(()=>{var S3=Object.create;var Ng=Object.defineProperty;var b3=Object.getOwnPropertyDescriptor;var C3=Object.getOwnPropertyNames;var F3=Object.getPrototypeOf,_3=Object.prototype.hasOwnProperty;var Oa=(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 we=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var I3=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of C3(t))!_3.call(e,i)&&i!==r&&Ng(e,i,{get:()=>t[i],enumerable:!(n=b3(t,i))||n.enumerable});return e};var ln=(e,t,r)=>(r=e!=null?S3(F3(e)):{},I3(t||!e||!e.__esModule?Ng(r,"default",{value:e,enumerable:!0}):r,e));var Up=we((DP,Mg)=>{var k3=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};Mg.exports=k3});var Hp=we((BP,qg)=>{var L3="2.0.0",U3=Number.MAX_SAFE_INTEGER||9007199254740991,H3=16,j3=250,M3=["major","premajor","minor","preminor","patch","prepatch","prerelease"];qg.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:H3,MAX_SAFE_BUILD_LENGTH:j3,MAX_SAFE_INTEGER:U3,RELEASE_TYPES:M3,SEMVER_SPEC_VERSION:L3,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var qp=we((hs,Vg)=>{var{MAX_SAFE_COMPONENT_LENGTH:jp,MAX_SAFE_BUILD_LENGTH:q3,MAX_LENGTH:V3}=Hp(),K3=Up();hs=Vg.exports={};var G3=hs.re=[],z3=hs.safeRe=[],Te=hs.src=[],xe=hs.t={},Y3=0,Mp="[a-zA-Z0-9-]",W3=[["\\s",1],["\\d",V3],[Mp,q3]],X3=e=>{for(let[t,r]of W3)e=e.split(`${t}*`).join(`${t}{0,${r}}`).split(`${t}+`).join(`${t}{1,${r}}`);return e},Xe=(e,t,r)=>{let n=X3(t),i=Y3++;K3(e,i,t),xe[e]=i,Te[i]=t,G3[i]=new RegExp(t,r?"g":void 0),z3[i]=new RegExp(n,r?"g":void 0)};Xe("NUMERICIDENTIFIER","0|[1-9]\\d*");Xe("NUMERICIDENTIFIERLOOSE","\\d+");Xe("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${Mp}*`);Xe("MAINVERSION",`(${Te[xe.NUMERICIDENTIFIER]})\\.(${Te[xe.NUMERICIDENTIFIER]})\\.(${Te[xe.NUMERICIDENTIFIER]})`);Xe("MAINVERSIONLOOSE",`(${Te[xe.NUMERICIDENTIFIERLOOSE]})\\.(${Te[xe.NUMERICIDENTIFIERLOOSE]})\\.(${Te[xe.NUMERICIDENTIFIERLOOSE]})`);Xe("PRERELEASEIDENTIFIER",`(?:${Te[xe.NUMERICIDENTIFIER]}|${Te[xe.NONNUMERICIDENTIFIER]})`);Xe("PRERELEASEIDENTIFIERLOOSE",`(?:${Te[xe.NUMERICIDENTIFIERLOOSE]}|${Te[xe.NONNUMERICIDENTIFIER]})`);Xe("PRERELEASE",`(?:-(${Te[xe.PRERELEASEIDENTIFIER]}(?:\\.${Te[xe.PRERELEASEIDENTIFIER]})*))`);Xe("PRERELEASELOOSE",`(?:-?(${Te[xe.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${Te[xe.PRERELEASEIDENTIFIERLOOSE]})*))`);Xe("BUILDIDENTIFIER",`${Mp}+`);Xe("BUILD",`(?:\\+(${Te[xe.BUILDIDENTIFIER]}(?:\\.${Te[xe.BUILDIDENTIFIER]})*))`);Xe("FULLPLAIN",`v?${Te[xe.MAINVERSION]}${Te[xe.PRERELEASE]}?${Te[xe.BUILD]}?`);Xe("FULL",`^${Te[xe.FULLPLAIN]}$`);Xe("LOOSEPLAIN",`[v=\\s]*${Te[xe.MAINVERSIONLOOSE]}${Te[xe.PRERELEASELOOSE]}?${Te[xe.BUILD]}?`);Xe("LOOSE",`^${Te[xe.LOOSEPLAIN]}$`);Xe("GTLT","((?:<|>)?=?)");Xe("XRANGEIDENTIFIERLOOSE",`${Te[xe.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);Xe("XRANGEIDENTIFIER",`${Te[xe.NUMERICIDENTIFIER]}|x|X|\\*`);Xe("XRANGEPLAIN",`[v=\\s]*(${Te[xe.XRANGEIDENTIFIER]})(?:\\.(${Te[xe.XRANGEIDENTIFIER]})(?:\\.(${Te[xe.XRANGEIDENTIFIER]})(?:${Te[xe.PRERELEASE]})?${Te[xe.BUILD]}?)?)?`);Xe("XRANGEPLAINLOOSE",`[v=\\s]*(${Te[xe.XRANGEIDENTIFIERLOOSE]})(?:\\.(${Te[xe.XRANGEIDENTIFIERLOOSE]})(?:\\.(${Te[xe.XRANGEIDENTIFIERLOOSE]})(?:${Te[xe.PRERELEASELOOSE]})?${Te[xe.BUILD]}?)?)?`);Xe("XRANGE",`^${Te[xe.GTLT]}\\s*${Te[xe.XRANGEPLAIN]}$`);Xe("XRANGELOOSE",`^${Te[xe.GTLT]}\\s*${Te[xe.XRANGEPLAINLOOSE]}$`);Xe("COERCEPLAIN",`(^|[^\\d])(\\d{1,${jp}})(?:\\.(\\d{1,${jp}}))?(?:\\.(\\d{1,${jp}}))?`);Xe("COERCE",`${Te[xe.COERCEPLAIN]}(?:$|[^\\d])`);Xe("COERCEFULL",Te[xe.COERCEPLAIN]+`(?:${Te[xe.PRERELEASE]})?(?:${Te[xe.BUILD]})?(?:$|[^\\d])`);Xe("COERCERTL",Te[xe.COERCE],!0);Xe("COERCERTLFULL",Te[xe.COERCEFULL],!0);Xe("LONETILDE","(?:~>?)");Xe("TILDETRIM",`(\\s*)${Te[xe.LONETILDE]}\\s+`,!0);hs.tildeTrimReplace="$1~";Xe("TILDE",`^${Te[xe.LONETILDE]}${Te[xe.XRANGEPLAIN]}$`);Xe("TILDELOOSE",`^${Te[xe.LONETILDE]}${Te[xe.XRANGEPLAINLOOSE]}$`);Xe("LONECARET","(?:\\^)");Xe("CARETTRIM",`(\\s*)${Te[xe.LONECARET]}\\s+`,!0);hs.caretTrimReplace="$1^";Xe("CARET",`^${Te[xe.LONECARET]}${Te[xe.XRANGEPLAIN]}$`);Xe("CARETLOOSE",`^${Te[xe.LONECARET]}${Te[xe.XRANGEPLAINLOOSE]}$`);Xe("COMPARATORLOOSE",`^${Te[xe.GTLT]}\\s*(${Te[xe.LOOSEPLAIN]})$|^$`);Xe("COMPARATOR",`^${Te[xe.GTLT]}\\s*(${Te[xe.FULLPLAIN]})$|^$`);Xe("COMPARATORTRIM",`(\\s*)${Te[xe.GTLT]}\\s*(${Te[xe.LOOSEPLAIN]}|${Te[xe.XRANGEPLAIN]})`,!0);hs.comparatorTrimReplace="$1$2$3";Xe("HYPHENRANGE",`^\\s*(${Te[xe.XRANGEPLAIN]})\\s+-\\s+(${Te[xe.XRANGEPLAIN]})\\s*$`);Xe("HYPHENRANGELOOSE",`^\\s*(${Te[xe.XRANGEPLAINLOOSE]})\\s+-\\s+(${Te[xe.XRANGEPLAINLOOSE]})\\s*$`);Xe("STAR","(<|>)?=?\\s*\\*");Xe("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");Xe("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var Gg=we(($P,Kg)=>{var J3=Object.freeze({loose:!0}),Z3=Object.freeze({}),Q3=e=>e?typeof e!="object"?J3:e:Z3;Kg.exports=Q3});var Xg=we((PP,Wg)=>{var zg=/^[0-9]+$/,Yg=(e,t)=>{let r=zg.test(e),n=zg.test(t);return r&&n&&(e=+e,t=+t),e===t?0:r&&!n?-1:n&&!r?1:eYg(t,e);Wg.exports={compareIdentifiers:Yg,rcompareIdentifiers:eb}});var Zl=we((RP,em)=>{var Xl=Up(),{MAX_LENGTH:Jg,MAX_SAFE_INTEGER:Jl}=Hp(),{safeRe:Zg,t:Qg}=qp(),tb=Gg(),{compareIdentifiers:Vu}=Xg(),Vp=class e{constructor(t,r){if(r=tb(r),t instanceof e){if(t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease)return t;t=t.version}else if(typeof t!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>Jg)throw new TypeError(`version is longer than ${Jg} characters`);Xl("SemVer",t,r),this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease;let n=t.trim().match(r.loose?Zg[Qg.LOOSE]:Zg[Qg.FULL]);if(!n)throw new TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>Jl||this.major<0)throw new TypeError("Invalid major version");if(this.minor>Jl||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>Jl||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map(i=>{if(/^[0-9]+$/.test(i)){let a=+i;if(a>=0&&a=0;)typeof this.prerelease[a]=="number"&&(this.prerelease[a]++,a=-2);if(a===-1){if(r===this.prerelease.join(".")&&n===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(i)}}if(r){let a=[r,i];n===!1&&(a=[r]),Vu(this.prerelease[0],r)===0?isNaN(this.prerelease[1])&&(this.prerelease=a):this.prerelease=a}break}default:throw new Error(`invalid increment argument: ${t}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};em.exports=Vp});var nm=we((TP,rm)=>{var tm=Zl(),rb=(e,t,r)=>new tm(e,r).compare(new tm(t,r));rm.exports=rb});var sm=we((xP,im)=>{var nb=nm(),ib=(e,t,r)=>nb(e,t,r)>=0;im.exports=ib});var om=we((OP,um)=>{var am=Zl(),sb=(e,t,r=!1)=>{if(e instanceof am)return e;try{return new am(e,t)}catch(n){if(!r)return null;throw n}};um.exports=sb});var lm=we((NP,cm)=>{var ab=Zl(),ub=om(),{safeRe:Ql,t:ef}=qp(),ob=(e,t)=>{if(e instanceof ab)return e;if(typeof e=="number"&&(e=String(e)),typeof e!="string")return null;t=t||{};let r=null;if(!t.rtl)r=e.match(t.includePrerelease?Ql[ef.COERCEFULL]:Ql[ef.COERCE]);else{let l=t.includePrerelease?Ql[ef.COERCERTLFULL]:Ql[ef.COERCERTL],h;for(;(h=l.exec(e))&&(!r||r.index+r[0].length!==e.length);)(!r||h.index+h[0].length!==r.index+r[0].length)&&(r=h),l.lastIndex=h.index+h[1].length+h[2].length;l.lastIndex=-1}if(r===null)return null;let n=r[2],i=r[3]||"0",a=r[4]||"0",s=t.includePrerelease&&r[5]?`-${r[5]}`:"",o=t.includePrerelease&&r[6]?`+${r[6]}`:"";return ub(`${n}.${i}.${a}${s}${o}`,t)};cm.exports=ob});var gm=we(rf=>{"use strict";rf.byteLength=fb;rf.toByteArray=pb;rf.fromByteArray=mb;var Fi=[],Xn=[],lb=typeof Uint8Array<"u"?Uint8Array:Array,zp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Ha=0,pm=zp.length;Ha0)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 fb(e){var t=dm(e),r=t[0],n=t[1];return(r+n)*3/4-n}function hb(e,t,r){return(t+r)*3/4-r}function pb(e){var t,r=dm(e),n=r[0],i=r[1],a=new lb(hb(e,n,i)),s=0,o=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=Xn[e.charCodeAt(l)]<<2|Xn[e.charCodeAt(l+1)]>>4,a[s++]=t&255),i===1&&(t=Xn[e.charCodeAt(l)]<<10|Xn[e.charCodeAt(l+1)]<<4|Xn[e.charCodeAt(l+2)]>>2,a[s++]=t>>8&255,a[s++]=t&255),a}function db(e){return Fi[e>>18&63]+Fi[e>>12&63]+Fi[e>>6&63]+Fi[e&63]}function gb(e,t,r){for(var n,i=[],a=t;ao?o:s+a));return n===1?(t=e[r-1],i.push(Fi[t>>2]+Fi[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Fi[t>>10]+Fi[t>>4&63]+Fi[t<<2&63]+"=")),i.join("")}});var mm=we(Yp=>{Yp.read=function(e,t,r,n,i){var a,s,o=i*8-n-1,l=(1<>1,d=-7,E=r?i-1:0,p=r?-1:1,f=e[t+E];for(E+=p,a=f&(1<<-d)-1,f>>=-d,d+=o;d>0;a=a*256+e[t+E],E+=p,d-=8);for(s=a&(1<<-d)-1,a>>=-d,d+=n;d>0;s=s*256+e[t+E],E+=p,d-=8);if(a===0)a=1-h;else{if(a===l)return s?NaN:(f?-1:1)*(1/0);s=s+Math.pow(2,n),a=a-h}return(f?-1:1)*s*Math.pow(2,a-n)};Yp.write=function(e,t,r,n,i,a){var s,o,l,h=a*8-i-1,d=(1<>1,p=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:a-1,w=n?1:-1,g=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=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+E>=1?t+=p/l:t+=p*Math.pow(2,1-E),t*l>=2&&(s++,l/=2),s+E>=d?(o=0,s=d):s+E>=1?(o=(t*l-1)*Math.pow(2,i),s=s+E):(o=t*Math.pow(2,E-1)*Math.pow(2,i),s=0));i>=8;e[r+f]=o&255,f+=w,o/=256,i-=8);for(s=s<0;e[r+f]=s&255,f+=w,s/=256,h-=8);e[r+f-w]|=g*128}});var af=we(Yu=>{"use strict";var Wp=gm(),Gu=mm(),vm=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Yu.Buffer=fe;Yu.SlowBuffer=Sb;Yu.INSPECT_MAX_BYTES=50;var nf=2147483647;Yu.kMaxLength=nf;fe.TYPED_ARRAY_SUPPORT=vb();!fe.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function vb(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(fe.prototype,"parent",{enumerable:!0,get:function(){if(fe.isBuffer(this))return this.buffer}});Object.defineProperty(fe.prototype,"offset",{enumerable:!0,get:function(){if(fe.isBuffer(this))return this.byteOffset}});function ps(e){if(e>nf)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,fe.prototype),t}function fe(e,t,r){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Qp(e)}return ym(e,t,r)}fe.poolSize=8192;function ym(e,t,r){if(typeof e=="string")return Ab(e,t);if(ArrayBuffer.isView(e))return wb(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(_i(e,ArrayBuffer)||e&&_i(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(_i(e,SharedArrayBuffer)||e&&_i(e.buffer,SharedArrayBuffer)))return Jp(e,t,r);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=e.valueOf&&e.valueOf();if(n!=null&&n!==e)return fe.from(n,t,r);let i=yb(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return fe.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}fe.from=function(e,t,r){return ym(e,t,r)};Object.setPrototypeOf(fe.prototype,Uint8Array.prototype);Object.setPrototypeOf(fe,Uint8Array);function Sm(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 Eb(e,t,r){return Sm(e),e<=0?ps(e):t!==void 0?typeof r=="string"?ps(e).fill(t,r):ps(e).fill(t):ps(e)}fe.alloc=function(e,t,r){return Eb(e,t,r)};function Qp(e){return Sm(e),ps(e<0?0:ed(e)|0)}fe.allocUnsafe=function(e){return Qp(e)};fe.allocUnsafeSlow=function(e){return Qp(e)};function Ab(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!fe.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=bm(e,t)|0,n=ps(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function Xp(e){let t=e.length<0?0:ed(e.length)|0,r=ps(t);for(let n=0;n=nf)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+nf.toString(16)+" bytes");return e|0}function Sb(e){return+e!=e&&(e=0),fe.alloc(+e)}fe.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==fe.prototype};fe.compare=function(t,r){if(_i(t,Uint8Array)&&(t=fe.from(t,t.offset,t.byteLength)),_i(r,Uint8Array)&&(r=fe.from(r,r.offset,r.byteLength)),!fe.isBuffer(t)||!fe.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;let n=t.length,i=r.length;for(let a=0,s=Math.min(n,i);ai.length?(fe.isBuffer(s)||(s=fe.from(s)),s.copy(i,a)):Uint8Array.prototype.set.call(i,s,a);else if(fe.isBuffer(s))s.copy(i,a);else throw new TypeError('"list" argument must be an Array of Buffers');a+=s.length}return i};function bm(e,t){if(fe.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||_i(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 Zp(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Rm(e).length;default:if(i)return n?-1:Zp(e).length;t=(""+t).toLowerCase(),i=!0}}fe.byteLength=bm;function bb(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 Tb(this,t,r);case"utf8":case"utf-8":return Fm(this,t,r);case"ascii":return Pb(this,t,r);case"latin1":case"binary":return Rb(this,t,r);case"base64":return Bb(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xb(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}fe.prototype._isBuffer=!0;function ja(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}fe.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;rr&&(t+=" ... "),""};vm&&(fe.prototype[vm]=fe.prototype.inspect);fe.prototype.compare=function(t,r,n,i,a){if(_i(t,Uint8Array)&&(t=fe.from(t,t.offset,t.byteLength)),!fe.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),a===void 0&&(a=this.length),r<0||n>t.length||i<0||a>this.length)throw new RangeError("out of range index");if(i>=a&&r>=n)return 0;if(i>=a)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,a>>>=0,this===t)return 0;let s=a-i,o=n-r,l=Math.min(s,o),h=this.slice(i,a),d=t.slice(r,n);for(let E=0;E2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,rd(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof t=="string"&&(t=fe.from(t,n)),fe.isBuffer(t))return t.length===0?-1:Em(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):Em(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Em(e,t,r,n,i){let a=1,s=e.length,o=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,o/=2,r/=2}function l(d,E){return a===1?d[E]:d.readUInt16BE(E*a)}let h;if(i){let d=-1;for(h=r;hs&&(r=s-o),h=r;h>=0;h--){let d=!0;for(let E=0;Ei&&(n=i)):n=i;let a=t.length;n>a/2&&(n=a/2);let s;for(s=0;s>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let a=this.length-r;if((n===void 0||n>a)&&(n=a),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return Cb(this,t,r,n);case"utf8":case"utf-8":return Fb(this,t,r,n);case"ascii":case"latin1":case"binary":return _b(this,t,r,n);case"base64":return Ib(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Db(this,t,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};fe.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Bb(e,t,r){return t===0&&r===e.length?Wp.fromByteArray(e):Wp.fromByteArray(e.slice(t,r))}function Fm(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+o<=r){let l,h,d,E;switch(o){case 1:a<128&&(s=a);break;case 2:l=e[i+1],(l&192)===128&&(E=(a&31)<<6|l&63,E>127&&(s=E));break;case 3:l=e[i+1],h=e[i+2],(l&192)===128&&(h&192)===128&&(E=(a&15)<<12|(l&63)<<6|h&63,E>2047&&(E<55296||E>57343)&&(s=E));break;case 4:l=e[i+1],h=e[i+2],d=e[i+3],(l&192)===128&&(h&192)===128&&(d&192)===128&&(E=(a&15)<<18|(l&63)<<12|(h&63)<<6|d&63,E>65535&&E<1114112&&(s=E))}}s===null?(s=65533,o=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=o}return $b(n)}var Am=4096;function $b(e){let t=e.length;if(t<=Am)return String.fromCharCode.apply(String,e);let r="",n=0;for(;nn)&&(r=n);let i="";for(let a=t;an&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),rr)throw new RangeError("Trying to access beyond buffer length")}fe.prototype.readUintLE=fe.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||gr(t,r,this.length);let i=this[t],a=1,s=0;for(;++s>>0,r=r>>>0,n||gr(t,r,this.length);let i=this[t+--r],a=1;for(;r>0&&(a*=256);)i+=this[t+--r]*a;return i};fe.prototype.readUint8=fe.prototype.readUInt8=function(t,r){return t=t>>>0,r||gr(t,1,this.length),this[t]};fe.prototype.readUint16LE=fe.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||gr(t,2,this.length),this[t]|this[t+1]<<8};fe.prototype.readUint16BE=fe.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||gr(t,2,this.length),this[t]<<8|this[t+1]};fe.prototype.readUint32LE=fe.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||gr(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};fe.prototype.readUint32BE=fe.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||gr(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};fe.prototype.readBigUInt64LE=Js(function(t){t=t>>>0,zu(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Ac(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,zu(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Ac(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||gr(t,r,this.length);let i=this[t],a=1,s=0;for(;++s=a&&(i-=Math.pow(2,8*r)),i};fe.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||gr(t,r,this.length);let i=r,a=1,s=this[t+--i];for(;i>0&&(a*=256);)s+=this[t+--i]*a;return a*=128,s>=a&&(s-=Math.pow(2,8*r)),s};fe.prototype.readInt8=function(t,r){return t=t>>>0,r||gr(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};fe.prototype.readInt16LE=function(t,r){t=t>>>0,r||gr(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};fe.prototype.readInt16BE=function(t,r){t=t>>>0,r||gr(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};fe.prototype.readInt32LE=function(t,r){return t=t>>>0,r||gr(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};fe.prototype.readInt32BE=function(t,r){return t=t>>>0,r||gr(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};fe.prototype.readBigInt64LE=Js(function(t){t=t>>>0,zu(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Ac(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,zu(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Ac(t,this.length-8);let i=(r<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<>>0,r||gr(t,4,this.length),Gu.read(this,t,!0,23,4)};fe.prototype.readFloatBE=function(t,r){return t=t>>>0,r||gr(t,4,this.length),Gu.read(this,t,!1,23,4)};fe.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||gr(t,8,this.length),Gu.read(this,t,!0,52,8)};fe.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||gr(t,8,this.length),Gu.read(this,t,!1,52,8)};function fn(e,t,r,n,i,a){if(!fe.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}fe.prototype.writeUintLE=fe.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let o=Math.pow(2,8*n)-1;fn(this,t,r,n,o,0)}let a=1,s=0;for(this[r]=t&255;++s>>0,n=n>>>0,!i){let o=Math.pow(2,8*n)-1;fn(this,t,r,n,o,0)}let a=n-1,s=1;for(this[r+a]=t&255;--a>=0&&(s*=256);)this[r+a]=t/s&255;return r+n};fe.prototype.writeUint8=fe.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||fn(this,t,r,1,255,0),this[r]=t&255,r+1};fe.prototype.writeUint16LE=fe.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||fn(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};fe.prototype.writeUint16BE=fe.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||fn(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};fe.prototype.writeUint32LE=fe.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||fn(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255,r+4};fe.prototype.writeUint32BE=fe.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||fn(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 _m(e,t,r,n,i){Pm(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 Im(e,t,r,n,i){Pm(t,n,i,e,r,7);let a=Number(t&BigInt(4294967295));e[r+7]=a,a=a>>8,e[r+6]=a,a=a>>8,e[r+5]=a,a=a>>8,e[r+4]=a;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=s,s=s>>8,e[r+2]=s,s=s>>8,e[r+1]=s,s=s>>8,e[r]=s,r+8}fe.prototype.writeBigUInt64LE=Js(function(t,r=0){return _m(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});fe.prototype.writeBigUInt64BE=Js(function(t,r=0){return Im(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});fe.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let l=Math.pow(2,8*n-1);fn(this,t,r,n,l-1,-l)}let a=0,s=1,o=0;for(this[r]=t&255;++a>0)-o&255;return r+n};fe.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let l=Math.pow(2,8*n-1);fn(this,t,r,n,l-1,-l)}let a=n-1,s=1,o=0;for(this[r+a]=t&255;--a>=0&&(s*=256);)t<0&&o===0&&this[r+a+1]!==0&&(o=1),this[r+a]=(t/s>>0)-o&255;return r+n};fe.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||fn(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};fe.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||fn(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};fe.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||fn(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};fe.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||fn(this,t,r,4,2147483647,-2147483648),this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4};fe.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||fn(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};fe.prototype.writeBigInt64LE=Js(function(t,r=0){return _m(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});fe.prototype.writeBigInt64BE=Js(function(t,r=0){return Im(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Dm(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 Bm(e,t,r,n,i){return t=+t,r=r>>>0,i||Dm(e,t,r,4,34028234663852886e22,-34028234663852886e22),Gu.write(e,t,r,n,23,4),r+4}fe.prototype.writeFloatLE=function(t,r,n){return Bm(this,t,r,!0,n)};fe.prototype.writeFloatBE=function(t,r,n){return Bm(this,t,r,!1,n)};function $m(e,t,r,n,i){return t=+t,r=r>>>0,i||Dm(e,t,r,8,17976931348623157e292,-17976931348623157e292),Gu.write(e,t,r,n,52,8),r+8}fe.prototype.writeDoubleLE=function(t,r,n){return $m(this,t,r,!0,n)};fe.prototype.writeDoubleBE=function(t,r,n){return $m(this,t,r,!1,n)};fe.prototype.copy=function(t,r,n,i){if(!fe.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-r>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let a;if(typeof t=="number")for(a=r;a2**32?i=wm(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=wm(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function wm(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 Ob(e,t,r){zu(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&Ac(t,e.length-(r+1))}function Pm(e,t,r,n,i,a){if(e>r||e3?t===0||t===BigInt(0)?o=`>= 0${s} and < 2${s} ** ${(a+1)*8}${s}`:o=`>= -(2${s} ** ${(a+1)*8-1}${s}) and < 2 ** ${(a+1)*8-1}${s}`:o=`>= ${t}${s} and <= ${r}${s}`,new Ku.ERR_OUT_OF_RANGE("value",o,e)}Ob(n,i,a)}function zu(e,t){if(typeof e!="number")throw new Ku.ERR_INVALID_ARG_TYPE(t,"number",e)}function Ac(e,t,r){throw Math.floor(e)!==e?(zu(e,r),new Ku.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new Ku.ERR_BUFFER_OUT_OF_BOUNDS:new Ku.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var Nb=/[^+/0-9A-Za-z-_]/g;function kb(e){if(e=e.split("=")[0],e=e.trim().replace(Nb,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function Zp(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 Lb(e){let t=[];for(let r=0;r>8,i=r%256,a.push(i),a.push(n);return a}function Rm(e){return Wp.toByteArray(kb(e))}function sf(e,t,r,n){let i;for(i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function _i(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function rd(e){return e!==e}var Hb=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 Js(e){return typeof BigInt>"u"?jb:e}function jb(){throw new Error("BigInt not supported")}});var rv=we(Se=>{var wc={};wc.userAgent=!1;var Wu={},Mb="11.1.0",qb="jsrsasign(all) 11.1.0 (2024-02-01) (c) 2010-2023 Kenji Urushima | kjur.github.io/jsrsasign/license";var Ce=Ce||function(e,t){var r={},n=r.lib={},i=n.Base=function(){function f(){}return{extend:function(w){f.prototype=this;var g=new f;return w&&g.mixIn(w),g.hasOwnProperty("init")||(g.init=function(){g.$super.init.apply(this,arguments)}),g.init.prototype=g,g.$super=this,g},create:function(){var w=this.extend();return w.init.apply(w,arguments),w},init:function(){},mixIn:function(w){for(var g in w)w.hasOwnProperty(g)&&(this[g]=w[g]);w.hasOwnProperty("toString")&&(this.toString=w.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),a=n.WordArray=i.extend({init:function(f,w){f=this.words=f||[],w!=t?this.sigBytes=w:this.sigBytes=f.length*4},toString:function(f){return(f||o).stringify(this)},concat:function(f){var w=this.words,g=f.words,y=this.sigBytes,A=f.sigBytes;if(this.clamp(),y%4)for(var S=0;S>>2]>>>24-S%4*8&255;w[y+S>>>2]|=_<<24-(y+S)%4*8}else for(var S=0;S>>2]=g[S>>>2];return this.sigBytes+=A,this},clamp:function(){var f=this.words,w=this.sigBytes;f[w>>>2]&=4294967295<<32-w%4*8,f.length=e.ceil(w/4)},clone:function(){var f=i.clone.call(this);return f.words=this.words.slice(0),f},random:function(f){for(var w=[],g=0;g>>2]>>>24-A%4*8&255;y.push((S>>>4).toString(16)),y.push((S&15).toString(16))}return y.join("")},parse:function(f){for(var w=f.length,g=[],y=0;y>>3]|=parseInt(f.substr(y,2),16)<<24-y%8*4;return new a.init(g,w/2)}},l=s.Latin1={stringify:function(f){for(var w=f.words,g=f.sigBytes,y=[],A=0;A>>2]>>>24-A%4*8&255;y.push(String.fromCharCode(S))}return y.join("")},parse:function(f){for(var w=f.length,g=[],y=0;y>>2]|=(f.charCodeAt(y)&255)<<24-y%4*8;return new a.init(g,w)}},h=s.Utf8={stringify:function(f){try{return decodeURIComponent(escape(l.stringify(f)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(f){return l.parse(unescape(encodeURIComponent(f)))}},d=n.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(f){typeof f=="string"&&(f=h.parse(f)),this._data.concat(f),this._nDataBytes+=f.sigBytes},_process:function(f){var w=this._data,g=w.words,y=w.sigBytes,A=this.blockSize,S=A*4,_=y/S;f?_=e.ceil(_):_=e.max((_|0)-this._minBufferSize,0);var I=_*A,D=e.min(I*4,y);if(I){for(var H=0;H>>2]&255}},t.BlockCipher=o.extend({cfg:o.cfg.extend({mode:E,padding:h}),reset:function(){o.reset.call(this);var y=this.cfg,g=y.iv,y=y.mode;if(this._xformMode==this._ENC_XFORM_MODE)var A=y.createEncryptor;else A=y.createDecryptor,this._minBufferSize=1;this._mode=A.call(y,this,g&&g.words)},_doProcessBlock:function(g,y){this._mode.processBlock(g,y)},_doFinalize:function(){var g=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){g.pad(this._data,this.blockSize);var y=this._process(!0)}else y=this._process(!0),g.unpad(y);return y},blockSize:4});var d=t.CipherParams=r.extend({init:function(g){this.mixIn(g)},toString:function(g){return(g||this.formatter).stringify(this)}}),E=(f.format={}).OpenSSL={stringify:function(g){var y=g.ciphertext;return g=g.salt,(g?n.create([1398893684,1701076831]).concat(g).concat(y):y).toString(a)},parse:function(g){g=a.parse(g);var y=g.words;if(y[0]==1398893684&&y[1]==1701076831){var A=n.create(y.slice(2,4));y.splice(0,4),g.sigBytes-=16}return d.create({ciphertext:g,salt:A})}},p=t.SerializableCipher=r.extend({cfg:r.extend({format:E}),encrypt:function(g,y,A,S){S=this.cfg.extend(S);var _=g.createEncryptor(A,S);return y=_.finalize(y),_=_.cfg,d.create({ciphertext:y,key:A,iv:_.iv,algorithm:g,mode:_.mode,padding:_.padding,blockSize:g.blockSize,formatter:S.format})},decrypt:function(g,y,A,S){return S=this.cfg.extend(S),y=this._parse(y,S.format),g.createDecryptor(A,S).finalize(y.ciphertext)},_parse:function(g,y){return typeof g=="string"?y.parse(g,this):g}}),f=(f.kdf={}).OpenSSL={execute:function(g,y,A,S){return S||(S=n.random(8)),g=s.create({keySize:y+A}).compute(g,S),A=n.create(g.words.slice(y),4*A),g.sigBytes=4*y,d.create({key:g,iv:A,salt:S})}},w=t.PasswordBasedCipher=p.extend({cfg:p.cfg.extend({kdf:f}),encrypt:function(g,y,A,S){return S=this.cfg.extend(S),A=S.kdf.execute(A,g.keySize,g.ivSize),S.iv=A.iv,g=p.encrypt.call(this,g,y,A.key,S),g.mixIn(A),g},decrypt:function(g,y,A,S){return S=this.cfg.extend(S),y=this._parse(y,S.format),A=S.kdf.execute(A,g.keySize,g.ivSize,y.salt),S.iv=A.iv,p.decrypt.call(this,g,y,A.key,S)}})}();(function(){for(var e=Ce,t=e.lib.BlockCipher,H=e.algo,r=[],n=[],i=[],a=[],s=[],o=[],l=[],h=[],d=[],E=[],p=[],f=0;256>f;f++)p[f]=128>f?f<<1:f<<1^283;for(var w=0,g=0,f=0;256>f;f++){var y=g^g<<1^g<<2^g<<3^g<<4,y=y>>>8^y&255^99;r[w]=y,n[y]=w;var A=p[w],S=p[A],_=p[S],I=257*p[y]^16843008*y;i[w]=I<<24|I>>>8,a[w]=I<<16|I>>>16,s[w]=I<<8|I>>>24,o[w]=I,I=16843009*_^65537*S^257*A^16843008*w,l[y]=I<<24|I>>>8,h[y]=I<<16|I>>>16,d[y]=I<<8|I>>>24,E[y]=I,w?(w=A^p[p[p[_^A]]],g^=p[p[g]]):w=g=1}var D=[0,1,2,4,8,16,32,64,128,27,54],H=H.AES=t.extend({_doReset:function(){for(var P=this._key,V=P.words,F=P.sigBytes/4,P=4*((this._nRounds=F+6)+1),k=this._keySchedule=[],L=0;L>>24]<<24|r[q>>>16&255]<<16|r[q>>>8&255]<<8|r[q&255]):(q=q<<8|q>>>24,q=r[q>>>24]<<24|r[q>>>16&255]<<16|r[q>>>8&255]<<8|r[q&255],q^=D[L/F|0]<<24),k[L]=k[L-F]^q}for(V=this._invKeySchedule=[],F=0;FF||4>=L?q:l[r[q>>>24]]^h[r[q>>>16&255]]^d[r[q>>>8&255]]^E[r[q&255]]},encryptBlock:function(V,F){this._doCryptBlock(V,F,this._keySchedule,i,a,s,o,r)},decryptBlock:function(V,F){var P=V[F+1];V[F+1]=V[F+3],V[F+3]=P,this._doCryptBlock(V,F,this._invKeySchedule,l,h,d,E,n),P=V[F+1],V[F+1]=V[F+3],V[F+3]=P},_doCryptBlock:function(V,F,P,k,L,q,J,z){for(var K=this._nRounds,ce=V[F]^P[0],_e=V[F+1]^P[1],Le=V[F+2]^P[2],qe=V[F+3]^P[3],X=4,ie=1;ie>>24]^L[_e>>>16&255]^q[Le>>>8&255]^J[qe&255]^P[X++],ye=k[_e>>>24]^L[Le>>>16&255]^q[qe>>>8&255]^J[ce&255]^P[X++],$e=k[Le>>>24]^L[qe>>>16&255]^q[ce>>>8&255]^J[_e&255]^P[X++],qe=k[qe>>>24]^L[ce>>>16&255]^q[_e>>>8&255]^J[Le&255]^P[X++],ce=be,_e=ye,Le=$e;be=(z[ce>>>24]<<24|z[_e>>>16&255]<<16|z[Le>>>8&255]<<8|z[qe&255])^P[X++],ye=(z[_e>>>24]<<24|z[Le>>>16&255]<<16|z[qe>>>8&255]<<8|z[ce&255])^P[X++],$e=(z[Le>>>24]<<24|z[qe>>>16&255]<<16|z[ce>>>8&255]<<8|z[_e&255])^P[X++],qe=(z[qe>>>24]<<24|z[ce>>>16&255]<<16|z[_e>>>8&255]<<8|z[Le&255])^P[X++],V[F]=be,V[F+1]=ye,V[F+2]=$e,V[F+3]=qe},keySize:8});e.AES=t._createHelper(H)})();(function(){function e(p,f){var w=(this._lBlock>>>p^this._rBlock)&f;this._rBlock^=w,this._lBlock^=w<>>p^this._lBlock)&f;this._lBlock^=w,this._rBlock^=w<w;w++){var g=s[w]-1;f[w]=p[g>>>5]>>>31-g%32&1}for(p=this._subKeys=[],g=0;16>g;g++){for(var y=p[g]=[],A=l[g],w=0;24>w;w++)y[w/6|0]|=f[(o[w]-1+A)%28]<<31-w%6,y[4+(w/6|0)]|=f[28+(o[w+24]-1+A)%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(f=this._invSubKeys=[],w=0;16>w;w++)f[w]=p[15-w]},encryptBlock:function(p,f){this._doCryptBlock(p,f,this._subKeys)},decryptBlock:function(p,f){this._doCryptBlock(p,f,this._invSubKeys)},_doCryptBlock:function(p,f,w){this._lBlock=p[f],this._rBlock=p[f+1],e.call(this,4,252645135),e.call(this,16,65535),t.call(this,2,858993459),t.call(this,8,16711935),e.call(this,1,1431655765);for(var g=0;16>g;g++){for(var y=w[g],A=this._lBlock,S=this._rBlock,_=0,I=0;8>I;I++)_|=h[I][((S^y[I])&d[I])>>>0];this._lBlock=S,this._rBlock=A^_}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[f]=this._lBlock,p[f+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});r.DES=i._createHelper(E),a=a.TripleDES=i.extend({_doReset:function(){var p=this._key.words;this._des1=E.createEncryptor(n.create(p.slice(0,2))),this._des2=E.createEncryptor(n.create(p.slice(2,4))),this._des3=E.createEncryptor(n.create(p.slice(4,6)))},encryptBlock:function(p,f){this._des1.encryptBlock(p,f),this._des2.decryptBlock(p,f),this._des3.encryptBlock(p,f)},decryptBlock:function(p,f){this._des3.decryptBlock(p,f),this._des2.encryptBlock(p,f),this._des1.decryptBlock(p,f)},keySize:6,ivSize:2,blockSize:2}),r.TripleDES=i._createHelper(a)})();(function(){var e=Ce,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,o=0;o>>6-2*(o%4);a[s>>>2]|=(l|h)<<24-8*(s%4),s++}return t.create(a,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}})();(function(e){function t(E,p,f,w,g,y,A){return E=E+(p&f|~p&w)+g+A,(E<>>32-y)+p}function r(E,p,f,w,g,y,A){return E=E+(p&w|f&~w)+g+A,(E<>>32-y)+p}function n(E,p,f,w,g,y,A){return E=E+(p^f^w)+g+A,(E<>>32-y)+p}function i(E,p,f,w,g,y,A){return E=E+(f^(p|~w))+g+A,(E<>>32-y)+p}for(var a=Ce,l=a.lib,s=l.WordArray,o=l.Hasher,l=a.algo,h=[],d=0;64>d;d++)h[d]=4294967296*e.abs(e.sin(d+1))|0;l=l.MD5=o.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(E,p){for(var f=0;16>f;f++){var w=p+f,g=E[w];E[w]=(g<<8|g>>>24)&16711935|(g<<24|g>>>8)&4278255360}var f=this._hash.words,w=E[p+0],g=E[p+1],y=E[p+2],A=E[p+3],S=E[p+4],_=E[p+5],I=E[p+6],D=E[p+7],H=E[p+8],V=E[p+9],F=E[p+10],P=E[p+11],k=E[p+12],L=E[p+13],q=E[p+14],J=E[p+15],z=f[0],ie=f[1],X=f[2],K=f[3],z=t(z,ie,X,K,w,7,h[0]),K=t(K,z,ie,X,g,12,h[1]),X=t(X,K,z,ie,y,17,h[2]),ie=t(ie,X,K,z,A,22,h[3]),z=t(z,ie,X,K,S,7,h[4]),K=t(K,z,ie,X,_,12,h[5]),X=t(X,K,z,ie,I,17,h[6]),ie=t(ie,X,K,z,D,22,h[7]),z=t(z,ie,X,K,H,7,h[8]),K=t(K,z,ie,X,V,12,h[9]),X=t(X,K,z,ie,F,17,h[10]),ie=t(ie,X,K,z,P,22,h[11]),z=t(z,ie,X,K,k,7,h[12]),K=t(K,z,ie,X,L,12,h[13]),X=t(X,K,z,ie,q,17,h[14]),ie=t(ie,X,K,z,J,22,h[15]),z=r(z,ie,X,K,g,5,h[16]),K=r(K,z,ie,X,I,9,h[17]),X=r(X,K,z,ie,P,14,h[18]),ie=r(ie,X,K,z,w,20,h[19]),z=r(z,ie,X,K,_,5,h[20]),K=r(K,z,ie,X,F,9,h[21]),X=r(X,K,z,ie,J,14,h[22]),ie=r(ie,X,K,z,S,20,h[23]),z=r(z,ie,X,K,V,5,h[24]),K=r(K,z,ie,X,q,9,h[25]),X=r(X,K,z,ie,A,14,h[26]),ie=r(ie,X,K,z,H,20,h[27]),z=r(z,ie,X,K,L,5,h[28]),K=r(K,z,ie,X,y,9,h[29]),X=r(X,K,z,ie,D,14,h[30]),ie=r(ie,X,K,z,k,20,h[31]),z=n(z,ie,X,K,_,4,h[32]),K=n(K,z,ie,X,H,11,h[33]),X=n(X,K,z,ie,P,16,h[34]),ie=n(ie,X,K,z,q,23,h[35]),z=n(z,ie,X,K,g,4,h[36]),K=n(K,z,ie,X,S,11,h[37]),X=n(X,K,z,ie,D,16,h[38]),ie=n(ie,X,K,z,F,23,h[39]),z=n(z,ie,X,K,L,4,h[40]),K=n(K,z,ie,X,w,11,h[41]),X=n(X,K,z,ie,A,16,h[42]),ie=n(ie,X,K,z,I,23,h[43]),z=n(z,ie,X,K,V,4,h[44]),K=n(K,z,ie,X,k,11,h[45]),X=n(X,K,z,ie,J,16,h[46]),ie=n(ie,X,K,z,y,23,h[47]),z=i(z,ie,X,K,w,6,h[48]),K=i(K,z,ie,X,D,10,h[49]),X=i(X,K,z,ie,q,15,h[50]),ie=i(ie,X,K,z,_,21,h[51]),z=i(z,ie,X,K,k,6,h[52]),K=i(K,z,ie,X,A,10,h[53]),X=i(X,K,z,ie,F,15,h[54]),ie=i(ie,X,K,z,g,21,h[55]),z=i(z,ie,X,K,H,6,h[56]),K=i(K,z,ie,X,J,10,h[57]),X=i(X,K,z,ie,I,15,h[58]),ie=i(ie,X,K,z,L,21,h[59]),z=i(z,ie,X,K,S,6,h[60]),K=i(K,z,ie,X,P,10,h[61]),X=i(X,K,z,ie,y,15,h[62]),ie=i(ie,X,K,z,V,21,h[63]);f[0]=f[0]+z|0,f[1]=f[1]+ie|0,f[2]=f[2]+X|0,f[3]=f[3]+K|0},_doFinalize:function(){var E=this._data,p=E.words,f=8*this._nDataBytes,w=8*E.sigBytes;p[w>>>5]|=128<<24-w%32;var g=e.floor(f/4294967296);for(p[(w+64>>>9<<4)+15]=(g<<8|g>>>24)&16711935|(g<<24|g>>>8)&4278255360,p[(w+64>>>9<<4)+14]=(f<<8|f>>>24)&16711935|(f<<24|f>>>8)&4278255360,E.sigBytes=4*(p.length+1),this._process(),E=this._hash,p=E.words,f=0;4>f;f++)w=p[f],p[f]=(w<<8|w>>>24)&16711935|(w<<24|w>>>8)&4278255360;return E},clone:function(){var E=o.clone.call(this);return E._hash=this._hash.clone(),E}}),a.MD5=o._createHelper(l),a.HmacMD5=o._createHmacHelper(l)})(Math);(function(){var e=Ce,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 o=this._hash.words,l=o[0],h=o[1],d=o[2],E=o[3],p=o[4],f=0;80>f;f++){if(16>f)n[f]=a[s+f]|0;else{var w=n[f-3]^n[f-8]^n[f-14]^n[f-16];n[f]=w<<1|w>>>31}w=(l<<5|l>>>27)+p+n[f],w=20>f?w+((h&d|~h&E)+1518500249):40>f?w+((h^d^E)+1859775393):60>f?w+((h&d|h&E|d&E)-1894007588):w+((h^d^E)-899497514),p=E,E=d,d=h<<30|h>>>2,h=l,l=w}o[0]=o[0]+l|0,o[1]=o[1]+h|0,o[2]=o[2]+d|0,o[3]=o[3]+E|0,o[4]=o[4]+p|0},_doFinalize:function(){var a=this._data,s=a.words,o=8*this._nDataBytes,l=8*a.sigBytes;return s[l>>>5]|=128<<24-l%32,s[(l+64>>>9<<4)+14]=Math.floor(o/4294967296),s[(l+64>>>9<<4)+15]=o,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=Ce,f=t.lib,r=f.WordArray,n=f.Hasher,f=t.algo,i=[],a=[],s=function(g){return 4294967296*(g-(g|0))|0},o=2,l=0;64>l;){var h;e:{h=o;for(var d=e.sqrt(h),E=2;E<=d;E++)if(!(h%E)){h=!1;break e}h=!0}h&&(8>l&&(i[l]=s(e.pow(o,.5))),a[l]=s(e.pow(o,1/3)),l++),o++}var p=[],f=f.SHA256=n.extend({_doReset:function(){this._hash=new r.init(i.slice(0))},_doProcessBlock:function(w,g){for(var y=this._hash.words,A=y[0],S=y[1],_=y[2],I=y[3],D=y[4],H=y[5],V=y[6],F=y[7],P=0;64>P;P++){if(16>P)p[P]=w[g+P]|0;else{var k=p[P-15],L=p[P-2];p[P]=((k<<25|k>>>7)^(k<<14|k>>>18)^k>>>3)+p[P-7]+((L<<15|L>>>17)^(L<<13|L>>>19)^L>>>10)+p[P-16]}k=F+((D<<26|D>>>6)^(D<<21|D>>>11)^(D<<7|D>>>25))+(D&H^~D&V)+a[P]+p[P],L=((A<<30|A>>>2)^(A<<19|A>>>13)^(A<<10|A>>>22))+(A&S^A&_^S&_),F=V,V=H,H=D,D=I+k|0,I=_,_=S,S=A,A=k+L|0}y[0]=y[0]+A|0,y[1]=y[1]+S|0,y[2]=y[2]+_|0,y[3]=y[3]+I|0,y[4]=y[4]+D|0,y[5]=y[5]+H|0,y[6]=y[6]+V|0,y[7]=y[7]+F|0},_doFinalize:function(){var w=this._data,g=w.words,y=8*this._nDataBytes,A=8*w.sigBytes;return g[A>>>5]|=128<<24-A%32,g[(A+64>>>9<<4)+14]=e.floor(y/4294967296),g[(A+64>>>9<<4)+15]=y,w.sigBytes=4*g.length,this._process(),this._hash},clone:function(){var w=n.clone.call(this);return w._hash=this._hash.clone(),w}});t.SHA256=n._createHelper(f),t.HmacSHA256=n._createHmacHelper(f)})(Math);(function(){var e=Ce,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=Ce,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)],o=[],l=0;80>l;l++)o[l]=e();a=a.SHA512=r.extend({_doReset:function(){this._hash=new i.init([new n.init(1779033703,4089235720),new n.init(3144134277,2227873595),new n.init(1013904242,4271175723),new n.init(2773480762,1595750129),new n.init(1359893119,2917565137),new n.init(2600822924,725511199),new n.init(528734635,4215389547),new n.init(1541459225,327033209)])},_doProcessBlock:function(h,d){for(var S=this._hash.words,E=S[0],p=S[1],f=S[2],w=S[3],g=S[4],y=S[5],A=S[6],S=S[7],_=E.high,I=E.low,D=p.high,H=p.low,V=f.high,F=f.low,P=w.high,k=w.low,L=g.high,q=g.low,J=y.high,z=y.low,K=A.high,X=A.low,ie=S.high,be=S.low,ye=_,$e=I,qe=D,ce=H,_e=V,Le=F,lr=P,Bt=k,pt=L,zt=q,Tt=J,nt=z,It=K,tt=X,gt=ie,Yt=be,Je=0;80>Je;Je++){var Pr=o[Je];if(16>Je)var Ut=Pr.high=h[d+2*Je]|0,Ze=Pr.low=h[d+2*Je+1]|0;else{var Ut=o[Je-15],Ze=Ut.high,Zt=Ut.low,Ut=(Ze>>>1|Zt<<31)^(Ze>>>8|Zt<<24)^Ze>>>7,Zt=(Zt>>>1|Ze<<31)^(Zt>>>8|Ze<<24)^(Zt>>>7|Ze<<25),$r=o[Je-2],Ze=$r.high,mt=$r.low,$r=(Ze>>>19|mt<<13)^(Ze<<3|mt>>>29)^Ze>>>6,mt=(mt>>>19|Ze<<13)^(mt<<3|Ze>>>29)^(mt>>>6|Ze<<26),Ze=o[Je-7],Un=Ze.high,fr=o[Je-16],Qt=fr.high,fr=fr.low,Ze=Zt+Ze.low,Ut=Ut+Un+(Ze>>>0>>0?1:0),Ze=Ze+mt,Ut=Ut+$r+(Ze>>>0>>0?1:0),Ze=Ze+fr,Ut=Ut+Qt+(Ze>>>0>>0?1:0);Pr.high=Ut,Pr.low=Ze}var Un=pt&Tt^~pt&It,fr=zt&nt^~zt&tt,Pr=ye&qe^ye&_e^qe&_e,wr=$e&ce^$e&Le^ce&Le,Zt=(ye>>>28|$e<<4)^(ye<<30|$e>>>2)^(ye<<25|$e>>>7),$r=($e>>>28|ye<<4)^($e<<30|ye>>>2)^($e<<25|ye>>>7),mt=s[Je],la=mt.high,Mr=mt.low,mt=Yt+((zt>>>14|pt<<18)^(zt>>>18|pt<<14)^(zt<<23|pt>>>9)),Qt=gt+((pt>>>14|zt<<18)^(pt>>>18|zt<<14)^(pt<<23|zt>>>9))+(mt>>>0>>0?1:0),mt=mt+fr,Qt=Qt+Un+(mt>>>0>>0?1:0),mt=mt+Mr,Qt=Qt+la+(mt>>>0>>0?1:0),mt=mt+Ze,Qt=Qt+Ut+(mt>>>0>>0?1:0),Ze=$r+wr,Pr=Zt+Pr+(Ze>>>0<$r>>>0?1:0),gt=It,Yt=tt,It=Tt,tt=nt,Tt=pt,nt=zt,zt=Bt+mt|0,pt=lr+Qt+(zt>>>0>>0?1:0)|0,lr=_e,Bt=Le,_e=qe,Le=ce,qe=ye,ce=$e,$e=mt+Ze|0,ye=Qt+Pr+($e>>>0>>0?1:0)|0}I=E.low=I+$e,E.high=_+ye+(I>>>0<$e>>>0?1:0),H=p.low=H+ce,p.high=D+qe+(H>>>0>>0?1:0),F=f.low=F+Le,f.high=V+_e+(F>>>0>>0?1:0),k=w.low=k+Bt,w.high=P+lr+(k>>>0>>0?1:0),q=g.low=q+zt,g.high=L+pt+(q>>>0>>0?1:0),z=y.low=z+nt,y.high=J+Tt+(z>>>0>>0?1:0),X=A.low=X+tt,A.high=K+It+(X>>>0>>0?1:0),be=S.low=be+Yt,S.high=ie+gt+(be>>>0>>0?1:0)},_doFinalize:function(){var h=this._data,d=h.words,E=8*this._nDataBytes,p=8*h.sigBytes;return d[p>>>5]|=128<<24-p%32,d[(p+128>>>10<<5)+30]=Math.floor(E/4294967296),d[(p+128>>>10<<5)+31]=E,h.sigBytes=4*d.length,this._process(),this._hash.toX32()},clone:function(){var h=r.clone.call(this);return h._hash=this._hash.clone(),h},blockSize:32}),t.SHA512=r._createHelper(a),t.HmacSHA512=r._createHmacHelper(a)})();(function(){var e=Ce,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=Ce,h=e.lib,t=h.WordArray,r=h.Hasher,h=e.algo,n=t.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),i=t.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),a=t.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),s=t.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),o=t.create([0,1518500249,1859775393,2400959708,2840853838]),l=t.create([1352829926,1548603684,1836072691,2053994217,0]),h=h.RIPEMD160=r.extend({_doReset:function(){this._hash=t.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(d,E){for(var p=0;16>p;p++){var f=E+p,w=d[f];d[f]=(w<<8|w>>>24)&16711935|(w<<24|w>>>8)&4278255360}var f=this._hash.words,w=o.words,g=l.words,y=n.words,A=i.words,S=a.words,_=s.words,I,D,H,V,F,P,k,L,q,J;P=I=f[0],k=D=f[1],L=H=f[2],q=V=f[3],J=F=f[4];for(var z,p=0;80>p;p+=1)z=I+d[E+y[p]]|0,z=16>p?z+((D^H^V)+w[0]):32>p?z+((D&H|~D&V)+w[1]):48>p?z+(((D|~H)^V)+w[2]):64>p?z+((D&V|H&~V)+w[3]):z+((D^(H|~V))+w[4]),z|=0,z=z<>>32-S[p],z=z+F|0,I=F,F=V,V=H<<10|H>>>22,H=D,D=z,z=P+d[E+A[p]]|0,z=16>p?z+((k^(L|~q))+g[0]):32>p?z+((k&q|L&~q)+g[1]):48>p?z+(((k|~L)^q)+g[2]):64>p?z+((k&L|~k&q)+g[3]):z+((k^L^q)+g[4]),z|=0,z=z<<_[p]|z>>>32-_[p],z=z+J|0,P=J,J=q,q=L<<10|L>>>22,L=k,k=z;z=f[1]+H+q|0,f[1]=f[2]+V+J|0,f[2]=f[3]+F+P|0,f[3]=f[4]+I+k|0,f[4]=f[0]+D+L|0,f[0]=z},_doFinalize:function(){var d=this._data,E=d.words,p=8*this._nDataBytes,f=8*d.sigBytes;for(E[f>>>5]|=128<<24-f%32,E[(f+64>>>9<<4)+14]=(p<<8|p>>>24)&16711935|(p<<24|p>>>8)&4278255360,d.sigBytes=4*(E.length+1),this._process(),d=this._hash,E=d.words,p=0;5>p;p++)f=E[p],E[p]=(f<<8|f>>>24)&16711935|(f<<24|f>>>8)&4278255360;return d},clone:function(){var d=r.clone.call(this);return d._hash=this._hash.clone(),d}});e.RIPEMD160=r._createHelper(h),e.HmacRIPEMD160=r._createHmacHelper(h)})(Math);(function(){var e=Ce,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(),o=this._iKey=n.clone(),l=s.words,h=o.words,d=0;d>6)+Xu.charAt(r&63);if(t+1==e.length?(r=parseInt(e.substring(t,t+1),16),n+=Xu.charAt(r<<2)):t+2==e.length&&(r=parseInt(e.substring(t,t+2),16),n+=Xu.charAt(r>>2)+Xu.charAt((r&3)<<4)),ud)for(;(n.length&3)>0;)n+=ud;return n}function Zu(e){var t="",r,n=0,i,a;for(r=0;r>2),i=a&3,n=1):n==1?(t+=ds(i<<2|a>>4),i=a&15,n=2):n==2?(t+=ds(i),t+=ds(a>>2),i=a&3,n=3):(t+=ds(i<<2|a>>4),t+=ds(a&15),n=0));return n==1&&(t+=ds(i<<2)),t}function Nm(e){var t=Zu(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 Gb(e,t,r,n,i,a){for(var s=t&32767,o=t>>15;--a>=0;){var l=this[e]&32767,h=this[e++]>>15,d=o*l+h*s;l=s*l+((d&32767)<<15)+r[n]+(i&1073741823),i=(l>>>30)+(d>>>15)+o*h+(i>>>30),r[n++]=l&1073741823}return i}function zb(e,t,r,n,i,a){for(var s=t&16383,o=t>>14;--a>=0;){var l=this[e]&16383,h=this[e++]>>14,d=o*l+h*s;l=s*l+((d&16383)<<14)+r[n]+i,i=(l>>28)+(d>>14)+o*h,r[n++]=l&268435455}return i}Tm&&wc.appName=="Microsoft Internet Explorer"?(ee.prototype.am=Gb,Qs=30):Tm&&wc.appName!="Netscape"?(ee.prototype.am=Kb,Qs=26):(ee.prototype.am=zb,Qs=28);ee.prototype.DB=Qs;ee.prototype.DM=(1<=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s}function Xb(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 Zs(e){var t=ft();return t.fromInt(e),t}function Jb(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:km(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 Qb(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(o>o)>0&&(i=!0,a=ds(n));s>=0;)o>(o+=this.DB-t)):(n=this[s]>>(o-=t)&r,o<=0&&(o+=this.DB,--s)),n>0&&(i=!0),i&&(a+=ds(n));return i?a:"0"}function eC(){var e=ft();return ee.ZERO.subTo(this,e),e}function tC(){return this.s<0?this.negate():this}function rC(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 hf(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 nC(){return this.t<=0?0:this.DB*(this.t-1)+hf(this[this.t-1]^this.s&this.DM)}function iC(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 sC(e,t){for(var r=e;r=0;--o)t[o+a+1]=this[o]>>n|s,s=(this[o]&i)<=0;--o)t[o]=0;t[a]=s,t.t=this.t+a+1,t.s=this.s,t.clamp()}function uC(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 cC(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 fC(e,t,r){var n=e.abs();if(!(n.t<=0)){var i=this.abs();if(i.t0?(n.lShiftTo(l,a),i.lShiftTo(l,r)):(n.copyTo(a),i.copyTo(r));var h=a.t,d=a[h-1];if(d!=0){var E=d*(1<1?a[h-2]>>this.F2:0),p=this.FV/E,f=(1<=0&&(r[r.t++]=1,r.subTo(A,r)),ee.ONE.dlShiftTo(h,A),A.subTo(a,a);a.t=0;){var S=r[--g]==d?this.DM:Math.floor(r[g]*p+(r[g-1]+w)*f);if((r[g]+=a.am(0,S,r,y,0,h))0&&r.rShiftTo(l,r),s<0&&ee.ZERO.subTo(r,r)}}}function hC(e){var t=ft();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(ee.ZERO)>0&&e.subTo(t,t),t}function Ma(e){this.m=e}function pC(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e}function dC(e){return e}function gC(e){e.divRemTo(this.m,null,e)}function mC(e,t,r){e.multiplyTo(t,r),this.reduce(r)}function vC(e,t){e.squareTo(t),this.reduce(t)}Ma.prototype.convert=pC;Ma.prototype.revert=dC;Ma.prototype.reduce=gC;Ma.prototype.mulTo=mC;Ma.prototype.sqrTo=vC;function EC(){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 qa(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 wC(e){var t=ft();return e.copyTo(t),this.reduce(t),t}function yC(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 SC(e,t){e.squareTo(t),this.reduce(t)}function bC(e,t,r){e.multiplyTo(t,r),this.reduce(r)}qa.prototype.convert=AC;qa.prototype.revert=wC;qa.prototype.reduce=yC;qa.prototype.mulTo=bC;qa.prototype.sqrTo=SC;function CC(){return(this.t>0?this[0]&1:this.s)==0}function FC(e,t){if(e>4294967295||e<1)return ee.ONE;var r=ft(),n=ft(),i=t.convert(this),a=hf(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 _C(e,t){var r;return e<256||t.isEven()?r=new Ma(t):r=new qa(t),this.exp(e,r)}ee.prototype.copyTo=Wb;ee.prototype.fromInt=Xb;ee.prototype.fromString=Jb;ee.prototype.clamp=Zb;ee.prototype.dlShiftTo=iC;ee.prototype.drShiftTo=sC;ee.prototype.lShiftTo=aC;ee.prototype.rShiftTo=uC;ee.prototype.subTo=oC;ee.prototype.multiplyTo=cC;ee.prototype.squareTo=lC;ee.prototype.divRemTo=fC;ee.prototype.invDigit=EC;ee.prototype.isEven=CC;ee.prototype.exp=FC;ee.prototype.toString=Qb;ee.prototype.negate=eC;ee.prototype.abs=tC;ee.prototype.compareTo=rC;ee.prototype.bitLength=nC;ee.prototype.mod=hC;ee.prototype.modPowInt=_C;ee.ZERO=Zs(0);ee.ONE=Zs(1);function IC(){var e=ft();return this.copyTo(e),e}function DC(){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 $C(){return this.t==0?this.s:this[0]<<16>>16}function PC(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}function RC(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function TC(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=Zs(r),i=ft(),a=ft(),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 xC(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,o=0;o=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 OC(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),pd,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 kC(e){return this.compareTo(e)==0}function LC(e){return this.compareTo(e)<0?this:e}function UC(e){return this.compareTo(e)>0?this:e}function HC(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 XC(){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 sF(e){var t=ft();return this.addTo(e,t),t}function aF(e){var t=ft();return this.subTo(e,t),t}function uF(e){var t=ft();return this.multiplyTo(e,t),t}function oF(){var e=ft();return this.squareTo(e),e}function cF(e){var t=ft();return this.divRemTo(e,t,null),t}function lF(e){var t=ft();return this.divRemTo(e,null,t),t}function fF(e){var t=ft(),r=ft();return this.divRemTo(e,t,r),new Array(t,r)}function hF(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}function pF(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 Sc(){}function Hm(e){return e}function dF(e,t,r){e.multiplyTo(t,r)}function gF(e,t){e.squareTo(t)}Sc.prototype.convert=Hm;Sc.prototype.revert=Hm;Sc.prototype.mulTo=dF;Sc.prototype.sqrTo=gF;function mF(e){return this.exp(e,new Sc)}function vF(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=ft();return e.copyTo(t),this.reduce(t),t}function wF(e){return e}function yF(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 SF(e,t){e.squareTo(t),this.reduce(t)}function bF(e,t,r){e.multiplyTo(t,r),this.reduce(r)}eo.prototype.convert=AF;eo.prototype.revert=wF;eo.prototype.reduce=yF;eo.prototype.mulTo=bF;eo.prototype.sqrTo=SF;function CF(e,t){var r=e.bitLength(),n,i=Zs(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 Ma(t):t.isEven()?a=new eo(t):a=new qa(t);var s=new Array,o=3,l=n-1,h=(1<1){var d=ft();for(a.sqrTo(s[1],d);o<=h;)s[o]=ft(),a.mulTo(d,s[o-2],s[o]),o+=2}var E=e.t-1,p,f=!0,w=ft(),g;for(r=hf(e[E])-1;E>=0;){for(r>=l?p=e[E]>>r-l&h:(p=(e[E]&(1<0&&(p|=e[E-1]>>this.DB+r-l)),o=n;!(p&1);)p>>=1,--o;if((r-=o)<0&&(r+=this.DB,--E),f)s[p].copyTo(i),f=!1;else{for(;o>1;)a.sqrTo(i,w),a.sqrTo(w,i),o-=2;o>0?a.sqrTo(i,w):(g=i,i=w,w=g),a.mulTo(w,s[p],i)}for(;E>=0&&!(e[E]&1<0&&(t.rShiftTo(a,t),r.rShiftTo(a,r));t.signum()>0;)(i=t.getLowestSetBit())>0&&t.rShiftTo(i,t),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return a>0&&r.lShiftTo(a,r),r}function _F(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 IF(e){var t=e.isEven();if(this.isEven()&&t||e.signum()==0)return ee.ZERO;for(var r=e.clone(),n=this.clone(),i=Zs(1),a=Zs(0),s=Zs(0),o=Zs(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()||!o.isEven())&&(s.addTo(this,s),o.subTo(e,o)),s.rShiftTo(1,s)):o.isEven()||o.subTo(e,o),o.rShiftTo(1,o);r.compareTo(n)>=0?(r.subTo(n,r),t&&i.subTo(s,i),a.subTo(o,a)):(n.subTo(r,n),t&&s.subTo(i,s),o.subTo(a,o))}if(n.compareTo(ee.ONE)!=0)return ee.ZERO;if(o.compareTo(e)>=0)return o.subtract(e);if(o.signum()<0)o.addTo(e,o);else return o;return o.signum()<0?o.add(e):o}var Xr=[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],DF=(1<<26)/Xr[Xr.length-1];function BF(e){var t,r=this.abs();if(r.t==1&&r[0]<=Xr[Xr.length-1]){for(t=0;t>1,e>Xr.length&&(e=Xr.length);for(var i=ft(),a=0;a>8&255,Bn[mr++]^=e>>16&255,Bn[mr++]^=e>>24&255,mr>=od&&(mr-=od)}function gd(){xF(new Date().getTime())}if(Bn==null){if(Bn=new Array,mr=0,Wu!==void 0&&(Wu.crypto!==void 0||Wu.msCrypto!==void 0)){if(nd=Wu.crypto||Wu.msCrypto,nd.getRandomValues)for(sd=new Uint8Array(32),nd.getRandomValues(sd),Jn=0;Jn<32;++Jn)Bn[mr++]=sd[Jn];else if(wc.appName=="Netscape"&&wc.appVersion<"5")for(ad=Wu.crypto.random(32),Jn=0;Jn>>8,Bn[mr++]=Jn&255;mr=0,gd()}var Jn,nd,sd,ad;function OF(){if(uf==null){for(gd(),uf=TF(),uf.init(Bn),mr=0;mr0&&t.length>0)this.n=hn(e,16),this.e=parseInt(t,16);else throw"Invalid RSA public key"}function LF(e){return e.modPowInt(this.e,this.n)}ze.prototype.doPublic=LF;ze.prototype.setPublic=kF;ze.prototype.type="RSA";function UF(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=hn(e,16),this.e=parseInt(t,16),this.d=hn(r,16);else throw"Invalid RSA private key"}function HF(e,t,r,n,i,a,s,o){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=hn(e,16),this.e=parseInt(t,16),this.d=hn(r,16),this.p=hn(n,16),this.q=hn(i,16),this.dmp1=hn(a,16),this.dmq1=hn(s,16),this.coeff=hn(o,16);else throw"Invalid RSA private key in RSASetPrivateEx"}function jF(e,t){var r=new to,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 o=this.p;this.p=this.q,this.q=o}var l=this.q.subtract(this.p).abs();if(!(l.bitLength()0;--h){i=i.twice();var d=r.testBit(h),E=t.testBit(h);d!=E&&(i=i.add(d?this:n))}for(h=s.bitLength()-2;h>0;--h){o=o.twice();var p=s.testBit(h),f=a.testBit(h);p!=f&&(o=o.add(p?o:l))}return i}function s8(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}dt.prototype.getX=JF;dt.prototype.getY=ZF;dt.prototype.equals=QF;dt.prototype.isInfinity=e8;dt.prototype.negate=t8;dt.prototype.add=r8;dt.prototype.twice=n8;dt.prototype.multiply=i8;dt.prototype.multiplyTwo=s8;function ms(e,t,r){this.q=e,this.a=this.fromBigInteger(t),this.b=this.fromBigInteger(r),this.infinity=new dt(this,null,null)}function a8(){return this.q}function u8(){return this.a}function o8(){return this.b}function c8(e){return e==this?!0:this.q.equals(e.q)&&this.a.equals(e.a)&&this.b.equals(e.b)}function l8(){return this.infinity}function f8(e){return new ar(this.q,e)}function h8(e){switch(parseInt(e.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:var t=e.substr(0,2),r=e.substr(2),n=this.fromBigInteger(new ee(h,16)),i=this.getA(),a=this.getB(),s=n.square().add(i).multiply(n).add(a),o=s.sqrt();return t=="03"&&(o=o.negate()),new dt(this,n,o);case 4:case 6:case 7:var l=(e.length-2)/2,h=e.substr(2,l),d=e.substr(l+2,l);return new dt(this,this.fromBigInteger(new ee(h,16)),this.fromBigInteger(new ee(d,16)));default:return null}}ms.prototype.getQ=a8;ms.prototype.getA=u8;ms.prototype.getB=o8;ms.prototype.equals=c8;ms.prototype.getInfinity=l8;ms.prototype.fromBigInteger=f8;ms.prototype.decodePointHex=h8;ar.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)};dt.prototype.getEncoded=function(e){var t=function(a,s){var o=a.toByteArrayUnsigned();if(so.length;)o.unshift(0);return o},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};dt.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),o=new ee(a);return new dt(e,e.fromBigInteger(s),e.fromBigInteger(o))};dt.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),o=new ee(a,16);return new dt(e,e.fromBigInteger(s),e.fromBigInteger(o))};dt.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 dt(this.curve,i,a)};dt.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 dt(this.curve,n,i)};dt.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),o=t.testBit(a);s!=o&&(i=i.add2D(s?this:n))}return i};dt.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)};dt.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"};dt.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 jm=function(){var e="(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)",t='(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))',r='(?:"'+t+'*")',n=new RegExp("(?:false|true|null|[\\{\\}\\[\\]]|"+e+"|"+r+")","g"),i=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),a={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:` `,r:"\r",t:" "};function s(E,p,f){return p?a[p]:String.fromCharCode(parseInt(f,16))}var o=new String(""),l="\\",h={"{":Object,"[":Array},d=Object.hasOwnProperty;return function(E,p){var f=E.match(n),w,g=f[0],y=!1;g==="{"?w={}:g==="["?w=[]:(w=[],y=!0);for(var A,S=[w],_=1-y,I=f.length;_=0;)delete P[k[J]]}return p.call(V,F,P)};w=H({"":w},"")}return w}}();(typeof m>"u"||!m)&&(m={});(typeof m.asn1>"u"||!m.asn1)&&(m.asn1={});m.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 Cc(e)},this.getPEMStringFromHex=function(e,t){return Or(e,t)},this.newObject=function(e){var t=m,r=t.asn1,n=r.ASN1Object,i=r.DERBoolean,a=r.DERInteger,s=r.DERBitString,o=r.DEROctetString,l=r.DERNull,h=r.DERObjectIdentifier,d=r.DEREnumerated,E=r.DERUTF8String,p=r.DERNumericString,f=r.DERPrintableString,w=r.DERTeletexString,g=r.DERIA5String,y=r.DERUTCTime,A=r.DERGeneralizedTime,S=r.DERVisibleString,_=r.DERBMPString,I=r.DERSequence,D=r.DERSet,H=r.DERTaggedObject,V=r.ASN1Util.newObject;if(e instanceof r.ASN1Object)return e;var F=Object.keys(e);if(F.length!=1)throw new Error("key of param shall be only one.");var P=F[0];if(":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+P+":")==-1)throw new Error("undefined key: "+P);if(P=="bool")return new i(e[P]);if(P=="int")return new a(e[P]);if(P=="bitstr")return new s(e[P]);if(P=="octstr")return new o(e[P]);if(P=="null")return new l(e[P]);if(P=="oid")return new h(e[P]);if(P=="enum")return new d(e[P]);if(P=="utf8str")return new E(e[P]);if(P=="numstr")return new p(e[P]);if(P=="prnstr")return new f(e[P]);if(P=="telstr")return new w(e[P]);if(P=="ia5str")return new g(e[P]);if(P=="utctime")return new y(e[P]);if(P=="gentime")return new A(e[P]);if(P=="visstr")return new S(e[P]);if(P=="bmpstr")return new _(e[P]);if(P=="asn1")return new n(e[P]);if(P=="seq"){for(var k=e[P],L=[],q=0;q"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,o=s.toString(16);if(o.length%2==1&&(o="0"+o),s<128)return o;var l=o.length/2;if(l>15)throw new Error("ASN.1 length too long to represent by 8x: n = "+s.toString(16));var h=128+l;return h.toString(16)+o},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)};m.asn1.DERAbstractString=function(e){m.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=df(this.s).toLowerCase()},this.setStringHex=function(n){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=n},this.getFreshValueHex=function(){return this.hV},typeof e<"u"&&(typeof e=="string"?this.setString(e):typeof e.str<"u"?this.setString(e.str):typeof e.hex<"u"&&this.setStringHex(e.hex))};he(m.asn1.DERAbstractString,m.asn1.ASN1Object);m.asn1.DERAbstractTime=function(e){m.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,o=this.localDateToUTC(n),l=String(o.getFullYear());i=="utc"&&(l=l.substr(2,2));var h=s(String(o.getMonth()+1),2),d=s(String(o.getDate()),2),E=s(String(o.getHours()),2),p=s(String(o.getMinutes()),2),f=s(String(o.getSeconds()),2),w=l+h+d+E+p+f;if(a===!0){var g=o.getMilliseconds();if(g!=0){var y=s(String(g),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,o,l){var h=new Date(Date.UTC(n,i-1,a,s,o,l,0));this.setByDate(h)},this.getFreshValueHex=function(){return this.hV}};he(m.asn1.DERAbstractTime,m.asn1.ASN1Object);m.asn1.DERAbstractStructured=function(e){m.asn1.DERAbstractString.superclass.constructor.call(this);var t=null;this.setByASN1ObjectArray=function(r){this.hTLV=null,this.isModified=!0,this.asn1Array=r},this.appendASN1Object=function(r){this.hTLV=null,this.isModified=!0,this.asn1Array.push(r)},this.asn1Array=new Array,typeof e<"u"&&typeof e.array<"u"&&(this.asn1Array=e.array)};he(m.asn1.DERAbstractStructured,m.asn1.ASN1Object);m.asn1.DERBoolean=function(e){m.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",e==!1?this.hTLV="010100":this.hTLV="0101ff"};he(m.asn1.DERBoolean,m.asn1.ASN1Object);m.asn1.DERInteger=function(e){m.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.params=null;var t=Cc;this.setByBigInteger=function(r){this.isModified=!0,this.params={bigint:r}},this.setByInteger=function(r){this.isModified=!0,this.params=r},this.setValueHex=function(r){this.isModified=!0,this.params={hex:r}},this.getFreshValueHex=function(){var r=this.params,n=null;if(r==null)throw new Error("value not set");if(typeof r=="object"&&r.hex!=null)return this.hV=r.hex,this.hV;if(typeof r=="number")n=new ee(String(r),10);else if(r.int!=null)n=new ee(String(r.int),10);else if(r.bigint!=null)n=r.bigint;else throw new Error("wrong parameter");return this.hV=t(n),this.hV},e!=null&&(this.params=e)};he(m.asn1.DERInteger,m.asn1.ASN1Object);m.asn1.DERBitString=function(e){if(e!==void 0&&typeof e.obj<"u"){var t=m.asn1.ASN1Util.newObject(e.obj);e.hex="00"+t.tohex()}m.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(r){this.hTLV=null,this.isModified=!0,this.hV=r},this.setUnusedBitsAndHexValue=function(r,n){if(r<0||7=a)break}return n};Ae.getNthChildIdx=function(e,t,r){var n=Ae.getChildIdx(e,t);return n[r]};Ae.getIdxbyList=function(e,t,r,n){var i=Ae,a,s;return r.length==0?n!==void 0&&e.substr(t,2)!==n?-1:t:(a=r.shift(),s=i.getChildIdx(e,t),a>=s.length?-1:i.getIdxbyList(e,s[a],r,n))};Ae.getIdxbyListEx=function(e,t,r,n){var i=Ae,a,s;if(r.length==0)return n!==void 0&&e.substr(t,2)!==n?-1:t;a=r.shift(),s=i.getChildIdx(e,t);for(var o=0,l=0;l=e.length?null:i.getTLV(e,a)};Ae.getTLVbyListEx=function(e,t,r,n){var i=Ae,a=i.getIdxbyListEx(e,t,r,n);return a==-1?null:i.getTLV(e,a)};Ae.getVbyList=function(e,t,r,n,i){var a=Ae,s,o;return s=a.getIdxbyList(e,t,r,n),s==-1||s>=e.length?null:(o=a.getV(e,s),i===!0&&(o=o.substr(2)),o)};Ae.getVbyListEx=function(e,t,r,n,i){var a=Ae,s,o,l;return s=a.getIdxbyListEx(e,t,r,n),s==-1?null:(l=a.getV(e,s),e.substr(s,2)=="03"&&i!==!1&&(l=l.substr(2)),l)};Ae.getInt=function(e,t,r){r==null&&(r=-1);try{var n=e.substr(t,2);if(n!="02"&&n!="03")return r;var i=Ae.getV(e,t);return n=="02"?parseInt(i,16):Xm(i)}catch{return r}};Ae.getOID=function(e,t,r){r==null&&(r=null);try{if(e.substr(t,2)!="06")return r;var n=Ae.getV(e,t);return Af(n)}catch{return r}};Ae.getOIDName=function(e,t,r){r==null&&(r=null);try{var n=Ae.getOID(e,t,r);if(n==r)return r;var i=m.asn1.x509.OID.oid2name(n);return i==""?n:i}catch{return r}};Ae.getString=function(e,t,r){r==null&&(r=null);try{var n=Ae.getV(e,t);return dn(n)}catch{return r}};Ae.hextooidstr=function(e){var t=function(E,p){return E.length>=p?E:new Array(p-E.length+1).join("0")+E},r=[],n=e.substr(0,2),i=parseInt(n,16);r[0]=new String(Math.floor(i/40)),r[1]=new String(i%40);for(var a=e.substr(2),s=[],o=0;o0&&(d=d+"."+l.join(".")),d};Ae.dump=function(e,t,r,n){var i=Ae,a=i.getV,s=i.dump,o=i.getChildIdx,l=e;e instanceof m.asn1.ASN1Object&&(l=e.tohex());var h=function(V,F){if(V.length<=F*2)return V;var P=V.substr(0,F)+"..(total "+V.length/2+"bytes).."+V.substr(V.length-F,F);return P};t===void 0&&(t={ommit_long_octet:32}),r===void 0&&(r=0),n===void 0&&(n="");var d=t.ommit_long_octet,D=l.substr(r,2);if(D=="01"){var E=a(l,r);return E=="00"?n+`BOOLEAN FALSE `:n+`BOOLEAN TRUE `}if(D=="02"){var E=a(l,r);return n+"INTEGER "+h(E,d)+` `}if(D=="03"){var E=a(l,r);if(i.isASN1HEX(E.substr(2))){var p=n+`BITSTRING, encapsulates `;return p=p+s(E.substr(2),t,0,n+" "),p}else return n+"BITSTRING "+h(E,d)+` `}if(D=="04"){var E=a(l,r);if(i.isASN1HEX(E)){var p=n+`OCTETSTRING, encapsulates `;return p=p+s(E,t,0,n+" "),p}else return n+"OCTETSTRING "+h(E,d)+` `}if(D=="05")return n+`NULL `;if(D=="06"){var f=a(l,r),w=m.asn1.ASN1Util.oidHexToInt(f),g=m.asn1.x509.OID.oid2name(w),y=w.replace(/\./g," ");return g!=""?n+"ObjectIdentifier "+g+" ("+y+`) `:n+"ObjectIdentifier ("+y+`) `}if(D=="0a")return n+"ENUMERATED "+parseInt(a(l,r))+` `;if(D=="0c")return n+"UTF8String '"+yt(a(l,r))+`' `;if(D=="13")return n+"PrintableString '"+yt(a(l,r))+`' `;if(D=="14")return n+"TeletexString '"+yt(a(l,r))+`' `;if(D=="16")return n+"IA5String '"+yt(a(l,r))+`' `;if(D=="17")return n+"UTCTime "+yt(a(l,r))+` `;if(D=="18")return n+"GeneralizedTime "+yt(a(l,r))+` `;if(D=="1a")return n+"VisualString '"+yt(a(l,r))+`' `;if(D=="1e")return n+"BMPString '"+Ad(a(l,r))+`' `;if(D=="30"){if(l.substr(r,4)=="3000")return n+`SEQUENCE {} `;var p=n+`SEQUENCE `,A=o(l,r),S=t;if((A.length==2||A.length==3)&&l.substr(A[0],2)=="06"&&l.substr(A[A.length-1],2)=="04"){var g=i.oidname(a(l,A[0])),_=JSON.parse(JSON.stringify(t));_.x509ExtName=g,S=_}for(var I=0;I4?{enum:{hex:A}}:{enum:parseInt(A,16)};if(g=="30"||g=="31")return y[f[g]]=w(e),y;if(g=="14"){var H=p(A);return y[f[g]]={str:H},y}else if(g=="1e"){var H=E(A);return y[f[g]]={str:H},y}else if(":0c:12:13:16:17:18:1a:".indexOf(g)!=-1){var H=d(A);return y[f[g]]={str:H},y}else if(g.match(/^8[0-9]$/)){var H=d(A);return H==null|H==""?{tag:{tag:g,explicit:!1,hex:A}}:H.match(/[\x00-\x1F\x7F-\x9F]/)!=null||H.match(/[\u0000-\u001F\u0080–\u009F]/)!=null?{tag:{tag:g,explicit:!1,hex:A}}:{tag:{tag:g,explicit:!1,str:H}}}else if(g.match(/^a[0-9]$/))try{if(!n(A))throw new Error("not encap");return{tag:{tag:g,explicit:!0,obj:r(A)}}}catch{return{tag:{tag:g,explicit:!0,hex:A}}}else{var V=new m.asn1.ASN1Object;V.hV=A;var F=V.getLengthHexFromValue();return{asn1:{tlv:g+F+A}}}}}};Ae.isContextTag=function(e,t){e=e.toLowerCase();var r,n;try{r=parseInt(e,16)}catch{return-1}if(t===void 0)return(r&192)==128;try{var i=t.match(/^\[[0-9]+\]$/);return i==null||(n=parseInt(t.substr(1,t.length-1),10),n>31)?!1:(r&192)==128&&(r&31)==n}catch{return!1}};Ae.isASN1HEX=function(e){var t=Ae;if(e.length%2==1)return!1;var r=t.getVblen(e,0),n=e.substr(0,2),i=t.getL(e,0),a=e.length-n.length-i.length;return a==r*2};Ae.checkStrictDER=function(e,t,r,n,i){var a=Ae;if(r===void 0){if(typeof e!="string")throw new Error("not hex string");if(e=e.toLowerCase(),!m.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 o=a.getVblen(e,t);if(o>n)throw new Error("value of L too long than hex: idx="+t);var l=a.getTLV(e,t),h=l.length-2-a.getL(e,t).length;if(h!==o*2)throw new Error("V string length and L's value not the same:"+h+"/"+o*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 E=a.getVidx(e,t);if(e.substr(E,2)=="00"&&e.charCodeAt(E+2)<56)throw new Error("not least zeros for DER INTEGER")}if(parseInt(d,16)&32){for(var p=a.getVblen(e,t),f=0,w=a.getChildIdx(e,t),g=0;g"u"||!m)&&(m={});(typeof m.asn1>"u"||!m.asn1)&&(m.asn1={});(typeof m.asn1.x509>"u"||!m.asn1.x509)&&(m.asn1.x509={});m.asn1.x509.Certificate=function(e){m.asn1.x509.Certificate.superclass.constructor.call(this);var t=m,r=t.asn1,n=r.DERBitString,i=r.DERSequence,a=r.x509,s=a.TBSCertificate,o=a.AlgorithmIdentifier;this.params=void 0,this.setByParam=function(l){this.params=l},this.sign=function(){var l=this.params,h=l.sigalg;l.sigalg.name!=null&&(h=l.sigalg.name);var d=l.tbsobj.tohex(),E=new m.crypto.Signature({alg:h});E.init(l.cakey),E.updateHex(d),l.sighex=E.sign()},this.getPEM=function(){return Or(this.tohex(),"CERTIFICATE")},this.tohex=function(){var l=this.params;if((l.tbsobj==null||l.tbsobj==null)&&(l.tbsobj=new s(l)),l.sighex==null&&l.cakey!=null&&this.sign(),l.sighex==null)throw new Error("sighex or cakey parameter not defined");var h=[];h.push(l.tbsobj),h.push(new o({name:l.sigalg})),h.push(new n({hex:"00"+l.sighex}));var d=new i({array:h});return d.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&(this.params=e)};he(m.asn1.x509.Certificate,m.asn1.ASN1Object);m.asn1.x509.TBSCertificate=function(e){m.asn1.x509.TBSCertificate.superclass.constructor.call(this);var t=m,r=t.asn1,n=r.x509,i=r.DERTaggedObject,a=r.DERInteger,s=r.DERSequence,o=n.AlgorithmIdentifier,l=n.Time,h=n.X500Name,d=n.Extensions,E=n.SubjectPublicKeyInfo;this.params=null,this.setByParam=function(p){this.params=p},this.tohex=function(){var p=[],f=this.params;if(f.version!=null||f.version!=1){var w=2;f.version!=null&&(w=f.version-1);var g=new i({obj:new a({int:w})});p.push(g)}p.push(new a(f.serial)),p.push(new o({name:f.sigalg})),p.push(new h(f.issuer)),p.push(new s({array:[new l(f.notbefore),new l(f.notafter)]})),p.push(new h(f.subject)),p.push(new E(at.getKey(f.sbjpubkey))),f.ext!==void 0&&f.ext.length>0&&p.push(new i({tag:"a3",obj:new d(f.ext)}));var y=new m.asn1.DERSequence({array:p});return y.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};he(m.asn1.x509.TBSCertificate,m.asn1.ASN1Object);m.asn1.x509.Extensions=function(e){m.asn1.x509.Extensions.superclass.constructor.call(this);var t=m,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&&o.push(new n({int:this.pathLen}));var l=new i({array:o});return this.asn1ExtnValue=l,this.asn1ExtnValue.tohex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,e!==void 0&&(e.cA!==void 0&&(this.cA=e.cA),e.pathLen!==void 0&&(this.pathLen=e.pathLen))};he(m.asn1.x509.BasicConstraints,m.asn1.x509.Extension);m.asn1.x509.CRLDistributionPoints=function(e){m.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,e);var t=m,r=t.asn1,n=r.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.setByDPArray=function(i){for(var a=[],s=0;s0&&a.push(new r({array:s}))}var l=new r({array:a});return l.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(this.params=e)};he(m.asn1.x509.PolicyInformation,m.asn1.ASN1Object);m.asn1.x509.PolicyQualifierInfo=function(e){m.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var t=m.asn1,r=t.DERSequence,n=t.DERIA5String,i=t.DERObjectIdentifier,a=t.x509.UserNotice;this.params=null,this.tohex=function(){if(this.params.cps!==void 0){var s=new r({array:[new i({oid:"1.3.6.1.5.5.7.2.1"}),new n({str:this.params.cps})]});return s.tohex()}if(this.params.unotice!=null){var s=new r({array:[new i({oid:"1.3.6.1.5.5.7.2.2"}),new a(this.params.unotice)]});return s.tohex()}},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(this.params=e)};he(m.asn1.x509.PolicyQualifierInfo,m.asn1.ASN1Object);m.asn1.x509.UserNotice=function(e){m.asn1.x509.UserNotice.superclass.constructor.call(this,e);var t=m.asn1.DERSequence,r=m.asn1.DERInteger,n=m.asn1.x509.DisplayText,i=m.asn1.x509.NoticeReference;this.params=null,this.tohex=function(){var a=[];this.params.noticeref!==void 0&&a.push(new i(this.params.noticeref)),this.params.exptext!==void 0&&a.push(new n(this.params.exptext));var s=new t({array:a});return s.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(this.params=e)};he(m.asn1.x509.UserNotice,m.asn1.ASN1Object);m.asn1.x509.NoticeReference=function(e){m.asn1.x509.NoticeReference.superclass.constructor.call(this,e);var t=m.asn1.DERSequence,r=m.asn1.DERInteger,n=m.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,o=0;o0)for(var s=0;s0;i++){var a=t.shift();if(r===!0){var s=n.pop(),o=(s+","+a).replace(/\\,/g,",");n.push(o),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("/")};m.asn1.x509.X500Name.ldapToOneline=function(e){return m.asn1.x509.X500Name.ldapToCompat(e)};m.asn1.x509.RDN=function(e){m.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var t=m.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 m.asn1.x509.AttributeTypeAndValue({str:r,rule:this.sRule}))},this.addByMultiValuedString=function(r){for(var n=m.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(),o=(s+"+"+a).replace(/\\\+/g,"+");n.push(o),r=!1}else n.push(a);a.substr(-1,1)==="\\"&&(r=!0)}for(var l=!1,h=[],i=0;n.length>0;i++){var a=n.shift();if(l===!0){var d=h.pop();if(a.match(/"$/)){var o=(d+"+"+a).replace(/^([^=]+)="(.*)"$/,"$1=$2");h.push(o),l=!1}else h.push(d+"+"+a)}else h.push(a);a.match(/^[^=]+="/)&&(l=!0)}return h};m.asn1.x509.AttributeTypeAndValue=function(e){m.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this),this.sRule="utf8",this.sType=null,this.sValue=null,this.dsType=null;var t=m,r=t.asn1,n=r.DERSequence,i=r.DERUTF8String,a=r.DERPrintableString,s=r.DERTeletexString,o=r.DERIA5String,l=r.DERVisibleString,h=r.DERBMPString,d=t.lang.String.isMail,E=t.lang.String.isPrintable;this.setByParam=function(p){if(p.rule!==void 0&&(this.sRule=p.rule),p.ds!==void 0&&(this.dsType=p.ds),p.value===void 0&&p.str!==void 0){var f=p.str,w=f.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,f){f!==void 0&&(this.sRule=f);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,f=this.sValue,w=this.sRule;return w==="prn"?p=="CN"&&d(f)?"ia5":E(f)?"prn":"utf8":w==="utf8"?p=="CN"&&d(f)?"ia5":p=="C"?"prn":"utf8":"utf8"},this.setByAttrTypeAndValueStr=function(p,f,w){w!==void 0&&(this.sRule=w),this.sType=p,this.sValue=f},this.getValueObj=function(p,f){if(p=="utf8")return new i({str:f});if(p=="prn")return new a({str:f});if(p=="tel")return new s({str:f});if(p=="ia5")return new o({str:f});if(p=="vis")return new l({str:f});if(p=="bmp")return new h({str:f});throw new Error("unsupported directory string type: type="+p+" value="+f)},this.tohex=function(){this.dsType==null&&(this.dsType=this._getDsType());var p=m.asn1.x509.OID.atype2obj(this.sType),f=this.getValueObj(this.dsType,this.sValue),w=new n({array:[p,f]});return this.TLV=w.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};he(m.asn1.x509.AttributeTypeAndValue,m.asn1.ASN1Object);m.asn1.x509.SubjectPublicKeyInfo=function(e){m.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var t=null,r=null,n=m,i=n.asn1,a=i.DERInteger,s=i.DERBitString,o=i.DERObjectIdentifier,l=i.DERSequence,h=i.ASN1Util.newObject,d=i.x509,E=d.AlgorithmIdentifier,p=n.crypto,f=p.ECDSA,w=p.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null)throw"algId and/or subjPubKey not set";var g=new l({array:[this.asn1AlgId,this.asn1SubjPKey]});return g},this.tohex=function(){var g=this.getASN1Object();return this.hTLV=g.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},this.setPubKey=function(g){try{if(g instanceof ze){var y=h({seq:[{int:{bigint:g.n}},{int:{int:g.e}}]}),A=y.tohex();this.asn1AlgId=new E({name:"rsaEncryption"}),this.asn1SubjPKey=new s({hex:"00"+A})}}catch{}try{if(g instanceof m.crypto.ECDSA){var S=new o({name:g.curveName});this.asn1AlgId=new E({name:"ecPublicKey",asn1params:S}),this.asn1SubjPKey=new s({hex:"00"+g.pubKeyHex})}}catch{}try{if(g instanceof m.crypto.DSA){var S=new h({seq:[{int:{bigint:g.p}},{int:{bigint:g.q}},{int:{bigint:g.g}}]});this.asn1AlgId=new E({name:"dsa",asn1params:S});var _=new a({bigint:g.y});this.asn1SubjPKey=new s({hex:"00"+_.tohex()})}}catch{}},e!==void 0&&this.setPubKey(e)};he(m.asn1.x509.SubjectPublicKeyInfo,m.asn1.ASN1Object);m.asn1.x509.Time=function(e){m.asn1.x509.Time.superclass.constructor.call(this);var t=null,r=null,n=m,i=n.asn1,a=i.DERUTCTime,s=i.DERGeneralizedTime;this.params=null,this.type=null,this.setTimeParams=function(o){this.timeParams=o},this.setByParam=function(o){this.params=o},this.getType=function(o){return o.match(/^[0-9]{12}Z$/)?"utc":o.match(/^[0-9]{14}Z$/)?"gen":o.match(/^[0-9]{12}\.[0-9]+Z$/)?"utc":o.match(/^[0-9]{14}\.[0-9]+Z$/)?"gen":null},this.tohex=function(){var o=this.params,l=null;if(typeof o=="string"&&(o={str:o}),o!=null&&o.str&&(o.type==null||o.type==null)&&(o.type=this.getType(o.str)),o!=null&&o.str?(o.type=="utc"&&(l=new a(o.str)),o.type=="gen"&&(l=new s(o.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)};m.asn1.x509.Time_bak=function(e){m.asn1.x509.Time_bak.superclass.constructor.call(this);var t=null,r=null,n=m,i=n.asn1,a=i.DERUTCTime,s=i.DERGeneralizedTime;this.setTimeParams=function(o){this.timeParams=o},this.tohex=function(){var o=null;return this.timeParams!=null?this.type=="utc"?o=new a(this.timeParams):o=new s(this.timeParams):this.type=="utc"?o=new a:o=new s,this.TLV=o.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},this.type="utc",e!==void 0&&(e.type!==void 0?this.type=e.type:e.str!==void 0&&(e.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),e.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=e)};he(m.asn1.x509.Time,m.asn1.ASN1Object);m.asn1.x509.AlgorithmIdentifier=function(e){m.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var t=m,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 o=[this.asn1Alg];this.asn1Params!==null&&o.push(this.asn1Params);var l=new r.DERSequence({array:o});return this.hTLV=l.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(e.name!==void 0&&(this.nameAlg=e.name),e.asn1params!==void 0&&(this.asn1Params=e.asn1params),e.paramempty!==void 0&&(this.paramEmpty=e.paramempty)),this.asn1Params===null&&this.paramEmpty===!1&&this.nameAlg!==null){this.nameAlg.name!==void 0&&(this.nameAlg=this.nameAlg.name);var i=this.nameAlg.toLowerCase();i.substr(-7,7)!=="withdsa"&&i.substr(-9,9)!=="withecdsa"&&(this.asn1Params=new r.DERNull)}};he(m.asn1.x509.AlgorithmIdentifier,m.asn1.ASN1Object);m.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"};m.asn1.x509.GeneralName=function(e){m.asn1.x509.GeneralName.superclass.constructor.call(this);var t={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87",otherName:"a0"},r=m,n=r.asn1,i=n.x509,a=i.X500Name,s=i.OtherName,o=n.DERIA5String,l=n.DERPrintableString,h=n.DEROctetString,d=n.DERTaggedObject,E=n.ASN1Object,p=Error;this.params=null,this.setByParam=function(f){this.params=f},this.tohex=function(){var f=this.params,w,y,g,y=!1;if(f.other!==void 0)w="a0",g=new s(f.other);else if(f.rfc822!==void 0)w="81",g=new o({str:f.rfc822});else if(f.dns!==void 0)w="82",g=new o({str:f.dns});else if(f.dn!==void 0)w="a4",y=!0,typeof f.dn=="string"?g=new a({str:f.dn}):f.dn instanceof m.asn1.x509.X500Name?g=f.dn:g=new a(f.dn);else if(f.ldapdn!==void 0)w="a4",y=!0,g=new a({ldapstr:f.ldapdn});else if(f.certissuer!==void 0||f.certsubj!==void 0){w="a4",y=!0;var A,S,_=null;if(f.certsubj!==void 0?(A=!1,S=f.certsubj):(A=!0,S=f.certissuer),S.match(/^[0-9A-Fa-f]+$/)&&_==S,S.indexOf("-----BEGIN ")!=-1&&(_=kt(S)),_==null)throw new Error("certsubj/certissuer not cert");var I=new He;I.hex=_;var D;A?D=I.getIssuerHex():D=I.getSubjectHex(),g=new E,g.hTLV=D}else if(f.uri!==void 0)w="86",g=new o({str:f.uri});else if(f.ip!==void 0){w="87";var H,V=f.ip;try{if(V.match(/^[0-9a-f]+$/)){var F=V.length;if(F==8||F==16||F==32||F==64)H=V;else throw"err"}else H=Ed(V)}catch(k){throw new p("malformed IP address: "+f.ip+":"+k.message)}g=new h({hex:H})}else throw new p("improper params");var P=new d({tag:w,explicit:y,obj:g});return P.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};he(m.asn1.x509.GeneralName,m.asn1.ASN1Object);m.asn1.x509.GeneralNames=function(e){m.asn1.x509.GeneralNames.superclass.constructor.call(this);var t=null,r=m,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}}};m.asn1.x509.OID.oid2name=function(e){var t=m.asn1.x509.OID.name2oidList;for(var r in t)if(t[r]==e)return r;return""};m.asn1.x509.OID.oid2atype=function(e){var t=m.asn1.x509.OID.atype2oidList;for(var r in t)if(t[r]==e)return r;return e};m.asn1.x509.OID.name2oid=function(e){if(e.match(/^[0-9.]+$/))return e;var t=m.asn1.x509.OID.name2oidList;return t[e]===void 0?"":t[e]};m.asn1.x509.X509Util={};m.asn1.x509.X509Util.newCertPEM=function(e){var t=m.asn1.x509,r=t.TBSCertificate,n=t.Certificate,i=new n(e);return i.getPEM()};(typeof m>"u"||!m)&&(m={});(typeof m.asn1>"u"||!m.asn1)&&(m.asn1={});(typeof m.asn1.cms>"u"||!m.asn1.cms)&&(m.asn1.cms={});m.asn1.cms.Attribute=function(e){var t=Error,r=m,n=r.asn1,i=n.DERSequence,a=n.DERSet,s=n.DERObjectIdentifier;this.params=null,this.typeOid=null,this.setByParam=function(o){this.params=o},this.getValueArray=function(){throw new t("not yet implemented abstract")},this.tohex=function(){var o=new s({oid:this.typeOid}),l=new a({array:this.getValueArray()}),h=new i({array:[o,l]});return h.tohex()},this.getEncodedHex=function(){return this.tohex()}};he(m.asn1.cms.Attribute,m.asn1.ASN1Object);m.asn1.cms.ContentType=function(e){var t=m,r=t.asn1;r.cms.ContentType.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.3",this.getValueArray=function(){var n=new r.DERObjectIdentifier(this.params.type);return[n]},e!=null&&this.setByParam(e)};he(m.asn1.cms.ContentType,m.asn1.cms.Attribute);m.asn1.cms.MessageDigest=function(e){var t=m,r=t.asn1,n=r.DEROctetString,i=r.cms;i.MessageDigest.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.4",this.getValueArray=function(){var a=new n(this.params);return[a]},e!=null&&this.setByParam(e)};he(m.asn1.cms.MessageDigest,m.asn1.cms.Attribute);m.asn1.cms.SigningTime=function(e){var t=m,r=t.asn1;r.cms.SigningTime.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.5",this.getValueArray=function(){var n=new r.x509.Time(this.params);return[n]},e!=null&&this.setByParam(e)};he(m.asn1.cms.SigningTime,m.asn1.cms.Attribute);m.asn1.cms.SigningCertificate=function(e){var t=Error,r=m,n=r.asn1,i=n.DERSequence,a=n.cms,s=a.ESSCertID,o=r.crypto;a.SigningCertificate.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.12",this.getValueArray=function(){if(this.params==null||this.params==null||this.params.array==null)throw new t("parameter 'array' not specified");for(var l=this.params.array,h=[],d=0;d0){for(var w=a(p.valhex,f[0]),g=E(w,0),y=[],A=0;A1){var I=a(p.valhex,f[1]);p.polhex=I}delete p.valhex},this.setSignaturePolicyIdentifier=function(p){var f=E(p.valhex,0);if(f.length>0){var w=n.getOID(p.valhex,f[0]);p.oid=w}if(f.length>1){var g=new t,y=E(p.valhex,f[1]),A=a(p.valhex,y[0]),S=g.getAlgorithmIdentifierName(A);p.alg=S;var _=i(p.valhex,y[1]);p.hash=_}delete p.valhex},this.setSigningCertificateV2=function(p){var f=E(p.valhex,0);if(f.length>0){for(var w=a(p.valhex,f[0]),g=E(w,0),y=[],A=0;A1){var I=a(p.valhex,f[1]);p.polhex=I}delete p.valhex},this.getESSCertID=function(p){var f={},w=E(p,0);if(w.length>0){var g=i(p,w[0]);f.hash=g}if(w.length>1){var y=a(p,w[1]),A=this.getIssuerSerial(y);A.serial!=null&&(f.serial=A.serial),A.issuer!=null&&(f.issuer=A.issuer)}return f},this.getESSCertIDv2=function(p){var f={},w=E(p,0);if(w.length<1||3g+1){var S=a(p,w[g+1]),_=this.getIssuerSerial(S);f.issuer=_.issuer,f.serial=_.serial}return f},this.getIssuerSerial=function(p){var f={},w=E(p,0),g=a(p,w[0]),y=r.getGeneralNames(g),A=y[0].dn;f.issuer=A;var S=i(p,w[1]);return f.serial={hex:S},f},this.getCertificateSet=function(p){for(var f=E(p,0),w=[],g=0;g"u"||!m)&&(m={});(typeof m.asn1>"u"||!m.asn1)&&(m.asn1={});(typeof m.asn1.tsp>"u"||!m.asn1.tsp)&&(m.asn1.tsp={});m.asn1.tsp.TimeStampToken=function(e){var t=m,r=t.asn1,n=r.tsp;n.TimeStampToken.superclass.constructor.call(this),this.params=null,this.getEncodedHexPrepare=function(){var i=new n.TSTInfo(this.params.econtent.content);this.params.econtent.content.hex=i.tohex()},e!=null&&this.setByParam(e)};he(m.asn1.tsp.TimeStampToken,m.asn1.cms.SignedData);m.asn1.tsp.TSTInfo=function(e){var t=Error,r=m,n=r.asn1,i=n.DERSequence,a=n.DERInteger,s=n.DERBoolean,o=n.DERGeneralizedTime,l=n.DERObjectIdentifier,h=n.DERTaggedObject,d=n.tsp,E=d.MessageImprint,p=d.Accuracy,f=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 g=[this.dVersion];if(this.dPolicy==null)throw new Error("policy shall be specified.");if(g.push(this.dPolicy),this.dMessageImprint==null)throw new Error("messageImprint shall be specified.");if(g.push(this.dMessageImprint),this.dSerial==null)throw new Error("serialNumber shall be specified.");if(g.push(this.dSerial),this.dGenTime==null)throw new Error("genTime shall be specified.");g.push(this.dGenTime),this.dAccuracy!=null&&g.push(this.dAccuracy),this.dOrdering!=null&&g.push(this.dOrdering),this.dNonce!=null&&g.push(this.dNonce),this.dTsa!=null&&g.push(this.dTsa);var y=new i({array:g});return this.hTLV=y.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},e!==void 0){if(typeof e.policy=="string"){if(!e.policy.match(/^[0-9.]+$/))throw"policy shall be oid like 0.1.4.134";this.dPolicy=new l({oid:e.policy})}e.messageImprint!==void 0&&(this.dMessageImprint=new E(e.messageImprint)),e.serial!==void 0&&(this.dSerial=new a(e.serial)),e.genTime!==void 0&&(this.dGenTime=new o(e.genTime)),e.accuracy!==void 0&&(this.dAccuracy=new p(e.accuracy)),e.ordering!==void 0&&e.ordering==!0&&(this.dOrdering=new s),e.nonce!==void 0&&(this.dNonce=new a(e.nonce)),e.tsa!==void 0&&(this.dTsa=new h({tag:"a0",explicit:!0,obj:new w({dn:e.tsa})}))}};he(m.asn1.tsp.TSTInfo,m.asn1.ASN1Object);m.asn1.tsp.Accuracy=function(e){var t=m,r=t.asn1,n=r.ASN1Util.newObject;r.tsp.Accuracy.superclass.constructor.call(this),this.params=null,this.tohex=function(){var i=this.params,a=[];return i.seconds!=null&&typeof i.seconds=="number"&&a.push({int:i.seconds}),i.millis!=null&&typeof i.millis=="number"&&a.push({tag:{tagi:"80",obj:{int:i.millis}}}),i.micros!=null&&typeof i.micros=="number"&&a.push({tag:{tagi:"81",obj:{int:i.micros}}}),n({seq:a}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};he(m.asn1.tsp.Accuracy,m.asn1.ASN1Object);m.asn1.tsp.MessageImprint=function(e){var t=m,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 o=this.params,l=new s({name:o.alg}),h=new i({hex:o.hash}),d=new n({array:[l,h]});return d.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};he(m.asn1.tsp.MessageImprint,m.asn1.ASN1Object);m.asn1.tsp.TimeStampReq=function(e){var t=m,r=t.asn1,n=r.DERSequence,i=r.DERInteger,a=r.DERBoolean,s=r.ASN1Object,o=r.DERObjectIdentifier,l=r.tsp,h=l.MessageImprint;l.TimeStampReq.superclass.constructor.call(this),this.params=null,this.tohex=function(){var d=this.params,E=[];E.push(new i({int:1})),d.messageImprint instanceof m.asn1.ASN1Object?E.push(d.messageImprint):E.push(new h(d.messageImprint)),d.policy!=null&&E.push(new o(d.policy)),d.nonce!=null&&E.push(new i(d.nonce)),d.certreq==!0&&E.push(new a);var p=new n({array:E});return p.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};he(m.asn1.tsp.TimeStampReq,m.asn1.ASN1Object);m.asn1.tsp.TimeStampResp=function(e){var t=m,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 o=this.params,l=[];if(o.econtent!=null||o.tst!=null)if(o.statusinfo!=null?l.push(new s(o.statusinfo)):l.push(new s("granted")),o.econtent!=null)l.push(new a.TimeStampToken(o).getContentInfo());else if(o.tst instanceof r.ASN1Object)l.push(o.tst);else throw new Error("improper member tst value");else if(o.statusinfo!=null)l.push(new s(o.statusinfo));else throw new Error("parameter for token nor statusinfo not specified");var h=new n({array:l});return h.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};he(m.asn1.tsp.TimeStampResp,m.asn1.ASN1Object);m.asn1.tsp.PKIStatusInfo=function(e){var t=Error,r=m,n=r.asn1,i=n.DERSequence,a=n.tsp,s=a.PKIStatus,o=a.PKIFreeText,l=a.PKIFailureInfo;a.PKIStatusInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var h=this.params,d=[];if(typeof h=="string")d.push(new s(h));else{if(h.status==null)throw new t("property 'status' unspecified");d.push(new s(h.status)),h.statusstr!=null&&d.push(new o(h.statusstr)),h.failinfo!=null&&d.push(new l(h.failinfo))}var E=new i({array:d});return E.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};he(m.asn1.tsp.PKIStatusInfo,m.asn1.ASN1Object);m.asn1.tsp.PKIStatus=function(e){var t=Error,r=m,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 o=this.params,l,h;if(typeof o=="string")try{h=s[o]}catch{throw new t("undefined name: "+o)}else if(typeof o=="number")h=o;else throw new t("unsupported params");return new i({int:h}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};he(m.asn1.tsp.PKIStatus,m.asn1.ASN1Object);m.asn1.tsp.PKIFreeText=function(e){var t=Error,r=m,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 o=this.params;if(!o instanceof Array)throw new t("wrong params: not array");for(var l=[],h=0;h=0;p--)E+=d[p];return E}else{if(typeof l=="string"&&o[l]!=null)return lf([l],o);if(typeof l=="object"&&l.length!=null)return lf(l,o);throw new t("wrong params")}},this.tohex=function(){var l=this.params,h=this.getBinValue();return new i({bin:h}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};he(m.asn1.tsp.PKIFailureInfo,m.asn1.ASN1Object);m.asn1.tsp.AbstractTSAAdapter=function(e){this.getTSTHex=function(t,r){throw"not implemented yet"}};m.asn1.tsp.SimpleTSAAdapter=function(e){var t=m,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 o=i(a,s);this.params.econtent.content.messageImprint={alg:s,hash:o},this.params.econtent.content.serial={int:this.serial++};var l=Math.floor(Math.random()*1e9);this.params.econtent.content.nonce={int:l};var h=new n.TimeStampToken(this.params);return h.getContentInfoEncodedHex()},e!==void 0&&(this.params=e)};he(m.asn1.tsp.SimpleTSAAdapter,m.asn1.tsp.AbstractTSAAdapter);m.asn1.tsp.FixedTSAAdapter=function(e){var t=m,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 o=i(a,s);this.params.econtent.content.messageImprint={alg:s,hash:o};var l=new n.TimeStampToken(this.params);return l.getContentInfoEncodedHex()},e!==void 0&&(this.params=e)};he(m.asn1.tsp.FixedTSAAdapter,m.asn1.tsp.AbstractTSAAdapter);m.asn1.tsp.TSPUtil=new function(){};m.asn1.tsp.TSPUtil.newTimeStampToken=function(e){return new m.asn1.tsp.TimeStampToken(e)};m.asn1.tsp.TSPUtil.parseTimeStampReq=function(e){var t=new m.asn1.tsp.TSPParser;return t.getTimeStampReq(e)};m.asn1.tsp.TSPUtil.parseMessageImprint=function(e){var t=new m.asn1.tsp.TSPParser;return t.getMessageImprint(e)};m.asn1.tsp.TSPParser=function(){var e=Error,t=He,r=new t,n=Ae,i=n.getV,a=n.getTLV,s=n.getIdxbyList,o=n.getTLVbyListEx,l=n.getChildIdx,h=["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(E){var p=l(E,0);if(p.length==1)return this.getPKIStatusInfo(a(E,p[0]));if(p.length>1){var f=this.getPKIStatusInfo(a(E,p[0])),w=a(E,p[1]),g=this.getToken(w);return g.statusinfo=f,g}},this.getToken=function(E){var p=new m.asn1.cms.CMSParser,f=p.getCMSSignedData(E);return this.setTSTInfo(f),f},this.setTSTInfo=function(E){var p=E.econtent;if(p.type=="tstinfo"){var f=p.content.hex,w=this.getTSTInfo(f);p.content=w}},this.getTSTInfo=function(E){var p={},f=l(E,0),w=i(E,f[1]);p.policy=Af(w);var g=a(E,f[2]);p.messageImprint=this.getMessageImprint(g);var y=i(E,f[3]);p.serial={hex:y};var A=i(E,f[4]);p.genTime={str:yt(A)};var S=0;if(f.length>5&&E.substr(f[5],2)=="30"){var _=a(E,f[5]);p.accuracy=this.getAccuracy(_),S++}if(f.length>5+S&&E.substr(f[5+S],2)=="01"){var I=i(E,f[5+S]);I=="ff"&&(p.ordering=!0),S++}if(f.length>5+S&&E.substr(f[5+S],2)=="02"){var D=i(E,f[5+S]);p.nonce={hex:D},S++}if(f.length>5+S&&E.substr(f[5+S],2)=="a0"){var H=a(E,f[5+S]);H="30"+H.substr(2),pGeneralNames=r.getGeneralNames(H);var V=pGeneralNames[0].dn;p.tsa=V,S++}if(f.length>5+S&&E.substr(f[5+S],2)=="a1"){var F=a(E,f[5+S]);F="30"+F.substr(2);var P=r.getExtParamArray(F);p.ext=P,S++}return p},this.getAccuracy=function(E){for(var p={},f=l(E,0),w=0;w1&&E.substr(f[1],2)=="30"){var A=a(E,f[1]);p.statusstr=this.getPKIFreeText(A),w++}if(f.length>w&&E.substr(f[1+w],2)=="03"){var S=a(E,f[1+w]);p.failinfo=this.getPKIFailureInfo(S)}return p},this.getPKIFreeText=function(E){for(var p=[],f=l(E,0),w=0;w"u"||!m)&&(m={});(typeof m.asn1>"u"||!m.asn1)&&(m.asn1={});(typeof m.asn1.cades>"u"||!m.asn1.cades)&&(m.asn1.cades={});m.asn1.cades.SignaturePolicyIdentifier=function(e){var t=m,r=t.asn1,n=r.cades,i=n.SignaturePolicyId;n.SignaturePolicyIdentifier.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.15",this.params=null,this.getValueArray=function(){return[new i(this.params)]},this.setByParam=function(a){this.params=a},e!=null&&this.setByParam(e)};he(m.asn1.cades.SignaturePolicyIdentifier,m.asn1.cms.Attribute);m.asn1.cades.SignaturePolicyId=function(e){var t=m,r=t.asn1,n=r.DERSequence,i=r.DERObjectIdentifier,a=r.x509,s=a.AlgorithmIdentifier,o=r.cades,l=o.SignaturePolicyId,h=o.OtherHashAlgAndValue;l.superclass.constructor.call(this),this.params=null,this.tohex=function(){var d=this.params,E=[];E.push(new i(d.oid)),E.push(new h(d));var p=new n({array:E});return p.tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(d){this.params=d},e!=null&&this.setByParam(e)};he(m.asn1.cades.SignaturePolicyId,m.asn1.ASN1Object);m.asn1.cades.OtherHashAlgAndValue=function(e){var t=Error,r=m,n=r.asn1,i=n.DERSequence,a=n.DEROctetString,s=n.x509,o=s.AlgorithmIdentifier,l=n.cades,h=l.OtherHashAlgAndValue;h.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 E=null;if(d.hash!=null)E=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=kt(d.cert)),E=m.crypto.Util.hashHex(p,d.alg)}var f=[];f.push(new o({name:d.alg})),f.push(new a({hex:E}));var w=new i({array:f});return w.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};he(m.asn1.cades.OtherHashAlgAndValue,m.asn1.ASN1Object);m.asn1.cades.OtherHashValue=function(e){m.asn1.cades.OtherHashValue.superclass.constructor.call(this);var t=Error,r=m,n=r.lang.String.isHex,i=r.asn1,a=i.DEROctetString,s=r.crypto.Util.hashHex;this.params=null,this.tohex=function(){var o=this.params;if(o.hash==null&&o.cert==null)throw new t("hash or cert not specified");var l=null;if(o.hash!=null)l=o.hash;else if(o.cert!=null){if(typeof o.cert!="string")throw new t("cert not string");var h=o.cert;o.cert.indexOf("-----BEGIN")!=-1&&(h=kt(o.cert)),l=m.crypto.Util.hashHex(h,"sha1")}return new a({hex:l}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};he(m.asn1.cades.OtherHashValue,m.asn1.ASN1Object);m.asn1.cades.SignatureTimeStamp=function(e){var t=Error,r=m,n=r.lang.String.isHex,i=r.asn1,a=i.ASN1Object,s=i.x509,o=i.cades;o.SignatureTimeStamp.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.14",this.params=null,this.getValueArray=function(){var l=this.params;if(l.tst!=null)if(n(l.tst)){var h=new a;return h.hTLV=l.tst,[h]}else{if(l.tst instanceof a)return[l.tst];throw new t("params.tst has wrong value")}else if(l.res!=null){var d=l.res;if(d instanceof a&&(d=d.tohex()),typeof d!="string"||!n(d))throw new t("params.res has wrong value");var E=Ae.getTLVbyList(d,0,[1]),h=new a;return h.hTLV=l.tst,[h]}},e!=null&&this.setByParam(e)};he(m.asn1.cades.SignatureTimeStamp,m.asn1.cms.Attribute);m.asn1.cades.CompleteCertificateRefs=function(e){var t=Error,r=m,n=r.asn1,i=n.DERSequence,a=n.cades,s=a.OtherCertID,o=r.lang.String.isHex;a.CompleteCertificateRefs.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.21",this.params=null,this.getValueArray=function(){for(var l=this.params,h=[],d=0;d"u"||!m.asn1.csr)&&(m.asn1.csr={});m.asn1.csr.CertificationRequest=function(e){var t=m,r=t.asn1,n=r.DERBitString,i=r.DERSequence,a=r.csr,s=r.x509,o=a.CertificationRequestInfo;a.CertificationRequest.superclass.constructor.call(this),this.setByParam=function(l){this.params=l},this.sign=function(){var l=new o(this.params).tohex(),h=new m.crypto.Signature({alg:this.params.sigalg});h.init(this.params.sbjprvkey),h.updateHex(l);var d=h.sign();this.params.sighex=d},this.getPEM=function(){return Or(this.tohex(),"CERTIFICATE REQUEST")},this.tohex=function(){var l=this.params,h=new m.asn1.csr.CertificationRequestInfo(this.params),d=new m.asn1.x509.AlgorithmIdentifier({name:l.sigalg});if(l.sighex==null&&l.sbjprvkey!=null&&this.sign(),l.sighex==null)throw new Error("sighex or sbjprvkey parameter not defined");var E=new n({hex:"00"+l.sighex}),p=new i({array:[h,d,E]});return p.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};he(m.asn1.csr.CertificationRequest,m.asn1.ASN1Object);m.asn1.csr.CertificationRequestInfo=function(e){var t=m,r=t.asn1,n=r.DERBitString,i=r.DERSequence,a=r.DERInteger,s=r.DERUTF8String,o=r.DERTaggedObject,l=r.ASN1Util.newObject,h=r.csr,d=r.x509,E=d.X500Name,p=d.Extensions,f=d.SubjectPublicKeyInfo,w=h.AttributeList;h.CertificationRequestInfo.superclass.constructor.call(this),this.params=null,this.setByParam=function(y){y!=null&&(this.params=y)},this.tohex=function(){var y=this.params,A=[];if(A.push(new a({int:0})),A.push(new E(y.subject)),A.push(new f(at.getKey(y.sbjpubkey))),y.attrs!=null){var S=g(y.attrs),_=l({tag:{tage:"a0",obj:S}});A.push(_)}else if(y.extreq!=null){var I=new p(y.extreq),_=l({tag:{tage:"a0",obj:{seq:[{oid:"1.2.840.113549.1.9.14"},{set:[I]}]}}});A.push(_)}else A.push(new o({tag:"a0",explicit:!1,obj:new s({str:""})}));var D=new i({array:A});return D.tohex()},this.getEncodedHex=function(){return this.tohex()};function g(y){for(var A=Error,S=m.asn1.x509.Extensions,_=[],I=0;I"u"||!m)&&(m={});(typeof m.asn1>"u"||!m.asn1)&&(m.asn1={});(typeof m.asn1.ocsp>"u"||!m.asn1.ocsp)&&(m.asn1.ocsp={});m.asn1.ocsp.DEFAULT_HASH="sha1";m.asn1.ocsp.OCSPResponse=function(e){m.asn1.ocsp.OCSPResponse.superclass.constructor.call(this);var t=m.asn1.DEREnumerated,r=m.asn1.ASN1Util.newObject,n=m.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 o=new n(a);return r({seq:[{enum:{int:0}},{tag:{tag:"a0",explicit:!0,obj:o}}]}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};he(m.asn1.ocsp.OCSPResponse,m.asn1.ASN1Object);m.asn1.ocsp.ResponseBytes=function(e){m.asn1.ocsp.ResponseBytes.superclass.constructor.call(this);var t=m.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 o=new a(s),l=[];l.push(new n({name:"ocspBasic"})),l.push(new i({hex:o.tohex()}));var h=new r({array:l});return h.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};he(m.asn1.ocsp.ResponseBytes,m.asn1.ASN1Object);m.asn1.ocsp.BasicOCSPResponse=function(e){m.asn1.ocsp.BasicOCSPResponse.superclass.constructor.call(this);var t=Error,r=m.asn1,n=r.ASN1Object,i=r.DERSequence,a=r.DERGeneralizedTime,s=r.DERTaggedObject,o=r.DERBitString,l=r.x509.Extensions,h=r.x509.AlgorithmIdentifier,d=r.ocsp,E=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,f=p.tbsresp.tohex(),w=new m.crypto.Signature({alg:p.sigalg});w.init(p.reskey),w.updateHex(f),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 f=[];if(f.push(p.tbsresp),f.push(new h({name:p.sigalg})),f.push(new o({hex:"00"+p.sighex})),p.certs!=null&&p.certs.length!=null){for(var w=[],g=0;g"u"||!m)&&(m={});(typeof m.lang>"u"||!m.lang)&&(m.lang={});m.lang.String=function(){};function Mm(e){for(var t=new Array,r=0;r>6,l=128|s&63;return yt(o.toString(16)+l.toString(16))}var o=224|(a&240)>>4,l=128|(a&15)<<2|(s&192)>>6,h=128|s&63;return yt(o.toString(16)+l.toString(16)+h.toString(16))}var r=e.match(/.{4}/g),n=r.map(t);return n.join("")}function Ef(e){for(var t=encodeURIComponent(e),r="",n=0;n"7"?"00"+e:e}function $8(e){e=e.replace(/^\s*\[\s*/,""),e=e.replace(/\s*\]\s*$/,""),e=e.replace(/\s*/g,"");try{var t=e.split(/,/).map(function(r,n,i){var a=parseInt(r);if(a<0||255t.length&&(r=t.length);for(var n=0;n0&&(h=h+"."+o.join(".")),h}catch{return null}}function Wm(e){var t=new ee(String(e),10);return Cc(t)}function Cc(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 Xm(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 Jm(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+cf("",r,"0");var n=parseInt(t,2).toString(16);n.length%2==1&&(n="0"+n);var i="0"+r;return i+n}function Zm(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 _t(e,n,r){if(typeof e=="object"){for(var n=String(n).split("."),i=0;i"u"||!m)&&(m={});(typeof m.crypto>"u"||!m.crypto)&&(m.crypto={});m.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:Ce.algo.MD5,sha1:Ce.algo.SHA1,sha224:Ce.algo.SHA224,sha256:Ce.algo.SHA256,sha384:Ce.algo.SHA384,sha512:Ce.algo.SHA512,ripemd160:Ce.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,o="",l=i-a.length-s.length,h=0;h"u"||!m)&&(m={});(typeof m.crypto>"u"||!m.crypto)&&(m.crypto={});m.crypto.ECDSA=function(e){var t="secp256r1",r=null,n=null,i=null,a=Error,s=ee,o=dt,l=m.crypto.ECDSA,h=m.crypto.ECParameterDB,d=l.getName,E=Ae,p=E.getVbyListEx,f=E.isASN1HEX,w=new to,g=null;this.type="EC",this.isPrivate=!1,this.isPublic=!1;function y(A,S,_,I){for(var D=Math.max(S.bitLength(),I.bitLength()),H=A.add2D(_),V=A.curve.getInfinity(),F=D-1;F>=0;--F)V=V.twice2D(),V.z=s.ONE,S.testBit(F)?I.testBit(F)?V=V.add2D(H):V=V.add2D(A):I.testBit(F)&&(V=V.add2D(_));return V}this.getBigRandom=function(A){return new s(A.bitLength(),w).mod(A.subtract(s.ONE)).add(s.ONE)},this.setNamedCurve=function(A){this.ecparams=h.getByName(A),this.prvKeyHex=null,this.pubKeyHex=null,this.curveName=A},this.setPrivateKeyHex=function(A){this.isPrivate=!0,this.prvKeyHex=A},this.setPublicKeyHex=function(A){this.isPublic=!0,this.pubKeyHex=A},this.getPublicKeyXYHex=function(){var A=this.pubKeyHex;if(A.substr(0,2)!=="04")throw"this method supports uncompressed format(04) only";var S=this.ecparams.keycharlen;if(A.length!==2+S*2)throw"malformed public key hex length";var _={};return _.x=A.substr(2,S),_.y=A.substr(2+S),_},this.getShortNISTPCurveName=function(){var A=this.curveName;return A==="secp256r1"||A==="NIST P-256"||A==="P-256"||A==="prime256v1"?"P-256":A==="secp384r1"||A==="NIST P-384"||A==="P-384"?"P-384":A==="secp521r1"||A==="NIST P-521"||A==="P-521"?"P-521":null},this.generateKeyPairHex=function(){var A=this.ecparams.n,S=this.getBigRandom(A),_=this.ecparams.keycharlen,I=("0000000000"+S.toString(16)).slice(-_);this.setPrivateKeyHex(I);var D=this.generatePublicKeyHex();return{ecprvhex:I,ecpubhex:D}},this.generatePublicKeyHex=function(){var A=new s(this.prvKeyHex,16),S=this.ecparams.G.multiply(A),_=S.getX().toBigInteger(),I=S.getY().toBigInteger(),D=this.ecparams.keycharlen,H=("0000000000"+_.toString(16)).slice(-D),V=("0000000000"+I.toString(16)).slice(-D),F="04"+H+V;return this.setPublicKeyHex(F),F},this.signWithMessageHash=function(A){return this.signHex(A,this.prvKeyHex)},this.signHex=function(A,S){var _=new s(S,16),I=this.ecparams.n,D=new s(A.substring(0,this.ecparams.keycharlen),16);do var H=this.getBigRandom(I),V=this.ecparams.G,F=V.multiply(H),P=F.getX().toBigInteger().mod(I);while(P.compareTo(s.ZERO)<=0);var k=H.modInverse(I).multiply(D.add(_.multiply(P))).mod(I);return l.biRSSigToASN1Sig(P,k)},this.sign=function(A,S){var _=S,I=this.ecparams.n,D=s.fromByteArrayUnsigned(A);do var H=this.getBigRandom(I),V=this.ecparams.G,F=V.multiply(H),P=F.getX().toBigInteger().mod(I);while(P.compareTo(ee.ZERO)<=0);var k=H.modInverse(I).multiply(D.add(_.multiply(P))).mod(I);return this.serializeSig(P,k)},this.verifyWithMessageHash=function(A,S){return this.verifyHex(A,S,this.pubKeyHex)},this.verifyHex=function(A,S,_){try{var I,D,H=l.parseSigHex(S);I=H.r,D=H.s;var V=o.decodeFromHex(this.ecparams.curve,_),F=new s(A.substring(0,this.ecparams.keycharlen),16);return this.verifyRaw(F,I,D,V)}catch{return!1}},this.verify=function(A,S,_){var I,D;if(Bitcoin.Util.isArray(S)){var H=this.parseSig(S);I=H.r,D=H.s}else if(typeof S=="object"&&S.r&&S.s)I=S.r,D=S.s;else throw"Invalid value for signature";var V;if(_ instanceof dt)V=_;else if(Bitcoin.Util.isArray(_))V=o.decodeFrom(this.ecparams.curve,_);else throw"Invalid format for pubkey value, must be byte array or ECPointFp";var F=s.fromByteArrayUnsigned(A);return this.verifyRaw(F,I,D,V)},this.verifyRaw=function(A,S,_,I){var D=this.ecparams.n,H=this.ecparams.G;if(S.compareTo(s.ONE)<0||S.compareTo(D)>=0||_.compareTo(s.ONE)<0||_.compareTo(D)>=0)return!1;var V=_.modInverse(D),F=A.multiply(V).mod(D),P=S.multiply(V).mod(D),k=H.multiply(F).add(I.multiply(P)),L=k.getX().toBigInteger().mod(D);return L.equals(S)},this.serializeSig=function(A,S){var _=A.toByteArraySigned(),I=S.toByteArraySigned(),D=[];return D.push(2),D.push(_.length),D=D.concat(_),D.push(2),D.push(I.length),D=D.concat(I),D.unshift(D.length),D.unshift(48),D},this.parseSig=function(A){var S;if(A[0]!=48)throw new Error("Signature not a valid DERSequence");if(S=2,A[S]!=2)throw new Error("First element in signature must be a DERInteger");var _=A.slice(S+2,S+2+A[S+1]);if(S+=2+A[S+1],A[S]!=2)throw new Error("Second element in signature must be a DERInteger");var I=A.slice(S+2,S+2+A[S+1]);S+=2+A[S+1];var D=s.fromByteArrayUnsigned(_),H=s.fromByteArrayUnsigned(I);return{r:D,s:H}},this.parseSigCompact=function(A){if(A.length!==65)throw"Signature has the wrong length";var S=A[0]-27;if(S<0||S>7)throw"Invalid signature type";var _=this.ecparams.n,I=s.fromByteArrayUnsigned(A.slice(1,33)).mod(_),D=s.fromByteArrayUnsigned(A.slice(33,65)).mod(_);return{r:I,s:D,i:S}},this.readPKCS5PrvKeyHex=function(A){if(f(A)===!1)throw new Error("not ASN.1 hex string");var S,_,I;try{S=p(A,0,["[0]",0],"06"),_=p(A,0,[1],"04");try{I=p(A,0,["[1]",0],"03")}catch{}}catch{throw new Error("malformed PKCS#1/5 plain ECC private key")}if(this.curveName=d(S),this.curveName===void 0)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(I),this.setPrivateKeyHex(_),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(A){if(f(A)===!1)throw new a("not ASN.1 hex string");var S,_,I,D;try{S=p(A,0,[1,0],"06"),_=p(A,0,[1,1],"06"),I=p(A,0,[2,0,1],"04");try{D=p(A,0,[2,0,"[1]",0],"03")}catch{}}catch{throw new a("malformed PKCS#8 plain ECC private key")}if(this.curveName=d(_),this.curveName===void 0)throw new a("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(D),this.setPrivateKeyHex(I),this.isPublic=!1},this.readPKCS8PubKeyHex=function(A){if(f(A)===!1)throw new a("not ASN.1 hex string");var S,_,I;try{S=p(A,0,[0,0],"06"),_=p(A,0,[0,1],"06"),I=p(A,0,[1],"03")}catch{throw new a("malformed PKCS#8 ECC public key")}if(this.curveName=d(_),this.curveName===null)throw new a("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(I)},this.readCertPubKeyHex=function(A,S){if(f(A)===!1)throw new a("not ASN.1 hex string");var _,I;try{_=p(A,0,[0,5,0,1],"06"),I=p(A,0,[0,5,1],"03")}catch{throw new a("malformed X.509 certificate ECC public key")}if(this.curveName=d(_),this.curveName===null)throw new a("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(I)},e!==void 0&&e.curve!==void 0&&(this.curveName=e.curve),this.curveName===void 0&&(this.curveName=t),this.setNamedCurve(this.curveName),e!==void 0&&(e.prv!==void 0&&this.setPrivateKeyHex(e.prv),e.pub!==void 0&&this.setPublicKeyHex(e.pub))};m.crypto.ECDSA.parseSigHex=function(e){var t=m.crypto.ECDSA.parseSigHexInHexRS(e),r=new ee(t.r,16),n=new ee(t.s,16);return{r,s:n}};m.crypto.ECDSA.parseSigHexInHexRS=function(e){var t=Ae,r=t.getChildIdx,n=t.getV;if(t.checkStrictDER(e,0),e.substr(0,2)!="30")throw new Error("signature is not a ASN.1 sequence");var i=r(e,0);if(i.length!=2)throw new Error("signature shall have two elements");var a=i[0],s=i[1];if(e.substr(a,2)!="02")throw new Error("1st item not ASN.1 integer");if(e.substr(s,2)!="02")throw new Error("2nd item not ASN.1 integer");var o=n(e,a),l=n(e,s);return{r:o,s:l}};m.crypto.ECDSA.asn1SigToConcatSig=function(e){var t=m.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};m.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 m.crypto.ECDSA.hexRSSigToASN1Sig(t,r)};m.crypto.ECDSA.hexRSSigToASN1Sig=function(e,t){var r=new ee(e,16),n=new ee(t,16);return m.crypto.ECDSA.biRSSigToASN1Sig(r,n)};m.crypto.ECDSA.biRSSigToASN1Sig=function(e,t){var r=m.asn1,n=new r.DERInteger({bigint:e}),i=new r.DERInteger({bigint:t}),a=new r.DERSequence({array:[n,i]});return a.tohex()};m.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 m>"u"||!m)&&(m={});(typeof m.crypto>"u"||!m.crypto)&&(m.crypto={});m.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,o,l,h,d,E,p,f,w){e[n]={};var g=r(a),y=r(s),A=r(o),S=r(l),_=r(h),I=new ms(g,y,A),D=I.decodePointHex("04"+d+E);e[n].name=n,e[n].keylen=i,e[n].keycharlen=Math.ceil(i/8)*2,e[n].curve=I,e[n].G=D,e[n].n=S,e[n].h=_,e[n].oid=f,e[n].info=w;for(var H=0;H"u"||!m)&&(m={});(typeof m.crypto>"u"||!m.crypto)&&(m.crypto={});m.crypto.DSA=function(){var e=Ae,t=e.getVbyList,r=e.getVbyListEx,n=e.isASN1HEX,i=ee;this.p=null,this.q=null,this.g=null,this.y=null,this.x=null,this.type="DSA",this.isPrivate=!1,this.isPublic=!1,this.setPrivate=function(a,s,o,l,h){this.isPrivate=!0,this.p=a,this.q=s,this.g=o,this.y=l,this.x=h},this.setPrivateHex=function(a,s,o,l,h){var d,E,p,f,w;d=new ee(a,16),E=new ee(s,16),p=new ee(o,16),typeof l=="string"&&l.length>1?f=new ee(l,16):f=null,w=new ee(h,16),this.setPrivate(d,E,p,f,w)},this.setPublic=function(a,s,o,l){this.isPublic=!0,this.p=a,this.q=s,this.g=o,this.y=l,this.x=null},this.setPublicHex=function(a,s,o,l){var h,d,E,p;h=new ee(a,16),d=new ee(s,16),E=new ee(o,16),p=new ee(l,16),this.setPublic(h,d,E,p)},this.signWithMessageHash=function(a){var s=this.p,o=this.q,l=this.g,h=this.y,d=this.x,E=m.crypto.Util.getRandomBigIntegerMinToMax(ee.ONE.add(ee.ONE),o.subtract(ee.ONE)),p=a.substr(0,o.bitLength()/4),f=new ee(p,16),w=l.modPow(E,s).mod(o),g=E.modInverse(o).multiply(f.add(d.multiply(w))).mod(o),y=m.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:w}},{int:{bigint:g}}]});return y},this.verifyWithMessageHash=function(a,s){var o=this.p,l=this.q,h=this.g,d=this.y,E=this.parseASN1Signature(s),p=E[0],f=E[1],w=a.substr(0,l.bitLength()/4),g=new ee(w,16);if(ee.ZERO.compareTo(p)>0||p.compareTo(l)>0||ee.ZERO.compareTo(f)>=0||f.compareTo(l)>0)throw"invalid DSA signature";var y=f.modInverse(l),A=g.multiply(y).mod(l),S=p.multiply(y).mod(l),_=h.modPow(A,o).multiply(d.modPow(S,o)).mod(o).mod(l);return _.compareTo(p)==0},this.parseASN1Signature=function(a){try{var s=new i(r(a,0,[0],"02"),16),o=new i(r(a,0,[1],"02"),16);return[s,o]}catch{throw new Error("malformed ASN.1 DSA signature")}},this.readPKCS5PrvKeyHex=function(a){var s,o,l,h,d;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{s=r(a,0,[1],"02"),o=r(a,0,[2],"02"),l=r(a,0,[3],"02"),h=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,o,l,h,d)},this.readPKCS8PrvKeyHex=function(a){var s,o,l,h;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{s=r(a,0,[1,1,0],"02"),o=r(a,0,[1,1,1],"02"),l=r(a,0,[1,1,2],"02"),h=r(a,0,[2,0],"02")}catch{throw new Error("malformed PKCS#8 plain DSA private key")}this.setPrivateHex(s,o,l,null,h)},this.readPKCS8PubKeyHex=function(a){var s,o,l,h;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{s=r(a,0,[0,1,0],"02"),o=r(a,0,[0,1,1],"02"),l=r(a,0,[0,1,2],"02"),h=r(a,0,[1,0],"02")}catch{throw new Error("malformed PKCS#8 DSA public key")}this.setPublicHex(s,o,l,h)},this.readCertPubKeyHex=function(a,s){var o,l,h,d;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{o=r(a,0,[0,5,0,1,0],"02"),l=r(a,0,[0,5,0,1,1],"02"),h=r(a,0,[0,5,0,1,2],"02"),d=r(a,0,[0,5,1,0],"02")}catch{throw new Error("malformed X.509 certificate DSA public key")}this.setPublicHex(o,l,h,d)}};var at=function(){var e=function(g,y,A){return n(Ce.AES,g,y,A)},t=function(g,y,A){return n(Ce.TripleDES,g,y,A)},r=function(g,y,A){return n(Ce.DES,g,y,A)},n=function(g,y,A,S){var _=Ce.enc.Hex.parse(y),I=Ce.enc.Hex.parse(A),D=Ce.enc.Hex.parse(S),H={};H.key=I,H.iv=D,H.ciphertext=_;var V=g.decrypt(H,I,{iv:D});return Ce.enc.Hex.stringify(V)},i=function(g,y,A){return o(Ce.AES,g,y,A)},a=function(g,y,A){return o(Ce.TripleDES,g,y,A)},s=function(g,y,A){return o(Ce.DES,g,y,A)},o=function(g,y,A,S){var _=Ce.enc.Hex.parse(y),I=Ce.enc.Hex.parse(A),D=Ce.enc.Hex.parse(S),H=g.encrypt(_,I,{iv:D}),V=Ce.enc.Hex.parse(H.toString()),F=Ce.enc.Base64.stringify(V);return F},l={"AES-256-CBC":{proc:e,eproc:i,keylen:32,ivlen:16},"AES-192-CBC":{proc:e,eproc:i,keylen:24,ivlen:16},"AES-128-CBC":{proc:e,eproc:i,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:t,eproc:a,keylen:24,ivlen:8},"DES-CBC":{proc:r,eproc:s,keylen:8,ivlen:8}},h=function(g){return l[g].proc},d=function(g){var y=Ce.lib.WordArray.random(g),A=Ce.enc.Hex.stringify(y);return A},E=function(g){var y={},A=g.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));A&&(y.cipher=A[1],y.ivsalt=A[2]);var S=g.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));S&&(y.type=S[1]);var _=-1,I=0;g.indexOf(`\r \r `)!=-1&&(_=g.indexOf(`\r \r `),I=2),g.indexOf(` `)!=-1&&(_=g.indexOf(` `),I=1);var D=g.indexOf("-----END");if(_!=-1&&D!=-1){var H=g.substring(_+I*2,D-I);H=H.replace(/\s+/g,""),y.data=H}return y},p=function(g,y,A){for(var S=A.substring(0,16),_=Ce.enc.Hex.parse(S),I=Ce.enc.Utf8.parse(y),D=l[g].keylen+l[g].ivlen,H="",V=null;;){var F=Ce.algo.MD5.create();if(V!=null&&F.update(V),F.update(I),F.update(_),V=F.finalize(),H=H+Ce.enc.Hex.stringify(V),H.length>=D*2)break}var P={};return P.keyhex=H.substr(0,l[g].keylen*2),P.ivhex=H.substr(l[g].keylen*2,l[g].ivlen*2),P},f=function(g,y,A,S){var _=Ce.enc.Base64.parse(g),I=Ce.enc.Hex.stringify(_),D=l[y].proc,H=D(I,A,S);return H},w=function(g,y,A,S){var _=l[y].eproc,I=_(g,A,S);return I};return{version:"1.0.0",parsePKCS5PEM:function(g){return E(g)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(g,y,A){return p(g,y,A)},decryptKeyB64:function(g,y,A,S){return f(g,y,A,S)},getDecryptedKeyHex:function(g,y){var A=E(g),S=A.type,_=A.cipher,I=A.ivsalt,D=A.data,H=p(_,y,I),V=H.keyhex,F=f(D,_,V,I);return F},getEncryptedPKCS5PEMFromPrvKeyHex:function(g,y,A,S,_){var k="";if((typeof S>"u"||S==null)&&(S="AES-256-CBC"),typeof l[S]>"u")throw new Error("KEYUTIL unsupported algorithm: "+S);if(typeof _>"u"||_==null){var I=l[S].ivlen,D=d(I);_=D.toUpperCase()}var H=p(S,A,_),V=H.keyhex,F=w(y,S,V,_),P=F.replace(/(.{64})/g,`$1\r `),k="-----BEGIN "+g+` PRIVATE KEY-----\r `;return k+=`Proc-Type: 4,ENCRYPTED\r `,k+="DEK-Info: "+S+","+_+`\r `,k+=`\r `,k+=P,k+=`\r -----END `+g+` PRIVATE KEY-----\r `,k},getEncryptedPKCS8PEM:function(g,y,A){var S=this.getEncryptedPKCS8Hex(g,y,A);return Or(S,"ENCRYPTED PRIVATE KEY")},getEncryptedPKCS8Hex:function(g,y,A){var S;A==null||A==null?S={}:S=JSON.parse(JSON.stringify(A)),S.plain=g,this.initPBES2Param(S),this.encryptPBES2Param(S,y);var _=this.generatePBES2ASN1Param(S);return m.asn1.ASN1Util.newObject(_).tohex()},initPBES2Param:function(g){if(_t(g,"encalg")==null&&(g.encalg="aes256-CBC"),_t(g,"iter")==null&&(g.iter=2048),_t(g,"prf")==null&&(g.prf="hmacWithSHA256"),_t(g,"salt")==null&&(g.salt=Ce.enc.Hex.stringify(Ce.lib.WordArray.random(8))),_t(g,"enciv")==null){var y;g.encalg=="des-EDE3-CBC"&&(y=8),g.encalg=="aes128-CBC"&&(y=16),g.encalg=="aes256-CBC"&&(y=16),g.enciv=Ce.enc.Hex.stringify(Ce.lib.WordArray.random(y))}},encryptPBES2Param:function(g,y){var A=at.getDKFromPBES2Param(g,y);try{var S=m.crypto.Cipher.encrypt(g.plain,A,g.encalg,{iv:g.enciv})}catch{throw new Error("encrypt error: "+g.plain+" "+A+" "+g.encalg+" "+g.enciv)}g.enc=S},generatePBES2ASN1Param:function(g){var y={seq:[{seq:[{oid:"pkcs5PBES2"},{seq:[{seq:[{oid:"pkcs5PBKDF2"},{seq:[{octstr:{hex:g.salt}},{int:{hex:Wm(g.iter)}}]}]},{seq:[{oid:g.encalg},{octstr:{hex:g.enciv}}]}]}]},{octstr:{hex:g.enc}}]};return g.prf!="hmacWithSHA1"&&y.seq[0].seq[1].seq[0].seq[1].seq.push({seq:[{oid:g.prf},{null:""}]}),y},parseHexOfEncryptedPKCS8:function(g){var y=Ae,A=y.getChildIdx,S=y.getV,_={},I=A(g,0);if(I.length!=2)throw new Error("malformed format: SEQUENCE(0).items != 2: "+I.length);_.ciphertext=S(g,I[1]);var D=A(g,I[0]);if(D.length!=2)throw new Error("malformed format: SEQUENCE(0.0).items != 2: "+D.length);if(S(g,D[0])!="2a864886f70d01050d")throw new Error("this only supports pkcs5PBES2");var H=A(g,D[1]);if(D.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1).items != 2: "+H.length);var V=A(g,H[1]);if(V.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1.1).items != 2: "+V.length);if(S(g,V[0])!="2a864886f70d0307")throw"this only supports TripleDES";_.encryptionSchemeAlg="TripleDES",_.encryptionSchemeIV=S(g,V[1]);var F=A(g,H[0]);if(F.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1.0).items != 2: "+F.length);if(S(g,F[0])!="2a864886f70d01050c")throw new Error("this only supports pkcs5PBKDF2");var P=A(g,F[1]);if(P.length<2)throw new Error("malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+P.length);_.pbkdf2Salt=S(g,P[0]);var k=S(g,P[1]);try{_.pbkdf2Iter=parseInt(k,16)}catch{throw new Error("malformed format pbkdf2Iter: "+k)}return _},getPBKDF2KeyHexFromParam:function(g,y){var A=Ce.enc.Hex.parse(g.pbkdf2Salt),S=g.pbkdf2Iter,_=Ce.PBKDF2(y,A,{keySize:192/32,iterations:S}),I=Ce.enc.Hex.stringify(_);return I},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(g,y){var A=kt(g,"ENCRYPTED PRIVATE KEY"),S=this.parseHexOfEncryptedPKCS8(A),_=at.getPBKDF2KeyHexFromParam(S,y),I={};I.ciphertext=Ce.enc.Hex.parse(S.ciphertext);var D=Ce.enc.Hex.parse(_),H=Ce.enc.Hex.parse(S.encryptionSchemeIV),V=Ce.TripleDES.decrypt(I,D,{iv:H}),F=Ce.enc.Hex.stringify(V);return F},parsePBES2:function(g){var y=Ae.parse(g);if(_t(y,"seq.0.seq.0.oid")!="pkcs5PBES2"||_t(y,"seq.0.seq.1.seq.0.seq.0.oid")!="pkcs5PBKDF2")throw new Error("not pkcs5PBES2 and pkcs5PBKDF2 used");var A=_t(y,"seq.0.seq.1.seq.0.seq.1.seq");if(A==null)throw new Error("PBKDF2 parameter not found");var S=_t(A,"0.octstr.hex"),_=_t(A,"1.int.hex"),I=_t(A,"2.seq.0.oid","hmacWithSHA1"),D=-1;try{D=parseInt(_,16)}catch{throw new Error("iter not proper value")}var H=_t(y,"seq.0.seq.1.seq.1.seq.0.oid"),V=_t(y,"seq.0.seq.1.seq.1.seq.1.octstr.hex"),F=_t(y,"seq.1.octstr.hex");if(H==null||V==null||F==null)throw new Error("encalg, enciv or enc is undefined");var P={salt:S,iter:D,prf:I,encalg:H,enciv:V,enc:F};return P},getDKFromPBES2Param:function(g,y){var A={hmacWithSHA1:Ce.algo.SHA1,hmacWithSHA224:Ce.algo.SHA224,hmacWithSHA256:Ce.algo.SHA256,hmacWithSHA384:Ce.algo.SHA384,hmacWithSHA512:Ce.algo.SHA512},S={"des-EDE3-CBC":192/32,"aes128-CBC":128/32,"aes256-CBC":256/32},_=A[g.prf];if(_==null)throw new Error("unsupported prf");var I=S[g.encalg];if(I==null)throw new Error("unsupported encalg");var D=Ce.enc.Hex.parse(g.salt),H=g.iter;try{var V=Ce.PBKDF2(y,D,{keySize:I,iterations:H,hasher:_});return Ce.enc.Hex.stringify(V)}catch(F){throw new Error("PBKDF2 error: "+F+" "+JSON.stringify(g)+" "+y)}},getPlainHexFromEncryptedPKCS8PEM:function(g,y){if(g.indexOf("BEGIN ENCRYPTED PRIVATE KEY")==-1)throw new Error("not Encrypted PKCS#8 PEM string");var A=kt(g),S;try{S=at.parsePBES2(A)}catch(I){throw new Error("malformed PBES2 format: "+I.message)}var _=at.getDKFromPBES2Param(S,y);return m.crypto.Cipher.decrypt(S.enc,_,S.encalg,{iv:S.enciv})},getKeyFromEncryptedPKCS8PEM:function(g,y){var A=this.getPlainHexFromEncryptedPKCS8PEM(g,y),S=this.getKeyFromPlainPrivatePKCS8Hex(A);return S},parsePlainPrivatePKCS8Hex:function(g){var y=Ae,A=y.getChildIdx,S=y.getV,_={};if(_.algparam=null,g.substr(0,2)!="30")throw new Error("malformed plain PKCS8 private key(code:001)");var I=A(g,0);if(I.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if(g.substr(I[1],2)!="30")throw new Error("malformed PKCS8 private key(code:003)");var D=A(g,I[1]);if(D.length!=2)throw new Error("malformed PKCS8 private key(code:004)");if(g.substr(D[0],2)!="06")throw new Error("malformed PKCS8 private key(code:005)");if(_.algoid=S(g,D[0]),g.substr(D[1],2)=="06"&&(_.algparam=S(g,D[1])),g.substr(I[2],2)!="04")throw new Error("malformed PKCS8 private key(code:006)");return _.keyidx=y.getVidx(g,I[2]),_},getKeyFromPlainPrivatePKCS8PEM:function(g){var y=kt(g,"PRIVATE KEY"),A=this.getKeyFromPlainPrivatePKCS8Hex(y);return A},getKeyFromPlainPrivatePKCS8Hex:function(g){var y=this.parsePlainPrivatePKCS8Hex(g),A;if(y.algoid=="2a864886f70d010101")A=new ze;else if(y.algoid=="2a8648ce380401")A=new m.crypto.DSA;else if(y.algoid=="2a8648ce3d0201")A=new m.crypto.ECDSA;else throw new Error("unsupported private key algorithm");return A.readPKCS8PrvKeyHex(g),A},_getKeyFromPublicPKCS8Hex:function(g){var y,A=Ae.getVbyList(g,0,[0,0],"06");if(A==="2a864886f70d010101")y=new ze;else if(A==="2a8648ce380401")y=new m.crypto.DSA;else if(A==="2a8648ce3d0201")y=new m.crypto.ECDSA;else throw new Error("unsupported PKCS#8 public key hex");return y.readPKCS8PubKeyHex(g),y},parsePublicRawRSAKeyHex:function(g){var y=Ae,A=y.getChildIdx,S=y.getV,_={};if(g.substr(0,2)!="30")throw new Error("malformed RSA key(code:001)");var I=A(g,0);if(I.length!=2)throw new Error("malformed RSA key(code:002)");if(g.substr(I[0],2)!="02")throw new Error("malformed RSA key(code:003)");if(_.n=S(g,I[0]),g.substr(I[1],2)!="02")throw new Error("malformed RSA key(code:004)");return _.e=S(g,I[1]),_},parsePublicPKCS8Hex:function(g){var y=Ae,A=y.getChildIdx,S=y.getV,_={};_.algparam=null;var I=A(g,0);if(I.length!=2)throw new Error("outer DERSequence shall have 2 elements: "+I.length);var D=I[0];if(g.substr(D,2)!="30")throw new Error("malformed PKCS8 public key(code:001)");var H=A(g,D);if(H.length!=2)throw new Error("malformed PKCS8 public key(code:002)");if(g.substr(H[0],2)!="06")throw new Error("malformed PKCS8 public key(code:003)");if(_.algoid=S(g,H[0]),g.substr(H[1],2)=="06"?_.algparam=S(g,H[1]):g.substr(H[1],2)=="30"&&(_.algparam={},_.algparam.p=y.getVbyList(g,H[1],[0],"02"),_.algparam.q=y.getVbyList(g,H[1],[1],"02"),_.algparam.g=y.getVbyList(g,H[1],[2],"02")),g.substr(I[1],2)!="03")throw new Error("malformed PKCS8 public key(code:004)");return _.key=S(g,I[1]).substr(2),_}}}();at.getKey=function(e,t,r){var n=Ae,i=n.getChildIdx,a=n.getV,s=n.getVbyList,o=m.crypto,l=o.ECDSA,h=o.DSA,d=ze,E=kt,p=at;if(typeof d<"u"&&e instanceof d||typeof l<"u"&&e instanceof l||typeof h<"u"&&e instanceof h)return e;if(e.curve!==void 0&&e.xy!==void 0&&e.d===void 0)return new l({pub:e.xy,curve:e.curve});if(e.curve!==void 0&&e.d!==void 0)return new l({prv:e.d,curve:e.curve});if(e.kty===void 0&&e.n!==void 0&&e.e!==void 0&&e.d===void 0){var f=new d;return f.setPublic(e.n,e.e),f}if(e.kty===void 0&&e.n!==void 0&&e.e!==void 0&&e.d!==void 0&&e.p!==void 0&&e.q!==void 0&&e.dp!==void 0&&e.dq!==void 0&&e.co!==void 0&&e.qi===void 0){var f=new d;return f.setPrivateEx(e.n,e.e,e.d,e.p,e.q,e.dp,e.dq,e.co),f}if(e.kty===void 0&&e.n!==void 0&&e.e!==void 0&&e.d!==void 0&&e.p===void 0){var f=new d;return f.setPrivate(e.n,e.e,e.d),f}if(e.p!==void 0&&e.q!==void 0&&e.g!==void 0&&e.y!==void 0&&e.x===void 0){var f=new h;return f.setPublic(e.p,e.q,e.g,e.y),f}if(e.p!==void 0&&e.q!==void 0&&e.g!==void 0&&e.y!==void 0&&e.x!==void 0){var f=new h;return f.setPrivate(e.p,e.q,e.g,e.y,e.x),f}if(e.kty==="RSA"&&e.n!==void 0&&e.e!==void 0&&e.d===void 0){var f=new d;return f.setPublic(Pt(e.n),Pt(e.e)),f}if(e.kty==="RSA"&&e.n!==void 0&&e.e!==void 0&&e.d!==void 0&&e.p!==void 0&&e.q!==void 0&&e.dp!==void 0&&e.dq!==void 0&&e.qi!==void 0){var f=new d;return f.setPrivateEx(Pt(e.n),Pt(e.e),Pt(e.d),Pt(e.p),Pt(e.q),Pt(e.dp),Pt(e.dq),Pt(e.qi)),f}if(e.kty==="RSA"&&e.n!==void 0&&e.e!==void 0&&e.d!==void 0){var f=new d;return f.setPrivate(Pt(e.n),Pt(e.e),Pt(e.d)),f}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}),g=w.ecparams.keycharlen,y=("0000000000"+Pt(e.x)).slice(-g),A=("0000000000"+Pt(e.y)).slice(-g),S="04"+y+A;return w.setPublicKeyHex(S),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}),g=w.ecparams.keycharlen,y=("0000000000"+Pt(e.x)).slice(-g),A=("0000000000"+Pt(e.y)).slice(-g),S="04"+y+A,_=("0000000000"+Pt(e.d)).slice(-g);return w.setPublicKeyHex(S),w.setPrivateKeyHex(_),w}if(r==="pkcs5prv"){var I=e,n=Ae,D,f;if(D=i(I,0),D.length===9)f=new d,f.readPKCS5PrvKeyHex(I);else if(D.length===6)f=new h,f.readPKCS5PrvKeyHex(I);else if(D.length>2&&I.substr(D[1],2)==="04")f=new l,f.readPKCS5PrvKeyHex(I);else throw new Error("unsupported PKCS#1/5 hexadecimal key");return f}if(r==="pkcs8prv"){var f=p.getKeyFromPlainPrivatePKCS8Hex(e);return f}if(r==="pkcs8pub")return p._getKeyFromPublicPKCS8Hex(e);if(r==="x509pub")return He.getPublicKeyFromCertHex(e);if(e.indexOf("-END CERTIFICATE-",0)!=-1||e.indexOf("-END X509 CERTIFICATE-",0)!=-1||e.indexOf("-END TRUSTED CERTIFICATE-",0)!=-1)return He.getPublicKeyFromCertPEM(e);if(e.indexOf("-END PUBLIC KEY-")!=-1){var H=kt(e,"PUBLIC KEY");return p._getKeyFromPublicPKCS8Hex(H)}if(e.indexOf("-END RSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")==-1){var V=E(e,"RSA PRIVATE KEY");return p.getKey(V,null,"pkcs5prv")}if(e.indexOf("-END DSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")==-1){var F=E(e,"DSA PRIVATE KEY"),P=s(F,0,[1],"02"),k=s(F,0,[2],"02"),L=s(F,0,[3],"02"),q=s(F,0,[4],"02"),J=s(F,0,[5],"02"),f=new h;return f.setPrivate(new ee(P,16),new ee(k,16),new ee(L,16),new ee(q,16),new ee(J,16)),f}if(e.indexOf("-END EC PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")==-1){var V=E(e,"EC PRIVATE KEY");return p.getKey(V,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 z=p.getDecryptedKeyHex(e,t),K=new ze;return K.readPKCS5PrvKeyHex(z),K}if(e.indexOf("-END EC PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")!=-1){var F=p.getDecryptedKeyHex(e,t),f=s(F,0,[1],"04"),X=s(F,0,[2,0],"06"),ie=s(F,0,[3,0],"03").substr(2),be="";if(m.crypto.OID.oidhex2name[X]!==void 0)be=m.crypto.OID.oidhex2name[X];else throw new Error("undefined OID(hex) in KJUR.crypto.OID: "+X);var w=new l({curve:be});return w.setPublicKeyHex(ie),w.setPrivateKeyHex(f),w.isPublic=!1,w}if(e.indexOf("-END DSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")!=-1){var F=p.getDecryptedKeyHex(e,t),P=s(F,0,[1],"02"),k=s(F,0,[2],"02"),L=s(F,0,[3],"02"),q=s(F,0,[4],"02"),J=s(F,0,[5],"02"),f=new h;return f.setPrivate(new ee(P,16),new ee(k,16),new ee(L,16),new ee(q,16),new ee(J,16)),f}if(e.indexOf("-END ENCRYPTED PRIVATE KEY-")!=-1)return p.getKeyFromEncryptedPKCS8PEM(e,t);throw new Error("not supported argument")};at.generateKeypair=function(e,t){if(e=="RSA"){var r=t,n=new ze;n.generate(r,"10001"),n.isPrivate=!0,n.isPublic=!0;var i=new ze,a=n.n.toString(16),s=n.e.toString(16);i.setPublic(a,s),i.isPrivate=!1,i.isPublic=!0;var o={};return o.prvKeyObj=n,o.pubKeyObj=i,o}else if(e=="EC"){var l=t,h=new m.crypto.ECDSA({curve:l}),d=h.generateKeyPairHex(),n=new m.crypto.ECDSA({curve:l});n.setPublicKeyHex(d.ecpubhex),n.setPrivateKeyHex(d.ecprvhex),n.isPrivate=!0,n.isPublic=!1;var i=new m.crypto.ECDSA({curve:l});i.setPublicKeyHex(d.ecpubhex),i.isPrivate=!1,i.isPublic=!0;var o={};return o.prvKeyObj=n,o.pubKeyObj=i,o}else throw new Error("unknown algorithm: "+e)};at.getPEM=function(e,t,r,n,i,a){var s=m,o=s.asn1,l=o.DERObjectIdentifier,h=o.DERInteger,d=o.ASN1Util.newObject,E=o.x509,p=E.SubjectPublicKeyInfo,f=s.crypto,w=f.DSA,g=f.ECDSA,y=ze;function A(K){var X=d({seq:[{int:0},{int:{bigint:K.n}},{int:K.e},{int:{bigint:K.d}},{int:{bigint:K.p}},{int:{bigint:K.q}},{int:{bigint:K.dmp1}},{int:{bigint:K.dmq1}},{int:{bigint:K.coeff}}]});return X}function S(K){var X=d({seq:[{int:1},{octstr:{hex:K.prvKeyHex}},{tag:["a0",!0,{oid:{name:K.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+K.pubKeyHex}}]}]});return X}function _(K){var X=d({seq:[{int:0},{int:{bigint:K.p}},{int:{bigint:K.q}},{int:{bigint:K.g}},{int:{bigint:K.y}},{int:{bigint:K.x}}]});return X}if((y!==void 0&&e instanceof y||w!==void 0&&e instanceof w||g!==void 0&&e instanceof g)&&e.isPublic==!0&&(t===void 0||t=="PKCS8PUB")){var I=new p(e),D=I.tohex();return Or(D,"PUBLIC KEY")}if(t=="PKCS1PRV"&&y!==void 0&&e instanceof y&&(r===void 0||r==null)&&e.isPrivate==!0){var I=A(e),D=I.tohex();return Or(D,"RSA PRIVATE KEY")}if(t=="PKCS1PRV"&&g!==void 0&&e instanceof g&&(r===void 0||r==null)&&e.isPrivate==!0){var H=new l({name:e.curveName}),V=H.tohex(),F=S(e),P=F.tohex(),k="";return k+=Or(V,"EC PARAMETERS"),k+=Or(P,"EC PRIVATE KEY"),k}if(t=="PKCS1PRV"&&w!==void 0&&e instanceof w&&(r===void 0||r==null)&&e.isPrivate==!0){var I=_(e),D=I.tohex();return Or(D,"DSA PRIVATE KEY")}if(t=="PKCS5PRV"&&y!==void 0&&e instanceof y&&r!==void 0&&r!=null&&e.isPrivate==!0){var I=A(e),D=I.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",D,r,n,a)}if(t=="PKCS5PRV"&&g!==void 0&&e instanceof g&&r!==void 0&&r!=null&&e.isPrivate==!0){var I=S(e),D=I.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",D,r,n,a)}if(t=="PKCS5PRV"&&w!==void 0&&e instanceof w&&r!==void 0&&r!=null&&e.isPrivate==!0){var I=_(e),D=I.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",D,r,n,a)}var L=function(K,X){if(typeof X=="string")return at.getEncryptedPKCS8PEM(K,X);if(typeof X=="object"&&_t(X,"passcode")!=null){var ie=JSON.parse(JSON.stringify(X)),be=ie.passcode;return delete ie.passcode,at.getEncryptedPKCS8PEM(K,be,ie)}};if(t=="PKCS8PRV"&&y!=null&&e instanceof y&&e.isPrivate==!0){var q=A(e),J=q.tohex(),I=d({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:J}}]}),D=I.tohex();return r===void 0||r==null?Or(D,"PRIVATE KEY"):L(D,r)}if(t=="PKCS8PRV"&&g!==void 0&&e instanceof g&&e.isPrivate==!0){var z={seq:[{int:1},{octstr:{hex:e.prvKeyHex}}]};typeof e.pubKeyHex=="string"&&z.seq.push({tag:["a1",!0,{bitstr:{hex:"00"+e.pubKeyHex}}]});var q=new d(z),J=q.tohex(),I=d({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:e.curveName}}]},{octstr:{hex:J}}]}),D=I.tohex();return r===void 0||r==null?Or(D,"PRIVATE KEY"):L(D,r)}if(t=="PKCS8PRV"&&w!==void 0&&e instanceof w&&e.isPrivate==!0){var q=new h({bigint:e.x}),J=q.tohex(),I=d({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.g}}]}]},{octstr:{hex:J}}]}),D=I.tohex();return r===void 0||r==null?Or(D,"PRIVATE KEY"):L(D,r)}throw new Error("unsupported object nor format")};at.getKeyFromCSRPEM=function(e){var t=kt(e,"CERTIFICATE REQUEST"),r=at.getKeyFromCSRHex(t);return r};at.getKeyFromCSRHex=function(e){var t=at.parseCSRHex(e),r=at.getKey(t.p8pubkeyhex,null,"pkcs8pub");return r};at.parseCSRHex=function(e){var t=Ae,r=t.getChildIdx,n=t.getTLV,i={},a=e;if(a.substr(0,2)!="30")throw new Error("malformed CSR(code:001)");var s=r(a,0);if(s.length<1)throw new Error("malformed CSR(code:002)");if(a.substr(s[0],2)!="30")throw new Error("malformed CSR(code:003)");var o=r(a,s[0]);if(o.length<3)throw new Error("malformed CSR(code:004)");return i.p8pubkeyhex=n(a,o[2]),i};at.getKeyID=function(e){var t=at,r=Ae;typeof e=="string"&&e.indexOf("BEGIN ")!=-1&&(e=t.getKey(e));var n=kt(t.getPEM(e)),i=r.getIdxbyList(n,0,[1]),a=r.getV(n,i).substring(2);return m.crypto.Util.hashHex(a,"sha1")};at.getJWK=function(e,t,r,n,i){var a,s={},o,l=m.crypto.Util.hashHex;if(typeof e=="string")a=at.getKey(e),e.indexOf("CERTIFICATE")!=-1&&(o=kt(e));else if(typeof e=="object")e instanceof He?(a=e.getPublicKey(),o=e.hex):a=e;else throw new Error("unsupported keyinfo type");if(a instanceof ze&&a.isPrivate)s.kty="RSA",s.n=sr(a.n.toString(16)),s.e=sr(a.e.toString(16)),s.d=sr(a.d.toString(16)),s.p=sr(a.p.toString(16)),s.q=sr(a.q.toString(16)),s.dp=sr(a.dmp1.toString(16)),s.dq=sr(a.dmq1.toString(16)),s.qi=sr(a.coeff.toString(16));else if(a instanceof ze&&a.isPublic)s.kty="RSA",s.n=sr(a.n.toString(16)),s.e=sr(a.e.toString(16));else if(a instanceof m.crypto.ECDSA&&a.isPrivate){var h=a.getShortNISTPCurveName();if(h!=="P-256"&&h!=="P-384"&&h!=="P-521")throw new Error("unsupported curve name for JWT: "+h);var d=a.getPublicKeyXYHex();s.kty="EC",s.crv=h,s.x=sr(d.x),s.y=sr(d.y),s.d=sr(a.prvKeyHex)}else if(a instanceof m.crypto.ECDSA&&a.isPublic){var h=a.getShortNISTPCurveName();if(h!=="P-256"&&h!=="P-384"&&h!=="P-521")throw new Error("unsupported curve name for JWT: "+h);var d=a.getPublicKeyXYHex();s.kty="EC",s.crv=h,s.x=sr(d.x),s.y=sr(d.y)}if(s.kty==null)throw new Error("unsupported keyinfo");return!a.isPrivate&&t!=!0&&(s.kid=m.jws.JWS.getJWKthumbprint(s)),o!=null&&r!=!0&&(s.x5c=[gs(o)]),o!=null&&n!=!0&&(s.x5t=Ju(gs(l(o,"sha1")))),o!=null&&i!=!0&&(s["x5t#S256"]=Ju(gs(l(o,"sha256")))),s};at.getJWKFromKey=function(e){return at.getJWK(e,!0,!0,!0,!0)};ze.getPosArrayOfChildrenFromHex=function(e){return Ae.getChildIdx(e,0)};ze.getHexValueArrayOfChildrenFromHex=function(e){var t=Ae,r=t.getV,p=ze.getPosArrayOfChildrenFromHex(e),n=r(e,p[0]),i=r(e,p[1]),a=r(e,p[2]),s=r(e,p[3]),o=r(e,p[4]),l=r(e,p[5]),h=r(e,p[6]),d=r(e,p[7]),E=r(e,p[8]),p=new Array;return p.push(n,i,a,s,o,l,h,d,E),p};ze.prototype.readPrivateKeyFromPEMString=function(e){var t=kt(e),r=ze.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8])};ze.prototype.readPKCS5PrvKeyHex=function(e){var t=ze.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])};ze.prototype.readPKCS8PrvKeyHex=function(e){var t,r,n,i,a,s,o,l,h=Ae,d=h.getVbyListEx;if(h.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"),o=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,o,l)};ze.prototype.readPKCS5PubKeyHex=function(e){var t=Ae,r=t.getV;if(t.isASN1HEX(e)===!1)throw new Error("keyHex is not ASN.1 hex string");var n=t.getChildIdx(e,0);if(n.length!==2||e.substr(n[0],2)!=="02"||e.substr(n[1],2)!=="02")throw new Error("wrong hex for PKCS#5 public key");var i=r(e,n[0]),a=r(e,n[1]);this.setPublic(i,a)};ze.prototype.readPKCS8PubKeyHex=function(e){var t=Ae;if(t.isASN1HEX(e)===!1)throw new Error("not ASN.1 hex string");if(t.getTLVbyListEx(e,0,[0,0])!=="06092a864886f70d010101")throw new Error("not PKCS8 RSA public key");var r=t.getTLVbyListEx(e,0,[1,0]);this.readPKCS5PubKeyHex(r)};ze.prototype.readCertPubKeyHex=function(e,t){var r,n;r=new He,r.readCertHex(e),n=r.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)};var qP=new RegExp("[^0-9a-f]","gi");function Qm(e,t){for(var r="",n=t/4-e.length,i=0;i>24,(i&16711680)>>16,(i&65280)>>8,i&255])))),i+=1;return n}ze.prototype.signPSS=function(e,t,r){var n=function(a){return m.crypto.Util.hashHex(a,t)},i=n(Ii(e));return r===void 0&&(r=-1),this.signWithMessageHashPSS(i,t,r)};ze.prototype.signWithMessageHashPSS=function(e,t,r){var n=dn(e),i=n.length,a=this.n.bitLength()-1,s=Math.ceil(a/8),o,l=function(y){return m.crypto.Util.hashHex(y,t)};if(r===-1||r===void 0)r=i;else if(r===-2)r=s-i-2;else if(r<-2)throw new Error("invalid salt length");if(s0&&(h=new Array(r),new to().nextBytes(h),h=String.fromCharCode.apply(String,h));var d=dn(l(Ii("\0\0\0\0\0\0\0\0"+n+h))),E=[];for(o=0;o>8*s-a&255;for(w[0]&=~g,o=0;on)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/,""),o=tv(s);if(o.length==0)return!1;var l=o[0],h=o[1],d=function(p){return m.crypto.Util.hashString(p,l)},E=d(e);return h==E};ze.prototype.verifyWithMessageHash=function(e,t){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var r=hn(t,16);if(r.bitLength()>this.n.bitLength())return 0;var n=this.doPublic(r),i=n.toString(16).replace(/^1f+00/,""),a=tv(i);if(a.length==0)return!1;var s=a[0],o=a[1];return o==e};ze.prototype.verifyPSS=function(e,t,r,n){var i=function(s){return m.crypto.Util.hashHex(s,r)},a=i(Ii(e));return n===void 0&&(n=-1),this.verifyWithMessageHashPSS(a,t,r,n)};ze.prototype.verifyWithMessageHashPSS=function(e,t,r,n){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var i=new ee(t,16),a=function(S){return m.crypto.Util.hashHex(S,r)},s=dn(e),o=s.length,l=this.n.bitLength()-1,h=Math.ceil(l/8),d;if(n===-1||n===void 0)n=o;else if(n===-2)n=h-o-2;else if(n<-2)throw new Error("invalid salt length");if(h>8*h-l&255;if(p.charCodeAt(0)&w)throw new Error("bits beyond keysize not zero");var g=ev(f,p.length,a),y=[];for(d=0;d0?P:void 0}catch{return}},this._asn1ToNoticeRef=function(F){try{for(var P={},k=_t(F,"seq"),L=0;L0?P:void 0}catch{return}},this._asn1ToNoticeNum=function(F){try{for(var P=_t(F,"seq"),k=[],L=0;L1){var J=s(F,q[1]),z=this.getGeneralName(J);z.uri!=null&&(L.uri=z.uri)}if(q.length>2){var K=s(F,q[2]);K=="0101ff"&&(L.reqauth=!0),K=="010100"&&(L.reqauth=!1)}return L},this.getExtSubjectDirectoryAttributes=function(F,P){if(F===void 0&&P===void 0){var k=this.getExtInfo("subjectDirectoryAttributes");if(k===void 0)return;F=s(this.hex,k.vidx),P=k.critical}var L={extname:"subjectDirectoryAttributes"};P&&(L.critical=!0);try{for(var q=a(F),J=[],z=0;z0&&(P.ext=this.getExtParamArray()),P.sighex=this.getSignatureValueHex(),F.tbshex==!0&&(P.tbshex=h(this.hex,0,[0])),F.nodnarray==!0&&(delete P.issuer.array,delete P.subject.array),P},this.getExtParamArray=function(F){if(F==null){var P=p(this.hex,0,[0,"[3]"]);P!=-1&&(F=d(this.hex,0,[0,"[3]",0],"30"))}for(var k=[],L=r(F,0),q=0;q"u"||!m)&&(m={});(typeof m.jws>"u"||!m.jws)&&(m.jws={});m.jws.JWS=function(){var e=m,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],o=a[2],l=a[3],h=s+"."+o;if(this.parsedJWS={},this.parsedJWS.headB64U=s,this.parsedJWS.payloadB64U=o,this.parsedJWS.sigvalB64U=l,this.parsedJWS.si=h,!i){var d=Pt(l),E=hn(d,16);this.parsedJWS.sigvalH=d,this.parsedJWS.sigvalBI=E}var p=ci(s),f=ci(o);if(this.parsedJWS.headS=p,this.parsedJWS.payloadS=f,!r(p,this.parsedJWS,"headP"))throw"malformed JSON string for JWS Head: "+p}}};m.jws.JWS.sign=function(e,t,r,n,i){var a=m,s=a.jws,o=s.JWS,l=o.readSafeJSONString,h=o.isSafeJSONString,d=a.crypto,E=d.ECDSA,p=d.Mac,f=d.Signature,w=JSON,g,y,A;if(typeof t!="string"&&typeof t!="object")throw"spHeader must be JSON string or object: "+t;if(typeof t=="object"&&(y=t,g=w.stringify(y)),typeof t=="string"){if(g=t,!h(g))throw"JWS Head is not safe JSON string: "+g;y=l(g)}if(A=r,typeof r=="object"&&(A=w.stringify(r)),(e==""||e==null)&&y.alg!==void 0&&(e=y.alg),e!=""&&e!=null&&y.alg===void 0&&(y.alg=e,g=w.stringify(y)),e!==y.alg)throw"alg and sHeader.alg doesn't match: "+e+"!="+y.alg;var S=null;if(o.jwsalg2sigalg[e]===void 0)throw"unsupported alg name: "+e;S=o.jwsalg2sigalg[e];var _=yc(g),I=yc(A),D=_+"."+I,H="";if(S.substr(0,4)=="Hmac"){if(n===void 0)throw"mac key shall be specified for HS* alg";var V=new p({alg:S,prov:"cryptojs",pass:n});V.updateString(D),H=V.doFinal()}else if(S.indexOf("withECDSA")!=-1){var F=new f({alg:S});F.init(n,i),F.updateString(D);var P=F.sign();H=m.crypto.ECDSA.asn1SigToConcatSig(P)}else if(S!="none"){var F=new f({alg:S});F.init(n,i),F.updateString(D),H=F.sign()}var k=sr(H);return D+"."+k};m.jws.JWS.verify=function(e,t,r){var n=m,i=n.jws,a=i.JWS,s=a.readSafeJSONString,o=n.crypto,l=o.ECDSA,h=o.Mac,d=o.Signature,E;if(typeof ze!==void 0&&(E=ze),!wd(e))return!1;var p=e.split(".");if(p.length!==3)return!1;var f=p[0],w=p[1],g=f+"."+w,y=Pt(p[2]),A=s(ci(p[0])),S=null,_=null;if(A.alg===void 0)throw"algorithm not specified in header";if(S=A.alg,_=S.substr(0,2),r!=null&&Object.prototype.toString.call(r)==="[object Array]"&&r.length>0){var I=":"+r.join(":")+":";if(I.indexOf(":"+S+":")==-1)throw"algorithm '"+S+"' not accepted in the list"}if(S!="none"&&t===null)throw"key shall be specified to verify.";if(typeof t=="string"&&t.indexOf("-----BEGIN ")!=-1&&(t=at.getKey(t)),(_=="RS"||_=="PS")&&!(t instanceof E))throw"key shall be a RSAKey obj for RS* and PS* algs";if(_=="ES"&&!(t instanceof l))throw"key shall be a ECDSA obj for ES* algs";S=="none";var D=null;if(a.jwsalg2sigalg[A.alg]===void 0)throw"unsupported alg name: "+S;if(D=a.jwsalg2sigalg[S],D=="none")throw"not supported";if(D.substr(0,4)=="Hmac"){var H=null;if(t===void 0)throw"hexadecimal key shall be specified for HMAC";var V=new h({alg:D,pass:t});return V.updateString(g),H=V.doFinal(),y==H}else if(D.indexOf("withECDSA")!=-1){var F=null;try{F=l.concatSigToASN1Sig(y)}catch{return!1}var P=new d({alg:D});return P.init(t),P.updateString(g),P.verify(F)}else{var P=new d({alg:D});return P.init(t),P.updateString(g),P.verify(y)}};m.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=m.jws.JWS.readSafeJSONString(ci(n)),r.payloadObj=m.jws.JWS.readSafeJSONString(ci(i)),r.headerPP=JSON.stringify(r.headerObj,null," "),r.payloadObj==null?r.payloadPP=ci(i):r.payloadPP=JSON.stringify(r.payloadObj,null," "),a!==void 0&&(r.sigHex=Pt(a)),r};m.jws.JWS.verifyJWT=function(e,t,r){var n=m,i=n.jws,a=i.JWS,s=a.readSafeJSONString,o=a.inArray,l=a.includedArray;if(!wd(e))return!1;var h=e.split(".");if(h.length!=3)return!1;var d=h[0],E=h[1],p=d+"."+E,f=Pt(h[2]),w=s(ci(d)),g=s(ci(E));if(w.alg===void 0)return!1;if(r.alg===void 0)throw"acceptField.alg shall be specified";if(!o(w.alg,r.alg)||g.iss!==void 0&&typeof r.iss=="object"&&!o(g.iss,r.iss)||g.sub!==void 0&&typeof r.sub=="object"&&!o(g.sub,r.sub))return!1;if(g.aud!==void 0&&typeof r.aud=="object"){if(typeof g.aud=="string"){if(!o(g.aud,r.aud))return!1}else if(typeof g.aud=="object"&&!l(g.aud,r.aud))return!1}var y=i.IntDate.getNow();return r.verifyAt!==void 0&&typeof r.verifyAt=="number"&&(y=r.verifyAt),(r.gracePeriod===void 0||typeof r.gracePeriod!="number")&&(r.gracePeriod=0),!(g.exp!==void 0&&typeof g.exp=="number"&&g.exp+r.gracePeriod"u"||!m)&&(m={});(typeof m.jws>"u"||!m.jws)&&(m.jws={});m.jws.JWSJS=function(){var e=m,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,o){if(this.sPayload===void 0||this.sPayload===null)throw"there's no JSON-JS signature to add.";var l=this.aHeader.length;if(this.aHeader.length!=this.aSignature.length)throw"aHeader.length != aSignature.length";try{var h=m.jws.JWS.sign(i,a,this.sPayload,s,o),d=h.split("."),E=d[0],p=d[2];this.aHeader.push(d[0]),this.aSignature.push(d[2])}catch(f){throw this.aHeader.length>l&&this.aHeader.pop(),this.aSignature.length>l&&this.aSignature.pop(),"addSignature failed: "+f}},this.verifyAll=function(i){if(this.aHeader.length!==i.length||this.aSignature.length!==i.length)return!1;for(var a=0;a0)this.aHeader=i.headers;else throw"malformed header";if(typeof i.payload=="string")this.sPayload=i.payload;else throw"malformed signatures";if(i.signatures.length>0)this.aSignature=i.signatures;else throw"malformed signatures"}catch(s){throw"malformed JWS-JS JSON object: "+s}},this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}},this.isEmpty=function(){return this.aHeader.length==0?1:0}};Se.SecureRandom=to;Se.rng_seed_time=gd;Se.BigInteger=ee;Se.RSAKey=ze;Se.ECDSA=m.crypto.ECDSA;Se.DSA=m.crypto.DSA;Se.Signature=m.crypto.Signature;Se.MessageDigest=m.crypto.MessageDigest;Se.Mac=m.crypto.Mac;Se.KEYUTIL=at;Se.ASN1HEX=Ae;Se.X509=He;Se.X509CRL=T8;Se.CryptoJS=Ce;Se.b64tohex=Zu;Se.b64toBA=Nm;Se.ECFieldElementFp=ar;Se.ECPointFp=dt;Se.ECCurveFp=ms;Se.stoBA=Mm;Se.BAtos=qm;Se.BAtohex=pf;Se.stohex=pn;Se.stob64=p8;Se.stob64u=d8;Se.b64utos=g8;Se.b64tob64u=Ju;Se.b64utob64=bc;Se.hex2b64=gs;Se.hextob64u=sr;Se.b64utohex=Pt;Se.utf8tob64u=yc;Se.b64utoutf8=ci;Se.utf8tob64=m8;Se.b64toutf8=v8;Se.utf8tohex=df;Se.hextoutf8=yt;Se.hextorstr=dn;Se.rstrtohex=Ii;Se.hextob64=md;Se.hextob64nl=w8;Se.b64nltohex=Vm;Se.hextopem=Or;Se.pemtohex=kt;Se.hextoArrayBuffer=b8;Se.ArrayBuffertohex=C8;Se.zulutomsec=vd;Se.msectozulu=F8;Se.zulutosec=Km;Se.zulutodate=_8;Se.datetozulu=I8;Se.uricmptohex=mf;Se.hextouricmp=vf;Se.ipv6tohex=cd;Se.hextoipv6=ld;Se.hextoip=of;Se.iptohex=Ed;Se.ucs2hextoutf8=Ad;Se.encodeURIComponentAll=Ef;Se.newline_toUnix=D8;Se.newline_toDos=B8;Se.hextoposhex=fd;Se.intarystrtohex=$8;Se.strdiffidx=P8;Se.oidtohex=Ym;Se.hextooid=Af;Se.strpad=cf;Se.bitstrtoint=Xm;Se.inttobitstr=Jm;Se.bitstrtobinstr=Zm;Se.binstrtobitstr=R8;Se.isBase64URLDot=wd;Se.namearraytobinstr=lf;Se.extendClass=he;Se.foldnl=gf;Se.b64topem=y8;Se.pemtob64=S8;Se.timeogen=Gm;Se.aryval=_t;Se.inttohex=Wm;Se.twoscompl=Cc;Se.KJUR=m;Se.crypto=m.crypto;Se.asn1=m.asn1;Se.jws=m.jws;Se.lang=m.lang;Se.VERSION=Mb;Se.VERSION_FULL=qb});var Ka=we((GP,Va)=>{"use strict";function iv(e){return typeof e>"u"||e===null}function O8(e){return typeof e=="object"&&e!==null}function N8(e){return Array.isArray(e)?e:iv(e)?[]:[e]}function k8(e,t){var r,n,i,a;if(t)for(a=Object.keys(t),r=0,n=a.length;r{"use strict";function Fc(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||""}Fc.prototype=Object.create(Error.prototype);Fc.prototype.constructor=Fc;Fc.prototype.toString=function(t){var r=this.name+": ";return r+=this.reason||"(unknown reason)",!t&&this.mark&&(r+=" "+this.mark.toString()),r};sv.exports=Fc});var ov=we((YP,uv)=>{"use strict";var av=Ka();function Sd(e,t,r,n,i){this.name=e,this.buffer=t,this.position=r,this.line=n,this.column=i}Sd.prototype.getSnippet=function(t,r){var n,i,a,s,o;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 o=this.buffer.slice(i,s),av.repeat(" ",t)+n+o+a+` `+av.repeat(" ",t+this.position-i+n.length)+"^"};Sd.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};uv.exports=Sd});var ur=we((WP,lv)=>{"use strict";var cv=ro(),H8=["kind","resolve","construct","instanceOf","predicate","represent","defaultStyle","styleAliases"],j8=["scalar","sequence","mapping"];function M8(e){var t={};return e!==null&&Object.keys(e).forEach(function(r){e[r].forEach(function(n){t[String(n)]=r})}),t}function q8(e,t){if(t=t||{},Object.keys(t).forEach(function(r){if(H8.indexOf(r)===-1)throw new cv('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=M8(t.styleAliases||null),j8.indexOf(this.kind)===-1)throw new cv('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}lv.exports=q8});var Ga=we((XP,hv)=>{"use strict";var fv=Ka(),wf=ro(),V8=ur();function bd(e,t,r){var n=[];return e.include.forEach(function(i){r=bd(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 K8(){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 G8=ur();pv.exports=new G8("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}})});var mv=we((ZP,gv)=>{"use strict";var z8=ur();gv.exports=new z8("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}})});var Ev=we((QP,vv)=>{"use strict";var Y8=ur();vv.exports=new Y8("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}})});var yf=we((eR,Av)=>{"use strict";var W8=Ga();Av.exports=new W8({explicit:[dv(),mv(),Ev()]})});var yv=we((tR,wv)=>{"use strict";var X8=ur();function J8(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function Z8(){return null}function Q8(e){return e===null}wv.exports=new X8("tag:yaml.org,2002:null",{kind:"scalar",resolve:J8,construct:Z8,predicate:Q8,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"}},defaultStyle:"lowercase"})});var bv=we((rR,Sv)=>{"use strict";var e_=ur();function t_(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 r_(e){return e==="true"||e==="True"||e==="TRUE"}function n_(e){return Object.prototype.toString.call(e)==="[object Boolean]"}Sv.exports=new e_("tag:yaml.org,2002:bool",{kind:"scalar",resolve:t_,construct:r_,predicate:n_,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 Fv=we((nR,Cv)=>{"use strict";var i_=Ka(),s_=ur();function a_(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function u_(e){return 48<=e&&e<=55}function o_(e){return 48<=e&&e<=57}function c_(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 Dv=we((iR,Iv)=>{"use strict";var _v=Ka(),h_=ur(),p_=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 d_(e){return!(e===null||!p_.test(e)||e[e.length-1]==="_")}function g_(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 m_=/^[-+]?[0-9]+e/;function v_(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(_v.isNegativeZero(e))return"-0.0";return r=e.toString(10),m_.test(r)?r.replace("e",".e"):r}function E_(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||_v.isNegativeZero(e))}Iv.exports=new h_("tag:yaml.org,2002:float",{kind:"scalar",resolve:d_,construct:g_,predicate:E_,represent:v_,defaultStyle:"lowercase"})});var Cd=we((sR,Bv)=>{"use strict";var A_=Ga();Bv.exports=new A_({include:[yf()],implicit:[yv(),bv(),Fv(),Dv()]})});var Fd=we((aR,$v)=>{"use strict";var w_=Ga();$v.exports=new w_({include:[Cd()]})});var xv=we((uR,Tv)=>{"use strict";var y_=ur(),Pv=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Rv=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 S_(e){return e===null?!1:Pv.exec(e)!==null||Rv.exec(e)!==null}function b_(e){var t,r,n,i,a,s,o,l=0,h=null,d,E,p;if(t=Pv.exec(e),t===null&&(t=Rv.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],o=+t[6],t[7]){for(l=t[7].slice(0,3);l.length<3;)l+="0";l=+l}return t[9]&&(d=+t[10],E=+(t[11]||0),h=(d*60+E)*6e4,t[9]==="-"&&(h=-h)),p=new Date(Date.UTC(r,n,i,a,s,o,l)),h&&p.setTime(p.getTime()-h),p}function C_(e){return e.toISOString()}Tv.exports=new y_("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:S_,construct:b_,instanceOf:Date,represent:C_})});var Nv=we((oR,Ov)=>{"use strict";var F_=ur();function __(e){return e==="<<"||e===null}Ov.exports=new F_("tag:yaml.org,2002:merge",{kind:"scalar",resolve:__})});var Uv=we((cR,Lv)=>{"use strict";var za;try{kv=Oa,za=kv("buffer").Buffer}catch{}var kv,I_=ur(),_d=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= \r`;function D_(e){if(e===null)return!1;var t,r,n=0,i=e.length,a=_d;for(r=0;r64)){if(t<0)return!1;n+=6}return n%8===0}function B_(e){var t,r,n=e.replace(/[\r\n=]/g,""),i=n.length,a=_d,s=0,o=[];for(t=0;t>16&255),o.push(s>>8&255),o.push(s&255)),s=s<<6|a.indexOf(n.charAt(t));return r=i%4*6,r===0?(o.push(s>>16&255),o.push(s>>8&255),o.push(s&255)):r===18?(o.push(s>>10&255),o.push(s>>2&255)):r===12&&o.push(s>>4&255),za?za.from?za.from(o):new za(o):o}function $_(e){var t="",r=0,n,i,a=e.length,s=_d;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 P_(e){return za&&za.isBuffer(e)}Lv.exports=new I_("tag:yaml.org,2002:binary",{kind:"scalar",resolve:D_,construct:B_,predicate:P_,represent:$_})});var jv=we((fR,Hv)=>{"use strict";var R_=ur(),T_=Object.prototype.hasOwnProperty,x_=Object.prototype.toString;function O_(e){if(e===null)return!0;var t=[],r,n,i,a,s,o=e;for(r=0,n=o.length;r{"use strict";var k_=ur(),L_=Object.prototype.toString;function U_(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 j_=ur(),M_=Object.prototype.hasOwnProperty;function q_(e){if(e===null)return!0;var t,r=e;for(t in r)if(M_.call(r,t)&&r[t]!==null)return!1;return!0}function V_(e){return e!==null?e:{}}Vv.exports=new j_("tag:yaml.org,2002:set",{kind:"mapping",resolve:q_,construct:V_})});var io=we((dR,Gv)=>{"use strict";var K_=Ga();Gv.exports=new K_({include:[Fd()],implicit:[xv(),Nv()],explicit:[Uv(),jv(),qv(),Kv()]})});var Yv=we((gR,zv)=>{"use strict";var G_=ur();function z_(){return!0}function Y_(){}function W_(){return""}function X_(e){return typeof e>"u"}zv.exports=new G_("tag:yaml.org,2002:js/undefined",{kind:"scalar",resolve:z_,construct:Y_,predicate:X_,represent:W_})});var Xv=we((mR,Wv)=>{"use strict";var J_=ur();function Z_(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 Q_(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 eI(e){var t="/"+e.source+"/";return e.global&&(t+="g"),e.multiline&&(t+="m"),e.ignoreCase&&(t+="i"),t}function tI(e){return Object.prototype.toString.call(e)==="[object RegExp]"}Wv.exports=new J_("tag:yaml.org,2002:js/regexp",{kind:"scalar",resolve:Z_,construct:Q_,predicate:tI,represent:eI})});var Qv=we((vR,Zv)=>{"use strict";var Sf;try{Jv=Oa,Sf=Jv("esprima")}catch{typeof window<"u"&&(Sf=window.esprima)}var Jv,rI=ur();function nI(e){if(e===null)return!1;try{var t="("+e+")",r=Sf.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 iI(e){var t="("+e+")",r=Sf.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 sI(e){return e.toString()}function aI(e){return Object.prototype.toString.call(e)==="[object Function]"}Zv.exports=new rI("tag:yaml.org,2002:js/function",{kind:"scalar",resolve:nI,construct:iI,predicate:aI,represent:sI})});var _c=we((AR,t2)=>{"use strict";var e2=Ga();t2.exports=e2.DEFAULT=new e2({include:[io()],explicit:[Yv(),Xv(),Qv()]})});var w2=we((wR,Ic)=>{"use strict";var vs=Ka(),o2=ro(),uI=ov(),c2=io(),oI=_c(),ta=Object.prototype.hasOwnProperty,bf=1,l2=2,f2=3,Cf=4,Id=1,cI=2,r2=3,lI=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,fI=/[\x85\u2028\u2029]/,hI=/[,\[\]\{\}]/,h2=/^(?:!|!!|![a-z\-]+!)$/i,p2=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function n2(e){return Object.prototype.toString.call(e)}function Di(e){return e===10||e===13}function Wa(e){return e===9||e===32}function gn(e){return e===9||e===32||e===10||e===13}function so(e){return e===44||e===91||e===93||e===123||e===125}function pI(e){var t;return 48<=e&&e<=57?e-48:(t=e|32,97<=t&&t<=102?t-97+10:-1)}function dI(e){return e===120?2:e===117?4:e===85?8:0}function gI(e){return 48<=e&&e<=57?e-48:-1}function i2(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 mI(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}var d2=new Array(256),g2=new Array(256);for(Ya=0;Ya<256;Ya++)d2[Ya]=i2(Ya)?1:0,g2[Ya]=i2(Ya);var Ya;function vI(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||oI,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 m2(e,t){return new o2(t,new uI(e.filename,e.input,e.position,e.line,e.position-e.lineStart))}function Me(e,t){throw m2(e,t)}function Ff(e,t){e.onWarning&&e.onWarning.call(null,m2(e,t))}var s2={YAML:function(t,r,n){var i,a,s;t.version!==null&&Me(t,"duplication of %YAML directive"),n.length!==1&&Me(t,"YAML directive accepts exactly one argument"),i=/^([0-9]+)\.([0-9]+)$/.exec(n[0]),i===null&&Me(t,"ill-formed argument of the YAML directive"),a=parseInt(i[1],10),s=parseInt(i[2],10),a!==1&&Me(t,"unacceptable YAML version of the document"),t.version=n[0],t.checkLineBreaks=s<2,s!==1&&s!==2&&Ff(t,"unsupported YAML version of the document")},TAG:function(t,r,n){var i,a;n.length!==2&&Me(t,"TAG directive accepts exactly two arguments"),i=n[0],a=n[1],h2.test(i)||Me(t,"ill-formed tag handle (first argument) of the TAG directive"),ta.call(t.tagMap,i)&&Me(t,'there is a previously declared suffix for "'+i+'" tag handle'),p2.test(a)||Me(t,"ill-formed tag prefix (second argument) of the TAG directive"),t.tagMap[i]=a}};function ea(e,t,r,n){var i,a,s,o;if(t1&&(e.result+=vs.repeat(` `,t-1))}function EI(e,t,r){var n,i,a,s,o,l,h,d,E=e.kind,p=e.result,f;if(f=e.input.charCodeAt(e.position),gn(f)||so(f)||f===35||f===38||f===42||f===33||f===124||f===62||f===39||f===34||f===37||f===64||f===96||(f===63||f===45)&&(i=e.input.charCodeAt(e.position+1),gn(i)||r&&so(i)))return!1;for(e.kind="scalar",e.result="",a=s=e.position,o=!1;f!==0;){if(f===58){if(i=e.input.charCodeAt(e.position+1),gn(i)||r&&so(i))break}else if(f===35){if(n=e.input.charCodeAt(e.position-1),gn(n))break}else{if(e.position===e.lineStart&&_f(e)||r&&so(f))break;if(Di(f))if(l=e.line,h=e.lineStart,d=e.lineIndent,rr(e,!1,-1),e.lineIndent>=t){o=!0,f=e.input.charCodeAt(e.position);continue}else{e.position=s,e.line=l,e.lineStart=h,e.lineIndent=d;break}}o&&(ea(e,a,s,!1),Bd(e,e.line-l),a=s=e.position,o=!1),Wa(f)||(s=e.position+1),f=e.input.charCodeAt(++e.position)}return ea(e,a,s,!1),e.result?!0:(e.kind=E,e.result=p,!1)}function AI(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(ea(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 Di(r)?(ea(e,n,i,!0),Bd(e,rr(e,!1,t)),n=i=e.position):e.position===e.lineStart&&_f(e)?Me(e,"unexpected end of the document within a single quoted scalar"):(e.position++,i=e.position);Me(e,"unexpected end of the stream within a single quoted scalar")}function wI(e,t){var r,n,i,a,s,o;if(o=e.input.charCodeAt(e.position),o!==34)return!1;for(e.kind="scalar",e.result="",e.position++,r=n=e.position;(o=e.input.charCodeAt(e.position))!==0;){if(o===34)return ea(e,r,e.position,!0),e.position++,!0;if(o===92){if(ea(e,r,e.position,!0),o=e.input.charCodeAt(++e.position),Di(o))rr(e,!1,t);else if(o<256&&d2[o])e.result+=g2[o],e.position++;else if((s=dI(o))>0){for(i=s,a=0;i>0;i--)o=e.input.charCodeAt(++e.position),(s=pI(o))>=0?a=(a<<4)+s:Me(e,"expected hexadecimal character");e.result+=mI(a),e.position++}else Me(e,"unknown escape sequence");r=n=e.position}else Di(o)?(ea(e,r,n,!0),Bd(e,rr(e,!1,t)),r=n=e.position):e.position===e.lineStart&&_f(e)?Me(e,"unexpected end of the document within a double quoted scalar"):(e.position++,n=e.position)}Me(e,"unexpected end of the stream within a double quoted scalar")}function yI(e,t){var r=!0,n,i=e.tag,a,s=e.anchor,o,l,h,d,E,p={},f,w,g,y;if(y=e.input.charCodeAt(e.position),y===91)l=93,E=!1,a=[];else if(y===123)l=125,E=!0,a={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=a),y=e.input.charCodeAt(++e.position);y!==0;){if(rr(e,!0,t),y=e.input.charCodeAt(e.position),y===l)return e.position++,e.tag=i,e.anchor=s,e.kind=E?"mapping":"sequence",e.result=a,!0;r||Me(e,"missed comma between flow collection entries"),w=f=g=null,h=d=!1,y===63&&(o=e.input.charCodeAt(e.position+1),gn(o)&&(h=d=!0,e.position++,rr(e,!0,t))),n=e.line,uo(e,t,bf,!1,!0),w=e.tag,f=e.result,rr(e,!0,t),y=e.input.charCodeAt(e.position),(d||e.line===n)&&y===58&&(h=!0,y=e.input.charCodeAt(++e.position),rr(e,!0,t),uo(e,t,bf,!1,!0),g=e.result),E?ao(e,a,p,w,f,g):h?a.push(ao(e,null,p,w,f,g)):a.push(f),rr(e,!0,t),y=e.input.charCodeAt(e.position),y===44?(r=!0,y=e.input.charCodeAt(++e.position)):r=!1}Me(e,"unexpected end of the stream within a flow collection")}function SI(e,t){var r,n,i=Id,a=!1,s=!1,o=t,l=0,h=!1,d,E;if(E=e.input.charCodeAt(e.position),E===124)n=!1;else if(E===62)n=!0;else return!1;for(e.kind="scalar",e.result="";E!==0;)if(E=e.input.charCodeAt(++e.position),E===43||E===45)Id===i?i=E===43?r2:cI:Me(e,"repeat of a chomping mode identifier");else if((d=gI(E))>=0)d===0?Me(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):s?Me(e,"repeat of an indentation width identifier"):(o=t+d-1,s=!0);else break;if(Wa(E)){do E=e.input.charCodeAt(++e.position);while(Wa(E));if(E===35)do E=e.input.charCodeAt(++e.position);while(!Di(E)&&E!==0)}for(;E!==0;){for(Dd(e),e.lineIndent=0,E=e.input.charCodeAt(e.position);(!s||e.lineIndento&&(o=e.lineIndent),Di(E)){l++;continue}if(e.lineIndentt)&&l!==0)Me(e,"bad indentation of a sequence entry");else if(e.lineIndentt)&&(uo(e,t,Cf,!0,i)&&(w?p=e.result:f=e.result),w||(ao(e,h,d,E,p,f,a,s),E=p=f=null),rr(e,!0,-1),y=e.input.charCodeAt(e.position)),e.lineIndent>t&&y!==0)Me(e,"bad indentation of a mapping entry");else if(e.lineIndentt?l=1:e.lineIndent===t?l=0:e.lineIndentt?l=1:e.lineIndent===t?l=0:e.lineIndent tag; it should be "scalar", not "'+e.kind+'"'),E=0,p=e.implicitTypes.length;E tag; it should be "'+f.kind+'", not "'+e.kind+'"'),f.resolve(e.result)?(e.result=f.construct(e.result),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):Me(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")):Me(e,"unknown tag !<"+e.tag+">");return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||d}function II(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&&(rr(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&&!gn(s);)s=e.input.charCodeAt(++e.position);for(n=e.input.slice(r,e.position),i=[],n.length<1&&Me(e,"directive name must not be less than one character in length");s!==0;){for(;Wa(s);)s=e.input.charCodeAt(++e.position);if(s===35){do s=e.input.charCodeAt(++e.position);while(s!==0&&!Di(s));break}if(Di(s))break;for(r=e.position;s!==0&&!gn(s);)s=e.input.charCodeAt(++e.position);i.push(e.input.slice(r,e.position))}s!==0&&Dd(e),ta.call(s2,n)?s2[n](e,n,i):Ff(e,'unknown document directive "'+n+'"')}if(rr(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,rr(e,!0,-1)):a&&Me(e,"directives end mark is expected"),uo(e,e.lineIndent-1,Cf,!1,!0),rr(e,!0,-1),e.checkLineBreaks&&fI.test(e.input.slice(t,e.position))&&Ff(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&_f(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,rr(e,!0,-1));return}if(e.position"u"&&(r=t,t=null);var n=v2(e,r);if(typeof t!="function")return n;for(var i=0,a=n.length;i"u"&&(r=t,t=null),E2(e,t,vs.extend({schema:c2},r))}function BI(e,t){return A2(e,vs.extend({schema:c2},t))}Ic.exports.loadAll=E2;Ic.exports.load=A2;Ic.exports.safeLoadAll=DI;Ic.exports.safeLoad=BI});var q2=we((yR,Td)=>{"use strict";var Bc=Ka(),$c=ro(),$I=_c(),PI=io(),D2=Object.prototype.toString,B2=Object.prototype.hasOwnProperty,RI=9,Dc=10,TI=13,xI=32,OI=33,NI=34,$2=35,kI=37,LI=38,UI=39,HI=42,P2=44,jI=45,R2=58,MI=61,qI=62,VI=63,KI=64,T2=91,x2=93,GI=96,O2=123,zI=124,N2=125,Nr={};Nr[0]="\\0";Nr[7]="\\a";Nr[8]="\\b";Nr[9]="\\t";Nr[10]="\\n";Nr[11]="\\v";Nr[12]="\\f";Nr[13]="\\r";Nr[27]="\\e";Nr[34]='\\"';Nr[92]="\\\\";Nr[133]="\\N";Nr[160]="\\_";Nr[8232]="\\L";Nr[8233]="\\P";var YI=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"];function WI(e,t){var r,n,i,a,s,o,l;if(t===null)return{};for(r={},n=Object.keys(t),i=0,a=n.length;i0?e.charCodeAt(a-1):null,p=p&&b2(s,o)}else{for(a=0;an&&e[E+1]!==" ",E=a);else if(!oo(s))return If;o=a>0?e.charCodeAt(a-1):null,p=p&&b2(s,o)}h=h||d&&a-E-1>n&&e[E+1]!==" "}return!l&&!h?p&&!i(e)?L2:U2:r>9&&k2(e)?If:h?j2:H2}function t9(e,t,r,n){e.dump=function(){if(t.length===0)return"''";if(!e.noCompatMode&&YI.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 o(l){return JI(e,l)}switch(e9(t,s,e.indent,a,o)){case L2:return t;case U2:return"'"+t.replace(/'/g,"''")+"'";case H2:return"|"+C2(t,e.indent)+F2(S2(t,i));case j2:return">"+C2(t,e.indent)+F2(S2(r9(t,a),i));case If:return'"'+n9(t,a)+'"';default:throw new $c("impossible error: invalid scalar style")}}()}function C2(e,t){var r=k2(e)?String(t):"",n=e[e.length-1]===` `,i=n&&(e[e.length-2]===` `||e===` `),a=i?"+":n?"":"-";return r+a+` `}function F2(e){return e[e.length-1]===` `?e.slice(0,-1):e}function r9(e,t){for(var r=/(\n+)([^\n]*)/g,n=function(){var h=e.indexOf(` `);return h=h!==-1?h:e.length,r.lastIndex=h,_2(e.slice(0,h),t)}(),i=e[0]===` `||e[0]===" ",a,s;s=r.exec(e);){var o=s[1],l=s[2];a=l[0]===" ",n+=o+(!i&&!a&&l!==""?` `:"")+_2(l,t),i=a}return n}function _2(e,t){if(e===""||e[0]===" ")return e;for(var r=/ [^ ]/g,n,i=0,a,s=0,o=0,l="";n=r.exec(e);)o=n.index,o-i>t&&(a=s>i?s:o,l+=` `+e.slice(i,a),i=a+1),s=o;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 n9(e){for(var t="",r,n,i,a=0;a=55296&&r<=56319&&(n=e.charCodeAt(a+1),n>=56320&&n<=57343)){t+=y2((r-55296)*1024+n-56320+65536),a++;continue}i=Nr[r],t+=!i&&oo(r)?e[a]:i||y2(r)}return t}function i9(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?"":" "),Xa(e,t,h,!1,!1)&&(d+=e.dump,n+=d));e.tag=i,e.dump="{"+n+"}"}function u9(e,t,r,n){var i="",a=e.tag,s=Object.keys(r),o,l,h,d,E,p;if(e.sortKeys===!0)s.sort();else if(typeof e.sortKeys=="function")s.sort(e.sortKeys);else if(e.sortKeys)throw new $c("sortKeys must be a boolean or a function");for(o=0,l=s.length;o1024,E&&(e.dump&&Dc===e.dump.charCodeAt(0)?p+="?":p+="? "),p+=e.dump,E&&(p+=$d(e,t)),Xa(e,t+1,d,!0,E)&&(e.dump&&Dc===e.dump.charCodeAt(0)?p+=":":p+=": ",p+=e.dump,i+=p));e.tag=a,e.dump=i||"{}"}function I2(e,t,r){var n,i,a,s,o,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 Xa(e,t,r,n,i,a){e.tag=null,e.dump=r,I2(e,r,!1)||I2(e,r,!0);var s=D2.call(e.dump);n&&(n=e.flowLevel<0||e.flowLevel>t);var o=s==="[object Object]"||s==="[object Array]",l,h;if(o&&(l=e.duplicates.indexOf(r),h=l!==-1),(e.tag!==null&&e.tag!=="?"||h||e.indent!==2&&t>0)&&(i=!1),h&&e.usedDuplicates[l])e.dump="*ref_"+l;else{if(o&&h&&!e.usedDuplicates[l]&&(e.usedDuplicates[l]=!0),s==="[object Object]")n&&Object.keys(e.dump).length!==0?(u9(e,t,e.dump,i),h&&(e.dump="&ref_"+l+e.dump)):(a9(e,t,e.dump),h&&(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?(s9(e,d,e.dump,i),h&&(e.dump="&ref_"+l+e.dump)):(i9(e,d,e.dump),h&&(e.dump="&ref_"+l+" "+e.dump))}else if(s==="[object String]")e.tag!=="?"&&t9(e,e.dump,t,a);else{if(e.skipInvalid)return!1;throw new $c("unacceptable kind of an object to dump "+s)}e.tag!==null&&e.tag!=="?"&&(e.dump="!<"+e.tag+"> "+e.dump)}return!0}function o9(e,t){var r=[],n=[],i,a;for(Pd(e,r,n),i=0,a=n.length;i{"use strict";var Df=w2(),V2=q2();function Bf(e){return function(){throw new Error("Function "+e+" is deprecated and cannot be used.")}}Vt.exports.Type=ur();Vt.exports.Schema=Ga();Vt.exports.FAILSAFE_SCHEMA=yf();Vt.exports.JSON_SCHEMA=Cd();Vt.exports.CORE_SCHEMA=Fd();Vt.exports.DEFAULT_SAFE_SCHEMA=io();Vt.exports.DEFAULT_FULL_SCHEMA=_c();Vt.exports.load=Df.load;Vt.exports.loadAll=Df.loadAll;Vt.exports.safeLoad=Df.safeLoad;Vt.exports.safeLoadAll=Df.safeLoadAll;Vt.exports.dump=V2.dump;Vt.exports.safeDump=V2.safeDump;Vt.exports.YAMLException=ro();Vt.exports.MINIMAL_SCHEMA=yf();Vt.exports.SAFE_SCHEMA=io();Vt.exports.DEFAULT_SCHEMA=_c();Vt.exports.scan=Bf("scan");Vt.exports.parse=Bf("parse");Vt.exports.compose=Bf("compose");Vt.exports.addConstructor=Bf("addConstructor")});var z2=we((bR,G2)=>{"use strict";var l9=K2();G2.exports=l9});var W2=we((CR,Y2)=>{"use strict";var $f=z2();Y2.exports={safeLoad:$f.safeLoad,load:$f.load,safeDump:$f.safeDump,dump:$f.dump}});var Od=we(co=>{"use strict";Object.defineProperty(co,"__esModule",{value:!0});co.isCorrect=co.isInSubnet=void 0;function w9(e){return this.subnetMask{"use strict";Object.defineProperty(Bi,"__esModule",{value:!0});Bi.RE_SUBNET_STRING=Bi.RE_ADDRESS=Bi.GROUPS=Bi.BITS=void 0;Bi.BITS=32;Bi.GROUPS=4;Bi.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;Bi.RE_SUBNET_STRING=/\/\d{1,2}$/});var xf=we(Tf=>{"use strict";Object.defineProperty(Tf,"__esModule",{value:!0});Tf.AddressError=void 0;var kd=class extends Error{constructor(t,r){super(t),this.name="AddressError",r!==null&&(this.parseMessage=r)}};Tf.AddressError=kd});var Ld=we((Of,Z2)=>{(function(){var e,t=0xdeadbeefcafe,r=(t&16777215)==15715070;function n(R,x,j){R!=null&&(typeof R=="number"?this.fromNumber(R,x,j):x==null&&typeof R!="string"?this.fromString(R,256):this.fromString(R,x))}function i(){return new n(null)}function a(R,x,j,Q,de,ve){for(;--ve>=0;){var Fe=x*this[R++]+j[Q]+de;de=Math.floor(Fe/67108864),j[Q++]=Fe&67108863}return de}function s(R,x,j,Q,de,ve){for(var Fe=x&32767,Pe=x>>15;--ve>=0;){var St=this[R]&32767,jt=this[R++]>>15,yr=Pe*St+jt*Fe;St=Fe*St+((yr&32767)<<15)+j[Q]+(de&1073741823),de=(St>>>30)+(yr>>>15)+Pe*jt+(de>>>30),j[Q++]=St&1073741823}return de}function o(R,x,j,Q,de,ve){for(var Fe=x&16383,Pe=x>>14;--ve>=0;){var St=this[R]&16383,jt=this[R++]>>14,yr=Pe*St+jt*Fe;St=Fe*St+((yr&16383)<<14)+j[Q]+de,de=(St>>28)+(yr>>14)+Pe*jt,j[Q++]=St&268435455}return de}var l=typeof navigator<"u";l&&r&&navigator.appName=="Microsoft Internet Explorer"?(n.prototype.am=s,e=30):l&&r&&navigator.appName!="Netscape"?(n.prototype.am=a,e=26):(n.prototype.am=o,e=28),n.prototype.DB=e,n.prototype.DM=(1<=0;--x)R[x]=this[x];R.t=this.t,R.s=this.s}function A(R){this.t=1,this.s=R<0?-1:0,R>0?this[0]=R:R<-1?this[0]=R+this.DV:this.t=0}function S(R){var x=i();return x.fromInt(R),x}function _(R,x){var j;if(x==16)j=4;else if(x==8)j=3;else if(x==256)j=8;else if(x==2)j=1;else if(x==32)j=5;else if(x==4)j=2;else{this.fromRadix(R,x);return}this.t=0,this.s=0;for(var Q=R.length,de=!1,ve=0;--Q>=0;){var Fe=j==8?R[Q]&255:g(R,Q);if(Fe<0){R.charAt(Q)=="-"&&(de=!0);continue}de=!1,ve==0?this[this.t++]=Fe:ve+j>this.DB?(this[this.t-1]|=(Fe&(1<>this.DB-ve):this[this.t-1]|=Fe<=this.DB&&(ve-=this.DB)}j==8&&R[0]&128&&(this.s=-1,ve>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==R;)--this.t}function D(R){if(this.s<0)return"-"+this.negate().toString(R);var x;if(R==16)x=4;else if(R==8)x=3;else if(R==2)x=1;else if(R==32)x=5;else if(R==4)x=2;else return this.toRadix(R);var j=(1<0)for(Pe>Pe)>0&&(de=!0,ve=w(Q));Fe>=0;)Pe>(Pe+=this.DB-x)):(Q=this[Fe]>>(Pe-=x)&j,Pe<=0&&(Pe+=this.DB,--Fe)),Q>0&&(de=!0),de&&(ve+=w(Q));return de?ve:"0"}function H(){var R=i();return n.ZERO.subTo(this,R),R}function V(){return this.s<0?this.negate():this}function F(R){var x=this.s-R.s;if(x!=0)return x;var j=this.t;if(x=j-R.t,x!=0)return this.s<0?-x:x;for(;--j>=0;)if((x=this[j]-R[j])!=0)return x;return 0}function P(R){var x=1,j;return(j=R>>>16)!=0&&(R=j,x+=16),(j=R>>8)!=0&&(R=j,x+=8),(j=R>>4)!=0&&(R=j,x+=4),(j=R>>2)!=0&&(R=j,x+=2),(j=R>>1)!=0&&(R=j,x+=1),x}function k(){return this.t<=0?0:this.DB*(this.t-1)+P(this[this.t-1]^this.s&this.DM)}function L(R,x){var j;for(j=this.t-1;j>=0;--j)x[j+R]=this[j];for(j=R-1;j>=0;--j)x[j]=0;x.t=this.t+R,x.s=this.s}function q(R,x){for(var j=R;j=0;--Pe)x[Pe+ve+1]=this[Pe]>>Q|Fe,Fe=(this[Pe]&de)<=0;--Pe)x[Pe]=0;x[ve]=Fe,x.t=this.t+ve+1,x.s=this.s,x.clamp()}function z(R,x){x.s=this.s;var j=Math.floor(R/this.DB);if(j>=this.t){x.t=0;return}var Q=R%this.DB,de=this.DB-Q,ve=(1<>Q;for(var Fe=j+1;Fe>Q;Q>0&&(x[this.t-j-1]|=(this.s&ve)<>=this.DB;if(R.t>=this.DB;Q+=this.s}else{for(Q+=this.s;j>=this.DB;Q-=R.s}x.s=Q<0?-1:0,Q<-1?x[j++]=this.DV+Q:Q>0&&(x[j++]=Q),x.t=j,x.clamp()}function X(R,x){var j=this.abs(),Q=R.abs(),de=j.t;for(x.t=de+Q.t;--de>=0;)x[de]=0;for(de=0;de=0;)R[j]=0;for(j=0;j=x.DV&&(R[j+x.t]-=x.DV,R[j+x.t+1]=1)}R.t>0&&(R[R.t-1]+=x.am(j,x[j],R,2*j,0,1)),R.s=0,R.clamp()}function be(R,x,j){var Q=R.abs();if(!(Q.t<=0)){var de=this.abs();if(de.t0?(Q.lShiftTo(St,ve),de.lShiftTo(St,j)):(Q.copyTo(ve),de.copyTo(j));var jt=ve.t,yr=ve[jt-1];if(yr!=0){var Sr=yr*(1<1?ve[jt-2]>>this.F2:0),An=this.FV/Sr,Us=(1<=0&&(j[j.t++]=1,j.subTo(Hn,j)),n.ONE.dlShiftTo(jt,Hn),Hn.subTo(ve,ve);ve.t=0;){var Ca=j[--br]==yr?this.DM:Math.floor(j[br]*An+(j[br-1]+Vr)*Us);if((j[br]+=ve.am(0,Ca,j,Hs,0,jt))0&&j.rShiftTo(St,j),Fe<0&&n.ZERO.subTo(j,j)}}}function ye(R){var x=i();return this.abs().divRemTo(R,null,x),this.s<0&&x.compareTo(n.ZERO)>0&&R.subTo(x,x),x}function $e(R){this.m=R}function qe(R){return R.s<0||R.compareTo(this.m)>=0?R.mod(this.m):R}function ce(R){return R}function _e(R){R.divRemTo(this.m,null,R)}function Le(R,x,j){R.multiplyTo(x,j),this.reduce(j)}function lr(R,x){R.squareTo(x),this.reduce(x)}$e.prototype.convert=qe,$e.prototype.revert=ce,$e.prototype.reduce=_e,$e.prototype.mulTo=Le,$e.prototype.sqrTo=lr;function Bt(){if(this.t<1)return 0;var R=this[0];if(!(R&1))return 0;var x=R&3;return x=x*(2-(R&15)*x)&15,x=x*(2-(R&255)*x)&255,x=x*(2-((R&65535)*x&65535))&65535,x=x*(2-R*x%this.DV)%this.DV,x>0?this.DV-x:-x}function pt(R){this.m=R,this.mp=R.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(x,x),x}function Tt(R){var x=i();return R.copyTo(x),this.reduce(x),x}function nt(R){for(;R.t<=this.mt2;)R[R.t++]=0;for(var x=0;x>15)*this.mpl&this.um)<<15)&R.DM;for(j=x+this.m.t,R[j]+=this.m.am(0,Q,R,x,0,this.m.t);R[j]>=R.DV;)R[j]-=R.DV,R[++j]++}R.clamp(),R.drShiftTo(this.m.t,R),R.compareTo(this.m)>=0&&R.subTo(this.m,R)}function It(R,x){R.squareTo(x),this.reduce(x)}function tt(R,x,j){R.multiplyTo(x,j),this.reduce(j)}pt.prototype.convert=zt,pt.prototype.revert=Tt,pt.prototype.reduce=nt,pt.prototype.mulTo=tt,pt.prototype.sqrTo=It;function gt(){return(this.t>0?this[0]&1:this.s)==0}function Yt(R,x){if(R>4294967295||R<1)return n.ONE;var j=i(),Q=i(),de=x.convert(this),ve=P(R)-1;for(de.copyTo(j);--ve>=0;)if(x.sqrTo(j,Q),(R&1<0)x.mulTo(Q,de,j);else{var Fe=j;j=Q,Q=Fe}return x.revert(j)}function Je(R,x){var j;return R<256||x.isEven()?j=new $e(x):j=new pt(x),this.exp(R,j)}n.prototype.copyTo=y,n.prototype.fromInt=A,n.prototype.fromString=_,n.prototype.clamp=I,n.prototype.dlShiftTo=L,n.prototype.drShiftTo=q,n.prototype.lShiftTo=J,n.prototype.rShiftTo=z,n.prototype.subTo=K,n.prototype.multiplyTo=X,n.prototype.squareTo=ie,n.prototype.divRemTo=be,n.prototype.invDigit=Bt,n.prototype.isEven=gt,n.prototype.exp=Yt,n.prototype.toString=D,n.prototype.negate=H,n.prototype.abs=V,n.prototype.compareTo=F,n.prototype.bitLength=k,n.prototype.mod=ye,n.prototype.modPowInt=Je,n.ZERO=S(0),n.ONE=S(1);function Ut(){var R=i();return this.copyTo(R),R}function Un(){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 wr(){return this.t==0?this.s:this[0]<<16>>16}function Zt(R){return Math.floor(Math.LN2*this.DB/Math.log(R))}function $r(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function la(R){if(R==null&&(R=10),this.signum()==0||R<2||R>36)return"0";var x=this.chunkSize(R),j=Math.pow(R,x),Q=S(j),de=i(),ve=i(),Fe="";for(this.divRemTo(Q,de,ve);de.signum()>0;)Fe=(j+ve.intValue()).toString(R).substr(1)+Fe,de.divRemTo(Q,de,ve);return ve.intValue().toString(R)+Fe}function Mr(R,x){this.fromInt(0),x==null&&(x=10);for(var j=this.chunkSize(x),Q=Math.pow(x,j),de=!1,ve=0,Fe=0,Pe=0;Pe=j&&(this.dMultiply(Q),this.dAddOffset(Fe,0),ve=0,Fe=0)}ve>0&&(this.dMultiply(Math.pow(x,ve)),this.dAddOffset(Fe,0)),de&&n.ZERO.subTo(this,this)}function mt(R,x,j){if(typeof x=="number")if(R<2)this.fromInt(1);else for(this.fromNumber(R,j),this.testBit(R-1)||this.bitwiseTo(n.ONE.shiftLeft(R-1),Gi,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(x);)this.dAddOffset(2,0),this.bitLength()>R&&this.subTo(n.ONE.shiftLeft(R-1),this);else{var Q=new Array,de=R&7;Q.length=(R>>3)+1,x.nextBytes(Q),de>0?Q[0]&=(1<0)for(j>j)!=(this.s&this.DM)>>j&&(x[de++]=Q|this.s<=0;)j<8?(Q=(this[R]&(1<>(j+=this.DB-8)):(Q=this[R]>>(j-=8)&255,j<=0&&(j+=this.DB,--R)),Q&128&&(Q|=-256),de==0&&(this.s&128)!=(Q&128)&&++de,(de>0||Q!=this.s)&&(x[de++]=Q);return x}function Ze(R){return this.compareTo(R)==0}function Pr(R){return this.compareTo(R)<0?this:R}function fa(R){return this.compareTo(R)>0?this:R}function ha(R,x,j){var Q,de,ve=Math.min(R.t,this.t);for(Q=0;Q>=16,x+=16),R&255||(R>>=8,x+=8),R&15||(R>>=4,x+=4),R&3||(R>>=2,x+=2),R&1||++x,x}function hu(){for(var R=0;R=this.t?this.s!=0:(this[x]&1<>=this.DB;if(R.t>=this.DB;Q+=this.s}else{for(Q+=this.s;j>=this.DB;Q+=R.s}x.s=Q<0?-1:0,Q>0?x[j++]=Q:Q<-1&&(x[j++]=this.DV+Q),x.t=j,x.clamp()}function ma(R){var x=i();return this.addTo(R,x),x}function To(R){var x=i();return this.subTo(R,x),x}function xo(R){var x=i();return this.multiplyTo(R,x),x}function Oo(){var R=i();return this.squareTo(R),R}function No(R){var x=i();return this.divRemTo(R,x,null),x}function ko(R){var x=i();return this.divRemTo(R,null,x),x}function Lo(R){var x=i(),j=i();return this.divRemTo(R,x,j),new Array(x,j)}function Uo(R){this[this.t]=this.am(0,R-1,this,0,0,this.t),++this.t,this.clamp()}function Ho(R,x){if(R!=0){for(;this.t<=x;)this[this.t++]=0;for(this[x]+=R;this[x]>=this.DV;)this[x]-=this.DV,++x>=this.t&&(this[this.t++]=0),++this[x]}}function mi(){}function gu(R){return R}function jo(R,x,j){R.multiplyTo(x,j)}function Mo(R,x){R.squareTo(x)}mi.prototype.convert=gu,mi.prototype.revert=gu,mi.prototype.mulTo=jo,mi.prototype.sqrTo=Mo;function qo(R){return this.exp(R,new mi)}function mu(R,x,j){var Q=Math.min(this.t+R.t,x);for(j.s=0,j.t=Q;Q>0;)j[--Q]=0;var de;for(de=j.t-this.t;Q=0;)j[Q]=0;for(Q=Math.max(x-this.t,0);Q2*this.m.t)return R.mod(this.m);if(R.compareTo(this.m)<0)return R;var x=i();return R.copyTo(x),this.reduce(x),x}function ks(R){return R}function En(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 Ko(R,x){R.squareTo(x),this.reduce(x)}function Go(R,x,j){R.multiplyTo(x,j),this.reduce(j)}en.prototype.convert=Vo,en.prototype.revert=ks,en.prototype.reduce=En,en.prototype.mulTo=Go,en.prototype.sqrTo=Ko;function vu(R,x){var j=R.bitLength(),Q,de=S(1),ve;if(j<=0)return de;j<18?Q=1:j<48?Q=3:j<144?Q=4:j<768?Q=5:Q=6,j<8?ve=new $e(x):x.isEven()?ve=new en(x):ve=new pt(x);var Fe=new Array,Pe=3,St=Q-1,jt=(1<1){var yr=i();for(ve.sqrTo(Fe[1],yr);Pe<=jt;)Fe[Pe]=i(),ve.mulTo(yr,Fe[Pe-2],Fe[Pe]),Pe+=2}var Sr=R.t-1,An,Us=!0,Vr=i(),br;for(j=P(R[Sr])-1;Sr>=0;){for(j>=St?An=R[Sr]>>j-St&jt:(An=(R[Sr]&(1<0&&(An|=R[Sr-1]>>this.DB+j-St)),Pe=Q;!(An&1);)An>>=1,--Pe;if((j-=Pe)<0&&(j+=this.DB,--Sr),Us)Fe[An].copyTo(de),Us=!1;else{for(;Pe>1;)ve.sqrTo(de,Vr),ve.sqrTo(Vr,de),Pe-=2;Pe>0?ve.sqrTo(de,Vr):(br=de,de=Vr,Vr=br),ve.mulTo(Vr,Fe[An],de)}for(;Sr>=0&&!(R[Sr]&1<0&&(x.rShiftTo(ve,x),j.rShiftTo(ve,j));x.signum()>0;)(de=x.getLowestSetBit())>0&&x.rShiftTo(de,x),(de=j.getLowestSetBit())>0&&j.rShiftTo(de,j),x.compareTo(j)>=0?(x.subTo(j,x),x.rShiftTo(1,x)):(j.subTo(x,j),j.rShiftTo(1,j));return ve>0&&j.lShiftTo(ve,j),j}function Eu(R){if(R<=0)return 0;var x=this.DV%R,j=this.s<0?R-1:0;if(this.t>0)if(x==0)j=this[0]%R;else for(var Q=this.t-1;Q>=0;--Q)j=(x*j+this[Q])%R;return j}function Ls(R){var x=R.isEven();if(this.isEven()&&x||R.signum()==0)return n.ZERO;for(var j=R.clone(),Q=this.clone(),de=S(1),ve=S(0),Fe=S(0),Pe=S(1);j.signum()!=0;){for(;j.isEven();)j.rShiftTo(1,j),x?((!de.isEven()||!ve.isEven())&&(de.addTo(this,de),ve.subTo(R,ve)),de.rShiftTo(1,de)):ve.isEven()||ve.subTo(R,ve),ve.rShiftTo(1,ve);for(;Q.isEven();)Q.rShiftTo(1,Q),x?((!Fe.isEven()||!Pe.isEven())&&(Fe.addTo(this,Fe),Pe.subTo(R,Pe)),Fe.rShiftTo(1,Fe)):Pe.isEven()||Pe.subTo(R,Pe),Pe.rShiftTo(1,Pe);j.compareTo(Q)>=0?(j.subTo(Q,j),x&&de.subTo(Fe,de),ve.subTo(Pe,ve)):(Q.subTo(j,Q),x&&Fe.subTo(de,Fe),Pe.subTo(ve,Pe))}if(Q.compareTo(n.ONE)!=0)return n.ZERO;if(Pe.compareTo(R)>=0)return Pe.subtract(R);if(Pe.signum()<0)Pe.addTo(R,Pe);else return Pe;return Pe.signum()<0?Pe.add(R):Pe}var Ht=[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],zo=(1<<26)/Ht[Ht.length-1];function Yo(R){var x,j=this.abs();if(j.t==1&&j[0]<=Ht[Ht.length-1]){for(x=0;x>1,R>Ht.length&&(R=Ht.length);for(var de=i(),ve=0;ve>8&255,hr[Rt++]^=R>>16&255,hr[Rt++]^=R>>24&255,Rt>=qr&&(Rt-=qr)}function Ea(){Wo(new Date().getTime())}if(hr==null){hr=new Array,Rt=0;var pr;if(typeof window<"u"&&window.crypto){if(window.crypto.getRandomValues){var Aa=new Uint8Array(32);for(window.crypto.getRandomValues(Aa),pr=0;pr<32;++pr)hr[Rt++]=Aa[pr]}else if(navigator.appName=="Netscape"&&navigator.appVersion<"5"){var wu=window.crypto.random(32);for(pr=0;pr>>8,hr[Rt++]=pr&255;Rt=0,Ea()}function yu(){if(Ei==null){for(Ea(),Ei=ba(),Ei.init(hr),Rt=0;Rt{(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,o){return t.apply(null,[s].concat(o||[]))}function n(s,o){var l=1,h=s.length,d,E="",p,f,w,g,y,A,S,_;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)?E+=d:(e.number.test(w.type)&&(!S||w.sign)?(_=S?"+":"-",d=d.toString().replace(e.sign,"")):_="",y=w.pad_char?w.pad_char==="0"?"0":w.pad_char.charAt(1):" ",A=w.width-(_+d).length,g=w.width&&A>0?y.repeat(A):"",E+=w.align?_+d+g:y==="0"?_+g+d:g+_+d)}return E}var i=Object.create(null);function a(s){if(i[s])return i[s];for(var o=s,l,h=[],d=0;o;){if((l=e.text.exec(o))!==null)h.push(l[0]);else if((l=e.modulo.exec(o))!==null)h.push("%");else if((l=e.placeholder.exec(o))!==null){if(l[2]){d|=1;var E=[],p=l[2],f=[];if((f=e.key.exec(p))!==null)for(E.push(f[1]);(p=p.substring(f[0].length))!=="";)if((f=e.key_access.exec(p))!==null)E.push(f[1]);else if((f=e.index_access.exec(p))!==null)E.push(f[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");l[2]=E}else d|=2;if(d===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");h.push({placeholder:l[0],param_no:l[1],keys:l[2],sign:l[3],pad_char:l[4],align:l[5],width:l[6],precision:l[7],type:l[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");o=o.substring(l[0].length)}return i[s]=h}typeof Nf<"u"&&(Nf.sprintf=t,Nf.vsprintf=r),typeof window<"u"&&(window.sprintf=t,window.vsprintf=r,typeof define=="function"&&define.amd&&define(function(){return{sprintf:t,vsprintf:r}}))})()});var Hd=we($i=>{"use strict";var S9=$i&&$i.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),b9=$i&&$i.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),tE=$i&&$i.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&S9(t,e,r);return b9(t,e),t};Object.defineProperty($i,"__esModule",{value:!0});$i.Address4=void 0;var Q2=tE(Od()),fi=tE(Nd()),eE=xf(),Tc=Ld(),lo=Rc(),Ud=class e{constructor(t){this.groups=fi.GROUPS,this.parsedAddress=[],this.parsedSubnet="",this.subnet="/32",this.subnetMask=32,this.v4=!0,this.isCorrect=Q2.isCorrect(fi.BITS),this.isInSubnet=Q2.isInSubnet,this.address=t;let r=fi.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>fi.BITS)throw new eE.AddressError("Invalid subnet mask.");t=t.replace(fi.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(fi.RE_ADDRESS))throw new eE.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,lo.sprintf)("%02x",parseInt(t,10))).join(":")}toArray(){return this.parsedAddress.map(t=>parseInt(t,10))}toGroup6(){let t=[],r;for(r=0;r(0,lo.sprintf)("%02x",parseInt(t,10))).join(""),16)}_startAddress(){return new Tc.BigInteger(this.mask()+"0".repeat(fi.BITS-this.subnetMask),2)}startAddress(){return e.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new Tc.BigInteger("1");return e.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new Tc.BigInteger(this.mask()+"1".repeat(fi.BITS-this.subnetMask),2)}endAddress(){return e.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new Tc.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,lo.sprintf)("%s.in-addr.arpa.",r)}isMulticast(){return this.isInSubnet(new e("224.0.0.0/4"))}binaryZeroPad(){return this.bigInteger().toString(2).padStart(fi.BITS,"0")}groupForV6(){let t=this.parsedAddress;return this.address.replace(fi.RE_ADDRESS,(0,lo.sprintf)('%s.%s',t.slice(0,2).join("."),t.slice(2,4).join(".")))}};$i.Address4=Ud});var jd=we(Kt=>{"use strict";Object.defineProperty(Kt,"__esModule",{value:!0});Kt.RE_URL_WITH_PORT=Kt.RE_URL=Kt.RE_ZONE_STRING=Kt.RE_SUBNET_STRING=Kt.RE_BAD_ADDRESS=Kt.RE_BAD_CHARACTERS=Kt.TYPES=Kt.SCOPES=Kt.GROUPS=Kt.BITS=void 0;Kt.BITS=128;Kt.GROUPS=8;Kt.SCOPES={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"};Kt.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"};Kt.RE_BAD_CHARACTERS=/([^0-9a-f:/%])/gi;Kt.RE_BAD_ADDRESS=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi;Kt.RE_SUBNET_STRING=/\/\d{1,3}(?=%|$)/;Kt.RE_ZONE_STRING=/%.*$/;Kt.RE_URL=new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/);Kt.RE_URL_WITH_PORT=new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/)});var Md=we(Pi=>{"use strict";Object.defineProperty(Pi,"__esModule",{value:!0});Pi.simpleGroup=Pi.spanLeadingZeroes=Pi.spanAll=Pi.spanAllZeroes=void 0;var rE=Rc();function nE(e){return e.replace(/(0+)/g,'$1')}Pi.spanAllZeroes=nE;function C9(e,t=0){return e.split("").map((n,i)=>(0,rE.sprintf)('%s',n,i+t,nE(n))).join("")}Pi.spanAll=C9;function iE(e){return e.replace(/^(0+)/,'$1')}function F9(e){return e.split(":").map(r=>iE(r)).join(":")}Pi.spanLeadingZeroes=F9;function _9(e,t=0){return e.split(":").map((n,i)=>/group-v4/.test(n)?n:(0,rE.sprintf)('%s',i+t,iE(n)))}Pi.simpleGroup=_9});var sE=we(vr=>{"use strict";var I9=vr&&vr.__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]}),D9=vr&&vr.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),B9=vr&&vr.__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)&&I9(t,e,r);return D9(t,e),t};Object.defineProperty(vr,"__esModule",{value:!0});vr.possibleElisions=vr.simpleRegularExpression=vr.ADDRESS_BOUNDARY=vr.padGroup=vr.groupPossibilities=void 0;var $9=B9(jd()),fo=Rc();function Lf(e){return(0,fo.sprintf)("(%s)",e.join("|"))}vr.groupPossibilities=Lf;function kf(e){return e.length<4?(0,fo.sprintf)("0{0,%d}%s",4-e.length,e):e}vr.padGroup=kf;vr.ADDRESS_BOUNDARY="[^A-Fa-f0-9:]";function P9(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===$9.GROUPS-1?":":"";return Lf([kf(i),s])}return kf(i)}).join(":"));return r.push(e.map(kf).join(":")),Lf(r)}vr.simpleRegularExpression=P9;function R9(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,fo.sprintf)("%s(:0{1,4}){1,%d}",n,e-1)),a.push((0,fo.sprintf)("(0{1,4}:){1,%d}%s",e-1,i)),a.push((0,fo.sprintf)("(0{1,4}:){%d}0{1,4}",e-1));for(let s=1;s{"use strict";var T9=Ri&&Ri.__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]}),x9=Ri&&Ri.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Hf=Ri&&Ri.__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 x9(t,e),t};Object.defineProperty(Ri,"__esModule",{value:!0});Ri.Address6=void 0;var aE=Hf(Od()),qd=Hf(Nd()),$t=Hf(jd()),Vd=Hf(Md()),Za=Hd(),Qa=sE(),Es=xf(),Jr=Ld(),Zr=Rc();function Uf(e){if(!e)throw new Error("Assertion failed.")}function O9(e){let t=/(\d+)(\d{3})/;for(;t.test(e);)e=e.replace(t,"$1,$2");return e}function N9(e){return e=e.replace(/^(0{1,})([1-9]+)$/,'$1$2'),e=e.replace(/^(0{1,})(0)$/,'$1$2'),e}function k9(e,t){let r=[],n=[],i;for(i=0;it[1]&&n.push(e[i]);return r.concat(["compact"]).concat(n)}function uE(e){return(0,Zr.sprintf)("%04x",parseInt(e,16))}function oE(e){return e&255}var Kd=class e{constructor(t,r){this.addressMinusSuffix="",this.parsedSubnet="",this.subnet="/128",this.subnetMask=128,this.v4=!1,this.zone="",this.isInSubnet=aE.isInSubnet,this.isCorrect=aE.isCorrect($t.BITS),r===void 0?this.groups=$t.GROUPS:this.groups=r,this.address=t;let n=$t.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>$t.BITS)throw new Es.AddressError("Invalid subnet mask.");t=t.replace($t.RE_SUBNET_STRING,"")}else if(/\//.test(t))throw new Es.AddressError("Invalid subnet mask.");let i=$t.RE_ZONE_STRING.exec(t);i&&(this.zone=i[0],t=t.replace($t.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;i<$t.GROUPS;i++)n.push(r.slice(i*4,(i+1)*4));return new e(n.join(":"))}static fromURL(t){let r,n=null,i;if(t.indexOf("[")!==-1&&t.indexOf("]:")!==-1){if(i=$t.RE_URL_WITH_PORT.exec(t),i===null)return{error:"failed to parse address with port",address:null,port:null};r=i[1],n=i[2]}else if(t.indexOf("/")!==-1){if(t=t.replace(/^[a-z0-9]+:\/\//,""),i=$t.RE_URL.exec(t),i===null)return{error:"failed to parse address from URL",address:null,port:null};r=i[1]}else r=t;return n?(n=parseInt(n,10),(n<0||n>65536)&&(n=null)):n=null,{address:new e(r),port:n}}static fromAddress4(t){let r=new Za.Address4(t),n=$t.BITS-(qd.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 Es.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,Zr.sprintf)("%s.ipv6-literal.net",this.correctForm().replace(/:/g,"-"))}mask(t=this.subnetMask){return this.getBitsBase2(0,t)}possibleSubnets(t=128){let r=$t.BITS-this.subnetMask,n=Math.abs(t-$t.BITS),i=r-n;return i<0?"0":O9(new Jr.BigInteger("2",10).pow(i).toString(10))}_startAddress(){return new Jr.BigInteger(this.mask()+"0".repeat($t.BITS-this.subnetMask),2)}startAddress(){return e.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new Jr.BigInteger("1");return e.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new Jr.BigInteger(this.mask()+"1".repeat($t.BITS-this.subnetMask),2)}endAddress(){return e.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new Jr.BigInteger("1");return e.fromBigInteger(this._endAddress().subtract(t))}getScope(){let t=$t.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($t.TYPES))if(this.isInSubnet(new e(t)))return $t.TYPES[t];return"Global unicast"}getBits(t,r){return new Jr.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,$t.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,Zr.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(o=>o[1]-o[0]+1);if(i.length>0){let o=a.indexOf(Math.max(...a));r=k9(this.parsedAddress,i[o])}else r=this.parsedAddress;for(t=0;t1?"s":"",r.join("")),t.replace($t.RE_BAD_CHARACTERS,'$1'));let n=t.match($t.RE_BAD_ADDRESS);if(n)throw new Es.AddressError((0,Zr.sprintf)("Address failed regex: %s",n.join("")),t.replace($t.RE_BAD_ADDRESS,'$1'));let i=[],a=t.split("::");if(a.length===2){let s=a[0].split(":"),o=a[1].split(":");s.length===1&&s[0]===""&&(s=[]),o.length===1&&o[0]===""&&(o=[]);let l=this.groups-(s.length+o.length);if(!l)throw new Es.AddressError("Error parsing groups");this.elidedGroups=l,this.elisionBegin=s.length,this.elisionEnd=s.length+this.elidedGroups,i=i.concat(s);for(let h=0;h(0,Zr.sprintf)("%x",parseInt(s,16))),i.length!==this.groups)throw new Es.AddressError("Incorrect number of groups found");return i}canonicalForm(){return this.parsedAddress.map(uE).join(":")}decimal(){return this.parsedAddress.map(t=>(0,Zr.sprintf)("%05d",parseInt(t,16))).join(":")}bigInteger(){return new Jr.BigInteger(this.parsedAddress.map(uE).join(""),16)}to4(){let t=this.binaryZeroPad().split("");return Za.Address4.fromHex(new Jr.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 Jr.BigInteger("ffff",16)).toString(),n=Za.Address4.fromHex(this.getBitsBase16(32,64)),i=Za.Address4.fromHex(this.getBits(96,128).xor(new Jr.BigInteger("ffffffff",16)).toString(16)),a=this.getBits(64,80),s=this.getBitsBase2(64,80),o=a.testBit(15),l=a.testBit(14),h=a.testBit(8),d=a.testBit(9),E=new Jr.BigInteger(s.slice(2,6)+s.slice(8,16),2).toString(10);return{prefix:(0,Zr.sprintf)("%s:%s",t.slice(0,4),t.slice(4,8)),server4:n.address,client4:i.address,flags:s,coneNat:o,microsoft:{reserved:l,universalLocal:d,groupIndividual:h,nonce:E},udpPort:r}}inspect6to4(){let t=this.getBitsBase16(0,16),r=Za.Address4.fromHex(this.getBitsBase16(16,48));return{prefix:(0,Zr.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(oE)}static fromByteArray(t){return this.fromUnsignedByteArray(t.map(oE))}static fromUnsignedByteArray(t){let r=new Jr.BigInteger("256",10),n=new Jr.BigInteger("0",10),i=new Jr.BigInteger("1",10);for(let a=t.length-1;a>=0;a--)n=n.add(i.multiply(new Jr.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,Zr.sprintf)(":%s",t),(0,Zr.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,Zr.sprintf)('%2$s',t.prefix,r.call(this),t.className):(0,Zr.sprintf)('%2$s',t.prefix,r.call(this))}group(){if(this.elidedGroups===0)return Vd.simpleGroup(this.address).join(":");Uf(typeof this.elidedGroups=="number"),Uf(typeof this.elisionBegin=="number");let t=[],[r,n]=this.address.split("::");r.length?t.push(...Vd.simpleGroup(r)):t.push("");let i=["hover-group"];for(let a=this.elisionBegin;a',i.join(" "))),n.length?t.push(...Vd.simpleGroup(n,this.elisionEnd)):t.push(""),this.is4()&&(Uf(this.address4 instanceof Za.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,Qa.simpleRegularExpression)(n.parsedAddress));else if(n.elidedGroups===$t.GROUPS)r.push((0,Qa.possibleElisions)($t.GROUPS));else{let i=n.address.split("::");i[0].length&&r.push((0,Qa.simpleRegularExpression)(i[0].split(":"))),Uf(typeof n.elidedGroups=="number"),r.push((0,Qa.possibleElisions)(n.elidedGroups,i[0].length!==0,i[1].length!==0)),i[1].length&&r.push((0,Qa.simpleRegularExpression)(i[1].split(":"))),r=[r.join(":")]}return t||(r=["(?=^|",Qa.ADDRESS_BOUNDARY,"|[^\\w\\:])(",...r,")(?=[^\\w\\:]|",Qa.ADDRESS_BOUNDARY,"|$)"]),r.join("")}regularExpression(t=!1){return new RegExp(this.regularExpressionString(t),"i")}};Ri.Address6=Kd});var lE=we(jr=>{"use strict";var L9=jr&&jr.__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]}),U9=jr&&jr.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),H9=jr&&jr.__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)&&L9(t,e,r);return U9(t,e),t};Object.defineProperty(jr,"__esModule",{value:!0});jr.v6=jr.AddressError=jr.Address6=jr.Address4=void 0;var j9=Hd();Object.defineProperty(jr,"Address4",{enumerable:!0,get:function(){return j9.Address4}});var M9=cE();Object.defineProperty(jr,"Address6",{enumerable:!0,get:function(){return M9.Address6}});var q9=xf();Object.defineProperty(jr,"AddressError",{enumerable:!0,get:function(){return q9.AddressError}});var V9=H9(Md());jr.v6={helpers:V9}});var TE=we(r0=>{"use strict";r0.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};r0.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 xE=we(n0=>{"use strict";n0.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};n0.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 OE=we(i0=>{"use strict";i0.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};i0.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 NE=we(s0=>{"use strict";s0.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};s0.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 kE=we(a0=>{"use strict";a0.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}`};a0.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 HE=we((UE,u0)=>{var LE=function(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.decode=E,e.encode=d,e.familyOf=h,e.name=void 0,e.sizeOf=l,e.v6=e.v4=void 0;let t=/^(\d{1,3}\.){3,3}\d{1,3}$/,r=4,n=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,i=16,a={name:"v4",size:r,isFormat:p=>t.test(p),encode(p,f,w){w=~~w,f=f||new Uint8Array(w+r);let g=p.length,y=0;for(let A=0;Ap.length>0&&n.test(p),encode(p,f,w){w=~~w;let g=w+i,y=-1,A=0,S=0,_=!0,I=!1;f=f||new Uint8Array(w+i);for(let D=0;D>8),w=97?H-=87:H>=65?H-=55:(H-=48,S=S*10+H),A=(A<<4)+H)}if(_===!1)I===!0?(w>8),w=y+2;D--)f[D]=f[D-2];f[y]=0,f[y+1]=0,y=w}if(y!==w&&y!==-1)for(w>g-2&&(w=g-2);g>y;)f[--g]=wy?f[--w]:0;else for(;w{"use strict";var ke=af().Buffer,Bs=TE(),hD=xE(),pD=OE(),Zf=NE(),o0=kE(),tu=HE(),dD=0,jE=32768,c0=32768,gD=~c0,ME=32768,mD=~ME,De=Ne.name={};De.encode=function(e,t,r,{mail:n=!1}={}){t||(t=ke.alloc(De.encodingLength(e))),r||(r=0);let i=r,a=e.replace(/^\.|\.$/gm,"");if(a.length){let s=[];if(n){let o="";a.split(".").forEach(l=>{l.endsWith("\\")?o+=(o.length?".":"")+l.slice(0,-1):s.length===0&&o.length?s.push(o+"."+l):s.push(l)})}else s=a.split(".");for(let o=0;o=e.length)throw new Error("Cannot decode name (buffer overflow)");let l=e[t++];if(s+=o?0:1,l===0)break;if(l&192)if((l&192)===192){if(t+1>e.length)throw new Error("Cannot decode name (buffer overflow)");let h=e.readUInt16BE(t-1)-49152;if(h>=i)throw new Error("Cannot decode name (bad pointer)");t=h,i=h,s+=o?0:1,o=!0}else throw new Error("Cannot decode name (bad label)");else{if(t+l>e.length)throw new Error("Cannot decode name (buffer overflow)");if(a+=l+1,a>254)throw new Error("Cannot decode name (name too long)");let h=e.toString("utf-8",t,t+l);r&&(h=h.replace(/\./g,"\\.")),n.push(h),t+=l,s+=o?0:l}}return De.decode.bytes=s,n.length===0?".":n.join(".")};De.decode.bytes=0;De.encodingLength=function(e){return e==="."||e===".."?1:ke.byteLength(e.replace(/^\.|\.$/gm,""))+2};var st={};st.encode=function(e,t,r){t||(t=ke.alloc(st.encodingLength(e))),r||(r=0);let n=t.write(e,r+1);return t[r]=n,st.encode.bytes=n+1,t};st.encode.bytes=0;st.decode=function(e,t){t||(t=0);let r=e[t],n=e.toString("utf-8",t+1,t+1+r);return st.decode.bytes=r+1,n};st.decode.bytes=0;st.encodingLength=function(e){return ke.byteLength(e)+1};var di={};di.encode=function(e,t,r){t||(t=di.encodingLength(e)),r||(r=0);let n=(e.flags||0)&32767,i=e.type==="response"?jE:dD;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};di.encode.bytes=12;di.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&jE?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:pD.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:hD.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))}};di.decode.bytes=12;di.encodingLength=function(){return 12};var ws=Ne.unknown={};ws.encode=function(e,t,r){return t||(t=ke.alloc(ws.encodingLength(e))),r||(r=0),t.writeUInt16BE(e.length,r),e.copy(t,r+2),ws.encode.bytes=e.length+2,t};ws.encode.bytes=0;ws.decode=function(e,t){t||(t=0);let r=e.readUInt16BE(t),n=e.slice(t+2,t+2+r);return ws.decode.bytes=r+2,n};ws.decode.bytes=0;ws.encodingLength=function(e){return e.length+2};var ys=Ne.ns={};ys.encode=function(e,t,r){return t||(t=ke.alloc(ys.encodingLength(e))),r||(r=0),De.encode(e,t,r+2),t.writeUInt16BE(De.encode.bytes,r),ys.encode.bytes=De.encode.bytes+2,t};ys.encode.bytes=0;ys.decode=function(e,t){t||(t=0);let r=e.readUInt16BE(t),n=De.decode(e,t+2);return ys.decode.bytes=r+2,n};ys.decode.bytes=0;ys.encodingLength=function(e){return De.encodingLength(e)+2};var Ss=Ne.soa={};Ss.encode=function(e,t,r){t||(t=ke.alloc(Ss.encodingLength(e))),r||(r=0);let n=r;return r+=2,De.encode(e.mname,t,r),r+=De.encode.bytes,De.encode(e.rname,t,r,{mail:!0}),r+=De.encode.bytes,t.writeUInt32BE(e.serial||0,r),r+=4,t.writeUInt32BE(e.refresh||0,r),r+=4,t.writeUInt32BE(e.retry||0,r),r+=4,t.writeUInt32BE(e.expire||0,r),r+=4,t.writeUInt32BE(e.minimum||0,r),r+=4,t.writeUInt16BE(r-n-2,n),Ss.encode.bytes=r-n,t};Ss.encode.bytes=0;Ss.decode=function(e,t){t||(t=0);let r=t,n={};return t+=2,n.mname=De.decode(e,t),t+=De.decode.bytes,n.rname=De.decode(e,t,{mail:!0}),t+=De.decode.bytes,n.serial=e.readUInt32BE(t),t+=4,n.refresh=e.readUInt32BE(t),t+=4,n.retry=e.readUInt32BE(t),t+=4,n.expire=e.readUInt32BE(t),t+=4,n.minimum=e.readUInt32BE(t),t+=4,Ss.decode.bytes=t-r,n};Ss.decode.bytes=0;Ss.encodingLength=function(e){return 22+De.encodingLength(e.mname)+De.encodingLength(e.rname)};var bs=Ne.txt={};bs.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++]=mn.decode(e,t),t+=mn.decode.bytes,i-=mn.decode.bytes;return Rn.decode.bytes=t-r,n};Rn.decode.bytes=0;Rn.encodingLength=function(e){return 2+Ao(e||[],mn)};var Qr=Ne.dnskey={};Qr.PROTOCOL_DNSSEC=3;Qr.ZONE_KEY=128;Qr.SECURE_ENTRYPOINT=32768;Qr.encode=function(e,t,r){t||(t=ke.alloc(Qr.encodingLength(e))),r||(r=0);let n=r,i=e.key;if(!ke.isBuffer(i))throw new Error("Key must be a Buffer");return r+=2,t.writeUInt16BE(e.flags,r),r+=2,t.writeUInt8(Qr.PROTOCOL_DNSSEC,r),r+=1,t.writeUInt8(e.algorithm,r),r+=1,i.copy(t,r,0,i.length),r+=i.length,Qr.encode.bytes=r-n,t.writeUInt16BE(Qr.encode.bytes-2,n),t};Qr.encode.bytes=0;Qr.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)!==Qr.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,Qr.decode.bytes=t-r,n};Qr.decode.bytes=0;Qr.encodingLength=function(e){return 6+ke.byteLength(e.key)};var Oi=Ne.rrsig={};Oi.encode=function(e,t,r){t||(t=ke.alloc(Oi.encodingLength(e))),r||(r=0);let n=r,i=e.signature;if(!ke.isBuffer(i))throw new Error("Signature must be a Buffer");return r+=2,t.writeUInt16BE(Bs.toType(e.typeCovered),r),r+=2,t.writeUInt8(e.algorithm,r),r+=1,t.writeUInt8(e.labels,r),r+=1,t.writeUInt32BE(e.originalTTL,r),r+=4,t.writeUInt32BE(e.expiration,r),r+=4,t.writeUInt32BE(e.inception,r),r+=4,t.writeUInt16BE(e.keyTag,r),r+=2,De.encode(e.signersName,t,r),r+=De.encode.bytes,i.copy(t,r,0,i.length),r+=i.length,Oi.encode.bytes=r-n,t.writeUInt16BE(Oi.encode.bytes-2,n),t};Oi.encode.bytes=0;Oi.decode=function(e,t){t||(t=0);let r=t;var n={},i=e.readUInt16BE(t);return t+=2,n.typeCovered=Bs.toString(e.readUInt16BE(t)),t+=2,n.algorithm=e.readUInt8(t),t+=1,n.labels=e.readUInt8(t),t+=1,n.originalTTL=e.readUInt32BE(t),t+=4,n.expiration=e.readUInt32BE(t),t+=4,n.inception=e.readUInt32BE(t),t+=4,n.keyTag=e.readUInt16BE(t),t+=2,n.signersName=De.decode(e,t),t+=De.decode.bytes,n.signature=e.slice(t,r+i+2),t+=n.signature.length,Oi.decode.bytes=t-r,n};Oi.decode.bytes=0;Oi.encodingLength=function(e){return 20+De.encodingLength(e.signersName)+ke.byteLength(e.signature)};var Ni=Ne.rp={};Ni.encode=function(e,t,r){t||(t=ke.alloc(Ni.encodingLength(e))),r||(r=0);let n=r;return r+=2,De.encode(e.mbox||".",t,r,{mail:!0}),r+=De.encode.bytes,De.encode(e.txt||".",t,r),r+=De.encode.bytes,Ni.encode.bytes=r-n,t.writeUInt16BE(Ni.encode.bytes-2,n),t};Ni.encode.bytes=0;Ni.decode=function(e,t){t||(t=0);let r=t,n={};return t+=2,n.mbox=De.decode(e,t,{mail:!0})||".",t+=De.decode.bytes,n.txt=De.decode(e,t)||".",t+=De.decode.bytes,Ni.decode.bytes=t-r,n};Ni.decode.bytes=0;Ni.encodingLength=function(e){return 2+De.encodingLength(e.mbox||".")+De.encodingLength(e.txt||".")};var Ar={};Ar.encode=function(e,t,r){t||(t=ke.alloc(Ar.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=Rn.decode(e,t+8),t+=8+Rn.decode.bytes;else{let i=e.readUInt16BE(t+2);r.ttl=e.readUInt32BE(t+4),r.class=Zf.toString(i&gD),r.flush=!!(i&c0);let a=l0(r.type);r.data=a.decode(e,t+8),t+=8+a.decode.bytes}return Dr.decode.bytes=t-n,r};Dr.decode.bytes=0;Dr.encodingLength=function(e){let t=e.data!==null&&e.data!==void 0?e.data:e.options;return De.encodingLength(e.name)+8+l0(e.type).encodingLength(t)};var pi=Ne.question={};pi.encode=function(e,t,r){t||(t=ke.alloc(pi.encodingLength(e))),r||(r=0);let n=r;return De.encode(e.name,t,r),r+=De.encode.bytes,t.writeUInt16BE(Bs.toType(e.type),r),r+=2,t.writeUInt16BE(Zf.toClass(e.class===void 0?"IN":e.class),r),r+=2,pi.encode.bytes=r-n,e};pi.encode.bytes=0;pi.decode=function(e,t){t||(t=0);let r=t,n={};return n.name=De.decode(e,t),t+=De.decode.bytes,n.type=Bs.toString(e.readUInt16BE(t)),t+=2,n.class=Zf.toString(e.readUInt16BE(t)),t+=2,!!(n.class&ME)&&(n.class&=mD),pi.decode.bytes=t-r,n};pi.decode.bytes=0;pi.encodingLength=function(e){return De.encodingLength(e.name)+4};Ne.AUTHORITATIVE_ANSWER=1024;Ne.TRUNCATED_RESPONSE=512;Ne.RECURSION_DESIRED=256;Ne.RECURSION_AVAILABLE=128;Ne.AUTHENTIC_DATA=32;Ne.CHECKING_DISABLED=16;Ne.DNSSEC_OK=32768;Ne.encode=function(e,t,r){let n=!t;n&&(t=ke.alloc(Ne.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=[]),di.encode(e,t,r),r+=di.encode.bytes,r=Uc(e.questions,pi,t,r),r=Uc(e.answers,Dr,t,r),r=Uc(e.authorities,Dr,t,r),r=Uc(e.additionals,Dr,t,r),Ne.encode.bytes=r-i,n&&Ne.encode.bytes!==t.length?t.slice(0,Ne.encode.bytes):t};Ne.encode.bytes=0;Ne.decode=function(e,t){t||(t=0);let r=t,n=di.decode(e,t);return t+=di.decode.bytes,t=Jf(n.questions,pi,e,t),t=Jf(n.answers,Dr,e,t),t=Jf(n.authorities,Dr,e,t),t=Jf(n.additionals,Dr,e,t),Ne.decode.bytes=t-r,n};Ne.decode.bytes=0;Ne.encodingLength=function(e){return di.encodingLength(e)+Ao(e.questions||[],pi)+Ao(e.answers||[],Dr)+Ao(e.authorities||[],Dr)+Ao(e.additionals||[],Dr)};Ne.streamEncode=function(e){let t=Ne.encode(e),r=ke.alloc(2);r.writeUInt16BE(t.byteLength);let n=ke.concat([r,t]);return Ne.streamEncode.bytes=n.byteLength,n};Ne.streamEncode.bytes=0;Ne.streamDecode=function(e){let t=e.readUInt16BE(0);if(e.byteLength{(function(){var e,t="4.17.21",r=200,n="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",i="Expected a function",a="Invalid `variable` option passed into `_.template`",s="__lodash_hash_undefined__",o=500,l="__lodash_placeholder__",h=1,d=2,E=4,p=1,f=2,w=1,g=2,y=4,A=8,S=16,_=32,I=64,D=128,H=256,V=512,F=30,P="...",k=800,L=16,q=1,J=2,z=3,K=1/0,X=9007199254740991,ie=17976931348623157e292,be=NaN,ye=4294967295,$e=ye-1,qe=ye>>>1,ce=[["ary",D],["bind",w],["bindKey",g],["curry",A],["curryRight",S],["flip",V],["partial",_],["partialRight",I],["rearg",H]],_e="[object Arguments]",Le="[object Array]",lr="[object AsyncFunction]",Bt="[object Boolean]",pt="[object Date]",zt="[object DOMException]",Tt="[object Error]",nt="[object Function]",It="[object GeneratorFunction]",tt="[object Map]",gt="[object Number]",Yt="[object Null]",Je="[object Object]",Ut="[object Promise]",Un="[object Proxy]",fr="[object RegExp]",wr="[object Set]",Zt="[object String]",$r="[object Symbol]",la="[object Undefined]",Mr="[object WeakMap]",mt="[object WeakSet]",Qt="[object ArrayBuffer]",Ze="[object DataView]",Pr="[object Float32Array]",fa="[object Float64Array]",ha="[object Int8Array]",pa="[object Int16Array]",da="[object Int32Array]",Gi="[object Uint8Array]",ga="[object Uint8ClampedArray]",Os="[object Uint16Array]",gi="[object Uint32Array]",zi=/\b__p \+= '';/g,uu=/\b(__p \+=) '' \+/g,ou=/(__e\(.*?\)|\b__t\)) \+\n'';/g,cu=/&(?:amp|lt|gt|quot|#39);/g,lu=/[&<>"']/g,fu=RegExp(cu.source),hu=RegExp(lu.source),pu=/<%-([\s\S]+?)%>/g,Do=/<%([\s\S]+?)%>/g,du=/<%=([\s\S]+?)%>/g,Bo=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,$o=/^\w*$/,Po=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ns=/[\\^$.*+?()[\]{}|]/g,Ro=RegExp(Ns.source),ma=/^\s+/,To=/\s/,xo=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Oo=/\{\n\/\* \[wrapped with (.+)\] \*/,No=/,? & /,ko=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Lo=/[()=,{}\[\]\/\s]/,Uo=/\\(\\)?/g,Ho=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,mi=/\w*$/,gu=/^[-+]0x[0-9a-f]+$/i,jo=/^0b[01]+$/i,Mo=/^\[object .+?Constructor\]$/,qo=/^0o[0-7]+$/i,mu=/^(?:0|[1-9]\d*)$/,vi=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,en=/($^)/,Vo=/['\n\r\u2028\u2029\\]/g,ks="\\ud800-\\udfff",En="\\u0300-\\u036f",Ko="\\ufe20-\\ufe2f",Go="\\u20d0-\\u20ff",vu=En+Ko+Go,va="\\u2700-\\u27bf",Eu="a-z\\xdf-\\xf6\\xf8-\\xff",Ls="\\xac\\xb1\\xd7\\xf7",Ht="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",zo="\\u2000-\\u206f",Yo=" \\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",Au="A-Z\\xc0-\\xd6\\xd8-\\xde",Ei="\\ufe0e\\ufe0f",hr=Ls+Ht+zo+Yo,Rt="['\u2019]",Wo="["+ks+"]",Ea="["+hr+"]",pr="["+vu+"]",Aa="\\d+",wu="["+va+"]",yu="["+Eu+"]",wa="[^"+ks+hr+Aa+va+Eu+Au+"]",Ai="\\ud83c[\\udffb-\\udfff]",ya="(?:"+pr+"|"+Ai+")",Su="[^"+ks+"]",Sa="(?:\\ud83c[\\udde6-\\uddff]){2}",ba="[\\ud800-\\udbff][\\udc00-\\udfff]",qr="["+Au+"]",R="\\u200d",x="(?:"+yu+"|"+wa+")",j="(?:"+qr+"|"+wa+")",Q="(?:"+Rt+"(?:d|ll|m|re|s|t|ve))?",de="(?:"+Rt+"(?:D|LL|M|RE|S|T|VE))?",ve=ya+"?",Fe="["+Ei+"]?",Pe="(?:"+R+"(?:"+[Su,Sa,ba].join("|")+")"+Fe+ve+")*",St="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",jt="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",yr=Fe+ve+Pe,Sr="(?:"+[wu,Sa,ba].join("|")+")"+yr,An="(?:"+[Su+pr+"?",pr,Sa,ba,Wo].join("|")+")",Us=RegExp(Rt,"g"),Vr=RegExp(pr,"g"),br=RegExp(Ai+"(?="+Ai+")|"+An+yr,"g"),Hs=RegExp([qr+"?"+yu+"+"+Q+"(?="+[Ea,qr,"$"].join("|")+")",j+"+"+de+"(?="+[Ea,qr+x,"$"].join("|")+")",qr+"?"+x+"+"+Q,qr+"+"+de,jt,St,Aa,Sr].join("|"),"g"),Hn=RegExp("["+R+ks+vu+Ei+"]"),Ca=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Eh=["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"],Ah=-1,Dt={};Dt[Pr]=Dt[fa]=Dt[ha]=Dt[pa]=Dt[da]=Dt[Gi]=Dt[ga]=Dt[Os]=Dt[gi]=!0,Dt[_e]=Dt[Le]=Dt[Qt]=Dt[Bt]=Dt[Ze]=Dt[pt]=Dt[Tt]=Dt[nt]=Dt[tt]=Dt[gt]=Dt[Je]=Dt[fr]=Dt[wr]=Dt[Zt]=Dt[Mr]=!1;var Ft={};Ft[_e]=Ft[Le]=Ft[Qt]=Ft[Ze]=Ft[Bt]=Ft[pt]=Ft[Pr]=Ft[fa]=Ft[ha]=Ft[pa]=Ft[da]=Ft[tt]=Ft[gt]=Ft[Je]=Ft[fr]=Ft[wr]=Ft[Zt]=Ft[$r]=Ft[Gi]=Ft[ga]=Ft[Os]=Ft[gi]=!0,Ft[Tt]=Ft[nt]=Ft[Mr]=!1;var wh={\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"},yh={"&":"&","<":"<",">":">",'"':""","'":"'"},Sh={"&":"&","<":"<",">":">",""":'"',"'":"'"},bh={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Ch=parseFloat,Fh=parseInt,Qc=typeof global=="object"&&global&&global.Object===Object&&global,_h=typeof self=="object"&&self&&self.Object===Object&&self,er=Qc||_h||Function("return this")(),Xo=typeof yo=="object"&&yo&&!yo.nodeType&&yo,Yi=Xo&&typeof Hc=="object"&&Hc&&!Hc.nodeType&&Hc,el=Yi&&Yi.exports===Xo,Jo=el&&Qc.process,tn=function(){try{var re=Yi&&Yi.require&&Yi.require("util").types;return re||Jo&&Jo.binding&&Jo.binding("util")}catch{}}(),tl=tn&&tn.isArrayBuffer,rl=tn&&tn.isDate,nl=tn&&tn.isMap,il=tn&&tn.isRegExp,sl=tn&&tn.isSet,al=tn&&tn.isTypedArray;function Kr(re,le,ue){switch(ue.length){case 0:return re.call(le);case 1:return re.call(le,ue[0]);case 2:return re.call(le,ue[0],ue[1]);case 3:return re.call(le,ue[0],ue[1],ue[2])}return re.apply(le,ue)}function Ih(re,le,ue,Re){for(var Ge=-1,ct=re==null?0:re.length;++Ge-1}function Fa(re,le,ue){for(var Re=-1,Ge=re==null?0:re.length;++Re-1;);return ue}function ll(re,le){for(var ue=re.length;ue--&&js(le,re[ue],0)>-1;);return ue}function fl(re,le){for(var ue=re.length,Re=0;ue--;)re[ue]===le&&++Re;return Re}var nc=pe(wh),$h=pe(yh);function hl(re){return"\\"+bh[re]}function Ph(re,le){return re==null?e:re[le]}function Xi(re){return Hn.test(re)}function Rh(re){return Ca.test(re)}function Th(re){for(var le,ue=[];!(le=re.next()).done;)ue.push(le.value);return ue}function ic(re){var le=-1,ue=Array(re.size);return re.forEach(function(Re,Ge){ue[++le]=[Ge,Re]}),ue}function Cr(re,le){return function(ue){return re(le(ue))}}function Sn(re,le){for(var ue=-1,Re=re.length,Ge=0,ct=[];++ue-1}function zw(u,c){var v=this.__data__,C=Cl(v,u);return C<0?(++this.size,v.push([u,c])):v[C][1]=c,this}ts.prototype.clear=qw,ts.prototype.delete=Vw,ts.prototype.get=Kw,ts.prototype.has=Gw,ts.prototype.set=zw;function rs(u){var c=-1,v=u==null?0:u.length;for(this.clear();++c=c?u:c)),u}function Vn(u,c,v,C,T,U){var Y,Z=c&h,ne=c&d,ge=c&E;if(v&&(Y=T?v(u,C,T,U):v(u)),Y!==e)return Y;if(!Nt(u))return u;var me=We(u);if(me){if(Y=Jy(u),!Z)return an(u,Y)}else{var Ee=xr(u),Ie=Ee==nt||Ee==It;if(Gs(u))return I1(u,Z);if(Ee==Je||Ee==_e||Ie&&!T){if(Y=ne||Ie?{}:G1(u),!Z)return ne?Hy(u,cy(Y,u)):Uy(u,n1(Y,u))}else{if(!Ft[Ee])return T?u:{};Y=Zy(u,Ee,Z)}}U||(U=new ii);var Oe=U.get(u);if(Oe)return Oe;U.set(u,Y),yg(u)?u.forEach(function(Ke){Y.add(Vn(Ke,c,v,Ke,u,U))}):Ag(u)&&u.forEach(function(Ke,ut){Y.set(ut,Vn(Ke,c,v,ut,u,U))});var Ve=ge?ne?hp:fp:ne?on:dr,rt=me?e:Ve(u);return rn(rt||u,function(Ke,ut){rt&&(ut=Ke,Ke=u[ut]),cc(Y,ut,Vn(Ke,c,v,ut,u,U))}),Y}function ly(u){var c=dr(u);return function(v){return i1(v,u,c)}}function i1(u,c,v){var C=v.length;if(u==null)return!C;for(u=bt(u);C--;){var T=v[C],U=c[T],Y=u[T];if(Y===e&&!(T in u)||!U(Y))return!1}return!0}function s1(u,c,v){if(typeof u!="function")throw new sn(i);return mc(function(){u.apply(e,v)},c)}function lc(u,c,v,C){var T=-1,U=Gr,Y=!0,Z=u.length,ne=[],ge=c.length;if(!Z)return ne;v&&(c=te(c,Rr(v))),C?(U=Fa,Y=!1):c.length>=r&&(U=Ia,Y=!1,c=new Ba(c));e:for(;++TT?0:T+v),C=C===e||C>T?T:et(C),C<0&&(C+=T),C=v>C?0:bg(C);v0&&v(Z)?c>1?Fr(Z,c-1,v,C,T):yn(T,Z):C||(T[T.length]=Z)}return T}var zh=T1(),o1=T1(!0);function yi(u,c){return u&&zh(u,c,dr)}function Yh(u,c){return u&&o1(u,c,dr)}function _l(u,c){return wn(c,function(v){return us(u[v])})}function Pa(u,c){c=Vs(c,u);for(var v=0,C=c.length;u!=null&&vc}function py(u,c){return u!=null&&ht.call(u,c)}function dy(u,c){return u!=null&&c in bt(u)}function gy(u,c,v){return u>=Tr(c,v)&&u=120&&me.length>=120)?new Ba(Y&&me):e}me=u[0];var Ee=-1,Ie=Z[0];e:for(;++Ee-1;)Z!==u&&vt.call(Z,ne,1),vt.call(u,ne,1);return u}function A1(u,c){for(var v=u?c.length:0,C=v-1;v--;){var T=c[v];if(v==C||T!==U){var U=T;as(T)?vt.call(u,T,1):ip(u,T)}}return u}function tp(u,c){return u+se(Q0()*(c-u+1))}function Dy(u,c,v,C){for(var T=-1,U=ir(M((c-u)/(v||1)),0),Y=ue(U);U--;)Y[C?U:++T]=u,u+=v;return Y}function rp(u,c){var v="";if(!u||c<1||c>X)return v;do c%2&&(v+=u),c=se(c/2),c&&(u+=u);while(c);return v}function it(u,c){return Ap(W1(u,c,cn),u+"")}function By(u){return r1(qu(u))}function $y(u,c){var v=qu(u);return kl(v,$a(c,0,v.length))}function pc(u,c,v,C){if(!Nt(u))return u;c=Vs(c,u);for(var T=-1,U=c.length,Y=U-1,Z=u;Z!=null&&++TT?0:T+c),v=v>T?T:v,v<0&&(v+=T),T=c>v?0:v-c>>>0,c>>>=0;for(var U=ue(T);++C>>1,Y=u[U];Y!==null&&!Fn(Y)&&(v?Y<=c:Y=r){var ge=c?null:Vy(u);if(ge)return bn(ge);Y=!1,T=Ia,ne=new Ba}else ne=c?[]:Z;e:for(;++C=C?u:Kn(u,c,v)}var _1=b||function(u){return er.clearTimeout(u)};function I1(u,c){if(c)return u.slice();var v=u.length,C=vl?vl(v):new u.constructor(v);return u.copy(C),C}function op(u){var c=new u.constructor(u.byteLength);return new Tu(c).set(new Tu(u)),c}function Oy(u,c){var v=c?op(u.buffer):u.buffer;return new u.constructor(v,u.byteOffset,u.byteLength)}function Ny(u){var c=new u.constructor(u.source,mi.exec(u));return c.lastIndex=u.lastIndex,c}function ky(u){return oc?bt(oc.call(u)):{}}function D1(u,c){var v=c?op(u.buffer):u.buffer;return new u.constructor(v,u.byteOffset,u.length)}function B1(u,c){if(u!==c){var v=u!==e,C=u===null,T=u===u,U=Fn(u),Y=c!==e,Z=c===null,ne=c===c,ge=Fn(c);if(!Z&&!ge&&!U&&u>c||U&&Y&&ne&&!Z&&!ge||C&&Y&&ne||!v&&ne||!T)return 1;if(!C&&!U&&!ge&&u=Z)return ne;var ge=v[C];return ne*(ge=="desc"?-1:1)}}return u.index-c.index}function $1(u,c,v,C){for(var T=-1,U=u.length,Y=v.length,Z=-1,ne=c.length,ge=ir(U-Y,0),me=ue(ne+ge),Ee=!C;++Z1?v[T-1]:e,Y=T>2?v[2]:e;for(U=u.length>3&&typeof U=="function"?(T--,U):e,Y&&Yr(v[0],v[1],Y)&&(U=T<3?e:U,T=1),c=bt(c);++C-1?T[U?c[Y]:Y]:e}}function N1(u){return ss(function(c){var v=c.length,C=v,T=qn.prototype.thru;for(u&&c.reverse();C--;){var U=c[C];if(typeof U!="function")throw new sn(i);if(T&&!Y&&Ol(U)=="wrapper")var Y=new qn([],!0)}for(C=Y?C:v;++C1&<.reverse(),me&&neZ))return!1;var ge=U.get(u),me=U.get(c);if(ge&&me)return ge==c&&me==u;var Ee=-1,Ie=!0,Oe=v&f?new Ba:e;for(U.set(u,c),U.set(c,u);++Ee1?"& ":"")+c[C],c=c.join(v>2?", ":" "),u.replace(xo,`{ /* [wrapped with `+c+`] */ `)}function e4(u){return We(u)||xa(u)||!!(wl&&u&&u[wl])}function as(u,c){var v=typeof u;return c=c??X,!!c&&(v=="number"||v!="symbol"&&mu.test(u))&&u>-1&&u%1==0&&u0){if(++c>=k)return arguments[0]}else c=0;return u.apply(e,arguments)}}function kl(u,c){var v=-1,C=u.length,T=C-1;for(c=c===e?C:c;++v1?u[c-1]:e;return v=typeof v=="function"?(u.pop(),v):e,ug(u,v)});function og(u){var c=N(u);return c.__chain__=!0,c}function f6(u,c){return c(u),u}function Ll(u,c){return c(u)}var h6=ss(function(u){var c=u.length,v=c?u[0]:0,C=this.__wrapped__,T=function(U){return Gh(U,u)};return c>1||this.__actions__.length||!(C instanceof ot)||!as(v)?this.thru(T):(C=C.slice(v,+v+(c?1:0)),C.__actions__.push({func:Ll,args:[T],thisArg:e}),new qn(C,this.__chain__).thru(function(U){return c&&!U.length&&U.push(e),U}))});function p6(){return og(this)}function d6(){return new qn(this.value(),this.__chain__)}function g6(){this.__values__===e&&(this.__values__=Sg(this.value()));var u=this.__index__>=this.__values__.length,c=u?e:this.__values__[this.__index__++];return{done:u,value:c}}function m6(){return this}function v6(u){for(var c,v=this;v instanceof bl;){var C=tg(v);C.__index__=0,C.__values__=e,c?T.__wrapped__=C:c=C;var T=C;v=v.__wrapped__}return T.__wrapped__=u,c}function E6(){var u=this.__wrapped__;if(u instanceof ot){var c=u;return this.__actions__.length&&(c=new ot(this)),c=c.reverse(),c.__actions__.push({func:Ll,args:[wp],thisArg:e}),new qn(c,this.__chain__)}return this.thru(wp)}function A6(){return C1(this.__wrapped__,this.__actions__)}var w6=$l(function(u,c,v){ht.call(u,v)?++u[v]:ns(u,v,1)});function y6(u,c,v){var C=We(u)?Ye:fy;return v&&Yr(u,c,v)&&(c=e),C(u,je(c,3))}function S6(u,c){var v=We(u)?wn:u1;return v(u,je(c,3))}var b6=O1(rg),C6=O1(ng);function F6(u,c){return Fr(Ul(u,c),1)}function _6(u,c){return Fr(Ul(u,c),K)}function I6(u,c,v){return v=v===e?1:et(v),Fr(Ul(u,c),v)}function cg(u,c){var v=We(u)?rn:Ms;return v(u,je(c,3))}function lg(u,c){var v=We(u)?B:a1;return v(u,je(c,3))}var D6=$l(function(u,c,v){ht.call(u,v)?u[v].push(c):ns(u,v,[c])});function B6(u,c,v,C){u=un(u)?u:qu(u),v=v&&!C?et(v):0;var T=u.length;return v<0&&(v=ir(T+v,0)),Vl(u)?v<=T&&u.indexOf(c,v)>-1:!!T&&js(u,c,v)>-1}var $6=it(function(u,c,v){var C=-1,T=typeof c=="function",U=un(u)?ue(u.length):[];return Ms(u,function(Y){U[++C]=T?Kr(c,Y,v):fc(Y,c,v)}),U}),P6=$l(function(u,c,v){ns(u,v,c)});function Ul(u,c){var v=We(u)?te:p1;return v(u,je(c,3))}function R6(u,c,v,C){return u==null?[]:(We(c)||(c=c==null?[]:[c]),v=C?e:v,We(v)||(v=v==null?[]:[v]),v1(u,c,v))}var T6=$l(function(u,c,v){u[v?0:1].push(c)},function(){return[[],[]]});function x6(u,c,v){var C=We(u)?Zo:ol,T=arguments.length<3;return C(u,je(c,4),v,T,Ms)}function O6(u,c,v){var C=We(u)?J0:ol,T=arguments.length<3;return C(u,je(c,4),v,T,a1)}function N6(u,c){var v=We(u)?wn:u1;return v(u,Ml(je(c,3)))}function k6(u){var c=We(u)?r1:By;return c(u)}function L6(u,c,v){(v?Yr(u,c,v):c===e)?c=1:c=et(c);var C=We(u)?ay:$y;return C(u,c)}function U6(u){var c=We(u)?uy:Ry;return c(u)}function H6(u){if(u==null)return 0;if(un(u))return Vl(u)?Ji(u):u.length;var c=xr(u);return c==tt||c==wr?u.size:Zh(u).length}function j6(u,c,v){var C=We(u)?ul:Ty;return v&&Yr(u,c,v)&&(c=e),C(u,je(c,3))}var M6=it(function(u,c){if(u==null)return[];var v=c.length;return v>1&&Yr(u,c[0],c[1])?c=[]:v>2&&Yr(c[0],c[1],c[2])&&(c=[c[0]]),v1(u,Fr(c,1),[])}),Hl=O||function(){return er.Date.now()};function q6(u,c){if(typeof c!="function")throw new sn(i);return u=et(u),function(){if(--u<1)return c.apply(this,arguments)}}function fg(u,c,v){return c=v?e:c,c=u&&c==null?u.length:c,is(u,D,e,e,e,e,c)}function hg(u,c){var v;if(typeof c!="function")throw new sn(i);return u=et(u),function(){return--u>0&&(v=c.apply(this,arguments)),u<=1&&(c=e),v}}var Sp=it(function(u,c,v){var C=w;if(v.length){var T=Sn(v,ju(Sp));C|=_}return is(u,C,c,v,T)}),pg=it(function(u,c,v){var C=w|g;if(v.length){var T=Sn(v,ju(pg));C|=_}return is(c,C,u,v,T)});function dg(u,c,v){c=v?e:c;var C=is(u,A,e,e,e,e,e,c);return C.placeholder=dg.placeholder,C}function gg(u,c,v){c=v?e:c;var C=is(u,S,e,e,e,e,e,c);return C.placeholder=gg.placeholder,C}function mg(u,c,v){var C,T,U,Y,Z,ne,ge=0,me=!1,Ee=!1,Ie=!0;if(typeof u!="function")throw new sn(i);c=zn(c)||0,Nt(v)&&(me=!!v.leading,Ee="maxWait"in v,U=Ee?ir(zn(v.maxWait)||0,c):U,Ie="trailing"in v?!!v.trailing:Ie);function Oe(Xt){var ai=C,cs=T;return C=T=e,ge=Xt,Y=u.apply(cs,ai),Y}function Ve(Xt){return ge=Xt,Z=mc(ut,c),me?Oe(Xt):Y}function rt(Xt){var ai=Xt-ne,cs=Xt-ge,Og=c-ai;return Ee?Tr(Og,U-cs):Og}function Ke(Xt){var ai=Xt-ne,cs=Xt-ge;return ne===e||ai>=c||ai<0||Ee&&cs>=U}function ut(){var Xt=Hl();if(Ke(Xt))return lt(Xt);Z=mc(ut,rt(Xt))}function lt(Xt){return Z=e,Ie&&C?Oe(Xt):(C=T=e,Y)}function _n(){Z!==e&&_1(Z),ge=0,C=ne=T=Z=e}function Wr(){return Z===e?Y:lt(Hl())}function In(){var Xt=Hl(),ai=Ke(Xt);if(C=arguments,T=this,ne=Xt,ai){if(Z===e)return Ve(ne);if(Ee)return _1(Z),Z=mc(ut,c),Oe(ne)}return Z===e&&(Z=mc(ut,c)),Y}return In.cancel=_n,In.flush=Wr,In}var V6=it(function(u,c){return s1(u,1,c)}),K6=it(function(u,c,v){return s1(u,zn(c)||0,v)});function G6(u){return is(u,V)}function jl(u,c){if(typeof u!="function"||c!=null&&typeof c!="function")throw new sn(i);var v=function(){var C=arguments,T=c?c.apply(this,C):C[0],U=v.cache;if(U.has(T))return U.get(T);var Y=u.apply(this,C);return v.cache=U.set(T,Y)||U,Y};return v.cache=new(jl.Cache||rs),v}jl.Cache=rs;function Ml(u){if(typeof u!="function")throw new sn(i);return function(){var c=arguments;switch(c.length){case 0:return!u.call(this);case 1:return!u.call(this,c[0]);case 2:return!u.call(this,c[0],c[1]);case 3:return!u.call(this,c[0],c[1],c[2])}return!u.apply(this,c)}}function z6(u){return hg(2,u)}var Y6=xy(function(u,c){c=c.length==1&&We(c[0])?te(c[0],Rr(je())):te(Fr(c,1),Rr(je()));var v=c.length;return it(function(C){for(var T=-1,U=Tr(C.length,v);++T=c}),xa=l1(function(){return arguments}())?l1:function(u){return qt(u)&&ht.call(u,"callee")&&!Al.call(u,"callee")},We=ue.isArray,cS=tl?Rr(tl):vy;function un(u){return u!=null&&ql(u.length)&&!us(u)}function Wt(u){return qt(u)&&un(u)}function lS(u){return u===!0||u===!1||qt(u)&&zr(u)==Bt}var Gs=Ct||xp,fS=rl?Rr(rl):Ey;function hS(u){return qt(u)&&u.nodeType===1&&!vc(u)}function pS(u){if(u==null)return!0;if(un(u)&&(We(u)||typeof u=="string"||typeof u.splice=="function"||Gs(u)||Mu(u)||xa(u)))return!u.length;var c=xr(u);if(c==tt||c==wr)return!u.size;if(gc(u))return!Zh(u).length;for(var v in u)if(ht.call(u,v))return!1;return!0}function dS(u,c){return hc(u,c)}function gS(u,c,v){v=typeof v=="function"?v:e;var C=v?v(u,c):e;return C===e?hc(u,c,e,v):!!C}function Cp(u){if(!qt(u))return!1;var c=zr(u);return c==Tt||c==zt||typeof u.message=="string"&&typeof u.name=="string"&&!vc(u)}function mS(u){return typeof u=="number"&&Mt(u)}function us(u){if(!Nt(u))return!1;var c=zr(u);return c==nt||c==It||c==lr||c==Un}function Eg(u){return typeof u=="number"&&u==et(u)}function ql(u){return typeof u=="number"&&u>-1&&u%1==0&&u<=X}function Nt(u){var c=typeof u;return u!=null&&(c=="object"||c=="function")}function qt(u){return u!=null&&typeof u=="object"}var Ag=nl?Rr(nl):wy;function vS(u,c){return u===c||Jh(u,c,dp(c))}function ES(u,c,v){return v=typeof v=="function"?v:e,Jh(u,c,dp(c),v)}function AS(u){return wg(u)&&u!=+u}function wS(u){if(n4(u))throw new Ge(n);return f1(u)}function yS(u){return u===null}function SS(u){return u==null}function wg(u){return typeof u=="number"||qt(u)&&zr(u)==gt}function vc(u){if(!qt(u)||zr(u)!=Je)return!1;var c=xu(u);if(c===null)return!0;var v=ht.call(c,"constructor")&&c.constructor;return typeof v=="function"&&v instanceof v&&Bu.call(v)==Hh}var Fp=il?Rr(il):yy;function bS(u){return Eg(u)&&u>=-X&&u<=X}var yg=sl?Rr(sl):Sy;function Vl(u){return typeof u=="string"||!We(u)&&qt(u)&&zr(u)==Zt}function Fn(u){return typeof u=="symbol"||qt(u)&&zr(u)==$r}var Mu=al?Rr(al):by;function CS(u){return u===e}function FS(u){return qt(u)&&xr(u)==Mr}function _S(u){return qt(u)&&zr(u)==mt}var IS=xl(Qh),DS=xl(function(u,c){return u<=c});function Sg(u){if(!u)return[];if(un(u))return Vl(u)?nn(u):an(u);if(Qi&&u[Qi])return Th(u[Qi]());var c=xr(u),v=c==tt?ic:c==wr?bn:qu;return v(u)}function os(u){if(!u)return u===0?u:0;if(u=zn(u),u===K||u===-K){var c=u<0?-1:1;return c*ie}return u===u?u:0}function et(u){var c=os(u),v=c%1;return c===c?v?c-v:c:0}function bg(u){return u?$a(et(u),0,ye):0}function zn(u){if(typeof u=="number")return u;if(Fn(u))return be;if(Nt(u)){var c=typeof u.valueOf=="function"?u.valueOf():u;u=Nt(c)?c+"":c}if(typeof u!="string")return u===0?u:+u;u=rc(u);var v=jo.test(u);return v||qo.test(u)?Fh(u.slice(2),v?2:8):gu.test(u)?be:+u}function Cg(u){return Si(u,on(u))}function BS(u){return u?$a(et(u),-X,X):u===0?u:0}function wt(u){return u==null?"":Cn(u)}var $S=Uu(function(u,c){if(gc(c)||un(c)){Si(c,dr(c),u);return}for(var v in c)ht.call(c,v)&&cc(u,v,c[v])}),Fg=Uu(function(u,c){Si(c,on(c),u)}),Kl=Uu(function(u,c,v,C){Si(c,on(c),u,C)}),PS=Uu(function(u,c,v,C){Si(c,dr(c),u,C)}),RS=ss(Gh);function TS(u,c){var v=Lu(u);return c==null?v:n1(v,c)}var xS=it(function(u,c){u=bt(u);var v=-1,C=c.length,T=C>2?c[2]:e;for(T&&Yr(c[0],c[1],T)&&(C=1);++v1),U}),Si(u,hp(u),v),C&&(v=Vn(v,h|d|E,Ky));for(var T=c.length;T--;)ip(v,c[T]);return v});function ZS(u,c){return Ig(u,Ml(je(c)))}var QS=ss(function(u,c){return u==null?{}:_y(u,c)});function Ig(u,c){if(u==null)return{};var v=te(hp(u),function(C){return[C]});return c=je(c),E1(u,v,function(C,T){return c(C,T[0])})}function e5(u,c,v){c=Vs(c,u);var C=-1,T=c.length;for(T||(T=1,u=e);++Cc){var C=u;u=c,c=C}if(v||u%1||c%1){var T=Q0();return Tr(u+T*(c-u+Ch("1e-"+((T+"").length-1))),c)}return tp(u,c)}var f5=Hu(function(u,c,v){return c=c.toLowerCase(),u+(v?$g(c):c)});function $g(u){return Dp(wt(u).toLowerCase())}function Pg(u){return u=wt(u),u&&u.replace(vi,nc).replace(Vr,"")}function h5(u,c,v){u=wt(u),c=Cn(c);var C=u.length;v=v===e?C:$a(et(v),0,C);var T=v;return v-=c.length,v>=0&&u.slice(v,T)==c}function p5(u){return u=wt(u),u&&hu.test(u)?u.replace(lu,$h):u}function d5(u){return u=wt(u),u&&Ro.test(u)?u.replace(Ns,"\\$&"):u}var g5=Hu(function(u,c,v){return u+(v?"-":"")+c.toLowerCase()}),m5=Hu(function(u,c,v){return u+(v?" ":"")+c.toLowerCase()}),v5=x1("toLowerCase");function E5(u,c,v){u=wt(u),c=et(c);var C=c?Ji(u):0;if(!c||C>=c)return u;var T=(c-C)/2;return Tl(se(T),v)+u+Tl(M(T),v)}function A5(u,c,v){u=wt(u),c=et(c);var C=c?Ji(u):0;return c&&C>>0,v?(u=wt(u),u&&(typeof c=="string"||c!=null&&!Fp(c))&&(c=Cn(c),!c&&Xi(u))?Ks(nn(u),0,v):u.split(c,v)):[]}var _5=Hu(function(u,c,v){return u+(v?" ":"")+Dp(c)});function I5(u,c,v){return u=wt(u),v=v==null?0:$a(et(v),0,u.length),c=Cn(c),u.slice(v,v+c.length)==c}function D5(u,c,v){var C=N.templateSettings;v&&Yr(u,c,v)&&(c=e),u=wt(u),c=Kl({},c,C,j1);var T=Kl({},c.imports,C.imports,j1),U=dr(T),Y=_a(T,U),Z,ne,ge=0,me=c.interpolate||en,Ee="__p += '",Ie=Iu((c.escape||en).source+"|"+me.source+"|"+(me===du?Ho:en).source+"|"+(c.evaluate||en).source+"|$","g"),Oe="//# sourceURL="+(ht.call(c,"sourceURL")?(c.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Ah+"]")+` `;u.replace(Ie,function(Ke,ut,lt,_n,Wr,In){return lt||(lt=_n),Ee+=u.slice(ge,In).replace(Vo,hl),ut&&(Z=!0,Ee+=`' + __e(`+ut+`) + '`),Wr&&(ne=!0,Ee+=`'; `+Wr+`; __p += '`),lt&&(Ee+=`' + ((__t = (`+lt+`)) == null ? '' : __t) + '`),ge=In+Ke.length,Ke}),Ee+=`'; `;var Ve=ht.call(c,"variable")&&c.variable;if(!Ve)Ee=`with (obj) { `+Ee+` } `;else if(Lo.test(Ve))throw new Ge(a);Ee=(ne?Ee.replace(zi,""):Ee).replace(uu,"$1").replace(ou,"$1;"),Ee="function("+(Ve||"obj")+`) { `+(Ve?"":`obj || (obj = {}); `)+"var __t, __p = ''"+(Z?", __e = _.escape":"")+(ne?`, __j = Array.prototype.join; function print() { __p += __j.call(arguments, '') } `:`; `)+Ee+`return __p }`;var rt=Tg(function(){return ct(U,Oe+"return "+Ee).apply(e,Y)});if(rt.source=Ee,Cp(rt))throw rt;return rt}function B5(u){return wt(u).toLowerCase()}function $5(u){return wt(u).toUpperCase()}function P5(u,c,v){if(u=wt(u),u&&(v||c===e))return rc(u);if(!u||!(c=Cn(c)))return u;var C=nn(u),T=nn(c),U=Cu(C,T),Y=ll(C,T)+1;return Ks(C,U,Y).join("")}function R5(u,c,v){if(u=wt(u),u&&(v||c===e))return u.slice(0,_u(u)+1);if(!u||!(c=Cn(c)))return u;var C=nn(u),T=ll(C,nn(c))+1;return Ks(C,0,T).join("")}function T5(u,c,v){if(u=wt(u),u&&(v||c===e))return u.replace(ma,"");if(!u||!(c=Cn(c)))return u;var C=nn(u),T=Cu(C,nn(c));return Ks(C,T).join("")}function x5(u,c){var v=F,C=P;if(Nt(c)){var T="separator"in c?c.separator:T;v="length"in c?et(c.length):v,C="omission"in c?Cn(c.omission):C}u=wt(u);var U=u.length;if(Xi(u)){var Y=nn(u);U=Y.length}if(v>=U)return u;var Z=v-Ji(C);if(Z<1)return C;var ne=Y?Ks(Y,0,Z).join(""):u.slice(0,Z);if(T===e)return ne+C;if(Y&&(Z+=ne.length-Z),Fp(T)){if(u.slice(Z).search(T)){var ge,me=ne;for(T.global||(T=Iu(T.source,wt(mi.exec(T))+"g")),T.lastIndex=0;ge=T.exec(me);)var Ee=ge.index;ne=ne.slice(0,Ee===e?Z:Ee)}}else if(u.indexOf(Cn(T),Z)!=Z){var Ie=ne.lastIndexOf(T);Ie>-1&&(ne=ne.slice(0,Ie))}return ne+C}function O5(u){return u=wt(u),u&&fu.test(u)?u.replace(cu,dl):u}var N5=Hu(function(u,c,v){return u+(v?" ":"")+c.toUpperCase()}),Dp=x1("toUpperCase");function Rg(u,c,v){return u=wt(u),c=v?e:c,c===e?Rh(u)?Nh(u):Qo(u):u.match(c)||[]}var Tg=it(function(u,c){try{return Kr(u,e,c)}catch(v){return Cp(v)?v:new Ge(v)}}),k5=ss(function(u,c){return rn(c,function(v){v=bi(v),ns(u,v,Sp(u[v],u))}),u});function L5(u){var c=u==null?0:u.length,v=je();return u=c?te(u,function(C){if(typeof C[1]!="function")throw new sn(i);return[v(C[0]),C[1]]}):[],it(function(C){for(var T=-1;++TX)return[];var v=ye,C=Tr(u,ye);c=je(c),u-=ye;for(var T=tc(C,c);++v0||c<0)?new ot(v):(u<0?v=v.takeRight(-u):u&&(v=v.drop(u)),c!==e&&(c=et(c),v=c<0?v.dropRight(-c):v.take(c-u)),v)},ot.prototype.takeRightWhile=function(u){return this.reverse().takeWhile(u).reverse()},ot.prototype.toArray=function(){return this.take(ye)},yi(ot.prototype,function(u,c){var v=/^(?:filter|find|map|reject)|While$/.test(c),C=/^(?:head|last)$/.test(c),T=N[C?"take"+(c=="last"?"Right":""):c],U=C||/^find/.test(c);T&&(N.prototype[c]=function(){var Y=this.__wrapped__,Z=C?[1]:arguments,ne=Y instanceof ot,ge=Z[0],me=ne||We(Y),Ee=function(ut){var lt=T.apply(N,yn([ut],Z));return C&&Ie?lt[0]:lt};me&&v&&typeof ge=="function"&&ge.length!=1&&(ne=me=!1);var Ie=this.__chain__,Oe=!!this.__actions__.length,Ve=U&&!Ie,rt=ne&&!Oe;if(!U&&me){Y=rt?Y:new ot(this);var Ke=u.apply(Y,Z);return Ke.__actions__.push({func:Ll,args:[Ee],thisArg:e}),new qn(Ke,Ie)}return Ve&&rt?u.apply(this,Z):(Ke=this.thru(Ee),Ve?C?Ke.value()[0]:Ke.value():Ke)})}),rn(["pop","push","shift","sort","splice","unshift"],function(u){var c=Du[u],v=/^(?:push|sort|unshift)$/.test(u)?"tap":"thru",C=/^(?:pop|shift)$/.test(u);N.prototype[u]=function(){var T=arguments;if(C&&!this.__chain__){var U=this.value();return c.apply(We(U)?U:[],T)}return this[v](function(Y){return c.apply(We(Y)?Y:[],T)})}}),yi(ot.prototype,function(u,c){var v=N[c];if(v){var C=v.name+"";ht.call(ku,C)||(ku[C]=[]),ku[C].push({name:c,func:v})}}),ku[Pl(e,g).name]=[{name:"wrapper",func:e}],ot.prototype.clone=Ow,ot.prototype.reverse=Nw,ot.prototype.value=kw,N.prototype.at=h6,N.prototype.chain=p6,N.prototype.commit=d6,N.prototype.next=g6,N.prototype.plant=v6,N.prototype.reverse=E6,N.prototype.toJSON=N.prototype.valueOf=N.prototype.value=A6,N.prototype.first=N.prototype.head,Qi&&(N.prototype[Qi]=m6),N},Mn=kh();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(er._=Mn,define(function(){return Mn})):Yi?((Yi.exports=Mn)._=Mn,Xo._=Mn):er._=Mn}).call(yo)});var lh=we(($O,cA)=>{"use strict";var a$=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])},S0=class e extends Error{constructor(t,r,n){super(t),a$(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,o=""){let l="",h=r.find(({source:E})=>E===a.source),d=a.start;if(h){let E=a.end,p=h.text[d.line-1],w=(d.line===E.line?E.column:p.length+1)-d.column||1;o&&(l+=` note: ${o}`),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}`,o&&(l+=`: ${o}`);return l}function i(a,s,o,l=[]){let h;o?h=l.reduce((E,{location:p})=>Math.max(E,p.start.line),o.start.line):h=Math.max.apply(null,l.map(E=>E.location.start.line)),h=h.toString().length;let d=`${a}: ${s}`;o&&(d+=n(o,h));for(let E of l)d+=n(E.location,h,E.message);return d}return this.problems.filter(a=>a[0]!=="info").map(a=>i(...a)).join(` `)}};cA.exports=S0});var ti=we((PO,lA)=>{"use strict";var u$={build(e){function t(s,...o){return e[s.type](s,...o)}function r(){}function n(s,...o){return t(s.expression,...o)}function i(s){return function(o,...l){o[s].forEach(h=>t(h,...l))}}let a={grammar(s,...o){s.topLevelInitializer&&t(s.topLevelInitializer,...o),s.initializer&&t(s.initializer,...o),s.rules.forEach(l=>t(l,...o))},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}};lA.exports=u$});var sa=we((RO,hA)=>{"use strict";var o$=ti(),fA={findRule(e,t){for(let r=0;r{"use strict";var c$={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};pA.exports=c$});var C0=we((xO,dA)=>{"use strict";var l$=ti(),f$=sa(),h$=lh(),Gc=1,au=0,zc=-1;function fh(e){function t(s){return s.match=au}function r(s){return a(s.expression),s.match=Gc}function n(s){return s.match=a(s.expression)}function i(s,o){let l=s.length,h=0,d=0;for(let E=0;E0?zc:au}let a=l$.build({rule(s){let o,l=0;if(typeof s.match>"u"){s.match=au;do if(o=s.match,s.match=a(s.expression),++l>6)throw new h$("Infinity cycle detected when trying to evaluate node match result",s.location);while(o!==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 o=f$.findRule(e,s.name);return s.match=a(o)},literal(s){let o=s.value.length===0?Gc:au;return s.match=o},class(s){let o=s.parts.length===0?zc:au;return s.match=o},any:t});a(e)}fh.ALWAYS_MATCH=Gc;fh.SOMETIMES_MATCH=au;fh.NEVER_MATCH=zc;dA.exports=fh});var mA=we((OO,gA)=>{"use strict";var p$=sa(),Be=b0(),d$=ti(),{ALWAYS_MATCH:Co,SOMETIMES_MATCH:F0,NEVER_MATCH:_0}=C0();function g$(e){let t=[],r=[],n=[],i=[];function a(S){let _=t.indexOf(S);return _===-1?t.push(S)-1:_}function s(S){let _={value:S.parts,inverted:S.inverted,ignoreCase:S.ignoreCase},I=JSON.stringify(_),D=r.findIndex(H=>JSON.stringify(H)===I);return D===-1?r.push(_)-1:D}function o(S){let _=JSON.stringify(S),I=n.findIndex(D=>JSON.stringify(D)===_);return I===-1?n.push(S)-1:I}function l(S,_,I){let D={predicate:S,params:_,body:I.code,location:I.codeLocation},H=JSON.stringify(D),V=i.findIndex(F=>JSON.stringify(F)===H);return V===-1?i.push(D)-1:V}function h(S){let _={};return Object.keys(S).forEach(I=>{_[I]=S[I]}),_}function d(S,..._){return S.concat(..._)}function E(S,_,I,D){return S===Co?I:S===_0?D:_.concat([I.length,D.length],I,D)}function p(S,_){return S.concat([_.length],_)}function f(S,_,I,D){let H=Object.keys(I).map(V=>D-I[V]);return[Be.CALL,S,_,H.length].concat(H)}function w(S,_,I){let D=S.match|0;return d([Be.PUSH_CURR_POS],[Be.SILENT_FAILS_ON],A(S,{sp:I.sp+1,env:h(I.env),action:null}),[Be.SILENT_FAILS_OFF],E(_?-D:D,[_?Be.IF_ERROR:Be.IF_NOT_ERROR],d([Be.POP],[_?Be.POP:Be.POP_CURR_POS],[Be.PUSH_UNDEFINED]),d([Be.POP],[_?Be.POP_CURR_POS:Be.POP],[Be.PUSH_FAILED])))}function g(S,_,I){let D=l(!0,Object.keys(I.env),S);return d([Be.UPDATE_SAVED_POS],f(D,0,I.env,I.sp),E(S.match|0,[Be.IF],d([Be.POP],_?[Be.PUSH_FAILED]:[Be.PUSH_UNDEFINED]),d([Be.POP],_?[Be.PUSH_UNDEFINED]:[Be.PUSH_FAILED])))}function y(S){return p([Be.WHILE_NOT_ERROR],d([Be.APPEND],S))}let A=d$.build({grammar(S){S.rules.forEach(A),S.literals=t,S.classes=r,S.expectations=n,S.functions=i},rule(S){S.bytecode=A(S.expression,{sp:-1,env:{},pluck:[],action:null})},named(S,_){let I=S.match|0,D=I===_0?null:o({type:"rule",value:S.name});return d([Be.SILENT_FAILS_ON],A(S.expression,_),[Be.SILENT_FAILS_OFF],E(I,[Be.IF_ERROR],[Be.FAIL,D],[]))},choice(S,_){function I(D,H){let V=D[0].match|0,F=A(D[0],{sp:H.sp,env:h(H.env),action:null});return V===Co?F:d(F,D.length>1?E(F0,[Be.IF_ERROR],d([Be.POP],I(D.slice(1),H)),[]):[])}return I(S.alternatives,_)},action(S,_){let I=h(_.env),D=S.expression.type!=="sequence"||S.expression.elements.length===0,H=A(S.expression,{sp:_.sp+(D?1:0),env:I,action:S}),V=S.expression.match|0,F=D&&V!==_0?l(!1,Object.keys(I),S):null;return D?d([Be.PUSH_CURR_POS],H,E(V,[Be.IF_NOT_ERROR],d([Be.LOAD_SAVED_POS,1],f(F,1,I,_.sp+2)),[]),[Be.NIP]):H},sequence(S,_){function I(D,H){if(D.length>0){let V=S.elements.length-D.length+1;return d(A(D[0],{sp:H.sp,env:H.env,pluck:H.pluck,action:null}),E(D[0].match|0,[Be.IF_NOT_ERROR],I(D.slice(1),{sp:H.sp+1,env:H.env,pluck:H.pluck,action:H.action}),d(V>1?[Be.POP_N,V]:[Be.POP],[Be.POP_CURR_POS],[Be.PUSH_FAILED])))}else{if(H.pluck.length>0)return d([Be.PLUCK,S.elements.length+1,H.pluck.length],H.pluck.map(V=>H.sp-V));if(H.action){let V=l(!1,Object.keys(H.env),H.action);return d([Be.LOAD_SAVED_POS,S.elements.length],f(V,S.elements.length+1,H.env,H.sp))}else return d([Be.WRAP,S.elements.length],[Be.NIP])}}return d([Be.PUSH_CURR_POS],I(S.elements,{sp:_.sp+1,env:_.env,pluck:[],action:_.action}))},labeled(S,_){let I=_.env,D=S.label,H=_.sp+1;return D&&(I=h(_.env),_.env[S.label]=H),S.pick&&_.pluck.push(H),A(S.expression,{sp:_.sp,env:I,action:null})},text(S,_){return d([Be.PUSH_CURR_POS],A(S.expression,{sp:_.sp+1,env:h(_.env),action:null}),E(S.match|0,[Be.IF_NOT_ERROR],d([Be.POP],[Be.TEXT]),[Be.NIP]))},simple_and(S,_){return w(S.expression,!1,_)},simple_not(S,_){return w(S.expression,!0,_)},optional(S,_){return d(A(S.expression,{sp:_.sp,env:h(_.env),action:null}),E(-(S.expression.match|0),[Be.IF_ERROR],d([Be.POP],[Be.PUSH_NULL]),[]))},zero_or_more(S,_){let I=A(S.expression,{sp:_.sp+1,env:h(_.env),action:null});return d([Be.PUSH_EMPTY_ARRAY],I,y(I),[Be.POP])},one_or_more(S,_){let I=A(S.expression,{sp:_.sp+1,env:h(_.env),action:null});return d([Be.PUSH_EMPTY_ARRAY],I,E(S.expression.match|0,[Be.IF_NOT_ERROR],d(y(I),[Be.POP]),d([Be.POP],[Be.POP],[Be.PUSH_FAILED])))},group(S,_){return A(S.expression,{sp:_.sp,env:h(_.env),action:null})},semantic_and(S,_){return g(S,!1,_)},semantic_not(S,_){return g(S,!0,_)},rule_ref(S){return[Be.RULE,p$.indexOfRule(e,S.name)]},literal(S){if(S.value.length>0){let _=S.match|0,D=_===F0||_===Co&&!S.ignoreCase?a(S.ignoreCase?S.value.toLowerCase():S.value):null,H=_!==Co?o({type:"literal",value:S.value,ignoreCase:S.ignoreCase}):null;return E(_,S.ignoreCase?[Be.MATCH_STRING_IC,D]:[Be.MATCH_STRING,D],S.ignoreCase?[Be.ACCEPT_N,S.value.length]:[Be.ACCEPT_STRING,D],[Be.FAIL,H])}return[Be.PUSH_EMPTY_STRING]},class(S){let _=S.match|0,I=_===F0?s(S):null,D=_!==Co?o({type:"class",value:S.parts,inverted:S.inverted,ignoreCase:S.ignoreCase}):null;return E(_,[Be.MATCH_CHAR_CLASS,I],[Be.ACCEPT_N,1],[Be.FAIL,D])},any(S){let _=S.match|0,I=_!==Co?o({type:"any"}):null;return E(_,[Be.MATCH_ANY],[Be.ACCEPT_N,1],[Be.FAIL,I])}});A(e)}gA.exports=g$});var EA=we((NO,vA)=>{"use strict";var I0=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+").")}};vA.exports=I0});var D0=we((kO,AA)=>{"use strict";AA.exports="2.0.1"});var wA=we(hh=>{"use strict";function Ts(e){return e.charCodeAt(0).toString(16).toUpperCase()}hh.hex=Ts;function m$(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"+Ts(t)).replace(/[\x10-\x1F\x7F-\xFF]/g,t=>"\\x"+Ts(t)).replace(/[\u0100-\u0FFF]/g,t=>"\\u0"+Ts(t)).replace(/[\u1000-\uFFFF]/g,t=>"\\u"+Ts(t))}hh.stringEscape=m$;function v$(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"+Ts(t)).replace(/[\x10-\x1F\x7F-\xFF]/g,t=>"\\x"+Ts(t)).replace(/[\u0100-\u0FFF]/g,t=>"\\u0"+Ts(t)).replace(/[\u1000-\uFFFF]/g,t=>"\\u"+Ts(t))}hh.regexpClassEscape=v$});var bA=we(SA=>{var yA="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");SA.encode=function(e){if(0<=e&&e{var E$=bA(),CA=5,FA=1<>>=CA,i>0&&(n|=w$),r+=E$.encode(n);while(i>0);return r}});var dh=we(oa=>{function S$(e,t,r){if(t in e)return e[t];if(arguments.length===3)return r;throw new Error('"'+t+'" is a required argument.')}oa.getArg=S$;var BA=function(){return!("__proto__"in Object.create(null))}();function $A(e){return e}function b$(e){return PA(e)?"$"+e:e}oa.toSetString=BA?$A:b$;function C$(e){return PA(e)?e.slice(1):e}oa.fromSetString=BA?$A:C$;function PA(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 DA(e,t){return e===t?0:e===null?1:t===null?-1:e>t?1:-1}function F$(e,t){let r=e.generatedLine-t.generatedLine;return r!==0||(r=e.generatedColumn-t.generatedColumn,r!==0)||(r=DA(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:DA(e.name,t.name)}oa.compareByGeneratedPositionsInflated=F$;var B0="http:",Yc=`${B0}//host`;function RA(e){return t=>{let r=Wc(t),n=$0(t),i=new URL(t,n);e(i);let a=i.toString();return r==="absolute"?a:r==="scheme-relative"?a.slice(B0.length):r==="path-absolute"?a.slice(Yc.length):P0(n,a)}}function aa(e,t){return new URL(e,t).toString()}function _$(e,t){let r=0;do{let n=e+r++;if(t.indexOf(n)===-1)return n}while(!0)}function $0(e){let t=e.split("..").length-1,r=_$("p",e),n=`${Yc}/`;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 D$=RA(e=>{e.pathname=e.pathname.replace(/\/?$/,"/")}),ph=RA(e=>{});oa.normalize=ph;function B$(e,t){let r=Wc(t),n=Wc(e);if(e=D$(e),r==="absolute")return aa(t,void 0);if(n==="absolute")return aa(t,e);if(r==="scheme-relative")return ph(t);if(n==="scheme-relative")return aa(t,aa(e,Yc)).slice(B0.length);if(r==="path-absolute")return ph(t);if(n==="path-absolute")return aa(t,aa(e,Yc)).slice(Yc.length);let i=$0(t+e),a=aa(t,aa(e,i));return P0(i,a)}oa.join=B$;function $$(e,t){let r=P$(e,t);return typeof r=="string"?r:ph(t)}oa.relative=$$;function P$(e,t){if(Wc(e)!==Wc(t))return null;let n=$0(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:P0(i,a)}});var xA=we(TA=>{var R0=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 OA=dh();function R$(e,t){let r=e.generatedLine,n=t.generatedLine,i=e.generatedColumn,a=t.generatedColumn;return n>r||n==r&&a>=i||OA.compareByGeneratedPositionsInflated(e,t)<=0}var T0=class{constructor(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}unsortedForEach(t,r){this._array.forEach(t,r)}add(t){R$(this._last,t)?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))}toArray(){return this._sorted||(this._array.sort(OA.compareByGeneratedPositionsInflated),this._sorted=!0),this._array}};NA.MappingList=T0});var x0=we(LA=>{var Xc=IA(),nr=dh(),gh=xA().ArraySet,T$=kA().MappingList,mh=class e{constructor(t){t||(t={}),this._file=nr.getArg(t,"file",null),this._sourceRoot=nr.getArg(t,"sourceRoot",null),this._skipValidation=nr.getArg(t,"skipValidation",!1),this._sources=new gh,this._names=new gh,this._mappings=new T$,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=nr.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=nr.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=nr.getArg(t,"generated"),n=nr.getArg(t,"original",null),i=nr.getArg(t,"source",null),a=nr.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=nr.relative(this._sourceRoot,n)),r!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[nr.toSetString(n)]=r):this._sourcesContents&&(delete this._sourcesContents[nr.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=nr.relative(a,i));let s=this._mappings.toArray().length>0?new gh:this._sources,o=new gh;this._mappings.unsortedForEach(function(l){if(l.source===i&&l.originalLine!=null){let E=t.originalPositionFor({line:l.originalLine,column:l.originalColumn});E.source!=null&&(l.source=E.source,n!=null&&(l.source=nr.join(n,l.source)),a!=null&&(l.source=nr.relative(a,l.source)),l.originalLine=E.line,l.originalColumn=E.column,E.name!=null&&(l.name=E.name))}let h=l.source;h!=null&&!s.has(h)&&s.add(h);let d=l.name;d!=null&&!o.has(d)&&o.add(d)},this),this._sources=s,this._names=o,t.sources.forEach(function(l){let h=t.sourceContentFor(l);h!=null&&(n!=null&&(l=nr.join(n,l)),a!=null&&(l=nr.relative(a,l)),this.setSourceContent(l,h))},this)}_validateMapping(t,r,n,i){if(r&&typeof r.line!="number"&&typeof r.column!="number")throw new Error("original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.");if(!(t&&"line"in t&&"column"in t&&t.line>0&&t.column>=0&&!r&&!n&&!i)){if(!(t&&"line"in t&&"column"in t&&r&&"line"in r&&"column"in r&&t.line>0&&t.column>=0&&r.line>0&&r.column>=0&&n))throw new Error("Invalid mapping: "+JSON.stringify({generated:t,source:n,original:r,name:i}))}}_serializeMappings(){let t=0,r=1,n=0,i=0,a=0,s=0,o="",l,h,d,E,p=this._mappings.toArray();for(let f=0,w=p.length;f0){if(!nr.compareByGeneratedPositionsInflated(h,p[f-1]))continue;l+=","}l+=Xc.encode(h.generatedColumn-t),t=h.generatedColumn,h.source!=null&&(E=this._sources.indexOf(h.source),l+=Xc.encode(E-s),s=E,l+=Xc.encode(h.originalLine-1-i),i=h.originalLine-1,l+=Xc.encode(h.originalColumn-n),n=h.originalColumn,h.name!=null&&(d=this._names.indexOf(h.name),l+=Xc.encode(d-a),a=d)),o+=l}return o}_generateSourcesContent(t,r){return t.map(function(n){if(!this._sourcesContents)return null;r!=null&&(n=nr.relative(r,n));let i=nr.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())}};mh.prototype._version=3;LA.SourceMapGenerator=mh});var HA=we(UA=>{var x$=x0().SourceMapGenerator,vh=dh(),O$=/(\r?\n)/,N$=10,Fo="$$$isSourceNode$$$",O0=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[Fo]=!0,i!=null&&this.add(i)}static fromStringWithSourceMap(t,r,n){let i=new e,a=t.split(O$),s=0,o=function(){let f=g(),w=g()||"";return f+w;function g(){return s=0;r--)this.prepend(t[r]);else if(t[Fo]||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{N0.SourceMapGenerator=x0().SourceMapGenerator;N0.SourceNode=HA().SourceNode});var KA=we((zO,VA)=>{"use strict";var k$=sa(),At=b0(),L$=EA(),U$=D0(),{stringEscape:kn,regexpClassEscape:k0}=wA(),{SourceNode:ri}=jA();function qA(e,t,r){let n=t.start.line,i=t.start.column-1,a=e.split(` `);return a.length===1?new ri(n,i,t.source,e,r):new ri(null,null,t.source,a.map((s,o)=>new ri(n+o,o===0?i:0,t.source,o===a.length-1?s:[s,` `],r)))}function MA(e,t,r,n,i){return r?new ri(null,null,r.source,[e,qA(t,r,i),new ri(r.end.line,r.end.column-1,r.source,n)]):new ri(null,null,null,[e,t,n])}function H$(e,t){function r(g){return g instanceof ri?g:g.replace(/^(.+)$/gm," $1")}function n(g){return"peg$c"+g}function i(g){return"peg$r"+g}function a(g){return"peg$e"+g}function s(g){return"peg$f"+g}function o(g){return"peg$parse"+g}function l(){function g(_){return'"'+kn(_)+'"'}function y(_){return"/^["+(_.inverted?"^":"")+_.value.map(I=>Array.isArray(I)?k0(I[0])+"-"+k0(I[1]):k0(I)).join("")+"]/"+(_.ignoreCase?"i":"")}function A(_){switch(_.type){case"rule":return'peg$otherExpectation("'+kn(_.value)+'")';case"literal":return'peg$literalExpectation("'+kn(_.value)+'", '+_.ignoreCase+")";case"class":return"peg$classExpectation(["+_.value.map(D=>Array.isArray(D)?'["'+kn(D[0])+'", "'+kn(D[1])+'"]':'"'+kn(D)+'"').join(", ")+"], "+_.inverted+", "+_.ignoreCase+")";case"any":return"peg$anyExpectation()";default:throw new Error("Unknown expectation type ("+JSON.stringify(_)+")")}}function S(_,I){return MA(` var ${s(I)} = function(${_.params.join(", ")}) {`,_.body,_.location,"};")}return new ri(null,null,t.grammarSource,[e.literals.map((_,I)=>" var "+n(I)+" = "+g(_)+";").concat("",e.classes.map((_,I)=>" var "+i(I)+" = "+y(_)+";")).concat("",e.expectations.map((_,I)=>" var "+a(I)+" = "+A(_)+";")).concat("").join(` `),e.functions.map(S)])}function h(g,y){let A=[];return A.push(""),t.trace&&A.push("peg$tracer.trace({",' type: "rule.enter",'," rule: "+g+","," location: peg$computeLocation(startPos, startPos)","});",""),t.cache&&(A.push("var key = peg$currPos * "+e.rules.length+" + "+y+";","var cached = peg$resultsCache[key];","","if (cached) {"," peg$currPos = cached.nextPos;",""),t.trace&&A.push("if (cached.result !== peg$FAILED) {"," peg$tracer.trace({",' type: "rule.match",'," rule: "+g+","," result: cached.result,"," location: peg$computeLocation(startPos, peg$currPos)"," });","} else {"," peg$tracer.trace({",' type: "rule.fail",'," rule: "+g+","," location: peg$computeLocation(startPos, startPos)"," });","}",""),A.push(" return cached.result;","}","")),A}function d(g,y){let A=[];return t.cache&&A.push("","peg$resultsCache[key] = { nextPos: peg$currPos, result: "+y+" };"),t.trace&&A.push("","if ("+y+" !== peg$FAILED) {"," peg$tracer.trace({",' type: "rule.match",'," rule: "+g+","," result: "+y+","," location: peg$computeLocation(startPos, peg$currPos)"," });","} else {"," peg$tracer.trace({",' type: "rule.fail",'," rule: "+g+","," location: peg$computeLocation(startPos, startPos)"," });","}"),A.push("","return "+y+";"),A}function E(g){let y=[],A=new L$(g.name,"s","var");function S(I){let D=0,H=I.length,V=[],F;function P(q,J){let z=J+3,K=I[D+z-2],X=I[D+z-1],ie,be;A.checkedIf(D,()=>{D+=z,ie=S(I.slice(D,D+K)),D+=K},X>0?()=>{be=S(I.slice(D,D+X)),D+=X}:null),V.push("if ("+q+") {"),V.push(...ie.map(r)),X>0&&(V.push("} else {"),V.push(...be.map(r))),V.push("}")}function k(q){let z=I[D+2-1],K;A.checkedLoop(D,()=>{D+=2,K=S(I.slice(D,D+z)),D+=z}),V.push("while ("+q+") {"),V.push(...K.map(r)),V.push("}")}function L(){let J=I[D+4-1],z=s(I[D+1])+"("+I.slice(D+4,D+4+J).map(K=>A.index(K)).join(", ")+")";A.pop(I[D+2]),V.push(A.push(z)),D+=4+J}for(;DA.index(K)).join(", ")} ]`,A.pop(I[D+1]),V.push(A.push(F)),D+=z;break}case At.IF:P(A.top(),0);break;case At.IF_ERROR:P(A.top()+" === peg$FAILED",0);break;case At.IF_NOT_ERROR:P(A.top()+" !== peg$FAILED",0);break;case At.WHILE_NOT_ERROR:k(A.top()+" !== peg$FAILED");break;case At.MATCH_ANY:P("input.length > peg$currPos",0);break;case At.MATCH_STRING:P(e.literals[I[D+1]].length>1?"input.substr(peg$currPos, "+e.literals[I[D+1]].length+") === "+n(I[D+1]):"input.charCodeAt(peg$currPos) === "+e.literals[I[D+1]].charCodeAt(0),1);break;case At.MATCH_STRING_IC:P("input.substr(peg$currPos, "+e.literals[I[D+1]].length+").toLowerCase() === "+n(I[D+1]),1);break;case At.MATCH_CHAR_CLASS:P(i(I[D+1])+".test(input.charAt(peg$currPos))",1);break;case At.ACCEPT_N:V.push(A.push(I[D+1]>1?"input.substr(peg$currPos, "+I[D+1]+")":"input.charAt(peg$currPos)")),V.push(I[D+1]>1?"peg$currPos += "+I[D+1]+";":"peg$currPos++;"),D+=2;break;case At.ACCEPT_STRING:V.push(A.push(n(I[D+1]))),V.push(e.literals[I[D+1]].length>1?"peg$currPos += "+e.literals[I[D+1]].length+";":"peg$currPos++;"),D+=2;break;case At.FAIL:V.push(A.push("peg$FAILED")),V.push("if (peg$silentFails === 0) { peg$fail("+a(I[D+1])+"); }"),D+=2;break;case At.LOAD_SAVED_POS:V.push("peg$savedPos = "+A.index(I[D+1])+";"),D+=2;break;case At.UPDATE_SAVED_POS:V.push("peg$savedPos = peg$currPos;"),D++;break;case At.CALL:L();break;case At.RULE:V.push(A.push(o(e.rules[I[D+1]].name)+"()")),D+=2;break;case At.SILENT_FAILS_ON:V.push("peg$silentFails++;"),D++;break;case At.SILENT_FAILS_OFF:V.push("peg$silentFails--;"),D++;break;default:throw new Error("Invalid opcode: "+I[D]+".")}return V}let _=S(g.bytecode);return y.push(MA(" function ",o(g.name),g.nameLocation,`() { `,g.name)),t.trace&&y.push(" var startPos = peg$currPos;"),y.push(r(A.defines())),y.push(...h('"'+kn(g.name)+'"',k$.indexOfRule(e,g.name)).map(r)),y.push(..._.map(r)),y.push(...d('"'+kn(g.name)+'"',A.result()).map(r)),y.push("}"),y}function p(g){return g.codeLocation?qA(g.code,g.codeLocation,"$"+g.type):g.code}function f(){let g=[];e.topLevelInitializer&&(g.push(p(e.topLevelInitializer)),g.push("")),g.push("function peg$subclass(child, parent) {"," function C() { this.constructor = child; }"," C.prototype = parent.prototype;"," child.prototype = new C();","}","","function peg$SyntaxError(message, expected, found, location) {"," var self = Error.call(this, message);"," // istanbul ignore next Check is a necessary evil to support older environments"," if (Object.setPrototypeOf) {"," Object.setPrototypeOf(self, peg$SyntaxError.prototype);"," }"," self.expected = expected;"," self.found = found;"," self.location = location;",' self.name = "SyntaxError";'," return self;","}","","peg$subclass(peg$SyntaxError, Error);","","function peg$padEnd(str, targetLength, padString) {",' padString = padString || " ";'," if (str.length > targetLength) { return str; }"," targetLength -= str.length;"," padString += padString.repeat(targetLength);"," return str + padString.slice(0, targetLength);","}","","peg$SyntaxError.prototype.format = function(sources) {",' var str = "Error: " + this.message;'," if (this.location) {"," var src = null;"," var k;"," for (k = 0; k < sources.length; k++) {"," if (sources[k].source === this.location.source) {"," src = sources[k].text.split(/\\r\\n|\\n|\\r/g);"," break;"," }"," }"," var s = this.location.start;",' var loc = this.location.source + ":" + s.line + ":" + s.column;'," if (src) {"," var e = this.location.end;",` var filler = peg$padEnd("", s.line.toString().length, ' ');`," var line = src[s.line - 1];"," var last = s.line === e.line ? e.column : line.length + 1;"," var hatLen = (last - s.column) || 1;",' str += "\\n --> " + loc + "\\n"',' + filler + " |\\n"',' + s.line + " | " + line + "\\n"',` + filler + " | " + peg$padEnd("", s.column - 1, ' ')`,' + peg$padEnd("", hatLen, "^");'," } else {",' str += "\\n at " + loc;'," }"," }"," return str;","};","","peg$SyntaxError.buildMessage = function(expected, found) {"," var DESCRIBE_EXPECTATION_FNS = {"," literal: function(expectation) {",' return "\\"" + literalEscape(expectation.text) + "\\"";'," },",""," class: function(expectation) {"," var escapedParts = expectation.parts.map(function(part) {"," return Array.isArray(part)",' ? classEscape(part[0]) + "-" + classEscape(part[1])'," : classEscape(part);"," });","",' return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";'," },",""," any: function() {",' return "any character";'," },",""," end: function() {",' return "end of input";'," },",""," other: function(expectation) {"," return expectation.description;"," }"," };",""," function hex(ch) {"," return ch.charCodeAt(0).toString(16).toUpperCase();"," }",""," function literalEscape(s) {"," return s",' .replace(/\\\\/g, "\\\\\\\\")',' .replace(/"/g, "\\\\\\"")',' .replace(/\\0/g, "\\\\0")',' .replace(/\\t/g, "\\\\t")',' .replace(/\\n/g, "\\\\n")',' .replace(/\\r/g, "\\\\r")',' .replace(/[\\x00-\\x0F]/g, function(ch) { return "\\\\x0" + hex(ch); })',' .replace(/[\\x10-\\x1F\\x7F-\\x9F]/g, function(ch) { return "\\\\x" + hex(ch); });'," }",""," function classEscape(s) {"," return s",' .replace(/\\\\/g, "\\\\\\\\")',' .replace(/\\]/g, "\\\\]")',' .replace(/\\^/g, "\\\\^")',' .replace(/-/g, "\\\\-")',' .replace(/\\0/g, "\\\\0")',' .replace(/\\t/g, "\\\\t")',' .replace(/\\n/g, "\\\\n")',' .replace(/\\r/g, "\\\\r")',' .replace(/[\\x00-\\x0F]/g, function(ch) { return "\\\\x0" + hex(ch); })',' .replace(/[\\x10-\\x1F\\x7F-\\x9F]/g, function(ch) { return "\\\\x" + hex(ch); });'," }",""," function describeExpectation(expectation) {"," return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);"," }",""," function describeExpected(expected) {"," var descriptions = expected.map(describeExpectation);"," var i, j;",""," descriptions.sort();",""," if (descriptions.length > 0) {"," for (i = 1, j = 1; i < descriptions.length; i++) {"," if (descriptions[i - 1] !== descriptions[i]) {"," descriptions[j] = descriptions[i];"," j++;"," }"," }"," descriptions.length = j;"," }",""," switch (descriptions.length) {"," case 1:"," return descriptions[0];",""," case 2:",' return descriptions[0] + " or " + descriptions[1];',""," default:",' return descriptions.slice(0, -1).join(", ")',' + ", or "'," + descriptions[descriptions.length - 1];"," }"," }",""," function describeFound(found) {",' return found ? "\\"" + literalEscape(found) + "\\"" : "end of input";'," }","",' return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";',"};",""),t.trace&&g.push("function peg$DefaultTracer() {"," this.indentLevel = 0;","}","","peg$DefaultTracer.prototype.trace = function(event) {"," var that = this;",""," function log(event) {"," function repeat(string, n) {",' var result = "", i;',""," for (i = 0; i < n; i++) {"," result += string;"," }",""," return result;"," }",""," function pad(string, length) {",' return string + repeat(" ", length - string.length);'," }","",' if (typeof console === "object") {'," console.log(",' event.location.start.line + ":" + event.location.start.column + "-"',' + event.location.end.line + ":" + event.location.end.column + " "',' + pad(event.type, 10) + " "',' + repeat(" ", that.indentLevel) + event.rule'," );"," }"," }",""," switch (event.type) {",' case "rule.enter":'," log(event);"," this.indentLevel++;"," break;","",' case "rule.match":'," this.indentLevel--;"," log(event);"," break;","",' case "rule.fail":'," this.indentLevel--;"," log(event);"," break;",""," default:",' throw new Error("Invalid event type: " + event.type + ".");'," }","};","");let y="{ "+t.allowedStartRules.map(S=>S+": "+o(S)).join(", ")+" }",A=o(t.allowedStartRules[0]);return g.push("function peg$parse(input, options) {"," options = options !== undefined ? options : {};",""," var peg$FAILED = {};"," var peg$source = options.grammarSource;",""," var peg$startRuleFunctions = "+y+";"," var peg$startRuleFunction = "+A+";","",l(),""," var peg$currPos = 0;"," var peg$savedPos = 0;"," var peg$posDetailsCache = [{ line: 1, column: 1 }];"," var peg$maxFailPos = 0;"," var peg$maxFailExpected = [];"," var peg$silentFails = 0;",""),t.cache&&g.push(" var peg$resultsCache = {};",""),t.trace&&g.push(' var peg$tracer = "tracer" in options ? options.tracer : new peg$DefaultTracer();',""),g.push(" var peg$result;","",' if ("startRule" in options) {'," if (!(options.startRule in peg$startRuleFunctions)) {",` throw new Error("Can't start parsing from rule \\"" + options.startRule + "\\".");`," }",""," peg$startRuleFunction = peg$startRuleFunctions[options.startRule];"," }",""," function text() {"," return input.substring(peg$savedPos, peg$currPos);"," }",""," function offset() {"," return peg$savedPos;"," }",""," function range() {"," return {"," source: peg$source,"," start: peg$savedPos,"," end: peg$currPos"," };"," }",""," function location() {"," return peg$computeLocation(peg$savedPos, peg$currPos);"," }",""," function expected(description, location) {"," location = location !== undefined"," ? location"," : peg$computeLocation(peg$savedPos, peg$currPos);",""," throw peg$buildStructuredError("," [peg$otherExpectation(description)],"," input.substring(peg$savedPos, peg$currPos),"," location"," );"," }",""," function error(message, location) {"," location = location !== undefined"," ? location"," : peg$computeLocation(peg$savedPos, peg$currPos);",""," throw peg$buildSimpleError(message, location);"," }",""," function peg$literalExpectation(text, ignoreCase) {",' return { type: "literal", text: text, ignoreCase: ignoreCase };'," }",""," function peg$classExpectation(parts, inverted, ignoreCase) {",' return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };'," }",""," function peg$anyExpectation() {",' return { type: "any" };'," }",""," function peg$endExpectation() {",' return { type: "end" };'," }",""," function peg$otherExpectation(description) {",' return { type: "other", description: description };'," }",""," function peg$computePosDetails(pos) {"," var details = peg$posDetailsCache[pos];"," var p;",""," if (details) {"," return details;"," } else {"," p = pos - 1;"," while (!peg$posDetailsCache[p]) {"," p--;"," }",""," details = peg$posDetailsCache[p];"," details = {"," line: details.line,"," column: details.column"," };",""," while (p < pos) {"," if (input.charCodeAt(p) === 10) {"," details.line++;"," details.column = 1;"," } else {"," details.column++;"," }",""," p++;"," }",""," peg$posDetailsCache[pos] = details;",""," return details;"," }"," }",""," function peg$computeLocation(startPos, endPos) {"," var startPosDetails = peg$computePosDetails(startPos);"," var endPosDetails = peg$computePosDetails(endPos);",""," return {"," source: peg$source,"," start: {"," offset: startPos,"," line: startPosDetails.line,"," column: startPosDetails.column"," },"," end: {"," offset: endPos,"," line: endPosDetails.line,"," column: endPosDetails.column"," }"," };"," }",""," function peg$fail(expected) {"," if (peg$currPos < peg$maxFailPos) { return; }",""," if (peg$currPos > peg$maxFailPos) {"," peg$maxFailPos = peg$currPos;"," peg$maxFailExpected = [];"," }",""," peg$maxFailExpected.push(expected);"," }",""," function peg$buildSimpleError(message, location) {"," return new peg$SyntaxError(message, null, null, location);"," }",""," function peg$buildStructuredError(expected, found, location) {"," return new peg$SyntaxError("," peg$SyntaxError.buildMessage(expected, found),"," expected,"," found,"," location"," );"," }",""),e.rules.forEach(S=>{g.push(...E(S).map(r)),g.push("")}),e.initializer&&(g.push(p(e.initializer)),g.push("")),g.push(" peg$result = peg$startRuleFunction();",""," if (peg$result !== peg$FAILED && peg$currPos === input.length) {"," return peg$result;"," } else {"," if (peg$result !== peg$FAILED && peg$currPos < input.length) {"," peg$fail(peg$endExpectation());"," }",""," throw peg$buildStructuredError("," peg$maxFailExpected,"," peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,"," peg$maxFailPos < input.length"," ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)"," : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)"," );"," }","}"),new ri(null,null,t.grammarSource,g.map(S=>S instanceof ri?S:S+` `))}function w(g){function y(){return[`// Generated by Peggy ${U$}.`,"//","// https://peggyjs.org/"]}function A(){return t.trace?["{"," SyntaxError: peg$SyntaxError,"," DefaultTracer: peg$DefaultTracer,"," parse: peg$parse","}"].join(` `):["{"," SyntaxError: peg$SyntaxError,"," parse: peg$parse","}"].join(` `)}let _={bare(){return[...y(),"(function() {",' "use strict";',"",g,"",r("return "+A()+";"),"})()"]},commonjs(){let I=Object.keys(t.dependencies),D=y();return D.push("",'"use strict";',""),I.length>0&&(I.forEach(H=>{D.push("var "+H+' = require("'+kn(t.dependencies[H])+'");')}),D.push("")),D.push(g,"","module.exports = "+A()+";"),D},es(){let I=Object.keys(t.dependencies),D=y();return D.push(""),I.length>0&&(I.forEach(H=>{D.push("import "+H+' from "'+kn(t.dependencies[H])+'";')}),D.push("")),D.push(g,"","export {"," peg$SyntaxError as SyntaxError,",t.trace?" peg$DefaultTracer as DefaultTracer,":""," peg$parse as parse","};"),D},amd(){let I=Object.keys(t.dependencies),H="["+I.map(F=>t.dependencies[F]).map(F=>'"'+kn(F)+'"').join(", ")+"]",V=I.join(", ");return[...y(),"define("+H+", function("+V+") {",' "use strict";',"",g,"",r("return "+A()+";"),"});"]},globals(){return[...y(),"(function(root) {",' "use strict";',"",g,"",r("root."+t.exportVar+" = "+A()+";"),"})(this);"]},umd(){let I=Object.keys(t.dependencies),D=I.map(k=>t.dependencies[k]),H="["+D.map(k=>'"'+kn(k)+'"').join(", ")+"]",V=D.map(k=>'require("'+kn(k)+'")').join(", "),F=I.join(", "),P=y();return P.push("(function(root, factory) {",' if (typeof define === "function" && define.amd) {'," define("+H+", factory);",' } else if (typeof module === "object" && module.exports) {'," module.exports = factory("+V+");"),t.exportVar!==null&&P.push(" } else {"," root."+t.exportVar+" = factory();"),P.push(" }","})(this, function("+F+") {",' "use strict";',"",g,"",r("return "+A()+";"),"});"),P}}[t.format]();return new ri(null,null,t.grammarSource,_.map(I=>I instanceof ri?I:I+` `))}e.code=w(f())}VA.exports=H$});var zA=we((YO,GA)=>{"use strict";var j$=sa(),M$=ti();function q$(e,t,r){function n(s){return s.type==="rule"&&s.expression.type==="rule_ref"}function i(s,o,l){M$.build({rule_ref(d){d.name===o&&(d.name=l,r.info(`Proxy rule "${o}" replaced by the rule "${l}"`,d.location,[{message:"This rule will be used",location:j$.findRule(s,l).nameLocation}]))}})(s)}let a=[];e.rules.forEach((s,o)=>{n(s)&&(i(e,s.name,s.expression.name),t.allowedStartRules.indexOf(s.name)===-1&&a.push(o))}),a.reverse(),a.forEach(s=>{e.rules.splice(s,1)})}GA.exports=q$});var WA=we((WO,YA)=>{"use strict";var V$=ti();function K$(e,t,r){function n(s){let o={};return Object.keys(s).forEach(l=>{o[l]=s[l]}),o}function i(s,o){a(s.expression,n(o))}let a=V$.build({rule(s){a(s.expression,{})},choice(s,o){s.alternatives.forEach(l=>{a(l,n(o))})},action:i,labeled(s,o){let l=s.label;l&&Object.prototype.hasOwnProperty.call(o,l)&&r.error(`Label "${s.label}" is already defined`,s.labelLocation,[{message:"Original label location",location:o[l]}]),a(s.expression,o),o[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)}YA.exports=K$});var JA=we((XO,XA)=>{"use strict";var G$=ti();function z$(e,t,r){let n={};G$.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)}XA.exports=z$});var ew=we((JO,QA)=>{"use strict";var ZA=sa(),Y$=ti();function W$(e,t,r){let n=[],i=[],a=Y$.build({rule(s){n.push(s.name),a(s.expression),n.pop()},sequence(s){s.elements.every(o=>(a(o),!ZA.alwaysConsumesOnSuccess(e,o)))},rule_ref(s){i.push(s);let o=ZA.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(" -> ")+")",o.nameLocation,i.map((l,h,d)=>({message:h+1!==d.length?`Step ${h+1}: call of the rule "${l.name}" without input consumption`:`Step ${h+1}: call itself without input consumption - left recursion`,location:l.location})));return}o&&a(o),i.pop()}});a(e)}QA.exports=W$});var nw=we((ZO,rw)=>{"use strict";var tw=sa(),X$=ti();function J$(e,t,r){X$.build({zero_or_more(i){tw.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){tw.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)}rw.exports=J$});var sw=we((QO,iw)=>{"use strict";var Z$=sa(),Q$=ti();function e7(e,t,r){Q$.build({rule_ref(i){Z$.findRule(e,i.name)||r.error(`Rule "${i.name}" is not defined`,i.location)}})(e)}iw.exports=e7});var uw=we((eN,aw)=>{"use strict";var t7=ti();function r7(e,t,r){let n=t7.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)}aw.exports=r7});var cw=we((tN,ow)=>{"use strict";var n7=lh(),L0=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(){}},U0=class{constructor(t){this._callbacks=new L0(t),this._firstError=null,this.errors=0,this.problems=[],this.stage=null}error(...t){++this.errors,this._firstError===null&&(this._firstError=new n7(...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}};ow.exports=U0});var lw=we((exports,module)=>{"use strict";var generateBytecode=mA(),generateJS=KA(),inferenceMatchResult=C0(),removeProxyRules=zA(),reportDuplicateLabels=WA(),reportDuplicateRules=JA(),reportInfiniteRecursion=ew(),reportInfiniteRepetition=nw(),reportUndefinedRules=sw(),reportIncorrectPlucking=uw(),Session=cw(),visitor=ti();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 hw=we((rN,fw)=>{"use strict";var i7={$:"text","&":"simple_and","!":"simple_not"},s7={"?":"optional","*":"zero_or_more","+":"one_or_more"},a7={"&":"semantic_and","!":"semantic_not"};function u7(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}function ca(e,t,r,n){var i=Error.call(this,e);return Object.setPrototypeOf&&Object.setPrototypeOf(i,ca.prototype),i.expected=t,i.found=r,i.location=n,i.name="SyntaxError",i}u7(ca,Error);function H0(e,t,r){return r=r||" ",e.length>t?e:(t-=e.length,r+=r.repeat(t),e+r.slice(0,t))}ca.prototype.format=function(e){var t="Error: "+this.message;if(this.location){var r=null,n;for(n=0;n `+a+` `+o+` | `+i.line+" | "+l+` `+o+" | "+H0("",i.column-1," ")+H0("",d,"^")}else t+=` at `+a}return t};ca.buildMessage=function(e,t){var r={literal:function(h){return'"'+i(h.text)+'"'},class:function(h){var d=h.parts.map(function(E){return Array.isArray(E)?a(E[0])+"-"+a(E[1]):a(E)});return"["+(h.inverted?"^":"")+d.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(h){return h.description}};function n(h){return h.charCodeAt(0).toString(16).toUpperCase()}function i(h){return h.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(d){return"\\x0"+n(d)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(d){return"\\x"+n(d)})}function a(h){return h.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(d){return"\\x0"+n(d)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(d){return"\\x"+n(d)})}function s(h){return r[h.type](h)}function o(h){var d=h.map(s),E,p;if(d.sort(),d.length>0){for(E=1,p=1;E0?{type:"choice",alternatives:[b].concat(O),location:xt()}:b},Hn=function(b,O){return O!==null?{type:"action",expression:b,code:O[0],codeLocation:O[1],location:xt()}:b},Ca=function(b,O){return O.length>0||b.type==="labeled"&&b.pick?{type:"sequence",elements:[b].concat(O),location:xt()}:b},Eh=function(b,O,W){return W.type.startsWith("semantic_")&&Qo('"@" cannot be used on a semantic predicate',b),{type:"labeled",label:O!==null?O[0]:null,labelLocation:O!==null?O[1]:b,pick:!0,expression:W,location:xt()}},Ah=function(b,O){return{type:"labeled",label:b[0],labelLocation:b[1],expression:O,location:xt()}},Dt=function(){return xt()},Ft=function(b){return Ou.indexOf(b[0])>=0&&Qo(`Label can't be a reserved word "${b[0]}"`,b[1]),b},wh=function(b,O){return{type:i7[b],expression:O,location:xt()}},yh=function(b,O){return{type:s7[O],expression:b,location:xt()}},Sh=function(b){return b.type==="labeled"||b.type==="sequence"?{type:"group",expression:b,location:xt()}:b},bh=function(b){return{type:"rule_ref",name:b[0],location:xt()}},Ch=function(b,O){return{type:a7[b],code:O[0],codeLocation:O[1],location:xt()}},Fh=function(b,O){return[b+O.join(""),xt()]},Qc=function(b,O){return{type:"literal",value:b,ignoreCase:O!==null,location:xt()}},_h=function(b){return b.join("")},er=function(b){return b.join("")},Xo=function(b,O,W){return{type:"class",parts:O.filter(M=>M!==""),inverted:b!==null,ignoreCase:W!==null,location:xt()}},Yi=function(b,O){return b.charCodeAt(0)>O.charCodeAt(0)&&Qo("Invalid character range: "+Zo()+"."),[b,O]},el=function(){return""},Jo=function(){return"\0"},tn=function(){return"\b"},tl=function(){return"\f"},rl=function(){return` `},nl=function(){return"\r"},il=function(){return" "},sl=function(){return"\v"},al=function(b){return String.fromCharCode(parseInt(b,16))},Kr=function(b){return String.fromCharCode(parseInt(b,16))},Ih=function(){return{type:"any",location:xt()}},rn=function(b){return[b,xt()]},B=0,Ye=0,wn=[{line:1,column:1}],Gr=0,Fa=[],te=0,yn;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 Zo(){return e.substring(Ye,B)}function J0(){return Ye}function ul(){return{source:n,start:Ye,end:B}}function xt(){return Wi(Ye,B)}function Z0(b,O){throw O=O!==void 0?O:Wi(Ye,B),cl([jn(b)],e.substring(Ye,B),O)}function Qo(b,O){throw O=O!==void 0?O:Wi(Ye,B),ol(b,O)}function Ue(b,O){return{type:"literal",text:b,ignoreCase:O}}function tr(b,O,W){return{type:"class",parts:b,inverted:O,ignoreCase:W}}function js(){return{type:"any"}}function Dh(){return{type:"end"}}function jn(b){return{type:"other",description:b}}function ec(b){var O=wn[b],W;if(O)return O;for(W=b-1;!wn[W];)W--;for(O=wn[W],O={line:O.line,column:O.column};WGr&&(Gr=B,Fa=[]),Fa.push(b))}function ol(b,O){return new ca(b,null,null,O)}function cl(b,O,W){return new ca(ca.buildMessage(b,O),b,O,W)}function bu(){var b,O,W,M,se,oe,Ct,Mt;if(b=B,O=vt(),W=B,M=tc(),M!==r?(se=vt(),W=M):(B=W,W=r),W===r&&(W=null),M=B,se=Bh(),se!==r?(oe=vt(),M=se):(B=M,M=r),M===r&&(M=null),se=[],oe=B,Ct=rc(),Ct!==r?(Mt=vt(),oe=Ct):(B=oe,oe=r),oe!==r)for(;oe!==r;)se.push(oe),oe=B,Ct=rc(),Ct!==r?(Mt=vt(),oe=Ct):(B=oe,oe=r);else se=r;return se!==r?(Ye=b,b=An(W,M,se)):(B=b,b=r),b}function tc(){var b,O,W,M,se;return b=B,e.charCodeAt(B)===123?(O=s,B++):(O=r,te===0&&pe(gi)),O!==r?(W=ht(),W!==r?(e.charCodeAt(B)===125?(M=o,B++):(M=r,te===0&&pe(zi)),M!==r?(se=Qi(),se!==r?(Ye=b,b=Us(W)):(B=b,b=r)):(B=b,b=r)):(B=b,b=r)):(B=b,b=r),b}function Bh(){var b,O,W;return b=B,O=ht(),O!==r?(W=Qi(),W!==r?(Ye=b,b=Vr(O)):(B=b,b=r)):(B=b,b=r),b}function rc(){var b,O,W,M,se,oe,Ct,Mt;return b=B,O=_u(),O!==r?(W=vt(),M=B,se=Mn(),se!==r?(oe=vt(),M=se):(B=M,M=r),M===r&&(M=null),e.charCodeAt(B)===61?(se=l,B++):(se=r,te===0&&pe(uu)),se!==r?(oe=vt(),Ct=Rr(),Ct!==r?(Mt=Qi(),Mt!==r?(Ye=b,b=br(O,M,Ct)):(B=b,b=r)):(B=b,b=r)):(B=b,b=r)):(B=b,b=r),b}function Rr(){var b,O,W,M,se,oe,Ct,Mt;if(b=B,O=_a(),O!==r){for(W=[],M=B,se=vt(),e.charCodeAt(B)===47?(oe=h,B++):(oe=r,te===0&&pe(ou)),oe!==r?(Ct=vt(),Mt=_a(),Mt!==r?M=Mt:(B=M,M=r)):(B=M,M=r);M!==r;)W.push(M),M=B,se=vt(),e.charCodeAt(B)===47?(oe=h,B++):(oe=r,te===0&&pe(ou)),oe!==r?(Ct=vt(),Mt=_a(),Mt!==r?M=Mt:(B=M,M=r)):(B=M,M=r);Ye=b,b=Hs(O,W)}else B=b,b=r;return b}function _a(){var b,O,W,M,se;return b=B,O=Ia(),O!==r?(W=B,M=vt(),se=ht(),se!==r?W=se:(B=W,W=r),W===r&&(W=null),Ye=b,b=Hn(O,W)):(B=b,b=r),b}function Ia(){var b,O,W,M,se,oe;if(b=B,O=Cu(),O!==r){for(W=[],M=B,se=vt(),oe=Cu(),oe!==r?M=oe:(B=M,M=r);M!==r;)W.push(M),M=B,se=vt(),oe=Cu(),oe!==r?M=oe:(B=M,M=r);Ye=b,b=Ca(O,W)}else B=b,b=r;return b}function Cu(){var b,O,W,M;return b=B,O=ll(),O!==r?(W=fl(),W===r&&(W=null),M=nc(),M!==r?(Ye=b,b=Eh(O,W,M)):(B=b,b=r)):(B=b,b=r),b===r&&(b=B,O=fl(),O!==r?(W=vt(),M=nc(),M!==r?(Ye=b,b=Ah(O,M)):(B=b,b=r)):(B=b,b=r),b===r&&(b=nc())),b}function ll(){var b,O;return b=B,e.charCodeAt(B)===64?(O=d,B++):(O=r,te===0&&pe(cu)),O!==r&&(Ye=b,O=Dt()),b=O,b}function fl(){var b,O,W,M;return b=B,O=_u(),O!==r?(W=vt(),e.charCodeAt(B)===58?(M=E,B++):(M=r,te===0&&pe(lu)),M!==r?(Ye=b,b=Ft(O)):(B=b,b=r)):(B=b,b=r),b}function nc(){var b,O,W,M;return b=B,O=$h(),O!==r?(W=vt(),M=hl(),M!==r?(Ye=b,b=wh(O,M)):(B=b,b=r)):(B=b,b=r),b===r&&(b=hl()),b}function $h(){var b;return e.charCodeAt(B)===36?(b=p,B++):(b=r,te===0&&pe(fu)),b===r&&(e.charCodeAt(B)===38?(b=f,B++):(b=r,te===0&&pe(hu)),b===r&&(e.charCodeAt(B)===33?(b=w,B++):(b=r,te===0&&pe(pu)))),b}function hl(){var b,O,W,M;return b=B,O=Xi(),O!==r?(W=vt(),M=Ph(),M!==r?(Ye=b,b=yh(O,M)):(B=b,b=r)):(B=b,b=r),b===r&&(b=Xi()),b}function Ph(){var b;return e.charCodeAt(B)===63?(b=g,B++):(b=r,te===0&&pe(Do)),b===r&&(e.charCodeAt(B)===42?(b=y,B++):(b=r,te===0&&pe(du)),b===r&&(e.charCodeAt(B)===43?(b=A,B++):(b=r,te===0&&pe(Bo)))),b}function Xi(){var b,O,W,M,se,oe;return b=kh(),b===r&&(b=ue(),b===r&&(b=Bu(),b===r&&(b=Rh(),b===r&&(b=Th(),b===r&&(b=B,e.charCodeAt(B)===40?(O=S,B++):(O=r,te===0&&pe($o)),O!==r?(W=vt(),M=Rr(),M!==r?(se=vt(),e.charCodeAt(B)===41?(oe=_,B++):(oe=r,te===0&&pe(Po)),oe!==r?(Ye=b,b=Sh(M)):(B=b,b=r)):(B=b,b=r)):(B=b,b=r)))))),b}function Rh(){var b,O,W,M,se,oe,Ct,Mt;return b=B,O=_u(),O!==r?(W=B,te++,M=B,se=vt(),oe=B,Ct=Mn(),Ct!==r?(Mt=vt(),Ct=[Ct,Mt],oe=Ct):(B=oe,oe=r),oe===r&&(oe=null),e.charCodeAt(B)===61?(Ct=l,B++):(Ct=r,te===0&&pe(uu)),Ct!==r?(se=[se,oe,Ct],M=se):(B=M,M=r),te--,M===r?W=void 0:(B=W,W=r),W!==r?(Ye=b,b=bh(O)):(B=b,b=r)):(B=b,b=r),b}function Th(){var b,O,W,M;return b=B,O=ic(),O!==r?(W=vt(),M=ht(),M!==r?(Ye=b,b=Ch(O,M)):(B=b,b=r)):(B=b,b=r),b}function ic(){var b;return e.charCodeAt(B)===38?(b=f,B++):(b=r,te===0&&pe(hu)),b===r&&(e.charCodeAt(B)===33?(b=w,B++):(b=r,te===0&&pe(pu))),b}function Cr(){var b;return e.length>B?(b=e.charAt(B),B++):(b=r,te===0&&pe(Ns)),b}function Sn(){var b,O;return te++,e.charCodeAt(B)===9?(b=I,B++):(b=r,te===0&&pe(ma)),b===r&&(e.charCodeAt(B)===11?(b=D,B++):(b=r,te===0&&pe(To)),b===r&&(e.charCodeAt(B)===12?(b=H,B++):(b=r,te===0&&pe(xo)),b===r&&(e.charCodeAt(B)===32?(b=V,B++):(b=r,te===0&&pe(Oo)),b===r&&(e.charCodeAt(B)===160?(b=F,B++):(b=r,te===0&&pe(No)),b===r&&(e.charCodeAt(B)===65279?(b=P,B++):(b=r,te===0&&pe(ko)),b===r&&(b=Al())))))),te--,b===r&&(O=r,te===0&&pe(Ro)),b}function bn(){var b;return Zt.test(e.charAt(B))?(b=e.charAt(B),B++):(b=r,te===0&&pe(Lo)),b}function Fu(){var b,O;return te++,e.charCodeAt(B)===10?(b=k,B++):(b=r,te===0&&pe(Ho)),b===r&&(e.substr(B,2)===L?(b=L,B+=2):(b=r,te===0&&pe(mi)),b===r&&(e.charCodeAt(B)===13?(b=q,B++):(b=r,te===0&&pe(gu)),b===r&&(e.charCodeAt(B)===8232?(b=J,B++):(b=r,te===0&&pe(jo)),b===r&&(e.charCodeAt(B)===8233?(b=z,B++):(b=r,te===0&&pe(Mo)))))),te--,b===r&&(O=r,te===0&&pe(Uo)),b}function pl(){var b,O;return te++,b=xh(),b===r&&(b=nn()),te--,b===r&&(O=r,te===0&&pe(qo)),b}function xh(){var b,O,W,M,se,oe;if(b=B,e.substr(B,2)===K?(O=K,B+=2):(O=r,te===0&&pe(mu)),O!==r){for(W=[],M=B,se=B,te++,e.substr(B,2)===X?(oe=X,B+=2):(oe=r,te===0&&pe(vi)),te--,oe===r?se=void 0:(B=se,se=r),se!==r?(oe=Cr(),oe!==r?(se=[se,oe],M=se):(B=M,M=r)):(B=M,M=r);M!==r;)W.push(M),M=B,se=B,te++,e.substr(B,2)===X?(oe=X,B+=2):(oe=r,te===0&&pe(vi)),te--,oe===r?se=void 0:(B=se,se=r),se!==r?(oe=Cr(),oe!==r?(se=[se,oe],M=se):(B=M,M=r)):(B=M,M=r);e.substr(B,2)===X?(M=X,B+=2):(M=r,te===0&&pe(vi)),M!==r?(O=[O,W,M],b=O):(B=b,b=r)}else B=b,b=r;return b}function Ji(){var b,O,W,M,se,oe;if(b=B,e.substr(B,2)===K?(O=K,B+=2):(O=r,te===0&&pe(mu)),O!==r){for(W=[],M=B,se=B,te++,e.substr(B,2)===X?(oe=X,B+=2):(oe=r,te===0&&pe(vi)),oe===r&&(oe=bn()),te--,oe===r?se=void 0:(B=se,se=r),se!==r?(oe=Cr(),oe!==r?(se=[se,oe],M=se):(B=M,M=r)):(B=M,M=r);M!==r;)W.push(M),M=B,se=B,te++,e.substr(B,2)===X?(oe=X,B+=2):(oe=r,te===0&&pe(vi)),oe===r&&(oe=bn()),te--,oe===r?se=void 0:(B=se,se=r),se!==r?(oe=Cr(),oe!==r?(se=[se,oe],M=se):(B=M,M=r)):(B=M,M=r);e.substr(B,2)===X?(M=X,B+=2):(M=r,te===0&&pe(vi)),M!==r?(O=[O,W,M],b=O):(B=b,b=r)}else B=b,b=r;return b}function nn(){var b,O,W,M,se,oe;if(b=B,e.substr(B,2)===ie?(O=ie,B+=2):(O=r,te===0&&pe(en)),O!==r){for(W=[],M=B,se=B,te++,oe=bn(),te--,oe===r?se=void 0:(B=se,se=r),se!==r?(oe=Cr(),oe!==r?(se=[se,oe],M=se):(B=M,M=r)):(B=M,M=r);M!==r;)W.push(M),M=B,se=B,te++,oe=bn(),te--,oe===r?se=void 0:(B=se,se=r),se!==r?(oe=Cr(),oe!==r?(se=[se,oe],M=se):(B=M,M=r)):(B=M,M=r);O=[O,W],b=O}else B=b,b=r;return b}function _u(){var b,O,W,M;if(te++,b=B,O=dl(),O!==r){for(W=[],M=gl();M!==r;)W.push(M),M=gl();Ye=b,b=Fh(O,W)}else B=b,b=r;return te--,b===r&&(O=r,te===0&&pe(Vo)),b}function dl(){var b,O,W;return b=Oh(),b===r&&(e.charCodeAt(B)===36?(b=p,B++):(b=r,te===0&&pe(fu)),b===r&&(e.charCodeAt(B)===95?(b=be,B++):(b=r,te===0&&pe(ks)),b===r&&(b=B,e.charCodeAt(B)===92?(O=ye,B++):(O=r,te===0&&pe(En)),O!==r?(W=ml(),W!==r?b=W:(B=b,b=r)):(B=b,b=r)))),b}function gl(){var b;return b=dl(),b===r&&(b=Nh(),b===r&&(b=vl(),b===r&&(b=El(),b===r&&(e.charCodeAt(B)===8204?(b=$e,B++):(b=r,te===0&&pe(Ko)),b===r&&(e.charCodeAt(B)===8205?(b=qe,B++):(b=r,te===0&&pe(Go))))))),b}function Oh(){var b;return b=Ru(),b===r&&(b=Pu(),b===r&&(b=Mh(),b===r&&(b=Hh(),b===r&&(b=jh(),b===r&&(b=xu()))))),b}function Nh(){var b;return b=Tu(),b===r&&(b=wi()),b}function kh(){var b,O,W;return te++,b=B,O=Mn(),O!==r?(e.charCodeAt(B)===105?(W=ce,B++):(W=r,te===0&&pe(va)),W===r&&(W=null),Ye=b,b=Qc(O,W)):(B=b,b=r),te--,b===r&&(O=r,te===0&&pe(vu)),b}function Mn(){var b,O,W,M;if(te++,b=B,e.charCodeAt(B)===34?(O=_e,B++):(O=r,te===0&&pe(Ls)),O!==r){for(W=[],M=re();M!==r;)W.push(M),M=re();e.charCodeAt(B)===34?(M=_e,B++):(M=r,te===0&&pe(Ls)),M!==r?(Ye=b,b=_h(W)):(B=b,b=r)}else B=b,b=r;if(b===r)if(b=B,e.charCodeAt(B)===39?(O=Le,B++):(O=r,te===0&&pe(Ht)),O!==r){for(W=[],M=le();M!==r;)W.push(M),M=le();e.charCodeAt(B)===39?(M=Le,B++):(M=r,te===0&&pe(Ht)),M!==r?(Ye=b,b=er(W)):(B=b,b=r)}else B=b,b=r;return te--,b===r&&(O=r,te===0&&pe(Eu)),b}function re(){var b,O,W,M;return b=B,O=B,W=B,te++,e.charCodeAt(B)===34?(M=_e,B++):(M=r,te===0&&pe(Ls)),M===r&&(e.charCodeAt(B)===92?(M=ye,B++):(M=r,te===0&&pe(En)),M===r&&(M=bn())),te--,M===r?W=void 0:(B=W,W=r),W!==r?(M=Cr(),M!==r?(W=[W,M],O=W):(B=O,O=r)):(B=O,O=r),O!==r?b=e.substring(b,B):b=O,b===r&&(b=B,e.charCodeAt(B)===92?(O=ye,B++):(O=r,te===0&&pe(En)),O!==r?(W=Ot(),W!==r?b=W:(B=b,b=r)):(B=b,b=r),b===r&&(b=ct())),b}function le(){var b,O,W,M;return b=B,O=B,W=B,te++,e.charCodeAt(B)===39?(M=Le,B++):(M=r,te===0&&pe(Ht)),M===r&&(e.charCodeAt(B)===92?(M=ye,B++):(M=r,te===0&&pe(En)),M===r&&(M=bn())),te--,M===r?W=void 0:(B=W,W=r),W!==r?(M=Cr(),M!==r?(W=[W,M],O=W):(B=O,O=r)):(B=O,O=r),O!==r?b=e.substring(b,B):b=O,b===r&&(b=B,e.charCodeAt(B)===92?(O=ye,B++):(O=r,te===0&&pe(En)),O!==r?(W=Ot(),W!==r?b=W:(B=b,b=r)):(B=b,b=r),b===r&&(b=ct())),b}function ue(){var b,O,W,M,se,oe;if(te++,b=B,e.charCodeAt(B)===91?(O=lr,B++):(O=r,te===0&&pe(Yo)),O!==r){for(e.charCodeAt(B)===94?(W=Bt,B++):(W=r,te===0&&pe(Au)),W===r&&(W=null),M=[],se=Re(),se===r&&(se=Ge());se!==r;)M.push(se),se=Re(),se===r&&(se=Ge());e.charCodeAt(B)===93?(se=pt,B++):(se=r,te===0&&pe(Ei)),se!==r?(e.charCodeAt(B)===105?(oe=ce,B++):(oe=r,te===0&&pe(va)),oe===r&&(oe=null),Ye=b,b=Xo(W,M,oe)):(B=b,b=r)}else B=b,b=r;return te--,b===r&&(O=r,te===0&&pe(zo)),b}function Re(){var b,O,W,M;return b=B,O=Ge(),O!==r?(e.charCodeAt(B)===45?(W=zt,B++):(W=r,te===0&&pe(hr)),W!==r?(M=Ge(),M!==r?(Ye=b,b=Yi(O,M)):(B=b,b=r)):(B=b,b=r)):(B=b,b=r),b}function Ge(){var b,O,W,M;return b=B,O=B,W=B,te++,e.charCodeAt(B)===93?(M=pt,B++):(M=r,te===0&&pe(Ei)),M===r&&(e.charCodeAt(B)===92?(M=ye,B++):(M=r,te===0&&pe(En)),M===r&&(M=bn())),te--,M===r?W=void 0:(B=W,W=r),W!==r?(M=Cr(),M!==r?(W=[W,M],O=W):(B=O,O=r)):(B=O,O=r),O!==r?b=e.substring(b,B):b=O,b===r&&(b=B,e.charCodeAt(B)===92?(O=ye,B++):(O=r,te===0&&pe(En)),O!==r?(W=Ot(),W!==r?b=W:(B=b,b=r)):(B=b,b=r),b===r&&(b=ct())),b}function ct(){var b,O,W;return b=B,e.charCodeAt(B)===92?(O=ye,B++):(O=r,te===0&&pe(En)),O!==r?(W=Fu(),W!==r?(Ye=b,b=el()):(B=b,b=r)):(B=b,b=r),b}function Ot(){var b,O,W,M;return b=bt(),b===r&&(b=B,e.charCodeAt(B)===48?(O=Tt,B++):(O=r,te===0&&pe(Rt)),O!==r?(W=B,te++,M=Zi(),te--,M===r?W=void 0:(B=W,W=r),W!==r?(Ye=b,b=Jo()):(B=b,b=r)):(B=b,b=r),b===r&&(b=Du(),b===r&&(b=ml()))),b}function bt(){var b;return b=Iu(),b===r&&(b=Lh()),b}function Iu(){var b,O;return e.charCodeAt(B)===39?(b=Le,B++):(b=r,te===0&&pe(Ht)),b===r&&(e.charCodeAt(B)===34?(b=_e,B++):(b=r,te===0&&pe(Ls)),b===r&&(e.charCodeAt(B)===92?(b=ye,B++):(b=r,te===0&&pe(En)),b===r&&(b=B,e.charCodeAt(B)===98?(O=nt,B++):(O=r,te===0&&pe(Wo)),O!==r&&(Ye=b,O=tn()),b=O,b===r&&(b=B,e.charCodeAt(B)===102?(O=It,B++):(O=r,te===0&&pe(Ea)),O!==r&&(Ye=b,O=tl()),b=O,b===r&&(b=B,e.charCodeAt(B)===110?(O=tt,B++):(O=r,te===0&&pe(pr)),O!==r&&(Ye=b,O=rl()),b=O,b===r&&(b=B,e.charCodeAt(B)===114?(O=gt,B++):(O=r,te===0&&pe(Aa)),O!==r&&(Ye=b,O=nl()),b=O,b===r&&(b=B,e.charCodeAt(B)===116?(O=Yt,B++):(O=r,te===0&&pe(wu)),O!==r&&(Ye=b,O=il()),b=O,b===r&&(b=B,e.charCodeAt(B)===118?(O=Je,B++):(O=r,te===0&&pe(yu)),O!==r&&(Ye=b,O=sl()),b=O)))))))),b}function Lh(){var b,O,W,M;return b=B,O=B,W=B,te++,M=sn(),M===r&&(M=bn()),te--,M===r?W=void 0:(B=W,W=r),W!==r?(M=Cr(),M!==r?(W=[W,M],O=W):(B=O,O=r)):(B=O,O=r),O!==r?b=e.substring(b,B):b=O,b}function sn(){var b;return b=Iu(),b===r&&(b=Zi(),b===r&&(e.charCodeAt(B)===120?(b=Ut,B++):(b=r,te===0&&pe(wa)),b===r&&(e.charCodeAt(B)===117?(b=Un,B++):(b=r,te===0&&pe(Ai))))),b}function Du(){var b,O,W,M,se,oe;return b=B,e.charCodeAt(B)===120?(O=Ut,B++):(O=r,te===0&&pe(wa)),O!==r?(W=B,M=B,se=ni(),se!==r?(oe=ni(),oe!==r?(se=[se,oe],M=se):(B=M,M=r)):(B=M,M=r),M!==r?W=e.substring(W,B):W=M,W!==r?(Ye=b,b=al(W)):(B=b,b=r)):(B=b,b=r),b}function ml(){var b,O,W,M,se,oe,Ct,Mt;return b=B,e.charCodeAt(B)===117?(O=Un,B++):(O=r,te===0&&pe(Ai)),O!==r?(W=B,M=B,se=ni(),se!==r?(oe=ni(),oe!==r?(Ct=ni(),Ct!==r?(Mt=ni(),Mt!==r?(se=[se,oe,Ct,Mt],M=se):(B=M,M=r)):(B=M,M=r)):(B=M,M=r)):(B=M,M=r),M!==r?W=e.substring(W,B):W=M,W!==r?(Ye=b,b=Kr(W)):(B=b,b=r)):(B=b,b=r),b}function Zi(){var b;return $r.test(e.charAt(B))?(b=e.charAt(B),B++):(b=r,te===0&&pe(ya)),b}function ni(){var b;return la.test(e.charAt(B))?(b=e.charAt(B),B++):(b=r,te===0&&pe(Su)),b}function Bu(){var b,O;return b=B,e.charCodeAt(B)===46?(O=fr,B++):(O=r,te===0&&pe(Sa)),O!==r&&(Ye=b,O=Ih()),b=O,b}function ht(){var b,O,W,M;return te++,b=B,e.charCodeAt(B)===123?(O=s,B++):(O=r,te===0&&pe(gi)),O!==r?(W=Uh(),e.charCodeAt(B)===125?(M=o,B++):(M=r,te===0&&pe(zi)),M!==r?b=W:(B=b,b=r)):(B=b,b=r),te--,b===r&&(O=r,te===0&&pe(ba)),b}function Uh(){var b,O;return b=B,O=$u(),Ye=b,O=rn(O),b=O,b}function $u(){var b,O,W,M,se,oe;if(b=B,O=[],W=[],M=B,se=B,te++,Mr.test(e.charAt(B))?(oe=e.charAt(B),B++):(oe=r,te===0&&pe(qr)),te--,oe===r?se=void 0:(B=se,se=r),se!==r?(oe=Cr(),oe!==r?(se=[se,oe],M=se):(B=M,M=r)):(B=M,M=r),M!==r)for(;M!==r;)W.push(M),M=B,se=B,te++,Mr.test(e.charAt(B))?(oe=e.charAt(B),B++):(oe=r,te===0&&pe(qr)),te--,oe===r?se=void 0:(B=se,se=r),se!==r?(oe=Cr(),oe!==r?(se=[se,oe],M=se):(B=M,M=r)):(B=M,M=r);else W=r;for(W===r&&(W=B,e.charCodeAt(B)===123?(M=s,B++):(M=r,te===0&&pe(gi)),M!==r?(se=$u(),e.charCodeAt(B)===125?(oe=o,B++):(oe=r,te===0&&pe(zi)),oe!==r?(M=[M,se,oe],W=M):(B=W,W=r)):(B=W,W=r));W!==r;){if(O.push(W),W=[],M=B,se=B,te++,Mr.test(e.charAt(B))?(oe=e.charAt(B),B++):(oe=r,te===0&&pe(qr)),te--,oe===r?se=void 0:(B=se,se=r),se!==r?(oe=Cr(),oe!==r?(se=[se,oe],M=se):(B=M,M=r)):(B=M,M=r),M!==r)for(;M!==r;)W.push(M),M=B,se=B,te++,Mr.test(e.charAt(B))?(oe=e.charAt(B),B++):(oe=r,te===0&&pe(qr)),te--,oe===r?se=void 0:(B=se,se=r),se!==r?(oe=Cr(),oe!==r?(se=[se,oe],M=se):(B=M,M=r)):(B=M,M=r);else W=r;W===r&&(W=B,e.charCodeAt(B)===123?(M=s,B++):(M=r,te===0&&pe(gi)),M!==r?(se=$u(),e.charCodeAt(B)===125?(oe=o,B++):(oe=r,te===0&&pe(zi)),oe!==r?(M=[M,se,oe],W=M):(B=W,W=r)):(B=W,W=r))}return b=e.substring(b,B),b}function Pu(){var b;return mt.test(e.charAt(B))?(b=e.charAt(B),B++):(b=r,te===0&&pe(R)),b}function Hh(){var b;return Qt.test(e.charAt(B))?(b=e.charAt(B),B++):(b=r,te===0&&pe(x)),b}function jh(){var b;return Ze.test(e.charAt(B))?(b=e.charAt(B),B++):(b=r,te===0&&pe(j)),b}function Mh(){var b;return Pr.test(e.charAt(B))?(b=e.charAt(B),B++):(b=r,te===0&&pe(Q)),b}function Ru(){var b;return fa.test(e.charAt(B))?(b=e.charAt(B),B++):(b=r,te===0&&pe(de)),b}function wi(){var b;return ha.test(e.charAt(B))?(b=e.charAt(B),B++):(b=r,te===0&&pe(ve)),b}function Tu(){var b;return pa.test(e.charAt(B))?(b=e.charAt(B),B++):(b=r,te===0&&pe(Fe)),b}function vl(){var b;return da.test(e.charAt(B))?(b=e.charAt(B),B++):(b=r,te===0&&pe(Pe)),b}function xu(){var b;return Gi.test(e.charAt(B))?(b=e.charAt(B),B++):(b=r,te===0&&pe(St)),b}function El(){var b;return ga.test(e.charAt(B))?(b=e.charAt(B),B++):(b=r,te===0&&pe(jt)),b}function Al(){var b;return Os.test(e.charAt(B))?(b=e.charAt(B),B++):(b=r,te===0&&pe(yr)),b}function vt(){var b,O;for(b=[],O=Sn(),O===r&&(O=Fu(),O===r&&(O=pl()));O!==r;)b.push(O),O=Sn(),O===r&&(O=Fu(),O===r&&(O=pl()));return b}function wl(){var b,O;for(b=[],O=Sn(),O===r&&(O=Ji());O!==r;)b.push(O),O=Sn(),O===r&&(O=Ji());return b}function Qi(){var b,O,W,M;return b=B,O=vt(),e.charCodeAt(B)===59?(W=wr,B++):(W=r,te===0&&pe(Sr)),W!==r?(O=[O,W],b=O):(B=b,b=r),b===r&&(b=B,O=wl(),W=nn(),W===r&&(W=null),M=Fu(),M!==r?(O=[O,W,M],b=O):(B=b,b=r),b===r&&(b=B,O=vt(),W=es(),W!==r?(O=[O,W],b=O):(B=b,b=r))),b}function es(){var b,O;return b=B,te++,e.length>B?(O=e.charAt(B),B++):(O=r,te===0&&pe(Ns)),te--,O===r?b=void 0:(B=b,b=r),b}let Ou=t.reservedWords||[];if(yn=a(),yn!==r&&B===e.length)return yn;throw yn!==r&&B{"use strict";var c7=lh(),l7=lw(),f7=hw(),h7=D0(),p7=["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"],Jc={VERSION:h7,RESERVED_WORDS:p7,GrammarError:c7,parser:f7,compiler:l7,generate(e,t){t=t!==void 0?t:{};function r(a){let s={};return Object.keys(a).forEach(o=>{s[o]=a[o].slice()}),s}let n="plugins"in t?t.plugins:[],i={parser:Jc.parser,passes:r(Jc.compiler.passes),reservedWords:Jc.RESERVED_WORDS.slice()};return n.forEach(a=>{a.use(i,t)}),Jc.compiler.compile(i.parser.parse(e,{grammarSource:t.grammarSource,reservedWords:i.reservedWords}),i.passes,t)}};pw.exports=Jc});var Gl="2.19.18";var Op="schemaVersion",Yn="settings",Wn="subs",zs="collections",Na="files",kg="modules",ui="artifacts",Ec="rules",Np="tokens";var Lg="Sub-Store Artifacts Repository",ka="#sub-store-cached-resource",La="#sub-store-cached-headers-resource",zl="#sub-store-chr-expiration-time";var Ua="#sub-store-cached-script-resource",Yl="#sub-store-csr-expiration-time";var Ys=typeof $task<"u",ls=typeof $loon<"u",Ws=typeof $httpClient<"u"&&!ls,Ci=eval('typeof process !== "undefined"'),Ug=typeof $environment<"u"&&$environment["stash-version"],Hg=typeof $rocket<"u",B3=typeof egern=="object",$3=typeof $native<"u",Xs=typeof $Plugins<"u",Wl=class{constructor(name="untitled",debug=!1){if(this.name=name,this.debug=debug,this.http=oi(),this.env=Dn(),Ci){let dotenv=eval('require("dotenv")');dotenv.config()}this.node=(()=>{if(Ci){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(Ys&&(this.cache=JSON.parse($prefs.valueForKey(this.name)||"{}")),(ls||Ws)&&(this.cache=JSON.parse($persistentStore.read(this.name)||"{}")),Xs&&(this.cache=JSON.parse($Plugins.SubStoreCache.get(this.name)||"{}")),Ci){let basePath=eval("process.env.SUB_STORE_DATA_BASE_PATH")||".",rootPath=`${basePath}/root.json`;this.log(`Root path: ${rootPath}`),this.node.fs.existsSync(rootPath)?this.root=JSON.parse(this.node.fs.readFileSync(`${rootPath}`)):(this.node.fs.writeFileSync(rootPath,JSON.stringify({}),{flag:"wx"}),this.root={});let fpath=`${basePath}/${this.name}.json`;this.log(`Data path: ${fpath}`),this.node.fs.existsSync(fpath)?this.cache=JSON.parse(this.node.fs.readFileSync(`${fpath}`)):(this.node.fs.writeFileSync(fpath,JSON.stringify({}),{flag:"wx"}),this.cache={})}}persistCache(){let data=JSON.stringify(this.cache,null,2);if(Ys&&$prefs.setValueForKey(data,this.name),(ls||Ws)&&$persistentStore.write(data,this.name),Xs&&$Plugins.SubStoreCache.set(this.name,data),Ci){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),Ws||ls)return $persistentStore.write(e,t);if(Ys)return $prefs.setValueForKey(e,t);if(Ci&&(this.root[t]=e),Xs)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),Ws||ls)return $persistentStore.read(e);if(Ys)return $prefs.valueForKey(e);if(Ci)return this.root[e];if(Xs)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),Ws||ls)return $persistentStore.write(null,e);if(Ys)return $prefs.removeValueForKey(e);if(Ci&&delete this.root[e],Xs)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(Ys&&$notify(title,subtitle,content,options),Ws&&$notification.post(title,subtitle,content+`${mediaURL?` \u591A\u5A92\u4F53:`+mediaURL:""}`,{url:openURL}),ls){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(Ci){let content_=content+(openURL?` \u70B9\u51FB\u8DF3\u8F6C: ${openURL}`:"")+(mediaURL?` \u591A\u5A92\u4F53: ${mediaURL}`:"");console.log(`${title} ${subtitle} ${content_} `);let push=eval("process.env.SUB_STORE_PUSH_SERVICE");if(push){let e=push.replace("[\u63A8\u9001\u6807\u9898]",encodeURIComponent(title||"Sub-Store")).replace("[\u63A8\u9001\u5185\u5BB9]",encodeURIComponent([subtitle,content_].map(r=>r).join(` `)));oi().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}`)})}}Xs&&$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={}){Ys||ls||Ws||Xs?$done(e):Ci&&typeof $context<"u"&&($context.headers=e.headers,$context.statusCode=e.statusCode,$context.body=e.body)}};function Dn(){return{isQX:Ys,isLoon:ls,isSurge:Ws,isNode:Ci,isStash:Ug,isShadowRocket:Hg,isEgern:B3,isLanceX:$3,isGUIforCores:Xs}}function oi(defaultOptions={baseURL:""}){let{isQX,isLoon,isSurge,isNode,isGUIforCores}=Dn(),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||Ug||Hg)&&(opts.timeout=Math.ceil(opts.timeout/1e3),e="s")}if(isNode){let undici=eval("require('undici')"),{ProxyAgent,EnvHttpProxyAgent,request,interceptors}=undici,agentOpts={connect:{rejectUnauthorized:!(opts.strictSSL===!1||opts.insecure===!0)},bodyTimeout:opts.timeout,headersTimeout:opts.timeout};try{let e=new URL(opts.url);(e.username||e.password)&&(opts.headers={...opts.headers||{},Authorization:`Basic ${Buffer.from(`${e.username||""}:${e.password||""}`).toString("base64")}`});let t=await request(opts.url,{...opts,method:method.toUpperCase(),dispatcher:(opts.proxy?new ProxyAgent({...agentOpts,uri:opts.proxy}):new EnvHttpProxyAgent(agentOpts)).compose(interceptors.redirect({maxRedirections:3,throwOnMaxRedirects:!0}))});resolve({statusCode:t.statusCode,headers:t.headers,body:opts.encoding===null?await t.body.arrayBuffer():await t.body.text()})}catch(e){reject(e)}}else $httpClient[method.toLowerCase()](opts,(e,t,r)=>{e?reject(e):resolve({statusCode:t.status||t.statusCode,headers:t.headers,body:r})})}):isGUIforCores&&(worker=new Promise(async(e,t)=>{try{let r=await $Plugins.Requests({method,url:options.url,headers:options.headers,body:options.body,options:{Proxy:options.proxy,Timeout:options.timeout?options.timeout/1e3:15}});e({statusCode:r.status,headers:r.headers,body:r.body})}catch(r){t(r)}}));let timeoutid,timer=timeout?new Promise((e,t)=>{timeoutid=setTimeout(()=>(events.onTimeout(),t(`${method} URL: ${options.url} exceeds the timeout ${timeout} ms`)),timeout)}):null;return(timer?Promise.race([timer,worker]).then(e=>(typeof clearTimeout<"u"&&clearTimeout(timeoutid),e)):worker).then(e=>events.onResponse(e))}let http={};return methods.forEach(e=>http[e.toLowerCase()]=t=>send(e,t)),http}var P3=new Wl("sub-store"),G=P3;function kp(){R3()}function R3(){let e=G.read(Op);e||T3(),e!=="2.0"&&G.write("2.0",Op)}function T3(){G.info("Start migrating...");let e=G.read(Wn)||{},t=Object.values(e).map(w=>(w.source=w.source||"remote",p(w),f(w),w));G.write(t,Wn);let r=G.read(zs)||{},n=Object.values(r).map(w=>(delete w.ua,p(w),f(w),w));G.write(n,zs);let i=G.read(ui)||{},a=Object.values(i);G.write(a,ui);let s=G.read(Ec)||{},o=Object.values(s);G.write(o,Ec);let l=G.read(Na)||{},h=Object.values(l);G.write(h,Na);let d=G.read(Np)||{},E=Object.values(d);G.write(E,Np),delete G.cache.builtin,G.info("Migration complete!");function p(w){let g=w["display-name"];g&&(w.displayName=g,delete w["display-name"])}function f(w){let g=w.process;if(!g||g.length===0)return;let y=[],A={type:"Quick Setting Operator",args:{udp:"DEFAULT",tfo:"DEFAULT",scert:"DEFAULT","vmess aead":"DEFAULT",useless:"DEFAULT"}};for(let S of g)if(S.type){if(S.type==="Useless Filter")A.args.useless="ENABLED";else if(S.type==="Set Property Operator"){let{key:_,value:I}=S.args;switch(_){case"udp":A.args.udp=I?"ENABLED":"DISABLED";break;case"tfo":A.args.tfo=I?"ENABLED":"DISABLED";break;case"skip-cert-verify":A.args.scert=I?"ENABLED":"DISABLED";break;case"aead":A.args["vmess aead"]=I?"ENABLED":"DISABLED";break}}else if(S.type.indexOf("Keyword")===-1)if(S.type==="Flag Operator"){let _=typeof S.args>"u"?!0:S.args;S.args={mode:_?"add":"remove"},y.push(S)}else y.push(S)}y.unshift(A),w.process=y}}function Lp({substore:$,port,host}){let{isNode}=Dn(),DEFAULT_HEADERS={"Content-Type":"text/plain;charset=UTF-8","Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"POST,GET,OPTIONS,PATCH,PUT,DELETE","Access-Control-Allow-Headers":"Origin, X-Requested-With, Content-Type, Accept","X-Powered-By":"Sub-Store"};if(isNode){let express_=eval('require("express")'),bodyParser=eval('require("body-parser")'),app=express_();return app.use(bodyParser.json({verify:rawBodySaver,limit:eval("process.env.SUB_STORE_BODY_JSON_LIMIT")||"1mb"})),app.use(bodyParser.urlencoded({verify:rawBodySaver,extended:!0})),app.use(bodyParser.raw({verify:rawBodySaver,type:"*/*"})),app.use((e,t,r)=>{t.set(DEFAULT_HEADERS),r()}),app.start=()=>{let e=app.listen(port,host,()=>{let{address:t,port:r}=e.address();$.info(`[BACKEND] ${t}:${r}`)})},app}let handlers=[],METHODS_NAMES=["GET","POST","PUT","DELETE","PATCH","OPTIONS","HEAD'","ALL"],dispatch=(e,t=0)=>{let{method:r,url:n,headers:i,body:a}=e;i=x3(i),/json/i.test(i["content-type"])&&(a=JSON.parse(a)),r=r.toUpperCase();let{path:s,query:o}=N3(n),l=null,h,d=0;for(h=t;hd&&(l=handlers[h],d=E.split("/").length)}if(l){let E=()=>{dispatch(r,n,h)},p={method:r,url:n,path:s,query:o,params:jg(l.pattern,s),headers:i,body:a},f=Response(),w=l.callback,g=y=>{f.status(500).json({status:"failed",message:`Internal Server Error: ${y}`})};if(w.constructor.name==="AsyncFunction")w(p,f,E).catch(g);else try{w(p,f,E)}catch(y){g(y)}}else Response().status(404).json({status:"failed",message:"ERROR: 404 not found"})},app={};return METHODS_NAMES.forEach(e=>{app[e.toLowerCase()]=(t,r)=>{handlers.push({method:e,pattern:t,callback:r})}}),app.route=e=>{let t={};return METHODS_NAMES.forEach(r=>{t[r.toLowerCase()]=n=>(handlers.push({method:r,pattern:e,callback:n}),t)}),t},app.start=()=>{dispatch($request)},app;function rawBodySaver(e,t,r,n){r&&r.length&&(e.rawBody=r.toString(n||"utf8"))}function Response(){let e=200,{isQX:t,isLoon:r,isSurge:n,isGUIforCores:i}=Dn(),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(o){return e=o,this}send(o=""){let l={status:t?s[e]:e,body:o,headers:a};t||i?$done(l):(r||n)&&$done({response:l})}end(){this.send()}html(o){this.set("Content-Type","text/html;charset=UTF-8"),this.send(o)}json(o){this.set("Content-Type","application/json;charset=UTF-8"),this.send(JSON.stringify(o))}set(o,l){return a[o]=l,this}}}}function x3(e){let t={};for(let r of Object.keys(e))t[r.toLowerCase()]=e[r];return t}function O3(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;i\s*/g,"__SubStoreJSYAMLString__"),...r)).replace(/__SubStoreJSYAMLString__/g,""),...r)}}function Pf(e,...t){return X2(Pc.default.safeLoad,JSON.parse(JSON.stringify(e)),...t)}function f9(e,...t){return X2(Pc.default.load,JSON.parse(JSON.stringify(e)),...t)}function h9(e,...t){return Pc.default.safeDump(JSON.parse(JSON.stringify(e)),...t)}function J2(e,...t){return Pc.default.dump(JSON.parse(JSON.stringify(e)),...t)}var Ja={safeLoad:Pf,load:f9,safeDump:h9,dump:J2};var xd=0;function li(e){return d9(p9(g9(e)))}function p9(e){return v9(E9(m9(e),e.length*8))}function d9(e){try{}catch{xd=0}for(var t=xd?"0123456789ABCDEF":"0123456789abcdef",r="",n,i=0;i>>4&15)+t.charAt(n&15);return r}function g9(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 m9(e){for(var t=Array(e.length>>2),r=0;r>5]|=(e.charCodeAt(r/8)&255)<>5]>>>r%32&255);return t}function E9(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 A9(e,t){return e<>>32-t}var jf=ln(lE()),K9=/^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)(\.(?!$)|$)){4}$/,G9=/^(([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 or(e){return K9.test(e)}function Jt(e){return G9.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 Ti(e){return typeof e=="string"&&e.trim().length>0}function Lt(e,t){return Ti(e)?e:t}function ho(e){return typeof e<"u"&&e!==null}function eu(e,t){return ho(e)?e:t}function As(e){return e?/^.+?\s*?=\s*?.+?\s*?,.+?/.test(e)?{"policy-descriptor":e}:{policy:e}:{}}function z9(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e}function xc(e){let t=e.split(/,|\//),r=t[Math.floor(Math.random()*t.length)];if(r.includes("-")){let[n,i]=r.split("-").map(Number);return z9(n,i)}else return Number(r)}function hE(e){return Number.isSafeInteger(e)?String(e):BigInt(e).toString()}function Mf(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)}var Gd=class{constructor(t){this.expires=t,G.read(ka)||G.write("{}",ka);try{this.resourceCache=JSON.parse(G.read(ka))}catch(r){G.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${ka} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${r?.message??r}`),this.resourceCache={},G.write("{}",ka)}this._cleanup()}_cleanup(){let t=!1;Object.entries(this.resourceCache).forEach(r=>{let[n,i]=r;i.time||(delete this.resourceCache[n],G.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(){G.write(JSON.stringify(this.resourceCache),ka)}get(t){let r=this.resourceCache[t]&&this.resourceCache[t].time;return r&&new Date().getTime()-r<=this.expires?this.resourceCache[t].data:null}set(t,r){this.resourceCache[t]={time:new Date().getTime(),data:r},this._persist()}},Er=new Gd(36e5);var zd=class{constructor(){this.expires=W9(),G.read(La)||G.write("{}",La);try{this.resourceCache=JSON.parse(G.read(La))}catch(t){G.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${La} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${t?.message??t}`),this.resourceCache={},G.write("{}",La)}this._cleanup()}_cleanup(){let t=!1;Object.entries(this.resourceCache).forEach(r=>{let[n,i]=r;i.time||(delete this.resourceCache[n],G.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(){G.write(JSON.stringify(this.resourceCache),La)}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 W9(){G.read(zl)||G.write("6e4",zl);let e=6e4;if(G.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=G.read("#\u54CD\u5E94\u5934\u7F13\u5B58\u6709\u6548\u671F");return r in t&&(e=t[r],e==="readcachets"&&(e=r)),e}else return e=G.read(zl),e}var Oc=new zd;function po(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 xi(rawUrl,ua,timeout,customProxy,flowUrl){let url=flowUrl||rawUrl||"",$arguments={},rawArgs=url.split("#");if(url=url.split("#")[0],rawArgs.length>1)try{$arguments=JSON.parse(decodeURIComponent(rawArgs[1]))}catch{for(let t of rawArgs[1].split("&")){let r=t.split("=")[0],n=t.split("=")[1];$arguments[r]=n==null||n===""?!0:decodeURIComponent(n)}}if($arguments?.noFlow)return;let{isStash,isLoon,isShadowRocket,isQX}=Dn(),insecure=$arguments?.insecure?G.env.isNode?{strictSSL:!1}:{insecure:!0}:void 0,{defaultProxy,defaultFlowUserAgent,defaultTimeout}=G.read(Yn),proxy=customProxy||defaultProxy;G.env.isNode&&(proxy=proxy||eval("process.env.SUB_STORE_BACKEND_DEFAULT_PROXY"));let userAgent=ua||defaultFlowUserAgent||"clash",requestTimeout=timeout||defaultTimeout||8e3,id=li(userAgent+url),cached=Oc.get(id),flowInfo;if(!$arguments?.noCache&&cached)G.info(`\u4F7F\u7528\u7F13\u5B58\u7684\u6D41\u91CF\u4FE1\u606F: ${url}, ${userAgent}`),flowInfo=cached;else{let e=oi();if(flowUrl){G.info(`\u4F7F\u7528 GET \u65B9\u6CD5\u4ECE\u54CD\u5E94\u4F53\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F: ${flowUrl}, User-Agent: ${userAgent||""}, Insecure: ${!!insecure}, Proxy: ${proxy}`);let{body:t}=await e.get({url:flowUrl,headers:{"User-Agent":userAgent},timeout:requestTimeout,...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?As(proxy):{},...insecure||{}});flowInfo=t}else{try{G.info(`\u4F7F\u7528 HEAD \u65B9\u6CD5\u4ECE\u54CD\u5E94\u5934\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F: ${url}, User-Agent: ${userAgent||""}, Insecure: ${!!insecure}, Proxy: ${proxy}`);let{headers:t}=await e.head({url:url.split(/[\r\n]+/).map(r=>r.trim()).filter(r=>r.length)[0],headers:{"User-Agent":userAgent,...isStash&&proxy?{"X-Stash-Selected-Proxy":encodeURIComponent(proxy)}:{},...isShadowRocket&&proxy?{"X-Surge-Policy":proxy}:{}},timeout:requestTimeout,...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?As(proxy):{},...insecure||{}});flowInfo=po(t)}catch(t){G.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){G.info(`\u4F7F\u7528 GET \u65B9\u6CD5\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F: ${url}, User-Agent: ${userAgent||""}, Insecure: ${!!insecure}, Proxy: ${proxy}`);let{headers:t}=await e.get({url:url.split(/[\r\n]+/).map(r=>r.trim()).filter(r=>r.length)[0],headers:{"User-Agent":userAgent,...isStash&&proxy?{"X-Stash-Selected-Proxy":encodeURIComponent(proxy)}:{},...isShadowRocket&&proxy?{"X-Surge-Policy":proxy}:{}},timeout:requestTimeout,...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?As(proxy):{},...insecure||{}});flowInfo=po(t)}}flowInfo&&(flowInfo=flowInfo.trim()),flowInfo&&Oc.set(id,flowInfo)}return flowInfo}function qf(e){if(!e)return;let t=e.match(/upload=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),r=Number(t[1]+t[2]),n=e.match(/download=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),i=Number(n[1]+n[2]),a=e.match(/total=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),s=Number(a[1]+a[2]),o=e.match(/expire=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),l=o?Number(o[1]+o[2]):void 0,h=e.match(/reset_day=([0-9]+)/),d=h?Number(h[1]):void 0,E=e.match(/app_url=(.*?)\s*?(;|$)/),p=E?decodeURIComponent(E[1]):void 0,f=e.match(/plan_name=(.*?)\s*?(;|$)/),w=f?decodeURIComponent(f[1]):void 0;return{expires:l,total:s,usage:{upload:r,download:i},remainingDays:d,appUrl:p,planName:w}}function Nc(e,t="B"){let r=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],n=r.indexOf(t);return e<1024||n===r.length-1?{value:e.toFixed(1),unit:t}:Nc(e/1024,r[++n])}function Vf(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(),o=i.getFullYear(),l;return t>a?l=0:l=new Date(o,s+1,0).getDate(),l-a+t}}catch(t){G.error(`getRmainingDays failed: ${t.message??t}`)}}function go(e){try{let t=new Map;return e.split(";").map(r=>r.trim()).filter(Boolean).forEach(r=>{let n=r.indexOf("=");if(n===-1)return;let i=r.slice(0,n).trim(),a=r.slice(n+1).trim();if(!t.has(i))try{let s=decodeURIComponent(a);t.set(i,s)}catch{t.set(i,a)}}),Array.from(t.entries()).map(([r,n])=>`${r}=${encodeURIComponent(n)}`).join("; ")}catch(t){return G.error(`normalizeFlowHeader failed: ${t.message??t}`),e}}var AE="3.7.7",X9=AE,vo=typeof Buffer=="function",dE=typeof TextDecoder=="function"?new TextDecoder:void 0,gE=typeof TextEncoder=="function"?new TextEncoder:void 0,J9="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",kc=Array.prototype.slice.call(J9),Kf=(e=>{let t={};return e.forEach((r,n)=>t[r]=n),t})(kc),Z9=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,_r=String.fromCharCode.bind(String),mE=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):e=>new Uint8Array(Array.prototype.slice.call(e,0)),wE=e=>e.replace(/=/g,"").replace(/[+\/]/g,t=>t=="+"?"-":"_"),yE=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),SE=e=>{let t,r,n,i,a="",s=e.length%3;for(let o=0;o255||(n=e.charCodeAt(o++))>255||(i=e.charCodeAt(o++))>255)throw new TypeError("invalid character found");t=r<<16|n<<8|i,a+=kc[t>>18&63]+kc[t>>12&63]+kc[t>>6&63]+kc[t&63]}return s?a.slice(0,s-3)+"===".substring(s):a},Xd=typeof btoa=="function"?e=>btoa(e):vo?e=>Buffer.from(e,"binary").toString("base64"):SE,Yd=vo?e=>Buffer.from(e).toString("base64"):e=>{let r=[];for(let n=0,i=e.length;nt?wE(Yd(e)):Yd(e),Q9=e=>{if(e.length<2){var t=e.charCodeAt(0);return t<128?e:t<2048?_r(192|t>>>6)+_r(128|t&63):_r(224|t>>>12&15)+_r(128|t>>>6&63)+_r(128|t&63)}else{var t=65536+(e.charCodeAt(0)-55296)*1024+(e.charCodeAt(1)-56320);return _r(240|t>>>18&7)+_r(128|t>>>12&63)+_r(128|t>>>6&63)+_r(128|t&63)}},eD=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,bE=e=>e.replace(eD,Q9),vE=vo?e=>Buffer.from(e,"utf8").toString("base64"):gE?e=>Yd(gE.encode(e)):e=>Xd(bE(e)),mo=(e,t=!1)=>t?wE(vE(e)):vE(e),EE=e=>mo(e,!0),tD=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,rD=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 _r((r>>>10)+55296)+_r((r&1023)+56320);case 3:return _r((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return _r((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},CE=e=>e.replace(tD,rD),FE=e=>{if(e=e.replace(/\s+/g,""),!Z9.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?_r(t>>16&255,t>>8&255):_r(t>>16&255,t>>8&255,t&255);return r},Jd=typeof atob=="function"?e=>atob(yE(e)):vo?e=>Buffer.from(e,"base64").toString("binary"):FE,_E=vo?e=>mE(Buffer.from(e,"base64")):e=>mE(Jd(e).split("").map(t=>t.charCodeAt(0))),IE=e=>_E(DE(e)),nD=vo?e=>Buffer.from(e,"base64").toString("utf8"):dE?e=>dE.decode(_E(e)):e=>CE(Jd(e)),DE=e=>yE(e.replace(/[-_]/g,t=>t=="-"?"+":"/")),Wd=e=>nD(DE(e)),iD=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)},BE=e=>({value:e,enumerable:!1,writable:!0,configurable:!0}),$E=function(){let e=(t,r)=>Object.defineProperty(String.prototype,t,BE(r));e("fromBase64",function(){return Wd(this)}),e("toBase64",function(t){return mo(this,t)}),e("toBase64URI",function(){return mo(this,!0)}),e("toBase64URL",function(){return mo(this,!0)}),e("toUint8Array",function(){return IE(this)})},PE=function(){let e=(t,r)=>Object.defineProperty(Uint8Array.prototype,t,BE(r));e("toBase64",function(t){return Gf(this,t)}),e("toBase64URI",function(){return Gf(this,!0)}),e("toBase64URL",function(){return Gf(this,!0)})},sD=()=>{$E(),PE()},Et={version:AE,VERSION:X9,atob:Jd,atobPolyfill:FE,btoa:Xd,btoaPolyfill:SE,fromBase64:Wd,toBase64:mo,encode:mo,encodeURI:EE,encodeURL:EE,utob:bE,btou:CE,decode:Wd,isValid:iD,fromUint8Array:Gf,toUint8Array:IE,extendString:$E,extendUint8Array:PE,extendBuiltins:sD};function aD(){return{name:"HTML",test:n=>/^/.test(n),parse:()=>""}}function uD(){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=Et.decode(i);return/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(a)?a:(G.error("Base64 Pre-processor error: decoded line does not start with protocol"),i)}}}function oD(){return{name:"Clash Pre-processor",test:function(n){if(!/proxies/.test(n))return!1;let i=Pf(n);return i.proxies&&Array.isArray(i.proxies)},parse:function(n,i){let a=n.replace(/short-id:([ \t]*[^#\n,}]*)/g,(l,h)=>{let d=h.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":o}=Pf(a);return(i?`proxies: `:"")+s.map(l=>(o&&!l["client-fingerprint"]&&(l["client-fingerprint"]=o),`${i?" - ":""}${JSON.stringify(l)} `)).join("")}}}function cD(){return{name:"SSD Pre-processor",test:function(n){return n.indexOf("ssd://")===0},parse:function(n){let i=[],a=JSON.parse(Et.decode(n.split("ssd://")[1])),s=a.port,o=a.encryption,l=a.password,h=a.servers;for(let d=0;de.name==="Clash Pre-processor"),Zd=new Map;async function Ir(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}=Dn(),{defaultProxy,defaultUserAgent,defaultTimeout,cacheThreshold:defaultCacheThreshold}=G.read(Yn),cacheThreshold=defaultCacheThreshold||1024,proxy=customProxy||defaultProxy;G.env.isNode&&(proxy=proxy||eval("process.env.SUB_STORE_BACKEND_DEFAULT_PROXY"));let userAgent=ua||defaultUserAgent||"clash.meta",requestTimeout=timeout||defaultTimeout||8e3,id=li(userAgent+url);$arguments?.cacheKey===!0&&(G.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=G.read(customCacheKey),t=Er.get(id);if(!noCache&&!$arguments?.noCache&&t)return G.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){G.info(`\u4E50\u89C2\u7F13\u5B58: URL ${url} \u672C\u6B21\u8FDB\u884C\u8BF7\u6C42 \u5C1D\u8BD5\u66F4\u65B0\u7F13\u5B58`);try{await Ir(rawUrl.replace(/(\?|&)cacheKey=.*?(&|$)/,""),ua,timeout,proxy,!0,void 0,void 0,preprocess)}catch(r){G.error(`\u4E50\u89C2\u7F13\u5B58: URL ${url} \u66F4\u65B0\u7F13\u5B58\u53D1\u751F\u9519\u8BEF ${r.message??r}`),G.info("\u4F7F\u7528\u4E50\u89C2\u7F13\u5B58\u7684\u6570\u636E\u5237\u65B0\u7F13\u5B58, \u9632\u6B62\u540E\u7EED\u8BF7\u6C42"),Er.set(id,e)}}else G.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`),Ir(rawUrl.replace(/(\?|&)cacheKey=.*?(&|$)/,""),ua,timeout,proxy,!0,void 0,void 0,preprocess).catch(r=>{G.error(`\u4E50\u89C2\u7F13\u5B58: URL ${url} \u5F02\u6B65\u66F4\u65B0\u7F13\u5B58\u53D1\u751F\u9519\u8BEF ${r.message??r}`)});return e}}if(!isNode&&Zd.has(id))return Zd.get(id);let http=oi({headers:{"User-Agent":userAgent,...isStash&&proxy?{"X-Stash-Selected-Proxy":encodeURIComponent(proxy)}:{},...isShadowRocket&&proxy?{"X-Surge-Policy":proxy}:{}},timeout:requestTimeout}),result,cached=Er.get(id);if(!noCache&&!$arguments?.noCache&&cached)G.info(`\u4F7F\u7528\u7F13\u5B58: ${url}, ${userAgent}`),result=cached,customCacheKey&&(G.info(`URL ${url} \u5199\u5165\u81EA\u5B9A\u4E49\u7F13\u5B58 ${$arguments?.cacheKey}`),G.write(cached,customCacheKey));else{let e=$arguments?.insecure?isNode?{strictSSL:!1}:{insecure:!0}:void 0;G.info(`Downloading... User-Agent: ${userAgent} Timeout: ${requestTimeout} Proxy: ${proxy} Insecure: ${!!e} Preprocess: ${preprocess} URL: ${url}`);try{let{body:t,headers:r,statusCode:n}=await http.get({url,...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?As(proxy):{},...e||{}});if(G.info(`statusCode: ${n}`),n<200||n>=400)throw new Error(`statusCode: ${n}`);if(r){let a=po(r);a&&Oc.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{RE.test(t)&&(t=RE.parse(t,!0))}catch(a){G.error(`Clash Pre-processor error: ${a}`)}let i=!0;if(cacheThreshold){let a=t.length/1024;a>cacheThreshold&&(G.info(`\u8D44\u6E90\u5927\u5C0F ${a.toFixed(2)} KB \u8D85\u8FC7\u4E86 ${cacheThreshold} KB, \u4E0D\u7F13\u5B58`),i=!1)}i&&(Er.set(id,t),customCacheKey&&(G.info(`URL ${url} \u5199\u5165\u81EA\u5B9A\u4E49\u7F13\u5B58 ${$arguments?.cacheKey}`),G.write(t,customCacheKey))),result=t}catch(t){if(customCacheKey){let r=G.read(customCacheKey);if(r)return G.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 Vf(qf(await xi(url,$arguments.flowUserAgent,void 0,proxy,$arguments.flowUrl))),isNode||Zd.set(id,result),result}var Qd=class{constructor(){this.expires=fD(),G.read(Ua)||G.write("{}",Ua);try{this.resourceCache=JSON.parse(G.read(Ua))}catch(t){G.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${Ua} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${t?.message??t}`),this.resourceCache={},G.write("{}",Ua)}this._cleanup()}_cleanup(t,r){let n=!1;Object.entries(this.resourceCache).forEach(i=>{let[a,s]=i;s.time||(delete this.resourceCache[a],G.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(){G.write(JSON.stringify(this.resourceCache),Ua)}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 fD(){G.read(Yl)||G.write("1728e5",Yl);let e=1728e5;if(G.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=G.read("#\u8282\u70B9\u7F13\u5B58\u6709\u6548\u671F");return r in t&&(e=t[r],e==="readcachets"&&(e=r)),e}else return e=G.read(Yl),e}var e0=new Qd;function Yf(e,t){return[...Array(e).keys()].map(()=>t)}var t0={"\u{1F3F3}\uFE0F\u200D\u{1F308}":["EXP","BAND"],"\u{1F1F8}\u{1F1F1}":["TEST","SOS"],"\u{1F1E6}\u{1F1E9}":["AD","AND"],"\u{1F1E6}\u{1F1EA}":["AE","ARE"],"\u{1F1E6}\u{1F1EB}":["AF","AFG"],"\u{1F1E6}\u{1F1F1}":["AL","ALB"],"\u{1F1E6}\u{1F1F2}":["AM","ARM"],"\u{1F1E6}\u{1F1F7}":["AR","ARG"],"\u{1F1E6}\u{1F1F9}":["AT","AUT"],"\u{1F1E6}\u{1F1FA}":["AU","AUS"],"\u{1F1E6}\u{1F1FF}":["AZ","AZE"],"\u{1F1E7}\u{1F1E6}":["BA","BIH"],"\u{1F1E7}\u{1F1E9}":["BD","BGD"],"\u{1F1E7}\u{1F1EA}":["BE","BEL"],"\u{1F1E7}\u{1F1EC}":["BG","BGR"],"\u{1F1E7}\u{1F1ED}":["BH","BHR"],"\u{1F1E7}\u{1F1F4}":["BO","BOL"],"\u{1F1E7}\u{1F1F3}":["BN","BRN"],"\u{1F1E7}\u{1F1F7}":["BR","BRA"],"\u{1F1E7}\u{1F1F9}":["BT","BTN"],"\u{1F1E7}\u{1F1FE}":["BY","BLR"],"\u{1F1E8}\u{1F1E6}":["CA","CAN"],"\u{1F1E8}\u{1F1ED}":["CH","CHE"],"\u{1F1E8}\u{1F1F1}":["CL","CHL"],"\u{1F1E8}\u{1F1F4}":["CO","COL"],"\u{1F1E8}\u{1F1F7}":["CR","CRI"],"\u{1F1E8}\u{1F1FE}":["CY","CYP"],"\u{1F1E8}\u{1F1FF}":["CZ","CZE"],"\u{1F1E9}\u{1F1EA}":["DE","DEU"],"\u{1F1E9}\u{1F1F0}":["DK","DNK"],"\u{1F1EA}\u{1F1E8}":["EC","ECU"],"\u{1F1EA}\u{1F1EA}":["EE","EST"],"\u{1F1EA}\u{1F1EC}":["EG","EGY"],"\u{1F1EA}\u{1F1F8}":["ES","ESP"],"\u{1F1EA}\u{1F1FA}":["EU"],"\u{1F1EB}\u{1F1EE}":["FI","FIN"],"\u{1F1EB}\u{1F1F7}":["FR","FRA"],"\u{1F1EC}\u{1F1E7}":["GB","GBR","UK"],"\u{1F1EC}\u{1F1EA}":["GE","GEO"],"\u{1F1EC}\u{1F1F7}":["GR","GRC"],"\u{1F1EC}\u{1F1F9}":["GT","GTM"],"\u{1F1EC}\u{1F1FA}":["GU","GUM"],"\u{1F1ED}\u{1F1F0}":["HK","HKG","HKT","HKBN","HGC","WTT","CMI"],"\u{1F1ED}\u{1F1F7}":["HR","HRV"],"\u{1F1ED}\u{1F1FA}":["HU","HUN"],"\u{1F1EF}\u{1F1F4}":["JO","JOR"],"\u{1F1EF}\u{1F1F5}":["JP","JPN","TYO"],"\u{1F1F0}\u{1F1EA}":["KE","KEN"],"\u{1F1F0}\u{1F1EC}":["KG","KGZ"],"\u{1F1F0}\u{1F1ED}":["KH","KGZ"],"\u{1F1F0}\u{1F1F5}":["KP","PRK"],"\u{1F1F0}\u{1F1F7}":["KR","KOR","SEL"],"\u{1F1F0}\u{1F1FF}":["KZ","KAZ"],"\u{1F1EE}\u{1F1E9}":["ID","IDN"],"\u{1F1EE}\u{1F1EA}":["IE","IRL"],"\u{1F1EE}\u{1F1F1}":["IL","ISR"],"\u{1F1EE}\u{1F1F2}":["IM","IMN"],"\u{1F1EE}\u{1F1F3}":["IN","IND"],"\u{1F1EE}\u{1F1F7}":["IR","IRN"],"\u{1F1EE}\u{1F1F8}":["IS","ISL"],"\u{1F1EE}\u{1F1F9}":["IT","ITA"],"\u{1F1F1}\u{1F1E6}":["LA","LAO"],"\u{1F1F1}\u{1F1F0}":["LK","LKA"],"\u{1F1F1}\u{1F1F9}":["LT","LTU"],"\u{1F1F1}\u{1F1FA}":["LU","LUX"],"\u{1F1F1}\u{1F1FB}":["LV","LVA"],"\u{1F1F2}\u{1F1E6}":["MA","MAR"],"\u{1F1F2}\u{1F1E9}":["MD","MDA"],"\u{1F1F3}\u{1F1EC}":["NG","NGA"],"\u{1F1F2}\u{1F1F2}":["MM","MMR"],"\u{1F1F2}\u{1F1F0}":["MK","MKD"],"\u{1F1F2}\u{1F1F3}":["MN","MNG"],"\u{1F1F2}\u{1F1F4}":["MO","MAC","CTM"],"\u{1F1F2}\u{1F1F9}":["MT","MLT"],"\u{1F1F2}\u{1F1FD}":["MX","MEX"],"\u{1F1F2}\u{1F1FE}":["MY","MYS"],"\u{1F1F3}\u{1F1F1}":["NL","NLD","AMS"],"\u{1F1F3}\u{1F1F4}":["NO","NOR"],"\u{1F1F3}\u{1F1F5}":["NP","NPL"],"\u{1F1F3}\u{1F1FF}":["NZ","NZL"],"\u{1F1F5}\u{1F1E6}":["PA","PAN"],"\u{1F1F5}\u{1F1EA}":["PE","PER"],"\u{1F1F5}\u{1F1ED}":["PH","PHL"],"\u{1F1F5}\u{1F1F0}":["PK","PAK"],"\u{1F1F5}\u{1F1F1}":["PL","POL"],"\u{1F1F5}\u{1F1F7}":["PR","PRI"],"\u{1F1F5}\u{1F1F9}":["PT","PRT"],"\u{1F1F5}\u{1F1FE}":["PY","PRY"],"\u{1F1F5}\u{1F1EC}":["PG","PNG"],"\u{1F1F7}\u{1F1F4}":["RO","ROU"],"\u{1F1F7}\u{1F1F8}":["RS","SRB"],"\u{1F1F7}\u{1F1EA}":["RE","REU"],"\u{1F1F7}\u{1F1FA}":["RU","RUS"],"\u{1F1F8}\u{1F1E6}":["SA","SAU"],"\u{1F1F8}\u{1F1EA}":["SE","SWE"],"\u{1F1F8}\u{1F1EC}":["SG","SGP"],"\u{1F1F8}\u{1F1EE}":["SI","SVN"],"\u{1F1F8}\u{1F1F0}":["SK","SVK"],"\u{1F1F9}\u{1F1ED}":["TH","THA"],"\u{1F1F9}\u{1F1F3}":["TN","TUN"],"\u{1F1F9}\u{1F1F7}":["TR","TUR"],"\u{1F1F9}\u{1F1FC}":["TW","TWN","CHT","HINET","ROC"],"\u{1F1FA}\u{1F1E6}":["UA","UKR"],"\u{1F1FA}\u{1F1F8}":["US","USA","LAX","SFO","SJC"],"\u{1F1FA}\u{1F1FE}":["UY","URY"],"\u{1F1FB}\u{1F1EA}":["VE","VEN"],"\u{1F1FB}\u{1F1F3}":["VN","VNM"],"\u{1F1FF}\u{1F1E6}":["ZA","ZAF","JNB"],"\u{1F1E8}\u{1F1F3}":["CN","CHN","BACK"]};function Eo(e){let t={"\u{1F3F3}\uFE0F\u200D\u{1F308}":["\u6D41\u91CF","\u65F6\u95F4","\u8FC7\u671F","Bandwidth","Expire"],"\u{1F1F8}\u{1F1F1}":["\u5E94\u6025","\u6D4B\u8BD5\u8282\u70B9"],"\u{1F1E6}\u{1F1E9}":["Andorra","\u5B89\u9053\u5C14"],"\u{1F1E6}\u{1F1EA}":["United Arab Emirates","\u963F\u8054\u914B","\u8FEA\u62DC"],"\u{1F1E6}\u{1F1EB}":["Afghanistan","\u963F\u5BCC\u6C57"],"\u{1F1E6}\u{1F1F1}":["Albania","\u963F\u5C14\u5DF4\u5C3C\u4E9A","\u963F\u723E\u5DF4\u5C3C\u4E9E"],"\u{1F1E6}\u{1F1F2}":["Armenia","\u4E9A\u7F8E\u5C3C\u4E9A"],"\u{1F1E6}\u{1F1F7}":["Argentina","\u963F\u6839\u5EF7"],"\u{1F1E6}\u{1F1F9}":["Austria","\u5965\u5730\u5229","\u5967\u5730\u5229","\u7EF4\u4E5F\u7EB3"],"\u{1F1E6}\u{1F1FA}":["Australia","\u6FB3\u5927\u5229\u4E9A","\u6FB3\u6D32","\u58A8\u5C14\u672C","\u6089\u5C3C","\u571F\u6FB3","\u4EAC\u6FB3","\u5EE3\u6FB3","\u6EEC\u6FB3","\u6CAA\u6FB3","\u5E7F\u6FB3","Sydney"],"\u{1F1E6}\u{1F1FF}":["Azerbaijan","\u963F\u585E\u62DC\u7586"],"\u{1F1E7}\u{1F1E6}":["Bosnia and Herzegovina","\u6CE2\u9ED1\u5171\u548C\u56FD","\u6CE2\u9ED1"],"\u{1F1E7}\u{1F1E9}":["Bangladesh","\u5B5F\u52A0\u62C9\u56FD","\u5B5F\u52A0\u62C9"],"\u{1F1E7}\u{1F1EA}":["Belgium","\u6BD4\u5229\u65F6","\u6BD4\u5229\u6642"],"\u{1F1E7}\u{1F1EC}":["Bulgaria","\u4FDD\u52A0\u5229\u4E9A","\u4FDD\u52A0\u5229\u4E9E"],"\u{1F1E7}\u{1F1ED}":["Bahrain","\u5DF4\u6797"],"\u{1F1E7}\u{1F1F7}":["Brazil","\u5DF4\u897F","\u5723\u4FDD\u7F57"],"\u{1F1E7}\u{1F1F3}":["Brunei","\u6587\u83B1","\u6C76\u840A"],"\u{1F1E7}\u{1F1FE}":["Belarus","\u767D\u4FC4\u7F57\u65AF","\u767D\u4FC4"],"\u{1F1E7}\u{1F1F4}":["Bolivia","\u73BB\u5229\u7EF4\u4E9A"],"\u{1F1E7}\u{1F1F9}":["Bhutan","\u4E0D\u4E39","\u4E0D\u4E39\u738B\u56FD"],"\u{1F1E8}\u{1F1E6}":["Canada","\u52A0\u62FF\u5927","\u8499\u7279\u5229\u5C14","\u6E29\u54E5\u534E","\u6953\u8449","\u67AB\u53F6","\u6ED1\u94C1\u5362","\u591A\u4F26\u591A","Waterloo","Toronto"],"\u{1F1E8}\u{1F1ED}":["Switzerland","\u745E\u58EB","\u82CF\u9ECE\u4E16","Zurich"],"\u{1F1E8}\u{1F1F1}":["Chile","\u667A\u5229"],"\u{1F1E8}\u{1F1F4}":["Colombia","\u54E5\u4F26\u6BD4\u4E9A"],"\u{1F1E8}\u{1F1F7}":["Costa Rica","\u54E5\u65AF\u8FBE\u9ECE\u52A0"],"\u{1F1E8}\u{1F1FE}":["Cyprus","\u585E\u6D66\u8DEF\u65AF"],"\u{1F1E8}\u{1F1FF}":["Czechia","\u6377\u514B"],"\u{1F1E9}\u{1F1EA}":["German","\u5FB7\u56FD","\u5FB7\u570B","\u4EAC\u5FB7","\u6EEC\u5FB7","\u5EE3\u5FB7","\u6CAA\u5FB7","\u5E7F\u5FB7","\u6CD5\u5170\u514B\u798F","Frankfurt","\u5FB7\u610F\u5FD7"],"\u{1F1E9}\u{1F1F0}":["Denmark","\u4E39\u9EA6","\u4E39\u9EA5"],"\u{1F1EA}\u{1F1E8}":["Ecuador","\u5384\u74DC\u591A\u5C14"],"\u{1F1EA}\u{1F1EA}":["Estonia","\u7231\u6C99\u5C3C\u4E9A"],"\u{1F1EA}\u{1F1EC}":["Egypt","\u57C3\u53CA"],"\u{1F1EA}\u{1F1F8}":["Spain","\u897F\u73ED\u7259"],"\u{1F1EA}\u{1F1FA}":["European Union","\u6B27\u76DF","\u6B27\u7F57\u5DF4"],"\u{1F1EB}\u{1F1EE}":["Finland","\u82AC\u5170","\u82AC\u862D","\u8D6B\u5C14\u8F9B\u57FA"],"\u{1F1EB}\u{1F1F7}":["France","\u6CD5\u56FD","\u6CD5\u570B","\u5DF4\u9ECE"],"\u{1F1EC}\u{1F1E7}":["Great Britain","\u82F1\u56FD","England","United Kingdom","\u4F26\u6566","\u82F1","London"],"\u{1F1EC}\u{1F1EA}":["Georgia","\u683C\u9C81\u5409\u4E9A","\u683C\u9B6F\u5409\u4E9E"],"\u{1F1EC}\u{1F1F7}":["Greece","\u5E0C\u814A","\u5E0C\u81D8"],"\u{1F1EC}\u{1F1FA}":["Guam","\u5173\u5C9B","\u95DC\u5CF6"],"\u{1F1EC}\u{1F1F9}":["Guatemala","\u5371\u5730\u9A6C\u62C9"],"\u{1F1ED}\u{1F1F0}":["Hongkong","\u9999\u6E2F","Hong Kong","HongKong","HONG KONG","\u6DF1\u6E2F","\u6CAA\u6E2F","\u547C\u6E2F","\u7A57\u6E2F","\u4EAC\u6E2F","\u6E2F"],"\u{1F1ED}\u{1F1F7}":["Croatia","\u514B\u7F57\u5730\u4E9A","\u514B\u7F85\u5730\u4E9E"],"\u{1F1ED}\u{1F1FA}":["Hungary","\u5308\u7259\u5229"],"\u{1F1EF}\u{1F1F4}":["Jordan","\u7EA6\u65E6"],"\u{1F1EF}\u{1F1F5}":["Japan","\u65E5\u672C","\u4E1C\u4EAC","\u5927\u962A","\u57FC\u7389","\u6CAA\u65E5","\u7A57\u65E5","\u5DDD\u65E5","\u4E2D\u65E5","\u6CC9\u65E5","\u676D\u65E5","\u6DF1\u65E5","\u8FBD\u65E5","\u5E7F\u65E5","\u5927\u5742","Osaka","Tokyo"],"\u{1F1F0}\u{1F1EA}":["Kenya","\u80AF\u5C3C\u4E9A"],"\u{1F1F0}\u{1F1EC}":["Kyrgyzstan","\u5409\u5C14\u5409\u65AF\u65AF\u5766"],"\u{1F1F0}\u{1F1ED}":["Cambodia","\u67EC\u57D4\u5BE8"],"\u{1F1F0}\u{1F1F5}":["North Korea","\u671D\u9C9C"],"\u{1F1F0}\u{1F1F7}":["Korea","\u97E9\u56FD","\u97D3\u570B","\u97E9","\u97D3","\u9996\u5C14","\u6625\u5DDD","Chuncheon","Seoul"],"\u{1F1F0}\u{1F1FF}":["Kazakhstan","\u54C8\u8428\u514B\u65AF\u5766","\u54C8\u8428\u514B"],"\u{1F1EE}\u{1F1E9}":["Indonesia","\u5370\u5C3C","\u5370\u5EA6\u5C3C\u897F\u4E9A","\u96C5\u52A0\u8FBE"],"\u{1F1EE}\u{1F1EA}":["Ireland","\u7231\u5C14\u5170","\u611B\u723E\u862D","\u90FD\u67CF\u6797"],"\u{1F1EE}\u{1F1F1}":["Israel","\u4EE5\u8272\u5217"],"\u{1F1EE}\u{1F1F2}":["Isle of Man","\u9A6C\u6069\u5C9B","\u99AC\u6069\u5CF6"],"\u{1F1EE}\u{1F1F3}":["India","\u5370\u5EA6","\u5B5F\u4E70","MFumbai","Mumbai"],"\u{1F1EE}\u{1F1F7}":["Iran","\u4F0A\u6717"],"\u{1F1EE}\u{1F1F8}":["Iceland","\u51B0\u5C9B","\u51B0\u5CF6"],"\u{1F1EE}\u{1F1F9}":["Italy","\u610F\u5927\u5229","\u7FA9\u5927\u5229","\u7C73\u5170","Nachash"],"\u{1F1F1}\u{1F1F0}":["Sri Lanka","\u65AF\u91CC\u5170\u5361","\u65AF\u91CC\u862D\u5361"],"\u{1F1F1}\u{1F1E6}":["Laos","\u8001\u631D","\u8001\u64BE"],"\u{1F1F1}\u{1F1F9}":["Lithuania","\u7ACB\u9676\u5B9B"],"\u{1F1F1}\u{1F1FA}":["Luxembourg","\u5362\u68EE\u5821"],"\u{1F1F1}\u{1F1FB}":["Latvia","\u62C9\u8131\u7EF4\u4E9A","Latvija"],"\u{1F1F2}\u{1F1E6}":["Morocco","\u6469\u6D1B\u54E5"],"\u{1F1F2}\u{1F1E9}":["Moldova","\u6469\u5C14\u591A\u74E6","\u6469\u723E\u591A\u74E6"],"\u{1F1F2}\u{1F1F2}":["Myanmar","\u7F05\u7538","\u7DEC\u7538"],"\u{1F1F3}\u{1F1EC}":["Nigeria","\u5C3C\u65E5\u5229\u4E9A","\u5C3C\u65E5\u5229\u4E9E"],"\u{1F1F2}\u{1F1F0}":["Macedonia","\u9A6C\u5176\u987F","\u99AC\u5176\u9813"],"\u{1F1F2}\u{1F1F3}":["Mongolia","\u8499\u53E4"],"\u{1F1F2}\u{1F1F4}":["Macao","\u6FB3\u95E8","\u6FB3\u9580","CTM"],"\u{1F1F2}\u{1F1F9}":["Malta","\u9A6C\u8033\u4ED6"],"\u{1F1F2}\u{1F1FD}":["Mexico","\u58A8\u897F\u54E5"],"\u{1F1F2}\u{1F1FE}":["Malaysia","\u9A6C\u6765","\u99AC\u4F86","\u5409\u9686\u5761","\u5927\u99AC"],"\u{1F1F3}\u{1F1F1}":["Netherlands","\u8377\u5170","\u8377\u862D","\u5C3C\u5FB7\u862D","\u963F\u59C6\u65AF\u7279\u4E39","Amsterdam"],"\u{1F1F3}\u{1F1F4}":["Norway","\u632A\u5A01"],"\u{1F1F3}\u{1F1F5}":["Nepal","\u5C3C\u6CCA\u5C14"],"\u{1F1F3}\u{1F1FF}":["New Zealand","\u65B0\u897F\u5170","\u65B0\u897F\u862D"],"\u{1F1F5}\u{1F1E6}":["Panama","\u5DF4\u62FF\u9A6C"],"\u{1F1F5}\u{1F1EA}":["Peru","\u79D8\u9C81","\u7955\u9B6F"],"\u{1F1F5}\u{1F1ED}":["Philippines","\u83F2\u5F8B\u5BBE","\u83F2\u5F8B\u8CD3"],"\u{1F1F5}\u{1F1F0}":["Pakistan","\u5DF4\u57FA\u65AF\u5766"],"\u{1F1F5}\u{1F1F1}":["Poland","\u6CE2\u5170","\u6CE2\u862D","\u534E\u6C99","Warsaw"],"\u{1F1F5}\u{1F1F7}":["Puerto Rico","\u6CE2\u591A\u9ECE\u5404"],"\u{1F1F5}\u{1F1F9}":["Portugal","\u8461\u8404\u7259"],"\u{1F1F5}\u{1F1EC}":["Papua New Guinea","\u5DF4\u5E03\u4E9A\u65B0\u51E0\u5185\u4E9A"],"\u{1F1F5}\u{1F1FE}":["Paraguay","\u5DF4\u62C9\u572D"],"\u{1F1F7}\u{1F1F4}":["Romania","\u7F57\u9A6C\u5C3C\u4E9A"],"\u{1F1F7}\u{1F1F8}":["Serbia","\u585E\u5C14\u7EF4\u4E9A"],"\u{1F1F7}\u{1F1EA}":["R\xE9union","\u7559\u5C3C\u6C6A","\u6CD5\u5C5E\u7559\u5C3C\u6C6A"],"\u{1F1F7}\u{1F1FA}":["Russia","\u4FC4\u7F57\u65AF","\u4FC4\u56FD","\u4FC4\u7F85\u65AF","\u4F2F\u529B","\u83AB\u65AF\u79D1","\u5723\u5F7C\u5F97\u5821","\u897F\u4F2F\u5229\u4E9A","\u4EAC\u4FC4","\u676D\u4FC4","\u5EE3\u4FC4","\u6EEC\u4FC4","\u5E7F\u4FC4","\u6CAA\u4FC4","Moscow"],"\u{1F1F8}\u{1F1E6}":["Saudi","\u6C99\u7279\u963F\u62C9\u4F2F","\u6C99\u7279","Riyadh","\u5229\u96C5\u5F97"],"\u{1F1F8}\u{1F1EA}":["Sweden","\u745E\u5178","\u65AF\u5FB7\u54E5\u5C14\u6469","Stockholm"],"\u{1F1F8}\u{1F1EC}":["Singapore","\u65B0\u52A0\u5761","\u72EE\u57CE","\u6CAA\u65B0","\u4EAC\u65B0","\u4E2D\u65B0","\u6CC9\u65B0","\u7A57\u65B0","\u6DF1\u65B0","\u676D\u65B0","\u5E7F\u65B0","\u5EE3\u65B0","\u6EEC\u65B0"],"\u{1F1F8}\u{1F1EE}":["Slovenia","\u65AF\u6D1B\u6587\u5C3C\u4E9A"],"\u{1F1F8}\u{1F1F0}":["Slovakia","\u65AF\u6D1B\u4F10\u514B"],"\u{1F1F9}\u{1F1ED}":["Thailand","\u6CF0\u56FD","\u6CF0\u570B","\u66FC\u8C37"],"\u{1F1F9}\u{1F1F3}":["Tunisia","\u7A81\u5C3C\u65AF"],"\u{1F1F9}\u{1F1F7}":["Turkey","\u571F\u8033\u5176","\u4F0A\u65AF\u5766\u5E03\u5C14","Istanbul"],"\u{1F1F9}\u{1F1FC}":["Taiwan","\u53F0\u6E7E","\u81FA\u7063","\u53F0\u7063","\u4E2D\u83EF\u6C11\u570B","\u4E2D\u534E\u6C11\u56FD","\u53F0\u5317","\u53F0\u4E2D","\u65B0\u5317","\u5F70\u5316","\u53F0","\u81FA","Taipei","Tai Wan"],"\u{1F1FA}\u{1F1E6}":["Ukraine","\u4E4C\u514B\u5170","\u70CF\u514B\u862D"],"\u{1F1FA}\u{1F1F8}":["United States","\u7F8E\u56FD","America","\u7F8E","\u4EAC\u7F8E","\u6CE2\u7279\u5170","\u8FBE\u62C9\u65AF","\u4FC4\u52D2\u5188","Oregon","\u51E4\u51F0\u57CE","\u8D39\u5229\u8499","\u7845\u8C37","\u77FD\u8C37","\u62C9\u65AF\u7EF4\u52A0\u65AF","\u6D1B\u6749\u77F6","\u5723\u4F55\u585E","\u5723\u514B\u62C9\u62C9","\u897F\u96C5\u56FE","\u829D\u52A0\u54E5","\u6CAA\u7F8E","\u54E5\u4F26\u5E03","\u7EBD\u7EA6","New York","Los Angeles","San Jose","Sillicon Valley","Michigan","\u4FC4\u4EA5\u4FC4","Ohio","\u9A6C\u7EB3\u8428\u65AF","Manassas","\u5F17\u5409\u5C3C\u4E9A","Virginia"],"\u{1F1FA}\u{1F1FE}":["Uruguay","\u4E4C\u62C9\u572D"],"\u{1F1FB}\u{1F1EA}":["Venezuela","\u59D4\u5185\u745E\u62C9"],"\u{1F1FB}\u{1F1F3}":["Vietnam","\u8D8A\u5357","\u80E1\u5FD7\u660E"],"\u{1F1FF}\u{1F1E6}":["South Africa","\u5357\u975E"],"\u{1F1E8}\u{1F1F3}":["China","\u4E2D\u56FD","\u4E2D\u570B","\u56DE\u56FD","\u56DE\u570B","\u56FD\u5185","\u570B\u5167","\u534E\u4E1C","\u534E\u897F","\u534E\u5357","\u534E\u5317","\u534E\u4E2D","\u6C5F\u82CF","\u5317\u4EAC","\u4E0A\u6D77","\u5E7F\u5DDE","\u6DF1\u5733","\u676D\u5DDE","\u5F90\u5DDE","\u9752\u5C9B","\u5B81\u6CE2","\u9547\u6C5F"]},r=e.match(/[\uD83C][\uDDE6-\uDDFF][\uD83C][\uDDE6-\uDDFF]/)?.[0]||"\u{1F3F4}\u200D\u2620\uFE0F";for(let n of Object.keys(t))if(t[n].some(a=>RegExp(`${a}`,"i").test(e)))return/内蒙古/.test(e)&&["\u{1F1F2}\u{1F1F3}"].includes(n)?r="\u{1F1E8}\u{1F1F3}":r=n;for(let n of Object.keys(t0))if(t0[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 Xf(e){return t0[Eo(e)]?.[0]}function Lc(e){return e.replace(/[\uD83C][\uDDE6-\uDDFF][\uD83C][\uDDE6-\uDDFF]|🏴‍☠️|🏳️‍🌈/g,"").trim()}var Wf=class{constructor({country,asn}={}){if(G.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 Qf=ln(qE()),VE=ln(af());async function wo({url:e,domain:t,type:r="A",timeout:n,edns:i}){let a=Qf.default.encode({type:"query",id:0,flags:Qf.default.RECURSION_DESIRED,questions:[{type:r,name:t}],additionals:[{type:"OPT",name:".",udpPayloadSize:4096,flags:0,options:[{code:"CLIENT_SUBNET",ip:i,sourcePrefixLength:or(i)?24:56,scopePrefixLength:0}]}]}),s=await G.http.get({url:`${e}?dns=${a.toString("base64").toString("utf-8").replace(/=/g,"")}`,headers:{Accept:"application/dns-message"},"binary-mode":!0,encoding:null,timeout:n});return Qf.default.decode(VE.Buffer.from(G.env.isQX?s.bodyBytes:s.body))}var g0=ln(f0());function Mi(e,t,r){e.status(r||200).json({status:"success",data:t})}function Br(e,t,r){e.status(r||500).json({status:"failed",error:{code:t.code,type:t.type,message:t.message,details:t.details}})}var jc=class{constructor(t,r,n){this.code=t,this.message=r,this.details=n}},Tn=class extends jc{constructor(t,r,n){super(t,r,n),this.type="InternalServerError"}};var $s=class extends jc{constructor(t,r,n){super(t,r,n),this.type="ResourceNotFoundError"}},eh=class extends jc{constructor(t,r,n){super(t,r,n),this.type="NetworkError"}};function cr(e,t,r="name"){return e.find(n=>n[r]===t)}function AD(){return{name:"HTML",test:n=>/^/.test(n),parse:()=>""}}function wD(){return{name:"Clash Provider",test:n=>/^payload:/gm.exec(n).index>=0,parse:n=>n.replace("payload:","").replace(/^\s*-\s*/gm,"")}}var KE=[AD(),wD()];function yD(){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 GE(){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 SD(){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))),GE().func(r))}}function bD(){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(o=>["no-resolve"].includes(o))),s+=a.options?.length>0?`,${a.options.join(",")}`:""),s})};return Ja.dump(i)}}}var zE={QX:yD(),Surge:GE(),Loon:SD(),Clash:bD()};var CD=[[/^(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 FD(){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 o=s.split(",").map(d=>d.trim()),l=o[0],h=!1;for(let d of CD)if(d[0].test(l)){h=!0;let p={type:d[1],content:o[1]};["IP-CIDR","IP-CIDR6","GEOIP"].includes(p.type)&&(p.options=o.slice(2)),a.push(p)}if(!h)throw new Error("Invalid rule type: "+l)}catch(o){console.log(`Failed to parse line: ${s} Reason: ${o}`)}return a}}}var YE=[FD()];var th=function(){function e(n){for(let i of KE)try{if(i.test(n))return G.info(`Pre-processor [${i.name}] activated`),i.parse(n)}catch(a){G.error(`Parser [${i.name}] failed Reason: ${a}`)}return n}function t(n){n=e(n);for(let i of YE){let a;try{a=i.test(n)}catch{a=!1}if(a)return G.info(`Rule parser [${i.name}] is activated!`),i.parse(n)}}function r(n,i){let a=zE[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(o){return console.log(`ERROR: cannot produce rule: ${JSON.stringify(s)} Reason: ${o}`),""}}).filter(s=>s.length>0).join(` `);if(a.type==="ALL")return a.func(n)}return{parse:t,produce:r}}();var ru=class{constructor({token,key,syncPlatform}){let{isStash,isLoon,isShadowRocket,isQX}=Dn(),{defaultProxy,defaultTimeout:timeout}=G.read(Yn),proxy=defaultProxy;G.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=oi({baseURL:"https://gitlab.com/api/v4",headers:{...this.headers,...isStash&&proxy?{"X-Stash-Selected-Proxy":encodeURIComponent(proxy)}:{},...isShadowRocket&&proxy?{"X-Surge-Policy":proxy}:{}},...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?As(proxy):{},timeout:timeout||8e3,events:{onResponse:e=>{if(/^[45]/.test(String(e.statusCode))){let t=JSON.parse(e.body);return Promise.reject(`ERROR: ${t.message?.error??t.message}`)}else return e}}})):(this.headers={Authorization:`token ${token}`,"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36"},this.http=oi({baseURL:"https://api.github.com",headers:{...this.headers,...isStash&&proxy?{"X-Stash-Selected-Proxy":encodeURIComponent(proxy)}:{},...isShadowRocket&&proxy?{"X-Surge-Policy":proxy}:{}},...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?As(proxy):{},timeout:timeout||8e3,events:{onResponse:e=>/^[45]/.test(String(e.statusCode))?Promise.reject(`ERROR: ${JSON.parse(e.body).message}`):e}})),this.key=key,this.syncPlatform=syncPlatform}async locate(){return this.syncPlatform==="gitlab"?this.http.get("/snippets").then(e=>{let t=JSON.parse(e.body);for(let r of t)if(r.title===this.key)return r}):this.http.get("/gists?per_page=100&page=1").then(e=>{let t=JSON.parse(e.body);G.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})`)}};async function h0(e){let{gistToken:t,syncPlatform:r}=G.read(Yn);if(!t)return Promise.reject("\u672A\u8BBE\u7F6E GitHub Token\uFF01");let i=await new ru({token:t,key:Lg,syncPlatform:r}).upload(e),a={};try{a=JSON.parse(i.body)}catch{}let s=a?.html_url??a?.web_url,o=G.read(Yn);return s?(G.log(`\u540C\u6B65 Gist \u540E, \u627E\u5230 Sub-Store Gist: ${s}`),o.artifactStore=s,o.artifactStoreStatus="VALID"):(G.error("\u540C\u6B65 Gist \u540E, \u627E\u4E0D\u5230 Sub-Store Gist"),o.artifactStoreStatus="NOT FOUND"),G.write(o,Yn),i}function p0(e){G.read(ui)||G.write({},ui),e.get("/api/sync/artifacts",ID),e.get("/api/sync/artifact/:name",DD)}async function Qn({type:e,name:t,platform:r,url:n,ua:i,content:a,mergeSources:s,ignoreFailedRemoteSub:o,ignoreFailedRemoteFile:l,produceType:h,produceOpts:d={},subscription:E,awaitCustomCache:p,$options:f,proxy:w,noCache:g}){if(r=r||"JSON",["subscription","sub"].includes(e)){let y;if(t){let I=G.read(Wn);if(y=cr(I,t),!y)throw new Error(`\u627E\u4E0D\u5230\u8BA2\u9605 ${t}`)}else if(E)y=E;else throw new Error("\u672A\u63D0\u4F9B\u8BA2\u9605\u540D\u79F0\u6216\u8BA2\u9605\u6570\u636E");let A;if(a&&!["localFirst","remoteFirst"].includes(s))A=a;else if(n){let I={};A=await Promise.all(n.split(/[\r\n]+/).map(H=>H.trim()).filter(H=>H.length).map(async H=>{try{return await Ir(H,i||y.ua,void 0,w||y.proxy,void 0,p,g||y.noCache,!0)}catch(V){return I[H]=V,G.error(`\u8BA2\u9605 ${y.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${H} \u53D1\u751F\u9519\u8BEF: ${V}`),""}}));let D=y.ignoreFailedRemoteSub;if(o!=null&&o!==""&&(D=o),!D&&Object.keys(I).length>0)throw new Error(`\u8BA2\u9605 ${y.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(I).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);s==="localFirst"?A.unshift(a):s==="remoteFirst"&&A.push(a)}else if(y.source==="local"&&!["localFirst","remoteFirst"].includes(y.mergeSources))A=y.content;else{let I={};A=await Promise.all(y.url.split(/[\r\n]+/).map(H=>H.trim()).filter(H=>H.length).map(async H=>{try{return await Ir(H,i||y.ua,void 0,w||y.proxy,void 0,p,g||y.noCache,!0)}catch(V){return I[H]=V,G.error(`\u8BA2\u9605 ${y.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${H} \u53D1\u751F\u9519\u8BEF: ${V}`),""}}));let D=y.ignoreFailedRemoteSub;if(o!=null&&o!==""&&(D=o),!D&&Object.keys(I).length>0)throw new Error(`\u8BA2\u9605 ${y.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(I).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);y.mergeSources==="localFirst"?A.unshift(y.content):y.mergeSources==="remoteFirst"&&A.push(y.content)}let S=(Array.isArray(A)?A:[A]).map(I=>Gt.parse(I)).flat();if(S.forEach(I=>{I._subName=y.name,I._subDisplayName=y.displayName}),S=await Gt.process(S,y.process||[],r,{[y.name]:y},f),S.length===0)throw new Error(`\u8BA2\u9605 ${t} \u4E2D\u4E0D\u542B\u6709\u6548\u8282\u70B9`);let _={};for(let I of S){if(_[I.name]){G.notify("\u{1F30D} Sub-Store",`\u26A0\uFE0F \u8BA2\u9605 ${t} \u5305\u542B\u91CD\u590D\u8282\u70B9 ${I.name}\uFF01`,"\u8BF7\u4ED4\u7EC6\u68C0\u6D4B\u914D\u7F6E\uFF01",{"media-url":"https://cdn3.iconfinder.com/data/icons/seo-outline-1/512/25_code_program_programming_develop_bug_search_developer-512.png"});break}_[I.name]=!0}return Gt.produce(S,r,h,d)}else if(["collection","col"].includes(e)){let y=G.read(Wn),A=G.read(zs),S=cr(A,t);if(!S)throw new Error(`\u627E\u4E0D\u5230\u7EC4\u5408\u8BA2\u9605 ${t}`);let _=[...S.subscriptions],I=S.subscriptionTags;Array.isArray(I)&&I.length>0&&y.forEach(L=>{Array.isArray(L.tag)&&L.tag.length>0&&!_.includes(L.name)&&L.tag.some(q=>I.includes(q))&&_.push(L.name)});let D={},H={},V=0;await Promise.all(_.map(async L=>{let q=cr(y,L),J=q.passThroughUA,z=q.ua;J&&(G.info(`\u8BA2\u9605\u5F00\u542F\u4E86\u900F\u4F20 User-Agent, \u4F7F\u7528\u8BF7\u6C42\u7684 User-Agent: ${i}`),z=i);try{G.info(`\u6B63\u5728\u5904\u7406\u5B50\u8BA2\u9605\uFF1A${q.name}...`);let K;if(q.source==="local"&&!["localFirst","remoteFirst"].includes(q.mergeSources))K=q.content;else{let ie={};if(K=await await Promise.all(q.url.split(/[\r\n]+/).map(be=>be.trim()).filter(be=>be.length).map(async be=>{try{return await Ir(be,z,void 0,w||q.proxy||S.proxy,void 0,void 0,g||q.noCache,!0)}catch(ye){return ie[be]=ye,G.error(`\u8BA2\u9605 ${q.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${be} \u53D1\u751F\u9519\u8BEF: ${ye}`),""}})),!q.ignoreFailedRemoteSub&&Object.keys(ie).length>0)throw new Error(`\u8BA2\u9605 ${q.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(ie).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);q.mergeSources==="localFirst"?K.unshift(q.content):q.mergeSources==="remoteFirst"&&K.push(q.content)}let X=(Array.isArray(K)?K:[K]).map(ie=>Gt.parse(ie)).flat();X.forEach(ie=>{ie._subName=q.name,ie._subDisplayName=q.displayName,ie._collectionName=S.name,ie._collectionDisplayName=S.displayName}),X=await Gt.process(X,q.process||[],r,{[q.name]:q,_collection:S,$options:f}),D[L]=X,V++,G.info(`\u2705 \u5B50\u8BA2\u9605\uFF1A${q.name}\u52A0\u8F7D\u6210\u529F\uFF0C\u8FDB\u5EA6--${100*(V/_.length).toFixed(1)}% `)}catch(K){V++,H[L]=K,G.error(`\u274C \u5904\u7406\u7EC4\u5408\u8BA2\u9605\u4E2D\u7684\u5B50\u8BA2\u9605: ${q.name}\u65F6\u51FA\u73B0\u9519\u8BEF\uFF1A${K}\uFF01\u8FDB\u5EA6--${100*(V/_.length).toFixed(1)}%`)}}));let F=S.ignoreFailedRemoteSub;if(o!=null&&o!==""&&(F=o),!F&&Object.keys(H).length>0)throw new Error(`\u7EC4\u5408\u8BA2\u9605 ${t} \u4E2D\u7684\u5B50\u8BA2\u9605 ${Object.keys(H).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);let P=Array.prototype.concat.apply([],_.map(L=>D[L]||[]));if(P.forEach(L=>{L._collectionName=S.name,L._collectionDisplayName=S.displayName}),P=await Gt.process(P,S.process||[],r,{_collection:S},f),P.length===0)throw new Error(`\u7EC4\u5408\u8BA2\u9605 ${t} \u4E2D\u4E0D\u542B\u6709\u6548\u8282\u70B9`);let k={};for(let L of P){if(k[L.name]){G.notify("\u{1F30D} Sub-Store",`\u26A0\uFE0F \u7EC4\u5408\u8BA2\u9605 ${t} \u5305\u542B\u91CD\u590D\u8282\u70B9 ${L.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}k[L.name]=!0}return Gt.produce(P,r,h,d)}else if(e==="rule"){let y=G.read(Ec),A=cr(y,t);if(!A)throw new Error(`\u627E\u4E0D\u5230\u89C4\u5219 ${t}`);let S=[];for(let _=0;_F.trim()).filter(F=>F.length).map(async F=>{try{return await Ir(F,i||A.ua,void 0,A.proxy||w,void 0,void 0,g)}catch(P){return H[F]=P,G.error(`\u6587\u4EF6 ${A.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${F} \u53D1\u751F\u9519\u8BEF: ${P}`),""}}));let V=A.ignoreFailedRemoteFile;if(l!=null&&l!==""&&(V=l),!V&&Object.keys(H).length>0)throw new Error(`\u6587\u4EF6 ${A.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${Object.keys(H).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);s==="localFirst"?S.unshift(a):s==="remoteFirst"&&S.push(a)}else if(A.source==="local"&&!["localFirst","remoteFirst"].includes(A.mergeSources))S=A.content;else{let H={};S=await Promise.all(A.url.split(/[\r\n]+/).map(F=>F.trim()).filter(F=>F.length).map(async F=>{try{return await Ir(F,i||A.ua,void 0,A.proxy||w,void 0,void 0,g)}catch(P){return H[F]=P,G.error(`\u6587\u4EF6 ${A.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${F} \u53D1\u751F\u9519\u8BEF: ${P}`),""}}));let V=A.ignoreFailedRemoteFile;if(l!=null&&l!==""&&(V=l),!V&&Object.keys(H).length>0)throw new Error(`\u6587\u4EF6 ${A.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${Object.keys(H).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);A.mergeSources==="localFirst"?S.unshift(A.content):A.mergeSources==="remoteFirst"&&S.push(A.content)}let _=(Array.isArray(S)?S:[S]).flat(),I=_.filter(H=>H!=null&&H!=="").join(` `);return(Array.isArray(A.process)&&A.process.length>0?await Gt.process({$files:_,$content:I,$options:f,$file:A},A.process):{$content:I,$files:_,$options:f})?.$content??""}}async function _D(){G.info("\u5F00\u59CB\u540C\u6B65\u6240\u6709\u8FDC\u7A0B\u914D\u7F6E...");let e=G.read(ui),t={};try{let r=[],n=[],i=G.read(Wn),a=G.read(zs),s=[],o=0;if(e.map(d=>{if(d.sync&&d.source){if(o++,d.type==="subscription"){let E=d.source,p=cr(i,E);p&&p.url&&!s.includes(E)&&s.push(E)}else if(d.type==="collection"){let E=cr(a,d.source);E&&Array.isArray(E.subscriptions)&&E.subscriptions.map(p=>{let f=cr(i,p);f&&f.url&&!s.includes(p)&&s.push(p)})}}}),o===0){G.info(`\u9700\u540C\u6B65\u7684\u914D\u7F6E: ${o}, \u603B\u6570: ${e.length}`);return}if(s.length>0&&await Promise.all(s.map(async d=>{try{await Qn({type:"subscription",name:d,awaitCustomCache:!0})}catch{}})),await Promise.all(e.map(async d=>{try{if(d.sync&&d.source){G.info(`\u6B63\u5728\u540C\u6B65\u4E91\u914D\u7F6E\uFF1A${d.name}...`);let E=d.platform==="SurgeMac";E&&G.info("\u624B\u52A8\u6307\u5B9A\u4E86 target \u4E3A SurgeMac, \u5C06\u4F7F\u7528 Mihomo External");let p=await Qn({type:d.type,name:d.source,platform:d.platform,produceOpts:{"include-unsupported-proxy":d.includeUnsupportedProxy,useMihomoExternal:E}});t[encodeURIComponent(d.name)]={content:p},r.push(d.name)}}catch(E){G.error(`\u751F\u6210\u540C\u6B65\u914D\u7F6E ${d.name} \u53D1\u751F\u9519\u8BEF: ${E.message??E}`),n.push(d.name)}})),G.info(`${r.length} \u4E2A\u540C\u6B65\u914D\u7F6E\u751F\u6210\u6210\u529F: ${r.join(", ")}`),G.info(`${n.length} \u4E2A\u540C\u6B65\u914D\u7F6E\u751F\u6210\u5931\u8D25: ${n.join(", ")}`),r.length===0)throw new Error(`\u540C\u6B65\u914D\u7F6E ${n.join(", ")} \u751F\u6210\u5931\u8D25 \u8BE6\u60C5\u8BF7\u67E5\u770B\u65E5\u5FD7`);let l=await h0(t),h=JSON.parse(l.body);delete h.history,delete h.forks,delete h.owner,Object.values(h.files).forEach(d=>{delete d.content}),G.info("\u4E0A\u4F20\u914D\u7F6E\u54CD\u5E94:"),G.info(JSON.stringify(h,null,2));for(let d of e)if(d.sync&&d.source&&r.includes(d.name)){d.updated=new Date().getTime();let E=h.files,p;Array.isArray(E)&&(p=!0,E=Object.fromEntries(E.map(g=>[g.path,g])));let f=E[encodeURIComponent(d.name)]?.raw_url,w=p?f:f?.replace(/\/raw\/[^/]*\/(.*)/,"/raw/$1");G.info(`\u4E0A\u4F20\u914D\u7F6E\u5B8C\u6210 \u6587\u4EF6\u5217\u8868: ${Object.keys(E).join(", ")} \u5F53\u524D\u6587\u4EF6: ${encodeURIComponent(d.name)} \u54CD\u5E94\u8FD4\u56DE\u7684\u539F\u59CB\u94FE\u63A5: ${f} \u5904\u7406\u5B8C\u7684\u65B0\u94FE\u63A5: ${w}`),d.url=w}if(G.write(e,ui),G.info("\u4E0A\u4F20\u914D\u7F6E\u6210\u529F"),n.length>0)throw new Error(`\u540C\u6B65\u914D\u7F6E\u6210\u529F ${r.length} \u4E2A, \u5931\u8D25 ${n.length} \u4E2A, \u8BE6\u60C5\u8BF7\u67E5\u770B\u65E5\u5FD7`);G.info(`\u540C\u6B65\u914D\u7F6E\u6210\u529F ${r.length} \u4E2A`)}catch(r){throw G.error(`\u540C\u6B65\u914D\u7F6E\u5931\u8D25\uFF0C\u539F\u56E0\uFF1A${r.message??r}`),r}}async function ID(e,t){G.info("\u5F00\u59CB\u540C\u6B65\u6240\u6709\u8FDC\u7A0B\u914D\u7F6E...");try{await _D(),Mi(t)}catch(r){G.error(`\u540C\u6B65\u914D\u7F6E\u5931\u8D25\uFF0C\u539F\u56E0\uFF1A${r.message??r}`),Br(t,new Tn("FAILED_TO_SYNC_ARTIFACTS","Failed to sync all artifacts",`Reason: ${r.message??r}`))}}async function DD(e,t){let{name:r}=e.params;r=decodeURIComponent(r),G.info(`\u5F00\u59CB\u540C\u6B65\u8FDC\u7A0B\u914D\u7F6E ${r}...`);let n=G.read(ui),i=cr(n,r);if(!i){G.error(`\u627E\u4E0D\u5230\u8FDC\u7A0B\u914D\u7F6E ${r}`),Br(t,new $s("RESOURCE_NOT_FOUND",`\u627E\u4E0D\u5230\u8FDC\u7A0B\u914D\u7F6E ${r}`),404);return}if(!i.source){G.error(`\u8FDC\u7A0B\u914D\u7F6E ${r} \u672A\u8BBE\u7F6E\u6765\u6E90`),Br(t,new $s("RESOURCE_HAS_NO_SOURCE",`\u8FDC\u7A0B\u914D\u7F6E ${r} \u672A\u8BBE\u7F6E\u6765\u6E90`),404);return}try{let a=i.platform==="SurgeMac";a&&G.info("\u624B\u52A8\u6307\u5B9A\u4E86 target \u4E3A SurgeMac, \u5C06\u4F7F\u7528 Mihomo External");let s=await Qn({type:i.type,name:i.source,platform:i.platform,produceOpts:{"include-unsupported-proxy":i.includeUnsupportedProxy,useMihomoExternal:a}});G.info(`\u6B63\u5728\u4E0A\u4F20\u914D\u7F6E\uFF1A${i.name} >>>${JSON.stringify(i,null,2)}`);let o=await h0({[encodeURIComponent(i.name)]:{content:s}});i.updated=new Date().getTime();let l=JSON.parse(o.body);delete l.history,delete l.forks,delete l.owner,Object.values(l.files).forEach(f=>{delete f.content}),G.info("\u4E0A\u4F20\u914D\u7F6E\u54CD\u5E94:"),G.info(JSON.stringify(l,null,2));let h=l.files,d;Array.isArray(h)&&(d=!0,h=Object.fromEntries(h.map(f=>[f.path,f])));let E=h[encodeURIComponent(i.name)]?.raw_url,p=d?E:E?.replace(/\/raw\/[^/]*\/(.*)/,"/raw/$1");G.info(`\u4E0A\u4F20\u914D\u7F6E\u5B8C\u6210 \u6587\u4EF6\u5217\u8868: ${Object.keys(h).join(", ")} \u5F53\u524D\u6587\u4EF6: ${encodeURIComponent(i.name)} \u54CD\u5E94\u8FD4\u56DE\u7684\u539F\u59CB\u94FE\u63A5: ${E} \u5904\u7406\u5B8C\u7684\u65B0\u94FE\u63A5: ${p}`),i.url=p,G.write(n,ui),Mi(t,i)}catch(a){G.error(`\u8FDC\u7A0B\u914D\u7F6E ${i.name} \u53D1\u751F\u9519\u8BEF: ${a.message??a}`),Br(t,new Tn("FAILED_TO_SYNC_ARTIFACT",`Failed to sync artifact ${r}`,`Reason: ${a}`))}}var{isNode:WE,isQX:BD,isLoon:$D,isSurge:PD,isStash:RD,isShadowRocket:TD,isLanceX:xD,isEgern:OD,isGUIforCores:ND}=Dn(),qi="Node";WE&&(qi="Node");BD&&(qi="QX");$D&&(qi="Loon");PD&&(qi="Surge");RD&&(qi="Stash");TD&&(qi="ShadowRocket");OD&&(qi="Egern");xD&&(qi="LanceX");ND&&(qi="GUI.for.Cores");var nu={},kD={};try{if(typeof $environment<"u"&&(nu.env=$environment),typeof $loon<"u"&&(nu.loon=$loon),typeof $script<"u"&&(nu.script=$script),typeof $Plugin<"u"&&(nu.plugin=$Plugin),WE){nu.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)&&(nu.node.env[e]=env[e])}}catch(e){}var iu={backend:qi,version:Gl,feature:kD,meta:nu};function LD(e){return e&&typeof e=="object"&&!Array.isArray(e)}function Mc(e){return e.startsWith("<")&&e.endsWith(">")?e.slice(1,-1):e}function JE(e,t){let r=typeof t=="string"?JSON.parse(t):t;for(let n in r)if(LD(r[n]))if(n.endsWith("!")){let i=Mc(n.slice(0,-1));e[i]=r[n]}else{let i=Mc(n);e[i]||Object.assign(e,{[i]:{}}),JE(e[i],r[i])}else if(Array.isArray(r[n]))if(n.startsWith("+")){let i=Mc(n.slice(1));e[i]||Object.assign(e,{[i]:[]}),e[i]=[...r[n],...e[i]]}else if(n.endsWith("+")){let i=Mc(n.slice(0,-1));e[i]||Object.assign(e,{[i]:[]}),e[i]=[...e[i],...r[n]]}else{let i=Mc(n);Object.assign(e,{[i]:r[n]})}else Object.assign(e,{[n]:r[n]});return e}function UD({rule:e}){return{name:"Conditional Filter",func:t=>t.map(r=>rh(e,r))}}function rh(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=>rh(r,t));case"OR":return e.child.some(r=>rh(r,t));case"NOT":return!rh(e.child,t);default:throw new Error(`Unknown operator: ${e.operator}`)}}function HD(e){return{name:"Quick Setting Operator",func:r=>{if(t(e.useless)){let i=tA().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 jD({mode:e,tw:t}){return{name:"Flag Operator",func:r=>r.map(n=>{if(e==="remove")n.name=Lc(n.name);else{let i=Eo(n.name);n.name=Lc(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 MD(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(o=>s[o.name]?!1:(s[o.name]=!0,!0))}else if(t==="rename"){let s=r.split(" "),o={},l=0;a.forEach(d=>{typeof o[d.name]>"u"?o[d.name]=1:o[d.name]++,l=Math.max(o[d.name].toString().length,l)});let h={};return a.map(d=>{if(o[d.name]>1){typeof h[d.name]>"u"&&(h[d.name]=1);let E="",p=h[d.name]++,f=0;for(;p>0;)E=s[p%10]+E,p=parseInt(p/10),f++;for(;f++{switch(e){case"asc":case"desc":return t.sort((r,n)=>{let i=r.name>n.name?1:-1;return i*=e==="desc"?-1:1,i});case"random":return eB(t);default:throw new Error("Unknown sort option: "+e)}}}}function VD(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=>m0(i)),n.sort((i,a)=>{let s=XE(r,i.name),o=XE(r,a.name);return s&&!o?-1:o&&!s?1:s&&o?st.map(r=>{for(let{expr:n,now:i}of e)r.name=r.name.replace(m0(n,"g"),i).trim();return r})}}function KD(e){let t=e.map(r=>({expr:r,now:""}));return{name:"Regex Delete Operator",func:ZE(t).func}}function GD(e,t,r,n,i){return{name:"Script Operator",func:async a=>{let s=a;if(s?.$file?.type==="mihomoProfile")try{let o=Ja.safeLoad(e),l;if(s?.$content)try{l=Ja.safeLoad(s?.$content)}catch(h){G.error(h.message??h)}if(typeof o!="object")throw new Error("patch is not an object");return s.$content=Gt.yaml.safeDump(JE(l||(s?.$file?.sourceType==="none"?{}:{proxies:await Qn({type:s?.$file?.sourceType||"collection",name:s?.$file?.sourceName,platform:"mihomo",produceType:"internal",produceOpts:{"delete-underscore-fields":!0}})}),o)),s}catch{}return await async function(){s=nh("operator",e,r,i)(a,t,{source:n,...iu})}(),s},nodeFunc:async a=>{let s=a;return await async function(){s=nh("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,...iu})}(),s}}}function zD(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,o=i&255,l=a>>8,h=a&255;if(t=`${s}.${o}.${l}.${h}`,r<=0||r>65535)throw new Error(`Invalid port number: ${r}`);if(!or(t))throw new Error(`Invalid IP address: ${t}`)}catch(n){G.error(`IP4P \u89E3\u6790\u5931\u8D25: ${n}`)}return{server:t,port:r}}var QE={Custom:async function(e,t,r,n,i,a){let s=li(`CUSTOM:${a}:${e}:${t}`),o=Er.get(s);if(!r&&o)return o;let l=t==="IPv6"?"AAAA":"A",h=await wo({url:a,domain:e,type:l,timeout:n,edns:i}),{answers:d}=h;if(!Array.isArray(d)||d.length===0)throw new Error("No answers");let E=d.filter(p=>p?.type===l).map(p=>p?.data).filter(p=>p);if(E.length===0)throw new Error("No answers");return Er.set(s,E),E},Google:async function(e,t,r,n,i){let a=li(`GOOGLE:${e}:${t}`),s=Er.get(a);if(!r&&s)return s;let o=t==="IPv6"?"AAAA":"A",l=await wo({url:"https://8.8.4.4/dns-query",domain:e,type:o,timeout:n,edns:i}),{answers:h}=l;if(!Array.isArray(h)||h.length===0)throw new Error("No answers");let d=h.filter(E=>E?.type===o).map(E=>E?.data).filter(E=>E);if(d.length===0)throw new Error("No answers");return Er.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=li(`IP-API:${e}`),a=Er.get(i);if(!r&&a)return a;let s=await G.http.get({url:`http://ip-api.com/json/${encodeURIComponent(e)}?lang=zh-CN`,timeout:n}),o=JSON.parse(s.body);if(o.status!=="success")throw new Error(`Status is ${o.status}`);if(!o.query||o.query===0)throw new Error("No answers");let l=[o.query];if(l.length===0)throw new Error("No answers");return Er.set(i,l),l},Cloudflare:async function(e,t,r,n,i){let a=li(`CLOUDFLARE:${e}:${t}`),s=Er.get(a);if(!r&&s)return s;let o=t==="IPv6"?"AAAA":"A",l=await wo({url:"https://1.0.0.1/dns-query",domain:e,type:o,timeout:n,edns:i}),{answers:h}=l;if(!Array.isArray(h)||h.length===0)throw new Error("No answers");let d=h.filter(E=>E?.type===o).map(E=>E?.data).filter(E=>E);if(d.length===0)throw new Error("No answers");return Er.set(a,d),d},Ali:async function(e,t,r,n,i){let a=li(`ALI:${e}:${t}`),s=Er.get(a);if(!r&&s)return s;let o=await G.http.get({url:`http://223.6.6.6/resolve?edns_client_subnet=${i}/24&name=${encodeURIComponent(e)}&type=${t==="IPv6"?"AAAA":"A"}&short=1`,headers:{accept:"application/dns-json"},timeout:n}),l=JSON.parse(o.body);if(!Array.isArray(l)||l.length===0)throw new Error("No answers");let h=l;if(h.length===0)throw new Error("No answers");return Er.set(a,h),h},Tencent:async function(e,t,r,n,i){let a=li(`TENCENT:${e}:${t}`),s=Er.get(a);if(!r&&s)return s;let l=(await G.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 h=l;if(h.length===0)throw new Error("No answers");return Er.set(a,h),h}};function eA({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:o}=G.read(Yn),l=a||o||8e3,h=["IPv6","IP4P"].includes(t)?"IPv6":"IPv4",d=QE[e];if(!d)throw new Error(`\u627E\u4E0D\u5230\u57DF\u540D\u89E3\u6790\u670D\u52A1\u63D0\u4F9B\u65B9: ${e}`);let E=s||"223.6.6.6";if(!su(E))throw new Error("\u57DF\u540D\u89E3\u6790 EDNS \u5E94\u4E3A IP");return G.info(`Domain Resolver: [${t}] ${e} ${E||""} ${i||""}`),{name:"Resolve Domain Operator",func:async p=>{p.forEach((A,S)=>{!A["_no-resolve"]&&A["no-resolve"]&&(p[S]["_no-resolve"]=A["no-resolve"])});let f={},w=15,g=[...new Set(p.filter(A=>!su(A.server)&&!A["_no-resolve"]).map(A=>A.server))],y=Math.ceil(g.length/w);for(let A=0;A{f[_]=I,G.info(`Successfully resolved domain: ${_} \u279F ${I}`)}).catch(I=>{G.error(`Failed to resolve domain: ${_} with resolver [${e}]: ${I}`)}));await Promise.all(S)}return p.forEach(A=>{if(!A["_no-resolve"])if(f[A.server]){A._resolved_ips=f[A.server];let S=Array.isArray(f[A.server])?f[A.server][Math.floor(Math.random()*f[A.server].length)]:f[A.server];if(h==="IPv6"&&Jt(S)){try{S=new jf.Address6(S).correctForm()}catch(_){G.error(`Failed to parse IPv6 address: ${S}: ${_}`)}if(/^2001::[^:]+:[^:]+:[^:]+$/.test(S)){A._IP4P=S;let{server:_,port:I}=zD(S);_&&I?(A._domain=A.server,A.server=_,A.port=I,A.resolved=!0,A._IPv4=A.server,su(A._IP)||(A._IP=A.server)):A.resolved||(A.resolved=!1)}else A._domain=A.server,A.server=S,A.resolved=!0,A[`_${h}`]=A.server,su(A._IP)||(A._IP=A.server)}else A._domain=A.server,A.server=S,A.resolved=!0,A[`_${h}`]=A.server,su(A._IP)||(A._IP=A.server)}else A.resolved||(A.resolved=!1)}),p.filter(A=>r==="removeFailed"?su(A.server)||A["_no-resolve"]||A.resolved:r==="IPOnly"?su(A.server):r==="IPv4Only"?or(A.server):r==="IPv6Only"?Jt(A.server):!0)}}}function su(e){return or(e)||Jt(e)}eA.resolver=QE;function d0(e){var t=/^[\x00-\x7F]+$/;return t.test(e)}function tA(){return{name:"Useless Filter",func:e=>e.map(t=>{if(t.cipher&&!d0(t.cipher))return!1;if(t.password&&!d0(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&&!d0(n)))return!1}return!/网址|流量|时间|应急|过期|Bandwidth|expire/.test(t.name)})}}function YD(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=Eo(a.name),o=t.some(l=>n[l]===s);return r?o:!o})}}function WD({regex:e=[],keep:t=!0}){return{name:"Regex Filter",func:r=>r.map(n=>{let i=e.some(a=>m0(a).test(n.name));return t?i:!i})}}function m0(e,...t){return t=t.join(""),e.startsWith("(?i)")?(e=e.substring(4),new RegExp(e,"i"+t)):new RegExp(e,t)}function XD(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 JD(e,t,r,n,i){return{name:"Script Filter",func:async a=>{let s=Yf(a.length,!0);return await async function(){s=nh("filter",e,r,i)(a,t,{source:n,...iu})}(),s},nodeFunc:async a=>{let s=Yf(a.length,!0);return await async function(){s=nh("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,...iu})}(),s}}}var ih={"Useless Filter":tA,"Region Filter":YD,"Regex Filter":WD,"Type Filter":XD,"Script Filter":JD,"Conditional Filter":UD,"Quick Setting Operator":HD,"Flag Operator":jD,"Sort Operator":qD,"Regex Sort Operator":VD,"Regex Rename Operator":ZE,"Regex Delete Operator":KD,"Script Operator":GD,"Handle Duplicate Operator":MD,"Resolve Domain Operator":eA};async function ZD(e,t){let r=Yf(t.length,!0);try{r=await e.func(t)}catch(n){let i="",a=`${n.message??n}`;a.includes("$server is not defined")?i="":(G.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){G.error(`Cannot apply filter ${e.name}(shortcut script)! Reason: ${s}`);let o="",l=`${s.message??s}`;throw i&&l===a?(o="",i=`\u6267\u884C\u5931\u8D25 ${a}`):o=`\u6267\u884C\u5FEB\u6377\u8FC7\u6EE4\u811A\u672C \u5931\u8D25 ${l}`,new Error(`\u811A\u672C\u8FC7\u6EE4 ${i}${o}`)}}return t.filter((n,i)=>r[i])}async function QD(e,t){let r=tB(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="":(G.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){G.error(`Cannot apply operator ${e.name}(shortcut script)! Reason: ${s}`);let o="",l=`${s.message??s}`;throw i&&l===a?(o="",i=`\u6267\u884C\u5931\u8D25 ${a}`):o=`\u6267\u884C\u5FEB\u6377\u811A\u672C \u5931\u8D25 ${l}`,new Error(`\u811A\u672C\u64CD\u4F5C ${i}${o}`)}}return r}async function rA(e,t){if(e.name.indexOf("Filter")!==-1)return ZD(e,t);if(e.name.indexOf("Operator")!==-1)return QD(e,t)}function eB(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 tB(e){return JSON.parse(JSON.stringify(e))}function nh(name,script,$arguments,$options){let flowUtils={getFlowField:po,getFlowHeaders:xi,parseFlowHeaders:qf,flowTransfer:Nc,validCheck:Vf,getRmainingDays:pE,normalizeFlowHeader:go};return G.env.isLoon?new Function("$arguments","$options","$substore","lodash","$persistentStore","$httpClient","$notification","ProxyUtils","scriptResourceCache","flowUtils","produceArtifact","require",`${script} return ${name}`)($arguments,$options,G,g0.default,$persistentStore,$httpClient,$notification,Gt,e0,flowUtils,Qn,eval('typeof require !== "undefined"')?Oa:void 0):new Function("$arguments","$options","$substore","lodash","ProxyUtils","scriptResourceCache","flowUtils","produceArtifact","require",`${script} return ${name}`)($arguments,$options,G,g0.default,Gt,e0,flowUtils,Qn,eval('typeof require !== "undefined"')?Oa:void 0)}var nA=ln(f0()),Qe=class{constructor(t){this.proxy=t,this.output=[]}append(t){if(typeof t>"u")throw new Error("required field is missing");this.output.push(t)}appendIfPresent(t,r){ae(this.proxy,r)&&this.append(t)}toString(){return this.output.join("")}};function ae(e,t){let r=nA.default.get(e,t);return typeof r<"u"&&r!==null}var rB="Surge",ei={dual:"dual",ipv4:"v4-only",ipv6:"v6-only","ipv4-prefer":"prefer-v4","ipv6-prefer":"prefer-v6"};function So(){return{produce:(t,r,n={})=>{switch(t.name=t.name.replace(/=|,/g,""),t.ports&&(t.ports=String(t.ports)),t.type){case"ss":return nB(t,n["include-unsupported-proxy"]);case"trojan":return iB(t);case"vmess":return sB(t,n["include-unsupported-proxy"]);case"http":return uB(t);case"direct":return oB(t);case"socks5":return cB(t);case"snell":return lB(t);case"tuic":return fB(t);case"wireguard-surge":return pB(t);case"hysteria2":return dB(t);case"ssh":return aB(t)}if(n["include-unsupported-proxy"]&&t.type==="wireguard")return hB(t);throw new Error(`Platform ${rB} does not support proxy type: ${t.type}`)}}}function nB(e){let t=new Qe(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=ei[e["ip-version"]]||e["ip-version"];if(t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),ae(e,"plugin")){if(e.plugin==="obfs")t.append(`,obfs=${e["plugin-opts"].mode}`),t.appendIfPresent(`,obfs-host=${e["plugin-opts"].host}`,"plugin-opts.host"),t.appendIfPresent(`,obfs-uri=${e["plugin-opts"].path}`,"plugin-opts.path");else if(!["shadow-tls"].includes(e.plugin))throw new Error(`plugin ${e.plugin} is not supported`)}if(t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ae(e,"shadow-tls-password"))t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni"),t.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port");else if(["shadow-tls"].includes(e.plugin)&&e["plugin-opts"]){let n=e["plugin-opts"].password,i=e["plugin-opts"].host,a=e["plugin-opts"].version;if(n){if(t.append(`,shadow-tls-password=${n}`),i&&t.append(`,shadow-tls-sni=${i}`),a){if(a<2)throw new Error(`shadow-tls version ${a} is not supported`);t.append(`,shadow-tls-version=${a}`)}t.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port")}}return t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function iB(e){let t=new Qe(e);t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password="${e.password}"`,"password");let r=ei[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"),iA(t,e),t.appendIfPresent(`,tls=${e.tls}`,"tls"),t.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ae(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function sB(e,t){let r=new Qe(e);r.append(`${e.name}=${e.type},${e.server},${e.port}`),r.appendIfPresent(`,username=${e.uuid}`,"uuid");let n=ei[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"),iA(r,e,t),ae(e,"aead")?r.append(`,vmess-aead=${e.aead}`):r.append(`,vmess-aead=${e.alterId===0}`),r.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),r.appendIfPresent(`,tls=${e.tls}`,"tls"),r.appendIfPresent(`,sni=${e.sni}`,"sni"),r.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),r.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),r.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),r.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),r.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),r.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),r.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),r.appendIfPresent(`,tos=${e.tos}`,"tos"),r.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),r.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ae(e,"shadow-tls-password")&&(r.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),r.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),r.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),r.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),r.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),r.toString()}function aB(e){let t=new Qe(e);t.append(`${e.name}=ssh,${e.server},${e.port}`),t.appendIfPresent(`,${e.username}`,"username"),t.appendIfPresent(`,"${e.password}"`,"password"),t.appendIfPresent(`,private-key=${e["keystore-private-key"]}`,"keystore-private-key"),t.appendIfPresent(`,idle-timeout=${e["idle-timeout"]}`,"idle-timeout"),t.appendIfPresent(`,server-fingerprint="${e["server-fingerprint"]}"`,"server-fingerprint");let r=ei[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 uB(e){if(e.headers&&Object.keys(e.headers).length>0)throw new Error("headers is unsupported");let t=new Qe(e),r=e.tls?"https":"http";t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,${e.username}`,"username"),t.appendIfPresent(`,"${e.password}"`,"password");let n=ei[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${n}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ae(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function oB(e){let t=new Qe(e);t.append(`${e.name}=direct`);let n=ei[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 cB(e){let t=new Qe(e),r=e.tls?"socks5-tls":"socks5";t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,${e.username}`,"username"),t.appendIfPresent(`,"${e.password}"`,"password");let n=ei[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&&G.info("Option tfo is not supported by Surge, thus omitted"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ae(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function lB(e){let t=new Qe(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=ei[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,obfs=${e["obfs-opts"]?.mode}`,"obfs-opts.mode"),t.appendIfPresent(`,obfs-host=${e["obfs-opts"]?.host}`,"obfs-opts.host"),t.appendIfPresent(`,obfs-uri=${e["obfs-opts"]?.path}`,"obfs-opts.path"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ae(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.appendIfPresent(`,reuse=${e.reuse}`,"reuse"),t.toString()}function fB(e){let t=new Qe(e),r=e.type;(!e.token||e.token.length===0)&&(r="tuic-v5"),t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,uuid=${e.uuid}`,"uuid"),t.appendIfPresent(`,password="${e.password}"`,"password"),t.appendIfPresent(`,token=${e.token}`,"token"),t.appendIfPresent(`,alpn=${Array.isArray(e.alpn)?e.alpn[0]:e.alpn}`,"alpn"),ae(e,"ports")&&t.append(`,port-hopping="${e.ports.replace(/,/g,";")}"`),t.appendIfPresent(`,port-hopping-interval=${e["hop-interval"]}`,"hop-interval");let n=ei[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${n}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),ae(e,"tfo")?t.append(`,tfo=${e.tfo}`):ae(e,"fast-open")&&t.append(`,tfo=${e["fast-open"]}`),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ae(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.appendIfPresent(`,ecn=${e.ecn}`,"ecn"),t.toString()}function hB(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 Qe(e);t.append(`# > WireGuard Proxy ${e.name} # ${e.name}=wireguard`),e["section-name"]=Lt(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=ei[e["ip-version"]]||e["ip-version"];t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ae(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.append(` # > WireGuard Section ${e.name} [WireGuard ${e["section-name"]}] private-key = ${e["private-key"]}`),t.appendIfPresent(` self-ip = ${e.ip}`,"ip"),t.appendIfPresent(` self-ip-v6 = ${e.ipv6}`,"ipv6"),e.dns&&(Array.isArray(e.dns)&&(e.dns=e.dns.join(", ")),t.append(` dns-server = ${e.dns}`)),t.appendIfPresent(` mtu = ${e.mtu}`,"mtu"),r==="prefer-v6"&&t.append(` prefer-ipv6 = true`);let n=Array.isArray(e["allowed-ips"])?e["allowed-ips"].join(","):e["allowed-ips"],i=Array.isArray(e.reserved)?e.reserved.join("/"):e.reserved,a=e["preshared-key"]??e["pre-shared-key"];a&&(a=`,preshared-key="${a}"`);let s={"public-key":e["public-key"],"allowed-ips":n?`"${n}"`:void 0,endpoint:`${e.server}:${e.port}`,keepalive:e["persistent-keepalive"]||e.keepalive,"client-id":i,"preshared-key":a};return t.append(` peer = (${Object.keys(s).filter(o=>s[o]!=null).map(o=>`${o} = ${s[o]}`).join(", ")})`),t.toString()}function pB(e){let t=new Qe(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=ei[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ae(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function dB(e){if(e.obfs||e["obfs-password"])throw new Error("obfs is unsupported");let t=new Qe(e);t.append(`${e.name}=hysteria2,${e.server},${e.port}`),t.appendIfPresent(`,password="${e.password}"`,"password"),ae(e,"ports")&&t.append(`,port-hopping="${e.ports.replace(/,/g,";")}"`),t.appendIfPresent(`,port-hopping-interval=${e["hop-interval"]}`,"hop-interval");let r=ei[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),ae(e,"tfo")?t.append(`,tfo=${e.tfo}`):ae(e,"fast-open")&&t.append(`,tfo=${e["fast-open"]}`),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ae(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.appendIfPresent(`,download-bandwidth=${`${e.down}`.match(/\d+/)?.[0]||0}`,"down"),t.appendIfPresent(`,ecn=${e.ecn}`,"ecn"),t.toString()}function iA(e,t,r){if(ae(t,"network"))if(t.network==="ws"){if(e.append(",ws=true"),ae(t,"ws-opts")&&(e.appendIfPresent(`,ws-path=${t["ws-opts"].path}`,"ws-opts.path"),ae(t,"ws-opts.headers"))){let n=t["ws-opts"].headers,i=Object.keys(n).map(a=>{let s=n[a];return["Host"].includes(a)&&(s=`"${s}"`),`${a}:${s}`}).join("|");Ti(i)&&e.append(`,ws-headers=${i}`)}}else if(r&&["http"].includes(t.network))G.info(`Include Unsupported Proxy: nework ${t.network} -> tcp`);else throw new Error(`network ${t.network} is unsupported`)}function xn(){return{type:"ALL",produce:(r,n,i={})=>{let a=r.filter(s=>i["include-unsupported-proxy"]?!0:s.type==="snell"&&String(s.version)==="4"||["juicity"].includes(s.type)?!1:!(["ss"].includes(s.type)&&!["aes-128-ctr","aes-192-ctr","aes-256-ctr","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-gcm","aes-192-gcm","aes-256-gcm","aes-128-ccm","aes-192-ccm","aes-256-ccm","aes-128-gcm-siv","aes-256-gcm-siv","chacha20-ietf","chacha20","xchacha20","chacha20-ietf-poly1305","xchacha20-ietf-poly1305","chacha8-ietf-poly1305","xchacha8-ietf-poly1305","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm","2022-blake3-chacha20-poly1305","lea-128-gcm","lea-192-gcm","lea-256-gcm","rabbit128-poly1305","aegis-128l","aegis-256","aez-384","deoxys-ii-256-128","rc4-md5","none"].includes(s.cipher))).map(s=>{if(s.type==="vmess"?(ae(s,"aead")&&(s.aead&&(s.alterId=0),delete s.aead),ae(s,"sni")&&(s.servername=s.sni,delete s.sni),ae(s,"cipher")&&!["auto","none","zero","aes-128-gcm","chacha20-poly1305"].includes(s.cipher)&&(s.cipher="auto")):s.type==="tuic"?(ae(s,"alpn")?s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]:s.alpn=["h3"],ae(s,"tfo")&&!ae(s,"fast-open")&&(s["fast-open"]=s.tfo),(!s.token||s.token.length===0)&&!ae(s,"version")&&(s.version=5)):s.type==="hysteria"?(ae(s,"auth_str")&&!ae(s,"auth-str")&&(s["auth-str"]=s.auth_str),ae(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),ae(s,"tfo")&&!ae(s,"fast-open")&&(s["fast-open"]=s.tfo)):s.type==="wireguard"?(s.keepalive=s.keepalive??s["persistent-keepalive"],s["persistent-keepalive"]=s.keepalive,s["preshared-key"]=s["preshared-key"]??s["pre-shared-key"],s["pre-shared-key"]=s["preshared-key"]):s.type==="snell"&&s.version<3?delete s.udp:s.type==="vless"?ae(s,"sni")&&(s.servername=s.sni,delete s.sni):s.type==="ss"&&ae(s,"shadow-tls-password")&&!ae(s,"plugin")&&(s.plugin="shadow-tls",s["plugin-opts"]={host:s["shadow-tls-sni"],password:s["shadow-tls-password"],version:s["shadow-tls-version"]},delete s["shadow-tls-password"],delete s["shadow-tls-sni"],delete s["shadow-tls-version"]),["vmess","vless"].includes(s.type)&&s.network==="http"){let o=s["http-opts"]?.path;ae(s,"http-opts.path")&&!Array.isArray(o)&&(s["http-opts"].path=[o]);let l=s["http-opts"]?.headers?.Host;ae(s,"http-opts.headers.Host")&&!Array.isArray(l)&&(s["http-opts"].headers.Host=[l])}if(["vmess","vless"].includes(s.type)&&s.network==="h2"){let o=s["h2-opts"]?.path;ae(s,"h2-opts.path")&&Array.isArray(o)&&(s["h2-opts"].path=o[0]);let l=s["h2-opts"]?.headers?.host;ae(s,"h2-opts.headers.Host")&&!Array.isArray(l)&&(s["h2-opts"].headers.host=[l])}if(s["plugin-opts"]?.tls&&ae(s,"skip-cert-verify")&&(s["plugin-opts"]["skip-cert-verify"]=s["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls"].includes(s.type)&&delete s.tls,s["tls-fingerprint"]&&(s.fingerprint=s["tls-fingerprint"]),delete s["tls-fingerprint"],s["underlying-proxy"]&&(s["dialer-proxy"]=s["underlying-proxy"]),delete s["underlying-proxy"],ae(s,"tls")&&typeof s.tls!="boolean"&&delete s.tls,delete s.subName,delete s.collectionName,delete s.id,delete s.resolved,delete s["no-resolve"],n!=="internal"||i["delete-underscore-fields"])for(let o in s)(s[o]==null||/^_/i.test(o))&&delete s[o];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 sA="SurgeMac",gB=So();function v0(){return{produce:(t,r,n={})=>{switch(t.type){case"external":return aA(t);default:try{return gB.produce(t,r,n)}catch{if(n.useMihomoExternal)return G.log(`${t.name} is not supported on ${sA}, try to use Mihomo(SurgeMac - External Proxy Program) instead`),mB(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 aA(e){let t=new Qe(e);if(!e.exec||!e["local-port"])throw new Error(`${e.type}: exec and local-port are required`);return t.append(`${e.name}=external,exec="${e.exec}",local-port=${e["local-port"]}`),Array.isArray(e.args)&&e.args.map(r=>{t.append(`,args="${r}"`)}),Array.isArray(e.addresses)&&e.addresses.map(r=>{t.append(`,addresses=${r}`)}),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),ae(e,"tfo")?t.append(`,tfo=${e.tfo}`):ae(e,"fast-open")&&t.append(`,tfo=${e["fast-open"]}`),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.toString()}function mB(e,t,r){let n=xn().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",Et.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 vB(e.server)?s.addresses.push(e.server):G.log(`Platform ${sA}, proxy type ${e.type}: addresses should be an IP address, but got ${e.server}`),r.localPort=i-1,aA(s)}}function vB(e){return or(e)||Jt(e)}function E0(){return{type:"ALL",produce:(r,n,i={})=>{let a=r.filter(s=>i["include-unsupported-proxy"]?!0:!(!["ss","ssr","vmess","vless","socks5","http","snell","trojan","wireguard"].includes(s.type)||s.type==="ss"&&!["aes-128-gcm","aes-192-gcm","aes-256-gcm","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","rc4-md5","chacha20-ietf","xchacha20","chacha20-ietf-poly1305","xchacha20-ietf-poly1305"].includes(s.cipher)||s.type==="snell"&&String(s.version)==="4"||s.type==="vless"&&(typeof s.flow<"u"||s["reality-opts"]))).map(s=>{if(s.type==="vmess"?(ae(s,"aead")&&(s.aead&&(s.alterId=0),delete s.aead),ae(s,"sni")&&(s.servername=s.sni,delete s.sni),ae(s,"cipher")&&!["auto","aes-128-gcm","chacha20-poly1305","none"].includes(s.cipher)&&(s.cipher="auto")):s.type==="wireguard"?(s.keepalive=s.keepalive??s["persistent-keepalive"],s["persistent-keepalive"]=s.keepalive,s["preshared-key"]=s["preshared-key"]??s["pre-shared-key"],s["pre-shared-key"]=s["preshared-key"]):s.type==="snell"&&s.version<3?delete s.udp:s.type==="vless"&&ae(s,"sni")&&(s.servername=s.sni,delete s.sni),["vmess","vless"].includes(s.type)&&s.network==="http"){let o=s["http-opts"]?.path;ae(s,"http-opts.path")&&!Array.isArray(o)&&(s["http-opts"].path=[o]);let l=s["http-opts"]?.headers?.Host;ae(s,"http-opts.headers.Host")&&!Array.isArray(l)&&(s["http-opts"].headers.Host=[l])}if(["vmess","vless"].includes(s.type)&&s.network==="h2"){let o=s["h2-opts"]?.path;ae(s,"h2-opts.path")&&Array.isArray(o)&&(s["h2-opts"].path=o[0]);let l=s["h2-opts"]?.headers?.host;ae(s,"h2-opts.headers.Host")&&!Array.isArray(l)&&(s["h2-opts"].headers.host=[l])}if(s["plugin-opts"]?.tls&&ae(s,"skip-cert-verify")&&(s["plugin-opts"]["skip-cert-verify"]=s["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls"].includes(s.type)&&delete s.tls,s["tls-fingerprint"]&&(s.fingerprint=s["tls-fingerprint"]),delete s["tls-fingerprint"],s["underlying-proxy"]&&(s["dialer-proxy"]=s["underlying-proxy"]),delete s["underlying-proxy"],ae(s,"tls")&&typeof s.tls!="boolean"&&delete s.tls,delete s.subName,delete s.collectionName,delete s.id,delete s.resolved,delete s["no-resolve"],n!=="internal")for(let o in s)(s[o]==null||/^_/i.test(o))&&delete s[o];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 sh(){return{type:"ALL",produce:(r,n,i={})=>{let a=r.filter(s=>!(!["ss","ssr","vmess","socks5","http","snell","trojan","tuic","vless","wireguard","hysteria","hysteria2","ssh","juicity"].includes(s.type)||s.type==="ss"&&!["aes-128-gcm","aes-192-gcm","aes-256-gcm","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","rc4-md5","chacha20-ietf","xchacha20","chacha20-ietf-poly1305","xchacha20-ietf-poly1305","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"].includes(s.cipher)||s.type==="snell"&&String(s.version)==="4"||(i["include-unsupported-proxy"]?s.type==="vless"&&s["reality-opts"]&&!["xtls-rprx-vision"].includes(s.flow):s.type==="vless"&&s["reality-opts"]))).map(s=>{if(s.type==="vmess"?(ae(s,"aead")&&(s.aead&&(s.alterId=0),delete s.aead),ae(s,"sni")&&(s.servername=s.sni,delete s.sni),ae(s,"cipher")&&!["auto","aes-128-gcm","chacha20-poly1305","none"].includes(s.cipher)&&(s.cipher="auto")):s.type==="tuic"?(ae(s,"alpn")?s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]:s.alpn=["h3"],ae(s,"tfo")&&!ae(s,"fast-open")&&(s["fast-open"]=s.tfo,delete s.tfo),(!s.token||s.token.length===0)&&!ae(s,"version")&&(s.version=5)):s.type==="hysteria"?(ae(s,"auth_str")&&!ae(s,"auth-str")&&(s["auth-str"]=s.auth_str),ae(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),ae(s,"tfo")&&!ae(s,"fast-open")&&(s["fast-open"]=s.tfo,delete s.tfo),ae(s,"down")&&!ae(s,"down-speed")&&(s["down-speed"]=s.down,delete s.down),ae(s,"up")&&!ae(s,"up-speed")&&(s["up-speed"]=s.up,delete s.up),ae(s,"down-speed")&&(s["down-speed"]=`${s["down-speed"]}`.match(/\d+/)?.[0]||0),ae(s,"up-speed")&&(s["up-speed"]=`${s["up-speed"]}`.match(/\d+/)?.[0]||0)):s.type==="hysteria2"?(ae(s,"password")&&!ae(s,"auth")&&(s.auth=s.password,delete s.password),ae(s,"tfo")&&!ae(s,"fast-open")&&(s["fast-open"]=s.tfo,delete s.tfo),ae(s,"down")&&!ae(s,"down-speed")&&(s["down-speed"]=s.down,delete s.down),ae(s,"up")&&!ae(s,"up-speed")&&(s["up-speed"]=s.up,delete s.up),ae(s,"down-speed")&&(s["down-speed"]=`${s["down-speed"]}`.match(/\d+/)?.[0]||0),ae(s,"up-speed")&&(s["up-speed"]=`${s["up-speed"]}`.match(/\d+/)?.[0]||0)):s.type==="wireguard"?(s.keepalive=s.keepalive??s["persistent-keepalive"],s["persistent-keepalive"]=s.keepalive,s["preshared-key"]=s["preshared-key"]??s["pre-shared-key"],s["pre-shared-key"]=s["preshared-key"]):s.type==="snell"&&s.version<3?delete s.udp:s.type==="vless"&&ae(s,"sni")&&(s.servername=s.sni,delete s.sni),["vmess","vless"].includes(s.type)&&s.network==="http"){let o=s["http-opts"]?.path;ae(s,"http-opts.path")&&!Array.isArray(o)&&(s["http-opts"].path=[o]);let l=s["http-opts"]?.headers?.Host;ae(s,"http-opts.headers.Host")&&!Array.isArray(l)&&(s["http-opts"].headers.Host=[l])}if(["vmess","vless"].includes(s.type)&&s.network==="h2"){let o=s["h2-opts"]?.path;ae(s,"h2-opts.path")&&Array.isArray(o)&&(s["h2-opts"].path=o[0]);let l=s["h2-opts"]?.headers?.host;ae(s,"h2-opts.headers.Host")&&!Array.isArray(l)&&(s["h2-opts"].headers.host=[l])}if(s["plugin-opts"]?.tls&&ae(s,"skip-cert-verify")&&(s["plugin-opts"]["skip-cert-verify"]=s["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls"].includes(s.type)&&delete s.tls,s["tls-fingerprint"]&&(s["server-cert-fingerprint"]=s["tls-fingerprint"]),delete s["tls-fingerprint"],s["underlying-proxy"]&&(s["dialer-proxy"]=s["underlying-proxy"]),delete s["underlying-proxy"],ae(s,"tls")&&typeof s.tls!="boolean"&&delete s.tls,s["test-url"]&&(s["benchmark-url"]=s["test-url"],delete s["test-url"]),s["test-timeout"]&&(s["benchmark-timeout"]=s["test-timeout"],delete s["test-timeout"]),delete s.subName,delete s.collectionName,delete s.id,delete s.resolved,delete s["no-resolve"],n!=="internal")for(let o in s)(s[o]==null||/^_/i.test(o))&&delete s[o];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 EB="Loon",Ps={dual:"dual",ipv4:"v4-only",ipv6:"v6-only","ipv4-prefer":"prefer-v4","ipv6-prefer":"prefer-v6"};function A0(){return{produce:(t,r,n={})=>{switch(t.type){case"ss":return AB(t);case"ssr":return wB(t);case"trojan":return yB(t);case"vmess":return SB(t,n["include-unsupported-proxy"]);case"vless":return bB(t,n["include-unsupported-proxy"]);case"http":return CB(t);case"socks5":return FB(t);case"wireguard":return _B(t);case"hysteria2":return IB(t)}throw new Error(`Platform ${EB} does not support proxy type: ${t.type}`)}}}function AB(e){let t=new Qe(e);if(!["rc4","rc4-md5","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","bf-cfb","camellia-128-cfb","camellia-192-cfb","camellia-256-cfb","salsa20","chacha20","chacha20-ietf","aes-128-gcm","aes-192-gcm","aes-256-gcm","chacha20-ietf-poly1305","xchacha20-ietf-poly1305","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"].includes(e.cipher))throw new Error(`cipher ${e.cipher} is not supported`);if(t.append(`${e.name}=shadowsocks,${e.server},${e.port},${e.cipher},"${e.password}"`),ae(e,"plugin")){if(e.plugin==="obfs")t.append(`,obfs-name=${e["plugin-opts"].mode}`),t.appendIfPresent(`,obfs-host=${e["plugin-opts"].host}`,"plugin-opts.host"),t.appendIfPresent(`,obfs-uri=${e["plugin-opts"].path}`,"plugin-opts.path");else if(!["shadow-tls"].includes(e.plugin))throw new Error(`plugin ${e.plugin} is not supported`)}if(ae(e,"shadow-tls-password"))t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni"),t.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port");else if(["shadow-tls"].includes(e.plugin)&&e["plugin-opts"]){let n=e["plugin-opts"].password,i=e["plugin-opts"].host,a=e["plugin-opts"].version;if(n){if(t.append(`,shadow-tls-password=${n}`),i&&t.append(`,shadow-tls-sni=${i}`),a){if(a<2)throw new Error(`shadow-tls version ${a} is not supported`);t.append(`,shadow-tls-version=${a}`)}t.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port")}}t.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e.udp&&t.append(",udp=true");let r=Ps[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function wB(e,t){let r=new Qe(e);if(r.append(`${e.name}=shadowsocksr,${e.server},${e.port},${e.cipher},"${e.password}"`),r.append(`,protocol=${e.protocol}`),r.appendIfPresent(`,protocol-param=${e["protocol-param"]}`,"protocol-param"),r.appendIfPresent(`,obfs=${e.obfs}`,"obfs"),r.appendIfPresent(`,obfs-param=${e["obfs-param"]}`,"obfs-param"),ae(e,"shadow-tls-password"))r.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),r.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),r.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni"),r.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port");else if(["shadow-tls"].includes(e.plugin)&&e["plugin-opts"]){let i=e["plugin-opts"].password,a=e["plugin-opts"].host,s=e["plugin-opts"].version;if(i){if(r.append(`,shadow-tls-password=${i}`),a&&r.append(`,shadow-tls-sni=${a}`),s){if(s<2)throw new Error(`shadow-tls version ${s} is not supported`);r.append(`,shadow-tls-version=${s}`)}r.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port")}}r.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e.udp&&r.append(",udp=true");let n=Ps[e["ip-version"]]||e["ip-version"];return r.appendIfPresent(`,ip-mode=${n}`,"ip-version"),r.toString()}function yB(e){let t=new Qe(e);if(t.append(`${e.name}=trojan,${e.server},${e.port},"${e.password}"`),e.network==="tcp"&&delete e.network,ae(e,"network"))if(e.network==="ws")t.append(",transport=ws"),t.appendIfPresent(`,path=${e["ws-opts"]?.path}`,"ws-opts.path"),t.appendIfPresent(`,host=${e["ws-opts"]?.headers?.Host}`,"ws-opts.headers.Host");else throw new Error(`network ${e.network} is unsupported`);t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tls-name=${e.sni}`,"sni"),t.appendIfPresent(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),t.appendIfPresent(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),t.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e.udp&&t.append(",udp=true");let r=Ps[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function SB(e,t){if(!t&&e["reality-opts"])throw new Error("VMess REALITY is not supported");let r=!1;t&&e["reality-opts"]&&(r=!0);let n=new Qe(e);if(n.append(`${e.name}=vmess,${e.server},${e.port},${e.cipher},"${e.uuid}"`),e.network==="tcp"&&delete e.network,ae(e,"network"))if(e.network==="ws")n.append(",transport=ws"),n.appendIfPresent(`,path=${e["ws-opts"]?.path}`,"ws-opts.path"),n.appendIfPresent(`,host=${e["ws-opts"]?.headers?.Host}`,"ws-opts.headers.Host");else if(e.network==="http"){n.append(",transport=http");let a=e["http-opts"]?.path,s=e["http-opts"]?.headers?.Host;n.appendIfPresent(`,path=${Array.isArray(a)?a[0]:a}`,"http-opts.path"),n.appendIfPresent(`,host=${Array.isArray(s)?s[0]:s}`,"http-opts.headers.Host")}else throw new Error(`network ${e.network} is unsupported`);else n.append(",transport=tcp");n.appendIfPresent(`,over-tls=${e.tls}`,"tls"),n.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),r?(n.appendIfPresent(`,sni=${e.sni}`,"sni"),n.appendIfPresent(`,public-key="${e["reality-opts"]["public-key"]}"`,"reality-opts.public-key"),n.appendIfPresent(`,short-id=${e["reality-opts"]["short-id"]}`,"reality-opts.short-id")):(n.appendIfPresent(`,tls-name=${e.sni}`,"sni"),n.appendIfPresent(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),n.appendIfPresent(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256")),ae(e,"aead")?n.append(",alterId=0"):n.append(`,alterId=${e.alterId}`),n.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e.udp&&n.append(",udp=true");let i=Ps[e["ip-version"]]||e["ip-version"];return n.appendIfPresent(`,ip-mode=${i}`,"ip-version"),n.toString()}function bB(e,t){if(!t&&(typeof e.flow<"u"||e["reality-opts"]))throw new Error("VLESS XTLS/REALITY is not supported");let r=!1,n=!1;if(t&&(e["reality-opts"]&&(n=!0),typeof e.flow<"u"))if(["xtls-rprx-vision"].includes(e.flow))r=!0;else throw new Error(`VLESS flow(${e.flow}) is not supported`);let i=new Qe(e);if(i.append(`${e.name}=vless,${e.server},${e.port},"${e.uuid}"`),e.network==="tcp"&&delete e.network,ae(e,"network"))if(e.network==="ws")i.append(",transport=ws"),i.appendIfPresent(`,path=${e["ws-opts"]?.path}`,"ws-opts.path"),i.appendIfPresent(`,host=${e["ws-opts"]?.headers?.Host}`,"ws-opts.headers.Host");else if(e.network==="http"){i.append(",transport=http");let s=e["http-opts"]?.path,o=e["http-opts"]?.headers?.Host;i.appendIfPresent(`,path=${Array.isArray(s)?s[0]:s}`,"http-opts.path"),i.appendIfPresent(`,host=${Array.isArray(o)?o[0]:o}`,"http-opts.headers.Host")}else throw new Error(`network ${e.network} is unsupported`);else i.append(",transport=tcp");i.appendIfPresent(`,over-tls=${e.tls}`,"tls"),i.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),r&&i.appendIfPresent(`,flow=${e.flow}`,"flow"),n?(i.appendIfPresent(`,sni=${e.sni}`,"sni"),i.appendIfPresent(`,public-key="${e["reality-opts"]["public-key"]}"`,"reality-opts.public-key"),i.appendIfPresent(`,short-id=${e["reality-opts"]["short-id"]}`,"reality-opts.short-id")):(i.appendIfPresent(`,tls-name=${e.sni}`,"sni"),i.appendIfPresent(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),i.appendIfPresent(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256")),i.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e.udp&&i.append(",udp=true");let a=Ps[e["ip-version"]]||e["ip-version"];return i.appendIfPresent(`,ip-mode=${a}`,"ip-version"),i.toString()}function CB(e){let t=new Qe(e),r=e.tls?"https":"http";t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,${e.username}`,"username"),t.appendIfPresent(`,"${e.password}"`,"password"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo");let n=Ps[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${n}`,"ip-version"),t.toString()}function FB(e){let t=new Qe(e);t.append(`${e.name}=socks5,${e.server},${e.port}`),t.appendIfPresent(`,${e.username}`,"username"),t.appendIfPresent(`,"${e.password}"`,"password"),t.appendIfPresent(`,over-tls=${e.tls}`,"tls"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),e.udp&&t.append(",udp=true");let r=Ps[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function _B(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 Qe(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(o=>Jt(o));let s=e.dns.find(o=>or(o));s||(s=e.dns.find(o=>!or(o)&&!Jt(o))),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=Ps[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${a}`,"ip-version"),t.toString()}function IB(e){if(e["obfs-password"]&&e.obfs!="salamander")throw new Error("only salamander obfs is supported");let t=new Qe(e);t.append(`${e.name}=Hysteria2,${e.server},${e.port}`),t.appendIfPresent(`,"${e.password}"`,"password"),t.appendIfPresent(`,tls-name=${e.sni}`,"sni"),t.appendIfPresent(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),t.appendIfPresent(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),e["obfs-password"]&&e.obfs=="salamander"&&t.append(`,salamander-password=${e["obfs-password"]}`),t.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e.udp&&t.append(",udp=true"),t.appendIfPresent(`,download-bandwidth=${`${e.down}`.match(/\d+/)?.[0]||0}`,"down"),t.appendIfPresent(`,ecn=${e.ecn}`,"ecn");let r=Ps[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function bo(){return{type:"SINGLE",produce:r=>{let n="";delete r.subName,delete r.collectionName,delete r.id,delete r.resolved,delete r["no-resolve"];for(let i in r)(r[i]==null||/^_/i.test(i))&&delete r[i];switch(["trojan","tuic","hysteria","hysteria2","juicity"].includes(r.type)&&delete r.tls,!["vmess"].includes(r.type)&&r.server&&Jt(r.server)&&(r.server=`[${r.server}]`),r.type){case"socks5":n=`socks://${encodeURIComponent(Et.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)}`:Et.encode(i)}@${r.server}:${r.port}${r.plugin?"/":""}`,r.plugin){n+="?plugin=";let ce=r["plugin-opts"];switch(r.plugin){case"obfs":n+=encodeURIComponent(`simple-obfs;obfs=${ce.mode}${ce.host?";obfs-host="+ce.host:""}`);break;case"v2ray-plugin":n+=encodeURIComponent(`v2ray-plugin;obfs=${ce.mode}${ce.host?";obfs-host"+ce.host:""}${ce.tls?";tls":""}`);break;case"shadow-tls":n+=encodeURIComponent(`shadow-tls;host=${ce.host};password=${ce.password};version=${ce.version}`);break;default:throw new Error(`Unsupported plugin option: ${r.plugin}`)}}r["udp-over-tcp"]&&(n=`${n}${r.plugin?"&":"?"}uot=1`),r.tfo&&(n=`${n}${r.plugin||r["udp-over-tcp"]?"&":"?"}tfo=1`),n+=`#${encodeURIComponent(r.name)}`;break;case"ssr":n=`${r.server}:${r.port}:${r.protocol}:${r.cipher}:${r.obfs}:${Et.encode(r.password)}/`,n+=`?remarks=${Et.encode(r.name)}${r["obfs-param"]?"&obfsparam="+Et.encode(r["obfs-param"]):""}${r["protocol-param"]?"&protocolparam="+Et.encode(r["protocol-param"]):""}`,n="ssr://"+Et.encode(n);break;case"vmess":let a="",s=r.network||"tcp";if(r.network==="http"?(s="tcp",a="http"):r.network==="ws"&&r["ws-opts"]?.["v2ray-http-upgrade"]&&(s="httpupgrade"),n={v:"2",ps:r.name,add:r.server,port:r.port,id:r.uuid,type:a,aid:r.alterId||0,net:s,tls:r.tls?"tls":""},r.tls&&r.sni&&(n.sni=r.sni),r.network){let ce=r[`${r.network}-opts`]?.path,_e=r[`${r.network}-opts`]?.headers?.Host;ce&&(n.path=Array.isArray(ce)?ce[0]:ce),_e&&(n.host=Array.isArray(_e)?_e[0]:_e),["grpc"].includes(r.network)&&(n.path=r[`${r.network}-opts`]?.["grpc-service-name"],n.type=r[`${r.network}-opts`]?.["_grpc-type"]||"gun",n.host=r[`${r.network}-opts`]?.["_grpc-authority"])}n="vmess://"+Et.encode(JSON.stringify(n));break;case"vless":let o="none",l=r["reality-opts"],h="",d="",E="";if(l){o="reality";let ce=r["reality-opts"]?.["public-key"];ce&&(d=`&pbk=${encodeURIComponent(ce)}`);let _e=r["reality-opts"]?.["short-id"];_e&&(h=`&sid=${encodeURIComponent(_e)}`);let Le=r["reality-opts"]?.["_spider-x"];Le&&(E=`&spx=${encodeURIComponent(Le)}`)}else r.tls&&(o="tls");let p="";r.alpn&&(p=`&alpn=${encodeURIComponent(Array.isArray(r.alpn)?r.alpn:r.alpn.join(","))}`);let f="";r["skip-cert-verify"]&&(f="&allowInsecure=1");let w="";r.sni&&(w=`&sni=${encodeURIComponent(r.sni)}`);let g="";r["client-fingerprint"]&&(g=`&fp=${encodeURIComponent(r["client-fingerprint"])}`);let y="";r.flow&&(y=`&flow=${encodeURIComponent(r.flow)}`);let A="";r._extra&&(A=`&extra=${encodeURIComponent(r._extra)}`);let S="";r._mode&&(S=`&mode=${encodeURIComponent(r._mode)}`);let _=r.network;r.network==="ws"&&r["ws-opts"]?.["v2ray-http-upgrade"]&&(_="httpupgrade");let I=`&type=${encodeURIComponent(_)}`;if(["grpc"].includes(r.network)){I+=`&mode=${encodeURIComponent(r[`${r.network}-opts`]?.["_grpc-type"]||"gun")}`;let ce=r[`${r.network}-opts`]?.["_grpc-authority"];ce&&(I+=`&authority=${encodeURIComponent(ce)}`)}let D=r[`${r.network}-opts`]?.[`${r.network}-service-name`],H=r[`${r.network}-opts`]?.path,V=r[`${r.network}-opts`]?.headers?.Host;H&&(I+=`&path=${encodeURIComponent(Array.isArray(H)?H[0]:H)}`),V&&(I+=`&host=${encodeURIComponent(Array.isArray(V)?V[0]:V)}`),D&&(I+=`&serviceName=${encodeURIComponent(D)}`),r.network==="kcp"&&(r.seed&&(I+=`&seed=${encodeURIComponent(r.seed)}`),r.headerType&&(I+=`&headerType=${encodeURIComponent(r.headerType)}`)),n=`vless://${r.uuid}@${r.server}:${r.port}?security=${encodeURIComponent(o)}${I}${p}${f}${w}${g}${y}${h}${E}${d}${S}${A}#${encodeURIComponent(r.name)}`;break;case"trojan":let F="";if(r.network){let ce=r.network;if(r.network==="ws"&&r["ws-opts"]?.["v2ray-http-upgrade"]&&(ce="httpupgrade"),F=`&type=${encodeURIComponent(ce)}`,["grpc"].includes(r.network)){let lr=r[`${r.network}-opts`]?.[`${r.network}-service-name`],Bt=r[`${r.network}-opts`]?.["_grpc-authority"];lr&&(F+=`&serviceName=${encodeURIComponent(lr)}`),Bt&&(F+=`&authority=${encodeURIComponent(Bt)}`),F+=`&mode=${encodeURIComponent(r[`${r.network}-opts`]?.["_grpc-type"]||"gun")}`}let _e=r[`${r.network}-opts`]?.path,Le=r[`${r.network}-opts`]?.headers?.Host;_e&&(F+=`&path=${encodeURIComponent(Array.isArray(_e)?_e[0]:_e)}`),Le&&(F+=`&host=${encodeURIComponent(Array.isArray(Le)?Le[0]:Le)}`)}let P="";r["client-fingerprint"]&&(P=`&fp=${encodeURIComponent(r["client-fingerprint"])}`);let k="";r.alpn&&(k=`&alpn=${encodeURIComponent(Array.isArray(r.alpn)?r.alpn:r.alpn.join(","))}`);let L=r["reality-opts"],q="",J="",z="",K="",X="",ie="";if(L){K="&security=reality";let ce=r["reality-opts"]?.["public-key"];ce&&(J=`&pbk=${encodeURIComponent(ce)}`);let _e=r["reality-opts"]?.["short-id"];_e&&(q=`&sid=${encodeURIComponent(_e)}`);let Le=r["reality-opts"]?.["_spider-x"];Le&&(z=`&spx=${encodeURIComponent(Le)}`),r._extra&&(ie=`&extra=${encodeURIComponent(r._extra)}`),r._mode&&(X=`&mode=${encodeURIComponent(r._mode)}`)}n=`trojan://${r.password}@${r.server}:${r.port}?sni=${encodeURIComponent(r.sni||r.server)}${r["skip-cert-verify"]?"&allowInsecure=1":""}${F}${k}${P}${K}${q}${J}${z}${X}${ie}#${encodeURIComponent(r.name)}`;break;case"hysteria2":let be=[];r["hop-interval"]&&be.push(`hop-interval=${r["hop-interval"]}`),r.keepalive&&be.push(`keepalive=${r.keepalive}`),r["skip-cert-verify"]&&be.push("insecure=1"),r.obfs&&(be.push(`obfs=${encodeURIComponent(r.obfs)}`),r["obfs-password"]&&be.push(`obfs-password=${encodeURIComponent(r["obfs-password"])}`)),r.sni&&be.push(`sni=${encodeURIComponent(r.sni)}`),r.ports&&be.push(`mport=${r.ports}`),r["tls-fingerprint"]&&be.push(`pinSHA256=${encodeURIComponent(r["tls-fingerprint"])}`),r.tfo&&be.push("fastopen=1"),n=`hysteria2://${encodeURIComponent(r.password)}@${r.server}:${r.port}?${be.join("&")}#${encodeURIComponent(r.name)}`;break;case"hysteria":let ye=[];Object.keys(r).forEach(ce=>{if(!["name","type","server","port"].includes(ce)){let _e=ce.replace(/-/,"_");["alpn"].includes(ce)?r[ce]&&ye.push(`${_e}=${encodeURIComponent(Array.isArray(r[ce])?r[ce][0]:r[ce])}`):["skip-cert-verify"].includes(ce)?r[ce]&&ye.push("insecure=1"):["tfo","fast-open"].includes(ce)?r[ce]&&!ye.includes("fastopen=1")&&ye.push("fastopen=1"):["ports"].includes(ce)?ye.push(`mport=${r[ce]}`):["auth-str"].includes(ce)?ye.push(`auth=${r[ce]}`):["up"].includes(ce)?ye.push(`upmbps=${r[ce]}`):["down"].includes(ce)?ye.push(`downmbps=${r[ce]}`):["_obfs"].includes(ce)?ye.push(`obfs=${r[ce]}`):["obfs"].includes(ce)?ye.push(`obfsParam=${r[ce]}`):["sni"].includes(ce)?ye.push(`peer=${r[ce]}`):r[ce]&&ye.push(`${_e}=${encodeURIComponent(r[ce])}`)}}),n=`hysteria://${r.server}:${r.port}?${ye.join("&")}#${encodeURIComponent(r.name)}`;break;case"tuic":if(!r.token||r.token.length===0){let ce=[];Object.keys(r).forEach(_e=>{if(!["name","type","uuid","password","server","port","tls"].includes(_e)){let Le=_e.replace(/-/,"_");["alpn"].includes(_e)?r[_e]&&ce.push(`${Le}=${encodeURIComponent(Array.isArray(r[_e])?r[_e][0]:r[_e])}`):["skip-cert-verify"].includes(_e)?r[_e]&&ce.push("allow_insecure=1"):["tfo","fast-open"].includes(_e)?r[_e]&&!ce.includes("fast_open=1")&&ce.push("fast_open=1"):["disable-sni","reduce-rtt"].includes(_e)&&r[_e]?ce.push(`${Le.replace(/-/g,"_")}=1`):r[_e]&&ce.push(`${Le.replace(/-/g,"_")}=${encodeURIComponent(r[_e])}`)}}),n=`tuic://${encodeURIComponent(r.uuid)}:${encodeURIComponent(r.password)}@${r.server}:${r.port}?${ce.join("&")}#${encodeURIComponent(r.name)}`}break;case"anytls":let $e=[];Object.keys(r).forEach(ce=>{if(!["name","type","password","server","port","tls"].includes(ce)){let _e=ce.replace(/-/,"_");["alpn"].includes(ce)?r[ce]&&$e.push(`${_e}=${encodeURIComponent(Array.isArray(r[ce])?r[ce][0]:r[ce])}`):["skip-cert-verify"].includes(ce)?r[ce]&&$e.push("insecure=1"):r[ce]&&$e.push(`${_e.replace(/-/g,"_")}=${encodeURIComponent(r[ce])}`)}}),n=`anytls://${encodeURIComponent(r.password)}@${r.server}:${r.port}/?${$e.join("&")}#${encodeURIComponent(r.name)}`;break;case"wireguard":let qe=[];Object.keys(r).forEach(ce=>{["name","type","server","port","ip","ipv6","private-key"].includes(ce)||(["public-key"].includes(ce)?qe.push(`publickey=${r[ce]}`):["udp"].includes(ce)?r[ce]&&qe.push(`${ce}=1`):r[ce]&&qe.push(`${ce}=${encodeURIComponent(r[ce])}`))}),r.ip&&r.ipv6?qe.push(`address=${r.ip}/32,${r.ipv6}/128`):r.ip?qe.push(`address=${r.ip}/32`):r.ipv6&&qe.push(`address=${r.ipv6}/128`),n=`wireguard://${encodeURIComponent(r["private-key"])}@${r.server}:${r.port}/?${qe.join("&")}#${encodeURIComponent(r.name)}`;break}return n}}}var DB=bo();function qc(){return{type:"ALL",produce:r=>{let n=[];return r.map(i=>{try{n.push(DB.produce(i))}catch(a){G.error(`Cannot produce proxy: ${JSON.stringify(i,null,2)} Reason: ${a}`)}}),Et.encode(n.join(` `))}}}var BB="QX";function Vc(){return{produce:(t,r,n={})=>{switch(t.type){case"ss":return $B(t,n["include-unsupported-proxy"]);case"ssr":return PB(t);case"trojan":return RB(t);case"vmess":return TB(t);case"http":return OB(t);case"socks5":return NB(t);case"vless":return xB(t)}throw new Error(`Platform ${BB} does not support proxy type: ${t.type}`)}}}function $B(e,t){let r=new Qe(e),n=r.append.bind(r),i=r.appendIfPresent.bind(r);if(e.cipher||(e.cipher="none"),!["none","rc4-md5","rc4-md5-6","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","bf-cfb","cast5-cfb","des-cfb","rc2-cfb","salsa20","chacha20","chacha20-ietf","aes-128-gcm","aes-192-gcm","aes-256-gcm","chacha20-ietf-poly1305","xchacha20-ietf-poly1305",...t?["2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"]:[]].includes(e.cipher))throw new Error(`cipher ${e.cipher} is not supported`);if(n(`shadowsocks=${e.server}:${e.port}`),n(`,method=${e.cipher}`),n(`,password=${e.password}`),On(e)&&(e.tls=!0),ae(e,"plugin")){if(e.plugin==="obfs"){let a=e["plugin-opts"];n(`,obfs=${a.mode}`)}else if(e.plugin==="v2ray-plugin"&&e["plugin-opts"].mode==="websocket")e["plugin-opts"].tls?n(",obfs=wss"):n(",obfs=ws");else throw new Error("plugin is not supported");i(`,obfs-host=${e["plugin-opts"].host}`,"plugin-opts.host"),i(`,obfs-uri=${e["plugin-opts"].path}`,"plugin-opts.path")}return On(e)&&(i(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),i(`,tls-alpn=${e["tls-alpn"]}`,"tls-alpn"),i(`,tls-no-session-ticket=${e["tls-no-session-ticket"]}`,"tls-no-session-ticket"),i(`,tls-no-session-reuse=${e["tls-no-session-reuse"]}`,"tls-no-session-reuse"),i(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),i(`,tls-verification=${!e["skip-cert-verify"]}`,"skip-cert-verify"),i(`,tls-host=${e.sni}`,"sni")),i(`,fast-open=${e.tfo}`,"tfo"),i(`,udp-relay=${e.udp}`,"udp"),r.appendIfPresent(`,server_check_url=${e["test-url"]}`,"test-url"),n(`,tag=${e.name}`),r.toString()}function PB(e){let t=new Qe(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 RB(e){let t=new Qe(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t);if(r(`trojan=${e.server}:${e.port}`),r(`,password=${e.password}`),ae(e,"network"))if(e.network==="ws")On(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"&&On(e)&&r(",over-tls=true"),On(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 TB(e){let t=new Qe(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}`),On(e)&&(e.tls=!0),ae(e,"network")){if(e.network==="ws")e.tls?r(",obfs=wss"):r(",obfs=ws");else if(e.network==="http")r(",obfs=http");else throw new Error(`network ${e.network} is unsupported`);let a=e[`${e.network}-opts`]?.path,s=e[`${e.network}-opts`]?.headers?.Host;n(`,obfs-uri=${Array.isArray(a)?a[0]:a}`,`${e.network}-opts.path`),n(`,obfs-host=${Array.isArray(s)?s[0]:s}`,`${e.network}-opts.headers.Host`)}else e.tls&&r(",obfs=over-tls");return On(e)&&(n(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),n(`,tls-alpn=${e["tls-alpn"]}`,"tls-alpn"),n(`,tls-no-session-ticket=${e["tls-no-session-ticket"]}`,"tls-no-session-ticket"),n(`,tls-no-session-reuse=${e["tls-no-session-reuse"]}`,"tls-no-session-reuse"),n(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),n(`,tls-verification=${!e["skip-cert-verify"]}`,"skip-cert-verify"),n(`,tls-host=${e.sni}`,"sni")),ae(e,"aead")?r(`,aead=${e.aead}`):r(`,aead=${e.alterId===0}`),n(`,fast-open=${e.tfo}`,"tfo"),n(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,server_check_url=${e["test-url"]}`,"test-url"),r(`,tag=${e.name}`),t.toString()}function xB(e){if(typeof e.flow<"u"||e["reality-opts"])throw new Error("VLESS XTLS/REALITY is not supported");let t=new Qe(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}`),On(e)&&(e.tls=!0),ae(e,"network")){if(e.network==="ws")e.tls?r(",obfs=wss"):r(",obfs=ws");else if(e.network==="http")r(",obfs=http");else if(!["tcp"].includes(e.network))throw new Error(`network ${e.network} is unsupported`);let a=e[`${e.network}-opts`]?.path,s=e[`${e.network}-opts`]?.headers?.Host;n(`,obfs-uri=${Array.isArray(a)?a[0]:a}`,`${e.network}-opts.path`),n(`,obfs-host=${Array.isArray(s)?s[0]:s}`,`${e.network}-opts.headers.Host`)}else e.tls&&r(",obfs=over-tls");return On(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 OB(e){let t=new Qe(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"),On(e)&&(e.tls=!0),n(`,over-tls=${e.tls}`,"tls"),On(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 NB(e){let t=new Qe(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"),On(e)&&(e.tls=!0),n(`,over-tls=${e.tls}`,"tls"),On(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 On(e){return e.tls}function Kc(){return{type:"ALL",produce:(r,n,i={})=>{let a=r.filter(s=>i["include-unsupported-proxy"]?!0:s.type==="snell"&&String(s.version)==="4"?!1:!["mieru","anytls"].includes(s.type)).map(s=>{if(s.type==="vmess"?(ae(s,"aead")&&(s.aead&&(s.alterId=0),delete s.aead),ae(s,"sni")&&(s.servername=s.sni,delete s.sni),ae(s,"cipher")&&!["auto","none","zero","aes-128-gcm","chacha20-poly1305"].includes(s.cipher)&&(s.cipher="auto")):s.type==="tuic"?(ae(s,"alpn")?s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]:s.alpn=["h3"],ae(s,"tfo")&&!ae(s,"fast-open")&&(s["fast-open"]=s.tfo),(!s.token||s.token.length===0)&&!ae(s,"version")&&(s.version=5)):s.type==="hysteria"?(ae(s,"auth_str")&&!ae(s,"auth-str")&&(s["auth-str"]=s.auth_str),ae(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),ae(s,"tfo")&&!ae(s,"fast-open")&&(s["fast-open"]=s.tfo)):s.type==="hysteria2"?(s["obfs-password"]&&s.obfs=="salamander"&&(s.obfs=s["obfs-password"],delete s["obfs-password"]),ae(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),ae(s,"tfo")&&!ae(s,"fast-open")&&(s["fast-open"]=s.tfo)):s.type==="wireguard"?(s.keepalive=s.keepalive??s["persistent-keepalive"],s["persistent-keepalive"]=s.keepalive,s["preshared-key"]=s["preshared-key"]??s["pre-shared-key"],s["pre-shared-key"]=s["preshared-key"]):s.type==="snell"&&s.version<3?delete s.udp:s.type==="vless"?ae(s,"sni")&&(s.servername=s.sni,delete s.sni):s.type==="ss"&&ae(s,"shadow-tls-password")&&!ae(s,"plugin")&&(s.plugin="shadow-tls",s["plugin-opts"]={host:s["shadow-tls-sni"],password:s["shadow-tls-password"],version:s["shadow-tls-version"]},delete s["shadow-tls-password"],delete s["shadow-tls-sni"],delete s["shadow-tls-version"]),["vmess","vless"].includes(s.type)&&s.network==="http"){let o=s["http-opts"]?.path;ae(s,"http-opts.path")&&!Array.isArray(o)&&(s["http-opts"].path=[o]);let l=s["http-opts"]?.headers?.Host;ae(s,"http-opts.headers.Host")&&!Array.isArray(l)&&(s["http-opts"].headers.Host=[l])}if(["vmess","vless"].includes(s.type)&&s.network==="h2"){let o=s["h2-opts"]?.path;ae(s,"h2-opts.path")&&Array.isArray(o)&&(s["h2-opts"].path=o[0]);let l=s["h2-opts"]?.headers?.host;ae(s,"h2-opts.headers.Host")&&!Array.isArray(l)&&(s["h2-opts"].headers.host=[l])}if(s["plugin-opts"]?.tls&&ae(s,"skip-cert-verify")&&(s["plugin-opts"]["skip-cert-verify"]=s["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls"].includes(s.type)&&delete s.tls,s["tls-fingerprint"]&&(s.fingerprint=s["tls-fingerprint"]),delete s["tls-fingerprint"],s["underlying-proxy"]&&(s["dialer-proxy"]=s["underlying-proxy"]),delete s["underlying-proxy"],ae(s,"tls")&&typeof s.tls!="boolean"&&delete s.tls,delete s.subName,delete s.collectionName,delete s.id,delete s.resolved,delete s["no-resolve"],n!=="internal")for(let o in s)(s[o]==null||/^_/i.test(o))&&delete s[o];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 kB="Surfboard";function ah(){return{produce:t=>{switch(t.name=t.name.replace(/=|,/g,""),t.type){case"ss":return LB(t);case"trojan":return UB(t);case"vmess":return HB(t);case"http":return jB(t);case"socks5":return MB(t);case"wireguard-surge":return qB(t)}throw new Error(`Platform ${kB} does not support proxy type: ${t.type}`)}}}function LB(e){let t=new Qe(e);if(t.append(`${e.name}=${e.type},${e.server},${e.port}`),!["aes-128-gcm","aes-192-gcm","aes-256-gcm","chacha20-ietf-poly1305","xchacha20-ietf-poly1305","rc4","rc4-md5","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","bf-cfb","camellia-128-cfb","camellia-192-cfb","camellia-256-cfb","salsa20","chacha20","chacha20-ietf"].includes(e.cipher))throw new Error(`cipher ${e.cipher} is not supported`);if(t.append(`,encrypt-method=${e.cipher}`),t.appendIfPresent(`,password=${e.password}`,"password"),ae(e,"plugin"))if(e.plugin==="obfs")t.append(`,obfs=${e["plugin-opts"].mode}`),t.appendIfPresent(`,obfs-host=${e["plugin-opts"].host}`,"plugin-opts.host"),t.appendIfPresent(`,obfs-uri=${e["plugin-opts"].path}`,"plugin-opts.path");else throw new Error(`plugin ${e.plugin} is not supported`);return t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.toString()}function UB(e){let t=new Qe(e);return t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password=${e.password}`,"password"),uA(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 HB(e){let t=new Qe(e);return t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,username=${e.uuid}`,"uuid"),uA(t,e),ae(e,"aead")?t.append(`,vmess-aead=${e.aead}`):t.append(`,vmess-aead=${e.alterId===0}`),t.appendIfPresent(`,tls=${e.tls}`,"tls"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.toString()}function jB(e){let t=new Qe(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 MB(e){let t=new Qe(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 qB(e){let t=new Qe(e);return t.append(`${e.name}=wireguard`),t.appendIfPresent(`,section-name=${e["section-name"]}`,"section-name"),t.toString()}function uA(e,t){if(ae(t,"network"))if(t.network==="ws"){if(e.append(",ws=true"),ae(t,"ws-opts")&&(e.appendIfPresent(`,ws-path=${t["ws-opts"].path}`,"ws-opts.path"),ae(t,"ws-opts.headers"))){let r=t["ws-opts"].headers,n=Object.keys(r).map(i=>{let a=r[i];return["Host"].includes(i)&&(a=`"${a}"`),`${i}:${a}`}).join("|");Ti(n)&&e.append(`,ws-headers=${n}`)}}else throw new Error(`network ${t.network} is unsupported`)}var vn=(e,t)=>{t.detour=e["dialer-proxy"]||e.detour},Rs=(e,t)=>{["tcp","udp"].includes(e._network)&&(t.network=e._network)},Nn=(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},Vi=(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))},w0=(e,t)=>{let r={type:"ws",headers:{}};if(e["ws-opts"]){let{path:n="",headers:i={}}=e["ws-opts"];if(n!==""&&(r.path=`${n}`),Object.keys(i).length>0){let a={};for(let o of Object.keys(i)){let l=i[o];l!==""&&(Array.isArray(l)||(l=[`${l}`]),l.length>0&&(a[o]=l))}let{Host:s}=a;if(s.length===1)for(let o of`Host:${s[0]}`.split(` `)){let[l,h]=o.split(":");h.trim()!==""&&(a[l.trim()]=h.trim().split(","))}r.headers=a}}if(e["ws-headers"]){let n={};for(let a of Object.keys(e["ws-headers"])){let s=e["ws-headers"][a];s!==""&&(Array.isArray(s)||(s=[`${s}`]),s.length>0&&(n[a]=s))}let{Host:i}=n;if(i.length===1)for(let a of`Host:${i[0]}`.split(` `)){let[s,o]=a.split(":");o.trim()!==""&&(n[s.trim()]=o.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},VB=(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 o=a[s];if(o!==""){if(s.toLowerCase()==="host"){let l=o;Array.isArray(l)||(l=`${l}`.split(",").map(h=>h.trim())),l.length>0&&(r.host=l);continue}Array.isArray(o)||(o=`${o}`.split(",").map(l=>l.trim())),o.length>0&&(r.headers[s]=o)}}}if(e["http-host"]&&e["http-host"]!==""){let n=e["http-host"];Array.isArray(n)||(n=`${n}`.split(",").map(i=>i.trim())),n.length>0&&(r.host=n)}if(r.host){if(e["http-path"]&&e["http-path"]!==""){let n=e["http-path"];Array.isArray(n)?r.path=`${n[0]}`:n!==""&&(r.path=`${n}`)}t.tls.insecure&&(t.tls.server_name=r.host[0]),r.host.length===1&&(r.host=r.host[0]);for(let n of Object.keys(r.headers)){let i=r.headers[n];i.length===1&&(r.headers[n]=i[0])}t.transport=r}},KB=(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},y0=(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},ia=(e,t)=>{e.tls&&(t.tls.enabled=!0),e.servername&&e.servername!==""&&(t.tls.server_name=e.servername),e.peer&&e.peer!==""&&(t.tls.server_name=e.peer),e.sni&&e.sni!==""&&(t.tls.server_name=e.sni),e["skip-cert-verify"]&&(t.tls.insecure=!0),e.insecure&&(t.tls.insecure=!0),e["disable-sni"]&&(t.tls.disable_sni=!0),typeof e.alpn=="string"?t.tls.alpn=[e.alpn]:Array.isArray(e.alpn)&&(t.tls.alpn=e.alpn),e.ca&&(t.tls.certificate_path=`${e.ca}`),e.ca_str&&(t.tls.certificate=[e.ca_str]),e["ca-str"]&&(t.tls.certificate=[e["ca-str"]]),e["reality-opts"]&&(t.tls.reality={enabled:!0},e["reality-opts"]["public-key"]&&(t.tls.reality.public_key=e["reality-opts"]["public-key"]),e["reality-opts"]["short-id"]&&(t.tls.reality.short_id=e["reality-opts"]["short-id"]),t.tls.utls={enabled:!0}),!["hysteria","hysteria2","tuic"].includes(e.type)&&e["client-fingerprint"]&&e["client-fingerprint"]!==""&&(t.tls.utls={enabled:!0,fingerprint:e["client-fingerprint"]}),t.tls.enabled||delete t.tls},GB=(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),Nn(e,t),vn(e,t),t},zB=(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),Nn(e,t),vn(e,t),ia(e,t),t},YB=(e={})=>{let t={tag:e.name,type:"socks",server:e.server,server_port:parseInt(`${e.port}`,10),password:e.password,version:"5"};if(t.server_port<0||t.server_port>65535)throw"invalid port";return e.username&&(t.username=e.username),e.password&&(t.password=e.password),e.uot&&(t.udp_over_tcp=!0),e["udp-over-tcp"]&&(t.udp_over_tcp=!0),e["fast-open"]&&(t.udp_fragment=!0),Rs(e,t),Nn(e,t),vn(e,t),t},WB=(e={})=>{let t={tag:e.name,type:"shadowsocks",method:e.cipher,password:e.password,detour:`${e.name}_shadowtls`},r={tag:`${e.name}_shadowtls`,type:"shadowtls",server:e.server,server_port:parseInt(`${e.port}`,10),version:e["plugin-opts"].version,password:e["plugin-opts"].password,tls:{enabled:!0,server_name:e["plugin-opts"].host,utls:{enabled:!0,fingerprint:e["client-fingerprint"]}}};if(r.server_port<0||r.server_port>65535)throw"\u7AEF\u53E3\u503C\u975E\u6CD5";return e["fast-open"]===!0&&(r.udp_fragment=!0),Nn(e,r),vn(e,r),Vi(e.smux,t),{type:"ss-with-st",ssPart:t,stPart:r}},XB=(e={})=>{let t={tag:e.name,type:"shadowsocks",server:e.server,server_port:parseInt(`${e.port}`,10),method:e.cipher,password:e.password};if(t.server_port<0||t.server_port>65535)throw"invalid port";if(e.uot&&(t.udp_over_tcp=!0),e["udp-over-tcp"]&&(t.udp_over_tcp=!0),e["fast-open"]&&(t.udp_fragment=!0),Rs(e,t),Nn(e,t),vn(e,t),Vi(e.smux,t),e.plugin){let r=[];e.plugin==="obfs"&&(t.plugin="obfs-local",t.plugin_opts="",e["obfs-host"]&&(e["plugin-opts"].host=e["obfs-host"]),Object.keys(e["plugin-opts"]).forEach(n=>{switch(n){case"mode":r.push(`obfs=${e["plugin-opts"].mode}`);break;case"host":r.push(`obfs-host=${e["plugin-opts"].host}`);break;default:r.push(`${n}=${e["plugin-opts"][n]}`);break}})),e.plugin==="v2ray-plugin"&&(t.plugin="v2ray-plugin",e["ws-host"]&&(e["plugin-opts"].host=e["ws-host"]),e["ws-path"]&&(e["plugin-opts"].path=e["ws-path"]),Object.keys(e["plugin-opts"]).forEach(n=>{switch(n){case"tls":e["plugin-opts"].tls&&r.push("tls");break;case"host":r.push(`host=${e["plugin-opts"].host}`);break;case"path":r.push(`path=${e["plugin-opts"].path}`);break;case"headers":r.push(`headers=${JSON.stringify(e["plugin-opts"].headers)}`);break;case"mux":e["plugin-opts"].mux&&(t.multiplex={enabled:!0});break;default:r.push(`${n}=${e["plugin-opts"][n]}`)}})),t.plugin_opts=r.join(";")}return t},JB=(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),Nn(e,t),vn(e,t),Vi(e.smux,t),t},ZB=(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"&&w0(e,t),e.network==="h2"&&KB(e,t),e.network==="http"&&VB(e,t),e.network==="grpc"&&y0(e,t),Rs(e,t),Nn(e,t),vn(e,t),ia(e,t),Vi(e.smux,t),t},QB=(e={})=>{let t={tag:e.name,type:"vless",server:e.server,server_port:parseInt(`${e.port}`,10),uuid:e.uuid,tls:{enabled:!1,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";return e["fast-open"]&&(t.udp_fragment=!0),e.flow==="xtls-rprx-vision"&&(t.flow=e.flow),e.network==="ws"&&w0(e,t),e.network==="grpc"&&y0(e,t),Rs(e,t),Nn(e,t),vn(e,t),Vi(e.smux,t),ia(e,t),t},e$=(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"&&y0(e,t),e.network==="ws"&&w0(e,t),Rs(e,t),Nn(e,t),vn(e,t),ia(e,t),Vi(e.smux,t),t},t$=(e={})=>{let t={tag:e.name,type:"hysteria",server:e.server,server_port:parseInt(`${e.port}`,10),disable_mtu_discovery:!1,tls:{enabled:!0,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";e.auth_str&&(t.auth_str=`${e.auth_str}`),e["auth-str"]&&(t.auth_str=`${e["auth-str"]}`),e["fast-open"]&&(t.udp_fragment=!0);let r=new RegExp("^[0-9]+[ ]*[KMGT]*[Bb]ps$");return r.test(`${e.up}`)?t.up=`${e.up}`:t.up_mbps=parseInt(`${e.up}`,10),r.test(`${e.down}`)?t.down=`${e.down}`:t.down_mbps=parseInt(`${e.down}`,10),e.obfs&&(t.obfs=e.obfs),e.recv_window_conn&&(t.recv_window_conn=e.recv_window_conn),e["recv-window-conn"]&&(t.recv_window_conn=e["recv-window-conn"]),e.recv_window&&(t.recv_window=e.recv_window),e["recv-window"]&&(t.recv_window=e["recv-window"]),e.disable_mtu_discovery&&(typeof e.disable_mtu_discovery=="boolean"?t.disable_mtu_discovery=e.disable_mtu_discovery:e.disable_mtu_discovery===1&&(t.disable_mtu_discovery=!0)),Rs(e,t),ia(e,t),vn(e,t),Nn(e,t),Vi(e.smux,t),t},r$=(e={})=>{let t={tag:e.name,type:"hysteria2",server:e.server,server_port:parseInt(`${e.port}`,10),password:e.password,obfs:{},tls:{enabled:!0,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";return e["hop-interval"]&&(t.hop_interval=/^\d+$/.test(e["hop-interval"])?`${e["hop-interval"]}s`:e["hop-interval"]),e.ports&&(t.server_ports=e.ports.split(/\s*,\s*/).map(r=>r.replace(/\s*-\s*/g,":"))),e.up&&(t.up_mbps=parseInt(`${e.up}`,10)),e.down&&(t.down_mbps=parseInt(`${e.down}`,10)),e.obfs==="salamander"&&(t.obfs.type="salamander"),e["obfs-password"]&&(t.obfs.password=e["obfs-password"]),t.obfs.type||delete t.obfs,Rs(e,t),ia(e,t),Nn(e,t),vn(e,t),Vi(e.smux,t),t},n$=(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`),Rs(e,t),Nn(e,t),vn(e,t),ia(e,t),Vi(e.smux,t),t},i$=(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`),vn(e,t),ia(e,t),t},s$=(e={})=>{let t=["ip","ipv6"].map(n=>e[n]).map(n=>{if(or(n))return`${n}/32`;if(Jt(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 Rs(e,r),Nn(e,r),vn(e,r),Vi(e.smux,r),r};function uh(){return{type:"ALL",produce:(r,n,i={})=>{let a=[];return xn().produce(r,"internal",{"include-unsupported-proxy":!0}).map(s=>{try{switch(s.type){case"ssh":a.push(GB(s));break;case"http":a.push(zB(s));break;case"socks5":if(s.tls)throw new Error(`Platform sing-box does not support proxy type: ${s.type} with tls`);a.push(YB(s));break;case"ss":if(s.plugin==="shadow-tls"){let{ssPart:o,stPart:l}=WB(s);a.push(o),a.push(l)}else a.push(XB(s));break;case"ssr":if(i["include-unsupported-proxy"])a.push(JB(s));else throw new Error(`Platform sing-box does not support proxy type: ${s.type}`);break;case"vmess":if(!s.network||["ws","grpc","h2","http"].includes(s.network))a.push(ZB(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(QB(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(e$(s));else throw new Error(`Platform sing-box does not support proxy type: ${s.type} with flow ${s.flow}`);break;case"hysteria":a.push(t$(s));break;case"hysteria2":a.push(r$(s,i["include-unsupported-proxy"]));break;case"tuic":if(!s.token||s.token.length===0)a.push(n$(s));else throw new Error("Platform sing-box does not support proxy type: TUIC v4");break;case"wireguard":a.push(s$(s));break;case"anytls":a.push(i$(s));break;default:throw new Error(`Platform sing-box does not support proxy type: ${s.type}`)}}catch(o){G.error(o.message??o)}}),n==="internal"?a:JSON.stringify({outbounds:a},null,2)}}}function oh(){return{type:"ALL",produce:(r,n)=>{let i=r.filter(a=>!(!["http","socks5","ss","trojan","hysteria2","vless","vmess","tuic"].includes(a.type)||a.type==="ss"&&(a.plugin==="obfs"&&!["http","tls"].includes(a["plugin-opts"]?.mode)||!["chacha20-ietf-poly1305","chacha20-poly1305","aes-256-gcm","aes-128-gcm","none","tbale","rc4","rc4-md5","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","bf-cfb","camellia-128-cfb","camellia-192-cfb","camellia-256-cfb","cast5-cfb","des-cfb","idea-cfb","rc2-cfb","seed-cfb","salsa20","chacha20","chacha20-ietf","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"].includes(a.cipher))||a.type==="vmess"&&!["http","ws","tcp"].includes(a.network)&&a.network||a.type==="trojan"&&!["http","ws","tcp"].includes(a.network)&&a.network||a.type==="vless"&&(typeof a.flow<"u"||a["reality-opts"]||!["http","ws","tcp"].includes(a.network)&&a.network)||a.type==="tuic"&&a.token&&a.token.length!==0)).map(a=>{let s={...a};a.tls&&!a.sni&&(a.sni=a.server);let o=a.prev_hop||a["underlying-proxy"]||a["dialer-proxy"]||a.detour;if(a.type==="http")a={type:"http",name:a.name,server:a.server,port:a.port,username:a.username,password:a.password,tfo:a.tfo||a["fast-open"],next_hop:a.next_hop};else if(a.type==="socks5")a={type:"socks5",name:a.name,server:a.server,port:a.port,username:a.username,password:a.password,tfo:a.tfo||a["fast-open"],udp_relay:a.udp||a.udp_relay||a.udp_relay,next_hop:a.next_hop};else if(a.type==="ss")a={type:"shadowsocks",name:a.name,method:a.cipher==="chacha20-ietf-poly1305"?"chacha20-poly1305":a.cipher,server:a.server,port:a.port,password:a.password,tfo:a.tfo||a["fast-open"],udp_relay:a.udp||a.udp_relay||a.udp_relay,next_hop:a.next_hop},s.plugin==="obfs"&&(a.obfs=s["plugin-opts"].mode,a.obfs_host=s["plugin-opts"].host,a.obfs_uri=s["plugin-opts"].path);else if(a.type==="hysteria2")a={type:"hysteria2",name:a.name,server:a.server,port:a.port,auth:a.password,tfo:a.tfo||a["fast-open"],udp_relay:a.udp||a.udp_relay||a.udp_relay,next_hop:a.next_hop,sni:a.sni,skip_tls_verify:a["skip-cert-verify"],port_hopping:a.ports,port_hopping_interval:a["hop-interval"]},s["obfs-password"]&&s.obfs=="salamander"&&(a.obfs="salamander",a.obfs_password=s["obfs-password"]);else if(a.type==="tuic")a={type:"tuic",name:a.name,server:a.server,port:a.port,uuid:a.uuid,password:a.password,next_hop:a.next_hop,sni:a.sni,alpn:Array.isArray(a.alpn)?a.alpn:[a.alpn||"h3"],skip_tls_verify:a["skip-cert-verify"],port_hopping:a.ports,port_hopping_interval:a["hop-interval"]};else if(a.type==="trojan")a.network==="ws"&&(a.websocket={path:a["ws-opts"]?.path,host:a["ws-opts"]?.headers?.Host}),a={type:"trojan",name:a.name,server:a.server,port:a.port,password:a.password,tfo:a.tfo||a["fast-open"],udp_relay:a.udp||a.udp_relay||a.udp_relay,next_hop:a.next_hop,sni:a.sni,skip_tls_verify:a["skip-cert-verify"],websocket:a.websocket};else if(a.type==="vmess"){let l=a.cipher;l&&!["auto","none","zero","aes-128-gcm","chacha20-poly1305"].includes(l)&&(l="auto"),a.network==="ws"?a.transport={[a.tls?"wss":"ws"]:{path:a["ws-opts"]?.path,headers:{Host:a["ws-opts"]?.headers?.Host},sni:a.tls?a.sni:void 0,skip_tls_verify:a.tls?a["skip-cert-verify"]:void 0}}:a.network==="http"?a.transport={http1:{method:a["http-opts"]?.method,path:Array.isArray(a["http-opts"]?.path)?a["http-opts"]?.path[0]:a["http-opts"]?.path,headers:{Host:Array.isArray(a["http-opts"]?.headers?.Host)?a["http-opts"]?.headers?.Host[0]:a["http-opts"]?.headers?.Host},skip_tls_verify:a["skip-cert-verify"]}}:a.network==="h2"?a.transport={http2:{method:a["h2-opts"]?.method,path:Array.isArray(a["h2-opts"]?.path)?a["h2-opts"]?.path[0]:a["h2-opts"]?.path,headers:{Host:Array.isArray(a["h2-opts"]?.headers?.Host)?a["h2-opts"]?.headers?.Host[0]:a["h2-opts"]?.headers?.Host},skip_tls_verify:a["skip-cert-verify"]}}:(a.network==="tcp"||!a.network)&&a.tls&&(a.transport={tls:{sni:a.tls?a.sni:void 0,skip_tls_verify:a.tls?a["skip-cert-verify"]:void 0}}),a={type:"vmess",name:a.name,server:a.server,port:a.port,user_id:a.uuid,security:l,tfo:a.tfo||a["fast-open"],legacy:a.legacy,udp_relay:a.udp||a.udp_relay||a.udp_relay,next_hop:a.next_hop,transport:a.transport}}else a.type==="vless"&&(a.network==="ws"?a.transport={[a.tls?"wss":"ws"]:{path:a["ws-opts"]?.path,headers:{Host:a["ws-opts"]?.headers?.Host},sni:a.tls?a.sni:void 0,skip_tls_verify:a.tls?a["skip-cert-verify"]:void 0}}:a.network==="http"?a.transport={http:{method:a["http-opts"]?.method,path:Array.isArray(a["http-opts"]?.path)?a["http-opts"]?.path[0]:a["http-opts"]?.path,headers:{Host:Array.isArray(a["http-opts"]?.headers?.Host)?a["http-opts"]?.headers?.Host[0]:a["http-opts"]?.headers?.Host},skip_tls_verify:a["skip-cert-verify"]}}:(a.network==="tcp"||!a.network)&&(a.transport={[a.tls?"tls":"tcp"]:{sni:a.tls?a.sni:void 0,skip_tls_verify:a.tls?a["skip-cert-verify"]:void 0}}),a={type:"vless",name:a.name,server:a.server,port:a.port,user_id:a.uuid,security:a.cipher,tfo:a.tfo||a["fast-open"],legacy:a.legacy,udp_relay:a.udp||a.udp_relay||a.udp_relay,next_hop:a.next_hop,transport:a.transport});if(["http","socks5","ss","trojan","vless","vmess"].includes(s.type)){if(ae(s,"shadow-tls-password")){if(s["shadow-tls-version"]!=3)throw new Error(`shadow-tls version ${s["shadow-tls-version"]} is not supported`);a.shadow_tls={password:s["shadow-tls-password"],sni:s["shadow-tls-sni"]}}else if(["shadow-tls"].includes(s.plugin)&&s["plugin-opts"]){if(s["plugin-opts"].version!=3)throw new Error(`shadow-tls version ${s["plugin-opts"].version} is not supported`);a.shadow_tls={password:s["plugin-opts"].password,sni:s["plugin-opts"].host}}}if(delete a.subName,delete a.collectionName,delete a.id,delete a.resolved,delete a["no-resolve"],n!=="internal")for(let l in a)(a[l]==null||/^_/i.test(l))&&delete a[l];return{[a.type]:{...a,type:void 0,prev_hop:o}}});return n==="internal"?i:`proxies: `+i.map(a=>" - "+JSON.stringify(a)+` `).join("")}}}function oA(){return{type:"ALL",produce:(r,n)=>n==="internal"?r:JSON.stringify(r,null,2)}}var ch={qx:Vc(),QX:Vc(),QuantumultX:Vc(),surge:So(),Surge:So(),SurgeMac:v0(),Loon:A0(),Clash:E0(),meta:xn(),clashmeta:xn(),"clash.meta":xn(),"Clash.Meta":xn(),ClashMeta:xn(),mihomo:xn(),Mihomo:xn(),uri:bo(),URI:bo(),v2:qc(),v2ray:qc(),V2Ray:qc(),json:oA(),JSON:oA(),stash:sh(),Stash:sh(),shadowrocket:Kc(),Shadowrocket:Kc(),ShadowRocket:Kc(),surfboard:ah(),Surfboard:ah(),singbox:uh(),"sing-box":uh(),egern:oh(),Egern:oh()};var dw=ln(Zc()),d7=String.raw` // global initializer {{ function $set(obj, path, value) { if (Object(obj) !== obj) return obj; if (!Array.isArray(path)) path = path.toString().match(/[^.[\]]+/g) || []; path .slice(0, -1) .reduce((a, c, i) => (Object(a[c]) === a[c] ? a[c] : (a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1] ? [] : {})), obj)[ path[path.length - 1] ] = value; return obj; } }} // per-parser initializer { const proxy = {}; const obfs = {}; const $ = {}; function handleWebsocket() { if (obfs.type === "ws") { proxy.network = "ws"; $set(proxy, "ws-opts.path", obfs.path); $set(proxy, "ws-opts.headers", obfs['ws-headers']); if (proxy['ws-opts'] && proxy['ws-opts']['headers'] && proxy['ws-opts']['headers'].Host) { proxy['ws-opts']['headers'].Host = proxy['ws-opts']['headers'].Host.replace(/^"(.*)"$/, '$1') } } } function handleShadowTLS() { if (proxy['shadow-tls-password'] && !proxy['shadow-tls-version']) { proxy['shadow-tls-version'] = 2; } } } start = (shadowsocks/vmess/trojan/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard/hysteria2/ssh/direct) { return proxy; } shadowsocks = tag equals "ss" address (method/passwordk/obfs/obfs_host/obfs_uri/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/udp_port/others)* { proxy.type = "ss"; // handle obfs if (obfs.type == "http" || obfs.type === "tls") { proxy.plugin = "obfs"; $set(proxy, "plugin-opts.mode", obfs.type); $set(proxy, "plugin-opts.host", obfs.host); $set(proxy, "plugin-opts.path", obfs.path); } handleShadowTLS(); } vmess = tag equals "vmess" address (vmess_uuid/vmess_aead/ws/ws_path/ws_headers/method/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls/sni/tls_fingerprint/tls_verification/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "vmess"; proxy.cipher = proxy.cipher || "none"; if (proxy.aead) { proxy.alterId = 0; } else { proxy.alterId = proxy.alterId || 0; } handleWebsocket(); handleShadowTLS(); } trojan = tag equals "trojan" address (passwordk/ws/ws_path/ws_headers/tls/sni/tls_fingerprint/tls_verification/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "trojan"; handleWebsocket(); handleShadowTLS(); } https = tag equals "https" address (username password)? (usernamek passwordk)? (sni/tls_fingerprint/tls_verification/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "http"; proxy.tls = true; handleShadowTLS(); } http = tag equals "http" address (username password)? (usernamek passwordk)? (ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "http"; handleShadowTLS(); } ssh = tag equals "ssh" address (username password)? (usernamek passwordk)? (server_fingerprint/idle_timeout/private_key/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "ssh"; handleShadowTLS(); } snell = tag equals "snell" address (snell_version/snell_psk/obfs/obfs_host/obfs_uri/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/reuse/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "snell"; // handle obfs if (obfs.type == "http" || obfs.type === "tls") { $set(proxy, "obfs-opts.mode", obfs.type); $set(proxy, "obfs-opts.host", obfs.host); $set(proxy, "obfs-opts.path", obfs.path); } handleShadowTLS(); } tuic = tag equals "tuic" address (alpn/token/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/sni/fast_open/tfo/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/others)* { proxy.type = "tuic"; handleShadowTLS(); } tuic_v5 = tag equals "tuic-v5" address (alpn/passwordk/uuidk/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/sni/fast_open/tfo/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/others)* { proxy.type = "tuic"; proxy.version = 5; handleShadowTLS(); } wireguard = tag equals "wireguard" (section_name/no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "wireguard-surge"; handleShadowTLS(); } hysteria2 = tag equals "hysteria2" address (no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/sni/fast_open/tfo/tls_verification/passwordk/tls_fingerprint/download_bandwidth/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/others)* { proxy.type = "hysteria2"; handleShadowTLS(); } socks5 = tag equals "socks5" address (username password)? (usernamek passwordk)? (udp_relay/no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "socks5"; handleShadowTLS(); } socks5_tls = tag equals "socks5-tls" address (username password)? (usernamek passwordk)? (udp_relay/no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/sni/tls_fingerprint/tls_verification/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "socks5"; proxy.tls = true; handleShadowTLS(); } direct = tag equals "direct" (udp_relay/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/block_quic/others)* { proxy.type = "direct"; } address = comma server:server comma port:port { proxy.server = server; proxy.port = port; } server = ip/domain ip = & { const start = peg$currPos; let j = start; while (j < input.length) { if (input[j] === ",") break; j++; } peg$currPos = j; $.ip = input.substring(start, j).trim(); return true; } { return $.ip; } domain = match:[0-9a-zA-z-_.]+ { const domain = match.join(""); if (/(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/.test(domain)) { return domain; } } port = digits:[0-9]+ { const port = parseInt(digits.join(""), 10); if (port >= 0 && port <= 65535) { return port; } } port_hopping_interval = comma "port-hopping-interval" equals match:$[0-9]+ { proxy["hop-interval"] = parseInt(match.trim()); } username = & { let j = peg$currPos; let start, end; let first = true; while (j < input.length) { if (input[j] === ',') { if (first) { start = j + 1; first = false; } else { end = j; break; } } j++; } const match = input.substring(start, end); if (match.indexOf("=") === -1) { $.username = match; peg$currPos = end; return true; } } { proxy.username = $.username; } password = comma match:[^,]+ { proxy.password = match.join(""); } tls = comma "tls" equals flag:bool { proxy.tls = flag; } sni = comma "sni" equals sni:("off"/domain) { if (sni === "off") { proxy["disable-sni"] = true; } else { proxy.sni = sni; } } tls_verification = comma "skip-cert-verify" equals flag:bool { proxy["skip-cert-verify"] = flag; } tls_fingerprint = comma "server-cert-fingerprint-sha256" equals tls_fingerprint:$[^,]+ { proxy["tls-fingerprint"] = tls_fingerprint.trim(); } snell_psk = comma "psk" equals match:[^,]+ { proxy.psk = match.join(""); } snell_version = comma "version" equals match:$[0-9]+ { proxy.version = parseInt(match.trim()); } usernamek = comma "username" equals match:[^,]+ { proxy.username = match.join(""); } passwordk = comma "password" equals match:[^,]+ { proxy.password = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } vmess_uuid = comma "username" equals match:[^,]+ { proxy.uuid = match.join(""); } vmess_aead = comma "vmess-aead" equals flag:bool { proxy.aead = flag; } method = comma "encrypt-method" equals cipher:cipher { proxy.cipher = cipher; } cipher = ("aes-128-cfb"/"aes-128-ctr"/"aes-128-gcm"/"aes-192-cfb"/"aes-192-ctr"/"aes-192-gcm"/"aes-256-cfb"/"aes-256-ctr"/"aes-256-gcm"/"bf-cfb"/"camellia-128-cfb"/"camellia-192-cfb"/"camellia-256-cfb"/"cast5-cfb"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"des-cfb"/"idea-cfb"/"none"/"rc2-cfb"/"rc4-md5"/"rc4"/"salsa20"/"seed-cfb"/"xchacha20-ietf-poly1305"/"2022-blake3-aes-128-gcm"/"2022-blake3-aes-256-gcm"); ws = comma "ws" equals flag:bool { obfs.type = "ws"; } ws_headers = comma "ws-headers" equals headers:$[^,]+ { const pairs = headers.split("|"); const result = {}; pairs.forEach(pair => { const [key, value] = pair.trim().split(":"); result[key.trim()] = value.trim(); }) obfs["ws-headers"] = result; } ws_path = comma "ws-path" equals path:uri { obfs.path = path; } obfs = comma "obfs" equals type:("http"/"tls") { obfs.type = type; } obfs_host = comma "obfs-host" equals host:domain { obfs.host = host; }; obfs_uri = comma "obfs-uri" equals path:uri { obfs.path = path } uri = $[^,]+ udp_relay = comma "udp-relay" equals flag:bool { proxy.udp = flag; } fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; } reuse = comma "reuse" equals flag:bool { proxy.reuse = flag; } ecn = comma "ecn" equals flag:bool { proxy.ecn = flag; } tfo = comma "tfo" equals flag:bool { proxy.tfo = flag; } ip_version = comma "ip-version" equals match:[^,]+ { proxy["ip-version"] = match.join(""); } section_name = comma "section-name" equals match:[^,]+ { proxy["section-name"] = match.join(""); } no_error_alert = comma "no-error-alert" equals match:[^,]+ { proxy["no-error-alert"] = match.join(""); } underlying_proxy = comma "underlying-proxy" equals match:[^,]+ { proxy["underlying-proxy"] = match.join(""); } download_bandwidth = comma "download-bandwidth" equals match:[^,]+ { proxy.down = match.join(""); } test_url = comma "test-url" equals match:[^,]+ { proxy["test-url"] = match.join(""); } test_udp = comma "test-udp" equals match:[^,]+ { proxy["test-udp"] = match.join(""); } test_timeout = comma "test-timeout" equals match:$[0-9]+ { proxy["test-timeout"] = parseInt(match.trim()); } tos = comma "tos" equals match:$[0-9]+ { proxy.tos = parseInt(match.trim()); } interface = comma "interface" equals match:[^,]+ { proxy.interface = match.join(""); } allow_other_interface = comma "allow-other-interface" equals flag:bool { proxy["allow-other-interface"] = flag; } hybrid = comma "hybrid" equals flag:bool { proxy.hybrid = flag; } idle_timeout = comma "idle-timeout" equals match:$[0-9]+ { proxy["idle-timeout"] = parseInt(match.trim()); } private_key = comma "private-key" equals match:[^,]+ { proxy["keystore-private-key"] = match.join("").replace(/^"(.*)"$/, '$1'); } server_fingerprint = comma "server-fingerprint" equals match:[^,]+ { proxy["server-fingerprint"] = match.join("").replace(/^"(.*)"$/, '$1'); } block_quic = comma "block-quic" equals match:[^,]+ { proxy["block-quic"] = match.join(""); } udp_port = comma "udp-port" equals match:$[0-9]+ { proxy["udp-port"] = parseInt(match.trim()); } shadow_tls_version = comma "shadow-tls-version" equals match:$[0-9]+ { proxy["shadow-tls-version"] = parseInt(match.trim()); } shadow_tls_sni = comma "shadow-tls-sni" equals match:[^,]+ { proxy["shadow-tls-sni"] = match.join(""); } shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { proxy["shadow-tls-password"] = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } token = comma "token" equals match:[^,]+ { proxy.token = match.join(""); } alpn = comma "alpn" equals match:[^,]+ { proxy.alpn = match.join(""); } uuidk = comma "uuid" equals match:[^,]+ { proxy.uuid = match.join(""); } tag = match:[^=,]* { proxy.name = match.join("").trim(); } comma = _ "," _ equals = _ "=" _ _ = [ \r\t]* bool = b:("true"/"false") { return b === "true" } others = comma [^=,]+ equals [^=,]+ `,j0;function Ln(){return j0||(j0=dw.generate(d7)),j0}var gw=ln(Zc()),g7=String.raw` // global initializer {{ function $set(obj, path, value) { if (Object(obj) !== obj) return obj; if (!Array.isArray(path)) path = path.toString().match(/[^.[\]]+/g) || []; path .slice(0, -1) .reduce((a, c, i) => (Object(a[c]) === a[c] ? a[c] : (a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1] ? [] : {})), obj)[ path[path.length - 1] ] = value; return obj; } }} // per-parser initializer { const proxy = {}; const obfs = {}; const transport = {}; const $ = {}; function handleTransport() { if (transport.type === "tcp") { /* do nothing */ } else if (transport.type === "ws") { proxy.network = "ws"; $set(proxy, "ws-opts.path", transport.path); $set(proxy, "ws-opts.headers.Host", transport.host); } else if (transport.type === "http") { proxy.network = "http"; $set(proxy, "http-opts.path", transport.path); $set(proxy, "http-opts.headers.Host", transport.host); } } } start = (shadowsocksr/shadowsocks/vmess/vless/trojan/https/http/socks5/hysteria2) { return proxy; } shadowsocksr = tag equals "shadowsocksr"i address method password (ssr_protocol/ssr_protocol_param/obfs_ssr/obfs_ssr_param/obfs_host/obfs_uri/fast_open/udp_relay/udp_port/shadow_tls_version/shadow_tls_sni/shadow_tls_password/ip_mode/others)*{ proxy.type = "ssr"; // handle ssr obfs proxy.obfs = obfs.type; } shadowsocks = tag equals "shadowsocks"i address method password (obfs_typev obfs_hostv)? (obfs_ss/obfs_host/obfs_uri/fast_open/udp_relay/udp_port/shadow_tls_version/shadow_tls_sni/shadow_tls_password/ip_mode/others)* { proxy.type = "ss"; // handle ss obfs if (obfs.type == "http" || obfs.type === "tls") { proxy.plugin = "obfs"; $set(proxy, "plugin-opts.mode", obfs.type); $set(proxy, "plugin-opts.host", obfs.host); $set(proxy, "plugin-opts.path", obfs.path); } } vmess = tag equals "vmess"i address method uuid (transport/transport_host/transport_path/over_tls/tls_host/tls_verification/tls_cert_sha256/tls_pubkey_sha256/vmess_alterId/fast_open/udp_relay/ip_mode/public_key/short_id/others)* { proxy.type = "vmess"; proxy.cipher = proxy.cipher || "none"; proxy.alterId = proxy.alterId || 0; handleTransport(); } vless = tag equals "vless"i address uuid (transport/transport_host/transport_path/over_tls/tls_host/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/flow/public_key/short_id/others)* { proxy.type = "vless"; handleTransport(); } trojan = tag equals "trojan"i address password (transport/transport_host/transport_path/over_tls/tls_host/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/others)* { proxy.type = "trojan"; handleTransport(); } hysteria2 = tag equals "hysteria2"i address password (tls_host/tls_verification/tls_cert_sha256/tls_pubkey_sha256/udp_relay/fast_open/download_bandwidth/salamander_password/ecn/ip_mode/others)* { proxy.type = "hysteria2"; } https = tag equals "https"i address (username password)? (tls_host/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/others)* { proxy.type = "http"; proxy.tls = true; } http = tag equals "http"i address (username password)? (fast_open/udp_relay/ip_mode/others)* { proxy.type = "http"; } socks5 = tag equals "socks5"i address (username password)? (over_tls/tls_host/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/others)* { proxy.type = "socks5"; } address = comma server:server comma port:port { proxy.server = server; proxy.port = port; } server = ip/domain ip = & { const start = peg$currPos; let j = start; while (j < input.length) { if (input[j] === ",") break; j++; } peg$currPos = j; $.ip = input.substring(start, j).trim(); return true; } { return $.ip; } domain = match:[0-9a-zA-z-_.]+ { const domain = match.join(""); if (/(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/.test(domain)) { return domain; } throw new Error("Invalid domain: " + domain); } port = digits:[0-9]+ { const port = parseInt(digits.join(""), 10); if (port >= 0 && port <= 65535) { return port; } throw new Error("Invalid port number: " + port); } method = comma cipher:cipher { proxy.cipher = cipher; } cipher = ("aes-128-cfb"/"aes-128-ctr"/"aes-128-gcm"/"aes-192-cfb"/"aes-192-ctr"/"aes-192-gcm"/"aes-256-cfb"/"aes-256-ctr"/"aes-256-gcm"/"auto"/"bf-cfb"/"camellia-128-cfb"/"camellia-192-cfb"/"camellia-256-cfb"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"none"/"rc4-md5"/"rc4"/"salsa20"/"xchacha20-ietf-poly1305"/"2022-blake3-aes-128-gcm"/"2022-blake3-aes-256-gcm"); username = & { let j = peg$currPos; let start, end; let first = true; while (j < input.length) { if (input[j] === ',') { if (first) { start = j + 1; first = false; } else { end = j; break; } } j++; } const match = input.substring(start, end); if (match.indexOf("=") === -1) { $.username = match; peg$currPos = end; return true; } } { proxy.username = $.username; } password = comma '"' match:[^"]* '"' { proxy.password = match.join(""); } uuid = comma '"' match:[^"]+ '"' { proxy.uuid = match.join(""); } obfs_typev = comma type:("http"/"tls") { obfs.type = type; } obfs_hostv = comma match:[^,]+ { obfs.host = match.join(""); } obfs_ss = comma "obfs-name" equals type:("http"/"tls") { obfs.type = type; } obfs_ssr = comma "obfs" equals type:("plain"/"http_simple"/"http_post"/"random_head"/"tls1.2_ticket_auth"/"tls1.2_ticket_fastauth") { obfs.type = type; } obfs_ssr_param = comma "obfs-param" equals match:$[^,]+ { proxy["obfs-param"] = match; } obfs_host = comma "obfs-host" equals host:domain { obfs.host = host; } obfs_uri = comma "obfs-uri" equals uri:uri { obfs.path = uri; } uri = $[^,]+ transport = comma "transport" equals type:("tcp"/"ws"/"http") { transport.type = type; } transport_host = comma "host" equals host:domain { transport.host = host; } transport_path = comma "path" equals path:uri { transport.path = path; } ssr_protocol = comma "protocol" equals protocol:("origin"/"auth_sha1_v4"/"auth_aes128_md5"/"auth_aes128_sha1"/"auth_chain_a"/"auth_chain_b") { proxy.protocol = protocol; } ssr_protocol_param = comma "protocol-param" equals param:$[^=,]+ { proxy["protocol-param"] = param; } vmess_alterId = comma "alterId" equals alterId:$[0-9]+ { proxy.alterId = parseInt(alterId); } udp_port = comma "udp-port" equals match:$[0-9]+ { proxy["udp-port"] = parseInt(match.trim()); } shadow_tls_version = comma "shadow-tls-version" equals match:$[0-9]+ { proxy["shadow-tls-version"] = parseInt(match.trim()); } shadow_tls_sni = comma "shadow-tls-sni" equals match:[^,]+ { proxy["shadow-tls-sni"] = match.join(""); } shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { proxy["shadow-tls-password"] = match.join(""); } over_tls = comma "over-tls" equals flag:bool { proxy.tls = flag; } tls_host = comma sni:("tls-name"/"sni") equals host:domain { proxy.sni = host; } tls_verification = comma "skip-cert-verify" equals flag:bool { proxy["skip-cert-verify"] = flag; } tls_cert_sha256 = comma "tls-cert-sha256" equals match:[^,]+ { proxy["tls-fingerprint"] = match.join("").replace(/^"(.*)"$/, '$1'); } tls_pubkey_sha256 = comma "tls-pubkey-sha256" equals match:[^,]+ { proxy["tls-pubkey-sha256"] = match.join("").replace(/^"(.*)"$/, '$1'); } flow = comma "flow" equals match:[^,]+ { proxy["flow"] = match.join("").replace(/^"(.*)"$/, '$1'); } public_key = comma "public-key" equals match:[^,]+ { proxy["reality-opts"] = proxy["reality-opts"] || {}; proxy["reality-opts"]["public-key"] = match.join("").replace(/^"(.*)"$/, '$1'); } short_id = comma "short-id" equals match:[^,]+ { proxy["reality-opts"] = proxy["reality-opts"] || {}; proxy["reality-opts"]["short-id"] = match.join("").replace(/^"(.*)"$/, '$1'); } fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; } udp_relay = comma "udp" equals flag:bool { proxy.udp = flag; } ip_mode = comma "ip-mode" equals match:[^,]+ { proxy["ip-version"] = match.join(""); } ecn = comma "ecn" equals flag:bool { proxy.ecn = flag; } download_bandwidth = comma "download-bandwidth" equals match:[^,]+ { proxy.down = match.join(""); } salamander_password = comma "salamander-password" equals match:[^,]+ { proxy['obfs-password'] = match.join(""); proxy.obfs = 'salamander'; } tag = match:[^=,]* { proxy.name = match.join("").trim(); } comma = _ "," _ equals = _ "=" _ _ = [ \r\t]* bool = b:("true"/"false") { return b === "true" } others = comma [^=,]+ equals [^=,]+ `,M0;function Ki(){return M0||(M0=gw.generate(g7)),M0}var mw=ln(Zc()),m7=String.raw` // global initializer {{ function $set(obj, path, value) { if (Object(obj) !== obj) return obj; if (!Array.isArray(path)) path = path.toString().match(/[^.[\]]+/g) || []; path .slice(0, -1) .reduce((a, c, i) => (Object(a[c]) === a[c] ? a[c] : (a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1] ? [] : {})), obj)[ path[path.length - 1] ] = value; return obj; } }} // per-parse initializer { const proxy = {}; const obfs = {}; const $ = {}; function handleObfs() { if (obfs.type === "ws" || obfs.type === "wss") { proxy.network = "ws"; if (obfs.type === 'wss') { proxy.tls = true; } $set(proxy, "ws-opts.path", obfs.path); $set(proxy, "ws-opts.headers.Host", obfs.host); } else if (obfs.type === "over-tls") { proxy.tls = true; } else if (obfs.type === "http") { proxy.network = "http"; $set(proxy, "http-opts.path", obfs.path); $set(proxy, "http-opts.headers.Host", obfs.host); } } } start = (trojan/shadowsocks/vmess/vless/http/socks5) { return proxy } trojan = "trojan" equals address (password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/obfs/obfs_host/obfs_uri/tag/udp_relay/udp_over_tcp/fast_open/server_check_url/others)* { proxy.type = "trojan"; handleObfs(); } shadowsocks = "shadowsocks" equals address (password/method/obfs_ssr/obfs_ss/obfs_host/obfs_uri/ssr_protocol/ssr_protocol_param/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/udp_relay/udp_over_tcp/fast_open/tag/server_check_url/others)* { if (proxy.protocol || proxy.type === "ssr") { proxy.type = "ssr"; if (!proxy.protocol) { proxy.protocol = "origin"; } // handle ssr obfs if (obfs.host) proxy["obfs-param"] = obfs.host; if (obfs.type) proxy.obfs = obfs.type; } else { proxy.type = "ss"; // handle ss obfs if (obfs.type == "http" || obfs.type === "tls") { proxy.plugin = "obfs"; $set(proxy, "plugin-opts", { mode: obfs.type }); } else if (obfs.type === "ws" || obfs.type === "wss") { proxy.plugin = "v2ray-plugin"; $set(proxy, "plugin-opts.mode", "websocket"); if (obfs.type === "wss") { $set(proxy, "plugin-opts.tls", true); } } else if (obfs.type === 'over-tls') { throw new Error('ss over-tls is not supported'); } if (obfs.type) { $set(proxy, "plugin-opts.host", obfs.host); $set(proxy, "plugin-opts.path", obfs.path); } } } vmess = "vmess" equals address (uuid/method/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/obfs/obfs_host/obfs_uri/udp_relay/udp_over_tcp/fast_open/aead/server_check_url/others)* { proxy.type = "vmess"; proxy.cipher = proxy.cipher || "none"; if (proxy.aead) { proxy.alterId = 0; } else { proxy.alterId = proxy.alterId || 0; } handleObfs(); } vless = "vless" equals address (uuid/method/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/obfs/obfs_host/obfs_uri/udp_relay/udp_over_tcp/fast_open/aead/server_check_url/others)* { proxy.type = "vless"; proxy.cipher = proxy.cipher || "none"; handleObfs(); } http = "http" equals address (username/password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/fast_open/udp_relay/udp_over_tcp/server_check_url/others)*{ proxy.type = "http"; } socks5 = "socks5" equals address (username/password/password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/fast_open/udp_relay/udp_over_tcp/server_check_url/others)* { proxy.type = "socks5"; } address = server:server ":" port:port { proxy.server = server; proxy.port = port; } server = ip/domain domain = match:[0-9a-zA-z-_.]+ { const domain = match.join(""); if (/(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/.test(domain)) { return domain; } } ip = & { const start = peg$currPos; let end; let j = start; while (j < input.length) { if (input[j] === ",") break; if (input[j] === ":") end = j; j++; } peg$currPos = end || j; $.ip = input.substring(start, end).trim(); return true; } { return $.ip; } port = digits:[0-9]+ { const port = parseInt(digits.join(""), 10); if (port >= 0 && port <= 65535) { return port; } } username = comma "username" equals username:[^,]+ { proxy.username = username.join("").trim(); } password = comma "password" equals password:[^,]+ { proxy.password = password.join("").trim(); } uuid = comma "password" equals uuid:[^,]+ { proxy.uuid = uuid.join("").trim(); } method = comma "method" equals cipher:cipher { proxy.cipher = cipher; }; cipher = ("aes-128-cfb"/"aes-128-ctr"/"aes-128-gcm"/"aes-192-cfb"/"aes-192-ctr"/"aes-192-gcm"/"aes-256-cfb"/"aes-256-ctr"/"aes-256-gcm"/"bf-cfb"/"cast5-cfb"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"des-cfb"/"none"/"rc2-cfb"/"rc4-md5-6"/"rc4-md5"/"salsa20"/"xchacha20-ietf-poly1305"/"2022-blake3-aes-128-gcm"/"2022-blake3-aes-256-gcm"); aead = comma "aead" equals flag:bool { proxy.aead = flag; } udp_relay = comma "udp-relay" equals flag:bool { proxy.udp = flag; } udp_over_tcp = comma "udp-over-tcp" equals flag:bool { throw new Error("UDP over TCP is not supported"); } fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; } over_tls = comma "over-tls" equals flag:bool { proxy.tls = flag; } tls_host = comma "tls-host" equals sni:domain { proxy.sni = sni; } tls_verification = comma "tls-verification" equals flag:bool { proxy["skip-cert-verify"] = !flag; } tls_fingerprint = comma "tls-cert-sha256" equals tls_fingerprint:$[^,]+ { proxy["tls-fingerprint"] = tls_fingerprint.trim(); } tls_pubkey_sha256 = comma "tls-pubkey-sha256" equals param:$[^=,]+ { proxy["tls-pubkey-sha256"] = param; } tls_alpn = comma "tls-alpn" equals param:$[^=,]+ { proxy["tls-alpn"] = param; } tls_no_session_ticket = comma "tls-no-session-ticket" equals flag:bool { proxy["tls-no-session-ticket"] = flag; } tls_no_session_reuse = comma "tls-no-session-reuse" equals flag:bool { proxy["tls-no-session-reuse"] = flag; } obfs_ss = comma "obfs" equals type:("http"/"tls"/"wss"/"ws"/"over-tls") { obfs.type = type; return type; } obfs_ssr = comma "obfs" equals type:("plain"/"http_simple"/"http_post"/"random_head"/"tls1.2_ticket_auth"/"tls1.2_ticket_fastauth") { proxy.type = "ssr"; obfs.type = type; return type; } obfs = comma "obfs" equals type:("wss"/"ws"/"over-tls"/"http") { obfs.type = type; return type; }; obfs_host = comma "obfs-host" equals host:domain { obfs.host = host; } obfs_uri = comma "obfs-uri" equals uri:uri { obfs.path = uri; } ssr_protocol = comma "ssr-protocol" equals protocol:("origin"/"auth_sha1_v4"/"auth_aes128_md5"/"auth_aes128_sha1"/"auth_chain_a"/"auth_chain_b") { proxy.protocol = protocol; return protocol; } ssr_protocol_param = comma "ssr-protocol-param" equals param:$[^=,]+ { proxy["protocol-param"] = param; } server_check_url = comma "server_check_url" equals param:$[^=,]+ { proxy["test-url"] = param; } uri = $[^,]+ tag = comma "tag" equals tag:[^=,]+ { proxy.name = tag.join(""); } others = comma [^=,]+ equals [^=,]+ comma = _ "," _ equals = _ "=" _ _ = [ \r\t]* bool = b:("true"/"false") { return b === "true" } `,q0;function xs(){return q0||(q0=mw.generate(m7)),q0}var vw=ln(Zc()),v7=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); } `,V0;function K0(){return V0||(V0=vw.generate(v7)),V0}function Ew(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 E7(){return{name:"URI PROXY Parser",test:n=>/^(socks5\+tls|socks5|http|https):\/\//.test(n),parse:n=>{let[i,a,s,o,l,h,d,E,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 G.error(`port is not present in line: ${n}`),new Error(`port is not present in line: ${n}`);G.info(`port is not present in line: ${n}, set to ${d}`)}return{name:p!=null?decodeURIComponent(p):`${a} ${h}:${d}`,type:a,tls:!!s,server:h,port:d,username:o!=null?decodeURIComponent(o):void 0,password:l!=null?decodeURIComponent(l):void 0}}}}function A7(){return{name:"URI SOCKS Parser",test:n=>/^socks:\/\//.test(n),parse:n=>{let[i,a,s,o,l,h,d]=n.match(/^(socks)?:\/\/(?:(.*)@)?(.*?)(?::(\d+?))?(\?.*?)?(?:#(.*?))?$/);if(l)l=parseInt(l,10);else throw G.error(`port is not present in line: ${n}`),new Error(`port is not present in line: ${n}`);let E,p;if(s){let w=Et.decode(decodeURIComponent(s)).split(":");E=w[0],p=w[1]}return{name:d!=null?decodeURIComponent(d):`${a} ${o}:${l}`,type:"socks5",server:o,port:l,username:E,password:p}}}}function w7(){return{name:"URI SS Parser",test:n=>/^ss:\/\//.test(n),parse:n=>{let i=n.split("ss://")[1],a={name:decodeURIComponent(n.split("#")[1]),type:"ss"};i=i.split("#")[0];let s=i.match(/@([^/]*)(\/|$)/),o=decodeURIComponent(i.split("@")[0]),l;o?.startsWith("2022-blake3-")?l=o:l=Et.decode(o);let h="";if(s)i.includes("?")&&(h=i.match(/(\?.*)$/)[1]);else{if(i.includes("?")){let g=i.match(/^(.*)(\?.*)$/);i=g[1],h=g[2]}if(i=Et.decode(i),h){if(/(&|\?)v2ray-plugin=/.test(h)){let y=h.match(/(&|\?)v2ray-plugin=(.*?)(&|$)/)[2];y&&(a.plugin="v2ray-plugin",a["plugin-opts"]=JSON.parse(Et.decode(y)))}i=`${i}${h}`}l=i.match(/(^.*)@/)?.[1],s=i.match(/@([^/@]*)(\/|$)/)}let d=s[1],E=d.lastIndexOf(":");a.server=d.substring(0,E),a.port=`${d.substring(E+1)}`.match(/\d+/)?.[0];let p=l.match(/(^.*?):(.*$)/);a.cipher=p?.[1],a.password=p?.[2];let f=i.match(/[?&]plugin=([^&]+)/),w=i.match(/[?&]shadow-tls=([^&]+)/);if(f){let g=("plugin="+decodeURIComponent(f[1])).split(";"),y={};for(let A of g){let[S,_]=A.split("=");S&&(y[S]=_||!0)}switch(y.plugin){case"obfs-local":case"simple-obfs":a.plugin="obfs",a["plugin-opts"]={mode:y.obfs,host:Lt(y["obfs-host"])};break;case"v2ray-plugin":a.plugin="v2ray-plugin",a["plugin-opts"]={mode:"websocket",host:Lt(y["obfs-host"]),path:Lt(y.path),tls:eu(y.tls)};break;case"shadow-tls":{a.plugin="shadow-tls";let A=Lt(y.version);a["plugin-opts"]={host:Lt(y.host),password:Lt(y.password),version:A?parseInt(A,10):void 0};break}default:throw new Error(`Unsupported plugin option: ${y.plugin}`)}}if(w){let g=JSON.parse(Et.decode(w[1])),y=Lt(g.version),A=Lt(g.address),S=Lt(g.port);a.plugin="shadow-tls",a["plugin-opts"]={host:Lt(g.host),password:Lt(g.password),version:y?parseInt(y,10):void 0},A&&(a.server=A),S&&(a.port=parseInt(S,10))}return/(&|\?)uot=(1|true)/i.test(h)&&(a["udp-over-tcp"]=!0),/(&|\?)tfo=(1|true)/i.test(h)&&(a.tfo=!0),a}}}function y7(){return{name:"URI SSR Parser",test:n=>/^ssr:\/\//.test(n),parse:n=>{n=Et.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(":")),o=a.substring(a.lastIndexOf(":")+1),l=n.substring(i+1).split("/?")[0].split(":"),h={type:"ssr",server:s,port:o,protocol:l[0],cipher:l[1],obfs:l[2],password:Et.decode(l[3])},d={};if(n=n.split("/?")[1].split("&"),n.length>1)for(let E of n){let[p,f]=E.split("=");f=f.trim(),f.length>0&&f!=="(null)"&&(d[p]=f)}return h={...h,name:d.remarks?Et.decode(d.remarks):h.server,"protocol-param":Lt(Et.decode(d.protoparam||"").replace(/\s/g,"")),"obfs-param":Lt(Et.decode(d.obfsparam||"").replace(/\s/g,""))},h}}}function S7(){return{name:"URI VMess Parser",test:n=>/^vmess:\/\//.test(n),parse:n=>{n=n.split("vmess://")[1];let i=Et.decode(n.replace(/\?.*?$/,""));if(/=\s*vmess/.test(i)){let a=i.split(",").map(l=>l.trim()),s={};for(let l of a)if(l.indexOf("=")!==-1){let[h,d]=l.split("=");s[h.trim()]=d.trim()}let o={name:a[0].split("=")[0].trim(),type:"vmess",server:a[1],port:a[2],cipher:Lt(a[3],"auto"),uuid:a[4].match(/^"(.*)"$/)[1],tls:s.obfs==="wss",udp:eu(s["udp-relay"]),tfo:eu(s["fast-open"]),"skip-cert-verify":ho(s["tls-verification"])?!s["tls-verification"]:void 0};if(ho(s.obfs))if(s.obfs==="ws"||s.obfs==="wss"){o.network="ws",o["ws-opts"].path=(Lt(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]),Ti(l)&&(o["ws-opts"].headers={Host:l})}else throw new Error(`Unsupported obfs: ${s.obfs}`);return o}else{let a={};try{a=JSON.parse(i)}catch{let[E,p,f]=/(^[^?]+?)\/?\?(.*)$/.exec(n);i=Et.decode(p);for(let _ of f.split("&")){let[I,D]=_.split("="),H=D;H=decodeURIComponent(D),H.indexOf(",")===-1?a[I]=H:a[I]=H.split(",")}let[w,g,y,A,S]=/(^[^:]+?):([^:]+?)@(.*):(\d+)$/.exec(i);a.scy=g,a.id=y,a.port=S,a.add=A}let s=a.add,o=parseInt(eu(a.port),10),l={name:a.ps??a.remarks??a.remark??`VMess ${s}:${o}`,type:"vmess",server:s,port:o,cipher:eu(a.scy,"auto"),uuid:a.id,alterId:parseInt(eu(a.aid??a.alterId,0),10),tls:["tls",!0,1,"1"].includes(a.tls),"skip-cert-verify":ho(a.verify_cert)?!a.verify_cert:void 0};!l["skip-cert-verify"]&&ho(a.allowInsecure)&&(l["skip-cert-verify"]=/(TRUE)|1/i.test(a.allowInsecure)),l.tls&&a.sni&&a.sni!==""&&(l.sni=a.sni);let h=!1;if(a.net==="ws"||a.obfs==="websocket"?l.network="ws":["http"].includes(a.net)||["http"].includes(a.obfs)||["http"].includes(a.type)?l.network="http":["grpc"].includes(a.net)?l.network="grpc":a.net==="httpupgrade"||l.network==="httpupgrade"?(l.network="ws",h=!0):(a.net==="h2"||l.network==="h2")&&(l.network="h2"),l.network){let d=a.host??a.obfsParam;try{let f=JSON.parse(d)?.Host;f&&(d=f)}catch{}let E=a.path;if(["ws"].includes(l.network)&&(E=E||"/"),l.network==="http"&&(d&&(d=d.split(",").map(p=>p.trim()),d=Array.isArray(d)?d[0]:d),E?E=Array.isArray(E)?E[0]:E:E="/"),E||d)if(["grpc"].includes(l.network))l[`${l.network}-opts`]={"grpc-service-name":Lt(E),"_grpc-type":Lt(a.type),"_grpc-authority":Lt(a.authority)};else{let p={path:Lt(E),headers:{Host:Lt(d)}};h&&(p["v2ray-http-upgrade"]=!0,p["v2ray-http-upgrade-fast-open"]=!0),l[`${l.network}-opts`]=p}else delete l.network}return l}}}}function b7(){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,A,S]=/^(.*?)(\?.*?$)/.exec(n);n=`${Et.decode(A)}${S}`,a=/^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(n),i=!0}let[s,o,l,h,d,E="",p]=a;i&&(o=o.replace(/^.*?:/g,"")),h=parseInt(`${h}`,10),o=decodeURIComponent(o),p!=null&&(p=decodeURIComponent(p));let f={type:"vless",name:p,server:l,port:h,uuid:o},w={};for(let y of E.split("&")){let[A,S]=y.split("="),_=S;_=decodeURIComponent(S),w[A]=_}if(f.name=p??w.remarks??w.remark??`VLESS ${l}:${h}`,f.tls=w.security&&w.security!=="none",i&&/TRUE|1/i.test(w.tls)&&(f.tls=!0,w.security=w.security??"reality"),f.sni=w.sni||w.peer,f.flow=w.flow,!f.flow&&i&&w.xtls){let y=[void 0,"xtls-rprx-direct","xtls-rprx-vision"][w.xtls];y&&(f.flow=y)}if(f["client-fingerprint"]=w.fp,f.alpn=w.alpn?w.alpn.split(","):void 0,f["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&&(f[`${w.security}-opts`]=y)}let g=!1;if(f.network=w.type,f.network==="tcp"&&w.headerType==="http"?f.network="http":f.network==="httpupgrade"&&(f.network="ws",g=!0),!f.network&&i&&w.obfs&&(f.network=w.obfs,["none"].includes(f.network)&&(f.network="tcp")),["websocket"].includes(f.network)&&(f.network="ws"),f.network&&!["tcp","none"].includes(f.network)){let y={},A=w.host??w.obfsParam;if(A)if(w.obfsParam)try{let S=JSON.parse(A);y.headers=S}catch{y.headers={Host:A}}else y.headers={Host:A};w.serviceName?(y[`${f.network}-service-name`]=w.serviceName,["grpc"].includes(f.network)&&w.authority&&(y["_grpc-authority"]=w.authority)):i&&w.path&&(["ws","http","h2"].includes(f.network)||(y[`${f.network}-service-name`]=w.path,delete w.path)),w.path&&(y.path=w.path),["grpc"].includes(f.network)&&(y["_grpc-type"]=w.mode||"gun"),g&&(y["v2ray-http-upgrade"]=!0,y["v2ray-http-upgrade-fast-open"]=!0),Object.keys(y).length>0&&(f[`${f.network}-opts`]=y),f.network==="kcp"&&(w.seed&&(f.seed=w.seed),f.headerType=w.headerType||"none"),w.mode&&(f._mode=w.mode),w.extra&&(f._extra=w.extra)}return f}}}function C7(){return{name:"URI AnyTLS Parser",test:n=>/^anytls:\/\//.test(n),parse:n=>{n=n.split(/anytls:\/\//)[1];let[i,a,s,o,l="",h]=/^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(n);a=decodeURIComponent(a),o=parseInt(`${o}`,10),isNaN(o)&&(o=443),a=decodeURIComponent(a),h!=null&&(h=decodeURIComponent(h)),h=h??`AnyTLS ${s}:${o}`;let d={type:"anytls",name:h,server:s,port:o,password:a};for(let E of l.split("&")){let[p,f]=E.split("=");p=p.replace(/_/g,"-"),f=decodeURIComponent(f),["alpn"].includes(p)?d[p]=f?f.split(","):void 0:["insecure"].includes(p)?d["skip-cert-verify"]=/(TRUE)|1/i.test(f):d[p]=f}return d}}}function F7(){return{name:"URI Hysteria2 Parser",test:n=>/^(hysteria2|hy2):\/\//.test(n),parse:n=>{n=n.split(/(hysteria2|hy2):\/\//)[2];let i,[a,s,o,l,h,d,E,p,f,w,g="",y]=/^(.*?)@(.*?)(:((\d+(-\d+)?)([,;]\d+(-\d+)?)*))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);/^\d+$/.test(h)?(h=parseInt(`${h}`,10),isNaN(h)&&(h=443)):h?(i=h,h=xc(i)):h=443,s=decodeURIComponent(s),y!=null&&(y=decodeURIComponent(y)),y=y??`Hysteria2 ${o}:${h}`;let A={type:"hysteria2",name:y,server:o,port:h,ports:i,password:s},S={};for(let D of g.split("&")){let[H,V]=D.split("="),F=V;F=decodeURIComponent(V),S[H]=F}A.sni=S.sni,!A.sni&&S.peer&&(A.sni=S.peer),S.obfs&&S.obfs!=="none"&&(A.obfs=S.obfs),S.mport&&(A.ports=S.mport),A["obfs-password"]=S["obfs-password"],A["skip-cert-verify"]=/(TRUE)|1/i.test(S.insecure),A.tfo=/(TRUE)|1/i.test(S.fastopen),A["tls-fingerprint"]=S.pinSHA256;let _=S["hop-interval"]||S.hop_interval;/^\d+$/.test(_)&&(A["hop-interval"]=parseInt(`${_}`,10));let I=S.keepalive;return/^\d+$/.test(I)&&(A.keepalive=parseInt(`${I}`,10)),A}}}function _7(){return{name:"URI Hysteria Parser",test:n=>/^(hysteria|hy):\/\//.test(n),parse:n=>{n=n.split(/(hysteria|hy):\/\//)[2];let[i,a,s,o,l,h="",d]=/^(.*?)(:(\d+))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);o=parseInt(`${o}`,10),isNaN(o)&&(o=443),d!=null&&(d=decodeURIComponent(d)),d=d??`Hysteria ${a}:${o}`;let E={type:"hysteria",name:d,server:a,port:o},p={};for(let f of h.split("&")){let[w,g]=f.split("=");w=w.replace(/_/,"-"),g=decodeURIComponent(g),["alpn"].includes(w)?E[w]=g?g.split(","):void 0:["insecure"].includes(w)?E["skip-cert-verify"]=/(TRUE)|1/i.test(g):["auth"].includes(w)?E["auth-str"]=g:["mport"].includes(w)?E.ports=g:["obfsParam"].includes(w)?E.obfs=g:["upmbps"].includes(w)?E.up=g:["downmbps"].includes(w)?E.down=g:["obfs"].includes(w)?E._obfs=g||"":["fast-open","peer"].includes(w)?p[w]=g:E[w]=g}return!E.sni&&p.peer&&(E.sni=p.peer),!E["fast-open"]&&p.fastopen&&(E["fast-open"]=!0),E.protocol||(E.protocol="udp"),E}}}function I7(){return{name:"URI TUIC Parser",test:n=>/^tuic:\/\//.test(n),parse:n=>{n=n.split(/tuic:\/\//)[1];let[i,a,s,o,l="",h]=/^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(n);a=decodeURIComponent(a);let[d,...E]=a.split(":"),p=E.join(":");o=parseInt(`${o}`,10),isNaN(o)&&(o=443),p=decodeURIComponent(p),h!=null&&(h=decodeURIComponent(h)),h=h??`TUIC ${s}:${o}`;let f={type:"tuic",name:h,server:s,port:o,password:p,uuid:d};for(let w of l.split("&")){let[g,y]=w.split("=");g=g.replace(/_/g,"-"),y=decodeURIComponent(y),["alpn"].includes(g)?f[g]=y?y.split(","):void 0:["allow-insecure"].includes(g)?f["skip-cert-verify"]=/(TRUE)|1/i.test(y):["fast-open"].includes(g)?f.tfo=!0:["disable-sni","reduce-rtt"].includes(g)?f[g]=/(TRUE)|1/i.test(y):f[g]=y}return f}}}function D7(){return{name:"URI WireGuard Parser",test:n=>/^(wireguard|wg):\/\//.test(n),parse:n=>{n=n.split(/(wireguard|wg):\/\//)[2];let[i,a,s,o,l,h,d,E="",p]=/^((.*?)@)?(.*?)(:(\d+))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);h=parseInt(`${h}`,10),isNaN(h)&&(h=51820),s=decodeURIComponent(s),p!=null&&(p=decodeURIComponent(p)),p=p??`WireGuard ${o}:${h}`;let f={type:"wireguard",name:p,server:o,port:h,"private-key":s,udp:!0};for(let w of E.split("&")){let[g,y]=w.split("=");if(g=g.replace(/_/,"-"),y=decodeURIComponent(y),["reserved"].includes(g)){let A=y.split(",").map(S=>parseInt(S.trim(),10)).filter(S=>Number.isInteger(S));A.length===3&&(f[g]=A)}else if(["address","ip"].includes(g))y.split(",").map(A=>{let S=A.trim().replace(/\/\d+$/,"").replace(/^\[/,"").replace(/\]$/,"");or(S)?f.ip=S:Jt(S)&&(f.ipv6=S)});else if(["mtu"].includes(g)){let A=parseInt(y.trim(),10);Number.isInteger(A)&&(f[g]=A)}else/publickey/i.test(g)?f["public-key"]=y:/privatekey/i.test(g)?f["private-key"]=y:["udp"].includes(g)?f[g]=/(TRUE)|1/i.test(y):["flag"].includes(g)||(f[g]=y)}return f}}}function B7(){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,o]=n.split(/#(.+)/,2),h=K0().parse(s);if(Ti(o))try{h.name=decodeURIComponent(o)}catch(d){console.log(d)}return h}}}function $7(){return{name:"Clash Parser",test:n=>{try{JSON.parse(n)}catch{return!1}return!0},parse:n=>{let i=JSON.parse(n);if(!["anytls","mieru","juicity","ss","ssr","vmess","socks5","http","snell","trojan","tuic","vless","hysteria","hysteria2","wireguard","ssh","direct"].includes(i.type))throw new Error(`Clash does not support proxy with type: ${i.type}`);return["vmess","vless"].includes(i.type)&&(i.sni=i.servername,delete i.servername),i["server-cert-fingerprint"]&&(i["tls-fingerprint"]=i["server-cert-fingerprint"]),i.fingerprint&&(i["tls-fingerprint"]=i.fingerprint),i["dialer-proxy"]&&(i["underlying-proxy"]=i["dialer-proxy"]),i["benchmark-url"]&&(i["test-url"]=i["benchmark-url"]),i["benchmark-timeout"]&&(i["test-timeout"]=i["benchmark-timeout"]),i}}}function P7(){return{name:"QX SS Parser",test:n=>/^shadowsocks\s*=/.test(n.split(",")[0].trim())&&n.indexOf("ssr-protocol")===-1,parse:n=>xs().parse(n)}}function R7(){return{name:"QX SSR Parser",test:n=>/^shadowsocks\s*=/.test(n.split(",")[0].trim())&&n.indexOf("ssr-protocol")!==-1,parse:n=>xs().parse(n)}}function T7(){return{name:"QX VMess Parser",test:n=>/^vmess\s*=/.test(n.split(",")[0].trim()),parse:n=>xs().parse(n)}}function x7(){return{name:"QX VLESS Parser",test:n=>/^vless\s*=/.test(n.split(",")[0].trim()),parse:n=>xs().parse(n)}}function O7(){return{name:"QX Trojan Parser",test:n=>/^trojan\s*=/.test(n.split(",")[0].trim()),parse:n=>xs().parse(n)}}function N7(){return{name:"QX HTTP Parser",test:n=>/^http\s*=/.test(n.split(",")[0].trim()),parse:n=>xs().parse(n)}}function k7(){return{name:"QX Socks5 Parser",test:n=>/^socks5\s*=/.test(n.split(",")[0].trim()),parse:n=>xs().parse(n)}}function L7(){return{name:"Loon SS Parser",test:n=>n.split(",")[0].split("=")[1].trim().toLowerCase()==="shadowsocks",parse:n=>Ki().parse(n)}}function U7(){return{name:"Loon SSR Parser",test:n=>n.split(",")[0].split("=")[1].trim().toLowerCase()==="shadowsocksr",parse:n=>Ki().parse(n)}}function H7(){return{name:"Loon VMess Parser",test:n=>/^.*=\s*vmess/i.test(n.split(",")[0])&&n.indexOf("username")===-1,parse:n=>Ki().parse(n)}}function j7(){return{name:"Loon Vless Parser",test:n=>/^.*=\s*vless/i.test(n.split(",")[0]),parse:n=>Ki().parse(n)}}function M7(){return{name:"Loon Trojan Parser",test:n=>/^.*=\s*trojan/i.test(n.split(",")[0]),parse:n=>Ki().parse(n)}}function q7(){return{name:"Loon Hysteria2 Parser",test:n=>/^.*=\s*Hysteria2/i.test(n.split(",")[0]),parse:n=>Ki().parse(n)}}function V7(){return{name:"Loon HTTP Parser",test:n=>/^.*=\s*http/i.test(n.split(",")[0]),parse:n=>Ki().parse(n)}}function K7(){return{name:"Loon SOCKS5 Parser",test:n=>/^.*=\s*socks5/i.test(n.split(",")[0]),parse:n=>Ki().parse(n)}}function G7(){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),o=s?.[2],l=parseInt(s?.[3],10),h=n.match(/(,|^)\s*?mtu\s*?=\s*?"?(\d+?)"?\s*?(,|$)/i)?.[2];h&&(h=parseInt(h,10));let d=n.match(/(,|^)\s*?keepalive\s*?=\s*?"?(\d+?)"?\s*?(,|$)/i)?.[2];d&&(d=parseInt(d,10));let E=a.match(/(,|^)\s*?reserved\s*?=\s*?"?(\[\s*?.+?\s*?\])"?\s*?(,|$)/i)?.[2];E&&(E=JSON.parse(E));let p,f=n.match(/(,|^)\s*?dns\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],w=n.match(/(,|^)\s*?dnsv6\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2];(f||w)&&(p=[],f&&p.push(f),w&&p.push(w));let g=a.match(/(,|^)\s*?allowed-ips\s*?=\s*?"(.+?)"\s*?(,|$)/i)?.[2]?.split(",").map(D=>D.trim()),y=a.match(/(,|^)\s*?preshared-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],A=n.match(/(,|^)\s*?interface-ip\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],S=n.match(/(,|^)\s*?interface-ipv6\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],_=a.match(/(,|^)\s*?public-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],I={type:"wireguard",name:i,server:o,port:l,ip:A,ipv6:S,"private-key":n.match(/(,|^)\s*?private-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],"public-key":_,mtu:h,keepalive:d,reserved:E,"allowed-ips":g,"preshared-key":y,dns:p,udp:!0,peers:[{server:o,port:l,ip:A,ipv6:S,"public-key":_,"pre-shared-key":y,"allowed-ips":g,reserved:E}]};return Array.isArray(I.dns)&&I.dns.length>0&&(I["remote-dns-resolve"]=!0),I}}}function z7(){return{name:"Surge Direct Parser",test:n=>/^.*=\s*direct/.test(n.split(",")[0]),parse:n=>Ln().parse(n)}}function Y7(){return{name:"Surge SSH Parser",test:n=>/^.*=\s*ssh/.test(n.split(",")[0]),parse:n=>Ln().parse(n)}}function W7(){return{name:"Surge SS Parser",test:n=>/^.*=\s*ss/.test(n.split(",")[0]),parse:n=>Ln().parse(n)}}function X7(){return{name:"Surge VMess Parser",test:n=>/^.*=\s*vmess/.test(n.split(",")[0])&&n.indexOf("username")!==-1,parse:n=>Ln().parse(n)}}function J7(){return{name:"Surge Trojan Parser",test:n=>/^.*=\s*trojan/.test(n.split(",")[0]),parse:n=>Ln().parse(n)}}function Z7(){return{name:"Surge HTTP Parser",test:n=>/^.*=\s*https?/.test(n.split(",")[0]),parse:n=>Ln().parse(n)}}function Q7(){return{name:"Surge Socks5 Parser",test:n=>/^.*=\s*socks5(-tls)?/.test(n.split(",")[0]),parse:n=>Ln().parse(n)}}function eP(){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,o]=i;n=o;let l=/(,|^)\s*?exec\s*?=\s*"(.*?)"\s*?(,|$)/.exec(n)?.[2];l||(l=/(,|^)\s*?exec\s*?=\s*(.*?)\s*?(,|$)/.exec(n)?.[2]);let h=/(,|^)\s*?local-port\s*?=\s*"(.*?)"\s*?(,|$)/.exec(n)?.[2];h||(h=/(,|^)\s*?local-port\s*?=\s*(.*?)\s*?(,|$)/.exec(n)?.[2]);let d=/(,|^)\s*?args\s*?=\s*("(.*?)"|(.*?))(?=\s*?(,|$))/g,E,p=[];for(;(E=d.exec(n))!==null;)E[3]!=null?p.push(E[3]):E[4]!=null&&p.push(E[4]);let f=/(,|^)\s*?addresses\s*?=\s*("(.*?)"|(.*?))(?=\s*?(,|$))/g,w,g=[];for(;(w=f.exec(n))!==null;){let A;w[3]!=null?A=w[3]:w[4]!=null&&(A=w[4]),A!=null&&(A=`${A}`.trim().replace(/^\[/,"").replace(/\]$/,"")),sP(A)&&g.push(A)}return{type:"external",name:s,exec:l,"local-port":h,args:p,addresses:g}}}}function tP(){return{name:"Surge Snell Parser",test:n=>/^.*=\s*snell/.test(n.split(",")[0]),parse:n=>Ln().parse(n)}}function rP(){return{name:"Surge Tuic Parser",test:n=>/^.*=\s*tuic(-v5)?/.test(n.split(",")[0]),parse:n=>{let{port_hopping:i,line:a}=Ew(n),s=Ln().parse(a);return s.ports=i,s}}}function nP(){return{name:"Surge WireGuard Parser",test:n=>/^.*=\s*wireguard/.test(n.split(",")[0]),parse:n=>Ln().parse(n)}}function iP(){return{name:"Surge Hysteria2 Parser",test:n=>/^.*=\s*hysteria2/.test(n.split(",")[0]),parse:n=>{let{port_hopping:i,line:a}=Ew(n),s=Ln().parse(a);return s.ports=i,s}}}function sP(e){return or(e)||Jt(e)}var Aw=[E7(),A7(),w7(),y7(),S7(),b7(),I7(),D7(),_7(),F7(),B7(),C7(),$7(),z7(),Y7(),W7(),X7(),J7(),Z7(),tP(),rP(),nP(),iP(),Q7(),eP(),L7(),U7(),H7(),j7(),q7(),M7(),V7(),K7(),G7(),P7(),R7(),T7(),x7(),O7(),N7(),k7()];function aP(e){for(let t of zf)try{if(t.test(e))return G.info(`Pre-processor [${t.name}] activated`),t.parse(e)}catch(r){G.error(`Parser [${t.name}] failed Reason: ${r}`)}return e}function uP(e){e=aP(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,o]=ww(n,i);o||(r.push(Sw(s)),a=!0)}if(!a)for(let s of Aw){let[o,l]=ww(s,i);if(!l){r.push(Sw(o)),n=s,a=!0,G.info(`${s.name} is activated`);break}}a||G.error(`Failed to parse line: ${i}`)}return r.filter(i=>(["vless","vmess"].includes(i.type)&&(Mf(i.uuid)||G.error(`UUID may be invalid: ${i.name} ${i.uuid}`)),!0))}async function oP(e,t=[],r,n,i){for(let a of t){if(a.disabled){G.log(`Skipping disabled operator: "${a.type}" with arguments: >>> ${JSON.stringify(a.args,null,2)||"None"}`);continue}let s,o={};if(a.type.indexOf("Script")!==-1){let{mode:h,content:d}=a.args;if(h==="link"){let E=d||"",p=E.split("#");if(p.length>1)try{o=JSON.parse(decodeURIComponent(p[1]))}catch{for(let g of p[1].split("&")){let y=g.split("=")[0],A=g.split("=")[1];o[y]=A==null||A===""?!0:decodeURIComponent(A)}}E=`${E.split("#")[0]}${p[2]?`#${p[2]}`:o?.noCache!=null||o?.insecure!=null?`#${p[1]}`:""}`;let f=E.match(/^\/api\/(file|module)\/(.+)/);if(f){let w="";try{w=f?.[1];let g=f?.[2];if(g==null)throw new Error(`\u672C\u5730 ${w} URL \u65E0\u6548: ${E}`);g=decodeURIComponent(g);let y=w==="module"?kg:Na,A=cr(G.read(y),g);if(!A)throw new Error(`\u627E\u4E0D\u5230 ${w}: ${g}`);w==="module"?s=A.content:s=await Qn({type:"file",name:g})}catch(g){throw G.error(`Error when loading ${w}: ${a.args.content}. Reason: ${g}`),new Error(`\u65E0\u6CD5\u52A0\u8F7D ${w}: ${E}`)}}else try{s=await Ir(E)}catch(w){throw G.error(`Error when downloading remote script: ${a.args.content}. Reason: ${w}`),new Error(`\u65E0\u6CD5\u4E0B\u8F7D\u811A\u672C: ${E}`)}}else s=d,o=a.args.arguments||{}}if(!ih[a.type]){G.error(`Unknown operator: "${a.type}"`);continue}G.log(`Applying "${a.type}" with arguments: >>> ${JSON.stringify(a.args,null,2)||"None"}`);let l;a.type.indexOf("Script")!==-1?l=ih[a.type](s,r,o,n,i):l=ih[a.type](a.args||{}),e=await rA(l,e)}return e}function cP(e,t,r,n={}){let i=ch[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)&&(Mf(s.uuid)||G.error(`UUID may be invalid: ${s.name} ${s.uuid}`)),!0)),e=e.map(s=>(s._resolved=s.resolved,Ti(s.name)||(s.name=`${s.type} ${s.server}:${s.port}`),s["disable-sni"]&&(a?s.sni="off":["tuic"].includes(s.type)||(G.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=xc(s.ports))),s)),G.log(`Producing proxies for target: ${t}`),typeof i.type>"u"||i.type==="SINGLE"){let s=e.map(o=>{try{return i.produce(o,r,n)}catch(l){return G.error(`Cannot produce proxy: ${JSON.stringify(o,null,2)} Reason: ${l}`),""}}).filter(o=>o.length>0);return s=r==="internal"?s:s.join(` `),t.startsWith("Surge")&&e.length>0&&e.every(o=>o.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 Gt={parse:uP,process:oP,produce:cP,ipAddress:jf,getRandomPort:xc,isIPv4:or,isIPv6:Jt,isIP:z0,yaml:Ja,getFlag:Eo,removeFlag:Lc,getISO:Xf,MMDB:Wf,Gist:ru,download:Ir,isValidUUID:Mf,doh:wo};function ww(e,t){if(!lP(e,t))return[null,new Error("Parser mismatch")];try{return[e.parse(t),null]}catch(r){return[null,r]}}function lP(e,t){try{return e.test(t)}catch{return!1}}function yw(e){if(typeof e=="string"||typeof e=="number"){if(e=String(e).trim(),e==="")return"/";if(!e.startsWith("/"))return"/"+e}return e}function Sw(e){typeof e.cipher=="string"&&(e.cipher=e.cipher.toLowerCase()),typeof e.password=="number"&&(e.password=hE(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=>yw(n)):t!=null&&(e[`${e.network}-opts`].path=yw(t)),e.type==="trojan"&&e.network==="tcp"&&delete e.network,["vless"].includes(e.type)&&(e.network||(e.network="tcp")),["trojan","tuic","hysteria","hysteria2","juicity","anytls"].includes(e.type)&&(e.tls=!0),e.network){let n=e[`${e.network}-opts`]?.headers?.Host,i=e[`${e.network}-opts`]?.headers?.host;e.network==="h2"?!i&&n&&(e[`${e.network}-opts`].headers.host=n,delete e[`${e.network}-opts`].headers.Host):i&&!n&&(e[`${e.network}-opts`].headers.Host=i,delete e[`${e.network}-opts`].headers.host)}if(e.network==="h2"){let n=e["h2-opts"]?.headers?.host,i=e["h2-opts"]?.path;n&&!Array.isArray(n)&&(e["h2-opts"].headers.host=[n]),Array.isArray(i)&&(e["h2-opts"].path=i[0])}if(!e.tls&&["ws","http"].includes(e.network)&&!e[`${e.network}-opts`]?.headers?.Host&&!z0(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&&(z0(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=G0.Buffer.from(e.name.data).toString("utf8"):e.name=G0.Buffer.from(e.name).toString("utf8")}catch(n){G.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{G.env.isNode&&!r&&e._ca&&(r=G.node.fs.readFileSync(e._ca,{encoding:"utf8"}))}catch(n){G.error(`Read ca file failed Reason: ${n}`)}return!e["tls-fingerprint"]&&r&&(e["tls-fingerprint"]=nv.generateFingerprint(r)),["ss"].includes(e.type)&&ae(e,"shadow-tls-password")&&(e.plugin="shadow-tls",e["plugin-opts"]={host:e["shadow-tls-sni"],password:e["shadow-tls-password"],version:e["shadow-tls-version"]},delete e["shadow-tls-sni"],delete e["shadow-tls-password"],delete e["shadow-tls-version"]),e}function z0(e){return or(e)||Jt(e)}function Y0(e){e.get("/share/col/:name/:target",async(t,r)=>{let{target:n}=t.params;n&&(t.query.target=n,G.info(`\u4F7F\u7528\u8DEF\u7531\u6307\u5B9A\u76EE\u6807: ${n}`)),await Io(t,r)}),e.get("/share/col/:name",Io),e.get("/share/sub/:name/:target",async(t,r)=>{let{target:n}=t.params;n&&(t.query.target=n,G.info(`\u4F7F\u7528\u8DEF\u7531\u6307\u5B9A\u76EE\u6807: ${n}`)),await _o(t,r)}),e.get("/share/sub/:name",_o),e.get("/download/collection/:name/:target",async(t,r)=>{let{target:n}=t.params;n&&(t.query.target=n,G.info(`\u4F7F\u7528\u8DEF\u7531\u6307\u5B9A\u76EE\u6807: ${n}`)),await Io(t,r)}),e.get("/download/collection/:name",Io),e.get("/download/:name/:target",async(t,r)=>{let{target:n}=t.params;n&&(t.query.target=n,G.info(`\u4F7F\u7528\u8DEF\u7531\u6307\u5B9A\u76EE\u6807: ${n}`)),await _o(t,r)}),e.get("/download/:name",_o),e.get("/download/collection/:name/api/v1/server/details",async(t,r)=>{t.query.platform="JSON",t.query.produceType="internal",t.query.resultFormat="nezha",await Io(t,r)}),e.get("/download/:name/api/v1/server/details",async(t,r)=>{t.query.platform="JSON",t.query.produceType="internal",t.query.resultFormat="nezha",await _o(t,r)}),e.get("/download/collection/:name/api/v1/monitor/:nezhaIndex",async(t,r)=>{t.query.platform="JSON",t.query.produceType="internal",t.query.resultFormat="nezha-monitor",await Io(t,r)}),e.get("/download/:name/api/v1/monitor/:nezhaIndex",async(t,r)=>{t.query.platform="JSON",t.query.produceType="internal",t.query.resultFormat="nezha-monitor",await _o(t,r)})}async function _o(e,t){let{name:r,nezhaIndex:n}=e.params;r=decodeURIComponent(r),n=decodeURIComponent(n);let i=e.query.target==="SurgeMac",a=e.query.target||Kp(e.headers)||"JSON",s=e.headers["user-agent"]||e.headers["User-Agent"];G.info(`\u6B63\u5728\u4E0B\u8F7D\u8BA2\u9605\uFF1A${r} \u8BF7\u6C42 User-Agent: ${s} \u8BF7\u6C42 target: ${e.query.target} \u5B9E\u9645\u8F93\u51FA: ${a}`);let{url:o,ua:l,content:h,mergeSources:d,ignoreFailedRemoteSub:E,produceType:p,includeUnsupportedProxy:f,resultFormat:w,proxy:g,noCache:y}=e.query,A={_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{A=JSON.parse(decodeURIComponent(e.query.$options))}catch{for(let D of e.query.$options.split("&")){let H=D.split("=")[0],V=D.split("=")[1];A[H]=V==null||V===""?!0:decodeURIComponent(V)}}G.info(`\u4F20\u5165 $options: ${JSON.stringify(A)}`)}o&&(o=decodeURIComponent(o),G.info(`\u6307\u5B9A\u8FDC\u7A0B\u8BA2\u9605 URL: ${o}`),/^https?:\/\//.test(o)||(h=o,G.info("URL \u4E0D\u662F\u94FE\u63A5\uFF0C\u89C6\u4E3A\u672C\u5730\u8BA2\u9605"))),h&&(h=decodeURIComponent(h),G.info(`\u6307\u5B9A\u672C\u5730\u8BA2\u9605: ${h}`)),g&&(g=decodeURIComponent(g),G.info(`\u6307\u5B9A\u8FDC\u7A0B\u8BA2\u9605\u4F7F\u7528\u4EE3\u7406/\u7B56\u7565 proxy: ${g}`)),l&&(l=decodeURIComponent(l),G.info(`\u6307\u5B9A\u8FDC\u7A0B\u8BA2\u9605 User-Agent: ${l}`)),d&&(d=decodeURIComponent(d),G.info(`\u6307\u5B9A\u5408\u5E76\u6765\u6E90: ${d}`)),E!=null&&E!==""&&(E=decodeURIComponent(E),G.info(`\u6307\u5B9A\u5FFD\u7565\u5931\u8D25\u7684\u8FDC\u7A0B\u8BA2\u9605: ${E}`)),p&&(p=decodeURIComponent(p),G.info(`\u6307\u5B9A\u751F\u4EA7\u7C7B\u578B: ${p}`)),f&&(f=decodeURIComponent(f),G.info(`\u5305\u542B\u5B98\u65B9/\u5546\u5E97\u7248/\u672A\u7EED\u8D39\u8BA2\u9605\u4E0D\u652F\u6301\u7684\u534F\u8BAE: ${f}`)),!f&&Gp(a,s)&&(f=!0,G.info(`\u5F53\u524D\u5BA2\u6237\u7AEF\u53EF\u5305\u542B\u5B98\u65B9/\u5546\u5E97\u7248/\u672A\u7EED\u8D39\u8BA2\u9605\u4E0D\u652F\u6301\u7684\u534F\u8BAE: ${f}`)),i&&G.info("\u624B\u52A8\u6307\u5B9A\u4E86 target \u4E3A SurgeMac, \u5C06\u4F7F\u7528 Mihomo External"),y&&G.info(`\u6307\u5B9A\u4E0D\u4F7F\u7528\u7F13\u5B58: ${y}`);let S=G.read(Wn),_=cr(S,r);if(_)try{_.passThroughUA&&(G.info(`\u8BA2\u9605\u5F00\u542F\u4E86\u900F\u4F20 User-Agent, \u4F7F\u7528\u8BF7\u6C42\u7684 User-Agent: ${s}`),l=s);let D=await Qn({type:"subscription",name:r,platform:a,url:o,ua:l,content:h,mergeSources:d,ignoreFailedRemoteSub:E,produceType:p,produceOpts:{"include-unsupported-proxy":f,useMihomoExternal:i},$options:A,proxy:g,noCache:y}),H;if(_.source!=="local"||["localFirst","remoteFirst"].includes(_.mergeSources))try{o=`${o||_.url}`.split(/[\r\n]+/).map(P=>P.trim()).filter(P=>P.length)?.[0]||"";let V={},F=o.split("#");if(o=o.split("#")[0],F.length>1)try{V=JSON.parse(decodeURIComponent(F[1]))}catch{for(let k of F[1].split("&")){let L=k.split("=")[0],q=k.split("=")[1];V[L]=q==null||q===""?!0:decodeURIComponent(q)}}V.noFlow||(H=await xi(V?.insecure?`${o}#insecure`:o,V.flowUserAgent,void 0,g||_.proxy,V.flowUrl),H&&t.set("subscription-userinfo",go(H)))}catch(V){G.error(`\u8BA2\u9605 ${r} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(V)}`)}if(_.subUserinfo){let V;if(/^https?:\/\//.test(_.subUserinfo))try{V=await xi(void 0,void 0,void 0,g||_.proxy,_.subUserinfo)}catch(F){G.error(`\u8BA2\u9605 ${r} \u4F7F\u7528\u81EA\u5B9A\u4E49\u6D41\u91CF\u94FE\u63A5 ${_.subUserinfo} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(F)}`)}else V=_.subUserinfo;t.set("subscription-userinfo",go([V,H].filter(F=>F).join(";")))}a==="JSON"?(w==="nezha"?D=Cw(D):w==="nezha-monitor"&&(n=/^\d+$/.test(n)?parseInt(n,10):D.findIndex(V=>V.name===n),D=await bw(D[n],n,e.query)),t.set("Content-Type","application/json;charset=utf-8").send(D)):t.send(D)}catch(I){G.notify("\u{1F30D} Sub-Store \u4E0B\u8F7D\u8BA2\u9605\u5931\u8D25",`\u274C \u65E0\u6CD5\u4E0B\u8F7D\u8BA2\u9605\uFF1A${r}\uFF01`,`\u{1F914} \u539F\u56E0\uFF1A${I.message??I}`),G.error(I.message??I),Br(t,new Tn("INTERNAL_SERVER_ERROR",`Failed to download subscription: ${r}`,`Reason: ${I.message??I}`))}else G.error(`\u{1F30D} Sub-Store \u4E0B\u8F7D\u8BA2\u9605\u5931\u8D25 \u274C \u672A\u627E\u5230\u8BA2\u9605\uFF1A${r}\uFF01`),Br(t,new $s("RESOURCE_NOT_FOUND",`Subscription ${r} does not exist!`),404)}async function Io(e,t){let{name:r,nezhaIndex:n}=e.params;r=decodeURIComponent(r),n=decodeURIComponent(n);let i=e.query.target==="SurgeMac",a=e.query.target||Kp(e.headers)||"JSON",s=G.read(zs),o=cr(s,r),l=e.headers["user-agent"]||e.headers["User-Agent"];G.info(`\u6B63\u5728\u4E0B\u8F7D\u7EC4\u5408\u8BA2\u9605\uFF1A${r} \u8BF7\u6C42 User-Agent: ${l} \u8BF7\u6C42 target: ${e.query.target} \u5B9E\u9645\u8F93\u51FA: ${a}`);let{ignoreFailedRemoteSub:h,produceType:d,includeUnsupportedProxy:E,resultFormat:p,proxy:f,noCache:w}=e.query,g={_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{g=JSON.parse(decodeURIComponent(e.query.$options))}catch{for(let A of e.query.$options.split("&")){let S=A.split("=")[0],_=A.split("=")[1];g[S]=_==null||_===""?!0:decodeURIComponent(_)}}G.info(`\u4F20\u5165 $options: ${JSON.stringify(g)}`)}if(f&&(f=decodeURIComponent(f),G.info(`\u6307\u5B9A\u8FDC\u7A0B\u8BA2\u9605\u4F7F\u7528\u4EE3\u7406/\u7B56\u7565 proxy: ${f}`)),h!=null&&h!==""&&(h=decodeURIComponent(h),G.info(`\u6307\u5B9A\u5FFD\u7565\u5931\u8D25\u7684\u8FDC\u7A0B\u8BA2\u9605: ${h}`)),d&&(d=decodeURIComponent(d),G.info(`\u6307\u5B9A\u751F\u4EA7\u7C7B\u578B: ${d}`)),E&&(E=decodeURIComponent(E),G.info(`\u5305\u542B\u5B98\u65B9/\u5546\u5E97\u7248/\u672A\u7EED\u8D39\u8BA2\u9605\u4E0D\u652F\u6301\u7684\u534F\u8BAE: ${E}`)),!E&&Gp(a,l)&&(E=!0,G.info(`\u5F53\u524D\u5BA2\u6237\u7AEF\u53EF\u5305\u542B\u5B98\u65B9/\u5546\u5E97\u7248/\u672A\u7EED\u8D39\u8BA2\u9605\u4E0D\u652F\u6301\u7684\u534F\u8BAE: ${E}`)),i&&G.info("\u624B\u52A8\u6307\u5B9A\u4E86 target \u4E3A SurgeMac, \u5C06\u4F7F\u7528 Mihomo External"),w&&G.info(`\u6307\u5B9A\u4E0D\u4F7F\u7528\u7F13\u5B58: ${w}`),o)try{let y=await Qn({type:"collection",name:r,platform:a,ignoreFailedRemoteSub:h,produceType:d,produceOpts:{"include-unsupported-proxy":E,useMihomoExternal:i},$options:g,proxy:f,noCache:w,ua:l}),A,S=G.read(Wn),_=o.subscriptions;if(_.length>0){let H=cr(S,_[0]);if(H.source!=="local"||["localFirst","remoteFirst"].includes(H.mergeSources))try{let V=`${H.url}`.split(/[\r\n]+/).map(k=>k.trim()).filter(k=>k.length)?.[0]||"",F={},P=V.split("#");if(V=V.split("#")[0],P.length>1)try{F=JSON.parse(decodeURIComponent(P[1]))}catch{for(let L of P[1].split("&")){let q=L.split("=")[0],J=L.split("=")[1];F[q]=J==null||J===""?!0:decodeURIComponent(J)}}F.noFlow||(A=await xi(F?.insecure?`${V}#insecure`:V,F.flowUserAgent,void 0,f||H.proxy||o.proxy,F.flowUrl))}catch(V){G.error(`\u7EC4\u5408\u8BA2\u9605 ${r} \u4E2D\u7684\u5B50\u8BA2\u9605 ${H.name} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${V.message??V}`)}if(H.subUserinfo){let V;if(/^https?:\/\//.test(H.subUserinfo))try{V=await xi(void 0,void 0,void 0,f||H.proxy,H.subUserinfo)}catch(F){G.error(`\u7EC4\u5408\u8BA2\u9605 ${r} \u4F7F\u7528\u81EA\u5B9A\u4E49\u6D41\u91CF\u94FE\u63A5 ${H.subUserinfo} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(F)}`)}else V=H.subUserinfo;A=[V,A].filter(F=>F).join("; ")}}G.info(`\u7EC4\u5408\u8BA2\u9605 ${r} \u900F\u4F20\u7684\u7684\u6D41\u91CF\u4FE1\u606F: ${A}`);let I;if(/^https?:\/\//.test(o.subUserinfo))try{I=await xi(void 0,void 0,void 0,f||o.proxy,o.subUserinfo)}catch(H){G.error(`\u7EC4\u5408\u8BA2\u9605 ${r} \u4F7F\u7528\u81EA\u5B9A\u4E49\u6D41\u91CF\u94FE\u63A5 ${o.subUserinfo} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(H)}`)}else I=o.subUserinfo;let D=[I,A].filter(H=>H).join("; ");D&&t.set("subscription-userinfo",go(D)),a==="JSON"?(p==="nezha"?y=Cw(y):p==="nezha-monitor"&&(n=/^\d+$/.test(n)?parseInt(n,10):y.findIndex(H=>H.name===n),y=await bw(y[n],n,e.query)),t.set("Content-Type","application/json;charset=utf-8").send(y)):t.send(y)}catch(y){G.notify("\u{1F30D} Sub-Store \u4E0B\u8F7D\u7EC4\u5408\u8BA2\u9605\u5931\u8D25",`\u274C \u4E0B\u8F7D\u7EC4\u5408\u8BA2\u9605\u9519\u8BEF\uFF1A${r}\uFF01`,`\u{1F914} \u539F\u56E0\uFF1A${y}`),Br(t,new Tn("INTERNAL_SERVER_ERROR",`Failed to download collection: ${r}`,`Reason: ${y.message??y}`))}else G.error("\u{1F30D} Sub-Store \u4E0B\u8F7D\u7EC4\u5408\u8BA2\u9605\u5931\u8D25",`\u274C \u672A\u627E\u5230\u7EC4\u5408\u8BA2\u9605\uFF1A${r}\uFF01`),Br(t,new $s("RESOURCE_NOT_FOUND",`Collection ${r} does not exist!`),404)}async function bw(e,t,r){let n={code:0,message:"success",result:[]};try{let{isLoon:i,isSurge:a}=G.env;if(!i&&!a)throw new Error("\u4EC5\u652F\u6301 Loon \u548C Surge(ability=http-client-policy)");let s=Gt.produce([e],i?"Loon":"Surge");if(!s)throw new Error("\u5F53\u524D\u5BA2\u6237\u7AEF\u4E0D\u517C\u5BB9\u6B64\u8282\u70B9");let o=e._monitors||[{name:"Cloudflare",url:"http://cp.cloudflare.com/generate_204",method:"HEAD",number:3,timeout:2e3},{name:"Google",url:"http://www.google.com/generate_204",method:"HEAD",number:3,timeout:2e3}],l=r.number||Math.max(...o.map(h=>h.number))||3;for(let h of o){let E={monitor_id:o.indexOf(h),server_id:t,monitor_name:h.name,server_name:e.name,created_at:[],avg_delay:[]};for(let p=0;p{let i=r._geo?.countryCode||r._geo?.country;if(/^[a-z]{2}$/i.test(i)||(i=Xf(r.name)),/^[a-z]{2}$/i.test(i)){let a=Math.round(new Date().getTime()/1e3),s=r._unavailable?0:a,o=parseInt(r._uptime||0,10);t.result.push({id:n,name:r.name,tag:`${r._tag??""}`,last_active:s,valid_ip:r._IP||r.server,ipv4:r._IPv4||r.server,ipv6:r._IPv6||(Jt(r.server)?r.server:""),host:{Platform:"Sub-Store",PlatformVersion:iu.version,CPU:[],MemTotal:1024,DiskTotal:1024,SwapTotal:1024,Arch:"",Virtualization:"",BootTime:a-o,CountryCode:i,Version:"0.0.1"},status:{CPU:0,MemUsed:0,SwapUsed:0,DiskUsed:0,NetInTransfer:0,NetOutTransfer:0,NetInSpeed:0,NetOutSpeed:0,Uptime:o,Load1:0,Load5:0,Load15:0,TcpConnCount:0,UdpConnCount:0,ProcessCount:0}})}}),JSON.stringify(t,null,2)}function W0(e){e.post("/api/preview/sub",hP),e.post("/api/preview/collection",pP),e.post("/api/preview/file",fP)}async function fP(e,t){try{let r=e.body,n="";if(r.type!=="mihomoProfile")if(r.source==="local"&&!["localFirst","remoteFirst"].includes(r.mergeSources))n=r.content;else{let o={};if(n=await Promise.all(r.url.split(/[\r\n]+/).map(l=>l.trim()).filter(l=>l.length).map(async l=>{try{return await Ir(l,r.ua,void 0,r.proxy)}catch(h){return o[l]=h,G.error(`\u6587\u4EF6 ${r.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${l} \u53D1\u751F\u9519\u8BEF: ${h}`),""}})),!r.ignoreFailedRemoteFile&&Object.keys(o).length>0)throw new Error(`\u6587\u4EF6 ${r.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${Object.keys(o).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);r.mergeSources==="localFirst"?n.unshift(r.content):r.mergeSources==="remoteFirst"&&n.push(r.content)}let i=(Array.isArray(n)?n:[n]).flat(),a=i.filter(o=>o!=null&&o!=="").join(` `),s=Array.isArray(r.process)&&r.process.length>0?await Gt.process({$files:i,$content:a,$file:r},r.process):{$content:a,$files:i};Mi(t,{original:a,processed:s?.$content??""})}catch(r){G.error(r.message??r),Br(t,new Tn("INTERNAL_SERVER_ERROR","Failed to preview file",`Reason: ${r.message??r}`))}}async function hP(e,t){try{let r=e.body,n=e.query.target||"JSON",i;if(r.source==="local"&&!["localFirst","remoteFirst"].includes(r.mergeSources))i=r.content;else{let o={};if(i=await Promise.all(r.url.split(/[\r\n]+/).map(l=>l.trim()).filter(l=>l.length).map(async l=>{try{return await Ir(l,r.ua,void 0,r.proxy,void 0,void 0,void 0,!0)}catch(h){return o[l]=h,G.error(`\u8BA2\u9605 ${r.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${l} \u53D1\u751F\u9519\u8BEF: ${h}`),""}})),!r.ignoreFailedRemoteSub&&Object.keys(o).length>0)throw new Error(`\u8BA2\u9605 ${r.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(o).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);r.mergeSources==="localFirst"?i.unshift(r.content):r.mergeSources==="remoteFirst"&&i.push(r.content)}let a=(Array.isArray(i)?i:[i]).map(o=>Gt.parse(o)).flat();a.forEach((o,l)=>{o.id=l,o._subName=r.name,o._subDisplayName=r.displayName});let s=await Gt.process(a,r.process||[],n,{[r.name]:r});Mi(t,{original:a,processed:s})}catch(r){G.error(r.message??r),Br(t,new Tn("INTERNAL_SERVER_ERROR","Failed to preview subscription",`Reason: ${r.message??r}`))}}async function pP(e,t){try{let r=G.read(Wn),n=e.body,i=[...n.subscriptions],a=n.subscriptionTags;Array.isArray(a)&&a.length>0&&r.forEach(d=>{Array.isArray(d.tag)&&d.tag.length>0&&!i.includes(d.name)&&d.tag.some(E=>a.includes(E))&&i.push(d.name)});let s={},o={};if(await Promise.all(i.map(async d=>{let E=cr(r,d);try{let p;if(E.source==="local"&&!["localFirst","remoteFirst"].includes(E.mergeSources))p=E.content;else{let w={};if(p=await Promise.all(E.url.split(/[\r\n]+/).map(g=>g.trim()).filter(g=>g.length).map(async g=>{try{return await Ir(g,E.ua,void 0,E.proxy,void 0,void 0,void 0,!0)}catch(y){return w[g]=y,G.error(`\u8BA2\u9605 ${E.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${g} \u53D1\u751F\u9519\u8BEF: ${y}`),""}})),!E.ignoreFailedRemoteSub&&Object.keys(w).length>0)throw new Error(`\u8BA2\u9605 ${E.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(w).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);E.mergeSources==="localFirst"?p.unshift(E.content):E.mergeSources==="remoteFirst"&&p.push(E.content)}let f=(Array.isArray(p)?p:[p]).map(w=>Gt.parse(w)).flat();f.forEach(w=>{w._subName=E.name,w._subDisplayName=E.displayName,w._collectionName=n.name,w._collectionDisplayName=n.displayName}),f=await Gt.process(f,E.process||[],"JSON",{[E.name]:E,_collection:n}),s[d]=f}catch(p){o[d]=p,G.error(`\u274C \u5904\u7406\u7EC4\u5408\u8BA2\u9605 ${n.name} \u4E2D\u7684\u5B50\u8BA2\u9605: ${E.name}\u65F6\u51FA\u73B0\u9519\u8BEF\uFF1A${p}\uFF01`)}})),!n.ignoreFailedRemoteSub&&Object.keys(o).length>0)throw new Error(`\u7EC4\u5408\u8BA2\u9605 ${n.name} \u4E2D\u7684\u5B50\u8BA2\u9605 ${Object.keys(o).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);let l=Array.prototype.concat.apply([],i.map(d=>s[d]||[]));l.forEach((d,E)=>{d.id=E,d._collectionName=n.name,d._collectionDisplayName=n.displayName});let h=await Gt.process(l,n.process||[],"JSON",{_collection:n});Mi(t,{original:l,processed:h})}catch(r){G.error(r.message??r),Br(t,new Tn("INTERNAL_SERVER_ERROR","Failed to preview collection",`Reason: ${r.message??r}`))}}function X0(e){e.post("/api/utils/node-info",dP)}async function dP(e,t){let r=e.body,n=e.query.lang||"zh-CN",i;try{i=ch.URI.produce(r)}catch{}try{let s=await oi().get({url:`http://ip-api.com/json/${encodeURIComponent(`${r.server}`.trim().replace(/^\[/,"").replace(/\]$/,""))}?lang=${n}`,headers:{"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 12_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Safari/605.1.15"}}).then(o=>{let l=JSON.parse(o.body);if(l.status!=="success")throw new Error(l.message);return delete l.status,l});Mi(t,{shareUrl:i,info:s})}catch(a){Br(t,new eh("FAILED_TO_GET_NODE_INFO","Failed to get node info",`Reason: ${a}`))}}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${Gl} \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 `);kp();gP();function gP(){let e=Lp({substore:G});Y0(e),W0(e),p0(e),X0(e),e.options("/",(t,r)=>{r.status(200).end()}),e.start()}})(); /*! Bundled license information: ieee754/index.js: (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh *) buffer/index.js: (*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT *) jsrsasign/lib/jsrsasign.js: (*! CryptoJS v3.1.2 core-fix.js * code.google.com/p/crypto-js * (c) 2009-2013 by Jeff Mott. All rights reserved. * code.google.com/p/crypto-js/wiki/License * THIS IS FIX of 'core.js' to fix Hmac issue. * https://code.google.com/p/crypto-js/issues/detail?id=84 * https://crypto-js.googlecode.com/svn-history/r667/branches/3.x/src/core.js *) (*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ *) (*! (c) Tom Wu, Kenji Urushima | http://www-cs-students.stanford.edu/~tjw/jsbn/ *) (*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib *) (*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval *) lodash/lodash.js: (** * @license * Lodash * Copyright OpenJS Foundation and other contributors * Released under MIT license * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors *) */