(()=>{var IN=Object.create;var Fw=Object.defineProperty;var BN=Object.getOwnPropertyDescriptor;var $N=Object.getOwnPropertyNames;var TN=Object.getPrototypeOf,PN=Object.prototype.hasOwnProperty;var Iw=(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),xN=(e,t)=>{for(var r in t)Fw(e,r,{get:t[r],enumerable:!0})},RN=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of $N(t))!PN.call(e,i)&&i!==r&&Fw(e,i,{get:()=>t[i],enumerable:!(n=BN(t,i))||n.enumerable});return e};var B=(e,t,r)=>(r=e!=null?IN(TN(e)):{},RN(t||!e||!e.__esModule?Fw(r,"default",{value:e,enumerable:!0}):r,e));var hi=Ce((Bw,F5)=>{"use strict";var mne=B(T()),Pd=function(e){return e&&e.Math===Math&&e};F5.exports=Pd(typeof globalThis=="object"&&globalThis)||Pd(typeof window=="object"&&window)||Pd(typeof self=="object"&&self)||Pd(typeof global=="object"&&global)||Pd(typeof Bw=="object"&&Bw)||function(){return this}()||Function("return this")()});var Wa=Ce((gne,I5)=>{"use strict";var vne=B(T());I5.exports=function(e){try{return!!e()}catch{return!0}}});var tc=Ce((wne,B5)=>{"use strict";var yne=B(T()),kN=Wa();B5.exports=!kN(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var $w=Ce((Ene,$5)=>{"use strict";var bne=B(T()),ON=Wa();$5.exports=!ON(function(){var e=function(){}.bind();return typeof e!="function"||e.hasOwnProperty("prototype")})});var D1=Ce((Ane,T5)=>{"use strict";var Sne=B(T()),NN=$w(),_1=Function.prototype.call;T5.exports=NN?_1.bind(_1):function(){return _1.apply(_1,arguments)}});var k5=Ce(R5=>{"use strict";var _ne=B(T()),P5={}.propertyIsEnumerable,x5=Object.getOwnPropertyDescriptor,LN=x5&&!P5.call({1:2},1);R5.f=LN?function(t){var r=x5(this,t);return!!r&&r.enumerable}:P5});var Tw=Ce((Dne,O5)=>{"use strict";var Fne=B(T());O5.exports=function(e,t){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:t}}});var Mo=Ce((Ine,U5)=>{"use strict";var Bne=B(T()),N5=$w(),L5=Function.prototype,Pw=L5.call,UN=N5&&L5.bind.bind(Pw,Pw);U5.exports=N5?UN:function(e){return function(){return Pw.apply(e,arguments)}}});var q5=Ce(($ne,M5)=>{"use strict";var Tne=B(T()),H5=Mo(),HN=H5({}.toString),MN=H5("".slice);M5.exports=function(e){return MN(HN(e),8,-1)}});var K5=Ce((Pne,j5)=>{"use strict";var xne=B(T()),qN=Mo(),jN=Wa(),KN=q5(),xw=Object,VN=qN("".split);j5.exports=jN(function(){return!xw("z").propertyIsEnumerable(0)})?function(e){return KN(e)==="String"?VN(e,""):xw(e)}:xw});var Rw=Ce((Rne,V5)=>{"use strict";var kne=B(T());V5.exports=function(e){return e==null}});var kw=Ce((One,z5)=>{"use strict";var Nne=B(T()),zN=Rw(),GN=TypeError;z5.exports=function(e){if(zN(e))throw new GN("Can't call method on "+e);return e}});var F1=Ce((Lne,G5)=>{"use strict";var Une=B(T()),YN=K5(),WN=kw();G5.exports=function(e){return YN(WN(e))}});var Zi=Ce((Hne,Y5)=>{"use strict";var Mne=B(T()),Ow=typeof document=="object"&&document.all;Y5.exports=typeof Ow>"u"&&Ow!==void 0?function(e){return typeof e=="function"||e===Ow}:function(e){return typeof e=="function"}});var $f=Ce((qne,W5)=>{"use strict";var jne=B(T()),XN=Zi();W5.exports=function(e){return typeof e=="object"?e!==null:XN(e)}});var Lw=Ce((Kne,X5)=>{"use strict";var Vne=B(T()),Nw=hi(),JN=Zi(),ZN=function(e){return JN(e)?e:void 0};X5.exports=function(e,t){return arguments.length<2?ZN(Nw[e]):Nw[e]&&Nw[e][t]}});var Z5=Ce((zne,J5)=>{"use strict";var Gne=B(T()),QN=Mo();J5.exports=QN({}.isPrototypeOf)});var r4=Ce((Yne,t4)=>{"use strict";var Wne=B(T()),eL=hi(),Q5=eL.navigator,e4=Q5&&Q5.userAgent;t4.exports=e4?String(e4):""});var c4=Ce((Xne,u4)=>{"use strict";var Jne=B(T()),a4=hi(),Uw=r4(),n4=a4.process,s4=a4.Deno,i4=n4&&n4.versions||s4&&s4.version,o4=i4&&i4.v8,Qi,I1;o4&&(Qi=o4.split("."),I1=Qi[0]>0&&Qi[0]<4?1:+(Qi[0]+Qi[1]));!I1&&Uw&&(Qi=Uw.match(/Edge\/(\d+)/),(!Qi||Qi[1]>=74)&&(Qi=Uw.match(/Chrome\/(\d+)/),Qi&&(I1=+Qi[1])));u4.exports=I1});var Hw=Ce((Zne,f4)=>{"use strict";var Qne=B(T()),l4=c4(),tL=Wa(),rL=hi(),nL=rL.String;f4.exports=!!Object.getOwnPropertySymbols&&!tL(function(){var e=Symbol("symbol detection");return!nL(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&l4&&l4<41})});var Mw=Ce((ese,h4)=>{"use strict";var tse=B(T()),sL=Hw();h4.exports=sL&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var qw=Ce((rse,d4)=>{"use strict";var nse=B(T()),iL=Lw(),oL=Zi(),aL=Z5(),uL=Mw(),cL=Object;d4.exports=uL?function(e){return typeof e=="symbol"}:function(e){var t=iL("Symbol");return oL(t)&&aL(t.prototype,cL(e))}});var m4=Ce((sse,p4)=>{"use strict";var ise=B(T()),lL=String;p4.exports=function(e){try{return lL(e)}catch{return"Object"}}});var v4=Ce((ose,g4)=>{"use strict";var ase=B(T()),fL=Zi(),hL=m4(),dL=TypeError;g4.exports=function(e){if(fL(e))return e;throw new dL(hL(e)+" is not a function")}});var y4=Ce((use,w4)=>{"use strict";var cse=B(T()),pL=v4(),mL=Rw();w4.exports=function(e,t){var r=e[t];return mL(r)?void 0:pL(r)}});var b4=Ce((lse,E4)=>{"use strict";var fse=B(T()),jw=D1(),Kw=Zi(),Vw=$f(),gL=TypeError;E4.exports=function(e,t){var r,n;if(t==="string"&&Kw(r=e.toString)&&!Vw(n=jw(r,e))||Kw(r=e.valueOf)&&!Vw(n=jw(r,e))||t!=="string"&&Kw(r=e.toString)&&!Vw(n=jw(r,e)))return n;throw new gL("Can't convert object to primitive value")}});var S4=Ce((hse,A4)=>{"use strict";var dse=B(T());A4.exports=!1});var B1=Ce((pse,_4)=>{"use strict";var mse=B(T()),C4=hi(),vL=Object.defineProperty;_4.exports=function(e,t){try{vL(C4,e,{value:t,configurable:!0,writable:!0})}catch{C4[e]=t}return t}});var $1=Ce((gse,I4)=>{"use strict";var vse=B(T()),wL=S4(),yL=hi(),EL=B1(),D4="__core-js_shared__",F4=I4.exports=yL[D4]||EL(D4,{});(F4.versions||(F4.versions=[])).push({version:"3.49.0",mode:wL?"pure":"global",copyright:"\xA9 2013\u20132025 Denis Pushkarev (zloirock.ru), 2025\u20132026 CoreJS Company (core-js.io). All rights reserved.",license:"https://github.com/zloirock/core-js/blob/v3.49.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var zw=Ce((wse,$4)=>{"use strict";var yse=B(T()),B4=$1();$4.exports=function(e,t){return B4[e]||(B4[e]=t||{})}});var P4=Ce((Ese,T4)=>{"use strict";var bse=B(T()),bL=kw(),AL=Object;T4.exports=function(e){return AL(bL(e))}});var Xa=Ce((Ase,x4)=>{"use strict";var Sse=B(T()),SL=Mo(),CL=P4(),_L=SL({}.hasOwnProperty);x4.exports=Object.hasOwn||function(t,r){return _L(CL(t),r)}});var Gw=Ce((Cse,R4)=>{"use strict";var _se=B(T()),DL=Mo(),FL=0,IL=Math.random(),BL=DL(1.1.toString);R4.exports=function(e){return"Symbol("+(e===void 0?"":e)+")_"+BL(++FL+IL,36)}});var N4=Ce((Dse,O4)=>{"use strict";var Fse=B(T()),$L=hi(),TL=zw(),k4=Xa(),PL=Gw(),xL=Hw(),RL=Mw(),Tf=$L.Symbol,Yw=TL("wks"),kL=RL?Tf.for||Tf:Tf&&Tf.withoutSetter||PL;O4.exports=function(e){return k4(Yw,e)||(Yw[e]=xL&&k4(Tf,e)?Tf[e]:kL("Symbol."+e)),Yw[e]}});var M4=Ce((Ise,H4)=>{"use strict";var Bse=B(T()),OL=D1(),L4=$f(),U4=qw(),NL=y4(),LL=b4(),UL=N4(),HL=TypeError,ML=UL("toPrimitive");H4.exports=function(e,t){if(!L4(e)||U4(e))return e;var r=NL(e,ML),n;if(r){if(t===void 0&&(t="default"),n=OL(r,e,t),!L4(n)||U4(n))return n;throw new HL("Can't convert object to primitive value")}return t===void 0&&(t="number"),LL(e,t)}});var Ww=Ce(($se,q4)=>{"use strict";var Tse=B(T()),qL=M4(),jL=qw();q4.exports=function(e){var t=qL(e,"string");return jL(t)?t:t+""}});var V4=Ce((Pse,K4)=>{"use strict";var xse=B(T()),KL=hi(),j4=$f(),Xw=KL.document,VL=j4(Xw)&&j4(Xw.createElement);K4.exports=function(e){return VL?Xw.createElement(e):{}}});var Jw=Ce((Rse,z4)=>{"use strict";var kse=B(T()),zL=tc(),GL=Wa(),YL=V4();z4.exports=!zL&&!GL(function(){return Object.defineProperty(YL("div"),"a",{get:function(){return 7}}).a!==7})});var Zw=Ce(Y4=>{"use strict";var Nse=B(T()),WL=tc(),XL=D1(),JL=k5(),ZL=Tw(),QL=F1(),eU=Ww(),tU=Xa(),rU=Jw(),G4=Object.getOwnPropertyDescriptor;Y4.f=WL?G4:function(t,r){if(t=QL(t),r=eU(r),rU)try{return G4(t,r)}catch{}if(tU(t,r))return ZL(!XL(JL.f,t,r),t[r])}});var X4=Ce((Lse,W4)=>{"use strict";var Use=B(T()),nU=tc(),sU=Wa();W4.exports=nU&&sU(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Qw=Ce((Hse,J4)=>{"use strict";var Mse=B(T()),iU=$f(),oU=String,aU=TypeError;J4.exports=function(e){if(iU(e))return e;throw new aU(oU(e)+" is not an object")}});var P1=Ce(Q4=>{"use strict";var jse=B(T()),uU=tc(),cU=Jw(),lU=X4(),T1=Qw(),Z4=Ww(),fU=TypeError,ey=Object.defineProperty,hU=Object.getOwnPropertyDescriptor,ty="enumerable",ry="configurable",ny="writable";Q4.f=uU?lU?function(t,r,n){if(T1(t),r=Z4(r),T1(n),typeof t=="function"&&r==="prototype"&&"value"in n&&ny in n&&!n[ny]){var i=hU(t,r);i&&i[ny]&&(t[r]=n.value,n={configurable:ry in n?n[ry]:i[ry],enumerable:ty in n?n[ty]:i[ty],writable:!1})}return ey(t,r,n)}:ey:function(t,r,n){if(T1(t),r=Z4(r),T1(n),cU)try{return ey(t,r,n)}catch{}if("get"in n||"set"in n)throw new fU("Accessors not supported");return"value"in n&&(t[r]=n.value),t}});var sy=Ce((Kse,eC)=>{"use strict";var Vse=B(T()),dU=tc(),pU=P1(),mU=Tw();eC.exports=dU?function(e,t,r){return pU.f(e,t,mU(1,r))}:function(e,t,r){return e[t]=r,e}});var nC=Ce((zse,rC)=>{"use strict";var Gse=B(T()),iy=tc(),gU=Xa(),tC=Function.prototype,vU=iy&&Object.getOwnPropertyDescriptor,oy=gU(tC,"name"),wU=oy&&function(){}.name==="something",yU=oy&&(!iy||iy&&vU(tC,"name").configurable);rC.exports={EXISTS:oy,PROPER:wU,CONFIGURABLE:yU}});var iC=Ce((Yse,sC)=>{"use strict";var Wse=B(T()),EU=Mo(),bU=Zi(),ay=$1(),AU=EU(Function.toString);bU(ay.inspectSource)||(ay.inspectSource=function(e){return AU(e)});sC.exports=ay.inspectSource});var uC=Ce((Xse,aC)=>{"use strict";var Jse=B(T()),SU=hi(),CU=Zi(),oC=SU.WeakMap;aC.exports=CU(oC)&&/native code/.test(String(oC))});var fC=Ce((Zse,lC)=>{"use strict";var Qse=B(T()),_U=zw(),DU=Gw(),cC=_U("keys");lC.exports=function(e){return cC[e]||(cC[e]=DU(e))}});var uy=Ce((eie,hC)=>{"use strict";var tie=B(T());hC.exports={}});var gC=Ce((rie,mC)=>{"use strict";var nie=B(T()),FU=uC(),pC=hi(),IU=$f(),BU=sy(),cy=Xa(),ly=$1(),$U=fC(),TU=uy(),dC="Object already initialized",fy=pC.TypeError,PU=pC.WeakMap,x1,xd,R1,xU=function(e){return R1(e)?xd(e):x1(e,{})},RU=function(e){return function(t){var r;if(!IU(t)||(r=xd(t)).type!==e)throw new fy("Incompatible receiver, "+e+" required");return r}};FU||ly.state?(eo=ly.state||(ly.state=new PU),eo.get=eo.get,eo.has=eo.has,eo.set=eo.set,x1=function(e,t){if(eo.has(e))throw new fy(dC);return t.facade=e,eo.set(e,t),t},xd=function(e){return eo.get(e)||{}},R1=function(e){return eo.has(e)}):(dl=$U("state"),TU[dl]=!0,x1=function(e,t){if(cy(e,dl))throw new fy(dC);return t.facade=e,BU(e,dl,t),t},xd=function(e){return cy(e,dl)?e[dl]:{}},R1=function(e){return cy(e,dl)});var eo,dl;mC.exports={set:x1,get:xd,has:R1,enforce:xU,getterFor:RU}});var EC=Ce((sie,yC)=>{"use strict";var iie=B(T()),dy=Mo(),kU=Wa(),OU=Zi(),k1=Xa(),hy=tc(),NU=nC().CONFIGURABLE,LU=iC(),wC=gC(),UU=wC.enforce,HU=wC.get,vC=String,O1=Object.defineProperty,MU=dy("".slice),qU=dy("".replace),jU=dy([].join),KU=hy&&!kU(function(){return O1(function(){},"length",{value:8}).length!==8}),VU=String(String).split("String"),zU=yC.exports=function(e,t,r){MU(vC(t),0,7)==="Symbol("&&(t="["+qU(vC(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),r&&r.getter&&(t="get "+t),r&&r.setter&&(t="set "+t),(!k1(e,"name")||NU&&e.name!==t)&&(hy?O1(e,"name",{value:t,configurable:!0}):e.name=t),KU&&r&&k1(r,"arity")&&e.length!==r.arity&&O1(e,"length",{value:r.arity});try{r&&k1(r,"constructor")&&r.constructor?hy&&O1(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch{}var n=UU(e);return k1(n,"source")||(n.source=jU(VU,typeof t=="string"?t:"")),e};Function.prototype.toString=zU(function(){return OU(this)&&HU(this).source||LU(this)},"toString")});var AC=Ce((oie,bC)=>{"use strict";var aie=B(T()),GU=Zi(),YU=P1(),WU=EC(),XU=B1();bC.exports=function(e,t,r,n){n||(n={});var i=n.enumerable,o=n.name!==void 0?n.name:t;if(GU(r)&&WU(r,o,n),n.global)i?e[t]=r:XU(t,r);else{try{n.unsafe?e[t]&&(i=!0):delete e[t]}catch{}i?e[t]=r:YU.f(e,t,{value:r,enumerable:!1,configurable:!n.nonConfigurable,writable:!n.nonWritable})}return e}});var CC=Ce((uie,SC)=>{"use strict";var cie=B(T()),JU=Math.ceil,ZU=Math.floor;SC.exports=Math.trunc||function(t){var r=+t;return(r>0?ZU:JU)(r)}});var py=Ce((lie,_C)=>{"use strict";var fie=B(T()),QU=CC();_C.exports=function(e){var t=+e;return t!==t||t===0?0:QU(t)}});var FC=Ce((hie,DC)=>{"use strict";var die=B(T()),eH=py(),tH=Math.max,rH=Math.min;DC.exports=function(e,t){var r=eH(e);return r<0?tH(r+t,0):rH(r,t)}});var BC=Ce((pie,IC)=>{"use strict";var mie=B(T()),nH=py(),sH=Math.min;IC.exports=function(e){var t=nH(e);return t>0?sH(t,9007199254740991):0}});var TC=Ce((gie,$C)=>{"use strict";var vie=B(T()),iH=BC();$C.exports=function(e){return iH(e.length)}});var RC=Ce((wie,xC)=>{"use strict";var yie=B(T()),oH=F1(),aH=FC(),uH=TC(),PC=function(e){return function(t,r,n){var i=oH(t),o=uH(i);if(o===0)return!e&&-1;var s=aH(n,o),a;if(e&&r!==r){for(;o>s;)if(a=i[s++],a!==a)return!0}else for(;o>s;s++)if((e||s in i)&&i[s]===r)return e||s||0;return!e&&-1}};xC.exports={includes:PC(!0),indexOf:PC(!1)}});var NC=Ce((Eie,OC)=>{"use strict";var bie=B(T()),cH=Mo(),my=Xa(),lH=F1(),fH=RC().indexOf,hH=uy(),kC=cH([].push);OC.exports=function(e,t){var r=lH(e),n=0,i=[],o;for(o in r)!my(hH,o)&&my(r,o)&&kC(i,o);for(;t.length>n;)my(r,o=t[n++])&&(~fH(i,o)||kC(i,o));return i}});var UC=Ce((Aie,LC)=>{"use strict";var Sie=B(T());LC.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var MC=Ce(HC=>{"use strict";var _ie=B(T()),dH=NC(),pH=UC(),mH=pH.concat("length","prototype");HC.f=Object.getOwnPropertyNames||function(t){return dH(t,mH)}});var jC=Ce(qC=>{"use strict";var Fie=B(T());qC.f=Object.getOwnPropertySymbols});var VC=Ce((Iie,KC)=>{"use strict";var Bie=B(T()),gH=Lw(),vH=Mo(),wH=MC(),yH=jC(),EH=Qw(),bH=vH([].concat);KC.exports=gH("Reflect","ownKeys")||function(t){var r=wH.f(EH(t)),n=yH.f;return n?bH(r,n(t)):r}});var YC=Ce(($ie,GC)=>{"use strict";var Tie=B(T()),zC=Xa(),AH=VC(),SH=Zw(),CH=P1();GC.exports=function(e,t,r){for(var n=AH(t),i=CH.f,o=SH.f,s=0;s{"use strict";var xie=B(T()),_H=Wa(),DH=Zi(),FH=/#|\.prototype\./,Rd=function(e,t){var r=BH[IH(e)];return r===TH?!0:r===$H?!1:DH(t)?_H(t):!!t},IH=Rd.normalize=function(e){return String(e).replace(FH,".").toLowerCase()},BH=Rd.data={},$H=Rd.NATIVE="N",TH=Rd.POLYFILL="P";WC.exports=Rd});var ZC=Ce((Rie,JC)=>{"use strict";var kie=B(T()),N1=hi(),PH=Zw().f,xH=sy(),RH=AC(),kH=B1(),OH=YC(),NH=XC();JC.exports=function(e,t){var r=e.target,n=e.global,i=e.stat,o,s,a,u,l,f;if(n?s=N1:i?s=N1[r]||kH(r,{}):s=N1[r]&&N1[r].prototype,s)for(a in t){if(l=t[a],e.dontCallGetSet?(f=PH(s,a),u=f&&f.value):u=s[a],o=NH(n?a:r+(i?".":"#")+a,e.forced),!o&&u!==void 0){if(typeof l==typeof u)continue;OH(l,u)}(e.sham||u&&u.sham)&&xH(l,"sham",!0),RH(s,a,l,e)}}});var QC=Ce(()=>{"use strict";var Lie=B(T()),LH=ZC(),UH=Xa();LH({target:"Object",stat:!0},{hasOwn:UH})});var t_=Ce((Uie,e_)=>{"use strict";var Hie=B(T()),HH=hi();e_.exports=HH});var n_=Ce((Mie,r_)=>{"use strict";var qie=B(T());QC();var MH=t_();r_.exports=MH.Object.hasOwn});var i_=Ce((jie,s_)=>{"use strict";var Kie=B(T()),qH=n_();s_.exports=qH});var T=Ce((Vie,o_)=>{"use strict";var jH=i_();o_.exports=jH});var c_=Ce(u_=>{"use strict";var Xie=B(T());(function(e){function t(){}function r(){}var n=String.fromCharCode,i={}.toString,o=i.call(e.SharedArrayBuffer),s=i(),a=e.Uint8Array,u=a||Array,l=a?ArrayBuffer:u,f=l.isView||function(v){return v&&"length"in v},m=i.call(l.prototype);l=r.prototype;var p=e.TextEncoder,d=new(a?Uint16Array:u)(32);t.prototype.decode=function(v){if(!f(v)){var g=i.call(v);if(g!==m&&g!==o&&g!==s)throw TypeError("Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");v=a?new u(v):v||[]}for(var y=g="",w=0,E=v.length|0,S=E-32|0,D,F,M=0,z=0,C,P=0,U=-1;w>4){case 15:if(C=v[w=w+1|0]&255,C>>6!==2||247>6===2?z+4|0:24,F=F+256&768;case 13:case 12:C=v[w=w+1|0]&255,M<<=6,M|=(F&31)<<6|C&63,z=z+7|0,w>6===2&&M>>z&&1114112>M?(F=M,M=M-65536|0,0<=M&&(U=(M>>10)+55296|0,F=(M&1023)+56320|0,31>P?(d[P]=U,P=P+1|0,U=-1):(C=U,U=F,F=C))):(F>>=8,w=w-F-1|0,F=65533),M=z=0,D=w<=S?32:E-w|0;default:d[P]=F;continue;case 11:case 10:case 9:case 8:}d[P]=65533}if(y+=n(d[0],d[1],d[2],d[3],d[4],d[5],d[6],d[7],d[8],d[9],d[10],d[11],d[12],d[13],d[14],d[15],d[16],d[17],d[18],d[19],d[20],d[21],d[22],d[23],d[24],d[25],d[26],d[27],d[28],d[29],d[30],d[31]),32>P&&(y=y.slice(0,P-32|0)),w>>31,U=-1,y.length=D)y[E]=D;else{if(2047>=D)y[E]=192|D>>6;else{e:{if(55296<=D)if(56319>=D){var F=v.charCodeAt(w=w+1|0)|0;if(56320<=F&&57343>=F){if(D=(D<<10)+F-56613888|0,65535>18,y[E=E+1|0]=128|D>>12&63,y[E=E+1|0]=128|D>>6&63,y[E=E+1|0]=128|D&63;continue}break e}D=65533}else 57343>=D&&(D=65533);!S&&w<<1>12,y[E=E+1|0]=128|D>>6&63}y[E=E+1|0]=128|D&63}}return a?y.subarray(0,E):y.slice(0,E)},p||(e.TextDecoder=t,e.TextEncoder=r)})(typeof global>"u"?typeof self>"u"?u_:self:global)});var $y=Ce(Nf=>{"use strict";var Loe=B(T());Object.defineProperty(Nf,"__esModule",{value:!0});Nf.isCorrect=Nf.isInSubnet=void 0;function UM(e){return this.subnetMask{"use strict";var Hoe=B(T());Object.defineProperty(zo,"__esModule",{value:!0});zo.RE_SUBNET_STRING=zo.RE_ADDRESS=zo.GROUPS=zo.BITS=void 0;zo.BITS=32;zo.GROUPS=4;zo.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;zo.RE_SUBNET_STRING=/\/\d{1,2}$/});var X1=Ce(W1=>{"use strict";var qoe=B(T());Object.defineProperty(W1,"__esModule",{value:!0});W1.AddressError=void 0;var Py=class extends Error{constructor(t,r){super(t),this.name="AddressError",r!==null&&(this.parseMessage=r)}};W1.AddressError=Py});var xy=Ce((J1,d8)=>{var joe=B(T());(function(){var e,t=0xdeadbeefcafe,r=(t&16777215)==15715070;function n(j,G,Q){j!=null&&(typeof j=="number"?this.fromNumber(j,G,Q):G==null&&typeof j!="string"?this.fromString(j,256):this.fromString(j,G))}function i(){return new n(null)}function o(j,G,Q,ae,Ie,Pe){for(;--Pe>=0;){var Me=G*this[j++]+Q[ae]+Ie;Ie=Math.floor(Me/67108864),Q[ae++]=Me&67108863}return Ie}function s(j,G,Q,ae,Ie,Pe){for(var Me=G&32767,ze=G>>15;--Pe>=0;){var fr=this[j]&32767,Or=this[j++]>>15,Zn=ze*fr+Or*Me;fr=Me*fr+((Zn&32767)<<15)+Q[ae]+(Ie&1073741823),Ie=(fr>>>30)+(Zn>>>15)+ze*Or+(Ie>>>30),Q[ae++]=fr&1073741823}return Ie}function a(j,G,Q,ae,Ie,Pe){for(var Me=G&16383,ze=G>>14;--Pe>=0;){var fr=this[j]&16383,Or=this[j++]>>14,Zn=ze*fr+Or*Me;fr=Me*fr+((Zn&16383)<<14)+Q[ae]+Ie,Ie=(fr>>28)+(Zn>>14)+ze*Or,Q[ae++]=fr&268435455}return Ie}var u=typeof navigator<"u";u&&r&&navigator.appName=="Microsoft Internet Explorer"?(n.prototype.am=s,e=30):u&&r&&navigator.appName!="Netscape"?(n.prototype.am=o,e=26):(n.prototype.am=a,e=28),n.prototype.DB=e,n.prototype.DM=(1<=0;--G)j[G]=this[G];j.t=this.t,j.s=this.s}function w(j){this.t=1,this.s=j<0?-1:0,j>0?this[0]=j:j<-1?this[0]=j+this.DV:this.t=0}function E(j){var G=i();return G.fromInt(j),G}function S(j,G){var Q;if(G==16)Q=4;else if(G==8)Q=3;else if(G==256)Q=8;else if(G==2)Q=1;else if(G==32)Q=5;else if(G==4)Q=2;else{this.fromRadix(j,G);return}this.t=0,this.s=0;for(var ae=j.length,Ie=!1,Pe=0;--ae>=0;){var Me=Q==8?j[ae]&255:g(j,ae);if(Me<0){j.charAt(ae)=="-"&&(Ie=!0);continue}Ie=!1,Pe==0?this[this.t++]=Me:Pe+Q>this.DB?(this[this.t-1]|=(Me&(1<>this.DB-Pe):this[this.t-1]|=Me<=this.DB&&(Pe-=this.DB)}Q==8&&j[0]&128&&(this.s=-1,Pe>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==j;)--this.t}function F(j){if(this.s<0)return"-"+this.negate().toString(j);var G;if(j==16)G=4;else if(j==8)G=3;else if(j==2)G=1;else if(j==32)G=5;else if(j==4)G=2;else return this.toRadix(j);var Q=(1<0)for(ze>ze)>0&&(Ie=!0,Pe=v(ae));Me>=0;)ze>(ze+=this.DB-G)):(ae=this[Me]>>(ze-=G)&Q,ze<=0&&(ze+=this.DB,--Me)),ae>0&&(Ie=!0),Ie&&(Pe+=v(ae));return Ie?Pe:"0"}function M(){var j=i();return n.ZERO.subTo(this,j),j}function z(){return this.s<0?this.negate():this}function C(j){var G=this.s-j.s;if(G!=0)return G;var Q=this.t;if(G=Q-j.t,G!=0)return this.s<0?-G:G;for(;--Q>=0;)if((G=this[Q]-j[Q])!=0)return G;return 0}function P(j){var G=1,Q;return(Q=j>>>16)!=0&&(j=Q,G+=16),(Q=j>>8)!=0&&(j=Q,G+=8),(Q=j>>4)!=0&&(j=Q,G+=4),(Q=j>>2)!=0&&(j=Q,G+=2),(Q=j>>1)!=0&&(j=Q,G+=1),G}function U(){return this.t<=0?0:this.DB*(this.t-1)+P(this[this.t-1]^this.s&this.DM)}function k(j,G){var Q;for(Q=this.t-1;Q>=0;--Q)G[Q+j]=this[Q];for(Q=j-1;Q>=0;--Q)G[Q]=0;G.t=this.t+j,G.s=this.s}function O(j,G){for(var Q=j;Q=0;--ze)G[ze+Pe+1]=this[ze]>>ae|Me,Me=(this[ze]&Ie)<=0;--ze)G[ze]=0;G[Pe]=Me,G.t=this.t+Pe+1,G.s=this.s,G.clamp()}function N(j,G){G.s=this.s;var Q=Math.floor(j/this.DB);if(Q>=this.t){G.t=0;return}var ae=j%this.DB,Ie=this.DB-ae,Pe=(1<>ae;for(var Me=Q+1;Me>ae;ae>0&&(G[this.t-Q-1]|=(this.s&Pe)<>=this.DB;if(j.t>=this.DB;ae+=this.s}else{for(ae+=this.s;Q>=this.DB;ae-=j.s}G.s=ae<0?-1:0,ae<-1?G[Q++]=this.DV+ae:ae>0&&(G[Q++]=ae),G.t=Q,G.clamp()}function R(j,G){var Q=this.abs(),ae=j.abs(),Ie=Q.t;for(G.t=Ie+ae.t;--Ie>=0;)G[Ie]=0;for(Ie=0;Ie=0;)j[Q]=0;for(Q=0;Q=G.DV&&(j[Q+G.t]-=G.DV,j[Q+G.t+1]=1)}j.t>0&&(j[j.t-1]+=G.am(Q,G[Q],j,2*Q,0,1)),j.s=0,j.clamp()}function Z(j,G,Q){var ae=j.abs();if(!(ae.t<=0)){var Ie=this.abs();if(Ie.t0?(ae.lShiftTo(fr,Pe),Ie.lShiftTo(fr,Q)):(ae.copyTo(Pe),Ie.copyTo(Q));var Or=Pe.t,Zn=Pe[Or-1];if(Zn!=0){var wn=Zn*(1<1?Pe[Or-2]>>this.F2:0),oi=this.FV/wn,Vu=(1<=0&&(Q[Q.t++]=1,Q.subTo(Ci,Q)),n.ONE.dlShiftTo(Or,Ci),Ci.subTo(Pe,Pe);Pe.t=0;){var tl=Q[--bs]==Zn?this.DM:Math.floor(Q[bs]*oi+(Q[bs-1]+Es)*Vu);if((Q[bs]+=Pe.am(0,tl,Q,ko,0,Or))0&&Q.rShiftTo(fr,Q),Me<0&&n.ZERO.subTo(Q,Q)}}}function Y(j){var G=i();return this.abs().divRemTo(j,null,G),this.s<0&&G.compareTo(n.ZERO)>0&&j.subTo(G,G),G}function te(j){this.m=j}function se(j){return j.s<0||j.compareTo(this.m)>=0?j.mod(this.m):j}function fe(j){return j}function ve(j){j.divRemTo(this.m,null,j)}function we(j,G,Q){j.multiplyTo(G,Q),this.reduce(Q)}function Te(j,G){j.squareTo(G),this.reduce(G)}te.prototype.convert=se,te.prototype.revert=fe,te.prototype.reduce=ve,te.prototype.mulTo=we,te.prototype.sqrTo=Te;function Le(){if(this.t<1)return 0;var j=this[0];if(!(j&1))return 0;var G=j&3;return G=G*(2-(j&15)*G)&15,G=G*(2-(j&255)*G)&255,G=G*(2-((j&65535)*G&65535))&65535,G=G*(2-j*G%this.DV)%this.DV,G>0?this.DV-G:-G}function Oe(j){this.m=j,this.mp=j.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(G,G),G}function Se(j){var G=i();return j.copyTo(G),this.reduce(G),G}function Re(j){for(;j.t<=this.mt2;)j[j.t++]=0;for(var G=0;G>15)*this.mpl&this.um)<<15)&j.DM;for(Q=G+this.m.t,j[Q]+=this.m.am(0,ae,j,G,0,this.m.t);j[Q]>=j.DV;)j[Q]-=j.DV,j[++Q]++}j.clamp(),j.drShiftTo(this.m.t,j),j.compareTo(this.m)>=0&&j.subTo(this.m,j)}function Ve(j,G){j.squareTo(G),this.reduce(G)}function rt(j,G,Q){j.multiplyTo(G,Q),this.reduce(Q)}Oe.prototype.convert=le,Oe.prototype.revert=Se,Oe.prototype.reduce=Re,Oe.prototype.mulTo=rt,Oe.prototype.sqrTo=Ve;function qe(){return(this.t>0?this[0]&1:this.s)==0}function At(j,G){if(j>4294967295||j<1)return n.ONE;var Q=i(),ae=i(),Ie=G.convert(this),Pe=P(j)-1;for(Ie.copyTo(Q);--Pe>=0;)if(G.sqrTo(Q,ae),(j&1<0)G.mulTo(ae,Ie,Q);else{var Me=Q;Q=ae,ae=Me}return G.revert(Q)}function it(j,G){var Q;return j<256||G.isEven()?Q=new te(G):Q=new Oe(G),this.exp(j,Q)}n.prototype.copyTo=y,n.prototype.fromInt=w,n.prototype.fromString=S,n.prototype.clamp=D,n.prototype.dlShiftTo=k,n.prototype.drShiftTo=O,n.prototype.lShiftTo=q,n.prototype.rShiftTo=N,n.prototype.subTo=_,n.prototype.multiplyTo=R,n.prototype.squareTo=K,n.prototype.divRemTo=Z,n.prototype.invDigit=Le,n.prototype.isEven=qe,n.prototype.exp=At,n.prototype.toString=F,n.prototype.negate=M,n.prototype.abs=z,n.prototype.compareTo=C,n.prototype.bitLength=U,n.prototype.mod=Y,n.prototype.modPowInt=it,n.ZERO=E(0),n.ONE=E(1);function Et(){var j=i();return this.copyTo(j),j}function pn(){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 Br(){return this.t==0?this.s:this[0]<<16>>16}function bt(j){return Math.floor(Math.LN2*this.DB/Math.log(j))}function Mr(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function Yn(j){if(j==null&&(j=10),this.signum()==0||j<2||j>36)return"0";var G=this.chunkSize(j),Q=Math.pow(j,G),ae=E(Q),Ie=i(),Pe=i(),Me="";for(this.divRemTo(ae,Ie,Pe);Ie.signum()>0;)Me=(Q+Pe.intValue()).toString(j).substr(1)+Me,Ie.divRemTo(ae,Ie,Pe);return Pe.intValue().toString(j)+Me}function ni(j,G){this.fromInt(0),G==null&&(G=10);for(var Q=this.chunkSize(G),ae=Math.pow(G,Q),Ie=!1,Pe=0,Me=0,ze=0;ze=Q&&(this.dMultiply(ae),this.dAddOffset(Me,0),Pe=0,Me=0)}Pe>0&&(this.dMultiply(Math.pow(G,Pe)),this.dAddOffset(Me,0)),Ie&&n.ZERO.subTo(this,this)}function Rt(j,G,Q){if(typeof G=="number")if(j<2)this.fromInt(1);else for(this.fromNumber(j,Q),this.testBit(j-1)||this.bitwiseTo(n.ONE.shiftLeft(j-1),De,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(G);)this.dAddOffset(2,0),this.bitLength()>j&&this.subTo(n.ONE.shiftLeft(j-1),this);else{var ae=new Array,Ie=j&7;ae.length=(j>>3)+1,G.nextBytes(ae),Ie>0?ae[0]&=(1<0)for(Q>Q)!=(this.s&this.DM)>>Q&&(G[Ie++]=ae|this.s<=0;)Q<8?(ae=(this[j]&(1<>(Q+=this.DB-8)):(ae=this[j]>>(Q-=8)&255,Q<=0&&(Q+=this.DB,--j)),ae&128&&(ae|=-256),Ie==0&&(this.s&128)!=(ae&128)&&++Ie,(Ie>0||ae!=this.s)&&(G[Ie++]=ae);return G}function Ue(j){return this.compareTo(j)==0}function Ar(j){return this.compareTo(j)<0?this:j}function In(j){return this.compareTo(j)>0?this:j}function St(j,G,Q){var ae,Ie,Pe=Math.min(j.t,this.t);for(ae=0;ae>=16,G+=16),j&255||(j>>=8,G+=8),j&15||(j>>=4,G+=4),j&3||(j>>=2,G+=2),j&1||++G,G}function Qt(){for(var j=0;j=this.t?this.s!=0:(this[G]&1<>=this.DB;if(j.t>=this.DB;ae+=this.s}else{for(ae+=this.s;Q>=this.DB;ae+=j.s}G.s=ae<0?-1:0,ae>0?G[Q++]=ae:ae<-1&&(G[Q++]=this.DV+ae),G.t=Q,G.clamp()}function Wc(j){var G=i();return this.addTo(j,G),G}function ue(j){var G=i();return this.subTo(j,G),G}function Ee(j){var G=i();return this.multiplyTo(j,G),G}function Qe(){var j=i();return this.squareTo(j),j}function Xe(j){var G=i();return this.divRemTo(j,G,null),G}function ut(j){var G=i();return this.divRemTo(j,null,G),G}function Ct(j){var G=i(),Q=i();return this.divRemTo(j,G,Q),new Array(G,Q)}function Dt(j){this[this.t]=this.am(0,j-1,this,0,0,this.t),++this.t,this.clamp()}function qr(j,G){if(j!=0){for(;this.t<=G;)this[this.t++]=0;for(this[G]+=j;this[G]>=this.DV;)this[G]-=this.DV,++G>=this.t&&(this[this.t++]=0),++this[G]}}function lr(){}function vs(j){return j}function Ai(j,G,Q){j.multiplyTo(G,Q)}function $n(j,G){j.squareTo(G)}lr.prototype.convert=vs,lr.prototype.revert=vs,lr.prototype.mulTo=Ai,lr.prototype.sqrTo=$n;function Wn(j){return this.exp(j,new lr)}function Rr(j,G,Q){var ae=Math.min(this.t+j.t,G);for(Q.s=0,Q.t=ae;ae>0;)Q[--ae]=0;var Ie;for(Ie=Q.t-this.t;ae=0;)Q[ae]=0;for(ae=Math.max(G-this.t,0);ae2*this.m.t)return j.mod(this.m);if(j.compareTo(this.m)<0)return j;var G=i();return j.copyTo(G),this.reduce(G),G}function Xc(j){return j}function gn(j){for(j.drShiftTo(this.m.t-1,this.r2),j.t>this.m.t+1&&(j.t=this.m.t+1,j.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);j.compareTo(this.r2)<0;)j.dAddOffset(1,this.m.t+1);for(j.subTo(this.r2,j);j.compareTo(this.m)>=0;)j.subTo(this.m,j)}function Xt(j,G){j.squareTo(G),this.reduce(G)}function kr(j,G,Q){j.multiplyTo(G,Q),this.reduce(Q)}Xn.prototype.convert=Ro,Xn.prototype.revert=Xc,Xn.prototype.reduce=gn,Xn.prototype.mulTo=kr,Xn.prototype.sqrTo=Xt;function wt(j,G){var Q=j.bitLength(),ae,Ie=E(1),Pe;if(Q<=0)return Ie;Q<18?ae=1:Q<48?ae=3:Q<144?ae=4:Q<768?ae=5:ae=6,Q<8?Pe=new te(G):G.isEven()?Pe=new Xn(G):Pe=new Oe(G);var Me=new Array,ze=3,fr=ae-1,Or=(1<1){var Zn=i();for(Pe.sqrTo(Me[1],Zn);ze<=Or;)Me[ze]=i(),Pe.mulTo(Zn,Me[ze-2],Me[ze]),ze+=2}var wn=j.t-1,oi,Vu=!0,Es=i(),bs;for(Q=P(j[wn])-1;wn>=0;){for(Q>=fr?oi=j[wn]>>Q-fr&Or:(oi=(j[wn]&(1<0&&(oi|=j[wn-1]>>this.DB+Q-fr)),ze=ae;!(oi&1);)oi>>=1,--ze;if((Q-=ze)<0&&(Q+=this.DB,--wn),Vu)Me[oi].copyTo(Ie),Vu=!1;else{for(;ze>1;)Pe.sqrTo(Ie,Es),Pe.sqrTo(Es,Ie),ze-=2;ze>0?Pe.sqrTo(Ie,Es):(bs=Ie,Ie=Es,Es=bs),Pe.mulTo(Es,Me[oi],Ie)}for(;wn>=0&&!(j[wn]&1<0&&(G.rShiftTo(Pe,G),Q.rShiftTo(Pe,Q));G.signum()>0;)(Ie=G.getLowestSetBit())>0&&G.rShiftTo(Ie,G),(Ie=Q.getLowestSetBit())>0&&Q.rShiftTo(Ie,Q),G.compareTo(Q)>=0?(G.subTo(Q,G),G.rShiftTo(1,G)):(Q.subTo(G,Q),Q.rShiftTo(1,Q));return Pe>0&&Q.lShiftTo(Pe,Q),Q}function vn(j){if(j<=0)return 0;var G=this.DV%j,Q=this.s<0?j-1:0;if(this.t>0)if(G==0)Q=this[0]%j;else for(var ae=this.t-1;ae>=0;--ae)Q=(G*Q+this[ae])%j;return Q}function yr(j){var G=j.isEven();if(this.isEven()&&G||j.signum()==0)return n.ZERO;for(var Q=j.clone(),ae=this.clone(),Ie=E(1),Pe=E(0),Me=E(0),ze=E(1);Q.signum()!=0;){for(;Q.isEven();)Q.rShiftTo(1,Q),G?((!Ie.isEven()||!Pe.isEven())&&(Ie.addTo(this,Ie),Pe.subTo(j,Pe)),Ie.rShiftTo(1,Ie)):Pe.isEven()||Pe.subTo(j,Pe),Pe.rShiftTo(1,Pe);for(;ae.isEven();)ae.rShiftTo(1,ae),G?((!Me.isEven()||!ze.isEven())&&(Me.addTo(this,Me),ze.subTo(j,ze)),Me.rShiftTo(1,Me)):ze.isEven()||ze.subTo(j,ze),ze.rShiftTo(1,ze);Q.compareTo(ae)>=0?(Q.subTo(ae,Q),G&&Ie.subTo(Me,Ie),Pe.subTo(ze,Pe)):(ae.subTo(Q,ae),G&&Me.subTo(Ie,Me),ze.subTo(Pe,ze))}if(ae.compareTo(n.ONE)!=0)return n.ZERO;if(ze.compareTo(j)>=0)return ze.subtract(j);if(ze.signum()<0)ze.addTo(j,ze);else return ze;return ze.signum()<0?ze.add(j):ze}var or=[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],ws=(1<<26)/or[or.length-1];function Ls(j){var G,Q=this.abs();if(Q.t==1&&Q[0]<=or[or.length-1]){for(G=0;G>1,j>or.length&&(j=or.length);for(var Ie=i(),Pe=0;Pe>8&255,en[$r++]^=j>>16&255,en[$r++]^=j>>24&255,$r>=Si&&($r-=Si)}function hf(){Jc(new Date().getTime())}if(en==null){en=new Array,$r=0;var Jn;if(typeof window<"u"&&window.crypto){if(window.crypto.getRandomValues){var Pa=new Uint8Array(32);for(window.crypto.getRandomValues(Pa),Jn=0;Jn<32;++Jn)en[$r++]=Pa[Jn]}else if(navigator.appName=="Netscape"&&navigator.appVersion<"5"){var Zc=window.crypto.random(32);for(Jn=0;Jn>>8,en[$r++]=Jn&255;$r=0,hf()}function ed(){if(ys==null){for(hf(),ys=el(),ys.init(en),$r=0;$r{var Voe=B(T());(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(o(s),arguments)}function r(s,a){return t.apply(null,[s].concat(a||[]))}function n(s,a){var u=1,l=s.length,f,m="",p,d,v,g,y,w,E,S;for(p=0;p=0),v.type){case"b":f=parseInt(f,10).toString(2);break;case"c":f=String.fromCharCode(parseInt(f,10));break;case"d":case"i":f=parseInt(f,10);break;case"j":f=JSON.stringify(f,null,v.width?parseInt(v.width):0);break;case"e":f=v.precision?parseFloat(f).toExponential(v.precision):parseFloat(f).toExponential();break;case"f":f=v.precision?parseFloat(f).toFixed(v.precision):parseFloat(f);break;case"g":f=v.precision?String(Number(f.toPrecision(v.precision))):parseFloat(f);break;case"o":f=(parseInt(f,10)>>>0).toString(8);break;case"s":f=String(f),f=v.precision?f.substring(0,v.precision):f;break;case"t":f=String(!!f),f=v.precision?f.substring(0,v.precision):f;break;case"T":f=Object.prototype.toString.call(f).slice(8,-1).toLowerCase(),f=v.precision?f.substring(0,v.precision):f;break;case"u":f=parseInt(f,10)>>>0;break;case"v":f=f.valueOf(),f=v.precision?f.substring(0,v.precision):f;break;case"x":f=(parseInt(f,10)>>>0).toString(16);break;case"X":f=(parseInt(f,10)>>>0).toString(16).toUpperCase();break}e.json.test(v.type)?m+=f:(e.number.test(v.type)&&(!E||v.sign)?(S=E?"+":"-",f=f.toString().replace(e.sign,"")):S="",y=v.pad_char?v.pad_char==="0"?"0":v.pad_char.charAt(1):" ",w=v.width-(S+f).length,g=v.width&&w>0?y.repeat(w):"",m+=v.align?S+f+g:y==="0"?S+g+f:g+S+f)}return m}var i=Object.create(null);function o(s){if(i[s])return i[s];for(var a=s,u,l=[],f=0;a;){if((u=e.text.exec(a))!==null)l.push(u[0]);else if((u=e.modulo.exec(a))!==null)l.push("%");else if((u=e.placeholder.exec(a))!==null){if(u[2]){f|=1;var m=[],p=u[2],d=[];if((d=e.key.exec(p))!==null)for(m.push(d[1]);(p=p.substring(d[0].length))!=="";)if((d=e.key_access.exec(p))!==null)m.push(d[1]);else if((d=e.index_access.exec(p))!==null)m.push(d[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");u[2]=m}else f|=2;if(f===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");l.push({placeholder:u[0],param_no:u[1],keys:u[2],sign:u[3],pad_char:u[4],align:u[5],width:u[6],precision:u[7],type:u[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");a=a.substring(u[0].length)}return i[s]=l}typeof Z1<"u"&&(Z1.sprintf=t,Z1.vsprintf=r),typeof window<"u"&&(window.sprintf=t,window.vsprintf=r,typeof define=="function"&&define.amd&&define(function(){return{sprintf:t,vsprintf:r}}))})()});var ky=Ce(Go=>{"use strict";var Goe=B(T()),MM=Go&&Go.__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]}),qM=Go&&Go.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),g8=Go&&Go.__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)&&MM(t,e,r);return qM(t,e),t};Object.defineProperty(Go,"__esModule",{value:!0});Go.Address4=void 0;var p8=g8($y()),to=g8(Ty()),m8=X1(),Hd=xy(),Lf=Ud(),Ry=class e{constructor(t){this.groups=to.GROUPS,this.parsedAddress=[],this.parsedSubnet="",this.subnet="/32",this.subnetMask=32,this.v4=!0,this.isCorrect=p8.isCorrect(to.BITS),this.isInSubnet=p8.isInSubnet,this.address=t;let r=to.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>to.BITS)throw new m8.AddressError("Invalid subnet mask.");t=t.replace(to.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(to.RE_ADDRESS))throw new m8.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 o=r.slice(i,i+2);n.push(parseInt(o,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,Lf.sprintf)("%02x",parseInt(t,10))).join(":")}toArray(){return this.parsedAddress.map(t=>parseInt(t,10))}toGroup6(){let t=[],r;for(r=0;r(0,Lf.sprintf)("%02x",parseInt(t,10))).join(""),16)}_startAddress(){return new Hd.BigInteger(this.mask()+"0".repeat(to.BITS-this.subnetMask),2)}startAddress(){return e.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new Hd.BigInteger("1");return e.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new Hd.BigInteger(this.mask()+"1".repeat(to.BITS-this.subnetMask),2)}endAddress(){return e.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new Hd.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,Lf.sprintf)("%s.in-addr.arpa.",r)}isMulticast(){return this.isInSubnet(new e("224.0.0.0/4"))}binaryZeroPad(){return this.bigInteger().toString(2).padStart(to.BITS,"0")}groupForV6(){let t=this.parsedAddress;return this.address.replace(to.RE_ADDRESS,(0,Lf.sprintf)('%s.%s',t.slice(0,2).join("."),t.slice(2,4).join(".")))}};Go.Address4=Ry});var Oy=Ce(Lr=>{"use strict";var Woe=B(T());Object.defineProperty(Lr,"__esModule",{value:!0});Lr.RE_URL_WITH_PORT=Lr.RE_URL=Lr.RE_ZONE_STRING=Lr.RE_SUBNET_STRING=Lr.RE_BAD_ADDRESS=Lr.RE_BAD_CHARACTERS=Lr.TYPES=Lr.SCOPES=Lr.GROUPS=Lr.BITS=void 0;Lr.BITS=128;Lr.GROUPS=8;Lr.SCOPES={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"};Lr.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"};Lr.RE_BAD_CHARACTERS=/([^0-9a-f:/%])/gi;Lr.RE_BAD_ADDRESS=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi;Lr.RE_SUBNET_STRING=/\/\d{1,3}(?=%|$)/;Lr.RE_ZONE_STRING=/%.*$/;Lr.RE_URL=new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/);Lr.RE_URL_WITH_PORT=new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/)});var Ny=Ce(Yo=>{"use strict";var Joe=B(T());Object.defineProperty(Yo,"__esModule",{value:!0});Yo.simpleGroup=Yo.spanLeadingZeroes=Yo.spanAll=Yo.spanAllZeroes=void 0;var v8=Ud();function w8(e){return e.replace(/(0+)/g,'$1')}Yo.spanAllZeroes=w8;function jM(e,t=0){return e.split("").map((n,i)=>(0,v8.sprintf)('%s',n,i+t,w8(n))).join("")}Yo.spanAll=jM;function y8(e){return e.replace(/^(0+)/,'$1')}function KM(e){return e.split(":").map(r=>y8(r)).join(":")}Yo.spanLeadingZeroes=KM;function VM(e,t=0){return e.split(":").map((n,i)=>/group-v4/.test(n)?n:(0,v8.sprintf)('%s',i+t,y8(n)))}Yo.simpleGroup=VM});var E8=Ce(Sn=>{"use strict";var Qoe=B(T()),zM=Sn&&Sn.__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]}),GM=Sn&&Sn.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),YM=Sn&&Sn.__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)&&zM(t,e,r);return GM(t,e),t};Object.defineProperty(Sn,"__esModule",{value:!0});Sn.possibleElisions=Sn.simpleRegularExpression=Sn.ADDRESS_BOUNDARY=Sn.padGroup=Sn.groupPossibilities=void 0;var WM=YM(Oy()),Uf=Ud();function em(e){return(0,Uf.sprintf)("(%s)",e.join("|"))}Sn.groupPossibilities=em;function Q1(e){return e.length<4?(0,Uf.sprintf)("0{0,%d}%s",4-e.length,e):e}Sn.padGroup=Q1;Sn.ADDRESS_BOUNDARY="[^A-Fa-f0-9:]";function XM(e){let t=[];e.forEach((n,i)=>{parseInt(n,16)===0&&t.push(i)});let r=t.map(n=>e.map((i,o)=>{if(o===n){let s=o===0||o===WM.GROUPS-1?":":"";return em([Q1(i),s])}return Q1(i)}).join(":"));return r.push(e.map(Q1).join(":")),em(r)}Sn.simpleRegularExpression=XM;function JM(e,t,r){let n=t?"":":",i=r?"":":",o=[];!t&&!r&&o.push("::"),t&&r&&o.push(""),(r&&!t||!r&&t)&&o.push(":"),o.push((0,Uf.sprintf)("%s(:0{1,4}){1,%d}",n,e-1)),o.push((0,Uf.sprintf)("(0{1,4}:){1,%d}%s",e-1,i)),o.push((0,Uf.sprintf)("(0{1,4}:){%d}0{1,4}",e-1));for(let s=1;s{"use strict";var tae=B(T()),ZM=Wo&&Wo.__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]}),QM=Wo&&Wo.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),rm=Wo&&Wo.__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)&&ZM(t,e,r);return QM(t,e),t};Object.defineProperty(Wo,"__esModule",{value:!0});Wo.Address6=void 0;var b8=rm($y()),Ly=rm(Ty()),br=rm(Oy()),Uy=rm(Ny()),yl=ky(),El=E8(),Qa=X1(),Fs=xy(),Is=Ud();function tm(e){if(!e)throw new Error("Assertion failed.")}function eq(e){let t=/(\d+)(\d{3})/;for(;t.test(e);)e=e.replace(t,"$1,$2");return e}function tq(e){return e=e.replace(/^(0{1,})([1-9]+)$/,'$1$2'),e=e.replace(/^(0{1,})(0)$/,'$1$2'),e}function rq(e,t){let r=[],n=[],i;for(i=0;it[1]&&n.push(e[i]);return r.concat(["compact"]).concat(n)}function A8(e){return(0,Is.sprintf)("%04x",parseInt(e,16))}function S8(e){return e&255}var Hy=class e{constructor(t,r){this.addressMinusSuffix="",this.parsedSubnet="",this.subnet="/128",this.subnetMask=128,this.v4=!1,this.zone="",this.isInSubnet=b8.isInSubnet,this.isCorrect=b8.isCorrect(br.BITS),r===void 0?this.groups=br.GROUPS:this.groups=r,this.address=t;let n=br.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>br.BITS)throw new Qa.AddressError("Invalid subnet mask.");t=t.replace(br.RE_SUBNET_STRING,"")}else if(/\//.test(t))throw new Qa.AddressError("Invalid subnet mask.");let i=br.RE_ZONE_STRING.exec(t);i&&(this.zone=i[0],t=t.replace(br.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 yl.Address4(t),n=br.BITS-(Ly.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 Qa.AddressError("Invalid 'ip6.arpa' form.");let i=r.split(".").reverse();for(let o=n;o>0;o--){let s=o*4;i.splice(s,0,":")}return r=i.join(""),new e(r)}microsoftTranscription(){return(0,Is.sprintf)("%s.ipv6-literal.net",this.correctForm().replace(/:/g,"-"))}mask(t=this.subnetMask){return this.getBitsBase2(0,t)}possibleSubnets(t=128){let r=br.BITS-this.subnetMask,n=Math.abs(t-br.BITS),i=r-n;return i<0?"0":eq(new Fs.BigInteger("2",10).pow(i).toString(10))}_startAddress(){return new Fs.BigInteger(this.mask()+"0".repeat(br.BITS-this.subnetMask),2)}startAddress(){return e.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new Fs.BigInteger("1");return e.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new Fs.BigInteger(this.mask()+"1".repeat(br.BITS-this.subnetMask),2)}endAddress(){return e.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new Fs.BigInteger("1");return e.fromBigInteger(this._endAddress().subtract(t))}getScope(){let t=br.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(br.TYPES))if(this.isInSubnet(new e(t)))return br.TYPES[t];return"Global unicast"}getBits(t,r){return new Fs.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,br.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,Is.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 o=i.map(a=>a[1]-a[0]+1);if(i.length>0){let a=o.indexOf(Math.max(...o));r=rq(this.parsedAddress,i[a])}else r=this.parsedAddress;for(t=0;t1?"s":"",r.join("")),t.replace(br.RE_BAD_CHARACTERS,'$1'));let n=t.match(br.RE_BAD_ADDRESS);if(n)throw new Qa.AddressError((0,Is.sprintf)("Address failed regex: %s",n.join("")),t.replace(br.RE_BAD_ADDRESS,'$1'));let i=[],o=t.split("::");if(o.length===2){let s=o[0].split(":"),a=o[1].split(":");s.length===1&&s[0]===""&&(s=[]),a.length===1&&a[0]===""&&(a=[]);let u=this.groups-(s.length+a.length);if(!u)throw new Qa.AddressError("Error parsing groups");this.elidedGroups=u,this.elisionBegin=s.length,this.elisionEnd=s.length+this.elidedGroups,i=i.concat(s);for(let l=0;l(0,Is.sprintf)("%x",parseInt(s,16))),i.length!==this.groups)throw new Qa.AddressError("Incorrect number of groups found");return i}canonicalForm(){return this.parsedAddress.map(A8).join(":")}decimal(){return this.parsedAddress.map(t=>(0,Is.sprintf)("%05d",parseInt(t,16))).join(":")}bigInteger(){return new Fs.BigInteger(this.parsedAddress.map(A8).join(""),16)}to4(){let t=this.binaryZeroPad().split("");return yl.Address4.fromHex(new Fs.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 Fs.BigInteger("ffff",16)).toString(),n=yl.Address4.fromHex(this.getBitsBase16(32,64)),i=yl.Address4.fromHex(this.getBits(96,128).xor(new Fs.BigInteger("ffffffff",16)).toString(16)),o=this.getBits(64,80),s=this.getBitsBase2(64,80),a=o.testBit(15),u=o.testBit(14),l=o.testBit(8),f=o.testBit(9),m=new Fs.BigInteger(s.slice(2,6)+s.slice(8,16),2).toString(10);return{prefix:(0,Is.sprintf)("%s:%s",t.slice(0,4),t.slice(4,8)),server4:n.address,client4:i.address,flags:s,coneNat:a,microsoft:{reserved:u,universalLocal:f,groupIndividual:l,nonce:m},udpPort:r}}inspect6to4(){let t=this.getBitsBase16(0,16),r=yl.Address4.fromHex(this.getBitsBase16(16,48));return{prefix:(0,Is.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(S8)}static fromByteArray(t){return this.fromUnsignedByteArray(t.map(S8))}static fromUnsignedByteArray(t){let r=new Fs.BigInteger("256",10),n=new Fs.BigInteger("0",10),i=new Fs.BigInteger("1",10);for(let o=t.length-1;o>=0;o--)n=n.add(i.multiply(new Fs.BigInteger(t[o].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,Is.sprintf)(":%s",t),(0,Is.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,Is.sprintf)('%2$s',t.prefix,r.call(this),t.className):(0,Is.sprintf)('%2$s',t.prefix,r.call(this))}group(){if(this.elidedGroups===0)return Uy.simpleGroup(this.address).join(":");tm(typeof this.elidedGroups=="number"),tm(typeof this.elisionBegin=="number");let t=[],[r,n]=this.address.split("::");r.length?t.push(...Uy.simpleGroup(r)):t.push("");let i=["hover-group"];for(let o=this.elisionBegin;o',i.join(" "))),n.length?t.push(...Uy.simpleGroup(n,this.elisionEnd)):t.push(""),this.is4()&&(tm(this.address4 instanceof yl.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,El.simpleRegularExpression)(n.parsedAddress));else if(n.elidedGroups===br.GROUPS)r.push((0,El.possibleElisions)(br.GROUPS));else{let i=n.address.split("::");i[0].length&&r.push((0,El.simpleRegularExpression)(i[0].split(":"))),tm(typeof n.elidedGroups=="number"),r.push((0,El.possibleElisions)(n.elidedGroups,i[0].length!==0,i[1].length!==0)),i[1].length&&r.push((0,El.simpleRegularExpression)(i[1].split(":"))),r=[r.join(":")]}return t||(r=["(?=^|",El.ADDRESS_BOUNDARY,"|[^\\w\\:])(",...r,")(?=[^\\w\\:]|",El.ADDRESS_BOUNDARY,"|$)"]),r.join("")}regularExpression(t=!1){return new RegExp(this.regularExpressionString(t),"i")}};Wo.Address6=Hy});var _8=Ce(rs=>{"use strict";var nae=B(T()),nq=rs&&rs.__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]}),sq=rs&&rs.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),iq=rs&&rs.__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)&&nq(t,e,r);return sq(t,e),t};Object.defineProperty(rs,"__esModule",{value:!0});rs.v6=rs.AddressError=rs.Address6=rs.Address4=void 0;var oq=ky();Object.defineProperty(rs,"Address4",{enumerable:!0,get:function(){return oq.Address4}});var aq=C8();Object.defineProperty(rs,"Address6",{enumerable:!0,get:function(){return aq.Address6}});var uq=X1();Object.defineProperty(rs,"AddressError",{enumerable:!0,get:function(){return uq.AddressError}});var cq=iq(Ny());rs.v6={helpers:cq}});var Tp=Ce((dh,$p)=>{var fde=B(T());(function(){var e,t="4.18.1",r=200,n="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",i="Expected a function",o="Invalid `variable` option passed into `_.template`",s="Invalid `imports` option passed into `_.template`",a="__lodash_hash_undefined__",u=500,l="__lodash_placeholder__",f=1,m=2,p=4,d=1,v=2,g=1,y=2,w=4,E=8,S=16,D=32,F=64,M=128,z=256,C=512,P=30,U="...",k=800,O=16,q=1,N=2,_=3,R=1/0,K=9007199254740991,Z=17976931348623157e292,Y=NaN,te=4294967295,se=te-1,fe=te>>>1,ve=[["ary",M],["bind",g],["bindKey",y],["curry",E],["curryRight",S],["flip",C],["partial",D],["partialRight",F],["rearg",z]],we="[object Arguments]",Te="[object Array]",Le="[object AsyncFunction]",Oe="[object Boolean]",le="[object Date]",Se="[object DOMException]",Re="[object Error]",Ve="[object Function]",rt="[object GeneratorFunction]",qe="[object Map]",At="[object Number]",it="[object Null]",Et="[object Object]",pn="[object Promise]",Ir="[object Proxy]",Br="[object RegExp]",bt="[object Set]",Mr="[object String]",Yn="[object Symbol]",ni="[object Undefined]",Rt="[object WeakMap]",st="[object WeakSet]",Ue="[object ArrayBuffer]",Ar="[object DataView]",In="[object Float32Array]",St="[object Float64Array]",Ba="[object Int8Array]",Bn="[object Int16Array]",De="[object Int32Array]",$o="[object Uint8Array]",Yt="[object Uint8ClampedArray]",mn="[object Uint16Array]",si="[object Uint32Array]",qu=/\b__p \+= '';/g,To=/\b(__p \+=) '' \+/g,zc=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Po=/&(?:amp|lt|gt|quot|#39);/g,bi=/[&<>"']/g,Qt=RegExp(Po.source),Ns=RegExp(bi.source),ju=/<%-([\s\S]+?)%>/g,Gc=/<%([\s\S]+?)%>/g,$a=/<%=([\s\S]+?)%>/g,xo=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Yc=/^\w*$/,Ku=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ta=/[\\^$.*+?()[\]{}|]/g,Wc=RegExp(Ta.source),ue=/^\s+/,Ee=/\s/,Qe=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Xe=/\{\n\/\* \[wrapped with (.+)\] \*/,ut=/,? & /,Ct=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Dt=/[()=,{}\[\]\/\s]/,qr=/\\(\\)?/g,lr=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,vs=/\w*$/,Ai=/^[-+]0x[0-9a-f]+$/i,$n=/^0b[01]+$/i,Wn=/^\[object .+?Constructor\]$/,Rr=/^0o[0-7]+$/i,Tn=/^(?:0|[1-9]\d*)$/,Xn=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ro=/($^)/,Xc=/['\n\r\u2028\u2029\\]/g,gn="\\ud800-\\udfff",Xt="\\u0300-\\u036f",kr="\\ufe20-\\ufe2f",wt="\\u20d0-\\u20ff",Sr=Xt+kr+wt,vn="\\u2700-\\u27bf",yr="a-z\\xdf-\\xf6\\xf8-\\xff",or="\\xac\\xb1\\xd7\\xf7",ws="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Ls="\\u2000-\\u206f",ii=" \\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",ys="A-Z\\xc0-\\xd6\\xd8-\\xde",en="\\ufe0e\\ufe0f",$r=or+ws+Ls+ii,Jc="['\u2019]",hf="["+gn+"]",Jn="["+$r+"]",Pa="["+Sr+"]",Zc="\\d+",ed="["+vn+"]",Qc="["+yr+"]",xa="[^"+gn+$r+Zc+vn+yr+ys+"]",Ra="\\ud83c[\\udffb-\\udfff]",td="(?:"+Pa+"|"+Ra+")",df="[^"+gn+"]",el="(?:\\ud83c[\\udde6-\\uddff]){2}",Si="[\\ud800-\\udbff][\\udc00-\\udfff]",j="["+ys+"]",G="\\u200d",Q="(?:"+Qc+"|"+xa+")",ae="(?:"+j+"|"+xa+")",Ie="(?:"+Jc+"(?:d|ll|m|re|s|t|ve))?",Pe="(?:"+Jc+"(?:D|LL|M|RE|S|T|VE))?",Me=td+"?",ze="["+en+"]?",fr="(?:"+G+"(?:"+[df,el,Si].join("|")+")"+ze+Me+")*",Or="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Zn="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",wn=ze+Me+fr,oi="(?:"+[ed,el,Si].join("|")+")"+wn,Vu="(?:"+[df+Pa+"?",Pa,el,Si,hf].join("|")+")",Es=RegExp(Jc,"g"),bs=RegExp(Pa,"g"),ko=RegExp(Ra+"(?="+Ra+")|"+Vu+wn,"g"),Ci=RegExp([j+"?"+Qc+"+"+Ie+"(?="+[Jn,j,"$"].join("|")+")",ae+"+"+Pe+"(?="+[Jn,j+Q,"$"].join("|")+")",j+"?"+Q+"+"+Ie,j+"+"+Pe,Zn,Or,Zc,oi].join("|"),"g"),tl=RegExp("["+G+gn+Sr+en+"]"),fv=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,hv=["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"],dv=-1,wr={};wr[In]=wr[St]=wr[Ba]=wr[Bn]=wr[De]=wr[$o]=wr[Yt]=wr[mn]=wr[si]=!0,wr[we]=wr[Te]=wr[Ue]=wr[Oe]=wr[Ar]=wr[le]=wr[Re]=wr[Ve]=wr[qe]=wr[At]=wr[Et]=wr[Br]=wr[bt]=wr[Mr]=wr[Rt]=!1;var mr={};mr[we]=mr[Te]=mr[Ue]=mr[Ar]=mr[Oe]=mr[le]=mr[In]=mr[St]=mr[Ba]=mr[Bn]=mr[De]=mr[qe]=mr[At]=mr[Et]=mr[Br]=mr[bt]=mr[Mr]=mr[Yn]=mr[$o]=mr[Yt]=mr[mn]=mr[si]=!0,mr[Re]=mr[Ve]=mr[Rt]=!1;var pv={\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"},mv={"&":"&","<":"<",">":">",'"':""","'":"'"},gv={"&":"&","<":"<",">":">",""":'"',"'":"'"},vv={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},wv=parseFloat,yv=parseInt,R0=typeof global=="object"&&global&&global.Object===Object&&global,Ev=typeof self=="object"&&self&&self.Object===Object&&self,tn=R0||Ev||Function("return this")(),rd=typeof dh=="object"&&dh&&!dh.nodeType&&dh,ka=rd&&typeof $p=="object"&&$p&&!$p.nodeType&&$p,k0=ka&&ka.exports===rd,nd=k0&&R0.process,Us=function(){try{var ce=ka&&ka.require&&ka.require("util").types;return ce||nd&&nd.binding&&nd.binding("util")}catch{}}(),O0=Us&&Us.isArrayBuffer,N0=Us&&Us.isDate,L0=Us&&Us.isMap,U0=Us&&Us.isRegExp,H0=Us&&Us.isSet,M0=Us&&Us.isTypedArray;function As(ce,Ae,ge){switch(ge.length){case 0:return ce.call(Ae);case 1:return ce.call(Ae,ge[0]);case 2:return ce.call(Ae,ge[0],ge[1]);case 3:return ce.call(Ae,ge[0],ge[1],ge[2])}return ce.apply(Ae,ge)}function bv(ce,Ae,ge,We){for(var vt=-1,jt=ce==null?0:ce.length;++vt-1}function de(ce,Ae,ge){for(var We=-1,vt=ce==null?0:ce.length;++We-1;);return ge}function dd(ce,Ae){for(var ge=ce.length;ge--&&Gu(Ae,ce[ge],0)>-1;);return ge}function pd(ce,Ae){for(var ge=ce.length,We=0;ge--;)ce[ge]===Ae&&++We;return We}var Av=ad(pv),z0=ad(mv);function Sv(ce){return"\\"+vv[ce]}function G0(ce,Ae){return ce==null?e:ce[Ae]}function Wu(ce){return tl.test(ce)}function Cv(ce){return fv.test(ce)}function _v(ce){for(var Ae,ge=[];!(Ae=ce.next()).done;)ge.push(Ae.value);return ge}function En(ce){var Ae=-1,ge=Array(ce.size);return ce.forEach(function(We,vt){ge[++Ae]=[vt,We]}),ge}function nl(ce,Ae){return function(ge){return ce(Ae(ge))}}function xn(ce,Ae){for(var ge=-1,We=ce.length,vt=0,jt=[];++ge-1}function eP(c,h){var b=this.__data__,x=s1(b,c);return x<0?(++this.size,b.push([c,h])):b[x][1]=h,this}Ma.prototype.clear=XT,Ma.prototype.delete=JT,Ma.prototype.get=ZT,Ma.prototype.has=QT,Ma.prototype.set=eP;function qa(c){var h=-1,b=c==null?0:c.length;for(this.clear();++h=h?c:h)),c}function Di(c,h,b,x,V,J){var re,ie=h&f,he=h&m,Be=h&p;if(b&&(re=V?b(c,x,V,J):b(c)),re!==e)return re;if(!Tr(c))return c;var $e=It(c);if($e){if(re=sx(c),!ie)return Ms(c,re)}else{var xe=es(c),je=xe==Ve||xe==rt;if(ec(c))return v3(c,ie);if(xe==Et||xe==we||je&&!V){if(re=he||je?{}:O3(c),!ie)return he?GP(c,gP(re,c)):zP(c,G6(re,c))}else{if(!mr[xe])return V?c:{};re=ix(c,xe,ie)}}J||(J=new Yi);var tt=J.get(c);if(tt)return tt;J.set(c,re),f5(c)?c.forEach(function(ht){re.add(Di(ht,h,b,ht,c,J))}):c5(c)&&c.forEach(function(ht,Ut){re.set(Ut,Di(ht,h,b,Ut,c,J))});var mt=Be?he?nw:rw:he?js:bn,xt=$e?e:mt(c);return L(xt||c,function(ht,Ut){xt&&(Ut=ht,ht=c[Ut]),Sd(re,Ut,Di(ht,h,b,Ut,c,J))}),re}function vP(c){var h=bn(c);return function(b){return Y6(b,c,h)}}function Y6(c,h,b){var x=b.length;if(c==null)return!x;for(c=ar(c);x--;){var V=b[x],J=h[V],re=c[V];if(re===e&&!(V in c)||!J(re))return!1}return!0}function W6(c,h,b){if(typeof c!="function")throw new Hs(i);return $d(function(){c.apply(e,b)},h)}function Cd(c,h,b,x){var V=-1,J=zu,re=!0,ie=c.length,he=[],Be=h.length;if(!ie)return he;b&&(h=hr(h,Pn(b))),x?(J=de,re=!1):h.length>=r&&(J=Oa,re=!1,h=new al(h));e:for(;++VV?0:V+b),x=x===e||x>V?V:Tt(x),x<0&&(x+=V),x=b>x?0:d5(x);b0&&b(ie)?h>1?Rn(ie,h-1,b,x,V):Oo(V,ie):x||(V[V.length]=ie)}return V}var Lv=S3(),Z6=S3(!0);function Uo(c,h){return c&&Lv(c,h,bn)}function Uv(c,h){return c&&Z6(c,h,bn)}function o1(c,h){return on(h,function(b){return za(c[b])})}function cl(c,h){h=Zu(h,c);for(var b=0,x=h.length;c!=null&&bh}function EP(c,h){return c!=null&&er.call(c,h)}function bP(c,h){return c!=null&&h in ar(c)}function AP(c,h,b){return c>=Qn(h,b)&&c=120&&$e.length>=120)?new al(re&&$e):e}$e=c[0];var xe=-1,je=ie[0];e:for(;++xe-1;)ie!==c&&Ef.call(ie,he,1),Ef.call(c,he,1);return c}function c3(c,h){for(var b=c?h.length:0,x=b-1;b--;){var V=h[b];if(b==x||V!==J){var J=V;Va(V)?Ef.call(c,V,1):Wv(c,V)}}return c}function zv(c,h){return c+ye(j6()*(h-c+1))}function kP(c,h,b,x){for(var V=-1,J=an(me((h-c)/(b||1)),0),re=ge(J);J--;)re[x?J:++V]=c,c+=b;return re}function Gv(c,h){var b="";if(!c||h<1||h>K)return b;do h%2&&(b+=c),h=ye(h/2),h&&(c+=c);while(h);return b}function kt(c,h){return lw(U3(c,h,Ks),c+"")}function OP(c){return z6(Bf(c))}function NP(c,h){var b=Bf(c);return v1(b,ul(h,0,b.length))}function Fd(c,h,b,x){if(!Tr(c))return c;h=Zu(h,c);for(var V=-1,J=h.length,re=J-1,ie=c;ie!=null&&++VV?0:V+h),b=b>V?V:b,b<0&&(b+=V),V=h>b?0:b-h>>>0,h>>>=0;for(var J=ge(V);++x>>1,re=c[J];re!==null&&!ci(re)&&(b?re<=h:re=r){var Be=h?null:JP(c);if(Be)return Na(Be);re=!1,V=Oa,he=new al}else he=h?[]:ie;e:for(;++x=x?c:Fi(c,h,b)}var g3=W||function(c){return tn.clearTimeout(c)};function v3(c,h){if(h)return c.slice();var b=c.length,x=Q0?Q0(b):new c.constructor(b);return c.copy(x),x}function Qv(c){var h=new c.constructor(c.byteLength);return new wf(h).set(new wf(c)),h}function qP(c,h){var b=h?Qv(c.buffer):c.buffer;return new c.constructor(b,c.byteOffset,c.byteLength)}function jP(c){var h=new c.constructor(c.source,vs.exec(c));return h.lastIndex=c.lastIndex,h}function KP(c){return Ad?ar(Ad.call(c)):{}}function w3(c,h){var b=h?Qv(c.buffer):c.buffer;return new c.constructor(b,c.byteOffset,c.length)}function y3(c,h){if(c!==h){var b=c!==e,x=c===null,V=c===c,J=ci(c),re=h!==e,ie=h===null,he=h===h,Be=ci(h);if(!ie&&!Be&&!J&&c>h||J&&re&&he&&!ie&&!Be||x&&re&&he||!b&&he||!V)return 1;if(!x&&!J&&!Be&&c=ie)return he;var Be=b[x];return he*(Be=="desc"?-1:1)}}return c.index-h.index}function E3(c,h,b,x){for(var V=-1,J=c.length,re=b.length,ie=-1,he=h.length,Be=an(J-re,0),$e=ge(he+Be),xe=!x;++ie1?b[V-1]:e,re=V>2?b[2]:e;for(J=c.length>3&&typeof J=="function"?(V--,J):e,re&&_s(b[0],b[1],re)&&(J=V<3?e:J,V=1),h=ar(h);++x-1?V[J?h[re]:re]:e}}function D3(c){return Ka(function(h){var b=h.length,x=b,V=_i.prototype.thru;for(c&&h.reverse();x--;){var J=h[x];if(typeof J!="function")throw new Hs(i);if(V&&!re&&m1(J)=="wrapper")var re=new _i([],!0)}for(x=re?x:b;++x1&&Kt.reverse(),$e&&heie))return!1;var Be=J.get(c),$e=J.get(h);if(Be&&$e)return Be==h&&$e==c;var xe=-1,je=!0,tt=b&v?new al:e;for(J.set(c,h),J.set(h,c);++xe1?"& ":"")+h[x],h=h.join(b>2?", ":" "),c.replace(Qe,`{ /* [wrapped with `+h+`] */ `)}function ax(c){return It(c)||hl(c)||!!(bf&&c&&c[bf])}function Va(c,h){var b=typeof c;return h=h??K,!!h&&(b=="number"||b!="symbol"&&Tn.test(c))&&c>-1&&c%1==0&&c0){if(++h>=k)return arguments[0]}else h=0;return c.apply(e,arguments)}}function v1(c,h){var b=-1,x=c.length,V=x-1;for(h=h===e?x:h;++b1?c[h-1]:e;return b=typeof b=="function"?(c.pop(),b):e,J3(c,b)});function Z3(c){var h=X(c);return h.__chain__=!0,h}function wR(c,h){return h(c),c}function w1(c,h){return h(c)}var yR=Ka(function(c){var h=c.length,b=h?c[0]:0,x=this.__wrapped__,V=function(J){return Nv(J,c)};return h>1||this.__actions__.length||!(x instanceof Ht)||!Va(b)?this.thru(V):(x=x.slice(b,+b+(h?1:0)),x.__actions__.push({func:w1,args:[V],thisArg:e}),new _i(x,this.__chain__).thru(function(J){return h&&!J.length&&J.push(e),J}))});function ER(){return Z3(this)}function bR(){return new _i(this.value(),this.__chain__)}function AR(){this.__values__===e&&(this.__values__=h5(this.value()));var c=this.__index__>=this.__values__.length,h=c?e:this.__values__[this.__index__++];return{done:c,value:h}}function SR(){return this}function CR(c){for(var h,b=this;b instanceof n1;){var x=V3(b);x.__index__=0,x.__values__=e,h?V.__wrapped__=x:h=x;var V=x;b=b.__wrapped__}return V.__wrapped__=c,h}function _R(){var c=this.__wrapped__;if(c instanceof Ht){var h=c;return this.__actions__.length&&(h=new Ht(this)),h=h.reverse(),h.__actions__.push({func:w1,args:[fw],thisArg:e}),new _i(h,this.__chain__)}return this.thru(fw)}function DR(){return p3(this.__wrapped__,this.__actions__)}var FR=l1(function(c,h,b){er.call(c,b)?++c[b]:Lo(c,b,1)});function IR(c,h,b){var x=It(c)?rl:wP;return b&&_s(c,h,b)&&(h=e),x(c,dt(h,3))}function BR(c,h){var b=It(c)?on:J6;return b(c,dt(h,3))}var $R=_3(z3),TR=_3(G3);function PR(c,h){return Rn(y1(c,h),1)}function xR(c,h){return Rn(y1(c,h),R)}function RR(c,h,b){return b=b===e?1:Tt(b),Rn(y1(c,h),b)}function Q3(c,h){var b=It(c)?L:Xu;return b(c,dt(h,3))}function e5(c,h){var b=It(c)?Ft:X6;return b(c,dt(h,3))}var kR=l1(function(c,h,b){er.call(c,b)?c[b].push(h):Lo(c,b,[h])});function OR(c,h,b,x){c=qs(c)?c:Bf(c),b=b&&!x?Tt(b):0;var V=c.length;return b<0&&(b=an(V+b,0)),C1(c)?b<=V&&c.indexOf(h,b)>-1:!!V&&Gu(c,h,b)>-1}var NR=kt(function(c,h,b){var x=-1,V=typeof h=="function",J=qs(c)?ge(c.length):[];return Xu(c,function(re){J[++x]=V?As(h,re,b):_d(re,h,b)}),J}),LR=l1(function(c,h,b){Lo(c,b,h)});function y1(c,h){var b=It(c)?hr:n3;return b(c,dt(h,3))}function UR(c,h,b,x){return c==null?[]:(It(h)||(h=h==null?[]:[h]),b=x?e:b,It(b)||(b=b==null?[]:[b]),a3(c,h,b))}var HR=l1(function(c,h,b){c[b?0:1].push(h)},function(){return[[],[]]});function MR(c,h,b){var x=It(c)?q0:ud,V=arguments.length<3;return x(c,dt(h,4),b,V,Xu)}function qR(c,h,b){var x=It(c)?H6:ud,V=arguments.length<3;return x(c,dt(h,4),b,V,X6)}function jR(c,h){var b=It(c)?on:J6;return b(c,A1(dt(h,3)))}function KR(c){var h=It(c)?z6:OP;return h(c)}function VR(c,h,b){(b?_s(c,h,b):h===e)?h=1:h=Tt(h);var x=It(c)?dP:NP;return x(c,h)}function zR(c){var h=It(c)?pP:UP;return h(c)}function GR(c){if(c==null)return 0;if(qs(c))return C1(c)?La(c):c.length;var h=es(c);return h==qe||h==bt?c.size:jv(c).length}function YR(c,h,b){var x=It(c)?Cr:HP;return b&&_s(c,h,b)&&(h=e),x(c,dt(h,3))}var WR=kt(function(c,h){if(c==null)return[];var b=h.length;return b>1&&_s(c,h[0],h[1])?h=[]:b>2&&_s(h[0],h[1],h[2])&&(h=[h[0]]),a3(c,Rn(h,1),[])}),E1=ne||function(){return tn.Date.now()};function XR(c,h){if(typeof h!="function")throw new Hs(i);return c=Tt(c),function(){if(--c<1)return h.apply(this,arguments)}}function t5(c,h,b){return h=b?e:h,h=c&&h==null?c.length:h,ja(c,M,e,e,e,e,h)}function r5(c,h){var b;if(typeof h!="function")throw new Hs(i);return c=Tt(c),function(){return--c>0&&(b=h.apply(this,arguments)),c<=1&&(h=e),b}}var dw=kt(function(c,h,b){var x=g;if(b.length){var V=xn(b,Ff(dw));x|=D}return ja(c,x,h,b,V)}),n5=kt(function(c,h,b){var x=g|y;if(b.length){var V=xn(b,Ff(n5));x|=D}return ja(h,x,c,b,V)});function s5(c,h,b){h=b?e:h;var x=ja(c,E,e,e,e,e,e,h);return x.placeholder=s5.placeholder,x}function i5(c,h,b){h=b?e:h;var x=ja(c,S,e,e,e,e,e,h);return x.placeholder=i5.placeholder,x}function o5(c,h,b){var x,V,J,re,ie,he,Be=0,$e=!1,xe=!1,je=!0;if(typeof c!="function")throw new Hs(i);h=Bi(h)||0,Tr(b)&&($e=!!b.leading,xe="maxWait"in b,J=xe?an(Bi(b.maxWait)||0,h):J,je="trailing"in b?!!b.trailing:je);function tt(zr){var Ji=x,Ya=V;return x=V=e,Be=zr,re=c.apply(Ya,Ji),re}function mt(zr){return Be=zr,ie=$d(Ut,h),$e?tt(zr):re}function xt(zr){var Ji=zr-he,Ya=zr-Be,D5=h-Ji;return xe?Qn(D5,J-Ya):D5}function ht(zr){var Ji=zr-he,Ya=zr-Be;return he===e||Ji>=h||Ji<0||xe&&Ya>=J}function Ut(){var zr=E1();if(ht(zr))return Kt(zr);ie=$d(Ut,xt(zr))}function Kt(zr){return ie=e,je&&x?tt(zr):(x=V=e,re)}function li(){ie!==e&&g3(ie),Be=0,x=he=V=ie=e}function Ds(){return ie===e?re:Kt(E1())}function fi(){var zr=E1(),Ji=ht(zr);if(x=arguments,V=this,he=zr,Ji){if(ie===e)return mt(he);if(xe)return g3(ie),ie=$d(Ut,h),tt(he)}return ie===e&&(ie=$d(Ut,h)),re}return fi.cancel=li,fi.flush=Ds,fi}var JR=kt(function(c,h){return W6(c,1,h)}),ZR=kt(function(c,h,b){return W6(c,Bi(h)||0,b)});function QR(c){return ja(c,C)}function b1(c,h){if(typeof c!="function"||h!=null&&typeof h!="function")throw new Hs(i);var b=function(){var x=arguments,V=h?h.apply(this,x):x[0],J=b.cache;if(J.has(V))return J.get(V);var re=c.apply(this,x);return b.cache=J.set(V,re)||J,re};return b.cache=new(b1.Cache||qa),b}b1.Cache=qa;function A1(c){if(typeof c!="function")throw new Hs(i);return function(){var h=arguments;switch(h.length){case 0:return!c.call(this);case 1:return!c.call(this,h[0]);case 2:return!c.call(this,h[0],h[1]);case 3:return!c.call(this,h[0],h[1],h[2])}return!c.apply(this,h)}}function ek(c){return r5(2,c)}var tk=MP(function(c,h){h=h.length==1&&It(h[0])?hr(h[0],Pn(dt())):hr(Rn(h,1),Pn(dt()));var b=h.length;return kt(function(x){for(var V=-1,J=Qn(x.length,b);++V=h}),hl=e3(function(){return arguments}())?e3:function(c){return Nr(c)&&er.call(c,"callee")&&!dr.call(c,"callee")},It=ge.isArray,gk=O0?Pn(O0):CP;function qs(c){return c!=null&&S1(c.length)&&!za(c)}function Vr(c){return Nr(c)&&qs(c)}function vk(c){return c===!0||c===!1||Nr(c)&&Cs(c)==Oe}var ec=Kr||Dw,wk=N0?Pn(N0):_P;function yk(c){return Nr(c)&&c.nodeType===1&&!Td(c)}function Ek(c){if(c==null)return!0;if(qs(c)&&(It(c)||typeof c=="string"||typeof c.splice=="function"||ec(c)||If(c)||hl(c)))return!c.length;var h=es(c);if(h==qe||h==bt)return!c.size;if(Bd(c))return!jv(c).length;for(var b in c)if(er.call(c,b))return!1;return!0}function bk(c,h){return Dd(c,h)}function Ak(c,h,b){b=typeof b=="function"?b:e;var x=b?b(c,h):e;return x===e?Dd(c,h,e,b):!!x}function mw(c){if(!Nr(c))return!1;var h=Cs(c);return h==Re||h==Se||typeof c.message=="string"&&typeof c.name=="string"&&!Td(c)}function Sk(c){return typeof c=="number"&&q6(c)}function za(c){if(!Tr(c))return!1;var h=Cs(c);return h==Ve||h==rt||h==Le||h==Ir}function u5(c){return typeof c=="number"&&c==Tt(c)}function S1(c){return typeof c=="number"&&c>-1&&c%1==0&&c<=K}function Tr(c){var h=typeof c;return c!=null&&(h=="object"||h=="function")}function Nr(c){return c!=null&&typeof c=="object"}var c5=L0?Pn(L0):FP;function Ck(c,h){return c===h||qv(c,h,iw(h))}function _k(c,h,b){return b=typeof b=="function"?b:e,qv(c,h,iw(h),b)}function Dk(c){return l5(c)&&c!=+c}function Fk(c){if(lx(c))throw new vt(n);return t3(c)}function Ik(c){return c===null}function Bk(c){return c==null}function l5(c){return typeof c=="number"||Nr(c)&&Cs(c)==At}function Td(c){if(!Nr(c)||Cs(c)!=Et)return!1;var h=yf(c);if(h===null)return!0;var b=er.call(h,"constructor")&&h.constructor;return typeof b=="function"&&b instanceof b&&Ua.call(b)==Tv}var gw=U0?Pn(U0):IP;function $k(c){return u5(c)&&c>=-K&&c<=K}var f5=H0?Pn(H0):BP;function C1(c){return typeof c=="string"||!It(c)&&Nr(c)&&Cs(c)==Mr}function ci(c){return typeof c=="symbol"||Nr(c)&&Cs(c)==Yn}var If=M0?Pn(M0):$P;function Tk(c){return c===e}function Pk(c){return Nr(c)&&es(c)==Rt}function xk(c){return Nr(c)&&Cs(c)==st}var Rk=p1(Kv),kk=p1(function(c,h){return c<=h});function h5(c){if(!c)return[];if(qs(c))return C1(c)?Ss(c):Ms(c);if(il&&c[il])return _v(c[il]());var h=es(c),b=h==qe?En:h==bt?Na:Bf;return b(c)}function Ga(c){if(!c)return c===0?c:0;if(c=Bi(c),c===R||c===-R){var h=c<0?-1:1;return h*Z}return c===c?c:0}function Tt(c){var h=Ga(c),b=h%1;return h===h?b?h-b:h:0}function d5(c){return c?ul(Tt(c),0,te):0}function Bi(c){if(typeof c=="number")return c;if(ci(c))return Y;if(Tr(c)){var h=typeof c.valueOf=="function"?c.valueOf():c;c=Tr(h)?h+"":h}if(typeof c!="string")return c===0?c:+c;c=fd(c);var b=$n.test(c);return b||Rr.test(c)?yv(c.slice(2),b?2:8):Ai.test(c)?Y:+c}function p5(c){return Ho(c,js(c))}function Ok(c){return c?ul(Tt(c),-K,K):c===0?c:0}function ur(c){return c==null?"":ui(c)}var Nk=_f(function(c,h){if(Bd(h)||qs(h)){Ho(h,bn(h),c);return}for(var b in h)er.call(h,b)&&Sd(c,b,h[b])}),m5=_f(function(c,h){Ho(h,js(h),c)}),g5=_f(function(c,h,b,x){Ho(h,js(h),c,x)}),vw=_f(function(c,h,b,x){Ho(h,bn(h),c,x)}),Lk=Ka(Nv);function Uk(c,h){var b=Cf(c);return h==null?b:G6(b,h)}var Hk=kt(function(c,h){c=ar(c);var b=-1,x=h.length,V=x>2?h[2]:e;for(V&&_s(h[0],h[1],V)&&(x=1);++b1),J}),Ho(c,nw(c),b),x&&(b=Di(b,f|m|p,ZP));for(var V=h.length;V--;)Wv(b,h[V]);return b});function sO(c,h){return w5(c,A1(dt(h)))}var iO=Ka(function(c,h){return c==null?{}:xP(c,h)});function w5(c,h){if(c==null)return{};var b=hr(nw(c),function(x){return[x]});return h=dt(h),u3(c,b,function(x,V){return h(x,V[0])})}function oO(c,h,b){h=Zu(h,c);var x=-1,V=h.length;for(V||(V=1,c=e);++xh){var x=c;c=h,h=x}if(b||c%1||h%1){var V=j6();return Qn(c+V*(h-c+wv("1e-"+((V+"").length-1))),h)}return zv(c,h)}var vO=Df(function(c,h,b){return h=h.toLowerCase(),c+(b?b5(h):h)});function b5(c){return Ew(ur(c).toLowerCase())}function A5(c){return c=ur(c),c&&c.replace(Xn,Av).replace(bs,"")}function wO(c,h,b){c=ur(c),h=ui(h);var x=c.length;b=b===e?x:ul(Tt(b),0,x);var V=b;return b-=h.length,b>=0&&c.slice(b,V)==h}function yO(c){return c=ur(c),c&&Ns.test(c)?c.replace(bi,z0):c}function EO(c){return c=ur(c),c&&Wc.test(c)?c.replace(Ta,"\\$&"):c}var bO=Df(function(c,h,b){return c+(b?"-":"")+h.toLowerCase()}),AO=Df(function(c,h,b){return c+(b?" ":"")+h.toLowerCase()}),SO=C3("toLowerCase");function CO(c,h,b){c=ur(c),h=Tt(h);var x=h?La(c):0;if(!h||x>=h)return c;var V=(h-x)/2;return d1(ye(V),b)+c+d1(me(V),b)}function _O(c,h,b){c=ur(c),h=Tt(h);var x=h?La(c):0;return h&&x>>0,b?(c=ur(c),c&&(typeof h=="string"||h!=null&&!gw(h))&&(h=ui(h),!h&&Wu(c))?Qu(Ss(c),0,b):c.split(h,b)):[]}var PO=Df(function(c,h,b){return c+(b?" ":"")+Ew(h)});function xO(c,h,b){return c=ur(c),b=b==null?0:ul(Tt(b),0,c.length),h=ui(h),c.slice(b,b+h.length)==h}function RO(c,h,b){var x=X.templateSettings;b&&_s(c,h,b)&&(h=e),c=ur(c),h=vw({},h,x,T3);var V=vw({},h.imports,x.imports,T3),J=bn(V),re=hd(V,J);L(J,function(ht){if(Dt.test(ht))throw new vt(s)});var ie,he,Be=0,$e=h.interpolate||Ro,xe="__p += '",je=vd((h.escape||Ro).source+"|"+$e.source+"|"+($e===$a?lr:Ro).source+"|"+(h.evaluate||Ro).source+"|$","g"),tt="//# sourceURL="+(er.call(h,"sourceURL")?(h.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++dv+"]")+` `;c.replace(je,function(ht,Ut,Kt,li,Ds,fi){return Kt||(Kt=li),xe+=c.slice(Be,fi).replace(Xc,Sv),Ut&&(ie=!0,xe+=`' + __e(`+Ut+`) + '`),Ds&&(he=!0,xe+=`'; `+Ds+`; __p += '`),Kt&&(xe+=`' + ((__t = (`+Kt+`)) == null ? '' : __t) + '`),Be=fi+ht.length,ht}),xe+=`'; `;var mt=er.call(h,"variable")&&h.variable;if(!mt)xe=`with (obj) { `+xe+` } `;else if(Dt.test(mt))throw new vt(o);xe=(he?xe.replace(qu,""):xe).replace(To,"$1").replace(zc,"$1;"),xe="function("+(mt||"obj")+`) { `+(mt?"":`obj || (obj = {}); `)+"var __t, __p = ''"+(ie?", __e = _.escape":"")+(he?`, __j = Array.prototype.join; function print() { __p += __j.call(arguments, '') } `:`; `)+xe+`return __p }`;var xt=C5(function(){return jt(J,tt+"return "+xe).apply(e,re)});if(xt.source=xe,mw(xt))throw xt;return xt}function kO(c){return ur(c).toLowerCase()}function OO(c){return ur(c).toUpperCase()}function NO(c,h,b){if(c=ur(c),c&&(b||h===e))return fd(c);if(!c||!(h=ui(h)))return c;var x=Ss(c),V=Ss(h),J=V0(x,V),re=dd(x,V)+1;return Qu(x,J,re).join("")}function LO(c,h,b){if(c=ur(c),c&&(b||h===e))return c.slice(0,md(c)+1);if(!c||!(h=ui(h)))return c;var x=Ss(c),V=dd(x,Ss(h))+1;return Qu(x,0,V).join("")}function UO(c,h,b){if(c=ur(c),c&&(b||h===e))return c.replace(ue,"");if(!c||!(h=ui(h)))return c;var x=Ss(c),V=V0(x,Ss(h));return Qu(x,V).join("")}function HO(c,h){var b=P,x=U;if(Tr(h)){var V="separator"in h?h.separator:V;b="length"in h?Tt(h.length):b,x="omission"in h?ui(h.omission):x}c=ur(c);var J=c.length;if(Wu(c)){var re=Ss(c);J=re.length}if(b>=J)return c;var ie=b-La(x);if(ie<1)return x;var he=re?Qu(re,0,ie).join(""):c.slice(0,ie);if(V===e)return he+x;if(re&&(ie+=he.length-ie),gw(V)){if(c.slice(ie).search(V)){var Be,$e=he;for(V.global||(V=vd(V.source,ur(vs.exec(V))+"g")),V.lastIndex=0;Be=V.exec($e);)var xe=Be.index;he=he.slice(0,xe===e?ie:xe)}}else if(c.indexOf(ui(V),ie)!=ie){var je=he.lastIndexOf(V);je>-1&&(he=he.slice(0,je))}return he+x}function MO(c){return c=ur(c),c&&Qt.test(c)?c.replace(Po,X0):c}var qO=Df(function(c,h,b){return c+(b?" ":"")+h.toUpperCase()}),Ew=C3("toUpperCase");function S5(c,h,b){return c=ur(c),h=b?e:h,h===e?Cv(c)?Bv(c):ft(c):c.match(h)||[]}var C5=kt(function(c,h){try{return As(c,e,h)}catch(b){return mw(b)?b:new vt(b)}}),jO=Ka(function(c,h){return L(h,function(b){b=Wi(b),Lo(c,b,dw(c[b],c))}),c});function KO(c){var h=c==null?0:c.length,b=dt();return c=h?hr(c,function(x){if(typeof x[1]!="function")throw new Hs(i);return[b(x[0]),x[1]]}):[],kt(function(x){for(var V=-1;++VK)return[];var b=te,x=Qn(c,te);h=dt(h),c-=te;for(var V=ld(x,h);++b0||h<0)?new Ht(b):(c<0?b=b.takeRight(-c):c&&(b=b.drop(c)),h!==e&&(h=Tt(h),b=h<0?b.dropRight(-h):b.take(h-c)),b)},Ht.prototype.takeRightWhile=function(c){return this.reverse().takeWhile(c).reverse()},Ht.prototype.toArray=function(){return this.take(te)},Uo(Ht.prototype,function(c,h){var b=/^(?:filter|find|map|reject)|While$/.test(h),x=/^(?:head|last)$/.test(h),V=X[x?"take"+(h=="last"?"Right":""):h],J=x||/^find/.test(h);V&&(X.prototype[h]=function(){var re=this.__wrapped__,ie=x?[1]:arguments,he=re instanceof Ht,Be=ie[0],$e=he||It(re),xe=function(Ut){var Kt=V.apply(X,Oo([Ut],ie));return x&&je?Kt[0]:Kt};$e&&b&&typeof Be=="function"&&Be.length!=1&&(he=$e=!1);var je=this.__chain__,tt=!!this.__actions__.length,mt=J&&!je,xt=he&&!tt;if(!J&&$e){re=xt?re:new Ht(this);var ht=c.apply(re,ie);return ht.__actions__.push({func:w1,args:[xe],thisArg:e}),new _i(ht,je)}return mt&&xt?c.apply(this,ie):(ht=this.thru(xe),mt?x?ht.value()[0]:ht.value():ht)})}),L(["pop","push","shift","sort","splice","unshift"],function(c){var h=sl[c],b=/^(?:push|sort|unshift)$/.test(c)?"tap":"thru",x=/^(?:pop|shift)$/.test(c);X.prototype[c]=function(){var V=arguments;if(x&&!this.__chain__){var J=this.value();return h.apply(It(J)?J:[],V)}return this[b](function(re){return h.apply(It(re)?re:[],V)})}}),Uo(Ht.prototype,function(c,h){var b=X[h];if(b){var x=b.name+"";er.call(Sf,x)||(Sf[x]=[]),Sf[x].push({name:h,func:b})}}),Sf[f1(e,y).name]=[{name:"wrapper",func:e}],Ht.prototype.clone=qT,Ht.prototype.reverse=jT,Ht.prototype.value=KT,X.prototype.at=yR,X.prototype.chain=ER,X.prototype.commit=bR,X.prototype.next=AR,X.prototype.plant=CR,X.prototype.reverse=_R,X.prototype.toJSON=X.prototype.valueOf=X.prototype.value=DR,X.prototype.first=X.prototype.head,il&&(X.prototype[il]=SR),X},Gi=gd();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(tn._=Gi,define(function(){return Gi})):ka?((ka.exports=Gi)._=Gi,rd._=Gi):tn._=Gi}).call(dh)});var LB=Ce(r2=>{"use strict";var twe=B(T());r2.byteLength=AG;r2.toByteArray=CG;r2.fromByteArray=FG;var ma=[],Mi=[],bG=typeof Uint8Array<"u"?Uint8Array:Array,kA="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Zl=0,OB=kA.length;Zl0)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 AG(e){var t=NB(e),r=t[0],n=t[1];return(r+n)*3/4-n}function SG(e,t,r){return(t+r)*3/4-r}function CG(e){var t,r=NB(e),n=r[0],i=r[1],o=new bG(SG(e,n,i)),s=0,a=i>0?n-4:n,u;for(u=0;u>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=Mi[e.charCodeAt(u)]<<2|Mi[e.charCodeAt(u+1)]>>4,o[s++]=t&255),i===1&&(t=Mi[e.charCodeAt(u)]<<10|Mi[e.charCodeAt(u+1)]<<4|Mi[e.charCodeAt(u+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function _G(e){return ma[e>>18&63]+ma[e>>12&63]+ma[e>>6&63]+ma[e&63]}function DG(e,t,r){for(var n,i=[],o=t;oa?a:s+o));return n===1?(t=e[r-1],i.push(ma[t>>2]+ma[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(ma[t>>10]+ma[t>>4&63]+ma[t<<2&63]+"=")),i.join("")}});var UB=Ce(OA=>{var nwe=B(T());OA.read=function(e,t,r,n,i){var o,s,a=i*8-n-1,u=(1<>1,f=-7,m=r?i-1:0,p=r?-1:1,d=e[t+m];for(m+=p,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=o*256+e[t+m],m+=p,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=s*256+e[t+m],m+=p,f-=8);if(o===0)o=1-l;else{if(o===u)return s?NaN:(d?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-l}return(d?-1:1)*s*Math.pow(2,o-n)};OA.write=function(e,t,r,n,i,o){var s,a,u,l=o*8-i-1,f=(1<>1,p=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,v=n?1:-1,g=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),s+m>=1?t+=p/u:t+=p*Math.pow(2,1-m),t*u>=2&&(s++,u/=2),s+m>=f?(a=0,s=f):s+m>=1?(a=(t*u-1)*Math.pow(2,i),s=s+m):(a=t*Math.pow(2,m-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=a&255,d+=v,a/=256,i-=8);for(s=s<0;e[r+d]=s&255,d+=v,s/=256,l-=8);e[r+d-v]|=g*128}});var i2=Ce(Bh=>{"use strict";var owe=B(T());var NA=LB(),Fh=UB(),HB=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Bh.Buffer=be;Bh.SlowBuffer=xG;Bh.INSPECT_MAX_BYTES=50;var n2=2147483647;Bh.kMaxLength=n2;be.TYPED_ARRAY_SUPPORT=IG();!be.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 IG(){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(be.prototype,"parent",{enumerable:!0,get:function(){if(be.isBuffer(this))return this.buffer}});Object.defineProperty(be.prototype,"offset",{enumerable:!0,get:function(){if(be.isBuffer(this))return this.byteOffset}});function bu(e){if(e>n2)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,be.prototype),t}function be(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 MA(e)}return KB(e,t,r)}be.poolSize=8192;function KB(e,t,r){if(typeof e=="string")return $G(e,t);if(ArrayBuffer.isView(e))return TG(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(ga(e,ArrayBuffer)||e&&ga(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ga(e,SharedArrayBuffer)||e&&ga(e.buffer,SharedArrayBuffer)))return UA(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 be.from(n,t,r);let i=PG(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return be.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)}be.from=function(e,t,r){return KB(e,t,r)};Object.setPrototypeOf(be.prototype,Uint8Array.prototype);Object.setPrototypeOf(be,Uint8Array);function VB(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 BG(e,t,r){return VB(e),e<=0?bu(e):t!==void 0?typeof r=="string"?bu(e).fill(t,r):bu(e).fill(t):bu(e)}be.alloc=function(e,t,r){return BG(e,t,r)};function MA(e){return VB(e),bu(e<0?0:qA(e)|0)}be.allocUnsafe=function(e){return MA(e)};be.allocUnsafeSlow=function(e){return MA(e)};function $G(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!be.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=zB(e,t)|0,n=bu(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function LA(e){let t=e.length<0?0:qA(e.length)|0,r=bu(t);for(let n=0;n=n2)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n2.toString(16)+" bytes");return e|0}function xG(e){return+e!=e&&(e=0),be.alloc(+e)}be.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==be.prototype};be.compare=function(t,r){if(ga(t,Uint8Array)&&(t=be.from(t,t.offset,t.byteLength)),ga(r,Uint8Array)&&(r=be.from(r,r.offset,r.byteLength)),!be.isBuffer(t)||!be.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 o=0,s=Math.min(n,i);oi.length?(be.isBuffer(s)||(s=be.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(be.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function zB(e,t){if(be.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||ga(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 HA(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return t9(e).length;default:if(i)return n?-1:HA(e).length;t=(""+t).toLowerCase(),i=!0}}be.byteLength=zB;function RG(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 KG(this,t,r);case"utf8":case"utf-8":return YB(this,t,r);case"ascii":return qG(this,t,r);case"latin1":case"binary":return jG(this,t,r);case"base64":return HG(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return VG(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}be.prototype._isBuffer=!0;function Ql(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}be.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+=" ... "),""};HB&&(be.prototype[HB]=be.prototype.inspect);be.prototype.compare=function(t,r,n,i,o){if(ga(t,Uint8Array)&&(t=be.from(t,t.offset,t.byteLength)),!be.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),o===void 0&&(o=this.length),r<0||n>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===t)return 0;let s=o-i,a=n-r,u=Math.min(s,a),l=this.slice(i,o),f=t.slice(r,n);for(let m=0;m2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,KA(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=be.from(t,n)),be.isBuffer(t))return t.length===0?-1:MB(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):MB(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function MB(e,t,r,n,i){let o=1,s=e.length,a=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;o=2,s/=2,a/=2,r/=2}function u(f,m){return o===1?f[m]:f.readUInt16BE(m*o)}let l;if(i){let f=-1;for(l=r;ls&&(r=s-a),l=r;l>=0;l--){let f=!0;for(let m=0;mi&&(n=i)):n=i;let o=t.length;n>o/2&&(n=o/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 o=this.length-r;if((n===void 0||n>o)&&(n=o),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 kG(this,t,r,n);case"utf8":case"utf-8":return OG(this,t,r,n);case"ascii":case"latin1":case"binary":return NG(this,t,r,n);case"base64":return LG(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return UG(this,t,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};be.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function HG(e,t,r){return t===0&&r===e.length?NA.fromByteArray(e):NA.fromByteArray(e.slice(t,r))}function YB(e,t,r){r=Math.min(e.length,r);let n=[],i=t;for(;i239?4:o>223?3:o>191?2:1;if(i+a<=r){let u,l,f,m;switch(a){case 1:o<128&&(s=o);break;case 2:u=e[i+1],(u&192)===128&&(m=(o&31)<<6|u&63,m>127&&(s=m));break;case 3:u=e[i+1],l=e[i+2],(u&192)===128&&(l&192)===128&&(m=(o&15)<<12|(u&63)<<6|l&63,m>2047&&(m<55296||m>57343)&&(s=m));break;case 4:u=e[i+1],l=e[i+2],f=e[i+3],(u&192)===128&&(l&192)===128&&(f&192)===128&&(m=(o&15)<<18|(u&63)<<12|(l&63)<<6|f&63,m>65535&&m<1114112&&(s=m))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=a}return MG(n)}var qB=4096;function MG(e){let t=e.length;if(t<=qB)return String.fromCharCode.apply(String,e);let r="",n=0;for(;nn)&&(r=n);let i="";for(let o=t;on&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),rr)throw new RangeError("Trying to access beyond buffer length")}be.prototype.readUintLE=be.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||Dn(t,r,this.length);let i=this[t],o=1,s=0;for(;++s>>0,r=r>>>0,n||Dn(t,r,this.length);let i=this[t+--r],o=1;for(;r>0&&(o*=256);)i+=this[t+--r]*o;return i};be.prototype.readUint8=be.prototype.readUInt8=function(t,r){return t=t>>>0,r||Dn(t,1,this.length),this[t]};be.prototype.readUint16LE=be.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||Dn(t,2,this.length),this[t]|this[t+1]<<8};be.prototype.readUint16BE=be.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||Dn(t,2,this.length),this[t]<<8|this[t+1]};be.prototype.readUint32LE=be.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||Dn(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};be.prototype.readUint32BE=be.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||Dn(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};be.prototype.readBigUInt64LE=Tc(function(t){t=t>>>0,Ih(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&e0(t,this.length-8);let i=r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,o=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<>>0,Ih(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&e0(t,this.length-8);let i=r*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],o=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(i)<>>0,r=r>>>0,n||Dn(t,r,this.length);let i=this[t],o=1,s=0;for(;++s=o&&(i-=Math.pow(2,8*r)),i};be.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||Dn(t,r,this.length);let i=r,o=1,s=this[t+--i];for(;i>0&&(o*=256);)s+=this[t+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*r)),s};be.prototype.readInt8=function(t,r){return t=t>>>0,r||Dn(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};be.prototype.readInt16LE=function(t,r){t=t>>>0,r||Dn(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};be.prototype.readInt16BE=function(t,r){t=t>>>0,r||Dn(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};be.prototype.readInt32LE=function(t,r){return t=t>>>0,r||Dn(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};be.prototype.readInt32BE=function(t,r){return t=t>>>0,r||Dn(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};be.prototype.readBigInt64LE=Tc(function(t){t=t>>>0,Ih(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&e0(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,Ih(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&e0(t,this.length-8);let i=(r<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<>>0,r||Dn(t,4,this.length),Fh.read(this,t,!0,23,4)};be.prototype.readFloatBE=function(t,r){return t=t>>>0,r||Dn(t,4,this.length),Fh.read(this,t,!1,23,4)};be.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||Dn(t,8,this.length),Fh.read(this,t,!0,52,8)};be.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||Dn(t,8,this.length),Fh.read(this,t,!1,52,8)};function Ws(e,t,r,n,i,o){if(!be.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}be.prototype.writeUintLE=be.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;Ws(this,t,r,n,a,0)}let o=1,s=0;for(this[r]=t&255;++s>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;Ws(this,t,r,n,a,0)}let o=n-1,s=1;for(this[r+o]=t&255;--o>=0&&(s*=256);)this[r+o]=t/s&255;return r+n};be.prototype.writeUint8=be.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||Ws(this,t,r,1,255,0),this[r]=t&255,r+1};be.prototype.writeUint16LE=be.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||Ws(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};be.prototype.writeUint16BE=be.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||Ws(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};be.prototype.writeUint32LE=be.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||Ws(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};be.prototype.writeUint32BE=be.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||Ws(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 WB(e,t,r,n,i){e9(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o;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 XB(e,t,r,n,i){e9(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r+7]=o,o=o>>8,e[r+6]=o,o=o>>8,e[r+5]=o,o=o>>8,e[r+4]=o;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}be.prototype.writeBigUInt64LE=Tc(function(t,r=0){return WB(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});be.prototype.writeBigUInt64BE=Tc(function(t,r=0){return XB(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});be.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let u=Math.pow(2,8*n-1);Ws(this,t,r,n,u-1,-u)}let o=0,s=1,a=0;for(this[r]=t&255;++o>0)-a&255;return r+n};be.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let u=Math.pow(2,8*n-1);Ws(this,t,r,n,u-1,-u)}let o=n-1,s=1,a=0;for(this[r+o]=t&255;--o>=0&&(s*=256);)t<0&&a===0&&this[r+o+1]!==0&&(a=1),this[r+o]=(t/s>>0)-a&255;return r+n};be.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||Ws(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};be.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||Ws(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};be.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||Ws(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};be.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||Ws(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};be.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||Ws(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};be.prototype.writeBigInt64LE=Tc(function(t,r=0){return WB(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});be.prototype.writeBigInt64BE=Tc(function(t,r=0){return XB(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function JB(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ZB(e,t,r,n,i){return t=+t,r=r>>>0,i||JB(e,t,r,4,34028234663852886e22,-34028234663852886e22),Fh.write(e,t,r,n,23,4),r+4}be.prototype.writeFloatLE=function(t,r,n){return ZB(this,t,r,!0,n)};be.prototype.writeFloatBE=function(t,r,n){return ZB(this,t,r,!1,n)};function QB(e,t,r,n,i){return t=+t,r=r>>>0,i||JB(e,t,r,8,17976931348623157e292,-17976931348623157e292),Fh.write(e,t,r,n,52,8),r+8}be.prototype.writeDoubleLE=function(t,r,n){return QB(this,t,r,!0,n)};be.prototype.writeDoubleBE=function(t,r,n){return QB(this,t,r,!1,n)};be.prototype.copy=function(t,r,n,i){if(!be.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 o;if(typeof t=="number")for(o=r;o2**32?i=jB(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=jB(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function jB(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 zG(e,t,r){Ih(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&e0(t,e.length-(r+1))}function e9(e,t,r,n,i,o){if(e>r||e3?t===0||t===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:a=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:a=`>= ${t}${s} and <= ${r}${s}`,new Dh.ERR_OUT_OF_RANGE("value",a,e)}zG(n,i,o)}function Ih(e,t){if(typeof e!="number")throw new Dh.ERR_INVALID_ARG_TYPE(t,"number",e)}function e0(e,t,r){throw Math.floor(e)!==e?(Ih(e,r),new Dh.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new Dh.ERR_BUFFER_OUT_OF_BOUNDS:new Dh.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var GG=/[^+/0-9A-Za-z-_]/g;function YG(e){if(e=e.split("=")[0],e=e.trim().replace(GG,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function HA(e,t){t=t||1/0;let r,n=e.length,i=null,o=[];for(let s=0;s55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function WG(e){let t=[];for(let r=0;r>8,i=r%256,o.push(i),o.push(n);return o}function t9(e){return NA.toByteArray(YG(e))}function s2(e,t,r,n){let i;for(i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function ga(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function KA(e){return e!==e}var JG=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 Tc(e){return typeof BigInt>"u"?ZG:e}function ZG(){throw new Error("BigInt not supported")}});var F9=Ce(Ne=>{var cwe=B(T()),r0={};r0.userAgent=!1;var $h={},QG="11.1.3",eY="jsrsasign(all) 11.1.3 (2026-04-18) (c) 2010-2023 Kenji Urushima | kjur.github.io/jsrsasign/license";var He=He||function(e,t){var r={},n=r.lib={},i=n.Base=function(){function d(){}return{extend:function(v){d.prototype=this;var g=new d;return v&&g.mixIn(v),g.hasOwnProperty("init")||(g.init=function(){g.$super.init.apply(this,arguments)}),g.init.prototype=g,g.$super=this,g},create:function(){var v=this.extend();return v.init.apply(v,arguments),v},init:function(){},mixIn:function(v){for(var g in v)v.hasOwnProperty(g)&&(this[g]=v[g]);v.hasOwnProperty("toString")&&(this.toString=v.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),o=n.WordArray=i.extend({init:function(d,v){d=this.words=d||[],v!=t?this.sigBytes=v:this.sigBytes=d.length*4},toString:function(d){return(d||a).stringify(this)},concat:function(d){var v=this.words,g=d.words,y=this.sigBytes,w=d.sigBytes;if(this.clamp(),y%4)for(var E=0;E>>2]>>>24-E%4*8&255;v[y+E>>>2]|=S<<24-(y+E)%4*8}else for(var E=0;E>>2]=g[E>>>2];return this.sigBytes+=w,this},clamp:function(){var d=this.words,v=this.sigBytes;d[v>>>2]&=4294967295<<32-v%4*8,d.length=e.ceil(v/4)},clone:function(){var d=i.clone.call(this);return d.words=this.words.slice(0),d},random:function(d){for(var v=[],g=0;g>>2]>>>24-w%4*8&255;y.push((E>>>4).toString(16)),y.push((E&15).toString(16))}return y.join("")},parse:function(d){for(var v=d.length,g=[],y=0;y>>3]|=parseInt(d.substr(y,2),16)<<24-y%8*4;return new o.init(g,v/2)}},u=s.Latin1={stringify:function(d){for(var v=d.words,g=d.sigBytes,y=[],w=0;w>>2]>>>24-w%4*8&255;y.push(String.fromCharCode(E))}return y.join("")},parse:function(d){for(var v=d.length,g=[],y=0;y>>2]|=(d.charCodeAt(y)&255)<<24-y%4*8;return new o.init(g,v)}},l=s.Utf8={stringify:function(d){try{return decodeURIComponent(escape(u.stringify(d)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(d){return u.parse(unescape(encodeURIComponent(d)))}},f=n.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(d){typeof d=="string"&&(d=l.parse(d)),this._data.concat(d),this._nDataBytes+=d.sigBytes},_process:function(d){var v=this._data,g=v.words,y=v.sigBytes,w=this.blockSize,E=w*4,S=y/E;d?S=e.ceil(S):S=e.max((S|0)-this._minBufferSize,0);var D=S*w,F=e.min(D*4,y);if(D){for(var M=0;M>>2]&255}},t.BlockCipher=a.extend({cfg:a.cfg.extend({mode:m,padding:l}),reset:function(){a.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 f=t.CipherParams=r.extend({init:function(g){this.mixIn(g)},toString:function(g){return(g||this.formatter).stringify(this)}}),m=(d.format={}).OpenSSL={stringify:function(g){var y=g.ciphertext;return g=g.salt,(g?n.create([1398893684,1701076831]).concat(g).concat(y):y).toString(o)},parse:function(g){g=o.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 f.create({ciphertext:g,salt:w})}},p=t.SerializableCipher=r.extend({cfg:r.extend({format:m}),encrypt:function(g,y,w,E){E=this.cfg.extend(E);var S=g.createEncryptor(w,E);return y=S.finalize(y),S=S.cfg,f.create({ciphertext:y,key:w,iv:S.iv,algorithm:g,mode:S.mode,padding:S.padding,blockSize:g.blockSize,formatter:E.format})},decrypt:function(g,y,w,E){return E=this.cfg.extend(E),y=this._parse(y,E.format),g.createDecryptor(w,E).finalize(y.ciphertext)},_parse:function(g,y){return typeof g=="string"?y.parse(g,this):g}}),d=(d.kdf={}).OpenSSL={execute:function(g,y,w,E){return E||(E=n.random(8)),g=s.create({keySize:y+w}).compute(g,E),w=n.create(g.words.slice(y),4*w),g.sigBytes=4*y,f.create({key:g,iv:w,salt:E})}},v=t.PasswordBasedCipher=p.extend({cfg:p.cfg.extend({kdf:d}),encrypt:function(g,y,w,E){return E=this.cfg.extend(E),w=E.kdf.execute(w,g.keySize,g.ivSize),E.iv=w.iv,g=p.encrypt.call(this,g,y,w.key,E),g.mixIn(w),g},decrypt:function(g,y,w,E){return E=this.cfg.extend(E),y=this._parse(y,E.format),w=E.kdf.execute(w,g.keySize,g.ivSize,y.salt),E.iv=w.iv,p.decrypt.call(this,g,y,w.key,E)}})}();(function(){for(var e=He,t=e.lib.BlockCipher,M=e.algo,r=[],n=[],i=[],o=[],s=[],a=[],u=[],l=[],f=[],m=[],p=[],d=0;256>d;d++)p[d]=128>d?d<<1:d<<1^283;for(var v=0,g=0,d=0;256>d;d++){var y=g^g<<1^g<<2^g<<3^g<<4,y=y>>>8^y&255^99;r[v]=y,n[y]=v;var w=p[v],E=p[w],S=p[E],D=257*p[y]^16843008*y;i[v]=D<<24|D>>>8,o[v]=D<<16|D>>>16,s[v]=D<<8|D>>>24,a[v]=D,D=16843009*S^65537*E^257*w^16843008*v,u[y]=D<<24|D>>>8,l[y]=D<<16|D>>>16,f[y]=D<<8|D>>>24,m[y]=D,v?(v=w^p[p[p[S^w]]],g^=p[p[g]]):v=g=1}var F=[0,1,2,4,8,16,32,64,128,27,54],M=M.AES=t.extend({_doReset:function(){for(var P=this._key,z=P.words,C=P.sigBytes/4,P=4*((this._nRounds=C+6)+1),U=this._keySchedule=[],k=0;k>>24]<<24|r[O>>>16&255]<<16|r[O>>>8&255]<<8|r[O&255]):(O=O<<8|O>>>24,O=r[O>>>24]<<24|r[O>>>16&255]<<16|r[O>>>8&255]<<8|r[O&255],O^=F[k/C|0]<<24),U[k]=U[k-C]^O}for(z=this._invKeySchedule=[],C=0;CC||4>=k?O:u[r[O>>>24]]^l[r[O>>>16&255]]^f[r[O>>>8&255]]^m[r[O&255]]},encryptBlock:function(z,C){this._doCryptBlock(z,C,this._keySchedule,i,o,s,a,r)},decryptBlock:function(z,C){var P=z[C+1];z[C+1]=z[C+3],z[C+3]=P,this._doCryptBlock(z,C,this._invKeySchedule,u,l,f,m,n),P=z[C+1],z[C+1]=z[C+3],z[C+3]=P},_doCryptBlock:function(z,C,P,U,k,O,q,N){for(var _=this._nRounds,fe=z[C]^P[0],ve=z[C+1]^P[1],we=z[C+2]^P[2],se=z[C+3]^P[3],R=4,K=1;K<_;K++)var Z=U[fe>>>24]^k[ve>>>16&255]^O[we>>>8&255]^q[se&255]^P[R++],Y=U[ve>>>24]^k[we>>>16&255]^O[se>>>8&255]^q[fe&255]^P[R++],te=U[we>>>24]^k[se>>>16&255]^O[fe>>>8&255]^q[ve&255]^P[R++],se=U[se>>>24]^k[fe>>>16&255]^O[ve>>>8&255]^q[we&255]^P[R++],fe=Z,ve=Y,we=te;Z=(N[fe>>>24]<<24|N[ve>>>16&255]<<16|N[we>>>8&255]<<8|N[se&255])^P[R++],Y=(N[ve>>>24]<<24|N[we>>>16&255]<<16|N[se>>>8&255]<<8|N[fe&255])^P[R++],te=(N[we>>>24]<<24|N[se>>>16&255]<<16|N[fe>>>8&255]<<8|N[ve&255])^P[R++],se=(N[se>>>24]<<24|N[fe>>>16&255]<<16|N[ve>>>8&255]<<8|N[we&255])^P[R++],z[C]=Z,z[C+1]=Y,z[C+2]=te,z[C+3]=se},keySize:8});e.AES=t._createHelper(M)})();(function(){function e(p,d){var v=(this._lBlock>>>p^this._rBlock)&d;this._rBlock^=v,this._lBlock^=v<>>p^this._lBlock)&d;this._lBlock^=v,this._rBlock^=v<v;v++){var g=s[v]-1;d[v]=p[g>>>5]>>>31-g%32&1}for(p=this._subKeys=[],g=0;16>g;g++){for(var y=p[g]=[],w=u[g],v=0;24>v;v++)y[v/6|0]|=d[(a[v]-1+w)%28]<<31-v%6,y[4+(v/6|0)]|=d[28+(a[v+24]-1+w)%28]<<31-v%6;for(y[0]=y[0]<<1|y[0]>>>31,v=1;7>v;v++)y[v]>>>=4*(v-1)+3;y[7]=y[7]<<5|y[7]>>>27}for(d=this._invSubKeys=[],v=0;16>v;v++)d[v]=p[15-v]},encryptBlock:function(p,d){this._doCryptBlock(p,d,this._subKeys)},decryptBlock:function(p,d){this._doCryptBlock(p,d,this._invSubKeys)},_doCryptBlock:function(p,d,v){this._lBlock=p[d],this._rBlock=p[d+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=v[g],w=this._lBlock,E=this._rBlock,S=0,D=0;8>D;D++)S|=l[D][((E^y[D])&f[D])>>>0];this._lBlock=E,this._rBlock=w^S}v=this._lBlock,this._lBlock=this._rBlock,this._rBlock=v,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[d]=this._lBlock,p[d+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});r.DES=i._createHelper(m),o=o.TripleDES=i.extend({_doReset:function(){var p=this._key.words;this._des1=m.createEncryptor(n.create(p.slice(0,2))),this._des2=m.createEncryptor(n.create(p.slice(2,4))),this._des3=m.createEncryptor(n.create(p.slice(4,6)))},encryptBlock:function(p,d){this._des1.encryptBlock(p,d),this._des2.decryptBlock(p,d),this._des3.encryptBlock(p,d)},decryptBlock:function(p,d){this._des3.decryptBlock(p,d),this._des2.encryptBlock(p,d),this._des1.decryptBlock(p,d)},keySize:6,ivSize:2,blockSize:2}),r.TripleDES=i._createHelper(o)})();(function(){var e=He,t=e.lib.WordArray;e.enc.Base64={stringify:function(r){var n=r.words,i=r.sigBytes,o=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,u=0;4>u&&s+.75*u>>6*(3-u)&63));if(n=o.charAt(64))for(;r.length%4;)r.push(n);return r.join("")},parse:function(r){var n=r.length,i=this._map,o=i.charAt(64);o&&(o=r.indexOf(o),o!=-1&&(n=o));for(var o=[],s=0,a=0;a>>6-2*(a%4);o[s>>>2]|=(u|l)<<24-8*(s%4),s++}return t.create(o,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}})();(function(e){function t(m,p,d,v,g,y,w){return m=m+(p&d|~p&v)+g+w,(m<>>32-y)+p}function r(m,p,d,v,g,y,w){return m=m+(p&v|d&~v)+g+w,(m<>>32-y)+p}function n(m,p,d,v,g,y,w){return m=m+(p^d^v)+g+w,(m<>>32-y)+p}function i(m,p,d,v,g,y,w){return m=m+(d^(p|~v))+g+w,(m<>>32-y)+p}for(var o=He,u=o.lib,s=u.WordArray,a=u.Hasher,u=o.algo,l=[],f=0;64>f;f++)l[f]=4294967296*e.abs(e.sin(f+1))|0;u=u.MD5=a.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(m,p){for(var d=0;16>d;d++){var v=p+d,g=m[v];m[v]=(g<<8|g>>>24)&16711935|(g<<24|g>>>8)&4278255360}var d=this._hash.words,v=m[p+0],g=m[p+1],y=m[p+2],w=m[p+3],E=m[p+4],S=m[p+5],D=m[p+6],F=m[p+7],M=m[p+8],z=m[p+9],C=m[p+10],P=m[p+11],U=m[p+12],k=m[p+13],O=m[p+14],q=m[p+15],N=d[0],K=d[1],R=d[2],_=d[3],N=t(N,K,R,_,v,7,l[0]),_=t(_,N,K,R,g,12,l[1]),R=t(R,_,N,K,y,17,l[2]),K=t(K,R,_,N,w,22,l[3]),N=t(N,K,R,_,E,7,l[4]),_=t(_,N,K,R,S,12,l[5]),R=t(R,_,N,K,D,17,l[6]),K=t(K,R,_,N,F,22,l[7]),N=t(N,K,R,_,M,7,l[8]),_=t(_,N,K,R,z,12,l[9]),R=t(R,_,N,K,C,17,l[10]),K=t(K,R,_,N,P,22,l[11]),N=t(N,K,R,_,U,7,l[12]),_=t(_,N,K,R,k,12,l[13]),R=t(R,_,N,K,O,17,l[14]),K=t(K,R,_,N,q,22,l[15]),N=r(N,K,R,_,g,5,l[16]),_=r(_,N,K,R,D,9,l[17]),R=r(R,_,N,K,P,14,l[18]),K=r(K,R,_,N,v,20,l[19]),N=r(N,K,R,_,S,5,l[20]),_=r(_,N,K,R,C,9,l[21]),R=r(R,_,N,K,q,14,l[22]),K=r(K,R,_,N,E,20,l[23]),N=r(N,K,R,_,z,5,l[24]),_=r(_,N,K,R,O,9,l[25]),R=r(R,_,N,K,w,14,l[26]),K=r(K,R,_,N,M,20,l[27]),N=r(N,K,R,_,k,5,l[28]),_=r(_,N,K,R,y,9,l[29]),R=r(R,_,N,K,F,14,l[30]),K=r(K,R,_,N,U,20,l[31]),N=n(N,K,R,_,S,4,l[32]),_=n(_,N,K,R,M,11,l[33]),R=n(R,_,N,K,P,16,l[34]),K=n(K,R,_,N,O,23,l[35]),N=n(N,K,R,_,g,4,l[36]),_=n(_,N,K,R,E,11,l[37]),R=n(R,_,N,K,F,16,l[38]),K=n(K,R,_,N,C,23,l[39]),N=n(N,K,R,_,k,4,l[40]),_=n(_,N,K,R,v,11,l[41]),R=n(R,_,N,K,w,16,l[42]),K=n(K,R,_,N,D,23,l[43]),N=n(N,K,R,_,z,4,l[44]),_=n(_,N,K,R,U,11,l[45]),R=n(R,_,N,K,q,16,l[46]),K=n(K,R,_,N,y,23,l[47]),N=i(N,K,R,_,v,6,l[48]),_=i(_,N,K,R,F,10,l[49]),R=i(R,_,N,K,O,15,l[50]),K=i(K,R,_,N,S,21,l[51]),N=i(N,K,R,_,U,6,l[52]),_=i(_,N,K,R,w,10,l[53]),R=i(R,_,N,K,C,15,l[54]),K=i(K,R,_,N,g,21,l[55]),N=i(N,K,R,_,M,6,l[56]),_=i(_,N,K,R,q,10,l[57]),R=i(R,_,N,K,D,15,l[58]),K=i(K,R,_,N,k,21,l[59]),N=i(N,K,R,_,E,6,l[60]),_=i(_,N,K,R,P,10,l[61]),R=i(R,_,N,K,y,15,l[62]),K=i(K,R,_,N,z,21,l[63]);d[0]=d[0]+N|0,d[1]=d[1]+K|0,d[2]=d[2]+R|0,d[3]=d[3]+_|0},_doFinalize:function(){var m=this._data,p=m.words,d=8*this._nDataBytes,v=8*m.sigBytes;p[v>>>5]|=128<<24-v%32;var g=e.floor(d/4294967296);for(p[(v+64>>>9<<4)+15]=(g<<8|g>>>24)&16711935|(g<<24|g>>>8)&4278255360,p[(v+64>>>9<<4)+14]=(d<<8|d>>>24)&16711935|(d<<24|d>>>8)&4278255360,m.sigBytes=4*(p.length+1),this._process(),m=this._hash,p=m.words,d=0;4>d;d++)v=p[d],p[d]=(v<<8|v>>>24)&16711935|(v<<24|v>>>8)&4278255360;return m},clone:function(){var m=a.clone.call(this);return m._hash=this._hash.clone(),m}}),o.MD5=a._createHelper(u),o.HmacMD5=a._createHmacHelper(u)})(Math);(function(){var e=He,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(o,s){for(var a=this._hash.words,u=a[0],l=a[1],f=a[2],m=a[3],p=a[4],d=0;80>d;d++){if(16>d)n[d]=o[s+d]|0;else{var v=n[d-3]^n[d-8]^n[d-14]^n[d-16];n[d]=v<<1|v>>>31}v=(u<<5|u>>>27)+p+n[d],v=20>d?v+((l&f|~l&m)+1518500249):40>d?v+((l^f^m)+1859775393):60>d?v+((l&f|l&m|f&m)-1894007588):v+((l^f^m)-899497514),p=m,m=f,f=l<<30|l>>>2,l=u,u=v}a[0]=a[0]+u|0,a[1]=a[1]+l|0,a[2]=a[2]+f|0,a[3]=a[3]+m|0,a[4]=a[4]+p|0},_doFinalize:function(){var o=this._data,s=o.words,a=8*this._nDataBytes,u=8*o.sigBytes;return s[u>>>5]|=128<<24-u%32,s[(u+64>>>9<<4)+14]=Math.floor(a/4294967296),s[(u+64>>>9<<4)+15]=a,o.sigBytes=4*s.length,this._process(),this._hash},clone:function(){var o=r.clone.call(this);return o._hash=this._hash.clone(),o}});e.SHA1=r._createHelper(i),e.HmacSHA1=r._createHmacHelper(i)})();(function(e){for(var t=He,d=t.lib,r=d.WordArray,n=d.Hasher,d=t.algo,i=[],o=[],s=function(g){return 4294967296*(g-(g|0))|0},a=2,u=0;64>u;){var l;e:{l=a;for(var f=e.sqrt(l),m=2;m<=f;m++)if(!(l%m)){l=!1;break e}l=!0}l&&(8>u&&(i[u]=s(e.pow(a,.5))),o[u]=s(e.pow(a,1/3)),u++),a++}var p=[],d=d.SHA256=n.extend({_doReset:function(){this._hash=new r.init(i.slice(0))},_doProcessBlock:function(v,g){for(var y=this._hash.words,w=y[0],E=y[1],S=y[2],D=y[3],F=y[4],M=y[5],z=y[6],C=y[7],P=0;64>P;P++){if(16>P)p[P]=v[g+P]|0;else{var U=p[P-15],k=p[P-2];p[P]=((U<<25|U>>>7)^(U<<14|U>>>18)^U>>>3)+p[P-7]+((k<<15|k>>>17)^(k<<13|k>>>19)^k>>>10)+p[P-16]}U=C+((F<<26|F>>>6)^(F<<21|F>>>11)^(F<<7|F>>>25))+(F&M^~F&z)+o[P]+p[P],k=((w<<30|w>>>2)^(w<<19|w>>>13)^(w<<10|w>>>22))+(w&E^w&S^E&S),C=z,z=M,M=F,F=D+U|0,D=S,S=E,E=w,w=U+k|0}y[0]=y[0]+w|0,y[1]=y[1]+E|0,y[2]=y[2]+S|0,y[3]=y[3]+D|0,y[4]=y[4]+F|0,y[5]=y[5]+M|0,y[6]=y[6]+z|0,y[7]=y[7]+C|0},_doFinalize:function(){var v=this._data,g=v.words,y=8*this._nDataBytes,w=8*v.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,v.sigBytes=4*g.length,this._process(),this._hash},clone:function(){var v=n.clone.call(this);return v._hash=this._hash.clone(),v}});t.SHA256=n._createHelper(d),t.HmacSHA256=n._createHmacHelper(d)})(Math);(function(){var e=He,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=He,r=t.lib.Hasher,o=t.x64,n=o.Word,i=o.WordArray,o=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)],a=[],u=0;80>u;u++)a[u]=e();o=o.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(l,f){for(var E=this._hash.words,m=E[0],p=E[1],d=E[2],v=E[3],g=E[4],y=E[5],w=E[6],E=E[7],S=m.high,D=m.low,F=p.high,M=p.low,z=d.high,C=d.low,P=v.high,U=v.low,k=g.high,O=g.low,q=y.high,N=y.low,_=w.high,R=w.low,K=E.high,Z=E.low,Y=S,te=D,se=F,fe=M,ve=z,we=C,Te=P,Le=U,Oe=k,le=O,Se=q,Re=N,Ve=_,rt=R,qe=K,At=Z,it=0;80>it;it++){var Ar=a[it];if(16>it)var Et=Ar.high=l[f+2*it]|0,Ue=Ar.low=l[f+2*it+1]|0;else{var Et=a[it-15],Ue=Et.high,bt=Et.low,Et=(Ue>>>1|bt<<31)^(Ue>>>8|bt<<24)^Ue>>>7,bt=(bt>>>1|Ue<<31)^(bt>>>8|Ue<<24)^(bt>>>7|Ue<<25),Mr=a[it-2],Ue=Mr.high,Rt=Mr.low,Mr=(Ue>>>19|Rt<<13)^(Ue<<3|Rt>>>29)^Ue>>>6,Rt=(Rt>>>19|Ue<<13)^(Rt<<3|Ue>>>29)^(Rt>>>6|Ue<<26),Ue=a[it-7],pn=Ue.high,Ir=a[it-16],st=Ir.high,Ir=Ir.low,Ue=bt+Ue.low,Et=Et+pn+(Ue>>>0>>0?1:0),Ue=Ue+Rt,Et=Et+Mr+(Ue>>>0>>0?1:0),Ue=Ue+Ir,Et=Et+st+(Ue>>>0>>0?1:0);Ar.high=Et,Ar.low=Ue}var pn=Oe&Se^~Oe&Ve,Ir=le&Re^~le&rt,Ar=Y&se^Y&ve^se&ve,Br=te&fe^te&we^fe&we,bt=(Y>>>28|te<<4)^(Y<<30|te>>>2)^(Y<<25|te>>>7),Mr=(te>>>28|Y<<4)^(te<<30|Y>>>2)^(te<<25|Y>>>7),Rt=s[it],Yn=Rt.high,ni=Rt.low,Rt=At+((le>>>14|Oe<<18)^(le>>>18|Oe<<14)^(le<<23|Oe>>>9)),st=qe+((Oe>>>14|le<<18)^(Oe>>>18|le<<14)^(Oe<<23|le>>>9))+(Rt>>>0>>0?1:0),Rt=Rt+Ir,st=st+pn+(Rt>>>0>>0?1:0),Rt=Rt+ni,st=st+Yn+(Rt>>>0>>0?1:0),Rt=Rt+Ue,st=st+Et+(Rt>>>0>>0?1:0),Ue=Mr+Br,Ar=bt+Ar+(Ue>>>0>>0?1:0),qe=Ve,At=rt,Ve=Se,rt=Re,Se=Oe,Re=le,le=Le+Rt|0,Oe=Te+st+(le>>>0>>0?1:0)|0,Te=ve,Le=we,ve=se,we=fe,se=Y,fe=te,te=Rt+Ue|0,Y=st+Ar+(te>>>0>>0?1:0)|0}D=m.low=D+te,m.high=S+Y+(D>>>0>>0?1:0),M=p.low=M+fe,p.high=F+se+(M>>>0>>0?1:0),C=d.low=C+we,d.high=z+ve+(C>>>0>>0?1:0),U=v.low=U+Le,v.high=P+Te+(U>>>0>>0?1:0),O=g.low=O+le,g.high=k+Oe+(O>>>0>>0?1:0),N=y.low=N+Re,y.high=q+Se+(N>>>0>>0?1:0),R=w.low=R+rt,w.high=_+Ve+(R>>>0>>0?1:0),Z=E.low=Z+At,E.high=K+qe+(Z>>>0>>0?1:0)},_doFinalize:function(){var l=this._data,f=l.words,m=8*this._nDataBytes,p=8*l.sigBytes;return f[p>>>5]|=128<<24-p%32,f[(p+128>>>10<<5)+30]=Math.floor(m/4294967296),f[(p+128>>>10<<5)+31]=m,l.sigBytes=4*f.length,this._process(),this._hash.toX32()},clone:function(){var l=r.clone.call(this);return l._hash=this._hash.clone(),l},blockSize:32}),t.SHA512=r._createHelper(o),t.HmacSHA512=r._createHmacHelper(o)})();(function(){var e=He,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 o=n._doFinalize.call(this);return o.sigBytes-=16,o}});e.SHA384=n._createHelper(i),e.HmacSHA384=n._createHmacHelper(i)})();(function(){var e=He,l=e.lib,t=l.WordArray,r=l.Hasher,l=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]),o=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]),a=t.create([0,1518500249,1859775393,2400959708,2840853838]),u=t.create([1352829926,1548603684,1836072691,2053994217,0]),l=l.RIPEMD160=r.extend({_doReset:function(){this._hash=t.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(f,m){for(var p=0;16>p;p++){var d=m+p,v=f[d];f[d]=(v<<8|v>>>24)&16711935|(v<<24|v>>>8)&4278255360}var d=this._hash.words,v=a.words,g=u.words,y=n.words,w=i.words,E=o.words,S=s.words,D,F,M,z,C,P,U,k,O,q;P=D=d[0],U=F=d[1],k=M=d[2],O=z=d[3],q=C=d[4];for(var N,p=0;80>p;p+=1)N=D+f[m+y[p]]|0,N=16>p?N+((F^M^z)+v[0]):32>p?N+((F&M|~F&z)+v[1]):48>p?N+(((F|~M)^z)+v[2]):64>p?N+((F&z|M&~z)+v[3]):N+((F^(M|~z))+v[4]),N|=0,N=N<>>32-E[p],N=N+C|0,D=C,C=z,z=M<<10|M>>>22,M=F,F=N,N=P+f[m+w[p]]|0,N=16>p?N+((U^(k|~O))+g[0]):32>p?N+((U&O|k&~O)+g[1]):48>p?N+(((U|~k)^O)+g[2]):64>p?N+((U&k|~U&O)+g[3]):N+((U^k^O)+g[4]),N|=0,N=N<>>32-S[p],N=N+q|0,P=q,q=O,O=k<<10|k>>>22,k=U,U=N;N=d[1]+M+O|0,d[1]=d[2]+z+q|0,d[2]=d[3]+C+P|0,d[3]=d[4]+D+U|0,d[4]=d[0]+F+k|0,d[0]=N},_doFinalize:function(){var f=this._data,m=f.words,p=8*this._nDataBytes,d=8*f.sigBytes;for(m[d>>>5]|=128<<24-d%32,m[(d+64>>>9<<4)+14]=(p<<8|p>>>24)&16711935|(p<<24|p>>>8)&4278255360,f.sigBytes=4*(m.length+1),this._process(),f=this._hash,m=f.words,p=0;5>p;p++)d=m[p],m[p]=(d<<8|d>>>24)&16711935|(d<<24|d>>>8)&4278255360;return f},clone:function(){var f=r.clone.call(this);return f._hash=this._hash.clone(),f}});e.RIPEMD160=r._createHelper(l),e.HmacRIPEMD160=r._createHmacHelper(l)})(Math);(function(){var e=He,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,o=4*i;n.sigBytes>o&&(n=r.finalize(n)),n.clamp();for(var s=this._oKey=n.clone(),a=this._iKey=n.clone(),u=s.words,l=a.words,f=0;f>6)+Th.charAt(r&63);if(t+1==e.length?(r=parseInt(e.substring(t,t+1),16),n+=Th.charAt(r<<2)):t+2==e.length&&(r=parseInt(e.substring(t,t+2),16),n+=Th.charAt(r>>2)+Th.charAt((r&3)<<4)),GA)for(;(n.length&3)>0;)n+=GA;return n}function xh(e){var t="",r,n=0,i,o;for(r=0;r>2),i=o&3,n=1):n==1?(t+=Au(i<<2|o>>4),i=o&15,n=2):n==2?(t+=Au(i),t+=Au(o>>2),i=o&3,n=3):(t+=Au(i<<2|o>>4),t+=Au(o&15),n=0));return n==1&&(t+=Au(i<<2)),t}function i9(e){var t=xh(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 nY(e,t,r,n,i,o){for(var s=t&32767,a=t>>15;--o>=0;){var u=this[e]&32767,l=this[e++]>>15,f=a*u+l*s;u=s*u+((f&32767)<<15)+r[n]+(i&1073741823),i=(u>>>30)+(f>>>15)+a*l+(i>>>30),r[n++]=u&1073741823}return i}function sY(e,t,r,n,i,o){for(var s=t&16383,a=t>>14;--o>=0;){var u=this[e]&16383,l=this[e++]>>14,f=a*u+l*s;u=s*u+((f&16383)<<14)+r[n]+i,i=(u>>28)+(f>>14)+a*l,r[n++]=u&268435455}return i}r9&&r0.appName=="Microsoft Internet Explorer"?(oe.prototype.am=nY,xc=30):r9&&r0.appName!="Netscape"?(oe.prototype.am=rY,xc=26):(oe.prototype.am=sY,xc=28);oe.prototype.DB=xc;oe.prototype.DM=(1<=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s}function aY(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 Pc(e){var t=Gt();return t.fromInt(e),t}function uY(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,o=0;--n>=0;){var s=r==8?e[n]&255:o9(e,n);if(s<0){e.charAt(n)=="-"&&(i=!0);continue}i=!1,o==0?this[this.t++]=s:o+r>this.DB?(this[this.t-1]|=(s&(1<>this.DB-o):this[this.t-1]|=s<=this.DB&&(o-=this.DB)}r==8&&e[0]&128&&(this.s=-1,o>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==e;)--this.t}function lY(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(a>a)>0&&(i=!0,o=Au(n));s>=0;)a>(a+=this.DB-t)):(n=this[s]>>(a-=t)&r,a<=0&&(a+=this.DB,--s)),n>0&&(i=!0),i&&(o+=Au(n));return i?o:"0"}function fY(){var e=Gt();return oe.ZERO.subTo(this,e),e}function hY(){return this.s<0?this.negate():this}function dY(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 h2(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 pY(){return this.t<=0?0:this.DB*(this.t-1)+h2(this[this.t-1]^this.s&this.DM)}function mY(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 gY(e,t){for(var r=e;r=0;--a)t[a+o+1]=this[a]>>n|s,s=(this[a]&i)<=0;--a)t[a]=0;t[o]=s,t.t=this.t+o+1,t.s=this.s,t.clamp()}function wY(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,o=(1<>n;for(var s=r+1;s>n;n>0&&(t[this.t-r-1]|=(this.s&o)<>=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 EY(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 AY(e,t,r){var n=e.abs();if(n.t<=0)throw"BigInteger divide by zero";var i=this.abs();if(i.t0?(n.lShiftTo(u,o),i.lShiftTo(u,r)):(n.copyTo(o),i.copyTo(r));var l=o.t,f=o[l-1];if(f!=0){var m=f*(1<1?o[l-2]>>this.F2:0),p=this.FV/m,d=(1<=0&&(r[r.t++]=1,r.subTo(w,r)),oe.ONE.dlShiftTo(l,w),w.subTo(o,o);o.t=0;){var E=r[--g]==f?this.DM:Math.floor(r[g]*p+(r[g-1]+v)*d);if((r[g]+=o.am(0,E,r,y,0,l))0&&r.rShiftTo(u,r),s<0&&oe.ZERO.subTo(r,r)}}function SY(e){var t=Gt();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(oe.ZERO)>0&&e.subTo(t,t),t}function ef(e){this.m=e}function CY(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e}function _Y(e){return e}function DY(e){e.divRemTo(this.m,null,e)}function FY(e,t,r){e.multiplyTo(t,r),this.reduce(r)}function IY(e,t){e.squareTo(t),this.reduce(t)}ef.prototype.convert=CY;ef.prototype.revert=_Y;ef.prototype.reduce=DY;ef.prototype.mulTo=FY;ef.prototype.sqrTo=IY;function BY(){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 tf(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 TY(e){var t=Gt();return e.copyTo(t),this.reduce(t),t}function PY(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 xY(e,t){e.squareTo(t),this.reduce(t)}function RY(e,t,r){e.multiplyTo(t,r),this.reduce(r)}tf.prototype.convert=$Y;tf.prototype.revert=TY;tf.prototype.reduce=PY;tf.prototype.mulTo=RY;tf.prototype.sqrTo=xY;function kY(){return(this.t>0?this[0]&1:this.s)==0}function OY(e,t){if(e>4294967295||e<1)return oe.ONE;var r=Gt(),n=Gt(),i=t.convert(this),o=h2(e)-1;for(i.copyTo(r);--o>=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 NY(e,t){var r;return e<256||t.isEven()?r=new ef(t):r=new tf(t),this.exp(e,r)}oe.prototype.copyTo=oY;oe.prototype.fromInt=aY;oe.prototype.fromString=uY;oe.prototype.clamp=cY;oe.prototype.dlShiftTo=mY;oe.prototype.drShiftTo=gY;oe.prototype.lShiftTo=vY;oe.prototype.rShiftTo=wY;oe.prototype.subTo=yY;oe.prototype.multiplyTo=EY;oe.prototype.squareTo=bY;oe.prototype.divRemTo=AY;oe.prototype.invDigit=BY;oe.prototype.isEven=kY;oe.prototype.exp=OY;oe.prototype.toString=lY;oe.prototype.negate=fY;oe.prototype.abs=hY;oe.prototype.compareTo=dY;oe.prototype.bitLength=pY;oe.prototype.mod=SY;oe.prototype.modPowInt=NY;oe.ZERO=Pc(0);oe.ONE=Pc(1);function LY(){var e=Gt();return this.copyTo(e),e}function UY(){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 MY(){return this.t==0?this.s:this[0]<<16>>16}function qY(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}function jY(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function KY(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=Pc(r),i=Gt(),o=Gt(),s="";for(this.divRemTo(n,i,o);i.signum()>0;)s=(r+o.intValue()).toString(e).substr(1)+s,i.divRemTo(n,i,o);return o.intValue().toString(e)+s}function VY(e,t){this.fromInt(0),t==null&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),i=!1,o=0,s=0,a=0;a=r&&(this.dMultiply(n),this.dAddOffset(s,0),o=0,s=0)}o>0&&(this.dMultiply(Math.pow(t,o)),this.dAddOffset(s,0)),i&&oe.ZERO.subTo(this,this)}function zY(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(oe.ONE.shiftLeft(e-1),ZA,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(oe.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 YY(e){return this.compareTo(e)==0}function WY(e){return this.compareTo(e)<0?this:e}function XY(e){return this.compareTo(e)>0?this:e}function JY(e,t,r){var n,i,o=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 aW(){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 gW(e){var t=Gt();return this.addTo(e,t),t}function vW(e){var t=Gt();return this.subTo(e,t),t}function wW(e){var t=Gt();return this.multiplyTo(e,t),t}function yW(){var e=Gt();return this.squareTo(e),e}function EW(e){var t=Gt();return this.divRemTo(e,t,null),t}function bW(e){var t=Gt();return this.divRemTo(e,null,t),t}function AW(e){var t=Gt(),r=Gt();return this.divRemTo(e,t,r),new Array(t,r)}function SW(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}function CW(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 s0(){}function c9(e){return e}function _W(e,t,r){e.multiplyTo(t,r)}function DW(e,t){e.squareTo(t)}s0.prototype.convert=c9;s0.prototype.revert=c9;s0.prototype.mulTo=_W;s0.prototype.sqrTo=DW;function FW(e){return this.exp(e,new s0)}function IW(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=Gt();return e.copyTo(t),this.reduce(t),t}function TW(e){return e}function PW(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 xW(e,t){e.squareTo(t),this.reduce(t)}function RW(e,t,r){e.multiplyTo(t,r),this.reduce(r)}kh.prototype.convert=$W;kh.prototype.revert=TW;kh.prototype.reduce=PW;kh.prototype.mulTo=RW;kh.prototype.sqrTo=xW;function kW(e,t){if(e.signum()<0)return this.modInverse(t).modPow(e.negate(),t);var r=e.bitLength(),n,i=Pc(1),o;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?o=new ef(t):t.isEven()?o=new kh(t):o=new tf(t);var s=new Array,a=3,u=n-1,l=(1<1){var f=Gt();for(o.sqrTo(s[1],f);a<=l;)s[a]=Gt(),o.mulTo(f,s[a-2],s[a]),a+=2}var m=e.t-1,p,d=!0,v=Gt(),g;for(r=h2(e[m])-1;m>=0;){for(r>=u?p=e[m]>>r-u&l:(p=(e[m]&(1<0&&(p|=e[m-1]>>this.DB+r-u)),a=n;!(p&1);)p>>=1,--a;if((r-=a)<0&&(r+=this.DB,--m),d)s[p].copyTo(i),d=!1;else{for(;a>1;)o.sqrTo(i,v),o.sqrTo(v,i),a-=2;a>0?o.sqrTo(i,v):(g=i,i=v,v=g),o.mulTo(v,s[p],i)}for(;m>=0&&!(e[m]&1<0&&(t.rShiftTo(o,t),r.rShiftTo(o,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 o>0&&r.lShiftTo(o,r),r}function NW(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 LW(e){if(e.signum()==0)return oe.ZERO;var t=this.mod(e),r=e.isEven();if(t.isEven()&&r||t.signum()==0)return oe.ZERO;for(var n=e.clone(),i=t.clone(),o=Pc(1),s=Pc(0),a=Pc(0),u=Pc(1);n.signum()!=0;){for(;n.isEven();)n.rShiftTo(1,n),r?((!o.isEven()||!s.isEven())&&(o.addTo(t,o),s.subTo(e,s)),o.rShiftTo(1,o)):s.isEven()||s.subTo(e,s),s.rShiftTo(1,s);for(;i.isEven();)i.rShiftTo(1,i),r?((!a.isEven()||!u.isEven())&&(a.addTo(t,a),u.subTo(e,u)),a.rShiftTo(1,a)):u.isEven()||u.subTo(e,u),u.rShiftTo(1,u);n.compareTo(i)>=0?(n.subTo(i,n),r&&o.subTo(a,o),s.subTo(u,s)):(i.subTo(n,i),r&&a.subTo(o,a),u.subTo(s,u))}if(i.compareTo(oe.ONE)!=0)return oe.ZERO;if(u.compareTo(e)>=0)return u.subtract(e);if(u.signum()<0)u.addTo(e,u);else return u;return u.signum()<0?u.add(e):u}var xs=[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],UW=(1<<26)/xs[xs.length-1];function HW(e){if(this.signum()<=0)return!1;var t,r=this.abs();if(r.t==1&&r[0]<=xs[xs.length-1]){for(t=0;t>1,e>xs.length&&(e=xs.length);for(var i=Gt(),o=0;o>8&255,Xs[Qr++]^=e>>16&255,Xs[Qr++]^=e>>24&255,Qr>=t0&&(Qr-=t0)}function eS(){VW(new Date().getTime())}if(Xs==null){if(Xs=new Array,Qr=0,typeof $h<"u"&&($h.crypto!==void 0||$h.msCrypto!==void 0)){if(Su=$h.crypto||$h.msCrypto,Su.getRandomValues)for(VA=new Uint8Array(32),Su.getRandomValues(VA),ds=0;ds<32;++ds)Xs[Qr++]=VA[ds];else if(r0.appName=="Netscape"&&r0.appVersion<"5")for(zA=$h.crypto.random(32),ds=0;ds>>8,Xs[Qr++]=ds&255;Qr=0,eS()}var ds,Su,VA,zA,a2;function zW(){if(o2==null){for(eS(),o2=KW(),o2.init(Xs),Qr=0;Qr0&&t.length>0)this.n=Js(e,16),this.e=parseInt(t,16);else throw"Invalid RSA public key";if(this.n==null||typeof this.n.compareTo!="function"||this.n.compareTo(oe.ONE)<=0||this.e==null||isNaN(this.e)||this.e<=0)throw"Invalid RSA public key"}function WW(e){return e.modPowInt(this.e,this.n)}yt.prototype.doPublic=WW;yt.prototype.setPublic=YW;yt.prototype.type="RSA";function XW(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=Js(e,16),this.e=parseInt(t,16),this.d=Js(r,16);else throw"Invalid RSA private key"}function JW(e,t,r,n,i,o,s,a){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=Js(e,16),this.e=parseInt(t,16),this.d=Js(r,16),this.p=Js(n,16),this.q=Js(i,16),this.dmp1=Js(o,16),this.dmq1=Js(s,16),this.coeff=Js(a,16);else throw"Invalid RSA private key in RSASetPrivateEx"}function ZW(e,t){var r=new Oh,n=e>>1;this.e=parseInt(t,16);for(var i=new oe(t,16),o=e/2-100,s=oe.ONE.shiftLeft(o);;){for(;this.p=new oe(e-n,1,r),!(this.p.subtract(oe.ONE).gcd(i).compareTo(oe.ONE)==0&&this.p.isProbablePrime(10)););for(;this.q=new oe(n,1,r),!(this.q.subtract(oe.ONE).gcd(i).compareTo(oe.ONE)==0&&this.q.isProbablePrime(10)););if(this.p.compareTo(this.q)<=0){var a=this.p;this.p=this.q,this.q=a}var u=this.q.subtract(this.p).abs();if(!(u.bitLength()0;--l){i=i.twice();var f=r.testBit(l),m=t.testBit(l);f!=m&&(i=i.add(f?this:n))}for(l=s.bitLength()-2;l>0;--l){a=a.twice();var p=s.testBit(l),d=o.testBit(l);p!=d&&(a=a.add(p?a:u))}return i}function gX(e,t,r){var n;e.bitLength()>r.bitLength()?n=e.bitLength()-1:n=r.bitLength()-1;for(var i=this.curve.getInfinity(),o=this.add(t);n>=0;)i=i.twice(),e.testBit(n)?r.testBit(n)?i=i.add(o):i=i.add(this):r.testBit(n)&&(i=i.add(t)),--n;return i}tr.prototype.getX=uX;tr.prototype.getY=cX;tr.prototype.equals=lX;tr.prototype.isInfinity=fX;tr.prototype.negate=hX;tr.prototype.add=dX;tr.prototype.twice=pX;tr.prototype.multiply=mX;tr.prototype.multiplyTwo=gX;function _u(e,t,r){this.q=e,this.a=this.fromBigInteger(t),this.b=this.fromBigInteger(r),this.infinity=new tr(this,null,null)}function vX(){return this.q}function wX(){return this.a}function yX(){return this.b}function EX(e){return e==this?!0:this.q.equals(e.q)&&this.a.equals(e.a)&&this.b.equals(e.b)}function bX(){return this.infinity}function AX(e){return new dn(this.q,e)}function SX(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 oe(l,16)),i=this.getA(),o=this.getB(),s=n.square().add(i).multiply(n).add(o),a=s.sqrt();return t=="03"&&(a=a.negate()),new tr(this,n,a);case 4:case 6:case 7:var u=(e.length-2)/2,l=e.substr(2,u),f=e.substr(u+2,u);return new tr(this,this.fromBigInteger(new oe(l,16)),this.fromBigInteger(new oe(f,16)));default:return null}}_u.prototype.getQ=vX;_u.prototype.getA=wX;_u.prototype.getB=yX;_u.prototype.equals=EX;_u.prototype.getInfinity=bX;_u.prototype.fromBigInteger=AX;_u.prototype.decodePointHex=SX;dn.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)};tr.prototype.getEncoded=function(e){var t=function(o,s){var a=o.toByteArrayUnsigned();if(sa.length;)a.unshift(0);return a},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};tr.decodeFrom=function(e,t){var r=t[0],n=t.length-1,i=t.slice(1,1+n/2),o=t.slice(1+n/2,1+n);i.unshift(0),o.unshift(0);var s=new oe(i),a=new oe(o);return new tr(e,e.fromBigInteger(s),e.fromBigInteger(a))};tr.decodeFromHex=function(e,t){var r=t.substr(0,2),n=t.length-2,i=t.substr(2,n/2),o=t.substr(2+n/2,n/2),s=new oe(i,16),a=new oe(o,16);return new tr(e,e.fromBigInteger(s),e.fromBigInteger(a))};tr.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),o=n.multiply(this.x.subtract(i)).subtract(this.y);return new tr(this.curve,i,o)};tr.prototype.twice2D=function(){if(this.isInfinity())return this;if(this.y.toBigInteger().signum()==0)return this.curve.getInfinity();var e=this.curve.fromBigInteger(oe.valueOf(2)),t=this.curve.fromBigInteger(oe.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 tr(this.curve,n,i)};tr.prototype.multiply2D=function(e){if(this.isInfinity())return this;if(e.signum()==0)return this.curve.getInfinity();var t=e,r=t.multiply(new oe("3")),n=this.negate(),i=this,o;for(o=r.bitLength()-2;o>0;--o){i=i.twice();var s=r.testBit(o),a=t.testBit(o);s!=a&&(i=i.add2D(s?this:n))}return i};tr.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(),o=t.multiply(t).mod(i),s=e.multiply(e).multiply(e).add(r.multiply(e)).add(n).mod(i);return o.equals(s)};tr.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"};tr.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(oe.ONE)<0||t.compareTo(e.subtract(oe.ONE))>0)throw new Error("x coordinate out of bounds");if(r.compareTo(oe.ONE)<0||r.compareTo(e.subtract(oe.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 l9=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"),o={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:` `,r:"\r",t:" "};function s(m,p,d){return p?o[p]:String.fromCharCode(parseInt(d,16))}var a=new String(""),u="\\",l={"{":Object,"[":Array},f=Object.hasOwnProperty;return function(m,p){var d=m.match(n),v,g=d[0],y=!1;g==="{"?v={}:g==="["?v=[]:(v=[],y=!0);for(var w,E=[v],S=1-y,D=d.length;S=0;)delete P[U[q]]}return p.call(z,C,P)};v=M({"":v},"")}return v}}();(typeof A>"u"||!A)&&(A={});(typeof A.asn1>"u"||!A.asn1)&&(A.asn1={});A.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 o0(e)},this.getPEMStringFromHex=function(e,t){return ps(e,t)},this.newObject=function(e){var t=A,r=t.asn1,n=r.ASN1Object,i=r.DERBoolean,o=r.DERInteger,s=r.DERBitString,a=r.DEROctetString,u=r.DERNull,l=r.DERObjectIdentifier,f=r.DEREnumerated,m=r.DERUTF8String,p=r.DERNumericString,d=r.DERPrintableString,v=r.DERTeletexString,g=r.DERIA5String,y=r.DERUTCTime,w=r.DERGeneralizedTime,E=r.DERVisibleString,S=r.DERBMPString,D=r.DERSequence,F=r.DERSet,M=r.DERTaggedObject,z=r.ASN1Util.newObject;if(e instanceof r.ASN1Object)return e;var C=Object.keys(e);if(C.length!=1)throw new Error("key of param shall be only one.");var P=C[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 o(e[P]);if(P=="bitstr")return new s(e[P]);if(P=="octstr")return new a(e[P]);if(P=="null")return new u(e[P]);if(P=="oid")return new l(e[P]);if(P=="enum")return new f(e[P]);if(P=="utf8str")return new m(e[P]);if(P=="numstr")return new p(e[P]);if(P=="prnstr")return new d(e[P]);if(P=="telstr")return new v(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 E(e[P]);if(P=="bmpstr")return new S(e[P]);if(P=="asn1")return new n(e[P]);if(P=="seq"){for(var U=e[P],k=[],O=0;O"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="+o.length+",v="+this.hV);var s=this.hV.length/2,a=s.toString(16);if(a.length%2==1&&(a="0"+a),s<128)return a;var u=a.length/2;if(u>15)throw new Error("ASN.1 length too long to represent by 8x: n = "+s.toString(16));var l=128+u;return l.toString(16)+a},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)};A.asn1.DERAbstractString=function(e){A.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=p2(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))};_e(A.asn1.DERAbstractString,A.asn1.ASN1Object);A.asn1.DERAbstractTime=function(e){A.asn1.DERAbstractTime.superclass.constructor.call(this);var t=null,r=null;this.localDateToUTC=function(n){var i=n.getTime()+n.getTimezoneOffset()*6e4,o=new Date(i);return o},this.formatDate=function(n,i,o){var s=this.zeroPadding,a=this.localDateToUTC(n),u=String(a.getFullYear());i=="utc"&&(u=u.substr(2,2));var l=s(String(a.getMonth()+1),2),f=s(String(a.getDate()),2),m=s(String(a.getHours()),2),p=s(String(a.getMinutes()),2),d=s(String(a.getSeconds()),2),v=u+l+f+m+p+d;if(o===!0){var g=a.getMilliseconds();if(g!=0){var y=s(String(g),3);y=y.replace(/[0]+$/,""),v=v+"."+y}}return v+"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,o,s,a,u){var l=new Date(Date.UTC(n,i-1,o,s,a,u,0));this.setByDate(l)},this.getFreshValueHex=function(){return this.hV}};_e(A.asn1.DERAbstractTime,A.asn1.ASN1Object);A.asn1.DERAbstractStructured=function(e){A.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)};_e(A.asn1.DERAbstractStructured,A.asn1.ASN1Object);A.asn1.DERBoolean=function(e){A.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",e==!1?this.hTLV="010100":this.hTLV="0101ff"};_e(A.asn1.DERBoolean,A.asn1.ASN1Object);A.asn1.DERInteger=function(e){A.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.params=null;var t=o0;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 oe(String(r),10);else if(r.int!=null)n=new oe(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)};_e(A.asn1.DERInteger,A.asn1.ASN1Object);A.asn1.DERBitString=function(e){if(e!==void 0&&typeof e.obj<"u"){var t=A.asn1.ASN1Util.newObject(e.obj);e.hex="00"+t.tohex()}A.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||7e.length)throw new Error("too short ASN.1 value");e.substr(t,2)=="03"&&(i+=2,o-=2),s=0;for(var a=i;s<=o;){var u=r.getTLVblen(e,a);if(u<=0)throw new Error("malformed ASN.1: invalid TLV length");if(s+=u,s<=o&&n.push(a),a+=u,s>=o)break}return n};ke.getNthChildIdx=function(e,t,r){var n=ke.getChildIdx(e,t);return n[r]};ke.getIdxbyList=function(e,t,r,n){var i=ke,o,s;return r.length==0?n!==void 0&&e.substr(t,2)!==n?-1:t:(o=r.shift(),s=i.getChildIdx(e,t),o>=s.length?-1:i.getIdxbyList(e,s[o],r,n))};ke.getIdxbyListEx=function(e,t,r,n){var i=ke,o,s;if(r.length==0)return n!==void 0&&e.substr(t,2)!==n?-1:t;o=r.shift(),s=i.getChildIdx(e,t);for(var a=0,u=0;u=e.length?null:i.getTLV(e,o)};ke.getTLVbyListEx=function(e,t,r,n){var i=ke,o=i.getIdxbyListEx(e,t,r,n);return o==-1?null:i.getTLV(e,o)};ke.getVbyList=function(e,t,r,n,i){var o=ke,s,a;return s=o.getIdxbyList(e,t,r,n),s==-1||s>=e.length?null:(a=o.getV(e,s),i===!0&&(a=a.substr(2)),a)};ke.getVbyListEx=function(e,t,r,n,i){var o=ke,s,a,u;return s=o.getIdxbyListEx(e,t,r,n),s==-1?null:(u=o.getV(e,s),e.substr(s,2)=="03"&&i!==!1&&(u=u.substr(2)),u)};ke.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=ke.getV(e,t);return n=="02"?parseInt(i,16):b9(i)}catch{return r}};ke.getOID=function(e,t,r){r==null&&(r=null);try{if(e.substr(t,2)!="06")return r;var n=ke.getV(e,t);return y2(n)}catch{return r}};ke.getOIDName=function(e,t,r){r==null&&(r=null);try{var n=ke.getOID(e,t,r);if(n==r)return r;var i=A.asn1.x509.OID.oid2name(n);return i==""?n:i}catch{return r}};ke.getString=function(e,t,r){r==null&&(r=null);try{var n=ke.getV(e,t);return Qs(n)}catch{return r}};ke.hextooidstr=function(e){var t=function(m,p){return m.length>=p?m:new Array(p-m.length+1).join("0")+m},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 o=e.substr(2),s=[],a=0;a0&&(f=f+"."+u.join(".")),f};ke.dump=function(e,t,r,n){var i=ke,o=i.getV,s=i.dump,a=i.getChildIdx,u=e;e instanceof A.asn1.ASN1Object&&(u=e.tohex());var l=function(z,C){if(z.length<=C*2)return z;var P=z.substr(0,C)+"..(total "+z.length/2+"bytes).."+z.substr(z.length-C,C);return P};t===void 0&&(t={ommit_long_octet:32}),r===void 0&&(r=0),n===void 0&&(n="");var f=t.ommit_long_octet,F=u.substr(r,2);if(F=="01"){var m=o(u,r);return m=="00"?n+`BOOLEAN FALSE `:n+`BOOLEAN TRUE `}if(F=="02"){var m=o(u,r);return n+"INTEGER "+l(m,f)+` `}if(F=="03"){var m=o(u,r);if(i.isASN1HEX(m.substr(2))){var p=n+`BITSTRING, encapsulates `;return p=p+s(m.substr(2),t,0,n+" "),p}else return n+"BITSTRING "+l(m,f)+` `}if(F=="04"){var m=o(u,r);if(i.isASN1HEX(m)){var p=n+`OCTETSTRING, encapsulates `;return p=p+s(m,t,0,n+" "),p}else return n+"OCTETSTRING "+l(m,f)+` `}if(F=="05")return n+`NULL `;if(F=="06"){var d=o(u,r),v=A.asn1.ASN1Util.oidHexToInt(d),g=A.asn1.x509.OID.oid2name(v),y=v.replace(/\./g," ");return g!=""?n+"ObjectIdentifier "+g+" ("+y+`) `:n+"ObjectIdentifier ("+y+`) `}if(F=="0a")return n+"ENUMERATED "+parseInt(o(u,r))+` `;if(F=="0c")return n+"UTF8String '"+cr(o(u,r))+`' `;if(F=="13")return n+"PrintableString '"+cr(o(u,r))+`' `;if(F=="14")return n+"TeletexString '"+cr(o(u,r))+`' `;if(F=="16")return n+"IA5String '"+cr(o(u,r))+`' `;if(F=="17")return n+"UTCTime "+cr(o(u,r))+` `;if(F=="18")return n+"GeneralizedTime "+cr(o(u,r))+` `;if(F=="1a")return n+"VisualString '"+cr(o(u,r))+`' `;if(F=="1e")return n+"BMPString '"+sS(o(u,r))+`' `;if(F=="30"){if(u.substr(r,4)=="3000")return n+`SEQUENCE {} `;var p=n+`SEQUENCE `,w=a(u,r),E=t;if((w.length==2||w.length==3)&&u.substr(w[0],2)=="06"&&u.substr(w[w.length-1],2)=="04"){var g=i.oidname(o(u,w[0])),S=JSON.parse(JSON.stringify(t));S.x509ExtName=g,E=S}for(var D=0;D4?{enum:{hex:w}}:{enum:parseInt(w,16)};if(g=="30"||g=="31")return y[d[g]]=v(e),y;if(g=="14"){var M=p(w);return y[d[g]]={str:M},y}else if(g=="1e"){var M=m(w);return y[d[g]]={str:M},y}else if(":0c:12:13:16:17:18:1a:".indexOf(g)!=-1){var M=f(w);return y[d[g]]={str:M},y}else if(g.match(/^8[0-9]$/)){var M=f(w);return M==null|M==""?{tag:{tag:g,explicit:!1,hex:w}}:M.match(/[\x00-\x1F\x7F-\x9F]/)!=null||M.match(/[\u0000-\u001F\u0080–\u009F]/)!=null?{tag:{tag:g,explicit:!1,hex:w}}:{tag:{tag:g,explicit:!1,str:M}}}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 A.asn1.ASN1Object;z.hV=w;var C=z.getLengthHexFromValue();return{asn1:{tlv:g+C+w}}}}}};ke.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}};ke.isASN1HEX=function(e){var t=ke;if(e.length%2==1)return!1;var r=t.getVblen(e,0),n=e.substr(0,2),i=t.getL(e,0),o=e.length-n.length-i.length;return o==r*2};ke.checkStrictDER=function(e,t,r,n,i){var o=ke;if(r===void 0){if(typeof e!="string")throw new Error("not hex string");if(e=e.toLowerCase(),!A.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=o.getL(e,t);if(s.length>i*2)throw new Error("L of TLV too long: idx="+t);var a=o.getVblen(e,t);if(a>n)throw new Error("value of L too long than hex: idx="+t);var u=o.getTLV(e,t),l=u.length-2-o.getL(e,t).length;if(l!==a*2)throw new Error("V string length and L's value not the same:"+l+"/"+a*2);if(t===0&&e.length!=u.length)throw new Error("total length and TLV length unmatch:"+e.length+"!="+u.length);var f=e.substr(t,2);if(f==="02"){var m=o.getVidx(e,t);if(e.substr(m,2)=="00"&&e.charCodeAt(m+2)<56)throw new Error("not least zeros for DER INTEGER")}if(parseInt(f,16)&32){for(var p=o.getVblen(e,t),d=0,v=o.getChildIdx(e,t),g=0;g"u"||!A)&&(A={});(typeof A.asn1>"u"||!A.asn1)&&(A.asn1={});(typeof A.asn1.x509>"u"||!A.asn1.x509)&&(A.asn1.x509={});A.asn1.x509.Certificate=function(e){A.asn1.x509.Certificate.superclass.constructor.call(this);var t=A,r=t.asn1,n=r.DERBitString,i=r.DERSequence,o=r.x509,s=o.TBSCertificate,a=o.AlgorithmIdentifier;this.params=void 0,this.setByParam=function(u){this.params=u},this.sign=function(){var u=this.params,l=u.sigalg;u.sigalg.name!=null&&(l=u.sigalg.name);var f=u.tbsobj.tohex(),m=new A.crypto.Signature({alg:l});m.init(u.cakey),m.updateHex(f),u.sighex=m.sign()},this.getPEM=function(){return ps(this.tohex(),"CERTIFICATE")},this.tohex=function(){var u=this.params;if((u.tbsobj==null||u.tbsobj==null)&&(u.tbsobj=new s(u)),u.sighex==null&&u.cakey!=null&&this.sign(),u.sighex==null)throw new Error("sighex or cakey parameter not defined");var l=[];l.push(u.tbsobj),l.push(new a({name:u.sigalg})),l.push(new n({hex:"00"+u.sighex}));var f=new i({array:l});return f.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&(this.params=e)};_e(A.asn1.x509.Certificate,A.asn1.ASN1Object);A.asn1.x509.TBSCertificate=function(e){A.asn1.x509.TBSCertificate.superclass.constructor.call(this);var t=A,r=t.asn1,n=r.x509,i=r.DERTaggedObject,o=r.DERInteger,s=r.DERSequence,a=n.AlgorithmIdentifier,u=n.Time,l=n.X500Name,f=n.Extensions,m=n.SubjectPublicKeyInfo;this.params=null,this.setByParam=function(p){this.params=p},this.tohex=function(){var p=[],d=this.params;if(d.version!=null||d.version!=1){var v=2;d.version!=null&&(v=d.version-1);var g=new i({obj:new o({int:v})});p.push(g)}p.push(new o(d.serial)),p.push(new a({name:d.sigalg})),p.push(new l(d.issuer)),p.push(new s({array:[new u(d.notbefore),new u(d.notafter)]})),p.push(new l(d.subject)),p.push(new m(Lt.getKey(d.sbjpubkey))),d.ext!==void 0&&d.ext.length>0&&p.push(new i({tag:"a3",obj:new f(d.ext)}));var y=new A.asn1.DERSequence({array:p});return y.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};_e(A.asn1.x509.TBSCertificate,A.asn1.ASN1Object);A.asn1.x509.Extensions=function(e){A.asn1.x509.Extensions.superclass.constructor.call(this);var t=A,r=t.asn1,n=r.DERSequence,i=r.x509;this.aParam=[],this.setByParam=function(o){this.aParam=o},this.tohex=function(){for(var o=[],s=0;s-1&&a.push(new n({int:this.pathLen}));var u=new i({array:a});return this.asn1ExtnValue=u,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))};_e(A.asn1.x509.BasicConstraints,A.asn1.x509.Extension);A.asn1.x509.CRLDistributionPoints=function(e){A.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,e);var t=A,r=t.asn1,n=r.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.setByDPArray=function(i){for(var o=[],s=0;s0&&o.push(new r({array:s}))}var u=new r({array:o});return u.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(this.params=e)};_e(A.asn1.x509.PolicyInformation,A.asn1.ASN1Object);A.asn1.x509.PolicyQualifierInfo=function(e){A.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var t=A.asn1,r=t.DERSequence,n=t.DERIA5String,i=t.DERObjectIdentifier,o=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 o(this.params.unotice)]});return s.tohex()}},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(this.params=e)};_e(A.asn1.x509.PolicyQualifierInfo,A.asn1.ASN1Object);A.asn1.x509.UserNotice=function(e){A.asn1.x509.UserNotice.superclass.constructor.call(this,e);var t=A.asn1.DERSequence,r=A.asn1.DERInteger,n=A.asn1.x509.DisplayText,i=A.asn1.x509.NoticeReference;this.params=null,this.tohex=function(){var o=[];this.params.noticeref!==void 0&&o.push(new i(this.params.noticeref)),this.params.exptext!==void 0&&o.push(new n(this.params.exptext));var s=new t({array:o});return s.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(this.params=e)};_e(A.asn1.x509.UserNotice,A.asn1.ASN1Object);A.asn1.x509.NoticeReference=function(e){A.asn1.x509.NoticeReference.superclass.constructor.call(this,e);var t=A.asn1.DERSequence,r=A.asn1.DERInteger,n=A.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 o=[],s=this.params.noticenum,a=0;a0)for(var s=0;s0;i++){var o=t.shift();if(r===!0){var s=n.pop(),a=(s+","+o).replace(/\\,/g,",");n.push(a),r=!1}else n.push(o);o.substr(-1,1)==="\\"&&(r=!0)}return n=n.map(function(u){return u.replace("/","\\/")}),n.reverse(),"/"+n.join("/")};A.asn1.x509.X500Name.ldapToOneline=function(e){return A.asn1.x509.X500Name.ldapToCompat(e)};A.asn1.x509.RDN=function(e){A.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var t=A.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 A.asn1.x509.AttributeTypeAndValue({str:r,rule:this.sRule}))},this.addByMultiValuedString=function(r){for(var n=A.asn1.x509.RDN.parseString(r),i=0;i0)for(var r=0;r0;i++){var o=t.shift();if(r===!0){var s=n.pop(),a=(s+"+"+o).replace(/\\\+/g,"+");n.push(a),r=!1}else n.push(o);o.substr(-1,1)==="\\"&&(r=!0)}for(var u=!1,l=[],i=0;n.length>0;i++){var o=n.shift();if(u===!0){var f=l.pop();if(o.match(/"$/)){var a=(f+"+"+o).replace(/^([^=]+)="(.*)"$/,"$1=$2");l.push(a),u=!1}else l.push(f+"+"+o)}else l.push(o);o.match(/^[^=]+="/)&&(u=!0)}return l};A.asn1.x509.AttributeTypeAndValue=function(e){A.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this),this.sRule="utf8",this.sType=null,this.sValue=null,this.dsType=null;var t=A,r=t.asn1,n=r.DERSequence,i=r.DERUTF8String,o=r.DERPrintableString,s=r.DERTeletexString,a=r.DERIA5String,u=r.DERVisibleString,l=r.DERBMPString,f=t.lang.String.isMail,m=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 d=p.str,v=d.match(/^([^=]+)=(.+)$/);if(v)this.sType=v[1],this.sValue=v[2];else throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}else this.sType=p.type,this.sValue=p.value},this.setByString=function(p,d){d!==void 0&&(this.sRule=d);var v=p.match(/^([^=]+)=(.+)$/);if(v)this.setByAttrTypeAndValueStr(v[1],v[2]);else throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)},this._getDsType=function(){var p=this.sType,d=this.sValue,v=this.sRule;return v==="prn"?p=="CN"&&f(d)?"ia5":m(d)?"prn":"utf8":v==="utf8"?p=="CN"&&f(d)?"ia5":p=="C"?"prn":"utf8":"utf8"},this.setByAttrTypeAndValueStr=function(p,d,v){v!==void 0&&(this.sRule=v),this.sType=p,this.sValue=d},this.getValueObj=function(p,d){if(p=="utf8")return new i({str:d});if(p=="prn")return new o({str:d});if(p=="tel")return new s({str:d});if(p=="ia5")return new a({str:d});if(p=="vis")return new u({str:d});if(p=="bmp")return new l({str:d});throw new Error("unsupported directory string type: type="+p+" value="+d)},this.tohex=function(){this.dsType==null&&(this.dsType=this._getDsType());var p=A.asn1.x509.OID.atype2obj(this.sType),d=this.getValueObj(this.dsType,this.sValue),v=new n({array:[p,d]});return this.TLV=v.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};_e(A.asn1.x509.AttributeTypeAndValue,A.asn1.ASN1Object);A.asn1.x509.SubjectPublicKeyInfo=function(e){A.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var t=null,r=null,n=A,i=n.asn1,o=i.DERInteger,s=i.DERBitString,a=i.DERObjectIdentifier,u=i.DERSequence,l=i.ASN1Util.newObject,f=i.x509,m=f.AlgorithmIdentifier,p=n.crypto,d=p.ECDSA,v=p.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null)throw"algId and/or subjPubKey not set";var g=new u({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 yt){var y=l({seq:[{int:{bigint:g.n}},{int:{int:g.e}}]}),w=y.tohex();this.asn1AlgId=new m({name:"rsaEncryption"}),this.asn1SubjPKey=new s({hex:"00"+w})}}catch{}try{if(g instanceof A.crypto.ECDSA){var E=new a({name:g.curveName});this.asn1AlgId=new m({name:"ecPublicKey",asn1params:E}),this.asn1SubjPKey=new s({hex:"00"+g.pubKeyHex})}}catch{}try{if(g instanceof A.crypto.DSA){var E=new l({seq:[{int:{bigint:g.p}},{int:{bigint:g.q}},{int:{bigint:g.g}}]});this.asn1AlgId=new m({name:"dsa",asn1params:E});var S=new o({bigint:g.y});this.asn1SubjPKey=new s({hex:"00"+S.tohex()})}}catch{}},e!==void 0&&this.setPubKey(e)};_e(A.asn1.x509.SubjectPublicKeyInfo,A.asn1.ASN1Object);A.asn1.x509.Time=function(e){A.asn1.x509.Time.superclass.constructor.call(this);var t=null,r=null,n=A,i=n.asn1,o=i.DERUTCTime,s=i.DERGeneralizedTime;this.params=null,this.type=null,this.setTimeParams=function(a){this.timeParams=a},this.setByParam=function(a){this.params=a},this.getType=function(a){return a.match(/^[0-9]{12}Z$/)?"utc":a.match(/^[0-9]{14}Z$/)?"gen":a.match(/^[0-9]{12}\.[0-9]+Z$/)?"utc":a.match(/^[0-9]{14}\.[0-9]+Z$/)?"gen":null},this.tohex=function(){var a=this.params,u=null;if(typeof a=="string"&&(a={str:a}),a!=null&&a.str&&(a.type==null||a.type==null)&&(a.type=this.getType(a.str)),a!=null&&a.str?(a.type=="utc"&&(u=new o(a.str)),a.type=="gen"&&(u=new s(a.str))):this.type=="gen"?u=new s:u=new o,u==null)throw new Error("wrong setting for Time");return this.TLV=u.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};A.asn1.x509.Time_bak=function(e){A.asn1.x509.Time_bak.superclass.constructor.call(this);var t=null,r=null,n=A,i=n.asn1,o=i.DERUTCTime,s=i.DERGeneralizedTime;this.setTimeParams=function(a){this.timeParams=a},this.tohex=function(){var a=null;return this.timeParams!=null?this.type=="utc"?a=new o(this.timeParams):a=new s(this.timeParams):this.type=="utc"?a=new o:a=new s,this.TLV=a.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)};_e(A.asn1.x509.Time,A.asn1.ASN1Object);A.asn1.x509.AlgorithmIdentifier=function(e){A.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var t=A,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 o=null;for(var s in n)s===this.nameAlg&&(o=n[s]);if(o!==null)return this.hTLV=o,this.hTLV}this.nameAlg!==null&&this.asn1Alg===null&&(this.asn1Alg=r.x509.OID.name2obj(this.nameAlg));var a=[this.asn1Alg];this.asn1Params!==null&&a.push(this.asn1Params);var u=new r.DERSequence({array:a});return this.hTLV=u.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)}};_e(A.asn1.x509.AlgorithmIdentifier,A.asn1.ASN1Object);A.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"};A.asn1.x509.GeneralName=function(e){A.asn1.x509.GeneralName.superclass.constructor.call(this);var t={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87",otherName:"a0"},r=A,n=r.asn1,i=n.x509,o=i.X500Name,s=i.OtherName,a=n.DERIA5String,u=n.DERPrintableString,l=n.DEROctetString,f=n.DERTaggedObject,m=n.ASN1Object,p=Error;this.params=null,this.setByParam=function(d){this.params=d},this.tohex=function(){var d=this.params,v,y,g,y=!1;if(d.other!==void 0)v="a0",g=new s(d.other);else if(d.rfc822!==void 0)v="81",g=new a({str:d.rfc822});else if(d.dns!==void 0)v="82",g=new a({str:d.dns});else if(d.dn!==void 0)v="a4",y=!0,typeof d.dn=="string"?g=new o({str:d.dn}):d.dn instanceof A.asn1.x509.X500Name?g=d.dn:g=new o(d.dn);else if(d.ldapdn!==void 0)v="a4",y=!0,g=new o({ldapstr:d.ldapdn});else if(d.certissuer!==void 0||d.certsubj!==void 0){v="a4",y=!0;var w,E,S=null;if(d.certsubj!==void 0?(w=!1,E=d.certsubj):(w=!0,E=d.certissuer),E.match(/^[0-9A-Fa-f]+$/)&&S==E,E.indexOf("-----BEGIN ")!=-1&&(S=xr(E)),S==null)throw new Error("certsubj/certissuer not cert");var D=new lt;D.hex=S;var F;w?F=D.getIssuerHex():F=D.getSubjectHex(),g=new m,g.hTLV=F}else if(d.uri!==void 0)v="86",g=new a({str:d.uri});else if(d.ip!==void 0){v="87";var M,z=d.ip;try{if(z.match(/^[0-9a-f]+$/)){var C=z.length;if(C==8||C==16||C==32||C==64)M=z;else throw"err"}else M=nS(z)}catch(U){throw new p("malformed IP address: "+d.ip+":"+U.message)}g=new l({hex:M})}else throw new p("improper params");var P=new f({tag:v,explicit:y,obj:g});return P.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};_e(A.asn1.x509.GeneralName,A.asn1.ASN1Object);A.asn1.x509.GeneralNames=function(e){A.asn1.x509.GeneralNames.superclass.constructor.call(this);var t=null,r=A,n=r.asn1;this.setByParamArray=function(i){for(var o=0;o"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,o){var s=this[n];if(!s.match(/^[0-2]\.[0-9.]+$/))throw new Error("value is not OID")},t),!0)}catch{return!1}}};A.asn1.x509.OID.oid2name=function(e){var t=A.asn1.x509.OID.name2oidList;for(var r in t)if(t[r]==e)return r;return""};A.asn1.x509.OID.oid2atype=function(e){var t=A.asn1.x509.OID.atype2oidList;for(var r in t)if(t[r]==e)return r;return e};A.asn1.x509.OID.name2oid=function(e){if(e.match(/^[0-9.]+$/))return e;var t=A.asn1.x509.OID.name2oidList;return t[e]===void 0?"":t[e]};A.asn1.x509.X509Util={};A.asn1.x509.X509Util.newCertPEM=function(e){var t=A.asn1.x509,r=t.TBSCertificate,n=t.Certificate,i=new n(e);return i.getPEM()};(typeof A>"u"||!A)&&(A={});(typeof A.asn1>"u"||!A.asn1)&&(A.asn1={});(typeof A.asn1.cms>"u"||!A.asn1.cms)&&(A.asn1.cms={});A.asn1.cms.Attribute=function(e){var t=Error,r=A,n=r.asn1,i=n.DERSequence,o=n.DERSet,s=n.DERObjectIdentifier;this.params=null,this.typeOid=null,this.setByParam=function(a){this.params=a},this.getValueArray=function(){throw new t("not yet implemented abstract")},this.tohex=function(){var a=new s({oid:this.typeOid}),u=new o({array:this.getValueArray()}),l=new i({array:[a,u]});return l.tohex()},this.getEncodedHex=function(){return this.tohex()}};_e(A.asn1.cms.Attribute,A.asn1.ASN1Object);A.asn1.cms.ContentType=function(e){var t=A,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)};_e(A.asn1.cms.ContentType,A.asn1.cms.Attribute);A.asn1.cms.MessageDigest=function(e){var t=A,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 o=new n(this.params);return[o]},e!=null&&this.setByParam(e)};_e(A.asn1.cms.MessageDigest,A.asn1.cms.Attribute);A.asn1.cms.SigningTime=function(e){var t=A,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)};_e(A.asn1.cms.SigningTime,A.asn1.cms.Attribute);A.asn1.cms.SigningCertificate=function(e){var t=Error,r=A,n=r.asn1,i=n.DERSequence,o=n.cms,s=o.ESSCertID,a=r.crypto;o.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 u=this.params.array,l=[],f=0;f0){for(var v=o(p.valhex,d[0]),g=m(v,0),y=[],w=0;w1){var D=o(p.valhex,d[1]);p.polhex=D}delete p.valhex},this.setSignaturePolicyIdentifier=function(p){var d=m(p.valhex,0);if(d.length>0){var v=n.getOID(p.valhex,d[0]);p.oid=v}if(d.length>1){var g=new t,y=m(p.valhex,d[1]),w=o(p.valhex,y[0]),E=g.getAlgorithmIdentifierName(w);p.alg=E;var S=i(p.valhex,y[1]);p.hash=S}delete p.valhex},this.setSigningCertificateV2=function(p){var d=m(p.valhex,0);if(d.length>0){for(var v=o(p.valhex,d[0]),g=m(v,0),y=[],w=0;w1){var D=o(p.valhex,d[1]);p.polhex=D}delete p.valhex},this.getESSCertID=function(p){var d={},v=m(p,0);if(v.length>0){var g=i(p,v[0]);d.hash=g}if(v.length>1){var y=o(p,v[1]),w=this.getIssuerSerial(y);w.serial!=null&&(d.serial=w.serial),w.issuer!=null&&(d.issuer=w.issuer)}return d},this.getESSCertIDv2=function(p){var d={},v=m(p,0);if(v.length<1||3g+1){var E=o(p,v[g+1]),S=this.getIssuerSerial(E);d.issuer=S.issuer,d.serial=S.serial}return d},this.getIssuerSerial=function(p){var d={},v=m(p,0),g=o(p,v[0]),y=r.getGeneralNames(g),w=y[0].dn;d.issuer=w;var E=i(p,v[1]);return d.serial={hex:E},d},this.getCertificateSet=function(p){for(var d=m(p,0),v=[],g=0;g"u"||!A)&&(A={});(typeof A.asn1>"u"||!A.asn1)&&(A.asn1={});(typeof A.asn1.tsp>"u"||!A.asn1.tsp)&&(A.asn1.tsp={});A.asn1.tsp.TimeStampToken=function(e){var t=A,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)};_e(A.asn1.tsp.TimeStampToken,A.asn1.cms.SignedData);A.asn1.tsp.TSTInfo=function(e){var t=Error,r=A,n=r.asn1,i=n.DERSequence,o=n.DERInteger,s=n.DERBoolean,a=n.DERGeneralizedTime,u=n.DERObjectIdentifier,l=n.DERTaggedObject,f=n.tsp,m=f.MessageImprint,p=f.Accuracy,d=n.x509.X500Name,v=n.x509.GeneralName;if(f.TSTInfo.superclass.constructor.call(this),this.dVersion=new o({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 u({oid:e.policy})}e.messageImprint!==void 0&&(this.dMessageImprint=new m(e.messageImprint)),e.serial!==void 0&&(this.dSerial=new o(e.serial)),e.genTime!==void 0&&(this.dGenTime=new a(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 o(e.nonce)),e.tsa!==void 0&&(this.dTsa=new l({tag:"a0",explicit:!0,obj:new v({dn:e.tsa})}))}};_e(A.asn1.tsp.TSTInfo,A.asn1.ASN1Object);A.asn1.tsp.Accuracy=function(e){var t=A,r=t.asn1,n=r.ASN1Util.newObject;r.tsp.Accuracy.superclass.constructor.call(this),this.params=null,this.tohex=function(){var i=this.params,o=[];return i.seconds!=null&&typeof i.seconds=="number"&&o.push({int:i.seconds}),i.millis!=null&&typeof i.millis=="number"&&o.push({tag:{tagi:"80",obj:{int:i.millis}}}),i.micros!=null&&typeof i.micros=="number"&&o.push({tag:{tagi:"81",obj:{int:i.micros}}}),n({seq:o}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};_e(A.asn1.tsp.Accuracy,A.asn1.ASN1Object);A.asn1.tsp.MessageImprint=function(e){var t=A,r=t.asn1,n=r.DERSequence,i=r.DEROctetString,o=r.x509,s=o.AlgorithmIdentifier;r.tsp.MessageImprint.superclass.constructor.call(this),this.params=null,this.tohex=function(){var a=this.params,u=new s({name:a.alg}),l=new i({hex:a.hash}),f=new n({array:[u,l]});return f.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};_e(A.asn1.tsp.MessageImprint,A.asn1.ASN1Object);A.asn1.tsp.TimeStampReq=function(e){var t=A,r=t.asn1,n=r.DERSequence,i=r.DERInteger,o=r.DERBoolean,s=r.ASN1Object,a=r.DERObjectIdentifier,u=r.tsp,l=u.MessageImprint;u.TimeStampReq.superclass.constructor.call(this),this.params=null,this.tohex=function(){var f=this.params,m=[];m.push(new i({int:1})),f.messageImprint instanceof A.asn1.ASN1Object?m.push(f.messageImprint):m.push(new l(f.messageImprint)),f.policy!=null&&m.push(new a(f.policy)),f.nonce!=null&&m.push(new i(f.nonce)),f.certreq==!0&&m.push(new o);var p=new n({array:m});return p.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};_e(A.asn1.tsp.TimeStampReq,A.asn1.ASN1Object);A.asn1.tsp.TimeStampResp=function(e){var t=A,r=t.asn1,n=r.DERSequence,i=r.ASN1Object,o=r.tsp,s=o.PKIStatusInfo;o.TimeStampResp.superclass.constructor.call(this),this.params=null,this.tohex=function(){var a=this.params,u=[];if(a.econtent!=null||a.tst!=null)if(a.statusinfo!=null?u.push(new s(a.statusinfo)):u.push(new s("granted")),a.econtent!=null)u.push(new o.TimeStampToken(a).getContentInfo());else if(a.tst instanceof r.ASN1Object)u.push(a.tst);else throw new Error("improper member tst value");else if(a.statusinfo!=null)u.push(new s(a.statusinfo));else throw new Error("parameter for token nor statusinfo not specified");var l=new n({array:u});return l.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};_e(A.asn1.tsp.TimeStampResp,A.asn1.ASN1Object);A.asn1.tsp.PKIStatusInfo=function(e){var t=Error,r=A,n=r.asn1,i=n.DERSequence,o=n.tsp,s=o.PKIStatus,a=o.PKIFreeText,u=o.PKIFailureInfo;o.PKIStatusInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var l=this.params,f=[];if(typeof l=="string")f.push(new s(l));else{if(l.status==null)throw new t("property 'status' unspecified");f.push(new s(l.status)),l.statusstr!=null&&f.push(new a(l.statusstr)),l.failinfo!=null&&f.push(new u(l.failinfo))}var m=new i({array:f});return m.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};_e(A.asn1.tsp.PKIStatusInfo,A.asn1.ASN1Object);A.asn1.tsp.PKIStatus=function(e){var t=Error,r=A,n=r.asn1,i=n.DERInteger,o=n.tsp;o.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 a=this.params,u,l;if(typeof a=="string")try{l=s[a]}catch{throw new t("undefined name: "+a)}else if(typeof a=="number")l=a;else throw new t("unsupported params");return new i({int:l}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};_e(A.asn1.tsp.PKIStatus,A.asn1.ASN1Object);A.asn1.tsp.PKIFreeText=function(e){var t=Error,r=A,n=r.asn1,i=n.DERSequence,o=n.DERUTF8String,s=n.tsp;s.PKIFreeText.superclass.constructor.call(this),this.params=null,this.tohex=function(){var a=this.params;if(!(a instanceof Array))throw new t("wrong params: not array");for(var u=[],l=0;l=0;p--)m+=f[p];return m}else{if(typeof u=="string"&&a[u]!=null)return l2([u],a);if(typeof u=="object"&&u.length!=null)return l2(u,a);throw new t("wrong params")}},this.tohex=function(){var u=this.params,l=this.getBinValue();return new i({bin:l}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};_e(A.asn1.tsp.PKIFailureInfo,A.asn1.ASN1Object);A.asn1.tsp.AbstractTSAAdapter=function(e){this.getTSTHex=function(t,r){throw"not implemented yet"}};A.asn1.tsp.SimpleTSAAdapter=function(e){var t=A,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(o,s){var a=i(o,s);this.params.econtent.content.messageImprint={alg:s,hash:a},this.params.econtent.content.serial={int:this.serial++};var u=Math.floor(Math.random()*1e9);this.params.econtent.content.nonce={int:u};var l=new n.TimeStampToken(this.params);return l.getContentInfoEncodedHex()},e!==void 0&&(this.params=e)};_e(A.asn1.tsp.SimpleTSAAdapter,A.asn1.tsp.AbstractTSAAdapter);A.asn1.tsp.FixedTSAAdapter=function(e){var t=A,r=t.asn1,n=r.tsp,i=t.crypto.Util.hashHex;n.FixedTSAAdapter.superclass.constructor.call(this),this.params=null,this.getTSTHex=function(o,s){var a=i(o,s);this.params.econtent.content.messageImprint={alg:s,hash:a};var u=new n.TimeStampToken(this.params);return u.getContentInfoEncodedHex()},e!==void 0&&(this.params=e)};_e(A.asn1.tsp.FixedTSAAdapter,A.asn1.tsp.AbstractTSAAdapter);A.asn1.tsp.TSPUtil=new function(){};A.asn1.tsp.TSPUtil.newTimeStampToken=function(e){return new A.asn1.tsp.TimeStampToken(e)};A.asn1.tsp.TSPUtil.parseTimeStampReq=function(e){var t=new A.asn1.tsp.TSPParser;return t.getTimeStampReq(e)};A.asn1.tsp.TSPUtil.parseMessageImprint=function(e){var t=new A.asn1.tsp.TSPParser;return t.getMessageImprint(e)};A.asn1.tsp.TSPParser=function(){var e=Error,t=lt,r=new t,n=ke,i=n.getV,o=n.getTLV,s=n.getIdxbyList,a=n.getTLVbyListEx,u=n.getChildIdx,l=["granted","grantedWithMods","rejection","waiting","revocationWarning","revocationNotification"],f={0:"badAlg",2:"badRequest",5:"badDataFormat",14:"timeNotAvailable",15:"unacceptedPolicy",16:"unacceptedExtension",17:"addInfoNotAvailable",25:"systemFailure"};this.getResponse=function(m){var p=u(m,0);if(p.length==1)return this.getPKIStatusInfo(o(m,p[0]));if(p.length>1){var d=this.getPKIStatusInfo(o(m,p[0])),v=o(m,p[1]),g=this.getToken(v);return g.statusinfo=d,g}},this.getToken=function(m){var p=new A.asn1.cms.CMSParser,d=p.getCMSSignedData(m);return this.setTSTInfo(d),d},this.setTSTInfo=function(m){var p=m.econtent;if(p.type=="tstinfo"){var d=p.content.hex,v=this.getTSTInfo(d);p.content=v}},this.getTSTInfo=function(m){var p={},d=u(m,0),v=i(m,d[1]);p.policy=y2(v);var g=o(m,d[2]);p.messageImprint=this.getMessageImprint(g);var y=i(m,d[3]);p.serial={hex:y};var w=i(m,d[4]);p.genTime={str:cr(w)};var E=0;if(d.length>5&&m.substr(d[5],2)=="30"){var S=o(m,d[5]);p.accuracy=this.getAccuracy(S),E++}if(d.length>5+E&&m.substr(d[5+E],2)=="01"){var D=i(m,d[5+E]);D=="ff"&&(p.ordering=!0),E++}if(d.length>5+E&&m.substr(d[5+E],2)=="02"){var F=i(m,d[5+E]);p.nonce={hex:F},E++}if(d.length>5+E&&m.substr(d[5+E],2)=="a0"){var M=o(m,d[5+E]);M="30"+M.substr(2),pGeneralNames=r.getGeneralNames(M);var z=pGeneralNames[0].dn;p.tsa=z,E++}if(d.length>5+E&&m.substr(d[5+E],2)=="a1"){var C=o(m,d[5+E]);C="30"+C.substr(2);var P=r.getExtParamArray(C);p.ext=P,E++}return p},this.getAccuracy=function(m){for(var p={},d=u(m,0),v=0;v1&&m.substr(d[1],2)=="30"){var w=o(m,d[1]);p.statusstr=this.getPKIFreeText(w),v++}if(d.length>v&&m.substr(d[1+v],2)=="03"){var E=o(m,d[1+v]);p.failinfo=this.getPKIFailureInfo(E)}return p},this.getPKIFreeText=function(m){for(var p=[],d=u(m,0),v=0;v"u"||!A)&&(A={});(typeof A.asn1>"u"||!A.asn1)&&(A.asn1={});(typeof A.asn1.cades>"u"||!A.asn1.cades)&&(A.asn1.cades={});A.asn1.cades.SignaturePolicyIdentifier=function(e){var t=A,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(o){this.params=o},e!=null&&this.setByParam(e)};_e(A.asn1.cades.SignaturePolicyIdentifier,A.asn1.cms.Attribute);A.asn1.cades.SignaturePolicyId=function(e){var t=A,r=t.asn1,n=r.DERSequence,i=r.DERObjectIdentifier,o=r.x509,s=o.AlgorithmIdentifier,a=r.cades,u=a.SignaturePolicyId,l=a.OtherHashAlgAndValue;u.superclass.constructor.call(this),this.params=null,this.tohex=function(){var f=this.params,m=[];m.push(new i(f.oid)),m.push(new l(f));var p=new n({array:m});return p.tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(f){this.params=f},e!=null&&this.setByParam(e)};_e(A.asn1.cades.SignaturePolicyId,A.asn1.ASN1Object);A.asn1.cades.OtherHashAlgAndValue=function(e){var t=Error,r=A,n=r.asn1,i=n.DERSequence,o=n.DEROctetString,s=n.x509,a=s.AlgorithmIdentifier,u=n.cades,l=u.OtherHashAlgAndValue;l.superclass.constructor.call(this),this.params=null,this.tohex=function(){var f=this.params;if(f.alg==null)throw new t("property 'alg' not specified");if(f.hash==null&&f.cert==null)throw new t("property 'hash' nor 'cert' not specified");var m=null;if(f.hash!=null)m=f.hash;else if(f.cert!=null){if(typeof f.cert!="string")throw new t("cert not string");var p=f.cert;f.cert.indexOf("-----BEGIN")!=-1&&(p=xr(f.cert)),m=A.crypto.Util.hashHex(p,f.alg)}var d=[];d.push(new a({name:f.alg})),d.push(new o({hex:m}));var v=new i({array:d});return v.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};_e(A.asn1.cades.OtherHashAlgAndValue,A.asn1.ASN1Object);A.asn1.cades.OtherHashValue=function(e){A.asn1.cades.OtherHashValue.superclass.constructor.call(this);var t=Error,r=A,n=r.lang.String.isHex,i=r.asn1,o=i.DEROctetString,s=r.crypto.Util.hashHex;this.params=null,this.tohex=function(){var a=this.params;if(a.hash==null&&a.cert==null)throw new t("hash or cert not specified");var u=null;if(a.hash!=null)u=a.hash;else if(a.cert!=null){if(typeof a.cert!="string")throw new t("cert not string");var l=a.cert;a.cert.indexOf("-----BEGIN")!=-1&&(l=xr(a.cert)),u=A.crypto.Util.hashHex(l,"sha1")}return new o({hex:u}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};_e(A.asn1.cades.OtherHashValue,A.asn1.ASN1Object);A.asn1.cades.SignatureTimeStamp=function(e){var t=Error,r=A,n=r.lang.String.isHex,i=r.asn1,o=i.ASN1Object,s=i.x509,a=i.cades;a.SignatureTimeStamp.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.14",this.params=null,this.getValueArray=function(){var u=this.params;if(u.tst!=null)if(n(u.tst)){var l=new o;return l.hTLV=u.tst,[l]}else{if(u.tst instanceof o)return[u.tst];throw new t("params.tst has wrong value")}else if(u.res!=null){var f=u.res;if(f instanceof o&&(f=f.tohex()),typeof f!="string"||!n(f))throw new t("params.res has wrong value");var m=ke.getTLVbyList(f,0,[1]),l=new o;return l.hTLV=u.tst,[l]}},e!=null&&this.setByParam(e)};_e(A.asn1.cades.SignatureTimeStamp,A.asn1.cms.Attribute);A.asn1.cades.CompleteCertificateRefs=function(e){var t=Error,r=A,n=r.asn1,i=n.DERSequence,o=n.cades,s=o.OtherCertID,a=r.lang.String.isHex;o.CompleteCertificateRefs.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.21",this.params=null,this.getValueArray=function(){for(var u=this.params,l=[],f=0;f"u"||!A.asn1.csr)&&(A.asn1.csr={});A.asn1.csr.CertificationRequest=function(e){var t=A,r=t.asn1,n=r.DERBitString,i=r.DERSequence,o=r.csr,s=r.x509,a=o.CertificationRequestInfo;o.CertificationRequest.superclass.constructor.call(this),this.setByParam=function(u){this.params=u},this.sign=function(){var u=new a(this.params).tohex(),l=new A.crypto.Signature({alg:this.params.sigalg});l.init(this.params.sbjprvkey),l.updateHex(u);var f=l.sign();this.params.sighex=f},this.getPEM=function(){return ps(this.tohex(),"CERTIFICATE REQUEST")},this.tohex=function(){var u=this.params,l=new A.asn1.csr.CertificationRequestInfo(this.params),f=new A.asn1.x509.AlgorithmIdentifier({name:u.sigalg});if(u.sighex==null&&u.sbjprvkey!=null&&this.sign(),u.sighex==null)throw new Error("sighex or sbjprvkey parameter not defined");var m=new n({hex:"00"+u.sighex}),p=new i({array:[l,f,m]});return p.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};_e(A.asn1.csr.CertificationRequest,A.asn1.ASN1Object);A.asn1.csr.CertificationRequestInfo=function(e){var t=A,r=t.asn1,n=r.DERBitString,i=r.DERSequence,o=r.DERInteger,s=r.DERUTF8String,a=r.DERTaggedObject,u=r.ASN1Util.newObject,l=r.csr,f=r.x509,m=f.X500Name,p=f.Extensions,d=f.SubjectPublicKeyInfo,v=l.AttributeList;l.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 o({int:0})),w.push(new m(y.subject)),w.push(new d(Lt.getKey(y.sbjpubkey))),y.attrs!=null){var E=g(y.attrs),S=u({tag:{tage:"a0",obj:E}});w.push(S)}else if(y.extreq!=null){var D=new p(y.extreq),S=u({tag:{tage:"a0",obj:{seq:[{oid:"1.2.840.113549.1.9.14"},{set:[D]}]}}});w.push(S)}else w.push(new a({tag:"a0",explicit:!1,obj:new s({str:""})}));var F=new i({array:w});return F.tohex()},this.getEncodedHex=function(){return this.tohex()};function g(y){for(var w=Error,E=A.asn1.x509.Extensions,S=[],D=0;D"u"||!A)&&(A={});(typeof A.asn1>"u"||!A.asn1)&&(A.asn1={});(typeof A.asn1.ocsp>"u"||!A.asn1.ocsp)&&(A.asn1.ocsp={});A.asn1.ocsp.DEFAULT_HASH="sha1";A.asn1.ocsp.OCSPResponse=function(e){A.asn1.ocsp.OCSPResponse.superclass.constructor.call(this);var t=A.asn1.DEREnumerated,r=A.asn1.ASN1Util.newObject,n=A.asn1.ocsp.ResponseBytes,i=["successful","malformedRequest","internalError","tryLater","_not_used_","sigRequired","unauthorized"];this.params=null,this._getStatusCode=function(){var o=this.params.resstatus;return typeof o=="number"?o:typeof o!="string"?-1:i.indexOf(o)},this.setByParam=function(o){this.params=o},this.tohex=function(){var o=this.params,s=this._getStatusCode();if(s==-1)throw new Error("responseStatus not supported: "+o.resstatus);if(s!=0)return r({seq:[{enum:{int:s}}]}).tohex();var a=new n(o);return r({seq:[{enum:{int:0}},{tag:{tag:"a0",explicit:!0,obj:a}}]}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};_e(A.asn1.ocsp.OCSPResponse,A.asn1.ASN1Object);A.asn1.ocsp.ResponseBytes=function(e){A.asn1.ocsp.ResponseBytes.superclass.constructor.call(this);var t=A.asn1,r=t.DERSequence,n=t.DERObjectIdentifier,i=t.DEROctetString,o=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 a=new o(s),u=[];u.push(new n({name:"ocspBasic"})),u.push(new i({hex:a.tohex()}));var l=new r({array:u});return l.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};_e(A.asn1.ocsp.ResponseBytes,A.asn1.ASN1Object);A.asn1.ocsp.BasicOCSPResponse=function(e){A.asn1.ocsp.BasicOCSPResponse.superclass.constructor.call(this);var t=Error,r=A.asn1,n=r.ASN1Object,i=r.DERSequence,o=r.DERGeneralizedTime,s=r.DERTaggedObject,a=r.DERBitString,u=r.x509.Extensions,l=r.x509.AlgorithmIdentifier,f=r.ocsp,m=f.ResponderID;_SingleResponseList=f.SingleResponseList,_ResponseData=f.ResponseData,this.params=null,this.setByParam=function(p){this.params=p},this.sign=function(){var p=this.params,d=p.tbsresp.tohex(),v=new A.crypto.Signature({alg:p.sigalg});v.init(p.reskey),v.updateHex(d),p.sighex=v.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 d=[];if(d.push(p.tbsresp),d.push(new l({name:p.sigalg})),d.push(new a({hex:"00"+p.sighex})),p.certs!=null&&p.certs.length!=null){for(var v=[],g=0;g"u"||!A)&&(A={});(typeof A.lang>"u"||!A.lang)&&(A.lang={});A.lang.String=function(){};function f9(e){for(var t=new Array,r=0;r>6,u=128|s&63;return cr(a.toString(16)+u.toString(16))}var a=224|(o&240)>>4,u=128|(o&15)<<2|(s&192)>>6,l=128|s&63;return cr(a.toString(16)+u.toString(16)+l.toString(16))}var r=e.match(/.{4}/g),n=r.map(t);return n.join("")}function w2(e){for(var t=encodeURIComponent(e),r="",n=0;n"7"?"00"+e:e}function MX(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 o=parseInt(r);if(o<0||255t.length&&(r=t.length);for(var n=0;n0&&(l=l+"."+a.join(".")),l}catch{return null}}function E9(e){var t=new oe(String(e),10);return o0(t)}function o0(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="",o=0;o=t?e:new Array(t-e.length+1).join(r)+e};function b9(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 o=parseInt(i,2);return o==NaN?-1:o}catch{return-1}}function A9(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+c2("",r,"0");var n=parseInt(t,2).toString(16);n.length%2==1&&(n="0"+n);var i="0"+r;return i+n}function S9(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--)o+=i[n];return o}function vr(e,n,r){if(typeof e=="object"){for(var n=String(n).split("."),i=0;i"u"||!A)&&(A={});(typeof A.crypto>"u"||!A.crypto)&&(A.crypto={});A.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:He.algo.MD5,sha1:He.algo.SHA1,sha224:He.algo.SHA224,sha256:He.algo.SHA256,sha384:He.algo.SHA384,sha512:He.algo.SHA512,ripemd160:He.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 o="0001",s="00"+n,a="",u=i-o.length-s.length,l=0;l=0)return r}};A.crypto.Util.getRandomBigIntegerMinToMax=function(e,t){var r=e.compareTo(t);if(r>0)throw"biMin is greater than biMax";if(r==0)return e;var n=t.subtract(e),i=A.crypto.Util.getRandomBigIntegerZeroToMax(n);return i.add(e)};A.crypto.MessageDigest=function(e){var t=null,r=null,n=null;this.setAlgAndProvider=function(i,o){if(i=A.crypto.MessageDigest.getCanonicalAlgName(i),i!==null&&o===void 0&&(o=A.crypto.Util.DEFAULTPROVIDER[i]),":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(i)!=-1&&o=="cryptojs"){try{this.md=A.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[i].create()}catch(s){throw"setAlgAndProvider hash alg set fail alg="+i+"/"+s}this.updateString=function(s){this.md.update(s)},this.updateHex=function(s){var a=He.enc.Hex.parse(s);this.md.update(a)},this.digest=function(){var s=this.md.finalize();return s.toString(He.enc.Hex)},this.digestString=function(s){return this.updateString(s),this.digest()},this.digestHex=function(s){return this.updateHex(s),this.digest()}}if(":sha256:".indexOf(i)!=-1&&o=="sjcl"){try{this.md=new sjcl.hash.sha256}catch(s){throw"setAlgAndProvider hash alg set fail alg="+i+"/"+s}this.updateString=function(s){this.md.update(s)},this.updateHex=function(s){var a=sjcl.codec.hex.toBits(s);this.md.update(a)},this.digest=function(){var s=this.md.finalize();return sjcl.codec.hex.fromBits(s)},this.digestString=function(s){return this.updateString(s),this.digest()},this.digestHex=function(s){return this.updateHex(s),this.digest()}}},this.updateString=function(i){throw"updateString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.updateHex=function(i){throw"updateHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digest=function(){throw"digest() not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestString=function(i){throw"digestString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestHex=function(i){throw"digestHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},e!==void 0&&e.alg!==void 0&&(this.algName=e.alg,e.prov===void 0&&(this.provName=A.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName))};A.crypto.MessageDigest.getCanonicalAlgName=function(e){return typeof e=="string"&&(e=e.toLowerCase(),e=e.replace(/-/,"")),e};A.crypto.MessageDigest.getHashLength=function(e){var t=A.crypto.MessageDigest,r=t.getCanonicalAlgName(e);if(t.HASHLENGTH[r]===void 0)throw"not supported algorithm: "+e;return t.HASHLENGTH[r]};A.crypto.MessageDigest.HASHLENGTH={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,ripemd160:20};A.crypto.Mac=function(e){var t=null,r=null,n=null,i=null,o=null;this.setAlgAndProvider=function(s,a){if(s=s.toLowerCase(),s==null&&(s="hmacsha1"),s=s.toLowerCase(),s.substr(0,4)!="hmac")throw"setAlgAndProvider unsupported HMAC alg: "+s;a===void 0&&(a=A.crypto.Util.DEFAULTPROVIDER[s]),this.algProv=s+"/"+a;var u=s.substr(4);if(":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(u)!=-1&&a=="cryptojs"){try{var l=A.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[u];this.mac=He.algo.HMAC.create(l,this.pass)}catch(f){throw"setAlgAndProvider hash alg set fail hashAlg="+u+"/"+f}this.updateString=function(f){this.mac.update(f)},this.updateHex=function(f){var m=He.enc.Hex.parse(f);this.mac.update(m)},this.doFinal=function(){var f=this.mac.finalize();return f.toString(He.enc.Hex)},this.doFinalString=function(f){return this.updateString(f),this.doFinal()},this.doFinalHex=function(f){return this.updateHex(f),this.doFinal()}}},this.updateString=function(s){throw"updateString(str) not supported for this alg/prov: "+this.algProv},this.updateHex=function(s){throw"updateHex(hex) not supported for this alg/prov: "+this.algProv},this.doFinal=function(){throw"digest() not supported for this alg/prov: "+this.algProv},this.doFinalString=function(s){throw"digestString(str) not supported for this alg/prov: "+this.algProv},this.doFinalHex=function(s){throw"digestHex(hex) not supported for this alg/prov: "+this.algProv},this.setPassword=function(s){if(typeof s=="string"){var a=s;(s.length%2==1||!s.match(/^[0-9A-Fa-f]+$/))&&(a=va(s)),this.pass=He.enc.Hex.parse(a);return}if(typeof s!="object")throw"KJUR.crypto.Mac unsupported password type: "+s;var a=null;if(s.hex!==void 0){if(s.hex.length%2!=0||!s.hex.match(/^[0-9A-Fa-f]+$/))throw"Mac: wrong hex password: "+s.hex;a=s.hex}if(s.utf8!==void 0&&(a=p2(s.utf8)),s.rstr!==void 0&&(a=va(s.rstr)),s.b64!==void 0&&(a=xh(s.b64)),s.b64u!==void 0&&(a=Dr(s.b64u)),a==null)throw"KJUR.crypto.Mac unsupported password type: "+s;this.pass=He.enc.Hex.parse(a)},e!==void 0&&(e.pass!==void 0&&this.setPassword(e.pass),e.alg!==void 0&&(this.algName=e.alg,e.prov===void 0&&(this.provName=A.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName)))};A.crypto.Signature=function(e){var t=null,r=null,n=null,i=null,o=null,s=null,a=null,u=null,l=null,f=null,m=-1,p=null,d=null,v=null,g=null,y=null;if(this._setAlgNames=function(){var w=this.algName.match(/^(.+)with(.+)$/);w&&(this.mdAlgName=w[1].toLowerCase(),this.pubkeyAlgName=w[2].toLowerCase(),this.pubkeyAlgName=="rsaandmgf1"&&this.mdAlgName=="sha"&&(this.mdAlgName="sha1"))},this._zeroPaddingOfSignature=function(w,E){for(var S="",D=E/4-w.length,F=0;F"u"||!A)&&(A={});(typeof A.crypto>"u"||!A.crypto)&&(A.crypto={});A.crypto.ECDSA=function(e){var t="secp256r1",r=null,n=null,i=null,o=Error,s=oe,a=tr,u=A.crypto.ECDSA,l=A.crypto.ECParameterDB,f=u.getName,m=ke,p=m.getVbyListEx,d=m.isASN1HEX,v=new Oh,g=null;this.type="EC",this.isPrivate=!1,this.isPublic=!1;function y(w,E,S,D){for(var F=Math.max(E.bitLength(),D.bitLength()),M=w.add2D(S),z=w.curve.getInfinity(),C=F-1;C>=0;--C)z=z.twice2D(),z.z=s.ONE,E.testBit(C)?D.testBit(C)?z=z.add2D(M):z=z.add2D(w):D.testBit(C)&&(z=z.add2D(S));return z}this.getBigRandom=function(w){return new s(w.bitLength(),v).mod(w.subtract(s.ONE)).add(s.ONE)},this.setNamedCurve=function(w){this.ecparams=l.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 E=this.ecparams.keycharlen;if(w.length!==2+E*2)throw"malformed public key hex length";var S={};return S.x=w.substr(2,E),S.y=w.substr(2+E),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,E=this.getBigRandom(w),S=this.ecparams.keycharlen,D=("0000000000"+E.toString(16)).slice(-S);this.setPrivateKeyHex(D);var F=this.generatePublicKeyHex();return{ecprvhex:D,ecpubhex:F}},this.generatePublicKeyHex=function(){var w=new s(this.prvKeyHex,16),E=this.ecparams.G.multiply(w),S=E.getX().toBigInteger(),D=E.getY().toBigInteger(),F=this.ecparams.keycharlen,M=("0000000000"+S.toString(16)).slice(-F),z=("0000000000"+D.toString(16)).slice(-F),C="04"+M+z;return this.setPublicKeyHex(C),C},this.signWithMessageHash=function(w){return this.signHex(w,this.prvKeyHex)},this.signHex=function(w,E){var S=new s(E,16),D=this.ecparams.n,F=new s(w.substring(0,this.ecparams.keycharlen),16);do var M=this.getBigRandom(D),z=this.ecparams.G,C=z.multiply(M),P=C.getX().toBigInteger().mod(D);while(P.compareTo(s.ZERO)<=0);var U=M.modInverse(D).multiply(F.add(S.multiply(P))).mod(D);return u.biRSSigToASN1Sig(P,U)},this.sign=function(w,E){var S=E,D=this.ecparams.n,F=s.fromByteArrayUnsigned(w);do var M=this.getBigRandom(D),z=this.ecparams.G,C=z.multiply(M),P=C.getX().toBigInteger().mod(D);while(P.compareTo(oe.ZERO)<=0);var U=M.modInverse(D).multiply(F.add(S.multiply(P))).mod(D);return this.serializeSig(P,U)},this.verifyWithMessageHash=function(w,E){return this.verifyHex(w,E,this.pubKeyHex)},this.verifyHex=function(w,E,S){try{var D,F,M=u.parseSigHex(E);D=M.r,F=M.s;var z=a.decodeFromHex(this.ecparams.curve,S),C=new s(w.substring(0,this.ecparams.keycharlen),16);return this.verifyRaw(C,D,F,z)}catch{return!1}},this.verify=function(w,E,S){var D,F;if(Bitcoin.Util.isArray(E)){var M=this.parseSig(E);D=M.r,F=M.s}else if(typeof E=="object"&&E.r&&E.s)D=E.r,F=E.s;else throw"Invalid value for signature";var z;if(S instanceof tr)z=S;else if(Bitcoin.Util.isArray(S))z=a.decodeFrom(this.ecparams.curve,S);else throw"Invalid format for pubkey value, must be byte array or ECPointFp";var C=s.fromByteArrayUnsigned(w);return this.verifyRaw(C,D,F,z)},this.verifyRaw=function(w,E,S,D){var F=this.ecparams.n,M=this.ecparams.G;if(E.compareTo(s.ONE)<0||E.compareTo(F)>=0||S.compareTo(s.ONE)<0||S.compareTo(F)>=0)return!1;var z=S.modInverse(F),C=w.multiply(z).mod(F),P=E.multiply(z).mod(F),U=M.multiply(C).add(D.multiply(P)),k=U.getX().toBigInteger().mod(F);return k.equals(E)},this.serializeSig=function(w,E){var S=w.toByteArraySigned(),D=E.toByteArraySigned(),F=[];return F.push(2),F.push(S.length),F=F.concat(S),F.push(2),F.push(D.length),F=F.concat(D),F.unshift(F.length),F.unshift(48),F},this.parseSig=function(w){var E;if(w[0]!=48)throw new Error("Signature not a valid DERSequence");if(E=2,w[E]!=2)throw new Error("First element in signature must be a DERInteger");var S=w.slice(E+2,E+2+w[E+1]);if(E+=2+w[E+1],w[E]!=2)throw new Error("Second element in signature must be a DERInteger");var D=w.slice(E+2,E+2+w[E+1]);E+=2+w[E+1];var F=s.fromByteArrayUnsigned(S),M=s.fromByteArrayUnsigned(D);return{r:F,s:M}},this.parseSigCompact=function(w){if(w.length!==65)throw"Signature has the wrong length";var E=w[0]-27;if(E<0||E>7)throw"Invalid signature type";var S=this.ecparams.n,D=s.fromByteArrayUnsigned(w.slice(1,33)).mod(S),F=s.fromByteArrayUnsigned(w.slice(33,65)).mod(S);return{r:D,s:F,i:E}},this.readPKCS5PrvKeyHex=function(w){if(d(w)===!1)throw new Error("not ASN.1 hex string");var E,S,D;try{E=p(w,0,["[0]",0],"06"),S=p(w,0,[1],"04");try{D=p(w,0,["[1]",0],"03")}catch{}}catch{throw new Error("malformed PKCS#1/5 plain ECC private key")}if(this.curveName=f(E),this.curveName===void 0)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(D),this.setPrivateKeyHex(S),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(w){if(d(w)===!1)throw new o("not ASN.1 hex string");var E,S,D,F;try{E=p(w,0,[1,0],"06"),S=p(w,0,[1,1],"06"),D=p(w,0,[2,0,1],"04");try{F=p(w,0,[2,0,"[1]",0],"03")}catch{}}catch{throw new o("malformed PKCS#8 plain ECC private key")}if(this.curveName=f(S),this.curveName===void 0)throw new o("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(F),this.setPrivateKeyHex(D),this.isPublic=!1},this.readPKCS8PubKeyHex=function(w){if(d(w)===!1)throw new o("not ASN.1 hex string");var E,S,D;try{E=p(w,0,[0,0],"06"),S=p(w,0,[0,1],"06"),D=p(w,0,[1],"03")}catch{throw new o("malformed PKCS#8 ECC public key")}if(this.curveName=f(S),this.curveName===null)throw new o("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(D)},this.readCertPubKeyHex=function(w,E){if(d(w)===!1)throw new o("not ASN.1 hex string");var S,D;try{S=p(w,0,[0,5,0,1],"06"),D=p(w,0,[0,5,1],"03")}catch{throw new o("malformed X.509 certificate ECC public key")}if(this.curveName=f(S),this.curveName===null)throw new o("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(D)},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))};A.crypto.ECDSA.parseSigHex=function(e){var t=A.crypto.ECDSA.parseSigHexInHexRS(e),r=new oe(t.r,16),n=new oe(t.s,16);return{r,s:n}};A.crypto.ECDSA.parseSigHexInHexRS=function(e){var t=ke,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 o=i[0],s=i[1];if(e.substr(o,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 a=n(e,o),u=n(e,s);return{r:a,s:u}};A.crypto.ECDSA.asn1SigToConcatSig=function(e){var t=A.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};A.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 A.crypto.ECDSA.hexRSSigToASN1Sig(t,r)};A.crypto.ECDSA.hexRSSigToASN1Sig=function(e,t){var r=new oe(e,16),n=new oe(t,16);return A.crypto.ECDSA.biRSSigToASN1Sig(r,n)};A.crypto.ECDSA.biRSSigToASN1Sig=function(e,t){var r=A.asn1,n=new r.DERInteger({bigint:e}),i=new r.DERInteger({bigint:t}),o=new r.DERSequence({array:[n,i]});return o.tohex()};A.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 A>"u"||!A)&&(A={});(typeof A.crypto>"u"||!A.crypto)&&(A.crypto={});A.crypto.ECParameterDB=new function(){var e={},t={};function r(n){return new oe(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,o,s,a,u,l,f,m,p,d,v){e[n]={};var g=r(o),y=r(s),w=r(a),E=r(u),S=r(l),D=new _u(g,y,w),F=D.decodePointHex("04"+f+m);e[n].name=n,e[n].keylen=i,e[n].keycharlen=Math.ceil(i/8)*2,e[n].curve=D,e[n].G=F,e[n].n=E,e[n].h=S,e[n].oid=d,e[n].info=v;for(var M=0;M"u"||!A)&&(A={});(typeof A.crypto>"u"||!A.crypto)&&(A.crypto={});A.crypto.DSA=function(){var e=ke,t=e.getVbyList,r=e.getVbyListEx,n=e.isASN1HEX,i=oe,o=oe.ONE,s=function(a,u,l,f){if(a==null||u==null||l==null||f==null)throw new Error("invalid DSA public key");if(o.compareTo(u)>=0||u.compareTo(a)>=0)throw new Error("invalid DSA public key");if(o.compareTo(l)>=0||l.compareTo(a)>=0)throw new Error("invalid DSA public key");if(o.compareTo(f)>=0||f.compareTo(a)>=0)throw new Error("invalid DSA public key");if(l.modPow(u,a).compareTo(o)!=0)throw new Error("invalid DSA public key")};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,u,l,f,m){this.isPrivate=!0,this.p=a,this.q=u,this.g=l,this.y=f,this.x=m},this.setPrivateHex=function(a,u,l,f,m){var p,d,v,g,y;p=new oe(a,16),d=new oe(u,16),v=new oe(l,16),typeof f=="string"&&f.length>1?g=new oe(f,16):g=null,y=new oe(m,16),this.setPrivate(p,d,v,g,y)},this.setPublic=function(a,u,l,f){s(a,u,l,f),this.isPublic=!0,this.p=a,this.q=u,this.g=l,this.y=f,this.x=null},this.setPublicHex=function(a,u,l,f){var m,p,d,v;m=new oe(a,16),p=new oe(u,16),d=new oe(l,16),v=new oe(f,16),this.setPublic(m,p,d,v)},this.signWithMessageHash=function(a){var u=this.p,l=this.q,f=this.g,m=this.y,p=this.x,d=a.substr(0,l.bitLength()/4),v=new oe(d,16),g,y,w;do g=A.crypto.Util.getRandomBigIntegerMinToMax(oe.ONE.add(oe.ONE),l.subtract(oe.ONE)),y=f.modPow(g,u).mod(l),w=g.modInverse(l).multiply(v.add(p.multiply(y))).mod(l);while(y.compareTo(oe.ZERO)==0||w.compareTo(oe.ZERO)==0);var E=A.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:y}},{int:{bigint:w}}]});return E},this.verifyWithMessageHash=function(a,u){var l=this.p,f=this.q,m=this.g,p=this.y,d=this.parseASN1Signature(u),v=d[0],g=d[1],y=a.substr(0,f.bitLength()/4),w=new oe(y,16);if(oe.ZERO.compareTo(v)>=0||v.compareTo(f)>=0||oe.ZERO.compareTo(g)>=0||g.compareTo(f)>=0)throw"invalid DSA signature";var E=g.modInverse(f),S=w.multiply(E).mod(f),D=v.multiply(E).mod(f),F=m.modPow(S,l).multiply(p.modPow(D,l)).mod(l).mod(f);return F.compareTo(v)==0},this.parseASN1Signature=function(a){try{var u=new i(r(a,0,[0],"02"),16),l=new i(r(a,0,[1],"02"),16);return[u,l]}catch{throw new Error("malformed ASN.1 DSA signature")}},this.readPKCS5PrvKeyHex=function(a){var u,l,f,m,p;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{u=r(a,0,[1],"02"),l=r(a,0,[2],"02"),f=r(a,0,[3],"02"),m=r(a,0,[4],"02"),p=r(a,0,[5],"02")}catch{throw new Error("malformed PKCS#1/5 plain DSA private key")}this.setPrivateHex(u,l,f,m,p)},this.readPKCS8PrvKeyHex=function(a){var u,l,f,m;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{u=r(a,0,[1,1,0],"02"),l=r(a,0,[1,1,1],"02"),f=r(a,0,[1,1,2],"02"),m=r(a,0,[2,0],"02")}catch{throw new Error("malformed PKCS#8 plain DSA private key")}this.setPrivateHex(u,l,f,null,m)},this.readPKCS8PubKeyHex=function(a){var u,l,f,m;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{u=r(a,0,[0,1,0],"02"),l=r(a,0,[0,1,1],"02"),f=r(a,0,[0,1,2],"02"),m=r(a,0,[1,0],"02")}catch{throw new Error("malformed PKCS#8 DSA public key")}this.setPublicHex(u,l,f,m)},this.readCertPubKeyHex=function(a,u){var l,f,m,p;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{l=r(a,0,[0,5,0,1,0],"02"),f=r(a,0,[0,5,0,1,1],"02"),m=r(a,0,[0,5,0,1,2],"02"),p=r(a,0,[0,5,1,0],"02")}catch{throw new Error("malformed X.509 certificate DSA public key")}this.setPublicHex(l,f,m,p)}};var Lt=function(){var e=function(g,y,w){return n(He.AES,g,y,w)},t=function(g,y,w){return n(He.TripleDES,g,y,w)},r=function(g,y,w){return n(He.DES,g,y,w)},n=function(g,y,w,E){var S=He.enc.Hex.parse(y),D=He.enc.Hex.parse(w),F=He.enc.Hex.parse(E),M={};M.key=D,M.iv=F,M.ciphertext=S;var z=g.decrypt(M,D,{iv:F});return He.enc.Hex.stringify(z)},i=function(g,y,w){return a(He.AES,g,y,w)},o=function(g,y,w){return a(He.TripleDES,g,y,w)},s=function(g,y,w){return a(He.DES,g,y,w)},a=function(g,y,w,E){var S=He.enc.Hex.parse(y),D=He.enc.Hex.parse(w),F=He.enc.Hex.parse(E),M=g.encrypt(S,D,{iv:F}),z=He.enc.Hex.parse(M.toString()),C=He.enc.Base64.stringify(z);return C},u={"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:o,keylen:24,ivlen:8},"DES-CBC":{proc:r,eproc:s,keylen:8,ivlen:8}},l=function(g){return u[g].proc},f=function(g){var y=He.lib.WordArray.random(g),w=He.enc.Hex.stringify(y);return w},m=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 E=g.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));E&&(y.type=E[1]);var S=-1,D=0;g.indexOf(`\r \r `)!=-1&&(S=g.indexOf(`\r \r `),D=2),g.indexOf(` `)!=-1&&(S=g.indexOf(` `),D=1);var F=g.indexOf("-----END");if(S!=-1&&F!=-1){var M=g.substring(S+D*2,F-D);M=M.replace(/\s+/g,""),y.data=M}return y},p=function(g,y,w){for(var E=w.substring(0,16),S=He.enc.Hex.parse(E),D=He.enc.Utf8.parse(y),F=u[g].keylen+u[g].ivlen,M="",z=null;;){var C=He.algo.MD5.create();if(z!=null&&C.update(z),C.update(D),C.update(S),z=C.finalize(),M=M+He.enc.Hex.stringify(z),M.length>=F*2)break}var P={};return P.keyhex=M.substr(0,u[g].keylen*2),P.ivhex=M.substr(u[g].keylen*2,u[g].ivlen*2),P},d=function(g,y,w,E){var S=He.enc.Base64.parse(g),D=He.enc.Hex.stringify(S),F=u[y].proc,M=F(D,w,E);return M},v=function(g,y,w,E){var S=u[y].eproc,D=S(g,w,E);return D};return{version:"1.0.0",parsePKCS5PEM:function(g){return m(g)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(g,y,w){return p(g,y,w)},decryptKeyB64:function(g,y,w,E){return d(g,y,w,E)},getDecryptedKeyHex:function(g,y){var w=m(g),E=w.type,S=w.cipher,D=w.ivsalt,F=w.data,M=p(S,y,D),z=M.keyhex,C=d(F,S,z,D);return C},getEncryptedPKCS5PEMFromPrvKeyHex:function(g,y,w,E,S){var U="";if((typeof E>"u"||E==null)&&(E="AES-256-CBC"),typeof u[E]>"u")throw new Error("KEYUTIL unsupported algorithm: "+E);if(typeof S>"u"||S==null){var D=u[E].ivlen,F=f(D);S=F.toUpperCase()}var M=p(E,w,S),z=M.keyhex,C=v(y,E,z,S),P=C.replace(/(.{64})/g,`$1\r `),U="-----BEGIN "+g+` PRIVATE KEY-----\r `;return U+=`Proc-Type: 4,ENCRYPTED\r `,U+="DEK-Info: "+E+","+S+`\r `,U+=`\r `,U+=P,U+=`\r -----END `+g+` PRIVATE KEY-----\r `,U},getEncryptedPKCS8PEM:function(g,y,w){var E=this.getEncryptedPKCS8Hex(g,y,w);return ps(E,"ENCRYPTED PRIVATE KEY")},getEncryptedPKCS8Hex:function(g,y,w){var E;w==null||w==null?E={}:E=JSON.parse(JSON.stringify(w)),E.plain=g,this.initPBES2Param(E),this.encryptPBES2Param(E,y);var S=this.generatePBES2ASN1Param(E);return A.asn1.ASN1Util.newObject(S).tohex()},initPBES2Param:function(g){if(vr(g,"encalg")==null&&(g.encalg="aes256-CBC"),vr(g,"iter")==null&&(g.iter=2048),vr(g,"prf")==null&&(g.prf="hmacWithSHA256"),vr(g,"salt")==null&&(g.salt=He.enc.Hex.stringify(He.lib.WordArray.random(8))),vr(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=He.enc.Hex.stringify(He.lib.WordArray.random(y))}},encryptPBES2Param:function(g,y){var w=Lt.getDKFromPBES2Param(g,y);try{var E=A.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=E},generatePBES2ASN1Param:function(g){var y={seq:[{seq:[{oid:"pkcs5PBES2"},{seq:[{seq:[{oid:"pkcs5PBKDF2"},{seq:[{octstr:{hex:g.salt}},{int:{hex:E9(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=ke,w=y.getChildIdx,E=y.getV,S={},D=w(g,0);if(D.length!=2)throw new Error("malformed format: SEQUENCE(0).items != 2: "+D.length);S.ciphertext=E(g,D[1]);var F=w(g,D[0]);if(F.length!=2)throw new Error("malformed format: SEQUENCE(0.0).items != 2: "+F.length);if(E(g,F[0])!="2a864886f70d01050d")throw new Error("this only supports pkcs5PBES2");var M=w(g,F[1]);if(F.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1).items != 2: "+M.length);var z=w(g,M[1]);if(z.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1.1).items != 2: "+z.length);if(E(g,z[0])!="2a864886f70d0307")throw"this only supports TripleDES";S.encryptionSchemeAlg="TripleDES",S.encryptionSchemeIV=E(g,z[1]);var C=w(g,M[0]);if(C.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1.0).items != 2: "+C.length);if(E(g,C[0])!="2a864886f70d01050c")throw new Error("this only supports pkcs5PBKDF2");var P=w(g,C[1]);if(P.length<2)throw new Error("malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+P.length);S.pbkdf2Salt=E(g,P[0]);var U=E(g,P[1]);try{S.pbkdf2Iter=parseInt(U,16)}catch{throw new Error("malformed format pbkdf2Iter: "+U)}return S},getPBKDF2KeyHexFromParam:function(g,y){var w=He.enc.Hex.parse(g.pbkdf2Salt),E=g.pbkdf2Iter,S=He.PBKDF2(y,w,{keySize:192/32,iterations:E}),D=He.enc.Hex.stringify(S);return D},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(g,y){var w=xr(g,"ENCRYPTED PRIVATE KEY"),E=this.parseHexOfEncryptedPKCS8(w),S=Lt.getPBKDF2KeyHexFromParam(E,y),D={};D.ciphertext=He.enc.Hex.parse(E.ciphertext);var F=He.enc.Hex.parse(S),M=He.enc.Hex.parse(E.encryptionSchemeIV),z=He.TripleDES.decrypt(D,F,{iv:M}),C=He.enc.Hex.stringify(z);return C},parsePBES2:function(g){var y=ke.parse(g);if(vr(y,"seq.0.seq.0.oid")!="pkcs5PBES2"||vr(y,"seq.0.seq.1.seq.0.seq.0.oid")!="pkcs5PBKDF2")throw new Error("not pkcs5PBES2 and pkcs5PBKDF2 used");var w=vr(y,"seq.0.seq.1.seq.0.seq.1.seq");if(w==null)throw new Error("PBKDF2 parameter not found");var E=vr(w,"0.octstr.hex"),S=vr(w,"1.int.hex"),D=vr(w,"2.seq.0.oid","hmacWithSHA1"),F=-1;try{F=parseInt(S,16)}catch{throw new Error("iter not proper value")}var M=vr(y,"seq.0.seq.1.seq.1.seq.0.oid"),z=vr(y,"seq.0.seq.1.seq.1.seq.1.octstr.hex"),C=vr(y,"seq.1.octstr.hex");if(M==null||z==null||C==null)throw new Error("encalg, enciv or enc is undefined");var P={salt:E,iter:F,prf:D,encalg:M,enciv:z,enc:C};return P},getDKFromPBES2Param:function(g,y){var w={hmacWithSHA1:He.algo.SHA1,hmacWithSHA224:He.algo.SHA224,hmacWithSHA256:He.algo.SHA256,hmacWithSHA384:He.algo.SHA384,hmacWithSHA512:He.algo.SHA512},E={"des-EDE3-CBC":192/32,"aes128-CBC":128/32,"aes256-CBC":256/32},S=w[g.prf];if(S==null)throw new Error("unsupported prf");var D=E[g.encalg];if(D==null)throw new Error("unsupported encalg");var F=He.enc.Hex.parse(g.salt),M=g.iter;try{var z=He.PBKDF2(y,F,{keySize:D,iterations:M,hasher:S});return He.enc.Hex.stringify(z)}catch(C){throw new Error("PBKDF2 error: "+C+" "+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=xr(g),E;try{E=Lt.parsePBES2(w)}catch(D){throw new Error("malformed PBES2 format: "+D.message)}var S=Lt.getDKFromPBES2Param(E,y);return A.crypto.Cipher.decrypt(E.enc,S,E.encalg,{iv:E.enciv})},getKeyFromEncryptedPKCS8PEM:function(g,y){var w=this.getPlainHexFromEncryptedPKCS8PEM(g,y),E=this.getKeyFromPlainPrivatePKCS8Hex(w);return E},parsePlainPrivatePKCS8Hex:function(g){var y=ke,w=y.getChildIdx,E=y.getV,S={};if(S.algparam=null,g.substr(0,2)!="30")throw new Error("malformed plain PKCS8 private key(code:001)");var D=w(g,0);if(D.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if(g.substr(D[1],2)!="30")throw new Error("malformed PKCS8 private key(code:003)");var F=w(g,D[1]);if(F.length!=2)throw new Error("malformed PKCS8 private key(code:004)");if(g.substr(F[0],2)!="06")throw new Error("malformed PKCS8 private key(code:005)");if(S.algoid=E(g,F[0]),g.substr(F[1],2)=="06"&&(S.algparam=E(g,F[1])),g.substr(D[2],2)!="04")throw new Error("malformed PKCS8 private key(code:006)");return S.keyidx=y.getVidx(g,D[2]),S},getKeyFromPlainPrivatePKCS8PEM:function(g){var y=xr(g,"PRIVATE KEY"),w=this.getKeyFromPlainPrivatePKCS8Hex(y);return w},getKeyFromPlainPrivatePKCS8Hex:function(g){var y=this.parsePlainPrivatePKCS8Hex(g),w;if(y.algoid=="2a864886f70d010101")w=new yt;else if(y.algoid=="2a8648ce380401")w=new A.crypto.DSA;else if(y.algoid=="2a8648ce3d0201")w=new A.crypto.ECDSA;else throw new Error("unsupported private key algorithm");return w.readPKCS8PrvKeyHex(g),w},_getKeyFromPublicPKCS8Hex:function(g){var y,w=ke.getVbyList(g,0,[0,0],"06");if(w==="2a864886f70d010101")y=new yt;else if(w==="2a8648ce380401")y=new A.crypto.DSA;else if(w==="2a8648ce3d0201")y=new A.crypto.ECDSA;else throw new Error("unsupported PKCS#8 public key hex");return y.readPKCS8PubKeyHex(g),y},parsePublicRawRSAKeyHex:function(g){var y=ke,w=y.getChildIdx,E=y.getV,S={};if(g.substr(0,2)!="30")throw new Error("malformed RSA key(code:001)");var D=w(g,0);if(D.length!=2)throw new Error("malformed RSA key(code:002)");if(g.substr(D[0],2)!="02")throw new Error("malformed RSA key(code:003)");if(S.n=E(g,D[0]),g.substr(D[1],2)!="02")throw new Error("malformed RSA key(code:004)");return S.e=E(g,D[1]),S},parsePublicPKCS8Hex:function(g){var y=ke,w=y.getChildIdx,E=y.getV,S={};S.algparam=null;var D=w(g,0);if(D.length!=2)throw new Error("outer DERSequence shall have 2 elements: "+D.length);var F=D[0];if(g.substr(F,2)!="30")throw new Error("malformed PKCS8 public key(code:001)");var M=w(g,F);if(M.length!=2)throw new Error("malformed PKCS8 public key(code:002)");if(g.substr(M[0],2)!="06")throw new Error("malformed PKCS8 public key(code:003)");if(S.algoid=E(g,M[0]),g.substr(M[1],2)=="06"?S.algparam=E(g,M[1]):g.substr(M[1],2)=="30"&&(S.algparam={},S.algparam.p=y.getVbyList(g,M[1],[0],"02"),S.algparam.q=y.getVbyList(g,M[1],[1],"02"),S.algparam.g=y.getVbyList(g,M[1],[2],"02")),g.substr(D[1],2)!="03")throw new Error("malformed PKCS8 public key(code:004)");return S.key=E(g,D[1]).substr(2),S}}}();Lt.getKey=function(e,t,r){var n=ke,i=n.getChildIdx,o=n.getV,s=n.getVbyList,a=A.crypto,u=a.ECDSA,l=a.DSA,f=yt,m=xr,p=Lt;if(typeof f<"u"&&e instanceof f||typeof u<"u"&&e instanceof u||typeof l<"u"&&e instanceof l)return e;if(e.curve!==void 0&&e.xy!==void 0&&e.d===void 0)return new u({pub:e.xy,curve:e.curve});if(e.curve!==void 0&&e.d!==void 0)return new u({prv:e.d,curve:e.curve});if(e.kty===void 0&&e.n!==void 0&&e.e!==void 0&&e.d===void 0){var d=new f;return d.setPublic(e.n,e.e),d}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 d=new f;return d.setPrivateEx(e.n,e.e,e.d,e.p,e.q,e.dp,e.dq,e.co),d}if(e.kty===void 0&&e.n!==void 0&&e.e!==void 0&&e.d!==void 0&&e.p===void 0){var d=new f;return d.setPrivate(e.n,e.e,e.d),d}if(e.p!==void 0&&e.q!==void 0&&e.g!==void 0&&e.y!==void 0&&e.x===void 0){var d=new l;return d.setPublic(e.p,e.q,e.g,e.y),d}if(e.p!==void 0&&e.q!==void 0&&e.g!==void 0&&e.y!==void 0&&e.x!==void 0){var d=new l;return d.setPrivate(e.p,e.q,e.g,e.y,e.x),d}if(e.kty==="RSA"&&e.n!==void 0&&e.e!==void 0&&e.d===void 0){var d=new f;return d.setPublic(Dr(e.n),Dr(e.e)),d}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 d=new f;return d.setPrivateEx(Dr(e.n),Dr(e.e),Dr(e.d),Dr(e.p),Dr(e.q),Dr(e.dp),Dr(e.dq),Dr(e.qi)),d}if(e.kty==="RSA"&&e.n!==void 0&&e.e!==void 0&&e.d!==void 0){var d=new f;return d.setPrivate(Dr(e.n),Dr(e.e),Dr(e.d)),d}if(e.kty==="EC"&&e.crv!==void 0&&e.x!==void 0&&e.y!==void 0&&e.d===void 0){var v=new u({curve:e.crv}),g=v.ecparams.keycharlen,y=("0000000000"+Dr(e.x)).slice(-g),w=("0000000000"+Dr(e.y)).slice(-g),E="04"+y+w;return v.setPublicKeyHex(E),v}if(e.kty==="EC"&&e.crv!==void 0&&e.x!==void 0&&e.y!==void 0&&e.d!==void 0){var v=new u({curve:e.crv}),g=v.ecparams.keycharlen,y=("0000000000"+Dr(e.x)).slice(-g),w=("0000000000"+Dr(e.y)).slice(-g),E="04"+y+w,S=("0000000000"+Dr(e.d)).slice(-g);return v.setPublicKeyHex(E),v.setPrivateKeyHex(S),v}if(r==="pkcs5prv"){var D=e,n=ke,F,d;if(F=i(D,0),F.length===9)d=new f,d.readPKCS5PrvKeyHex(D);else if(F.length===6)d=new l,d.readPKCS5PrvKeyHex(D);else if(F.length>2&&D.substr(F[1],2)==="04")d=new u,d.readPKCS5PrvKeyHex(D);else throw new Error("unsupported PKCS#1/5 hexadecimal key");return d}if(r==="pkcs8prv"){var d=p.getKeyFromPlainPrivatePKCS8Hex(e);return d}if(r==="pkcs8pub")return p._getKeyFromPublicPKCS8Hex(e);if(r==="x509pub")return lt.getPublicKeyFromCertHex(e);if(e.indexOf("-END CERTIFICATE-",0)!=-1||e.indexOf("-END X509 CERTIFICATE-",0)!=-1||e.indexOf("-END TRUSTED CERTIFICATE-",0)!=-1)return lt.getPublicKeyFromCertPEM(e);if(e.indexOf("-END PUBLIC KEY-")!=-1){var M=xr(e,"PUBLIC KEY");return p._getKeyFromPublicPKCS8Hex(M)}if(e.indexOf("-END RSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")==-1){var z=m(e,"RSA PRIVATE KEY");return p.getKey(z,null,"pkcs5prv")}if(e.indexOf("-END DSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")==-1){var C=m(e,"DSA PRIVATE KEY"),P=s(C,0,[1],"02"),U=s(C,0,[2],"02"),k=s(C,0,[3],"02"),O=s(C,0,[4],"02"),q=s(C,0,[5],"02"),d=new l;return d.setPrivate(new oe(P,16),new oe(U,16),new oe(k,16),new oe(O,16),new oe(q,16)),d}if(e.indexOf("-END EC PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")==-1){var z=m(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 N=p.getDecryptedKeyHex(e,t),_=new yt;return _.readPKCS5PrvKeyHex(N),_}if(e.indexOf("-END EC PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")!=-1){var C=p.getDecryptedKeyHex(e,t),d=s(C,0,[1],"04"),R=s(C,0,[2,0],"06"),K=s(C,0,[3,0],"03").substr(2),Z="";if(A.crypto.OID.oidhex2name[R]!==void 0)Z=A.crypto.OID.oidhex2name[R];else throw new Error("undefined OID(hex) in KJUR.crypto.OID: "+R);var v=new u({curve:Z});return v.setPublicKeyHex(K),v.setPrivateKeyHex(d),v.isPublic=!1,v}if(e.indexOf("-END DSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")!=-1){var C=p.getDecryptedKeyHex(e,t),P=s(C,0,[1],"02"),U=s(C,0,[2],"02"),k=s(C,0,[3],"02"),O=s(C,0,[4],"02"),q=s(C,0,[5],"02"),d=new l;return d.setPrivate(new oe(P,16),new oe(U,16),new oe(k,16),new oe(O,16),new oe(q,16)),d}if(e.indexOf("-END ENCRYPTED PRIVATE KEY-")!=-1)return p.getKeyFromEncryptedPKCS8PEM(e,t);throw new Error("not supported argument")};Lt.generateKeypair=function(e,t){if(e=="RSA"){var r=t,n=new yt;n.generate(r,"10001"),n.isPrivate=!0,n.isPublic=!0;var i=new yt,o=n.n.toString(16),s=n.e.toString(16);i.setPublic(o,s),i.isPrivate=!1,i.isPublic=!0;var a={};return a.prvKeyObj=n,a.pubKeyObj=i,a}else if(e=="EC"){var u=t,l=new A.crypto.ECDSA({curve:u}),f=l.generateKeyPairHex(),n=new A.crypto.ECDSA({curve:u});n.setPublicKeyHex(f.ecpubhex),n.setPrivateKeyHex(f.ecprvhex),n.isPrivate=!0,n.isPublic=!1;var i=new A.crypto.ECDSA({curve:u});i.setPublicKeyHex(f.ecpubhex),i.isPrivate=!1,i.isPublic=!0;var a={};return a.prvKeyObj=n,a.pubKeyObj=i,a}else throw new Error("unknown algorithm: "+e)};Lt.getPEM=function(e,t,r,n,i,o){var s=A,a=s.asn1,u=a.DERObjectIdentifier,l=a.DERInteger,f=a.ASN1Util.newObject,m=a.x509,p=m.SubjectPublicKeyInfo,d=s.crypto,v=d.DSA,g=d.ECDSA,y=yt;function w(_){var R=f({seq:[{int:0},{int:{bigint:_.n}},{int:_.e},{int:{bigint:_.d}},{int:{bigint:_.p}},{int:{bigint:_.q}},{int:{bigint:_.dmp1}},{int:{bigint:_.dmq1}},{int:{bigint:_.coeff}}]});return R}function E(_){var R=f({seq:[{int:1},{octstr:{hex:_.prvKeyHex}},{tag:["a0",!0,{oid:{name:_.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+_.pubKeyHex}}]}]});return R}function S(_){var R=f({seq:[{int:0},{int:{bigint:_.p}},{int:{bigint:_.q}},{int:{bigint:_.g}},{int:{bigint:_.y}},{int:{bigint:_.x}}]});return R}if((y!==void 0&&e instanceof y||v!==void 0&&e instanceof v||g!==void 0&&e instanceof g)&&e.isPublic==!0&&(t===void 0||t=="PKCS8PUB")){var D=new p(e),F=D.tohex();return ps(F,"PUBLIC KEY")}if(t=="PKCS1PRV"&&y!==void 0&&e instanceof y&&(r===void 0||r==null)&&e.isPrivate==!0){var D=w(e),F=D.tohex();return ps(F,"RSA PRIVATE KEY")}if(t=="PKCS1PRV"&&g!==void 0&&e instanceof g&&(r===void 0||r==null)&&e.isPrivate==!0){var M=new u({name:e.curveName}),z=M.tohex(),C=E(e),P=C.tohex(),U="";return U+=ps(z,"EC PARAMETERS"),U+=ps(P,"EC PRIVATE KEY"),U}if(t=="PKCS1PRV"&&v!==void 0&&e instanceof v&&(r===void 0||r==null)&&e.isPrivate==!0){var D=S(e),F=D.tohex();return ps(F,"DSA PRIVATE KEY")}if(t=="PKCS5PRV"&&y!==void 0&&e instanceof y&&r!==void 0&&r!=null&&e.isPrivate==!0){var D=w(e),F=D.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",F,r,n,o)}if(t=="PKCS5PRV"&&g!==void 0&&e instanceof g&&r!==void 0&&r!=null&&e.isPrivate==!0){var D=E(e),F=D.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",F,r,n,o)}if(t=="PKCS5PRV"&&v!==void 0&&e instanceof v&&r!==void 0&&r!=null&&e.isPrivate==!0){var D=S(e),F=D.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",F,r,n,o)}var k=function(_,R){if(typeof R=="string")return Lt.getEncryptedPKCS8PEM(_,R);if(typeof R=="object"&&vr(R,"passcode")!=null){var K=JSON.parse(JSON.stringify(R)),Z=K.passcode;return delete K.passcode,Lt.getEncryptedPKCS8PEM(_,Z,K)}};if(t=="PKCS8PRV"&&y!=null&&e instanceof y&&e.isPrivate==!0){var O=w(e),q=O.tohex(),D=f({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:q}}]}),F=D.tohex();return r===void 0||r==null?ps(F,"PRIVATE KEY"):k(F,r)}if(t=="PKCS8PRV"&&g!==void 0&&e instanceof g&&e.isPrivate==!0){var N={seq:[{int:1},{octstr:{hex:e.prvKeyHex}}]};typeof e.pubKeyHex=="string"&&N.seq.push({tag:["a1",!0,{bitstr:{hex:"00"+e.pubKeyHex}}]});var O=new f(N),q=O.tohex(),D=f({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:e.curveName}}]},{octstr:{hex:q}}]}),F=D.tohex();return r===void 0||r==null?ps(F,"PRIVATE KEY"):k(F,r)}if(t=="PKCS8PRV"&&v!==void 0&&e instanceof v&&e.isPrivate==!0){var O=new l({bigint:e.x}),q=O.tohex(),D=f({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.g}}]}]},{octstr:{hex:q}}]}),F=D.tohex();return r===void 0||r==null?ps(F,"PRIVATE KEY"):k(F,r)}throw new Error("unsupported object nor format")};Lt.getKeyFromCSRPEM=function(e){var t=xr(e,"CERTIFICATE REQUEST"),r=Lt.getKeyFromCSRHex(t);return r};Lt.getKeyFromCSRHex=function(e){var t=Lt.parseCSRHex(e),r=Lt.getKey(t.p8pubkeyhex,null,"pkcs8pub");return r};Lt.parseCSRHex=function(e){var t=ke,r=t.getChildIdx,n=t.getTLV,i={},o=e;if(o.substr(0,2)!="30")throw new Error("malformed CSR(code:001)");var s=r(o,0);if(s.length<1)throw new Error("malformed CSR(code:002)");if(o.substr(s[0],2)!="30")throw new Error("malformed CSR(code:003)");var a=r(o,s[0]);if(a.length<3)throw new Error("malformed CSR(code:004)");return i.p8pubkeyhex=n(o,a[2]),i};Lt.getKeyID=function(e){var t=Lt,r=ke;typeof e=="string"&&e.indexOf("BEGIN ")!=-1&&(e=t.getKey(e));var n=xr(t.getPEM(e)),i=r.getIdxbyList(n,0,[1]),o=r.getV(n,i).substring(2);return A.crypto.Util.hashHex(o,"sha1")};Lt.getJWK=function(e,t,r,n,i){var o,s={},a,u=A.crypto.Util.hashHex;if(typeof e=="string")o=Lt.getKey(e),e.indexOf("CERTIFICATE")!=-1&&(a=xr(e));else if(typeof e=="object")e instanceof lt?(o=e.getPublicKey(),a=e.hex):o=e;else throw new Error("unsupported keyinfo type");if(o instanceof yt&&o.isPrivate)s.kty="RSA",s.n=hn(o.n.toString(16)),s.e=hn(o.e.toString(16)),s.d=hn(o.d.toString(16)),s.p=hn(o.p.toString(16)),s.q=hn(o.q.toString(16)),s.dp=hn(o.dmp1.toString(16)),s.dq=hn(o.dmq1.toString(16)),s.qi=hn(o.coeff.toString(16));else if(o instanceof yt&&o.isPublic)s.kty="RSA",s.n=hn(o.n.toString(16)),s.e=hn(o.e.toString(16));else if(o instanceof A.crypto.ECDSA&&o.isPrivate){var l=o.getShortNISTPCurveName();if(l!=="P-256"&&l!=="P-384"&&l!=="P-521")throw new Error("unsupported curve name for JWT: "+l);var f=o.getPublicKeyXYHex();s.kty="EC",s.crv=l,s.x=hn(f.x),s.y=hn(f.y),s.d=hn(o.prvKeyHex)}else if(o instanceof A.crypto.ECDSA&&o.isPublic){var l=o.getShortNISTPCurveName();if(l!=="P-256"&&l!=="P-384"&&l!=="P-521")throw new Error("unsupported curve name for JWT: "+l);var f=o.getPublicKeyXYHex();s.kty="EC",s.crv=l,s.x=hn(f.x),s.y=hn(f.y)}if(s.kty==null)throw new Error("unsupported keyinfo");return!o.isPrivate&&t!=!0&&(s.kid=A.jws.JWS.getJWKthumbprint(s)),a!=null&&r!=!0&&(s.x5c=[Cu(a)]),a!=null&&n!=!0&&(s.x5t=Ph(Cu(u(a,"sha1")))),a!=null&&i!=!0&&(s["x5t#S256"]=Ph(Cu(u(a,"sha256")))),s};Lt.getJWKFromKey=function(e){return Lt.getJWK(e,!0,!0,!0,!0)};yt.getPosArrayOfChildrenFromHex=function(e){return ke.getChildIdx(e,0)};yt.getHexValueArrayOfChildrenFromHex=function(e){var t=ke,r=t.getV,p=yt.getPosArrayOfChildrenFromHex(e),n=r(e,p[0]),i=r(e,p[1]),o=r(e,p[2]),s=r(e,p[3]),a=r(e,p[4]),u=r(e,p[5]),l=r(e,p[6]),f=r(e,p[7]),m=r(e,p[8]),p=new Array;return p.push(n,i,o,s,a,u,l,f,m),p};yt.prototype.readPrivateKeyFromPEMString=function(e){var t=xr(e),r=yt.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8])};yt.prototype.readPKCS5PrvKeyHex=function(e){var t=yt.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])};yt.prototype.readPKCS8PrvKeyHex=function(e){var t,r,n,i,o,s,a,u,l=ke,f=l.getVbyListEx;if(l.isASN1HEX(e)===!1)throw new Error("not ASN.1 hex string");try{t=f(e,0,[2,0,1],"02"),r=f(e,0,[2,0,2],"02"),n=f(e,0,[2,0,3],"02"),i=f(e,0,[2,0,4],"02"),o=f(e,0,[2,0,5],"02"),s=f(e,0,[2,0,6],"02"),a=f(e,0,[2,0,7],"02"),u=f(e,0,[2,0,8],"02")}catch{throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(t,r,n,i,o,s,a,u)};yt.prototype.readPKCS5PubKeyHex=function(e){var t=ke,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]),o=r(e,n[1]);this.setPublic(i,o)};yt.prototype.readPKCS8PubKeyHex=function(e){var t=ke;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)};yt.prototype.readCertPubKeyHex=function(e,t){var r,n;r=new lt,r.readCertHex(e),n=r.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)};var awe=new RegExp("[^0-9a-f]","gi");function C9(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}yt.prototype.signPSS=function(e,t,r){var n=function(o){return A.crypto.Util.hashHex(o,t)},i=n(va(e));return r===void 0&&(r=-1),this.signWithMessageHashPSS(i,t,r)};yt.prototype.signWithMessageHashPSS=function(e,t,r){var n=Qs(e),i=n.length,o=this.n.bitLength()-1,s=Math.ceil(o/8),a,u=function(y){return A.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&&(l=new Array(r),new Oh().nextBytes(l),l=String.fromCharCode.apply(String,l));var f=Qs(u(va("\0\0\0\0\0\0\0\0"+n+l))),m=[];for(a=0;a>8*s-o&255;for(v[0]&=~g,a=0;an)return!1;var i=this.doPublic(r),o=i.toString(16);if(o.length+3!=n/4)return!1;var s=o.replace(/^1f+00/,""),a=D9(s);if(a.length==0)return!1;var u=a[0],l=a[1],f=function(p){return A.crypto.Util.hashString(p,u)},m=f(e);return l==m};yt.prototype.verifyWithMessageHash=function(e,t){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var r=Js(t,16);if(r.bitLength()>this.n.bitLength())return 0;var n=this.doPublic(r),i=n.toString(16).replace(/^1f+00/,""),o=D9(i);if(o.length==0)return!1;var s=o[0],a=o[1];return a==e};yt.prototype.verifyPSS=function(e,t,r,n){var i=function(s){return A.crypto.Util.hashHex(s,r)},o=i(va(e));return n===void 0&&(n=-1),this.verifyWithMessageHashPSS(o,t,r,n)};yt.prototype.verifyWithMessageHashPSS=function(e,t,r,n){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var i=new oe(t,16),o=function(E){return A.crypto.Util.hashHex(E,r)},s=Qs(e),a=s.length,u=this.n.bitLength()-1,l=Math.ceil(u/8),f;if(n===-1||n===void 0)n=a;else if(n===-2)n=l-a-2;else if(n<-2)throw new Error("invalid salt length");if(l>8*l-u&255;if(p.charCodeAt(0)&v)throw new Error("bits beyond keysize not zero");var g=_9(d,p.length,o),y=[];for(f=0;f0?P:void 0}catch{return}},this._asn1ToNoticeRef=function(C){try{for(var P={},U=vr(C,"seq"),k=0;k0?P:void 0}catch{return}},this._asn1ToNoticeNum=function(C){try{for(var P=vr(C,"seq"),U=[],k=0;k1){var q=s(C,O[1]),N=this.getGeneralName(q);N.uri!=null&&(k.uri=N.uri)}if(O.length>2){var _=s(C,O[2]);_=="0101ff"&&(k.reqauth=!0),_=="010100"&&(k.reqauth=!1)}return k},this.getExtSubjectDirectoryAttributes=function(C,P){if(C===void 0&&P===void 0){var U=this.getExtInfo("subjectDirectoryAttributes");if(U===void 0)return;C=s(this.hex,U.vidx),P=U.critical}var k={extname:"subjectDirectoryAttributes"};P&&(k.critical=!0);try{for(var O=o(C),q=[],N=0;N0&&(P.ext=this.getExtParamArray()),P.sighex=this.getSignatureValueHex(),C.tbshex==!0&&(P.tbshex=l(this.hex,0,[0])),C.nodnarray==!0&&(delete P.issuer.array,delete P.subject.array),P},this.getExtParamArray=function(C){if(C==null){var P=p(this.hex,0,[0,"[3]"]);P!=-1&&(C=f(this.hex,0,[0,"[3]",0],"30"))}for(var U=[],k=r(C,0),O=0;O"u"||!A)&&(A={});(typeof A.jws>"u"||!A.jws)&&(A.jws={});A.jws.JWS=function(){var e=A,t=e.jws.JWS,r=t.isSafeJSONString;this.parseJWS=function(n,i){if(!(this.parsedJWS!==void 0&&(i||this.parsedJWS.sigvalH!==void 0))){var o=n.match(/^([^.]+)\.([^.]+)\.([^.]+)$/);if(o==null)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";var s=o[1],a=o[2],u=o[3],l=s+"."+a;if(this.parsedJWS={},this.parsedJWS.headB64U=s,this.parsedJWS.payloadB64U=a,this.parsedJWS.sigvalB64U=u,this.parsedJWS.si=l,!i){var f=Dr(u),m=Js(f,16);this.parsedJWS.sigvalH=f,this.parsedJWS.sigvalBI=m}var p=yo(s),d=yo(a);if(this.parsedJWS.headS=p,this.parsedJWS.payloadS=d,!r(p,this.parsedJWS,"headP"))throw"malformed JSON string for JWS Head: "+p}}};A.jws.JWS.sign=function(e,t,r,n,i){var o=A,s=o.jws,a=s.JWS,u=a.readSafeJSONString,l=a.isSafeJSONString,f=o.crypto,m=f.ECDSA,p=f.Mac,d=f.Signature,v=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=v.stringify(y)),typeof t=="string"){if(g=t,!l(g))throw"JWS Head is not safe JSON string: "+g;y=u(g)}if(w=r,typeof r=="object"&&(w=v.stringify(r)),(e==""||e==null)&&y.alg!==void 0&&(e=y.alg),e!=""&&e!=null&&y.alg===void 0&&(y.alg=e,g=v.stringify(y)),e!==y.alg)throw"alg and sHeader.alg doesn't match: "+e+"!="+y.alg;var E=null;if(a.jwsalg2sigalg[e]===void 0)throw"unsupported alg name: "+e;E=a.jwsalg2sigalg[e];var S=n0(g),D=n0(w),F=S+"."+D,M="";if(E.substr(0,4)=="Hmac"){if(n===void 0)throw"mac key shall be specified for HS* alg";var z=new p({alg:E,prov:"cryptojs",pass:n});z.updateString(F),M=z.doFinal()}else if(E.indexOf("withECDSA")!=-1){var C=new d({alg:E});C.init(n,i),C.updateString(F);var P=C.sign();M=A.crypto.ECDSA.asn1SigToConcatSig(P)}else if(E!="none"){var C=new d({alg:E});C.init(n,i),C.updateString(F),M=C.sign()}var U=hn(M);return F+"."+U};A.jws.JWS.verify=function(e,t,r){var n=A,i=n.jws,o=i.JWS,s=o.readSafeJSONString,a=n.crypto,u=a.ECDSA,l=a.Mac,f=a.Signature,m;if(typeof yt!==void 0&&(m=yt),!iS(e))return!1;var p=e.split(".");if(p.length!==3)return!1;var d=p[0],v=p[1],g=d+"."+v,y=Dr(p[2]),w=s(yo(p[0])),E=null,S=null;if(w.alg===void 0)throw"algorithm not specified in header";if(E=w.alg,S=E.substr(0,2),r!=null&&Object.prototype.toString.call(r)==="[object Array]"&&r.length>0){var D=":"+r.join(":")+":";if(D.indexOf(":"+E+":")==-1)throw"algorithm '"+E+"' not accepted in the list"}if(E!="none"&&t===null)throw"key shall be specified to verify.";if(typeof t=="string"&&t.indexOf("-----BEGIN ")!=-1&&(t=Lt.getKey(t)),(S=="RS"||S=="PS")&&!(t instanceof m))throw"key shall be a RSAKey obj for RS* and PS* algs";if(S=="ES"&&!(t instanceof u))throw"key shall be a ECDSA obj for ES* algs";E=="none";var F=null;if(o.jwsalg2sigalg[w.alg]===void 0)throw new Error("unsupported alg name: "+E);if(F=o.jwsalg2sigalg[E],w.crit!==void 0){if(!Array.isArray(w.crit)||w.crit.length===0)throw new Error("wrong critical header");for(var M=0;M"u"||!A)&&(A={});(typeof A.jws>"u"||!A.jws)&&(A.jws={});A.jws.JWSJS=function(){var e=A,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 o=i.split(".");if(o.length!=3)throw"malformed input JWS";this.aHeader.push(o[0]),this.sPayload=o[1],this.aSignature.push(o[2])},this.addSignature=function(i,o,s,a){if(this.sPayload===void 0||this.sPayload===null)throw"there's no JSON-JS signature to add.";var u=this.aHeader.length;if(this.aHeader.length!=this.aSignature.length)throw"aHeader.length != aSignature.length";try{var l=A.jws.JWS.sign(i,o,this.sPayload,s,a),f=l.split("."),m=f[0],p=f[2];this.aHeader.push(f[0]),this.aSignature.push(f[2])}catch(d){throw this.aHeader.length>u&&this.aHeader.pop(),this.aSignature.length>u&&this.aSignature.pop(),"addSignature failed: "+d}},this.verifyAll=function(i){if(this.aHeader.length!==i.length||this.aSignature.length!==i.length)return!1;for(var o=0;o0)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}};Ne.SecureRandom=Oh;Ne.rng_seed_time=eS;Ne.BigInteger=oe;Ne.RSAKey=yt;Ne.ECDSA=A.crypto.ECDSA;Ne.DSA=A.crypto.DSA;Ne.Signature=A.crypto.Signature;Ne.MessageDigest=A.crypto.MessageDigest;Ne.Mac=A.crypto.Mac;Ne.KEYUTIL=Lt;Ne.ASN1HEX=ke;Ne.X509=lt;Ne.X509CRL=KX;Ne.CryptoJS=He;Ne.b64tohex=xh;Ne.b64toBA=i9;Ne.ECFieldElementFp=dn;Ne.ECPointFp=tr;Ne.ECCurveFp=_u;Ne.stoBA=f9;Ne.BAtos=h9;Ne.BAtohex=d2;Ne.stohex=Zs;Ne.stob64=CX;Ne.stob64u=_X;Ne.b64utos=DX;Ne.b64tob64u=Ph;Ne.b64utob64=i0;Ne.hex2b64=Cu;Ne.hextob64u=hn;Ne.b64utohex=Dr;Ne.utf8tob64u=n0;Ne.b64utoutf8=yo;Ne.utf8tob64=FX;Ne.b64toutf8=IX;Ne.utf8tohex=p2;Ne.hextoutf8=cr;Ne.hextorstr=Qs;Ne.rstrtohex=va;Ne.hextob64=tS;Ne.hextob64nl=TX;Ne.b64nltohex=d9;Ne.hextopem=ps;Ne.pemtohex=xr;Ne.hextoArrayBuffer=RX;Ne.ArrayBuffertohex=kX;Ne.zulutomsec=rS;Ne.msectozulu=OX;Ne.zulutosec=p9;Ne.zulutodate=NX;Ne.datetozulu=LX;Ne.uricmptohex=g2;Ne.hextouricmp=v2;Ne.ipv6tohex=YA;Ne.hextoipv6=WA;Ne.hextoip=u2;Ne.iptohex=nS;Ne.ucs2hextoutf8=sS;Ne.encodeURIComponentAll=w2;Ne.newline_toUnix=UX;Ne.newline_toDos=HX;Ne.hextoposhex=XA;Ne.intarystrtohex=MX;Ne.strdiffidx=qX;Ne.oidtohex=y9;Ne.hextooid=y2;Ne.strpad=c2;Ne.bitstrtoint=b9;Ne.inttobitstr=A9;Ne.bitstrtobinstr=S9;Ne.binstrtobitstr=jX;Ne.isBase64URLDot=iS;Ne.namearraytobinstr=l2;Ne.extendClass=_e;Ne.foldnl=m2;Ne.b64topem=PX;Ne.pemtob64=xX;Ne.timeogen=m9;Ne.aryval=vr;Ne.inttohex=E9;Ne.twoscompl=o0;Ne.timingSafeEqual=v9;Ne.timingSafeEqualImpl=w9;Ne.KJUR=A;Ne.crypto=A.crypto;Ne.asn1=A.asn1;Ne.jws=A.jws;Ne.lang=A.lang;Ne.VERSION=QG;Ne.VERSION_FULL=eY});var $9=Ce(uS=>{"use strict";var wwe=B(T());uS.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};uS.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 T9=Ce(cS=>{"use strict";var Ewe=B(T());cS.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};cS.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 P9=Ce(lS=>{"use strict";var Awe=B(T());lS.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};lS.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 x9=Ce(fS=>{"use strict";var Cwe=B(T());fS.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};fS.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 R9=Ce(hS=>{"use strict";var Dwe=B(T());hS.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}`};hS.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 N9=Ce((O9,dS)=>{var Fwe=B(T()),k9=function(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.decode=m,e.encode=f,e.familyOf=l,e.name=void 0,e.sizeOf=u,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,o={name:"v4",size:r,isFormat:p=>t.test(p),encode(p,d,v){v=~~v,d=d||new Uint8Array(v+r);let g=p.length,y=0;for(let w=0;wp.length>0&&n.test(p),encode(p,d,v){v=~~v;let g=v+i,y=-1,w=0,E=0,S=!0,D=!1;d=d||new Uint8Array(v+i);for(let F=0;F>8),v=97?M-=87:M>=65?M-=55:(M-=48,E=E*10+M),w=(w<<4)+M)}if(S===!1)D===!0?(v>8),v=y+2;F--)d[F]=d[F-2];d[y]=0,d[y+1]=0,y=v}if(y!==v&&y!==-1)for(v>g-2&&(v=g-2);g>y;)d[--g]=vy?d[--v]:0;else for(;v{"use strict";var Bwe=B(T()),at=i2().Buffer,ku=$9(),zX=T9(),GX=P9(),S2=x9(),pS=R9(),rf=N9(),YX=0,L9=32768,mS=32768,WX=~mS,U9=32768,XX=~U9,Ge=ot.name={};Ge.encode=function(e,t,r,{mail:n=!1}={}){t||(t=at.alloc(Ge.encodingLength(e))),r||(r=0);let i=r,o=e.replace(/^\.|\.$/gm,"");if(o.length){let s=[];if(n){let a="";o.split(".").forEach(u=>{u.endsWith("\\")?a+=(a.length?".":"")+u.slice(0,-1):s.length===0&&a.length?s.push(a+"."+u):s.push(u)})}else s=o.split(".");for(let a=0;a=e.length)throw new Error("Cannot decode name (buffer overflow)");let u=e[t++];if(s+=a?0:1,u===0)break;if(u&192)if((u&192)===192){if(t+1>e.length)throw new Error("Cannot decode name (buffer overflow)");let l=e.readUInt16BE(t-1)-49152;if(l>=i)throw new Error("Cannot decode name (bad pointer)");t=l,i=l,s+=a?0:1,a=!0}else throw new Error("Cannot decode name (bad label)");else{if(t+u>e.length)throw new Error("Cannot decode name (buffer overflow)");if(o+=u+1,o>254)throw new Error("Cannot decode name (name too long)");let l=e.toString("utf-8",t,t+u);r&&(l=l.replace(/\./g,"\\.")),n.push(l),t+=u,s+=a?0:u}}return Ge.decode.bytes=s,n.length===0?".":n.join(".")};Ge.decode.bytes=0;Ge.encodingLength=function(e){return e==="."||e===".."?1:at.byteLength(e.replace(/^\.|\.$/gm,""))+2};var Nt={};Nt.encode=function(e,t,r){t||(t=at.alloc(Nt.encodingLength(e))),r||(r=0);let n=t.write(e,r+1);return t[r]=n,Nt.encode.bytes=n+1,t};Nt.encode.bytes=0;Nt.decode=function(e,t){t||(t=0);let r=e[t],n=e.toString("utf-8",t+1,t+1+r);return Nt.decode.bytes=r+1,n};Nt.decode.bytes=0;Nt.encodingLength=function(e){return at.byteLength(e)+1};var Ao={};Ao.encode=function(e,t,r){t||(t=Ao.encodingLength(e)),r||(r=0);let n=(e.flags||0)&32767,i=e.type==="response"?L9:YX;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};Ao.encode.bytes=12;Ao.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&L9?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:GX.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:zX.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))}};Ao.decode.bytes=12;Ao.encodingLength=function(){return 12};var Du=ot.unknown={};Du.encode=function(e,t,r){return t||(t=at.alloc(Du.encodingLength(e))),r||(r=0),t.writeUInt16BE(e.length,r),e.copy(t,r+2),Du.encode.bytes=e.length+2,t};Du.encode.bytes=0;Du.decode=function(e,t){t||(t=0);let r=e.readUInt16BE(t),n=e.slice(t+2,t+2+r);return Du.decode.bytes=r+2,n};Du.decode.bytes=0;Du.encodingLength=function(e){return e.length+2};var Fu=ot.ns={};Fu.encode=function(e,t,r){return t||(t=at.alloc(Fu.encodingLength(e))),r||(r=0),Ge.encode(e,t,r+2),t.writeUInt16BE(Ge.encode.bytes,r),Fu.encode.bytes=Ge.encode.bytes+2,t};Fu.encode.bytes=0;Fu.decode=function(e,t){t||(t=0);let r=e.readUInt16BE(t),n=Ge.decode(e,t+2);return Fu.decode.bytes=r+2,n};Fu.decode.bytes=0;Fu.encodingLength=function(e){return Ge.encodingLength(e)+2};var Iu=ot.soa={};Iu.encode=function(e,t,r){t||(t=at.alloc(Iu.encodingLength(e))),r||(r=0);let n=r;return r+=2,Ge.encode(e.mname,t,r),r+=Ge.encode.bytes,Ge.encode(e.rname,t,r,{mail:!0}),r+=Ge.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),Iu.encode.bytes=r-n,t};Iu.encode.bytes=0;Iu.decode=function(e,t){t||(t=0);let r=t,n={};return t+=2,n.mname=Ge.decode(e,t),t+=Ge.decode.bytes,n.rname=Ge.decode(e,t,{mail:!0}),t+=Ge.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,Iu.decode.bytes=t-r,n};Iu.decode.bytes=0;Iu.encodingLength=function(e){return 22+Ge.encodingLength(e.mname)+Ge.encodingLength(e.rname)};var Bu=ot.txt={};Bu.encode=function(e,t,r){Array.isArray(e)||(e=[e]);for(let i=0;i0;){let o=e[t++];if(--n,n0&&(r.timeout=e.readUInt16BE(t),t+=2);break;case 14:r.tags=[];for(let o=0;o0;)n[o++]=ei.decode(e,t),t+=ei.decode.bytes,i-=ei.decode.bytes;return vi.decode.bytes=t-r,n};vi.decode.bytes=0;vi.encodingLength=function(e){return 2+Lh(e||[],ei)};var Rs=ot.dnskey={};Rs.PROTOCOL_DNSSEC=3;Rs.ZONE_KEY=128;Rs.SECURE_ENTRYPOINT=32768;Rs.encode=function(e,t,r){t||(t=at.alloc(Rs.encodingLength(e))),r||(r=0);let n=r,i=e.key;if(!at.isBuffer(i))throw new Error("Key must be a Buffer");return r+=2,t.writeUInt16BE(e.flags,r),r+=2,t.writeUInt8(Rs.PROTOCOL_DNSSEC,r),r+=1,t.writeUInt8(e.algorithm,r),r+=1,i.copy(t,r,0,i.length),r+=i.length,Rs.encode.bytes=r-n,t.writeUInt16BE(Rs.encode.bytes-2,n),t};Rs.encode.bytes=0;Rs.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)!==Rs.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,Rs.decode.bytes=t-r,n};Rs.decode.bytes=0;Rs.encodingLength=function(e){return 6+at.byteLength(e.key)};var wa=ot.rrsig={};wa.encode=function(e,t,r){t||(t=at.alloc(wa.encodingLength(e))),r||(r=0);let n=r,i=e.signature;if(!at.isBuffer(i))throw new Error("Signature must be a Buffer");return r+=2,t.writeUInt16BE(ku.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,Ge.encode(e.signersName,t,r),r+=Ge.encode.bytes,i.copy(t,r,0,i.length),r+=i.length,wa.encode.bytes=r-n,t.writeUInt16BE(wa.encode.bytes-2,n),t};wa.encode.bytes=0;wa.decode=function(e,t){t||(t=0);let r=t;var n={},i=e.readUInt16BE(t);return t+=2,n.typeCovered=ku.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=Ge.decode(e,t),t+=Ge.decode.bytes,n.signature=e.slice(t,r+i+2),t+=n.signature.length,wa.decode.bytes=t-r,n};wa.decode.bytes=0;wa.encodingLength=function(e){return 20+Ge.encodingLength(e.signersName)+at.byteLength(e.signature)};var ya=ot.rp={};ya.encode=function(e,t,r){t||(t=at.alloc(ya.encodingLength(e))),r||(r=0);let n=r;return r+=2,Ge.encode(e.mbox||".",t,r,{mail:!0}),r+=Ge.encode.bytes,Ge.encode(e.txt||".",t,r),r+=Ge.encode.bytes,ya.encode.bytes=r-n,t.writeUInt16BE(ya.encode.bytes-2,n),t};ya.encode.bytes=0;ya.decode=function(e,t){t||(t=0);let r=t,n={};return t+=2,n.mbox=Ge.decode(e,t,{mail:!0})||".",t+=Ge.decode.bytes,n.txt=Ge.decode(e,t)||".",t+=Ge.decode.bytes,ya.decode.bytes=t-r,n};ya.decode.bytes=0;ya.encodingLength=function(e){return 2+Ge.encodingLength(e.mbox||".")+Ge.encodingLength(e.txt||".")};var Fn={};Fn.encode=function(e,t,r){t||(t=at.alloc(Fn.encodingLength(e))),r||(r=0);let n=r;for(var i=[],o=0;o>8]===void 0&&(i[s>>8]=[]),i[s>>8][s>>3&31]|=1<<7-(s&7)}for(o=0;o>8]=Math.max(t[n>>8]||0,n&255)}var i=0;for(r=0;r>15&1)===1,r.options=vi.decode(e,t+8),t+=8+vi.decode.bytes;else{let i=e.readUInt16BE(t+2);r.ttl=e.readUInt32BE(t+4),r.class=S2.toString(i&WX),r.flush=!!(i&mS);let o=gS(r.type);r.data=o.decode(e,t+8),t+=8+o.decode.bytes}return qn.decode.bytes=t-n,r};qn.decode.bytes=0;qn.encodingLength=function(e){let t=e.data!==null&&e.data!==void 0?e.data:e.options;return Ge.encodingLength(e.name)+8+gS(e.type).encodingLength(t)};var bo=ot.question={};bo.encode=function(e,t,r){t||(t=at.alloc(bo.encodingLength(e))),r||(r=0);let n=r;return Ge.encode(e.name,t,r),r+=Ge.encode.bytes,t.writeUInt16BE(ku.toType(e.type),r),r+=2,t.writeUInt16BE(S2.toClass(e.class===void 0?"IN":e.class),r),r+=2,bo.encode.bytes=r-n,e};bo.encode.bytes=0;bo.decode=function(e,t){t||(t=0);let r=t,n={};return n.name=Ge.decode(e,t),t+=Ge.decode.bytes,n.type=ku.toString(e.readUInt16BE(t)),t+=2,n.class=S2.toString(e.readUInt16BE(t)),t+=2,!!(n.class&U9)&&(n.class&=XX),bo.decode.bytes=t-r,n};bo.decode.bytes=0;bo.encodingLength=function(e){return Ge.encodingLength(e.name)+4};ot.AUTHORITATIVE_ANSWER=1024;ot.TRUNCATED_RESPONSE=512;ot.RECURSION_DESIRED=256;ot.RECURSION_AVAILABLE=128;ot.AUTHENTIC_DATA=32;ot.CHECKING_DISABLED=16;ot.DNSSEC_OK=32768;ot.encode=function(e,t,r){let n=!t;n&&(t=at.alloc(ot.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=[]),Ao.encode(e,t,r),r+=Ao.encode.bytes,r=u0(e.questions,bo,t,r),r=u0(e.answers,qn,t,r),r=u0(e.authorities,qn,t,r),r=u0(e.additionals,qn,t,r),ot.encode.bytes=r-i,n&&ot.encode.bytes!==t.length?t.slice(0,ot.encode.bytes):t};ot.encode.bytes=0;ot.decode=function(e,t){t||(t=0);let r=t,n=Ao.decode(e,t);return t+=Ao.decode.bytes,t=A2(n.questions,bo,e,t),t=A2(n.answers,qn,e,t),t=A2(n.authorities,qn,e,t),t=A2(n.additionals,qn,e,t),ot.decode.bytes=t-r,n};ot.decode.bytes=0;ot.encodingLength=function(e){return Ao.encodingLength(e)+Lh(e.questions||[],bo)+Lh(e.answers||[],qn)+Lh(e.authorities||[],qn)+Lh(e.additionals||[],qn)};ot.streamEncode=function(e){let t=ot.encode(e),r=at.alloc(2);r.writeUInt16BE(t.byteLength);let n=at.concat([r,t]);return ot.streamEncode.bytes=n.byteLength,n};ot.streamEncode.bytes=0;ot.streamDecode=function(e){let t=e.readUInt16BE(0);if(e.byteLength{"use strict";var ibe=B(T()),HQ=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])},WS=class e extends Error{constructor(t,r,n){super(t),HQ(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:o,text:s})=>({source:o,text:s.split(/\r\n|\n|\r/g)}));function n(o,s,a=""){let u="",l=r.find(({source:m})=>m===o.source),f=o.start;if(l){let m=o.end,p=l.text[f.line-1],v=(f.line===m.line?m.column:p.length+1)-f.column||1;a&&(u+=` note: ${a}`),u+=` --> ${o.source}:${f.line}:${f.column} ${"".padEnd(s)} | ${f.line.toString().padStart(s)} | ${p} ${"".padEnd(s)} | ${"".padEnd(f.column-1)}${"".padEnd(v,"^")}`}else u+=` at ${o.source}:${f.line}:${f.column}`,a&&(u+=`: ${a}`);return u}function i(o,s,a,u=[]){let l;a?l=u.reduce((m,{location:p})=>Math.max(m,p.start.line),a.start.line):l=Math.max.apply(null,u.map(m=>m.location.start.line)),l=l.toString().length;let f=`${o}: ${s}`;a&&(f+=n(a,l));for(let m of u)f+=n(m.location,l,m.message);return f}return this.problems.filter(o=>o[0]!=="info").map(o=>i(...o)).join(` `)}};z7.exports=WS});var ji=Ce((obe,G7)=>{"use strict";var abe=B(T()),MQ={build(e){function t(s,...a){return e[s.type](s,...a)}function r(){}function n(s,...a){return t(s.expression,...a)}function i(s){return function(a,...u){a[s].forEach(l=>t(l,...u))}}let o={grammar(s,...a){s.topLevelInitializer&&t(s.topLevelInitializer,...a),s.initializer&&t(s.initializer,...a),s.rules.forEach(u=>t(u,...a))},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(o).forEach(s=>{Object.prototype.hasOwnProperty.call(e,s)||(e[s]=o[s])}),t}};G7.exports=MQ});var qc=Ce((ube,W7)=>{"use strict";var cbe=B(T()),qQ=ji(),Y7={findRule(e,t){for(let r=0;r{"use strict";var fbe=B(T()),jQ={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};X7.exports=jQ});var JS=Ce((hbe,J7)=>{"use strict";var dbe=B(T()),KQ=ji(),VQ=qc(),zQ=z2(),C0=1,ff=0,_0=-1;function G2(e){function t(s){return s.match=ff}function r(s){return o(s.expression),s.match=C0}function n(s){return s.match=o(s.expression)}function i(s,a){let u=s.length,l=0,f=0;for(let m=0;m0?_0:ff}let o=KQ.build({rule(s){let a,u=0;if(typeof s.match>"u"){s.match=ff;do if(a=s.match,s.match=o(s.expression),++u>6)throw new zQ("Infinity cycle detected when trying to evaluate node match result",s.location);while(a!==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=-o(s.expression)},optional:r,zero_or_more:r,one_or_more:n,group:n,semantic_and:t,semantic_not:t,rule_ref(s){let a=VQ.findRule(e,s.name);return s.match=o(a)},literal(s){let a=s.value.length===0?C0:ff;return s.match=a},class(s){let a=s.parts.length===0?_0:ff;return s.match=a},any:t});o(e)}G2.ALWAYS_MATCH=C0;G2.SOMETIMES_MATCH=ff;G2.NEVER_MATCH=_0;J7.exports=G2});var Q7=Ce((pbe,Z7)=>{"use strict";var mbe=B(T()),GQ=qc(),Ye=XS(),YQ=ji(),{ALWAYS_MATCH:Xh,SOMETIMES_MATCH:ZS,NEVER_MATCH:QS}=JS();function WQ(e){let t=[],r=[],n=[],i=[];function o(E){let S=t.indexOf(E);return S===-1?t.push(E)-1:S}function s(E){let S={value:E.parts,inverted:E.inverted,ignoreCase:E.ignoreCase},D=JSON.stringify(S),F=r.findIndex(M=>JSON.stringify(M)===D);return F===-1?r.push(S)-1:F}function a(E){let S=JSON.stringify(E),D=n.findIndex(F=>JSON.stringify(F)===S);return D===-1?n.push(E)-1:D}function u(E,S,D){let F={predicate:E,params:S,body:D.code,location:D.codeLocation},M=JSON.stringify(F),z=i.findIndex(C=>JSON.stringify(C)===M);return z===-1?i.push(F)-1:z}function l(E){let S={};return Object.keys(E).forEach(D=>{S[D]=E[D]}),S}function f(E,...S){return E.concat(...S)}function m(E,S,D,F){return E===Xh?D:E===QS?F:S.concat([D.length,F.length],D,F)}function p(E,S){return E.concat([S.length],S)}function d(E,S,D,F){let M=Object.keys(D).map(z=>F-D[z]);return[Ye.CALL,E,S,M.length].concat(M)}function v(E,S,D){let F=E.match|0;return f([Ye.PUSH_CURR_POS],[Ye.SILENT_FAILS_ON],w(E,{sp:D.sp+1,env:l(D.env),action:null}),[Ye.SILENT_FAILS_OFF],m(S?-F:F,[S?Ye.IF_ERROR:Ye.IF_NOT_ERROR],f([Ye.POP],[S?Ye.POP:Ye.POP_CURR_POS],[Ye.PUSH_UNDEFINED]),f([Ye.POP],[S?Ye.POP_CURR_POS:Ye.POP],[Ye.PUSH_FAILED])))}function g(E,S,D){let F=u(!0,Object.keys(D.env),E);return f([Ye.UPDATE_SAVED_POS],d(F,0,D.env,D.sp),m(E.match|0,[Ye.IF],f([Ye.POP],S?[Ye.PUSH_FAILED]:[Ye.PUSH_UNDEFINED]),f([Ye.POP],S?[Ye.PUSH_UNDEFINED]:[Ye.PUSH_FAILED])))}function y(E){return p([Ye.WHILE_NOT_ERROR],f([Ye.APPEND],E))}let w=YQ.build({grammar(E){E.rules.forEach(w),E.literals=t,E.classes=r,E.expectations=n,E.functions=i},rule(E){E.bytecode=w(E.expression,{sp:-1,env:{},pluck:[],action:null})},named(E,S){let D=E.match|0,F=D===QS?null:a({type:"rule",value:E.name});return f([Ye.SILENT_FAILS_ON],w(E.expression,S),[Ye.SILENT_FAILS_OFF],m(D,[Ye.IF_ERROR],[Ye.FAIL,F],[]))},choice(E,S){function D(F,M){let z=F[0].match|0,C=w(F[0],{sp:M.sp,env:l(M.env),action:null});return z===Xh?C:f(C,F.length>1?m(ZS,[Ye.IF_ERROR],f([Ye.POP],D(F.slice(1),M)),[]):[])}return D(E.alternatives,S)},action(E,S){let D=l(S.env),F=E.expression.type!=="sequence"||E.expression.elements.length===0,M=w(E.expression,{sp:S.sp+(F?1:0),env:D,action:E}),z=E.expression.match|0,C=F&&z!==QS?u(!1,Object.keys(D),E):null;return F?f([Ye.PUSH_CURR_POS],M,m(z,[Ye.IF_NOT_ERROR],f([Ye.LOAD_SAVED_POS,1],d(C,1,D,S.sp+2)),[]),[Ye.NIP]):M},sequence(E,S){function D(F,M){if(F.length>0){let z=E.elements.length-F.length+1;return f(w(F[0],{sp:M.sp,env:M.env,pluck:M.pluck,action:null}),m(F[0].match|0,[Ye.IF_NOT_ERROR],D(F.slice(1),{sp:M.sp+1,env:M.env,pluck:M.pluck,action:M.action}),f(z>1?[Ye.POP_N,z]:[Ye.POP],[Ye.POP_CURR_POS],[Ye.PUSH_FAILED])))}else{if(M.pluck.length>0)return f([Ye.PLUCK,E.elements.length+1,M.pluck.length],M.pluck.map(z=>M.sp-z));if(M.action){let z=u(!1,Object.keys(M.env),M.action);return f([Ye.LOAD_SAVED_POS,E.elements.length],d(z,E.elements.length+1,M.env,M.sp))}else return f([Ye.WRAP,E.elements.length],[Ye.NIP])}}return f([Ye.PUSH_CURR_POS],D(E.elements,{sp:S.sp+1,env:S.env,pluck:[],action:S.action}))},labeled(E,S){let D=S.env,F=E.label,M=S.sp+1;return F&&(D=l(S.env),S.env[E.label]=M),E.pick&&S.pluck.push(M),w(E.expression,{sp:S.sp,env:D,action:null})},text(E,S){return f([Ye.PUSH_CURR_POS],w(E.expression,{sp:S.sp+1,env:l(S.env),action:null}),m(E.match|0,[Ye.IF_NOT_ERROR],f([Ye.POP],[Ye.TEXT]),[Ye.NIP]))},simple_and(E,S){return v(E.expression,!1,S)},simple_not(E,S){return v(E.expression,!0,S)},optional(E,S){return f(w(E.expression,{sp:S.sp,env:l(S.env),action:null}),m(-(E.expression.match|0),[Ye.IF_ERROR],f([Ye.POP],[Ye.PUSH_NULL]),[]))},zero_or_more(E,S){let D=w(E.expression,{sp:S.sp+1,env:l(S.env),action:null});return f([Ye.PUSH_EMPTY_ARRAY],D,y(D),[Ye.POP])},one_or_more(E,S){let D=w(E.expression,{sp:S.sp+1,env:l(S.env),action:null});return f([Ye.PUSH_EMPTY_ARRAY],D,m(E.expression.match|0,[Ye.IF_NOT_ERROR],f(y(D),[Ye.POP]),f([Ye.POP],[Ye.POP],[Ye.PUSH_FAILED])))},group(E,S){return w(E.expression,{sp:S.sp,env:l(S.env),action:null})},semantic_and(E,S){return g(E,!1,S)},semantic_not(E,S){return g(E,!0,S)},rule_ref(E){return[Ye.RULE,GQ.indexOfRule(e,E.name)]},literal(E){if(E.value.length>0){let S=E.match|0,F=S===ZS||S===Xh&&!E.ignoreCase?o(E.ignoreCase?E.value.toLowerCase():E.value):null,M=S!==Xh?a({type:"literal",value:E.value,ignoreCase:E.ignoreCase}):null;return m(S,E.ignoreCase?[Ye.MATCH_STRING_IC,F]:[Ye.MATCH_STRING,F],E.ignoreCase?[Ye.ACCEPT_N,E.value.length]:[Ye.ACCEPT_STRING,F],[Ye.FAIL,M])}return[Ye.PUSH_EMPTY_STRING]},class(E){let S=E.match|0,D=S===ZS?s(E):null,F=S!==Xh?a({type:"class",value:E.parts,inverted:E.inverted,ignoreCase:E.ignoreCase}):null;return m(S,[Ye.MATCH_CHAR_CLASS,D],[Ye.ACCEPT_N,1],[Ye.FAIL,F])},any(E){let S=E.match|0,D=S!==Xh?a({type:"any"}):null;return m(S,[Ye.MATCH_ANY],[Ye.ACCEPT_N,1],[Ye.FAIL,D])}});w(e)}Z7.exports=WQ});var t$=Ce((gbe,e$)=>{"use strict";var vbe=B(T()),e6=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 o=this.sp;if(this.sp=i,n(),o!==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: "+o+", 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+").")}};e$.exports=e6});var t6=Ce((wbe,r$)=>{"use strict";var ybe=B(T());r$.exports="2.0.1"});var n$=Ce(Y2=>{"use strict";var bbe=B(T());function Hu(e){return e.charCodeAt(0).toString(16).toUpperCase()}Y2.hex=Hu;function XQ(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"+Hu(t)).replace(/[\x10-\x1F\x7F-\xFF]/g,t=>"\\x"+Hu(t)).replace(/[\u0100-\u0FFF]/g,t=>"\\u0"+Hu(t)).replace(/[\u1000-\uFFFF]/g,t=>"\\u"+Hu(t))}Y2.stringEscape=XQ;function JQ(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"+Hu(t)).replace(/[\x10-\x1F\x7F-\xFF]/g,t=>"\\x"+Hu(t)).replace(/[\u0100-\u0FFF]/g,t=>"\\u0"+Hu(t)).replace(/[\u1000-\uFFFF]/g,t=>"\\u"+Hu(t))}Y2.regexpClassEscape=JQ});var o$=Ce(i$=>{var Sbe=B(T()),s$="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");i$.encode=function(e){if(0<=e&&e{var _be=B(T()),ZQ=o$(),a$=5,u$=1<>>=a$,i>0&&(n|=eee),r+=ZQ.encode(n);while(i>0);return r}});var X2=Ce(Kc=>{var Fbe=B(T());function ree(e,t,r){if(t in e)return e[t];if(arguments.length===3)return r;throw new Error('"'+t+'" is a required argument.')}Kc.getArg=ree;var h$=function(){return!("__proto__"in Object.create(null))}();function d$(e){return e}function nee(e){return p$(e)?"$"+e:e}Kc.toSetString=h$?d$:nee;function see(e){return p$(e)?e.slice(1):e}Kc.fromSetString=h$?d$:see;function p$(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 f$(e,t){return e===t?0:e===null?1:t===null?-1:e>t?1:-1}function iee(e,t){let r=e.generatedLine-t.generatedLine;return r!==0||(r=e.generatedColumn-t.generatedColumn,r!==0)||(r=f$(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:f$(e.name,t.name)}Kc.compareByGeneratedPositionsInflated=iee;var r6="http:",D0=`${r6}//host`;function m$(e){return t=>{let r=F0(t),n=n6(t),i=new URL(t,n);e(i);let o=i.toString();return r==="absolute"?o:r==="scheme-relative"?o.slice(r6.length):r==="path-absolute"?o.slice(D0.length):s6(n,o)}}function jc(e,t){return new URL(e,t).toString()}function oee(e,t){let r=0;do{let n=e+r++;if(t.indexOf(n)===-1)return n}while(!0)}function n6(e){let t=e.split("..").length-1,r=oee("p",e),n=`${D0}/`;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 uee=m$(e=>{e.pathname=e.pathname.replace(/\/?$/,"/")}),W2=m$(e=>{});Kc.normalize=W2;function cee(e,t){let r=F0(t),n=F0(e);if(e=uee(e),r==="absolute")return jc(t,void 0);if(n==="absolute")return jc(t,e);if(r==="scheme-relative")return W2(t);if(n==="scheme-relative")return jc(t,jc(e,D0)).slice(r6.length);if(r==="path-absolute")return W2(t);if(n==="path-absolute")return jc(t,jc(e,D0)).slice(D0.length);let i=n6(t+e),o=jc(t,jc(e,i));return s6(i,o)}Kc.join=cee;function lee(e,t){let r=fee(e,t);return typeof r=="string"?r:W2(t)}Kc.relative=lee;function fee(e,t){if(F0(e)!==F0(t))return null;let n=n6(e+t),i=new URL(e,n),o=new URL(t,n);try{new URL("",o.toString())}catch{return null}return o.protocol!==i.protocol||o.user!==i.user||o.password!==i.password||o.hostname!==i.hostname||o.port!==i.port?null:s6(i,o)}});var v$=Ce(g$=>{var Bbe=B(T()),i6=class e{constructor(){this._array=[],this._set=new Map}static fromArray(t,r){let n=new e;for(let i=0,o=t.length;i=0)return r;throw new Error('"'+t+'" is not in the set.')}at(t){if(t>=0&&t{var Tbe=B(T()),w$=X2();function hee(e,t){let r=e.generatedLine,n=t.generatedLine,i=e.generatedColumn,o=t.generatedColumn;return n>r||n==r&&o>=i||w$.compareByGeneratedPositionsInflated(e,t)<=0}var o6=class{constructor(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}unsortedForEach(t,r){this._array.forEach(t,r)}add(t){hee(this._last,t)?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))}toArray(){return this._sorted||(this._array.sort(w$.compareByGeneratedPositionsInflated),this._sorted=!0),this._array}};y$.MappingList=o6});var a6=Ce(b$=>{var xbe=B(T()),I0=l$(),sn=X2(),J2=v$().ArraySet,dee=E$().MappingList,Z2=class e{constructor(t){t||(t={}),this._file=sn.getArg(t,"file",null),this._sourceRoot=sn.getArg(t,"sourceRoot",null),this._skipValidation=sn.getArg(t,"skipValidation",!1),this._sources=new J2,this._names=new J2,this._mappings=new dee,this._sourcesContents=null}static fromSourceMap(t){let r=t.sourceRoot,n=new e({file:t.file,sourceRoot:r});return t.eachMapping(function(i){let o={generated:{line:i.generatedLine,column:i.generatedColumn}};i.source!=null&&(o.source=i.source,r!=null&&(o.source=sn.relative(r,o.source)),o.original={line:i.originalLine,column:i.originalColumn},i.name!=null&&(o.name=i.name)),n.addMapping(o)}),t.sources.forEach(function(i){let o=i;r!=null&&(o=sn.relative(r,i)),n._sources.has(o)||n._sources.add(o);let s=t.sourceContentFor(i);s!=null&&n.setSourceContent(i,s)}),n}addMapping(t){let r=sn.getArg(t,"generated"),n=sn.getArg(t,"original",null),i=sn.getArg(t,"source",null),o=sn.getArg(t,"name",null);this._skipValidation||this._validateMapping(r,n,i,o),i!=null&&(i=String(i),this._sources.has(i)||this._sources.add(i)),o!=null&&(o=String(o),this._names.has(o)||this._names.add(o)),this._mappings.add({generatedLine:r.line,generatedColumn:r.column,originalLine:n&&n.line,originalColumn:n&&n.column,source:i,name:o})}setSourceContent(t,r){let n=t;this._sourceRoot!=null&&(n=sn.relative(this._sourceRoot,n)),r!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[sn.toSetString(n)]=r):this._sourcesContents&&(delete this._sourcesContents[sn.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 o=this._sourceRoot;o!=null&&(i=sn.relative(o,i));let s=this._mappings.toArray().length>0?new J2:this._sources,a=new J2;this._mappings.unsortedForEach(function(u){if(u.source===i&&u.originalLine!=null){let m=t.originalPositionFor({line:u.originalLine,column:u.originalColumn});m.source!=null&&(u.source=m.source,n!=null&&(u.source=sn.join(n,u.source)),o!=null&&(u.source=sn.relative(o,u.source)),u.originalLine=m.line,u.originalColumn=m.column,m.name!=null&&(u.name=m.name))}let l=u.source;l!=null&&!s.has(l)&&s.add(l);let f=u.name;f!=null&&!a.has(f)&&a.add(f)},this),this._sources=s,this._names=a,t.sources.forEach(function(u){let l=t.sourceContentFor(u);l!=null&&(n!=null&&(u=sn.join(n,u)),o!=null&&(u=sn.relative(o,u)),this.setSourceContent(u,l))},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,o=0,s=0,a="",u,l,f,m,p=this._mappings.toArray();for(let d=0,v=p.length;d0){if(!sn.compareByGeneratedPositionsInflated(l,p[d-1]))continue;u+=","}u+=I0.encode(l.generatedColumn-t),t=l.generatedColumn,l.source!=null&&(m=this._sources.indexOf(l.source),u+=I0.encode(m-s),s=m,u+=I0.encode(l.originalLine-1-i),i=l.originalLine-1,u+=I0.encode(l.originalColumn-n),n=l.originalColumn,l.name!=null&&(f=this._names.indexOf(l.name),u+=I0.encode(f-o),o=f)),a+=u}return a}_generateSourcesContent(t,r){return t.map(function(n){if(!this._sourcesContents)return null;r!=null&&(n=sn.relative(r,n));let i=sn.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())}};Z2.prototype._version=3;b$.SourceMapGenerator=Z2});var S$=Ce(A$=>{var kbe=B(T()),pee=a6().SourceMapGenerator,Q2=X2(),mee=/(\r?\n)/,gee=10,Jh="$$$isSourceNode$$$",u6=class e{constructor(t,r,n,i,o){this.children=[],this.sourceContents={},this.line=t??null,this.column=r??null,this.source=n??null,this.name=o??null,this[Jh]=!0,i!=null&&this.add(i)}static fromStringWithSourceMap(t,r,n){let i=new e,o=t.split(mee),s=0,a=function(){let d=g(),v=g()||"";return d+v;function g(){return s=0;r--)this.prepend(t[r]);else if(t[Jh]||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{var Nbe=B(T());c6.SourceMapGenerator=a6().SourceMapGenerator;c6.SourceNode=S$().SourceNode});var I$=Ce((Lbe,F$)=>{"use strict";var Ube=B(T()),vee=qc(),ir=XS(),wee=t$(),yee=t6(),{stringEscape:Ei,regexpClassEscape:l6}=n$(),{SourceNode:Ki}=C$();function D$(e,t,r){let n=t.start.line,i=t.start.column-1,o=e.split(` `);return o.length===1?new Ki(n,i,t.source,e,r):new Ki(null,null,t.source,o.map((s,a)=>new Ki(n+a,a===0?i:0,t.source,a===o.length-1?s:[s,` `],r)))}function _$(e,t,r,n,i){return r?new Ki(null,null,r.source,[e,D$(t,r,i),new Ki(r.end.line,r.end.column-1,r.source,n)]):new Ki(null,null,null,[e,t,n])}function Eee(e,t){function r(g){return g instanceof Ki?g:g.replace(/^(.+)$/gm," $1")}function n(g){return"peg$c"+g}function i(g){return"peg$r"+g}function o(g){return"peg$e"+g}function s(g){return"peg$f"+g}function a(g){return"peg$parse"+g}function u(){function g(S){return'"'+Ei(S)+'"'}function y(S){return"/^["+(S.inverted?"^":"")+S.value.map(D=>Array.isArray(D)?l6(D[0])+"-"+l6(D[1]):l6(D)).join("")+"]/"+(S.ignoreCase?"i":"")}function w(S){switch(S.type){case"rule":return'peg$otherExpectation("'+Ei(S.value)+'")';case"literal":return'peg$literalExpectation("'+Ei(S.value)+'", '+S.ignoreCase+")";case"class":return"peg$classExpectation(["+S.value.map(F=>Array.isArray(F)?'["'+Ei(F[0])+'", "'+Ei(F[1])+'"]':'"'+Ei(F)+'"').join(", ")+"], "+S.inverted+", "+S.ignoreCase+")";case"any":return"peg$anyExpectation()";default:throw new Error("Unknown expectation type ("+JSON.stringify(S)+")")}}function E(S,D){return _$(` var ${s(D)} = function(${S.params.join(", ")}) {`,S.body,S.location,"};")}return new Ki(null,null,t.grammarSource,[e.literals.map((S,D)=>" var "+n(D)+" = "+g(S)+";").concat("",e.classes.map((S,D)=>" var "+i(D)+" = "+y(S)+";")).concat("",e.expectations.map((S,D)=>" var "+o(D)+" = "+w(S)+";")).concat("").join(` `),e.functions.map(E)])}function l(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 f(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 m(g){let y=[],w=new wee(g.name,"s","var");function E(D){let F=0,M=D.length,z=[],C;function P(O,q){let N=q+3,_=D[F+N-2],R=D[F+N-1],K,Z;w.checkedIf(F,()=>{F+=N,K=E(D.slice(F,F+_)),F+=_},R>0?()=>{Z=E(D.slice(F,F+R)),F+=R}:null),z.push("if ("+O+") {"),z.push(...K.map(r)),R>0&&(z.push("} else {"),z.push(...Z.map(r))),z.push("}")}function U(O){let N=D[F+2-1],_;w.checkedLoop(F,()=>{F+=2,_=E(D.slice(F,F+N)),F+=N}),z.push("while ("+O+") {"),z.push(..._.map(r)),z.push("}")}function k(){let q=D[F+4-1],N=s(D[F+1])+"("+D.slice(F+4,F+4+q).map(_=>w.index(_)).join(", ")+")";w.pop(D[F+2]),z.push(w.push(N)),F+=4+q}for(;Fw.index(_)).join(", ")} ]`,w.pop(D[F+1]),z.push(w.push(C)),F+=N;break}case ir.IF:P(w.top(),0);break;case ir.IF_ERROR:P(w.top()+" === peg$FAILED",0);break;case ir.IF_NOT_ERROR:P(w.top()+" !== peg$FAILED",0);break;case ir.WHILE_NOT_ERROR:U(w.top()+" !== peg$FAILED");break;case ir.MATCH_ANY:P("input.length > peg$currPos",0);break;case ir.MATCH_STRING:P(e.literals[D[F+1]].length>1?"input.substr(peg$currPos, "+e.literals[D[F+1]].length+") === "+n(D[F+1]):"input.charCodeAt(peg$currPos) === "+e.literals[D[F+1]].charCodeAt(0),1);break;case ir.MATCH_STRING_IC:P("input.substr(peg$currPos, "+e.literals[D[F+1]].length+").toLowerCase() === "+n(D[F+1]),1);break;case ir.MATCH_CHAR_CLASS:P(i(D[F+1])+".test(input.charAt(peg$currPos))",1);break;case ir.ACCEPT_N:z.push(w.push(D[F+1]>1?"input.substr(peg$currPos, "+D[F+1]+")":"input.charAt(peg$currPos)")),z.push(D[F+1]>1?"peg$currPos += "+D[F+1]+";":"peg$currPos++;"),F+=2;break;case ir.ACCEPT_STRING:z.push(w.push(n(D[F+1]))),z.push(e.literals[D[F+1]].length>1?"peg$currPos += "+e.literals[D[F+1]].length+";":"peg$currPos++;"),F+=2;break;case ir.FAIL:z.push(w.push("peg$FAILED")),z.push("if (peg$silentFails === 0) { peg$fail("+o(D[F+1])+"); }"),F+=2;break;case ir.LOAD_SAVED_POS:z.push("peg$savedPos = "+w.index(D[F+1])+";"),F+=2;break;case ir.UPDATE_SAVED_POS:z.push("peg$savedPos = peg$currPos;"),F++;break;case ir.CALL:k();break;case ir.RULE:z.push(w.push(a(e.rules[D[F+1]].name)+"()")),F+=2;break;case ir.SILENT_FAILS_ON:z.push("peg$silentFails++;"),F++;break;case ir.SILENT_FAILS_OFF:z.push("peg$silentFails--;"),F++;break;default:throw new Error("Invalid opcode: "+D[F]+".")}return z}let S=E(g.bytecode);return y.push(_$(" function ",a(g.name),g.nameLocation,`() { `,g.name)),t.trace&&y.push(" var startPos = peg$currPos;"),y.push(r(w.defines())),y.push(...l('"'+Ei(g.name)+'"',vee.indexOfRule(e,g.name)).map(r)),y.push(...S.map(r)),y.push(...f('"'+Ei(g.name)+'"',w.result()).map(r)),y.push("}"),y}function p(g){return g.codeLocation?D$(g.code,g.codeLocation,"$"+g.type):g.code}function d(){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(E=>E+": "+a(E)).join(", ")+" }",w=a(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+";","",u(),""," 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(E=>{g.push(...m(E).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 Ki(null,null,t.grammarSource,g.map(E=>E instanceof Ki?E:E+` `))}function v(g){function y(){return[`// Generated by Peggy ${yee}.`,"//","// 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 S={bare(){return[...y(),"(function() {",' "use strict";',"",g,"",r("return "+w()+";"),"})()"]},commonjs(){let D=Object.keys(t.dependencies),F=y();return F.push("",'"use strict";',""),D.length>0&&(D.forEach(M=>{F.push("var "+M+' = require("'+Ei(t.dependencies[M])+'");')}),F.push("")),F.push(g,"","module.exports = "+w()+";"),F},es(){let D=Object.keys(t.dependencies),F=y();return F.push(""),D.length>0&&(D.forEach(M=>{F.push("import "+M+' from "'+Ei(t.dependencies[M])+'";')}),F.push("")),F.push(g,"","export {"," peg$SyntaxError as SyntaxError,",t.trace?" peg$DefaultTracer as DefaultTracer,":""," peg$parse as parse","};"),F},amd(){let D=Object.keys(t.dependencies),M="["+D.map(C=>t.dependencies[C]).map(C=>'"'+Ei(C)+'"').join(", ")+"]",z=D.join(", ");return[...y(),"define("+M+", function("+z+") {",' "use strict";',"",g,"",r("return "+w()+";"),"});"]},globals(){return[...y(),"(function(root) {",' "use strict";',"",g,"",r("root."+t.exportVar+" = "+w()+";"),"})(this);"]},umd(){let D=Object.keys(t.dependencies),F=D.map(U=>t.dependencies[U]),M="["+F.map(U=>'"'+Ei(U)+'"').join(", ")+"]",z=F.map(U=>'require("'+Ei(U)+'")').join(", "),C=D.join(", "),P=y();return P.push("(function(root, factory) {",' if (typeof define === "function" && define.amd) {'," define("+M+", 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("+C+") {",' "use strict";',"",g,"",r("return "+w()+";"),"});"),P}}[t.format]();return new Ki(null,null,t.grammarSource,S.map(D=>D instanceof Ki?D:D+` `))}e.code=v(d())}F$.exports=Eee});var $$=Ce((Hbe,B$)=>{"use strict";var Mbe=B(T()),bee=qc(),Aee=ji();function See(e,t,r){function n(s){return s.type==="rule"&&s.expression.type==="rule_ref"}function i(s,a,u){Aee.build({rule_ref(f){f.name===a&&(f.name=u,r.info(`Proxy rule "${a}" replaced by the rule "${u}"`,f.location,[{message:"This rule will be used",location:bee.findRule(s,u).nameLocation}]))}})(s)}let o=[];e.rules.forEach((s,a)=>{n(s)&&(i(e,s.name,s.expression.name),t.allowedStartRules.indexOf(s.name)===-1&&o.push(a))}),o.reverse(),o.forEach(s=>{e.rules.splice(s,1)})}B$.exports=See});var P$=Ce((qbe,T$)=>{"use strict";var jbe=B(T()),Cee=ji();function _ee(e,t,r){function n(s){let a={};return Object.keys(s).forEach(u=>{a[u]=s[u]}),a}function i(s,a){o(s.expression,n(a))}let o=Cee.build({rule(s){o(s.expression,{})},choice(s,a){s.alternatives.forEach(u=>{o(u,n(a))})},action:i,labeled(s,a){let u=s.label;u&&Object.prototype.hasOwnProperty.call(a,u)&&r.error(`Label "${s.label}" is already defined`,s.labelLocation,[{message:"Original label location",location:a[u]}]),o(s.expression,a),a[s.label]=s.labelLocation},text:i,simple_and:i,simple_not:i,optional:i,zero_or_more:i,one_or_more:i,group:i});o(e)}T$.exports=_ee});var R$=Ce((Kbe,x$)=>{"use strict";var Vbe=B(T()),Dee=ji();function Fee(e,t,r){let n={};Dee.build({rule(o){if(Object.prototype.hasOwnProperty.call(n,o.name)){r.error(`Rule "${o.name}" is already defined`,o.nameLocation,[{message:"Original rule location",location:n[o.name]}]);return}n[o.name]=o.nameLocation}})(e)}x$.exports=Fee});var N$=Ce((zbe,O$)=>{"use strict";var Gbe=B(T()),k$=qc(),Iee=ji();function Bee(e,t,r){let n=[],i=[],o=Iee.build({rule(s){n.push(s.name),o(s.expression),n.pop()},sequence(s){s.elements.every(a=>(o(a),!k$.alwaysConsumesOnSuccess(e,a)))},rule_ref(s){i.push(s);let a=k$.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(" -> ")+")",a.nameLocation,i.map((u,l,f)=>({message:l+1!==f.length?`Step ${l+1}: call of the rule "${u.name}" without input consumption`:`Step ${l+1}: call itself without input consumption - left recursion`,location:u.location})));return}a&&o(a),i.pop()}});o(e)}O$.exports=Bee});var H$=Ce((Ybe,U$)=>{"use strict";var Wbe=B(T()),L$=qc(),$ee=ji();function Tee(e,t,r){$ee.build({zero_or_more(i){L$.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){L$.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)}U$.exports=Tee});var q$=Ce((Xbe,M$)=>{"use strict";var Jbe=B(T()),Pee=qc(),xee=ji();function Ree(e,t,r){xee.build({rule_ref(i){Pee.findRule(e,i.name)||r.error(`Rule "${i.name}" is not defined`,i.location)}})(e)}M$.exports=Ree});var K$=Ce((Zbe,j$)=>{"use strict";var Qbe=B(T()),kee=ji();function Oee(e,t,r){let n=kee.build({action(i){n(i.expression,i)},labeled(i,o){i.pick&&o&&r.error('"@" cannot be used with an action block',i.labelLocation,[{message:"Action block location",location:o.codeLocation}]),n(i.expression)}});n(e)}j$.exports=Oee});var z$=Ce((eAe,V$)=>{"use strict";var tAe=B(T()),Nee=z2(),f6=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(){}},h6=class{constructor(t){this._callbacks=new f6(t),this._firstError=null,this.errors=0,this.problems=[],this.stage=null}error(...t){++this.errors,this._firstError===null&&(this._firstError=new Nee(...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}};V$.exports=h6});var G$=Ce((exports,module)=>{"use strict";var rAe=B(T()),generateBytecode=Q7(),generateJS=I$(),inferenceMatchResult=JS(),removeProxyRules=$$(),reportDuplicateLabels=P$(),reportDuplicateRules=R$(),reportInfiniteRecursion=N$(),reportInfiniteRepetition=H$(),reportUndefinedRules=q$(),reportIncorrectPlucking=K$(),Session=z$(),visitor=ji();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 W$=Ce((nAe,Y$)=>{"use strict";var sAe=B(T()),Lee={$:"text","&":"simple_and","!":"simple_not"},Uee={"?":"optional","*":"zero_or_more","+":"one_or_more"},Hee={"&":"semantic_and","!":"semantic_not"};function Mee(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}function Vc(e,t,r,n){var i=Error.call(this,e);return Object.setPrototypeOf&&Object.setPrototypeOf(i,Vc.prototype),i.expected=t,i.found=r,i.location=n,i.name="SyntaxError",i}Mee(Vc,Error);function d6(e,t,r){return r=r||" ",e.length>t?e:(t-=e.length,r+=r.repeat(t),e+r.slice(0,t))}Vc.prototype.format=function(e){var t="Error: "+this.message;if(this.location){var r=null,n;for(n=0;n `+o+` `+a+` | `+i.line+" | "+u+` `+a+" | "+d6("",i.column-1," ")+d6("",f,"^")}else t+=` at `+o}return t};Vc.buildMessage=function(e,t){var r={literal:function(l){return'"'+i(l.text)+'"'},class:function(l){var f=l.parts.map(function(m){return Array.isArray(m)?o(m[0])+"-"+o(m[1]):o(m)});return"["+(l.inverted?"^":"")+f.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(l){return l.description}};function n(l){return l.charCodeAt(0).toString(16).toUpperCase()}function i(l){return l.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(f){return"\\x0"+n(f)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(f){return"\\x"+n(f)})}function o(l){return l.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(f){return"\\x0"+n(f)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(f){return"\\x"+n(f)})}function s(l){return r[l.type](l)}function a(l){var f=l.map(s),m,p;if(f.sort(),f.length>0){for(m=1,p=1;m0?{type:"choice",alternatives:[I].concat(W),location:Cr()}:I},Ci=function(I,W){return W!==null?{type:"action",expression:I,code:W[0],codeLocation:W[1],location:Cr()}:I},tl=function(I,W){return W.length>0||I.type==="labeled"&&I.pick?{type:"sequence",elements:[I].concat(W),location:Cr()}:I},fv=function(I,W,ne){return ne.type.startsWith("semantic_")&&sd('"@" cannot be used on a semantic predicate',I),{type:"labeled",label:W!==null?W[0]:null,labelLocation:W!==null?W[1]:I,pick:!0,expression:ne,location:Cr()}},hv=function(I,W){return{type:"labeled",label:I[0],labelLocation:I[1],expression:W,location:Cr()}},dv=function(){return Cr()},wr=function(I){return Ha.indexOf(I[0])>=0&&sd(`Label can't be a reserved word "${I[0]}"`,I[1]),I},mr=function(I,W){return{type:Lee[I],expression:W,location:Cr()}},pv=function(I,W){return{type:Uee[W],expression:I,location:Cr()}},mv=function(I){return I.type==="labeled"||I.type==="sequence"?{type:"group",expression:I,location:Cr()}:I},gv=function(I){return{type:"rule_ref",name:I[0],location:Cr()}},vv=function(I,W){return{type:Hee[I],code:W[0],codeLocation:W[1],location:Cr()}},wv=function(I,W){return[I+W.join(""),Cr()]},yv=function(I,W){return{type:"literal",value:I,ignoreCase:W!==null,location:Cr()}},R0=function(I){return I.join("")},Ev=function(I){return I.join("")},tn=function(I,W,ne){return{type:"class",parts:W.filter(ee=>ee!==""),inverted:I!==null,ignoreCase:ne!==null,location:Cr()}},rd=function(I,W){return I.charCodeAt(0)>W.charCodeAt(0)&&sd("Invalid character range: "+Oo()+"."),[I,W]},ka=function(){return""},k0=function(){return"\0"},nd=function(){return"\b"},Us=function(){return"\f"},O0=function(){return` `},N0=function(){return"\r"},L0=function(){return" "},U0=function(){return"\v"},H0=function(I){return String.fromCharCode(parseInt(I,16))},M0=function(I){return String.fromCharCode(parseInt(I,16))},As=function(){return{type:"any",location:Cr()}},bv=function(I){return[I,Cr()]},L=0,Ft=0,rl=[{line:1,column:1}],on=0,zu=[],de=0,hr;if("startRule"in t){if(!(t.startRule in i))throw new Error(`Can't start parsing from rule "`+t.startRule+'".');o=i[t.startRule]}function Oo(){return e.substring(Ft,L)}function q0(){return Ft}function H6(){return{source:n,start:Ft,end:L}}function Cr(){return Yu(Ft,L)}function M6(I,W){throw W=W!==void 0?W:Yu(Ft,L),ud([zi(I)],e.substring(Ft,L),W)}function sd(I,W){throw W=W!==void 0?W:Yu(Ft,L),ad(I,W)}function ft(I,W){return{type:"literal",text:I,ignoreCase:W}}function yn(I,W,ne){return{type:"class",parts:I,inverted:W,ignoreCase:ne}}function pf(){return{type:"any"}}function Gu(){return{type:"end"}}function zi(I){return{type:"other",description:I}}function od(I){var W=rl[I],ne;if(W)return W;for(ne=I-1;!rl[ne];)ne--;for(W=rl[ne],W={line:W.line,column:W.column};neon&&(on=L,zu=[]),zu.push(I))}function ad(I,W){return new Vc(I,null,null,W)}function ud(I,W,ne){return new Vc(Vc.buildMessage(I,W),I,W,ne)}function j0(){var I,W,ne,ee,me,ye,nr,Kr;if(I=L,W=dr(),ne=L,ee=cd(),ee!==r?(me=dr(),ne=ee):(L=ne,ne=r),ne===r&&(ne=null),ee=L,me=ld(),me!==r?(ye=dr(),ee=me):(L=ee,ee=r),ee===r&&(ee=null),me=[],ye=L,nr=K0(),nr!==r?(Kr=dr(),ye=nr):(L=ye,ye=r),ye!==r)for(;ye!==r;)me.push(ye),ye=L,nr=K0(),nr!==r?(Kr=dr(),ye=nr):(L=ye,ye=r);else me=r;return me!==r?(Ft=I,I=oi(ne,ee,me)):(L=I,I=r),I}function cd(){var I,W,ne,ee,me;return I=L,e.charCodeAt(L)===123?(W=s,L++):(W=r,de===0&&Fe(mn)),W!==r?(ne=Ua(),ne!==r?(e.charCodeAt(L)===125?(ee=a,L++):(ee=r,de===0&&Fe(si)),ee!==r?(me=bf(),me!==r?(Ft=I,I=Vu(ne)):(L=I,I=r)):(L=I,I=r)):(L=I,I=r)):(L=I,I=r),I}function ld(){var I,W,ne;return I=L,W=Ua(),W!==r?(ne=bf(),ne!==r?(Ft=I,I=Es(W)):(L=I,I=r)):(L=I,I=r),I}function K0(){var I,W,ne,ee,me,ye,nr,Kr;return I=L,W=Ss(),W!==r?(ne=dr(),ee=L,me=gd(),me!==r?(ye=dr(),ee=me):(L=ee,ee=r),ee===r&&(ee=null),e.charCodeAt(L)===61?(me=u,L++):(me=r,de===0&&Fe(qu)),me!==r?(ye=dr(),nr=fd(),nr!==r?(Kr=bf(),Kr!==r?(Ft=I,I=bs(W,ee,nr)):(L=I,I=r)):(L=I,I=r)):(L=I,I=r)):(L=I,I=r),I}function fd(){var I,W,ne,ee,me,ye,nr,Kr;if(I=L,W=Pn(),W!==r){for(ne=[],ee=L,me=dr(),e.charCodeAt(L)===47?(ye=l,L++):(ye=r,de===0&&Fe(To)),ye!==r?(nr=dr(),Kr=Pn(),Kr!==r?ee=Kr:(L=ee,ee=r)):(L=ee,ee=r);ee!==r;)ne.push(ee),ee=L,me=dr(),e.charCodeAt(L)===47?(ye=l,L++):(ye=r,de===0&&Fe(To)),ye!==r?(nr=dr(),Kr=Pn(),Kr!==r?ee=Kr:(L=ee,ee=r)):(L=ee,ee=r);Ft=I,I=ko(W,ne)}else L=I,I=r;return I}function Pn(){var I,W,ne,ee,me;return I=L,W=hd(),W!==r?(ne=L,ee=dr(),me=Ua(),me!==r?ne=me:(L=ne,ne=r),ne===r&&(ne=null),Ft=I,I=Ci(W,ne)):(L=I,I=r),I}function hd(){var I,W,ne,ee,me,ye;if(I=L,W=Oa(),W!==r){for(ne=[],ee=L,me=dr(),ye=Oa(),ye!==r?ee=ye:(L=ee,ee=r);ee!==r;)ne.push(ee),ee=L,me=dr(),ye=Oa(),ye!==r?ee=ye:(L=ee,ee=r);Ft=I,I=tl(W,ne)}else L=I,I=r;return I}function Oa(){var I,W,ne,ee;return I=L,W=V0(),W!==r?(ne=dd(),ne===r&&(ne=null),ee=pd(),ee!==r?(Ft=I,I=fv(W,ne,ee)):(L=I,I=r)):(L=I,I=r),I===r&&(I=L,W=dd(),W!==r?(ne=dr(),ee=pd(),ee!==r?(Ft=I,I=hv(W,ee)):(L=I,I=r)):(L=I,I=r),I===r&&(I=pd())),I}function V0(){var I,W;return I=L,e.charCodeAt(L)===64?(W=f,L++):(W=r,de===0&&Fe(zc)),W!==r&&(Ft=I,W=dv()),I=W,I}function dd(){var I,W,ne,ee;return I=L,W=Ss(),W!==r?(ne=dr(),e.charCodeAt(L)===58?(ee=m,L++):(ee=r,de===0&&Fe(Po)),ee!==r?(Ft=I,I=wr(W)):(L=I,I=r)):(L=I,I=r),I}function pd(){var I,W,ne,ee;return I=L,W=Av(),W!==r?(ne=dr(),ee=z0(),ee!==r?(Ft=I,I=mr(W,ee)):(L=I,I=r)):(L=I,I=r),I===r&&(I=z0()),I}function Av(){var I;return e.charCodeAt(L)===36?(I=p,L++):(I=r,de===0&&Fe(bi)),I===r&&(e.charCodeAt(L)===38?(I=d,L++):(I=r,de===0&&Fe(Qt)),I===r&&(e.charCodeAt(L)===33?(I=v,L++):(I=r,de===0&&Fe(Ns)))),I}function z0(){var I,W,ne,ee;return I=L,W=G0(),W!==r?(ne=dr(),ee=Sv(),ee!==r?(Ft=I,I=pv(W,ee)):(L=I,I=r)):(L=I,I=r),I===r&&(I=G0()),I}function Sv(){var I;return e.charCodeAt(L)===63?(I=g,L++):(I=r,de===0&&Fe(ju)),I===r&&(e.charCodeAt(L)===42?(I=y,L++):(I=r,de===0&&Fe(Gc)),I===r&&(e.charCodeAt(L)===43?(I=w,L++):(I=r,de===0&&Fe($a)))),I}function G0(){var I,W,ne,ee,me,ye;return I=Bv(),I===r&&(I=Ae(),I===r&&(I=mf(),I===r&&(I=Wu(),I===r&&(I=Cv(),I===r&&(I=L,e.charCodeAt(L)===40?(W=E,L++):(W=r,de===0&&Fe(xo)),W!==r?(ne=dr(),ee=fd(),ee!==r?(me=dr(),e.charCodeAt(L)===41?(ye=S,L++):(ye=r,de===0&&Fe(Yc)),ye!==r?(Ft=I,I=mv(ee)):(L=I,I=r)):(L=I,I=r)):(L=I,I=r)))))),I}function Wu(){var I,W,ne,ee,me,ye,nr,Kr;return I=L,W=Ss(),W!==r?(ne=L,de++,ee=L,me=dr(),ye=L,nr=gd(),nr!==r?(Kr=dr(),nr=[nr,Kr],ye=nr):(L=ye,ye=r),ye===r&&(ye=null),e.charCodeAt(L)===61?(nr=u,L++):(nr=r,de===0&&Fe(qu)),nr!==r?(me=[me,ye,nr],ee=me):(L=ee,ee=r),de--,ee===r?ne=void 0:(L=ne,ne=r),ne!==r?(Ft=I,I=gv(W)):(L=I,I=r)):(L=I,I=r),I}function Cv(){var I,W,ne,ee;return I=L,W=_v(),W!==r?(ne=dr(),ee=Ua(),ee!==r?(Ft=I,I=vv(W,ee)):(L=I,I=r)):(L=I,I=r),I}function _v(){var I;return e.charCodeAt(L)===38?(I=d,L++):(I=r,de===0&&Fe(Qt)),I===r&&(e.charCodeAt(L)===33?(I=v,L++):(I=r,de===0&&Fe(Ns))),I}function En(){var I;return e.length>L?(I=e.charAt(L),L++):(I=r,de===0&&Fe(Ku)),I}function nl(){var I,W;return de++,e.charCodeAt(L)===9?(I=D,L++):(I=r,de===0&&Fe(Wc)),I===r&&(e.charCodeAt(L)===11?(I=F,L++):(I=r,de===0&&Fe(ue)),I===r&&(e.charCodeAt(L)===12?(I=M,L++):(I=r,de===0&&Fe(Ee)),I===r&&(e.charCodeAt(L)===32?(I=z,L++):(I=r,de===0&&Fe(Qe)),I===r&&(e.charCodeAt(L)===160?(I=C,L++):(I=r,de===0&&Fe(Xe)),I===r&&(e.charCodeAt(L)===65279?(I=P,L++):(I=r,de===0&&Fe(ut)),I===r&&(I=e1())))))),de--,I===r&&(W=r,de===0&&Fe(Ta)),I}function xn(){var I;return bt.test(e.charAt(L))?(I=e.charAt(L),L++):(I=r,de===0&&Fe(Ct)),I}function Na(){var I,W;return de++,e.charCodeAt(L)===10?(I=U,L++):(I=r,de===0&&Fe(qr)),I===r&&(e.substr(L,2)===k?(I=k,L+=2):(I=r,de===0&&Fe(lr)),I===r&&(e.charCodeAt(L)===13?(I=O,L++):(I=r,de===0&&Fe(vs)),I===r&&(e.charCodeAt(L)===8232?(I=q,L++):(I=r,de===0&&Fe(Ai)),I===r&&(e.charCodeAt(L)===8233?(I=N,L++):(I=r,de===0&&Fe($n)))))),de--,I===r&&(W=r,de===0&&Fe(Dt)),I}function Y0(){var I,W;return de++,I=Dv(),I===r&&(I=La()),de--,I===r&&(W=r,de===0&&Fe(Wn)),I}function Dv(){var I,W,ne,ee,me,ye;if(I=L,e.substr(L,2)===_?(W=_,L+=2):(W=r,de===0&&Fe(Rr)),W!==r){for(ne=[],ee=L,me=L,de++,e.substr(L,2)===R?(ye=R,L+=2):(ye=r,de===0&&Fe(Tn)),de--,ye===r?me=void 0:(L=me,me=r),me!==r?(ye=En(),ye!==r?(me=[me,ye],ee=me):(L=ee,ee=r)):(L=ee,ee=r);ee!==r;)ne.push(ee),ee=L,me=L,de++,e.substr(L,2)===R?(ye=R,L+=2):(ye=r,de===0&&Fe(Tn)),de--,ye===r?me=void 0:(L=me,me=r),me!==r?(ye=En(),ye!==r?(me=[me,ye],ee=me):(L=ee,ee=r)):(L=ee,ee=r);e.substr(L,2)===R?(ee=R,L+=2):(ee=r,de===0&&Fe(Tn)),ee!==r?(W=[W,ne,ee],I=W):(L=I,I=r)}else L=I,I=r;return I}function W0(){var I,W,ne,ee,me,ye;if(I=L,e.substr(L,2)===_?(W=_,L+=2):(W=r,de===0&&Fe(Rr)),W!==r){for(ne=[],ee=L,me=L,de++,e.substr(L,2)===R?(ye=R,L+=2):(ye=r,de===0&&Fe(Tn)),ye===r&&(ye=xn()),de--,ye===r?me=void 0:(L=me,me=r),me!==r?(ye=En(),ye!==r?(me=[me,ye],ee=me):(L=ee,ee=r)):(L=ee,ee=r);ee!==r;)ne.push(ee),ee=L,me=L,de++,e.substr(L,2)===R?(ye=R,L+=2):(ye=r,de===0&&Fe(Tn)),ye===r&&(ye=xn()),de--,ye===r?me=void 0:(L=me,me=r),me!==r?(ye=En(),ye!==r?(me=[me,ye],ee=me):(L=ee,ee=r)):(L=ee,ee=r);e.substr(L,2)===R?(ee=R,L+=2):(ee=r,de===0&&Fe(Tn)),ee!==r?(W=[W,ne,ee],I=W):(L=I,I=r)}else L=I,I=r;return I}function La(){var I,W,ne,ee,me,ye;if(I=L,e.substr(L,2)===K?(W=K,L+=2):(W=r,de===0&&Fe(Xn)),W!==r){for(ne=[],ee=L,me=L,de++,ye=xn(),de--,ye===r?me=void 0:(L=me,me=r),me!==r?(ye=En(),ye!==r?(me=[me,ye],ee=me):(L=ee,ee=r)):(L=ee,ee=r);ee!==r;)ne.push(ee),ee=L,me=L,de++,ye=xn(),de--,ye===r?me=void 0:(L=me,me=r),me!==r?(ye=En(),ye!==r?(me=[me,ye],ee=me):(L=ee,ee=r)):(L=ee,ee=r);W=[W,ne],I=W}else L=I,I=r;return I}function Ss(){var I,W,ne,ee;if(de++,I=L,W=md(),W!==r){for(ne=[],ee=X0();ee!==r;)ne.push(ee),ee=X0();Ft=I,I=wv(W,ne)}else L=I,I=r;return de--,I===r&&(W=r,de===0&&Fe(Ro)),I}function md(){var I,W,ne;return I=Fv(),I===r&&(e.charCodeAt(L)===36?(I=p,L++):(I=r,de===0&&Fe(bi)),I===r&&(e.charCodeAt(L)===95?(I=Z,L++):(I=r,de===0&&Fe(Xc)),I===r&&(I=L,e.charCodeAt(L)===92?(W=Y,L++):(W=r,de===0&&Fe(gn)),W!==r?(ne=sl(),ne!==r?I=ne:(L=I,I=r)):(L=I,I=r)))),I}function X0(){var I;return I=md(),I===r&&(I=Iv(),I===r&&(I=wf(),I===r&&(I=yf(),I===r&&(e.charCodeAt(L)===8204?(I=te,L++):(I=r,de===0&&Fe(Xt)),I===r&&(e.charCodeAt(L)===8205?(I=se,L++):(I=r,de===0&&Fe(kr))))))),I}function Fv(){var I;return I=xv(),I===r&&(I=Z0(),I===r&&(I=Pv(),I===r&&(I=gf(),I===r&&(I=Tv(),I===r&&(I=Q0()))))),I}function Iv(){var I;return I=No(),I===r&&(I=vf()),I}function Bv(){var I,W,ne;return de++,I=L,W=gd(),W!==r?(e.charCodeAt(L)===105?(ne=fe,L++):(ne=r,de===0&&Fe(Sr)),ne===r&&(ne=null),Ft=I,I=yv(W,ne)):(L=I,I=r),de--,I===r&&(W=r,de===0&&Fe(wt)),I}function gd(){var I,W,ne,ee;if(de++,I=L,e.charCodeAt(L)===34?(W=ve,L++):(W=r,de===0&&Fe(yr)),W!==r){for(ne=[],ee=Gi();ee!==r;)ne.push(ee),ee=Gi();e.charCodeAt(L)===34?(ee=ve,L++):(ee=r,de===0&&Fe(yr)),ee!==r?(Ft=I,I=R0(ne)):(L=I,I=r)}else L=I,I=r;if(I===r)if(I=L,e.charCodeAt(L)===39?(W=we,L++):(W=r,de===0&&Fe(or)),W!==r){for(ne=[],ee=ce();ee!==r;)ne.push(ee),ee=ce();e.charCodeAt(L)===39?(ee=we,L++):(ee=r,de===0&&Fe(or)),ee!==r?(Ft=I,I=Ev(ne)):(L=I,I=r)}else L=I,I=r;return de--,I===r&&(W=r,de===0&&Fe(vn)),I}function Gi(){var I,W,ne,ee;return I=L,W=L,ne=L,de++,e.charCodeAt(L)===34?(ee=ve,L++):(ee=r,de===0&&Fe(yr)),ee===r&&(e.charCodeAt(L)===92?(ee=Y,L++):(ee=r,de===0&&Fe(gn)),ee===r&&(ee=xn())),de--,ee===r?ne=void 0:(L=ne,ne=r),ne!==r?(ee=En(),ee!==r?(ne=[ne,ee],W=ne):(L=W,W=r)):(L=W,W=r),W!==r?I=e.substring(I,L):I=W,I===r&&(I=L,e.charCodeAt(L)===92?(W=Y,L++):(W=r,de===0&&Fe(gn)),W!==r?(ne=jt(),ne!==r?I=ne:(L=I,I=r)):(L=I,I=r),I===r&&(I=vt())),I}function ce(){var I,W,ne,ee;return I=L,W=L,ne=L,de++,e.charCodeAt(L)===39?(ee=we,L++):(ee=r,de===0&&Fe(or)),ee===r&&(e.charCodeAt(L)===92?(ee=Y,L++):(ee=r,de===0&&Fe(gn)),ee===r&&(ee=xn())),de--,ee===r?ne=void 0:(L=ne,ne=r),ne!==r?(ee=En(),ee!==r?(ne=[ne,ee],W=ne):(L=W,W=r)):(L=W,W=r),W!==r?I=e.substring(I,L):I=W,I===r&&(I=L,e.charCodeAt(L)===92?(W=Y,L++):(W=r,de===0&&Fe(gn)),W!==r?(ne=jt(),ne!==r?I=ne:(L=I,I=r)):(L=I,I=r),I===r&&(I=vt())),I}function Ae(){var I,W,ne,ee,me,ye;if(de++,I=L,e.charCodeAt(L)===91?(W=Te,L++):(W=r,de===0&&Fe(Ls)),W!==r){for(e.charCodeAt(L)===94?(ne=Le,L++):(ne=r,de===0&&Fe(ii)),ne===r&&(ne=null),ee=[],me=ge(),me===r&&(me=We());me!==r;)ee.push(me),me=ge(),me===r&&(me=We());e.charCodeAt(L)===93?(me=Oe,L++):(me=r,de===0&&Fe(ys)),me!==r?(e.charCodeAt(L)===105?(ye=fe,L++):(ye=r,de===0&&Fe(Sr)),ye===r&&(ye=null),Ft=I,I=tn(ne,ee,ye)):(L=I,I=r)}else L=I,I=r;return de--,I===r&&(W=r,de===0&&Fe(ws)),I}function ge(){var I,W,ne,ee;return I=L,W=We(),W!==r?(e.charCodeAt(L)===45?(ne=le,L++):(ne=r,de===0&&Fe(en)),ne!==r?(ee=We(),ee!==r?(Ft=I,I=rd(W,ee)):(L=I,I=r)):(L=I,I=r)):(L=I,I=r),I}function We(){var I,W,ne,ee;return I=L,W=L,ne=L,de++,e.charCodeAt(L)===93?(ee=Oe,L++):(ee=r,de===0&&Fe(ys)),ee===r&&(e.charCodeAt(L)===92?(ee=Y,L++):(ee=r,de===0&&Fe(gn)),ee===r&&(ee=xn())),de--,ee===r?ne=void 0:(L=ne,ne=r),ne!==r?(ee=En(),ee!==r?(ne=[ne,ee],W=ne):(L=W,W=r)):(L=W,W=r),W!==r?I=e.substring(I,L):I=W,I===r&&(I=L,e.charCodeAt(L)===92?(W=Y,L++):(W=r,de===0&&Fe(gn)),W!==r?(ne=jt(),ne!==r?I=ne:(L=I,I=r)):(L=I,I=r),I===r&&(I=vt())),I}function vt(){var I,W,ne;return I=L,e.charCodeAt(L)===92?(W=Y,L++):(W=r,de===0&&Fe(gn)),W!==r?(ne=Na(),ne!==r?(Ft=I,I=ka()):(L=I,I=r)):(L=I,I=r),I}function jt(){var I,W,ne,ee;return I=jr(),I===r&&(I=L,e.charCodeAt(L)===48?(W=Se,L++):(W=r,de===0&&Fe($r)),W!==r?(ne=L,de++,ee=J0(),de--,ee===r?ne=void 0:(L=ne,ne=r),ne!==r?(Ft=I,I=k0()):(L=I,I=r)):(L=I,I=r),I===r&&(I=Hs(),I===r&&(I=sl()))),I}function jr(){var I;return I=ar(),I===r&&(I=vd()),I}function ar(){var I,W;return e.charCodeAt(L)===39?(I=we,L++):(I=r,de===0&&Fe(or)),I===r&&(e.charCodeAt(L)===34?(I=ve,L++):(I=r,de===0&&Fe(yr)),I===r&&(e.charCodeAt(L)===92?(I=Y,L++):(I=r,de===0&&Fe(gn)),I===r&&(I=L,e.charCodeAt(L)===98?(W=Re,L++):(W=r,de===0&&Fe(Jc)),W!==r&&(Ft=I,W=nd()),I=W,I===r&&(I=L,e.charCodeAt(L)===102?(W=Ve,L++):(W=r,de===0&&Fe(hf)),W!==r&&(Ft=I,W=Us()),I=W,I===r&&(I=L,e.charCodeAt(L)===110?(W=rt,L++):(W=r,de===0&&Fe(Jn)),W!==r&&(Ft=I,W=O0()),I=W,I===r&&(I=L,e.charCodeAt(L)===114?(W=qe,L++):(W=r,de===0&&Fe(Pa)),W!==r&&(Ft=I,W=N0()),I=W,I===r&&(I=L,e.charCodeAt(L)===116?(W=At,L++):(W=r,de===0&&Fe(Zc)),W!==r&&(Ft=I,W=L0()),I=W,I===r&&(I=L,e.charCodeAt(L)===118?(W=it,L++):(W=r,de===0&&Fe(ed)),W!==r&&(Ft=I,W=U0()),I=W)))))))),I}function vd(){var I,W,ne,ee;return I=L,W=L,ne=L,de++,ee=$v(),ee===r&&(ee=xn()),de--,ee===r?ne=void 0:(L=ne,ne=r),ne!==r?(ee=En(),ee!==r?(ne=[ne,ee],W=ne):(L=W,W=r)):(L=W,W=r),W!==r?I=e.substring(I,L):I=W,I}function $v(){var I;return I=ar(),I===r&&(I=J0(),I===r&&(e.charCodeAt(L)===120?(I=Et,L++):(I=r,de===0&&Fe(Qc)),I===r&&(e.charCodeAt(L)===117?(I=pn,L++):(I=r,de===0&&Fe(xa))))),I}function Hs(){var I,W,ne,ee,me,ye;return I=L,e.charCodeAt(L)===120?(W=Et,L++):(W=r,de===0&&Fe(Qc)),W!==r?(ne=L,ee=L,me=ai(),me!==r?(ye=ai(),ye!==r?(me=[me,ye],ee=me):(L=ee,ee=r)):(L=ee,ee=r),ee!==r?ne=e.substring(ne,L):ne=ee,ne!==r?(Ft=I,I=H0(ne)):(L=I,I=r)):(L=I,I=r),I}function sl(){var I,W,ne,ee,me,ye,nr,Kr;return I=L,e.charCodeAt(L)===117?(W=pn,L++):(W=r,de===0&&Fe(xa)),W!==r?(ne=L,ee=L,me=ai(),me!==r?(ye=ai(),ye!==r?(nr=ai(),nr!==r?(Kr=ai(),Kr!==r?(me=[me,ye,nr,Kr],ee=me):(L=ee,ee=r)):(L=ee,ee=r)):(L=ee,ee=r)):(L=ee,ee=r),ee!==r?ne=e.substring(ne,L):ne=ee,ne!==r?(Ft=I,I=M0(ne)):(L=I,I=r)):(L=I,I=r),I}function J0(){var I;return Mr.test(e.charAt(L))?(I=e.charAt(L),L++):(I=r,de===0&&Fe(Ra)),I}function ai(){var I;return Yn.test(e.charAt(L))?(I=e.charAt(L),L++):(I=r,de===0&&Fe(td)),I}function mf(){var I,W;return I=L,e.charCodeAt(L)===46?(W=Ir,L++):(W=r,de===0&&Fe(df)),W!==r&&(Ft=I,W=As()),I=W,I}function Ua(){var I,W,ne,ee;return de++,I=L,e.charCodeAt(L)===123?(W=s,L++):(W=r,de===0&&Fe(mn)),W!==r?(ne=er(),e.charCodeAt(L)===125?(ee=a,L++):(ee=r,de===0&&Fe(si)),ee!==r?I=ne:(L=I,I=r)):(L=I,I=r),de--,I===r&&(W=r,de===0&&Fe(el)),I}function er(){var I,W;return I=L,W=wd(),Ft=I,W=bv(W),I=W,I}function wd(){var I,W,ne,ee,me,ye;if(I=L,W=[],ne=[],ee=L,me=L,de++,ni.test(e.charAt(L))?(ye=e.charAt(L),L++):(ye=r,de===0&&Fe(Si)),de--,ye===r?me=void 0:(L=me,me=r),me!==r?(ye=En(),ye!==r?(me=[me,ye],ee=me):(L=ee,ee=r)):(L=ee,ee=r),ee!==r)for(;ee!==r;)ne.push(ee),ee=L,me=L,de++,ni.test(e.charAt(L))?(ye=e.charAt(L),L++):(ye=r,de===0&&Fe(Si)),de--,ye===r?me=void 0:(L=me,me=r),me!==r?(ye=En(),ye!==r?(me=[me,ye],ee=me):(L=ee,ee=r)):(L=ee,ee=r);else ne=r;for(ne===r&&(ne=L,e.charCodeAt(L)===123?(ee=s,L++):(ee=r,de===0&&Fe(mn)),ee!==r?(me=wd(),e.charCodeAt(L)===125?(ye=a,L++):(ye=r,de===0&&Fe(si)),ye!==r?(ee=[ee,me,ye],ne=ee):(L=ne,ne=r)):(L=ne,ne=r));ne!==r;){if(W.push(ne),ne=[],ee=L,me=L,de++,ni.test(e.charAt(L))?(ye=e.charAt(L),L++):(ye=r,de===0&&Fe(Si)),de--,ye===r?me=void 0:(L=me,me=r),me!==r?(ye=En(),ye!==r?(me=[me,ye],ee=me):(L=ee,ee=r)):(L=ee,ee=r),ee!==r)for(;ee!==r;)ne.push(ee),ee=L,me=L,de++,ni.test(e.charAt(L))?(ye=e.charAt(L),L++):(ye=r,de===0&&Fe(Si)),de--,ye===r?me=void 0:(L=me,me=r),me!==r?(ye=En(),ye!==r?(me=[me,ye],ee=me):(L=ee,ee=r)):(L=ee,ee=r);else ne=r;ne===r&&(ne=L,e.charCodeAt(L)===123?(ee=s,L++):(ee=r,de===0&&Fe(mn)),ee!==r?(me=wd(),e.charCodeAt(L)===125?(ye=a,L++):(ye=r,de===0&&Fe(si)),ye!==r?(ee=[ee,me,ye],ne=ee):(L=ne,ne=r)):(L=ne,ne=r))}return I=e.substring(I,L),I}function Z0(){var I;return Rt.test(e.charAt(L))?(I=e.charAt(L),L++):(I=r,de===0&&Fe(j)),I}function gf(){var I;return st.test(e.charAt(L))?(I=e.charAt(L),L++):(I=r,de===0&&Fe(G)),I}function Tv(){var I;return Ue.test(e.charAt(L))?(I=e.charAt(L),L++):(I=r,de===0&&Fe(Q)),I}function Pv(){var I;return Ar.test(e.charAt(L))?(I=e.charAt(L),L++):(I=r,de===0&&Fe(ae)),I}function xv(){var I;return In.test(e.charAt(L))?(I=e.charAt(L),L++):(I=r,de===0&&Fe(Ie)),I}function vf(){var I;return St.test(e.charAt(L))?(I=e.charAt(L),L++):(I=r,de===0&&Fe(Pe)),I}function No(){var I;return Ba.test(e.charAt(L))?(I=e.charAt(L),L++):(I=r,de===0&&Fe(Me)),I}function wf(){var I;return Bn.test(e.charAt(L))?(I=e.charAt(L),L++):(I=r,de===0&&Fe(ze)),I}function Q0(){var I;return De.test(e.charAt(L))?(I=e.charAt(L),L++):(I=r,de===0&&Fe(fr)),I}function yf(){var I;return $o.test(e.charAt(L))?(I=e.charAt(L),L++):(I=r,de===0&&Fe(Or)),I}function e1(){var I;return Yt.test(e.charAt(L))?(I=e.charAt(L),L++):(I=r,de===0&&Fe(Zn)),I}function dr(){var I,W;for(I=[],W=nl(),W===r&&(W=Na(),W===r&&(W=Y0()));W!==r;)I.push(W),W=nl(),W===r&&(W=Na(),W===r&&(W=Y0()));return I}function Ef(){var I,W;for(I=[],W=nl(),W===r&&(W=W0());W!==r;)I.push(W),W=nl(),W===r&&(W=W0());return I}function bf(){var I,W,ne,ee;return I=L,W=dr(),e.charCodeAt(L)===59?(ne=Br,L++):(ne=r,de===0&&Fe(wn)),ne!==r?(W=[W,ne],I=W):(L=I,I=r),I===r&&(I=L,W=Ef(),ne=La(),ne===r&&(ne=null),ee=Na(),ee!==r?(W=[W,ne,ee],I=W):(L=I,I=r),I===r&&(I=L,W=dr(),ne=il(),ne!==r?(W=[W,ne],I=W):(L=I,I=r))),I}function il(){var I,W;return I=L,de++,e.length>L?(W=e.charAt(L),L++):(W=r,de===0&&Fe(Ku)),de--,W===r?I=void 0:(L=I,I=r),I}let Ha=t.reservedWords||[];if(hr=o(),hr!==r&&L===e.length)return hr;throw hr!==r&&L{"use strict";var oAe=B(T()),jee=z2(),Kee=G$(),Vee=W$(),zee=t6(),Gee=["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"],B0={VERSION:zee,RESERVED_WORDS:Gee,GrammarError:jee,parser:Vee,compiler:Kee,generate(e,t){t=t!==void 0?t:{};function r(o){let s={};return Object.keys(o).forEach(a=>{s[a]=o[a].slice()}),s}let n="plugins"in t?t.plugins:[],i={parser:B0.parser,passes:r(B0.compiler.passes),reservedWords:B0.RESERVED_WORDS.slice()};return n.forEach(o=>{o.use(i,t)}),B0.compiler.compile(i.parser.parse(e,{grammarSource:t.grammarSource,reservedWords:i.reservedWords}),i.passes,t)}};X$.exports=B0});var A6=Ce((E6,b6)=>{var vAe=B(T());(function(e,t){typeof E6=="object"&&typeof b6<"u"?b6.exports=t():typeof define=="function"&&define.amd?define(t):e.JSON5=t()})(E6,function(){"use strict";function e(ue,Ee){return Ee={exports:{}},ue(Ee,Ee.exports),Ee.exports}var t=e(function(ue){var Ee=ue.exports=typeof window<"u"&&window.Math==Math?window:typeof self<"u"&&self.Math==Math?self:Function("return this")();typeof __g=="number"&&(__g=Ee)}),r=e(function(ue){var Ee=ue.exports={version:"2.6.5"};typeof __e=="number"&&(__e=Ee)}),n=r.version,i=function(ue){return typeof ue=="object"?ue!==null:typeof ue=="function"},o=function(ue){if(!i(ue))throw TypeError(ue+" is not an object!");return ue},s=function(ue){try{return!!ue()}catch{return!0}},a=!s(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7}),u=t.document,l=i(u)&&i(u.createElement),f=function(ue){return l?u.createElement(ue):{}},m=!a&&!s(function(){return Object.defineProperty(f("div"),"a",{get:function(){return 7}}).a!=7}),p=function(ue,Ee){if(!i(ue))return ue;var Qe,Xe;if(Ee&&typeof(Qe=ue.toString)=="function"&&!i(Xe=Qe.call(ue))||typeof(Qe=ue.valueOf)=="function"&&!i(Xe=Qe.call(ue))||!Ee&&typeof(Qe=ue.toString)=="function"&&!i(Xe=Qe.call(ue)))return Xe;throw TypeError("Can't convert object to primitive value")},d=Object.defineProperty,v=a?Object.defineProperty:function(Ee,Qe,Xe){if(o(Ee),Qe=p(Qe,!0),o(Xe),m)try{return d(Ee,Qe,Xe)}catch{}if("get"in Xe||"set"in Xe)throw TypeError("Accessors not supported!");return"value"in Xe&&(Ee[Qe]=Xe.value),Ee},g={f:v},y=function(ue,Ee){return{enumerable:!(ue&1),configurable:!(ue&2),writable:!(ue&4),value:Ee}},w=a?function(ue,Ee,Qe){return g.f(ue,Ee,y(1,Qe))}:function(ue,Ee,Qe){return ue[Ee]=Qe,ue},E={}.hasOwnProperty,S=function(ue,Ee){return E.call(ue,Ee)},D=0,F=Math.random(),M=function(ue){return"Symbol(".concat(ue===void 0?"":ue,")_",(++D+F).toString(36))},z=!1,C=e(function(ue){var Ee="__core-js_shared__",Qe=t[Ee]||(t[Ee]={});(ue.exports=function(Xe,ut){return Qe[Xe]||(Qe[Xe]=ut!==void 0?ut:{})})("versions",[]).push({version:r.version,mode:z?"pure":"global",copyright:"\xA9 2019 Denis Pushkarev (zloirock.ru)"})}),P=C("native-function-to-string",Function.toString),U=e(function(ue){var Ee=M("src"),Qe="toString",Xe=(""+P).split(Qe);r.inspectSource=function(ut){return P.call(ut)},(ue.exports=function(ut,Ct,Dt,qr){var lr=typeof Dt=="function";lr&&(S(Dt,"name")||w(Dt,"name",Ct)),ut[Ct]!==Dt&&(lr&&(S(Dt,Ee)||w(Dt,Ee,ut[Ct]?""+ut[Ct]:Xe.join(String(Ct)))),ut===t?ut[Ct]=Dt:qr?ut[Ct]?ut[Ct]=Dt:w(ut,Ct,Dt):(delete ut[Ct],w(ut,Ct,Dt)))})(Function.prototype,Qe,function(){return typeof this=="function"&&this[Ee]||P.call(this)})}),k=function(ue){if(typeof ue!="function")throw TypeError(ue+" is not a function!");return ue},O=function(ue,Ee,Qe){if(k(ue),Ee===void 0)return ue;switch(Qe){case 1:return function(Xe){return ue.call(Ee,Xe)};case 2:return function(Xe,ut){return ue.call(Ee,Xe,ut)};case 3:return function(Xe,ut,Ct){return ue.call(Ee,Xe,ut,Ct)}}return function(){return ue.apply(Ee,arguments)}},q="prototype",N=function(ue,Ee,Qe){var Xe=ue&N.F,ut=ue&N.G,Ct=ue&N.S,Dt=ue&N.P,qr=ue&N.B,lr=ut?t:Ct?t[Ee]||(t[Ee]={}):(t[Ee]||{})[q],vs=ut?r:r[Ee]||(r[Ee]={}),Ai=vs[q]||(vs[q]={}),$n,Wn,Rr,Tn;ut&&(Qe=Ee);for($n in Qe)Wn=!Xe&&lr&&lr[$n]!==void 0,Rr=(Wn?lr:Qe)[$n],Tn=qr&&Wn?O(Rr,t):Dt&&typeof Rr=="function"?O(Function.call,Rr):Rr,lr&&U(lr,$n,Rr,ue&N.U),vs[$n]!=Rr&&w(vs,$n,Tn),Dt&&Ai[$n]!=Rr&&(Ai[$n]=Rr)};t.core=r,N.F=1,N.G=2,N.S=4,N.P=8,N.B=16,N.W=32,N.U=64,N.R=128;var _=N,R=Math.ceil,K=Math.floor,Z=function(ue){return isNaN(ue=+ue)?0:(ue>0?K:R)(ue)},Y=function(ue){if(ue==null)throw TypeError("Can't call method on "+ue);return ue},te=function(ue){return function(Ee,Qe){var Xe=String(Y(Ee)),ut=Z(Qe),Ct=Xe.length,Dt,qr;return ut<0||ut>=Ct?ue?"":void 0:(Dt=Xe.charCodeAt(ut),Dt<55296||Dt>56319||ut+1===Ct||(qr=Xe.charCodeAt(ut+1))<56320||qr>57343?ue?Xe.charAt(ut):Dt:ue?Xe.slice(ut,ut+2):(Dt-55296<<10)+(qr-56320)+65536)}},se=te(!1);_(_.P,"String",{codePointAt:function(Ee){return se(this,Ee)}});var fe=r.String.codePointAt,ve=Math.max,we=Math.min,Te=function(ue,Ee){return ue=Z(ue),ue<0?ve(ue+Ee,0):we(ue,Ee)},Le=String.fromCharCode,Oe=String.fromCodePoint;_(_.S+_.F*(!!Oe&&Oe.length!=1),"String",{fromCodePoint:function(Ee){for(var Qe=arguments,Xe=[],ut=arguments.length,Ct=0,Dt;ut>Ct;){if(Dt=+Qe[Ct++],Te(Dt,1114111)!==Dt)throw RangeError(Dt+" is not a valid code point");Xe.push(Dt<65536?Le(Dt):Le(((Dt-=65536)>>10)+55296,Dt%1024+56320))}return Xe.join("")}});var le=r.String.fromCodePoint,Se=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,Re=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,Ve=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/,rt={Space_Separator:Se,ID_Start:Re,ID_Continue:Ve},qe={isSpaceSeparator:function(Ee){return typeof Ee=="string"&&rt.Space_Separator.test(Ee)},isIdStartChar:function(Ee){return typeof Ee=="string"&&(Ee>="a"&&Ee<="z"||Ee>="A"&&Ee<="Z"||Ee==="$"||Ee==="_"||rt.ID_Start.test(Ee))},isIdContinueChar:function(Ee){return typeof Ee=="string"&&(Ee>="a"&&Ee<="z"||Ee>="A"&&Ee<="Z"||Ee>="0"&&Ee<="9"||Ee==="$"||Ee==="_"||Ee==="\u200C"||Ee==="\u200D"||rt.ID_Continue.test(Ee))},isDigit:function(Ee){return typeof Ee=="string"&&/[0-9]/.test(Ee)},isHexDigit:function(Ee){return typeof Ee=="string"&&/[0-9A-Fa-f]/.test(Ee)}},At,it,Et,pn,Ir,Br,bt,Mr,Yn,ni=function(Ee,Qe){At=String(Ee),it="start",Et=[],pn=0,Ir=1,Br=0,bt=void 0,Mr=void 0,Yn=void 0;do bt=Ba(),zc[it]();while(bt.type!=="eof");return typeof Qe=="function"?Rt({"":Yn},"",Qe):Yn};function Rt(ue,Ee,Qe){var Xe=ue[Ee];if(Xe!=null&&typeof Xe=="object")if(Array.isArray(Xe))for(var ut=0;ut0;){var Qe=Bn();if(!qe.isHexDigit(Qe))throw Qt(De());ue+=De()}return String.fromCodePoint(parseInt(ue,16))}var zc={start:function(){if(bt.type==="eof")throw Ns();Po()},beforePropertyName:function(){switch(bt.type){case"identifier":case"string":Mr=bt.value,it="afterPropertyName";return;case"punctuator":bi();return;case"eof":throw Ns()}},afterPropertyName:function(){if(bt.type==="eof")throw Ns();it="beforePropertyValue"},beforePropertyValue:function(){if(bt.type==="eof")throw Ns();Po()},beforeArrayValue:function(){if(bt.type==="eof")throw Ns();if(bt.type==="punctuator"&&bt.value==="]"){bi();return}Po()},afterPropertyValue:function(){if(bt.type==="eof")throw Ns();switch(bt.value){case",":it="beforePropertyName";return;case"}":bi()}},afterArrayValue:function(){if(bt.type==="eof")throw Ns();switch(bt.value){case",":it="beforeArrayValue";return;case"]":bi()}},end:function(){}};function Po(){var ue;switch(bt.type){case"punctuator":switch(bt.value){case"{":ue={};break;case"[":ue=[];break}break;case"null":case"boolean":case"numeric":case"string":ue=bt.value;break}if(Yn===void 0)Yn=ue;else{var Ee=Et[Et.length-1];Array.isArray(Ee)?Ee.push(ue):Object.defineProperty(Ee,Mr,{value:ue,writable:!0,enumerable:!0,configurable:!0})}if(ue!==null&&typeof ue=="object")Et.push(ue),Array.isArray(ue)?it="beforeArrayValue":it="beforePropertyName";else{var Qe=Et[Et.length-1];Qe==null?it="end":Array.isArray(Qe)?it="afterArrayValue":it="afterPropertyValue"}}function bi(){Et.pop();var ue=Et[Et.length-1];ue==null?it="end":Array.isArray(ue)?it="afterArrayValue":it="afterPropertyValue"}function Qt(ue){return xo(ue===void 0?"JSON5: invalid end of input at "+Ir+":"+Br:"JSON5: invalid character '"+$a(ue)+"' at "+Ir+":"+Br)}function Ns(){return xo("JSON5: invalid end of input at "+Ir+":"+Br)}function ju(){return Br-=5,xo("JSON5: invalid identifier character at "+Ir+":"+Br)}function Gc(ue){console.warn("JSON5: '"+$a(ue)+"' in strings is not valid ECMAScript; consider escaping")}function $a(ue){var Ee={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};if(Ee[ue])return Ee[ue];if(ue<" "){var Qe=ue.charCodeAt(0).toString(16);return"\\x"+("00"+Qe).substring(Qe.length)}return ue}function xo(ue){var Ee=new SyntaxError(ue);return Ee.lineNumber=Ir,Ee.columnNumber=Br,Ee}var Yc=function(Ee,Qe,Xe){var ut=[],Ct="",Dt,qr,lr="",vs;if(Qe!=null&&typeof Qe=="object"&&!Array.isArray(Qe)&&(Xe=Qe.space,vs=Qe.quote,Qe=Qe.replacer),typeof Qe=="function")qr=Qe;else if(Array.isArray(Qe)){Dt=[];for(var Ai=0,$n=Qe;Ai<$n.length;Ai+=1){var Wn=$n[Ai],Rr=void 0;typeof Wn=="string"?Rr=Wn:(typeof Wn=="number"||Wn instanceof String||Wn instanceof Number)&&(Rr=String(Wn)),Rr!==void 0&&Dt.indexOf(Rr)<0&&Dt.push(Rr)}}return Xe instanceof Number?Xe=Number(Xe):Xe instanceof String&&(Xe=String(Xe)),typeof Xe=="number"?Xe>0&&(Xe=Math.min(10,Math.floor(Xe)),lr=" ".substr(0,Xe)):typeof Xe=="string"&&(lr=Xe.substr(0,10)),Tn("",{"":Ee});function Tn(Xt,kr){var wt=kr[Xt];switch(wt!=null&&(typeof wt.toJSON5=="function"?wt=wt.toJSON5(Xt):typeof wt.toJSON=="function"&&(wt=wt.toJSON(Xt))),qr&&(wt=qr.call(kr,Xt,wt)),wt instanceof Number?wt=Number(wt):wt instanceof String?wt=String(wt):wt instanceof Boolean&&(wt=wt.valueOf()),wt){case null:return"null";case!0:return"true";case!1:return"false"}if(typeof wt=="string")return Xn(wt,!1);if(typeof wt=="number")return String(wt);if(typeof wt=="object")return Array.isArray(wt)?gn(wt):Ro(wt)}function Xn(Xt){for(var kr={"'":.1,'"':.2},wt={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"},Sr="",vn=0;vn=0)throw TypeError("Converting circular structure to JSON5");ut.push(Xt);var kr=Ct;Ct=Ct+lr;for(var wt=Dt||Object.keys(Xt),Sr=[],vn=0,yr=wt;vn=0)throw TypeError("Converting circular structure to JSON5");ut.push(Xt);var kr=Ct;Ct=Ct+lr;for(var wt=[],Sr=0;Sr!nM(p)),m=f.length!==l.length;return l=f,l.length>n?(l=l.slice(-n),q1(e,l)):m&&q1(e,l),u&&(l=l.filter(p=>u(rM(p)))),{logs:l.slice(-i).reverse(),total:l.length,maxCount:n}}function D_(e){q1(e,[])}function F_(e){p_||typeof console>"u"||(p_=!0,y_.forEach(t=>{let r=console[t];typeof r=="function"&&(console[t]=function(...n){if(r.apply(console,WH(n,{isNode:e.env.isNode})),!wy)try{wy=!0,ZH(e,t,n)}finally{wy=!1}})}))}function g_(e,t,r){let n=Number(e);return!isFinite(n)||n<=0?t:Math.min(Math.floor(n),r)}function QH(e){let t=Date.now();if(Od!==null&&ti.test(o)}let n=r?e.toLowerCase():e;return i=>(r?i.toLowerCase():i).includes(n)}function rM(e){return`${e.level||""} ${e.message||""}`}function nM(e){return B_(e.message)}function B_(e){let t=sM(e);return t.length===1?E_.test(t[0])||oM(t[0]):iM(t)}function sM(e){let t=`${e||""}`.split(/\r?\n/).map(n=>n.trim()).filter(Boolean);if(t.length===0)return t;let r=t[0].replace(b_,"").trim();return r!==t[0]&&(r?t[0]=r:t.shift()),t}function iM(e){return e.length<3||!d_.test(e[0])||!d_.test(e[e.length-1])?!1:e.slice(1,-1).some(t=>E_.test(t))}function oM(e){let t=e.replace(zH,"");return YH.some(r=>r.test(t))}function aM(e){if(e instanceof Error)return e.stack||e.message||String(e);if(typeof e=="string")return e;if(e==null)return String(e);if(typeof e=="object")try{return JSON.stringify(e)}catch{return String(e)}return String(e)}function uM(e){return e&&typeof e=="object"&&typeof e.id=="string"&&typeof e.time=="number"&&typeof e.level=="string"&&typeof e.message=="string"}function cM(){return`${Date.now()}-${Math.random().toString(36).slice(2,10)}`}var toe=B(T(),1),k_="3.7.8",lM=k_,xf=typeof Buffer=="function",$_=typeof TextDecoder=="function"?new TextDecoder:void 0,T_=typeof TextEncoder=="function"?new TextEncoder:void 0,fM="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Nd=Array.prototype.slice.call(fM),j1=(e=>{let t={};return e.forEach((r,n)=>t[r]=n),t})(Nd),hM=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,kn=String.fromCharCode.bind(String),P_=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):e=>new Uint8Array(Array.prototype.slice.call(e,0)),O_=e=>e.replace(/=/g,"").replace(/[+\/]/g,t=>t=="+"?"-":"_"),N_=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),L_=e=>{let t,r,n,i,o="",s=e.length%3;for(let a=0;a255||(n=e.charCodeAt(a++))>255||(i=e.charCodeAt(a++))>255)throw new TypeError("invalid character found");t=r<<16|n<<8|i,o+=Nd[t>>18&63]+Nd[t>>12&63]+Nd[t>>6&63]+Nd[t&63]}return s?o.slice(0,s-3)+"===".substring(s):o},Ay=typeof btoa=="function"?e=>btoa(e):xf?e=>Buffer.from(e,"binary").toString("base64"):L_,Ey=xf?e=>Buffer.from(e).toString("base64"):e=>{let r=[];for(let n=0,i=e.length;nt?O_(Ey(e)):Ey(e),dM=e=>{if(e.length<2){var t=e.charCodeAt(0);return t<128?e:t<2048?kn(192|t>>>6)+kn(128|t&63):kn(224|t>>>12&15)+kn(128|t>>>6&63)+kn(128|t&63)}else{var t=65536+(e.charCodeAt(0)-55296)*1024+(e.charCodeAt(1)-56320);return kn(240|t>>>18&7)+kn(128|t>>>12&63)+kn(128|t>>>6&63)+kn(128|t&63)}},pM=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,U_=e=>e.replace(pM,dM),x_=xf?e=>Buffer.from(e,"utf8").toString("base64"):T_?e=>Ey(T_.encode(e)):e=>Ay(U_(e)),Pf=(e,t=!1)=>t?O_(x_(e)):x_(e),R_=e=>Pf(e,!0),mM=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,gM=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 kn((r>>>10)+55296)+kn((r&1023)+56320);case 3:return kn((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return kn((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},H_=e=>e.replace(mM,gM),M_=e=>{if(e=e.replace(/\s+/g,""),!hM.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(e.length&3));let t,r,n,i=[];for(let o=0;o>16&255)):n===64?i.push(kn(t>>16&255,t>>8&255)):i.push(kn(t>>16&255,t>>8&255,t&255));return i.join("")},Sy=typeof atob=="function"?e=>atob(N_(e)):xf?e=>Buffer.from(e,"base64").toString("binary"):M_,q_=xf?e=>P_(Buffer.from(e,"base64")):e=>P_(Sy(e).split("").map(t=>t.charCodeAt(0))),j_=e=>q_(K_(e)),vM=xf?e=>Buffer.from(e,"base64").toString("utf8"):$_?e=>$_.decode(q_(e)):e=>H_(Sy(e)),K_=e=>N_(e.replace(/[-_]/g,t=>t=="-"?"+":"/")),by=e=>vM(K_(e)),wM=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)},V_=e=>({value:e,enumerable:!1,writable:!0,configurable:!0}),z_=function(){let e=(t,r)=>Object.defineProperty(String.prototype,t,V_(r));e("fromBase64",function(){return by(this)}),e("toBase64",function(t){return Pf(this,t)}),e("toBase64URI",function(){return Pf(this,!0)}),e("toBase64URL",function(){return Pf(this,!0)}),e("toUint8Array",function(){return j_(this)})},G_=function(){let e=(t,r)=>Object.defineProperty(Uint8Array.prototype,t,V_(r));e("toBase64",function(t){return K1(this,t)}),e("toBase64URI",function(){return K1(this,!0)}),e("toBase64URL",function(){return K1(this,!0)})},yM=()=>{z_(),G_()},_t={version:k_,VERSION:lM,atob:Sy,atobPolyfill:M_,btoa:Ay,btoaPolyfill:L_,fromBase64:by,toBase64:Pf,encode:Pf,encodeURI:R_,encodeURL:R_,utob:U_,btou:H_,decode:by,isValid:wM,fromUint8Array:K1,toUint8Array:j_,extendString:z_,extendUint8Array:G_,extendBuiltins:yM};var rc=typeof $task<"u",Ja=typeof $loon<"u",nc=typeof $httpClient<"u"&&!Ja,qo=eval('typeof process !== "undefined"'),Y_=typeof $environment<"u"&&$environment["stash-version"],W_=typeof $rocket<"u",EM=typeof Egern<"u"&&Egern.version,bM=typeof $native<"u",sc=typeof $Plugins<"u";function V1(e){return e!==null&&typeof e=="object"&&[null,Object.prototype].includes(Object.getPrototypeOf(e))}function AM(e){let[t,r,n,i,o,s,a]=e.match(/^socks5:\/\/(?:(.*?):(.*?)@)?(.*?)(?::(\d+?))?(\?.*?)?(?:#(.*?))?$/);if(o)o=parseInt(o,10);else throw $.error(`port is not present in line: ${e}`),new Error(`port is not present in line: ${e}`);return{type:5,host:i,port:o,userId:r!=null?decodeURIComponent(r):void 0,password:n!=null?decodeURIComponent(n):void 0}}function SM(e){let t=[],r=!1;for(let[n,i]of Object.entries(e||{})){let o=n.toLowerCase();o==="accept"&&(r=!0,i==null)||t.push([o,i])}return r||t.push(["accept","*/*"]),Object.fromEntries(t)}var z1=class{constructor(name="untitled",debug=!1){if(this.name=name,this.debug=debug,this.http=Za(),this.env=An(),qo){let dotenv=eval('require("dotenv")');dotenv.config()}this.node=(()=>{if(qo){let fs=eval("require('fs')");return{fs}}else return null})(),this.initCache(),F_(this);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(rc&&(this.cache=JSON.parse($prefs.valueForKey(this.name)||"{}")),(Ja||nc)&&(this.cache=JSON.parse($persistentStore.read(this.name)||"{}")),sc&&(this.cache=JSON.parse($Plugins.SubStoreCache.get(this.name)||"{}")),qo){let basePath=eval("process.env.SUB_STORE_DATA_BASE_PATH")||".",rootPath=`${basePath}/root.json`,backupRootPath=`${basePath}/root_${Date.now()}.json`;if(this.log(`Root path: ${rootPath}`),this.node.fs.existsSync(rootPath))try{this.root=JSON.parse(this.node.fs.readFileSync(`${rootPath}`))}catch(e){this.node.fs.copyFileSync(rootPath,backupRootPath),this.error(`Failed to parse ${rootPath}: ${e.message}. Backup created at ${backupRootPath}`)}V1(this.root)||(this.node.fs.writeFileSync(rootPath,JSON.stringify({}),{flag:"w"}),this.root={});let fpath=`${basePath}/${this.name}.json`,backupPath=`${basePath}/${this.name}_${Date.now()}.json`;if(this.log(`Data path: ${fpath}`),this.node.fs.existsSync(fpath))try{if(this.cache=JSON.parse(this.node.fs.readFileSync(`${fpath}`,"utf-8")),!V1(this.cache))throw new Error("Invalid Data")}catch{try{let t=_t.decode(this.node.fs.readFileSync(`${fpath}`,"utf-8"));if(this.cache=JSON.parse(t),this.node.fs.writeFileSync(fpath,t,{flag:"w"}),!V1(this.cache))throw new Error("Invalid Data")}catch(t){this.node.fs.copyFileSync(fpath,backupPath),this.error(`Failed to parse ${fpath}: ${t.message}. Backup created at ${backupPath}`)}}V1(this.cache)||(this.node.fs.writeFileSync(fpath,JSON.stringify({}),{flag:"w"}),this.cache={})}}persistCache(){let data=JSON.stringify(this.cache,null,2);if(rc&&$prefs.setValueForKey(data,this.name),(Ja||nc)&&$persistentStore.write(data,this.name),sc&&$Plugins.SubStoreCache.set(this.name,data),qo){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),nc||Ja)return $persistentStore.write(e,t);if(rc)return $prefs.setValueForKey(e,t);if(qo&&(this.root[t]=e),sc)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),nc||Ja)return $persistentStore.read(e);if(rc)return $prefs.valueForKey(e);if(qo)return this.root[e];if(sc)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),nc||Ja)return $persistentStore.write(null,e);if(rc)return $prefs.removeValueForKey(e);if(qo&&delete this.root[e],sc)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(rc&&$notify(title,subtitle,content,options),nc&&$notification.post(title,subtitle,content+`${mediaURL?` \u591A\u5A92\u4F53:`+mediaURL:""}`,{url:openURL}),Ja){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(qo){let content_=content+(openURL?` \u70B9\u51FB\u8DF3\u8F6C: ${openURL}`:"")+(mediaURL?` \u591A\u5A92\u4F53: ${mediaURL}`:"");console.log(`[Notify] ${title} ${subtitle} ${content_} `);let push=eval("process.env.SUB_STORE_PUSH_SERVICE");if(push)if(/^https?:\/\//.test(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(` `)));Za().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}`)})}else{let{execFile}=eval('require("child_process")');execFile("shoutrrr",["send","--url",push,"--message",`${title} ${subtitle} ${content_}`],(e,t,r)=>{if(e){console.log(`[Push Service] URL: ${push} ERROR: ${e}`);return}r&&console.log(`[Push Service] URL: ${push} stderr: ${r}`),console.log(`[Push Service] URL: ${push} stdout: ${t}`)})}}sc&&$Plugins.Notify(title,subtitle+` `+content)}log(e){this.debug&&console.log(`[${this.name}] LOG: ${e}`)}info(e){console.log(`[${this.name}] INFO: ${e}`)}warn(e){console.log(`[${this.name}] WARN: ${e}`)}error(e){console.log(`[${this.name}] ERROR: ${e}`)}wait(e){return new Promise(t=>setTimeout(t,e))}done(e={}){rc||Ja||nc||sc?$done(e):qo&&typeof $context<"u"&&($context.headers=e.headers,$context.statusCode=e.statusCode,$context.body=e.body)}};function An(){return{isQX:rc,isLoon:Ja,isSurge:nc,isNode:qo,isStash:Y_,isShadowRocket:W_,isEgern:EM,isLanceX:bM,isGUIforCores:sc}}function Za(defaultOptions={baseURL:""}){let{isQX,isLoon,isSurge,isNode,isGUIforCores}=An(),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;if(isQX)worker=$task.fetch({method,url:options.url,headers:options.headers,body:options.body,opts:options.opts});else if(isLoon||isSurge||isNode){let run=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||Y_||W_)&&(opts.timeout=Math.ceil(opts.timeout/1e3),e="s")}if(isNode){let undici=eval("require('undici')"),{socksDispatcher}=eval("require('fetch-socks')"),defaultMaxHeaderSize=32*1024,parsedMaxHeaderSize=Number.parseInt(eval("process.env.SUB_STORE_MAX_HEADER_SIZE"),10),maxHeaderSize=Number.isInteger(parsedMaxHeaderSize)&&parsedMaxHeaderSize>0?parsedMaxHeaderSize:defaultMaxHeaderSize,{ProxyAgent,EnvHttpProxyAgent,request,interceptors}=undici,allowH2=opts.allowH2!==!1,agentOpts={connect:{rejectUnauthorized:!(opts.strictSSL===!1||opts.insecure===!0||opts.rejectUnauthorized===!1),allowH2},bodyTimeout:opts.timeout,headersTimeout:opts.timeout,maxHeaderSize,allowH2},tlsOptions={rejectUnauthorized:agentOpts.connect.rejectUnauthorized,allowH2};opts.tls={...opts.tls||{},...tlsOptions};try{let url=new URL(opts.url);(url.username||url.password)&&(opts.headers={...opts.headers||{},Authorization:`Basic ${Buffer.from(`${url.username||""}:${url.password||""}`).toString("base64")}`}),opts.headers=SM(opts.headers);let dispatcher;if(!opts.proxy){let allProxy=eval("process.env.all_proxy")||eval("process.env.ALL_PROXY");allProxy&&/^socks5:\/\//.test(allProxy)&&(opts.proxy=allProxy)}opts.proxy?/^socks5:\/\//.test(opts.proxy)?dispatcher=socksDispatcher(AM(opts.proxy),{...agentOpts,requestTls:tlsOptions}):dispatcher=new ProxyAgent({...agentOpts,uri:opts.proxy,requestTls:tlsOptions,proxyTunnel:opts.proxyTunnel}):dispatcher=new EnvHttpProxyAgent({...agentOpts,requestTls:tlsOptions,proxyTunnel:opts.proxyTunnel});let response=await request(opts.url,{...opts,method:method.toUpperCase(),dispatcher:dispatcher.compose(interceptors.redirect({maxRedirections:3,throwOnMaxRedirect:!0}))});resolve({statusCode:response.statusCode,headers:response.headers,body:opts.encoding===null?await response.body.arrayBuffer():await response.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})})};worker=new Promise((e,t)=>{run(e,t).catch(t)})}else isGUIforCores&&(worker=new Promise(async(e,t)=>{try{let r=await $Plugins.Requests({method,url:options.url,headers:options.headers,body:options.body,autoTransformBody:!1,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,request=timer?Promise.race([timer,worker]):worker;return request.finally(()=>{timer&&typeof clearTimeout<"u"&&clearTimeout(timeoutid)}).then(e=>events.onResponse(e))}let http={request:e=>send(e.method||"GET",e)};return methods.forEach(e=>http[e.toLowerCase()]=t=>send(e,t)),http}var CM=new z1("sub-store"),H=CM;function Rf(){_M()}function _M(){let e=H.read(gy);e||DM(),e!=="2.0"&&H.write("2.0",gy)}function DM(){H.info("Start migrating...");let e=H.read(Er)||{},t=Object.values(e).map(v=>(v.source=v.source||"remote",p(v),d(v),v));H.write(t,Er);let r=H.read(pr)||{},n=Object.values(r).map(v=>(delete v.ua,p(v),d(v),v));H.write(n,pr);let i=H.read(Wt)||{},o=Object.values(i);H.write(o,Wt);let s=H.read(kd)||{},a=Object.values(s);H.write(a,kd);let u=H.read(Mt)||{},l=Object.values(u);H.write(l,Mt);let f=H.read(rn)||{},m=Object.values(f);H.write(m,rn),delete H.cache.builtin,H.info("Migration complete!");function p(v){let g=v["display-name"];g&&(v.displayName=g,delete v["display-name"])}function d(v){let g=v.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 E of g)if(E.type){if(E.type==="Useless Filter")w.args.useless="ENABLED";else if(E.type==="Set Property Operator"){let{key:S,value:D}=E.args;switch(S){case"udp":w.args.udp=D?"ENABLED":"DISABLED";break;case"tfo":w.args.tfo=D?"ENABLED":"DISABLED";break;case"skip-cert-verify":w.args.scert=D?"ENABLED":"DISABLED";break;case"aead":w.args["vmess aead"]=D?"ENABLED":"DISABLED";break}}else if(E.type.indexOf("Keyword")===-1)if(E.type==="Flag Operator"){let S=typeof E.args>"u"?!0:E.args;E.args={mode:S?"add":"remove"},y.push(E)}else y.push(E)}y.unshift(w),v.process=y}}var yoe=B(T());var moe=B(T()),Q_="SUB_STORE_CORS_ALLOWED_ORIGINS",FM="*",IM="https://sub-store.vercel.app,http://substore.stash,https://substore.stash",X_="cors",kf="*";function BM(e){if(e==null||e==="")return{};if(typeof e=="object")return e;let t=G1(`${e}`.trim());return Object.fromEntries(t.split("&").filter(Boolean).map(r=>{let[n,...i]=r.split("=");return[G1(Z_(n).trim()),G1(Z_(i.join("=").trim()))]}))}function $M({isNode:e,envValue:t,argument:r}={}){let n=e?FM:IM,i=e?t:BM(r)?.[X_],o=i!=null&&`${i}`.trim()!=="",s=o?i:n,a=o?e?`env:${Q_}`:`argument:${X_}`:e?"default:node":"default:non-node",u=J_(s,a);return!u.wildcard&&u.origins.length===0?J_(n,e?"default:node":"default:non-node"):u}function e8({isNode:e}={}){return $M({isNode:e,envValue:e?TM():void 0,argument:e?void 0:PM()})}function Cy(e,t){if(!t||e?.wildcard)return!0;let r=_y(t);return e?.origins?.includes(r)}function t8(e,t){return e?.wildcard?{"Access-Control-Allow-Origin":kf}:!t||!Cy(e,t)?{}:{"Access-Control-Allow-Origin":_y(t),Vary:"Origin"}}function r8(e){return`${e?.wildcard?kf:e?.origins?.join(",")||""} (${e?.source})`}function J_(e,t){let r=`${e}`.split(/[,,\s]+/).map(i=>i.trim()).filter(Boolean);if(r.includes(kf))return{wildcard:!0,origins:[],source:t,value:kf};let n=[...new Set(r.map(_y))];return{wildcard:!1,origins:n,source:t,value:n.join(",")}}function _y(e){let t=G1(`${e}`.trim());if(t===kf)return kf;try{return new URL(t).origin}catch{return t}}function TM(){try{return eval(`process.env.${Q_}`)}catch{return}}function PM(){try{if(typeof $argument<"u")return $argument}catch{return}}function Z_(e){try{return decodeURIComponent(e)}catch{return e}}function G1(e){return e.replace(/^["']|["']$/g,"")}function Dy({substore:$,port,host}){let{isNode}=An(),corsPolicy=e8({isNode});$.info(`[CORS] allowed origins: ${r8(corsPolicy)}`);let DEFAULT_HEADERS={"Content-Type":"text/plain;charset=UTF-8","Access-Control-Allow-Methods":"POST,GET,OPTIONS,PATCH,PUT,DELETE","Access-Control-Allow-Headers":"Origin, X-Requested-With, Content-Type, Accept","X-Powered-By":isNode&&eval("process.env.SUB_STORE_X_POWERED_BY")||"Sub-Store"};if(isNode){let express_=eval('require("express")'),bodyParser=eval('require("body-parser")'),app=express_(),limit=eval("process.env.SUB_STORE_BODY_JSON_LIMIT")||"1mb";return $.info(`[BACKEND] body JSON limit: ${limit}`),app.use((e,t,r)=>{let n=t.setHeader.bind(t);t.setHeader=function(i,o){function s(a){if(typeof a!="string")return a;if(["profile-web-page-url"].includes(i.toLowerCase()))try{return new URL(a).href}catch{return a}return a}try{return Array.isArray(o)?o=o.map(s):o=s(o),n(i,o)}catch{return console.log(`Invalid header ignored ${i}: ${o}`),this}},r()}),app.use((e,t,r)=>{let n=applyCors(e.headers?.origin,e.method);if(t.set({...DEFAULT_HEADERS,...n.headers}),!n.allowed){t.status(403).end("CORS origin not allowed");return}if(n.preflight){t.status(200).end();return}r()}),app.use(bodyParser.json({verify:rawBodySaver,limit})),app.use(bodyParser.urlencoded({verify:rawBodySaver,extended:!0})),app.use(bodyParser.raw({verify:rawBodySaver,type:"*/*"})),app.start=()=>{app.get("*",function(t,r){r.status(404).end()});let e=app.listen(port,host,()=>{let{address:t,port:r}=e.address();$.info(`[BACKEND] listening on ${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:o}=e;i=xM(i),/json/i.test(i["content-type"])&&(o=JSON.parse(o)),r=r.toUpperCase();let{path:s,query:a}=kM(n),u=applyCors(i.origin,r);if(!u.allowed){Response().status(403).send("CORS origin not allowed");return}if(u.preflight){Response(u.headers).status(200).end();return}let l=null,f,m=0;for(f=t;fm&&(l=handlers[f],m=p.split("/").length)}if(l){let p=()=>{dispatch(r,n,f)},d={method:r,url:n,path:s,query:a,params:n8(l.pattern,s),headers:i,body:o},v=Response(u.headers),g=l.callback,y=w=>{v.status(500).json({status:"failed",message:`Internal Server Error: ${w}`})};if(g.constructor.name==="AsyncFunction")g(d,v,p).catch(y);else try{g(d,v,p)}catch(w){y(w)}}else Response(u.headers).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(e={}){let t=200,{isQX:r,isLoon:n,isSurge:i,isGUIforCores:o}=An(),s={...DEFAULT_HEADERS,...e},a={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",403:"HTTP/1.1 403 Forbidden",404:"HTTP/1.1 404 Not Found",500:"HTTP/1.1 500 Internal Server Error"};return new class{status(u){return t=u,this}send(u=""){let l={status:r?a[t]:t,body:u,headers:s};r||o?$done(l):(n||i)&&$done({response:l})}end(){this.send()}html(u){this.set("Content-Type","text/html;charset=UTF-8"),this.send(u)}json(u){this.set("Content-Type","application/json;charset=UTF-8"),this.send(JSON.stringify(u))}set(u,l){return s[u]=l,this}removeHeader(u){return delete s[u],this}}}function applyCors(e,t){let r=Cy(corsPolicy,e);return{allowed:r,preflight:!!e&&r&&t?.toUpperCase()==="OPTIONS",headers:r?t8(corsPolicy,e):{}}}}function xM(e){let t={};for(let r of Object.keys(e))t[r.toLowerCase()]=e[r];return t}function RM(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 s8(e,t,r="name"){return e.findIndex(n=>n[r]===t)}function jo(e,t,r="name"){let n=s8(e,t,r);e.splice(n,1)}function $i(e,t,r,n="name"){let i=s8(e,t,n);e[i]=r}function Ko(e,t,r="bottom"){if(r==="top"){e.unshift(t);return}e.push(t)}var Doe=B(T());function Vo(){return H.read(Bt)?.appearanceSetting?.createItemPosition==="top"?"top":"bottom"}var Roe=B(T());var Ioe=B(T()),Of=class{constructor(t,r,n){this.code=t,this.message=r,this.details=n}},Pr=class extends Of{constructor(t,r,n){super(t,r,n),this.type="InternalServerError"}},Ke=class extends Of{constructor(t,r,n){super(t,r,n),this.type="RequestInvalidError"}},Ot=class extends Of{constructor(t,r,n){super(t,r,n),this.type="ResourceNotFoundError"}},Y1=class extends Of{constructor(t,r,n){super(t,r,n),this.type="NetworkError"}};function i8(e){if(e!==void 0)return JSON.parse(JSON.stringify(e))}function wl(){let e=H.read(U1);if(Array.isArray(e))return e;let t=[];return H.write(t,U1),t}function o8(){return wl()}function Fy(e){H.write(e,U1)}function OM(){return`${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function NM(e){let t=wl(),r={id:OM(),archivedAt:Date.now(),...e};return t.unshift(r),Fy(t),r}function LM(e){return wl().find(t=>t.id===e)}function Iy(e){let t=LM(e);if(!t)throw new Ot("ARCHIVE_ENTRY_NOT_FOUND",`Archive entry ${e} does not exist`);return t}function By(e){let t=wl(),r=t.findIndex(i=>i.id===e);if(r===-1)throw new Ot("ARCHIVE_ENTRY_NOT_FOUND",`Archive entry ${e} does not exist`);let[n]=t.splice(r,1);return Fy(t),n}function a8(e){if(!Array.isArray(e))throw new Ke("INVALID_SORT_PAYLOAD","Archive sort payload must be an array of ids");let t=wl(),r=new Map(e.map((n,i)=>[n,i]));return t.sort((n,i)=>{let o=r.has(n.id)?r.get(n.id):Number.MAX_SAFE_INTEGER,s=r.has(i.id)?r.get(i.id):Number.MAX_SAFE_INTEGER;return o-s}),Fy(t),t}function Ld(e,t,r={}){return NM({itemType:e,name:t.name,displayName:t.displayName,remark:t.remark,tag:i8(t.tag),snapshot:i8(t),...r})}function u8(e){let t=H.read(Er)||[],r=$t(t,e);if(!r)throw new Ot("RESOURCE_NOT_FOUND",`Subscription ${e} does not exist!`);return Ld("sub",r)}function c8(e){let t=H.read(pr)||[],r=$t(t,e);if(!r)throw new Ot("RESOURCE_NOT_FOUND",`Collection ${e} does not exist!`);return Ld("col",r)}function l8(e){let t=H.read(Mt)||[],r=$t(t,e);if(!r)throw new Ot("RESOURCE_NOT_FOUND",`File ${e} does not exist!`);return Ld("file",r)}function f8(e){let t=H.read(Wt)||[],r=$t(t,e);if(!r)throw new Ot("RESOURCE_NOT_FOUND",`Artifact ${e} does not exist!`);return Ld("artifact",r)}function h8(e,t,r){let i=(H.read(rn)||[]).find(o=>o.token===e&&o.type===t&&o.name===r);if(!i)throw new Ot("RESOURCE_NOT_FOUND",`Share ${t}/${r}/${e} does not exist!`);return Ld("share",i,{shareType:i.type})}var Ooe=B(T());function Ze(e,t,r){e.status(r||200).json({status:"success",data:t})}function Je(e,t,r){e.status(r||500).json({status:"failed",error:{code:t.code,type:t.type,message:t.message,details:e.req?.route?.path?.startsWith("/share/")?"\u8BE6\u60C5\u8BF7\u67E5\u770B\u65E5\u5FD7":t.details}})}var iae=B(T()),nm=B(_8()),lq=/^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)(\.(?!$)|$)){4}$/,fq=/^(([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 Gr(e){return lq.test(e)}function _r(e){return fq.test(e)}function D8(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 nt(e){return typeof e=="string"&&e.trim().length>0}function Vt(e,t){return nt(e)?e:t}function Hf(e){return typeof e<"u"&&e!==null}function eu(e,t){return Hf(e)?e:t}function tu(e){return e?/^.+?\s*?=\s*?.+?\s*?,.+?/.test(e)?{"policy-descriptor":e}:{policy:e}:{}}function hq(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e}function Md(e){let t=e.split(/,|\//),r=t[Math.floor(Math.random()*t.length)];if(r.includes("-")){let[n,i]=r.split("-").map(Number);return hq(n,i)}else return Number(r)}function F8(e){return Number.isSafeInteger(e)?String(e):BigInt(e).toString()}function sm(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 ic(e,t="YYYY-MM-DD_HH-mm-ss"){let r=e instanceof Date?e:new Date(e);if(isNaN(r.getTime()))return"";let n=o=>String(o).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,o=>i[o])}function gt(e){return e!==null&&typeof e=="object"&&[null,Object.prototype].includes(Object.getPrototypeOf(e))}var Nfe=B(T());var xfe=B(T(),1);var lae=B(T(),1);var aae=B(T(),1);function My(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Yr(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(`${r}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw new RangeError(`${r}expected integer >= 0, got ${e}`)}}function On(e,t,r=""){let n=My(e),i=e?.length,o=t!==void 0;if(!n||o&&i!==t){let s=r&&`"${r}" `,a=o?` of length ${t}`:"",u=n?`length=${i}`:`type=${typeof e}`,l=s+"expected Uint8Array"+a+", got "+u;throw n?new RangeError(l):new TypeError(l)}return e}function nu(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("Hash must wrapped by utils.createHasher");if(Yr(e.outputLen),Yr(e.blockLen),e.outputLen<1)throw new Error('"outputLen" must be >= 1');if(e.blockLen<1)throw new Error('"blockLen" must be >= 1')}function Mf(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function im(e,t){On(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length='+r)}function om(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Bs(...e){for(let t=0;t>>t}function Jt(e,t){return e<>>32-t>>>0}var dq=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function pq(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function mq(e){for(let t=0;te:mq,B8=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",gq=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function am(e){if(On(e),B8)return e.toHex();let t="";for(let r=0;r=ru._0&&e<=ru._9)return e-ru._0;if(e>=ru.A&&e<=ru.F)return e-(ru.A-10);if(e>=ru.a&&e<=ru.f)return e-(ru.a-10)}function qd(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);if(B8)try{return Uint8Array.fromHex(e)}catch(i){throw i instanceof SyntaxError?new RangeError(i.message):i}let t=e.length,r=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let i=0,o=0;ie(o).update(i).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=i=>e(i),Object.assign(r,t),Object.freeze(r)}function Xo(e=32){Yr(e,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var zy=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var cm=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(t,r){if(nu(t),On(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,i=new Uint8Array(n);i.set(r.length>n?t.create().update(r).digest():r);for(let o=0;o{let e=(t,r,n)=>new cm(t,r).update(n).digest();return e.create=(t,r)=>new cm(t,r),e})();var pae=B(T(),1);function jd(e,t,r){return nu(e),r===void 0&&(r=new Uint8Array(e.outputLen)),Jo(e,r,t)}var Gy=Uint8Array.of(0),$8=Uint8Array.of();function Yy(e,t,r,n=32){nu(e),Yr(n,"length"),On(t,void 0,"prk");let i=e.outputLen;if(t.length255*i)throw new Error("Length must be <= 255*HashLen");let o=Math.ceil(n/i);r===void 0?r=$8:On(r,void 0,"info");let s=new Uint8Array(o*i),a=Jo.create(e,t),u=a._cloneInto(),l=new Uint8Array(a.outputLen);for(let f=0;fYy(e,jd(e,t,r),n,i);var Cae=B(T(),1);var vae=B(T(),1);function T8(e,t,r){return e&t^~e&r}function P8(e,t,r){return e&t^e&r^t&r}var Kd=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,r,n,i){this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.buffer=new Uint8Array(t),this.view=qf(this.buffer)}update(t){Mf(this),On(t);let{view:r,buffer:n,blockLen:i}=this,o=t.length;for(let s=0;si-s&&(this.process(n,0),s=0);for(let m=s;mf.length)throw new Error("_sha2: outputLen bigger than state");for(let m=0;m>x8&lm)}:{h:Number(e>>x8&lm)|0,l:Number(e&lm)|0}}function R8(e,t=!1){let r=e.length,n=new Uint32Array(r),i=new Uint32Array(r);for(let o=0;oe>>>r,Xy=(e,t,r)=>e<<32-r|t>>>r,bl=(e,t,r)=>e>>>r|t<<32-r,Al=(e,t,r)=>e<<32-r|t>>>r,Vd=(e,t,r)=>e<<64-r|t>>>r-32,zd=(e,t,r)=>e>>>r-32|t<<64-r;function Zo(e,t,r,n){let i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:i|0}}var k8=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),O8=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,N8=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),L8=(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0,U8=(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0),H8=(e,t,r,n,i,o)=>t+r+n+i+o+(e/2**32|0)|0;var Eq=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ac=new Uint32Array(64),Jy=class extends Kd{constructor(t){super(64,t,8,!1)}get(){let{A:t,B:r,C:n,D:i,E:o,F:s,G:a,H:u}=this;return[t,r,n,i,o,s,a,u]}set(t,r,n,i,o,s,a,u){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=u|0}process(t,r){for(let m=0;m<16;m++,r+=4)ac[m]=t.getUint32(r,!1);for(let m=16;m<64;m++){let p=ac[m-15],d=ac[m-2],v=ro(p,7)^ro(p,18)^p>>>3,g=ro(d,17)^ro(d,19)^d>>>10;ac[m]=g+ac[m-7]+v+ac[m-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:u,G:l,H:f}=this;for(let m=0;m<64;m++){let p=ro(a,6)^ro(a,11)^ro(a,25),d=f+p+T8(a,u,l)+Eq[m]+ac[m]|0,g=(ro(n,2)^ro(n,13)^ro(n,22))+P8(n,i,o)|0;f=l,l=u,u=a,a=s+d|0,s=o,o=i,i=n,n=d+g|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,u=u+this.F|0,l=l+this.G|0,f=f+this.H|0,this.set(n,i,o,s,a,u,l,f)}roundClean(){Bs(ac)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Bs(this.buffer)}},Zy=class extends Jy{A=su[0]|0;B=su[1]|0;C=su[2]|0;D=su[3]|0;E=su[4]|0;F=su[5]|0;G=su[6]|0;H=su[7]|0;constructor(){super(32)}};var M8=R8(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),bq=M8[0],Aq=M8[1],uc=new Uint32Array(80),cc=new Uint32Array(80),Qy=class extends Kd{constructor(t){super(128,t,16,!1)}get(){let{Ah:t,Al:r,Bh:n,Bl:i,Ch:o,Cl:s,Dh:a,Dl:u,Eh:l,El:f,Fh:m,Fl:p,Gh:d,Gl:v,Hh:g,Hl:y}=this;return[t,r,n,i,o,s,a,u,l,f,m,p,d,v,g,y]}set(t,r,n,i,o,s,a,u,l,f,m,p,d,v,g,y){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=o|0,this.Cl=s|0,this.Dh=a|0,this.Dl=u|0,this.Eh=l|0,this.El=f|0,this.Fh=m|0,this.Fl=p|0,this.Gh=d|0,this.Gl=v|0,this.Hh=g|0,this.Hl=y|0}process(t,r){for(let S=0;S<16;S++,r+=4)uc[S]=t.getUint32(r),cc[S]=t.getUint32(r+=4);for(let S=16;S<80;S++){let D=uc[S-15]|0,F=cc[S-15]|0,M=bl(D,F,1)^bl(D,F,8)^Wy(D,F,7),z=Al(D,F,1)^Al(D,F,8)^Xy(D,F,7),C=uc[S-2]|0,P=cc[S-2]|0,U=bl(C,P,19)^Vd(C,P,61)^Wy(C,P,6),k=Al(C,P,19)^zd(C,P,61)^Xy(C,P,6),O=N8(z,k,cc[S-7],cc[S-16]),q=L8(O,M,U,uc[S-7],uc[S-16]);uc[S]=q|0,cc[S]=O|0}let{Ah:n,Al:i,Bh:o,Bl:s,Ch:a,Cl:u,Dh:l,Dl:f,Eh:m,El:p,Fh:d,Fl:v,Gh:g,Gl:y,Hh:w,Hl:E}=this;for(let S=0;S<80;S++){let D=bl(m,p,14)^bl(m,p,18)^Vd(m,p,41),F=Al(m,p,14)^Al(m,p,18)^zd(m,p,41),M=m&d^~m&g,z=p&v^~p&y,C=U8(E,F,z,Aq[S],cc[S]),P=H8(C,w,D,M,bq[S],uc[S]),U=C|0,k=bl(n,i,28)^Vd(n,i,34)^Vd(n,i,39),O=Al(n,i,28)^zd(n,i,34)^zd(n,i,39),q=n&o^n&a^o&a,N=i&s^i&u^s&u;w=g|0,E=y|0,g=d|0,y=v|0,d=m|0,v=p|0,{h:m,l:p}=Zo(l|0,f|0,P|0,U|0),l=a|0,f=u|0,a=o|0,u=s|0,o=n|0,s=i|0;let _=k8(U,O,N);n=O8(_,P,k,q),i=_|0}({h:n,l:i}=Zo(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:s}=Zo(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l:u}=Zo(this.Ch|0,this.Cl|0,a|0,u|0),{h:l,l:f}=Zo(this.Dh|0,this.Dl|0,l|0,f|0),{h:m,l:p}=Zo(this.Eh|0,this.El|0,m|0,p|0),{h:d,l:v}=Zo(this.Fh|0,this.Fl|0,d|0,v|0),{h:g,l:y}=Zo(this.Gh|0,this.Gl|0,g|0,y|0),{h:w,l:E}=Zo(this.Hh|0,this.Hl|0,w|0,E|0),this.set(n,i,o,s,a,u,l,f,m,p,d,v,g,y,w,E)}roundClean(){Bs(uc,cc)}destroy(){this.destroyed=!0,Bs(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},eE=class extends Qy{Ah=Nn[0]|0;Al=Nn[1]|0;Bh=Nn[2]|0;Bl=Nn[3]|0;Ch=Nn[4]|0;Cl=Nn[5]|0;Dh=Nn[6]|0;Dl=Nn[7]|0;Eh=Nn[8]|0;El=Nn[9]|0;Fh=Nn[10]|0;Fl=Nn[11]|0;Gh=Nn[12]|0;Gl=Nn[13]|0;Hh=Nn[14]|0;Hl=Nn[15]|0;constructor(){super(64)}};var Wr=Vy(()=>new Zy,zy(1));var fm=Vy(()=>new eE,zy(3));var efe=B(T(),1);var Dae=B(T(),1);function sE(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Sq(e){if(!sE(e))throw new TypeError("Uint8Array expected")}function V8(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(r=>typeof r=="string"):t.every(r=>Number.isSafeInteger(r)):!1}function Cq(e){if(typeof e!="function")throw new TypeError("function expected");return!0}function Sl(e,t){if(typeof t!="string")throw new TypeError(`${e}: string expected`);return!0}function iE(e){if(typeof e!="number")throw new TypeError(`number expected, got ${typeof e}`);if(!Number.isSafeInteger(e))throw new RangeError(`invalid integer: ${e}`)}function tE(e){if(!Array.isArray(e))throw new TypeError("array expected")}function dm(e,t){if(!V8(!0,t))throw new TypeError(`${e}: array of strings expected`)}function z8(e,t){if(!V8(!1,t))throw new TypeError(`${e}: array of numbers expected`)}function oE(...e){let t=o=>o,r=(o,s)=>a=>o(s(a)),n=e.map(o=>o.encode).reduceRight(r,t),i=e.map(o=>o.decode).reduce(r,t);return{encode:n,decode:i}}function aE(e){let t=typeof e=="string"?e.split(""):e,r=t.length;dm("alphabet",t);let n=new Map(t.map((i,o)=>[i,o]));return{encode:i=>(tE(i),i.map(o=>{if(!Number.isSafeInteger(o)||o<0||o>=r)throw new Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${e}`);return t[o]})),decode:i=>(tE(i),i.map(o=>{Sl("alphabet.decode",o);let s=n.get(o);if(s===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return s}))}}function uE(e=""){return Sl("join",e),{encode:t=>(dm("join.decode",t),t.join(e)),decode:t=>(Sl("join.decode",t),t.split(e))}}function _q(e,t="="){return iE(e),Sl("padding",t),{encode(r){for(dm("padding.encode",r);r.length*e%8;)r.push(t);return r},decode(r){dm("padding.decode",r);let n=r.length;if(n*e%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;n>0&&r[n-1]===t;n--)if((n-1)*e%8===0)throw new Error("padding: invalid, string has too much padding");return r.slice(0,n)}}}var G8=(e,t)=>t===0?e:G8(t,e%t),pm=(e,t)=>e+(t-G8(e,t)),hm=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function rE(e,t,r,n){if(tE(e),t<=0||t>32)throw new RangeError(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw new RangeError(`convertRadix2: wrong to=${r}`);if(pm(t,r)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${pm(t,r)}`);let i=0,o=0,s=hm[t],a=hm[r]-1,u=[];for(let l of e){if(iE(l),l>=s)throw new Error(`convertRadix2: invalid data word=${l} from=${t}`);if(i=i<32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${t}`);for(o+=t;o>=r;o-=r)u.push((i>>o-r&a)>>>0);let f=hm[o];if(f===void 0)throw new Error("invalid carry");i&=f-1}if(i=i<=t)throw new Error("Excess padding");if(!n&&i>0)throw new Error(`Non-zero padding: ${i}`);return n&&o>0&&u.push(i>>>0),u}function cE(e,t=!1){if(iE(e),e<=0||e>32)throw new RangeError("radix2: bits should be in (0..32]");if(pm(8,e)>32||pm(e,8)>32)throw new RangeError("radix2: carry overflow");return{encode:r=>{if(!sE(r))throw new TypeError("radix2.encode input should be Uint8Array");return rE(Array.from(r),8,e,!t)},decode:r=>(z8("radix2.decode",r),Uint8Array.from(rE(r,e,8,t)))}}function q8(e){return Cq(e),function(...t){try{return e.apply(null,t)}catch{}}}var Dq=typeof Uint8Array.from([]).toBase64=="function"&&typeof Uint8Array.fromBase64=="function",Fq=/[\t\n\f\r ]/,Iq=(e,t)=>{Sl("base64",e);let r=t?"base64url":"base64";if(e.length>0&&Fq.test(e))throw new Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})},lE=Object.freeze(Dq?{encode(e){return Sq(e),e.toBase64()},decode(e){return Iq(e,!1)}}:oE(cE(6),aE("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),_q(6),uE(""))),ns=Object.freeze(oE(cE(6),aE("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),uE("")));var nE=oE(aE("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),uE("")),j8=[996825010,642813549,513874426,1027748829,705979059];function Gd(e){let t=e>>25,r=(e&33554431)<<5;for(let n=0;n>n&1)===1&&(r^=j8[n]);return r}function K8(e,t,r=1){let n=e.length,i=1;for(let o=0;o126)throw new Error(`Invalid prefix (${e})`);i=Gd(i)^s>>5}i=Gd(i);for(let o=0;od)throw new TypeError(`Length ${g} exceeds limit ${d}`);let y=m.toLowerCase(),w=K8(y,p,t);return`${y}1${nE.encode(p)}${w}`}function a(m,p=90){Sl("bech32.decode input",m);let d=m.length;if(d<8||p!==!1&&d>p)throw new TypeError(`invalid string length: ${d} (${m}). Expected (8..${p})`);let v=m.toLowerCase();if(m!==v&&m!==m.toUpperCase())throw new Error("String must be lowercase or uppercase");let g=v.lastIndexOf("1");if(g===0||g===-1)throw new Error('Letter "1" must be present between prefix and data only');let y=v.slice(0,g),w=v.slice(g+1);if(w.length<6)throw new Error("Data must be at least 6 characters long");let E=nE.decode(w).slice(0,-6),S=K8(y,E,t);if(!w.endsWith(S))throw new Error(`Invalid checksum in ${m}: expected "${S}"`);return{prefix:y,words:E}}let u=q8(a);function l(m){let{prefix:p,words:d}=a(m,!1);return{prefix:p,words:d,bytes:n(d)}}function f(m,p){return s(m,i(p))}return{encode:s,decode:a,encodeFromBytes:f,decodeToBytes:l,decodeUnsafe:u,fromWords:n,fromWordsUnsafe:o,toWords:i}}var Vs=Object.freeze(Bq("bech32"));var kae=B(T(),1);var $ae=B(T(),1);function Tq(e,t,r,n){nu(e);let i=um({dkLen:32,asyncTick:10},n),{c:o,dkLen:s,asyncTick:a}=i;if(Yr(o,"c"),Yr(s,"dkLen"),Yr(a,"asyncTick"),o<1)throw new Error("iterations (c) must be >= 1");if(s<1)throw new Error('"dkLen" must be >= 1');if(s>(2**32-1)*e.outputLen)throw new Error("derived key too long");let u=jy(t,"password"),l=jy(r,"salt"),f=new Uint8Array(s),m=Jo.create(e,u),p=m._cloneInto().update(l);return{c:o,dkLen:s,asyncTick:a,DK:f,PRF:m,PRFSalt:p}}function Pq(e,t,r,n,i){return e.destroy(),t.destroy(),n&&n.destroy(),Bs(i),r}function fE(e,t,r,n){let{c:i,dkLen:o,DK:s,PRF:a,PRFSalt:u}=Tq(e,t,r,n),l,f=new Uint8Array(4),m=qf(f),p=new Uint8Array(a.outputLen);for(let d=1,v=0;v0&&(s+=16),Y8(r,o,e,t+=16,r,s)}function xq(e,t,r){let n=um({dkLen:32,asyncTick:10,maxmem:1073742848},r),{N:i,r:o,p:s,dkLen:a,asyncTick:u,maxmem:l,onProgress:f}=n;if(Yr(i,"N"),Yr(o,"r"),Yr(s,"p"),Yr(a,"dkLen"),Yr(u,"asyncTick"),Yr(l,"maxmem"),f!==void 0&&typeof f!="function")throw new Error("progressCb must be a function");let m=128*o,p=m/4,d=Math.pow(2,32);if(i<=1||i&i-1||i>d)throw new Error('"N" expected a power of 2, and 2^1 <= N <= 2^32');if(s<1||s>(d-1)*32/m)throw new Error('"p" expected integer 1..((2^32 - 1) * 32) / (128 * r)');if(a<1||a>(d-1)*32)throw new Error('"dkLen" expected integer 1..(2^32 - 1) * 32');let v=m*(i+s+1);if(v>l)throw new Error('"maxmem" limit was hit: memUsed(128*r*(N+p+1))='+v+", maxmem="+l);let g=fE(Wr,e,t,{c:1,dkLen:m*s}),y=om(g),w=om(new Uint8Array(m*i)),E=om(new Uint8Array(m)),S=()=>{};if(f){let D=2*i*s,F=Math.max(Math.floor(D/1e4),1),M=0;S=()=>{M++,f&&(!(M%F)||M===D)&&f(M/D)}}return{N:i,r:o,p:s,dkLen:a,blockSize32:p,V:w,B32:y,B:g,tmp:E,blockMixCb:S,asyncTick:u}}function Rq(e,t,r,n,i){let o=fE(Wr,e,r,{c:1,dkLen:t});return Bs(r,n,i),o}function dE(e,t,r){let{N:n,r:i,p:o,dkLen:s,blockSize32:a,V:u,B32:l,B:f,tmp:m,blockMixCb:p}=xq(e,t,r);qy(l);for(let d=0;d>>0;for(let w=0;we<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;var Lq=e=>{for(let t=0;te:Lq;function X8(e,t){if(t==null||typeof t!="object")throw new Error("options must be defined");return Object.assign(e,t)}function J8(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;n[]),o=(a,u)=>n(u,...i(a)).update(a).digest(),s=n(new Uint8Array(e),...i(new Uint8Array(0)));return o.outputLen=s.outputLen,o.blockLen=s.blockLen,o.create=(a,...u)=>n(a,...u),o}var Q8=(e,t)=>{function r(n,...i){if(un(n,void 0,"key"),e.nonceLength!==void 0){let f=i[0];un(f,e.varSizeNonce?void 0:e.nonceLength,"nonce")}let o=e.tagLength;o&&i[1]!==void 0&&un(i[1],void 0,"AAD");let s=t(n,...i),a=(f,m)=>{if(m!==void 0){if(f!==2)throw new Error("cipher output not supported");un(m,void 0,"output")}},u=!1;return{encrypt(f,m){if(u)throw new Error("cannot encrypt() twice with same key + nonce");return u=!0,un(f),a(s.encrypt.length,m),s.encrypt(f,m)},decrypt(f,m){if(un(f),o&&f.lengthUint8Array.from(e.split(""),t=>t.charCodeAt(0)),Uq=iu(Qo(rD("expand 16-byte k"))),Hq=iu(Qo(rD("expand 32-byte k")));function Zt(e,t){return e<>>32-t}var Wd=64,Mq=16,mE=2**32-1,tD=Uint32Array.of();function qq(e,t,r,n,i,o,s,a){let u=i.length,l=new Uint8Array(Wd),f=Qo(l),m=Cl&&Kf(i)&&Kf(o),p=m?Qo(i):tD,d=m?Qo(o):tD;if(!Cl){for(let v=0;v=mE)throw new Error("arx: counter overflow");let g=Math.min(Wd,u-v);for(let y=0,w;y=mE)throw new Error("arx: counter overflow");let g=Math.min(Wd,u-v);if(m&&g===Wd){let y=v/4;if(v%4!==0)throw new Error("arx: invalid block position");for(let w=0,E;w{un(a,void 0,"key"),un(u,void 0,"nonce"),un(l,void 0,"data");let p=l.length;if(f=Yd(p,f,!1),jf(m),m<0||m>=mE)throw new Error("arx: counter overflow");let d=[],v=a.length,g,y;if(v===32)d.push(g=Vf(a)),y=Hq;else if(v===16&&r)g=new Uint8Array(32),g.set(a),g.set(a,16),y=Uq,d.push(g);else throw un(a,32,"arx key"),new Error("invalid key size");(!Cl||!Kf(u))&&d.push(u=Vf(u));let w=Qo(g);if(n){if(u.length!==24)throw new Error("arx: extended nonce must be 24 bytes");let D=u.subarray(0,16);if(Cl)n(y,w,Qo(D),w);else{let F=iu(Uint32Array.from(y));n(F,w,Qo(D),w),no(F),iu(w)}u=u.subarray(16)}else Cl||iu(w);let E=16-i;if(E!==u.length)throw new Error(`arx: nonce must be ${E} or 16 bytes`);if(E!==12){let D=new Uint8Array(12);D.set(u,o?0:12-u.length),u=D,d.push(u)}let S=iu(Qo(u));try{return qq(e,y,w,S,l,f,m,s),f}finally{no(...d)}}}var Yae=B(T(),1);function Ln(e,t){return e[t++]&255|(e[t++]&255)<<8}var gE=class{blockLen=16;outputLen=16;buffer=new Uint8Array(16);r=new Uint16Array(10);h=new Uint16Array(10);pad=new Uint16Array(8);pos=0;finished=!1;destroyed=!1;constructor(t){t=Vf(un(t,32,"key"));let r=Ln(t,0),n=Ln(t,2),i=Ln(t,4),o=Ln(t,6),s=Ln(t,8),a=Ln(t,10),u=Ln(t,12),l=Ln(t,14);this.r[0]=r&8191,this.r[1]=(r>>>13|n<<3)&8191,this.r[2]=(n>>>10|i<<6)&7939,this.r[3]=(i>>>7|o<<9)&8191,this.r[4]=(o>>>4|s<<12)&255,this.r[5]=s>>>1&8190,this.r[6]=(s>>>14|a<<2)&8191,this.r[7]=(a>>>11|u<<5)&8065,this.r[8]=(u>>>8|l<<8)&8191,this.r[9]=l>>>5&127;for(let f=0;f<8;f++)this.pad[f]=Ln(t,16+2*f)}process(t,r,n=!1){let i=n?0:2048,{h:o,r:s}=this,a=s[0],u=s[1],l=s[2],f=s[3],m=s[4],p=s[5],d=s[6],v=s[7],g=s[8],y=s[9],w=Ln(t,r+0),E=Ln(t,r+2),S=Ln(t,r+4),D=Ln(t,r+6),F=Ln(t,r+8),M=Ln(t,r+10),z=Ln(t,r+12),C=Ln(t,r+14),P=o[0]+(w&8191),U=o[1]+((w>>>13|E<<3)&8191),k=o[2]+((E>>>10|S<<6)&8191),O=o[3]+((S>>>7|D<<9)&8191),q=o[4]+((D>>>4|F<<12)&8191),N=o[5]+(F>>>1&8191),_=o[6]+((F>>>14|M<<2)&8191),R=o[7]+((M>>>11|z<<5)&8191),K=o[8]+((z>>>8|C<<8)&8191),Z=o[9]+(C>>>5|i),Y=0,te=Y+P*a+U*(5*y)+k*(5*g)+O*(5*v)+q*(5*d);Y=te>>>13,te&=8191,te+=N*(5*p)+_*(5*m)+R*(5*f)+K*(5*l)+Z*(5*u),Y+=te>>>13,te&=8191;let se=Y+P*u+U*a+k*(5*y)+O*(5*g)+q*(5*v);Y=se>>>13,se&=8191,se+=N*(5*d)+_*(5*p)+R*(5*m)+K*(5*f)+Z*(5*l),Y+=se>>>13,se&=8191;let fe=Y+P*l+U*u+k*a+O*(5*y)+q*(5*g);Y=fe>>>13,fe&=8191,fe+=N*(5*v)+_*(5*d)+R*(5*p)+K*(5*m)+Z*(5*f),Y+=fe>>>13,fe&=8191;let ve=Y+P*f+U*l+k*u+O*a+q*(5*y);Y=ve>>>13,ve&=8191,ve+=N*(5*g)+_*(5*v)+R*(5*d)+K*(5*p)+Z*(5*m),Y+=ve>>>13,ve&=8191;let we=Y+P*m+U*f+k*l+O*u+q*a;Y=we>>>13,we&=8191,we+=N*(5*y)+_*(5*g)+R*(5*v)+K*(5*d)+Z*(5*p),Y+=we>>>13,we&=8191;let Te=Y+P*p+U*m+k*f+O*l+q*u;Y=Te>>>13,Te&=8191,Te+=N*a+_*(5*y)+R*(5*g)+K*(5*v)+Z*(5*d),Y+=Te>>>13,Te&=8191;let Le=Y+P*d+U*p+k*m+O*f+q*l;Y=Le>>>13,Le&=8191,Le+=N*u+_*a+R*(5*y)+K*(5*g)+Z*(5*v),Y+=Le>>>13,Le&=8191;let Oe=Y+P*v+U*d+k*p+O*m+q*f;Y=Oe>>>13,Oe&=8191,Oe+=N*l+_*u+R*a+K*(5*y)+Z*(5*g),Y+=Oe>>>13,Oe&=8191;let le=Y+P*g+U*v+k*d+O*p+q*m;Y=le>>>13,le&=8191,le+=N*f+_*l+R*u+K*a+Z*(5*y),Y+=le>>>13,le&=8191;let Se=Y+P*y+U*g+k*v+O*d+q*p;Y=Se>>>13,Se&=8191,Se+=N*m+_*f+R*l+K*u+Z*a,Y+=Se>>>13,Se&=8191,Y=(Y<<2)+Y|0,Y=Y+te|0,te=Y&8191,Y=Y>>>13,se+=Y,o[0]=te,o[1]=se,o[2]=fe,o[3]=ve,o[4]=we,o[5]=Te,o[6]=Le,o[7]=Oe,o[8]=le,o[9]=Se}finalize(){let{h:t,pad:r}=this,n=new Uint16Array(10),i=t[1]>>>13;t[1]&=8191;for(let a=2;a<10;a++)t[a]+=i,i=t[a]>>>13,t[a]&=8191;t[0]+=i*5,i=t[0]>>>13,t[0]&=8191,t[1]+=i,i=t[1]>>>13,t[1]&=8191,t[2]+=i,n[0]=t[0]+5,i=n[0]>>>13,n[0]&=8191;for(let a=1;a<10;a++)n[a]=t[a]+i,i=n[a]>>>13,n[a]&=8191;n[9]-=8192;let o=(i^1)-1;for(let a=0;a<10;a++)n[a]&=o;o=~o;for(let a=0;a<10;a++)t[a]=t[a]&o|n[a];t[0]=(t[0]|t[1]<<13)&65535,t[1]=(t[1]>>>3|t[2]<<10)&65535,t[2]=(t[2]>>>6|t[3]<<7)&65535,t[3]=(t[3]>>>9|t[4]<<4)&65535,t[4]=(t[4]>>>12|t[5]<<1|t[6]<<14)&65535,t[5]=(t[6]>>>2|t[7]<<11)&65535,t[6]=(t[7]>>>5|t[8]<<8)&65535,t[7]=(t[8]>>>8|t[9]<<5)&65535;let s=t[0]+r[0];t[0]=s&65535;for(let a=1;a<8;a++)s=(t[a]+r[a]|0)+(s>>>16)|0,t[a]=s&65535;no(n)}update(t){pE(this),un(t),t=Vf(t);let{buffer:r,blockLen:n}=this,i=t.length;for(let o=0;o>>0,t[o++]=n[s]>>>8}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}},sD=Z8(32,e=>new gE(e));function jq(e,t,r,n,i,o=20){let s=e[0],a=e[1],u=e[2],l=e[3],f=t[0],m=t[1],p=t[2],d=t[3],v=t[4],g=t[5],y=t[6],w=t[7],E=i,S=r[0],D=r[1],F=r[2],M=s,z=a,C=u,P=l,U=f,k=m,O=p,q=d,N=v,_=g,R=y,K=w,Z=E,Y=S,te=D,se=F;for(let ve=0;ve{e.update(t);let r=t.length%16;r&&e.update(Vq.subarray(r))},zq=new Uint8Array(32);function oD(e,t,r,n,i){i!==void 0&&un(i,void 0,"AAD");let o=e(t,r,zq),s=eD(n.length,i?i.length:0,!0),a=sD.create(o);i&&iD(a,i),iD(a,n),a.update(s);let u=a.digest();return no(o,s),u}var Gq=e=>(t,r,n)=>({encrypt(o,s){let a=o.length;s=Yd(a+16,s,!1),s.set(o);let u=s.subarray(0,-16);e(t,r,u,u,1);let l=oD(e,t,r,u,n);return s.set(l,a),no(l),s},decrypt(o,s){s=Yd(o.length-16,s,!1);let a=o.subarray(0,-16),u=o.subarray(-16),l=oD(e,t,r,a,n);if(!J8(u,l))throw no(l),new Error("invalid tag");return s.set(o.subarray(0,-16)),e(t,r,s,s,1),no(l),s}}),Ti=Q8({blockSize:64,nonceLength:12,tagLength:16},Gq(Kq));var Uce=B(T(),1);var oue=B(T(),1);var nue=B(T(),1);function zf(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Cn(e,t=""){if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw new Error(`${r}expected integer >0, got ${e}`)}}function ct(e,t,r=""){let n=zf(e),i=e?.length,o=t!==void 0;if(!n||o&&i!==t){let s=r&&`"${r}" `,a=o?` of length ${t}`:"",u=n?`length=${i}`:`type=${typeof e}`;throw new Error(s+"expected Uint8Array"+a+", got "+u)}return e}function Pi(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash must wrapped by utils.createHasher");Cn(e.outputLen),Cn(e.blockLen)}function au(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function gm(e,t){ct(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length='+r)}function vm(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function zs(...e){for(let t=0;t>>t}var Yq=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Wq(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Xq(e){for(let t=0;te:Xq,uD=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Jq=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function _l(e){if(ct(e),uD)return e.toHex();let t="";for(let r=0;r=ou._0&&e<=ou._9)return e-ou._0;if(e>=ou.A&&e<=ou.F)return e-(ou.A-10);if(e>=ou.a&&e<=ou.f)return e-(ou.a-10)}function Dl(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(uD)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let i=0,o=0;ie(o).update(i).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.create=i=>e(i),Object.assign(r,t),Object.freeze(r)}function lc(e=32){let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return t.getRandomValues(new Uint8Array(e))}var fc=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var yE=BigInt(0),wE=BigInt(1);function Xd(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new Error(r+"expected boolean, got type="+typeof e)}return e}function cD(e){if(typeof e=="bigint"){if(!ym(e))throw new Error("positive bigint expected, got "+e)}else Cn(e);return e}function Jd(e){let t=cD(e).toString(16);return t.length&1?"0"+t:t}function lD(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?yE:BigInt("0x"+e)}function hc(e){return lD(_l(e))}function dc(e){return lD(_l(Em(ct(e)).reverse()))}function Yf(e,t){Cn(t),e=cD(e);let r=Dl(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw new Error("number too large");return r}function Zd(e,t){return Yf(e,t).reverse()}function Em(e){return Uint8Array.from(e)}function pc(e){return Uint8Array.from(e,(t,r)=>{let n=t.charCodeAt(0);if(t.length!==1||n>127)throw new Error(`string contains non-ASCII character "${e[r]}" with code ${n} at position ${r}`);return n})}var ym=e=>typeof e=="bigint"&&yE<=e;function Zq(e,t,r){return ym(e)&&ym(t)&&ym(r)&&t<=e&&eyE;e>>=wE,t+=1);return t}var ep=e=>(wE<new Uint8Array(y),i=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,u=n(e),l=n(e),f=0,m=()=>{u.fill(1),l.fill(0),f=0},p=(...y)=>r(l,nn(u,...y)),d=(y=i)=>{l=p(o,y),u=p(),y.length!==0&&(l=p(s,y),u=p())},v=()=>{if(f++>=a)throw new Error("drbg: tried max amount of iterations");let y=0,w=[];for(;y{m(),d(y);let E;for(;!(E=w(v()));)d();return m(),E}}function Fl(e,t={},r={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function n(o,s,a){let u=e[o];if(a&&u===void 0)return;let l=typeof u;if(l!==s||u===null)throw new Error(`param "${o}" is invalid: expected ${s}, got ${l}`)}let i=(o,s)=>Object.entries(o).forEach(([a,u])=>n(a,u,s));i(t,!1),i(r,!0)}function bE(e){let t=new WeakMap;return(r,...n)=>{let i=t.get(r);if(i!==void 0)return i;let o=e(r,...n);return t.set(r,o),o}}var pue=B(T(),1);var lue=B(T(),1);var Ts=BigInt(0),ss=BigInt(1),Il=BigInt(2),pD=BigInt(3),mD=BigInt(4),gD=BigInt(5),Qq=BigInt(7),vD=BigInt(8),ej=BigInt(9),wD=BigInt(16);function $s(e,t){let r=e%t;return r>=Ts?r:t+r}function xi(e,t,r){let n=e;for(;t-- >Ts;)n*=n,n%=r;return n}function hD(e,t){if(e===Ts)throw new Error("invert: expected non-zero number");if(t<=Ts)throw new Error("invert: expected positive modulus, got "+t);let r=$s(e,t),n=t,i=Ts,o=ss,s=ss,a=Ts;for(;r!==Ts;){let l=n/r,f=n%r,m=i-s*l,p=o-a*l;n=r,r=f,i=s,o=a,s=m,a=p}if(n!==ss)throw new Error("invert: does not exist");return $s(i,t)}function SE(e,t,r){if(!e.eql(e.sqr(t),r))throw new Error("Cannot find square root")}function yD(e,t){let r=(e.ORDER+ss)/mD,n=e.pow(t,r);return SE(e,n,t),n}function tj(e,t){let r=(e.ORDER-gD)/vD,n=e.mul(t,Il),i=e.pow(n,r),o=e.mul(t,i),s=e.mul(e.mul(o,Il),i),a=e.mul(o,e.sub(s,e.ONE));return SE(e,a,t),a}function rj(e){let t=bm(e),r=ED(e),n=r(t,t.neg(t.ONE)),i=r(t,n),o=r(t,t.neg(n)),s=(e+Qq)/wD;return(a,u)=>{let l=a.pow(u,s),f=a.mul(l,n),m=a.mul(l,i),p=a.mul(l,o),d=a.eql(a.sqr(f),u),v=a.eql(a.sqr(m),u);l=a.cmov(l,f,d),f=a.cmov(p,m,v);let g=a.eql(a.sqr(f),u),y=a.cmov(l,f,g);return SE(a,y,u),y}}function ED(e){if(e1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return yD;let o=i.pow(n,t),s=(t+ss)/Il;return function(u,l){if(u.is0(l))return l;if(dD(u,l)!==1)throw new Error("Cannot find square root");let f=r,m=u.mul(u.ONE,o),p=u.pow(l,t),d=u.pow(l,s);for(;!u.eql(p,u.ONE);){if(u.is0(p))return u.ZERO;let v=1,g=u.sqr(p);for(;!u.eql(g,u.ONE);)if(v++,g=u.sqr(g),v===f)throw new Error("Cannot find square root");let y=ss<(n[i]="function",n),t);return Fl(e,r),e}function ij(e,t,r){if(rTs;)r&ss&&(n=e.mul(n,i)),i=e.sqr(i),r>>=ss;return n}function tp(e,t,r=!1){let n=new Array(t.length).fill(r?e.ZERO:void 0),i=t.reduce((s,a,u)=>e.is0(a)?s:(n[u]=s,e.mul(s,a)),e.ONE),o=e.inv(i);return t.reduceRight((s,a,u)=>e.is0(a)?s:(n[u]=e.mul(s,n[u]),e.mul(s,a)),o),n}function dD(e,t){let r=(e.ORDER-ss)/Il,n=e.pow(t,r),i=e.eql(n,e.ONE),o=e.eql(n,e.ZERO),s=e.eql(n,e.neg(e.ONE));if(!i&&!o&&!s)throw new Error("invalid Legendre symbol result");return i?1:o?0:-1}function oj(e,t){t!==void 0&&Cn(t);let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}var AE=class{ORDER;BITS;BYTES;isLE;ZERO=Ts;ONE=ss;_lengths;_sqrt;_mod;constructor(t,r={}){if(t<=Ts)throw new Error("invalid field: expected ORDER > 0, got "+t);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&(this.sqrt=r.sqrt),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=r.allowedLengths?.slice()),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:i,nByteLength:o}=oj(t,n);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=i,this.BYTES=o,this._sqrt=void 0,Object.preventExtensions(this)}create(t){return $s(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof t);return Ts<=t&&ti)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let l=new Uint8Array(i);l.set(t,o?0:l.length-t.length),t=l}if(t.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+t.length);let u=o?dc(t):hc(t);if(a&&(u=$s(u,s)),!r&&!this.isValid(u))throw new Error("invalid field element: outside of range 0..ORDER");return u}invertBatch(t){return tp(this,t)}cmov(t,r,n){return n?r:t}};function bm(e,t={}){return new AE(e,t)}function bD(e){if(typeof e!="bigint")throw new Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function _E(e){let t=bD(e);return t+Math.ceil(t/2)}function AD(e,t,r=!1){ct(e);let n=e.length,i=bD(t),o=_E(t);if(n<16||n1024)throw new Error("expected "+o+"-1024 bytes of input, got "+n);let s=r?dc(e):hc(e),a=$s(s,t-ss)+ss;return r?Zd(a,i):Yf(a,i)}var Wf=BigInt(0),Bl=BigInt(1);function rp(e,t){let r=t.negate();return e?r:t}function BE(e,t){let r=tp(e.Fp,t.map(n=>n.Z));return t.map((n,i)=>e.fromAffine(n.toAffine(r[i])))}function DD(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function DE(e,t){DD(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),i=2**e,o=ep(e),s=BigInt(e);return{windows:r,windowSize:n,mask:o,maxNumber:i,shiftBy:s}}function SD(e,t,r){let{windowSize:n,mask:i,maxNumber:o,shiftBy:s}=r,a=Number(e&i),u=e>>s;a>n&&(a-=o,u+=Bl);let l=t*n,f=l+Math.abs(a)-1,m=a===0,p=a<0,d=t%2!==0;return{nextN:u,offset:f,isZero:m,isNeg:p,isNegF:d,offsetF:l}}var FE=new WeakMap,FD=new WeakMap;function IE(e){return FD.get(e)||1}function CD(e){if(e!==Wf)throw new Error("invalid wNAF")}var Am=class{BASE;ZERO;Fn;bits;constructor(t,r){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=r}_unsafeLadder(t,r,n=this.ZERO){let i=t;for(;r>Wf;)r&Bl&&(n=n.add(i)),i=i.double(),r>>=Bl;return n}precomputeWindow(t,r){let{windows:n,windowSize:i}=DE(r,this.bits),o=[],s=t,a=s;for(let u=0;uWf||n>Wf;)r&Bl&&(o=o.add(i)),n&Bl&&(s=s.add(i)),i=i.double(),r>>=Bl,n>>=Bl;return{p1:o,p2:s}}function _D(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return CE(t),t}else return bm(e,{isLE:r})}function BD(e,t,r={},n){if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(let u of["p","n","h"]){let l=t[u];if(!(typeof l=="bigint"&&l>Wf))throw new Error(`CURVE.${u} must be positive bigint`)}let i=_D(t.p,r.Fp,n),o=_D(t.n,r.Fn,n),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let u of a)if(!i.isValid(t[u]))throw new Error(`CURVE.${u} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:o}}function Sm(e,t){return function(n){let i=e(n);return{secretKey:i,publicKey:t(i)}}}var yue=B(T(),1);var np=BigInt(0),Xf=BigInt(1),Cm=BigInt(2);function aj(e){return Fl(e,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...e})}function $D(e){let t=aj(e),{P:r,type:n,adjustScalarBytes:i,powPminus2:o,randomBytes:s}=t,a=n==="x25519";if(!a&&n!=="x448")throw new Error("invalid type");let u=s||lc,l=a?255:448,f=a?32:56,m=BigInt(a?9:5),p=BigInt(a?121665:39081),d=a?Cm**BigInt(254):Cm**BigInt(447),v=a?BigInt(8)*Cm**BigInt(251)-Xf:BigInt(4)*Cm**BigInt(445)-Xf,g=d+v+Xf,y=N=>$s(N,r),w=E(m);function E(N){return Zd(y(N),f)}function S(N){let _=Em(ct(N,f,"uCoordinate"));return a&&(_[31]&=127),y(dc(_))}function D(N){return dc(i(Em(ct(N,f,"scalar"))))}function F(N,_){let R=U(S(_),D(N));if(R===np)throw new Error("invalid private or public key received");return E(R)}function M(N){return F(N,w)}let z=M,C=F;function P(N,_,R){let K=y(N*(_-R));return _=y(_-K),R=y(R+K),{x_2:_,x_3:R}}function U(N,_){Qd("u",N,np,r),Qd("scalar",_,d,g);let R=_,K=N,Z=Xf,Y=np,te=N,se=Xf,fe=np;for(let we=BigInt(l-1);we>=np;we--){let Te=R>>we&Xf;fe^=Te,{x_2:Z,x_3:te}=P(fe,Z,te),{x_2:Y,x_3:se}=P(fe,Y,se),fe=Te;let Le=Z+Y,Oe=y(Le*Le),le=Z-Y,Se=y(le*le),Re=Oe-Se,Ve=te+se,rt=te-se,qe=y(rt*Le),At=y(Ve*le),it=qe+At,Et=qe-At;te=y(it*it),se=y(K*y(Et*Et)),Z=y(Oe*Se),Y=y(Re*(Oe+y(p*Re)))}({x_2:Z,x_3:te}=P(fe,Z,te)),{x_2:Y,x_3:se}=P(fe,Y,se);let ve=o(Y);return y(Z*ve)}let k={secretKey:f,publicKey:f,seed:f},O=(N=u(f))=>(ct(N,k.seed,"seed"),N),q={randomSecretKey:O};return Object.freeze({keygen:Sm(O,z),getSharedSecret:C,getPublicKey:z,scalarMult:F,scalarMultBase:M,utils:q,GuBytes:w.slice(),lengths:k})}var Bue=B(T(),1);var Aue=B(T(),1);var _m=class{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(t,r){if(Pi(t),ct(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,i=new Uint8Array(n);i.set(r.length>n?t.create().update(r).digest():r);for(let o=0;onew _m(e,t).update(r).digest();Jf.create=(e,t)=>new _m(e,t);var TD=(e,t)=>(e+(e>=0?t:-t)/PD)/t;function uj(e,t,r){let[[n,i],[o,s]]=t,a=TD(s*e,r),u=TD(-i*e,r),l=e-a*n-u*o,f=-a*i-u*s,m=l=d||f=d)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:m,k1:l,k2neg:p,k2:f}}function TE(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function $E(e,t){let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return Xd(r.lowS,"lowS"),Xd(r.prehash,"prehash"),r.format!==void 0&&TE(r.format),r}var PE=class extends Error{constructor(t=""){super(t)}},mc={Err:PE,_tlv:{encode:(e,t)=>{let{Err:r}=mc;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,i=Jd(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let o=n>127?Jd(i.length/2|128):"";return Jd(e)+o+i+t},decode(e,t){let{Err:r}=mc,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let i=t[n++],o=!!(i&128),s=0;if(!o)s=i;else{let u=i&127;if(!u)throw new r("tlv.decode(long): indefinite length not supported");if(u>4)throw new r("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+u);if(l.length!==u)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let f of l)s=s<<8|f;if(n+=u,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+s)}}},_int:{encode(e){let{Err:t}=mc;if(e{let{X:N,Y:_,Z:R}=O;if(n.eql(R,n.ONE))return{x:N,y:_};let K=O.is0();q==null&&(q=K?n.ONE:n.inv(R));let Z=n.mul(N,q),Y=n.mul(_,q),te=n.mul(R,q);if(K)return{x:n.ZERO,y:n.ZERO};if(!n.eql(te,n.ONE))throw new Error("invZ was invalid");return{x:Z,y:Y}}),z=bE(O=>{if(O.is0()){if(t.allowInfinityPoint&&!n.is0(O.Y))return;throw new Error("bad point: ZERO")}let{x:q,y:N}=O.toAffine();if(!n.isValid(q)||!n.isValid(N))throw new Error("bad point: x or y not field elements");if(!y(q,N))throw new Error("bad point: equation left != right");if(!O.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function C(O,q,N,_,R){return N=new P(n.mul(N.X,O),N.Y,N.Z),q=rp(_,q),N=rp(R,N),q.add(N)}class P{static BASE=new P(o.Gx,o.Gy,n.ONE);static ZERO=new P(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=i;X;Y;Z;constructor(q,N,_){this.X=S("x",q),this.Y=S("y",N,!0),this.Z=S("z",_),Object.freeze(this)}static CURVE(){return o}static fromAffine(q){let{x:N,y:_}=q||{};if(!q||!n.isValid(N)||!n.isValid(_))throw new Error("invalid affine point");if(q instanceof P)throw new Error("projective point not allowed");return n.is0(N)&&n.is0(_)?P.ZERO:new P(N,_,n.ONE)}static fromBytes(q){let N=P.fromAffine(v(ct(q,void 0,"point")));return N.assertValidity(),N}static fromHex(q){return P.fromBytes(Dl(q))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(q=8,N=!0){return k.createCache(this,q),N||this.multiply(Dm),this}assertValidity(){z(this)}hasEvenY(){let{y:q}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(q)}equals(q){D(q);let{X:N,Y:_,Z:R}=this,{X:K,Y:Z,Z:Y}=q,te=n.eql(n.mul(N,Y),n.mul(K,R)),se=n.eql(n.mul(_,Y),n.mul(Z,R));return te&&se}negate(){return new P(this.X,n.neg(this.Y),this.Z)}double(){let{a:q,b:N}=o,_=n.mul(N,Dm),{X:R,Y:K,Z}=this,Y=n.ZERO,te=n.ZERO,se=n.ZERO,fe=n.mul(R,R),ve=n.mul(K,K),we=n.mul(Z,Z),Te=n.mul(R,K);return Te=n.add(Te,Te),se=n.mul(R,Z),se=n.add(se,se),Y=n.mul(q,se),te=n.mul(_,we),te=n.add(Y,te),Y=n.sub(ve,te),te=n.add(ve,te),te=n.mul(Y,te),Y=n.mul(Te,Y),se=n.mul(_,se),we=n.mul(q,we),Te=n.sub(fe,we),Te=n.mul(q,Te),Te=n.add(Te,se),se=n.add(fe,fe),fe=n.add(se,fe),fe=n.add(fe,we),fe=n.mul(fe,Te),te=n.add(te,fe),we=n.mul(K,Z),we=n.add(we,we),fe=n.mul(we,Te),Y=n.sub(Y,fe),se=n.mul(we,ve),se=n.add(se,se),se=n.add(se,se),new P(Y,te,se)}add(q){D(q);let{X:N,Y:_,Z:R}=this,{X:K,Y:Z,Z:Y}=q,te=n.ZERO,se=n.ZERO,fe=n.ZERO,ve=o.a,we=n.mul(o.b,Dm),Te=n.mul(N,K),Le=n.mul(_,Z),Oe=n.mul(R,Y),le=n.add(N,_),Se=n.add(K,Z);le=n.mul(le,Se),Se=n.add(Te,Le),le=n.sub(le,Se),Se=n.add(N,R);let Re=n.add(K,Y);return Se=n.mul(Se,Re),Re=n.add(Te,Oe),Se=n.sub(Se,Re),Re=n.add(_,R),te=n.add(Z,Y),Re=n.mul(Re,te),te=n.add(Le,Oe),Re=n.sub(Re,te),fe=n.mul(ve,Se),te=n.mul(we,Oe),fe=n.add(te,fe),te=n.sub(Le,fe),fe=n.add(Le,fe),se=n.mul(te,fe),Le=n.add(Te,Te),Le=n.add(Le,Te),Oe=n.mul(ve,Oe),Se=n.mul(we,Se),Le=n.add(Le,Oe),Oe=n.sub(Te,Oe),Oe=n.mul(ve,Oe),Se=n.add(Se,Oe),Te=n.mul(Le,Se),se=n.add(se,Te),Te=n.mul(Re,Se),te=n.mul(le,te),te=n.sub(te,Te),Te=n.mul(le,Le),fe=n.mul(Re,fe),fe=n.add(fe,Te),new P(te,se,fe)}subtract(q){return this.add(q.negate())}is0(){return this.equals(P.ZERO)}multiply(q){let{endo:N}=t;if(!i.isValidNot0(q))throw new Error("invalid scalar: out of range");let _,R,K=Z=>k.cached(this,Z,Y=>BE(P,Y));if(N){let{k1neg:Z,k1:Y,k2neg:te,k2:se}=F(q),{p:fe,f:ve}=K(Y),{p:we,f:Te}=K(se);R=ve.add(Te),_=C(N.beta,fe,we,Z,te)}else{let{p:Z,f:Y}=K(q);_=Z,R=Y}return BE(P,[_,R])[0]}multiplyUnsafe(q){let{endo:N}=t,_=this;if(!i.isValid(q))throw new Error("invalid scalar: out of range");if(q===uu||_.is0())return P.ZERO;if(q===Zf)return _;if(k.hasCache(this))return this.multiply(q);if(N){let{k1neg:R,k1:K,k2neg:Z,k2:Y}=F(q),{p1:te,p2:se}=ID(P,_,K,Y);return C(N.beta,te,se,R,Z)}else return k.unsafe(_,q)}toAffine(q){return M(this,q)}isTorsionFree(){let{isTorsionFree:q}=t;return s===Zf?!0:q?q(P,this):k.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:q}=t;return s===Zf?this:q?q(P,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(q=!0){return Xd(q,"isCompressed"),this.assertValidity(),d(P,this,q)}toHex(q=!0){return _l(this.toBytes(q))}toString(){return``}}let U=i.BITS,k=new Am(P,t.endo?Math.ceil(U/2):U);return P.BASE.precompute(8),P}function xD(e){return Uint8Array.of(e?2:3)}function RD(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function lj(e,t={}){let{Fn:r}=e,n=t.randomBytes||lc,i=Object.assign(RD(e.Fp,r),{seed:_E(r.ORDER)});function o(d){try{let v=r.fromBytes(d);return r.isValidNot0(v)}catch{return!1}}function s(d,v){let{publicKey:g,publicKeyUncompressed:y}=i;try{let w=d.length;return v===!0&&w!==g||v===!1&&w!==y?!1:!!e.fromBytes(d)}catch{return!1}}function a(d=n(i.seed)){return AD(ct(d,i.seed,"seed"),r.ORDER)}function u(d,v=!0){return e.BASE.multiply(r.fromBytes(d)).toBytes(v)}function l(d){let{secretKey:v,publicKey:g,publicKeyUncompressed:y}=i;if(!zf(d)||"_lengths"in r&&r._lengths||v===g)return;let w=ct(d,void 0,"key").length;return w===g||w===y}function f(d,v,g=!0){if(l(d)===!0)throw new Error("first arg must be private key");if(l(v)===!1)throw new Error("second arg must be public key");let y=r.fromBytes(d);return e.fromBytes(v).multiply(y).toBytes(g)}let m={isValidSecretKey:o,isValidPublicKey:s,randomSecretKey:a},p=Sm(a,u);return Object.freeze({getPublicKey:u,getSharedSecret:f,keygen:p,Point:e,utils:m,lengths:i})}function RE(e,t,r={}){Pi(t),Fl(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes||lc,i=r.hmac||((N,_)=>Jf(t,N,_)),{Fp:o,Fn:s}=e,{ORDER:a,BITS:u}=s,{keygen:l,getPublicKey:f,getSharedSecret:m,utils:p,lengths:d}=lj(e,r),v={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},g=a*PD>Zf;return N>_}function w(N,_){if(!s.isValidNot0(_))throw new Error(`invalid signature ${N}: out of range 1..Point.Fn.ORDER`);return _}function E(){if(g)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function S(N,_){TE(_);let R=d.signature,K=_==="compact"?R:_==="recovered"?R+1:void 0;return ct(N,K)}class D{r;s;recovery;constructor(_,R,K){if(this.r=w("r",_),this.s=w("s",R),K!=null){if(E(),![0,1,2,3].includes(K))throw new Error("invalid recovery id");this.recovery=K}Object.freeze(this)}static fromBytes(_,R=v.format){S(_,R);let K;if(R==="der"){let{r:se,s:fe}=mc.toSig(ct(_));return new D(se,fe)}R==="recovered"&&(K=_[0],R="compact",_=_.subarray(1));let Z=d.signature/2,Y=_.subarray(0,Z),te=_.subarray(Z,Z*2);return new D(s.fromBytes(Y),s.fromBytes(te),K)}static fromHex(_,R){return this.fromBytes(Dl(_),R)}assertRecovery(){let{recovery:_}=this;if(_==null)throw new Error("invalid recovery id: must be present");return _}addRecoveryBit(_){return new D(this.r,this.s,_)}recoverPublicKey(_){let{r:R,s:K}=this,Z=this.assertRecovery(),Y=Z===2||Z===3?R+a:R;if(!o.isValid(Y))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let te=o.toBytes(Y),se=e.fromBytes(nn(xD((Z&1)===0),te)),fe=s.inv(Y),ve=M(ct(_,void 0,"msgHash")),we=s.create(-ve*fe),Te=s.create(K*fe),Le=e.BASE.multiplyUnsafe(we).add(se.multiplyUnsafe(Te));if(Le.is0())throw new Error("invalid recovery: point at infinify");return Le.assertValidity(),Le}hasHighS(){return y(this.s)}toBytes(_=v.format){if(TE(_),_==="der")return Dl(mc.hexFromSig(this));let{r:R,s:K}=this,Z=s.toBytes(R),Y=s.toBytes(K);return _==="recovered"?(E(),nn(Uint8Array.of(this.assertRecovery()),Z,Y)):nn(Z,Y)}toHex(_){return _l(this.toBytes(_))}}let F=r.bits2int||function(_){if(_.length>8192)throw new Error("input is too large");let R=hc(_),K=_.length*8-u;return K>0?R>>BigInt(K):R},M=r.bits2int_modN||function(_){return s.create(F(_))},z=ep(u);function C(N){return Qd("num < 2^"+u,N,uu,z),s.toBytes(N)}function P(N,_){return ct(N,void 0,"message"),_?ct(t(N),void 0,"prehashed message"):N}function U(N,_,R){let{lowS:K,prehash:Z,extraEntropy:Y}=$E(R,v);N=P(N,Z);let te=M(N),se=s.fromBytes(_);if(!s.isValidNot0(se))throw new Error("invalid private key");let fe=[C(se),C(te)];if(Y!=null&&Y!==!1){let Le=Y===!0?n(d.secretKey):Y;fe.push(ct(Le,void 0,"extraEntropy"))}let ve=nn(...fe),we=te;function Te(Le){let Oe=F(Le);if(!s.isValidNot0(Oe))return;let le=s.inv(Oe),Se=e.BASE.multiply(Oe).toAffine(),Re=s.create(Se.x);if(Re===uu)return;let Ve=s.create(le*s.create(we+Re*se));if(Ve===uu)return;let rt=(Se.x===Re?0:2)|Number(Se.y&Zf),qe=Ve;return K&&y(Ve)&&(qe=s.neg(Ve),rt^=1),new D(Re,qe,g?void 0:rt)}return{seed:ve,k2sig:Te}}function k(N,_,R={}){let{seed:K,k2sig:Z}=U(N,_,R);return fD(t.outputLen,s.BYTES,i)(K,Z).toBytes(R.format)}function O(N,_,R,K={}){let{lowS:Z,prehash:Y,format:te}=$E(K,v);if(R=ct(R,void 0,"publicKey"),_=P(_,Y),!zf(N)){let se=N instanceof D?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+se)}S(N,te);try{let se=D.fromBytes(N,te),fe=e.fromBytes(R);if(Z&&se.hasHighS())return!1;let{r:ve,s:we}=se,Te=M(_),Le=s.inv(we),Oe=s.create(Te*Le),le=s.create(ve*Le),Se=e.BASE.multiplyUnsafe(Oe).add(fe.multiplyUnsafe(le));return Se.is0()?!1:s.create(Se.x)===ve}catch{return!1}}function q(N,_,R={}){let{prehash:K}=$E(R,v);return _=P(_,K),D.fromBytes(N,"recovered").recoverPublicKey(_).toBytes()}return Object.freeze({keygen:l,getPublicKey:f,getSharedSecret:m,utils:p,lengths:d,Point:e,sign:k,verify:O,recoverPublicKey:q,Signature:D,hash:t})}var zue=B(T(),1);var Uue=B(T(),1);var Pue=B(T(),1);function kD(e,t,r){return e&t^~e&r}function OD(e,t,r){return e&t^e&r^t&r}var sp=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,r,n,i){this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.buffer=new Uint8Array(t),this.view=wm(this.buffer)}update(t){au(this),ct(t);let{view:r,buffer:n,blockLen:i}=this,o=t.length;for(let s=0;si-s&&(this.process(n,0),s=0);for(let m=s;mf.length)throw new Error("_sha2: outputLen bigger than state");for(let m=0;m>ND&Fm)}:{h:Number(e>>ND&Fm)|0,l:Number(e&Fm)|0}}function Im(e,t=!1){let r=e.length,n=new Uint32Array(r),i=new Uint32Array(r);for(let o=0;oe>>>r,OE=(e,t,r)=>e<<32-r|t>>>r,$l=(e,t,r)=>e>>>r|t<<32-r,Tl=(e,t,r)=>e<<32-r|t>>>r,ip=(e,t,r)=>e<<64-r|t>>>r-32,op=(e,t,r)=>e>>>r-32|t<<64-r;var LD=(e,t,r)=>e<>>32-r,UD=(e,t,r)=>t<>>32-r,HD=(e,t,r)=>t<>>64-r,MD=(e,t,r)=>e<>>64-r;function ea(e,t,r,n){let i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:i|0}}var qD=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),jD=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,KD=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),VD=(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0,zD=(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0),GD=(e,t,r,n,i,o)=>t+r+n+i+o+(e/2**32|0)|0;var dj=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),gc=new Uint32Array(64),NE=class extends sp{constructor(t){super(64,t,8,!1)}get(){let{A:t,B:r,C:n,D:i,E:o,F:s,G:a,H:u}=this;return[t,r,n,i,o,s,a,u]}set(t,r,n,i,o,s,a,u){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=u|0}process(t,r){for(let m=0;m<16;m++,r+=4)gc[m]=t.getUint32(r,!1);for(let m=16;m<64;m++){let p=gc[m-15],d=gc[m-2],v=so(p,7)^so(p,18)^p>>>3,g=so(d,17)^so(d,19)^d>>>10;gc[m]=g+gc[m-7]+v+gc[m-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:u,G:l,H:f}=this;for(let m=0;m<64;m++){let p=so(a,6)^so(a,11)^so(a,25),d=f+p+kD(a,u,l)+dj[m]+gc[m]|0,g=(so(n,2)^so(n,13)^so(n,22))+OD(n,i,o)|0;f=l,l=u,u=a,a=s+d|0,s=o,o=i,i=n,n=d+g|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,u=u+this.F|0,l=l+this.G|0,f=f+this.H|0,this.set(n,i,o,s,a,u,l,f)}roundClean(){zs(gc)}destroy(){this.set(0,0,0,0,0,0,0,0),zs(this.buffer)}},LE=class extends NE{A=cu[0]|0;B=cu[1]|0;C=cu[2]|0;D=cu[3]|0;E=cu[4]|0;F=cu[5]|0;G=cu[6]|0;H=cu[7]|0;constructor(){super(32)}};var YD=Im(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),pj=YD[0],mj=YD[1],vc=new Uint32Array(80),wc=new Uint32Array(80),UE=class extends sp{constructor(t){super(128,t,16,!1)}get(){let{Ah:t,Al:r,Bh:n,Bl:i,Ch:o,Cl:s,Dh:a,Dl:u,Eh:l,El:f,Fh:m,Fl:p,Gh:d,Gl:v,Hh:g,Hl:y}=this;return[t,r,n,i,o,s,a,u,l,f,m,p,d,v,g,y]}set(t,r,n,i,o,s,a,u,l,f,m,p,d,v,g,y){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=o|0,this.Cl=s|0,this.Dh=a|0,this.Dl=u|0,this.Eh=l|0,this.El=f|0,this.Fh=m|0,this.Fl=p|0,this.Gh=d|0,this.Gl=v|0,this.Hh=g|0,this.Hl=y|0}process(t,r){for(let S=0;S<16;S++,r+=4)vc[S]=t.getUint32(r),wc[S]=t.getUint32(r+=4);for(let S=16;S<80;S++){let D=vc[S-15]|0,F=wc[S-15]|0,M=$l(D,F,1)^$l(D,F,8)^kE(D,F,7),z=Tl(D,F,1)^Tl(D,F,8)^OE(D,F,7),C=vc[S-2]|0,P=wc[S-2]|0,U=$l(C,P,19)^ip(C,P,61)^kE(C,P,6),k=Tl(C,P,19)^op(C,P,61)^OE(C,P,6),O=KD(z,k,wc[S-7],wc[S-16]),q=VD(O,M,U,vc[S-7],vc[S-16]);vc[S]=q|0,wc[S]=O|0}let{Ah:n,Al:i,Bh:o,Bl:s,Ch:a,Cl:u,Dh:l,Dl:f,Eh:m,El:p,Fh:d,Fl:v,Gh:g,Gl:y,Hh:w,Hl:E}=this;for(let S=0;S<80;S++){let D=$l(m,p,14)^$l(m,p,18)^ip(m,p,41),F=Tl(m,p,14)^Tl(m,p,18)^op(m,p,41),M=m&d^~m&g,z=p&v^~p&y,C=zD(E,F,z,mj[S],wc[S]),P=GD(C,w,D,M,pj[S],vc[S]),U=C|0,k=$l(n,i,28)^ip(n,i,34)^ip(n,i,39),O=Tl(n,i,28)^op(n,i,34)^op(n,i,39),q=n&o^n&a^o&a,N=i&s^i&u^s&u;w=g|0,E=y|0,g=d|0,y=v|0,d=m|0,v=p|0,{h:m,l:p}=ea(l|0,f|0,P|0,U|0),l=a|0,f=u|0,a=o|0,u=s|0,o=n|0,s=i|0;let _=qD(U,O,N);n=jD(_,P,k,q),i=_|0}({h:n,l:i}=ea(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:s}=ea(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l:u}=ea(this.Ch|0,this.Cl|0,a|0,u|0),{h:l,l:f}=ea(this.Dh|0,this.Dl|0,l|0,f|0),{h:m,l:p}=ea(this.Eh|0,this.El|0,m|0,p|0),{h:d,l:v}=ea(this.Fh|0,this.Fl|0,d|0,v|0),{h:g,l:y}=ea(this.Gh|0,this.Gl|0,g|0,y|0),{h:w,l:E}=ea(this.Hh|0,this.Hl|0,w|0,E|0),this.set(n,i,o,s,a,u,l,f,m,p,d,v,g,y,w,E)}roundClean(){zs(vc,wc)}destroy(){zs(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var HE=class extends UE{Ah=Un[0]|0;Al=Un[1]|0;Bh=Un[2]|0;Bl=Un[3]|0;Ch=Un[4]|0;Cl=Un[5]|0;Dh=Un[6]|0;Dl=Un[7]|0;Eh=Un[8]|0;El=Un[9]|0;Fh=Un[10]|0;Fl=Un[11]|0;Gh=Un[12]|0;Gl=Un[13]|0;Hh=Un[14]|0;Hl=Un[15]|0;constructor(){super(48)}};var Bm=Gf(()=>new LE,fc(1));var WD=Gf(()=>new HE,fc(2));var gj=BigInt(1),XD=BigInt(2),vj=BigInt(3),wj=BigInt(5),Kue=BigInt(8),JD=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed");function yj(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),o=JD,a=e*e%o*e%o,u=xi(a,XD,o)*a%o,l=xi(u,gj,o)*e%o,f=xi(l,wj,o)*l%o,m=xi(f,t,o)*f%o,p=xi(m,r,o)*m%o,d=xi(p,n,o)*p%o,v=xi(d,i,o)*d%o,g=xi(v,i,o)*d%o,y=xi(g,t,o)*f%o;return{pow_p_5_8:xi(y,XD,o)*e%o,b2:a}}function Ej(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var ZD=(()=>{let e=JD;return $D({P:e,type:"x25519",powPminus2:t=>{let{pow_p_5_8:r,b2:n}=yj(t);return $s(xi(r,vj,e)*n,e)},adjustScalarBytes:Ej})})();var Zue=B(T(),1);var bj={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")},Aj={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")};var Sj=xE(bj),ME=RE(Sj,Bm);var Cj=xE(Aj),QD=RE(Cj,WD);var rce=B(T(),1);function tF(e,t,r){return Pi(e),r===void 0&&(r=new Uint8Array(e.outputLen)),Jf(e,r,t)}var qE=Uint8Array.of(0),eF=Uint8Array.of();function rF(e,t,r,n=32){Pi(e),Cn(n,"length");let i=e.outputLen;if(n>255*i)throw new Error("Length must be <= 255*HashLen");let o=Math.ceil(n/i);r===void 0?r=eF:ct(r,void 0,"info");let s=new Uint8Array(o*i),a=Jf.create(e,t),u=a._cloneInto(),l=new Uint8Array(a.outputLen);for(let f=0;f>Fj)*Bj)%Ij,t&Dj&&(i^=ap<<(ap<r>32?HD(e,t,r):LD(e,t,r),sF=(e,t,r)=>r>32?MD(e,t,r):UD(e,t,r);function Pj(e,t=24){let r=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let s=0;s<10;s++)r[s]=e[s]^e[s+10]^e[s+20]^e[s+30]^e[s+40];for(let s=0;s<10;s+=2){let a=(s+8)%10,u=(s+2)%10,l=r[u],f=r[u+1],m=nF(l,f,1)^r[a],p=sF(l,f,1)^r[a+1];for(let d=0;d<50;d+=10)e[s+d]^=m,e[s+d+1]^=p}let i=e[2],o=e[3];for(let s=0;s<24;s++){let a=oF[s],u=nF(i,o,a),l=sF(i,o,a),f=iF[s];i=e[f],o=e[f+1],e[f]=u,e[f+1]=l}for(let s=0;s<50;s+=10){for(let a=0;a<10;a++)r[a]=e[s+a];for(let a=0;a<10;a++)e[s+a]^=~r[(a+2)%10]&r[(a+4)%10]}e[0]^=$j[n],e[1]^=Tj[n]}zs(r)}var $m=class e{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;enableXOF=!1;rounds;constructor(t,r,n,i=!1,o=24){if(this.blockLen=t,this.suffix=r,this.outputLen=n,this.enableXOF=i,this.rounds=o,Cn(n,"outputLen"),!(0=n&&this.keccak();let s=Math.min(n-this.posOut,o-i);t.set(r.subarray(this.posOut,this.posOut+s),i),this.posOut+=s,i+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Cn(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(gm(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,zs(this.state)}_cloneInto(t){let{blockLen:r,suffix:n,outputLen:i,rounds:o,enableXOF:s}=this;return t||=new e(r,n,i,s,o),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=n,t.outputLen=i,t.enableXOF=s,t.destroyed=this.destroyed,t}},cF=(e,t,r,n={})=>Gf(()=>new $m(t,e,r),n);var Pl=cF(6,136,32,fc(8));var lF=cF(6,72,64,fc(10));var fF=(e,t,r,n={})=>Gf((i={})=>new $m(t,e,i.dkLen===void 0?r:i.dkLen,!0),n),hF=fF(31,168,16,fc(11)),ta=fF(31,136,32,fc(12));var _ce=B(T(),1);var wce=B(T(),1);var uce=B(T(),1);function jE(e){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw new Error("wrong u32 integer:"+e);return e}function pF(e){return jE(e),(e&e-1)===0&&e!==0}function KE(e,t){jE(e);let r=0;for(let n=0;n>>=1)r=r<<1|e&1;return r}function mF(e){return jE(e),31-Math.clz32(e)}function dF(e){let t=e.length;if(t<2||!pF(t))throw new Error("n must be a power of 2 and greater than 1. Got "+t);let r=mF(t);for(let n=0;n{let{N:r,roots:n,dit:i,invertButterflies:o=!1,skipStages:s=0,brp:a=!0}=t,u=mF(r);if(!pF(r))throw new Error("FFT: Polynomial size should be power of two");let l=i!==o;return f=>{if(f.length!==r)throw new Error("FFT: wrong Polynomial length");i&&a&&dF(f);for(let m=0,p=1;m>1,y=r>>d;for(let w=0;wtypeof i=="number"?i:i.bytesLen,n=t.reduce((i,o)=>i+r(o),0);return{bytesLen:n,encode:i=>{let o=new Uint8Array(n);for(let s=0,a=0;s{ct(i,n,e);let o=[];for(let s of t){let a=r(s),u=i.subarray(0,a);o.push(typeof s=="number"?u:s.decode(u)),i=i.subarray(a)}return o}}}function Pm(e,t){let r=t*e.bytesLen;return{bytesLen:r,encode:n=>{if(n.length!==t)throw new Error(`vecCoder.encode: wrong length=${n.length}. Expected: ${t}`);let i=new Uint8Array(r);for(let o=0,s=0;o{ct(n,r);let i=[];for(let o=0;o{let{newPoly:t,N:r,Q:n,F:i,ROOT_OF_UNITY:o,brvBits:s,isKyber:a}=e,u=(E,S=n)=>{let D=E%S|0;return(D>=0?D|0:S+D|0)|0},l=(E,S=n)=>{let D=u(E,S)|0;return(D>S>>1?D-S|0:D)|0};function f(){let E=t(r);for(let S=0;Su((E|0)+(S|0))|0,sub:(E,S)=>u((E|0)-(S|0))|0,mul:(E,S)=>u((E|0)*(S|0))|0,inv:E=>{throw new Error("not implemented")}},d={N:r,roots:m,invertButterflies:!0,skipStages:a?1:0,brp:!1},v=VE(p,{dit:!1,...d}),g=VE(p,{dit:!0,...d});return{mod:u,smod:l,nttZetas:m,NTT:{encode:E=>v(E),decode:E=>{g(E);for(let S=0;S{let D=zE(E),F=E*(r/8);return{bytesLen:F,encode:M=>{let z=new Uint8Array(F);for(let C=0,P=0,U=0,k=0;C=8;U-=8,P>>=8)z[k++]=P&zE(U);return z},decode:M=>{let z=t(r);for(let C=0,P=0,U=0,k=0;C=E;U-=E,P>>=E)z[k++]=S.decode(P&D);return z}}}}},xj=e=>(t,r)=>{r||(r=e.blockLen);let n=new Uint8Array(t.length+2);n.set(t);let i=t.length,o=new Uint8Array(r),s=e.create({}),a=0,u=0;return{stats:()=>({calls:a,xofs:u}),get:(l,f)=>(n[i+0]=l,n[i+1]=f,s.destroy(),s=e.create({}).update(n),a++,()=>(u++,s.xofInto(o))),clean:()=>{s.destroy(),cn(o,n)}}},wF=xj(hF);var is=256,lu=3329,Rj=3303,kj=17,{mod:lp,nttZetas:Oj,NTT:Rl,bitsCoder:Nj}=vF({N:is,Q:lu,F:Rj,ROOT_OF_UNITY:kj,newPoly:e=>new Uint16Array(e),brvBits:7,isKyber:!0}),GE={512:{N:is,Q:lu,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128},768:{N:is,Q:lu,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192},1024:{N:is,Q:lu,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256}},Lj=e=>{if(e>=12)return{encode:r=>r,decode:r=>r};let t=2**(e-1);return{encode:r=>((r<r*lu+t>>>e}},up=e=>Nj(e,Lj(e));function kl(e,t){for(let r=0;r>1)];r&1&&(n=-n);let{c0:i,c1:o}=Hj(e[2*r+0],e[2*r+1],t[2*r+0],t[2*r+1],n);e[2*r+0]=i,e[2*r+1]=o}return e}function yF(e){let t=new Uint16Array(is);for(let r=0;r>0|n[i+1]<<8)&4095,s=(n[i+1]>>4|n[i+2]<<4)&4095;o>=1,a+=1,a===n?(m=f,f=0):a===2*n&&(o[l++]=lp(m-f),f=0,a=0)}if(a)throw new Error(`sampleCBD: leftover bits: ${a}`);return o}var Mj=e=>{let{K:t,PRF:r,XOF:n,HASH512:i,ETA1:o,ETA2:s,du:a,dv:u}=e,l=up(1),f=up(u),m=up(a),p=xl("publicKey",Pm(up(12),t),32),d=Pm(up(12),t),v=xl("ciphertext",Pm(m,t),f),g=xl("seed",32,32);return{secretCoder:d,lengths:{secretKey:d.bytesLen,publicKey:p.bytesLen,cipherText:v.bytesLen},keygen:y=>{ct(y,32,"seed");let w=new Uint8Array(33);w.set(y),w[32]=t;let E=i(w),[S,D]=g.decode(E),F=[],M=[];for(let P=0;P{let[S,D]=p.decode(y),F=[];for(let k=0;k{let[E,S]=v.decode(y),D=d.decode(w),F=new Uint16Array(is);for(let M=0;M{ct(f,l,"seed");let{publicKey:m,secretKey:p}=t.keygen(f.subarray(0,32)),d=r(m),v=a.encode([p,m,d,f.subarray(32)]);return cn(p,d),{publicKey:m,secretKey:v}},getPublicKey:f=>{let[m,p,d,v]=a.decode(f);return Uint8Array.from(p)},encapsulate:(f,m=ra(u))=>{ct(f,s.publicKey,"publicKey"),ct(m,u,"message");let p=f.subarray(0,384*e.K),d=o.encode(o.decode(gF(p)));if(!Tm(d,p))throw cn(d),new Error("ML-KEM.encapsulate: wrong publicKey modulus");cn(d);let v=n.create().update(m).update(r(f)).digest(),g=t.encrypt(f,m,v.subarray(32,64));return cn(v.subarray(32)),{cipherText:g,sharedSecret:v.subarray(0,32)}},decapsulate:(f,m)=>{ct(m,a.bytesLen,"secretKey"),ct(f,s.cipherText,"cipherText");let p=a.bytesLen-96,d=p+32,v=r(m.subarray(p/2,d));if(!Tm(v,m.subarray(d,d+32)))throw new Error("invalid secretKey: hash check failed");let[g,y,w,E]=a.decode(m),S=t.decrypt(f,g),D=n.create().update(S).update(w).digest(),F=D.subarray(0,32),M=t.encrypt(y,S,D.subarray(32,64)),z=Tm(f,M),C=i.create({dkLen:32}).update(E).update(f).digest();return cn(S,M,z?C:F),z?F:C}}}function qj(e,t,r){return ta.create({dkLen:e}).update(t).update(new Uint8Array([r])).digest()}var WE={HASH256:Pl,HASH512:lF,KDF:ta,XOF:wF,PRF:qj},Sce=YE({...WE,...GE[512]}),fp=YE({...WE,...GE[768]}),EF=YE({...WE,...GE[1024]});function jj(e,t=!1){let r=e.lengths,n=e.keygen;if(t){let o=e.Point.Fn;if(!o)throw new Error("No Point.Fn");n=(s=ra(r.seed))=>{ct(s,r.seed,"seed");let a=o.isLE?dc(s):hc(s),u=o.toBytes(o.create(a));return{secretKey:u,publicKey:e.getPublicKey(u)}}}return{lengths:{secretKey:r.secretKey,publicKey:r.publicKey,seed:r.seed},keygen:n,getPublicKey:i=>e.getPublicKey(i)}}function XE(e,t=!1){let r=jj(e,t);if(!e.getSharedSecret)throw new Error("wrong curve");return{lengths:{...r.lengths,msg:r.lengths.seed,cipherText:r.lengths.publicKey},keygen:r.keygen,getPublicKey:r.getPublicKey,encapsulate(n,i=ra(e.lengths.seed)){let o=this.keygen(i).secretKey,s=this.decapsulate(n,o),a=e.getPublicKey(o);return cn(o),{sharedSecret:s,cipherText:a}},decapsulate(n,i){let o=e.getSharedSecret(i,n);return e.lengths.publicKeyHasPrefix?o.subarray(1):o}}}function hp(e,t){return xl(t,...e.map(r=>{if(typeof r.lengths[t]!="number")throw new Error("wrong length: "+t);return r.lengths[t]}))}function JE(e){return(t,r)=>e(t,{dkLen:r})}function Kj(e,t,...r){let n=hp(r,"seed"),i=hp(r,"publicKey");e===void 0&&(e=n.bytesLen),Cn(e);function o(s){ct(s,e);let a=n.decode(t(s,n.bytesLen)),u=r.map((m,p)=>m.keygen(a[p])),l=u.map(m=>m.secretKey),f=u.map(m=>m.publicKey);return{secretKey:l,publicKey:f}}return{info:{lengths:{seed:e,publicKey:i.bytesLen,secretKey:e}},getPublicKey(s){return this.keygen(s).publicKey},keygen(s=ra(e)){let{publicKey:a,secretKey:u}=o(s),l=i.encode(a);return cn(a),cn(u),{secretKey:s,publicKey:l}},expandDecapsulationKey:o,realSeedLen:e}}function Rm(e,t,r,n,...i){let o=Kj(e,r,...i),s=hp(i,"cipherText"),a=hp(i,"publicKey"),u=hp(i,"msg");return t===void 0&&(t=u.bytesLen),Cn(t),{lengths:{...o.info.lengths,msg:t,msgRand:u.bytesLen,cipherText:s.bytesLen},getPublicKey:o.getPublicKey,keygen:o.keygen,encapsulate(l,f=ra(u.bytesLen)){let m=a.decode(l),p=u.decode(f),d=i.map((w,E)=>w.encapsulate(m[E],p[E])),v=d.map(w=>w.sharedSecret),g=d.map(w=>w.cipherText),y={sharedSecret:n(m,g,v),cipherText:s.encode(g)};return cn(v,g),y},decapsulate(l,f){let m=s.decode(l),{publicKey:p,secretKey:d}=o.expandDecapsulationKey(f),v=i.map((g,y)=>g.decapsulate(m[y],d[y]));return n(p,m,v)}}}function bF(e,t,r,n,i){return Pi(n),Pi(i),Rm(32,32,JE(n),(o,s,a)=>i(nn(a[0],a[1],s[1],o[1],pc(e))),t,r)}var kce=bF("QSF-KEM(ML-KEM-768,P-256)-XOF(SHAKE256)-KDF(SHA3-256)",fp,XE(ME,!0),ta,Pl),Oce=bF("QSF-KEM(ML-KEM-1024,P-384)-XOF(SHAKE256)-KDF(SHA3-256)",EF,XE(QD,!0),ta,Pl);function Vj(e,t,r,n,i){return Pi(n),Pi(i),Rm(32,32,JE(n),(o,s,a)=>{let u=nn(a[0],a[1],s[0],o[0],s[1],o[1],pc(e)),l=32,f=nn(pc("hybrid_prk"),u),m=tF(i,f),p=nn(Yf(l,2),pc("shared_secret"),pc("")),d=rF(i,m,p,l);return cn(m,p,f,u),d},t,r)}var AF=XE(ZD),Nce=Vj("KitchenSink-KEM(ML-KEM-768,X25519)-XOF(SHAKE256)-KDF(HKDF-SHA-256)",fp,AF,ta,Bm),zj=Rm(32,32,JE(ta),(e,t,r)=>Pl(nn(r[0],r[1],t[1],e[1],pc("\\.//^\\"))),fp,AF);function Gj(e,t,r,n){let i=e.Point.Fn;if(!i)throw new Error("no Point.Fn");function o(s){let a;for(let f=0,m=t;;f=m,m+=t){if(m>s.length)throw new Error("rejection sampling failed");if(a=i.fromBytes(s.subarray(f,m),!0),i.isValidNot0(a))break}let u=i.toBytes(i.create(a)),l=e.getPublicKey(u,!1);return{secretKey:u,publicKey:l}}return{lengths:{secretKey:t,publicKey:r,seed:n,msg:n,cipherText:r},keygen(s=ra(n)){return ct(s,n,"seed"),o(s)},getPublicKey(s){return e.getPublicKey(s,!1)},encapsulate(s,a=ra(n)){ct(a,n,"rand");let{secretKey:u}=o(a),l=this.decapsulate(s,u),f=e.getPublicKey(u,!1);return cn(u),{sharedSecret:l,cipherText:f}},decapsulate(s,a){return e.getSharedSecret(a,s).subarray(1)}}}function Yj(e,t,r,n){let{secretKey:i,publicKeyUncompressed:o}=r.lengths;if(!i||!o)throw new Error("wrong curve");let s=Gj(r,i,o,n),a=64,u=a+n;return Rm(32,32,l=>{ct(l,32);let f=ta(l,{dkLen:u}),m=f.subarray(0,a),p=f.subarray(a,u);return nn(m,p)},(l,f,m)=>Pl(nn(m[0],m[1],f[1],l[1],pc(e))),t,s)}var Wj=Yj("MLKEM768-P256",fp,ME,128);var km=zj,SF=Wj;var hle=B(T(),1);var qce=B(T(),1);var gr=(e,t,r)=>On(e,t,r),QE=Yr,Qf=am,Hn=(...e)=>Ky(...e),eh=e=>qd(e),th=My,rh=e=>Xo(e),Nm=BigInt(0),ZE=BigInt(1);function fu(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new TypeError(r+"expected boolean, got type="+typeof e)}return e}function Lm(e){if(typeof e=="bigint"){if(!Om(e))throw new RangeError("positive bigint expected, got "+e)}else QE(e);return e}function na(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(r+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){let r=t&&`"${t}" `;throw new RangeError(r+"expected safe integer, got "+e)}}function dp(e){let t=Lm(e).toString(16);return t.length&1?"0"+t:t}function CF(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);return e===""?Nm:BigInt("0x"+e)}function Ol(e){return CF(am(e))}function io(e){return CF(am(yc(On(e)).reverse()))}function Um(e,t){if(Yr(t),t===0)throw new RangeError("zero length");e=Lm(e);let r=e.toString(16);if(r.length>t*2)throw new RangeError("number too large");return qd(r.padStart(t*2,"0"))}function pp(e,t){return Um(e,t).reverse()}function _F(e,t){if(e=gr(e),t=gr(t),e.length!==t.length)return!1;let r=0;for(let n=0;n{let n=t.charCodeAt(0);if(t.length!==1||n>127)throw new RangeError(`string contains non-ASCII character "${e[r]}" with code ${n} at position ${r}`);return n})}var Om=e=>typeof e=="bigint"&&Nm<=e;function Xj(e,t,r){return Om(e)&&Om(t)&&Om(r)&&t<=e&&eNm;e>>=ZE,t+=1);return t}var mp=e=>(ZE<new Uint8Array(y),i=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,u=n(e),l=n(e),f=0,m=()=>{u.fill(1),l.fill(0),f=0},p=(...y)=>r(l,Hn(u,...y)),d=(y=i)=>{l=p(o,y),u=p(),y.length!==0&&(l=p(s,y),u=p())},v=()=>{if(f++>=a)throw new Error("drbg: tried max amount of iterations");let y=0,w=[];for(;y{m(),d(y);let E;for(;(E=w(v()))===void 0;)d();return m(),E}}function Ri(e,t={},r={}){if(Object.prototype.toString.call(e)!=="[object Object]")throw new TypeError("expected valid options object");function n(o,s,a){if(!a&&s!=="function"&&!Object.hasOwn(e,o))throw new TypeError(`param "${o}" is invalid: expected own property`);let u=e[o];if(a&&u===void 0)return;let l=typeof u;if(l!==s||u===null)throw new TypeError(`param "${o}" is invalid: expected ${s}, got ${l}`)}let i=(o,s)=>Object.entries(o).forEach(([a,u])=>n(a,u,s));i(t,!1),i(r,!0)}var eb=()=>{throw new Error("not implemented")};var Wce=B(T(),1);var Vce=B(T(),1);var Mn=BigInt(0),Ur=BigInt(1),Nl=BigInt(2),$F=BigInt(3),TF=BigInt(4),PF=BigInt(5),Jj=BigInt(7),xF=BigInt(8),Zj=BigInt(9),RF=BigInt(16);function Fr(e,t){if(t<=Mn)throw new Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=Mn?r:t+r}function ki(e,t,r){if(tMn;)n*=n,n%=r;return n}function FF(e,t){if(e===Mn)throw new Error("invert: expected non-zero number");if(t<=Mn)throw new Error("invert: expected positive modulus, got "+t);let r=Fr(e,t),n=t,i=Mn,o=Ur,s=Ur,a=Mn;for(;r!==Mn;){let l=n/r,f=n-r*l,m=i-s*l,p=o-a*l;n=r,r=f,i=s,o=a,s=m,a=p}if(n!==Ur)throw new Error("invert: does not exist");return Fr(i,t)}function tb(e,t,r){let n=e;if(!n.eql(n.sqr(t),r))throw new Error("Cannot find square root")}function kF(e,t){let r=e,n=(r.ORDER+Ur)/TF,i=r.pow(t,n);return tb(r,i,t),i}function Qj(e,t){let r=e,n=(r.ORDER-PF)/xF,i=r.mul(t,Nl),o=r.pow(i,n),s=r.mul(t,o),a=r.mul(r.mul(s,Nl),o),u=r.mul(s,r.sub(a,r.ONE));return tb(r,u,t),u}function eK(e){let t=qm(e),r=OF(e),n=r(t,t.neg(t.ONE)),i=r(t,n),o=r(t,t.neg(n)),s=(e+Jj)/RF;return(a,u)=>{let l=a,f=l.pow(u,s),m=l.mul(f,n),p=l.mul(f,i),d=l.mul(f,o),v=l.eql(l.sqr(m),u),g=l.eql(l.sqr(p),u);f=l.cmov(f,m,v),m=l.cmov(d,p,g);let y=l.eql(l.sqr(m),u),w=l.cmov(f,m,y);return tb(l,w,u),w}}function OF(e){if(e<$F)throw new Error("sqrt is not defined for small field");let t=e-Ur,r=0;for(;t%Nl===Mn;)t/=Nl,r++;let n=Nl,i=qm(e);for(;IF(i,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return kF;let o=i.pow(n,t),s=(t+Ur)/Nl;return function(u,l){let f=u;if(f.is0(l))return l;if(IF(f,l)!==1)throw new Error("Cannot find square root");let m=r,p=f.mul(f.ONE,o),d=f.pow(l,t),v=f.pow(l,s);for(;!f.eql(d,f.ONE);){if(f.is0(d))return f.ZERO;let g=1,y=f.sqr(d);for(;!f.eql(y,f.ONE);)if(g++,y=f.sqr(y),g===m)throw new Error("Cannot find square root");let w=Ur<(Fr(e,t)&Ur)===Ur,rK=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function rb(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=rK.reduce((n,i)=>(n[i]="function",n),t);if(Ri(e,r),na(e.BYTES,"BYTES"),na(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=Ur)throw new Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function nK(e,t,r){let n=e;if(rMn;)r&Ur&&(i=n.mul(i,o)),o=n.sqr(o),r>>=Ur;return i}function gp(e,t,r=!1){let n=e,i=new Array(t.length).fill(r?n.ZERO:void 0),o=t.reduce((a,u,l)=>n.is0(u)?a:(i[l]=a,n.mul(a,u)),n.ONE),s=n.inv(o);return t.reduceRight((a,u,l)=>n.is0(u)?a:(i[l]=n.mul(a,i[l]),n.mul(a,u)),s),i}function IF(e,t){let r=e,n=(r.ORDER-Ur)/Nl,i=r.pow(t,n),o=r.eql(i,r.ONE),s=r.eql(i,r.ZERO),a=r.eql(i,r.neg(r.ONE));if(!o&&!s&&!a)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function sK(e,t){if(t!==void 0&&QE(t),e<=Mn)throw new Error("invalid n length: expected positive n, got "+e);if(t!==void 0&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);let r=nh(e);if(t!==void 0&&t= n.length (${t})`);let n=t!==void 0?t:r,i=Math.ceil(n/8);return{nBitLength:n,nByteLength:i}}var BF=new WeakMap,Mm=class{ORDER;BITS;BYTES;isLE;ZERO=Mn;ONE=Ur;_lengths;_mod;constructor(t,r={}){if(t<=Ur)throw new Error("invalid field: expected ORDER > 1, got "+t);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:r.sqrt,enumerable:!0}),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=Object.freeze(r.allowedLengths.slice())),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:i,nByteLength:o}=sK(t,n);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=i,this.BYTES=o,Object.freeze(this)}create(t){return Fr(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return Mn<=t&&ti)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let l=new Uint8Array(i);l.set(t,o?0:l.length-t.length),t=l}if(t.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+t.length);let u=o?io(t):Ol(t);if(a&&(u=Fr(u,s)),!r&&!this.isValid(u))throw new Error("invalid field element: outside of range 0..ORDER");return u}invertBatch(t){return gp(this,t)}cmov(t,r,n){return fu(n,"condition"),n?r:t}};Object.freeze(Mm.prototype);function qm(e,t={}){return new Mm(e,t)}function NF(e){if(typeof e!="bigint")throw new Error("field order must be bigint");if(e<=Ur)throw new Error("field order must be greater than 1");let t=nh(e-Ur);return Math.ceil(t/8)}function nb(e){let t=NF(e);return t+Math.ceil(t/2)}function LF(e,t,r=!1){gr(e);let n=e.length,i=NF(t),o=Math.max(nb(t),16);if(n1024)throw new Error("expected "+o+"-1024 bytes of input, got "+n);let s=r?io(e):Ol(e),a=Fr(s,t-Ur)+Ur;return r?pp(a,i):Um(a,i)}var sh=BigInt(0),Ll=BigInt(1);function vp(e,t){let r=t.negate();return e?r:t}function Ul(e,t){let r=gp(e.Fp,t.map(n=>n.Z));return t.map((n,i)=>e.fromAffine(n.toAffine(r[i])))}function qF(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function sb(e,t){qF(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),i=2**e,o=mp(e),s=BigInt(e);return{windows:r,windowSize:n,mask:o,maxNumber:i,shiftBy:s}}function UF(e,t,r){let{windowSize:n,mask:i,maxNumber:o,shiftBy:s}=r,a=Number(e&i),u=e>>s;a>n&&(a-=o,u+=Ll);let l=t*n,f=l+Math.abs(a)-1,m=a===0,p=a<0,d=t%2!==0;return{nextN:u,offset:f,isZero:m,isNeg:p,isNegF:d,offsetF:l}}var ib=new WeakMap,jF=new WeakMap;function ob(e){return jF.get(e)||1}function HF(e){if(e!==sh)throw new Error("invalid wNAF")}var ih=class{BASE;ZERO;Fn;bits;constructor(t,r){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=r}_unsafeLadder(t,r,n=this.ZERO){let i=t;for(;r>sh;)r&Ll&&(n=n.add(i)),i=i.double(),r>>=Ll;return n}precomputeWindow(t,r){let{windows:n,windowSize:i}=sb(r,this.bits),o=[],s=t,a=s;for(let u=0;ush||n>sh;)r&Ll&&(o=o.add(i)),n&Ll&&(s=s.add(i)),i=i.double(),r>>=Ll,n>>=Ll;return{p1:o,p2:s}}function MF(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return rb(t),t}else return qm(e,{isLE:r})}function jm(e,t,r={},n){if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(let u of["p","n","h"]){let l=t[u];if(!(typeof l=="bigint"&&l>sh))throw new Error(`CURVE.${u} must be positive bigint`)}let i=MF(t.p,r.Fp,n),o=MF(t.n,r.Fn,n),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let u of a)if(!i.isValid(t[u]))throw new Error(`CURVE.${u} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:o}}function wp(e,t){return function(n){let i=e(n);return{secretKey:i,publicKey:t(i)}}}var Zce=B(T(),1);function yp(e,t){if(na(e),na(t),t<0||t>4)throw new Error("invalid I2OSP length: "+t);if(e<0||e>2**(8*t)-1)throw new Error("invalid I2OSP input: "+e);let r=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)r[n]=e&255,e>>>=8;return new Uint8Array(r)}function iK(e,t){let r=new Uint8Array(e.length);for(let n=0;n255&&(t=n(Hn(Hm("H2C-OVERSIZE-DST-"),t)));let{outputLen:i,blockLen:o}=n,s=Math.ceil(r/i);if(r>65535||s>255)throw new Error("expand_message_xmd: invalid lenInBytes");let a=Hn(t,yp(t.length,1)),u=new Uint8Array(o),l=yp(r,2),f=new Array(s),m=n(Hn(u,e,l,yp(0,1),a));f[0]=n(Hn(m,yp(1,1),a));for(let d=1;d(e+(e>=0?t:-t)/GF)/t;function aK(e,t,r){hu("scalar",e,sa,r);let[[n,i],[o,s]]=t,a=zF(s*e,r),u=zF(-i*e,r),l=e-a*n-u*o,f=-a*i-u*s,m=l=d||f=d)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:m,k1:l,k2neg:p,k2:f}}function cb(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function ub(e,t){Ri(e);let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return fu(r.lowS,"lowS"),fu(r.prehash,"prehash"),r.format!==void 0&&cb(r.format),r}var lb=class extends Error{constructor(t=""){super(t)}},oo={Err:lb,_tlv:{encode:(e,t)=>{let{Err:r}=oo;if(na(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(typeof t!="string")throw new TypeError('"data" expected string, got type='+typeof t);if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,i=dp(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let o=n>127?dp(i.length/2|128):"";return dp(e)+o+i+t},decode(e,t){let{Err:r}=oo;t=gr(t,void 0,"DER data");let n=0;if(e<0||e>255)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let i=t[n++],o=!!(i&128),s=0;if(!o)s=i;else{let u=i&127;if(!u)throw new r("tlv.decode(long): indefinite length not supported");if(u>4)throw new r("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+u);if(l.length!==u)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let f of l)s=s<<8|f;if(n+=u,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+s)}}},_int:{encode(e){let{Err:t}=oo;if(Lm(e),e1&&e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Ol(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=oo,i=gr(e,void 0,"signature"),{v:o,l:s}=n.decode(48,i);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:u}=n.decode(2,o),{v:l,l:f}=n.decode(2,u);if(f.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(e){let{_tlv:t,_int:r}=oo,n=t.encode(2,r.encode(e.r)),i=t.encode(2,r.encode(e.s)),o=n+i;return t.encode(48,o)}};Object.freeze(oo._tlv);Object.freeze(oo._int);Object.freeze(oo);var sa=BigInt(0),Ec=BigInt(1),GF=BigInt(2),Km=BigInt(3),uK=BigInt(4);function YF(e,t={}){let r=jm("weierstrass",e,t),n=r.Fp,i=r.Fn,o=r.CURVE,{h:s,n:a}=o;Ri(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:u,allowInfinityPoint:l}=t;if(u&&(!n.is0(o.a)||typeof u.beta!="bigint"||!Array.isArray(u.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let f=XF(n,i);function m(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function p(k,O,q){if(l&&O.is0())return Uint8Array.of(0);let{x:N,y:_}=O.toAffine(),R=n.toBytes(N);if(fu(q,"isCompressed"),q){m();let K=!n.isOdd(_);return Hn(WF(K),R)}else return Hn(Uint8Array.of(4),R,n.toBytes(_))}function d(k){gr(k,void 0,"Point");let{publicKey:O,publicKeyUncompressed:q}=f,N=k.length,_=k[0],R=k.subarray(1);if(l&&N===1&&_===0)return{x:n.ZERO,y:n.ZERO};if(N===O&&(_===2||_===3)){let K=n.fromBytes(R);if(!n.isValid(K))throw new Error("bad point: is not on curve, wrong x");let Z=y(K),Y;try{Y=n.sqrt(Z)}catch(fe){let ve=fe instanceof Error?": "+fe.message:"";throw new Error("bad point: is not on curve, sqrt error"+ve)}m();let te=n.isOdd(Y);return(_&1)===1!==te&&(Y=n.neg(Y)),{x:K,y:Y}}else if(N===q&&_===4){let K=n.BYTES,Z=n.fromBytes(R.subarray(0,K)),Y=n.fromBytes(R.subarray(K,K*2));if(!w(Z,Y))throw new Error("bad point: is not on curve");return{x:Z,y:Y}}else throw new Error(`bad point: got length ${N}, expected compressed=${O} or uncompressed=${q}`)}let v=t.toBytes===void 0?p:t.toBytes,g=t.fromBytes===void 0?d:t.fromBytes;function y(k){let O=n.sqr(k),q=n.mul(O,k);return n.add(n.add(q,n.mul(k,o.a)),o.b)}function w(k,O){let q=n.sqr(O),N=y(k);return n.eql(q,N)}if(!w(o.Gx,o.Gy))throw new Error("bad curve params: generator point");let E=n.mul(n.pow(o.a,Km),uK),S=n.mul(n.sqr(o.b),BigInt(27));if(n.is0(n.add(E,S)))throw new Error("bad curve params: a or b");function D(k,O,q=!1){if(!n.isValid(O)||q&&n.is0(O))throw new Error(`bad point coordinate ${k}`);return O}function F(k){if(!(k instanceof C))throw new Error("Weierstrass Point expected")}function M(k){if(!u||!u.basises)throw new Error("no endo");return aK(k,u.basises,i.ORDER)}function z(k,O,q,N,_){return q=new C(n.mul(q.X,k),q.Y,q.Z),O=vp(N,O),q=vp(_,q),O.add(q)}class C{static BASE=new C(o.Gx,o.Gy,n.ONE);static ZERO=new C(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=i;X;Y;Z;constructor(O,q,N){this.X=D("x",O),this.Y=D("y",q,!0),this.Z=D("z",N),Object.freeze(this)}static CURVE(){return o}static fromAffine(O){let{x:q,y:N}=O||{};if(!O||!n.isValid(q)||!n.isValid(N))throw new Error("invalid affine point");if(O instanceof C)throw new Error("projective point not allowed");return n.is0(q)&&n.is0(N)?C.ZERO:new C(q,N,n.ONE)}static fromBytes(O){let q=C.fromAffine(g(gr(O,void 0,"point")));return q.assertValidity(),q}static fromHex(O){return C.fromBytes(eh(O))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(O=8,q=!0){return U.createCache(this,O),q||this.multiply(Km),this}assertValidity(){let O=this;if(O.is0()){if(t.allowInfinityPoint&&n.is0(O.X)&&n.eql(O.Y,n.ONE)&&n.is0(O.Z))return;throw new Error("bad point: ZERO")}let{x:q,y:N}=O.toAffine();if(!n.isValid(q)||!n.isValid(N))throw new Error("bad point: x or y not field elements");if(!w(q,N))throw new Error("bad point: equation left != right");if(!O.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:O}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(O)}equals(O){F(O);let{X:q,Y:N,Z:_}=this,{X:R,Y:K,Z}=O,Y=n.eql(n.mul(q,Z),n.mul(R,_)),te=n.eql(n.mul(N,Z),n.mul(K,_));return Y&&te}negate(){return new C(this.X,n.neg(this.Y),this.Z)}double(){let{a:O,b:q}=o,N=n.mul(q,Km),{X:_,Y:R,Z:K}=this,Z=n.ZERO,Y=n.ZERO,te=n.ZERO,se=n.mul(_,_),fe=n.mul(R,R),ve=n.mul(K,K),we=n.mul(_,R);return we=n.add(we,we),te=n.mul(_,K),te=n.add(te,te),Z=n.mul(O,te),Y=n.mul(N,ve),Y=n.add(Z,Y),Z=n.sub(fe,Y),Y=n.add(fe,Y),Y=n.mul(Z,Y),Z=n.mul(we,Z),te=n.mul(N,te),ve=n.mul(O,ve),we=n.sub(se,ve),we=n.mul(O,we),we=n.add(we,te),te=n.add(se,se),se=n.add(te,se),se=n.add(se,ve),se=n.mul(se,we),Y=n.add(Y,se),ve=n.mul(R,K),ve=n.add(ve,ve),se=n.mul(ve,we),Z=n.sub(Z,se),te=n.mul(ve,fe),te=n.add(te,te),te=n.add(te,te),new C(Z,Y,te)}add(O){F(O);let{X:q,Y:N,Z:_}=this,{X:R,Y:K,Z}=O,Y=n.ZERO,te=n.ZERO,se=n.ZERO,fe=o.a,ve=n.mul(o.b,Km),we=n.mul(q,R),Te=n.mul(N,K),Le=n.mul(_,Z),Oe=n.add(q,N),le=n.add(R,K);Oe=n.mul(Oe,le),le=n.add(we,Te),Oe=n.sub(Oe,le),le=n.add(q,_);let Se=n.add(R,Z);return le=n.mul(le,Se),Se=n.add(we,Le),le=n.sub(le,Se),Se=n.add(N,_),Y=n.add(K,Z),Se=n.mul(Se,Y),Y=n.add(Te,Le),Se=n.sub(Se,Y),se=n.mul(fe,le),Y=n.mul(ve,Le),se=n.add(Y,se),Y=n.sub(Te,se),se=n.add(Te,se),te=n.mul(Y,se),Te=n.add(we,we),Te=n.add(Te,we),Le=n.mul(fe,Le),le=n.mul(ve,le),Te=n.add(Te,Le),Le=n.sub(we,Le),Le=n.mul(fe,Le),le=n.add(le,Le),we=n.mul(Te,le),te=n.add(te,we),we=n.mul(Se,le),Y=n.mul(Oe,Y),Y=n.sub(Y,we),we=n.mul(Oe,Te),se=n.mul(Se,se),se=n.add(se,we),new C(Y,te,se)}subtract(O){return F(O),this.add(O.negate())}is0(){return this.equals(C.ZERO)}multiply(O){let{endo:q}=t;if(!i.isValidNot0(O))throw new RangeError("invalid scalar: out of range");let N,_,R=K=>U.cached(this,K,Z=>Ul(C,Z));if(q){let{k1neg:K,k1:Z,k2neg:Y,k2:te}=M(O),{p:se,f:fe}=R(Z),{p:ve,f:we}=R(te);_=fe.add(we),N=z(q.beta,se,ve,K,Y)}else{let{p:K,f:Z}=R(O);N=K,_=Z}return Ul(C,[N,_])[0]}multiplyUnsafe(O){let{endo:q}=t,N=this,_=O;if(!i.isValid(_))throw new RangeError("invalid scalar: out of range");if(_===sa||N.is0())return C.ZERO;if(_===Ec)return N;if(U.hasCache(this))return this.multiply(_);if(q){let{k1neg:R,k1:K,k2neg:Z,k2:Y}=M(_),{p1:te,p2:se}=KF(C,N,K,Y);return z(q.beta,te,se,R,Z)}else return U.unsafe(N,_)}toAffine(O){let q=this,N=O,{X:_,Y:R,Z:K}=q;if(n.eql(K,n.ONE))return{x:_,y:R};let Z=q.is0();N==null&&(N=Z?n.ONE:n.inv(K));let Y=n.mul(_,N),te=n.mul(R,N),se=n.mul(K,N);if(Z)return{x:n.ZERO,y:n.ZERO};if(!n.eql(se,n.ONE))throw new Error("invZ was invalid");return{x:Y,y:te}}isTorsionFree(){let{isTorsionFree:O}=t;return s===Ec?!0:O?O(C,this):U.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:O}=t;return s===Ec?this:O?O(C,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===Ec?this.is0():this.clearCofactor().is0()}toBytes(O=!0){return fu(O,"isCompressed"),this.assertValidity(),v(C,this,O)}toHex(O=!0){return Qf(this.toBytes(O))}toString(){return``}}let P=i.BITS,U=new ih(C,t.endo?Math.ceil(P/2):P);return P>=8&&C.BASE.precompute(8),Object.freeze(C.prototype),Object.freeze(C),C}function WF(e){return Uint8Array.of(e?2:3)}function XF(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function cK(e,t={}){let{Fn:r}=e,n=t.randomBytes===void 0?rh:t.randomBytes,i=Object.assign(XF(e.Fp,r),{seed:Math.max(nb(r.ORDER),16)});function o(d){try{let v=r.fromBytes(d);return r.isValidNot0(v)}catch{return!1}}function s(d,v){let{publicKey:g,publicKeyUncompressed:y}=i;try{let w=d.length;return v===!0&&w!==g||v===!1&&w!==y?!1:!!e.fromBytes(d)}catch{return!1}}function a(d){return d=d===void 0?n(i.seed):d,LF(gr(d,i.seed,"seed"),r.ORDER)}function u(d,v=!0){return e.BASE.multiply(r.fromBytes(d)).toBytes(v)}function l(d){let{secretKey:v,publicKey:g,publicKeyUncompressed:y}=i,w=r._lengths;if(!th(d))return;let E=gr(d,void 0,"key").length,S=E===g||E===y,D=E===v||!!w?.includes(E);if(!(S&&D))return S}function f(d,v,g=!0){if(l(d)===!0)throw new Error("first arg must be private key");if(l(v)===!1)throw new Error("second arg must be public key");let y=r.fromBytes(d);return e.fromBytes(v).multiply(y).toBytes(g)}let m={isValidSecretKey:o,isValidPublicKey:s,randomSecretKey:a},p=wp(a,u);return Object.freeze(m),Object.freeze(i),Object.freeze({getPublicKey:u,getSharedSecret:f,keygen:p,Point:e,utils:m,lengths:i})}function JF(e,t,r={}){let n=t;nu(n),Ri(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let i=r.randomBytes===void 0?rh:r.randomBytes,o=r.hmac===void 0?(_,R)=>Jo(n,_,R):r.hmac,{Fp:s,Fn:a}=e,{ORDER:u,BITS:l}=a,{keygen:f,getPublicKey:m,getSharedSecret:p,utils:d,lengths:v}=cK(e,r),g={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},y=u*GF+Ec>Ec;return _>R}function E(_,R){if(!a.isValidNot0(R))throw new Error(`invalid signature ${_}: out of range 1..Point.Fn.ORDER`);return R}function S(){if(y)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function D(_,R){cb(R);let K=v.signature,Z=R==="compact"?K:R==="recovered"?K+1:void 0;return gr(_,Z)}class F{r;s;recovery;constructor(R,K,Z){if(this.r=E("r",R),this.s=E("s",K),Z!=null){if(S(),![0,1,2,3].includes(Z))throw new Error("invalid recovery id");this.recovery=Z}Object.freeze(this)}static fromBytes(R,K=g.format){D(R,K);let Z;if(K==="der"){let{r:fe,s:ve}=oo.toSig(gr(R));return new F(fe,ve)}K==="recovered"&&(Z=R[0],K="compact",R=R.subarray(1));let Y=v.signature/2,te=R.subarray(0,Y),se=R.subarray(Y,Y*2);return new F(a.fromBytes(te),a.fromBytes(se),Z)}static fromHex(R,K){return this.fromBytes(eh(R),K)}assertRecovery(){let{recovery:R}=this;if(R==null)throw new Error("invalid recovery id: must be present");return R}addRecoveryBit(R){return new F(this.r,this.s,R)}recoverPublicKey(R){let{r:K,s:Z}=this,Y=this.assertRecovery(),te=Y===2||Y===3?K+u:K;if(!s.isValid(te))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let se=s.toBytes(te),fe=e.fromBytes(Hn(WF((Y&1)===0),se)),ve=a.inv(te),we=z(gr(R,void 0,"msgHash")),Te=a.create(-we*ve),Le=a.create(Z*ve),Oe=e.BASE.multiplyUnsafe(Te).add(fe.multiplyUnsafe(Le));if(Oe.is0())throw new Error("invalid recovery: point at infinify");return Oe.assertValidity(),Oe}hasHighS(){return w(this.s)}toBytes(R=g.format){if(cb(R),R==="der")return eh(oo.hexFromSig(this));let{r:K,s:Z}=this,Y=a.toBytes(K),te=a.toBytes(Z);return R==="recovered"?(S(),Hn(Uint8Array.of(this.assertRecovery()),Y,te)):Hn(Y,te)}toHex(R){return Qf(this.toBytes(R))}}Object.freeze(F.prototype),Object.freeze(F);let M=r.bits2int===void 0?function(R){if(R.length>8192)throw new Error("input is too large");let K=Ol(R),Z=R.length*8-l;return Z>0?K>>BigInt(Z):K}:r.bits2int,z=r.bits2int_modN===void 0?function(R){return a.create(M(R))}:r.bits2int_modN,C=mp(l);function P(_){return hu("num < 2^"+l,_,sa,C),a.toBytes(_)}function U(_,R){return gr(_,void 0,"message"),R?gr(n(_),void 0,"prehashed message"):_}function k(_,R,K){let{lowS:Z,prehash:Y,extraEntropy:te}=ub(K,g);_=U(_,Y);let se=z(_),fe=a.fromBytes(R);if(!a.isValidNot0(fe))throw new Error("invalid private key");let ve=[P(fe),P(se)];if(te!=null&&te!==!1){let Oe=te===!0?i(v.secretKey):te;ve.push(gr(Oe,void 0,"extraEntropy"))}let we=Hn(...ve),Te=se;function Le(Oe){let le=M(Oe);if(!a.isValidNot0(le))return;let Se=a.inv(le),Re=e.BASE.multiply(le).toAffine(),Ve=a.create(Re.x);if(Ve===sa)return;let rt=a.create(Se*a.create(Te+Ve*fe));if(rt===sa)return;let qe=(Re.x===Ve?0:2)|Number(Re.y&Ec),At=rt;return Z&&w(rt)&&(At=a.neg(rt),qe^=1),new F(Ve,At,y?void 0:qe)}return{seed:we,k2sig:Le}}function O(_,R,K={}){let{seed:Z,k2sig:Y}=k(_,R,K);return DF(n.outputLen,a.BYTES,o)(Z,Y).toBytes(K.format)}function q(_,R,K,Z={}){let{lowS:Y,prehash:te,format:se}=ub(Z,g);if(K=gr(K,void 0,"publicKey"),R=U(R,te),!th(_)){let fe=_ instanceof F?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+fe)}D(_,se);try{let fe=F.fromBytes(_,se),ve=e.fromBytes(K);if(Y&&fe.hasHighS())return!1;let{r:we,s:Te}=fe,Le=z(R),Oe=a.inv(Te),le=a.create(Le*Oe),Se=a.create(we*Oe),Re=e.BASE.multiplyUnsafe(le).add(ve.multiplyUnsafe(Se));return Re.is0()?!1:a.create(Re.x)===we}catch{return!1}}function N(_,R,K={}){let{prehash:Z}=ub(K,g);return R=U(R,Z),F.fromBytes(_,"recovered").recoverPublicKey(R).toBytes()}return Object.freeze({keygen:f,getPublicKey:m,getSharedSecret:p,utils:d,lengths:v,Point:e,sign:O,verify:q,recoverPublicKey:N,Signature:F,hash:n})}var lK={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")};var fK=YF(lK),oh=JF(fK,Wr);var kle=B(T(),1);var xle=B(T(),1);var gle=B(T(),1);var bc=BigInt(0),Gs=BigInt(1),fb=BigInt(2),hK=BigInt(8);function dK(e,t,r,n){let i=e.sqr(r),o=e.sqr(n),s=e.add(e.mul(t.a,i),o),a=e.add(e.ONE,e.mul(t.d,e.mul(i,o)));return e.eql(s,a)}function ZF(e,t={}){let r=t,n=jm("edwards",e,r,r.FpFnLE),{Fp:i,Fn:o}=n,s=n.CURVE,{h:a}=s;Ri(r,{},{uvRatio:"function"});let u=fb<i.create(g),f=r.uvRatio===void 0?(g,y)=>{try{return{isValid:!0,value:i.sqrt(i.div(g,y))}}catch{return{isValid:!1,value:bc}}}:r.uvRatio;if(!dK(i,s,s.Gx,s.Gy))throw new Error("bad curve params: generator point");function m(g,y,w=!1){let E=w?Gs:bc;return hu("coordinate "+g,y,E,u),y}function p(g){if(!(g instanceof d))throw new Error("EdwardsPoint expected")}class d{static BASE=new d(s.Gx,s.Gy,Gs,l(s.Gx*s.Gy));static ZERO=new d(bc,Gs,Gs,bc);static Fp=i;static Fn=o;X;Y;Z;T;constructor(y,w,E,S){this.X=m("x",y),this.Y=m("y",w),this.Z=m("z",E,!0),this.T=m("t",S),Object.freeze(this)}static CURVE(){return s}static fromAffine(y){if(y instanceof d)throw new Error("extended point not allowed");let{x:w,y:E}=y||{};return m("x",w),m("y",E),new d(w,E,Gs,l(w*E))}static fromBytes(y,w=!1){let E=i.BYTES,{a:S,d:D}=s;y=yc(gr(y,E,"point")),fu(w,"zip215");let F=yc(y),M=y[E-1];F[E-1]=M&-129;let z=io(F),C=w?u:i.ORDER;hu("point.y",z,bc,C);let P=l(z*z),U=l(P-Gs),k=l(D*P-S),{isValid:O,value:q}=f(U,k);if(!O)throw new Error("bad point: invalid y coordinate");let N=(q&Gs)===Gs,_=(M&128)!==0;if(!w&&q===bc&&_)throw new Error("bad point: x=0 and x_0=1");return _!==N&&(q=l(-q)),d.fromAffine({x:q,y:z})}static fromHex(y,w=!1){return d.fromBytes(eh(y),w)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(y=8,w=!0){return v.createCache(this,y),w||this.multiply(fb),this}assertValidity(){let y=this,{a:w,d:E}=s;if(y.is0())throw new Error("bad point: ZERO");let{X:S,Y:D,Z:F,T:M}=y,z=l(S*S),C=l(D*D),P=l(F*F),U=l(P*P),k=l(z*w),O=l(P*l(k+C)),q=l(U+l(E*l(z*C)));if(O!==q)throw new Error("bad point: equation left != right (1)");let N=l(S*D),_=l(F*M);if(N!==_)throw new Error("bad point: equation left != right (2)")}equals(y){p(y);let{X:w,Y:E,Z:S}=this,{X:D,Y:F,Z:M}=y,z=l(w*M),C=l(D*S),P=l(E*M),U=l(F*S);return z===C&&P===U}is0(){return this.equals(d.ZERO)}negate(){return new d(l(-this.X),this.Y,this.Z,l(-this.T))}double(){let{a:y}=s,{X:w,Y:E,Z:S}=this,D=l(w*w),F=l(E*E),M=l(fb*l(S*S)),z=l(y*D),C=w+E,P=l(l(C*C)-D-F),U=z+F,k=U-M,O=z-F,q=l(P*k),N=l(U*O),_=l(P*O),R=l(k*U);return new d(q,N,R,_)}add(y){p(y);let{a:w,d:E}=s,{X:S,Y:D,Z:F,T:M}=this,{X:z,Y:C,Z:P,T:U}=y,k=l(S*z),O=l(D*C),q=l(M*E*U),N=l(F*P),_=l((S+D)*(z+C)-k-O),R=N-q,K=N+q,Z=l(O-w*k),Y=l(_*R),te=l(K*Z),se=l(_*Z),fe=l(R*K);return new d(Y,te,fe,se)}subtract(y){return p(y),this.add(y.negate())}multiply(y){if(!o.isValidNot0(y))throw new RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:w,f:E}=v.cached(this,y,S=>Ul(d,S));return Ul(d,[w,E])[0]}multiplyUnsafe(y){if(!o.isValid(y))throw new RangeError("invalid scalar: expected 0 <= sc < curve.n");return y===bc?d.ZERO:this.is0()||y===Gs?this:v.unsafe(this,y,w=>Ul(d,w))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return v.unsafe(this,s.n).is0()}toAffine(y){let w=this,E=y,{X:S,Y:D,Z:F}=w,M=w.is0();E==null&&(E=M?hK:i.inv(F));let z=l(S*E),C=l(D*E),P=i.mul(F,E);if(M)return{x:bc,y:Gs};if(P!==Gs)throw new Error("invZ was invalid");return{x:z,y:C}}clearCofactor(){return a===Gs?this:this.multiplyUnsafe(a)}toBytes(){let{x:y,y:w}=this.toAffine(),E=i.toBytes(w);return E[E.length-1]|=y&Gs?128:0,E}toHex(){return Qf(this.toBytes())}toString(){return``}}let v=new ih(d,o.BITS);return o.BITS>=8&&d.BASE.precompute(8),Object.freeze(d.prototype),Object.freeze(d),d}var Vm=class{static BASE;static ZERO;static Fp;static Fn;ep;constructor(t){this.ep=t}static fromBytes(t){eb()}static fromHex(t){eb()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(t){return this.ep.toAffine(t)}toHex(){return Qf(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(t){return this.assertSame(t),this.init(this.ep.add(t.ep))}subtract(t){return this.assertSame(t),this.init(this.ep.subtract(t.ep))}multiply(t){return this.init(this.ep.multiply(t))}multiplyUnsafe(t){return this.init(this.ep.multiplyUnsafe(t))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(t,r){return this.ep.precompute(t,r),this}};var ble=B(T(),1);var Ep=BigInt(0),ah=BigInt(1),zm=BigInt(2);function pK(e){return Ri(e,{P:"bigint",type:"string",adjustScalarBytes:"function",powPminus2:"function"},{randomBytes:"function"}),Object.freeze({...e})}function QF(e){let t=pK(e),{P:r,type:n,adjustScalarBytes:i,powPminus2:o,randomBytes:s}=t,a=n==="x25519";if(!a&&n!=="x448")throw new Error("invalid type");let u=s===void 0?rh:s,l=a?255:448,f=a?32:56,m=BigInt(a?9:5),p=BigInt(a?121665:39081),d=a?zm**BigInt(254):zm**BigInt(447),v=a?BigInt(8)*zm**BigInt(251)-ah:BigInt(4)*zm**BigInt(445)-ah,g=d+v+ah,y=N=>Fr(N,r),w=E(m);function E(N){return pp(y(N),f)}function S(N){let _=yc(gr(N,f,"uCoordinate"));return a&&(_[31]&=127),y(io(_))}function D(N){return io(i(yc(gr(N,f,"scalar"))))}function F(N,_){let R=U(S(_),D(N));if(R===Ep)throw new Error("invalid private or public key received");return E(R)}function M(N){return F(N,w)}let z=M,C=F;function P(N,_,R){let K=y(N*(_-R));return _=y(_-K),R=y(R+K),{x_2:_,x_3:R}}function U(N,_){hu("u",N,Ep,r),hu("scalar",_,d,g);let R=_,K=N,Z=ah,Y=Ep,te=N,se=ah,fe=Ep;for(let we=BigInt(l-1);we>=Ep;we--){let Te=R>>we&ah;fe^=Te,{x_2:Z,x_3:te}=P(fe,Z,te),{x_2:Y,x_3:se}=P(fe,Y,se),fe=Te;let Le=Z+Y,Oe=y(Le*Le),le=Z-Y,Se=y(le*le),Re=Oe-Se,Ve=te+se,rt=te-se,qe=y(rt*Le),At=y(Ve*le),it=qe+At,Et=qe-At;te=y(it*it),se=y(K*y(Et*Et)),Z=y(Oe*Se),Y=y(Re*(Oe+y(p*Re)))}({x_2:Z,x_3:te}=P(fe,Z,te)),{x_2:Y,x_3:se}=P(fe,Y,se);let ve=o(Y);return y(Z*ve)}let k={secretKey:f,publicKey:f,seed:f},O=N=>(N=N===void 0?u(f):N,gr(N,k.seed,"seed"),N),q={randomSecretKey:O};return Object.freeze(k),Object.freeze(q),Object.freeze({keygen:wp(O,z),getSharedSecret:C,getPublicKey:z,scalarMult:F,scalarMultBase:M,utils:q,GuBytes:w.slice(),lengths:k})}var mK=BigInt(0),pu=BigInt(1),eI=BigInt(2),gK=BigInt(3),vK=BigInt(5),wK=BigInt(8),Ml=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),mb={p:Ml,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:wK,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function nI(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),o=Ml,a=e*e%o*e%o,u=ki(a,eI,o)*a%o,l=ki(u,pu,o)*e%o,f=ki(l,vK,o)*l%o,m=ki(f,t,o)*f%o,p=ki(m,r,o)*m%o,d=ki(p,n,o)*p%o,v=ki(d,i,o)*d%o,g=ki(v,i,o)*d%o,y=ki(g,t,o)*f%o;return{pow_p_5_8:ki(y,eI,o)*e%o,b2:a}}function yK(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var hb=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function gb(e,t){let r=Ml,n=Fr(t*t*t,r),i=Fr(n*n*t,r),o=nI(e*i).pow_p_5_8,s=Fr(e*n*o,r),a=Fr(t*s*s,r),u=s,l=Fr(s*hb,r),f=a===e,m=a===Fr(-e,r),p=a===Fr(-e*hb,r);return f&&(s=u),(m||p)&&(s=l),du(s,r)&&(s=Fr(-s,r)),{isValid:f||m,value:s}}var Hl=ZF(mb,{uvRatio:gb}),Ac=Hl.Fp,sI=Hl.Fn;var Gm=(()=>{let e=Ml;return QF({P:e,type:"x25519",powPminus2:t=>{let{pow_p_5_8:r,b2:n}=nI(t);return Fr(ki(r,gK,e)*n,e)},adjustScalarBytes:yK})})();var db=hb,EK=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),bK=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),AK=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),SK=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),tI=e=>gb(pu,e),CK=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),pb=e=>Ac.create(io(e)&CK);function rI(e){let{d:t}=mb,r=Ml,n=w=>Ac.create(w),i=n(db*e*e),o=n((i+pu)*AK),s=BigInt(-1),a=n((s-t*i)*n(i+t)),{isValid:u,value:l}=gb(o,a),f=n(l*e);du(f,r)||(f=n(-f)),u||(l=f),u||(s=i);let m=n(s*(i-pu)*SK-a),p=l*l,d=n((l+l)*a),v=n(m*EK),g=n(pu-p),y=n(pu+p);return new Hl(n(d*y),n(g*v),n(v*y),n(d*g))}var Sc=class e extends Vm{static BASE=new e(Hl.BASE);static ZERO=new e(Hl.ZERO);static Fp=Ac;static Fn=sI;constructor(t){super(t)}static fromAffine(t){return new e(Hl.fromAffine(t))}assertSame(t){if(!(t instanceof e))throw new Error("RistrettoPoint expected")}init(t){return new e(t)}static fromBytes(t){On(t,32);let{a:r,d:n}=mb,i=Ml,o=D=>Ac.create(D),s=pb(t);if(!_F(Ac.toBytes(s),t)||du(s,i))throw new Error("invalid ristretto255 encoding 1");let a=o(s*s),u=o(pu+r*a),l=o(pu-r*a),f=o(u*u),m=o(l*l),p=o(r*n*f-m),{isValid:d,value:v}=tI(o(p*m)),g=o(v*l),y=o(v*g*p),w=o((s+s)*g);du(w,i)&&(w=o(-w));let E=o(u*y),S=o(w*E);if(!d||du(S,i)||E===mK)throw new Error("invalid ristretto255 encoding 2");return new e(new Hl(w,E,pu,S))}static fromHex(t){return e.fromBytes(qd(t))}toBytes(){let{X:t,Y:r,Z:n,T:i}=this.ep,o=Ml,s=y=>Ac.create(y),a=s(s(n+r)*s(n-r)),u=s(t*r),l=s(u*u),{value:f}=tI(s(a*l)),m=s(f*a),p=s(f*u),d=s(m*p*i),v;if(du(i*d,o)){let y=s(r*db),w=s(t*db);t=y,r=w,v=s(m*bK)}else v=p;du(t*d,o)&&(r=s(-r));let g=s((n-r)*v);return du(g,o)&&(g=s(-g)),Ac.toBytes(g)}equals(t){this.assertSame(t);let{X:r,Y:n}=this.ep,{X:i,Y:o}=t.ep,s=l=>Ac.create(l),a=s(r*o)===s(n*i),u=s(n*o)===s(r*i);return a||u}is0(){return this.equals(e.ZERO)}};Object.freeze(Sc.BASE);Object.freeze(Sc.ZERO);Object.freeze(Sc.prototype);Object.freeze(Sc);var _K=Object.freeze({Point:Sc,hashToCurve(e,t){let r=t?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":t.DST,n=ab(e,r,64,fm);return _K.deriveToCurve(n)},hashToScalar(e,t={DST:VF}){let r=ab(e,t.DST,64,fm);return sI.create(io(r))},deriveToCurve(e){On(e,64);let t=pb(e.subarray(0,32)),r=rI(t),n=pb(e.subarray(32,64)),i=rI(n);return new Sc(r.add(i))}});var iI=!1,DK=!1;async function oI(e,t){if(DK)return await t();try{return await e()}catch(r){if(r instanceof ReferenceError||r instanceof DOMException&&r.name==="NotSupportedError")return await t();throw r}}async function Ym(e,t){return await oI(async()=>{let r=vb(e)?e:await IK(e),n=await crypto.subtle.importKey("raw",t,{name:"X25519"},iI,[]);return new Uint8Array(await crypto.subtle.deriveBits({name:"X25519",public:n},r,256))},()=>{if(vb(e))throw new Error("CryptoKey provided but X25519 WebCrypto is not supported");return Gm.scalarMult(e,t)})}async function bp(e){return await oI(async()=>Ym(e,Gm.GuBytes),()=>{if(vb(e))throw new Error("CryptoKey provided but X25519 WebCrypto is not supported");return Gm.scalarMultBase(e)})}var FK=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,110,4,34,4,32]);async function IK(e){if(e.length!==32)throw new Error("X25519 private key must be 32 bytes");let t=new Uint8Array([...FK,...e]);return crypto.subtle.importKey("pkcs8",t,{name:"X25519"},iI,["deriveBits"])}function vb(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}var Mle=B(T(),1);var Nle=B(T(),1);var Wm=class{s;transcript=[];buf=new Uint8Array(0);constructor(t){this.s=t.getReader()}async readLine(){let t=[];for(;;){let r=this.buf.indexOf(10);if(r>=0)return t.push(this.buf.subarray(0,r)),this.transcript.push(this.buf.subarray(0,r+1)),this.buf=this.buf.subarray(r+1),$K(ql(t));this.buf.length>0&&(t.push(this.buf),this.transcript.push(this.buf));let n=await this.s.read();if(n.done)return this.buf=ql(t),null;this.buf=n.value}}close(){return this.s.releaseLock(),{rest:this.buf,transcript:ql(this.transcript)}}};function $K(e){return e.forEach(t=>{if(t<32||t>126)throw Error("invalid non-ASCII byte in header")}),new TextDecoder().decode(e)}function ql(e){let t=e.reduce((i,o)=>i+o.length,0),r=new Uint8Array(t),n=0;for(let i of e)r.set(i,n),n+=i.length;return r}function uh(e,...t){return e.pipeThrough(new TransformStream({start(r){for(let n of t)r.enqueue(n)}}))}function Xm(e){return new ReadableStream({start(t){t.enqueue(e),t.close()}})}async function wb(e){if(!(e instanceof ReadableStream))throw new Error("readAll expects a ReadableStream");return new Uint8Array(await new Response(e).arrayBuffer())}async function aI(e){if(!(e instanceof ReadableStream))throw new Error("readAllString expects a ReadableStream");return await new Response(e).text()}async function uI(e,t){let r=e.getReader(),n=[],i=0;for(;i")return{next:t};for(let o of r)if(o.length===0)throw Error("invalid stanza");let n=[];for(;;){let o=await e.readLine();if(o===null)throw Error("invalid stanza");let s=ns.decode(o);if(s.length>48)throw Error("invalid stanza");if(n.push(s),s.length<48)break}let i=ql(n);return{s:new ao(r,i)}}async function cI(e){let t=new Wm(e),r=await t.readLine();if(r!=="age-encryption.org/v1")throw Error("invalid version "+(r??"line"));let n=[];for(;;){let{s:i,next:o}=await TK(t);if(i!==void 0){n.push(i);continue}if(!o.startsWith("--- "))throw Error("invalid header");let s=ns.decode(o.slice(4)),{rest:a,transcript:u}=t.close(),l=u.slice(0,u.length-1-o.length+3);return{stanzas:n,headerNoMAC:l,MAC:s,headerSize:u.length,rest:uh(e,a)}}}function yb(e){let t=[];t.push(`age-encryption.org/v1 `);for(let r of e){t.push("-> "+r.args.join(" ")+` `);for(let n=0;nr.body.length&&(i=r.body.length),t.push(ns.encode(r.body.subarray(n,i))+` `)}r.body.length%48===0&&t.push(` `)}return t.push("---"),new TextEncoder().encode(t.join(""))}function lI(e,t){return ql([yb(e),new TextEncoder().encode(" "+ns.encode(t)+` `)])}function Ab(){let e=Xo(32),t=Vs.encodeFromBytes("AGE-SECRET-KEY-",e).toUpperCase();return Promise.resolve(t)}function Sb(){let e=Xo(32),t=Vs.encodeFromBytes("AGE-SECRET-KEY-PQ-",e).toUpperCase();return Promise.resolve(t)}async function ig(e){let t;if(hI(e))t=e;else if(e.startsWith("AGE-SECRET-KEY-PQ-1")){let n=Vs.decodeToBytes(e);if(n.prefix.toUpperCase()!=="AGE-SECRET-KEY-PQ-"||n.bytes.length!==32)throw Error("invalid identity");let i=km.getPublicKey(n.bytes);return Vs.encode("age1pq",Vs.toWords(i),!1)}else{let n=Vs.decodeToBytes(e);if(!e.startsWith("AGE-SECRET-KEY-1")||n.prefix.toUpperCase()!=="AGE-SECRET-KEY-"||n.bytes.length!==32)throw Error("invalid identity");t=n.bytes}let r=await bp(t);return Vs.encodeFromBytes("age",r)}var Zm=class{recipient;constructor(t){let r=Vs.decodeToBytes(t);if(!t.startsWith("age1pq1")||r.prefix.toLowerCase()!=="age1pq"||r.bytes.length!==1216)throw Error("invalid recipient");this.recipient=r.bytes}wrapFileKey(t){let{cipherText:r,sharedSecret:n}=km.encapsulate(this.recipient),i=new TextEncoder().encode("age-encryption.org/mlkem768x25519"),{key:o,nonce:s}=og(fI,n,i),a=Ti(o,s).encrypt(t);return[new ao(["mlkem768x25519",ns.encode(r)],a)]}},Qm=class{identity;constructor(t){let r=Vs.decodeToBytes(t);if(!t.startsWith("AGE-SECRET-KEY-PQ-1")||r.prefix.toUpperCase()!=="AGE-SECRET-KEY-PQ-"||r.bytes.length!==32)throw Error("invalid identity");this.identity=r.bytes}unwrapFileKey(t){for(let r of t){if(r.args.length<1||r.args[0]!=="mlkem768x25519")continue;if(r.args.length!==2)throw Error("invalid mlkem768x25519 stanza");let n=ns.decode(r.args[1]);if(n.length!==1120||r.body.length!==32)throw Error("invalid mlkem768x25519 stanza");let i=km.decapsulate(n,this.identity),o=new TextEncoder().encode("age-encryption.org/mlkem768x25519"),{key:s,nonce:a}=og(fI,i,o);try{return Ti(s,a).decrypt(r.body)}catch{continue}}return null}},fI=25722,PK=80,Eb=16;function og(e,t,r){let n=xK(e),i=Jm(n,void 0,"psk_id_hash",new Uint8Array(0)),o=Jm(n,void 0,"info_hash",r),s=new Uint8Array(1+i.length+o.length);s[0]=0,s.set(i,1),s.set(o,1+i.length);let a=Jm(n,t,"secret",new Uint8Array(0)),u=bb(n,a,"key",s,32),l=bb(n,a,"base_nonce",s,12);return{key:u,nonce:l}}function xK(e){let t=new Uint8Array(10);return t.set(new TextEncoder().encode("HPKE"),0),t[4]=e>>8&255,t[5]=e&255,t[6]=0,t[7]=1,t[8]=0,t[9]=3,t}function Jm(e,t,r,n){let i=new Uint8Array(7+e.length+r.length+n.length),o=0;return i.set(new TextEncoder().encode("HPKE-v1"),o),o+=7,i.set(e,o),o+=e.length,i.set(new TextEncoder().encode(r),o),o+=r.length,i.set(n,o),jd(Wr,i,t)}function bb(e,t,r,n,i){let o=new Uint8Array(9+e.length+r.length+n.length),s=0;return o[s]=i>>8&255,o[s+1]=i&255,s+=2,o.set(new TextEncoder().encode("HPKE-v1"),s),s+=7,o.set(e,s),s+=e.length,o.set(new TextEncoder().encode(r),s),s+=r.length,o.set(n,s),Yy(Wr,t,o,i)}function RK(e){e.length!==oh.lengths.publicKeyUncompressed&&(e=oh.Point.fromBytes(e).toBytes(!1));let t=oh.utils.randomSecretKey(),r=oh.getPublicKey(t,!1),n=oh.getSharedSecret(t,e,!0).subarray(1),i=new Uint8Array(r.length+e.length);i.set(r,0),i.set(e,r.length);let o=new Uint8Array(5);o.set(new TextEncoder().encode("KEM"),0),o[3]=Eb>>8,o[4]=Eb&255;let s=Jm(o,void 0,"eae_prk",n),a=bb(o,s,"shared_secret",i,32);return{encapsulatedKey:r,sharedSecret:a}}var eg=class{recipient;constructor(t){let r=Vs.decodeToBytes(t);if(!t.startsWith("age1tag1")||r.prefix.toLowerCase()!=="age1tag"||r.bytes.length!==33)throw Error("invalid recipient");this.recipient=r.bytes}wrapFileKey(t){let{encapsulatedKey:r,sharedSecret:n}=RK(this.recipient),i=new TextEncoder().encode("age-encryption.org/p256tag"),o=(()=>{let l=Wr(this.recipient).subarray(0,4),f=new Uint8Array(r.length+l.length);return f.set(r,0),f.set(l,r.length),jd(Wr,f,i).subarray(0,4)})(),{key:s,nonce:a}=og(Eb,n,i),u=Ti(s,a).encrypt(t);return[new ao(["p256tag",ns.encode(o),ns.encode(r)],u)]}},tg=class{recipient;constructor(t){let r=Vs.decodeToBytes(t);if(!t.startsWith("age1tagpq1")||r.prefix.toLowerCase()!=="age1tagpq"||r.bytes.length!==1249)throw Error("invalid recipient");this.recipient=r.bytes}wrapFileKey(t){let{cipherText:r,sharedSecret:n}=SF.encapsulate(this.recipient),i=new TextEncoder().encode("age-encryption.org/mlkem768p256tag"),o=(()=>{let l=Wr(this.recipient.subarray(1184)).subarray(0,4),f=new Uint8Array(r.length+l.length);return f.set(r,0),f.set(l,r.length),jd(Wr,f,i).subarray(0,4)})(),{key:s,nonce:a}=og(PK,n,i),u=Ti(s,a).encrypt(t);return[new ao(["mlkem768p256tag",ns.encode(o),ns.encode(r)],u)]}},rg=class{recipient;constructor(t){let r=Vs.decodeToBytes(t);if(!t.startsWith("age1")||r.prefix.toLowerCase()!=="age"||r.bytes.length!==32)throw Error("invalid recipient");this.recipient=r.bytes}async wrapFileKey(t){let r=Xo(32),n=await bp(r),i=await Ym(r,this.recipient),o=new Uint8Array(n.length+this.recipient.length);o.set(n),o.set(this.recipient,n.length);let s=new TextEncoder().encode("age-encryption.org/v1/X25519"),a=oc(Wr,i,o,s,32);return[new ao(["X25519",ns.encode(n)],Cb(t,a))]}},Ap=class{identity;recipient;constructor(t){if(hI(t)){this.identity=t,this.recipient=bp(t);return}let r=Vs.decodeToBytes(t);if(!t.startsWith("AGE-SECRET-KEY-1")||r.prefix.toUpperCase()!=="AGE-SECRET-KEY-"||r.bytes.length!==32)throw Error("invalid identity");this.identity=r.bytes,this.recipient=bp(r.bytes)}async unwrapFileKey(t){for(let r of t){if(r.args.length<1||r.args[0]!=="X25519")continue;if(r.args.length!==2)throw Error("invalid X25519 stanza");let n=ns.decode(r.args[1]);if(n.length!==32)throw Error("invalid X25519 stanza");let i=await Ym(this.identity,n),o=await this.recipient,s=new Uint8Array(n.length+o.length);s.set(n),s.set(o,n.length);let a=new TextEncoder().encode("age-encryption.org/v1/X25519"),u=oc(Wr,i,s,a,32),l=_b(r.body,u);if(l!==null)return l}return null}},ng=class{passphrase;logN;constructor(t,r){this.passphrase=t,this.logN=r}wrapFileKey(t){let r=Xo(16),n="age-encryption.org/v1/scrypt",i=new Uint8Array(n.length+16);i.set(new TextEncoder().encode(n)),i.set(r,n.length);let o=dE(this.passphrase,i,{N:2**this.logN,r:8,p:1,dkLen:32});return[new ao(["scrypt",ns.encode(r),this.logN.toString()],Cb(t,o))]}},sg=class{passphrase;constructor(t){this.passphrase=t}unwrapFileKey(t){for(let r of t){if(r.args.length<1||r.args[0]!=="scrypt")continue;if(t.length!==1)throw Error("scrypt recipient is not the only one in the header");if(r.args.length!==3||!/^[1-9][0-9]*$/.test(r.args[2]))throw Error("invalid scrypt stanza");let n=ns.decode(r.args[1]);if(n.length!==16)throw Error("invalid scrypt stanza");let i=Number(r.args[2]);if(i>20)throw Error("scrypt work factor is too high");let o="age-encryption.org/v1/scrypt",s=new Uint8Array(o.length+16);s.set(new TextEncoder().encode(o)),s.set(n,o.length);let a=dE(this.passphrase,s,{N:2**i,r:8,p:1,dkLen:32}),u=_b(r.body,a);if(u!==null)return u}return null}};function Cb(e,t){let r=new Uint8Array(12);return Ti(t,r).encrypt(e)}function _b(e,t){if(e.length!==32)throw Error("invalid stanza");let r=new Uint8Array(12);try{return Ti(t,r).decrypt(e)}catch{return null}}function hI(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}var nfe=B(T(),1);var jl=16,Fb=64*1024,Db=Fb+jl;function dI(e){let t=new Uint8Array(12),r=()=>{for(let s=t.length-2;s>=0&&(t[s]++,t[s]===0);s--);},n=!0,i=new Uint8Array(Db),o=0;return new TransformStream({transform(s,a){for(;s.length>0;){if(o===i.length){let l=Ti(e,t).decrypt(i);a.enqueue(l),r(),o=0,n=!1}let u=Math.min(i.length-o,s.length);i.set(s.subarray(0,u),o),o+=u,s=s.subarray(u)}},flush(s){t[11]=1;let a=Ti(e,t).decrypt(i.subarray(0,o));if(!n&&a.length===0)throw new Error("final chunk is empty");s.enqueue(a)}})}function pI(e){if(e0?jl:0,n}function mI(e){let t=new Uint8Array(12),r=()=>{for(let o=t.length-2;o>=0&&(t[o]++,t[o]===0);o--);},n=new Uint8Array(Fb),i=0;return new TransformStream({transform(o,s){for(;o.length>0;){if(i===n.length){let u=Ti(e,t).encrypt(n);s.enqueue(u),r(),i=0}let a=Math.min(n.length-i,o.length);n.set(o.subarray(0,a),i),i+=a,o=o.subarray(a)}},flush(o){t[11]=1;let s=Ti(e,t).encrypt(n.subarray(0,i));o.enqueue(s)}})}function gI(e){let t=Math.max(1,Math.ceil(e/Fb));return e+jl*t}var Sp={};xN(Sp,{decode:()=>OK,encode:()=>kK});var ofe=B(T(),1);function kK(e){let t=[];t.push(`-----BEGIN AGE ENCRYPTED FILE----- `);for(let r=0;re.length&&(n=e.length),t.push(lE.encode(e.subarray(r,n))+` `)}return t.push(`-----END AGE ENCRYPTED FILE----- `),t.join("")}function OK(e){let t=e.trim().replaceAll(`\r `,` `).split(` `);if(t.shift()!=="-----BEGIN AGE ENCRYPTED FILE-----")throw Error("invalid header");if(t.pop()!=="-----END AGE ENCRYPTED FILE-----")throw Error("invalid footer");function r(n,i){return n===t.length-1?i.length>0&&i.length<=64&&i.length%4===0:i.length===64}if(!t.every((n,i)=>r(i,n)))throw Error("invalid line length");if(!t.every(n=>/^[A-Za-z0-9+/=]+$/.test(n)))throw Error("invalid base64");return lE.decode(t.join(""))}var Efe=B(T(),1);var afe=B(T(),1);var Cp=class{passphrase=null;scryptWorkFactor=18;recipients=[];setPassphrase(t){if(this.passphrase!==null)throw new Error("can encrypt to at most one passphrase");if(this.recipients.length!==0)throw new Error("can't encrypt to both recipients and passphrases");this.passphrase=t}setScryptWorkFactor(t){this.scryptWorkFactor=t}addRecipient(t){if(this.passphrase!==null)throw new Error("can't encrypt to both recipients and passphrases");if(typeof t=="string")if(t.startsWith("age1pq1"))this.recipients.push(new Zm(t));else if(t.startsWith("age1tag1"))this.recipients.push(new eg(t));else if(t.startsWith("age1tagpq1"))this.recipients.push(new tg(t));else if(t.startsWith("age1"))this.recipients.push(new rg(t));else throw new Error("unrecognized recipient type");else this.recipients.push(t)}async encrypt(t){let r=Xo(16),n=[],i=this.recipients;this.passphrase!==null&&(i=[new ng(this.passphrase,this.scryptWorkFactor)]);for(let d of i)n.push(...await d.wrapFileKey(r));let o=new TextEncoder().encode("header"),s=oc(Wr,r,void 0,o,32),a=Jo(Wr,s,yb(n)),u=lI(n,a),l=Xo(16),f=new TextEncoder().encode("payload"),m=oc(Wr,r,l,f,32),p=mI(m);return t instanceof ReadableStream?Object.assign(uh(t.pipeThrough(p),u,l),{size:d=>gI(d)+u.length+l.length}):(typeof t=="string"&&(t=new TextEncoder().encode(t)),await wb(uh(Xm(t).pipeThrough(p),u,l)))}},ag=class{identities=[];addPassphrase(t){this.identities.push(new sg(t))}addIdentity(t){if(HK(t))this.identities.push(new Ap(t));else if(typeof t=="string")if(t.startsWith("AGE-SECRET-KEY-1"))this.identities.push(new Ap(t));else if(t.startsWith("AGE-SECRET-KEY-PQ-1"))this.identities.push(new Qm(t));else throw new Error("unrecognized identity type");else this.identities.push(t)}async decrypt(t,r){let n=t instanceof ReadableStream?t:Xm(t),{fileKey:i,headerSize:o,rest:s}=await this.decryptHeaderInternal(n),{data:a,rest:u}=await uI(s,16),l=new TextEncoder().encode("payload"),f=oc(Wr,i,a,l,32),m=dI(f),p=u.pipeThrough(m),d=Object.assign(p,{size:v=>pI(v-o-a.length)});return t instanceof ReadableStream?d:r==="text"?await aI(p):await wb(p)}async decryptHeader(t){return(await this.decryptHeaderInternal(Xm(t))).fileKey}async decryptHeaderInternal(t){let r=await cI(t),n=await this.unwrapFileKey(r.stanzas);if(n===null)throw Error("no identity matched any of the file's recipients");let i=new TextEncoder().encode("header"),o=oc(Wr,n,void 0,i,32),s=Jo(Wr,o,r.headerNoMAC);if(!UK(r.MAC,s))throw Error("invalid header HMAC");return{fileKey:n,headerSize:r.headerSize,rest:r.rest}}async unwrapFileKey(t){for(let r of this.identities){let n=await r.unwrapFileKey(t);if(n!==null)return n}return null}};function UK(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;ntypeof e?.[i]>"u"),r=e?.crypto;if(r&&typeof r.getRandomValues=="function"||t.push("crypto.getRandomValues"),t.length>0)throw new Error(`\u5F53\u524D\u8FD0\u884C\u73AF\u5883\u7F3A\u5C11 age \u52A0\u89E3\u5BC6\u6240\u9700 Web API: ${t.join(", ")}`);QK(e)}function ug(){return typeof DOMException<"u"?new DOMException("X25519 WebCrypto is not available","NotSupportedError"):new ReferenceError("X25519 WebCrypto is not available")}function WK(){let e={importKey(){throw ug()},deriveBits(){throw ug()}};return e[Ib]=!0,e}function XK(e){return typeof e=="string"?e:e?.name}function yI(e){return String(XK(e)||"").toUpperCase()==="X25519"}function JK(e){let t=String(e?.message||e||"");return/x25519|algorithm|not\s+supported|unsupported|unrecognized|unknown/i.test(t)}function EI(e){return e instanceof TypeError||e instanceof ReferenceError||e?.name==="TypeError"||e?.name==="ReferenceError"||e?.name==="NotSupportedError"||e?.name==="Error"&&JK(e)||typeof DOMException<"u"&&e instanceof DOMException&&e.name==="NotSupportedError"}function ZK(e){let t=Object.create(e);return Object.defineProperty(t,Ib,{configurable:!0,value:!0}),Object.defineProperty(t,"importKey",{configurable:!0,value:async(...r)=>{try{return await e.importKey.apply(e,r)}catch(n){throw yI(r[2])&&EI(n)?ug():n}}}),Object.defineProperty(t,"deriveBits",{configurable:!0,value:async(...r)=>{try{return await e.deriveBits.apply(e,r)}catch(n){throw yI(r[0])&&EI(n)?ug():n}}}),t}function bI(e,t,r){try{if(t.subtle=r,t.subtle===r)return!0}catch{}try{if(Object.defineProperty(t,"subtle",{configurable:!0,value:r}),t.subtle===r)return!0}catch{}try{let n=Object.create(t);return Object.defineProperty(n,"subtle",{configurable:!0,value:r}),typeof t.getRandomValues=="function"&&Object.defineProperty(n,"getRandomValues",{configurable:!0,value:t.getRandomValues.bind(t)}),e.crypto=n,e.crypto?.subtle===r}catch{return!1}}function QK(e=globalThis){let t=e?.crypto,r=t?.subtle;if(!(!t||r?.[Ib])){if(!r||typeof r.importKey!="function"||typeof r.deriveBits!="function"){bI(e,t,WK());return}typeof process>"u"&&bI(e,t,ZK(r))}}function Bb(e){let t=_p(e);if(!t||!VK(t)&&!zK(t))throw vI();try{new Cp().addRecipient(t)}catch{throw vI()}return t}async function $b(e){let t=_p(e);if(!t||!GK(t)&&!YK(t))throw wI();try{await ig(t)}catch{throw wI()}return t}async function SI(e=ch.X25519){cg();let t;if(e===ch.X25519)t=await Ab();else if(e===ch.HYBRID)t=await Sb();else throw new Error(`\u4E0D\u652F\u6301\u7684 age key \u7C7B\u578B: ${e}. \u652F\u6301: ${Object.values(ch).join(", ")}`);let r=await Kl(t);return{type:e,[ln]:t,[Oi]:r}}async function Kl(e){cg();let t=await $b(e),r=await ig(t);return Bb(r)}async function lh(e,t){cg();let r=Bb(t),n=new Cp;n.addRecipient(r);let i=await n.encrypt(e??"");return Sp.encode(i)}function Tb(e){return _p(e).startsWith(qK)}async function fh(e,t){let r=e??"",n=typeof r=="string"?r:new TextDecoder().decode(r);if(!Tb(n))return r;cg();let i=await $b(t),o=new ag;o.addIdentity(i);try{let s=Sp.decode(n);return await o.decrypt(s,"text")}catch(s){throw new Error(`age \u89E3\u5BC6\u5931\u8D25: ${s?.message??s}`)}}function eV(e){return String(e??"").replace(KK,t=>`${t.startsWith("AGE-SECRET-KEY-PQ-1")?"AGE-SECRET-KEY-PQ-1":"AGE-SECRET-KEY-1"}...${t.slice(-6)}`)}function Ni(e){return eV(String(e??"").replace(/([?#&]age-secret-key=)[^&#\s]+/gi,"$1***"))}var Ufe=B(T()),tV=new Set(["javascript","json","json5","yaml","ini","plaintext"]),rV=["editorLanguage","previewLanguage"];function CI(e){if(!(!e||typeof e!="object"))for(let t of rV)tV.has(e[t])||delete e[t]}function Li(e){CI(e),Array.isArray(e?.process)&&e.process.forEach(t=>{CI(t?.args)})}function Pb(e){H.read(pr)||H.write({},pr),e.route("/api/collection/:name").get(sV).patch(iV).delete(oV),e.route("/api/collections").get(aV).post(nV).put(uV)}function nV(e,t){try{let r=xb(e.body);Ze(t,r,201)}catch(r){Je(t,r)}}function sV(e,t){let{name:r}=e.params,{raw:n}=e.query,i=H.read(pr),o=$t(i,r);o?n?t.set("content-type","application/json").set("access-control-expose-headers","content-disposition").set("content-disposition",`attachment; filename="${encodeURIComponent(`sub-store_collection_${r}_${ic(new Date)}.json`)}"`).send(JSON.stringify(o)):Ze(t,o):Je(t,new Ot("SUBSCRIPTION_NOT_FOUND",`Collection ${r} does not exist`,404))}function iV(e,t){let{name:r}=e.params,n=e.body,i=H.read(pr),o=$t(i,r);if(o){n.name||(n.name=o.name);let s={...o,...n};if(_n(s),Li(s),H.info(`\u6B63\u5728\u66F4\u65B0\u7EC4\u5408\u8BA2\u9605\uFF1A${r}...`),r!==s.name){let a=H.read(Wt)||[];for(let l of a)l.type==="collection"&&l.source===o.name&&(l.source=s.name);let u=H.read(Mt)||[];for(let l of u)l.sourceType==="collection"&&l.sourceName===o.name&&(l.sourceName=s.name);H.write(a,Wt),H.write(u,Mt)}$i(i,r,s),H.write(i,pr),Ze(t,s)}else Je(t,new Ot("RESOURCE_NOT_FOUND",`Collection ${r} does not exist!`),404)}function oV(e,t){try{let{name:r}=e.params;H.info(`\u6B63\u5728\u5220\u9664\u7EC4\u5408\u8BA2\u9605\uFF1A${r}`),lV(e.query.mode)&&c8(r),cV(r),Ze(t)}catch(r){Je(t,r)}}function aV(e,t){let r=H.read(pr);Ze(t,r)}function uV(e,t){try{let r=e.body;r.forEach(n=>{_n(n),Li(n)}),H.write(r,pr),Ze(t)}catch(r){Je(t,r)}}function xb(e){if(_n(e),Li(e),H.info(`\u6B63\u5728\u521B\u5EFA\u7EC4\u5408\u8BA2\u9605\uFF1A${e.name}`),/\//.test(e.name))throw new Ke("INVALID_NAME",`Collection ${e.name} is invalid`);let t=H.read(pr);if($t(t,e.name))throw new Ke("DUPLICATE_KEY",`Collection ${e.name} already exists.`);return Ko(t,e,Vo()),H.write(t,pr),e}function cV(e){let t=H.read(pr),r=$t(t,e);if(!r)throw new Ot("RESOURCE_NOT_FOUND",`Collection ${e} does not exist!`);return jo(t,e),H.write(t,pr),r}function lV(e){if(e==null||e===""||e==="permanent")return!1;if(e==="archive")return!0;throw new Ke("INVALID_DELETE_MODE",`Unsupported delete mode: ${e}`)}var Bhe=B(T());var ghe=B(T());var Qfe=B(T()),Rb=0;function Xr(e){return hV(fV(dV(e)))}function fV(e){return mV(gV(pV(e),e.length*8))}function hV(e){try{}catch{Rb=0}for(var t=Rb?"0123456789ABCDEF":"0123456789abcdef",r="",n,i=0;i>>4&15)+t.charAt(n&15);return r}function dV(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 pV(e){for(var t=Array(e.length>>2),r=0;r>5]|=(e.charCodeAt(r/8)&255)<>5]>>>r%32&255);return t}function gV(e,t){e[t>>5]|=128<>>9<<4)+14]=t;for(var r=1732584193,n=-271733879,i=-1732584194,o=271733878,s=0;s>16)+(t>>16)+(r>>16);return n<<16|r&65535}function vV(e,t){return e<>>32-t}var nhe=B(T());var Ob=class{constructor(){H.read(gl)||H.write("{}",gl);try{this.resourceCache=JSON.parse(H.read(gl))}catch(t){H.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${gl} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${t?.message??t}`),this.resourceCache={},H.write("{}",gl)}this._cleanup()}_cleanup(t,r){let n=kb(r)??0,i=!1,o=Date.now();Object.entries(this.resourceCache).forEach(s=>{let[a,u]=s;(!u.time||u.time0?t:null}function yV(){let t=H.read(Bt)?.headersCacheTtl;return t&&(t=Number(t),isFinite(t)&&t>0)?t*1e3:6e4}var Vl=new Ob;var ahe=B(T());var _I=10,Fp="backendRequestConcurrency",DI=0,Ip="backendRequestConcurrencyWaitTime",Dp=0,Ub=[];function EV(e){return new Promise(t=>setTimeout(t,e))}function bV(e){if(typeof e>"u"||e===null||typeof e=="string"&&e.trim()==="")return _I;let t=Number(e);return!Number.isInteger(t)||t<1?_I:t}function AV(e){if(typeof e>"u"||e===null||typeof e=="string"&&e.trim()==="")return DI;let t=Number(e);return!Number.isInteger(t)||t<0?DI:t}function Nb(){let e=H.read(Bt)||{};return bV(e[Fp])}function Lb(){let e=H.read(Bt)||{};return AV(e[Ip])}function SV(e,t){return`active=${Dp}, pending=${Ub.length}, limit=${e}, waitTime=${t}ms`}function fg(e,t,r,n){H.log(`[Backend Request Concurrency] ${e}: ${t} (${SV(r,n)})`)}function CV(){let e=Ub.shift();e&&e()}async function _V(e){let t=Nb(),r=Lb();for(;Dp>=t;)fg("queued",e,t,r),await new Promise(n=>{Ub.push(n)}),t=Nb(),r=Lb();Dp+=1,fg("acquired",e,t,r),r>0&&(fg("waiting before request",e,t,r),await EV(r))}function DV(e){Dp=Math.max(0,Dp-1),fg("released",e,Nb(),Lb()),CV()}async function hh(e,t="request"){await _V(t);try{return await e()}finally{DV(t)}}function zl(e){let t=Object.keys(e),r="",n="",i="";for(let o of t){let s=o.toLowerCase();s==="subscription-userinfo"?r=e[o]:s==="profile-web-page-url"?n=e[o]:s==="plan-name"&&(i=e[o])}return`${r||""}${n?`; app_url=${encodeURIComponent(n)}`:""}${i?`; plan_name=${encodeURIComponent(i)}`:""}`}async function ia(rawUrl,ua,timeout,customProxy,flowUrl,flowHeaders){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||!/^https?/.test(url))return;let{isStash,isLoon,isShadowRocket,isQX}=An(),insecure=$arguments?.insecure?H.env.isNode?{strictSSL:!1}:{insecure:!0}:void 0,{defaultProxy,defaultFlowUserAgent,defaultTimeout}=H.read(Bt),proxy=customProxy||defaultProxy;H.env.isNode&&(proxy=proxy||eval("process.env.SUB_STORE_BACKEND_DEFAULT_PROXY"));let userAgent=ua||defaultFlowUserAgent||"clash.meta/v1.19.29",requestTimeout=timeout||defaultTimeout||8e3,customHeaders,customHeadersArg=flowHeaders||$arguments?.flowHeaders||$arguments?.headers;if(customHeadersArg)try{let e=typeof customHeadersArg=="string"?JSON.parse(customHeadersArg):customHeadersArg;if(e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length>0){let t={"user-agent":userAgent};for(let r in e)t[r.toLowerCase()]=e[r];customHeaders=t}}catch(e){H.error(`\u89E3\u6790\u81EA\u5B9A\u4E49 ${flowHeaders||$arguments?.flowHeaders?"flowHeaders":"headers"} \u5931\u8D25: ${e}`)}let id=Xr(`${customHeaders?JSON.stringify(customHeaders):userAgent}${url}`),cached=Vl.get(id),flowInfo;if(!$arguments?.noCache&&cached)H.info(`\u4F7F\u7528\u7F13\u5B58\u7684\u6D41\u91CF\u4FE1\u606F: ${url}, ${customHeaders?JSON.stringify(customHeaders):userAgent}`),flowInfo=cached;else{let e=Za();if(flowUrl){let t;try{H.info(`\u4F7F\u7528 GET \u65B9\u6CD5\u4ECE\u54CD\u5E94\u4F53\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F: ${flowUrl}, ${customHeaders?JSON.stringify(customHeaders):`User-Agent: ${userAgent||""}`}, Insecure: ${!!insecure}, Proxy: ${proxy}`);let{headers:r,body:n,statusCode:i}=await hh(()=>e.get({url,headers:customHeaders||{"User-Agent":userAgent},timeout:requestTimeout,...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?tu(proxy):{},...insecure||{}}),"flow body GET");if(i<200||i>=400)throw new Error(`statusCode: ${i}`);t=r;let o=mu(n);if(Number.isFinite(o?.total)&&Number.isFinite(o?.usage?.download)&&Number.isFinite(o?.usage?.upload))flowInfo=n;else throw new Error("\u54CD\u5E94\u4F53\u4E2D\u672A\u5305\u542B\u5408\u6CD5\u7684\u6D41\u91CF\u4FE1\u606F")}catch(r){if(H.error(`\u4F7F\u7528 GET \u65B9\u6CD5\u4ECE\u54CD\u5E94\u4F53\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u5931\u8D25: ${flowUrl}, ${customHeaders?JSON.stringify(customHeaders):`User-Agent: ${userAgent||""}`}, Insecure: ${!!insecure}, Proxy: ${proxy}: ${r.message??r}`),t)try{let n=zl(t),i=mu(n);if(Number.isFinite(i?.total)&&Number.isFinite(i?.usage?.download)&&Number.isFinite(i?.usage?.upload))H.info(`\u4F7F\u7528 GET \u65B9\u6CD5\u4ECE\u54CD\u5E94\u5934\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u6210\u529F: ${flowUrl}, ${customHeaders?JSON.stringify(customHeaders):`User-Agent: ${userAgent||""}`}, Insecure: ${!!insecure}, Proxy: ${proxy}`),flowInfo=n;else throw new Error("\u54CD\u5E94\u4F53\u4E2D\u672A\u5305\u542B\u5408\u6CD5\u7684\u6D41\u91CF\u4FE1\u606F")}catch(n){H.error(`\u4F7F\u7528 GET \u65B9\u6CD5\u4ECE\u54CD\u5E94\u5934\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u5931\u8D25: ${flowUrl}, ${customHeaders?JSON.stringify(customHeaders):`User-Agent: ${userAgent||""}`}, Insecure: ${!!insecure}, Proxy: ${proxy}: ${n.message??n}`)}}}else{try{H.info(`\u4F7F\u7528 HEAD \u65B9\u6CD5\u4ECE\u54CD\u5E94\u5934\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F: ${url}, ${customHeaders?JSON.stringify(customHeaders):`User-Agent: ${userAgent||""}`}, Insecure: ${!!insecure}, Proxy: ${proxy}`);let{headers:t}=await hh(()=>e.head({url:url.split(/[\r\n]+/).map(r=>r.trim()).filter(r=>r.length)[0],headers:{...customHeaders||{"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?tu(proxy):{},...insecure||{}}),"flow headers HEAD");flowInfo=zl(t)}catch(t){H.error(`\u4F7F\u7528 HEAD \u65B9\u6CD5\u4ECE\u54CD\u5E94\u5934\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u5931\u8D25: ${url}, ${customHeaders?JSON.stringify(customHeaders):`User-Agent: ${userAgent||""}`}, Insecure: ${!!insecure}, Proxy: ${proxy}: ${t.message??t}`)}if(!flowInfo){H.info(`\u4F7F\u7528 GET \u65B9\u6CD5\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F: ${url}, ${customHeaders?JSON.stringify(customHeaders):`User-Agent: ${userAgent||""}`}, Insecure: ${!!insecure}, Proxy: ${proxy}`);let{headers:t}=await hh(()=>e.get({url:url.split(/[\r\n]+/).map(r=>r.trim()).filter(r=>r.length)[0],headers:{...customHeaders||{"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?tu(proxy):{},...insecure||{}}),"flow headers GET");flowInfo=zl(t)}}flowInfo&&(flowInfo=flowInfo.trim()),flowInfo&&Vl.set(id,flowInfo,$arguments?.headersCacheTtl?$arguments?.headersCacheTtl*1e3:void 0)}return flowInfo}function mu(e){if(!e)return;let t=e.match(/upload=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),r=t==null?0:Number(t[1]+t[2]),n=e.match(/download=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),i=Number(n[1]+n[2]),o=e.match(/total=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),s=Number(o[1]+o[2]),a=e.match(/expire=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),u=a?Number(a[1]+a[2]):void 0,l=e.match(/reset_day=([0-9]+)/),f=l?Number(l[1]):void 0,m=e.match(/app_url=(.*?)\s*?(;|$)/),p=m?decodeURIComponent(m[1]):void 0,d=e.match(/plan_name=(.*?)\s*?(;|$)/),v=d?decodeURIComponent(d[1]):void 0;return{expires:u,total:s,usage:{upload:r,download:i},remainingDays:f,appUrl:p,planName:v}}function Bp(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:(Math.round(e*100)/100).toString(),unit:t}:Bp(e/1024,r[++n])}function hg(e){if(!e)throw new Error("\u6CA1\u6709\u6D41\u91CF\u4FE1\u606F");if(e?.expires&&e.expires*1e3o.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,o=i.getDate(),s=i.getMonth(),a=i.getFullYear(),u;return t>o?u=0:u=new Date(a,s+1,0).getDate(),u-o+t}}catch(t){H.error(`getRmainingDays failed: ${t.message??t}`)}}function pg(e,t){try{let r=new Map;e.split(";").map(o=>o.trim()).filter(Boolean).forEach(o=>{let s=o.indexOf("=");if(s===-1)return;let a=o.slice(0,s).trim(),u=o.slice(s+1).trim();if(!r.has(a))try{let l=decodeURIComponent(u);if(["upload","download","total","expire","reset_day"].includes(a))try{l=Number(l),["expire","reset_day"].includes(a)&&(l<=0||!Number.isFinite(l))?l="":["upload","download","total"].includes(a)&&!Number.isFinite(l)?l=0:l=l.toFixed(0)}catch(f){H.error(`Failed to convert value for key "${a}=${u}": ${f.message??f}`)}r.set(a,l)}catch{r.set(a,u)}});let n={},i={"subscription-userinfo":"","profile-web-page-url":"","plan-name":""};return r.forEach((o,s)=>{t&&s==="app_url"?i["profile-web-page-url"]=o:t&&s==="plan_name"?i["plan-name"]=o:n[s]=o}),Object.keys(n).length>0&&(i["subscription-userinfo"]=Object.entries(n).map(([o,s])=>`${o}=${encodeURIComponent(s)}`).join("; ")),t?i:i["subscription-userinfo"]}catch(r){return H.error(`normalizeFlowHeader failed: ${r.message??r}`),t?{"subscription-userinfo":e}:e}}H.read(Er)||H.write({},Er);function Hb(e){e.get("/api/sub/flow/:name",FV),e.route("/api/sub/:name").get(BV).patch($V).delete(TV),e.route("/api/subs").get(PV).post(IV).put(xV)}async function FV(e,t){let{name:r}=e.params,{url:n}=e.query;n&&H.info(`\u6307\u5B9A\u8FDC\u7A0B\u8BA2\u9605 URL: ${Ni(n)}`);let i=H.read(Er),o=$t(i,r);if(!o){Je(t,new Ot("RESOURCE_NOT_FOUND",`Subscription ${r} does not exist!`),404);return}if(o.source==="local"&&!["localFirst","remoteFirst"].includes(o.mergeSources)){if(o.subUserinfo){let s;if(/^https?:\/\//.test(o.subUserinfo))try{s=await ia(void 0,void 0,void 0,o.proxy,o.subUserinfo)}catch(a){H.error(`\u8BA2\u9605 ${r} \u4F7F\u7528\u81EA\u5B9A\u4E49\u6D41\u91CF\u94FE\u63A5 ${o.subUserinfo} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(a)}`)}else s=o.subUserinfo;try{Ze(t,{...mu(s)})}catch(a){H.error(`Failed to parse flow info for local subscription ${r}: ${a.message??a}`),Je(t,new Ke("NO_FLOW_INFO","N/A","Failed to parse flow info"))}}else Je(t,new Ke("NO_FLOW_INFO","N/A",`Local subscription ${r} has no flow information!`));return}try{n=`${n||o.url}`.split(/[\r\n]+/).map(l=>l.trim()).filter(l=>l.length)?.[0]||"";let s={},a=n.split("#");if(n=n.split("#")[0],a.length>1)try{s=JSON.parse(decodeURIComponent(a[1]))}catch{for(let f of a[1].split("&")){let m=f.split("=")[0],p=f.split("=")[1];s[m]=p==null||p===""?!0:decodeURIComponent(p)}}if(s.noFlow||!/^https?/.test(n)){Je(t,new Ke("NO_FLOW_INFO","N/A",`Subscription ${r}: noFlow`));return}let u=await ia(s?.insecure?`${n}#insecure`:n,s.flowUserAgent,void 0,o.proxy,s.flowUrl,s.flowHeaders);if(!u&&!o.subUserinfo){Je(t,new Pr("NO_FLOW_INFO","No flow info","Failed to fetch flow headers"));return}try{let l=dg({resetDay:s.resetDay,startDate:s.startDate,cycleDays:s.cycleDays}),f;if(/^https?:\/\//.test(o.subUserinfo))try{f=await ia(void 0,void 0,void 0,o.proxy,o.subUserinfo)}catch(p){H.error(`\u8BA2\u9605 ${r} \u4F7F\u7528\u81EA\u5B9A\u4E49\u6D41\u91CF\u94FE\u63A5 ${o.subUserinfo} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(p)}`)}else f=o.subUserinfo;let m={...mu([f,u].filter(p=>p).join("; "))};l!=null&&(m.remainingDays=l),Ze(t,m)}catch(l){H.error(`Failed to parse flow info for local subscription ${r}: ${l.message??l}`),Je(t,new Ke("NO_FLOW_INFO","N/A","Failed to parse flow info"))}}catch{Je(t,new Y1("URL_NOT_ACCESSIBLE",`The URL for subscription ${r} is inaccessible.`))}}function IV(e,t){try{let r=Mb(e.body);Ze(t,r,201)}catch(r){Je(t,r)}}function BV(e,t){let{name:r}=e.params,{raw:n}=e.query,i=H.read(Er),o=$t(i,r);delete o.subscriptions,o?n?t.set("content-type","application/json").set("access-control-expose-headers","content-disposition").set("content-disposition",`attachment; filename="${encodeURIComponent(`sub-store_subscription_${r}_${ic(new Date)}.json`)}"`).send(JSON.stringify(o)):Ze(t,o):Je(t,new Ot("SUBSCRIPTION_NOT_FOUND",`Subscription ${r} does not exist`,404))}function $V(e,t){let{name:r}=e.params,n=e.body;delete n.subscriptions;let i=H.read(Er),o=$t(i,r);if(o){n.name||(n.name=o.name);let s={...o,...n};if(_n(s),Li(s),H.info(`\u6B63\u5728\u66F4\u65B0\u8BA2\u9605\uFF1A ${r}`),r!==n.name){let a=H.read(pr)||[];for(let f of a){let m=f.subscriptions.indexOf(r);m!==-1&&(f.subscriptions[m]=n.name)}let u=H.read(Wt)||[];for(let f of u)f.type==="subscription"&&f.source==r&&(f.source=n.name);let l=H.read(Mt)||[];for(let f of l)f.sourceType==="subscription"&&f.sourceName==r&&(f.sourceName=n.name);H.write(a,pr),H.write(u,Wt),H.write(l,Mt)}$i(i,r,s),H.write(i,Er),Ze(t,s)}else Je(t,new Ot("RESOURCE_NOT_FOUND",`Subscription ${r} does not exist!`),404)}function TV(e,t){try{let{name:r}=e.params;H.info(`\u5220\u9664\u8BA2\u9605\uFF1A${r}...`),kV(e.query.mode)&&u8(r),RV(r),Ze(t)}catch(r){Je(t,r)}}function PV(e,t){let r=H.read(Er);Ze(t,r)}function xV(e,t){try{let r=e.body;r.forEach(n=>{_n(n),Li(n)}),H.write(r,Er),Ze(t)}catch(r){Je(t,r)}}function Mb(e){let t={...e};if(_n(t),Li(t),delete t.subscriptions,H.info(`\u6B63\u5728\u521B\u5EFA\u8BA2\u9605\uFF1A ${t.name}`),/\//.test(t.name))throw new Ke("INVALID_NAME",`Subscription ${t.name} is invalid`);let r=H.read(Er);if($t(r,t.name))throw new Ke("DUPLICATE_KEY",`Subscription ${t.name} already exists.`);return Ko(r,t,Vo()),H.write(r,Er),t}function RV(e){let t=H.read(Er),r=$t(t,e);if(!r)throw new Ot("RESOURCE_NOT_FOUND",`Subscription ${e} does not exist!`);jo(t,e),H.write(t,Er);let n=H.read(pr)||[];for(let i of n)i.subscriptions=i.subscriptions.filter(o=>o!==e);return H.write(n,pr),r}function kV(e){if(e==null||e===""||e==="permanent")return!1;if(e==="archive")return!0;throw new Ke("INVALID_DELETE_MODE",`Unsupported delete mode: ${e}`)}var ede=B(T());var Ohe=B(T());var qb="https://api.github.com";function FI(e){let t;try{t=JSON.parse(e.body)}catch{}let r=t?.message?.error??t?.error??t?.message??e.body??"Unknown error";return`ERROR: HTTP ${e.statusCode}: ${r}`}function OV(e,t=qb){return(String(e??"").trim()||t).replace(/\/+$/,"")}function II({githubApiUrl:e,githubProxy:t}={}){let r=OV(e),n=r!==qb,i=String(t||"").trim().replace(/\/+$/,"");return n?r:`${i?`${i}/`:""}${qb}`}function Rhe(e={}){return!!e?.gistToken}var Ui=class{constructor({token,key,syncPlatform}){let{isStash,isLoon,isShadowRocket,isQX}=An(),{defaultProxy,githubApiTimeout,githubProxy,githubApiUrl}=H.read(Bt),githubApiRequestTimeout=githubApiTimeout||1e4,githubGistBaseURL=II({githubApiUrl,githubProxy}),proxy=defaultProxy;H.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=Za({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?tu(proxy):{},timeout:githubApiRequestTimeout,events:{onResponse:e=>/^[45]/.test(String(e.statusCode))?Promise.reject(FI(e)):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=Za({baseURL:githubGistBaseURL,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?tu(proxy):{},timeout:githubApiRequestTimeout,events:{onResponse:e=>/^[45]/.test(String(e.statusCode))?Promise.reject(FI(e)):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);H.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,t={}){if(Object.keys(e).length===0)return Promise.reject("\u672A\u63D0\u4F9B\u9700\u4E0A\u4F20\u7684\u6587\u4EF6");let r=await this.locate(),n=e,i=t.emptyFileFallback,o=!!i?.filename,s={},a=l=>l.then(f=>(Object.keys(s).length>0&&(f.subStoreUploadMeta=s),f)),u=({actions:l,existingFiles:f,result:m})=>{if(!o)return;let p=i.filename,d=i.content??"",v=Object.keys(m).filter(g=>g!==p);Object.keys(m).length===0?(m[p]={content:d},s.emptyFileFallback={status:"created",filename:p},this.syncPlatform==="gitlab"?l.push({action:f[p]?"update":"create",file_path:p,content:d}):n[p]={content:d}):m[p]&&v.length>0?(delete m[p],s.emptyFileFallback={status:"removed",filename:p},this.syncPlatform==="gitlab"?l.push({action:"delete",file_path:p}):n[p]=null):m[p]&&v.length===0&&(s.emptyFileFallback={status:"retained",filename:p})};if(r?.id){this.syncPlatform==="gitlab"&&(r.files=r.files.reduce((m,p)=>(m[p.path]=p,m),{}));let l=[],f={...r.files};return Object.keys(n).map(m=>{f[m]?n[m].content==null||n[m].content===""?(delete f[m],n[m]=null,l.push({action:"delete",file_path:m})):(f[m]=n[m],l.push({action:"update",file_path:m,content:n[m].content})):n[m].content==null||n[m].content===""?(delete f[m],delete n[m]):(f[m]=n[m],l.push({action:"create",file_path:m,content:n[m].content}))}),u({actions:l,existingFiles:r.files,result:f}),this.syncPlatform==="gitlab"?Object.keys(f).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(f).length>10?Promise.reject("\u672C\u6B21\u64CD\u4F5C\u5C06\u5BFC\u81F4 snippet \u7684\u6587\u4EF6\u6570\u8D85\u8FC7 10, \u65E0\u6CD5\u66F4\u65B0 snippet"):(n=l,a(this.http.put({headers:{...this.headers,"Content-Type":"application/json"},url:`/snippets/${r.id}`,body:JSON.stringify({files:n})}))):Object.keys(f).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"):a(this.http.patch({url:`/gists/${r.id}`,body:JSON.stringify({files:n})}))}else return n=Object.entries(n).reduce((l,[f,m])=>(m.content!==null&&m.content!==""&&(l[f]=m),l),{}),this.syncPlatform==="gitlab"?Object.keys(n).length===0?Promise.reject("\u6240\u6709\u6587\u4EF6\u7684\u5185\u5BB9\u90FD\u4E3A\u7A7A, \u65E0\u6CD5\u521B\u5EFA snippet"):(n=Object.keys(n).map(l=>({file_path:l,content:n[l].content})),a(this.http.post({headers:{...this.headers,"Content-Type":"application/json"},url:"/snippets",body:JSON.stringify({title:this.key,visibility:"private",files:n})}))):Object.keys(n).length===0?Promise.reject("\u6240\u6709\u6587\u4EF6\u7684\u5185\u5BB9\u90FD\u4E3A\u7A7A, \u65E0\u6CD5\u521B\u5EFA gist"):a(this.http.post({url:"/gists",body:JSON.stringify({description:this.key,public:!1,files:n})}))}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})`)}};var qhe=B(T());var Kb=new Map,jb=new Set,Vb;function zb(e){return e?.cron==null?"":`${e.cron}`.trim()}function BI(e){return zb(e).length>0}function NV(e){let t=e?.displayName??e?.["display-name"];return t==null?"":`${t}`.trim()}function $I(e){if(!e||typeof e!="object")return`${e}`;let t=e.name==null?"":`${e.name}`,r=NV(e);return!r||r===t?t:`${t} (${r})`}function LV(e){return!BI(e)}function UV(cron){if(!(!cron||!H.env.isNode))try{let{CronTime}=eval('require("cron")');new CronTime(cron)}catch(e){throw new Ke("INVALID_ARTIFACT_CRON",`Artifact cron ${cron} is invalid.`,`Reason: ${e.message??e}`)}}function mg(e){if(!e||typeof e!="object")return e;let t=zb(e);return t?(UV(t),e.cron=t,e):(delete e.cron,e)}function HV(){Kb.forEach(e=>e.stop()),Kb.clear()}async function MV(e,t,r){if(jb.has(e)){H.info(`[ARTIFACT CRON] ${t} ${r} skipped: previous run is still running`);return}jb.add(e);try{H.info(`[ARTIFACT CRON] ${t} ${r} started`),await Vb(e),H.info(`[ARTIFACT CRON] ${t} ${r} finished`)}catch(n){H.error(`[ARTIFACT CRON] ${t} ${r} error: ${n.message??n}`)}finally{jb.delete(e)}}function qV(artifact){let cron=zb(artifact),name=artifact.name,logName=$I(artifact),{CronJob}=eval('require("cron")');try{let e=new CronJob(cron,async function(){await MV(name,logName,cron)},null,!0);Kb.set(name,e),H.info(`[ARTIFACT CRON] ${logName} ${cron} scheduled`)}catch(e){H.error(`[ARTIFACT CRON] ${logName} ${cron} schedule error: ${e.message??e}`)}}function Gl(){if(!H.env.isNode||!Vb)return;HV();let e=H.read(Wt);(Array.isArray(e)?e:[]).filter(r=>r.sync&&r.source).filter(BI).forEach(qV)}function Hhe(e){H.env.isNode&&(Vb=e,Gl())}var TI=".sub-store-placeholder",jV=["Sub-Store placeholder","This file keeps the Gist alive when all sync configuration files are deleted."].join(` `);function Gb(e){H.read(Wt)||H.write({},Wt),e.get("/api/artifacts/restore",KV),e.route("/api/artifacts").get(VV).post(YV).put(zV),e.route("/api/artifact/:name").get(GV).patch(WV).delete(XV)}async function KV(e,t){H.info("\u5F00\u59CB\u6062\u590D\u8FDC\u7A0B\u914D\u7F6E...");try{let{gistToken:r,syncPlatform:n}=H.read(Bt);if(!r)return Promise.reject("\u672A\u8BBE\u7F6E GitHub Token\uFF01");let i=new Ui({token:r,key:pl,syncPlatform:n});try{let o=await i.locate();if(!o?.files)throw new Error("\u627E\u4E0D\u5230 Sub-Store Gist \u6587\u4EF6\u5217\u8868");let s=H.read(Wt),a=[];Object.keys(o.files).map(u=>{let l=o.files[u]?.filename;if(l){if(xI(l)){H.info(`\u5FFD\u7565 Gist \u5360\u4F4D\u6587\u4EF6: ${l}`);return}if(encodeURIComponent(l)!==l)H.error(`\u6587\u4EF6\u540D ${l} \u672A\u7F16\u7801 \u4E0D\u4FDD\u5B58`),a.push(l);else{let f=$t(s,l);f?$i(s,l,{...f,url:o.files[u]?.raw_url.replace(/\/raw\/[^/]*\/(.*)/,"/raw/$1")}):s.push({name:`${l}`,url:o.files[u]?.raw_url.replace(/\/raw\/[^/]*\/(.*)/,"/raw/$1")})}}}),H.write(s,Wt),Gl()}catch(o){throw H.error(`\u67E5\u627E Sub-Store Gist \u65F6\u53D1\u751F\u9519\u8BEF: ${o.message??o}`),o}Ze(t)}catch(r){H.error(`\u6062\u590D\u8FDC\u7A0B\u914D\u7F6E\u5931\u8D25\uFF0C\u539F\u56E0\uFF1A${r.message??r}`),Je(t,new Pr("FAILED_TO_RESTORE_ARTIFACTS","Failed to restore artifacts",`Reason: ${r.message??r}`))}}function VV(e,t){let r=H.read(Wt);Ze(t,r)}function zV(e,t){try{let r=e.body;r.forEach(_n),r.forEach(mg),H.write(r,Wt),Gl(),Ze(t)}catch(r){Je(t,r)}}async function GV(e,t){let{name:r}=e.params,n=H.read(Wt),i=$t(n,r);i?Ze(t,i):Je(t,new Ot("RESOURCE_NOT_FOUND",`Artifact ${r} does not exist!`),404)}function YV(e,t){try{let r=Yb(e.body);Ze(t,r,201)}catch(r){Je(t,r)}}function WV(e,t){let r=e.body,n=H.read(Wt),i=e.params.name,o=$t(n,i);if(o){r.name||(r.name=o.name),H.info(`\u6B63\u5728\u66F4\u65B0\u8FDC\u7A0B\u914D\u7F6E\uFF1A${o.name}`);let s={...o,...r};if(_n(s),!PI(s.name)){Je(t,new Ke("INVALID_ARTIFACT_NAME",`Artifact name ${s.name} is invalid.`));return}try{mg(s)}catch(a){Je(t,a);return}$i(n,i,s),H.write(n,Wt),Gl(),Ze(t,s)}else Je(t,new Ke("DUPLICATE_KEY",`Artifact ${i} already exists.`))}async function XV(e,t){try{let{name:r}=e.params;H.info(`\u6B63\u5728\u5220\u9664\u8FDC\u7A0B\u914D\u7F6E\uFF1A${r}`),ZV(e.query.mode)&&f8(r);let n=await JV(r);Ze(t,n)}catch(r){H.error(`\u65E0\u6CD5\u5220\u9664\u8FDC\u7A0B\u914D\u7F6E\uFF1A${e.params.name}\uFF0C\u539F\u56E0\uFF1A${r}`),Je(t,r instanceof Pr||r instanceof Ke||r instanceof Ot?r:new Pr("FAILED_TO_DELETE_ARTIFACT",`Failed to delete artifact ${e.params.name}`,`Reason: ${r}`))}}function PI(e){return/^[a-zA-Z0-9._-]*$/.test(e)&&!xI(e)}function Yb(e){if(_n(e),!PI(e.name))throw new Ke("INVALID_ARTIFACT_NAME",`Artifact name ${e.name} is invalid.`);H.info(`\u6B63\u5728\u521B\u5EFA\u8FDC\u7A0B\u914D\u7F6E\uFF1A${e.name}`),mg(e);let t=H.read(Wt);if($t(t,e.name))throw new Ke("DUPLICATE_KEY",`Artifact ${e.name} already exists.`);return Ko(t,e,Vo()),H.write(t,Wt),Gl(),e}async function JV(e){let t=H.read(Wt),r=$t(t,e);if(!r)throw new Ot("RESOURCE_NOT_FOUND",`Artifact ${e} does not exist!`);let n={attempted:!1,status:"not_attempted"};if(r.url||r.updated&&r.upload!==!1){let i={};i[encodeURIComponent(r.name)]={content:""},encodeURIComponent(r.name)!==r.name&&(i[r.name]={content:""}),n.attempted=!0;try{let s=(await RI(i)).subStoreUploadMeta?.emptyFileFallback;n.status=s?.status==="created"||s?.status==="retained"?"placeholder_retained":"deleted",s?.filename&&(n.placeholderFilename=s.filename)}catch(o){n.status="failed",n.message=`${o.message??o}`,H.error(`Function syncToGist: ${e} : ${o}`)}}return jo(t,e),H.write(t,Wt),Gl(),{artifact:r,remote:n}}function ZV(e){if(e==null||e===""||e==="permanent")return!1;if(e==="archive")return!0;throw new Ke("INVALID_DELETE_MODE",`Unsupported delete mode: ${e}`)}function xI(e){return e===TI}function QV(){return{filename:TI,content:jV}}async function RI(e,t={}){let{gistToken:r,syncPlatform:n}=H.read(Bt);if(!r)return Promise.reject("\u672A\u8BBE\u7F6E GitHub Token\uFF01");let i=ez(e);H.info(`\u51C6\u5907\u540C\u6B65 Gist: \u6587\u4EF6\u6570 ${i.count}, \u603B\u5927\u5C0F ${gg(i.totalBytes)}, \u6700\u5927\u6587\u4EF6 ${i.largestFilename||"-"} (${gg(i.largestBytes)})`);let o=new Ui({token:r,key:pl,syncPlatform:n}),s;try{s=await o.upload(e,{...t,emptyFileFallback:t.emptyFileFallback??QV()})}catch(f){throw H.error(`\u540C\u6B65 Gist \u8BF7\u6C42\u5931\u8D25: \u6587\u4EF6\u6570 ${i.count}, \u603B\u5927\u5C0F ${gg(i.totalBytes)}, \u6700\u5927\u6587\u4EF6 ${i.largestFilename||"-"} (${gg(i.largestBytes)}), \u539F\u56E0: ${f.message??f}`),f}let a={};try{a=JSON.parse(s.body)}catch{}let u=a?.html_url??a?.web_url,l=H.read(Bt);return u?(H.log(`\u540C\u6B65 Gist \u540E, \u627E\u5230 Sub-Store Gist: ${u}`),l.artifactStore=u,l.artifactStoreStatus="VALID"):(H.error("\u540C\u6B65 Gist \u540E, \u627E\u4E0D\u5230 Sub-Store Gist"),l.artifactStoreStatus="NOT FOUND"),H.write(l,Bt),s}function ez(e){return Object.entries(e||{}).reduce((t,[r,n])=>{let i=n?.content;if(typeof i!="string")return t;let o=tz(i);return t.count++,t.totalBytes+=o,o>t.largestBytes&&(t.largestBytes=o,t.largestFilename=r),t},{count:0,totalBytes:0,largestBytes:0,largestFilename:""})}function tz(e){return typeof TextEncoder<"u"?new TextEncoder().encode(e).length:unescape(encodeURIComponent(e)).length}function gg(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}var lde=B(T());var rz=["gistToken","githubProxy","githubApiUrl","defaultProxy"];function kI(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function nz(e,t){return Object.prototype.hasOwnProperty.call(e||{},t)}function sz(e,t={}){return t.gistUpload==="age"||e?.gistUpload==="age"&&nz(t,ln)}async function iz(e){if(await AI(e),!e[ln])throw new Ke("INVALID_GIST_AGE_KEYS","age \u52A0\u5BC6\u6A21\u5F0F\u9700\u8981\u914D\u7F6E age-secret-key")}function oz(e={}){return rz.some(t=>Object.prototype.hasOwnProperty.call(e,t))}function Wb(e){H.read(Bt)||H.write({},Bt),e.route("/api/settings").get(az).patch(uz)}async function az(e,t){try{let r=H.read(Bt);r||(r={},H.write(r,Bt)),r.artifactStore||await vg(),Ze(t,r)}catch(r){H.error(`Failed to get settings: ${r.message??r}`),Je(t,new Pr("FAILED_TO_GET_SETTINGS","Failed to get settings",`Reason: ${r.message??r}`))}}async function uz(e,t){try{let r=H.read(Bt),n={...r,...e.body};if(kI(e.body?.appearanceSetting)&&(n.appearanceSetting={...kI(r?.appearanceSetting)?r.appearanceSetting:{},...e.body.appearanceSetting}),["defaultTimeout","githubApiTimeout","artifactSyncBatchSize","cacheThreshold","resourceCacheTtl","headersCacheTtl","scriptCacheTtl"].map(i=>{let o=Number(n[i]);(!isFinite(o)||o<=0)&&delete n[i]}),"logsMaxCount"in n){let i=n.logsMaxCount,o=Number(i);(i==null||i===""||!isFinite(o)||o<0)&&delete n.logsMaxCount}if(Fp in n){let i=n[Fp],o=Number(i);(i==null||i===""||!Number.isInteger(o)||o<1)&&delete n[Fp]}if(Ip in n){let i=n[Ip],o=Number(i);(i==null||i===""||!Number.isInteger(o)||o<0)&&delete n[Ip]}sz(n,e.body)&&await iz(n),H.write(n,Bt),C_(),oz(e.body)&&await vg(),Ze(t,n)}catch(r){H.error(`Failed to update settings: ${r.message??r}`),Je(t,r instanceof Ke?r:new Pr("FAILED_TO_UPDATE_SETTINGS","Failed to update settings",`Reason: ${r.message??r}`))}}async function vg(){H.log("Updating artifact store");let e=H.read(Bt),{gistToken:t,syncPlatform:r}=e;if(t){let n=new Ui({token:t,key:pl,syncPlatform:r});try{let i=await n.locate(),o=i?.html_url??i?.web_url;o?(H.log(`\u627E\u5230 Sub-Store Gist: ${o}`),e.artifactStore=o,e.artifactStoreStatus="VALID"):(H.error(`\u627E\u4E0D\u5230 Sub-Store Gist (${pl})`),e.artifactStoreStatus="NOT FOUND")}catch(i){H.error(`\u67E5\u627E Sub-Store Gist (${pl}) \u65F6\u53D1\u751F\u9519\u8BEF: ${i.message??i}`),e.artifactStoreStatus="ERROR"}H.write(e,Bt)}}var Hde=B(T());var tA=B(Tp());var mde=B(T());var Jb=class{constructor(){H.read(ml)||H.write("{}",ml);try{this.resourceCache=JSON.parse(H.read(ml))}catch(t){H.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${ml} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${t?.message??t}`),this.resourceCache={},H.write("{}",ml)}this._cleanup()}_cleanup(t,r){let n=Xb(r)??0,i=!1,o=Date.now();Object.entries(this.resourceCache).forEach(s=>{let[a,u]=s;(!u.time||u.time0?t:null}function lz(){let t=H.read(Bt)?.resourceCacheTtl;return t&&(t=Number(t),isFinite(t)&&t>0)?t*1e3:36e5}var Jr=new Jb;var yde=B(T());var Qb=class{constructor(){H.read(vl)||H.write("{}",vl);try{this.resourceCache=JSON.parse(H.read(vl))}catch(t){H.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${vl} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${t?.message??t}`),this.resourceCache={},H.write("{}",vl)}this._cleanup()}_cleanup(t,r){let n=Zb(r)??0,i=!1,o=Date.now();Object.entries(this.resourceCache).forEach(s=>{let[a,u]=s;(!u.time||u.time0?t:null}function hz(){let t=H.read(Bt)?.scriptCacheTtl;return t&&(t=Number(t),isFinite(t)&&t>0)?t*1e3:1728e5}var Pp=new Qb;var Sde=B(T());var{isNode:OI,isQX:dz,isLoon:pz,isSurge:mz,isStash:gz,isShadowRocket:vz,isLanceX:wz,isEgern:yz,isGUIforCores:Ez}=An(),oa="Node";OI?oa="Node":dz?oa="QX":pz?oa="Loon":gz?oa="Stash":vz?oa="Shadowrocket":yz?oa="Egern":mz?oa="Surge":wz?oa="LanceX":Ez&&(oa="GUI.for.Cores");var Yl={},bz={};try{if(typeof $environment<"u"&&(Yl.env=$environment),typeof $loon<"u"&&(Yl.loon=$loon),typeof $script<"u"&&(Yl.script=$script),typeof $Plugin<"u"&&(Yl.plugin=$Plugin),OI){Yl.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)&&(Yl.node.env[e]=env[e])}}catch(e){}var aa={backend:oa,version:L1,feature:bz,meta:Yl};function rA(e){e.get("/api/utils/env",NI),e.get("/api/utils/backup",Dz),e.get("/api/utils/refresh",Az),e.route("/api/storage").get((t,r)=>{r.set("content-type","application/json").set("access-control-expose-headers","content-disposition").set("content-disposition",`attachment; filename="${encodeURIComponent(`sub-store_data_${ic(new Date)}.json`)}"`).send(H.env.isNode?JSON.stringify(H.cache):H.read("#sub-store"))}).post((t,r)=>{try{let{content:n}=t.body;try{if(n=JSON.parse(_t.decode(n)),!(Object.keys(n.settings).length>=0))throw new Error("\u5907\u4EFD\u6587\u4EF6\u5E94\u8BE5\u81F3\u5C11\u5305\u542B settings \u5B57\u6BB5")}catch{try{if(n=JSON.parse(n),!(Object.keys(n.settings).length>=0))throw new Error("\u5907\u4EFD\u6587\u4EF6\u5E94\u8BE5\u81F3\u5C11\u5305\u542B settings \u5B57\u6BB5")}catch(o){throw H.error(`\u5907\u4EFD\u6587\u4EF6\u6821\u9A8C\u5931\u8D25, \u65E0\u6CD5\u8FD8\u539F Reason: ${o.message??o}`),new Error("\u5907\u4EFD\u6587\u4EF6\u6821\u9A8C\u5931\u8D25, \u65E0\u6CD5\u8FD8\u539F")}}H.write(JSON.stringify(n,null," "),"#sub-store"),H.env.isNode&&(H.cache=n,H.persistCache()),Rf(),Ze(r)}catch(n){H.error(`Failed to restore backup data. Reason: ${n.message??n}`),Je(r,new Ke("INVALID_BACKUP_DATA","Invalid backup data, failed to restore!",`Reason: ${n.message??n}`))}}),An().isNode?e.get("/",NI):e.get("/",async(t,r)=>{r.set("location","https://sub-store.vercel.app/").status(302).end()}),An().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 NI(e,t){aa.feature=aa.feature||{},aa.feature.archive=!0,e.query.share&&(aa.feature.share=!0),t.set("Content-Type","application/json;charset=UTF-8").send(JSON.stringify({status:"success",data:{guide:"\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F \u60A8\u5F53\u524D\u770B\u5230\u7684\u662F\u540E\u7AEF\u7684\u54CD\u5E94. \u82E5\u60F3\u914D\u5408\u524D\u7AEF\u4F7F\u7528, \u53EF\u8BBF\u95EE\u5B98\u65B9\u524D\u7AEF https://sub-store.vercel.app \u540E\u81EA\u884C\u914D\u7F6E\u540E\u7AEF\u5730\u5740, \u6216\u4E00\u952E\u914D\u7F6E\u540E\u7AEF https://sub-store.vercel.app?api=https://a.com/xxx (\u5047\u8BBE https://a.com \u662F\u4F60\u540E\u7AEF\u7684\u57DF\u540D, /xxx \u662F\u81EA\u5B9A\u4E49\u8DEF\u5F84). \u9700\u6CE8\u610F HTTPS \u524D\u7AEF\u65E0\u6CD5\u8BF7\u6C42\u975E\u672C\u5730\u7684 HTTP \u540E\u7AEF(\u90E8\u5206\u6D4F\u89C8\u5668\u4E0A\u4E5F\u65E0\u6CD5\u8BBF\u95EE\u672C\u5730 HTTP \u540E\u7AEF). \u8BF7\u914D\u7F6E\u53CD\u4EE3\u6216\u5728\u5C40\u57DF\u7F51\u81EA\u5EFA HTTP \u524D\u7AEF. \u5982\u679C\u8FD8\u6709\u95EE\u9898, \u53EF\u67E5\u770B\u6B64\u6392\u67E5\u8BF4\u660E: https://telegram.me/zhetengsha/1068",...aa}},null,2))}async function Az(e,t){await vg(),Jr.revokeAll(),Pp.revokeAll(),Vl.revokeAll(),Ze(t)}function eA(){let e=H.read("#sub-store");return e=e?JSON.parse(e):{},H.env.isNode&&(e=JSON.parse(JSON.stringify(H.cache))),e}function LI(e,t,r={}){let n=JSON.parse(JSON.stringify(e||{}));return!r.keepAgeSecretKey&&n.settings?.[ln]&&delete n.settings[ln],t==="plaintext"?(n.settings=n.settings||{},n.settings.gistToken="\u6062\u590D\u540E\u8BF7\u91CD\u65B0\u8BBE\u7F6E GitHub Token",JSON.stringify(n,null," ")):_t.encode(JSON.stringify(n,null," "))}function Sz(e){return["base64","plaintext","age"].includes(e)?e:"base64"}function UI(e){return e==="plaintext"?"plaintext":"base64"}function xp(e){return e==="age"}async function Cz(e,t,r){if(!xp(r))return e;let n=t?.[ln];if(!n)throw new Error("age \u52A0\u5BC6\u6A21\u5F0F\u9700\u8981\u914D\u7F6E age \u89E3\u5BC6\u79C1\u94A5");return H.info("\u4F7F\u7528 age \u52A0\u5BC6 Gist \u5907\u4EFD\u5185\u5BB9"),lh(e,await Kl(n))}async function HI(e,t,r){if(!xp(r))return e;let n=t?.[ln];if(!n)throw new Error("age \u52A0\u5BC6\u6A21\u5F0F\u9700\u8981\u914D\u7F6E age \u89E3\u5BC6\u79C1\u94A5");return H.info("\u5C1D\u8BD5\u4F7F\u7528 age \u89E3\u5BC6 Gist \u5907\u4EFD\u5185\u5BB9"),fh(e,n)}async function _z(e,t,r){let{gistToken:n,syncPlatform:i}=H.read(Bt);if(!n)throw new Error("GitHub Token is required for backup!");let o=new Ui({token:n,key:a_,syncPlatform:i}),s=eA(),a,u=H.read(Bt),l=u.syncTime,f=Sz(r||u.gistUpload||"base64");switch(H.info(`Gist backup action: ${e}, keep: ${t}, encode: ${r}, settings encode: ${u.gistUpload}, final encoding: ${f}`),e){case"upload":try{let m=xp(f);a=LI(eA(),UI(f),{keepAgeSecretKey:m}),H.info("\u4E0B\u8F7D\u5907\u4EFD, \u4E0E\u672C\u5730\u5185\u5BB9\u5BF9\u6BD4...");let p=await o.download(H1),d=await HI(p,u,f);if((!xp(f)||Tb(p))&&d===a){H.info("\u5185\u5BB9\u4E00\u81F4, \u65E0\u9700\u4E0A\u4F20\u5907\u4EFD");return}}catch(m){H.error(`${m.message??m}`)}u.syncTime=new Date().getTime(),H.write(u,Bt),a=LI(eA(),UI(f),{keepAgeSecretKey:xp(f)}),a=await Cz(a,u,f),H.info("\u4E0A\u4F20\u5907\u4EFD\u4E2D...");try{await o.upload({[H1]:{content:a}}),H.info("\u4E0A\u4F20\u5907\u4EFD\u5B8C\u6210")}catch(m){throw u.syncTime=l,H.write(u,Bt),m}break;case"download":H.info("\u8FD8\u539F\u5907\u4EFD\u4E2D..."),a=await o.download(H1),a=await HI(a,u,f);try{if(a=JSON.parse(_t.decode(a)),!(Object.keys(a.settings).length>=0))throw new Error("\u5907\u4EFD\u6587\u4EF6\u5E94\u8BE5\u81F3\u5C11\u5305\u542B settings \u5B57\u6BB5")}catch{try{if(a=JSON.parse(a),!(Object.keys(a.settings).length>=0))throw new Error("\u5907\u4EFD\u6587\u4EF6\u5E94\u8BE5\u81F3\u5C11\u5305\u542B settings \u5B57\u6BB5")}catch(p){throw H.error(`Gist \u5907\u4EFD\u6587\u4EF6\u6821\u9A8C\u5931\u8D25, \u65E0\u6CD5\u8FD8\u539F Reason: ${p.message??p}`),new Error("Gist \u5907\u4EFD\u6587\u4EF6\u6821\u9A8C\u5931\u8D25, \u65E0\u6CD5\u8FD8\u539F")}}t&&(H.info(`\u4FDD\u7559\u539F\u6709\u8BBE\u7F6E ${t}`),t.split(",").forEach(m=>{tA.default.set(a,m,tA.default.get(s,m))})),H.write(JSON.stringify(a,null," "),"#sub-store"),H.env.isNode&&(H.cache=a,H.persistCache()),H.info("perform migration after restoring from gist..."),Rf(),H.info("migration completed"),H.info("\u8FD8\u539F\u5907\u4EFD\u5B8C\u6210");break}}async function Dz(e,t){let{action:r,keep:n,encode:i}=e.query,{gistToken:o}=H.read(Bt);if(!o)Je(t,new Ke("GIST_TOKEN_NOT_FOUND","GitHub Token is required for backup!"));else try{await _z(r,n,i),Ze(t)}catch(s){H.error(`Failed to ${r} gist data. Reason: ${s.message??s}`),Je(t,new Pr("BACKUP_FAILED",`Failed to ${r} gist data!`,`Reason: ${s.message??s}`))}}var zde=B(T());function nA(e){e.post("/api/sort/subs",Fz),e.post("/api/sort/collections",Iz),e.post("/api/sort/artifacts",Bz),e.post("/api/sort/files",$z),e.post("/api/sort/tokens",Tz),e.post("/api/sort/archives",Pz)}function Fz(e,t){let r=e.body,n=H.read(Er);n.sort((i,o)=>r.indexOf(i.name)-r.indexOf(o.name)),H.write(n,Er),Ze(t,n)}function Iz(e,t){let r=e.body,n=H.read(pr);n.sort((i,o)=>r.indexOf(i.name)-r.indexOf(o.name)),H.write(n,pr),Ze(t,n)}function Bz(e,t){let r=e.body,n=H.read(Wt);n.sort((i,o)=>r.indexOf(i.name)-r.indexOf(o.name)),H.write(n,Wt),Ze(t,n)}function $z(e,t){let r=e.body,n=H.read(Mt);n.sort((i,o)=>r.indexOf(i.name)-r.indexOf(o.name)),H.write(n,Mt),Ze(t,n)}function Tz(e,t){let r=e.body,n=H.read(rn);n.sort((i,o)=>r.indexOf(`${i.type}-${i.name}-${i.token}`)-r.indexOf(`${o.type}-${o.name}-${o.token}`)),H.write(n,rn),Ze(t,n)}function Pz(e,t){let r=a8(e.body);Ze(t,r)}var T6e=B(T());var ZSe=B(T());var mSe=B(T());var Qve=B(T());var Yve=B(T());var Kve=B(T(),1);var Fve=B(T(),1);var j2e=B(T(),1);var tpe=B(T(),1);var Yde=B(T(),1),wg=Symbol.for("yaml.alias"),yg=Symbol.for("yaml.document"),uo=Symbol.for("yaml.map"),sA=Symbol.for("yaml.pair"),di=Symbol.for("yaml.scalar"),gu=Symbol.for("yaml.seq"),Ps=Symbol.for("yaml.node.type"),co=e=>!!e&&typeof e=="object"&&e[Ps]===wg,lo=e=>!!e&&typeof e=="object"&&e[Ps]===yg,fo=e=>!!e&&typeof e=="object"&&e[Ps]===uo,qt=e=>!!e&&typeof e=="object"&&e[Ps]===sA,Pt=e=>!!e&&typeof e=="object"&&e[Ps]===di,ho=e=>!!e&&typeof e=="object"&&e[Ps]===gu;function sr(e){if(e&&typeof e=="object")switch(e[Ps]){case uo:case gu:return!0}return!1}function zt(e){if(e&&typeof e=="object")switch(e[Ps]){case wg:case uo:case di:case gu:return!0}return!1}var Eg=e=>(Pt(e)||sr(e))&&!!e.anchor;var Jde=B(T(),1);var Ys=Symbol("break visit"),MI=Symbol("skip children"),ca=Symbol("remove node");function la(e,t){let r=qI(t);lo(e)?ph(null,e.contents,r,Object.freeze([e]))===ca&&(e.contents=null):ph(null,e,r,Object.freeze([]))}la.BREAK=Ys;la.SKIP=MI;la.REMOVE=ca;function ph(e,t,r,n){let i=jI(e,t,r,n);if(zt(i)||qt(i))return KI(e,n,i),ph(e,i,r,n);if(typeof i!="symbol"){if(sr(t)){n=Object.freeze(n.concat(t));for(let o=0;oe.replace(/[!,[\]{}]/g,t=>xz[t]),fa=class e{constructor(t,r){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,r)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,r){this.atNextDocument&&(this.yaml={explicit:e.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},e.defaultTags),this.atNextDocument=!1);let n=t.trim().split(/[ \t]+/),i=n.shift();switch(i){case"%TAG":{if(n.length!==2&&(r(0,"%TAG directive should contain exactly two parts"),n.length<2))return!1;let[o,s]=n;return this.tags[o]=s,!0}case"%YAML":{if(this.yaml.explicit=!0,n.length!==1)return r(0,"%YAML directive should contain exactly one part"),!1;let[o]=n;if(o==="1.1"||o==="1.2")return this.yaml.version=o,!0;{let s=/^\d+\.\d+$/.test(o);return r(6,`Unsupported YAML version ${o}`,s),!1}}default:return r(0,`Unknown directive ${i}`,!0),!1}}tagName(t,r){if(t==="!")return"!";if(t[0]!=="!")return r(`Not a valid tag: ${t}`),null;if(t[1]==="<"){let s=t.slice(2,-1);return s==="!"||s==="!!"?(r(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&r("Verbatim tags must end with a >"),s)}let[,n,i]=t.match(/^(.*!)([^!]*)$/s);i||r(`The ${t} tag has no suffix`);let o=this.tags[n];if(o)try{return o+decodeURIComponent(i)}catch(s){return r(String(s)),null}return n==="!"?t:(r(`Could not resolve tag: ${t}`),null)}tagString(t){for(let[r,n]of Object.entries(this.tags))if(t.startsWith(n))return r+Rz(t.substring(n.length));return t[0]==="!"?t:`!<${t}>`}toString(t){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags),i;if(t&&n.length>0&&zt(t.contents)){let o={};la(t.contents,(s,a)=>{zt(a)&&a.tag&&(o[a.tag]=!0)}),i=Object.keys(o)}else i=[];for(let[o,s]of n)o==="!!"&&s==="tag:yaml.org,2002:"||(!t||i.some(a=>a.startsWith(s)))&&r.push(`%TAG ${o} ${s}`);return r.join(` `)}};fa.defaultYaml={explicit:!1,version:"1.2"};fa.defaultTags={"!!":"tag:yaml.org,2002:"};var pge=B(T(),1);var Ape=B(T(),1);var ipe=B(T(),1);function Ag(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let r=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw new Error(r)}return!0}function iA(e){let t=new Set;return la(e,{Value(r,n){n.anchor&&t.add(n.anchor)}}),t}function oA(e,t){for(let r=1;;++r){let n=`${e}${r}`;if(!t.has(n))return n}}function VI(e,t){let r=[],n=new Map,i=null;return{onAnchor:o=>{r.push(o),i??(i=iA(e));let s=oA(t,i);return i.add(s),s},setAnchors:()=>{for(let o of r){let s=n.get(o);if(typeof s=="object"&&s.anchor&&(Pt(s.node)||sr(s.node)))s.node.anchor=s.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=o,a}}},sourceObjects:n}}var mpe=B(T(),1);var ape=B(T(),1);function _c(e,t,r,n){if(n&&typeof n=="object")if(Array.isArray(n))for(let i=0,o=n.length;ifn(n,String(i),r));if(e&&typeof e.toJSON=="function"){if(!r||!Eg(e))return e.toJSON(t,r);let n={aliasCount:0,count:1,res:void 0};r.anchors.set(e,n),r.onCreate=o=>{n.res=o,delete r.onCreate};let i=e.toJSON(t,r);return r.onCreate&&r.onCreate(i),i}return typeof e=="bigint"&&!r?.keep?Number(e):e}var Dc=class{constructor(t){Object.defineProperty(this,Ps,{value:t})}clone(){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:r,maxAliasCount:n,onAnchor:i,reviver:o}={}){if(!lo(t))throw new TypeError("A document argument is required");let s={anchors:new Map,doc:t,keep:!0,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},a=fn(this,"",s);if(typeof i=="function")for(let{count:u,res:l}of s.anchors.values())i(l,u);return typeof o=="function"?_c(o,{"":a},"",a):a}};var vu=class extends Dc{constructor(t){super(wg),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,r){if(r?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let n;r?.aliasResolveCache?n=r.aliasResolveCache:(n=[],la(t,{Node:(o,s)=>{(co(s)||Eg(s))&&n.push(s)}}),r&&(r.aliasResolveCache=n));let i;for(let o of n){if(o===this)break;o.anchor===this.source&&(i=o)}return i}toJSON(t,r){if(!r)return{source:this.source};let{anchors:n,doc:i,maxAliasCount:o}=r,s=this.resolve(i,r);if(!s){let u=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(u)}let a=n.get(s);if(a||(fn(s,null,r),a=n.get(s)),a?.res===void 0){let u="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(u)}if(o>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=Sg(i,s,n)),a.count*a.aliasCount>o)){let u="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(u)}return a.res}toString(t,r,n){let i=`*${this.source}`;if(t){if(Ag(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){let o=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(o)}if(t.implicitKey)return`${i} `}return i}};function Sg(e,t,r){if(co(t)){let n=t.resolve(e),i=r&&n&&r.get(n);return i?i.count*i.aliasCount:0}else if(sr(t)){let n=0;for(let i of t.items){let o=Sg(e,i,r);o>n&&(n=o)}return n}else if(qt(t)){let n=Sg(e,t.key,r),i=Sg(e,t.value,r);return Math.max(n,i)}return 1}var Npe=B(T(),1);var Ppe=B(T(),1);var Fpe=B(T(),1);var Cg=e=>!e||typeof e!="function"&&typeof e!="object",et=class extends Dc{constructor(t){super(di),this.value=t}toJSON(t,r){return r?.keep?this.value:fn(this.value,t,r)}toString(){return String(this.value)}};et.BLOCK_FOLDED="BLOCK_FOLDED";et.BLOCK_LITERAL="BLOCK_LITERAL";et.PLAIN="PLAIN";et.QUOTE_DOUBLE="QUOTE_DOUBLE";et.QUOTE_SINGLE="QUOTE_SINGLE";var kz="tag:yaml.org,2002:";function Oz(e,t,r){if(t){let n=r.filter(o=>o.tag===t),i=n.find(o=>!o.format)??n[0];if(!i)throw new Error(`Tag ${t} not found`);return i}return r.find(n=>n.identify?.(e)&&!n.format)}function wu(e,t,r){if(lo(e)&&(e=e.contents),zt(e))return e;if(qt(e)){let m=r.schema[uo].createNode?.(r.schema,null,r);return m.items.push(e),m}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:n,onAnchor:i,onTagObj:o,schema:s,sourceObjects:a}=r,u;if(n&&e&&typeof e=="object"){if(u=a.get(e),u)return u.anchor??(u.anchor=i(e)),new vu(u.anchor);u={anchor:null,node:null},a.set(e,u)}t?.startsWith("!!")&&(t=kz+t.slice(2));let l=Oz(e,t,s.tags);if(!l){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){let m=new et(e);return u&&(u.node=m),m}l=e instanceof Map?s[uo]:Symbol.iterator in Object(e)?s[gu]:s[uo]}o&&(o(l),delete r.onTagObj);let f=l?.createNode?l.createNode(r.schema,e,r):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(r.schema,e,r):new et(e);return t?f.tag=t:l.default||(f.tag=l.tag),u&&(u.node=f),f}function Rp(e,t,r){let n=r;for(let i=t.length-1;i>=0;--i){let o=t[i];if(typeof o=="number"&&Number.isInteger(o)&&o>=0){let s=[];s[o]=n,n=s}else n=new Map([[o,n]])}return wu(n,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var vh=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done,gh=class extends Dc{constructor(t,r){super(t),Object.defineProperty(this,"schema",{value:r,configurable:!0,enumerable:!1,writable:!0})}clone(t){let r=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(r.schema=t),r.items=r.items.map(n=>zt(n)||qt(n)?n.clone(t):n),this.range&&(r.range=this.range.slice()),r}addIn(t,r){if(vh(t))this.add(r);else{let[n,...i]=t,o=this.get(n,!0);if(sr(o))o.addIn(i,r);else if(o===void 0&&this.schema)this.set(n,Rp(this.schema,i,r));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}}deleteIn(t){let[r,...n]=t;if(n.length===0)return this.delete(r);let i=this.get(r,!0);if(sr(i))return i.deleteIn(n);throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}getIn(t,r){let[n,...i]=t,o=this.get(n,!0);return i.length===0?!r&&Pt(o)?o.value:o:sr(o)?o.getIn(i,r):void 0}hasAllNullValues(t){return this.items.every(r=>{if(!qt(r))return!1;let n=r.value;return n==null||t&&Pt(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(t){let[r,...n]=t;if(n.length===0)return this.has(r);let i=this.get(r,!0);return sr(i)?i.hasIn(n):!1}setIn(t,r){let[n,...i]=t;if(i.length===0)this.set(n,r);else{let o=this.get(n,!0);if(sr(o))o.setIn(i,r);else if(o===void 0&&this.schema)this.set(n,Rp(this.schema,i,r));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}}};var A0e=B(T(),1);var n0e=B(T(),1);var Jpe=B(T(),1);var Upe=B(T(),1),zI=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function Hi(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var ha=(e,t,r)=>e.endsWith(` `)?Hi(r,t):r.includes(` `)?` `+Hi(r,t):(e.endsWith(" ")?"":" ")+r;var Vpe=B(T(),1);var Mpe=B(T(),1),aA="flow",_g="block",kp="quoted";function Op(e,t,r="flow",{indentAtStart:n,lineWidth:i=80,minContentWidth:o=20,onFold:s,onOverflow:a}={}){if(!i||i<0)return e;ii-Math.max(2,o)?l.push(0):m=i-n);let p,d,v=!1,g=-1,y=-1,w=-1;r===_g&&(g=GI(e,g,t.length),g!==-1&&(m=g+u));for(let S;S=e[g+=1];){if(r===kp&&S==="\\"){switch(y=g,e[g+1]){case"x":g+=3;break;case"u":g+=5;break;case"U":g+=9;break;default:g+=1}w=g}if(S===` `)r===_g&&(g=GI(e,g,t.length)),m=g+t.length+u,p=void 0;else{if(S===" "&&d&&d!==" "&&d!==` `&&d!==" "){let D=e[g+1];D&&D!==" "&&D!==` `&&D!==" "&&(p=g)}if(g>=m)if(p)l.push(p),m=p+u,p=void 0;else if(r===kp){for(;d===" "||d===" ";)d=S,S=e[g+=1],v=!0;let D=g>w+1?g-2:y-1;if(f[D])return e;l.push(D),f[D]=!0,m=D+u,p=void 0}else v=!0}d=S}if(v&&a&&a(),l.length===0)return e;s&&s();let E=e.slice(0,l[0]);for(let S=0;S({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),Ig=e=>/^(%|---|\.\.\.)/m.test(e);function Nz(e,t,r){if(!t||t<0)return!1;let n=t-r,i=e.length;if(i<=n)return!1;for(let o=0,s=0;on)return!0;if(s=o+1,i-s<=n)return!1}return!0}function Np(e,t){let r=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return r;let{implicitKey:n}=t,i=t.options.doubleQuotedMinMultiLineLength,o=t.indent||(Ig(e)?" ":""),s="",a=0;for(let u=0,l=r[u];l;l=r[++u])if(l===" "&&r[u+1]==="\\"&&r[u+2]==="n"&&(s+=r.slice(a,u)+"\\ ",u+=1,a=u,l="\\"),l==="\\")switch(r[u+1]){case"u":{s+=r.slice(a,u);let f=r.substr(u+2,4);switch(f){case"0000":s+="\\0";break;case"0007":s+="\\a";break;case"000b":s+="\\v";break;case"001b":s+="\\e";break;case"0085":s+="\\N";break;case"00a0":s+="\\_";break;case"2028":s+="\\L";break;case"2029":s+="\\P";break;default:f.substr(0,2)==="00"?s+="\\x"+f.substr(2):s+=r.substr(u,6)}u+=5,a=u+1}break;case"n":if(n||r[u+2]==='"'||r.length `;let m,p;for(p=r.length;p>0;--p){let F=r[p-1];if(F!==` `&&F!==" "&&F!==" ")break}let d=r.substring(p),v=d.indexOf(` `);v===-1?m="-":r===d||v!==d.length-1?(m="+",o&&o()):m="",d&&(r=r.slice(0,-d.length),d[d.length-1]===` `&&(d=d.slice(0,-1)),d=d.replace(cA,`$&${l}`));let g=!1,y,w=-1;for(y=0;y{M=!0});let C=Op(`${E}${F}${d}`,l,_g,z);if(!M)return`>${D} ${l}${C}`}return r=r.replace(/\n+/g,`$&${l}`),`|${D} ${l}${E}${r}${d}`}function Lz(e,t,r,n){let{type:i,value:o}=e,{actualString:s,implicitKey:a,indent:u,indentStep:l,inFlow:f}=t;if(a&&o.includes(` `)||f&&/[[\]{},]/.test(o))return wh(o,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(o))return a||f||!o.includes(` `)?wh(o,t):Dg(e,t,r,n);if(!a&&!f&&i!==et.PLAIN&&o.includes(` `))return Dg(e,t,r,n);if(Ig(o)){if(u==="")return t.forceBlockIndent=!0,Dg(e,t,r,n);if(a&&u===l)return wh(o,t)}let m=o.replace(/\n+/g,`$& ${u}`);if(s){let p=g=>g.default&&g.tag!=="tag:yaml.org,2002:str"&&g.test?.test(m),{compat:d,tags:v}=t.doc.schema;if(v.some(p)||d?.some(p))return wh(o,t)}return a?m:Op(m,u,aA,Fg(t,!1))}function Wl(e,t,r,n){let{implicitKey:i,inFlow:o}=t,s=typeof e.value=="string"?e:Object.assign({},e,{value:String(e.value)}),{type:a}=e;a!==et.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(s.value)&&(a=et.QUOTE_DOUBLE);let u=f=>{switch(f){case et.BLOCK_FOLDED:case et.BLOCK_LITERAL:return i||o?wh(s.value,t):Dg(s,t,r,n);case et.QUOTE_DOUBLE:return Np(s.value,t);case et.QUOTE_SINGLE:return uA(s.value,t);case et.PLAIN:return Lz(s,t,r,n);default:return null}},l=u(a);if(l===null){let{defaultKeyType:f,defaultStringType:m}=t.options,p=i&&f||m;if(l=u(p),l===null)throw new Error(`Unsupported default string type ${p}`)}return l}function Bg(e,t){let r=Object.assign({blockQuote:!0,commentString:zI,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t),n;switch(r.collectionStyle){case"block":n=!1;break;case"flow":n=!0;break;default:n=null}return{anchors:new Set,doc:e,flowCollectionPadding:r.flowCollectionPadding?" ":"",indent:"",indentStep:typeof r.indent=="number"?" ".repeat(r.indent):" ",inFlow:n,options:r}}function Uz(e,t){if(t.tag){let i=e.filter(o=>o.tag===t.tag);if(i.length>0)return i.find(o=>o.format===t.format)??i[0]}let r,n;if(Pt(t)){n=t.value;let i=e.filter(o=>o.identify?.(n));if(i.length>1){let o=i.filter(s=>s.test);o.length>0&&(i=o)}r=i.find(o=>o.format===t.format)??i.find(o=>!o.format)}else n=t,r=e.find(i=>i.nodeClass&&n instanceof i.nodeClass);if(!r){let i=n?.constructor?.name??(n===null?"null":typeof n);throw new Error(`Tag not resolved for ${i} value`)}return r}function Hz(e,t,{anchors:r,doc:n}){if(!n.directives)return"";let i=[],o=(Pt(e)||sr(e))&&e.anchor;o&&Ag(o)&&(r.add(o),i.push(`&${o}`));let s=e.tag??(t.default?null:t.tag);return s&&i.push(n.directives.tagString(s)),i.join(" ")}function yu(e,t,r,n){if(qt(e))return e.toString(t,r,n);if(co(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw new TypeError("Cannot stringify circular structure without alias nodes");t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let i,o=zt(e)?e:t.doc.createNode(e,{onTagObj:u=>i=u});i??(i=Uz(t.doc.schema.tags,o));let s=Hz(o,i,t);s.length>0&&(t.indentAtStart=(t.indentAtStart??0)+s.length+1);let a=typeof i.stringify=="function"?i.stringify(o,t,r,n):Pt(o)?Wl(o,t,r,n):o.toString(t,r,n);return s?Pt(o)||a[0]==="{"||a[0]==="["?`${s} ${a}`:`${s} ${t.indent}${a}`:a}function YI({key:e,value:t},r,n,i){let{allNullValues:o,doc:s,indent:a,indentStep:u,options:{commentString:l,indentSeq:f,simpleKeys:m}}=r,p=zt(e)&&e.comment||null;if(m){if(p)throw new Error("With simple keys, key nodes cannot have comments");if(sr(e)||!zt(e)&&typeof e=="object"){let z="With simple keys, collection cannot be used as a key value";throw new Error(z)}}let d=!m&&(!e||p&&t==null&&!r.inFlow||sr(e)||(Pt(e)?e.type===et.BLOCK_FOLDED||e.type===et.BLOCK_LITERAL:typeof e=="object"));r=Object.assign({},r,{allNullValues:!1,implicitKey:!d&&(m||!o),indent:a+u});let v=!1,g=!1,y=yu(e,r,()=>v=!0,()=>g=!0);if(!d&&!r.inFlow&&y.length>1024){if(m)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");d=!0}if(r.inFlow){if(o||t==null)return v&&n&&n(),y===""?"?":d?`? ${y}`:y}else if(o&&!m||t==null&&d)return y=`? ${y}`,p&&!v?y+=ha(y,r.indent,l(p)):g&&i&&i(),y;v&&(p=null),d?(p&&(y+=ha(y,r.indent,l(p))),y=`? ${y} ${a}:`):(y=`${y}:`,p&&(y+=ha(y,r.indent,l(p))));let w,E,S;zt(t)?(w=!!t.spaceBefore,E=t.commentBefore,S=t.comment):(w=!1,E=null,S=null,t&&typeof t=="object"&&(t=s.createNode(t))),r.implicitKey=!1,!d&&!p&&Pt(t)&&(r.indentAtStart=y.length+1),g=!1,!f&&u.length>=2&&!r.inFlow&&!d&&ho(t)&&!t.flow&&!t.tag&&!t.anchor&&(r.indent=r.indent.substring(2));let D=!1,F=yu(t,r,()=>D=!0,()=>g=!0),M=" ";if(p||w||E){if(M=w?` `:"",E){let z=l(E);M+=` ${Hi(z,r.indent)}`}F===""&&!r.inFlow?M===` `&&S&&(M=` `):M+=` ${r.indent}`}else if(!d&&sr(t)){let z=F[0],C=F.indexOf(` `),P=C!==-1,U=r.inFlow??t.flow??t.items.length===0;if(P||!U){let k=!1;if(P&&(z==="&"||z==="!")){let O=F.indexOf(" ");z==="&"&&O!==-1&&Oe===Tg||typeof e=="symbol"&&e.description===Tg,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new et(Symbol(Tg)),{addToJSMap:fA}),stringify:()=>Tg},WI=(e,t)=>(po.identify(t)||Pt(t)&&(!t.type||t.type===et.PLAIN)&&po.identify(t.value))&&e?.doc.schema.tags.some(r=>r.tag===po.tag&&r.default);function fA(e,t,r){let n=XI(e,r);if(ho(n))for(let i of n.items)lA(e,t,i);else if(Array.isArray(n))for(let i of n)lA(e,t,i);else lA(e,t,n)}function lA(e,t,r){let n=XI(e,r);if(!fo(n))throw new Error("Merge sources must be maps or map aliases");let i=n.toJSON(null,e,Map);for(let[o,s]of i)t instanceof Map?t.has(o)||t.set(o,s):t instanceof Set?t.add(o):Object.prototype.hasOwnProperty.call(t,o)||Object.defineProperty(t,o,{value:s,writable:!0,enumerable:!0,configurable:!0});return t}function XI(e,t){return e&&co(t)?t.resolve(e.doc,e):t}function Pg(e,t,{key:r,value:n}){if(zt(r)&&r.addToJSMap)r.addToJSMap(e,t,n);else if(WI(e,r))fA(e,t,n);else{let i=fn(r,"",e);if(t instanceof Map)t.set(i,fn(n,i,e));else if(t instanceof Set)t.add(i);else{let o=Mz(r,i,e),s=fn(n,o,e);o in t?Object.defineProperty(t,o,{value:s,writable:!0,enumerable:!0,configurable:!0}):t[o]=s}}return t}function Mz(e,t,r){if(t===null)return"";if(typeof t!="object")return String(t);if(zt(e)&&r?.doc){let n=Bg(r.doc,{});n.anchors=new Set;for(let o of r.anchors.keys())n.anchors.add(o.anchor);n.inFlow=!0,n.inStringifyKey=!0;let i=e.toString(n);if(!r.mapKeyWarned){let o=JSON.stringify(i);o.length>40&&(o=o.substring(0,36)+'..."'),$g(r.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${o}. Set mapAsMap: true to use object keys.`),r.mapKeyWarned=!0}return i}return JSON.stringify(t)}function yh(e,t,r){let n=wu(e,void 0,r),i=wu(t,void 0,r);return new Hr(n,i)}var Hr=class e{constructor(t,r=null){Object.defineProperty(this,Ps,{value:sA}),this.key=t,this.value=r}clone(t){let{key:r,value:n}=this;return zt(r)&&(r=r.clone(t)),zt(n)&&(n=n.clone(t)),new e(r,n)}toJSON(t,r){let n=r?.mapAsMap?new Map:{};return Pg(r,n,this)}toString(t,r,n){return t?.doc?YI(this,t,r,n):JSON.stringify(this)}};var Xme=B(T(),1);var U0e=B(T(),1);var k0e=B(T(),1);var F0e=B(T(),1);function Rg(e,t,r){return(t.inFlow??e.flow?jz:qz)(e,t,r)}function qz({comment:e,items:t},r,{blockItemPrefix:n,flowChars:i,itemIndent:o,onChompKeep:s,onComment:a}){let{indent:u,options:{commentString:l}}=r,f=Object.assign({},r,{indent:o,type:null}),m=!1,p=[];for(let v=0;vy=null,()=>m=!0);y&&(w+=ha(w,o,l(y))),m&&y&&(m=!1),p.push(n+w)}let d;if(p.length===0)d=i.start+i.end;else{d=p[0];for(let v=1;vy=null);l||(l=m.length>f||w.includes(` `)),v0&&(l||(l=m.reduce((E,S)=>E+S.length+2,2)+(w.length+2)>t.options.lineWidth)),l&&(w+=",")),y&&(w+=ha(w,n,a(y))),m.push(w),f=m.length}let{start:p,end:d}=r;if(m.length===0)return p+d;if(!l){let v=m.reduce((g,y)=>g+y.length+2,2);l=t.options.lineWidth>0&&v>t.options.lineWidth}if(l){let v=p;for(let g of m)v+=g?` ${o}${i}${g}`:` `;return`${v} ${i}${d}`}else return`${p}${s}${m.join(" ")}${s}${d}`}function xg({indent:e,options:{commentString:t}},r,n,i){if(n&&i&&(n=n.replace(/^\n+/,"")),n){let o=Hi(t(n),e);r.push(o.trimStart())}}function Fc(e,t){let r=Pt(t)?t.value:t;for(let n of e)if(qt(n)&&(n.key===t||n.key===r||Pt(n.key)&&n.key.value===r))return n}var Zr=class extends gh{static get tagName(){return"tag:yaml.org,2002:map"}constructor(t){super(uo,t),this.items=[]}static from(t,r,n){let{keepUndefined:i,replacer:o}=n,s=new this(t),a=(u,l)=>{if(typeof o=="function")l=o.call(r,u,l);else if(Array.isArray(o)&&!o.includes(u))return;(l!==void 0||i)&&s.items.push(yh(u,l,n))};if(r instanceof Map)for(let[u,l]of r)a(u,l);else if(r&&typeof r=="object")for(let u of Object.keys(r))a(u,r[u]);return typeof t.sortMapEntries=="function"&&s.items.sort(t.sortMapEntries),s}add(t,r){let n;qt(t)?n=t:!t||typeof t!="object"||!("key"in t)?n=new Hr(t,t?.value):n=new Hr(t.key,t.value);let i=Fc(this.items,n.key),o=this.schema?.sortMapEntries;if(i){if(!r)throw new Error(`Key ${n.key} already set`);Pt(i.value)&&Cg(n.value)?i.value.value=n.value:i.value=n.value}else if(o){let s=this.items.findIndex(a=>o(n,a)<0);s===-1?this.items.push(n):this.items.splice(s,0,n)}else this.items.push(n)}delete(t){let r=Fc(this.items,t);return r?this.items.splice(this.items.indexOf(r),1).length>0:!1}get(t,r){let i=Fc(this.items,t)?.value;return(!r&&Pt(i)?i.value:i)??void 0}has(t){return!!Fc(this.items,t)}set(t,r){this.add(new Hr(t,r),!0)}toJSON(t,r,n){let i=n?new n:r?.mapAsMap?new Map:{};r?.onCreate&&r.onCreate(i);for(let o of this.items)Pg(r,i,o);return i}toString(t,r,n){if(!t)return JSON.stringify(this);for(let i of this.items)if(!qt(i))throw new Error(`Map items must all be pairs; found ${JSON.stringify(i)} instead`);return!t.allNullValues&&this.hasAllNullValues(!1)&&(t=Object.assign({},t,{allNullValues:!0})),Rg(this,t,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:t.indent||"",onChompKeep:n,onComment:r})}};var mo={collection:"map",default:!0,nodeClass:Zr,tag:"tag:yaml.org,2002:map",resolve(e,t){return fo(e)||t("Expected a mapping for this tag"),e},createNode:(e,t,r)=>Zr.from(e,t,r)};var J0e=B(T(),1);var G0e=B(T(),1);var ls=class extends gh{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(t){super(gu,t),this.items=[]}add(t){this.items.push(t)}delete(t){let r=kg(t);return typeof r!="number"?!1:this.items.splice(r,1).length>0}get(t,r){let n=kg(t);if(typeof n!="number")return;let i=this.items[n];return!r&&Pt(i)?i.value:i}has(t){let r=kg(t);return typeof r=="number"&&r=0?t:null}var go={collection:"seq",default:!0,nodeClass:ls,tag:"tag:yaml.org,2002:seq",resolve(e,t){return ho(e)||t("Expected a sequence for this tag"),e},createNode:(e,t,r)=>ls.from(e,t,r)};var e1e=B(T(),1);var Ic={identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify(e,t,r,n){return t=Object.assign({actualString:!0},t),Wl(e,t,r,n)}};var jme=B(T(),1);var n1e=B(T(),1);var Xl={identify:e=>e==null,createNode:()=>new et(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new et(null),stringify:({source:e},t)=>typeof e=="string"&&Xl.test.test(e)?e:t.options.nullStr};var o1e=B(T(),1);var Lp={identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new et(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},r){if(e&&Lp.test.test(e)){let n=e[0]==="t"||e[0]==="T";if(t===n)return e}return t?r.options.trueStr:r.options.falseStr}};var h1e=B(T(),1);var u1e=B(T(),1);function hs({format:e,minFractionDigits:t,tag:r,value:n}){if(typeof n=="bigint")return String(n);let i=typeof n=="number"?n:Number(n);if(!isFinite(i))return isNaN(i)?".nan":i<0?"-.inf":".inf";let o=Object.is(n,-0)?"-0":JSON.stringify(n);if(!e&&t&&(!r||r==="tag:yaml.org,2002:float")&&/^-?\d/.test(o)&&!o.includes("e")){let s=o.indexOf(".");s<0&&(s=o.length,o+=".");let a=t-(o.length-s-1);for(;a-- >0;)o+="0"}return o}var Og={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:hs},Ng={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():hs(e)}},Lg={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new et(parseFloat(e)),r=e.indexOf(".");return r!==-1&&e[e.length-1]==="0"&&(t.minFractionDigits=e.length-r-1),t},stringify:hs};var m1e=B(T(),1);var Ug=e=>typeof e=="bigint"||Number.isInteger(e),hA=(e,t,r,{intAsBigInt:n})=>n?BigInt(e):parseInt(e.substring(t),r);function JI(e,t,r){let{value:n}=e;return Ug(n)&&n>=0?r+n.toString(t):hs(e)}var Hg={identify:e=>Ug(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,r)=>hA(e,2,8,r),stringify:e=>JI(e,8,"0o")},Mg={identify:Ug,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,r)=>hA(e,0,10,r),stringify:hs},qg={identify:e=>Ug(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,r)=>hA(e,2,16,r),stringify:e=>JI(e,16,"0x")};var C1e=B(T(),1);var ZI=[mo,go,Ic,Xl,Lp,Hg,Mg,qg,Og,Ng,Lg];var B1e=B(T(),1);function QI(e){return typeof e=="bigint"||Number.isInteger(e)}var jg=({value:e})=>JSON.stringify(e),Kz=[{identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:jg},{identify:e=>e==null,createNode:()=>new et(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:jg},{identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:e=>e==="true",stringify:jg},{identify:QI,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:r})=>r?BigInt(e):parseInt(e,10),stringify:({value:e})=>QI(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:jg}],Vz={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},eB=[mo,go].concat(Kz,Vz);var x1e=B(T(),1);var Up={identify:e=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof atob=="function"){let r=atob(e.replace(/[\n\r]/g,"")),n=new Uint8Array(r.length);for(let i=0;i1&&t("Each pair must have its own sequence indicator");let i=n.items[0]||new Hr(new et(null));if(n.commentBefore&&(i.key.commentBefore=i.key.commentBefore?`${n.commentBefore} ${i.key.commentBefore}`:n.commentBefore),n.comment){let o=i.value??i.key;o.comment=o.comment?`${n.comment} ${o.comment}`:n.comment}n=i}e.items[r]=qt(n)?n:new Hr(n)}}else t("Expected a sequence for this tag");return e}function pA(e,t,r){let{replacer:n}=r,i=new ls(e);i.tag="tag:yaml.org,2002:pairs";let o=0;if(t&&Symbol.iterator in Object(t))for(let s of t){typeof n=="function"&&(s=n.call(t,String(o++),s));let a,u;if(Array.isArray(s))if(s.length===2)a=s[0],u=s[1];else throw new TypeError(`Expected [key, value] tuple: ${s}`);else if(s&&s instanceof Object){let l=Object.keys(s);if(l.length===1)a=l[0],u=s[a];else throw new TypeError(`Expected tuple with one key, not ${l.length} keys`)}else a=s;i.items.push(yh(a,u,r))}return i}var Hp={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:dA,createNode:pA};var Eh=class e extends ls{constructor(){super(),this.add=Zr.prototype.add.bind(this),this.delete=Zr.prototype.delete.bind(this),this.get=Zr.prototype.get.bind(this),this.has=Zr.prototype.has.bind(this),this.set=Zr.prototype.set.bind(this),this.tag=e.tag}toJSON(t,r){if(!r)return super.toJSON(t);let n=new Map;r?.onCreate&&r.onCreate(n);for(let i of this.items){let o,s;if(qt(i)?(o=fn(i.key,"",r),s=fn(i.value,o,r)):o=fn(i,"",r),n.has(o))throw new Error("Ordered maps must not include duplicate keys");n.set(o,s)}return n}static from(t,r,n){let i=pA(t,r,n),o=new this;return o.items=i.items,o}};Eh.tag="tag:yaml.org,2002:omap";var Mp={collection:"seq",identify:e=>e instanceof Map,nodeClass:Eh,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let r=dA(e,t),n=[];for(let{key:i}of r.items)Pt(i)&&(n.includes(i.value)?t(`Ordered maps must not include duplicate keys: ${i.value}`):n.push(i.value));return Object.assign(new Eh,r)},createNode:(e,t,r)=>Eh.from(e,t,r)};var _me=B(T(),1);var W1e=B(T(),1);function tB({value:e,source:t},r){return t&&(e?mA:gA).test.test(t)?t:e?r.options.trueStr:r.options.falseStr}var mA={identify:e=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new et(!0),stringify:tB},gA={identify:e=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new et(!1),stringify:tB};var Q1e=B(T(),1);var rB={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:hs},nB={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():hs(e)}},sB={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new et(parseFloat(e.replace(/_/g,""))),r=e.indexOf(".");if(r!==-1){let n=e.substring(r+1).replace(/_/g,"");n[n.length-1]==="0"&&(t.minFractionDigits=n.length)}return t},stringify:hs};var rme=B(T(),1);var qp=e=>typeof e=="bigint"||Number.isInteger(e);function Kg(e,t,r,{intAsBigInt:n}){let i=e[0];if((i==="-"||i==="+")&&(t+=1),e=e.substring(t).replace(/_/g,""),n){switch(r){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let s=BigInt(e);return i==="-"?BigInt(-1)*s:s}let o=parseInt(e,r);return i==="-"?-1*o:o}function vA(e,t,r){let{value:n}=e;if(qp(n)){let i=n.toString(t);return n<0?"-"+r+i.substr(1):r+i}return hs(e)}var iB={identify:qp,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,r)=>Kg(e,2,2,r),stringify:e=>vA(e,2,"0b")},oB={identify:qp,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,r)=>Kg(e,1,8,r),stringify:e=>vA(e,8,"0")},aB={identify:qp,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,r)=>Kg(e,0,10,r),stringify:hs},uB={identify:qp,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,r)=>Kg(e,2,16,r),stringify:e=>vA(e,16,"0x")};var ame=B(T(),1);var bh=class e extends Zr{constructor(t){super(t),this.tag=e.tag}add(t){let r;qt(t)?r=t:t&&typeof t=="object"&&"key"in t&&"value"in t&&t.value===null?r=new Hr(t.key,null):r=new Hr(t,null),Fc(this.items,r.key)||this.items.push(r)}get(t,r){let n=Fc(this.items,t);return!r&&qt(n)?Pt(n.key)?n.key.value:n.key:n}set(t,r){if(typeof r!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof r}`);let n=Fc(this.items,t);n&&!r?this.items.splice(this.items.indexOf(n),1):!n&&r&&this.items.push(new Hr(t))}toJSON(t,r){return super.toJSON(t,r,Set)}toString(t,r,n){if(!t)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},t,{allNullValues:!0}),r,n);throw new Error("Set items must all have null values")}static from(t,r,n){let{replacer:i}=n,o=new this(t);if(r&&Symbol.iterator in Object(r))for(let s of r)typeof i=="function"&&(s=i.call(r,s,s)),o.items.push(yh(s,null,n));return o}};bh.tag="tag:yaml.org,2002:set";var jp={collection:"map",identify:e=>e instanceof Set,nodeClass:bh,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,r)=>bh.from(e,t,r),resolve(e,t){if(fo(e)){if(e.hasAllNullValues(!0))return Object.assign(new bh,e);t("Set items must all have null values")}else t("Expected a mapping for this tag");return e}};var lme=B(T(),1);function wA(e,t){let r=e[0],n=r==="-"||r==="+"?e.substring(1):e,i=s=>t?BigInt(s):Number(s),o=n.replace(/_/g,"").split(":").reduce((s,a)=>s*i(60)+i(a),i(0));return r==="-"?i(-1)*o:o}function cB(e){let{value:t}=e,r=s=>s;if(typeof t=="bigint")r=s=>BigInt(s);else if(isNaN(t)||!isFinite(t))return hs(e);let n="";t<0&&(n="-",t*=r(-1));let i=r(60),o=[t%i];return t<60?o.unshift(0):(t=(t-o[0])/i,o.unshift(t%i),t>=60&&(t=(t-o[0])/i,o.unshift(t))),n+o.map(s=>String(s).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var Vg={identify:e=>typeof e=="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:r})=>wA(e,r),stringify:cB},zg={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>wA(e,!1),stringify:cB},Ah={identify:e=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(Ah.test);if(!t)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,n,i,o,s,a]=t.map(Number),u=t[7]?Number((t[7]+"00").substr(1,3)):0,l=Date.UTC(r,n-1,i,o||0,s||0,a||0,u),f=t[8];if(f&&f!=="Z"){let m=wA(f,!1);Math.abs(m)<30&&(m*=60),l-=6e4*m}return new Date(l)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};var yA=[mo,go,Ic,Xl,mA,gA,iB,oB,aB,uB,rB,nB,sB,Up,po,Mp,Hp,jp,Vg,zg,Ah];var lB=new Map([["core",ZI],["failsafe",[mo,go,Ic]],["json",eB],["yaml11",yA],["yaml-1.1",yA]]),fB={binary:Up,bool:Lp,float:Lg,floatExp:Ng,floatNaN:Og,floatTime:zg,int:Mg,intHex:qg,intOct:Hg,intTime:Vg,map:mo,merge:po,null:Xl,omap:Mp,pairs:Hp,seq:go,set:jp,timestamp:Ah},hB={"tag:yaml.org,2002:binary":Up,"tag:yaml.org,2002:merge":po,"tag:yaml.org,2002:omap":Mp,"tag:yaml.org,2002:pairs":Hp,"tag:yaml.org,2002:set":jp,"tag:yaml.org,2002:timestamp":Ah};function Gg(e,t,r){let n=lB.get(t);if(n&&!e)return r&&!n.includes(po)?n.concat(po):n.slice();let i=n;if(!i)if(Array.isArray(e))i=[];else{let o=Array.from(lB.keys()).filter(s=>s!=="yaml11").map(s=>JSON.stringify(s)).join(", ");throw new Error(`Unknown schema "${t}"; use one of ${o} or define customTags array`)}if(Array.isArray(e))for(let o of e)i=i.concat(o);else typeof e=="function"&&(i=e(i.slice()));return r&&(i=i.concat(po)),i.reduce((o,s)=>{let a=typeof s=="string"?fB[s]:s;if(!a){let u=JSON.stringify(s),l=Object.keys(fB).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${u}; use one of ${l}`)}return o.includes(a)||o.push(a),o},[])}var zz=(e,t)=>e.keyt.key?1:0,Kp=class e{constructor({compat:t,customTags:r,merge:n,resolveKnownTags:i,schema:o,sortMapEntries:s,toStringDefaults:a}){this.compat=Array.isArray(t)?Gg(t,"compat"):t?Gg(null,t):null,this.name=typeof o=="string"&&o||"core",this.knownTags=i?hB:{},this.tags=Gg(r,this.name,n),this.toStringOptions=a??null,Object.defineProperty(this,uo,{value:mo}),Object.defineProperty(this,di,{value:Ic}),Object.defineProperty(this,gu,{value:go}),this.sortMapEntries=typeof s=="function"?s:s===!0?zz:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};var tge=B(T(),1);function dB(e,t){let r=[],n=t.directives===!0;if(t.directives!==!1&&e.directives){let u=e.directives.toString(e);u?(r.push(u),n=!0):e.directives.docStart&&(n=!0)}n&&r.push("---");let i=Bg(e,t),{commentString:o}=i.options;if(e.commentBefore){r.length!==1&&r.unshift("");let u=o(e.commentBefore);r.unshift(Hi(u,""))}let s=!1,a=null;if(e.contents){if(zt(e.contents)){if(e.contents.spaceBefore&&n&&r.push(""),e.contents.commentBefore){let f=o(e.contents.commentBefore);r.push(Hi(f,""))}i.forceBlockIndent=!!e.comment,a=e.contents.comment}let u=a?void 0:()=>s=!0,l=yu(e.contents,i,()=>a=null,u);a&&(l+=ha(l,"",o(a))),(l[0]==="|"||l[0]===">")&&r[r.length-1]==="---"?r[r.length-1]=`--- ${l}`:r.push(l)}else r.push(yu(e.contents,i));if(e.directives?.docEnd)if(e.comment){let u=o(e.comment);u.includes(` `)?(r.push("..."),r.push(Hi(u,""))):r.push(`... ${u}`)}else r.push("...");else{let u=e.comment;u&&s&&(u=u.replace(/^\n+/,"")),u&&((!s||a)&&r[r.length-1]!==""&&r.push(""),r.push(Hi(o(u),"")))}return r.join(` `)+` `}var Eu=class e{constructor(t,r,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Ps,{value:yg});let i=null;typeof r=="function"||Array.isArray(r)?i=r:n===void 0&&r&&(n=r,r=void 0);let o=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},n);this.options=o;let{version:s}=o;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(s=this.directives.yaml.version)):this.directives=new fa({version:s}),this.setSchema(s,n),this.contents=t===void 0?null:this.createNode(t,i,n)}clone(){let t=Object.create(e.prototype,{[Ps]:{value:yg}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=zt(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(t){Sh(this.contents)&&this.contents.add(t)}addIn(t,r){Sh(this.contents)&&this.contents.addIn(t,r)}createAlias(t,r){if(!t.anchor){let n=iA(this);t.anchor=!r||n.has(r)?oA(r||"a",n):r}return new vu(t.anchor)}createNode(t,r,n){let i;if(typeof r=="function")t=r.call({"":t},"",t),i=r;else if(Array.isArray(r)){let y=E=>typeof E=="number"||E instanceof String||E instanceof Number,w=r.filter(y).map(String);w.length>0&&(r=r.concat(w)),i=r}else n===void 0&&r&&(n=r,r=void 0);let{aliasDuplicateObjects:o,anchorPrefix:s,flow:a,keepUndefined:u,onTagObj:l,tag:f}=n??{},{onAnchor:m,setAnchors:p,sourceObjects:d}=VI(this,s||"a"),v={aliasDuplicateObjects:o??!0,keepUndefined:u??!1,onAnchor:m,onTagObj:l,replacer:i,schema:this.schema,sourceObjects:d},g=wu(t,f,v);return a&&sr(g)&&(g.flow=!0),p(),g}createPair(t,r,n={}){let i=this.createNode(t,null,n),o=this.createNode(r,null,n);return new Hr(i,o)}delete(t){return Sh(this.contents)?this.contents.delete(t):!1}deleteIn(t){return vh(t)?this.contents==null?!1:(this.contents=null,!0):Sh(this.contents)?this.contents.deleteIn(t):!1}get(t,r){return sr(this.contents)?this.contents.get(t,r):void 0}getIn(t,r){return vh(t)?!r&&Pt(this.contents)?this.contents.value:this.contents:sr(this.contents)?this.contents.getIn(t,r):void 0}has(t){return sr(this.contents)?this.contents.has(t):!1}hasIn(t){return vh(t)?this.contents!==void 0:sr(this.contents)?this.contents.hasIn(t):!1}set(t,r){this.contents==null?this.contents=Rp(this.schema,[t],r):Sh(this.contents)&&this.contents.set(t,r)}setIn(t,r){vh(t)?this.contents=r:this.contents==null?this.contents=Rp(this.schema,Array.from(t),r):Sh(this.contents)&&this.contents.setIn(t,r)}setSchema(t,r={}){typeof t=="number"&&(t=String(t));let n;switch(t){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new fa({version:"1.1"}),n={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=t:this.directives=new fa({version:t}),n={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,n=null;break;default:{let i=JSON.stringify(t);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${i}`)}}if(r.schema instanceof Object)this.schema=r.schema;else if(n)this.schema=new Kp(Object.assign(n,r));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:t,jsonArg:r,mapAsMap:n,maxAliasCount:i,onAnchor:o,reviver:s}={}){let a={anchors:new Map,doc:this,keep:!t,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},u=fn(this.contents,r??"",a);if(typeof o=="function")for(let{count:l,res:f}of a.anchors.values())o(f,l);return typeof s=="function"?_c(s,{"":u},"",u):u}toJSON(t,r){return this.toJS({json:!0,jsonArg:t,mapAsMap:!1,onAnchor:r})}toString(t={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in t&&(!Number.isInteger(t.indent)||Number(t.indent)<=0)){let r=JSON.stringify(t.indent);throw new Error(`"indent" option must be a positive integer, not ${r}`)}return dB(this,t)}};function Sh(e){if(sr(e))return!0;throw new Error("Expected a YAML collection as document contents")}var gge=B(T(),1),Vp=class extends Error{constructor(t,r,n,i){super(),this.name=t,this.code=n,this.message=i,this.pos=r}},vo=class extends Vp{constructor(t,r,n){super("YAMLParseError",t,r,n)}},zp=class extends Vp{constructor(t,r,n){super("YAMLWarning",t,r,n)}},EA=(e,t)=>r=>{if(r.pos[0]===-1)return;r.linePos=r.pos.map(a=>t.linePos(a));let{line:n,col:i}=r.linePos[0];r.message+=` at line ${n}, column ${i}`;let o=i-1,s=e.substring(t.lineStarts[n-1],t.lineStarts[n]).replace(/[\n\r]+$/,"");if(o>=60&&s.length>80){let a=Math.min(o-39,s.length-79);s="\u2026"+s.substring(a),o-=a-1}if(s.length>80&&(s=s.substring(0,79)+"\u2026"),n>1&&/^ *$/.test(s.substring(0,o))){let a=e.substring(t.lineStarts[n-2],t.lineStarts[n-1]);a.length>80&&(a=a.substring(0,79)+`\u2026 `),s=a+s}if(/[^ ]/.test(s)){let a=1,u=r.linePos[1];u?.line===n&&u.col>i&&(a=Math.max(1,Math.min(u.col-i,80-o)));let l=" ".repeat(o)+"^".repeat(a);r.message+=`: ${s} ${l} `}};var k2e=B(T(),1);var B2e=B(T(),1);var o2e=B(T(),1);var Rge=B(T(),1);var wge=B(T(),1);function da(e,{flow:t,indicator:r,next:n,offset:i,onError:o,parentIndent:s,startOnNewline:a}){let u=!1,l=a,f=a,m="",p="",d=!1,v=!1,g=null,y=null,w=null,E=null,S=null,D=null,F=null;for(let C of e)switch(v&&(C.type!=="space"&&C.type!=="newline"&&C.type!=="comma"&&o(C.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),v=!1),g&&(l&&C.type!=="comment"&&C.type!=="newline"&&o(g,"TAB_AS_INDENT","Tabs are not allowed as indentation"),g=null),C.type){case"space":!t&&(r!=="doc-start"||n?.type!=="flow-collection")&&C.source.includes(" ")&&(g=C),f=!0;break;case"comment":{f||o(C,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let P=C.source.substring(1)||" ";m?m+=p+P:m=P,p="",l=!1;break}case"newline":l?m?m+=C.source:(!D||r!=="seq-item-ind")&&(u=!0):p+=C.source,l=!0,d=!0,(y||w)&&(E=C),f=!0;break;case"anchor":y&&o(C,"MULTIPLE_ANCHORS","A node can have at most one anchor"),C.source.endsWith(":")&&o(C.offset+C.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),y=C,F??(F=C.offset),l=!1,f=!1,v=!0;break;case"tag":{w&&o(C,"MULTIPLE_TAGS","A node can have at most one tag"),w=C,F??(F=C.offset),l=!1,f=!1,v=!0;break}case r:(y||w)&&o(C,"BAD_PROP_ORDER",`Anchors and tags must be after the ${C.source} indicator`),D&&o(C,"UNEXPECTED_TOKEN",`Unexpected ${C.source} in ${t??"collection"}`),D=C,l=r==="seq-item-ind"||r==="explicit-key-ind",f=!1;break;case"comma":if(t){S&&o(C,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),S=C,l=!1,f=!1;break}default:o(C,"UNEXPECTED_TOKEN",`Unexpected ${C.type} token`),l=!1,f=!1}let M=e[e.length-1],z=M?M.offset+M.source.length:i;return v&&n&&n.type!=="space"&&n.type!=="newline"&&n.type!=="comma"&&(n.type!=="scalar"||n.source!=="")&&o(n.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),g&&(l&&g.indent<=s||n?.type==="block-map"||n?.type==="block-seq")&&o(g,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:S,found:D,spaceBefore:u,comment:m,hasNewline:d,anchor:y,tag:w,newlineAfterProp:E,end:z,start:F??z}}var Ege=B(T(),1);function Bc(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(` `))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let r of t.start)if(r.type==="newline")return!0;if(t.sep){for(let r of t.sep)if(r.type==="newline")return!0}if(Bc(t.key)||Bc(t.value))return!0}return!1;default:return!0}}var Sge=B(T(),1);function Gp(e,t,r){if(t?.type==="flow-collection"){let n=t.end[0];n.indent===e&&(n.source==="]"||n.source==="}")&&Bc(t)&&r(n,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}var Dge=B(T(),1);function Yg(e,t,r){let{uniqueKeys:n}=e.options;if(n===!1)return!1;let i=typeof n=="function"?n:(o,s)=>o===s||Pt(o)&&Pt(s)&&o.value===s.value;return t.some(o=>i(o.key,r))}var pB="All mapping items must start at the same column";function mB({composeNode:e,composeEmptyNode:t},r,n,i,o){let s=o?.nodeClass??Zr,a=new s(r.schema);r.atRoot&&(r.atRoot=!1);let u=n.offset,l=null;for(let f of n.items){let{start:m,key:p,sep:d,value:v}=f,g=da(m,{indicator:"explicit-key-ind",next:p??d?.[0],offset:u,onError:i,parentIndent:n.indent,startOnNewline:!0}),y=!g.found;if(y){if(p&&(p.type==="block-seq"?i(u,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in p&&p.indent!==n.indent&&i(u,"BAD_INDENT",pB)),!g.anchor&&!g.tag&&!d){l=g.end,g.comment&&(a.comment?a.comment+=` `+g.comment:a.comment=g.comment);continue}(g.newlineAfterProp||Bc(p))&&i(p??m[m.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else g.found?.indent!==n.indent&&i(u,"BAD_INDENT",pB);r.atKey=!0;let w=g.end,E=p?e(r,p,g,i):t(r,w,m,null,g,i);r.schema.compat&&Gp(n.indent,p,i),r.atKey=!1,Yg(r,a.items,E)&&i(w,"DUPLICATE_KEY","Map keys must be unique");let S=da(d??[],{indicator:"map-value-ind",next:v,offset:E.range[2],onError:i,parentIndent:n.indent,startOnNewline:!p||p.type==="block-scalar"});if(u=S.end,S.found){y&&(v?.type==="block-map"&&!S.hasNewline&&i(u,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),r.options.strict&&g.starte&&(e.type==="block-map"||e.type==="block-seq");function vB({composeNode:e,composeEmptyNode:t},r,n,i,o){let s=n.start.source==="{",a=s?"flow map":"flow sequence",u=o?.nodeClass??(s?Zr:ls),l=new u(r.schema);l.flow=!0;let f=r.atRoot;f&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let m=n.offset+n.start.source.length;for(let y=0;y0){let y=pa(v,g,r.options.strict,i);y.comment&&(l.comment?l.comment+=` `+y.comment:l.comment=y.comment),l.range=[n.offset,g,y.offset]}else l.range=[n.offset,g,g];return l}function SA(e,t,r,n,i,o){let s=r.type==="block-map"?mB(e,t,r,n,o):r.type==="block-seq"?gB(e,t,r,n,o):vB(e,t,r,n,o),a=s.constructor;return i==="!"||i===a.tagName?(s.tag=a.tagName,s):(i&&(s.tag=i),s)}function wB(e,t,r,n,i){let o=n.tag,s=o?t.directives.tagName(o.source,p=>i(o,"TAG_RESOLVE_FAILED",p)):null;if(r.type==="block-seq"){let{anchor:p,newlineAfterProp:d}=n,v=p&&o?p.offset>o.offset?p:o:p??o;v&&(!d||d.offsetp.tag===s&&p.collection===a);if(!u){let p=t.schema.knownTags[s];if(p?.collection===a)t.schema.tags.push(Object.assign({},p,{default:!1})),u=p;else return p?i(o,"BAD_COLLECTION_TYPE",`${p.tag} used for ${a} collection, but expects ${p.collection??"scalar"}`,!0):i(o,"TAG_RESOLVE_FAILED",`Unresolved tag: ${s}`,!0),SA(e,t,r,i,s)}let l=SA(e,t,r,i,s,u),f=u.resolve?.(l,p=>i(o,"TAG_RESOLVE_FAILED",p),t.options)??l,m=zt(f)?f:new et(f);return m.range=l.range,m.tag=s,u?.format&&(m.format=u.format),m}var y2e=B(T(),1);var c2e=B(T(),1);function CA(e,t,r){let n=t.offset,i=Gz(t,e.options.strict,r);if(!i)return{value:"",type:null,comment:"",range:[n,n,n]};let o=i.mode===">"?et.BLOCK_FOLDED:et.BLOCK_LITERAL,s=t.source?Yz(t.source):[],a=s.length;for(let g=s.length-1;g>=0;--g){let y=s[g][1];if(y===""||y==="\r")a=g;else break}if(a===0){let g=i.chomp==="+"&&s.length>0?` `.repeat(Math.max(1,s.length-1)):"",y=n+i.length;return t.source&&(y+=t.source.length),{value:g,type:o,comment:i.comment,range:[n,y,y]}}let u=t.indent+i.indent,l=t.offset+i.length,f=0;for(let g=0;gu&&(u=y.length);else{if(y.length=a;--g)s[g][0].length>u&&(a=g+1);let m="",p="",d=!1;for(let g=0;gu||w[0]===" "?(p===" "?p=` `:!d&&p===` `&&(p=` `),m+=p+y.slice(u)+w,p=` `,d=!0):w===""?p===` `?m+=` `:p=` `:(m+=p+w,p=" ",d=!1)}switch(i.chomp){case"-":break;case"+":for(let g=a;gr(n+p,d,v);switch(i){case"scalar":a=et.PLAIN,u=Wz(o,l);break;case"single-quoted-scalar":a=et.QUOTE_SINGLE,u=Xz(o,l);break;case"double-quoted-scalar":a=et.QUOTE_DOUBLE,u=Jz(o,l);break;default:return r(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${i}`),{value:"",type:null,comment:"",range:[n,n+o.length,n+o.length]}}let f=n+o.length,m=pa(s,f,t,r);return{value:u,type:a,comment:m.comment,range:[n,f,m.offset]}}function Wz(e,t){let r="";switch(e[0]){case" ":r="a tab character";break;case",":r="flow indicator character ,";break;case"%":r="directive indicator character %";break;case"|":case">":{r=`block scalar indicator ${e[0]}`;break}case"@":case"`":{r=`reserved character ${e[0]}`;break}}return r&&t(0,"BAD_SCALAR_START",`Plain value cannot start with ${r}`),yB(e)}function Xz(e,t){return(e[e.length-1]!=="'"||e.length===1)&&t(e.length,"MISSING_CHAR","Missing closing 'quote"),yB(e.slice(1,-1)).replace(/''/g,"'")}function yB(e){let t,r;try{t=new RegExp(`(.*?)(?o?e.slice(o,n+1):i)}else r+=i}return(e[e.length-1]!=='"'||e.length===1)&&t(e.length,"MISSING_CHAR",'Missing closing "quote'),r}function Zz(e,t){let r="",n=e[t+1];for(;(n===" "||n===" "||n===` `||n==="\r")&&!(n==="\r"&&e[t+2]!==` `);)n===` `&&(r+=` `),t+=1,n=e[t+1];return r||(r=" "),{fold:r,offset:t}}var Qz={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:` `,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function eG(e,t,r,n){let i=e.substr(t,r),s=i.length===r&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(s)}catch{let a=e.substr(t-2,r+2);return n(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}function DA(e,t,r,n){let{value:i,type:o,comment:s,range:a}=t.type==="block-scalar"?CA(e,t,n):_A(t,e.options.strict,n),u=r?e.directives.tagName(r.source,m=>n(r,"TAG_RESOLVE_FAILED",m)):null,l;e.options.stringKeys&&e.atKey?l=e.schema[di]:u?l=tG(e.schema,i,u,r,n):t.type==="scalar"?l=rG(e,i,t,n):l=e.schema[di];let f;try{let m=l.resolve(i,p=>n(r??t,"TAG_RESOLVE_FAILED",p),e.options);f=Pt(m)?m:new et(m)}catch(m){let p=m instanceof Error?m.message:String(m);n(r??t,"TAG_RESOLVE_FAILED",p),f=new et(i)}return f.range=a,f.source=i,o&&(f.type=o),u&&(f.tag=u),l.format&&(f.format=l.format),s&&(f.comment=s),f}function tG(e,t,r,n,i){if(r==="!")return e[di];let o=[];for(let a of e.tags)if(!a.collection&&a.tag===r)if(a.default&&a.test)o.push(a);else return a;for(let a of o)if(a.test?.test(t))return a;let s=e.knownTags[r];return s&&!s.collection?(e.tags.push(Object.assign({},s,{default:!1,test:void 0})),s):(i(n,"TAG_RESOLVE_FAILED",`Unresolved tag: ${r}`,r!=="tag:yaml.org,2002:str"),e[di])}function rG({atKey:e,directives:t,schema:r},n,i,o){let s=r.tags.find(a=>(a.default===!0||e&&a.default==="key")&&a.test?.test(n))||r[di];if(r.compat){let a=r.compat.find(u=>u.default&&u.test?.test(n))??r[di];if(s.tag!==a.tag){let u=t.tagString(s.tag),l=t.tagString(a.tag),f=`Value may be parsed as either ${u} or ${l}`;o(i,"TAG_RESOLVE_FAILED",f,!0)}}return s}var b2e=B(T(),1);function EB(e,t,r){if(t){r??(r=t.length);for(let n=r-1;n>=0;--n){let i=t[n];switch(i.type){case"space":case"comment":case"newline":e-=i.source.length;continue}for(i=t[++n];i?.type==="space";)e+=i.source.length,i=t[++n];break}}return e}var nG={composeNode:FA,composeEmptyNode:Wg};function FA(e,t,r,n){let i=e.atKey,{spaceBefore:o,comment:s,anchor:a,tag:u}=r,l,f=!0;switch(t.type){case"alias":l=sG(e,t,n),(a||u)&&n(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":l=DA(e,t,u,n),a&&(l.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{l=wB(nG,e,t,r,n),a&&(l.anchor=a.source.substring(1))}catch(m){let p=m instanceof Error?m.message:String(m);n(t,"RESOURCE_EXHAUSTION",p)}break;default:{let m=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;n(t,"UNEXPECTED_TOKEN",m),f=!1}}return l??(l=Wg(e,t.offset,void 0,null,r,n)),a&&l.anchor===""&&n(a,"BAD_ALIAS","Anchor cannot be an empty string"),i&&e.options.stringKeys&&(!Pt(l)||typeof l.value!="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str")&&n(u??t,"NON_STRING_KEY","With stringKeys, all keys must be strings"),o&&(l.spaceBefore=!0),s&&(t.type==="scalar"&&t.source===""?l.comment=s:l.commentBefore=s),e.options.keepSourceTokens&&f&&(l.srcToken=t),l}function Wg(e,t,r,n,{spaceBefore:i,comment:o,anchor:s,tag:a,end:u},l){let f={type:"scalar",offset:EB(t,r,n),indent:-1,source:""},m=DA(e,f,a,l);return s&&(m.anchor=s.source.substring(1),m.anchor===""&&l(s,"BAD_ALIAS","Anchor cannot be an empty string")),i&&(m.spaceBefore=!0),o&&(m.comment=o,m.range[2]=u),m}function sG({options:e},{offset:t,source:r,end:n},i){let o=new vu(r.substring(1));o.source===""&&i(t,"BAD_ALIAS","Alias cannot be an empty string"),o.source.endsWith(":")&&i(t+r.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let s=t+r.length,a=pa(n,s,e.strict,i);return o.range=[t,s,a.offset],a.comment&&(o.comment=a.comment),o}function bB(e,t,{offset:r,start:n,value:i,end:o},s){let a=Object.assign({_directives:t},e),u=new Eu(void 0,a),l={atKey:!1,atRoot:!0,directives:u.directives,options:u.options,schema:u.schema},f=da(n,{indicator:"doc-start",next:i??o?.[0],offset:r,onError:s,parentIndent:0,startOnNewline:!0});f.found&&(u.directives.docStart=!0,i&&(i.type==="block-map"||i.type==="block-seq")&&!f.hasNewline&&s(f.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),u.contents=i?FA(l,i,f,s):Wg(l,f.end,n,null,f,s);let m=u.contents.range[2],p=pa(o,m,!1,s);return p.comment&&(u.comment=p.comment),u.range=[r,m,p.offset],u}function Yp(e){if(typeof e=="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:r}=e;return[t,t+(typeof r=="string"?r.length:1)]}function AB(e){let t="",r=!1,n=!1;for(let i=0;i{let s=Yp(r);o?this.warnings.push(new zp(s,n,i)):this.errors.push(new vo(s,n,i))},this.directives=new fa({version:t.version||"1.2"}),this.options=t}decorate(t,r){let{comment:n,afterEmptyLine:i}=AB(this.prelude);if(n){let o=t.contents;if(r)t.comment=t.comment?`${t.comment} ${n}`:n;else if(i||t.directives.docStart||!o)t.commentBefore=n;else if(sr(o)&&!o.flow&&o.items.length>0){let s=o.items[0];qt(s)&&(s=s.key);let a=s.commentBefore;s.commentBefore=a?`${n} ${a}`:n}else{let s=o.commentBefore;o.commentBefore=s?`${n} ${s}`:n}}if(r){for(let o=0;o{let o=Yp(t);o[0]+=r,this.onError(o,"BAD_DIRECTIVE",n,i)}),this.prelude.push(t.source),this.atDirectives=!0;break;case"document":{let r=bB(this.options,this.directives,t,this.onError);this.atDirectives&&!r.directives.docStart&&this.onError(t,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(r,!1),this.doc&&(yield this.doc),this.doc=r,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(t.source);break;case"error":{let r=t.source?`${t.message}: ${JSON.stringify(t.source)}`:t.message,n=new vo(Yp(t),"UNEXPECTED_TOKEN",r);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case"doc-end":{if(!this.doc){let n="Unexpected doc-end without preceding document";this.errors.push(new vo(Yp(t),"UNEXPECTED_TOKEN",n));break}this.doc.directives.docEnd=!0;let r=pa(t.end,t.offset+t.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),r.comment){let n=this.doc.comment;this.doc.comment=n?`${n} ${r.comment}`:r.comment}this.doc.range[2]=r.offset;break}default:this.errors.push(new vo(Yp(t),"UNEXPECTED_TOKEN",`Unsupported token ${t.type}`))}}*end(t=!1,r=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(t){let n=Object.assign({_directives:this.directives},this.options),i=new Eu(void 0,n);this.atDirectives&&this.onError(r,"MISSING_CHAR","Missing directives-end indicator line"),i.range=[0,r,r],this.decorate(i,!1),yield i}}};var sve=B(T(),1);var W2e=B(T(),1);var J2e=B(T(),1);var Q2e=B(T(),1),IA=Symbol("break visit"),iG=Symbol("skip children"),SB=Symbol("remove item");function Jl(e,t){"type"in e&&e.type==="document"&&(e={start:e.start,value:e.value}),CB(Object.freeze([]),e,t)}Jl.BREAK=IA;Jl.SKIP=iG;Jl.REMOVE=SB;Jl.itemAtPath=(e,t)=>{let r=e;for(let[n,i]of t){let o=r?.[n];if(o&&"items"in o)r=o.items[i];else return}return r};Jl.parentCollection=(e,t)=>{let r=Jl.itemAtPath(e,t.slice(0,-1)),n=t[t.length-1][0],i=r?.[n];if(i&&"items"in i)return i;throw new Error("Parent collection not found")};function CB(e,t,r){let n=r(t,e);if(typeof n=="symbol")return n;for(let i of["key","value"]){let o=t[i];if(o&&"items"in o){for(let s=0;s":return"block-scalar-header"}return null}var lve=B(T(),1);function wo(e){switch(e){case void 0:case" ":case` `:case"\r":case" ":return!0;default:return!1}}var DB=new Set("0123456789ABCDEFabcdef"),aG=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Jg=new Set(",[]{}"),uG=new Set(` ,[]{} \r `),PA=e=>!e||uG.has(e),Xp=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(t,r=!1){if(t){if(typeof t!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+t:t,this.lineEndPos=null}this.atEnd=!r;let n=this.next??"stream";for(;n&&(r||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let t=this.pos,r=this.buffer[t];for(;r===" "||r===" ";)r=this.buffer[++t];return!r||r==="#"||r===` `?!0:r==="\r"?this.buffer[t+1]===` `:!1}charAt(t){return this.buffer[this.pos+t]}continueScalar(t){let r=this.buffer[t];if(this.indentNext>0){let n=0;for(;r===" ";)r=this.buffer[++n+t];if(r==="\r"){let i=this.buffer[n+t+1];if(i===` `||!i&&!this.atEnd)return t+n+1}return r===` `||n>=this.indentNext||!r&&!this.atEnd?t+n:-1}if(r==="-"||r==="."){let n=this.buffer.substr(t,3);if((n==="---"||n==="...")&&wo(this.buffer[t+3]))return-1}return t}getLine(){let t=this.lineEndPos;return(typeof t!="number"||t!==-1&&tthis.indentValue&&!wo(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[t,r]=this.peek(2);if(!r&&!this.atEnd)return this.setNext("block-start");if((t==="-"||t==="?"||t===":")&&wo(r)){let n=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=n,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let t=this.getLine();if(t===null)return this.setNext("doc");let r=yield*this.pushIndicators();switch(t[r]){case"#":yield*this.pushCount(t.length-r);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(PA),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return r+=yield*this.parseBlockScalarHeader(),r+=yield*this.pushSpaces(!0),yield*this.pushCount(t.length-r),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let t,r,n=-1;do t=yield*this.pushNewline(),t>0?(r=yield*this.pushSpaces(!1),this.indentValue=n=r):r=0,r+=yield*this.pushSpaces(!0);while(t+r>0);let i=this.getLine();if(i===null)return this.setNext("flow");if((n!==-1&&n"0"&&r<="9")this.blockScalarIndent=Number(r)-1;else if(r!=="-")break}return yield*this.pushUntil(r=>wo(r)||r==="#")}*parseBlockScalar(){let t=this.pos-1,r=0,n;e:for(let o=this.pos;n=this.buffer[o];++o)switch(n){case" ":r+=1;break;case` `:t=o,r=0;break;case"\r":{let s=this.buffer[o+1];if(!s&&!this.atEnd)return this.setNext("block-scalar");if(s===` `)break}default:break e}if(!n&&!this.atEnd)return this.setNext("block-scalar");if(r>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=r:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let o=this.continueScalar(t+1);if(o===-1)break;t=this.buffer.indexOf(` `,o)}while(t!==-1);if(t===-1){if(!this.atEnd)return this.setNext("block-scalar");t=this.buffer.length}}let i=t+1;for(n=this.buffer[i];n===" ";)n=this.buffer[++i];if(n===" "){for(;n===" "||n===" "||n==="\r"||n===` `;)n=this.buffer[++i];t=i-1}else if(!this.blockScalarKeep)do{let o=t-1,s=this.buffer[o];s==="\r"&&(s=this.buffer[--o]);let a=o;for(;s===" ";)s=this.buffer[--o];if(s===` `&&o>=this.pos&&o+1+r>a)t=o;else break}while(!0);return yield Xg,yield*this.pushToIndex(t+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let t=this.flowLevel>0,r=this.pos-1,n=this.pos-1,i;for(;i=this.buffer[++n];)if(i===":"){let o=this.buffer[n+1];if(wo(o)||t&&Jg.has(o))break;r=n}else if(wo(i)){let o=this.buffer[n+1];if(i==="\r"&&(o===` `?(n+=1,i=` `,o=this.buffer[n+1]):r=n),o==="#"||t&&Jg.has(o))break;if(i===` `){let s=this.continueScalar(n+1);if(s===-1)break;n=Math.max(n,s-2)}}else{if(t&&Jg.has(i))break;r=n}return!i&&!this.atEnd?this.setNext("plain-scalar"):(yield Xg,yield*this.pushToIndex(r+1,!0),t?"flow":"doc")}*pushCount(t){return t>0?(yield this.buffer.substr(this.pos,t),this.pos+=t,t):0}*pushToIndex(t,r){let n=this.buffer.slice(this.pos,t);return n?(yield n,this.pos+=n.length,n.length):(r&&(yield""),0)}*pushIndicators(){let t=0;e:for(;;){switch(this.charAt(0)){case"!":t+=yield*this.pushTag(),t+=yield*this.pushSpaces(!0);continue e;case"&":t+=yield*this.pushUntil(PA),t+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let r=this.flowLevel>0,n=this.charAt(1);if(wo(n)||r&&Jg.has(n)){r?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,t+=yield*this.pushCount(1),t+=yield*this.pushSpaces(!0);continue e}}}break e}return t}*pushTag(){if(this.charAt(1)==="<"){let t=this.pos+2,r=this.buffer[t];for(;!wo(r)&&r!==">";)r=this.buffer[++t];return yield*this.pushToIndex(r===">"?t+1:t,!1)}else{let t=this.pos+1,r=this.buffer[t];for(;r;)if(aG.has(r))r=this.buffer[++t];else if(r==="%"&&DB.has(this.buffer[t+1])&&DB.has(this.buffer[t+2]))r=this.buffer[t+=3];else break;return yield*this.pushToIndex(t,!1)}}*pushNewline(){let t=this.buffer[this.pos];return t===` `?yield*this.pushCount(1):t==="\r"&&this.charAt(1)===` `?yield*this.pushCount(2):0}*pushSpaces(t){let r=this.pos-1,n;do n=this.buffer[++r];while(n===" "||t&&n===" ");let i=r-this.pos;return i>0&&(yield this.buffer.substr(this.pos,i),this.pos=r),i}*pushUntil(t){let r=this.pos,n=this.buffer[r];for(;!t(n);)n=this.buffer[++r];return yield*this.pushToIndex(r,!1)}};var hve=B(T(),1),Jp=class{constructor(){this.lineStarts=[],this.addNewLine=t=>this.lineStarts.push(t),this.linePos=t=>{let r=0,n=this.lineStarts.length;for(;r>1;this.lineStarts[o]=0;)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;e[++t]?.type==="space";);return e.splice(t,e.length)}function Qg(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let r=0;r0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let t=this.peek(1);if(this.type==="doc-end"&&t?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!t)return yield*this.stream();switch(t.type){case"document":return yield*this.document(t);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(t);case"block-scalar":return yield*this.blockScalar(t);case"block-map":return yield*this.blockMap(t);case"block-seq":return yield*this.blockSequence(t);case"flow-collection":return yield*this.flowCollection(t);case"doc-end":return yield*this.documentEnd(t)}yield*this.pop()}peek(t){return this.stack[this.stack.length-t]}*pop(t){let r=t??this.stack.pop();if(r)if(this.stack.length===0)yield r;else{let n=this.peek(1);switch(r.type==="block-scalar"?r.indent="indent"in n?n.indent:0:r.type==="flow-collection"&&n.type==="document"&&(r.indent=0),r.type==="flow-collection"&&IB(r),n.type){case"document":n.value=r;break;case"block-scalar":n.props.push(r);break;case"block-map":{let i=n.items[n.items.length-1];if(i.value){n.items.push({start:[],key:r,sep:[]}),this.onKeyLine=!0;return}else if(i.sep)i.value=r;else{Object.assign(i,{key:r,sep:[]}),this.onKeyLine=!i.explicitKey;return}break}case"block-seq":{let i=n.items[n.items.length-1];i.value?n.items.push({start:[],value:r}):i.value=r;break}case"flow-collection":{let i=n.items[n.items.length-1];!i||i.value?n.items.push({start:[],key:r,sep:[]}):i.sep?i.value=r:Object.assign(i,{key:r,sep:[]});return}default:yield*this.pop(),yield*this.pop(r)}if((n.type==="document"||n.type==="block-map"||n.type==="block-seq")&&(r.type==="block-map"||r.type==="block-seq")){let i=r.items[r.items.length-1];i&&!i.sep&&!i.value&&i.start.length>0&&FB(i.start)===-1&&(r.indent===0||i.start.every(o=>o.type!=="comment"||o.indent=t.indent){let n=!this.onKeyLine&&this.indent===t.indent,i=n&&(r.sep||r.explicitKey)&&this.type!=="seq-item-ind",o=[];if(i&&r.sep&&!r.value){let s=[];for(let a=0;at.indent&&(s.length=0);break;default:s.length=0}}s.length>=2&&(o=r.sep.splice(s[1]))}switch(this.type){case"anchor":case"tag":i||r.value?(o.push(this.sourceToken),t.items.push({start:o}),this.onKeyLine=!0):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"explicit-key-ind":!r.sep&&!r.explicitKey?(r.start.push(this.sourceToken),r.explicitKey=!0):i||r.value?(o.push(this.sourceToken),t.items.push({start:o,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(r.explicitKey)if(r.sep)if(r.value)t.items.push({start:[],key:null,sep:[this.sourceToken]});else if($c(r.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]});else if(BB(r.key)&&!$c(r.sep,"newline")){let s=Ch(r.start),a=r.key,u=r.sep;u.push(this.sourceToken),delete r.key,delete r.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:a,sep:u}]})}else o.length>0?r.sep=r.sep.concat(o,this.sourceToken):r.sep.push(this.sourceToken);else if($c(r.start,"newline"))Object.assign(r,{key:null,sep:[this.sourceToken]});else{let s=Ch(r.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]})}else r.sep?r.value||i?t.items.push({start:o,key:null,sep:[this.sourceToken]}):$c(r.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let s=this.flowScalar(this.type);i||r.value?(t.items.push({start:o,key:s,sep:[]}),this.onKeyLine=!0):r.sep?this.stack.push(s):(Object.assign(r,{key:s,sep:[]}),this.onKeyLine=!0);return}default:{let s=this.startBlockValue(t);if(s){if(s.type==="block-seq"){if(!r.explicitKey&&r.sep&&!$c(r.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else n&&t.items.push({start:o});this.stack.push(s);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(t){let r=t.items[t.items.length-1];switch(this.type){case"newline":if(r.value){let n="end"in r.value?r.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment"?n?.push(this.sourceToken):t.items.push({start:[this.sourceToken]})}else r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)t.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(r.start,t.indent)){let i=t.items[t.items.length-2]?.value?.end;if(Array.isArray(i)){Qg(i,r.start),i.push(this.sourceToken),t.items.pop();return}}r.start.push(this.sourceToken)}return;case"anchor":case"tag":if(r.value||this.indent<=t.indent)break;r.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==t.indent)break;r.value||$c(r.start,"seq-item-ind")?t.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return}if(this.indent>t.indent){let n=this.startBlockValue(t);if(n){this.stack.push(n);return}}yield*this.pop(),yield*this.step()}*flowCollection(t){let r=t.items[t.items.length-1];if(this.type==="flow-error-end"){let n;do yield*this.pop(),n=this.peek(1);while(n?.type==="flow-collection")}else if(t.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!r||r.sep?t.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return;case"map-value-ind":!r||r.value?t.items.push({start:[],key:null,sep:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!r||r.value?t.items.push({start:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let i=this.flowScalar(this.type);!r||r.value?t.items.push({start:[],key:i,sep:[]}):r.sep?this.stack.push(i):Object.assign(r,{key:i,sep:[]});return}case"flow-map-end":case"flow-seq-end":t.end.push(this.sourceToken);return}let n=this.startBlockValue(t);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let n=this.peek(2);if(n.type==="block-map"&&(this.type==="map-value-ind"&&n.indent===t.indent||this.type==="newline"&&!n.items[n.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&n.type!=="flow-collection"){let i=Zg(n),o=Ch(i);IB(t);let s=t.end.splice(1,t.end.length);s.push(this.sourceToken);let a={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:o,key:t,sep:s}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(t)}}flowScalar(t){if(this.onNewLine){let r=this.source.indexOf(` `)+1;for(;r!==0;)this.onNewLine(this.offset+r),r=this.source.indexOf(` `,r)+1}return{type:t,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(t){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let r=Zg(t),n=Ch(r);return n.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let r=Zg(t),n=Ch(r);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(t,r){return this.type!=="comment"||this.indent<=r?!1:t.every(n=>n.type==="newline"||n.type==="space")}*documentEnd(t){this.type!=="doc-mode"&&(t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(t){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};var _ve=B(T(),1);function cG(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new Jp||null,prettyErrors:t}}function $B(e,t={}){let{lineCounter:r,prettyErrors:n}=cG(t),i=new Zp(r?.addNewLine),o=new Wp(t),s=null;for(let a of o.compose(i.parse(e),!0,e.length))if(!s)s=a;else if(s.options.logLevel!=="silent"){s.errors.push(new vo(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return n&&r&&(s.errors.forEach(EA(e,r)),s.warnings.forEach(EA(e,r))),s}function xA(e,t,r){let n;typeof t=="function"?n=t:r===void 0&&t&&typeof t=="object"&&(r=t);let i=$B(e,r);if(!i)return null;if(i.warnings.forEach(o=>$g(i.options.logLevel,o)),i.errors.length>0){if(i.options.logLevel!=="silent")throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:n},r))}function RA(e,t,r){let n=null;if(typeof t=="function"||Array.isArray(t)?n=t:r===void 0&&t&&(r=t),typeof r=="string"&&(r=r.length),typeof r=="number"){let i=Math.round(r);r=i<1?void 0:i>8?{indent:8}:{indent:i}}if(e===void 0){let{keepUndefined:i}=r??t??{};if(!i)return}return lo(e)&&!n?e.toString(r):new Eu(e,n,r).toString(r)}var fG={logLevel:"error",merge:!0};function PB(e,t,...r){try{return e(t,...r)}catch{return e(kB(e(t.replace(/!\s*/g,"__SubStoreJSYAMLString__"),...r)).replace(/__SubStoreJSYAMLString__/g,""),...r)}}function e2(e){return JSON.parse(JSON.stringify(e))}function hG(e){return{...fG,...e||{}}}function dG(e={}){let{forceQuotes:t,lineWidth:r,noArrayIndent:n,noRefs:i,quotingType:o,sortKeys:s,...a}=e||{},u={...a};return typeof r=="number"&&(u.lineWidth=r<=0?0:r),typeof n=="boolean"&&(u.indentSeq=!n),typeof i=="boolean"&&(u.aliasDuplicateObjects=!i),typeof s<"u"&&(u.sortMapEntries=s),o==="'"?u.singleQuote=!0:o==='"'&&(u.singleQuote=!1),t&&(u.defaultStringType=o==="'"?"QUOTE_SINGLE":"QUOTE_DOUBLE"),u}function xB(e,t){return xA(e,hG(t))}function RB(e,t){return RA(e,dG(t))}function _h(e,...t){return PB(xB,e2(e),...t)}function pG(e,...t){return PB(xB,e2(e),...t)}function TB(e,...t){return RB(e2(e),...t)}function kB(e,...t){return RB(e2(e),...t)}var pi={safeLoad:_h,load:pG,safeDump:TB,dump:kB,parse:_h,stringify:TB};function Qp(e){if(typeof e!="string"||!e.includes("proxies:")||!e.includes("short-id:"))return e;try{let t=_h(e);if(!Array.isArray(t.proxies)||t.proxies.length===0)return e}catch{return e}return e.replace(/short-id:([ \t]*[^#\n,}]*)/g,(t,r)=>{let n=r.trim();return!n||n===""?'short-id: ""':/^(['"]).*\1$/.test(n)?`short-id: ${n}`:["null"].includes(n)?`short-id: ${n}`:`short-id: "${n}"`})}function mG(){return{name:"HTML",test:n=>/^/.test(n),parse:()=>""}}function gG(){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 _t.isValid(i)&&!/^\w+:\/\/\w+/im.test(i)&&t.some(o=>i.indexOf(o)!==-1)},parse:function(i){let o=_t.decode(i);return/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(o)?o:(H.error("Base64 Pre-processor error: decoded line does not start with protocol"),i)}}}function vG(){return{name:"Fallback Base64 Pre-processor",test:function(n){return _t.isValid(n)},parse:function(n){let i=_t.decode(n);return/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(i)?i:(H.error("Fallback Base64 Pre-processor error: decoded line does not start with protocol"),n)}}}function wG(){return{name:"Clash Pre-processor",test:function(n){if(!/proxies/.test(n))return!1;let i=_h(n);return Array.isArray(i.proxies)||Array.isArray(i["proxy-groups"])},parse:function(n,i){let o=Qp(n),{proxies:s}=_h(o);return(i?`proxies: `:"")+(Array.isArray(s)?s:[]).map(a=>`${i?" - ":""}${JSON.stringify(a)} `).join("")}}}function yG(){return{name:"SSD Pre-processor",test:function(n){return n.indexOf("ssd://")===0},parse:function(n){let i=[],o=JSON.parse(_t.decode(n.split("ssd://")[1])),s=o.port,a=o.encryption,u=o.password,l=o.servers;for(let f=0;ft)}var gwe=B(T());var aS={"\u{1F3F3}\uFE0F\u200D\u{1F308}":["EXP","BAND"],"\u{1F1F8}\u{1F1F1}":["TEST","SOS"],"\u{1F1F2}\u{1F1F5}":["MP","MNP"],"\u{1F1F8}\u{1F1F4}":["SO","SOM"],"\u{1F1E6}\u{1F1F6}":["AQ","ATA"],"\u{1F1E6}\u{1F1EC}":["AG","ATG"],"\u{1F1EC}\u{1F1F1}":["GL","GRL"],"\u{1F1FF}\u{1F1FC}":["ZW","ZWE"],"\u{1F1E6}\u{1F1FC}":["AW","ABW"],"\u{1F1F2}\u{1F1F1}":["ML","MLI"],"\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{1F1EB}":["CF","CAF"],"\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{1F1E9}\u{1F1FF}":["DZ","DZA"],"\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{1F1EE}\u{1F1F6}":["IQ","IRQ"],"\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{1F1F8}":["LS","LSO"],"\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{1F1F4}\u{1F1F2}":["OM","OMN"],"\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{1F1F6}\u{1F1E6}":["QA","QAT"],"\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{1F1FC}\u{1F1F8}":["WS","WSM"],"\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{1F1EC}":["TG","TGO"],"\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{1F1E6}":["VA","VAT"],"\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 Nh(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{1F1F2}\u{1F1F5}":["\u5317\u9A6C\u91CC\u4E9A\u7EB3","Northern Mariana Islands","Saipan","\u585E\u73ED"],"\u{1F1F8}\u{1F1F4}":["Somalia","\u7D22\u9A6C\u91CC","\u6469\u52A0\u8FEA\u6C99","Mogadishu"],"\u{1F1E6}\u{1F1F6}":["Antarctica","\u5357\u6781\u6D32","\u5357\u6781"],"\u{1F1E6}\u{1F1EC}":["Antigua and Barbuda","\u5B89\u63D0\u74DC\u548C\u5DF4\u5E03\u8FBE"],"\u{1F1EC}\u{1F1F1}":["Greenland","\u683C\u9675\u5170\u5C9B","\u683C\u9675\u5170"],"\u{1F1FF}\u{1F1FC}":["Zimbabwe","\u6D25\u5DF4\u5E03\u97E6"],"\u{1F1E6}\u{1F1FC}":["Aruba","\u963F\u9C81\u5DF4"],"\u{1F1F2}\u{1F1F1}":["Mali","\u9A6C\u91CC"],"\u{1F1E6}\u{1F1E9}":["Andorra","\u5B89\u9053\u5C14"],"\u{1F1E6}\u{1F1EA}":["United Arab Emirates","\u963F\u8054\u914B","\u8FEA\u62DC","Dubai"],"\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{1F1FC}\u{1F1F8}":["Samoa","\u8428\u6469\u4E9A","\u85A9\u6469\u4E9E"],"\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{1F1EB}":["Central African Republic","\u4E2D\u975E\u5171\u548C\u56FD","\u4E2D\u975E"],"\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","Czech","Czech Republic"],"\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{1F1E9}\u{1F1FF}":["Algeria","\u963F\u5C14\u53CA\u5229\u4E9A","\u963F\u723E\u53CA\u5229\u4E9E"],"\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{1F1EE}\u{1F1F6}":["Iraq","\u4F0A\u62C9\u514B","\u5DF4\u683C\u8FBE","Baghdad"],"\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{1F1F8}":["Lesotho","\u83B1\u7D22\u6258"],"\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{1F1F4}\u{1F1F2}":["Oman","\u963F\u66FC","\u9A6C\u65AF\u5580\u7279"],"\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{1F1F6}\u{1F1E6}":["Qatar","\u5361\u5854\u5C14","\u5361\u5854\u723E"],"\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{1F1EC}":["Togo","\u591A\u54E5","\u6D1B\u7F8E","Lom\xE9","Lome"],"\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{1F1E6}":["Vatican","Vatican City","Holy See","\u68B5\u8482\u5188","\u68B5\u8482\u5CA1"],"\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(o=>RegExp(`${o}`,"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(aS))if(aS[n].some(o=>RegExp(`(^|[^a-zA-Z])${o}([^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 B9(e){return aS[Nh(e)]?.[0]}function a0(e){return e.replace(/[\uD83C][\uDDE6-\uDDFF][\uD83C][\uDDE6-\uDDFF]|🏴‍☠️|🏳️‍🌈/g,"").trim()}var b2=class{constructor({country,asn}={}){if(H.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 xwe=B(T());var Uh=B(H9()),nf=B(i2());var M9=53,QX=853,c0=2;function vS({domain:e,type:t="A",edns:r}){let n=[];return r&&n.push({type:"OPT",name:".",udpPayloadSize:4096,flags:0,options:[{code:"CLIENT_SUBNET",ip:r,sourcePrefixLength:Gr(r)?24:56,scopePrefixLength:0}]}),Uh.default.encode({type:"query",id:0,flags:Uh.default.RECURSION_DESIRED,questions:[{type:t,name:e}],additionals:n})}function q9(e){return e||8e3}function eJ(e){return e?.replace(/^\[(.*)\]$/,"$1")}function tJ(e){return Gr(e)||_r(e)}function rJ(e,t=M9){if(!e)return t;let r=Number(e);if(!Number.isInteger(r)||r<1||r>65535)throw new Error("\u81EA\u5B9A\u4E49 DNS \u7AEF\u53E3\u53F7\u5E94\u4E3A 1-65535 \u7684\u6574\u6570");return r}function nJ(e,t){if(e.username||e.password||e.pathname&&e.pathname!=="/"||e.search||e.hash)throw new Error(`\u81EA\u5B9A\u4E49 DNS \u5730\u5740\u683C\u5F0F\u65E0\u6548: ${t}`)}function sJ(e,t){try{let r=t?e:`udp://${_r(e)?`[${e}]`:e}`,n=new URL(r);nJ(n,e);let i=eJ(n.hostname);if(!i)throw new Error(`\u81EA\u5B9A\u4E49 DNS \u5730\u5740\u683C\u5F0F\u65E0\u6548: ${e}`);return{protocol:t||"udp",host:i,port:rJ(n.port,t==="tls"?QX:M9)}}catch(r){throw r?.message?.includes("\u81EA\u5B9A\u4E49 DNS")?r:new Error(`\u81EA\u5B9A\u4E49 DNS \u5730\u5740\u683C\u5F0F\u65E0\u6548: ${e}`)}}function iJ(e){let t=`${e||""}`.trim();if(!t)throw new Error("\u81EA\u5B9A\u4E49 DNS \u4E0D\u80FD\u4E3A\u7A7A");if(/^https?:\/\//i.test(t))return{protocol:"doh",url:t};let r=t.match(/^([a-z][a-z\d+.-]*):\/\//i)?.[1],n=r?.toLowerCase();if(n&&!["udp","tcp","tls"].includes(n))throw new Error(`\u81EA\u5B9A\u4E49 DNS \u4E0D\u652F\u6301 ${r} \u534F\u8BAE`);return sJ(t,n)}async function wS({url:e,domain:t,type:r="A",timeout:n,edns:i,skipCertVerify:o}){let s=vS({domain:t,type:r,edns:i}),u=nf.Buffer.from(s).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),l=await H.http.get({url:`${e}?dns=${encodeURIComponent(u)}`,headers:{Accept:"application/dns-message"},"binary-mode":!0,encoding:null,timeout:n,insecure:o===!0});return Uh.default.decode(nf.Buffer.from(H.env.isQX?l.bodyBytes:l.body))}async function oJ({server,domain,type="A",timeout,edns}){let dgram=eval("require('dgram')"),buf=vS({domain,type,edns});return new Promise((e,t)=>{let r=!1,n=dgram.createSocket(_r(server.host)?"udp6":"udp4"),i=setTimeout(()=>{s(new Error("DNS UDP query timeout"))},q9(timeout));function o(){clearTimeout(i),n.removeAllListeners();try{n.close()}catch{}}function s(a,u){r||(r=!0,o(),a?t(a):e(u))}n.on("error",a=>s(a)),n.on("message",a=>{try{s(null,Uh.default.decode(a))}catch(u){s(u)}}),n.send(buf,server.port,server.host,a=>{a&&s(a)})})}async function aJ({server,domain,type="A",timeout,edns,skipCertVerify}){let transport=server.protocol==="tls"?eval("require('tls')"):eval("require('net')"),transportName=server.protocol==="tls"?"TLS":"TCP",payload=vS({domain,type,edns}),length=nf.Buffer.alloc(c0);length.writeUInt16BE(payload.length,0);let request=nf.Buffer.concat([length,payload]);return new Promise((e,t)=>{let r=!1,n=nf.Buffer.alloc(0),i,o=server.protocol==="tls"?transport.connect({host:server.host,port:server.port,servername:tJ(server.host)?void 0:server.host,rejectUnauthorized:skipCertVerify===!0?!1:void 0}):transport.createConnection({host:server.host,port:server.port});function s(){o.removeAllListeners(),o.destroy()}function a(u,l){r||(r=!0,s(),u?t(u):e(l))}o.setTimeout(q9(timeout),()=>{a(new Error(`DNS ${transportName} query timeout`))}),o.on(server.protocol==="tls"?"secureConnect":"connect",()=>{o.write(request)}),o.on("error",u=>a(u)),o.on("end",()=>{a(new Error(`DNS ${transportName} connection ended before response`))}),o.on("data",u=>{try{if(n=nf.Buffer.concat([n,u]),i==null&&n.length>=c0&&(i=n.readUInt16BE(0)),i!=null&&n.length>=i+c0){let l=n.slice(c0,i+c0);a(null,Uh.default.decode(l))}}catch(l){a(l)}})})}async function C2({url:e,domain:t,type:r="A",timeout:n,edns:i,skipCertVerify:o}){let s=`${e||""}`.trim(),a=s.match(/^([a-z][a-z\d+.-]*):\/\//i)?.[1];if(s&&!H.env.isNode&&!/^https?:\/\//i.test(s)&&(!a||["udp","tcp","tls"].includes(a.toLowerCase())))throw new Error("DoT \u548C TCP/UDP DNS \u4EC5\u652F\u6301 Node.js \u73AF\u5883");let u=iJ(e);if(u.protocol==="doh")return wS({url:u.url,domain:t,type:r,timeout:n,edns:i,skipCertVerify:o});if(!H.env.isNode)throw new Error("DoT \u548C TCP/UDP DNS \u4EC5\u652F\u6301 Node.js \u73AF\u5883");return["tcp","tls"].includes(u.protocol)?aJ({server:u,domain:t,type:r,timeout:n,edns:i,skipCertVerify:o}):oJ({server:u,domain:t,type:r,timeout:n,edns:i})}var Mh=B(Tp());var kwe=B(T()),_2="mihomoConfig",uJ="mihomoProfile",cJ=[_2,uJ];function So(e){let t=typeof e=="string"?e:e?.type;return cJ.includes(t)}function j9(e){return So(e)?_2:e}function Hh(e){return!e||!So(e)||e.type===_2?e:{...e,type:_2}}var AS="Response Transformer";function SS(e){return e===AS}function l0(e){return e.startsWith("<")&&e.endsWith(">")?e.slice(1,-1):e}function G9(e,t){let r=typeof t=="string"?JSON.parse(t):t;for(let n in r)if(gt(r[n]))if(n.endsWith("!")){let i=l0(n.slice(0,-1));e[i]=r[n]}else{let i=l0(n);e[i]||Object.assign(e,{[i]:{}}),G9(e[i],r[i])}else if(Array.isArray(r[n]))if(n.startsWith("+")){let i=l0(n.slice(1));e[i]||Object.assign(e,{[i]:[]}),e[i]=[...r[n],...e[i]]}else if(n.endsWith("+")){let i=l0(n.slice(0,-1));e[i]||Object.assign(e,{[i]:[]}),e[i]=[...e[i],...r[n]]}else{let i=l0(n);Object.assign(e,{[i]:r[n]})}else Object.assign(e,{[n]:r[n]});return e}function lJ({rule:e}){return{name:"Conditional Filter",func:t=>t.map(r=>D2(e,r))}}function D2(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=>D2(r,t));case"OR":return e.child.some(r=>D2(r,t));case"NOT":return!D2(e.child,t);default:throw new Error(`Unknown operator: ${e.operator}`)}}function fJ(e){return{name:"Quick Setting Operator",func:i=>{if(t(e.useless)){let s=e7().func(i);i=i.filter((a,u)=>s[u]&&a.port>0&&a.port<=65535)}return i.map(o=>(o.udp=t(e.udp,o.udp),o.tfo=t(e.tfo,o.tfo),o["fast-open"]=t(e.tfo,o["fast-open"]),o["skip-cert-verify"]=t(e.scert,o["skip-cert-verify"]),o.type==="vmess"&&(o.aead=t(e["vmess aead"],o.aead)),["snell","anytls","trusttunnel"].includes(o.type)&&(o.reuse=t(e.reuse,o.reuse)),["tuic","hysteria2"].includes(o.type)&&(o.ecn=t(e.ecn,o.ecn)),o["block-quic"]=r(e["block-quic"],o["block-quic"]),o["ip-version"]=n(e["ip-version"],o["ip-version"]),o))}};function t(i,o){switch(i){case"ENABLED":return!0;case"DISABLED":return!1;default:return o}}function r(i,o){switch(i){case"auto":case"on":case"off":return i;default:return o}}function n(i,o){switch(i){case void 0:case null:case"":case"DEFAULT":return o;default:return i}}}function hJ({mode:e,tw:t}){return{name:"Flag Operator",func:r=>r.map(n=>{if(e==="remove")n.name=a0(n.name);else{let i=Nh(n.name);n.name=a0(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 dJ(e){let{action:t,template:r,link:n,position:i,field:o}={action:"rename",template:"0 1 2 3 4 5 6 7 8 9",link:"-",position:"back",field:["name"],...e};return{name:"Handle Duplicate Operator",func:s=>{if(t==="delete"){let a={};return s.filter(u=>{let l=o.map(f=>Mh.default.get(u,f,"-")).join("_");return a[l]?!1:(a[l]=!0,!0)})}else if(t==="rename"){let a=r.split(" "),u={},l=0;s.forEach(m=>{let p=o.map(d=>Mh.default.get(m,d,"-")).join("_");typeof u[p]>"u"?u[p]=1:u[p]++,l=Math.max(u[p].toString().length,l)});let f={};return s.map(m=>{let p=o.map(d=>Mh.default.get(m,d,"-")).join("_");if(u[p]>1){typeof f[p]>"u"&&(f[p]=1);let d="",v=f[p]++,g=0;for(;v>0;)d=a[v%10]+d,v=parseInt(v/10),g++;for(;g++{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 HJ(t);default:throw new Error("Unknown sort option: "+e)}}}}function mJ(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=>_S(i)),n.sort((i,o)=>{let s=K9(r,i.name),a=K9(r,o.name);return s&&!a?-1:a&&!s?1:s&&a?st.map(r=>{for(let{expr:n,now:i}of e)r.name=r.name.replace(_S(n,"g"),i).trim();return r})}}function gJ(e){let t=e.map(r=>({expr:r,now:""}));return{name:"Regex Delete Operator",func:Y9(t).func}}function vJ(e,t,r,n,i,o){return o.source=n,o.env=aa,{name:"Script Operator",func:async s=>{let a=s;if(So(a?.$file))try{let u=pi.safeLoad(e),l;if(a?.$content)try{l=pi.safeLoad(a?.$content)}catch(f){H.error(f.message??f)}if(typeof u!="object")throw new Error("patch is not an object");return a.$content=rr.yaml.safeDump(G9(l||{},u)),a}catch{}return await async function(){a=qh("operator",e,r,i)(s,t,o)}(),a},nodeFunc:async s=>{let a=s;return await async function(){a=qh("operator",`async function operator(input = [], targetPlatform, context) { if (input && (input.$files || input.$content)) { let { $content, $files, $options, $file } = input if (['mihomoConfig', 'mihomoProfile'].includes($file?.type)) { ${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 || {})) } } 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)(s,t,o)}(),a}}}var W9="Add Proxies From Subscription Operator";function wJ(e){if(!e)return{};let t=pi.safeLoad(e);return gt(t)?t:{}}function yJ(e){return Array.isArray(e?.proxies)?e.proxies:[]}function EJ({sourceType:e="subscription",sourceName:t,includeUnsupportedProxy:r,position:n="replace"}={}){let i=async o=>{if(!So(o?.$file))return o;let s=wJ(o.$content),a=yJ(s),u=await Co({type:e,name:t,platform:"mihomo",produceType:"internal",produceOpts:{"delete-underscore-fields":!0,"include-unsupported-proxy":r}});switch(n){case"front":s.proxies=[...u,...a];break;case"back":s.proxies=[...a,...u];break;case"replace":default:s.proxies=u;break}return o.$content=rr.yaml.safeDump(s),o};return{name:W9,func:i,nodeFunc:i}}function bJ(e){let t,r;try{let n=e.split(":");r=parseInt(n[2],16);let i=parseInt(n[3],16),o=parseInt(n[4],16),s=i>>8,a=i&255,u=o>>8,l=o&255;if(t=`${s}.${a}.${u}.${l}`,r<=0||r>65535)throw new Error(`Invalid port number: ${r}`);if(!Gr(t))throw new Error(`Invalid IP address: ${t}`)}catch(n){H.error(`IP4P \u89E3\u6790\u5931\u8D25: ${n}`)}return{server:t,port:r}}var AJ=10,SJ=2,V9=20;function CJ(e){if(typeof e>"u"||e===null||typeof e=="string"&&e.trim()==="")return AJ;let t=Number(e);if(!Number.isInteger(t)||t<1)throw new Error("\u57DF\u540D\u89E3\u6790\u5E76\u53D1\u6570\u5E94\u4E3A\u5927\u4E8E 0 \u7684\u6574\u6570");return t}function X9(e){if(typeof e>"u"||e===null||typeof e=="string"&&e.trim()==="")return SJ;let t=Number(e);if(!Number.isInteger(t)||t<1)throw new Error("\u591A DNS \u5E76\u53D1\u6570\u5E94\u4E3A\u5927\u4E8E 0 \u7684\u6574\u6570");return t}function _J(e,t){if(!(typeof e>"u"||e===null||typeof e=="string"&&e.trim()==="")){let i=Number(e);if(!Number.isInteger(i)||i<1)throw new Error("DNS \u8D85\u65F6\u5E94\u4E3A\u5927\u4E8E 0 \u7684\u6574\u6570");return i}if(typeof t>"u"||t===null||typeof t=="string"&&t.trim()==="")return 8e3;let n=Number(t);return!isFinite(n)||n<=0?8e3:n}function DJ(e){if(typeof e>"u"||e===null||typeof e=="string"&&e.trim()==="")return;let t=Number(e);if(!Number.isInteger(t)||t<1)throw new Error("\u57DF\u540D\u89E3\u6790\u7F13\u5B58\u65F6\u957F\u5E94\u4E3A\u5927\u4E8E 0 \u7684\u6574\u6570");return t*1e3}function CS(e){let t=`${e||""}`.split(/\r?\n/).map(r=>r.trim()).filter(r=>r);if(t.length===0)throw new Error("\u81EA\u5B9A\u4E49 DNS \u4E0D\u80FD\u4E3A\u7A7A");return t}function FJ(e){return CS(e).join(` `)}async function IJ(e,t,r){let n=0,i=Math.min(t,e.length),o=Array.from({length:i},async()=>{for(;n{let o=0,s=0,a=0,u=!1,l=[],f=Math.min(t,e.length);function m(){!u&&a===e.length&&i(new Error(l.length>0?l.join("; "):"No answers"))}function p(){if(!u){for(;sr(d)).then(v=>{s-=1,a+=1,!u&&(u=!0,n({result:v,resolverUrl:d}))}).catch(v=>{s-=1,a+=1,l.push(`${d}: ${v}`),p(),m()})}m()}}p()})}function bS(e,t,r,n,i){switch(e){case"Custom":return Xr(`CUSTOM:${i?"INSECURE:":""}${n}:${t}:${r}`);case"Google":return Xr(`GOOGLE:${t}:${r}`);case"IP-API":return Xr(`IP-API:${t}`);case"Cloudflare":return Xr(`CLOUDFLARE:${t}:${r}`);case"Ali":return Xr(`ALI:${t}:${r}`);case"Tencent":return Xr(`TENCENT:${t}:${r}`)}}function $J(e,t,r,n,i,o){if(n==="disabled")return null;let s=bS(e,t,r,i,o),a=s?Jr.get(s):null;return e==="Custom"?Z9(a):a}function yS(e,t){if(e!=="Custom"||!t)return"";let r=`${t}`.split(/\r?\n/).map(n=>n.trim()).filter(n=>n);return r.length<=1?` via ${t}`:` via ${r.length} custom DNS`}function TJ(e,t){if(e!=="Custom"||!t)return t||"";let r=`${t}`.split(/\r?\n/).map(n=>n.trim()).filter(n=>n);return r.length<=1?t:`${r.length} custom DNS`}function J9(e,t){return e&&typeof e=="object"&&Object.defineProperty(e,"_resolverUrl",{value:t,enumerable:!1,configurable:!0}),e}function PJ(e,t){return{result:e,resolverUrl:t}}function Z9(e){return e&&typeof e=="object"&&!Array.isArray(e)&&Array.isArray(e.result)?J9(e.result,e.resolverUrl):e}function z9(e){return e&&typeof e=="object"?e._resolverUrl:null}var F2={Custom:async function(e,t,r,n,i,o,s,a,u){let l=CS(o),f=l.join(` `),m=X9(a),p=Xr(`CUSTOM:${s?"INSECURE:":""}${f}:${e}:${t}`),d=Z9(Jr.get(p));if(!r&&d)return d;let v=t==="IPv6"?"AAAA":"A",g=async E=>{let S=await C2({url:E,domain:e,type:v,timeout:n,edns:i,skipCertVerify:s}),{answers:D}=S;if(!Array.isArray(D)||D.length===0)throw new Error("No answers");let F=D.filter(M=>M?.type===v).map(M=>M?.data).filter(M=>M);if(F.length===0)throw new Error("No answers");return F},{result:y,resolverUrl:w}=l.length===1?{result:await g(l[0]),resolverUrl:l[0]}:await BJ(l,m,g);return Jr.set(p,PJ(y,w),u),J9(y,w)},Google:async function(e,t,r,n,i,o,s,a,u){let l=Xr(`GOOGLE:${e}:${t}`),f=Jr.get(l);if(!r&&f)return f;let m=t==="IPv6"?"AAAA":"A",p=await C2({url:"https://8.8.4.4/dns-query",domain:e,type:m,timeout:n,edns:i}),{answers:d}=p;if(!Array.isArray(d)||d.length===0)throw new Error("No answers");let v=d.filter(g=>g?.type===m).map(g=>g?.data).filter(g=>g);if(v.length===0)throw new Error("No answers");return Jr.set(l,v,u),v},"IP-API":async function(e,t,r,n,i,o,s,a,u){if(["IPv6"].includes(t))throw new Error(`\u57DF\u540D\u89E3\u6790\u670D\u52A1\u63D0\u4F9B\u65B9 IP-API \u4E0D\u652F\u6301 ${t}`);let l=Xr(`IP-API:${e}`),f=Jr.get(l);if(!r&&f)return f;let m=await H.http.get({url:`http://ip-api.com/json/${encodeURIComponent(e)}?lang=zh-CN`,timeout:n}),p=JSON.parse(m.body);if(p.status!=="success")throw new Error(`Status is ${p.status}`);if(!p.query||p.query===0)throw new Error("No answers");let d=[p.query];if(d.length===0)throw new Error("No answers");return Jr.set(l,d,u),d},Cloudflare:async function(e,t,r,n,i,o,s,a,u){let l=Xr(`CLOUDFLARE:${e}:${t}`),f=Jr.get(l);if(!r&&f)return f;let m=t==="IPv6"?"AAAA":"A",p=await C2({url:"https://1.0.0.1/dns-query",domain:e,type:m,timeout:n,edns:i}),{answers:d}=p;if(!Array.isArray(d)||d.length===0)throw new Error("No answers");let v=d.filter(g=>g?.type===m).map(g=>g?.data).filter(g=>g);if(v.length===0)throw new Error("No answers");return Jr.set(l,v,u),v},Ali:async function(e,t,r,n,i,o,s,a,u){let l=Xr(`ALI:${e}:${t}`),f=Jr.get(l);if(!r&&f)return f;let m=await H.http.get({url:`http://223.6.6.6/resolve?edns_client_subnet=${i}/${Gr(i)?24:56}&name=${encodeURIComponent(e)}&type=${t==="IPv6"?"AAAA":"A"}&short=1`,headers:{accept:"application/dns-json"},timeout:n}),p=JSON.parse(m.body);if(!Array.isArray(p)||p.length===0)throw new Error("No answers");let d=p;if(d.length===0)throw new Error("No answers");return Jr.set(l,d,u),d},Tencent:async function(e,t,r,n,i,o,s,a,u){let l=Xr(`TENCENT:${e}:${t}`),f=Jr.get(l);if(!r&&f)return f;let p=(await H.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(p.length===0||String(p)==="0")throw new Error("No answers");let d=p;if(d.length===0)throw new Error("No answers");return Jr.set(l,d,u),d}};function Q9({provider:e,type:t,filter:r,cache:n,url:i,tlsSkipCertVerify:o,timeout:s,cacheTtl:a,edns:u,concurrency:l,dnsConcurrency:f}){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:m}=H.read(Bt)||{},p=_J(s,m),d=DJ(a),v=["IPv6","IP4P"].includes(t)?"IPv6":"IPv4",g=F2[e];if(!g)throw new Error(`\u627E\u4E0D\u5230\u57DF\u540D\u89E3\u6790\u670D\u52A1\u63D0\u4F9B\u65B9: ${e}`);let y=u||"223.6.6.6";if(!sf(y))throw new Error("\u57DF\u540D\u89E3\u6790 EDNS \u5E94\u4E3A IP");let w=CJ(l),E=e==="Custom"?FJ(i):i,S=e==="Custom"?CS(E).length:1,D=e==="Custom"?X9(f):1,F=w*Math.min(D,S),M=e==="Custom"&&(o===!0||o==="enabled");return F>V9&&H.warn(`\u57DF\u540D\u89E3\u6790\u603B\u5E76\u53D1\u6570\u4E0A\u9650 ${F} \u8D85\u8FC7\u5EFA\u8BAE\u503C ${V9}, \u53EF\u80FD\u5BFC\u81F4\u4EE3\u7406 App TCP \u8FDE\u63A5\u6570\u6FC0\u589E`),H.info(`Domain Resolver: [${t}] ${e} ${y||""} ${TJ(e,E)}${M?" tlsSkipCertVerify=enabled":""} concurrency=${w}${e==="Custom"?` dnsConcurrency=${D}`:""}`),{name:"Resolve Domain Operator",func:async z=>{z.forEach((k,O)=>{!k["_no-resolve"]&&k["no-resolve"]&&(z[O]["_no-resolve"]=k["no-resolve"])});let C={},P=[...new Map(z.filter(k=>!sf(k.server)&&!k["_no-resolve"]).map(k=>{let O=bS(e,k.server,v,E,M);return[O,{id:O,domain:k.server}]})).values()],U=[];return P.forEach(({id:k,domain:O})=>{let q=$J(e,O,v,n,E,M);if(q){C[k]=q;let N=e==="Custom"&&z9(q)||E;H.info(`Using cached resolved domain: ${O}${yS(e,N)} \u279F ${q}`)}else U.push({id:k,domain:O})}),await IJ(U,w,async({id:k,domain:O})=>{try{let q=await g(O,v,n==="disabled",p,y,E,M,D,d);C[k]=q;let N=e==="Custom"&&z9(q)||E;H.info(`Successfully resolved domain: ${O}${yS(e,N)} \u279F ${q}`)}catch(q){H.error(`Failed to resolve domain: ${O}${yS(e,E)} with resolver [${e}]: ${q}`)}}),z.forEach(k=>{if(!k["_no-resolve"]){let O=bS(e,k.server,v,E,M);if(O&&C[O]){k._resolved_ips=C[O];let q=Array.isArray(C[O])?C[O][Math.floor(Math.random()*C[O].length)]:C[O];if(v==="IPv6"&&_r(q)){try{q=new nm.Address6(q).correctForm()}catch(N){H.error(`Failed to parse IPv6 address: ${q}: ${N}`)}if(/^2001::[^:]+:[^:]+:[^:]+$/.test(q)){k._IP4P=q;let{server:N,port:_}=bJ(q);N&&_?(k._domain=k.server,k.server=N,k.port=_,k.resolved=!0,k._IPv4=k.server,sf(k._IP)||(k._IP=k.server)):k.resolved||(k.resolved=!1)}else k._domain=k.server,k.server=q,k.resolved=!0,k[`_${v}`]=k.server,sf(k._IP)||(k._IP=k.server)}else k._domain=k.server,k.server=q,k.resolved=!0,k[`_${v}`]=k.server,sf(k._IP)||(k._IP=k.server)}else k.resolved||(k.resolved=!1)}}),z.filter(k=>r==="removeFailed"?sf(k.server)||k["_no-resolve"]||k.resolved:r==="IPOnly"?sf(k.server):r==="IPv4Only"?Gr(k.server):r==="IPv6Only"?_r(k.server):!0)}}}function sf(e){return Gr(e)||_r(e)}Q9.resolver=F2;function ES(e){var t=/^[\x00-\x7F]+$/;return t.test(e)}function e7(){return{name:"Useless Filter",func:e=>e.map(t=>{if(t.cipher&&!ES(t.cipher))return!1;if(t.password&&!ES(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&&!ES(n)))return!1}return!/网址|流量|时间|应急|过期|Bandwidth|expire/.test(t.name)})}}function xJ(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(o=>{let s=Nh(o.name),a=t.some(u=>n[u]===s);return r?a:!a})}}function RJ({regex:e=[],keep:t=!0}){return{name:"Regex Filter",func:r=>r.map(n=>{let i=e.some(o=>_S(o).test(n.name));return t?i:!i})}}function _S(e,...t){return t=t.join(""),e.startsWith("(?i)")?(e=e.substring(4),new RegExp(e,"i"+t)):new RegExp(e,t)}function kJ(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 o=t.some(s=>i.type===s);return r?o:!o})}}function OJ(e,t,r,n,i,o){return o.source=n,o.env=aa,{name:"Script Filter",func:async s=>{let a=E2(s.length,!0);return await async function(){a=qh("filter",e,r,i)(s,t,o)}(),a},nodeFunc:async s=>{let a=E2(s.length,!0);return await async function(){a=qh("filter",`async function filter(input = [], targetPlatform, context) { 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)(s,t,o)}(),a}}}function NJ(e,t,r,n,i,o){return o.source=n,o.env=aa,{name:AS,func:async s=>{let a=s;return await async function(){a=qh("transformFunction",e,r,i)(s,o)}(),a},shortcutFunc:async s=>{let a=s;return await async function(){a=qh("transformFunction",`async function transformFunction(res = {}, context) { let $res = res ${e} return $res }`,r,i)(s,o)}(),a}}}var f0={"Useless Filter":e7,"Region Filter":xJ,"Regex Filter":RJ,"Type Filter":kJ,"Script Filter":OJ,"Conditional Filter":lJ,"Quick Setting Operator":fJ,"Flag Operator":hJ,"Sort Operator":pJ,"Regex Sort Operator":mJ,"Regex Rename Operator":Y9,"Regex Delete Operator":gJ,"Script Operator":vJ,[W9]:EJ,[AS]:NJ,"Handle Duplicate Operator":dJ,"Resolve Domain Operator":Q9};async function t7(e,t){let r=t;try{let n=await e.func(r);n&&(r=n)}catch(n){let i="",o=`${n.message??n}`;o.includes("$res is not defined")||(H.error(`Cannot apply ${e.name}(function transformFunction)! Reason: ${n}`),i=`\u6267\u884C function transformFunction \u5931\u8D25 ${o}; `);try{let s=await e.shortcutFunc(r);s&&(r=s)}catch(s){H.error(`Cannot apply ${e.name}(shortcut script)! Reason: ${s}`);let a="",u=`${s.message??s}`;throw i&&u===o?(a="",i=`\u6267\u884C\u5931\u8D25 ${o}`):a=`\u6267\u884C\u5FEB\u6377\u811A\u672C\u5931\u8D25 ${u}`,new Error(`\u54CD\u5E94\u4FEE\u6539 ${i}${a}`)}}return r}async function LJ(e,t){let r=E2(t.length,!0);try{r=await e.func(t)}catch(n){let i="",o=`${n.message??n}`;o.includes("$server is not defined")?i="":(H.error(`Cannot apply filter ${e.name}(function filter)! Reason: ${n}`),i=`\u6267\u884C function filter \u5931\u8D25 ${o}; `);try{r=await e.nodeFunc(t)}catch(s){H.error(`Cannot apply filter ${e.name}(shortcut script)! Reason: ${s}`);let a="",u=`${s.message??s}`;throw i&&u===o?(a="",i=`\u6267\u884C\u5931\u8D25 ${o}`):a=`\u6267\u884C\u5FEB\u6377\u8FC7\u6EE4\u811A\u672C \u5931\u8D25 ${u}`,new Error(`\u811A\u672C\u8FC7\u6EE4 ${i}${a}`)}}return t.filter((n,i)=>r[i])}async function UJ(e,t){let r=MJ(t);try{let n=await e.func(r);n&&(r=n)}catch(n){let i="",o=`${n.message??n}`;o.includes("$server is not defined")||o.includes("$content is not defined")||o.includes("$files is not defined")||r?.$files||r?.$content?i="":(H.error(`Cannot apply operator ${e.name}(function operator)! Reason: ${n}`),i=`\u6267\u884C function operator \u5931\u8D25 ${o}; `);try{let s=await e.nodeFunc(r);s&&(r=s)}catch(s){H.error(`Cannot apply operator ${e.name}(shortcut script)! Reason: ${s}`);let a="",u=`${s.message??s}`;throw i&&u===o?(a="",i=`\u6267\u884C\u5931\u8D25 ${o}`):a=`\u6267\u884C\u5FEB\u6377\u811A\u672C \u5931\u8D25 ${u}`,new Error(`\u811A\u672C\u64CD\u4F5C ${i}${a}`)}}return r}async function r7(e,t){if(e.name.indexOf("Filter")!==-1)return LJ(e,t);if(e.name.indexOf("Operator")!==-1)return UJ(e,t)}function HJ(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 MJ(e){return JSON.parse(JSON.stringify(e))}function qh(name,script,$arguments,$options){let flowUtils={getFlowField:zl,getFlowHeaders:ia,parseFlowHeaders:mu,flowTransfer:Bp,validCheck:hg,getRmainingDays:dg,normalizeFlowHeader:pg};return H.env.isLoon?new Function("$arguments","$options","$substore","lodash","$persistentStore","$httpClient","$notification","ProxyUtils","yaml","Buffer","b64d","b64e","DOMAIN_RESOLVERS","scriptResourceCache","flowUtils","produceArtifact","require",`${script} return ${name}`)($arguments,$options,H,Mh.default,$persistentStore,$httpClient,$notification,rr,rr.yaml,rr.Buffer,rr.Base64.decode,rr.Base64.encode,F2,Pp,flowUtils,Co,eval('typeof require !== "undefined"')?Iw:void 0):new Function("$arguments","$options","$substore","lodash","ProxyUtils","yaml","Buffer","b64d","b64e","DOMAIN_RESOLVERS","scriptResourceCache","flowUtils","produceArtifact","require",`${script} return ${name}`)($arguments,$options,H,Mh.default,rr,rr.yaml,rr.Buffer,rr.Base64.decode,rr.Base64.encode,F2,Pp,flowUtils,Co,eval('typeof require !== "undefined"')?Iw:void 0)}var nbe=B(T());var hye=B(T());var sye=B(T()),i7=B(Tp());var pt=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){pe(this.proxy,r)&&this.append(t)}toString(){return this.output.join("")}};function pe(e,t){let r=i7.default.get(e,t);return typeof r<"u"&&r!==null}function jh(e){let t=typeof e?.network=="string"?e.network.trim().toLowerCase():e?.network;return e?.type==="ss"&&e?.tls===!0&&!pe(e,"plugin")&&(!pe(e,"network")||t==="tcp")}function h0(e){if(typeof e=="boolean")return Number(e);if(typeof e=="string"){let t=e.trim().toLowerCase();if(t==="true")return 1;if(t==="false")return 0;if(/^\d+$/.test(t))return parseInt(t,10)}return e}function o7(e){return!!h0(e)}function Kh(e,t){if(e?.type!=="ss"||e?.plugin!=="v2ray-plugin")return!0;let r=typeof e?.["plugin-opts"]?.mode=="string"?e["plugin-opts"].mode.trim().toLowerCase():e?.["plugin-opts"]?.mode;return t.includes(r)}function n7(e,t){if(e?.plugin!=="shadow-tls"||!e["plugin-opts"])return;let r=e["plugin-opts"],n=!!r.password||r.version!=null&&Number(r.version)!==0;return e["shadow-tls-opts"]={password:r.password,version:r.version},r.host!=null&&(e[t]=r.host),r.alpn!=null&&(e.alpn=r.alpn),delete e.plugin,delete e["plugin-opts"],n}function I2(e){if(["vmess","vless","trojan","anytls"].includes(e.type)&&n7(e,"sni")&&["vmess","vless"].includes(e.type)&&(e.tls=!0),e.type==="vless"&&e.network==="xhttp"){let t=e["xhttp-opts"]?.["download-settings"];n7(t,"servername")&&(t.tls=!0)}}function DS(e,t){if(e==null)return;let r=`${e}`.trim();if(!/^\d+$/.test(r))return;let n=parseInt(r,10);if(!(n<0||n>t))return n}function a7(e,t){if(e==null)return null;let r=`${e}`.trim();if(!r)return null;let[,n=r,i]=/^(.*?)(?:\/(\d+))?$/.exec(r)||[],o=`${n}`.trim().replace(/^\[/,"").replace(/\]$/,""),s=t==="ipv4";return(s?Gr(o):_r(o))?{address:o,cidr:DS(i,s?32:128)}:null}function s7(e,t){let{addressKey:r,cidrKey:n,family:i,defaultCIDR:o}=t,s=a7(e[r],i);if(!s){(e[r]==null||`${e[r]}`.trim().length===0)&&delete e[n];return}e[r]=s.address;let a=DS(e[n],o);e[n]=a??s.cidr??o}function FS(e={}){return s7(e,{addressKey:"ip",cidrKey:"ip-cidr",family:"ipv4",defaultCIDR:32}),s7(e,{addressKey:"ipv6",cidrKey:"ipv6-cidr",family:"ipv6",defaultCIDR:128}),e}function ti(e={},t="ipv4"){let r=t==="ipv6"?{addressKey:"ipv6",cidrKey:"ipv6-cidr",defaultCIDR:128}:{addressKey:"ip",cidrKey:"ip-cidr",defaultCIDR:32},n=a7(e[r.addressKey],t);if(!n)return;let i=DS(e[r.cidrKey],r.defaultCIDR);return`${n.address}/${i??n.cidr??r.defaultCIDR}`}function _a(e,t,r={}){return t==="internal"?e:r.prettyYaml||r["pretty-yaml"]?Qp(pi.safeDump({proxies:e},{lineWidth:-1})):`proxies: `+e.map(n=>" - "+JSON.stringify(n)+` `).join("")}var oye=B(T()),B2="auto",qJ=[B2,"none","zero","aes-128-gcm","chacha20-poly1305"],jJ=[B2,"aes-128-gcm","chacha20-poly1305","none"],KJ=["none","chacha20-poly1305"],VJ={"chacha20-ietf-poly1305":"chacha20-poly1305"};function u7(e){return e==null?"":`${e}`.trim().toLowerCase()}function IS(e){return VJ[e]||e}function jn(e,t=qJ,{acceptAliases:r=!0,fallback:n=B2}={}){let i=u7(e);if(!i)return n;let o=t.map(u7);if(o.includes(i))return IS(i);let s=IS(i),a=o.map(IS);return r&&a.includes(s)?s:n}function d0(e){return jn(e,jJ)}function c7(e){return jn(e,KJ,{fallback:"chacha20-poly1305"})}function l7(e){let t=d0(e);return t==="chacha20-poly1305"?"chacha20-ietf-poly1305":t}function f7(e){let t=jn(e,["aes-128-gcm","chacha20-poly1305"]);if(t!==B2)return t==="chacha20-poly1305"?"chacha20-ietf-poly1305":t}var $2="Surge",Vh=class extends Error{constructor(t){super(t),this.name="SurgeUnsupportedProxyError"}};function Ou(e){return new Vh(e)}var ks={dual:"dual",ipv4:"v4-only",ipv6:"v6-only","ipv4-prefer":"prefer-v4","ipv6-prefer":"prefer-v6"};function T2(e){if(typeof e!="string")return e;let t=e.trim(),r=t[0];return(r==='"'||r==="'")&&t[t.length-1]===r?t.slice(1,-1):t}function zh(e){return`"${String(T2(e))}"`}function P2(e){return e!=null&&`${e}`.trim().length>0}function h7(e){return(Array.isArray(e)?e:T2(`${e||""}`).split(",")).filter(r=>r!=null).map(r=>String(T2(r)).trim()).filter(r=>r!=="").join(",")}function zJ(e,t){let r=h7(t.alpn);r&&e.append(`,alpn="${r}"`)}function GJ(e){return h7(e?.["plugin-opts"]?.alpn??e?.alpn)}function _o(e,t,r=!1){if(t.plugin!=="shadow-tls"||!t["plugin-opts"])return;let n=t["plugin-opts"].password,i=t["plugin-opts"].host,o=t["plugin-opts"].version;if(!n)return;if(e.append(`,shadow-tls-password="${n}"`),i&&e.append(`,shadow-tls-sni=${i}`),o){if(o<2)throw Ou(`shadow-tls version ${o} is not supported`);e.append(`,shadow-tls-version=${o}`)}let s=GJ(t);s&&e.append(`,alpn="${s}"`),r&&e.appendIfPresent(`,udp-port=${t["udp-port"]}`,"udp-port")}function Nu(e,t,r=!0){if(!r)return;e.appendIfPresent(`,server-cert-fingerprint-sha256=${t["tls-fingerprint"]}`,"tls-fingerprint"),e.appendIfPresent(`,sni="${t.sni}"`,"sni"),e.appendIfPresent(`,server-cert-verify-name=${zh(t["name-cert-verify"])}`,"name-cert-verify"),t.plugin!=="shadow-tls"&&zJ(e,t),e.appendIfPresent(`,skip-cert-verify=${t["skip-cert-verify"]}`,"skip-cert-verify");let n=pe(t,"keystore-client-cert")?t["keystore-client-cert"]:t["client-cert"];(pe(t,"keystore-client-cert")||pe(t,"client-cert"))&&e.append(`,client-cert=${zh(n)}`)}function YJ(e,t){let r=pe(t,"keystore-private-key")?t["keystore-private-key"]:t["private-key"];(pe(t,"keystore-private-key")||pe(t,"private-key"))&&e.append(`,private-key=${zh(r)}`)}function d7(e){if(!pe(e,"max-streams"))return;let t=Number(T2(e["max-streams"]));!Number.isInteger(t)||t<=3||H.warn(`Surge ${e.type} proxy ${e.name}: max-streams=${t} is greater than 3. Too many streams sharing one TCP connection may hurt performance.`)}function WJ(e){return pe(e,"obfs-opts.mode")||pe(e,"obfs-opts.host")||pe(e,"obfs-opts.path")}function XJ(e){return Number(e.version)===6&&WJ(e)}function Gh(){return{produce:(t,r,n={})=>{if(["ws"].includes(t.network)&&t["ws-opts"]?.["v2ray-http-upgrade"])throw Ou(`Platform ${$2} does not support network ${t.network} with http upgrade`);switch(t.name=t.name.replace(/=|,/g,""),t.ports&&(t.ports=String(t.ports)),t.type){case"ss":return JJ(t);case"trojan":return ZJ(t);case"vmess":return rZ(t,n["include-unsupported-proxy"]);case"http":return sZ(t);case"h2-connect":return tZ(t);case"direct":return iZ(t);case"socks5":return oZ(t);case"snell":return uZ(t);case"tuic":return cZ(t);case"wireguard-surge":return fZ(t);case"hysteria2":return hZ(t);case"ssh":return nZ(t);case"trusttunnel":return eZ(t)}if(n["include-unsupported-proxy"]&&t.type==="wireguard")return lZ(t);if(t.type==="anytls"){if(t.network&&(!["tcp"].includes(t.network)||["tcp"].includes(t.network)&&t["reality-opts"]))throw Ou(`Platform ${$2} does not support proxy type ${t.type} with network or REALITY`);return QJ(t)}throw Ou(`Platform ${$2} does not support proxy type: ${t.type}`)}}}function JJ(e){let t=new pt(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 Ou(`cipher ${e.cipher} is not supported`);t.append(`,encrypt-method=${e.cipher}`),t.appendIfPresent(`,password="${e.password}"`,"password");let r=ks[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"),pe(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 Ou(`plugin ${e.plugin} is not supported`)}return 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(`,interface=${e.interface}`,"interface"),_o(t,e,!0),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function ZJ(e){let t=new pt(e);t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password="${e.password}"`,"password");let r=ks[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"),m7(t,e),t.appendIfPresent(`,tls=${e.tls}`,"tls"),Nu(t,e),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(`,interface=${e.interface}`,"interface"),_o(t,e),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function QJ(e){let t=new pt(e);t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password="${e.password}"`,"password");let r=ks[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"),Nu(t,e),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(`,interface=${e.interface}`,"interface"),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 eZ(e){let t=new pt(e);t.append(`${e.name}=trust-tunnel,${e.server},${e.port}`),t.appendIfPresent(`,username="${e.username}"`,"username"),t.appendIfPresent(`,password="${e.password}"`,"password"),BS(t,e),d7(e),t.appendIfPresent(`,max-streams=${e["max-streams"]}`,"max-streams");let r=ks[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"),Nu(t,e),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(`,interface=${e.interface}`,"interface"),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 tZ(e){let t=new pt(e);t.append(`${e.name}=h2-connect,${e.server},${e.port}`),t.appendIfPresent(`,username="${e.username}"`,"username"),t.appendIfPresent(`,password="${e.password}"`,"password"),BS(t,e),d7(e),t.appendIfPresent(`,max-streams=${e["max-streams"]}`,"max-streams");let r=ks[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"),Nu(t,e),e.tfo&&H.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"),t.appendIfPresent(`,interface=${e.interface}`,"interface"),_o(t,e),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function rZ(e,t){let r=new pt(e);r.append(`${e.name}=${e.type},${e.server},${e.port}`),r.appendIfPresent(`,username=${e.uuid}`,"uuid");let n=f7(e.cipher);n&&r.append(`,encrypt-method=${n}`);let i=ks[e["ip-version"]]||e["ip-version"];return r.appendIfPresent(`,ip-version=${i}`,"ip-version"),r.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),m7(r,e,t),pe(e,"aead")?r.append(`,vmess-aead=${e.aead}`):r.append(`,vmess-aead=${e.alterId===0}`),r.appendIfPresent(`,tls=${e.tls}`,"tls"),Nu(r,e,!!e.tls),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"),r.appendIfPresent(`,interface=${e.interface}`,"interface"),_o(r,e),r.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),r.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),r.toString()}function nZ(e){let t=new pt(e);t.append(`${e.name}=ssh,${e.server},${e.port}`),t.appendIfPresent(`,username="${e.username}"`,"username"),t.appendIfPresent(`,password="${e.password}"`,"password"),YJ(t,e),t.appendIfPresent(`,idle-timeout=${e["idle-timeout"]}`,"idle-timeout"),t.appendIfPresent(`,server-fingerprint="${e["server-fingerprint"]}"`,"server-fingerprint");let r=ks[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(`,interface=${e.interface}`,"interface"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function sZ(e){let t=new pt(e),r=e.tls?"https":"http";t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,username="${e.username}"`,"username"),t.appendIfPresent(`,password="${e.password}"`,"password"),BS(t,e);let n=ks[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"),Nu(t,e,!!e.tls),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(`,interface=${e.interface}`,"interface"),_o(t,e),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function iZ(e){let t=new pt(e),r="direct";t.append(`${e.name}=${r}`);let n=ks[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(`,interface=${e.interface}`,"interface"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function oZ(e){let t=new pt(e),r=e.tls?"socks5-tls":"socks5";t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,username="${e.username}"`,"username"),t.appendIfPresent(`,password="${e.password}"`,"password");let n=ks[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"),Nu(t,e,!!e.tls),e.tfo&&H.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"),t.appendIfPresent(`,interface=${e.interface}`,"interface"),_o(t,e),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function BS(e,t){let r=aZ(t.headers);nt(r)&&e.append(`,headers=${zh(r)}`)}function aZ(e){return p7(e,";")}function p7(e,t){return!e||typeof e!="object"?"":Object.entries(e).filter(([r,n])=>nt(r)&&n!=null).map(([r,n])=>`${r}:${zh(n)}`).join(t)}function uZ(e){if(XJ(e))return H.error(`Platform ${$2} does not support Snell version ${e.version} with obfs`),"";let t=new pt(e);t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,version=${e.version}`,"version"),t.appendIfPresent(`,psk="${e.psk}"`,"psk"),Number(e.version)===6&&t.appendIfPresent(`,mode=${e.mode}`,"mode");let r=ks[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"),t.appendIfPresent(`,interface=${e.interface}`,"interface"),_o(t,e),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 cZ(e){let t=new pt(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"),P2(e.ports)&&t.append(`,port-hopping="${String(e.ports).replace(/,/g,";")}"`),P2(e["hop-interval"])&&t.append(`,port-hopping-interval=${e["hop-interval"]}`);let n=ks[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"),Nu(t,e),pe(e,"tfo")?t.append(`,tfo=${e.tfo}`):pe(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"),t.appendIfPresent(`,interface=${e.interface}`,"interface"),_o(t,e),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 lZ(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 pt(e);t.append(`# > WireGuard Proxy ${e.name} # ${e.name}=wireguard`),e["section-name"]=Vt(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=ks[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"),t.appendIfPresent(`,interface=${e.interface}`,"interface"),_o(t,e),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,o=e["preshared-key"]??e["pre-shared-key"],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":o};return t.append(` peer = (${Object.keys(s).filter(a=>s[a]!=null).map(a=>`${a} = ${s[a]}`).join(", ")})`),t.toString()}function fZ(e){let t=new pt(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=ks[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"),t.appendIfPresent(`,interface=${e.interface}`,"interface"),_o(t,e),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function hZ(e){let t={salamander:"salamander-password",gecko:"gecko-password"}[e.obfs];if(e["obfs-password"]&&!t)throw Ou("only salamander and gecko obfs are supported");let r=new pt(e);r.append(`${e.name}=hysteria2,${e.server},${e.port}`),r.appendIfPresent(`,password="${e.password}"`,"password"),P2(e.ports)&&r.append(`,port-hopping="${String(e.ports).replace(/,/g,";")}"`),P2(e["hop-interval"])&&r.append(`,port-hopping-interval=${e["hop-interval"]}`),e["obfs-password"]&&t&&r.append(`,${t}="${e["obfs-password"]}"`);let n=ks[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"),Nu(r,e),pe(e,"tfo")?r.append(`,tfo=${e.tfo}`):pe(e,"fast-open")&&r.append(`,tfo=${e["fast-open"]}`),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"),r.appendIfPresent(`,interface=${e.interface}`,"interface"),_o(r,e),r.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),r.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),r.appendIfPresent(`,download-bandwidth=${`${e.down}`.match(/\d+/)?.[0]||0}`,"down"),r.appendIfPresent(`,ecn=${e.ecn}`,"ecn"),r.toString()}function m7(e,t,r){if(pe(t,"network"))if(t.network==="ws"){if(e.append(",ws=true"),pe(t,"ws-opts")&&(e.appendIfPresent(`,ws-path=${t["ws-opts"].path}`,"ws-opts.path"),pe(t,"ws-opts.headers"))){let n=t["ws-opts"].headers,i=p7(n,"|");nt(i)&&e.append(`,ws-headers=${zh(i)}`)}}else if(r&&["http"].includes(t.network))H.info(`Include Unsupported Proxy: network ${t.network} -> tcp`);else{if(["tcp"].includes(t.network)&&t["reality-opts"])throw Ou("reality is unsupported");if(!["tcp"].includes(t.network))throw Ou(`network ${t.network} is unsupported`)}}var xye=B(T());var _ye=B(T());var pye=B(T());function $S(e){try{return decodeURIComponent(`${e}`.replace(/\+/g,"%20"))}catch{return e}}function g7(e){let t=e.indexOf("=");return t===-1?{key:$S(e),value:""}:{key:$S(e.slice(0,t)),value:$S(e.slice(t+1))}}function Lu(e){if(!/^\d+$/.test(`${e}`))return null;let t=parseInt(`${e}`,10);return Number.isSafeInteger(t)?t:null}function ri(e,t){let r=e==null?"":`${e}`,n=r.indexOf("?");if(n===-1)return{path:r,value:""};let i=r.slice(0,n),o=r.slice(n+1),s=[],a="";for(let u of o.split("&")){if(u==="")continue;let l=g7(u);if(l.key===t){a===""&&l.value!==""&&(a=l.value);continue}s.push(u)}return{path:s.length>0?`${i}?${s.join("&")}`:i,value:a}}function p0(e,t){let r=e==null?"":`${e}`,n=r.indexOf("?");if(n===-1)return"";let i=r.slice(n+1);for(let o of i.split("&")){if(o==="")continue;let s=g7(o);if(s.key===t&&s.value!=="")return s.value}return""}function TS(e,t){let r=p0(e,t),n=Lu(r);return n==null?{value:"",parsed:null}:{value:r,parsed:n}}function dZ(e,t,r){let n=e.includes("?")?e.endsWith("?")||e.endsWith("&")?"":"&":"?";return`${e}${n}${encodeURIComponent(t)}=${encodeURIComponent(`${r}`)}`}function PS(e,t,r){let n=e==null||e===""?"/":`${e}`,{path:i}=ri(n,t);return dZ(i,t,r)}function kc(e){let t=e?.path;if(!e)return;let{value:r,parsed:n}=TS(t,"ed");if(e["v2ray-http-upgrade"]){r!==""&&(e.path=ri(t,"ed").path,e["v2ray-http-upgrade-fast-open"]=!0,(e["_v2ray-http-upgrade-ed"]==null||`${e["_v2ray-http-upgrade-ed"]}`=="")&&(e["_v2ray-http-upgrade-ed"]=r)),delete e["early-data-header-name"],delete e["max-early-data"];return}r!==""&&(e.path=ri(t,"ed").path,e["early-data-header-name"]==null&&(e["early-data-header-name"]="Sec-WebSocket-Protocol"),e["max-early-data"]==null&&(e["max-early-data"]=n))}function Oc(e){e&&delete e["_v2ray-http-upgrade-ed"]}var vye=B(T());var of="_dns",xS="_force-query",RS="_sockopt",v7="https://dns.alidns.com/dns-query";function w7(e){if(!nt(e))return;if(!e.includes("://"))return{type:"config",config:e};let t=e.split("+");if(t.length===1&&nt(t[0]))return{type:"dns",dns:t[0]};if(t.length===2&&nt(t[0])&&nt(t[1]))return{type:"dns",queryServerName:t[0],dns:t[1]}}function kS(e){return w7(e)!=null}function x2(e){return["none","half","full"].includes(e)}function pZ(e){return typeof e=="boolean"?e:typeof e=="number"&&Number.isInteger(e)&&e!==0}function R2({echConfigList:e,echForceQuery:t,echSockopt:r}={}){let n=w7(e);if(!n)return;let i={enable:!0};return n.type==="config"?i.config=n.config:(i[of]=n.dns,n.queryServerName&&(i["query-server-name"]=n.queryServerName)),x2(t)&&(i[xS]=t),gt(r)&&(i[RS]=r),i}function OS(e,t,{dnsFieldPath:r="ech-opts._dns",warnDefaultDns:n}={}){let i={};if(gt(e)){if(!pZ(e.enable))return i;let o=e["query-server-name"];return nt(e.config)?i.echConfigList=e.config:nt(e[of])?i.echConfigList=nt(o)?`${o}+${e[of]}`:e[of]:nt(o)&&(i.echConfigList=`${o}+${v7}`,n?.({defaultDns:v7,dnsFieldPath:r,queryServerName:o})),i.echConfigList&&x2(e[xS])&&(i.echForceQuery=e[xS]),i.echConfigList&>(e[RS])&&(i.echSockopt=e[RS]),i}return nt(t)&&(i.echConfigList=t),i}function NS(e,t,r){return OS(e,t,r).echConfigList}var mZ={dual:"dual","v4-only":"ipv4","v6-only":"ipv6","prefer-v4":"ipv4-prefer","prefer-v6":"ipv6-prefer"};function y7(e,t,r){if(!gt(t)||!nt(t[of]))return;let n=nt(t["query-server-name"])?t["query-server-name"]:"\u8FD9\u91CC\u662F query-server-name";H.warn(`mihomo \u4E0D\u652F\u6301\u5728 ech-opts \u4E2D\u914D\u7F6E ECH DNS. \u5982\u9700\u8DDF\u8282\u70B9 ECH \u914D\u7F6E\u4E00\u81F4, \u8BF7\u5728 mihomo \u914D\u7F6E\u6587\u4EF6\u91CC\u8BBE\u7F6E dns["nameserver-policy"]["${n}"] = ["${t[of]}"].`)}function gZ(e,t){t!=="internal"&&(y7(e,e["ech-opts"],"ech-opts"),y7(e,e["xhttp-opts"]?.["download-settings"]?.["ech-opts"],"xhttp-opts.download-settings.ech-opts"))}function wi(){return{type:"ALL",produce:(r,n,i={})=>{let o=r.filter(s=>{if(i["include-unsupported-proxy"])return!0;if(s.type==="h2-connect")return H.error(`mihomo does not support HTTP/2 CONNECT proxy type. Proxy ${s.name} has been filtered.`),!1;if(vZ(s)&&s.type==="trusttunnel")return H.error(`mihomo does not support headers for TrustTunnel proxy ${s.name}. Proxy has been filtered.`),!1;if(Kh(s,["websocket"])){if(s.type==="snell"&&!LS(s.version,[1,2,3,4,5]))return!1;if(E7(s)&&(!["ss","snell","vmess","vless","trojan","anytls"].includes(s.type)||!LS(b7(s),["ss","snell"].includes(s.type)?[1,2,3]:[0,1,2,3])))return!1;if(s.type==="vless"&&s.network==="xhttp"&&E7(s["xhttp-opts"]?.["download-settings"])&&!LS(b7(s["xhttp-opts"]["download-settings"]),[0,1,2,3]))return!1;if(wZ(s))return H.error(`Platform Mihomo does not support Snell shadow-tls with obfs for proxy ${s.name}. Proxy has been filtered.`),!1;if(["juicity","naive"].includes(s.type))return!1;if(["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))return!1;if(["anytls"].includes(s.type)&&s.network&&(!["tcp"].includes(s.network)||["tcp"].includes(s.network)&&s["reality-opts"]))return!1;if(!["vless"].includes(s.type)&&["xhttp"].includes(s.network))return!1}else return!1;return!0}).map(s=>{if(gZ(s,n),I2(s),s["reality-opts"]&&!s["client-fingerprint"]&&(s["client-fingerprint"]="chrome"),s.type==="vmess")pe(s,"aead")&&(s.aead&&(s.alterId=0),delete s.aead),pe(s,"sni")&&(s.servername=s.sni,delete s.sni),s.cipher=jn(s.cipher);else if(s.type==="tuic")pe(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),pe(s,"tfo")&&!pe(s,"fast-open")&&(s["fast-open"]=s.tfo),(!s.token||s.token.length===0)&&!pe(s,"version")&&(s.version=5);else if(s.type==="hysteria")pe(s,"auth_str")&&!pe(s,"auth-str")&&(s["auth-str"]=s.auth_str),pe(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),pe(s,"tfo")&&!pe(s,"fast-open")&&(s["fast-open"]=s.tfo);else if(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.ip=ti(s,"ipv4"),s.ipv6=ti(s,"ipv6");else if(s.type==="snell"&&s.version<3)delete s.udp;else if(s.type==="vless"){if(pe(s,"sni")&&(s.servername=s.sni,delete s.sni),s.network==="xhttp"&&s["xhttp-opts"]?.["download-settings"]){let a=s["xhttp-opts"]["download-settings"];s.tls&&a.tls&&s["reality-opts"]&&!a["reality-opts"]&&(a["reality-opts"]={"public-key":""})}}else["anytls"].includes(s.type)&&s.reuse!=null&&!s.reuse&&(s["disable-reuse"]=!0,delete s.reuse);if(pe(s,"plugin-opts.mux")&&(s["plugin-opts"].mux=o7(s["plugin-opts"].mux)),s.type==="snell"){let a=US(s);a&&(s["obfs-opts"]={mode:"shadow-tls",host:a.host,password:a.password,version:a.version},a.alpn&&(s["obfs-opts"].alpn=a.alpn),delete s.plugin,delete s["plugin-opts"])}if(["vmess","vless"].includes(s.type)&&s.network==="http"){let a=s["http-opts"]?.path;pe(s,"http-opts.path")&&!Array.isArray(a)&&(s["http-opts"].path=[a]);let u=s["http-opts"]?.headers?.Host;pe(s,"http-opts.headers.Host")&&!Array.isArray(u)&&(s["http-opts"].headers.Host=[u])}if(["vmess","vless"].includes(s.type)&&s.network==="h2"){let a=s["h2-opts"]?.path;pe(s,"h2-opts.path")&&Array.isArray(a)&&(s["h2-opts"].path=a[0]);let u=s["h2-opts"]?.host??s["h2-opts"]?.headers?.host??s["h2-opts"]?.headers?.Host;(pe(s,"h2-opts.host")||pe(s,"h2-opts.headers.host")||pe(s,"h2-opts.headers.Host"))&&(s["h2-opts"].host=Array.isArray(u)?u:[u]),s["h2-opts"]?.headers&&(delete s["h2-opts"].headers.host,delete s["h2-opts"].headers.Host,Object.keys(s["h2-opts"].headers).length===0&&delete s["h2-opts"].headers)}if(["ws"].includes(s.network)){let a=`${s.network}-opts`;s[a]=s[a]||{},s[a].path||(s[a].path="/"),kc(s[a])}if(s["plugin-opts"]?.tls&&pe(s,"skip-cert-verify")&&(s["plugin-opts"]["skip-cert-verify"]=s["plugin-opts"]["skip-cert-verify"]||s["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls","trusttunnel","naive","masque","shadowquic"].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"],pe(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"],delete s["ip-cidr"],delete s["ipv6-cidr"],n!=="internal"||i["delete-underscore-fields"]){for(let a in s)(s[a]==null||/^_/i.test(a))&&delete s[a];Oc(s[`${s.network}-opts`])}return["grpc"].includes(s.network)&&s[`${s.network}-opts`]&&(delete s[`${s.network}-opts`]["_grpc-type"],delete s[`${s.network}-opts`]["_grpc-authority"]),s["ip-version"]&&(s["ip-version"]=mZ[s["ip-version"]]||s["ip-version"]),s});return _a(o,n,i)}}}function vZ(e){return e?.headers&&typeof e.headers=="object"&&Object.keys(e.headers).length>0}function LS(e,t){if(e==null)return!0;let r=typeof e=="string"?e.trim():`${e}`;if(!r)return!1;let n=Number(r);return Number.isInteger(n)&&t.includes(n)}function E7(e){return!!US(e)}function wZ(e){return e?.type==="snell"&&e?.plugin==="shadow-tls"&&(pe(e,"obfs-opts.mode")||pe(e,"obfs-opts.host")||pe(e,"obfs-opts.path"))}function b7(e){return US(e)?.version}function US(e){if(e?.plugin==="shadow-tls"&&e?.["plugin-opts"])return e["plugin-opts"];if(e?.type==="snell"&&e?.["obfs-opts"]?.mode==="shadow-tls")return e["obfs-opts"]}var S7="SurgeMac",C7=Gh();function m0(){return{produce:(t,r,n={})=>{switch(t.type){case"external":return _7(t);default:{if(n.mihomoExternal||t._mihomoExternal)return A7(t,r,n)||"";try{return C7.produce(t,r,n)}catch(i){if(n.useMihomoExternal&&i instanceof Vh){let o=A7(t,r,n)||"";if(!o)throw i;return H.log(`${t.name} is not supported on ${S7}, try to use mihomo(SurgeMac - External Proxy Program) instead`),o}throw i instanceof Vh?new Error(`${i.message}. 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`):i}}}}}}function _7(e){let t=new pt(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"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),pe(e,"tfo")?t.append(`,tfo=${e.tfo}`):pe(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 A7(e,t,r){let n=wi().produce([e],"internal")?.[0];if(n){let i=r?.localPort||e._localPort||65535,o=!["ipv4","v4-only"].includes(e["ip-version"]),s={enable:!0,ipv6:o,"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"]},a=r?.merge||e._merge,u;if(a){let l={name:e.name,type:"socks5",server:"127.0.0.1",port:i,udp:!0};u=C7.produce(l,"socks5",r),r._merged=r._merged||{name:r?.mergeName||e._mergeName||"mihomo merged",exec:r?.exec||e._exec||"/usr/local/bin/mihomo",config:{ipv6:o,mode:"global",dns:s,proxies:[],"proxy-groups":[{name:"GLOBAL",type:"fallback",proxies:[]}],listeners:[]}};let f=`${i}`;r._merged.config.listeners.push({name:`socks5-${i}`,type:"socks",port:i,listen:"127.0.0.1",udp:!0,proxy:f}),r._merged.config["proxy-groups"][0].proxies.push(f),r._merged.config.proxies.push({...n,name:f}),r._merged.config={...r._merged.config,...r?.config||e._config||{}}}else{let l={name:e.name,type:"external",udp:!0,exec:r?.exec||e._exec||"/usr/local/bin/mihomo","local-port":i,args:["-config",_t.encode(JSON.stringify({"mixed-port":i,ipv6:o,mode:"global",dns:s,proxies:[{...n,name:"proxy"}],"proxy-groups":[{name:"GLOBAL",type:"select",proxies:["proxy"]}],...r?.config||e._config||{}}))],addresses:[]};yZ(e.server)?l.addresses.push(e.server):H.warn(`Platform ${S7}, proxy type ${e.type}: addresses should be an IP address, but got ${e.server}`),u=_7(l)}return r.localPort=i-1,u}}function yZ(e){return Gr(e)||_r(e)}var Uye=B(T());function HS(){return{type:"ALL",produce:(r,n,i={})=>{let o=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"&&s.version>=4||s.type==="vless"&&(typeof s.flow<"u"||s["reality-opts"])||["ws"].includes(s.network)&&s["ws-opts"]?.["v2ray-http-upgrade"]?!1:s["underlying-proxy"]||s["dialer-proxy"]?(H.error(`Clash \u4E0D\u652F\u6301\u524D\u7F6E\u4EE3\u7406\u5B57\u6BB5. \u5DF2\u8FC7\u6EE4\u8282\u70B9 ${s.name}`),!1):!0).map(s=>{if(s.type==="vmess"?(pe(s,"aead")&&(s.aead&&(s.alterId=0),delete s.aead),pe(s,"sni")&&(s.servername=s.sni,delete s.sni),s.cipher=d0(s.cipher)):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"&&pe(s,"sni")&&(s.servername=s.sni,delete s.sni),["vmess","vless"].includes(s.type)&&s.network==="http"){let a=s["http-opts"]?.path;pe(s,"http-opts.path")&&!Array.isArray(a)&&(s["http-opts"].path=[a]);let u=s["http-opts"]?.headers?.Host;pe(s,"http-opts.headers.Host")&&!Array.isArray(u)&&(s["http-opts"].headers.Host=[u])}if(["vmess","vless"].includes(s.type)&&s.network==="h2"){let a=s["h2-opts"]?.path;pe(s,"h2-opts.path")&&Array.isArray(a)&&(s["h2-opts"].path=a[0]);let u=s["h2-opts"]?.host??s["h2-opts"]?.headers?.host??s["h2-opts"]?.headers?.Host;(pe(s,"h2-opts.host")||pe(s,"h2-opts.headers.host")||pe(s,"h2-opts.headers.Host"))&&(s["h2-opts"].host=Array.isArray(u)?u:[u]),s["h2-opts"]?.headers&&(delete s["h2-opts"].headers.host,delete s["h2-opts"].headers.Host,Object.keys(s["h2-opts"].headers).length===0&&delete s["h2-opts"].headers)}if(["ws"].includes(s.network)){let a=`${s.network}-opts`;s[a]=s[a]||{},s[a].path||(s[a].path="/"),kc(s[a])}if(s["plugin-opts"]?.tls&&pe(s,"skip-cert-verify")&&(s["plugin-opts"]["skip-cert-verify"]=s["plugin-opts"]["skip-cert-verify"]||s["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls","trusttunnel","naive"].includes(s.type)&&delete s.tls,s["tls-fingerprint"]&&(s.fingerprint=s["tls-fingerprint"]),delete s["tls-fingerprint"],pe(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"],delete s["ip-cidr"],delete s["ipv6-cidr"],n!=="internal"){for(let a in s)(s[a]==null||/^_/i.test(a))&&delete s[a];Oc(s[`${s.network}-opts`])}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 _a(o,n,i)}}}var zye=B(T());function k2(){return{type:"ALL",produce:(r,n,i={})=>{let o=r.filter(s=>{if(i["include-unsupported-proxy"])return!0;if(!["ss","ssr","vmess","socks5","http","snell","trojan","tuic","vless","wireguard","hysteria","hysteria2","ssh","juicity","anytls","tailscale","trusttunnel"].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"&&s.version>=4)return!1;if(Kh(s,["websocket"])){if(["vless"].includes(s.type)&&s["reality-opts"]&&s.network&&!["tcp"].includes(s.network))return!1;if(["anytls"].includes(s.type)&&s.network&&(!["tcp"].includes(s.network)||["tcp"].includes(s.network)&&s["reality-opts"]))return!1;if(["xhttp"].includes(s.network))return!1;if(s.encryption&&s.encryption!=="none"&&["vless"].includes(s.type))return!1;if(["ws"].includes(s.network)&&s["ws-opts"]?.["v2ray-http-upgrade"])return!1}else return!1;return!0}).map(s=>{if(s.type==="vmess"?(pe(s,"aead")&&(s.aead&&(s.alterId=0),delete s.aead),pe(s,"sni")&&(s.servername=s.sni,delete s.sni),s.cipher=d0(s.cipher)):s.type==="tuic"?(pe(s,"alpn")?s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]:s.alpn=["h3"],pe(s,"tfo")&&!pe(s,"fast-open")&&(s["fast-open"]=s.tfo,delete s.tfo),(!s.token||s.token.length===0)&&!pe(s,"version")&&(s.version=5)):s.type==="hysteria"?(pe(s,"auth_str")&&!pe(s,"auth-str")&&(s["auth-str"]=s.auth_str),pe(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),pe(s,"tfo")&&!pe(s,"fast-open")&&(s["fast-open"]=s.tfo,delete s.tfo),pe(s,"down")&&!pe(s,"down-speed")&&(s["down-speed"]=s.down,delete s.down),pe(s,"up")&&!pe(s,"up-speed")&&(s["up-speed"]=s.up,delete s.up),pe(s,"down-speed")&&(s["down-speed"]=`${s["down-speed"]}`.match(/\d+/)?.[0]||0),pe(s,"up-speed")&&(s["up-speed"]=`${s["up-speed"]}`.match(/\d+/)?.[0]||0)):s.type==="hysteria2"?(pe(s,"password")&&!pe(s,"auth")&&(s.auth=s.password,delete s.password),pe(s,"tfo")&&!pe(s,"fast-open")&&(s["fast-open"]=s.tfo,delete s.tfo),pe(s,"down")&&!pe(s,"down-speed")&&(s["down-speed"]=s.down,delete s.down),pe(s,"up")&&!pe(s,"up-speed")&&(s["up-speed"]=s.up,delete s.up),pe(s,"down-speed")&&(s["down-speed"]=`${s["down-speed"]}`.match(/\d+/)?.[0]||0),pe(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"&&pe(s,"sni")&&(s.servername=s.sni,delete s.sni),["vmess","vless"].includes(s.type)&&s.network==="http"){let a=s["http-opts"]?.path;pe(s,"http-opts.path")&&!Array.isArray(a)&&(s["http-opts"].path=[a]);let u=s["http-opts"]?.headers?.Host;pe(s,"http-opts.headers.Host")&&!Array.isArray(u)&&(s["http-opts"].headers.Host=[u])}if(["vmess","vless"].includes(s.type)&&s.network==="h2"){let a=s["h2-opts"]?.path;pe(s,"h2-opts.path")&&Array.isArray(a)&&(s["h2-opts"].path=a[0]);let u=s["h2-opts"]?.host??s["h2-opts"]?.headers?.host??s["h2-opts"]?.headers?.Host;(pe(s,"h2-opts.host")||pe(s,"h2-opts.headers.host")||pe(s,"h2-opts.headers.Host"))&&(s["h2-opts"].host=Array.isArray(u)?u:[u]),s["h2-opts"]?.headers&&(delete s["h2-opts"].headers.host,delete s["h2-opts"].headers.Host,Object.keys(s["h2-opts"].headers).length===0&&delete s["h2-opts"].headers)}if(["ws"].includes(s.network)){let a=`${s.network}-opts`;s[a]=s[a]||{},s[a].path||(s[a].path="/"),kc(s[a])}if(s["plugin-opts"]?.tls&&pe(s,"skip-cert-verify")&&(s["plugin-opts"]["skip-cert-verify"]=s["plugin-opts"]["skip-cert-verify"]||s["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls","trusttunnel","naive"].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"],pe(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"],delete s["ip-cidr"],delete s["ipv6-cidr"],n!=="internal"){for(let a in s)(s[a]==null||/^_/i.test(a))&&delete s[a];Oc(s[`${s.network}-opts`])}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 _a(o,n,i)}}}var Zye=B(T());var g0="Loon",Da={dual:"dual",ipv4:"v4-only",ipv6:"v6-only","ipv4-prefer":"prefer-v4","ipv6-prefer":"prefer-v6"};function MS(){return{produce:(t,r,n={})=>{if(["ws"].includes(t.network)&&t["ws-opts"]?.["v2ray-http-upgrade"])throw new Error(`Platform ${g0} does not support network ${t.network} with http upgrade`);switch(t.type){case"ss":return SZ(t);case"ssr":return CZ(t);case"trojan":return _Z(t);case"vmess":return FZ(t,n["include-unsupported-proxy"]);case"vless":return IZ(t,n["include-unsupported-proxy"]);case"http":return BZ(t);case"socks5":return $Z(t);case"wireguard":return TZ(t);case"hysteria2":return PZ(t)}if(t.type==="anytls"){if(t.network&&!["tcp"].includes(t.network))throw new Error(`Platform ${g0} does not support proxy type ${t.type} with network ${t.network}`);return DZ(t)}throw new Error(`Platform ${g0} does not support proxy type: ${t.type}`)}}}function Nc(e,t){let r=AZ(t);r&&e.append(`,tls-profile=${r}`)}function af(e,t){let r=bZ(t);r&&e.append(`,alpn="${r}"`)}function EZ(e){let t=e?.["plugin-opts"]?.alpn??e?.alpn;return(Array.isArray(t)?t:`${t||""}`.split(",")).map(n=>`${n}`.trim()).filter(n=>n!=="").join(",")}function D7(e,t){if(t.plugin!=="shadow-tls"||!t["plugin-opts"])return;let r=t["plugin-opts"].password,n=t["plugin-opts"].host,i=t["plugin-opts"].version;if(!r)return;if(e.append(`,shadow-tls-password=${r}`),n&&e.append(`,shadow-tls-sni=${n}`),i){if(i<2)throw new Error(`shadow-tls version ${i} is not supported`);e.append(`,shadow-tls-version=${i}`)}Nc(e,t);let o=EZ(t);o&&e.append(`,alpn="${o}"`),e.appendIfPresent(`,udp-port=${t["udp-port"]}`,"udp-port")}function O2(e,t){e.appendIfPresent(`,sni=${t.sni}`,"sni"),e.appendIfPresent(`,public-key="${t["reality-opts"]["public-key"]}"`,"reality-opts.public-key"),e.appendIfPresent(`,short-id=${t["reality-opts"]["short-id"]}`,"reality-opts.short-id")}function bZ(e){return(Array.isArray(e.alpn)?e.alpn:`${e.alpn||""}`.split(",")).map(r=>`${r}`.trim()).filter(r=>r!=="").join(",")}function AZ(e){let t=`${e._loon_tls_profile||""}`.trim();if(["default","chrome","ios18","ios26"].includes(t))return t;switch(`${e["client-fingerprint"]||""}`.trim()){case"chrome":return"chrome";case"ios":return"ios26"}}function SZ(e){let t=new pt(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}"`),pe(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`)}D7(t,e),e["udp-over-tcp"]&&(e["udp-over-tcp-version"]===2?e.plugin==="obfs"?H.error(`Platform ${g0} shadowsocks udp-over-tcp does not support obfs`):t.append(",udp-over-tcp=true"):H.error(`Platform ${g0} shadowsocks only supports udp-over-tcp-version 2`)),t.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e["block-quic"]==="on"?t.append(",block-quic=true"):e["block-quic"]==="off"&&t.append(",block-quic=false"),e.udp&&t.append(",udp=true");let r=Da[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function CZ(e){let t=new pt(e);t.append(`${e.name}=shadowsocksr,${e.server},${e.port},${e.cipher},"${e.password}"`),t.append(`,protocol=${e.protocol}`),t.appendIfPresent(`,protocol-param=${e["protocol-param"]}`,"protocol-param"),t.appendIfPresent(`,obfs=${e.obfs}`,"obfs"),t.appendIfPresent(`,obfs-param=${e["obfs-param"]}`,"obfs-param"),D7(t,e),t.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e["block-quic"]==="on"?t.append(",block-quic=true"):e["block-quic"]==="off"&&t.append(",block-quic=false"),e.udp&&t.append(",udp=true");let r=Da[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function _Z(e){let t=!!e["reality-opts"],r=new pt(e);if(r.append(`${e.name}=trojan,${e.server},${e.port},"${e.password}"`),e.network==="tcp"&&delete e.network,pe(e,"network"))if(e.network==="ws")r.append(",transport=ws"),r.appendIfPresent(`,path=${e["ws-opts"]?.path}`,"ws-opts.path"),r.appendIfPresent(`,host=${e["ws-opts"]?.headers?.Host}`,"ws-opts.headers.Host");else throw new Error(`network ${e.network} is unsupported`);r.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),Nc(r,e),af(r,e),t?O2(r,e):(r.appendIfPresent(`,tls-name=${e.sni}`,"sni"),r.appendIfPresent(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),r.appendIfPresent(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256")),r.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e["block-quic"]==="on"?r.append(",block-quic=true"):e["block-quic"]==="off"&&r.append(",block-quic=false"),e.udp&&r.append(",udp=true");let n=Da[e["ip-version"]]||e["ip-version"];return r.appendIfPresent(`,ip-mode=${n}`,"ip-version"),r.toString()}function DZ(e){let t=!!e["reality-opts"],r=new pt(e);r.append(`${e.name}=anytls,${e.server},${e.port},"${e.password}"`);for(let i of["idle-session-timeout","max-stream-count"])pe(e,i)&&Number.isInteger(e[i])&&r.append(`,${i}=${e[i]}`);r.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),Nc(r,e),af(r,e),t?O2(r,e):(r.appendIfPresent(`,tls-name=${e.sni}`,"sni"),r.appendIfPresent(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),r.appendIfPresent(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256")),r.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e["block-quic"]==="on"?r.append(",block-quic=true"):e["block-quic"]==="off"&&r.append(",block-quic=false"),e.udp&&r.append(",udp=true");let n=Da[e["ip-version"]]||e["ip-version"];return r.appendIfPresent(`,ip-mode=${n}`,"ip-version"),r.toString()}function FZ(e){let t=!!e["reality-opts"],r=l7(e.cipher),n=new pt(e);if(n.append(`${e.name}=vmess,${e.server},${e.port},${r},"${e.uuid}"`),e.network==="tcp"&&delete e.network,pe(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 o=e["http-opts"]?.path,s=e["http-opts"]?.headers?.Host;n.appendIfPresent(`,path=${Array.isArray(o)?o[0]:o}`,"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"),(e.tls||t)&&(Nc(n,e),af(n,e)),t?O2(n,e):(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")),pe(e,"aead")?n.append(`,alterId=${e.aead?0:1}`):n.append(`,alterId=${e.alterId}`),n.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e["block-quic"]==="on"?n.append(",block-quic=true"):e["block-quic"]==="off"&&n.append(",block-quic=false"),e.udp&&n.append(",udp=true");let i=Da[e["ip-version"]]||e["ip-version"];return n.appendIfPresent(`,ip-mode=${i}`,"ip-version"),n.toString()}function IZ(e){if(e.encryption&&e.encryption!=="none")throw new Error("VLESS encryption is not supported");let t=!1,r=!!e["reality-opts"];if(typeof e.flow<"u")if(["xtls-rprx-vision"].includes(e.flow))t=!0;else throw new Error(`VLESS flow(${e.flow}) is not supported`);let n=new pt(e);if(n.append(`${e.name}=vless,${e.server},${e.port},"${e.uuid}"`),e.network==="tcp"&&delete e.network,pe(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 o=e["http-opts"]?.path,s=e["http-opts"]?.headers?.Host;n.appendIfPresent(`,path=${Array.isArray(o)?o[0]:o}`,"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"),(e.tls||r||t)&&(Nc(n,e),af(n,e)),t&&n.appendIfPresent(`,flow=${e.flow}`,"flow"),r?O2(n,e):(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")),n.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e["block-quic"]==="on"?n.append(",block-quic=true"):e["block-quic"]==="off"&&n.append(",block-quic=false"),e.udp&&n.append(",udp=true");let i=Da[e["ip-version"]]||e["ip-version"];return n.appendIfPresent(`,ip-mode=${i}`,"ip-version"),n.toString()}function BZ(e){let t=new pt(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"),e.tls&&(Nc(t,e),af(t,e)),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),e["block-quic"]==="on"?t.append(",block-quic=true"):e["block-quic"]==="off"&&t.append(",block-quic=false");let n=Da[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${n}`,"ip-version"),t.toString()}function $Z(e){let t=new pt(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"),e.tls&&(Nc(t,e),af(t,e)),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),e["block-quic"]==="on"?t.append(",block-quic=true"):e["block-quic"]==="off"&&t.append(",block-quic=false"),e.udp&&t.append(",udp=true");let r=Da[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function TZ(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 pt(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(a=>_r(a));let s=e.dns.find(a=>Gr(a));s||(s=e.dns.find(a=>!Gr(a)&&!_r(a))),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 o=Da[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${o}`,"ip-version"),e["block-quic"]==="on"?t.append(",block-quic=true"):e["block-quic"]==="off"&&t.append(",block-quic=false"),t.toString()}function PZ(e){if(e["obfs-password"]&&e.obfs!="salamander")throw new Error("only salamander obfs is supported");let t=new pt(e);t.append(`${e.name}=Hysteria2,${e.server},${e.port}`),t.appendIfPresent(`,"${e.password}"`,"password"),pe(e,"ports")&&`${e.ports}`.trim().length>0&&t.append(`,server-ports="${e.ports}"`),pe(e,"hop-interval")&&`${e["hop-interval"]}`.trim().length>0&&t.append(`,hop-interval=${e["hop-interval"]}`),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"),Nc(t,e),af(t,e),e["obfs-password"]&&e.obfs=="salamander"&&t.append(`,salamander-password=${e["obfs-password"]}`),t.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e["block-quic"]==="on"?t.append(",block-quic=true"):e["block-quic"]==="off"&&t.append(",block-quic=false"),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=Da[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}var lEe=B(T());var eEe=B(T());function qS(e,{allowZeroLowerBound:t=!0,allowZeroUpperBound:r=!0}={}){if(typeof e!="string"&&typeof e!="number")return;let n=f=>{let m=f.trim();if(!/^\+?\d+$/.test(m))return;let p=parseInt(m,10);return Number.isSafeInteger(p)?p:void 0},o=`${e}`.trim().split("-"),s=t?0:1,a=r?0:1;if(o.length===1){let f=n(o[0]),m=Math.max(s,a);return f>=m?{lowerBound:f,upperBound:f}:void 0}if(o.length!==2)return;let u=n(o[0]),l=n(o[1]);if(!(u==null||l==null))return u>=s&&l>=a&&l>=u?{lowerBound:u,upperBound:l}:void 0}function xZ(e){return qS(e,{allowZeroUpperBound:!1})}function F7(e){return qS(e,{allowZeroLowerBound:!1,allowZeroUpperBound:!1})}function v0(e){let t=xZ(e);if(!t)return;let{lowerBound:r,upperBound:n}=t;return r===n?n:`${r}-${n}`}function Yh(e){let t=F7(e);if(!t)return;let{lowerBound:r,upperBound:n}=t;return r===n?`${n}`:`${r}-${n}`}function w0(e){let t=F7(e);if(!t)return;let{lowerBound:r,upperBound:n}=t;return r===n?n:`${r}-${n}`}function Lc(e){let t=qS(e);if(!t)return;let{lowerBound:r,upperBound:n}=t;return r===n?n:`${r}-${n}`}function Uc(e,{allowNegative:t=!0}={}){if(typeof e=="number"&&Number.isFinite(e)&&Number.isSafeInteger(e))return!t&&e<0?void 0:e;if(typeof e!="string")return;let r=e.trim();if(!(t?/^[+-]?\d+$/:/^\+?\d+$/).test(r))return;let i=parseInt(r,10);if(Number.isSafeInteger(i)&&!(!t&&i<0))return i}function RZ(e,{excludeHost:t=!1}={}){if(!gt(e))return;let r={};for(let[n,i]of Object.entries(e))typeof i=="string"&&(t&&/^host$/i.test(n)||(r[n]=i));return Object.keys(r).length>0?r:void 0}function kZ(e,t){let r=L2(e?.["_v2ray-http-upgrade-ed"]);if(r!=="")return r;let n=L2(ri(t||"/","ed").value);return n!==""?n:2560}function N2(e,t){return t?.["v2ray-http-upgrade-fast-open"]?PS(e||"/","ed",kZ(t,e)):e}function jS(e,t){let r=t?.["max-early-data"],n=L2(r);if(n==="")return r!=null&&`${r}`!=""?e==null?e:ri(e,"ed").path:e;let i=t?.["early-data-header-name"];return i&&i!=="Sec-WebSocket-Protocol"?e==null?e:ri(e,"ed").path:PS(e||"/","ed",n)}function L2(e){return e==null||`${e}`==""||Lu(e)==null?"":`${e}`}function OZ(e){return Uc(e)}function NZ(e){return Lc(e)}function B7({defaultDns:e,dnsFieldPath:t,echOptsPath:r,proxyName:n,queryServerName:i}){let o=n||"\u672A\u547D\u540D\u8282\u70B9";H.warn(`URI ECH: \u8282\u70B9 "${o}" \u7684 ${r} \u5DF2\u5F00\u542F\u4E14\u8BBE\u7F6E query-server-name="${i}", \u4F46\u672A\u8BBE\u7F6E ${t}; \u5DF2\u4F7F\u7528\u9ED8\u8BA4 DNS ${e}. \u5982\u9700\u81EA\u5B9A\u4E49, \u8BF7\u8BBE\u7F6E ${t}.`)}function U2(e,t={}){return e==="h2"?t.host??t.headers?.host??t.headers?.Host:e==="xhttp"?t.host??t.headers?.Host??t.headers?.host:t.headers?.Host??t.headers?.host??t.host}function LZ(e){if(!gt(e))return;let t={},r={"max-connections":"maxConnections","max-concurrency":"maxConcurrency","c-max-reuse-times":"cMaxReuseTimes","h-max-request-times":"hMaxRequestTimes","h-max-reusable-secs":"hMaxReusableSecs"};for(let[i,o]of Object.entries(r)){let s=Lc(e[i]);s!=null&&(t[o]=typeof s=="number"?`${s}`:s)}let n=OZ(e["h-keep-alive-period"]);return n!=null&&(t.hKeepAlivePeriod=n),Object.keys(t).length>0?t:void 0}function $7(e,t,{excludeHostHeader:r=!0,xmuxTarget:n="root"}={}){if(!gt(e)||!gt(t))return;let i=RZ(t.headers,{excludeHost:r});if(i&&(e.headers=i),t["no-grpc-header"]===!0&&(e.noGRPCHeader=!0),t["x-padding-bytes"]&&(e.xPaddingBytes=t["x-padding-bytes"]),t["x-padding-obfs-mode"]===!0&&(e.xPaddingObfsMode=!0),t["x-padding-key"]&&(e.xPaddingKey=t["x-padding-key"]),t["x-padding-header"]&&(e.xPaddingHeader=t["x-padding-header"]),t["x-padding-placement"]&&(e.xPaddingPlacement=t["x-padding-placement"]),t["x-padding-method"]&&(e.xPaddingMethod=t["x-padding-method"]),t["uplink-http-method"]&&(e.uplinkHTTPMethod=t["uplink-http-method"]),t["session-placement"]&&(e.sessionIDPlacement=t["session-placement"]),t["session-key"]&&(e.sessionIDKey=t["session-key"]),typeof t["session-table"]=="string"&&(e.sessionIDTable=t["session-table"]),t["session-length"]!=null){let a=w0(t["session-length"]);a!=null&&(e.sessionIDLength=a)}t["seq-placement"]&&(e.seqPlacement=t["seq-placement"]),t["seq-key"]&&(e.seqKey=t["seq-key"]),t["uplink-data-placement"]&&(e.uplinkDataPlacement=t["uplink-data-placement"]),t["uplink-data-key"]&&(e.uplinkDataKey=t["uplink-data-key"]);let o=NZ(t["uplink-chunk-size"]);if(o!=null&&(e.uplinkChunkSize=o),t["sc-max-each-post-bytes"]!=null){let a=w0(t["sc-max-each-post-bytes"]);a!=null&&(e.scMaxEachPostBytes=a)}if(t["sc-min-posts-interval-ms"]!=null){let a=v0(t["sc-min-posts-interval-ms"]);a!=null&&(e.scMinPostsIntervalMs=a)}let s=LZ(t["reuse-settings"]);s&&(n==="extra"?e.extra={...gt(e.extra)?e.extra:{},xmux:s}:e.xmux=s)}function UZ(e,t={},r={}){if(!gt(e))return;let n=typeof e.network=="string"?e.network.toLowerCase():"",i=n==="xhttp"||n==="splithttp"?"xhttp":void 0,o={};e.server&&(o.address=e.server);let s=Uc(e.port,{allowNegative:!1});s!=null&&(o.port=s);let a=gt(e["reality-opts"])?e["reality-opts"]:void 0;a?o.security="reality":e.tls&&(o.security="tls");let u={};e.servername&&(u.serverName=e.servername),e["client-fingerprint"]&&(u.fingerprint=e["client-fingerprint"]),e["skip-cert-verify"]&&(u.allowInsecure=!0),e.alpn&&(u.alpn=Array.isArray(e.alpn)?e.alpn:[e.alpn]);let l=OS(e["ech-opts"],void 0,{dnsFieldPath:"xhttp-opts.download-settings.ech-opts._dns",warnDefaultDns:v=>B7({...v,echOptsPath:"xhttp-opts.download-settings.ech-opts",proxyName:r.name})});if(l.echConfigList&&(u.echConfigList=l.echConfigList),l.echForceQuery&&(u.echForceQuery=l.echForceQuery),l.echSockopt&&(u.echSockopt=Hc(l.echSockopt)),Object.keys(u).length>0&&(o.tlsSettings=u),a){let v={};e.servername&&(v.serverName=e.servername),e["client-fingerprint"]&&(v.fingerprint=e["client-fingerprint"]),a["public-key"]&&(v.publicKey=a["public-key"]),a["short-id"]&&(v.shortId=a["short-id"]),Object.keys(v).length>0&&(o.realitySettings=v)}let f={},m=e.path??t.path;m&&(f.path=m);let p=U2("xhttp",e)??U2("xhttp",t);p&&(f.host=p);let d=e.mode??t.mode;if(d&&(f.mode=d),$7(f,e,{excludeHostHeader:!0,xmuxTarget:"extra"}),Object.keys(f).length>0&&(o.xhttpSettings=f),!(Object.keys(o).length===0&&i==null))return{...o.address!=null?{address:o.address}:{},network:i||"xhttp",...o.port!=null?{port:o.port}:{},...o.security!=null?{security:o.security}:{},...o.tlsSettings!=null?{tlsSettings:o.tlsSettings}:{},...o.realitySettings!=null?{realitySettings:o.realitySettings}:{},...o.xhttpSettings!=null?{xhttpSettings:o.xhttpSettings}:{}}}function HZ(e){let t=e["xhttp-opts"]||{},r={};$7(r,t,{excludeHostHeader:!0,xmuxTarget:"root"});let n=UZ(t["download-settings"],t,e);return n&&(r.downloadSettings=n),Object.keys(r).length>0?r:void 0}function Hc(e){if(Array.isArray(e))return e.map(Hc);if(gt(e)){let t={};for(let[r,n]of Object.entries(e))t[r]=Hc(n);return t}return e}function MZ(e,t){return e==null?Hc(t):Array.isArray(e)||Array.isArray(t)?Hc(e):gt(e)&>(t)?T7(e,t):Hc(e)}function T7(e,t){let r=gt(e)?Hc(e):{};if(!gt(t))return r;for(let[n,i]of Object.entries(t)){if(!Object.prototype.hasOwnProperty.call(r,n)){r[n]=Hc(i);continue}r[n]=MZ(r[n],i)}return r}function qZ(e){if(typeof e._extra=="string")return e._extra;if(gt(e._extra))return JSON.stringify(e._extra)}function jZ(e){let t=qZ(e);if(t!=null)return t;if(e.network!=="xhttp")return e._extra||"";let r=HZ(e),n=T7(r,e._extra_unsupported);return Object.keys(n).length>0?JSON.stringify(n):""}function I7(e){let t="none",r=e["reality-opts"],n="",i="",o="";if(r){t="reality";let K=e["reality-opts"]?.["public-key"];K&&(i=`&pbk=${encodeURIComponent(K)}`);let Z=e["reality-opts"]?.["short-id"];Z&&(n=`&sid=${encodeURIComponent(Z)}`);let Y=e["reality-opts"]?.["_spider-x"];Y&&(o=`&spx=${encodeURIComponent(Y)}`)}else e.tls&&(t="tls");let s="";e.alpn&&(s=`&alpn=${encodeURIComponent(Array.isArray(e.alpn)?e.alpn:e.alpn.join(","))}`);let a="";e["skip-cert-verify"]&&(a="&allowInsecure=1");let u="";e._h2&&(u="&h2=1");let l="";e["tls-fingerprint"]&&(l=`&pcs=${encodeURIComponent(e["tls-fingerprint"])}`);let f="",m=Array.isArray(e._vcn)?e._vcn.join(","):e["name-cert-verify"];(Array.isArray(e._vcn)||m)&&(f=`&vcn=${encodeURIComponent(m)}`);let p="",d=NS(e["ech-opts"],e._echConfigList,{dnsFieldPath:"ech-opts._dns",warnDefaultDns:K=>B7({...K,echOptsPath:"ech-opts",proxyName:e.name})});d&&(p=`&ech=${encodeURIComponent(d)}`);let v="";e.sni&&(v=`&sni=${encodeURIComponent(e.sni)}`);let g="";e["client-fingerprint"]&&(g=`&fp=${encodeURIComponent(e["client-fingerprint"])}`);let y="";e.flow&&(y=`&flow=${encodeURIComponent(e.flow)}`);let w="",E=jZ(e);E&&(w=`&extra=${encodeURIComponent(E)}`);let S="";["xhttp"].includes(e.network)&&e[`${e.network}-opts`]?.mode?S=`&mode=${encodeURIComponent(e[`${e.network}-opts`].mode)}`:e._mode&&(S=`&mode=${encodeURIComponent(e._mode)}`);let D="";e._pqv&&(D=`&pqv=${encodeURIComponent(e._pqv)}`);let F="";e.encryption&&(F=`&encryption=${encodeURIComponent(e.encryption)}`);let M=e.network;e.network==="ws"&&e["ws-opts"]?.["v2ray-http-upgrade"]?M="httpupgrade":e.network==="http"?M="tcp":e.network==="h2"&&(M="http");let z=`&type=${encodeURIComponent(M)}`;if(e.network==="http"&&(z+="&headerType=http"),["grpc"].includes(e.network)){z+=`&mode=${encodeURIComponent(e[`${e.network}-opts`]?.["_grpc-type"]||"gun")}`;let K=e[`${e.network}-opts`]?.["_grpc-authority"];K&&(z+=`&authority=${encodeURIComponent(K)}`)}let C=e[`${e.network}-opts`]||{},P=e.network==="ws"&&C?.["v2ray-http-upgrade"],U=C?.[`${e.network}-service-name`],k=C?.path,O=U2(e.network,C),q=L2(e["ws-opts"]?.["max-early-data"]);Array.isArray(k)&&(k=k[0]),P&&C?.["v2ray-http-upgrade-fast-open"]?k=N2(k,C):e.network==="ws"&&e["ws-opts"]?.["max-early-data"]!=null&&k&&(k=ri(k,"ed").path),k&&(z+=`&path=${encodeURIComponent(k)}`),O&&(z+=`&host=${encodeURIComponent(Array.isArray(O)?O[0]:O)}`),U&&(z+=`&serviceName=${encodeURIComponent(U)}`),e.network==="http"&&e["http-opts"]?.method&&(z+=`&method=${encodeURIComponent(e["http-opts"].method)}`),e.network==="kcp"&&(e.seed&&(z+=`&seed=${encodeURIComponent(e.seed)}`),e.headerType&&(z+=`&headerType=${encodeURIComponent(e.headerType)}`)),e.network==="ws"&&!P&&q!==""&&(z+=`&ed=${encodeURIComponent(q)}`);let N=e["ws-opts"]?.["early-data-header-name"];N&&(P||e["ws-opts"]?.["max-early-data"]==null||N!=="Sec-WebSocket-Protocol")&&(z+=`&eh=${encodeURIComponent(N)}`);let _="",R;switch(e["packet-encoding"]!=null?R=`${e["packet-encoding"]}`.trim().toLowerCase():e.xudp?R="xudp":e["packet-addr"]?R="packetaddr":e.udp===!0&&(R=""),R){case"":_="&packetEncoding=none";break;case"packetaddr":_="&packetEncoding=packet";break;case"xudp":_="&packetEncoding=xudp";break}return`vless://${e.uuid}@${e.server}:${e.port}?security=${encodeURIComponent(t)}${z}${_}${s}${a}${l}${f}${p}${u}${v}${g}${y}${n}${o}${i}${S}${w}${D}${F}#${encodeURIComponent(e.name)}`}function Wh(){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&&delete r[i];switch(["tuic","hysteria","hysteria2","juicity","trusttunnel"].includes(r.type)&&delete r.tls,!["vmess"].includes(r.type)&&r.server&&_r(r.server)&&(r.server=`[${r.server}]`),r.type){case"socks5":n=`socks://${encodeURIComponent(_t.encode(`${r.username??""}:${r.password??""}`))}@${r.server}:${r.port}#${r.name}`;break;case"ss":let i=`${r.cipher}:${r.password}`;n=`ss://${r.cipher?.startsWith("2022-blake3-")?`${encodeURIComponent(r.cipher)}:${encodeURIComponent(r.password)}`:_t.encode(i)}@${r.server}:${r.port}${r.plugin?"/":""}`;let o="";if(r.plugin){o+="&plugin=";let le=r["plugin-opts"];switch(r.plugin){case"obfs":o+=encodeURIComponent(`simple-obfs;obfs=${le.mode}${le.host?";obfs-host="+le.host:""}`);break;case"v2ray-plugin":let Se=h0(le.mux);o+=encodeURIComponent(`v2ray-plugin;obfs=${le.mode};mode=${le.mode}${le.host?";obfs-host="+le.host:""}${le.host?";host="+le.host:""}${le.path?";path="+le.path:""}${le.tls?";tls":""}${le.sni?";sni="+le.sni:""}${le["skip-cert-verify"]?";skip-cert-verify="+le["skip-cert-verify"]:""}${Se!=null?";mux="+Se:""}`);break;case"shadow-tls":o+=encodeURIComponent(`shadow-tls;host=${le.host};password=${le.password};version=${le.version}`);break;default:throw new Error(`Unsupported plugin option: ${r.plugin}`)}}r["udp-over-tcp"]&&(o+="&uot=1"),r.tfo&&(o+="&tfo=1");let s="";if(r.network){let le=r.network;if(r.network==="ws"&&r["ws-opts"]?.["v2ray-http-upgrade"]&&(le="httpupgrade"),s=`&type=${encodeURIComponent(le)}`,["grpc"].includes(r.network)){let qe=r[`${r.network}-opts`]?.[`${r.network}-service-name`],At=r[`${r.network}-opts`]?.["_grpc-authority"];qe&&(s+=`&serviceName=${encodeURIComponent(qe)}`),At&&(s+=`&authority=${encodeURIComponent(At)}`),s+=`&mode=${encodeURIComponent(r[`${r.network}-opts`]?.["_grpc-type"]||"gun")}`}let Se=r[`${r.network}-opts`]||{},Re=r.network==="ws"&&Se?.["v2ray-http-upgrade"],Ve=Se?.path,rt=Se?.headers?.Host;Array.isArray(Ve)&&(Ve=Ve[0]),Re?Ve=N2(Ve,Se):r.network==="ws"&&(Ve=jS(Ve,Se)),Ve&&(s+=`&path=${encodeURIComponent(Ve)}`),rt&&(s+=`&host=${encodeURIComponent(Array.isArray(rt)?rt[0]:rt)}`)}let a="";r["client-fingerprint"]&&(a=`&fp=${encodeURIComponent(r["client-fingerprint"])}`);let u="";r.alpn&&(u=`&alpn=${encodeURIComponent(Array.isArray(r.alpn)?r.alpn:r.alpn.join(","))}`);let l=r["reality-opts"],f="",m="",p="",d=r.tls?"&security=tls":"",v="",g="";if(l){d="&security=reality";let le=r["reality-opts"]?.["public-key"];le&&(m=`&pbk=${encodeURIComponent(le)}`);let Se=r["reality-opts"]?.["short-id"];Se&&(f=`&sid=${encodeURIComponent(Se)}`);let Re=r["reality-opts"]?.["_spider-x"];Re&&(p=`&spx=${encodeURIComponent(Re)}`),r._extra&&(g=`&extra=${encodeURIComponent(r._extra)}`),r._mode&&(v=`&mode=${encodeURIComponent(r._mode)}`)}r.tls&&(o+=`&sni=${encodeURIComponent(r.sni||r.server)}${r["skip-cert-verify"]?"&allowInsecure=1":""}`),o+=`${s}${u}${a}${d}${f}${m}${p}${v}${g}#${encodeURIComponent(r.name)}`,n+=o.replace(/^&/,"?");break;case"ssr":n=`${r.server}:${r.port}:${r.protocol}:${r.cipher}:${r.obfs}:${_t.encode(r.password)}/`,n+=`?remarks=${_t.encode(r.name)}${r["obfs-param"]?"&obfsparam="+_t.encode(r["obfs-param"]):""}${r["protocol-param"]?"&protocolparam="+_t.encode(r["protocol-param"]):""}`,n="ssr://"+_t.encode(n);break;case"vmess":let y="",w=r.network||"tcp";if(r.network==="http"?(w="tcp",y="http"):r.network==="ws"&&r["ws-opts"]?.["v2ray-http-upgrade"]&&(w="httpupgrade"),n={v:"2",ps:r.name,add:r.server,port:`${r.port}`,id:r.uuid,aid:`${r.alterId||0}`,scy:jn(r.cipher),net:w,type:y,tls:r.tls?"tls":"",alpn:Array.isArray(r.alpn)?r.alpn.join(","):r.alpn,fp:r["client-fingerprint"]},r.tls&&r.sni&&(n.sni=r.sni),r.network){let le=r[`${r.network}-opts`]||{},Se=r.network==="ws"&&le?.["v2ray-http-upgrade"],Re=le?.path,Ve=U2(r.network,le);["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"]):["kcp","quic"].includes(r.network)?(n.type=r[`${r.network}-opts`]?.[`_${r.network}-type`]||"none",n.host=r[`${r.network}-opts`]?.[`_${r.network}-host`],n.path=r[`${r.network}-opts`]?.[`_${r.network}-path`]):(Array.isArray(Re)&&(Re=Re[0]),Se?Re=N2(Re,le):r.network==="ws"&&(Re=jS(Re,le)),Re&&(n.path=Re),Ve&&(n.host=Array.isArray(Ve)?Ve[0]:Ve))}n="vmess://"+_t.encode(JSON.stringify(n));break;case"vless":n=I7(r);break;case"trojan":let E="";if(r.network){let le=r.network;if(r.network==="ws"&&r["ws-opts"]?.["v2ray-http-upgrade"]&&(le="httpupgrade"),E=`&type=${encodeURIComponent(le)}`,["grpc"].includes(r.network)){let qe=r[`${r.network}-opts`]?.[`${r.network}-service-name`],At=r[`${r.network}-opts`]?.["_grpc-authority"];qe&&(E+=`&serviceName=${encodeURIComponent(qe)}`),At&&(E+=`&authority=${encodeURIComponent(At)}`),E+=`&mode=${encodeURIComponent(r[`${r.network}-opts`]?.["_grpc-type"]||"gun")}`}let Se=r[`${r.network}-opts`]||{},Re=r.network==="ws"&&Se?.["v2ray-http-upgrade"],Ve=Se?.path,rt=Se?.headers?.Host;Array.isArray(Ve)&&(Ve=Ve[0]),Re?Ve=N2(Ve,Se):r.network==="ws"&&(Ve=jS(Ve,Se)),Ve&&(E+=`&path=${encodeURIComponent(Ve)}`),rt&&(E+=`&host=${encodeURIComponent(Array.isArray(rt)?rt[0]:rt)}`)}let S="";r["client-fingerprint"]&&(S=`&fp=${encodeURIComponent(r["client-fingerprint"])}`);let D="";r["tls-fingerprint"]&&(D=`&pcs=${encodeURIComponent(r["tls-fingerprint"])}`);let F="",M=Array.isArray(r._vcn)?r._vcn.join(","):r["name-cert-verify"];(Array.isArray(r._vcn)||M)&&(F=`&vcn=${encodeURIComponent(M)}`);let z="";r.alpn&&(z=`&alpn=${encodeURIComponent(Array.isArray(r.alpn)?r.alpn:r.alpn.join(","))}`);let C=r["reality-opts"],P="",U="",k="",O="",q="",N="";if(C){O="&security=reality";let le=r["reality-opts"]?.["public-key"];le&&(U=`&pbk=${encodeURIComponent(le)}`);let Se=r["reality-opts"]?.["short-id"];Se&&(P=`&sid=${encodeURIComponent(Se)}`);let Re=r["reality-opts"]?.["_spider-x"];Re&&(k=`&spx=${encodeURIComponent(Re)}`),r._extra&&(N=`&extra=${encodeURIComponent(r._extra)}`),r._mode&&(q=`&mode=${encodeURIComponent(r._mode)}`)}n=`trojan://${r.password}@${r.server}:${r.port}?sni=${encodeURIComponent(r.sni||r.server)}${r["skip-cert-verify"]?"&allowInsecure=1":""}${E}${z}${S}${D}${F}${O}${P}${U}${k}${q}${N}#${encodeURIComponent(r.name)}`;break;case"hysteria2":let _=[];r["hop-interval"]&&_.push(`hop-interval=${r["hop-interval"]}`),r.keepalive&&_.push(`keepalive=${r.keepalive}`),r["skip-cert-verify"]&&_.push("insecure=1"),r.obfs&&(_.push(`obfs=${encodeURIComponent(r.obfs)}`),r["obfs-password"]&&_.push(`obfs-password=${encodeURIComponent(r["obfs-password"])}`)),r.sni&&_.push(`sni=${encodeURIComponent(r.sni)}`),r.ports&&_.push(`mport=${r.ports}`),r["tls-fingerprint"]&&_.push(`pinSHA256=${encodeURIComponent(r["tls-fingerprint"])}`),r.tfo&&_.push("fastopen=1");let R=NS(r["ech-opts"]);R&&_.push(`ech=${encodeURIComponent(R)}`),n=`hysteria2://${encodeURIComponent(r.password)}@${r.server}:${r.port}?${_.join("&")}#${encodeURIComponent(r.name)}`;break;case"hysteria":let K=[];Object.keys(r).forEach(le=>{if(!["name","type","server","port"].includes(le)){let Se=le.replace(/-/,"_");["alpn"].includes(le)?r[le]&&K.push(`${Se}=${encodeURIComponent(Array.isArray(r[le])?r[le][0]:r[le])}`):["skip-cert-verify"].includes(le)?r[le]&&K.push("insecure=1"):["tfo","fast-open"].includes(le)?r[le]&&!K.includes("fastopen=1")&&K.push("fastopen=1"):["ports"].includes(le)?K.push(`mport=${r[le]}`):["auth-str"].includes(le)?K.push(`auth=${r[le]}`):["up"].includes(le)?K.push(`upmbps=${r[le]}`):["down"].includes(le)?K.push(`downmbps=${r[le]}`):["_obfs"].includes(le)?K.push(`obfs=${r[le]}`):["obfs"].includes(le)?K.push(`obfsParam=${r[le]}`):["sni"].includes(le)?K.push(`peer=${r[le]}`):r[le]&&!/^_/i.test(le)&&K.push(`${Se}=${encodeURIComponent(r[le])}`)}}),n=`hysteria://${r.server}:${r.port}?${K.join("&")}#${encodeURIComponent(r.name)}`;break;case"tuic":if(!r.token||r.token.length===0){let le=[];Object.keys(r).forEach(Se=>{if(!["name","type","uuid","password","server","port","tls"].includes(Se)){let Re=Se.replace(/-/,"_");["alpn"].includes(Se)?r[Se]&&le.push(`${Re}=${encodeURIComponent(Array.isArray(r[Se])?r[Se][0]:r[Se])}`):["skip-cert-verify"].includes(Se)?r[Se]&&le.push("allow_insecure=1"):["tfo","fast-open"].includes(Se)?r[Se]&&!le.includes("fast_open=1")&&le.push("fast_open=1"):["disable-sni","reduce-rtt"].includes(Se)&&r[Se]?le.push(`${Re.replace(/-/g,"_")}=1`):["congestion-controller"].includes(Se)?le.push(`congestion_control=${r[Se]}`):r[Se]&&!/^_/i.test(Se)&&le.push(`${Re.replace(/-/g,"_")}=${encodeURIComponent(r[Se])}`)}}),n=`tuic://${encodeURIComponent(r.uuid)}:${encodeURIComponent(r.password)}@${r.server}:${r.port}?${le.join("&")}#${encodeURIComponent(r.name)}`}break;case"anytls":n=I7({...r,uuid:r.password,network:r.network||"tcp"}).replace("vless","anytls");let Z=[];Object.keys(r).forEach(le=>{if(!["name","type","password","server","port","tls"].includes(le)){let Se=le.replace(/-/,"_");["alpn"].includes(le)?r[le]&&Z.push(`${Se}=${encodeURIComponent(Array.isArray(r[le])?r[le][0]:r[le])}`):["skip-cert-verify"].includes(le)?r[le]&&Z.push("insecure=1"):["udp"].includes(le)?r[le]&&Z.push("udp=1"):r[le]&&!/^_|client-fingerprint/i.test(le)&&["number","string","boolean"].includes(typeof r[le])&&Z.push(`${Se.replace(/-/g,"_")}=${encodeURIComponent(r[le])}`)}});let Y=n.split("?"),te=Y[0],se={};Y.length>1&&Y[1].split("#")[0].split("&").forEach(Re=>{let[Ve,rt]=Re.split("=");Ve&&(se[Ve]=rt)}),Z.forEach(le=>{let[Se,Re]=le.split("=");Se&&(se[Se]=Re)});let fe=Object.keys(se).map(le=>`${le}=${se[le]}`).join("&"),ve=n.match(/#(.*)$/),we=ve?`#${ve[1]}`:"";n=`${te}?${fe}${we}`;break;case"wireguard":let Te=[];Object.keys(r).forEach(le=>{["name","type","server","port","ip","ipv6","ip-cidr","ipv6-cidr","private-key"].includes(le)||(["public-key"].includes(le)?Te.push(`publickey=${encodeURIComponent(r[le])}`):["udp"].includes(le)?r[le]&&Te.push(`${le}=1`):r[le]&&!/^_/i.test(le)&&Te.push(`${le}=${encodeURIComponent(r[le])}`))});let Le=ti(r,"ipv4"),Oe=ti(r,"ipv6");Le&&Oe?Te.push(`address=${encodeURIComponent(`${Le},${Oe}`)}`):Le?Te.push(`address=${encodeURIComponent(Le)}`):Oe&&Te.push(`address=${encodeURIComponent(Oe)}`),n=`wireguard://${encodeURIComponent(r["private-key"])}@${r.server}:${r.port}/?${Te.join("&")}#${encodeURIComponent(r.name)}`;break}return n}}}var mEe=B(T());var KZ=Wh();function y0(){return{type:"ALL",produce:r=>{let n=[];return r.map(i=>{try{n.push(KZ.produce(i))}catch(o){H.error(`Cannot produce proxy: ${i.name} Reason: ${o}`)}}),_t.encode(n.join(` `))}}}var yEe=B(T());var H2="QX";function E0(){let e=(t,r,n={})=>{if(["ws"].includes(t.network)&&t["ws-opts"]?.["v2ray-http-upgrade"])throw new Error(`Platform ${H2} does not support network ${t.network} with http upgrade`);switch(t.type){case"ss":return VZ(t);case"ssr":return zZ(t);case"trojan":return GZ(t);case"vmess":return YZ(t);case"http":return JZ(t);case"socks5":return ZZ(t);case"vless":return WZ(t);case"anytls":return XZ(t)}throw new Error(`Platform ${H2} does not support proxy type: ${t.type}`)};return{produce:(t,r,n={})=>{let i=e(t,r,n);if(t.flow&&t.flow!=="xtls-rprx-vision")throw new Error(`Platform ${H2} does not support flow ${t.flow}`);return t["reality-opts"]&&(t["reality-opts"]["public-key"]&&(i=`${i},reality-base64-pubkey=${t["reality-opts"]["public-key"]}`),t["reality-opts"]["short-id"]&&(i=`${i},reality-hex-shortid=${t["reality-opts"]["short-id"]}`)),i}}}function KS(e){return["http","vmess-http","vemss-http","shadowsocks-http"].includes(e._qx_obfs_http)?e._qx_obfs_http:"http"}function uf(e,t){let r=pe(t,"name-cert-verify")?"name-cert-verify":"skip-cert-verify";e.appendIfPresent(`,tls-verification=${t["name-cert-verify"]??!t["skip-cert-verify"]}`,r)}function VZ(e){let t=new pt(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t),i=jh(e);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","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"].includes(e.cipher))throw new Error(`cipher ${e.cipher} is not supported`);if(r(`shadowsocks=${e.server}:${e.port}`),r(`,method=${e.cipher}`),r(`,password=${e.password}`),yi(e)&&(e.tls=!0),i)r(",obfs=over-tls"),pe(e,"sni")?r(`,obfs-host=${e.sni}`):n(`,obfs-host=${e.servername}`,"servername");else if(pe(e,"plugin")){if(e.plugin==="obfs"){let o=e["plugin-opts"];o.mode==="http"?r(`,obfs=${KS(e)}`):r(`,obfs=${o.mode}`)}else if(e.plugin==="v2ray-plugin"&&e["plugin-opts"].mode==="websocket")e["plugin-opts"].tls?r(",obfs=wss"):r(",obfs=ws");else throw new Error("plugin is not supported");n(`,obfs-host=${e["plugin-opts"].host}`,"plugin-opts.host"),n(`,obfs-uri=${e["plugin-opts"].path}`,"plugin-opts.path")}return yi(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"),uf(t,e),i||n(`,tls-host=${e.sni}`,"sni")),n(`,fast-open=${e.tfo}`,"tfo"),n(`,udp-relay=${e.udp}`,"udp"),e._ssr_python_uot?r(",udp-over-tcp=true"):e["udp-over-tcp"]&&(!e["udp-over-tcp-version"]||e["udp-over-tcp-version"]===1?r(",udp-over-tcp=sp.v1"):e["udp-over-tcp-version"]===2&&r(",udp-over-tcp=sp.v2")),t.appendIfPresent(`,server_check_url=${e["test-url"]}`,"test-url"),r(`,tag=${e.name}`),t.toString()}function zZ(e){let t=new pt(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 GZ(e){let t=new pt(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t);if(r(`trojan=${e.server}:${e.port}`),r(`,password=${e.password}`),pe(e,"network")){if(e.network==="ws")yi(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 if(!["tcp"].includes(e.network))throw new Error(`network ${e.network} is unsupported`)}return e.network!=="ws"&&yi(e)&&r(",over-tls=true"),yi(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"),uf(t,e),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 YZ(e){let t=new pt(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t);r(`vmess=${e.server}:${e.port}`);let i=c7(e.cipher);if(r(`,method=${i}`),r(`,password=${e.uuid}`),yi(e)&&(e.tls=!0),pe(e,"network")){if(e.network==="ws")e.tls?r(",obfs=wss"):r(",obfs=ws");else if(e.network==="http")r(`,obfs=${KS(e)}`);else if(["tcp"].includes(e.network))e.tls&&r(",obfs=over-tls");else if(!["tcp"].includes(e.network))throw new Error(`network ${e.network} is unsupported`);let o=e[`${e.network}-opts`]?.path,s=e[`${e.network}-opts`]?.headers?.Host;n(`,obfs-uri=${Array.isArray(o)?o[0]:o}`,`${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 yi(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"),uf(t,e),n(`,tls-host=${e.sni}`,"sni")),pe(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 WZ(e){if(e.encryption&&e.encryption!=="none")throw new Error("VLESS encryption is not supported");let t=new pt(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}`),yi(e)&&(e.tls=!0),pe(e,"network")){if(e.network==="ws")e.tls?r(",obfs=wss"):r(",obfs=ws");else if(e.network==="http")r(`,obfs=${KS(e)}`);else if(["tcp"].includes(e.network))e.tls&&r(",obfs=over-tls");else if(!["tcp"].includes(e.network))throw new Error(`network ${e.network} is unsupported`);let o=e[`${e.network}-opts`]?.path,s=e[`${e.network}-opts`]?.headers?.Host;n(`,obfs-uri=${Array.isArray(o)?o[0]:o}`,`${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 yi(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"),uf(t,e),n(`,tls-host=${e.sni}`,"sni")),n(`,vless-flow=${e.flow}`,"flow"),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 XZ(e){let t=e.network?.trim().toLowerCase();if(t&&t!=="tcp")throw new Error(`Platform ${H2} does not support AnyTLS with transport ${e.network}`);let r=new pt(e),n=r.append.bind(r),i=r.appendIfPresent.bind(r);return n(`anytls=${e.server}:${e.port}`),n(`,password=${e.password}`),e.tls=!0,n(",over-tls=true"),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"),uf(r,e),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 JZ(e){let t=new pt(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"),yi(e)&&(e.tls=!0),n(`,over-tls=${e.tls}`,"tls"),yi(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"),uf(t,e),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 ZZ(e){let t=new pt(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"),yi(e)&&(e.tls=!0),n(`,over-tls=${e.tls}`,"tls"),yi(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"),uf(t,e),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 yi(e){return e.tls}var _Ee=B(T());function b0(){return{type:"ALL",produce:(r,n,i={})=>{let o=r.filter(s=>{if(i["include-unsupported-proxy"])return!0;if(Kh(s,["websocket","quic","http2","mkcp","grpc"])){if(s.type==="snell"&&![1,2,3,4,5,6].includes(s.version))return!1;if(QZ(s))return H.error(`Platform Shadowrocket does not support Snell shadow-tls with obfs for proxy ${s.name}. Proxy has been filtered.`),!1;if(["tailscale","sudoku","naive","openvpn","gost-relay","shadowquic"].includes(s.type))return!1;if(["xhttp"].includes(s.network))return H.warn("VLESS XHTTP \u7ED3\u6784\u590D\u6742, Shadowrocket \u53EF\u80FD\u65E0\u6CD5\u5B8C\u5168\u517C\u5BB9"),!0}else return!1;return!0}).map(s=>{if(I2(s),s.type==="vmess"?(pe(s,"aead")&&(s.aead&&(s.alterId=0),delete s.aead),pe(s,"sni")&&(s.servername=s.sni,delete s.sni),s.cipher=jn(s.cipher)):s.type==="tuic"?(pe(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),pe(s,"tfo")&&!pe(s,"fast-open")&&(s["fast-open"]=s.tfo),(!s.token||s.token.length===0)&&!pe(s,"version")&&(s.version=5)):s.type==="hysteria"?(pe(s,"auth_str")&&!pe(s,"auth-str")&&(s["auth-str"]=s.auth_str),pe(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),pe(s,"tfo")&&!pe(s,"fast-open")&&(s["fast-open"]=s.tfo)):s.type==="hysteria2"?(pe(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),pe(s,"tfo")&&!pe(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.ip=ti(s,"ipv4"),s.ipv6=ti(s,"ipv6")):s.type==="snell"?(s.version<3&&delete s.udp,s.plugin==="shadow-tls"&&s["plugin-opts"]&&(s["obfs-opts"]={mode:"shadow-tls",host:s["plugin-opts"].host,password:s["plugin-opts"].password,version:s["plugin-opts"].version},s["plugin-opts"].alpn&&(s["obfs-opts"].alpn=s["plugin-opts"].alpn),delete s.plugin,delete s["plugin-opts"])):s.type==="vless"?pe(s,"sni")&&(s.servername=s.sni,delete s.sni):s.type==="ss"?jh(s)&&pe(s,"sni")&&(s.servername=s.sni):["anytls"].includes(s.type)&&s.reuse!=null&&!s.reuse&&(s["disable-reuse"]=!0,delete s.reuse),["vmess","vless"].includes(s.type)&&s.network==="http"){let a=s["http-opts"]?.path;pe(s,"http-opts.path")&&!Array.isArray(a)&&(s["http-opts"].path=[a]);let u=s["http-opts"]?.headers?.Host;pe(s,"http-opts.headers.Host")&&!Array.isArray(u)&&(s["http-opts"].headers.Host=[u])}if(["vmess","vless"].includes(s.type)&&s.network==="h2"){let a=s["h2-opts"]?.path;pe(s,"h2-opts.path")&&Array.isArray(a)&&(s["h2-opts"].path=a[0]);let u=s["h2-opts"]?.host??s["h2-opts"]?.headers?.host??s["h2-opts"]?.headers?.Host;(pe(s,"h2-opts.host")||pe(s,"h2-opts.headers.host")||pe(s,"h2-opts.headers.Host"))&&(s["h2-opts"].host=Array.isArray(u)?u:[u]),s["h2-opts"]?.headers&&(delete s["h2-opts"].headers.host,delete s["h2-opts"].headers.Host,Object.keys(s["h2-opts"].headers).length===0&&delete s["h2-opts"].headers)}if(["ws"].includes(s.network)){let a=`${s.network}-opts`;s[a]=s[a]||{},s[a].path||(s[a].path="/"),kc(s[a])}if(s["plugin-opts"]?.tls&&pe(s,"skip-cert-verify")&&(s["plugin-opts"]["skip-cert-verify"]=s["plugin-opts"]["skip-cert-verify"]||s["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls","trusttunnel","naive"].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"],pe(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"],delete s["ip-cidr"],delete s["ipv6-cidr"],n!=="internal"){for(let a in s)(s[a]==null||/^_/i.test(a))&&delete s[a];Oc(s[`${s.network}-opts`])}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 _a(o,n,i)}}}function QZ(e){return e?.type==="snell"&&e?.plugin==="shadow-tls"&&(pe(e,"obfs-opts.mode")||pe(e,"obfs-opts.host")||pe(e,"obfs-opts.path"))}var BEe=B(T());var A0="Surfboard";function S0(e){return e!=null&&`${e}`.trim().length>0}function cf(e,t,r=!0){r&&(e.appendIfPresent(`,server-cert-fingerprint-sha256=${t["tls-fingerprint"]}`,"tls-fingerprint"),e.appendIfPresent(`,sni="${t.sni}"`,"sni"),e.appendIfPresent(`,skip-cert-verify=${t["skip-cert-verify"]}`,"skip-cert-verify"))}function M2(){return{produce:t=>{if(["ws"].includes(t.network)&&t["ws-opts"]?.["v2ray-http-upgrade"])throw new Error(`Platform ${A0} does not support network ${t.network} with http upgrade`);switch(t.name=t.name.replace(/=|,/g,""),t.type){case"ss":return sQ(t);case"trojan":return iQ(t);case"vmess":return oQ(t);case"http":return aQ(t);case"snell":return nQ(t);case"tuic":return eQ(t);case"socks5":return uQ(t);case"hysteria2":return tQ(t);case"wireguard-surge":return cQ(t)}if(t.type==="anytls"){if(t.network&&(!["tcp"].includes(t.network)||["tcp"].includes(t.network)&&t["reality-opts"]))throw new Error(`Platform ${A0} does not support proxy type ${t.type} with network or REALITY`);return rQ(t)}throw new Error(`Platform ${A0} does not support proxy type: ${t.type}`)}}}function eQ(e){if(e.token?.length)throw new Error(`Platform ${A0} does not support proxy type ${e.type} v4`);let t=new pt(e);return t.append(`${e.name}=tuic-v5,${e.server},${e.port}`),t.appendIfPresent(`,uuid=${e.uuid}`,"uuid"),t.appendIfPresent(`,password="${e.password}"`,"password"),S0(e.alpn)&&t.append(`,alpn="${Array.isArray(e.alpn)?e.alpn.join(","):e.alpn}"`),S0(e.ports)&&t.append(`,port-hopping="${String(e.ports).replace(/,/g,";")}"`),S0(e["hop-interval"])&&t.append(`,port-hopping-interval=${e["hop-interval"]}`),cf(t,e),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.toString()}function tQ(e){if(e.obfs&&e.obfs!=="salamander"||e["obfs-password"]&&e.obfs!=="salamander")throw new Error("Surfboard Hysteria2 only supports salamander obfs");let t=new pt(e);return t.append(`${e.name}=hysteria2,${e.server},${e.port}`),t.appendIfPresent(`,password="${e.password}"`,"password"),S0(e.ports)&&t.append(`,port-hopping="${String(e.ports).replace(/,/g,";")}"`),S0(e["hop-interval"])&&t.append(`,port-hopping-interval=${e["hop-interval"]}`),e["obfs-password"]&&t.append(`,salamander-password="${e["obfs-password"]}"`),cf(t,e),t.appendIfPresent(`,download-bandwidth=${`${e.down}`.match(/\d+/)?.[0]||0}`,"down"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.toString()}function rQ(e){let t=new pt(e);return t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password="${e.password}"`,"password"),cf(t,e),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,reuse=${e.reuse}`,"reuse"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.toString()}function nQ(e){if(pe(e,"version")&&![1,2,3,4,5].includes(Number(e.version)))throw new Error(`Platform ${A0} does not support snell version ${e.version}`);let t=new pt(e);return t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,version=${e.version}`,"version"),t.appendIfPresent(`,psk="${e.psk}"`,"psk"),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"),e.version>=3&&t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.toString()}function sQ(e){let t=new pt(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","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(`,encrypt-method=${e.cipher}`),t.appendIfPresent(`,password="${e.password}"`,"password"),pe(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.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.toString()}function iQ(e){let t=new pt(e);return t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password=${e.password}`,"password"),P7(t,e),t.appendIfPresent(`,tls=${e.tls}`,"tls"),cf(t,e),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.toString()}function oQ(e){let t=new pt(e);return t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,username=${e.uuid}`,"uuid"),P7(t,e),pe(e,"aead")?t.append(`,vmess-aead=${e.aead}`):t.append(`,vmess-aead=${e.alterId===0}`),t.appendIfPresent(`,tls=${e.tls}`,"tls"),cf(t,e,!!e.tls),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.toString()}function aQ(e){let t=new pt(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"),cf(t,e,!!e.tls),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.toString()}function uQ(e){let t=new pt(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"),cf(t,e,!!e.tls),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.toString()}function cQ(e){let t=new pt(e);return t.append(`${e.name}=wireguard`),t.appendIfPresent(`,section-name=${e["section-name"]}`,"section-name"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.toString()}function P7(e,t){if(pe(t,"network"))if(t.network==="ws"){if(e.append(",ws=true"),pe(t,"ws-opts")&&(e.appendIfPresent(`,ws-path=${t["ws-opts"].path}`,"ws-opts.path"),pe(t,"ws-opts.headers"))){let r=t["ws-opts"].headers,n=Object.keys(r).map(i=>{let o=r[i];return["Host"].includes(i)&&(o=`"${o}"`),`${i}:${o}`}).join("|");nt(n)&&e.append(`,ws-headers=${n}`)}}else{if(["tcp"].includes(t.network)&&t["reality-opts"])throw new Error("reality is unsupported");if(!["tcp"].includes(t.network))throw new Error(`network ${t.network} is unsupported`)}}var NEe=B(T());var lQ={ipv4:"ipv4_only",ipv6:"ipv6_only","v4-only":"ipv4_only","v6-only":"ipv6_only","ipv4-prefer":"prefer_ipv4","ipv6-prefer":"prefer_ipv6","prefer-v4":"prefer_ipv4","prefer-v6":"prefer_ipv6"},Kn=(e,t)=>{let r=lQ[e["ip-version"]];e._dns_server&&r&&(t.domain_resolver={server:e._dns_server,strategy:r})},Vn=(e,t)=>{e._domain_resolver&&(typeof e._domain_resolver=="string"?t.domain_resolver={...t.domain_resolver??{},server:e._domain_resolver}:t.domain_resolver={...t.domain_resolver??{},...e._domain_resolver})},fQ=e=>{let t=e["control-http-client"];return t==null?!1:typeof t=="string"?t.trim()!=="":gt(t)?Object.values(t).some(r=>r!=null&&r!==""):!0},zn=(e,t)=>{t.detour=e["dialer-proxy"]||e.detour},Do=(e,t)=>{if(["tcp","udp"].includes(e._network)){t.network=e._network;return}e.udp===!1&&(t.network="tcp")},Os=(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},Fo=(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),(e["brutal-opts"]?.up||e["brutal-opts"]?.down)&&(t.multiplex.brutal={enabled:!0},e["brutal-opts"]?.up&&(t.multiplex.brutal.up_mbps=parseInt(`${e["brutal-opts"]?.up}`,10)),e["brutal-opts"]?.down&&(t.multiplex.brutal.down_mbps=parseInt(`${e["brutal-opts"]?.down}`,10))))},zS=(e,t)=>{let r={type:"ws",headers:{}};if(e["ws-opts"]){let{path:n="",headers:i={},"max-early-data":o,"early-data-header-name":s}=e["ws-opts"];if(r.early_data_header_name=s,r.max_early_data=o?parseInt(o,10):void 0,n!==""&&(r.path=`${n}`),Object.keys(i).length>0){let a={};for(let l of Object.keys(i)){let f=i[l];f!==""&&(Array.isArray(f)||(f=[`${f}`]),f.length>0&&(a[l]=f))}let{Host:u}=a;if(u.length===1)for(let l of`Host:${u[0]}`.split(` `)){let[f,m]=l.split(":");m.trim()!==""&&(a[f.trim()]=m.trim().split(","))}r.headers=a}}if(e["ws-headers"]){let n={};for(let o of Object.keys(e["ws-headers"])){let s=e["ws-headers"][o];s!==""&&(Array.isArray(s)||(s=[`${s}`]),s.length>0&&(n[o]=s))}let{Host:i}=n;if(i.length===1)for(let o of`Host:${i[0]}`.split(` `)){let[s,a]=o.split(":");a.trim()!==""&&(n[s.trim()]=a.trim().split(","))}for(let o of Object.keys(n))r.headers[o]=n[o]}if(e["ws-path"]&&e["ws-path"]!==""&&(r.path=`${e["ws-path"]}`),r.path){let{value:n,parsed:i}=TS(r.path,"ed");n!==""&&(r.path=ri(r.path,"ed").path,r.early_data_header_name="Sec-WebSocket-Protocol",r.max_early_data=i)}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},R7=(e,t)=>{let r={type:"http",headers:{}};if(e["http-opts"]){let{method:n="",path:i="",headers:o={}}=e["http-opts"];n!==""&&(r.method=n),Array.isArray(i)?r.path=`${i[0]}`:i!==""&&(r.path=`${i}`);for(let s of Object.keys(o)){let a=o[s];if(a!==""){if(s.toLowerCase()==="host"){let u=a;Array.isArray(u)||(u=`${u}`.split(",").map(l=>l.trim())),u.length>0&&(r.host=u);continue}Array.isArray(a)||(a=`${a}`.split(",").map(u=>u.trim())),a.length>0&&(r.headers[s]=a)}}}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(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},k7=(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(o=>o.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},GS=(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},hQ=(e,t)=>{let r=Array.isArray(e)?e:[e],n=[];for(let i of r){let o=`${i}`.trim().replace(/\\r\\n/g,` `).replace(/\\n/g,` `);if(o!=="")for(let s of o.split(/\r?\n/)){let a=s.trim();a!==""&&n.push(a)}}if(n.length!==0)return n.some(i=>/^-----BEGIN [A-Za-z0-9 -]+-----$/.test(i))?n:[`-----BEGIN ${t}-----`,...n,`-----END ${t}-----`]},dQ=["chrome","firefox","edge","safari","360","qq","ios","android","random","randomized"],O7=e=>{let t=`${e||""}`.trim().toLowerCase();if(dQ.includes(t))return t},Uu=(e,t)=>{if(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"]!==""){let r=O7(e["client-fingerprint"]);r&&(t.tls.utls={...t.tls.utls,enabled:!0,fingerprint:r})}if(e._ech&>(e._ech))t.tls.ech=e._ech;else if(e["ech-opts"]&>(e["ech-opts"])){t.tls.ech=t.tls.ech||{},t.tls.ech.enabled=e["ech-opts"].enable;let r=e["ech-opts"].config;if(Array.isArray(r)||typeof r=="string"){let n=hQ(r,"ECH CONFIGS");n&&(t.tls.ech.config=n)}t.tls.ech.query_server_name=e["ech-opts"]["query-server-name"],t.tls.ech.config_path=e["ech-opts"]["config-path"],t.tls.ech.fragment=e["ech-opts"].fragment,t.tls.ech.fragment_fallback_delay=e["ech-opts"]["fragment-fallback-delay"],t.tls.ech.record_fragment=e["ech-opts"]["record-fragment"]}e._curve_preferences&&Array.isArray(e._curve_preferences)&&(t.tls.curve_preferences=e._curve_preferences),e._fragment&&(t.tls.fragment=!!e._fragment),e._fragment_fallback_delay&&(t.tls.fragment_fallback_delay=e._fragment_fallback_delay),e._record_fragment&&(t.tls.record_fragment=!!e._record_fragment),e._certificate&&(t.tls.certificate=e._certificate),e._certificate_path&&(t.tls.certificate_path=e._certificate_path),e._certificate_public_key_sha256&&(t.tls.certificate_public_key_sha256=e._certificate_public_key_sha256),e._client_certificate&&(t.tls.client_certificate=e._client_certificate),e._client_certificate_path&&(t.tls.client_certificate_path=e._client_certificate_path),e._client_key&&(t.tls.client_key=e._client_key),e._client_key_path&&(t.tls.client_key_path=e._client_key_path),t.tls.enabled||delete t.tls},pQ=(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),Os(e,t),zn(e,t),Kn(e,t),Vn(e,t),t},mQ=(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),Os(e,t),zn(e,t),Uu(e,t),Kn(e,t),Vn(e,t),t},gQ=(e={})=>{let t={tag:e.name,type:"socks",server:e.server,server_port:parseInt(`${e.port}`,10),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={enabled:!0,version:!e["udp-over-tcp-version"]||e["udp-over-tcp-version"]===1?1:2}),e["fast-open"]&&(t.udp_fragment=!0),Do(e,t),Os(e,t),zn(e,t),Kn(e,t),Vn(e,t),t},vQ=(e={})=>{let t=q2(e),r={tag:e.name,type:"shadowsocks",method:e.cipher,password:e.password,detour:j2(e)};return e.uot&&(r.udp_over_tcp=!0),e["udp-over-tcp"]&&(r.udp_over_tcp={enabled:!0,version:!e["udp-over-tcp-version"]||e["udp-over-tcp-version"]===1?1:2}),Do(e,r),Fo(e.smux,r),{type:"ss-with-st",ssPart:r,stPart:VS(e,t)}},j2=(e={})=>`${e.name}_shadowtls`,q2=(e={})=>{if(e.plugin==="shadow-tls"&&e["plugin-opts"])return e["plugin-opts"];if(e.type==="snell"&&e["obfs-opts"]?.mode==="shadow-tls")return{host:e["obfs-opts"].host,password:e["obfs-opts"].password,version:e["obfs-opts"].version,alpn:e["obfs-opts"].alpn}},x7=e=>{if(typeof e=="string")return e.split(",").map(t=>t.trim()).filter(t=>t!=="");if(Array.isArray(e))return e},VS=(e={},t)=>{if(!t)throw new Error("shadow-tls plugin options are missing");let r=O7(e["client-fingerprint"]),n={tag:j2(e),type:"shadowtls",server:e.server,server_port:parseInt(`${e.port}`,10),version:t.version,password:t.password,tls:{enabled:!0,server_name:t.host}};if(e["skip-cert-verify"]&&(n.tls.insecure=!0),r&&(n.tls.utls={enabled:!0,fingerprint:r}),n.server_port<0||n.server_port>65535)throw"\u7AEF\u53E3\u503C\u975E\u6CD5";let i=x7(t.alpn)??x7(e.alpn);return i&&(n.tls.alpn=i),e["fast-open"]===!0&&(n.udp_fragment=!0),Os(e,n),zn(e,n),Kn(e,n),Vn(e,n),n},wQ=(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={enabled:!0,version:!e["udp-over-tcp-version"]||e["udp-over-tcp-version"]===1?1:2}),e["fast-open"]&&(t.udp_fragment=!0),Do(e,t),Os(e,t),zn(e,t),Fo(e.smux,t),Kn(e,t),Vn(e,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":{let i=h0(e["plugin-opts"].mux);i&&(t.multiplex={enabled:!0}),r.push(`mux=${i}`);break}default:r.push(`${n}=${e["plugin-opts"][n]}`)}})),t.plugin_opts=r.join(";")}return t},yQ=(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),Do(e,t),Os(e,t),zn(e,t),Fo(e.smux,t),Kn(e,t),Vn(e,t),t},EQ=e=>{if(e==null)return;let t=`${e}`.trim();return/^\d+$/.test(t)?parseInt(t,10):NaN},bQ=(e={},t=!1)=>{let r=EQ(e.version),n=q2(e),i=t?[1,2,3,4,5,6]:[4,5,6];if(r!=null&&(!i.includes(r)||Number.isNaN(r)))throw new Error(`Platform sing-box does not support snell version ${e.version}`);let o=!t&&r===5?4:r,s={tag:e.name,type:"snell",server:e.server,server_port:parseInt(`${e.port}`,10),psk:e.psk};if(s.server_port<0||s.server_port>65535)throw"invalid port";return o!=null&&(s.version=o),e._userkey&&(s.userkey=e._userkey),o===6?e.mode&&(s.mode=e.mode):(e["obfs-opts"]?.mode&&e["obfs-opts"].mode!=="shadow-tls"&&(s.obfs_mode=e["obfs-opts"].mode),e["obfs-opts"]?.host&&e["obfs-opts"]?.mode!=="shadow-tls"&&(s.obfs_host=e["obfs-opts"].host)),e.reuse&&(r==null||r>=4)&&(s.reuse=!0),Do(e,s),n?(s.detour=j2(e),delete s.server,delete s.server_port):(e["fast-open"]&&(s.udp_fragment=!0),Os(e,s),zn(e,s),Kn(e,s),Vn(e,s)),s},AQ=["","packetaddr","xudp"],SQ=e=>{let t=`${e}`.trim().toLowerCase();if(AQ.includes(t))return t},N7=(e,t)=>{if(e["packet-encoding"]!=null){let r=SQ(e["packet-encoding"]);r!=null&&(t.packet_encoding=r)}else e.xudp?t.packet_encoding="xudp":e["packet-addr"]&&(t.packet_encoding="packetaddr")},CQ=(e,t)=>{N7(e,t),e["global-padding"]!=null&&(t.global_padding=!!e["global-padding"]),e["authenticated-length"]!=null&&(t.authenticated_length=!!e["authenticated-length"])},_Q=(e={})=>{let t={tag:e.name,type:"vmess",server:e.server,server_port:parseInt(`${e.port}`,10),uuid:e.uuid,security:jn(e.cipher),alter_id:parseInt(`${e.alterId}`,10),tls:{enabled:!1,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";return CQ(e,t),e["fast-open"]&&(t.udp_fragment=!0),e.network==="ws"&&zS(e,t),e.network==="h2"&&k7(e,t),e.network==="http"&&R7(e,t),e.network==="grpc"&&GS(e,t),Do(e,t),Os(e,t),zn(e,t),Uu(e,t),Fo(e.smux,t),Kn(e,t),Vn(e,t),t},DQ=(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 N7(e,t),e["fast-open"]&&(t.udp_fragment=!0),e.flow!=null&&(t.flow=e.flow),e.network==="ws"&&zS(e,t),e.network==="h2"&&k7(e,t),e.network==="http"&&R7(e,t),e.network==="grpc"&&GS(e,t),Do(e,t),Os(e,t),zn(e,t),Fo(e.smux,t),Uu(e,t),Kn(e,t),Vn(e,t),t},FQ=(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"&&GS(e,t),e.network==="ws"&&zS(e,t),Do(e,t),Os(e,t),zn(e,t),Uu(e,t),Fo(e.smux,t),Kn(e,t),Vn(e,t),t},IQ=(e={})=>{let t={tag:e.name,type:"naive",server:e.server,server_port:parseInt(`${e.port}`,10),tls:{enabled:!0,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";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={enabled:!0,version:!e["udp-over-tcp-version"]||e["udp-over-tcp-version"]===1?1:2});let r=parseInt(`${e["insecure-concurrency"]}`,10);return Number.isInteger(r)&&r>=0&&(t.insecure_concurrency=r),e["extra-headers"]&&(t.extra_headers=e["extra-headers"]),e.quic&&(t.quic=!!e.quic),e["quic-congestion-control"]&&(t.quic_congestion_control=e["quic-congestion-control"]),e["fast-open"]&&(t.udp_fragment=!0),Os(e,t),zn(e,t),Uu(e,t),Fo(e.smux,t),Kn(e,t),Vn(e,t),t.tls?.insecure&&(H.info("Platform sing-box: insecure is not supported on naive outbound"),delete t.tls.insecure),t},BQ=(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["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(n=>{let i=n.replace(/\s*-\s*/g,":");return i.includes(":")?i:`${i}:${i}`})),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}`)&&!`${e.up}`.endsWith("Mbps")?t.up=`${e.up}`:t.up_mbps=parseInt(`${e.up}`,10),r.test(`${e.down}`)&&!`${e.down}`.endsWith("Mbps")?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)),Do(e,t),Uu(e,t),zn(e,t),Os(e,t),Fo(e.smux,t),Kn(e,t),Vn(e,t),t},$Q=(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";if(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=>{let n=r.replace(/\s*-\s*/g,":");return n.includes(":")?n:`${n}:${n}`})),e.up&&(t.up_mbps=parseInt(`${e.up}`,10)),e.down&&(t.down_mbps=parseInt(`${e.down}`,10)),["salamander","gecko"].includes(e.obfs)&&(t.obfs.type=e.obfs),e.obfs==="gecko"){let r=e["obfs-min-packet-size"],n=e["obfs-max-packet-size"],i=r!=null&&`${r}`!="",o=n!=null&&`${n}`!="";if(i||o){let s=i?Lu(`${r}`.trim()):void 0,a=o?Lu(`${n}`.trim()):void 0,u=a!=null?Math.min(a,2048):a,l=s??512,f=u??1200;o&&a!=null&&a>2048&&H.warn(`Gecko obfs max packet size for proxy ${e.name} exceeds 2048, clamped to 2048: ${n}`),i&&(s==null||s<=0)||o&&(a==null||a<=0)||f{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`),Do(e,t),Os(e,t),zn(e,t),Uu(e,t),Fo(e.smux,t),Kn(e,t),Vn(e,t),t},PQ=(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`),/^\d+$/.test(e["min-idle-session"])&&(t.min_idle_session=parseInt(`${e["min-idle-session"]}`,10)),e["disable-reuse"]!=null&&(t.disable_reuse=!!e["disable-reuse"]),zn(e,t),Uu(e,t),Kn(e,t),Vn(e,t),t},xQ=(e={})=>{let t=fQ(e),r={tag:e.name,type:"tailscale",control_http_client:e["control-http-client"],udp_timeout:e["udp-timeout"],state_directory:e["state-dir"]||e["state-directory"],auth_key:e["auth-key"],control_url:e["control-url"],ephemeral:e.ephemeral,hostname:e.hostname,accept_routes:e["accept-routes"],exit_node:e["exit-node"],exit_node_allow_lan_access:e["exit-node-allow-lan-access"],advertise_routes:Array.isArray(e["advertise-routes"])?e["advertise-routes"]:void 0,advertise_exit_node:e["advertise-exit-node"],advertise_tags:Array.isArray(e["advertise-tags"])?e["advertise-tags"]:void 0,relay_server_static_endpoints:Array.isArray(e["relay-server-static-endpoints"])?e["relay-server-static-endpoints"]:void 0,system_interface:e["system-interface"],system_interface_name:e["system-interface-name"]};return/^\d+$/.test(e["system-interface-mtu"])&&(r.system_interface_mtu=parseInt(`${e["system-interface-mtu"]}`,10)),/^\d+$/.test(e["relay-server-port"])&&(r.relay_server_port=parseInt(`${e["relay-server-port"]}`,10)),t||(zn(e,r),Kn(e,r),Vn(e,r)),gt(e["ssh-server"])?r.ssh_server={enabled:e["ssh-server"].enabled!==!1,disable_pty:e["ssh-server"]["disable-pty"],disable_sftp:e["ssh-server"]["disable-sftp"],disable_forwarding:e["ssh-server"]["disable-forwarding"]}:e["ssh-server"]&&(r.ssh_server=!!e["ssh-server"]),r},RQ=(e={})=>{let t=["ipv4","ipv6"].map(n=>ti(e,n)).filter(n=>n),r={system:!!e.system,mtu:e.mtu?parseInt(`${e.mtu}`,10):void 0,udp_timeout:e["udp-timeout"],workers:e.workers?parseInt(`${e.workers}`,10):void 0,tag:e.name,type:"wireguard",server:e.server,server_port:parseInt(`${e.port}`,10),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((!Array.isArray(e.peers)||e.peers.length===0)&&(e.peers=[{}]),e.peers&&e.peers.length>0){r.peers=[];for(let n of e.peers){let i,o;n.server&&n.port?(i=n.server,o=parseInt(`${n.port}`,10)):(i=r.server,o=parseInt(`${r.server_port}`,10));let s={address:i,port:o,persistent_keepalive_interval:n["persistent-keepalive-interval"]?parseInt(`${n["persistent-keepalive-interval"]}`,10):void 0,public_key:n["public-key"]||n.public_key||r.peer_public_key,pre_shared_key:n["pre-shared-key"]||n.pre_shared_key||r.pre_shared_key,allowed_ips:n["allowed-ips"]||n.allowed_ips||["0.0.0.0/0",...e.ipv6?["::/0"]:[]],reserved:[]};if(typeof n.reserved=="string")s.reserved.push(n.reserved);else if(Array.isArray(n.reserved))for(let a of n.reserved)s.reserved.push(a);else delete s.reserved;(!Array.isArray(s.reserved)||s.reserved.length===0)&&(s.reserved=r.reserved),r.peers.push(s)}}return Os(e,r),zn(e,r),Fo(e.smux,r),Kn(e,r),Vn(e,r),delete r.server,delete r.server_port,delete r.pre_shared_key,delete r.peer_public_key,delete r.reserved,r};function K2(){return{type:"ALL",produce:(r,n,i={})=>{let o=[],s=new Map(r.filter(u=>u?.plugin==="shadow-tls"&&u?.["plugin-opts"]).map(u=>[u,{plugin:u.plugin,"plugin-opts":u["plugin-opts"]?JSON.parse(JSON.stringify(u["plugin-opts"])):void 0,"obfs-opts":u["obfs-opts"]?JSON.parse(JSON.stringify(u["obfs-opts"])):void 0}]));if(wi().produce(r,"internal",{"include-unsupported-proxy":!0}).map(u=>{let l=o.length;try{let f=s.get(u);f&&(u.plugin=f.plugin,u["plugin-opts"]=f["plugin-opts"],f["obfs-opts"]?u["obfs-opts"]=f["obfs-opts"]:delete u["obfs-opts"]);let m=q2(u),p=!!(m&&(m.password||m.version!=null&&Number(m.version)!==0)),d;if(p&&["vmess","vless","trojan"].includes(u.type)){if(u["reality-opts"])throw new Error(`Platform sing-box cannot chain ShadowTLS with Reality for proxy ${u.name}`);if(["vmess","vless"].includes(u.type)&&u.network==="h2")throw new Error(`Platform sing-box cannot chain ShadowTLS with network h2 for proxy ${u.name}`);if(u.type==="vless"&&u.flow==="xtls-rprx-vision")throw new Error(`Platform sing-box cannot chain ShadowTLS with flow xtls-rprx-vision for proxy ${u.name}`);let v=m.version,g=typeof v=="string"&&v.trim()===""?NaN:Number(v??0),y=g===0?2:g;if(!Number.isInteger(y)||![1,2,3].includes(y))throw new Error(`Platform sing-box does not support shadow-tls version ${v} for proxy ${u.name}`);d=VS(u,{...m,version:y})}if(u.type==="anytls"&&p)throw new Error("Platform sing-box cannot replace AnyTLS TLS with ShadowTLS");if(["xhttp"].includes(u.network))throw new Error(`Platform sing-box does not support network: ${u.network}`);switch(u.type){case"ssh":o.push(pQ(u));break;case"http":o.push(mQ(u));break;case"socks5":if(u.tls)throw new Error(`Platform sing-box does not support proxy type: ${u.type} with tls`);o.push(gQ(u));break;case"ss":if(u.plugin==="shadow-tls"){let{ssPart:v,stPart:g}=vQ(u);o.push(v),o.push(g)}else o.push(wQ(u));break;case"ssr":if(i["include-unsupported-proxy"])o.push(yQ(u));else throw new Error(`Platform sing-box does not support proxy type: ${u.type}`);break;case"snell":{o.push(bQ(u,i["include-unsupported-proxy"]));let v=q2(u);v&&o.push(VS(u,v));break}case"vmess":if(!u.network||["tcp","ws","grpc","h2","http"].includes(u.network))o.push(_Q(u));else throw new Error(`Platform sing-box does not support proxy type: ${u.type} with network ${u.network}`);break;case"vless":if(u.encryption&&u.encryption!=="none")throw new Error("VLESS encryption is not supported");if(!u.flow||["xtls-rprx-vision"].includes(u.flow))o.push(DQ(u));else throw new Error(`Platform sing-box does not support proxy type: ${u.type} with flow ${u.flow}`);break;case"trojan":if(!u.flow)o.push(FQ(u));else throw new Error(`Platform sing-box does not support proxy type: ${u.type} with flow ${u.flow}`);break;case"naive":o.push(IQ(u));break;case"hysteria":o.push(BQ(u));break;case"hysteria2":o.push($Q(u,i["include-unsupported-proxy"]));break;case"tuic":if(!u.token||u.token.length===0)o.push(TQ(u));else throw new Error("Platform sing-box does not support proxy type: TUIC v4");break;case"wireguard":o.push(RQ(u));break;case"anytls":o.push(PQ(u));break;case"tailscale":o.push(xQ(u));break;default:throw new Error(`Platform sing-box does not support proxy type: ${u.type}`)}if(d){let v=o[l];v.detour=j2(u),delete v.tls,o.push(d)}if(i["include-unsupported-proxy"]&&u["name-cert-verify"])for(let v=l;v(["wireguard","tailscale"].includes(l.type)?u.endpoints.push(l):u.outbounds.push(l),u),{outbounds:[],endpoints:[]});return JSON.stringify(a,null,2)}}}var qEe=B(T());function V2(){return{type:"ALL",produce:(r,n,i={})=>{let o=r.filter(s=>!["http","https","socks5","ss","trojan","hysteria2","vless","vmess","tuic","wireguard","anytls","ssh","snell"].includes(s.type)||s.type==="ss"&&(s.plugin==="obfs"&&!["http","tls"].includes(s["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(s.cipher))||s.type==="vmess"&&(!["h2","http","ws","tcp","grpc"].includes(s.network)&&s.network||!M7(s))||s.type==="trojan"&&!["http","ws","tcp"].includes(s.network)&&s.network||s.type==="vless"&&(!["h2","http","ws","tcp","grpc"].includes(s.network)&&s.network||!M7(s)||typeof s.flow<"u"&&!["xtls-rprx-vision",""].includes(s.flow))||s.type==="tuic"&&s.token&&s.token.length!==0||s.type==="snell"&&q7(s.version)===null||["anytls"].includes(s.type)&&s.network&&!["tcp"].includes(s.network)?!1:!(["ws"].includes(s.network)&&s["ws-opts"]?.["v2ray-http-upgrade"])).map(s=>{let a=s;try{let u={...s},l;s.tls&&!s.sni&&(s.sni=s.server);let f=s.prev_hop||s["underlying-proxy"]||s["dialer-proxy"]||s.detour;if(s.type==="http")s={type:s.tls?"https":"http",name:s.name,server:s.server,port:s.port,username:s.username,password:s.password,...L7(s)?{headers:s.headers}:{},tfo:Io(s),...s.tls?{sni:s.sni,skip_tls_verify:s["skip-cert-verify"],reality:lf(s)}:{}};else if(s.type==="https")s={type:"https",name:s.name,server:s.server,port:s.port,username:s.username,password:s.password,...L7(s)?{headers:s.headers}:{},tfo:Io(s),sni:s.sni,skip_tls_verify:s["skip-cert-verify"],reality:lf(s)};else if(s.type==="socks5")s={type:s.tls?"socks5_tls":"socks5",name:s.name,server:s.server,port:s.port,username:s.username,password:s.password,tfo:Io(s),udp_relay:Mc(s),...s.tls?{sni:s.sni,skip_tls_verify:s["skip-cert-verify"],reality:lf(s)}:{}};else if(s.type==="ss"){if(s={type:"shadowsocks",name:s.name,method:s.cipher==="chacha20-ietf-poly1305"?"chacha20-poly1305":s.cipher,server:s.server,port:s.port,password:s.password,tfo:Io(s),udp_relay:Mc(s)},pe(u,"plugin")){if(u.plugin==="obfs")s.obfs=u["plugin-opts"].mode,s.obfs_host=u["plugin-opts"].host,s.obfs_uri=u["plugin-opts"].path;else if(!["shadow-tls"].includes(u.plugin))throw new Error(`plugin ${u.plugin} is not supported`)}}else if(s.type==="hysteria2")s={type:"hysteria2",name:s.name,server:s.server,port:s.port,auth:s.password,...pe(s,"up")?{bandwidth:parseInt(`${s.up}`.match(/\d+/)?.[0]||0,10)}:{},tfo:Io(s),udp_relay:Mc(s),sni:s.sni,skip_tls_verify:s["skip-cert-verify"],port_hopping:s.ports,port_hopping_interval:s["hop-interval"]},u["obfs-password"]&&u.obfs=="salamander"&&(s.obfs="salamander",s.obfs_password=u["obfs-password"]);else if(s.type==="tuic")s={type:"tuic",name:s.name,server:s.server,port:s.port,uuid:s.uuid,password:s.password,sni:s.sni,alpn:Array.isArray(s.alpn)?s.alpn:[s.alpn||"h3"],skip_tls_verify:s["skip-cert-verify"],port_hopping:s.ports,port_hopping_interval:s["hop-interval"]};else if(s.type==="trojan")s.network==="ws"&&(s.websocket={path:s["ws-opts"]?.path,host:s["ws-opts"]?.headers?.Host}),s={type:"trojan",name:s.name,server:s.server,port:s.port,password:s.password,tfo:Io(s),udp_relay:Mc(s),sni:s.sni,skip_tls_verify:s["skip-cert-verify"],reality:lf(s),websocket:s.websocket};else if(s.type==="anytls")s={type:"anytls",name:s.name,server:s.server,port:s.port,password:s.password,tfo:Io(s),udp_relay:Mc(s),sni:s.sni,skip_tls_verify:s["skip-cert-verify"],reality:lf(s)};else if(s.type==="vmess"){let p=jn(s.cipher);s.network==="ws"?s.transport={[s.tls?"wss":"ws"]:{path:s["ws-opts"]?.path,headers:{Host:s["ws-opts"]?.headers?.Host},sni:s.tls?s.sni:void 0,skip_tls_verify:s.tls?s["skip-cert-verify"]:void 0}}:s.network==="http"?s.transport={http1:{method:s["http-opts"]?.method,path:Array.isArray(s["http-opts"]?.path)?s["http-opts"]?.path[0]:s["http-opts"]?.path,headers:{Host:Array.isArray(s["http-opts"]?.headers?.Host)?s["http-opts"]?.headers?.Host[0]:s["http-opts"]?.headers?.Host},skip_tls_verify:s["skip-cert-verify"]}}:s.network==="h2"?s.transport={http2:{method:s["h2-opts"]?.method,path:Array.isArray(s["h2-opts"]?.path)?s["h2-opts"]?.path[0]:s["h2-opts"]?.path,headers:j7(s["h2-opts"]),sni:s.sni,skip_tls_verify:s["skip-cert-verify"]}}:s.network==="grpc"?s.transport=H7(s):(s.network==="tcp"||!s.network)&&s.tls&&(s.transport={tls:{sni:s.tls?s.sni:void 0,skip_tls_verify:s.tls?s["skip-cert-verify"]:void 0}});let d=!1;(pe(s,"aead")&&!s.aead||pe(s,"alterId")&&s.alterId!==0)&&(d=!0),s={type:"vmess",name:s.name,server:s.server,port:s.port,user_id:s.uuid,security:p,tfo:Io(s),legacy:d,udp_relay:Mc(s),transport:s.transport}}else if(s.type==="vless"){if(s.encryption&&s.encryption!=="none")throw new Error("VLESS encryption is not supported");s.network==="ws"?s.transport={[s.tls?"wss":"ws"]:{path:s["ws-opts"]?.path,headers:{Host:s["ws-opts"]?.headers?.Host},sni:s.tls?s.sni:void 0,skip_tls_verify:s.tls?s["skip-cert-verify"]:void 0}}:s.network==="http"?s.transport={http:{method:s["http-opts"]?.method,path:Array.isArray(s["http-opts"]?.path)?s["http-opts"]?.path[0]:s["http-opts"]?.path,headers:{Host:Array.isArray(s["http-opts"]?.headers?.Host)?s["http-opts"]?.headers?.Host[0]:s["http-opts"]?.headers?.Host},skip_tls_verify:s["skip-cert-verify"]}}:s.network==="h2"?s.transport={http2:{method:s["h2-opts"]?.method,path:Array.isArray(s["h2-opts"]?.path)?s["h2-opts"]?.path[0]:s["h2-opts"]?.path,headers:j7(s["h2-opts"]),sni:s.sni,skip_tls_verify:s["skip-cert-verify"]}}:s.network==="grpc"?s.transport=H7(s):(s.network==="tcp"||!s.network)&&(s.transport={[s.tls?"tls":"tcp"]:{sni:s.tls?s.sni:void 0,skip_tls_verify:s.tls?s["skip-cert-verify"]:void 0,reality:lf(s)}},l=s.flow,l===""&&(l=void 0)),s={type:"vless",name:s.name,server:s.server,port:s.port,user_id:s.uuid,security:s.cipher,tfo:Io(s),udp_relay:Mc(s),transport:s.transport,flow:l}}else if(s.type==="wireguard")Array.isArray(s.peers)&&s.peers.length>0&&(s.server=s.peers[0].server,s.port=s.peers[0].port,s.ip=s.peers[0].ip,s.ipv6=s.peers[0].ipv6,s["public-key"]=s.peers[0]["public-key"],s["preshared-key"]=s.peers[0]["pre-shared-key"],s["allowed-ips"]=s.peers[0]["allowed-ips"],s.reserved=s.peers[0].reserved),s={type:"wireguard",name:s.name,local_ipv4:ti(s,"ipv4"),local_ipv6:ti(s,"ipv6"),server:s.server,port:s.port,private_key:s["private-key"],peer_public_key:s["public-key"],preshared_key:s["preshared-key"],reserved:s.reserved?Array.isArray(s.reserved)?s.reserved:s.reserved.split(/\s*\/\s*/).map(p=>p.trim()).filter(p=>p.length>0):void 0,dns_servers:s.dns?Array.isArray(s.dns)?s.dns:s.dns.split(/\s*,\s*/).map(p=>p.trim()).filter(p=>p.length>0):void 0,mtu:s.mtu,keepalive:s.keepalive};else if(s.type==="ssh")s={type:"ssh",name:s.name,server:s.server,port:s.port,username:s.username,password:s.password,private_key:s["private-key"],host_keys:s["host-key"],tfo:Io(s)};else if(s.type==="snell"){let p=q7(s.version);s={type:"snell",name:s.name,server:s.server,port:s.port,psk:s.psk,version:p,...p==null||p>=3?{udp_relay:Mc(s)}:{},reuse:s.reuse,obfs:s["obfs-opts"]?.mode||s.obfs,obfs_host:s["obfs-opts"]?.host||s["obfs-host"]||s.obfs_host,tfo:Io(s)}}if(["http","https","socks5","ss","trojan","vless","vmess","anytls","ssh","snell"].includes(u.type)&&["shadow-tls"].includes(u.plugin)&&u["plugin-opts"]){if(u["plugin-opts"].version!=3)throw new Error(`shadow-tls version ${u["plugin-opts"].version} is not supported`);s.shadow_tls={password:u["plugin-opts"].password,sni:u["plugin-opts"].host}}let m=NQ(u);if(m&&(LQ(u,s)&&(s.fingerprint_sha256=m),UQ(s.transport,m)),["socks5","ss","trojan","vless","vmess","wireguard","tuic","hysteria2","anytls","ssh","snell"].includes(u.type)&&(["on","true",!0,"1",1].includes(u["block-quic"])?s.block_quic=!0:["off","false",!1,"0",0].includes(u["block-quic"])&&(s.block_quic=!1)),["ss"].includes(u.type)&&s.shadow_tls&&u["udp-port"]>0&&u["udp-port"]<=65535&&(s.udp_port=u["udp-port"]),delete s.subName,delete s.collectionName,delete s.id,delete s.resolved,delete s["no-resolve"],s.transport){for(let p in s.transport)p!=="grpc"&&(Object.keys(s.transport[p]).length===0||Object.values(s.transport[p]).every(d=>d==null))&&delete s.transport[p];Object.keys(s.transport).length===0&&delete s.transport}if(n!=="internal")for(let p in s)(s[p]==null||/^_/i.test(p))&&delete s[p];return{[s.type]:{...s,type:void 0,prev_hop:f}}}catch(u){return H.error(`Cannot produce proxy: ${s.name} Reason: ${u}`),null}}).filter(Boolean);return _a(o,n,i)}}}function L7(e){return e?.headers&&typeof e.headers=="object"&&Object.keys(e.headers).length>0}function Io(e){return e.tfo??e["fast-open"]}function Mc(e){return e.udp??e.udp_relay}function U7(e){if(e!=null&&!(typeof e=="string"&&e.length===0))return e}function lf(e){let t=e?.["reality-opts"];if(!t)return;let r={},n=U7(t["public-key"]),i=U7(t["short-id"]);return n!=null&&(r.public_key=n),i!=null&&(r.short_id=i),Object.keys(r).length>0?r:void 0}function H7(e){return{grpc:{service_name:e["grpc-opts"]?.["grpc-service-name"],sni:e.sni,reality:lf(e),skip_tls_verify:e["skip-cert-verify"]}}}function M7(e){if(e.network!=="grpc")return!0;let t=e["grpc-opts"]?.["_grpc-type"];return t==null?!0:`${t}`.trim().toLowerCase()==="gun"}function q7(e){if(e==null)return;let t=`${e}`.trim();return/^[1-5]$/.test(t)?parseInt(t,10):null}function kQ(e,...t){for(let r of t){let n=YS(e?.[r]);if(n)return n}}function OQ(e){return YS(e?.host)||kQ(e?.headers,"host","Host")}function j7(e){let t={};if(e?.headers&&typeof e.headers=="object"&&!Array.isArray(e.headers))for(let[n,i]of Object.entries(e.headers)){if(/^host$/i.test(n))continue;let o=YS(i);o!=null&&(t[n]=o)}let r=OQ(e);return r&&(t.Host=r),Object.keys(t).length>0?t:void 0}function YS(e){if(Array.isArray(e))return e[0];if(e!=null)return e}function NQ(e){let t=e?.["tls-fingerprint"];if(typeof t!="string")return;let r=t.trim();return r.length>0?r:void 0}function LQ(e,t){return["anytls","https","hysteria2","trojan","tuic"].includes(e.type)||e.type==="socks5"&&t.type==="socks5_tls"||e.type==="http"&&t.type==="https"}function UQ(e,t){if(e)for(let r of["grpc","http2","tls","wss"])e[r]&&(e[r].fingerprint_sha256=t)}function K7(){return{type:"ALL",produce:(r,n)=>n==="internal"?r:JSON.stringify(r,null,2)}}var V7={qx:E0(),QX:E0(),QuantumultX:E0(),surge:Gh(),Surge:Gh(),SurgeMac:m0(),Loon:MS(),Clash:HS(),meta:wi(),clashmeta:wi(),"clash.meta":wi(),"Clash.Meta":wi(),ClashMeta:wi(),mihomo:wi(),Mihomo:wi(),uri:Wh(),URI:Wh(),v2:y0(),v2ray:y0(),V2Ray:y0(),json:K7(),JSON:K7(),stash:k2(),Stash:k2(),shadowrocket:b0(),Shadowrocket:b0(),ShadowRocket:b0(),surfboard:M2(),Surfboard:M2(),singbox:K2(),"sing-box":K2(),egern:V2(),Egern:V2()};var TAe=B(T());var uAe=B(T()),J$=B(ev()),Yee=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 shadowTLS = {}; 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 (shadowTLS.password && !shadowTLS.version) { shadowTLS.version = 2; } if (shadowTLS.password) { if (shadowTLS.version < 2) { throw new Error("shadow-tls version " + shadowTLS.version + " is not supported"); } proxy.plugin = "shadow-tls"; proxy["plugin-opts"] = { host: shadowTLS.host, password: shadowTLS.password, version: shadowTLS.version, }; if (proxy.alpn) { $set(proxy, "plugin-opts.alpn", proxy.alpn); delete proxy.alpn; } } } function stripQuotes(value) { const trimmed = value.trim(); const quote = trimmed[0]; if ( (quote === '"' || quote === "'") && trimmed[trimmed.length - 1] === quote ) { return trimmed.slice(1, -1); } return trimmed; } function readQuotedHeaderKey(text, start) { const quote = text[start]; let index = start + 1; let hasKey = false; while (index < text.length) { const char = text[index]; if (char === quote) { return hasKey ? index + 1 : -1; } hasKey = true; index++; } return -1; } function startsWithQuotedHeaderKey(text) { const trimmed = text.trim(); if (trimmed[0] !== '"' && trimmed[0] !== "'") return false; const index = readQuotedHeaderKey(trimmed, 0); if (index === -1) return false; let cursor = index; while (cursor < trimmed.length && /\s/.test(trimmed[cursor])) cursor++; return trimmed[cursor] === ":"; } function stripOuterHeadersQuotes(headers) { const trimmed = headers.trim(); const quote = trimmed[0]; if ( (quote === '"' || quote === "'") && trimmed[trimmed.length - 1] === quote && !startsWithQuotedHeaderKey(trimmed) ) { return trimmed.slice(1, -1); } return trimmed; } function isHeaderKeyStart(text, start) { let index = start; while (index < text.length && /\s/.test(text[index])) index++; if (text[index] === '"' || text[index] === "'") { index = readQuotedHeaderKey(text, index); if (index === -1) return false; } else { const keyStart = index; while ( index < text.length && /[!#$%&'*+\-.^_|~0-9A-Za-z]/.test(text[index]) ) index++; if (index === keyStart) return false; } while (index < text.length && /\s/.test(text[index])) index++; return text[index] === ":"; } function isOptionStart(text, start) { let index = start; while (index < text.length && /\s/.test(text[index])) index++; const keyStart = index; while (index < text.length && /[0-9A-Za-z-]/.test(text[index])) index++; if (index === keyStart) return false; while (index < text.length && /\s/.test(text[index])) index++; return text[index] === "="; } function isHeaderValueQuoteEnd(text, index, pairSeparator, allowCommaEnd, containerQuote) { let cursor = index + 1; while (cursor < text.length && /\s/.test(text[cursor])) cursor++; if (cursor >= text.length) return true; if (allowCommaEnd && text[cursor] === "," && isOptionStart(text, cursor + 1)) { return true; } if (text[cursor] === pairSeparator && isHeaderKeyStart(text, cursor + 1)) { return true; } if (containerQuote && text[cursor] === containerQuote) { let next = cursor + 1; while (next < text.length && /\s/.test(text[next])) next++; return next >= text.length || text[next] === ","; } return false; } function findHeaderSeparator(pair) { let quote = ""; for (let index = 0; index < pair.length; index++) { const char = pair[index]; if (quote) { if (char === quote) { quote = ""; } continue; } if (char === '"' || char === "'") { quote = char; continue; } if (char === ":") { return index; } } return -1; } function readUnquotedHeadersEnd(text, start, pairSeparator) { let index = start; let quote = ""; let quoteRole = ""; let seenSeparator = false; while (index < text.length) { const char = text[index]; if (quote) { if (char === quote) { if ( quoteRole === "key" || isHeaderValueQuoteEnd(text, index, pairSeparator, true) ) { quote = ""; quoteRole = ""; } } index++; continue; } if (char === '"' || char === "'") { quote = char; quoteRole = seenSeparator ? "value" : "key"; index++; continue; } if (char === ":" && !seenSeparator) { seenSeparator = true; index++; continue; } if (char === pairSeparator && isHeaderKeyStart(text, index + 1)) { seenSeparator = false; index++; continue; } if (char === ",") break; index++; } return index; } function readQuotedHeadersEnd(text, start, pairSeparator) { const quote = text[start]; let index = start + 1; let innerQuote = ""; let quoteRole = ""; let seenSeparator = false; while (index < text.length) { const char = text[index]; if (innerQuote) { if (char === innerQuote) { if ( quoteRole === "key" || isHeaderValueQuoteEnd(text, index, pairSeparator, false, quote) ) { innerQuote = ""; quoteRole = ""; } } index++; continue; } if (char === quote) { let cursor = index + 1; while (cursor < text.length && /\s/.test(text[cursor])) cursor++; if (cursor >= text.length || text[cursor] === ",") { return index + 1; } } if (char === '"' || char === "'") { innerQuote = char; quoteRole = seenSeparator ? "value" : "key"; index++; continue; } if (char === ":" && !seenSeparator) { seenSeparator = true; index++; continue; } if (char === pairSeparator && isHeaderKeyStart(text, index + 1)) { seenSeparator = false; index++; continue; } index++; } return text.length; } function readHeadersEnd(text, start, pairSeparator) { let index = start; while (index < text.length && /\s/.test(text[index])) index++; if ( (text[index] === '"' || text[index] === "'") && !startsWithQuotedHeaderKey(text.slice(index)) ) { return readQuotedHeadersEnd(text, index, pairSeparator); } return readUnquotedHeadersEnd(text, start, pairSeparator); } function splitHeaders(headers, pairSeparator) { const result = []; let start = 0; let quote = ""; let quoteRole = ""; let seenSeparator = false; for (let index = 0; index < headers.length; index++) { const char = headers[index]; if (quote) { if (char === quote) { if ( quoteRole === "key" || isHeaderValueQuoteEnd(headers, index, pairSeparator, false) ) { quote = ""; quoteRole = ""; } } continue; } if (char === '"' || char === "'") { quote = char; quoteRole = seenSeparator ? "value" : "key"; continue; } if (char === ":" && !seenSeparator) { seenSeparator = true; continue; } if (char === pairSeparator && isHeaderKeyStart(headers, index + 1)) { result.push(headers.slice(start, index)); start = index + 1; seenSeparator = false; } } result.push(headers.slice(start)); return result; } function parseHeaders(headers, pairSeparator) { const result = {}; splitHeaders(stripOuterHeadersQuotes(headers), pairSeparator).forEach((pair) => { const index = findHeaderSeparator(pair); if (index === -1) return; const key = stripQuotes(pair.slice(0, index)); const value = stripQuotes(pair.slice(index + 1)); if (key) { result[key] = value; } }); return result; } function normalizeVmessSecurity(security) { const normalized = String(security || "").trim().toLowerCase(); const supported = ["aes-128-gcm", "chacha20-ietf-poly1305"]; if (!supported.includes(normalized)) return "auto"; return normalized === "chacha20-ietf-poly1305" ? "chacha20-poly1305" : normalized; } function parseAlpn(value) { return stripQuotes(value) .split(",") .map((item) => item.trim()) .filter((item) => item !== ""); } } start = (anytls/shadowsocks/vmess/trojan/h2_connect/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard/hysteria2/ssh/trust_tunnel/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/alpn/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/vmess_method/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls/sni/cert_verify_name/alpn/tls_fingerprint/tls_verification/client_cert/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "vmess"; proxy.cipher = proxy.cipher || "auto"; // Surfboard 与 Surge 默认不一致, 不管 Surfboard https://getsurfboard.com/docs/profile-format/proxy/external-proxy/vmess if (proxy.aead) { proxy.alterId = 0; } else { proxy.alterId = 1; } handleWebsocket(); handleShadowTLS(); } trojan = tag equals "trojan" address (passwordk/ws/ws_path/ws_headers/tls/sni/cert_verify_name/alpn/tls_fingerprint/tls_verification/client_cert/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)? (headers/sni/cert_verify_name/alpn/tls_fingerprint/tls_verification/client_cert/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(); } h2_connect = tag equals "h2-connect" address (username password)? (usernamek passwordk)? (headers/max_streams/sni/cert_verify_name/alpn/tls_fingerprint/tls_verification/client_cert/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 = "h2-connect"; proxy.tls = true; handleShadowTLS(); } http = tag equals "http" address (username password)? (usernamek passwordk)? (headers/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_mode/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/alpn/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/client_cert/sni/cert_verify_name/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/client_cert/sni/cert_verify_name/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/cert_verify_name/alpn/tls_verification/client_cert/passwordk/tls_fingerprint/download_bandwidth/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/salamander_password/gecko_password/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/fast_open/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/cert_verify_name/alpn/tls_fingerprint/tls_verification/client_cert/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "socks5"; proxy.tls = true; handleShadowTLS(); } anytls = tag equals "anytls" address (passwordk/reuse/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/client_cert/sni/cert_verify_name/alpn/fast_open/tfo/block_quic/others)* { proxy.type = "anytls"; proxy.tls = true; } trust_tunnel = tag equals "trust-tunnel" address (usernamek/passwordk/headers/max_streams/reuse/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/client_cert/sni/cert_verify_name/alpn/fast_open/tfo/block_quic/others)* { proxy.type = "trusttunnel"; proxy.tls = true; } 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.trim().replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } password = comma match:[^,]+ { proxy.password = match.join("").replace(/^"(.*)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } tls = comma "tls" equals flag:bool { proxy.tls = flag; } sni = comma "sni" equals match:[^,]+ { const sni = match.join("").replace(/^"(.*)"$/, '$1'); if (sni === "off") { proxy["disable-sni"] = true; } else { proxy.sni = sni; } } cert_verify_name = comma "server-cert-verify-name" equals match:[^,]+ { proxy["name-cert-verify"] = stripQuotes(match.join("")); } 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(); } client_cert = comma "client-cert" equals match:[^,]+ { proxy["keystore-client-cert"] = stripQuotes(match.join("")); } snell_psk = comma "psk" equals match:[^,]+ { proxy.psk = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } snell_version = comma "version" equals match:$[0-9]+ { proxy.version = parseInt(match.trim()); } snell_mode = comma "mode" equals match:[^,]+ { const mode = stripQuotes(match.join("")).trim(); if (["default", "unshaped", "unsafe-raw"].includes(mode)) { proxy.mode = mode; } } usernamek = comma "username" equals match:[^,]+ { proxy.username = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } 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; } vmess_method = comma "encrypt-method" equals cipher:$[^,]+ { proxy.cipher = normalizeVmessSecurity(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 & { const start = peg$currPos; const index = readHeadersEnd(input, start, "|"); $.headers = input.substring(start, index); peg$currPos = index; return $.headers.trim().length > 0; } { obfs["ws-headers"] = parseHeaders($.headers, "|"); } ws_path = comma "ws-path" equals path:uri { obfs.path = path.trim().replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } headers = comma "headers" equals & { const start = peg$currPos; const index = readHeadersEnd(input, start, ";"); $.headers = input.substring(start, index); peg$currPos = index; return $.headers.trim().length > 0; } { proxy.headers = parseHeaders($.headers, ";"); } obfs = comma "obfs" equals type:("http"/"tls") { obfs.type = type; } obfs_host = comma "obfs-host" equals match:[^,]+ { obfs.host = match.join("").replace(/^"(.*)"$/, '$1'); }; 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()); } max_streams = comma "max-streams" equals match:quoted_integer { proxy["max-streams"] = match; } quoted_integer = '"' match:$[0-9]+ '"' { return parseInt(match.trim()); } / "'" match:$[0-9]+ "'" { return parseInt(match.trim()); } / match:$[0-9]+ { return 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"] = stripQuotes(match.join("")); } 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]+ { shadowTLS.version = parseInt(match.trim()); } shadow_tls_sni = comma "shadow-tls-sni" equals match:[^,]+ { shadowTLS.host = match.join(""); } shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { shadowTLS.password = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } token = comma "token" equals match:[^,]+ { proxy.token = match.join(""); } alpn = comma "alpn" equals match:quoted_value { const values = parseAlpn(match); if (values.length > 0) proxy.alpn = values; } quoted_value = '"' match:$[^"]* '"' { return match; } / "'" match:$[^']* "'" { return match; } / match:$[^,]+ { return match; } uuidk = comma "uuid" equals match:[^,]+ { proxy.uuid = match.join(""); } salamander_password = comma "salamander-password" equals match:[^,]+ { proxy['obfs-password'] = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); proxy.obfs = 'salamander'; } gecko_password = comma "gecko-password" equals match:[^,]+ { proxy['obfs-password'] = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); proxy.obfs = 'gecko'; } tag = match:[^=,]* { proxy.name = match.join("").trim(); } comma = _ "," _ equals = _ "=" _ _ = [ \r\t]* bool = b:("true"/"false") { return b === "true" } others = comma [^=,]+ equals [^=,]+ `,p6;function gs(){return p6||(p6=J$.default.generate(Yee)),p6}var lAe=B(T()),Z$=B(ev()),Wee=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 shadowTLS = {}; 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); } } function handleShadowTLS() { if (shadowTLS.password) { if (shadowTLS.version < 2) { throw new Error("shadow-tls version " + shadowTLS.version + " is not supported"); } proxy.plugin = "shadow-tls"; proxy["plugin-opts"] = { host: shadowTLS.host, password: shadowTLS.password, version: shadowTLS.version, }; if (proxy.alpn) { $set(proxy, "plugin-opts.alpn", proxy.alpn); delete proxy.alpn; } } } function normalizeVmessSecurity(security) { const normalized = String(security || "").trim().toLowerCase(); const supported = ["none", "auto", "aes-128-gcm", "chacha20-ietf-poly1305"]; if (!supported.includes(normalized)) return "auto"; return normalized === "chacha20-ietf-poly1305" ? "chacha20-poly1305" : normalized; } function loonClientFingerprint(tlsProfile) { switch (String(tlsProfile || "").trim()) { case "chrome": return "chrome"; case "ios18": case "ios26": return "ios"; } } } start = (shadowsocksr/shadowsocks/vmess/vless/trojan/https/http/socks5/hysteria2/anytls) { 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/tls_profile/alpn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/ip_mode/block_quic/others)*{ proxy.type = "ssr"; // handle ssr obfs proxy.obfs = obfs.type; handleShadowTLS(); } shadowsocks = tag equals "shadowsocks"i address method password (obfs_typev obfs_hostv)? (obfs_ss/obfs_host/obfs_uri/fast_open/udp_relay/udp_port/tls_profile/alpn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/ip_mode/block_quic/udp_over_tcp/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); } handleShadowTLS(); } vmess = tag equals "vmess"i address vmess_method uuid (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/vmess_alterId/fast_open/udp_relay/ip_mode/public_key/short_id/block_quic/others)* { proxy.type = "vmess"; proxy.cipher = proxy.cipher || "auto"; proxy.alterId = proxy.alterId || 0; handleTransport(); } vless = tag equals "vless"i address uuid (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/fast_open/udp_relay/ip_mode/flow/public_key/short_id/block_quic/others)* { proxy.type = "vless"; handleTransport(); } trojan = tag equals "trojan"i address password (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/fast_open/udp_relay/ip_mode/public_key/short_id/block_quic/others)* { proxy.type = "trojan"; handleTransport(); } anytls = tag equals "anytls"i address password (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/fast_open/udp_relay/ip_mode/public_key/short_id/block_quic/idle_session_check_interval/idle_session_timeout/min_idle_session/max_stream_count/others)* { proxy.type = "anytls"; handleTransport(); } hysteria2 = tag equals "hysteria2"i address password (tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/udp_relay/fast_open/download_bandwidth/server_ports/hop_interval/salamander_password/ecn/ip_mode/block_quic/others)* { proxy.type = "hysteria2"; } https = tag equals "https"i address (username password)? (tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/fast_open/udp_relay/ip_mode/block_quic/others)* { proxy.type = "http"; proxy.tls = true; } http = tag equals "http"i address (username password)? (fast_open/udp_relay/ip_mode/block_quic/others)* { proxy.type = "http"; } socks5 = tag equals "socks5"i address (username password)? (over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/fast_open/udp_relay/ip_mode/block_quic/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; } vmess_method = comma cipher:$[^,]+ { proxy.cipher = normalizeVmessSecurity(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 match:[^,]+ { obfs.host = match.join("").replace(/^"(.*)"$/, '$1'); } 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 match:[^,]+ { transport.host = match.join("").replace(/^"(.*)"$/, '$1'); } 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]+ { shadowTLS.version = parseInt(match.trim()); } shadow_tls_sni = comma "shadow-tls-sni" equals match:[^,]+ { shadowTLS.host = match.join(""); } shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { shadowTLS.password = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } over_tls = comma "over-tls" equals flag:bool { proxy.tls = flag; } tls_name = comma sni:("tls-name") equals match:[^,]+ { proxy.sni = match.join("").replace(/^"(.*)"$/, '$1'); } sni = comma "sni" equals match:[^,]+ { proxy.sni = match.join("").replace(/^"(.*)"$/, '$1'); } 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'); } tls_profile = comma "tls-profile" equals match:[^,]+ { const tlsProfile = match.join("").replace(/^"(.*)"$/, '$1').trim(); proxy["_loon_tls_profile"] = tlsProfile; const clientFingerprint = loonClientFingerprint(tlsProfile); if (clientFingerprint) proxy["client-fingerprint"] = clientFingerprint; } alpn = comma "alpn" equals '"' match:$[^"]* '"' { const values = match .split(",") .map((item) => item.trim()) .filter((item) => item !== ""); if (values.length > 0) proxy.alpn = values; } 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(""); } server_ports = comma "server-ports" equals '"' match:$[^"]+ '"' { proxy.ports = match.trim().replace(/\s*-\s*/g, "-").replace(/\s*,\s*/g, ","); } hop_interval = comma "hop-interval" equals match:$[0-9]+ { proxy["hop-interval"] = parseInt(match, 10); } salamander_password = comma "salamander-password" equals match:[^,]+ { proxy['obfs-password'] = match.join(""); proxy.obfs = 'salamander'; } block_quic = comma "block-quic" equals flag:bool { if(flag) proxy["block-quic"] = "on"; else proxy["block-quic"] = "off"; } idle_session_check_interval = comma "idle-session-check-interval" equals match:$[0-9]+ { proxy["idle-session-check-interval"] = parseInt(match.trim()); } idle_session_timeout = comma "idle-session-timeout" equals match:$[0-9]+ { proxy["idle-session-timeout"] = parseInt(match.trim()); } min_idle_session = comma "min-idle-session" equals match:$[0-9]+ { proxy["min-idle-session"] = parseInt(match.trim()); } max_stream_count = comma "max-stream-count" equals match:$[0-9]+ { proxy["max-stream-count"] = parseInt(match.trim()); } udp_over_tcp = comma "udp-over-tcp" equals flag:bool { proxy["udp-over-tcp"] = true; proxy["udp-over-tcp-version"] = 2; } tag = match:[^=,]* { proxy.name = match.join("").trim(); } comma = _ "," _ equals = _ "=" _ _ = [ \r\t]* bool = b:("true"/"false") { return b === "true" } others = comma [^=,]+ equals [^=,]+ `,m6;function Bo(){return m6||(m6=Z$.default.generate(Wee)),m6}var hAe=B(T()),Q$=B(ev()),Xee=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 setQxHttpObfs(type) { // Preserve the original QX http-obfs token for round-trip output, // including the upstream "vemss-http" typo that appears in QX // examples. proxy._qx_obfs_http = type; obfs.type = "http"; return type; } 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; // Some QX share links use obfs-host as the TLS server name for // plain over-tls TCP nodes instead of the explicit tls-host field. // Accept it as a compatibility alias, but do not override tls-host. if (obfs.host && !proxy.sni) { proxy.sni = obfs.host; } } 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/anytls/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/reality_base64_pubkey/reality_hex_shortid/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_new/fast_open/tag/server_check_url/reality_base64_pubkey/reality_hex_shortid/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') { proxy.tls = true; if (obfs.host) { proxy.sni = obfs.host; } } if (obfs.type && obfs.type !== 'over-tls') { $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_vmess/obfs_host/obfs_uri/udp_relay/udp_over_tcp/fast_open/aead/server_check_url/reality_base64_pubkey/reality_hex_shortid/others)* { proxy.type = "vmess"; proxy.cipher = proxy.cipher || "none"; if (proxy.aead === false) { proxy.alterId = 1; } else { 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_vless/obfs_host/obfs_uri/udp_relay/udp_over_tcp/fast_open/aead/server_check_url/reality_base64_pubkey/reality_hex_shortid/vless_flow/others)* { proxy.type = "vless"; proxy.cipher = proxy.cipher || "none"; handleObfs(); } anytls = "anytls" equals address (password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/udp_relay/fast_open/server_check_url/reality_base64_pubkey/reality_hex_shortid/others)* { proxy.type = "anytls"; proxy.tls = true; } 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/reality_base64_pubkey/reality_hex_shortid/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/reality_base64_pubkey/reality_hex_shortid/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"); } udp_over_tcp_new = comma "udp-over-tcp" equals param:$[^=,]+ { if (param === "sp.v1") { proxy["udp-over-tcp"] = true; proxy["udp-over-tcp-version"] = 1; } else if (param === "sp.v2") { proxy["udp-over-tcp"] = true; proxy["udp-over-tcp-version"] = 2; } else if (param === "true") { proxy["_ssr_python_uot"] = true; } else { throw new Error("Invalid value for udp-over-tcp"); } } 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 sni:("tls-host") equals match:[^,]+ { proxy.sni = match.join("").replace(/^"(.*)"$/, '$1'); } tls_verification = comma "tls-verification" equals raw:$[^,]+ { const value = raw.trim(); if (value === "true" || value === "false") { proxy["skip-cert-verify"] = value !== "true"; } else { proxy["name-cert-verify"] = value; } } 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:("tls"/"wss"/"ws"/"over-tls") { obfs.type = type; return type; } / type:("http"/"vmess-http"/"vemss-http"/"shadowsocks-http") { // QX accepts multiple http-obfs spellings for ss/vmess/vless; keep // the original token so QX output can round-trip it unchanged. return setQxHttpObfs(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_vmess = comma "obfs" equals ( type:("wss"/"ws"/"over-tls") { obfs.type = type; return type; } / type:("http"/"vmess-http"/"vemss-http"/"shadowsocks-http") { // QX accepts multiple http-obfs spellings for ss/vmess/vless; keep // the original token so QX output can round-trip it unchanged. return setQxHttpObfs(type); } ); obfs_vless = comma "obfs" equals ( type:("wss"/"ws"/"over-tls") { obfs.type = type; return type; } / type:("http"/"vmess-http"/"vemss-http"/"shadowsocks-http") { // QX accepts multiple http-obfs spellings for ss/vmess/vless; keep // the original token so QX output can round-trip it unchanged. return setQxHttpObfs(type); } ); obfs_host = comma "obfs-host" equals match:[^,]+ { obfs.host = match.join("").replace(/^"(.*)"$/, '$1'); } 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; } reality_base64_pubkey = comma "reality-base64-pubkey" equals param:$[^=,]+ { $set(proxy, "reality-opts.public-key", param); } reality_hex_shortid = comma "reality-hex-shortid" equals param:$[^=,]+ { $set(proxy, "reality-opts.short-id", param); } vless_flow = comma "vless-flow" equals param:$[^=,]+ { proxy["flow"] = 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" } `,g6;function Fa(){return g6||(g6=Q$.default.generate(Xee)),g6}var gAe=B(T());var Jee=new Set(["__proto__","constructor","prototype"]),v6;function Mu(e,t,r){if(Object(e)!==e)return e;if(Array.isArray(t)||(t=t.toString().match(/[^.[\]]+/g)||[]),t.some(n=>Jee.has(n)))throw new Error("Unsafe property path");return t.slice(0,-1).reduce((n,i,o)=>Object.prototype.hasOwnProperty.call(n,i)&&Object(n[i])===n[i]?n[i]:n[i]=Math.abs(t[o+1])>>0===+t[o+1]?[]:{},e)[t[t.length-1]]=r,e}function tv(e){if(e!=null)return/(TRUE)|1/i.test(e)}function eT(e){return Lu(e)!=null}function w6(e){try{return decodeURIComponent(e)}catch{return e}}function Zee(e){let t={},r=e.match(/^trojan:\/\/([^@]+)@(\[[^\]]+\]|[^/?#]+):(\d+)(?:\/)?(?:\?([^#]*))?(?:#(.*))?$/);if(!r)throw new Error("Invalid trojan url");let[,n,i,o,s,a]=r,u=i.replace(/^\[|\]$/g,"");if((i.startsWith("[")||i.includes(":"))&&!_r(u))throw new Error(`Invalid server: ${i}`);if(t.type="trojan",t.password=w6(n),t.server=i,t.port=Number(o),!Number.isSafeInteger(t.port)||t.port<1||t.port>65535)throw new Error(`Invalid port: ${o}`);t.name=a?w6(a):`${i}:${o}`;let l={};if(s)for(let f of s.split("&")){let m=f.indexOf("="),p=m===-1?f:f.slice(0,m);l[p]=m===-1?!0:w6(f.slice(m+1))}if(t["skip-cert-verify"]=tv(l.allowInsecure),t.sni=l.sni||l.peer,t["client-fingerprint"]=l.fp,t["tls-fingerprint"]=l.pcs,t._vcn=l.vcn?.split(",").map(f=>f.trim()).filter(Boolean),t["name-cert-verify"]=t._vcn?.[0],l.alpn&&(t.alpn=l.alpn.split(",")),tv(l.ws)&&(t.network="ws",Mu(t,"ws-opts.path",l.wspath)),l.type){let f=!1,m="",p="";if(t.network=l.type,t.network==="httpupgrade"&&(t.network="ws",f=!0),t.network==="grpc")t["grpc-opts"]={"grpc-service-name":l.serviceName,"_grpc-type":l.mode,"_grpc-authority":l.authority};else{if(l.path){let d=l.path;if(t.network==="ws"){let v=p0(d,"ed");eT(v)&&(d=ri(d,"ed").path,f?m=v:p=v)}Mu(t,`${t.network}-opts.path`,d)}l.host&&Mu(t,`${t.network}-opts.headers.Host`,l.host),f?(m=m||(eT(l.ed)?String(l.ed):""),Mu(t,"ws-opts.v2ray-http-upgrade",!0),m&&(Mu(t,"ws-opts.v2ray-http-upgrade-fast-open",!0),Mu(t,"ws-opts._v2ray-http-upgrade-ed",m))):t.network==="ws"&&p&&(Mu(t,"ws-opts.max-early-data",Lu(p)),Mu(t,"ws-opts.early-data-header-name","Sec-WebSocket-Protocol"))}if(l.security==="reality"){let d={};l.pbk&&(d["public-key"]=l.pbk),l.sid&&(d["short-id"]=l.sid),l.spx&&(d["_spider-x"]=l.spx),l.mode&&(t._mode=l.mode),l.extra&&(t._extra=l.extra),Object.keys(d).length&&Mu(t,"reality-opts",d)}}return t.udp=tv(l.udp),t.tfo=tv(l.tfo),t}function y6(){return v6||(v6={parse:Zee}),v6}var S6=B(A6());var Ia=B(Tp());function tT(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 rT(e){let[t,r,n]=/^(.*?)(?:#(.*?))?$/.exec(e);return{content:r,fragment:n!=null?decodeURIComponent(n):void 0}}function Qee(e){let t=e.indexOf(":");if(t!==-1)return[decodeURIComponent(e.slice(0,t)),decodeURIComponent(e.slice(t+1))].join(":");let r=decodeURIComponent(e);return r.includes(":")?r:_t.decode(r)}function C6(e){return e==null||!/^\d+$/.test(`${e}`)?!1:Number.isSafeInteger(parseInt(`${e}`,10))}function _6(e){let t=p0(e,"ed");return C6(t)?{path:ri(e,"ed").path,ed:t}:{path:e,ed:""}}function D6(e){let t=`${e}`;if(!/^\d+$/.test(t))throw new Error(`bad WebSocket max early data size: ${e}`);let r=parseInt(t,10);if(!Number.isSafeInteger(r))throw new Error(`bad WebSocket max early data size: ${e}`);return r}function F6(e){if(Array.isArray(e))return e.flatMap(r=>F6(r)||[]);if(typeof e!="string")return e==null?void 0:[e];let t=e.split(",").map(r=>r.trim()).filter(Boolean);return t.length>0?t:void 0}function ete(e){if(e==null)return null;let t=`${e}`.trim();if(!t)return null;let[,r=t,n]=/^(.*?)(?:\/(\d+))?$/.exec(t)||[],i=`${r}`.trim().replace(/^\[/,"").replace(/\]$/,""),o=(s,a)=>{if(s==null||!/^\d+$/.test(s))return;let u=parseInt(s,10);if(!(u<0||u>a))return u};return Gr(i)?{family:"ipv4",address:i,cidr:o(n,32)}:_r(i)?{family:"ipv6",address:i,cidr:o(n,128)}:null}function tte(){return{name:"URI PROXY Parser",test:n=>/^(socks5\+tls|socks5|http|https):\/\//.test(n),parse:n=>{let[i,o,s,a,u,l,f,m,p]=n.match(/^(socks5|http|http)(\+tls|s)?:\/\/(?:(.*?):(.*?)@)?(.*?)(?::(\d+?))?\/?(\?.*?)?(?:#(.*?))?$/);if(f)f=parseInt(f,10);else{if(s)f=443;else if(o==="http")f=80;else throw H.error(`port is not present in line: ${n}`),new Error(`port is not present in line: ${n}`);H.info(`port is not present in line: ${n}, set to ${f}`)}return{name:p!=null?decodeURIComponent(p):`${o} ${l}:${f}`,type:o,tls:!!s,server:l,port:f,username:a!=null?decodeURIComponent(a):void 0,password:u!=null?decodeURIComponent(u):void 0}}}}function rte(){return{name:"URI SOCKS Parser",test:n=>/^socks:\/\//.test(n),parse:n=>{let[i,o,s,a,u,l,f]=n.match(/^(socks)?:\/\/(?:(.*)@)?(.*?)(?::(\d+?))?(\?.*?)?(?:#(.*?))?$/);if(u)u=parseInt(u,10);else throw H.error(`port is not present in line: ${n}`),new Error(`port is not present in line: ${n}`);let m,p;if(s){let v=_t.decode(decodeURIComponent(s)).split(":");m=v[0],p=v[1]}return{name:f!=null?decodeURIComponent(f):`${o} ${a}:${u}`,type:"socks5",server:a,port:u,username:m,password:p}}}}function nte(){return{name:"URI SS Parser",test:n=>/^ss:\/\//.test(n),parse:n=>{let{content:i,fragment:o}=rT(n.split("ss://")[1]),s={type:"ss"},a=i.match(/@([^/?]*)(\/|\?|$)/),u=Qee(i.split("@")[0]),l="";if(a)i.includes("?")&&(l=i.match(/(\?.*)$/)[1]);else{if(i.includes("?")){let w=i.match(/^(.*)(\?.*)$/);i=w[1],l=w[2]}if(i=_t.decode(i),l){if(/(&|\?)v2ray-plugin=/.test(l)){let E=l.match(/(&|\?)v2ray-plugin=(.*?)(&|$)/)[2];E&&(s.plugin="v2ray-plugin",s["plugin-opts"]=JSON.parse(_t.decode(E)))}i=`${i}${l}`}u=i.match(/(^.*)@/)?.[1],a=i.match(/@([^/@]*)(\/|$)/)}let f={};for(let w of l.replace(/^\?/,"").split("&"))if(w){let[E,S]=w.split("="),D=S;D=decodeURIComponent(S),f[E]=D}if(s.tls=f.security&&f.security!=="none",s["skip-cert-verify"]=!!f.allowInsecure,s.sni=f.sni||f.peer,s["client-fingerprint"]=f.fp,s.alpn=f.alpn?decodeURIComponent(f.alpn).split(","):void 0,f.ws&&(s.network="ws",Ia.default.set(s,"ws-opts.path",f.wspath)),f.type){let w,E="",S="";if(s.network=f.type,s.network==="httpupgrade"&&(s.network="ws",w=!0),["grpc"].includes(s.network))s[s.network+"-opts"]={"grpc-service-name":f.serviceName,"_grpc-type":f.mode,"_grpc-authority":f.authority};else{if(f.path){let D=f.path;if(s.network==="ws"){let F=_6(D);D=F.path,w?E=F.ed:S=F.ed}Ia.default.set(s,s.network+"-opts.path",D)}f.host&&Ia.default.set(s,s.network+"-opts.headers.Host",decodeURIComponent(f.host)),w?(E=E||(C6(f.ed)?`${f.ed}`:""),Ia.default.set(s,s.network+"-opts.v2ray-http-upgrade",!0),E!==""&&(Ia.default.set(s,s.network+"-opts.v2ray-http-upgrade-fast-open",!0),Ia.default.set(s,s.network+"-opts._v2ray-http-upgrade-ed",E))):s.network==="ws"&&S!==""&&(Ia.default.set(s,s.network+"-opts.max-early-data",D6(S)),Ia.default.set(s,s.network+"-opts.early-data-header-name","Sec-WebSocket-Protocol"))}if(["reality"].includes(f.security)){let D={};f.pbk&&(D["public-key"]=f.pbk),f.sid&&(D["short-id"]=f.sid),f.spx&&(D["_spider-x"]=f.spx),f.mode&&(s._mode=f.mode),f.extra&&(s._extra=f.extra),Object.keys(D).length>0&&Ia.default.set(s,f.security+"-opts",D)}}s.udp=!!f.udp;let m=a[1],p=m.lastIndexOf(":");s.server=m.substring(0,p),s.port=`${m.substring(p+1)}`.match(/\d+/)?.[0];let d=u.match(/(^.*?):(.*$)/);s.cipher=d?.[1],s.password=d?.[2];let v=i.match(/[?&]plugin=([^&]+)/),g=i.match(/[?&]shadow-tls=([^&]+)/),y=i.match(/[?&]gost=([^&]+)/);if(v){let w=("plugin="+decodeURIComponent(v[1])).split(";"),E={};for(let S of w){let D=S.indexOf("=");if(D===-1){S&&(E[S]=!0);continue}let F=S.slice(0,D),M=S.slice(D+1).replace(/\\=/g,"=");F&&(E[F]=M||!0)}switch(E.plugin){case"obfs-local":case"simple-obfs":s.plugin="obfs",s["plugin-opts"]={mode:E.obfs,host:Vt(E["obfs-host"])};break;case"v2ray-plugin":s.plugin="v2ray-plugin",s["plugin-opts"]={mode:Vt(E.obfs)||Vt(E.mode)||"websocket",host:Vt(E["obfs-host"])||Vt(E.host),path:Vt(E.path),tls:eu(E.tls),sni:eu(E.sni),"skip-cert-verify":["1","true",1,!0].includes(E["skip-cert-verify"]),mux:/^\d+$/.test(E.mux)?parseInt(E.mux,10):void 0};break;case"shadow-tls":{s.plugin="shadow-tls";let S=Vt(E.version);s["plugin-opts"]={host:Vt(E.host),password:Vt(E.password),version:S?parseInt(S,10):void 0};break}default:throw new Error(`Unsupported plugin option: ${E.plugin}`)}}if(g){let w=JSON.parse(_t.decode(g[1])),E=Vt(w.version),S=Vt(w.address),D=Vt(w.port);s.plugin="shadow-tls",s["plugin-opts"]={host:Vt(w.host),password:Vt(w.password),version:E?parseInt(E,10):void 0},S&&(s.server=S),D&&(s.port=parseInt(D,10))}if(y){let w=JSON.parse(_t.decode(decodeURIComponent(y[1]))),E=Vt(w.address),S=Vt(w.port),D=Vt(w.route),F=D?.trim().toLowerCase(),M=["ws","wss","websocket"].includes(F);s.plugin="gost-plugin",s["plugin-opts"]={mode:M?"websocket":D,host:Vt(w.host),path:Vt(w.path)},F==="wss"&&(s["plugin-opts"].tls=!0),E&&(s.server=E),S&&(s.port=parseInt(S,10))}return/(&|\?)uot=(1|true)/i.test(l)&&(s["udp-over-tcp"]=!0),/(&|\?)tfo=(1|true)/i.test(l)&&(s.tfo=!0),s.name=o??`SS ${s.server}:${s.port}`,s}}}function ste(){return{name:"URI SSR Parser",test:n=>/^ssr:\/\//.test(n),parse:n=>{n=_t.decode(n.split("ssr://")[1]);let i=n.indexOf(":origin");i===-1&&(i=n.indexOf(":auth_"));let o=n.substring(0,i),s=o.substring(0,o.lastIndexOf(":")),a=o.substring(o.lastIndexOf(":")+1),u=n.substring(i+1).split("/?")[0].split(":"),l={type:"ssr",server:s,port:a,protocol:u[0],cipher:u[1],obfs:u[2],password:_t.decode(u[3])},f={};if(n=n.split("/?")[1].split("&"),n.length>1)for(let m of n){let[p,d]=m.split("=");d=d.trim(),d.length>0&&d!=="(null)"&&(f[p]=d)}return l={...l,name:f.remarks?_t.decode(f.remarks):l.server,"protocol-param":Vt(_t.decode(f.protoparam||"").replace(/\s/g,"")),"obfs-param":Vt(_t.decode(f.obfsparam||"").replace(/\s/g,""))},l}}}function ite(){return{name:"URI VMess Parser",test:n=>/^vmess:\/\//.test(n),parse:n=>{let{content:i,fragment:o}=rT(n.split("vmess://")[1]),s=_t.decode(i.replace(/\?.*?$/,""));if(/=\s*vmess/.test(s)){let a=s.split(",").map(f=>f.trim()),u={};for(let f of a)if(f.indexOf("=")!==-1){let[m,p]=f.split("=");u[m.trim()]=p.trim()}let l={name:a[0].split("=")[0].trim(),type:"vmess",server:a[1],port:a[2],cipher:jn(Vt(a[3],"auto")),uuid:a[4].match(/^"(.*)"$/)[1],tls:u.obfs==="wss",udp:eu(u["udp-relay"]),tfo:eu(u["fast-open"]),"skip-cert-verify":Hf(u["tls-verification"])?!u["tls-verification"]:void 0};if(Hf(u.obfs))if(u.obfs==="ws"||u.obfs==="wss"){l.network="ws",l["ws-opts"].path=(Vt(u["obfs-path"])||'"/"').match(/^"(.*)"$/)[1];let f=u["obfs-header"];f&&f.indexOf("Host")!==-1&&(f=f.match(/Host:\s*([a-zA-Z0-9-.]*)/)[1]),nt(f)&&(l["ws-opts"].headers={Host:f})}else throw new Error(`Unsupported obfs: ${u.obfs}`);return nt(o)&&(l.name=o),l}else{let a={};try{a=JSON.parse(s)}catch{let[d,v,g]=/(^[^?]+?)\/?\?(.*)$/.exec(i);s=_t.decode(v);for(let F of g.split("&")){let[M,z]=F.split("="),C=z;C=decodeURIComponent(z),C.indexOf(",")===-1?a[M]=C:a[M]=C.split(",")}let[y,w,E,S,D]=/(^[^:]+?):([^:]+?)@(.*):(\d+)$/.exec(s);a.scy=w,a.id=E,a.port=D,a.add=S}let u=a.add,l=parseInt(eu(a.port),10),f={name:a.ps??a.remarks??a.remark??`VMess ${u}:${l}`,type:"vmess",server:u,port:l,cipher:jn(a.scy),uuid:a.id,alterId:parseInt(eu(a.aid??a.alterId,0),10),tls:["tls",!0,1,"1"].includes(a.tls),"skip-cert-verify":Hf(a.verify_cert)?!a.verify_cert:void 0};!f["skip-cert-verify"]&&Hf(a.allowInsecure)&&(f["skip-cert-verify"]=/(TRUE)|1/i.test(a.allowInsecure)),f.tls&&(a.sni&&a.sni!==""?f.sni=a.sni:a.peer&&a.peer!==""&&(f.sni=a.peer));let m=!1;if(a.net==="ws"||a.obfs==="websocket"?f.network="ws":["http"].includes(a.obfs)||["http"].includes(a.type)?f.network="http":a.net==="http"?f.network="h2":["grpc","kcp","quic"].includes(a.net)?f.network=a.net:a.net==="httpupgrade"||f.network==="httpupgrade"?(f.network="ws",m=!0):(a.net==="h2"||f.network==="h2")&&(f.network="h2"),f.network){let p=a.host??a.obfsParam;try{let w=JSON.parse(p)?.Host;w&&(p=w)}catch{}let d=a.path,v="",g="";if(f.network==="ws"&&d){let y=_6(d);d=y.path,m?v=y.ed:g=y.ed}if(["ws"].includes(f.network)&&(d=d||"/"),f.network==="http"?(p&&(p=p.split(",").map(y=>y.trim()),p=Array.isArray(p)?p[0]:p),d?d=Array.isArray(d)?d[0]:d:d="/"):f.network==="h2"&&(d||(d="/")),d||p||["kcp","quic"].includes(f.network))if(["grpc"].includes(f.network))f[`${f.network}-opts`]={"grpc-service-name":Vt(d),"_grpc-type":Vt(a.type),"_grpc-authority":Vt(a.authority)};else if(["kcp","quic"].includes(f.network))f[`${f.network}-opts`]={[`_${f.network}-type`]:Vt(a.type),[`_${f.network}-host`]:Vt(Vt(p)),[`_${f.network}-path`]:Vt(d)};else{let y={path:Vt(d)},w=Vt(p);if(f.network==="h2"){let E=F6(w);E&&(y.host=E)}else y.headers={Host:w};m?(y["v2ray-http-upgrade"]=!0,v=v||(C6(a.ed)?`${a.ed}`:""),v!==""&&(y["v2ray-http-upgrade-fast-open"]=!0,y["_v2ray-http-upgrade-ed"]=v)):f.network==="ws"&&g!==""&&(y["max-early-data"]=D6(g),y["early-data-header-name"]="Sec-WebSocket-Protocol"),f[`${f.network}-opts`]=y}else delete f.network}return f["client-fingerprint"]=a.fp,f.alpn=a.alpn?a.alpn.split(","):void 0,nt(o)&&(f.name=o),f}}}}function nT(){return{name:"URI VLESS Parser",test:n=>/^vless:\/\//.test(n),parse:n=>{let i=_=>{if(!gt(_))return;let R={},K={maxConnections:"max-connections",maxConcurrency:"max-concurrency",cMaxReuseTimes:"c-max-reuse-times",hMaxRequestTimes:"h-max-request-times",hMaxReusableSecs:"h-max-reusable-secs"};for(let[Y,te]of Object.entries(K)){let se=Lc(_[Y]);se!=null&&(R[te]=typeof se=="number"?`${se}`:se)}let Z=Uc(_.hKeepAlivePeriod);return Z!=null&&(R["h-keep-alive-period"]=Z),Object.keys(R).length>0?R:void 0},o=_=>{if(!gt(_))return;let R={};for(let[K,Z]of Object.entries(_))typeof Z=="string"&&(R[K]=Z);return Object.keys(R).length>0?R:void 0},s=_=>{if(Array.isArray(_))return _.map(s);if(gt(_)){let R={};for(let[K,Z]of Object.entries(_))R[K]=s(Z);return R}return _},a=_=>{if(Array.isArray(_))return _.map(a).filter(K=>K!==void 0);if(!gt(_))return _;let R={};for(let[K,Z]of Object.entries(_)){let Y=a(Z);Y!==void 0&&(R[K]=Y)}return Object.keys(R).length>0?R:void 0},u=(_,R,K)=>{let Z=a(s(K));Z!==void 0&&(_[R]=Z)},l=_=>{if(_==null)return;if(!gt(_))return s(_);let R={};for(let[K,Z]of Object.entries(_))typeof Z!="string"&&u(R,K,Z);return a(R)},f=(_,R)=>["maxConnections","maxConcurrency","cMaxReuseTimes","hMaxRequestTimes","hMaxReusableSecs"].includes(_)?Lc(R)!=null:_==="hKeepAlivePeriod"?Uc(R)!=null:!1,m=_=>{if(_==null)return;if(!gt(_))return s(_);let R={};for(let[K,Z]of Object.entries(_))f(K,Z)||u(R,K,Z);return a(R)},p=_=>{if(_==null)return;if(!gt(_))return s(_);let R={};for(let[K,Z]of Object.entries(_))switch(K){case"headers":{let Y=l(Z);Y!==void 0&&(R.headers=Y);break}case"noGRPCHeader":case"xPaddingObfsMode":Z!==!0&&u(R,K,Z);break;case"xPaddingBytes":Yh(Z)==null&&u(R,K,Z);break;case"xPaddingKey":case"xPaddingHeader":case"xPaddingPlacement":case"xPaddingMethod":case"uplinkHTTPMethod":case"sessionIDPlacement":case"sessionPlacement":case"sessionIDKey":case"sessionKey":case"seqPlacement":case"seqKey":case"uplinkDataPlacement":case"uplinkDataKey":typeof Z!="string"&&u(R,K,Z);break;case"sessionIDTable":typeof Z!="string"&&u(R,K,Z);break;case"uplinkChunkSize":Lc(Z)==null&&u(R,K,Z);break;case"scMaxEachPostBytes":Yh(Z)==null&&u(R,K,Z);break;case"scMinPostsIntervalMs":v0(Z)==null&&u(R,K,Z);break;case"sessionIDLength":Yh(Z)==null&&u(R,K,Z);break;case"xmux":{let Y=m(Z);Y!==void 0&&(R.xmux=Y);break}default:u(R,K,Z);break}return a(R)},d=_=>{if(_==null)return;if(!gt(_))return s(_);let R={};Object.prototype.hasOwnProperty.call(_,"path")&&!nt(_.path)&&u(R,"path",_.path),Object.prototype.hasOwnProperty.call(_,"host")&&!nt(_.host)&&u(R,"host",_.host),Object.prototype.hasOwnProperty.call(_,"mode")&&!nt(_.mode)&&u(R,"mode",_.mode);let K={};for(let[Y,te]of Object.entries(_))["path","host","mode","extra"].includes(Y)||(K[Y]=te);let Z=p(K);if(gt(Z)&&Object.assign(R,Z),Object.prototype.hasOwnProperty.call(_,"extra")){let Y=p(_.extra);Y!==void 0&&(R.extra=Y)}return a(R)},v=_=>{if(_==null)return;if(!gt(_))return s(_);let R={};for(let[K,Z]of Object.entries(_))switch(K){case"address":nt(Z)||u(R,K,Z);break;case"port":Uc(Z,{allowNegative:!1})==null&&u(R,K,Z);break;case"security":{let Y=typeof Z=="string"?Z.toLowerCase():"";["tls","reality"].includes(Y)||u(R,K,Z);break}case"tlsSettings":{if(!gt(Z)){u(R,K,Z);break}let Y={},te=kS(Z.echConfigList);for(let[fe,ve]of Object.entries(Z))switch(fe){case"serverName":case"fingerprint":nt(ve)||u(Y,fe,ve);break;case"echConfigList":kS(ve)||u(Y,fe,ve);break;case"echForceQuery":(!te||!x2(ve))&&u(Y,fe,ve);break;case"echSockopt":(!te||!gt(ve))&&u(Y,fe,ve);break;case"alpn":Array.isArray(ve)&&ve.length>0&&ve.every(we=>typeof we=="string"&&we!=="")||u(Y,fe,ve);break;case"allowInsecure":ve!==!0&&u(Y,fe,ve);break;default:u(Y,fe,ve);break}let se=a(Y);se!==void 0&&(R.tlsSettings=se);break}case"realitySettings":{if(!gt(Z)){u(R,K,Z);break}let Y={};for(let[se,fe]of Object.entries(Z))switch(se){case"publicKey":case"shortId":case"serverName":case"fingerprint":nt(fe)||u(Y,se,fe);break;default:u(Y,se,fe);break}let te=a(Y);te!==void 0&&(R.realitySettings=te);break}case"xhttpSettings":{let Y=d(Z);Y!==void 0&&(R.xhttpSettings=Y);break}case"network":{let Y=typeof Z=="string"?Z.toLowerCase():"";Y!=="xhttp"&&Y!=="splithttp"&&u(R,K,Z);break}default:u(R,K,Z);break}return a(R)},g=(_,{parsedDownloadSettings:R}={})=>{if(!gt(_))return;let{downloadSettings:K,...Z}=_,Y=p(Z)||{};if(Object.prototype.hasOwnProperty.call(_,"downloadSettings")){let te=v(K);te!==void 0&&(Y.downloadSettings=te)}return a(Y)},y=(_,R)=>{if(!gt(_)||!gt(R))return;let K=o(R.headers);if(K){let we={..._.headers||{}};for(let[Te,Le]of Object.entries(K)){if(/^host$/i.test(Te)){!Object.prototype.hasOwnProperty.call(we,"Host")&&!Object.prototype.hasOwnProperty.call(we,"host")&&(we.Host=Le);continue}we[Te]=Le}Object.keys(we).length>0&&(_.headers=we)}R.noGRPCHeader===!0&&(_["no-grpc-header"]=!0);let Z=Yh(R.xPaddingBytes);Z!=null&&(_["x-padding-bytes"]=Z),R.xPaddingObfsMode===!0&&(_["x-padding-obfs-mode"]=!0),nt(R.xPaddingKey)&&(_["x-padding-key"]=R.xPaddingKey),nt(R.xPaddingHeader)&&(_["x-padding-header"]=R.xPaddingHeader),nt(R.xPaddingPlacement)&&(_["x-padding-placement"]=R.xPaddingPlacement),nt(R.xPaddingMethod)&&(_["x-padding-method"]=R.xPaddingMethod),nt(R.uplinkHTTPMethod)&&(_["uplink-http-method"]=R.uplinkHTTPMethod),nt(R.sessionIDPlacement)?_["session-placement"]=R.sessionIDPlacement:nt(R.sessionPlacement)&&(_["session-placement"]=R.sessionPlacement),nt(R.sessionIDKey)?_["session-key"]=R.sessionIDKey:nt(R.sessionKey)&&(_["session-key"]=R.sessionKey),typeof R.sessionIDTable=="string"&&(_["session-table"]=R.sessionIDTable);let Y=Yh(R.sessionIDLength);Y!=null&&(_["session-length"]=Y),nt(R.seqPlacement)&&(_["seq-placement"]=R.seqPlacement),nt(R.seqKey)&&(_["seq-key"]=R.seqKey),nt(R.uplinkDataPlacement)&&(_["uplink-data-placement"]=R.uplinkDataPlacement),nt(R.uplinkDataKey)&&(_["uplink-data-key"]=R.uplinkDataKey);let te=Lc(R.uplinkChunkSize);te!=null&&(_["uplink-chunk-size"]=te);let se=w0(R.scMaxEachPostBytes);se!=null&&(_["sc-max-each-post-bytes"]=se);let fe=v0(R.scMinPostsIntervalMs);fe!=null&&(_["sc-min-posts-interval-ms"]=fe);let ve=i(R.xmux);ve&&(_["reuse-settings"]=ve)},w=_=>{if(!gt(_))return;let R={},K=typeof _.network=="string"?_.network.toLowerCase():"";(K==="xhttp"||K==="splithttp")&&(R.network="xhttp"),nt(_.address)&&(R.server=_.address);let Z=Uc(_.port,{allowNegative:!1});Z!=null&&(R.port=Z);let Y=typeof _.security=="string"?_.security.toLowerCase():"";if((Y==="tls"||Y==="reality")&&(R.tls=!0),gt(_.tlsSettings)){nt(_.tlsSettings.serverName)&&(R.servername=_.tlsSettings.serverName),nt(_.tlsSettings.fingerprint)&&(R["client-fingerprint"]=_.tlsSettings.fingerprint),Array.isArray(_.tlsSettings.alpn)&&_.tlsSettings.alpn.length>0&&_.tlsSettings.alpn.every(fe=>typeof fe=="string"&&fe!=="")&&(R.alpn=_.tlsSettings.alpn),_.tlsSettings.allowInsecure===!0&&(R["skip-cert-verify"]=!0);let se=R2({echConfigList:_.tlsSettings.echConfigList,echForceQuery:_.tlsSettings.echForceQuery,echSockopt:_.tlsSettings.echSockopt});se&&(R["ech-opts"]=se)}let te;return gt(_.realitySettings)&&(te={},nt(_.realitySettings.publicKey)&&(te["public-key"]=_.realitySettings.publicKey),nt(_.realitySettings.shortId)&&(te["short-id"]=_.realitySettings.shortId),nt(_.realitySettings.serverName)&&(R.servername=_.realitySettings.serverName),nt(_.realitySettings.fingerprint)&&(R["client-fingerprint"]=_.realitySettings.fingerprint)),Y==="reality"?R["reality-opts"]=te||{}:te&&Object.keys(te).length>0&&(R["reality-opts"]=te),gt(_.xhttpSettings)&&(nt(_.xhttpSettings.path)&&(R.path=_.xhttpSettings.path),nt(_.xhttpSettings.host)&&(R.host=_.xhttpSettings.host),nt(_.xhttpSettings.mode)&&(R.mode=_.xhttpSettings.mode),y(R,_.xhttpSettings),gt(_.xhttpSettings.extra)&&y(R,_.xhttpSettings.extra)),Object.keys(R).length>0?R:void 0};n=n.split("vless://")[1];let E,S=/^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);if(!S){let[_,R,K]=/^(.*?)(\?.*?$)/.exec(n);n=`${_t.decode(R)}${K}`,S=/^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(n),E=!0}let[D,F,M,z,C,P="",U]=S;E&&(F=F.replace(/^.*?:/g,"")),z=parseInt(`${z}`,10),F=decodeURIComponent(F),U!=null&&(U=decodeURIComponent(U));let k={type:"vless",name:U,server:M,port:z,uuid:F,udp:!0},O={};for(let _ of P.split("&"))if(_){let[R,K]=_.split("="),Z=K;Z=decodeURIComponent(K),O[R]=Z}if(k.name=U??O.remarks??O.remark??`VLESS ${M}:${z}`,k.tls=O.security&&O.security!=="none",O.pbk&&(O.security="reality"),E&&/TRUE|1/i.test(O.tls)&&(k.tls=!0,O.security=O.security??"reality"),k.sni=O.sni||O.peer,k.flow=O.flow,!k.flow&&E&&O.xtls){let _=[void 0,"xtls-rprx-direct","xtls-rprx-vision"][O.xtls];_&&(k.flow=_)}k["client-fingerprint"]=O.fp,k.alpn=O.alpn?O.alpn.split(","):void 0,k["skip-cert-verify"]=/(TRUE)|1/i.test(O.allowInsecure),k._echConfigList=eu(O.ech);let q=R2({echConfigList:O.ech});switch(q&&(k["ech-opts"]=q),k["tls-fingerprint"]=eu(O.pcs),k._vcn=O.vcn?.split(",").map(_=>_.trim()).filter(Boolean),k["name-cert-verify"]=k._vcn?.[0],k._h2=/(TRUE)|1/i.test(O.h2),`${O.packetEncoding||""}`.trim().toLowerCase()){case"none":k["packet-encoding"]="";break;case"packet":k["packet-encoding"]="packetaddr";break;default:k["packet-encoding"]="xudp";break}if(["reality"].includes(O.security)){let _={};O.pbk&&(_["public-key"]=O.pbk),O.sid&&(_["short-id"]=O.sid),O.spx&&(_["_spider-x"]=O.spx),Object.keys(_).length>0&&(k[`${O.security}-opts`]=_)}let N=!1;if(k.network=O.type||"tcp",k.network==="tcp"&&O.headerType==="http"?k.network="http":k.network==="http"?k.network="h2":k.network==="httpupgrade"&&(k.network="ws",N=!0),!O.type&&E&&O.obfs&&(k.network=O.obfs,["none"].includes(k.network)&&(k.network="tcp")),["websocket"].includes(k.network)&&(k.network="ws"),k.network&&!["tcp","none"].includes(k.network)){let _={},R="",K=O.host??O.obfsParam;if(K){if(O.obfsParam)try{let te=JSON.parse(K);_.headers=te}catch{_.headers={Host:K}}else _.headers={Host:K};["xhttp"].includes(k.network)&&_.headers?.Host&&(_.host=_.headers.Host,delete _.headers.Host,Object.keys(_.headers).length===0&&delete _.headers);let Y=_.headers?.Host??_.headers?.host;["h2"].includes(k.network)&&Y&&(_.host=F6(Y),delete _.headers.Host,delete _.headers.host,Object.keys(_.headers).length===0&&delete _.headers)}if(O.serviceName?(_[`${k.network}-service-name`]=O.serviceName,["grpc"].includes(k.network)&&O.authority&&(_["_grpc-authority"]=O.authority)):E&&O.path&&(["ws","http","h2"].includes(k.network)||(_[`${k.network}-service-name`]=O.path,delete O.path)),O.path){let Y=O.path;if(k.network==="ws"){let te=_6(Y);Y=te.path,R=te.ed}_.path=Y}else k.network==="h2"&&(_.path="/");k.network==="http"&&O.method&&(_.method=O.method),["grpc"].includes(k.network)&&(_["_grpc-type"]=O.mode||"gun"),N&&(_["v2ray-http-upgrade"]=!0);let Z=R||O.ed;if(Z){let Y=D6(Z);N?(_["v2ray-http-upgrade-fast-open"]=!0,_["_v2ray-http-upgrade-ed"]=`${Z}`):k.network==="ws"&&(_["max-early-data"]=Y,_["early-data-header-name"]=O.eh||"Sec-WebSocket-Protocol")}if(O.eh&&(k.network==="ws"||N)&&(_["early-data-header-name"]=O.eh),Object.keys(_).length>0&&(k[`${k.network}-opts`]=_),k.network==="kcp"&&(O.seed&&(k.seed=O.seed),k.headerType=O.headerType||"none"),O.extra&&!["xhttp"].includes(k.network)&&(k._extra=O.extra),["xhttp"].includes(k.network)){let Y={},te;try{Y=O.extra?JSON.parse(O.extra):{}}catch{H.error(`Failed to parse extra field as JSON: ${O.extra}`),te=O.extra}let se={...k[`${k.network}-opts`]||{}};O.mode&&(se.mode=O.mode),y(se,Y);let fe=w(Y?.downloadSettings);fe&&(se["download-settings"]=fe),Object.keys(se).length>0&&(k[`${k.network}-opts`]=se),te!=null&&(k._extra=te);let ve=g(Y,{parsedDownloadSettings:fe});ve&&(k._extra_unsupported=ve)}else O.mode&&(k._mode=O.mode)}return O.encryption&&(k.encryption=O.encryption),O.pqv&&(k._pqv=O.pqv),k}}}function ote(){return{name:"URI AnyTLS Parser",test:n=>/^anytls:\/\//.test(n),parse:n=>{let i=nT().parse(n.replace("anytls","vless"));n=n.split(/anytls:\/\//)[1];let[o,s,a,u,l="",f]=/^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(n);s=decodeURIComponent(s),u=parseInt(`${u}`,10),isNaN(u)&&(u=443),s=decodeURIComponent(s),f!=null&&(f=decodeURIComponent(f)),f=f??`AnyTLS ${a}:${u}`;let m={...i,uuid:void 0,type:"anytls",name:f,server:a,port:u,password:s};for(let p of l.split("&"))if(p){let[d,v]=p.split("=");d=d.replace(/_/g,"-"),v=decodeURIComponent(v),["alpn"].includes(d)?m[d]=v?v.split(","):void 0:["insecure"].includes(d)?m["skip-cert-verify"]=/(TRUE)|1/i.test(v):["udp"].includes(d)?m[d]=/(TRUE)|1/i.test(v):Object.keys(m).includes(d)||(m[d]=v)}return["tcp"].includes(m.network)&&!m["reality-opts"]&&(delete m.network,delete m.security),m}}}function ate(){return{name:"URI Hysteria2 Parser",test:n=>/^(hysteria2|hy2):\/\//.test(n),parse:n=>{n=n.split(/(hysteria2|hy2):\/\//)[2];let i,[o,s,a,u,l,f,m,p,d,v,g="",y]=/^(.*?)@(.*?)(:((\d+(-\d+)?)([,;]\d+(-\d+)?)*))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);/^\d+$/.test(l)?(l=parseInt(`${l}`,10),isNaN(l)&&(l=443)):l?(i=l,l=Md(i)):l=443,s=decodeURIComponent(s),y!=null&&(y=decodeURIComponent(y)),y=y??`Hysteria2 ${a}:${l}`;let w={type:"hysteria2",name:y,server:a,port:l,ports:i,password:s},E={};for(let M of g.split("&"))if(M){let[z,C]=M.split("="),P=C;P=decodeURIComponent(C),E[z]=P}w.sni=E.sni,!w.sni&&E.peer&&(w.sni=E.peer),E.obfs&&E.obfs!=="none"&&(w.obfs=E.obfs),E.mport&&(w.ports=E.mport),w["obfs-password"]=E["obfs-password"],w["skip-cert-verify"]=/(TRUE)|1/i.test(E.insecure),w.tfo=/(TRUE)|1/i.test(E.fastopen),w["tls-fingerprint"]=E.pinSHA256;let S=E["hop-interval"]||E.hop_interval;S!=null&&(w["hop-interval"]=S);let D=E.keepalive;/^\d+$/.test(D)&&(w.keepalive=parseInt(`${D}`,10)),E.upmbps&&(w.up=E.upmbps),E.downmbps&&(w.down=E.downmbps);let F=R2({echConfigList:E.ech});return F&&(w["ech-opts"]=F),w}}}function ute(){return{name:"URI Hysteria Parser",test:n=>/^(hysteria|hy):\/\//.test(n),parse:n=>{n=n.split(/(hysteria|hy):\/\//)[2];let[i,o,s,a,u,l="",f]=/^(.*?)(:(\d+))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);a=parseInt(`${a}`,10),isNaN(a)&&(a=443),f!=null&&(f=decodeURIComponent(f)),f=f??`Hysteria ${o}:${a}`;let m={type:"hysteria",name:f,server:o,port:a},p={};for(let d of l.split("&"))if(d){let[v,g]=d.split("=");v=v.replace(/_/,"-"),g=decodeURIComponent(g),["alpn"].includes(v)?m[v]=g?g.split(","):void 0:["insecure"].includes(v)?m["skip-cert-verify"]=/(TRUE)|1/i.test(g):["auth"].includes(v)?m["auth-str"]=g:["mport"].includes(v)?m.ports=g:["obfsParam"].includes(v)?m.obfs=g:["upmbps"].includes(v)?m.up=g:["downmbps"].includes(v)?m.down=g:["obfs"].includes(v)?m._obfs=g||"":["fast-open","peer"].includes(v)?p[v]=g:Object.keys(m).includes(v)||(m[v]=g)}return!m.sni&&p.peer&&(m.sni=p.peer),!m["fast-open"]&&p.fastopen&&(m["fast-open"]=!0),m.protocol||(m.protocol="udp"),m}}}function cte(){return{name:"URI TUIC Parser",test:n=>/^tuic:\/\//.test(n),parse:n=>{n=n.split(/tuic:\/\//)[1];let[i,o,s,a,u="",l]=/^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(n);o=decodeURIComponent(o);let[f,...m]=o.split(":"),p=m.join(":");a=parseInt(`${a}`,10),isNaN(a)&&(a=443),p=decodeURIComponent(p),l!=null&&(l=decodeURIComponent(l)),l=l??`TUIC ${s}:${a}`;let d={type:"tuic",name:l,server:s,port:a,password:p,uuid:f};for(let v of u.split("&"))if(v){let[g,y]=v.split("=");g=g.replace(/_/g,"-"),y=decodeURIComponent(y),["alpn"].includes(g)?d[g]=y?y.split(","):void 0:["allow-insecure","insecure"].includes(g)?d["skip-cert-verify"]=/(TRUE)|1/i.test(y):["fast-open"].includes(g)?d.tfo=!0:["disable-sni","reduce-rtt"].includes(g)?d[g]=/(TRUE)|1/i.test(y):g==="congestion-control"?(d["congestion-controller"]=y,delete d[g]):Object.keys(d).includes(g)||(d[g]=y)}return d}}}function lte(){return{name:"URI WireGuard Parser",test:n=>/^(wireguard|wg):\/\//.test(n),parse:n=>{n=n.split(/(wireguard|wg):\/\//)[2];let[i,o,s,a,u,l,f,m="",p]=/^((.*?)@)?(.*?)(:(\d+))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);l=parseInt(`${l}`,10),isNaN(l)&&(l=51820),s=decodeURIComponent(s),p!=null&&(p=decodeURIComponent(p)),p=p??`WireGuard ${a}:${l}`;let d={type:"wireguard",name:p,server:a,port:l,"private-key":s,udp:!0};for(let v of m.split("&"))if(v){let g=v.indexOf("="),y,w;if(g===-1?(y=v,w=""):(y=v.slice(0,g),w=v.slice(g+1)),y=y.replace(/_/,"-"),w=decodeURIComponent(w),["reserved"].includes(y)){let E=w.split(",").map(S=>parseInt(S.trim(),10)).filter(S=>Number.isInteger(S));E.length===3&&(d[y]=E)}else if(["address","ip"].includes(y))w.split(",").map(E=>{let S=ete(E);S&&(S.family==="ipv4"?(d.ip=S.address,typeof S.cidr<"u"&&(d["ip-cidr"]=S.cidr)):S.family==="ipv6"&&(d.ipv6=S.address,typeof S.cidr<"u"&&(d["ipv6-cidr"]=S.cidr)))});else if(["mtu"].includes(y)){let E=parseInt(w.trim(),10);Number.isInteger(E)&&(d[y]=E)}else/publickey/i.test(y)?d["public-key"]=w:/privatekey/i.test(y)?d["private-key"]=w:["udp"].includes(y)?d[y]=/(TRUE)|1/i.test(w):[...Object.keys(d),"flag"].includes(y)||(d[y]=w)}return d}}}function fte(){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,a]=n.split(/#(.+)/,2),l=y6().parse(s);if(nt(a))try{l.name=decodeURIComponent(a)}catch(f){console.log(f)}return l}}}function hte(){return{name:"Clash Parser",test:n=>{let i;try{i=S6.default.parse(n)}catch{i=pi.parse(n)}return!!i?.type},parse:n=>{let i;try{i=S6.default.parse(n)}catch{i=pi.parse(n)}if(!["shadowquic","gost-relay","openvpn","tailscale","trusttunnel","h2-connect","naive","anytls","mieru","masque","sudoku","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.servername&&(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.type==="vmess"&&(i.cipher=jn(i.cipher)),i}}}function dte(){return{name:"QX SS Parser",test:n=>/^shadowsocks\s*=/.test(n.split(",")[0].trim())&&n.indexOf("ssr-protocol")===-1,parse:n=>Fa().parse(n)}}function pte(){return{name:"QX SSR Parser",test:n=>/^shadowsocks\s*=/.test(n.split(",")[0].trim())&&n.indexOf("ssr-protocol")!==-1,parse:n=>Fa().parse(n)}}function mte(){return{name:"QX VMess Parser",test:n=>/^vmess\s*=/.test(n.split(",")[0].trim()),parse:n=>Fa().parse(n)}}function gte(){return{name:"QX VLESS Parser",test:n=>/^vless\s*=/.test(n.split(",")[0].trim()),parse:n=>Fa().parse(n)}}function vte(){return{name:"QX AnyTLS Parser",test:n=>/^anytls\s*=/.test(n.split(",")[0].trim()),parse:n=>Fa().parse(n)}}function wte(){return{name:"QX Trojan Parser",test:n=>/^trojan\s*=/.test(n.split(",")[0].trim()),parse:n=>Fa().parse(n)}}function yte(){return{name:"QX HTTP Parser",test:n=>/^http\s*=/.test(n.split(",")[0].trim()),parse:n=>Fa().parse(n)}}function Ete(){return{name:"QX Socks5 Parser",test:n=>/^socks5\s*=/.test(n.split(",")[0].trim()),parse:n=>Fa().parse(n)}}function bte(){return{name:"Loon SS Parser",test:n=>n.split(",")[0].split("=")[1].trim().toLowerCase()==="shadowsocks",parse:n=>Bo().parse(n)}}function Ate(){return{name:"Loon SSR Parser",test:n=>n.split(",")[0].split("=")[1].trim().toLowerCase()==="shadowsocksr",parse:n=>Bo().parse(n)}}function Ste(){return{name:"Loon VMess Parser",test:n=>/^.*=\s*vmess/i.test(n.split(",")[0])&&n.indexOf("username")===-1,parse:n=>Bo().parse(n)}}function Cte(){return{name:"Loon Vless Parser",test:n=>/^.*=\s*vless/i.test(n.split(",")[0]),parse:n=>Bo().parse(n)}}function _te(){return{name:"Loon Trojan Parser",test:n=>/^.*=\s*trojan/i.test(n.split(",")[0]),parse:n=>Bo().parse(n)}}function Dte(){return{name:"Loon AnyTLS Parser",test:n=>/^.*=\s*anytls/i.test(n.split(",")[0]),parse:n=>Bo().parse(n)}}function Fte(){return{name:"Loon Hysteria2 Parser",test:n=>/^.*=\s*Hysteria2/i.test(n.split(",")[0]),parse:n=>Bo().parse(n)}}function Ite(){return{name:"Loon HTTP Parser",test:n=>/^.*=\s*http/i.test(n.split(",")[0]),parse:n=>Bo().parse(n)}}function Bte(){return{name:"Loon SOCKS5 Parser",test:n=>/^.*=\s*socks5/i.test(n.split(",")[0]),parse:n=>Bo().parse(n)}}function $te(){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 o=n.match(/,\s*?peers\s*?=\s*?\[\s*?\{\s*?(.+?)\s*?\}\s*?\]/i)?.[1],s=o.match(/(,|^)\s*?endpoint\s*?=\s*?"?(.+?):(\d+)"?\s*?(,|$)/i),a=s?.[2],u=parseInt(s?.[3],10),l=n.match(/(,|^)\s*?mtu\s*?=\s*?"?(\d+?)"?\s*?(,|$)/i)?.[2];l&&(l=parseInt(l,10));let f=n.match(/(,|^)\s*?keepalive\s*?=\s*?"?(\d+?)"?\s*?(,|$)/i)?.[2];f&&(f=parseInt(f,10));let m=o.match(/(,|^)\s*?reserved\s*?=\s*?"?(\[\s*?.+?\s*?\])"?\s*?(,|$)/i)?.[2];m&&(m=JSON.parse(m));let p,d=n.match(/(,|^)\s*?dns\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],v=n.match(/(,|^)\s*?dnsv6\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2];(d||v)&&(p=[],d&&p.push(d),v&&p.push(v));let g=o.match(/(,|^)\s*?allowed-ips\s*?=\s*?"(.+?)"\s*?(,|$)/i)?.[2]?.split(",").map(F=>F.trim()),y=o.match(/(,|^)\s*?preshared-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],w=n.match(/(,|^)\s*?interface-ip\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],E=n.match(/(,|^)\s*?interface-ipv6\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],S=o.match(/(,|^)\s*?public-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],D={type:"wireguard",name:i,server:a,port:u,ip:w,ipv6:E,"private-key":n.match(/(,|^)\s*?private-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],"public-key":S,mtu:l,keepalive:f,reserved:m,"allowed-ips":g,"preshared-key":y,dns:p,udp:!0,peers:[{server:a,port:u,ip:w,ipv6:E,"public-key":S,"pre-shared-key":y,"allowed-ips":g,reserved:m}]};return Array.isArray(D.dns)&&D.dns.length>0&&(D["remote-dns-resolve"]=!0),D}}}function Tte(){return{name:"Surge Direct Parser",test:n=>/^.*=\s*direct/.test(n.split(",")[0]),parse:n=>gs().parse(n)}}function Pte(){return{name:"Surge AnyTLS Parser",test:n=>/^.*=\s*anytls/.test(n.split(",")[0]),parse:n=>gs().parse(n)}}function xte(){return{name:"Surge TrustTunnel Parser",test:n=>/^.*=\s*trust-tunnel/.test(n.split(",")[0]),parse:n=>gs().parse(n)}}function Rte(){return{name:"Surge HTTP/2 CONNECT Parser",test:n=>/^.*=\s*h2-connect/.test(n.split(",")[0]),parse:n=>gs().parse(n)}}function kte(){return{name:"Surge SSH Parser",test:n=>/^.*=\s*ssh/.test(n.split(",")[0]),parse:n=>gs().parse(n)}}function Ote(){return{name:"Surge SS Parser",test:n=>/^.*=\s*ss/.test(n.split(",")[0]),parse:n=>gs().parse(n)}}function Nte(){return{name:"Surge VMess Parser",test:n=>/^.*=\s*vmess/.test(n.split(",")[0])&&n.indexOf("username")!==-1,parse:n=>gs().parse(n)}}function Lte(){return{name:"Surge Trojan Parser",test:n=>/^.*=\s*trojan/.test(n.split(",")[0]),parse:n=>gs().parse(n)}}var sT=/(^|,)\s*(fast-open|over-tls|tls-name|ip-mode|tls-cert-sha256|tls-pubkey-sha256)\s*=/i;function Ute(){return{name:"Surge HTTP Parser",test:n=>/^.*=\s*https?/.test(n.split(",")[0])&&!sT.test(n),parse:n=>gs().parse(n)}}function Hte(){return{name:"Surge Socks5 Parser",test:n=>/^.*=\s*socks5(-tls)?/.test(n.split(",")[0])&&!sT.test(n),parse:n=>gs().parse(n)}}function Mte(){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),[o,s,a]=i;n=a;let u=/(,|^)\s*?exec\s*?=\s*"(.*?)"\s*?(,|$)/.exec(n)?.[2];u||(u=/(,|^)\s*?exec\s*?=\s*(.*?)\s*?(,|$)/.exec(n)?.[2]);let l=/(,|^)\s*?local-port\s*?=\s*"(.*?)"\s*?(,|$)/.exec(n)?.[2];l||(l=/(,|^)\s*?local-port\s*?=\s*(.*?)\s*?(,|$)/.exec(n)?.[2]);let f=/(,|^)\s*?args\s*?=\s*("(.*?)"|(.*?))(?=\s*?(,|$))/g,m,p=[];for(;(m=f.exec(n))!==null;)m[3]!=null?p.push(m[3]):m[4]!=null&&p.push(m[4]);let d=/(,|^)\s*?addresses\s*?=\s*("(.*?)"|(.*?))(?=\s*?(,|$))/g,v,g=[];for(;(v=d.exec(n))!==null;){let w;v[3]!=null?w=v[3]:v[4]!=null&&(w=v[4]),w!=null&&(w=`${w}`.trim().replace(/^\[/,"").replace(/\]$/,"")),zte(w)&&g.push(w)}return{type:"external",name:s,exec:u,"local-port":l,args:p,addresses:g}}}}function qte(){return{name:"Surge Snell Parser",test:n=>/^.*=\s*snell/.test(n.split(",")[0]),parse:n=>gs().parse(n)}}function jte(){return{name:"Surge Tuic Parser",test:n=>/^.*=\s*tuic(-v5)?/.test(n.split(",")[0]),parse:n=>{let{port_hopping:i,line:o}=tT(n),s=gs().parse(o);return s.ports=i,s}}}function Kte(){return{name:"Surge WireGuard Parser",test:n=>/^.*=\s*wireguard/.test(n.split(",")[0]),parse:n=>gs().parse(n)}}function Vte(){return{name:"Surge Hysteria2 Parser",test:n=>/^.*=\s*hysteria2/.test(n.split(",")[0]),parse:n=>{let{port_hopping:i,line:o}=tT(n),s=gs().parse(o);return s.ports=i,s}}}function zte(e){return Gr(e)||_r(e)}var iT=[tte(),rte(),nte(),ste(),ite(),nT(),cte(),lte(),ute(),ate(),fte(),ote(),hte(),Tte(),Pte(),xte(),Rte(),kte(),Ote(),Nte(),Lte(),Ute(),qte(),jte(),Kte(),Vte(),Hte(),Mte(),bte(),Ate(),Ste(),Cte(),Fte(),_te(),Dte(),Ite(),Bte(),$te(),dte(),pte(),mte(),gte(),vte(),wte(),yte(),Ete()];var lT=B(A6());var Gte={encrypt:lh,decrypt:fh,derivePublicKey:Kl};function Yte(e){for(let t of t2)try{if(t.test(e))return H.info(`Pre-processor [${t.name}] activated`),t.parse(e)}catch(r){H.error(`Parser [${t.name}] failed Reason: ${r}`)}return e}function Wte(e){e=Yte(e);let t=e.split(` `),r=[],n;for(let i of t){if(i=i.trim(),i.length===0)continue;let o=!1;if(n){let[s,a]=aT(n,i);a||(r.push(cT(s)),o=!0)}if(!o)for(let s of iT){let[a,u]=aT(s,i);if(!u){r.push(cT(a)),n=s,o=!0,H.info(`${s.name} is activated`);break}}o||H.error(`Failed to parse line: ${i}`)}return r.filter(i=>{if(["vless","vmess"].includes(i.type))sm(i.uuid)||H.warn(`UUID may be invalid: ${i.name} ${i.uuid}`);else if(["hysteria2"].includes(i.type)&&i.obfs&&!i["obfs-password"])return H.error(`Proxy ${i.name} has obfs ${i.obfs} but missing obfs-password`),!1;return!0})}function fT(e,t){let r=t.process;if(!r||typeof r!="object")return!1;let{type:n,customNames:i}=r;if(!Array.isArray(i))return!1;let o=e.customName!=null&&i.includes(e.customName);return n==="disable"?o:n==="enable"?!o:!1}async function Xte(e,t=[],r,n,i,o){let s={};o!==void 0&&(s.raw=Array.isArray(o)||o!==null&&typeof o=="object"?o:[o]);for(let a of t){if(SS(a.type)){H.log(`Skipping response transformer during proxy/file processing: "${a.type}" with arguments: >>> ${JSON.stringify(a.args,null,2)||"None"}`);continue}if(fT(a,s)){H.info(`Skipping context-controlled operator: "${a.type}" with customName "${a.customName||""}"`);continue}if(a.disabled){H.log(`Skipping disabled operator: "${a.type}" with arguments: >>> ${JSON.stringify(a.args,null,2)||"None"}`);continue}let u,l={};if(a.type.indexOf("Script")!==-1&&({script:u,$arguments:l}=await hT(a)),!f0[a.type]){H.error(`Unknown operator: "${a.type}"`);continue}H.log(`Applying "${a.type}" with arguments: >>> ${JSON.stringify(a.args,null,2)||"None"}`);let f;a.type.indexOf("Script")!==-1?f=f0[a.type](u,r,l,n,i,s):f=f0[a.type](a.args||{}),e=await r7(f,e)}return e}async function Jte(e,t=[],r,n,i){let o={},s=oT(e);for(let a of t){if(!SS(a.type))continue;if(fT(a,o)){H.info(`Skipping context-controlled response transformer: "${a.type}" with customName "${a.customName||""}"`);continue}if(a.disabled){H.log(`Skipping disabled response transformer: "${a.type}" with arguments: >>> ${JSON.stringify(a.args,null,2)||"None"}`);continue}let{script:u,$arguments:l}=await hT(a);H.log(`Applying "${a.type}" with arguments: >>> ${JSON.stringify(a.args,null,2)||"None"}`);let f=f0[a.type](u,r,l,n,i,o);s=oT(await t7(f,s))}return s}async function hT(item){let script,$arguments={},{mode,content}=item.args||{};if(mode==="link"){let url=content||"",rawArgs=url.split("#");if(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)}}url=`${url.split("#")[0]}${rawArgs[2]?`#${rawArgs[2]}`:$arguments?.noCache!=null||$arguments?.insecure!=null?`#${rawArgs[1]}`:""}`;let downloadUrlMatch=url.split("#")[0].match(/^\/api\/(file|module)\/(.+)/);if(downloadUrlMatch){let e="";try{e=downloadUrlMatch?.[1];let t=downloadUrlMatch?.[2];if(t==null)throw new Error(`\u672C\u5730 ${e} URL \u65E0\u6548: ${url}`);t=decodeURIComponent(t);let r=e==="module"?ts:Mt,n=$t(H.read(r),t);if(!n)throw new Error(`\u627E\u4E0D\u5230 ${e}: ${t}`);e==="module"?script=n.content:script=await Co({type:"file",name:t})}catch(t){throw H.error(`Error when loading ${e}: ${item.args.content}. Reason: ${t}`),new Error(`\u65E0\u6CD5\u52A0\u8F7D ${e}: ${url}`)}}else if(url?.startsWith("/"))try{let fs=eval('require("fs")');script=fs.readFileSync(url.split("#")[0],"utf8")}catch(e){throw H.error(`Error when reading local script: ${item.args.content}. Reason: ${e}`),new Error(`\u65E0\u6CD5\u4ECE\u8BE5\u8DEF\u5F84\u8BFB\u53D6\u811A\u672C\u6587\u4EF6: ${url}`)}else try{script=await Vi(url)}catch(e){throw H.error(`Error when downloading remote script: ${item.args.content}. Reason: ${e}`),new Error(`\u65E0\u6CD5\u4E0B\u8F7D\u811A\u672C: ${url}`)}}else script=content,$arguments=item.args?.arguments||{};return{script,$arguments}}function oT(e={}){let t=e.header||e.headers||{};(!t||typeof t!="object")&&(t={});let r={status:e.status||e.statusCode||200,body:Object.prototype.hasOwnProperty.call(e,"body")?e.body:""};return Object.defineProperty(r,"headers",{enumerable:!0,get(){return t},set(n){t=n&&typeof n=="object"?n:{}}}),Object.defineProperty(r,"header",{enumerable:!0,get(){return t},set(n){t=n&&typeof n=="object"?n:{}}}),r}function Zte(e,t,r,n={}){let i=V7[t];if(!i)throw new Error(`Target platform: ${t} is not supported!`);let o=String(t).toLowerCase();if(e=e.filter(s=>{let a=n["include-unsupported-proxy"];if(!a&&s.supported&&s.supported[t]===!1)return!1;if(!a&&Qte(s)&&ere(s)&&!tre(s,t))return H.error(`Target platform ${t} does not support headers for ${rre(s)} proxy ${s.name||`${s.server}:${s.port}`}. Proxy has been filtered.`),!1;if(!a&&jh(s)&&!["qx","quantumultx","shadowrocket"].includes(o))return!1;if(["vless","vmess"].includes(s.type)){sm(s.uuid)||H.warn(`UUID may be invalid: ${s.name} ${s.uuid}`);let l=s.type==="vless",f=l?[["reality-opts",s["reality-opts"]],["xhttp download-settings reality-opts",s["xhttp-opts"]?.["download-settings"]?.["reality-opts"]]]:[];for(let[p,d]of f)if(d&&!nt(d["public-key"])){if(p==="xhttp download-settings reality-opts"&&nt(s["reality-opts"]?.["public-key"])&&d["public-key"]==="")continue;return H.error(`Skipping VLESS Reality proxy ${s.name}: empty ${p}.public-key`),!1}let m=s["xhttp-opts"];if(l&&s.network==="xhttp"&&m?.mode==="stream-one"&&m["download-settings"])return H.error(`Skipping VLESS xhttp proxy ${s.name}: mode "stream-one" cannot be used with download-settings`),!1}return!0}),e=e.map(s=>(s._resolved=s.resolved,nt(s.name)||(s.name=`${s.type} ${s.server}:${s.port}`),s["disable-sni"]&&(["surge","surgemac","shadowrocket"].includes(o)?s.sni="off":!["tuic"].includes(s.type)&&!["sing-box","singbox"].includes(o)&&(H.error(`Target platform ${t} does not support sni off. As a workaround for mihomo, proxy ${s.name} sni will be set to IP instead`),s.sni=nv(s.server)?s.server:"127.0.0.1")),s.ports&&(s.ports=String(s.ports),["meta","clashmeta","clash.meta","mihomo"].includes(o)||(s.ports=s.ports.replace(/\//g,",")),s.port||(s.port=Md(s.ports))),s.type==="wireguard"&&FS(s),s)),H.log(`Producing proxies for target: ${t}`),typeof i.type>"u"||i.type==="SINGLE"){let s=e.map(a=>{try{return i.produce(a,r,n)}catch(u){return H.error(`Cannot produce proxy: ${a.name} Reason: ${u}`),""}}).filter(a=>a.length>0);return n._merged&&n.localPort>=1&&s.push(m0().produce({name:n._merged.name,type:"external",udp:!0,exec:n._merged.exec,"local-port":n.localPort,args:["-config",_t.encode(JSON.stringify({...n._merged.config,"mixed-port":n.localPort}))],addresses:[]},r,n)),s=r==="internal"?s:s.join(` `),t.startsWith("Surge")&&e.length>0&&e.every(a=>a.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)}function Qte(e){return e?.headers&&typeof e.headers=="object"&&Object.keys(e.headers).length>0}function ere(e){return["http","h2-connect","trusttunnel"].includes(e?.type)}function tre(e,t){let r=`${t}`.toLowerCase();return r.startsWith("surge")?["http","h2-connect","trusttunnel"].includes(e.type):r==="egern"||["clashmeta","clash.meta","meta","mihomo"].includes(r)||["singbox","sing-box"].includes(r)?e.type==="http":r==="json"?["http","h2-connect","trusttunnel"].includes(e.type):!1}function rre(e){return e.type==="http"?e.tls?"HTTPS":"HTTP":e.type==="h2-connect"?"HTTP/2 CONNECT":e.type==="trusttunnel"?"TrustTunnel":e.type}var rr={parse:Wte,process:Xte,processResponse:Jte,produce:Zte,age:Gte,ipAddress:nm,getRandomPort:Md,isIPv4:Gr,isIPv6:_r,isIP:nv,yaml:pi,getFlag:Nh,removeFlag:a0,getISO:B9,MMDB:b2,Gist:Ui,download:Vi,downloadFile:dT,isValidUUID:sm,doh:wS,Buffer:rv.Buffer,Base64:_t,JSON5:lT.default,hex_md5:Xr};function aT(e,t){if(!nre(e,t))return[null,new Error("Parser mismatch")];try{return[e.parse(t),null]}catch(r){return[null,r]}}function nre(e,t){try{return e.test(t)}catch{return!1}}function uT(e){if(typeof e=="string"||typeof e=="number"){if(e=String(e).trim(),e==="")return"/";if(!e.startsWith("/"))return"/"+e}return e}function cT(e){let t=(s,a)=>Object.prototype.hasOwnProperty.call(s,a),r=s=>{if(!(!s||typeof s!="object"||Array.isArray(s)))for(let a of Object.keys(s)){let u=a.toLowerCase();a!==u&&(t(s,u)||(s[u]=s[a]),delete s[a])}};for(let s of Object.keys(e)){let a=s.toLowerCase();a.endsWith("-opts")&&(s!==a&&(t(e,a)||(e[a]=e[s]),delete e[s]),r(e[a]))}if(e.udp=![!1,0,"0","false","off"].includes(typeof e.udp=="string"?e.udp.toLowerCase():e.udp),typeof e.cipher=="string"&&(e.cipher=e.cipher.toLowerCase()),typeof e.password=="number"&&(e.password=F8(e.password)),e["hop-interval"]!=null){let s=`${e["hop-interval"]}`.trim(),a=s.match(/^(\d+)\s*-\s*(\d+)$/);if(a){let u=parseInt(a[1],10),l=parseInt(a[2],10);u>0&&u<=l?(e["hop-interval"]=u,e["hop-interval-max"]=l):(delete e["hop-interval"],delete e["hop-interval-max"])}else if(/^\d+$/.test(s)){let u=parseInt(s,10);u>0?(e["hop-interval"]=u,delete e["hop-interval-max"]):(delete e["hop-interval"],delete e["hop-interval-max"])}else delete e["hop-interval"],delete e["hop-interval-max"]}["ss"].includes(e.type)&&e.cipher==="none"&&!e.password&&(e.password=""),e.interface&&(e["interface-name"]=e.interface,delete e.interface),D8(e.port)&&(e.port=parseInt(e.port,10)),e.server&&(e.server=`${e.server}`.trim().replace(/^\[/,"").replace(/\]$/,"")),["vmess","vless","trojan","anytls"].includes(e.type)&&e["shadow-tls-opts"]&&(e.plugin="shadow-tls",e["plugin-opts"]={host:e.sni,password:e["shadow-tls-opts"].password,version:e["shadow-tls-opts"].version},delete e["shadow-tls-opts"]),e.type==="snell"&&e["obfs-opts"]?.mode==="shadow-tls"&&!e.plugin&&(e.plugin="shadow-tls",e["plugin-opts"]={host:e["obfs-opts"].host,password:e["obfs-opts"].password,version:e["obfs-opts"].version,alpn:e["obfs-opts"].alpn},delete e["obfs-opts"]),e.plugin==="shadow-tls"&&e["plugin-opts"]&&(e.alpn&&!e["plugin-opts"].alpn&&(e["plugin-opts"].alpn=e.alpn),delete e.alpn);let n=e.type==="vless"&&e.network==="xhttp"?e["xhttp-opts"]?.["download-settings"]:void 0;n?.["shadow-tls-opts"]&&(n.plugin="shadow-tls",n["plugin-opts"]={host:n.servername,password:n["shadow-tls-opts"].password,version:n["shadow-tls-opts"].version},delete n["shadow-tls-opts"]),n?.plugin==="shadow-tls"&&n["plugin-opts"]&&(n.alpn&&!n["plugin-opts"].alpn&&(n["plugin-opts"].alpn=n.alpn),delete n.alpn),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 i=e[`${e.network}-opts`]?.path;if(Array.isArray(i)?e[`${e.network}-opts`].path=i.map(s=>uT(s)):i!=null&&(e[`${e.network}-opts`].path=uT(i)),e.type==="trojan"&&(e.network=e.network||"tcp"),["vmess"].includes(e.type)&&(e.network=e.network||"tcp",e.cipher=e.cipher||"none",e.alterId=e.alterId||0),["vless"].includes(e.type)&&(e.network=e.network||"tcp"),["vmess","vless"].includes(e.type)&&e["packet-encoding"]==null&&(e.xudp?e["packet-encoding"]="xudp":e["packet-addr"]&&(e["packet-encoding"]="packetaddr")),["trojan","tuic","hysteria","hysteria2","juicity","anytls","trusttunnel","h2-connect","naive","masque","shadowquic"].includes(e.type)&&(e.tls=!0),e.network){let s=e[`${e.network}-opts`]?.headers?.Host,a=e[`${e.network}-opts`]?.headers?.host;e.network!=="h2"&&a&&!s&&(e[`${e.network}-opts`].headers.Host=a,delete e[`${e.network}-opts`].headers.host)}if(e.network==="h2"){let s=e["h2-opts"],a=s?.host??s?.headers?.host??s?.headers?.Host,u=s?.path;a&&(s.host=Array.isArray(a)?a:[a]),s?.headers&&(delete s.headers.host,delete s.headers.Host,Object.keys(s.headers).length===0&&delete s.headers),Array.isArray(u)&&(s.path=u[0])}if(!e.tls&&["ws","http"].includes(e.network)&&!e[`${e.network}-opts`]?.headers?.Host&&!nv(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 s=e[`${e.network}-opts`]?.path,a=e[`${e.network}-opts`]?.headers?.Host;a&&!Array.isArray(a)&&(e[`${e.network}-opts`].headers.Host=[a]),s&&!Array.isArray(s)&&(e[`${e.network}-opts`].path=[s])}if(e.tls&&!e.sni&&e.sni!==""){if(e.network){let s=e.network==="h2"?e["h2-opts"]?.host:e[`${e.network}-opts`]?.headers?.Host;s=Array.isArray(s)?s[0]:s,s&&(e.sni=s)}!e.sni&&!nv(e.server)&&(e.sni=e.server)}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||["null",null].includes(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=rv.Buffer.from(e.name.data).toString("utf8"):e.name=rv.Buffer.from(e.name).toString("utf8")}catch(s){H.error(`proxy.name decode failed Reason: ${s}`),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(s=>!s))&&(e[`${e.network}-opts`]=e[`${e.network}-opts`]||{},e[`${e.network}-opts`].path=["/"])),["anytls"].includes(e.type)&&e["disable-reuse"]&&(e.reuse=!1),["","off"].includes(e.sni)&&(e["disable-sni"]=!0);let o=e.ca_str;e["ca-str"]?o=e["ca-str"]:o&&(delete e.ca_str,e["ca-str"]=o);try{H.env.isNode&&!o&&e._ca&&(o=H.node.fs.readFileSync(e._ca,{encoding:"utf8"}))}catch(s){H.error(`Read ca file failed Reason: ${s}`)}return!e["tls-fingerprint"]&&o&&(e["tls-fingerprint"]=I9.generateFingerprint(o)),["tuic"].includes(e.type)&&(e.alpn=Array.isArray(e.alpn)?e.alpn:[e.alpn||"h3"],e["congestion-controller"]=e["congestion-controller"]||"cubic",e["udp-relay-mode"]=e["udp-relay-mode"]||"native"),["wireguard"].includes(e.type)&&(Array.isArray(e.peers)&&e.peers.length>0&&(e.peers.find(a=>a.ip&&a.ipv6)||e.peers.find(a=>a.ip||a.ipv6))&&(e.ip||(e.ip=e.peers[0]?.ip),e.ipv6||(e.ipv6=e.peers[0]?.ipv6)),FS(e)),e}function nv(e){return Gr(e)||_r(e)}var pT=t2.find(e=>e.name==="Clash Pre-processor"),I6=new Map;function sre(e=""){let t=`${e}`.trim();return t?new RegExp(t,"i"):null}function ire(e,t,r){if(!t||!r||typeof e!="string"||!/^https?:\/\//i.test(e))return e;let n=`${t}/`;if(e.startsWith(n))return e;let i;try{i=sre(r)}catch(o){return H.error(`GitHub \u52A0\u901F\u4EE3\u7406\u5339\u914D\u6B63\u5219\u65E0\u6548: ${o.message??o}`),e}return i?.test(e)?(H.info(`GitHub \u52A0\u901F\u4EE3\u7406\u547D\u4E2D\u4E0B\u8F7D\u94FE\u63A5: ${e}`),`${t}/${e}`):e}function ore(e){return Ni(e)}async function Zh(e,{ageSecretKey:t,preprocess:r,url:n}){let i=t?await fh(e,t):e,o=i;if(r)try{pT.test(i)&&(i=pT.parse(i,!0))}catch(s){H.error(`Clash Pre-processor error: ${s}`)}if(r)try{let s=rr.parse(i);if(!Array.isArray(s)||s.length===0)return{result:i,raw:o,shouldCache:!1,cacheReason:`URL ${n} \u4E0D\u5305\u542B\u6709\u6548\u8282\u70B9, \u4E0D\u7F13\u5B58`}}catch(s){return{result:i,raw:o,shouldCache:!1,cacheReason:`URL ${n} \u5C1D\u8BD5\u89E3\u6790\u8282\u70B9\u5931\u8D25 ${s.message??s}, \u4E0D\u7F13\u5B58`}}return{result:i,raw:o,shouldCache:!0}}function $0(e,t){return t?{result:e.result,raw:e.raw}:e.result}function B6(e,t){return t?{result:e,raw:e}:e}async function Vi(rawUrl="",ua,timeout,customProxy,skipCustomCache,awaitCustomCache,noCache,preprocess,options={}){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 explicitAgeSecretKey=options&&typeof options=="object"?options?.[ln]||options?.ageSecretKey:void 0,returnRaw=options&&typeof options=="object"&&options.returnRaw,ageSecretKey=explicitAgeSecretKey||$arguments?.[ln],{isNode,isStash,isLoon,isShadowRocket,isQX}=An(),{githubProxy,githubProxyRegex,defaultProxy,defaultUserAgent,defaultTimeout,cacheThreshold:defaultCacheThreshold}=H.read(Bt),cacheThreshold=defaultCacheThreshold||1024,proxy=customProxy||defaultProxy;H.env.isNode&&(proxy=proxy||eval("process.env.SUB_STORE_BACKEND_DEFAULT_PROXY"));let userAgent=ua||defaultUserAgent||"clash.meta/v1.19.29",customHeaders;if($arguments?.headers)try{let e=JSON.parse($arguments?.headers);if(e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length>0){let t={"user-agent":userAgent};for(let r in e)t[r.toLowerCase()]=e[r];customHeaders=t}}catch(e){H.error(`\u89E3\u6790\u81EA\u5B9A\u4E49 headers \u5931\u8D25: ${e}`)}let requestTimeout=timeout||defaultTimeout||8e3;url=ire(url,githubProxy,githubProxyRegex);let safeUrl=ore(url),id=Xr(`${customHeaders?JSON.stringify(customHeaders):userAgent}${url}`);$arguments?.cacheKey===!0&&(H.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=H.read(customCacheKey),t=Jr.get(id);if(!noCache&&!$arguments?.noCache&&t)return H.info(`\u4E50\u89C2\u7F13\u5B58: URL ${safeUrl} \u5B58\u5728\u6709\u6548\u7684\u5E38\u89C4\u7F13\u5B58 \u4F7F\u7528\u5E38\u89C4\u7F13\u5B58\u4EE5\u907F\u514D\u91CD\u590D\u8BF7\u6C42`),$0(await Zh(t,{ageSecretKey,preprocess,url:safeUrl}),returnRaw);if(e){if(awaitCustomCache){H.info(`\u4E50\u89C2\u7F13\u5B58: URL ${safeUrl} \u672C\u6B21\u8FDB\u884C\u8BF7\u6C42 \u5C1D\u8BD5\u66F4\u65B0\u7F13\u5B58`);try{await Vi(rawUrl.replace(/(\?|&)cacheKey=.*?(&|$)/,""),ua,timeout,proxy,!0,void 0,void 0,preprocess)}catch(r){H.error(`\u4E50\u89C2\u7F13\u5B58: URL ${safeUrl} \u66F4\u65B0\u7F13\u5B58\u53D1\u751F\u9519\u8BEF ${r.message??r}`),H.info("\u4F7F\u7528\u4E50\u89C2\u7F13\u5B58\u7684\u6570\u636E\u5237\u65B0\u7F13\u5B58, \u9632\u6B62\u540E\u7EED\u8BF7\u6C42"),Jr.set(id,e)}}else H.info(`\u4E50\u89C2\u7F13\u5B58: URL ${safeUrl} \u672C\u6B21\u8FD4\u56DE\u81EA\u5B9A\u4E49\u7F13\u5B58 ${$arguments?.cacheKey} \u5E76\u8FDB\u884C\u8BF7\u6C42 \u5C1D\u8BD5\u5F02\u6B65\u66F4\u65B0\u7F13\u5B58`),Vi(rawUrl.replace(/(\?|&)cacheKey=.*?(&|$)/,""),ua,timeout,proxy,!0,void 0,void 0,preprocess).catch(r=>{H.error(`\u4E50\u89C2\u7F13\u5B58: URL ${safeUrl} \u5F02\u6B65\u66F4\u65B0\u7F13\u5B58\u53D1\u751F\u9519\u8BEF ${r.message??r}`)});return $0(await Zh(e,{ageSecretKey,preprocess,url:safeUrl}),returnRaw)}}let downloadUrlMatch=url.split("#")[0].match(/^\/api\/(file|module)\/(.+)/);if(downloadUrlMatch){let e="";try{e=downloadUrlMatch?.[1];let t=downloadUrlMatch?.[2];if(t==null)throw new Error(`\u672C\u5730 ${e} URL \u65E0\u6548: ${url}`);t=decodeURIComponent(t);let r=e==="module"?ts:Mt,n=$t(H.read(r),t);if(!n)throw new Error(`\u627E\u4E0D\u5230 ${e}: ${t}`);return B6(e==="module"?n.content:await Co({type:"file",name:t}),returnRaw)}catch(t){throw H.error(`Error when loading ${e}: ${url.split("#")[0]}. Reason: ${t}`),new Error(`\u65E0\u6CD5\u52A0\u8F7D ${e}: ${url}`)}}else if(url?.startsWith("/"))try{let fs=eval('require("fs")');return B6(fs.readFileSync(url.split("#")[0],"utf8"),returnRaw)}catch(e){throw H.error(`Error when reading local file: ${url.split("#")[0]}. Reason: ${e}`),new Error(`\u65E0\u6CD5\u4ECE\u8BE5\u8DEF\u5F84\u8BFB\u53D6\u6587\u672C\u5185\u5BB9: ${url}`)}if(!isNode&&I6.has(id))return $0(await Zh(await I6.get(id),{ageSecretKey,preprocess,url:safeUrl}),returnRaw);let http=Za({headers:{...customHeaders||{"User-Agent":userAgent},...isStash&&proxy?{"X-Stash-Selected-Proxy":encodeURIComponent(proxy)}:{},...isShadowRocket&&proxy?{"X-Surge-Policy":proxy}:{}},timeout:requestTimeout}),result,rawResult,cached=Jr.get(id);if(!noCache&&!$arguments?.noCache&&cached)H.info(`\u4F7F\u7528\u7F13\u5B58: ${safeUrl}, ${customHeaders?JSON.stringify(customHeaders):userAgent}`),rawResult=cached,result=await Zh(cached,{ageSecretKey,preprocess,url:safeUrl}),customCacheKey&&(H.info(`URL ${safeUrl} \u5199\u5165\u81EA\u5B9A\u4E49\u7F13\u5B58 ${$arguments?.cacheKey}`),H.write(cached,customCacheKey));else{let e=$arguments?.insecure?isNode?{strictSSL:!1}:{insecure:!0}:void 0;H.info(`Downloading... ${customHeaders?JSON.stringify(customHeaders):`User-Agent: ${userAgent}`} Timeout: ${requestTimeout} Proxy: ${proxy} Insecure: ${!!e} Preprocess: ${preprocess} URL: ${safeUrl}`);try{let{body:t,headers:r,statusCode:n}=await hh(()=>http.get({url,...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?tu(proxy):{},...e||{}}),"download");if(H.info(`statusCode: ${n}`),n<200||n>=400)throw new Error(`statusCode: ${n}`);if(r){let o=zl(r);o&&Vl.set(id,o,$arguments?.headersCacheTtl?$arguments?.headersCacheTtl*1e3:void 0)}if(t.replace(/\s/g,"").length===0)throw new Error(new Error("\u8FDC\u7A0B\u8D44\u6E90\u5185\u5BB9\u4E3A\u7A7A"));result=await Zh(t,{ageSecretKey,preprocess,url:safeUrl});let i=!0;if(cacheThreshold){let o=t.length/1024;o>cacheThreshold&&(H.info(`\u8D44\u6E90\u5927\u5C0F ${o.toFixed(2)} KB \u8D85\u8FC7\u4E86 ${cacheThreshold} KB, \u4E0D\u7F13\u5B58`),i=!1)}result.shouldCache||(H.error(result.cacheReason),i=!1),i&&(Jr.set(id,t,$arguments?.cacheTtl?$arguments?.cacheTtl*1e3:void 0),customCacheKey&&(H.info(`URL ${safeUrl} \u5199\u5165\u81EA\u5B9A\u4E49\u7F13\u5B58 ${$arguments?.cacheKey}`),H.write(t,customCacheKey))),rawResult=t}catch(t){if(customCacheKey){let n=H.read(customCacheKey);if(n)return H.info(`\u65E0\u6CD5\u4E0B\u8F7D URL ${safeUrl}: ${t.message??t} \u4F7F\u7528\u81EA\u5B9A\u4E49\u7F13\u5B58 ${$arguments?.cacheKey}`),$0(await Zh(n,{ageSecretKey,preprocess,url:safeUrl}),returnRaw)}let r=`\u65E0\u6CD5\u4E0B\u8F7D URL ${safeUrl}: ${t.message??t}`;throw H.error(r),new Error(r)}}return $arguments?.validCheck&&await hg(mu(await ia(url,$arguments.flowUserAgent,void 0,proxy,$arguments.flowUrl,$arguments.flowHeaders))),isNode||I6.set(id,rawResult),$0(result,returnRaw)}async function dT(url,file){let undici=eval("require('undici')"),fs=eval("require('fs')"),{pipeline}=eval("require('stream/promises')"),{Agent,interceptors,request}=undici;H.info(`Downloading file... URL: ${url} File: ${file}`);let{body,statusCode}=await request(url,{dispatcher:new Agent().compose(interceptors.redirect({maxRedirections:3,throwOnMaxRedirect:!0}))});if(statusCode!==200)throw new Error(`Failed to download file from ${url}`);let fileStream=fs.createWriteStream(file);return await pipeline(body,fileStream),H.info(`File downloaded from ${url} to ${file}`),file}var ISe=B(T());var vSe=B(T());function are(){return{name:"HTML",test:n=>/^/.test(n),parse:()=>""}}function ure(){return{name:"Clash Provider",test:n=>/^payload:/gm.exec(n).index>=0,parse:n=>n.replace("payload:","").replace(/^\s*-\s*/gm,"")}}var mT=[are(),ure()];var ESe=B(T());function cre(){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 gT(){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 lre(){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))),gT().func(r))}}function fre(){return{type:"ALL",func:r=>{let n={"DEST-PORT":"DST-PORT","SRC-IP":"SRC-IP-CIDR","IN-PORT":"SRC-PORT"},i={payload:r.map(o=>{let s=`${n[o.type]||o.type},${o.content}`;return["IP-CIDR","IP-CIDR6","GEOIP"].includes(o.type)&&(o.options&&(o.options=o.options.filter(a=>["no-resolve"].includes(a))),s+=o.options?.length>0?`,${o.options.join(",")}`:""),s})};return pi.dump(i)}}}var vT={QX:cre(),Surge:gT(),Loon:lre(),Clash:fre()};var ASe=B(T()),hre=[[/^(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 dre(){return{name:"Universal Rule Parser",test:()=>!0,parse:n=>{let i=n.split(` `),o=[];for(let s of i)if(s=s.trim(),s.length!==0&&!/\s*#/.test(s))try{let a=s.split(",").map(f=>f.trim()),u=a[0],l=!1;for(let f of hre)if(f[0].test(u)){l=!0;let p={type:f[1],content:a[1]};["IP-CIDR","IP-CIDR6","GEOIP"].includes(p.type)&&(p.options=a.slice(2)),o.push(p)}if(!l)throw new Error("Invalid rule type: "+u)}catch(a){console.log(`Failed to parse line: ${s} Reason: ${a}`)}return o}}}var wT=[dre()];var sv=function(){function e(n){for(let i of mT)try{if(i.test(n))return H.info(`Pre-processor [${i.name}] activated`),i.parse(n)}catch(o){H.error(`Parser [${i.name}] failed Reason: ${o}`)}return n}function t(n){n=e(n);for(let i of wT){let o;try{o=i.test(n)}catch{o=!1}if(o)return H.info(`Rule parser [${i.name}] is activated!`),i.parse(n)}}function r(n,i){let o=vT[i];if(!o)throw new Error(`Target platform: ${i} is not supported!`);if(typeof o.type>"u"||o.type==="SINGLE")return n.map(s=>{try{return o.func(s)}catch(a){return console.log(`ERROR: cannot produce rule: ${JSON.stringify(s)} Reason: ${a}`),""}}).filter(s=>s.length>0).join(` `);if(o.type==="ALL")return o.func(n)}return{parse:t,produce:r}}();var TSe=B(T());var pre=new Set(["enabled","fallbackNotify"]),mre=new Set(["fallbackNotify","fallbackQuiet"]);function iv(e){return e===!0?"quiet":e===!1||e==null||e===""?"disabled":e}function ov(...e){for(let t of e)if(t!=null&&t!=="")return iv(t);return"disabled"}function av(e){return pre.has(iv(e))}function Qh(e){return mre.has(iv(e))}function T0({mode:e,message:t,notify:r}){let n=iv(e);if(n==="disabled"||Qh(n))throw new Error(t);av(n)&&r?.(t)}function uv({mode:e,notify:t,error:r}){av(e)&&t?.(r)}function $6({platform:e="JSON",produceType:t,produceOpts:r={}}){return t==="raw"?JSON.stringify([]):rr.produce([],e,t,r)}var RSe=B(T());var gre="x-sub-store-share-age-public-key";function yT(e){return String(e??"").trim()}function vre(e){let t=yT(e);return t?{[Oi]:t}:void 0}function wre(...e){for(let t of e){let r=yT(t?.[Oi]);if(r)return r}return""}function ET({req:e,type:t,name:r,findShareToken:n}){if(!e?.path?.startsWith("/share/"))return;let o=e.subStoreShareToken||(e.query?.token&&typeof n=="function"?n({token:e.query.token,type:t,name:r,pathname:e.path}):null),s=e.headers?.[gre];return vre(o?.[Oi]||s)}async function T6({body:e,res:t,configs:r=[]}){let n=wre(...r);if(!n)return e;let i=await lh(e??"",n);return t?.set&&t.set("Content-Type","text/plain; charset=utf-8"),i}var yre=["localFirst","remoteFirst"],Ere=["local","remote"],bre=["collection","local","none","remote","subscription"];function P0(e){return Object.keys(e).map(Ni).join(", ")}function bT(e){return yre.includes(e)}function Are(e){return So(e)?ST(e):e?.source}function ST(e){return bre.includes(e?.sourceType)?e.sourceType:"collection"}function cv(e){return(Array.isArray(e)?e:[e]).flat()}function CT(e){return cv(e).filter(t=>t!=null&&t!=="").join(` `)}function Sre(e,t){return t!=null&&t!==""?t:e.ignoreFailedRemoteFile}async function AT({file:e,sourceUrl:t,ua:r,proxy:n,noCache:i,ignoreFailedRemoteFile:o,notifyTitle:s="\u{1F30D} Sub-Store \u5904\u7406\u6587\u4EF6\u5931\u8D25"}){let a={},u=`${t||""}`.split(/[\r\n]+/).map(m=>m.trim()).filter(m=>m.length);if(u.length===0)throw new Error(`\u6587\u4EF6 ${e.name} \u672A\u914D\u7F6E\u8FDC\u7A0B\u6587\u4EF6 URL`);let l=await Promise.all(u.map(async m=>{try{return await Vi(m,r||e.ua,void 0,e.proxy||n,void 0,void 0,i)}catch(p){return a[m]=p,H.error(`\u6587\u4EF6 ${e.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${Ni(m)} \u53D1\u751F\u9519\u8BEF: ${p}`),""}})),f=Sre(e,o);if(Object.keys(a).length>0)if(f)f==="enabled"&&H.notify(s,`\u274C ${e.name}`,`\u8FDC\u7A0B\u6587\u4EF6 ${P0(a)} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);else throw new Error(`\u6587\u4EF6 ${e.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${P0(a)} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);return l}async function _T(e,{url:t,ua:r,content:n,mergeSources:i,ignoreFailedRemoteFile:o,proxy:s,noCache:a,notifyTitle:u}={}){if(n&&!bT(i))return n;if(t){let f=await AT({file:e,sourceUrl:t,ua:r,proxy:s,noCache:a,ignoreFailedRemoteFile:o,notifyTitle:u});return i==="localFirst"?f.unshift(n):i==="remoteFirst"&&f.push(n),f}if(Are(e)==="local"&&!bT(e.mergeSources))return e.content;let l=await AT({file:e,sourceUrl:e.url,ua:r,proxy:s,noCache:a,ignoreFailedRemoteFile:o,notifyTitle:u});return e.mergeSources==="localFirst"?l.unshift(e.content):e.mergeSources==="remoteFirst"&&l.push(e.content),l}async function Cre(e,t={}){let r={},n=ST(e);if(n==="none")return rr.yaml.safeDump(r);if(Ere.includes(n)){let i=await _T(e,t);if(e?.mode!=="proxy")return CT(i);let o=cv(i).map(s=>rr.parse(s)).flat();if(o.length===0)throw new Error(`\u6587\u4EF6 ${e.name} \u4E2D\u4E0D\u542B\u6709\u6548\u8282\u70B9`);r.proxies=rr.produce(o,"mihomo","internal",{"delete-underscore-fields":!0,"include-unsupported-proxy":e?.includeUnsupportedProxy})}else r.proxies=await Co({type:n,name:e?.sourceName,platform:"mihomo",produceType:"internal",produceOpts:{"delete-underscore-fields":!0,"include-unsupported-proxy":e?.includeUnsupportedProxy}});return rr.yaml.safeDump(r)}async function Co({type:e,name:t,platform:r,url:n,ua:i,content:o,mergeSources:s,ignoreFailedRemoteSub:a,ignoreFailedRemoteFile:u,produceType:l,produceOpts:f={},subscription:m,file:p,awaitCustomCache:d,$options:v,proxy:g,noCache:y,all:w}){if(r=r||"JSON",["subscription","sub"].includes(e)){let E;if(t){let D=H.read(Er);if(E=$t(D,t),!E)throw new Error(`\u627E\u4E0D\u5230\u8BA2\u9605 ${t}`)}else if(m)E=m;else throw new Error("\u672A\u63D0\u4F9B\u8BA2\u9605\u540D\u79F0\u6216\u8BA2\u9605\u6570\u636E");let S=ov(a,E.ignoreFailedRemoteSub);try{let D,F;if(o&&!["localFirst","remoteFirst"].includes(s))D=o,F=o;else if(n){let C={},P=await Promise.all(n.split(/[\r\n]+/).map(U=>U.trim()).filter(U=>U.length).map(async U=>{try{return await Vi(U,i||E.ua,void 0,g||E.proxy,void 0,d,y||E.noCache,!0,{returnRaw:!0})}catch(k){return C[U]=k,H.error(`\u8BA2\u9605 ${E.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Ni(U)} \u53D1\u751F\u9519\u8BEF: ${k}`),""}}));if(D=P.map(U=>U.result??U),F=P.map(U=>U.raw??U),Object.keys(C).length>0){let U=`\u8BA2\u9605 ${E.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${P0(C)} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`;T0({mode:S,message:U,notify:()=>{H.notify("\u{1F30D} Sub-Store \u5904\u7406\u8BA2\u9605\u5931\u8D25",`\u274C ${E.name}`,U)}})}s==="localFirst"?(D.unshift(o),F.unshift(o)):s==="remoteFirst"&&(D.push(o),F.push(o))}else if(E.source==="local"&&!["localFirst","remoteFirst"].includes(E.mergeSources))D=E.content,F=E.content;else{let C={},P=await Promise.all(E.url.split(/[\r\n]+/).map(U=>U.trim()).filter(U=>U.length).map(async U=>{try{return await Vi(U,i||E.ua,void 0,g||E.proxy,void 0,d,y||E.noCache,!0,{returnRaw:!0})}catch(k){return C[U]=k,H.error(`\u8BA2\u9605 ${E.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Ni(U)} \u53D1\u751F\u9519\u8BEF: ${k}`),""}}));if(D=P.map(U=>U.result??U),F=P.map(U=>U.raw??U),Object.keys(C).length>0){let U=`\u8BA2\u9605 ${E.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${P0(C)} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`;T0({mode:S,message:U,notify:()=>{H.notify("\u{1F30D} Sub-Store \u5904\u7406\u8BA2\u9605\u5931\u8D25",`\u274C ${E.name}`,U)}})}E.mergeSources==="localFirst"?(D.unshift(E.content),F.unshift(E.content)):E.mergeSources==="remoteFirst"&&(D.push(E.content),F.push(E.content))}if(l==="raw")return JSON.stringify((Array.isArray(D)?D:[D]).flat());let M=(Array.isArray(D)?D:[D]).map(C=>rr.parse(C)).flat();if(M.forEach(C=>{C._subName=E.name,C._subDisplayName=E.displayName}),M=await rr.process(M,E.process||[],r,{[E.name]:E},v,F),M.length===0)throw new Error(`\u8BA2\u9605 ${t} \u4E2D\u4E0D\u542B\u6709\u6548\u8282\u70B9`);let z={};for(let C of M){if(z[C.name]){H.notify("\u{1F30D} Sub-Store",`\u26A0\uFE0F \u8BA2\u9605 ${t} \u5305\u542B\u91CD\u590D\u8282\u70B9 ${C.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}z[C.name]=!0}return rr.produce(M,r,l,f)}catch(D){if(!Qh(S))throw D;return uv({mode:S,error:D,notify:F=>{H.notify("\u{1F30D} Sub-Store \u5904\u7406\u8BA2\u9605\u5931\u8D25",`\u274C ${E.name}`,`\u{1F914} \u539F\u56E0\uFF1A${F.message??F}`)}}),H.error(`\u8BA2\u9605 ${E.name} \u542F\u7528\u515C\u5E95\u540E\u8FD4\u56DE\u7A7A\u7ED3\u679C: ${D.message??D}`),$6({platform:r,produceType:l,produceOpts:f})}}else if(["collection","col"].includes(e)){let E=H.read(Er),S=H.read(pr),D=$t(S,t);if(!D)throw new Error(`\u627E\u4E0D\u5230\u7EC4\u5408\u8BA2\u9605 ${t}`);let F=[...D.subscriptions],M=D.subscriptionTags;Array.isArray(M)&&M.length>0&&E.forEach(C=>{Array.isArray(C.tag)&&C.tag.length>0&&!F.includes(C.name)&&C.tag.some(P=>M.includes(P))&&F.push(C.name)});let z=ov(a,D.ignoreFailedRemoteSub);try{let C={},P={},U={},k=0;if(await Promise.all(F.map(async N=>{let _=$t(E,N),R=ov(_.ignoreFailedRemoteSub),K=_.passThroughUA,Z=_.ua;K&&(H.info(`\u8BA2\u9605\u5F00\u542F\u4E86\u900F\u4F20 User-Agent, \u4F7F\u7528\u8BF7\u6C42\u7684 User-Agent: ${i}`),Z=i);try{H.info(`\u6B63\u5728\u5904\u7406\u5B50\u8BA2\u9605\uFF1A${_.name}...`);let Y,te;if(_.source==="local"&&!["localFirst","remoteFirst"].includes(_.mergeSources))Y=_.content,te=_.content;else{let ve={},we=await Promise.all(_.url.split(/[\r\n]+/).map(Te=>Te.trim()).filter(Te=>Te.length).map(async Te=>{try{return await Vi(Te,Z,void 0,g||_.proxy||D.proxy,void 0,void 0,y||_.noCache,!0,{returnRaw:!0})}catch(Le){return ve[Te]=Le,H.error(`\u8BA2\u9605 ${_.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Ni(Te)} \u53D1\u751F\u9519\u8BEF: ${Le}`),""}}));if(Y=we.map(Te=>Te.result??Te),te=we.map(Te=>Te.raw??Te),Object.keys(ve).length>0){let Te=`\u8BA2\u9605 ${_.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${P0(ve)} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`;T0({mode:R,message:Te,notify:()=>{H.notify("\u{1F30D} Sub-Store \u5904\u7406\u8BA2\u9605\u5931\u8D25",`\u274C ${_.name}`,Te)}})}_.mergeSources==="localFirst"?(Y.unshift(_.content),te.unshift(_.content)):_.mergeSources==="remoteFirst"&&(Y.push(_.content),te.push(_.content))}let se=(Array.isArray(Y)?Y:[Y]).map(ve=>rr.parse(ve)).flat();se.forEach(ve=>{ve._subName=_.name,ve._subDisplayName=_.displayName,ve._collectionName=D.name,ve._collectionDisplayName=D.displayName});let fe=Array.isArray(te)?te:[te];se=await rr.process(se,_.process||[],r,{[_.name]:_,_collection:D,$options:v},void 0,fe),C[N]=se,U[N]=fe,k++,H.info(`\u2705 \u5B50\u8BA2\u9605\uFF1A${_.name}\u52A0\u8F7D\u6210\u529F\uFF0C\u8FDB\u5EA6--${100*(k/F.length).toFixed(1)}% `)}catch(Y){if(k++,Qh(R)){uv({mode:R,error:Y,notify:te=>{H.notify("\u{1F30D} Sub-Store \u5904\u7406\u8BA2\u9605\u5931\u8D25",`\u274C ${_.name}`,`\u{1F914} \u539F\u56E0\uFF1A${te.message??te}`)}}),H.error(`\u8BA2\u9605 ${_.name} \u5728\u7EC4\u5408\u8BA2\u9605\u5904\u7406\u4E2D\u542F\u7528\u515C\u5E95\u540E\u8FD4\u56DE\u7A7A\u7ED3\u679C: ${Y.message??Y}`),C[N]=[],U[N]=[];return}P[N]=Y,U[N]=void 0,H.error(`\u274C \u5904\u7406\u7EC4\u5408\u8BA2\u9605\u4E2D\u7684\u5B50\u8BA2\u9605: ${_.name}\u65F6\u51FA\u73B0\u9519\u8BEF\uFF1A${Y}\uFF01\u8FDB\u5EA6--${100*(k/F.length).toFixed(1)}%`)}})),Object.keys(P).length>0){let N=`\u7EC4\u5408\u8BA2\u9605 ${D.name} \u7684\u5B50\u8BA2\u9605 ${Object.keys(P).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`,_=()=>{H.notify("\u{1F30D} Sub-Store \u5904\u7406\u7EC4\u5408\u8BA2\u9605\u5931\u8D25",`\u274C ${D.name}`,N)};Object.keys(C).length>0&&Qh(z)?(Object.keys(P).forEach(K=>{U[K]=[]}),av(z)&&_()):T0({mode:z,message:N,notify:_})}let O=Array.prototype.concat.apply([],F.map(N=>C[N]||[]));if(O.forEach(N=>{N._collectionName=D.name,N._collectionDisplayName=D.displayName}),O=await rr.process(O,D.process||[],r,{_collection:D},v,U),O.length===0)throw new Error(`\u7EC4\u5408\u8BA2\u9605 ${t} \u4E2D\u4E0D\u542B\u6709\u6548\u8282\u70B9`);let q={};for(let N of O){if(q[N.name]){H.notify("\u{1F30D} Sub-Store",`\u26A0\uFE0F \u7EC4\u5408\u8BA2\u9605 ${t} \u5305\u542B\u91CD\u590D\u8282\u70B9 ${N.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}q[N.name]=!0}return rr.produce(O,r,l,f)}catch(C){if(!Qh(z))throw C;return uv({mode:z,error:C,notify:P=>{H.notify("\u{1F30D} Sub-Store \u5904\u7406\u7EC4\u5408\u8BA2\u9605\u5931\u8D25",`\u274C ${D.name}`,`\u{1F914} \u539F\u56E0\uFF1A${P.message??P}`)}}),H.error(`\u7EC4\u5408\u8BA2\u9605 ${D.name} \u542F\u7528\u515C\u5E95\u540E\u8FD4\u56DE\u7A7A\u7ED3\u679C: ${C.message??C}`),$6({platform:r,produceType:l,produceOpts:f})}}else if(e==="rule"){let E=H.read(kd),S=$t(E,t);if(!S)throw new Error(`\u627E\u4E0D\u5230\u89C4\u5219 ${t}`);let D=[];for(let F=0;F0?await rr.process({$files:F,$content:M,$options:v,$file:S},S.process):{$content:M,$files:F,$options:v};return z.$content=Qp(z?.$content??""),(w?z:z?.$content)??""}}var t6e=B(T());function _re(e){return typeof e.getHeaders=="function"?{...e.getHeaders()}:{}}function Dre(e,t,r={}){for(let n of Object.keys(t))Object.prototype.hasOwnProperty.call(r,n)||e.removeHeader(n);for(let[n,i]of Object.entries(r))i==null?e.removeHeader(n):e.set(n,i)}function Fre(e,t){let r=Number(t);Number.isInteger(r)&&r>=100&&r<=599&&e.status(r)}async function DT({res:e,body:t,process:r,targetPlatform:n,source:i,$options:o}){let s=_re(e),a=await rr.processResponse({status:e.statusCode||200,headers:s,body:t},r||[],n,i,o);return Dre(e,s,a.header||a.headers),Fre(e,a.status||a.statusCode),a.body}var d6e=B(T());function P6(e){H.read(rn)||H.write([],rn),e.post("/api/token",$re),e.route("/api/token/:token").delete(Ire),e.route("/api/tokens").get(Bre)}function Ire(e,t){try{let{token:r}=e.params,{type:n,name:i}=e.query;if(!n||!i)throw new Ke("INVALID_PAYLOAD","Payload type and name are required. Please update your front-end(version >= 2.15.76)");H.info(`\u6B63\u5728\u5220\u9664... token: ${r}, \u7C7B\u578B\uFF1A${n}, \u540D\u79F0\uFF1A${i}`),Ure(e.query.mode)&&h8(r,n,i),Lre(r,n,i),Ze(t)}catch(r){Je(t,r)}}function Bre(e,t){let{type:r,name:n}=e.query,i=H.read(rn)||[];Ze(t,r||n?i.filter(o=>(r?o.type===r:!0)&&(n?o.name===n:!0)):i)}async function $re(e,t){if(!An().isNode)return Je(t,new Ke("INVALID_ENV","This endpoint is only available in Node.js environment"));try{let r=x6(e.body.payload,e.body.options);return Ze(t,{token:r.token})}catch(r){return Je(t,r instanceof Ke?r:new Pr("TOKEN_SIGN_FAILED","Failed to sign token",`Reason: ${r.message??r}`))}}function Tre(e){if(!(e==null||e==="")){if(e==="duration"||e==="datetime"||e==="count")return e;throw new Ke("INVALID_EXPIRATION_MODE",`Unsupported expiration mode: ${e}`)}}function Pre(e={}){if(e?.expiresIn!=null&&e.expiresIn!=="")return"duration";if(e?.exp!=null&&e.exp!=="")return"datetime"}function xre(e={}){let t=e?.exp;if(typeof t!="number"&&typeof t!="string")throw new Ke("INVALID_EXPIRATION_DATETIME",`Invalid exp option: ${t}`);let r=typeof t=="string"?t.trim():t;if(r==="")throw new Ke("INVALID_EXPIRATION_DATETIME",`Invalid exp option: ${t}`);let n=Number(r);if(!Number.isSafeInteger(n)||n<=0||n<1e12)throw new Ke("INVALID_EXPIRATION_DATETIME",`Invalid exp option: ${t}`);return n}function Rre(options={},{required=!1}={}){let rawExpiresIn=options?.expiresIn;if(rawExpiresIn==null||rawExpiresIn===""){if(required)throw new Ke("INVALID_EXPIRES_IN",`Invalid expiresIn option: ${rawExpiresIn}`);return null}let ms=eval('require("ms")'),expiresIn=ms(rawExpiresIn);if(expiresIn==null||isNaN(expiresIn)||expiresIn<=0)throw new Ke("INVALID_EXPIRES_IN",`Invalid expiresIn option: ${rawExpiresIn}`);return{rawExpiresIn,expiresIn,exp:Date.now()+expiresIn}}var kre={day:24*60*60*1e3,month:30*24*60*60*1e3,season:90*24*60*60*1e3,year:365*24*60*60*1e3};function Ore(e={},t){let r=e?.expiresValue,n=e?.expiresUnit,i=r!=null&&r!=="",o=n!=null&&n!=="";if(!i&&!o)return null;let s=Number(r);if(!Number.isFinite(s)||s<=0)throw new Ke("INVALID_EXPIRES_VALUE",`Invalid expiresValue option: ${r}`);let a=typeof n=="string"?n.trim():"";if(!["day","month","season","year"].includes(a))throw new Ke("INVALID_EXPIRES_UNIT",`Invalid expiresUnit option: ${n}`);let u=Number(s.toFixed(2)),l=u*kre[a];if(t&&Math.abs(t.expiresIn-l)>1)throw new Ke("INVALID_DURATION_INPUT",`expiresValue/expiresUnit do not match expiresIn option: ${r}${a} != ${e?.expiresIn}`);return{expiresValue:String(u),expiresUnit:a}}function Nre(e={}){let t=e?.count;if(t==null||t==="")throw new Ke("INVALID_SHARE_COUNT",`Invalid count option: ${t}`);let r=Number(t);if(!Number.isSafeInteger(r)||r<=0)throw new Ke("INVALID_SHARE_COUNT",`Invalid count option: ${t}`);let n=e?.usedCount??0,i=Number(n);if(!Number.isSafeInteger(i)||i<0||i>r)throw new Ke("INVALID_SHARE_USED_COUNT",`Invalid usedCount option: ${n}`);return{count:r,usedCount:i}}function x6(payload,options={}){let type=payload?.type,name=payload?.name;if(!type||!name)throw new Ke("INVALID_PAYLOAD","payload type and name are required");let token=payload?.token;if(token!=null){if(typeof token!="string"||token.length<1)throw new Ke("INVALID_CUSTOM_TOKEN",`Invalid custom token: ${token}`);if((H.read(rn)||[]).find(t=>t.token===token&&t.type===type&&t.name===name))throw new Ke("DUPLICATE_TOKEN",`Token ${token} already exists`)}if(type==="col"){if(!(H.read(pr)||[]).find(r=>r.name===name))throw new Ke("INVALID_COLLECTION",`collection ${name} not found`)}else if(type==="file"){if(!(H.read(Mt)||[]).find(r=>r.name===name))throw new Ke("INVALID_FILE",`file ${name} not found`)}else if(type==="sub"){if(!(H.read(Er)||[]).find(r=>r.name===name))throw new Ke("INVALID_SUB",`sub ${name} not found`)}else throw new Ke("INVALID_TYPE",`type ${name} not supported`);let expirationMode=Tre(options?.mode)??Pre(options),durationExpiration=null,durationInput=null,exp,countExpiration=null;expirationMode==="datetime"?exp=xre(options):expirationMode==="count"?countExpiration=Nre(options):(durationExpiration=Rre(options,{required:expirationMode==="duration"}),durationExpiration&&(durationInput=Ore(options,durationExpiration)),exp=durationExpiration?.exp);let nanoid=eval('require("nanoid")'),tokens=H.read(rn)||[];if(!token)do token=nanoid.customAlphabet(nanoid.urlAlphabet)();while(tokens.find(e=>e.token===token&&e.type===type&&e.name===name));let normalizedMode=expirationMode==="datetime"?"datetime":expirationMode==="count"?"count":durationExpiration?"duration":void 0,safePayload={...payload};delete safePayload.mode,delete safePayload.exp,delete safePayload.expiresIn,delete safePayload.expiresValue,delete safePayload.expiresUnit,delete safePayload.count,delete safePayload.usedCount,_n(safePayload);let tokenData={...safePayload,token,createdAt:Date.now(),...normalizedMode?{mode:normalizedMode}:{},...normalizedMode==="datetime"?{exp}:normalizedMode==="count"?{count:countExpiration.count,usedCount:countExpiration.usedCount}:durationExpiration?{expiresIn:durationExpiration.rawExpiresIn,...durationInput||{},exp}:{}};return Ko(tokens,tokenData,Vo()),H.write(tokens,rn),tokenData}function Lre(e,t,r){let n=H.read(rn)||[],i=n.find(s=>s.token===e&&s.type===t&&s.name===r);if(!i)throw new Ot("RESOURCE_NOT_FOUND",`Share ${t}/${r}/${e} does not exist!`);let o=n.filter(s=>!(s.token===e&&s.type===t&&s.name===r));return H.write(o,rn),i}function FT(e,{token:t,type:r,name:n,pathname:i}){return e.token===t&&(r?e.type===r:!0)&&(n?e.name===n:!0)&&(i?`/share/${e.type}/${e.name}`===i||i.startsWith(`/share/${e.type}/${e.name}/`):!0)}function IT(e){if(e.exp!=null&&e.exp<=Date.now())return!1;if(e.mode==="count"){let t=Number(e.count),r=e.usedCount==null?0:Number(e.usedCount);return Number.isSafeInteger(t)&&t>0&&Number.isSafeInteger(r)&&r>=0&&rFT(o,e)&&IT(o));if(r<0)return null;let n=t[r];if(n.mode!=="count")return n;let i={...n,usedCount:Number(n.usedCount??0)+1};return t[r]=i,H.write(t,rn),i}function BT(e){return(H.read(rn)||[]).find(r=>FT(r,e)&&IT(r))||null}function Ure(e){if(e==null||e===""||e==="permanent")return!1;if(e==="archive")return!0;throw new Ke("INVALID_DELETE_MODE",`Unsupported delete mode: ${e}`)}function R6(e){H.read(Mt)||H.write([],Mt),e.get("/share/file/:name",$T),e.route("/api/file/:name").get($T).patch(qre).delete(jre),e.route("/api/wholeFile/:name").get(Mre),e.route("/api/files").get(Kre).post(Hre).put(zre),e.route("/api/wholeFiles").get(Vre)}function Hre(e,t){try{let r=k6(e.body);Ze(t,r,201)}catch(r){Je(t,r)}}async function $T(e,t,r){let{name:n}=e.params,i=e.headers["user-agent"]||e.headers["User-Agent"],o=e.path?.startsWith("/share/");H.info(`\u6B63\u5728\u4E0B\u8F7D\u6587\u4EF6\uFF1A${n} \u8BF7\u6C42 User-Agent: ${i}`);let{url:s,subInfoUrl:a,subInfoUserAgent:u,ua:l,content:f,mergeSources:m,ignoreFailedRemoteFile:p,includeUnsupportedProxy:d,type:v,source:g,sourceType:y,sourceName:w,mode:E,proxy:S,noCache:D,produceType:F,download:M,fakeFile:z}=e.query,C={_req:{method:e.method,url:e.url,path:e.path,query:e.query,params:e.params,headers:e.headers,body:e.body,socket:{remoteAddress:e.socket?.remoteAddress}}};if(e.query.$options){let O={};try{O=JSON.parse(decodeURIComponent(e.query.$options))}catch{for(let N of e.query.$options.split("&")){let _=N.split("=")[0],R=N.split("=")[1];O[_]=R==null||R===""?!0:decodeURIComponent(R)}}H.info(`\u4F20\u5165 $options: ${JSON.stringify(O)}`),Object.assign(C,O)}if(o&&z){H.warn(`\u5206\u4EAB\u94FE\u63A5\u7981\u6B62\u4F7F\u7528 fakeFile: ${n}`),Je(t,new Ke("UNSUPPORTED_SHARE_FAKE_FILE","share/file \u4E0D\u652F\u6301 fakeFile \u53C2\u6570"),400);return}if(z&&!Xre({content:f,fileType:v,sourceName:w,sourceType:y,url:s})){H.warn(`fakeFile \u7F3A\u5C11\u53EF\u7528\u6765\u6E90: ${n}`),Je(t,new Ke("INVALID_FAKE_FILE_SOURCE","fakeFile \u9700\u8981\u63D0\u4F9B content/url \u6216 mihomo \u914D\u7F6E\u6765\u6E90\u53C2\u6570"),400);return}if(o&&(s!=null&&s!==""||f!=null&&f!=="")){H.warn(`\u5206\u4EAB\u94FE\u63A5\u7981\u6B62\u4F7F\u7528 url/content: ${n}`),Je(t,new Ke("UNSUPPORTED_SHARE_FILE_SOURCE_OVERRIDE","share/file \u4E0D\u652F\u6301 url \u6216 content \u53C2\u6570"),400);return}if(o&&TT([v,g,y,w,E])){H.warn(`\u5206\u4EAB\u94FE\u63A5\u7981\u6B62\u4F7F\u7528\u6587\u4EF6\u6765\u6E90\u914D\u7F6E\u8986\u76D6: ${n}`),Je(t,new Ke("UNSUPPORTED_SHARE_FILE_RUNTIME_OVERRIDE","share/file \u4E0D\u652F\u6301\u6587\u4EF6\u6765\u6E90\u914D\u7F6E\u8986\u76D6\u53C2\u6570"),400);return}if(o&&a!=null&&a!==""){H.warn(`\u5206\u4EAB\u94FE\u63A5\u7981\u6B62\u4F7F\u7528 subInfoUrl: ${n}`),Je(t,new Ke("UNSUPPORTED_SHARE_FILE_SUB_INFO_URL","share/file \u4E0D\u652F\u6301 subInfoUrl \u53C2\u6570"),400);return}if(o&&m){H.warn(`\u5206\u4EAB\u94FE\u63A5\u7981\u6B62\u4F7F\u7528 mergeSources: ${n}`),Je(t,new Ke("UNSUPPORTED_SHARE_FILE_MERGE_SOURCES","share/file \u4E0D\u652F\u6301 mergeSources \u53C2\u6570"),400);return}s&&H.info(`\u6307\u5B9A\u8FDC\u7A0B\u6587\u4EF6 URL: ${Ni(s)}`),z&&H.info(`\u4F7F\u7528\u5047\u6587\u4EF6, \u4E0D\u518D\u901A\u8FC7\u5355\u4E2A\u6587\u4EF6\u540D\u79F0 ${n} \u67E5\u8BE2`),S&&H.info(`\u6307\u5B9A\u8FDC\u7A0B\u6587\u4EF6\u4F7F\u7528\u4EE3\u7406/\u7B56\u7565 proxy: ${S}`),l&&H.info(`\u6307\u5B9A\u8FDC\u7A0B\u6587\u4EF6 User-Agent: ${l}`),a&&H.info(`\u6307\u5B9A\u83B7\u53D6\u6D41\u91CF\u7684 subInfoUrl: ${a}`),u&&H.info(`\u6307\u5B9A\u83B7\u53D6\u6D41\u91CF\u7684 subInfoUserAgent: ${u}`),f&&H.info(`\u6307\u5B9A\u672C\u5730\u6587\u4EF6: ${f}`),m&&H.info(`\u6307\u5B9A\u5408\u5E76\u6765\u6E90: ${m}`),p!=null&&p!==""&&H.info(`\u6307\u5B9A\u5FFD\u7565\u5931\u8D25\u7684\u8FDC\u7A0B\u6587\u4EF6: ${p}`),D&&H.info(`\u6307\u5B9A\u4E0D\u4F7F\u7528\u7F13\u5B58: ${D}`),F&&H.info(`\u6307\u5B9A\u751F\u4EA7\u7C7B\u578B: ${F}`),v&&H.info(`\u6307\u5B9A\u6587\u4EF6\u7C7B\u578B: ${v}`),g&&H.info(`\u6307\u5B9A\u6587\u4EF6\u6765\u6E90: ${g}`),y&&H.info(`\u6307\u5B9A mihomo \u914D\u7F6E\u6765\u6E90: ${y}`),w&&H.info(`\u6307\u5B9A mihomo \u914D\u7F6E\u6765\u6E90\u540D\u79F0: ${w}`),E&&H.info(`\u6307\u5B9A mihomo \u914D\u7F6E\u5904\u7406\u65B9\u5F0F: ${E}`),M&&H.info("\u542F\u7528\u4E0B\u8F7D(\u6587\u4EF6\u540D\u4E3A\u663E\u793A\u540D\u79F0)"),d!=null&&d!==""&&H.info(`\u5305\u542B\u5B98\u65B9/\u5546\u5E97\u7248\u4E0D\u652F\u6301\u7684\u534F\u8BAE: ${d}`);let P=H.read(Mt)||[],k=z?{name:"fakeFile",source:"remote",url:""}:$t(P,n);if(k)try{let O=Wre(k,{content:f,download:M,fileSource:g,fileType:v,ignoreFailedRemoteFile:p,includeUnsupportedProxy:d,mergeSources:m,mode:E,noCache:D,sourceName:w,sourceType:y,produceType:F,proxy:S,subInfoUrl:a,subInfoUserAgent:u,ua:l,url:s}),q=await Co({type:"file",name:n,url:s,ua:l,content:f,mergeSources:m,ignoreFailedRemoteFile:p,$options:C,proxy:S,noCache:D,produceType:F,all:!0,file:O});try{let _=O.subInfoUrl;if(_){let R=await ia(_,O.subInfoUserAgent,void 0,O.proxy);if(R){let K=pg(R,!0);K?.["subscription-userinfo"]&&t.set("subscription-userinfo",K["subscription-userinfo"]),K?.["profile-web-page-url"]&&t.set("profile-web-page-url",K["profile-web-page-url"]),K?.["plan-name"]&&t.set("plan-name",K["plan-name"])}}}catch(_){H.error(`\u6587\u4EF6 ${n} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(_)}`)}O.download&&t.set("Content-Disposition",`attachment; filename*=UTF-8''${encodeURIComponent(O.displayName||O.name)}`),t.set("Content-Type","text/plain; charset=utf-8"),q?.$options?._res?.headers&&Object.entries(q.$options._res.headers).forEach(([_,R])=>{R==null?t.removeHeader(_):t.set(_,R)}),q?.$options?._res?.status&&t.status(q.$options._res.status);let N=await DT({res:t,body:q?.$content??"",process:O.process,source:{$file:O},$options:q?.$options??C});t.send(await T6({res:t,body:N,configs:[ET({req:e,type:"file",name:n,findShareToken:BT}),O]}))}catch(O){H.notify("\u{1F30D} Sub-Store \u4E0B\u8F7D\u6587\u4EF6\u5931\u8D25",`\u274C \u65E0\u6CD5\u4E0B\u8F7D\u6587\u4EF6\uFF1A${n}\uFF01`,`\u{1F914} \u539F\u56E0\uFF1A${O.message??O}`),H.error(O.message??O),Je(t,new Pr("INTERNAL_SERVER_ERROR",`Failed to download file: ${n}`,`Reason: ${O.message??O}`))}else H.error(`\u{1F30D} Sub-Store \u4E0B\u8F7D\u6587\u4EF6\u5931\u8D25 \u274C \u672A\u627E\u5230\u6587\u4EF6\uFF1A${n}\uFF01`),Je(t,new Ot("RESOURCE_NOT_FOUND",`File ${n} does not exist!`),404)}function Mre(e,t){let{name:r}=e.params,{raw:n}=e.query,i=H.read(Mt),o=$t(i,r);o?n?t.set("content-type","application/json").set("access-control-expose-headers","content-disposition").set("content-disposition",`attachment; filename="${encodeURIComponent(`sub-store_file_${r}_${ic(new Date)}.json`)}"`).send(JSON.stringify(o)):Ze(t,o):Je(t,new Ot("FILE_NOT_FOUND",`File ${r} does not exist`,404))}function qre(e,t){let{name:r}=e.params,n=e.body,i=H.read(Mt)||[],o=$t(i,r);if(o){n.name||(n.name=o.name);let s=Hh({...o,...n});if(_n(s),Li(s),H.info(`\u6B63\u5728\u66F4\u65B0\u6587\u4EF6\uFF1A${r}...`),r!==s.name){let a=H.read(Wt)||[];for(let u of a)u.type==="file"&&u.source===o.name&&(u.source=s.name);H.write(a,Wt)}$i(i,r,s),H.write(i,Mt),Ze(t,s)}else Je(t,new Ot("RESOURCE_NOT_FOUND",`File ${r} does not exist!`),404)}function jre(e,t){try{let{name:r}=e.params;H.info(`\u6B63\u5728\u5220\u9664\u6587\u4EF6\uFF1A${r}`),Yre(e.query.mode)&&l8(r),Gre(r),Ze(t)}catch(r){Je(t,r)}}function Kre(e,t){let r=H.read(Mt)||[];Ze(t,r.map(({content:n,...i})=>i))}function Vre(e,t){let r=H.read(Mt)||[];Ze(t,r)}function zre(e,t){try{let r=e.body.map(Hh);r.forEach(n=>{_n(n),Li(n)}),H.write(r,Mt),Ze(t)}catch(r){Je(t,r)}}function k6(e){let t=Hh({...e});_n(t),Li(t),t.name=`${t.name??Date.now()}`,H.info(`\u6B63\u5728\u521B\u5EFA\u6587\u4EF6\uFF1A${t.name}`);let r=H.read(Mt);if($t(r,t.name))throw new Ke("DUPLICATE_KEY",e.name?`\u5DF2\u5B58\u5728 name \u4E3A ${t.name} \u7684\u6587\u4EF6`:"\u65E0\u6CD5\u540C\u65F6\u521B\u5EFA\u76F8\u540C\u7684\u6587\u4EF6 \u53EF\u7A0D\u540E\u91CD\u8BD5");return Ko(r,t,Vo()),H.write(r,Mt),t}function Gre(e){let t=H.read(Mt)||[],r=$t(t,e);if(!r)throw new Ot("RESOURCE_NOT_FOUND",`File ${e} does not exist!`);return jo(t,e),H.write(t,Mt),r}function Yre(e){if(e==null||e===""||e==="permanent")return!1;if(e==="archive")return!0;throw new Ke("INVALID_DELETE_MODE",`Unsupported delete mode: ${e}`)}function Wre(e,{content:t,download:r,fileSource:n,fileType:i,ignoreFailedRemoteFile:o,includeUnsupportedProxy:s,mergeSources:a,mode:u,noCache:l,produceType:f,proxy:m,sourceName:p,sourceType:d,subInfoUrl:v,subInfoUserAgent:g,ua:y,url:w}={}){let E={...e};return Gn(E,"content",t),Gn(E,"download",r),Gn(E,"ignoreFailedRemoteFile",o),Gn(E,"mergeSources",a),Gn(E,"noCache",l),Gn(E,"produceType",f),Gn(E,"proxy",m),Gn(E,"subInfoUrl",v),Gn(E,"subInfoUserAgent",g),Gn(E,"type",i),E.type=j9(E.type),Gn(E,"ua",y),Gn(E,"url",w),Gn(E,"source",n),So(E)&&(Gn(E,"sourceType",d),Gn(E,"sourceName",p),Gn(E,"mode",u),E.sourceType||(x0(w)?E.sourceType="remote":x0(t)&&(E.sourceType="local"))),Gn(E,"includeUnsupportedProxy",s),E}function Xre({content:e,fileType:t,sourceName:r,sourceType:n,url:i}){if(TT([e,i]))return!0;if(!So(lv(t)))return!1;let o=lv(n);return o==="none"?!0:["subscription","collection"].includes(o)&&x0(r)}function Gn(e,t,r){x0(r)&&(e[t]=lv(r))}function lv(e){return Array.isArray(e)?e[e.length-1]:e}function x0(e){let t=lv(e);return t!=null&&t!==""}function TT(e){return e.some(x0)}var M6e=B(T());function O6(e){wl(),e.route("/api/archives").get(Jre),e.route("/api/archives/:id").get(Zre).delete(Qre),e.post("/api/archives/:id/restore",ene)}function Jre(e,t){Ze(t,o8())}function Zre(e,t){try{Ze(t,Iy(e.params.id))}catch(r){Je(t,r,r instanceof Ot?404:500)}}function Qre(e,t){try{let r=By(e.params.id);Ze(t,r)}catch(r){Je(t,r,r instanceof Ot?404:500)}}function ene(e,t){try{let r=Iy(e.params.id),n=tne(r);By(e.params.id),Ze(t,n)}catch(r){let n=r instanceof Ke||r instanceof Ot?r:new Pr("ARCHIVE_RESTORE_FAILED","Failed to restore archive entry",`Reason: ${r.message??r}`),i=n instanceof Ot?404:n instanceof Ke?400:500;Je(t,n,i)}}function tne(e){let t=JSON.parse(JSON.stringify(e.snapshot));switch(e.itemType){case"sub":return Mb(t);case"col":return xb(t);case"file":return k6(t);case"artifact":return Yb(rne(t));case"share":return x6(t,{mode:t.mode,expiresIn:t.expiresIn,expiresValue:t.expiresValue,expiresUnit:t.expiresUnit,exp:t.exp,count:t.count,usedCount:t.usedCount});default:throw new Ke("INVALID_ARCHIVE_TYPE",`Unsupported archive item type: ${e.itemType}`)}}function rne(e){let t={...e};return delete t.updated,delete t.url,t}var W6e=B(T());function N6(e){H.read(ts)||H.write([],ts),e.route("/api/module/:name").get(sne).patch(ine).delete(one),e.route("/api/modules").get(ane).post(nne).put(une)}function nne(e,t){let r=e.body;r.name=`${r.name??Xr(JSON.stringify(r))}`,H.info(`\u6B63\u5728\u521B\u5EFA\u6A21\u5757\uFF1A${r.name}`);let n=H.read(ts);if($t(n,r.name))return Je(t,new Ke("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),H.write(n,ts),Ze(t,r,201)}function sne(e,t){let{name:r}=e.params,n=H.read(ts),i=$t(n,r);i?t.set("Content-Type","text/plain; charset=utf-8").send(i.content):Je(t,new Ot("MODULE_NOT_FOUND",`Module ${r} does not exist`,404))}function ine(e,t){let{name:r}=e.params,n=e.body,i=H.read(ts),o=$t(i,r);if(o){let s={...o,...n};H.info(`\u6B63\u5728\u66F4\u65B0\u6A21\u5757\uFF1A${r}...`),$i(i,r,s),H.write(i,ts),Ze(t,s)}else Je(t,new Ot("RESOURCE_NOT_FOUND",`Module ${r} does not exist!`),404)}function one(e,t){let{name:r}=e.params;H.info(`\u6B63\u5728\u5220\u9664\u6A21\u5757\uFF1A${r}`);let n=H.read(ts);jo(n,r),H.write(n,ts),Ze(t)}function ane(e,t){let r=H.read(ts);Ze(t,r.map(({content:n,...i})=>i))}function une(e,t){let r=e.body;H.write(r,ts),Ze(t)}var t3e=B(T());function L6(e){e.route("/api/logs").get(cne).delete(lne)}function cne(e,t){try{Ze(t,__(H,e.query||{}))}catch(r){if(r instanceof SyntaxError){Je(t,new Ke("INVALID_LOG_KEYWORD_REGEX","Invalid log keyword regular expression",`Reason: ${r.message??r}`),400);return}Je(t,new Pr("FAILED_TO_GET_LOGS","Failed to get logs",`Reason: ${r.message??r}`))}}function lne(e,t){try{D_(H),Ze(t)}catch(r){Je(t,new Pr("FAILED_TO_CLEAR_LOGS","Failed to clear logs",`Reason: ${r.message??r}`))}}var i3e=B(T());function U6(e){e.post("/api/utils/age/key-pair",fne),e.post("/api/utils/age/public-key",hne)}async function fne(e,t){try{let r=await SI(e.body?.type||ch.X25519);Ze(t,{type:r.type,[ln]:r[ln],[Oi]:r[Oi]})}catch(r){Je(t,r)}}async function hne(e,t){try{let r=await Kl(e.body?.[ln]);Ze(t,{[Oi]:r})}catch(r){Je(t,r)}}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${L1} \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 `);Rf();dne();function dne(){let e=Dy({substore:H});Pb(e),Hb(e),P6(e),R6(e),N6(e),Gb(e),Wb(e),nA(e),O6(e),rA(e),L6(e),U6(e),e.start()}})(); /*! Bundled license information: 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 *) 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 *) @scure/base/index.js: (*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/ciphers/utils.js: (*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) *) @noble/hashes/utils.js: (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/utils.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/abstract/modular.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/abstract/curve.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/abstract/montgomery.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/abstract/weierstrass.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/ed25519.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/nist.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/post-quantum/utils.js: (*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) *) @noble/post-quantum/_crystals.js: (*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) *) @noble/post-quantum/ml-kem.js: (*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) *) @noble/post-quantum/hybrid.js: (*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) *) @noble/curves/utils.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/abstract/modular.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/abstract/curve.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/abstract/weierstrass.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/nist.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/abstract/edwards.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/abstract/montgomery.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/ed25519.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) */