(()=>{var t9=Object.create;var HA=Object.defineProperty;var r9=Object.getOwnPropertyDescriptor;var n9=Object.getOwnPropertyNames;var i9=Object.getPrototypeOf,s9=Object.prototype.hasOwnProperty;var Po=(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 he=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var a9=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of n9(t))!s9.call(e,i)&&i!==r&&HA(e,i,{get:()=>t[i],enumerable:!(n=r9(t,i))||n.enumerable});return e};var _n=(e,t,r)=>(r=e!=null?t9(i9(e)):{},a9(t||!e||!e.__esModule?HA(r,"default",{value:e,enumerable:!0}):r,e));var VA=he(qA=>{"use strict";(function(e){function t(){}function r(){}var n=String.fromCharCode,i={}.toString,a=i.call(e.SharedArrayBuffer),s=i(),u=e.Uint8Array,l=u||Array,f=u?ArrayBuffer:l,d=f.isView||function(w){return w&&"length"in w},m=i.call(f.prototype);f=r.prototype;var p=e.TextEncoder,h=new(u?Uint16Array:l)(32);t.prototype.decode=function(w){if(!d(w)){var v=i.call(w);if(v!==m&&v!==a&&v!==s)throw TypeError("Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");w=u?new l(w):w||[]}for(var y=v="",g=0,b=w.length|0,D=b-32|0,C,F,U=0,L=0,S,B=0,O=-1;g>4){case 15:if(S=w[g=g+1|0]&255,S>>6!==2||247>6===2?L+4|0:24,F=F+256&768;case 13:case 12:S=w[g=g+1|0]&255,U<<=6,U|=(F&31)<<6|S&63,L=L+7|0,g>6===2&&U>>L&&1114112>U?(F=U,U=U-65536|0,0<=U&&(O=(U>>10)+55296|0,F=(U&1023)+56320|0,31>B?(h[B]=O,B=B+1|0,O=-1):(S=O,O=F,F=S))):(F>>=8,g=g-F-1|0,F=65533),U=L=0,C=g<=D?32:b-g|0;default:h[B]=F;continue;case 11:case 10:case 9:case 8:}h[B]=65533}if(y+=n(h[0],h[1],h[2],h[3],h[4],h[5],h[6],h[7],h[8],h[9],h[10],h[11],h[12],h[13],h[14],h[15],h[16],h[17],h[18],h[19],h[20],h[21],h[22],h[23],h[24],h[25],h[26],h[27],h[28],h[29],h[30],h[31]),32>B&&(y=y.slice(0,B-32|0)),g>>31,O=-1,y.length=C)y[b]=C;else{if(2047>=C)y[b]=192|C>>6;else{e:{if(55296<=C)if(56319>=C){var F=w.charCodeAt(g=g+1|0)|0;if(56320<=F&&57343>=F){if(C=(C<<10)+F-56613888|0,65535>18,y[b=b+1|0]=128|C>>12&63,y[b=b+1|0]=128|C>>6&63,y[b=b+1|0]=128|C&63;continue}break e}C=65533}else 57343>=C&&(C=65533);!D&&g<<1>12,y[b=b+1|0]=128|C>>6&63}y[b=b+1|0]=128|C&63}}return u?y.subarray(0,b):y.slice(0,b)},p||(e.TextDecoder=t,e.TextEncoder=r)})(typeof global>"u"?typeof self>"u"?qA:self:global)});var ig=he(Hl=>{"use strict";Object.defineProperty(Hl,"__esModule",{value:!0});Hl.isCorrect=Hl.isInSubnet=void 0;function S9(e){return this.subnetMask{"use strict";Object.defineProperty(Zs,"__esModule",{value:!0});Zs.RE_SUBNET_STRING=Zs.RE_ADDRESS=Zs.GROUPS=Zs.BITS=void 0;Zs.BITS=32;Zs.GROUPS=4;Zs.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;Zs.RE_SUBNET_STRING=/\/\d{1,2}$/});var N0=he(k0=>{"use strict";Object.defineProperty(k0,"__esModule",{value:!0});k0.AddressError=void 0;var ag=class extends Error{constructor(t,r){super(t),this.name="AddressError",r!==null&&(this.parseMessage=r)}};k0.AddressError=ag});var ug=he((L0,dE)=>{(function(){var e,t=0xdeadbeefcafe,r=(t&16777215)==15715070;function n(R,N,K){R!=null&&(typeof R=="number"?this.fromNumber(R,N,K):N==null&&typeof R!="string"?this.fromString(R,256):this.fromString(R,N))}function i(){return new n(null)}function a(R,N,K,Q,ve,Ee){for(;--Ee>=0;){var Ie=N*this[R++]+K[Q]+ve;ve=Math.floor(Ie/67108864),K[Q++]=Ie&67108863}return ve}function s(R,N,K,Q,ve,Ee){for(var Ie=N&32767,Re=N>>15;--Ee>=0;){var Jt=this[R]&32767,Ir=this[R++]>>15,wn=Re*Jt+Ir*Ie;Jt=Ie*Jt+((wn&32767)<<15)+K[Q]+(ve&1073741823),ve=(Jt>>>30)+(wn>>>15)+Re*Ir+(ve>>>30),K[Q++]=Jt&1073741823}return ve}function u(R,N,K,Q,ve,Ee){for(var Ie=N&16383,Re=N>>14;--Ee>=0;){var Jt=this[R]&16383,Ir=this[R++]>>14,wn=Re*Jt+Ir*Ie;Jt=Ie*Jt+((wn&16383)<<14)+K[Q]+ve,ve=(Jt>>28)+(wn>>14)+Re*Ir,K[Q++]=Jt&268435455}return ve}var l=typeof navigator<"u";l&&r&&navigator.appName=="Microsoft Internet Explorer"?(n.prototype.am=s,e=30):l&&r&&navigator.appName!="Netscape"?(n.prototype.am=a,e=26):(n.prototype.am=u,e=28),n.prototype.DB=e,n.prototype.DM=(1<=0;--N)R[N]=this[N];R.t=this.t,R.s=this.s}function g(R){this.t=1,this.s=R<0?-1:0,R>0?this[0]=R:R<-1?this[0]=R+this.DV:this.t=0}function b(R){var N=i();return N.fromInt(R),N}function D(R,N){var K;if(N==16)K=4;else if(N==8)K=3;else if(N==256)K=8;else if(N==2)K=1;else if(N==32)K=5;else if(N==4)K=2;else{this.fromRadix(R,N);return}this.t=0,this.s=0;for(var Q=R.length,ve=!1,Ee=0;--Q>=0;){var Ie=K==8?R[Q]&255:v(R,Q);if(Ie<0){R.charAt(Q)=="-"&&(ve=!0);continue}ve=!1,Ee==0?this[this.t++]=Ie:Ee+K>this.DB?(this[this.t-1]|=(Ie&(1<>this.DB-Ee):this[this.t-1]|=Ie<=this.DB&&(Ee-=this.DB)}K==8&&R[0]&128&&(this.s=-1,Ee>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==R;)--this.t}function F(R){if(this.s<0)return"-"+this.negate().toString(R);var N;if(R==16)N=4;else if(R==8)N=3;else if(R==2)N=1;else if(R==32)N=5;else if(R==4)N=2;else return this.toRadix(R);var K=(1<0)for(Re>Re)>0&&(ve=!0,Ee=w(Q));Ie>=0;)Re>(Re+=this.DB-N)):(Q=this[Ie]>>(Re-=N)&K,Re<=0&&(Re+=this.DB,--Ie)),Q>0&&(ve=!0),ve&&(Ee+=w(Q));return ve?Ee:"0"}function U(){var R=i();return n.ZERO.subTo(this,R),R}function L(){return this.s<0?this.negate():this}function S(R){var N=this.s-R.s;if(N!=0)return N;var K=this.t;if(N=K-R.t,N!=0)return this.s<0?-N:N;for(;--K>=0;)if((N=this[K]-R[K])!=0)return N;return 0}function B(R){var N=1,K;return(K=R>>>16)!=0&&(R=K,N+=16),(K=R>>8)!=0&&(R=K,N+=8),(K=R>>4)!=0&&(R=K,N+=4),(K=R>>2)!=0&&(R=K,N+=2),(K=R>>1)!=0&&(R=K,N+=1),N}function O(){return this.t<=0?0:this.DB*(this.t-1)+B(this[this.t-1]^this.s&this.DM)}function x(R,N){var K;for(K=this.t-1;K>=0;--K)N[K+R]=this[K];for(K=R-1;K>=0;--K)N[K]=0;N.t=this.t+R,N.s=this.s}function j(R,N){for(var K=R;K=0;--Re)N[Re+Ee+1]=this[Re]>>Q|Ie,Ie=(this[Re]&ve)<=0;--Re)N[Re]=0;N[Ee]=Ie,N.t=this.t+Ee+1,N.s=this.s,N.clamp()}function M(R,N){N.s=this.s;var K=Math.floor(R/this.DB);if(K>=this.t){N.t=0;return}var Q=R%this.DB,ve=this.DB-Q,Ee=(1<>Q;for(var Ie=K+1;Ie>Q;Q>0&&(N[this.t-K-1]|=(this.s&Ee)<>=this.DB;if(R.t>=this.DB;Q+=this.s}else{for(Q+=this.s;K>=this.DB;Q-=R.s}N.s=Q<0?-1:0,Q<-1?N[K++]=this.DV+Q:Q>0&&(N[K++]=Q),N.t=K,N.clamp()}function W(R,N){var K=this.abs(),Q=R.abs(),ve=K.t;for(N.t=ve+Q.t;--ve>=0;)N[ve]=0;for(ve=0;ve=0;)R[K]=0;for(K=0;K=N.DV&&(R[K+N.t]-=N.DV,R[K+N.t+1]=1)}R.t>0&&(R[R.t-1]+=N.am(K,N[K],R,2*K,0,1)),R.s=0,R.clamp()}function Ce(R,N,K){var Q=R.abs();if(!(Q.t<=0)){var ve=this.abs();if(ve.t0?(Q.lShiftTo(Jt,Ee),ve.lShiftTo(Jt,K)):(Q.copyTo(Ee),ve.copyTo(K));var Ir=Ee.t,wn=Ee[Ir-1];if(wn!=0){var An=wn*(1<1?Ee[Ir-2]>>this.F2:0),Ri=this.FV/An,$u=(1<=0&&(K[K.t++]=1,K.subTo(ts,K)),n.ONE.dlShiftTo(Ir,ts),ts.subTo(Ee,Ee);Ee.t=0;){var Eo=K[--En]==wn?this.DM:Math.floor(K[En]*Ri+(K[En-1]+Wn)*$u);if((K[En]+=Ee.am(0,Eo,K,Pu,0,Ir))0&&K.rShiftTo(Jt,K),Ie<0&&n.ZERO.subTo(K,K)}}}function Fe(R){var N=i();return this.abs().divRemTo(R,null,N),this.s<0&&N.compareTo(n.ZERO)>0&&R.subTo(N,N),N}function xe(R){this.m=R}function rt(R){return R.s<0||R.compareTo(this.m)>=0?R.mod(this.m):R}function tt(R){return R}function lt(R){R.divRemTo(this.m,null,R)}function ct(R,N,K){R.multiplyTo(N,K),this.reduce(K)}function fn(R,N){R.squareTo(N),this.reduce(N)}xe.prototype.convert=rt,xe.prototype.revert=tt,xe.prototype.reduce=lt,xe.prototype.mulTo=ct,xe.prototype.sqrTo=fn;function ur(){if(this.t<1)return 0;var R=this[0];if(!(R&1))return 0;var N=R&3;return N=N*(2-(R&15)*N)&15,N=N*(2-(R&255)*N)&255,N=N*(2-((R&65535)*N&65535))&65535,N=N*(2-R*N%this.DV)%this.DV,N>0?this.DV-N:-N}function _t(R){this.m=R,this.mp=R.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(N,N),N}function lr(R){var N=i();return R.copyTo(N),this.reduce(N),N}function ht(R){for(;R.t<=this.mt2;)R[R.t++]=0;for(var N=0;N>15)*this.mpl&this.um)<<15)&R.DM;for(K=N+this.m.t,R[K]+=this.m.am(0,Q,R,N,0,this.m.t);R[K]>=R.DV;)R[K]-=R.DV,R[++K]++}R.clamp(),R.drShiftTo(this.m.t,R),R.compareTo(this.m)>=0&&R.subTo(this.m,R)}function Wt(R,N){R.squareTo(N),this.reduce(N)}function nt(R,N,K){R.multiplyTo(N,K),this.reduce(K)}_t.prototype.convert=Cr,_t.prototype.revert=lr,_t.prototype.reduce=ht,_t.prototype.mulTo=nt,_t.prototype.sqrTo=Wt;function Ke(){return(this.t>0?this[0]&1:this.s)==0}function cr(R,N){if(R>4294967295||R<1)return n.ONE;var K=i(),Q=i(),ve=N.convert(this),Ee=B(R)-1;for(ve.copyTo(K);--Ee>=0;)if(N.sqrTo(K,Q),(R&1<0)N.mulTo(Q,ve,K);else{var Ie=K;K=Q,Q=Ie}return N.revert(K)}function Ue(R,N){var K;return R<256||N.isEven()?K=new xe(N):K=new _t(N),this.exp(R,K)}n.prototype.copyTo=y,n.prototype.fromInt=g,n.prototype.fromString=D,n.prototype.clamp=C,n.prototype.dlShiftTo=x,n.prototype.drShiftTo=j,n.prototype.lShiftTo=Y,n.prototype.rShiftTo=M,n.prototype.subTo=z,n.prototype.multiplyTo=W,n.prototype.squareTo=ie,n.prototype.divRemTo=Ce,n.prototype.invDigit=ur,n.prototype.isEven=Ke,n.prototype.exp=cr,n.prototype.toString=F,n.prototype.negate=U,n.prototype.abs=L,n.prototype.compareTo=S,n.prototype.bitLength=O,n.prototype.mod=Fe,n.prototype.modPowInt=Ue,n.ZERO=b(0),n.ONE=b(1);function kt(){var R=i();return this.copyTo(R),R}function hn(){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 Xt(){return this.t==0?this.s:this[0]<<16>>16}function vt(R){return Math.floor(Math.LN2*this.DB/Math.log(R))}function Lr(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function xi(R){if(R==null&&(R=10),this.signum()==0||R<2||R>36)return"0";var N=this.chunkSize(R),K=Math.pow(R,N),Q=b(K),ve=i(),Ee=i(),Ie="";for(this.divRemTo(Q,ve,Ee);ve.signum()>0;)Ie=(K+Ee.intValue()).toString(R).substr(1)+Ie,ve.divRemTo(Q,ve,Ee);return Ee.intValue().toString(R)+Ie}function dn(R,N){this.fromInt(0),N==null&&(N=10);for(var K=this.chunkSize(N),Q=Math.pow(N,K),ve=!1,Ee=0,Ie=0,Re=0;Re=K&&(this.dMultiply(Q),this.dAddOffset(Ie,0),Ee=0,Ie=0)}Ee>0&&(this.dMultiply(Math.pow(N,Ee)),this.dAddOffset(Ie,0)),ve&&n.ZERO.subTo(this,this)}function Dt(R,N,K){if(typeof N=="number")if(R<2)this.fromInt(1);else for(this.fromNumber(R,K),this.testBit(R-1)||this.bitwiseTo(n.ONE.shiftLeft(R-1),ge,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(N);)this.dAddOffset(2,0),this.bitLength()>R&&this.subTo(n.ONE.shiftLeft(R-1),this);else{var Q=new Array,ve=R&7;Q.length=(R>>3)+1,N.nextBytes(Q),ve>0?Q[0]&=(1<0)for(K>K)!=(this.s&this.DM)>>K&&(N[ve++]=Q|this.s<=0;)K<8?(Q=(this[R]&(1<>(K+=this.DB-8)):(Q=this[R]>>(K-=8)&255,K<=0&&(K+=this.DB,--R)),Q&128&&(Q|=-256),ve==0&&(this.s&128)!=(Q&128)&&++ve,(ve>0||Q!=this.s)&&(N[ve++]=Q);return N}function De(R){return this.compareTo(R)==0}function Dr(R){return this.compareTo(R)<0?this:R}function pn(R){return this.compareTo(R)>0?this:R}function it(R,N,K){var Q,ve,Ee=Math.min(R.t,this.t);for(Q=0;Q>=16,N+=16),R&255||(R>>=8,N+=8),R&15||(R>>=4,N+=4),R&3||(R>>=2,N+=2),R&1||++N,N}function Nt(){for(var R=0;R=this.t?this.s!=0:(this[N]&1<>=this.DB;if(R.t>=this.DB;Q+=this.s}else{for(Q+=this.s;K>=this.DB;Q+=R.s}N.s=Q<0?-1:0,Q>0?N[K++]=Q:Q<-1&&(N[K++]=this.DV+Q),N.t=K,N.clamp()}function xa(R){var N=i();return this.addTo(R,N),N}function re(R){var N=i();return this.subTo(R,N),N}function ce(R){var N=i();return this.multiplyTo(R,N),N}function ke(){var R=i();return this.squareTo(R),R}function Te(R){var N=i();return this.divRemTo(R,N,null),N}function Me(R){var N=i();return this.divRemTo(R,null,N),N}function st(R){var N=i(),K=i();return this.divRemTo(R,N,K),new Array(N,K)}function ft(R){this[this.t]=this.am(0,R-1,this,0,0,this.t),++this.t,this.clamp()}function Tr(R,N){if(R!=0){for(;this.t<=N;)this[this.t++]=0;for(this[N]+=R;this[N]>=this.DV;)this[N]-=this.DV,++N>=this.t&&(this[this.t++]=0),++this[N]}}function qt(){}function ci(R){return R}function es(R,N,K){R.multiplyTo(N,K)}function mn(R,N){R.squareTo(N)}qt.prototype.convert=ci,qt.prototype.revert=ci,qt.prototype.mulTo=es,qt.prototype.sqrTo=mn;function Pn(R){return this.exp(R,new qt)}function Fr(R,N,K){var Q=Math.min(this.t+R.t,N);for(K.s=0,K.t=Q;Q>0;)K[--Q]=0;var ve;for(ve=K.t-this.t;Q=0;)K[Q]=0;for(Q=Math.max(N-this.t,0);Q2*this.m.t)return R.mod(this.m);if(R.compareTo(this.m)<0)return R;var N=i();return R.copyTo(N),this.reduce(N),N}function Ks(R){return R}function Kn(R){for(R.drShiftTo(this.m.t-1,this.r2),R.t>this.m.t+1&&(R.t=this.m.t+1,R.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);R.compareTo(this.r2)<0;)R.dAddOffset(1,this.m.t+1);for(R.subTo(this.r2,R);R.compareTo(this.m)>=0;)R.subTo(this.m,R)}function Ot(R,N){R.squareTo(N),this.reduce(N)}function Sr(R,N,K){R.multiplyTo(N,K),this.reduce(K)}Gr.prototype.convert=ho,Gr.prototype.revert=Ks,Gr.prototype.reduce=Kn,Gr.prototype.mulTo=Sr,Gr.prototype.sqrTo=Ot;function Ze(R,N){var K=R.bitLength(),Q,ve=b(1),Ee;if(K<=0)return ve;K<18?Q=1:K<48?Q=3:K<144?Q=4:K<768?Q=5:Q=6,K<8?Ee=new xe(N):N.isEven()?Ee=new Gr(N):Ee=new _t(N);var Ie=new Array,Re=3,Jt=Q-1,Ir=(1<1){var wn=i();for(Ee.sqrTo(Ie[1],wn);Re<=Ir;)Ie[Re]=i(),Ee.mulTo(wn,Ie[Re-2],Ie[Re]),Re+=2}var An=R.t-1,Ri,$u=!0,Wn=i(),En;for(K=B(R[An])-1;An>=0;){for(K>=Jt?Ri=R[An]>>K-Jt&Ir:(Ri=(R[An]&(1<0&&(Ri|=R[An-1]>>this.DB+K-Jt)),Re=Q;!(Ri&1);)Ri>>=1,--Re;if((K-=Re)<0&&(K+=this.DB,--An),$u)Ie[Ri].copyTo(ve),$u=!1;else{for(;Re>1;)Ee.sqrTo(ve,Wn),Ee.sqrTo(Wn,ve),Re-=2;Re>0?Ee.sqrTo(ve,Wn):(En=ve,ve=Wn,Wn=En),Ee.mulTo(Wn,Ie[Ri],ve)}for(;An>=0&&!(R[An]&1<0&&(N.rShiftTo(Ee,N),K.rShiftTo(Ee,K));N.signum()>0;)(ve=N.getLowestSetBit())>0&&N.rShiftTo(ve,N),(ve=K.getLowestSetBit())>0&&K.rShiftTo(ve,K),N.compareTo(K)>=0?(N.subTo(K,N),N.rShiftTo(1,N)):(K.subTo(N,K),K.rShiftTo(1,K));return Ee>0&&K.lShiftTo(Ee,K),K}function rn(R){if(R<=0)return 0;var N=this.DV%R,K=this.s<0?R-1:0;if(this.t>0)if(N==0)K=this[0]%R;else for(var Q=this.t-1;Q>=0;--Q)K=(N*K+this[Q])%R;return K}function hr(R){var N=R.isEven();if(this.isEven()&&N||R.signum()==0)return n.ZERO;for(var K=R.clone(),Q=this.clone(),ve=b(1),Ee=b(0),Ie=b(0),Re=b(1);K.signum()!=0;){for(;K.isEven();)K.rShiftTo(1,K),N?((!ve.isEven()||!Ee.isEven())&&(ve.addTo(this,ve),Ee.subTo(R,Ee)),ve.rShiftTo(1,ve)):Ee.isEven()||Ee.subTo(R,Ee),Ee.rShiftTo(1,Ee);for(;Q.isEven();)Q.rShiftTo(1,Q),N?((!Ie.isEven()||!Re.isEven())&&(Ie.addTo(this,Ie),Re.subTo(R,Re)),Ie.rShiftTo(1,Ie)):Re.isEven()||Re.subTo(R,Re),Re.rShiftTo(1,Re);K.compareTo(Q)>=0?(K.subTo(Q,K),N&&ve.subTo(Ie,ve),Ee.subTo(Re,Ee)):(Q.subTo(K,Q),N&&Ie.subTo(ve,Ie),Re.subTo(Ee,Re))}if(Q.compareTo(n.ONE)!=0)return n.ZERO;if(Re.compareTo(R)>=0)return Re.subtract(R);if(Re.signum()<0)Re.addTo(R,Re);else return Re;return Re.signum()<0?Re.add(R):Re}var Vt=[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],zn=(1<<26)/Vt[Vt.length-1];function fi(R){var N,K=this.abs();if(K.t==1&&K[0]<=Vt[Vt.length-1]){for(N=0;N>1,R>Vt.length&&(R=Vt.length);for(var ve=i(),Ee=0;Ee>8&255,Ur[gr++]^=R>>16&255,Ur[gr++]^=R>>24&255,gr>=Yn&&(gr-=Yn)}function po(){Vc(new Date().getTime())}if(Ur==null){Ur=new Array,gr=0;var nn;if(typeof window<"u"&&window.crypto){if(window.crypto.getRandomValues){var go=new Uint8Array(32);for(window.crypto.getRandomValues(go),nn=0;nn<32;++nn)Ur[gr++]=go[nn]}else if(navigator.appName=="Netscape"&&navigator.appVersion<"5"){var dl=window.crypto.random(32);for(nn=0;nn>>8,Ur[gr++]=nn&255;gr=0,po()}function pl(){if(Gn==null){for(po(),Gn=Ao(),Gn.init(Ur),gr=0;gr{(function(){"use strict";var e={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function t(s){return n(a(s),arguments)}function r(s,u){return t.apply(null,[s].concat(u||[]))}function n(s,u){var l=1,f=s.length,d,m="",p,h,w,v,y,g,b,D;for(p=0;p=0),w.type){case"b":d=parseInt(d,10).toString(2);break;case"c":d=String.fromCharCode(parseInt(d,10));break;case"d":case"i":d=parseInt(d,10);break;case"j":d=JSON.stringify(d,null,w.width?parseInt(w.width):0);break;case"e":d=w.precision?parseFloat(d).toExponential(w.precision):parseFloat(d).toExponential();break;case"f":d=w.precision?parseFloat(d).toFixed(w.precision):parseFloat(d);break;case"g":d=w.precision?String(Number(d.toPrecision(w.precision))):parseFloat(d);break;case"o":d=(parseInt(d,10)>>>0).toString(8);break;case"s":d=String(d),d=w.precision?d.substring(0,w.precision):d;break;case"t":d=String(!!d),d=w.precision?d.substring(0,w.precision):d;break;case"T":d=Object.prototype.toString.call(d).slice(8,-1).toLowerCase(),d=w.precision?d.substring(0,w.precision):d;break;case"u":d=parseInt(d,10)>>>0;break;case"v":d=d.valueOf(),d=w.precision?d.substring(0,w.precision):d;break;case"x":d=(parseInt(d,10)>>>0).toString(16);break;case"X":d=(parseInt(d,10)>>>0).toString(16).toUpperCase();break}e.json.test(w.type)?m+=d:(e.number.test(w.type)&&(!b||w.sign)?(D=b?"+":"-",d=d.toString().replace(e.sign,"")):D="",y=w.pad_char?w.pad_char==="0"?"0":w.pad_char.charAt(1):" ",g=w.width-(D+d).length,v=w.width&&g>0?y.repeat(g):"",m+=w.align?D+d+v:y==="0"?D+v+d:v+D+d)}return m}var i=Object.create(null);function a(s){if(i[s])return i[s];for(var u=s,l,f=[],d=0;u;){if((l=e.text.exec(u))!==null)f.push(l[0]);else if((l=e.modulo.exec(u))!==null)f.push("%");else if((l=e.placeholder.exec(u))!==null){if(l[2]){d|=1;var m=[],p=l[2],h=[];if((h=e.key.exec(p))!==null)for(m.push(h[1]);(p=p.substring(h[0].length))!=="";)if((h=e.key_access.exec(p))!==null)m.push(h[1]);else if((h=e.index_access.exec(p))!==null)m.push(h[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");l[2]=m}else d|=2;if(d===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");f.push({placeholder:l[0],param_no:l[1],keys:l[2],sign:l[3],pad_char:l[4],align:l[5],width:l[6],precision:l[7],type:l[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");u=u.substring(l[0].length)}return i[s]=f}typeof U0<"u"&&(U0.sprintf=t,U0.vsprintf=r),typeof window<"u"&&(window.sprintf=t,window.vsprintf=r,typeof define=="function"&&define.amd&&define(function(){return{sprintf:t,vsprintf:r}}))})()});var lg=he(Qs=>{"use strict";var B9=Qs&&Qs.__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]}),$9=Qs&&Qs.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),mE=Qs&&Qs.__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)&&B9(t,e,r);return $9(t,e),t};Object.defineProperty(Qs,"__esModule",{value:!0});Qs.Address4=void 0;var pE=mE(ig()),Is=mE(sg()),gE=N0(),vf=ug(),Ml=mf(),og=class e{constructor(t){this.groups=Is.GROUPS,this.parsedAddress=[],this.parsedSubnet="",this.subnet="/32",this.subnetMask=32,this.v4=!0,this.isCorrect=pE.isCorrect(Is.BITS),this.isInSubnet=pE.isInSubnet,this.address=t;let r=Is.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>Is.BITS)throw new gE.AddressError("Invalid subnet mask.");t=t.replace(Is.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(Is.RE_ADDRESS))throw new gE.AddressError("Invalid IPv4 address.");return r}correctForm(){return this.parsedAddress.map(t=>parseInt(t,10)).join(".")}static fromHex(t){let r=t.replace(/:/g,"").padStart(8,"0"),n=[],i;for(i=0;i<8;i+=2){let a=r.slice(i,i+2);n.push(parseInt(a,16))}return new e(n.join("."))}static fromInteger(t){return e.fromHex(t.toString(16))}static fromArpa(t){let n=t.replace(/(\.in-addr\.arpa)?\.$/,"").split(".").reverse().join(".");return new e(n)}toHex(){return this.parsedAddress.map(t=>(0,Ml.sprintf)("%02x",parseInt(t,10))).join(":")}toArray(){return this.parsedAddress.map(t=>parseInt(t,10))}toGroup6(){let t=[],r;for(r=0;r(0,Ml.sprintf)("%02x",parseInt(t,10))).join(""),16)}_startAddress(){return new vf.BigInteger(this.mask()+"0".repeat(Is.BITS-this.subnetMask),2)}startAddress(){return e.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new vf.BigInteger("1");return e.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new vf.BigInteger(this.mask()+"1".repeat(Is.BITS-this.subnetMask),2)}endAddress(){return e.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new vf.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,Ml.sprintf)("%s.in-addr.arpa.",r)}isMulticast(){return this.isInSubnet(new e("224.0.0.0/4"))}binaryZeroPad(){return this.bigInteger().toString(2).padStart(Is.BITS,"0")}groupForV6(){let t=this.parsedAddress;return this.address.replace(Is.RE_ADDRESS,(0,Ml.sprintf)('%s.%s',t.slice(0,2).join("."),t.slice(2,4).join(".")))}};Qs.Address4=og});var cg=he(Pr=>{"use strict";Object.defineProperty(Pr,"__esModule",{value:!0});Pr.RE_URL_WITH_PORT=Pr.RE_URL=Pr.RE_ZONE_STRING=Pr.RE_SUBNET_STRING=Pr.RE_BAD_ADDRESS=Pr.RE_BAD_CHARACTERS=Pr.TYPES=Pr.SCOPES=Pr.GROUPS=Pr.BITS=void 0;Pr.BITS=128;Pr.GROUPS=8;Pr.SCOPES={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"};Pr.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"};Pr.RE_BAD_CHARACTERS=/([^0-9a-f:/%])/gi;Pr.RE_BAD_ADDRESS=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi;Pr.RE_SUBNET_STRING=/\/\d{1,3}(?=%|$)/;Pr.RE_ZONE_STRING=/%.*$/;Pr.RE_URL=new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/);Pr.RE_URL_WITH_PORT=new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/)});var fg=he(ea=>{"use strict";Object.defineProperty(ea,"__esModule",{value:!0});ea.simpleGroup=ea.spanLeadingZeroes=ea.spanAll=ea.spanAllZeroes=void 0;var vE=mf();function wE(e){return e.replace(/(0+)/g,'$1')}ea.spanAllZeroes=wE;function P9(e,t=0){return e.split("").map((n,i)=>(0,vE.sprintf)('%s',n,i+t,wE(n))).join("")}ea.spanAll=P9;function AE(e){return e.replace(/^(0+)/,'$1')}function x9(e){return e.split(":").map(r=>AE(r)).join(":")}ea.spanLeadingZeroes=x9;function R9(e,t=0){return e.split(":").map((n,i)=>/group-v4/.test(n)?n:(0,vE.sprintf)('%s',i+t,AE(n)))}ea.simpleGroup=R9});var EE=he(un=>{"use strict";var T9=un&&un.__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]}),O9=un&&un.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),k9=un&&un.__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)&&T9(t,e,r);return O9(t,e),t};Object.defineProperty(un,"__esModule",{value:!0});un.possibleElisions=un.simpleRegularExpression=un.ADDRESS_BOUNDARY=un.padGroup=un.groupPossibilities=void 0;var N9=k9(cg()),ql=mf();function H0(e){return(0,ql.sprintf)("(%s)",e.join("|"))}un.groupPossibilities=H0;function j0(e){return e.length<4?(0,ql.sprintf)("0{0,%d}%s",4-e.length,e):e}un.padGroup=j0;un.ADDRESS_BOUNDARY="[^A-Fa-f0-9:]";function L9(e){let t=[];e.forEach((n,i)=>{parseInt(n,16)===0&&t.push(i)});let r=t.map(n=>e.map((i,a)=>{if(a===n){let s=a===0||a===N9.GROUPS-1?":":"";return H0([j0(i),s])}return j0(i)}).join(":"));return r.push(e.map(j0).join(":")),H0(r)}un.simpleRegularExpression=L9;function U9(e,t,r){let n=t?"":":",i=r?"":":",a=[];!t&&!r&&a.push("::"),t&&r&&a.push(""),(r&&!t||!r&&t)&&a.push(":"),a.push((0,ql.sprintf)("%s(:0{1,4}){1,%d}",n,e-1)),a.push((0,ql.sprintf)("(0{1,4}:){1,%d}%s",e-1,i)),a.push((0,ql.sprintf)("(0{1,4}:){%d}0{1,4}",e-1));for(let s=1;s{"use strict";var j9=ta&&ta.__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]}),H9=ta&&ta.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),q0=ta&&ta.__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)&&j9(t,e,r);return H9(t,e),t};Object.defineProperty(ta,"__esModule",{value:!0});ta.Address6=void 0;var bE=q0(ig()),hg=q0(sg()),or=q0(cg()),dg=q0(fg()),ko=lg(),No=EE(),Ja=N0(),ti=ug(),ri=mf();function M0(e){if(!e)throw new Error("Assertion failed.")}function M9(e){let t=/(\d+)(\d{3})/;for(;t.test(e);)e=e.replace(t,"$1,$2");return e}function q9(e){return e=e.replace(/^(0{1,})([1-9]+)$/,'$1$2'),e=e.replace(/^(0{1,})(0)$/,'$1$2'),e}function V9(e,t){let r=[],n=[],i;for(i=0;it[1]&&n.push(e[i]);return r.concat(["compact"]).concat(n)}function yE(e){return(0,ri.sprintf)("%04x",parseInt(e,16))}function _E(e){return e&255}var pg=class e{constructor(t,r){this.addressMinusSuffix="",this.parsedSubnet="",this.subnet="/128",this.subnetMask=128,this.v4=!1,this.zone="",this.isInSubnet=bE.isInSubnet,this.isCorrect=bE.isCorrect(or.BITS),r===void 0?this.groups=or.GROUPS:this.groups=r,this.address=t;let n=or.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>or.BITS)throw new Ja.AddressError("Invalid subnet mask.");t=t.replace(or.RE_SUBNET_STRING,"")}else if(/\//.test(t))throw new Ja.AddressError("Invalid subnet mask.");let i=or.RE_ZONE_STRING.exec(t);i&&(this.zone=i[0],t=t.replace(or.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 ko.Address4(t),n=or.BITS-(hg.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 Ja.AddressError("Invalid 'ip6.arpa' form.");let i=r.split(".").reverse();for(let a=n;a>0;a--){let s=a*4;i.splice(s,0,":")}return r=i.join(""),new e(r)}microsoftTranscription(){return(0,ri.sprintf)("%s.ipv6-literal.net",this.correctForm().replace(/:/g,"-"))}mask(t=this.subnetMask){return this.getBitsBase2(0,t)}possibleSubnets(t=128){let r=or.BITS-this.subnetMask,n=Math.abs(t-or.BITS),i=r-n;return i<0?"0":M9(new ti.BigInteger("2",10).pow(i).toString(10))}_startAddress(){return new ti.BigInteger(this.mask()+"0".repeat(or.BITS-this.subnetMask),2)}startAddress(){return e.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new ti.BigInteger("1");return e.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new ti.BigInteger(this.mask()+"1".repeat(or.BITS-this.subnetMask),2)}endAddress(){return e.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new ti.BigInteger("1");return e.fromBigInteger(this._endAddress().subtract(t))}getScope(){let t=or.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(or.TYPES))if(this.isInSubnet(new e(t)))return or.TYPES[t];return"Global unicast"}getBits(t,r){return new ti.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,or.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,ri.sprintf)("%s.ip6.arpa.",n):t.omitSuffix?"":"ip6.arpa."}correctForm(){let t,r=[],n=0,i=[];for(t=0;t0&&(n>1&&i.push([t-n,t-1]),n=0)}n>1&&i.push([this.parsedAddress.length-n,this.parsedAddress.length-1]);let a=i.map(u=>u[1]-u[0]+1);if(i.length>0){let u=a.indexOf(Math.max(...a));r=V9(this.parsedAddress,i[u])}else r=this.parsedAddress;for(t=0;t1?"s":"",r.join("")),t.replace(or.RE_BAD_CHARACTERS,'$1'));let n=t.match(or.RE_BAD_ADDRESS);if(n)throw new Ja.AddressError((0,ri.sprintf)("Address failed regex: %s",n.join("")),t.replace(or.RE_BAD_ADDRESS,'$1'));let i=[],a=t.split("::");if(a.length===2){let s=a[0].split(":"),u=a[1].split(":");s.length===1&&s[0]===""&&(s=[]),u.length===1&&u[0]===""&&(u=[]);let l=this.groups-(s.length+u.length);if(!l)throw new Ja.AddressError("Error parsing groups");this.elidedGroups=l,this.elisionBegin=s.length,this.elisionEnd=s.length+this.elidedGroups,i=i.concat(s);for(let f=0;f(0,ri.sprintf)("%x",parseInt(s,16))),i.length!==this.groups)throw new Ja.AddressError("Incorrect number of groups found");return i}canonicalForm(){return this.parsedAddress.map(yE).join(":")}decimal(){return this.parsedAddress.map(t=>(0,ri.sprintf)("%05d",parseInt(t,16))).join(":")}bigInteger(){return new ti.BigInteger(this.parsedAddress.map(yE).join(""),16)}to4(){let t=this.binaryZeroPad().split("");return ko.Address4.fromHex(new ti.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 ti.BigInteger("ffff",16)).toString(),n=ko.Address4.fromHex(this.getBitsBase16(32,64)),i=ko.Address4.fromHex(this.getBits(96,128).xor(new ti.BigInteger("ffffffff",16)).toString(16)),a=this.getBits(64,80),s=this.getBitsBase2(64,80),u=a.testBit(15),l=a.testBit(14),f=a.testBit(8),d=a.testBit(9),m=new ti.BigInteger(s.slice(2,6)+s.slice(8,16),2).toString(10);return{prefix:(0,ri.sprintf)("%s:%s",t.slice(0,4),t.slice(4,8)),server4:n.address,client4:i.address,flags:s,coneNat:u,microsoft:{reserved:l,universalLocal:d,groupIndividual:f,nonce:m},udpPort:r}}inspect6to4(){let t=this.getBitsBase16(0,16),r=ko.Address4.fromHex(this.getBitsBase16(16,48));return{prefix:(0,ri.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(_E)}static fromByteArray(t){return this.fromUnsignedByteArray(t.map(_E))}static fromUnsignedByteArray(t){let r=new ti.BigInteger("256",10),n=new ti.BigInteger("0",10),i=new ti.BigInteger("1",10);for(let a=t.length-1;a>=0;a--)n=n.add(i.multiply(new ti.BigInteger(t[a].toString(10),10))),i=i.multiply(r);return e.fromBigInteger(n)}isCanonical(){return this.addressMinusSuffix===this.canonicalForm()}isLinkLocal(){return this.getBitsBase2(0,64)==="1111111010000000000000000000000000000000000000000000000000000000"}isMulticast(){return this.getType()==="Multicast"}is4(){return this.v4}isTeredo(){return this.isInSubnet(new e("2001::/32"))}is6to4(){return this.isInSubnet(new e("2002::/16"))}isLoopback(){return this.getType()==="Loopback"}href(t){return t===void 0?t="":t=(0,ri.sprintf)(":%s",t),(0,ri.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,ri.sprintf)('%2$s',t.prefix,r.call(this),t.className):(0,ri.sprintf)('%2$s',t.prefix,r.call(this))}group(){if(this.elidedGroups===0)return dg.simpleGroup(this.address).join(":");M0(typeof this.elidedGroups=="number"),M0(typeof this.elisionBegin=="number");let t=[],[r,n]=this.address.split("::");r.length?t.push(...dg.simpleGroup(r)):t.push("");let i=["hover-group"];for(let a=this.elisionBegin;a',i.join(" "))),n.length?t.push(...dg.simpleGroup(n,this.elisionEnd)):t.push(""),this.is4()&&(M0(this.address4 instanceof ko.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,No.simpleRegularExpression)(n.parsedAddress));else if(n.elidedGroups===or.GROUPS)r.push((0,No.possibleElisions)(or.GROUPS));else{let i=n.address.split("::");i[0].length&&r.push((0,No.simpleRegularExpression)(i[0].split(":"))),M0(typeof n.elidedGroups=="number"),r.push((0,No.possibleElisions)(n.elidedGroups,i[0].length!==0,i[1].length!==0)),i[1].length&&r.push((0,No.simpleRegularExpression)(i[1].split(":"))),r=[r.join(":")]}return t||(r=["(?=^|",No.ADDRESS_BOUNDARY,"|[^\\w\\:])(",...r,")(?=[^\\w\\:]|",No.ADDRESS_BOUNDARY,"|$)"]),r.join("")}regularExpression(t=!1){return new RegExp(this.regularExpressionString(t),"i")}};ta.Address6=pg});var DE=he(kn=>{"use strict";var K9=kn&&kn.__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]}),z9=kn&&kn.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),G9=kn&&kn.__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)&&K9(t,e,r);return z9(t,e),t};Object.defineProperty(kn,"__esModule",{value:!0});kn.v6=kn.AddressError=kn.Address6=kn.Address4=void 0;var Y9=lg();Object.defineProperty(kn,"Address4",{enumerable:!0,get:function(){return Y9.Address4}});var W9=CE();Object.defineProperty(kn,"Address6",{enumerable:!0,get:function(){return W9.Address6}});var X9=N0();Object.defineProperty(kn,"AddressError",{enumerable:!0,get:function(){return X9.AddressError}});var J9=G9(fg());kn.v6={helpers:J9}});var Z0=he((Gl,Ef)=>{(function(){var e,t="4.17.21",r=200,n="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",i="Expected a function",a="Invalid `variable` option passed into `_.template`",s="__lodash_hash_undefined__",u=500,l="__lodash_placeholder__",f=1,d=2,m=4,p=1,h=2,w=1,v=2,y=4,g=8,b=16,D=32,C=64,F=128,U=256,L=512,S=30,B="...",O=800,x=16,j=1,Y=2,M=3,z=1/0,W=9007199254740991,ie=17976931348623157e292,Ce=NaN,Fe=4294967295,xe=Fe-1,rt=Fe>>>1,tt=[["ary",F],["bind",w],["bindKey",v],["curry",g],["curryRight",b],["flip",L],["partial",D],["partialRight",C],["rearg",U]],lt="[object Arguments]",ct="[object Array]",fn="[object AsyncFunction]",ur="[object Boolean]",_t="[object Date]",Cr="[object DOMException]",lr="[object Error]",ht="[object Function]",Wt="[object GeneratorFunction]",nt="[object Map]",Ke="[object Number]",cr="[object Null]",Ue="[object Object]",kt="[object Promise]",hn="[object Proxy]",nr="[object RegExp]",Xt="[object Set]",vt="[object String]",Lr="[object Symbol]",xi="[object Undefined]",dn="[object WeakMap]",Dt="[object WeakSet]",Ne="[object ArrayBuffer]",De="[object DataView]",Dr="[object Float32Array]",pn="[object Float64Array]",it="[object Int8Array]",Pa="[object Int16Array]",gn="[object Int32Array]",ge="[object Uint8Array]",js="[object Uint8ClampedArray]",$t="[object Uint16Array]",tn="[object Uint32Array]",Es=/\b__p \+= '';/g,Du=/\b(__p \+=) '' \+/g,Hs=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Fu=/&(?:amp|lt|gt|quot|#39);/g,Ms=/[&<>"']/g,bs=RegExp(Fu.source),Nt=RegExp(Ms.source),li=/<%-([\s\S]+?)%>/g,Su=/<%([\s\S]+?)%>/g,Iu=/<%=([\s\S]+?)%>/g,Bu=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,qs=/^\w*$/,co=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Vs=/[\\^$.*+?()[\]{}|]/g,fo=RegExp(Vs.source),xa=/^\s+/,re=/\s/,ce=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ke=/\{\n\/\* \[wrapped with (.+)\] \*/,Te=/,? & /,Me=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,st=/[()=,{}\[\]\/\s]/,ft=/\\(\\)?/g,Tr=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,qt=/\w*$/,ci=/^[-+]0x[0-9a-f]+$/i,es=/^0b[01]+$/i,mn=/^\[object .+?Constructor\]$/,Pn=/^0o[0-7]+$/i,Fr=/^(?:0|[1-9]\d*)$/,vn=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Gr=/($^)/,ho=/['\n\r\u2028\u2029\\]/g,Ks="\\ud800-\\udfff",Kn="\\u0300-\\u036f",Ot="\\ufe20-\\ufe2f",Sr="\\u20d0-\\u20ff",Ze=Kn+Ot+Sr,fr="\\u2700-\\u27bf",rn="a-z\\xdf-\\xf6\\xf8-\\xff",hr="\\xac\\xb1\\xd7\\xf7",Vt="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",zn="\\u2000-\\u206f",fi=" \\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",hi="A-Z\\xc0-\\xd6\\xd8-\\xde",Gn="\\ufe0e\\ufe0f",Ur=hr+Vt+zn+fi,gr="['\u2019]",Vc="["+Ks+"]",po="["+Ur+"]",nn="["+Ze+"]",go="\\d+",dl="["+fr+"]",pl="["+rn+"]",mo="[^"+Ks+Ur+go+fr+rn+hi+"]",zs="\\ud83c[\\udffb-\\udfff]",vo="(?:"+nn+"|"+zs+")",gl="[^"+Ks+"]",wo="(?:\\ud83c[\\udde6-\\uddff]){2}",Ao="[\\ud800-\\udbff][\\udc00-\\udfff]",Yn="["+hi+"]",R="\\u200d",N="(?:"+pl+"|"+mo+")",K="(?:"+Yn+"|"+mo+")",Q="(?:"+gr+"(?:d|ll|m|re|s|t|ve))?",ve="(?:"+gr+"(?:D|LL|M|RE|S|T|VE))?",Ee=vo+"?",Ie="["+Gn+"]?",Re="(?:"+R+"(?:"+[gl,wo,Ao].join("|")+")"+Ie+Ee+")*",Jt="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ir="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",wn=Ie+Ee+Re,An="(?:"+[dl,wo,Ao].join("|")+")"+wn,Ri="(?:"+[gl+nn+"?",nn,wo,Ao,Vc].join("|")+")",$u=RegExp(gr,"g"),Wn=RegExp(nn,"g"),En=RegExp(zs+"(?="+zs+")|"+Ri+wn,"g"),Pu=RegExp([Yn+"?"+pl+"+"+Q+"(?="+[po,Yn,"$"].join("|")+")",K+"+"+ve+"(?="+[po,Yn+N,"$"].join("|")+")",Yn+"?"+N+"+"+Q,Yn+"+"+ve,Ir,Jt,go,An].join("|"),"g"),ts=RegExp("["+R+Ks+Ze+Gn+"]"),Eo=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Op=["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"],kp=-1,ir={};ir[Dr]=ir[pn]=ir[it]=ir[Pa]=ir[gn]=ir[ge]=ir[js]=ir[$t]=ir[tn]=!0,ir[lt]=ir[ct]=ir[Ne]=ir[ur]=ir[De]=ir[_t]=ir[lr]=ir[ht]=ir[nt]=ir[Ke]=ir[Ue]=ir[nr]=ir[Xt]=ir[vt]=ir[dn]=!1;var er={};er[lt]=er[ct]=er[Ne]=er[De]=er[ur]=er[_t]=er[Dr]=er[pn]=er[it]=er[Pa]=er[gn]=er[nt]=er[Ke]=er[Ue]=er[nr]=er[Xt]=er[vt]=er[Lr]=er[ge]=er[js]=er[$t]=er[tn]=!0,er[lr]=er[ht]=er[dn]=!1;var Np={\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"},Lp={"&":"&","<":"<",">":">",'"':""","'":"'"},Up={"&":"&","<":"<",">":">",""":'"',"'":"'"},jp={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Hp=parseFloat,Mp=parseInt,Th=typeof global=="object"&&global&&global.Object===Object&&global,qp=typeof self=="object"&&self&&self.Object===Object&&self,jr=Th||qp||Function("return this")(),Kc=typeof Gl=="object"&&Gl&&!Gl.nodeType&&Gl,Ra=Kc&&typeof Ef=="object"&&Ef&&!Ef.nodeType&&Ef,Oh=Ra&&Ra.exports===Kc,zc=Oh&&Th.process,di=function(){try{var ne=Ra&&Ra.require&&Ra.require("util").types;return ne||zc&&zc.binding&&zc.binding("util")}catch{}}(),kh=di&&di.isArrayBuffer,Nh=di&&di.isDate,Lh=di&&di.isMap,Uh=di&&di.isRegExp,jh=di&&di.isSet,Hh=di&&di.isTypedArray;function Xn(ne,fe,oe){switch(oe.length){case 0:return ne.call(fe);case 1:return ne.call(fe,oe[0]);case 2:return ne.call(fe,oe[0],oe[1]);case 3:return ne.call(fe,oe[0],oe[1],oe[2])}return ne.apply(fe,oe)}function Vp(ne,fe,oe,Oe){for(var Qe=-1,Ft=ne==null?0:ne.length;++Qe-1}function bo(ne,fe,oe){for(var Oe=-1,Qe=ne==null?0:ne.length;++Oe-1;);return oe}function Kh(ne,fe){for(var oe=ne.length;oe--&&xu(fe,ne[oe],0)>-1;);return oe}function zh(ne,fe){for(var oe=ne.length,Oe=0;oe--;)ne[oe]===fe&&++Oe;return Oe}var Zc=me(Np),Gp=me(Lp);function Gh(ne){return"\\"+jp[ne]}function Yp(ne,fe){return ne==null?e:ne[fe]}function Oa(ne){return ts.test(ne)}function Wp(ne){return Eo.test(ne)}function Xp(ne){for(var fe,oe=[];!(fe=ne.next()).done;)oe.push(fe.value);return oe}function Qc(ne){var fe=-1,oe=Array(ne.size);return ne.forEach(function(Oe,Qe){oe[++fe]=[Qe,Oe]}),oe}function bn(ne,fe){return function(oe){return ne(fe(oe))}}function ki(ne,fe){for(var oe=-1,Oe=ne.length,Qe=0,Ft=[];++oe-1}function F5(o,c){var E=this.__data__,I=s0(E,o);return I<0?(++this.size,E.push([o,c])):E[I][1]=c,this}ja.prototype.clear=y5,ja.prototype.delete=_5,ja.prototype.get=C5,ja.prototype.has=D5,ja.prototype.set=F5;function Ha(o){var c=-1,E=o==null?0:o.length;for(this.clear();++c=c?o:c)),o}function ss(o,c,E,I,T,V){var X,Z=c&f,se=c&d,we=c&m;if(E&&(X=T?E(o,I,T,V):E(o)),X!==e)return X;if(!Er(o))return o;var Ae=ut(o);if(Ae){if(X=$F(o),!Z)return vi(o,X)}else{var be=Tn(o),Be=be==ht||be==Wt;if(Nu(o))return xw(o,Z);if(be==Ue||be==lt||Be&&!T){if(X=se||Be?{}:Jw(o),!Z)return se?AF(o,M5(X,o)):wF(o,ow(X,o))}else{if(!er[be])return T?o:{};X=PF(o,be,Z)}}V||(V=new _s);var Le=V.get(o);if(Le)return Le;V.set(o,X),FA(o)?o.forEach(function(Je){X.add(ss(Je,c,E,Je,o,V))}):CA(o)&&o.forEach(function(Je,bt){X.set(bt,ss(Je,c,E,bt,o,V))});var Xe=we?se?B1:I1:se?Ai:sn,gt=Ae?e:Xe(o);return pi(gt||o,function(Je,bt){gt&&(bt=Je,Je=o[bt]),sf(X,bt,ss(Je,c,E,bt,o,V))}),X}function q5(o){var c=sn(o);return function(E){return lw(E,o,c)}}function lw(o,c,E){var I=E.length;if(o==null)return!I;for(o=Zt(o);I--;){var T=E[I],V=c[T],X=o[T];if(X===e&&!(T in o)||!V(X))return!1}return!0}function cw(o,c,E){if(typeof o!="function")throw new mi(i);return hf(function(){o.apply(e,E)},c)}function af(o,c,E,I){var T=-1,V=Jn,X=!0,Z=o.length,se=[],we=c.length;if(!Z)return se;E&&(c=te(c,xn(E))),I?(V=bo,X=!1):c.length>=r&&(V=_o,X=!1,c=new Do(c));e:for(;++TT?0:T+E),I=I===e||I>T?T:dt(I),I<0&&(I+=T),I=E>I?0:IA(I);E0&&E(Z)?c>1?yn(Z,c-1,E,I,T):Oi(T,Z):I||(T[T.length]=Z)}return T}var c1=Lw(),dw=Lw(!0);function Ys(o,c){return o&&c1(o,c,sn)}function f1(o,c){return o&&dw(o,c,sn)}function u0(o,c){return Ti(c,function(E){return za(o[E])})}function So(o,c){c=Ou(c,o);for(var E=0,I=c.length;o!=null&&Ec}function z5(o,c){return o!=null&&Pt.call(o,c)}function G5(o,c){return o!=null&&c in Zt(o)}function Y5(o,c,E){return o>=Rn(c,E)&&o=120&&Ae.length>=120)?new Do(X&&Ae):e}Ae=o[0];var be=-1,Be=Z[0];e:for(;++be-1;)Z!==o&&Ut.call(Z,se,1),Ut.call(o,se,1);return o}function Cw(o,c){for(var E=o?c.length:0,I=E-1;E--;){var T=c[E];if(E==I||T!==V){var V=T;Ka(T)?Ut.call(o,T,1):b1(o,T)}}return o}function w1(o,c){return o+ae(iw()*(c-o+1))}function uF(o,c,E,I){for(var T=-1,V=Yr(G((c-o)/(E||1)),0),X=oe(V);V--;)X[I?V:++T]=o,o+=E;return X}function A1(o,c){var E="";if(!o||c<1||c>W)return E;do c%2&&(E+=o),c=ae(c/2),c&&(o+=o);while(c);return E}function wt(o,c){return k1(eA(o,c,Ei),o+"")}function oF(o){return uw(kl(o))}function lF(o,c){var E=kl(o);return w0(E,Fo(c,0,E.length))}function lf(o,c,E,I){if(!Er(o))return o;c=Ou(c,o);for(var T=-1,V=c.length,X=V-1,Z=o;Z!=null&&++TT?0:T+c),E=E>T?T:E,E<0&&(E+=T),T=c>E?0:E-c>>>0,c>>>=0;for(var V=oe(T);++I>>1,X=o[V];X!==null&&!Ui(X)&&(E?X<=c:X=r){var we=c?null:_F(o);if(we)return Ni(we);X=!1,T=_o,se=new Do}else se=c?[]:Z;e:for(;++I=I?o:as(o,c,E)}var Pw=_||function(o){return jr.clearTimeout(o)};function xw(o,c){if(c)return o.slice();var E=o.length,I=Zh?Zh(E):new o.constructor(E);return o.copy(I),I}function D1(o){var c=new o.constructor(o.byteLength);return new Fl(c).set(new Fl(o)),c}function pF(o,c){var E=c?D1(o.buffer):o.buffer;return new o.constructor(E,o.byteOffset,o.byteLength)}function gF(o){var c=new o.constructor(o.source,qt.exec(o));return c.lastIndex=o.lastIndex,c}function mF(o){return nf?Zt(nf.call(o)):{}}function Rw(o,c){var E=c?D1(o.buffer):o.buffer;return new o.constructor(E,o.byteOffset,o.length)}function Tw(o,c){if(o!==c){var E=o!==e,I=o===null,T=o===o,V=Ui(o),X=c!==e,Z=c===null,se=c===c,we=Ui(c);if(!Z&&!we&&!V&&o>c||V&&X&&se&&!Z&&!we||I&&X&&se||!E&&se||!T)return 1;if(!I&&!V&&!we&&o=Z)return se;var we=E[I];return se*(we=="desc"?-1:1)}}return o.index-c.index}function Ow(o,c,E,I){for(var T=-1,V=o.length,X=E.length,Z=-1,se=c.length,we=Yr(V-X,0),Ae=oe(se+we),be=!I;++Z1?E[T-1]:e,X=T>2?E[2]:e;for(V=o.length>3&&typeof V=="function"?(T--,V):e,X&&Qn(E[0],E[1],X)&&(V=T<3?e:V,T=1),c=Zt(c);++I-1?T[V?c[X]:X]:e}}function Hw(o){return Va(function(c){var E=c.length,I=E,T=is.prototype.thru;for(o&&c.reverse();I--;){var V=c[I];if(typeof V!="function")throw new mi(i);if(T&&!X&&m0(V)=="wrapper")var X=new is([],!0)}for(I=X?I:E;++I1&&St.reverse(),Ae&&seZ))return!1;var we=V.get(o),Ae=V.get(c);if(we&&Ae)return we==c&&Ae==o;var be=-1,Be=!0,Le=E&h?new Do:e;for(V.set(o,c),V.set(c,o);++be1?"& ":"")+c[I],c=c.join(E>2?", ":" "),o.replace(ce,`{ /* [wrapped with `+c+`] */ `)}function RF(o){return ut(o)||$o(o)||!!(t0&&o&&o[t0])}function Ka(o,c){var E=typeof o;return c=c??W,!!c&&(E=="number"||E!="symbol"&&Fr.test(o))&&o>-1&&o%1==0&&o0){if(++c>=O)return arguments[0]}else c=0;return o.apply(e,arguments)}}function w0(o,c){var E=-1,I=o.length,T=I-1;for(c=c===e?I:c;++E1?o[c-1]:e;return E=typeof E=="function"?(o.pop(),E):e,hA(o,E)});function dA(o){var c=q(o);return c.__chain__=!0,c}function V8(o,c){return c(o),o}function A0(o,c){return c(o)}var K8=Va(function(o){var c=o.length,E=c?o[0]:0,I=this.__wrapped__,T=function(V){return l1(V,o)};return c>1||this.__actions__.length||!(I instanceof Ct)||!Ka(E)?this.thru(T):(I=I.slice(E,+E+(c?1:0)),I.__actions__.push({func:A0,args:[T],thisArg:e}),new is(I,this.__chain__).thru(function(V){return c&&!V.length&&V.push(e),V}))});function z8(){return dA(this)}function G8(){return new is(this.value(),this.__chain__)}function Y8(){this.__values__===e&&(this.__values__=SA(this.value()));var o=this.__index__>=this.__values__.length,c=o?e:this.__values__[this.__index__++];return{done:o,value:c}}function W8(){return this}function X8(o){for(var c,E=this;E instanceof i0;){var I=aA(E);I.__index__=0,I.__values__=e,c?T.__wrapped__=I:c=I;var T=I;E=E.__wrapped__}return T.__wrapped__=o,c}function J8(){var o=this.__wrapped__;if(o instanceof Ct){var c=o;return this.__actions__.length&&(c=new Ct(this)),c=c.reverse(),c.__actions__.push({func:A0,args:[N1],thisArg:e}),new is(c,this.__chain__)}return this.thru(N1)}function Z8(){return Bw(this.__wrapped__,this.__actions__)}var Q8=f0(function(o,c,E){Pt.call(o,E)?++o[E]:Ma(o,E,1)});function eS(o,c,E){var I=ut(o)?at:V5;return E&&Qn(o,c,E)&&(c=e),I(o,Ye(c,3))}function tS(o,c){var E=ut(o)?Ti:hw;return E(o,Ye(c,3))}var rS=jw(uA),nS=jw(oA);function iS(o,c){return yn(E0(o,c),1)}function sS(o,c){return yn(E0(o,c),z)}function aS(o,c,E){return E=E===e?1:dt(E),yn(E0(o,c),E)}function pA(o,c){var E=ut(o)?pi:Ru;return E(o,Ye(c,3))}function gA(o,c){var E=ut(o)?P:fw;return E(o,Ye(c,3))}var uS=f0(function(o,c,E){Pt.call(o,E)?o[E].push(c):Ma(o,E,[c])});function oS(o,c,E,I){o=wi(o)?o:kl(o),E=E&&!I?dt(E):0;var T=o.length;return E<0&&(E=Yr(T+E,0)),D0(o)?E<=T&&o.indexOf(c,E)>-1:!!T&&xu(o,c,E)>-1}var lS=wt(function(o,c,E){var I=-1,T=typeof c=="function",V=wi(o)?oe(o.length):[];return Ru(o,function(X){V[++I]=T?Xn(c,X,E):uf(X,c,E)}),V}),cS=f0(function(o,c,E){Ma(o,E,c)});function E0(o,c){var E=ut(o)?te:ww;return E(o,Ye(c,3))}function fS(o,c,E,I){return o==null?[]:(ut(c)||(c=c==null?[]:[c]),E=I?e:E,ut(E)||(E=E==null?[]:[E]),yw(o,c,E))}var hS=f0(function(o,c,E){o[E?0:1].push(c)},function(){return[[],[]]});function dS(o,c,E){var I=ut(o)?Gc:qh,T=arguments.length<3;return I(o,Ye(c,4),E,T,Ru)}function pS(o,c,E){var I=ut(o)?rw:qh,T=arguments.length<3;return I(o,Ye(c,4),E,T,fw)}function gS(o,c){var E=ut(o)?Ti:hw;return E(o,_0(Ye(c,3)))}function mS(o){var c=ut(o)?uw:oF;return c(o)}function vS(o,c,E){(E?Qn(o,c,E):c===e)?c=1:c=dt(c);var I=ut(o)?U5:lF;return I(o,c)}function wS(o){var c=ut(o)?j5:fF;return c(o)}function AS(o){if(o==null)return 0;if(wi(o))return D0(o)?ka(o):o.length;var c=Tn(o);return c==nt||c==Xt?o.size:g1(o).length}function ES(o,c,E){var I=ut(o)?Mh:hF;return E&&Qn(o,c,E)&&(c=e),I(o,Ye(c,3))}var bS=wt(function(o,c){if(o==null)return[];var E=c.length;return E>1&&Qn(o,c[0],c[1])?c=[]:E>2&&Qn(c[0],c[1],c[2])&&(c=[c[0]]),yw(o,yn(c,1),[])}),b0=H||function(){return jr.Date.now()};function yS(o,c){if(typeof c!="function")throw new mi(i);return o=dt(o),function(){if(--o<1)return c.apply(this,arguments)}}function mA(o,c,E){return c=E?e:c,c=o&&c==null?o.length:c,qa(o,F,e,e,e,e,c)}function vA(o,c){var E;if(typeof c!="function")throw new mi(i);return o=dt(o),function(){return--o>0&&(E=c.apply(this,arguments)),o<=1&&(c=e),E}}var U1=wt(function(o,c,E){var I=w;if(E.length){var T=ki(E,Tl(U1));I|=D}return qa(o,I,c,E,T)}),wA=wt(function(o,c,E){var I=w|v;if(E.length){var T=ki(E,Tl(wA));I|=D}return qa(c,I,o,E,T)});function AA(o,c,E){c=E?e:c;var I=qa(o,g,e,e,e,e,e,c);return I.placeholder=AA.placeholder,I}function EA(o,c,E){c=E?e:c;var I=qa(o,b,e,e,e,e,e,c);return I.placeholder=EA.placeholder,I}function bA(o,c,E){var I,T,V,X,Z,se,we=0,Ae=!1,be=!1,Be=!0;if(typeof o!="function")throw new mi(i);c=os(c)||0,Er(E)&&(Ae=!!E.leading,be="maxWait"in E,V=be?Yr(os(E.maxWait)||0,c):V,Be="trailing"in E?!!E.trailing:Be);function Le(kr){var Ds=I,Ya=T;return I=T=e,we=kr,X=o.apply(Ya,Ds),X}function Xe(kr){return we=kr,Z=hf(bt,c),Ae?Le(kr):X}function gt(kr){var Ds=kr-se,Ya=kr-we,jA=c-Ds;return be?Rn(jA,V-Ya):jA}function Je(kr){var Ds=kr-se,Ya=kr-we;return se===e||Ds>=c||Ds<0||be&&Ya>=V}function bt(){var kr=b0();if(Je(kr))return St(kr);Z=hf(bt,gt(kr))}function St(kr){return Z=e,Be&&I?Le(kr):(I=T=e,X)}function ji(){Z!==e&&Pw(Z),we=0,I=se=T=Z=e}function ei(){return Z===e?X:St(b0())}function Hi(){var kr=b0(),Ds=Je(kr);if(I=arguments,T=this,se=kr,Ds){if(Z===e)return Xe(se);if(be)return Pw(Z),Z=hf(bt,c),Le(se)}return Z===e&&(Z=hf(bt,c)),X}return Hi.cancel=ji,Hi.flush=ei,Hi}var _S=wt(function(o,c){return cw(o,1,c)}),CS=wt(function(o,c,E){return cw(o,os(c)||0,E)});function DS(o){return qa(o,L)}function y0(o,c){if(typeof o!="function"||c!=null&&typeof c!="function")throw new mi(i);var E=function(){var I=arguments,T=c?c.apply(this,I):I[0],V=E.cache;if(V.has(T))return V.get(T);var X=o.apply(this,I);return E.cache=V.set(T,X)||V,X};return E.cache=new(y0.Cache||Ha),E}y0.Cache=Ha;function _0(o){if(typeof o!="function")throw new mi(i);return function(){var c=arguments;switch(c.length){case 0:return!o.call(this);case 1:return!o.call(this,c[0]);case 2:return!o.call(this,c[0],c[1]);case 3:return!o.call(this,c[0],c[1],c[2])}return!o.apply(this,c)}}function FS(o){return vA(2,o)}var SS=dF(function(o,c){c=c.length==1&&ut(c[0])?te(c[0],xn(Ye())):te(yn(c,1),xn(Ye()));var E=c.length;return wt(function(I){for(var T=-1,V=Rn(I.length,E);++T=c}),$o=gw(function(){return arguments}())?gw:function(o){return $r(o)&&Pt.call(o,"callee")&&!e0.call(o,"callee")},ut=oe.isArray,MS=kh?xn(kh):X5;function wi(o){return o!=null&&C0(o.length)&&!za(o)}function Or(o){return $r(o)&&wi(o)}function qS(o){return o===!0||o===!1||$r(o)&&Zn(o)==ur}var Nu=Qt||J1,VS=Nh?xn(Nh):J5;function KS(o){return $r(o)&&o.nodeType===1&&!df(o)}function zS(o){if(o==null)return!0;if(wi(o)&&(ut(o)||typeof o=="string"||typeof o.splice=="function"||Nu(o)||Ol(o)||$o(o)))return!o.length;var c=Tn(o);if(c==nt||c==Xt)return!o.size;if(ff(o))return!g1(o).length;for(var E in o)if(Pt.call(o,E))return!1;return!0}function GS(o,c){return of(o,c)}function YS(o,c,E){E=typeof E=="function"?E:e;var I=E?E(o,c):e;return I===e?of(o,c,e,E):!!I}function H1(o){if(!$r(o))return!1;var c=Zn(o);return c==lr||c==Cr||typeof o.message=="string"&&typeof o.name=="string"&&!df(o)}function WS(o){return typeof o=="number"&&Br(o)}function za(o){if(!Er(o))return!1;var c=Zn(o);return c==ht||c==Wt||c==fn||c==hn}function _A(o){return typeof o=="number"&&o==dt(o)}function C0(o){return typeof o=="number"&&o>-1&&o%1==0&&o<=W}function Er(o){var c=typeof o;return o!=null&&(c=="object"||c=="function")}function $r(o){return o!=null&&typeof o=="object"}var CA=Lh?xn(Lh):Q5;function XS(o,c){return o===c||p1(o,c,P1(c))}function JS(o,c,E){return E=typeof E=="function"?E:e,p1(o,c,P1(c),E)}function ZS(o){return DA(o)&&o!=+o}function QS(o){if(kF(o))throw new Qe(n);return mw(o)}function eI(o){return o===null}function tI(o){return o==null}function DA(o){return typeof o=="number"||$r(o)&&Zn(o)==Ke}function df(o){if(!$r(o)||Zn(o)!=Ue)return!1;var c=Sl(o);if(c===null)return!0;var E=Pt.call(c,"constructor")&&c.constructor;return typeof E=="function"&&E instanceof E&&yl.call(E)==n1}var M1=Uh?xn(Uh):eF;function rI(o){return _A(o)&&o>=-W&&o<=W}var FA=jh?xn(jh):tF;function D0(o){return typeof o=="string"||!ut(o)&&$r(o)&&Zn(o)==vt}function Ui(o){return typeof o=="symbol"||$r(o)&&Zn(o)==Lr}var Ol=Hh?xn(Hh):rF;function nI(o){return o===e}function iI(o){return $r(o)&&Tn(o)==dn}function sI(o){return $r(o)&&Zn(o)==Dt}var aI=g0(m1),uI=g0(function(o,c){return o<=c});function SA(o){if(!o)return[];if(wi(o))return D0(o)?gi(o):vi(o);if(La&&o[La])return Xp(o[La]());var c=Tn(o),E=c==nt?Qc:c==Xt?Ni:kl;return E(o)}function Ga(o){if(!o)return o===0?o:0;if(o=os(o),o===z||o===-z){var c=o<0?-1:1;return c*ie}return o===o?o:0}function dt(o){var c=Ga(o),E=c%1;return c===c?E?c-E:c:0}function IA(o){return o?Fo(dt(o),0,Fe):0}function os(o){if(typeof o=="number")return o;if(Ui(o))return Ce;if(Er(o)){var c=typeof o.valueOf=="function"?o.valueOf():o;o=Er(c)?c+"":c}if(typeof o!="string")return o===0?o:+o;o=Jc(o);var E=es.test(o);return E||Pn.test(o)?Mp(o.slice(2),E?2:8):ci.test(o)?Ce:+o}function BA(o){return Ws(o,Ai(o))}function oI(o){return o?Fo(dt(o),-W,W):o===0?o:0}function Kt(o){return o==null?"":Li(o)}var lI=xl(function(o,c){if(ff(c)||wi(c)){Ws(c,sn(c),o);return}for(var E in c)Pt.call(c,E)&&sf(o,E,c[E])}),$A=xl(function(o,c){Ws(c,Ai(c),o)}),F0=xl(function(o,c,E,I){Ws(c,Ai(c),o,I)}),cI=xl(function(o,c,E,I){Ws(c,sn(c),o,I)}),fI=Va(l1);function hI(o,c){var E=Pl(o);return c==null?E:ow(E,c)}var dI=wt(function(o,c){o=Zt(o);var E=-1,I=c.length,T=I>2?c[2]:e;for(T&&Qn(c[0],c[1],T)&&(I=1);++E1),V}),Ws(o,B1(o),E),I&&(E=ss(E,f|d|m,CF));for(var T=c.length;T--;)b1(E,c[T]);return E});function PI(o,c){return xA(o,_0(Ye(c)))}var xI=Va(function(o,c){return o==null?{}:sF(o,c)});function xA(o,c){if(o==null)return{};var E=te(B1(o),function(I){return[I]});return c=Ye(c),_w(o,E,function(I,T){return c(I,T[0])})}function RI(o,c,E){c=Ou(c,o);var I=-1,T=c.length;for(T||(T=1,o=e);++Ic){var I=o;o=c,c=I}if(E||o%1||c%1){var T=iw();return Rn(o+T*(c-o+Hp("1e-"+((T+"").length-1))),c)}return w1(o,c)}var VI=Rl(function(o,c,E){return c=c.toLowerCase(),o+(E?OA(c):c)});function OA(o){return K1(Kt(o).toLowerCase())}function kA(o){return o=Kt(o),o&&o.replace(vn,Zc).replace(Wn,"")}function KI(o,c,E){o=Kt(o),c=Li(c);var I=o.length;E=E===e?I:Fo(dt(E),0,I);var T=E;return E-=c.length,E>=0&&o.slice(E,T)==c}function zI(o){return o=Kt(o),o&&Nt.test(o)?o.replace(Ms,Gp):o}function GI(o){return o=Kt(o),o&&fo.test(o)?o.replace(Vs,"\\$&"):o}var YI=Rl(function(o,c,E){return o+(E?"-":"")+c.toLowerCase()}),WI=Rl(function(o,c,E){return o+(E?" ":"")+c.toLowerCase()}),XI=Uw("toLowerCase");function JI(o,c,E){o=Kt(o),c=dt(c);var I=c?ka(o):0;if(!c||I>=c)return o;var T=(c-I)/2;return p0(ae(T),E)+o+p0(G(T),E)}function ZI(o,c,E){o=Kt(o),c=dt(c);var I=c?ka(o):0;return c&&I>>0,E?(o=Kt(o),o&&(typeof c=="string"||c!=null&&!M1(c))&&(c=Li(c),!c&&Oa(o))?ku(gi(o),0,E):o.split(c,E)):[]}var sB=Rl(function(o,c,E){return o+(E?" ":"")+K1(c)});function aB(o,c,E){return o=Kt(o),E=E==null?0:Fo(dt(E),0,o.length),c=Li(c),o.slice(E,E+c.length)==c}function uB(o,c,E){var I=q.templateSettings;E&&Qn(o,c,E)&&(c=e),o=Kt(o),c=F0({},c,I,zw);var T=F0({},c.imports,I.imports,zw),V=sn(T),X=yo(T,V),Z,se,we=0,Ae=c.interpolate||Gr,be="__p += '",Be=El((c.escape||Gr).source+"|"+Ae.source+"|"+(Ae===Iu?Tr:Gr).source+"|"+(c.evaluate||Gr).source+"|$","g"),Le="//# sourceURL="+(Pt.call(c,"sourceURL")?(c.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++kp+"]")+` `;o.replace(Be,function(Je,bt,St,ji,ei,Hi){return St||(St=ji),be+=o.slice(we,Hi).replace(ho,Gh),bt&&(Z=!0,be+=`' + __e(`+bt+`) + '`),ei&&(se=!0,be+=`'; `+ei+`; __p += '`),St&&(be+=`' + ((__t = (`+St+`)) == null ? '' : __t) + '`),we=Hi+Je.length,Je}),be+=`'; `;var Xe=Pt.call(c,"variable")&&c.variable;if(!Xe)be=`with (obj) { `+be+` } `;else if(st.test(Xe))throw new Qe(a);be=(se?be.replace(Es,""):be).replace(Du,"$1").replace(Hs,"$1;"),be="function("+(Xe||"obj")+`) { `+(Xe?"":`obj || (obj = {}); `)+"var __t, __p = ''"+(Z?", __e = _.escape":"")+(se?`, __j = Array.prototype.join; function print() { __p += __j.call(arguments, '') } `:`; `)+be+`return __p }`;var gt=LA(function(){return Ft(V,Le+"return "+be).apply(e,X)});if(gt.source=be,H1(gt))throw gt;return gt}function oB(o){return Kt(o).toLowerCase()}function lB(o){return Kt(o).toUpperCase()}function cB(o,c,E){if(o=Kt(o),o&&(E||c===e))return Jc(o);if(!o||!(c=Li(c)))return o;var I=gi(o),T=gi(c),V=vl(I,T),X=Kh(I,T)+1;return ku(I,V,X).join("")}function fB(o,c,E){if(o=Kt(o),o&&(E||c===e))return o.slice(0,Al(o)+1);if(!o||!(c=Li(c)))return o;var I=gi(o),T=Kh(I,gi(c))+1;return ku(I,0,T).join("")}function hB(o,c,E){if(o=Kt(o),o&&(E||c===e))return o.replace(xa,"");if(!o||!(c=Li(c)))return o;var I=gi(o),T=vl(I,gi(c));return ku(I,T).join("")}function dB(o,c){var E=S,I=B;if(Er(c)){var T="separator"in c?c.separator:T;E="length"in c?dt(c.length):E,I="omission"in c?Li(c.omission):I}o=Kt(o);var V=o.length;if(Oa(o)){var X=gi(o);V=X.length}if(E>=V)return o;var Z=E-ka(I);if(Z<1)return I;var se=X?ku(X,0,Z).join(""):o.slice(0,Z);if(T===e)return se+I;if(X&&(Z+=se.length-Z),M1(T)){if(o.slice(Z).search(T)){var we,Ae=se;for(T.global||(T=El(T.source,Kt(qt.exec(T))+"g")),T.lastIndex=0;we=T.exec(Ae);)var be=we.index;se=se.slice(0,be===e?Z:be)}}else if(o.indexOf(Li(T),Z)!=Z){var Be=se.lastIndexOf(T);Be>-1&&(se=se.slice(0,Be))}return se+I}function pB(o){return o=Kt(o),o&&bs.test(o)?o.replace(Fu,Wh):o}var gB=Rl(function(o,c,E){return o+(E?" ":"")+c.toUpperCase()}),K1=Uw("toUpperCase");function NA(o,c,E){return o=Kt(o),c=E?e:c,c===e?Wp(o)?Qp(o):Yc(o):o.match(c)||[]}var LA=wt(function(o,c){try{return Xn(o,e,c)}catch(E){return H1(E)?E:new Qe(E)}}),mB=Va(function(o,c){return pi(c,function(E){E=Xs(E),Ma(o,E,U1(o[E],o))}),o});function vB(o){var c=o==null?0:o.length,E=Ye();return o=c?te(o,function(I){if(typeof I[1]!="function")throw new mi(i);return[E(I[0]),I[1]]}):[],wt(function(I){for(var T=-1;++TW)return[];var E=Fe,I=Rn(o,Fe);c=Ye(c),o-=Fe;for(var T=Xc(I,c);++E0||c<0)?new Ct(E):(o<0?E=E.takeRight(-o):o&&(E=E.drop(o)),c!==e&&(c=dt(c),E=c<0?E.dropRight(-c):E.take(c-o)),E)},Ct.prototype.takeRightWhile=function(o){return this.reverse().takeWhile(o).reverse()},Ct.prototype.toArray=function(){return this.take(Fe)},Ys(Ct.prototype,function(o,c){var E=/^(?:filter|find|map|reject)|While$/.test(c),I=/^(?:head|last)$/.test(c),T=q[I?"take"+(c=="last"?"Right":""):c],V=I||/^find/.test(c);T&&(q.prototype[c]=function(){var X=this.__wrapped__,Z=I?[1]:arguments,se=X instanceof Ct,we=Z[0],Ae=se||ut(X),be=function(bt){var St=T.apply(q,Oi([bt],Z));return I&&Be?St[0]:St};Ae&&E&&typeof we=="function"&&we.length!=1&&(se=Ae=!1);var Be=this.__chain__,Le=!!this.__actions__.length,Xe=V&&!Be,gt=se&&!Le;if(!V&&Ae){X=gt?X:new Ct(this);var Je=o.apply(X,Z);return Je.__actions__.push({func:A0,args:[be],thisArg:e}),new is(Je,Be)}return Xe&>?o.apply(this,Z):(Je=this.thru(be),Xe?I?Je.value()[0]:Je.value():Je)})}),pi(["pop","push","shift","sort","splice","unshift"],function(o){var c=bl[o],E=/^(?:push|sort|unshift)$/.test(o)?"tap":"thru",I=/^(?:pop|shift)$/.test(o);q.prototype[o]=function(){var T=arguments;if(I&&!this.__chain__){var V=this.value();return c.apply(ut(V)?V:[],T)}return this[E](function(X){return c.apply(ut(X)?X:[],T)})}}),Ys(Ct.prototype,function(o,c){var E=q[c];if(E){var I=E.name+"";Pt.call($l,I)||($l[I]=[]),$l[I].push({name:c,func:E})}}),$l[h0(e,v).name]=[{name:"wrapper",func:e}],Ct.prototype.clone=p5,Ct.prototype.reverse=g5,Ct.prototype.value=m5,q.prototype.at=K8,q.prototype.chain=z8,q.prototype.commit=G8,q.prototype.next=Y8,q.prototype.plant=X8,q.prototype.reverse=J8,q.prototype.toJSON=q.prototype.valueOf=q.prototype.value=Z8,q.prototype.first=q.prototype.head,La&&(q.prototype[La]=W8),q},ns=e1();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(jr._=ns,define(function(){return ns})):Ra?((Ra.exports=ns)._=ns,Kc._=ns):jr._=ns}).call(Gl)});var Mo=he((vG,Ho)=>{"use strict";function xE(e){return typeof e>"u"||e===null}function W7(e){return typeof e=="object"&&e!==null}function X7(e){return Array.isArray(e)?e:xE(e)?[]:[e]}function J7(e,t){var r,n,i,a;if(t)for(a=Object.keys(t),r=0,n=a.length;r{"use strict";function yf(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=(this.reason||"(unknown reason)")+(this.mark?" "+this.mark.toString():""),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}yf.prototype=Object.create(Error.prototype);yf.prototype.constructor=yf;yf.prototype.toString=function(t){var r=this.name+": ";return r+=this.reason||"(unknown reason)",!t&&this.mark&&(r+=" "+this.mark.toString()),r};RE.exports=yf});var kE=he((AG,OE)=>{"use strict";var TE=Mo();function Fg(e,t,r,n,i){this.name=e,this.buffer=t,this.position=r,this.line=n,this.column=i}Fg.prototype.getSnippet=function(t,r){var n,i,a,s,u;if(!this.buffer)return null;for(t=t||4,r=r||75,n="",i=this.position;i>0&&`\0\r \x85\u2028\u2029`.indexOf(this.buffer.charAt(i-1))===-1;)if(i-=1,this.position-i>r/2-1){n=" ... ",i+=5;break}for(a="",s=this.position;sr/2-1){a=" ... ",s-=5;break}return u=this.buffer.slice(i,s),TE.repeat(" ",t)+n+u+a+` `+TE.repeat(" ",t+this.position-i+n.length)+"^"};Fg.prototype.toString=function(t){var r,n="";return this.name&&(n+='in "'+this.name+'" '),n+="at line "+(this.line+1)+", column "+(this.column+1),t||(r=this.getSnippet(),r&&(n+=`: `+r)),n};OE.exports=Fg});var Jr=he((EG,LE)=>{"use strict";var NE=Yl(),e$=["kind","resolve","construct","instanceOf","predicate","represent","defaultStyle","styleAliases"],t$=["scalar","sequence","mapping"];function r$(e){var t={};return e!==null&&Object.keys(e).forEach(function(r){e[r].forEach(function(n){t[String(n)]=r})}),t}function n$(e,t){if(t=t||{},Object.keys(t).forEach(function(r){if(e$.indexOf(r)===-1)throw new NE('Unknown option "'+r+'" is met in definition of "'+e+'" YAML type.')}),this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(r){return r},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.defaultStyle=t.defaultStyle||null,this.styleAliases=r$(t.styleAliases||null),t$.indexOf(this.kind)===-1)throw new NE('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}LE.exports=n$});var qo=he((bG,jE)=>{"use strict";var UE=Mo(),Q0=Yl(),i$=Jr();function Sg(e,t,r){var n=[];return e.include.forEach(function(i){r=Sg(i,t,r)}),e[t].forEach(function(i){r.forEach(function(a,s){a.tag===i.tag&&a.kind===i.kind&&n.push(s)}),r.push(i)}),r.filter(function(i,a){return n.indexOf(a)===-1})}function s$(){var e={scalar:{},sequence:{},mapping:{},fallback:{}},t,r;function n(i){e[i.kind][i.tag]=e.fallback[i.tag]=i}for(t=0,r=arguments.length;t{"use strict";var a$=Jr();HE.exports=new a$("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}})});var VE=he((_G,qE)=>{"use strict";var u$=Jr();qE.exports=new u$("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}})});var zE=he((CG,KE)=>{"use strict";var o$=Jr();KE.exports=new o$("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}})});var ed=he((DG,GE)=>{"use strict";var l$=qo();GE.exports=new l$({explicit:[ME(),VE(),zE()]})});var WE=he((FG,YE)=>{"use strict";var c$=Jr();function f$(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function h$(){return null}function d$(e){return e===null}YE.exports=new c$("tag:yaml.org,2002:null",{kind:"scalar",resolve:f$,construct:h$,predicate:d$,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"}},defaultStyle:"lowercase"})});var JE=he((SG,XE)=>{"use strict";var p$=Jr();function g$(e){if(e===null)return!1;var t=e.length;return t===4&&(e==="true"||e==="True"||e==="TRUE")||t===5&&(e==="false"||e==="False"||e==="FALSE")}function m$(e){return e==="true"||e==="True"||e==="TRUE"}function v$(e){return Object.prototype.toString.call(e)==="[object Boolean]"}XE.exports=new p$("tag:yaml.org,2002:bool",{kind:"scalar",resolve:g$,construct:m$,predicate:v$,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"})});var QE=he((IG,ZE)=>{"use strict";var w$=Mo(),A$=Jr();function E$(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function b$(e){return 48<=e&&e<=55}function y$(e){return 48<=e&&e<=57}function _$(e){if(e===null)return!1;var t=e.length,r=0,n=!1,i;if(!t)return!1;if(i=e[r],(i==="-"||i==="+")&&(i=e[++r]),i==="0"){if(r+1===t)return!0;if(i=e[++r],i==="b"){for(r++;r=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0"+e.toString(8):"-0"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}})});var rb=he((BG,tb)=>{"use strict";var eb=Mo(),F$=Jr(),S$=new RegExp("^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function I$(e){return!(e===null||!S$.test(e)||e[e.length-1]==="_")}function B$(e){var t,r,n,i;return t=e.replace(/_/g,"").toLowerCase(),r=t[0]==="-"?-1:1,i=[],"+-".indexOf(t[0])>=0&&(t=t.slice(1)),t===".inf"?r===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:t===".nan"?NaN:t.indexOf(":")>=0?(t.split(":").forEach(function(a){i.unshift(parseFloat(a,10))}),t=0,n=1,i.forEach(function(a){t+=a*n,n*=60}),r*t):r*parseFloat(t,10)}var $$=/^[-+]?[0-9]+e/;function P$(e,t){var r;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(eb.isNegativeZero(e))return"-0.0";return r=e.toString(10),$$.test(r)?r.replace("e",".e"):r}function x$(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||eb.isNegativeZero(e))}tb.exports=new F$("tag:yaml.org,2002:float",{kind:"scalar",resolve:I$,construct:B$,predicate:x$,represent:P$,defaultStyle:"lowercase"})});var Ig=he(($G,nb)=>{"use strict";var R$=qo();nb.exports=new R$({include:[ed()],implicit:[WE(),JE(),QE(),rb()]})});var Bg=he((PG,ib)=>{"use strict";var T$=qo();ib.exports=new T$({include:[Ig()]})});var ob=he((xG,ub)=>{"use strict";var O$=Jr(),sb=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),ab=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function k$(e){return e===null?!1:sb.exec(e)!==null||ab.exec(e)!==null}function N$(e){var t,r,n,i,a,s,u,l=0,f=null,d,m,p;if(t=sb.exec(e),t===null&&(t=ab.exec(e)),t===null)throw new Error("Date resolve error");if(r=+t[1],n=+t[2]-1,i=+t[3],!t[4])return new Date(Date.UTC(r,n,i));if(a=+t[4],s=+t[5],u=+t[6],t[7]){for(l=t[7].slice(0,3);l.length<3;)l+="0";l=+l}return t[9]&&(d=+t[10],m=+(t[11]||0),f=(d*60+m)*6e4,t[9]==="-"&&(f=-f)),p=new Date(Date.UTC(r,n,i,a,s,u,l)),f&&p.setTime(p.getTime()-f),p}function L$(e){return e.toISOString()}ub.exports=new O$("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:k$,construct:N$,instanceOf:Date,represent:L$})});var cb=he((RG,lb)=>{"use strict";var U$=Jr();function j$(e){return e==="<<"||e===null}lb.exports=new U$("tag:yaml.org,2002:merge",{kind:"scalar",resolve:j$})});var db=he((TG,hb)=>{"use strict";var Vo;try{fb=Po,Vo=fb("buffer").Buffer}catch{}var fb,H$=Jr(),$g=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= \r`;function M$(e){if(e===null)return!1;var t,r,n=0,i=e.length,a=$g;for(r=0;r64)){if(t<0)return!1;n+=6}return n%8===0}function q$(e){var t,r,n=e.replace(/[\r\n=]/g,""),i=n.length,a=$g,s=0,u=[];for(t=0;t>16&255),u.push(s>>8&255),u.push(s&255)),s=s<<6|a.indexOf(n.charAt(t));return r=i%4*6,r===0?(u.push(s>>16&255),u.push(s>>8&255),u.push(s&255)):r===18?(u.push(s>>10&255),u.push(s>>2&255)):r===12&&u.push(s>>4&255),Vo?Vo.from?Vo.from(u):new Vo(u):u}function V$(e){var t="",r=0,n,i,a=e.length,s=$g;for(n=0;n>18&63],t+=s[r>>12&63],t+=s[r>>6&63],t+=s[r&63]),r=(r<<8)+e[n];return i=a%3,i===0?(t+=s[r>>18&63],t+=s[r>>12&63],t+=s[r>>6&63],t+=s[r&63]):i===2?(t+=s[r>>10&63],t+=s[r>>4&63],t+=s[r<<2&63],t+=s[64]):i===1&&(t+=s[r>>2&63],t+=s[r<<4&63],t+=s[64],t+=s[64]),t}function K$(e){return Vo&&Vo.isBuffer(e)}hb.exports=new H$("tag:yaml.org,2002:binary",{kind:"scalar",resolve:M$,construct:q$,predicate:K$,represent:V$})});var gb=he((kG,pb)=>{"use strict";var z$=Jr(),G$=Object.prototype.hasOwnProperty,Y$=Object.prototype.toString;function W$(e){if(e===null)return!0;var t=[],r,n,i,a,s,u=e;for(r=0,n=u.length;r{"use strict";var J$=Jr(),Z$=Object.prototype.toString;function Q$(e){if(e===null)return!0;var t,r,n,i,a,s=e;for(a=new Array(s.length),t=0,r=s.length;t{"use strict";var tP=Jr(),rP=Object.prototype.hasOwnProperty;function nP(e){if(e===null)return!0;var t,r=e;for(t in r)if(rP.call(r,t)&&r[t]!==null)return!1;return!0}function iP(e){return e!==null?e:{}}wb.exports=new tP("tag:yaml.org,2002:set",{kind:"mapping",resolve:nP,construct:iP})});var Xl=he((UG,Eb)=>{"use strict";var sP=qo();Eb.exports=new sP({include:[Bg()],implicit:[ob(),cb()],explicit:[db(),gb(),vb(),Ab()]})});var yb=he((jG,bb)=>{"use strict";var aP=Jr();function uP(){return!0}function oP(){}function lP(){return""}function cP(e){return typeof e>"u"}bb.exports=new aP("tag:yaml.org,2002:js/undefined",{kind:"scalar",resolve:uP,construct:oP,predicate:cP,represent:lP})});var Cb=he((HG,_b)=>{"use strict";var fP=Jr();function hP(e){if(e===null||e.length===0)return!1;var t=e,r=/\/([gim]*)$/.exec(e),n="";return!(t[0]==="/"&&(r&&(n=r[1]),n.length>3||t[t.length-n.length-1]!=="/"))}function dP(e){var t=e,r=/\/([gim]*)$/.exec(e),n="";return t[0]==="/"&&(r&&(n=r[1]),t=t.slice(1,t.length-n.length-1)),new RegExp(t,n)}function pP(e){var t="/"+e.source+"/";return e.global&&(t+="g"),e.multiline&&(t+="m"),e.ignoreCase&&(t+="i"),t}function gP(e){return Object.prototype.toString.call(e)==="[object RegExp]"}_b.exports=new fP("tag:yaml.org,2002:js/regexp",{kind:"scalar",resolve:hP,construct:dP,predicate:gP,represent:pP})});var Sb=he((MG,Fb)=>{"use strict";var td;try{Db=Po,td=Db("esprima")}catch{typeof window<"u"&&(td=window.esprima)}var Db,mP=Jr();function vP(e){if(e===null)return!1;try{var t="("+e+")",r=td.parse(t,{range:!0});return!(r.type!=="Program"||r.body.length!==1||r.body[0].type!=="ExpressionStatement"||r.body[0].expression.type!=="ArrowFunctionExpression"&&r.body[0].expression.type!=="FunctionExpression")}catch{return!1}}function wP(e){var t="("+e+")",r=td.parse(t,{range:!0}),n=[],i;if(r.type!=="Program"||r.body.length!==1||r.body[0].type!=="ExpressionStatement"||r.body[0].expression.type!=="ArrowFunctionExpression"&&r.body[0].expression.type!=="FunctionExpression")throw new Error("Failed to resolve function");return r.body[0].expression.params.forEach(function(a){n.push(a.name)}),i=r.body[0].expression.body.range,r.body[0].expression.body.type==="BlockStatement"?new Function(n,t.slice(i[0]+1,i[1]-1)):new Function(n,"return "+t.slice(i[0],i[1]))}function AP(e){return e.toString()}function EP(e){return Object.prototype.toString.call(e)==="[object Function]"}Fb.exports=new mP("tag:yaml.org,2002:js/function",{kind:"scalar",resolve:vP,construct:wP,predicate:EP,represent:AP})});var _f=he((VG,Bb)=>{"use strict";var Ib=qo();Bb.exports=Ib.DEFAULT=new Ib({include:[Xl()],explicit:[yb(),Cb(),Sb()]})});var Yb=he((KG,Cf)=>{"use strict";var Qa=Mo(),kb=Yl(),bP=kE(),Nb=Xl(),yP=_f(),Ku=Object.prototype.hasOwnProperty,rd=1,Lb=2,Ub=3,nd=4,Pg=1,_P=2,$b=3,CP=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,DP=/[\x85\u2028\u2029]/,FP=/[,\[\]\{\}]/,jb=/^(?:!|!!|![a-z\-]+!)$/i,Hb=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function Pb(e){return Object.prototype.toString.call(e)}function sa(e){return e===10||e===13}function zo(e){return e===9||e===32}function bi(e){return e===9||e===32||e===10||e===13}function Jl(e){return e===44||e===91||e===93||e===123||e===125}function SP(e){var t;return 48<=e&&e<=57?e-48:(t=e|32,97<=t&&t<=102?t-97+10:-1)}function IP(e){return e===120?2:e===117?4:e===85?8:0}function BP(e){return 48<=e&&e<=57?e-48:-1}function xb(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?` `:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"\x85":e===95?"\xA0":e===76?"\u2028":e===80?"\u2029":""}function $P(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}var Mb=new Array(256),qb=new Array(256);for(Ko=0;Ko<256;Ko++)Mb[Ko]=xb(Ko)?1:0,qb[Ko]=xb(Ko);var Ko;function PP(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||yP,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.documents=[]}function Vb(e,t){return new kb(t,new bP(e.filename,e.input,e.position,e.line,e.position-e.lineStart))}function We(e,t){throw Vb(e,t)}function sd(e,t){e.onWarning&&e.onWarning.call(null,Vb(e,t))}var Rb={YAML:function(t,r,n){var i,a,s;t.version!==null&&We(t,"duplication of %YAML directive"),n.length!==1&&We(t,"YAML directive accepts exactly one argument"),i=/^([0-9]+)\.([0-9]+)$/.exec(n[0]),i===null&&We(t,"ill-formed argument of the YAML directive"),a=parseInt(i[1],10),s=parseInt(i[2],10),a!==1&&We(t,"unacceptable YAML version of the document"),t.version=n[0],t.checkLineBreaks=s<2,s!==1&&s!==2&&sd(t,"unsupported YAML version of the document")},TAG:function(t,r,n){var i,a;n.length!==2&&We(t,"TAG directive accepts exactly two arguments"),i=n[0],a=n[1],jb.test(i)||We(t,"ill-formed tag handle (first argument) of the TAG directive"),Ku.call(t.tagMap,i)&&We(t,'there is a previously declared suffix for "'+i+'" tag handle'),Hb.test(a)||We(t,"ill-formed tag prefix (second argument) of the TAG directive"),t.tagMap[i]=a}};function Vu(e,t,r,n){var i,a,s,u;if(t1&&(e.result+=Qa.repeat(` `,t-1))}function xP(e,t,r){var n,i,a,s,u,l,f,d,m=e.kind,p=e.result,h;if(h=e.input.charCodeAt(e.position),bi(h)||Jl(h)||h===35||h===38||h===42||h===33||h===124||h===62||h===39||h===34||h===37||h===64||h===96||(h===63||h===45)&&(i=e.input.charCodeAt(e.position+1),bi(i)||r&&Jl(i)))return!1;for(e.kind="scalar",e.result="",a=s=e.position,u=!1;h!==0;){if(h===58){if(i=e.input.charCodeAt(e.position+1),bi(i)||r&&Jl(i))break}else if(h===35){if(n=e.input.charCodeAt(e.position-1),bi(n))break}else{if(e.position===e.lineStart&&ad(e)||r&&Jl(h))break;if(sa(h))if(l=e.line,f=e.lineStart,d=e.lineIndent,Vr(e,!1,-1),e.lineIndent>=t){u=!0,h=e.input.charCodeAt(e.position);continue}else{e.position=s,e.line=l,e.lineStart=f,e.lineIndent=d;break}}u&&(Vu(e,a,s,!1),Rg(e,e.line-l),a=s=e.position,u=!1),zo(h)||(s=e.position+1),h=e.input.charCodeAt(++e.position)}return Vu(e,a,s,!1),e.result?!0:(e.kind=m,e.result=p,!1)}function RP(e,t){var r,n,i;if(r=e.input.charCodeAt(e.position),r!==39)return!1;for(e.kind="scalar",e.result="",e.position++,n=i=e.position;(r=e.input.charCodeAt(e.position))!==0;)if(r===39)if(Vu(e,n,e.position,!0),r=e.input.charCodeAt(++e.position),r===39)n=e.position,e.position++,i=e.position;else return!0;else sa(r)?(Vu(e,n,i,!0),Rg(e,Vr(e,!1,t)),n=i=e.position):e.position===e.lineStart&&ad(e)?We(e,"unexpected end of the document within a single quoted scalar"):(e.position++,i=e.position);We(e,"unexpected end of the stream within a single quoted scalar")}function TP(e,t){var r,n,i,a,s,u;if(u=e.input.charCodeAt(e.position),u!==34)return!1;for(e.kind="scalar",e.result="",e.position++,r=n=e.position;(u=e.input.charCodeAt(e.position))!==0;){if(u===34)return Vu(e,r,e.position,!0),e.position++,!0;if(u===92){if(Vu(e,r,e.position,!0),u=e.input.charCodeAt(++e.position),sa(u))Vr(e,!1,t);else if(u<256&&Mb[u])e.result+=qb[u],e.position++;else if((s=IP(u))>0){for(i=s,a=0;i>0;i--)u=e.input.charCodeAt(++e.position),(s=SP(u))>=0?a=(a<<4)+s:We(e,"expected hexadecimal character");e.result+=$P(a),e.position++}else We(e,"unknown escape sequence");r=n=e.position}else sa(u)?(Vu(e,r,n,!0),Rg(e,Vr(e,!1,t)),r=n=e.position):e.position===e.lineStart&&ad(e)?We(e,"unexpected end of the document within a double quoted scalar"):(e.position++,n=e.position)}We(e,"unexpected end of the stream within a double quoted scalar")}function OP(e,t){var r=!0,n,i=e.tag,a,s=e.anchor,u,l,f,d,m,p={},h,w,v,y;if(y=e.input.charCodeAt(e.position),y===91)l=93,m=!1,a=[];else if(y===123)l=125,m=!0,a={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=a),y=e.input.charCodeAt(++e.position);y!==0;){if(Vr(e,!0,t),y=e.input.charCodeAt(e.position),y===l)return e.position++,e.tag=i,e.anchor=s,e.kind=m?"mapping":"sequence",e.result=a,!0;r||We(e,"missed comma between flow collection entries"),w=h=v=null,f=d=!1,y===63&&(u=e.input.charCodeAt(e.position+1),bi(u)&&(f=d=!0,e.position++,Vr(e,!0,t))),n=e.line,Ql(e,t,rd,!1,!0),w=e.tag,h=e.result,Vr(e,!0,t),y=e.input.charCodeAt(e.position),(d||e.line===n)&&y===58&&(f=!0,y=e.input.charCodeAt(++e.position),Vr(e,!0,t),Ql(e,t,rd,!1,!0),v=e.result),m?Zl(e,a,p,w,h,v):f?a.push(Zl(e,null,p,w,h,v)):a.push(h),Vr(e,!0,t),y=e.input.charCodeAt(e.position),y===44?(r=!0,y=e.input.charCodeAt(++e.position)):r=!1}We(e,"unexpected end of the stream within a flow collection")}function kP(e,t){var r,n,i=Pg,a=!1,s=!1,u=t,l=0,f=!1,d,m;if(m=e.input.charCodeAt(e.position),m===124)n=!1;else if(m===62)n=!0;else return!1;for(e.kind="scalar",e.result="";m!==0;)if(m=e.input.charCodeAt(++e.position),m===43||m===45)Pg===i?i=m===43?$b:_P:We(e,"repeat of a chomping mode identifier");else if((d=BP(m))>=0)d===0?We(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):s?We(e,"repeat of an indentation width identifier"):(u=t+d-1,s=!0);else break;if(zo(m)){do m=e.input.charCodeAt(++e.position);while(zo(m));if(m===35)do m=e.input.charCodeAt(++e.position);while(!sa(m)&&m!==0)}for(;m!==0;){for(xg(e),e.lineIndent=0,m=e.input.charCodeAt(e.position);(!s||e.lineIndentu&&(u=e.lineIndent),sa(m)){l++;continue}if(e.lineIndentt)&&l!==0)We(e,"bad indentation of a sequence entry");else if(e.lineIndentt)&&(Ql(e,t,nd,!0,i)&&(w?p=e.result:h=e.result),w||(Zl(e,f,d,m,p,h,a,s),m=p=h=null),Vr(e,!0,-1),y=e.input.charCodeAt(e.position)),e.lineIndent>t&&y!==0)We(e,"bad indentation of a mapping entry");else if(e.lineIndentt?l=1:e.lineIndent===t?l=0:e.lineIndentt?l=1:e.lineIndent===t?l=0:e.lineIndent tag; it should be "scalar", not "'+e.kind+'"'),m=0,p=e.implicitTypes.length;m tag; it should be "'+h.kind+'", not "'+e.kind+'"'),h.resolve(e.result)?(e.result=h.construct(e.result),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):We(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")):We(e,"unknown tag !<"+e.tag+">");return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||d}function HP(e){var t=e.position,r,n,i,a=!1,s;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap={},e.anchorMap={};(s=e.input.charCodeAt(e.position))!==0&&(Vr(e,!0,-1),s=e.input.charCodeAt(e.position),!(e.lineIndent>0||s!==37));){for(a=!0,s=e.input.charCodeAt(++e.position),r=e.position;s!==0&&!bi(s);)s=e.input.charCodeAt(++e.position);for(n=e.input.slice(r,e.position),i=[],n.length<1&&We(e,"directive name must not be less than one character in length");s!==0;){for(;zo(s);)s=e.input.charCodeAt(++e.position);if(s===35){do s=e.input.charCodeAt(++e.position);while(s!==0&&!sa(s));break}if(sa(s))break;for(r=e.position;s!==0&&!bi(s);)s=e.input.charCodeAt(++e.position);i.push(e.input.slice(r,e.position))}s!==0&&xg(e),Ku.call(Rb,n)?Rb[n](e,n,i):sd(e,'unknown document directive "'+n+'"')}if(Vr(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,Vr(e,!0,-1)):a&&We(e,"directives end mark is expected"),Ql(e,e.lineIndent-1,nd,!1,!0),Vr(e,!0,-1),e.checkLineBreaks&&DP.test(e.input.slice(t,e.position))&&sd(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&ad(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,Vr(e,!0,-1));return}if(e.position"u"&&(r=t,t=null);var n=Kb(e,r);if(typeof t!="function")return n;for(var i=0,a=n.length;i"u"&&(r=t,t=null),zb(e,t,Qa.extend({schema:Nb},r))}function qP(e,t){return Gb(e,Qa.extend({schema:Nb},t))}Cf.exports.loadAll=zb;Cf.exports.load=Gb;Cf.exports.safeLoadAll=MP;Cf.exports.safeLoad=qP});var vy=he((zG,Ng)=>{"use strict";var Ff=Mo(),Sf=Yl(),VP=_f(),KP=Xl(),ry=Object.prototype.toString,ny=Object.prototype.hasOwnProperty,zP=9,Df=10,GP=13,YP=32,WP=33,XP=34,iy=35,JP=37,ZP=38,QP=39,ex=42,sy=44,tx=45,ay=58,rx=61,nx=62,ix=63,sx=64,uy=91,oy=93,ax=96,ly=123,ux=124,cy=125,Hn={};Hn[0]="\\0";Hn[7]="\\a";Hn[8]="\\b";Hn[9]="\\t";Hn[10]="\\n";Hn[11]="\\v";Hn[12]="\\f";Hn[13]="\\r";Hn[27]="\\e";Hn[34]='\\"';Hn[92]="\\\\";Hn[133]="\\N";Hn[160]="\\_";Hn[8232]="\\L";Hn[8233]="\\P";var ox=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"];function lx(e,t){var r,n,i,a,s,u,l;if(t===null)return{};for(r={},n=Object.keys(t),i=0,a=n.length;i0?e.charCodeAt(a-1):null,p=p&&Jb(s,u)}else{for(a=0;an&&e[m+1]!==" ",m=a);else if(!ec(s))return ud;u=a>0?e.charCodeAt(a-1):null,p=p&&Jb(s,u)}f=f||d&&a-m-1>n&&e[m+1]!==" "}return!l&&!f?p&&!i(e)?hy:dy:r>9&&fy(e)?ud:f?gy:py}function gx(e,t,r,n){e.dump=function(){if(t.length===0)return"''";if(!e.noCompatMode&&ox.indexOf(t)!==-1)return"'"+t+"'";var i=e.indent*Math.max(1,r),a=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-i),s=n||e.flowLevel>-1&&r>=e.flowLevel;function u(l){return fx(e,l)}switch(px(t,s,e.indent,a,u)){case hy:return t;case dy:return"'"+t.replace(/'/g,"''")+"'";case py:return"|"+Zb(t,e.indent)+Qb(Xb(t,i));case gy:return">"+Zb(t,e.indent)+Qb(Xb(mx(t,a),i));case ud:return'"'+vx(t,a)+'"';default:throw new Sf("impossible error: invalid scalar style")}}()}function Zb(e,t){var r=fy(e)?String(t):"",n=e[e.length-1]===` `,i=n&&(e[e.length-2]===` `||e===` `),a=i?"+":n?"":"-";return r+a+` `}function Qb(e){return e[e.length-1]===` `?e.slice(0,-1):e}function mx(e,t){for(var r=/(\n+)([^\n]*)/g,n=function(){var f=e.indexOf(` `);return f=f!==-1?f:e.length,r.lastIndex=f,ey(e.slice(0,f),t)}(),i=e[0]===` `||e[0]===" ",a,s;s=r.exec(e);){var u=s[1],l=s[2];a=l[0]===" ",n+=u+(!i&&!a&&l!==""?` `:"")+ey(l,t),i=a}return n}function ey(e,t){if(e===""||e[0]===" ")return e;for(var r=/ [^ ]/g,n,i=0,a,s=0,u=0,l="";n=r.exec(e);)u=n.index,u-i>t&&(a=s>i?s:u,l+=` `+e.slice(i,a),i=a+1),s=u;return l+=` `,e.length-i>t&&s>i?l+=e.slice(i,s)+` `+e.slice(s+1):l+=e.slice(i),l.slice(1)}function vx(e){for(var t="",r,n,i,a=0;a=55296&&r<=56319&&(n=e.charCodeAt(a+1),n>=56320&&n<=57343)){t+=Wb((r-55296)*1024+n-56320+65536),a++;continue}i=Hn[r],t+=!i&&ec(r)?e[a]:i||Wb(r)}return t}function wx(e,t,r){var n="",i=e.tag,a,s;for(a=0,s=r.length;a1024&&(d+="? "),d+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),Go(e,t,f,!1,!1)&&(d+=e.dump,n+=d));e.tag=i,e.dump="{"+n+"}"}function bx(e,t,r,n){var i="",a=e.tag,s=Object.keys(r),u,l,f,d,m,p;if(e.sortKeys===!0)s.sort();else if(typeof e.sortKeys=="function")s.sort(e.sortKeys);else if(e.sortKeys)throw new Sf("sortKeys must be a boolean or a function");for(u=0,l=s.length;u1024,m&&(e.dump&&Df===e.dump.charCodeAt(0)?p+="?":p+="? "),p+=e.dump,m&&(p+=Tg(e,t)),Go(e,t+1,d,!0,m)&&(e.dump&&Df===e.dump.charCodeAt(0)?p+=":":p+=": ",p+=e.dump,i+=p));e.tag=a,e.dump=i||"{}"}function ty(e,t,r){var n,i,a,s,u,l;for(i=r?e.explicitTypes:e.implicitTypes,a=0,s=i.length;a tag resolver accepts not "'+l+'" style');e.dump=n}return!0}return!1}function Go(e,t,r,n,i,a){e.tag=null,e.dump=r,ty(e,r,!1)||ty(e,r,!0);var s=ry.call(e.dump);n&&(n=e.flowLevel<0||e.flowLevel>t);var u=s==="[object Object]"||s==="[object Array]",l,f;if(u&&(l=e.duplicates.indexOf(r),f=l!==-1),(e.tag!==null&&e.tag!=="?"||f||e.indent!==2&&t>0)&&(i=!1),f&&e.usedDuplicates[l])e.dump="*ref_"+l;else{if(u&&f&&!e.usedDuplicates[l]&&(e.usedDuplicates[l]=!0),s==="[object Object]")n&&Object.keys(e.dump).length!==0?(bx(e,t,e.dump,i),f&&(e.dump="&ref_"+l+e.dump)):(Ex(e,t,e.dump),f&&(e.dump="&ref_"+l+" "+e.dump));else if(s==="[object Array]"){var d=e.noArrayIndent&&t>0?t-1:t;n&&e.dump.length!==0?(Ax(e,d,e.dump,i),f&&(e.dump="&ref_"+l+e.dump)):(wx(e,d,e.dump),f&&(e.dump="&ref_"+l+" "+e.dump))}else if(s==="[object String]")e.tag!=="?"&&gx(e,e.dump,t,a);else{if(e.skipInvalid)return!1;throw new Sf("unacceptable kind of an object to dump "+s)}e.tag!==null&&e.tag!=="?"&&(e.dump="!<"+e.tag+"> "+e.dump)}return!0}function yx(e,t){var r=[],n=[],i,a;for(Og(e,r,n),i=0,a=n.length;i{"use strict";var od=Yb(),wy=vy();function ld(e){return function(){throw new Error("Function "+e+" is deprecated and cannot be used.")}}xr.exports.Type=Jr();xr.exports.Schema=qo();xr.exports.FAILSAFE_SCHEMA=ed();xr.exports.JSON_SCHEMA=Ig();xr.exports.CORE_SCHEMA=Bg();xr.exports.DEFAULT_SAFE_SCHEMA=Xl();xr.exports.DEFAULT_FULL_SCHEMA=_f();xr.exports.load=od.load;xr.exports.loadAll=od.loadAll;xr.exports.safeLoad=od.safeLoad;xr.exports.safeLoadAll=od.safeLoadAll;xr.exports.dump=wy.dump;xr.exports.safeDump=wy.safeDump;xr.exports.YAMLException=Yl();xr.exports.MINIMAL_SCHEMA=ed();xr.exports.SAFE_SCHEMA=Xl();xr.exports.DEFAULT_SCHEMA=_f();xr.exports.scan=ld("scan");xr.exports.parse=ld("parse");xr.exports.compose=ld("compose");xr.exports.addConstructor=ld("addConstructor")});var by=he((YG,Ey)=>{"use strict";var Cx=Ay();Ey.exports=Cx});var _y=he((WG,yy)=>{"use strict";var cd=by();yy.exports={safeLoad:cd.safeLoad,load:cd.load,safeDump:cd.safeDump,dump:cd.dump}});var By=he(hd=>{"use strict";hd.byteLength=Rx;hd.toByteArray=Ox;hd.fromByteArray=Lx;var oa=[],hs=[],xx=typeof Uint8Array<"u"?Uint8Array:Array,Lg="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Yo=0,Sy=Lg.length;Yo0)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 Rx(e){var t=Iy(e),r=t[0],n=t[1];return(r+n)*3/4-n}function Tx(e,t,r){return(t+r)*3/4-r}function Ox(e){var t,r=Iy(e),n=r[0],i=r[1],a=new xx(Tx(e,n,i)),s=0,u=i>0?n-4:n,l;for(l=0;l>16&255,a[s++]=t>>8&255,a[s++]=t&255;return i===2&&(t=hs[e.charCodeAt(l)]<<2|hs[e.charCodeAt(l+1)]>>4,a[s++]=t&255),i===1&&(t=hs[e.charCodeAt(l)]<<10|hs[e.charCodeAt(l+1)]<<4|hs[e.charCodeAt(l+2)]>>2,a[s++]=t>>8&255,a[s++]=t&255),a}function kx(e){return oa[e>>18&63]+oa[e>>12&63]+oa[e>>6&63]+oa[e&63]}function Nx(e,t,r){for(var n,i=[],a=t;au?u:s+a));return n===1?(t=e[r-1],i.push(oa[t>>2]+oa[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(oa[t>>10]+oa[t>>4&63]+oa[t<<2&63]+"=")),i.join("")}});var $y=he(Ug=>{Ug.read=function(e,t,r,n,i){var a,s,u=i*8-n-1,l=(1<>1,d=-7,m=r?i-1:0,p=r?-1:1,h=e[t+m];for(m+=p,a=h&(1<<-d)-1,h>>=-d,d+=u;d>0;a=a*256+e[t+m],m+=p,d-=8);for(s=a&(1<<-d)-1,a>>=-d,d+=n;d>0;s=s*256+e[t+m],m+=p,d-=8);if(a===0)a=1-f;else{if(a===l)return s?NaN:(h?-1:1)*(1/0);s=s+Math.pow(2,n),a=a-f}return(h?-1:1)*s*Math.pow(2,a-n)};Ug.write=function(e,t,r,n,i,a){var s,u,l,f=a*8-i-1,d=(1<>1,p=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:a-1,w=n?1:-1,v=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(u=isNaN(t)?1:0,s=d):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),s+m>=1?t+=p/l:t+=p*Math.pow(2,1-m),t*l>=2&&(s++,l/=2),s+m>=d?(u=0,s=d):s+m>=1?(u=(t*l-1)*Math.pow(2,i),s=s+m):(u=t*Math.pow(2,m-1)*Math.pow(2,i),s=0));i>=8;e[r+h]=u&255,h+=w,u/=256,i-=8);for(s=s<0;e[r+h]=s&255,h+=w,s/=256,f-=8);e[r+h-w]|=v*128}});var gd=he(ic=>{"use strict";var jg=By(),rc=$y(),Py=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ic.Buffer=de;ic.SlowBuffer=Vx;ic.INSPECT_MAX_BYTES=50;var dd=2147483647;ic.kMaxLength=dd;de.TYPED_ARRAY_SUPPORT=Ux();!de.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 Ux(){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(de.prototype,"parent",{enumerable:!0,get:function(){if(de.isBuffer(this))return this.buffer}});Object.defineProperty(de.prototype,"offset",{enumerable:!0,get:function(){if(de.isBuffer(this))return this.byteOffset}});function eu(e){if(e>dd)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,de.prototype),t}function de(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 Vg(e)}return Oy(e,t,r)}de.poolSize=8192;function Oy(e,t,r){if(typeof e=="string")return Hx(e,t);if(ArrayBuffer.isView(e))return Mx(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(la(e,ArrayBuffer)||e&&la(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(la(e,SharedArrayBuffer)||e&&la(e.buffer,SharedArrayBuffer)))return Mg(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 de.from(n,t,r);let i=qx(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return de.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)}de.from=function(e,t,r){return Oy(e,t,r)};Object.setPrototypeOf(de.prototype,Uint8Array.prototype);Object.setPrototypeOf(de,Uint8Array);function ky(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 jx(e,t,r){return ky(e),e<=0?eu(e):t!==void 0?typeof r=="string"?eu(e).fill(t,r):eu(e).fill(t):eu(e)}de.alloc=function(e,t,r){return jx(e,t,r)};function Vg(e){return ky(e),eu(e<0?0:Kg(e)|0)}de.allocUnsafe=function(e){return Vg(e)};de.allocUnsafeSlow=function(e){return Vg(e)};function Hx(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!de.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=Ny(e,t)|0,n=eu(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function Hg(e){let t=e.length<0?0:Kg(e.length)|0,r=eu(t);for(let n=0;n=dd)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+dd.toString(16)+" bytes");return e|0}function Vx(e){return+e!=e&&(e=0),de.alloc(+e)}de.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==de.prototype};de.compare=function(t,r){if(la(t,Uint8Array)&&(t=de.from(t,t.offset,t.byteLength)),la(r,Uint8Array)&&(r=de.from(r,r.offset,r.byteLength)),!de.isBuffer(t)||!de.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;let n=t.length,i=r.length;for(let a=0,s=Math.min(n,i);ai.length?(de.isBuffer(s)||(s=de.from(s)),s.copy(i,a)):Uint8Array.prototype.set.call(i,s,a);else if(de.isBuffer(s))s.copy(i,a);else throw new TypeError('"list" argument must be an Array of Buffers');a+=s.length}return i};function Ny(e,t){if(de.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||la(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 qg(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return zy(e).length;default:if(i)return n?-1:qg(e).length;t=(""+t).toLowerCase(),i=!0}}de.byteLength=Ny;function Kx(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 tR(this,t,r);case"utf8":case"utf-8":return Uy(this,t,r);case"ascii":return Qx(this,t,r);case"latin1":case"binary":return eR(this,t,r);case"base64":return Jx(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return rR(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}de.prototype._isBuffer=!0;function Wo(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}de.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+=" ... "),""};Py&&(de.prototype[Py]=de.prototype.inspect);de.prototype.compare=function(t,r,n,i,a){if(la(t,Uint8Array)&&(t=de.from(t,t.offset,t.byteLength)),!de.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),a===void 0&&(a=this.length),r<0||n>t.length||i<0||a>this.length)throw new RangeError("out of range index");if(i>=a&&r>=n)return 0;if(i>=a)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,a>>>=0,this===t)return 0;let s=a-i,u=n-r,l=Math.min(s,u),f=this.slice(i,a),d=t.slice(r,n);for(let m=0;m2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Gg(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=de.from(t,n)),de.isBuffer(t))return t.length===0?-1:xy(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):xy(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function xy(e,t,r,n,i){let a=1,s=e.length,u=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;a=2,s/=2,u/=2,r/=2}function l(d,m){return a===1?d[m]:d.readUInt16BE(m*a)}let f;if(i){let d=-1;for(f=r;fs&&(r=s-u),f=r;f>=0;f--){let d=!0;for(let m=0;mi&&(n=i)):n=i;let a=t.length;n>a/2&&(n=a/2);let s;for(s=0;s>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let a=this.length-r;if((n===void 0||n>a)&&(n=a),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return zx(this,t,r,n);case"utf8":case"utf-8":return Gx(this,t,r,n);case"ascii":case"latin1":case"binary":return Yx(this,t,r,n);case"base64":return Wx(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Xx(this,t,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};de.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Jx(e,t,r){return t===0&&r===e.length?jg.fromByteArray(e):jg.fromByteArray(e.slice(t,r))}function Uy(e,t,r){r=Math.min(e.length,r);let n=[],i=t;for(;i239?4:a>223?3:a>191?2:1;if(i+u<=r){let l,f,d,m;switch(u){case 1:a<128&&(s=a);break;case 2:l=e[i+1],(l&192)===128&&(m=(a&31)<<6|l&63,m>127&&(s=m));break;case 3:l=e[i+1],f=e[i+2],(l&192)===128&&(f&192)===128&&(m=(a&15)<<12|(l&63)<<6|f&63,m>2047&&(m<55296||m>57343)&&(s=m));break;case 4:l=e[i+1],f=e[i+2],d=e[i+3],(l&192)===128&&(f&192)===128&&(d&192)===128&&(m=(a&15)<<18|(l&63)<<12|(f&63)<<6|d&63,m>65535&&m<1114112&&(s=m))}}s===null?(s=65533,u=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=u}return Zx(n)}var Ry=4096;function Zx(e){let t=e.length;if(t<=Ry)return String.fromCharCode.apply(String,e);let r="",n=0;for(;nn)&&(r=n);let i="";for(let a=t;an&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),rr)throw new RangeError("Trying to access beyond buffer length")}de.prototype.readUintLE=de.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||on(t,r,this.length);let i=this[t],a=1,s=0;for(;++s>>0,r=r>>>0,n||on(t,r,this.length);let i=this[t+--r],a=1;for(;r>0&&(a*=256);)i+=this[t+--r]*a;return i};de.prototype.readUint8=de.prototype.readUInt8=function(t,r){return t=t>>>0,r||on(t,1,this.length),this[t]};de.prototype.readUint16LE=de.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||on(t,2,this.length),this[t]|this[t+1]<<8};de.prototype.readUint16BE=de.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||on(t,2,this.length),this[t]<<8|this[t+1]};de.prototype.readUint32LE=de.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||on(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};de.prototype.readUint32BE=de.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||on(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};de.prototype.readBigUInt64LE=zu(function(t){t=t>>>0,nc(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&$f(t,this.length-8);let i=r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,a=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(i)+(BigInt(a)<>>0,nc(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&$f(t,this.length-8);let i=r*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],a=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(i)<>>0,r=r>>>0,n||on(t,r,this.length);let i=this[t],a=1,s=0;for(;++s=a&&(i-=Math.pow(2,8*r)),i};de.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||on(t,r,this.length);let i=r,a=1,s=this[t+--i];for(;i>0&&(a*=256);)s+=this[t+--i]*a;return a*=128,s>=a&&(s-=Math.pow(2,8*r)),s};de.prototype.readInt8=function(t,r){return t=t>>>0,r||on(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};de.prototype.readInt16LE=function(t,r){t=t>>>0,r||on(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};de.prototype.readInt16BE=function(t,r){t=t>>>0,r||on(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};de.prototype.readInt32LE=function(t,r){return t=t>>>0,r||on(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};de.prototype.readInt32BE=function(t,r){return t=t>>>0,r||on(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};de.prototype.readBigInt64LE=zu(function(t){t=t>>>0,nc(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&$f(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,nc(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&$f(t,this.length-8);let i=(r<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<>>0,r||on(t,4,this.length),rc.read(this,t,!0,23,4)};de.prototype.readFloatBE=function(t,r){return t=t>>>0,r||on(t,4,this.length),rc.read(this,t,!1,23,4)};de.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||on(t,8,this.length),rc.read(this,t,!0,52,8)};de.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||on(t,8,this.length),rc.read(this,t,!1,52,8)};function yi(e,t,r,n,i,a){if(!de.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}de.prototype.writeUintLE=de.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let u=Math.pow(2,8*n)-1;yi(this,t,r,n,u,0)}let a=1,s=0;for(this[r]=t&255;++s>>0,n=n>>>0,!i){let u=Math.pow(2,8*n)-1;yi(this,t,r,n,u,0)}let a=n-1,s=1;for(this[r+a]=t&255;--a>=0&&(s*=256);)this[r+a]=t/s&255;return r+n};de.prototype.writeUint8=de.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||yi(this,t,r,1,255,0),this[r]=t&255,r+1};de.prototype.writeUint16LE=de.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||yi(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};de.prototype.writeUint16BE=de.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||yi(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};de.prototype.writeUint32LE=de.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||yi(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};de.prototype.writeUint32BE=de.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||yi(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 jy(e,t,r,n,i){Ky(t,n,i,e,r,7);let a=Number(t&BigInt(4294967295));e[r++]=a,a=a>>8,e[r++]=a,a=a>>8,e[r++]=a,a=a>>8,e[r++]=a;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,r}function Hy(e,t,r,n,i){Ky(t,n,i,e,r,7);let a=Number(t&BigInt(4294967295));e[r+7]=a,a=a>>8,e[r+6]=a,a=a>>8,e[r+5]=a,a=a>>8,e[r+4]=a;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=s,s=s>>8,e[r+2]=s,s=s>>8,e[r+1]=s,s=s>>8,e[r]=s,r+8}de.prototype.writeBigUInt64LE=zu(function(t,r=0){return jy(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});de.prototype.writeBigUInt64BE=zu(function(t,r=0){return Hy(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});de.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let l=Math.pow(2,8*n-1);yi(this,t,r,n,l-1,-l)}let a=0,s=1,u=0;for(this[r]=t&255;++a>0)-u&255;return r+n};de.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let l=Math.pow(2,8*n-1);yi(this,t,r,n,l-1,-l)}let a=n-1,s=1,u=0;for(this[r+a]=t&255;--a>=0&&(s*=256);)t<0&&u===0&&this[r+a+1]!==0&&(u=1),this[r+a]=(t/s>>0)-u&255;return r+n};de.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||yi(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};de.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||yi(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};de.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||yi(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};de.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||yi(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};de.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||yi(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};de.prototype.writeBigInt64LE=zu(function(t,r=0){return jy(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});de.prototype.writeBigInt64BE=zu(function(t,r=0){return Hy(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function My(e,t,r,n,i,a){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function qy(e,t,r,n,i){return t=+t,r=r>>>0,i||My(e,t,r,4,34028234663852886e22,-34028234663852886e22),rc.write(e,t,r,n,23,4),r+4}de.prototype.writeFloatLE=function(t,r,n){return qy(this,t,r,!0,n)};de.prototype.writeFloatBE=function(t,r,n){return qy(this,t,r,!1,n)};function Vy(e,t,r,n,i){return t=+t,r=r>>>0,i||My(e,t,r,8,17976931348623157e292,-17976931348623157e292),rc.write(e,t,r,n,52,8),r+8}de.prototype.writeDoubleLE=function(t,r,n){return Vy(this,t,r,!0,n)};de.prototype.writeDoubleBE=function(t,r,n){return Vy(this,t,r,!1,n)};de.prototype.copy=function(t,r,n,i){if(!de.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-r>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let a;if(typeof t=="number")for(a=r;a2**32?i=Ty(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=Ty(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function Ty(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 nR(e,t,r){nc(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&$f(t,e.length-(r+1))}function Ky(e,t,r,n,i,a){if(e>r||e3?t===0||t===BigInt(0)?u=`>= 0${s} and < 2${s} ** ${(a+1)*8}${s}`:u=`>= -(2${s} ** ${(a+1)*8-1}${s}) and < 2 ** ${(a+1)*8-1}${s}`:u=`>= ${t}${s} and <= ${r}${s}`,new tc.ERR_OUT_OF_RANGE("value",u,e)}nR(n,i,a)}function nc(e,t){if(typeof e!="number")throw new tc.ERR_INVALID_ARG_TYPE(t,"number",e)}function $f(e,t,r){throw Math.floor(e)!==e?(nc(e,r),new tc.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new tc.ERR_BUFFER_OUT_OF_BOUNDS:new tc.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var iR=/[^+/0-9A-Za-z-_]/g;function sR(e){if(e=e.split("=")[0],e=e.trim().replace(iR,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function qg(e,t){t=t||1/0;let r,n=e.length,i=null,a=[];for(let s=0;s55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&a.push(239,191,189);continue}else if(s+1===n){(t-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&a.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;a.push(r)}else if(r<2048){if((t-=2)<0)break;a.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;a.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return a}function aR(e){let t=[];for(let r=0;r>8,i=r%256,a.push(i),a.push(n);return a}function zy(e){return jg.toByteArray(sR(e))}function pd(e,t,r,n){let i;for(i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function la(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Gg(e){return e!==e}var oR=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 zu(e){return typeof BigInt>"u"?lR:e}function lR(){throw new Error("BigInt not supported")}});var m_=he(_e=>{var Pf={};Pf.userAgent=!1;var sc={},cR="11.1.0",fR="jsrsasign(all) 11.1.0 (2024-02-01) (c) 2010-2023 Kenji Urushima | kjur.github.io/jsrsasign/license";var Se=Se||function(e,t){var r={},n=r.lib={},i=n.Base=function(){function h(){}return{extend:function(w){h.prototype=this;var v=new h;return w&&v.mixIn(w),v.hasOwnProperty("init")||(v.init=function(){v.$super.init.apply(this,arguments)}),v.init.prototype=v,v.$super=this,v},create:function(){var w=this.extend();return w.init.apply(w,arguments),w},init:function(){},mixIn:function(w){for(var v in w)w.hasOwnProperty(v)&&(this[v]=w[v]);w.hasOwnProperty("toString")&&(this.toString=w.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),a=n.WordArray=i.extend({init:function(h,w){h=this.words=h||[],w!=t?this.sigBytes=w:this.sigBytes=h.length*4},toString:function(h){return(h||u).stringify(this)},concat:function(h){var w=this.words,v=h.words,y=this.sigBytes,g=h.sigBytes;if(this.clamp(),y%4)for(var b=0;b>>2]>>>24-b%4*8&255;w[y+b>>>2]|=D<<24-(y+b)%4*8}else for(var b=0;b>>2]=v[b>>>2];return this.sigBytes+=g,this},clamp:function(){var h=this.words,w=this.sigBytes;h[w>>>2]&=4294967295<<32-w%4*8,h.length=e.ceil(w/4)},clone:function(){var h=i.clone.call(this);return h.words=this.words.slice(0),h},random:function(h){for(var w=[],v=0;v>>2]>>>24-g%4*8&255;y.push((b>>>4).toString(16)),y.push((b&15).toString(16))}return y.join("")},parse:function(h){for(var w=h.length,v=[],y=0;y>>3]|=parseInt(h.substr(y,2),16)<<24-y%8*4;return new a.init(v,w/2)}},l=s.Latin1={stringify:function(h){for(var w=h.words,v=h.sigBytes,y=[],g=0;g>>2]>>>24-g%4*8&255;y.push(String.fromCharCode(b))}return y.join("")},parse:function(h){for(var w=h.length,v=[],y=0;y>>2]|=(h.charCodeAt(y)&255)<<24-y%4*8;return new a.init(v,w)}},f=s.Utf8={stringify:function(h){try{return decodeURIComponent(escape(l.stringify(h)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(h){return l.parse(unescape(encodeURIComponent(h)))}},d=n.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(h){typeof h=="string"&&(h=f.parse(h)),this._data.concat(h),this._nDataBytes+=h.sigBytes},_process:function(h){var w=this._data,v=w.words,y=w.sigBytes,g=this.blockSize,b=g*4,D=y/b;h?D=e.ceil(D):D=e.max((D|0)-this._minBufferSize,0);var C=D*g,F=e.min(C*4,y);if(C){for(var U=0;U>>2]&255}},t.BlockCipher=u.extend({cfg:u.cfg.extend({mode:m,padding:f}),reset:function(){u.reset.call(this);var y=this.cfg,v=y.iv,y=y.mode;if(this._xformMode==this._ENC_XFORM_MODE)var g=y.createEncryptor;else g=y.createDecryptor,this._minBufferSize=1;this._mode=g.call(y,this,v&&v.words)},_doProcessBlock:function(v,y){this._mode.processBlock(v,y)},_doFinalize:function(){var v=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){v.pad(this._data,this.blockSize);var y=this._process(!0)}else y=this._process(!0),v.unpad(y);return y},blockSize:4});var d=t.CipherParams=r.extend({init:function(v){this.mixIn(v)},toString:function(v){return(v||this.formatter).stringify(this)}}),m=(h.format={}).OpenSSL={stringify:function(v){var y=v.ciphertext;return v=v.salt,(v?n.create([1398893684,1701076831]).concat(v).concat(y):y).toString(a)},parse:function(v){v=a.parse(v);var y=v.words;if(y[0]==1398893684&&y[1]==1701076831){var g=n.create(y.slice(2,4));y.splice(0,4),v.sigBytes-=16}return d.create({ciphertext:v,salt:g})}},p=t.SerializableCipher=r.extend({cfg:r.extend({format:m}),encrypt:function(v,y,g,b){b=this.cfg.extend(b);var D=v.createEncryptor(g,b);return y=D.finalize(y),D=D.cfg,d.create({ciphertext:y,key:g,iv:D.iv,algorithm:v,mode:D.mode,padding:D.padding,blockSize:v.blockSize,formatter:b.format})},decrypt:function(v,y,g,b){return b=this.cfg.extend(b),y=this._parse(y,b.format),v.createDecryptor(g,b).finalize(y.ciphertext)},_parse:function(v,y){return typeof v=="string"?y.parse(v,this):v}}),h=(h.kdf={}).OpenSSL={execute:function(v,y,g,b){return b||(b=n.random(8)),v=s.create({keySize:y+g}).compute(v,b),g=n.create(v.words.slice(y),4*g),v.sigBytes=4*y,d.create({key:v,iv:g,salt:b})}},w=t.PasswordBasedCipher=p.extend({cfg:p.cfg.extend({kdf:h}),encrypt:function(v,y,g,b){return b=this.cfg.extend(b),g=b.kdf.execute(g,v.keySize,v.ivSize),b.iv=g.iv,v=p.encrypt.call(this,v,y,g.key,b),v.mixIn(g),v},decrypt:function(v,y,g,b){return b=this.cfg.extend(b),y=this._parse(y,b.format),g=b.kdf.execute(g,v.keySize,v.ivSize,y.salt),b.iv=g.iv,p.decrypt.call(this,v,y,g.key,b)}})}();(function(){for(var e=Se,t=e.lib.BlockCipher,U=e.algo,r=[],n=[],i=[],a=[],s=[],u=[],l=[],f=[],d=[],m=[],p=[],h=0;256>h;h++)p[h]=128>h?h<<1:h<<1^283;for(var w=0,v=0,h=0;256>h;h++){var y=v^v<<1^v<<2^v<<3^v<<4,y=y>>>8^y&255^99;r[w]=y,n[y]=w;var g=p[w],b=p[g],D=p[b],C=257*p[y]^16843008*y;i[w]=C<<24|C>>>8,a[w]=C<<16|C>>>16,s[w]=C<<8|C>>>24,u[w]=C,C=16843009*D^65537*b^257*g^16843008*w,l[y]=C<<24|C>>>8,f[y]=C<<16|C>>>16,d[y]=C<<8|C>>>24,m[y]=C,w?(w=g^p[p[p[D^g]]],v^=p[p[v]]):w=v=1}var F=[0,1,2,4,8,16,32,64,128,27,54],U=U.AES=t.extend({_doReset:function(){for(var B=this._key,L=B.words,S=B.sigBytes/4,B=4*((this._nRounds=S+6)+1),O=this._keySchedule=[],x=0;x>>24]<<24|r[j>>>16&255]<<16|r[j>>>8&255]<<8|r[j&255]):(j=j<<8|j>>>24,j=r[j>>>24]<<24|r[j>>>16&255]<<16|r[j>>>8&255]<<8|r[j&255],j^=F[x/S|0]<<24),O[x]=O[x-S]^j}for(L=this._invKeySchedule=[],S=0;SS||4>=x?j:l[r[j>>>24]]^f[r[j>>>16&255]]^d[r[j>>>8&255]]^m[r[j&255]]},encryptBlock:function(L,S){this._doCryptBlock(L,S,this._keySchedule,i,a,s,u,r)},decryptBlock:function(L,S){var B=L[S+1];L[S+1]=L[S+3],L[S+3]=B,this._doCryptBlock(L,S,this._invKeySchedule,l,f,d,m,n),B=L[S+1],L[S+1]=L[S+3],L[S+3]=B},_doCryptBlock:function(L,S,B,O,x,j,Y,M){for(var z=this._nRounds,tt=L[S]^B[0],lt=L[S+1]^B[1],ct=L[S+2]^B[2],rt=L[S+3]^B[3],W=4,ie=1;ie>>24]^x[lt>>>16&255]^j[ct>>>8&255]^Y[rt&255]^B[W++],Fe=O[lt>>>24]^x[ct>>>16&255]^j[rt>>>8&255]^Y[tt&255]^B[W++],xe=O[ct>>>24]^x[rt>>>16&255]^j[tt>>>8&255]^Y[lt&255]^B[W++],rt=O[rt>>>24]^x[tt>>>16&255]^j[lt>>>8&255]^Y[ct&255]^B[W++],tt=Ce,lt=Fe,ct=xe;Ce=(M[tt>>>24]<<24|M[lt>>>16&255]<<16|M[ct>>>8&255]<<8|M[rt&255])^B[W++],Fe=(M[lt>>>24]<<24|M[ct>>>16&255]<<16|M[rt>>>8&255]<<8|M[tt&255])^B[W++],xe=(M[ct>>>24]<<24|M[rt>>>16&255]<<16|M[tt>>>8&255]<<8|M[lt&255])^B[W++],rt=(M[rt>>>24]<<24|M[tt>>>16&255]<<16|M[lt>>>8&255]<<8|M[ct&255])^B[W++],L[S]=Ce,L[S+1]=Fe,L[S+2]=xe,L[S+3]=rt},keySize:8});e.AES=t._createHelper(U)})();(function(){function e(p,h){var w=(this._lBlock>>>p^this._rBlock)&h;this._rBlock^=w,this._lBlock^=w<>>p^this._lBlock)&h;this._lBlock^=w,this._rBlock^=w<w;w++){var v=s[w]-1;h[w]=p[v>>>5]>>>31-v%32&1}for(p=this._subKeys=[],v=0;16>v;v++){for(var y=p[v]=[],g=l[v],w=0;24>w;w++)y[w/6|0]|=h[(u[w]-1+g)%28]<<31-w%6,y[4+(w/6|0)]|=h[28+(u[w+24]-1+g)%28]<<31-w%6;for(y[0]=y[0]<<1|y[0]>>>31,w=1;7>w;w++)y[w]>>>=4*(w-1)+3;y[7]=y[7]<<5|y[7]>>>27}for(h=this._invSubKeys=[],w=0;16>w;w++)h[w]=p[15-w]},encryptBlock:function(p,h){this._doCryptBlock(p,h,this._subKeys)},decryptBlock:function(p,h){this._doCryptBlock(p,h,this._invSubKeys)},_doCryptBlock:function(p,h,w){this._lBlock=p[h],this._rBlock=p[h+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 v=0;16>v;v++){for(var y=w[v],g=this._lBlock,b=this._rBlock,D=0,C=0;8>C;C++)D|=f[C][((b^y[C])&d[C])>>>0];this._lBlock=b,this._rBlock=g^D}w=this._lBlock,this._lBlock=this._rBlock,this._rBlock=w,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[h]=this._lBlock,p[h+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});r.DES=i._createHelper(m),a=a.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,h){this._des1.encryptBlock(p,h),this._des2.decryptBlock(p,h),this._des3.encryptBlock(p,h)},decryptBlock:function(p,h){this._des3.decryptBlock(p,h),this._des2.encryptBlock(p,h),this._des1.decryptBlock(p,h)},keySize:6,ivSize:2,blockSize:2}),r.TripleDES=i._createHelper(a)})();(function(){var e=Se,t=e.lib.WordArray;e.enc.Base64={stringify:function(r){var n=r.words,i=r.sigBytes,a=this._map;r.clamp(),r=[];for(var s=0;s>>2]>>>24-8*(s%4)&255)<<16|(n[s+1>>>2]>>>24-8*((s+1)%4)&255)<<8|n[s+2>>>2]>>>24-8*((s+2)%4)&255,l=0;4>l&&s+.75*l>>6*(3-l)&63));if(n=a.charAt(64))for(;r.length%4;)r.push(n);return r.join("")},parse:function(r){var n=r.length,i=this._map,a=i.charAt(64);a&&(a=r.indexOf(a),a!=-1&&(n=a));for(var a=[],s=0,u=0;u>>6-2*(u%4);a[s>>>2]|=(l|f)<<24-8*(s%4),s++}return t.create(a,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}})();(function(e){function t(m,p,h,w,v,y,g){return m=m+(p&h|~p&w)+v+g,(m<>>32-y)+p}function r(m,p,h,w,v,y,g){return m=m+(p&w|h&~w)+v+g,(m<>>32-y)+p}function n(m,p,h,w,v,y,g){return m=m+(p^h^w)+v+g,(m<>>32-y)+p}function i(m,p,h,w,v,y,g){return m=m+(h^(p|~w))+v+g,(m<>>32-y)+p}for(var a=Se,l=a.lib,s=l.WordArray,u=l.Hasher,l=a.algo,f=[],d=0;64>d;d++)f[d]=4294967296*e.abs(e.sin(d+1))|0;l=l.MD5=u.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(m,p){for(var h=0;16>h;h++){var w=p+h,v=m[w];m[w]=(v<<8|v>>>24)&16711935|(v<<24|v>>>8)&4278255360}var h=this._hash.words,w=m[p+0],v=m[p+1],y=m[p+2],g=m[p+3],b=m[p+4],D=m[p+5],C=m[p+6],F=m[p+7],U=m[p+8],L=m[p+9],S=m[p+10],B=m[p+11],O=m[p+12],x=m[p+13],j=m[p+14],Y=m[p+15],M=h[0],ie=h[1],W=h[2],z=h[3],M=t(M,ie,W,z,w,7,f[0]),z=t(z,M,ie,W,v,12,f[1]),W=t(W,z,M,ie,y,17,f[2]),ie=t(ie,W,z,M,g,22,f[3]),M=t(M,ie,W,z,b,7,f[4]),z=t(z,M,ie,W,D,12,f[5]),W=t(W,z,M,ie,C,17,f[6]),ie=t(ie,W,z,M,F,22,f[7]),M=t(M,ie,W,z,U,7,f[8]),z=t(z,M,ie,W,L,12,f[9]),W=t(W,z,M,ie,S,17,f[10]),ie=t(ie,W,z,M,B,22,f[11]),M=t(M,ie,W,z,O,7,f[12]),z=t(z,M,ie,W,x,12,f[13]),W=t(W,z,M,ie,j,17,f[14]),ie=t(ie,W,z,M,Y,22,f[15]),M=r(M,ie,W,z,v,5,f[16]),z=r(z,M,ie,W,C,9,f[17]),W=r(W,z,M,ie,B,14,f[18]),ie=r(ie,W,z,M,w,20,f[19]),M=r(M,ie,W,z,D,5,f[20]),z=r(z,M,ie,W,S,9,f[21]),W=r(W,z,M,ie,Y,14,f[22]),ie=r(ie,W,z,M,b,20,f[23]),M=r(M,ie,W,z,L,5,f[24]),z=r(z,M,ie,W,j,9,f[25]),W=r(W,z,M,ie,g,14,f[26]),ie=r(ie,W,z,M,U,20,f[27]),M=r(M,ie,W,z,x,5,f[28]),z=r(z,M,ie,W,y,9,f[29]),W=r(W,z,M,ie,F,14,f[30]),ie=r(ie,W,z,M,O,20,f[31]),M=n(M,ie,W,z,D,4,f[32]),z=n(z,M,ie,W,U,11,f[33]),W=n(W,z,M,ie,B,16,f[34]),ie=n(ie,W,z,M,j,23,f[35]),M=n(M,ie,W,z,v,4,f[36]),z=n(z,M,ie,W,b,11,f[37]),W=n(W,z,M,ie,F,16,f[38]),ie=n(ie,W,z,M,S,23,f[39]),M=n(M,ie,W,z,x,4,f[40]),z=n(z,M,ie,W,w,11,f[41]),W=n(W,z,M,ie,g,16,f[42]),ie=n(ie,W,z,M,C,23,f[43]),M=n(M,ie,W,z,L,4,f[44]),z=n(z,M,ie,W,O,11,f[45]),W=n(W,z,M,ie,Y,16,f[46]),ie=n(ie,W,z,M,y,23,f[47]),M=i(M,ie,W,z,w,6,f[48]),z=i(z,M,ie,W,F,10,f[49]),W=i(W,z,M,ie,j,15,f[50]),ie=i(ie,W,z,M,D,21,f[51]),M=i(M,ie,W,z,O,6,f[52]),z=i(z,M,ie,W,g,10,f[53]),W=i(W,z,M,ie,S,15,f[54]),ie=i(ie,W,z,M,v,21,f[55]),M=i(M,ie,W,z,U,6,f[56]),z=i(z,M,ie,W,Y,10,f[57]),W=i(W,z,M,ie,C,15,f[58]),ie=i(ie,W,z,M,x,21,f[59]),M=i(M,ie,W,z,b,6,f[60]),z=i(z,M,ie,W,B,10,f[61]),W=i(W,z,M,ie,y,15,f[62]),ie=i(ie,W,z,M,L,21,f[63]);h[0]=h[0]+M|0,h[1]=h[1]+ie|0,h[2]=h[2]+W|0,h[3]=h[3]+z|0},_doFinalize:function(){var m=this._data,p=m.words,h=8*this._nDataBytes,w=8*m.sigBytes;p[w>>>5]|=128<<24-w%32;var v=e.floor(h/4294967296);for(p[(w+64>>>9<<4)+15]=(v<<8|v>>>24)&16711935|(v<<24|v>>>8)&4278255360,p[(w+64>>>9<<4)+14]=(h<<8|h>>>24)&16711935|(h<<24|h>>>8)&4278255360,m.sigBytes=4*(p.length+1),this._process(),m=this._hash,p=m.words,h=0;4>h;h++)w=p[h],p[h]=(w<<8|w>>>24)&16711935|(w<<24|w>>>8)&4278255360;return m},clone:function(){var m=u.clone.call(this);return m._hash=this._hash.clone(),m}}),a.MD5=u._createHelper(l),a.HmacMD5=u._createHmacHelper(l)})(Math);(function(){var e=Se,i=e.lib,t=i.WordArray,r=i.Hasher,n=[],i=e.algo.SHA1=r.extend({_doReset:function(){this._hash=new t.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(a,s){for(var u=this._hash.words,l=u[0],f=u[1],d=u[2],m=u[3],p=u[4],h=0;80>h;h++){if(16>h)n[h]=a[s+h]|0;else{var w=n[h-3]^n[h-8]^n[h-14]^n[h-16];n[h]=w<<1|w>>>31}w=(l<<5|l>>>27)+p+n[h],w=20>h?w+((f&d|~f&m)+1518500249):40>h?w+((f^d^m)+1859775393):60>h?w+((f&d|f&m|d&m)-1894007588):w+((f^d^m)-899497514),p=m,m=d,d=f<<30|f>>>2,f=l,l=w}u[0]=u[0]+l|0,u[1]=u[1]+f|0,u[2]=u[2]+d|0,u[3]=u[3]+m|0,u[4]=u[4]+p|0},_doFinalize:function(){var a=this._data,s=a.words,u=8*this._nDataBytes,l=8*a.sigBytes;return s[l>>>5]|=128<<24-l%32,s[(l+64>>>9<<4)+14]=Math.floor(u/4294967296),s[(l+64>>>9<<4)+15]=u,a.sigBytes=4*s.length,this._process(),this._hash},clone:function(){var a=r.clone.call(this);return a._hash=this._hash.clone(),a}});e.SHA1=r._createHelper(i),e.HmacSHA1=r._createHmacHelper(i)})();(function(e){for(var t=Se,h=t.lib,r=h.WordArray,n=h.Hasher,h=t.algo,i=[],a=[],s=function(v){return 4294967296*(v-(v|0))|0},u=2,l=0;64>l;){var f;e:{f=u;for(var d=e.sqrt(f),m=2;m<=d;m++)if(!(f%m)){f=!1;break e}f=!0}f&&(8>l&&(i[l]=s(e.pow(u,.5))),a[l]=s(e.pow(u,1/3)),l++),u++}var p=[],h=h.SHA256=n.extend({_doReset:function(){this._hash=new r.init(i.slice(0))},_doProcessBlock:function(w,v){for(var y=this._hash.words,g=y[0],b=y[1],D=y[2],C=y[3],F=y[4],U=y[5],L=y[6],S=y[7],B=0;64>B;B++){if(16>B)p[B]=w[v+B]|0;else{var O=p[B-15],x=p[B-2];p[B]=((O<<25|O>>>7)^(O<<14|O>>>18)^O>>>3)+p[B-7]+((x<<15|x>>>17)^(x<<13|x>>>19)^x>>>10)+p[B-16]}O=S+((F<<26|F>>>6)^(F<<21|F>>>11)^(F<<7|F>>>25))+(F&U^~F&L)+a[B]+p[B],x=((g<<30|g>>>2)^(g<<19|g>>>13)^(g<<10|g>>>22))+(g&b^g&D^b&D),S=L,L=U,U=F,F=C+O|0,C=D,D=b,b=g,g=O+x|0}y[0]=y[0]+g|0,y[1]=y[1]+b|0,y[2]=y[2]+D|0,y[3]=y[3]+C|0,y[4]=y[4]+F|0,y[5]=y[5]+U|0,y[6]=y[6]+L|0,y[7]=y[7]+S|0},_doFinalize:function(){var w=this._data,v=w.words,y=8*this._nDataBytes,g=8*w.sigBytes;return v[g>>>5]|=128<<24-g%32,v[(g+64>>>9<<4)+14]=e.floor(y/4294967296),v[(g+64>>>9<<4)+15]=y,w.sigBytes=4*v.length,this._process(),this._hash},clone:function(){var w=n.clone.call(this);return w._hash=this._hash.clone(),w}});t.SHA256=n._createHelper(h),t.HmacSHA256=n._createHmacHelper(h)})(Math);(function(){var e=Se,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=Se,r=t.lib.Hasher,a=t.x64,n=a.Word,i=a.WordArray,a=t.algo,s=[e(1116352408,3609767458),e(1899447441,602891725),e(3049323471,3964484399),e(3921009573,2173295548),e(961987163,4081628472),e(1508970993,3053834265),e(2453635748,2937671579),e(2870763221,3664609560),e(3624381080,2734883394),e(310598401,1164996542),e(607225278,1323610764),e(1426881987,3590304994),e(1925078388,4068182383),e(2162078206,991336113),e(2614888103,633803317),e(3248222580,3479774868),e(3835390401,2666613458),e(4022224774,944711139),e(264347078,2341262773),e(604807628,2007800933),e(770255983,1495990901),e(1249150122,1856431235),e(1555081692,3175218132),e(1996064986,2198950837),e(2554220882,3999719339),e(2821834349,766784016),e(2952996808,2566594879),e(3210313671,3203337956),e(3336571891,1034457026),e(3584528711,2466948901),e(113926993,3758326383),e(338241895,168717936),e(666307205,1188179964),e(773529912,1546045734),e(1294757372,1522805485),e(1396182291,2643833823),e(1695183700,2343527390),e(1986661051,1014477480),e(2177026350,1206759142),e(2456956037,344077627),e(2730485921,1290863460),e(2820302411,3158454273),e(3259730800,3505952657),e(3345764771,106217008),e(3516065817,3606008344),e(3600352804,1432725776),e(4094571909,1467031594),e(275423344,851169720),e(430227734,3100823752),e(506948616,1363258195),e(659060556,3750685593),e(883997877,3785050280),e(958139571,3318307427),e(1322822218,3812723403),e(1537002063,2003034995),e(1747873779,3602036899),e(1955562222,1575990012),e(2024104815,1125592928),e(2227730452,2716904306),e(2361852424,442776044),e(2428436474,593698344),e(2756734187,3733110249),e(3204031479,2999351573),e(3329325298,3815920427),e(3391569614,3928383900),e(3515267271,566280711),e(3940187606,3454069534),e(4118630271,4000239992),e(116418474,1914138554),e(174292421,2731055270),e(289380356,3203993006),e(460393269,320620315),e(685471733,587496836),e(852142971,1086792851),e(1017036298,365543100),e(1126000580,2618297676),e(1288033470,3409855158),e(1501505948,4234509866),e(1607167915,987167468),e(1816402316,1246189591)],u=[],l=0;80>l;l++)u[l]=e();a=a.SHA512=r.extend({_doReset:function(){this._hash=new i.init([new n.init(1779033703,4089235720),new n.init(3144134277,2227873595),new n.init(1013904242,4271175723),new n.init(2773480762,1595750129),new n.init(1359893119,2917565137),new n.init(2600822924,725511199),new n.init(528734635,4215389547),new n.init(1541459225,327033209)])},_doProcessBlock:function(f,d){for(var b=this._hash.words,m=b[0],p=b[1],h=b[2],w=b[3],v=b[4],y=b[5],g=b[6],b=b[7],D=m.high,C=m.low,F=p.high,U=p.low,L=h.high,S=h.low,B=w.high,O=w.low,x=v.high,j=v.low,Y=y.high,M=y.low,z=g.high,W=g.low,ie=b.high,Ce=b.low,Fe=D,xe=C,rt=F,tt=U,lt=L,ct=S,fn=B,ur=O,_t=x,Cr=j,lr=Y,ht=M,Wt=z,nt=W,Ke=ie,cr=Ce,Ue=0;80>Ue;Ue++){var Dr=u[Ue];if(16>Ue)var kt=Dr.high=f[d+2*Ue]|0,De=Dr.low=f[d+2*Ue+1]|0;else{var kt=u[Ue-15],De=kt.high,vt=kt.low,kt=(De>>>1|vt<<31)^(De>>>8|vt<<24)^De>>>7,vt=(vt>>>1|De<<31)^(vt>>>8|De<<24)^(vt>>>7|De<<25),Lr=u[Ue-2],De=Lr.high,Dt=Lr.low,Lr=(De>>>19|Dt<<13)^(De<<3|Dt>>>29)^De>>>6,Dt=(Dt>>>19|De<<13)^(Dt<<3|De>>>29)^(Dt>>>6|De<<26),De=u[Ue-7],hn=De.high,nr=u[Ue-16],Ne=nr.high,nr=nr.low,De=vt+De.low,kt=kt+hn+(De>>>0>>0?1:0),De=De+Dt,kt=kt+Lr+(De>>>0
>>0?1:0),De=De+nr,kt=kt+Ne+(De>>>0>>0?1:0);Dr.high=kt,Dr.low=De}var hn=_t&lr^~_t&Wt,nr=Cr&ht^~Cr&nt,Dr=Fe&rt^Fe<^rt<,Xt=xe&tt^xe&ct^tt&ct,vt=(Fe>>>28|xe<<4)^(Fe<<30|xe>>>2)^(Fe<<25|xe>>>7),Lr=(xe>>>28|Fe<<4)^(xe<<30|Fe>>>2)^(xe<<25|Fe>>>7),Dt=s[Ue],xi=Dt.high,dn=Dt.low,Dt=cr+((Cr>>>14|_t<<18)^(Cr>>>18|_t<<14)^(Cr<<23|_t>>>9)),Ne=Ke+((_t>>>14|Cr<<18)^(_t>>>18|Cr<<14)^(_t<<23|Cr>>>9))+(Dt>>>0>>0?1:0),Dt=Dt+nr,Ne=Ne+hn+(Dt>>>0>>0?1:0),Dt=Dt+dn,Ne=Ne+xi+(Dt>>>0>>0?1:0),Dt=Dt+De,Ne=Ne+kt+(Dt>>>0>>0?1:0),De=Lr+Xt,Dr=vt+Dr+(De>>>0>>0?1:0),Ke=Wt,cr=nt,Wt=lr,nt=ht,lr=_t,ht=Cr,Cr=ur+Dt|0,_t=fn+Ne+(Cr>>>0>>0?1:0)|0,fn=lt,ur=ct,lt=rt,ct=tt,rt=Fe,tt=xe,xe=Dt+De|0,Fe=Ne+Dr+(xe>>>0
>>0?1:0)|0}C=m.low=C+xe,m.high=D+Fe+(C>>>0>>0?1:0),U=p.low=U+tt,p.high=F+rt+(U>>>0>>0?1:0),S=h.low=S+ct,h.high=L+lt+(S>>>0>>0?1:0),O=w.low=O+ur,w.high=B+fn+(O>>>0>>0?1:0),j=v.low=j+Cr,v.high=x+_t+(j>>>0>>0?1:0),M=y.low=M+ht,y.high=Y+lr+(M>>>0>>0?1:0),W=g.low=W+nt,g.high=z+Wt+(W>>>0>>0?1:0),Ce=b.low=Ce+cr,b.high=ie+Ke+(Ce>>>0>>0?1:0)},_doFinalize:function(){var f=this._data,d=f.words,m=8*this._nDataBytes,p=8*f.sigBytes;return d[p>>>5]|=128<<24-p%32,d[(p+128>>>10<<5)+30]=Math.floor(m/4294967296),d[(p+128>>>10<<5)+31]=m,f.sigBytes=4*d.length,this._process(),this._hash.toX32()},clone:function(){var f=r.clone.call(this);return f._hash=this._hash.clone(),f},blockSize:32}),t.SHA512=r._createHelper(a),t.HmacSHA512=r._createHmacHelper(a)})();(function(){var e=Se,i=e.x64,t=i.Word,r=i.WordArray,i=e.algo,n=i.SHA512,i=i.SHA384=n.extend({_doReset:function(){this._hash=new r.init([new t.init(3418070365,3238371032),new t.init(1654270250,914150663),new t.init(2438529370,812702999),new t.init(355462360,4144912697),new t.init(1731405415,4290775857),new t.init(2394180231,1750603025),new t.init(3675008525,1694076839),new t.init(1203062813,3204075428)])},_doFinalize:function(){var a=n._doFinalize.call(this);return a.sigBytes-=16,a}});e.SHA384=n._createHelper(i),e.HmacSHA384=n._createHmacHelper(i)})();(function(){var e=Se,f=e.lib,t=f.WordArray,r=f.Hasher,f=e.algo,n=t.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),i=t.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),a=t.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),s=t.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),u=t.create([0,1518500249,1859775393,2400959708,2840853838]),l=t.create([1352829926,1548603684,1836072691,2053994217,0]),f=f.RIPEMD160=r.extend({_doReset:function(){this._hash=t.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(d,m){for(var p=0;16>p;p++){var h=m+p,w=d[h];d[h]=(w<<8|w>>>24)&16711935|(w<<24|w>>>8)&4278255360}var h=this._hash.words,w=u.words,v=l.words,y=n.words,g=i.words,b=a.words,D=s.words,C,F,U,L,S,B,O,x,j,Y;B=C=h[0],O=F=h[1],x=U=h[2],j=L=h[3],Y=S=h[4];for(var M,p=0;80>p;p+=1)M=C+d[m+y[p]]|0,M=16>p?M+((F^U^L)+w[0]):32>p?M+((F&U|~F&L)+w[1]):48>p?M+(((F|~U)^L)+w[2]):64>p?M+((F&L|U&~L)+w[3]):M+((F^(U|~L))+w[4]),M|=0,M=M<>>32-b[p],M=M+S|0,C=S,S=L,L=U<<10|U>>>22,U=F,F=M,M=B+d[m+g[p]]|0,M=16>p?M+((O^(x|~j))+v[0]):32>p?M+((O&j|x&~j)+v[1]):48>p?M+(((O|~x)^j)+v[2]):64>p?M+((O&x|~O&j)+v[3]):M+((O^x^j)+v[4]),M|=0,M=M<>>32-D[p],M=M+Y|0,B=Y,Y=j,j=x<<10|x>>>22,x=O,O=M;M=h[1]+U+j|0,h[1]=h[2]+L+Y|0,h[2]=h[3]+S+B|0,h[3]=h[4]+C+O|0,h[4]=h[0]+F+x|0,h[0]=M},_doFinalize:function(){var d=this._data,m=d.words,p=8*this._nDataBytes,h=8*d.sigBytes;for(m[h>>>5]|=128<<24-h%32,m[(h+64>>>9<<4)+14]=(p<<8|p>>>24)&16711935|(p<<24|p>>>8)&4278255360,d.sigBytes=4*(m.length+1),this._process(),d=this._hash,m=d.words,p=0;5>p;p++)h=m[p],m[p]=(h<<8|h>>>24)&16711935|(h<<24|h>>>8)&4278255360;return d},clone:function(){var d=r.clone.call(this);return d._hash=this._hash.clone(),d}});e.RIPEMD160=r._createHelper(f),e.HmacRIPEMD160=r._createHmacHelper(f)})(Math);(function(){var e=Se,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(r,n){r=this._hasher=new r.init,typeof n=="string"&&(n=t.parse(n));var i=r.blockSize,a=4*i;n.sigBytes>a&&(n=r.finalize(n)),n.clamp();for(var s=this._oKey=n.clone(),u=this._iKey=n.clone(),l=s.words,f=u.words,d=0;d>6)+ac.charAt(r&63);if(t+1==e.length?(r=parseInt(e.substring(t,t+1),16),n+=ac.charAt(r<<2)):t+2==e.length&&(r=parseInt(e.substring(t,t+2),16),n+=ac.charAt(r>>2)+ac.charAt((r&3)<<4)),Jg)for(;(n.length&3)>0;)n+=Jg;return n}function oc(e){var t="",r,n=0,i,a;for(r=0;r>2),i=a&3,n=1):n==1?(t+=tu(i<<2|a>>4),i=a&15,n=2):n==2?(t+=tu(i),t+=tu(a>>2),i=a&3,n=3):(t+=tu(i<<2|a>>4),t+=tu(a&15),n=0));return n==1&&(t+=tu(i<<2)),t}function Xy(e){var t=oc(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 pR(e,t,r,n,i,a){for(var s=t&32767,u=t>>15;--a>=0;){var l=this[e]&32767,f=this[e++]>>15,d=u*l+f*s;l=s*l+((d&32767)<<15)+r[n]+(i&1073741823),i=(l>>>30)+(d>>>15)+u*f+(i>>>30),r[n++]=l&1073741823}return i}function gR(e,t,r,n,i,a){for(var s=t&16383,u=t>>14;--a>=0;){var l=this[e]&16383,f=this[e++]>>14,d=u*l+f*s;l=s*l+((d&16383)<<14)+r[n]+i,i=(l>>28)+(d>>14)+u*f,r[n++]=l&268435455}return i}Gy&&Pf.appName=="Microsoft Internet Explorer"?(ee.prototype.am=pR,Yu=30):Gy&&Pf.appName!="Netscape"?(ee.prototype.am=dR,Yu=26):(ee.prototype.am=gR,Yu=28);ee.prototype.DB=Yu;ee.prototype.DM=(1<=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s}function wR(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 Gu(e){var t=It();return t.fromInt(e),t}function AR(e,t){var r;if(t==16)r=4;else if(t==8)r=3;else if(t==256)r=8;else if(t==2)r=1;else if(t==32)r=5;else if(t==4)r=2;else{this.fromRadix(e,t);return}this.t=0,this.s=0;for(var n=e.length,i=!1,a=0;--n>=0;){var s=r==8?e[n]&255:Jy(e,n);if(s<0){e.charAt(n)=="-"&&(i=!0);continue}i=!1,a==0?this[this.t++]=s:a+r>this.DB?(this[this.t-1]|=(s&(1<>this.DB-a):this[this.t-1]|=s<=this.DB&&(a-=this.DB)}r==8&&e[0]&128&&(this.s=-1,a>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==e;)--this.t}function bR(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(u>u)>0&&(i=!0,a=tu(n));s>=0;)u>(u+=this.DB-t)):(n=this[s]>>(u-=t)&r,u<=0&&(u+=this.DB,--s)),n>0&&(i=!0),i&&(a+=tu(n));return i?a:"0"}function yR(){var e=It();return ee.ZERO.subTo(this,e),e}function _R(){return this.s<0?this.negate():this}function CR(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 bd(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 DR(){return this.t<=0?0:this.DB*(this.t-1)+bd(this[this.t-1]^this.s&this.DM)}function FR(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 SR(e,t){for(var r=e;r=0;--u)t[u+a+1]=this[u]>>n|s,s=(this[u]&i)<=0;--u)t[u]=0;t[a]=s,t.t=this.t+a+1,t.s=this.s,t.clamp()}function BR(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t){t.t=0;return}var n=e%this.DB,i=this.DB-n,a=(1<>n;for(var s=r+1;s>n;n>0&&(t[this.t-r-1]|=(this.s&a)<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t[r++]=this.DV+n:n>0&&(t[r++]=n),t.t=r,t.clamp()}function PR(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 RR(e,t,r){var n=e.abs();if(!(n.t<=0)){var i=this.abs();if(i.t0?(n.lShiftTo(l,a),i.lShiftTo(l,r)):(n.copyTo(a),i.copyTo(r));var f=a.t,d=a[f-1];if(d!=0){var m=d*(1<1?a[f-2]>>this.F2:0),p=this.FV/m,h=(1<=0&&(r[r.t++]=1,r.subTo(g,r)),ee.ONE.dlShiftTo(f,g),g.subTo(a,a);a.t=0;){var b=r[--v]==d?this.DM:Math.floor(r[v]*p+(r[v-1]+w)*h);if((r[v]+=a.am(0,b,r,y,0,f))0&&r.rShiftTo(l,r),s<0&&ee.ZERO.subTo(r,r)}}}function TR(e){var t=It();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(ee.ZERO)>0&&e.subTo(t,t),t}function Xo(e){this.m=e}function OR(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e}function kR(e){return e}function NR(e){e.divRemTo(this.m,null,e)}function LR(e,t,r){e.multiplyTo(t,r),this.reduce(r)}function UR(e,t){e.squareTo(t),this.reduce(t)}Xo.prototype.convert=OR;Xo.prototype.revert=kR;Xo.prototype.reduce=NR;Xo.prototype.mulTo=LR;Xo.prototype.sqrTo=UR;function jR(){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 Jo(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 MR(e){var t=It();return e.copyTo(t),this.reduce(t),t}function qR(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 VR(e,t){e.squareTo(t),this.reduce(t)}function KR(e,t,r){e.multiplyTo(t,r),this.reduce(r)}Jo.prototype.convert=HR;Jo.prototype.revert=MR;Jo.prototype.reduce=qR;Jo.prototype.mulTo=KR;Jo.prototype.sqrTo=VR;function zR(){return(this.t>0?this[0]&1:this.s)==0}function GR(e,t){if(e>4294967295||e<1)return ee.ONE;var r=It(),n=It(),i=t.convert(this),a=bd(e)-1;for(i.copyTo(r);--a>=0;)if(t.sqrTo(r,n),(e&1<0)t.mulTo(n,i,r);else{var s=r;r=n,n=s}return t.revert(r)}function YR(e,t){var r;return e<256||t.isEven()?r=new Xo(t):r=new Jo(t),this.exp(e,r)}ee.prototype.copyTo=vR;ee.prototype.fromInt=wR;ee.prototype.fromString=AR;ee.prototype.clamp=ER;ee.prototype.dlShiftTo=FR;ee.prototype.drShiftTo=SR;ee.prototype.lShiftTo=IR;ee.prototype.rShiftTo=BR;ee.prototype.subTo=$R;ee.prototype.multiplyTo=PR;ee.prototype.squareTo=xR;ee.prototype.divRemTo=RR;ee.prototype.invDigit=jR;ee.prototype.isEven=zR;ee.prototype.exp=GR;ee.prototype.toString=bR;ee.prototype.negate=yR;ee.prototype.abs=_R;ee.prototype.compareTo=CR;ee.prototype.bitLength=DR;ee.prototype.mod=TR;ee.prototype.modPowInt=YR;ee.ZERO=Gu(0);ee.ONE=Gu(1);function WR(){var e=It();return this.copyTo(e),e}function XR(){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 ZR(){return this.t==0?this.s:this[0]<<16>>16}function QR(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}function eT(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function tT(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=Gu(r),i=It(),a=It(),s="";for(this.divRemTo(n,i,a);i.signum()>0;)s=(r+a.intValue()).toString(e).substr(1)+s,i.divRemTo(n,i,a);return a.intValue().toString(e)+s}function rT(e,t){this.fromInt(0),t==null&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),i=!1,a=0,s=0,u=0;u=r&&(this.dMultiply(n),this.dAddOffset(s,0),a=0,s=0)}a>0&&(this.dMultiply(Math.pow(t,a)),this.dAddOffset(s,0)),i&&ee.ZERO.subTo(this,this)}function nT(e,t,r){if(typeof t=="number")if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(ee.ONE.shiftLeft(e-1),nm,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(ee.ONE.shiftLeft(e-1),this);else{var n=new Array,i=e&7;n.length=(e>>3)+1,t.nextBytes(n),i>0?n[0]&=(1<0)for(r>r)!=(this.s&this.DM)>>r&&(t[i++]=n|this.s<=0;)r<8?(n=(this[e]&(1<>(r+=this.DB-8)):(n=this[e]>>(r-=8)&255,r<=0&&(r+=this.DB,--e)),n&128&&(n|=-256),i==0&&(this.s&128)!=(n&128)&&++i,(i>0||n!=this.s)&&(t[i++]=n);return t}function sT(e){return this.compareTo(e)==0}function aT(e){return this.compareTo(e)<0?this:e}function uT(e){return this.compareTo(e)>0?this:e}function oT(e,t,r){var n,i,a=Math.min(e.t,this.t);for(n=0;n>=16,t+=16),e&255||(e>>=8,t+=8),e&15||(e>>=4,t+=4),e&3||(e>>=2,t+=2),e&1||++t,t}function wT(){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 ST(e){var t=It();return this.addTo(e,t),t}function IT(e){var t=It();return this.subTo(e,t),t}function BT(e){var t=It();return this.multiplyTo(e,t),t}function $T(){var e=It();return this.squareTo(e),e}function PT(e){var t=It();return this.divRemTo(e,t,null),t}function xT(e){var t=It();return this.divRemTo(e,null,t),t}function RT(e){var t=It(),r=It();return this.divRemTo(e,t,r),new Array(t,r)}function TT(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}function OT(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 Rf(){}function e_(e){return e}function kT(e,t,r){e.multiplyTo(t,r)}function NT(e,t){e.squareTo(t)}Rf.prototype.convert=e_;Rf.prototype.revert=e_;Rf.prototype.mulTo=kT;Rf.prototype.sqrTo=NT;function LT(e){return this.exp(e,new Rf)}function UT(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=It();return e.copyTo(t),this.reduce(t),t}function MT(e){return e}function qT(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 VT(e,t){e.squareTo(t),this.reduce(t)}function KT(e,t,r){e.multiplyTo(t,r),this.reduce(r)}cc.prototype.convert=HT;cc.prototype.revert=MT;cc.prototype.reduce=qT;cc.prototype.mulTo=KT;cc.prototype.sqrTo=VT;function zT(e,t){var r=e.bitLength(),n,i=Gu(1),a;if(r<=0)return i;r<18?n=1:r<48?n=3:r<144?n=4:r<768?n=5:n=6,r<8?a=new Xo(t):t.isEven()?a=new cc(t):a=new Jo(t);var s=new Array,u=3,l=n-1,f=(1<1){var d=It();for(a.sqrTo(s[1],d);u<=f;)s[u]=It(),a.mulTo(d,s[u-2],s[u]),u+=2}var m=e.t-1,p,h=!0,w=It(),v;for(r=bd(e[m])-1;m>=0;){for(r>=l?p=e[m]>>r-l&f:(p=(e[m]&(1<0&&(p|=e[m-1]>>this.DB+r-l)),u=n;!(p&1);)p>>=1,--u;if((r-=u)<0&&(r+=this.DB,--m),h)s[p].copyTo(i),h=!1;else{for(;u>1;)a.sqrTo(i,w),a.sqrTo(w,i),u-=2;u>0?a.sqrTo(i,w):(v=i,i=w,w=v),a.mulTo(w,s[p],i)}for(;m>=0&&!(e[m]&1<0&&(t.rShiftTo(a,t),r.rShiftTo(a,r));t.signum()>0;)(i=t.getLowestSetBit())>0&&t.rShiftTo(i,t),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return a>0&&r.lShiftTo(a,r),r}function YT(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 WT(e){var t=e.isEven();if(this.isEven()&&t||e.signum()==0)return ee.ZERO;for(var r=e.clone(),n=this.clone(),i=Gu(1),a=Gu(0),s=Gu(0),u=Gu(1);r.signum()!=0;){for(;r.isEven();)r.rShiftTo(1,r),t?((!i.isEven()||!a.isEven())&&(i.addTo(this,i),a.subTo(e,a)),i.rShiftTo(1,i)):a.isEven()||a.subTo(e,a),a.rShiftTo(1,a);for(;n.isEven();)n.rShiftTo(1,n),t?((!s.isEven()||!u.isEven())&&(s.addTo(this,s),u.subTo(e,u)),s.rShiftTo(1,s)):u.isEven()||u.subTo(e,u),u.rShiftTo(1,u);r.compareTo(n)>=0?(r.subTo(n,r),t&&i.subTo(s,i),a.subTo(u,a)):(n.subTo(r,n),t&&s.subTo(i,s),u.subTo(a,u))}if(n.compareTo(ee.ONE)!=0)return ee.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 ni=[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],XT=(1<<26)/ni[ni.length-1];function JT(e){var t,r=this.abs();if(r.t==1&&r[0]<=ni[ni.length-1]){for(t=0;t>1,e>ni.length&&(e=ni.length);for(var i=It(),a=0;a>8&255,qi[ln++]^=e>>16&255,qi[ln++]^=e>>24&255,ln>=Zg&&(ln-=Zg)}function sm(){rO(new Date().getTime())}if(qi==null){if(qi=new Array,ln=0,sc!==void 0&&(sc.crypto!==void 0||sc.msCrypto!==void 0)){if(Yg=sc.crypto||sc.msCrypto,Yg.getRandomValues)for(Wg=new Uint8Array(32),Yg.getRandomValues(Wg),ds=0;ds<32;++ds)qi[ln++]=Wg[ds];else if(Pf.appName=="Netscape"&&Pf.appVersion<"5")for(Xg=sc.crypto.random(32),ds=0;ds>>8,qi[ln++]=ds&255;ln=0,sm()}var ds,Yg,Wg,Xg;function nO(){if(md==null){for(sm(),md=tO(),md.init(qi),ln=0;ln0&&t.length>0)this.n=_i(e,16),this.e=parseInt(t,16);else throw"Invalid RSA public key"}function aO(e){return e.modPowInt(this.e,this.n)}et.prototype.doPublic=aO;et.prototype.setPublic=sO;et.prototype.type="RSA";function uO(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=_i(e,16),this.e=parseInt(t,16),this.d=_i(r,16);else throw"Invalid RSA private key"}function oO(e,t,r,n,i,a,s,u){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=_i(e,16),this.e=parseInt(t,16),this.d=_i(r,16),this.p=_i(n,16),this.q=_i(i,16),this.dmp1=_i(a,16),this.dmq1=_i(s,16),this.coeff=_i(u,16);else throw"Invalid RSA private key in RSASetPrivateEx"}function lO(e,t){var r=new fc,n=e>>1;this.e=parseInt(t,16);for(var i=new ee(t,16),a=e/2-100,s=ee.ONE.shiftLeft(a);;){for(;this.p=new ee(e-n,1,r),!(this.p.subtract(ee.ONE).gcd(i).compareTo(ee.ONE)==0&&this.p.isProbablePrime(10)););for(;this.q=new ee(n,1,r),!(this.q.subtract(ee.ONE).gcd(i).compareTo(ee.ONE)==0&&this.q.isProbablePrime(10)););if(this.p.compareTo(this.q)<=0){var u=this.p;this.p=this.q,this.q=u}var l=this.q.subtract(this.p).abs();if(!(l.bitLength()0;--f){i=i.twice();var d=r.testBit(f),m=t.testBit(f);d!=m&&(i=i.add(d?this:n))}for(f=s.bitLength()-2;f>0;--f){u=u.twice();var p=s.testBit(f),h=a.testBit(f);p!=h&&(u=u.add(p?u:l))}return i}function SO(e,t,r){var n;e.bitLength()>r.bitLength()?n=e.bitLength()-1:n=r.bitLength()-1;for(var i=this.curve.getInfinity(),a=this.add(t);n>=0;)i=i.twice(),e.testBit(n)?r.testBit(n)?i=i.add(a):i=i.add(this):r.testBit(n)&&(i=i.add(t)),--n;return i}Lt.prototype.getX=AO;Lt.prototype.getY=EO;Lt.prototype.equals=bO;Lt.prototype.isInfinity=yO;Lt.prototype.negate=_O;Lt.prototype.add=CO;Lt.prototype.twice=DO;Lt.prototype.multiply=FO;Lt.prototype.multiplyTwo=SO;function nu(e,t,r){this.q=e,this.a=this.fromBigInteger(t),this.b=this.fromBigInteger(r),this.infinity=new Lt(this,null,null)}function IO(){return this.q}function BO(){return this.a}function $O(){return this.b}function PO(e){return e==this?!0:this.q.equals(e.q)&&this.a.equals(e.a)&&this.b.equals(e.b)}function xO(){return this.infinity}function RO(e){return new Qr(this.q,e)}function TO(e){switch(parseInt(e.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:var t=e.substr(0,2),r=e.substr(2),n=this.fromBigInteger(new ee(f,16)),i=this.getA(),a=this.getB(),s=n.square().add(i).multiply(n).add(a),u=s.sqrt();return t=="03"&&(u=u.negate()),new Lt(this,n,u);case 4:case 6:case 7:var l=(e.length-2)/2,f=e.substr(2,l),d=e.substr(l+2,l);return new Lt(this,this.fromBigInteger(new ee(f,16)),this.fromBigInteger(new ee(d,16)));default:return null}}nu.prototype.getQ=IO;nu.prototype.getA=BO;nu.prototype.getB=$O;nu.prototype.equals=PO;nu.prototype.getInfinity=xO;nu.prototype.fromBigInteger=RO;nu.prototype.decodePointHex=TO;Qr.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)};Lt.prototype.getEncoded=function(e){var t=function(a,s){var u=a.toByteArrayUnsigned();if(su.length;)u.unshift(0);return u},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};Lt.decodeFrom=function(e,t){var r=t[0],n=t.length-1,i=t.slice(1,1+n/2),a=t.slice(1+n/2,1+n);i.unshift(0),a.unshift(0);var s=new ee(i),u=new ee(a);return new Lt(e,e.fromBigInteger(s),e.fromBigInteger(u))};Lt.decodeFromHex=function(e,t){var r=t.substr(0,2),n=t.length-2,i=t.substr(2,n/2),a=t.substr(2+n/2,n/2),s=new ee(i,16),u=new ee(a,16);return new Lt(e,e.fromBigInteger(s),e.fromBigInteger(u))};Lt.prototype.add2D=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;if(this.x.equals(e.x))return this.y.equals(e.y)?this.twice():this.curve.getInfinity();var t=e.x.subtract(this.x),r=e.y.subtract(this.y),n=r.divide(t),i=n.square().subtract(this.x).subtract(e.x),a=n.multiply(this.x.subtract(i)).subtract(this.y);return new Lt(this.curve,i,a)};Lt.prototype.twice2D=function(){if(this.isInfinity())return this;if(this.y.toBigInteger().signum()==0)return this.curve.getInfinity();var e=this.curve.fromBigInteger(ee.valueOf(2)),t=this.curve.fromBigInteger(ee.valueOf(3)),r=this.x.square().multiply(t).add(this.curve.a).divide(this.y.multiply(e)),n=r.square().subtract(this.x.multiply(e)),i=r.multiply(this.x.subtract(n)).subtract(this.y);return new Lt(this.curve,n,i)};Lt.prototype.multiply2D=function(e){if(this.isInfinity())return this;if(e.signum()==0)return this.curve.getInfinity();var t=e,r=t.multiply(new ee("3")),n=this.negate(),i=this,a;for(a=r.bitLength()-2;a>0;--a){i=i.twice();var s=r.testBit(a),u=t.testBit(a);s!=u&&(i=i.add2D(s?this:n))}return i};Lt.prototype.isOnCurve=function(){var e=this.getX().toBigInteger(),t=this.getY().toBigInteger(),r=this.curve.getA().toBigInteger(),n=this.curve.getB().toBigInteger(),i=this.curve.getQ(),a=t.multiply(t).mod(i),s=e.multiply(e).multiply(e).add(r.multiply(e)).add(n).mod(i);return a.equals(s)};Lt.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"};Lt.prototype.validate=function(){var e=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var t=this.getX().toBigInteger(),r=this.getY().toBigInteger();if(t.compareTo(ee.ONE)<0||t.compareTo(e.subtract(ee.ONE))>0)throw new Error("x coordinate out of bounds");if(r.compareTo(ee.ONE)<0||r.compareTo(e.subtract(ee.ONE))>0)throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(e).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0};var t_=function(){var e="(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)",t='(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))',r='(?:"'+t+'*")',n=new RegExp("(?:false|true|null|[\\{\\}\\[\\]]|"+e+"|"+r+")","g"),i=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),a={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:` `,r:"\r",t:" "};function s(m,p,h){return p?a[p]:String.fromCharCode(parseInt(h,16))}var u=new String(""),l="\\",f={"{":Object,"[":Array},d=Object.hasOwnProperty;return function(m,p){var h=m.match(n),w,v=h[0],y=!1;v==="{"?w={}:v==="["?w=[]:(w=[],y=!0);for(var g,b=[w],D=1-y,C=h.length;D=0;)delete B[O[Y]]}return p.call(L,S,B)};w=U({"":w},"")}return w}}();(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 Of(e)},this.getPEMStringFromHex=function(e,t){return Mn(e,t)},this.newObject=function(e){var t=A,r=t.asn1,n=r.ASN1Object,i=r.DERBoolean,a=r.DERInteger,s=r.DERBitString,u=r.DEROctetString,l=r.DERNull,f=r.DERObjectIdentifier,d=r.DEREnumerated,m=r.DERUTF8String,p=r.DERNumericString,h=r.DERPrintableString,w=r.DERTeletexString,v=r.DERIA5String,y=r.DERUTCTime,g=r.DERGeneralizedTime,b=r.DERVisibleString,D=r.DERBMPString,C=r.DERSequence,F=r.DERSet,U=r.DERTaggedObject,L=r.ASN1Util.newObject;if(e instanceof r.ASN1Object)return e;var S=Object.keys(e);if(S.length!=1)throw new Error("key of param shall be only one.");var B=S[0];if(":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+B+":")==-1)throw new Error("undefined key: "+B);if(B=="bool")return new i(e[B]);if(B=="int")return new a(e[B]);if(B=="bitstr")return new s(e[B]);if(B=="octstr")return new u(e[B]);if(B=="null")return new l(e[B]);if(B=="oid")return new f(e[B]);if(B=="enum")return new d(e[B]);if(B=="utf8str")return new m(e[B]);if(B=="numstr")return new p(e[B]);if(B=="prnstr")return new h(e[B]);if(B=="telstr")return new w(e[B]);if(B=="ia5str")return new v(e[B]);if(B=="utctime")return new y(e[B]);if(B=="gentime")return new g(e[B]);if(B=="visstr")return new b(e[B]);if(B=="bmpstr")return new D(e[B]);if(B=="asn1")return new n(e[B]);if(B=="seq"){for(var O=e[B],x=[],j=0;j"u"||this.hV==null)throw new Error("this.hV is null or undefined");if(this.hV.length%2==1)throw new Error("value hex must be even length: n="+a.length+",v="+this.hV);var s=this.hV.length/2,u=s.toString(16);if(u.length%2==1&&(u="0"+u),s<128)return u;var l=u.length/2;if(l>15)throw new Error("ASN.1 length too long to represent by 8x: n = "+s.toString(16));var f=128+l;return f.toString(16)+u},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=_d(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))};pe(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,a=new Date(i);return a},this.formatDate=function(n,i,a){var s=this.zeroPadding,u=this.localDateToUTC(n),l=String(u.getFullYear());i=="utc"&&(l=l.substr(2,2));var f=s(String(u.getMonth()+1),2),d=s(String(u.getDate()),2),m=s(String(u.getHours()),2),p=s(String(u.getMinutes()),2),h=s(String(u.getSeconds()),2),w=l+f+d+m+p+h;if(a===!0){var v=u.getMilliseconds();if(v!=0){var y=s(String(v),3);y=y.replace(/[0]+$/,""),w=w+"."+y}}return w+"Z"},this.zeroPadding=function(n,i){return n.length>=i?n:new Array(i-n.length+1).join("0")+n},this.setByParam=function(n){this.hV=null,this.hTLV=null,this.params=n},this.getString=function(){},this.setString=function(n){this.hTLV=null,this.isModified=!0,this.params==null&&(this.params={}),this.params.str=n},this.setByDate=function(n){this.hTLV=null,this.isModified=!0,this.params==null&&(this.params={}),this.params.date=n},this.setByDateValue=function(n,i,a,s,u,l){var f=new Date(Date.UTC(n,i-1,a,s,u,l,0));this.setByDate(f)},this.getFreshValueHex=function(){return this.hV}};pe(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)};pe(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"};pe(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=Of;this.setByBigInteger=function(r){this.isModified=!0,this.params={bigint:r}},this.setByInteger=function(r){this.isModified=!0,this.params=r},this.setValueHex=function(r){this.isModified=!0,this.params={hex:r}},this.getFreshValueHex=function(){var r=this.params,n=null;if(r==null)throw new Error("value not set");if(typeof r=="object"&&r.hex!=null)return this.hV=r.hex,this.hV;if(typeof r=="number")n=new ee(String(r),10);else if(r.int!=null)n=new ee(String(r.int),10);else if(r.bigint!=null)n=r.bigint;else throw new Error("wrong parameter");return this.hV=t(n),this.hV},e!=null&&(this.params=e)};pe(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||7=a)break}return n};ye.getNthChildIdx=function(e,t,r){var n=ye.getChildIdx(e,t);return n[r]};ye.getIdxbyList=function(e,t,r,n){var i=ye,a,s;return r.length==0?n!==void 0&&e.substr(t,2)!==n?-1:t:(a=r.shift(),s=i.getChildIdx(e,t),a>=s.length?-1:i.getIdxbyList(e,s[a],r,n))};ye.getIdxbyListEx=function(e,t,r,n){var i=ye,a,s;if(r.length==0)return n!==void 0&&e.substr(t,2)!==n?-1:t;a=r.shift(),s=i.getChildIdx(e,t);for(var u=0,l=0;l=e.length?null:i.getTLV(e,a)};ye.getTLVbyListEx=function(e,t,r,n){var i=ye,a=i.getIdxbyListEx(e,t,r,n);return a==-1?null:i.getTLV(e,a)};ye.getVbyList=function(e,t,r,n,i){var a=ye,s,u;return s=a.getIdxbyList(e,t,r,n),s==-1||s>=e.length?null:(u=a.getV(e,s),i===!0&&(u=u.substr(2)),u)};ye.getVbyListEx=function(e,t,r,n,i){var a=ye,s,u,l;return s=a.getIdxbyListEx(e,t,r,n),s==-1?null:(l=a.getV(e,s),e.substr(s,2)=="03"&&i!==!1&&(l=l.substr(2)),l)};ye.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=ye.getV(e,t);return n=="02"?parseInt(i,16):c_(i)}catch{return r}};ye.getOID=function(e,t,r){r==null&&(r=null);try{if(e.substr(t,2)!="06")return r;var n=ye.getV(e,t);return Id(n)}catch{return r}};ye.getOIDName=function(e,t,r){r==null&&(r=null);try{var n=ye.getOID(e,t,r);if(n==r)return r;var i=A.asn1.x509.OID.oid2name(n);return i==""?n:i}catch{return r}};ye.getString=function(e,t,r){r==null&&(r=null);try{var n=ye.getV(e,t);return Di(n)}catch{return r}};ye.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 a=e.substr(2),s=[],u=0;u0&&(d=d+"."+l.join(".")),d};ye.dump=function(e,t,r,n){var i=ye,a=i.getV,s=i.dump,u=i.getChildIdx,l=e;e instanceof A.asn1.ASN1Object&&(l=e.tohex());var f=function(L,S){if(L.length<=S*2)return L;var B=L.substr(0,S)+"..(total "+L.length/2+"bytes).."+L.substr(L.length-S,S);return B};t===void 0&&(t={ommit_long_octet:32}),r===void 0&&(r=0),n===void 0&&(n="");var d=t.ommit_long_octet,F=l.substr(r,2);if(F=="01"){var m=a(l,r);return m=="00"?n+`BOOLEAN FALSE `:n+`BOOLEAN TRUE `}if(F=="02"){var m=a(l,r);return n+"INTEGER "+f(m,d)+` `}if(F=="03"){var m=a(l,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 "+f(m,d)+` `}if(F=="04"){var m=a(l,r);if(i.isASN1HEX(m)){var p=n+`OCTETSTRING, encapsulates `;return p=p+s(m,t,0,n+" "),p}else return n+"OCTETSTRING "+f(m,d)+` `}if(F=="05")return n+`NULL `;if(F=="06"){var h=a(l,r),w=A.asn1.ASN1Util.oidHexToInt(h),v=A.asn1.x509.OID.oid2name(w),y=w.replace(/\./g," ");return v!=""?n+"ObjectIdentifier "+v+" ("+y+`) `:n+"ObjectIdentifier ("+y+`) `}if(F=="0a")return n+"ENUMERATED "+parseInt(a(l,r))+` `;if(F=="0c")return n+"UTF8String '"+Gt(a(l,r))+`' `;if(F=="13")return n+"PrintableString '"+Gt(a(l,r))+`' `;if(F=="14")return n+"TeletexString '"+Gt(a(l,r))+`' `;if(F=="16")return n+"IA5String '"+Gt(a(l,r))+`' `;if(F=="17")return n+"UTCTime "+Gt(a(l,r))+` `;if(F=="18")return n+"GeneralizedTime "+Gt(a(l,r))+` `;if(F=="1a")return n+"VisualString '"+Gt(a(l,r))+`' `;if(F=="1e")return n+"BMPString '"+lm(a(l,r))+`' `;if(F=="30"){if(l.substr(r,4)=="3000")return n+`SEQUENCE {} `;var p=n+`SEQUENCE `,g=u(l,r),b=t;if((g.length==2||g.length==3)&&l.substr(g[0],2)=="06"&&l.substr(g[g.length-1],2)=="04"){var v=i.oidname(a(l,g[0])),D=JSON.parse(JSON.stringify(t));D.x509ExtName=v,b=D}for(var C=0;C4?{enum:{hex:g}}:{enum:parseInt(g,16)};if(v=="30"||v=="31")return y[h[v]]=w(e),y;if(v=="14"){var U=p(g);return y[h[v]]={str:U},y}else if(v=="1e"){var U=m(g);return y[h[v]]={str:U},y}else if(":0c:12:13:16:17:18:1a:".indexOf(v)!=-1){var U=d(g);return y[h[v]]={str:U},y}else if(v.match(/^8[0-9]$/)){var U=d(g);return U==null|U==""?{tag:{tag:v,explicit:!1,hex:g}}:U.match(/[\x00-\x1F\x7F-\x9F]/)!=null||U.match(/[\u0000-\u001F\u0080–\u009F]/)!=null?{tag:{tag:v,explicit:!1,hex:g}}:{tag:{tag:v,explicit:!1,str:U}}}else if(v.match(/^a[0-9]$/))try{if(!n(g))throw new Error("not encap");return{tag:{tag:v,explicit:!0,obj:r(g)}}}catch{return{tag:{tag:v,explicit:!0,hex:g}}}else{var L=new A.asn1.ASN1Object;L.hV=g;var S=L.getLengthHexFromValue();return{asn1:{tlv:v+S+g}}}}}};ye.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}};ye.isASN1HEX=function(e){var t=ye;if(e.length%2==1)return!1;var r=t.getVblen(e,0),n=e.substr(0,2),i=t.getL(e,0),a=e.length-n.length-i.length;return a==r*2};ye.checkStrictDER=function(e,t,r,n,i){var a=ye;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=a.getL(e,t);if(s.length>i*2)throw new Error("L of TLV too long: idx="+t);var u=a.getVblen(e,t);if(u>n)throw new Error("value of L too long than hex: idx="+t);var l=a.getTLV(e,t),f=l.length-2-a.getL(e,t).length;if(f!==u*2)throw new Error("V string length and L's value not the same:"+f+"/"+u*2);if(t===0&&e.length!=l.length)throw new Error("total length and TLV length unmatch:"+e.length+"!="+l.length);var d=e.substr(t,2);if(d==="02"){var m=a.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(d,16)&32){for(var p=a.getVblen(e,t),h=0,w=a.getChildIdx(e,t),v=0;v"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,a=r.x509,s=a.TBSCertificate,u=a.AlgorithmIdentifier;this.params=void 0,this.setByParam=function(l){this.params=l},this.sign=function(){var l=this.params,f=l.sigalg;l.sigalg.name!=null&&(f=l.sigalg.name);var d=l.tbsobj.tohex(),m=new A.crypto.Signature({alg:f});m.init(l.cakey),m.updateHex(d),l.sighex=m.sign()},this.getPEM=function(){return Mn(this.tohex(),"CERTIFICATE")},this.tohex=function(){var l=this.params;if((l.tbsobj==null||l.tbsobj==null)&&(l.tbsobj=new s(l)),l.sighex==null&&l.cakey!=null&&this.sign(),l.sighex==null)throw new Error("sighex or cakey parameter not defined");var f=[];f.push(l.tbsobj),f.push(new u({name:l.sigalg})),f.push(new n({hex:"00"+l.sighex}));var d=new i({array:f});return d.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&(this.params=e)};pe(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,a=r.DERInteger,s=r.DERSequence,u=n.AlgorithmIdentifier,l=n.Time,f=n.X500Name,d=n.Extensions,m=n.SubjectPublicKeyInfo;this.params=null,this.setByParam=function(p){this.params=p},this.tohex=function(){var p=[],h=this.params;if(h.version!=null||h.version!=1){var w=2;h.version!=null&&(w=h.version-1);var v=new i({obj:new a({int:w})});p.push(v)}p.push(new a(h.serial)),p.push(new u({name:h.sigalg})),p.push(new f(h.issuer)),p.push(new s({array:[new l(h.notbefore),new l(h.notafter)]})),p.push(new f(h.subject)),p.push(new m(Et.getKey(h.sbjpubkey))),h.ext!==void 0&&h.ext.length>0&&p.push(new i({tag:"a3",obj:new d(h.ext)}));var y=new A.asn1.DERSequence({array:p});return y.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};pe(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(a){this.aParam=a},this.tohex=function(){for(var a=[],s=0;s-1&&u.push(new n({int:this.pathLen}));var l=new i({array:u});return this.asn1ExtnValue=l,this.asn1ExtnValue.tohex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,e!==void 0&&(e.cA!==void 0&&(this.cA=e.cA),e.pathLen!==void 0&&(this.pathLen=e.pathLen))};pe(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 a=[],s=0;s0&&a.push(new r({array:s}))}var l=new r({array:a});return l.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(this.params=e)};pe(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,a=t.x509.UserNotice;this.params=null,this.tohex=function(){if(this.params.cps!==void 0){var s=new r({array:[new i({oid:"1.3.6.1.5.5.7.2.1"}),new n({str:this.params.cps})]});return s.tohex()}if(this.params.unotice!=null){var s=new r({array:[new i({oid:"1.3.6.1.5.5.7.2.2"}),new a(this.params.unotice)]});return s.tohex()}},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(this.params=e)};pe(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 a=[];this.params.noticeref!==void 0&&a.push(new i(this.params.noticeref)),this.params.exptext!==void 0&&a.push(new n(this.params.exptext));var s=new t({array:a});return s.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(this.params=e)};pe(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 a=[],s=this.params.noticenum,u=0;u0)for(var s=0;s0;i++){var a=t.shift();if(r===!0){var s=n.pop(),u=(s+","+a).replace(/\\,/g,",");n.push(u),r=!1}else n.push(a);a.substr(-1,1)==="\\"&&(r=!0)}return n=n.map(function(l){return l.replace("/","\\/")}),n.reverse(),"/"+n.join("/")};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 a=t.shift();if(r===!0){var s=n.pop(),u=(s+"+"+a).replace(/\\\+/g,"+");n.push(u),r=!1}else n.push(a);a.substr(-1,1)==="\\"&&(r=!0)}for(var l=!1,f=[],i=0;n.length>0;i++){var a=n.shift();if(l===!0){var d=f.pop();if(a.match(/"$/)){var u=(d+"+"+a).replace(/^([^=]+)="(.*)"$/,"$1=$2");f.push(u),l=!1}else f.push(d+"+"+a)}else f.push(a);a.match(/^[^=]+="/)&&(l=!0)}return f};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,a=r.DERPrintableString,s=r.DERTeletexString,u=r.DERIA5String,l=r.DERVisibleString,f=r.DERBMPString,d=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 h=p.str,w=h.match(/^([^=]+)=(.+)$/);if(w)this.sType=w[1],this.sValue=w[2];else throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}else this.sType=p.type,this.sValue=p.value},this.setByString=function(p,h){h!==void 0&&(this.sRule=h);var w=p.match(/^([^=]+)=(.+)$/);if(w)this.setByAttrTypeAndValueStr(w[1],w[2]);else throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)},this._getDsType=function(){var p=this.sType,h=this.sValue,w=this.sRule;return w==="prn"?p=="CN"&&d(h)?"ia5":m(h)?"prn":"utf8":w==="utf8"?p=="CN"&&d(h)?"ia5":p=="C"?"prn":"utf8":"utf8"},this.setByAttrTypeAndValueStr=function(p,h,w){w!==void 0&&(this.sRule=w),this.sType=p,this.sValue=h},this.getValueObj=function(p,h){if(p=="utf8")return new i({str:h});if(p=="prn")return new a({str:h});if(p=="tel")return new s({str:h});if(p=="ia5")return new u({str:h});if(p=="vis")return new l({str:h});if(p=="bmp")return new f({str:h});throw new Error("unsupported directory string type: type="+p+" value="+h)},this.tohex=function(){this.dsType==null&&(this.dsType=this._getDsType());var p=A.asn1.x509.OID.atype2obj(this.sType),h=this.getValueObj(this.dsType,this.sValue),w=new n({array:[p,h]});return this.TLV=w.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};pe(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,a=i.DERInteger,s=i.DERBitString,u=i.DERObjectIdentifier,l=i.DERSequence,f=i.ASN1Util.newObject,d=i.x509,m=d.AlgorithmIdentifier,p=n.crypto,h=p.ECDSA,w=p.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null)throw"algId and/or subjPubKey not set";var v=new l({array:[this.asn1AlgId,this.asn1SubjPKey]});return v},this.tohex=function(){var v=this.getASN1Object();return this.hTLV=v.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},this.setPubKey=function(v){try{if(v instanceof et){var y=f({seq:[{int:{bigint:v.n}},{int:{int:v.e}}]}),g=y.tohex();this.asn1AlgId=new m({name:"rsaEncryption"}),this.asn1SubjPKey=new s({hex:"00"+g})}}catch{}try{if(v instanceof A.crypto.ECDSA){var b=new u({name:v.curveName});this.asn1AlgId=new m({name:"ecPublicKey",asn1params:b}),this.asn1SubjPKey=new s({hex:"00"+v.pubKeyHex})}}catch{}try{if(v instanceof A.crypto.DSA){var b=new f({seq:[{int:{bigint:v.p}},{int:{bigint:v.q}},{int:{bigint:v.g}}]});this.asn1AlgId=new m({name:"dsa",asn1params:b});var D=new a({bigint:v.y});this.asn1SubjPKey=new s({hex:"00"+D.tohex()})}}catch{}},e!==void 0&&this.setPubKey(e)};pe(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,a=i.DERUTCTime,s=i.DERGeneralizedTime;this.params=null,this.type=null,this.setTimeParams=function(u){this.timeParams=u},this.setByParam=function(u){this.params=u},this.getType=function(u){return u.match(/^[0-9]{12}Z$/)?"utc":u.match(/^[0-9]{14}Z$/)?"gen":u.match(/^[0-9]{12}\.[0-9]+Z$/)?"utc":u.match(/^[0-9]{14}\.[0-9]+Z$/)?"gen":null},this.tohex=function(){var u=this.params,l=null;if(typeof u=="string"&&(u={str:u}),u!=null&&u.str&&(u.type==null||u.type==null)&&(u.type=this.getType(u.str)),u!=null&&u.str?(u.type=="utc"&&(l=new a(u.str)),u.type=="gen"&&(l=new s(u.str))):this.type=="gen"?l=new s:l=new a,l==null)throw new Error("wrong setting for Time");return this.TLV=l.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};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,a=i.DERUTCTime,s=i.DERGeneralizedTime;this.setTimeParams=function(u){this.timeParams=u},this.tohex=function(){var u=null;return this.timeParams!=null?this.type=="utc"?u=new a(this.timeParams):u=new s(this.timeParams):this.type=="utc"?u=new a:u=new s,this.TLV=u.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)};pe(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 a=null;for(var s in n)s===this.nameAlg&&(a=n[s]);if(a!==null)return this.hTLV=a,this.hTLV}this.nameAlg!==null&&this.asn1Alg===null&&(this.asn1Alg=r.x509.OID.name2obj(this.nameAlg));var u=[this.asn1Alg];this.asn1Params!==null&&u.push(this.asn1Params);var l=new r.DERSequence({array:u});return this.hTLV=l.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(e.name!==void 0&&(this.nameAlg=e.name),e.asn1params!==void 0&&(this.asn1Params=e.asn1params),e.paramempty!==void 0&&(this.paramEmpty=e.paramempty)),this.asn1Params===null&&this.paramEmpty===!1&&this.nameAlg!==null){this.nameAlg.name!==void 0&&(this.nameAlg=this.nameAlg.name);var i=this.nameAlg.toLowerCase();i.substr(-7,7)!=="withdsa"&&i.substr(-9,9)!=="withecdsa"&&(this.asn1Params=new r.DERNull)}};pe(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,a=i.X500Name,s=i.OtherName,u=n.DERIA5String,l=n.DERPrintableString,f=n.DEROctetString,d=n.DERTaggedObject,m=n.ASN1Object,p=Error;this.params=null,this.setByParam=function(h){this.params=h},this.tohex=function(){var h=this.params,w,y,v,y=!1;if(h.other!==void 0)w="a0",v=new s(h.other);else if(h.rfc822!==void 0)w="81",v=new u({str:h.rfc822});else if(h.dns!==void 0)w="82",v=new u({str:h.dns});else if(h.dn!==void 0)w="a4",y=!0,typeof h.dn=="string"?v=new a({str:h.dn}):h.dn instanceof A.asn1.x509.X500Name?v=h.dn:v=new a(h.dn);else if(h.ldapdn!==void 0)w="a4",y=!0,v=new a({ldapstr:h.ldapdn});else if(h.certissuer!==void 0||h.certsubj!==void 0){w="a4",y=!0;var g,b,D=null;if(h.certsubj!==void 0?(g=!1,b=h.certsubj):(g=!0,b=h.certissuer),b.match(/^[0-9A-Fa-f]+$/)&&D==b,b.indexOf("-----BEGIN ")!=-1&&(D=br(b)),D==null)throw new Error("certsubj/certissuer not cert");var C=new Ge;C.hex=D;var F;g?F=C.getIssuerHex():F=C.getSubjectHex(),v=new m,v.hTLV=F}else if(h.uri!==void 0)w="86",v=new u({str:h.uri});else if(h.ip!==void 0){w="87";var U,L=h.ip;try{if(L.match(/^[0-9a-f]+$/)){var S=L.length;if(S==8||S==16||S==32||S==64)U=L;else throw"err"}else U=om(L)}catch(O){throw new p("malformed IP address: "+h.ip+":"+O.message)}v=new f({hex:U})}else throw new p("improper params");var B=new d({tag:w,explicit:y,obj:v});return B.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};pe(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 a=0;a"u")throw"Name of ObjectIdentifier not defined: "+t;var r=this.name2oidList[t],n=new e({oid:r});return this.objCache[t]=n,n},this.atype2obj=function(t){if(this.objCache[t]!==void 0)return this.objCache[t];var r;if(t.match(/^\d+\.\d+\.[0-9.]+$/))r=t;else if(this.atype2oidList[t]!==void 0)r=this.atype2oidList[t];else if(this.name2oidList[t]!==void 0)r=this.name2oidList[t];else throw new Error("AttributeType name undefined: "+t);var n=new e({oid:r});return this.objCache[t]=n,n},this.registerOIDs=function(t){if(this.checkOIDs(t))for(var r in t)this.name2oidList[r]=t[r]},this.checkOIDs=function(t){try{var r=Object.keys(t);return r.length==0?!1:(r.map(function(n,i,a){var s=this[n];if(!s.match(/^[0-2]\.[0-9.]+$/))throw new Error("value is not OID")},t),!0)}catch{return!1}}};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,a=n.DERSet,s=n.DERObjectIdentifier;this.params=null,this.typeOid=null,this.setByParam=function(u){this.params=u},this.getValueArray=function(){throw new t("not yet implemented abstract")},this.tohex=function(){var u=new s({oid:this.typeOid}),l=new a({array:this.getValueArray()}),f=new i({array:[u,l]});return f.tohex()},this.getEncodedHex=function(){return this.tohex()}};pe(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)};pe(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 a=new n(this.params);return[a]},e!=null&&this.setByParam(e)};pe(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)};pe(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,a=n.cms,s=a.ESSCertID,u=r.crypto;a.SigningCertificate.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.12",this.getValueArray=function(){if(this.params==null||this.params==null||this.params.array==null)throw new t("parameter 'array' not specified");for(var l=this.params.array,f=[],d=0;d0){for(var w=a(p.valhex,h[0]),v=m(w,0),y=[],g=0;g1){var C=a(p.valhex,h[1]);p.polhex=C}delete p.valhex},this.setSignaturePolicyIdentifier=function(p){var h=m(p.valhex,0);if(h.length>0){var w=n.getOID(p.valhex,h[0]);p.oid=w}if(h.length>1){var v=new t,y=m(p.valhex,h[1]),g=a(p.valhex,y[0]),b=v.getAlgorithmIdentifierName(g);p.alg=b;var D=i(p.valhex,y[1]);p.hash=D}delete p.valhex},this.setSigningCertificateV2=function(p){var h=m(p.valhex,0);if(h.length>0){for(var w=a(p.valhex,h[0]),v=m(w,0),y=[],g=0;g1){var C=a(p.valhex,h[1]);p.polhex=C}delete p.valhex},this.getESSCertID=function(p){var h={},w=m(p,0);if(w.length>0){var v=i(p,w[0]);h.hash=v}if(w.length>1){var y=a(p,w[1]),g=this.getIssuerSerial(y);g.serial!=null&&(h.serial=g.serial),g.issuer!=null&&(h.issuer=g.issuer)}return h},this.getESSCertIDv2=function(p){var h={},w=m(p,0);if(w.length<1||3v+1){var b=a(p,w[v+1]),D=this.getIssuerSerial(b);h.issuer=D.issuer,h.serial=D.serial}return h},this.getIssuerSerial=function(p){var h={},w=m(p,0),v=a(p,w[0]),y=r.getGeneralNames(v),g=y[0].dn;h.issuer=g;var b=i(p,w[1]);return h.serial={hex:b},h},this.getCertificateSet=function(p){for(var h=m(p,0),w=[],v=0;v"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)};pe(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,a=n.DERInteger,s=n.DERBoolean,u=n.DERGeneralizedTime,l=n.DERObjectIdentifier,f=n.DERTaggedObject,d=n.tsp,m=d.MessageImprint,p=d.Accuracy,h=n.x509.X500Name,w=n.x509.GeneralName;if(d.TSTInfo.superclass.constructor.call(this),this.dVersion=new a({int:1}),this.dPolicy=null,this.dMessageImprint=null,this.dSerial=null,this.dGenTime=null,this.dAccuracy=null,this.dOrdering=null,this.dNonce=null,this.dTsa=null,this.tohex=function(){var v=[this.dVersion];if(this.dPolicy==null)throw new Error("policy shall be specified.");if(v.push(this.dPolicy),this.dMessageImprint==null)throw new Error("messageImprint shall be specified.");if(v.push(this.dMessageImprint),this.dSerial==null)throw new Error("serialNumber shall be specified.");if(v.push(this.dSerial),this.dGenTime==null)throw new Error("genTime shall be specified.");v.push(this.dGenTime),this.dAccuracy!=null&&v.push(this.dAccuracy),this.dOrdering!=null&&v.push(this.dOrdering),this.dNonce!=null&&v.push(this.dNonce),this.dTsa!=null&&v.push(this.dTsa);var y=new i({array:v});return this.hTLV=y.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},e!==void 0){if(typeof e.policy=="string"){if(!e.policy.match(/^[0-9.]+$/))throw"policy shall be oid like 0.1.4.134";this.dPolicy=new l({oid:e.policy})}e.messageImprint!==void 0&&(this.dMessageImprint=new m(e.messageImprint)),e.serial!==void 0&&(this.dSerial=new a(e.serial)),e.genTime!==void 0&&(this.dGenTime=new u(e.genTime)),e.accuracy!==void 0&&(this.dAccuracy=new p(e.accuracy)),e.ordering!==void 0&&e.ordering==!0&&(this.dOrdering=new s),e.nonce!==void 0&&(this.dNonce=new a(e.nonce)),e.tsa!==void 0&&(this.dTsa=new f({tag:"a0",explicit:!0,obj:new w({dn:e.tsa})}))}};pe(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,a=[];return i.seconds!=null&&typeof i.seconds=="number"&&a.push({int:i.seconds}),i.millis!=null&&typeof i.millis=="number"&&a.push({tag:{tagi:"80",obj:{int:i.millis}}}),i.micros!=null&&typeof i.micros=="number"&&a.push({tag:{tagi:"81",obj:{int:i.micros}}}),n({seq:a}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};pe(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,a=r.x509,s=a.AlgorithmIdentifier;r.tsp.MessageImprint.superclass.constructor.call(this),this.params=null,this.tohex=function(){var u=this.params,l=new s({name:u.alg}),f=new i({hex:u.hash}),d=new n({array:[l,f]});return d.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};pe(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,a=r.DERBoolean,s=r.ASN1Object,u=r.DERObjectIdentifier,l=r.tsp,f=l.MessageImprint;l.TimeStampReq.superclass.constructor.call(this),this.params=null,this.tohex=function(){var d=this.params,m=[];m.push(new i({int:1})),d.messageImprint instanceof A.asn1.ASN1Object?m.push(d.messageImprint):m.push(new f(d.messageImprint)),d.policy!=null&&m.push(new u(d.policy)),d.nonce!=null&&m.push(new i(d.nonce)),d.certreq==!0&&m.push(new a);var p=new n({array:m});return p.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};pe(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,a=r.tsp,s=a.PKIStatusInfo;a.TimeStampResp.superclass.constructor.call(this),this.params=null,this.tohex=function(){var u=this.params,l=[];if(u.econtent!=null||u.tst!=null)if(u.statusinfo!=null?l.push(new s(u.statusinfo)):l.push(new s("granted")),u.econtent!=null)l.push(new a.TimeStampToken(u).getContentInfo());else if(u.tst instanceof r.ASN1Object)l.push(u.tst);else throw new Error("improper member tst value");else if(u.statusinfo!=null)l.push(new s(u.statusinfo));else throw new Error("parameter for token nor statusinfo not specified");var f=new n({array:l});return f.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};pe(A.asn1.tsp.TimeStampResp,A.asn1.ASN1Object);A.asn1.tsp.PKIStatusInfo=function(e){var t=Error,r=A,n=r.asn1,i=n.DERSequence,a=n.tsp,s=a.PKIStatus,u=a.PKIFreeText,l=a.PKIFailureInfo;a.PKIStatusInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var f=this.params,d=[];if(typeof f=="string")d.push(new s(f));else{if(f.status==null)throw new t("property 'status' unspecified");d.push(new s(f.status)),f.statusstr!=null&&d.push(new u(f.statusstr)),f.failinfo!=null&&d.push(new l(f.failinfo))}var m=new i({array:d});return m.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};pe(A.asn1.tsp.PKIStatusInfo,A.asn1.ASN1Object);A.asn1.tsp.PKIStatus=function(e){var t=Error,r=A,n=r.asn1,i=n.DERInteger,a=n.tsp;a.PKIStatus.superclass.constructor.call(this);var s={granted:0,grantedWithMods:1,rejection:2,waiting:3,revocationWarning:4,revocationNotification:5};this.params=null,this.tohex=function(){var u=this.params,l,f;if(typeof u=="string")try{f=s[u]}catch{throw new t("undefined name: "+u)}else if(typeof u=="number")f=u;else throw new t("unsupported params");return new i({int:f}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};pe(A.asn1.tsp.PKIStatus,A.asn1.ASN1Object);A.asn1.tsp.PKIFreeText=function(e){var t=Error,r=A,n=r.asn1,i=n.DERSequence,a=n.DERUTF8String,s=n.tsp;s.PKIFreeText.superclass.constructor.call(this),this.params=null,this.tohex=function(){var u=this.params;if(!u instanceof Array)throw new t("wrong params: not array");for(var l=[],f=0;f=0;p--)m+=d[p];return m}else{if(typeof l=="string"&&u[l]!=null)return Ad([l],u);if(typeof l=="object"&&l.length!=null)return Ad(l,u);throw new t("wrong params")}},this.tohex=function(){var l=this.params,f=this.getBinValue();return new i({bin:f}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};pe(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(a,s){var u=i(a,s);this.params.econtent.content.messageImprint={alg:s,hash:u},this.params.econtent.content.serial={int:this.serial++};var l=Math.floor(Math.random()*1e9);this.params.econtent.content.nonce={int:l};var f=new n.TimeStampToken(this.params);return f.getContentInfoEncodedHex()},e!==void 0&&(this.params=e)};pe(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(a,s){var u=i(a,s);this.params.econtent.content.messageImprint={alg:s,hash:u};var l=new n.TimeStampToken(this.params);return l.getContentInfoEncodedHex()},e!==void 0&&(this.params=e)};pe(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=Ge,r=new t,n=ye,i=n.getV,a=n.getTLV,s=n.getIdxbyList,u=n.getTLVbyListEx,l=n.getChildIdx,f=["granted","grantedWithMods","rejection","waiting","revocationWarning","revocationNotification"],d={0:"badAlg",2:"badRequest",5:"badDataFormat",14:"timeNotAvailable",15:"unacceptedPolicy",16:"unacceptedExtension",17:"addInfoNotAvailable",25:"systemFailure"};this.getResponse=function(m){var p=l(m,0);if(p.length==1)return this.getPKIStatusInfo(a(m,p[0]));if(p.length>1){var h=this.getPKIStatusInfo(a(m,p[0])),w=a(m,p[1]),v=this.getToken(w);return v.statusinfo=h,v}},this.getToken=function(m){var p=new A.asn1.cms.CMSParser,h=p.getCMSSignedData(m);return this.setTSTInfo(h),h},this.setTSTInfo=function(m){var p=m.econtent;if(p.type=="tstinfo"){var h=p.content.hex,w=this.getTSTInfo(h);p.content=w}},this.getTSTInfo=function(m){var p={},h=l(m,0),w=i(m,h[1]);p.policy=Id(w);var v=a(m,h[2]);p.messageImprint=this.getMessageImprint(v);var y=i(m,h[3]);p.serial={hex:y};var g=i(m,h[4]);p.genTime={str:Gt(g)};var b=0;if(h.length>5&&m.substr(h[5],2)=="30"){var D=a(m,h[5]);p.accuracy=this.getAccuracy(D),b++}if(h.length>5+b&&m.substr(h[5+b],2)=="01"){var C=i(m,h[5+b]);C=="ff"&&(p.ordering=!0),b++}if(h.length>5+b&&m.substr(h[5+b],2)=="02"){var F=i(m,h[5+b]);p.nonce={hex:F},b++}if(h.length>5+b&&m.substr(h[5+b],2)=="a0"){var U=a(m,h[5+b]);U="30"+U.substr(2),pGeneralNames=r.getGeneralNames(U);var L=pGeneralNames[0].dn;p.tsa=L,b++}if(h.length>5+b&&m.substr(h[5+b],2)=="a1"){var S=a(m,h[5+b]);S="30"+S.substr(2);var B=r.getExtParamArray(S);p.ext=B,b++}return p},this.getAccuracy=function(m){for(var p={},h=l(m,0),w=0;w1&&m.substr(h[1],2)=="30"){var g=a(m,h[1]);p.statusstr=this.getPKIFreeText(g),w++}if(h.length>w&&m.substr(h[1+w],2)=="03"){var b=a(m,h[1+w]);p.failinfo=this.getPKIFailureInfo(b)}return p},this.getPKIFreeText=function(m){for(var p=[],h=l(m,0),w=0;w"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(a){this.params=a},e!=null&&this.setByParam(e)};pe(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,a=r.x509,s=a.AlgorithmIdentifier,u=r.cades,l=u.SignaturePolicyId,f=u.OtherHashAlgAndValue;l.superclass.constructor.call(this),this.params=null,this.tohex=function(){var d=this.params,m=[];m.push(new i(d.oid)),m.push(new f(d));var p=new n({array:m});return p.tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(d){this.params=d},e!=null&&this.setByParam(e)};pe(A.asn1.cades.SignaturePolicyId,A.asn1.ASN1Object);A.asn1.cades.OtherHashAlgAndValue=function(e){var t=Error,r=A,n=r.asn1,i=n.DERSequence,a=n.DEROctetString,s=n.x509,u=s.AlgorithmIdentifier,l=n.cades,f=l.OtherHashAlgAndValue;f.superclass.constructor.call(this),this.params=null,this.tohex=function(){var d=this.params;if(d.alg==null)throw new t("property 'alg' not specified");if(d.hash==null&&d.cert==null)throw new t("property 'hash' nor 'cert' not specified");var m=null;if(d.hash!=null)m=d.hash;else if(d.cert!=null){if(typeof d.cert!="string")throw new t("cert not string");var p=d.cert;d.cert.indexOf("-----BEGIN")!=-1&&(p=br(d.cert)),m=A.crypto.Util.hashHex(p,d.alg)}var h=[];h.push(new u({name:d.alg})),h.push(new a({hex:m}));var w=new i({array:h});return w.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};pe(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,a=i.DEROctetString,s=r.crypto.Util.hashHex;this.params=null,this.tohex=function(){var u=this.params;if(u.hash==null&&u.cert==null)throw new t("hash or cert not specified");var l=null;if(u.hash!=null)l=u.hash;else if(u.cert!=null){if(typeof u.cert!="string")throw new t("cert not string");var f=u.cert;u.cert.indexOf("-----BEGIN")!=-1&&(f=br(u.cert)),l=A.crypto.Util.hashHex(f,"sha1")}return new a({hex:l}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};pe(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,a=i.ASN1Object,s=i.x509,u=i.cades;u.SignatureTimeStamp.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.14",this.params=null,this.getValueArray=function(){var l=this.params;if(l.tst!=null)if(n(l.tst)){var f=new a;return f.hTLV=l.tst,[f]}else{if(l.tst instanceof a)return[l.tst];throw new t("params.tst has wrong value")}else if(l.res!=null){var d=l.res;if(d instanceof a&&(d=d.tohex()),typeof d!="string"||!n(d))throw new t("params.res has wrong value");var m=ye.getTLVbyList(d,0,[1]),f=new a;return f.hTLV=l.tst,[f]}},e!=null&&this.setByParam(e)};pe(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,a=n.cades,s=a.OtherCertID,u=r.lang.String.isHex;a.CompleteCertificateRefs.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.21",this.params=null,this.getValueArray=function(){for(var l=this.params,f=[],d=0;d"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,a=r.csr,s=r.x509,u=a.CertificationRequestInfo;a.CertificationRequest.superclass.constructor.call(this),this.setByParam=function(l){this.params=l},this.sign=function(){var l=new u(this.params).tohex(),f=new A.crypto.Signature({alg:this.params.sigalg});f.init(this.params.sbjprvkey),f.updateHex(l);var d=f.sign();this.params.sighex=d},this.getPEM=function(){return Mn(this.tohex(),"CERTIFICATE REQUEST")},this.tohex=function(){var l=this.params,f=new A.asn1.csr.CertificationRequestInfo(this.params),d=new A.asn1.x509.AlgorithmIdentifier({name:l.sigalg});if(l.sighex==null&&l.sbjprvkey!=null&&this.sign(),l.sighex==null)throw new Error("sighex or sbjprvkey parameter not defined");var m=new n({hex:"00"+l.sighex}),p=new i({array:[f,d,m]});return p.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};pe(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,a=r.DERInteger,s=r.DERUTF8String,u=r.DERTaggedObject,l=r.ASN1Util.newObject,f=r.csr,d=r.x509,m=d.X500Name,p=d.Extensions,h=d.SubjectPublicKeyInfo,w=f.AttributeList;f.CertificationRequestInfo.superclass.constructor.call(this),this.params=null,this.setByParam=function(y){y!=null&&(this.params=y)},this.tohex=function(){var y=this.params,g=[];if(g.push(new a({int:0})),g.push(new m(y.subject)),g.push(new h(Et.getKey(y.sbjpubkey))),y.attrs!=null){var b=v(y.attrs),D=l({tag:{tage:"a0",obj:b}});g.push(D)}else if(y.extreq!=null){var C=new p(y.extreq),D=l({tag:{tage:"a0",obj:{seq:[{oid:"1.2.840.113549.1.9.14"},{set:[C]}]}}});g.push(D)}else g.push(new u({tag:"a0",explicit:!1,obj:new s({str:""})}));var F=new i({array:g});return F.tohex()},this.getEncodedHex=function(){return this.tohex()};function v(y){for(var g=Error,b=A.asn1.x509.Extensions,D=[],C=0;C"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 a=this.params.resstatus;return typeof a=="number"?a:typeof a!="string"?-1:i.indexOf(a)},this.setByParam=function(a){this.params=a},this.tohex=function(){var a=this.params,s=this._getStatusCode();if(s==-1)throw new Error("responseStatus not supported: "+a.resstatus);if(s!=0)return r({seq:[{enum:{int:s}}]}).tohex();var u=new n(a);return r({seq:[{enum:{int:0}},{tag:{tag:"a0",explicit:!0,obj:u}}]}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};pe(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,a=t.ocsp.BasicOCSPResponse;this.params=null,this.setByParam=function(s){this.params=s},this.tohex=function(){var s=this.params;if(s.restype!="ocspBasic")throw new Error("not supported responseType: "+s.restype);var u=new a(s),l=[];l.push(new n({name:"ocspBasic"})),l.push(new i({hex:u.tohex()}));var f=new r({array:l});return f.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};pe(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,a=r.DERGeneralizedTime,s=r.DERTaggedObject,u=r.DERBitString,l=r.x509.Extensions,f=r.x509.AlgorithmIdentifier,d=r.ocsp,m=d.ResponderID;_SingleResponseList=d.SingleResponseList,_ResponseData=d.ResponseData,this.params=null,this.setByParam=function(p){this.params=p},this.sign=function(){var p=this.params,h=p.tbsresp.tohex(),w=new A.crypto.Signature({alg:p.sigalg});w.init(p.reskey),w.updateHex(h),p.sighex=w.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 h=[];if(h.push(p.tbsresp),h.push(new f({name:p.sigalg})),h.push(new u({hex:"00"+p.sighex})),p.certs!=null&&p.certs.length!=null){for(var w=[],v=0;v"u"||!A)&&(A={});(typeof A.lang>"u"||!A.lang)&&(A.lang={});A.lang.String=function(){};function r_(e){for(var t=new Array,r=0;r>6,l=128|s&63;return Gt(u.toString(16)+l.toString(16))}var u=224|(a&240)>>4,l=128|(a&15)<<2|(s&192)>>6,f=128|s&63;return Gt(u.toString(16)+l.toString(16)+f.toString(16))}var r=e.match(/.{4}/g),n=r.map(t);return n.join("")}function Sd(e){for(var t=encodeURIComponent(e),r="",n=0;n"7"?"00"+e:e}function ZO(e){e=e.replace(/^\s*\[\s*/,""),e=e.replace(/\s*\]\s*$/,""),e=e.replace(/\s*/g,"");try{var t=e.split(/,/).map(function(r,n,i){var a=parseInt(r);if(a<0||255t.length&&(r=t.length);for(var n=0;n0&&(f=f+"."+u.join(".")),f}catch{return null}}function l_(e){var t=new ee(String(e),10);return Of(t)}function Of(e){var t=e.toString(16);if(t.substr(0,1)!="-")return t.length%2==1?t="0"+t:t.match(/^[0-7]/)||(t="00"+t),t;var r=t.substr(1),n=r.length;n%2==1?n+=1:t.match(/^[0-7]/)||(n+=2);for(var i="",a=0;a=t?e:new Array(t-e.length+1).join(r)+e};function c_(e){if(e.length%2!=0||(e=e.toLowerCase(),e.match(/^[0-9a-f]+$/)==null))return-1;try{var t=e.substr(0,2);if(t=="00")return parseInt(e.substr(2),16);var r=parseInt(t,16);if(r>7)return-1;var n=e.substr(2),i=parseInt(n,16).toString(2);i=="0"&&(i="00000000"),i=i.slice(0,0-r);var a=parseInt(i,2);return a==NaN?-1:a}catch{return-1}}function f_(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+wd("",r,"0");var n=parseInt(t,2).toString(16);n.length%2==1&&(n="0"+n);var i="0"+r;return i+n}function h_(e){if(typeof e!="string"||e.length%2!=0||!e.match(/^[0-9a-f]+$/))return null;try{var t=parseInt(e.substr(0,2),16);if(t<0||7=0;n--)a+=i[n];return a}function tr(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:Se.algo.MD5,sha1:Se.algo.SHA1,sha224:Se.algo.SHA224,sha256:Se.algo.SHA256,sha384:Se.algo.SHA384,sha512:Se.algo.SHA512,ripemd160:Se.algo.RIPEMD160},this.getDigestInfoHex=function(e,t){if(typeof this.DIGESTINFOHEAD[t]>"u")throw"alg not supported in Util.DIGESTINFOHEAD: "+t;return this.DIGESTINFOHEAD[t]+e},this.getPaddedDigestInfoHex=function(e,t,r){var n=this.getDigestInfoHex(e,t),i=r/4;if(n.length+22>i)throw"key is too short for SigAlg: keylen="+r+","+t;for(var a="0001",s="00"+n,u="",l=i-a.length-s.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,a=Error,s=ee,u=Lt,l=A.crypto.ECDSA,f=A.crypto.ECParameterDB,d=l.getName,m=ye,p=m.getVbyListEx,h=m.isASN1HEX,w=new fc,v=null;this.type="EC",this.isPrivate=!1,this.isPublic=!1;function y(g,b,D,C){for(var F=Math.max(b.bitLength(),C.bitLength()),U=g.add2D(D),L=g.curve.getInfinity(),S=F-1;S>=0;--S)L=L.twice2D(),L.z=s.ONE,b.testBit(S)?C.testBit(S)?L=L.add2D(U):L=L.add2D(g):C.testBit(S)&&(L=L.add2D(D));return L}this.getBigRandom=function(g){return new s(g.bitLength(),w).mod(g.subtract(s.ONE)).add(s.ONE)},this.setNamedCurve=function(g){this.ecparams=f.getByName(g),this.prvKeyHex=null,this.pubKeyHex=null,this.curveName=g},this.setPrivateKeyHex=function(g){this.isPrivate=!0,this.prvKeyHex=g},this.setPublicKeyHex=function(g){this.isPublic=!0,this.pubKeyHex=g},this.getPublicKeyXYHex=function(){var g=this.pubKeyHex;if(g.substr(0,2)!=="04")throw"this method supports uncompressed format(04) only";var b=this.ecparams.keycharlen;if(g.length!==2+b*2)throw"malformed public key hex length";var D={};return D.x=g.substr(2,b),D.y=g.substr(2+b),D},this.getShortNISTPCurveName=function(){var g=this.curveName;return g==="secp256r1"||g==="NIST P-256"||g==="P-256"||g==="prime256v1"?"P-256":g==="secp384r1"||g==="NIST P-384"||g==="P-384"?"P-384":g==="secp521r1"||g==="NIST P-521"||g==="P-521"?"P-521":null},this.generateKeyPairHex=function(){var g=this.ecparams.n,b=this.getBigRandom(g),D=this.ecparams.keycharlen,C=("0000000000"+b.toString(16)).slice(-D);this.setPrivateKeyHex(C);var F=this.generatePublicKeyHex();return{ecprvhex:C,ecpubhex:F}},this.generatePublicKeyHex=function(){var g=new s(this.prvKeyHex,16),b=this.ecparams.G.multiply(g),D=b.getX().toBigInteger(),C=b.getY().toBigInteger(),F=this.ecparams.keycharlen,U=("0000000000"+D.toString(16)).slice(-F),L=("0000000000"+C.toString(16)).slice(-F),S="04"+U+L;return this.setPublicKeyHex(S),S},this.signWithMessageHash=function(g){return this.signHex(g,this.prvKeyHex)},this.signHex=function(g,b){var D=new s(b,16),C=this.ecparams.n,F=new s(g.substring(0,this.ecparams.keycharlen),16);do var U=this.getBigRandom(C),L=this.ecparams.G,S=L.multiply(U),B=S.getX().toBigInteger().mod(C);while(B.compareTo(s.ZERO)<=0);var O=U.modInverse(C).multiply(F.add(D.multiply(B))).mod(C);return l.biRSSigToASN1Sig(B,O)},this.sign=function(g,b){var D=b,C=this.ecparams.n,F=s.fromByteArrayUnsigned(g);do var U=this.getBigRandom(C),L=this.ecparams.G,S=L.multiply(U),B=S.getX().toBigInteger().mod(C);while(B.compareTo(ee.ZERO)<=0);var O=U.modInverse(C).multiply(F.add(D.multiply(B))).mod(C);return this.serializeSig(B,O)},this.verifyWithMessageHash=function(g,b){return this.verifyHex(g,b,this.pubKeyHex)},this.verifyHex=function(g,b,D){try{var C,F,U=l.parseSigHex(b);C=U.r,F=U.s;var L=u.decodeFromHex(this.ecparams.curve,D),S=new s(g.substring(0,this.ecparams.keycharlen),16);return this.verifyRaw(S,C,F,L)}catch{return!1}},this.verify=function(g,b,D){var C,F;if(Bitcoin.Util.isArray(b)){var U=this.parseSig(b);C=U.r,F=U.s}else if(typeof b=="object"&&b.r&&b.s)C=b.r,F=b.s;else throw"Invalid value for signature";var L;if(D instanceof Lt)L=D;else if(Bitcoin.Util.isArray(D))L=u.decodeFrom(this.ecparams.curve,D);else throw"Invalid format for pubkey value, must be byte array or ECPointFp";var S=s.fromByteArrayUnsigned(g);return this.verifyRaw(S,C,F,L)},this.verifyRaw=function(g,b,D,C){var F=this.ecparams.n,U=this.ecparams.G;if(b.compareTo(s.ONE)<0||b.compareTo(F)>=0||D.compareTo(s.ONE)<0||D.compareTo(F)>=0)return!1;var L=D.modInverse(F),S=g.multiply(L).mod(F),B=b.multiply(L).mod(F),O=U.multiply(S).add(C.multiply(B)),x=O.getX().toBigInteger().mod(F);return x.equals(b)},this.serializeSig=function(g,b){var D=g.toByteArraySigned(),C=b.toByteArraySigned(),F=[];return F.push(2),F.push(D.length),F=F.concat(D),F.push(2),F.push(C.length),F=F.concat(C),F.unshift(F.length),F.unshift(48),F},this.parseSig=function(g){var b;if(g[0]!=48)throw new Error("Signature not a valid DERSequence");if(b=2,g[b]!=2)throw new Error("First element in signature must be a DERInteger");var D=g.slice(b+2,b+2+g[b+1]);if(b+=2+g[b+1],g[b]!=2)throw new Error("Second element in signature must be a DERInteger");var C=g.slice(b+2,b+2+g[b+1]);b+=2+g[b+1];var F=s.fromByteArrayUnsigned(D),U=s.fromByteArrayUnsigned(C);return{r:F,s:U}},this.parseSigCompact=function(g){if(g.length!==65)throw"Signature has the wrong length";var b=g[0]-27;if(b<0||b>7)throw"Invalid signature type";var D=this.ecparams.n,C=s.fromByteArrayUnsigned(g.slice(1,33)).mod(D),F=s.fromByteArrayUnsigned(g.slice(33,65)).mod(D);return{r:C,s:F,i:b}},this.readPKCS5PrvKeyHex=function(g){if(h(g)===!1)throw new Error("not ASN.1 hex string");var b,D,C;try{b=p(g,0,["[0]",0],"06"),D=p(g,0,[1],"04");try{C=p(g,0,["[1]",0],"03")}catch{}}catch{throw new Error("malformed PKCS#1/5 plain ECC private key")}if(this.curveName=d(b),this.curveName===void 0)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(C),this.setPrivateKeyHex(D),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(g){if(h(g)===!1)throw new a("not ASN.1 hex string");var b,D,C,F;try{b=p(g,0,[1,0],"06"),D=p(g,0,[1,1],"06"),C=p(g,0,[2,0,1],"04");try{F=p(g,0,[2,0,"[1]",0],"03")}catch{}}catch{throw new a("malformed PKCS#8 plain ECC private key")}if(this.curveName=d(D),this.curveName===void 0)throw new a("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(F),this.setPrivateKeyHex(C),this.isPublic=!1},this.readPKCS8PubKeyHex=function(g){if(h(g)===!1)throw new a("not ASN.1 hex string");var b,D,C;try{b=p(g,0,[0,0],"06"),D=p(g,0,[0,1],"06"),C=p(g,0,[1],"03")}catch{throw new a("malformed PKCS#8 ECC public key")}if(this.curveName=d(D),this.curveName===null)throw new a("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(C)},this.readCertPubKeyHex=function(g,b){if(h(g)===!1)throw new a("not ASN.1 hex string");var D,C;try{D=p(g,0,[0,5,0,1],"06"),C=p(g,0,[0,5,1],"03")}catch{throw new a("malformed X.509 certificate ECC public key")}if(this.curveName=d(D),this.curveName===null)throw new a("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(C)},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 ee(t.r,16),n=new ee(t.s,16);return{r,s:n}};A.crypto.ECDSA.parseSigHexInHexRS=function(e){var t=ye,r=t.getChildIdx,n=t.getV;if(t.checkStrictDER(e,0),e.substr(0,2)!="30")throw new Error("signature is not a ASN.1 sequence");var i=r(e,0);if(i.length!=2)throw new Error("signature shall have two elements");var a=i[0],s=i[1];if(e.substr(a,2)!="02")throw new Error("1st item not ASN.1 integer");if(e.substr(s,2)!="02")throw new Error("2nd item not ASN.1 integer");var u=n(e,a),l=n(e,s);return{r:u,s:l}};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 ee(e,16),n=new ee(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}),a=new r.DERSequence({array:[n,i]});return a.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 ee(n,16)}this.getByName=function(n){var i=n;if(typeof t[i]<"u"&&(i=t[n]),typeof e[i]<"u")return e[i];throw"unregistered EC curve name: "+i},this.regist=function(n,i,a,s,u,l,f,d,m,p,h,w){e[n]={};var v=r(a),y=r(s),g=r(u),b=r(l),D=r(f),C=new nu(v,y,g),F=C.decodePointHex("04"+d+m);e[n].name=n,e[n].keylen=i,e[n].keycharlen=Math.ceil(i/8)*2,e[n].curve=C,e[n].G=F,e[n].n=b,e[n].h=D,e[n].oid=h,e[n].info=w;for(var U=0;U"u"||!A)&&(A={});(typeof A.crypto>"u"||!A.crypto)&&(A.crypto={});A.crypto.DSA=function(){var e=ye,t=e.getVbyList,r=e.getVbyListEx,n=e.isASN1HEX,i=ee;this.p=null,this.q=null,this.g=null,this.y=null,this.x=null,this.type="DSA",this.isPrivate=!1,this.isPublic=!1,this.setPrivate=function(a,s,u,l,f){this.isPrivate=!0,this.p=a,this.q=s,this.g=u,this.y=l,this.x=f},this.setPrivateHex=function(a,s,u,l,f){var d,m,p,h,w;d=new ee(a,16),m=new ee(s,16),p=new ee(u,16),typeof l=="string"&&l.length>1?h=new ee(l,16):h=null,w=new ee(f,16),this.setPrivate(d,m,p,h,w)},this.setPublic=function(a,s,u,l){this.isPublic=!0,this.p=a,this.q=s,this.g=u,this.y=l,this.x=null},this.setPublicHex=function(a,s,u,l){var f,d,m,p;f=new ee(a,16),d=new ee(s,16),m=new ee(u,16),p=new ee(l,16),this.setPublic(f,d,m,p)},this.signWithMessageHash=function(a){var s=this.p,u=this.q,l=this.g,f=this.y,d=this.x,m=A.crypto.Util.getRandomBigIntegerMinToMax(ee.ONE.add(ee.ONE),u.subtract(ee.ONE)),p=a.substr(0,u.bitLength()/4),h=new ee(p,16),w=l.modPow(m,s).mod(u),v=m.modInverse(u).multiply(h.add(d.multiply(w))).mod(u),y=A.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:w}},{int:{bigint:v}}]});return y},this.verifyWithMessageHash=function(a,s){var u=this.p,l=this.q,f=this.g,d=this.y,m=this.parseASN1Signature(s),p=m[0],h=m[1],w=a.substr(0,l.bitLength()/4),v=new ee(w,16);if(ee.ZERO.compareTo(p)>0||p.compareTo(l)>0||ee.ZERO.compareTo(h)>=0||h.compareTo(l)>0)throw"invalid DSA signature";var y=h.modInverse(l),g=v.multiply(y).mod(l),b=p.multiply(y).mod(l),D=f.modPow(g,u).multiply(d.modPow(b,u)).mod(u).mod(l);return D.compareTo(p)==0},this.parseASN1Signature=function(a){try{var s=new i(r(a,0,[0],"02"),16),u=new i(r(a,0,[1],"02"),16);return[s,u]}catch{throw new Error("malformed ASN.1 DSA signature")}},this.readPKCS5PrvKeyHex=function(a){var s,u,l,f,d;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{s=r(a,0,[1],"02"),u=r(a,0,[2],"02"),l=r(a,0,[3],"02"),f=r(a,0,[4],"02"),d=r(a,0,[5],"02")}catch{throw new Error("malformed PKCS#1/5 plain DSA private key")}this.setPrivateHex(s,u,l,f,d)},this.readPKCS8PrvKeyHex=function(a){var s,u,l,f;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{s=r(a,0,[1,1,0],"02"),u=r(a,0,[1,1,1],"02"),l=r(a,0,[1,1,2],"02"),f=r(a,0,[2,0],"02")}catch{throw new Error("malformed PKCS#8 plain DSA private key")}this.setPrivateHex(s,u,l,null,f)},this.readPKCS8PubKeyHex=function(a){var s,u,l,f;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{s=r(a,0,[0,1,0],"02"),u=r(a,0,[0,1,1],"02"),l=r(a,0,[0,1,2],"02"),f=r(a,0,[1,0],"02")}catch{throw new Error("malformed PKCS#8 DSA public key")}this.setPublicHex(s,u,l,f)},this.readCertPubKeyHex=function(a,s){var u,l,f,d;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{u=r(a,0,[0,5,0,1,0],"02"),l=r(a,0,[0,5,0,1,1],"02"),f=r(a,0,[0,5,0,1,2],"02"),d=r(a,0,[0,5,1,0],"02")}catch{throw new Error("malformed X.509 certificate DSA public key")}this.setPublicHex(u,l,f,d)}};var Et=function(){var e=function(v,y,g){return n(Se.AES,v,y,g)},t=function(v,y,g){return n(Se.TripleDES,v,y,g)},r=function(v,y,g){return n(Se.DES,v,y,g)},n=function(v,y,g,b){var D=Se.enc.Hex.parse(y),C=Se.enc.Hex.parse(g),F=Se.enc.Hex.parse(b),U={};U.key=C,U.iv=F,U.ciphertext=D;var L=v.decrypt(U,C,{iv:F});return Se.enc.Hex.stringify(L)},i=function(v,y,g){return u(Se.AES,v,y,g)},a=function(v,y,g){return u(Se.TripleDES,v,y,g)},s=function(v,y,g){return u(Se.DES,v,y,g)},u=function(v,y,g,b){var D=Se.enc.Hex.parse(y),C=Se.enc.Hex.parse(g),F=Se.enc.Hex.parse(b),U=v.encrypt(D,C,{iv:F}),L=Se.enc.Hex.parse(U.toString()),S=Se.enc.Base64.stringify(L);return S},l={"AES-256-CBC":{proc:e,eproc:i,keylen:32,ivlen:16},"AES-192-CBC":{proc:e,eproc:i,keylen:24,ivlen:16},"AES-128-CBC":{proc:e,eproc:i,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:t,eproc:a,keylen:24,ivlen:8},"DES-CBC":{proc:r,eproc:s,keylen:8,ivlen:8}},f=function(v){return l[v].proc},d=function(v){var y=Se.lib.WordArray.random(v),g=Se.enc.Hex.stringify(y);return g},m=function(v){var y={},g=v.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));g&&(y.cipher=g[1],y.ivsalt=g[2]);var b=v.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));b&&(y.type=b[1]);var D=-1,C=0;v.indexOf(`\r \r `)!=-1&&(D=v.indexOf(`\r \r `),C=2),v.indexOf(` `)!=-1&&(D=v.indexOf(` `),C=1);var F=v.indexOf("-----END");if(D!=-1&&F!=-1){var U=v.substring(D+C*2,F-C);U=U.replace(/\s+/g,""),y.data=U}return y},p=function(v,y,g){for(var b=g.substring(0,16),D=Se.enc.Hex.parse(b),C=Se.enc.Utf8.parse(y),F=l[v].keylen+l[v].ivlen,U="",L=null;;){var S=Se.algo.MD5.create();if(L!=null&&S.update(L),S.update(C),S.update(D),L=S.finalize(),U=U+Se.enc.Hex.stringify(L),U.length>=F*2)break}var B={};return B.keyhex=U.substr(0,l[v].keylen*2),B.ivhex=U.substr(l[v].keylen*2,l[v].ivlen*2),B},h=function(v,y,g,b){var D=Se.enc.Base64.parse(v),C=Se.enc.Hex.stringify(D),F=l[y].proc,U=F(C,g,b);return U},w=function(v,y,g,b){var D=l[y].eproc,C=D(v,g,b);return C};return{version:"1.0.0",parsePKCS5PEM:function(v){return m(v)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(v,y,g){return p(v,y,g)},decryptKeyB64:function(v,y,g,b){return h(v,y,g,b)},getDecryptedKeyHex:function(v,y){var g=m(v),b=g.type,D=g.cipher,C=g.ivsalt,F=g.data,U=p(D,y,C),L=U.keyhex,S=h(F,D,L,C);return S},getEncryptedPKCS5PEMFromPrvKeyHex:function(v,y,g,b,D){var O="";if((typeof b>"u"||b==null)&&(b="AES-256-CBC"),typeof l[b]>"u")throw new Error("KEYUTIL unsupported algorithm: "+b);if(typeof D>"u"||D==null){var C=l[b].ivlen,F=d(C);D=F.toUpperCase()}var U=p(b,g,D),L=U.keyhex,S=w(y,b,L,D),B=S.replace(/(.{64})/g,`$1\r `),O="-----BEGIN "+v+` PRIVATE KEY-----\r `;return O+=`Proc-Type: 4,ENCRYPTED\r `,O+="DEK-Info: "+b+","+D+`\r `,O+=`\r `,O+=B,O+=`\r -----END `+v+` PRIVATE KEY-----\r `,O},getEncryptedPKCS8PEM:function(v,y,g){var b=this.getEncryptedPKCS8Hex(v,y,g);return Mn(b,"ENCRYPTED PRIVATE KEY")},getEncryptedPKCS8Hex:function(v,y,g){var b;g==null||g==null?b={}:b=JSON.parse(JSON.stringify(g)),b.plain=v,this.initPBES2Param(b),this.encryptPBES2Param(b,y);var D=this.generatePBES2ASN1Param(b);return A.asn1.ASN1Util.newObject(D).tohex()},initPBES2Param:function(v){if(tr(v,"encalg")==null&&(v.encalg="aes256-CBC"),tr(v,"iter")==null&&(v.iter=2048),tr(v,"prf")==null&&(v.prf="hmacWithSHA256"),tr(v,"salt")==null&&(v.salt=Se.enc.Hex.stringify(Se.lib.WordArray.random(8))),tr(v,"enciv")==null){var y;v.encalg=="des-EDE3-CBC"&&(y=8),v.encalg=="aes128-CBC"&&(y=16),v.encalg=="aes256-CBC"&&(y=16),v.enciv=Se.enc.Hex.stringify(Se.lib.WordArray.random(y))}},encryptPBES2Param:function(v,y){var g=Et.getDKFromPBES2Param(v,y);try{var b=A.crypto.Cipher.encrypt(v.plain,g,v.encalg,{iv:v.enciv})}catch{throw new Error("encrypt error: "+v.plain+" "+g+" "+v.encalg+" "+v.enciv)}v.enc=b},generatePBES2ASN1Param:function(v){var y={seq:[{seq:[{oid:"pkcs5PBES2"},{seq:[{seq:[{oid:"pkcs5PBKDF2"},{seq:[{octstr:{hex:v.salt}},{int:{hex:l_(v.iter)}}]}]},{seq:[{oid:v.encalg},{octstr:{hex:v.enciv}}]}]}]},{octstr:{hex:v.enc}}]};return v.prf!="hmacWithSHA1"&&y.seq[0].seq[1].seq[0].seq[1].seq.push({seq:[{oid:v.prf},{null:""}]}),y},parseHexOfEncryptedPKCS8:function(v){var y=ye,g=y.getChildIdx,b=y.getV,D={},C=g(v,0);if(C.length!=2)throw new Error("malformed format: SEQUENCE(0).items != 2: "+C.length);D.ciphertext=b(v,C[1]);var F=g(v,C[0]);if(F.length!=2)throw new Error("malformed format: SEQUENCE(0.0).items != 2: "+F.length);if(b(v,F[0])!="2a864886f70d01050d")throw new Error("this only supports pkcs5PBES2");var U=g(v,F[1]);if(F.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1).items != 2: "+U.length);var L=g(v,U[1]);if(L.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1.1).items != 2: "+L.length);if(b(v,L[0])!="2a864886f70d0307")throw"this only supports TripleDES";D.encryptionSchemeAlg="TripleDES",D.encryptionSchemeIV=b(v,L[1]);var S=g(v,U[0]);if(S.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1.0).items != 2: "+S.length);if(b(v,S[0])!="2a864886f70d01050c")throw new Error("this only supports pkcs5PBKDF2");var B=g(v,S[1]);if(B.length<2)throw new Error("malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+B.length);D.pbkdf2Salt=b(v,B[0]);var O=b(v,B[1]);try{D.pbkdf2Iter=parseInt(O,16)}catch{throw new Error("malformed format pbkdf2Iter: "+O)}return D},getPBKDF2KeyHexFromParam:function(v,y){var g=Se.enc.Hex.parse(v.pbkdf2Salt),b=v.pbkdf2Iter,D=Se.PBKDF2(y,g,{keySize:192/32,iterations:b}),C=Se.enc.Hex.stringify(D);return C},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(v,y){var g=br(v,"ENCRYPTED PRIVATE KEY"),b=this.parseHexOfEncryptedPKCS8(g),D=Et.getPBKDF2KeyHexFromParam(b,y),C={};C.ciphertext=Se.enc.Hex.parse(b.ciphertext);var F=Se.enc.Hex.parse(D),U=Se.enc.Hex.parse(b.encryptionSchemeIV),L=Se.TripleDES.decrypt(C,F,{iv:U}),S=Se.enc.Hex.stringify(L);return S},parsePBES2:function(v){var y=ye.parse(v);if(tr(y,"seq.0.seq.0.oid")!="pkcs5PBES2"||tr(y,"seq.0.seq.1.seq.0.seq.0.oid")!="pkcs5PBKDF2")throw new Error("not pkcs5PBES2 and pkcs5PBKDF2 used");var g=tr(y,"seq.0.seq.1.seq.0.seq.1.seq");if(g==null)throw new Error("PBKDF2 parameter not found");var b=tr(g,"0.octstr.hex"),D=tr(g,"1.int.hex"),C=tr(g,"2.seq.0.oid","hmacWithSHA1"),F=-1;try{F=parseInt(D,16)}catch{throw new Error("iter not proper value")}var U=tr(y,"seq.0.seq.1.seq.1.seq.0.oid"),L=tr(y,"seq.0.seq.1.seq.1.seq.1.octstr.hex"),S=tr(y,"seq.1.octstr.hex");if(U==null||L==null||S==null)throw new Error("encalg, enciv or enc is undefined");var B={salt:b,iter:F,prf:C,encalg:U,enciv:L,enc:S};return B},getDKFromPBES2Param:function(v,y){var g={hmacWithSHA1:Se.algo.SHA1,hmacWithSHA224:Se.algo.SHA224,hmacWithSHA256:Se.algo.SHA256,hmacWithSHA384:Se.algo.SHA384,hmacWithSHA512:Se.algo.SHA512},b={"des-EDE3-CBC":192/32,"aes128-CBC":128/32,"aes256-CBC":256/32},D=g[v.prf];if(D==null)throw new Error("unsupported prf");var C=b[v.encalg];if(C==null)throw new Error("unsupported encalg");var F=Se.enc.Hex.parse(v.salt),U=v.iter;try{var L=Se.PBKDF2(y,F,{keySize:C,iterations:U,hasher:D});return Se.enc.Hex.stringify(L)}catch(S){throw new Error("PBKDF2 error: "+S+" "+JSON.stringify(v)+" "+y)}},getPlainHexFromEncryptedPKCS8PEM:function(v,y){if(v.indexOf("BEGIN ENCRYPTED PRIVATE KEY")==-1)throw new Error("not Encrypted PKCS#8 PEM string");var g=br(v),b;try{b=Et.parsePBES2(g)}catch(C){throw new Error("malformed PBES2 format: "+C.message)}var D=Et.getDKFromPBES2Param(b,y);return A.crypto.Cipher.decrypt(b.enc,D,b.encalg,{iv:b.enciv})},getKeyFromEncryptedPKCS8PEM:function(v,y){var g=this.getPlainHexFromEncryptedPKCS8PEM(v,y),b=this.getKeyFromPlainPrivatePKCS8Hex(g);return b},parsePlainPrivatePKCS8Hex:function(v){var y=ye,g=y.getChildIdx,b=y.getV,D={};if(D.algparam=null,v.substr(0,2)!="30")throw new Error("malformed plain PKCS8 private key(code:001)");var C=g(v,0);if(C.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if(v.substr(C[1],2)!="30")throw new Error("malformed PKCS8 private key(code:003)");var F=g(v,C[1]);if(F.length!=2)throw new Error("malformed PKCS8 private key(code:004)");if(v.substr(F[0],2)!="06")throw new Error("malformed PKCS8 private key(code:005)");if(D.algoid=b(v,F[0]),v.substr(F[1],2)=="06"&&(D.algparam=b(v,F[1])),v.substr(C[2],2)!="04")throw new Error("malformed PKCS8 private key(code:006)");return D.keyidx=y.getVidx(v,C[2]),D},getKeyFromPlainPrivatePKCS8PEM:function(v){var y=br(v,"PRIVATE KEY"),g=this.getKeyFromPlainPrivatePKCS8Hex(y);return g},getKeyFromPlainPrivatePKCS8Hex:function(v){var y=this.parsePlainPrivatePKCS8Hex(v),g;if(y.algoid=="2a864886f70d010101")g=new et;else if(y.algoid=="2a8648ce380401")g=new A.crypto.DSA;else if(y.algoid=="2a8648ce3d0201")g=new A.crypto.ECDSA;else throw new Error("unsupported private key algorithm");return g.readPKCS8PrvKeyHex(v),g},_getKeyFromPublicPKCS8Hex:function(v){var y,g=ye.getVbyList(v,0,[0,0],"06");if(g==="2a864886f70d010101")y=new et;else if(g==="2a8648ce380401")y=new A.crypto.DSA;else if(g==="2a8648ce3d0201")y=new A.crypto.ECDSA;else throw new Error("unsupported PKCS#8 public key hex");return y.readPKCS8PubKeyHex(v),y},parsePublicRawRSAKeyHex:function(v){var y=ye,g=y.getChildIdx,b=y.getV,D={};if(v.substr(0,2)!="30")throw new Error("malformed RSA key(code:001)");var C=g(v,0);if(C.length!=2)throw new Error("malformed RSA key(code:002)");if(v.substr(C[0],2)!="02")throw new Error("malformed RSA key(code:003)");if(D.n=b(v,C[0]),v.substr(C[1],2)!="02")throw new Error("malformed RSA key(code:004)");return D.e=b(v,C[1]),D},parsePublicPKCS8Hex:function(v){var y=ye,g=y.getChildIdx,b=y.getV,D={};D.algparam=null;var C=g(v,0);if(C.length!=2)throw new Error("outer DERSequence shall have 2 elements: "+C.length);var F=C[0];if(v.substr(F,2)!="30")throw new Error("malformed PKCS8 public key(code:001)");var U=g(v,F);if(U.length!=2)throw new Error("malformed PKCS8 public key(code:002)");if(v.substr(U[0],2)!="06")throw new Error("malformed PKCS8 public key(code:003)");if(D.algoid=b(v,U[0]),v.substr(U[1],2)=="06"?D.algparam=b(v,U[1]):v.substr(U[1],2)=="30"&&(D.algparam={},D.algparam.p=y.getVbyList(v,U[1],[0],"02"),D.algparam.q=y.getVbyList(v,U[1],[1],"02"),D.algparam.g=y.getVbyList(v,U[1],[2],"02")),v.substr(C[1],2)!="03")throw new Error("malformed PKCS8 public key(code:004)");return D.key=b(v,C[1]).substr(2),D}}}();Et.getKey=function(e,t,r){var n=ye,i=n.getChildIdx,a=n.getV,s=n.getVbyList,u=A.crypto,l=u.ECDSA,f=u.DSA,d=et,m=br,p=Et;if(typeof d<"u"&&e instanceof d||typeof l<"u"&&e instanceof l||typeof f<"u"&&e instanceof f)return e;if(e.curve!==void 0&&e.xy!==void 0&&e.d===void 0)return new l({pub:e.xy,curve:e.curve});if(e.curve!==void 0&&e.d!==void 0)return new l({prv:e.d,curve:e.curve});if(e.kty===void 0&&e.n!==void 0&&e.e!==void 0&&e.d===void 0){var h=new d;return h.setPublic(e.n,e.e),h}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 h=new d;return h.setPrivateEx(e.n,e.e,e.d,e.p,e.q,e.dp,e.dq,e.co),h}if(e.kty===void 0&&e.n!==void 0&&e.e!==void 0&&e.d!==void 0&&e.p===void 0){var h=new d;return h.setPrivate(e.n,e.e,e.d),h}if(e.p!==void 0&&e.q!==void 0&&e.g!==void 0&&e.y!==void 0&&e.x===void 0){var h=new f;return h.setPublic(e.p,e.q,e.g,e.y),h}if(e.p!==void 0&&e.q!==void 0&&e.g!==void 0&&e.y!==void 0&&e.x!==void 0){var h=new f;return h.setPrivate(e.p,e.q,e.g,e.y,e.x),h}if(e.kty==="RSA"&&e.n!==void 0&&e.e!==void 0&&e.d===void 0){var h=new d;return h.setPublic(dr(e.n),dr(e.e)),h}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 h=new d;return h.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)),h}if(e.kty==="RSA"&&e.n!==void 0&&e.e!==void 0&&e.d!==void 0){var h=new d;return h.setPrivate(dr(e.n),dr(e.e),dr(e.d)),h}if(e.kty==="EC"&&e.crv!==void 0&&e.x!==void 0&&e.y!==void 0&&e.d===void 0){var w=new l({curve:e.crv}),v=w.ecparams.keycharlen,y=("0000000000"+dr(e.x)).slice(-v),g=("0000000000"+dr(e.y)).slice(-v),b="04"+y+g;return w.setPublicKeyHex(b),w}if(e.kty==="EC"&&e.crv!==void 0&&e.x!==void 0&&e.y!==void 0&&e.d!==void 0){var w=new l({curve:e.crv}),v=w.ecparams.keycharlen,y=("0000000000"+dr(e.x)).slice(-v),g=("0000000000"+dr(e.y)).slice(-v),b="04"+y+g,D=("0000000000"+dr(e.d)).slice(-v);return w.setPublicKeyHex(b),w.setPrivateKeyHex(D),w}if(r==="pkcs5prv"){var C=e,n=ye,F,h;if(F=i(C,0),F.length===9)h=new d,h.readPKCS5PrvKeyHex(C);else if(F.length===6)h=new f,h.readPKCS5PrvKeyHex(C);else if(F.length>2&&C.substr(F[1],2)==="04")h=new l,h.readPKCS5PrvKeyHex(C);else throw new Error("unsupported PKCS#1/5 hexadecimal key");return h}if(r==="pkcs8prv"){var h=p.getKeyFromPlainPrivatePKCS8Hex(e);return h}if(r==="pkcs8pub")return p._getKeyFromPublicPKCS8Hex(e);if(r==="x509pub")return Ge.getPublicKeyFromCertHex(e);if(e.indexOf("-END CERTIFICATE-",0)!=-1||e.indexOf("-END X509 CERTIFICATE-",0)!=-1||e.indexOf("-END TRUSTED CERTIFICATE-",0)!=-1)return Ge.getPublicKeyFromCertPEM(e);if(e.indexOf("-END PUBLIC KEY-")!=-1){var U=br(e,"PUBLIC KEY");return p._getKeyFromPublicPKCS8Hex(U)}if(e.indexOf("-END RSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")==-1){var L=m(e,"RSA PRIVATE KEY");return p.getKey(L,null,"pkcs5prv")}if(e.indexOf("-END DSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")==-1){var S=m(e,"DSA PRIVATE KEY"),B=s(S,0,[1],"02"),O=s(S,0,[2],"02"),x=s(S,0,[3],"02"),j=s(S,0,[4],"02"),Y=s(S,0,[5],"02"),h=new f;return h.setPrivate(new ee(B,16),new ee(O,16),new ee(x,16),new ee(j,16),new ee(Y,16)),h}if(e.indexOf("-END EC PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")==-1){var L=m(e,"EC PRIVATE KEY");return p.getKey(L,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 M=p.getDecryptedKeyHex(e,t),z=new et;return z.readPKCS5PrvKeyHex(M),z}if(e.indexOf("-END EC PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")!=-1){var S=p.getDecryptedKeyHex(e,t),h=s(S,0,[1],"04"),W=s(S,0,[2,0],"06"),ie=s(S,0,[3,0],"03").substr(2),Ce="";if(A.crypto.OID.oidhex2name[W]!==void 0)Ce=A.crypto.OID.oidhex2name[W];else throw new Error("undefined OID(hex) in KJUR.crypto.OID: "+W);var w=new l({curve:Ce});return w.setPublicKeyHex(ie),w.setPrivateKeyHex(h),w.isPublic=!1,w}if(e.indexOf("-END DSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")!=-1){var S=p.getDecryptedKeyHex(e,t),B=s(S,0,[1],"02"),O=s(S,0,[2],"02"),x=s(S,0,[3],"02"),j=s(S,0,[4],"02"),Y=s(S,0,[5],"02"),h=new f;return h.setPrivate(new ee(B,16),new ee(O,16),new ee(x,16),new ee(j,16),new ee(Y,16)),h}if(e.indexOf("-END ENCRYPTED PRIVATE KEY-")!=-1)return p.getKeyFromEncryptedPKCS8PEM(e,t);throw new Error("not supported argument")};Et.generateKeypair=function(e,t){if(e=="RSA"){var r=t,n=new et;n.generate(r,"10001"),n.isPrivate=!0,n.isPublic=!0;var i=new et,a=n.n.toString(16),s=n.e.toString(16);i.setPublic(a,s),i.isPrivate=!1,i.isPublic=!0;var u={};return u.prvKeyObj=n,u.pubKeyObj=i,u}else if(e=="EC"){var l=t,f=new A.crypto.ECDSA({curve:l}),d=f.generateKeyPairHex(),n=new A.crypto.ECDSA({curve:l});n.setPublicKeyHex(d.ecpubhex),n.setPrivateKeyHex(d.ecprvhex),n.isPrivate=!0,n.isPublic=!1;var i=new A.crypto.ECDSA({curve:l});i.setPublicKeyHex(d.ecpubhex),i.isPrivate=!1,i.isPublic=!0;var u={};return u.prvKeyObj=n,u.pubKeyObj=i,u}else throw new Error("unknown algorithm: "+e)};Et.getPEM=function(e,t,r,n,i,a){var s=A,u=s.asn1,l=u.DERObjectIdentifier,f=u.DERInteger,d=u.ASN1Util.newObject,m=u.x509,p=m.SubjectPublicKeyInfo,h=s.crypto,w=h.DSA,v=h.ECDSA,y=et;function g(z){var W=d({seq:[{int:0},{int:{bigint:z.n}},{int:z.e},{int:{bigint:z.d}},{int:{bigint:z.p}},{int:{bigint:z.q}},{int:{bigint:z.dmp1}},{int:{bigint:z.dmq1}},{int:{bigint:z.coeff}}]});return W}function b(z){var W=d({seq:[{int:1},{octstr:{hex:z.prvKeyHex}},{tag:["a0",!0,{oid:{name:z.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+z.pubKeyHex}}]}]});return W}function D(z){var W=d({seq:[{int:0},{int:{bigint:z.p}},{int:{bigint:z.q}},{int:{bigint:z.g}},{int:{bigint:z.y}},{int:{bigint:z.x}}]});return W}if((y!==void 0&&e instanceof y||w!==void 0&&e instanceof w||v!==void 0&&e instanceof v)&&e.isPublic==!0&&(t===void 0||t=="PKCS8PUB")){var C=new p(e),F=C.tohex();return Mn(F,"PUBLIC KEY")}if(t=="PKCS1PRV"&&y!==void 0&&e instanceof y&&(r===void 0||r==null)&&e.isPrivate==!0){var C=g(e),F=C.tohex();return Mn(F,"RSA PRIVATE KEY")}if(t=="PKCS1PRV"&&v!==void 0&&e instanceof v&&(r===void 0||r==null)&&e.isPrivate==!0){var U=new l({name:e.curveName}),L=U.tohex(),S=b(e),B=S.tohex(),O="";return O+=Mn(L,"EC PARAMETERS"),O+=Mn(B,"EC PRIVATE KEY"),O}if(t=="PKCS1PRV"&&w!==void 0&&e instanceof w&&(r===void 0||r==null)&&e.isPrivate==!0){var C=D(e),F=C.tohex();return Mn(F,"DSA PRIVATE KEY")}if(t=="PKCS5PRV"&&y!==void 0&&e instanceof y&&r!==void 0&&r!=null&&e.isPrivate==!0){var C=g(e),F=C.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",F,r,n,a)}if(t=="PKCS5PRV"&&v!==void 0&&e instanceof v&&r!==void 0&&r!=null&&e.isPrivate==!0){var C=b(e),F=C.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",F,r,n,a)}if(t=="PKCS5PRV"&&w!==void 0&&e instanceof w&&r!==void 0&&r!=null&&e.isPrivate==!0){var C=D(e),F=C.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",F,r,n,a)}var x=function(z,W){if(typeof W=="string")return Et.getEncryptedPKCS8PEM(z,W);if(typeof W=="object"&&tr(W,"passcode")!=null){var ie=JSON.parse(JSON.stringify(W)),Ce=ie.passcode;return delete ie.passcode,Et.getEncryptedPKCS8PEM(z,Ce,ie)}};if(t=="PKCS8PRV"&&y!=null&&e instanceof y&&e.isPrivate==!0){var j=g(e),Y=j.tohex(),C=d({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:Y}}]}),F=C.tohex();return r===void 0||r==null?Mn(F,"PRIVATE KEY"):x(F,r)}if(t=="PKCS8PRV"&&v!==void 0&&e instanceof v&&e.isPrivate==!0){var M={seq:[{int:1},{octstr:{hex:e.prvKeyHex}}]};typeof e.pubKeyHex=="string"&&M.seq.push({tag:["a1",!0,{bitstr:{hex:"00"+e.pubKeyHex}}]});var j=new d(M),Y=j.tohex(),C=d({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:e.curveName}}]},{octstr:{hex:Y}}]}),F=C.tohex();return r===void 0||r==null?Mn(F,"PRIVATE KEY"):x(F,r)}if(t=="PKCS8PRV"&&w!==void 0&&e instanceof w&&e.isPrivate==!0){var j=new f({bigint:e.x}),Y=j.tohex(),C=d({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.g}}]}]},{octstr:{hex:Y}}]}),F=C.tohex();return r===void 0||r==null?Mn(F,"PRIVATE KEY"):x(F,r)}throw new Error("unsupported object nor format")};Et.getKeyFromCSRPEM=function(e){var t=br(e,"CERTIFICATE REQUEST"),r=Et.getKeyFromCSRHex(t);return r};Et.getKeyFromCSRHex=function(e){var t=Et.parseCSRHex(e),r=Et.getKey(t.p8pubkeyhex,null,"pkcs8pub");return r};Et.parseCSRHex=function(e){var t=ye,r=t.getChildIdx,n=t.getTLV,i={},a=e;if(a.substr(0,2)!="30")throw new Error("malformed CSR(code:001)");var s=r(a,0);if(s.length<1)throw new Error("malformed CSR(code:002)");if(a.substr(s[0],2)!="30")throw new Error("malformed CSR(code:003)");var u=r(a,s[0]);if(u.length<3)throw new Error("malformed CSR(code:004)");return i.p8pubkeyhex=n(a,u[2]),i};Et.getKeyID=function(e){var t=Et,r=ye;typeof e=="string"&&e.indexOf("BEGIN ")!=-1&&(e=t.getKey(e));var n=br(t.getPEM(e)),i=r.getIdxbyList(n,0,[1]),a=r.getV(n,i).substring(2);return A.crypto.Util.hashHex(a,"sha1")};Et.getJWK=function(e,t,r,n,i){var a,s={},u,l=A.crypto.Util.hashHex;if(typeof e=="string")a=Et.getKey(e),e.indexOf("CERTIFICATE")!=-1&&(u=br(e));else if(typeof e=="object")e instanceof Ge?(a=e.getPublicKey(),u=e.hex):a=e;else throw new Error("unsupported keyinfo type");if(a instanceof et&&a.isPrivate)s.kty="RSA",s.n=Zr(a.n.toString(16)),s.e=Zr(a.e.toString(16)),s.d=Zr(a.d.toString(16)),s.p=Zr(a.p.toString(16)),s.q=Zr(a.q.toString(16)),s.dp=Zr(a.dmp1.toString(16)),s.dq=Zr(a.dmq1.toString(16)),s.qi=Zr(a.coeff.toString(16));else if(a instanceof et&&a.isPublic)s.kty="RSA",s.n=Zr(a.n.toString(16)),s.e=Zr(a.e.toString(16));else if(a instanceof A.crypto.ECDSA&&a.isPrivate){var f=a.getShortNISTPCurveName();if(f!=="P-256"&&f!=="P-384"&&f!=="P-521")throw new Error("unsupported curve name for JWT: "+f);var d=a.getPublicKeyXYHex();s.kty="EC",s.crv=f,s.x=Zr(d.x),s.y=Zr(d.y),s.d=Zr(a.prvKeyHex)}else if(a instanceof A.crypto.ECDSA&&a.isPublic){var f=a.getShortNISTPCurveName();if(f!=="P-256"&&f!=="P-384"&&f!=="P-521")throw new Error("unsupported curve name for JWT: "+f);var d=a.getPublicKeyXYHex();s.kty="EC",s.crv=f,s.x=Zr(d.x),s.y=Zr(d.y)}if(s.kty==null)throw new Error("unsupported keyinfo");return!a.isPrivate&&t!=!0&&(s.kid=A.jws.JWS.getJWKthumbprint(s)),u!=null&&r!=!0&&(s.x5c=[ru(u)]),u!=null&&n!=!0&&(s.x5t=uc(ru(l(u,"sha1")))),u!=null&&i!=!0&&(s["x5t#S256"]=uc(ru(l(u,"sha256")))),s};Et.getJWKFromKey=function(e){return Et.getJWK(e,!0,!0,!0,!0)};et.getPosArrayOfChildrenFromHex=function(e){return ye.getChildIdx(e,0)};et.getHexValueArrayOfChildrenFromHex=function(e){var t=ye,r=t.getV,p=et.getPosArrayOfChildrenFromHex(e),n=r(e,p[0]),i=r(e,p[1]),a=r(e,p[2]),s=r(e,p[3]),u=r(e,p[4]),l=r(e,p[5]),f=r(e,p[6]),d=r(e,p[7]),m=r(e,p[8]),p=new Array;return p.push(n,i,a,s,u,l,f,d,m),p};et.prototype.readPrivateKeyFromPEMString=function(e){var t=br(e),r=et.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8])};et.prototype.readPKCS5PrvKeyHex=function(e){var t=et.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])};et.prototype.readPKCS8PrvKeyHex=function(e){var t,r,n,i,a,s,u,l,f=ye,d=f.getVbyListEx;if(f.isASN1HEX(e)===!1)throw new Error("not ASN.1 hex string");try{t=d(e,0,[2,0,1],"02"),r=d(e,0,[2,0,2],"02"),n=d(e,0,[2,0,3],"02"),i=d(e,0,[2,0,4],"02"),a=d(e,0,[2,0,5],"02"),s=d(e,0,[2,0,6],"02"),u=d(e,0,[2,0,7],"02"),l=d(e,0,[2,0,8],"02")}catch{throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(t,r,n,i,a,s,u,l)};et.prototype.readPKCS5PubKeyHex=function(e){var t=ye,r=t.getV;if(t.isASN1HEX(e)===!1)throw new Error("keyHex is not ASN.1 hex string");var n=t.getChildIdx(e,0);if(n.length!==2||e.substr(n[0],2)!=="02"||e.substr(n[1],2)!=="02")throw new Error("wrong hex for PKCS#5 public key");var i=r(e,n[0]),a=r(e,n[1]);this.setPublic(i,a)};et.prototype.readPKCS8PubKeyHex=function(e){var t=ye;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)};et.prototype.readCertPubKeyHex=function(e,t){var r,n;r=new Ge,r.readCertHex(e),n=r.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)};var sY=new RegExp("[^0-9a-f]","gi");function d_(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}et.prototype.signPSS=function(e,t,r){var n=function(a){return A.crypto.Util.hashHex(a,t)},i=n(ca(e));return r===void 0&&(r=-1),this.signWithMessageHashPSS(i,t,r)};et.prototype.signWithMessageHashPSS=function(e,t,r){var n=Di(e),i=n.length,a=this.n.bitLength()-1,s=Math.ceil(a/8),u,l=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&&(f=new Array(r),new fc().nextBytes(f),f=String.fromCharCode.apply(String,f));var d=Di(l(ca("\0\0\0\0\0\0\0\0"+n+f))),m=[];for(u=0;u>8*s-a&255;for(w[0]&=~v,u=0;un)return!1;var i=this.doPublic(r),a=i.toString(16);if(a.length+3!=n/4)return!1;var s=a.replace(/^1f+00/,""),u=g_(s);if(u.length==0)return!1;var l=u[0],f=u[1],d=function(p){return A.crypto.Util.hashString(p,l)},m=d(e);return f==m};et.prototype.verifyWithMessageHash=function(e,t){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var r=_i(t,16);if(r.bitLength()>this.n.bitLength())return 0;var n=this.doPublic(r),i=n.toString(16).replace(/^1f+00/,""),a=g_(i);if(a.length==0)return!1;var s=a[0],u=a[1];return u==e};et.prototype.verifyPSS=function(e,t,r,n){var i=function(s){return A.crypto.Util.hashHex(s,r)},a=i(ca(e));return n===void 0&&(n=-1),this.verifyWithMessageHashPSS(a,t,r,n)};et.prototype.verifyWithMessageHashPSS=function(e,t,r,n){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var i=new ee(t,16),a=function(b){return A.crypto.Util.hashHex(b,r)},s=Di(e),u=s.length,l=this.n.bitLength()-1,f=Math.ceil(l/8),d;if(n===-1||n===void 0)n=u;else if(n===-2)n=f-u-2;else if(n<-2)throw new Error("invalid salt length");if(f>8*f-l&255;if(p.charCodeAt(0)&w)throw new Error("bits beyond keysize not zero");var v=p_(h,p.length,a),y=[];for(d=0;d0?B:void 0}catch{return}},this._asn1ToNoticeRef=function(S){try{for(var B={},O=tr(S,"seq"),x=0;x0?B:void 0}catch{return}},this._asn1ToNoticeNum=function(S){try{for(var B=tr(S,"seq"),O=[],x=0;x1){var Y=s(S,j[1]),M=this.getGeneralName(Y);M.uri!=null&&(x.uri=M.uri)}if(j.length>2){var z=s(S,j[2]);z=="0101ff"&&(x.reqauth=!0),z=="010100"&&(x.reqauth=!1)}return x},this.getExtSubjectDirectoryAttributes=function(S,B){if(S===void 0&&B===void 0){var O=this.getExtInfo("subjectDirectoryAttributes");if(O===void 0)return;S=s(this.hex,O.vidx),B=O.critical}var x={extname:"subjectDirectoryAttributes"};B&&(x.critical=!0);try{for(var j=a(S),Y=[],M=0;M0&&(B.ext=this.getExtParamArray()),B.sighex=this.getSignatureValueHex(),S.tbshex==!0&&(B.tbshex=f(this.hex,0,[0])),S.nodnarray==!0&&(delete B.issuer.array,delete B.subject.array),B},this.getExtParamArray=function(S){if(S==null){var B=p(this.hex,0,[0,"[3]"]);B!=-1&&(S=d(this.hex,0,[0,"[3]",0],"30"))}for(var O=[],x=r(S,0),j=0;j"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 a=n.match(/^([^.]+)\.([^.]+)\.([^.]+)$/);if(a==null)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";var s=a[1],u=a[2],l=a[3],f=s+"."+u;if(this.parsedJWS={},this.parsedJWS.headB64U=s,this.parsedJWS.payloadB64U=u,this.parsedJWS.sigvalB64U=l,this.parsedJWS.si=f,!i){var d=dr(l),m=_i(d,16);this.parsedJWS.sigvalH=d,this.parsedJWS.sigvalBI=m}var p=Bs(s),h=Bs(u);if(this.parsedJWS.headS=p,this.parsedJWS.payloadS=h,!r(p,this.parsedJWS,"headP"))throw"malformed JSON string for JWS Head: "+p}}};A.jws.JWS.sign=function(e,t,r,n,i){var a=A,s=a.jws,u=s.JWS,l=u.readSafeJSONString,f=u.isSafeJSONString,d=a.crypto,m=d.ECDSA,p=d.Mac,h=d.Signature,w=JSON,v,y,g;if(typeof t!="string"&&typeof t!="object")throw"spHeader must be JSON string or object: "+t;if(typeof t=="object"&&(y=t,v=w.stringify(y)),typeof t=="string"){if(v=t,!f(v))throw"JWS Head is not safe JSON string: "+v;y=l(v)}if(g=r,typeof r=="object"&&(g=w.stringify(r)),(e==""||e==null)&&y.alg!==void 0&&(e=y.alg),e!=""&&e!=null&&y.alg===void 0&&(y.alg=e,v=w.stringify(y)),e!==y.alg)throw"alg and sHeader.alg doesn't match: "+e+"!="+y.alg;var b=null;if(u.jwsalg2sigalg[e]===void 0)throw"unsupported alg name: "+e;b=u.jwsalg2sigalg[e];var D=xf(v),C=xf(g),F=D+"."+C,U="";if(b.substr(0,4)=="Hmac"){if(n===void 0)throw"mac key shall be specified for HS* alg";var L=new p({alg:b,prov:"cryptojs",pass:n});L.updateString(F),U=L.doFinal()}else if(b.indexOf("withECDSA")!=-1){var S=new h({alg:b});S.init(n,i),S.updateString(F);var B=S.sign();U=A.crypto.ECDSA.asn1SigToConcatSig(B)}else if(b!="none"){var S=new h({alg:b});S.init(n,i),S.updateString(F),U=S.sign()}var O=Zr(U);return F+"."+O};A.jws.JWS.verify=function(e,t,r){var n=A,i=n.jws,a=i.JWS,s=a.readSafeJSONString,u=n.crypto,l=u.ECDSA,f=u.Mac,d=u.Signature,m;if(typeof et!==void 0&&(m=et),!cm(e))return!1;var p=e.split(".");if(p.length!==3)return!1;var h=p[0],w=p[1],v=h+"."+w,y=dr(p[2]),g=s(Bs(p[0])),b=null,D=null;if(g.alg===void 0)throw"algorithm not specified in header";if(b=g.alg,D=b.substr(0,2),r!=null&&Object.prototype.toString.call(r)==="[object Array]"&&r.length>0){var C=":"+r.join(":")+":";if(C.indexOf(":"+b+":")==-1)throw"algorithm '"+b+"' not accepted in the list"}if(b!="none"&&t===null)throw"key shall be specified to verify.";if(typeof t=="string"&&t.indexOf("-----BEGIN ")!=-1&&(t=Et.getKey(t)),(D=="RS"||D=="PS")&&!(t instanceof m))throw"key shall be a RSAKey obj for RS* and PS* algs";if(D=="ES"&&!(t instanceof l))throw"key shall be a ECDSA obj for ES* algs";b=="none";var F=null;if(a.jwsalg2sigalg[g.alg]===void 0)throw"unsupported alg name: "+b;if(F=a.jwsalg2sigalg[b],F=="none")throw"not supported";if(F.substr(0,4)=="Hmac"){var U=null;if(t===void 0)throw"hexadecimal key shall be specified for HMAC";var L=new f({alg:F,pass:t});return L.updateString(v),U=L.doFinal(),y==U}else if(F.indexOf("withECDSA")!=-1){var S=null;try{S=l.concatSigToASN1Sig(y)}catch{return!1}var B=new d({alg:F});return B.init(t),B.updateString(v),B.verify(S)}else{var B=new d({alg:F});return B.init(t),B.updateString(v),B.verify(y)}};A.jws.JWS.parse=function(e){var t=e.split("."),r={},n,i,a;if(t.length!=2&&t.length!=3)throw"malformed sJWS: wrong number of '.' splitted elements";return n=t[0],i=t[1],t.length==3&&(a=t[2]),r.headerObj=A.jws.JWS.readSafeJSONString(Bs(n)),r.payloadObj=A.jws.JWS.readSafeJSONString(Bs(i)),r.headerPP=JSON.stringify(r.headerObj,null," "),r.payloadObj==null?r.payloadPP=Bs(i):r.payloadPP=JSON.stringify(r.payloadObj,null," "),a!==void 0&&(r.sigHex=dr(a)),r};A.jws.JWS.verifyJWT=function(e,t,r){var n=A,i=n.jws,a=i.JWS,s=a.readSafeJSONString,u=a.inArray,l=a.includedArray;if(!cm(e))return!1;var f=e.split(".");if(f.length!=3)return!1;var d=f[0],m=f[1],p=d+"."+m,h=dr(f[2]),w=s(Bs(d)),v=s(Bs(m));if(w.alg===void 0)return!1;if(r.alg===void 0)throw"acceptField.alg shall be specified";if(!u(w.alg,r.alg)||v.iss!==void 0&&typeof r.iss=="object"&&!u(v.iss,r.iss)||v.sub!==void 0&&typeof r.sub=="object"&&!u(v.sub,r.sub))return!1;if(v.aud!==void 0&&typeof r.aud=="object"){if(typeof v.aud=="string"){if(!u(v.aud,r.aud))return!1}else if(typeof v.aud=="object"&&!l(v.aud,r.aud))return!1}var y=i.IntDate.getNow();return r.verifyAt!==void 0&&typeof r.verifyAt=="number"&&(y=r.verifyAt),(r.gracePeriod===void 0||typeof r.gracePeriod!="number")&&(r.gracePeriod=0),!(v.exp!==void 0&&typeof v.exp=="number"&&v.exp+r.gracePeriod"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 a=i.split(".");if(a.length!=3)throw"malformed input JWS";this.aHeader.push(a[0]),this.sPayload=a[1],this.aSignature.push(a[2])},this.addSignature=function(i,a,s,u){if(this.sPayload===void 0||this.sPayload===null)throw"there's no JSON-JS signature to add.";var l=this.aHeader.length;if(this.aHeader.length!=this.aSignature.length)throw"aHeader.length != aSignature.length";try{var f=A.jws.JWS.sign(i,a,this.sPayload,s,u),d=f.split("."),m=d[0],p=d[2];this.aHeader.push(d[0]),this.aSignature.push(d[2])}catch(h){throw this.aHeader.length>l&&this.aHeader.pop(),this.aSignature.length>l&&this.aSignature.pop(),"addSignature failed: "+h}},this.verifyAll=function(i){if(this.aHeader.length!==i.length||this.aSignature.length!==i.length)return!1;for(var a=0;a0)this.aHeader=i.headers;else throw"malformed header";if(typeof i.payload=="string")this.sPayload=i.payload;else throw"malformed signatures";if(i.signatures.length>0)this.aSignature=i.signatures;else throw"malformed signatures"}catch(s){throw"malformed JWS-JS JSON object: "+s}},this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}},this.isEmpty=function(){return this.aHeader.length==0?1:0}};_e.SecureRandom=fc;_e.rng_seed_time=sm;_e.BigInteger=ee;_e.RSAKey=et;_e.ECDSA=A.crypto.ECDSA;_e.DSA=A.crypto.DSA;_e.Signature=A.crypto.Signature;_e.MessageDigest=A.crypto.MessageDigest;_e.Mac=A.crypto.Mac;_e.KEYUTIL=Et;_e.ASN1HEX=ye;_e.X509=Ge;_e.X509CRL=tk;_e.CryptoJS=Se;_e.b64tohex=oc;_e.b64toBA=Xy;_e.ECFieldElementFp=Qr;_e.ECPointFp=Lt;_e.ECCurveFp=nu;_e.stoBA=r_;_e.BAtos=n_;_e.BAtohex=yd;_e.stohex=Ci;_e.stob64=OO;_e.stob64u=kO;_e.b64utos=NO;_e.b64tob64u=uc;_e.b64utob64=Tf;_e.hex2b64=ru;_e.hextob64u=Zr;_e.b64utohex=dr;_e.utf8tob64u=xf;_e.b64utoutf8=Bs;_e.utf8tob64=LO;_e.b64toutf8=UO;_e.utf8tohex=_d;_e.hextoutf8=Gt;_e.hextorstr=Di;_e.rstrtohex=ca;_e.hextob64=am;_e.hextob64nl=MO;_e.b64nltohex=i_;_e.hextopem=Mn;_e.pemtohex=br;_e.hextoArrayBuffer=KO;_e.ArrayBuffertohex=zO;_e.zulutomsec=um;_e.msectozulu=GO;_e.zulutosec=s_;_e.zulutodate=YO;_e.datetozulu=WO;_e.uricmptohex=Dd;_e.hextouricmp=Fd;_e.ipv6tohex=Qg;_e.hextoipv6=em;_e.hextoip=vd;_e.iptohex=om;_e.ucs2hextoutf8=lm;_e.encodeURIComponentAll=Sd;_e.newline_toUnix=XO;_e.newline_toDos=JO;_e.hextoposhex=tm;_e.intarystrtohex=ZO;_e.strdiffidx=QO;_e.oidtohex=o_;_e.hextooid=Id;_e.strpad=wd;_e.bitstrtoint=c_;_e.inttobitstr=f_;_e.bitstrtobinstr=h_;_e.binstrtobitstr=ek;_e.isBase64URLDot=cm;_e.namearraytobinstr=Ad;_e.extendClass=pe;_e.foldnl=Cd;_e.b64topem=qO;_e.pemtob64=VO;_e.timeogen=a_;_e.aryval=tr;_e.inttohex=l_;_e.twoscompl=Of;_e.KJUR=A;_e.crypto=A.crypto;_e.asn1=A.asn1;_e.jws=A.jws;_e.lang=A.lang;_e.VERSION=cR;_e.VERSION_FULL=fR});var A_=he(dm=>{"use strict";dm.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};dm.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 E_=he(pm=>{"use strict";pm.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};pm.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 b_=he(gm=>{"use strict";gm.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};gm.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 y_=he(mm=>{"use strict";mm.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};mm.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 __=he(vm=>{"use strict";vm.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}`};vm.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 F_=he((D_,wm)=>{var C_=function(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.decode=m,e.encode=d,e.familyOf=f,e.name=void 0,e.sizeOf=l,e.v6=e.v4=void 0;let t=/^(\d{1,3}\.){3,3}\d{1,3}$/,r=4,n=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,i=16,a={name:"v4",size:r,isFormat:p=>t.test(p),encode(p,h,w){w=~~w,h=h||new Uint8Array(w+r);let v=p.length,y=0;for(let g=0;gp.length>0&&n.test(p),encode(p,h,w){w=~~w;let v=w+i,y=-1,g=0,b=0,D=!0,C=!1;h=h||new Uint8Array(w+i);for(let F=0;F>8),w=97?U-=87:U>=65?U-=55:(U-=48,b=b*10+U),g=(g<<4)+U)}if(D===!1)C===!0?(w>8),w=y+2;F--)h[F]=h[F-2];h[y]=0,h[y+1]=0,y=w}if(y!==w&&y!==-1)for(w>v-2&&(w=v-2);v>y;)h[--v]=wy?h[--w]:0;else for(;w{"use strict";var He=gd().Buffer,du=A_(),nk=E_(),ik=b_(),xd=y_(),Am=__(),Zo=F_(),sk=0,S_=32768,Em=32768,ak=~Em,I_=32768,uk=~I_,$e=je.name={};$e.encode=function(e,t,r,{mail:n=!1}={}){t||(t=He.alloc($e.encodingLength(e))),r||(r=0);let i=r,a=e.replace(/^\.|\.$/gm,"");if(a.length){let s=[];if(n){let u="";a.split(".").forEach(l=>{l.endsWith("\\")?u+=(u.length?".":"")+l.slice(0,-1):s.length===0&&u.length?s.push(u+"."+l):s.push(l)})}else s=a.split(".");for(let u=0;u=e.length)throw new Error("Cannot decode name (buffer overflow)");let l=e[t++];if(s+=u?0:1,l===0)break;if(l&192)if((l&192)===192){if(t+1>e.length)throw new Error("Cannot decode name (buffer overflow)");let f=e.readUInt16BE(t-1)-49152;if(f>=i)throw new Error("Cannot decode name (bad pointer)");t=f,i=f,s+=u?0:1,u=!0}else throw new Error("Cannot decode name (bad label)");else{if(t+l>e.length)throw new Error("Cannot decode name (buffer overflow)");if(a+=l+1,a>254)throw new Error("Cannot decode name (name too long)");let f=e.toString("utf-8",t,t+l);r&&(f=f.replace(/\./g,"\\.")),n.push(f),t+=l,s+=u?0:l}}return $e.decode.bytes=s,n.length===0?".":n.join(".")};$e.decode.bytes=0;$e.encodingLength=function(e){return e==="."||e===".."?1:He.byteLength(e.replace(/^\.|\.$/gm,""))+2};var At={};At.encode=function(e,t,r){t||(t=He.alloc(At.encodingLength(e))),r||(r=0);let n=t.write(e,r+1);return t[r]=n,At.encode.bytes=n+1,t};At.encode.bytes=0;At.decode=function(e,t){t||(t=0);let r=e[t],n=e.toString("utf-8",t+1,t+1+r);return At.decode.bytes=r+1,n};At.decode.bytes=0;At.encodingLength=function(e){return He.byteLength(e)+1};var xs={};xs.encode=function(e,t,r){t||(t=xs.encodingLength(e)),r||(r=0);let n=(e.flags||0)&32767,i=e.type==="response"?S_:sk;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};xs.encode.bytes=12;xs.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&S_?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:ik.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:nk.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))}};xs.decode.bytes=12;xs.encodingLength=function(){return 12};var iu=je.unknown={};iu.encode=function(e,t,r){return t||(t=He.alloc(iu.encodingLength(e))),r||(r=0),t.writeUInt16BE(e.length,r),e.copy(t,r+2),iu.encode.bytes=e.length+2,t};iu.encode.bytes=0;iu.decode=function(e,t){t||(t=0);let r=e.readUInt16BE(t),n=e.slice(t+2,t+2+r);return iu.decode.bytes=r+2,n};iu.decode.bytes=0;iu.encodingLength=function(e){return e.length+2};var su=je.ns={};su.encode=function(e,t,r){return t||(t=He.alloc(su.encodingLength(e))),r||(r=0),$e.encode(e,t,r+2),t.writeUInt16BE($e.encode.bytes,r),su.encode.bytes=$e.encode.bytes+2,t};su.encode.bytes=0;su.decode=function(e,t){t||(t=0);let r=e.readUInt16BE(t),n=$e.decode(e,t+2);return su.decode.bytes=r+2,n};su.decode.bytes=0;su.encodingLength=function(e){return $e.encodingLength(e)+2};var au=je.soa={};au.encode=function(e,t,r){t||(t=He.alloc(au.encodingLength(e))),r||(r=0);let n=r;return r+=2,$e.encode(e.mname,t,r),r+=$e.encode.bytes,$e.encode(e.rname,t,r,{mail:!0}),r+=$e.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),au.encode.bytes=r-n,t};au.encode.bytes=0;au.decode=function(e,t){t||(t=0);let r=t,n={};return t+=2,n.mname=$e.decode(e,t),t+=$e.decode.bytes,n.rname=$e.decode(e,t,{mail:!0}),t+=$e.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,au.decode.bytes=t-r,n};au.decode.bytes=0;au.encodingLength=function(e){return 22+$e.encodingLength(e.mname)+$e.encodingLength(e.rname)};var uu=je.txt={};uu.encode=function(e,t,r){Array.isArray(e)||(e=[e]);for(let i=0;i0;){let a=e[t++];if(--n,n0&&(r.timeout=e.readUInt16BE(t),t+=2);break;case 14:r.tags=[];for(let a=0;a0;)n[a++]=Fi.decode(e,t),t+=Fi.decode.bytes,i-=Fi.decode.bytes;return zi.decode.bytes=t-r,n};zi.decode.bytes=0;zi.encodingLength=function(e){return 2+dc(e||[],Fi)};var ii=je.dnskey={};ii.PROTOCOL_DNSSEC=3;ii.ZONE_KEY=128;ii.SECURE_ENTRYPOINT=32768;ii.encode=function(e,t,r){t||(t=He.alloc(ii.encodingLength(e))),r||(r=0);let n=r,i=e.key;if(!He.isBuffer(i))throw new Error("Key must be a Buffer");return r+=2,t.writeUInt16BE(e.flags,r),r+=2,t.writeUInt8(ii.PROTOCOL_DNSSEC,r),r+=1,t.writeUInt8(e.algorithm,r),r+=1,i.copy(t,r,0,i.length),r+=i.length,ii.encode.bytes=r-n,t.writeUInt16BE(ii.encode.bytes-2,n),t};ii.encode.bytes=0;ii.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)!==ii.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,ii.decode.bytes=t-r,n};ii.decode.bytes=0;ii.encodingLength=function(e){return 6+He.byteLength(e.key)};var fa=je.rrsig={};fa.encode=function(e,t,r){t||(t=He.alloc(fa.encodingLength(e))),r||(r=0);let n=r,i=e.signature;if(!He.isBuffer(i))throw new Error("Signature must be a Buffer");return r+=2,t.writeUInt16BE(du.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,$e.encode(e.signersName,t,r),r+=$e.encode.bytes,i.copy(t,r,0,i.length),r+=i.length,fa.encode.bytes=r-n,t.writeUInt16BE(fa.encode.bytes-2,n),t};fa.encode.bytes=0;fa.decode=function(e,t){t||(t=0);let r=t;var n={},i=e.readUInt16BE(t);return t+=2,n.typeCovered=du.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=$e.decode(e,t),t+=$e.decode.bytes,n.signature=e.slice(t,r+i+2),t+=n.signature.length,fa.decode.bytes=t-r,n};fa.decode.bytes=0;fa.encodingLength=function(e){return 20+$e.encodingLength(e.signersName)+He.byteLength(e.signature)};var ha=je.rp={};ha.encode=function(e,t,r){t||(t=He.alloc(ha.encodingLength(e))),r||(r=0);let n=r;return r+=2,$e.encode(e.mbox||".",t,r,{mail:!0}),r+=$e.encode.bytes,$e.encode(e.txt||".",t,r),r+=$e.encode.bytes,ha.encode.bytes=r-n,t.writeUInt16BE(ha.encode.bytes-2,n),t};ha.encode.bytes=0;ha.decode=function(e,t){t||(t=0);let r=t,n={};return t+=2,n.mbox=$e.decode(e,t,{mail:!0})||".",t+=$e.decode.bytes,n.txt=$e.decode(e,t)||".",t+=$e.decode.bytes,ha.decode.bytes=t-r,n};ha.decode.bytes=0;ha.encodingLength=function(e){return 2+$e.encodingLength(e.mbox||".")+$e.encodingLength(e.txt||".")};var cn={};cn.encode=function(e,t,r){t||(t=He.alloc(cn.encodingLength(e))),r||(r=0);let n=r;for(var i=[],a=0;a>8]===void 0&&(i[s>>8]=[]),i[s>>8][s>>3&31]|=1<<7-(s&7)}for(a=0;a>8]=Math.max(t[n>>8]||0,n&255)}var i=0;for(r=0;r>15&1)===1,r.options=zi.decode(e,t+8),t+=8+zi.decode.bytes;else{let i=e.readUInt16BE(t+2);r.ttl=e.readUInt32BE(t+4),r.class=xd.toString(i&ak),r.flush=!!(i&Em);let a=bm(r.type);r.data=a.decode(e,t+8),t+=8+a.decode.bytes}return Fn.decode.bytes=t-n,r};Fn.decode.bytes=0;Fn.encodingLength=function(e){let t=e.data!==null&&e.data!==void 0?e.data:e.options;return $e.encodingLength(e.name)+8+bm(e.type).encodingLength(t)};var Ps=je.question={};Ps.encode=function(e,t,r){t||(t=He.alloc(Ps.encodingLength(e))),r||(r=0);let n=r;return $e.encode(e.name,t,r),r+=$e.encode.bytes,t.writeUInt16BE(du.toType(e.type),r),r+=2,t.writeUInt16BE(xd.toClass(e.class===void 0?"IN":e.class),r),r+=2,Ps.encode.bytes=r-n,e};Ps.encode.bytes=0;Ps.decode=function(e,t){t||(t=0);let r=t,n={};return n.name=$e.decode(e,t),t+=$e.decode.bytes,n.type=du.toString(e.readUInt16BE(t)),t+=2,n.class=xd.toString(e.readUInt16BE(t)),t+=2,!!(n.class&I_)&&(n.class&=uk),Ps.decode.bytes=t-r,n};Ps.decode.bytes=0;Ps.encodingLength=function(e){return $e.encodingLength(e.name)+4};je.AUTHORITATIVE_ANSWER=1024;je.TRUNCATED_RESPONSE=512;je.RECURSION_DESIRED=256;je.RECURSION_AVAILABLE=128;je.AUTHENTIC_DATA=32;je.CHECKING_DISABLED=16;je.DNSSEC_OK=32768;je.encode=function(e,t,r){let n=!t;n&&(t=He.alloc(je.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=[]),xs.encode(e,t,r),r+=xs.encode.bytes,r=Nf(e.questions,Ps,t,r),r=Nf(e.answers,Fn,t,r),r=Nf(e.authorities,Fn,t,r),r=Nf(e.additionals,Fn,t,r),je.encode.bytes=r-i,n&&je.encode.bytes!==t.length?t.slice(0,je.encode.bytes):t};je.encode.bytes=0;je.decode=function(e,t){t||(t=0);let r=t,n=xs.decode(e,t);return t+=xs.decode.bytes,t=Pd(n.questions,Ps,e,t),t=Pd(n.answers,Fn,e,t),t=Pd(n.authorities,Fn,e,t),t=Pd(n.additionals,Fn,e,t),je.decode.bytes=t-r,n};je.decode.bytes=0;je.encodingLength=function(e){return xs.encodingLength(e)+dc(e.questions||[],Ps)+dc(e.answers||[],Fn)+dc(e.authorities||[],Fn)+dc(e.additionals||[],Fn)};je.streamEncode=function(e){let t=je.encode(e),r=He.alloc(2);r.writeUInt16BE(t.byteLength);let n=He.concat([r,t]);return je.streamEncode.bytes=n.byteLength,n};je.streamEncode.bytes=0;je.streamDecode=function(e){let t=e.readUInt16BE(0);if(e.byteLength{var M_=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);M_?(Bm=new Uint8Array(16),Pm.exports=function(){return M_(Bm),Bm}):($m=new Array(16),Pm.exports=function(){for(var t=0,r;t<16;t++)t&3||(r=Math.random()*4294967296),$m[t]=r>>>((t&3)<<3)&255;return $m});var Bm,$m});var Rm=he((aW,V_)=>{var q_=[];for(Uf=0;Uf<256;++Uf)q_[Uf]=(Uf+256).toString(16).substr(1);var Uf;function tN(e,t){var r=t||0,n=q_;return[n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]]].join("")}V_.exports=tN});var G_=he((uW,z_)=>{var rN=xm(),nN=Rm(),K_,Tm,Om=0,km=0;function iN(e,t,r){var n=t&&r||0,i=t||[];e=e||{};var a=e.node||K_,s=e.clockseq!==void 0?e.clockseq:Tm;if(a==null||s==null){var u=rN();a==null&&(a=K_=[u[0]|1,u[1],u[2],u[3],u[4],u[5]]),s==null&&(s=Tm=(u[6]<<8|u[7])&16383)}var l=e.msecs!==void 0?e.msecs:new Date().getTime(),f=e.nsecs!==void 0?e.nsecs:km+1,d=l-Om+(f-km)/1e4;if(d<0&&e.clockseq===void 0&&(s=s+1&16383),(d<0||l>Om)&&e.nsecs===void 0&&(f=0),f>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Om=l,km=f,Tm=s,l+=122192928e5;var m=((l&268435455)*1e4+f)%4294967296;i[n++]=m>>>24&255,i[n++]=m>>>16&255,i[n++]=m>>>8&255,i[n++]=m&255;var p=l/4294967296*1e4&268435455;i[n++]=p>>>8&255,i[n++]=p&255,i[n++]=p>>>24&15|16,i[n++]=p>>>16&255,i[n++]=s>>>8|128,i[n++]=s&255;for(var h=0;h<6;++h)i[n+h]=a[h];return t||nN(i)}z_.exports=iN});var W_=he((oW,Y_)=>{var sN=xm(),aN=Rm();function uN(e,t,r){var n=t&&r||0;typeof e=="string"&&(t=e==="binary"?new Array(16):null,e=null),e=e||{};var i=e.random||(e.rng||sN)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t)for(var a=0;a<16;++a)t[n+a]=i[a];return t||aN(i)}Y_.exports=uN});var Z_=he((lW,J_)=>{var oN=G_(),X_=W_(),Nm=X_;Nm.v1=oN;Nm.v4=X_;J_.exports=Nm});var Ld=he((cW,eC)=>{var{v4:lN}=Z_();function Q_(){return lN().replace(/-/g,"")}var Lm=Q_;function Um(){return Lm()}Um.setFactory=e=>{Lm=e};Um.reset=()=>{Lm=Q_};eC.exports=Um});var gu=he((fW,tC)=>{var cN=Symbol("_options"),fN=Symbol("_cache"),hN=Symbol("_state"),dN=Symbol("_objectId"),pN=Symbol("_conflicts"),gN=Symbol("_change"),mN=Symbol("_elemIds");tC.exports={OPTIONS:cN,CACHE:fN,STATE:hN,OBJECT_ID:dN,CONFLICTS:pN,CHANGE:gN,ELEM_IDS:mN}});var Rs=he((hW,nC)=>{function rC(e){return typeof e=="object"&&e!==null}function vN(e){if(!rC(e))return{};let t={};for(let r of Object.keys(e))t[r]=e[r];return t}function wN(e){let t=/^(\d+)@(.*)$/.exec(e||"");if(!t)throw new RangeError(`Not a valid opId: ${e}`);return{counter:parseInt(t[1],10),actorId:t[2]}}function AN(e,t){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array))throw new TypeError("equalBytes can only compare Uint8Arrays");if(e.byteLength!==t.byteLength)return!1;for(let r=0;r{var{OBJECT_ID:el}=gu(),{isObject:bN}=Rs(),Hf=class{constructor(t){if(typeof t=="string"){let r=[...t].map(n=>({value:n}));return jf(void 0,r)}else if(Array.isArray(t)){let r=t.map(n=>({value:n}));return jf(void 0,r)}else{if(t===void 0)return jf(void 0,[]);throw new TypeError(`Unsupported initial value for Text: ${t}`)}}get length(){return this.elems.length}get(t){let r=this.elems[t].value;if(this.context&&bN(r)){let n=r[el],i=this.path.concat([{key:t,objectId:n}]);return this.context.instantiateObject(i,n)}else return r}getElemId(t){return this.elems[t].elemId}[Symbol.iterator](){let t=this.elems,r=-1;return{next(){return r+=1,r0&&(t.push(r),r=""),t.push(n.value));return r.length>0&&t.push(r),t}toJSON(){return this.toString()}getWriteable(t,r){if(!this[el])throw new RangeError("getWriteable() requires the objectId to be set");let n=jf(this[el],this.elems);return n.context=t,n.path=r,n}set(t,r){if(this.context)this.context.setListIndex(this.path,t,r);else if(!this[el])this.elems[t].value=r;else throw new TypeError("Automerge.Text object cannot be modified outside of a change block");return this}insertAt(t,...r){if(this.context)this.context.splice(this.path,t,0,r);else if(!this[el])this.elems.splice(t,0,...r.map(n=>({value:n})));else throw new TypeError("Automerge.Text object cannot be modified outside of a change block");return this}deleteAt(t,r=1){if(this.context)this.context.splice(this.path,t,r,[]);else if(!this[el])this.elems.splice(t,r);else throw new TypeError("Automerge.Text object cannot be modified outside of a change block");return this}};for(let e of["concat","every","filter","find","findIndex","forEach","includes","indexOf","join","lastIndexOf","map","reduce","reduceRight","slice","some","toLocaleString"])Hf.prototype[e]=function(...t){return[...this][e](...t)};function jf(e,t){let r=Object.create(Hf.prototype);return r[el]=e,r.elems=t,r}iC.exports={Text:Hf,instantiateText:jf}});var Vf=he((pW,uC)=>{var{OBJECT_ID:tl,CONFLICTS:yN}=gu(),{isObject:Ud,copyObject:sC}=Rs();function jm(e,t,r){for(let n of e)if(t[n]!==r[n]){if(typeof t[n]=="number"&&typeof r[n]=="number")return t[n]-r[n];{let i=""+t[n],a=""+r[n];if(i===a)continue;return i{let r=this.entries[t];return Ud(r)&&r.id===t})}get count(){return this.ids.length}get rows(){return this.ids.map(t=>this.byId(t))}filter(t,r){return this.rows.filter(t,r)}find(t,r){return this.rows.find(t,r)}map(t,r){return this.rows.map(t,r)}sort(t){if(typeof t=="function")return this.rows.sort(t);if(typeof t=="string")return this.rows.sort((r,n)=>jm([t],r,n));if(Array.isArray(t))return this.rows.sort((r,n)=>jm(t,r,n));if(t===void 0)return this.rows.sort((r,n)=>jm(["id"],r,n));throw new TypeError(`Unsupported sorting argument: ${t}`)}[Symbol.iterator](){let t=this.rows,r=-1;return{next(){return r+=1,r{var jd=class{constructor(t){this.value=t||0,Object.freeze(this)}valueOf(){return this.value}toString(){return this.valueOf().toString()}toJSON(){return this.value}},Mm=class extends jd{increment(t){return t=typeof t=="number"?t:1,this.context.increment(this.path,this.key,t),this.value+=t,this.value}decrement(t){return this.increment(typeof t=="number"?-t:-1)}};function _N(e,t,r,n,i){let a=Object.create(Mm.prototype);return a.value=e,a.context=t,a.path=r,a.objectId=n,a.key=i,a}oC.exports={Counter:jd,getWriteableCounter:_N}});var qm=he((mW,hC)=>{var{isObject:CN,copyObject:lC,parseOpId:qd}=Rs(),{OBJECT_ID:Kf,CONFLICTS:rl,ELEM_IDS:Md}=gu(),{instantiateText:DN}=Mf(),{instantiateTable:FN}=Vf(),{Counter:SN}=Hd();function mu(e,t,r){return e.objectId?(t&&t[Kf]!==e.objectId&&(t=void 0),fC(e,t,r)):e.datatype==="timestamp"?new Date(e.value):e.datatype==="counter"?new SN(e.value):e.value}function IN(e,t){let r=/^(\d+)@(.*)$/,n=r.test(e)?qd(e):{counter:0,actorId:e},i=r.test(t)?qd(t):{counter:0,actorId:t};return n.counteri.counter?1:n.actorIdi.actorId?1:0}function BN(e,t,r,n){if(e)for(let i of Object.keys(e)){let a={},s=Object.keys(e[i]).sort(IN).reverse();for(let u of s){let l=e[i][u];r[i]&&r[i][u]?a[u]=mu(l,r[i][u],n):a[u]=mu(l,void 0,n)}s.length===0?(delete t[i],delete r[i]):(t[i]=a[s[0]],r[i]=a)}}function cC(e,t){let r=lC(e),n=lC(e?e[rl]:void 0);return Object.defineProperty(r,Kf,{value:t}),Object.defineProperty(r,rl,{value:n}),r}function $N(e,t,r){let n=e.objectId;r[n]||(r[n]=cC(t,n));let i=r[n];return BN(e.props,i,i[rl],r),i}function PN(e,t,r){let n=e.objectId;r[n]||(r[n]=t?t._clone():FN(n));let i=r[n];for(let a of Object.keys(e.props||{})){let s=Object.keys(e.props[a]);if(s.length===0)i.remove(a);else if(s.length===1){let u=e.props[a][s[0]];i._set(a,mu(u,i.byId(a),r),s[0])}else throw new RangeError("Conflicts are not supported on properties of a table")}return i}function xN(e,t){let r=e?e.slice():[],n=e&&e[rl]?e[rl].slice():[],i=e&&e[Md]?e[Md].slice():[];return Object.defineProperty(r,Kf,{value:t}),Object.defineProperty(r,rl,{value:n}),Object.defineProperty(r,Md,{value:i}),r}function RN(e,t,r){let n=e.objectId;r[n]||(r[n]=xN(t,n));let i=r[n],a=i[rl],s=i[Md];for(let u=0;u{let y=`${f.counter+v}@${f.actorId}`;w=mu({value:w,datatype:h},void 0,r),m.push(w),p.push({[y]:{value:w,datatype:h,type:"value"}}),d.push(y)}),i.splice(l.index,0,...m),a.splice(l.index,0,...p),s.splice(l.index,0,...d)}else l.action==="remove"&&(i.splice(l.index,l.count),a.splice(l.index,l.count),s.splice(l.index,l.count))}return i}function TN(e,t,r){let n=e.objectId,i;r[n]?i=r[n].elems:t?i=t.elems.slice():i=[];for(let a of e.edits)if(a.action==="insert"){let s=mu(a.value,void 0,r),u={elemId:a.elemId,pred:[a.opId],value:s};i.splice(a.index,0,u)}else if(a.action==="multi-insert"){let s=qd(a.elemId),u=a.datatype,l=a.values.map((f,d)=>{f=mu({datatype:u,value:f},void 0,r);let m=`${s.counter+d}@${s.actorId}`;return{elemId:m,pred:[m],value:f}});i.splice(a.index,0,...l)}else if(a.action==="update"){let s=i[a.index].elemId,u=mu(a.value,i[a.index].value,r);i[a.index]={elemId:s,pred:[a.opId],value:u}}else a.action==="remove"&&i.splice(a.index,a.count);return r[n]=DN(n,i),r[n]}function fC(e,t,r){if(CN(t)&&(!e.props||Object.keys(e.props).length===0)&&(!e.edits||e.edits.length===0)&&!r[e.objectId])return t;if(e.type==="map")return $N(e,t,r);if(e.type==="table")return PN(e,t,r);if(e.type==="list")return RN(e,t,r);if(e.type==="text")return TN(e,t,r);throw new TypeError(`Unknown object type: ${e.type}`)}function ON(e){if(e[Kf]!=="_root")throw new RangeError(`Not the root object: ${e[Kf]}`);return cC(e,"_root")}hC.exports={interpretPatch:fC,cloneRootObject:ON}});var gC=he((vW,pC)=>{var{OBJECT_ID:nl,CHANGE:Vd,STATE:kN}=gu(),{createArrayOfNulls:NN}=Rs(),{Text:LN}=Mf(),{Table:UN}=Vf();function Aa(e){if(typeof e=="string"&&/^[0-9]+$/.test(e)&&(e=parseInt(e,10)),typeof e!="number")throw new TypeError("A list index must be a number, but you passed "+JSON.stringify(e));if(e<0||isNaN(e)||e===1/0||e===-1/0)throw new RangeError("A list index must be positive, but you passed "+e);return e}function jN(e,t,r){let n={deleteAt(i,a){return e.splice(r,Aa(i),a||1,[]),this},fill(i,a,s){let u=e.getObject(t);for(let l=Aa(a||0);lu.length-i)&&(a=u.length-i);let l=[];for(let f=0;fa[i]()}for(let i of["concat","every","filter","find","findIndex","forEach","includes","join","lastIndexOf","map","reduce","reduceRight","slice","some","toLocaleString","toString"])n[i]=(...a)=>e.getObject(t).map((u,l)=>e.getObjectField(r,t,l))[i](...a);return n}var HN={get(e,t){let{context:r,objectId:n,path:i}=e;return t===nl?n:t===Vd?r:t===kN?{actorId:r.actorId}:r.getObjectField(i,n,t)},set(e,t,r){let{context:n,path:i,readonly:a}=e;if(Array.isArray(a)&&a.indexOf(t)>=0)throw new RangeError(`Object property "${t}" cannot be modified`);return n.setMapKey(i,t,r),!0},deleteProperty(e,t){let{context:r,path:n,readonly:i}=e;if(Array.isArray(i)&&i.indexOf(t)>=0)throw new RangeError(`Object property "${t}" cannot be modified`);return r.deleteMapKey(n,t),!0},has(e,t){let{context:r,objectId:n}=e;return[nl,Vd].includes(t)||t in r.getObject(n)},getOwnPropertyDescriptor(e,t){let{context:r,objectId:n}=e,i=r.getObject(n);if(t in i)return{configurable:!0,enumerable:!0,value:r.getObjectField(n,t)}},ownKeys(e){let{context:t,objectId:r}=e;return Object.keys(t.getObject(r))}},MN={get(e,t){let[r,n,i]=e;return t===Symbol.iterator?r.getObject(n)[Symbol.iterator]:t===nl?n:t===Vd?r:t==="length"?r.getObject(n).length:typeof t=="string"&&/^[0-9]+$/.test(t)?r.getObjectField(i,n,Aa(t)):jN(r,n,i)[t]},set(e,t,r){let[n,i,a]=e;if(t==="length"){if(typeof r!="number")throw new RangeError("Invalid array length");let s=n.getObject(i).length;s>r?n.splice(a,r,s-r,[]):n.splice(a,s,0,NN(r-s))}else n.setListIndex(a,Aa(t),r);return!0},deleteProperty(e,t){let[r,,n]=e;return r.splice(n,Aa(t),1,[]),!0},has(e,t){let[r,n]=e;return typeof t=="string"&&/^[0-9]+$/.test(t)?Aa(t){var Vm=class{constructor(t){if(!(Number.isInteger(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER))throw new RangeError(`Value ${t} cannot be a uint`);this.value=t,Object.freeze(this)}},Km=class{constructor(t){if(!(Number.isInteger(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=0))throw new RangeError(`Value ${t} cannot be a uint`);this.value=t,Object.freeze(this)}},zm=class{constructor(t){if(typeof t!="number")throw new RangeError(`Value ${t} cannot be a float64`);this.value=t||0,Object.freeze(this)}};mC.exports={Int:Vm,Uint:Km,Float64:zm}});var EC=he((AW,AC)=>{var{CACHE:zN,OBJECT_ID:Kd,CONFLICTS:il,ELEM_IDS:vC,STATE:GN}=gu(),{interpretPatch:YN}=qm(),{Text:Yf}=Mf(),{Table:Wf}=Vf(),{Counter:Xu,getWriteableCounter:WN}=Hd(),{Int:Ym,Uint:Wm,Float64:Xm}=Gm(),{isObject:zf,parseOpId:wC,createArrayOfNulls:XN}=Rs(),JN=Ld(),Jm=class{constructor(t,r,n){this.actorId=r,this.nextOpNum=t[GN].maxOp+1,this.cache=t[zN],this.updated={},this.ops=[],this.applyPatch=n||YN}addOp(t){this.ops.push(t),t.action==="set"&&t.values?this.nextOpNum+=t.values.length:t.action==="del"&&t.multiOp?this.nextOpNum+=t.multiOp:this.nextOpNum+=1}nextOpId(){return`${this.nextOpNum}@${this.actorId}`}getValueDescription(t){if(!["object","boolean","number","string"].includes(typeof t))throw new TypeError(`Unsupported type of value: ${typeof t}`);if(zf(t)){if(t instanceof Date)return{type:"value",value:t.getTime(),datatype:"timestamp"};if(t instanceof Ym)return{type:"value",value:t.value,datatype:"int"};if(t instanceof Wm)return{type:"value",value:t.value,datatype:"uint"};if(t instanceof Xm)return{type:"value",value:t.value,datatype:"float64"};if(t instanceof Xu)return{type:"value",value:t.value,datatype:"counter"};{let r=t[Kd],n=this.getObjectType(r);if(!r)throw new RangeError(`Object ${JSON.stringify(t)} has no objectId`);return n==="list"||n==="text"?{objectId:r,type:n,edits:[]}:{objectId:r,type:n,props:{}}}}else return typeof t=="number"?Number.isInteger(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER?{type:"value",value:t,datatype:"int"}:{type:"value",value:t,datatype:"float64"}:{type:"value",value:t}}getValuesDescriptions(t,r,n){if(r instanceof Wf){let i=r.byId(n),a=r.opIds[n];return i?{[a]:this.getValueDescription(i)}:{}}else if(r instanceof Yf){let i=r.get(n),a=r.getElemId(n);return i?{[a]:this.getValueDescription(i)}:{}}else{let i=r[il][n],a={};if(!i)throw new RangeError(`No children at key ${n} of path ${JSON.stringify(t)}`);for(let s of Object.keys(i))a[s]=this.getValueDescription(i[s]);return a}}getPropertyValue(t,r,n){return t instanceof Wf?t.byId(r):t instanceof Yf?t.get(r):t[il][r][n]}getSubpatch(t,r){if(r.length==0)return t;let n=t,i=this.getObject("_root");for(let a of r){let s=this.getValuesDescriptions(r,i,a.key);if(n.props)n.props[a.key]||(n.props[a.key]=s);else if(n.edits)for(let l of Object.keys(s))n.edits.push({action:"update",index:a.key,opId:l,value:s[l]});let u=null;for(let l of Object.keys(s))s[l].objectId===a.objectId&&(u=l);if(!u)throw new RangeError(`Cannot find path object with objectId ${a.objectId}`);n=s[u],i=this.getPropertyValue(i,a.key,u)}return n}getObject(t){let r=this.updated[t]||this.cache[t];if(!r)throw new RangeError(`Target object does not exist: ${t}`);return r}getObjectType(t){if(t==="_root")return"map";let r=this.getObject(t);return r instanceof Yf?"text":r instanceof Wf?"table":Array.isArray(r)?"list":"map"}getObjectField(t,r,n){if(!["string","number"].includes(typeof n))return;let i=this.getObject(r);if(i[n]instanceof Xu)return WN(i[n].value,this,t,r,n);if(zf(i[n])){let a=i[n][Kd],s=t.concat([{key:n,objectId:a}]);return this.instantiateObject(s,a)}else return i[n]}createNestedObjects(t,r,n,i,a,s){if(n[Kd])throw new RangeError("Cannot create a reference to an existing document object");let u=this.nextOpId();if(n instanceof Yf){this.addOp(s?{action:"makeText",obj:t,elemId:s,insert:i,pred:a}:{action:"makeText",obj:t,key:r,insert:i,pred:a});let l={objectId:u,type:"text",edits:[]};return this.insertListItems(l,0,[...n],!0),l}else if(n instanceof Wf){if(n.count>0)throw new RangeError("Assigning a non-empty Table object is not supported");return this.addOp(s?{action:"makeTable",obj:t,elemId:s,insert:i,pred:a}:{action:"makeTable",obj:t,key:r,insert:i,pred:a}),{objectId:u,type:"table",props:{}}}else if(Array.isArray(n)){this.addOp(s?{action:"makeList",obj:t,elemId:s,insert:i,pred:a}:{action:"makeList",obj:t,key:r,insert:i,pred:a});let l={objectId:u,type:"list",edits:[]};return this.insertListItems(l,0,n,!0),l}else{this.addOp(s?{action:"makeMap",obj:t,elemId:s,insert:i,pred:a}:{action:"makeMap",obj:t,key:r,insert:i,pred:a});let l={};for(let f of Object.keys(n).sort()){let d=this.nextOpId(),m=this.setValue(u,f,n[f],!1,[]);l[f]={[d]:m}}return{objectId:u,type:"map",props:l}}}setValue(t,r,n,i,a,s){if(!t)throw new RangeError("setValue needs an objectId");if(r==="")throw new RangeError("The key of a map entry must not be an empty string");if(zf(n)&&!(n instanceof Date)&&!(n instanceof Xu)&&!(n instanceof Ym)&&!(n instanceof Wm)&&!(n instanceof Xm))return this.createNestedObjects(t,r,n,i,a,s);{let u=this.getValueDescription(n),l={action:"set",obj:t,insert:i,value:u.value,pred:a};return s?l.elemId=s:l.key=r,u.datatype&&(l.datatype=u.datatype),this.addOp(l),u}}applyAtPath(t,r){let n={objectId:"_root",type:"map",props:{}};r(this.getSubpatch(n,t)),this.applyPatch(n,this.cache._root,this.updated)}setMapKey(t,r,n){if(typeof r!="string")throw new RangeError(`The key of a map entry must be a string, not ${typeof r}`);let i=t.length===0?"_root":t[t.length-1].objectId,a=this.getObject(i);if(a[r]instanceof Xu)throw new RangeError("Cannot overwrite a Counter object; use .increment() or .decrement() to change its value.");(a[r]!==n||Object.keys(a[il][r]||{}).length>1||n===void 0)&&this.applyAtPath(t,s=>{let u=Gf(a,r),l=this.nextOpId(),f=this.setValue(i,r,n,!1,u);s.props[r]={[l]:f}})}deleteMapKey(t,r){let n=t.length===0?"_root":t[t.length-1].objectId,i=this.getObject(n);if(i[r]!==void 0){let a=Gf(i,r);this.addOp({action:"del",obj:n,key:r,insert:!1,pred:a}),this.applyAtPath(t,s=>{s.props[r]={}})}}insertListItems(t,r,n,i){let a=i?[]:this.getObject(t.objectId);if(r<0||r>a.length)throw new RangeError(`List index ${r} is out of bounds for list of length ${a.length}`);if(n.length===0)return;let s=zd(a,r,!0),u=n.every(d=>typeof d=="string"||typeof d=="number"||typeof d=="boolean"||d===null||zf(d)&&(d instanceof Date||d instanceof Xu||d instanceof Ym||d instanceof Wm||d instanceof Xm)),l=u?n.map(d=>this.getValueDescription(d)):[],f=l.every(d=>d.datatype===l[0].datatype);if(u&&f&&n.length>1){let d=this.nextOpId(),m=l[0].datatype,p=l.map(v=>v.value),h={action:"set",obj:t.objectId,elemId:s,insert:!0,values:p,pred:[]},w={action:"multi-insert",elemId:d,index:r,values:p};m&&(h.datatype=m,w.datatype=m),this.addOp(h),t.edits.push(w)}else for(let d=0;d=a.length){let s=XN(r-a.length);return s.push(n),this.splice(t,a.length,0,s)}if(a[r]instanceof Xu)throw new RangeError("Cannot overwrite a Counter object; use .increment() or .decrement() to change its value.");(a[r]!==n||Object.keys(a[il][r]||{}).length>1||n===void 0)&&this.applyAtPath(t,s=>{let u=Gf(a,r),l=this.nextOpId(),f=this.setValue(i,r,n,!1,u,zd(a,r));s.edits.push({action:"update",index:r,opId:l,value:f})})}splice(t,r,n,i){let a=t.length===0?"_root":t[t.length-1].objectId,s=this.getObject(a);if(r<0||n<0||r>s.length-n)throw new RangeError(`${n} deletions starting at index ${r} are out of bounds for list of length ${s.length}`);if(n===0&&i.length===0)return;let u={diffs:{objectId:"_root",type:"map",props:{}}},l=this.getSubpatch(u.diffs,t);if(n>0){let f,d,m;for(let p=0;p0&&this.insertListItems(l,r,i,!1),this.applyPatch(u.diffs,this.cache._root,this.updated)}addTableRow(t,r){if(!zf(r)||Array.isArray(r))throw new TypeError("A table row must be an object");if(r[Kd])throw new TypeError("Cannot reuse an existing object as table row");if(r.id)throw new TypeError('A table row must not have an "id" property; it is generated automatically');let n=JN(),i=this.setValue(t[t.length-1].objectId,n,r,!1,[]);return this.applyAtPath(t,a=>{a.props[n]={[i.objectId]:i}}),n}deleteTableRow(t,r,n){let i=t[t.length-1].objectId;this.getObject(i).byId(r)&&(this.addOp({action:"del",obj:i,key:r,insert:!1,pred:[n]}),this.applyAtPath(t,s=>{s.props[r]={}}))}increment(t,r,n){let i=t.length===0?"_root":t[t.length-1].objectId,a=this.getObject(i);if(!(a[r]instanceof Xu))throw new TypeError("Only counter values can be incremented");let s=this.getObjectType(i),u=a[r].value+n,l=this.nextOpId(),f=Gf(a,r);if(s==="list"||s==="text"){let d=zd(a,r,!1);this.addOp({action:"inc",obj:i,elemId:d,value:n,insert:!1,pred:f})}else this.addOp({action:"inc",obj:i,key:r,value:n,insert:!1,pred:f});this.applyAtPath(t,d=>{s==="list"||s==="text"?d.edits.push({action:"update",index:r,opId:l,value:{value:u,datatype:"counter"}}):d.props[r]={[l]:{value:u,datatype:"counter"}}})}};function Gf(e,t){return e instanceof Wf?[e.opIds[t]]:e instanceof Yf?e.elems[t].pred:e[il]?e[il][t]?Object.keys(e[il][t]):[]:[]}function zd(e,t,r=!1){if(r){if(t===0)return"_head";t-=1}if(e[vC])return e[vC][t];if(e.getElemId)return e.getElemId(t);throw new RangeError(`Cannot find elemId at list index ${t}`)}AC.exports={Context:Jm}});var yC=he((EW,bC)=>{var{OBJECT_ID:ZN,CONFLICTS:si}=gu(),Zm=class{constructor(){this.observers={}}patchCallback(t,r,n,i,a){this._objectUpdate(t.diffs,r,n,i,a)}_objectUpdate(t,r,n,i,a){if(t.objectId){if(this.observers[t.objectId])for(let s of this.observers[t.objectId])s(t,r,n,i,a);if(t.type==="map"&&t.props)for(let s of Object.keys(t.props))for(let u of Object.keys(t.props[s]))this._objectUpdate(t.props[s][u],r&&r[si]&&r[si][s]&&r[si][s][u],n&&n[si]&&n[si][s]&&n[si][s][u],i,a);else if(t.type==="table"&&t.props)for(let s of Object.keys(t.props))for(let u of Object.keys(t.props[s]))this._objectUpdate(t.props[s][u],r&&r.byId(s),n&&n.byId(s),i,a);else if(t.type==="list"&&t.edits){let s=0;for(let u of t.edits)u.action==="insert"?(s-=1,this._objectUpdate(u.value,void 0,n&&n[si]&&n[si][u.index]&&n[si][u.index][u.elemId],i,a)):u.action==="multi-insert"?s-=u.values.length:u.action==="update"?this._objectUpdate(u.value,r&&r[si]&&r[si][u.index+s]&&r[si][u.index+s][u.opId],n&&n[si]&&n[si][u.index]&&n[si][u.index][u.opId],i,a):u.action==="remove"&&(s+=u.count)}else if(t.type==="text"&&t.edits){let s=0;for(let u of t.edits)u.action==="insert"?(s-=1,this._objectUpdate(u.value,void 0,n&&n.get(u.index),i,a)):u.action==="multi-insert"?s-=u.values.length:u.action==="update"?this._objectUpdate(u.value,r&&r.get(u.index+s),n&&n.get(u.index),i,a):u.action==="remove"&&(s+=u.count)}}}observe(t,r){let n=t[ZN];if(!n)throw new TypeError("The observed object must be part of an Automerge document");this.observers[n]||(this.observers[n]=[]),this.observers[n].push(r)}};bC.exports={Observable:Zm}});var PC=he((bW,$C)=>{var{OPTIONS:Ea,CACHE:mc,STATE:ba,OBJECT_ID:wc,CONFLICTS:vc,CHANGE:_C,ELEM_IDS:QN}=gu(),{isObject:tv,copyObject:Qm}=Rs(),eL=Ld(),{interpretPatch:tL,cloneRootObject:rL}=qm(),{rootObjectProxy:nL}=gC(),{Context:CC}=EC(),{Text:rv}=Mf(),{Table:DC}=Vf(),{Counter:iL}=Hd(),{Float64:sL,Int:aL,Uint:uL}=Gm(),{Observable:oL}=yC();function FC(e){if(typeof e!="string")throw new TypeError(`Unsupported type of actorId: ${typeof e}`);if(!/^[0-9a-f]+$/.test(e))throw new RangeError("actorId must consist only of lowercase hex digits");if(e.length%2!==0)throw new RangeError("actorId must consist of an even number of digits")}function Gd(e,t,r){let n=t._root;if(n||(n=rL(e[mc]._root),t._root=n),Object.defineProperty(n,Ea,{value:e[Ea]}),Object.defineProperty(n,mc,{value:t}),Object.defineProperty(n,ba,{value:r}),e[Ea].freeze)for(let i of Object.keys(t))t[i]instanceof DC?t[i]._freeze():t[i]instanceof rv?(Object.freeze(t[i].elems),Object.freeze(t[i])):(Object.freeze(t[i]),Object.freeze(t[i][vc]));for(let i of Object.keys(e[mc]))t[i]||(t[i]=e[mc][i]);return e[Ea].freeze&&Object.freeze(t),n}function SC(e,t,r){let n=Ac(e);if(!n)throw new Error("Actor ID must be initialized with setActorId() before making a change");let i=Qm(e[ba]);i.seq+=1;let a={actor:n,seq:i.seq,startOp:i.maxOp+1,deps:i.deps,time:r&&typeof r.time=="number"?r.time:Math.round(new Date().getTime()/1e3),message:r&&typeof r.message=="string"?r.message:"",ops:t.ops};if(e[Ea].backend){let[s,u,l]=e[Ea].backend.applyLocalChange(i.backendState,a);i.backendState=s,i.lastLocalChange=l;let f=ev(e,u,i,!0),d=r&&r.patchCallback||e[Ea].patchCallback;return d&&d(u,e,f,!0,[l]),[f,a]}else{let s={actor:n,seq:a.seq,before:e};return i.requests=i.requests.concat([s]),i.maxOp=i.maxOp+lL(a.ops),i.deps=[],[Gd(e,t?t.updated:{},i),a]}}function lL(e){let t=0;for(let r of e)r.action==="set"&&r.values?t+=r.values.length:t+=1;return t}function cL(e){return e[ba]&&e[ba].lastLocalChange?e[ba].lastLocalChange:null}function ev(e,t,r,n){let i=Ac(e),a={};if(tL(t.diffs,e,a),n){if(!t.clock)throw new RangeError("patch is missing clock field");t.clock[i]&&t.clock[i]>r.seq&&(r.seq=t.clock[i]),r.clock=t.clock,r.deps=t.deps,r.maxOp=Math.max(r.maxOp,t.maxOp)}return Gd(e,a,r)}function IC(e){if(typeof e=="string")e={actorId:e};else if(typeof e>"u")e={};else if(!tv(e))throw new TypeError(`Unsupported value for init() options: ${e}`);if(e.deferActorId||(e.actorId===void 0&&(e.actorId=eL()),FC(e.actorId)),e.observable){let i=e.patchCallback,a=e.observable;e.patchCallback=(s,u,l,f,d)=>{i&&i(s,u,l,f,d),a.patchCallback(s,u,l,f,d)}}let t={},r={_root:t},n={seq:0,maxOp:0,requests:[],clock:{},deps:[]};return e.backend&&(n.backendState=e.backend.init(),n.lastLocalChange=null),Object.defineProperty(t,wc,{value:"_root"}),Object.defineProperty(t,Ea,{value:Object.freeze(e)}),Object.defineProperty(t,vc,{value:Object.freeze({})}),Object.defineProperty(t,mc,{value:Object.freeze(r)}),Object.defineProperty(t,ba,{value:Object.freeze(n)}),Object.freeze(t)}function fL(e,t){return BC(IC(t),"Initialization",r=>Object.assign(r,e))}function BC(e,t,r){if(e[wc]!=="_root")throw new TypeError("The first argument to Automerge.change must be the document root");if(e[_C])throw new TypeError("Calls to Automerge.change cannot be nested");if(typeof t=="function"&&r===void 0&&([t,r]=[r,t]),typeof t=="string"&&(t={message:t}),t!==void 0&&!tv(t))throw new TypeError("Unsupported type of options");let n=Ac(e);if(!n)throw new Error("Actor ID must be initialized with setActorId() before making a change");let i=new CC(e,n);return r(nL(i)),Object.keys(i.updated).length===0?[e,null]:SC(e,i,t)}function hL(e,t){if(e[wc]!=="_root")throw new TypeError("The first argument to Automerge.emptyChange must be the document root");if(typeof t=="string"&&(t={message:t}),t!==void 0&&!tv(t))throw new TypeError("Unsupported type of options");let r=Ac(e);if(!r)throw new Error("Actor ID must be initialized with setActorId() before making a change");return SC(e,new CC(e,r),t)}function dL(e,t,r=void 0){if(e[wc]!=="_root")throw new TypeError("The first argument to Frontend.applyPatch must be the document root");let n=Qm(e[ba]);if(e[Ea].backend){if(!r)throw new RangeError("applyPatch must be called with the updated backend state");return n.backendState=r,ev(e,t,n,!0)}let i;if(n.requests.length>0)if(i=n.requests[0].before,t.actor===Ac(e)){if(n.requests[0].seq!==t.seq)throw new RangeError(`Mismatched sequence number: patch ${t.seq} does not match next request ${n.requests[0].seq}`);n.requests=n.requests.slice(1)}else n.requests=n.requests.slice();else i=e,n.requests=[];let a=ev(i,t,n,!0);return n.requests.length===0?a:(n.requests[0]=Qm(n.requests[0]),n.requests[0].before=a,Gd(e,{},n))}function pL(e){return e[wc]}function gL(e,t){if(e[_C])throw new TypeError("Cannot use getObjectById in a change callback");return e[mc][t]}function Ac(e){return e[ba].actorId||e[Ea].actorId}function mL(e,t){FC(t);let r=Object.assign({},e[ba],{actorId:t});return Gd(e,{},r)}function vL(e,t){if(e[vc]&&e[vc][t]&&Object.keys(e[vc][t]).length>1)return e[vc][t]}function wL(e,t=null,r="first"){if(e[wc]!=="_root"){let n=Array.isArray(e)?". Note: Automerge.applyChanges now returns an array.":"";throw t?new TypeError(`The ${r} argument to Automerge.${t} must be the document root${n}`):new TypeError(`Argument is not an Automerge document root${n}`)}return e[ba].backendState}function AL(e){return e instanceof rv?e.elems.map(t=>t.elemId):e[QN]}$C.exports={init:IC,from:fL,change:BC,emptyChange:hL,applyPatch:dL,getObjectId:pL,getObjectById:gL,getActorId:Ac,setActorId:mL,getConflicts:vL,getLastLocalChange:cL,getBackendState:wL,getElementIds:AL,Text:rv,Table:DC,Counter:iL,Observable:oL,Float64:sL,Int:aL,Uint:uL}});var ZC=he((yW,yc)=>{"use strict";function bc(e){let t=e.length;for(;--t>=0;)e[t]=0}var EL=0,NC=1,bL=2,yL=3,_L=258,lv=29,th=256,Jf=th+1+lv,Ec=30,cv=19,LC=2*Jf+1,sl=15,nv=16,CL=7,fv=256,UC=16,jC=17,HC=18,uv=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Yd=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),DL=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),MC=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),FL=512,vu=new Array((Jf+2)*2);bc(vu);var Xf=new Array(Ec*2);bc(Xf);var Zf=new Array(FL);bc(Zf);var Qf=new Array(_L-yL+1);bc(Qf);var hv=new Array(lv);bc(hv);var Wd=new Array(Ec);bc(Wd);function iv(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}var qC,VC,KC;function sv(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}var zC=e=>e<256?Zf[e]:Zf[256+(e>>>7)],eh=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},Si=(e,t,r)=>{e.bi_valid>nv-r?(e.bi_buf|=t<>nv-e.bi_valid,e.bi_valid+=r-nv):(e.bi_buf|=t<{Si(e,r[t*2],r[t*2+1])},GC=(e,t)=>{let r=0;do r|=e&1,e>>>=1,r<<=1;while(--t>0);return r>>>1},SL=e=>{e.bi_valid===16?(eh(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)},IL=(e,t)=>{let r=t.dyn_tree,n=t.max_code,i=t.stat_desc.static_tree,a=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,u=t.stat_desc.extra_base,l=t.stat_desc.max_length,f,d,m,p,h,w,v=0;for(p=0;p<=sl;p++)e.bl_count[p]=0;for(r[e.heap[e.heap_max]*2+1]=0,f=e.heap_max+1;fl&&(p=l,v++),r[d*2+1]=p,!(d>n)&&(e.bl_count[p]++,h=0,d>=u&&(h=s[d-u]),w=r[d*2],e.opt_len+=w*(p+h),a&&(e.static_len+=w*(i[d*2+1]+h)));if(v!==0){do{for(p=l-1;e.bl_count[p]===0;)p--;e.bl_count[p]--,e.bl_count[p+1]+=2,e.bl_count[l]--,v-=2}while(v>0);for(p=l;p!==0;p--)for(d=e.bl_count[p];d!==0;)m=e.heap[--f],!(m>n)&&(r[m*2+1]!==p&&(e.opt_len+=(p-r[m*2+1])*r[m*2],r[m*2+1]=p),d--)}},YC=(e,t,r)=>{let n=new Array(sl+1),i=0,a,s;for(a=1;a<=sl;a++)i=i+r[a-1]<<1,n[a]=i;for(s=0;s<=t;s++){let u=e[s*2+1];u!==0&&(e[s*2]=GC(n[u]++,u))}},BL=()=>{let e,t,r,n,i,a=new Array(sl+1);for(r=0,n=0;n>=7;n{let t;for(t=0;t{e.bi_valid>8?eh(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},xC=(e,t,r,n)=>{let i=t*2,a=r*2;return e[i]{let n=e.heap[r],i=r<<1;for(;i<=e.heap_len&&(i{let n,i,a=0,s,u;if(e.sym_next!==0)do n=e.pending_buf[e.sym_buf+a++]&255,n+=(e.pending_buf[e.sym_buf+a++]&255)<<8,i=e.pending_buf[e.sym_buf+a++],n===0?ya(e,i,t):(s=Qf[i],ya(e,s+th+1,t),u=uv[s],u!==0&&(i-=hv[s],Si(e,i,u)),n--,s=zC(n),ya(e,s,r),u=Yd[s],u!==0&&(n-=Wd[s],Si(e,n,u)));while(a{let r=t.dyn_tree,n=t.stat_desc.static_tree,i=t.stat_desc.has_stree,a=t.stat_desc.elems,s,u,l=-1,f;for(e.heap_len=0,e.heap_max=LC,s=0;s>1;s>=1;s--)av(e,r,s);f=a;do s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],av(e,r,1),u=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=u,r[f*2]=r[s*2]+r[u*2],e.depth[f]=(e.depth[s]>=e.depth[u]?e.depth[s]:e.depth[u])+1,r[s*2+1]=r[u*2+1]=f,e.heap[1]=f++,av(e,r,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],IL(e,t),YC(r,l,e.bl_count)},TC=(e,t,r)=>{let n,i=-1,a,s=t[0*2+1],u=0,l=7,f=4;for(s===0&&(l=138,f=3),t[(r+1)*2+1]=65535,n=0;n<=r;n++)a=s,s=t[(n+1)*2+1],!(++u{let n,i=-1,a,s=t[0*2+1],u=0,l=7,f=4;for(s===0&&(l=138,f=3),n=0;n<=r;n++)if(a=s,s=t[(n+1)*2+1],!(++u{let t;for(TC(e,e.dyn_ltree,e.l_desc.max_code),TC(e,e.dyn_dtree,e.d_desc.max_code),ov(e,e.bl_desc),t=cv-1;t>=3&&e.bl_tree[MC[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},PL=(e,t,r,n)=>{let i;for(Si(e,t-257,5),Si(e,r-1,5),Si(e,n-4,4),i=0;i{let t=4093624447,r;for(r=0;r<=31;r++,t>>>=1)if(t&1&&e.dyn_ltree[r*2]!==0)return 0;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return 1;for(r=32;r{kC||(BL(),kC=!0),e.l_desc=new sv(e.dyn_ltree,qC),e.d_desc=new sv(e.dyn_dtree,VC),e.bl_desc=new sv(e.bl_tree,KC),e.bi_buf=0,e.bi_valid=0,WC(e)},JC=(e,t,r,n)=>{Si(e,(EL<<1)+(n?1:0),3),XC(e),eh(e,r),eh(e,~r),r&&e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r},TL=e=>{Si(e,NC<<1,3),ya(e,fv,vu),SL(e)},OL=(e,t,r,n)=>{let i,a,s=0;e.level>0?(e.strm.data_type===2&&(e.strm.data_type=xL(e)),ov(e,e.l_desc),ov(e,e.d_desc),s=$L(e),i=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,a<=i&&(i=a)):i=a=r+5,r+4<=i&&t!==-1?JC(e,t,r,n):e.strategy===4||a===i?(Si(e,(NC<<1)+(n?1:0),3),RC(e,vu,Xf)):(Si(e,(bL<<1)+(n?1:0),3),PL(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),RC(e,e.dyn_ltree,e.dyn_dtree)),WC(e),n&&XC(e)},kL=(e,t,r)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=r,t===0?e.dyn_ltree[r*2]++:(e.matches++,t--,e.dyn_ltree[(Qf[r]+th+1)*2]++,e.dyn_dtree[zC(t)*2]++),e.sym_next===e.sym_end);yc.exports._tr_init=RL;yc.exports._tr_stored_block=JC;yc.exports._tr_flush_block=OL;yc.exports._tr_tally=kL;yc.exports._tr_align=TL});var dv=he((_W,QC)=>{"use strict";var NL=(e,t,r,n)=>{let i=e&65535|0,a=e>>>16&65535|0,s=0;for(;r!==0;){s=r>2e3?2e3:r,r-=s;do i=i+t[n++]|0,a=a+i|0;while(--s);i%=65521,a%=65521}return i|a<<16|0};QC.exports=NL});var pv=he((CW,e6)=>{"use strict";var LL=()=>{let e,t=[];for(var r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;t[r]=e}return t},UL=new Uint32Array(LL()),jL=(e,t,r,n)=>{let i=UL,a=n+r;e^=-1;for(let s=n;s>>8^i[(e^t[s])&255];return e^-1};e6.exports=jL});var Xd=he((DW,t6)=>{"use strict";t6.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}});var Ju=he((FW,r6)=>{"use strict";r6.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}});var h6=he((SW,Fa)=>{"use strict";var{_tr_init:HL,_tr_stored_block:vv,_tr_flush_block:ML,_tr_tally:to,_tr_align:qL}=ZC(),a6=dv(),Zu=pv(),VL=Xd(),{Z_NO_FLUSH:ro,Z_PARTIAL_FLUSH:KL,Z_FULL_FLUSH:zL,Z_FINISH:gs,Z_BLOCK:n6,Z_OK:Sn,Z_STREAM_END:i6,Z_STREAM_ERROR:Ca,Z_DATA_ERROR:GL,Z_BUF_ERROR:gv,Z_DEFAULT_COMPRESSION:YL,Z_FILTERED:WL,Z_HUFFMAN_ONLY:Jd,Z_RLE:XL,Z_FIXED:JL,Z_DEFAULT_STRATEGY:ZL,Z_UNKNOWN:QL,Z_DEFLATED:Zd}=Ju(),eU=9,tU=15,rU=8,nU=29,iU=256,wv=iU+1+nU,sU=30,aU=19,uU=2*wv+1,oU=15,Bt=3,eo=258,Da=eo+Bt+1,lU=32,Cc=42,Cv=57,Av=69,Ev=73,bv=91,yv=103,al=113,nh=666,ai=1,Fc=2,ol=3,Sc=4,cU=3,ul=(e,t)=>(e.msg=VL[t],t),s6=e=>e*2-(e>4?9:0),Qu=e=>{let t=e.length;for(;--t>=0;)e[t]=0},fU=e=>{let t,r,n,i=e.w_size;t=e.hash_size,n=t;do r=e.head[--n],e.head[n]=r>=i?r-i:0;while(--t);t=i,n=t;do r=e.prev[--n],e.prev[n]=r>=i?r-i:0;while(--t)},hU=(e,t,r)=>(t<{let t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),r!==0&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+r),e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,t.pending===0&&(t.pending_out=0))},Xi=(e,t)=>{ML(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Wi(e.strm)},Ht=(e,t)=>{e.pending_buf[e.pending++]=t},rh=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},_v=(e,t,r,n)=>{let i=e.avail_in;return i>n&&(i=n),i===0?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),r),e.state.wrap===1?e.adler=a6(e.adler,t,i,r):e.state.wrap===2&&(e.adler=Zu(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)},u6=(e,t)=>{let r=e.max_chain_length,n=e.strstart,i,a,s=e.prev_length,u=e.nice_match,l=e.strstart>e.w_size-Da?e.strstart-(e.w_size-Da):0,f=e.window,d=e.w_mask,m=e.prev,p=e.strstart+eo,h=f[n+s-1],w=f[n+s];e.prev_length>=e.good_match&&(r>>=2),u>e.lookahead&&(u=e.lookahead);do if(i=t,!(f[i+s]!==w||f[i+s-1]!==h||f[i]!==f[n]||f[++i]!==f[n+1])){n+=2,i++;do;while(f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&ns){if(e.match_start=t,s=a,a>=u)break;h=f[n+s-1],w=f[n+s]}}while((t=m[t&d])>l&&--r!==0);return s<=e.lookahead?s:e.lookahead},Dc=e=>{let t=e.w_size,r,n,i;do{if(n=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Da)&&(e.window.set(e.window.subarray(t,t+t-n),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),fU(e),n+=t),e.strm.avail_in===0)break;if(r=_v(e.strm,e.window,e.strstart+e.lookahead,n),e.lookahead+=r,e.lookahead+e.insert>=Bt)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=no(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=no(e,e.ins_h,e.window[i+Bt-1]),e.prev[i&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=i,i++,e.insert--,!(e.lookahead+e.insert{let r=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,n,i,a,s=0,u=e.strm.avail_in;do{if(n=65535,a=e.bi_valid+42>>3,e.strm.avail_outi+e.strm.avail_in&&(n=i+e.strm.avail_in),n>a&&(n=a),n>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,Wi(e.strm),i&&(i>n&&(i=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+i),e.strm.next_out),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i,e.block_start+=i,n-=i),n&&(_v(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(s===0);return u-=e.strm.avail_in,u&&(u>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=u&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-u,e.strm.next_in),e.strstart),e.strstart+=u,e.insert+=u>e.w_size-e.insert?e.w_size-e.insert:u),e.block_start=e.strstart),e.high_watera&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,a+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),a>e.strm.avail_in&&(a=e.strm.avail_in),a&&(_v(e.strm,e.window,e.strstart,a),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.high_water>3,a=e.pending_buf_size-a>65535?65535:e.pending_buf_size-a,r=a>e.w_size?e.w_size:a,i=e.strstart-e.block_start,(i>=r||(i||t===gs)&&t!==ro&&e.strm.avail_in===0&&i<=a)&&(n=i>a?a:i,s=t===gs&&e.strm.avail_in===0&&n===i?1:0,vv(e,e.block_start,n,s),e.block_start+=n,Wi(e.strm)),s?ol:ai)},mv=(e,t)=>{let r,n;for(;;){if(e.lookahead=Bt&&(e.ins_h=no(e,e.ins_h,e.window[e.strstart+Bt-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),r!==0&&e.strstart-r<=e.w_size-Da&&(e.match_length=u6(e,r)),e.match_length>=Bt)if(n=to(e,e.strstart-e.match_start,e.match_length-Bt),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=Bt){e.match_length--;do e.strstart++,e.ins_h=no(e,e.ins_h,e.window[e.strstart+Bt-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=no(e,e.ins_h,e.window[e.strstart+1]);else n=to(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(Xi(e,!1),e.strm.avail_out===0))return ai}return e.insert=e.strstart{let r,n,i;for(;;){if(e.lookahead=Bt&&(e.ins_h=no(e,e.ins_h,e.window[e.strstart+Bt-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=Bt-1,r!==0&&e.prev_length4096)&&(e.match_length=Bt-1)),e.prev_length>=Bt&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-Bt,n=to(e,e.strstart-1-e.prev_match,e.prev_length-Bt),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=no(e,e.ins_h,e.window[e.strstart+Bt-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=Bt-1,e.strstart++,n&&(Xi(e,!1),e.strm.avail_out===0))return ai}else if(e.match_available){if(n=to(e,0,e.window[e.strstart-1]),n&&Xi(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return ai}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=to(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart{let r,n,i,a,s=e.window;for(;;){if(e.lookahead<=eo){if(Dc(e),e.lookahead<=eo&&t===ro)return ai;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=Bt&&e.strstart>0&&(i=e.strstart-1,n=s[i],n===s[++i]&&n===s[++i]&&n===s[++i])){a=e.strstart+eo;do;while(n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=Bt?(r=to(e,1,e.match_length-Bt),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=to(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(Xi(e,!1),e.strm.avail_out===0))return ai}return e.insert=0,t===gs?(Xi(e,!0),e.strm.avail_out===0?ol:Sc):e.sym_next&&(Xi(e,!1),e.strm.avail_out===0)?ai:Fc},pU=(e,t)=>{let r;for(;;){if(e.lookahead===0&&(Dc(e),e.lookahead===0)){if(t===ro)return ai;break}if(e.match_length=0,r=to(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(Xi(e,!1),e.strm.avail_out===0))return ai}return e.insert=0,t===gs?(Xi(e,!0),e.strm.avail_out===0?ol:Sc):e.sym_next&&(Xi(e,!1),e.strm.avail_out===0)?ai:Fc};function _a(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}var ih=[new _a(0,0,0,0,o6),new _a(4,4,8,4,mv),new _a(4,5,16,8,mv),new _a(4,6,32,32,mv),new _a(4,4,16,16,_c),new _a(8,16,32,32,_c),new _a(8,16,128,128,_c),new _a(8,32,128,256,_c),new _a(32,128,258,1024,_c),new _a(32,258,258,4096,_c)],gU=e=>{e.window_size=2*e.w_size,Qu(e.head),e.max_lazy_match=ih[e.level].max_lazy,e.good_match=ih[e.level].good_length,e.nice_match=ih[e.level].nice_length,e.max_chain_length=ih[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=Bt-1,e.match_available=0,e.ins_h=0};function mU(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Zd,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(uU*2),this.dyn_dtree=new Uint16Array((2*sU+1)*2),this.bl_tree=new Uint16Array((2*aU+1)*2),Qu(this.dyn_ltree),Qu(this.dyn_dtree),Qu(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(oU+1),this.heap=new Uint16Array(2*wv+1),Qu(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*wv+1),Qu(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var sh=e=>{if(!e)return 1;let t=e.state;return!t||t.strm!==e||t.status!==Cc&&t.status!==Cv&&t.status!==Av&&t.status!==Ev&&t.status!==bv&&t.status!==yv&&t.status!==al&&t.status!==nh?1:0},l6=e=>{if(sh(e))return ul(e,Ca);e.total_in=e.total_out=0,e.data_type=QL;let t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?Cv:t.wrap?Cc:al,e.adler=t.wrap===2?0:1,t.last_flush=-2,HL(t),Sn},c6=e=>{let t=l6(e);return t===Sn&&gU(e.state),t},vU=(e,t)=>sh(e)||e.state.wrap!==2?Ca:(e.state.gzhead=t,Sn),f6=(e,t,r,n,i,a)=>{if(!e)return Ca;let s=1;if(t===YL&&(t=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),i<1||i>eU||r!==Zd||n<8||n>15||t<0||t>9||a<0||a>JL||n===8&&s!==1)return ul(e,Ca);n===8&&(n=9);let u=new mU;return e.state=u,u.strm=e,u.status=Cc,u.wrap=s,u.gzhead=null,u.w_bits=n,u.w_size=1<f6(e,t,Zd,tU,rU,ZL),AU=(e,t)=>{if(sh(e)||t>n6||t<0)return e?ul(e,Ca):Ca;let r=e.state;if(!e.output||e.avail_in!==0&&!e.input||r.status===nh&&t!==gs)return ul(e,e.avail_out===0?gv:Ca);let n=r.last_flush;if(r.last_flush=t,r.pending!==0){if(Wi(e),e.avail_out===0)return r.last_flush=-1,Sn}else if(e.avail_in===0&&s6(t)<=s6(n)&&t!==gs)return ul(e,gv);if(r.status===nh&&e.avail_in!==0)return ul(e,gv);if(r.status===Cc&&r.wrap===0&&(r.status=al),r.status===Cc){let i=Zd+(r.w_bits-8<<4)<<8,a=-1;if(r.strategy>=Jd||r.level<2?a=0:r.level<6?a=1:r.level===6?a=2:a=3,i|=a<<6,r.strstart!==0&&(i|=lU),i+=31-i%31,rh(r,i),r.strstart!==0&&(rh(r,e.adler>>>16),rh(r,e.adler&65535)),e.adler=1,r.status=al,Wi(e),r.pending!==0)return r.last_flush=-1,Sn}if(r.status===Cv){if(e.adler=0,Ht(r,31),Ht(r,139),Ht(r,8),r.gzhead)Ht(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),Ht(r,r.gzhead.time&255),Ht(r,r.gzhead.time>>8&255),Ht(r,r.gzhead.time>>16&255),Ht(r,r.gzhead.time>>24&255),Ht(r,r.level===9?2:r.strategy>=Jd||r.level<2?4:0),Ht(r,r.gzhead.os&255),r.gzhead.extra&&r.gzhead.extra.length&&(Ht(r,r.gzhead.extra.length&255),Ht(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=Zu(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=Av;else if(Ht(r,0),Ht(r,0),Ht(r,0),Ht(r,0),Ht(r,0),Ht(r,r.level===9?2:r.strategy>=Jd||r.level<2?4:0),Ht(r,cU),r.status=al,Wi(e),r.pending!==0)return r.last_flush=-1,Sn}if(r.status===Av){if(r.gzhead.extra){let i=r.pending,a=(r.gzhead.extra.length&65535)-r.gzindex;for(;r.pending+a>r.pending_buf_size;){let u=r.pending_buf_size-r.pending;if(r.pending_buf.set(r.gzhead.extra.subarray(r.gzindex,r.gzindex+u),r.pending),r.pending=r.pending_buf_size,r.gzhead.hcrc&&r.pending>i&&(e.adler=Zu(e.adler,r.pending_buf,r.pending-i,i)),r.gzindex+=u,Wi(e),r.pending!==0)return r.last_flush=-1,Sn;i=0,a-=u}let s=new Uint8Array(r.gzhead.extra);r.pending_buf.set(s.subarray(r.gzindex,r.gzindex+a),r.pending),r.pending+=a,r.gzhead.hcrc&&r.pending>i&&(e.adler=Zu(e.adler,r.pending_buf,r.pending-i,i)),r.gzindex=0}r.status=Ev}if(r.status===Ev){if(r.gzhead.name){let i=r.pending,a;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>i&&(e.adler=Zu(e.adler,r.pending_buf,r.pending-i,i)),Wi(e),r.pending!==0)return r.last_flush=-1,Sn;i=0}r.gzindexi&&(e.adler=Zu(e.adler,r.pending_buf,r.pending-i,i)),r.gzindex=0}r.status=bv}if(r.status===bv){if(r.gzhead.comment){let i=r.pending,a;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>i&&(e.adler=Zu(e.adler,r.pending_buf,r.pending-i,i)),Wi(e),r.pending!==0)return r.last_flush=-1,Sn;i=0}r.gzindexi&&(e.adler=Zu(e.adler,r.pending_buf,r.pending-i,i))}r.status=yv}if(r.status===yv){if(r.gzhead.hcrc){if(r.pending+2>r.pending_buf_size&&(Wi(e),r.pending!==0))return r.last_flush=-1,Sn;Ht(r,e.adler&255),Ht(r,e.adler>>8&255),e.adler=0}if(r.status=al,Wi(e),r.pending!==0)return r.last_flush=-1,Sn}if(e.avail_in!==0||r.lookahead!==0||t!==ro&&r.status!==nh){let i=r.level===0?o6(r,t):r.strategy===Jd?pU(r,t):r.strategy===XL?dU(r,t):ih[r.level].func(r,t);if((i===ol||i===Sc)&&(r.status=nh),i===ai||i===ol)return e.avail_out===0&&(r.last_flush=-1),Sn;if(i===Fc&&(t===KL?qL(r):t!==n6&&(vv(r,0,0,!1),t===zL&&(Qu(r.head),r.lookahead===0&&(r.strstart=0,r.block_start=0,r.insert=0))),Wi(e),e.avail_out===0))return r.last_flush=-1,Sn}return t!==gs?Sn:r.wrap<=0?i6:(r.wrap===2?(Ht(r,e.adler&255),Ht(r,e.adler>>8&255),Ht(r,e.adler>>16&255),Ht(r,e.adler>>24&255),Ht(r,e.total_in&255),Ht(r,e.total_in>>8&255),Ht(r,e.total_in>>16&255),Ht(r,e.total_in>>24&255)):(rh(r,e.adler>>>16),rh(r,e.adler&65535)),Wi(e),r.wrap>0&&(r.wrap=-r.wrap),r.pending!==0?Sn:i6)},EU=e=>{if(sh(e))return Ca;let t=e.state.status;return e.state=null,t===al?ul(e,GL):Sn},bU=(e,t)=>{let r=t.length;if(sh(e))return Ca;let n=e.state,i=n.wrap;if(i===2||i===1&&n.status!==Cc||n.lookahead)return Ca;if(i===1&&(e.adler=a6(e.adler,t,r,0)),n.wrap=0,r>=n.w_size){i===0&&(Qu(n.head),n.strstart=0,n.block_start=0,n.insert=0);let l=new Uint8Array(n.w_size);l.set(t.subarray(r-n.w_size,r),0),t=l,r=n.w_size}let a=e.avail_in,s=e.next_in,u=e.input;for(e.avail_in=r,e.next_in=0,e.input=t,Dc(n);n.lookahead>=Bt;){let l=n.strstart,f=n.lookahead-(Bt-1);do n.ins_h=no(n,n.ins_h,n.window[l+Bt-1]),n.prev[l&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=l,l++;while(--f);n.strstart=l,n.lookahead=Bt-1,Dc(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=Bt-1,n.match_available=0,e.next_in=s,e.input=u,e.avail_in=a,n.wrap=i,Sn};Fa.exports.deflateInit=wU;Fa.exports.deflateInit2=f6;Fa.exports.deflateReset=c6;Fa.exports.deflateResetKeep=l6;Fa.exports.deflateSetHeader=vU;Fa.exports.deflate=AU;Fa.exports.deflateEnd=EU;Fa.exports.deflateSetDictionary=bU;Fa.exports.deflateInfo="pako deflate (from Nodeca project)"});var Fv=he((IW,Dv)=>{"use strict";var yU=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);Dv.exports.assign=function(e){let t=Array.prototype.slice.call(arguments,1);for(;t.length;){let r=t.shift();if(r){if(typeof r!="object")throw new TypeError(r+"must be non-object");for(let n in r)yU(r,n)&&(e[n]=r[n])}}return e};Dv.exports.flattenChunks=e=>{let t=0;for(let n=0,i=e.length;n{"use strict";var d6=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{d6=!1}var ah=new Uint8Array(256);for(let e=0;e<256;e++)ah[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;ah[254]=ah[254]=1;Qd.exports.string2buf=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,r,n,i,a,s=e.length,u=0;for(i=0;i>>6,t[a++]=128|r&63):r<65536?(t[a++]=224|r>>>12,t[a++]=128|r>>>6&63,t[a++]=128|r&63):(t[a++]=240|r>>>18,t[a++]=128|r>>>12&63,t[a++]=128|r>>>6&63,t[a++]=128|r&63);return t};var _U=(e,t)=>{if(t<65534&&e.subarray&&d6)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let r="";for(let n=0;n{let r=t||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,t));let n,i,a=new Array(r*2);for(i=0,n=0;n4){a[i++]=65533,n+=u-1;continue}for(s&=u===2?31:u===3?15:7;u>1&&n1){a[i++]=65533;continue}s<65536?a[i++]=s:(s-=65536,a[i++]=55296|s>>10&1023,a[i++]=56320|s&1023)}return _U(a,i)};Qd.exports.utf8border=(e,t)=>{t=t||e.length,t>e.length&&(t=e.length);let r=t-1;for(;r>=0&&(e[r]&192)===128;)r--;return r<0||r===0?t:r+ah[e[r]]>t?r:t}});var Iv=he(($W,p6)=>{"use strict";function CU(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}p6.exports=CU});var w6=he((PW,Ic)=>{"use strict";var uh=h6(),g6=Fv(),m6=Sv(),Bv=Xd(),DU=Iv(),v6=Object.prototype.toString,{Z_NO_FLUSH:FU,Z_SYNC_FLUSH:SU,Z_FULL_FLUSH:IU,Z_FINISH:BU,Z_OK:ep,Z_STREAM_END:$U,Z_DEFAULT_COMPRESSION:PU,Z_DEFAULT_STRATEGY:xU,Z_DEFLATED:RU}=Ju();function oh(e){this.options=g6.assign({level:PU,method:RU,chunkSize:16384,windowBits:15,memLevel:8,strategy:xU},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new DU,this.strm.avail_out=0;let r=uh.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==ep)throw new Error(Bv[r]);if(t.header&&uh.deflateSetHeader(this.strm,t.header),t.dictionary){let n;if(typeof t.dictionary=="string"?n=m6.string2buf(t.dictionary):v6.call(t.dictionary)==="[object ArrayBuffer]"?n=new Uint8Array(t.dictionary):n=t.dictionary,r=uh.deflateSetDictionary(this.strm,n),r!==ep)throw new Error(Bv[r]);this._dict_set=!0}}oh.prototype.push=function(e,t){let r=this.strm,n=this.options.chunkSize,i,a;if(this.ended)return!1;for(t===~~t?a=t:a=t===!0?BU:FU,typeof e=="string"?r.input=m6.string2buf(e):v6.call(e)==="[object ArrayBuffer]"?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){if(r.avail_out===0&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(a===SU||a===IU)&&r.avail_out<=6){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if(i=uh.deflate(r,a),i===$U)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),i=uh.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===ep;if(r.avail_out===0){this.onData(r.output);continue}if(a>0&&r.next_out>0){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if(r.avail_in===0)break}return!0};oh.prototype.onData=function(e){this.chunks.push(e)};oh.prototype.onEnd=function(e){e===ep&&(this.result=g6.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function $v(e,t){let r=new oh(t);if(r.push(e,!0),r.err)throw r.msg||Bv[r.err];return r.result}function TU(e,t){return t=t||{},t.raw=!0,$v(e,t)}function OU(e,t){return t=t||{},t.gzip=!0,$v(e,t)}Ic.exports.Deflate=oh;Ic.exports.deflate=$v;Ic.exports.deflateRaw=TU;Ic.exports.gzip=OU;Ic.exports.constants=Ju()});var E6=he((xW,A6)=>{"use strict";A6.exports=function(t,r){let n,i,a,s,u,l,f,d,m,p,h,w,v,y,g,b,D,C,F,U,L,S,B,O,x=t.state;n=t.next_in,B=t.input,i=n+(t.avail_in-5),a=t.next_out,O=t.output,s=a-(r-t.avail_out),u=a+(t.avail_out-257),l=x.dmax,f=x.wsize,d=x.whave,m=x.wnext,p=x.window,h=x.hold,w=x.bits,v=x.lencode,y=x.distcode,g=(1<>>24,h>>>=C,w-=C,C=D>>>16&255,C===0)O[a++]=D&65535;else if(C&16){F=D&65535,C&=15,C&&(w>>=C,w-=C),w<15&&(h+=B[n++]<>>24,h>>>=C,w-=C,C=D>>>16&255,C&16){if(U=D&65535,C&=15,wl){t.msg="invalid distance too far back",x.mode=16209;break e}if(h>>>=C,w-=C,C=a-s,U>C){if(C=U-C,C>d&&x.sane){t.msg="invalid distance too far back",x.mode=16209;break e}if(L=0,S=p,m===0){if(L+=f-C,C2;)O[a++]=S[L++],O[a++]=S[L++],O[a++]=S[L++],F-=3;F&&(O[a++]=S[L++],F>1&&(O[a++]=S[L++]))}else{L=a-U;do O[a++]=O[L++],O[a++]=O[L++],O[a++]=O[L++],F-=3;while(F>2);F&&(O[a++]=O[L++],F>1&&(O[a++]=O[L++]))}}else if(C&64){t.msg="invalid distance code",x.mode=16209;break e}else{D=y[(D&65535)+(h&(1<>3,n-=F,w-=F<<3,h&=(1<{"use strict";var kU=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),NU=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),LU=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),UU=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),jU=(e,t,r,n,i,a,s,u)=>{let l=u.bits,f=0,d=0,m=0,p=0,h=0,w=0,v=0,y=0,g=0,b=0,D,C,F,U,L,S=null,B,O=new Uint16Array(16),x=new Uint16Array(16),j=null,Y,M,z;for(f=0;f<=15;f++)O[f]=0;for(d=0;d=1&&O[p]===0;p--);if(h>p&&(h=p),p===0)return i[a++]=1<<24|64<<16|0,i[a++]=1<<24|64<<16|0,u.bits=1,0;for(m=1;m0&&(e===0||p!==1))return-1;for(x[1]=0,f=1;f<15;f++)x[f+1]=x[f]+O[f];for(d=0;d852||e===2&&g>592)return 1;for(;;){Y=f-v,s[d]+1=B?(M=j[s[d]-B],z=S[s[d]-B]):(M=96,z=0),D=1<>v)+C]=Y<<24|M<<16|z|0;while(C!==0);for(D=1<>=1;if(D!==0?(b&=D-1,b+=D):b=0,d++,--O[f]===0){if(f===p)break;f=t[r+s[d]]}if(f>h&&(b&U)!==F){for(v===0&&(v=h),L+=m,w=f-v,y=1<852||e===2&&g>592)return 1;F=b&U,i[F]=h<<24|w<<16|L-a|0}}return b!==0&&(i[L+b]=f-v<<24|64<<16|0),u.bits=h,0};b6.exports=jU});var n4=he((TW,Ts)=>{"use strict";var kv=dv(),Sa=pv(),HU=E6(),lh=y6(),MU=0,Y6=1,W6=2,{Z_FINISH:_6,Z_BLOCK:qU,Z_TREES:tp,Z_OK:ll,Z_STREAM_END:VU,Z_NEED_DICT:KU,Z_STREAM_ERROR:vs,Z_DATA_ERROR:X6,Z_MEM_ERROR:Nv,Z_BUF_ERROR:zU,Z_DEFLATED:C6}=Ju(),sp=16180,D6=16181,F6=16182,S6=16183,I6=16184,B6=16185,$6=16186,P6=16187,x6=16188,R6=16189,ip=16190,wu=16191,Pv=16192,T6=16193,xv=16194,O6=16195,k6=16196,N6=16197,L6=16198,rp=16199,np=16200,U6=16201,j6=16202,H6=16203,M6=16204,q6=16205,Rv=16206,V6=16207,K6=16208,vr=16209,Lv=16210,J6=16211,GU=852,YU=592,WU=15,XU=WU,z6=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function JU(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var cl=e=>{if(!e)return 1;let t=e.state;return!t||t.strm!==e||t.modeJ6?1:0},Z6=e=>{if(cl(e))return vs;let t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=sp,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(GU),t.distcode=t.distdyn=new Int32Array(YU),t.sane=1,t.back=-1,ll},Q6=e=>{if(cl(e))return vs;let t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Z6(e)},e4=(e,t)=>{let r;if(cl(e))return vs;let n=e.state;return t<0?(r=0,t=-t):(r=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?vs:(n.window!==null&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,Q6(e))},t4=(e,t)=>{if(!e)return vs;let r=new JU;e.state=r,r.strm=e,r.window=null,r.mode=sp;let n=e4(e,t);return n!==ll&&(e.state=null),n},ZU=e=>t4(e,XU),G6=!0,Tv,Ov,QU=e=>{if(G6){Tv=new Int32Array(512),Ov=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(lh(Y6,e.lens,0,288,Tv,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;lh(W6,e.lens,0,32,Ov,0,e.work,{bits:5}),G6=!1}e.lencode=Tv,e.lenbits=9,e.distcode=Ov,e.distbits=5},r4=(e,t,r,n)=>{let i,a=e.state;return a.window===null&&(a.wsize=1<=a.wsize?(a.window.set(t.subarray(r-a.wsize,r),0),a.wnext=0,a.whave=a.wsize):(i=a.wsize-a.wnext,i>n&&(i=n),a.window.set(t.subarray(r-n,r-n+i),a.wnext),n-=i,n?(a.window.set(t.subarray(r-n,r),0),a.wnext=n,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave{let r,n,i,a,s,u,l,f,d,m,p,h,w,v,y=0,g,b,D,C,F,U,L,S,B=new Uint8Array(4),O,x,j=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(cl(e)||!e.output||!e.input&&e.avail_in!==0)return vs;r=e.state,r.mode===wu&&(r.mode=Pv),s=e.next_out,i=e.output,l=e.avail_out,a=e.next_in,n=e.input,u=e.avail_in,f=r.hold,d=r.bits,m=u,p=l,S=ll;e:for(;;)switch(r.mode){case sp:if(r.wrap===0){r.mode=Pv;break}for(;d<16;){if(u===0)break e;u--,f+=n[a++]<>>8&255,r.check=Sa(r.check,B,2,0),f=0,d=0,r.mode=D6;break}if(r.head&&(r.head.done=!1),!(r.wrap&1)||(((f&255)<<8)+(f>>8))%31){e.msg="incorrect header check",r.mode=vr;break}if((f&15)!==C6){e.msg="unknown compression method",r.mode=vr;break}if(f>>>=4,d-=4,L=(f&15)+8,r.wbits===0&&(r.wbits=L),L>15||L>r.wbits){e.msg="invalid window size",r.mode=vr;break}r.dmax=1<>8&1),r.flags&512&&r.wrap&4&&(B[0]=f&255,B[1]=f>>>8&255,r.check=Sa(r.check,B,2,0)),f=0,d=0,r.mode=F6;case F6:for(;d<32;){if(u===0)break e;u--,f+=n[a++]<>>8&255,B[2]=f>>>16&255,B[3]=f>>>24&255,r.check=Sa(r.check,B,4,0)),f=0,d=0,r.mode=S6;case S6:for(;d<16;){if(u===0)break e;u--,f+=n[a++]<>8),r.flags&512&&r.wrap&4&&(B[0]=f&255,B[1]=f>>>8&255,r.check=Sa(r.check,B,2,0)),f=0,d=0,r.mode=I6;case I6:if(r.flags&1024){for(;d<16;){if(u===0)break e;u--,f+=n[a++]<>>8&255,r.check=Sa(r.check,B,2,0)),f=0,d=0}else r.head&&(r.head.extra=null);r.mode=B6;case B6:if(r.flags&1024&&(h=r.length,h>u&&(h=u),h&&(r.head&&(L=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(a,a+h),L)),r.flags&512&&r.wrap&4&&(r.check=Sa(r.check,n,h,a)),u-=h,a+=h,r.length-=h),r.length))break e;r.length=0,r.mode=$6;case $6:if(r.flags&2048){if(u===0)break e;h=0;do L=n[a+h++],r.head&&L&&r.length<65536&&(r.head.name+=String.fromCharCode(L));while(L&&h>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=wu;break;case R6:for(;d<32;){if(u===0)break e;u--,f+=n[a++]<>>=d&7,d-=d&7,r.mode=Rv;break}for(;d<3;){if(u===0)break e;u--,f+=n[a++]<>>=1,d-=1,f&3){case 0:r.mode=T6;break;case 1:if(QU(r),r.mode=rp,t===tp){f>>>=2,d-=2;break e}break;case 2:r.mode=k6;break;case 3:e.msg="invalid block type",r.mode=vr}f>>>=2,d-=2;break;case T6:for(f>>>=d&7,d-=d&7;d<32;){if(u===0)break e;u--,f+=n[a++]<>>16^65535)){e.msg="invalid stored block lengths",r.mode=vr;break}if(r.length=f&65535,f=0,d=0,r.mode=xv,t===tp)break e;case xv:r.mode=O6;case O6:if(h=r.length,h){if(h>u&&(h=u),h>l&&(h=l),h===0)break e;i.set(n.subarray(a,a+h),s),u-=h,a+=h,l-=h,s+=h,r.length-=h;break}r.mode=wu;break;case k6:for(;d<14;){if(u===0)break e;u--,f+=n[a++]<>>=5,d-=5,r.ndist=(f&31)+1,f>>>=5,d-=5,r.ncode=(f&15)+4,f>>>=4,d-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=vr;break}r.have=0,r.mode=N6;case N6:for(;r.have>>=3,d-=3}for(;r.have<19;)r.lens[j[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,O={bits:r.lenbits},S=lh(MU,r.lens,0,19,r.lencode,0,r.work,O),r.lenbits=O.bits,S){e.msg="invalid code lengths set",r.mode=vr;break}r.have=0,r.mode=L6;case L6:for(;r.have>>24,b=y>>>16&255,D=y&65535,!(g<=d);){if(u===0)break e;u--,f+=n[a++]<>>=g,d-=g,r.lens[r.have++]=D;else{if(D===16){for(x=g+2;d>>=g,d-=g,r.have===0){e.msg="invalid bit length repeat",r.mode=vr;break}L=r.lens[r.have-1],h=3+(f&3),f>>>=2,d-=2}else if(D===17){for(x=g+3;d>>=g,d-=g,L=0,h=3+(f&7),f>>>=3,d-=3}else{for(x=g+7;d>>=g,d-=g,L=0,h=11+(f&127),f>>>=7,d-=7}if(r.have+h>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=vr;break}for(;h--;)r.lens[r.have++]=L}}if(r.mode===vr)break;if(r.lens[256]===0){e.msg="invalid code -- missing end-of-block",r.mode=vr;break}if(r.lenbits=9,O={bits:r.lenbits},S=lh(Y6,r.lens,0,r.nlen,r.lencode,0,r.work,O),r.lenbits=O.bits,S){e.msg="invalid literal/lengths set",r.mode=vr;break}if(r.distbits=6,r.distcode=r.distdyn,O={bits:r.distbits},S=lh(W6,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,O),r.distbits=O.bits,S){e.msg="invalid distances set",r.mode=vr;break}if(r.mode=rp,t===tp)break e;case rp:r.mode=np;case np:if(u>=6&&l>=258){e.next_out=s,e.avail_out=l,e.next_in=a,e.avail_in=u,r.hold=f,r.bits=d,HU(e,p),s=e.next_out,i=e.output,l=e.avail_out,a=e.next_in,n=e.input,u=e.avail_in,f=r.hold,d=r.bits,r.mode===wu&&(r.back=-1);break}for(r.back=0;y=r.lencode[f&(1<>>24,b=y>>>16&255,D=y&65535,!(g<=d);){if(u===0)break e;u--,f+=n[a++]<>C)],g=y>>>24,b=y>>>16&255,D=y&65535,!(C+g<=d);){if(u===0)break e;u--,f+=n[a++]<>>=C,d-=C,r.back+=C}if(f>>>=g,d-=g,r.back+=g,r.length=D,b===0){r.mode=q6;break}if(b&32){r.back=-1,r.mode=wu;break}if(b&64){e.msg="invalid literal/length code",r.mode=vr;break}r.extra=b&15,r.mode=U6;case U6:if(r.extra){for(x=r.extra;d>>=r.extra,d-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=j6;case j6:for(;y=r.distcode[f&(1<>>24,b=y>>>16&255,D=y&65535,!(g<=d);){if(u===0)break e;u--,f+=n[a++]<>C)],g=y>>>24,b=y>>>16&255,D=y&65535,!(C+g<=d);){if(u===0)break e;u--,f+=n[a++]<>>=C,d-=C,r.back+=C}if(f>>>=g,d-=g,r.back+=g,b&64){e.msg="invalid distance code",r.mode=vr;break}r.offset=D,r.extra=b&15,r.mode=H6;case H6:if(r.extra){for(x=r.extra;d>>=r.extra,d-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=vr;break}r.mode=M6;case M6:if(l===0)break e;if(h=p-l,r.offset>h){if(h=r.offset-h,h>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=vr;break}h>r.wnext?(h-=r.wnext,w=r.wsize-h):w=r.wnext-h,h>r.length&&(h=r.length),v=r.window}else v=i,w=s-r.offset,h=r.length;h>l&&(h=l),l-=h,r.length-=h;do i[s++]=v[w++];while(--h);r.length===0&&(r.mode=np);break;case q6:if(l===0)break e;i[s++]=r.length,l--,r.mode=np;break;case Rv:if(r.wrap){for(;d<32;){if(u===0)break e;u--,f|=n[a++]<{if(cl(e))return vs;let t=e.state;return t.window&&(t.window=null),e.state=null,ll},rj=(e,t)=>{if(cl(e))return vs;let r=e.state;return r.wrap&2?(r.head=t,t.done=!1,ll):vs},nj=(e,t)=>{let r=t.length,n,i,a;return cl(e)||(n=e.state,n.wrap!==0&&n.mode!==ip)?vs:n.mode===ip&&(i=1,i=kv(i,t,r,0),i!==n.check)?X6:(a=r4(e,t,r,r),a?(n.mode=Lv,Nv):(n.havedict=1,ll))};Ts.exports.inflateReset=Q6;Ts.exports.inflateReset2=e4;Ts.exports.inflateResetKeep=Z6;Ts.exports.inflateInit=ZU;Ts.exports.inflateInit2=t4;Ts.exports.inflate=ej;Ts.exports.inflateEnd=tj;Ts.exports.inflateGetHeader=rj;Ts.exports.inflateSetDictionary=nj;Ts.exports.inflateInfo="pako inflate (from Nodeca project)"});var s4=he((OW,i4)=>{"use strict";function ij(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}i4.exports=ij});var l4=he((kW,Bc)=>{"use strict";var Au=n4(),u4=Fv(),Hv=Sv(),Mv=Xd(),sj=Iv(),aj=s4(),o4=Object.prototype.toString,{Z_NO_FLUSH:uj,Z_FINISH:oj,Z_OK:ch,Z_STREAM_END:Uv,Z_NEED_DICT:jv,Z_STREAM_ERROR:lj,Z_DATA_ERROR:a4,Z_MEM_ERROR:cj}=Ju();function fh(e){this.options=u4.assign({chunkSize:1024*64,windowBits:15,to:""},e||{});let t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new sj,this.strm.avail_out=0;let r=Au.inflateInit2(this.strm,t.windowBits);if(r!==ch)throw new Error(Mv[r]);if(this.header=new aj,Au.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=Hv.string2buf(t.dictionary):o4.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=Au.inflateSetDictionary(this.strm,t.dictionary),r!==ch)))throw new Error(Mv[r])}fh.prototype.push=function(e,t){let r=this.strm,n=this.options.chunkSize,i=this.options.dictionary,a,s,u;if(this.ended)return!1;for(t===~~t?s=t:s=t===!0?oj:uj,o4.call(e)==="[object ArrayBuffer]"?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){for(r.avail_out===0&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),a=Au.inflate(r,s),a===jv&&i&&(a=Au.inflateSetDictionary(r,i),a===ch?a=Au.inflate(r,s):a===a4&&(a=jv));r.avail_in>0&&a===Uv&&r.state.wrap>0&&e[r.next_in]!==0;)Au.inflateReset(r),a=Au.inflate(r,s);switch(a){case lj:case a4:case jv:case cj:return this.onEnd(a),this.ended=!0,!1}if(u=r.avail_out,r.next_out&&(r.avail_out===0||a===Uv))if(this.options.to==="string"){let l=Hv.utf8border(r.output,r.next_out),f=r.next_out-l,d=Hv.buf2string(r.output,l);r.next_out=f,r.avail_out=n-f,f&&r.output.set(r.output.subarray(l,l+f),0),this.onData(d)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(!(a===ch&&u===0)){if(a===Uv)return a=Au.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(r.avail_in===0)break}}return!0};fh.prototype.onData=function(e){this.chunks.push(e)};fh.prototype.onEnd=function(e){e===ch&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=u4.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function qv(e,t){let r=new fh(t);if(r.push(e),r.err)throw r.msg||Mv[r.err];return r.result}function fj(e,t){return t=t||{},t.raw=!0,qv(e,t)}Bc.exports.Inflate=fh;Bc.exports.inflate=qv;Bc.exports.inflateRaw=fj;Bc.exports.ungzip=qv;Bc.exports.constants=Ju()});var c4=he((NW,Ia)=>{"use strict";var{Deflate:hj,deflate:dj,deflateRaw:pj,gzip:gj}=w6(),{Inflate:mj,inflate:vj,inflateRaw:wj,ungzip:Aj}=l4(),Ej=Ju();Ia.exports.Deflate=hj;Ia.exports.deflate=dj;Ia.exports.deflateRaw=pj;Ia.exports.gzip=gj;Ia.exports.Inflate=mj;Ia.exports.inflate=vj;Ia.exports.inflateRaw=wj;Ia.exports.ungzip=Aj;Ia.exports.constants=Ej});var Yv=he((LW,g4)=>{var bj=new TextEncoder,yj=new TextDecoder("utf-8");function Vv(e){return bj.encode(e)}function Kv(e){return yj.decode(e)}function h4(e){if(typeof e!="string")throw new TypeError("value is not a string");if(!/^([0-9a-f][0-9a-f])*$/.test(e))throw new RangeError("value is not hexadecimal");return e===""?new Uint8Array(0):new Uint8Array(e.match(/../g).map(t=>parseInt(t,16)))}var f4=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"],d4=new Array(256);for(let e=0;e<256;e++)d4[e]=`${f4[e>>>4&15]}${f4[e&15]}`;function p4(e){let t="",r=e.byteLength;for(let n=0;n=this.buf.byteLength&&this.grow(),this.buf[this.offset]=t,this.offset+=1}appendUint32(t){if(!Number.isInteger(t))throw new RangeError("value is not an integer");if(t<0||t>4294967295)throw new RangeError("number out of range");let r=Math.max(1,Math.ceil((32-Math.clz32(t))/7));this.offset+r>this.buf.byteLength&&this.grow();for(let n=0;n>>=7;return this.offset+=r,r}appendInt32(t){if(!Number.isInteger(t))throw new RangeError("value is not an integer");if(t<-2147483648||t>2147483647)throw new RangeError("number out of range");let r=Math.ceil((33-Math.clz32(t>=0?t:-t-1))/7);this.offset+r>this.buf.byteLength&&this.grow();for(let n=0;n>=7;return this.offset+=r,r}appendUint53(t){if(!Number.isInteger(t))throw new RangeError("value is not an integer");if(t<0||t>Number.MAX_SAFE_INTEGER)throw new RangeError("number out of range");let r=Math.floor(t/4294967296),n=(t&4294967295)>>>0;return this.appendUint64(r,n)}appendInt53(t){if(!Number.isInteger(t))throw new RangeError("value is not an integer");if(tNumber.MAX_SAFE_INTEGER)throw new RangeError("number out of range");let r=Math.floor(t/4294967296),n=(t&4294967295)>>>0;return this.appendInt64(r,n)}appendUint64(t,r){if(!Number.isInteger(t)||!Number.isInteger(r))throw new RangeError("value is not an integer");if(t<0||t>4294967295||r<0||r>4294967295)throw new RangeError("number out of range");if(t===0)return this.appendUint32(r);let n=Math.ceil((64-Math.clz32(t))/7);this.offset+n>this.buf.byteLength&&this.grow();for(let i=0;i<4;i++)this.buf[this.offset+i]=r&127|128,r>>>=7;this.buf[this.offset+4]=r&15|(t&7)<<4|(n===5?0:128),t>>>=3;for(let i=5;i>>=7;return this.offset+=n,n}appendInt64(t,r){if(!Number.isInteger(t)||!Number.isInteger(r))throw new RangeError("value is not an integer");if(t<-2147483648||t>2147483647||r<-2147483648||r>4294967295)throw new RangeError("number out of range");if(r>>>=0,t===0&&r<=2147483647)return this.appendInt32(r);if(t===-1&&r>=2147483648)return this.appendInt32(r-4294967296);let n=Math.ceil((65-Math.clz32(t>=0?t:-t-1))/7);this.offset+n>this.buf.byteLength&&this.grow();for(let i=0;i<4;i++)this.buf[this.offset+i]=r&127|128,r>>>=7;this.buf[this.offset+4]=r&15|(t&7)<<4|(n===5?0:128),t>>=3;for(let i=5;i>=7;return this.offset+=n,n}appendRawBytes(t){return this.offset+t.byteLength>this.buf.byteLength&&this.grow(this.offset+t.byteLength),this.buf.set(t,this.offset),this.offset+=t.byteLength,t.byteLength}appendRawString(t){if(typeof t!="string")throw new TypeError("value is not a string");return this.appendRawBytes(Vv(t))}appendPrefixedBytes(t){return this.appendUint53(t.byteLength),this.appendRawBytes(t),this}appendPrefixedString(t){if(typeof t!="string")throw new TypeError("value is not a string");return this.appendPrefixedBytes(Vv(t)),this}appendHexString(t){return this.appendPrefixedBytes(h4(t)),this}finish(){}},dh=class{constructor(t){if(!(t instanceof Uint8Array))throw new TypeError(`Not a byte array: ${t}`);this.buf=t,this.offset=0}get done(){return this.offset===this.buf.byteLength}reset(){this.offset=0}skip(t){if(this.offset+t>this.buf.byteLength)throw new RangeError("cannot skip beyond end of buffer");this.offset+=t}readByte(){return this.offset+=1,this.buf[this.offset-1]}readUint32(){let t=0,r=0;for(;this.offset>>0,r+=7,this.offset++,!(n&128))return t}throw new RangeError("buffer ended with incomplete number")}readInt32(){let t=0,r=0;for(;this.offset28?t:t|-1<2097151)throw new RangeError("number out of range");return r*4294967296+t}readInt53(){let{low32:t,high32:r}=this.readInt64();if(r<-2097152||r===-2097152&&t===0||r>2097151)throw new RangeError("number out of range");return r*4294967296+t}readUint64(){let t=0,r=0,n=0;for(;this.offset>>0,n===28&&(r=(i&112)>>>4),n+=7,this.offset++,!(i&128))return{high32:r,low32:t}}for(n=3;this.offset>>0,n+=7,this.offset++,!(i&128))return{high32:r,low32:t}}throw new RangeError("buffer ended with incomplete number")}readInt64(){let t=0,r=0,n=0;for(;this.offset>>0,n===28&&(r=(i&112)>>>4),n+=7,this.offset++,!(i&128))return i&64&&(n<32&&(t=(t|-1<>>0),r|=-1<this.buf.byteLength)throw new RangeError("subarray exceeds buffer size");return this.offset+=t,this.buf.subarray(r,this.offset)}readRawString(t){return Kv(this.readRawBytes(t))}readPrefixedBytes(){return this.readRawBytes(this.readUint53())}readPrefixedString(){return Kv(this.readPrefixedBytes())}readHexString(){return p4(this.readPrefixedBytes())}},ap=class extends hh{constructor(t){super(),this.type=t,this.state="empty",this.lastValue=void 0,this.count=0,this.literal=[]}appendValue(t,r=1){this._appendValue(t,r)}_appendValue(t,r=1){r<=0||(this.state==="empty"?(this.state=t===null?"nulls":r===1?"loneValue":"repetition",this.lastValue=t,this.count=r):this.state==="loneValue"?t===null?(this.flush(),this.state="nulls",this.count=r):t===this.lastValue?(this.state="repetition",this.count=1+r):r>1?(this.flush(),this.state="repetition",this.count=r,this.lastValue=t):(this.state="literal",this.literal=[this.lastValue],this.lastValue=t):this.state==="repetition"?t===null?(this.flush(),this.state="nulls",this.count=r):t===this.lastValue?this.count+=r:r>1?(this.flush(),this.state="repetition",this.count=r,this.lastValue=t):(this.flush(),this.state="loneValue",this.lastValue=t):this.state==="literal"?t===null?(this.literal.push(this.lastValue),this.flush(),this.state="nulls",this.count=r):t===this.lastValue?(this.flush(),this.state="repetition",this.count=1+r):r>1?(this.literal.push(this.lastValue),this.flush(),this.state="repetition",this.count=r,this.lastValue=t):(this.literal.push(this.lastValue),this.lastValue=t):this.state==="nulls"&&(t===null?this.count+=r:r>1?(this.flush(),this.state="repetition",this.count=r,this.lastValue=t):(this.flush(),this.state="loneValue",this.lastValue=t)))}copyFrom(t,r={}){let{count:n,sumValues:i,sumShift:a}=r;if(!(t instanceof ph)||t.type!==this.type)throw new TypeError("incompatible type of decoder");let s=typeof n=="number"?n:Number.MAX_SAFE_INTEGER,u=0,l=0;if(n&&s>0&&t.done)throw new RangeError(`cannot copy ${n} values`);if(s===0||t.done)return i?{nonNullValues:u,sum:l}:{nonNullValues:u};let f=t.readValue();if(f===null){let m=Math.min(t.count+1,s);if(s-=m,t.count-=m-1,this.appendValue(null,m),n&&s>0&&t.done)throw new RangeError(`cannot copy ${n} values`);if(s===0||t.done)return i?{nonNullValues:u,sum:l}:{nonNullValues:u};if(f=t.readValue(),f===null)throw new RangeError("null run must be followed by non-null value")}if(this.appendValue(f),s--,u++,i&&(l+=a?f>>>a:f),n&&s>0&&t.done)throw new RangeError(`cannot copy ${n} values`);if(s===0||t.done)return i?{nonNullValues:u,sum:l}:{nonNullValues:u};let d=t.count>0;for(;s>0&&!t.done;){d||t.readRecord();let m=Math.min(t.count,s);if(t.count-=m,t.state==="literal"){u+=m;for(let p=0;p>>a:h)}}else if(t.state==="repetition"){u+=m,i&&(l+=m*(a?t.lastValue>>>a:t.lastValue));let p=t.lastValue;if(this._appendValue(p),m>1){if(this._appendValue(p),this.state!=="repetition")throw new RangeError(`Unexpected state ${this.state}`);this.count+=m-2}}else if(t.state==="nulls"){if(this._appendValue(null),this.state!=="nulls")throw new RangeError(`Unexpected state ${this.state}`);this.count+=m-1}d=!1,s-=m}if(n&&s>0&&t.done)throw new RangeError(`cannot copy ${n} values`);return i?{nonNullValues:u,sum:l}:{nonNullValues:u}}flush(){if(this.state==="loneValue")this.appendInt32(-1),this.appendRawValue(this.lastValue);else if(this.state==="repetition")this.appendInt53(this.count),this.appendRawValue(this.lastValue);else if(this.state==="literal"){this.appendInt53(-this.literal.length);for(let t of this.literal)this.appendRawValue(t)}else this.state==="nulls"&&(this.appendInt32(0),this.appendUint53(this.count));this.state="empty"}appendRawValue(t){if(this.type==="int")this.appendInt53(t);else if(this.type==="uint")this.appendUint53(t);else if(this.type==="utf8")this.appendPrefixedString(t);else throw new RangeError(`Unknown RLEEncoder datatype: ${this.type}`)}finish(){this.state==="literal"&&this.literal.push(this.lastValue),(this.state!=="nulls"||this.offset>0)&&this.flush()}},ph=class extends dh{constructor(t,r){super(r),this.type=t,this.lastValue=void 0,this.count=0,this.state=void 0}get done(){return this.count===0&&this.offset===this.buf.byteLength}reset(){this.offset=0,this.lastValue=void 0,this.count=0,this.state=void 0}readValue(){if(this.done)return null;if(this.count===0&&this.readRecord(),this.count-=1,this.state==="literal"){let t=this.readRawValue();if(t===this.lastValue)throw new RangeError("Repetition of values is not allowed in literal");return this.lastValue=t,t}else return this.lastValue}skipValues(t){for(;t>0&&!this.done;){this.count===0&&(this.count=this.readInt53(),this.count>0?(this.lastValue=this.count<=t?this.skipRawValues(1):this.readRawValue(),this.state="repetition"):this.count<0?(this.count=-this.count,this.state="literal"):(this.count=this.readUint53(),this.lastValue=null,this.state="nulls"));let r=Math.min(t,this.count);this.state==="literal"&&this.skipRawValues(r),t-=r,this.count-=r}}readRecord(){if(this.count=this.readInt53(),this.count>1){let t=this.readRawValue();if((this.state==="repetition"||this.state==="literal")&&this.lastValue===t)throw new RangeError("Successive repetitions with the same value are not allowed");this.state="repetition",this.lastValue=t}else{if(this.count===1)throw new RangeError("Repetition count of 1 is not allowed, use a literal instead");if(this.count<0){if(this.count=-this.count,this.state==="literal")throw new RangeError("Successive literals are not allowed");this.state="literal"}else{if(this.state==="nulls")throw new RangeError("Successive null runs are not allowed");if(this.count=this.readUint53(),this.count===0)throw new RangeError("Zero-length null runs are not allowed");this.lastValue=null,this.state="nulls"}}}readRawValue(){if(this.type==="int")return this.readInt53();if(this.type==="uint")return this.readUint53();if(this.type==="utf8")return this.readPrefixedString();throw new RangeError(`Unknown RLEDecoder datatype: ${this.type}`)}skipRawValues(t){if(this.type==="utf8")for(let r=0;r0&&this.offset0)throw new RangeError("cannot skip beyond end of buffer")}}},zv=class extends ap{constructor(){super("int"),this.absoluteValue=0}appendValue(t,r=1){r<=0||(typeof t=="number"?(super.appendValue(t-this.absoluteValue,1),this.absoluteValue=t,r>1&&super.appendValue(0,r-1)):super.appendValue(t,r))}copyFrom(t,r={}){if(r.sumValues)throw new RangeError("unsupported options for DeltaEncoder.copyFrom()");if(!(t instanceof up))throw new TypeError("incompatible type of decoder");let n=r.count;if(n>0&&t.done)throw new RangeError(`cannot copy ${n} values`);if(n===0||t.done)return;let i=t.readValue(),a=0;if(this.appendValue(i),i===null){if(a=t.count+1,n!==void 0&&na&&t.done)throw new RangeError(`cannot copy ${n} values`);if(n===a||t.done)return;t.count===0&&this.appendValue(t.readValue())}n!==void 0&&(n-=a+1);let{nonNullValues:s,sum:u}=super.copyFrom(t,{count:n,sumValues:!0});s>0&&(this.absoluteValue=u,t.absoluteValue=u)}},up=class extends ph{constructor(t){super("int",t),this.absoluteValue=0}reset(){this.offset=0,this.lastValue=void 0,this.count=0,this.state=void 0,this.absoluteValue=0}readValue(){let t=super.readValue();return t===null?null:(this.absoluteValue+=t,this.absoluteValue)}skipValues(t){for(;t>0&&!this.done;){this.count===0&&this.readRecord();let r=Math.min(t,this.count);if(this.state==="literal")for(let n=0;n0&&t.done)throw new RangeError(`cannot copy ${n} values`);if(i===0||t.done)return;this.appendValue(t.readValue()),i--;let a=Math.min(t.count,i);for(this.count+=a,t.count-=a,i-=a;i>0&&!t.done;){if(t.count=t.readUint53(),t.count===0)throw new RangeError("Zero-length runs are not allowed");t.lastValue=!t.lastValue,this.appendUint53(this.count);let s=Math.min(t.count,i);this.count=s,this.lastValue=t.lastValue,t.count-=s,i-=s}if(n&&i>0&&t.done)throw new RangeError(`cannot copy ${n} values`)}finish(){this.count>0&&(this.appendUint53(this.count),this.count=0)}},op=class extends dh{constructor(t){super(t),this.lastValue=!0,this.firstRun=!0,this.count=0}get done(){return this.count===0&&this.offset===this.buf.byteLength}reset(){this.offset=0,this.lastValue=!0,this.firstRun=!0,this.count=0}readValue(){if(this.done)return!1;for(;this.count===0;){if(this.count=this.readUint53(),this.lastValue=!this.lastValue,this.count===0&&!this.firstRun)throw new RangeError("Zero-length runs are not allowed");this.firstRun=!1}return this.count-=1,this.lastValue}skipValues(t){for(;t>0&&!this.done;){if(this.count===0){if(this.count=this.readUint53(),this.lastValue=!this.lastValue,this.count===0&&!this.firstRun)throw new RangeError("Zero-length runs are not allowed");this.firstRun=!1}this.count{(function(e,t){var r={};t(r);var n=r.default;for(var i in r)n[i]=r[i];typeof lp=="object"&&typeof lp.exports=="object"?lp.exports=n:typeof define=="function"&&define.amd?define(function(){return n}):e.sha256=n})(m4,function(e){"use strict";e.__esModule=!0,e.digestLength=32,e.blockSize=64;var t=new Uint32Array([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]);function r(m,p,h,w,v){for(var y,g,b,D,C,F,U,L,S,B,O,x,j;v>=64;){for(y=p[0],g=p[1],b=p[2],D=p[3],C=p[4],F=p[5],U=p[6],L=p[7],B=0;B<16;B++)O=w+B*4,m[B]=(h[O]&255)<<24|(h[O+1]&255)<<16|(h[O+2]&255)<<8|h[O+3]&255;for(B=16;B<64;B++)S=m[B-2],x=(S>>>17|S<<15)^(S>>>19|S<<13)^S>>>10,S=m[B-15],j=(S>>>7|S<<25)^(S>>>18|S<<14)^S>>>3,m[B]=(x+m[B-7]|0)+(j+m[B-16]|0);for(B=0;B<64;B++)x=(((C>>>6|C<<26)^(C>>>11|C<<21)^(C>>>25|C<<7))+(C&F^~C&U)|0)+(L+(t[B]+m[B]|0)|0)|0,j=((y>>>2|y<<30)^(y>>>13|y<<19)^(y>>>22|y<<10))+(y&g^y&b^g&b)|0,L=U,U=F,F=C,C=D+x|0,D=b,b=g,g=y,y=x+j|0;p[0]+=y,p[1]+=g,p[2]+=b,p[3]+=D,p[4]+=C,p[5]+=F,p[6]+=U,p[7]+=L,w+=64,v-=64}return w}var n=function(){function m(){this.digestLength=e.digestLength,this.blockSize=e.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return m.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},m.prototype.clean=function(){for(var p=0;p0){for(;this.bufferLength<64&&h>0;)this.buffer[this.bufferLength++]=p[w++],h--;this.bufferLength===64&&(r(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(h>=64&&(w=r(this.temp,this.state,p,w,h),h%=64);h>0;)this.buffer[this.bufferLength++]=p[w++],h--;return this},m.prototype.finish=function(p){if(!this.finished){var h=this.bytesHashed,w=this.bufferLength,v=h/536870912|0,y=h<<3,g=h%64<56?64:128;this.buffer[w]=128;for(var b=w+1;b>>24&255,this.buffer[g-7]=v>>>16&255,this.buffer[g-6]=v>>>8&255,this.buffer[g-5]=v>>>0&255,this.buffer[g-4]=y>>>24&255,this.buffer[g-3]=y>>>16&255,this.buffer[g-2]=y>>>8&255,this.buffer[g-1]=y>>>0&255,r(this.temp,this.state,this.buffer,0,g),this.finished=!0}for(var b=0;b<8;b++)p[b*4+0]=this.state[b]>>>24&255,p[b*4+1]=this.state[b]>>>16&255,p[b*4+2]=this.state[b]>>>8&255,p[b*4+3]=this.state[b]>>>0&255;return this},m.prototype.digest=function(){var p=new Uint8Array(this.digestLength);return this.finish(p),p},m.prototype._saveState=function(p){for(var h=0;hthis.blockSize)new n().update(p).finish(h).clean();else for(var w=0;w1&&p.update(m),h&&p.update(h),p.update(w),p.finish(m),w[0]++}var l=new Uint8Array(e.digestLength);function f(m,p,h,w){p===void 0&&(p=l),w===void 0&&(w=32);for(var v=new Uint8Array([1]),y=s(p,m),g=new i(y),b=new Uint8Array(g.digestLength),D=b.length,C=new Uint8Array(w),F=0;F>>24&255,g[1]=U>>>16&255,g[2]=U>>>8&255,g[3]=U>>>0&255,v.reset(),v.update(p),v.update(g),v.finish(D);for(var L=0;L{var hp=c4(),{copyObject:w4,parseOpId:Eu,equalBytes:A4}=Rs(),{utf8ToString:_j,hexStringToBytes:D4,bytesToHexString:dp,Encoder:xc,Decoder:Bi,RLEEncoder:Ii,RLEDecoder:E4,DeltaEncoder:$c,DeltaDecoder:Cj,BooleanEncoder:F4,BooleanDecoder:Dj}=Yv(),{Hash:S4}=v4(),Pc=new Uint8Array([133,111,74,131]),Qv=0,Rc=1,vh=2,I4=256,mt={GROUP_CARD:0,ACTOR_ID:1,INT_RLE:2,INT_DELTA:3,BOOLEAN:4,STRING_RLE:5,VALUE_LEN:6,VALUE_RAW:7},mh=8,rr={NULL:0,FALSE:1,TRUE:2,LEB128_UINT:3,LEB128_INT:4,IEEE754:5,UTF8:6,BYTES:7,COUNTER:8,TIMESTAMP:9,MIN_UNKNOWN:10,MAX_UNKNOWN:15},gh=["makeMap","set","makeList","del","makeText","inc","makeTable","link"],Fj={makeMap:"map",makeList:"list",makeText:"text",makeTable:"table"},B4=[{columnName:"objActor",columnId:0|mt.ACTOR_ID},{columnName:"objCtr",columnId:0|mt.INT_RLE},{columnName:"keyActor",columnId:16|mt.ACTOR_ID},{columnName:"keyCtr",columnId:16|mt.INT_DELTA},{columnName:"keyStr",columnId:16|mt.STRING_RLE},{columnName:"idActor",columnId:32|mt.ACTOR_ID},{columnName:"idCtr",columnId:32|mt.INT_DELTA},{columnName:"insert",columnId:48|mt.BOOLEAN},{columnName:"action",columnId:64|mt.INT_RLE},{columnName:"valLen",columnId:80|mt.VALUE_LEN},{columnName:"valRaw",columnId:80|mt.VALUE_RAW},{columnName:"chldActor",columnId:96|mt.ACTOR_ID},{columnName:"chldCtr",columnId:96|mt.INT_DELTA}],e2=B4.concat([{columnName:"predNum",columnId:112|mt.GROUP_CARD},{columnName:"predActor",columnId:112|mt.ACTOR_ID},{columnName:"predCtr",columnId:112|mt.INT_DELTA}]),t2=B4.concat([{columnName:"succNum",columnId:128|mt.GROUP_CARD},{columnName:"succActor",columnId:128|mt.ACTOR_ID},{columnName:"succCtr",columnId:128|mt.INT_DELTA}]),$4=[{columnName:"actor",columnId:0|mt.ACTOR_ID},{columnName:"seq",columnId:0|mt.INT_DELTA},{columnName:"maxOp",columnId:16|mt.INT_DELTA},{columnName:"time",columnId:32|mt.INT_DELTA},{columnName:"message",columnId:48|mt.STRING_RLE},{columnName:"depsNum",columnId:64|mt.GROUP_CARD},{columnName:"depsIndex",columnId:64|mt.INT_DELTA},{columnName:"extraLen",columnId:80|mt.VALUE_LEN},{columnName:"extraRaw",columnId:80|mt.VALUE_RAW}];function cp(e,t){if(!e||!e.actorId)return e;let r=e.counter,n=t.indexOf(e.actorId);if(n<0)throw new RangeError("missing actorId");return{counter:r,actorNum:n,actorId:e.actorId}}function Wv(e,t){return e.countert.counter?1:e.actorIdt.actorId?1:0}function Sj(e,t){let r={},n=[];for(let a of e)a=w4(a),r[a.actor]=!0,a.ops=Oj(a.ops,a.startOp,a.actor),a.ops=a.ops.map(s=>{s=w4(s),s.obj!=="_root"&&(s.obj=Eu(s.obj)),s.elemId&&s.elemId!=="_head"&&(s.elemId=Eu(s.elemId)),s.child&&(s.child=Eu(s.child)),s.pred&&(s.pred=s.pred.map(Eu)),s.obj.actorId&&(r[s.obj.actorId]=!0),s.elemId&&s.elemId.actorId&&(r[s.elemId.actorId]=!0),s.child&&s.child.actorId&&(r[s.child.actorId]=!0);for(let u of s.pred)r[u.actorId]=!0;return s}),n.push(a);let i=Object.keys(r).sort();t&&(i=[e[0].actor].concat(i.filter(a=>a!==e[0].actor)));for(let a of n){a.actorNum=i.indexOf(a.actor);for(let s=0;scp(l,i))}}return{changes:n,actorIds:i}}function Ij(e,t){if(e.obj==="_root")t.objActor.appendValue(null),t.objCtr.appendValue(null);else if(e.obj.actorNum>=0&&e.obj.counter>0)t.objActor.appendValue(e.obj.actorNum),t.objCtr.appendValue(e.obj.counter);else throw new RangeError(`Unexpected objectId reference: ${JSON.stringify(e.obj)}`)}function Bj(e,t){if(e.key)t.keyActor.appendValue(null),t.keyCtr.appendValue(null),t.keyStr.appendValue(e.key);else if(e.elemId==="_head"&&e.insert)t.keyActor.appendValue(null),t.keyCtr.appendValue(0),t.keyStr.appendValue(null);else if(e.elemId&&e.elemId.actorNum>=0&&e.elemId.counter>0)t.keyActor.appendValue(e.elemId.actorNum),t.keyCtr.appendValue(e.elemId.counter),t.keyStr.appendValue(null);else throw new RangeError(`Unexpected operation key: ${JSON.stringify(e)}`)}function $j(e,t){let r=gh.indexOf(e.action);if(r>=0)t.action.appendValue(r);else if(typeof e.action=="number")t.action.appendValue(e.action);else throw new RangeError(`Unexpected operation action: ${e.action}`)}function Pj(e){switch(e.datatype){case"counter":return[rr.COUNTER,e.value];case"timestamp":return[rr.TIMESTAMP,e.value];case"uint":return[rr.LEB128_UINT,e.value];case"int":return[rr.LEB128_INT,e.value];case"float64":{let t=new ArrayBuffer(8);return new DataView(t).setFloat64(0,e.value,!0),[rr.IEEE754,new Uint8Array(t)]}default:if(Number.isInteger(e.value)&&e.value<=Number.MAX_SAFE_INTEGER&&e.value>=Number.MIN_SAFE_INTEGER)return[rr.LEB128_INT,e.value];{let t=new ArrayBuffer(8);return new DataView(t).setFloat64(0,e.value,!0),[rr.IEEE754,new Uint8Array(t)]}}}function xj(e,t){if(e.action!=="set"&&e.action!=="inc"||e.value===null)t.valLen.appendValue(rr.NULL);else if(e.value===!1)t.valLen.appendValue(rr.FALSE);else if(e.value===!0)t.valLen.appendValue(rr.TRUE);else if(typeof e.value=="string"){let r=t.valRaw.appendRawString(e.value);t.valLen.appendValue(r<<4|rr.UTF8)}else if(ArrayBuffer.isView(e.value)){let r=t.valRaw.appendRawBytes(new Uint8Array(e.value.buffer));t.valLen.appendValue(r<<4|rr.BYTES)}else if(typeof e.value=="number"){let[r,n]=Pj(e),i;r===rr.LEB128_UINT?i=t.valRaw.appendUint53(n):r===rr.IEEE754?i=t.valRaw.appendRawBytes(n):i=t.valRaw.appendInt53(n),t.valLen.appendValue(i<<4|r)}else if(typeof e.datatype=="number"&&e.datatype>=rr.MIN_UNKNOWN&&e.datatype<=rr.MAX_UNKNOWN&&e.value instanceof Uint8Array){let r=t.valRaw.appendRawBytes(e.value);t.valLen.appendValue(r<<4|e.datatype)}else throw e.datatype?new RangeError(`Unknown datatype ${e.datatype} for value ${e.value}`):new RangeError(`Unsupported value in operation: ${e.value}`)}function P4(e,t){if(e===rr.NULL)return{value:null};if(e===rr.FALSE)return{value:!1};if(e===rr.TRUE)return{value:!0};if(e%16===rr.UTF8)return{value:_j(t)};if(e%16===rr.LEB128_UINT)return{value:new Bi(t).readUint53(),datatype:"uint"};if(e%16===rr.LEB128_INT)return{value:new Bi(t).readInt53(),datatype:"int"};if(e%16===rr.IEEE754){let r=new DataView(t.buffer,t.byteOffset,t.byteLength);if(t.byteLength===8)return{value:r.getFloat64(0,!0),datatype:"float64"};throw new RangeError(`Invalid length for floating point number: ${t.byteLength}`)}else return e%16===rr.COUNTER?{value:new Bi(t).readInt53(),datatype:"counter"}:e%16===rr.TIMESTAMP?{value:new Bi(t).readInt53(),datatype:"timestamp"}:{value:t,datatype:e%16}}function b4(e,t,r,n){let{columnId:i,columnName:a,decoder:s}=e[t];if(i%8===mt.VALUE_LEN&&t+1>4),{value:f,datatype:d}=P4(u,l);return n[a]=f,d&&(n[a+"_datatype"]=d),2}else if(i%8===mt.ACTOR_ID){let u=s.readValue();if(u===null)n[a]=null;else{if(!r[u])throw new RangeError(`No actor index ${u}`);n[a]=r[u]}}else n[a]=s.readValue();return 1}function Rj(e,t){let r={objActor:new Ii("uint"),objCtr:new Ii("uint"),keyActor:new Ii("uint"),keyCtr:new $c,keyStr:new Ii("utf8"),insert:new F4,action:new Ii("uint"),valLen:new Ii("uint"),valRaw:new xc,chldActor:new Ii("uint"),chldCtr:new $c};t?(r.idActor=new Ii("uint"),r.idCtr=new $c,r.succNum=new Ii("uint"),r.succActor=new Ii("uint"),r.succCtr=new $c):(r.predNum=new Ii("uint"),r.predCtr=new $c,r.predActor=new Ii("uint"));for(let i of e)if(Ij(i,r),Bj(i,r),r.insert.appendValue(!!i.insert),$j(i,r),xj(i,r),i.child&&i.child.counter?(r.chldActor.appendValue(i.child.actorNum),r.chldCtr.appendValue(i.child.counter)):(r.chldActor.appendValue(null),r.chldCtr.appendValue(null)),t){r.idActor.appendValue(i.id.actorNum),r.idCtr.appendValue(i.id.counter),r.succNum.appendValue(i.succ.length),i.succ.sort(Wv);for(let a=0;ai.columnId-a.columnId)}function Tj(e,t){return t===void 0?typeof e=="string"||typeof e=="boolean"||e===null:typeof e=="number"}function Oj(e,t,r){let n=t,i=[];for(let a of e)if(a.action==="set"&&a.values&&a.insert){if(a.pred.length!==0)throw new RangeError("multi-insert pred must be empty");let s=a.elemId,u=a.datatype;for(let l of a.values){if(!Tj(l,u))throw new RangeError(`Decode failed: bad value/datatype association (${l},${u})`);i.push({action:"set",obj:a.obj,elemId:s,datatype:u,value:l,pred:[],insert:!0}),s=`${n}@${r}`,n+=1}}else if(a.action==="del"&&a.multiOp>1){if(a.pred.length!==1)throw new RangeError("multiOp deletion must have exactly one pred");let s=Eu(a.elemId),u=Eu(a.pred[0]);for(let l=0;l`${l.succCtr}@${l.succActor}`),y4(n.succNum.map(l=>({counter:l.succCtr,actorId:l.succActor})))):(u.pred=n.predNum.map(l=>`${l.predCtr}@${l.predActor}`),y4(n.predNum.map(l=>({counter:l.predCtr,actorId:l.predActor})))),r.push(u)}return r}function y4(e){let t=null;for(let r of e){if(t&&Wv(t,r)!==-1)throw new RangeError("operation IDs are not in ascending order");t=r}}function kj(e){return(e&7)===mt.INT_DELTA?new $c:(e&7)===mt.BOOLEAN?new F4:(e&7)===mt.STRING_RLE?new Ii("utf8"):(e&7)===mt.VALUE_RAW?new xc:new Ii("uint")}function fp(e,t){return(e&7)===mt.INT_DELTA?new Cj(t):(e&7)===mt.BOOLEAN?new Dj(t):(e&7)===mt.STRING_RLE?new E4("utf8",t):(e&7)===mt.VALUE_RAW?new Bi(t):new E4("uint",t)}function R4(e,t){let r=new Uint8Array(0),n=[],i=0,a=0;for(;i!i.decoder.done);){let i={},a=0;for(;a>4,l=1;for(;a+l>4===u;)l++;if(s%8===mt.GROUP_CARD){let f=[],d=e[a].decoder.readValue();for(let m=0;m>>0,r=-1,n=[],i=e.readUint53();for(let a=0;an.encoder.buffer.byteLength>0);e.appendUint53(r.length);for(let n of r)e.appendUint53(n.columnId),e.appendUint53(n.encoder.buffer.byteLength)}function T4(e){let t=e.readUint53(),r=[];for(let s=0;s{if(!Array.isArray(n.deps))throw new TypeError("deps is not an array");u.appendUint53(n.deps.length);for(let f of n.deps.slice().sort())u.appendRawBytes(D4(f));u.appendHexString(n.actor),u.appendUint53(n.seq),u.appendUint53(n.startOp),u.appendInt53(n.time),u.appendPrefixedString(n.message||""),u.appendUint53(r.length-1);for(let f of r.slice(1))u.appendHexString(f);let l=Rj(n.ops,!1);Zv(u,l);for(let f of l)u.appendRawBytes(f.encoder.buffer);n.extraBytes&&u.appendRawBytes(n.extraBytes)}),s=dp(i);if(e.hash&&e.hash!==s)throw new RangeError(`Change hash does not match encoding: ${e.hash} != ${s}`);return a.byteLength>=I4?Lj(a):a}function N4(e){e[8]===vh&&(e=L4(e));let t=new Bi(e),r=Tc(t,!0),n=new Bi(r.chunkData);if(!t.done)throw new RangeError("Encoded change has trailing data");if(r.chunkType!==Rc)throw new RangeError(`Unexpected chunk type: ${r.chunkType}`);let i=T4(n),a=Jv(n);for(let s=0;sn.counter?1:r.actorIdn.actorId?1:0}function Hj(e,t){let r={};for(let i of e){if(i.ops=[],r[i.actor]||(r[i.actor]=[]),i.seq!==r[i.actor].length+1)throw new RangeError(`Expected seq = ${r[i.actor].length+1}, got ${i.seq}`);if(i.seq>1&&r[i.actor][i.seq-2].maxOp>i.maxOp)throw new RangeError("maxOp must increase monotonically per actor");r[i.actor].push(i)}let n={};for(let i of t){if(i.action==="del")throw new RangeError("document should not contain del operations");i.pred=n[i.id]?n[i.id].pred:[],n[i.id]=i;for(let a of i.succ){if(!n[a])if(i.elemId){let s=i.insert?i.id:i.elemId;n[a]={id:a,action:"del",obj:i.obj,elemId:s,pred:[]}}else n[a]={id:a,action:"del",obj:i.obj,key:i.key,pred:[]};n[a].pred.push(i.id)}delete i.succ}for(let i of Object.values(n))i.action==="del"&&t.push(i);for(let i of t){let{counter:a,actorId:s}=Eu(i.id),u=r[s],l=0,f=u.length;for(;l=u.length)throw new RangeError(`Operation ID ${i.id} outside of allowed range`);u[l].ops.push(i)}for(let i of e){i.ops.sort((a,s)=>jj(a.id,s.id)),i.startOp=i.maxOp-i.ops.length+1,delete i.maxOp;for(let a=0;af.depsIndex)){if(!e[l]||!e[l].hash)throw new RangeError(`No hash for index ${l} while processing index ${s}`);let f=e[l].hash;u.deps.push(f),r[f]&&delete r[f]}if(u.deps.sort(),delete u.depsNum,u.extraLen_datatype!==rr.BYTES)throw new RangeError(`Bad datatype for extra bytes: ${rr.BYTES}`);u.extraBytes=u.extraLen,delete u.extraLen_datatype,e[s]=r2(k4(u)),r[e[s].hash]=!0}let n=Object.keys(r).sort(),i=n.length===t.length,a=0;for(;i&&a{u.appendUint53(n.length);for(let l of n)u.appendHexString(l);u.appendUint53(i.length);for(let l of i.sort())u.appendRawBytes(D4(l));Zv(u,t),Zv(u,r);for(let l of t)u.appendRawBytes(l.encoder.buffer);for(let l of r)u.appendRawBytes(l.encoder.buffer);for(let l of a)u.appendUint53(l);s&&u.appendRawBytes(s)}).bytes}function j4(e){let t=new Bi(e),r=Tc(t,!0),n=new Bi(r.chunkData);if(!t.done)throw new RangeError("Encoded document has trailing data");if(r.chunkType!==Qv)throw new RangeError(`Unexpected chunk type: ${r.chunkType}`);let i=[],a=n.readUint53();for(let p=0;p=I4&&(e.encoder={buffer:hp.deflateRaw(e.encoder.buffer)},e.columnId|=mh)}function C4(e){e.columnId&mh&&(e.buffer=hp.inflateRaw(e.buffer),e.columnId^=mh)}M4.exports={COLUMN_TYPE:mt,VALUE_TYPE:rr,ACTIONS:gh,OBJECT_TYPE:Fj,DOC_OPS_COLUMNS:t2,CHANGE_COLUMNS:e2,DOCUMENT_COLUMNS:$4,encoderByColumnId:kj,decoderByColumnId:fp,makeDecoders:R4,decodeValue:P4,splitContainers:U4,encodeChange:k4,decodeChangeColumns:N4,decodeChange:r2,decodeChangeMeta:Nj,decodeChanges:Uj,encodeDocumentHeader:qj,decodeDocumentHeader:j4,decodeDocument:H4}});var sD=he((jW,iD)=>{var{parseOpId:mp,copyObject:vp}=Rs(),{COLUMN_TYPE:$n,VALUE_TYPE:i2,ACTIONS:bu,OBJECT_TYPE:q4,DOC_OPS_COLUMNS:V4,CHANGE_COLUMNS:Yt,DOCUMENT_COLUMNS:Os,encoderByColumnId:Uc,decoderByColumnId:h2,makeDecoders:Ah,decodeValue:pp,encodeChange:Vj,decodeChangeColumns:Kj,decodeChangeMeta:zj,decodeChanges:Gj,decodeDocumentHeader:Yj,encodeDocumentHeader:Wj}=wh(),bh=600,Xj=10,X4=7,J4=Math.floor(Xj*bh/8),Rr=0,_r=1,In=2,Bn=3,yt=4,qn=5,pr=6,Vn=7,Kr=8,io=9,fl=10,so=13,Oc=14,kc=15,ks=13,s2=14,Nc=15,K4=Yt.filter(e=>["predNum","predActor","predCtr"].includes(e.columnName)).map(e=>e.columnId);function a2(e,t,r){if(t.length===1)e[t[0]]=r;else{let n=Object.assign({},e[t[0]]);a2(n,t.slice(1),r),e[t[0]]=n}}function z4(e,t,r,n){for(let M of t)M.decoder.reset();let{objActor:i,objCtr:a,keyActor:s,keyCtr:u,keyStr:l,idActor:f,idCtr:d,insert:m}=e,[p,h,,,w,v,y,g,b,,,,,D]=t.map(M=>M.decoder),C=0,F=0,U=!1,L=null,S=null,B=null,O=null,x=null,j=null,Y=0;if(a!==null&&!n)for(;(!h.done||!p.done||!b.done)&&(S=h.readValue(),L=r[p.readValue()],b.skipValues(1),S===null||!L||S0&&s!==null){for(C+=1;!y.done&&!v.done&&(O!==u||B!==s)&&(j&&(U=!1),Y===0&&!U&&(F+=1,U=!0),O=y.readValue(),B=r[v.readValue()],S=h.readValue(),L=r[p.readValue()],j=g.readValue(),Y=D.readValue(),S===a&&L===i);)C+=1;if(S!==a||L!==i||O!==u||B!==s||!j)return{found:!1,skipCount:C,visibleCount:F};if(j&&(U=!1),Y===0&&!U&&(F+=1,U=!0),y.done||v.done)return{found:!0,skipCount:C,visibleCount:F};O=y.readValue(),B=r[v.readValue()],S=h.readValue(),L=r[p.readValue()],j=g.readValue(),Y=D.readValue()}for(;(!j||O>d||O===d&&B>f)&&S===a&&L===i&&(C+=1,j&&(U=!1),Y===0&&!U&&(F+=1,U=!0),!y.done&&!v.done);)O=y.readValue(),B=r[v.readValue()],S=h.readValue(),L=r[p.readValue()],j=g.readValue(),Y=D.readValue()}else if(u!==null&&u>0&&s!==null){for(;(!j||O!==u||B!==s)&&S===a&&L===i&&(C+=1,j&&(U=!1),Y===0&&!U&&(F+=1,U=!0),!y.done&&!v.done);)O=y.readValue(),B=r[v.readValue()],S=h.readValue(),L=r[p.readValue()],j=g.readValue(),Y=D.readValue();if(S!==a||L!==i||O!==u||B!==s||!j)return{found:!1,skipCount:C,visibleCount:F}}return{found:!0,skipCount:C,visibleCount:F}}function G4(e,t,r,n){let i=e.blocks[t],a=e.blocks[t+1];return i.lastObjectActor!==r||i.lastObjectCtr!==n||i.numVisible===void 0?0:i.lastVisibleActor===a.firstVisibleActor&&i.lastVisibleActor!==void 0&&i.lastVisibleCtr===a.firstVisibleCtr&&i.lastVisibleCtr!==void 0?i.numVisible-1:i.numVisible}function Z4(e,t){let{objActor:r,objActorNum:n,objCtr:i,keyActor:a,keyCtr:s,keyStr:u}=t,l=0,f=0;if(i!==null)for(;li)throw new RangeError(`Reference element not found: ${s}@${a}`);f+=G4(e,l,n,i),l++}let{found:h,skipCount:w,visibleCount:v}=z4(t,e.blocks[l].columns,e.actorIds,p);if(l===e.blocks.length-1||e.blocks[l].lastObjectActor!==n||e.blocks[l].lastObjectCtr!==i){if(h)return{blockIndex:l,skipCount:w,visibleCount:f+v};throw new RangeError(`Reference element not found: ${s}@${a}`)}else if(h&&w>>0)%n;for(let u=0;u>>3]|=1<<(i&7),i=(i+a)%n,a=(a+s)%n}function eD(e,t,r){let n=8*e.byteLength,i=r%n,a=t%n,s=((r^t)*16777619>>>0)%n;for(let u=0;u>>3]&1<<(i&7)))return!1;i=(i+a)%n,a=(a+s)%n}return!0}function tD(e){e.bloom=new Uint8Array(J4),e.numOps=0,e.lastKey=void 0,e.numVisible=void 0,e.lastObjectActor=void 0,e.lastObjectCtr=void 0,e.firstVisibleActor=void 0,e.firstVisibleCtr=void 0,e.lastVisibleActor=void 0,e.lastVisibleCtr=void 0;for(let d of e.columns)d.decoder.reset();let[t,r,n,i,a,s,u,l,,,,,,f]=e.columns.map(d=>d.decoder);for(;!u.done;){e.numOps+=1;let d=t.readValue(),m=r.readValue(),p=n.readValue(),h=i.readValue(),w=a.readValue(),v=s.readValue(),y=u.readValue(),g=l.readValue(),b=f.readValue();if((e.lastObjectActor!==d||e.lastObjectCtr!==m)&&(e.numVisible=0,e.lastObjectActor=d,e.lastObjectCtr=m),w!==null)e.lastKey=w;else if(g||h!==null){e.lastKey=void 0;let D=g?v:p,C=g?y:h;Q4(e.bloom,D,C),b===0&&(e.firstVisibleActor===void 0&&(e.firstVisibleActor=D),e.firstVisibleCtr===void 0&&(e.firstVisibleCtr=C),(e.lastVisibleActor!==D||e.lastVisibleCtr!==C)&&(e.numVisible+=1,e.lastVisibleActor=D,e.lastVisibleCtr=C))}}}function n2(e,t,r,n){if(t[yt]!==null)e.lastObjectCtr===t[_r]&&e.lastObjectActor===t[Rr]&&(e.lastKey===void 0||e.lastKey({columnId:f.columnId,encoder:Uc(f.columnId)}));jc(s,e.columns,a);let l={columns:s.map(f=>{let d=h2(f.columnId,f.encoder.buffer);return{columnId:f.columnId,decoder:d}})};tD(l),r.push(l),n+=a}return r}function Jj(e){let t=e[0].columns.map(r=>({columnId:r.columnId,encoder:Uc(r.columnId)}));for(let r of e){for(let n of r.columns)n.decoder.reset();jc(t,r.columns,r.numOps)}return t}function jc(e,t,r){if(r===0)return;let n=0,i=-1,a=0,s=-1,u=0;for(let l of e){for(;n0&&(f=t[n].decoder);let d=l.columnId>>4===i?a:r;if(l.columnId%8===$n.GROUP_CARD)i=l.columnId>>4,f?a=l.encoder.copyFrom(f,{count:r,sumValues:!0}).sum:(l.encoder.appendValue(0,r),a=0);else if(l.columnId%8===$n.VALUE_LEN)if(f){if(n+1===t.length||t[n+1].columnId!==l.columnId+1)throw new RangeError("VALUE_LEN column without accompanying VALUE_RAW column");s=l.columnId+1,u=l.encoder.copyFrom(f,{count:d,sumValues:!0,sumShift:4}).sum}else l.encoder.appendValue(null,d),s=l.columnId+1,u=0;else if(l.columnId%8===$n.VALUE_RAW){if(l.columnId!==s)throw new RangeError("VALUE_RAW column without accompanying VALUE_LEN column");u>0&&l.encoder.appendRawBytes(f.readRawBytes(u))}else if(f)l.encoder.copyFrom(f,{count:d});else{let m=l.columnId%8===$n.BOOLEAN?!1:null;l.encoder.appendValue(m,d)}}}function u2(e,t){let r=[],n,i=-1,a=0,s=-1,u=0;for(let l of e){if(l.columnId%8===$n.VALUE_RAW){if(l.columnId!==s)throw new RangeError("unexpected VALUE_RAW column");n=l.decoder.readRawBytes(u)}else if(l.columnId%8===$n.GROUP_CARD)i=l.columnId>>4,a=l.decoder.readValue()||0,n=a;else if(l.columnId>>4===i){n=[],l.columnId%8===$n.VALUE_LEN&&(s=l.columnId+1,u=0);for(let f=0;f>>4),n.push(d)}}else n=l.decoder.readValue(),l.columnId%8===$n.ACTOR_ID&&t&&typeof n=="number"&&(n=t[n]),l.columnId%8===$n.VALUE_LEN&&(s=l.columnId+1,u=n>>>4);r.push(n)}return r}function gp(e,t,r){let n=0,i=-1,a=0;for(let s of e){for(;n>4,a=u,s.encoder.appendValue(u);else if(s.columnId>>4===i){if(!Array.isArray(u)||u.length!==a)throw new RangeError("bad group value");for(let l of u)s.encoder.appendValue(l)}else s.columnId%8===$n.VALUE_RAW?u&&s.encoder.appendRawBytes(u):s.encoder.appendValue(u)}else if(s.columnId%8===$n.GROUP_CARD)i=s.columnId>>4,a=0,s.encoder.appendValue(0);else if(s.columnId%8!==$n.VALUE_RAW){let u=s.columnId>>4===i?a:1,l=null;s.columnId%8===$n.BOOLEAN&&(l=!1),s.columnId%8===$n.VALUE_LEN&&(l=0),s.encoder.appendValue(l,u)}}}function o2(e,t){let r=e.blocks[t];if(r.columns[Kr].decoder.done){if(t===e.blocks.length-1)return{docOp:null,blockIndex:t};t+=1,r=e.blocks[t];for(let n of r.columns)n.decoder.reset();return{docOp:u2(r.columns),blockIndex:t}}else return{docOp:u2(r.columns),blockIndex:t}}function nD(e,t){for(;t.changeIndexe.maxOp&&(e.maxOp=t.opCtr),t.opCtr+=1;let r=t.nextOp;if(r[_r]===null&&r[Rr]!==null||r[_r]!==null&&r[Rr]===null)throw new RangeError(`Mismatched object reference: (${r[_r]}, ${r[Rr]})`);if(r[Bn]===null&&r[In]!==null||r[Bn]===0&&r[In]!==null||r[Bn]>0&&r[In]===null)throw new RangeError(`Mismatched operation key: (${r[Bn]}, ${r[In]})`)}function Lc(e,t){return t==="list"||t==="text"?{objectId:e,type:t,edits:[]}:{objectId:e,type:t,props:{}}}function Y4(e,t,r=1){let n=mp(e),i=mp(t);return n.actorId===i.actorId&&n.counter+r===i.counter}function Eh(e,t){if(e.length===0){e.push(t);return}let r=e[e.length-1];r.action==="insert"&&t.action==="insert"&&r.index===t.index-1&&r.value.type==="value"&&t.value.type==="value"&&r.elemId===r.opId&&t.elemId===t.opId&&Y4(r.elemId,t.elemId,1)&&r.value.datatype===t.value.datatype&&typeof r.value.value==typeof t.value.value?(r.action="multi-insert",t.value.datatype&&(r.datatype=t.value.datatype),r.values=[r.value.value,t.value.value],delete r.value,delete r.opId):r.action==="multi-insert"&&t.action==="insert"&&r.index+r.values.length===t.index&&t.value.type==="value"&&t.elemId===t.opId&&Y4(r.elemId,t.elemId,r.values.length)&&r.datatype===t.value.datatype&&typeof r.values[0]==typeof t.value.value?r.values.push(t.value.value):r.action==="remove"&&t.action==="remove"&&r.index===t.index?r.count+=t.count:e.push(t)}function l2(e,t,r,n,i,a){let s=!1;if(a)for(;!s&&e.length>0;){let u=e[e.length-1];if((u.action==="insert"||u.action==="update")&&u.index===t)e.pop(),s=u.action==="insert";else if(u.action==="multi-insert"&&u.index+u.values.length-1===t)u.values.pop(),s=!0;else break}s?Eh(e,{action:"insert",index:t,elemId:r,opId:n,value:i}):Eh(e,{action:"update",index:t,opId:n,value:i})}function Zj(e,t,r){let n=[];for(;e.length>0;){let a=e[e.length-1];if(a.action==="insert"){if(a.index!==t)throw new RangeError("last edit has unexpected index");n.unshift(e.pop());break}else if(a.action==="update"){if(a.index!==t)throw new RangeError("last edit has unexpected index");n.unshift(e.pop())}else throw new RangeError("last edit has unexpected action")}let i=!0;for(let a of n)l2(e,t,r,a.opId,a.value,i),i=!1}function c2(e,t,r,n,i,a,s,u){let l=!t,f=n[Kr]0;v||(a[h].visibleOps.push(n),a[h].hasChild=a[h].hasChild||n[Kr]%2===0);let y=i.objectMeta[r].children[h];if(a[h].hasChild||y&&Object.keys(y).length>0){let C={};for(let F of a[h].visibleOps){let U=`${F[pr]}@${i.actorIds[F[qn]]}`;if(bu[F[Kr]]==="set")C[U]=Object.assign({type:"value"},pp(F[io],F[fl]));else if(F[Kr]%2===0){let L=F[Kr]1?C.count-=1:D.edits.pop(),a[h].action="update",l2(D.edits,s,h,g,b,!0),t&&t.lastObjectActor===n[Rr]&&t.lastObjectCtr===n[_r]&&(t.numVisible+=1)}else l2(D.edits,s,h,g,b,!a[h].action),a[h].action||(a[h].action="update");else u===0&&!a[h].action&&(a[h].action="remove",Eh(D.edits,{action:"remove",index:s,count:1}),t&&t.lastObjectActor===n[Rr]&&t.lastObjectCtr===n[_r]&&(t.numVisible-=1));else(b||!l)&&((w||!D.props[n[yt]])&&(D.props[n[yt]]={}),b&&(D.props[n[yt]][g]=b))}function Qj(e,t,r,n,i,a,s){let u=n.nextOp,l=u[Vn],f=u[Rr],d=u[_r],m=f===null?"_root":`${d}@${i.actorIds[f]}`,p=n.actorIndex,h=i.actorIds[p],w=!1,v=!1,y={},g;({docOp:g,blockIndex:s}=o2(i,s));let b=g===null?0:1,D=g===null?0:g[ks],C=null,F=[],U=[],L=[],S=null;for(n.objectIds.add(m);;){if(F.length===0){w=!1;let M=n.nextOp;for(;!n.done&&M[qn]===p&&M[Vn]===l&&M[Rr]===u[Rr]&&M[_r]===u[_r];){let z=F.length>0?F[F.length-1]:null,W=!1;for(let ie=0;ie0&&(C=F[0]);let B=g&&g[Rr]===C[Rr]&&g[_r]===C[_r],O=g&&g[yt]!==null&&g[yt]===C[yt],x=g&&g[yt]===null&&C[yt]===null&&(!g[Vn]&&g[In]===C[In]&&g[Bn]===C[Bn]||g[Vn]&&g[qn]===C[In]&&g[pr]===C[Bn]);if(F.length===0&&!(B&&(O||x)))break;let j=!1,Y=0;if(l||!B||g[yt]===null&&C[yt]!==null||g[yt]!==null&&C[yt]!==null&&C[yt]=0;M--){let z=!0;for(let W=0;W0){for(let M=0;M({columnId:B.columnId,encoder:Uc(B.columnId)}));jc(C,g.columns,v);let{blockIndex:F,docOpsConsumed:U}=Qj(e,D,C,t,r,y,w),L=r.blocks[F],S=-v-U;for(let B=w;B<=F;B++)S+=r.blocks[B].numOps;jc(C,L.columns,S),D.numOps+=S;for(let B of L.columns)if(!B.decoder.done)throw new RangeError(`excess ops in column ${B.columnId}`);if(D.columns=C.map(B=>{let O=h2(B.columnId,B.encoder.buffer);return{columnId:B.columnId,decoder:O}}),w===F&&D.numOps<=bh)S>0&&g.lastVisibleActor!==void 0&&g.lastVisibleCtr!==void 0&&(D.lastVisibleActor=g.lastVisibleActor,D.lastVisibleCtr=g.lastVisibleCtr),r.blocks[w]=D;else{let B=rD(D);r.blocks.splice(w,F-w+1,...B)}}function tH(e,t){if(t[Rr].columnId!==Yt[Rr].columnId||Yt[Rr].columnName!=="objActor"||t[_r].columnId!==Yt[_r].columnId||Yt[_r].columnName!=="objCtr"||t[In].columnId!==Yt[In].columnId||Yt[In].columnName!=="keyActor"||t[Bn].columnId!==Yt[Bn].columnId||Yt[Bn].columnName!=="keyCtr"||t[yt].columnId!==Yt[yt].columnId||Yt[yt].columnName!=="keyStr"||t[qn].columnId!==Yt[qn].columnId||Yt[qn].columnName!=="idActor"||t[pr].columnId!==Yt[pr].columnId||Yt[pr].columnName!=="idCtr"||t[Vn].columnId!==Yt[Vn].columnId||Yt[Vn].columnName!=="insert"||t[Kr].columnId!==Yt[Kr].columnId||Yt[Kr].columnName!=="action"||t[io].columnId!==Yt[io].columnId||Yt[io].columnName!=="valLen"||t[fl].columnId!==Yt[fl].columnId||Yt[fl].columnName!=="valRaw"||t[so].columnId!==Yt[so].columnId||Yt[so].columnName!=="predNum"||t[Oc].columnId!==Yt[Oc].columnId||Yt[Oc].columnName!=="predActor"||t[kc].columnId!==Yt[kc].columnId||Yt[kc].columnName!=="predCtr")throw new RangeError("unexpected columnId");let r=e.blocks[0].columns;if(!t.every(n=>K4.includes(n.columnId)||r.find(i=>i.columnId===n.columnId))){let n=r.map(i=>({columnId:i.columnId}));for(let i of t){let{columnId:a}=i;!K4.includes(a)&&!r.find(s=>s.columnId===a)&&n.push({columnId:a})}n.sort((i,a)=>i.columnId-a.columnId);for(let i=0;i({columnId:s.columnId,buffer:s.decoder.buf})),n),e.blocks[i]=a}}}function rH(e,t){if(e.indexOf(t.actorIds[0])<0){if(t.seq!==1)throw new RangeError(`Seq ${t.seq} is the first change for actor ${t.actorIds[0]}`);e=e.concat([t.actorIds[0]])}let r=[];for(let n of t.actorIds){let i=e.indexOf(n);if(i<0)throw new RangeError(`actorId ${n} is not known to document`);r.push(i)}return{actorIds:e,actorTable:r}}function nH(e,t,r){for(let n of t){let i=r.objectMeta[n],a=null,s=!1;for(;;){let u=a&&Object.keys(i.children[a.parentKey]).length>0;if(e[n]||(e[n]=Lc(n,i.type)),a&&u)if(i.type==="list"||i.type==="text"){for(let l of e[n].edits)l.opId&&i.children[a.parentKey][l.opId]&&(s=!0);if(!s){let l=mp(n),f=mp(a.parentKey),d={objActor:l.actorId,objCtr:l.counter,keyActor:f.actorId,keyCtr:f.counter,objActorNum:r.actorIds.indexOf(l.actorId),keyActorNum:r.actorIds.indexOf(f.actorId),keyStr:null,insert:!1,objId:n},{visibleCount:m}=Z4(r,d);for(let[p,h]of Object.entries(i.children[a.parentKey])){let w=h;h.objectId&&(e[h.objectId]||(e[h.objectId]=Lc(h.objectId,h.type)),w=e[h.objectId]);let v={action:"update",index:m,opId:p,value:w};Eh(e[n].edits,v)}}}else{e[n].props[a.parentKey]||(e[n].props[a.parentKey]={});let l=e[n].props[a.parentKey];for(let[f,d]of Object.entries(i.children[a.parentKey]))l[f]?s=!0:d.objectId?(e[d.objectId]||(e[d.objectId]=Lc(d.objectId,d.type)),l[f]=e[d.objectId]):l[f]=d}if(s||!i.parentObj||a&&!u)break;a=i,n=i.parentObj,i=r.objectMeta[n]}}return e}function iH(e,t,r,n,i){let a=new Set(r.heads),s=new Set,u=vp(r.clock),l=[],f=[];for(let d of t){if(r.changeIndexByHash[d.hash]!==void 0||s.has(d.hash))continue;let m=(u[d.actor]||0)+1,p=!0;for(let h of d.deps){let w=r.changeIndexByHash[h];(w===void 0||w===-1)&&!s.has(h)&&(p=!1)}if(!p)f.push(d);else if(d.seqm)throw new RangeError(`Skipped sequence number ${m} for actor ${d.actor}`);u[d.actor]=d.seq,s.add(d.hash);for(let h of d.deps)a.delete(h);a.add(d.hash),l.push(d)}}if(l.length>0){let d={changes:l,changeIndex:-1,objectIds:n};for(nD(r,d);!d.done;)eH(e,d,r);r.heads=[...a].sort(),r.clock=u}return[l,f]}function W4(e){for(let d of e.blocks[0].columns)d.decoder.reset();let t={},r=null,n=0,i={_root:{objectId:"_root",type:"map",props:{}}},a=null,s=null,u="_root",l=!1,f=0;for(;{docOp:r,blockIndex:n}=o2(e,n),r!==null;){(r[Rr]!==a||r[_r]!==s)&&(u=`${r[_r]}@${e.actorIds[r[Rr]]}`,a=r[Rr],s=r[_r],t={},f=0,l=!1),r[Vn]&&l&&(l=!1,f++),r[ks]===0&&(l=!0),r[pr]>e.maxOp&&(e.maxOp=r[pr]);for(let d=0;de.maxOp&&(e.maxOp=r[Nc][d]);c2(i,null,u,r,e,t,f,r[ks])}return i._root}function sH(e){let t=Ah(e.changesColumns,Os),r=t[0].decoder,n=t[1].decoder,i=t[5].decoder,a=t[6].decoder;if(t[0].columnId!==Os[0].columnId||Os[0].columnName!=="actor"||t[1].columnId!==Os[1].columnId||Os[1].columnName!=="seq"||t[5].columnId!==Os[5].columnId||Os[5].columnName!=="depsNum"||t[6].columnId!==Os[6].columnId||Os[6].columnName!=="depsIndex")throw new RangeError("unexpected columnId");let s=0,u={},l=[],f=new Set;for(;!r.done;){let p=r.readValue(),h=n.readValue(),w=i.readValue(),v=e.actorIds[p];if(h!==1&&h!==u[v]+1)throw new RangeError(`Expected seq ${u[v]+1}, got ${h} for actor ${v}`);l.push(p),u[v]=h,f.add(s);for(let y=0;ye.actorIds[l[p]]).sort();for(let p of t)p.decoder.reset();let m=t.map(p=>({columnId:p.columnId,encoder:Uc(p.columnId)}));return jc(m,t,s),{clock:u,headActors:d,encoders:m,numChanges:s}}function aH(e,t,r,n){gp(e,Os,[r.indexOf(t.actor),t.seq,t.maxOp,t.time,t.message,t.deps.length,t.deps.map(i=>n[i]),t.extraBytes?t.extraBytes.byteLength<<4|i2.BYTES:i2.BYTES,t.extraBytes])}var f2=class e{constructor(t){if(this.maxOp=0,this.haveHashGraph=!1,this.changes=[],this.changeIndexByHash={},this.dependenciesByHash={},this.dependentsByHash={},this.hashesByActor={},this.actorIds=[],this.heads=[],this.clock={},this.queue=[],this.objectMeta={_root:{parentObj:null,parentKey:null,opId:null,type:"map",children:{}}},t){let r=Yj(t),{clock:n,headActors:i,encoders:a,numChanges:s}=sH(r);if(this.binaryDoc=t,this.changes=new Array(s),this.actorIds=r.actorIds,this.heads=r.heads,this.clock=n,this.changesEncoders=a,this.extraBytes=r.extraBytes,r.heads.length===1&&i.length===1&&(this.hashesByActor[i[0]]=[],this.hashesByActor[i[0]][n[i[0]]-1]=r.heads[0]),r.heads.length===r.headsIndexes.length)for(let l=0;lbh&&(this.blocks=rD(this.blocks[0]));let u={blocks:this.blocks,actorIds:this.actorIds,objectMeta:this.objectMeta,maxOp:0};this.initPatch=W4(u),this.maxOp=u.maxOp}else this.haveHashGraph=!0,this.changesEncoders=Os.map(r=>({columnId:r.columnId,encoder:Uc(r.columnId)})),this.blocks=[{columns:Ah([],V4),bloom:new Uint8Array(J4),numOps:0,lastKey:void 0,numVisible:void 0,lastObjectActor:void 0,lastObjectCtr:void 0,firstVisibleActor:void 0,firstVisibleCtr:void 0,lastVisibleActor:void 0,lastVisibleCtr:void 0}]}clone(){let t=new e;return t.maxOp=this.maxOp,t.haveHashGraph=this.haveHashGraph,t.changes=this.changes.slice(),t.changeIndexByHash=vp(this.changeIndexByHash),t.dependenciesByHash=vp(this.dependenciesByHash),t.dependentsByHash=Object.entries(this.dependentsByHash).reduce((r,[n,i])=>(r[n]=i.slice(),r),{}),t.hashesByActor=Object.entries(this.hashesByActor).reduce((r,[n,i])=>(r[n]=i.slice(),r),{}),t.actorIds=this.actorIds,t.heads=this.heads,t.clock=this.clock,t.blocks=this.blocks,t.objectMeta=this.objectMeta,t.queue=this.queue,t}applyChanges(t,r=!1){let n=t.map(d=>{let m=Kj(d);return m.buffer=d,m}),i={_root:{objectId:"_root",type:"map",props:{}}},a={maxOp:this.maxOp,changeIndexByHash:this.changeIndexByHash,actorIds:this.actorIds,heads:this.heads,clock:this.clock,blocks:this.blocks.slice(),objectMeta:Object.assign({},this.objectMeta)},s=this.queue.length===0?n:n.concat(this.queue),u=[],l=new Set;for(;;){let[d,m]=iH(i,s,a,l,this.haveHashGraph);s=m;for(let p=0;p0&&(u=u.concat(d)),s.length===0)break;if(d.length===0){if(this.haveHashGraph)break;this.computeHashGraph(),a.changeIndexByHash=this.changeIndexByHash}}nH(i,l,a);for(let d of u){this.changes.push(d.buffer),this.hashesByActor[d.actor]||(this.hashesByActor[d.actor]=[]),this.hashesByActor[d.actor][d.seq-1]=d.hash,this.changeIndexByHash[d.hash]=this.changes.length-1,this.dependenciesByHash[d.hash]=d.deps,this.dependentsByHash[d.hash]=[];for(let m of d.deps)this.dependentsByHash[m]||(this.dependentsByHash[m]=[]),this.dependentsByHash[m].push(d.hash);aH(this.changesEncoders,d,a.actorIds,this.changeIndexByHash)}this.maxOp=a.maxOp,this.actorIds=a.actorIds,this.heads=a.heads,this.clock=a.clock,this.blocks=a.blocks,this.objectMeta=a.objectMeta,this.queue=s,this.binaryDoc=null,this.initPatch=null;let f={maxOp:this.maxOp,clock:this.clock,deps:this.heads,pendingChanges:this.queue.length,diffs:i._root};return r&&n.length===1&&(f.actor=n[0].actor,f.seq=n[0].seq),f}computeHashGraph(){let t=this.save();this.haveHashGraph=!0,this.changes=[],this.changeIndexByHash={},this.dependenciesByHash={},this.dependentsByHash={},this.hashesByActor={},this.clock={};for(let r of Gj([t])){let n=Vj(r);this.changes.push(n),this.changeIndexByHash[r.hash]=this.changes.length-1,this.dependenciesByHash[r.hash]=r.deps,this.dependentsByHash[r.hash]=[];for(let a of r.deps)this.dependentsByHash[a].push(r.hash);r.seq===1&&(this.hashesByActor[r.actor]=[]),this.hashesByActor[r.actor].push(r.hash);let i=(this.clock[r.actor]||0)+1;if(r.seq!==i)throw new RangeError(`Expected seq ${i}, got seq ${r.seq} from actor ${r.actor}`);this.clock[r.actor]=r.seq}}getChanges(t){if(this.haveHashGraph||this.computeHashGraph(),t.length===0)return this.changes.slice();let r=[],n={},i=[];for(let a of t){n[a]=!0;let s=this.dependentsByHash[a];if(!s)throw new RangeError(`hash not found: ${a}`);r.push(...s)}for(;r.length>0;){let a=r.pop();if(n[a]=!0,i.push(a),!this.dependenciesByHash[a].every(s=>n[s]))break;r.push(...this.dependentsByHash[a])}if(r.length===0&&this.heads.every(a=>n[a]))return i.map(a=>this.changes[this.changeIndexByHash[a]]);for(r=t.slice(),n={};r.length>0;){let a=r.pop();if(!n[a]){let s=this.dependenciesByHash[a];if(!s)throw new RangeError(`hash not found: ${a}`);r.push(...s),n[a]=!0}}return this.changes.filter(a=>!n[zj(a,!0).hash])}getChangesAdded(t){this.haveHashGraph||this.computeHashGraph();let r=this.heads.slice(),n={},i=[];for(;r.length>0;){let a=r.pop();!n[a]&&t.changeIndexByHash[a]===void 0&&(n[a]=!0,i.push(a),r.push(...this.dependenciesByHash[a]))}return i.reverse().map(a=>this.changes[this.changeIndexByHash[a]])}getChangeByHash(t){return this.haveHashGraph||this.computeHashGraph(),this.changes[this.changeIndexByHash[t]]}getMissingDeps(t=[]){this.haveHashGraph||this.computeHashGraph();let r=new Set(t),n=new Set;for(let a of this.queue){n.add(a.hash);for(let s of a.deps)r.add(s)}let i=[];for(let a of r)this.changeIndexByHash[a]===void 0&&!n.has(a)&&i.push(a);return i.sort()}save(){if(this.binaryDoc)return this.binaryDoc;let t=this.changesEncoders.map(n=>({columnId:n.columnId,encoder:Uc(n.columnId)})),r=this.changesEncoders.map(n=>{let i=h2(n.columnId,n.encoder.buffer);return{columnId:n.columnId,decoder:i}});return jc(t,r,this.changes.length),this.binaryDoc=Wj({changesColumns:this.changesEncoders,opsColumns:Jj(this.blocks),actorIds:this.actorIds,heads:this.heads,headsIndexes:this.heads.map(n=>this.changeIndexByHash[n]),extraBytes:this.extraBytes}),this.changesEncoders=t,this.binaryDoc}getPatch(){let t={_root:{parentObj:null,parentKey:null,opId:null,type:"map",children:{}}},r={blocks:this.blocks,actorIds:this.actorIds,objectMeta:t,maxOp:0},n=this.initPatch?this.initPatch:W4(r);return{maxOp:this.maxOp,clock:this.clock,deps:this.heads,pendingChanges:this.queue.length,diffs:n}}};iD.exports={MAX_BLOCK_SIZE:bh,BackendDoc:f2,bloomFilterContains:eD}});var uD=he((HW,aD)=>{function uH(e){if(e.frozen)throw new Error("Attempting to use an outdated Automerge document that has already been updated. Please use the latest document state, or call Automerge.clone() if you really need to use this old document state.");return e.state}aD.exports={backendState:uH}});var d2=he((MW,fD)=>{var{encodeChange:oH}=wh(),{BackendDoc:lD}=sD(),{backendState:Ns}=uD();function lH(){return{state:new lD,heads:[]}}function cH(e){return{state:Ns(e).clone(),heads:e.heads}}function fH(e){e.state=null,e.frozen=!0}function hH(e,t){let r=Ns(e),n=r.applyChanges(t);return e.frozen=!0,[{state:r,heads:r.heads},n]}function oD(e,t,r){if(e.hashesByActor[t]&&e.hashesByActor[t][r]||!e.haveHashGraph&&(e.computeHashGraph(),e.hashesByActor[t]&&e.hashesByActor[t][r]))return e.hashesByActor[t][r];throw new RangeError(`Unknown change: actorId = ${t}, seq = ${r+1}`)}function dH(e,t){let r=Ns(e);if(t.seq<=r.clock[t.actor])throw new RangeError("Change request has already been applied");if(t.seq>1){let s=oD(r,t.actor,t.seq-2);if(!s)throw new RangeError(`Cannot find hash of localChange before seq=${t.seq}`);let u={[s]:!0};for(let l of t.deps)u[l]=!0;t.deps=Object.keys(u).sort()}let n=oH(t),i=r.applyChanges([n],!0);e.frozen=!0;let a=oD(r,t.actor,t.seq-1);return i.deps=i.deps.filter(s=>s!==a),[{state:r,heads:r.heads},i,n]}function pH(e){return Ns(e).save()}function gH(e){let t=new lD(e);return{state:t,heads:t.heads}}function mH(e,t){let r=Ns(e);return r.applyChanges(t),e.frozen=!0,{state:r,heads:r.heads}}function vH(e){return Ns(e).getPatch()}function wH(e){return e.heads}function AH(e){return cD(e,[])}function cD(e,t){if(!Array.isArray(t))throw new TypeError("Pass an array of hashes to Backend.getChanges()");return Ns(e).getChanges(t)}function EH(e,t){return Ns(t).getChangesAdded(Ns(e))}function bH(e,t){return Ns(e).getChangeByHash(t)}function yH(e,t=[]){return Ns(e).getMissingDeps(t)}fD.exports={init:lH,clone:cH,free:fH,applyChanges:hH,applyLocalChange:dH,save:pH,load:gH,loadChanges:mH,getPatch:vH,getHeads:wH,getAllChanges:AH,getChanges:cD,getChangesAdded:EH,getChangeByHash:bH,getMissingDeps:yH}});var AD=he((qW,wD)=>{var Ls=d2(),{hexStringToBytes:hD,bytesToHexString:_H,Encoder:m2,Decoder:v2}=Yv(),{decodeChangeMeta:Ep}=wh(),{copyObject:CH}=Rs(),dD=32,pD=66,gD=67,DH=10,FH=7,yh=class{constructor(t){if(Array.isArray(t)){this.numEntries=t.length,this.numBitsPerEntry=DH,this.numProbes=FH,this.bits=new Uint8Array(Math.ceil(this.numEntries*this.numBitsPerEntry/8));for(let r of t)this.addHash(r)}else if(t instanceof Uint8Array)if(t.byteLength===0)this.numEntries=0,this.numBitsPerEntry=0,this.numProbes=0,this.bits=t;else{let r=new v2(t);this.numEntries=r.readUint32(),this.numBitsPerEntry=r.readUint32(),this.numProbes=r.readUint32(),this.bits=r.readRawBytes(Math.ceil(this.numEntries*this.numBitsPerEntry/8))}else throw new TypeError("invalid argument")}get bytes(){if(this.numEntries===0)return new Uint8Array(0);let t=new m2;return t.appendUint32(this.numEntries),t.appendUint32(this.numBitsPerEntry),t.appendUint32(this.numProbes),t.appendRawBytes(this.bits),t.buffer}getProbes(t){let r=hD(t),n=8*this.bits.byteLength;if(r.byteLength!==32)throw new RangeError(`Not a 256-bit hash: ${t}`);let i=((r[0]|r[1]<<8|r[2]<<16|r[3]<<24)>>>0)%n,a=((r[4]|r[5]<<8|r[6]<<16|r[7]<<24)>>>0)%n,s=((r[8]|r[9]<<8|r[10]<<16|r[11]<<24)>>>0)%n,u=[i];for(let l=1;l>>3]|=1<<(r&7)}containsHash(t){if(this.numEntries===0)return!1;for(let r of this.getProbes(t))if(!(this.bits[r>>>3]&1<<(r&7)))return!1;return!0}};function wp(e,t){if(!Array.isArray(t))throw new TypeError("hashes must be an array");e.appendUint32(t.length);for(let r=0;r0&&t[r-1]>=t[r])throw new RangeError("hashes must be sorted");let n=hD(t[r]);if(n.byteLength!==dD)throw new TypeError("heads hashes must be 256 bits");e.appendRawBytes(n)}}function Ap(e){let t=e.readUint32(),r=[];for(let n=0;nEp(i,!0).hash);return{lastSync:t,bloom:new yh(n).bytes}}function $H(e,t,r){if(t.length===0)return r.map(m=>Ls.getChangeByHash(e,m)).filter(m=>m!==void 0);let n={},i=[];for(let m of t){for(let p of m.lastSync)n[p]=!0;i.push(new yh(m.bloom))}let a=Ls.getChanges(e,Object.keys(n)).map(m=>Ep(m,!0)),s={},u={},l={};for(let m of a){s[m.hash]=!0;for(let p of m.deps)u[p]||(u[p]=[]),u[p].push(m.hash);i.every(p=>!p.containsHash(m.hash))&&(l[m.hash]=!0)}let f=Object.keys(l);for(;f.length>0;){let m=f.pop();if(u[m])for(let p of u[m])l[p]||(l[p]=!0,f.push(p))}let d=[];for(let m of r)if(l[m]=!0,!s[m]){let p=Ls.getChangeByHash(e,m);p&&d.push(p)}for(let m of a)l[m.hash]&&d.push(m.change);return d}function vD(){return{sharedHeads:[],lastSentHeads:[],theirHeads:null,theirNeed:null,theirHave:null,sentHashes:{}}}function g2(e,t){return e.length===t.length&&e.every((r,n)=>r===t[n])}function PH(e,t){if(!e)throw new Error("generateSyncMessage called with no Automerge document");if(!t)throw new Error("generateSyncMessage requires a syncState, which can be created with initSyncState()");let{sharedHeads:r,lastSentHeads:n,theirHeads:i,theirNeed:a,theirHave:s,sentHashes:u}=t,l=Ls.getHeads(e),f=Ls.getMissingDeps(e,i||[]),d=[];if((!i||f.every(v=>i.includes(v)))&&(d=[BH(e,r)]),s&&s.length>0&&!s[0].lastSync.every(y=>Ls.getChangeByHash(e,y))){let y={heads:l,need:[],have:[{lastSync:[],bloom:new Uint8Array(0)}],changes:[]};return[t,p2(y)]}let m=Array.isArray(s)&&Array.isArray(a)?$H(e,s,a):[],p=Array.isArray(n)&&g2(l,n),h=Array.isArray(i)&&g2(l,i);if(p&&h&&m.length===0)return[t,null];m=m.filter(v=>!u[Ep(v,!0).hash]);let w={heads:l,have:d,need:f,changes:m};if(m.length>0){u=CH(u);for(let v of m)u[Ep(v,!0).hash]=!0}return t=Object.assign({},t,{lastSentHeads:l,sentHashes:u}),[t,p2(w)]}function xH(e,t,r){let n=t.filter(s=>!e.includes(s)),i=r.filter(s=>t.includes(s));return[...new Set([...n,...i])].sort()}function RH(e,t,r){if(!e)throw new Error("generateSyncMessage called with no Automerge document");if(!t)throw new Error("generateSyncMessage requires a syncState, which can be created with initSyncState()");let{sharedHeads:n,lastSentHeads:i,sentHashes:a}=t,s=null,u=mD(r),l=Ls.getHeads(e);u.changes.length>0&&([e,s]=Ls.applyChanges(e,u.changes),n=xH(l,Ls.getHeads(e),n)),u.changes.length===0&&g2(u.heads,l)&&(i=u.heads);let f=u.heads.filter(m=>Ls.getChangeByHash(e,m));f.length===u.heads.length?(n=u.heads,u.heads.length===0&&(i=[],a=[])):n=[...new Set(f.concat(n))].sort();let d={sharedHeads:n,lastSentHeads:i,theirHave:u.have,theirHeads:u.heads,theirNeed:u.need,sentHashes:a};return[e,d,s]}wD.exports={receiveSyncMessage:RH,generateSyncMessage:PH,encodeSyncMessage:p2,decodeSyncMessage:mD,initSyncState:vD,encodeSyncState:SH,decodeSyncState:IH,BloomFilter:yh}});var bD=he((VW,ED)=>{var{init:TH,clone:OH,free:kH,applyChanges:NH,applyLocalChange:LH,save:UH,load:jH,loadChanges:HH,getPatch:MH,getHeads:qH,getAllChanges:VH,getChanges:KH,getChangesAdded:zH,getChangeByHash:GH,getMissingDeps:YH}=d2(),{receiveSyncMessage:WH,generateSyncMessage:XH,encodeSyncMessage:JH,decodeSyncMessage:ZH,encodeSyncState:QH,decodeSyncState:eM,initSyncState:tM}=AD();ED.exports={init:TH,clone:OH,free:kH,applyChanges:NH,applyLocalChange:LH,save:UH,load:jH,loadChanges:HH,getPatch:MH,getHeads:qH,getAllChanges:VH,getChanges:KH,getChangesAdded:zH,getChangeByHash:GH,getMissingDeps:YH,receiveSyncMessage:WH,generateSyncMessage:XH,encodeSyncMessage:JH,decodeSyncMessage:ZH,encodeSyncState:QH,decodeSyncState:eM,initSyncState:tM}});var ID=he((KW,A2)=>{var rM=Ld(),en=PC(),{OPTIONS:yD}=gu(),{encodeChange:nM,decodeChange:_D}=wh(),{isObject:w2}=Rs(),Nr=bD();function _h(e){if(typeof e=="string")e={actorId:e};else if(typeof e>"u")e={};else if(!w2(e))throw new TypeError(`Unsupported options for init(): ${e}`);return en.init(Object.assign({backend:Nr},e))}function iM(e,t){let r={message:"Initialization"};return CD(_h(t),r,n=>Object.assign(n,e))}function CD(e,t,r){let[n]=en.change(e,t,r);return n}function sM(e,t){let[r]=en.emptyChange(e,t);return r}function aM(e,t={}){let r=Nr.clone(en.getBackendState(e,"clone"));return bp(_h(t),Nr.getPatch(r),r,[],t)}function uM(e){Nr.free(en.getBackendState(e,"free"))}function oM(e,t={}){let r=Nr.load(e);return bp(_h(t),Nr.getPatch(r),r,[e],t)}function lM(e){return Nr.save(en.getBackendState(e,"save"))}function cM(e,t){let r=en.getBackendState(e,"merge"),n=en.getBackendState(t,"merge","second"),i=Nr.getChangesAdded(r,n),[a]=FD(e,i);return a}function fM(e,t){let r=en.getBackendState(e,"getChanges"),n=en.getBackendState(t,"getChanges","second");return Nr.getChanges(n,Nr.getHeads(r))}function DD(e){return Nr.getAllChanges(en.getBackendState(e,"getAllChanges"))}function bp(e,t,r,n,i){let a=en.applyPatch(e,t,r),s=i.patchCallback||e[yD].patchCallback;return s&&s(t,e,a,!1,n),a}function FD(e,t,r={}){let n=en.getBackendState(e,"applyChanges"),[i,a]=Nr.applyChanges(n,t);return[bp(e,a,i,t,r),a]}function SD(e,t){if(!w2(e)||!w2(t))return e===t;let r=Object.keys(e).sort(),n=Object.keys(t).sort();if(r.length!==n.length)return!1;for(let i=0;i({get change(){return _D(n)},get snapshot(){let a=Nr.loadChanges(Nr.init(),r.slice(0,i+1));return en.applyPatch(_h(t),Nr.getPatch(a),a)}}))}function dM(e,t){let r=en.getBackendState(e,"generateSyncMessage");return Nr.generateSyncMessage(r,t)}function pM(e,t,r){let n=en.getBackendState(e,"receiveSyncMessage"),[i,a,s]=Nr.receiveSyncMessage(n,t,r);if(!s)return[e,a,s];let u=null;return e[yD].patchCallback&&(u=Nr.decodeSyncMessage(r).changes),[bp(e,s,i,u,{}),a,s]}function gM(){return Nr.initSyncState()}function mM(e){Nr=e}A2.exports={init:_h,from:iM,change:CD,emptyChange:sM,clone:aM,free:uM,load:oM,save:lM,merge:cM,getChanges:fM,getAllChanges:DD,applyChanges:FD,encodeChange:nM,decodeChange:_D,equals:SD,getHistory:hM,uuid:rM,Frontend:en,setDefaultBackend:mM,generateSyncMessage:dM,receiveSyncMessage:pM,initSyncState:gM,get Backend(){return Nr}};for(let e of["getObjectId","getObjectById","getActorId","setActorId","getConflicts","getLastLocalChange","Text","Table","Counter","Observable","Int","Uint","Float64"])A2.exports[e]=en[e]});var Dp=he(($X,OD)=>{"use strict";var YM=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])},_2=class e extends Error{constructor(t,r,n){super(t),YM(this,e.prototype),this.name="GrammarError",this.location=r,n===void 0&&(n=[]),this.diagnostics=n,this.stage=null,this.problems=[["error",t,r,n]]}toString(){let t=super.toString();this.location&&(t+=` at `,this.location.source!==void 0&&this.location.source!==null&&(t+=`${this.location.source}:`),t+=`${this.location.start.line}:${this.location.start.column}`);for(let r of this.diagnostics)t+=` from `,r.location.source!==void 0&&r.location.source!==null&&(t+=`${r.location.source}:`),t+=`${r.location.start.line}:${r.location.start.column}: ${r.message}`;return t}format(t){let r=t.map(({source:a,text:s})=>({source:a,text:s.split(/\r\n|\n|\r/g)}));function n(a,s,u=""){let l="",f=r.find(({source:m})=>m===a.source),d=a.start;if(f){let m=a.end,p=f.text[d.line-1],w=(d.line===m.line?m.column:p.length+1)-d.column||1;u&&(l+=` note: ${u}`),l+=` --> ${a.source}:${d.line}:${d.column} ${"".padEnd(s)} | ${d.line.toString().padStart(s)} | ${p} ${"".padEnd(s)} | ${"".padEnd(d.column-1)}${"".padEnd(w,"^")}`}else l+=` at ${a.source}:${d.line}:${d.column}`,u&&(l+=`: ${u}`);return l}function i(a,s,u,l=[]){let f;u?f=l.reduce((m,{location:p})=>Math.max(m,p.start.line),u.start.line):f=Math.max.apply(null,l.map(m=>m.location.start.line)),f=f.toString().length;let d=`${a}: ${s}`;u&&(d+=n(u,f));for(let m of l)d+=n(m.location,f,m.message);return d}return this.problems.filter(a=>a[0]!=="info").map(a=>i(...a)).join(` `)}};OD.exports=_2});var ws=he((PX,kD)=>{"use strict";var WM={build(e){function t(s,...u){return e[s.type](s,...u)}function r(){}function n(s,...u){return t(s.expression,...u)}function i(s){return function(u,...l){u[s].forEach(f=>t(f,...l))}}let a={grammar(s,...u){s.topLevelInitializer&&t(s.topLevelInitializer,...u),s.initializer&&t(s.initializer,...u),s.rules.forEach(l=>t(l,...u))},top_level_initializer:r,initializer:r,rule:n,named:n,choice:i("alternatives"),action:n,sequence:i("elements"),labeled:n,text:n,simple_and:n,simple_not:n,optional:n,zero_or_more:n,one_or_more:n,group:n,semantic_and:r,semantic_not:r,rule_ref:r,literal:r,class:r,any:r};return Object.keys(a).forEach(s=>{Object.prototype.hasOwnProperty.call(e,s)||(e[s]=a[s])}),t}};kD.exports=WM});var ao=he((xX,LD)=>{"use strict";var XM=ws(),ND={findRule(e,t){for(let r=0;r{"use strict";var JM={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};UD.exports=JM});var D2=he((TX,jD)=>{"use strict";var ZM=ws(),QM=ao(),eq=Dp(),Sh=1,hl=0,Ih=-1;function Fp(e){function t(s){return s.match=hl}function r(s){return a(s.expression),s.match=Sh}function n(s){return s.match=a(s.expression)}function i(s,u){let l=s.length,f=0,d=0;for(let m=0;m0?Ih:hl}let a=ZM.build({rule(s){let u,l=0;if(typeof s.match>"u"){s.match=hl;do if(u=s.match,s.match=a(s.expression),++l>6)throw new eq("Infinity cycle detected when trying to evaluate node match result",s.location);while(u!==s.match)}return s.match},named:n,choice(s){return s.match=i(s.alternatives,!0)},action:n,sequence(s){return s.match=i(s.elements,!1)},labeled:n,text:n,simple_and:n,simple_not(s){return s.match=-a(s.expression)},optional:r,zero_or_more:r,one_or_more:n,group:n,semantic_and:t,semantic_not:t,rule_ref(s){let u=QM.findRule(e,s.name);return s.match=a(u)},literal(s){let u=s.value.length===0?Sh:hl;return s.match=u},class(s){let u=s.parts.length===0?Ih:hl;return s.match=u},any:t});a(e)}Fp.ALWAYS_MATCH=Sh;Fp.SOMETIMES_MATCH=hl;Fp.NEVER_MATCH=Ih;jD.exports=Fp});var MD=he((OX,HD)=>{"use strict";var tq=ao(),Pe=C2(),rq=ws(),{ALWAYS_MATCH:Mc,SOMETIMES_MATCH:F2,NEVER_MATCH:S2}=D2();function nq(e){let t=[],r=[],n=[],i=[];function a(b){let D=t.indexOf(b);return D===-1?t.push(b)-1:D}function s(b){let D={value:b.parts,inverted:b.inverted,ignoreCase:b.ignoreCase},C=JSON.stringify(D),F=r.findIndex(U=>JSON.stringify(U)===C);return F===-1?r.push(D)-1:F}function u(b){let D=JSON.stringify(b),C=n.findIndex(F=>JSON.stringify(F)===D);return C===-1?n.push(b)-1:C}function l(b,D,C){let F={predicate:b,params:D,body:C.code,location:C.codeLocation},U=JSON.stringify(F),L=i.findIndex(S=>JSON.stringify(S)===U);return L===-1?i.push(F)-1:L}function f(b){let D={};return Object.keys(b).forEach(C=>{D[C]=b[C]}),D}function d(b,...D){return b.concat(...D)}function m(b,D,C,F){return b===Mc?C:b===S2?F:D.concat([C.length,F.length],C,F)}function p(b,D){return b.concat([D.length],D)}function h(b,D,C,F){let U=Object.keys(C).map(L=>F-C[L]);return[Pe.CALL,b,D,U.length].concat(U)}function w(b,D,C){let F=b.match|0;return d([Pe.PUSH_CURR_POS],[Pe.SILENT_FAILS_ON],g(b,{sp:C.sp+1,env:f(C.env),action:null}),[Pe.SILENT_FAILS_OFF],m(D?-F:F,[D?Pe.IF_ERROR:Pe.IF_NOT_ERROR],d([Pe.POP],[D?Pe.POP:Pe.POP_CURR_POS],[Pe.PUSH_UNDEFINED]),d([Pe.POP],[D?Pe.POP_CURR_POS:Pe.POP],[Pe.PUSH_FAILED])))}function v(b,D,C){let F=l(!0,Object.keys(C.env),b);return d([Pe.UPDATE_SAVED_POS],h(F,0,C.env,C.sp),m(b.match|0,[Pe.IF],d([Pe.POP],D?[Pe.PUSH_FAILED]:[Pe.PUSH_UNDEFINED]),d([Pe.POP],D?[Pe.PUSH_UNDEFINED]:[Pe.PUSH_FAILED])))}function y(b){return p([Pe.WHILE_NOT_ERROR],d([Pe.APPEND],b))}let g=rq.build({grammar(b){b.rules.forEach(g),b.literals=t,b.classes=r,b.expectations=n,b.functions=i},rule(b){b.bytecode=g(b.expression,{sp:-1,env:{},pluck:[],action:null})},named(b,D){let C=b.match|0,F=C===S2?null:u({type:"rule",value:b.name});return d([Pe.SILENT_FAILS_ON],g(b.expression,D),[Pe.SILENT_FAILS_OFF],m(C,[Pe.IF_ERROR],[Pe.FAIL,F],[]))},choice(b,D){function C(F,U){let L=F[0].match|0,S=g(F[0],{sp:U.sp,env:f(U.env),action:null});return L===Mc?S:d(S,F.length>1?m(F2,[Pe.IF_ERROR],d([Pe.POP],C(F.slice(1),U)),[]):[])}return C(b.alternatives,D)},action(b,D){let C=f(D.env),F=b.expression.type!=="sequence"||b.expression.elements.length===0,U=g(b.expression,{sp:D.sp+(F?1:0),env:C,action:b}),L=b.expression.match|0,S=F&&L!==S2?l(!1,Object.keys(C),b):null;return F?d([Pe.PUSH_CURR_POS],U,m(L,[Pe.IF_NOT_ERROR],d([Pe.LOAD_SAVED_POS,1],h(S,1,C,D.sp+2)),[]),[Pe.NIP]):U},sequence(b,D){function C(F,U){if(F.length>0){let L=b.elements.length-F.length+1;return d(g(F[0],{sp:U.sp,env:U.env,pluck:U.pluck,action:null}),m(F[0].match|0,[Pe.IF_NOT_ERROR],C(F.slice(1),{sp:U.sp+1,env:U.env,pluck:U.pluck,action:U.action}),d(L>1?[Pe.POP_N,L]:[Pe.POP],[Pe.POP_CURR_POS],[Pe.PUSH_FAILED])))}else{if(U.pluck.length>0)return d([Pe.PLUCK,b.elements.length+1,U.pluck.length],U.pluck.map(L=>U.sp-L));if(U.action){let L=l(!1,Object.keys(U.env),U.action);return d([Pe.LOAD_SAVED_POS,b.elements.length],h(L,b.elements.length+1,U.env,U.sp))}else return d([Pe.WRAP,b.elements.length],[Pe.NIP])}}return d([Pe.PUSH_CURR_POS],C(b.elements,{sp:D.sp+1,env:D.env,pluck:[],action:D.action}))},labeled(b,D){let C=D.env,F=b.label,U=D.sp+1;return F&&(C=f(D.env),D.env[b.label]=U),b.pick&&D.pluck.push(U),g(b.expression,{sp:D.sp,env:C,action:null})},text(b,D){return d([Pe.PUSH_CURR_POS],g(b.expression,{sp:D.sp+1,env:f(D.env),action:null}),m(b.match|0,[Pe.IF_NOT_ERROR],d([Pe.POP],[Pe.TEXT]),[Pe.NIP]))},simple_and(b,D){return w(b.expression,!1,D)},simple_not(b,D){return w(b.expression,!0,D)},optional(b,D){return d(g(b.expression,{sp:D.sp,env:f(D.env),action:null}),m(-(b.expression.match|0),[Pe.IF_ERROR],d([Pe.POP],[Pe.PUSH_NULL]),[]))},zero_or_more(b,D){let C=g(b.expression,{sp:D.sp+1,env:f(D.env),action:null});return d([Pe.PUSH_EMPTY_ARRAY],C,y(C),[Pe.POP])},one_or_more(b,D){let C=g(b.expression,{sp:D.sp+1,env:f(D.env),action:null});return d([Pe.PUSH_EMPTY_ARRAY],C,m(b.expression.match|0,[Pe.IF_NOT_ERROR],d(y(C),[Pe.POP]),d([Pe.POP],[Pe.POP],[Pe.PUSH_FAILED])))},group(b,D){return g(b.expression,{sp:D.sp,env:f(D.env),action:null})},semantic_and(b,D){return v(b,!1,D)},semantic_not(b,D){return v(b,!0,D)},rule_ref(b){return[Pe.RULE,tq.indexOfRule(e,b.name)]},literal(b){if(b.value.length>0){let D=b.match|0,F=D===F2||D===Mc&&!b.ignoreCase?a(b.ignoreCase?b.value.toLowerCase():b.value):null,U=D!==Mc?u({type:"literal",value:b.value,ignoreCase:b.ignoreCase}):null;return m(D,b.ignoreCase?[Pe.MATCH_STRING_IC,F]:[Pe.MATCH_STRING,F],b.ignoreCase?[Pe.ACCEPT_N,b.value.length]:[Pe.ACCEPT_STRING,F],[Pe.FAIL,U])}return[Pe.PUSH_EMPTY_STRING]},class(b){let D=b.match|0,C=D===F2?s(b):null,F=D!==Mc?u({type:"class",value:b.parts,inverted:b.inverted,ignoreCase:b.ignoreCase}):null;return m(D,[Pe.MATCH_CHAR_CLASS,C],[Pe.ACCEPT_N,1],[Pe.FAIL,F])},any(b){let D=b.match|0,C=D!==Mc?u({type:"any"}):null;return m(D,[Pe.MATCH_ANY],[Pe.ACCEPT_N,1],[Pe.FAIL,C])}});g(e)}HD.exports=nq});var VD=he((kX,qD)=>{"use strict";var I2=class{constructor(t,r,n){this.sp=-1,this.maxSp=-1,this.varName=r,this.ruleName=t,this.type=n}name(t){if(t<0)throw new RangeError(`Rule '${this.ruleName}': The variable stack underflow: attempt to use a variable '${this.varName}' at an index ${t}`);return this.varName+t}push(t){let r=this.name(++this.sp)+" = "+t+";";return this.sp>this.maxSp&&(this.maxSp=this.sp),r}pop(t){return t!==void 0?(this.sp-=t,Array.from({length:t},(r,n)=>this.name(this.sp+1+n))):this.name(this.sp--)}top(){return this.name(this.sp)}index(t){if(t<0)throw new RangeError(`Rule '${this.ruleName}': The variable stack overflow: attempt to get a variable at a negative index ${t}`);return this.name(this.sp-t)}result(){if(this.maxSp<0)throw new RangeError(`Rule '${this.ruleName}': The variable stack is empty, can't get the result'`);return this.name(0)}defines(){return this.maxSp<0?"":this.type+" "+Array.from({length:this.maxSp+1},(t,r)=>this.name(r)).join(", ")+";"}checkedIf(t,r,n){let i=this.sp;if(r(),n){let a=this.sp;if(this.sp=i,n(),a!==this.sp)throw new Error("Rule '"+this.ruleName+"', position "+t+": Branches of a condition can't move the stack pointer differently (before: "+i+", after then: "+a+", after else: "+this.sp+").")}}checkedLoop(t,r){let n=this.sp;if(r(),n!==this.sp)throw new Error("Rule '"+this.ruleName+"', position "+t+": Body of a loop can't move the stack pointer (before: "+n+", after: "+this.sp+").")}};qD.exports=I2});var B2=he((NX,KD)=>{"use strict";KD.exports="2.0.1"});var zD=he(Sp=>{"use strict";function _u(e){return e.charCodeAt(0).toString(16).toUpperCase()}Sp.hex=_u;function iq(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"+_u(t)).replace(/[\x10-\x1F\x7F-\xFF]/g,t=>"\\x"+_u(t)).replace(/[\u0100-\u0FFF]/g,t=>"\\u0"+_u(t)).replace(/[\u1000-\uFFFF]/g,t=>"\\u"+_u(t))}Sp.stringEscape=iq;function sq(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"+_u(t)).replace(/[\x10-\x1F\x7F-\xFF]/g,t=>"\\x"+_u(t)).replace(/[\u0100-\u0FFF]/g,t=>"\\u0"+_u(t)).replace(/[\u1000-\uFFFF]/g,t=>"\\u"+_u(t))}Sp.regexpClassEscape=sq});var WD=he(YD=>{var GD="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");YD.encode=function(e){if(0<=e&&e{var aq=WD(),XD=5,JD=1<>>=XD,i>0&&(n|=oq),r+=aq.encode(n);while(i>0);return r}});var Bp=he(oo=>{function cq(e,t,r){if(t in e)return e[t];if(arguments.length===3)return r;throw new Error('"'+t+'" is a required argument.')}oo.getArg=cq;var t3=function(){return!("__proto__"in Object.create(null))}();function r3(e){return e}function fq(e){return n3(e)?"$"+e:e}oo.toSetString=t3?r3:fq;function hq(e){return n3(e)?e.slice(1):e}oo.fromSetString=t3?r3:hq;function n3(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 e3(e,t){return e===t?0:e===null?1:t===null?-1:e>t?1:-1}function dq(e,t){let r=e.generatedLine-t.generatedLine;return r!==0||(r=e.generatedColumn-t.generatedColumn,r!==0)||(r=e3(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:e3(e.name,t.name)}oo.compareByGeneratedPositionsInflated=dq;var $2="http:",Bh=`${$2}//host`;function i3(e){return t=>{let r=$h(t),n=P2(t),i=new URL(t,n);e(i);let a=i.toString();return r==="absolute"?a:r==="scheme-relative"?a.slice($2.length):r==="path-absolute"?a.slice(Bh.length):x2(n,a)}}function uo(e,t){return new URL(e,t).toString()}function pq(e,t){let r=0;do{let n=e+r++;if(t.indexOf(n)===-1)return n}while(!0)}function P2(e){let t=e.split("..").length-1,r=pq("p",e),n=`${Bh}/`;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 mq=i3(e=>{e.pathname=e.pathname.replace(/\/?$/,"/")}),Ip=i3(e=>{});oo.normalize=Ip;function vq(e,t){let r=$h(t),n=$h(e);if(e=mq(e),r==="absolute")return uo(t,void 0);if(n==="absolute")return uo(t,e);if(r==="scheme-relative")return Ip(t);if(n==="scheme-relative")return uo(t,uo(e,Bh)).slice($2.length);if(r==="path-absolute")return Ip(t);if(n==="path-absolute")return uo(t,uo(e,Bh)).slice(Bh.length);let i=P2(t+e),a=uo(t,uo(e,i));return x2(i,a)}oo.join=vq;function wq(e,t){let r=Aq(e,t);return typeof r=="string"?r:Ip(t)}oo.relative=wq;function Aq(e,t){if($h(e)!==$h(t))return null;let n=P2(e+t),i=new URL(e,n),a=new URL(t,n);try{new URL("",a.toString())}catch{return null}return a.protocol!==i.protocol||a.user!==i.user||a.password!==i.password||a.hostname!==i.hostname||a.port!==i.port?null:x2(i,a)}});var a3=he(s3=>{var R2=class e{constructor(){this._array=[],this._set=new Map}static fromArray(t,r){let n=new e;for(let i=0,a=t.length;i=0)return r;throw new Error('"'+t+'" is not in the set.')}at(t){if(t>=0&&t{var u3=Bp();function Eq(e,t){let r=e.generatedLine,n=t.generatedLine,i=e.generatedColumn,a=t.generatedColumn;return n>r||n==r&&a>=i||u3.compareByGeneratedPositionsInflated(e,t)<=0}var T2=class{constructor(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}unsortedForEach(t,r){this._array.forEach(t,r)}add(t){Eq(this._last,t)?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))}toArray(){return this._sorted||(this._array.sort(u3.compareByGeneratedPositionsInflated),this._sorted=!0),this._array}};o3.MappingList=T2});var O2=he(c3=>{var Ph=QD(),zr=Bp(),$p=a3().ArraySet,bq=l3().MappingList,Pp=class e{constructor(t){t||(t={}),this._file=zr.getArg(t,"file",null),this._sourceRoot=zr.getArg(t,"sourceRoot",null),this._skipValidation=zr.getArg(t,"skipValidation",!1),this._sources=new $p,this._names=new $p,this._mappings=new bq,this._sourcesContents=null}static fromSourceMap(t){let r=t.sourceRoot,n=new e({file:t.file,sourceRoot:r});return t.eachMapping(function(i){let a={generated:{line:i.generatedLine,column:i.generatedColumn}};i.source!=null&&(a.source=i.source,r!=null&&(a.source=zr.relative(r,a.source)),a.original={line:i.originalLine,column:i.originalColumn},i.name!=null&&(a.name=i.name)),n.addMapping(a)}),t.sources.forEach(function(i){let a=i;r!=null&&(a=zr.relative(r,i)),n._sources.has(a)||n._sources.add(a);let s=t.sourceContentFor(i);s!=null&&n.setSourceContent(i,s)}),n}addMapping(t){let r=zr.getArg(t,"generated"),n=zr.getArg(t,"original",null),i=zr.getArg(t,"source",null),a=zr.getArg(t,"name",null);this._skipValidation||this._validateMapping(r,n,i,a),i!=null&&(i=String(i),this._sources.has(i)||this._sources.add(i)),a!=null&&(a=String(a),this._names.has(a)||this._names.add(a)),this._mappings.add({generatedLine:r.line,generatedColumn:r.column,originalLine:n&&n.line,originalColumn:n&&n.column,source:i,name:a})}setSourceContent(t,r){let n=t;this._sourceRoot!=null&&(n=zr.relative(this._sourceRoot,n)),r!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[zr.toSetString(n)]=r):this._sourcesContents&&(delete this._sourcesContents[zr.toSetString(n)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))}applySourceMap(t,r,n){let i=r;if(r==null){if(t.file==null)throw new Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`);i=t.file}let a=this._sourceRoot;a!=null&&(i=zr.relative(a,i));let s=this._mappings.toArray().length>0?new $p:this._sources,u=new $p;this._mappings.unsortedForEach(function(l){if(l.source===i&&l.originalLine!=null){let m=t.originalPositionFor({line:l.originalLine,column:l.originalColumn});m.source!=null&&(l.source=m.source,n!=null&&(l.source=zr.join(n,l.source)),a!=null&&(l.source=zr.relative(a,l.source)),l.originalLine=m.line,l.originalColumn=m.column,m.name!=null&&(l.name=m.name))}let f=l.source;f!=null&&!s.has(f)&&s.add(f);let d=l.name;d!=null&&!u.has(d)&&u.add(d)},this),this._sources=s,this._names=u,t.sources.forEach(function(l){let f=t.sourceContentFor(l);f!=null&&(n!=null&&(l=zr.join(n,l)),a!=null&&(l=zr.relative(a,l)),this.setSourceContent(l,f))},this)}_validateMapping(t,r,n,i){if(r&&typeof r.line!="number"&&typeof r.column!="number")throw new Error("original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.");if(!(t&&"line"in t&&"column"in t&&t.line>0&&t.column>=0&&!r&&!n&&!i)){if(!(t&&"line"in t&&"column"in t&&r&&"line"in r&&"column"in r&&t.line>0&&t.column>=0&&r.line>0&&r.column>=0&&n))throw new Error("Invalid mapping: "+JSON.stringify({generated:t,source:n,original:r,name:i}))}}_serializeMappings(){let t=0,r=1,n=0,i=0,a=0,s=0,u="",l,f,d,m,p=this._mappings.toArray();for(let h=0,w=p.length;h0){if(!zr.compareByGeneratedPositionsInflated(f,p[h-1]))continue;l+=","}l+=Ph.encode(f.generatedColumn-t),t=f.generatedColumn,f.source!=null&&(m=this._sources.indexOf(f.source),l+=Ph.encode(m-s),s=m,l+=Ph.encode(f.originalLine-1-i),i=f.originalLine-1,l+=Ph.encode(f.originalColumn-n),n=f.originalColumn,f.name!=null&&(d=this._names.indexOf(f.name),l+=Ph.encode(d-a),a=d)),u+=l}return u}_generateSourcesContent(t,r){return t.map(function(n){if(!this._sourcesContents)return null;r!=null&&(n=zr.relative(r,n));let i=zr.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())}};Pp.prototype._version=3;c3.SourceMapGenerator=Pp});var h3=he(f3=>{var yq=O2().SourceMapGenerator,xp=Bp(),_q=/(\r?\n)/,Cq=10,qc="$$$isSourceNode$$$",k2=class e{constructor(t,r,n,i,a){this.children=[],this.sourceContents={},this.line=t??null,this.column=r??null,this.source=n??null,this.name=a??null,this[qc]=!0,i!=null&&this.add(i)}static fromStringWithSourceMap(t,r,n){let i=new e,a=t.split(_q),s=0,u=function(){let h=v(),w=v()||"";return h+w;function v(){return s=0;r--)this.prepend(t[r]);else if(t[qc]||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{N2.SourceMapGenerator=O2().SourceMapGenerator;N2.SourceNode=h3().SourceNode});var v3=he((GX,m3)=>{"use strict";var Dq=ao(),Mt=C2(),Fq=VD(),Sq=B2(),{stringEscape:Zi,regexpClassEscape:L2}=zD(),{SourceNode:As}=d3();function g3(e,t,r){let n=t.start.line,i=t.start.column-1,a=e.split(` `);return a.length===1?new As(n,i,t.source,e,r):new As(null,null,t.source,a.map((s,u)=>new As(n+u,u===0?i:0,t.source,u===a.length-1?s:[s,` `],r)))}function p3(e,t,r,n,i){return r?new As(null,null,r.source,[e,g3(t,r,i),new As(r.end.line,r.end.column-1,r.source,n)]):new As(null,null,null,[e,t,n])}function Iq(e,t){function r(v){return v instanceof As?v:v.replace(/^(.+)$/gm," $1")}function n(v){return"peg$c"+v}function i(v){return"peg$r"+v}function a(v){return"peg$e"+v}function s(v){return"peg$f"+v}function u(v){return"peg$parse"+v}function l(){function v(D){return'"'+Zi(D)+'"'}function y(D){return"/^["+(D.inverted?"^":"")+D.value.map(C=>Array.isArray(C)?L2(C[0])+"-"+L2(C[1]):L2(C)).join("")+"]/"+(D.ignoreCase?"i":"")}function g(D){switch(D.type){case"rule":return'peg$otherExpectation("'+Zi(D.value)+'")';case"literal":return'peg$literalExpectation("'+Zi(D.value)+'", '+D.ignoreCase+")";case"class":return"peg$classExpectation(["+D.value.map(F=>Array.isArray(F)?'["'+Zi(F[0])+'", "'+Zi(F[1])+'"]':'"'+Zi(F)+'"').join(", ")+"], "+D.inverted+", "+D.ignoreCase+")";case"any":return"peg$anyExpectation()";default:throw new Error("Unknown expectation type ("+JSON.stringify(D)+")")}}function b(D,C){return p3(` var ${s(C)} = function(${D.params.join(", ")}) {`,D.body,D.location,"};")}return new As(null,null,t.grammarSource,[e.literals.map((D,C)=>" var "+n(C)+" = "+v(D)+";").concat("",e.classes.map((D,C)=>" var "+i(C)+" = "+y(D)+";")).concat("",e.expectations.map((D,C)=>" var "+a(C)+" = "+g(D)+";")).concat("").join(` `),e.functions.map(b)])}function f(v,y){let g=[];return g.push(""),t.trace&&g.push("peg$tracer.trace({",' type: "rule.enter",'," rule: "+v+","," location: peg$computeLocation(startPos, startPos)","});",""),t.cache&&(g.push("var key = peg$currPos * "+e.rules.length+" + "+y+";","var cached = peg$resultsCache[key];","","if (cached) {"," peg$currPos = cached.nextPos;",""),t.trace&&g.push("if (cached.result !== peg$FAILED) {"," peg$tracer.trace({",' type: "rule.match",'," rule: "+v+","," result: cached.result,"," location: peg$computeLocation(startPos, peg$currPos)"," });","} else {"," peg$tracer.trace({",' type: "rule.fail",'," rule: "+v+","," location: peg$computeLocation(startPos, startPos)"," });","}",""),g.push(" return cached.result;","}","")),g}function d(v,y){let g=[];return t.cache&&g.push("","peg$resultsCache[key] = { nextPos: peg$currPos, result: "+y+" };"),t.trace&&g.push("","if ("+y+" !== peg$FAILED) {"," peg$tracer.trace({",' type: "rule.match",'," rule: "+v+","," result: "+y+","," location: peg$computeLocation(startPos, peg$currPos)"," });","} else {"," peg$tracer.trace({",' type: "rule.fail",'," rule: "+v+","," location: peg$computeLocation(startPos, startPos)"," });","}"),g.push("","return "+y+";"),g}function m(v){let y=[],g=new Fq(v.name,"s","var");function b(C){let F=0,U=C.length,L=[],S;function B(j,Y){let M=Y+3,z=C[F+M-2],W=C[F+M-1],ie,Ce;g.checkedIf(F,()=>{F+=M,ie=b(C.slice(F,F+z)),F+=z},W>0?()=>{Ce=b(C.slice(F,F+W)),F+=W}:null),L.push("if ("+j+") {"),L.push(...ie.map(r)),W>0&&(L.push("} else {"),L.push(...Ce.map(r))),L.push("}")}function O(j){let M=C[F+2-1],z;g.checkedLoop(F,()=>{F+=2,z=b(C.slice(F,F+M)),F+=M}),L.push("while ("+j+") {"),L.push(...z.map(r)),L.push("}")}function x(){let Y=C[F+4-1],M=s(C[F+1])+"("+C.slice(F+4,F+4+Y).map(z=>g.index(z)).join(", ")+")";g.pop(C[F+2]),L.push(g.push(M)),F+=4+Y}for(;Fg.index(z)).join(", ")} ]`,g.pop(C[F+1]),L.push(g.push(S)),F+=M;break}case Mt.IF:B(g.top(),0);break;case Mt.IF_ERROR:B(g.top()+" === peg$FAILED",0);break;case Mt.IF_NOT_ERROR:B(g.top()+" !== peg$FAILED",0);break;case Mt.WHILE_NOT_ERROR:O(g.top()+" !== peg$FAILED");break;case Mt.MATCH_ANY:B("input.length > peg$currPos",0);break;case Mt.MATCH_STRING:B(e.literals[C[F+1]].length>1?"input.substr(peg$currPos, "+e.literals[C[F+1]].length+") === "+n(C[F+1]):"input.charCodeAt(peg$currPos) === "+e.literals[C[F+1]].charCodeAt(0),1);break;case Mt.MATCH_STRING_IC:B("input.substr(peg$currPos, "+e.literals[C[F+1]].length+").toLowerCase() === "+n(C[F+1]),1);break;case Mt.MATCH_CHAR_CLASS:B(i(C[F+1])+".test(input.charAt(peg$currPos))",1);break;case Mt.ACCEPT_N:L.push(g.push(C[F+1]>1?"input.substr(peg$currPos, "+C[F+1]+")":"input.charAt(peg$currPos)")),L.push(C[F+1]>1?"peg$currPos += "+C[F+1]+";":"peg$currPos++;"),F+=2;break;case Mt.ACCEPT_STRING:L.push(g.push(n(C[F+1]))),L.push(e.literals[C[F+1]].length>1?"peg$currPos += "+e.literals[C[F+1]].length+";":"peg$currPos++;"),F+=2;break;case Mt.FAIL:L.push(g.push("peg$FAILED")),L.push("if (peg$silentFails === 0) { peg$fail("+a(C[F+1])+"); }"),F+=2;break;case Mt.LOAD_SAVED_POS:L.push("peg$savedPos = "+g.index(C[F+1])+";"),F+=2;break;case Mt.UPDATE_SAVED_POS:L.push("peg$savedPos = peg$currPos;"),F++;break;case Mt.CALL:x();break;case Mt.RULE:L.push(g.push(u(e.rules[C[F+1]].name)+"()")),F+=2;break;case Mt.SILENT_FAILS_ON:L.push("peg$silentFails++;"),F++;break;case Mt.SILENT_FAILS_OFF:L.push("peg$silentFails--;"),F++;break;default:throw new Error("Invalid opcode: "+C[F]+".")}return L}let D=b(v.bytecode);return y.push(p3(" function ",u(v.name),v.nameLocation,`() { `,v.name)),t.trace&&y.push(" var startPos = peg$currPos;"),y.push(r(g.defines())),y.push(...f('"'+Zi(v.name)+'"',Dq.indexOfRule(e,v.name)).map(r)),y.push(...D.map(r)),y.push(...d('"'+Zi(v.name)+'"',g.result()).map(r)),y.push("}"),y}function p(v){return v.codeLocation?g3(v.code,v.codeLocation,"$"+v.type):v.code}function h(){let v=[];e.topLevelInitializer&&(v.push(p(e.topLevelInitializer)),v.push("")),v.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&&v.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(b=>b+": "+u(b)).join(", ")+" }",g=u(t.allowedStartRules[0]);return v.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 = "+g+";","",l(),""," var peg$currPos = 0;"," var peg$savedPos = 0;"," var peg$posDetailsCache = [{ line: 1, column: 1 }];"," var peg$maxFailPos = 0;"," var peg$maxFailExpected = [];"," var peg$silentFails = 0;",""),t.cache&&v.push(" var peg$resultsCache = {};",""),t.trace&&v.push(' var peg$tracer = "tracer" in options ? options.tracer : new peg$DefaultTracer();',""),v.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(b=>{v.push(...m(b).map(r)),v.push("")}),e.initializer&&(v.push(p(e.initializer)),v.push("")),v.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 As(null,null,t.grammarSource,v.map(b=>b instanceof As?b:b+` `))}function w(v){function y(){return[`// Generated by Peggy ${Sq}.`,"//","// https://peggyjs.org/"]}function g(){return t.trace?["{"," SyntaxError: peg$SyntaxError,"," DefaultTracer: peg$DefaultTracer,"," parse: peg$parse","}"].join(` `):["{"," SyntaxError: peg$SyntaxError,"," parse: peg$parse","}"].join(` `)}let D={bare(){return[...y(),"(function() {",' "use strict";',"",v,"",r("return "+g()+";"),"})()"]},commonjs(){let C=Object.keys(t.dependencies),F=y();return F.push("",'"use strict";',""),C.length>0&&(C.forEach(U=>{F.push("var "+U+' = require("'+Zi(t.dependencies[U])+'");')}),F.push("")),F.push(v,"","module.exports = "+g()+";"),F},es(){let C=Object.keys(t.dependencies),F=y();return F.push(""),C.length>0&&(C.forEach(U=>{F.push("import "+U+' from "'+Zi(t.dependencies[U])+'";')}),F.push("")),F.push(v,"","export {"," peg$SyntaxError as SyntaxError,",t.trace?" peg$DefaultTracer as DefaultTracer,":""," peg$parse as parse","};"),F},amd(){let C=Object.keys(t.dependencies),U="["+C.map(S=>t.dependencies[S]).map(S=>'"'+Zi(S)+'"').join(", ")+"]",L=C.join(", ");return[...y(),"define("+U+", function("+L+") {",' "use strict";',"",v,"",r("return "+g()+";"),"});"]},globals(){return[...y(),"(function(root) {",' "use strict";',"",v,"",r("root."+t.exportVar+" = "+g()+";"),"})(this);"]},umd(){let C=Object.keys(t.dependencies),F=C.map(O=>t.dependencies[O]),U="["+F.map(O=>'"'+Zi(O)+'"').join(", ")+"]",L=F.map(O=>'require("'+Zi(O)+'")').join(", "),S=C.join(", "),B=y();return B.push("(function(root, factory) {",' if (typeof define === "function" && define.amd) {'," define("+U+", factory);",' } else if (typeof module === "object" && module.exports) {'," module.exports = factory("+L+");"),t.exportVar!==null&&B.push(" } else {"," root."+t.exportVar+" = factory();"),B.push(" }","})(this, function("+S+") {",' "use strict";',"",v,"",r("return "+g()+";"),"});"),B}}[t.format]();return new As(null,null,t.grammarSource,D.map(C=>C instanceof As?C:C+` `))}e.code=w(h())}m3.exports=Iq});var A3=he((YX,w3)=>{"use strict";var Bq=ao(),$q=ws();function Pq(e,t,r){function n(s){return s.type==="rule"&&s.expression.type==="rule_ref"}function i(s,u,l){$q.build({rule_ref(d){d.name===u&&(d.name=l,r.info(`Proxy rule "${u}" replaced by the rule "${l}"`,d.location,[{message:"This rule will be used",location:Bq.findRule(s,l).nameLocation}]))}})(s)}let a=[];e.rules.forEach((s,u)=>{n(s)&&(i(e,s.name,s.expression.name),t.allowedStartRules.indexOf(s.name)===-1&&a.push(u))}),a.reverse(),a.forEach(s=>{e.rules.splice(s,1)})}w3.exports=Pq});var b3=he((WX,E3)=>{"use strict";var xq=ws();function Rq(e,t,r){function n(s){let u={};return Object.keys(s).forEach(l=>{u[l]=s[l]}),u}function i(s,u){a(s.expression,n(u))}let a=xq.build({rule(s){a(s.expression,{})},choice(s,u){s.alternatives.forEach(l=>{a(l,n(u))})},action:i,labeled(s,u){let l=s.label;l&&Object.prototype.hasOwnProperty.call(u,l)&&r.error(`Label "${s.label}" is already defined`,s.labelLocation,[{message:"Original label location",location:u[l]}]),a(s.expression,u),u[s.label]=s.labelLocation},text:i,simple_and:i,simple_not:i,optional:i,zero_or_more:i,one_or_more:i,group:i});a(e)}E3.exports=Rq});var _3=he((XX,y3)=>{"use strict";var Tq=ws();function Oq(e,t,r){let n={};Tq.build({rule(a){if(Object.prototype.hasOwnProperty.call(n,a.name)){r.error(`Rule "${a.name}" is already defined`,a.nameLocation,[{message:"Original rule location",location:n[a.name]}]);return}n[a.name]=a.nameLocation}})(e)}y3.exports=Oq});var F3=he((JX,D3)=>{"use strict";var C3=ao(),kq=ws();function Nq(e,t,r){let n=[],i=[],a=kq.build({rule(s){n.push(s.name),a(s.expression),n.pop()},sequence(s){s.elements.every(u=>(a(u),!C3.alwaysConsumesOnSuccess(e,u)))},rule_ref(s){i.push(s);let u=C3.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(" -> ")+")",u.nameLocation,i.map((l,f,d)=>({message:f+1!==d.length?`Step ${f+1}: call of the rule "${l.name}" without input consumption`:`Step ${f+1}: call itself without input consumption - left recursion`,location:l.location})));return}u&&a(u),i.pop()}});a(e)}D3.exports=Nq});var B3=he((ZX,I3)=>{"use strict";var S3=ao(),Lq=ws();function Uq(e,t,r){Lq.build({zero_or_more(i){S3.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){S3.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)}I3.exports=Uq});var P3=he((QX,$3)=>{"use strict";var jq=ao(),Hq=ws();function Mq(e,t,r){Hq.build({rule_ref(i){jq.findRule(e,i.name)||r.error(`Rule "${i.name}" is not defined`,i.location)}})(e)}$3.exports=Mq});var R3=he((eJ,x3)=>{"use strict";var qq=ws();function Vq(e,t,r){let n=qq.build({action(i){n(i.expression,i)},labeled(i,a){i.pick&&a&&r.error('"@" cannot be used with an action block',i.labelLocation,[{message:"Action block location",location:a.codeLocation}]),n(i.expression)}});n(e)}x3.exports=Vq});var O3=he((tJ,T3)=>{"use strict";var Kq=Dp(),U2=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(){}},j2=class{constructor(t){this._callbacks=new U2(t),this._firstError=null,this.errors=0,this.problems=[],this.stage=null}error(...t){++this.errors,this._firstError===null&&(this._firstError=new Kq(...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}};T3.exports=j2});var k3=he((exports,module)=>{"use strict";var generateBytecode=MD(),generateJS=v3(),inferenceMatchResult=D2(),removeProxyRules=A3(),reportDuplicateLabels=b3(),reportDuplicateRules=_3(),reportInfiniteRecursion=F3(),reportInfiniteRepetition=B3(),reportUndefinedRules=P3(),reportIncorrectPlucking=R3(),Session=O3(),visitor=ws();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 L3=he((rJ,N3)=>{"use strict";var zq={$:"text","&":"simple_and","!":"simple_not"},Gq={"?":"optional","*":"zero_or_more","+":"one_or_more"},Yq={"&":"semantic_and","!":"semantic_not"};function Wq(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}function lo(e,t,r,n){var i=Error.call(this,e);return Object.setPrototypeOf&&Object.setPrototypeOf(i,lo.prototype),i.expected=t,i.found=r,i.location=n,i.name="SyntaxError",i}Wq(lo,Error);function H2(e,t,r){return r=r||" ",e.length>t?e:(t-=e.length,r+=r.repeat(t),e+r.slice(0,t))}lo.prototype.format=function(e){var t="Error: "+this.message;if(this.location){var r=null,n;for(n=0;n `+a+` `+u+` | `+i.line+" | "+l+` `+u+" | "+H2("",i.column-1," ")+H2("",d,"^")}else t+=` at `+a}return t};lo.buildMessage=function(e,t){var r={literal:function(f){return'"'+i(f.text)+'"'},class:function(f){var d=f.parts.map(function(m){return Array.isArray(m)?a(m[0])+"-"+a(m[1]):a(m)});return"["+(f.inverted?"^":"")+d.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(f){return f.description}};function n(f){return f.charCodeAt(0).toString(16).toUpperCase()}function i(f){return f.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(d){return"\\x0"+n(d)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(d){return"\\x"+n(d)})}function a(f){return f.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(d){return"\\x0"+n(d)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(d){return"\\x"+n(d)})}function s(f){return r[f.type](f)}function u(f){var d=f.map(s),m,p;if(d.sort(),d.length>0){for(m=1,p=1;m0?{type:"choice",alternatives:[_].concat(H),location:wr()}:_},ts=function(_,H){return H!==null?{type:"action",expression:_,code:H[0],codeLocation:H[1],location:wr()}:_},Eo=function(_,H){return H.length>0||_.type==="labeled"&&_.pick?{type:"sequence",elements:[_].concat(H),location:wr()}:_},Op=function(_,H,J){return J.type.startsWith("semantic_")&&Yc('"@" cannot be used on a semantic predicate',_),{type:"labeled",label:H!==null?H[0]:null,labelLocation:H!==null?H[1]:_,pick:!0,expression:J,location:wr()}},kp=function(_,H){return{type:"labeled",label:_[0],labelLocation:_[1],expression:H,location:wr()}},ir=function(){return wr()},er=function(_){return Il.indexOf(_[0])>=0&&Yc(`Label can't be a reserved word "${_[0]}"`,_[1]),_},Np=function(_,H){return{type:zq[_],expression:H,location:wr()}},Lp=function(_,H){return{type:Gq[H],expression:_,location:wr()}},Up=function(_){return _.type==="labeled"||_.type==="sequence"?{type:"group",expression:_,location:wr()}:_},jp=function(_){return{type:"rule_ref",name:_[0],location:wr()}},Hp=function(_,H){return{type:Yq[_],code:H[0],codeLocation:H[1],location:wr()}},Mp=function(_,H){return[_+H.join(""),wr()]},Th=function(_,H){return{type:"literal",value:_,ignoreCase:H!==null,location:wr()}},qp=function(_){return _.join("")},jr=function(_){return _.join("")},Kc=function(_,H,J){return{type:"class",parts:H.filter(G=>G!==""),inverted:_!==null,ignoreCase:J!==null,location:wr()}},Ra=function(_,H){return _.charCodeAt(0)>H.charCodeAt(0)&&Yc("Invalid character range: "+Gc()+"."),[_,H]},Oh=function(){return""},zc=function(){return"\0"},di=function(){return"\b"},kh=function(){return"\f"},Nh=function(){return` `},Lh=function(){return"\r"},Uh=function(){return" "},jh=function(){return"\v"},Hh=function(_){return String.fromCharCode(parseInt(_,16))},Xn=function(_){return String.fromCharCode(parseInt(_,16))},Vp=function(){return{type:"any",location:wr()}},pi=function(_){return[_,wr()]},P=0,at=0,Ti=[{line:1,column:1}],Jn=0,bo=[],te=0,Oi;if("startRule"in t){if(!(t.startRule in i))throw new Error(`Can't start parsing from rule "`+t.startRule+'".');a=i[t.startRule]}function Gc(){return e.substring(at,P)}function rw(){return at}function Mh(){return{source:n,start:at,end:P}}function wr(){return Ta(at,P)}function nw(_,H){throw H=H!==void 0?H:Ta(at,P),Vh([rs(_)],e.substring(at,P),H)}function Yc(_,H){throw H=H!==void 0?H:Ta(at,P),qh(_,H)}function ze(_,H){return{type:"literal",text:_,ignoreCase:H}}function Hr(_,H,J){return{type:"class",parts:_,inverted:H,ignoreCase:J}}function xu(){return{type:"any"}}function Kp(){return{type:"end"}}function rs(_){return{type:"other",description:_}}function Wc(_){var H=Ti[_],J;if(H)return H;for(J=_-1;!Ti[J];)J--;for(H=Ti[J],H={line:H.line,column:H.column};J<_;)e.charCodeAt(J)===10?(H.line++,H.column=1):H.column++,J++;return Ti[_]=H,H}function Ta(_,H){var J=Wc(_),G=Wc(H);return{source:n,start:{offset:_,line:J.line,column:J.column},end:{offset:H,line:G.line,column:G.column}}}function me(_){PJn&&(Jn=P,bo=[]),bo.push(_))}function qh(_,H){return new lo(_,null,null,H)}function Vh(_,H,J){return new lo(lo.buildMessage(_,H),_,H,J)}function ml(){var _,H,J,G,ae,le,Qt,Br;if(_=P,H=Ut(),J=P,G=Xc(),G!==r?(ae=Ut(),J=G):(P=J,J=r),J===r&&(J=null),G=P,ae=zp(),ae!==r?(le=Ut(),G=ae):(P=G,G=r),G===r&&(G=null),ae=[],le=P,Qt=Jc(),Qt!==r?(Br=Ut(),le=Qt):(P=le,le=r),le!==r)for(;le!==r;)ae.push(le),le=P,Qt=Jc(),Qt!==r?(Br=Ut(),le=Qt):(P=le,le=r);else ae=r;return ae!==r?(at=_,_=Ri(J,G,ae)):(P=_,_=r),_}function Xc(){var _,H,J,G,ae;return _=P,e.charCodeAt(P)===123?(H=s,P++):(H=r,te===0&&me(tn)),H!==r?(J=Pt(),J!==r?(e.charCodeAt(P)===125?(G=u,P++):(G=r,te===0&&me(Es)),G!==r?(ae=La(),ae!==r?(at=_,_=$u(J)):(P=_,_=r)):(P=_,_=r)):(P=_,_=r)):(P=_,_=r),_}function zp(){var _,H,J;return _=P,H=Pt(),H!==r?(J=La(),J!==r?(at=_,_=Wn(H)):(P=_,_=r)):(P=_,_=r),_}function Jc(){var _,H,J,G,ae,le,Qt,Br;return _=P,H=Al(),H!==r?(J=Ut(),G=P,ae=ns(),ae!==r?(le=Ut(),G=ae):(P=G,G=r),G===r&&(G=null),e.charCodeAt(P)===61?(ae=l,P++):(ae=r,te===0&&me(Du)),ae!==r?(le=Ut(),Qt=xn(),Qt!==r?(Br=La(),Br!==r?(at=_,_=En(H,G,Qt)):(P=_,_=r)):(P=_,_=r)):(P=_,_=r)):(P=_,_=r),_}function xn(){var _,H,J,G,ae,le,Qt,Br;if(_=P,H=yo(),H!==r){for(J=[],G=P,ae=Ut(),e.charCodeAt(P)===47?(le=f,P++):(le=r,te===0&&me(Hs)),le!==r?(Qt=Ut(),Br=yo(),Br!==r?G=Br:(P=G,G=r)):(P=G,G=r);G!==r;)J.push(G),G=P,ae=Ut(),e.charCodeAt(P)===47?(le=f,P++):(le=r,te===0&&me(Hs)),le!==r?(Qt=Ut(),Br=yo(),Br!==r?G=Br:(P=G,G=r)):(P=G,G=r);at=_,_=Pu(H,J)}else P=_,_=r;return _}function yo(){var _,H,J,G,ae;return _=P,H=_o(),H!==r?(J=P,G=Ut(),ae=Pt(),ae!==r?J=ae:(P=J,J=r),J===r&&(J=null),at=_,_=ts(H,J)):(P=_,_=r),_}function _o(){var _,H,J,G,ae,le;if(_=P,H=vl(),H!==r){for(J=[],G=P,ae=Ut(),le=vl(),le!==r?G=le:(P=G,G=r);G!==r;)J.push(G),G=P,ae=Ut(),le=vl(),le!==r?G=le:(P=G,G=r);at=_,_=Eo(H,J)}else P=_,_=r;return _}function vl(){var _,H,J,G;return _=P,H=Kh(),H!==r?(J=zh(),J===r&&(J=null),G=Zc(),G!==r?(at=_,_=Op(H,J,G)):(P=_,_=r)):(P=_,_=r),_===r&&(_=P,H=zh(),H!==r?(J=Ut(),G=Zc(),G!==r?(at=_,_=kp(H,G)):(P=_,_=r)):(P=_,_=r),_===r&&(_=Zc())),_}function Kh(){var _,H;return _=P,e.charCodeAt(P)===64?(H=d,P++):(H=r,te===0&&me(Fu)),H!==r&&(at=_,H=ir()),_=H,_}function zh(){var _,H,J,G;return _=P,H=Al(),H!==r?(J=Ut(),e.charCodeAt(P)===58?(G=m,P++):(G=r,te===0&&me(Ms)),G!==r?(at=_,_=er(H)):(P=_,_=r)):(P=_,_=r),_}function Zc(){var _,H,J,G;return _=P,H=Gp(),H!==r?(J=Ut(),G=Gh(),G!==r?(at=_,_=Np(H,G)):(P=_,_=r)):(P=_,_=r),_===r&&(_=Gh()),_}function Gp(){var _;return e.charCodeAt(P)===36?(_=p,P++):(_=r,te===0&&me(bs)),_===r&&(e.charCodeAt(P)===38?(_=h,P++):(_=r,te===0&&me(Nt)),_===r&&(e.charCodeAt(P)===33?(_=w,P++):(_=r,te===0&&me(li)))),_}function Gh(){var _,H,J,G;return _=P,H=Oa(),H!==r?(J=Ut(),G=Yp(),G!==r?(at=_,_=Lp(H,G)):(P=_,_=r)):(P=_,_=r),_===r&&(_=Oa()),_}function Yp(){var _;return e.charCodeAt(P)===63?(_=v,P++):(_=r,te===0&&me(Su)),_===r&&(e.charCodeAt(P)===42?(_=y,P++):(_=r,te===0&&me(Iu)),_===r&&(e.charCodeAt(P)===43?(_=g,P++):(_=r,te===0&&me(Bu)))),_}function Oa(){var _,H,J,G,ae,le;return _=e1(),_===r&&(_=oe(),_===r&&(_=yl(),_===r&&(_=Wp(),_===r&&(_=Xp(),_===r&&(_=P,e.charCodeAt(P)===40?(H=b,P++):(H=r,te===0&&me(qs)),H!==r?(J=Ut(),G=xn(),G!==r?(ae=Ut(),e.charCodeAt(P)===41?(le=D,P++):(le=r,te===0&&me(co)),le!==r?(at=_,_=Up(G)):(P=_,_=r)):(P=_,_=r)):(P=_,_=r)))))),_}function Wp(){var _,H,J,G,ae,le,Qt,Br;return _=P,H=Al(),H!==r?(J=P,te++,G=P,ae=Ut(),le=P,Qt=ns(),Qt!==r?(Br=Ut(),Qt=[Qt,Br],le=Qt):(P=le,le=r),le===r&&(le=null),e.charCodeAt(P)===61?(Qt=l,P++):(Qt=r,te===0&&me(Du)),Qt!==r?(ae=[ae,le,Qt],G=ae):(P=G,G=r),te--,G===r?J=void 0:(P=J,J=r),J!==r?(at=_,_=jp(H)):(P=_,_=r)):(P=_,_=r),_}function Xp(){var _,H,J,G;return _=P,H=Qc(),H!==r?(J=Ut(),G=Pt(),G!==r?(at=_,_=Hp(H,G)):(P=_,_=r)):(P=_,_=r),_}function Qc(){var _;return e.charCodeAt(P)===38?(_=h,P++):(_=r,te===0&&me(Nt)),_===r&&(e.charCodeAt(P)===33?(_=w,P++):(_=r,te===0&&me(li))),_}function bn(){var _;return e.length>P?(_=e.charAt(P),P++):(_=r,te===0&&me(Vs)),_}function ki(){var _,H;return te++,e.charCodeAt(P)===9?(_=C,P++):(_=r,te===0&&me(xa)),_===r&&(e.charCodeAt(P)===11?(_=F,P++):(_=r,te===0&&me(re)),_===r&&(e.charCodeAt(P)===12?(_=U,P++):(_=r,te===0&&me(ce)),_===r&&(e.charCodeAt(P)===32?(_=L,P++):(_=r,te===0&&me(ke)),_===r&&(e.charCodeAt(P)===160?(_=S,P++):(_=r,te===0&&me(Te)),_===r&&(e.charCodeAt(P)===65279?(_=B,P++):(_=r,te===0&&me(Me)),_===r&&(_=e0())))))),te--,_===r&&(H=r,te===0&&me(fo)),_}function Ni(){var _;return vt.test(e.charAt(P))?(_=e.charAt(P),P++):(_=r,te===0&&me(st)),_}function wl(){var _,H;return te++,e.charCodeAt(P)===10?(_=O,P++):(_=r,te===0&&me(Tr)),_===r&&(e.substr(P,2)===x?(_=x,P+=2):(_=r,te===0&&me(qt)),_===r&&(e.charCodeAt(P)===13?(_=j,P++):(_=r,te===0&&me(ci)),_===r&&(e.charCodeAt(P)===8232?(_=Y,P++):(_=r,te===0&&me(es)),_===r&&(e.charCodeAt(P)===8233?(_=M,P++):(_=r,te===0&&me(mn)))))),te--,_===r&&(H=r,te===0&&me(ft)),_}function Yh(){var _,H;return te++,_=Jp(),_===r&&(_=gi()),te--,_===r&&(H=r,te===0&&me(Pn)),_}function Jp(){var _,H,J,G,ae,le;if(_=P,e.substr(P,2)===z?(H=z,P+=2):(H=r,te===0&&me(Fr)),H!==r){for(J=[],G=P,ae=P,te++,e.substr(P,2)===W?(le=W,P+=2):(le=r,te===0&&me(vn)),te--,le===r?ae=void 0:(P=ae,ae=r),ae!==r?(le=bn(),le!==r?(ae=[ae,le],G=ae):(P=G,G=r)):(P=G,G=r);G!==r;)J.push(G),G=P,ae=P,te++,e.substr(P,2)===W?(le=W,P+=2):(le=r,te===0&&me(vn)),te--,le===r?ae=void 0:(P=ae,ae=r),ae!==r?(le=bn(),le!==r?(ae=[ae,le],G=ae):(P=G,G=r)):(P=G,G=r);e.substr(P,2)===W?(G=W,P+=2):(G=r,te===0&&me(vn)),G!==r?(H=[H,J,G],_=H):(P=_,_=r)}else P=_,_=r;return _}function ka(){var _,H,J,G,ae,le;if(_=P,e.substr(P,2)===z?(H=z,P+=2):(H=r,te===0&&me(Fr)),H!==r){for(J=[],G=P,ae=P,te++,e.substr(P,2)===W?(le=W,P+=2):(le=r,te===0&&me(vn)),le===r&&(le=Ni()),te--,le===r?ae=void 0:(P=ae,ae=r),ae!==r?(le=bn(),le!==r?(ae=[ae,le],G=ae):(P=G,G=r)):(P=G,G=r);G!==r;)J.push(G),G=P,ae=P,te++,e.substr(P,2)===W?(le=W,P+=2):(le=r,te===0&&me(vn)),le===r&&(le=Ni()),te--,le===r?ae=void 0:(P=ae,ae=r),ae!==r?(le=bn(),le!==r?(ae=[ae,le],G=ae):(P=G,G=r)):(P=G,G=r);e.substr(P,2)===W?(G=W,P+=2):(G=r,te===0&&me(vn)),G!==r?(H=[H,J,G],_=H):(P=_,_=r)}else P=_,_=r;return _}function gi(){var _,H,J,G,ae,le;if(_=P,e.substr(P,2)===ie?(H=ie,P+=2):(H=r,te===0&&me(Gr)),H!==r){for(J=[],G=P,ae=P,te++,le=Ni(),te--,le===r?ae=void 0:(P=ae,ae=r),ae!==r?(le=bn(),le!==r?(ae=[ae,le],G=ae):(P=G,G=r)):(P=G,G=r);G!==r;)J.push(G),G=P,ae=P,te++,le=Ni(),te--,le===r?ae=void 0:(P=ae,ae=r),ae!==r?(le=bn(),le!==r?(ae=[ae,le],G=ae):(P=G,G=r)):(P=G,G=r);H=[H,J],_=H}else P=_,_=r;return _}function Al(){var _,H,J,G;if(te++,_=P,H=Wh(),H!==r){for(J=[],G=Xh();G!==r;)J.push(G),G=Xh();at=_,_=Mp(H,J)}else P=_,_=r;return te--,_===r&&(H=r,te===0&&me(ho)),_}function Wh(){var _,H,J;return _=Zp(),_===r&&(e.charCodeAt(P)===36?(_=p,P++):(_=r,te===0&&me(bs)),_===r&&(e.charCodeAt(P)===95?(_=Ce,P++):(_=r,te===0&&me(Ks)),_===r&&(_=P,e.charCodeAt(P)===92?(H=Fe,P++):(H=r,te===0&&me(Kn)),H!==r?(J=Jh(),J!==r?_=J:(P=_,_=r)):(P=_,_=r)))),_}function Xh(){var _;return _=Wh(),_===r&&(_=Qp(),_===r&&(_=Zh(),_===r&&(_=Qh(),_===r&&(e.charCodeAt(P)===8204?(_=xe,P++):(_=r,te===0&&me(Ot)),_===r&&(e.charCodeAt(P)===8205?(_=rt,P++):(_=r,te===0&&me(Sr))))))),_}function Zp(){var _;return _=Dl(),_===r&&(_=Cl(),_===r&&(_=s1(),_===r&&(_=n1(),_===r&&(_=i1(),_===r&&(_=Sl()))))),_}function Qp(){var _;return _=Fl(),_===r&&(_=Gs()),_}function e1(){var _,H,J;return te++,_=P,H=ns(),H!==r?(e.charCodeAt(P)===105?(J=tt,P++):(J=r,te===0&&me(fr)),J===r&&(J=null),at=_,_=Th(H,J)):(P=_,_=r),te--,_===r&&(H=r,te===0&&me(Ze)),_}function ns(){var _,H,J,G;if(te++,_=P,e.charCodeAt(P)===34?(H=lt,P++):(H=r,te===0&&me(hr)),H!==r){for(J=[],G=ne();G!==r;)J.push(G),G=ne();e.charCodeAt(P)===34?(G=lt,P++):(G=r,te===0&&me(hr)),G!==r?(at=_,_=qp(J)):(P=_,_=r)}else P=_,_=r;if(_===r)if(_=P,e.charCodeAt(P)===39?(H=ct,P++):(H=r,te===0&&me(Vt)),H!==r){for(J=[],G=fe();G!==r;)J.push(G),G=fe();e.charCodeAt(P)===39?(G=ct,P++):(G=r,te===0&&me(Vt)),G!==r?(at=_,_=jr(J)):(P=_,_=r)}else P=_,_=r;return te--,_===r&&(H=r,te===0&&me(rn)),_}function ne(){var _,H,J,G;return _=P,H=P,J=P,te++,e.charCodeAt(P)===34?(G=lt,P++):(G=r,te===0&&me(hr)),G===r&&(e.charCodeAt(P)===92?(G=Fe,P++):(G=r,te===0&&me(Kn)),G===r&&(G=Ni())),te--,G===r?J=void 0:(P=J,J=r),J!==r?(G=bn(),G!==r?(J=[J,G],H=J):(P=H,H=r)):(P=H,H=r),H!==r?_=e.substring(_,P):_=H,_===r&&(_=P,e.charCodeAt(P)===92?(H=Fe,P++):(H=r,te===0&&me(Kn)),H!==r?(J=Ar(),J!==r?_=J:(P=_,_=r)):(P=_,_=r),_===r&&(_=Ft())),_}function fe(){var _,H,J,G;return _=P,H=P,J=P,te++,e.charCodeAt(P)===39?(G=ct,P++):(G=r,te===0&&me(Vt)),G===r&&(e.charCodeAt(P)===92?(G=Fe,P++):(G=r,te===0&&me(Kn)),G===r&&(G=Ni())),te--,G===r?J=void 0:(P=J,J=r),J!==r?(G=bn(),G!==r?(J=[J,G],H=J):(P=H,H=r)):(P=H,H=r),H!==r?_=e.substring(_,P):_=H,_===r&&(_=P,e.charCodeAt(P)===92?(H=Fe,P++):(H=r,te===0&&me(Kn)),H!==r?(J=Ar(),J!==r?_=J:(P=_,_=r)):(P=_,_=r),_===r&&(_=Ft())),_}function oe(){var _,H,J,G,ae,le;if(te++,_=P,e.charCodeAt(P)===91?(H=fn,P++):(H=r,te===0&&me(fi)),H!==r){for(e.charCodeAt(P)===94?(J=ur,P++):(J=r,te===0&&me(hi)),J===r&&(J=null),G=[],ae=Oe(),ae===r&&(ae=Qe());ae!==r;)G.push(ae),ae=Oe(),ae===r&&(ae=Qe());e.charCodeAt(P)===93?(ae=_t,P++):(ae=r,te===0&&me(Gn)),ae!==r?(e.charCodeAt(P)===105?(le=tt,P++):(le=r,te===0&&me(fr)),le===r&&(le=null),at=_,_=Kc(J,G,le)):(P=_,_=r)}else P=_,_=r;return te--,_===r&&(H=r,te===0&&me(zn)),_}function Oe(){var _,H,J,G;return _=P,H=Qe(),H!==r?(e.charCodeAt(P)===45?(J=Cr,P++):(J=r,te===0&&me(Ur)),J!==r?(G=Qe(),G!==r?(at=_,_=Ra(H,G)):(P=_,_=r)):(P=_,_=r)):(P=_,_=r),_}function Qe(){var _,H,J,G;return _=P,H=P,J=P,te++,e.charCodeAt(P)===93?(G=_t,P++):(G=r,te===0&&me(Gn)),G===r&&(e.charCodeAt(P)===92?(G=Fe,P++):(G=r,te===0&&me(Kn)),G===r&&(G=Ni())),te--,G===r?J=void 0:(P=J,J=r),J!==r?(G=bn(),G!==r?(J=[J,G],H=J):(P=H,H=r)):(P=H,H=r),H!==r?_=e.substring(_,P):_=H,_===r&&(_=P,e.charCodeAt(P)===92?(H=Fe,P++):(H=r,te===0&&me(Kn)),H!==r?(J=Ar(),J!==r?_=J:(P=_,_=r)):(P=_,_=r),_===r&&(_=Ft())),_}function Ft(){var _,H,J;return _=P,e.charCodeAt(P)===92?(H=Fe,P++):(H=r,te===0&&me(Kn)),H!==r?(J=wl(),J!==r?(at=_,_=Oh()):(P=_,_=r)):(P=_,_=r),_}function Ar(){var _,H,J,G;return _=Zt(),_===r&&(_=P,e.charCodeAt(P)===48?(H=lr,P++):(H=r,te===0&&me(gr)),H!==r?(J=P,te++,G=Na(),te--,G===r?J=void 0:(P=J,J=r),J!==r?(at=_,_=zc()):(P=_,_=r)):(P=_,_=r),_===r&&(_=bl(),_===r&&(_=Jh()))),_}function Zt(){var _;return _=El(),_===r&&(_=t1()),_}function El(){var _,H;return e.charCodeAt(P)===39?(_=ct,P++):(_=r,te===0&&me(Vt)),_===r&&(e.charCodeAt(P)===34?(_=lt,P++):(_=r,te===0&&me(hr)),_===r&&(e.charCodeAt(P)===92?(_=Fe,P++):(_=r,te===0&&me(Kn)),_===r&&(_=P,e.charCodeAt(P)===98?(H=ht,P++):(H=r,te===0&&me(Vc)),H!==r&&(at=_,H=di()),_=H,_===r&&(_=P,e.charCodeAt(P)===102?(H=Wt,P++):(H=r,te===0&&me(po)),H!==r&&(at=_,H=kh()),_=H,_===r&&(_=P,e.charCodeAt(P)===110?(H=nt,P++):(H=r,te===0&&me(nn)),H!==r&&(at=_,H=Nh()),_=H,_===r&&(_=P,e.charCodeAt(P)===114?(H=Ke,P++):(H=r,te===0&&me(go)),H!==r&&(at=_,H=Lh()),_=H,_===r&&(_=P,e.charCodeAt(P)===116?(H=cr,P++):(H=r,te===0&&me(dl)),H!==r&&(at=_,H=Uh()),_=H,_===r&&(_=P,e.charCodeAt(P)===118?(H=Ue,P++):(H=r,te===0&&me(pl)),H!==r&&(at=_,H=jh()),_=H)))))))),_}function t1(){var _,H,J,G;return _=P,H=P,J=P,te++,G=mi(),G===r&&(G=Ni()),te--,G===r?J=void 0:(P=J,J=r),J!==r?(G=bn(),G!==r?(J=[J,G],H=J):(P=H,H=r)):(P=H,H=r),H!==r?_=e.substring(_,P):_=H,_}function mi(){var _;return _=El(),_===r&&(_=Na(),_===r&&(e.charCodeAt(P)===120?(_=kt,P++):(_=r,te===0&&me(mo)),_===r&&(e.charCodeAt(P)===117?(_=hn,P++):(_=r,te===0&&me(zs))))),_}function bl(){var _,H,J,G,ae,le;return _=P,e.charCodeAt(P)===120?(H=kt,P++):(H=r,te===0&&me(mo)),H!==r?(J=P,G=P,ae=ys(),ae!==r?(le=ys(),le!==r?(ae=[ae,le],G=ae):(P=G,G=r)):(P=G,G=r),G!==r?J=e.substring(J,P):J=G,J!==r?(at=_,_=Hh(J)):(P=_,_=r)):(P=_,_=r),_}function Jh(){var _,H,J,G,ae,le,Qt,Br;return _=P,e.charCodeAt(P)===117?(H=hn,P++):(H=r,te===0&&me(zs)),H!==r?(J=P,G=P,ae=ys(),ae!==r?(le=ys(),le!==r?(Qt=ys(),Qt!==r?(Br=ys(),Br!==r?(ae=[ae,le,Qt,Br],G=ae):(P=G,G=r)):(P=G,G=r)):(P=G,G=r)):(P=G,G=r),G!==r?J=e.substring(J,P):J=G,J!==r?(at=_,_=Xn(J)):(P=_,_=r)):(P=_,_=r),_}function Na(){var _;return Lr.test(e.charAt(P))?(_=e.charAt(P),P++):(_=r,te===0&&me(vo)),_}function ys(){var _;return xi.test(e.charAt(P))?(_=e.charAt(P),P++):(_=r,te===0&&me(gl)),_}function yl(){var _,H;return _=P,e.charCodeAt(P)===46?(H=nr,P++):(H=r,te===0&&me(wo)),H!==r&&(at=_,H=Vp()),_=H,_}function Pt(){var _,H,J,G;return te++,_=P,e.charCodeAt(P)===123?(H=s,P++):(H=r,te===0&&me(tn)),H!==r?(J=r1(),e.charCodeAt(P)===125?(G=u,P++):(G=r,te===0&&me(Es)),G!==r?_=J:(P=_,_=r)):(P=_,_=r),te--,_===r&&(H=r,te===0&&me(Ao)),_}function r1(){var _,H;return _=P,H=_l(),at=_,H=pi(H),_=H,_}function _l(){var _,H,J,G,ae,le;if(_=P,H=[],J=[],G=P,ae=P,te++,dn.test(e.charAt(P))?(le=e.charAt(P),P++):(le=r,te===0&&me(Yn)),te--,le===r?ae=void 0:(P=ae,ae=r),ae!==r?(le=bn(),le!==r?(ae=[ae,le],G=ae):(P=G,G=r)):(P=G,G=r),G!==r)for(;G!==r;)J.push(G),G=P,ae=P,te++,dn.test(e.charAt(P))?(le=e.charAt(P),P++):(le=r,te===0&&me(Yn)),te--,le===r?ae=void 0:(P=ae,ae=r),ae!==r?(le=bn(),le!==r?(ae=[ae,le],G=ae):(P=G,G=r)):(P=G,G=r);else J=r;for(J===r&&(J=P,e.charCodeAt(P)===123?(G=s,P++):(G=r,te===0&&me(tn)),G!==r?(ae=_l(),e.charCodeAt(P)===125?(le=u,P++):(le=r,te===0&&me(Es)),le!==r?(G=[G,ae,le],J=G):(P=J,J=r)):(P=J,J=r));J!==r;){if(H.push(J),J=[],G=P,ae=P,te++,dn.test(e.charAt(P))?(le=e.charAt(P),P++):(le=r,te===0&&me(Yn)),te--,le===r?ae=void 0:(P=ae,ae=r),ae!==r?(le=bn(),le!==r?(ae=[ae,le],G=ae):(P=G,G=r)):(P=G,G=r),G!==r)for(;G!==r;)J.push(G),G=P,ae=P,te++,dn.test(e.charAt(P))?(le=e.charAt(P),P++):(le=r,te===0&&me(Yn)),te--,le===r?ae=void 0:(P=ae,ae=r),ae!==r?(le=bn(),le!==r?(ae=[ae,le],G=ae):(P=G,G=r)):(P=G,G=r);else J=r;J===r&&(J=P,e.charCodeAt(P)===123?(G=s,P++):(G=r,te===0&&me(tn)),G!==r?(ae=_l(),e.charCodeAt(P)===125?(le=u,P++):(le=r,te===0&&me(Es)),le!==r?(G=[G,ae,le],J=G):(P=J,J=r)):(P=J,J=r))}return _=e.substring(_,P),_}function Cl(){var _;return Dt.test(e.charAt(P))?(_=e.charAt(P),P++):(_=r,te===0&&me(R)),_}function n1(){var _;return Ne.test(e.charAt(P))?(_=e.charAt(P),P++):(_=r,te===0&&me(N)),_}function i1(){var _;return De.test(e.charAt(P))?(_=e.charAt(P),P++):(_=r,te===0&&me(K)),_}function s1(){var _;return Dr.test(e.charAt(P))?(_=e.charAt(P),P++):(_=r,te===0&&me(Q)),_}function Dl(){var _;return pn.test(e.charAt(P))?(_=e.charAt(P),P++):(_=r,te===0&&me(ve)),_}function Gs(){var _;return it.test(e.charAt(P))?(_=e.charAt(P),P++):(_=r,te===0&&me(Ee)),_}function Fl(){var _;return Pa.test(e.charAt(P))?(_=e.charAt(P),P++):(_=r,te===0&&me(Ie)),_}function Zh(){var _;return gn.test(e.charAt(P))?(_=e.charAt(P),P++):(_=r,te===0&&me(Re)),_}function Sl(){var _;return ge.test(e.charAt(P))?(_=e.charAt(P),P++):(_=r,te===0&&me(Jt)),_}function Qh(){var _;return js.test(e.charAt(P))?(_=e.charAt(P),P++):(_=r,te===0&&me(Ir)),_}function e0(){var _;return $t.test(e.charAt(P))?(_=e.charAt(P),P++):(_=r,te===0&&me(wn)),_}function Ut(){var _,H;for(_=[],H=ki(),H===r&&(H=wl(),H===r&&(H=Yh()));H!==r;)_.push(H),H=ki(),H===r&&(H=wl(),H===r&&(H=Yh()));return _}function t0(){var _,H;for(_=[],H=ki(),H===r&&(H=ka());H!==r;)_.push(H),H=ki(),H===r&&(H=ka());return _}function La(){var _,H,J,G;return _=P,H=Ut(),e.charCodeAt(P)===59?(J=Xt,P++):(J=r,te===0&&me(An)),J!==r?(H=[H,J],_=H):(P=_,_=r),_===r&&(_=P,H=t0(),J=gi(),J===r&&(J=null),G=wl(),G!==r?(H=[H,J,G],_=H):(P=_,_=r),_===r&&(_=P,H=Ut(),J=Ua(),J!==r?(H=[H,J],_=H):(P=_,_=r))),_}function Ua(){var _,H;return _=P,te++,e.length>P?(H=e.charAt(P),P++):(H=r,te===0&&me(Vs)),te--,H===r?_=void 0:(P=_,_=r),_}let Il=t.reservedWords||[];if(Oi=a(),Oi!==r&&P===e.length)return Oi;throw Oi!==r&&P{"use strict";var Jq=Dp(),Zq=k3(),Qq=L3(),eV=B2(),tV=["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"],xh={VERSION:eV,RESERVED_WORDS:tV,GrammarError:Jq,parser:Qq,compiler:Zq,generate(e,t){t=t!==void 0?t:{};function r(a){let s={};return Object.keys(a).forEach(u=>{s[u]=a[u].slice()}),s}let n="plugins"in t?t.plugins:[],i={parser:xh.parser,passes:r(xh.compiler.passes),reservedWords:xh.RESERVED_WORDS.slice()};return n.forEach(a=>{a.use(i,t)}),xh.compiler.compile(i.parser.parse(e,{grammarSource:t.grammarSource,reservedWords:i.reservedWords}),i.passes,t)}};U3.exports=xh});var W2=he((G2,Y2)=>{(function(e,t){typeof G2=="object"&&typeof Y2<"u"?Y2.exports=t():typeof define=="function"&&define.amd?define(t):e.JSON5=t()})(G2,function(){"use strict";function e(re,ce){return ce={exports:{}},re(ce,ce.exports),ce.exports}var t=e(function(re){var ce=re.exports=typeof window<"u"&&window.Math==Math?window:typeof self<"u"&&self.Math==Math?self:Function("return this")();typeof __g=="number"&&(__g=ce)}),r=e(function(re){var ce=re.exports={version:"2.6.5"};typeof __e=="number"&&(__e=ce)}),n=r.version,i=function(re){return typeof re=="object"?re!==null:typeof re=="function"},a=function(re){if(!i(re))throw TypeError(re+" is not an object!");return re},s=function(re){try{return!!re()}catch{return!0}},u=!s(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7}),l=t.document,f=i(l)&&i(l.createElement),d=function(re){return f?l.createElement(re):{}},m=!u&&!s(function(){return Object.defineProperty(d("div"),"a",{get:function(){return 7}}).a!=7}),p=function(re,ce){if(!i(re))return re;var ke,Te;if(ce&&typeof(ke=re.toString)=="function"&&!i(Te=ke.call(re))||typeof(ke=re.valueOf)=="function"&&!i(Te=ke.call(re))||!ce&&typeof(ke=re.toString)=="function"&&!i(Te=ke.call(re)))return Te;throw TypeError("Can't convert object to primitive value")},h=Object.defineProperty,w=u?Object.defineProperty:function(ce,ke,Te){if(a(ce),ke=p(ke,!0),a(Te),m)try{return h(ce,ke,Te)}catch{}if("get"in Te||"set"in Te)throw TypeError("Accessors not supported!");return"value"in Te&&(ce[ke]=Te.value),ce},v={f:w},y=function(re,ce){return{enumerable:!(re&1),configurable:!(re&2),writable:!(re&4),value:ce}},g=u?function(re,ce,ke){return v.f(re,ce,y(1,ke))}:function(re,ce,ke){return re[ce]=ke,re},b={}.hasOwnProperty,D=function(re,ce){return b.call(re,ce)},C=0,F=Math.random(),U=function(re){return"Symbol(".concat(re===void 0?"":re,")_",(++C+F).toString(36))},L=!1,S=e(function(re){var ce="__core-js_shared__",ke=t[ce]||(t[ce]={});(re.exports=function(Te,Me){return ke[Te]||(ke[Te]=Me!==void 0?Me:{})})("versions",[]).push({version:r.version,mode:L?"pure":"global",copyright:"\xA9 2019 Denis Pushkarev (zloirock.ru)"})}),B=S("native-function-to-string",Function.toString),O=e(function(re){var ce=U("src"),ke="toString",Te=(""+B).split(ke);r.inspectSource=function(Me){return B.call(Me)},(re.exports=function(Me,st,ft,Tr){var qt=typeof ft=="function";qt&&(D(ft,"name")||g(ft,"name",st)),Me[st]!==ft&&(qt&&(D(ft,ce)||g(ft,ce,Me[st]?""+Me[st]:Te.join(String(st)))),Me===t?Me[st]=ft:Tr?Me[st]?Me[st]=ft:g(Me,st,ft):(delete Me[st],g(Me,st,ft)))})(Function.prototype,ke,function(){return typeof this=="function"&&this[ce]||B.call(this)})}),x=function(re){if(typeof re!="function")throw TypeError(re+" is not a function!");return re},j=function(re,ce,ke){if(x(re),ce===void 0)return re;switch(ke){case 1:return function(Te){return re.call(ce,Te)};case 2:return function(Te,Me){return re.call(ce,Te,Me)};case 3:return function(Te,Me,st){return re.call(ce,Te,Me,st)}}return function(){return re.apply(ce,arguments)}},Y="prototype",M=function(re,ce,ke){var Te=re&M.F,Me=re&M.G,st=re&M.S,ft=re&M.P,Tr=re&M.B,qt=Me?t:st?t[ce]||(t[ce]={}):(t[ce]||{})[Y],ci=Me?r:r[ce]||(r[ce]={}),es=ci[Y]||(ci[Y]={}),mn,Pn,Fr,vn;Me&&(ke=ce);for(mn in ke)Pn=!Te&&qt&&qt[mn]!==void 0,Fr=(Pn?qt:ke)[mn],vn=Tr&&Pn?j(Fr,t):ft&&typeof Fr=="function"?j(Function.call,Fr):Fr,qt&&O(qt,mn,Fr,re&M.U),ci[mn]!=Fr&&g(ci,mn,vn),ft&&es[mn]!=Fr&&(es[mn]=Fr)};t.core=r,M.F=1,M.G=2,M.S=4,M.P=8,M.B=16,M.W=32,M.U=64,M.R=128;var z=M,W=Math.ceil,ie=Math.floor,Ce=function(re){return isNaN(re=+re)?0:(re>0?ie:W)(re)},Fe=function(re){if(re==null)throw TypeError("Can't call method on "+re);return re},xe=function(re){return function(ce,ke){var Te=String(Fe(ce)),Me=Ce(ke),st=Te.length,ft,Tr;return Me<0||Me>=st?re?"":void 0:(ft=Te.charCodeAt(Me),ft<55296||ft>56319||Me+1===st||(Tr=Te.charCodeAt(Me+1))<56320||Tr>57343?re?Te.charAt(Me):ft:re?Te.slice(Me,Me+2):(ft-55296<<10)+(Tr-56320)+65536)}},rt=xe(!1);z(z.P,"String",{codePointAt:function(ce){return rt(this,ce)}});var tt=r.String.codePointAt,lt=Math.max,ct=Math.min,fn=function(re,ce){return re=Ce(re),re<0?lt(re+ce,0):ct(re,ce)},ur=String.fromCharCode,_t=String.fromCodePoint;z(z.S+z.F*(!!_t&&_t.length!=1),"String",{fromCodePoint:function(ce){for(var ke=arguments,Te=[],Me=arguments.length,st=0,ft;Me>st;){if(ft=+ke[st++],fn(ft,1114111)!==ft)throw RangeError(ft+" is not a valid code point");Te.push(ft<65536?ur(ft):ur(((ft-=65536)>>10)+55296,ft%1024+56320))}return Te.join("")}});var Cr=r.String.fromCodePoint,lr=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,ht=/[\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]/,Wt=/[\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]/,nt={Space_Separator:lr,ID_Start:ht,ID_Continue:Wt},Ke={isSpaceSeparator:function(ce){return typeof ce=="string"&&nt.Space_Separator.test(ce)},isIdStartChar:function(ce){return typeof ce=="string"&&(ce>="a"&&ce<="z"||ce>="A"&&ce<="Z"||ce==="$"||ce==="_"||nt.ID_Start.test(ce))},isIdContinueChar:function(ce){return typeof ce=="string"&&(ce>="a"&&ce<="z"||ce>="A"&&ce<="Z"||ce>="0"&&ce<="9"||ce==="$"||ce==="_"||ce==="\u200C"||ce==="\u200D"||nt.ID_Continue.test(ce))},isDigit:function(ce){return typeof ce=="string"&&/[0-9]/.test(ce)},isHexDigit:function(ce){return typeof ce=="string"&&/[0-9A-Fa-f]/.test(ce)}},cr,Ue,kt,hn,nr,Xt,vt,Lr,xi,dn=function(ce,ke){cr=String(ce),Ue="start",kt=[],hn=0,nr=1,Xt=0,vt=void 0,Lr=void 0,xi=void 0;do vt=Pa(),Fu[Ue]();while(vt.type!=="eof");return typeof ke=="function"?Dt({"":xi},"",ke):xi};function Dt(re,ce,ke){var Te=re[ce];if(Te!=null&&typeof Te=="object")if(Array.isArray(Te))for(var Me=0;Me0;){var ke=gn();if(!Ke.isHexDigit(ke))throw Nt(ge());re+=ge()}return String.fromCodePoint(parseInt(re,16))}var Fu={start:function(){if(vt.type==="eof")throw li();Ms()},beforePropertyName:function(){switch(vt.type){case"identifier":case"string":Lr=vt.value,Ue="afterPropertyName";return;case"punctuator":bs();return;case"eof":throw li()}},afterPropertyName:function(){if(vt.type==="eof")throw li();Ue="beforePropertyValue"},beforePropertyValue:function(){if(vt.type==="eof")throw li();Ms()},beforeArrayValue:function(){if(vt.type==="eof")throw li();if(vt.type==="punctuator"&&vt.value==="]"){bs();return}Ms()},afterPropertyValue:function(){if(vt.type==="eof")throw li();switch(vt.value){case",":Ue="beforePropertyName";return;case"}":bs()}},afterArrayValue:function(){if(vt.type==="eof")throw li();switch(vt.value){case",":Ue="beforeArrayValue";return;case"]":bs()}},end:function(){}};function Ms(){var re;switch(vt.type){case"punctuator":switch(vt.value){case"{":re={};break;case"[":re=[];break}break;case"null":case"boolean":case"numeric":case"string":re=vt.value;break}if(xi===void 0)xi=re;else{var ce=kt[kt.length-1];Array.isArray(ce)?ce.push(re):Object.defineProperty(ce,Lr,{value:re,writable:!0,enumerable:!0,configurable:!0})}if(re!==null&&typeof re=="object")kt.push(re),Array.isArray(re)?Ue="beforeArrayValue":Ue="beforePropertyName";else{var ke=kt[kt.length-1];ke==null?Ue="end":Array.isArray(ke)?Ue="afterArrayValue":Ue="afterPropertyValue"}}function bs(){kt.pop();var re=kt[kt.length-1];re==null?Ue="end":Array.isArray(re)?Ue="afterArrayValue":Ue="afterPropertyValue"}function Nt(re){return qs(re===void 0?"JSON5: invalid end of input at "+nr+":"+Xt:"JSON5: invalid character '"+Bu(re)+"' at "+nr+":"+Xt)}function li(){return qs("JSON5: invalid end of input at "+nr+":"+Xt)}function Su(){return Xt-=5,qs("JSON5: invalid identifier character at "+nr+":"+Xt)}function Iu(re){console.warn("JSON5: '"+Bu(re)+"' in strings is not valid ECMAScript; consider escaping")}function Bu(re){var ce={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};if(ce[re])return ce[re];if(re<" "){var ke=re.charCodeAt(0).toString(16);return"\\x"+("00"+ke).substring(ke.length)}return re}function qs(re){var ce=new SyntaxError(re);return ce.lineNumber=nr,ce.columnNumber=Xt,ce}var co=function(ce,ke,Te){var Me=[],st="",ft,Tr,qt="",ci;if(ke!=null&&typeof ke=="object"&&!Array.isArray(ke)&&(Te=ke.space,ci=ke.quote,ke=ke.replacer),typeof ke=="function")Tr=ke;else if(Array.isArray(ke)){ft=[];for(var es=0,mn=ke;es0&&(Te=Math.min(10,Math.floor(Te)),qt=" ".substr(0,Te)):typeof Te=="string"&&(qt=Te.substr(0,10)),vn("",{"":ce});function vn(Ot,Sr){var Ze=Sr[Ot];switch(Ze!=null&&(typeof Ze.toJSON5=="function"?Ze=Ze.toJSON5(Ot):typeof Ze.toJSON=="function"&&(Ze=Ze.toJSON(Ot))),Tr&&(Ze=Tr.call(Sr,Ot,Ze)),Ze instanceof Number?Ze=Number(Ze):Ze instanceof String?Ze=String(Ze):Ze instanceof Boolean&&(Ze=Ze.valueOf()),Ze){case null:return"null";case!0:return"true";case!1:return"false"}if(typeof Ze=="string")return Gr(Ze,!1);if(typeof Ze=="number")return String(Ze);if(typeof Ze=="object")return Array.isArray(Ze)?Kn(Ze):ho(Ze)}function Gr(Ot){for(var Sr={"'":.1,'"':.2},Ze={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"},fr="",rn=0;rn=0)throw TypeError("Converting circular structure to JSON5");Me.push(Ot);var Sr=st;st=st+qt;for(var Ze=ft||Object.keys(Ot),fr=[],rn=0,hr=Ze;rn=0)throw TypeError("Converting circular structure to JSON5");Me.push(Ot);var Sr=st;st=st+qt;for(var Ze=[],fr=0;fr{let t={};return e.forEach((r,n)=>t[r]=n),t})(gf),c9=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,Cn=String.fromCharCode.bind(String),GA=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):e=>new Uint8Array(Array.prototype.slice.call(e,0)),JA=e=>e.replace(/=/g,"").replace(/[+\/]/g,t=>t=="+"?"-":"_"),ZA=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),QA=e=>{let t,r,n,i,a="",s=e.length%3;for(let u=0;u255||(n=e.charCodeAt(u++))>255||(i=e.charCodeAt(u++))>255)throw new TypeError("invalid character found");t=r<<16|n<<8|i,a+=gf[t>>18&63]+gf[t>>12&63]+gf[t>>6&63]+gf[t&63]}return s?a.slice(0,s-3)+"===".substring(s):a},tg=typeof btoa=="function"?e=>btoa(e):Ll?e=>Buffer.from(e,"binary").toString("base64"):QA,Q1=Ll?e=>Buffer.from(e).toString("base64"):e=>{let r=[];for(let n=0,i=e.length;nt?JA(Q1(e)):Q1(e),f9=e=>{if(e.length<2){var t=e.charCodeAt(0);return t<128?e:t<2048?Cn(192|t>>>6)+Cn(128|t&63):Cn(224|t>>>12&15)+Cn(128|t>>>6&63)+Cn(128|t&63)}else{var t=65536+(e.charCodeAt(0)-55296)*1024+(e.charCodeAt(1)-56320);return Cn(240|t>>>18&7)+Cn(128|t>>>12&63)+Cn(128|t>>>6&63)+Cn(128|t&63)}},h9=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,eE=e=>e.replace(h9,f9),YA=Ll?e=>Buffer.from(e,"utf8").toString("base64"):zA?e=>Q1(zA.encode(e)):e=>tg(eE(e)),Nl=(e,t=!1)=>t?JA(YA(e)):YA(e),WA=e=>Nl(e,!0),d9=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,p9=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 Cn((r>>>10)+55296)+Cn((r&1023)+56320);case 3:return Cn((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return Cn((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},tE=e=>e.replace(d9,p9),rE=e=>{if(e=e.replace(/\s+/g,""),!c9.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(e.length&3));let t,r="",n,i;for(let a=0;a>16&255):i===64?Cn(t>>16&255,t>>8&255):Cn(t>>16&255,t>>8&255,t&255);return r},rg=typeof atob=="function"?e=>atob(ZA(e)):Ll?e=>Buffer.from(e,"base64").toString("binary"):rE,nE=Ll?e=>GA(Buffer.from(e,"base64")):e=>GA(rg(e).split("").map(t=>t.charCodeAt(0))),iE=e=>nE(sE(e)),g9=Ll?e=>Buffer.from(e,"base64").toString("utf8"):KA?e=>KA.decode(nE(e)):e=>tE(rg(e)),sE=e=>ZA(e.replace(/[-_]/g,t=>t=="-"?"+":"/")),eg=e=>g9(sE(e)),m9=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)},aE=e=>({value:e,enumerable:!1,writable:!0,configurable:!0}),uE=function(){let e=(t,r)=>Object.defineProperty(String.prototype,t,aE(r));e("fromBase64",function(){return eg(this)}),e("toBase64",function(t){return Nl(this,t)}),e("toBase64URI",function(){return Nl(this,!0)}),e("toBase64URL",function(){return Nl(this,!0)}),e("toUint8Array",function(){return iE(this)})},oE=function(){let e=(t,r)=>Object.defineProperty(Uint8Array.prototype,t,aE(r));e("toBase64",function(t){return x0(this,t)}),e("toBase64URI",function(){return x0(this,!0)}),e("toBase64URL",function(){return x0(this,!0)})},v9=()=>{uE(),oE()},pt={version:XA,VERSION:o9,atob:rg,atobPolyfill:rE,btoa:tg,btoaPolyfill:QA,fromBase64:eg,toBase64:Nl,encode:Nl,encodeURI:WA,encodeURL:WA,utob:eE,btou:tE,decode:eg,isValid:m9,fromUint8Array:x0,toUint8Array:iE,extendString:uE,extendUint8Array:oE,extendBuiltins:v9};var Lu=typeof $task<"u",Wa=typeof $loon<"u",Uu=typeof $httpClient<"u"&&!Wa,Js=eval('typeof process !== "undefined"'),lE=typeof $environment<"u"&&$environment["stash-version"],cE=typeof $rocket<"u",w9=typeof egern=="object",A9=typeof $native<"u",ju=typeof $Plugins<"u";function R0(e){return e!==null&&typeof e=="object"&&[null,Object.prototype].includes(Object.getPrototypeOf(e))}function E9(e){let[t,r,n,i,a,s,u]=e.match(/^socks5:\/\/(?:(.*?):(.*?)@)?(.*?)(?::(\d+?))?(\?.*?)?(?:#(.*?))?$/);if(a)a=parseInt(a,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:a,userId:r!=null?decodeURIComponent(r):void 0,password:n!=null?decodeURIComponent(n):void 0}}var T0=class{constructor(name="untitled",debug=!1){if(this.name=name,this.debug=debug,this.http=Xa(),this.env=an(),Js){let dotenv=eval('require("dotenv")');dotenv.config()}this.node=(()=>{if(Js){let fs=eval("require('fs')");return{fs}}else return null})(),this.initCache();let delay=(e,t)=>new Promise(function(r){setTimeout(r.bind(null,t),e)});Promise.prototype.delay=async function(e){let t=await this;return await delay(e,t)}}initCache(){if(Lu&&(this.cache=JSON.parse($prefs.valueForKey(this.name)||"{}")),(Wa||Uu)&&(this.cache=JSON.parse($persistentStore.read(this.name)||"{}")),ju&&(this.cache=JSON.parse($Plugins.SubStoreCache.get(this.name)||"{}")),Js){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}`)}R0(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")),!R0(this.cache))throw new Error("Invalid Data")}catch{try{let t=pt.decode(this.node.fs.readFileSync(`${fpath}`,"utf-8"));if(this.cache=JSON.parse(t),this.node.fs.writeFileSync(fpath,t,{flag:"w"}),!R0(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}`)}}R0(this.cache)||(this.node.fs.writeFileSync(fpath,JSON.stringify({}),{flag:"w"}),this.cache={})}}persistCache(){let data=JSON.stringify(this.cache,null,2);if(Lu&&$prefs.setValueForKey(data,this.name),(Wa||Uu)&&$persistentStore.write(data,this.name),ju&&$Plugins.SubStoreCache.set(this.name,data),Js){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),Uu||Wa)return $persistentStore.write(e,t);if(Lu)return $prefs.setValueForKey(e,t);if(Js&&(this.root[t]=e),ju)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),Uu||Wa)return $persistentStore.read(e);if(Lu)return $prefs.valueForKey(e);if(Js)return this.root[e];if(ju)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),Uu||Wa)return $persistentStore.write(null,e);if(Lu)return $prefs.removeValueForKey(e);if(Js&&delete this.root[e],ju)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(Lu&&$notify(title,subtitle,content,options),Uu&&$notification.post(title,subtitle,content+`${mediaURL?` \u591A\u5A92\u4F53:`+mediaURL:""}`,{url:openURL}),Wa){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(Js){let content_=content+(openURL?` \u70B9\u51FB\u8DF3\u8F6C: ${openURL}`:"")+(mediaURL?` \u591A\u5A92\u4F53: ${mediaURL}`:"");console.log(`${title} ${subtitle} ${content_} `);let push=eval("process.env.SUB_STORE_PUSH_SERVICE");if(push)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(` `)));Xa().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}`)})}}ju&&$Plugins.Notify(title,subtitle+` `+content)}log(e){this.debug&&console.log(`[${this.name}] LOG: ${e}`)}info(e){console.log(`[${this.name}] INFO: ${e}`)}error(e){console.log(`[${this.name}] ERROR: ${e}`)}wait(e){return new Promise(t=>setTimeout(t,e))}done(e={}){Lu||Wa||Uu||ju?$done(e):Js&&typeof $context<"u"&&($context.headers=e.headers,$context.statusCode=e.statusCode,$context.body=e.body)}};function an(){return{isQX:Lu,isLoon:Wa,isSurge:Uu,isNode:Js,isStash:lE,isShadowRocket:cE,isEgern:w9,isLanceX:A9,isGUIforCores:ju}}function Xa(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;isQX?worker=$task.fetch({method,url:options.url,headers:options.headers,body:options.body,opts:options.opts}):isLoon||isSurge||isNode?worker=new Promise(async(resolve,reject)=>{let body=options.body,opts=JSON.parse(JSON.stringify(options));if(opts.body=body,opts.timeout=opts.timeout||8e3,opts.timeout&&(opts.timeout++,isNaN(opts.timeout)&&(opts.timeout=8e3),!isNode)){let e="ms";(isSurge||lE||cE)&&(opts.timeout=Math.ceil(opts.timeout/1e3),e="s")}if(isNode){let undici=eval("require('undici')"),{socksDispatcher}=eval("require('fetch-socks')"),{ProxyAgent,EnvHttpProxyAgent,request,interceptors}=undici,agentOpts={connect:{rejectUnauthorized:!(opts.strictSSL===!1||opts.insecure===!0||opts.rejectUnauthorized===!1)},bodyTimeout:opts.timeout,headersTimeout:opts.timeout,maxHeaderSize:eval("process.env.SUB_STORE_MAX_HEADER_SIZE")||32*1024},tlsOptions={rejectUnauthorized:agentOpts.connect.rejectUnauthorized};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")}`});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(E9(opts.proxy),{...agentOpts,requestTls:tlsOptions}):dispatcher=new ProxyAgent({...agentOpts,uri:opts.proxy,requestTls:tlsOptions}):dispatcher=new EnvHttpProxyAgent({...agentOpts,requestTls:tlsOptions});let response=await request(opts.url,{...opts,method:method.toUpperCase(),dispatcher:dispatcher.compose(interceptors.redirect({maxRedirections:3,throwOnMaxRedirects:!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})})}):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;return(timer?Promise.race([timer,worker]).then(e=>(typeof clearTimeout<"u"&&clearTimeout(timeoutid),e)):worker).then(e=>events.onResponse(e))}let http={};return methods.forEach(e=>http[e.toLowerCase()]=t=>send(e,t)),http}var b9=new T0("sub-store"),k=b9;function Ul(){y9()}function y9(){let e=k.read(Z1);e||_9(),e!=="2.0"&&k.write("2.0",Z1)}function _9(){k.info("Start migrating...");let e=k.read(mr)||{},t=Object.values(e).map(w=>(w.source=w.source||"remote",p(w),h(w),w));k.write(t,mr);let r=k.read(sr)||{},n=Object.values(r).map(w=>(delete w.ua,p(w),h(w),w));k.write(n,sr);let i=k.read(zt)||{},a=Object.values(i);k.write(a,zt);let s=k.read(pf)||{},u=Object.values(s);k.write(u,pf);let l=k.read(xt)||{},f=Object.values(l);k.write(f,xt);let d=k.read(ls)||{},m=Object.values(d);k.write(m,ls),delete k.cache.builtin,k.info("Migration complete!");function p(w){let v=w["display-name"];v&&(w.displayName=v,delete w["display-name"])}function h(w){let v=w.process;if(!v||v.length===0)return;let y=[],g={type:"Quick Setting Operator",args:{udp:"DEFAULT",tfo:"DEFAULT",scert:"DEFAULT","vmess aead":"DEFAULT",useless:"DEFAULT"}};for(let b of v)if(b.type){if(b.type==="Useless Filter")g.args.useless="ENABLED";else if(b.type==="Set Property Operator"){let{key:D,value:C}=b.args;switch(D){case"udp":g.args.udp=C?"ENABLED":"DISABLED";break;case"tfo":g.args.tfo=C?"ENABLED":"DISABLED";break;case"skip-cert-verify":g.args.scert=C?"ENABLED":"DISABLED";break;case"aead":g.args["vmess aead"]=C?"ENABLED":"DISABLED";break}}else if(b.type.indexOf("Keyword")===-1)if(b.type==="Flag Operator"){let D=typeof b.args>"u"?!0:b.args;b.args={mode:D?"add":"remove"},y.push(b)}else y.push(b)}y.unshift(g),w.process=y}}function ng({substore:$,port,host}){let{isNode}=an(),DEFAULT_HEADERS={"Content-Type":"text/plain;charset=UTF-8","Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"POST,GET,OPTIONS,PATCH,PUT,DELETE","Access-Control-Allow-Headers":"Origin, X-Requested-With, Content-Type, Accept","X-Powered-By":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(bodyParser.json({verify:rawBodySaver,limit})),app.use(bodyParser.urlencoded({verify:rawBodySaver,extended:!0})),app.use(bodyParser.raw({verify:rawBodySaver,type:"*/*"})),app.use((e,t,r)=>{t.set(DEFAULT_HEADERS),r()}),app.start=()=>{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:a}=e;i=C9(i),/json/i.test(i["content-type"])&&(a=JSON.parse(a)),r=r.toUpperCase();let{path:s,query:u}=F9(n),l=null,f,d=0;for(f=t;fd&&(l=handlers[f],d=m.split("/").length)}if(l){let m=()=>{dispatch(r,n,f)},p={method:r,url:n,path:s,query:u,params:fE(l.pattern,s),headers:i,body:a},h=Response(),w=l.callback,v=y=>{h.status(500).json({status:"failed",message:`Internal Server Error: ${y}`})};if(w.constructor.name==="AsyncFunction")w(p,h,m).catch(v);else try{w(p,h,m)}catch(y){v(y)}}else Response().status(404).json({status:"failed",message:"ERROR: 404 not found"})},app={};return METHODS_NAMES.forEach(e=>{app[e.toLowerCase()]=(t,r)=>{handlers.push({method:e,pattern:t,callback:r})}}),app.route=e=>{let t={};return METHODS_NAMES.forEach(r=>{t[r.toLowerCase()]=n=>(handlers.push({method:r,pattern:e,callback:n}),t)}),t},app.start=()=>{dispatch($request)},app;function rawBodySaver(e,t,r,n){r&&r.length&&(e.rawBody=r.toString(n||"utf8"))}function Response(){let e=200,{isQX:t,isLoon:r,isSurge:n,isGUIforCores:i}=an(),a=DEFAULT_HEADERS,s={200:"HTTP/1.1 200 OK",201:"HTTP/1.1 201 Created",302:"HTTP/1.1 302 Found",307:"HTTP/1.1 307 Temporary Redirect",308:"HTTP/1.1 308 Permanent Redirect",404:"HTTP/1.1 404 Not Found",500:"HTTP/1.1 500 Internal Server Error"};return new class{status(u){return e=u,this}send(u=""){let l={status:t?s[e]:e,body:u,headers:a};t||i?$done(l):(r||n)&&$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 a[u]=l,this}}}}function C9(e){let t={};for(let r of Object.keys(e))t[r.toLowerCase()]=e[r];return t}function D9(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 hE(e,t,r="name"){return e.findIndex(n=>n[r]===t)}function Fs(e,t,r="name"){let n=hE(e,t,r);e.splice(n,1)}function Ss(e,t,r,n="name"){let i=hE(e,t,n);e[i]=r}function qe(e,t,r){e.status(r||200).json({status:"success",data:t})}function Ve(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 jl=class{constructor(t,r,n){this.code=t,this.message=r,this.details=n}},Dn=class extends jl{constructor(t,r,n){super(t,r,n),this.type="InternalServerError"}},Tt=class extends jl{constructor(t,r,n){super(t,r,n),this.type="RequestInvalidError"}},Wr=class extends jl{constructor(t,r,n){super(t,r,n),this.type="ResourceNotFoundError"}},O0=class extends jl{constructor(t,r,n){super(t,r,n),this.type="NetworkError"}};var V0=_n(DE()),Z9=/^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)(\.(?!$)|$)){4}$/,Q9=/^(([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 Mr(e){return Z9.test(e)}function Xr(e){return Q9.test(e)}function FE(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 ra(e){return typeof e=="string"&&e.trim().length>0}function ar(e,t){return ra(e)?e:t}function Vl(e){return typeof e<"u"&&e!==null}function Kl(e,t){return Vl(e)?e:t}function Za(e){return e?/^.+?\s*?=\s*?.+?\s*?,.+?/.test(e)?{"policy-descriptor":e}:{policy:e}:{}}function e7(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e}function wf(e){let t=e.split(/,|\//),r=t[Math.floor(Math.random()*t.length)];if(r.includes("-")){let[n,i]=r.split("-").map(Number);return e7(n,i)}else return Number(r)}function SE(e){return Number.isSafeInteger(e)?String(e):BigInt(e).toString()}function K0(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 Hu(e,t="YYYY-MM-DD_HH-mm-ss"){let r=e instanceof Date?e:new Date(e);if(isNaN(r.getTime()))return"";let n=a=>String(a).padStart(2,"0"),i={YYYY:r.getFullYear(),MM:n(r.getMonth()+1),DD:n(r.getDate()),HH:n(r.getHours()),mm:n(r.getMinutes()),ss:n(r.getSeconds())};return t.replace(/YYYY|MM|DD|HH|mm|ss/g,a=>i[a])}function gg(e){k.read(sr)||k.write({},sr),e.route("/api/collection/:name").get(r7).patch(n7).delete(i7),e.route("/api/collections").get(s7).post(t7).put(a7)}function t7(e,t){let r=e.body;if(k.info(`\u6B63\u5728\u521B\u5EFA\u7EC4\u5408\u8BA2\u9605\uFF1A${r.name}`),/\//.test(r.name)){Ve(t,new Tt("INVALID_NAME",`Collection ${r.name} is invalid`));return}let n=k.read(sr);if(Rt(n,r.name)){Ve(t,new Tt("DUPLICATE_KEY",`Collection ${r.name} already exists.`));return}n.push(r),k.write(n,sr),qe(t,r,201)}function r7(e,t){let{name:r}=e.params,{raw:n}=e.query,i=k.read(sr),a=Rt(i,r);a?n?t.set("content-type","application/json").set("content-disposition",`attachment; filename="${encodeURIComponent(`sub-store_collection_${r}_${Hu(new Date)}.json`)}"`).send(JSON.stringify(a)):qe(t,a):Ve(t,new Wr("SUBSCRIPTION_NOT_FOUND",`Collection ${r} does not exist`,404))}function n7(e,t){let{name:r}=e.params,n=e.body,i=k.read(sr),a=Rt(i,r);if(a){let s={...a,...n};if(k.info(`\u6B63\u5728\u66F4\u65B0\u7EC4\u5408\u8BA2\u9605\uFF1A${r}...`),r!==s.name){let u=k.read(zt)||[];for(let f of u)f.type==="collection"&&f.source===a.name&&(f.source=s.name);let l=k.read(xt)||[];for(let f of l)f.sourceType==="collection"&&f.sourceName===a.name&&(f.sourceName=s.name);k.write(u,zt),k.write(l,xt)}Ss(i,r,s),k.write(i,sr),qe(t,s)}else Ve(t,new Wr("RESOURCE_NOT_FOUND",`Collection ${r} does not exist!`),404)}function i7(e,t){let{name:r}=e.params;k.info(`\u6B63\u5728\u5220\u9664\u7EC4\u5408\u8BA2\u9605\uFF1A${r}`);let n=k.read(sr);Fs(n,r),k.write(n,sr),qe(t)}function s7(e,t){let r=k.read(sr);qe(t,r)}function a7(e,t){let r=e.body;k.write(r,sr),qe(t)}var mg=0;function Mi(e){return o7(u7(l7(e)))}function u7(e){return f7(h7(c7(e),e.length*8))}function o7(e){try{}catch{mg=0}for(var t=mg?"0123456789ABCDEF":"0123456789abcdef",r="",n,i=0;i>>4&15)+t.charAt(n&15);return r}function l7(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 c7(e){for(var t=Array(e.length>>2),r=0;r>5]|=(e.charCodeAt(r/8)&255)<>5]>>>r%32&255);return t}function h7(e,t){e[t>>5]|=128<>>9<<4)+14]=t;for(var r=1732584193,n=-271733879,i=-1732584194,a=271733878,s=0;s>16)+(t>>16)+(r>>16);return n<<16|r&65535}function d7(e,t){return e<>>32-t}var vg=class{constructor(){this.expires=p7(),k.read(To)||k.write("{}",To);try{this.resourceCache=JSON.parse(k.read(To))}catch(t){k.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${To} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${t?.message??t}`),this.resourceCache={},k.write("{}",To)}this._cleanup()}_cleanup(){let t=!1;Object.entries(this.resourceCache).forEach(r=>{let[n,i]=r;i.time||(delete this.resourceCache[n],k.delete(`#${n}`),t=!0),new Date().getTime()-i.time>this.expires&&(delete this.resourceCache[n],t=!0)}),t&&this._persist()}revokeAll(){this.resourceCache={},this._persist()}_persist(){k.write(JSON.stringify(this.resourceCache),To)}get(t){let r=this.resourceCache[t]&&this.resourceCache[t].time;return r&&new Date().getTime()-r<=this.expires?this.resourceCache[t].data:null}gettime(t){let r=this.resourceCache[t]&&this.resourceCache[t].time;return r&&new Date().getTime()-r<=this.expires?this.resourceCache[t].time:null}set(t,r){this.resourceCache[t]={time:new Date().getTime(),data:r},this._persist()}};function p7(){k.read(B0)||k.write("6e4",B0);let e=6e4;if(k.env.isLoon){let t={"1\u5206\u949F":6e4,"5\u5206\u949F":3e5,"10\u5206\u949F":6e5,"30\u5206\u949F":18e5,"1\u5C0F\u65F6":36e5,"2\u5C0F\u65F6":72e5,"3\u5C0F\u65F6":108e5,"6\u5C0F\u65F6":216e5,"12\u5C0F\u65F6":432e5,"24\u5C0F\u65F6":864e5,"48\u5C0F\u65F6":1728e5,"72\u5C0F\u65F6":2592e5,\u53C2\u6570\u4F20\u5165:"readcachets"},r=k.read("#\u54CD\u5E94\u5934\u7F13\u5B58\u6709\u6548\u671F");return r in t&&(e=t[r],e==="readcachets"&&(e=r)),e}else return e=k.read(B0),e}var Lo=new vg;function zl(e){let t=Object.keys(e),r="",n="";for(let i of t){let a=i.toLowerCase();a==="subscription-userinfo"?r=e[i]:a==="profile-web-page-url"&&(n=e[i])}return`${r||""}${n?`; app_url=${encodeURIComponent(n)}`:""}`}async function na(rawUrl,ua,timeout,customProxy,flowUrl){let url=flowUrl||rawUrl||"",$arguments={},rawArgs=url.split("#");if(url=url.split("#")[0],rawArgs.length>1)try{$arguments=JSON.parse(decodeURIComponent(rawArgs[1]))}catch{for(let t of rawArgs[1].split("&")){let r=t.split("=")[0],n=t.split("=")[1];$arguments[r]=n==null||n===""?!0:decodeURIComponent(n)}}if($arguments?.noFlow||!/^https?/.test(url))return;let{isStash,isLoon,isShadowRocket,isQX}=an(),insecure=$arguments?.insecure?k.env.isNode?{strictSSL:!1}:{insecure:!0}:void 0,{defaultProxy,defaultFlowUserAgent,defaultTimeout}=k.read(jt),proxy=customProxy||defaultProxy;k.env.isNode&&(proxy=proxy||eval("process.env.SUB_STORE_BACKEND_DEFAULT_PROXY"));let userAgent=ua||defaultFlowUserAgent||"clash.meta/v1.19.16",requestTimeout=timeout||defaultTimeout||8e3,id=Mi(userAgent+url),cached=Lo.get(id),flowInfo;if(!$arguments?.noCache&&cached)k.info(`\u4F7F\u7528\u7F13\u5B58\u7684\u6D41\u91CF\u4FE1\u606F: ${url}, ${userAgent}`),flowInfo=cached;else{let e=Xa();if(flowUrl){k.info(`\u4F7F\u7528 GET \u65B9\u6CD5\u4ECE\u54CD\u5E94\u4F53\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F: ${flowUrl}, User-Agent: ${userAgent||""}, Insecure: ${!!insecure}, Proxy: ${proxy}`);let{body:t,statusCode:r}=await e.get({url:flowUrl,headers:{"User-Agent":userAgent},timeout:requestTimeout,...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?Za(proxy):{},...insecure||{}});if(r<200||r>=400)throw new Error(`statusCode: ${r}`);flowInfo=t}else{try{k.info(`\u4F7F\u7528 HEAD \u65B9\u6CD5\u4ECE\u54CD\u5E94\u5934\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F: ${url}, User-Agent: ${userAgent||""}, Insecure: ${!!insecure}, Proxy: ${proxy}`);let{headers:t}=await e.head({url:url.split(/[\r\n]+/).map(r=>r.trim()).filter(r=>r.length)[0],headers:{"User-Agent":userAgent,...isStash&&proxy?{"X-Stash-Selected-Proxy":encodeURIComponent(proxy)}:{},...isShadowRocket&&proxy?{"X-Surge-Policy":proxy}:{}},timeout:requestTimeout,...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?Za(proxy):{},...insecure||{}});flowInfo=zl(t)}catch(t){k.error(`\u4F7F\u7528 HEAD \u65B9\u6CD5\u4ECE\u54CD\u5E94\u5934\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u5931\u8D25: ${url}, User-Agent: ${userAgent||""}, Insecure: ${!!insecure}, Proxy: ${proxy}: ${t.message??t}`)}if(!flowInfo){k.info(`\u4F7F\u7528 GET \u65B9\u6CD5\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F: ${url}, User-Agent: ${userAgent||""}, Insecure: ${!!insecure}, Proxy: ${proxy}`);let{headers:t}=await e.get({url:url.split(/[\r\n]+/).map(r=>r.trim()).filter(r=>r.length)[0],headers:{"User-Agent":userAgent,...isStash&&proxy?{"X-Stash-Selected-Proxy":encodeURIComponent(proxy)}:{},...isShadowRocket&&proxy?{"X-Surge-Policy":proxy}:{}},timeout:requestTimeout,...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?Za(proxy):{},...insecure||{}});flowInfo=zl(t)}}flowInfo&&(flowInfo=flowInfo.trim()),flowInfo&&Lo.set(id,flowInfo)}return flowInfo}function Uo(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]),a=e.match(/total=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),s=Number(a[1]+a[2]),u=e.match(/expire=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),l=u?Number(u[1]+u[2]):void 0,f=e.match(/reset_day=([0-9]+)/),d=f?Number(f[1]):void 0,m=e.match(/app_url=(.*?)\s*?(;|$)/),p=m?decodeURIComponent(m[1]):void 0,h=e.match(/plan_name=(.*?)\s*?(;|$)/),w=h?decodeURIComponent(h[1]):void 0;return{expires:l,total:s,usage:{upload:r,download:i},remainingDays:d,appUrl:p,planName:w}}function Af(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}:Af(e/1024,r[++n])}function G0(e){if(!e)throw new Error("\u6CA1\u6709\u6D41\u91CF\u4FE1\u606F");if(e?.expires&&e.expires*1e3a.getTime())throw new Error("\u5F00\u59CB\u65E5\u671F\u5E94\u65E9\u4E8E\u73B0\u5728");let s=new Date(r);for(s.setDate(s.getDate()+n);s31)throw new Error("\u6708\u91CD\u7F6E\u65E5\u5E94\u4E3A 1-31 \u4E4B\u95F4\u7684\u6574\u6570");let i=new Date,a=i.getDate(),s=i.getMonth(),u=i.getFullYear(),l;return t>a?l=0:l=new Date(u,s+1,0).getDate(),l-a+t}}catch(t){k.error(`getRmainingDays failed: ${t.message??t}`)}}function W0(e){try{let t=new Map;return e.split(";").map(r=>r.trim()).filter(Boolean).forEach(r=>{let n=r.indexOf("=");if(n===-1)return;let i=r.slice(0,n).trim(),a=r.slice(n+1).trim();if(!t.has(i))try{let s=decodeURIComponent(a);if(["upload","download","total","expire"].includes(i))try{s=Number(s).toFixed(0),["expire"].includes(i)&&s<=0&&(s="")}catch(u){k.error(`Failed to convert value for key "${i}=${a}": ${u.message??u}`)}t.set(i,s)}catch{t.set(i,a)}}),Array.from(t.entries()).map(([r,n])=>`${r}=${encodeURIComponent(n)}`).join("; ")}catch(t){return k.error(`normalizeFlowHeader failed: ${t.message??t}`),e}}k.read(mr)||k.write({},mr);function wg(e){e.get("/api/sub/flow/:name",g7),e.route("/api/sub/:name").get(v7).patch(w7).delete(A7),e.route("/api/subs").get(E7).post(m7).put(b7)}async function g7(e,t){let{name:r}=e.params,{url:n}=e.query;n&&k.info(`\u6307\u5B9A\u8FDC\u7A0B\u8BA2\u9605 URL: ${n}`);let i=k.read(mr),a=Rt(i,r);if(!a){Ve(t,new Wr("RESOURCE_NOT_FOUND",`Subscription ${r} does not exist!`),404);return}if(a.source==="local"&&!["localFirst","remoteFirst"].includes(a.mergeSources)){if(a.subUserinfo){let s;if(/^https?:\/\//.test(a.subUserinfo))try{s=await na(void 0,void 0,void 0,a.proxy,a.subUserinfo)}catch(u){k.error(`\u8BA2\u9605 ${r} \u4F7F\u7528\u81EA\u5B9A\u4E49\u6D41\u91CF\u94FE\u63A5 ${a.subUserinfo} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(u)}`)}else s=a.subUserinfo;try{qe(t,{...Uo(s)})}catch(u){k.error(`Failed to parse flow info for local subscription ${r}: ${u.message??u}`),Ve(t,new Tt("NO_FLOW_INFO","N/A","Failed to parse flow info"))}}else Ve(t,new Tt("NO_FLOW_INFO","N/A",`Local subscription ${r} has no flow information!`));return}try{n=`${n||a.url}`.split(/[\r\n]+/).map(f=>f.trim()).filter(f=>f.length)?.[0]||"";let s={},u=n.split("#");if(n=n.split("#")[0],u.length>1)try{s=JSON.parse(decodeURIComponent(u[1]))}catch{for(let d of u[1].split("&")){let m=d.split("=")[0],p=d.split("=")[1];s[m]=p==null||p===""?!0:decodeURIComponent(p)}}if(s.noFlow||!/^https?/.test(n)){Ve(t,new Tt("NO_FLOW_INFO","N/A",`Subscription ${r}: noFlow`));return}let l=await na(s?.insecure?`${n}#insecure`:n,s.flowUserAgent,void 0,a.proxy,s.flowUrl);if(!l&&!a.subUserinfo){Ve(t,new Dn("NO_FLOW_INFO","No flow info","Failed to fetch flow headers"));return}try{let f=Y0({resetDay:s.resetDay,startDate:s.startDate,cycleDays:s.cycleDays}),d;if(/^https?:\/\//.test(a.subUserinfo))try{d=await na(void 0,void 0,void 0,a.proxy,a.subUserinfo)}catch(p){k.error(`\u8BA2\u9605 ${r} \u4F7F\u7528\u81EA\u5B9A\u4E49\u6D41\u91CF\u94FE\u63A5 ${a.subUserinfo} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(p)}`)}else d=a.subUserinfo;let m={...Uo([d,l].filter(p=>p).join("; "))};f!=null&&(m.remainingDays=f),qe(t,m)}catch(f){k.error(`Failed to parse flow info for local subscription ${r}: ${f.message??f}`),Ve(t,new Tt("NO_FLOW_INFO","N/A","Failed to parse flow info"))}}catch{Ve(t,new O0("URL_NOT_ACCESSIBLE",`The URL for subscription ${r} is inaccessible.`))}}function m7(e,t){let r=e.body;if(delete r.subscriptions,k.info(`\u6B63\u5728\u521B\u5EFA\u8BA2\u9605\uFF1A ${r.name}`),/\//.test(r.name)){Ve(t,new Tt("INVALID_NAME",`Subscription ${r.name} is invalid`));return}let n=k.read(mr);if(Rt(n,r.name)){Ve(t,new Tt("DUPLICATE_KEY",`Subscription ${r.name} already exists.`));return}n.push(r),k.write(n,mr),qe(t,r,201)}function v7(e,t){let{name:r}=e.params,{raw:n}=e.query,i=k.read(mr),a=Rt(i,r);delete a.subscriptions,a?n?t.set("content-type","application/json").set("content-disposition",`attachment; filename="${encodeURIComponent(`sub-store_subscription_${r}_${Hu(new Date)}.json`)}"`).send(JSON.stringify(a)):qe(t,a):Ve(t,new Wr("SUBSCRIPTION_NOT_FOUND",`Subscription ${r} does not exist`,404))}function w7(e,t){let{name:r}=e.params,n=e.body;delete n.subscriptions;let i=k.read(mr),a=Rt(i,r);if(a){let s={...a,...n};if(k.info(`\u6B63\u5728\u66F4\u65B0\u8BA2\u9605\uFF1A ${r}`),r!==n.name){let u=k.read(sr)||[];for(let d of u){let m=d.subscriptions.indexOf(r);m!==-1&&(d.subscriptions[m]=n.name)}let l=k.read(zt)||[];for(let d of l)d.type==="subscription"&&d.source==r&&(d.source=n.name);let f=k.read(xt)||[];for(let d of f)d.sourceType==="subscription"&&d.sourceName==r&&(d.sourceName=n.name);k.write(u,sr),k.write(l,zt),k.write(f,xt)}Ss(i,r,s),k.write(i,mr),qe(t,s)}else Ve(t,new Wr("RESOURCE_NOT_FOUND",`Subscription ${r} does not exist!`),404)}function A7(e,t){let{name:r}=e.params;k.info(`\u5220\u9664\u8BA2\u9605\uFF1A${r}...`);let n=k.read(mr);Fs(n,r),k.write(n,mr);let i=k.read(sr);for(let a of i)a.subscriptions=a.subscriptions.filter(s=>s!==r);k.write(i,sr),qe(t)}function E7(e,t){let r=k.read(mr);qe(t,r)}function b7(e,t){let r=e.body;k.write(r,mr),qe(t)}var cs=class{constructor({token,key,syncPlatform}){let{isStash,isLoon,isShadowRocket,isQX}=an(),{defaultProxy,defaultTimeout:timeout,githubProxy}=k.read(jt),proxy=defaultProxy;k.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=Xa({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?Za(proxy):{},timeout:timeout||8e3,events:{onResponse:e=>{if(/^[45]/.test(String(e.statusCode))){let t=JSON.parse(e.body);return Promise.reject(`ERROR: ${t.message?.error??t.message}`)}else return e}}})):(this.headers={Authorization:`token ${token}`,"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36"},this.http=Xa({baseURL:`${githubProxy?`${githubProxy}/`:""}https://api.github.com`,headers:{...this.headers,...isStash&&proxy?{"X-Stash-Selected-Proxy":encodeURIComponent(proxy)}:{},...isShadowRocket&&proxy?{"X-Surge-Policy":proxy}:{}},...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?Za(proxy):{},timeout:timeout||8e3,events:{onResponse:e=>/^[45]/.test(String(e.statusCode))?Promise.reject(`ERROR: ${JSON.parse(e.body).message}`):e}})),this.key=key,this.syncPlatform=syncPlatform}async locate(){return this.syncPlatform==="gitlab"?this.http.get("/snippets").then(e=>{let t=JSON.parse(e.body);for(let r of t)if(r.title===this.key)return r}):this.http.get("/gists?per_page=100&page=1").then(e=>{let t=JSON.parse(e.body);k.info(`\u83B7\u53D6\u5230\u5F53\u524D GitHub \u7528\u6237\u7684 gist: ${t.length} \u4E2A`);for(let r of t)if(r.description===this.key)return r})}async upload(e){if(Object.keys(e).length===0)return Promise.reject("\u672A\u63D0\u4F9B\u9700\u4E0A\u4F20\u7684\u6587\u4EF6");let t=await this.locate(),r=e;if(t?.id){this.syncPlatform==="gitlab"&&(t.files=t.files.reduce((a,s)=>(a[s.path]=s,a),{}));let n=[],i={...t.files};return Object.keys(r).map(a=>{i[a]?r[a].content==null||r[a].content===""?(delete i[a],n.push({action:"delete",file_path:a})):(i[a]=r[a],n.push({action:"update",file_path:a,content:r[a].content})):r[a].content==null||r[a].content===""?(delete i[a],delete r[a]):(i[a]=r[a],n.push({action:"create",file_path:a,content:r[a].content}))}),this.syncPlatform==="gitlab"?Object.keys(i).length===0?Promise.reject("\u672C\u6B21\u64CD\u4F5C\u5C06\u5BFC\u81F4\u6240\u6709\u6587\u4EF6\u7684\u5185\u5BB9\u90FD\u4E3A\u7A7A, \u65E0\u6CD5\u66F4\u65B0 snippet"):Object.keys(i).length>10?Promise.reject("\u672C\u6B21\u64CD\u4F5C\u5C06\u5BFC\u81F4 snippet \u7684\u6587\u4EF6\u6570\u8D85\u8FC7 10, \u65E0\u6CD5\u66F4\u65B0 snippet"):(r=n,this.http.put({headers:{...this.headers,"Content-Type":"application/json"},url:`/snippets/${t.id}`,body:JSON.stringify({files:r})})):Object.keys(i).length===0?Promise.reject("\u672C\u6B21\u64CD\u4F5C\u5C06\u5BFC\u81F4\u6240\u6709\u6587\u4EF6\u7684\u5185\u5BB9\u90FD\u4E3A\u7A7A, \u65E0\u6CD5\u66F4\u65B0 gist"):this.http.patch({url:`/gists/${t.id}`,body:JSON.stringify({files:r})})}else return r=Object.entries(r).reduce((n,[i,a])=>(a.content!==null&&a.content!==""&&(n[i]=a),n),{}),this.syncPlatform==="gitlab"?Object.keys(r).length===0?Promise.reject("\u6240\u6709\u6587\u4EF6\u7684\u5185\u5BB9\u90FD\u4E3A\u7A7A, \u65E0\u6CD5\u521B\u5EFA snippet"):(r=Object.keys(r).map(n=>({file_path:n,content:r[n].content})),this.http.post({headers:{...this.headers,"Content-Type":"application/json"},url:"/snippets",body:JSON.stringify({title:this.key,visibility:"private",files:r})})):Object.keys(r).length===0?Promise.reject("\u6240\u6709\u6587\u4EF6\u7684\u5185\u5BB9\u90FD\u4E3A\u7A7A, \u65E0\u6CD5\u521B\u5EFA gist"):this.http.post({url:"/gists",body:JSON.stringify({description:this.key,public:!1,files:r})})}async download(e){let t=await this.locate();if(t?.id)try{let{files:r}=await this.http.get(`/gists/${t.id}`).then(i=>JSON.parse(i.body)),n=r[e].raw_url;return await this.http.get(n).then(i=>i.body)}catch(r){return Promise.reject(r)}else return Promise.reject(`\u627E\u4E0D\u5230 Sub-Store Gist (${this.key})`)}};function Ag(e){k.read(zt)||k.write({},zt),e.get("/api/artifacts/restore",y7),e.route("/api/artifacts").get(_7).post(F7).put(C7),e.route("/api/artifact/:name").get(D7).patch(S7).delete(I7)}async function y7(e,t){k.info("\u5F00\u59CB\u6062\u590D\u8FDC\u7A0B\u914D\u7F6E...");try{let{gistToken:r,syncPlatform:n}=k.read(jt);if(!r)return Promise.reject("\u672A\u8BBE\u7F6E GitHub Token\uFF01");let i=new cs({token:r,key:xo,syncPlatform:n});try{let a=await i.locate();if(!a?.files)throw new Error("\u627E\u4E0D\u5230 Sub-Store Gist \u6587\u4EF6\u5217\u8868");let s=k.read(zt),u=[];Object.keys(a.files).map(l=>{let f=a.files[l]?.filename;if(f)if(encodeURIComponent(f)!==f)k.error(`\u6587\u4EF6\u540D ${f} \u672A\u7F16\u7801 \u4E0D\u4FDD\u5B58`),u.push(f);else{let d=Rt(s,f);d?Ss(s,f,{...d,url:a.files[l]?.raw_url.replace(/\/raw\/[^/]*\/(.*)/,"/raw/$1")}):s.push({name:`${f}`,url:a.files[l]?.raw_url.replace(/\/raw\/[^/]*\/(.*)/,"/raw/$1")})}}),k.write(s,zt)}catch(a){throw k.error(`\u67E5\u627E Sub-Store Gist \u65F6\u53D1\u751F\u9519\u8BEF: ${a.message??a}`),a}qe(t)}catch(r){k.error(`\u6062\u590D\u8FDC\u7A0B\u914D\u7F6E\u5931\u8D25\uFF0C\u539F\u56E0\uFF1A${r.message??r}`),Ve(t,new Dn("FAILED_TO_RESTORE_ARTIFACTS","Failed to restore artifacts",`Reason: ${r.message??r}`))}}function _7(e,t){let r=k.read(zt);qe(t,r)}function C7(e,t){let r=e.body;k.write(r,zt),qe(t)}async function D7(e,t){let{name:r}=e.params,n=k.read(zt),i=Rt(n,r);i?qe(t,i):Ve(t,new Wr("RESOURCE_NOT_FOUND",`Artifact ${r} does not exist!`),404)}function F7(e,t){let r=e.body;if(!IE(r.name)){Ve(t,new Tt("INVALID_ARTIFACT_NAME",`Artifact name ${r.name} is invalid.`));return}k.info(`\u6B63\u5728\u521B\u5EFA\u8FDC\u7A0B\u914D\u7F6E\uFF1A${r.name}`);let n=k.read(zt);Rt(n,r.name)?Ve(t,new Tt("DUPLICATE_KEY",`Artifact ${r.name} already exists.`)):(n.push(r),k.write(n,zt),qe(t,r,201))}function S7(e,t){let r=k.read(zt),n=e.params.name,i=Rt(r,n);if(i){k.info(`\u6B63\u5728\u66F4\u65B0\u8FDC\u7A0B\u914D\u7F6E\uFF1A${i.name}`);let a={...i,...e.body};if(!IE(a.name)){Ve(t,new Tt("INVALID_ARTIFACT_NAME",`Artifact name ${a.name} is invalid.`));return}Ss(r,n,a),k.write(r,zt),qe(t,a)}else Ve(t,new Tt("DUPLICATE_KEY",`Artifact ${n} already exists.`))}async function I7(e,t){let{name:r}=e.params;k.info(`\u6B63\u5728\u5220\u9664\u8FDC\u7A0B\u914D\u7F6E\uFF1A${r}`);let n=k.read(zt);try{let i=Rt(n,r);if(!i)throw new Error(`\u8FDC\u7A0B\u914D\u7F6E\uFF1A${r}\u4E0D\u5B58\u5728\uFF01`);if(i.updated){let a={};a[encodeURIComponent(i.name)]={content:""},encodeURIComponent(i.name)!==i.name&&(a[i.name]={content:""});try{await BE(a)}catch(s){k.error(`Function syncToGist: ${r} : ${s}`)}}Fs(n,r),k.write(n,zt),qe(t)}catch(i){k.error(`\u65E0\u6CD5\u5220\u9664\u8FDC\u7A0B\u914D\u7F6E\uFF1A${r}\uFF0C\u539F\u56E0\uFF1A${i}`),Ve(t,new Dn("FAILED_TO_DELETE_ARTIFACT",`Failed to delete artifact ${r}`,`Reason: ${i}`))}}function IE(e){return/^[a-zA-Z0-9._-]*$/.test(e)}async function BE(e){let{gistToken:t,syncPlatform:r}=k.read(jt);if(!t)return Promise.reject("\u672A\u8BBE\u7F6E GitHub Token\uFF01");let i=await new cs({token:t,key:xo,syncPlatform:r}).upload(e),a={};try{a=JSON.parse(i.body)}catch{}let s=a?.html_url??a?.web_url,u=k.read(jt);return s?(k.log(`\u540C\u6B65 Gist \u540E, \u627E\u5230 Sub-Store Gist: ${s}`),u.artifactStore=s,u.artifactStoreStatus="VALID"):(k.error("\u540C\u6B65 Gist \u540E, \u627E\u4E0D\u5230 Sub-Store Gist"),u.artifactStoreStatus="NOT FOUND"),k.write(u,jt),i}function Eg(e){k.read(jt)||k.write({},jt),e.route("/api/settings").get(B7).patch($7)}async function B7(e,t){try{let r=k.read(jt);r||(r={},k.write(r,jt)),r.avatarUrl||await X0(),r.artifactStore||await J0(),qe(t,r)}catch(r){k.error(`Failed to get settings: ${r.message??r}`),Ve(t,new Dn("FAILED_TO_GET_SETTINGS","Failed to get settings",`Reason: ${r.message??r}`))}}async function $7(e,t){try{let n={...k.read(jt),...e.body};k.write(n,jt),(e.body.githubUser||e.body.gistToken||e.body.githubProxy||e.body.defaultProxy)&&(await X0(),await J0()),qe(t,n)}catch(r){k.error(`Failed to update settings: ${r.message??r}`),Ve(t,new Dn("FAILED_TO_UPDATE_SETTINGS","Failed to update settings",`Reason: ${r.message??r}`))}}async function X0(){let e=k.read(jt),{githubUser:t,syncPlatform:r,githubProxy:n}=e;if(t)if(r==="gitlab")try{let i=await k.http.get({url:`https://gitlab.com/api/v4/users?username=${encodeURIComponent(t)}`,headers:{"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36"}}).then(a=>JSON.parse(a.body));e.avatarUrl=i[0].avatar_url.replace(/(\?|&)s=\d+(&|$)/,"$1s=160$2"),k.write(e,jt)}catch(i){k.error(`Failed to fetch GitLab avatar for User: ${t}. Reason: ${i.message??i}`)}else try{let i=await k.http.get({url:`${n?`${n}/`:""}https://api.github.com/users/${encodeURIComponent(t)}`,headers:{"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36"}}).then(a=>JSON.parse(a.body));e.avatarUrl=i.avatar_url,k.write(e,jt)}catch(i){k.error(`Failed to fetch GitHub avatar for User: ${t}. Reason: ${i.message??i}`)}}async function J0(){k.log("Updating artifact store");let e=k.read(jt),{gistToken:t,syncPlatform:r}=e;if(t){let n=new cs({token:t,key:xo,syncPlatform:r});try{let i=await n.locate(),a=i?.html_url??i?.web_url;a?(k.log(`\u627E\u5230 Sub-Store Gist: ${a}`),e.artifactStore=a,e.artifactStoreStatus="VALID"):(k.error(`\u627E\u4E0D\u5230 Sub-Store Gist (${xo})`),e.artifactStoreStatus="NOT FOUND")}catch(i){k.error(`\u67E5\u627E Sub-Store Gist (${xo}) \u65F6\u53D1\u751F\u9519\u8BEF: ${i.message??i}`),e.artifactStoreStatus="ERROR"}k.write(e,jt)}}var _g=_n(Z0());var bg=class{constructor(t){this.expires=t,k.read(Ro)||k.write("{}",Ro);try{this.resourceCache=JSON.parse(k.read(Ro))}catch(r){k.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${Ro} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${r?.message??r}`),this.resourceCache={},k.write("{}",Ro)}this._cleanup()}_cleanup(){let t=!1;Object.entries(this.resourceCache).forEach(r=>{let[n,i]=r;i.time||(delete this.resourceCache[n],k.delete(`#${n}`),t=!0),new Date().getTime()-i.time>this.expires&&(delete this.resourceCache[n],t=!0)}),t&&this._persist()}revokeAll(){this.resourceCache={},this._persist()}_persist(){k.write(JSON.stringify(this.resourceCache),Ro)}get(t){let r=this.resourceCache[t]&&this.resourceCache[t].time;return r&&new Date().getTime()-r<=this.expires?this.resourceCache[t].data:null}set(t,r){this.resourceCache[t]={time:new Date().getTime(),data:r},this._persist()}},qr=new bg(36e5);var yg=class{constructor(){this.expires=x7(),k.read(Oo)||k.write("{}",Oo);try{this.resourceCache=JSON.parse(k.read(Oo))}catch(t){k.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${Oo} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${t?.message??t}`),this.resourceCache={},k.write("{}",Oo)}this._cleanup()}_cleanup(t,r){let n=!1;Object.entries(this.resourceCache).forEach(i=>{let[a,s]=i;s.time||(delete this.resourceCache[a],k.delete(`#${a}`),n=!0),(new Date().getTime()-s.time>(r??this.expires)||t&&a.startsWith(t))&&(delete this.resourceCache[a],n=!0)}),n&&this._persist()}revokeAll(){this.resourceCache={},this._persist()}_persist(){k.write(JSON.stringify(this.resourceCache),Oo)}get(t,r,n){let i=this.resourceCache[t]&&this.resourceCache[t].time;if(i){if(new Date().getTime()-i<=(r??this.expires))return this.resourceCache[t].data;n&&(delete this.resourceCache[t],this._persist())}return null}gettime(t){let r=this.resourceCache[t]&&this.resourceCache[t].time;return r&&new Date().getTime()-r<=this.expires?this.resourceCache[t].time:null}set(t,r){this.resourceCache[t]={time:new Date().getTime(),data:r},this._persist()}};function x7(){k.read($0)||k.write("1728e5",$0);let e=1728e5;if(k.env.isLoon){let t={"1\u5206\u949F":6e4,"5\u5206\u949F":3e5,"10\u5206\u949F":6e5,"30\u5206\u949F":18e5,"1\u5C0F\u65F6":36e5,"2\u5C0F\u65F6":72e5,"3\u5C0F\u65F6":108e5,"6\u5C0F\u65F6":216e5,"12\u5C0F\u65F6":432e5,"24\u5C0F\u65F6":864e5,"48\u5C0F\u65F6":1728e5,"72\u5C0F\u65F6":2592e5,\u53C2\u6570\u4F20\u5165:"readcachets"},r=k.read("#\u8282\u70B9\u7F13\u5B58\u6709\u6548\u671F");return r in t&&(e=t[r],e==="readcachets"&&(e=r)),e}else return e=k.read($0),e}var bf=new yg;var{isNode:$E,isQX:R7,isLoon:T7,isSurge:O7,isStash:k7,isShadowRocket:N7,isLanceX:L7,isEgern:U7,isGUIforCores:j7}=an(),ia="Node";$E&&(ia="Node");R7&&(ia="QX");T7&&(ia="Loon");O7&&(ia="Surge");k7&&(ia="Stash");N7&&(ia="Shadowrocket");U7&&(ia="Egern");L7&&(ia="LanceX");j7&&(ia="GUI.for.Cores");var jo={},H7={};try{if(typeof $environment<"u"&&(jo.env=$environment),typeof $loon<"u"&&(jo.loon=$loon),typeof $script<"u"&&(jo.script=$script),typeof $Plugin<"u"&&(jo.plugin=$Plugin),$E){jo.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)&&(jo.node.env[e]=env[e])}}catch(e){}var qu={backend:ia,version:S0,feature:H7,meta:jo};function Cg(e){e.get("/api/utils/env",PE),e.get("/api/utils/backup",V7),e.get("/api/utils/refresh",M7),e.route("/api/storage").get((t,r)=>{r.set("content-type","application/json").set("content-disposition",`attachment; filename="${encodeURIComponent(`sub-store_data_${Hu(new Date)}.json`)}"`).send(k.env.isNode?JSON.stringify(k.cache):k.read("#sub-store"))}).post((t,r)=>{let{content:n}=t.body;try{if(n=JSON.parse(pt.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(a){throw k.error(`\u5907\u4EFD\u6587\u4EF6\u6821\u9A8C\u5931\u8D25, \u65E0\u6CD5\u8FD8\u539F Reason: ${a.message??a}`),new Error("\u5907\u4EFD\u6587\u4EF6\u6821\u9A8C\u5931\u8D25, \u65E0\u6CD5\u8FD8\u539F")}}k.write(JSON.stringify(n,null," "),"#sub-store"),k.env.isNode&&(k.cache=n,k.persistCache()),Ul(),qe(r)}),an().isNode?e.get("/",PE):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 PE(e,t){e.query.share&&(qu.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://t.me/zhetengsha/1068",...qu}},null,2))}async function M7(e,t){await X0(),await J0(),qr.revokeAll(),bf.revokeAll(),Lo.revokeAll(),qe(t)}async function q7(e,t,r){let{gistToken:n,syncPlatform:i}=k.read(jt);if(!n)throw new Error("GitHub Token is required for backup!");let a=new cs({token:n,key:MA,syncPlatform:i}),s=k.read("#sub-store");s=s?JSON.parse(s):{},k.env.isNode&&(s=JSON.parse(JSON.stringify(k.cache)));let u,l=k.read(jt),f=l.syncTime,d=r||l.gistUpload||"base64";switch(k.info(`Gist backup action: ${e}, keep: ${t}, encode: ${r}, settings encode: ${l.gistUpload}, final encoding: ${d}`),e){case"upload":try{if(u=k.read("#sub-store"),u=u?JSON.parse(u):{},k.env.isNode&&(u=JSON.parse(JSON.stringify(k.cache))),d==="plaintext"?(u.settings.gistToken="\u6062\u590D\u540E\u8BF7\u91CD\u65B0\u8BBE\u7F6E GitHub Token",u=JSON.stringify(u,null," ")):u=pt.encode(JSON.stringify(u,null," ")),k.info("\u4E0B\u8F7D\u5907\u4EFD, \u4E0E\u672C\u5730\u5185\u5BB9\u5BF9\u6BD4..."),await a.download(I0)===u){k.info("\u5185\u5BB9\u4E00\u81F4, \u65E0\u9700\u4E0A\u4F20\u5907\u4EFD");return}}catch(m){k.error(`${m.message??m}`)}l.syncTime=new Date().getTime(),k.write(l,jt),u=k.read("#sub-store"),u=u?JSON.parse(u):{},k.env.isNode&&(u=JSON.parse(JSON.stringify(k.cache))),d==="plaintext"?(u.settings.gistToken="\u6062\u590D\u540E\u8BF7\u91CD\u65B0\u8BBE\u7F6E GitHub Token",u=JSON.stringify(u,null," ")):u=pt.encode(JSON.stringify(u,null," ")),k.info("\u4E0A\u4F20\u5907\u4EFD\u4E2D...");try{await a.upload({[I0]:{content:u}}),k.info("\u4E0A\u4F20\u5907\u4EFD\u5B8C\u6210")}catch(m){throw l.syncTime=f,k.write(l,jt),m}break;case"download":k.info("\u8FD8\u539F\u5907\u4EFD\u4E2D..."),u=await a.download(I0);try{if(u=JSON.parse(pt.decode(u)),Object.keys(u.settings).length===0)throw new Error("\u5907\u4EFD\u6587\u4EF6\u5E94\u8BE5\u81F3\u5C11\u5305\u542B settings \u5B57\u6BB5")}catch{try{if(u=JSON.parse(u),Object.keys(u.settings).length===0)throw new Error("\u5907\u4EFD\u6587\u4EF6\u5E94\u8BE5\u81F3\u5C11\u5305\u542B settings \u5B57\u6BB5")}catch(p){throw k.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&&(k.info(`\u4FDD\u7559\u539F\u6709\u8BBE\u7F6E ${t}`),t.split(",").forEach(m=>{_g.default.set(u,m,_g.default.get(s,m))})),k.write(JSON.stringify(u,null," "),"#sub-store"),k.env.isNode&&(k.cache=u,k.persistCache()),k.info("perform migration after restoring from gist..."),Ul(),k.info("migration completed"),k.info("\u8FD8\u539F\u5907\u4EFD\u5B8C\u6210");break}}async function V7(e,t){let{action:r,keep:n,encode:i}=e.query,{gistToken:a}=k.read(jt);if(!a)Ve(t,new Tt("GIST_TOKEN_NOT_FOUND","GitHub Token is required for backup!"));else try{await q7(r,n,i),qe(t)}catch(s){k.error(`Failed to ${r} gist data. Reason: ${s.message??s}`),Ve(t,new Dn("BACKUP_FAILED",`Failed to ${r} gist data!`,`Reason: ${s.message??s}`))}}function Dg(e){e.post("/api/sort/subs",K7),e.post("/api/sort/collections",z7),e.post("/api/sort/artifacts",G7),e.post("/api/sort/files",Y7)}function K7(e,t){let r=e.body,n=k.read(mr);n.sort((i,a)=>r.indexOf(i.name)-r.indexOf(a.name)),k.write(n,mr),qe(t,n)}function z7(e,t){let r=e.body,n=k.read(sr);n.sort((i,a)=>r.indexOf(i.name)-r.indexOf(a.name)),k.write(n,sr),qe(t,n)}function G7(e,t){let r=e.body,n=k.read(zt);n.sort((i,a)=>r.indexOf(i.name)-r.indexOf(a.name)),k.write(n,zt),qe(t,n)}function Y7(e,t){let r=e.body,n=k.read(xt);n.sort((i,a)=>r.indexOf(i.name)-r.indexOf(a.name)),k.write(n,xt),qe(t,n)}var Bf=_n(_y());function Dy(e,t,...r){try{return e(t,...r)}catch{return e(Fy(e(t.replace(/!\s*/g,"__SubStoreJSYAMLString__"),...r)).replace(/__SubStoreJSYAMLString__/g,""),...r)}}function If(e,...t){return Dy(Bf.default.safeLoad,JSON.parse(JSON.stringify(e)),...t)}function Dx(e,...t){return Dy(Bf.default.load,JSON.parse(JSON.stringify(e)),...t)}function Cy(e,...t){return Bf.default.safeDump(JSON.parse(JSON.stringify(e)),...t)}function Fy(e,...t){return Bf.default.dump(JSON.parse(JSON.stringify(e)),...t)}var aa={safeLoad:If,load:Dx,safeDump:Cy,dump:Fy,parse:If,stringify:Cy};function Fx(){return{name:"HTML",test:n=>/^/.test(n),parse:()=>""}}function Sx(){let e="Base64 Pre-processor",t=["dm1lc3M","c3NyOi8v","c29ja3M6Ly","dHJvamFu","c3M6Ly","c3NkOi8v","c2hhZG93","aHR0c","dmxlc3M=","aHlzdGVyaWEy","aHkyOi8v","d2lyZWd1YXJkOi8v","d2c6Ly8=","dHVpYzovLw=="];return{name:e,test:function(i){return!/^\w+:\/\/\w+/im.test(i)&&t.some(a=>i.indexOf(a)!==-1)},parse:function(i){let a=pt.decode(i);return/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(a)?a:(k.error("Base64 Pre-processor error: decoded line does not start with protocol"),i)}}}function Ix(){return{name:"Fallback Base64 Pre-processor",test:function(n){return!0},parse:function(n){let i=pt.decode(n);return/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(i)?i:(k.error("Fallback Base64 Pre-processor error: decoded line does not start with protocol"),n)}}}function Bx(){return{name:"Clash Pre-processor",test:function(n){if(!/proxies/.test(n))return!1;let i=If(n);return i.proxies&&Array.isArray(i.proxies)},parse:function(n,i){let a=n.replace(/short-id:([ \t]*[^#\n,}]*)/g,(l,f)=>{let d=f.trim();return!d||d===""?'short-id: ""':/^(['"]).*\1$/.test(d)?`short-id: ${d}`:["null"].includes(d)?`short-id: ${d}`:`short-id: "${d}"`}),{proxies:s,"global-client-fingerprint":u}=If(a);return(i?`proxies: `:"")+s.map(l=>(u&&!l["client-fingerprint"]&&(l["client-fingerprint"]=u),`${i?" - ":""}${JSON.stringify(l)} `)).join("")}}}function $x(){return{name:"SSD Pre-processor",test:function(n){return n.indexOf("ssd://")===0},parse:function(n){let i=[],a=JSON.parse(pt.decode(n.split("ssd://")[1])),s=a.port,u=a.encryption,l=a.password,f=a.servers;for(let d=0;dt)}var hm={"\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{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{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 hc(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{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{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(a=>RegExp(`${a}`,"i").test(e)))return/内蒙古/.test(e)&&["\u{1F1F2}\u{1F1F3}"].includes(n)?r="\u{1F1E8}\u{1F1F3}":r=n;for(let n of Object.keys(hm))if(hm[n].some(a=>RegExp(`(^|[^a-zA-Z])${a}([^a-zA-Z]|$)`).test(e))&&!(n=="\u{1F1E8}\u{1F1F3}"&&RegExp("(^|[^a-zA-Z])CN2([^a-zA-Z]|$)").test(e)))return r=n;return r}function w_(e){return hm[hc(e)]?.[0]}function kf(e){return e.replace(/[\uD83C][\uDDE6-\uDDFF][\uD83C][\uDDE6-\uDDFF]|🏴‍☠️|🏳️‍🌈/g,"").trim()}var $d=class{constructor({country,asn}={}){if(k.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 Rd=_n(B_()),ym=_n(gd());async function pc({url:e,domain:t,type:r="A",timeout:n,edns:i}){let a=Rd.default.encode({type:"query",id:0,flags:Rd.default.RECURSION_DESIRED,questions:[{type:r,name:t}],additionals:[{type:"OPT",name:".",udpPayloadSize:4096,flags:0,options:[{code:"CLIENT_SUBNET",ip:i,sourcePrefixLength:Mr(i)?24:56,scopePrefixLength:0}]}]}),u=ym.Buffer.from(a).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),l=await k.http.get({url:`${e}?dns=${encodeURIComponent(u)}`,headers:{Accept:"application/dns-message"},"binary-mode":!0,encoding:null,timeout:n});return Rd.default.decode(ym.Buffer.from(k.env.isQX?l.bodyBytes:l.body))}var Cm=_n(Z0());function ck(e){return e&&typeof e=="object"&&!Array.isArray(e)}function Lf(e){return e.startsWith("<")&&e.endsWith(">")?e.slice(1,-1):e}function P_(e,t){let r=typeof t=="string"?JSON.parse(t):t;for(let n in r)if(ck(r[n]))if(n.endsWith("!")){let i=Lf(n.slice(0,-1));e[i]=r[n]}else{let i=Lf(n);e[i]||Object.assign(e,{[i]:{}}),P_(e[i],r[i])}else if(Array.isArray(r[n]))if(n.startsWith("+")){let i=Lf(n.slice(1));e[i]||Object.assign(e,{[i]:[]}),e[i]=[...r[n],...e[i]]}else if(n.endsWith("+")){let i=Lf(n.slice(0,-1));e[i]||Object.assign(e,{[i]:[]}),e[i]=[...e[i],...r[n]]}else{let i=Lf(n);Object.assign(e,{[i]:r[n]})}else Object.assign(e,{[n]:r[n]});return e}function fk({rule:e}){return{name:"Conditional Filter",func:t=>t.map(r=>Td(e,r))}}function Td(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=>Td(r,t));case"OR":return e.child.some(r=>Td(r,t));case"NOT":return!Td(e.child,t);default:throw new Error(`Unknown operator: ${e.operator}`)}}function hk(e){return{name:"Quick Setting Operator",func:r=>{if(t(e.useless)){let i=O_().func(r);r=r.filter((a,s)=>i[s]&&a.port>0&&a.port<=65535)}return r.map(n=>(n.udp=t(e.udp,n.udp),n.tfo=t(e.tfo,n.tfo),n["fast-open"]=t(e.tfo,n["fast-open"]),n["skip-cert-verify"]=t(e.scert,n["skip-cert-verify"]),n.type==="vmess"&&(n.aead=t(e["vmess aead"],n.aead)),n))}};function t(r,n){switch(r){case"ENABLED":return!0;case"DISABLED":return!1;default:return n}}}function dk({mode:e,tw:t}){return{name:"Flag Operator",func:r=>r.map(n=>{if(e==="remove")n.name=kf(n.name);else{let i=hc(n.name);n.name=kf(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 pk(e){let{action:t,template:r,link:n,position:i}={action:"rename",template:"0 1 2 3 4 5 6 7 8 9",link:"-",position:"back",...e};return{name:"Handle Duplicate Operator",func:a=>{if(t==="delete"){let s={};return a.filter(u=>s[u.name]?!1:(s[u.name]=!0,!0))}else if(t==="rename"){let s=r.split(" "),u={},l=0;a.forEach(d=>{typeof u[d.name]>"u"?u[d.name]=1:u[d.name]++,l=Math.max(u[d.name].toString().length,l)});let f={};return a.map(d=>{if(u[d.name]>1){typeof f[d.name]>"u"&&(f[d.name]=1);let m="",p=f[d.name]++,h=0;for(;p>0;)m=s[p%10]+m,p=parseInt(p/10),h++;for(;h++{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 Fk(t);default:throw new Error("Unknown sort option: "+e)}}}}function mk(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=>Dm(i)),n.sort((i,a)=>{let s=$_(r,i.name),u=$_(r,a.name);return s&&!u?-1:u&&!s?1:s&&u?st.map(r=>{for(let{expr:n,now:i}of e)r.name=r.name.replace(Dm(n,"g"),i).trim();return r})}}function vk(e){let t=e.map(r=>({expr:r,now:""}));return{name:"Regex Delete Operator",func:x_(t).func}}function wk(e,t,r,n,i){return{name:"Script Operator",func:async a=>{let s=a;if(s?.$file?.type==="mihomoProfile")try{let u=aa.safeLoad(e),l;if(s?.$content)try{l=aa.safeLoad(s?.$content)}catch(f){k.error(f.message??f)}if(typeof u!="object")throw new Error("patch is not an object");return s.$content=yr.yaml.safeDump(P_(l||(s?.$file?.sourceType==="none"?{}:{proxies:await wa({type:s?.$file?.sourceType||"collection",name:s?.$file?.sourceName,platform:"mihomo",produceType:"internal",produceOpts:{"delete-underscore-fields":!0}})}),u)),s}catch{}return await async function(){s=Od("operator",e,r,i)(a,t,{source:n,...qu})}(),s},nodeFunc:async a=>{let s=a;return await async function(){s=Od("operator",`async function operator(input = []) { if (input && (input.$files || input.$content)) { let { $content, $files, $options, $file } = input if($file.type === 'mihomoProfile') { ${e} if(typeof main === 'function') { let config; if ($content) { try { config = ProxyUtils.yaml.safeLoad($content); } catch (e) { console.log(e.message ?? e); } } $content = ProxyUtils.yaml.safeDump(await main(config || ($file.sourceType === 'none' ? {} : { proxies: await produceArtifact({ type: $file.sourceType || 'collection', name: $file.sourceName, platform: 'mihomo', produceType: 'internal', produceOpts: { 'delete-underscore-fields': true } }), }))) } } else { ${e} } return { $content, $files, $options, $file } } else { let proxies = input let list = [] for await (let $server of proxies) { ${e} list.push($server) } return list } }`,r,i)(a,t,{source:n,...qu})}(),s}}}function Ak(e){let t,r;try{let n=e.split(":");r=parseInt(n[2],16);let i=parseInt(n[3],16),a=parseInt(n[4],16),s=i>>8,u=i&255,l=a>>8,f=a&255;if(t=`${s}.${u}.${l}.${f}`,r<=0||r>65535)throw new Error(`Invalid port number: ${r}`);if(!Mr(t))throw new Error(`Invalid IP address: ${t}`)}catch(n){k.error(`IP4P \u89E3\u6790\u5931\u8D25: ${n}`)}return{server:t,port:r}}var R_={Custom:async function(e,t,r,n,i,a){let s=Mi(`CUSTOM:${a}:${e}:${t}`),u=qr.get(s);if(!r&&u)return u;let l=t==="IPv6"?"AAAA":"A",f=await pc({url:a,domain:e,type:l,timeout:n,edns:i}),{answers:d}=f;if(!Array.isArray(d)||d.length===0)throw new Error("No answers");let m=d.filter(p=>p?.type===l).map(p=>p?.data).filter(p=>p);if(m.length===0)throw new Error("No answers");return qr.set(s,m),m},Google:async function(e,t,r,n,i){let a=Mi(`GOOGLE:${e}:${t}`),s=qr.get(a);if(!r&&s)return s;let u=t==="IPv6"?"AAAA":"A",l=await pc({url:"https://8.8.4.4/dns-query",domain:e,type:u,timeout:n,edns:i}),{answers:f}=l;if(!Array.isArray(f)||f.length===0)throw new Error("No answers");let d=f.filter(m=>m?.type===u).map(m=>m?.data).filter(m=>m);if(d.length===0)throw new Error("No answers");return qr.set(a,d),d},"IP-API":async function(e,t,r,n){if(["IPv6"].includes(t))throw new Error(`\u57DF\u540D\u89E3\u6790\u670D\u52A1\u63D0\u4F9B\u65B9 IP-API \u4E0D\u652F\u6301 ${t}`);let i=Mi(`IP-API:${e}`),a=qr.get(i);if(!r&&a)return a;let s=await k.http.get({url:`http://ip-api.com/json/${encodeURIComponent(e)}?lang=zh-CN`,timeout:n}),u=JSON.parse(s.body);if(u.status!=="success")throw new Error(`Status is ${u.status}`);if(!u.query||u.query===0)throw new Error("No answers");let l=[u.query];if(l.length===0)throw new Error("No answers");return qr.set(i,l),l},Cloudflare:async function(e,t,r,n,i){let a=Mi(`CLOUDFLARE:${e}:${t}`),s=qr.get(a);if(!r&&s)return s;let u=t==="IPv6"?"AAAA":"A",l=await pc({url:"https://1.0.0.1/dns-query",domain:e,type:u,timeout:n,edns:i}),{answers:f}=l;if(!Array.isArray(f)||f.length===0)throw new Error("No answers");let d=f.filter(m=>m?.type===u).map(m=>m?.data).filter(m=>m);if(d.length===0)throw new Error("No answers");return qr.set(a,d),d},Ali:async function(e,t,r,n,i){let a=Mi(`ALI:${e}:${t}`),s=qr.get(a);if(!r&&s)return s;let u=await k.http.get({url:`http://223.6.6.6/resolve?edns_client_subnet=${i}/${Mr(i)?24:56}&name=${encodeURIComponent(e)}&type=${t==="IPv6"?"AAAA":"A"}&short=1`,headers:{accept:"application/dns-json"},timeout:n}),l=JSON.parse(u.body);if(!Array.isArray(l)||l.length===0)throw new Error("No answers");let f=l;if(f.length===0)throw new Error("No answers");return qr.set(a,f),f},Tencent:async function(e,t,r,n,i){let a=Mi(`TENCENT:${e}:${t}`),s=qr.get(a);if(!r&&s)return s;let l=(await k.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(d=>d.split(",")[0]);if(l.length===0||String(l)==="0")throw new Error("No answers");let f=l;if(f.length===0)throw new Error("No answers");return qr.set(a,f),f}};function T_({provider:e,type:t,filter:r,cache:n,url:i,timeout:a,edns:s}){if(["IPv6","IP4P"].includes(t)&&["IP-API"].includes(e))throw new Error(`\u57DF\u540D\u89E3\u6790\u670D\u52A1\u63D0\u4F9B\u65B9 ${e} \u4E0D\u652F\u6301 ${t}`);let{defaultTimeout:u}=k.read(jt),l=a||u||8e3,f=["IPv6","IP4P"].includes(t)?"IPv6":"IPv4",d=R_[e];if(!d)throw new Error(`\u627E\u4E0D\u5230\u57DF\u540D\u89E3\u6790\u670D\u52A1\u63D0\u4F9B\u65B9: ${e}`);let m=s||"223.6.6.6";if(!Qo(m))throw new Error("\u57DF\u540D\u89E3\u6790 EDNS \u5E94\u4E3A IP");return k.info(`Domain Resolver: [${t}] ${e} ${m||""} ${i||""}`),{name:"Resolve Domain Operator",func:async p=>{p.forEach((g,b)=>{!g["_no-resolve"]&&g["no-resolve"]&&(p[b]["_no-resolve"]=g["no-resolve"])});let h={},w=15,v=[...new Set(p.filter(g=>!Qo(g.server)&&!g["_no-resolve"]).map(g=>g.server))],y=Math.ceil(v.length/w);for(let g=0;g{h[D]=C,k.info(`Successfully resolved domain: ${D} \u279F ${C}`)}).catch(C=>{k.error(`Failed to resolve domain: ${D} with resolver [${e}]: ${C}`)}));await Promise.all(b)}return p.forEach(g=>{if(!g["_no-resolve"])if(h[g.server]){g._resolved_ips=h[g.server];let b=Array.isArray(h[g.server])?h[g.server][Math.floor(Math.random()*h[g.server].length)]:h[g.server];if(f==="IPv6"&&Xr(b)){try{b=new V0.Address6(b).correctForm()}catch(D){k.error(`Failed to parse IPv6 address: ${b}: ${D}`)}if(/^2001::[^:]+:[^:]+:[^:]+$/.test(b)){g._IP4P=b;let{server:D,port:C}=Ak(b);D&&C?(g._domain=g.server,g.server=D,g.port=C,g.resolved=!0,g._IPv4=g.server,Qo(g._IP)||(g._IP=g.server)):g.resolved||(g.resolved=!1)}else g._domain=g.server,g.server=b,g.resolved=!0,g[`_${f}`]=g.server,Qo(g._IP)||(g._IP=g.server)}else g._domain=g.server,g.server=b,g.resolved=!0,g[`_${f}`]=g.server,Qo(g._IP)||(g._IP=g.server)}else g.resolved||(g.resolved=!1)}),p.filter(g=>r==="removeFailed"?Qo(g.server)||g["_no-resolve"]||g.resolved:r==="IPOnly"?Qo(g.server):r==="IPv4Only"?Mr(g.server):r==="IPv6Only"?Xr(g.server):!0)}}}function Qo(e){return Mr(e)||Xr(e)}T_.resolver=R_;function _m(e){var t=/^[\x00-\x7F]+$/;return t.test(e)}function O_(){return{name:"Useless Filter",func:e=>e.map(t=>{if(t.cipher&&!_m(t.cipher))return!1;if(t.password&&!_m(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&&!_m(n)))return!1}return!/网址|流量|时间|应急|过期|Bandwidth|expire/.test(t.name)})}}function Ek(e){let t=e?.value||e;Array.isArray(t)||(t=[]);let r=e?.keep??!0,n={HK:"\u{1F1ED}\u{1F1F0}",TW:"\u{1F1F9}\u{1F1FC}",US:"\u{1F1FA}\u{1F1F8}",SG:"\u{1F1F8}\u{1F1EC}",JP:"\u{1F1EF}\u{1F1F5}",UK:"\u{1F1EC}\u{1F1E7}",DE:"\u{1F1E9}\u{1F1EA}",KR:"\u{1F1F0}\u{1F1F7}"};return{name:"Region Filter",func:i=>i.map(a=>{let s=hc(a.name),u=t.some(l=>n[l]===s);return r?u:!u})}}function bk({regex:e=[],keep:t=!0}){return{name:"Regex Filter",func:r=>r.map(n=>{let i=e.some(a=>Dm(a).test(n.name));return t?i:!i})}}function Dm(e,...t){return t=t.join(""),e.startsWith("(?i)")?(e=e.substring(4),new RegExp(e,"i"+t)):new RegExp(e,t)}function yk(e){let t=e?.value||e;Array.isArray(t)||(t=[]);let r=e?.keep??!0;return{name:"Type Filter",func:n=>n.map(i=>{let a=t.some(s=>i.type===s);return r?a:!a})}}function _k(e,t,r,n,i){return{name:"Script Filter",func:async a=>{let s=Bd(a.length,!0);return await async function(){s=Od("filter",e,r,i)(a,t,{source:n,...qu})}(),s},nodeFunc:async a=>{let s=Bd(a.length,!0);return await async function(){s=Od("filter",`async function filter(input = []) { let proxies = input let list = [] const fn = async ($server) => { ${e} } for await (let $server of proxies) { list.push(await fn($server)) } return list }`,r,i)(a,t,{source:n,...qu})}(),s}}}var kd={"Useless Filter":O_,"Region Filter":Ek,"Regex Filter":bk,"Type Filter":yk,"Script Filter":_k,"Conditional Filter":fk,"Quick Setting Operator":hk,"Flag Operator":dk,"Sort Operator":gk,"Regex Sort Operator":mk,"Regex Rename Operator":x_,"Regex Delete Operator":vk,"Script Operator":wk,"Handle Duplicate Operator":pk,"Resolve Domain Operator":T_};async function Ck(e,t){let r=Bd(t.length,!0);try{r=await e.func(t)}catch(n){let i="",a=`${n.message??n}`;a.includes("$server is not defined")?i="":(k.error(`Cannot apply filter ${e.name}(function filter)! Reason: ${n}`),i=`\u6267\u884C function filter \u5931\u8D25 ${a}; `);try{r=await e.nodeFunc(t)}catch(s){k.error(`Cannot apply filter ${e.name}(shortcut script)! Reason: ${s}`);let u="",l=`${s.message??s}`;throw i&&l===a?(u="",i=`\u6267\u884C\u5931\u8D25 ${a}`):u=`\u6267\u884C\u5FEB\u6377\u8FC7\u6EE4\u811A\u672C \u5931\u8D25 ${l}`,new Error(`\u811A\u672C\u8FC7\u6EE4 ${i}${u}`)}}return t.filter((n,i)=>r[i])}async function Dk(e,t){let r=Sk(t);try{let n=await e.func(r);n&&(r=n)}catch(n){let i="",a=`${n.message??n}`;a.includes("$server is not defined")||a.includes("$content is not defined")||a.includes("$files is not defined")||r?.$files||r?.$content?i="":(k.error(`Cannot apply operator ${e.name}(function operator)! Reason: ${n}`),i=`\u6267\u884C function operator \u5931\u8D25 ${a}; `);try{let s=await e.nodeFunc(r);s&&(r=s)}catch(s){k.error(`Cannot apply operator ${e.name}(shortcut script)! Reason: ${s}`);let u="",l=`${s.message??s}`;throw i&&l===a?(u="",i=`\u6267\u884C\u5931\u8D25 ${a}`):u=`\u6267\u884C\u5FEB\u6377\u811A\u672C \u5931\u8D25 ${l}`,new Error(`\u811A\u672C\u64CD\u4F5C ${i}${u}`)}}return r}async function k_(e,t){if(e.name.indexOf("Filter")!==-1)return Ck(e,t);if(e.name.indexOf("Operator")!==-1)return Dk(e,t)}function Fk(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 Sk(e){return JSON.parse(JSON.stringify(e))}function Od(name,script,$arguments,$options){let flowUtils={getFlowField:zl,getFlowHeaders:na,parseFlowHeaders:Uo,flowTransfer:Af,validCheck:G0,getRmainingDays:Y0,normalizeFlowHeader:W0};return k.env.isLoon?new Function("$arguments","$options","$substore","lodash","$persistentStore","$httpClient","$notification","ProxyUtils","yaml","Buffer","b64d","b64e","scriptResourceCache","flowUtils","produceArtifact","require",`${script} return ${name}`)($arguments,$options,k,Cm.default,$persistentStore,$httpClient,$notification,yr,yr.yaml,yr.Buffer,yr.Base64.decode,yr.Base64.encode,bf,flowUtils,wa,eval('typeof require !== "undefined"')?Po:void 0):new Function("$arguments","$options","$substore","lodash","ProxyUtils","yaml","Buffer","b64d","b64e","scriptResourceCache","flowUtils","produceArtifact","require",`${script} return ${name}`)($arguments,$options,k,Cm.default,yr,yr.yaml,yr.Buffer,yr.Base64.decode,yr.Base64.encode,bf,flowUtils,wa,eval('typeof require !== "undefined"')?Po:void 0)}var N_=_n(Z0()),ot=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){ue(this.proxy,r)&&this.append(t)}toString(){return this.output.join("")}};function ue(e,t){let r=N_.default.get(e,t);return typeof r<"u"&&r!==null}var L_="Surge",Gi={dual:"dual",ipv4:"v4-only",ipv6:"v6-only","ipv4-prefer":"prefer-v4","ipv6-prefer":"prefer-v6"};function gc(){return{produce:(t,r,n={})=>{switch(t.name=t.name.replace(/=|,/g,""),t.ports&&(t.ports=String(t.ports)),t.type){case"ss":return Ik(t,n["include-unsupported-proxy"]);case"trojan":return Bk(t);case"vmess":return Pk(t,n["include-unsupported-proxy"]);case"http":return Rk(t);case"direct":return Tk(t);case"socks5":return Ok(t);case"snell":return kk(t);case"tuic":return Nk(t);case"wireguard-surge":return Uk(t);case"hysteria2":return jk(t);case"ssh":return xk(t)}if(n["include-unsupported-proxy"]&&t.type==="wireguard")return Lk(t);if(n["include-unsupported-proxy"]&&t.type==="anytls"){if(t.network&&(!["tcp"].includes(t.network)||["tcp"].includes(t.network)&&t["reality-opts"]))throw new Error(`Platform ${L_} does not support proxy type ${t.type} with network or reality`);return $k(t)}throw new Error(`Platform ${L_} does not support proxy type: ${t.type}`)}}}function Ik(e){let t=new ot(e);if(t.append(`${e.name}=${e.type},${e.server},${e.port}`),e.cipher||(e.cipher="none"),!["aes-128-gcm","aes-192-gcm","aes-256-gcm","chacha20-ietf-poly1305","xchacha20-ietf-poly1305","rc4","rc4-md5","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","bf-cfb","camellia-128-cfb","camellia-192-cfb","camellia-256-cfb","cast5-cfb","des-cfb","idea-cfb","rc2-cfb","seed-cfb","salsa20","chacha20","chacha20-ietf","none","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"].includes(e.cipher))throw new Error(`cipher ${e.cipher} is not supported`);t.append(`,encrypt-method=${e.cipher}`),t.appendIfPresent(`,password="${e.password}"`,"password");let r=Gi[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"),ue(e,"plugin")){if(e.plugin==="obfs")t.append(`,obfs=${e["plugin-opts"].mode}`),t.appendIfPresent(`,obfs-host=${e["plugin-opts"].host}`,"plugin-opts.host"),t.appendIfPresent(`,obfs-uri=${e["plugin-opts"].path}`,"plugin-opts.path");else if(!["shadow-tls"].includes(e.plugin))throw new Error(`plugin ${e.plugin} is not supported`)}if(t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ue(e,"shadow-tls-password"))t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni"),t.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port");else if(["shadow-tls"].includes(e.plugin)&&e["plugin-opts"]){let n=e["plugin-opts"].password,i=e["plugin-opts"].host,a=e["plugin-opts"].version;if(n){if(t.append(`,shadow-tls-password=${n}`),i&&t.append(`,shadow-tls-sni=${i}`),a){if(a<2)throw new Error(`shadow-tls version ${a} is not supported`);t.append(`,shadow-tls-version=${a}`)}t.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port")}}return t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function Bk(e){let t=new ot(e);t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password="${e.password}"`,"password");let r=Gi[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"),U_(t,e),t.appendIfPresent(`,tls=${e.tls}`,"tls"),t.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ue(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function $k(e){let t=new ot(e);t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password="${e.password}"`,"password");let r=Gi[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(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),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 Pk(e,t){let r=new ot(e);r.append(`${e.name}=${e.type},${e.server},${e.port}`),r.appendIfPresent(`,username=${e.uuid}`,"uuid");let n=Gi[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"),U_(r,e,t),ue(e,"aead")?r.append(`,vmess-aead=${e.aead}`):r.append(`,vmess-aead=${e.alterId===0}`),r.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),r.appendIfPresent(`,tls=${e.tls}`,"tls"),r.appendIfPresent(`,sni=${e.sni}`,"sni"),r.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),r.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),r.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),r.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),r.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),r.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),r.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),r.appendIfPresent(`,tos=${e.tos}`,"tos"),r.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),r.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ue(e,"shadow-tls-password")&&(r.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),r.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),r.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),r.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),r.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),r.toString()}function xk(e){let t=new ot(e);t.append(`${e.name}=ssh,${e.server},${e.port}`),t.appendIfPresent(`,username="${e.username}"`,"username"),t.appendIfPresent(`,password="${e.password}"`,"password"),t.appendIfPresent(`,private-key=${e["keystore-private-key"]}`,"keystore-private-key"),t.appendIfPresent(`,idle-timeout=${e["idle-timeout"]}`,"idle-timeout"),t.appendIfPresent(`,server-fingerprint="${e["server-fingerprint"]}"`,"server-fingerprint");let r=Gi[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function Rk(e){if(e.headers&&Object.keys(e.headers).length>0)throw new Error("headers is unsupported");let t=new ot(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");let n=Gi[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${n}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ue(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function Tk(e){let t=new ot(e);t.append(`${e.name}=direct`);let n=Gi[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${n}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function Ok(e){let t=new ot(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=Gi[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${n}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),e.tfo&&k.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"),ue(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function kk(e){let t=new ot(e);t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,version=${e.version}`,"version"),t.appendIfPresent(`,psk=${e.psk}`,"psk");let r=Gi[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"),ue(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.appendIfPresent(`,reuse=${e.reuse}`,"reuse"),t.toString()}function Nk(e){let t=new ot(e),r=e.type;(!e.token||e.token.length===0)&&(r="tuic-v5"),t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,uuid=${e.uuid}`,"uuid"),t.appendIfPresent(`,password="${e.password}"`,"password"),t.appendIfPresent(`,token=${e.token}`,"token"),t.appendIfPresent(`,alpn=${Array.isArray(e.alpn)?e.alpn[0]:e.alpn}`,"alpn"),ue(e,"ports")&&t.append(`,port-hopping="${e.ports.replace(/,/g,";")}"`),t.appendIfPresent(`,port-hopping-interval=${e["hop-interval"]}`,"hop-interval");let n=Gi[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${n}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),ue(e,"tfo")?t.append(`,tfo=${e.tfo}`):ue(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"),ue(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.appendIfPresent(`,ecn=${e.ecn}`,"ecn"),t.toString()}function Lk(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 ot(e);t.append(`# > WireGuard Proxy ${e.name} # ${e.name}=wireguard`),e["section-name"]=ar(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=Gi[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"),ue(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.append(` # > WireGuard Section ${e.name} [WireGuard ${e["section-name"]}] private-key = ${e["private-key"]}`),t.appendIfPresent(` self-ip = ${e.ip}`,"ip"),t.appendIfPresent(` self-ip-v6 = ${e.ipv6}`,"ipv6"),e.dns&&(Array.isArray(e.dns)&&(e.dns=e.dns.join(", ")),t.append(` dns-server = ${e.dns}`)),t.appendIfPresent(` mtu = ${e.mtu}`,"mtu"),r==="prefer-v6"&&t.append(` prefer-ipv6 = true`);let n=Array.isArray(e["allowed-ips"])?e["allowed-ips"].join(","):e["allowed-ips"],i=Array.isArray(e.reserved)?e.reserved.join("/"):e.reserved,a=e["preshared-key"]??e["pre-shared-key"],s={"public-key":e["public-key"],"allowed-ips":n?`"${n}"`:void 0,endpoint:`${e.server}:${e.port}`,keepalive:e["persistent-keepalive"]||e.keepalive,"client-id":i,"preshared-key":a};return t.append(` peer = (${Object.keys(s).filter(u=>s[u]!=null).map(u=>`${u} = ${s[u]}`).join(", ")})`),t.toString()}function Uk(e){let t=new ot(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=Gi[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"),ue(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function jk(e){if(e.obfs||e["obfs-password"])throw new Error("obfs is unsupported");let t=new ot(e);t.append(`${e.name}=hysteria2,${e.server},${e.port}`),t.appendIfPresent(`,password="${e.password}"`,"password"),ue(e,"ports")&&t.append(`,port-hopping="${e.ports.replace(/,/g,";")}"`),t.appendIfPresent(`,port-hopping-interval=${e["hop-interval"]}`,"hop-interval");let r=Gi[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),ue(e,"tfo")?t.append(`,tfo=${e.tfo}`):ue(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"),ue(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.appendIfPresent(`,download-bandwidth=${`${e.down}`.match(/\d+/)?.[0]||0}`,"down"),t.appendIfPresent(`,ecn=${e.ecn}`,"ecn"),t.toString()}function U_(e,t,r){if(ue(t,"network"))if(t.network==="ws"){if(e.append(",ws=true"),ue(t,"ws-opts")&&(e.appendIfPresent(`,ws-path=${t["ws-opts"].path}`,"ws-opts.path"),ue(t,"ws-opts.headers"))){let n=t["ws-opts"].headers,i=Object.keys(n).map(a=>{let s=n[a];return s=`"${s}"`,`${a}:${s}`}).join("|");ra(i)&&e.append(`,ws-headers=${i}`)}}else if(r&&["http"].includes(t.network))k.info(`Include Unsupported Proxy: network ${t.network} -> tcp`);else throw new Error(`network ${t.network} is unsupported`)}var Hk={dual:"dual","v4-only":"ipv4","v6-only":"ipv6","prefer-v4":"ipv4-prefer","prefer-v6":"ipv6-prefer"};function Yi(){return{type:"ALL",produce:(r,n,i={})=>{let a=r.filter(s=>i["include-unsupported-proxy"]?!0:s.type==="snell"&&s.version>=4||["juicity","naive"].includes(s.type)||["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)||["anytls"].includes(s.type)&&s.network&&(!["tcp"].includes(s.network)||["tcp"].includes(s.network)&&s["reality-opts"])?!1:!["xhttp"].includes(s.network)).map(s=>{if(s.type==="vmess"?(ue(s,"aead")&&(s.aead&&(s.alterId=0),delete s.aead),ue(s,"sni")&&(s.servername=s.sni,delete s.sni),ue(s,"cipher")&&!["auto","none","zero","aes-128-gcm","chacha20-poly1305"].includes(s.cipher)&&(s.cipher="auto")):s.type==="tuic"?(ue(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),ue(s,"tfo")&&!ue(s,"fast-open")&&(s["fast-open"]=s.tfo),(!s.token||s.token.length===0)&&!ue(s,"version")&&(s.version=5)):s.type==="hysteria"?(ue(s,"auth_str")&&!ue(s,"auth-str")&&(s["auth-str"]=s.auth_str),ue(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),ue(s,"tfo")&&!ue(s,"fast-open")&&(s["fast-open"]=s.tfo)):s.type==="wireguard"?(s.keepalive=s.keepalive??s["persistent-keepalive"],s["persistent-keepalive"]=s.keepalive,s["preshared-key"]=s["preshared-key"]??s["pre-shared-key"],s["pre-shared-key"]=s["preshared-key"]):s.type==="snell"&&s.version<3?delete s.udp:s.type==="vless"?ue(s,"sni")&&(s.servername=s.sni,delete s.sni):s.type==="ss"&&ue(s,"shadow-tls-password")&&!ue(s,"plugin")&&(s.plugin="shadow-tls",s["plugin-opts"]={host:s["shadow-tls-sni"],password:s["shadow-tls-password"],version:s["shadow-tls-version"]},delete s["shadow-tls-password"],delete s["shadow-tls-sni"],delete s["shadow-tls-version"]),["vmess","vless"].includes(s.type)&&s.network==="http"){let u=s["http-opts"]?.path;ue(s,"http-opts.path")&&!Array.isArray(u)&&(s["http-opts"].path=[u]);let l=s["http-opts"]?.headers?.Host;ue(s,"http-opts.headers.Host")&&!Array.isArray(l)&&(s["http-opts"].headers.Host=[l])}if(["vmess","vless"].includes(s.type)&&s.network==="h2"){let u=s["h2-opts"]?.path;ue(s,"h2-opts.path")&&Array.isArray(u)&&(s["h2-opts"].path=u[0]);let l=s["h2-opts"]?.headers?.host;ue(s,"h2-opts.headers.Host")&&!Array.isArray(l)&&(s["h2-opts"].headers.host=[l])}if(["ws"].includes(s.network)){let u=s[`${s.network}-opts`]?.path;if(u){let l=/^(.*?)(?:\?ed=(\d+))?$/,[f,d="",m=""]=l.exec(u);s[`${s.network}-opts`].path=d,m!==""&&(s["ws-opts"]["early-data-header-name"]="Sec-WebSocket-Protocol",s["ws-opts"]["max-early-data"]=parseInt(m,10))}else s[`${s.network}-opts`]=s[`${s.network}-opts`]||{},s[`${s.network}-opts`].path="/"}if(s["plugin-opts"]?.tls&&ue(s,"skip-cert-verify")&&(s["plugin-opts"]["skip-cert-verify"]=s["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls","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"],ue(s,"tls")&&typeof s.tls!="boolean"&&delete s.tls,delete s.subName,delete s.collectionName,delete s.id,delete s.resolved,delete s["no-resolve"],n!=="internal"||i["delete-underscore-fields"])for(let u in s)(s[u]==null||/^_/i.test(u))&&delete s[u];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"]=Hk[s["ip-version"]]||s["ip-version"]),s});return n==="internal"?a:`proxies: `+a.map(s=>" - "+JSON.stringify(s)+` `).join("")}}}var j_="SurgeMac",Mk=gc();function Fm(){return{produce:(t,r,n={})=>{switch(t.type){case"external":return H_(t);default:try{return Mk.produce(t,r,n)}catch{if(n.useMihomoExternal)return k.log(`${t.name} is not supported on ${j_}, try to use Mihomo(SurgeMac - External Proxy Program) instead`),qk(t,r,n);throw new Error("Surge for macOS \u53EF\u624B\u52A8\u6307\u5B9A\u94FE\u63A5\u53C2\u6570 target=SurgeMac \u6216\u5728 \u540C\u6B65\u914D\u7F6E \u4E2D\u6307\u5B9A SurgeMac \u6765\u542F\u7528 mihomo \u652F\u63F4 Surge \u672C\u8EAB\u4E0D\u652F\u6301\u7684\u534F\u8BAE")}}}}}function H_(e){let t=new ot(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"),ue(e,"tfo")?t.append(`,tfo=${e.tfo}`):ue(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 qk(e,t,r){let n=Yi().produce([e],"internal")?.[0];if(n){let i=r?.localPort||e._localPort||65535,a=!["ipv4","v4-only"].includes(e["ip-version"]),s={name:e.name,type:"external",exec:e._exec||"/usr/local/bin/mihomo","local-port":i,args:["-config",pt.encode(JSON.stringify({"mixed-port":i,ipv6:a,mode:"global",dns:{enable:!0,ipv6:a,"default-nameserver":r?.defaultNameserver||e._defaultNameserver||["180.76.76.76","52.80.52.52","119.28.28.28","223.6.6.6"],nameserver:r?.nameserver||e._nameserver||["https://doh.pub/dns-query","https://dns.alidns.com/dns-query","https://doh-pure.onedns.net/dns-query"]},proxies:[{...n,name:"proxy"}],"proxy-groups":[{name:"GLOBAL",type:"select",proxies:["proxy"]}]}))],addresses:[]};return Vk(e.server)?s.addresses.push(e.server):k.log(`Platform ${j_}, proxy type ${e.type}: addresses should be an IP address, but got ${e.server}`),r.localPort=i-1,H_(s)}}function Vk(e){return Mr(e)||Xr(e)}function Sm(){return{type:"ALL",produce:(r,n,i={})=>{let a=r.filter(s=>i["include-unsupported-proxy"]?!0:!["ss","ssr","vmess","vless","socks5","http","snell","trojan","wireguard"].includes(s.type)||s.type==="ss"&&!["aes-128-gcm","aes-192-gcm","aes-256-gcm","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","rc4-md5","chacha20-ietf","xchacha20","chacha20-ietf-poly1305","xchacha20-ietf-poly1305"].includes(s.cipher)||s.type==="snell"&&s.version>=4||s.type==="vless"&&(typeof s.flow<"u"||s["reality-opts"])?!1:s["underlying-proxy"]||s["dialer-proxy"]?(k.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"?(ue(s,"aead")&&(s.aead&&(s.alterId=0),delete s.aead),ue(s,"sni")&&(s.servername=s.sni,delete s.sni),ue(s,"cipher")&&!["auto","aes-128-gcm","chacha20-poly1305","none"].includes(s.cipher)&&(s.cipher="auto")):s.type==="wireguard"?(s.keepalive=s.keepalive??s["persistent-keepalive"],s["persistent-keepalive"]=s.keepalive,s["preshared-key"]=s["preshared-key"]??s["pre-shared-key"],s["pre-shared-key"]=s["preshared-key"]):s.type==="snell"&&s.version<3?delete s.udp:s.type==="vless"&&ue(s,"sni")&&(s.servername=s.sni,delete s.sni),["vmess","vless"].includes(s.type)&&s.network==="http"){let u=s["http-opts"]?.path;ue(s,"http-opts.path")&&!Array.isArray(u)&&(s["http-opts"].path=[u]);let l=s["http-opts"]?.headers?.Host;ue(s,"http-opts.headers.Host")&&!Array.isArray(l)&&(s["http-opts"].headers.Host=[l])}if(["vmess","vless"].includes(s.type)&&s.network==="h2"){let u=s["h2-opts"]?.path;ue(s,"h2-opts.path")&&Array.isArray(u)&&(s["h2-opts"].path=u[0]);let l=s["h2-opts"]?.headers?.host;ue(s,"h2-opts.headers.Host")&&!Array.isArray(l)&&(s["h2-opts"].headers.host=[l])}if(["ws"].includes(s.network)){let u=s[`${s.network}-opts`]?.path;if(u){let l=/^(.*?)(?:\?ed=(\d+))?$/,[f,d="",m=""]=l.exec(u);s[`${s.network}-opts`].path=d,m!==""&&(s["ws-opts"]["early-data-header-name"]="Sec-WebSocket-Protocol",s["ws-opts"]["max-early-data"]=parseInt(m,10))}else s[`${s.network}-opts`]=s[`${s.network}-opts`]||{},s[`${s.network}-opts`].path="/"}if(s["plugin-opts"]?.tls&&ue(s,"skip-cert-verify")&&(s["plugin-opts"]["skip-cert-verify"]=s["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls","naive"].includes(s.type)&&delete s.tls,s["tls-fingerprint"]&&(s.fingerprint=s["tls-fingerprint"]),delete s["tls-fingerprint"],ue(s,"tls")&&typeof s.tls!="boolean"&&delete s.tls,delete s.subName,delete s.collectionName,delete s.id,delete s.resolved,delete s["no-resolve"],n!=="internal")for(let u in s)(s[u]==null||/^_/i.test(u))&&delete s[u];return["grpc"].includes(s.network)&&s[`${s.network}-opts`]&&(delete s[`${s.network}-opts`]["_grpc-type"],delete s[`${s.network}-opts`]["_grpc-authority"]),s});return n==="internal"?a:`proxies: `+a.map(s=>" - "+JSON.stringify(s)+` `).join("")}}}function Nd(){return{type:"ALL",produce:(r,n,i={})=>{let a=r.filter(s=>!["ss","ssr","vmess","socks5","http","snell","trojan","tuic","vless","wireguard","hysteria","hysteria2","ssh","juicity"].includes(s.type)||s.type==="ss"&&!["aes-128-gcm","aes-192-gcm","aes-256-gcm","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","rc4-md5","chacha20-ietf","xchacha20","chacha20-ietf-poly1305","xchacha20-ietf-poly1305","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"].includes(s.cipher)||s.type==="snell"&&s.version>=4||s.type==="vless"&&s["reality-opts"]&&!["xtls-rprx-vision"].includes(s.flow)?!1:s["underlying-proxy"]||s["dialer-proxy"]?(k.error(`Stash \u6682\u4E0D\u652F\u6301\u524D\u7F6E\u4EE3\u7406\u5B57\u6BB5. \u5DF2\u8FC7\u6EE4\u8282\u70B9 ${s.name}. \u8BF7\u4F7F\u7528 \u4EE3\u7406\u7684\u8F6C\u53D1\u94FE https://stash.wiki/proxy-protocols/proxy-groups#relay`),!1):!0).map(s=>{if(s.type==="vmess"?(ue(s,"aead")&&(s.aead&&(s.alterId=0),delete s.aead),ue(s,"sni")&&(s.servername=s.sni,delete s.sni),ue(s,"cipher")&&!["auto","aes-128-gcm","chacha20-poly1305","none"].includes(s.cipher)&&(s.cipher="auto")):s.type==="tuic"?(ue(s,"alpn")?s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]:s.alpn=["h3"],ue(s,"tfo")&&!ue(s,"fast-open")&&(s["fast-open"]=s.tfo,delete s.tfo),(!s.token||s.token.length===0)&&!ue(s,"version")&&(s.version=5)):s.type==="hysteria"?(ue(s,"auth_str")&&!ue(s,"auth-str")&&(s["auth-str"]=s.auth_str),ue(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),ue(s,"tfo")&&!ue(s,"fast-open")&&(s["fast-open"]=s.tfo,delete s.tfo),ue(s,"down")&&!ue(s,"down-speed")&&(s["down-speed"]=s.down,delete s.down),ue(s,"up")&&!ue(s,"up-speed")&&(s["up-speed"]=s.up,delete s.up),ue(s,"down-speed")&&(s["down-speed"]=`${s["down-speed"]}`.match(/\d+/)?.[0]||0),ue(s,"up-speed")&&(s["up-speed"]=`${s["up-speed"]}`.match(/\d+/)?.[0]||0)):s.type==="hysteria2"?(ue(s,"password")&&!ue(s,"auth")&&(s.auth=s.password,delete s.password),ue(s,"tfo")&&!ue(s,"fast-open")&&(s["fast-open"]=s.tfo,delete s.tfo),ue(s,"down")&&!ue(s,"down-speed")&&(s["down-speed"]=s.down,delete s.down),ue(s,"up")&&!ue(s,"up-speed")&&(s["up-speed"]=s.up,delete s.up),ue(s,"down-speed")&&(s["down-speed"]=`${s["down-speed"]}`.match(/\d+/)?.[0]||0),ue(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"&&ue(s,"sni")&&(s.servername=s.sni,delete s.sni),["vmess","vless"].includes(s.type)&&s.network==="http"){let u=s["http-opts"]?.path;ue(s,"http-opts.path")&&!Array.isArray(u)&&(s["http-opts"].path=[u]);let l=s["http-opts"]?.headers?.Host;ue(s,"http-opts.headers.Host")&&!Array.isArray(l)&&(s["http-opts"].headers.Host=[l])}if(["vmess","vless"].includes(s.type)&&s.network==="h2"){let u=s["h2-opts"]?.path;ue(s,"h2-opts.path")&&Array.isArray(u)&&(s["h2-opts"].path=u[0]);let l=s["h2-opts"]?.headers?.host;ue(s,"h2-opts.headers.Host")&&!Array.isArray(l)&&(s["h2-opts"].headers.host=[l])}if(["ws"].includes(s.network)){let u=s[`${s.network}-opts`]?.path;if(u){let l=/^(.*?)(?:\?ed=(\d+))?$/,[f,d="",m=""]=l.exec(u);s[`${s.network}-opts`].path=d,m!==""&&(s["ws-opts"]["early-data-header-name"]="Sec-WebSocket-Protocol",s["ws-opts"]["max-early-data"]=parseInt(m,10))}else s[`${s.network}-opts`]=s[`${s.network}-opts`]||{},s[`${s.network}-opts`].path="/"}if(s["plugin-opts"]?.tls&&ue(s,"skip-cert-verify")&&(s["plugin-opts"]["skip-cert-verify"]=s["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls","naive"].includes(s.type)&&delete s.tls,s["tls-fingerprint"]&&(s["server-cert-fingerprint"]=s["tls-fingerprint"]),delete s["tls-fingerprint"],ue(s,"tls")&&typeof s.tls!="boolean"&&delete s.tls,s["test-url"]&&(s["benchmark-url"]=s["test-url"],delete s["test-url"]),s["test-timeout"]&&(s["benchmark-timeout"]=s["test-timeout"],delete s["test-timeout"]),delete s.subName,delete s.collectionName,delete s.id,delete s.resolved,delete s["no-resolve"],n!=="internal")for(let u in s)(s[u]==null||/^_/i.test(u))&&delete s[u];return["grpc"].includes(s.network)&&s[`${s.network}-opts`]&&(delete s[`${s.network}-opts`]["_grpc-type"],delete s[`${s.network}-opts`]["_grpc-authority"]),s});return n==="internal"?a:`proxies: `+a.map(s=>" - "+JSON.stringify(s)+` `).join("")}}}var Kk="Loon",pu={dual:"dual",ipv4:"v4-only",ipv6:"v6-only","ipv4-prefer":"prefer-v4","ipv6-prefer":"prefer-v6"};function Im(){return{produce:(t,r,n={})=>{switch(t.type){case"ss":return zk(t);case"ssr":return Gk(t);case"trojan":return Yk(t);case"vmess":return Wk(t,n["include-unsupported-proxy"]);case"vless":return Xk(t,n["include-unsupported-proxy"]);case"http":return Jk(t);case"socks5":return Zk(t);case"wireguard":return Qk(t);case"hysteria2":return eN(t)}throw new Error(`Platform ${Kk} does not support proxy type: ${t.type}`)}}}function zk(e){let t=new ot(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}"`),ue(e,"plugin")){if(e.plugin==="obfs"){if(e["plugin-opts"]?.mode&&e.cipher.startsWith("2022-"))throw new Error(`${e.cipher} ${e.plugin} is not supported`);t.append(`,obfs-name=${e["plugin-opts"].mode}`),t.appendIfPresent(`,obfs-host=${e["plugin-opts"].host}`,"plugin-opts.host"),t.appendIfPresent(`,obfs-uri=${e["plugin-opts"].path}`,"plugin-opts.path")}else if(!["shadow-tls"].includes(e.plugin))throw new Error(`plugin ${e.plugin} is not supported`)}if(ue(e,"shadow-tls-password"))t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni"),t.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port");else if(["shadow-tls"].includes(e.plugin)&&e["plugin-opts"]){let n=e["plugin-opts"].password,i=e["plugin-opts"].host,a=e["plugin-opts"].version;if(n){if(t.append(`,shadow-tls-password=${n}`),i&&t.append(`,shadow-tls-sni=${i}`),a){if(a<2)throw new Error(`shadow-tls version ${a} is not supported`);t.append(`,shadow-tls-version=${a}`)}t.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port")}}t.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e["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=pu[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function Gk(e){let t=new ot(e);if(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"),ue(e,"shadow-tls-password"))t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni"),t.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port");else if(["shadow-tls"].includes(e.plugin)&&e["plugin-opts"]){let n=e["plugin-opts"].password,i=e["plugin-opts"].host,a=e["plugin-opts"].version;if(n){if(t.append(`,shadow-tls-password=${n}`),i&&t.append(`,shadow-tls-sni=${i}`),a){if(a<2)throw new Error(`shadow-tls version ${a} is not supported`);t.append(`,shadow-tls-version=${a}`)}t.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port")}}t.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e["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=pu[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function Yk(e){let t=new ot(e);if(t.append(`${e.name}=trojan,${e.server},${e.port},"${e.password}"`),e.network==="tcp"&&delete e.network,ue(e,"network"))if(e.network==="ws")t.append(",transport=ws"),t.appendIfPresent(`,path=${e["ws-opts"]?.path}`,"ws-opts.path"),t.appendIfPresent(`,host=${e["ws-opts"]?.headers?.Host}`,"ws-opts.headers.Host");else throw new Error(`network ${e.network} is unsupported`);t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tls-name=${e.sni}`,"sni"),t.appendIfPresent(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),t.appendIfPresent(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),t.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e["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=pu[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function Wk(e){let t=!!e["reality-opts"],r=new ot(e);if(r.append(`${e.name}=vmess,${e.server},${e.port},${e.cipher},"${e.uuid}"`),e.network==="tcp"&&delete e.network,ue(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 if(e.network==="http"){r.append(",transport=http");let i=e["http-opts"]?.path,a=e["http-opts"]?.headers?.Host;r.appendIfPresent(`,path=${Array.isArray(i)?i[0]:i}`,"http-opts.path"),r.appendIfPresent(`,host=${Array.isArray(a)?a[0]:a}`,"http-opts.headers.Host")}else throw new Error(`network ${e.network} is unsupported`);else r.append(",transport=tcp");r.appendIfPresent(`,over-tls=${e.tls}`,"tls"),r.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t?(r.appendIfPresent(`,sni=${e.sni}`,"sni"),r.appendIfPresent(`,public-key="${e["reality-opts"]["public-key"]}"`,"reality-opts.public-key"),r.appendIfPresent(`,short-id=${e["reality-opts"]["short-id"]}`,"reality-opts.short-id")):(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")),ue(e,"aead")?r.append(`,alterId=${e.aead?0:1}`):r.append(`,alterId=${e.alterId}`),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=pu[e["ip-version"]]||e["ip-version"];return r.appendIfPresent(`,ip-mode=${n}`,"ip-version"),r.toString()}function Xk(e){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 ot(e);if(n.append(`${e.name}=vless,${e.server},${e.port},"${e.uuid}"`),e.network==="tcp"&&delete e.network,ue(e,"network"))if(e.network==="ws")n.append(",transport=ws"),n.appendIfPresent(`,path=${e["ws-opts"]?.path}`,"ws-opts.path"),n.appendIfPresent(`,host=${e["ws-opts"]?.headers?.Host}`,"ws-opts.headers.Host");else if(e.network==="http"){n.append(",transport=http");let a=e["http-opts"]?.path,s=e["http-opts"]?.headers?.Host;n.appendIfPresent(`,path=${Array.isArray(a)?a[0]:a}`,"http-opts.path"),n.appendIfPresent(`,host=${Array.isArray(s)?s[0]:s}`,"http-opts.headers.Host")}else throw new Error(`network ${e.network} is unsupported`);else n.append(",transport=tcp");n.appendIfPresent(`,over-tls=${e.tls}`,"tls"),n.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t&&n.appendIfPresent(`,flow=${e.flow}`,"flow"),r?(n.appendIfPresent(`,sni=${e.sni}`,"sni"),n.appendIfPresent(`,public-key="${e["reality-opts"]["public-key"]}"`,"reality-opts.public-key"),n.appendIfPresent(`,short-id=${e["reality-opts"]["short-id"]}`,"reality-opts.short-id")):(n.appendIfPresent(`,tls-name=${e.sni}`,"sni"),n.appendIfPresent(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),n.appendIfPresent(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256")),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=pu[e["ip-version"]]||e["ip-version"];return n.appendIfPresent(`,ip-mode=${i}`,"ip-version"),n.toString()}function Jk(e){let t=new ot(e),r=e.tls?"https":"http";t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,${e.username}`,"username"),t.appendIfPresent(`,"${e.password}"`,"password"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),e["block-quic"]==="on"?t.append(",block-quic=true"):e["block-quic"]==="off"&&t.append(",block-quic=false");let n=pu[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${n}`,"ip-version"),t.toString()}function Zk(e){let t=new ot(e);t.append(`${e.name}=socks5,${e.server},${e.port}`),t.appendIfPresent(`,${e.username}`,"username"),t.appendIfPresent(`,"${e.password}"`,"password"),t.appendIfPresent(`,over-tls=${e.tls}`,"tls"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),e["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=pu[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function Qk(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 ot(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(u=>Xr(u));let s=e.dns.find(u=>Mr(u));s||(s=e.dns.find(u=>!Mr(u)&&!Xr(u))),e.dns=s}t.appendIfPresent(`,dns=${e.dns}`,"dns"),t.appendIfPresent(`,dnsv6=${e.dnsv6}`,"dnsv6"),t.appendIfPresent(`,keepalive=${e["persistent-keepalive"]}`,"persistent-keepalive"),t.appendIfPresent(`,keepalive=${e.keepalive}`,"keepalive");let r=Array.isArray(e["allowed-ips"])?e["allowed-ips"].join(","):e["allowed-ips"],n=Array.isArray(e.reserved)?e.reserved.join(","):e.reserved;n&&(n=`,reserved=[${n}]`);let i=e["preshared-key"]??e["pre-shared-key"];i&&(i=`,preshared-key="${i}"`),t.append(`,peers=[{public-key="${e["public-key"]}",allowed-ips="${r??"0.0.0.0/0,::/0"}",endpoint=${e.server}:${e.port}${n??""}${i??""}}]`);let a=pu[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${a}`,"ip-version"),e["block-quic"]==="on"?t.append(",block-quic=true"):e["block-quic"]==="off"&&t.append(",block-quic=false"),t.toString()}function eN(e){if(e["obfs-password"]&&e.obfs!="salamander")throw new Error("only salamander obfs is supported");let t=new ot(e);t.append(`${e.name}=Hysteria2,${e.server},${e.port}`),t.appendIfPresent(`,"${e.password}"`,"password"),t.appendIfPresent(`,tls-name=${e.sni}`,"sni"),t.appendIfPresent(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),t.appendIfPresent(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),e["obfs-password"]&&e.obfs=="salamander"&&t.append(`,salamander-password=${e["obfs-password"]}`),t.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e["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=pu[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}var YW=_n(ID());function BD(e){let t="none",r=e["reality-opts"],n="",i="",a="";if(r){t="reality";let C=e["reality-opts"]?.["public-key"];C&&(i=`&pbk=${encodeURIComponent(C)}`);let F=e["reality-opts"]?.["short-id"];F&&(n=`&sid=${encodeURIComponent(F)}`);let U=e["reality-opts"]?.["_spider-x"];U&&(a=`&spx=${encodeURIComponent(U)}`)}else e.tls&&(t="tls");let s="";e.alpn&&(s=`&alpn=${encodeURIComponent(Array.isArray(e.alpn)?e.alpn:e.alpn.join(","))}`);let u="";e["skip-cert-verify"]&&(u="&allowInsecure=1");let l="";e.sni&&(l=`&sni=${encodeURIComponent(e.sni)}`);let f="";e["client-fingerprint"]&&(f=`&fp=${encodeURIComponent(e["client-fingerprint"])}`);let d="";e.flow&&(d=`&flow=${encodeURIComponent(e.flow)}`);let m="";e._extra&&(m=`&extra=${encodeURIComponent(e._extra)}`);let p="";e._mode&&(p=`&mode=${encodeURIComponent(e._mode)}`);let h="";e._pqv&&(h=`&pqv=${encodeURIComponent(e._pqv)}`);let w="";e.encryption&&(w=`&encryption=${encodeURIComponent(e.encryption)}`);let v=e.network;e.network==="ws"&&e["ws-opts"]?.["v2ray-http-upgrade"]&&(v="httpupgrade");let y=`&type=${encodeURIComponent(v)}`;if(["grpc"].includes(e.network)){y+=`&mode=${encodeURIComponent(e[`${e.network}-opts`]?.["_grpc-type"]||"gun")}`;let C=e[`${e.network}-opts`]?.["_grpc-authority"];C&&(y+=`&authority=${encodeURIComponent(C)}`)}let g=e[`${e.network}-opts`]?.[`${e.network}-service-name`],b=e[`${e.network}-opts`]?.path,D=e[`${e.network}-opts`]?.headers?.Host;return b&&(y+=`&path=${encodeURIComponent(Array.isArray(b)?b[0]:b)}`),D&&(y+=`&host=${encodeURIComponent(Array.isArray(D)?D[0]:D)}`),g&&(y+=`&serviceName=${encodeURIComponent(g)}`),e.network==="kcp"&&(e.seed&&(y+=`&seed=${encodeURIComponent(e.seed)}`),e.headerType&&(y+=`&headerType=${encodeURIComponent(e.headerType)}`)),`vless://${e.uuid}@${e.server}:${e.port}?security=${encodeURIComponent(t)}${y}${s}${u}${l}${f}${d}${n}${a}${i}${p}${m}${h}${w}#${encodeURIComponent(e.name)}`}function Hc(){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(["trojan","tuic","hysteria","hysteria2","juicity","anytls"].includes(r.type)&&delete r.tls,!["vmess"].includes(r.type)&&r.server&&Xr(r.server)&&(r.server=`[${r.server}]`),r.type){case"socks5":n=`socks://${encodeURIComponent(pt.encode(`${r.username??""}:${r.password??""}`))}@${r.server}:${r.port}#${r.name}`;break;case"ss":let i=`${r.cipher}:${r.password}`;if(n=`ss://${r.cipher?.startsWith("2022-blake3-")?`${encodeURIComponent(r.cipher)}:${encodeURIComponent(r.password)}`:pt.encode(i)}@${r.server}:${r.port}${r.plugin?"/":""}`,r.plugin){n+="?plugin=";let x=r["plugin-opts"];switch(r.plugin){case"obfs":n+=encodeURIComponent(`simple-obfs;obfs=${x.mode}${x.host?";obfs-host="+x.host:""}`);break;case"v2ray-plugin":n+=encodeURIComponent(`v2ray-plugin;obfs=${x.mode}${x.host?";obfs-host"+x.host:""}${x.tls?";tls":""}`);break;case"shadow-tls":n+=encodeURIComponent(`shadow-tls;host=${x.host};password=${x.password};version=${x.version}`);break;default:throw new Error(`Unsupported plugin option: ${r.plugin}`)}}r["udp-over-tcp"]&&(n=`${n}${r.plugin?"&":"?"}uot=1`),r.tfo&&(n=`${n}${r.plugin||r["udp-over-tcp"]?"&":"?"}tfo=1`),n+=`#${encodeURIComponent(r.name)}`;break;case"ssr":n=`${r.server}:${r.port}:${r.protocol}:${r.cipher}:${r.obfs}:${pt.encode(r.password)}/`,n+=`?remarks=${pt.encode(r.name)}${r["obfs-param"]?"&obfsparam="+pt.encode(r["obfs-param"]):""}${r["protocol-param"]?"&protocolparam="+pt.encode(r["protocol-param"]):""}`,n="ssr://"+pt.encode(n);break;case"vmess":let a="",s=r.network||"tcp";if(r.network==="http"?(s="tcp",a="http"):r.network==="ws"&&r["ws-opts"]?.["v2ray-http-upgrade"]&&(s="httpupgrade"),n={v:"2",ps:r.name,add:r.server,port:`${r.port}`,id:r.uuid,aid:`${r.alterId||0}`,scy:r.cipher,net:s,type:a,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 x=r[`${r.network}-opts`]?.path,j=r[`${r.network}-opts`]?.headers?.Host;["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`]):(x&&(n.path=Array.isArray(x)?x[0]:x),j&&(n.host=Array.isArray(j)?j[0]:j))}n="vmess://"+pt.encode(JSON.stringify(n));break;case"vless":n=BD(r);break;case"trojan":let u="";if(r.network){let x=r.network;if(r.network==="ws"&&r["ws-opts"]?.["v2ray-http-upgrade"]&&(x="httpupgrade"),u=`&type=${encodeURIComponent(x)}`,["grpc"].includes(r.network)){let M=r[`${r.network}-opts`]?.[`${r.network}-service-name`],z=r[`${r.network}-opts`]?.["_grpc-authority"];M&&(u+=`&serviceName=${encodeURIComponent(M)}`),z&&(u+=`&authority=${encodeURIComponent(z)}`),u+=`&mode=${encodeURIComponent(r[`${r.network}-opts`]?.["_grpc-type"]||"gun")}`}let j=r[`${r.network}-opts`]?.path,Y=r[`${r.network}-opts`]?.headers?.Host;j&&(u+=`&path=${encodeURIComponent(Array.isArray(j)?j[0]:j)}`),Y&&(u+=`&host=${encodeURIComponent(Array.isArray(Y)?Y[0]:Y)}`)}let l="";r["client-fingerprint"]&&(l=`&fp=${encodeURIComponent(r["client-fingerprint"])}`);let f="";r.alpn&&(f=`&alpn=${encodeURIComponent(Array.isArray(r.alpn)?r.alpn:r.alpn.join(","))}`);let d=r["reality-opts"],m="",p="",h="",w="",v="",y="";if(d){w="&security=reality";let x=r["reality-opts"]?.["public-key"];x&&(p=`&pbk=${encodeURIComponent(x)}`);let j=r["reality-opts"]?.["short-id"];j&&(m=`&sid=${encodeURIComponent(j)}`);let Y=r["reality-opts"]?.["_spider-x"];Y&&(h=`&spx=${encodeURIComponent(Y)}`),r._extra&&(y=`&extra=${encodeURIComponent(r._extra)}`),r._mode&&(v=`&mode=${encodeURIComponent(r._mode)}`)}n=`trojan://${r.password}@${r.server}:${r.port}?sni=${encodeURIComponent(r.sni||r.server)}${r["skip-cert-verify"]?"&allowInsecure=1":""}${u}${f}${l}${w}${m}${p}${h}${v}${y}#${encodeURIComponent(r.name)}`;break;case"hysteria2":let g=[];r["hop-interval"]&&g.push(`hop-interval=${r["hop-interval"]}`),r.keepalive&&g.push(`keepalive=${r.keepalive}`),r["skip-cert-verify"]&&g.push("insecure=1"),r.obfs&&(g.push(`obfs=${encodeURIComponent(r.obfs)}`),r["obfs-password"]&&g.push(`obfs-password=${encodeURIComponent(r["obfs-password"])}`)),r.sni&&g.push(`sni=${encodeURIComponent(r.sni)}`),r.ports&&g.push(`mport=${r.ports}`),r["tls-fingerprint"]&&g.push(`pinSHA256=${encodeURIComponent(r["tls-fingerprint"])}`),r.tfo&&g.push("fastopen=1"),n=`hysteria2://${encodeURIComponent(r.password)}@${r.server}:${r.port}?${g.join("&")}#${encodeURIComponent(r.name)}`;break;case"hysteria":let b=[];Object.keys(r).forEach(x=>{if(!["name","type","server","port"].includes(x)){let j=x.replace(/-/,"_");["alpn"].includes(x)?r[x]&&b.push(`${j}=${encodeURIComponent(Array.isArray(r[x])?r[x][0]:r[x])}`):["skip-cert-verify"].includes(x)?r[x]&&b.push("insecure=1"):["tfo","fast-open"].includes(x)?r[x]&&!b.includes("fastopen=1")&&b.push("fastopen=1"):["ports"].includes(x)?b.push(`mport=${r[x]}`):["auth-str"].includes(x)?b.push(`auth=${r[x]}`):["up"].includes(x)?b.push(`upmbps=${r[x]}`):["down"].includes(x)?b.push(`downmbps=${r[x]}`):["_obfs"].includes(x)?b.push(`obfs=${r[x]}`):["obfs"].includes(x)?b.push(`obfsParam=${r[x]}`):["sni"].includes(x)?b.push(`peer=${r[x]}`):r[x]&&!/^_/i.test(x)&&b.push(`${j}=${encodeURIComponent(r[x])}`)}}),n=`hysteria://${r.server}:${r.port}?${b.join("&")}#${encodeURIComponent(r.name)}`;break;case"tuic":if(!r.token||r.token.length===0){let x=[];Object.keys(r).forEach(j=>{if(!["name","type","uuid","password","server","port","tls"].includes(j)){let Y=j.replace(/-/,"_");["alpn"].includes(j)?r[j]&&x.push(`${Y}=${encodeURIComponent(Array.isArray(r[j])?r[j][0]:r[j])}`):["skip-cert-verify"].includes(j)?r[j]&&x.push("allow_insecure=1"):["tfo","fast-open"].includes(j)?r[j]&&!x.includes("fast_open=1")&&x.push("fast_open=1"):["disable-sni","reduce-rtt"].includes(j)&&r[j]?x.push(`${Y.replace(/-/g,"_")}=1`):["congestion-controller"].includes(j)?x.push(`congestion_control=${r[j]}`):r[j]&&!/^_/i.test(j)&&x.push(`${Y.replace(/-/g,"_")}=${encodeURIComponent(r[j])}`)}}),n=`tuic://${encodeURIComponent(r.uuid)}:${encodeURIComponent(r.password)}@${r.server}:${r.port}?${x.join("&")}#${encodeURIComponent(r.name)}`}break;case"anytls":n=BD({...r,uuid:r.password,network:r.network||"tcp"}).replace("vless","anytls");let D=[];Object.keys(r).forEach(x=>{if(!["name","type","password","server","port","tls"].includes(x)){let j=x.replace(/-/,"_");["alpn"].includes(x)?r[x]&&D.push(`${j}=${encodeURIComponent(Array.isArray(r[x])?r[x][0]:r[x])}`):["skip-cert-verify"].includes(x)?r[x]&&D.push("insecure=1"):["udp"].includes(x)?r[x]&&D.push("udp=1"):r[x]&&!/^_|client-fingerprint/i.test(x)&&["number","string","boolean"].includes(typeof r[x])&&D.push(`${j.replace(/-/g,"_")}=${encodeURIComponent(r[x])}`)}});let C=n.split("?"),F=C[0],U={};C.length>1&&C[1].split("#")[0].split("&").forEach(Y=>{let[M,z]=Y.split("=");M&&(U[M]=z)}),D.forEach(x=>{let[j,Y]=x.split("=");j&&(U[j]=Y)});let L=Object.keys(U).map(x=>`${x}=${U[x]}`).join("&"),S=n.match(/#(.*)$/),B=S?`#${S[1]}`:"";n=`${F}?${L}${B}`;break;case"wireguard":let O=[];Object.keys(r).forEach(x=>{["name","type","server","port","ip","ipv6","private-key"].includes(x)||(["public-key"].includes(x)?O.push(`publickey=${r[x]}`):["udp"].includes(x)?r[x]&&O.push(`${x}=1`):r[x]&&!/^_/i.test(x)&&O.push(`${x}=${encodeURIComponent(r[x])}`))}),r.ip&&r.ipv6?O.push(`address=${r.ip}/32,${r.ipv6}/128`):r.ip?O.push(`address=${r.ip}/32`):r.ipv6&&O.push(`address=${r.ipv6}/128`),n=`wireguard://${encodeURIComponent(r["private-key"])}@${r.server}:${r.port}/?${O.join("&")}#${encodeURIComponent(r.name)}`;break}return n}}}var vM=Hc();function Ch(){return{type:"ALL",produce:r=>{let n=[];return r.map(i=>{try{n.push(vM.produce(i))}catch(a){k.error(`Cannot produce proxy: ${JSON.stringify(i,null,2)} Reason: ${a}`)}}),pt.encode(n.join(` `))}}}var E2="QX";function Dh(){let e=(t,r,n={})=>{switch(t.type){case"ss":return wM(t);case"ssr":return AM(t);case"trojan":return EM(t);case"vmess":return bM(t);case"http":return _M(t);case"socks5":return CM(t);case"vless":return yM(t)}throw new Error(`Platform ${E2} does not support proxy type: ${t.type}`)};return{produce:(t,r,n={})=>{console.log(n);let i=e(t,r,n);if(n["include-unsupported-proxy"]){if(t.flow==="xtls-rprx-vision")throw new Error(`Platform ${E2} does not support flow ${t.flow}`);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"]}`))}else if(typeof t.flow<"u"||t["reality-opts"])throw new Error(`Platform ${E2} does not support XTLS/REALITY`);return i}}}function wM(e){let t=new ot(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t);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}`),Ji(e)&&(e.tls=!0),ue(e,"plugin")){if(e.plugin==="obfs"){let i=e["plugin-opts"];r(`,obfs=${i.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 Ji(e)&&(n(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),n(`,tls-alpn=${e["tls-alpn"]}`,"tls-alpn"),n(`,tls-no-session-ticket=${e["tls-no-session-ticket"]}`,"tls-no-session-ticket"),n(`,tls-no-session-reuse=${e["tls-no-session-reuse"]}`,"tls-no-session-reuse"),n(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),n(`,tls-verification=${!e["skip-cert-verify"]}`,"skip-cert-verify"),n(`,tls-host=${e.sni}`,"sni")),n(`,fast-open=${e.tfo}`,"tfo"),n(`,udp-relay=${e.udp}`,"udp"),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 AM(e){let t=new ot(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 EM(e){let t=new ot(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t);if(r(`trojan=${e.server}:${e.port}`),r(`,password=${e.password}`),ue(e,"network"))if(e.network==="ws")Ji(e)?r(",obfs=wss"):r(",obfs=ws"),n(`,obfs-uri=${e["ws-opts"]?.path}`,"ws-opts.path"),n(`,obfs-host=${e["ws-opts"]?.headers?.Host}`,"ws-opts.headers.Host");else throw new Error(`network ${e.network} is unsupported`);return e.network!=="ws"&&Ji(e)&&r(",over-tls=true"),Ji(e)&&(n(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),n(`,tls-alpn=${e["tls-alpn"]}`,"tls-alpn"),n(`,tls-no-session-ticket=${e["tls-no-session-ticket"]}`,"tls-no-session-ticket"),n(`,tls-no-session-reuse=${e["tls-no-session-reuse"]}`,"tls-no-session-reuse"),n(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),n(`,tls-verification=${!e["skip-cert-verify"]}`,"skip-cert-verify"),n(`,tls-host=${e.sni}`,"sni")),n(`,fast-open=${e.tfo}`,"tfo"),n(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,server_check_url=${e["test-url"]}`,"test-url"),r(`,tag=${e.name}`),t.toString()}function bM(e){let t=new ot(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t);r(`vmess=${e.server}:${e.port}`);let i;if(e.cipher==="auto"?i="chacha20-ietf-poly1305":i=e.cipher,r(`,method=${i}`),r(`,password=${e.uuid}`),Ji(e)&&(e.tls=!0),ue(e,"network")){if(e.network==="ws")e.tls?r(",obfs=wss"):r(",obfs=ws");else if(e.network==="http")r(",obfs=http");else throw new Error(`network ${e.network} is unsupported`);let a=e[`${e.network}-opts`]?.path,s=e[`${e.network}-opts`]?.headers?.Host;n(`,obfs-uri=${Array.isArray(a)?a[0]:a}`,`${e.network}-opts.path`),n(`,obfs-host=${Array.isArray(s)?s[0]:s}`,`${e.network}-opts.headers.Host`)}else e.tls&&r(",obfs=over-tls");return Ji(e)&&(n(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),n(`,tls-alpn=${e["tls-alpn"]}`,"tls-alpn"),n(`,tls-no-session-ticket=${e["tls-no-session-ticket"]}`,"tls-no-session-ticket"),n(`,tls-no-session-reuse=${e["tls-no-session-reuse"]}`,"tls-no-session-reuse"),n(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),n(`,tls-verification=${!e["skip-cert-verify"]}`,"skip-cert-verify"),n(`,tls-host=${e.sni}`,"sni")),ue(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 yM(e){let t=new ot(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}`),Ji(e)&&(e.tls=!0),ue(e,"network")){if(e.network==="ws")e.tls?r(",obfs=wss"):r(",obfs=ws");else if(e.network==="http")r(",obfs=http");else if(["tcp"].includes(e.network))e.tls&&r(",obfs=over-tls");else if(!["tcp"].includes(e.network))throw new Error(`network ${e.network} is unsupported`);let a=e[`${e.network}-opts`]?.path,s=e[`${e.network}-opts`]?.headers?.Host;n(`,obfs-uri=${Array.isArray(a)?a[0]:a}`,`${e.network}-opts.path`),n(`,obfs-host=${Array.isArray(s)?s[0]:s}`,`${e.network}-opts.headers.Host`)}else e.tls&&r(",obfs=over-tls");return Ji(e)&&(n(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),n(`,tls-alpn=${e["tls-alpn"]}`,"tls-alpn"),n(`,tls-no-session-ticket=${e["tls-no-session-ticket"]}`,"tls-no-session-ticket"),n(`,tls-no-session-reuse=${e["tls-no-session-reuse"]}`,"tls-no-session-reuse"),n(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),n(`,tls-verification=${!e["skip-cert-verify"]}`,"skip-cert-verify"),n(`,tls-host=${e.sni}`,"sni")),n(`,fast-open=${e.tfo}`,"tfo"),n(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,server_check_url=${e["test-url"]}`,"test-url"),r(`,tag=${e.name}`),t.toString()}function _M(e){let t=new ot(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"),Ji(e)&&(e.tls=!0),n(`,over-tls=${e.tls}`,"tls"),Ji(e)&&(n(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),n(`,tls-alpn=${e["tls-alpn"]}`,"tls-alpn"),n(`,tls-no-session-ticket=${e["tls-no-session-ticket"]}`,"tls-no-session-ticket"),n(`,tls-no-session-reuse=${e["tls-no-session-reuse"]}`,"tls-no-session-reuse"),n(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),n(`,tls-verification=${!e["skip-cert-verify"]}`,"skip-cert-verify"),n(`,tls-host=${e.sni}`,"sni")),n(`,fast-open=${e.tfo}`,"tfo"),n(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,server_check_url=${e["test-url"]}`,"test-url"),r(`,tag=${e.name}`),t.toString()}function CM(e){let t=new ot(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"),Ji(e)&&(e.tls=!0),n(`,over-tls=${e.tls}`,"tls"),Ji(e)&&(n(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),n(`,tls-alpn=${e["tls-alpn"]}`,"tls-alpn"),n(`,tls-no-session-ticket=${e["tls-no-session-ticket"]}`,"tls-no-session-ticket"),n(`,tls-no-session-reuse=${e["tls-no-session-reuse"]}`,"tls-no-session-reuse"),n(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),n(`,tls-verification=${!e["skip-cert-verify"]}`,"skip-cert-verify"),n(`,tls-host=${e.sni}`,"sni")),n(`,fast-open=${e.tfo}`,"tfo"),n(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,server_check_url=${e["test-url"]}`,"test-url"),r(`,tag=${e.name}`),t.toString()}function Ji(e){return e.tls}function Fh(){return{type:"ALL",produce:(r,n,i={})=>{let a=r.filter(s=>i["include-unsupported-proxy"]?!0:s.type==="snell"&&s.version>=4?!1:!["mieru","sudoku","naive"].includes(s.type)).map(s=>{if(s.type==="vmess")ue(s,"aead")&&(s.aead&&(s.alterId=0),delete s.aead),ue(s,"sni")&&(s.servername=s.sni,delete s.sni),ue(s,"cipher")&&!["auto","none","zero","aes-128-gcm","chacha20-poly1305"].includes(s.cipher)&&(s.cipher="auto");else if(s.type==="tuic")ue(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),ue(s,"tfo")&&!ue(s,"fast-open")&&(s["fast-open"]=s.tfo),(!s.token||s.token.length===0)&&!ue(s,"version")&&(s.version=5);else if(s.type==="hysteria")ue(s,"auth_str")&&!ue(s,"auth-str")&&(s["auth-str"]=s.auth_str),ue(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),ue(s,"tfo")&&!ue(s,"fast-open")&&(s["fast-open"]=s.tfo);else if(s.type==="hysteria2")ue(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),ue(s,"tfo")&&!ue(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"];else if(s.type==="snell"&&s.version<3)delete s.udp;else if(s.type==="vless")ue(s,"sni")&&(s.servername=s.sni,delete s.sni);else if(s.type==="ss")ue(s,"shadow-tls-password")&&!ue(s,"plugin")&&(s.plugin="shadow-tls",s["plugin-opts"]={host:s["shadow-tls-sni"],password:s["shadow-tls-password"],version:s["shadow-tls-version"]},delete s["shadow-tls-password"],delete s["shadow-tls-sni"],delete s["shadow-tls-version"]);else{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(["vmess","vless"].includes(s.type)&&s.network==="http"){let u=s["http-opts"]?.path;ue(s,"http-opts.path")&&!Array.isArray(u)&&(s["http-opts"].path=[u]);let l=s["http-opts"]?.headers?.Host;ue(s,"http-opts.headers.Host")&&!Array.isArray(l)&&(s["http-opts"].headers.Host=[l])}if(["vmess","vless"].includes(s.type)&&s.network==="h2"){let u=s["h2-opts"]?.path;ue(s,"h2-opts.path")&&Array.isArray(u)&&(s["h2-opts"].path=u[0]);let l=s["h2-opts"]?.headers?.host;ue(s,"h2-opts.headers.Host")&&!Array.isArray(l)&&(s["h2-opts"].headers.host=[l])}if(["ws"].includes(s.network)){let u=s[`${s.network}-opts`]?.path;if(u){let l=/^(.*?)(?:\?ed=(\d+))?$/,[f,d="",m=""]=l.exec(u);s[`${s.network}-opts`].path=d,m!==""&&(s["ws-opts"]["early-data-header-name"]="Sec-WebSocket-Protocol",s["ws-opts"]["max-early-data"]=parseInt(m,10))}else s[`${s.network}-opts`]=s[`${s.network}-opts`]||{},s[`${s.network}-opts`].path="/"}if(s["plugin-opts"]?.tls&&ue(s,"skip-cert-verify")&&(s["plugin-opts"]["skip-cert-verify"]=s["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls","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"],ue(s,"tls")&&typeof s.tls!="boolean"&&delete s.tls,delete s.subName,delete s.collectionName,delete s.id,delete s.resolved,delete s["no-resolve"],n!=="internal")for(let u in s)(s[u]==null||/^_/i.test(u))&&delete s[u];return["grpc"].includes(s.network)&&s[`${s.network}-opts`]&&(delete s[`${s.network}-opts`]["_grpc-type"],delete s[`${s.network}-opts`]["_grpc-authority"]),s});return n==="internal"?a:`proxies: `+a.map(s=>" - "+JSON.stringify(s)+` `).join("")}}}var DM="Surfboard";function yp(){return{produce:t=>{switch(t.name=t.name.replace(/=|,/g,""),t.type){case"ss":return FM(t);case"trojan":return SM(t);case"vmess":return IM(t);case"http":return BM(t);case"socks5":return $M(t);case"wireguard-surge":return PM(t)}throw new Error(`Platform ${DM} does not support proxy type: ${t.type}`)}}}function FM(e){let t=new ot(e);if(t.append(`${e.name}=${e.type},${e.server},${e.port}`),!["aes-128-gcm","aes-192-gcm","aes-256-gcm","chacha20-ietf-poly1305","xchacha20-ietf-poly1305","rc4","rc4-md5","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","bf-cfb","camellia-128-cfb","camellia-192-cfb","camellia-256-cfb","salsa20","chacha20","chacha20-ietf"].includes(e.cipher))throw new Error(`cipher ${e.cipher} is not supported`);if(t.append(`,encrypt-method=${e.cipher}`),t.appendIfPresent(`,password=${e.password}`,"password"),ue(e,"plugin"))if(e.plugin==="obfs")t.append(`,obfs=${e["plugin-opts"].mode}`),t.appendIfPresent(`,obfs-host=${e["plugin-opts"].host}`,"plugin-opts.host"),t.appendIfPresent(`,obfs-uri=${e["plugin-opts"].path}`,"plugin-opts.path");else throw new Error(`plugin ${e.plugin} is not supported`);return t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.toString()}function SM(e){let t=new ot(e);return t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password=${e.password}`,"password"),$D(t,e),t.appendIfPresent(`,tls=${e.tls}`,"tls"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.toString()}function IM(e){let t=new ot(e);return t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,username=${e.uuid}`,"uuid"),$D(t,e),ue(e,"aead")?t.append(`,vmess-aead=${e.aead}`):t.append(`,vmess-aead=${e.alterId===0}`),t.appendIfPresent(`,tls=${e.tls}`,"tls"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.toString()}function BM(e){let t=new ot(e),r=e.tls?"https":"http";return t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,${e.username}`,"username"),t.appendIfPresent(`,${e.password}`,"password"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.toString()}function $M(e){let t=new ot(e),r=e.tls?"socks5-tls":"socks5";return t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,${e.username}`,"username"),t.appendIfPresent(`,${e.password}`,"password"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.toString()}function PM(e){let t=new ot(e);return t.append(`${e.name}=wireguard`),t.appendIfPresent(`,section-name=${e["section-name"]}`,"section-name"),t.toString()}function $D(e,t){if(ue(t,"network"))if(t.network==="ws"){if(e.append(",ws=true"),ue(t,"ws-opts")&&(e.appendIfPresent(`,ws-path=${t["ws-opts"].path}`,"ws-opts.path"),ue(t,"ws-opts.headers"))){let r=t["ws-opts"].headers,n=Object.keys(r).map(i=>{let a=r[i];return["Host"].includes(i)&&(a=`"${a}"`),`${i}:${a}`}).join("|");ra(n)&&e.append(`,ws-headers=${n}`)}}else throw new Error(`network ${t.network} is unsupported`)}var xM={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"},ui=(e,t)=>{let r=xM[e["ip-version"]];e._dns_server&&r&&(t.domain_resolver={server:e._dns_server,strategy:r})},oi=(e,t)=>{t.detour=e["dialer-proxy"]||e.detour},Ba=(e,t)=>{["tcp","udp"].includes(e._network)&&(t.network=e._network)},$i=(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},Us=(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))))},b2=(e,t)=>{let r={type:"ws",headers:{}};if(e["ws-opts"]){let{path:n="",headers:i={},"max-early-data":a,"early-data-header-name":s}=e["ws-opts"];if(r.early_data_header_name=s,r.max_early_data=a?parseInt(a,10):void 0,n!==""&&(r.path=`${n}`),Object.keys(i).length>0){let u={};for(let f of Object.keys(i)){let d=i[f];d!==""&&(Array.isArray(d)||(d=[`${d}`]),d.length>0&&(u[f]=d))}let{Host:l}=u;if(l.length===1)for(let f of`Host:${l[0]}`.split(` `)){let[d,m]=f.split(":");m.trim()!==""&&(u[d.trim()]=m.trim().split(","))}r.headers=u}}if(e["ws-headers"]){let n={};for(let a of Object.keys(e["ws-headers"])){let s=e["ws-headers"][a];s!==""&&(Array.isArray(s)||(s=[`${s}`]),s.length>0&&(n[a]=s))}let{Host:i}=n;if(i.length===1)for(let a of`Host:${i[0]}`.split(` `)){let[s,u]=a.split(":");u.trim()!==""&&(n[s.trim()]=u.trim().split(","))}for(let a of Object.keys(n))r.headers[a]=n[a]}if(e["ws-path"]&&e["ws-path"]!==""&&(r.path=`${e["ws-path"]}`),r.path){let n=/^(.*?)(?:\?ed=(\d+))?$/,[i,a="",s=""]=n.exec(r.path);r.path=a,s!==""&&(r.early_data_header_name="Sec-WebSocket-Protocol",r.max_early_data=parseInt(s,10))}t.tls.insecure&&(t.tls.server_name=r.headers.Host[0]),e["ws-opts"]&&e["ws-opts"]["v2ray-http-upgrade"]&&(r.type="httpupgrade",r.headers.Host&&(r.host=r.headers.Host[0],delete r.headers.Host),r.max_early_data&&delete r.max_early_data,r.early_data_header_name&&delete r.early_data_header_name);for(let n of Object.keys(r.headers)){let i=r.headers[n];i.length===1&&(r.headers[n]=i[0])}t.transport=r},PD=(e,t)=>{let r={type:"http",headers:{}};if(e["http-opts"]){let{method:n="",path:i="",headers:a={}}=e["http-opts"];n!==""&&(r.method=n),Array.isArray(i)?r.path=`${i[0]}`:i!==""&&(r.path=`${i}`);for(let s of Object.keys(a)){let u=a[s];if(u!==""){if(s.toLowerCase()==="host"){let l=u;Array.isArray(l)||(l=`${l}`.split(",").map(f=>f.trim())),l.length>0&&(r.host=l);continue}Array.isArray(u)||(u=`${u}`.split(",").map(l=>l.trim())),u.length>0&&(r.headers[s]=u)}}}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},xD=(e,t)=>{let r={type:"http"};if(e["h2-opts"]){let{host:n="",path:i=""}=e["h2-opts"];i!==""&&(r.path=`${i}`),n!==""&&(Array.isArray(n)||(n=`${n}`.split(",").map(a=>a.trim())),n.length>0&&(r.host=n))}if(e["h2-host"]&&e["h2-host"]!==""){let n=e["h2-host"];Array.isArray(n)||(n=`${n}`.split(",").map(i=>i.trim())),n.length>0&&(r.host=n)}e["h2-path"]&&e["h2-path"]!==""&&(r.path=`${e["h2-path"]}`),t.tls.enabled=!0,t.tls.insecure&&(t.tls.server_name=r.host[0]),r.host.length===1&&(r.host=r.host[0]),t.transport=r},y2=(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},yu=(e,t)=>{e.tls&&(t.tls.enabled=!0),e.servername&&e.servername!==""&&(t.tls.server_name=e.servername),e.peer&&e.peer!==""&&(t.tls.server_name=e.peer),e.sni&&e.sni!==""&&(t.tls.server_name=e.sni),e["skip-cert-verify"]&&(t.tls.insecure=!0),e.insecure&&(t.tls.insecure=!0),e["disable-sni"]&&(t.tls.disable_sni=!0),typeof e.alpn=="string"?t.tls.alpn=[e.alpn]:Array.isArray(e.alpn)&&(t.tls.alpn=e.alpn),e.ca&&(t.tls.certificate_path=`${e.ca}`),e.ca_str&&(t.tls.certificate=[e.ca_str]),e["ca-str"]&&(t.tls.certificate=[e["ca-str"]]),e["reality-opts"]&&(t.tls.reality={enabled:!0},e["reality-opts"]["public-key"]&&(t.tls.reality.public_key=e["reality-opts"]["public-key"]),e["reality-opts"]["short-id"]&&(t.tls.reality.short_id=e["reality-opts"]["short-id"]),t.tls.utls={enabled:!0}),!["hysteria","hysteria2","tuic"].includes(e.type)&&e["client-fingerprint"]&&e["client-fingerprint"]!==""&&(t.tls.utls={enabled:!0,fingerprint:e["client-fingerprint"]}),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},RM=(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),$i(e,t),oi(e,t),ui(e,t),t},TM=(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),$i(e,t),oi(e,t),yu(e,t),ui(e,t),t},OM=(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),Ba(e,t),$i(e,t),oi(e,t),ui(e,t),t},kM=(e={})=>{let t={tag:e.name,type:"shadowsocks",method:e.cipher,password:e.password,detour:`${e.name}_shadowtls`};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={tag:`${e.name}_shadowtls`,type:"shadowtls",server:e.server,server_port:parseInt(`${e.port}`,10),version:e["plugin-opts"].version,password:e["plugin-opts"].password,tls:{enabled:!0,server_name:e["plugin-opts"].host,utls:{enabled:!0,fingerprint:e["client-fingerprint"]}}};if(r.server_port<0||r.server_port>65535)throw"\u7AEF\u53E3\u503C\u975E\u6CD5";return e["fast-open"]===!0&&(r.udp_fragment=!0),$i(e,r),oi(e,r),Us(e.smux,t),ui(e,r),{type:"ss-with-st",ssPart:t,stPart:r}},NM=(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),Ba(e,t),$i(e,t),oi(e,t),Us(e.smux,t),ui(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":e["plugin-opts"].mux&&(t.multiplex={enabled:!0});break;default:r.push(`${n}=${e["plugin-opts"][n]}`)}})),t.plugin_opts=r.join(";")}return t},LM=(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),$i(e,t),oi(e,t),Us(e.smux,t),ui(e,t),t},UM=(e={})=>{let t={tag:e.name,type:"vmess",server:e.server,server_port:parseInt(`${e.port}`,10),uuid:e.uuid,security:e.cipher,alter_id:parseInt(`${e.alterId}`,10),tls:{enabled:!1,server_name:e.server,insecure:!1}};if(["auto","none","zero","aes-128-gcm","chacha20-poly1305","aes-128-ctr"].indexOf(t.security)===-1&&(t.security="auto"),t.server_port<0||t.server_port>65535)throw"invalid port";return e.xudp&&(t.packet_encoding="xudp"),e["fast-open"]&&(t.udp_fragment=!0),e.network==="ws"&&b2(e,t),e.network==="h2"&&xD(e,t),e.network==="http"&&PD(e,t),e.network==="grpc"&&y2(e,t),Ba(e,t),$i(e,t),oi(e,t),yu(e,t),Us(e.smux,t),ui(e,t),t},jM=(e={})=>{let t={tag:e.name,type:"vless",server:e.server,server_port:parseInt(`${e.port}`,10),uuid:e.uuid,tls:{enabled:!1,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";return e.xudp&&(t.packet_encoding="xudp"),e["fast-open"]&&(t.udp_fragment=!0),e.flow!=null&&(t.flow=e.flow),e.network==="ws"&&b2(e,t),e.network==="h2"&&xD(e,t),e.network==="http"&&PD(e,t),e.network==="grpc"&&y2(e,t),Ba(e,t),$i(e,t),oi(e,t),Us(e.smux,t),yu(e,t),ui(e,t),t},HM=(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"&&y2(e,t),e.network==="ws"&&b2(e,t),Ba(e,t),$i(e,t),oi(e,t),yu(e,t),Us(e.smux,t),ui(e,t),t},MM=(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["fast-open"]&&(t.udp_fragment=!0),$i(e,t),oi(e,t),yu(e,t),Us(e.smux,t),ui(e,t),t.tls?.insecure&&(k.info("Platform sing-box: insecure is not supported on naive outbound"),delete t.tls.insecure),t},qM=(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)),Ba(e,t),yu(e,t),oi(e,t),$i(e,t),Us(e.smux,t),ui(e,t),t},VM=(e={})=>{let t={tag:e.name,type:"hysteria2",server:e.server,server_port:parseInt(`${e.port}`,10),password:e.password,obfs:{},tls:{enabled:!0,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";return e["hop-interval"]&&(t.hop_interval=/^\d+$/.test(e["hop-interval"])?`${e["hop-interval"]}s`:e["hop-interval"]),e.ports&&(t.server_ports=e.ports.split(/\s*,\s*/).map(r=>{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)),e.obfs==="salamander"&&(t.obfs.type="salamander"),e["obfs-password"]&&(t.obfs.password=e["obfs-password"]),t.obfs.type||delete t.obfs,Ba(e,t),yu(e,t),$i(e,t),oi(e,t),Us(e.smux,t),ui(e,t),t},KM=(e={})=>{let t={tag:e.name,type:"tuic",server:e.server,server_port:parseInt(`${e.port}`,10),uuid:e.uuid,password:e.password,tls:{enabled:!0,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";return e["fast-open"]&&(t.udp_fragment=!0),e["congestion-controller"]&&e["congestion-controller"]!=="cubic"&&(t.congestion_control=e["congestion-controller"]),e["udp-relay-mode"]&&e["udp-relay-mode"]!=="native"&&(t.udp_relay_mode=e["udp-relay-mode"]),e["reduce-rtt"]&&(t.zero_rtt_handshake=!0),e["udp-over-stream"]&&(t.udp_over_stream=!0),e["heartbeat-interval"]&&(t.heartbeat=`${e["heartbeat-interval"]}ms`),Ba(e,t),$i(e,t),oi(e,t),yu(e,t),Us(e.smux,t),ui(e,t),t},zM=(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)),Ba(e,t),oi(e,t),yu(e,t),ui(e,t),t},GM=(e={})=>{let t=["ip","ipv6"].map(n=>e[n]).map(n=>{if(Mr(n))return`${n}/32`;if(Xr(n))return`${n}/128`}).filter(n=>n),r={tag:e.name,type:"wireguard",server:e.server,server_port:parseInt(`${e.port}`,10),local_address:t,private_key:e["private-key"],peer_public_key:e["public-key"],pre_shared_key:e["pre-shared-key"],reserved:[]};if(r.server_port<0||r.server_port>65535)throw"invalid port";if(e["fast-open"]&&(r.udp_fragment=!0),typeof e.reserved=="string")r.reserved=e.reserved;else if(Array.isArray(e.reserved))for(let n of e.reserved)r.reserved.push(n);else delete r.reserved;if(e.peers&&e.peers.length>0){r.peers=[];for(let n of e.peers){let i={server:n.server,server_port:parseInt(`${n.port}`,10),public_key:n["public-key"],allowed_ips:n["allowed-ips"]||n.allowed_ips,reserved:[]};if(typeof n.reserved=="string")i.reserved.push(n.reserved);else if(Array.isArray(n.reserved))for(let a of n.reserved)i.reserved.push(a);else delete i.reserved;n["pre-shared-key"]&&(i.pre_shared_key=n["pre-shared-key"]),r.peers.push(i)}}return Ba(e,r),$i(e,r),oi(e,r),Us(e.smux,r),ui(e,r),r};function _p(){return{type:"ALL",produce:(r,n,i={})=>{let a=[];return Yi().produce(r,"internal",{"include-unsupported-proxy":!0}).map(s=>{try{switch(s.type){case"ssh":a.push(RM(s));break;case"http":a.push(TM(s));break;case"socks5":if(s.tls)throw new Error(`Platform sing-box does not support proxy type: ${s.type} with tls`);a.push(OM(s));break;case"ss":if(s.plugin==="shadow-tls"){let{ssPart:u,stPart:l}=kM(s);a.push(u),a.push(l)}else a.push(NM(s));break;case"ssr":if(i["include-unsupported-proxy"])a.push(LM(s));else throw new Error(`Platform sing-box does not support proxy type: ${s.type}`);break;case"vmess":if(!s.network||["tcp","ws","grpc","h2","http"].includes(s.network))a.push(UM(s));else throw new Error(`Platform sing-box does not support proxy type: ${s.type} with network ${s.network}`);break;case"vless":if(!s.flow||["xtls-rprx-vision"].includes(s.flow))a.push(jM(s));else throw new Error(`Platform sing-box does not support proxy type: ${s.type} with flow ${s.flow}`);break;case"trojan":if(!s.flow)a.push(HM(s));else throw new Error(`Platform sing-box does not support proxy type: ${s.type} with flow ${s.flow}`);break;case"naive":a.push(MM(s));break;case"hysteria":a.push(qM(s));break;case"hysteria2":a.push(VM(s,i["include-unsupported-proxy"]));break;case"tuic":if(!s.token||s.token.length===0)a.push(KM(s));else throw new Error("Platform sing-box does not support proxy type: TUIC v4");break;case"wireguard":a.push(GM(s));break;case"anytls":a.push(zM(s));break;default:throw new Error(`Platform sing-box does not support proxy type: ${s.type}`)}}catch(u){k.error(u.message??u)}}),n==="internal"?a:JSON.stringify({outbounds:a},null,2)}}}function Cp(){return{type:"ALL",produce:(r,n,i={})=>{let a=r.filter(s=>!(!["http","https","socks5","ss","trojan","hysteria2","vless","vmess","tuic"].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"&&!["http","ws","tcp"].includes(s.network)&&s.network||s.type==="trojan"&&!["http","ws","tcp"].includes(s.network)&&s.network||s.type==="vless"&&!["http","ws","tcp"].includes(s.network)&&s.network||s.type==="tuic"&&s.token&&s.token.length!==0)).map(s=>{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,tfo:s.tfo||s["fast-open"],next_hop:s.next_hop,...s.tls?{sni:s.sni,skip_tls_verify:s["skip-cert-verify"]}:{}};else if(s.type==="socks5")s={type:"socks5",name:s.name,server:s.server,port:s.port,username:s.username,password:s.password,tfo:s.tfo||s["fast-open"],udp_relay:s.udp||s.udp_relay||s.udp_relay,next_hop:s.next_hop};else if(s.type==="ss")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:s.tfo||s["fast-open"],udp_relay:s.udp||s.udp_relay||s.udp_relay,next_hop:s.next_hop},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(s.type==="hysteria2")s={type:"hysteria2",name:s.name,server:s.server,port:s.port,auth:s.password,tfo:s.tfo||s["fast-open"],udp_relay:s.udp||s.udp_relay||s.udp_relay,next_hop:s.next_hop,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,next_hop:s.next_hop,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:s.tfo||s["fast-open"],udp_relay:s.udp||s.udp_relay||s.udp_relay,next_hop:s.next_hop,sni:s.sni,skip_tls_verify:s["skip-cert-verify"],websocket:s.websocket};else if(s.type==="vmess"){let d=s.cipher;d&&!["auto","none","zero","aes-128-gcm","chacha20-poly1305"].includes(d)&&(d="auto"),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:{Host:Array.isArray(s["h2-opts"]?.headers?.Host)?s["h2-opts"]?.headers?.Host[0]:s["h2-opts"]?.headers?.Host},skip_tls_verify:s["skip-cert-verify"]}}:(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 m;(ue(s,"aead")&&!s.aead||s.alterId!==0)&&(m=!0),s={type:"vmess",name:s.name,server:s.server,port:s.port,user_id:s.uuid,security:d,tfo:s.tfo||s["fast-open"],legacy:m,udp_relay:s.udp||s.udp_relay||s.udp_relay,next_hop:s.next_hop,transport:s.transport}}else if(s.type==="vless"){if(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}};else if(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"]}};else if(s.network==="tcp"||!s.network){let d;if((s["reality-opts"]?.["short-id"]||s["reality-opts"]?.["public-key"])&&(d={short_id:s["reality-opts"]["short-id"],public_key:s["reality-opts"]["public-key"]}),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:d}},typeof s.flow<"u"&&!["xtls-rprx-vision"].includes(s.flow))throw new Error(`VLESS flow(${s.flow}) is not supported`);l=s.flow}s={type:"vless",name:s.name,server:s.server,port:s.port,user_id:s.uuid,security:s.cipher,tfo:s.tfo||s["fast-open"],udp_relay:s.udp||s.udp_relay||s.udp_relay,next_hop:s.next_hop,transport:s.transport,flow:l}}if(["http","https","socks5","ss","trojan","vless","vmess"].includes(u.type)){if(ue(u,"shadow-tls-password")){if(u["shadow-tls-version"]!=3)throw new Error(`shadow-tls version ${u["shadow-tls-version"]} is not supported`);s.shadow_tls={password:u["shadow-tls-password"],sni:u["shadow-tls-sni"]}}else if(["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}}}if(["socks5","ss","trojan","vless","vmess"].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 d in s.transport)(Object.keys(s.transport[d]).length===0||Object.values(s.transport[d]).every(m=>m==null))&&delete s.transport[d];Object.keys(s.transport).length===0&&delete s.transport}if(n!=="internal")for(let d in s)(s[d]==null||/^_/i.test(d))&&delete s[d];return{[s.type]:{...s,type:void 0,prev_hop:f}}});return n==="internal"?a:`proxies: `+a.map(s=>" - "+JSON.stringify(s)+` `).join("")}}}function RD(){return{type:"ALL",produce:(r,n)=>n==="internal"?r:JSON.stringify(r,null,2)}}var TD={qx:Dh(),QX:Dh(),QuantumultX:Dh(),surge:gc(),Surge:gc(),SurgeMac:Fm(),Loon:Im(),Clash:Sm(),meta:Yi(),clashmeta:Yi(),"clash.meta":Yi(),"Clash.Meta":Yi(),ClashMeta:Yi(),mihomo:Yi(),Mihomo:Yi(),uri:Hc(),URI:Hc(),v2:Ch(),v2ray:Ch(),V2Ray:Ch(),json:RD(),JSON:RD(),stash:Nd(),Stash:Nd(),shadowrocket:Fh(),Shadowrocket:Fh(),ShadowRocket:Fh(),surfboard:yp(),Surfboard:yp(),singbox:_p(),"sing-box":_p(),egern:Cp(),Egern:Cp()};var j3=_n(Rh()),rV=String.raw` // global initializer {{ function $set(obj, path, value) { if (Object(obj) !== obj) return obj; if (!Array.isArray(path)) path = path.toString().match(/[^.[\]]+/g) || []; path .slice(0, -1) .reduce((a, c, i) => (Object(a[c]) === a[c] ? a[c] : (a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1] ? [] : {})), obj)[ path[path.length - 1] ] = value; return obj; } }} // per-parser initializer { const proxy = {}; const obfs = {}; const $ = {}; function handleWebsocket() { if (obfs.type === "ws") { proxy.network = "ws"; $set(proxy, "ws-opts.path", obfs.path); $set(proxy, "ws-opts.headers", obfs['ws-headers']); if (proxy['ws-opts'] && proxy['ws-opts']['headers'] && proxy['ws-opts']['headers'].Host) { proxy['ws-opts']['headers'].Host = proxy['ws-opts']['headers'].Host.replace(/^"(.*)"$/, '$1') } } } function handleShadowTLS() { if (proxy['shadow-tls-password'] && !proxy['shadow-tls-version']) { proxy['shadow-tls-version'] = 2; } } } start = (anytls/shadowsocks/vmess/trojan/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard/hysteria2/ssh/direct) { return proxy; } shadowsocks = tag equals "ss" address (method/passwordk/obfs/obfs_host/obfs_uri/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/udp_port/others)* { proxy.type = "ss"; // handle obfs if (obfs.type == "http" || obfs.type === "tls") { proxy.plugin = "obfs"; $set(proxy, "plugin-opts.mode", obfs.type); $set(proxy, "plugin-opts.host", obfs.host); $set(proxy, "plugin-opts.path", obfs.path); } handleShadowTLS(); } vmess = tag equals "vmess" address (vmess_uuid/vmess_aead/ws/ws_path/ws_headers/method/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls/sni/tls_fingerprint/tls_verification/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "vmess"; proxy.cipher = proxy.cipher || "none"; // 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/tls_fingerprint/tls_verification/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "trojan"; handleWebsocket(); handleShadowTLS(); } https = tag equals "https" address (username password)? (usernamek passwordk)? (sni/tls_fingerprint/tls_verification/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "http"; proxy.tls = true; handleShadowTLS(); } http = tag equals "http" address (username password)? (usernamek passwordk)? (ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "http"; handleShadowTLS(); } ssh = tag equals "ssh" address (username password)? (usernamek passwordk)? (server_fingerprint/idle_timeout/private_key/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "ssh"; handleShadowTLS(); } snell = tag equals "snell" address (snell_version/snell_psk/obfs/obfs_host/obfs_uri/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/reuse/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "snell"; // handle obfs if (obfs.type == "http" || obfs.type === "tls") { $set(proxy, "obfs-opts.mode", obfs.type); $set(proxy, "obfs-opts.host", obfs.host); $set(proxy, "obfs-opts.path", obfs.path); } handleShadowTLS(); } tuic = tag equals "tuic" address (alpn/token/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/sni/fast_open/tfo/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/others)* { proxy.type = "tuic"; handleShadowTLS(); } tuic_v5 = tag equals "tuic-v5" address (alpn/passwordk/uuidk/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/sni/fast_open/tfo/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/others)* { proxy.type = "tuic"; proxy.version = 5; handleShadowTLS(); } wireguard = tag equals "wireguard" (section_name/no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "wireguard-surge"; handleShadowTLS(); } hysteria2 = tag equals "hysteria2" address (no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/sni/tls_verification/passwordk/tls_fingerprint/download_bandwidth/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/others)* { proxy.type = "hysteria2"; handleShadowTLS(); } socks5 = tag equals "socks5" address (username password)? (usernamek passwordk)? (udp_relay/no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/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/tls_fingerprint/tls_verification/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "socks5"; proxy.tls = true; handleShadowTLS(); } 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/sni/fast_open/tfo/block_quic/others)* { proxy.type = "anytls"; 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 sni:("off"/domain) { if (sni === "off") { proxy["disable-sni"] = true; } else { proxy.sni = sni; } } tls_verification = comma "skip-cert-verify" equals flag:bool { proxy["skip-cert-verify"] = flag; } tls_fingerprint = comma "server-cert-fingerprint-sha256" equals tls_fingerprint:$[^,]+ { proxy["tls-fingerprint"] = tls_fingerprint.trim(); } snell_psk = comma "psk" equals match:[^,]+ { proxy.psk = match.join(""); } snell_version = comma "version" equals match:$[0-9]+ { proxy.version = parseInt(match.trim()); } usernamek = comma "username" equals match:[^,]+ { proxy.username = match.join("").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; } cipher = ("aes-128-cfb"/"aes-128-ctr"/"aes-128-gcm"/"aes-192-cfb"/"aes-192-ctr"/"aes-192-gcm"/"aes-256-cfb"/"aes-256-ctr"/"aes-256-gcm"/"bf-cfb"/"camellia-128-cfb"/"camellia-192-cfb"/"camellia-256-cfb"/"cast5-cfb"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"des-cfb"/"idea-cfb"/"none"/"rc2-cfb"/"rc4-md5"/"rc4"/"salsa20"/"seed-cfb"/"xchacha20-ietf-poly1305"/"2022-blake3-aes-128-gcm"/"2022-blake3-aes-256-gcm"); ws = comma "ws" equals flag:bool { obfs.type = "ws"; } ws_headers = comma "ws-headers" equals headers:$[^,]+ { const pairs = headers.split("|"); const result = {}; pairs.forEach(pair => { const [key, value] = pair.trim().split(":"); result[key.trim()] = value.trim().replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }) obfs["ws-headers"] = result; } ws_path = comma "ws-path" equals path:uri { obfs.path = path.trim().replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } obfs = comma "obfs" equals type:("http"/"tls") { obfs.type = type; } obfs_host = comma "obfs-host" equals host:domain { obfs.host = host; }; obfs_uri = comma "obfs-uri" equals path:uri { obfs.path = path } uri = $[^,]+ udp_relay = comma "udp-relay" equals flag:bool { proxy.udp = flag; } fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; } reuse = comma "reuse" equals flag:bool { proxy.reuse = flag; } ecn = comma "ecn" equals flag:bool { proxy.ecn = flag; } tfo = comma "tfo" equals flag:bool { proxy.tfo = flag; } ip_version = comma "ip-version" equals match:[^,]+ { proxy["ip-version"] = match.join(""); } section_name = comma "section-name" equals match:[^,]+ { proxy["section-name"] = match.join(""); } no_error_alert = comma "no-error-alert" equals match:[^,]+ { proxy["no-error-alert"] = match.join(""); } underlying_proxy = comma "underlying-proxy" equals match:[^,]+ { proxy["underlying-proxy"] = match.join(""); } download_bandwidth = comma "download-bandwidth" equals match:[^,]+ { proxy.down = match.join(""); } test_url = comma "test-url" equals match:[^,]+ { proxy["test-url"] = match.join(""); } test_udp = comma "test-udp" equals match:[^,]+ { proxy["test-udp"] = match.join(""); } test_timeout = comma "test-timeout" equals match:$[0-9]+ { proxy["test-timeout"] = parseInt(match.trim()); } tos = comma "tos" equals match:$[0-9]+ { proxy.tos = parseInt(match.trim()); } interface = comma "interface" equals match:[^,]+ { proxy.interface = match.join(""); } allow_other_interface = comma "allow-other-interface" equals flag:bool { proxy["allow-other-interface"] = flag; } hybrid = comma "hybrid" equals flag:bool { proxy.hybrid = flag; } idle_timeout = comma "idle-timeout" equals match:$[0-9]+ { proxy["idle-timeout"] = parseInt(match.trim()); } private_key = comma "private-key" equals match:[^,]+ { proxy["keystore-private-key"] = match.join("").replace(/^"(.*)"$/, '$1'); } server_fingerprint = comma "server-fingerprint" equals match:[^,]+ { proxy["server-fingerprint"] = match.join("").replace(/^"(.*)"$/, '$1'); } block_quic = comma "block-quic" equals match:[^,]+ { proxy["block-quic"] = match.join(""); } udp_port = comma "udp-port" equals match:$[0-9]+ { proxy["udp-port"] = parseInt(match.trim()); } shadow_tls_version = comma "shadow-tls-version" equals match:$[0-9]+ { proxy["shadow-tls-version"] = parseInt(match.trim()); } shadow_tls_sni = comma "shadow-tls-sni" equals match:[^,]+ { proxy["shadow-tls-sni"] = match.join(""); } shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { proxy["shadow-tls-password"] = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } token = comma "token" equals match:[^,]+ { proxy.token = match.join(""); } alpn = comma "alpn" equals match:[^,]+ { proxy.alpn = match.join(""); } uuidk = comma "uuid" equals match:[^,]+ { proxy.uuid = match.join(""); } tag = match:[^=,]* { proxy.name = match.join("").trim(); } comma = _ "," _ equals = _ "=" _ _ = [ \r\t]* bool = b:("true"/"false") { return b === "true" } others = comma [^=,]+ equals [^=,]+ `,M2;function Pi(){return M2||(M2=j3.generate(rV)),M2}var H3=_n(Rh()),nV=String.raw` // global initializer {{ function $set(obj, path, value) { if (Object(obj) !== obj) return obj; if (!Array.isArray(path)) path = path.toString().match(/[^.[\]]+/g) || []; path .slice(0, -1) .reduce((a, c, i) => (Object(a[c]) === a[c] ? a[c] : (a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1] ? [] : {})), obj)[ path[path.length - 1] ] = value; return obj; } }} // per-parser initializer { const proxy = {}; const obfs = {}; const transport = {}; const $ = {}; function handleTransport() { if (transport.type === "tcp") { /* do nothing */ } else if (transport.type === "ws") { proxy.network = "ws"; $set(proxy, "ws-opts.path", transport.path); $set(proxy, "ws-opts.headers.Host", transport.host); } else if (transport.type === "http") { proxy.network = "http"; $set(proxy, "http-opts.path", transport.path); $set(proxy, "http-opts.headers.Host", transport.host); } } } start = (shadowsocksr/shadowsocks/vmess/vless/trojan/https/http/socks5/hysteria2) { return proxy; } shadowsocksr = tag equals "shadowsocksr"i address method password (ssr_protocol/ssr_protocol_param/obfs_ssr/obfs_ssr_param/obfs_host/obfs_uri/fast_open/udp_relay/udp_port/shadow_tls_version/shadow_tls_sni/shadow_tls_password/ip_mode/block_quic/others)*{ proxy.type = "ssr"; // handle ssr obfs proxy.obfs = obfs.type; } shadowsocks = tag equals "shadowsocks"i address method password (obfs_typev obfs_hostv)? (obfs_ss/obfs_host/obfs_uri/fast_open/udp_relay/udp_port/shadow_tls_version/shadow_tls_sni/shadow_tls_password/ip_mode/block_quic/others)* { proxy.type = "ss"; // handle ss obfs if (obfs.type == "http" || obfs.type === "tls") { proxy.plugin = "obfs"; $set(proxy, "plugin-opts.mode", obfs.type); $set(proxy, "plugin-opts.host", obfs.host); $set(proxy, "plugin-opts.path", obfs.path); } } vmess = tag equals "vmess"i address method uuid (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/vmess_alterId/fast_open/udp_relay/ip_mode/public_key/short_id/block_quic/others)* { proxy.type = "vmess"; proxy.cipher = proxy.cipher || "none"; proxy.alterId = proxy.alterId || 0; handleTransport(); } vless = tag equals "vless"i address uuid (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/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/fast_open/udp_relay/ip_mode/block_quic/others)* { proxy.type = "trojan"; handleTransport(); } hysteria2 = tag equals "hysteria2"i address password (tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/udp_relay/fast_open/download_bandwidth/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/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/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; } cipher = ("aes-128-cfb"/"aes-128-ctr"/"aes-128-gcm"/"aes-192-cfb"/"aes-192-ctr"/"aes-192-gcm"/"aes-256-cfb"/"aes-256-ctr"/"aes-256-gcm"/"auto"/"bf-cfb"/"camellia-128-cfb"/"camellia-192-cfb"/"camellia-256-cfb"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"none"/"rc4-md5"/"rc4"/"salsa20"/"xchacha20-ietf-poly1305"/"2022-blake3-aes-128-gcm"/"2022-blake3-aes-256-gcm"); username = & { let j = peg$currPos; let start, end; let first = true; while (j < input.length) { if (input[j] === ',') { if (first) { start = j + 1; first = false; } else { end = j; break; } } j++; } const match = input.substring(start, end); if (match.indexOf("=") === -1) { $.username = match; peg$currPos = end; return true; } } { proxy.username = $.username; } password = comma '"' match:[^"]* '"' { proxy.password = match.join(""); } uuid = comma '"' match:[^"]+ '"' { proxy.uuid = match.join(""); } obfs_typev = comma type:("http"/"tls") { obfs.type = type; } obfs_hostv = comma match:[^,]+ { obfs.host = match.join(""); } obfs_ss = comma "obfs-name" equals type:("http"/"tls") { obfs.type = type; } obfs_ssr = comma "obfs" equals type:("plain"/"http_simple"/"http_post"/"random_head"/"tls1.2_ticket_auth"/"tls1.2_ticket_fastauth") { obfs.type = type; } obfs_ssr_param = comma "obfs-param" equals match:$[^,]+ { proxy["obfs-param"] = match; } obfs_host = comma "obfs-host" equals host:domain { obfs.host = host; } obfs_uri = comma "obfs-uri" equals uri:uri { obfs.path = uri; } uri = $[^,]+ transport = comma "transport" equals type:("tcp"/"ws"/"http") { transport.type = type; } transport_host = comma "host" equals host:domain { transport.host = host; } transport_path = comma "path" equals path:uri { transport.path = path; } ssr_protocol = comma "protocol" equals protocol:("origin"/"auth_sha1_v4"/"auth_aes128_md5"/"auth_aes128_sha1"/"auth_chain_a"/"auth_chain_b") { proxy.protocol = protocol; } ssr_protocol_param = comma "protocol-param" equals param:$[^=,]+ { proxy["protocol-param"] = param; } vmess_alterId = comma "alterId" equals alterId:$[0-9]+ { proxy.alterId = parseInt(alterId); } udp_port = comma "udp-port" equals match:$[0-9]+ { proxy["udp-port"] = parseInt(match.trim()); } shadow_tls_version = comma "shadow-tls-version" equals match:$[0-9]+ { proxy["shadow-tls-version"] = parseInt(match.trim()); } shadow_tls_sni = comma "shadow-tls-sni" equals match:[^,]+ { proxy["shadow-tls-sni"] = match.join(""); } shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { proxy["shadow-tls-password"] = match.join(""); } over_tls = comma "over-tls" equals flag:bool { proxy.tls = flag; } tls_name = comma sni:("tls-name") equals host:domain { proxy.sni = host; } sni = comma sni:("sni") equals host:domain { proxy.sni = host; } tls_verification = comma "skip-cert-verify" equals flag:bool { proxy["skip-cert-verify"] = flag; } tls_cert_sha256 = comma "tls-cert-sha256" equals match:[^,]+ { proxy["tls-fingerprint"] = match.join("").replace(/^"(.*)"$/, '$1'); } tls_pubkey_sha256 = comma "tls-pubkey-sha256" equals match:[^,]+ { proxy["tls-pubkey-sha256"] = match.join("").replace(/^"(.*)"$/, '$1'); } flow = comma "flow" equals match:[^,]+ { proxy["flow"] = match.join("").replace(/^"(.*)"$/, '$1'); } public_key = comma "public-key" equals match:[^,]+ { proxy["reality-opts"] = proxy["reality-opts"] || {}; proxy["reality-opts"]["public-key"] = match.join("").replace(/^"(.*)"$/, '$1'); } short_id = comma "short-id" equals match:[^,]+ { proxy["reality-opts"] = proxy["reality-opts"] || {}; proxy["reality-opts"]["short-id"] = match.join("").replace(/^"(.*)"$/, '$1'); } fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; } udp_relay = comma "udp" equals flag:bool { proxy.udp = flag; } ip_mode = comma "ip-mode" equals match:[^,]+ { proxy["ip-version"] = match.join(""); } ecn = comma "ecn" equals flag:bool { proxy.ecn = flag; } download_bandwidth = comma "download-bandwidth" equals match:[^,]+ { proxy.down = match.join(""); } salamander_password = comma "salamander-password" equals match:[^,]+ { proxy['obfs-password'] = match.join(""); proxy.obfs = 'salamander'; } block_quic = comma "block-quic" equals flag:bool { if(flag) proxy["block-quic"] = "on"; else proxy["block-quic"] = "off"; } tag = match:[^=,]* { proxy.name = match.join("").trim(); } comma = _ "," _ equals = _ "=" _ _ = [ \r\t]* bool = b:("true"/"false") { return b === "true" } others = comma [^=,]+ equals [^=,]+ `,q2;function $a(){return q2||(q2=H3.generate(nV)),q2}var M3=_n(Rh()),iV=String.raw` // global initializer {{ function $set(obj, path, value) { if (Object(obj) !== obj) return obj; if (!Array.isArray(path)) path = path.toString().match(/[^.[\]]+/g) || []; path .slice(0, -1) .reduce((a, c, i) => (Object(a[c]) === a[c] ? a[c] : (a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1] ? [] : {})), obj)[ path[path.length - 1] ] = value; return obj; } }} // per-parse initializer { const proxy = {}; const obfs = {}; const $ = {}; function handleObfs() { if (obfs.type === "ws" || obfs.type === "wss") { proxy.network = "ws"; if (obfs.type === 'wss') { proxy.tls = true; } $set(proxy, "ws-opts.path", obfs.path); $set(proxy, "ws-opts.headers.Host", obfs.host); } else if (obfs.type === "over-tls") { proxy.tls = true; } else if (obfs.type === "http") { proxy.network = "http"; $set(proxy, "http-opts.path", obfs.path); $set(proxy, "http-opts.headers.Host", obfs.host); } } } start = (trojan/shadowsocks/vmess/vless/http/socks5) { return proxy } trojan = "trojan" equals address (password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/obfs/obfs_host/obfs_uri/tag/udp_relay/udp_over_tcp/fast_open/server_check_url/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') { throw new Error('ss over-tls is not supported'); } if (obfs.type) { $set(proxy, "plugin-opts.host", obfs.host); $set(proxy, "plugin-opts.path", obfs.path); } } } vmess = "vmess" equals address (uuid/method/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/obfs/obfs_host/obfs_uri/udp_relay/udp_over_tcp/fast_open/aead/server_check_url/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/obfs_host/obfs_uri/udp_relay/udp_over_tcp/fast_open/aead/server_check_url/reality_base64_pubkey/reality_hex_shortid/others)* { proxy.type = "vless"; proxy.cipher = proxy.cipher || "none"; handleObfs(); } http = "http" equals address (username/password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/fast_open/udp_relay/udp_over_tcp/server_check_url/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 "tls-host" equals sni:domain { proxy.sni = sni; } tls_verification = comma "tls-verification" equals flag:bool { proxy["skip-cert-verify"] = !flag; } tls_fingerprint = comma "tls-cert-sha256" equals tls_fingerprint:$[^,]+ { proxy["tls-fingerprint"] = tls_fingerprint.trim(); } tls_pubkey_sha256 = comma "tls-pubkey-sha256" equals param:$[^=,]+ { proxy["tls-pubkey-sha256"] = param; } tls_alpn = comma "tls-alpn" equals param:$[^=,]+ { proxy["tls-alpn"] = param; } tls_no_session_ticket = comma "tls-no-session-ticket" equals flag:bool { proxy["tls-no-session-ticket"] = flag; } tls_no_session_reuse = comma "tls-no-session-reuse" equals flag:bool { proxy["tls-no-session-reuse"] = flag; } obfs_ss = comma "obfs" equals type:("http"/"tls"/"wss"/"ws"/"over-tls") { obfs.type = type; return type; } obfs_ssr = comma "obfs" equals type:("plain"/"http_simple"/"http_post"/"random_head"/"tls1.2_ticket_auth"/"tls1.2_ticket_fastauth") { proxy.type = "ssr"; obfs.type = type; return type; } obfs = comma "obfs" equals type:("wss"/"ws"/"over-tls"/"http") { obfs.type = type; return type; }; obfs_host = comma "obfs-host" equals host:domain { obfs.host = host; } obfs_uri = comma "obfs-uri" equals uri:uri { obfs.path = uri; } ssr_protocol = comma "ssr-protocol" equals protocol:("origin"/"auth_sha1_v4"/"auth_aes128_md5"/"auth_aes128_sha1"/"auth_chain_a"/"auth_chain_b") { proxy.protocol = protocol; return protocol; } ssr_protocol_param = comma "ssr-protocol-param" equals param:$[^=,]+ { proxy["protocol-param"] = param; } 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); } 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" } `,V2;function Cu(){return V2||(V2=M3.generate(iV)),V2}var q3=_n(Rh()),sV=String.raw` // global initializer {{ function $set(obj, path, value) { if (Object(obj) !== obj) return obj; if (!Array.isArray(path)) path = path.toString().match(/[^.[\]]+/g) || []; path .slice(0, -1) .reduce((a, c, i) => (Object(a[c]) === a[c] ? a[c] : (a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1] ? [] : {})), obj)[ path[path.length - 1] ] = value; return obj; } function toBool(str) { if (typeof str === 'undefined' || str === null) return undefined; return /(TRUE)|1/i.test(str); } }} { const proxy = {}; const obfs = {}; const $ = {}; const params = {}; } start = (trojan) { return proxy } trojan = "trojan://" password:password "@" server:server ":" port:port "/"? params? name:name?{ proxy.type = "trojan"; proxy.password = password; proxy.server = server; proxy.port = port; proxy.name = name; // name may be empty if (!proxy.name) { proxy.name = server + ":" + port; } }; password = match:$[^@]+ { return decodeURIComponent(match); }; server = ip/domain; domain = match:[0-9a-zA-z-_.]+ { const domain = match.join(""); if (/(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/.test(domain)) { return domain; } } ip = & { const start = peg$currPos; let end; let j = start; while (j < input.length) { if (input[j] === ",") break; if (input[j] === ":") end = j; j++; } peg$currPos = end || j; $.ip = input.substring(start, end).trim(); return true; } { return $.ip; } port = digits:[0-9]+ { const port = parseInt(digits.join(""), 10); if (port >= 0 && port <= 65535) { return port; } else { throw new Error("Invalid port: " + port); } } params = "?" head:param tail:("&"@param)* { for (const [key, value] of Object.entries(params)) { params[key] = decodeURIComponent(value); } proxy["skip-cert-verify"] = toBool(params["allowInsecure"]); proxy.sni = params["sni"] || params["peer"]; proxy['client-fingerprint'] = params.fp; proxy.alpn = params.alpn ? decodeURIComponent(params.alpn).split(',') : undefined; if (toBool(params["ws"])) { proxy.network = "ws"; $set(proxy, "ws-opts.path", params["wspath"]); } if (params["type"]) { let httpupgrade proxy.network = params["type"] if(proxy.network === 'httpupgrade') { proxy.network = 'ws' httpupgrade = true } if (['grpc'].includes(proxy.network)) { proxy[proxy.network + '-opts'] = { 'grpc-service-name': params["serviceName"], '_grpc-type': params["mode"], '_grpc-authority': params["authority"], }; } else { if (params["path"]) { $set(proxy, proxy.network+"-opts.path", decodeURIComponent(params["path"])); } if (params["host"]) { $set(proxy, proxy.network+"-opts.headers.Host", decodeURIComponent(params["host"])); } if (httpupgrade) { $set(proxy, proxy.network+"-opts.v2ray-http-upgrade", true); $set(proxy, proxy.network+"-opts.v2ray-http-upgrade-fast-open", true); } } if (['reality'].includes(params.security)) { const opts = {}; if (params.pbk) { opts['public-key'] = params.pbk; } if (params.sid) { opts['short-id'] = params.sid; } if (params.spx) { opts['_spider-x'] = params.spx; } if (params.mode) { proxy._mode = params.mode; } if (params.extra) { proxy._extra = params.extra; } if (Object.keys(opts).length > 0) { $set(proxy, params.security+"-opts", opts); } } } proxy.udp = toBool(params["udp"]); proxy.tfo = toBool(params["tfo"]); } param = kv/single; kv = key:$[a-z]i+ "=" value:$[^&#]i* { params[key] = value; } single = key:$[a-z]i+ { params[key] = true; }; name = "#" + match:$.* { return decodeURIComponent(match); } `,K2;function z2(){return K2||(K2=q3.generate(sV)),K2}var X2=_n(W2());function V3(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 aV(){return{name:"URI PROXY Parser",test:n=>/^(socks5\+tls|socks5|http|https):\/\//.test(n),parse:n=>{let[i,a,s,u,l,f,d,m,p]=n.match(/^(socks5|http|http)(\+tls|s)?:\/\/(?:(.*?):(.*?)@)?(.*?)(?::(\d+?))?\/?(\?.*?)?(?:#(.*?))?$/);if(d)d=parseInt(d,10);else{if(s)d=443;else if(a==="http")d=80;else throw k.error(`port is not present in line: ${n}`),new Error(`port is not present in line: ${n}`);k.info(`port is not present in line: ${n}, set to ${d}`)}return{name:p!=null?decodeURIComponent(p):`${a} ${f}:${d}`,type:a,tls:!!s,server:f,port:d,username:u!=null?decodeURIComponent(u):void 0,password:l!=null?decodeURIComponent(l):void 0}}}}function uV(){return{name:"URI SOCKS Parser",test:n=>/^socks:\/\//.test(n),parse:n=>{let[i,a,s,u,l,f,d]=n.match(/^(socks)?:\/\/(?:(.*)@)?(.*?)(?::(\d+?))?(\?.*?)?(?:#(.*?))?$/);if(l)l=parseInt(l,10);else throw k.error(`port is not present in line: ${n}`),new Error(`port is not present in line: ${n}`);let m,p;if(s){let w=pt.decode(decodeURIComponent(s)).split(":");m=w[0],p=w[1]}return{name:d!=null?decodeURIComponent(d):`${a} ${u}:${l}`,type:"socks5",server:u,port:l,username:m,password:p}}}}function oV(){return{name:"URI SS Parser",test:n=>/^ss:\/\//.test(n),parse:n=>{let i=n.split("ss://")[1],a=n.split("#")[1],s={type:"ss"};i=i.split("#")[0];let u=i.match(/@([^/?]*)(\/|\?|$)/),l=decodeURIComponent(i.split("@")[0]),f;l?.startsWith("2022-blake3-")?f=l:f=pt.decode(l);let d="";if(u)i.includes("?")&&(d=i.match(/(\?.*)$/)[1]);else{if(i.includes("?")){let y=i.match(/^(.*)(\?.*)$/);i=y[1],d=y[2]}if(i=pt.decode(i),d){if(/(&|\?)v2ray-plugin=/.test(d)){let g=d.match(/(&|\?)v2ray-plugin=(.*?)(&|$)/)[2];g&&(s.plugin="v2ray-plugin",s["plugin-opts"]=JSON.parse(pt.decode(g)))}i=`${i}${d}`}f=i.match(/(^.*)@/)?.[1],u=i.match(/@([^/@]*)(\/|$)/)}let m=u[1],p=m.lastIndexOf(":");s.server=m.substring(0,p),s.port=`${m.substring(p+1)}`.match(/\d+/)?.[0];let h=f.match(/(^.*?):(.*$)/);s.cipher=h?.[1],s.password=h?.[2];let w=i.match(/[?&]plugin=([^&]+)/),v=i.match(/[?&]shadow-tls=([^&]+)/);if(w){let y=("plugin="+decodeURIComponent(w[1])).split(";"),g={};for(let b of y){let[D,C]=b.split("=");D&&(g[D]=C||!0)}switch(g.plugin){case"obfs-local":case"simple-obfs":s.plugin="obfs",s["plugin-opts"]={mode:g.obfs,host:ar(g["obfs-host"])};break;case"v2ray-plugin":s.plugin="v2ray-plugin",s["plugin-opts"]={mode:"websocket",host:ar(g["obfs-host"]),path:ar(g.path),tls:Kl(g.tls)};break;case"shadow-tls":{s.plugin="shadow-tls";let b=ar(g.version);s["plugin-opts"]={host:ar(g.host),password:ar(g.password),version:b?parseInt(b,10):void 0};break}default:throw new Error(`Unsupported plugin option: ${g.plugin}`)}}if(v){let y=JSON.parse(pt.decode(v[1])),g=ar(y.version),b=ar(y.address),D=ar(y.port);s.plugin="shadow-tls",s["plugin-opts"]={host:ar(y.host),password:ar(y.password),version:g?parseInt(g,10):void 0},b&&(s.server=b),D&&(s.port=parseInt(D,10))}return/(&|\?)uot=(1|true)/i.test(d)&&(s["udp-over-tcp"]=!0),/(&|\?)tfo=(1|true)/i.test(d)&&(s.tfo=!0),a!=null&&(a=decodeURIComponent(a)),s.name=a??`SS ${s.server}:${s.port}`,s}}}function lV(){return{name:"URI SSR Parser",test:n=>/^ssr:\/\//.test(n),parse:n=>{n=pt.decode(n.split("ssr://")[1]);let i=n.indexOf(":origin");i===-1&&(i=n.indexOf(":auth_"));let a=n.substring(0,i),s=a.substring(0,a.lastIndexOf(":")),u=a.substring(a.lastIndexOf(":")+1),l=n.substring(i+1).split("/?")[0].split(":"),f={type:"ssr",server:s,port:u,protocol:l[0],cipher:l[1],obfs:l[2],password:pt.decode(l[3])},d={};if(n=n.split("/?")[1].split("&"),n.length>1)for(let m of n){let[p,h]=m.split("=");h=h.trim(),h.length>0&&h!=="(null)"&&(d[p]=h)}return f={...f,name:d.remarks?pt.decode(d.remarks):f.server,"protocol-param":ar(pt.decode(d.protoparam||"").replace(/\s/g,"")),"obfs-param":ar(pt.decode(d.obfsparam||"").replace(/\s/g,""))},f}}}function cV(){return{name:"URI VMess Parser",test:n=>/^vmess:\/\//.test(n),parse:n=>{n=n.split("vmess://")[1];let i=pt.decode(n.replace(/\?.*?$/,""));if(/=\s*vmess/.test(i)){let a=i.split(",").map(l=>l.trim()),s={};for(let l of a)if(l.indexOf("=")!==-1){let[f,d]=l.split("=");s[f.trim()]=d.trim()}let u={name:a[0].split("=")[0].trim(),type:"vmess",server:a[1],port:a[2],cipher:ar(a[3],"auto"),uuid:a[4].match(/^"(.*)"$/)[1],tls:s.obfs==="wss",udp:Kl(s["udp-relay"]),tfo:Kl(s["fast-open"]),"skip-cert-verify":Vl(s["tls-verification"])?!s["tls-verification"]:void 0};if(Vl(s.obfs))if(s.obfs==="ws"||s.obfs==="wss"){u.network="ws",u["ws-opts"].path=(ar(s["obfs-path"])||'"/"').match(/^"(.*)"$/)[1];let l=s["obfs-header"];l&&l.indexOf("Host")!==-1&&(l=l.match(/Host:\s*([a-zA-Z0-9-.]*)/)[1]),ra(l)&&(u["ws-opts"].headers={Host:l})}else throw new Error(`Unsupported obfs: ${s.obfs}`);return u}else{let a={};try{a=JSON.parse(i)}catch{let[m,p,h]=/(^[^?]+?)\/?\?(.*)$/.exec(n);i=pt.decode(p);for(let D of h.split("&")){let[C,F]=D.split("="),U=F;U=decodeURIComponent(F),U.indexOf(",")===-1?a[C]=U:a[C]=U.split(",")}let[w,v,y,g,b]=/(^[^:]+?):([^:]+?)@(.*):(\d+)$/.exec(i);a.scy=v,a.id=y,a.port=b,a.add=g}let s=a.add,u=parseInt(Kl(a.port),10),l={name:a.ps??a.remarks??a.remark??`VMess ${s}:${u}`,type:"vmess",server:s,port:u,cipher:["auto","aes-128-gcm","chacha20-poly1305","none"].includes(a.scy)?a.scy:"auto",uuid:a.id,alterId:parseInt(Kl(a.aid??a.alterId,0),10),tls:["tls",!0,1,"1"].includes(a.tls),"skip-cert-verify":Vl(a.verify_cert)?!a.verify_cert:void 0};!l["skip-cert-verify"]&&Vl(a.allowInsecure)&&(l["skip-cert-verify"]=/(TRUE)|1/i.test(a.allowInsecure)),l.tls&&(a.sni&&a.sni!==""?l.sni=a.sni:a.peer&&a.peer!==""&&(l.sni=a.peer));let f=!1;if(a.net==="ws"||a.obfs==="websocket"?l.network="ws":["http"].includes(a.net)||["http"].includes(a.obfs)||["http"].includes(a.type)?l.network="http":["grpc","kcp","quic"].includes(a.net)?l.network=a.net:a.net==="httpupgrade"||l.network==="httpupgrade"?(l.network="ws",f=!0):(a.net==="h2"||l.network==="h2")&&(l.network="h2"),l.network){let d=a.host??a.obfsParam;try{let h=JSON.parse(d)?.Host;h&&(d=h)}catch{}let m=a.path;if(["ws"].includes(l.network)&&(m=m||"/"),l.network==="http"&&(d&&(d=d.split(",").map(p=>p.trim()),d=Array.isArray(d)?d[0]:d),m?m=Array.isArray(m)?m[0]:m:m="/"),m||d||["kcp","quic"].includes(l.network))if(["grpc"].includes(l.network))l[`${l.network}-opts`]={"grpc-service-name":ar(m),"_grpc-type":ar(a.type),"_grpc-authority":ar(a.authority)};else if(["kcp","quic"].includes(l.network))l[`${l.network}-opts`]={[`_${l.network}-type`]:ar(a.type),[`_${l.network}-host`]:ar(ar(d)),[`_${l.network}-path`]:ar(m)};else{let p={path:ar(m),headers:{Host:ar(d)}};f&&(p["v2ray-http-upgrade"]=!0,p["v2ray-http-upgrade-fast-open"]=!0),l[`${l.network}-opts`]=p}else delete l.network}return l["client-fingerprint"]=a.fp,l.alpn=a.alpn?a.alpn.split(","):void 0,l}}}}function K3(){return{name:"URI VLESS Parser",test:n=>/^vless:\/\//.test(n),parse:n=>{n=n.split("vless://")[1];let i,a=/^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);if(!a){let[y,g,b]=/^(.*?)(\?.*?$)/.exec(n);n=`${pt.decode(g)}${b}`,a=/^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(n),i=!0}let[s,u,l,f,d,m="",p]=a;i&&(u=u.replace(/^.*?:/g,"")),f=parseInt(`${f}`,10),u=decodeURIComponent(u),p!=null&&(p=decodeURIComponent(p));let h={type:"vless",name:p,server:l,port:f,uuid:u},w={};for(let y of m.split("&"))if(y){let[g,b]=y.split("="),D=b;D=decodeURIComponent(b),w[g]=D}if(h.name=p??w.remarks??w.remark??`VLESS ${l}:${f}`,h.tls=w.security&&w.security!=="none",i&&/TRUE|1/i.test(w.tls)&&(h.tls=!0,w.security=w.security??"reality"),h.sni=w.sni||w.peer,h.flow=w.flow,!h.flow&&i&&w.xtls){let y=[void 0,"xtls-rprx-direct","xtls-rprx-vision"][w.xtls];y&&(h.flow=y)}if(h["client-fingerprint"]=w.fp,h.alpn=w.alpn?w.alpn.split(","):void 0,h["skip-cert-verify"]=/(TRUE)|1/i.test(w.allowInsecure),["reality"].includes(w.security)){let y={};w.pbk&&(y["public-key"]=w.pbk),w.sid&&(y["short-id"]=w.sid),w.spx&&(y["_spider-x"]=w.spx),Object.keys(y).length>0&&(h[`${w.security}-opts`]=y)}let v=!1;if(h.network=w.type,h.network==="tcp"&&w.headerType==="http"?h.network="http":h.network==="httpupgrade"&&(h.network="ws",v=!0),!h.network&&i&&w.obfs&&(h.network=w.obfs,["none"].includes(h.network)&&(h.network="tcp")),["websocket"].includes(h.network)&&(h.network="ws"),h.network&&!["tcp","none"].includes(h.network)){let y={},g=w.host??w.obfsParam;if(g)if(w.obfsParam)try{let b=JSON.parse(g);y.headers=b}catch{y.headers={Host:g}}else y.headers={Host:g};w.serviceName?(y[`${h.network}-service-name`]=w.serviceName,["grpc"].includes(h.network)&&w.authority&&(y["_grpc-authority"]=w.authority)):i&&w.path&&(["ws","http","h2"].includes(h.network)||(y[`${h.network}-service-name`]=w.path,delete w.path)),w.path&&(y.path=w.path),["grpc"].includes(h.network)&&(y["_grpc-type"]=w.mode||"gun"),v&&(y["v2ray-http-upgrade"]=!0,y["v2ray-http-upgrade-fast-open"]=!0),Object.keys(y).length>0&&(h[`${h.network}-opts`]=y),h.network==="kcp"&&(w.seed&&(h.seed=w.seed),h.headerType=w.headerType||"none"),w.mode&&(h._mode=w.mode),w.extra&&(h._extra=w.extra)}return w.encryption&&(h.encryption=w.encryption),w.pqv&&(h._pqv=w.pqv),h}}}function fV(){return{name:"URI AnyTLS Parser",test:n=>/^anytls:\/\//.test(n),parse:n=>{let i=K3().parse(n.replace("anytls","vless"));n=n.split(/anytls:\/\//)[1];let[a,s,u,l,f="",d]=/^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(n);s=decodeURIComponent(s),l=parseInt(`${l}`,10),isNaN(l)&&(l=443),s=decodeURIComponent(s),d!=null&&(d=decodeURIComponent(d)),d=d??`AnyTLS ${u}:${l}`;let m={...i,uuid:void 0,type:"anytls",name:d,server:u,port:l,password:s};for(let p of f.split("&"))if(p){let[h,w]=p.split("=");h=h.replace(/_/g,"-"),w=decodeURIComponent(w),["alpn"].includes(h)?m[h]=w?w.split(","):void 0:["insecure"].includes(h)?m["skip-cert-verify"]=/(TRUE)|1/i.test(w):["udp"].includes(h)?m[h]=/(TRUE)|1/i.test(w):Object.keys(m).includes(h)||(m[h]=w)}return["tcp"].includes(m.network)&&!m["reality-opts"]&&(delete m.network,delete m.security),m}}}function hV(){return{name:"URI Hysteria2 Parser",test:n=>/^(hysteria2|hy2):\/\//.test(n),parse:n=>{n=n.split(/(hysteria2|hy2):\/\//)[2];let i,[a,s,u,l,f,d,m,p,h,w,v="",y]=/^(.*?)@(.*?)(:((\d+(-\d+)?)([,;]\d+(-\d+)?)*))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);/^\d+$/.test(f)?(f=parseInt(`${f}`,10),isNaN(f)&&(f=443)):f?(i=f,f=wf(i)):f=443,s=decodeURIComponent(s),y!=null&&(y=decodeURIComponent(y)),y=y??`Hysteria2 ${u}:${f}`;let g={type:"hysteria2",name:y,server:u,port:f,ports:i,password:s},b={};for(let F of v.split("&"))if(F){let[U,L]=F.split("="),S=L;S=decodeURIComponent(L),b[U]=S}g.sni=b.sni,!g.sni&&b.peer&&(g.sni=b.peer),b.obfs&&b.obfs!=="none"&&(g.obfs=b.obfs),b.mport&&(g.ports=b.mport),g["obfs-password"]=b["obfs-password"],g["skip-cert-verify"]=/(TRUE)|1/i.test(b.insecure),g.tfo=/(TRUE)|1/i.test(b.fastopen),g["tls-fingerprint"]=b.pinSHA256;let D=b["hop-interval"]||b.hop_interval;/^\d+$/.test(D)&&(g["hop-interval"]=parseInt(`${D}`,10));let C=b.keepalive;return/^\d+$/.test(C)&&(g.keepalive=parseInt(`${C}`,10)),g}}}function dV(){return{name:"URI Hysteria Parser",test:n=>/^(hysteria|hy):\/\//.test(n),parse:n=>{n=n.split(/(hysteria|hy):\/\//)[2];let[i,a,s,u,l,f="",d]=/^(.*?)(:(\d+))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);u=parseInt(`${u}`,10),isNaN(u)&&(u=443),d!=null&&(d=decodeURIComponent(d)),d=d??`Hysteria ${a}:${u}`;let m={type:"hysteria",name:d,server:a,port:u},p={};for(let h of f.split("&"))if(h){let[w,v]=h.split("=");w=w.replace(/_/,"-"),v=decodeURIComponent(v),["alpn"].includes(w)?m[w]=v?v.split(","):void 0:["insecure"].includes(w)?m["skip-cert-verify"]=/(TRUE)|1/i.test(v):["auth"].includes(w)?m["auth-str"]=v:["mport"].includes(w)?m.ports=v:["obfsParam"].includes(w)?m.obfs=v:["upmbps"].includes(w)?m.up=v:["downmbps"].includes(w)?m.down=v:["obfs"].includes(w)?m._obfs=v||"":["fast-open","peer"].includes(w)?p[w]=v:Object.keys(m).includes(w)||(m[w]=v)}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 pV(){return{name:"URI TUIC Parser",test:n=>/^tuic:\/\//.test(n),parse:n=>{n=n.split(/tuic:\/\//)[1];let[i,a,s,u,l="",f]=/^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(n);a=decodeURIComponent(a);let[d,...m]=a.split(":"),p=m.join(":");u=parseInt(`${u}`,10),isNaN(u)&&(u=443),p=decodeURIComponent(p),f!=null&&(f=decodeURIComponent(f)),f=f??`TUIC ${s}:${u}`;let h={type:"tuic",name:f,server:s,port:u,password:p,uuid:d};for(let w of l.split("&"))if(w){let[v,y]=w.split("=");v=v.replace(/_/g,"-"),y=decodeURIComponent(y),["alpn"].includes(v)?h[v]=y?y.split(","):void 0:["allow-insecure","insecure"].includes(v)?h["skip-cert-verify"]=/(TRUE)|1/i.test(y):["fast-open"].includes(v)?h.tfo=!0:["disable-sni","reduce-rtt"].includes(v)?h[v]=/(TRUE)|1/i.test(y):v==="congestion-control"?(h["congestion-controller"]=y,delete h[v]):Object.keys(h).includes(v)||(h[v]=y)}return h}}}function gV(){return{name:"URI WireGuard Parser",test:n=>/^(wireguard|wg):\/\//.test(n),parse:n=>{n=n.split(/(wireguard|wg):\/\//)[2];let[i,a,s,u,l,f,d,m="",p]=/^((.*?)@)?(.*?)(:(\d+))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);f=parseInt(`${f}`,10),isNaN(f)&&(f=51820),s=decodeURIComponent(s),p!=null&&(p=decodeURIComponent(p)),p=p??`WireGuard ${u}:${f}`;let h={type:"wireguard",name:p,server:u,port:f,"private-key":s,udp:!0};for(let w of m.split("&"))if(w){let[v,y]=w.split("=");if(v=v.replace(/_/,"-"),y=decodeURIComponent(y),["reserved"].includes(v)){let g=y.split(",").map(b=>parseInt(b.trim(),10)).filter(b=>Number.isInteger(b));g.length===3&&(h[v]=g)}else if(["address","ip"].includes(v))y.split(",").map(g=>{let b=g.trim().replace(/\/\d+$/,"").replace(/^\[/,"").replace(/\]$/,"");Mr(b)?h.ip=b:Xr(b)&&(h.ipv6=b)});else if(["mtu"].includes(v)){let g=parseInt(y.trim(),10);Number.isInteger(g)&&(h[v]=g)}else/publickey/i.test(v)?h["public-key"]=y:/privatekey/i.test(v)?h["private-key"]=y:["udp"].includes(v)?h[v]=/(TRUE)|1/i.test(y):[...Object.keys(h),"flag"].includes(v)||(h[v]=y)}return h}}}function mV(){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,u]=n.split(/#(.+)/,2),f=z2().parse(s);if(ra(u))try{f.name=decodeURIComponent(u)}catch(d){console.log(d)}return f}}}function vV(){return{name:"Clash Parser",test:n=>{let i;try{i=X2.default.parse(n)}catch{i=aa.parse(n)}return!!i?.type},parse:n=>{let i;try{i=X2.default.parse(n)}catch{i=aa.parse(n)}if(!["naive","anytls","mieru","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.sni=i.servername,delete i.servername),i["server-cert-fingerprint"]&&(i["tls-fingerprint"]=i["server-cert-fingerprint"]),i.fingerprint&&(i["tls-fingerprint"]=i.fingerprint),i["dialer-proxy"]&&(i["underlying-proxy"]=i["dialer-proxy"]),i["benchmark-url"]&&(i["test-url"]=i["benchmark-url"]),i["benchmark-timeout"]&&(i["test-timeout"]=i["benchmark-timeout"]),i}}}function wV(){return{name:"QX SS Parser",test:n=>/^shadowsocks\s*=/.test(n.split(",")[0].trim())&&n.indexOf("ssr-protocol")===-1,parse:n=>Cu().parse(n)}}function AV(){return{name:"QX SSR Parser",test:n=>/^shadowsocks\s*=/.test(n.split(",")[0].trim())&&n.indexOf("ssr-protocol")!==-1,parse:n=>Cu().parse(n)}}function EV(){return{name:"QX VMess Parser",test:n=>/^vmess\s*=/.test(n.split(",")[0].trim()),parse:n=>Cu().parse(n)}}function bV(){return{name:"QX VLESS Parser",test:n=>/^vless\s*=/.test(n.split(",")[0].trim()),parse:n=>Cu().parse(n)}}function yV(){return{name:"QX Trojan Parser",test:n=>/^trojan\s*=/.test(n.split(",")[0].trim()),parse:n=>Cu().parse(n)}}function _V(){return{name:"QX HTTP Parser",test:n=>/^http\s*=/.test(n.split(",")[0].trim()),parse:n=>Cu().parse(n)}}function CV(){return{name:"QX Socks5 Parser",test:n=>/^socks5\s*=/.test(n.split(",")[0].trim()),parse:n=>Cu().parse(n)}}function DV(){return{name:"Loon SS Parser",test:n=>n.split(",")[0].split("=")[1].trim().toLowerCase()==="shadowsocks",parse:n=>$a().parse(n)}}function FV(){return{name:"Loon SSR Parser",test:n=>n.split(",")[0].split("=")[1].trim().toLowerCase()==="shadowsocksr",parse:n=>$a().parse(n)}}function SV(){return{name:"Loon VMess Parser",test:n=>/^.*=\s*vmess/i.test(n.split(",")[0])&&n.indexOf("username")===-1,parse:n=>$a().parse(n)}}function IV(){return{name:"Loon Vless Parser",test:n=>/^.*=\s*vless/i.test(n.split(",")[0]),parse:n=>$a().parse(n)}}function BV(){return{name:"Loon Trojan Parser",test:n=>/^.*=\s*trojan/i.test(n.split(",")[0]),parse:n=>$a().parse(n)}}function $V(){return{name:"Loon Hysteria2 Parser",test:n=>/^.*=\s*Hysteria2/i.test(n.split(",")[0]),parse:n=>$a().parse(n)}}function PV(){return{name:"Loon HTTP Parser",test:n=>/^.*=\s*http/i.test(n.split(",")[0]),parse:n=>$a().parse(n)}}function xV(){return{name:"Loon SOCKS5 Parser",test:n=>/^.*=\s*socks5/i.test(n.split(",")[0]),parse:n=>$a().parse(n)}}function RV(){return{name:"Loon WireGuard Parser",test:n=>/^.*=\s*wireguard/i.test(n.split(",")[0]),parse:n=>{let i=n.match(/(^.*?)\s*?=\s*?wireguard\s*?,.+?\s*?=\s*?.+?/i)?.[1];n=n.replace(i,"").replace(/^\s*?=\s*?wireguard\s*/i,"");let a=n.match(/,\s*?peers\s*?=\s*?\[\s*?\{\s*?(.+?)\s*?\}\s*?\]/i)?.[1],s=a.match(/(,|^)\s*?endpoint\s*?=\s*?"?(.+?):(\d+)"?\s*?(,|$)/i),u=s?.[2],l=parseInt(s?.[3],10),f=n.match(/(,|^)\s*?mtu\s*?=\s*?"?(\d+?)"?\s*?(,|$)/i)?.[2];f&&(f=parseInt(f,10));let d=n.match(/(,|^)\s*?keepalive\s*?=\s*?"?(\d+?)"?\s*?(,|$)/i)?.[2];d&&(d=parseInt(d,10));let m=a.match(/(,|^)\s*?reserved\s*?=\s*?"?(\[\s*?.+?\s*?\])"?\s*?(,|$)/i)?.[2];m&&(m=JSON.parse(m));let p,h=n.match(/(,|^)\s*?dns\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],w=n.match(/(,|^)\s*?dnsv6\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2];(h||w)&&(p=[],h&&p.push(h),w&&p.push(w));let v=a.match(/(,|^)\s*?allowed-ips\s*?=\s*?"(.+?)"\s*?(,|$)/i)?.[2]?.split(",").map(F=>F.trim()),y=a.match(/(,|^)\s*?preshared-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],g=n.match(/(,|^)\s*?interface-ip\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],b=n.match(/(,|^)\s*?interface-ipv6\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],D=a.match(/(,|^)\s*?public-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],C={type:"wireguard",name:i,server:u,port:l,ip:g,ipv6:b,"private-key":n.match(/(,|^)\s*?private-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],"public-key":D,mtu:f,keepalive:d,reserved:m,"allowed-ips":v,"preshared-key":y,dns:p,udp:!0,peers:[{server:u,port:l,ip:g,ipv6:b,"public-key":D,"pre-shared-key":y,"allowed-ips":v,reserved:m}]};return Array.isArray(C.dns)&&C.dns.length>0&&(C["remote-dns-resolve"]=!0),C}}}function TV(){return{name:"Surge Direct Parser",test:n=>/^.*=\s*direct/.test(n.split(",")[0]),parse:n=>Pi().parse(n)}}function OV(){return{name:"Surge Anytls Parser",test:n=>/^.*=\s*anytls/.test(n.split(",")[0]),parse:n=>Pi().parse(n)}}function kV(){return{name:"Surge SSH Parser",test:n=>/^.*=\s*ssh/.test(n.split(",")[0]),parse:n=>Pi().parse(n)}}function NV(){return{name:"Surge SS Parser",test:n=>/^.*=\s*ss/.test(n.split(",")[0]),parse:n=>Pi().parse(n)}}function LV(){return{name:"Surge VMess Parser",test:n=>/^.*=\s*vmess/.test(n.split(",")[0])&&n.indexOf("username")!==-1,parse:n=>Pi().parse(n)}}function UV(){return{name:"Surge Trojan Parser",test:n=>/^.*=\s*trojan/.test(n.split(",")[0]),parse:n=>Pi().parse(n)}}function jV(){return{name:"Surge HTTP Parser",test:n=>/^.*=\s*https?/.test(n.split(",")[0]),parse:n=>Pi().parse(n)}}function HV(){return{name:"Surge Socks5 Parser",test:n=>/^.*=\s*socks5(-tls)?/.test(n.split(",")[0]),parse:n=>Pi().parse(n)}}function MV(){return{name:"Surge External Parser",test:n=>/^.*=\s*external/.test(n.split(",")[0]),parse:n=>{let i=/^\s*(.*?)\s*?=\s*?external\s*?,\s*(.*?)\s*$/.exec(n),[a,s,u]=i;n=u;let l=/(,|^)\s*?exec\s*?=\s*"(.*?)"\s*?(,|$)/.exec(n)?.[2];l||(l=/(,|^)\s*?exec\s*?=\s*(.*?)\s*?(,|$)/.exec(n)?.[2]);let f=/(,|^)\s*?local-port\s*?=\s*"(.*?)"\s*?(,|$)/.exec(n)?.[2];f||(f=/(,|^)\s*?local-port\s*?=\s*(.*?)\s*?(,|$)/.exec(n)?.[2]);let d=/(,|^)\s*?args\s*?=\s*("(.*?)"|(.*?))(?=\s*?(,|$))/g,m,p=[];for(;(m=d.exec(n))!==null;)m[3]!=null?p.push(m[3]):m[4]!=null&&p.push(m[4]);let h=/(,|^)\s*?addresses\s*?=\s*("(.*?)"|(.*?))(?=\s*?(,|$))/g,w,v=[];for(;(w=h.exec(n))!==null;){let g;w[3]!=null?g=w[3]:w[4]!=null&&(g=w[4]),g!=null&&(g=`${g}`.trim().replace(/^\[/,"").replace(/\]$/,"")),GV(g)&&v.push(g)}return{type:"external",name:s,exec:l,"local-port":f,args:p,addresses:v}}}}function qV(){return{name:"Surge Snell Parser",test:n=>/^.*=\s*snell/.test(n.split(",")[0]),parse:n=>Pi().parse(n)}}function VV(){return{name:"Surge Tuic Parser",test:n=>/^.*=\s*tuic(-v5)?/.test(n.split(",")[0]),parse:n=>{let{port_hopping:i,line:a}=V3(n),s=Pi().parse(a);return s.ports=i,s}}}function KV(){return{name:"Surge WireGuard Parser",test:n=>/^.*=\s*wireguard/.test(n.split(",")[0]),parse:n=>Pi().parse(n)}}function zV(){return{name:"Surge Hysteria2 Parser",test:n=>/^.*=\s*hysteria2/.test(n.split(",")[0]),parse:n=>{let{port_hopping:i,line:a}=V3(n),s=Pi().parse(a);return s.ports=i,s}}}function GV(e){return Mr(e)||Xr(e)}var z3=[aV(),uV(),oV(),lV(),cV(),K3(),pV(),gV(),dV(),hV(),mV(),fV(),vV(),TV(),OV(),kV(),NV(),LV(),UV(),jV(),qV(),VV(),KV(),zV(),HV(),MV(),DV(),FV(),SV(),IV(),$V(),BV(),PV(),xV(),RV(),wV(),AV(),EV(),bV(),yV(),_V(),CV()];var X3=_n(W2());function YV(e){for(let t of fd)try{if(t.test(e))return k.info(`Pre-processor [${t.name}] activated`),t.parse(e)}catch(r){k.error(`Parser [${t.name}] failed Reason: ${r}`)}return e}function WV(e){e=YV(e);let t=e.split(` `),r=[],n;for(let i of t){if(i=i.trim(),i.length===0)continue;let a=!1;if(n){let[s,u]=G3(n,i);u||(r.push(W3(s)),a=!0)}if(!a)for(let s of z3){let[u,l]=G3(s,i);if(!l){r.push(W3(u)),n=s,a=!0,k.info(`${s.name} is activated`);break}}a||k.error(`Failed to parse line: ${i}`)}return r.filter(i=>(["vless","vmess"].includes(i.type)&&(K0(i.uuid)||k.info(`UUID may be invalid: ${i.name} ${i.uuid}`)),!0))}async function XV(proxies,operators=[],targetPlatform,source,$options){for(let item of operators){if(item.disabled){k.log(`Skipping disabled operator: "${item.type}" with arguments: >>> ${JSON.stringify(item.args,null,2)||"None"}`);continue}let script,$arguments={};if(item.type.indexOf("Script")!==-1){let{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"?On:xt,n=Rt(k.read(r),t);if(!n)throw new Error(`\u627E\u4E0D\u5230 ${e}: ${t}`);e==="module"?script=n.content:script=await wa({type:"file",name:t})}catch(t){throw k.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 k.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 Qi(url)}catch(e){throw k.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||{}}if(!kd[item.type]){k.error(`Unknown operator: "${item.type}"`);continue}k.log(`Applying "${item.type}" with arguments: >>> ${JSON.stringify(item.args,null,2)||"None"}`);let processor;item.type.indexOf("Script")!==-1?processor=kd[item.type](script,targetPlatform,$arguments,source,$options):processor=kd[item.type](item.args||{}),proxies=await k_(processor,proxies)}return proxies}function JV(e,t,r,n={}){let i=TD[t];if(!i)throw new Error(`Target platform: ${t} is not supported!`);let a=/Surge|SurgeMac|Shadowrocket/i.test(t);if(e=e.filter(s=>s.supported&&s.supported[t]===!1?!1:(["vless","vmess"].includes(s.type)&&(K0(s.uuid)||k.info(`UUID may be invalid: ${s.name} ${s.uuid}`)),!0)),e=e.map(s=>(s._resolved=s.resolved,ra(s.name)||(s.name=`${s.type} ${s.server}:${s.port}`),s["disable-sni"]&&(a?s.sni="off":["tuic"].includes(s.type)||(k.error(`Target platform ${t} does not support sni off. Proxy's fields (sni, tls-fingerprint and skip-cert-verify) will be modified.`),s.sni="",s["skip-cert-verify"]=!0,delete s["tls-fingerprint"])),s.ports&&(s.ports=String(s.ports),["ClashMeta"].includes(t)||(s.ports=s.ports.replace(/\//g,",")),s.port||(s.port=wf(s.ports))),s)),k.log(`Producing proxies for target: ${t}`),typeof i.type>"u"||i.type==="SINGLE"){let s=e.map(u=>{try{return i.produce(u,r,n)}catch(l){return k.error(`Cannot produce proxy: ${JSON.stringify(u,null,2)} Reason: ${l}`),""}}).filter(u=>u.length>0);return s=r==="internal"?s:s.join(` `),t.startsWith("Surge")&&e.length>0&&e.every(u=>u.type==="wireguard")&&(s=`#!name=${e[0]?._subName} #!desc=${e[0]?._desc??""} #!category=${e[0]?._category??""} ${s}`),s}else if(i.type==="ALL")return i.produce(e,r,n)}var yr={parse:WV,process:XV,produce:JV,ipAddress:V0,getRandomPort:wf,isIPv4:Mr,isIPv6:Xr,isIP:J2,yaml:aa,getFlag:hc,removeFlag:kf,getISO:w_,MMDB:$d,Gist:cs,download:Qi,downloadFile:J3,isValidUUID:K0,doh:pc,Buffer:Rp.Buffer,Base64:pt,JSON5:X3.default};function G3(e,t){if(!ZV(e,t))return[null,new Error("Parser mismatch")];try{return[e.parse(t),null]}catch(r){return[null,r]}}function ZV(e,t){try{return e.test(t)}catch{return!1}}function Y3(e){if(typeof e=="string"||typeof e=="number"){if(e=String(e).trim(),e==="")return"/";if(!e.startsWith("/"))return"/"+e}return e}function W3(e){typeof e.cipher=="string"&&(e.cipher=e.cipher.toLowerCase()),typeof e.password=="number"&&(e.password=SE(e.password)),["ss"].includes(e.type)&&e.cipher==="none"&&!e.password&&(e.password=""),e.interface&&(e["interface-name"]=e.interface,delete e.interface),FE(e.port)&&(e.port=parseInt(e.port,10)),e.server&&(e.server=`${e.server}`.trim().replace(/^\[/,"").replace(/\]$/,"")),e.network==="ws"&&(!e["ws-opts"]&&(e["ws-path"]||e["ws-headers"])&&(e["ws-opts"]={},e["ws-path"]&&(e["ws-opts"].path=e["ws-path"]),e["ws-headers"]&&(e["ws-opts"].headers=e["ws-headers"])),delete e["ws-path"],delete e["ws-headers"]);let t=e[`${e.network}-opts`]?.path;if(Array.isArray(t)?e[`${e.network}-opts`].path=t.map(n=>Y3(n)):t!=null&&(e[`${e.network}-opts`].path=Y3(t)),e.type==="trojan"&&e.network==="tcp"&&delete e.network,["vless"].includes(e.type)&&(e.network||(e.network="tcp")),["trojan","tuic","hysteria","hysteria2","juicity","anytls","naive"].includes(e.type)&&(e.tls=!0),e.network){let n=e[`${e.network}-opts`]?.headers?.Host,i=e[`${e.network}-opts`]?.headers?.host;e.network==="h2"?!i&&n&&(e[`${e.network}-opts`].headers.host=n,delete e[`${e.network}-opts`].headers.Host):i&&!n&&(e[`${e.network}-opts`].headers.Host=i,delete e[`${e.network}-opts`].headers.host)}if(e.network==="h2"){let n=e["h2-opts"]?.headers?.host,i=e["h2-opts"]?.path;n&&!Array.isArray(n)&&(e["h2-opts"].headers.host=[n]),Array.isArray(i)&&(e["h2-opts"].path=i[0])}if(!e.tls&&["ws","http"].includes(e.network)&&!e[`${e.network}-opts`]?.headers?.Host&&!J2(e.server)&&(e[`${e.network}-opts`]=e[`${e.network}-opts`]||{},e[`${e.network}-opts`].headers=e[`${e.network}-opts`].headers||{},e[`${e.network}-opts`].headers.Host=["vmess","vless"].includes(e.type)&&e.network==="http"?[e.server]:e.server),["vmess","vless"].includes(e.type)&&e.network==="http"){let n=e[`${e.network}-opts`]?.path,i=e[`${e.network}-opts`]?.headers?.Host;i&&!Array.isArray(i)&&(e[`${e.network}-opts`].headers.Host=[i]),n&&!Array.isArray(n)&&(e[`${e.network}-opts`].path=[n])}if(e.tls&&!e.sni&&(J2(e.server)||(e.sni=e.server),!e.sni&&e.network)){let n=e[`${e.network}-opts`]?.headers?.Host;n=Array.isArray(n)?n[0]:n,n&&(e.sni=n)}if(e.ports?e.ports=String(e.ports).replace(/\//g,","):delete e.ports,["hysteria2"].includes(e.type)&&e.obfs&&!["salamander"].includes(e.obfs)&&!e["obfs-password"]&&(e["obfs-password"]=e.obfs,e.obfs="salamander"),["hysteria2"].includes(e.type)&&!e["obfs-password"]&&e.obfs_password&&(e["obfs-password"]=e.obfs_password,delete e.obfs_password),["vless"].includes(e.type)&&(e["reality-opts"]&&Object.keys(e["reality-opts"]).length===0&&delete e["reality-opts"],e["grpc-opts"]&&Object.keys(e["grpc-opts"]).length===0&&delete e["grpc-opts"],!e["reality-opts"]&&!e.flow&&delete e.flow,["http"].includes(e.network)&&(e[`${e.network}-opts`]?.path||(e[`${e.network}-opts`]||(e[`${e.network}-opts`]={}),e[`${e.network}-opts`].path=["/"]))),typeof e.name!="string")if(/^\d+$/.test(e.name))e.name=`${e.name}`;else try{e.name?.data?e.name=Rp.Buffer.from(e.name.data).toString("utf8"):e.name=Rp.Buffer.from(e.name).toString("utf8")}catch(n){k.error(`proxy.name decode failed Reason: ${n}`),e.name=`${e.type} ${e.server}:${e.port}`}["ws","http","h2"].includes(e.network)&&(["ws","h2"].includes(e.network)&&!e[`${e.network}-opts`]?.path?(e[`${e.network}-opts`]=e[`${e.network}-opts`]||{},e[`${e.network}-opts`].path="/"):e.network==="http"&&(!Array.isArray(e[`${e.network}-opts`]?.path)||e[`${e.network}-opts`]?.path.every(n=>!n))&&(e[`${e.network}-opts`]=e[`${e.network}-opts`]||{},e[`${e.network}-opts`].path=["/"])),["","off"].includes(e.sni)&&(e["disable-sni"]=!0);let r=e.ca_str;e["ca-str"]?r=e["ca-str"]:r&&(delete e.ca_str,e["ca-str"]=r);try{k.env.isNode&&!r&&e._ca&&(r=k.node.fs.readFileSync(e._ca,{encoding:"utf8"}))}catch(n){k.error(`Read ca file failed Reason: ${n}`)}return!e["tls-fingerprint"]&&r&&(e["tls-fingerprint"]=v_.generateFingerprint(r)),["ss"].includes(e.type)&&ue(e,"shadow-tls-password")&&(e.plugin="shadow-tls",e["plugin-opts"]={host:e["shadow-tls-sni"],password:e["shadow-tls-password"],version:e["shadow-tls-version"]},delete e["shadow-tls-sni"],delete e["shadow-tls-password"],delete e["shadow-tls-version"]),e}function J2(e){return Mr(e)||Xr(e)}var Z3=fd.find(e=>e.name==="Clash Pre-processor"),Z2=new Map;async function Qi(rawUrl="",ua,timeout,customProxy,skipCustomCache,awaitCustomCache,noCache,preprocess){let $arguments={},url=rawUrl.replace(/#noFlow$/,""),rawArgs=url.split("#");if(url=url.split("#")[0],rawArgs.length>1)try{$arguments=JSON.parse(decodeURIComponent(rawArgs[1]))}catch{for(let t of rawArgs[1].split("&")){let r=t.split("=")[0],n=t.split("=")[1];$arguments[r]=n==null||n===""?!0:decodeURIComponent(n)}}let{isNode,isStash,isLoon,isShadowRocket,isQX}=an(),{defaultProxy,defaultUserAgent,defaultTimeout,cacheThreshold:defaultCacheThreshold}=k.read(jt),cacheThreshold=defaultCacheThreshold||1024,proxy=customProxy||defaultProxy;k.env.isNode&&(proxy=proxy||eval("process.env.SUB_STORE_BACKEND_DEFAULT_PROXY"));let userAgent=ua||defaultUserAgent||"clash.meta",requestTimeout=timeout||defaultTimeout||8e3,id=Mi(userAgent+url);$arguments?.cacheKey===!0&&(k.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=k.read(customCacheKey),t=qr.get(id);if(!noCache&&!$arguments?.noCache&&t)return k.info(`\u4E50\u89C2\u7F13\u5B58: URL ${url} \u5B58\u5728\u6709\u6548\u7684\u5E38\u89C4\u7F13\u5B58 \u4F7F\u7528\u5E38\u89C4\u7F13\u5B58\u4EE5\u907F\u514D\u91CD\u590D\u8BF7\u6C42`),t;if(e){if(awaitCustomCache){k.info(`\u4E50\u89C2\u7F13\u5B58: URL ${url} \u672C\u6B21\u8FDB\u884C\u8BF7\u6C42 \u5C1D\u8BD5\u66F4\u65B0\u7F13\u5B58`);try{await Qi(rawUrl.replace(/(\?|&)cacheKey=.*?(&|$)/,""),ua,timeout,proxy,!0,void 0,void 0,preprocess)}catch(r){k.error(`\u4E50\u89C2\u7F13\u5B58: URL ${url} \u66F4\u65B0\u7F13\u5B58\u53D1\u751F\u9519\u8BEF ${r.message??r}`),k.info("\u4F7F\u7528\u4E50\u89C2\u7F13\u5B58\u7684\u6570\u636E\u5237\u65B0\u7F13\u5B58, \u9632\u6B62\u540E\u7EED\u8BF7\u6C42"),qr.set(id,e)}}else k.info(`\u4E50\u89C2\u7F13\u5B58: URL ${url} \u672C\u6B21\u8FD4\u56DE\u81EA\u5B9A\u4E49\u7F13\u5B58 ${$arguments?.cacheKey} \u5E76\u8FDB\u884C\u8BF7\u6C42 \u5C1D\u8BD5\u5F02\u6B65\u66F4\u65B0\u7F13\u5B58`),Qi(rawUrl.replace(/(\?|&)cacheKey=.*?(&|$)/,""),ua,timeout,proxy,!0,void 0,void 0,preprocess).catch(r=>{k.error(`\u4E50\u89C2\u7F13\u5B58: URL ${url} \u5F02\u6B65\u66F4\u65B0\u7F13\u5B58\u53D1\u751F\u9519\u8BEF ${r.message??r}`)});return e}}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"?On:xt,n=Rt(k.read(r),t);if(!n)throw new Error(`\u627E\u4E0D\u5230 ${e}: ${t}`);return e==="module"?n.content:await wa({type:"file",name:t})}catch(t){throw k.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 fs.readFileSync(url.split("#")[0],"utf8")}catch(e){throw k.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&&Z2.has(id))return Z2.get(id);let http=Xa({headers:{"User-Agent":userAgent,...isStash&&proxy?{"X-Stash-Selected-Proxy":encodeURIComponent(proxy)}:{},...isShadowRocket&&proxy?{"X-Surge-Policy":proxy}:{}},timeout:requestTimeout}),result,cached=qr.get(id);if(!noCache&&!$arguments?.noCache&&cached)k.info(`\u4F7F\u7528\u7F13\u5B58: ${url}, ${userAgent}`),result=cached,customCacheKey&&(k.info(`URL ${url} \u5199\u5165\u81EA\u5B9A\u4E49\u7F13\u5B58 ${$arguments?.cacheKey}`),k.write(cached,customCacheKey));else{let e=$arguments?.insecure?isNode?{strictSSL:!1}:{insecure:!0}:void 0;k.info(`Downloading... User-Agent: ${userAgent} Timeout: ${requestTimeout} Proxy: ${proxy} Insecure: ${!!e} Preprocess: ${preprocess} URL: ${url}`);try{let{body:t,headers:r,statusCode:n}=await http.get({url,...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?Za(proxy):{},...e||{}});if(k.info(`statusCode: ${n}`),n<200||n>=400)throw new Error(`statusCode: ${n}`);if(r){let a=zl(r);a&&Lo.set(id,a)}if(t.replace(/\s/g,"").length===0)throw new Error(new Error("\u8FDC\u7A0B\u8D44\u6E90\u5185\u5BB9\u4E3A\u7A7A"));if(preprocess)try{Z3.test(t)&&(t=Z3.parse(t,!0))}catch(a){k.error(`Clash Pre-processor error: ${a}`)}let i=!0;if(cacheThreshold){let a=t.length/1024;a>cacheThreshold&&(k.info(`\u8D44\u6E90\u5927\u5C0F ${a.toFixed(2)} KB \u8D85\u8FC7\u4E86 ${cacheThreshold} KB, \u4E0D\u7F13\u5B58`),i=!1)}if(preprocess)try{let a=yr.parse(t);(!Array.isArray(a)||a.length===0)&&(k.error(`URL ${url} \u4E0D\u5305\u542B\u6709\u6548\u8282\u70B9, \u4E0D\u7F13\u5B58`),i=!1)}catch(a){k.error(`URL ${url} \u5C1D\u8BD5\u89E3\u6790\u8282\u70B9\u5931\u8D25 ${a.message??a}, \u4E0D\u7F13\u5B58`),i=!1}i&&(qr.set(id,t),customCacheKey&&(k.info(`URL ${url} \u5199\u5165\u81EA\u5B9A\u4E49\u7F13\u5B58 ${$arguments?.cacheKey}`),k.write(t,customCacheKey))),result=t}catch(t){if(customCacheKey){let r=k.read(customCacheKey);if(r)return k.info(`\u65E0\u6CD5\u4E0B\u8F7D URL ${url}: ${t.message??t} \u4F7F\u7528\u81EA\u5B9A\u4E49\u7F13\u5B58 ${$arguments?.cacheKey}`),r}throw new Error(`\u65E0\u6CD5\u4E0B\u8F7D URL ${url}: ${t.message??t}`)}}return $arguments?.validCheck&&await G0(Uo(await na(url,$arguments.flowUserAgent,void 0,proxy,$arguments.flowUrl))),isNode||Z2.set(id,result),result}async function J3(url,file){let undici=eval("require('undici')"),fs=eval("require('fs')"),{pipeline}=eval("require('stream/promises')"),{Agent,interceptors,request}=undici;k.info(`Downloading file... URL: ${url} File: ${file}`);let{body,statusCode}=await request(url,{dispatcher:new Agent().compose(interceptors.redirect({maxRedirections:3,throwOnRedirect:!0}))});if(statusCode!==200)throw new Error(`Failed to download file from ${url}`);let fileStream=fs.createWriteStream(file);return await pipeline(body,fileStream),k.info(`File downloaded from ${url} to ${file}`),file}function QV(){return{name:"HTML",test:n=>/^/.test(n),parse:()=>""}}function eK(){return{name:"Clash Provider",test:n=>/^payload:/gm.exec(n).index>=0,parse:n=>n.replace("payload:","").replace(/^\s*-\s*/gm,"")}}var Q3=[QV(),eK()];function tK(){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 e5(){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 rK(){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))),e5().func(r))}}function nK(){return{type:"ALL",func:r=>{let n={"DEST-PORT":"DST-PORT","SRC-IP":"SRC-IP-CIDR","IN-PORT":"SRC-PORT"},i={payload:r.map(a=>{let s=`${n[a.type]||a.type},${a.content}`;return["IP-CIDR","IP-CIDR6","GEOIP"].includes(a.type)&&(a.options&&(a.options=a.options.filter(u=>["no-resolve"].includes(u))),s+=a.options?.length>0?`,${a.options.join(",")}`:""),s})};return aa.dump(i)}}}var t5={QX:tK(),Surge:e5(),Loon:rK(),Clash:nK()};var iK=[[/^(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 sK(){return{name:"Universal Rule Parser",test:()=>!0,parse:n=>{let i=n.split(` `),a=[];for(let s of i)if(s=s.trim(),s.length!==0&&!/\s*#/.test(s))try{let u=s.split(",").map(d=>d.trim()),l=u[0],f=!1;for(let d of iK)if(d[0].test(l)){f=!0;let p={type:d[1],content:u[1]};["IP-CIDR","IP-CIDR6","GEOIP"].includes(p.type)&&(p.options=u.slice(2)),a.push(p)}if(!f)throw new Error("Invalid rule type: "+l)}catch(u){console.log(`Failed to parse line: ${s} Reason: ${u}`)}return a}}}var r5=[sK()];var Tp=function(){function e(n){for(let i of Q3)try{if(i.test(n))return k.info(`Pre-processor [${i.name}] activated`),i.parse(n)}catch(a){k.error(`Parser [${i.name}] failed Reason: ${a}`)}return n}function t(n){n=e(n);for(let i of r5){let a;try{a=i.test(n)}catch{a=!1}if(a)return k.info(`Rule parser [${i.name}] is activated!`),i.parse(n)}}function r(n,i){let a=t5[i];if(!a)throw new Error(`Target platform: ${i} is not supported!`);if(typeof a.type>"u"||a.type==="SINGLE")return n.map(s=>{try{return a.func(s)}catch(u){return console.log(`ERROR: cannot produce rule: ${JSON.stringify(s)} Reason: ${u}`),""}}).filter(s=>s.length>0).join(` `);if(a.type==="ALL")return a.func(n)}return{parse:t,produce:r}}();async function wa({type:e,name:t,platform:r,url:n,ua:i,content:a,mergeSources:s,ignoreFailedRemoteSub:u,ignoreFailedRemoteFile:l,produceType:f,produceOpts:d={},subscription:m,awaitCustomCache:p,$options:h,proxy:w,noCache:v,all:y}){if(r=r||"JSON",["subscription","sub"].includes(e)){let g;if(t){let F=k.read(mr);if(g=Rt(F,t),!g)throw new Error(`\u627E\u4E0D\u5230\u8BA2\u9605 ${t}`)}else if(m)g=m;else throw new Error("\u672A\u63D0\u4F9B\u8BA2\u9605\u540D\u79F0\u6216\u8BA2\u9605\u6570\u636E");let b;if(a&&!["localFirst","remoteFirst"].includes(s))b=a;else if(n){let F={};b=await Promise.all(n.split(/[\r\n]+/).map(L=>L.trim()).filter(L=>L.length).map(async L=>{try{return await Qi(L,i||g.ua,void 0,w||g.proxy,void 0,p,v||g.noCache,!0)}catch(S){return F[L]=S,k.error(`\u8BA2\u9605 ${g.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${L} \u53D1\u751F\u9519\u8BEF: ${S}`),""}}));let U=g.ignoreFailedRemoteSub;if(u!=null&&u!==""&&(U=u),Object.keys(F).length>0)if(U)U==="enabled"&&k.notify("\u{1F30D} Sub-Store \u5904\u7406\u8BA2\u9605\u5931\u8D25",`\u274C ${g.name}`,`\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(F).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);else throw new Error(`\u8BA2\u9605 ${g.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(F).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);s==="localFirst"?b.unshift(a):s==="remoteFirst"&&b.push(a)}else if(g.source==="local"&&!["localFirst","remoteFirst"].includes(g.mergeSources))b=g.content;else{let F={};b=await Promise.all(g.url.split(/[\r\n]+/).map(L=>L.trim()).filter(L=>L.length).map(async L=>{try{return await Qi(L,i||g.ua,void 0,w||g.proxy,void 0,p,v||g.noCache,!0)}catch(S){return F[L]=S,k.error(`\u8BA2\u9605 ${g.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${L} \u53D1\u751F\u9519\u8BEF: ${S}`),""}}));let U=g.ignoreFailedRemoteSub;if(u!=null&&u!==""&&(U=u),Object.keys(F).length>0)if(U)U==="enabled"&&k.notify("\u{1F30D} Sub-Store \u5904\u7406\u8BA2\u9605\u5931\u8D25",`\u274C ${g.name}`,`\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(F).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);else throw new Error(`\u8BA2\u9605 ${g.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(F).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);g.mergeSources==="localFirst"?b.unshift(g.content):g.mergeSources==="remoteFirst"&&b.push(g.content)}if(f==="raw")return JSON.stringify((Array.isArray(b)?b:[b]).flat());let D=(Array.isArray(b)?b:[b]).map(F=>yr.parse(F)).flat();if(D.forEach(F=>{F._subName=g.name,F._subDisplayName=g.displayName}),D=await yr.process(D,g.process||[],r,{[g.name]:g},h),D.length===0)throw new Error(`\u8BA2\u9605 ${t} \u4E2D\u4E0D\u542B\u6709\u6548\u8282\u70B9`);let C={};for(let F of D){if(C[F.name]){k.notify("\u{1F30D} Sub-Store",`\u26A0\uFE0F \u8BA2\u9605 ${t} \u5305\u542B\u91CD\u590D\u8282\u70B9 ${F.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}C[F.name]=!0}return yr.produce(D,r,f,d)}else if(["collection","col"].includes(e)){let g=k.read(mr),b=k.read(sr),D=Rt(b,t);if(!D)throw new Error(`\u627E\u4E0D\u5230\u7EC4\u5408\u8BA2\u9605 ${t}`);let C=[...D.subscriptions],F=D.subscriptionTags;Array.isArray(F)&&F.length>0&&g.forEach(j=>{Array.isArray(j.tag)&&j.tag.length>0&&!C.includes(j.name)&&j.tag.some(Y=>F.includes(Y))&&C.push(j.name)});let U={},L={},S=0;await Promise.all(C.map(async j=>{let Y=Rt(g,j),M=Y.passThroughUA,z=Y.ua;M&&(k.info(`\u8BA2\u9605\u5F00\u542F\u4E86\u900F\u4F20 User-Agent, \u4F7F\u7528\u8BF7\u6C42\u7684 User-Agent: ${i}`),z=i);try{k.info(`\u6B63\u5728\u5904\u7406\u5B50\u8BA2\u9605\uFF1A${Y.name}...`);let W;if(Y.source==="local"&&!["localFirst","remoteFirst"].includes(Y.mergeSources))W=Y.content;else{let Ce={};if(W=await await Promise.all(Y.url.split(/[\r\n]+/).map(Fe=>Fe.trim()).filter(Fe=>Fe.length).map(async Fe=>{try{return await Qi(Fe,z,void 0,w||Y.proxy||D.proxy,void 0,void 0,v||Y.noCache,!0)}catch(xe){return Ce[Fe]=xe,k.error(`\u8BA2\u9605 ${Y.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Fe} \u53D1\u751F\u9519\u8BEF: ${xe}`),""}})),Object.keys(Ce).length>0)if(Y.ignoreFailedRemoteSub)Y.ignoreFailedRemoteSub==="enabled"&&k.notify("\u{1F30D} Sub-Store \u5904\u7406\u8BA2\u9605\u5931\u8D25",`\u274C ${Y.name}`,`\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(Ce).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);else throw new Error(`\u8BA2\u9605 ${Y.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(Ce).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);Y.mergeSources==="localFirst"?W.unshift(Y.content):Y.mergeSources==="remoteFirst"&&W.push(Y.content)}let ie=(Array.isArray(W)?W:[W]).map(Ce=>yr.parse(Ce)).flat();ie.forEach(Ce=>{Ce._subName=Y.name,Ce._subDisplayName=Y.displayName,Ce._collectionName=D.name,Ce._collectionDisplayName=D.displayName}),ie=await yr.process(ie,Y.process||[],r,{[Y.name]:Y,_collection:D,$options:h}),U[j]=ie,S++,k.info(`\u2705 \u5B50\u8BA2\u9605\uFF1A${Y.name}\u52A0\u8F7D\u6210\u529F\uFF0C\u8FDB\u5EA6--${100*(S/C.length).toFixed(1)}% `)}catch(W){S++,L[j]=W,k.error(`\u274C \u5904\u7406\u7EC4\u5408\u8BA2\u9605\u4E2D\u7684\u5B50\u8BA2\u9605: ${Y.name}\u65F6\u51FA\u73B0\u9519\u8BEF\uFF1A${W}\uFF01\u8FDB\u5EA6--${100*(S/C.length).toFixed(1)}%`)}}));let B=D.ignoreFailedRemoteSub;if(u!=null&&u!==""&&(B=u),Object.keys(L).length>0)if(B)B==="enabled"&&k.notify("\u{1F30D} Sub-Store \u5904\u7406\u7EC4\u5408\u8BA2\u9605\u5931\u8D25",`\u274C ${D.name}`,`\u5B50\u8BA2\u9605 ${Object.keys(L).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);else throw new Error(`\u7EC4\u5408\u8BA2\u9605 ${D.name} \u7684\u5B50\u8BA2\u9605 ${Object.keys(L).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);let O=Array.prototype.concat.apply([],C.map(j=>U[j]||[]));if(O.forEach(j=>{j._collectionName=D.name,j._collectionDisplayName=D.displayName}),O=await yr.process(O,D.process||[],r,{_collection:D},h),O.length===0)throw new Error(`\u7EC4\u5408\u8BA2\u9605 ${t} \u4E2D\u4E0D\u542B\u6709\u6548\u8282\u70B9`);let x={};for(let j of O){if(x[j.name]){k.notify("\u{1F30D} Sub-Store",`\u26A0\uFE0F \u7EC4\u5408\u8BA2\u9605 ${t} \u5305\u542B\u91CD\u590D\u8282\u70B9 ${j.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}x[j.name]=!0}return yr.produce(O,r,f,d)}else if(e==="rule"){let g=k.read(pf),b=Rt(g,t);if(!b)throw new Error(`\u627E\u4E0D\u5230\u89C4\u5219 ${t}`);let D=[];for(let C=0;CB.trim()).filter(B=>B.length).map(async B=>{try{return await Qi(B,i||b.ua,void 0,b.proxy||w,void 0,void 0,v)}catch(O){return L[B]=O,k.error(`\u6587\u4EF6 ${b.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${B} \u53D1\u751F\u9519\u8BEF: ${O}`),""}}));let S=b.ignoreFailedRemoteFile;if(l!=null&&l!==""&&(S=l),!S&&Object.keys(L).length>0)throw new Error(`\u6587\u4EF6 ${b.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${Object.keys(L).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);s==="localFirst"?D.unshift(a):s==="remoteFirst"&&D.push(a)}else if(b.source==="local"&&!["localFirst","remoteFirst"].includes(b.mergeSources))D=b.content;else{let L={};D=await Promise.all(b.url.split(/[\r\n]+/).map(B=>B.trim()).filter(B=>B.length).map(async B=>{try{return await Qi(B,i||b.ua,void 0,b.proxy||w,void 0,void 0,v)}catch(O){return L[B]=O,k.error(`\u6587\u4EF6 ${b.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${B} \u53D1\u751F\u9519\u8BEF: ${O}`),""}}));let S=b.ignoreFailedRemoteFile;if(l!=null&&l!==""&&(S=l),Object.keys(L).length>0)if(S)S==="enabled"&&k.notify("\u{1F30D} Sub-Store \u5904\u7406\u6587\u4EF6\u5931\u8D25",`\u274C ${b.name}`,`\u8FDC\u7A0B\u6587\u4EF6 ${Object.keys(L).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);else throw new Error(`\u6587\u4EF6 ${b.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${Object.keys(L).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);b.mergeSources==="localFirst"?D.unshift(b.content):b.mergeSources==="remoteFirst"&&D.push(b.content)}if(f==="raw")return JSON.stringify((Array.isArray(D)?D:[D]).flat());let C=(Array.isArray(D)?D:[D]).flat(),F=C.filter(L=>L!=null&&L!=="").join(` `),U=Array.isArray(b.process)&&b.process.length>0?await yr.process({$files:C,$content:F,$options:h,$file:b},b.process):{$content:F,$files:C,$options:h};return(y?U:U?.$content)??""}}function Q2(e){k.read(xt)||k.write([],xt),e.get("/share/file/:name",n5),e.route("/api/file/:name").get(n5).patch(oK).delete(lK),e.route("/api/wholeFile/:name").get(uK),e.route("/api/files").get(cK).post(aK).put(hK),e.route("/api/wholeFiles").get(fK)}function aK(e,t){let r=e.body;r.name=`${r.name??Date.now()}`,k.info(`\u6B63\u5728\u521B\u5EFA\u6587\u4EF6\uFF1A${r.name}`);let n=k.read(xt);if(Rt(n,r.name))return Ve(t,new Tt("DUPLICATE_KEY",e.body.name?`\u5DF2\u5B58\u5728 name \u4E3A ${r.name} \u7684\u6587\u4EF6`:"\u65E0\u6CD5\u540C\u65F6\u521B\u5EFA\u76F8\u540C\u7684\u6587\u4EF6 \u53EF\u7A0D\u540E\u91CD\u8BD5"));n.push(r),k.write(n,xt),qe(t,r,201)}async function n5(e,t){let{name:r}=e.params,n=e.headers["user-agent"]||e.headers["User-Agent"];k.info(`\u6B63\u5728\u4E0B\u8F7D\u6587\u4EF6\uFF1A${r} \u8BF7\u6C42 User-Agent: ${n}`);let{url:i,subInfoUrl:a,subInfoUserAgent:s,ua:u,content:l,mergeSources:f,ignoreFailedRemoteFile:d,proxy:m,noCache:p,produceType:h}=e.query,w={_req:{method:e.method,url:e.url,path:e.path,query:e.query,params:e.params,headers:e.headers,body:e.body}};if(e.query.$options){try{w=JSON.parse(decodeURIComponent(e.query.$options))}catch{for(let b of e.query.$options.split("&")){let D=b.split("=")[0],C=b.split("=")[1];w[D]=C==null||C===""?!0:decodeURIComponent(C)}}k.info(`\u4F20\u5165 $options: ${JSON.stringify(w)}`)}i&&k.info(`\u6307\u5B9A\u8FDC\u7A0B\u6587\u4EF6 URL: ${i}`),m&&k.info(`\u6307\u5B9A\u8FDC\u7A0B\u8BA2\u9605\u4F7F\u7528\u4EE3\u7406/\u7B56\u7565 proxy: ${m}`),u&&k.info(`\u6307\u5B9A\u8FDC\u7A0B\u6587\u4EF6 User-Agent: ${u}`),a&&k.info(`\u6307\u5B9A\u83B7\u53D6\u6D41\u91CF\u7684 subInfoUrl: ${a}`),s&&k.info(`\u6307\u5B9A\u83B7\u53D6\u6D41\u91CF\u7684 subInfoUserAgent: ${s}`),l&&k.info(`\u6307\u5B9A\u672C\u5730\u6587\u4EF6: ${l}`),f&&k.info(`\u6307\u5B9A\u5408\u5E76\u6765\u6E90: ${f}`),d!=null&&d!==""&&k.info(`\u6307\u5B9A\u5FFD\u7565\u5931\u8D25\u7684\u8FDC\u7A0B\u6587\u4EF6: ${d}`),p&&k.info(`\u6307\u5B9A\u4E0D\u4F7F\u7528\u7F13\u5B58: ${p}`),h&&k.info(`\u6307\u5B9A\u751F\u4EA7\u7C7B\u578B: ${h}`);let v=k.read(xt),y=Rt(v,r);if(y)try{let g=await wa({type:"file",name:r,url:i,ua:u,content:l,mergeSources:f,ignoreFailedRemoteFile:d,$options:w,proxy:m,noCache:p,produceType:h,all:!0});try{if(a=a||y.subInfoUrl,a){let b=await na(a,s||y.subInfoUserAgent,void 0,m||y.proxy);b&&t.set("subscription-userinfo",W0(b))}}catch(b){k.error(`\u6587\u4EF6 ${r} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(b)}`)}y.download&&t.set("Content-Disposition",`attachment; filename*=UTF-8''${encodeURIComponent(y.displayName||y.name)}`),t.set("Content-Type","text/plain; charset=utf-8"),g?.$options?._res?.headers&&Object.entries(g.$options._res.headers).forEach(([b,D])=>{t.set(b,D)}),g?.$options?._res?.status&&t.status(g.$options._res.status),t.send(g?.$content??"")}catch(g){k.notify("\u{1F30D} Sub-Store \u4E0B\u8F7D\u6587\u4EF6\u5931\u8D25",`\u274C \u65E0\u6CD5\u4E0B\u8F7D\u6587\u4EF6\uFF1A${r}\uFF01`,`\u{1F914} \u539F\u56E0\uFF1A${g.message??g}`),k.error(g.message??g),Ve(t,new Dn("INTERNAL_SERVER_ERROR",`Failed to download file: ${r}`,`Reason: ${g.message??g}`))}else k.error(`\u{1F30D} Sub-Store \u4E0B\u8F7D\u6587\u4EF6\u5931\u8D25 \u274C \u672A\u627E\u5230\u6587\u4EF6\uFF1A${r}\uFF01`),Ve(t,new Wr("RESOURCE_NOT_FOUND",`File ${r} does not exist!`),404)}function uK(e,t){let{name:r}=e.params,{raw:n}=e.query,i=k.read(xt),a=Rt(i,r);a?n?t.set("content-type","application/json").set("content-disposition",`attachment; filename="${encodeURIComponent(`sub-store_file_${r}_${Hu(new Date)}.json`)}"`).send(JSON.stringify(a)):qe(t,a):Ve(t,new Wr("FILE_NOT_FOUND",`File ${r} does not exist`,404))}function oK(e,t){let{name:r}=e.params,n=e.body,i=k.read(xt),a=Rt(i,r);if(a){let s={...a,...n};if(k.info(`\u6B63\u5728\u66F4\u65B0\u6587\u4EF6\uFF1A${r}...`),r!==s.name){let u=k.read(zt)||[];for(let l of u)l.type==="file"&&l.source===a.name&&(l.source=s.name);k.write(u,zt)}Ss(i,r,s),k.write(i,xt),qe(t,s)}else Ve(t,new Wr("RESOURCE_NOT_FOUND",`File ${r} does not exist!`),404)}function lK(e,t){let{name:r}=e.params;k.info(`\u6B63\u5728\u5220\u9664\u6587\u4EF6\uFF1A${r}`);let n=k.read(xt);Fs(n,r),k.write(n,xt),qe(t)}function cK(e,t){let r=k.read(xt);qe(t,r.map(({content:n,...i})=>i))}function fK(e,t){let r=k.read(xt);qe(t,r)}function hK(e,t){let r=e.body;k.write(r,xt),qe(t)}function ew(e){k.read(ls)||k.write([],ls),e.post("/api/token",gK),e.route("/api/token/:token").delete(dK),e.route("/api/tokens").get(pK)}function dK(e,t){let{token:r}=e.params,{type:n,name:i}=e.query;if(!n||!i)return Ve(t,new Tt("INVALID_PAYLOAD","Payload type and name are required. Please update your front-end(version >= 2.15.76)"));k.info(`\u6B63\u5728\u5220\u9664... token: ${r}, \u7C7B\u578B\uFF1A${n}, \u540D\u79F0\uFF1A${i}`);let a=k.read(ls);a=a.filter(s=>!(s.token===r&&s.type===n&&s.name===i)),k.write(a,ls),qe(t)}function pK(e,t){let{type:r,name:n}=e.query,i=k.read(ls)||[];qe(t,r||n?i.filter(a=>(r?a.type===r:!0)&&(n?a.name===n:!0)):i)}async function gK(req,res){if(!an().isNode)return Ve(res,new Tt("INVALID_ENV","This endpoint is only available in Node.js environment"));try{let{payload,options}=req.body,ms=eval('require("ms")'),type=payload?.type,name=payload?.name;if(!type||!name)return Ve(res,new Tt("INVALID_PAYLOAD","payload type and name are required"));let token=payload?.token;if(token!=null){if(typeof token!="string"||token.length<1)return Ve(res,new Tt("INVALID_CUSTOM_TOKEN",`Invalid custom token: ${token}`));if((k.read(ls)||[]).find(t=>t.token===token&&t.type===type&&t.name===name))return Ve(res,new Tt("DUPLICATE_TOKEN",`Token ${token} already exists`))}if(type==="col"){if(!(k.read(sr)||[]).find(r=>r.name===name))return Ve(res,new Tt("INVALID_COLLECTION",`collection ${name} not found`))}else if(type==="file"){if(!(k.read(xt)||[]).find(r=>r.name===name))return Ve(res,new Tt("INVALID_FILE",`file ${name} not found`))}else if(type==="sub"){if(!(k.read(mr)||[]).find(r=>r.name===name))return Ve(res,new Tt("INVALID_SUB",`sub ${name} not found`))}else return Ve(res,new Tt("INVALID_TYPE",`type ${name} not supported`));let expiresIn=options?.expiresIn;if(options?.expiresIn!=null&&(expiresIn=ms(options.expiresIn),expiresIn==null||isNaN(expiresIn)||expiresIn<=0))return Ve(res,new Tt("INVALID_EXPIRES_IN",`Invalid expiresIn option: ${options.expiresIn}`));let nanoid=eval('require("nanoid")'),tokens=k.read(ls)||[];if(!token)do token=nanoid.customAlphabet(nanoid.urlAlphabet)();while(tokens.find(e=>e.token===token&&e.type===type&&e.name===name));return tokens.push({...payload,token,createdAt:Date.now(),expiresIn:expiresIn>0?options?.expiresIn:void 0,exp:expiresIn>0?Date.now()+expiresIn:void 0}),k.write(tokens,ls),qe(res,{token})}catch(e){return Ve(res,new Dn("TOKEN_SIGN_FAILED","Failed to sign token",`Reason: ${e.message??e}`))}}function tw(e){k.read(On)||k.write([],On),e.route("/api/module/:name").get(vK).patch(wK).delete(AK),e.route("/api/modules").get(EK).post(mK).put(bK)}function mK(e,t){let r=e.body;r.name=`${r.name??Mi(JSON.stringify(r))}`,k.info(`\u6B63\u5728\u521B\u5EFA\u6A21\u5757\uFF1A${r.name}`);let n=k.read(On);if(Rt(n,r.name))return Ve(t,new Tt("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),k.write(n,On),qe(t,r,201)}function vK(e,t){let{name:r}=e.params,n=k.read(On),i=Rt(n,r);i?t.set("Content-Type","text/plain; charset=utf-8").send(i.content):Ve(t,new Wr("MODULE_NOT_FOUND",`Module ${r} does not exist`,404))}function wK(e,t){let{name:r}=e.params,n=e.body,i=k.read(On),a=Rt(i,r);if(a){let s={...a,...n};k.info(`\u6B63\u5728\u66F4\u65B0\u6A21\u5757\uFF1A${r}...`),Ss(i,r,s),k.write(i,On),qe(t,s)}else Ve(t,new Wr("RESOURCE_NOT_FOUND",`Module ${r} does not exist!`),404)}function AK(e,t){let{name:r}=e.params;k.info(`\u6B63\u5728\u5220\u9664\u6A21\u5757\uFF1A${r}`);let n=k.read(On);Fs(n,r),k.write(n,On),qe(t)}function EK(e,t){let r=k.read(On);qe(t,r.map(({content:n,...i})=>i))}function bK(e,t){let r=e.body;k.write(r,On),qe(t)}console.log(` \u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505 Sub-Store -- v${S0} \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 `);Ul();yK();function yK(){let e=ng({substore:k});gg(e),wg(e),ew(e),Q2(e),tw(e),Ag(e),Eg(e),Dg(e),Cg(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 *) */