(()=>{var B9=Object.create;var Yw=Object.defineProperty;var $9=Object.getOwnPropertyDescriptor;var R9=Object.getOwnPropertyNames;var P9=Object.getPrototypeOf,x9=Object.prototype.hasOwnProperty;var Fo=(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 le=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var O9=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of R9(t))!x9.call(e,i)&&i!==r&&Yw(e,i,{get:()=>t[i],enumerable:!(n=$9(t,i))||n.enumerable});return e};var Zr=(e,t,r)=>(r=e!=null?B9(P9(e)):{},O9(t||!e||!e.__esModule?Yw(r,"default",{value:e,enumerable:!0}):r,e));var Jw=le(Xw=>{"use strict";(function(e){function t(){}function r(){}var n=String.fromCharCode,i={}.toString,a=i.call(e.SharedArrayBuffer),s=i(),u=e.Uint8Array,l=u||Array,f=u?ArrayBuffer:l,d=f.isView||function(E){return E&&"length"in E},g=i.call(f.prototype);f=r.prototype;var p=e.TextEncoder,h=new(u?Uint16Array:l)(32);t.prototype.decode=function(E){if(!d(E)){var v=i.call(E);if(v!==g&&v!==a&&v!==s)throw TypeError("Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");E=u?new l(E):E||[]}for(var b=v="",m=0,y=E.length|0,D=y-32|0,C,F,L=0,k=0,S,B=0,O=-1;m>4){case 15:if(S=E[m=m+1|0]&255,S>>6!==2||247>6===2?k+4|0:24,F=F+256&768;case 13:case 12:S=E[m=m+1|0]&255,L<<=6,L|=(F&31)<<6|S&63,k=k+7|0,m>6===2&&L>>k&&1114112>L?(F=L,L=L-65536|0,0<=L&&(O=(L>>10)+55296|0,F=(L&1023)+56320|0,31>B?(h[B]=O,B=B+1|0,O=-1):(S=O,O=F,F=S))):(F>>=8,m=m-F-1|0,F=65533),L=k=0,C=m<=D?32:y-m|0;default:h[B]=F;continue;case 11:case 10:case 9:case 8:}h[B]=65533}if(b+=n(h[0],h[1],h[2],h[3],h[4],h[5],h[6],h[7],h[8],h[9],h[10],h[11],h[12],h[13],h[14],h[15],h[16],h[17],h[18],h[19],h[20],h[21],h[22],h[23],h[24],h[25],h[26],h[27],h[28],h[29],h[30],h[31]),32>B&&(b=b.slice(0,B-32|0)),m>>31,O=-1,b.length=C)b[y]=C;else{if(2047>=C)b[y]=192|C>>6;else{e:{if(55296<=C)if(56319>=C){var F=E.charCodeAt(m=m+1|0)|0;if(56320<=F&&57343>=F){if(C=(C<<10)+F-56613888|0,65535>18,b[y=y+1|0]=128|C>>12&63,b[y=y+1|0]=128|C>>6&63,b[y=y+1|0]=128|C&63;continue}break e}C=65533}else 57343>=C&&(C=65533);!D&&m<<1>12,b[y=y+1|0]=128|C>>6&63}b[y=y+1|0]=128|C&63}}return u?b.subarray(0,y):b.slice(0,y)},p||(e.TextDecoder=t,e.TextEncoder=r)})(typeof global>"u"?typeof self>"u"?Xw:self:global)});var ag=le((rz,wA)=>{var t7=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};wA.exports=t7});var ug=le((nz,AA)=>{var r7="2.0.0",n7=Number.MAX_SAFE_INTEGER||9007199254740991,i7=16,s7=250,a7=["major","premajor","minor","preminor","patch","prepatch","prerelease"];AA.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:i7,MAX_SAFE_BUILD_LENGTH:s7,MAX_SAFE_INTEGER:n7,RELEASE_TYPES:a7,SEMVER_SPEC_VERSION:r7,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var cg=le((Ka,yA)=>{var{MAX_SAFE_COMPONENT_LENGTH:og,MAX_SAFE_BUILD_LENGTH:u7,MAX_LENGTH:o7}=ug(),l7=ag();Ka=yA.exports={};var c7=Ka.re=[],f7=Ka.safeRe=[],ke=Ka.src=[],Ne=Ka.t={},h7=0,lg="[a-zA-Z0-9-]",d7=[["\\s",1],["\\d",o7],[lg,u7]],p7=e=>{for(let[t,r]of d7)e=e.split(`${t}*`).join(`${t}{0,${r}}`).split(`${t}+`).join(`${t}{1,${r}}`);return e},ot=(e,t,r)=>{let n=p7(t),i=h7++;l7(e,i,t),Ne[e]=i,ke[i]=t,c7[i]=new RegExp(t,r?"g":void 0),f7[i]=new RegExp(n,r?"g":void 0)};ot("NUMERICIDENTIFIER","0|[1-9]\\d*");ot("NUMERICIDENTIFIERLOOSE","\\d+");ot("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${lg}*`);ot("MAINVERSION",`(${ke[Ne.NUMERICIDENTIFIER]})\\.(${ke[Ne.NUMERICIDENTIFIER]})\\.(${ke[Ne.NUMERICIDENTIFIER]})`);ot("MAINVERSIONLOOSE",`(${ke[Ne.NUMERICIDENTIFIERLOOSE]})\\.(${ke[Ne.NUMERICIDENTIFIERLOOSE]})\\.(${ke[Ne.NUMERICIDENTIFIERLOOSE]})`);ot("PRERELEASEIDENTIFIER",`(?:${ke[Ne.NUMERICIDENTIFIER]}|${ke[Ne.NONNUMERICIDENTIFIER]})`);ot("PRERELEASEIDENTIFIERLOOSE",`(?:${ke[Ne.NUMERICIDENTIFIERLOOSE]}|${ke[Ne.NONNUMERICIDENTIFIER]})`);ot("PRERELEASE",`(?:-(${ke[Ne.PRERELEASEIDENTIFIER]}(?:\\.${ke[Ne.PRERELEASEIDENTIFIER]})*))`);ot("PRERELEASELOOSE",`(?:-?(${ke[Ne.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${ke[Ne.PRERELEASEIDENTIFIERLOOSE]})*))`);ot("BUILDIDENTIFIER",`${lg}+`);ot("BUILD",`(?:\\+(${ke[Ne.BUILDIDENTIFIER]}(?:\\.${ke[Ne.BUILDIDENTIFIER]})*))`);ot("FULLPLAIN",`v?${ke[Ne.MAINVERSION]}${ke[Ne.PRERELEASE]}?${ke[Ne.BUILD]}?`);ot("FULL",`^${ke[Ne.FULLPLAIN]}$`);ot("LOOSEPLAIN",`[v=\\s]*${ke[Ne.MAINVERSIONLOOSE]}${ke[Ne.PRERELEASELOOSE]}?${ke[Ne.BUILD]}?`);ot("LOOSE",`^${ke[Ne.LOOSEPLAIN]}$`);ot("GTLT","((?:<|>)?=?)");ot("XRANGEIDENTIFIERLOOSE",`${ke[Ne.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);ot("XRANGEIDENTIFIER",`${ke[Ne.NUMERICIDENTIFIER]}|x|X|\\*`);ot("XRANGEPLAIN",`[v=\\s]*(${ke[Ne.XRANGEIDENTIFIER]})(?:\\.(${ke[Ne.XRANGEIDENTIFIER]})(?:\\.(${ke[Ne.XRANGEIDENTIFIER]})(?:${ke[Ne.PRERELEASE]})?${ke[Ne.BUILD]}?)?)?`);ot("XRANGEPLAINLOOSE",`[v=\\s]*(${ke[Ne.XRANGEIDENTIFIERLOOSE]})(?:\\.(${ke[Ne.XRANGEIDENTIFIERLOOSE]})(?:\\.(${ke[Ne.XRANGEIDENTIFIERLOOSE]})(?:${ke[Ne.PRERELEASELOOSE]})?${ke[Ne.BUILD]}?)?)?`);ot("XRANGE",`^${ke[Ne.GTLT]}\\s*${ke[Ne.XRANGEPLAIN]}$`);ot("XRANGELOOSE",`^${ke[Ne.GTLT]}\\s*${ke[Ne.XRANGEPLAINLOOSE]}$`);ot("COERCEPLAIN",`(^|[^\\d])(\\d{1,${og}})(?:\\.(\\d{1,${og}}))?(?:\\.(\\d{1,${og}}))?`);ot("COERCE",`${ke[Ne.COERCEPLAIN]}(?:$|[^\\d])`);ot("COERCEFULL",ke[Ne.COERCEPLAIN]+`(?:${ke[Ne.PRERELEASE]})?(?:${ke[Ne.BUILD]})?(?:$|[^\\d])`);ot("COERCERTL",ke[Ne.COERCE],!0);ot("COERCERTLFULL",ke[Ne.COERCEFULL],!0);ot("LONETILDE","(?:~>?)");ot("TILDETRIM",`(\\s*)${ke[Ne.LONETILDE]}\\s+`,!0);Ka.tildeTrimReplace="$1~";ot("TILDE",`^${ke[Ne.LONETILDE]}${ke[Ne.XRANGEPLAIN]}$`);ot("TILDELOOSE",`^${ke[Ne.LONETILDE]}${ke[Ne.XRANGEPLAINLOOSE]}$`);ot("LONECARET","(?:\\^)");ot("CARETTRIM",`(\\s*)${ke[Ne.LONECARET]}\\s+`,!0);Ka.caretTrimReplace="$1^";ot("CARET",`^${ke[Ne.LONECARET]}${ke[Ne.XRANGEPLAIN]}$`);ot("CARETLOOSE",`^${ke[Ne.LONECARET]}${ke[Ne.XRANGEPLAINLOOSE]}$`);ot("COMPARATORLOOSE",`^${ke[Ne.GTLT]}\\s*(${ke[Ne.LOOSEPLAIN]})$|^$`);ot("COMPARATOR",`^${ke[Ne.GTLT]}\\s*(${ke[Ne.FULLPLAIN]})$|^$`);ot("COMPARATORTRIM",`(\\s*)${ke[Ne.GTLT]}\\s*(${ke[Ne.LOOSEPLAIN]}|${ke[Ne.XRANGEPLAIN]})`,!0);Ka.comparatorTrimReplace="$1$2$3";ot("HYPHENRANGE",`^\\s*(${ke[Ne.XRANGEPLAIN]})\\s+-\\s+(${ke[Ne.XRANGEPLAIN]})\\s*$`);ot("HYPHENRANGELOOSE",`^\\s*(${ke[Ne.XRANGEPLAINLOOSE]})\\s+-\\s+(${ke[Ne.XRANGEPLAINLOOSE]})\\s*$`);ot("STAR","(<|>)?=?\\s*\\*");ot("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");ot("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var _A=le((iz,bA)=>{var g7=Object.freeze({loose:!0}),m7=Object.freeze({}),v7=e=>e?typeof e!="object"?g7:e:m7;bA.exports=v7});var SA=le((sz,FA)=>{var CA=/^[0-9]+$/,DA=(e,t)=>{let r=CA.test(e),n=CA.test(t);return r&&n&&(e=+e,t=+t),e===t?0:r&&!n?-1:n&&!r?1:eDA(t,e);FA.exports={compareIdentifiers:DA,rcompareIdentifiers:E7}});var O0=le((az,RA)=>{var P0=ag(),{MAX_LENGTH:IA,MAX_SAFE_INTEGER:x0}=ug(),{safeRe:BA,t:$A}=cg(),w7=_A(),{compareIdentifiers:xl}=SA(),fg=class e{constructor(t,r){if(r=w7(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>IA)throw new TypeError(`version is longer than ${IA} characters`);P0("SemVer",t,r),this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease;let n=t.trim().match(r.loose?BA[$A.LOOSE]:BA[$A.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>x0||this.major<0)throw new TypeError("Invalid major version");if(this.minor>x0||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>x0||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]),xl(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}};RA.exports=fg});var OA=le((uz,xA)=>{var PA=O0(),A7=(e,t,r)=>new PA(e,r).compare(new PA(t,r));xA.exports=A7});var kA=le((oz,TA)=>{var y7=OA(),b7=(e,t,r)=>y7(e,t,r)>=0;TA.exports=b7});var UA=le((lz,LA)=>{var NA=O0(),_7=(e,t,r=!1)=>{if(e instanceof NA)return e;try{return new NA(e,t)}catch(n){if(!r)return null;throw n}};LA.exports=_7});var HA=le((cz,jA)=>{var C7=O0(),D7=UA(),{safeRe:T0,t:k0}=cg(),F7=(e,t)=>{if(e instanceof C7)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?T0[k0.COERCEFULL]:T0[k0.COERCE]);else{let l=t.includePrerelease?T0[k0.COERCERTLFULL]:T0[k0.COERCERTL],f;for(;(f=l.exec(e))&&(!r||r.index+r[0].length!==e.length);)(!r||f.index+f[0].length!==r.index+r[0].length)&&(r=f),l.lastIndex=f.index+f[1].length+f[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]}`:"",u=t.includePrerelease&&r[6]?`+${r[6]}`:"";return D7(`${n}.${i}.${a}${s}${u}`,t)};jA.exports=F7});var zA=le(N0=>{"use strict";N0.byteLength=B7;N0.toByteArray=R7;N0.fromByteArray=O7;var zs=[],ss=[],I7=typeof Uint8Array<"u"?Uint8Array:Array,pg="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for($o=0,VA=pg.length;$o0)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 B7(e){var t=KA(e),r=t[0],n=t[1];return(r+n)*3/4-n}function $7(e,t,r){return(t+r)*3/4-r}function R7(e){var t,r=KA(e),n=r[0],i=r[1],a=new I7($7(e,n,i)),s=0,u=i>0?n-4:n,l;for(l=0;l>16&255,a[s++]=t>>8&255,a[s++]=t&255;return i===2&&(t=ss[e.charCodeAt(l)]<<2|ss[e.charCodeAt(l+1)]>>4,a[s++]=t&255),i===1&&(t=ss[e.charCodeAt(l)]<<10|ss[e.charCodeAt(l+1)]<<4|ss[e.charCodeAt(l+2)]>>2,a[s++]=t>>8&255,a[s++]=t&255),a}function P7(e){return zs[e>>18&63]+zs[e>>12&63]+zs[e>>6&63]+zs[e&63]}function x7(e,t,r){for(var n,i=[],a=t;au?u:s+a));return n===1?(t=e[r-1],i.push(zs[t>>2]+zs[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(zs[t>>10]+zs[t>>4&63]+zs[t<<2&63]+"=")),i.join("")}});var GA=le(gg=>{gg.read=function(e,t,r,n,i){var a,s,u=i*8-n-1,l=(1<>1,d=-7,g=r?i-1:0,p=r?-1:1,h=e[t+g];for(g+=p,a=h&(1<<-d)-1,h>>=-d,d+=u;d>0;a=a*256+e[t+g],g+=p,d-=8);for(s=a&(1<<-d)-1,a>>=-d,d+=n;d>0;s=s*256+e[t+g],g+=p,d-=8);if(a===0)a=1-f;else{if(a===l)return s?NaN:(h?-1:1)*(1/0);s=s+Math.pow(2,n),a=a-f}return(h?-1:1)*s*Math.pow(2,a-n)};gg.write=function(e,t,r,n,i,a){var s,u,l,f=a*8-i-1,d=(1<>1,p=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:a-1,E=n?1:-1,v=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(u=isNaN(t)?1:0,s=d):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),s+g>=1?t+=p/l:t+=p*Math.pow(2,1-g),t*l>=2&&(s++,l/=2),s+g>=d?(u=0,s=d):s+g>=1?(u=(t*l-1)*Math.pow(2,i),s=s+g):(u=t*Math.pow(2,g-1)*Math.pow(2,i),s=0));i>=8;e[r+h]=u&255,h+=E,u/=256,i-=8);for(s=s<0;e[r+h]=s&255,h+=E,s/=256,f-=8);e[r+h-E]|=v*128}});var j0=le(Nl=>{"use strict";var mg=zA(),Tl=GA(),YA=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Nl.Buffer=de;Nl.SlowBuffer=j7;Nl.INSPECT_MAX_BYTES=50;var L0=2147483647;Nl.kMaxLength=L0;de.TYPED_ARRAY_SUPPORT=T7();!de.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function T7(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(de.prototype,"parent",{enumerable:!0,get:function(){if(de.isBuffer(this))return this.buffer}});Object.defineProperty(de.prototype,"offset",{enumerable:!0,get:function(){if(de.isBuffer(this))return this.byteOffset}});function za(e){if(e>L0)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,de.prototype),t}function de(e,t,r){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Ag(e)}return ZA(e,t,r)}de.poolSize=8192;function ZA(e,t,r){if(typeof e=="string")return N7(e,t);if(ArrayBuffer.isView(e))return L7(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(Gs(e,ArrayBuffer)||e&&Gs(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Gs(e,SharedArrayBuffer)||e&&Gs(e.buffer,SharedArrayBuffer)))return Eg(e,t,r);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=e.valueOf&&e.valueOf();if(n!=null&&n!==e)return de.from(n,t,r);let i=U7(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return de.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}de.from=function(e,t,r){return ZA(e,t,r)};Object.setPrototypeOf(de.prototype,Uint8Array.prototype);Object.setPrototypeOf(de,Uint8Array);function QA(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 k7(e,t,r){return QA(e),e<=0?za(e):t!==void 0?typeof r=="string"?za(e).fill(t,r):za(e).fill(t):za(e)}de.alloc=function(e,t,r){return k7(e,t,r)};function Ag(e){return QA(e),za(e<0?0:yg(e)|0)}de.allocUnsafe=function(e){return Ag(e)};de.allocUnsafeSlow=function(e){return Ag(e)};function N7(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!de.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=ey(e,t)|0,n=za(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function vg(e){let t=e.length<0?0:yg(e.length)|0,r=za(t);for(let n=0;n=L0)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+L0.toString(16)+" bytes");return e|0}function j7(e){return+e!=e&&(e=0),de.alloc(+e)}de.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==de.prototype};de.compare=function(t,r){if(Gs(t,Uint8Array)&&(t=de.from(t,t.offset,t.byteLength)),Gs(r,Uint8Array)&&(r=de.from(r,r.offset,r.byteLength)),!de.isBuffer(t)||!de.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;let n=t.length,i=r.length;for(let a=0,s=Math.min(n,i);ai.length?(de.isBuffer(s)||(s=de.from(s)),s.copy(i,a)):Uint8Array.prototype.set.call(i,s,a);else if(de.isBuffer(s))s.copy(i,a);else throw new TypeError('"list" argument must be an Array of Buffers');a+=s.length}return i};function ey(e,t){if(de.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Gs(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 wg(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return ly(e).length;default:if(i)return n?-1:wg(e).length;t=(""+t).toLowerCase(),i=!0}}de.byteLength=ey;function H7(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 J7(this,t,r);case"utf8":case"utf-8":return ry(this,t,r);case"ascii":return W7(this,t,r);case"latin1":case"binary":return X7(this,t,r);case"base64":return G7(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Z7(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}de.prototype._isBuffer=!0;function Ro(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}de.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;rr&&(t+=" ... "),""};YA&&(de.prototype[YA]=de.prototype.inspect);de.prototype.compare=function(t,r,n,i,a){if(Gs(t,Uint8Array)&&(t=de.from(t,t.offset,t.byteLength)),!de.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),a===void 0&&(a=this.length),r<0||n>t.length||i<0||a>this.length)throw new RangeError("out of range index");if(i>=a&&r>=n)return 0;if(i>=a)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,a>>>=0,this===t)return 0;let s=a-i,u=n-r,l=Math.min(s,u),f=this.slice(i,a),d=t.slice(r,n);for(let g=0;g2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,_g(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof t=="string"&&(t=de.from(t,n)),de.isBuffer(t))return t.length===0?-1:WA(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):WA(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function WA(e,t,r,n,i){let a=1,s=e.length,u=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;a=2,s/=2,u/=2,r/=2}function l(d,g){return a===1?d[g]:d.readUInt16BE(g*a)}let f;if(i){let d=-1;for(f=r;fs&&(r=s-u),f=r;f>=0;f--){let d=!0;for(let g=0;gi&&(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 M7(this,t,r,n);case"utf8":case"utf-8":return q7(this,t,r,n);case"ascii":case"latin1":case"binary":return V7(this,t,r,n);case"base64":return K7(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return z7(this,t,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};de.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function G7(e,t,r){return t===0&&r===e.length?mg.fromByteArray(e):mg.fromByteArray(e.slice(t,r))}function ry(e,t,r){r=Math.min(e.length,r);let n=[],i=t;for(;i239?4:a>223?3:a>191?2:1;if(i+u<=r){let l,f,d,g;switch(u){case 1:a<128&&(s=a);break;case 2:l=e[i+1],(l&192)===128&&(g=(a&31)<<6|l&63,g>127&&(s=g));break;case 3:l=e[i+1],f=e[i+2],(l&192)===128&&(f&192)===128&&(g=(a&15)<<12|(l&63)<<6|f&63,g>2047&&(g<55296||g>57343)&&(s=g));break;case 4:l=e[i+1],f=e[i+2],d=e[i+3],(l&192)===128&&(f&192)===128&&(d&192)===128&&(g=(a&15)<<18|(l&63)<<12|(f&63)<<6|d&63,g>65535&&g<1114112&&(s=g))}}s===null?(s=65533,u=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=u}return Y7(n)}var XA=4096;function Y7(e){let t=e.length;if(t<=XA)return String.fromCharCode.apply(String,e);let r="",n=0;for(;nn)&&(r=n);let i="";for(let a=t;an&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),rr)throw new RangeError("Trying to access beyond buffer length")}de.prototype.readUintLE=de.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||Qr(t,r,this.length);let i=this[t],a=1,s=0;for(;++s>>0,r=r>>>0,n||Qr(t,r,this.length);let i=this[t+--r],a=1;for(;r>0&&(a*=256);)i+=this[t+--r]*a;return i};de.prototype.readUint8=de.prototype.readUInt8=function(t,r){return t=t>>>0,r||Qr(t,1,this.length),this[t]};de.prototype.readUint16LE=de.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||Qr(t,2,this.length),this[t]|this[t+1]<<8};de.prototype.readUint16BE=de.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||Qr(t,2,this.length),this[t]<<8|this[t+1]};de.prototype.readUint32LE=de.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||Qr(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};de.prototype.readUint32BE=de.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||Qr(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};de.prototype.readBigUInt64LE=Lu(function(t){t=t>>>0,kl(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&hf(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,kl(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&hf(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||Qr(t,r,this.length);let i=this[t],a=1,s=0;for(;++s=a&&(i-=Math.pow(2,8*r)),i};de.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||Qr(t,r,this.length);let i=r,a=1,s=this[t+--i];for(;i>0&&(a*=256);)s+=this[t+--i]*a;return a*=128,s>=a&&(s-=Math.pow(2,8*r)),s};de.prototype.readInt8=function(t,r){return t=t>>>0,r||Qr(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};de.prototype.readInt16LE=function(t,r){t=t>>>0,r||Qr(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};de.prototype.readInt16BE=function(t,r){t=t>>>0,r||Qr(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};de.prototype.readInt32LE=function(t,r){return t=t>>>0,r||Qr(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};de.prototype.readInt32BE=function(t,r){return t=t>>>0,r||Qr(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};de.prototype.readBigInt64LE=Lu(function(t){t=t>>>0,kl(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&hf(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,kl(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&hf(t,this.length-8);let i=(r<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<>>0,r||Qr(t,4,this.length),Tl.read(this,t,!0,23,4)};de.prototype.readFloatBE=function(t,r){return t=t>>>0,r||Qr(t,4,this.length),Tl.read(this,t,!1,23,4)};de.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||Qr(t,8,this.length),Tl.read(this,t,!0,52,8)};de.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||Qr(t,8,this.length),Tl.read(this,t,!1,52,8)};function pi(e,t,r,n,i,a){if(!de.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}de.prototype.writeUintLE=de.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let u=Math.pow(2,8*n)-1;pi(this,t,r,n,u,0)}let a=1,s=0;for(this[r]=t&255;++s>>0,n=n>>>0,!i){let u=Math.pow(2,8*n)-1;pi(this,t,r,n,u,0)}let a=n-1,s=1;for(this[r+a]=t&255;--a>=0&&(s*=256);)this[r+a]=t/s&255;return r+n};de.prototype.writeUint8=de.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||pi(this,t,r,1,255,0),this[r]=t&255,r+1};de.prototype.writeUint16LE=de.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||pi(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};de.prototype.writeUint16BE=de.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||pi(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};de.prototype.writeUint32LE=de.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||pi(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255,r+4};de.prototype.writeUint32BE=de.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||pi(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 ny(e,t,r,n,i){oy(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 iy(e,t,r,n,i){oy(t,n,i,e,r,7);let a=Number(t&BigInt(4294967295));e[r+7]=a,a=a>>8,e[r+6]=a,a=a>>8,e[r+5]=a,a=a>>8,e[r+4]=a;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=s,s=s>>8,e[r+2]=s,s=s>>8,e[r+1]=s,s=s>>8,e[r]=s,r+8}de.prototype.writeBigUInt64LE=Lu(function(t,r=0){return ny(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});de.prototype.writeBigUInt64BE=Lu(function(t,r=0){return iy(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});de.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let l=Math.pow(2,8*n-1);pi(this,t,r,n,l-1,-l)}let a=0,s=1,u=0;for(this[r]=t&255;++a>0)-u&255;return r+n};de.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let l=Math.pow(2,8*n-1);pi(this,t,r,n,l-1,-l)}let a=n-1,s=1,u=0;for(this[r+a]=t&255;--a>=0&&(s*=256);)t<0&&u===0&&this[r+a+1]!==0&&(u=1),this[r+a]=(t/s>>0)-u&255;return r+n};de.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||pi(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};de.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||pi(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};de.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||pi(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};de.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||pi(this,t,r,4,2147483647,-2147483648),this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4};de.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||pi(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};de.prototype.writeBigInt64LE=Lu(function(t,r=0){return ny(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});de.prototype.writeBigInt64BE=Lu(function(t,r=0){return iy(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function sy(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 ay(e,t,r,n,i){return t=+t,r=r>>>0,i||sy(e,t,r,4,34028234663852886e22,-34028234663852886e22),Tl.write(e,t,r,n,23,4),r+4}de.prototype.writeFloatLE=function(t,r,n){return ay(this,t,r,!0,n)};de.prototype.writeFloatBE=function(t,r,n){return ay(this,t,r,!1,n)};function uy(e,t,r,n,i){return t=+t,r=r>>>0,i||sy(e,t,r,8,17976931348623157e292,-17976931348623157e292),Tl.write(e,t,r,n,52,8),r+8}de.prototype.writeDoubleLE=function(t,r,n){return uy(this,t,r,!0,n)};de.prototype.writeDoubleBE=function(t,r,n){return uy(this,t,r,!1,n)};de.prototype.copy=function(t,r,n,i){if(!de.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-r>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let a;if(typeof t=="number")for(a=r;a2**32?i=JA(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=JA(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function JA(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 Q7(e,t,r){kl(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&hf(t,e.length-(r+1))}function oy(e,t,r,n,i,a){if(e>r||e3?t===0||t===BigInt(0)?u=`>= 0${s} and < 2${s} ** ${(a+1)*8}${s}`:u=`>= -(2${s} ** ${(a+1)*8-1}${s}) and < 2 ** ${(a+1)*8-1}${s}`:u=`>= ${t}${s} and <= ${r}${s}`,new Ol.ERR_OUT_OF_RANGE("value",u,e)}Q7(n,i,a)}function kl(e,t){if(typeof e!="number")throw new Ol.ERR_INVALID_ARG_TYPE(t,"number",e)}function hf(e,t,r){throw Math.floor(e)!==e?(kl(e,r),new Ol.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new Ol.ERR_BUFFER_OUT_OF_BOUNDS:new Ol.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var e$=/[^+/0-9A-Za-z-_]/g;function t$(e){if(e=e.split("=")[0],e=e.trim().replace(e$,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function wg(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 r$(e){let t=[];for(let r=0;r>8,i=r%256,a.push(i),a.push(n);return a}function ly(e){return mg.toByteArray(t$(e))}function U0(e,t,r,n){let i;for(i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Gs(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function _g(e){return e!==e}var i$=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 Lu(e){return typeof BigInt>"u"?s$:e}function s$(){throw new Error("BigInt not supported")}});var xy=le(_e=>{var df={};df.userAgent=!1;var Ll={},a$="11.1.0",u$="jsrsasign(all) 11.1.0 (2024-02-01) (c) 2010-2023 Kenji Urushima | kjur.github.io/jsrsasign/license";var Se=Se||function(e,t){var r={},n=r.lib={},i=n.Base=function(){function h(){}return{extend:function(E){h.prototype=this;var v=new h;return E&&v.mixIn(E),v.hasOwnProperty("init")||(v.init=function(){v.$super.init.apply(this,arguments)}),v.init.prototype=v,v.$super=this,v},create:function(){var E=this.extend();return E.init.apply(E,arguments),E},init:function(){},mixIn:function(E){for(var v in E)E.hasOwnProperty(v)&&(this[v]=E[v]);E.hasOwnProperty("toString")&&(this.toString=E.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),a=n.WordArray=i.extend({init:function(h,E){h=this.words=h||[],E!=t?this.sigBytes=E:this.sigBytes=h.length*4},toString:function(h){return(h||u).stringify(this)},concat:function(h){var E=this.words,v=h.words,b=this.sigBytes,m=h.sigBytes;if(this.clamp(),b%4)for(var y=0;y>>2]>>>24-y%4*8&255;E[b+y>>>2]|=D<<24-(b+y)%4*8}else for(var y=0;y>>2]=v[y>>>2];return this.sigBytes+=m,this},clamp:function(){var h=this.words,E=this.sigBytes;h[E>>>2]&=4294967295<<32-E%4*8,h.length=e.ceil(E/4)},clone:function(){var h=i.clone.call(this);return h.words=this.words.slice(0),h},random:function(h){for(var E=[],v=0;v>>2]>>>24-m%4*8&255;b.push((y>>>4).toString(16)),b.push((y&15).toString(16))}return b.join("")},parse:function(h){for(var E=h.length,v=[],b=0;b>>3]|=parseInt(h.substr(b,2),16)<<24-b%8*4;return new a.init(v,E/2)}},l=s.Latin1={stringify:function(h){for(var E=h.words,v=h.sigBytes,b=[],m=0;m>>2]>>>24-m%4*8&255;b.push(String.fromCharCode(y))}return b.join("")},parse:function(h){for(var E=h.length,v=[],b=0;b>>2]|=(h.charCodeAt(b)&255)<<24-b%4*8;return new a.init(v,E)}},f=s.Utf8={stringify:function(h){try{return decodeURIComponent(escape(l.stringify(h)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(h){return l.parse(unescape(encodeURIComponent(h)))}},d=n.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(h){typeof h=="string"&&(h=f.parse(h)),this._data.concat(h),this._nDataBytes+=h.sigBytes},_process:function(h){var E=this._data,v=E.words,b=E.sigBytes,m=this.blockSize,y=m*4,D=b/y;h?D=e.ceil(D):D=e.max((D|0)-this._minBufferSize,0);var C=D*m,F=e.min(C*4,b);if(C){for(var L=0;L>>2]&255}},t.BlockCipher=u.extend({cfg:u.cfg.extend({mode:g,padding:f}),reset:function(){u.reset.call(this);var b=this.cfg,v=b.iv,b=b.mode;if(this._xformMode==this._ENC_XFORM_MODE)var m=b.createEncryptor;else m=b.createDecryptor,this._minBufferSize=1;this._mode=m.call(b,this,v&&v.words)},_doProcessBlock:function(v,b){this._mode.processBlock(v,b)},_doFinalize:function(){var v=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){v.pad(this._data,this.blockSize);var b=this._process(!0)}else b=this._process(!0),v.unpad(b);return b},blockSize:4});var d=t.CipherParams=r.extend({init:function(v){this.mixIn(v)},toString:function(v){return(v||this.formatter).stringify(this)}}),g=(h.format={}).OpenSSL={stringify:function(v){var b=v.ciphertext;return v=v.salt,(v?n.create([1398893684,1701076831]).concat(v).concat(b):b).toString(a)},parse:function(v){v=a.parse(v);var b=v.words;if(b[0]==1398893684&&b[1]==1701076831){var m=n.create(b.slice(2,4));b.splice(0,4),v.sigBytes-=16}return d.create({ciphertext:v,salt:m})}},p=t.SerializableCipher=r.extend({cfg:r.extend({format:g}),encrypt:function(v,b,m,y){y=this.cfg.extend(y);var D=v.createEncryptor(m,y);return b=D.finalize(b),D=D.cfg,d.create({ciphertext:b,key:m,iv:D.iv,algorithm:v,mode:D.mode,padding:D.padding,blockSize:v.blockSize,formatter:y.format})},decrypt:function(v,b,m,y){return y=this.cfg.extend(y),b=this._parse(b,y.format),v.createDecryptor(m,y).finalize(b.ciphertext)},_parse:function(v,b){return typeof v=="string"?b.parse(v,this):v}}),h=(h.kdf={}).OpenSSL={execute:function(v,b,m,y){return y||(y=n.random(8)),v=s.create({keySize:b+m}).compute(v,y),m=n.create(v.words.slice(b),4*m),v.sigBytes=4*b,d.create({key:v,iv:m,salt:y})}},E=t.PasswordBasedCipher=p.extend({cfg:p.cfg.extend({kdf:h}),encrypt:function(v,b,m,y){return y=this.cfg.extend(y),m=y.kdf.execute(m,v.keySize,v.ivSize),y.iv=m.iv,v=p.encrypt.call(this,v,b,m.key,y),v.mixIn(m),v},decrypt:function(v,b,m,y){return y=this.cfg.extend(y),b=this._parse(b,y.format),m=y.kdf.execute(m,v.keySize,v.ivSize,b.salt),y.iv=m.iv,p.decrypt.call(this,v,b,m.key,y)}})}();(function(){for(var e=Se,t=e.lib.BlockCipher,L=e.algo,r=[],n=[],i=[],a=[],s=[],u=[],l=[],f=[],d=[],g=[],p=[],h=0;256>h;h++)p[h]=128>h?h<<1:h<<1^283;for(var E=0,v=0,h=0;256>h;h++){var b=v^v<<1^v<<2^v<<3^v<<4,b=b>>>8^b&255^99;r[E]=b,n[b]=E;var m=p[E],y=p[m],D=p[y],C=257*p[b]^16843008*b;i[E]=C<<24|C>>>8,a[E]=C<<16|C>>>16,s[E]=C<<8|C>>>24,u[E]=C,C=16843009*D^65537*y^257*m^16843008*E,l[b]=C<<24|C>>>8,f[b]=C<<16|C>>>16,d[b]=C<<8|C>>>24,g[b]=C,E?(E=m^p[p[p[D^m]]],v^=p[p[v]]):E=v=1}var F=[0,1,2,4,8,16,32,64,128,27,54],L=L.AES=t.extend({_doReset:function(){for(var B=this._key,k=B.words,S=B.sigBytes/4,B=4*((this._nRounds=S+6)+1),O=this._keySchedule=[],P=0;P>>24]<<24|r[U>>>16&255]<<16|r[U>>>8&255]<<8|r[U&255]):(U=U<<8|U>>>24,U=r[U>>>24]<<24|r[U>>>16&255]<<16|r[U>>>8&255]<<8|r[U&255],U^=F[P/S|0]<<24),O[P]=O[P-S]^U}for(k=this._invKeySchedule=[],S=0;SS||4>=P?U:l[r[U>>>24]]^f[r[U>>>16&255]]^d[r[U>>>8&255]]^g[r[U&255]]},encryptBlock:function(k,S){this._doCryptBlock(k,S,this._keySchedule,i,a,s,u,r)},decryptBlock:function(k,S){var B=k[S+1];k[S+1]=k[S+3],k[S+3]=B,this._doCryptBlock(k,S,this._invKeySchedule,l,f,d,g,n),B=k[S+1],k[S+1]=k[S+3],k[S+3]=B},_doCryptBlock:function(k,S,B,O,P,U,Y,H){for(var K=this._nRounds,tt=k[S]^B[0],ct=k[S+1]^B[1],ft=k[S+2]^B[2],rt=k[S+3]^B[3],W=4,ie=1;ie>>24]^P[ct>>>16&255]^U[ft>>>8&255]^Y[rt&255]^B[W++],Fe=O[ct>>>24]^P[ft>>>16&255]^U[rt>>>8&255]^Y[tt&255]^B[W++],Pe=O[ft>>>24]^P[rt>>>16&255]^U[tt>>>8&255]^Y[ct&255]^B[W++],rt=O[rt>>>24]^P[tt>>>16&255]^U[ct>>>8&255]^Y[ft&255]^B[W++],tt=Ce,ct=Fe,ft=Pe;Ce=(H[tt>>>24]<<24|H[ct>>>16&255]<<16|H[ft>>>8&255]<<8|H[rt&255])^B[W++],Fe=(H[ct>>>24]<<24|H[ft>>>16&255]<<16|H[rt>>>8&255]<<8|H[tt&255])^B[W++],Pe=(H[ft>>>24]<<24|H[rt>>>16&255]<<16|H[tt>>>8&255]<<8|H[ct&255])^B[W++],rt=(H[rt>>>24]<<24|H[tt>>>16&255]<<16|H[ct>>>8&255]<<8|H[ft&255])^B[W++],k[S]=Ce,k[S+1]=Fe,k[S+2]=Pe,k[S+3]=rt},keySize:8});e.AES=t._createHelper(L)})();(function(){function e(p,h){var E=(this._lBlock>>>p^this._rBlock)&h;this._rBlock^=E,this._lBlock^=E<>>p^this._lBlock)&h;this._lBlock^=E,this._rBlock^=E<E;E++){var v=s[E]-1;h[E]=p[v>>>5]>>>31-v%32&1}for(p=this._subKeys=[],v=0;16>v;v++){for(var b=p[v]=[],m=l[v],E=0;24>E;E++)b[E/6|0]|=h[(u[E]-1+m)%28]<<31-E%6,b[4+(E/6|0)]|=h[28+(u[E+24]-1+m)%28]<<31-E%6;for(b[0]=b[0]<<1|b[0]>>>31,E=1;7>E;E++)b[E]>>>=4*(E-1)+3;b[7]=b[7]<<5|b[7]>>>27}for(h=this._invSubKeys=[],E=0;16>E;E++)h[E]=p[15-E]},encryptBlock:function(p,h){this._doCryptBlock(p,h,this._subKeys)},decryptBlock:function(p,h){this._doCryptBlock(p,h,this._invSubKeys)},_doCryptBlock:function(p,h,E){this._lBlock=p[h],this._rBlock=p[h+1],e.call(this,4,252645135),e.call(this,16,65535),t.call(this,2,858993459),t.call(this,8,16711935),e.call(this,1,1431655765);for(var v=0;16>v;v++){for(var b=E[v],m=this._lBlock,y=this._rBlock,D=0,C=0;8>C;C++)D|=f[C][((y^b[C])&d[C])>>>0];this._lBlock=y,this._rBlock=m^D}E=this._lBlock,this._lBlock=this._rBlock,this._rBlock=E,e.call(this,1,1431655765),t.call(this,8,16711935),t.call(this,2,858993459),e.call(this,16,65535),e.call(this,4,252645135),p[h]=this._lBlock,p[h+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});r.DES=i._createHelper(g),a=a.TripleDES=i.extend({_doReset:function(){var p=this._key.words;this._des1=g.createEncryptor(n.create(p.slice(0,2))),this._des2=g.createEncryptor(n.create(p.slice(2,4))),this._des3=g.createEncryptor(n.create(p.slice(4,6)))},encryptBlock:function(p,h){this._des1.encryptBlock(p,h),this._des2.decryptBlock(p,h),this._des3.encryptBlock(p,h)},decryptBlock:function(p,h){this._des3.decryptBlock(p,h),this._des2.encryptBlock(p,h),this._des1.decryptBlock(p,h)},keySize:6,ivSize:2,blockSize:2}),r.TripleDES=i._createHelper(a)})();(function(){var e=Se,t=e.lib.WordArray;e.enc.Base64={stringify:function(r){var n=r.words,i=r.sigBytes,a=this._map;r.clamp(),r=[];for(var s=0;s>>2]>>>24-8*(s%4)&255)<<16|(n[s+1>>>2]>>>24-8*((s+1)%4)&255)<<8|n[s+2>>>2]>>>24-8*((s+2)%4)&255,l=0;4>l&&s+.75*l>>6*(3-l)&63));if(n=a.charAt(64))for(;r.length%4;)r.push(n);return r.join("")},parse:function(r){var n=r.length,i=this._map,a=i.charAt(64);a&&(a=r.indexOf(a),a!=-1&&(n=a));for(var a=[],s=0,u=0;u>>6-2*(u%4);a[s>>>2]|=(l|f)<<24-8*(s%4),s++}return t.create(a,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}})();(function(e){function t(g,p,h,E,v,b,m){return g=g+(p&h|~p&E)+v+m,(g<>>32-b)+p}function r(g,p,h,E,v,b,m){return g=g+(p&E|h&~E)+v+m,(g<>>32-b)+p}function n(g,p,h,E,v,b,m){return g=g+(p^h^E)+v+m,(g<>>32-b)+p}function i(g,p,h,E,v,b,m){return g=g+(h^(p|~E))+v+m,(g<>>32-b)+p}for(var a=Se,l=a.lib,s=l.WordArray,u=l.Hasher,l=a.algo,f=[],d=0;64>d;d++)f[d]=4294967296*e.abs(e.sin(d+1))|0;l=l.MD5=u.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(g,p){for(var h=0;16>h;h++){var E=p+h,v=g[E];g[E]=(v<<8|v>>>24)&16711935|(v<<24|v>>>8)&4278255360}var h=this._hash.words,E=g[p+0],v=g[p+1],b=g[p+2],m=g[p+3],y=g[p+4],D=g[p+5],C=g[p+6],F=g[p+7],L=g[p+8],k=g[p+9],S=g[p+10],B=g[p+11],O=g[p+12],P=g[p+13],U=g[p+14],Y=g[p+15],H=h[0],ie=h[1],W=h[2],K=h[3],H=t(H,ie,W,K,E,7,f[0]),K=t(K,H,ie,W,v,12,f[1]),W=t(W,K,H,ie,b,17,f[2]),ie=t(ie,W,K,H,m,22,f[3]),H=t(H,ie,W,K,y,7,f[4]),K=t(K,H,ie,W,D,12,f[5]),W=t(W,K,H,ie,C,17,f[6]),ie=t(ie,W,K,H,F,22,f[7]),H=t(H,ie,W,K,L,7,f[8]),K=t(K,H,ie,W,k,12,f[9]),W=t(W,K,H,ie,S,17,f[10]),ie=t(ie,W,K,H,B,22,f[11]),H=t(H,ie,W,K,O,7,f[12]),K=t(K,H,ie,W,P,12,f[13]),W=t(W,K,H,ie,U,17,f[14]),ie=t(ie,W,K,H,Y,22,f[15]),H=r(H,ie,W,K,v,5,f[16]),K=r(K,H,ie,W,C,9,f[17]),W=r(W,K,H,ie,B,14,f[18]),ie=r(ie,W,K,H,E,20,f[19]),H=r(H,ie,W,K,D,5,f[20]),K=r(K,H,ie,W,S,9,f[21]),W=r(W,K,H,ie,Y,14,f[22]),ie=r(ie,W,K,H,y,20,f[23]),H=r(H,ie,W,K,k,5,f[24]),K=r(K,H,ie,W,U,9,f[25]),W=r(W,K,H,ie,m,14,f[26]),ie=r(ie,W,K,H,L,20,f[27]),H=r(H,ie,W,K,P,5,f[28]),K=r(K,H,ie,W,b,9,f[29]),W=r(W,K,H,ie,F,14,f[30]),ie=r(ie,W,K,H,O,20,f[31]),H=n(H,ie,W,K,D,4,f[32]),K=n(K,H,ie,W,L,11,f[33]),W=n(W,K,H,ie,B,16,f[34]),ie=n(ie,W,K,H,U,23,f[35]),H=n(H,ie,W,K,v,4,f[36]),K=n(K,H,ie,W,y,11,f[37]),W=n(W,K,H,ie,F,16,f[38]),ie=n(ie,W,K,H,S,23,f[39]),H=n(H,ie,W,K,P,4,f[40]),K=n(K,H,ie,W,E,11,f[41]),W=n(W,K,H,ie,m,16,f[42]),ie=n(ie,W,K,H,C,23,f[43]),H=n(H,ie,W,K,k,4,f[44]),K=n(K,H,ie,W,O,11,f[45]),W=n(W,K,H,ie,Y,16,f[46]),ie=n(ie,W,K,H,b,23,f[47]),H=i(H,ie,W,K,E,6,f[48]),K=i(K,H,ie,W,F,10,f[49]),W=i(W,K,H,ie,U,15,f[50]),ie=i(ie,W,K,H,D,21,f[51]),H=i(H,ie,W,K,O,6,f[52]),K=i(K,H,ie,W,m,10,f[53]),W=i(W,K,H,ie,S,15,f[54]),ie=i(ie,W,K,H,v,21,f[55]),H=i(H,ie,W,K,L,6,f[56]),K=i(K,H,ie,W,Y,10,f[57]),W=i(W,K,H,ie,C,15,f[58]),ie=i(ie,W,K,H,P,21,f[59]),H=i(H,ie,W,K,y,6,f[60]),K=i(K,H,ie,W,B,10,f[61]),W=i(W,K,H,ie,b,15,f[62]),ie=i(ie,W,K,H,k,21,f[63]);h[0]=h[0]+H|0,h[1]=h[1]+ie|0,h[2]=h[2]+W|0,h[3]=h[3]+K|0},_doFinalize:function(){var g=this._data,p=g.words,h=8*this._nDataBytes,E=8*g.sigBytes;p[E>>>5]|=128<<24-E%32;var v=e.floor(h/4294967296);for(p[(E+64>>>9<<4)+15]=(v<<8|v>>>24)&16711935|(v<<24|v>>>8)&4278255360,p[(E+64>>>9<<4)+14]=(h<<8|h>>>24)&16711935|(h<<24|h>>>8)&4278255360,g.sigBytes=4*(p.length+1),this._process(),g=this._hash,p=g.words,h=0;4>h;h++)E=p[h],p[h]=(E<<8|E>>>24)&16711935|(E<<24|E>>>8)&4278255360;return g},clone:function(){var g=u.clone.call(this);return g._hash=this._hash.clone(),g}}),a.MD5=u._createHelper(l),a.HmacMD5=u._createHmacHelper(l)})(Math);(function(){var e=Se,i=e.lib,t=i.WordArray,r=i.Hasher,n=[],i=e.algo.SHA1=r.extend({_doReset:function(){this._hash=new t.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(a,s){for(var u=this._hash.words,l=u[0],f=u[1],d=u[2],g=u[3],p=u[4],h=0;80>h;h++){if(16>h)n[h]=a[s+h]|0;else{var E=n[h-3]^n[h-8]^n[h-14]^n[h-16];n[h]=E<<1|E>>>31}E=(l<<5|l>>>27)+p+n[h],E=20>h?E+((f&d|~f&g)+1518500249):40>h?E+((f^d^g)+1859775393):60>h?E+((f&d|f&g|d&g)-1894007588):E+((f^d^g)-899497514),p=g,g=d,d=f<<30|f>>>2,f=l,l=E}u[0]=u[0]+l|0,u[1]=u[1]+f|0,u[2]=u[2]+d|0,u[3]=u[3]+g|0,u[4]=u[4]+p|0},_doFinalize:function(){var a=this._data,s=a.words,u=8*this._nDataBytes,l=8*a.sigBytes;return s[l>>>5]|=128<<24-l%32,s[(l+64>>>9<<4)+14]=Math.floor(u/4294967296),s[(l+64>>>9<<4)+15]=u,a.sigBytes=4*s.length,this._process(),this._hash},clone:function(){var a=r.clone.call(this);return a._hash=this._hash.clone(),a}});e.SHA1=r._createHelper(i),e.HmacSHA1=r._createHmacHelper(i)})();(function(e){for(var t=Se,h=t.lib,r=h.WordArray,n=h.Hasher,h=t.algo,i=[],a=[],s=function(v){return 4294967296*(v-(v|0))|0},u=2,l=0;64>l;){var f;e:{f=u;for(var d=e.sqrt(f),g=2;g<=d;g++)if(!(f%g)){f=!1;break e}f=!0}f&&(8>l&&(i[l]=s(e.pow(u,.5))),a[l]=s(e.pow(u,1/3)),l++),u++}var p=[],h=h.SHA256=n.extend({_doReset:function(){this._hash=new r.init(i.slice(0))},_doProcessBlock:function(E,v){for(var b=this._hash.words,m=b[0],y=b[1],D=b[2],C=b[3],F=b[4],L=b[5],k=b[6],S=b[7],B=0;64>B;B++){if(16>B)p[B]=E[v+B]|0;else{var O=p[B-15],P=p[B-2];p[B]=((O<<25|O>>>7)^(O<<14|O>>>18)^O>>>3)+p[B-7]+((P<<15|P>>>17)^(P<<13|P>>>19)^P>>>10)+p[B-16]}O=S+((F<<26|F>>>6)^(F<<21|F>>>11)^(F<<7|F>>>25))+(F&L^~F&k)+a[B]+p[B],P=((m<<30|m>>>2)^(m<<19|m>>>13)^(m<<10|m>>>22))+(m&y^m&D^y&D),S=k,k=L,L=F,F=C+O|0,C=D,D=y,y=m,m=O+P|0}b[0]=b[0]+m|0,b[1]=b[1]+y|0,b[2]=b[2]+D|0,b[3]=b[3]+C|0,b[4]=b[4]+F|0,b[5]=b[5]+L|0,b[6]=b[6]+k|0,b[7]=b[7]+S|0},_doFinalize:function(){var E=this._data,v=E.words,b=8*this._nDataBytes,m=8*E.sigBytes;return v[m>>>5]|=128<<24-m%32,v[(m+64>>>9<<4)+14]=e.floor(b/4294967296),v[(m+64>>>9<<4)+15]=b,E.sigBytes=4*v.length,this._process(),this._hash},clone:function(){var E=n.clone.call(this);return E._hash=this._hash.clone(),E}});t.SHA256=n._createHelper(h),t.HmacSHA256=n._createHmacHelper(h)})(Math);(function(){var e=Se,t=e.lib.WordArray,n=e.algo,r=n.SHA256,n=n.SHA224=r.extend({_doReset:function(){this._hash=new t.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var i=r._doFinalize.call(this);return i.sigBytes-=4,i}});e.SHA224=r._createHelper(n),e.HmacSHA224=r._createHmacHelper(n)})();(function(){function e(){return n.create.apply(n,arguments)}for(var t=Se,r=t.lib.Hasher,a=t.x64,n=a.Word,i=a.WordArray,a=t.algo,s=[e(1116352408,3609767458),e(1899447441,602891725),e(3049323471,3964484399),e(3921009573,2173295548),e(961987163,4081628472),e(1508970993,3053834265),e(2453635748,2937671579),e(2870763221,3664609560),e(3624381080,2734883394),e(310598401,1164996542),e(607225278,1323610764),e(1426881987,3590304994),e(1925078388,4068182383),e(2162078206,991336113),e(2614888103,633803317),e(3248222580,3479774868),e(3835390401,2666613458),e(4022224774,944711139),e(264347078,2341262773),e(604807628,2007800933),e(770255983,1495990901),e(1249150122,1856431235),e(1555081692,3175218132),e(1996064986,2198950837),e(2554220882,3999719339),e(2821834349,766784016),e(2952996808,2566594879),e(3210313671,3203337956),e(3336571891,1034457026),e(3584528711,2466948901),e(113926993,3758326383),e(338241895,168717936),e(666307205,1188179964),e(773529912,1546045734),e(1294757372,1522805485),e(1396182291,2643833823),e(1695183700,2343527390),e(1986661051,1014477480),e(2177026350,1206759142),e(2456956037,344077627),e(2730485921,1290863460),e(2820302411,3158454273),e(3259730800,3505952657),e(3345764771,106217008),e(3516065817,3606008344),e(3600352804,1432725776),e(4094571909,1467031594),e(275423344,851169720),e(430227734,3100823752),e(506948616,1363258195),e(659060556,3750685593),e(883997877,3785050280),e(958139571,3318307427),e(1322822218,3812723403),e(1537002063,2003034995),e(1747873779,3602036899),e(1955562222,1575990012),e(2024104815,1125592928),e(2227730452,2716904306),e(2361852424,442776044),e(2428436474,593698344),e(2756734187,3733110249),e(3204031479,2999351573),e(3329325298,3815920427),e(3391569614,3928383900),e(3515267271,566280711),e(3940187606,3454069534),e(4118630271,4000239992),e(116418474,1914138554),e(174292421,2731055270),e(289380356,3203993006),e(460393269,320620315),e(685471733,587496836),e(852142971,1086792851),e(1017036298,365543100),e(1126000580,2618297676),e(1288033470,3409855158),e(1501505948,4234509866),e(1607167915,987167468),e(1816402316,1246189591)],u=[],l=0;80>l;l++)u[l]=e();a=a.SHA512=r.extend({_doReset:function(){this._hash=new i.init([new n.init(1779033703,4089235720),new n.init(3144134277,2227873595),new n.init(1013904242,4271175723),new n.init(2773480762,1595750129),new n.init(1359893119,2917565137),new n.init(2600822924,725511199),new n.init(528734635,4215389547),new n.init(1541459225,327033209)])},_doProcessBlock:function(f,d){for(var y=this._hash.words,g=y[0],p=y[1],h=y[2],E=y[3],v=y[4],b=y[5],m=y[6],y=y[7],D=g.high,C=g.low,F=p.high,L=p.low,k=h.high,S=h.low,B=E.high,O=E.low,P=v.high,U=v.low,Y=b.high,H=b.low,K=m.high,W=m.low,ie=y.high,Ce=y.low,Fe=D,Pe=C,rt=F,tt=L,ct=k,ft=S,sn=B,nr=O,_t=P,Er=U,sr=Y,dt=H,zt=K,nt=W,Ke=ie,ar=Ce,He=0;80>He;He++){var wr=u[He];if(16>He)var Ot=wr.high=f[d+2*He]|0,De=wr.low=f[d+2*He+1]|0;else{var Ot=u[He-15],De=Ot.high,vt=Ot.low,Ot=(De>>>1|vt<<31)^(De>>>8|vt<<24)^De>>>7,vt=(vt>>>1|De<<31)^(vt>>>8|De<<24)^(vt>>>7|De<<25),Or=u[He-2],De=Or.high,Ft=Or.low,Or=(De>>>19|Ft<<13)^(De<<3|Ft>>>29)^De>>>6,Ft=(Ft>>>19|De<<13)^(Ft<<3|De>>>29)^(Ft>>>6|De<<26),De=u[He-7],an=De.high,er=u[He-16],Ue=er.high,er=er.low,De=vt+De.low,Ot=Ot+an+(De>>>0>>0?1:0),De=De+Ft,Ot=Ot+Or+(De>>>0>>0?1:0),De=De+er,Ot=Ot+Ue+(De>>>0>>0?1:0);wr.high=Ot,wr.low=De}var an=_t&sr^~_t&zt,er=Er&dt^~Er&nt,wr=Fe&rt^Fe&ct^rt&ct,Gt=Pe&tt^Pe&ft^tt&ft,vt=(Fe>>>28|Pe<<4)^(Fe<<30|Pe>>>2)^(Fe<<25|Pe>>>7),Or=(Pe>>>28|Fe<<4)^(Pe<<30|Fe>>>2)^(Pe<<25|Fe>>>7),Ft=s[He],Fi=Ft.high,un=Ft.low,Ft=ar+((Er>>>14|_t<<18)^(Er>>>18|_t<<14)^(Er<<23|_t>>>9)),Ue=Ke+((_t>>>14|Er<<18)^(_t>>>18|Er<<14)^(_t<<23|Er>>>9))+(Ft>>>0>>0?1:0),Ft=Ft+er,Ue=Ue+an+(Ft>>>0>>0?1:0),Ft=Ft+un,Ue=Ue+Fi+(Ft>>>0>>0?1:0),Ft=Ft+De,Ue=Ue+Ot+(Ft>>>0>>0?1:0),De=Or+Gt,wr=vt+wr+(De>>>0>>0?1:0),Ke=zt,ar=nt,zt=sr,nt=dt,sr=_t,dt=Er,Er=nr+Ft|0,_t=sn+Ue+(Er>>>0>>0?1:0)|0,sn=ct,nr=ft,ct=rt,ft=tt,rt=Fe,tt=Pe,Pe=Ft+De|0,Fe=Ue+wr+(Pe>>>0>>0?1:0)|0}C=g.low=C+Pe,g.high=D+Fe+(C>>>0>>0?1:0),L=p.low=L+tt,p.high=F+rt+(L>>>0>>0?1:0),S=h.low=S+ft,h.high=k+ct+(S>>>0>>0?1:0),O=E.low=O+nr,E.high=B+sn+(O>>>0>>0?1:0),U=v.low=U+Er,v.high=P+_t+(U>>>0>>0?1:0),H=b.low=H+dt,b.high=Y+sr+(H>>>0
>>0?1:0),W=m.low=W+nt,m.high=K+zt+(W>>>0>>0?1:0),Ce=y.low=Ce+ar,y.high=ie+Ke+(Ce>>>0>>0?1:0)},_doFinalize:function(){var f=this._data,d=f.words,g=8*this._nDataBytes,p=8*f.sigBytes;return d[p>>>5]|=128<<24-p%32,d[(p+128>>>10<<5)+30]=Math.floor(g/4294967296),d[(p+128>>>10<<5)+31]=g,f.sigBytes=4*d.length,this._process(),this._hash.toX32()},clone:function(){var f=r.clone.call(this);return f._hash=this._hash.clone(),f},blockSize:32}),t.SHA512=r._createHelper(a),t.HmacSHA512=r._createHmacHelper(a)})();(function(){var e=Se,i=e.x64,t=i.Word,r=i.WordArray,i=e.algo,n=i.SHA512,i=i.SHA384=n.extend({_doReset:function(){this._hash=new r.init([new t.init(3418070365,3238371032),new t.init(1654270250,914150663),new t.init(2438529370,812702999),new t.init(355462360,4144912697),new t.init(1731405415,4290775857),new t.init(2394180231,1750603025),new t.init(3675008525,1694076839),new t.init(1203062813,3204075428)])},_doFinalize:function(){var a=n._doFinalize.call(this);return a.sigBytes-=16,a}});e.SHA384=n._createHelper(i),e.HmacSHA384=n._createHmacHelper(i)})();(function(){var e=Se,f=e.lib,t=f.WordArray,r=f.Hasher,f=e.algo,n=t.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),i=t.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),a=t.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),s=t.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),u=t.create([0,1518500249,1859775393,2400959708,2840853838]),l=t.create([1352829926,1548603684,1836072691,2053994217,0]),f=f.RIPEMD160=r.extend({_doReset:function(){this._hash=t.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(d,g){for(var p=0;16>p;p++){var h=g+p,E=d[h];d[h]=(E<<8|E>>>24)&16711935|(E<<24|E>>>8)&4278255360}var h=this._hash.words,E=u.words,v=l.words,b=n.words,m=i.words,y=a.words,D=s.words,C,F,L,k,S,B,O,P,U,Y;B=C=h[0],O=F=h[1],P=L=h[2],U=k=h[3],Y=S=h[4];for(var H,p=0;80>p;p+=1)H=C+d[g+b[p]]|0,H=16>p?H+((F^L^k)+E[0]):32>p?H+((F&L|~F&k)+E[1]):48>p?H+(((F|~L)^k)+E[2]):64>p?H+((F&k|L&~k)+E[3]):H+((F^(L|~k))+E[4]),H|=0,H=H<>>32-y[p],H=H+S|0,C=S,S=k,k=L<<10|L>>>22,L=F,F=H,H=B+d[g+m[p]]|0,H=16>p?H+((O^(P|~U))+v[0]):32>p?H+((O&U|P&~U)+v[1]):48>p?H+(((O|~P)^U)+v[2]):64>p?H+((O&P|~O&U)+v[3]):H+((O^P^U)+v[4]),H|=0,H=H<>>32-D[p],H=H+Y|0,B=Y,Y=U,U=P<<10|P>>>22,P=O,O=H;H=h[1]+L+U|0,h[1]=h[2]+k+Y|0,h[2]=h[3]+S+B|0,h[3]=h[4]+C+O|0,h[4]=h[0]+F+P|0,h[0]=H},_doFinalize:function(){var d=this._data,g=d.words,p=8*this._nDataBytes,h=8*d.sigBytes;for(g[h>>>5]|=128<<24-h%32,g[(h+64>>>9<<4)+14]=(p<<8|p>>>24)&16711935|(p<<24|p>>>8)&4278255360,d.sigBytes=4*(g.length+1),this._process(),d=this._hash,g=d.words,p=0;5>p;p++)h=g[p],g[p]=(h<<8|h>>>24)&16711935|(h<<24|h>>>8)&4278255360;return d},clone:function(){var d=r.clone.call(this);return d._hash=this._hash.clone(),d}});e.RIPEMD160=r._createHelper(f),e.HmacRIPEMD160=r._createHmacHelper(f)})(Math);(function(){var e=Se,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(r,n){r=this._hasher=new r.init,typeof n=="string"&&(n=t.parse(n));var i=r.blockSize,a=4*i;n.sigBytes>a&&(n=r.finalize(n)),n.clamp();for(var s=this._oKey=n.clone(),u=this._iKey=n.clone(),l=s.words,f=u.words,d=0;d>6)+Ul.charAt(r&63);if(t+1==e.length?(r=parseInt(e.substring(t,t+1),16),n+=Ul.charAt(r<<2)):t+2==e.length&&(r=parseInt(e.substring(t,t+2),16),n+=Ul.charAt(r>>2)+Ul.charAt((r&3)<<4)),Sg)for(;(n.length&3)>0;)n+=Sg;return n}function Hl(e){var t="",r,n=0,i,a;for(r=0;r>2),i=a&3,n=1):n==1?(t+=Ga(i<<2|a>>4),i=a&15,n=2):n==2?(t+=Ga(i),t+=Ga(a>>2),i=a&3,n=3):(t+=Ga(i<<2|a>>4),t+=Ga(a&15),n=0));return n==1&&(t+=Ga(i<<2)),t}function dy(e){var t=Hl(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 c$(e,t,r,n,i,a){for(var s=t&32767,u=t>>15;--a>=0;){var l=this[e]&32767,f=this[e++]>>15,d=u*l+f*s;l=s*l+((d&32767)<<15)+r[n]+(i&1073741823),i=(l>>>30)+(d>>>15)+u*f+(i>>>30),r[n++]=l&1073741823}return i}function f$(e,t,r,n,i,a){for(var s=t&16383,u=t>>14;--a>=0;){var l=this[e]&16383,f=this[e++]>>14,d=u*l+f*s;l=s*l+((d&16383)<<14)+r[n]+i,i=(l>>28)+(d>>14)+u*f,r[n++]=l&268435455}return i}cy&&df.appName=="Microsoft Internet Explorer"?(ee.prototype.am=c$,ju=30):cy&&df.appName!="Netscape"?(ee.prototype.am=l$,ju=26):(ee.prototype.am=f$,ju=28);ee.prototype.DB=ju;ee.prototype.DM=(1<=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s}function p$(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 Uu(e){var t=Bt();return t.fromInt(e),t}function g$(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:py(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 v$(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(e==16)t=4;else if(e==8)t=3;else if(e==2)t=1;else if(e==32)t=5;else if(e==4)t=2;else return this.toRadix(e);var r=(1<0)for(u>u)>0&&(i=!0,a=Ga(n));s>=0;)u>(u+=this.DB-t)):(n=this[s]>>(u-=t)&r,u<=0&&(u+=this.DB,--s)),n>0&&(i=!0),i&&(a+=Ga(n));return i?a:"0"}function E$(){var e=Bt();return ee.ZERO.subTo(this,e),e}function w$(){return this.s<0?this.negate():this}function A$(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 z0(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 y$(){return this.t<=0?0:this.DB*(this.t-1)+z0(this[this.t-1]^this.s&this.DM)}function b$(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 _$(e,t){for(var r=e;r=0;--u)t[u+a+1]=this[u]>>n|s,s=(this[u]&i)<=0;--u)t[u]=0;t[a]=s,t.t=this.t+a+1,t.s=this.s,t.clamp()}function D$(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 S$(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 B$(e,t,r){var n=e.abs();if(!(n.t<=0)){var i=this.abs();if(i.t0?(n.lShiftTo(l,a),i.lShiftTo(l,r)):(n.copyTo(a),i.copyTo(r));var f=a.t,d=a[f-1];if(d!=0){var g=d*(1<1?a[f-2]>>this.F2:0),p=this.FV/g,h=(1<=0&&(r[r.t++]=1,r.subTo(m,r)),ee.ONE.dlShiftTo(f,m),m.subTo(a,a);a.t=0;){var y=r[--v]==d?this.DM:Math.floor(r[v]*p+(r[v-1]+E)*h);if((r[v]+=a.am(0,y,r,b,0,f))0&&r.rShiftTo(l,r),s<0&&ee.ZERO.subTo(r,r)}}}function $$(e){var t=Bt();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(ee.ZERO)>0&&e.subTo(t,t),t}function Po(e){this.m=e}function R$(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e}function P$(e){return e}function x$(e){e.divRemTo(this.m,null,e)}function O$(e,t,r){e.multiplyTo(t,r),this.reduce(r)}function T$(e,t){e.squareTo(t),this.reduce(t)}Po.prototype.convert=R$;Po.prototype.revert=P$;Po.prototype.reduce=x$;Po.prototype.mulTo=O$;Po.prototype.sqrTo=T$;function k$(){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 xo(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 L$(e){var t=Bt();return e.copyTo(t),this.reduce(t),t}function U$(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 j$(e,t){e.squareTo(t),this.reduce(t)}function H$(e,t,r){e.multiplyTo(t,r),this.reduce(r)}xo.prototype.convert=N$;xo.prototype.revert=L$;xo.prototype.reduce=U$;xo.prototype.mulTo=H$;xo.prototype.sqrTo=j$;function M$(){return(this.t>0?this[0]&1:this.s)==0}function q$(e,t){if(e>4294967295||e<1)return ee.ONE;var r=Bt(),n=Bt(),i=t.convert(this),a=z0(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 V$(e,t){var r;return e<256||t.isEven()?r=new Po(t):r=new xo(t),this.exp(e,r)}ee.prototype.copyTo=d$;ee.prototype.fromInt=p$;ee.prototype.fromString=g$;ee.prototype.clamp=m$;ee.prototype.dlShiftTo=b$;ee.prototype.drShiftTo=_$;ee.prototype.lShiftTo=C$;ee.prototype.rShiftTo=D$;ee.prototype.subTo=F$;ee.prototype.multiplyTo=S$;ee.prototype.squareTo=I$;ee.prototype.divRemTo=B$;ee.prototype.invDigit=k$;ee.prototype.isEven=M$;ee.prototype.exp=q$;ee.prototype.toString=v$;ee.prototype.negate=E$;ee.prototype.abs=w$;ee.prototype.compareTo=A$;ee.prototype.bitLength=y$;ee.prototype.mod=$$;ee.prototype.modPowInt=V$;ee.ZERO=Uu(0);ee.ONE=Uu(1);function K$(){var e=Bt();return this.copyTo(e),e}function z$(){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 Y$(){return this.t==0?this.s:this[0]<<16>>16}function W$(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}function X$(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function J$(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=Uu(r),i=Bt(),a=Bt(),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 Z$(e,t){this.fromInt(0),t==null&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),i=!1,a=0,s=0,u=0;u=r&&(this.dMultiply(n),this.dAddOffset(s,0),a=0,s=0)}a>0&&(this.dMultiply(Math.pow(t,a)),this.dAddOffset(s,0)),i&&ee.ZERO.subTo(this,this)}function Q$(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),xg,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 tR(e){return this.compareTo(e)==0}function rR(e){return this.compareTo(e)<0?this:e}function nR(e){return this.compareTo(e)>0?this:e}function iR(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 pR(){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 _R(e){var t=Bt();return this.addTo(e,t),t}function CR(e){var t=Bt();return this.subTo(e,t),t}function DR(e){var t=Bt();return this.multiplyTo(e,t),t}function FR(){var e=Bt();return this.squareTo(e),e}function SR(e){var t=Bt();return this.divRemTo(e,t,null),t}function IR(e){var t=Bt();return this.divRemTo(e,null,t),t}function BR(e){var t=Bt(),r=Bt();return this.divRemTo(e,t,r),new Array(t,r)}function $R(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}function RR(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 gf(){}function vy(e){return e}function PR(e,t,r){e.multiplyTo(t,r)}function xR(e,t){e.squareTo(t)}gf.prototype.convert=vy;gf.prototype.revert=vy;gf.prototype.mulTo=PR;gf.prototype.sqrTo=xR;function OR(e){return this.exp(e,new gf)}function TR(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=Bt();return e.copyTo(t),this.reduce(t),t}function LR(e){return e}function UR(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 jR(e,t){e.squareTo(t),this.reduce(t)}function HR(e,t,r){e.multiplyTo(t,r),this.reduce(r)}ql.prototype.convert=NR;ql.prototype.revert=LR;ql.prototype.reduce=UR;ql.prototype.mulTo=HR;ql.prototype.sqrTo=jR;function MR(e,t){var r=e.bitLength(),n,i=Uu(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 Po(t):t.isEven()?a=new ql(t):a=new xo(t);var s=new Array,u=3,l=n-1,f=(1<1){var d=Bt();for(a.sqrTo(s[1],d);u<=f;)s[u]=Bt(),a.mulTo(d,s[u-2],s[u]),u+=2}var g=e.t-1,p,h=!0,E=Bt(),v;for(r=z0(e[g])-1;g>=0;){for(r>=l?p=e[g]>>r-l&f:(p=(e[g]&(1<0&&(p|=e[g-1]>>this.DB+r-l)),u=n;!(p&1);)p>>=1,--u;if((r-=u)<0&&(r+=this.DB,--g),h)s[p].copyTo(i),h=!1;else{for(;u>1;)a.sqrTo(i,E),a.sqrTo(E,i),u-=2;u>0?a.sqrTo(i,E):(v=i,i=E,E=v),a.mulTo(E,s[p],i)}for(;g>=0&&!(e[g]&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 VR(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 KR(e){var t=e.isEven();if(this.isEven()&&t||e.signum()==0)return ee.ZERO;for(var r=e.clone(),n=this.clone(),i=Uu(1),a=Uu(0),s=Uu(0),u=Uu(1);r.signum()!=0;){for(;r.isEven();)r.rShiftTo(1,r),t?((!i.isEven()||!a.isEven())&&(i.addTo(this,i),a.subTo(e,a)),i.rShiftTo(1,i)):a.isEven()||a.subTo(e,a),a.rShiftTo(1,a);for(;n.isEven();)n.rShiftTo(1,n),t?((!s.isEven()||!u.isEven())&&(s.addTo(this,s),u.subTo(e,u)),s.rShiftTo(1,s)):u.isEven()||u.subTo(e,u),u.rShiftTo(1,u);r.compareTo(n)>=0?(r.subTo(n,r),t&&i.subTo(s,i),a.subTo(u,a)):(n.subTo(r,n),t&&s.subTo(i,s),u.subTo(a,u))}if(n.compareTo(ee.ONE)!=0)return ee.ZERO;if(u.compareTo(e)>=0)return u.subtract(e);if(u.signum()<0)u.addTo(e,u);else return u;return u.signum()<0?u.add(e):u}var Yn=[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],zR=(1<<26)/Yn[Yn.length-1];function GR(e){var t,r=this.abs();if(r.t==1&&r[0]<=Yn[Yn.length-1]){for(t=0;t>1,e>Yn.length&&(e=Yn.length);for(var i=Bt(),a=0;a>8&255,Ni[en++]^=e>>16&255,Ni[en++]^=e>>24&255,en>=Ig&&(en-=Ig)}function Tg(){ZR(new Date().getTime())}if(Ni==null){if(Ni=new Array,en=0,Ll!==void 0&&(Ll.crypto!==void 0||Ll.msCrypto!==void 0)){if(Cg=Ll.crypto||Ll.msCrypto,Cg.getRandomValues)for(Dg=new Uint8Array(32),Cg.getRandomValues(Dg),as=0;as<32;++as)Ni[en++]=Dg[as];else if(df.appName=="Netscape"&&df.appVersion<"5")for(Fg=Ll.crypto.random(32),as=0;as>>8,Ni[en++]=as&255;en=0,Tg()}var as,Cg,Dg,Fg;function QR(){if(H0==null){for(Tg(),H0=JR(),H0.init(Ni),en=0;en0&&t.length>0)this.n=gi(e,16),this.e=parseInt(t,16);else throw"Invalid RSA public key"}function rP(e){return e.modPowInt(this.e,this.n)}et.prototype.doPublic=rP;et.prototype.setPublic=tP;et.prototype.type="RSA";function nP(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=gi(e,16),this.e=parseInt(t,16),this.d=gi(r,16);else throw"Invalid RSA private key"}function iP(e,t,r,n,i,a,s,u){if(this.isPrivate=!0,this.isPublic=!1,e==null)throw"RSASetPrivateEx N == null";if(t==null)throw"RSASetPrivateEx E == null";if(e.length==0)throw"RSASetPrivateEx N.length == 0";if(t.length==0)throw"RSASetPrivateEx E.length == 0";if(e!=null&&t!=null&&e.length>0&&t.length>0)this.n=gi(e,16),this.e=parseInt(t,16),this.d=gi(r,16),this.p=gi(n,16),this.q=gi(i,16),this.dmp1=gi(a,16),this.dmq1=gi(s,16),this.coeff=gi(u,16);else throw"Invalid RSA private key in RSASetPrivateEx"}function sP(e,t){var r=new Vl,n=e>>1;this.e=parseInt(t,16);for(var i=new ee(t,16),a=e/2-100,s=ee.ONE.shiftLeft(a);;){for(;this.p=new ee(e-n,1,r),!(this.p.subtract(ee.ONE).gcd(i).compareTo(ee.ONE)==0&&this.p.isProbablePrime(10)););for(;this.q=new ee(n,1,r),!(this.q.subtract(ee.ONE).gcd(i).compareTo(ee.ONE)==0&&this.q.isProbablePrime(10)););if(this.p.compareTo(this.q)<=0){var u=this.p;this.p=this.q,this.q=u}var l=this.q.subtract(this.p).abs();if(!(l.bitLength()0;--f){i=i.twice();var d=r.testBit(f),g=t.testBit(f);d!=g&&(i=i.add(d?this:n))}for(f=s.bitLength()-2;f>0;--f){u=u.twice();var p=s.testBit(f),h=a.testBit(f);p!=h&&(u=u.add(p?u:l))}return i}function _P(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}kt.prototype.getX=gP;kt.prototype.getY=mP;kt.prototype.equals=vP;kt.prototype.isInfinity=EP;kt.prototype.negate=wP;kt.prototype.add=AP;kt.prototype.twice=yP;kt.prototype.multiply=bP;kt.prototype.multiplyTwo=_P;function Wa(e,t,r){this.q=e,this.a=this.fromBigInteger(t),this.b=this.fromBigInteger(r),this.infinity=new kt(this,null,null)}function CP(){return this.q}function DP(){return this.a}function FP(){return this.b}function SP(e){return e==this?!0:this.q.equals(e.q)&&this.a.equals(e.a)&&this.b.equals(e.b)}function IP(){return this.infinity}function BP(e){return new Kr(this.q,e)}function $P(e){switch(parseInt(e.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:var t=e.substr(0,2),r=e.substr(2),n=this.fromBigInteger(new ee(f,16)),i=this.getA(),a=this.getB(),s=n.square().add(i).multiply(n).add(a),u=s.sqrt();return t=="03"&&(u=u.negate()),new kt(this,n,u);case 4:case 6:case 7:var l=(e.length-2)/2,f=e.substr(2,l),d=e.substr(l+2,l);return new kt(this,this.fromBigInteger(new ee(f,16)),this.fromBigInteger(new ee(d,16)));default:return null}}Wa.prototype.getQ=CP;Wa.prototype.getA=DP;Wa.prototype.getB=FP;Wa.prototype.equals=SP;Wa.prototype.getInfinity=IP;Wa.prototype.fromBigInteger=BP;Wa.prototype.decodePointHex=$P;Kr.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)};kt.prototype.getEncoded=function(e){var t=function(a,s){var u=a.toByteArrayUnsigned();if(su.length;)u.unshift(0);return u},r=this.getX().toBigInteger(),n=this.getY().toBigInteger(),i=t(r,32);return e?n.isEven()?i.unshift(2):i.unshift(3):(i.unshift(4),i=i.concat(t(n,32))),i};kt.decodeFrom=function(e,t){var r=t[0],n=t.length-1,i=t.slice(1,1+n/2),a=t.slice(1+n/2,1+n);i.unshift(0),a.unshift(0);var s=new ee(i),u=new ee(a);return new kt(e,e.fromBigInteger(s),e.fromBigInteger(u))};kt.decodeFromHex=function(e,t){var r=t.substr(0,2),n=t.length-2,i=t.substr(2,n/2),a=t.substr(2+n/2,n/2),s=new ee(i,16),u=new ee(a,16);return new kt(e,e.fromBigInteger(s),e.fromBigInteger(u))};kt.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 kt(this.curve,i,a)};kt.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 kt(this.curve,n,i)};kt.prototype.multiply2D=function(e){if(this.isInfinity())return this;if(e.signum()==0)return this.curve.getInfinity();var t=e,r=t.multiply(new ee("3")),n=this.negate(),i=this,a;for(a=r.bitLength()-2;a>0;--a){i=i.twice();var s=r.testBit(a),u=t.testBit(a);s!=u&&(i=i.add2D(s?this:n))}return i};kt.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)};kt.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"};kt.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 Ey=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(g,p,h){return p?a[p]:String.fromCharCode(parseInt(h,16))}var u=new String(""),l="\\",f={"{":Object,"[":Array},d=Object.hasOwnProperty;return function(g,p){var h=g.match(n),E,v=h[0],b=!1;v==="{"?E={}:v==="["?E=[]:(E=[],b=!0);for(var m,y=[E],D=1-b,C=h.length;D=0;)delete B[O[Y]]}return p.call(k,S,B)};E=L({"":E},"")}return E}}();(typeof w>"u"||!w)&&(w={});(typeof w.asn1>"u"||!w.asn1)&&(w.asn1={});w.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 vf(e)},this.getPEMStringFromHex=function(e,t){return Bn(e,t)},this.newObject=function(e){var t=w,r=t.asn1,n=r.ASN1Object,i=r.DERBoolean,a=r.DERInteger,s=r.DERBitString,u=r.DEROctetString,l=r.DERNull,f=r.DERObjectIdentifier,d=r.DEREnumerated,g=r.DERUTF8String,p=r.DERNumericString,h=r.DERPrintableString,E=r.DERTeletexString,v=r.DERIA5String,b=r.DERUTCTime,m=r.DERGeneralizedTime,y=r.DERVisibleString,D=r.DERBMPString,C=r.DERSequence,F=r.DERSet,L=r.DERTaggedObject,k=r.ASN1Util.newObject;if(e instanceof r.ASN1Object)return e;var S=Object.keys(e);if(S.length!=1)throw new Error("key of param shall be only one.");var B=S[0];if(":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+B+":")==-1)throw new Error("undefined key: "+B);if(B=="bool")return new i(e[B]);if(B=="int")return new a(e[B]);if(B=="bitstr")return new s(e[B]);if(B=="octstr")return new u(e[B]);if(B=="null")return new l(e[B]);if(B=="oid")return new f(e[B]);if(B=="enum")return new d(e[B]);if(B=="utf8str")return new g(e[B]);if(B=="numstr")return new p(e[B]);if(B=="prnstr")return new h(e[B]);if(B=="telstr")return new E(e[B]);if(B=="ia5str")return new v(e[B]);if(B=="utctime")return new b(e[B]);if(B=="gentime")return new m(e[B]);if(B=="visstr")return new y(e[B]);if(B=="bmpstr")return new D(e[B]);if(B=="asn1")return new n(e[B]);if(B=="seq"){for(var O=e[B],P=[],U=0;U"u"||this.hV==null)throw new Error("this.hV is null or undefined");if(this.hV.length%2==1)throw new Error("value hex must be even length: n="+a.length+",v="+this.hV);var s=this.hV.length/2,u=s.toString(16);if(u.length%2==1&&(u="0"+u),s<128)return u;var l=u.length/2;if(l>15)throw new Error("ASN.1 length too long to represent by 8x: n = "+s.toString(16));var f=128+l;return f.toString(16)+u},this.tohex=function(){return(this.hTLV==null||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getEncodedHex=function(){return this.tohex()},this.getValueHex=function(){return this.tohex(),this.hV},this.getFreshValueHex=function(){return""},this.setByParam=function(s){this.params=s},e!=null&&e.tlv!=null&&(this.hTLV=e.tlv,this.isModified=!1)};w.asn1.DERAbstractString=function(e){w.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=Y0(this.s).toLowerCase()},this.setStringHex=function(n){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=n},this.getFreshValueHex=function(){return this.hV},typeof e<"u"&&(typeof e=="string"?this.setString(e):typeof e.str<"u"?this.setString(e.str):typeof e.hex<"u"&&this.setStringHex(e.hex))};pe(w.asn1.DERAbstractString,w.asn1.ASN1Object);w.asn1.DERAbstractTime=function(e){w.asn1.DERAbstractTime.superclass.constructor.call(this);var t=null,r=null;this.localDateToUTC=function(n){var i=n.getTime()+n.getTimezoneOffset()*6e4,a=new Date(i);return a},this.formatDate=function(n,i,a){var s=this.zeroPadding,u=this.localDateToUTC(n),l=String(u.getFullYear());i=="utc"&&(l=l.substr(2,2));var f=s(String(u.getMonth()+1),2),d=s(String(u.getDate()),2),g=s(String(u.getHours()),2),p=s(String(u.getMinutes()),2),h=s(String(u.getSeconds()),2),E=l+f+d+g+p+h;if(a===!0){var v=u.getMilliseconds();if(v!=0){var b=s(String(v),3);b=b.replace(/[0]+$/,""),E=E+"."+b}}return E+"Z"},this.zeroPadding=function(n,i){return n.length>=i?n:new Array(i-n.length+1).join("0")+n},this.setByParam=function(n){this.hV=null,this.hTLV=null,this.params=n},this.getString=function(){},this.setString=function(n){this.hTLV=null,this.isModified=!0,this.params==null&&(this.params={}),this.params.str=n},this.setByDate=function(n){this.hTLV=null,this.isModified=!0,this.params==null&&(this.params={}),this.params.date=n},this.setByDateValue=function(n,i,a,s,u,l){var f=new Date(Date.UTC(n,i-1,a,s,u,l,0));this.setByDate(f)},this.getFreshValueHex=function(){return this.hV}};pe(w.asn1.DERAbstractTime,w.asn1.ASN1Object);w.asn1.DERAbstractStructured=function(e){w.asn1.DERAbstractString.superclass.constructor.call(this);var t=null;this.setByASN1ObjectArray=function(r){this.hTLV=null,this.isModified=!0,this.asn1Array=r},this.appendASN1Object=function(r){this.hTLV=null,this.isModified=!0,this.asn1Array.push(r)},this.asn1Array=new Array,typeof e<"u"&&typeof e.array<"u"&&(this.asn1Array=e.array)};pe(w.asn1.DERAbstractStructured,w.asn1.ASN1Object);w.asn1.DERBoolean=function(e){w.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",e==!1?this.hTLV="010100":this.hTLV="0101ff"};pe(w.asn1.DERBoolean,w.asn1.ASN1Object);w.asn1.DERInteger=function(e){w.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.params=null;var t=vf;this.setByBigInteger=function(r){this.isModified=!0,this.params={bigint:r}},this.setByInteger=function(r){this.isModified=!0,this.params=r},this.setValueHex=function(r){this.isModified=!0,this.params={hex:r}},this.getFreshValueHex=function(){var r=this.params,n=null;if(r==null)throw new Error("value not set");if(typeof r=="object"&&r.hex!=null)return this.hV=r.hex,this.hV;if(typeof r=="number")n=new ee(String(r),10);else if(r.int!=null)n=new ee(String(r.int),10);else if(r.bigint!=null)n=r.bigint;else throw new Error("wrong parameter");return this.hV=t(n),this.hV},e!=null&&(this.params=e)};pe(w.asn1.DERInteger,w.asn1.ASN1Object);w.asn1.DERBitString=function(e){if(e!==void 0&&typeof e.obj<"u"){var t=w.asn1.ASN1Util.newObject(e.obj);e.hex="00"+t.tohex()}w.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};be.getNthChildIdx=function(e,t,r){var n=be.getChildIdx(e,t);return n[r]};be.getIdxbyList=function(e,t,r,n){var i=be,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))};be.getIdxbyListEx=function(e,t,r,n){var i=be,a,s;if(r.length==0)return n!==void 0&&e.substr(t,2)!==n?-1:t;a=r.shift(),s=i.getChildIdx(e,t);for(var u=0,l=0;l=e.length?null:i.getTLV(e,a)};be.getTLVbyListEx=function(e,t,r,n){var i=be,a=i.getIdxbyListEx(e,t,r,n);return a==-1?null:i.getTLV(e,a)};be.getVbyList=function(e,t,r,n,i){var a=be,s,u;return s=a.getIdxbyList(e,t,r,n),s==-1||s>=e.length?null:(u=a.getV(e,s),i===!0&&(u=u.substr(2)),u)};be.getVbyListEx=function(e,t,r,n,i){var a=be,s,u,l;return s=a.getIdxbyListEx(e,t,r,n),s==-1?null:(l=a.getV(e,s),e.substr(s,2)=="03"&&i!==!1&&(l=l.substr(2)),l)};be.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=be.getV(e,t);return n=="02"?parseInt(i,16):Sy(i)}catch{return r}};be.getOID=function(e,t,r){r==null&&(r=null);try{if(e.substr(t,2)!="06")return r;var n=be.getV(e,t);return Q0(n)}catch{return r}};be.getOIDName=function(e,t,r){r==null&&(r=null);try{var n=be.getOID(e,t,r);if(n==r)return r;var i=w.asn1.x509.OID.oid2name(n);return i==""?n:i}catch{return r}};be.getString=function(e,t,r){r==null&&(r=null);try{var n=be.getV(e,t);return vi(n)}catch{return r}};be.hextooidstr=function(e){var t=function(g,p){return g.length>=p?g:new Array(p-g.length+1).join("0")+g},r=[],n=e.substr(0,2),i=parseInt(n,16);r[0]=new String(Math.floor(i/40)),r[1]=new String(i%40);for(var a=e.substr(2),s=[],u=0;u0&&(d=d+"."+l.join(".")),d};be.dump=function(e,t,r,n){var i=be,a=i.getV,s=i.dump,u=i.getChildIdx,l=e;e instanceof w.asn1.ASN1Object&&(l=e.tohex());var f=function(k,S){if(k.length<=S*2)return k;var B=k.substr(0,S)+"..(total "+k.length/2+"bytes).."+k.substr(k.length-S,S);return B};t===void 0&&(t={ommit_long_octet:32}),r===void 0&&(r=0),n===void 0&&(n="");var d=t.ommit_long_octet,F=l.substr(r,2);if(F=="01"){var g=a(l,r);return g=="00"?n+`BOOLEAN FALSE `:n+`BOOLEAN TRUE `}if(F=="02"){var g=a(l,r);return n+"INTEGER "+f(g,d)+` `}if(F=="03"){var g=a(l,r);if(i.isASN1HEX(g.substr(2))){var p=n+`BITSTRING, encapsulates `;return p=p+s(g.substr(2),t,0,n+" "),p}else return n+"BITSTRING "+f(g,d)+` `}if(F=="04"){var g=a(l,r);if(i.isASN1HEX(g)){var p=n+`OCTETSTRING, encapsulates `;return p=p+s(g,t,0,n+" "),p}else return n+"OCTETSTRING "+f(g,d)+` `}if(F=="05")return n+`NULL `;if(F=="06"){var h=a(l,r),E=w.asn1.ASN1Util.oidHexToInt(h),v=w.asn1.x509.OID.oid2name(E),b=E.replace(/\./g," ");return v!=""?n+"ObjectIdentifier "+v+" ("+b+`) `:n+"ObjectIdentifier ("+b+`) `}if(F=="0a")return n+"ENUMERATED "+parseInt(a(l,r))+` `;if(F=="0c")return n+"UTF8String '"+Vt(a(l,r))+`' `;if(F=="13")return n+"PrintableString '"+Vt(a(l,r))+`' `;if(F=="14")return n+"TeletexString '"+Vt(a(l,r))+`' `;if(F=="16")return n+"IA5String '"+Vt(a(l,r))+`' `;if(F=="17")return n+"UTCTime "+Vt(a(l,r))+` `;if(F=="18")return n+"GeneralizedTime "+Vt(a(l,r))+` `;if(F=="1a")return n+"VisualString '"+Vt(a(l,r))+`' `;if(F=="1e")return n+"BMPString '"+Ug(a(l,r))+`' `;if(F=="30"){if(l.substr(r,4)=="3000")return n+`SEQUENCE {} `;var p=n+`SEQUENCE `,m=u(l,r),y=t;if((m.length==2||m.length==3)&&l.substr(m[0],2)=="06"&&l.substr(m[m.length-1],2)=="04"){var v=i.oidname(a(l,m[0])),D=JSON.parse(JSON.stringify(t));D.x509ExtName=v,y=D}for(var C=0;C4?{enum:{hex:m}}:{enum:parseInt(m,16)};if(v=="30"||v=="31")return b[h[v]]=E(e),b;if(v=="14"){var L=p(m);return b[h[v]]={str:L},b}else if(v=="1e"){var L=g(m);return b[h[v]]={str:L},b}else if(":0c:12:13:16:17:18:1a:".indexOf(v)!=-1){var L=d(m);return b[h[v]]={str:L},b}else if(v.match(/^8[0-9]$/)){var L=d(m);return L==null|L==""?{tag:{tag:v,explicit:!1,hex:m}}:L.match(/[\x00-\x1F\x7F-\x9F]/)!=null||L.match(/[\u0000-\u001F\u0080–\u009F]/)!=null?{tag:{tag:v,explicit:!1,hex:m}}:{tag:{tag:v,explicit:!1,str:L}}}else if(v.match(/^a[0-9]$/))try{if(!n(m))throw new Error("not encap");return{tag:{tag:v,explicit:!0,obj:r(m)}}}catch{return{tag:{tag:v,explicit:!0,hex:m}}}else{var k=new w.asn1.ASN1Object;k.hV=m;var S=k.getLengthHexFromValue();return{asn1:{tlv:v+S+m}}}}}};be.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}};be.isASN1HEX=function(e){var t=be;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};be.checkStrictDER=function(e,t,r,n,i){var a=be;if(r===void 0){if(typeof e!="string")throw new Error("not hex string");if(e=e.toLowerCase(),!w.lang.String.isHex(e))throw new Error("not hex string");r=e.length,n=e.length/2,n<128?i=1:i=Math.ceil(n.toString(16))+1}var s=a.getL(e,t);if(s.length>i*2)throw new Error("L of TLV too long: idx="+t);var u=a.getVblen(e,t);if(u>n)throw new Error("value of L too long than hex: idx="+t);var l=a.getTLV(e,t),f=l.length-2-a.getL(e,t).length;if(f!==u*2)throw new Error("V string length and L's value not the same:"+f+"/"+u*2);if(t===0&&e.length!=l.length)throw new Error("total length and TLV length unmatch:"+e.length+"!="+l.length);var d=e.substr(t,2);if(d==="02"){var g=a.getVidx(e,t);if(e.substr(g,2)=="00"&&e.charCodeAt(g+2)<56)throw new Error("not least zeros for DER INTEGER")}if(parseInt(d,16)&32){for(var p=a.getVblen(e,t),h=0,E=a.getChildIdx(e,t),v=0;v"u"||!w)&&(w={});(typeof w.asn1>"u"||!w.asn1)&&(w.asn1={});(typeof w.asn1.x509>"u"||!w.asn1.x509)&&(w.asn1.x509={});w.asn1.x509.Certificate=function(e){w.asn1.x509.Certificate.superclass.constructor.call(this);var t=w,r=t.asn1,n=r.DERBitString,i=r.DERSequence,a=r.x509,s=a.TBSCertificate,u=a.AlgorithmIdentifier;this.params=void 0,this.setByParam=function(l){this.params=l},this.sign=function(){var l=this.params,f=l.sigalg;l.sigalg.name!=null&&(f=l.sigalg.name);var d=l.tbsobj.tohex(),g=new w.crypto.Signature({alg:f});g.init(l.cakey),g.updateHex(d),l.sighex=g.sign()},this.getPEM=function(){return Bn(this.tohex(),"CERTIFICATE")},this.tohex=function(){var l=this.params;if((l.tbsobj==null||l.tbsobj==null)&&(l.tbsobj=new s(l)),l.sighex==null&&l.cakey!=null&&this.sign(),l.sighex==null)throw new Error("sighex or cakey parameter not defined");var f=[];f.push(l.tbsobj),f.push(new u({name:l.sigalg})),f.push(new n({hex:"00"+l.sighex}));var d=new i({array:f});return d.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&(this.params=e)};pe(w.asn1.x509.Certificate,w.asn1.ASN1Object);w.asn1.x509.TBSCertificate=function(e){w.asn1.x509.TBSCertificate.superclass.constructor.call(this);var t=w,r=t.asn1,n=r.x509,i=r.DERTaggedObject,a=r.DERInteger,s=r.DERSequence,u=n.AlgorithmIdentifier,l=n.Time,f=n.X500Name,d=n.Extensions,g=n.SubjectPublicKeyInfo;this.params=null,this.setByParam=function(p){this.params=p},this.tohex=function(){var p=[],h=this.params;if(h.version!=null||h.version!=1){var E=2;h.version!=null&&(E=h.version-1);var v=new i({obj:new a({int:E})});p.push(v)}p.push(new a(h.serial)),p.push(new u({name:h.sigalg})),p.push(new f(h.issuer)),p.push(new s({array:[new l(h.notbefore),new l(h.notafter)]})),p.push(new f(h.subject)),p.push(new g(At.getKey(h.sbjpubkey))),h.ext!==void 0&&h.ext.length>0&&p.push(new i({tag:"a3",obj:new d(h.ext)}));var b=new w.asn1.DERSequence({array:p});return b.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};pe(w.asn1.x509.TBSCertificate,w.asn1.ASN1Object);w.asn1.x509.Extensions=function(e){w.asn1.x509.Extensions.superclass.constructor.call(this);var t=w,r=t.asn1,n=r.DERSequence,i=r.x509;this.aParam=[],this.setByParam=function(a){this.aParam=a},this.tohex=function(){for(var a=[],s=0;s-1&&u.push(new n({int:this.pathLen}));var l=new i({array:u});return this.asn1ExtnValue=l,this.asn1ExtnValue.tohex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,e!==void 0&&(e.cA!==void 0&&(this.cA=e.cA),e.pathLen!==void 0&&(this.pathLen=e.pathLen))};pe(w.asn1.x509.BasicConstraints,w.asn1.x509.Extension);w.asn1.x509.CRLDistributionPoints=function(e){w.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,e);var t=w,r=t.asn1,n=r.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.setByDPArray=function(i){for(var a=[],s=0;s0&&a.push(new r({array:s}))}var l=new r({array:a});return l.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(this.params=e)};pe(w.asn1.x509.PolicyInformation,w.asn1.ASN1Object);w.asn1.x509.PolicyQualifierInfo=function(e){w.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var t=w.asn1,r=t.DERSequence,n=t.DERIA5String,i=t.DERObjectIdentifier,a=t.x509.UserNotice;this.params=null,this.tohex=function(){if(this.params.cps!==void 0){var s=new r({array:[new i({oid:"1.3.6.1.5.5.7.2.1"}),new n({str:this.params.cps})]});return s.tohex()}if(this.params.unotice!=null){var s=new r({array:[new i({oid:"1.3.6.1.5.5.7.2.2"}),new a(this.params.unotice)]});return s.tohex()}},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(this.params=e)};pe(w.asn1.x509.PolicyQualifierInfo,w.asn1.ASN1Object);w.asn1.x509.UserNotice=function(e){w.asn1.x509.UserNotice.superclass.constructor.call(this,e);var t=w.asn1.DERSequence,r=w.asn1.DERInteger,n=w.asn1.x509.DisplayText,i=w.asn1.x509.NoticeReference;this.params=null,this.tohex=function(){var a=[];this.params.noticeref!==void 0&&a.push(new i(this.params.noticeref)),this.params.exptext!==void 0&&a.push(new n(this.params.exptext));var s=new t({array:a});return s.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(this.params=e)};pe(w.asn1.x509.UserNotice,w.asn1.ASN1Object);w.asn1.x509.NoticeReference=function(e){w.asn1.x509.NoticeReference.superclass.constructor.call(this,e);var t=w.asn1.DERSequence,r=w.asn1.DERInteger,n=w.asn1.x509.DisplayText;this.params=null,this.tohex=function(){var i=[];if(this.params.org!==void 0&&i.push(new n(this.params.org)),this.params.noticenum!==void 0){for(var a=[],s=this.params.noticenum,u=0;u0)for(var s=0;s0;i++){var a=t.shift();if(r===!0){var s=n.pop(),u=(s+","+a).replace(/\\,/g,",");n.push(u),r=!1}else n.push(a);a.substr(-1,1)==="\\"&&(r=!0)}return n=n.map(function(l){return l.replace("/","\\/")}),n.reverse(),"/"+n.join("/")};w.asn1.x509.X500Name.ldapToOneline=function(e){return w.asn1.x509.X500Name.ldapToCompat(e)};w.asn1.x509.RDN=function(e){w.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var t=w.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 w.asn1.x509.AttributeTypeAndValue({str:r,rule:this.sRule}))},this.addByMultiValuedString=function(r){for(var n=w.asn1.x509.RDN.parseString(r),i=0;i0)for(var r=0;r0;i++){var a=t.shift();if(r===!0){var s=n.pop(),u=(s+"+"+a).replace(/\\\+/g,"+");n.push(u),r=!1}else n.push(a);a.substr(-1,1)==="\\"&&(r=!0)}for(var l=!1,f=[],i=0;n.length>0;i++){var a=n.shift();if(l===!0){var d=f.pop();if(a.match(/"$/)){var u=(d+"+"+a).replace(/^([^=]+)="(.*)"$/,"$1=$2");f.push(u),l=!1}else f.push(d+"+"+a)}else f.push(a);a.match(/^[^=]+="/)&&(l=!0)}return f};w.asn1.x509.AttributeTypeAndValue=function(e){w.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this),this.sRule="utf8",this.sType=null,this.sValue=null,this.dsType=null;var t=w,r=t.asn1,n=r.DERSequence,i=r.DERUTF8String,a=r.DERPrintableString,s=r.DERTeletexString,u=r.DERIA5String,l=r.DERVisibleString,f=r.DERBMPString,d=t.lang.String.isMail,g=t.lang.String.isPrintable;this.setByParam=function(p){if(p.rule!==void 0&&(this.sRule=p.rule),p.ds!==void 0&&(this.dsType=p.ds),p.value===void 0&&p.str!==void 0){var h=p.str,E=h.match(/^([^=]+)=(.+)$/);if(E)this.sType=E[1],this.sValue=E[2];else throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}else this.sType=p.type,this.sValue=p.value},this.setByString=function(p,h){h!==void 0&&(this.sRule=h);var E=p.match(/^([^=]+)=(.+)$/);if(E)this.setByAttrTypeAndValueStr(E[1],E[2]);else throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)},this._getDsType=function(){var p=this.sType,h=this.sValue,E=this.sRule;return E==="prn"?p=="CN"&&d(h)?"ia5":g(h)?"prn":"utf8":E==="utf8"?p=="CN"&&d(h)?"ia5":p=="C"?"prn":"utf8":"utf8"},this.setByAttrTypeAndValueStr=function(p,h,E){E!==void 0&&(this.sRule=E),this.sType=p,this.sValue=h},this.getValueObj=function(p,h){if(p=="utf8")return new i({str:h});if(p=="prn")return new a({str:h});if(p=="tel")return new s({str:h});if(p=="ia5")return new u({str:h});if(p=="vis")return new l({str:h});if(p=="bmp")return new f({str:h});throw new Error("unsupported directory string type: type="+p+" value="+h)},this.tohex=function(){this.dsType==null&&(this.dsType=this._getDsType());var p=w.asn1.x509.OID.atype2obj(this.sType),h=this.getValueObj(this.dsType,this.sValue),E=new n({array:[p,h]});return this.TLV=E.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};pe(w.asn1.x509.AttributeTypeAndValue,w.asn1.ASN1Object);w.asn1.x509.SubjectPublicKeyInfo=function(e){w.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var t=null,r=null,n=w,i=n.asn1,a=i.DERInteger,s=i.DERBitString,u=i.DERObjectIdentifier,l=i.DERSequence,f=i.ASN1Util.newObject,d=i.x509,g=d.AlgorithmIdentifier,p=n.crypto,h=p.ECDSA,E=p.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null)throw"algId and/or subjPubKey not set";var v=new l({array:[this.asn1AlgId,this.asn1SubjPKey]});return v},this.tohex=function(){var v=this.getASN1Object();return this.hTLV=v.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},this.setPubKey=function(v){try{if(v instanceof et){var b=f({seq:[{int:{bigint:v.n}},{int:{int:v.e}}]}),m=b.tohex();this.asn1AlgId=new g({name:"rsaEncryption"}),this.asn1SubjPKey=new s({hex:"00"+m})}}catch{}try{if(v instanceof w.crypto.ECDSA){var y=new u({name:v.curveName});this.asn1AlgId=new g({name:"ecPublicKey",asn1params:y}),this.asn1SubjPKey=new s({hex:"00"+v.pubKeyHex})}}catch{}try{if(v instanceof w.crypto.DSA){var y=new f({seq:[{int:{bigint:v.p}},{int:{bigint:v.q}},{int:{bigint:v.g}}]});this.asn1AlgId=new g({name:"dsa",asn1params:y});var D=new a({bigint:v.y});this.asn1SubjPKey=new s({hex:"00"+D.tohex()})}}catch{}},e!==void 0&&this.setPubKey(e)};pe(w.asn1.x509.SubjectPublicKeyInfo,w.asn1.ASN1Object);w.asn1.x509.Time=function(e){w.asn1.x509.Time.superclass.constructor.call(this);var t=null,r=null,n=w,i=n.asn1,a=i.DERUTCTime,s=i.DERGeneralizedTime;this.params=null,this.type=null,this.setTimeParams=function(u){this.timeParams=u},this.setByParam=function(u){this.params=u},this.getType=function(u){return u.match(/^[0-9]{12}Z$/)?"utc":u.match(/^[0-9]{14}Z$/)?"gen":u.match(/^[0-9]{12}\.[0-9]+Z$/)?"utc":u.match(/^[0-9]{14}\.[0-9]+Z$/)?"gen":null},this.tohex=function(){var u=this.params,l=null;if(typeof u=="string"&&(u={str:u}),u!=null&&u.str&&(u.type==null||u.type==null)&&(u.type=this.getType(u.str)),u!=null&&u.str?(u.type=="utc"&&(l=new a(u.str)),u.type=="gen"&&(l=new s(u.str))):this.type=="gen"?l=new s:l=new a,l==null)throw new Error("wrong setting for Time");return this.TLV=l.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};w.asn1.x509.Time_bak=function(e){w.asn1.x509.Time_bak.superclass.constructor.call(this);var t=null,r=null,n=w,i=n.asn1,a=i.DERUTCTime,s=i.DERGeneralizedTime;this.setTimeParams=function(u){this.timeParams=u},this.tohex=function(){var u=null;return this.timeParams!=null?this.type=="utc"?u=new a(this.timeParams):u=new s(this.timeParams):this.type=="utc"?u=new a:u=new s,this.TLV=u.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},this.type="utc",e!==void 0&&(e.type!==void 0?this.type=e.type:e.str!==void 0&&(e.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),e.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=e)};pe(w.asn1.x509.Time,w.asn1.ASN1Object);w.asn1.x509.AlgorithmIdentifier=function(e){w.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var t=w,r=t.asn1,n=r.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;if(this.tohex=function(){if(this.nameAlg===null&&this.asn1Alg===null)throw new Error("algorithm not specified");if(this.nameAlg!==null){var a=null;for(var s in n)s===this.nameAlg&&(a=n[s]);if(a!==null)return this.hTLV=a,this.hTLV}this.nameAlg!==null&&this.asn1Alg===null&&(this.asn1Alg=r.x509.OID.name2obj(this.nameAlg));var u=[this.asn1Alg];this.asn1Params!==null&&u.push(this.asn1Params);var l=new r.DERSequence({array:u});return this.hTLV=l.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(e.name!==void 0&&(this.nameAlg=e.name),e.asn1params!==void 0&&(this.asn1Params=e.asn1params),e.paramempty!==void 0&&(this.paramEmpty=e.paramempty)),this.asn1Params===null&&this.paramEmpty===!1&&this.nameAlg!==null){this.nameAlg.name!==void 0&&(this.nameAlg=this.nameAlg.name);var i=this.nameAlg.toLowerCase();i.substr(-7,7)!=="withdsa"&&i.substr(-9,9)!=="withecdsa"&&(this.asn1Params=new r.DERNull)}};pe(w.asn1.x509.AlgorithmIdentifier,w.asn1.ASN1Object);w.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"};w.asn1.x509.GeneralName=function(e){w.asn1.x509.GeneralName.superclass.constructor.call(this);var t={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87",otherName:"a0"},r=w,n=r.asn1,i=n.x509,a=i.X500Name,s=i.OtherName,u=n.DERIA5String,l=n.DERPrintableString,f=n.DEROctetString,d=n.DERTaggedObject,g=n.ASN1Object,p=Error;this.params=null,this.setByParam=function(h){this.params=h},this.tohex=function(){var h=this.params,E,b,v,b=!1;if(h.other!==void 0)E="a0",v=new s(h.other);else if(h.rfc822!==void 0)E="81",v=new u({str:h.rfc822});else if(h.dns!==void 0)E="82",v=new u({str:h.dns});else if(h.dn!==void 0)E="a4",b=!0,typeof h.dn=="string"?v=new a({str:h.dn}):h.dn instanceof w.asn1.x509.X500Name?v=h.dn:v=new a(h.dn);else if(h.ldapdn!==void 0)E="a4",b=!0,v=new a({ldapstr:h.ldapdn});else if(h.certissuer!==void 0||h.certsubj!==void 0){E="a4",b=!0;var m,y,D=null;if(h.certsubj!==void 0?(m=!1,y=h.certsubj):(m=!0,y=h.certissuer),y.match(/^[0-9A-Fa-f]+$/)&&D==y,y.indexOf("-----BEGIN ")!=-1&&(D=mr(y)),D==null)throw new Error("certsubj/certissuer not cert");var C=new Ge;C.hex=D;var F;m?F=C.getIssuerHex():F=C.getSubjectHex(),v=new g,v.hTLV=F}else if(h.uri!==void 0)E="86",v=new u({str:h.uri});else if(h.ip!==void 0){E="87";var L,k=h.ip;try{if(k.match(/^[0-9a-f]+$/)){var S=k.length;if(S==8||S==16||S==32||S==64)L=k;else throw"err"}else L=Lg(k)}catch(O){throw new p("malformed IP address: "+h.ip+":"+O.message)}v=new f({hex:L})}else throw new p("improper params");var B=new d({tag:E,explicit:b,obj:v});return B.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};pe(w.asn1.x509.GeneralName,w.asn1.ASN1Object);w.asn1.x509.GeneralNames=function(e){w.asn1.x509.GeneralNames.superclass.constructor.call(this);var t=null,r=w,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}}};w.asn1.x509.OID.oid2name=function(e){var t=w.asn1.x509.OID.name2oidList;for(var r in t)if(t[r]==e)return r;return""};w.asn1.x509.OID.oid2atype=function(e){var t=w.asn1.x509.OID.atype2oidList;for(var r in t)if(t[r]==e)return r;return e};w.asn1.x509.OID.name2oid=function(e){if(e.match(/^[0-9.]+$/))return e;var t=w.asn1.x509.OID.name2oidList;return t[e]===void 0?"":t[e]};w.asn1.x509.X509Util={};w.asn1.x509.X509Util.newCertPEM=function(e){var t=w.asn1.x509,r=t.TBSCertificate,n=t.Certificate,i=new n(e);return i.getPEM()};(typeof w>"u"||!w)&&(w={});(typeof w.asn1>"u"||!w.asn1)&&(w.asn1={});(typeof w.asn1.cms>"u"||!w.asn1.cms)&&(w.asn1.cms={});w.asn1.cms.Attribute=function(e){var t=Error,r=w,n=r.asn1,i=n.DERSequence,a=n.DERSet,s=n.DERObjectIdentifier;this.params=null,this.typeOid=null,this.setByParam=function(u){this.params=u},this.getValueArray=function(){throw new t("not yet implemented abstract")},this.tohex=function(){var u=new s({oid:this.typeOid}),l=new a({array:this.getValueArray()}),f=new i({array:[u,l]});return f.tohex()},this.getEncodedHex=function(){return this.tohex()}};pe(w.asn1.cms.Attribute,w.asn1.ASN1Object);w.asn1.cms.ContentType=function(e){var t=w,r=t.asn1;r.cms.ContentType.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.3",this.getValueArray=function(){var n=new r.DERObjectIdentifier(this.params.type);return[n]},e!=null&&this.setByParam(e)};pe(w.asn1.cms.ContentType,w.asn1.cms.Attribute);w.asn1.cms.MessageDigest=function(e){var t=w,r=t.asn1,n=r.DEROctetString,i=r.cms;i.MessageDigest.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.4",this.getValueArray=function(){var a=new n(this.params);return[a]},e!=null&&this.setByParam(e)};pe(w.asn1.cms.MessageDigest,w.asn1.cms.Attribute);w.asn1.cms.SigningTime=function(e){var t=w,r=t.asn1;r.cms.SigningTime.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.5",this.getValueArray=function(){var n=new r.x509.Time(this.params);return[n]},e!=null&&this.setByParam(e)};pe(w.asn1.cms.SigningTime,w.asn1.cms.Attribute);w.asn1.cms.SigningCertificate=function(e){var t=Error,r=w,n=r.asn1,i=n.DERSequence,a=n.cms,s=a.ESSCertID,u=r.crypto;a.SigningCertificate.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.12",this.getValueArray=function(){if(this.params==null||this.params==null||this.params.array==null)throw new t("parameter 'array' not specified");for(var l=this.params.array,f=[],d=0;d0){for(var E=a(p.valhex,h[0]),v=g(E,0),b=[],m=0;m1){var C=a(p.valhex,h[1]);p.polhex=C}delete p.valhex},this.setSignaturePolicyIdentifier=function(p){var h=g(p.valhex,0);if(h.length>0){var E=n.getOID(p.valhex,h[0]);p.oid=E}if(h.length>1){var v=new t,b=g(p.valhex,h[1]),m=a(p.valhex,b[0]),y=v.getAlgorithmIdentifierName(m);p.alg=y;var D=i(p.valhex,b[1]);p.hash=D}delete p.valhex},this.setSigningCertificateV2=function(p){var h=g(p.valhex,0);if(h.length>0){for(var E=a(p.valhex,h[0]),v=g(E,0),b=[],m=0;m1){var C=a(p.valhex,h[1]);p.polhex=C}delete p.valhex},this.getESSCertID=function(p){var h={},E=g(p,0);if(E.length>0){var v=i(p,E[0]);h.hash=v}if(E.length>1){var b=a(p,E[1]),m=this.getIssuerSerial(b);m.serial!=null&&(h.serial=m.serial),m.issuer!=null&&(h.issuer=m.issuer)}return h},this.getESSCertIDv2=function(p){var h={},E=g(p,0);if(E.length<1||3v+1){var y=a(p,E[v+1]),D=this.getIssuerSerial(y);h.issuer=D.issuer,h.serial=D.serial}return h},this.getIssuerSerial=function(p){var h={},E=g(p,0),v=a(p,E[0]),b=r.getGeneralNames(v),m=b[0].dn;h.issuer=m;var y=i(p,E[1]);return h.serial={hex:y},h},this.getCertificateSet=function(p){for(var h=g(p,0),E=[],v=0;v"u"||!w)&&(w={});(typeof w.asn1>"u"||!w.asn1)&&(w.asn1={});(typeof w.asn1.tsp>"u"||!w.asn1.tsp)&&(w.asn1.tsp={});w.asn1.tsp.TimeStampToken=function(e){var t=w,r=t.asn1,n=r.tsp;n.TimeStampToken.superclass.constructor.call(this),this.params=null,this.getEncodedHexPrepare=function(){var i=new n.TSTInfo(this.params.econtent.content);this.params.econtent.content.hex=i.tohex()},e!=null&&this.setByParam(e)};pe(w.asn1.tsp.TimeStampToken,w.asn1.cms.SignedData);w.asn1.tsp.TSTInfo=function(e){var t=Error,r=w,n=r.asn1,i=n.DERSequence,a=n.DERInteger,s=n.DERBoolean,u=n.DERGeneralizedTime,l=n.DERObjectIdentifier,f=n.DERTaggedObject,d=n.tsp,g=d.MessageImprint,p=d.Accuracy,h=n.x509.X500Name,E=n.x509.GeneralName;if(d.TSTInfo.superclass.constructor.call(this),this.dVersion=new a({int:1}),this.dPolicy=null,this.dMessageImprint=null,this.dSerial=null,this.dGenTime=null,this.dAccuracy=null,this.dOrdering=null,this.dNonce=null,this.dTsa=null,this.tohex=function(){var v=[this.dVersion];if(this.dPolicy==null)throw new Error("policy shall be specified.");if(v.push(this.dPolicy),this.dMessageImprint==null)throw new Error("messageImprint shall be specified.");if(v.push(this.dMessageImprint),this.dSerial==null)throw new Error("serialNumber shall be specified.");if(v.push(this.dSerial),this.dGenTime==null)throw new Error("genTime shall be specified.");v.push(this.dGenTime),this.dAccuracy!=null&&v.push(this.dAccuracy),this.dOrdering!=null&&v.push(this.dOrdering),this.dNonce!=null&&v.push(this.dNonce),this.dTsa!=null&&v.push(this.dTsa);var b=new i({array:v});return this.hTLV=b.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 g(e.messageImprint)),e.serial!==void 0&&(this.dSerial=new a(e.serial)),e.genTime!==void 0&&(this.dGenTime=new u(e.genTime)),e.accuracy!==void 0&&(this.dAccuracy=new p(e.accuracy)),e.ordering!==void 0&&e.ordering==!0&&(this.dOrdering=new s),e.nonce!==void 0&&(this.dNonce=new a(e.nonce)),e.tsa!==void 0&&(this.dTsa=new f({tag:"a0",explicit:!0,obj:new E({dn:e.tsa})}))}};pe(w.asn1.tsp.TSTInfo,w.asn1.ASN1Object);w.asn1.tsp.Accuracy=function(e){var t=w,r=t.asn1,n=r.ASN1Util.newObject;r.tsp.Accuracy.superclass.constructor.call(this),this.params=null,this.tohex=function(){var i=this.params,a=[];return i.seconds!=null&&typeof i.seconds=="number"&&a.push({int:i.seconds}),i.millis!=null&&typeof i.millis=="number"&&a.push({tag:{tagi:"80",obj:{int:i.millis}}}),i.micros!=null&&typeof i.micros=="number"&&a.push({tag:{tagi:"81",obj:{int:i.micros}}}),n({seq:a}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};pe(w.asn1.tsp.Accuracy,w.asn1.ASN1Object);w.asn1.tsp.MessageImprint=function(e){var t=w,r=t.asn1,n=r.DERSequence,i=r.DEROctetString,a=r.x509,s=a.AlgorithmIdentifier;r.tsp.MessageImprint.superclass.constructor.call(this),this.params=null,this.tohex=function(){var u=this.params,l=new s({name:u.alg}),f=new i({hex:u.hash}),d=new n({array:[l,f]});return d.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};pe(w.asn1.tsp.MessageImprint,w.asn1.ASN1Object);w.asn1.tsp.TimeStampReq=function(e){var t=w,r=t.asn1,n=r.DERSequence,i=r.DERInteger,a=r.DERBoolean,s=r.ASN1Object,u=r.DERObjectIdentifier,l=r.tsp,f=l.MessageImprint;l.TimeStampReq.superclass.constructor.call(this),this.params=null,this.tohex=function(){var d=this.params,g=[];g.push(new i({int:1})),d.messageImprint instanceof w.asn1.ASN1Object?g.push(d.messageImprint):g.push(new f(d.messageImprint)),d.policy!=null&&g.push(new u(d.policy)),d.nonce!=null&&g.push(new i(d.nonce)),d.certreq==!0&&g.push(new a);var p=new n({array:g});return p.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};pe(w.asn1.tsp.TimeStampReq,w.asn1.ASN1Object);w.asn1.tsp.TimeStampResp=function(e){var t=w,r=t.asn1,n=r.DERSequence,i=r.ASN1Object,a=r.tsp,s=a.PKIStatusInfo;a.TimeStampResp.superclass.constructor.call(this),this.params=null,this.tohex=function(){var u=this.params,l=[];if(u.econtent!=null||u.tst!=null)if(u.statusinfo!=null?l.push(new s(u.statusinfo)):l.push(new s("granted")),u.econtent!=null)l.push(new a.TimeStampToken(u).getContentInfo());else if(u.tst instanceof r.ASN1Object)l.push(u.tst);else throw new Error("improper member tst value");else if(u.statusinfo!=null)l.push(new s(u.statusinfo));else throw new Error("parameter for token nor statusinfo not specified");var f=new n({array:l});return f.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};pe(w.asn1.tsp.TimeStampResp,w.asn1.ASN1Object);w.asn1.tsp.PKIStatusInfo=function(e){var t=Error,r=w,n=r.asn1,i=n.DERSequence,a=n.tsp,s=a.PKIStatus,u=a.PKIFreeText,l=a.PKIFailureInfo;a.PKIStatusInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var f=this.params,d=[];if(typeof f=="string")d.push(new s(f));else{if(f.status==null)throw new t("property 'status' unspecified");d.push(new s(f.status)),f.statusstr!=null&&d.push(new u(f.statusstr)),f.failinfo!=null&&d.push(new l(f.failinfo))}var g=new i({array:d});return g.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};pe(w.asn1.tsp.PKIStatusInfo,w.asn1.ASN1Object);w.asn1.tsp.PKIStatus=function(e){var t=Error,r=w,n=r.asn1,i=n.DERInteger,a=n.tsp;a.PKIStatus.superclass.constructor.call(this);var s={granted:0,grantedWithMods:1,rejection:2,waiting:3,revocationWarning:4,revocationNotification:5};this.params=null,this.tohex=function(){var u=this.params,l,f;if(typeof u=="string")try{f=s[u]}catch{throw new t("undefined name: "+u)}else if(typeof u=="number")f=u;else throw new t("unsupported params");return new i({int:f}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};pe(w.asn1.tsp.PKIStatus,w.asn1.ASN1Object);w.asn1.tsp.PKIFreeText=function(e){var t=Error,r=w,n=r.asn1,i=n.DERSequence,a=n.DERUTF8String,s=n.tsp;s.PKIFreeText.superclass.constructor.call(this),this.params=null,this.tohex=function(){var u=this.params;if(!u instanceof Array)throw new t("wrong params: not array");for(var l=[],f=0;f=0;p--)g+=d[p];return g}else{if(typeof l=="string"&&u[l]!=null)return V0([l],u);if(typeof l=="object"&&l.length!=null)return V0(l,u);throw new t("wrong params")}},this.tohex=function(){var l=this.params,f=this.getBinValue();return new i({bin:f}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};pe(w.asn1.tsp.PKIFailureInfo,w.asn1.ASN1Object);w.asn1.tsp.AbstractTSAAdapter=function(e){this.getTSTHex=function(t,r){throw"not implemented yet"}};w.asn1.tsp.SimpleTSAAdapter=function(e){var t=w,r=t.asn1,n=r.tsp,i=t.crypto.Util.hashHex;n.SimpleTSAAdapter.superclass.constructor.call(this),this.params=null,this.serial=0,this.getTSTHex=function(a,s){var u=i(a,s);this.params.econtent.content.messageImprint={alg:s,hash:u},this.params.econtent.content.serial={int:this.serial++};var l=Math.floor(Math.random()*1e9);this.params.econtent.content.nonce={int:l};var f=new n.TimeStampToken(this.params);return f.getContentInfoEncodedHex()},e!==void 0&&(this.params=e)};pe(w.asn1.tsp.SimpleTSAAdapter,w.asn1.tsp.AbstractTSAAdapter);w.asn1.tsp.FixedTSAAdapter=function(e){var t=w,r=t.asn1,n=r.tsp,i=t.crypto.Util.hashHex;n.FixedTSAAdapter.superclass.constructor.call(this),this.params=null,this.getTSTHex=function(a,s){var u=i(a,s);this.params.econtent.content.messageImprint={alg:s,hash:u};var l=new n.TimeStampToken(this.params);return l.getContentInfoEncodedHex()},e!==void 0&&(this.params=e)};pe(w.asn1.tsp.FixedTSAAdapter,w.asn1.tsp.AbstractTSAAdapter);w.asn1.tsp.TSPUtil=new function(){};w.asn1.tsp.TSPUtil.newTimeStampToken=function(e){return new w.asn1.tsp.TimeStampToken(e)};w.asn1.tsp.TSPUtil.parseTimeStampReq=function(e){var t=new w.asn1.tsp.TSPParser;return t.getTimeStampReq(e)};w.asn1.tsp.TSPUtil.parseMessageImprint=function(e){var t=new w.asn1.tsp.TSPParser;return t.getMessageImprint(e)};w.asn1.tsp.TSPParser=function(){var e=Error,t=Ge,r=new t,n=be,i=n.getV,a=n.getTLV,s=n.getIdxbyList,u=n.getTLVbyListEx,l=n.getChildIdx,f=["granted","grantedWithMods","rejection","waiting","revocationWarning","revocationNotification"],d={0:"badAlg",2:"badRequest",5:"badDataFormat",14:"timeNotAvailable",15:"unacceptedPolicy",16:"unacceptedExtension",17:"addInfoNotAvailable",25:"systemFailure"};this.getResponse=function(g){var p=l(g,0);if(p.length==1)return this.getPKIStatusInfo(a(g,p[0]));if(p.length>1){var h=this.getPKIStatusInfo(a(g,p[0])),E=a(g,p[1]),v=this.getToken(E);return v.statusinfo=h,v}},this.getToken=function(g){var p=new w.asn1.cms.CMSParser,h=p.getCMSSignedData(g);return this.setTSTInfo(h),h},this.setTSTInfo=function(g){var p=g.econtent;if(p.type=="tstinfo"){var h=p.content.hex,E=this.getTSTInfo(h);p.content=E}},this.getTSTInfo=function(g){var p={},h=l(g,0),E=i(g,h[1]);p.policy=Q0(E);var v=a(g,h[2]);p.messageImprint=this.getMessageImprint(v);var b=i(g,h[3]);p.serial={hex:b};var m=i(g,h[4]);p.genTime={str:Vt(m)};var y=0;if(h.length>5&&g.substr(h[5],2)=="30"){var D=a(g,h[5]);p.accuracy=this.getAccuracy(D),y++}if(h.length>5+y&&g.substr(h[5+y],2)=="01"){var C=i(g,h[5+y]);C=="ff"&&(p.ordering=!0),y++}if(h.length>5+y&&g.substr(h[5+y],2)=="02"){var F=i(g,h[5+y]);p.nonce={hex:F},y++}if(h.length>5+y&&g.substr(h[5+y],2)=="a0"){var L=a(g,h[5+y]);L="30"+L.substr(2),pGeneralNames=r.getGeneralNames(L);var k=pGeneralNames[0].dn;p.tsa=k,y++}if(h.length>5+y&&g.substr(h[5+y],2)=="a1"){var S=a(g,h[5+y]);S="30"+S.substr(2);var B=r.getExtParamArray(S);p.ext=B,y++}return p},this.getAccuracy=function(g){for(var p={},h=l(g,0),E=0;E1&&g.substr(h[1],2)=="30"){var m=a(g,h[1]);p.statusstr=this.getPKIFreeText(m),E++}if(h.length>E&&g.substr(h[1+E],2)=="03"){var y=a(g,h[1+E]);p.failinfo=this.getPKIFailureInfo(y)}return p},this.getPKIFreeText=function(g){for(var p=[],h=l(g,0),E=0;E"u"||!w)&&(w={});(typeof w.asn1>"u"||!w.asn1)&&(w.asn1={});(typeof w.asn1.cades>"u"||!w.asn1.cades)&&(w.asn1.cades={});w.asn1.cades.SignaturePolicyIdentifier=function(e){var t=w,r=t.asn1,n=r.cades,i=n.SignaturePolicyId;n.SignaturePolicyIdentifier.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.15",this.params=null,this.getValueArray=function(){return[new i(this.params)]},this.setByParam=function(a){this.params=a},e!=null&&this.setByParam(e)};pe(w.asn1.cades.SignaturePolicyIdentifier,w.asn1.cms.Attribute);w.asn1.cades.SignaturePolicyId=function(e){var t=w,r=t.asn1,n=r.DERSequence,i=r.DERObjectIdentifier,a=r.x509,s=a.AlgorithmIdentifier,u=r.cades,l=u.SignaturePolicyId,f=u.OtherHashAlgAndValue;l.superclass.constructor.call(this),this.params=null,this.tohex=function(){var d=this.params,g=[];g.push(new i(d.oid)),g.push(new f(d));var p=new n({array:g});return p.tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(d){this.params=d},e!=null&&this.setByParam(e)};pe(w.asn1.cades.SignaturePolicyId,w.asn1.ASN1Object);w.asn1.cades.OtherHashAlgAndValue=function(e){var t=Error,r=w,n=r.asn1,i=n.DERSequence,a=n.DEROctetString,s=n.x509,u=s.AlgorithmIdentifier,l=n.cades,f=l.OtherHashAlgAndValue;f.superclass.constructor.call(this),this.params=null,this.tohex=function(){var d=this.params;if(d.alg==null)throw new t("property 'alg' not specified");if(d.hash==null&&d.cert==null)throw new t("property 'hash' nor 'cert' not specified");var g=null;if(d.hash!=null)g=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=mr(d.cert)),g=w.crypto.Util.hashHex(p,d.alg)}var h=[];h.push(new u({name:d.alg})),h.push(new a({hex:g}));var E=new i({array:h});return E.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};pe(w.asn1.cades.OtherHashAlgAndValue,w.asn1.ASN1Object);w.asn1.cades.OtherHashValue=function(e){w.asn1.cades.OtherHashValue.superclass.constructor.call(this);var t=Error,r=w,n=r.lang.String.isHex,i=r.asn1,a=i.DEROctetString,s=r.crypto.Util.hashHex;this.params=null,this.tohex=function(){var u=this.params;if(u.hash==null&&u.cert==null)throw new t("hash or cert not specified");var l=null;if(u.hash!=null)l=u.hash;else if(u.cert!=null){if(typeof u.cert!="string")throw new t("cert not string");var f=u.cert;u.cert.indexOf("-----BEGIN")!=-1&&(f=mr(u.cert)),l=w.crypto.Util.hashHex(f,"sha1")}return new a({hex:l}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};pe(w.asn1.cades.OtherHashValue,w.asn1.ASN1Object);w.asn1.cades.SignatureTimeStamp=function(e){var t=Error,r=w,n=r.lang.String.isHex,i=r.asn1,a=i.ASN1Object,s=i.x509,u=i.cades;u.SignatureTimeStamp.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.14",this.params=null,this.getValueArray=function(){var l=this.params;if(l.tst!=null)if(n(l.tst)){var f=new a;return f.hTLV=l.tst,[f]}else{if(l.tst instanceof a)return[l.tst];throw new t("params.tst has wrong value")}else if(l.res!=null){var d=l.res;if(d instanceof a&&(d=d.tohex()),typeof d!="string"||!n(d))throw new t("params.res has wrong value");var g=be.getTLVbyList(d,0,[1]),f=new a;return f.hTLV=l.tst,[f]}},e!=null&&this.setByParam(e)};pe(w.asn1.cades.SignatureTimeStamp,w.asn1.cms.Attribute);w.asn1.cades.CompleteCertificateRefs=function(e){var t=Error,r=w,n=r.asn1,i=n.DERSequence,a=n.cades,s=a.OtherCertID,u=r.lang.String.isHex;a.CompleteCertificateRefs.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.21",this.params=null,this.getValueArray=function(){for(var l=this.params,f=[],d=0;d"u"||!w.asn1.csr)&&(w.asn1.csr={});w.asn1.csr.CertificationRequest=function(e){var t=w,r=t.asn1,n=r.DERBitString,i=r.DERSequence,a=r.csr,s=r.x509,u=a.CertificationRequestInfo;a.CertificationRequest.superclass.constructor.call(this),this.setByParam=function(l){this.params=l},this.sign=function(){var l=new u(this.params).tohex(),f=new w.crypto.Signature({alg:this.params.sigalg});f.init(this.params.sbjprvkey),f.updateHex(l);var d=f.sign();this.params.sighex=d},this.getPEM=function(){return Bn(this.tohex(),"CERTIFICATE REQUEST")},this.tohex=function(){var l=this.params,f=new w.asn1.csr.CertificationRequestInfo(this.params),d=new w.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 g=new n({hex:"00"+l.sighex}),p=new i({array:[f,d,g]});return p.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};pe(w.asn1.csr.CertificationRequest,w.asn1.ASN1Object);w.asn1.csr.CertificationRequestInfo=function(e){var t=w,r=t.asn1,n=r.DERBitString,i=r.DERSequence,a=r.DERInteger,s=r.DERUTF8String,u=r.DERTaggedObject,l=r.ASN1Util.newObject,f=r.csr,d=r.x509,g=d.X500Name,p=d.Extensions,h=d.SubjectPublicKeyInfo,E=f.AttributeList;f.CertificationRequestInfo.superclass.constructor.call(this),this.params=null,this.setByParam=function(b){b!=null&&(this.params=b)},this.tohex=function(){var b=this.params,m=[];if(m.push(new a({int:0})),m.push(new g(b.subject)),m.push(new h(At.getKey(b.sbjpubkey))),b.attrs!=null){var y=v(b.attrs),D=l({tag:{tage:"a0",obj:y}});m.push(D)}else if(b.extreq!=null){var C=new p(b.extreq),D=l({tag:{tage:"a0",obj:{seq:[{oid:"1.2.840.113549.1.9.14"},{set:[C]}]}}});m.push(D)}else m.push(new u({tag:"a0",explicit:!1,obj:new s({str:""})}));var F=new i({array:m});return F.tohex()},this.getEncodedHex=function(){return this.tohex()};function v(b){for(var m=Error,y=w.asn1.x509.Extensions,D=[],C=0;C"u"||!w)&&(w={});(typeof w.asn1>"u"||!w.asn1)&&(w.asn1={});(typeof w.asn1.ocsp>"u"||!w.asn1.ocsp)&&(w.asn1.ocsp={});w.asn1.ocsp.DEFAULT_HASH="sha1";w.asn1.ocsp.OCSPResponse=function(e){w.asn1.ocsp.OCSPResponse.superclass.constructor.call(this);var t=w.asn1.DEREnumerated,r=w.asn1.ASN1Util.newObject,n=w.asn1.ocsp.ResponseBytes,i=["successful","malformedRequest","internalError","tryLater","_not_used_","sigRequired","unauthorized"];this.params=null,this._getStatusCode=function(){var a=this.params.resstatus;return typeof a=="number"?a:typeof a!="string"?-1:i.indexOf(a)},this.setByParam=function(a){this.params=a},this.tohex=function(){var a=this.params,s=this._getStatusCode();if(s==-1)throw new Error("responseStatus not supported: "+a.resstatus);if(s!=0)return r({seq:[{enum:{int:s}}]}).tohex();var u=new n(a);return r({seq:[{enum:{int:0}},{tag:{tag:"a0",explicit:!0,obj:u}}]}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};pe(w.asn1.ocsp.OCSPResponse,w.asn1.ASN1Object);w.asn1.ocsp.ResponseBytes=function(e){w.asn1.ocsp.ResponseBytes.superclass.constructor.call(this);var t=w.asn1,r=t.DERSequence,n=t.DERObjectIdentifier,i=t.DEROctetString,a=t.ocsp.BasicOCSPResponse;this.params=null,this.setByParam=function(s){this.params=s},this.tohex=function(){var s=this.params;if(s.restype!="ocspBasic")throw new Error("not supported responseType: "+s.restype);var u=new a(s),l=[];l.push(new n({name:"ocspBasic"})),l.push(new i({hex:u.tohex()}));var f=new r({array:l});return f.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};pe(w.asn1.ocsp.ResponseBytes,w.asn1.ASN1Object);w.asn1.ocsp.BasicOCSPResponse=function(e){w.asn1.ocsp.BasicOCSPResponse.superclass.constructor.call(this);var t=Error,r=w.asn1,n=r.ASN1Object,i=r.DERSequence,a=r.DERGeneralizedTime,s=r.DERTaggedObject,u=r.DERBitString,l=r.x509.Extensions,f=r.x509.AlgorithmIdentifier,d=r.ocsp,g=d.ResponderID;_SingleResponseList=d.SingleResponseList,_ResponseData=d.ResponseData,this.params=null,this.setByParam=function(p){this.params=p},this.sign=function(){var p=this.params,h=p.tbsresp.tohex(),E=new w.crypto.Signature({alg:p.sigalg});E.init(p.reskey),E.updateHex(h),p.sighex=E.sign()},this.tohex=function(){var p=this.params;p.tbsresp==null&&(p.tbsresp=new _ResponseData(p)),p.sighex==null&&p.reskey!=null&&this.sign();var h=[];if(h.push(p.tbsresp),h.push(new f({name:p.sigalg})),h.push(new u({hex:"00"+p.sighex})),p.certs!=null&&p.certs.length!=null){for(var E=[],v=0;v"u"||!w)&&(w={});(typeof w.lang>"u"||!w.lang)&&(w.lang={});w.lang.String=function(){};function wy(e){for(var t=new Array,r=0;r>6,l=128|s&63;return Vt(u.toString(16)+l.toString(16))}var u=224|(a&240)>>4,l=128|(a&15)<<2|(s&192)>>6,f=128|s&63;return Vt(u.toString(16)+l.toString(16)+f.toString(16))}var r=e.match(/.{4}/g),n=r.map(t);return n.join("")}function Z0(e){for(var t=encodeURIComponent(e),r="",n=0;n"7"?"00"+e:e}function YP(e){e=e.replace(/^\s*\[\s*/,""),e=e.replace(/\s*\]\s*$/,""),e=e.replace(/\s*/g,"");try{var t=e.split(/,/).map(function(r,n,i){var a=parseInt(r);if(a<0||255t.length&&(r=t.length);for(var n=0;n0&&(f=f+"."+u.join(".")),f}catch{return null}}function Fy(e){var t=new ee(String(e),10);return vf(t)}function vf(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 Sy(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 Iy(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+q0("",r,"0");var n=parseInt(t,2).toString(16);n.length%2==1&&(n="0"+n);var i="0"+r;return i+n}function By(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 Zt(e,n,r){if(typeof e=="object"){for(var n=String(n).split("."),i=0;i"u"||!w)&&(w={});(typeof w.crypto>"u"||!w.crypto)&&(w.crypto={});w.crypto.Util=new function(){this.DIGESTINFOHEAD={sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",ripemd160:"3021300906052b2403020105000414"},this.DEFAULTPROVIDER={md5:"cryptojs",sha1:"cryptojs",sha224:"cryptojs",sha256:"cryptojs",sha384:"cryptojs",sha512:"cryptojs",ripemd160:"cryptojs",hmacmd5:"cryptojs",hmacsha1:"cryptojs",hmacsha224:"cryptojs",hmacsha256:"cryptojs",hmacsha384:"cryptojs",hmacsha512:"cryptojs",hmacripemd160:"cryptojs",MD5withRSA:"cryptojs/jsrsa",SHA1withRSA:"cryptojs/jsrsa",SHA224withRSA:"cryptojs/jsrsa",SHA256withRSA:"cryptojs/jsrsa",SHA384withRSA:"cryptojs/jsrsa",SHA512withRSA:"cryptojs/jsrsa",RIPEMD160withRSA:"cryptojs/jsrsa",MD5withECDSA:"cryptojs/jsrsa",SHA1withECDSA:"cryptojs/jsrsa",SHA224withECDSA:"cryptojs/jsrsa",SHA256withECDSA:"cryptojs/jsrsa",SHA384withECDSA:"cryptojs/jsrsa",SHA512withECDSA:"cryptojs/jsrsa",RIPEMD160withECDSA:"cryptojs/jsrsa",SHA1withDSA:"cryptojs/jsrsa",SHA224withDSA:"cryptojs/jsrsa",SHA256withDSA:"cryptojs/jsrsa",MD5withRSAandMGF1:"cryptojs/jsrsa",SHAwithRSAandMGF1:"cryptojs/jsrsa",SHA1withRSAandMGF1:"cryptojs/jsrsa",SHA224withRSAandMGF1:"cryptojs/jsrsa",SHA256withRSAandMGF1:"cryptojs/jsrsa",SHA384withRSAandMGF1:"cryptojs/jsrsa",SHA512withRSAandMGF1:"cryptojs/jsrsa",RIPEMD160withRSAandMGF1:"cryptojs/jsrsa"},this.CRYPTOJSMESSAGEDIGESTNAME={md5:Se.algo.MD5,sha1:Se.algo.SHA1,sha224:Se.algo.SHA224,sha256:Se.algo.SHA256,sha384:Se.algo.SHA384,sha512:Se.algo.SHA512,ripemd160:Se.algo.RIPEMD160},this.getDigestInfoHex=function(e,t){if(typeof this.DIGESTINFOHEAD[t]>"u")throw"alg not supported in Util.DIGESTINFOHEAD: "+t;return this.DIGESTINFOHEAD[t]+e},this.getPaddedDigestInfoHex=function(e,t,r){var n=this.getDigestInfoHex(e,t),i=r/4;if(n.length+22>i)throw"key is too short for SigAlg: keylen="+r+","+t;for(var a="0001",s="00"+n,u="",l=i-a.length-s.length,f=0;f"u"||!w)&&(w={});(typeof w.crypto>"u"||!w.crypto)&&(w.crypto={});w.crypto.ECDSA=function(e){var t="secp256r1",r=null,n=null,i=null,a=Error,s=ee,u=kt,l=w.crypto.ECDSA,f=w.crypto.ECParameterDB,d=l.getName,g=be,p=g.getVbyListEx,h=g.isASN1HEX,E=new Vl,v=null;this.type="EC",this.isPrivate=!1,this.isPublic=!1;function b(m,y,D,C){for(var F=Math.max(y.bitLength(),C.bitLength()),L=m.add2D(D),k=m.curve.getInfinity(),S=F-1;S>=0;--S)k=k.twice2D(),k.z=s.ONE,y.testBit(S)?C.testBit(S)?k=k.add2D(L):k=k.add2D(m):C.testBit(S)&&(k=k.add2D(D));return k}this.getBigRandom=function(m){return new s(m.bitLength(),E).mod(m.subtract(s.ONE)).add(s.ONE)},this.setNamedCurve=function(m){this.ecparams=f.getByName(m),this.prvKeyHex=null,this.pubKeyHex=null,this.curveName=m},this.setPrivateKeyHex=function(m){this.isPrivate=!0,this.prvKeyHex=m},this.setPublicKeyHex=function(m){this.isPublic=!0,this.pubKeyHex=m},this.getPublicKeyXYHex=function(){var m=this.pubKeyHex;if(m.substr(0,2)!=="04")throw"this method supports uncompressed format(04) only";var y=this.ecparams.keycharlen;if(m.length!==2+y*2)throw"malformed public key hex length";var D={};return D.x=m.substr(2,y),D.y=m.substr(2+y),D},this.getShortNISTPCurveName=function(){var m=this.curveName;return m==="secp256r1"||m==="NIST P-256"||m==="P-256"||m==="prime256v1"?"P-256":m==="secp384r1"||m==="NIST P-384"||m==="P-384"?"P-384":m==="secp521r1"||m==="NIST P-521"||m==="P-521"?"P-521":null},this.generateKeyPairHex=function(){var m=this.ecparams.n,y=this.getBigRandom(m),D=this.ecparams.keycharlen,C=("0000000000"+y.toString(16)).slice(-D);this.setPrivateKeyHex(C);var F=this.generatePublicKeyHex();return{ecprvhex:C,ecpubhex:F}},this.generatePublicKeyHex=function(){var m=new s(this.prvKeyHex,16),y=this.ecparams.G.multiply(m),D=y.getX().toBigInteger(),C=y.getY().toBigInteger(),F=this.ecparams.keycharlen,L=("0000000000"+D.toString(16)).slice(-F),k=("0000000000"+C.toString(16)).slice(-F),S="04"+L+k;return this.setPublicKeyHex(S),S},this.signWithMessageHash=function(m){return this.signHex(m,this.prvKeyHex)},this.signHex=function(m,y){var D=new s(y,16),C=this.ecparams.n,F=new s(m.substring(0,this.ecparams.keycharlen),16);do var L=this.getBigRandom(C),k=this.ecparams.G,S=k.multiply(L),B=S.getX().toBigInteger().mod(C);while(B.compareTo(s.ZERO)<=0);var O=L.modInverse(C).multiply(F.add(D.multiply(B))).mod(C);return l.biRSSigToASN1Sig(B,O)},this.sign=function(m,y){var D=y,C=this.ecparams.n,F=s.fromByteArrayUnsigned(m);do var L=this.getBigRandom(C),k=this.ecparams.G,S=k.multiply(L),B=S.getX().toBigInteger().mod(C);while(B.compareTo(ee.ZERO)<=0);var O=L.modInverse(C).multiply(F.add(D.multiply(B))).mod(C);return this.serializeSig(B,O)},this.verifyWithMessageHash=function(m,y){return this.verifyHex(m,y,this.pubKeyHex)},this.verifyHex=function(m,y,D){try{var C,F,L=l.parseSigHex(y);C=L.r,F=L.s;var k=u.decodeFromHex(this.ecparams.curve,D),S=new s(m.substring(0,this.ecparams.keycharlen),16);return this.verifyRaw(S,C,F,k)}catch{return!1}},this.verify=function(m,y,D){var C,F;if(Bitcoin.Util.isArray(y)){var L=this.parseSig(y);C=L.r,F=L.s}else if(typeof y=="object"&&y.r&&y.s)C=y.r,F=y.s;else throw"Invalid value for signature";var k;if(D instanceof kt)k=D;else if(Bitcoin.Util.isArray(D))k=u.decodeFrom(this.ecparams.curve,D);else throw"Invalid format for pubkey value, must be byte array or ECPointFp";var S=s.fromByteArrayUnsigned(m);return this.verifyRaw(S,C,F,k)},this.verifyRaw=function(m,y,D,C){var F=this.ecparams.n,L=this.ecparams.G;if(y.compareTo(s.ONE)<0||y.compareTo(F)>=0||D.compareTo(s.ONE)<0||D.compareTo(F)>=0)return!1;var k=D.modInverse(F),S=m.multiply(k).mod(F),B=y.multiply(k).mod(F),O=L.multiply(S).add(C.multiply(B)),P=O.getX().toBigInteger().mod(F);return P.equals(y)},this.serializeSig=function(m,y){var D=m.toByteArraySigned(),C=y.toByteArraySigned(),F=[];return F.push(2),F.push(D.length),F=F.concat(D),F.push(2),F.push(C.length),F=F.concat(C),F.unshift(F.length),F.unshift(48),F},this.parseSig=function(m){var y;if(m[0]!=48)throw new Error("Signature not a valid DERSequence");if(y=2,m[y]!=2)throw new Error("First element in signature must be a DERInteger");var D=m.slice(y+2,y+2+m[y+1]);if(y+=2+m[y+1],m[y]!=2)throw new Error("Second element in signature must be a DERInteger");var C=m.slice(y+2,y+2+m[y+1]);y+=2+m[y+1];var F=s.fromByteArrayUnsigned(D),L=s.fromByteArrayUnsigned(C);return{r:F,s:L}},this.parseSigCompact=function(m){if(m.length!==65)throw"Signature has the wrong length";var y=m[0]-27;if(y<0||y>7)throw"Invalid signature type";var D=this.ecparams.n,C=s.fromByteArrayUnsigned(m.slice(1,33)).mod(D),F=s.fromByteArrayUnsigned(m.slice(33,65)).mod(D);return{r:C,s:F,i:y}},this.readPKCS5PrvKeyHex=function(m){if(h(m)===!1)throw new Error("not ASN.1 hex string");var y,D,C;try{y=p(m,0,["[0]",0],"06"),D=p(m,0,[1],"04");try{C=p(m,0,["[1]",0],"03")}catch{}}catch{throw new Error("malformed PKCS#1/5 plain ECC private key")}if(this.curveName=d(y),this.curveName===void 0)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(C),this.setPrivateKeyHex(D),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(m){if(h(m)===!1)throw new a("not ASN.1 hex string");var y,D,C,F;try{y=p(m,0,[1,0],"06"),D=p(m,0,[1,1],"06"),C=p(m,0,[2,0,1],"04");try{F=p(m,0,[2,0,"[1]",0],"03")}catch{}}catch{throw new a("malformed PKCS#8 plain ECC private key")}if(this.curveName=d(D),this.curveName===void 0)throw new a("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(F),this.setPrivateKeyHex(C),this.isPublic=!1},this.readPKCS8PubKeyHex=function(m){if(h(m)===!1)throw new a("not ASN.1 hex string");var y,D,C;try{y=p(m,0,[0,0],"06"),D=p(m,0,[0,1],"06"),C=p(m,0,[1],"03")}catch{throw new a("malformed PKCS#8 ECC public key")}if(this.curveName=d(D),this.curveName===null)throw new a("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(C)},this.readCertPubKeyHex=function(m,y){if(h(m)===!1)throw new a("not ASN.1 hex string");var D,C;try{D=p(m,0,[0,5,0,1],"06"),C=p(m,0,[0,5,1],"03")}catch{throw new a("malformed X.509 certificate ECC public key")}if(this.curveName=d(D),this.curveName===null)throw new a("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(C)},e!==void 0&&e.curve!==void 0&&(this.curveName=e.curve),this.curveName===void 0&&(this.curveName=t),this.setNamedCurve(this.curveName),e!==void 0&&(e.prv!==void 0&&this.setPrivateKeyHex(e.prv),e.pub!==void 0&&this.setPublicKeyHex(e.pub))};w.crypto.ECDSA.parseSigHex=function(e){var t=w.crypto.ECDSA.parseSigHexInHexRS(e),r=new ee(t.r,16),n=new ee(t.s,16);return{r,s:n}};w.crypto.ECDSA.parseSigHexInHexRS=function(e){var t=be,r=t.getChildIdx,n=t.getV;if(t.checkStrictDER(e,0),e.substr(0,2)!="30")throw new Error("signature is not a ASN.1 sequence");var i=r(e,0);if(i.length!=2)throw new Error("signature shall have two elements");var a=i[0],s=i[1];if(e.substr(a,2)!="02")throw new Error("1st item not ASN.1 integer");if(e.substr(s,2)!="02")throw new Error("2nd item not ASN.1 integer");var u=n(e,a),l=n(e,s);return{r:u,s:l}};w.crypto.ECDSA.asn1SigToConcatSig=function(e){var t=w.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};w.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 w.crypto.ECDSA.hexRSSigToASN1Sig(t,r)};w.crypto.ECDSA.hexRSSigToASN1Sig=function(e,t){var r=new ee(e,16),n=new ee(t,16);return w.crypto.ECDSA.biRSSigToASN1Sig(r,n)};w.crypto.ECDSA.biRSSigToASN1Sig=function(e,t){var r=w.asn1,n=new r.DERInteger({bigint:e}),i=new r.DERInteger({bigint:t}),a=new r.DERSequence({array:[n,i]});return a.tohex()};w.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 w>"u"||!w)&&(w={});(typeof w.crypto>"u"||!w.crypto)&&(w.crypto={});w.crypto.ECParameterDB=new function(){var e={},t={};function r(n){return new ee(n,16)}this.getByName=function(n){var i=n;if(typeof t[i]<"u"&&(i=t[n]),typeof e[i]<"u")return e[i];throw"unregistered EC curve name: "+i},this.regist=function(n,i,a,s,u,l,f,d,g,p,h,E){e[n]={};var v=r(a),b=r(s),m=r(u),y=r(l),D=r(f),C=new Wa(v,b,m),F=C.decodePointHex("04"+d+g);e[n].name=n,e[n].keylen=i,e[n].keycharlen=Math.ceil(i/8)*2,e[n].curve=C,e[n].G=F,e[n].n=y,e[n].h=D,e[n].oid=h,e[n].info=E;for(var L=0;L"u"||!w)&&(w={});(typeof w.crypto>"u"||!w.crypto)&&(w.crypto={});w.crypto.DSA=function(){var e=be,t=e.getVbyList,r=e.getVbyListEx,n=e.isASN1HEX,i=ee;this.p=null,this.q=null,this.g=null,this.y=null,this.x=null,this.type="DSA",this.isPrivate=!1,this.isPublic=!1,this.setPrivate=function(a,s,u,l,f){this.isPrivate=!0,this.p=a,this.q=s,this.g=u,this.y=l,this.x=f},this.setPrivateHex=function(a,s,u,l,f){var d,g,p,h,E;d=new ee(a,16),g=new ee(s,16),p=new ee(u,16),typeof l=="string"&&l.length>1?h=new ee(l,16):h=null,E=new ee(f,16),this.setPrivate(d,g,p,h,E)},this.setPublic=function(a,s,u,l){this.isPublic=!0,this.p=a,this.q=s,this.g=u,this.y=l,this.x=null},this.setPublicHex=function(a,s,u,l){var f,d,g,p;f=new ee(a,16),d=new ee(s,16),g=new ee(u,16),p=new ee(l,16),this.setPublic(f,d,g,p)},this.signWithMessageHash=function(a){var s=this.p,u=this.q,l=this.g,f=this.y,d=this.x,g=w.crypto.Util.getRandomBigIntegerMinToMax(ee.ONE.add(ee.ONE),u.subtract(ee.ONE)),p=a.substr(0,u.bitLength()/4),h=new ee(p,16),E=l.modPow(g,s).mod(u),v=g.modInverse(u).multiply(h.add(d.multiply(E))).mod(u),b=w.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:E}},{int:{bigint:v}}]});return b},this.verifyWithMessageHash=function(a,s){var u=this.p,l=this.q,f=this.g,d=this.y,g=this.parseASN1Signature(s),p=g[0],h=g[1],E=a.substr(0,l.bitLength()/4),v=new ee(E,16);if(ee.ZERO.compareTo(p)>0||p.compareTo(l)>0||ee.ZERO.compareTo(h)>=0||h.compareTo(l)>0)throw"invalid DSA signature";var b=h.modInverse(l),m=v.multiply(b).mod(l),y=p.multiply(b).mod(l),D=f.modPow(m,u).multiply(d.modPow(y,u)).mod(u).mod(l);return D.compareTo(p)==0},this.parseASN1Signature=function(a){try{var s=new i(r(a,0,[0],"02"),16),u=new i(r(a,0,[1],"02"),16);return[s,u]}catch{throw new Error("malformed ASN.1 DSA signature")}},this.readPKCS5PrvKeyHex=function(a){var s,u,l,f,d;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{s=r(a,0,[1],"02"),u=r(a,0,[2],"02"),l=r(a,0,[3],"02"),f=r(a,0,[4],"02"),d=r(a,0,[5],"02")}catch{throw new Error("malformed PKCS#1/5 plain DSA private key")}this.setPrivateHex(s,u,l,f,d)},this.readPKCS8PrvKeyHex=function(a){var s,u,l,f;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{s=r(a,0,[1,1,0],"02"),u=r(a,0,[1,1,1],"02"),l=r(a,0,[1,1,2],"02"),f=r(a,0,[2,0],"02")}catch{throw new Error("malformed PKCS#8 plain DSA private key")}this.setPrivateHex(s,u,l,null,f)},this.readPKCS8PubKeyHex=function(a){var s,u,l,f;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{s=r(a,0,[0,1,0],"02"),u=r(a,0,[0,1,1],"02"),l=r(a,0,[0,1,2],"02"),f=r(a,0,[1,0],"02")}catch{throw new Error("malformed PKCS#8 DSA public key")}this.setPublicHex(s,u,l,f)},this.readCertPubKeyHex=function(a,s){var u,l,f,d;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{u=r(a,0,[0,5,0,1,0],"02"),l=r(a,0,[0,5,0,1,1],"02"),f=r(a,0,[0,5,0,1,2],"02"),d=r(a,0,[0,5,1,0],"02")}catch{throw new Error("malformed X.509 certificate DSA public key")}this.setPublicHex(u,l,f,d)}};var At=function(){var e=function(v,b,m){return n(Se.AES,v,b,m)},t=function(v,b,m){return n(Se.TripleDES,v,b,m)},r=function(v,b,m){return n(Se.DES,v,b,m)},n=function(v,b,m,y){var D=Se.enc.Hex.parse(b),C=Se.enc.Hex.parse(m),F=Se.enc.Hex.parse(y),L={};L.key=C,L.iv=F,L.ciphertext=D;var k=v.decrypt(L,C,{iv:F});return Se.enc.Hex.stringify(k)},i=function(v,b,m){return u(Se.AES,v,b,m)},a=function(v,b,m){return u(Se.TripleDES,v,b,m)},s=function(v,b,m){return u(Se.DES,v,b,m)},u=function(v,b,m,y){var D=Se.enc.Hex.parse(b),C=Se.enc.Hex.parse(m),F=Se.enc.Hex.parse(y),L=v.encrypt(D,C,{iv:F}),k=Se.enc.Hex.parse(L.toString()),S=Se.enc.Base64.stringify(k);return S},l={"AES-256-CBC":{proc:e,eproc:i,keylen:32,ivlen:16},"AES-192-CBC":{proc:e,eproc:i,keylen:24,ivlen:16},"AES-128-CBC":{proc:e,eproc:i,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:t,eproc:a,keylen:24,ivlen:8},"DES-CBC":{proc:r,eproc:s,keylen:8,ivlen:8}},f=function(v){return l[v].proc},d=function(v){var b=Se.lib.WordArray.random(v),m=Se.enc.Hex.stringify(b);return m},g=function(v){var b={},m=v.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));m&&(b.cipher=m[1],b.ivsalt=m[2]);var y=v.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));y&&(b.type=y[1]);var D=-1,C=0;v.indexOf(`\r \r `)!=-1&&(D=v.indexOf(`\r \r `),C=2),v.indexOf(` `)!=-1&&(D=v.indexOf(` `),C=1);var F=v.indexOf("-----END");if(D!=-1&&F!=-1){var L=v.substring(D+C*2,F-C);L=L.replace(/\s+/g,""),b.data=L}return b},p=function(v,b,m){for(var y=m.substring(0,16),D=Se.enc.Hex.parse(y),C=Se.enc.Utf8.parse(b),F=l[v].keylen+l[v].ivlen,L="",k=null;;){var S=Se.algo.MD5.create();if(k!=null&&S.update(k),S.update(C),S.update(D),k=S.finalize(),L=L+Se.enc.Hex.stringify(k),L.length>=F*2)break}var B={};return B.keyhex=L.substr(0,l[v].keylen*2),B.ivhex=L.substr(l[v].keylen*2,l[v].ivlen*2),B},h=function(v,b,m,y){var D=Se.enc.Base64.parse(v),C=Se.enc.Hex.stringify(D),F=l[b].proc,L=F(C,m,y);return L},E=function(v,b,m,y){var D=l[b].eproc,C=D(v,m,y);return C};return{version:"1.0.0",parsePKCS5PEM:function(v){return g(v)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(v,b,m){return p(v,b,m)},decryptKeyB64:function(v,b,m,y){return h(v,b,m,y)},getDecryptedKeyHex:function(v,b){var m=g(v),y=m.type,D=m.cipher,C=m.ivsalt,F=m.data,L=p(D,b,C),k=L.keyhex,S=h(F,D,k,C);return S},getEncryptedPKCS5PEMFromPrvKeyHex:function(v,b,m,y,D){var O="";if((typeof y>"u"||y==null)&&(y="AES-256-CBC"),typeof l[y]>"u")throw new Error("KEYUTIL unsupported algorithm: "+y);if(typeof D>"u"||D==null){var C=l[y].ivlen,F=d(C);D=F.toUpperCase()}var L=p(y,m,D),k=L.keyhex,S=E(b,y,k,D),B=S.replace(/(.{64})/g,`$1\r `),O="-----BEGIN "+v+` PRIVATE KEY-----\r `;return O+=`Proc-Type: 4,ENCRYPTED\r `,O+="DEK-Info: "+y+","+D+`\r `,O+=`\r `,O+=B,O+=`\r -----END `+v+` PRIVATE KEY-----\r `,O},getEncryptedPKCS8PEM:function(v,b,m){var y=this.getEncryptedPKCS8Hex(v,b,m);return Bn(y,"ENCRYPTED PRIVATE KEY")},getEncryptedPKCS8Hex:function(v,b,m){var y;m==null||m==null?y={}:y=JSON.parse(JSON.stringify(m)),y.plain=v,this.initPBES2Param(y),this.encryptPBES2Param(y,b);var D=this.generatePBES2ASN1Param(y);return w.asn1.ASN1Util.newObject(D).tohex()},initPBES2Param:function(v){if(Zt(v,"encalg")==null&&(v.encalg="aes256-CBC"),Zt(v,"iter")==null&&(v.iter=2048),Zt(v,"prf")==null&&(v.prf="hmacWithSHA256"),Zt(v,"salt")==null&&(v.salt=Se.enc.Hex.stringify(Se.lib.WordArray.random(8))),Zt(v,"enciv")==null){var b;v.encalg=="des-EDE3-CBC"&&(b=8),v.encalg=="aes128-CBC"&&(b=16),v.encalg=="aes256-CBC"&&(b=16),v.enciv=Se.enc.Hex.stringify(Se.lib.WordArray.random(b))}},encryptPBES2Param:function(v,b){var m=At.getDKFromPBES2Param(v,b);try{var y=w.crypto.Cipher.encrypt(v.plain,m,v.encalg,{iv:v.enciv})}catch{throw new Error("encrypt error: "+v.plain+" "+m+" "+v.encalg+" "+v.enciv)}v.enc=y},generatePBES2ASN1Param:function(v){var b={seq:[{seq:[{oid:"pkcs5PBES2"},{seq:[{seq:[{oid:"pkcs5PBKDF2"},{seq:[{octstr:{hex:v.salt}},{int:{hex:Fy(v.iter)}}]}]},{seq:[{oid:v.encalg},{octstr:{hex:v.enciv}}]}]}]},{octstr:{hex:v.enc}}]};return v.prf!="hmacWithSHA1"&&b.seq[0].seq[1].seq[0].seq[1].seq.push({seq:[{oid:v.prf},{null:""}]}),b},parseHexOfEncryptedPKCS8:function(v){var b=be,m=b.getChildIdx,y=b.getV,D={},C=m(v,0);if(C.length!=2)throw new Error("malformed format: SEQUENCE(0).items != 2: "+C.length);D.ciphertext=y(v,C[1]);var F=m(v,C[0]);if(F.length!=2)throw new Error("malformed format: SEQUENCE(0.0).items != 2: "+F.length);if(y(v,F[0])!="2a864886f70d01050d")throw new Error("this only supports pkcs5PBES2");var L=m(v,F[1]);if(F.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1).items != 2: "+L.length);var k=m(v,L[1]);if(k.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1.1).items != 2: "+k.length);if(y(v,k[0])!="2a864886f70d0307")throw"this only supports TripleDES";D.encryptionSchemeAlg="TripleDES",D.encryptionSchemeIV=y(v,k[1]);var S=m(v,L[0]);if(S.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1.0).items != 2: "+S.length);if(y(v,S[0])!="2a864886f70d01050c")throw new Error("this only supports pkcs5PBKDF2");var B=m(v,S[1]);if(B.length<2)throw new Error("malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+B.length);D.pbkdf2Salt=y(v,B[0]);var O=y(v,B[1]);try{D.pbkdf2Iter=parseInt(O,16)}catch{throw new Error("malformed format pbkdf2Iter: "+O)}return D},getPBKDF2KeyHexFromParam:function(v,b){var m=Se.enc.Hex.parse(v.pbkdf2Salt),y=v.pbkdf2Iter,D=Se.PBKDF2(b,m,{keySize:192/32,iterations:y}),C=Se.enc.Hex.stringify(D);return C},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(v,b){var m=mr(v,"ENCRYPTED PRIVATE KEY"),y=this.parseHexOfEncryptedPKCS8(m),D=At.getPBKDF2KeyHexFromParam(y,b),C={};C.ciphertext=Se.enc.Hex.parse(y.ciphertext);var F=Se.enc.Hex.parse(D),L=Se.enc.Hex.parse(y.encryptionSchemeIV),k=Se.TripleDES.decrypt(C,F,{iv:L}),S=Se.enc.Hex.stringify(k);return S},parsePBES2:function(v){var b=be.parse(v);if(Zt(b,"seq.0.seq.0.oid")!="pkcs5PBES2"||Zt(b,"seq.0.seq.1.seq.0.seq.0.oid")!="pkcs5PBKDF2")throw new Error("not pkcs5PBES2 and pkcs5PBKDF2 used");var m=Zt(b,"seq.0.seq.1.seq.0.seq.1.seq");if(m==null)throw new Error("PBKDF2 parameter not found");var y=Zt(m,"0.octstr.hex"),D=Zt(m,"1.int.hex"),C=Zt(m,"2.seq.0.oid","hmacWithSHA1"),F=-1;try{F=parseInt(D,16)}catch{throw new Error("iter not proper value")}var L=Zt(b,"seq.0.seq.1.seq.1.seq.0.oid"),k=Zt(b,"seq.0.seq.1.seq.1.seq.1.octstr.hex"),S=Zt(b,"seq.1.octstr.hex");if(L==null||k==null||S==null)throw new Error("encalg, enciv or enc is undefined");var B={salt:y,iter:F,prf:C,encalg:L,enciv:k,enc:S};return B},getDKFromPBES2Param:function(v,b){var m={hmacWithSHA1:Se.algo.SHA1,hmacWithSHA224:Se.algo.SHA224,hmacWithSHA256:Se.algo.SHA256,hmacWithSHA384:Se.algo.SHA384,hmacWithSHA512:Se.algo.SHA512},y={"des-EDE3-CBC":192/32,"aes128-CBC":128/32,"aes256-CBC":256/32},D=m[v.prf];if(D==null)throw new Error("unsupported prf");var C=y[v.encalg];if(C==null)throw new Error("unsupported encalg");var F=Se.enc.Hex.parse(v.salt),L=v.iter;try{var k=Se.PBKDF2(b,F,{keySize:C,iterations:L,hasher:D});return Se.enc.Hex.stringify(k)}catch(S){throw new Error("PBKDF2 error: "+S+" "+JSON.stringify(v)+" "+b)}},getPlainHexFromEncryptedPKCS8PEM:function(v,b){if(v.indexOf("BEGIN ENCRYPTED PRIVATE KEY")==-1)throw new Error("not Encrypted PKCS#8 PEM string");var m=mr(v),y;try{y=At.parsePBES2(m)}catch(C){throw new Error("malformed PBES2 format: "+C.message)}var D=At.getDKFromPBES2Param(y,b);return w.crypto.Cipher.decrypt(y.enc,D,y.encalg,{iv:y.enciv})},getKeyFromEncryptedPKCS8PEM:function(v,b){var m=this.getPlainHexFromEncryptedPKCS8PEM(v,b),y=this.getKeyFromPlainPrivatePKCS8Hex(m);return y},parsePlainPrivatePKCS8Hex:function(v){var b=be,m=b.getChildIdx,y=b.getV,D={};if(D.algparam=null,v.substr(0,2)!="30")throw new Error("malformed plain PKCS8 private key(code:001)");var C=m(v,0);if(C.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if(v.substr(C[1],2)!="30")throw new Error("malformed PKCS8 private key(code:003)");var F=m(v,C[1]);if(F.length!=2)throw new Error("malformed PKCS8 private key(code:004)");if(v.substr(F[0],2)!="06")throw new Error("malformed PKCS8 private key(code:005)");if(D.algoid=y(v,F[0]),v.substr(F[1],2)=="06"&&(D.algparam=y(v,F[1])),v.substr(C[2],2)!="04")throw new Error("malformed PKCS8 private key(code:006)");return D.keyidx=b.getVidx(v,C[2]),D},getKeyFromPlainPrivatePKCS8PEM:function(v){var b=mr(v,"PRIVATE KEY"),m=this.getKeyFromPlainPrivatePKCS8Hex(b);return m},getKeyFromPlainPrivatePKCS8Hex:function(v){var b=this.parsePlainPrivatePKCS8Hex(v),m;if(b.algoid=="2a864886f70d010101")m=new et;else if(b.algoid=="2a8648ce380401")m=new w.crypto.DSA;else if(b.algoid=="2a8648ce3d0201")m=new w.crypto.ECDSA;else throw new Error("unsupported private key algorithm");return m.readPKCS8PrvKeyHex(v),m},_getKeyFromPublicPKCS8Hex:function(v){var b,m=be.getVbyList(v,0,[0,0],"06");if(m==="2a864886f70d010101")b=new et;else if(m==="2a8648ce380401")b=new w.crypto.DSA;else if(m==="2a8648ce3d0201")b=new w.crypto.ECDSA;else throw new Error("unsupported PKCS#8 public key hex");return b.readPKCS8PubKeyHex(v),b},parsePublicRawRSAKeyHex:function(v){var b=be,m=b.getChildIdx,y=b.getV,D={};if(v.substr(0,2)!="30")throw new Error("malformed RSA key(code:001)");var C=m(v,0);if(C.length!=2)throw new Error("malformed RSA key(code:002)");if(v.substr(C[0],2)!="02")throw new Error("malformed RSA key(code:003)");if(D.n=y(v,C[0]),v.substr(C[1],2)!="02")throw new Error("malformed RSA key(code:004)");return D.e=y(v,C[1]),D},parsePublicPKCS8Hex:function(v){var b=be,m=b.getChildIdx,y=b.getV,D={};D.algparam=null;var C=m(v,0);if(C.length!=2)throw new Error("outer DERSequence shall have 2 elements: "+C.length);var F=C[0];if(v.substr(F,2)!="30")throw new Error("malformed PKCS8 public key(code:001)");var L=m(v,F);if(L.length!=2)throw new Error("malformed PKCS8 public key(code:002)");if(v.substr(L[0],2)!="06")throw new Error("malformed PKCS8 public key(code:003)");if(D.algoid=y(v,L[0]),v.substr(L[1],2)=="06"?D.algparam=y(v,L[1]):v.substr(L[1],2)=="30"&&(D.algparam={},D.algparam.p=b.getVbyList(v,L[1],[0],"02"),D.algparam.q=b.getVbyList(v,L[1],[1],"02"),D.algparam.g=b.getVbyList(v,L[1],[2],"02")),v.substr(C[1],2)!="03")throw new Error("malformed PKCS8 public key(code:004)");return D.key=y(v,C[1]).substr(2),D}}}();At.getKey=function(e,t,r){var n=be,i=n.getChildIdx,a=n.getV,s=n.getVbyList,u=w.crypto,l=u.ECDSA,f=u.DSA,d=et,g=mr,p=At;if(typeof d<"u"&&e instanceof d||typeof l<"u"&&e instanceof l||typeof f<"u"&&e instanceof f)return e;if(e.curve!==void 0&&e.xy!==void 0&&e.d===void 0)return new l({pub:e.xy,curve:e.curve});if(e.curve!==void 0&&e.d!==void 0)return new l({prv:e.d,curve:e.curve});if(e.kty===void 0&&e.n!==void 0&&e.e!==void 0&&e.d===void 0){var h=new d;return h.setPublic(e.n,e.e),h}if(e.kty===void 0&&e.n!==void 0&&e.e!==void 0&&e.d!==void 0&&e.p!==void 0&&e.q!==void 0&&e.dp!==void 0&&e.dq!==void 0&&e.co!==void 0&&e.qi===void 0){var h=new d;return h.setPrivateEx(e.n,e.e,e.d,e.p,e.q,e.dp,e.dq,e.co),h}if(e.kty===void 0&&e.n!==void 0&&e.e!==void 0&&e.d!==void 0&&e.p===void 0){var h=new d;return h.setPrivate(e.n,e.e,e.d),h}if(e.p!==void 0&&e.q!==void 0&&e.g!==void 0&&e.y!==void 0&&e.x===void 0){var h=new f;return h.setPublic(e.p,e.q,e.g,e.y),h}if(e.p!==void 0&&e.q!==void 0&&e.g!==void 0&&e.y!==void 0&&e.x!==void 0){var h=new f;return h.setPrivate(e.p,e.q,e.g,e.y,e.x),h}if(e.kty==="RSA"&&e.n!==void 0&&e.e!==void 0&&e.d===void 0){var h=new d;return h.setPublic(lr(e.n),lr(e.e)),h}if(e.kty==="RSA"&&e.n!==void 0&&e.e!==void 0&&e.d!==void 0&&e.p!==void 0&&e.q!==void 0&&e.dp!==void 0&&e.dq!==void 0&&e.qi!==void 0){var h=new d;return h.setPrivateEx(lr(e.n),lr(e.e),lr(e.d),lr(e.p),lr(e.q),lr(e.dp),lr(e.dq),lr(e.qi)),h}if(e.kty==="RSA"&&e.n!==void 0&&e.e!==void 0&&e.d!==void 0){var h=new d;return h.setPrivate(lr(e.n),lr(e.e),lr(e.d)),h}if(e.kty==="EC"&&e.crv!==void 0&&e.x!==void 0&&e.y!==void 0&&e.d===void 0){var E=new l({curve:e.crv}),v=E.ecparams.keycharlen,b=("0000000000"+lr(e.x)).slice(-v),m=("0000000000"+lr(e.y)).slice(-v),y="04"+b+m;return E.setPublicKeyHex(y),E}if(e.kty==="EC"&&e.crv!==void 0&&e.x!==void 0&&e.y!==void 0&&e.d!==void 0){var E=new l({curve:e.crv}),v=E.ecparams.keycharlen,b=("0000000000"+lr(e.x)).slice(-v),m=("0000000000"+lr(e.y)).slice(-v),y="04"+b+m,D=("0000000000"+lr(e.d)).slice(-v);return E.setPublicKeyHex(y),E.setPrivateKeyHex(D),E}if(r==="pkcs5prv"){var C=e,n=be,F,h;if(F=i(C,0),F.length===9)h=new d,h.readPKCS5PrvKeyHex(C);else if(F.length===6)h=new f,h.readPKCS5PrvKeyHex(C);else if(F.length>2&&C.substr(F[1],2)==="04")h=new l,h.readPKCS5PrvKeyHex(C);else throw new Error("unsupported PKCS#1/5 hexadecimal key");return h}if(r==="pkcs8prv"){var h=p.getKeyFromPlainPrivatePKCS8Hex(e);return h}if(r==="pkcs8pub")return p._getKeyFromPublicPKCS8Hex(e);if(r==="x509pub")return Ge.getPublicKeyFromCertHex(e);if(e.indexOf("-END CERTIFICATE-",0)!=-1||e.indexOf("-END X509 CERTIFICATE-",0)!=-1||e.indexOf("-END TRUSTED CERTIFICATE-",0)!=-1)return Ge.getPublicKeyFromCertPEM(e);if(e.indexOf("-END PUBLIC KEY-")!=-1){var L=mr(e,"PUBLIC KEY");return p._getKeyFromPublicPKCS8Hex(L)}if(e.indexOf("-END RSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")==-1){var k=g(e,"RSA PRIVATE KEY");return p.getKey(k,null,"pkcs5prv")}if(e.indexOf("-END DSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")==-1){var S=g(e,"DSA PRIVATE KEY"),B=s(S,0,[1],"02"),O=s(S,0,[2],"02"),P=s(S,0,[3],"02"),U=s(S,0,[4],"02"),Y=s(S,0,[5],"02"),h=new f;return h.setPrivate(new ee(B,16),new ee(O,16),new ee(P,16),new ee(U,16),new ee(Y,16)),h}if(e.indexOf("-END EC PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")==-1){var k=g(e,"EC PRIVATE KEY");return p.getKey(k,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 H=p.getDecryptedKeyHex(e,t),K=new et;return K.readPKCS5PrvKeyHex(H),K}if(e.indexOf("-END EC PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")!=-1){var S=p.getDecryptedKeyHex(e,t),h=s(S,0,[1],"04"),W=s(S,0,[2,0],"06"),ie=s(S,0,[3,0],"03").substr(2),Ce="";if(w.crypto.OID.oidhex2name[W]!==void 0)Ce=w.crypto.OID.oidhex2name[W];else throw new Error("undefined OID(hex) in KJUR.crypto.OID: "+W);var E=new l({curve:Ce});return E.setPublicKeyHex(ie),E.setPrivateKeyHex(h),E.isPublic=!1,E}if(e.indexOf("-END DSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")!=-1){var S=p.getDecryptedKeyHex(e,t),B=s(S,0,[1],"02"),O=s(S,0,[2],"02"),P=s(S,0,[3],"02"),U=s(S,0,[4],"02"),Y=s(S,0,[5],"02"),h=new f;return h.setPrivate(new ee(B,16),new ee(O,16),new ee(P,16),new ee(U,16),new ee(Y,16)),h}if(e.indexOf("-END ENCRYPTED PRIVATE KEY-")!=-1)return p.getKeyFromEncryptedPKCS8PEM(e,t);throw new Error("not supported argument")};At.generateKeypair=function(e,t){if(e=="RSA"){var r=t,n=new et;n.generate(r,"10001"),n.isPrivate=!0,n.isPublic=!0;var i=new et,a=n.n.toString(16),s=n.e.toString(16);i.setPublic(a,s),i.isPrivate=!1,i.isPublic=!0;var u={};return u.prvKeyObj=n,u.pubKeyObj=i,u}else if(e=="EC"){var l=t,f=new w.crypto.ECDSA({curve:l}),d=f.generateKeyPairHex(),n=new w.crypto.ECDSA({curve:l});n.setPublicKeyHex(d.ecpubhex),n.setPrivateKeyHex(d.ecprvhex),n.isPrivate=!0,n.isPublic=!1;var i=new w.crypto.ECDSA({curve:l});i.setPublicKeyHex(d.ecpubhex),i.isPrivate=!1,i.isPublic=!0;var u={};return u.prvKeyObj=n,u.pubKeyObj=i,u}else throw new Error("unknown algorithm: "+e)};At.getPEM=function(e,t,r,n,i,a){var s=w,u=s.asn1,l=u.DERObjectIdentifier,f=u.DERInteger,d=u.ASN1Util.newObject,g=u.x509,p=g.SubjectPublicKeyInfo,h=s.crypto,E=h.DSA,v=h.ECDSA,b=et;function m(K){var W=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 W}function y(K){var W=d({seq:[{int:1},{octstr:{hex:K.prvKeyHex}},{tag:["a0",!0,{oid:{name:K.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+K.pubKeyHex}}]}]});return W}function D(K){var W=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 W}if((b!==void 0&&e instanceof b||E!==void 0&&e instanceof E||v!==void 0&&e instanceof v)&&e.isPublic==!0&&(t===void 0||t=="PKCS8PUB")){var C=new p(e),F=C.tohex();return Bn(F,"PUBLIC KEY")}if(t=="PKCS1PRV"&&b!==void 0&&e instanceof b&&(r===void 0||r==null)&&e.isPrivate==!0){var C=m(e),F=C.tohex();return Bn(F,"RSA PRIVATE KEY")}if(t=="PKCS1PRV"&&v!==void 0&&e instanceof v&&(r===void 0||r==null)&&e.isPrivate==!0){var L=new l({name:e.curveName}),k=L.tohex(),S=y(e),B=S.tohex(),O="";return O+=Bn(k,"EC PARAMETERS"),O+=Bn(B,"EC PRIVATE KEY"),O}if(t=="PKCS1PRV"&&E!==void 0&&e instanceof E&&(r===void 0||r==null)&&e.isPrivate==!0){var C=D(e),F=C.tohex();return Bn(F,"DSA PRIVATE KEY")}if(t=="PKCS5PRV"&&b!==void 0&&e instanceof b&&r!==void 0&&r!=null&&e.isPrivate==!0){var C=m(e),F=C.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",F,r,n,a)}if(t=="PKCS5PRV"&&v!==void 0&&e instanceof v&&r!==void 0&&r!=null&&e.isPrivate==!0){var C=y(e),F=C.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",F,r,n,a)}if(t=="PKCS5PRV"&&E!==void 0&&e instanceof E&&r!==void 0&&r!=null&&e.isPrivate==!0){var C=D(e),F=C.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",F,r,n,a)}var P=function(K,W){if(typeof W=="string")return At.getEncryptedPKCS8PEM(K,W);if(typeof W=="object"&&Zt(W,"passcode")!=null){var ie=JSON.parse(JSON.stringify(W)),Ce=ie.passcode;return delete ie.passcode,At.getEncryptedPKCS8PEM(K,Ce,ie)}};if(t=="PKCS8PRV"&&b!=null&&e instanceof b&&e.isPrivate==!0){var U=m(e),Y=U.tohex(),C=d({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:Y}}]}),F=C.tohex();return r===void 0||r==null?Bn(F,"PRIVATE KEY"):P(F,r)}if(t=="PKCS8PRV"&&v!==void 0&&e instanceof v&&e.isPrivate==!0){var H={seq:[{int:1},{octstr:{hex:e.prvKeyHex}}]};typeof e.pubKeyHex=="string"&&H.seq.push({tag:["a1",!0,{bitstr:{hex:"00"+e.pubKeyHex}}]});var U=new d(H),Y=U.tohex(),C=d({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:e.curveName}}]},{octstr:{hex:Y}}]}),F=C.tohex();return r===void 0||r==null?Bn(F,"PRIVATE KEY"):P(F,r)}if(t=="PKCS8PRV"&&E!==void 0&&e instanceof E&&e.isPrivate==!0){var U=new f({bigint:e.x}),Y=U.tohex(),C=d({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.g}}]}]},{octstr:{hex:Y}}]}),F=C.tohex();return r===void 0||r==null?Bn(F,"PRIVATE KEY"):P(F,r)}throw new Error("unsupported object nor format")};At.getKeyFromCSRPEM=function(e){var t=mr(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=be,r=t.getChildIdx,n=t.getTLV,i={},a=e;if(a.substr(0,2)!="30")throw new Error("malformed CSR(code:001)");var s=r(a,0);if(s.length<1)throw new Error("malformed CSR(code:002)");if(a.substr(s[0],2)!="30")throw new Error("malformed CSR(code:003)");var u=r(a,s[0]);if(u.length<3)throw new Error("malformed CSR(code:004)");return i.p8pubkeyhex=n(a,u[2]),i};At.getKeyID=function(e){var t=At,r=be;typeof e=="string"&&e.indexOf("BEGIN ")!=-1&&(e=t.getKey(e));var n=mr(t.getPEM(e)),i=r.getIdxbyList(n,0,[1]),a=r.getV(n,i).substring(2);return w.crypto.Util.hashHex(a,"sha1")};At.getJWK=function(e,t,r,n,i){var a,s={},u,l=w.crypto.Util.hashHex;if(typeof e=="string")a=At.getKey(e),e.indexOf("CERTIFICATE")!=-1&&(u=mr(e));else if(typeof e=="object")e instanceof Ge?(a=e.getPublicKey(),u=e.hex):a=e;else throw new Error("unsupported keyinfo type");if(a instanceof et&&a.isPrivate)s.kty="RSA",s.n=Vr(a.n.toString(16)),s.e=Vr(a.e.toString(16)),s.d=Vr(a.d.toString(16)),s.p=Vr(a.p.toString(16)),s.q=Vr(a.q.toString(16)),s.dp=Vr(a.dmp1.toString(16)),s.dq=Vr(a.dmq1.toString(16)),s.qi=Vr(a.coeff.toString(16));else if(a instanceof et&&a.isPublic)s.kty="RSA",s.n=Vr(a.n.toString(16)),s.e=Vr(a.e.toString(16));else if(a instanceof w.crypto.ECDSA&&a.isPrivate){var f=a.getShortNISTPCurveName();if(f!=="P-256"&&f!=="P-384"&&f!=="P-521")throw new Error("unsupported curve name for JWT: "+f);var d=a.getPublicKeyXYHex();s.kty="EC",s.crv=f,s.x=Vr(d.x),s.y=Vr(d.y),s.d=Vr(a.prvKeyHex)}else if(a instanceof w.crypto.ECDSA&&a.isPublic){var f=a.getShortNISTPCurveName();if(f!=="P-256"&&f!=="P-384"&&f!=="P-521")throw new Error("unsupported curve name for JWT: "+f);var d=a.getPublicKeyXYHex();s.kty="EC",s.crv=f,s.x=Vr(d.x),s.y=Vr(d.y)}if(s.kty==null)throw new Error("unsupported keyinfo");return!a.isPrivate&&t!=!0&&(s.kid=w.jws.JWS.getJWKthumbprint(s)),u!=null&&r!=!0&&(s.x5c=[Ya(u)]),u!=null&&n!=!0&&(s.x5t=jl(Ya(l(u,"sha1")))),u!=null&&i!=!0&&(s["x5t#S256"]=jl(Ya(l(u,"sha256")))),s};At.getJWKFromKey=function(e){return At.getJWK(e,!0,!0,!0,!0)};et.getPosArrayOfChildrenFromHex=function(e){return be.getChildIdx(e,0)};et.getHexValueArrayOfChildrenFromHex=function(e){var t=be,r=t.getV,p=et.getPosArrayOfChildrenFromHex(e),n=r(e,p[0]),i=r(e,p[1]),a=r(e,p[2]),s=r(e,p[3]),u=r(e,p[4]),l=r(e,p[5]),f=r(e,p[6]),d=r(e,p[7]),g=r(e,p[8]),p=new Array;return p.push(n,i,a,s,u,l,f,d,g),p};et.prototype.readPrivateKeyFromPEMString=function(e){var t=mr(e),r=et.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8])};et.prototype.readPKCS5PrvKeyHex=function(e){var t=et.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])};et.prototype.readPKCS8PrvKeyHex=function(e){var t,r,n,i,a,s,u,l,f=be,d=f.getVbyListEx;if(f.isASN1HEX(e)===!1)throw new Error("not ASN.1 hex string");try{t=d(e,0,[2,0,1],"02"),r=d(e,0,[2,0,2],"02"),n=d(e,0,[2,0,3],"02"),i=d(e,0,[2,0,4],"02"),a=d(e,0,[2,0,5],"02"),s=d(e,0,[2,0,6],"02"),u=d(e,0,[2,0,7],"02"),l=d(e,0,[2,0,8],"02")}catch{throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(t,r,n,i,a,s,u,l)};et.prototype.readPKCS5PubKeyHex=function(e){var t=be,r=t.getV;if(t.isASN1HEX(e)===!1)throw new Error("keyHex is not ASN.1 hex string");var n=t.getChildIdx(e,0);if(n.length!==2||e.substr(n[0],2)!=="02"||e.substr(n[1],2)!=="02")throw new Error("wrong hex for PKCS#5 public key");var i=r(e,n[0]),a=r(e,n[1]);this.setPublic(i,a)};et.prototype.readPKCS8PubKeyHex=function(e){var t=be;if(t.isASN1HEX(e)===!1)throw new Error("not ASN.1 hex string");if(t.getTLVbyListEx(e,0,[0,0])!=="06092a864886f70d010101")throw new Error("not PKCS8 RSA public key");var r=t.getTLVbyListEx(e,0,[1,0]);this.readPKCS5PubKeyHex(r)};et.prototype.readCertPubKeyHex=function(e,t){var r,n;r=new Ge,r.readCertHex(e),n=r.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)};var Az=new RegExp("[^0-9a-f]","gi");function $y(e,t){for(var r="",n=t/4-e.length,i=0;i>24,(i&16711680)>>16,(i&65280)>>8,i&255])))),i+=1;return n}et.prototype.signPSS=function(e,t,r){var n=function(a){return w.crypto.Util.hashHex(a,t)},i=n(Ys(e));return r===void 0&&(r=-1),this.signWithMessageHashPSS(i,t,r)};et.prototype.signWithMessageHashPSS=function(e,t,r){var n=vi(e),i=n.length,a=this.n.bitLength()-1,s=Math.ceil(a/8),u,l=function(b){return w.crypto.Util.hashHex(b,t)};if(r===-1||r===void 0)r=i;else if(r===-2)r=s-i-2;else if(r<-2)throw new Error("invalid salt length");if(s0&&(f=new Array(r),new Vl().nextBytes(f),f=String.fromCharCode.apply(String,f));var d=vi(l(Ys("\0\0\0\0\0\0\0\0"+n+f))),g=[];for(u=0;u>8*s-a&255;for(E[0]&=~v,u=0;un)return!1;var i=this.doPublic(r),a=i.toString(16);if(a.length+3!=n/4)return!1;var s=a.replace(/^1f+00/,""),u=Py(s);if(u.length==0)return!1;var l=u[0],f=u[1],d=function(p){return w.crypto.Util.hashString(p,l)},g=d(e);return f==g};et.prototype.verifyWithMessageHash=function(e,t){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var r=gi(t,16);if(r.bitLength()>this.n.bitLength())return 0;var n=this.doPublic(r),i=n.toString(16).replace(/^1f+00/,""),a=Py(i);if(a.length==0)return!1;var s=a[0],u=a[1];return u==e};et.prototype.verifyPSS=function(e,t,r,n){var i=function(s){return w.crypto.Util.hashHex(s,r)},a=i(Ys(e));return n===void 0&&(n=-1),this.verifyWithMessageHashPSS(a,t,r,n)};et.prototype.verifyWithMessageHashPSS=function(e,t,r,n){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var i=new ee(t,16),a=function(y){return w.crypto.Util.hashHex(y,r)},s=vi(e),u=s.length,l=this.n.bitLength()-1,f=Math.ceil(l/8),d;if(n===-1||n===void 0)n=u;else if(n===-2)n=f-u-2;else if(n<-2)throw new Error("invalid salt length");if(f>8*f-l&255;if(p.charCodeAt(0)&E)throw new Error("bits beyond keysize not zero");var v=Ry(h,p.length,a),b=[];for(d=0;d0?B:void 0}catch{return}},this._asn1ToNoticeRef=function(S){try{for(var B={},O=Zt(S,"seq"),P=0;P0?B:void 0}catch{return}},this._asn1ToNoticeNum=function(S){try{for(var B=Zt(S,"seq"),O=[],P=0;P1){var Y=s(S,U[1]),H=this.getGeneralName(Y);H.uri!=null&&(P.uri=H.uri)}if(U.length>2){var K=s(S,U[2]);K=="0101ff"&&(P.reqauth=!0),K=="010100"&&(P.reqauth=!1)}return P},this.getExtSubjectDirectoryAttributes=function(S,B){if(S===void 0&&B===void 0){var O=this.getExtInfo("subjectDirectoryAttributes");if(O===void 0)return;S=s(this.hex,O.vidx),B=O.critical}var P={extname:"subjectDirectoryAttributes"};B&&(P.critical=!0);try{for(var U=a(S),Y=[],H=0;H0&&(B.ext=this.getExtParamArray()),B.sighex=this.getSignatureValueHex(),S.tbshex==!0&&(B.tbshex=f(this.hex,0,[0])),S.nodnarray==!0&&(delete B.issuer.array,delete B.subject.array),B},this.getExtParamArray=function(S){if(S==null){var B=p(this.hex,0,[0,"[3]"]);B!=-1&&(S=d(this.hex,0,[0,"[3]",0],"30"))}for(var O=[],P=r(S,0),U=0;U"u"||!w)&&(w={});(typeof w.jws>"u"||!w.jws)&&(w.jws={});w.jws.JWS=function(){var e=w,t=e.jws.JWS,r=t.isSafeJSONString;this.parseJWS=function(n,i){if(!(this.parsedJWS!==void 0&&(i||this.parsedJWS.sigvalH!==void 0))){var a=n.match(/^([^.]+)\.([^.]+)\.([^.]+)$/);if(a==null)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";var s=a[1],u=a[2],l=a[3],f=s+"."+u;if(this.parsedJWS={},this.parsedJWS.headB64U=s,this.parsedJWS.payloadB64U=u,this.parsedJWS.sigvalB64U=l,this.parsedJWS.si=f,!i){var d=lr(l),g=gi(d,16);this.parsedJWS.sigvalH=d,this.parsedJWS.sigvalBI=g}var p=ys(s),h=ys(u);if(this.parsedJWS.headS=p,this.parsedJWS.payloadS=h,!r(p,this.parsedJWS,"headP"))throw"malformed JSON string for JWS Head: "+p}}};w.jws.JWS.sign=function(e,t,r,n,i){var a=w,s=a.jws,u=s.JWS,l=u.readSafeJSONString,f=u.isSafeJSONString,d=a.crypto,g=d.ECDSA,p=d.Mac,h=d.Signature,E=JSON,v,b,m;if(typeof t!="string"&&typeof t!="object")throw"spHeader must be JSON string or object: "+t;if(typeof t=="object"&&(b=t,v=E.stringify(b)),typeof t=="string"){if(v=t,!f(v))throw"JWS Head is not safe JSON string: "+v;b=l(v)}if(m=r,typeof r=="object"&&(m=E.stringify(r)),(e==""||e==null)&&b.alg!==void 0&&(e=b.alg),e!=""&&e!=null&&b.alg===void 0&&(b.alg=e,v=E.stringify(b)),e!==b.alg)throw"alg and sHeader.alg doesn't match: "+e+"!="+b.alg;var y=null;if(u.jwsalg2sigalg[e]===void 0)throw"unsupported alg name: "+e;y=u.jwsalg2sigalg[e];var D=pf(v),C=pf(m),F=D+"."+C,L="";if(y.substr(0,4)=="Hmac"){if(n===void 0)throw"mac key shall be specified for HS* alg";var k=new p({alg:y,prov:"cryptojs",pass:n});k.updateString(F),L=k.doFinal()}else if(y.indexOf("withECDSA")!=-1){var S=new h({alg:y});S.init(n,i),S.updateString(F);var B=S.sign();L=w.crypto.ECDSA.asn1SigToConcatSig(B)}else if(y!="none"){var S=new h({alg:y});S.init(n,i),S.updateString(F),L=S.sign()}var O=Vr(L);return F+"."+O};w.jws.JWS.verify=function(e,t,r){var n=w,i=n.jws,a=i.JWS,s=a.readSafeJSONString,u=n.crypto,l=u.ECDSA,f=u.Mac,d=u.Signature,g;if(typeof et!==void 0&&(g=et),!jg(e))return!1;var p=e.split(".");if(p.length!==3)return!1;var h=p[0],E=p[1],v=h+"."+E,b=lr(p[2]),m=s(ys(p[0])),y=null,D=null;if(m.alg===void 0)throw"algorithm not specified in header";if(y=m.alg,D=y.substr(0,2),r!=null&&Object.prototype.toString.call(r)==="[object Array]"&&r.length>0){var C=":"+r.join(":")+":";if(C.indexOf(":"+y+":")==-1)throw"algorithm '"+y+"' not accepted in the list"}if(y!="none"&&t===null)throw"key shall be specified to verify.";if(typeof t=="string"&&t.indexOf("-----BEGIN ")!=-1&&(t=At.getKey(t)),(D=="RS"||D=="PS")&&!(t instanceof g))throw"key shall be a RSAKey obj for RS* and PS* algs";if(D=="ES"&&!(t instanceof l))throw"key shall be a ECDSA obj for ES* algs";y=="none";var F=null;if(a.jwsalg2sigalg[m.alg]===void 0)throw"unsupported alg name: "+y;if(F=a.jwsalg2sigalg[y],F=="none")throw"not supported";if(F.substr(0,4)=="Hmac"){var L=null;if(t===void 0)throw"hexadecimal key shall be specified for HMAC";var k=new f({alg:F,pass:t});return k.updateString(v),L=k.doFinal(),b==L}else if(F.indexOf("withECDSA")!=-1){var S=null;try{S=l.concatSigToASN1Sig(b)}catch{return!1}var B=new d({alg:F});return B.init(t),B.updateString(v),B.verify(S)}else{var B=new d({alg:F});return B.init(t),B.updateString(v),B.verify(b)}};w.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=w.jws.JWS.readSafeJSONString(ys(n)),r.payloadObj=w.jws.JWS.readSafeJSONString(ys(i)),r.headerPP=JSON.stringify(r.headerObj,null," "),r.payloadObj==null?r.payloadPP=ys(i):r.payloadPP=JSON.stringify(r.payloadObj,null," "),a!==void 0&&(r.sigHex=lr(a)),r};w.jws.JWS.verifyJWT=function(e,t,r){var n=w,i=n.jws,a=i.JWS,s=a.readSafeJSONString,u=a.inArray,l=a.includedArray;if(!jg(e))return!1;var f=e.split(".");if(f.length!=3)return!1;var d=f[0],g=f[1],p=d+"."+g,h=lr(f[2]),E=s(ys(d)),v=s(ys(g));if(E.alg===void 0)return!1;if(r.alg===void 0)throw"acceptField.alg shall be specified";if(!u(E.alg,r.alg)||v.iss!==void 0&&typeof r.iss=="object"&&!u(v.iss,r.iss)||v.sub!==void 0&&typeof r.sub=="object"&&!u(v.sub,r.sub))return!1;if(v.aud!==void 0&&typeof r.aud=="object"){if(typeof v.aud=="string"){if(!u(v.aud,r.aud))return!1}else if(typeof v.aud=="object"&&!l(v.aud,r.aud))return!1}var b=i.IntDate.getNow();return r.verifyAt!==void 0&&typeof r.verifyAt=="number"&&(b=r.verifyAt),(r.gracePeriod===void 0||typeof r.gracePeriod!="number")&&(r.gracePeriod=0),!(v.exp!==void 0&&typeof v.exp=="number"&&v.exp+r.gracePeriod"u"||!w)&&(w={});(typeof w.jws>"u"||!w.jws)&&(w.jws={});w.jws.JWSJS=function(){var e=w,t=e.jws,r=t.JWS,n=r.readSafeJSONString;this.aHeader=[],this.sPayload="",this.aSignature=[],this.init=function(){this.aHeader=[],this.sPayload=void 0,this.aSignature=[]},this.initWithJWS=function(i){this.init();var a=i.split(".");if(a.length!=3)throw"malformed input JWS";this.aHeader.push(a[0]),this.sPayload=a[1],this.aSignature.push(a[2])},this.addSignature=function(i,a,s,u){if(this.sPayload===void 0||this.sPayload===null)throw"there's no JSON-JS signature to add.";var l=this.aHeader.length;if(this.aHeader.length!=this.aSignature.length)throw"aHeader.length != aSignature.length";try{var f=w.jws.JWS.sign(i,a,this.sPayload,s,u),d=f.split("."),g=d[0],p=d[2];this.aHeader.push(d[0]),this.aSignature.push(d[2])}catch(h){throw this.aHeader.length>l&&this.aHeader.pop(),this.aSignature.length>l&&this.aSignature.pop(),"addSignature failed: "+h}},this.verifyAll=function(i){if(this.aHeader.length!==i.length||this.aSignature.length!==i.length)return!1;for(var a=0;a0)this.aHeader=i.headers;else throw"malformed header";if(typeof i.payload=="string")this.sPayload=i.payload;else throw"malformed signatures";if(i.signatures.length>0)this.aSignature=i.signatures;else throw"malformed signatures"}catch(s){throw"malformed JWS-JS JSON object: "+s}},this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}},this.isEmpty=function(){return this.aHeader.length==0?1:0}};_e.SecureRandom=Vl;_e.rng_seed_time=Tg;_e.BigInteger=ee;_e.RSAKey=et;_e.ECDSA=w.crypto.ECDSA;_e.DSA=w.crypto.DSA;_e.Signature=w.crypto.Signature;_e.MessageDigest=w.crypto.MessageDigest;_e.Mac=w.crypto.Mac;_e.KEYUTIL=At;_e.ASN1HEX=be;_e.X509=Ge;_e.X509CRL=JP;_e.CryptoJS=Se;_e.b64tohex=Hl;_e.b64toBA=dy;_e.ECFieldElementFp=Kr;_e.ECPointFp=kt;_e.ECCurveFp=Wa;_e.stoBA=wy;_e.BAtos=Ay;_e.BAtohex=G0;_e.stohex=mi;_e.stob64=RP;_e.stob64u=PP;_e.b64utos=xP;_e.b64tob64u=jl;_e.b64utob64=mf;_e.hex2b64=Ya;_e.hextob64u=Vr;_e.b64utohex=lr;_e.utf8tob64u=pf;_e.b64utoutf8=ys;_e.utf8tob64=OP;_e.b64toutf8=TP;_e.utf8tohex=Y0;_e.hextoutf8=Vt;_e.hextorstr=vi;_e.rstrtohex=Ys;_e.hextob64=kg;_e.hextob64nl=LP;_e.b64nltohex=yy;_e.hextopem=Bn;_e.pemtohex=mr;_e.hextoArrayBuffer=HP;_e.ArrayBuffertohex=MP;_e.zulutomsec=Ng;_e.msectozulu=qP;_e.zulutosec=by;_e.zulutodate=VP;_e.datetozulu=KP;_e.uricmptohex=X0;_e.hextouricmp=J0;_e.ipv6tohex=Bg;_e.hextoipv6=$g;_e.hextoip=M0;_e.iptohex=Lg;_e.ucs2hextoutf8=Ug;_e.encodeURIComponentAll=Z0;_e.newline_toUnix=zP;_e.newline_toDos=GP;_e.hextoposhex=Rg;_e.intarystrtohex=YP;_e.strdiffidx=WP;_e.oidtohex=Dy;_e.hextooid=Q0;_e.strpad=q0;_e.bitstrtoint=Sy;_e.inttobitstr=Iy;_e.bitstrtobinstr=By;_e.binstrtobitstr=XP;_e.isBase64URLDot=jg;_e.namearraytobinstr=V0;_e.extendClass=pe;_e.foldnl=W0;_e.b64topem=UP;_e.pemtob64=jP;_e.timeogen=_y;_e.aryval=Zt;_e.inttohex=Fy;_e.twoscompl=vf;_e.KJUR=w;_e.crypto=w.crypto;_e.asn1=w.asn1;_e.jws=w.jws;_e.lang=w.lang;_e.VERSION=a$;_e.VERSION_FULL=u$});var To=le((_z,Oo)=>{"use strict";function Ty(e){return typeof e>"u"||e===null}function QP(e){return typeof e=="object"&&e!==null}function ex(e){return Array.isArray(e)?e:Ty(e)?[]:[e]}function tx(e,t){var r,n,i,a;if(t)for(a=Object.keys(t),r=0,n=a.length;r{"use strict";function Ef(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||""}Ef.prototype=Object.create(Error.prototype);Ef.prototype.constructor=Ef;Ef.prototype.toString=function(t){var r=this.name+": ";return r+=this.reason||"(unknown reason)",!t&&this.mark&&(r+=" "+this.mark.toString()),r};ky.exports=Ef});var Uy=le((Dz,Ly)=>{"use strict";var Ny=To();function Mg(e,t,r,n,i){this.name=e,this.buffer=t,this.position=r,this.line=n,this.column=i}Mg.prototype.getSnippet=function(t,r){var n,i,a,s,u;if(!this.buffer)return null;for(t=t||4,r=r||75,n="",i=this.position;i>0&&`\0\r \x85\u2028\u2029`.indexOf(this.buffer.charAt(i-1))===-1;)if(i-=1,this.position-i>r/2-1){n=" ... ",i+=5;break}for(a="",s=this.position;sr/2-1){a=" ... ",s-=5;break}return u=this.buffer.slice(i,s),Ny.repeat(" ",t)+n+u+a+` `+Ny.repeat(" ",t+this.position-i+n.length)+"^"};Mg.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};Ly.exports=Mg});var zr=le((Fz,Hy)=>{"use strict";var jy=Kl(),ix=["kind","resolve","construct","instanceOf","predicate","represent","defaultStyle","styleAliases"],sx=["scalar","sequence","mapping"];function ax(e){var t={};return e!==null&&Object.keys(e).forEach(function(r){e[r].forEach(function(n){t[String(n)]=r})}),t}function ux(e,t){if(t=t||{},Object.keys(t).forEach(function(r){if(ix.indexOf(r)===-1)throw new jy('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=ax(t.styleAliases||null),sx.indexOf(this.kind)===-1)throw new jy('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}Hy.exports=ux});var ko=le((Sz,qy)=>{"use strict";var My=To(),ed=Kl(),ox=zr();function qg(e,t,r){var n=[];return e.include.forEach(function(i){r=qg(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 lx(){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 cx=zr();Vy.exports=new cx("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}})});var Gy=le((Bz,zy)=>{"use strict";var fx=zr();zy.exports=new fx("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}})});var Wy=le(($z,Yy)=>{"use strict";var hx=zr();Yy.exports=new hx("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}})});var td=le((Rz,Xy)=>{"use strict";var dx=ko();Xy.exports=new dx({explicit:[Ky(),Gy(),Wy()]})});var Zy=le((Pz,Jy)=>{"use strict";var px=zr();function gx(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function mx(){return null}function vx(e){return e===null}Jy.exports=new px("tag:yaml.org,2002:null",{kind:"scalar",resolve:gx,construct:mx,predicate:vx,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"}},defaultStyle:"lowercase"})});var eb=le((xz,Qy)=>{"use strict";var Ex=zr();function wx(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 Ax(e){return e==="true"||e==="True"||e==="TRUE"}function yx(e){return Object.prototype.toString.call(e)==="[object Boolean]"}Qy.exports=new Ex("tag:yaml.org,2002:bool",{kind:"scalar",resolve:wx,construct:Ax,predicate:yx,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 rb=le((Oz,tb)=>{"use strict";var bx=To(),_x=zr();function Cx(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function Dx(e){return 48<=e&&e<=55}function Fx(e){return 48<=e&&e<=57}function Sx(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 sb=le((Tz,ib)=>{"use strict";var nb=To(),$x=zr(),Rx=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 Px(e){return!(e===null||!Rx.test(e)||e[e.length-1]==="_")}function xx(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 Ox=/^[-+]?[0-9]+e/;function Tx(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(nb.isNegativeZero(e))return"-0.0";return r=e.toString(10),Ox.test(r)?r.replace("e",".e"):r}function kx(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||nb.isNegativeZero(e))}ib.exports=new $x("tag:yaml.org,2002:float",{kind:"scalar",resolve:Px,construct:xx,predicate:kx,represent:Tx,defaultStyle:"lowercase"})});var Vg=le((kz,ab)=>{"use strict";var Nx=ko();ab.exports=new Nx({include:[td()],implicit:[Zy(),eb(),rb(),sb()]})});var Kg=le((Nz,ub)=>{"use strict";var Lx=ko();ub.exports=new Lx({include:[Vg()]})});var fb=le((Lz,cb)=>{"use strict";var Ux=zr(),ob=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),lb=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 jx(e){return e===null?!1:ob.exec(e)!==null||lb.exec(e)!==null}function Hx(e){var t,r,n,i,a,s,u,l=0,f=null,d,g,p;if(t=ob.exec(e),t===null&&(t=lb.exec(e)),t===null)throw new Error("Date resolve error");if(r=+t[1],n=+t[2]-1,i=+t[3],!t[4])return new Date(Date.UTC(r,n,i));if(a=+t[4],s=+t[5],u=+t[6],t[7]){for(l=t[7].slice(0,3);l.length<3;)l+="0";l=+l}return t[9]&&(d=+t[10],g=+(t[11]||0),f=(d*60+g)*6e4,t[9]==="-"&&(f=-f)),p=new Date(Date.UTC(r,n,i,a,s,u,l)),f&&p.setTime(p.getTime()-f),p}function Mx(e){return e.toISOString()}cb.exports=new Ux("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:jx,construct:Hx,instanceOf:Date,represent:Mx})});var db=le((Uz,hb)=>{"use strict";var qx=zr();function Vx(e){return e==="<<"||e===null}hb.exports=new qx("tag:yaml.org,2002:merge",{kind:"scalar",resolve:Vx})});var mb=le((jz,gb)=>{"use strict";var No;try{pb=Fo,No=pb("buffer").Buffer}catch{}var pb,Kx=zr(),zg=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= \r`;function zx(e){if(e===null)return!1;var t,r,n=0,i=e.length,a=zg;for(r=0;r64)){if(t<0)return!1;n+=6}return n%8===0}function Gx(e){var t,r,n=e.replace(/[\r\n=]/g,""),i=n.length,a=zg,s=0,u=[];for(t=0;t>16&255),u.push(s>>8&255),u.push(s&255)),s=s<<6|a.indexOf(n.charAt(t));return r=i%4*6,r===0?(u.push(s>>16&255),u.push(s>>8&255),u.push(s&255)):r===18?(u.push(s>>10&255),u.push(s>>2&255)):r===12&&u.push(s>>4&255),No?No.from?No.from(u):new No(u):u}function Yx(e){var t="",r=0,n,i,a=e.length,s=zg;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 Wx(e){return No&&No.isBuffer(e)}gb.exports=new Kx("tag:yaml.org,2002:binary",{kind:"scalar",resolve:zx,construct:Gx,predicate:Wx,represent:Yx})});var Eb=le((Mz,vb)=>{"use strict";var Xx=zr(),Jx=Object.prototype.hasOwnProperty,Zx=Object.prototype.toString;function Qx(e){if(e===null)return!0;var t=[],r,n,i,a,s,u=e;for(r=0,n=u.length;r{"use strict";var tO=zr(),rO=Object.prototype.toString;function nO(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 sO=zr(),aO=Object.prototype.hasOwnProperty;function uO(e){if(e===null)return!0;var t,r=e;for(t in r)if(aO.call(r,t)&&r[t]!==null)return!1;return!0}function oO(e){return e!==null?e:{}}yb.exports=new sO("tag:yaml.org,2002:set",{kind:"mapping",resolve:uO,construct:oO})});var Gl=le((Kz,_b)=>{"use strict";var lO=ko();_b.exports=new lO({include:[Kg()],implicit:[fb(),db()],explicit:[mb(),Eb(),Ab(),bb()]})});var Db=le((zz,Cb)=>{"use strict";var cO=zr();function fO(){return!0}function hO(){}function dO(){return""}function pO(e){return typeof e>"u"}Cb.exports=new cO("tag:yaml.org,2002:js/undefined",{kind:"scalar",resolve:fO,construct:hO,predicate:pO,represent:dO})});var Sb=le((Gz,Fb)=>{"use strict";var gO=zr();function mO(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 vO(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 EO(e){var t="/"+e.source+"/";return e.global&&(t+="g"),e.multiline&&(t+="m"),e.ignoreCase&&(t+="i"),t}function wO(e){return Object.prototype.toString.call(e)==="[object RegExp]"}Fb.exports=new gO("tag:yaml.org,2002:js/regexp",{kind:"scalar",resolve:mO,construct:vO,predicate:wO,represent:EO})});var $b=le((Yz,Bb)=>{"use strict";var rd;try{Ib=Fo,rd=Ib("esprima")}catch{typeof window<"u"&&(rd=window.esprima)}var Ib,AO=zr();function yO(e){if(e===null)return!1;try{var t="("+e+")",r=rd.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 bO(e){var t="("+e+")",r=rd.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 _O(e){return e.toString()}function CO(e){return Object.prototype.toString.call(e)==="[object Function]"}Bb.exports=new AO("tag:yaml.org,2002:js/function",{kind:"scalar",resolve:yO,construct:bO,predicate:CO,represent:_O})});var wf=le((Xz,Pb)=>{"use strict";var Rb=ko();Pb.exports=Rb.DEFAULT=new Rb({include:[Gl()],explicit:[Db(),Sb(),$b()]})});var Jb=le((Jz,Af)=>{"use strict";var Xa=To(),Ub=Kl(),DO=Uy(),jb=Gl(),FO=wf(),Mu=Object.prototype.hasOwnProperty,nd=1,Hb=2,Mb=3,sd=4,Gg=1,SO=2,xb=3,IO=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,BO=/[\x85\u2028\u2029]/,$O=/[,\[\]\{\}]/,qb=/^(?:!|!!|![a-z\-]+!)$/i,Vb=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function Ob(e){return Object.prototype.toString.call(e)}function Ws(e){return e===10||e===13}function Uo(e){return e===9||e===32}function Ei(e){return e===9||e===32||e===10||e===13}function Yl(e){return e===44||e===91||e===93||e===123||e===125}function RO(e){var t;return 48<=e&&e<=57?e-48:(t=e|32,97<=t&&t<=102?t-97+10:-1)}function PO(e){return e===120?2:e===117?4:e===85?8:0}function xO(e){return 48<=e&&e<=57?e-48:-1}function Tb(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 OO(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}var Kb=new Array(256),zb=new Array(256);for(Lo=0;Lo<256;Lo++)Kb[Lo]=Tb(Lo)?1:0,zb[Lo]=Tb(Lo);var Lo;function TO(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||FO,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 Gb(e,t){return new Ub(t,new DO(e.filename,e.input,e.position,e.line,e.position-e.lineStart))}function We(e,t){throw Gb(e,t)}function ad(e,t){e.onWarning&&e.onWarning.call(null,Gb(e,t))}var kb={YAML:function(t,r,n){var i,a,s;t.version!==null&&We(t,"duplication of %YAML directive"),n.length!==1&&We(t,"YAML directive accepts exactly one argument"),i=/^([0-9]+)\.([0-9]+)$/.exec(n[0]),i===null&&We(t,"ill-formed argument of the YAML directive"),a=parseInt(i[1],10),s=parseInt(i[2],10),a!==1&&We(t,"unacceptable YAML version of the document"),t.version=n[0],t.checkLineBreaks=s<2,s!==1&&s!==2&&ad(t,"unsupported YAML version of the document")},TAG:function(t,r,n){var i,a;n.length!==2&&We(t,"TAG directive accepts exactly two arguments"),i=n[0],a=n[1],qb.test(i)||We(t,"ill-formed tag handle (first argument) of the TAG directive"),Mu.call(t.tagMap,i)&&We(t,'there is a previously declared suffix for "'+i+'" tag handle'),Vb.test(a)||We(t,"ill-formed tag prefix (second argument) of the TAG directive"),t.tagMap[i]=a}};function Hu(e,t,r,n){var i,a,s,u;if(t1&&(e.result+=Xa.repeat(` `,t-1))}function kO(e,t,r){var n,i,a,s,u,l,f,d,g=e.kind,p=e.result,h;if(h=e.input.charCodeAt(e.position),Ei(h)||Yl(h)||h===35||h===38||h===42||h===33||h===124||h===62||h===39||h===34||h===37||h===64||h===96||(h===63||h===45)&&(i=e.input.charCodeAt(e.position+1),Ei(i)||r&&Yl(i)))return!1;for(e.kind="scalar",e.result="",a=s=e.position,u=!1;h!==0;){if(h===58){if(i=e.input.charCodeAt(e.position+1),Ei(i)||r&&Yl(i))break}else if(h===35){if(n=e.input.charCodeAt(e.position-1),Ei(n))break}else{if(e.position===e.lineStart&&ud(e)||r&&Yl(h))break;if(Ws(h))if(l=e.line,f=e.lineStart,d=e.lineIndent,Lr(e,!1,-1),e.lineIndent>=t){u=!0,h=e.input.charCodeAt(e.position);continue}else{e.position=s,e.line=l,e.lineStart=f,e.lineIndent=d;break}}u&&(Hu(e,a,s,!1),Wg(e,e.line-l),a=s=e.position,u=!1),Uo(h)||(s=e.position+1),h=e.input.charCodeAt(++e.position)}return Hu(e,a,s,!1),e.result?!0:(e.kind=g,e.result=p,!1)}function NO(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(Hu(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 Ws(r)?(Hu(e,n,i,!0),Wg(e,Lr(e,!1,t)),n=i=e.position):e.position===e.lineStart&&ud(e)?We(e,"unexpected end of the document within a single quoted scalar"):(e.position++,i=e.position);We(e,"unexpected end of the stream within a single quoted scalar")}function LO(e,t){var r,n,i,a,s,u;if(u=e.input.charCodeAt(e.position),u!==34)return!1;for(e.kind="scalar",e.result="",e.position++,r=n=e.position;(u=e.input.charCodeAt(e.position))!==0;){if(u===34)return Hu(e,r,e.position,!0),e.position++,!0;if(u===92){if(Hu(e,r,e.position,!0),u=e.input.charCodeAt(++e.position),Ws(u))Lr(e,!1,t);else if(u<256&&Kb[u])e.result+=zb[u],e.position++;else if((s=PO(u))>0){for(i=s,a=0;i>0;i--)u=e.input.charCodeAt(++e.position),(s=RO(u))>=0?a=(a<<4)+s:We(e,"expected hexadecimal character");e.result+=OO(a),e.position++}else We(e,"unknown escape sequence");r=n=e.position}else Ws(u)?(Hu(e,r,n,!0),Wg(e,Lr(e,!1,t)),r=n=e.position):e.position===e.lineStart&&ud(e)?We(e,"unexpected end of the document within a double quoted scalar"):(e.position++,n=e.position)}We(e,"unexpected end of the stream within a double quoted scalar")}function UO(e,t){var r=!0,n,i=e.tag,a,s=e.anchor,u,l,f,d,g,p={},h,E,v,b;if(b=e.input.charCodeAt(e.position),b===91)l=93,g=!1,a=[];else if(b===123)l=125,g=!0,a={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=a),b=e.input.charCodeAt(++e.position);b!==0;){if(Lr(e,!0,t),b=e.input.charCodeAt(e.position),b===l)return e.position++,e.tag=i,e.anchor=s,e.kind=g?"mapping":"sequence",e.result=a,!0;r||We(e,"missed comma between flow collection entries"),E=h=v=null,f=d=!1,b===63&&(u=e.input.charCodeAt(e.position+1),Ei(u)&&(f=d=!0,e.position++,Lr(e,!0,t))),n=e.line,Xl(e,t,nd,!1,!0),E=e.tag,h=e.result,Lr(e,!0,t),b=e.input.charCodeAt(e.position),(d||e.line===n)&&b===58&&(f=!0,b=e.input.charCodeAt(++e.position),Lr(e,!0,t),Xl(e,t,nd,!1,!0),v=e.result),g?Wl(e,a,p,E,h,v):f?a.push(Wl(e,null,p,E,h,v)):a.push(h),Lr(e,!0,t),b=e.input.charCodeAt(e.position),b===44?(r=!0,b=e.input.charCodeAt(++e.position)):r=!1}We(e,"unexpected end of the stream within a flow collection")}function jO(e,t){var r,n,i=Gg,a=!1,s=!1,u=t,l=0,f=!1,d,g;if(g=e.input.charCodeAt(e.position),g===124)n=!1;else if(g===62)n=!0;else return!1;for(e.kind="scalar",e.result="";g!==0;)if(g=e.input.charCodeAt(++e.position),g===43||g===45)Gg===i?i=g===43?xb:SO:We(e,"repeat of a chomping mode identifier");else if((d=xO(g))>=0)d===0?We(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):s?We(e,"repeat of an indentation width identifier"):(u=t+d-1,s=!0);else break;if(Uo(g)){do g=e.input.charCodeAt(++e.position);while(Uo(g));if(g===35)do g=e.input.charCodeAt(++e.position);while(!Ws(g)&&g!==0)}for(;g!==0;){for(Yg(e),e.lineIndent=0,g=e.input.charCodeAt(e.position);(!s||e.lineIndentu&&(u=e.lineIndent),Ws(g)){l++;continue}if(e.lineIndentt)&&l!==0)We(e,"bad indentation of a sequence entry");else if(e.lineIndentt)&&(Xl(e,t,sd,!0,i)&&(E?p=e.result:h=e.result),E||(Wl(e,f,d,g,p,h,a,s),g=p=h=null),Lr(e,!0,-1),b=e.input.charCodeAt(e.position)),e.lineIndent>t&&b!==0)We(e,"bad indentation of a mapping entry");else if(e.lineIndentt?l=1:e.lineIndent===t?l=0:e.lineIndentt?l=1:e.lineIndent===t?l=0:e.lineIndent tag; it should be "scalar", not "'+e.kind+'"'),g=0,p=e.implicitTypes.length;g tag; it should be "'+h.kind+'", not "'+e.kind+'"'),h.resolve(e.result)?(e.result=h.construct(e.result),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):We(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")):We(e,"unknown tag !<"+e.tag+">");return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||d}function KO(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&&(Lr(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&&!Ei(s);)s=e.input.charCodeAt(++e.position);for(n=e.input.slice(r,e.position),i=[],n.length<1&&We(e,"directive name must not be less than one character in length");s!==0;){for(;Uo(s);)s=e.input.charCodeAt(++e.position);if(s===35){do s=e.input.charCodeAt(++e.position);while(s!==0&&!Ws(s));break}if(Ws(s))break;for(r=e.position;s!==0&&!Ei(s);)s=e.input.charCodeAt(++e.position);i.push(e.input.slice(r,e.position))}s!==0&&Yg(e),Mu.call(kb,n)?kb[n](e,n,i):ad(e,'unknown document directive "'+n+'"')}if(Lr(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,Lr(e,!0,-1)):a&&We(e,"directives end mark is expected"),Xl(e,e.lineIndent-1,sd,!1,!0),Lr(e,!0,-1),e.checkLineBreaks&&BO.test(e.input.slice(t,e.position))&&ad(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&ud(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,Lr(e,!0,-1));return}if(e.position"u"&&(r=t,t=null);var n=Yb(e,r);if(typeof t!="function")return n;for(var i=0,a=n.length;i"u"&&(r=t,t=null),Wb(e,t,Xa.extend({schema:jb},r))}function GO(e,t){return Xb(e,Xa.extend({schema:jb},t))}Af.exports.loadAll=Wb;Af.exports.load=Xb;Af.exports.safeLoadAll=zO;Af.exports.safeLoad=GO});var A_=le((Zz,Qg)=>{"use strict";var bf=To(),_f=Kl(),YO=wf(),WO=Gl(),s_=Object.prototype.toString,a_=Object.prototype.hasOwnProperty,XO=9,yf=10,JO=13,ZO=32,QO=33,eT=34,u_=35,tT=37,rT=38,nT=39,iT=42,o_=44,sT=45,l_=58,aT=61,uT=62,oT=63,lT=64,c_=91,f_=93,cT=96,h_=123,fT=124,d_=125,$n={};$n[0]="\\0";$n[7]="\\a";$n[8]="\\b";$n[9]="\\t";$n[10]="\\n";$n[11]="\\v";$n[12]="\\f";$n[13]="\\r";$n[27]="\\e";$n[34]='\\"';$n[92]="\\\\";$n[133]="\\N";$n[160]="\\_";$n[8232]="\\L";$n[8233]="\\P";var hT=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"];function dT(e,t){var r,n,i,a,s,u,l;if(t===null)return{};for(r={},n=Object.keys(t),i=0,a=n.length;i0?e.charCodeAt(a-1):null,p=p&&e_(s,u)}else{for(a=0;an&&e[g+1]!==" ",g=a);else if(!Jl(s))return od;u=a>0?e.charCodeAt(a-1):null,p=p&&e_(s,u)}f=f||d&&a-g-1>n&&e[g+1]!==" "}return!l&&!f?p&&!i(e)?g_:m_:r>9&&p_(e)?od:f?E_:v_}function wT(e,t,r,n){e.dump=function(){if(t.length===0)return"''";if(!e.noCompatMode&&hT.indexOf(t)!==-1)return"'"+t+"'";var i=e.indent*Math.max(1,r),a=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-i),s=n||e.flowLevel>-1&&r>=e.flowLevel;function u(l){return gT(e,l)}switch(ET(t,s,e.indent,a,u)){case g_:return t;case m_:return"'"+t.replace(/'/g,"''")+"'";case v_:return"|"+t_(t,e.indent)+r_(Qb(t,i));case E_:return">"+t_(t,e.indent)+r_(Qb(AT(t,a),i));case od:return'"'+yT(t,a)+'"';default:throw new _f("impossible error: invalid scalar style")}}()}function t_(e,t){var r=p_(e)?String(t):"",n=e[e.length-1]===` `,i=n&&(e[e.length-2]===` `||e===` `),a=i?"+":n?"":"-";return r+a+` `}function r_(e){return e[e.length-1]===` `?e.slice(0,-1):e}function AT(e,t){for(var r=/(\n+)([^\n]*)/g,n=function(){var f=e.indexOf(` `);return f=f!==-1?f:e.length,r.lastIndex=f,n_(e.slice(0,f),t)}(),i=e[0]===` `||e[0]===" ",a,s;s=r.exec(e);){var u=s[1],l=s[2];a=l[0]===" ",n+=u+(!i&&!a&&l!==""?` `:"")+n_(l,t),i=a}return n}function n_(e,t){if(e===""||e[0]===" ")return e;for(var r=/ [^ ]/g,n,i=0,a,s=0,u=0,l="";n=r.exec(e);)u=n.index,u-i>t&&(a=s>i?s:u,l+=` `+e.slice(i,a),i=a+1),s=u;return l+=` `,e.length-i>t&&s>i?l+=e.slice(i,s)+` `+e.slice(s+1):l+=e.slice(i),l.slice(1)}function yT(e){for(var t="",r,n,i,a=0;a=55296&&r<=56319&&(n=e.charCodeAt(a+1),n>=56320&&n<=57343)){t+=Zb((r-55296)*1024+n-56320+65536),a++;continue}i=$n[r],t+=!i&&Jl(r)?e[a]:i||Zb(r)}return t}function bT(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?"":" "),jo(e,t,f,!1,!1)&&(d+=e.dump,n+=d));e.tag=i,e.dump="{"+n+"}"}function DT(e,t,r,n){var i="",a=e.tag,s=Object.keys(r),u,l,f,d,g,p;if(e.sortKeys===!0)s.sort();else if(typeof e.sortKeys=="function")s.sort(e.sortKeys);else if(e.sortKeys)throw new _f("sortKeys must be a boolean or a function");for(u=0,l=s.length;u1024,g&&(e.dump&&yf===e.dump.charCodeAt(0)?p+="?":p+="? "),p+=e.dump,g&&(p+=Xg(e,t)),jo(e,t+1,d,!0,g)&&(e.dump&&yf===e.dump.charCodeAt(0)?p+=":":p+=": ",p+=e.dump,i+=p));e.tag=a,e.dump=i||"{}"}function i_(e,t,r){var n,i,a,s,u,l;for(i=r?e.explicitTypes:e.implicitTypes,a=0,s=i.length;a tag resolver accepts not "'+l+'" style');e.dump=n}return!0}return!1}function jo(e,t,r,n,i,a){e.tag=null,e.dump=r,i_(e,r,!1)||i_(e,r,!0);var s=s_.call(e.dump);n&&(n=e.flowLevel<0||e.flowLevel>t);var u=s==="[object Object]"||s==="[object Array]",l,f;if(u&&(l=e.duplicates.indexOf(r),f=l!==-1),(e.tag!==null&&e.tag!=="?"||f||e.indent!==2&&t>0)&&(i=!1),f&&e.usedDuplicates[l])e.dump="*ref_"+l;else{if(u&&f&&!e.usedDuplicates[l]&&(e.usedDuplicates[l]=!0),s==="[object Object]")n&&Object.keys(e.dump).length!==0?(DT(e,t,e.dump,i),f&&(e.dump="&ref_"+l+e.dump)):(CT(e,t,e.dump),f&&(e.dump="&ref_"+l+" "+e.dump));else if(s==="[object Array]"){var d=e.noArrayIndent&&t>0?t-1:t;n&&e.dump.length!==0?(_T(e,d,e.dump,i),f&&(e.dump="&ref_"+l+e.dump)):(bT(e,d,e.dump),f&&(e.dump="&ref_"+l+" "+e.dump))}else if(s==="[object String]")e.tag!=="?"&&wT(e,e.dump,t,a);else{if(e.skipInvalid)return!1;throw new _f("unacceptable kind of an object to dump "+s)}e.tag!==null&&e.tag!=="?"&&(e.dump="!<"+e.tag+"> "+e.dump)}return!0}function FT(e,t){var r=[],n=[],i,a;for(Jg(e,r,n),i=0,a=n.length;i{"use strict";var ld=Jb(),y_=A_();function cd(e){return function(){throw new Error("Function "+e+" is deprecated and cannot be used.")}}Dr.exports.Type=zr();Dr.exports.Schema=ko();Dr.exports.FAILSAFE_SCHEMA=td();Dr.exports.JSON_SCHEMA=Vg();Dr.exports.CORE_SCHEMA=Kg();Dr.exports.DEFAULT_SAFE_SCHEMA=Gl();Dr.exports.DEFAULT_FULL_SCHEMA=wf();Dr.exports.load=ld.load;Dr.exports.loadAll=ld.loadAll;Dr.exports.safeLoad=ld.safeLoad;Dr.exports.safeLoadAll=ld.safeLoadAll;Dr.exports.dump=y_.dump;Dr.exports.safeDump=y_.safeDump;Dr.exports.YAMLException=Kl();Dr.exports.MINIMAL_SCHEMA=td();Dr.exports.SAFE_SCHEMA=Gl();Dr.exports.DEFAULT_SCHEMA=wf();Dr.exports.scan=cd("scan");Dr.exports.parse=cd("parse");Dr.exports.compose=cd("compose");Dr.exports.addConstructor=cd("addConstructor")});var C_=le((eG,__)=>{"use strict";var IT=b_();__.exports=IT});var F_=le((tG,D_)=>{"use strict";var fd=C_();D_.exports={safeLoad:fd.safeLoad,load:fd.load,safeDump:fd.safeDump,dump:fd.dump}});var tm=le(Zl=>{"use strict";Object.defineProperty(Zl,"__esModule",{value:!0});Zl.isCorrect=Zl.isInSubnet=void 0;function NT(e){return this.subnetMask{"use strict";Object.defineProperty(Js,"__esModule",{value:!0});Js.RE_SUBNET_STRING=Js.RE_ADDRESS=Js.GROUPS=Js.BITS=void 0;Js.BITS=32;Js.GROUPS=4;Js.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;Js.RE_SUBNET_STRING=/\/\d{1,2}$/});var pd=le(dd=>{"use strict";Object.defineProperty(dd,"__esModule",{value:!0});dd.AddressError=void 0;var nm=class extends Error{constructor(t,r){super(t),this.name="AddressError",r!==null&&(this.parseMessage=r)}};dd.AddressError=nm});var im=le((gd,$_)=>{(function(){var e,t=0xdeadbeefcafe,r=(t&16777215)==15715070;function n(x,N,V){x!=null&&(typeof x=="number"?this.fromNumber(x,N,V):N==null&&typeof x!="string"?this.fromString(x,256):this.fromString(x,N))}function i(){return new n(null)}function a(x,N,V,Q,ve,Ae){for(;--Ae>=0;){var Ie=N*this[x++]+V[Q]+ve;ve=Math.floor(Ie/67108864),V[Q++]=Ie&67108863}return ve}function s(x,N,V,Q,ve,Ae){for(var Ie=N&32767,xe=N>>15;--Ae>=0;){var Yt=this[x]&32767,br=this[x++]>>15,hn=xe*Yt+br*Ie;Yt=Ie*Yt+((hn&32767)<<15)+V[Q]+(ve&1073741823),ve=(Yt>>>30)+(hn>>>15)+xe*br+(ve>>>30),V[Q++]=Yt&1073741823}return ve}function u(x,N,V,Q,ve,Ae){for(var Ie=N&16383,xe=N>>14;--Ae>=0;){var Yt=this[x]&16383,br=this[x++]>>14,hn=xe*Yt+br*Ie;Yt=Ie*Yt+((hn&16383)<<14)+V[Q]+ve,ve=(Yt>>28)+(hn>>14)+xe*br,V[Q++]=Yt&268435455}return ve}var l=typeof navigator<"u";l&&r&&navigator.appName=="Microsoft Internet Explorer"?(n.prototype.am=s,e=30):l&&r&&navigator.appName!="Netscape"?(n.prototype.am=a,e=26):(n.prototype.am=u,e=28),n.prototype.DB=e,n.prototype.DM=(1<=0;--N)x[N]=this[N];x.t=this.t,x.s=this.s}function m(x){this.t=1,this.s=x<0?-1:0,x>0?this[0]=x:x<-1?this[0]=x+this.DV:this.t=0}function y(x){var N=i();return N.fromInt(x),N}function D(x,N){var V;if(N==16)V=4;else if(N==8)V=3;else if(N==256)V=8;else if(N==2)V=1;else if(N==32)V=5;else if(N==4)V=2;else{this.fromRadix(x,N);return}this.t=0,this.s=0;for(var Q=x.length,ve=!1,Ae=0;--Q>=0;){var Ie=V==8?x[Q]&255:v(x,Q);if(Ie<0){x.charAt(Q)=="-"&&(ve=!0);continue}ve=!1,Ae==0?this[this.t++]=Ie:Ae+V>this.DB?(this[this.t-1]|=(Ie&(1<>this.DB-Ae):this[this.t-1]|=Ie<=this.DB&&(Ae-=this.DB)}V==8&&x[0]&128&&(this.s=-1,Ae>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==x;)--this.t}function F(x){if(this.s<0)return"-"+this.negate().toString(x);var N;if(x==16)N=4;else if(x==8)N=3;else if(x==2)N=1;else if(x==32)N=5;else if(x==4)N=2;else return this.toRadix(x);var V=(1<0)for(xe>xe)>0&&(ve=!0,Ae=E(Q));Ie>=0;)xe>(xe+=this.DB-N)):(Q=this[Ie]>>(xe-=N)&V,xe<=0&&(xe+=this.DB,--Ie)),Q>0&&(ve=!0),ve&&(Ae+=E(Q));return ve?Ae:"0"}function L(){var x=i();return n.ZERO.subTo(this,x),x}function k(){return this.s<0?this.negate():this}function S(x){var N=this.s-x.s;if(N!=0)return N;var V=this.t;if(N=V-x.t,N!=0)return this.s<0?-N:N;for(;--V>=0;)if((N=this[V]-x[V])!=0)return N;return 0}function B(x){var N=1,V;return(V=x>>>16)!=0&&(x=V,N+=16),(V=x>>8)!=0&&(x=V,N+=8),(V=x>>4)!=0&&(x=V,N+=4),(V=x>>2)!=0&&(x=V,N+=2),(V=x>>1)!=0&&(x=V,N+=1),N}function O(){return this.t<=0?0:this.DB*(this.t-1)+B(this[this.t-1]^this.s&this.DM)}function P(x,N){var V;for(V=this.t-1;V>=0;--V)N[V+x]=this[V];for(V=x-1;V>=0;--V)N[V]=0;N.t=this.t+x,N.s=this.s}function U(x,N){for(var V=x;V=0;--xe)N[xe+Ae+1]=this[xe]>>Q|Ie,Ie=(this[xe]&ve)<=0;--xe)N[xe]=0;N[Ae]=Ie,N.t=this.t+Ae+1,N.s=this.s,N.clamp()}function H(x,N){N.s=this.s;var V=Math.floor(x/this.DB);if(V>=this.t){N.t=0;return}var Q=x%this.DB,ve=this.DB-Q,Ae=(1<>Q;for(var Ie=V+1;Ie>Q;Q>0&&(N[this.t-V-1]|=(this.s&Ae)<>=this.DB;if(x.t>=this.DB;Q+=this.s}else{for(Q+=this.s;V>=this.DB;Q-=x.s}N.s=Q<0?-1:0,Q<-1?N[V++]=this.DV+Q:Q>0&&(N[V++]=Q),N.t=V,N.clamp()}function W(x,N){var V=this.abs(),Q=x.abs(),ve=V.t;for(N.t=ve+Q.t;--ve>=0;)N[ve]=0;for(ve=0;ve=0;)x[V]=0;for(V=0;V=N.DV&&(x[V+N.t]-=N.DV,x[V+N.t+1]=1)}x.t>0&&(x[x.t-1]+=N.am(V,N[V],x,2*V,0,1)),x.s=0,x.clamp()}function Ce(x,N,V){var Q=x.abs();if(!(Q.t<=0)){var ve=this.abs();if(ve.t0?(Q.lShiftTo(Yt,Ae),ve.lShiftTo(Yt,V)):(Q.copyTo(Ae),ve.copyTo(V));var br=Ae.t,hn=Ae[br-1];if(hn!=0){var dn=hn*(1<1?Ae[br-2]>>this.F2:0),Si=this.FV/dn,Fu=(1<=0&&(V[V.t++]=1,V.subTo(Wi,V)),n.ONE.dlShiftTo(br,Wi),Wi.subTo(Ae,Ae);Ae.t=0;){var go=V[--pn]==hn?this.DM:Math.floor(V[pn]*Si+(V[pn-1]+Mn)*Fu);if((V[pn]+=Ae.am(0,go,V,Su,0,br))0&&V.rShiftTo(Yt,V),Ie<0&&n.ZERO.subTo(V,V)}}}function Fe(x){var N=i();return this.abs().divRemTo(x,null,N),this.s<0&&N.compareTo(n.ZERO)>0&&x.subTo(N,N),N}function Pe(x){this.m=x}function rt(x){return x.s<0||x.compareTo(this.m)>=0?x.mod(this.m):x}function tt(x){return x}function ct(x){x.divRemTo(this.m,null,x)}function ft(x,N,V){x.multiplyTo(N,V),this.reduce(V)}function sn(x,N){x.squareTo(N),this.reduce(N)}Pe.prototype.convert=rt,Pe.prototype.revert=tt,Pe.prototype.reduce=ct,Pe.prototype.mulTo=ft,Pe.prototype.sqrTo=sn;function nr(){if(this.t<1)return 0;var x=this[0];if(!(x&1))return 0;var N=x&3;return N=N*(2-(x&15)*N)&15,N=N*(2-(x&255)*N)&255,N=N*(2-((x&65535)*N&65535))&65535,N=N*(2-x*N%this.DV)%this.DV,N>0?this.DV-N:-N}function _t(x){this.m=x,this.mp=x.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(N,N),N}function sr(x){var N=i();return x.copyTo(N),this.reduce(N),N}function dt(x){for(;x.t<=this.mt2;)x[x.t++]=0;for(var N=0;N>15)*this.mpl&this.um)<<15)&x.DM;for(V=N+this.m.t,x[V]+=this.m.am(0,Q,x,N,0,this.m.t);x[V]>=x.DV;)x[V]-=x.DV,x[++V]++}x.clamp(),x.drShiftTo(this.m.t,x),x.compareTo(this.m)>=0&&x.subTo(this.m,x)}function zt(x,N){x.squareTo(N),this.reduce(N)}function nt(x,N,V){x.multiplyTo(N,V),this.reduce(V)}_t.prototype.convert=Er,_t.prototype.revert=sr,_t.prototype.reduce=dt,_t.prototype.mulTo=nt,_t.prototype.sqrTo=zt;function Ke(){return(this.t>0?this[0]&1:this.s)==0}function ar(x,N){if(x>4294967295||x<1)return n.ONE;var V=i(),Q=i(),ve=N.convert(this),Ae=B(x)-1;for(ve.copyTo(V);--Ae>=0;)if(N.sqrTo(V,Q),(x&1<0)N.mulTo(Q,ve,V);else{var Ie=V;V=Q,Q=Ie}return N.revert(V)}function He(x,N){var V;return x<256||N.isEven()?V=new Pe(N):V=new _t(N),this.exp(x,V)}n.prototype.copyTo=b,n.prototype.fromInt=m,n.prototype.fromString=D,n.prototype.clamp=C,n.prototype.dlShiftTo=P,n.prototype.drShiftTo=U,n.prototype.lShiftTo=Y,n.prototype.rShiftTo=H,n.prototype.subTo=K,n.prototype.multiplyTo=W,n.prototype.squareTo=ie,n.prototype.divRemTo=Ce,n.prototype.invDigit=nr,n.prototype.isEven=Ke,n.prototype.exp=ar,n.prototype.toString=F,n.prototype.negate=L,n.prototype.abs=k,n.prototype.compareTo=S,n.prototype.bitLength=O,n.prototype.mod=Fe,n.prototype.modPowInt=He,n.ZERO=y(0),n.ONE=y(1);function Ot(){var x=i();return this.copyTo(x),x}function an(){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 Gt(){return this.t==0?this.s:this[0]<<16>>16}function vt(x){return Math.floor(Math.LN2*this.DB/Math.log(x))}function Or(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function Fi(x){if(x==null&&(x=10),this.signum()==0||x<2||x>36)return"0";var N=this.chunkSize(x),V=Math.pow(x,N),Q=y(V),ve=i(),Ae=i(),Ie="";for(this.divRemTo(Q,ve,Ae);ve.signum()>0;)Ie=(V+Ae.intValue()).toString(x).substr(1)+Ie,ve.divRemTo(Q,ve,Ae);return Ae.intValue().toString(x)+Ie}function un(x,N){this.fromInt(0),N==null&&(N=10);for(var V=this.chunkSize(N),Q=Math.pow(N,V),ve=!1,Ae=0,Ie=0,xe=0;xe=V&&(this.dMultiply(Q),this.dAddOffset(Ie,0),Ae=0,Ie=0)}Ae>0&&(this.dMultiply(Math.pow(N,Ae)),this.dAddOffset(Ie,0)),ve&&n.ZERO.subTo(this,this)}function Ft(x,N,V){if(typeof N=="number")if(x<2)this.fromInt(1);else for(this.fromNumber(x,V),this.testBit(x-1)||this.bitwiseTo(n.ONE.shiftLeft(x-1),ge,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(N);)this.dAddOffset(2,0),this.bitLength()>x&&this.subTo(n.ONE.shiftLeft(x-1),this);else{var Q=new Array,ve=x&7;Q.length=(x>>3)+1,N.nextBytes(Q),ve>0?Q[0]&=(1<0)for(V>V)!=(this.s&this.DM)>>V&&(N[ve++]=Q|this.s<=0;)V<8?(Q=(this[x]&(1<>(V+=this.DB-8)):(Q=this[x]>>(V-=8)&255,V<=0&&(V+=this.DB,--x)),Q&128&&(Q|=-256),ve==0&&(this.s&128)!=(Q&128)&&++ve,(ve>0||Q!=this.s)&&(N[ve++]=Q);return N}function De(x){return this.compareTo(x)==0}function wr(x){return this.compareTo(x)<0?this:x}function on(x){return this.compareTo(x)>0?this:x}function it(x,N,V){var Q,ve,Ae=Math.min(x.t,this.t);for(Q=0;Q>=16,N+=16),x&255||(x>>=8,N+=8),x&15||(x>>=4,N+=4),x&3||(x>>=2,N+=2),x&1||++N,N}function Tt(){for(var x=0;x=this.t?this.s!=0:(this[N]&1<>=this.DB;if(x.t>=this.DB;Q+=this.s}else{for(Q+=this.s;V>=this.DB;Q+=x.s}N.s=Q<0?-1:0,Q>0?N[V++]=Q:Q<-1&&(N[V++]=this.DV+Q),N.t=V,N.clamp()}function Fa(x){var N=i();return this.addTo(x,N),N}function re(x){var N=i();return this.subTo(x,N),N}function fe(x){var N=i();return this.multiplyTo(x,N),N}function Le(){var x=i();return this.squareTo(x),x}function Oe(x){var N=i();return this.divRemTo(x,N,null),N}function Ve(x){var N=i();return this.divRemTo(x,null,N),N}function st(x){var N=i(),V=i();return this.divRemTo(x,N,V),new Array(N,V)}function ht(x){this[this.t]=this.am(0,x-1,this,0,0,this.t),++this.t,this.clamp()}function Ir(x,N){if(x!=0){for(;this.t<=N;)this[this.t++]=0;for(this[N]+=x;this[N]>=this.DV;)this[N]-=this.DV,++N>=this.t&&(this[this.t++]=0),++this[N]}}function Ht(){}function ni(x){return x}function Yi(x,N,V){x.multiplyTo(N,V)}function cn(x,N){x.squareTo(N)}Ht.prototype.convert=ni,Ht.prototype.revert=ni,Ht.prototype.mulTo=Yi,Ht.prototype.sqrTo=cn;function Dn(x){return this.exp(x,new Ht)}function Ar(x,N,V){var Q=Math.min(this.t+x.t,N);for(V.s=0,V.t=Q;Q>0;)V[--Q]=0;var ve;for(ve=V.t-this.t;Q=0;)V[Q]=0;for(Q=Math.max(N-this.t,0);Q2*this.m.t)return x.mod(this.m);if(x.compareTo(this.m)<0)return x;var N=i();return x.copyTo(N),this.reduce(N),N}function Us(x){return x}function Ln(x){for(x.drShiftTo(this.m.t-1,this.r2),x.t>this.m.t+1&&(x.t=this.m.t+1,x.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);x.compareTo(this.r2)<0;)x.dAddOffset(1,this.m.t+1);for(x.subTo(this.r2,x);x.compareTo(this.m)>=0;)x.subTo(this.m,x)}function xt(x,N){x.squareTo(N),this.reduce(N)}function yr(x,N,V){x.multiplyTo(N,V),this.reduce(V)}Mr.prototype.convert=uo,Mr.prototype.revert=Us,Mr.prototype.reduce=Ln,Mr.prototype.mulTo=yr,Mr.prototype.sqrTo=xt;function Ze(x,N){var V=x.bitLength(),Q,ve=y(1),Ae;if(V<=0)return ve;V<18?Q=1:V<48?Q=3:V<144?Q=4:V<768?Q=5:Q=6,V<8?Ae=new Pe(N):N.isEven()?Ae=new Mr(N):Ae=new _t(N);var Ie=new Array,xe=3,Yt=Q-1,br=(1<1){var hn=i();for(Ae.sqrTo(Ie[1],hn);xe<=br;)Ie[xe]=i(),Ae.mulTo(hn,Ie[xe-2],Ie[xe]),xe+=2}var dn=x.t-1,Si,Fu=!0,Mn=i(),pn;for(V=B(x[dn])-1;dn>=0;){for(V>=Yt?Si=x[dn]>>V-Yt&br:(Si=(x[dn]&(1<0&&(Si|=x[dn-1]>>this.DB+V-Yt)),xe=Q;!(Si&1);)Si>>=1,--xe;if((V-=xe)<0&&(V+=this.DB,--dn),Fu)Ie[Si].copyTo(ve),Fu=!1;else{for(;xe>1;)Ae.sqrTo(ve,Mn),Ae.sqrTo(Mn,ve),xe-=2;xe>0?Ae.sqrTo(ve,Mn):(pn=ve,ve=Mn,Mn=pn),Ae.mulTo(Mn,Ie[Si],ve)}for(;dn>=0&&!(x[dn]&1<0&&(N.rShiftTo(Ae,N),V.rShiftTo(Ae,V));N.signum()>0;)(ve=N.getLowestSetBit())>0&&N.rShiftTo(ve,N),(ve=V.getLowestSetBit())>0&&V.rShiftTo(ve,V),N.compareTo(V)>=0?(N.subTo(V,N),N.rShiftTo(1,N)):(V.subTo(N,V),V.rShiftTo(1,V));return Ae>0&&V.lShiftTo(Ae,V),V}function Wr(x){if(x<=0)return 0;var N=this.DV%x,V=this.s<0?x-1:0;if(this.t>0)if(N==0)V=this[0]%x;else for(var Q=this.t-1;Q>=0;--Q)V=(N*V+this[Q])%x;return V}function or(x){var N=x.isEven();if(this.isEven()&&N||x.signum()==0)return n.ZERO;for(var V=x.clone(),Q=this.clone(),ve=y(1),Ae=y(0),Ie=y(0),xe=y(1);V.signum()!=0;){for(;V.isEven();)V.rShiftTo(1,V),N?((!ve.isEven()||!Ae.isEven())&&(ve.addTo(this,ve),Ae.subTo(x,Ae)),ve.rShiftTo(1,ve)):Ae.isEven()||Ae.subTo(x,Ae),Ae.rShiftTo(1,Ae);for(;Q.isEven();)Q.rShiftTo(1,Q),N?((!Ie.isEven()||!xe.isEven())&&(Ie.addTo(this,Ie),xe.subTo(x,xe)),Ie.rShiftTo(1,Ie)):xe.isEven()||xe.subTo(x,xe),xe.rShiftTo(1,xe);V.compareTo(Q)>=0?(V.subTo(Q,V),N&&ve.subTo(Ie,ve),Ae.subTo(xe,Ae)):(Q.subTo(V,Q),N&&Ie.subTo(ve,Ie),xe.subTo(Ae,xe))}if(Q.compareTo(n.ONE)!=0)return n.ZERO;if(xe.compareTo(x)>=0)return xe.subtract(x);if(xe.signum()<0)xe.addTo(x,xe);else return xe;return xe.signum()<0?xe.add(x):xe}var Mt=[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],Un=(1<<26)/Mt[Mt.length-1];function ii(x){var N,V=this.abs();if(V.t==1&&V[0]<=Mt[Mt.length-1]){for(N=0;N>1,x>Mt.length&&(x=Mt.length);for(var ve=i(),Ae=0;Ae>8&255,Tr[fr++]^=x>>16&255,Tr[fr++]^=x>>24&255,fr>=Hn&&(fr-=Hn)}function oo(){jc(new Date().getTime())}if(Tr==null){Tr=new Array,fr=0;var Xr;if(typeof window<"u"&&window.crypto){if(window.crypto.getRandomValues){var lo=new Uint8Array(32);for(window.crypto.getRandomValues(lo),Xr=0;Xr<32;++Xr)Tr[fr++]=lo[Xr]}else if(navigator.appName=="Netscape"&&navigator.appVersion<"5"){var ul=window.crypto.random(32);for(Xr=0;Xr>>8,Tr[fr++]=Xr&255;fr=0,oo()}function ol(){if(jn==null){for(oo(),jn=po(),jn.init(Tr),fr=0;fr{(function(){"use strict";var e={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function t(s){return n(a(s),arguments)}function r(s,u){return t.apply(null,[s].concat(u||[]))}function n(s,u){var l=1,f=s.length,d,g="",p,h,E,v,b,m,y,D;for(p=0;p=0),E.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,E.width?parseInt(E.width):0);break;case"e":d=E.precision?parseFloat(d).toExponential(E.precision):parseFloat(d).toExponential();break;case"f":d=E.precision?parseFloat(d).toFixed(E.precision):parseFloat(d);break;case"g":d=E.precision?String(Number(d.toPrecision(E.precision))):parseFloat(d);break;case"o":d=(parseInt(d,10)>>>0).toString(8);break;case"s":d=String(d),d=E.precision?d.substring(0,E.precision):d;break;case"t":d=String(!!d),d=E.precision?d.substring(0,E.precision):d;break;case"T":d=Object.prototype.toString.call(d).slice(8,-1).toLowerCase(),d=E.precision?d.substring(0,E.precision):d;break;case"u":d=parseInt(d,10)>>>0;break;case"v":d=d.valueOf(),d=E.precision?d.substring(0,E.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(E.type)?g+=d:(e.number.test(E.type)&&(!y||E.sign)?(D=y?"+":"-",d=d.toString().replace(e.sign,"")):D="",b=E.pad_char?E.pad_char==="0"?"0":E.pad_char.charAt(1):" ",m=E.width-(D+d).length,v=E.width&&m>0?b.repeat(m):"",g+=E.align?D+d+v:b==="0"?D+v+d:v+D+d)}return g}var i=Object.create(null);function a(s){if(i[s])return i[s];for(var u=s,l,f=[],d=0;u;){if((l=e.text.exec(u))!==null)f.push(l[0]);else if((l=e.modulo.exec(u))!==null)f.push("%");else if((l=e.placeholder.exec(u))!==null){if(l[2]){d|=1;var g=[],p=l[2],h=[];if((h=e.key.exec(p))!==null)for(g.push(h[1]);(p=p.substring(h[0].length))!=="";)if((h=e.key_access.exec(p))!==null)g.push(h[1]);else if((h=e.index_access.exec(p))!==null)g.push(h[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");l[2]=g}else d|=2;if(d===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");f.push({placeholder:l[0],param_no:l[1],keys:l[2],sign:l[3],pad_char:l[4],align:l[5],width:l[6],precision:l[7],type:l[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");u=u.substring(l[0].length)}return i[s]=f}typeof md<"u"&&(md.sprintf=t,md.vsprintf=r),typeof window<"u"&&(window.sprintf=t,window.vsprintf=r,typeof define=="function"&&define.amd&&define(function(){return{sprintf:t,vsprintf:r}}))})()});var am=le(Zs=>{"use strict";var UT=Zs&&Zs.__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]}),jT=Zs&&Zs.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),x_=Zs&&Zs.__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)&&UT(t,e,r);return jT(t,e),t};Object.defineProperty(Zs,"__esModule",{value:!0});Zs.Address4=void 0;var R_=x_(tm()),_s=x_(rm()),P_=pd(),Sf=im(),Ql=Ff(),sm=class e{constructor(t){this.groups=_s.GROUPS,this.parsedAddress=[],this.parsedSubnet="",this.subnet="/32",this.subnetMask=32,this.v4=!0,this.isCorrect=R_.isCorrect(_s.BITS),this.isInSubnet=R_.isInSubnet,this.address=t;let r=_s.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>_s.BITS)throw new P_.AddressError("Invalid subnet mask.");t=t.replace(_s.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(_s.RE_ADDRESS))throw new P_.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,Ql.sprintf)("%02x",parseInt(t,10))).join(":")}toArray(){return this.parsedAddress.map(t=>parseInt(t,10))}toGroup6(){let t=[],r;for(r=0;r<_s.GROUPS;r+=2){let n=(0,Ql.sprintf)("%02x%02x",parseInt(this.parsedAddress[r],10),parseInt(this.parsedAddress[r+1],10));t.push((0,Ql.sprintf)("%x",parseInt(n,16)))}return t.join(":")}bigInteger(){return new Sf.BigInteger(this.parsedAddress.map(t=>(0,Ql.sprintf)("%02x",parseInt(t,10))).join(""),16)}_startAddress(){return new Sf.BigInteger(this.mask()+"0".repeat(_s.BITS-this.subnetMask),2)}startAddress(){return e.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new Sf.BigInteger("1");return e.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new Sf.BigInteger(this.mask()+"1".repeat(_s.BITS-this.subnetMask),2)}endAddress(){return e.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new Sf.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,Ql.sprintf)("%s.in-addr.arpa.",r)}isMulticast(){return this.isInSubnet(new e("224.0.0.0/4"))}binaryZeroPad(){return this.bigInteger().toString(2).padStart(_s.BITS,"0")}groupForV6(){let t=this.parsedAddress;return this.address.replace(_s.RE_ADDRESS,(0,Ql.sprintf)('%s.%s',t.slice(0,2).join("."),t.slice(2,4).join(".")))}};Zs.Address4=sm});var um=le(Fr=>{"use strict";Object.defineProperty(Fr,"__esModule",{value:!0});Fr.RE_URL_WITH_PORT=Fr.RE_URL=Fr.RE_ZONE_STRING=Fr.RE_SUBNET_STRING=Fr.RE_BAD_ADDRESS=Fr.RE_BAD_CHARACTERS=Fr.TYPES=Fr.SCOPES=Fr.GROUPS=Fr.BITS=void 0;Fr.BITS=128;Fr.GROUPS=8;Fr.SCOPES={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"};Fr.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"};Fr.RE_BAD_CHARACTERS=/([^0-9a-f:/%])/gi;Fr.RE_BAD_ADDRESS=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi;Fr.RE_SUBNET_STRING=/\/\d{1,3}(?=%|$)/;Fr.RE_ZONE_STRING=/%.*$/;Fr.RE_URL=new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/);Fr.RE_URL_WITH_PORT=new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/)});var om=le(Qs=>{"use strict";Object.defineProperty(Qs,"__esModule",{value:!0});Qs.simpleGroup=Qs.spanLeadingZeroes=Qs.spanAll=Qs.spanAllZeroes=void 0;var O_=Ff();function T_(e){return e.replace(/(0+)/g,'$1')}Qs.spanAllZeroes=T_;function HT(e,t=0){return e.split("").map((n,i)=>(0,O_.sprintf)('%s',n,i+t,T_(n))).join("")}Qs.spanAll=HT;function k_(e){return e.replace(/^(0+)/,'$1')}function MT(e){return e.split(":").map(r=>k_(r)).join(":")}Qs.spanLeadingZeroes=MT;function qT(e,t=0){return e.split(":").map((n,i)=>/group-v4/.test(n)?n:(0,O_.sprintf)('%s',i+t,k_(n)))}Qs.simpleGroup=qT});var N_=le(tn=>{"use strict";var VT=tn&&tn.__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]}),KT=tn&&tn.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),zT=tn&&tn.__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)&&VT(t,e,r);return KT(t,e),t};Object.defineProperty(tn,"__esModule",{value:!0});tn.possibleElisions=tn.simpleRegularExpression=tn.ADDRESS_BOUNDARY=tn.padGroup=tn.groupPossibilities=void 0;var GT=zT(um()),ec=Ff();function Ed(e){return(0,ec.sprintf)("(%s)",e.join("|"))}tn.groupPossibilities=Ed;function vd(e){return e.length<4?(0,ec.sprintf)("0{0,%d}%s",4-e.length,e):e}tn.padGroup=vd;tn.ADDRESS_BOUNDARY="[^A-Fa-f0-9:]";function YT(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===GT.GROUPS-1?":":"";return Ed([vd(i),s])}return vd(i)}).join(":"));return r.push(e.map(vd).join(":")),Ed(r)}tn.simpleRegularExpression=YT;function WT(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,ec.sprintf)("%s(:0{1,4}){1,%d}",n,e-1)),a.push((0,ec.sprintf)("(0{1,4}:){1,%d}%s",e-1,i)),a.push((0,ec.sprintf)("(0{1,4}:){%d}0{1,4}",e-1));for(let s=1;s{"use strict";var XT=ea&&ea.__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]}),JT=ea&&ea.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Ad=ea&&ea.__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)&&XT(t,e,r);return JT(t,e),t};Object.defineProperty(ea,"__esModule",{value:!0});ea.Address6=void 0;var L_=Ad(tm()),lm=Ad(rm()),ir=Ad(um()),cm=Ad(om()),Ho=am(),Mo=N_(),Ja=pd(),Wn=im(),Xn=Ff();function wd(e){if(!e)throw new Error("Assertion failed.")}function ZT(e){let t=/(\d+)(\d{3})/;for(;t.test(e);)e=e.replace(t,"$1,$2");return e}function QT(e){return e=e.replace(/^(0{1,})([1-9]+)$/,'$1$2'),e=e.replace(/^(0{1,})(0)$/,'$1$2'),e}function ek(e,t){let r=[],n=[],i;for(i=0;it[1]&&n.push(e[i]);return r.concat(["compact"]).concat(n)}function U_(e){return(0,Xn.sprintf)("%04x",parseInt(e,16))}function j_(e){return e&255}var fm=class e{constructor(t,r){this.addressMinusSuffix="",this.parsedSubnet="",this.subnet="/128",this.subnetMask=128,this.v4=!1,this.zone="",this.isInSubnet=L_.isInSubnet,this.isCorrect=L_.isCorrect(ir.BITS),r===void 0?this.groups=ir.GROUPS:this.groups=r,this.address=t;let n=ir.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>ir.BITS)throw new Ja.AddressError("Invalid subnet mask.");t=t.replace(ir.RE_SUBNET_STRING,"")}else if(/\//.test(t))throw new Ja.AddressError("Invalid subnet mask.");let i=ir.RE_ZONE_STRING.exec(t);i&&(this.zone=i[0],t=t.replace(ir.RE_ZONE_STRING,"")),this.addressMinusSuffix=t,this.parsedAddress=this.parse(this.addressMinusSuffix)}static isValid(t){try{return new e(t),!0}catch{return!1}}static fromBigInteger(t){let r=t.toString(16).padStart(32,"0"),n=[],i;for(i=0;i65536)&&(n=null)):n=null,{address:new e(r),port:n}}static fromAddress4(t){let r=new Ho.Address4(t),n=ir.BITS-(lm.BITS-r.subnetMask);return new e(`::ffff:${r.correctForm()}/${n}`)}static fromArpa(t){let r=t.replace(/(\.ip6\.arpa)?\.$/,""),n=7;if(r.length!==63)throw new Ja.AddressError("Invalid 'ip6.arpa' form.");let i=r.split(".").reverse();for(let a=n;a>0;a--){let s=a*4;i.splice(s,0,":")}return r=i.join(""),new e(r)}microsoftTranscription(){return(0,Xn.sprintf)("%s.ipv6-literal.net",this.correctForm().replace(/:/g,"-"))}mask(t=this.subnetMask){return this.getBitsBase2(0,t)}possibleSubnets(t=128){let r=ir.BITS-this.subnetMask,n=Math.abs(t-ir.BITS),i=r-n;return i<0?"0":ZT(new Wn.BigInteger("2",10).pow(i).toString(10))}_startAddress(){return new Wn.BigInteger(this.mask()+"0".repeat(ir.BITS-this.subnetMask),2)}startAddress(){return e.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new Wn.BigInteger("1");return e.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new Wn.BigInteger(this.mask()+"1".repeat(ir.BITS-this.subnetMask),2)}endAddress(){return e.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new Wn.BigInteger("1");return e.fromBigInteger(this._endAddress().subtract(t))}getScope(){let t=ir.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(ir.TYPES))if(this.isInSubnet(new e(t)))return ir.TYPES[t];return"Global unicast"}getBits(t,r){return new Wn.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,ir.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,Xn.sprintf)("%s.ip6.arpa.",n):t.omitSuffix?"":"ip6.arpa."}correctForm(){let t,r=[],n=0,i=[];for(t=0;t0&&(n>1&&i.push([t-n,t-1]),n=0)}n>1&&i.push([this.parsedAddress.length-n,this.parsedAddress.length-1]);let a=i.map(u=>u[1]-u[0]+1);if(i.length>0){let u=a.indexOf(Math.max(...a));r=ek(this.parsedAddress,i[u])}else r=this.parsedAddress;for(t=0;t1?"s":"",r.join("")),t.replace(ir.RE_BAD_CHARACTERS,'$1'));let n=t.match(ir.RE_BAD_ADDRESS);if(n)throw new Ja.AddressError((0,Xn.sprintf)("Address failed regex: %s",n.join("")),t.replace(ir.RE_BAD_ADDRESS,'$1'));let i=[],a=t.split("::");if(a.length===2){let s=a[0].split(":"),u=a[1].split(":");s.length===1&&s[0]===""&&(s=[]),u.length===1&&u[0]===""&&(u=[]);let l=this.groups-(s.length+u.length);if(!l)throw new Ja.AddressError("Error parsing groups");this.elidedGroups=l,this.elisionBegin=s.length,this.elisionEnd=s.length+this.elidedGroups,i=i.concat(s);for(let f=0;f(0,Xn.sprintf)("%x",parseInt(s,16))),i.length!==this.groups)throw new Ja.AddressError("Incorrect number of groups found");return i}canonicalForm(){return this.parsedAddress.map(U_).join(":")}decimal(){return this.parsedAddress.map(t=>(0,Xn.sprintf)("%05d",parseInt(t,16))).join(":")}bigInteger(){return new Wn.BigInteger(this.parsedAddress.map(U_).join(""),16)}to4(){let t=this.binaryZeroPad().split("");return Ho.Address4.fromHex(new Wn.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 Wn.BigInteger("ffff",16)).toString(),n=Ho.Address4.fromHex(this.getBitsBase16(32,64)),i=Ho.Address4.fromHex(this.getBits(96,128).xor(new Wn.BigInteger("ffffffff",16)).toString(16)),a=this.getBits(64,80),s=this.getBitsBase2(64,80),u=a.testBit(15),l=a.testBit(14),f=a.testBit(8),d=a.testBit(9),g=new Wn.BigInteger(s.slice(2,6)+s.slice(8,16),2).toString(10);return{prefix:(0,Xn.sprintf)("%s:%s",t.slice(0,4),t.slice(4,8)),server4:n.address,client4:i.address,flags:s,coneNat:u,microsoft:{reserved:l,universalLocal:d,groupIndividual:f,nonce:g},udpPort:r}}inspect6to4(){let t=this.getBitsBase16(0,16),r=Ho.Address4.fromHex(this.getBitsBase16(16,48));return{prefix:(0,Xn.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(j_)}static fromByteArray(t){return this.fromUnsignedByteArray(t.map(j_))}static fromUnsignedByteArray(t){let r=new Wn.BigInteger("256",10),n=new Wn.BigInteger("0",10),i=new Wn.BigInteger("1",10);for(let a=t.length-1;a>=0;a--)n=n.add(i.multiply(new Wn.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,Xn.sprintf)(":%s",t),(0,Xn.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,Xn.sprintf)('%2$s',t.prefix,r.call(this),t.className):(0,Xn.sprintf)('%2$s',t.prefix,r.call(this))}group(){if(this.elidedGroups===0)return cm.simpleGroup(this.address).join(":");wd(typeof this.elidedGroups=="number"),wd(typeof this.elisionBegin=="number");let t=[],[r,n]=this.address.split("::");r.length?t.push(...cm.simpleGroup(r)):t.push("");let i=["hover-group"];for(let a=this.elisionBegin;a',i.join(" "))),n.length?t.push(...cm.simpleGroup(n,this.elisionEnd)):t.push(""),this.is4()&&(wd(this.address4 instanceof Ho.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,Mo.simpleRegularExpression)(n.parsedAddress));else if(n.elidedGroups===ir.GROUPS)r.push((0,Mo.possibleElisions)(ir.GROUPS));else{let i=n.address.split("::");i[0].length&&r.push((0,Mo.simpleRegularExpression)(i[0].split(":"))),wd(typeof n.elidedGroups=="number"),r.push((0,Mo.possibleElisions)(n.elidedGroups,i[0].length!==0,i[1].length!==0)),i[1].length&&r.push((0,Mo.simpleRegularExpression)(i[1].split(":"))),r=[r.join(":")]}return t||(r=["(?=^|",Mo.ADDRESS_BOUNDARY,"|[^\\w\\:])(",...r,")(?=[^\\w\\:]|",Mo.ADDRESS_BOUNDARY,"|$)"]),r.join("")}regularExpression(t=!1){return new RegExp(this.regularExpressionString(t),"i")}};ea.Address6=fm});var M_=le(Tn=>{"use strict";var tk=Tn&&Tn.__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]}),rk=Tn&&Tn.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),nk=Tn&&Tn.__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)&&tk(t,e,r);return rk(t,e),t};Object.defineProperty(Tn,"__esModule",{value:!0});Tn.v6=Tn.AddressError=Tn.Address6=Tn.Address4=void 0;var ik=am();Object.defineProperty(Tn,"Address4",{enumerable:!0,get:function(){return ik.Address4}});var sk=H_();Object.defineProperty(Tn,"Address6",{enumerable:!0,get:function(){return sk.Address6}});var ak=pd();Object.defineProperty(Tn,"AddressError",{enumerable:!0,get:function(){return ak.AddressError}});var uk=nk(om());Tn.v6={helpers:uk}});var Z_=le(Am=>{"use strict";Am.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};Am.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 Q_=le(ym=>{"use strict";ym.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};ym.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 eC=le(bm=>{"use strict";bm.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};bm.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 tC=le(_m=>{"use strict";_m.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};_m.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 rC=le(Cm=>{"use strict";Cm.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}`};Cm.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 sC=le((iC,Dm)=>{var nC=function(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.decode=g,e.encode=d,e.familyOf=f,e.name=void 0,e.sizeOf=l,e.v6=e.v4=void 0;let t=/^(\d{1,3}\.){3,3}\d{1,3}$/,r=4,n=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,i=16,a={name:"v4",size:r,isFormat:p=>t.test(p),encode(p,h,E){E=~~E,h=h||new Uint8Array(E+r);let v=p.length,b=0;for(let m=0;mp.length>0&&n.test(p),encode(p,h,E){E=~~E;let v=E+i,b=-1,m=0,y=0,D=!0,C=!1;h=h||new Uint8Array(E+i);for(let F=0;F>8),E=97?L-=87:L>=65?L-=55:(L-=48,y=y*10+L),m=(m<<4)+L)}if(D===!1)C===!0?(E>8),E=b+2;F--)h[F]=h[F-2];h[b]=0,h[b+1]=0,b=E}if(b!==E&&b!==-1)for(E>v-2&&(E=v-2);v>b;)h[--v]=Eb?h[--E]:0;else for(;E{"use strict";var qe=j0().Buffer,lu=Z_(),$k=Q_(),Rk=eC(),Pd=tC(),Fm=rC(),Vo=sC(),Pk=0,aC=32768,Sm=32768,xk=~Sm,uC=32768,Ok=~uC,$e=Me.name={};$e.encode=function(e,t,r,{mail:n=!1}={}){t||(t=qe.alloc($e.encodingLength(e))),r||(r=0);let i=r,a=e.replace(/^\.|\.$/gm,"");if(a.length){let s=[];if(n){let u="";a.split(".").forEach(l=>{l.endsWith("\\")?u+=(u.length?".":"")+l.slice(0,-1):s.length===0&&u.length?s.push(u+"."+l):s.push(l)})}else s=a.split(".");for(let u=0;u=e.length)throw new Error("Cannot decode name (buffer overflow)");let l=e[t++];if(s+=u?0:1,l===0)break;if(l&192)if((l&192)===192){if(t+1>e.length)throw new Error("Cannot decode name (buffer overflow)");let f=e.readUInt16BE(t-1)-49152;if(f>=i)throw new Error("Cannot decode name (bad pointer)");t=f,i=f,s+=u?0:1,u=!0}else throw new Error("Cannot decode name (bad label)");else{if(t+l>e.length)throw new Error("Cannot decode name (buffer overflow)");if(a+=l+1,a>254)throw new Error("Cannot decode name (name too long)");let f=e.toString("utf-8",t,t+l);r&&(f=f.replace(/\./g,"\\.")),n.push(f),t+=l,s+=u?0:l}}return $e.decode.bytes=s,n.length===0?".":n.join(".")};$e.decode.bytes=0;$e.encodingLength=function(e){return e==="."||e===".."?1:qe.byteLength(e.replace(/^\.|\.$/gm,""))+2};var wt={};wt.encode=function(e,t,r){t||(t=qe.alloc(wt.encodingLength(e))),r||(r=0);let n=t.write(e,r+1);return t[r]=n,wt.encode.bytes=n+1,t};wt.encode.bytes=0;wt.decode=function(e,t){t||(t=0);let r=e[t],n=e.toString("utf-8",t+1,t+1+r);return wt.decode.bytes=r+1,n};wt.decode.bytes=0;wt.encodingLength=function(e){return qe.byteLength(e)+1};var Fs={};Fs.encode=function(e,t,r){t||(t=Fs.encodingLength(e)),r||(r=0);let n=(e.flags||0)&32767,i=e.type==="response"?aC:Pk;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};Fs.encode.bytes=12;Fs.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&aC?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:Rk.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:$k.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))}};Fs.decode.bytes=12;Fs.encodingLength=function(){return 12};var eu=Me.unknown={};eu.encode=function(e,t,r){return t||(t=qe.alloc(eu.encodingLength(e))),r||(r=0),t.writeUInt16BE(e.length,r),e.copy(t,r+2),eu.encode.bytes=e.length+2,t};eu.encode.bytes=0;eu.decode=function(e,t){t||(t=0);let r=e.readUInt16BE(t),n=e.slice(t+2,t+2+r);return eu.decode.bytes=r+2,n};eu.decode.bytes=0;eu.encodingLength=function(e){return e.length+2};var tu=Me.ns={};tu.encode=function(e,t,r){return t||(t=qe.alloc(tu.encodingLength(e))),r||(r=0),$e.encode(e,t,r+2),t.writeUInt16BE($e.encode.bytes,r),tu.encode.bytes=$e.encode.bytes+2,t};tu.encode.bytes=0;tu.decode=function(e,t){t||(t=0);let r=e.readUInt16BE(t),n=$e.decode(e,t+2);return tu.decode.bytes=r+2,n};tu.decode.bytes=0;tu.encodingLength=function(e){return $e.encodingLength(e)+2};var ru=Me.soa={};ru.encode=function(e,t,r){t||(t=qe.alloc(ru.encodingLength(e))),r||(r=0);let n=r;return r+=2,$e.encode(e.mname,t,r),r+=$e.encode.bytes,$e.encode(e.rname,t,r,{mail:!0}),r+=$e.encode.bytes,t.writeUInt32BE(e.serial||0,r),r+=4,t.writeUInt32BE(e.refresh||0,r),r+=4,t.writeUInt32BE(e.retry||0,r),r+=4,t.writeUInt32BE(e.expire||0,r),r+=4,t.writeUInt32BE(e.minimum||0,r),r+=4,t.writeUInt16BE(r-n-2,n),ru.encode.bytes=r-n,t};ru.encode.bytes=0;ru.decode=function(e,t){t||(t=0);let r=t,n={};return t+=2,n.mname=$e.decode(e,t),t+=$e.decode.bytes,n.rname=$e.decode(e,t,{mail:!0}),t+=$e.decode.bytes,n.serial=e.readUInt32BE(t),t+=4,n.refresh=e.readUInt32BE(t),t+=4,n.retry=e.readUInt32BE(t),t+=4,n.expire=e.readUInt32BE(t),t+=4,n.minimum=e.readUInt32BE(t),t+=4,ru.decode.bytes=t-r,n};ru.decode.bytes=0;ru.encodingLength=function(e){return 22+$e.encodingLength(e.mname)+$e.encodingLength(e.rname)};var nu=Me.txt={};nu.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++]=Ai.decode(e,t),t+=Ai.decode.bytes,i-=Ai.decode.bytes;return Hi.decode.bytes=t-r,n};Hi.decode.bytes=0;Hi.encodingLength=function(e){return 2+ac(e||[],Ai)};var Jn=Me.dnskey={};Jn.PROTOCOL_DNSSEC=3;Jn.ZONE_KEY=128;Jn.SECURE_ENTRYPOINT=32768;Jn.encode=function(e,t,r){t||(t=qe.alloc(Jn.encodingLength(e))),r||(r=0);let n=r,i=e.key;if(!qe.isBuffer(i))throw new Error("Key must be a Buffer");return r+=2,t.writeUInt16BE(e.flags,r),r+=2,t.writeUInt8(Jn.PROTOCOL_DNSSEC,r),r+=1,t.writeUInt8(e.algorithm,r),r+=1,i.copy(t,r,0,i.length),r+=i.length,Jn.encode.bytes=r-n,t.writeUInt16BE(Jn.encode.bytes-2,n),t};Jn.encode.bytes=0;Jn.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)!==Jn.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,Jn.decode.bytes=t-r,n};Jn.decode.bytes=0;Jn.encodingLength=function(e){return 6+qe.byteLength(e.key)};var ia=Me.rrsig={};ia.encode=function(e,t,r){t||(t=qe.alloc(ia.encodingLength(e))),r||(r=0);let n=r,i=e.signature;if(!qe.isBuffer(i))throw new Error("Signature must be a Buffer");return r+=2,t.writeUInt16BE(lu.toType(e.typeCovered),r),r+=2,t.writeUInt8(e.algorithm,r),r+=1,t.writeUInt8(e.labels,r),r+=1,t.writeUInt32BE(e.originalTTL,r),r+=4,t.writeUInt32BE(e.expiration,r),r+=4,t.writeUInt32BE(e.inception,r),r+=4,t.writeUInt16BE(e.keyTag,r),r+=2,$e.encode(e.signersName,t,r),r+=$e.encode.bytes,i.copy(t,r,0,i.length),r+=i.length,ia.encode.bytes=r-n,t.writeUInt16BE(ia.encode.bytes-2,n),t};ia.encode.bytes=0;ia.decode=function(e,t){t||(t=0);let r=t;var n={},i=e.readUInt16BE(t);return t+=2,n.typeCovered=lu.toString(e.readUInt16BE(t)),t+=2,n.algorithm=e.readUInt8(t),t+=1,n.labels=e.readUInt8(t),t+=1,n.originalTTL=e.readUInt32BE(t),t+=4,n.expiration=e.readUInt32BE(t),t+=4,n.inception=e.readUInt32BE(t),t+=4,n.keyTag=e.readUInt16BE(t),t+=2,n.signersName=$e.decode(e,t),t+=$e.decode.bytes,n.signature=e.slice(t,r+i+2),t+=n.signature.length,ia.decode.bytes=t-r,n};ia.decode.bytes=0;ia.encodingLength=function(e){return 20+$e.encodingLength(e.signersName)+qe.byteLength(e.signature)};var sa=Me.rp={};sa.encode=function(e,t,r){t||(t=qe.alloc(sa.encodingLength(e))),r||(r=0);let n=r;return r+=2,$e.encode(e.mbox||".",t,r,{mail:!0}),r+=$e.encode.bytes,$e.encode(e.txt||".",t,r),r+=$e.encode.bytes,sa.encode.bytes=r-n,t.writeUInt16BE(sa.encode.bytes-2,n),t};sa.encode.bytes=0;sa.decode=function(e,t){t||(t=0);let r=t,n={};return t+=2,n.mbox=$e.decode(e,t,{mail:!0})||".",t+=$e.decode.bytes,n.txt=$e.decode(e,t)||".",t+=$e.decode.bytes,sa.decode.bytes=t-r,n};sa.decode.bytes=0;sa.encodingLength=function(e){return 2+$e.encodingLength(e.mbox||".")+$e.encodingLength(e.txt||".")};var nn={};nn.encode=function(e,t,r){t||(t=qe.alloc(nn.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=Hi.decode(e,t+8),t+=8+Hi.decode.bytes;else{let i=e.readUInt16BE(t+2);r.ttl=e.readUInt32BE(t+4),r.class=Pd.toString(i&xk),r.flush=!!(i&Sm);let a=Im(r.type);r.data=a.decode(e,t+8),t+=8+a.decode.bytes}return An.decode.bytes=t-n,r};An.decode.bytes=0;An.encodingLength=function(e){let t=e.data!==null&&e.data!==void 0?e.data:e.options;return $e.encodingLength(e.name)+8+Im(e.type).encodingLength(t)};var Ds=Me.question={};Ds.encode=function(e,t,r){t||(t=qe.alloc(Ds.encodingLength(e))),r||(r=0);let n=r;return $e.encode(e.name,t,r),r+=$e.encode.bytes,t.writeUInt16BE(lu.toType(e.type),r),r+=2,t.writeUInt16BE(Pd.toClass(e.class===void 0?"IN":e.class),r),r+=2,Ds.encode.bytes=r-n,e};Ds.encode.bytes=0;Ds.decode=function(e,t){t||(t=0);let r=t,n={};return n.name=$e.decode(e,t),t+=$e.decode.bytes,n.type=lu.toString(e.readUInt16BE(t)),t+=2,n.class=Pd.toString(e.readUInt16BE(t)),t+=2,!!(n.class&uC)&&(n.class&=Ok),Ds.decode.bytes=t-r,n};Ds.decode.bytes=0;Ds.encodingLength=function(e){return $e.encodingLength(e.name)+4};Me.AUTHORITATIVE_ANSWER=1024;Me.TRUNCATED_RESPONSE=512;Me.RECURSION_DESIRED=256;Me.RECURSION_AVAILABLE=128;Me.AUTHENTIC_DATA=32;Me.CHECKING_DISABLED=16;Me.DNSSEC_OK=32768;Me.encode=function(e,t,r){let n=!t;n&&(t=qe.alloc(Me.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=[]),Fs.encode(e,t,r),r+=Fs.encode.bytes,r=xf(e.questions,Ds,t,r),r=xf(e.answers,An,t,r),r=xf(e.authorities,An,t,r),r=xf(e.additionals,An,t,r),Me.encode.bytes=r-i,n&&Me.encode.bytes!==t.length?t.slice(0,Me.encode.bytes):t};Me.encode.bytes=0;Me.decode=function(e,t){t||(t=0);let r=t,n=Fs.decode(e,t);return t+=Fs.decode.bytes,t=Rd(n.questions,Ds,e,t),t=Rd(n.answers,An,e,t),t=Rd(n.authorities,An,e,t),t=Rd(n.additionals,An,e,t),Me.decode.bytes=t-r,n};Me.decode.bytes=0;Me.encodingLength=function(e){return Fs.encodingLength(e)+ac(e.questions||[],Ds)+ac(e.answers||[],An)+ac(e.authorities||[],An)+ac(e.additionals||[],An)};Me.streamEncode=function(e){let t=Me.encode(e),r=qe.alloc(2);r.writeUInt16BE(t.byteLength);let n=qe.concat([r,t]);return Me.streamEncode.bytes=n.byteLength,n};Me.streamEncode.bytes=0;Me.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__",u=500,l="__lodash_placeholder__",f=1,d=2,g=4,p=1,h=2,E=1,v=2,b=4,m=8,y=16,D=32,C=64,F=128,L=256,k=512,S=30,B="...",O=800,P=16,U=1,Y=2,H=3,K=1/0,W=9007199254740991,ie=17976931348623157e292,Ce=NaN,Fe=4294967295,Pe=Fe-1,rt=Fe>>>1,tt=[["ary",F],["bind",E],["bindKey",v],["curry",m],["curryRight",y],["flip",k],["partial",D],["partialRight",C],["rearg",L]],ct="[object Arguments]",ft="[object Array]",sn="[object AsyncFunction]",nr="[object Boolean]",_t="[object Date]",Er="[object DOMException]",sr="[object Error]",dt="[object Function]",zt="[object GeneratorFunction]",nt="[object Map]",Ke="[object Number]",ar="[object Null]",He="[object Object]",Ot="[object Promise]",an="[object Proxy]",er="[object RegExp]",Gt="[object Set]",vt="[object String]",Or="[object Symbol]",Fi="[object Undefined]",un="[object WeakMap]",Ft="[object WeakSet]",Ue="[object ArrayBuffer]",De="[object DataView]",wr="[object Float32Array]",on="[object Float64Array]",it="[object Int8Array]",Da="[object Int16Array]",ln="[object Int32Array]",ge="[object Uint8Array]",Os="[object Uint8ClampedArray]",Rt="[object Uint16Array]",Yr="[object Uint32Array]",ds=/\b__p \+= '';/g,yu=/\b(__p \+=) '' \+/g,Ts=/(__e\(.*?\)|\b__t\)) \+\n'';/g,bu=/&(?:amp|lt|gt|quot|#39);/g,ks=/[&<>"']/g,ps=RegExp(bu.source),Tt=RegExp(ks.source),ri=/<%-([\s\S]+?)%>/g,_u=/<%([\s\S]+?)%>/g,Cu=/<%=([\s\S]+?)%>/g,Du=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ns=/^\w*$/,so=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ls=/[\\^$.*+?()[\]{}|]/g,ao=RegExp(Ls.source),Fa=/^\s+/,re=/\s/,fe=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Le=/\{\n\/\* \[wrapped with (.+)\] \*/,Oe=/,? & /,Ve=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,st=/[()=,{}\[\]\/\s]/,ht=/\\(\\)?/g,Ir=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Ht=/\w*$/,ni=/^[-+]0x[0-9a-f]+$/i,Yi=/^0b[01]+$/i,cn=/^\[object .+?Constructor\]$/,Dn=/^0o[0-7]+$/i,Ar=/^(?:0|[1-9]\d*)$/,fn=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Mr=/($^)/,uo=/['\n\r\u2028\u2029\\]/g,Us="\\ud800-\\udfff",Ln="\\u0300-\\u036f",xt="\\ufe20-\\ufe2f",yr="\\u20d0-\\u20ff",Ze=Ln+xt+yr,ur="\\u2700-\\u27bf",Wr="a-z\\xdf-\\xf6\\xf8-\\xff",or="\\xac\\xb1\\xd7\\xf7",Mt="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Un="\\u2000-\\u206f",ii=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",si="A-Z\\xc0-\\xd6\\xd8-\\xde",jn="\\ufe0e\\ufe0f",Tr=or+Mt+Un+ii,fr="['\u2019]",jc="["+Us+"]",oo="["+Tr+"]",Xr="["+Ze+"]",lo="\\d+",ul="["+ur+"]",ol="["+Wr+"]",co="[^"+Us+Tr+lo+ur+Wr+si+"]",js="\\ud83c[\\udffb-\\udfff]",fo="(?:"+Xr+"|"+js+")",ll="[^"+Us+"]",ho="(?:\\ud83c[\\udde6-\\uddff]){2}",po="[\\ud800-\\udbff][\\udc00-\\udfff]",Hn="["+si+"]",x="\\u200d",N="(?:"+ol+"|"+co+")",V="(?:"+Hn+"|"+co+")",Q="(?:"+fr+"(?:d|ll|m|re|s|t|ve))?",ve="(?:"+fr+"(?:D|LL|M|RE|S|T|VE))?",Ae=fo+"?",Ie="["+jn+"]?",xe="(?:"+x+"(?:"+[ll,ho,po].join("|")+")"+Ie+Ae+")*",Yt="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",br="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",hn=Ie+Ae+xe,dn="(?:"+[ul,ho,po].join("|")+")"+hn,Si="(?:"+[ll+Xr+"?",Xr,ho,po,jc].join("|")+")",Fu=RegExp(fr,"g"),Mn=RegExp(Xr,"g"),pn=RegExp(js+"(?="+js+")|"+Si+hn,"g"),Su=RegExp([Hn+"?"+ol+"+"+Q+"(?="+[oo,Hn,"$"].join("|")+")",V+"+"+ve+"(?="+[oo,Hn+N,"$"].join("|")+")",Hn+"?"+N+"+"+Q,Hn+"+"+ve,br,Yt,lo,dn].join("|"),"g"),Wi=RegExp("["+x+Us+Ze+jn+"]"),go=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Tp=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],kp=-1,tr={};tr[wr]=tr[on]=tr[it]=tr[Da]=tr[ln]=tr[ge]=tr[Os]=tr[Rt]=tr[Yr]=!0,tr[ct]=tr[ft]=tr[Ue]=tr[nr]=tr[De]=tr[_t]=tr[sr]=tr[dt]=tr[nt]=tr[Ke]=tr[He]=tr[er]=tr[Gt]=tr[vt]=tr[un]=!1;var Jt={};Jt[ct]=Jt[ft]=Jt[Ue]=Jt[De]=Jt[nr]=Jt[_t]=Jt[wr]=Jt[on]=Jt[it]=Jt[Da]=Jt[ln]=Jt[nt]=Jt[Ke]=Jt[He]=Jt[er]=Jt[Gt]=Jt[vt]=Jt[Or]=Jt[ge]=Jt[Os]=Jt[Rt]=Jt[Yr]=!0,Jt[sr]=Jt[dt]=Jt[un]=!1;var Np={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},Lp={"&":"&","<":"<",">":">",'"':""","'":"'"},Up={"&":"&","<":"<",">":">",""":'"',"'":"'"},jp={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Hp=parseFloat,Mp=parseInt,Rh=typeof global=="object"&&global&&global.Object===Object&&global,qp=typeof self=="object"&&self&&self.Object===Object&&self,kr=Rh||qp||Function("return this")(),Hc=typeof oc=="object"&&oc&&!oc.nodeType&&oc,Sa=Hc&&typeof Of=="object"&&Of&&!Of.nodeType&&Of,Ph=Sa&&Sa.exports===Hc,Mc=Ph&&Rh.process,ai=function(){try{var ne=Sa&&Sa.require&&Sa.require("util").types;return ne||Mc&&Mc.binding&&Mc.binding("util")}catch{}}(),xh=ai&&ai.isArrayBuffer,Oh=ai&&ai.isDate,Th=ai&&ai.isMap,kh=ai&&ai.isRegExp,Nh=ai&&ai.isSet,Lh=ai&&ai.isTypedArray;function qn(ne,he,oe){switch(oe.length){case 0:return ne.call(he);case 1:return ne.call(he,oe[0]);case 2:return ne.call(he,oe[0],oe[1]);case 3:return ne.call(he,oe[0],oe[1],oe[2])}return ne.apply(he,oe)}function Vp(ne,he,oe,Te){for(var Qe=-1,St=ne==null?0:ne.length;++Qe-1}function mo(ne,he,oe){for(var Te=-1,Qe=ne==null?0:ne.length;++Te-1;);return oe}function Mh(ne,he){for(var oe=ne.length;oe--&&Iu(he,ne[oe],0)>-1;);return oe}function qh(ne,he){for(var oe=ne.length,Te=0;oe--;)ne[oe]===he&&++Te;return Te}var Yc=me(Np),Gp=me(Lp);function Vh(ne){return"\\"+jp[ne]}function Yp(ne,he){return ne==null?e:ne[he]}function Ba(ne){return Wi.test(ne)}function Wp(ne){return go.test(ne)}function Xp(ne){for(var he,oe=[];!(he=ne.next()).done;)oe.push(he.value);return oe}function Wc(ne){var he=-1,oe=Array(ne.size);return ne.forEach(function(Te,Qe){oe[++he]=[Qe,Te]}),oe}function gn(ne,he){return function(oe){return ne(he(oe))}}function $i(ne,he){for(var oe=-1,Te=ne.length,Qe=0,St=[];++oe-1}function eF(o,c){var A=this.__data__,I=r0(A,o);return I<0?(++this.size,A.push([o,c])):A[I][1]=c,this}Oa.prototype.clear=X5,Oa.prototype.delete=J5,Oa.prototype.get=Z5,Oa.prototype.has=Q5,Oa.prototype.set=eF;function Ta(o){var c=-1,A=o==null?0:o.length;for(this.clear();++c=c?o:c)),o}function Qi(o,c,A,I,T,q){var X,Z=c&f,se=c&d,Ee=c&g;if(A&&(X=T?A(o,I,T,q):A(o)),X!==e)return X;if(!gr(o))return o;var we=ut(o);if(we){if(X=iS(o),!Z)return ci(o,X)}else{var ye=In(o),Be=ye==dt||ye==zt;if(xu(o))return UE(o,Z);if(ye==He||ye==ct||Be&&!T){if(X=se||Be?{}:iw(o),!Z)return se?GF(o,mF(X,o)):zF(o,gE(X,o))}else{if(!Jt[ye])return T?o:{};X=sS(o,ye,Z)}}q||(q=new ms);var je=q.get(o);if(je)return je;q.set(o,X),xw(o)?o.forEach(function(Je){X.add(Qi(Je,c,A,Je,o,q))}):Rw(o)&&o.forEach(function(Je,yt){X.set(yt,Qi(Je,c,A,yt,o,q))});var Xe=Ee?se?B1:I1:se?hi:Jr,gt=we?e:Xe(o);return ui(gt||o,function(Je,yt){gt&&(yt=Je,Je=o[yt]),ef(X,yt,Qi(Je,c,A,yt,o,q))}),X}function vF(o){var c=Jr(o);return function(A){return mE(A,o,c)}}function mE(o,c,A){var I=A.length;if(o==null)return!I;for(o=Wt(o);I--;){var T=A[I],q=c[T],X=o[T];if(X===e&&!(T in o)||!q(X))return!1}return!0}function vE(o,c,A){if(typeof o!="function")throw new li(i);return of(function(){o.apply(e,A)},c)}function tf(o,c,A,I){var T=-1,q=Vn,X=!0,Z=o.length,se=[],Ee=c.length;if(!Z)return se;A&&(c=te(c,Fn(A))),I?(q=mo,X=!1):c.length>=r&&(q=Eo,X=!1,c=new Ao(c));e:for(;++TT?0:T+A),I=I===e||I>T?T:pt(I),I<0&&(I+=T),I=A>I?0:Tw(I);A0&&A(Z)?c>1?mn(Z,c-1,A,I,T):Bi(T,Z):I||(T[T.length]=Z)}return T}var c1=KE(),AE=KE(!0);function Ms(o,c){return o&&c1(o,c,Jr)}function f1(o,c){return o&&AE(o,c,Jr)}function i0(o,c){return Ii(c,function(A){return ja(o[A])})}function bo(o,c){c=Ru(c,o);for(var A=0,I=c.length;o!=null&&Ac}function AF(o,c){return o!=null&&Pt.call(o,c)}function yF(o,c){return o!=null&&c in Wt(o)}function bF(o,c,A){return o>=Sn(c,A)&&o=120&&we.length>=120)?new Ao(X&&we):e}we=o[0];var ye=-1,Be=Z[0];e:for(;++ye-1;)Z!==o&&Lt.call(Z,se,1),Lt.call(o,se,1);return o}function RE(o,c){for(var A=o?c.length:0,I=A-1;A--;){var T=c[A];if(A==I||T!==q){var q=T;Ua(T)?Lt.call(o,T,1):y1(o,T)}}return o}function E1(o,c){return o+ae(fE()*(c-o+1))}function TF(o,c,A,I){for(var T=-1,q=qr(z((c-o)/(A||1)),0),X=oe(q);q--;)X[I?q:++T]=o,o+=A;return X}function w1(o,c){var A="";if(!o||c<1||c>W)return A;do c%2&&(A+=o),c=ae(c/2),c&&(o+=o);while(c);return A}function Et(o,c){return k1(uw(o,c,di),o+"")}function kF(o){return pE($l(o))}function NF(o,c){var A=$l(o);return g0(A,yo(c,0,A.length))}function sf(o,c,A,I){if(!gr(o))return o;c=Ru(c,o);for(var T=-1,q=c.length,X=q-1,Z=o;Z!=null&&++TT?0:T+c),A=A>T?T:A,A<0&&(A+=T),T=c>A?0:A-c>>>0,c>>>=0;for(var q=oe(T);++I>>1,X=o[q];X!==null&&!xi(X)&&(A?X<=c:X=r){var Ee=c?null:JF(o);if(Ee)return Ri(Ee);X=!1,T=Eo,se=new Ao}else se=c?[]:Z;e:for(;++I=I?o:es(o,c,A)}var LE=_||function(o){return kr.clearTimeout(o)};function UE(o,c){if(c)return o.slice();var A=o.length,I=Wh?Wh(A):new o.constructor(A);return o.copy(I),I}function D1(o){var c=new o.constructor(o.byteLength);return new Al(c).set(new Al(o)),c}function MF(o,c){var A=c?D1(o.buffer):o.buffer;return new o.constructor(A,o.byteOffset,o.byteLength)}function qF(o){var c=new o.constructor(o.source,Ht.exec(o));return c.lastIndex=o.lastIndex,c}function VF(o){return Qc?Wt(Qc.call(o)):{}}function jE(o,c){var A=c?D1(o.buffer):o.buffer;return new o.constructor(A,o.byteOffset,o.length)}function HE(o,c){if(o!==c){var A=o!==e,I=o===null,T=o===o,q=xi(o),X=c!==e,Z=c===null,se=c===c,Ee=xi(c);if(!Z&&!Ee&&!q&&o>c||q&&X&&se&&!Z&&!Ee||I&&X&&se||!A&&se||!T)return 1;if(!I&&!q&&!Ee&&o=Z)return se;var Ee=A[I];return se*(Ee=="desc"?-1:1)}}return o.index-c.index}function ME(o,c,A,I){for(var T=-1,q=o.length,X=A.length,Z=-1,se=c.length,Ee=qr(q-X,0),we=oe(se+Ee),ye=!I;++Z1?A[T-1]:e,X=T>2?A[2]:e;for(q=o.length>3&&typeof q=="function"?(T--,q):e,X&&zn(A[0],A[1],X)&&(q=T<3?e:q,T=1),c=Wt(c);++I-1?T[q?c[X]:X]:e}}function YE(o){return La(function(c){var A=c.length,I=A,T=Zi.prototype.thru;for(o&&c.reverse();I--;){var q=c[I];if(typeof q!="function")throw new li(i);if(T&&!X&&d0(q)=="wrapper")var X=new Zi([],!0)}for(I=X?I:A;++I1&&It.reverse(),we&&seZ))return!1;var Ee=q.get(o),we=q.get(c);if(Ee&&we)return Ee==c&&we==o;var ye=-1,Be=!0,je=A&h?new Ao:e;for(q.set(o,c),q.set(c,o);++ye1?"& ":"")+c[I],c=c.join(A>2?", ":" "),o.replace(fe,`{ /* [wrapped with `+c+`] */ `)}function uS(o){return ut(o)||Do(o)||!!(Zh&&o&&o[Zh])}function Ua(o,c){var A=typeof o;return c=c??W,!!c&&(A=="number"||A!="symbol"&&Ar.test(o))&&o>-1&&o%1==0&&o0){if(++c>=O)return arguments[0]}else c=0;return o.apply(e,arguments)}}function g0(o,c){var A=-1,I=o.length,T=I-1;for(c=c===e?I:c;++A1?o[c-1]:e;return A=typeof A=="function"?(o.pop(),A):e,ww(o,A)});function Aw(o){var c=M(o);return c.__chain__=!0,c}function E8(o,c){return c(o),o}function m0(o,c){return c(o)}var w8=La(function(o){var c=o.length,A=c?o[0]:0,I=this.__wrapped__,T=function(q){return l1(q,o)};return c>1||this.__actions__.length||!(I instanceof Ct)||!Ua(A)?this.thru(T):(I=I.slice(A,+A+(c?1:0)),I.__actions__.push({func:m0,args:[T],thisArg:e}),new Zi(I,this.__chain__).thru(function(q){return c&&!q.length&&q.push(e),q}))});function A8(){return Aw(this)}function y8(){return new Zi(this.value(),this.__chain__)}function b8(){this.__values__===e&&(this.__values__=Ow(this.value()));var o=this.__index__>=this.__values__.length,c=o?e:this.__values__[this.__index__++];return{done:o,value:c}}function _8(){return this}function C8(o){for(var c,A=this;A instanceof t0;){var I=dw(A);I.__index__=0,I.__values__=e,c?T.__wrapped__=I:c=I;var T=I;A=A.__wrapped__}return T.__wrapped__=o,c}function D8(){var o=this.__wrapped__;if(o instanceof Ct){var c=o;return this.__actions__.length&&(c=new Ct(this)),c=c.reverse(),c.__actions__.push({func:m0,args:[N1],thisArg:e}),new Zi(c,this.__chain__)}return this.thru(N1)}function F8(){return kE(this.__wrapped__,this.__actions__)}var S8=o0(function(o,c,A){Pt.call(o,A)?++o[A]:ka(o,A,1)});function I8(o,c,A){var I=ut(o)?at:EF;return A&&zn(o,c,A)&&(c=e),I(o,Ye(c,3))}function B8(o,c){var A=ut(o)?Ii:wE;return A(o,Ye(c,3))}var $8=GE(pw),R8=GE(gw);function P8(o,c){return mn(v0(o,c),1)}function x8(o,c){return mn(v0(o,c),K)}function O8(o,c,A){return A=A===e?1:pt(A),mn(v0(o,c),A)}function yw(o,c){var A=ut(o)?ui:Bu;return A(o,Ye(c,3))}function bw(o,c){var A=ut(o)?R:EE;return A(o,Ye(c,3))}var T8=o0(function(o,c,A){Pt.call(o,A)?o[A].push(c):ka(o,A,[c])});function k8(o,c,A,I){o=fi(o)?o:$l(o),A=A&&!I?pt(A):0;var T=o.length;return A<0&&(A=qr(T+A,0)),b0(o)?A<=T&&o.indexOf(c,A)>-1:!!T&&Iu(o,c,A)>-1}var N8=Et(function(o,c,A){var I=-1,T=typeof c=="function",q=fi(o)?oe(o.length):[];return Bu(o,function(X){q[++I]=T?qn(c,X,A):rf(X,c,A)}),q}),L8=o0(function(o,c,A){ka(o,A,c)});function v0(o,c){var A=ut(o)?te:DE;return A(o,Ye(c,3))}function U8(o,c,A,I){return o==null?[]:(ut(c)||(c=c==null?[]:[c]),A=I?e:A,ut(A)||(A=A==null?[]:[A]),BE(o,c,A))}var j8=o0(function(o,c,A){o[A?0:1].push(c)},function(){return[[],[]]});function H8(o,c,A){var I=ut(o)?qc:jh,T=arguments.length<3;return I(o,Ye(c,4),A,T,Bu)}function M8(o,c,A){var I=ut(o)?lE:jh,T=arguments.length<3;return I(o,Ye(c,4),A,T,EE)}function q8(o,c){var A=ut(o)?Ii:wE;return A(o,A0(Ye(c,3)))}function V8(o){var c=ut(o)?pE:kF;return c(o)}function K8(o,c,A){(A?zn(o,c,A):c===e)?c=1:c=pt(c);var I=ut(o)?dF:NF;return I(o,c)}function z8(o){var c=ut(o)?pF:UF;return c(o)}function G8(o){if(o==null)return 0;if(fi(o))return b0(o)?$a(o):o.length;var c=In(o);return c==nt||c==Gt?o.size:g1(o).length}function Y8(o,c,A){var I=ut(o)?Uh:jF;return A&&zn(o,c,A)&&(c=e),I(o,Ye(c,3))}var W8=Et(function(o,c){if(o==null)return[];var A=c.length;return A>1&&zn(o,c[0],c[1])?c=[]:A>2&&zn(c[0],c[1],c[2])&&(c=[c[0]]),BE(o,mn(c,1),[])}),E0=j||function(){return kr.Date.now()};function X8(o,c){if(typeof c!="function")throw new li(i);return o=pt(o),function(){if(--o<1)return c.apply(this,arguments)}}function _w(o,c,A){return c=A?e:c,c=o&&c==null?o.length:c,Na(o,F,e,e,e,e,c)}function Cw(o,c){var A;if(typeof c!="function")throw new li(i);return o=pt(o),function(){return--o>0&&(A=c.apply(this,arguments)),o<=1&&(c=e),A}}var U1=Et(function(o,c,A){var I=E;if(A.length){var T=$i(A,Il(U1));I|=D}return Na(o,I,c,A,T)}),Dw=Et(function(o,c,A){var I=E|v;if(A.length){var T=$i(A,Il(Dw));I|=D}return Na(c,I,o,A,T)});function Fw(o,c,A){c=A?e:c;var I=Na(o,m,e,e,e,e,e,c);return I.placeholder=Fw.placeholder,I}function Sw(o,c,A){c=A?e:c;var I=Na(o,y,e,e,e,e,e,c);return I.placeholder=Sw.placeholder,I}function Iw(o,c,A){var I,T,q,X,Z,se,Ee=0,we=!1,ye=!1,Be=!0;if(typeof o!="function")throw new li(i);c=rs(c)||0,gr(A)&&(we=!!A.leading,ye="maxWait"in A,q=ye?qr(rs(A.maxWait)||0,c):q,Be="trailing"in A?!!A.trailing:Be);function je($r){var Es=I,Ma=T;return I=T=e,Ee=$r,X=o.apply(Ma,Es),X}function Xe($r){return Ee=$r,Z=of(yt,c),we?je($r):X}function gt($r){var Es=$r-se,Ma=$r-Ee,Gw=c-Es;return ye?Sn(Gw,q-Ma):Gw}function Je($r){var Es=$r-se,Ma=$r-Ee;return se===e||Es>=c||Es<0||ye&&Ma>=q}function yt(){var $r=E0();if(Je($r))return It($r);Z=of(yt,gt($r))}function It($r){return Z=e,Be&&I?je($r):(I=T=e,X)}function Oi(){Z!==e&&LE(Z),Ee=0,I=se=T=Z=e}function Gn(){return Z===e?X:It(E0())}function Ti(){var $r=E0(),Es=Je($r);if(I=arguments,T=this,se=$r,Es){if(Z===e)return Xe(se);if(ye)return LE(Z),Z=of(yt,c),je(se)}return Z===e&&(Z=of(yt,c)),X}return Ti.cancel=Oi,Ti.flush=Gn,Ti}var J8=Et(function(o,c){return vE(o,1,c)}),Z8=Et(function(o,c,A){return vE(o,rs(c)||0,A)});function Q8(o){return Na(o,k)}function w0(o,c){if(typeof o!="function"||c!=null&&typeof c!="function")throw new li(i);var A=function(){var I=arguments,T=c?c.apply(this,I):I[0],q=A.cache;if(q.has(T))return q.get(T);var X=o.apply(this,I);return A.cache=q.set(T,X)||q,X};return A.cache=new(w0.Cache||Ta),A}w0.Cache=Ta;function A0(o){if(typeof o!="function")throw new li(i);return function(){var c=arguments;switch(c.length){case 0:return!o.call(this);case 1:return!o.call(this,c[0]);case 2:return!o.call(this,c[0],c[1]);case 3:return!o.call(this,c[0],c[1],c[2])}return!o.apply(this,c)}}function eI(o){return Cw(2,o)}var tI=HF(function(o,c){c=c.length==1&&ut(c[0])?te(c[0],Fn(Ye())):te(mn(c,1),Fn(Ye()));var A=c.length;return Et(function(I){for(var T=-1,q=Sn(I.length,A);++T=c}),Do=bE(function(){return arguments}())?bE:function(o){return Cr(o)&&Pt.call(o,"callee")&&!Jh.call(o,"callee")},ut=oe.isArray,mI=xh?Fn(xh):CF;function fi(o){return o!=null&&y0(o.length)&&!ja(o)}function Br(o){return Cr(o)&&fi(o)}function vI(o){return o===!0||o===!1||Cr(o)&&Kn(o)==nr}var xu=Xt||J1,EI=Oh?Fn(Oh):DF;function wI(o){return Cr(o)&&o.nodeType===1&&!lf(o)}function AI(o){if(o==null)return!0;if(fi(o)&&(ut(o)||typeof o=="string"||typeof o.splice=="function"||xu(o)||Bl(o)||Do(o)))return!o.length;var c=In(o);if(c==nt||c==Gt)return!o.size;if(uf(o))return!g1(o).length;for(var A in o)if(Pt.call(o,A))return!1;return!0}function yI(o,c){return nf(o,c)}function bI(o,c,A){A=typeof A=="function"?A:e;var I=A?A(o,c):e;return I===e?nf(o,c,e,A):!!I}function H1(o){if(!Cr(o))return!1;var c=Kn(o);return c==sr||c==Er||typeof o.message=="string"&&typeof o.name=="string"&&!lf(o)}function _I(o){return typeof o=="number"&&_r(o)}function ja(o){if(!gr(o))return!1;var c=Kn(o);return c==dt||c==zt||c==sn||c==an}function $w(o){return typeof o=="number"&&o==pt(o)}function y0(o){return typeof o=="number"&&o>-1&&o%1==0&&o<=W}function gr(o){var c=typeof o;return o!=null&&(c=="object"||c=="function")}function Cr(o){return o!=null&&typeof o=="object"}var Rw=Th?Fn(Th):SF;function CI(o,c){return o===c||p1(o,c,R1(c))}function DI(o,c,A){return A=typeof A=="function"?A:e,p1(o,c,R1(c),A)}function FI(o){return Pw(o)&&o!=+o}function SI(o){if(cS(o))throw new Qe(n);return _E(o)}function II(o){return o===null}function BI(o){return o==null}function Pw(o){return typeof o=="number"||Cr(o)&&Kn(o)==Ke}function lf(o){if(!Cr(o)||Kn(o)!=He)return!1;var c=yl(o);if(c===null)return!0;var A=Pt.call(c,"constructor")&&c.constructor;return typeof A=="function"&&A instanceof A&&ml.call(A)==n1}var M1=kh?Fn(kh):IF;function $I(o){return $w(o)&&o>=-W&&o<=W}var xw=Nh?Fn(Nh):BF;function b0(o){return typeof o=="string"||!ut(o)&&Cr(o)&&Kn(o)==vt}function xi(o){return typeof o=="symbol"||Cr(o)&&Kn(o)==Or}var Bl=Lh?Fn(Lh):$F;function RI(o){return o===e}function PI(o){return Cr(o)&&In(o)==un}function xI(o){return Cr(o)&&Kn(o)==Ft}var OI=h0(m1),TI=h0(function(o,c){return o<=c});function Ow(o){if(!o)return[];if(fi(o))return b0(o)?oi(o):ci(o);if(Pa&&o[Pa])return Xp(o[Pa]());var c=In(o),A=c==nt?Wc:c==Gt?Ri:$l;return A(o)}function Ha(o){if(!o)return o===0?o:0;if(o=rs(o),o===K||o===-K){var c=o<0?-1:1;return c*ie}return o===o?o:0}function pt(o){var c=Ha(o),A=c%1;return c===c?A?c-A:c:0}function Tw(o){return o?yo(pt(o),0,Fe):0}function rs(o){if(typeof o=="number")return o;if(xi(o))return Ce;if(gr(o)){var c=typeof o.valueOf=="function"?o.valueOf():o;o=gr(c)?c+"":c}if(typeof o!="string")return o===0?o:+o;o=Gc(o);var A=Yi.test(o);return A||Dn.test(o)?Mp(o.slice(2),A?2:8):ni.test(o)?Ce:+o}function kw(o){return qs(o,hi(o))}function kI(o){return o?yo(pt(o),-W,W):o===0?o:0}function qt(o){return o==null?"":Pi(o)}var NI=Fl(function(o,c){if(uf(c)||fi(c)){qs(c,Jr(c),o);return}for(var A in c)Pt.call(c,A)&&ef(o,A,c[A])}),Nw=Fl(function(o,c){qs(c,hi(c),o)}),_0=Fl(function(o,c,A,I){qs(c,hi(c),o,I)}),LI=Fl(function(o,c,A,I){qs(c,Jr(c),o,I)}),UI=La(l1);function jI(o,c){var A=Dl(o);return c==null?A:gE(A,c)}var HI=Et(function(o,c){o=Wt(o);var A=-1,I=c.length,T=I>2?c[2]:e;for(T&&zn(c[0],c[1],T)&&(I=1);++A1),q}),qs(o,B1(o),A),I&&(A=Qi(A,f|d|g,ZF));for(var T=c.length;T--;)y1(A,c[T]);return A});function sB(o,c){return Uw(o,A0(Ye(c)))}var aB=La(function(o,c){return o==null?{}:xF(o,c)});function Uw(o,c){if(o==null)return{};var A=te(B1(o),function(I){return[I]});return c=Ye(c),$E(o,A,function(I,T){return c(I,T[0])})}function uB(o,c,A){c=Ru(c,o);var I=-1,T=c.length;for(T||(T=1,o=e);++Ic){var I=o;o=c,c=I}if(A||o%1||c%1){var T=fE();return Sn(o+T*(c-o+Hp("1e-"+((T+"").length-1))),c)}return E1(o,c)}var EB=Sl(function(o,c,A){return c=c.toLowerCase(),o+(A?Mw(c):c)});function Mw(o){return K1(qt(o).toLowerCase())}function qw(o){return o=qt(o),o&&o.replace(fn,Yc).replace(Mn,"")}function wB(o,c,A){o=qt(o),c=Pi(c);var I=o.length;A=A===e?I:yo(pt(A),0,I);var T=A;return A-=c.length,A>=0&&o.slice(A,T)==c}function AB(o){return o=qt(o),o&&Tt.test(o)?o.replace(ks,Gp):o}function yB(o){return o=qt(o),o&&ao.test(o)?o.replace(Ls,"\\$&"):o}var bB=Sl(function(o,c,A){return o+(A?"-":"")+c.toLowerCase()}),_B=Sl(function(o,c,A){return o+(A?" ":"")+c.toLowerCase()}),CB=zE("toLowerCase");function DB(o,c,A){o=qt(o),c=pt(c);var I=c?$a(o):0;if(!c||I>=c)return o;var T=(c-I)/2;return f0(ae(T),A)+o+f0(z(T),A)}function FB(o,c,A){o=qt(o),c=pt(c);var I=c?$a(o):0;return c&&I>>0,A?(o=qt(o),o&&(typeof c=="string"||c!=null&&!M1(c))&&(c=Pi(c),!c&&Ba(o))?Pu(oi(o),0,A):o.split(c,A)):[]}var xB=Sl(function(o,c,A){return o+(A?" ":"")+K1(c)});function OB(o,c,A){return o=qt(o),A=A==null?0:yo(pt(A),0,o.length),c=Pi(c),o.slice(A,A+c.length)==c}function TB(o,c,A){var I=M.templateSettings;A&&zn(o,c,A)&&(c=e),o=qt(o),c=_0({},c,I,QE);var T=_0({},c.imports,I.imports,QE),q=Jr(T),X=vo(T,q),Z,se,Ee=0,we=c.interpolate||Mr,ye="__p += '",Be=pl((c.escape||Mr).source+"|"+we.source+"|"+(we===Cu?Ir:Mr).source+"|"+(c.evaluate||Mr).source+"|$","g"),je="//# sourceURL="+(Pt.call(c,"sourceURL")?(c.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++kp+"]")+` `;o.replace(Be,function(Je,yt,It,Oi,Gn,Ti){return It||(It=Oi),ye+=o.slice(Ee,Ti).replace(uo,Vh),yt&&(Z=!0,ye+=`' + __e(`+yt+`) + '`),Gn&&(se=!0,ye+=`'; `+Gn+`; __p += '`),It&&(ye+=`' + ((__t = (`+It+`)) == null ? '' : __t) + '`),Ee=Ti+Je.length,Je}),ye+=`'; `;var Xe=Pt.call(c,"variable")&&c.variable;if(!Xe)ye=`with (obj) { `+ye+` } `;else if(st.test(Xe))throw new Qe(a);ye=(se?ye.replace(ds,""):ye).replace(yu,"$1").replace(Ts,"$1;"),ye="function("+(Xe||"obj")+`) { `+(Xe?"":`obj || (obj = {}); `)+"var __t, __p = ''"+(Z?", __e = _.escape":"")+(se?`, __j = Array.prototype.join; function print() { __p += __j.call(arguments, '') } `:`; `)+ye+`return __p }`;var gt=Kw(function(){return St(q,je+"return "+ye).apply(e,X)});if(gt.source=ye,H1(gt))throw gt;return gt}function kB(o){return qt(o).toLowerCase()}function NB(o){return qt(o).toUpperCase()}function LB(o,c,A){if(o=qt(o),o&&(A||c===e))return Gc(o);if(!o||!(c=Pi(c)))return o;var I=oi(o),T=oi(c),q=fl(I,T),X=Mh(I,T)+1;return Pu(I,q,X).join("")}function UB(o,c,A){if(o=qt(o),o&&(A||c===e))return o.slice(0,dl(o)+1);if(!o||!(c=Pi(c)))return o;var I=oi(o),T=Mh(I,oi(c))+1;return Pu(I,0,T).join("")}function jB(o,c,A){if(o=qt(o),o&&(A||c===e))return o.replace(Fa,"");if(!o||!(c=Pi(c)))return o;var I=oi(o),T=fl(I,oi(c));return Pu(I,T).join("")}function HB(o,c){var A=S,I=B;if(gr(c)){var T="separator"in c?c.separator:T;A="length"in c?pt(c.length):A,I="omission"in c?Pi(c.omission):I}o=qt(o);var q=o.length;if(Ba(o)){var X=oi(o);q=X.length}if(A>=q)return o;var Z=A-$a(I);if(Z<1)return I;var se=X?Pu(X,0,Z).join(""):o.slice(0,Z);if(T===e)return se+I;if(X&&(Z+=se.length-Z),M1(T)){if(o.slice(Z).search(T)){var Ee,we=se;for(T.global||(T=pl(T.source,qt(Ht.exec(T))+"g")),T.lastIndex=0;Ee=T.exec(we);)var ye=Ee.index;se=se.slice(0,ye===e?Z:ye)}}else if(o.indexOf(Pi(T),Z)!=Z){var Be=se.lastIndexOf(T);Be>-1&&(se=se.slice(0,Be))}return se+I}function MB(o){return o=qt(o),o&&ps.test(o)?o.replace(bu,zh):o}var qB=Sl(function(o,c,A){return o+(A?" ":"")+c.toUpperCase()}),K1=zE("toUpperCase");function Vw(o,c,A){return o=qt(o),c=A?e:c,c===e?Wp(o)?Qp(o):Vc(o):o.match(c)||[]}var Kw=Et(function(o,c){try{return qn(o,e,c)}catch(A){return H1(A)?A:new Qe(A)}}),VB=La(function(o,c){return ui(c,function(A){A=Vs(A),ka(o,A,U1(o[A],o))}),o});function KB(o){var c=o==null?0:o.length,A=Ye();return o=c?te(o,function(I){if(typeof I[1]!="function")throw new li(i);return[A(I[0]),I[1]]}):[],Et(function(I){for(var T=-1;++TW)return[];var A=Fe,I=Sn(o,Fe);c=Ye(c),o-=Fe;for(var T=zc(I,c);++A0||c<0)?new Ct(A):(o<0?A=A.takeRight(-o):o&&(A=A.drop(o)),c!==e&&(c=pt(c),A=c<0?A.dropRight(-c):A.take(c-o)),A)},Ct.prototype.takeRightWhile=function(o){return this.reverse().takeWhile(o).reverse()},Ct.prototype.toArray=function(){return this.take(Fe)},Ms(Ct.prototype,function(o,c){var A=/^(?:filter|find|map|reject)|While$/.test(c),I=/^(?:head|last)$/.test(c),T=M[I?"take"+(c=="last"?"Right":""):c],q=I||/^find/.test(c);T&&(M.prototype[c]=function(){var X=this.__wrapped__,Z=I?[1]:arguments,se=X instanceof Ct,Ee=Z[0],we=se||ut(X),ye=function(yt){var It=T.apply(M,Bi([yt],Z));return I&&Be?It[0]:It};we&&A&&typeof Ee=="function"&&Ee.length!=1&&(se=we=!1);var Be=this.__chain__,je=!!this.__actions__.length,Xe=q&&!Be,gt=se&&!je;if(!q&&we){X=gt?X:new Ct(this);var Je=o.apply(X,Z);return Je.__actions__.push({func:m0,args:[ye],thisArg:e}),new Zi(Je,Be)}return Xe&>?o.apply(this,Z):(Je=this.thru(ye),Xe?I?Je.value()[0]:Je.value():Je)})}),ui(["pop","push","shift","sort","splice","unshift"],function(o){var c=gl[o],A=/^(?:push|sort|unshift)$/.test(o)?"tap":"thru",I=/^(?:pop|shift)$/.test(o);M.prototype[o]=function(){var T=arguments;if(I&&!this.__chain__){var q=this.value();return c.apply(ut(q)?q:[],T)}return this[A](function(X){return c.apply(ut(X)?X:[],T)})}}),Ms(Ct.prototype,function(o,c){var A=M[c];if(A){var I=A.name+"";Pt.call(Cl,I)||(Cl[I]=[]),Cl[I].push({name:c,func:A})}}),Cl[l0(e,v).name]=[{name:"wrapper",func:e}],Ct.prototype.clone=M5,Ct.prototype.reverse=q5,Ct.prototype.value=V5,M.prototype.at=w8,M.prototype.chain=A8,M.prototype.commit=y8,M.prototype.next=b8,M.prototype.plant=C8,M.prototype.reverse=D8,M.prototype.toJSON=M.prototype.valueOf=M.prototype.value=F8,M.prototype.first=M.prototype.head,Pa&&(M.prototype[Pa]=_8),M},Ji=e1();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(kr._=Ji,define(function(){return Ji})):Sa?((Sa.exports=Ji)._=Ji,Hc._=Ji):kr._=Ji}).call(oc)});var jm=le((RW,Um)=>{var bC=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);bC?(Nm=new Uint8Array(16),Um.exports=function(){return bC(Nm),Nm}):(Lm=new Array(16),Um.exports=function(){for(var t=0,r;t<16;t++)t&3||(r=Math.random()*4294967296),Lm[t]=r>>>((t&3)<<3)&255;return Lm});var Nm,Lm});var Hm=le((PW,CC)=>{var _C=[];for(kf=0;kf<256;++kf)_C[kf]=(kf+256).toString(16).substr(1);var kf;function NN(e,t){var r=t||0,n=_C;return[n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]]].join("")}CC.exports=NN});var SC=le((xW,FC)=>{var LN=jm(),UN=Hm(),DC,Mm,qm=0,Vm=0;function jN(e,t,r){var n=t&&r||0,i=t||[];e=e||{};var a=e.node||DC,s=e.clockseq!==void 0?e.clockseq:Mm;if(a==null||s==null){var u=LN();a==null&&(a=DC=[u[0]|1,u[1],u[2],u[3],u[4],u[5]]),s==null&&(s=Mm=(u[6]<<8|u[7])&16383)}var l=e.msecs!==void 0?e.msecs:new Date().getTime(),f=e.nsecs!==void 0?e.nsecs:Vm+1,d=l-qm+(f-Vm)/1e4;if(d<0&&e.clockseq===void 0&&(s=s+1&16383),(d<0||l>qm)&&e.nsecs===void 0&&(f=0),f>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");qm=l,Vm=f,Mm=s,l+=122192928e5;var g=((l&268435455)*1e4+f)%4294967296;i[n++]=g>>>24&255,i[n++]=g>>>16&255,i[n++]=g>>>8&255,i[n++]=g&255;var p=l/4294967296*1e4&268435455;i[n++]=p>>>8&255,i[n++]=p&255,i[n++]=p>>>24&15|16,i[n++]=p>>>16&255,i[n++]=s>>>8|128,i[n++]=s&255;for(var h=0;h<6;++h)i[n+h]=a[h];return t||UN(i)}FC.exports=jN});var BC=le((OW,IC)=>{var HN=jm(),MN=Hm();function qN(e,t,r){var n=t&&r||0;typeof e=="string"&&(t=e==="binary"?new Array(16):null,e=null),e=e||{};var i=e.random||(e.rng||HN)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t)for(var a=0;a<16;++a)t[n+a]=i[a];return t||MN(i)}IC.exports=qN});var PC=le((TW,RC)=>{var VN=SC(),$C=BC(),Km=$C;Km.v1=VN;Km.v4=$C;RC.exports=Km});var Ld=le((kW,OC)=>{var{v4:KN}=PC();function xC(){return KN().replace(/-/g,"")}var zm=xC;function Gm(){return zm()}Gm.setFactory=e=>{zm=e};Gm.reset=()=>{zm=xC};OC.exports=Gm});var fu=le((NW,TC)=>{var zN=Symbol("_options"),GN=Symbol("_cache"),YN=Symbol("_state"),WN=Symbol("_objectId"),XN=Symbol("_conflicts"),JN=Symbol("_change"),ZN=Symbol("_elemIds");TC.exports={OPTIONS:zN,CACHE:GN,STATE:YN,OBJECT_ID:WN,CONFLICTS:XN,CHANGE:JN,ELEM_IDS:ZN}});var Ss=le((LW,NC)=>{function kC(e){return typeof e=="object"&&e!==null}function QN(e){if(!kC(e))return{};let t={};for(let r of Object.keys(e))t[r]=e[r];return t}function eL(e){let t=/^(\d+)@(.*)$/.exec(e||"");if(!t)throw new RangeError(`Not a valid opId: ${e}`);return{counter:parseInt(t[1],10),actorId:t[2]}}function tL(e,t){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array))throw new TypeError("equalBytes can only compare Uint8Arrays");if(e.byteLength!==t.byteLength)return!1;for(let r=0;r{var{OBJECT_ID:Yo}=fu(),{isObject:nL}=Ss(),Lf=class{constructor(t){if(typeof t=="string"){let r=[...t].map(n=>({value:n}));return Nf(void 0,r)}else if(Array.isArray(t)){let r=t.map(n=>({value:n}));return Nf(void 0,r)}else{if(t===void 0)return Nf(void 0,[]);throw new TypeError(`Unsupported initial value for Text: ${t}`)}}get length(){return this.elems.length}get(t){let r=this.elems[t].value;if(this.context&&nL(r)){let n=r[Yo],i=this.path.concat([{key:t,objectId:n}]);return this.context.instantiateObject(i,n)}else return r}getElemId(t){return this.elems[t].elemId}[Symbol.iterator](){let t=this.elems,r=-1;return{next(){return r+=1,r0&&(t.push(r),r=""),t.push(n.value));return r.length>0&&t.push(r),t}toJSON(){return this.toString()}getWriteable(t,r){if(!this[Yo])throw new RangeError("getWriteable() requires the objectId to be set");let n=Nf(this[Yo],this.elems);return n.context=t,n.path=r,n}set(t,r){if(this.context)this.context.setListIndex(this.path,t,r);else if(!this[Yo])this.elems[t].value=r;else throw new TypeError("Automerge.Text object cannot be modified outside of a change block");return this}insertAt(t,...r){if(this.context)this.context.splice(this.path,t,0,r);else if(!this[Yo])this.elems.splice(t,0,...r.map(n=>({value:n})));else throw new TypeError("Automerge.Text object cannot be modified outside of a change block");return this}deleteAt(t,r=1){if(this.context)this.context.splice(this.path,t,r,[]);else if(!this[Yo])this.elems.splice(t,r);else throw new TypeError("Automerge.Text object cannot be modified outside of a change block");return this}};for(let e of["concat","every","filter","find","findIndex","forEach","includes","indexOf","join","lastIndexOf","map","reduce","reduceRight","slice","some","toLocaleString"])Lf.prototype[e]=function(...t){return[...this][e](...t)};function Nf(e,t){let r=Object.create(Lf.prototype);return r[Yo]=e,r.elems=t,r}LC.exports={Text:Lf,instantiateText:Nf}});var Hf=le((jW,HC)=>{var{OBJECT_ID:Wo,CONFLICTS:iL}=fu(),{isObject:Ud,copyObject:UC}=Ss();function Ym(e,t,r){for(let n of e)if(t[n]!==r[n]){if(typeof t[n]=="number"&&typeof r[n]=="number")return t[n]-r[n];{let i=""+t[n],a=""+r[n];if(i===a)continue;return i{let r=this.entries[t];return Ud(r)&&r.id===t})}get count(){return this.ids.length}get rows(){return this.ids.map(t=>this.byId(t))}filter(t,r){return this.rows.filter(t,r)}find(t,r){return this.rows.find(t,r)}map(t,r){return this.rows.map(t,r)}sort(t){if(typeof t=="function")return this.rows.sort(t);if(typeof t=="string")return this.rows.sort((r,n)=>Ym([t],r,n));if(Array.isArray(t))return this.rows.sort((r,n)=>Ym(t,r,n));if(t===void 0)return this.rows.sort((r,n)=>Ym(["id"],r,n));throw new TypeError(`Unsupported sorting argument: ${t}`)}[Symbol.iterator](){let t=this.rows,r=-1;return{next(){return r+=1,r{var jd=class{constructor(t){this.value=t||0,Object.freeze(this)}valueOf(){return this.value}toString(){return this.valueOf().toString()}toJSON(){return this.value}},Xm=class extends jd{increment(t){return t=typeof t=="number"?t:1,this.context.increment(this.path,this.key,t),this.value+=t,this.value}decrement(t){return this.increment(typeof t=="number"?-t:-1)}};function sL(e,t,r,n,i){let a=Object.create(Xm.prototype);return a.value=e,a.context=t,a.path=r,a.objectId=n,a.key=i,a}MC.exports={Counter:jd,getWriteableCounter:sL}});var Jm=le((MW,zC)=>{var{isObject:aL,copyObject:qC,parseOpId:qd}=Ss(),{OBJECT_ID:Mf,CONFLICTS:Xo,ELEM_IDS:Md}=fu(),{instantiateText:uL}=Uf(),{instantiateTable:oL}=Hf(),{Counter:lL}=Hd();function hu(e,t,r){return e.objectId?(t&&t[Mf]!==e.objectId&&(t=void 0),KC(e,t,r)):e.datatype==="timestamp"?new Date(e.value):e.datatype==="counter"?new lL(e.value):e.value}function cL(e,t){let r=/^(\d+)@(.*)$/,n=r.test(e)?qd(e):{counter:0,actorId:e},i=r.test(t)?qd(t):{counter:0,actorId:t};return n.counteri.counter?1:n.actorIdi.actorId?1:0}function fL(e,t,r,n){if(e)for(let i of Object.keys(e)){let a={},s=Object.keys(e[i]).sort(cL).reverse();for(let u of s){let l=e[i][u];r[i]&&r[i][u]?a[u]=hu(l,r[i][u],n):a[u]=hu(l,void 0,n)}s.length===0?(delete t[i],delete r[i]):(t[i]=a[s[0]],r[i]=a)}}function VC(e,t){let r=qC(e),n=qC(e?e[Xo]:void 0);return Object.defineProperty(r,Mf,{value:t}),Object.defineProperty(r,Xo,{value:n}),r}function hL(e,t,r){let n=e.objectId;r[n]||(r[n]=VC(t,n));let i=r[n];return fL(e.props,i,i[Xo],r),i}function dL(e,t,r){let n=e.objectId;r[n]||(r[n]=t?t._clone():oL(n));let i=r[n];for(let a of Object.keys(e.props||{})){let s=Object.keys(e.props[a]);if(s.length===0)i.remove(a);else if(s.length===1){let u=e.props[a][s[0]];i._set(a,hu(u,i.byId(a),r),s[0])}else throw new RangeError("Conflicts are not supported on properties of a table")}return i}function pL(e,t){let r=e?e.slice():[],n=e&&e[Xo]?e[Xo].slice():[],i=e&&e[Md]?e[Md].slice():[];return Object.defineProperty(r,Mf,{value:t}),Object.defineProperty(r,Xo,{value:n}),Object.defineProperty(r,Md,{value:i}),r}function gL(e,t,r){let n=e.objectId;r[n]||(r[n]=pL(t,n));let i=r[n],a=i[Xo],s=i[Md];for(let u=0;u{let b=`${f.counter+v}@${f.actorId}`;E=hu({value:E,datatype:h},void 0,r),g.push(E),p.push({[b]:{value:E,datatype:h,type:"value"}}),d.push(b)}),i.splice(l.index,0,...g),a.splice(l.index,0,...p),s.splice(l.index,0,...d)}else l.action==="remove"&&(i.splice(l.index,l.count),a.splice(l.index,l.count),s.splice(l.index,l.count))}return i}function mL(e,t,r){let n=e.objectId,i;r[n]?i=r[n].elems:t?i=t.elems.slice():i=[];for(let a of e.edits)if(a.action==="insert"){let s=hu(a.value,void 0,r),u={elemId:a.elemId,pred:[a.opId],value:s};i.splice(a.index,0,u)}else if(a.action==="multi-insert"){let s=qd(a.elemId),u=a.datatype,l=a.values.map((f,d)=>{f=hu({datatype:u,value:f},void 0,r);let g=`${s.counter+d}@${s.actorId}`;return{elemId:g,pred:[g],value:f}});i.splice(a.index,0,...l)}else if(a.action==="update"){let s=i[a.index].elemId,u=hu(a.value,i[a.index].value,r);i[a.index]={elemId:s,pred:[a.opId],value:u}}else a.action==="remove"&&i.splice(a.index,a.count);return r[n]=uL(n,i),r[n]}function KC(e,t,r){if(aL(t)&&(!e.props||Object.keys(e.props).length===0)&&(!e.edits||e.edits.length===0)&&!r[e.objectId])return t;if(e.type==="map")return hL(e,t,r);if(e.type==="table")return dL(e,t,r);if(e.type==="list")return gL(e,t,r);if(e.type==="text")return mL(e,t,r);throw new TypeError(`Unknown object type: ${e.type}`)}function vL(e){if(e[Mf]!=="_root")throw new RangeError(`Not the root object: ${e[Mf]}`);return VC(e,"_root")}zC.exports={interpretPatch:KC,cloneRootObject:vL}});var WC=le((qW,YC)=>{var{OBJECT_ID:Jo,CHANGE:Vd,STATE:EL}=fu(),{createArrayOfNulls:wL}=Ss(),{Text:AL}=Uf(),{Table:yL}=Hf();function da(e){if(typeof e=="string"&&/^[0-9]+$/.test(e)&&(e=parseInt(e,10)),typeof e!="number")throw new TypeError("A list index must be a number, but you passed "+JSON.stringify(e));if(e<0||isNaN(e)||e===1/0||e===-1/0)throw new RangeError("A list index must be positive, but you passed "+e);return e}function bL(e,t,r){let n={deleteAt(i,a){return e.splice(r,da(i),a||1,[]),this},fill(i,a,s){let u=e.getObject(t);for(let l=da(a||0);lu.length-i)&&(a=u.length-i);let l=[];for(let f=0;fa[i]()}for(let i of["concat","every","filter","find","findIndex","forEach","includes","join","lastIndexOf","map","reduce","reduceRight","slice","some","toLocaleString","toString"])n[i]=(...a)=>e.getObject(t).map((u,l)=>e.getObjectField(r,t,l))[i](...a);return n}var _L={get(e,t){let{context:r,objectId:n,path:i}=e;return t===Jo?n:t===Vd?r:t===EL?{actorId:r.actorId}:r.getObjectField(i,n,t)},set(e,t,r){let{context:n,path:i,readonly:a}=e;if(Array.isArray(a)&&a.indexOf(t)>=0)throw new RangeError(`Object property "${t}" cannot be modified`);return n.setMapKey(i,t,r),!0},deleteProperty(e,t){let{context:r,path:n,readonly:i}=e;if(Array.isArray(i)&&i.indexOf(t)>=0)throw new RangeError(`Object property "${t}" cannot be modified`);return r.deleteMapKey(n,t),!0},has(e,t){let{context:r,objectId:n}=e;return[Jo,Vd].includes(t)||t in r.getObject(n)},getOwnPropertyDescriptor(e,t){let{context:r,objectId:n}=e,i=r.getObject(n);if(t in i)return{configurable:!0,enumerable:!0,value:r.getObjectField(n,t)}},ownKeys(e){let{context:t,objectId:r}=e;return Object.keys(t.getObject(r))}},CL={get(e,t){let[r,n,i]=e;return t===Symbol.iterator?r.getObject(n)[Symbol.iterator]:t===Jo?n:t===Vd?r:t==="length"?r.getObject(n).length:typeof t=="string"&&/^[0-9]+$/.test(t)?r.getObjectField(i,n,da(t)):bL(r,n,i)[t]},set(e,t,r){let[n,i,a]=e;if(t==="length"){if(typeof r!="number")throw new RangeError("Invalid array length");let s=n.getObject(i).length;s>r?n.splice(a,r,s-r,[]):n.splice(a,s,0,wL(r-s))}else n.setListIndex(a,da(t),r);return!0},deleteProperty(e,t){let[r,,n]=e;return r.splice(n,da(t),1,[]),!0},has(e,t){let[r,n]=e;return typeof t=="string"&&/^[0-9]+$/.test(t)?da(t){var Zm=class{constructor(t){if(!(Number.isInteger(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER))throw new RangeError(`Value ${t} cannot be a uint`);this.value=t,Object.freeze(this)}},Qm=class{constructor(t){if(!(Number.isInteger(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=0))throw new RangeError(`Value ${t} cannot be a uint`);this.value=t,Object.freeze(this)}},ev=class{constructor(t){if(typeof t!="number")throw new RangeError(`Value ${t} cannot be a float64`);this.value=t||0,Object.freeze(this)}};XC.exports={Int:Zm,Uint:Qm,Float64:ev}});var e6=le((KW,QC)=>{var{CACHE:IL,OBJECT_ID:Kd,CONFLICTS:Zo,ELEM_IDS:JC,STATE:BL}=fu(),{interpretPatch:$L}=Jm(),{Text:Kf}=Uf(),{Table:zf}=Hf(),{Counter:Ku,getWriteableCounter:RL}=Hd(),{Int:rv,Uint:nv,Float64:iv}=tv(),{isObject:qf,parseOpId:ZC,createArrayOfNulls:PL}=Ss(),xL=Ld(),sv=class{constructor(t,r,n){this.actorId=r,this.nextOpNum=t[BL].maxOp+1,this.cache=t[IL],this.updated={},this.ops=[],this.applyPatch=n||$L}addOp(t){this.ops.push(t),t.action==="set"&&t.values?this.nextOpNum+=t.values.length:t.action==="del"&&t.multiOp?this.nextOpNum+=t.multiOp:this.nextOpNum+=1}nextOpId(){return`${this.nextOpNum}@${this.actorId}`}getValueDescription(t){if(!["object","boolean","number","string"].includes(typeof t))throw new TypeError(`Unsupported type of value: ${typeof t}`);if(qf(t)){if(t instanceof Date)return{type:"value",value:t.getTime(),datatype:"timestamp"};if(t instanceof rv)return{type:"value",value:t.value,datatype:"int"};if(t instanceof nv)return{type:"value",value:t.value,datatype:"uint"};if(t instanceof iv)return{type:"value",value:t.value,datatype:"float64"};if(t instanceof Ku)return{type:"value",value:t.value,datatype:"counter"};{let r=t[Kd],n=this.getObjectType(r);if(!r)throw new RangeError(`Object ${JSON.stringify(t)} has no objectId`);return n==="list"||n==="text"?{objectId:r,type:n,edits:[]}:{objectId:r,type:n,props:{}}}}else return typeof t=="number"?Number.isInteger(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER?{type:"value",value:t,datatype:"int"}:{type:"value",value:t,datatype:"float64"}:{type:"value",value:t}}getValuesDescriptions(t,r,n){if(r instanceof zf){let i=r.byId(n),a=r.opIds[n];return i?{[a]:this.getValueDescription(i)}:{}}else if(r instanceof Kf){let i=r.get(n),a=r.getElemId(n);return i?{[a]:this.getValueDescription(i)}:{}}else{let i=r[Zo][n],a={};if(!i)throw new RangeError(`No children at key ${n} of path ${JSON.stringify(t)}`);for(let s of Object.keys(i))a[s]=this.getValueDescription(i[s]);return a}}getPropertyValue(t,r,n){return t instanceof zf?t.byId(r):t instanceof Kf?t.get(r):t[Zo][r][n]}getSubpatch(t,r){if(r.length==0)return t;let n=t,i=this.getObject("_root");for(let a of r){let s=this.getValuesDescriptions(r,i,a.key);if(n.props)n.props[a.key]||(n.props[a.key]=s);else if(n.edits)for(let l of Object.keys(s))n.edits.push({action:"update",index:a.key,opId:l,value:s[l]});let u=null;for(let l of Object.keys(s))s[l].objectId===a.objectId&&(u=l);if(!u)throw new RangeError(`Cannot find path object with objectId ${a.objectId}`);n=s[u],i=this.getPropertyValue(i,a.key,u)}return n}getObject(t){let r=this.updated[t]||this.cache[t];if(!r)throw new RangeError(`Target object does not exist: ${t}`);return r}getObjectType(t){if(t==="_root")return"map";let r=this.getObject(t);return r instanceof Kf?"text":r instanceof zf?"table":Array.isArray(r)?"list":"map"}getObjectField(t,r,n){if(!["string","number"].includes(typeof n))return;let i=this.getObject(r);if(i[n]instanceof Ku)return RL(i[n].value,this,t,r,n);if(qf(i[n])){let a=i[n][Kd],s=t.concat([{key:n,objectId:a}]);return this.instantiateObject(s,a)}else return i[n]}createNestedObjects(t,r,n,i,a,s){if(n[Kd])throw new RangeError("Cannot create a reference to an existing document object");let u=this.nextOpId();if(n instanceof Kf){this.addOp(s?{action:"makeText",obj:t,elemId:s,insert:i,pred:a}:{action:"makeText",obj:t,key:r,insert:i,pred:a});let l={objectId:u,type:"text",edits:[]};return this.insertListItems(l,0,[...n],!0),l}else if(n instanceof zf){if(n.count>0)throw new RangeError("Assigning a non-empty Table object is not supported");return this.addOp(s?{action:"makeTable",obj:t,elemId:s,insert:i,pred:a}:{action:"makeTable",obj:t,key:r,insert:i,pred:a}),{objectId:u,type:"table",props:{}}}else if(Array.isArray(n)){this.addOp(s?{action:"makeList",obj:t,elemId:s,insert:i,pred:a}:{action:"makeList",obj:t,key:r,insert:i,pred:a});let l={objectId:u,type:"list",edits:[]};return this.insertListItems(l,0,n,!0),l}else{this.addOp(s?{action:"makeMap",obj:t,elemId:s,insert:i,pred:a}:{action:"makeMap",obj:t,key:r,insert:i,pred:a});let l={};for(let f of Object.keys(n).sort()){let d=this.nextOpId(),g=this.setValue(u,f,n[f],!1,[]);l[f]={[d]:g}}return{objectId:u,type:"map",props:l}}}setValue(t,r,n,i,a,s){if(!t)throw new RangeError("setValue needs an objectId");if(r==="")throw new RangeError("The key of a map entry must not be an empty string");if(qf(n)&&!(n instanceof Date)&&!(n instanceof Ku)&&!(n instanceof rv)&&!(n instanceof nv)&&!(n instanceof iv))return this.createNestedObjects(t,r,n,i,a,s);{let u=this.getValueDescription(n),l={action:"set",obj:t,insert:i,value:u.value,pred:a};return s?l.elemId=s:l.key=r,u.datatype&&(l.datatype=u.datatype),this.addOp(l),u}}applyAtPath(t,r){let n={objectId:"_root",type:"map",props:{}};r(this.getSubpatch(n,t)),this.applyPatch(n,this.cache._root,this.updated)}setMapKey(t,r,n){if(typeof r!="string")throw new RangeError(`The key of a map entry must be a string, not ${typeof r}`);let i=t.length===0?"_root":t[t.length-1].objectId,a=this.getObject(i);if(a[r]instanceof Ku)throw new RangeError("Cannot overwrite a Counter object; use .increment() or .decrement() to change its value.");(a[r]!==n||Object.keys(a[Zo][r]||{}).length>1||n===void 0)&&this.applyAtPath(t,s=>{let u=Vf(a,r),l=this.nextOpId(),f=this.setValue(i,r,n,!1,u);s.props[r]={[l]:f}})}deleteMapKey(t,r){let n=t.length===0?"_root":t[t.length-1].objectId,i=this.getObject(n);if(i[r]!==void 0){let a=Vf(i,r);this.addOp({action:"del",obj:n,key:r,insert:!1,pred:a}),this.applyAtPath(t,s=>{s.props[r]={}})}}insertListItems(t,r,n,i){let a=i?[]:this.getObject(t.objectId);if(r<0||r>a.length)throw new RangeError(`List index ${r} is out of bounds for list of length ${a.length}`);if(n.length===0)return;let s=zd(a,r,!0),u=n.every(d=>typeof d=="string"||typeof d=="number"||typeof d=="boolean"||d===null||qf(d)&&(d instanceof Date||d instanceof Ku||d instanceof rv||d instanceof nv||d instanceof iv)),l=u?n.map(d=>this.getValueDescription(d)):[],f=l.every(d=>d.datatype===l[0].datatype);if(u&&f&&n.length>1){let d=this.nextOpId(),g=l[0].datatype,p=l.map(v=>v.value),h={action:"set",obj:t.objectId,elemId:s,insert:!0,values:p,pred:[]},E={action:"multi-insert",elemId:d,index:r,values:p};g&&(h.datatype=g,E.datatype=g),this.addOp(h),t.edits.push(E)}else for(let d=0;d=a.length){let s=PL(r-a.length);return s.push(n),this.splice(t,a.length,0,s)}if(a[r]instanceof Ku)throw new RangeError("Cannot overwrite a Counter object; use .increment() or .decrement() to change its value.");(a[r]!==n||Object.keys(a[Zo][r]||{}).length>1||n===void 0)&&this.applyAtPath(t,s=>{let u=Vf(a,r),l=this.nextOpId(),f=this.setValue(i,r,n,!1,u,zd(a,r));s.edits.push({action:"update",index:r,opId:l,value:f})})}splice(t,r,n,i){let a=t.length===0?"_root":t[t.length-1].objectId,s=this.getObject(a);if(r<0||n<0||r>s.length-n)throw new RangeError(`${n} deletions starting at index ${r} are out of bounds for list of length ${s.length}`);if(n===0&&i.length===0)return;let u={diffs:{objectId:"_root",type:"map",props:{}}},l=this.getSubpatch(u.diffs,t);if(n>0){let f,d,g;for(let p=0;p0&&this.insertListItems(l,r,i,!1),this.applyPatch(u.diffs,this.cache._root,this.updated)}addTableRow(t,r){if(!qf(r)||Array.isArray(r))throw new TypeError("A table row must be an object");if(r[Kd])throw new TypeError("Cannot reuse an existing object as table row");if(r.id)throw new TypeError('A table row must not have an "id" property; it is generated automatically');let n=xL(),i=this.setValue(t[t.length-1].objectId,n,r,!1,[]);return this.applyAtPath(t,a=>{a.props[n]={[i.objectId]:i}}),n}deleteTableRow(t,r,n){let i=t[t.length-1].objectId;this.getObject(i).byId(r)&&(this.addOp({action:"del",obj:i,key:r,insert:!1,pred:[n]}),this.applyAtPath(t,s=>{s.props[r]={}}))}increment(t,r,n){let i=t.length===0?"_root":t[t.length-1].objectId,a=this.getObject(i);if(!(a[r]instanceof Ku))throw new TypeError("Only counter values can be incremented");let s=this.getObjectType(i),u=a[r].value+n,l=this.nextOpId(),f=Vf(a,r);if(s==="list"||s==="text"){let d=zd(a,r,!1);this.addOp({action:"inc",obj:i,elemId:d,value:n,insert:!1,pred:f})}else this.addOp({action:"inc",obj:i,key:r,value:n,insert:!1,pred:f});this.applyAtPath(t,d=>{s==="list"||s==="text"?d.edits.push({action:"update",index:r,opId:l,value:{value:u,datatype:"counter"}}):d.props[r]={[l]:{value:u,datatype:"counter"}}})}};function Vf(e,t){return e instanceof zf?[e.opIds[t]]:e instanceof Kf?e.elems[t].pred:e[Zo]?e[Zo][t]?Object.keys(e[Zo][t]):[]:[]}function zd(e,t,r=!1){if(r){if(t===0)return"_head";t-=1}if(e[JC])return e[JC][t];if(e.getElemId)return e.getElemId(t);throw new RangeError(`Cannot find elemId at list index ${t}`)}QC.exports={Context:sv}});var r6=le((zW,t6)=>{var{OBJECT_ID:OL,CONFLICTS:Zn}=fu(),av=class{constructor(){this.observers={}}patchCallback(t,r,n,i,a){this._objectUpdate(t.diffs,r,n,i,a)}_objectUpdate(t,r,n,i,a){if(t.objectId){if(this.observers[t.objectId])for(let s of this.observers[t.objectId])s(t,r,n,i,a);if(t.type==="map"&&t.props)for(let s of Object.keys(t.props))for(let u of Object.keys(t.props[s]))this._objectUpdate(t.props[s][u],r&&r[Zn]&&r[Zn][s]&&r[Zn][s][u],n&&n[Zn]&&n[Zn][s]&&n[Zn][s][u],i,a);else if(t.type==="table"&&t.props)for(let s of Object.keys(t.props))for(let u of Object.keys(t.props[s]))this._objectUpdate(t.props[s][u],r&&r.byId(s),n&&n.byId(s),i,a);else if(t.type==="list"&&t.edits){let s=0;for(let u of t.edits)u.action==="insert"?(s-=1,this._objectUpdate(u.value,void 0,n&&n[Zn]&&n[Zn][u.index]&&n[Zn][u.index][u.elemId],i,a)):u.action==="multi-insert"?s-=u.values.length:u.action==="update"?this._objectUpdate(u.value,r&&r[Zn]&&r[Zn][u.index+s]&&r[Zn][u.index+s][u.opId],n&&n[Zn]&&n[Zn][u.index]&&n[Zn][u.index][u.opId],i,a):u.action==="remove"&&(s+=u.count)}else if(t.type==="text"&&t.edits){let s=0;for(let u of t.edits)u.action==="insert"?(s-=1,this._objectUpdate(u.value,void 0,n&&n.get(u.index),i,a)):u.action==="multi-insert"?s-=u.values.length:u.action==="update"?this._objectUpdate(u.value,r&&r.get(u.index+s),n&&n.get(u.index),i,a):u.action==="remove"&&(s+=u.count)}}}observe(t,r){let n=t[OL];if(!n)throw new TypeError("The observed object must be part of an Automerge document");this.observers[n]||(this.observers[n]=[]),this.observers[n].push(r)}};t6.exports={Observable:av}});var f6=le((GW,c6)=>{var{OPTIONS:pa,CACHE:cc,STATE:ga,OBJECT_ID:hc,CONFLICTS:fc,CHANGE:n6,ELEM_IDS:TL}=fu(),{isObject:lv,copyObject:uv}=Ss(),kL=Ld(),{interpretPatch:NL,cloneRootObject:LL}=Jm(),{rootObjectProxy:UL}=WC(),{Context:i6}=e6(),{Text:cv}=Uf(),{Table:s6}=Hf(),{Counter:jL}=Hd(),{Float64:HL,Int:ML,Uint:qL}=tv(),{Observable:VL}=r6();function a6(e){if(typeof e!="string")throw new TypeError(`Unsupported type of actorId: ${typeof e}`);if(!/^[0-9a-f]+$/.test(e))throw new RangeError("actorId must consist only of lowercase hex digits");if(e.length%2!==0)throw new RangeError("actorId must consist of an even number of digits")}function Gd(e,t,r){let n=t._root;if(n||(n=LL(e[cc]._root),t._root=n),Object.defineProperty(n,pa,{value:e[pa]}),Object.defineProperty(n,cc,{value:t}),Object.defineProperty(n,ga,{value:r}),e[pa].freeze)for(let i of Object.keys(t))t[i]instanceof s6?t[i]._freeze():t[i]instanceof cv?(Object.freeze(t[i].elems),Object.freeze(t[i])):(Object.freeze(t[i]),Object.freeze(t[i][fc]));for(let i of Object.keys(e[cc]))t[i]||(t[i]=e[cc][i]);return e[pa].freeze&&Object.freeze(t),n}function u6(e,t,r){let n=dc(e);if(!n)throw new Error("Actor ID must be initialized with setActorId() before making a change");let i=uv(e[ga]);i.seq+=1;let a={actor:n,seq:i.seq,startOp:i.maxOp+1,deps:i.deps,time:r&&typeof r.time=="number"?r.time:Math.round(new Date().getTime()/1e3),message:r&&typeof r.message=="string"?r.message:"",ops:t.ops};if(e[pa].backend){let[s,u,l]=e[pa].backend.applyLocalChange(i.backendState,a);i.backendState=s,i.lastLocalChange=l;let f=ov(e,u,i,!0),d=r&&r.patchCallback||e[pa].patchCallback;return d&&d(u,e,f,!0,[l]),[f,a]}else{let s={actor:n,seq:a.seq,before:e};return i.requests=i.requests.concat([s]),i.maxOp=i.maxOp+KL(a.ops),i.deps=[],[Gd(e,t?t.updated:{},i),a]}}function KL(e){let t=0;for(let r of e)r.action==="set"&&r.values?t+=r.values.length:t+=1;return t}function zL(e){return e[ga]&&e[ga].lastLocalChange?e[ga].lastLocalChange:null}function ov(e,t,r,n){let i=dc(e),a={};if(NL(t.diffs,e,a),n){if(!t.clock)throw new RangeError("patch is missing clock field");t.clock[i]&&t.clock[i]>r.seq&&(r.seq=t.clock[i]),r.clock=t.clock,r.deps=t.deps,r.maxOp=Math.max(r.maxOp,t.maxOp)}return Gd(e,a,r)}function o6(e){if(typeof e=="string")e={actorId:e};else if(typeof e>"u")e={};else if(!lv(e))throw new TypeError(`Unsupported value for init() options: ${e}`);if(e.deferActorId||(e.actorId===void 0&&(e.actorId=kL()),a6(e.actorId)),e.observable){let i=e.patchCallback,a=e.observable;e.patchCallback=(s,u,l,f,d)=>{i&&i(s,u,l,f,d),a.patchCallback(s,u,l,f,d)}}let t={},r={_root:t},n={seq:0,maxOp:0,requests:[],clock:{},deps:[]};return e.backend&&(n.backendState=e.backend.init(),n.lastLocalChange=null),Object.defineProperty(t,hc,{value:"_root"}),Object.defineProperty(t,pa,{value:Object.freeze(e)}),Object.defineProperty(t,fc,{value:Object.freeze({})}),Object.defineProperty(t,cc,{value:Object.freeze(r)}),Object.defineProperty(t,ga,{value:Object.freeze(n)}),Object.freeze(t)}function GL(e,t){return l6(o6(t),"Initialization",r=>Object.assign(r,e))}function l6(e,t,r){if(e[hc]!=="_root")throw new TypeError("The first argument to Automerge.change must be the document root");if(e[n6])throw new TypeError("Calls to Automerge.change cannot be nested");if(typeof t=="function"&&r===void 0&&([t,r]=[r,t]),typeof t=="string"&&(t={message:t}),t!==void 0&&!lv(t))throw new TypeError("Unsupported type of options");let n=dc(e);if(!n)throw new Error("Actor ID must be initialized with setActorId() before making a change");let i=new i6(e,n);return r(UL(i)),Object.keys(i.updated).length===0?[e,null]:u6(e,i,t)}function YL(e,t){if(e[hc]!=="_root")throw new TypeError("The first argument to Automerge.emptyChange must be the document root");if(typeof t=="string"&&(t={message:t}),t!==void 0&&!lv(t))throw new TypeError("Unsupported type of options");let r=dc(e);if(!r)throw new Error("Actor ID must be initialized with setActorId() before making a change");return u6(e,new i6(e,r),t)}function WL(e,t,r=void 0){if(e[hc]!=="_root")throw new TypeError("The first argument to Frontend.applyPatch must be the document root");let n=uv(e[ga]);if(e[pa].backend){if(!r)throw new RangeError("applyPatch must be called with the updated backend state");return n.backendState=r,ov(e,t,n,!0)}let i;if(n.requests.length>0)if(i=n.requests[0].before,t.actor===dc(e)){if(n.requests[0].seq!==t.seq)throw new RangeError(`Mismatched sequence number: patch ${t.seq} does not match next request ${n.requests[0].seq}`);n.requests=n.requests.slice(1)}else n.requests=n.requests.slice();else i=e,n.requests=[];let a=ov(i,t,n,!0);return n.requests.length===0?a:(n.requests[0]=uv(n.requests[0]),n.requests[0].before=a,Gd(e,{},n))}function XL(e){return e[hc]}function JL(e,t){if(e[n6])throw new TypeError("Cannot use getObjectById in a change callback");return e[cc][t]}function dc(e){return e[ga].actorId||e[pa].actorId}function ZL(e,t){a6(t);let r=Object.assign({},e[ga],{actorId:t});return Gd(e,{},r)}function QL(e,t){if(e[fc]&&e[fc][t]&&Object.keys(e[fc][t]).length>1)return e[fc][t]}function eU(e,t=null,r="first"){if(e[hc]!=="_root"){let n=Array.isArray(e)?". Note: Automerge.applyChanges now returns an array.":"";throw t?new TypeError(`The ${r} argument to Automerge.${t} must be the document root${n}`):new TypeError(`Argument is not an Automerge document root${n}`)}return e[ga].backendState}function tU(e){return e instanceof cv?e.elems.map(t=>t.elemId):e[TL]}c6.exports={init:o6,from:GL,change:l6,emptyChange:YL,applyPatch:WL,getObjectId:XL,getObjectById:JL,getActorId:dc,setActorId:ZL,getConflicts:QL,getLastLocalChange:zL,getBackendState:eU,getElementIds:tU,Text:cv,Table:s6,Counter:jL,Observable:VL,Float64:HL,Int:ML,Uint:qL}});var P6=le((YW,mc)=>{"use strict";function gc(e){let t=e.length;for(;--t>=0;)e[t]=0}var rU=0,v6=1,nU=2,iU=3,sU=258,vv=29,Zf=256,Yf=Zf+1+vv,pc=30,Ev=19,E6=2*Yf+1,Qo=15,fv=16,aU=7,wv=256,w6=16,A6=17,y6=18,gv=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Yd=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),uU=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),b6=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),oU=512,du=new Array((Yf+2)*2);gc(du);var Gf=new Array(pc*2);gc(Gf);var Wf=new Array(oU);gc(Wf);var Xf=new Array(sU-iU+1);gc(Xf);var Av=new Array(vv);gc(Av);var Wd=new Array(pc);gc(Wd);function hv(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}var _6,C6,D6;function dv(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}var F6=e=>e<256?Wf[e]:Wf[256+(e>>>7)],Jf=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},yi=(e,t,r)=>{e.bi_valid>fv-r?(e.bi_buf|=t<>fv-e.bi_valid,e.bi_valid+=r-fv):(e.bi_buf|=t<{yi(e,r[t*2],r[t*2+1])},S6=(e,t)=>{let r=0;do r|=e&1,e>>>=1,r<<=1;while(--t>0);return r>>>1},lU=e=>{e.bi_valid===16?(Jf(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)},cU=(e,t)=>{let r=t.dyn_tree,n=t.max_code,i=t.stat_desc.static_tree,a=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,u=t.stat_desc.extra_base,l=t.stat_desc.max_length,f,d,g,p,h,E,v=0;for(p=0;p<=Qo;p++)e.bl_count[p]=0;for(r[e.heap[e.heap_max]*2+1]=0,f=e.heap_max+1;fl&&(p=l,v++),r[d*2+1]=p,!(d>n)&&(e.bl_count[p]++,h=0,d>=u&&(h=s[d-u]),E=r[d*2],e.opt_len+=E*(p+h),a&&(e.static_len+=E*(i[d*2+1]+h)));if(v!==0){do{for(p=l-1;e.bl_count[p]===0;)p--;e.bl_count[p]--,e.bl_count[p+1]+=2,e.bl_count[l]--,v-=2}while(v>0);for(p=l;p!==0;p--)for(d=e.bl_count[p];d!==0;)g=e.heap[--f],!(g>n)&&(r[g*2+1]!==p&&(e.opt_len+=(p-r[g*2+1])*r[g*2],r[g*2+1]=p),d--)}},I6=(e,t,r)=>{let n=new Array(Qo+1),i=0,a,s;for(a=1;a<=Qo;a++)i=i+r[a-1]<<1,n[a]=i;for(s=0;s<=t;s++){let u=e[s*2+1];u!==0&&(e[s*2]=S6(n[u]++,u))}},fU=()=>{let e,t,r,n,i,a=new Array(Qo+1);for(r=0,n=0;n>=7;n{let t;for(t=0;t{e.bi_valid>8?Jf(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},h6=(e,t,r,n)=>{let i=t*2,a=r*2;return e[i]{let n=e.heap[r],i=r<<1;for(;i<=e.heap_len&&(i{let n,i,a=0,s,u;if(e.sym_next!==0)do n=e.pending_buf[e.sym_buf+a++]&255,n+=(e.pending_buf[e.sym_buf+a++]&255)<<8,i=e.pending_buf[e.sym_buf+a++],n===0?ma(e,i,t):(s=Xf[i],ma(e,s+Zf+1,t),u=gv[s],u!==0&&(i-=Av[s],yi(e,i,u)),n--,s=F6(n),ma(e,s,r),u=Yd[s],u!==0&&(n-=Wd[s],yi(e,n,u)));while(a{let r=t.dyn_tree,n=t.stat_desc.static_tree,i=t.stat_desc.has_stree,a=t.stat_desc.elems,s,u,l=-1,f;for(e.heap_len=0,e.heap_max=E6,s=0;s>1;s>=1;s--)pv(e,r,s);f=a;do s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],pv(e,r,1),u=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=u,r[f*2]=r[s*2]+r[u*2],e.depth[f]=(e.depth[s]>=e.depth[u]?e.depth[s]:e.depth[u])+1,r[s*2+1]=r[u*2+1]=f,e.heap[1]=f++,pv(e,r,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],cU(e,t),I6(r,l,e.bl_count)},p6=(e,t,r)=>{let n,i=-1,a,s=t[0*2+1],u=0,l=7,f=4;for(s===0&&(l=138,f=3),t[(r+1)*2+1]=65535,n=0;n<=r;n++)a=s,s=t[(n+1)*2+1],!(++u{let n,i=-1,a,s=t[0*2+1],u=0,l=7,f=4;for(s===0&&(l=138,f=3),n=0;n<=r;n++)if(a=s,s=t[(n+1)*2+1],!(++u{let t;for(p6(e,e.dyn_ltree,e.l_desc.max_code),p6(e,e.dyn_dtree,e.d_desc.max_code),mv(e,e.bl_desc),t=Ev-1;t>=3&&e.bl_tree[b6[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},dU=(e,t,r,n)=>{let i;for(yi(e,t-257,5),yi(e,r-1,5),yi(e,n-4,4),i=0;i{let t=4093624447,r;for(r=0;r<=31;r++,t>>>=1)if(t&1&&e.dyn_ltree[r*2]!==0)return 0;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return 1;for(r=32;r{m6||(fU(),m6=!0),e.l_desc=new dv(e.dyn_ltree,_6),e.d_desc=new dv(e.dyn_dtree,C6),e.bl_desc=new dv(e.bl_tree,D6),e.bi_buf=0,e.bi_valid=0,B6(e)},R6=(e,t,r,n)=>{yi(e,(rU<<1)+(n?1:0),3),$6(e),Jf(e,r),Jf(e,~r),r&&e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r},mU=e=>{yi(e,v6<<1,3),ma(e,wv,du),lU(e)},vU=(e,t,r,n)=>{let i,a,s=0;e.level>0?(e.strm.data_type===2&&(e.strm.data_type=pU(e)),mv(e,e.l_desc),mv(e,e.d_desc),s=hU(e),i=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,a<=i&&(i=a)):i=a=r+5,r+4<=i&&t!==-1?R6(e,t,r,n):e.strategy===4||a===i?(yi(e,(v6<<1)+(n?1:0),3),d6(e,du,Gf)):(yi(e,(nU<<1)+(n?1:0),3),dU(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),d6(e,e.dyn_ltree,e.dyn_dtree)),B6(e),n&&$6(e)},EU=(e,t,r)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=r,t===0?e.dyn_ltree[r*2]++:(e.matches++,t--,e.dyn_ltree[(Xf[r]+Zf+1)*2]++,e.dyn_dtree[F6(t)*2]++),e.sym_next===e.sym_end);mc.exports._tr_init=gU;mc.exports._tr_stored_block=R6;mc.exports._tr_flush_block=vU;mc.exports._tr_tally=EU;mc.exports._tr_align=mU});var yv=le((WW,x6)=>{"use strict";var wU=(e,t,r,n)=>{let i=e&65535|0,a=e>>>16&65535|0,s=0;for(;r!==0;){s=r>2e3?2e3:r,r-=s;do i=i+t[n++]|0,a=a+i|0;while(--s);i%=65521,a%=65521}return i|a<<16|0};x6.exports=wU});var bv=le((XW,O6)=>{"use strict";var AU=()=>{let e,t=[];for(var r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;t[r]=e}return t},yU=new Uint32Array(AU()),bU=(e,t,r,n)=>{let i=yU,a=n+r;e^=-1;for(let s=n;s>>8^i[(e^t[s])&255];return e^-1};O6.exports=bU});var Xd=le((JW,T6)=>{"use strict";T6.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}});var zu=le((ZW,k6)=>{"use strict";k6.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}});var z6=le((QW,Aa)=>{"use strict";var{_tr_init:_U,_tr_stored_block:Dv,_tr_flush_block:CU,_tr_tally:Xu,_tr_align:DU}=P6(),j6=yv(),Gu=bv(),FU=Xd(),{Z_NO_FLUSH:Ju,Z_PARTIAL_FLUSH:SU,Z_FULL_FLUSH:IU,Z_FINISH:os,Z_BLOCK:N6,Z_OK:yn,Z_STREAM_END:L6,Z_STREAM_ERROR:Ea,Z_DATA_ERROR:BU,Z_BUF_ERROR:_v,Z_DEFAULT_COMPRESSION:$U,Z_FILTERED:RU,Z_HUFFMAN_ONLY:Jd,Z_RLE:PU,Z_FIXED:xU,Z_DEFAULT_STRATEGY:OU,Z_UNKNOWN:TU,Z_DEFLATED:Zd}=zu(),kU=9,NU=15,LU=8,UU=29,jU=256,Fv=jU+1+UU,HU=30,MU=19,qU=2*Fv+1,VU=15,$t=3,Wu=258,wa=Wu+$t+1,KU=32,Ec=42,Pv=57,Sv=69,Iv=73,Bv=91,$v=103,el=113,eh=666,Qn=1,Ac=2,rl=3,yc=4,zU=3,tl=(e,t)=>(e.msg=FU[t],t),U6=e=>e*2-(e>4?9:0),Yu=e=>{let t=e.length;for(;--t>=0;)e[t]=0},GU=e=>{let t,r,n,i=e.w_size;t=e.hash_size,n=t;do r=e.head[--n],e.head[n]=r>=i?r-i:0;while(--t);t=i,n=t;do r=e.prev[--n],e.prev[n]=r>=i?r-i:0;while(--t)},YU=(e,t,r)=>(t<{let t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),r!==0&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+r),e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,t.pending===0&&(t.pending_out=0))},Ki=(e,t)=>{CU(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Vi(e.strm)},Ut=(e,t)=>{e.pending_buf[e.pending++]=t},Qf=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},Rv=(e,t,r,n)=>{let i=e.avail_in;return i>n&&(i=n),i===0?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),r),e.state.wrap===1?e.adler=j6(e.adler,t,i,r):e.state.wrap===2&&(e.adler=Gu(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)},H6=(e,t)=>{let r=e.max_chain_length,n=e.strstart,i,a,s=e.prev_length,u=e.nice_match,l=e.strstart>e.w_size-wa?e.strstart-(e.w_size-wa):0,f=e.window,d=e.w_mask,g=e.prev,p=e.strstart+Wu,h=f[n+s-1],E=f[n+s];e.prev_length>=e.good_match&&(r>>=2),u>e.lookahead&&(u=e.lookahead);do if(i=t,!(f[i+s]!==E||f[i+s-1]!==h||f[i]!==f[n]||f[++i]!==f[n+1])){n+=2,i++;do;while(f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&ns){if(e.match_start=t,s=a,a>=u)break;h=f[n+s-1],E=f[n+s]}}while((t=g[t&d])>l&&--r!==0);return s<=e.lookahead?s:e.lookahead},wc=e=>{let t=e.w_size,r,n,i;do{if(n=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-wa)&&(e.window.set(e.window.subarray(t,t+t-n),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),GU(e),n+=t),e.strm.avail_in===0)break;if(r=Rv(e.strm,e.window,e.strstart+e.lookahead,n),e.lookahead+=r,e.lookahead+e.insert>=$t)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=Zu(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=Zu(e,e.ins_h,e.window[i+$t-1]),e.prev[i&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=i,i++,e.insert--,!(e.lookahead+e.insert<$t)););}while(e.lookahead{let r=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,n,i,a,s=0,u=e.strm.avail_in;do{if(n=65535,a=e.bi_valid+42>>3,e.strm.avail_outi+e.strm.avail_in&&(n=i+e.strm.avail_in),n>a&&(n=a),n>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,Vi(e.strm),i&&(i>n&&(i=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+i),e.strm.next_out),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i,e.block_start+=i,n-=i),n&&(Rv(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(s===0);return u-=e.strm.avail_in,u&&(u>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=u&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-u,e.strm.next_in),e.strstart),e.strstart+=u,e.insert+=u>e.w_size-e.insert?e.w_size-e.insert:u),e.block_start=e.strstart),e.high_watera&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,a+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),a>e.strm.avail_in&&(a=e.strm.avail_in),a&&(Rv(e.strm,e.window,e.strstart,a),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.high_water>3,a=e.pending_buf_size-a>65535?65535:e.pending_buf_size-a,r=a>e.w_size?e.w_size:a,i=e.strstart-e.block_start,(i>=r||(i||t===os)&&t!==Ju&&e.strm.avail_in===0&&i<=a)&&(n=i>a?a:i,s=t===os&&e.strm.avail_in===0&&n===i?1:0,Dv(e,e.block_start,n,s),e.block_start+=n,Vi(e.strm)),s?rl:Qn)},Cv=(e,t)=>{let r,n;for(;;){if(e.lookahead=$t&&(e.ins_h=Zu(e,e.ins_h,e.window[e.strstart+$t-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),r!==0&&e.strstart-r<=e.w_size-wa&&(e.match_length=H6(e,r)),e.match_length>=$t)if(n=Xu(e,e.strstart-e.match_start,e.match_length-$t),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=$t){e.match_length--;do e.strstart++,e.ins_h=Zu(e,e.ins_h,e.window[e.strstart+$t-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=Zu(e,e.ins_h,e.window[e.strstart+1]);else n=Xu(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(Ki(e,!1),e.strm.avail_out===0))return Qn}return e.insert=e.strstart<$t-1?e.strstart:$t-1,t===os?(Ki(e,!0),e.strm.avail_out===0?rl:yc):e.sym_next&&(Ki(e,!1),e.strm.avail_out===0)?Qn:Ac},vc=(e,t)=>{let r,n,i;for(;;){if(e.lookahead=$t&&(e.ins_h=Zu(e,e.ins_h,e.window[e.strstart+$t-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=$t-1,r!==0&&e.prev_length4096)&&(e.match_length=$t-1)),e.prev_length>=$t&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-$t,n=Xu(e,e.strstart-1-e.prev_match,e.prev_length-$t),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=Zu(e,e.ins_h,e.window[e.strstart+$t-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=$t-1,e.strstart++,n&&(Ki(e,!1),e.strm.avail_out===0))return Qn}else if(e.match_available){if(n=Xu(e,0,e.window[e.strstart-1]),n&&Ki(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return Qn}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=Xu(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<$t-1?e.strstart:$t-1,t===os?(Ki(e,!0),e.strm.avail_out===0?rl:yc):e.sym_next&&(Ki(e,!1),e.strm.avail_out===0)?Qn:Ac},WU=(e,t)=>{let r,n,i,a,s=e.window;for(;;){if(e.lookahead<=Wu){if(wc(e),e.lookahead<=Wu&&t===Ju)return Qn;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=$t&&e.strstart>0&&(i=e.strstart-1,n=s[i],n===s[++i]&&n===s[++i]&&n===s[++i])){a=e.strstart+Wu;do;while(n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=$t?(r=Xu(e,1,e.match_length-$t),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=Xu(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(Ki(e,!1),e.strm.avail_out===0))return Qn}return e.insert=0,t===os?(Ki(e,!0),e.strm.avail_out===0?rl:yc):e.sym_next&&(Ki(e,!1),e.strm.avail_out===0)?Qn:Ac},XU=(e,t)=>{let r;for(;;){if(e.lookahead===0&&(wc(e),e.lookahead===0)){if(t===Ju)return Qn;break}if(e.match_length=0,r=Xu(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(Ki(e,!1),e.strm.avail_out===0))return Qn}return e.insert=0,t===os?(Ki(e,!0),e.strm.avail_out===0?rl:yc):e.sym_next&&(Ki(e,!1),e.strm.avail_out===0)?Qn:Ac};function va(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}var th=[new va(0,0,0,0,M6),new va(4,4,8,4,Cv),new va(4,5,16,8,Cv),new va(4,6,32,32,Cv),new va(4,4,16,16,vc),new va(8,16,32,32,vc),new va(8,16,128,128,vc),new va(8,32,128,256,vc),new va(32,128,258,1024,vc),new va(32,258,258,4096,vc)],JU=e=>{e.window_size=2*e.w_size,Yu(e.head),e.max_lazy_match=th[e.level].max_lazy,e.good_match=th[e.level].good_length,e.nice_match=th[e.level].nice_length,e.max_chain_length=th[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=$t-1,e.match_available=0,e.ins_h=0};function ZU(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Zd,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(qU*2),this.dyn_dtree=new Uint16Array((2*HU+1)*2),this.bl_tree=new Uint16Array((2*MU+1)*2),Yu(this.dyn_ltree),Yu(this.dyn_dtree),Yu(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(VU+1),this.heap=new Uint16Array(2*Fv+1),Yu(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Fv+1),Yu(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var rh=e=>{if(!e)return 1;let t=e.state;return!t||t.strm!==e||t.status!==Ec&&t.status!==Pv&&t.status!==Sv&&t.status!==Iv&&t.status!==Bv&&t.status!==$v&&t.status!==el&&t.status!==eh?1:0},q6=e=>{if(rh(e))return tl(e,Ea);e.total_in=e.total_out=0,e.data_type=TU;let t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?Pv:t.wrap?Ec:el,e.adler=t.wrap===2?0:1,t.last_flush=-2,_U(t),yn},V6=e=>{let t=q6(e);return t===yn&&JU(e.state),t},QU=(e,t)=>rh(e)||e.state.wrap!==2?Ea:(e.state.gzhead=t,yn),K6=(e,t,r,n,i,a)=>{if(!e)return Ea;let s=1;if(t===$U&&(t=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),i<1||i>kU||r!==Zd||n<8||n>15||t<0||t>9||a<0||a>xU||n===8&&s!==1)return tl(e,Ea);n===8&&(n=9);let u=new ZU;return e.state=u,u.strm=e,u.status=Ec,u.wrap=s,u.gzhead=null,u.w_bits=n,u.w_size=1<K6(e,t,Zd,NU,LU,OU),tj=(e,t)=>{if(rh(e)||t>N6||t<0)return e?tl(e,Ea):Ea;let r=e.state;if(!e.output||e.avail_in!==0&&!e.input||r.status===eh&&t!==os)return tl(e,e.avail_out===0?_v:Ea);let n=r.last_flush;if(r.last_flush=t,r.pending!==0){if(Vi(e),e.avail_out===0)return r.last_flush=-1,yn}else if(e.avail_in===0&&U6(t)<=U6(n)&&t!==os)return tl(e,_v);if(r.status===eh&&e.avail_in!==0)return tl(e,_v);if(r.status===Ec&&r.wrap===0&&(r.status=el),r.status===Ec){let i=Zd+(r.w_bits-8<<4)<<8,a=-1;if(r.strategy>=Jd||r.level<2?a=0:r.level<6?a=1:r.level===6?a=2:a=3,i|=a<<6,r.strstart!==0&&(i|=KU),i+=31-i%31,Qf(r,i),r.strstart!==0&&(Qf(r,e.adler>>>16),Qf(r,e.adler&65535)),e.adler=1,r.status=el,Vi(e),r.pending!==0)return r.last_flush=-1,yn}if(r.status===Pv){if(e.adler=0,Ut(r,31),Ut(r,139),Ut(r,8),r.gzhead)Ut(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),Ut(r,r.gzhead.time&255),Ut(r,r.gzhead.time>>8&255),Ut(r,r.gzhead.time>>16&255),Ut(r,r.gzhead.time>>24&255),Ut(r,r.level===9?2:r.strategy>=Jd||r.level<2?4:0),Ut(r,r.gzhead.os&255),r.gzhead.extra&&r.gzhead.extra.length&&(Ut(r,r.gzhead.extra.length&255),Ut(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=Gu(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=Sv;else if(Ut(r,0),Ut(r,0),Ut(r,0),Ut(r,0),Ut(r,0),Ut(r,r.level===9?2:r.strategy>=Jd||r.level<2?4:0),Ut(r,zU),r.status=el,Vi(e),r.pending!==0)return r.last_flush=-1,yn}if(r.status===Sv){if(r.gzhead.extra){let i=r.pending,a=(r.gzhead.extra.length&65535)-r.gzindex;for(;r.pending+a>r.pending_buf_size;){let u=r.pending_buf_size-r.pending;if(r.pending_buf.set(r.gzhead.extra.subarray(r.gzindex,r.gzindex+u),r.pending),r.pending=r.pending_buf_size,r.gzhead.hcrc&&r.pending>i&&(e.adler=Gu(e.adler,r.pending_buf,r.pending-i,i)),r.gzindex+=u,Vi(e),r.pending!==0)return r.last_flush=-1,yn;i=0,a-=u}let s=new Uint8Array(r.gzhead.extra);r.pending_buf.set(s.subarray(r.gzindex,r.gzindex+a),r.pending),r.pending+=a,r.gzhead.hcrc&&r.pending>i&&(e.adler=Gu(e.adler,r.pending_buf,r.pending-i,i)),r.gzindex=0}r.status=Iv}if(r.status===Iv){if(r.gzhead.name){let i=r.pending,a;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>i&&(e.adler=Gu(e.adler,r.pending_buf,r.pending-i,i)),Vi(e),r.pending!==0)return r.last_flush=-1,yn;i=0}r.gzindexi&&(e.adler=Gu(e.adler,r.pending_buf,r.pending-i,i)),r.gzindex=0}r.status=Bv}if(r.status===Bv){if(r.gzhead.comment){let i=r.pending,a;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>i&&(e.adler=Gu(e.adler,r.pending_buf,r.pending-i,i)),Vi(e),r.pending!==0)return r.last_flush=-1,yn;i=0}r.gzindexi&&(e.adler=Gu(e.adler,r.pending_buf,r.pending-i,i))}r.status=$v}if(r.status===$v){if(r.gzhead.hcrc){if(r.pending+2>r.pending_buf_size&&(Vi(e),r.pending!==0))return r.last_flush=-1,yn;Ut(r,e.adler&255),Ut(r,e.adler>>8&255),e.adler=0}if(r.status=el,Vi(e),r.pending!==0)return r.last_flush=-1,yn}if(e.avail_in!==0||r.lookahead!==0||t!==Ju&&r.status!==eh){let i=r.level===0?M6(r,t):r.strategy===Jd?XU(r,t):r.strategy===PU?WU(r,t):th[r.level].func(r,t);if((i===rl||i===yc)&&(r.status=eh),i===Qn||i===rl)return e.avail_out===0&&(r.last_flush=-1),yn;if(i===Ac&&(t===SU?DU(r):t!==N6&&(Dv(r,0,0,!1),t===IU&&(Yu(r.head),r.lookahead===0&&(r.strstart=0,r.block_start=0,r.insert=0))),Vi(e),e.avail_out===0))return r.last_flush=-1,yn}return t!==os?yn:r.wrap<=0?L6:(r.wrap===2?(Ut(r,e.adler&255),Ut(r,e.adler>>8&255),Ut(r,e.adler>>16&255),Ut(r,e.adler>>24&255),Ut(r,e.total_in&255),Ut(r,e.total_in>>8&255),Ut(r,e.total_in>>16&255),Ut(r,e.total_in>>24&255)):(Qf(r,e.adler>>>16),Qf(r,e.adler&65535)),Vi(e),r.wrap>0&&(r.wrap=-r.wrap),r.pending!==0?yn:L6)},rj=e=>{if(rh(e))return Ea;let t=e.state.status;return e.state=null,t===el?tl(e,BU):yn},nj=(e,t)=>{let r=t.length;if(rh(e))return Ea;let n=e.state,i=n.wrap;if(i===2||i===1&&n.status!==Ec||n.lookahead)return Ea;if(i===1&&(e.adler=j6(e.adler,t,r,0)),n.wrap=0,r>=n.w_size){i===0&&(Yu(n.head),n.strstart=0,n.block_start=0,n.insert=0);let l=new Uint8Array(n.w_size);l.set(t.subarray(r-n.w_size,r),0),t=l,r=n.w_size}let a=e.avail_in,s=e.next_in,u=e.input;for(e.avail_in=r,e.next_in=0,e.input=t,wc(n);n.lookahead>=$t;){let l=n.strstart,f=n.lookahead-($t-1);do n.ins_h=Zu(n,n.ins_h,n.window[l+$t-1]),n.prev[l&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=l,l++;while(--f);n.strstart=l,n.lookahead=$t-1,wc(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=$t-1,n.match_available=0,e.next_in=s,e.input=u,e.avail_in=a,n.wrap=i,yn};Aa.exports.deflateInit=ej;Aa.exports.deflateInit2=K6;Aa.exports.deflateReset=V6;Aa.exports.deflateResetKeep=q6;Aa.exports.deflateSetHeader=QU;Aa.exports.deflate=tj;Aa.exports.deflateEnd=rj;Aa.exports.deflateSetDictionary=nj;Aa.exports.deflateInfo="pako deflate (from Nodeca project)"});var Ov=le((eX,xv)=>{"use strict";var ij=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);xv.exports.assign=function(e){let t=Array.prototype.slice.call(arguments,1);for(;t.length;){let r=t.shift();if(r){if(typeof r!="object")throw new TypeError(r+"must be non-object");for(let n in r)ij(r,n)&&(e[n]=r[n])}}return e};xv.exports.flattenChunks=e=>{let t=0;for(let n=0,i=e.length;n{"use strict";var G6=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{G6=!1}var nh=new Uint8Array(256);for(let e=0;e<256;e++)nh[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;nh[254]=nh[254]=1;Qd.exports.string2buf=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,r,n,i,a,s=e.length,u=0;for(i=0;i>>6,t[a++]=128|r&63):r<65536?(t[a++]=224|r>>>12,t[a++]=128|r>>>6&63,t[a++]=128|r&63):(t[a++]=240|r>>>18,t[a++]=128|r>>>12&63,t[a++]=128|r>>>6&63,t[a++]=128|r&63);return t};var sj=(e,t)=>{if(t<65534&&e.subarray&&G6)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let r="";for(let n=0;n{let r=t||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,t));let n,i,a=new Array(r*2);for(i=0,n=0;n4){a[i++]=65533,n+=u-1;continue}for(s&=u===2?31:u===3?15:7;u>1&&n1){a[i++]=65533;continue}s<65536?a[i++]=s:(s-=65536,a[i++]=55296|s>>10&1023,a[i++]=56320|s&1023)}return sj(a,i)};Qd.exports.utf8border=(e,t)=>{t=t||e.length,t>e.length&&(t=e.length);let r=t-1;for(;r>=0&&(e[r]&192)===128;)r--;return r<0||r===0?t:r+nh[e[r]]>t?r:t}});var kv=le((rX,Y6)=>{"use strict";function aj(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}Y6.exports=aj});var Z6=le((nX,bc)=>{"use strict";var ih=z6(),W6=Ov(),X6=Tv(),Nv=Xd(),uj=kv(),J6=Object.prototype.toString,{Z_NO_FLUSH:oj,Z_SYNC_FLUSH:lj,Z_FULL_FLUSH:cj,Z_FINISH:fj,Z_OK:ep,Z_STREAM_END:hj,Z_DEFAULT_COMPRESSION:dj,Z_DEFAULT_STRATEGY:pj,Z_DEFLATED:gj}=zu();function sh(e){this.options=W6.assign({level:dj,method:gj,chunkSize:16384,windowBits:15,memLevel:8,strategy:pj},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new uj,this.strm.avail_out=0;let r=ih.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==ep)throw new Error(Nv[r]);if(t.header&&ih.deflateSetHeader(this.strm,t.header),t.dictionary){let n;if(typeof t.dictionary=="string"?n=X6.string2buf(t.dictionary):J6.call(t.dictionary)==="[object ArrayBuffer]"?n=new Uint8Array(t.dictionary):n=t.dictionary,r=ih.deflateSetDictionary(this.strm,n),r!==ep)throw new Error(Nv[r]);this._dict_set=!0}}sh.prototype.push=function(e,t){let r=this.strm,n=this.options.chunkSize,i,a;if(this.ended)return!1;for(t===~~t?a=t:a=t===!0?fj:oj,typeof e=="string"?r.input=X6.string2buf(e):J6.call(e)==="[object ArrayBuffer]"?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){if(r.avail_out===0&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(a===lj||a===cj)&&r.avail_out<=6){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if(i=ih.deflate(r,a),i===hj)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),i=ih.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===ep;if(r.avail_out===0){this.onData(r.output);continue}if(a>0&&r.next_out>0){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if(r.avail_in===0)break}return!0};sh.prototype.onData=function(e){this.chunks.push(e)};sh.prototype.onEnd=function(e){e===ep&&(this.result=W6.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Lv(e,t){let r=new sh(t);if(r.push(e,!0),r.err)throw r.msg||Nv[r.err];return r.result}function mj(e,t){return t=t||{},t.raw=!0,Lv(e,t)}function vj(e,t){return t=t||{},t.gzip=!0,Lv(e,t)}bc.exports.Deflate=sh;bc.exports.deflate=Lv;bc.exports.deflateRaw=mj;bc.exports.gzip=vj;bc.exports.constants=zu()});var e4=le((iX,Q6)=>{"use strict";Q6.exports=function(t,r){let n,i,a,s,u,l,f,d,g,p,h,E,v,b,m,y,D,C,F,L,k,S,B,O,P=t.state;n=t.next_in,B=t.input,i=n+(t.avail_in-5),a=t.next_out,O=t.output,s=a-(r-t.avail_out),u=a+(t.avail_out-257),l=P.dmax,f=P.wsize,d=P.whave,g=P.wnext,p=P.window,h=P.hold,E=P.bits,v=P.lencode,b=P.distcode,m=(1<>>24,h>>>=C,E-=C,C=D>>>16&255,C===0)O[a++]=D&65535;else if(C&16){F=D&65535,C&=15,C&&(E>>=C,E-=C),E<15&&(h+=B[n++]<>>24,h>>>=C,E-=C,C=D>>>16&255,C&16){if(L=D&65535,C&=15,El){t.msg="invalid distance too far back",P.mode=16209;break e}if(h>>>=C,E-=C,C=a-s,L>C){if(C=L-C,C>d&&P.sane){t.msg="invalid distance too far back",P.mode=16209;break e}if(k=0,S=p,g===0){if(k+=f-C,C2;)O[a++]=S[k++],O[a++]=S[k++],O[a++]=S[k++],F-=3;F&&(O[a++]=S[k++],F>1&&(O[a++]=S[k++]))}else{k=a-L;do O[a++]=O[k++],O[a++]=O[k++],O[a++]=O[k++],F-=3;while(F>2);F&&(O[a++]=O[k++],F>1&&(O[a++]=O[k++]))}}else if(C&64){t.msg="invalid distance code",P.mode=16209;break e}else{D=b[(D&65535)+(h&(1<>3,n-=F,E-=F<<3,h&=(1<{"use strict";var Ej=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),wj=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Aj=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),yj=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),bj=(e,t,r,n,i,a,s,u)=>{let l=u.bits,f=0,d=0,g=0,p=0,h=0,E=0,v=0,b=0,m=0,y=0,D,C,F,L,k,S=null,B,O=new Uint16Array(16),P=new Uint16Array(16),U=null,Y,H,K;for(f=0;f<=15;f++)O[f]=0;for(d=0;d=1&&O[p]===0;p--);if(h>p&&(h=p),p===0)return i[a++]=1<<24|64<<16|0,i[a++]=1<<24|64<<16|0,u.bits=1,0;for(g=1;g0&&(e===0||p!==1))return-1;for(P[1]=0,f=1;f<15;f++)P[f+1]=P[f]+O[f];for(d=0;d852||e===2&&m>592)return 1;for(;;){Y=f-v,s[d]+1=B?(H=U[s[d]-B],K=S[s[d]-B]):(H=96,K=0),D=1<>v)+C]=Y<<24|H<<16|K|0;while(C!==0);for(D=1<>=1;if(D!==0?(y&=D-1,y+=D):y=0,d++,--O[f]===0){if(f===p)break;f=t[r+s[d]]}if(f>h&&(y&L)!==F){for(v===0&&(v=h),k+=g,E=f-v,b=1<852||e===2&&m>592)return 1;F=y&L,i[F]=h<<24|E<<16|k-a|0}}return y!==0&&(i[k+y]=f-v<<24|64<<16|0),u.bits=h,0};t4.exports=bj});var N4=le((aX,Is)=>{"use strict";var Vv=yv(),ya=bv(),_j=e4(),ah=r4(),Cj=0,I4=1,B4=2,{Z_FINISH:n4,Z_BLOCK:Dj,Z_TREES:tp,Z_OK:nl,Z_STREAM_END:Fj,Z_NEED_DICT:Sj,Z_STREAM_ERROR:ls,Z_DATA_ERROR:$4,Z_MEM_ERROR:Kv,Z_BUF_ERROR:Ij,Z_DEFLATED:i4}=zu(),sp=16180,s4=16181,a4=16182,u4=16183,o4=16184,l4=16185,c4=16186,f4=16187,h4=16188,d4=16189,ip=16190,pu=16191,Uv=16192,p4=16193,jv=16194,g4=16195,m4=16196,v4=16197,E4=16198,rp=16199,np=16200,w4=16201,A4=16202,y4=16203,b4=16204,_4=16205,Hv=16206,C4=16207,D4=16208,hr=16209,zv=16210,R4=16211,Bj=852,$j=592,Rj=15,Pj=Rj,F4=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function xj(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var il=e=>{if(!e)return 1;let t=e.state;return!t||t.strm!==e||t.modeR4?1:0},P4=e=>{if(il(e))return ls;let t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=sp,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(Bj),t.distcode=t.distdyn=new Int32Array($j),t.sane=1,t.back=-1,nl},x4=e=>{if(il(e))return ls;let t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,P4(e)},O4=(e,t)=>{let r;if(il(e))return ls;let n=e.state;return t<0?(r=0,t=-t):(r=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?ls:(n.window!==null&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,x4(e))},T4=(e,t)=>{if(!e)return ls;let r=new xj;e.state=r,r.strm=e,r.window=null,r.mode=sp;let n=O4(e,t);return n!==nl&&(e.state=null),n},Oj=e=>T4(e,Pj),S4=!0,Mv,qv,Tj=e=>{if(S4){Mv=new Int32Array(512),qv=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(ah(I4,e.lens,0,288,Mv,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;ah(B4,e.lens,0,32,qv,0,e.work,{bits:5}),S4=!1}e.lencode=Mv,e.lenbits=9,e.distcode=qv,e.distbits=5},k4=(e,t,r,n)=>{let i,a=e.state;return a.window===null&&(a.wsize=1<=a.wsize?(a.window.set(t.subarray(r-a.wsize,r),0),a.wnext=0,a.whave=a.wsize):(i=a.wsize-a.wnext,i>n&&(i=n),a.window.set(t.subarray(r-n,r-n+i),a.wnext),n-=i,n?(a.window.set(t.subarray(r-n,r),0),a.wnext=n,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave{let r,n,i,a,s,u,l,f,d,g,p,h,E,v,b=0,m,y,D,C,F,L,k,S,B=new Uint8Array(4),O,P,U=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(il(e)||!e.output||!e.input&&e.avail_in!==0)return ls;r=e.state,r.mode===pu&&(r.mode=Uv),s=e.next_out,i=e.output,l=e.avail_out,a=e.next_in,n=e.input,u=e.avail_in,f=r.hold,d=r.bits,g=u,p=l,S=nl;e:for(;;)switch(r.mode){case sp:if(r.wrap===0){r.mode=Uv;break}for(;d<16;){if(u===0)break e;u--,f+=n[a++]<>>8&255,r.check=ya(r.check,B,2,0),f=0,d=0,r.mode=s4;break}if(r.head&&(r.head.done=!1),!(r.wrap&1)||(((f&255)<<8)+(f>>8))%31){e.msg="incorrect header check",r.mode=hr;break}if((f&15)!==i4){e.msg="unknown compression method",r.mode=hr;break}if(f>>>=4,d-=4,k=(f&15)+8,r.wbits===0&&(r.wbits=k),k>15||k>r.wbits){e.msg="invalid window size",r.mode=hr;break}r.dmax=1<>8&1),r.flags&512&&r.wrap&4&&(B[0]=f&255,B[1]=f>>>8&255,r.check=ya(r.check,B,2,0)),f=0,d=0,r.mode=a4;case a4:for(;d<32;){if(u===0)break e;u--,f+=n[a++]<>>8&255,B[2]=f>>>16&255,B[3]=f>>>24&255,r.check=ya(r.check,B,4,0)),f=0,d=0,r.mode=u4;case u4:for(;d<16;){if(u===0)break e;u--,f+=n[a++]<>8),r.flags&512&&r.wrap&4&&(B[0]=f&255,B[1]=f>>>8&255,r.check=ya(r.check,B,2,0)),f=0,d=0,r.mode=o4;case o4:if(r.flags&1024){for(;d<16;){if(u===0)break e;u--,f+=n[a++]<>>8&255,r.check=ya(r.check,B,2,0)),f=0,d=0}else r.head&&(r.head.extra=null);r.mode=l4;case l4:if(r.flags&1024&&(h=r.length,h>u&&(h=u),h&&(r.head&&(k=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(a,a+h),k)),r.flags&512&&r.wrap&4&&(r.check=ya(r.check,n,h,a)),u-=h,a+=h,r.length-=h),r.length))break e;r.length=0,r.mode=c4;case c4:if(r.flags&2048){if(u===0)break e;h=0;do k=n[a+h++],r.head&&k&&r.length<65536&&(r.head.name+=String.fromCharCode(k));while(k&&h>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=pu;break;case d4:for(;d<32;){if(u===0)break e;u--,f+=n[a++]<>>=d&7,d-=d&7,r.mode=Hv;break}for(;d<3;){if(u===0)break e;u--,f+=n[a++]<>>=1,d-=1,f&3){case 0:r.mode=p4;break;case 1:if(Tj(r),r.mode=rp,t===tp){f>>>=2,d-=2;break e}break;case 2:r.mode=m4;break;case 3:e.msg="invalid block type",r.mode=hr}f>>>=2,d-=2;break;case p4:for(f>>>=d&7,d-=d&7;d<32;){if(u===0)break e;u--,f+=n[a++]<>>16^65535)){e.msg="invalid stored block lengths",r.mode=hr;break}if(r.length=f&65535,f=0,d=0,r.mode=jv,t===tp)break e;case jv:r.mode=g4;case g4:if(h=r.length,h){if(h>u&&(h=u),h>l&&(h=l),h===0)break e;i.set(n.subarray(a,a+h),s),u-=h,a+=h,l-=h,s+=h,r.length-=h;break}r.mode=pu;break;case m4:for(;d<14;){if(u===0)break e;u--,f+=n[a++]<>>=5,d-=5,r.ndist=(f&31)+1,f>>>=5,d-=5,r.ncode=(f&15)+4,f>>>=4,d-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=hr;break}r.have=0,r.mode=v4;case v4:for(;r.have>>=3,d-=3}for(;r.have<19;)r.lens[U[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,O={bits:r.lenbits},S=ah(Cj,r.lens,0,19,r.lencode,0,r.work,O),r.lenbits=O.bits,S){e.msg="invalid code lengths set",r.mode=hr;break}r.have=0,r.mode=E4;case E4:for(;r.have>>24,y=b>>>16&255,D=b&65535,!(m<=d);){if(u===0)break e;u--,f+=n[a++]<>>=m,d-=m,r.lens[r.have++]=D;else{if(D===16){for(P=m+2;d>>=m,d-=m,r.have===0){e.msg="invalid bit length repeat",r.mode=hr;break}k=r.lens[r.have-1],h=3+(f&3),f>>>=2,d-=2}else if(D===17){for(P=m+3;d>>=m,d-=m,k=0,h=3+(f&7),f>>>=3,d-=3}else{for(P=m+7;d>>=m,d-=m,k=0,h=11+(f&127),f>>>=7,d-=7}if(r.have+h>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=hr;break}for(;h--;)r.lens[r.have++]=k}}if(r.mode===hr)break;if(r.lens[256]===0){e.msg="invalid code -- missing end-of-block",r.mode=hr;break}if(r.lenbits=9,O={bits:r.lenbits},S=ah(I4,r.lens,0,r.nlen,r.lencode,0,r.work,O),r.lenbits=O.bits,S){e.msg="invalid literal/lengths set",r.mode=hr;break}if(r.distbits=6,r.distcode=r.distdyn,O={bits:r.distbits},S=ah(B4,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,O),r.distbits=O.bits,S){e.msg="invalid distances set",r.mode=hr;break}if(r.mode=rp,t===tp)break e;case rp:r.mode=np;case np:if(u>=6&&l>=258){e.next_out=s,e.avail_out=l,e.next_in=a,e.avail_in=u,r.hold=f,r.bits=d,_j(e,p),s=e.next_out,i=e.output,l=e.avail_out,a=e.next_in,n=e.input,u=e.avail_in,f=r.hold,d=r.bits,r.mode===pu&&(r.back=-1);break}for(r.back=0;b=r.lencode[f&(1<>>24,y=b>>>16&255,D=b&65535,!(m<=d);){if(u===0)break e;u--,f+=n[a++]<>C)],m=b>>>24,y=b>>>16&255,D=b&65535,!(C+m<=d);){if(u===0)break e;u--,f+=n[a++]<>>=C,d-=C,r.back+=C}if(f>>>=m,d-=m,r.back+=m,r.length=D,y===0){r.mode=_4;break}if(y&32){r.back=-1,r.mode=pu;break}if(y&64){e.msg="invalid literal/length code",r.mode=hr;break}r.extra=y&15,r.mode=w4;case w4:if(r.extra){for(P=r.extra;d>>=r.extra,d-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=A4;case A4:for(;b=r.distcode[f&(1<>>24,y=b>>>16&255,D=b&65535,!(m<=d);){if(u===0)break e;u--,f+=n[a++]<>C)],m=b>>>24,y=b>>>16&255,D=b&65535,!(C+m<=d);){if(u===0)break e;u--,f+=n[a++]<>>=C,d-=C,r.back+=C}if(f>>>=m,d-=m,r.back+=m,y&64){e.msg="invalid distance code",r.mode=hr;break}r.offset=D,r.extra=y&15,r.mode=y4;case y4:if(r.extra){for(P=r.extra;d>>=r.extra,d-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=hr;break}r.mode=b4;case b4:if(l===0)break e;if(h=p-l,r.offset>h){if(h=r.offset-h,h>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=hr;break}h>r.wnext?(h-=r.wnext,E=r.wsize-h):E=r.wnext-h,h>r.length&&(h=r.length),v=r.window}else v=i,E=s-r.offset,h=r.length;h>l&&(h=l),l-=h,r.length-=h;do i[s++]=v[E++];while(--h);r.length===0&&(r.mode=np);break;case _4:if(l===0)break e;i[s++]=r.length,l--,r.mode=np;break;case Hv:if(r.wrap){for(;d<32;){if(u===0)break e;u--,f|=n[a++]<{if(il(e))return ls;let t=e.state;return t.window&&(t.window=null),e.state=null,nl},Lj=(e,t)=>{if(il(e))return ls;let r=e.state;return r.wrap&2?(r.head=t,t.done=!1,nl):ls},Uj=(e,t)=>{let r=t.length,n,i,a;return il(e)||(n=e.state,n.wrap!==0&&n.mode!==ip)?ls:n.mode===ip&&(i=1,i=Vv(i,t,r,0),i!==n.check)?$4:(a=k4(e,t,r,r),a?(n.mode=zv,Kv):(n.havedict=1,nl))};Is.exports.inflateReset=x4;Is.exports.inflateReset2=O4;Is.exports.inflateResetKeep=P4;Is.exports.inflateInit=Oj;Is.exports.inflateInit2=T4;Is.exports.inflate=kj;Is.exports.inflateEnd=Nj;Is.exports.inflateGetHeader=Lj;Is.exports.inflateSetDictionary=Uj;Is.exports.inflateInfo="pako inflate (from Nodeca project)"});var U4=le((uX,L4)=>{"use strict";function jj(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}L4.exports=jj});var q4=le((oX,_c)=>{"use strict";var gu=N4(),H4=Ov(),Wv=Tv(),Xv=Xd(),Hj=kv(),Mj=U4(),M4=Object.prototype.toString,{Z_NO_FLUSH:qj,Z_FINISH:Vj,Z_OK:uh,Z_STREAM_END:Gv,Z_NEED_DICT:Yv,Z_STREAM_ERROR:Kj,Z_DATA_ERROR:j4,Z_MEM_ERROR:zj}=zu();function oh(e){this.options=H4.assign({chunkSize:1024*64,windowBits:15,to:""},e||{});let t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Hj,this.strm.avail_out=0;let r=gu.inflateInit2(this.strm,t.windowBits);if(r!==uh)throw new Error(Xv[r]);if(this.header=new Mj,gu.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=Wv.string2buf(t.dictionary):M4.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=gu.inflateSetDictionary(this.strm,t.dictionary),r!==uh)))throw new Error(Xv[r])}oh.prototype.push=function(e,t){let r=this.strm,n=this.options.chunkSize,i=this.options.dictionary,a,s,u;if(this.ended)return!1;for(t===~~t?s=t:s=t===!0?Vj:qj,M4.call(e)==="[object ArrayBuffer]"?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){for(r.avail_out===0&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),a=gu.inflate(r,s),a===Yv&&i&&(a=gu.inflateSetDictionary(r,i),a===uh?a=gu.inflate(r,s):a===j4&&(a=Yv));r.avail_in>0&&a===Gv&&r.state.wrap>0&&e[r.next_in]!==0;)gu.inflateReset(r),a=gu.inflate(r,s);switch(a){case Kj:case j4:case Yv:case zj:return this.onEnd(a),this.ended=!0,!1}if(u=r.avail_out,r.next_out&&(r.avail_out===0||a===Gv))if(this.options.to==="string"){let l=Wv.utf8border(r.output,r.next_out),f=r.next_out-l,d=Wv.buf2string(r.output,l);r.next_out=f,r.avail_out=n-f,f&&r.output.set(r.output.subarray(l,l+f),0),this.onData(d)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(!(a===uh&&u===0)){if(a===Gv)return a=gu.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(r.avail_in===0)break}}return!0};oh.prototype.onData=function(e){this.chunks.push(e)};oh.prototype.onEnd=function(e){e===uh&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=H4.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Jv(e,t){let r=new oh(t);if(r.push(e),r.err)throw r.msg||Xv[r.err];return r.result}function Gj(e,t){return t=t||{},t.raw=!0,Jv(e,t)}_c.exports.Inflate=oh;_c.exports.inflate=Jv;_c.exports.inflateRaw=Gj;_c.exports.ungzip=Jv;_c.exports.constants=zu()});var V4=le((lX,ba)=>{"use strict";var{Deflate:Yj,deflate:Wj,deflateRaw:Xj,gzip:Jj}=Z6(),{Inflate:Zj,inflate:Qj,inflateRaw:eH,ungzip:tH}=q4(),rH=zu();ba.exports.Deflate=Yj;ba.exports.deflate=Wj;ba.exports.deflateRaw=Xj;ba.exports.gzip=Jj;ba.exports.Inflate=Zj;ba.exports.inflate=Qj;ba.exports.inflateRaw=eH;ba.exports.ungzip=tH;ba.exports.constants=rH});var r2=le((cX,W4)=>{var nH=new TextEncoder,iH=new TextDecoder("utf-8");function Zv(e){return nH.encode(e)}function Qv(e){return iH.decode(e)}function z4(e){if(typeof e!="string")throw new TypeError("value is not a string");if(!/^([0-9a-f][0-9a-f])*$/.test(e))throw new RangeError("value is not hexadecimal");return e===""?new Uint8Array(0):new Uint8Array(e.match(/../g).map(t=>parseInt(t,16)))}var K4=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"],G4=new Array(256);for(let e=0;e<256;e++)G4[e]=`${K4[e>>>4&15]}${K4[e&15]}`;function Y4(e){let t="",r=e.byteLength;for(let n=0;n=this.buf.byteLength&&this.grow(),this.buf[this.offset]=t,this.offset+=1}appendUint32(t){if(!Number.isInteger(t))throw new RangeError("value is not an integer");if(t<0||t>4294967295)throw new RangeError("number out of range");let r=Math.max(1,Math.ceil((32-Math.clz32(t))/7));this.offset+r>this.buf.byteLength&&this.grow();for(let n=0;n>>=7;return this.offset+=r,r}appendInt32(t){if(!Number.isInteger(t))throw new RangeError("value is not an integer");if(t<-2147483648||t>2147483647)throw new RangeError("number out of range");let r=Math.ceil((33-Math.clz32(t>=0?t:-t-1))/7);this.offset+r>this.buf.byteLength&&this.grow();for(let n=0;n>=7;return this.offset+=r,r}appendUint53(t){if(!Number.isInteger(t))throw new RangeError("value is not an integer");if(t<0||t>Number.MAX_SAFE_INTEGER)throw new RangeError("number out of range");let r=Math.floor(t/4294967296),n=(t&4294967295)>>>0;return this.appendUint64(r,n)}appendInt53(t){if(!Number.isInteger(t))throw new RangeError("value is not an integer");if(tNumber.MAX_SAFE_INTEGER)throw new RangeError("number out of range");let r=Math.floor(t/4294967296),n=(t&4294967295)>>>0;return this.appendInt64(r,n)}appendUint64(t,r){if(!Number.isInteger(t)||!Number.isInteger(r))throw new RangeError("value is not an integer");if(t<0||t>4294967295||r<0||r>4294967295)throw new RangeError("number out of range");if(t===0)return this.appendUint32(r);let n=Math.ceil((64-Math.clz32(t))/7);this.offset+n>this.buf.byteLength&&this.grow();for(let i=0;i<4;i++)this.buf[this.offset+i]=r&127|128,r>>>=7;this.buf[this.offset+4]=r&15|(t&7)<<4|(n===5?0:128),t>>>=3;for(let i=5;i>>=7;return this.offset+=n,n}appendInt64(t,r){if(!Number.isInteger(t)||!Number.isInteger(r))throw new RangeError("value is not an integer");if(t<-2147483648||t>2147483647||r<-2147483648||r>4294967295)throw new RangeError("number out of range");if(r>>>=0,t===0&&r<=2147483647)return this.appendInt32(r);if(t===-1&&r>=2147483648)return this.appendInt32(r-4294967296);let n=Math.ceil((65-Math.clz32(t>=0?t:-t-1))/7);this.offset+n>this.buf.byteLength&&this.grow();for(let i=0;i<4;i++)this.buf[this.offset+i]=r&127|128,r>>>=7;this.buf[this.offset+4]=r&15|(t&7)<<4|(n===5?0:128),t>>=3;for(let i=5;i>=7;return this.offset+=n,n}appendRawBytes(t){return this.offset+t.byteLength>this.buf.byteLength&&this.grow(this.offset+t.byteLength),this.buf.set(t,this.offset),this.offset+=t.byteLength,t.byteLength}appendRawString(t){if(typeof t!="string")throw new TypeError("value is not a string");return this.appendRawBytes(Zv(t))}appendPrefixedBytes(t){return this.appendUint53(t.byteLength),this.appendRawBytes(t),this}appendPrefixedString(t){if(typeof t!="string")throw new TypeError("value is not a string");return this.appendPrefixedBytes(Zv(t)),this}appendHexString(t){return this.appendPrefixedBytes(z4(t)),this}finish(){}},ch=class{constructor(t){if(!(t instanceof Uint8Array))throw new TypeError(`Not a byte array: ${t}`);this.buf=t,this.offset=0}get done(){return this.offset===this.buf.byteLength}reset(){this.offset=0}skip(t){if(this.offset+t>this.buf.byteLength)throw new RangeError("cannot skip beyond end of buffer");this.offset+=t}readByte(){return this.offset+=1,this.buf[this.offset-1]}readUint32(){let t=0,r=0;for(;this.offset>>0,r+=7,this.offset++,!(n&128))return t}throw new RangeError("buffer ended with incomplete number")}readInt32(){let t=0,r=0;for(;this.offset28?t:t|-1<2097151)throw new RangeError("number out of range");return r*4294967296+t}readInt53(){let{low32:t,high32:r}=this.readInt64();if(r<-2097152||r===-2097152&&t===0||r>2097151)throw new RangeError("number out of range");return r*4294967296+t}readUint64(){let t=0,r=0,n=0;for(;this.offset>>0,n===28&&(r=(i&112)>>>4),n+=7,this.offset++,!(i&128))return{high32:r,low32:t}}for(n=3;this.offset>>0,n+=7,this.offset++,!(i&128))return{high32:r,low32:t}}throw new RangeError("buffer ended with incomplete number")}readInt64(){let t=0,r=0,n=0;for(;this.offset>>0,n===28&&(r=(i&112)>>>4),n+=7,this.offset++,!(i&128))return i&64&&(n<32&&(t=(t|-1<>>0),r|=-1<this.buf.byteLength)throw new RangeError("subarray exceeds buffer size");return this.offset+=t,this.buf.subarray(r,this.offset)}readRawString(t){return Qv(this.readRawBytes(t))}readPrefixedBytes(){return this.readRawBytes(this.readUint53())}readPrefixedString(){return Qv(this.readPrefixedBytes())}readHexString(){return Y4(this.readPrefixedBytes())}},ap=class extends lh{constructor(t){super(),this.type=t,this.state="empty",this.lastValue=void 0,this.count=0,this.literal=[]}appendValue(t,r=1){this._appendValue(t,r)}_appendValue(t,r=1){r<=0||(this.state==="empty"?(this.state=t===null?"nulls":r===1?"loneValue":"repetition",this.lastValue=t,this.count=r):this.state==="loneValue"?t===null?(this.flush(),this.state="nulls",this.count=r):t===this.lastValue?(this.state="repetition",this.count=1+r):r>1?(this.flush(),this.state="repetition",this.count=r,this.lastValue=t):(this.state="literal",this.literal=[this.lastValue],this.lastValue=t):this.state==="repetition"?t===null?(this.flush(),this.state="nulls",this.count=r):t===this.lastValue?this.count+=r:r>1?(this.flush(),this.state="repetition",this.count=r,this.lastValue=t):(this.flush(),this.state="loneValue",this.lastValue=t):this.state==="literal"?t===null?(this.literal.push(this.lastValue),this.flush(),this.state="nulls",this.count=r):t===this.lastValue?(this.flush(),this.state="repetition",this.count=1+r):r>1?(this.literal.push(this.lastValue),this.flush(),this.state="repetition",this.count=r,this.lastValue=t):(this.literal.push(this.lastValue),this.lastValue=t):this.state==="nulls"&&(t===null?this.count+=r:r>1?(this.flush(),this.state="repetition",this.count=r,this.lastValue=t):(this.flush(),this.state="loneValue",this.lastValue=t)))}copyFrom(t,r={}){let{count:n,sumValues:i,sumShift:a}=r;if(!(t instanceof fh)||t.type!==this.type)throw new TypeError("incompatible type of decoder");let s=typeof n=="number"?n:Number.MAX_SAFE_INTEGER,u=0,l=0;if(n&&s>0&&t.done)throw new RangeError(`cannot copy ${n} values`);if(s===0||t.done)return i?{nonNullValues:u,sum:l}:{nonNullValues:u};let f=t.readValue();if(f===null){let g=Math.min(t.count+1,s);if(s-=g,t.count-=g-1,this.appendValue(null,g),n&&s>0&&t.done)throw new RangeError(`cannot copy ${n} values`);if(s===0||t.done)return i?{nonNullValues:u,sum:l}:{nonNullValues:u};if(f=t.readValue(),f===null)throw new RangeError("null run must be followed by non-null value")}if(this.appendValue(f),s--,u++,i&&(l+=a?f>>>a:f),n&&s>0&&t.done)throw new RangeError(`cannot copy ${n} values`);if(s===0||t.done)return i?{nonNullValues:u,sum:l}:{nonNullValues:u};let d=t.count>0;for(;s>0&&!t.done;){d||t.readRecord();let g=Math.min(t.count,s);if(t.count-=g,t.state==="literal"){u+=g;for(let p=0;p>>a:h)}}else if(t.state==="repetition"){u+=g,i&&(l+=g*(a?t.lastValue>>>a:t.lastValue));let p=t.lastValue;if(this._appendValue(p),g>1){if(this._appendValue(p),this.state!=="repetition")throw new RangeError(`Unexpected state ${this.state}`);this.count+=g-2}}else if(t.state==="nulls"){if(this._appendValue(null),this.state!=="nulls")throw new RangeError(`Unexpected state ${this.state}`);this.count+=g-1}d=!1,s-=g}if(n&&s>0&&t.done)throw new RangeError(`cannot copy ${n} values`);return i?{nonNullValues:u,sum:l}:{nonNullValues:u}}flush(){if(this.state==="loneValue")this.appendInt32(-1),this.appendRawValue(this.lastValue);else if(this.state==="repetition")this.appendInt53(this.count),this.appendRawValue(this.lastValue);else if(this.state==="literal"){this.appendInt53(-this.literal.length);for(let t of this.literal)this.appendRawValue(t)}else this.state==="nulls"&&(this.appendInt32(0),this.appendUint53(this.count));this.state="empty"}appendRawValue(t){if(this.type==="int")this.appendInt53(t);else if(this.type==="uint")this.appendUint53(t);else if(this.type==="utf8")this.appendPrefixedString(t);else throw new RangeError(`Unknown RLEEncoder datatype: ${this.type}`)}finish(){this.state==="literal"&&this.literal.push(this.lastValue),(this.state!=="nulls"||this.offset>0)&&this.flush()}},fh=class extends ch{constructor(t,r){super(r),this.type=t,this.lastValue=void 0,this.count=0,this.state=void 0}get done(){return this.count===0&&this.offset===this.buf.byteLength}reset(){this.offset=0,this.lastValue=void 0,this.count=0,this.state=void 0}readValue(){if(this.done)return null;if(this.count===0&&this.readRecord(),this.count-=1,this.state==="literal"){let t=this.readRawValue();if(t===this.lastValue)throw new RangeError("Repetition of values is not allowed in literal");return this.lastValue=t,t}else return this.lastValue}skipValues(t){for(;t>0&&!this.done;){this.count===0&&(this.count=this.readInt53(),this.count>0?(this.lastValue=this.count<=t?this.skipRawValues(1):this.readRawValue(),this.state="repetition"):this.count<0?(this.count=-this.count,this.state="literal"):(this.count=this.readUint53(),this.lastValue=null,this.state="nulls"));let r=Math.min(t,this.count);this.state==="literal"&&this.skipRawValues(r),t-=r,this.count-=r}}readRecord(){if(this.count=this.readInt53(),this.count>1){let t=this.readRawValue();if((this.state==="repetition"||this.state==="literal")&&this.lastValue===t)throw new RangeError("Successive repetitions with the same value are not allowed");this.state="repetition",this.lastValue=t}else{if(this.count===1)throw new RangeError("Repetition count of 1 is not allowed, use a literal instead");if(this.count<0){if(this.count=-this.count,this.state==="literal")throw new RangeError("Successive literals are not allowed");this.state="literal"}else{if(this.state==="nulls")throw new RangeError("Successive null runs are not allowed");if(this.count=this.readUint53(),this.count===0)throw new RangeError("Zero-length null runs are not allowed");this.lastValue=null,this.state="nulls"}}}readRawValue(){if(this.type==="int")return this.readInt53();if(this.type==="uint")return this.readUint53();if(this.type==="utf8")return this.readPrefixedString();throw new RangeError(`Unknown RLEDecoder datatype: ${this.type}`)}skipRawValues(t){if(this.type==="utf8")for(let r=0;r0&&this.offset0)throw new RangeError("cannot skip beyond end of buffer")}}},e2=class extends ap{constructor(){super("int"),this.absoluteValue=0}appendValue(t,r=1){r<=0||(typeof t=="number"?(super.appendValue(t-this.absoluteValue,1),this.absoluteValue=t,r>1&&super.appendValue(0,r-1)):super.appendValue(t,r))}copyFrom(t,r={}){if(r.sumValues)throw new RangeError("unsupported options for DeltaEncoder.copyFrom()");if(!(t instanceof up))throw new TypeError("incompatible type of decoder");let n=r.count;if(n>0&&t.done)throw new RangeError(`cannot copy ${n} values`);if(n===0||t.done)return;let i=t.readValue(),a=0;if(this.appendValue(i),i===null){if(a=t.count+1,n!==void 0&&na&&t.done)throw new RangeError(`cannot copy ${n} values`);if(n===a||t.done)return;t.count===0&&this.appendValue(t.readValue())}n!==void 0&&(n-=a+1);let{nonNullValues:s,sum:u}=super.copyFrom(t,{count:n,sumValues:!0});s>0&&(this.absoluteValue=u,t.absoluteValue=u)}},up=class extends fh{constructor(t){super("int",t),this.absoluteValue=0}reset(){this.offset=0,this.lastValue=void 0,this.count=0,this.state=void 0,this.absoluteValue=0}readValue(){let t=super.readValue();return t===null?null:(this.absoluteValue+=t,this.absoluteValue)}skipValues(t){for(;t>0&&!this.done;){this.count===0&&this.readRecord();let r=Math.min(t,this.count);if(this.state==="literal")for(let n=0;n0&&t.done)throw new RangeError(`cannot copy ${n} values`);if(i===0||t.done)return;this.appendValue(t.readValue()),i--;let a=Math.min(t.count,i);for(this.count+=a,t.count-=a,i-=a;i>0&&!t.done;){if(t.count=t.readUint53(),t.count===0)throw new RangeError("Zero-length runs are not allowed");t.lastValue=!t.lastValue,this.appendUint53(this.count);let s=Math.min(t.count,i);this.count=s,this.lastValue=t.lastValue,t.count-=s,i-=s}if(n&&i>0&&t.done)throw new RangeError(`cannot copy ${n} values`)}finish(){this.count>0&&(this.appendUint53(this.count),this.count=0)}},op=class extends ch{constructor(t){super(t),this.lastValue=!0,this.firstRun=!0,this.count=0}get done(){return this.count===0&&this.offset===this.buf.byteLength}reset(){this.offset=0,this.lastValue=!0,this.firstRun=!0,this.count=0}readValue(){if(this.done)return!1;for(;this.count===0;){if(this.count=this.readUint53(),this.lastValue=!this.lastValue,this.count===0&&!this.firstRun)throw new RangeError("Zero-length runs are not allowed");this.firstRun=!1}return this.count-=1,this.lastValue}skipValues(t){for(;t>0&&!this.done;){if(this.count===0){if(this.count=this.readUint53(),this.lastValue=!this.lastValue,this.count===0&&!this.firstRun)throw new RangeError("Zero-length runs are not allowed");this.firstRun=!1}this.count{(function(e,t){var r={};t(r);var n=r.default;for(var i in r)n[i]=r[i];typeof lp=="object"&&typeof lp.exports=="object"?lp.exports=n:typeof define=="function"&&define.amd?define(function(){return n}):e.sha256=n})(X4,function(e){"use strict";e.__esModule=!0,e.digestLength=32,e.blockSize=64;var t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function r(g,p,h,E,v){for(var b,m,y,D,C,F,L,k,S,B,O,P,U;v>=64;){for(b=p[0],m=p[1],y=p[2],D=p[3],C=p[4],F=p[5],L=p[6],k=p[7],B=0;B<16;B++)O=E+B*4,g[B]=(h[O]&255)<<24|(h[O+1]&255)<<16|(h[O+2]&255)<<8|h[O+3]&255;for(B=16;B<64;B++)S=g[B-2],P=(S>>>17|S<<15)^(S>>>19|S<<13)^S>>>10,S=g[B-15],U=(S>>>7|S<<25)^(S>>>18|S<<14)^S>>>3,g[B]=(P+g[B-7]|0)+(U+g[B-16]|0);for(B=0;B<64;B++)P=(((C>>>6|C<<26)^(C>>>11|C<<21)^(C>>>25|C<<7))+(C&F^~C&L)|0)+(k+(t[B]+g[B]|0)|0)|0,U=((b>>>2|b<<30)^(b>>>13|b<<19)^(b>>>22|b<<10))+(b&m^b&y^m&y)|0,k=L,L=F,F=C,C=D+P|0,D=y,y=m,m=b,b=P+U|0;p[0]+=b,p[1]+=m,p[2]+=y,p[3]+=D,p[4]+=C,p[5]+=F,p[6]+=L,p[7]+=k,E+=64,v-=64}return E}var n=function(){function g(){this.digestLength=e.digestLength,this.blockSize=e.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return g.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},g.prototype.clean=function(){for(var p=0;p0){for(;this.bufferLength<64&&h>0;)this.buffer[this.bufferLength++]=p[E++],h--;this.bufferLength===64&&(r(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(h>=64&&(E=r(this.temp,this.state,p,E,h),h%=64);h>0;)this.buffer[this.bufferLength++]=p[E++],h--;return this},g.prototype.finish=function(p){if(!this.finished){var h=this.bytesHashed,E=this.bufferLength,v=h/536870912|0,b=h<<3,m=h%64<56?64:128;this.buffer[E]=128;for(var y=E+1;y>>24&255,this.buffer[m-7]=v>>>16&255,this.buffer[m-6]=v>>>8&255,this.buffer[m-5]=v>>>0&255,this.buffer[m-4]=b>>>24&255,this.buffer[m-3]=b>>>16&255,this.buffer[m-2]=b>>>8&255,this.buffer[m-1]=b>>>0&255,r(this.temp,this.state,this.buffer,0,m),this.finished=!0}for(var y=0;y<8;y++)p[y*4+0]=this.state[y]>>>24&255,p[y*4+1]=this.state[y]>>>16&255,p[y*4+2]=this.state[y]>>>8&255,p[y*4+3]=this.state[y]>>>0&255;return this},g.prototype.digest=function(){var p=new Uint8Array(this.digestLength);return this.finish(p),p},g.prototype._saveState=function(p){for(var h=0;hthis.blockSize)new n().update(p).finish(h).clean();else for(var E=0;E1&&p.update(g),h&&p.update(h),p.update(E),p.finish(g),E[0]++}var l=new Uint8Array(e.digestLength);function f(g,p,h,E){p===void 0&&(p=l),E===void 0&&(E=32);for(var v=new Uint8Array([1]),b=s(p,g),m=new i(b),y=new Uint8Array(m.digestLength),D=y.length,C=new Uint8Array(E),F=0;F>>24&255,m[1]=L>>>16&255,m[2]=L>>>8&255,m[3]=L>>>0&255,v.reset(),v.update(p),v.update(m),v.finish(D);for(var k=0;k{var hp=V4(),{copyObject:Z4,parseOpId:mu,equalBytes:Q4}=Ss(),{utf8ToString:sH,hexStringToBytes:sD,bytesToHexString:dp,Encoder:Fc,Decoder:_i,RLEEncoder:bi,RLEDecoder:eD,DeltaEncoder:Cc,DeltaDecoder:aH,BooleanEncoder:aD,BooleanDecoder:uH}=r2(),{Hash:uD}=J4(),Dc=new Uint8Array([133,111,74,131]),u2=0,Sc=1,ph=2,oD=256,mt={GROUP_CARD:0,ACTOR_ID:1,INT_RLE:2,INT_DELTA:3,BOOLEAN:4,STRING_RLE:5,VALUE_LEN:6,VALUE_RAW:7},dh=8,Qt={NULL:0,FALSE:1,TRUE:2,LEB128_UINT:3,LEB128_INT:4,IEEE754:5,UTF8:6,BYTES:7,COUNTER:8,TIMESTAMP:9,MIN_UNKNOWN:10,MAX_UNKNOWN:15},hh=["makeMap","set","makeList","del","makeText","inc","makeTable","link"],oH={makeMap:"map",makeList:"list",makeText:"text",makeTable:"table"},lD=[{columnName:"objActor",columnId:0|mt.ACTOR_ID},{columnName:"objCtr",columnId:0|mt.INT_RLE},{columnName:"keyActor",columnId:16|mt.ACTOR_ID},{columnName:"keyCtr",columnId:16|mt.INT_DELTA},{columnName:"keyStr",columnId:16|mt.STRING_RLE},{columnName:"idActor",columnId:32|mt.ACTOR_ID},{columnName:"idCtr",columnId:32|mt.INT_DELTA},{columnName:"insert",columnId:48|mt.BOOLEAN},{columnName:"action",columnId:64|mt.INT_RLE},{columnName:"valLen",columnId:80|mt.VALUE_LEN},{columnName:"valRaw",columnId:80|mt.VALUE_RAW},{columnName:"chldActor",columnId:96|mt.ACTOR_ID},{columnName:"chldCtr",columnId:96|mt.INT_DELTA}],o2=lD.concat([{columnName:"predNum",columnId:112|mt.GROUP_CARD},{columnName:"predActor",columnId:112|mt.ACTOR_ID},{columnName:"predCtr",columnId:112|mt.INT_DELTA}]),l2=lD.concat([{columnName:"succNum",columnId:128|mt.GROUP_CARD},{columnName:"succActor",columnId:128|mt.ACTOR_ID},{columnName:"succCtr",columnId:128|mt.INT_DELTA}]),cD=[{columnName:"actor",columnId:0|mt.ACTOR_ID},{columnName:"seq",columnId:0|mt.INT_DELTA},{columnName:"maxOp",columnId:16|mt.INT_DELTA},{columnName:"time",columnId:32|mt.INT_DELTA},{columnName:"message",columnId:48|mt.STRING_RLE},{columnName:"depsNum",columnId:64|mt.GROUP_CARD},{columnName:"depsIndex",columnId:64|mt.INT_DELTA},{columnName:"extraLen",columnId:80|mt.VALUE_LEN},{columnName:"extraRaw",columnId:80|mt.VALUE_RAW}];function cp(e,t){if(!e||!e.actorId)return e;let r=e.counter,n=t.indexOf(e.actorId);if(n<0)throw new RangeError("missing actorId");return{counter:r,actorNum:n,actorId:e.actorId}}function n2(e,t){return e.countert.counter?1:e.actorIdt.actorId?1:0}function lH(e,t){let r={},n=[];for(let a of e)a=Z4(a),r[a.actor]=!0,a.ops=vH(a.ops,a.startOp,a.actor),a.ops=a.ops.map(s=>{s=Z4(s),s.obj!=="_root"&&(s.obj=mu(s.obj)),s.elemId&&s.elemId!=="_head"&&(s.elemId=mu(s.elemId)),s.child&&(s.child=mu(s.child)),s.pred&&(s.pred=s.pred.map(mu)),s.obj.actorId&&(r[s.obj.actorId]=!0),s.elemId&&s.elemId.actorId&&(r[s.elemId.actorId]=!0),s.child&&s.child.actorId&&(r[s.child.actorId]=!0);for(let u of s.pred)r[u.actorId]=!0;return s}),n.push(a);let i=Object.keys(r).sort();t&&(i=[e[0].actor].concat(i.filter(a=>a!==e[0].actor)));for(let a of n){a.actorNum=i.indexOf(a.actor);for(let s=0;scp(l,i))}}return{changes:n,actorIds:i}}function cH(e,t){if(e.obj==="_root")t.objActor.appendValue(null),t.objCtr.appendValue(null);else if(e.obj.actorNum>=0&&e.obj.counter>0)t.objActor.appendValue(e.obj.actorNum),t.objCtr.appendValue(e.obj.counter);else throw new RangeError(`Unexpected objectId reference: ${JSON.stringify(e.obj)}`)}function fH(e,t){if(e.key)t.keyActor.appendValue(null),t.keyCtr.appendValue(null),t.keyStr.appendValue(e.key);else if(e.elemId==="_head"&&e.insert)t.keyActor.appendValue(null),t.keyCtr.appendValue(0),t.keyStr.appendValue(null);else if(e.elemId&&e.elemId.actorNum>=0&&e.elemId.counter>0)t.keyActor.appendValue(e.elemId.actorNum),t.keyCtr.appendValue(e.elemId.counter),t.keyStr.appendValue(null);else throw new RangeError(`Unexpected operation key: ${JSON.stringify(e)}`)}function hH(e,t){let r=hh.indexOf(e.action);if(r>=0)t.action.appendValue(r);else if(typeof e.action=="number")t.action.appendValue(e.action);else throw new RangeError(`Unexpected operation action: ${e.action}`)}function dH(e){switch(e.datatype){case"counter":return[Qt.COUNTER,e.value];case"timestamp":return[Qt.TIMESTAMP,e.value];case"uint":return[Qt.LEB128_UINT,e.value];case"int":return[Qt.LEB128_INT,e.value];case"float64":{let t=new ArrayBuffer(8);return new DataView(t).setFloat64(0,e.value,!0),[Qt.IEEE754,new Uint8Array(t)]}default:if(Number.isInteger(e.value)&&e.value<=Number.MAX_SAFE_INTEGER&&e.value>=Number.MIN_SAFE_INTEGER)return[Qt.LEB128_INT,e.value];{let t=new ArrayBuffer(8);return new DataView(t).setFloat64(0,e.value,!0),[Qt.IEEE754,new Uint8Array(t)]}}}function pH(e,t){if(e.action!=="set"&&e.action!=="inc"||e.value===null)t.valLen.appendValue(Qt.NULL);else if(e.value===!1)t.valLen.appendValue(Qt.FALSE);else if(e.value===!0)t.valLen.appendValue(Qt.TRUE);else if(typeof e.value=="string"){let r=t.valRaw.appendRawString(e.value);t.valLen.appendValue(r<<4|Qt.UTF8)}else if(ArrayBuffer.isView(e.value)){let r=t.valRaw.appendRawBytes(new Uint8Array(e.value.buffer));t.valLen.appendValue(r<<4|Qt.BYTES)}else if(typeof e.value=="number"){let[r,n]=dH(e),i;r===Qt.LEB128_UINT?i=t.valRaw.appendUint53(n):r===Qt.IEEE754?i=t.valRaw.appendRawBytes(n):i=t.valRaw.appendInt53(n),t.valLen.appendValue(i<<4|r)}else if(typeof e.datatype=="number"&&e.datatype>=Qt.MIN_UNKNOWN&&e.datatype<=Qt.MAX_UNKNOWN&&e.value instanceof Uint8Array){let r=t.valRaw.appendRawBytes(e.value);t.valLen.appendValue(r<<4|e.datatype)}else throw e.datatype?new RangeError(`Unknown datatype ${e.datatype} for value ${e.value}`):new RangeError(`Unsupported value in operation: ${e.value}`)}function fD(e,t){if(e===Qt.NULL)return{value:null};if(e===Qt.FALSE)return{value:!1};if(e===Qt.TRUE)return{value:!0};if(e%16===Qt.UTF8)return{value:sH(t)};if(e%16===Qt.LEB128_UINT)return{value:new _i(t).readUint53(),datatype:"uint"};if(e%16===Qt.LEB128_INT)return{value:new _i(t).readInt53(),datatype:"int"};if(e%16===Qt.IEEE754){let r=new DataView(t.buffer,t.byteOffset,t.byteLength);if(t.byteLength===8)return{value:r.getFloat64(0,!0),datatype:"float64"};throw new RangeError(`Invalid length for floating point number: ${t.byteLength}`)}else return e%16===Qt.COUNTER?{value:new _i(t).readInt53(),datatype:"counter"}:e%16===Qt.TIMESTAMP?{value:new _i(t).readInt53(),datatype:"timestamp"}:{value:t,datatype:e%16}}function tD(e,t,r,n){let{columnId:i,columnName:a,decoder:s}=e[t];if(i%8===mt.VALUE_LEN&&t+1>4),{value:f,datatype:d}=fD(u,l);return n[a]=f,d&&(n[a+"_datatype"]=d),2}else if(i%8===mt.ACTOR_ID){let u=s.readValue();if(u===null)n[a]=null;else{if(!r[u])throw new RangeError(`No actor index ${u}`);n[a]=r[u]}}else n[a]=s.readValue();return 1}function gH(e,t){let r={objActor:new bi("uint"),objCtr:new bi("uint"),keyActor:new bi("uint"),keyCtr:new Cc,keyStr:new bi("utf8"),insert:new aD,action:new bi("uint"),valLen:new bi("uint"),valRaw:new Fc,chldActor:new bi("uint"),chldCtr:new Cc};t?(r.idActor=new bi("uint"),r.idCtr=new Cc,r.succNum=new bi("uint"),r.succActor=new bi("uint"),r.succCtr=new Cc):(r.predNum=new bi("uint"),r.predCtr=new Cc,r.predActor=new bi("uint"));for(let i of e)if(cH(i,r),fH(i,r),r.insert.appendValue(!!i.insert),hH(i,r),pH(i,r),i.child&&i.child.counter?(r.chldActor.appendValue(i.child.actorNum),r.chldCtr.appendValue(i.child.counter)):(r.chldActor.appendValue(null),r.chldCtr.appendValue(null)),t){r.idActor.appendValue(i.id.actorNum),r.idCtr.appendValue(i.id.counter),r.succNum.appendValue(i.succ.length),i.succ.sort(n2);for(let a=0;ai.columnId-a.columnId)}function mH(e,t){return t===void 0?typeof e=="string"||typeof e=="boolean"||e===null:typeof e=="number"}function vH(e,t,r){let n=t,i=[];for(let a of e)if(a.action==="set"&&a.values&&a.insert){if(a.pred.length!==0)throw new RangeError("multi-insert pred must be empty");let s=a.elemId,u=a.datatype;for(let l of a.values){if(!mH(l,u))throw new RangeError(`Decode failed: bad value/datatype association (${l},${u})`);i.push({action:"set",obj:a.obj,elemId:s,datatype:u,value:l,pred:[],insert:!0}),s=`${n}@${r}`,n+=1}}else if(a.action==="del"&&a.multiOp>1){if(a.pred.length!==1)throw new RangeError("multiOp deletion must have exactly one pred");let s=mu(a.elemId),u=mu(a.pred[0]);for(let l=0;l`${l.succCtr}@${l.succActor}`),rD(n.succNum.map(l=>({counter:l.succCtr,actorId:l.succActor})))):(u.pred=n.predNum.map(l=>`${l.predCtr}@${l.predActor}`),rD(n.predNum.map(l=>({counter:l.predCtr,actorId:l.predActor})))),r.push(u)}return r}function rD(e){let t=null;for(let r of e){if(t&&n2(t,r)!==-1)throw new RangeError("operation IDs are not in ascending order");t=r}}function EH(e){return(e&7)===mt.INT_DELTA?new Cc:(e&7)===mt.BOOLEAN?new aD:(e&7)===mt.STRING_RLE?new bi("utf8"):(e&7)===mt.VALUE_RAW?new Fc:new bi("uint")}function fp(e,t){return(e&7)===mt.INT_DELTA?new aH(t):(e&7)===mt.BOOLEAN?new uH(t):(e&7)===mt.STRING_RLE?new eD("utf8",t):(e&7)===mt.VALUE_RAW?new _i(t):new eD("uint",t)}function dD(e,t){let r=new Uint8Array(0),n=[],i=0,a=0;for(;i!i.decoder.done);){let i={},a=0;for(;a>4,l=1;for(;a+l>4===u;)l++;if(s%8===mt.GROUP_CARD){let f=[],d=e[a].decoder.readValue();for(let g=0;g>>0,r=-1,n=[],i=e.readUint53();for(let a=0;an.encoder.buffer.byteLength>0);e.appendUint53(r.length);for(let n of r)e.appendUint53(n.columnId),e.appendUint53(n.encoder.buffer.byteLength)}function pD(e){let t=e.readUint53(),r=[];for(let s=0;s{if(!Array.isArray(n.deps))throw new TypeError("deps is not an array");u.appendUint53(n.deps.length);for(let f of n.deps.slice().sort())u.appendRawBytes(sD(f));u.appendHexString(n.actor),u.appendUint53(n.seq),u.appendUint53(n.startOp),u.appendInt53(n.time),u.appendPrefixedString(n.message||""),u.appendUint53(r.length-1);for(let f of r.slice(1))u.appendHexString(f);let l=gH(n.ops,!1);a2(u,l);for(let f of l)u.appendRawBytes(f.encoder.buffer);n.extraBytes&&u.appendRawBytes(n.extraBytes)}),s=dp(i);if(e.hash&&e.hash!==s)throw new RangeError(`Change hash does not match encoding: ${e.hash} != ${s}`);return a.byteLength>=oD?AH(a):a}function vD(e){e[8]===ph&&(e=ED(e));let t=new _i(e),r=Ic(t,!0),n=new _i(r.chunkData);if(!t.done)throw new RangeError("Encoded change has trailing data");if(r.chunkType!==Sc)throw new RangeError(`Unexpected chunk type: ${r.chunkType}`);let i=pD(n),a=s2(n);for(let s=0;sn.counter?1:r.actorIdn.actorId?1:0}function _H(e,t){let r={};for(let i of e){if(i.ops=[],r[i.actor]||(r[i.actor]=[]),i.seq!==r[i.actor].length+1)throw new RangeError(`Expected seq = ${r[i.actor].length+1}, got ${i.seq}`);if(i.seq>1&&r[i.actor][i.seq-2].maxOp>i.maxOp)throw new RangeError("maxOp must increase monotonically per actor");r[i.actor].push(i)}let n={};for(let i of t){if(i.action==="del")throw new RangeError("document should not contain del operations");i.pred=n[i.id]?n[i.id].pred:[],n[i.id]=i;for(let a of i.succ){if(!n[a])if(i.elemId){let s=i.insert?i.id:i.elemId;n[a]={id:a,action:"del",obj:i.obj,elemId:s,pred:[]}}else n[a]={id:a,action:"del",obj:i.obj,key:i.key,pred:[]};n[a].pred.push(i.id)}delete i.succ}for(let i of Object.values(n))i.action==="del"&&t.push(i);for(let i of t){let{counter:a,actorId:s}=mu(i.id),u=r[s],l=0,f=u.length;for(;l=u.length)throw new RangeError(`Operation ID ${i.id} outside of allowed range`);u[l].ops.push(i)}for(let i of e){i.ops.sort((a,s)=>bH(a.id,s.id)),i.startOp=i.maxOp-i.ops.length+1,delete i.maxOp;for(let a=0;af.depsIndex)){if(!e[l]||!e[l].hash)throw new RangeError(`No hash for index ${l} while processing index ${s}`);let f=e[l].hash;u.deps.push(f),r[f]&&delete r[f]}if(u.deps.sort(),delete u.depsNum,u.extraLen_datatype!==Qt.BYTES)throw new RangeError(`Bad datatype for extra bytes: ${Qt.BYTES}`);u.extraBytes=u.extraLen,delete u.extraLen_datatype,e[s]=c2(mD(u)),r[e[s].hash]=!0}let n=Object.keys(r).sort(),i=n.length===t.length,a=0;for(;i&&a{u.appendUint53(n.length);for(let l of n)u.appendHexString(l);u.appendUint53(i.length);for(let l of i.sort())u.appendRawBytes(sD(l));a2(u,t),a2(u,r);for(let l of t)u.appendRawBytes(l.encoder.buffer);for(let l of r)u.appendRawBytes(l.encoder.buffer);for(let l of a)u.appendUint53(l);s&&u.appendRawBytes(s)}).bytes}function AD(e){let t=new _i(e),r=Ic(t,!0),n=new _i(r.chunkData);if(!t.done)throw new RangeError("Encoded document has trailing data");if(r.chunkType!==u2)throw new RangeError(`Unexpected chunk type: ${r.chunkType}`);let i=[],a=n.readUint53();for(let p=0;p=oD&&(e.encoder={buffer:hp.deflateRaw(e.encoder.buffer)},e.columnId|=dh)}function iD(e){e.columnId&dh&&(e.buffer=hp.inflateRaw(e.buffer),e.columnId^=dh)}bD.exports={COLUMN_TYPE:mt,VALUE_TYPE:Qt,ACTIONS:hh,OBJECT_TYPE:oH,DOC_OPS_COLUMNS:l2,CHANGE_COLUMNS:o2,DOCUMENT_COLUMNS:cD,encoderByColumnId:EH,decoderByColumnId:fp,makeDecoders:dD,decodeValue:fD,splitContainers:wD,encodeChange:mD,decodeChangeColumns:vD,decodeChange:c2,decodeChangeMeta:wH,decodeChanges:yH,encodeDocumentHeader:DH,decodeDocumentHeader:AD,decodeDocument:yD}});var UD=le((hX,LD)=>{var{parseOpId:mp,copyObject:vp}=Ss(),{COLUMN_TYPE:Cn,VALUE_TYPE:h2,ACTIONS:vu,OBJECT_TYPE:_D,DOC_OPS_COLUMNS:CD,CHANGE_COLUMNS:Kt,DOCUMENT_COLUMNS:Bs,encoderByColumnId:xc,decoderByColumnId:A2,makeDecoders:mh,decodeValue:pp,encodeChange:FH,decodeChangeColumns:SH,decodeChangeMeta:IH,decodeChanges:BH,decodeDocumentHeader:$H,encodeDocumentHeader:RH}=gh(),Eh=600,PH=10,$D=7,RD=Math.floor(PH*Eh/8),Sr=0,vr=1,bn=2,_n=3,bt=4,kn=5,cr=6,Nn=7,jr=8,Qu=9,sl=10,eo=13,Bc=14,$c=15,$s=13,d2=14,Rc=15,DD=Kt.filter(e=>["predNum","predActor","predCtr"].includes(e.columnName)).map(e=>e.columnId);function p2(e,t,r){if(t.length===1)e[t[0]]=r;else{let n=Object.assign({},e[t[0]]);p2(n,t.slice(1),r),e[t[0]]=n}}function FD(e,t,r,n){for(let H of t)H.decoder.reset();let{objActor:i,objCtr:a,keyActor:s,keyCtr:u,keyStr:l,idActor:f,idCtr:d,insert:g}=e,[p,h,,,E,v,b,m,y,,,,,D]=t.map(H=>H.decoder),C=0,F=0,L=!1,k=null,S=null,B=null,O=null,P=null,U=null,Y=0;if(a!==null&&!n)for(;(!h.done||!p.done||!y.done)&&(S=h.readValue(),k=r[p.readValue()],y.skipValues(1),S===null||!k||S0&&s!==null){for(C+=1;!b.done&&!v.done&&(O!==u||B!==s)&&(U&&(L=!1),Y===0&&!L&&(F+=1,L=!0),O=b.readValue(),B=r[v.readValue()],S=h.readValue(),k=r[p.readValue()],U=m.readValue(),Y=D.readValue(),S===a&&k===i);)C+=1;if(S!==a||k!==i||O!==u||B!==s||!U)return{found:!1,skipCount:C,visibleCount:F};if(U&&(L=!1),Y===0&&!L&&(F+=1,L=!0),b.done||v.done)return{found:!0,skipCount:C,visibleCount:F};O=b.readValue(),B=r[v.readValue()],S=h.readValue(),k=r[p.readValue()],U=m.readValue(),Y=D.readValue()}for(;(!U||O>d||O===d&&B>f)&&S===a&&k===i&&(C+=1,U&&(L=!1),Y===0&&!L&&(F+=1,L=!0),!b.done&&!v.done);)O=b.readValue(),B=r[v.readValue()],S=h.readValue(),k=r[p.readValue()],U=m.readValue(),Y=D.readValue()}else if(u!==null&&u>0&&s!==null){for(;(!U||O!==u||B!==s)&&S===a&&k===i&&(C+=1,U&&(L=!1),Y===0&&!L&&(F+=1,L=!0),!b.done&&!v.done);)O=b.readValue(),B=r[v.readValue()],S=h.readValue(),k=r[p.readValue()],U=m.readValue(),Y=D.readValue();if(S!==a||k!==i||O!==u||B!==s||!U)return{found:!1,skipCount:C,visibleCount:F}}return{found:!0,skipCount:C,visibleCount:F}}function SD(e,t,r,n){let i=e.blocks[t],a=e.blocks[t+1];return i.lastObjectActor!==r||i.lastObjectCtr!==n||i.numVisible===void 0?0:i.lastVisibleActor===a.firstVisibleActor&&i.lastVisibleActor!==void 0&&i.lastVisibleCtr===a.firstVisibleCtr&&i.lastVisibleCtr!==void 0?i.numVisible-1:i.numVisible}function PD(e,t){let{objActor:r,objActorNum:n,objCtr:i,keyActor:a,keyCtr:s,keyStr:u}=t,l=0,f=0;if(i!==null)for(;li)throw new RangeError(`Reference element not found: ${s}@${a}`);f+=SD(e,l,n,i),l++}let{found:h,skipCount:E,visibleCount:v}=FD(t,e.blocks[l].columns,e.actorIds,p);if(l===e.blocks.length-1||e.blocks[l].lastObjectActor!==n||e.blocks[l].lastObjectCtr!==i){if(h)return{blockIndex:l,skipCount:E,visibleCount:f+v};throw new RangeError(`Reference element not found: ${s}@${a}`)}else if(h&&E>>0)%n;for(let u=0;u<$D;u++)e[i>>>3]|=1<<(i&7),i=(i+a)%n,a=(a+s)%n}function OD(e,t,r){let n=8*e.byteLength,i=r%n,a=t%n,s=((r^t)*16777619>>>0)%n;for(let u=0;u<$D;u++){if(!(e[i>>>3]&1<<(i&7)))return!1;i=(i+a)%n,a=(a+s)%n}return!0}function TD(e){e.bloom=new Uint8Array(RD),e.numOps=0,e.lastKey=void 0,e.numVisible=void 0,e.lastObjectActor=void 0,e.lastObjectCtr=void 0,e.firstVisibleActor=void 0,e.firstVisibleCtr=void 0,e.lastVisibleActor=void 0,e.lastVisibleCtr=void 0;for(let d of e.columns)d.decoder.reset();let[t,r,n,i,a,s,u,l,,,,,,f]=e.columns.map(d=>d.decoder);for(;!u.done;){e.numOps+=1;let d=t.readValue(),g=r.readValue(),p=n.readValue(),h=i.readValue(),E=a.readValue(),v=s.readValue(),b=u.readValue(),m=l.readValue(),y=f.readValue();if((e.lastObjectActor!==d||e.lastObjectCtr!==g)&&(e.numVisible=0,e.lastObjectActor=d,e.lastObjectCtr=g),E!==null)e.lastKey=E;else if(m||h!==null){e.lastKey=void 0;let D=m?v:p,C=m?b:h;xD(e.bloom,D,C),y===0&&(e.firstVisibleActor===void 0&&(e.firstVisibleActor=D),e.firstVisibleCtr===void 0&&(e.firstVisibleCtr=C),(e.lastVisibleActor!==D||e.lastVisibleCtr!==C)&&(e.numVisible+=1,e.lastVisibleActor=D,e.lastVisibleCtr=C))}}}function f2(e,t,r,n){if(t[bt]!==null)e.lastObjectCtr===t[vr]&&e.lastObjectActor===t[Sr]&&(e.lastKey===void 0||e.lastKey({columnId:f.columnId,encoder:xc(f.columnId)}));Oc(s,e.columns,a);let l={columns:s.map(f=>{let d=A2(f.columnId,f.encoder.buffer);return{columnId:f.columnId,decoder:d}})};TD(l),r.push(l),n+=a}return r}function xH(e){let t=e[0].columns.map(r=>({columnId:r.columnId,encoder:xc(r.columnId)}));for(let r of e){for(let n of r.columns)n.decoder.reset();Oc(t,r.columns,r.numOps)}return t}function Oc(e,t,r){if(r===0)return;let n=0,i=-1,a=0,s=-1,u=0;for(let l of e){for(;n0&&(f=t[n].decoder);let d=l.columnId>>4===i?a:r;if(l.columnId%8===Cn.GROUP_CARD)i=l.columnId>>4,f?a=l.encoder.copyFrom(f,{count:r,sumValues:!0}).sum:(l.encoder.appendValue(0,r),a=0);else if(l.columnId%8===Cn.VALUE_LEN)if(f){if(n+1===t.length||t[n+1].columnId!==l.columnId+1)throw new RangeError("VALUE_LEN column without accompanying VALUE_RAW column");s=l.columnId+1,u=l.encoder.copyFrom(f,{count:d,sumValues:!0,sumShift:4}).sum}else l.encoder.appendValue(null,d),s=l.columnId+1,u=0;else if(l.columnId%8===Cn.VALUE_RAW){if(l.columnId!==s)throw new RangeError("VALUE_RAW column without accompanying VALUE_LEN column");u>0&&l.encoder.appendRawBytes(f.readRawBytes(u))}else if(f)l.encoder.copyFrom(f,{count:d});else{let g=l.columnId%8===Cn.BOOLEAN?!1:null;l.encoder.appendValue(g,d)}}}function g2(e,t){let r=[],n,i=-1,a=0,s=-1,u=0;for(let l of e){if(l.columnId%8===Cn.VALUE_RAW){if(l.columnId!==s)throw new RangeError("unexpected VALUE_RAW column");n=l.decoder.readRawBytes(u)}else if(l.columnId%8===Cn.GROUP_CARD)i=l.columnId>>4,a=l.decoder.readValue()||0,n=a;else if(l.columnId>>4===i){n=[],l.columnId%8===Cn.VALUE_LEN&&(s=l.columnId+1,u=0);for(let f=0;f>>4),n.push(d)}}else n=l.decoder.readValue(),l.columnId%8===Cn.ACTOR_ID&&t&&typeof n=="number"&&(n=t[n]),l.columnId%8===Cn.VALUE_LEN&&(s=l.columnId+1,u=n>>>4);r.push(n)}return r}function gp(e,t,r){let n=0,i=-1,a=0;for(let s of e){for(;n>4,a=u,s.encoder.appendValue(u);else if(s.columnId>>4===i){if(!Array.isArray(u)||u.length!==a)throw new RangeError("bad group value");for(let l of u)s.encoder.appendValue(l)}else s.columnId%8===Cn.VALUE_RAW?u&&s.encoder.appendRawBytes(u):s.encoder.appendValue(u)}else if(s.columnId%8===Cn.GROUP_CARD)i=s.columnId>>4,a=0,s.encoder.appendValue(0);else if(s.columnId%8!==Cn.VALUE_RAW){let u=s.columnId>>4===i?a:1,l=null;s.columnId%8===Cn.BOOLEAN&&(l=!1),s.columnId%8===Cn.VALUE_LEN&&(l=0),s.encoder.appendValue(l,u)}}}function m2(e,t){let r=e.blocks[t];if(r.columns[jr].decoder.done){if(t===e.blocks.length-1)return{docOp:null,blockIndex:t};t+=1,r=e.blocks[t];for(let n of r.columns)n.decoder.reset();return{docOp:g2(r.columns),blockIndex:t}}else return{docOp:g2(r.columns),blockIndex:t}}function ND(e,t){for(;t.changeIndexe.maxOp&&(e.maxOp=t.opCtr),t.opCtr+=1;let r=t.nextOp;if(r[vr]===null&&r[Sr]!==null||r[vr]!==null&&r[Sr]===null)throw new RangeError(`Mismatched object reference: (${r[vr]}, ${r[Sr]})`);if(r[_n]===null&&r[bn]!==null||r[_n]===0&&r[bn]!==null||r[_n]>0&&r[bn]===null)throw new RangeError(`Mismatched operation key: (${r[_n]}, ${r[bn]})`)}function Pc(e,t){return t==="list"||t==="text"?{objectId:e,type:t,edits:[]}:{objectId:e,type:t,props:{}}}function ID(e,t,r=1){let n=mp(e),i=mp(t);return n.actorId===i.actorId&&n.counter+r===i.counter}function vh(e,t){if(e.length===0){e.push(t);return}let r=e[e.length-1];r.action==="insert"&&t.action==="insert"&&r.index===t.index-1&&r.value.type==="value"&&t.value.type==="value"&&r.elemId===r.opId&&t.elemId===t.opId&&ID(r.elemId,t.elemId,1)&&r.value.datatype===t.value.datatype&&typeof r.value.value==typeof t.value.value?(r.action="multi-insert",t.value.datatype&&(r.datatype=t.value.datatype),r.values=[r.value.value,t.value.value],delete r.value,delete r.opId):r.action==="multi-insert"&&t.action==="insert"&&r.index+r.values.length===t.index&&t.value.type==="value"&&t.elemId===t.opId&&ID(r.elemId,t.elemId,r.values.length)&&r.datatype===t.value.datatype&&typeof r.values[0]==typeof t.value.value?r.values.push(t.value.value):r.action==="remove"&&t.action==="remove"&&r.index===t.index?r.count+=t.count:e.push(t)}function v2(e,t,r,n,i,a){let s=!1;if(a)for(;!s&&e.length>0;){let u=e[e.length-1];if((u.action==="insert"||u.action==="update")&&u.index===t)e.pop(),s=u.action==="insert";else if(u.action==="multi-insert"&&u.index+u.values.length-1===t)u.values.pop(),s=!0;else break}s?vh(e,{action:"insert",index:t,elemId:r,opId:n,value:i}):vh(e,{action:"update",index:t,opId:n,value:i})}function OH(e,t,r){let n=[];for(;e.length>0;){let a=e[e.length-1];if(a.action==="insert"){if(a.index!==t)throw new RangeError("last edit has unexpected index");n.unshift(e.pop());break}else if(a.action==="update"){if(a.index!==t)throw new RangeError("last edit has unexpected index");n.unshift(e.pop())}else throw new RangeError("last edit has unexpected action")}let i=!0;for(let a of n)v2(e,t,r,a.opId,a.value,i),i=!1}function E2(e,t,r,n,i,a,s,u){let l=!t,f=n[jr]0;v||(a[h].visibleOps.push(n),a[h].hasChild=a[h].hasChild||n[jr]%2===0);let b=i.objectMeta[r].children[h];if(a[h].hasChild||b&&Object.keys(b).length>0){let C={};for(let F of a[h].visibleOps){let L=`${F[cr]}@${i.actorIds[F[kn]]}`;if(vu[F[jr]]==="set")C[L]=Object.assign({type:"value"},pp(F[Qu],F[sl]));else if(F[jr]%2===0){let k=F[jr]1?C.count-=1:D.edits.pop(),a[h].action="update",v2(D.edits,s,h,m,y,!0),t&&t.lastObjectActor===n[Sr]&&t.lastObjectCtr===n[vr]&&(t.numVisible+=1)}else v2(D.edits,s,h,m,y,!a[h].action),a[h].action||(a[h].action="update");else u===0&&!a[h].action&&(a[h].action="remove",vh(D.edits,{action:"remove",index:s,count:1}),t&&t.lastObjectActor===n[Sr]&&t.lastObjectCtr===n[vr]&&(t.numVisible-=1));else(y||!l)&&((E||!D.props[n[bt]])&&(D.props[n[bt]]={}),y&&(D.props[n[bt]][m]=y))}function TH(e,t,r,n,i,a,s){let u=n.nextOp,l=u[Nn],f=u[Sr],d=u[vr],g=f===null?"_root":`${d}@${i.actorIds[f]}`,p=n.actorIndex,h=i.actorIds[p],E=!1,v=!1,b={},m;({docOp:m,blockIndex:s}=m2(i,s));let y=m===null?0:1,D=m===null?0:m[$s],C=null,F=[],L=[],k=[],S=null;for(n.objectIds.add(g);;){if(F.length===0){E=!1;let H=n.nextOp;for(;!n.done&&H[kn]===p&&H[Nn]===l&&H[Sr]===u[Sr]&&H[vr]===u[vr];){let K=F.length>0?F[F.length-1]:null,W=!1;for(let ie=0;ie0&&(C=F[0]);let B=m&&m[Sr]===C[Sr]&&m[vr]===C[vr],O=m&&m[bt]!==null&&m[bt]===C[bt],P=m&&m[bt]===null&&C[bt]===null&&(!m[Nn]&&m[bn]===C[bn]&&m[_n]===C[_n]||m[Nn]&&m[kn]===C[bn]&&m[cr]===C[_n]);if(F.length===0&&!(B&&(O||P)))break;let U=!1,Y=0;if(l||!B||m[bt]===null&&C[bt]!==null||m[bt]!==null&&C[bt]!==null&&C[bt]=0;H--){let K=!0;for(let W=0;W0){for(let H=0;H({columnId:B.columnId,encoder:xc(B.columnId)}));Oc(C,m.columns,v);let{blockIndex:F,docOpsConsumed:L}=TH(e,D,C,t,r,b,E),k=r.blocks[F],S=-v-L;for(let B=E;B<=F;B++)S+=r.blocks[B].numOps;Oc(C,k.columns,S),D.numOps+=S;for(let B of k.columns)if(!B.decoder.done)throw new RangeError(`excess ops in column ${B.columnId}`);if(D.columns=C.map(B=>{let O=A2(B.columnId,B.encoder.buffer);return{columnId:B.columnId,decoder:O}}),E===F&&D.numOps<=Eh)S>0&&m.lastVisibleActor!==void 0&&m.lastVisibleCtr!==void 0&&(D.lastVisibleActor=m.lastVisibleActor,D.lastVisibleCtr=m.lastVisibleCtr),r.blocks[E]=D;else{let B=kD(D);r.blocks.splice(E,F-E+1,...B)}}function NH(e,t){if(t[Sr].columnId!==Kt[Sr].columnId||Kt[Sr].columnName!=="objActor"||t[vr].columnId!==Kt[vr].columnId||Kt[vr].columnName!=="objCtr"||t[bn].columnId!==Kt[bn].columnId||Kt[bn].columnName!=="keyActor"||t[_n].columnId!==Kt[_n].columnId||Kt[_n].columnName!=="keyCtr"||t[bt].columnId!==Kt[bt].columnId||Kt[bt].columnName!=="keyStr"||t[kn].columnId!==Kt[kn].columnId||Kt[kn].columnName!=="idActor"||t[cr].columnId!==Kt[cr].columnId||Kt[cr].columnName!=="idCtr"||t[Nn].columnId!==Kt[Nn].columnId||Kt[Nn].columnName!=="insert"||t[jr].columnId!==Kt[jr].columnId||Kt[jr].columnName!=="action"||t[Qu].columnId!==Kt[Qu].columnId||Kt[Qu].columnName!=="valLen"||t[sl].columnId!==Kt[sl].columnId||Kt[sl].columnName!=="valRaw"||t[eo].columnId!==Kt[eo].columnId||Kt[eo].columnName!=="predNum"||t[Bc].columnId!==Kt[Bc].columnId||Kt[Bc].columnName!=="predActor"||t[$c].columnId!==Kt[$c].columnId||Kt[$c].columnName!=="predCtr")throw new RangeError("unexpected columnId");let r=e.blocks[0].columns;if(!t.every(n=>DD.includes(n.columnId)||r.find(i=>i.columnId===n.columnId))){let n=r.map(i=>({columnId:i.columnId}));for(let i of t){let{columnId:a}=i;!DD.includes(a)&&!r.find(s=>s.columnId===a)&&n.push({columnId:a})}n.sort((i,a)=>i.columnId-a.columnId);for(let i=0;i({columnId:s.columnId,buffer:s.decoder.buf})),n),e.blocks[i]=a}}}function LH(e,t){if(e.indexOf(t.actorIds[0])<0){if(t.seq!==1)throw new RangeError(`Seq ${t.seq} is the first change for actor ${t.actorIds[0]}`);e=e.concat([t.actorIds[0]])}let r=[];for(let n of t.actorIds){let i=e.indexOf(n);if(i<0)throw new RangeError(`actorId ${n} is not known to document`);r.push(i)}return{actorIds:e,actorTable:r}}function UH(e,t,r){for(let n of t){let i=r.objectMeta[n],a=null,s=!1;for(;;){let u=a&&Object.keys(i.children[a.parentKey]).length>0;if(e[n]||(e[n]=Pc(n,i.type)),a&&u)if(i.type==="list"||i.type==="text"){for(let l of e[n].edits)l.opId&&i.children[a.parentKey][l.opId]&&(s=!0);if(!s){let l=mp(n),f=mp(a.parentKey),d={objActor:l.actorId,objCtr:l.counter,keyActor:f.actorId,keyCtr:f.counter,objActorNum:r.actorIds.indexOf(l.actorId),keyActorNum:r.actorIds.indexOf(f.actorId),keyStr:null,insert:!1,objId:n},{visibleCount:g}=PD(r,d);for(let[p,h]of Object.entries(i.children[a.parentKey])){let E=h;h.objectId&&(e[h.objectId]||(e[h.objectId]=Pc(h.objectId,h.type)),E=e[h.objectId]);let v={action:"update",index:g,opId:p,value:E};vh(e[n].edits,v)}}}else{e[n].props[a.parentKey]||(e[n].props[a.parentKey]={});let l=e[n].props[a.parentKey];for(let[f,d]of Object.entries(i.children[a.parentKey]))l[f]?s=!0:d.objectId?(e[d.objectId]||(e[d.objectId]=Pc(d.objectId,d.type)),l[f]=e[d.objectId]):l[f]=d}if(s||!i.parentObj||a&&!u)break;a=i,n=i.parentObj,i=r.objectMeta[n]}}return e}function jH(e,t,r,n,i){let a=new Set(r.heads),s=new Set,u=vp(r.clock),l=[],f=[];for(let d of t){if(r.changeIndexByHash[d.hash]!==void 0||s.has(d.hash))continue;let g=(u[d.actor]||0)+1,p=!0;for(let h of d.deps){let E=r.changeIndexByHash[h];(E===void 0||E===-1)&&!s.has(h)&&(p=!1)}if(!p)f.push(d);else if(d.seqg)throw new RangeError(`Skipped sequence number ${g} for actor ${d.actor}`);u[d.actor]=d.seq,s.add(d.hash);for(let h of d.deps)a.delete(h);a.add(d.hash),l.push(d)}}if(l.length>0){let d={changes:l,changeIndex:-1,objectIds:n};for(ND(r,d);!d.done;)kH(e,d,r);r.heads=[...a].sort(),r.clock=u}return[l,f]}function BD(e){for(let d of e.blocks[0].columns)d.decoder.reset();let t={},r=null,n=0,i={_root:{objectId:"_root",type:"map",props:{}}},a=null,s=null,u="_root",l=!1,f=0;for(;{docOp:r,blockIndex:n}=m2(e,n),r!==null;){(r[Sr]!==a||r[vr]!==s)&&(u=`${r[vr]}@${e.actorIds[r[Sr]]}`,a=r[Sr],s=r[vr],t={},f=0,l=!1),r[Nn]&&l&&(l=!1,f++),r[$s]===0&&(l=!0),r[cr]>e.maxOp&&(e.maxOp=r[cr]);for(let d=0;de.maxOp&&(e.maxOp=r[Rc][d]);E2(i,null,u,r,e,t,f,r[$s])}return i._root}function HH(e){let t=mh(e.changesColumns,Bs),r=t[0].decoder,n=t[1].decoder,i=t[5].decoder,a=t[6].decoder;if(t[0].columnId!==Bs[0].columnId||Bs[0].columnName!=="actor"||t[1].columnId!==Bs[1].columnId||Bs[1].columnName!=="seq"||t[5].columnId!==Bs[5].columnId||Bs[5].columnName!=="depsNum"||t[6].columnId!==Bs[6].columnId||Bs[6].columnName!=="depsIndex")throw new RangeError("unexpected columnId");let s=0,u={},l=[],f=new Set;for(;!r.done;){let p=r.readValue(),h=n.readValue(),E=i.readValue(),v=e.actorIds[p];if(h!==1&&h!==u[v]+1)throw new RangeError(`Expected seq ${u[v]+1}, got ${h} for actor ${v}`);l.push(p),u[v]=h,f.add(s);for(let b=0;be.actorIds[l[p]]).sort();for(let p of t)p.decoder.reset();let g=t.map(p=>({columnId:p.columnId,encoder:xc(p.columnId)}));return Oc(g,t,s),{clock:u,headActors:d,encoders:g,numChanges:s}}function MH(e,t,r,n){gp(e,Bs,[r.indexOf(t.actor),t.seq,t.maxOp,t.time,t.message,t.deps.length,t.deps.map(i=>n[i]),t.extraBytes?t.extraBytes.byteLength<<4|h2.BYTES:h2.BYTES,t.extraBytes])}var w2=class e{constructor(t){if(this.maxOp=0,this.haveHashGraph=!1,this.changes=[],this.changeIndexByHash={},this.dependenciesByHash={},this.dependentsByHash={},this.hashesByActor={},this.actorIds=[],this.heads=[],this.clock={},this.queue=[],this.objectMeta={_root:{parentObj:null,parentKey:null,opId:null,type:"map",children:{}}},t){let r=$H(t),{clock:n,headActors:i,encoders:a,numChanges:s}=HH(r);if(this.binaryDoc=t,this.changes=new Array(s),this.actorIds=r.actorIds,this.heads=r.heads,this.clock=n,this.changesEncoders=a,this.extraBytes=r.extraBytes,r.heads.length===1&&i.length===1&&(this.hashesByActor[i[0]]=[],this.hashesByActor[i[0]][n[i[0]]-1]=r.heads[0]),r.heads.length===r.headsIndexes.length)for(let l=0;lEh&&(this.blocks=kD(this.blocks[0]));let u={blocks:this.blocks,actorIds:this.actorIds,objectMeta:this.objectMeta,maxOp:0};this.initPatch=BD(u),this.maxOp=u.maxOp}else this.haveHashGraph=!0,this.changesEncoders=Bs.map(r=>({columnId:r.columnId,encoder:xc(r.columnId)})),this.blocks=[{columns:mh([],CD),bloom:new Uint8Array(RD),numOps:0,lastKey:void 0,numVisible:void 0,lastObjectActor:void 0,lastObjectCtr:void 0,firstVisibleActor:void 0,firstVisibleCtr:void 0,lastVisibleActor:void 0,lastVisibleCtr:void 0}]}clone(){let t=new e;return t.maxOp=this.maxOp,t.haveHashGraph=this.haveHashGraph,t.changes=this.changes.slice(),t.changeIndexByHash=vp(this.changeIndexByHash),t.dependenciesByHash=vp(this.dependenciesByHash),t.dependentsByHash=Object.entries(this.dependentsByHash).reduce((r,[n,i])=>(r[n]=i.slice(),r),{}),t.hashesByActor=Object.entries(this.hashesByActor).reduce((r,[n,i])=>(r[n]=i.slice(),r),{}),t.actorIds=this.actorIds,t.heads=this.heads,t.clock=this.clock,t.blocks=this.blocks,t.objectMeta=this.objectMeta,t.queue=this.queue,t}applyChanges(t,r=!1){let n=t.map(d=>{let g=SH(d);return g.buffer=d,g}),i={_root:{objectId:"_root",type:"map",props:{}}},a={maxOp:this.maxOp,changeIndexByHash:this.changeIndexByHash,actorIds:this.actorIds,heads:this.heads,clock:this.clock,blocks:this.blocks.slice(),objectMeta:Object.assign({},this.objectMeta)},s=this.queue.length===0?n:n.concat(this.queue),u=[],l=new Set;for(;;){let[d,g]=jH(i,s,a,l,this.haveHashGraph);s=g;for(let p=0;p0&&(u=u.concat(d)),s.length===0)break;if(d.length===0){if(this.haveHashGraph)break;this.computeHashGraph(),a.changeIndexByHash=this.changeIndexByHash}}UH(i,l,a);for(let d of u){this.changes.push(d.buffer),this.hashesByActor[d.actor]||(this.hashesByActor[d.actor]=[]),this.hashesByActor[d.actor][d.seq-1]=d.hash,this.changeIndexByHash[d.hash]=this.changes.length-1,this.dependenciesByHash[d.hash]=d.deps,this.dependentsByHash[d.hash]=[];for(let g of d.deps)this.dependentsByHash[g]||(this.dependentsByHash[g]=[]),this.dependentsByHash[g].push(d.hash);MH(this.changesEncoders,d,a.actorIds,this.changeIndexByHash)}this.maxOp=a.maxOp,this.actorIds=a.actorIds,this.heads=a.heads,this.clock=a.clock,this.blocks=a.blocks,this.objectMeta=a.objectMeta,this.queue=s,this.binaryDoc=null,this.initPatch=null;let f={maxOp:this.maxOp,clock:this.clock,deps:this.heads,pendingChanges:this.queue.length,diffs:i._root};return r&&n.length===1&&(f.actor=n[0].actor,f.seq=n[0].seq),f}computeHashGraph(){let t=this.save();this.haveHashGraph=!0,this.changes=[],this.changeIndexByHash={},this.dependenciesByHash={},this.dependentsByHash={},this.hashesByActor={},this.clock={};for(let r of BH([t])){let n=FH(r);this.changes.push(n),this.changeIndexByHash[r.hash]=this.changes.length-1,this.dependenciesByHash[r.hash]=r.deps,this.dependentsByHash[r.hash]=[];for(let a of r.deps)this.dependentsByHash[a].push(r.hash);r.seq===1&&(this.hashesByActor[r.actor]=[]),this.hashesByActor[r.actor].push(r.hash);let i=(this.clock[r.actor]||0)+1;if(r.seq!==i)throw new RangeError(`Expected seq ${i}, got seq ${r.seq} from actor ${r.actor}`);this.clock[r.actor]=r.seq}}getChanges(t){if(this.haveHashGraph||this.computeHashGraph(),t.length===0)return this.changes.slice();let r=[],n={},i=[];for(let a of t){n[a]=!0;let s=this.dependentsByHash[a];if(!s)throw new RangeError(`hash not found: ${a}`);r.push(...s)}for(;r.length>0;){let a=r.pop();if(n[a]=!0,i.push(a),!this.dependenciesByHash[a].every(s=>n[s]))break;r.push(...this.dependentsByHash[a])}if(r.length===0&&this.heads.every(a=>n[a]))return i.map(a=>this.changes[this.changeIndexByHash[a]]);for(r=t.slice(),n={};r.length>0;){let a=r.pop();if(!n[a]){let s=this.dependenciesByHash[a];if(!s)throw new RangeError(`hash not found: ${a}`);r.push(...s),n[a]=!0}}return this.changes.filter(a=>!n[IH(a,!0).hash])}getChangesAdded(t){this.haveHashGraph||this.computeHashGraph();let r=this.heads.slice(),n={},i=[];for(;r.length>0;){let a=r.pop();!n[a]&&t.changeIndexByHash[a]===void 0&&(n[a]=!0,i.push(a),r.push(...this.dependenciesByHash[a]))}return i.reverse().map(a=>this.changes[this.changeIndexByHash[a]])}getChangeByHash(t){return this.haveHashGraph||this.computeHashGraph(),this.changes[this.changeIndexByHash[t]]}getMissingDeps(t=[]){this.haveHashGraph||this.computeHashGraph();let r=new Set(t),n=new Set;for(let a of this.queue){n.add(a.hash);for(let s of a.deps)r.add(s)}let i=[];for(let a of r)this.changeIndexByHash[a]===void 0&&!n.has(a)&&i.push(a);return i.sort()}save(){if(this.binaryDoc)return this.binaryDoc;let t=this.changesEncoders.map(n=>({columnId:n.columnId,encoder:xc(n.columnId)})),r=this.changesEncoders.map(n=>{let i=A2(n.columnId,n.encoder.buffer);return{columnId:n.columnId,decoder:i}});return Oc(t,r,this.changes.length),this.binaryDoc=RH({changesColumns:this.changesEncoders,opsColumns:xH(this.blocks),actorIds:this.actorIds,heads:this.heads,headsIndexes:this.heads.map(n=>this.changeIndexByHash[n]),extraBytes:this.extraBytes}),this.changesEncoders=t,this.binaryDoc}getPatch(){let t={_root:{parentObj:null,parentKey:null,opId:null,type:"map",children:{}}},r={blocks:this.blocks,actorIds:this.actorIds,objectMeta:t,maxOp:0},n=this.initPatch?this.initPatch:BD(r);return{maxOp:this.maxOp,clock:this.clock,deps:this.heads,pendingChanges:this.queue.length,diffs:n}}};LD.exports={MAX_BLOCK_SIZE:Eh,BackendDoc:w2,bloomFilterContains:OD}});var HD=le((dX,jD)=>{function qH(e){if(e.frozen)throw new Error("Attempting to use an outdated Automerge document that has already been updated. Please use the latest document state, or call Automerge.clone() if you really need to use this old document state.");return e.state}jD.exports={backendState:qH}});var y2=le((pX,KD)=>{var{encodeChange:VH}=gh(),{BackendDoc:qD}=UD(),{backendState:Rs}=HD();function KH(){return{state:new qD,heads:[]}}function zH(e){return{state:Rs(e).clone(),heads:e.heads}}function GH(e){e.state=null,e.frozen=!0}function YH(e,t){let r=Rs(e),n=r.applyChanges(t);return e.frozen=!0,[{state:r,heads:r.heads},n]}function MD(e,t,r){if(e.hashesByActor[t]&&e.hashesByActor[t][r]||!e.haveHashGraph&&(e.computeHashGraph(),e.hashesByActor[t]&&e.hashesByActor[t][r]))return e.hashesByActor[t][r];throw new RangeError(`Unknown change: actorId = ${t}, seq = ${r+1}`)}function WH(e,t){let r=Rs(e);if(t.seq<=r.clock[t.actor])throw new RangeError("Change request has already been applied");if(t.seq>1){let s=MD(r,t.actor,t.seq-2);if(!s)throw new RangeError(`Cannot find hash of localChange before seq=${t.seq}`);let u={[s]:!0};for(let l of t.deps)u[l]=!0;t.deps=Object.keys(u).sort()}let n=VH(t),i=r.applyChanges([n],!0);e.frozen=!0;let a=MD(r,t.actor,t.seq-1);return i.deps=i.deps.filter(s=>s!==a),[{state:r,heads:r.heads},i,n]}function XH(e){return Rs(e).save()}function JH(e){let t=new qD(e);return{state:t,heads:t.heads}}function ZH(e,t){let r=Rs(e);return r.applyChanges(t),e.frozen=!0,{state:r,heads:r.heads}}function QH(e){return Rs(e).getPatch()}function eM(e){return e.heads}function tM(e){return VD(e,[])}function VD(e,t){if(!Array.isArray(t))throw new TypeError("Pass an array of hashes to Backend.getChanges()");return Rs(e).getChanges(t)}function rM(e,t){return Rs(t).getChangesAdded(Rs(e))}function nM(e,t){return Rs(e).getChangeByHash(t)}function iM(e,t=[]){return Rs(e).getMissingDeps(t)}KD.exports={init:KH,clone:zH,free:GH,applyChanges:YH,applyLocalChange:WH,save:XH,load:JH,loadChanges:ZH,getPatch:QH,getHeads:eM,getAllChanges:tM,getChanges:VD,getChangesAdded:rM,getChangeByHash:nM,getMissingDeps:iM}});var QD=le((gX,ZD)=>{var Ps=y2(),{hexStringToBytes:zD,bytesToHexString:sM,Encoder:C2,Decoder:D2}=r2(),{decodeChangeMeta:Ap}=gh(),{copyObject:aM}=Ss(),GD=32,YD=66,WD=67,uM=10,oM=7,wh=class{constructor(t){if(Array.isArray(t)){this.numEntries=t.length,this.numBitsPerEntry=uM,this.numProbes=oM,this.bits=new Uint8Array(Math.ceil(this.numEntries*this.numBitsPerEntry/8));for(let r of t)this.addHash(r)}else if(t instanceof Uint8Array)if(t.byteLength===0)this.numEntries=0,this.numBitsPerEntry=0,this.numProbes=0,this.bits=t;else{let r=new D2(t);this.numEntries=r.readUint32(),this.numBitsPerEntry=r.readUint32(),this.numProbes=r.readUint32(),this.bits=r.readRawBytes(Math.ceil(this.numEntries*this.numBitsPerEntry/8))}else throw new TypeError("invalid argument")}get bytes(){if(this.numEntries===0)return new Uint8Array(0);let t=new C2;return t.appendUint32(this.numEntries),t.appendUint32(this.numBitsPerEntry),t.appendUint32(this.numProbes),t.appendRawBytes(this.bits),t.buffer}getProbes(t){let r=zD(t),n=8*this.bits.byteLength;if(r.byteLength!==32)throw new RangeError(`Not a 256-bit hash: ${t}`);let i=((r[0]|r[1]<<8|r[2]<<16|r[3]<<24)>>>0)%n,a=((r[4]|r[5]<<8|r[6]<<16|r[7]<<24)>>>0)%n,s=((r[8]|r[9]<<8|r[10]<<16|r[11]<<24)>>>0)%n,u=[i];for(let l=1;l>>3]|=1<<(r&7)}containsHash(t){if(this.numEntries===0)return!1;for(let r of this.getProbes(t))if(!(this.bits[r>>>3]&1<<(r&7)))return!1;return!0}};function Ep(e,t){if(!Array.isArray(t))throw new TypeError("hashes must be an array");e.appendUint32(t.length);for(let r=0;r0&&t[r-1]>=t[r])throw new RangeError("hashes must be sorted");let n=zD(t[r]);if(n.byteLength!==GD)throw new TypeError("heads hashes must be 256 bits");e.appendRawBytes(n)}}function wp(e){let t=e.readUint32(),r=[];for(let n=0;nAp(i,!0).hash);return{lastSync:t,bloom:new wh(n).bytes}}function hM(e,t,r){if(t.length===0)return r.map(g=>Ps.getChangeByHash(e,g)).filter(g=>g!==void 0);let n={},i=[];for(let g of t){for(let p of g.lastSync)n[p]=!0;i.push(new wh(g.bloom))}let a=Ps.getChanges(e,Object.keys(n)).map(g=>Ap(g,!0)),s={},u={},l={};for(let g of a){s[g.hash]=!0;for(let p of g.deps)u[p]||(u[p]=[]),u[p].push(g.hash);i.every(p=>!p.containsHash(g.hash))&&(l[g.hash]=!0)}let f=Object.keys(l);for(;f.length>0;){let g=f.pop();if(u[g])for(let p of u[g])l[p]||(l[p]=!0,f.push(p))}let d=[];for(let g of r)if(l[g]=!0,!s[g]){let p=Ps.getChangeByHash(e,g);p&&d.push(p)}for(let g of a)l[g.hash]&&d.push(g.change);return d}function JD(){return{sharedHeads:[],lastSentHeads:[],theirHeads:null,theirNeed:null,theirHave:null,sentHashes:{}}}function _2(e,t){return e.length===t.length&&e.every((r,n)=>r===t[n])}function dM(e,t){if(!e)throw new Error("generateSyncMessage called with no Automerge document");if(!t)throw new Error("generateSyncMessage requires a syncState, which can be created with initSyncState()");let{sharedHeads:r,lastSentHeads:n,theirHeads:i,theirNeed:a,theirHave:s,sentHashes:u}=t,l=Ps.getHeads(e),f=Ps.getMissingDeps(e,i||[]),d=[];if((!i||f.every(v=>i.includes(v)))&&(d=[fM(e,r)]),s&&s.length>0&&!s[0].lastSync.every(b=>Ps.getChangeByHash(e,b))){let b={heads:l,need:[],have:[{lastSync:[],bloom:new Uint8Array(0)}],changes:[]};return[t,b2(b)]}let g=Array.isArray(s)&&Array.isArray(a)?hM(e,s,a):[],p=Array.isArray(n)&&_2(l,n),h=Array.isArray(i)&&_2(l,i);if(p&&h&&g.length===0)return[t,null];g=g.filter(v=>!u[Ap(v,!0).hash]);let E={heads:l,have:d,need:f,changes:g};if(g.length>0){u=aM(u);for(let v of g)u[Ap(v,!0).hash]=!0}return t=Object.assign({},t,{lastSentHeads:l,sentHashes:u}),[t,b2(E)]}function pM(e,t,r){let n=t.filter(s=>!e.includes(s)),i=r.filter(s=>t.includes(s));return[...new Set([...n,...i])].sort()}function gM(e,t,r){if(!e)throw new Error("generateSyncMessage called with no Automerge document");if(!t)throw new Error("generateSyncMessage requires a syncState, which can be created with initSyncState()");let{sharedHeads:n,lastSentHeads:i,sentHashes:a}=t,s=null,u=XD(r),l=Ps.getHeads(e);u.changes.length>0&&([e,s]=Ps.applyChanges(e,u.changes),n=pM(l,Ps.getHeads(e),n)),u.changes.length===0&&_2(u.heads,l)&&(i=u.heads);let f=u.heads.filter(g=>Ps.getChangeByHash(e,g));f.length===u.heads.length?(n=u.heads,u.heads.length===0&&(i=[],a=[])):n=[...new Set(f.concat(n))].sort();let d={sharedHeads:n,lastSentHeads:i,theirHave:u.have,theirHeads:u.heads,theirNeed:u.need,sentHashes:a};return[e,d,s]}ZD.exports={receiveSyncMessage:gM,generateSyncMessage:dM,encodeSyncMessage:b2,decodeSyncMessage:XD,initSyncState:JD,encodeSyncState:lM,decodeSyncState:cM,BloomFilter:wh}});var t3=le((mX,e3)=>{var{init:mM,clone:vM,free:EM,applyChanges:wM,applyLocalChange:AM,save:yM,load:bM,loadChanges:_M,getPatch:CM,getHeads:DM,getAllChanges:FM,getChanges:SM,getChangesAdded:IM,getChangeByHash:BM,getMissingDeps:$M}=y2(),{receiveSyncMessage:RM,generateSyncMessage:PM,encodeSyncMessage:xM,decodeSyncMessage:OM,encodeSyncState:TM,decodeSyncState:kM,initSyncState:NM}=QD();e3.exports={init:mM,clone:vM,free:EM,applyChanges:wM,applyLocalChange:AM,save:yM,load:bM,loadChanges:_M,getPatch:CM,getHeads:DM,getAllChanges:FM,getChanges:SM,getChangesAdded:IM,getChangeByHash:BM,getMissingDeps:$M,receiveSyncMessage:RM,generateSyncMessage:PM,encodeSyncMessage:xM,decodeSyncMessage:OM,encodeSyncState:TM,decodeSyncState:kM,initSyncState:NM}});var o3=le((vX,S2)=>{var LM=Ld(),Gr=f6(),{OPTIONS:r3}=fu(),{encodeChange:UM,decodeChange:n3}=gh(),{isObject:F2}=Ss(),xr=t3();function Ah(e){if(typeof e=="string")e={actorId:e};else if(typeof e>"u")e={};else if(!F2(e))throw new TypeError(`Unsupported options for init(): ${e}`);return Gr.init(Object.assign({backend:xr},e))}function jM(e,t){let r={message:"Initialization"};return i3(Ah(t),r,n=>Object.assign(n,e))}function i3(e,t,r){let[n]=Gr.change(e,t,r);return n}function HM(e,t){let[r]=Gr.emptyChange(e,t);return r}function MM(e,t={}){let r=xr.clone(Gr.getBackendState(e,"clone"));return yp(Ah(t),xr.getPatch(r),r,[],t)}function qM(e){xr.free(Gr.getBackendState(e,"free"))}function VM(e,t={}){let r=xr.load(e);return yp(Ah(t),xr.getPatch(r),r,[e],t)}function KM(e){return xr.save(Gr.getBackendState(e,"save"))}function zM(e,t){let r=Gr.getBackendState(e,"merge"),n=Gr.getBackendState(t,"merge","second"),i=xr.getChangesAdded(r,n),[a]=a3(e,i);return a}function GM(e,t){let r=Gr.getBackendState(e,"getChanges"),n=Gr.getBackendState(t,"getChanges","second");return xr.getChanges(n,xr.getHeads(r))}function s3(e){return xr.getAllChanges(Gr.getBackendState(e,"getAllChanges"))}function yp(e,t,r,n,i){let a=Gr.applyPatch(e,t,r),s=i.patchCallback||e[r3].patchCallback;return s&&s(t,e,a,!1,n),a}function a3(e,t,r={}){let n=Gr.getBackendState(e,"applyChanges"),[i,a]=xr.applyChanges(n,t);return[yp(e,a,i,t,r),a]}function u3(e,t){if(!F2(e)||!F2(t))return e===t;let r=Object.keys(e).sort(),n=Object.keys(t).sort();if(r.length!==n.length)return!1;for(let i=0;i({get change(){return n3(n)},get snapshot(){let a=xr.loadChanges(xr.init(),r.slice(0,i+1));return Gr.applyPatch(Ah(t),xr.getPatch(a),a)}}))}function WM(e,t){let r=Gr.getBackendState(e,"generateSyncMessage");return xr.generateSyncMessage(r,t)}function XM(e,t,r){let n=Gr.getBackendState(e,"receiveSyncMessage"),[i,a,s]=xr.receiveSyncMessage(n,t,r);if(!s)return[e,a,s];let u=null;return e[r3].patchCallback&&(u=xr.decodeSyncMessage(r).changes),[yp(e,s,i,u,{}),a,s]}function JM(){return xr.initSyncState()}function ZM(e){xr=e}S2.exports={init:Ah,from:jM,change:i3,emptyChange:HM,clone:MM,free:qM,load:VM,save:KM,merge:zM,getChanges:GM,getAllChanges:s3,applyChanges:a3,encodeChange:UM,decodeChange:n3,equals:u3,getHistory:YM,uuid:LM,Frontend:Gr,setDefaultBackend:ZM,generateSyncMessage:WM,receiveSyncMessage:XM,initSyncState:JM,get Backend(){return xr}};for(let e of["getObjectId","getObjectById","getActorId","setActorId","getConflicts","getLastLocalChange","Text","Table","Counter","Observable","Int","Uint","Float64"])S2.exports[e]=Gr[e]});var Fp=le((rJ,p3)=>{"use strict";var $q=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])},R2=class e extends Error{constructor(t,r,n){super(t),$q(this,e.prototype),this.name="GrammarError",this.location=r,n===void 0&&(n=[]),this.diagnostics=n,this.stage=null,this.problems=[["error",t,r,n]]}toString(){let t=super.toString();this.location&&(t+=` at `,this.location.source!==void 0&&this.location.source!==null&&(t+=`${this.location.source}:`),t+=`${this.location.start.line}:${this.location.start.column}`);for(let r of this.diagnostics)t+=` from `,r.location.source!==void 0&&r.location.source!==null&&(t+=`${r.location.source}:`),t+=`${r.location.start.line}:${r.location.start.column}: ${r.message}`;return t}format(t){let r=t.map(({source:a,text:s})=>({source:a,text:s.split(/\r\n|\n|\r/g)}));function n(a,s,u=""){let l="",f=r.find(({source:g})=>g===a.source),d=a.start;if(f){let g=a.end,p=f.text[d.line-1],E=(d.line===g.line?g.column:p.length+1)-d.column||1;u&&(l+=` note: ${u}`),l+=` --> ${a.source}:${d.line}:${d.column} ${"".padEnd(s)} | ${d.line.toString().padStart(s)} | ${p} ${"".padEnd(s)} | ${"".padEnd(d.column-1)}${"".padEnd(E,"^")}`}else l+=` at ${a.source}:${d.line}:${d.column}`,u&&(l+=`: ${u}`);return l}function i(a,s,u,l=[]){let f;u?f=l.reduce((g,{location:p})=>Math.max(g,p.start.line),u.start.line):f=Math.max.apply(null,l.map(g=>g.location.start.line)),f=f.toString().length;let d=`${a}: ${s}`;u&&(d+=n(u,f));for(let g of l)d+=n(g.location,f,g.message);return d}return this.problems.filter(a=>a[0]!=="info").map(a=>i(...a)).join(` `)}};p3.exports=R2});var cs=le((nJ,g3)=>{"use strict";var Rq={build(e){function t(s,...u){return e[s.type](s,...u)}function r(){}function n(s,...u){return t(s.expression,...u)}function i(s){return function(u,...l){u[s].forEach(f=>t(f,...l))}}let a={grammar(s,...u){s.topLevelInitializer&&t(s.topLevelInitializer,...u),s.initializer&&t(s.initializer,...u),s.rules.forEach(l=>t(l,...u))},top_level_initializer:r,initializer:r,rule:n,named:n,choice:i("alternatives"),action:n,sequence:i("elements"),labeled:n,text:n,simple_and:n,simple_not:n,optional:n,zero_or_more:n,one_or_more:n,group:n,semantic_and:r,semantic_not:r,rule_ref:r,literal:r,class:r,any:r};return Object.keys(a).forEach(s=>{Object.prototype.hasOwnProperty.call(e,s)||(e[s]=a[s])}),t}};g3.exports=Rq});var to=le((iJ,v3)=>{"use strict";var Pq=cs(),m3={findRule(e,t){for(let r=0;r{"use strict";var xq={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};E3.exports=xq});var x2=le((aJ,w3)=>{"use strict";var Oq=cs(),Tq=to(),kq=Fp(),Ch=1,al=0,Dh=-1;function Sp(e){function t(s){return s.match=al}function r(s){return a(s.expression),s.match=Ch}function n(s){return s.match=a(s.expression)}function i(s,u){let l=s.length,f=0,d=0;for(let g=0;g0?Dh:al}let a=Oq.build({rule(s){let u,l=0;if(typeof s.match>"u"){s.match=al;do if(u=s.match,s.match=a(s.expression),++l>6)throw new kq("Infinity cycle detected when trying to evaluate node match result",s.location);while(u!==s.match)}return s.match},named:n,choice(s){return s.match=i(s.alternatives,!0)},action:n,sequence(s){return s.match=i(s.elements,!1)},labeled:n,text:n,simple_and:n,simple_not(s){return s.match=-a(s.expression)},optional:r,zero_or_more:r,one_or_more:n,group:n,semantic_and:t,semantic_not:t,rule_ref(s){let u=Tq.findRule(e,s.name);return s.match=a(u)},literal(s){let u=s.value.length===0?Ch:al;return s.match=u},class(s){let u=s.parts.length===0?Dh:al;return s.match=u},any:t});a(e)}Sp.ALWAYS_MATCH=Ch;Sp.SOMETIMES_MATCH=al;Sp.NEVER_MATCH=Dh;w3.exports=Sp});var y3=le((uJ,A3)=>{"use strict";var Nq=to(),Re=P2(),Lq=cs(),{ALWAYS_MATCH:kc,SOMETIMES_MATCH:O2,NEVER_MATCH:T2}=x2();function Uq(e){let t=[],r=[],n=[],i=[];function a(y){let D=t.indexOf(y);return D===-1?t.push(y)-1:D}function s(y){let D={value:y.parts,inverted:y.inverted,ignoreCase:y.ignoreCase},C=JSON.stringify(D),F=r.findIndex(L=>JSON.stringify(L)===C);return F===-1?r.push(D)-1:F}function u(y){let D=JSON.stringify(y),C=n.findIndex(F=>JSON.stringify(F)===D);return C===-1?n.push(y)-1:C}function l(y,D,C){let F={predicate:y,params:D,body:C.code,location:C.codeLocation},L=JSON.stringify(F),k=i.findIndex(S=>JSON.stringify(S)===L);return k===-1?i.push(F)-1:k}function f(y){let D={};return Object.keys(y).forEach(C=>{D[C]=y[C]}),D}function d(y,...D){return y.concat(...D)}function g(y,D,C,F){return y===kc?C:y===T2?F:D.concat([C.length,F.length],C,F)}function p(y,D){return y.concat([D.length],D)}function h(y,D,C,F){let L=Object.keys(C).map(k=>F-C[k]);return[Re.CALL,y,D,L.length].concat(L)}function E(y,D,C){let F=y.match|0;return d([Re.PUSH_CURR_POS],[Re.SILENT_FAILS_ON],m(y,{sp:C.sp+1,env:f(C.env),action:null}),[Re.SILENT_FAILS_OFF],g(D?-F:F,[D?Re.IF_ERROR:Re.IF_NOT_ERROR],d([Re.POP],[D?Re.POP:Re.POP_CURR_POS],[Re.PUSH_UNDEFINED]),d([Re.POP],[D?Re.POP_CURR_POS:Re.POP],[Re.PUSH_FAILED])))}function v(y,D,C){let F=l(!0,Object.keys(C.env),y);return d([Re.UPDATE_SAVED_POS],h(F,0,C.env,C.sp),g(y.match|0,[Re.IF],d([Re.POP],D?[Re.PUSH_FAILED]:[Re.PUSH_UNDEFINED]),d([Re.POP],D?[Re.PUSH_UNDEFINED]:[Re.PUSH_FAILED])))}function b(y){return p([Re.WHILE_NOT_ERROR],d([Re.APPEND],y))}let m=Lq.build({grammar(y){y.rules.forEach(m),y.literals=t,y.classes=r,y.expectations=n,y.functions=i},rule(y){y.bytecode=m(y.expression,{sp:-1,env:{},pluck:[],action:null})},named(y,D){let C=y.match|0,F=C===T2?null:u({type:"rule",value:y.name});return d([Re.SILENT_FAILS_ON],m(y.expression,D),[Re.SILENT_FAILS_OFF],g(C,[Re.IF_ERROR],[Re.FAIL,F],[]))},choice(y,D){function C(F,L){let k=F[0].match|0,S=m(F[0],{sp:L.sp,env:f(L.env),action:null});return k===kc?S:d(S,F.length>1?g(O2,[Re.IF_ERROR],d([Re.POP],C(F.slice(1),L)),[]):[])}return C(y.alternatives,D)},action(y,D){let C=f(D.env),F=y.expression.type!=="sequence"||y.expression.elements.length===0,L=m(y.expression,{sp:D.sp+(F?1:0),env:C,action:y}),k=y.expression.match|0,S=F&&k!==T2?l(!1,Object.keys(C),y):null;return F?d([Re.PUSH_CURR_POS],L,g(k,[Re.IF_NOT_ERROR],d([Re.LOAD_SAVED_POS,1],h(S,1,C,D.sp+2)),[]),[Re.NIP]):L},sequence(y,D){function C(F,L){if(F.length>0){let k=y.elements.length-F.length+1;return d(m(F[0],{sp:L.sp,env:L.env,pluck:L.pluck,action:null}),g(F[0].match|0,[Re.IF_NOT_ERROR],C(F.slice(1),{sp:L.sp+1,env:L.env,pluck:L.pluck,action:L.action}),d(k>1?[Re.POP_N,k]:[Re.POP],[Re.POP_CURR_POS],[Re.PUSH_FAILED])))}else{if(L.pluck.length>0)return d([Re.PLUCK,y.elements.length+1,L.pluck.length],L.pluck.map(k=>L.sp-k));if(L.action){let k=l(!1,Object.keys(L.env),L.action);return d([Re.LOAD_SAVED_POS,y.elements.length],h(k,y.elements.length+1,L.env,L.sp))}else return d([Re.WRAP,y.elements.length],[Re.NIP])}}return d([Re.PUSH_CURR_POS],C(y.elements,{sp:D.sp+1,env:D.env,pluck:[],action:D.action}))},labeled(y,D){let C=D.env,F=y.label,L=D.sp+1;return F&&(C=f(D.env),D.env[y.label]=L),y.pick&&D.pluck.push(L),m(y.expression,{sp:D.sp,env:C,action:null})},text(y,D){return d([Re.PUSH_CURR_POS],m(y.expression,{sp:D.sp+1,env:f(D.env),action:null}),g(y.match|0,[Re.IF_NOT_ERROR],d([Re.POP],[Re.TEXT]),[Re.NIP]))},simple_and(y,D){return E(y.expression,!1,D)},simple_not(y,D){return E(y.expression,!0,D)},optional(y,D){return d(m(y.expression,{sp:D.sp,env:f(D.env),action:null}),g(-(y.expression.match|0),[Re.IF_ERROR],d([Re.POP],[Re.PUSH_NULL]),[]))},zero_or_more(y,D){let C=m(y.expression,{sp:D.sp+1,env:f(D.env),action:null});return d([Re.PUSH_EMPTY_ARRAY],C,b(C),[Re.POP])},one_or_more(y,D){let C=m(y.expression,{sp:D.sp+1,env:f(D.env),action:null});return d([Re.PUSH_EMPTY_ARRAY],C,g(y.expression.match|0,[Re.IF_NOT_ERROR],d(b(C),[Re.POP]),d([Re.POP],[Re.POP],[Re.PUSH_FAILED])))},group(y,D){return m(y.expression,{sp:D.sp,env:f(D.env),action:null})},semantic_and(y,D){return v(y,!1,D)},semantic_not(y,D){return v(y,!0,D)},rule_ref(y){return[Re.RULE,Nq.indexOfRule(e,y.name)]},literal(y){if(y.value.length>0){let D=y.match|0,F=D===O2||D===kc&&!y.ignoreCase?a(y.ignoreCase?y.value.toLowerCase():y.value):null,L=D!==kc?u({type:"literal",value:y.value,ignoreCase:y.ignoreCase}):null;return g(D,y.ignoreCase?[Re.MATCH_STRING_IC,F]:[Re.MATCH_STRING,F],y.ignoreCase?[Re.ACCEPT_N,y.value.length]:[Re.ACCEPT_STRING,F],[Re.FAIL,L])}return[Re.PUSH_EMPTY_STRING]},class(y){let D=y.match|0,C=D===O2?s(y):null,F=D!==kc?u({type:"class",value:y.parts,inverted:y.inverted,ignoreCase:y.ignoreCase}):null;return g(D,[Re.MATCH_CHAR_CLASS,C],[Re.ACCEPT_N,1],[Re.FAIL,F])},any(y){let D=y.match|0,C=D!==kc?u({type:"any"}):null;return g(D,[Re.MATCH_ANY],[Re.ACCEPT_N,1],[Re.FAIL,C])}});m(e)}A3.exports=Uq});var _3=le((oJ,b3)=>{"use strict";var k2=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+").")}};b3.exports=k2});var N2=le((lJ,C3)=>{"use strict";C3.exports="2.0.1"});var D3=le(Ip=>{"use strict";function wu(e){return e.charCodeAt(0).toString(16).toUpperCase()}Ip.hex=wu;function jq(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"+wu(t)).replace(/[\x10-\x1F\x7F-\xFF]/g,t=>"\\x"+wu(t)).replace(/[\u0100-\u0FFF]/g,t=>"\\u0"+wu(t)).replace(/[\u1000-\uFFFF]/g,t=>"\\u"+wu(t))}Ip.stringEscape=jq;function Hq(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"+wu(t)).replace(/[\x10-\x1F\x7F-\xFF]/g,t=>"\\x"+wu(t)).replace(/[\u0100-\u0FFF]/g,t=>"\\u0"+wu(t)).replace(/[\u1000-\uFFFF]/g,t=>"\\u"+wu(t))}Ip.regexpClassEscape=Hq});var I3=le(S3=>{var F3="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");S3.encode=function(e){if(0<=e&&e{var Mq=I3(),B3=5,$3=1<>>=B3,i>0&&(n|=Vq),r+=Mq.encode(n);while(i>0);return r}});var $p=le(no=>{function zq(e,t,r){if(t in e)return e[t];if(arguments.length===3)return r;throw new Error('"'+t+'" is a required argument.')}no.getArg=zq;var O3=function(){return!("__proto__"in Object.create(null))}();function T3(e){return e}function Gq(e){return k3(e)?"$"+e:e}no.toSetString=O3?T3:Gq;function Yq(e){return k3(e)?e.slice(1):e}no.fromSetString=O3?T3:Yq;function k3(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 x3(e,t){return e===t?0:e===null?1:t===null?-1:e>t?1:-1}function Wq(e,t){let r=e.generatedLine-t.generatedLine;return r!==0||(r=e.generatedColumn-t.generatedColumn,r!==0)||(r=x3(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:x3(e.name,t.name)}no.compareByGeneratedPositionsInflated=Wq;var L2="http:",Fh=`${L2}//host`;function N3(e){return t=>{let r=Sh(t),n=U2(t),i=new URL(t,n);e(i);let a=i.toString();return r==="absolute"?a:r==="scheme-relative"?a.slice(L2.length):r==="path-absolute"?a.slice(Fh.length):j2(n,a)}}function ro(e,t){return new URL(e,t).toString()}function Xq(e,t){let r=0;do{let n=e+r++;if(t.indexOf(n)===-1)return n}while(!0)}function U2(e){let t=e.split("..").length-1,r=Xq("p",e),n=`${Fh}/`;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 Zq=N3(e=>{e.pathname=e.pathname.replace(/\/?$/,"/")}),Bp=N3(e=>{});no.normalize=Bp;function Qq(e,t){let r=Sh(t),n=Sh(e);if(e=Zq(e),r==="absolute")return ro(t,void 0);if(n==="absolute")return ro(t,e);if(r==="scheme-relative")return Bp(t);if(n==="scheme-relative")return ro(t,ro(e,Fh)).slice(L2.length);if(r==="path-absolute")return Bp(t);if(n==="path-absolute")return ro(t,ro(e,Fh)).slice(Fh.length);let i=U2(t+e),a=ro(t,ro(e,i));return j2(i,a)}no.join=Qq;function eV(e,t){let r=tV(e,t);return typeof r=="string"?r:Bp(t)}no.relative=eV;function tV(e,t){if(Sh(e)!==Sh(t))return null;let n=U2(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:j2(i,a)}});var U3=le(L3=>{var H2=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 j3=$p();function rV(e,t){let r=e.generatedLine,n=t.generatedLine,i=e.generatedColumn,a=t.generatedColumn;return n>r||n==r&&a>=i||j3.compareByGeneratedPositionsInflated(e,t)<=0}var M2=class{constructor(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}unsortedForEach(t,r){this._array.forEach(t,r)}add(t){rV(this._last,t)?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))}toArray(){return this._sorted||(this._array.sort(j3.compareByGeneratedPositionsInflated),this._sorted=!0),this._array}};H3.MappingList=M2});var q2=le(q3=>{var Ih=P3(),Hr=$p(),Rp=U3().ArraySet,nV=M3().MappingList,Pp=class e{constructor(t){t||(t={}),this._file=Hr.getArg(t,"file",null),this._sourceRoot=Hr.getArg(t,"sourceRoot",null),this._skipValidation=Hr.getArg(t,"skipValidation",!1),this._sources=new Rp,this._names=new Rp,this._mappings=new nV,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=Hr.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=Hr.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=Hr.getArg(t,"generated"),n=Hr.getArg(t,"original",null),i=Hr.getArg(t,"source",null),a=Hr.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=Hr.relative(this._sourceRoot,n)),r!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[Hr.toSetString(n)]=r):this._sourcesContents&&(delete this._sourcesContents[Hr.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=Hr.relative(a,i));let s=this._mappings.toArray().length>0?new Rp:this._sources,u=new Rp;this._mappings.unsortedForEach(function(l){if(l.source===i&&l.originalLine!=null){let g=t.originalPositionFor({line:l.originalLine,column:l.originalColumn});g.source!=null&&(l.source=g.source,n!=null&&(l.source=Hr.join(n,l.source)),a!=null&&(l.source=Hr.relative(a,l.source)),l.originalLine=g.line,l.originalColumn=g.column,g.name!=null&&(l.name=g.name))}let f=l.source;f!=null&&!s.has(f)&&s.add(f);let d=l.name;d!=null&&!u.has(d)&&u.add(d)},this),this._sources=s,this._names=u,t.sources.forEach(function(l){let f=t.sourceContentFor(l);f!=null&&(n!=null&&(l=Hr.join(n,l)),a!=null&&(l=Hr.relative(a,l)),this.setSourceContent(l,f))},this)}_validateMapping(t,r,n,i){if(r&&typeof r.line!="number"&&typeof r.column!="number")throw new Error("original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.");if(!(t&&"line"in t&&"column"in t&&t.line>0&&t.column>=0&&!r&&!n&&!i)){if(!(t&&"line"in t&&"column"in t&&r&&"line"in r&&"column"in r&&t.line>0&&t.column>=0&&r.line>0&&r.column>=0&&n))throw new Error("Invalid mapping: "+JSON.stringify({generated:t,source:n,original:r,name:i}))}}_serializeMappings(){let t=0,r=1,n=0,i=0,a=0,s=0,u="",l,f,d,g,p=this._mappings.toArray();for(let h=0,E=p.length;h0){if(!Hr.compareByGeneratedPositionsInflated(f,p[h-1]))continue;l+=","}l+=Ih.encode(f.generatedColumn-t),t=f.generatedColumn,f.source!=null&&(g=this._sources.indexOf(f.source),l+=Ih.encode(g-s),s=g,l+=Ih.encode(f.originalLine-1-i),i=f.originalLine-1,l+=Ih.encode(f.originalColumn-n),n=f.originalColumn,f.name!=null&&(d=this._names.indexOf(f.name),l+=Ih.encode(d-a),a=d)),u+=l}return u}_generateSourcesContent(t,r){return t.map(function(n){if(!this._sourcesContents)return null;r!=null&&(n=Hr.relative(r,n));let i=Hr.toSetString(n);return Object.prototype.hasOwnProperty.call(this._sourcesContents,i)?this._sourcesContents[i]:null},this)}toJSON(){let t={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return this._file!=null&&(t.file=this._file),this._sourceRoot!=null&&(t.sourceRoot=this._sourceRoot),this._sourcesContents&&(t.sourcesContent=this._generateSourcesContent(t.sources,t.sourceRoot)),t}toString(){return JSON.stringify(this.toJSON())}};Pp.prototype._version=3;q3.SourceMapGenerator=Pp});var K3=le(V3=>{var iV=q2().SourceMapGenerator,xp=$p(),sV=/(\r?\n)/,aV=10,Nc="$$$isSourceNode$$$",V2=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[Nc]=!0,i!=null&&this.add(i)}static fromStringWithSourceMap(t,r,n){let i=new e,a=t.split(sV),s=0,u=function(){let h=v(),E=v()||"";return h+E;function v(){return s=0;r--)this.prepend(t[r]);else if(t[Nc]||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{K2.SourceMapGenerator=q2().SourceMapGenerator;K2.SourceNode=K3().SourceNode});var X3=le((wJ,W3)=>{"use strict";var uV=to(),jt=P2(),oV=_3(),lV=N2(),{stringEscape:Gi,regexpClassEscape:z2}=D3(),{SourceNode:hs}=z3();function Y3(e,t,r){let n=t.start.line,i=t.start.column-1,a=e.split(` `);return a.length===1?new hs(n,i,t.source,e,r):new hs(null,null,t.source,a.map((s,u)=>new hs(n+u,u===0?i:0,t.source,u===a.length-1?s:[s,` `],r)))}function G3(e,t,r,n,i){return r?new hs(null,null,r.source,[e,Y3(t,r,i),new hs(r.end.line,r.end.column-1,r.source,n)]):new hs(null,null,null,[e,t,n])}function cV(e,t){function r(v){return v instanceof hs?v:v.replace(/^(.+)$/gm," $1")}function n(v){return"peg$c"+v}function i(v){return"peg$r"+v}function a(v){return"peg$e"+v}function s(v){return"peg$f"+v}function u(v){return"peg$parse"+v}function l(){function v(D){return'"'+Gi(D)+'"'}function b(D){return"/^["+(D.inverted?"^":"")+D.value.map(C=>Array.isArray(C)?z2(C[0])+"-"+z2(C[1]):z2(C)).join("")+"]/"+(D.ignoreCase?"i":"")}function m(D){switch(D.type){case"rule":return'peg$otherExpectation("'+Gi(D.value)+'")';case"literal":return'peg$literalExpectation("'+Gi(D.value)+'", '+D.ignoreCase+")";case"class":return"peg$classExpectation(["+D.value.map(F=>Array.isArray(F)?'["'+Gi(F[0])+'", "'+Gi(F[1])+'"]':'"'+Gi(F)+'"').join(", ")+"], "+D.inverted+", "+D.ignoreCase+")";case"any":return"peg$anyExpectation()";default:throw new Error("Unknown expectation type ("+JSON.stringify(D)+")")}}function y(D,C){return G3(` var ${s(C)} = function(${D.params.join(", ")}) {`,D.body,D.location,"};")}return new hs(null,null,t.grammarSource,[e.literals.map((D,C)=>" var "+n(C)+" = "+v(D)+";").concat("",e.classes.map((D,C)=>" var "+i(C)+" = "+b(D)+";")).concat("",e.expectations.map((D,C)=>" var "+a(C)+" = "+m(D)+";")).concat("").join(` `),e.functions.map(y)])}function f(v,b){let m=[];return m.push(""),t.trace&&m.push("peg$tracer.trace({",' type: "rule.enter",'," rule: "+v+","," location: peg$computeLocation(startPos, startPos)","});",""),t.cache&&(m.push("var key = peg$currPos * "+e.rules.length+" + "+b+";","var cached = peg$resultsCache[key];","","if (cached) {"," peg$currPos = cached.nextPos;",""),t.trace&&m.push("if (cached.result !== peg$FAILED) {"," peg$tracer.trace({",' type: "rule.match",'," rule: "+v+","," result: cached.result,"," location: peg$computeLocation(startPos, peg$currPos)"," });","} else {"," peg$tracer.trace({",' type: "rule.fail",'," rule: "+v+","," location: peg$computeLocation(startPos, startPos)"," });","}",""),m.push(" return cached.result;","}","")),m}function d(v,b){let m=[];return t.cache&&m.push("","peg$resultsCache[key] = { nextPos: peg$currPos, result: "+b+" };"),t.trace&&m.push("","if ("+b+" !== peg$FAILED) {"," peg$tracer.trace({",' type: "rule.match",'," rule: "+v+","," result: "+b+","," location: peg$computeLocation(startPos, peg$currPos)"," });","} else {"," peg$tracer.trace({",' type: "rule.fail",'," rule: "+v+","," location: peg$computeLocation(startPos, startPos)"," });","}"),m.push("","return "+b+";"),m}function g(v){let b=[],m=new oV(v.name,"s","var");function y(C){let F=0,L=C.length,k=[],S;function B(U,Y){let H=Y+3,K=C[F+H-2],W=C[F+H-1],ie,Ce;m.checkedIf(F,()=>{F+=H,ie=y(C.slice(F,F+K)),F+=K},W>0?()=>{Ce=y(C.slice(F,F+W)),F+=W}:null),k.push("if ("+U+") {"),k.push(...ie.map(r)),W>0&&(k.push("} else {"),k.push(...Ce.map(r))),k.push("}")}function O(U){let H=C[F+2-1],K;m.checkedLoop(F,()=>{F+=2,K=y(C.slice(F,F+H)),F+=H}),k.push("while ("+U+") {"),k.push(...K.map(r)),k.push("}")}function P(){let Y=C[F+4-1],H=s(C[F+1])+"("+C.slice(F+4,F+4+Y).map(K=>m.index(K)).join(", ")+")";m.pop(C[F+2]),k.push(m.push(H)),F+=4+Y}for(;Fm.index(K)).join(", ")} ]`,m.pop(C[F+1]),k.push(m.push(S)),F+=H;break}case jt.IF:B(m.top(),0);break;case jt.IF_ERROR:B(m.top()+" === peg$FAILED",0);break;case jt.IF_NOT_ERROR:B(m.top()+" !== peg$FAILED",0);break;case jt.WHILE_NOT_ERROR:O(m.top()+" !== peg$FAILED");break;case jt.MATCH_ANY:B("input.length > peg$currPos",0);break;case jt.MATCH_STRING:B(e.literals[C[F+1]].length>1?"input.substr(peg$currPos, "+e.literals[C[F+1]].length+") === "+n(C[F+1]):"input.charCodeAt(peg$currPos) === "+e.literals[C[F+1]].charCodeAt(0),1);break;case jt.MATCH_STRING_IC:B("input.substr(peg$currPos, "+e.literals[C[F+1]].length+").toLowerCase() === "+n(C[F+1]),1);break;case jt.MATCH_CHAR_CLASS:B(i(C[F+1])+".test(input.charAt(peg$currPos))",1);break;case jt.ACCEPT_N:k.push(m.push(C[F+1]>1?"input.substr(peg$currPos, "+C[F+1]+")":"input.charAt(peg$currPos)")),k.push(C[F+1]>1?"peg$currPos += "+C[F+1]+";":"peg$currPos++;"),F+=2;break;case jt.ACCEPT_STRING:k.push(m.push(n(C[F+1]))),k.push(e.literals[C[F+1]].length>1?"peg$currPos += "+e.literals[C[F+1]].length+";":"peg$currPos++;"),F+=2;break;case jt.FAIL:k.push(m.push("peg$FAILED")),k.push("if (peg$silentFails === 0) { peg$fail("+a(C[F+1])+"); }"),F+=2;break;case jt.LOAD_SAVED_POS:k.push("peg$savedPos = "+m.index(C[F+1])+";"),F+=2;break;case jt.UPDATE_SAVED_POS:k.push("peg$savedPos = peg$currPos;"),F++;break;case jt.CALL:P();break;case jt.RULE:k.push(m.push(u(e.rules[C[F+1]].name)+"()")),F+=2;break;case jt.SILENT_FAILS_ON:k.push("peg$silentFails++;"),F++;break;case jt.SILENT_FAILS_OFF:k.push("peg$silentFails--;"),F++;break;default:throw new Error("Invalid opcode: "+C[F]+".")}return k}let D=y(v.bytecode);return b.push(G3(" function ",u(v.name),v.nameLocation,`() { `,v.name)),t.trace&&b.push(" var startPos = peg$currPos;"),b.push(r(m.defines())),b.push(...f('"'+Gi(v.name)+'"',uV.indexOfRule(e,v.name)).map(r)),b.push(...D.map(r)),b.push(...d('"'+Gi(v.name)+'"',m.result()).map(r)),b.push("}"),b}function p(v){return v.codeLocation?Y3(v.code,v.codeLocation,"$"+v.type):v.code}function h(){let v=[];e.topLevelInitializer&&(v.push(p(e.topLevelInitializer)),v.push("")),v.push("function peg$subclass(child, parent) {"," function C() { this.constructor = child; }"," C.prototype = parent.prototype;"," child.prototype = new C();","}","","function peg$SyntaxError(message, expected, found, location) {"," var self = Error.call(this, message);"," // istanbul ignore next Check is a necessary evil to support older environments"," if (Object.setPrototypeOf) {"," Object.setPrototypeOf(self, peg$SyntaxError.prototype);"," }"," self.expected = expected;"," self.found = found;"," self.location = location;",' self.name = "SyntaxError";'," return self;","}","","peg$subclass(peg$SyntaxError, Error);","","function peg$padEnd(str, targetLength, padString) {",' padString = padString || " ";'," if (str.length > targetLength) { return str; }"," targetLength -= str.length;"," padString += padString.repeat(targetLength);"," return str + padString.slice(0, targetLength);","}","","peg$SyntaxError.prototype.format = function(sources) {",' var str = "Error: " + this.message;'," if (this.location) {"," var src = null;"," var k;"," for (k = 0; k < sources.length; k++) {"," if (sources[k].source === this.location.source) {"," src = sources[k].text.split(/\\r\\n|\\n|\\r/g);"," break;"," }"," }"," var s = this.location.start;",' var loc = this.location.source + ":" + s.line + ":" + s.column;'," if (src) {"," var e = this.location.end;",` var filler = peg$padEnd("", s.line.toString().length, ' ');`," var line = src[s.line - 1];"," var last = s.line === e.line ? e.column : line.length + 1;"," var hatLen = (last - s.column) || 1;",' str += "\\n --> " + loc + "\\n"',' + filler + " |\\n"',' + s.line + " | " + line + "\\n"',` + filler + " | " + peg$padEnd("", s.column - 1, ' ')`,' + peg$padEnd("", hatLen, "^");'," } else {",' str += "\\n at " + loc;'," }"," }"," return str;","};","","peg$SyntaxError.buildMessage = function(expected, found) {"," var DESCRIBE_EXPECTATION_FNS = {"," literal: function(expectation) {",' return "\\"" + literalEscape(expectation.text) + "\\"";'," },",""," class: function(expectation) {"," var escapedParts = expectation.parts.map(function(part) {"," return Array.isArray(part)",' ? classEscape(part[0]) + "-" + classEscape(part[1])'," : classEscape(part);"," });","",' return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";'," },",""," any: function() {",' return "any character";'," },",""," end: function() {",' return "end of input";'," },",""," other: function(expectation) {"," return expectation.description;"," }"," };",""," function hex(ch) {"," return ch.charCodeAt(0).toString(16).toUpperCase();"," }",""," function literalEscape(s) {"," return s",' .replace(/\\\\/g, "\\\\\\\\")',' .replace(/"/g, "\\\\\\"")',' .replace(/\\0/g, "\\\\0")',' .replace(/\\t/g, "\\\\t")',' .replace(/\\n/g, "\\\\n")',' .replace(/\\r/g, "\\\\r")',' .replace(/[\\x00-\\x0F]/g, function(ch) { return "\\\\x0" + hex(ch); })',' .replace(/[\\x10-\\x1F\\x7F-\\x9F]/g, function(ch) { return "\\\\x" + hex(ch); });'," }",""," function classEscape(s) {"," return s",' .replace(/\\\\/g, "\\\\\\\\")',' .replace(/\\]/g, "\\\\]")',' .replace(/\\^/g, "\\\\^")',' .replace(/-/g, "\\\\-")',' .replace(/\\0/g, "\\\\0")',' .replace(/\\t/g, "\\\\t")',' .replace(/\\n/g, "\\\\n")',' .replace(/\\r/g, "\\\\r")',' .replace(/[\\x00-\\x0F]/g, function(ch) { return "\\\\x0" + hex(ch); })',' .replace(/[\\x10-\\x1F\\x7F-\\x9F]/g, function(ch) { return "\\\\x" + hex(ch); });'," }",""," function describeExpectation(expectation) {"," return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);"," }",""," function describeExpected(expected) {"," var descriptions = expected.map(describeExpectation);"," var i, j;",""," descriptions.sort();",""," if (descriptions.length > 0) {"," for (i = 1, j = 1; i < descriptions.length; i++) {"," if (descriptions[i - 1] !== descriptions[i]) {"," descriptions[j] = descriptions[i];"," j++;"," }"," }"," descriptions.length = j;"," }",""," switch (descriptions.length) {"," case 1:"," return descriptions[0];",""," case 2:",' return descriptions[0] + " or " + descriptions[1];',""," default:",' return descriptions.slice(0, -1).join(", ")',' + ", or "'," + descriptions[descriptions.length - 1];"," }"," }",""," function describeFound(found) {",' return found ? "\\"" + literalEscape(found) + "\\"" : "end of input";'," }","",' return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";',"};",""),t.trace&&v.push("function peg$DefaultTracer() {"," this.indentLevel = 0;","}","","peg$DefaultTracer.prototype.trace = function(event) {"," var that = this;",""," function log(event) {"," function repeat(string, n) {",' var result = "", i;',""," for (i = 0; i < n; i++) {"," result += string;"," }",""," return result;"," }",""," function pad(string, length) {",' return string + repeat(" ", length - string.length);'," }","",' if (typeof console === "object") {'," console.log(",' event.location.start.line + ":" + event.location.start.column + "-"',' + event.location.end.line + ":" + event.location.end.column + " "',' + pad(event.type, 10) + " "',' + repeat(" ", that.indentLevel) + event.rule'," );"," }"," }",""," switch (event.type) {",' case "rule.enter":'," log(event);"," this.indentLevel++;"," break;","",' case "rule.match":'," this.indentLevel--;"," log(event);"," break;","",' case "rule.fail":'," this.indentLevel--;"," log(event);"," break;",""," default:",' throw new Error("Invalid event type: " + event.type + ".");'," }","};","");let b="{ "+t.allowedStartRules.map(y=>y+": "+u(y)).join(", ")+" }",m=u(t.allowedStartRules[0]);return v.push("function peg$parse(input, options) {"," options = options !== undefined ? options : {};",""," var peg$FAILED = {};"," var peg$source = options.grammarSource;",""," var peg$startRuleFunctions = "+b+";"," var peg$startRuleFunction = "+m+";","",l(),""," var peg$currPos = 0;"," var peg$savedPos = 0;"," var peg$posDetailsCache = [{ line: 1, column: 1 }];"," var peg$maxFailPos = 0;"," var peg$maxFailExpected = [];"," var peg$silentFails = 0;",""),t.cache&&v.push(" var peg$resultsCache = {};",""),t.trace&&v.push(' var peg$tracer = "tracer" in options ? options.tracer : new peg$DefaultTracer();',""),v.push(" var peg$result;","",' if ("startRule" in options) {'," if (!(options.startRule in peg$startRuleFunctions)) {",` throw new Error("Can't start parsing from rule \\"" + options.startRule + "\\".");`," }",""," peg$startRuleFunction = peg$startRuleFunctions[options.startRule];"," }",""," function text() {"," return input.substring(peg$savedPos, peg$currPos);"," }",""," function offset() {"," return peg$savedPos;"," }",""," function range() {"," return {"," source: peg$source,"," start: peg$savedPos,"," end: peg$currPos"," };"," }",""," function location() {"," return peg$computeLocation(peg$savedPos, peg$currPos);"," }",""," function expected(description, location) {"," location = location !== undefined"," ? location"," : peg$computeLocation(peg$savedPos, peg$currPos);",""," throw peg$buildStructuredError("," [peg$otherExpectation(description)],"," input.substring(peg$savedPos, peg$currPos),"," location"," );"," }",""," function error(message, location) {"," location = location !== undefined"," ? location"," : peg$computeLocation(peg$savedPos, peg$currPos);",""," throw peg$buildSimpleError(message, location);"," }",""," function peg$literalExpectation(text, ignoreCase) {",' return { type: "literal", text: text, ignoreCase: ignoreCase };'," }",""," function peg$classExpectation(parts, inverted, ignoreCase) {",' return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };'," }",""," function peg$anyExpectation() {",' return { type: "any" };'," }",""," function peg$endExpectation() {",' return { type: "end" };'," }",""," function peg$otherExpectation(description) {",' return { type: "other", description: description };'," }",""," function peg$computePosDetails(pos) {"," var details = peg$posDetailsCache[pos];"," var p;",""," if (details) {"," return details;"," } else {"," p = pos - 1;"," while (!peg$posDetailsCache[p]) {"," p--;"," }",""," details = peg$posDetailsCache[p];"," details = {"," line: details.line,"," column: details.column"," };",""," while (p < pos) {"," if (input.charCodeAt(p) === 10) {"," details.line++;"," details.column = 1;"," } else {"," details.column++;"," }",""," p++;"," }",""," peg$posDetailsCache[pos] = details;",""," return details;"," }"," }",""," function peg$computeLocation(startPos, endPos) {"," var startPosDetails = peg$computePosDetails(startPos);"," var endPosDetails = peg$computePosDetails(endPos);",""," return {"," source: peg$source,"," start: {"," offset: startPos,"," line: startPosDetails.line,"," column: startPosDetails.column"," },"," end: {"," offset: endPos,"," line: endPosDetails.line,"," column: endPosDetails.column"," }"," };"," }",""," function peg$fail(expected) {"," if (peg$currPos < peg$maxFailPos) { return; }",""," if (peg$currPos > peg$maxFailPos) {"," peg$maxFailPos = peg$currPos;"," peg$maxFailExpected = [];"," }",""," peg$maxFailExpected.push(expected);"," }",""," function peg$buildSimpleError(message, location) {"," return new peg$SyntaxError(message, null, null, location);"," }",""," function peg$buildStructuredError(expected, found, location) {"," return new peg$SyntaxError("," peg$SyntaxError.buildMessage(expected, found),"," expected,"," found,"," location"," );"," }",""),e.rules.forEach(y=>{v.push(...g(y).map(r)),v.push("")}),e.initializer&&(v.push(p(e.initializer)),v.push("")),v.push(" peg$result = peg$startRuleFunction();",""," if (peg$result !== peg$FAILED && peg$currPos === input.length) {"," return peg$result;"," } else {"," if (peg$result !== peg$FAILED && peg$currPos < input.length) {"," peg$fail(peg$endExpectation());"," }",""," throw peg$buildStructuredError("," peg$maxFailExpected,"," peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,"," peg$maxFailPos < input.length"," ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)"," : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)"," );"," }","}"),new hs(null,null,t.grammarSource,v.map(y=>y instanceof hs?y:y+` `))}function E(v){function b(){return[`// Generated by Peggy ${lV}.`,"//","// https://peggyjs.org/"]}function m(){return t.trace?["{"," SyntaxError: peg$SyntaxError,"," DefaultTracer: peg$DefaultTracer,"," parse: peg$parse","}"].join(` `):["{"," SyntaxError: peg$SyntaxError,"," parse: peg$parse","}"].join(` `)}let D={bare(){return[...b(),"(function() {",' "use strict";',"",v,"",r("return "+m()+";"),"})()"]},commonjs(){let C=Object.keys(t.dependencies),F=b();return F.push("",'"use strict";',""),C.length>0&&(C.forEach(L=>{F.push("var "+L+' = require("'+Gi(t.dependencies[L])+'");')}),F.push("")),F.push(v,"","module.exports = "+m()+";"),F},es(){let C=Object.keys(t.dependencies),F=b();return F.push(""),C.length>0&&(C.forEach(L=>{F.push("import "+L+' from "'+Gi(t.dependencies[L])+'";')}),F.push("")),F.push(v,"","export {"," peg$SyntaxError as SyntaxError,",t.trace?" peg$DefaultTracer as DefaultTracer,":""," peg$parse as parse","};"),F},amd(){let C=Object.keys(t.dependencies),L="["+C.map(S=>t.dependencies[S]).map(S=>'"'+Gi(S)+'"').join(", ")+"]",k=C.join(", ");return[...b(),"define("+L+", function("+k+") {",' "use strict";',"",v,"",r("return "+m()+";"),"});"]},globals(){return[...b(),"(function(root) {",' "use strict";',"",v,"",r("root."+t.exportVar+" = "+m()+";"),"})(this);"]},umd(){let C=Object.keys(t.dependencies),F=C.map(O=>t.dependencies[O]),L="["+F.map(O=>'"'+Gi(O)+'"').join(", ")+"]",k=F.map(O=>'require("'+Gi(O)+'")').join(", "),S=C.join(", "),B=b();return B.push("(function(root, factory) {",' if (typeof define === "function" && define.amd) {'," define("+L+", factory);",' } else if (typeof module === "object" && module.exports) {'," module.exports = factory("+k+");"),t.exportVar!==null&&B.push(" } else {"," root."+t.exportVar+" = factory();"),B.push(" }","})(this, function("+S+") {",' "use strict";',"",v,"",r("return "+m()+";"),"});"),B}}[t.format]();return new hs(null,null,t.grammarSource,D.map(C=>C instanceof hs?C:C+` `))}e.code=E(h())}W3.exports=cV});var Z3=le((AJ,J3)=>{"use strict";var fV=to(),hV=cs();function dV(e,t,r){function n(s){return s.type==="rule"&&s.expression.type==="rule_ref"}function i(s,u,l){hV.build({rule_ref(d){d.name===u&&(d.name=l,r.info(`Proxy rule "${u}" replaced by the rule "${l}"`,d.location,[{message:"This rule will be used",location:fV.findRule(s,l).nameLocation}]))}})(s)}let a=[];e.rules.forEach((s,u)=>{n(s)&&(i(e,s.name,s.expression.name),t.allowedStartRules.indexOf(s.name)===-1&&a.push(u))}),a.reverse(),a.forEach(s=>{e.rules.splice(s,1)})}J3.exports=dV});var e5=le((yJ,Q3)=>{"use strict";var pV=cs();function gV(e,t,r){function n(s){let u={};return Object.keys(s).forEach(l=>{u[l]=s[l]}),u}function i(s,u){a(s.expression,n(u))}let a=pV.build({rule(s){a(s.expression,{})},choice(s,u){s.alternatives.forEach(l=>{a(l,n(u))})},action:i,labeled(s,u){let l=s.label;l&&Object.prototype.hasOwnProperty.call(u,l)&&r.error(`Label "${s.label}" is already defined`,s.labelLocation,[{message:"Original label location",location:u[l]}]),a(s.expression,u),u[s.label]=s.labelLocation},text:i,simple_and:i,simple_not:i,optional:i,zero_or_more:i,one_or_more:i,group:i});a(e)}Q3.exports=gV});var r5=le((bJ,t5)=>{"use strict";var mV=cs();function vV(e,t,r){let n={};mV.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)}t5.exports=vV});var s5=le((_J,i5)=>{"use strict";var n5=to(),EV=cs();function wV(e,t,r){let n=[],i=[],a=EV.build({rule(s){n.push(s.name),a(s.expression),n.pop()},sequence(s){s.elements.every(u=>(a(u),!n5.alwaysConsumesOnSuccess(e,u)))},rule_ref(s){i.push(s);let u=n5.findRule(e,s.name);if(n.indexOf(s.name)!==-1){n.push(s.name),r.error("Possible infinite loop when parsing (left recursion: "+n.join(" -> ")+")",u.nameLocation,i.map((l,f,d)=>({message:f+1!==d.length?`Step ${f+1}: call of the rule "${l.name}" without input consumption`:`Step ${f+1}: call itself without input consumption - left recursion`,location:l.location})));return}u&&a(u),i.pop()}});a(e)}i5.exports=wV});var o5=le((CJ,u5)=>{"use strict";var a5=to(),AV=cs();function yV(e,t,r){AV.build({zero_or_more(i){a5.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){a5.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)}u5.exports=yV});var c5=le((DJ,l5)=>{"use strict";var bV=to(),_V=cs();function CV(e,t,r){_V.build({rule_ref(i){bV.findRule(e,i.name)||r.error(`Rule "${i.name}" is not defined`,i.location)}})(e)}l5.exports=CV});var h5=le((FJ,f5)=>{"use strict";var DV=cs();function FV(e,t,r){let n=DV.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)}f5.exports=FV});var p5=le((SJ,d5)=>{"use strict";var SV=Fp(),G2=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(){}},Y2=class{constructor(t){this._callbacks=new G2(t),this._firstError=null,this.errors=0,this.problems=[],this.stage=null}error(...t){++this.errors,this._firstError===null&&(this._firstError=new SV(...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}};d5.exports=Y2});var g5=le((exports,module)=>{"use strict";var generateBytecode=y3(),generateJS=X3(),inferenceMatchResult=x2(),removeProxyRules=Z3(),reportDuplicateLabels=e5(),reportDuplicateRules=r5(),reportInfiniteRecursion=s5(),reportInfiniteRepetition=o5(),reportUndefinedRules=c5(),reportIncorrectPlucking=h5(),Session=p5(),visitor=cs();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 v5=le((IJ,m5)=>{"use strict";var IV={$:"text","&":"simple_and","!":"simple_not"},BV={"?":"optional","*":"zero_or_more","+":"one_or_more"},$V={"&":"semantic_and","!":"semantic_not"};function RV(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}function io(e,t,r,n){var i=Error.call(this,e);return Object.setPrototypeOf&&Object.setPrototypeOf(i,io.prototype),i.expected=t,i.found=r,i.location=n,i.name="SyntaxError",i}RV(io,Error);function W2(e,t,r){return r=r||" ",e.length>t?e:(t-=e.length,r+=r.repeat(t),e+r.slice(0,t))}io.prototype.format=function(e){var t="Error: "+this.message;if(this.location){var r=null,n;for(n=0;n `+a+` `+u+` | `+i.line+" | "+l+` `+u+" | "+W2("",i.column-1," ")+W2("",d,"^")}else t+=` at `+a}return t};io.buildMessage=function(e,t){var r={literal:function(f){return'"'+i(f.text)+'"'},class:function(f){var d=f.parts.map(function(g){return Array.isArray(g)?a(g[0])+"-"+a(g[1]):a(g)});return"["+(f.inverted?"^":"")+d.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(f){return f.description}};function n(f){return f.charCodeAt(0).toString(16).toUpperCase()}function i(f){return f.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(d){return"\\x0"+n(d)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(d){return"\\x"+n(d)})}function a(f){return f.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(d){return"\\x0"+n(d)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(d){return"\\x"+n(d)})}function s(f){return r[f.type](f)}function u(f){var d=f.map(s),g,p;if(d.sort(),d.length>0){for(g=1,p=1;g0?{type:"choice",alternatives:[_].concat(j),location:dr()}:_},Wi=function(_,j){return j!==null?{type:"action",expression:_,code:j[0],codeLocation:j[1],location:dr()}:_},go=function(_,j){return j.length>0||_.type==="labeled"&&_.pick?{type:"sequence",elements:[_].concat(j),location:dr()}:_},Tp=function(_,j,J){return J.type.startsWith("semantic_")&&Vc('"@" cannot be used on a semantic predicate',_),{type:"labeled",label:j!==null?j[0]:null,labelLocation:j!==null?j[1]:_,pick:!0,expression:J,location:dr()}},kp=function(_,j){return{type:"labeled",label:_[0],labelLocation:_[1],expression:j,location:dr()}},tr=function(){return dr()},Jt=function(_){return bl.indexOf(_[0])>=0&&Vc(`Label can't be a reserved word "${_[0]}"`,_[1]),_},Np=function(_,j){return{type:IV[_],expression:j,location:dr()}},Lp=function(_,j){return{type:BV[j],expression:_,location:dr()}},Up=function(_){return _.type==="labeled"||_.type==="sequence"?{type:"group",expression:_,location:dr()}:_},jp=function(_){return{type:"rule_ref",name:_[0],location:dr()}},Hp=function(_,j){return{type:$V[_],code:j[0],codeLocation:j[1],location:dr()}},Mp=function(_,j){return[_+j.join(""),dr()]},Rh=function(_,j){return{type:"literal",value:_,ignoreCase:j!==null,location:dr()}},qp=function(_){return _.join("")},kr=function(_){return _.join("")},Hc=function(_,j,J){return{type:"class",parts:j.filter(z=>z!==""),inverted:_!==null,ignoreCase:J!==null,location:dr()}},Sa=function(_,j){return _.charCodeAt(0)>j.charCodeAt(0)&&Vc("Invalid character range: "+qc()+"."),[_,j]},Ph=function(){return""},Mc=function(){return"\0"},ai=function(){return"\b"},xh=function(){return"\f"},Oh=function(){return` `},Th=function(){return"\r"},kh=function(){return" "},Nh=function(){return"\v"},Lh=function(_){return String.fromCharCode(parseInt(_,16))},qn=function(_){return String.fromCharCode(parseInt(_,16))},Vp=function(){return{type:"any",location:dr()}},ui=function(_){return[_,dr()]},R=0,at=0,Ii=[{line:1,column:1}],Vn=0,mo=[],te=0,Bi;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 qc(){return e.substring(at,R)}function lE(){return at}function Uh(){return{source:n,start:at,end:R}}function dr(){return Ia(at,R)}function cE(_,j){throw j=j!==void 0?j:Ia(at,R),Hh([Xi(_)],e.substring(at,R),j)}function Vc(_,j){throw j=j!==void 0?j:Ia(at,R),jh(_,j)}function ze(_,j){return{type:"literal",text:_,ignoreCase:j}}function Nr(_,j,J){return{type:"class",parts:_,inverted:j,ignoreCase:J}}function Iu(){return{type:"any"}}function Kp(){return{type:"end"}}function Xi(_){return{type:"other",description:_}}function Kc(_){var j=Ii[_],J;if(j)return j;for(J=_-1;!Ii[J];)J--;for(j=Ii[J],j={line:j.line,column:j.column};J<_;)e.charCodeAt(J)===10?(j.line++,j.column=1):j.column++,J++;return Ii[_]=j,j}function Ia(_,j){var J=Kc(_),z=Kc(j);return{source:n,start:{offset:_,line:J.line,column:J.column},end:{offset:j,line:z.line,column:z.column}}}function me(_){RVn&&(Vn=R,mo=[]),mo.push(_))}function jh(_,j){return new io(_,null,null,j)}function Hh(_,j,J){return new io(io.buildMessage(_,j),_,j,J)}function cl(){var _,j,J,z,ae,ce,Xt,_r;if(_=R,j=Lt(),J=R,z=zc(),z!==r?(ae=Lt(),J=z):(R=J,J=r),J===r&&(J=null),z=R,ae=zp(),ae!==r?(ce=Lt(),z=ae):(R=z,z=r),z===r&&(z=null),ae=[],ce=R,Xt=Gc(),Xt!==r?(_r=Lt(),ce=Xt):(R=ce,ce=r),ce!==r)for(;ce!==r;)ae.push(ce),ce=R,Xt=Gc(),Xt!==r?(_r=Lt(),ce=Xt):(R=ce,ce=r);else ae=r;return ae!==r?(at=_,_=Si(J,z,ae)):(R=_,_=r),_}function zc(){var _,j,J,z,ae;return _=R,e.charCodeAt(R)===123?(j=s,R++):(j=r,te===0&&me(Yr)),j!==r?(J=Pt(),J!==r?(e.charCodeAt(R)===125?(z=u,R++):(z=r,te===0&&me(ds)),z!==r?(ae=Pa(),ae!==r?(at=_,_=Fu(J)):(R=_,_=r)):(R=_,_=r)):(R=_,_=r)):(R=_,_=r),_}function zp(){var _,j,J;return _=R,j=Pt(),j!==r?(J=Pa(),J!==r?(at=_,_=Mn(j)):(R=_,_=r)):(R=_,_=r),_}function Gc(){var _,j,J,z,ae,ce,Xt,_r;return _=R,j=dl(),j!==r?(J=Lt(),z=R,ae=Ji(),ae!==r?(ce=Lt(),z=ae):(R=z,z=r),z===r&&(z=null),e.charCodeAt(R)===61?(ae=l,R++):(ae=r,te===0&&me(yu)),ae!==r?(ce=Lt(),Xt=Fn(),Xt!==r?(_r=Pa(),_r!==r?(at=_,_=pn(j,z,Xt)):(R=_,_=r)):(R=_,_=r)):(R=_,_=r)):(R=_,_=r),_}function Fn(){var _,j,J,z,ae,ce,Xt,_r;if(_=R,j=vo(),j!==r){for(J=[],z=R,ae=Lt(),e.charCodeAt(R)===47?(ce=f,R++):(ce=r,te===0&&me(Ts)),ce!==r?(Xt=Lt(),_r=vo(),_r!==r?z=_r:(R=z,z=r)):(R=z,z=r);z!==r;)J.push(z),z=R,ae=Lt(),e.charCodeAt(R)===47?(ce=f,R++):(ce=r,te===0&&me(Ts)),ce!==r?(Xt=Lt(),_r=vo(),_r!==r?z=_r:(R=z,z=r)):(R=z,z=r);at=_,_=Su(j,J)}else R=_,_=r;return _}function vo(){var _,j,J,z,ae;return _=R,j=Eo(),j!==r?(J=R,z=Lt(),ae=Pt(),ae!==r?J=ae:(R=J,J=r),J===r&&(J=null),at=_,_=Wi(j,J)):(R=_,_=r),_}function Eo(){var _,j,J,z,ae,ce;if(_=R,j=fl(),j!==r){for(J=[],z=R,ae=Lt(),ce=fl(),ce!==r?z=ce:(R=z,z=r);z!==r;)J.push(z),z=R,ae=Lt(),ce=fl(),ce!==r?z=ce:(R=z,z=r);at=_,_=go(j,J)}else R=_,_=r;return _}function fl(){var _,j,J,z;return _=R,j=Mh(),j!==r?(J=qh(),J===r&&(J=null),z=Yc(),z!==r?(at=_,_=Tp(j,J,z)):(R=_,_=r)):(R=_,_=r),_===r&&(_=R,j=qh(),j!==r?(J=Lt(),z=Yc(),z!==r?(at=_,_=kp(j,z)):(R=_,_=r)):(R=_,_=r),_===r&&(_=Yc())),_}function Mh(){var _,j;return _=R,e.charCodeAt(R)===64?(j=d,R++):(j=r,te===0&&me(bu)),j!==r&&(at=_,j=tr()),_=j,_}function qh(){var _,j,J,z;return _=R,j=dl(),j!==r?(J=Lt(),e.charCodeAt(R)===58?(z=g,R++):(z=r,te===0&&me(ks)),z!==r?(at=_,_=Jt(j)):(R=_,_=r)):(R=_,_=r),_}function Yc(){var _,j,J,z;return _=R,j=Gp(),j!==r?(J=Lt(),z=Vh(),z!==r?(at=_,_=Np(j,z)):(R=_,_=r)):(R=_,_=r),_===r&&(_=Vh()),_}function Gp(){var _;return e.charCodeAt(R)===36?(_=p,R++):(_=r,te===0&&me(ps)),_===r&&(e.charCodeAt(R)===38?(_=h,R++):(_=r,te===0&&me(Tt)),_===r&&(e.charCodeAt(R)===33?(_=E,R++):(_=r,te===0&&me(ri)))),_}function Vh(){var _,j,J,z;return _=R,j=Ba(),j!==r?(J=Lt(),z=Yp(),z!==r?(at=_,_=Lp(j,z)):(R=_,_=r)):(R=_,_=r),_===r&&(_=Ba()),_}function Yp(){var _;return e.charCodeAt(R)===63?(_=v,R++):(_=r,te===0&&me(_u)),_===r&&(e.charCodeAt(R)===42?(_=b,R++):(_=r,te===0&&me(Cu)),_===r&&(e.charCodeAt(R)===43?(_=m,R++):(_=r,te===0&&me(Du)))),_}function Ba(){var _,j,J,z,ae,ce;return _=e1(),_===r&&(_=oe(),_===r&&(_=ml(),_===r&&(_=Wp(),_===r&&(_=Xp(),_===r&&(_=R,e.charCodeAt(R)===40?(j=y,R++):(j=r,te===0&&me(Ns)),j!==r?(J=Lt(),z=Fn(),z!==r?(ae=Lt(),e.charCodeAt(R)===41?(ce=D,R++):(ce=r,te===0&&me(so)),ce!==r?(at=_,_=Up(z)):(R=_,_=r)):(R=_,_=r)):(R=_,_=r)))))),_}function Wp(){var _,j,J,z,ae,ce,Xt,_r;return _=R,j=dl(),j!==r?(J=R,te++,z=R,ae=Lt(),ce=R,Xt=Ji(),Xt!==r?(_r=Lt(),Xt=[Xt,_r],ce=Xt):(R=ce,ce=r),ce===r&&(ce=null),e.charCodeAt(R)===61?(Xt=l,R++):(Xt=r,te===0&&me(yu)),Xt!==r?(ae=[ae,ce,Xt],z=ae):(R=z,z=r),te--,z===r?J=void 0:(R=J,J=r),J!==r?(at=_,_=jp(j)):(R=_,_=r)):(R=_,_=r),_}function Xp(){var _,j,J,z;return _=R,j=Wc(),j!==r?(J=Lt(),z=Pt(),z!==r?(at=_,_=Hp(j,z)):(R=_,_=r)):(R=_,_=r),_}function Wc(){var _;return e.charCodeAt(R)===38?(_=h,R++):(_=r,te===0&&me(Tt)),_===r&&(e.charCodeAt(R)===33?(_=E,R++):(_=r,te===0&&me(ri))),_}function gn(){var _;return e.length>R?(_=e.charAt(R),R++):(_=r,te===0&&me(Ls)),_}function $i(){var _,j;return te++,e.charCodeAt(R)===9?(_=C,R++):(_=r,te===0&&me(Fa)),_===r&&(e.charCodeAt(R)===11?(_=F,R++):(_=r,te===0&&me(re)),_===r&&(e.charCodeAt(R)===12?(_=L,R++):(_=r,te===0&&me(fe)),_===r&&(e.charCodeAt(R)===32?(_=k,R++):(_=r,te===0&&me(Le)),_===r&&(e.charCodeAt(R)===160?(_=S,R++):(_=r,te===0&&me(Oe)),_===r&&(e.charCodeAt(R)===65279?(_=B,R++):(_=r,te===0&&me(Ve)),_===r&&(_=Jh())))))),te--,_===r&&(j=r,te===0&&me(ao)),_}function Ri(){var _;return vt.test(e.charAt(R))?(_=e.charAt(R),R++):(_=r,te===0&&me(st)),_}function hl(){var _,j;return te++,e.charCodeAt(R)===10?(_=O,R++):(_=r,te===0&&me(Ir)),_===r&&(e.substr(R,2)===P?(_=P,R+=2):(_=r,te===0&&me(Ht)),_===r&&(e.charCodeAt(R)===13?(_=U,R++):(_=r,te===0&&me(ni)),_===r&&(e.charCodeAt(R)===8232?(_=Y,R++):(_=r,te===0&&me(Yi)),_===r&&(e.charCodeAt(R)===8233?(_=H,R++):(_=r,te===0&&me(cn)))))),te--,_===r&&(j=r,te===0&&me(ht)),_}function Kh(){var _,j;return te++,_=Jp(),_===r&&(_=oi()),te--,_===r&&(j=r,te===0&&me(Dn)),_}function Jp(){var _,j,J,z,ae,ce;if(_=R,e.substr(R,2)===K?(j=K,R+=2):(j=r,te===0&&me(Ar)),j!==r){for(J=[],z=R,ae=R,te++,e.substr(R,2)===W?(ce=W,R+=2):(ce=r,te===0&&me(fn)),te--,ce===r?ae=void 0:(R=ae,ae=r),ae!==r?(ce=gn(),ce!==r?(ae=[ae,ce],z=ae):(R=z,z=r)):(R=z,z=r);z!==r;)J.push(z),z=R,ae=R,te++,e.substr(R,2)===W?(ce=W,R+=2):(ce=r,te===0&&me(fn)),te--,ce===r?ae=void 0:(R=ae,ae=r),ae!==r?(ce=gn(),ce!==r?(ae=[ae,ce],z=ae):(R=z,z=r)):(R=z,z=r);e.substr(R,2)===W?(z=W,R+=2):(z=r,te===0&&me(fn)),z!==r?(j=[j,J,z],_=j):(R=_,_=r)}else R=_,_=r;return _}function $a(){var _,j,J,z,ae,ce;if(_=R,e.substr(R,2)===K?(j=K,R+=2):(j=r,te===0&&me(Ar)),j!==r){for(J=[],z=R,ae=R,te++,e.substr(R,2)===W?(ce=W,R+=2):(ce=r,te===0&&me(fn)),ce===r&&(ce=Ri()),te--,ce===r?ae=void 0:(R=ae,ae=r),ae!==r?(ce=gn(),ce!==r?(ae=[ae,ce],z=ae):(R=z,z=r)):(R=z,z=r);z!==r;)J.push(z),z=R,ae=R,te++,e.substr(R,2)===W?(ce=W,R+=2):(ce=r,te===0&&me(fn)),ce===r&&(ce=Ri()),te--,ce===r?ae=void 0:(R=ae,ae=r),ae!==r?(ce=gn(),ce!==r?(ae=[ae,ce],z=ae):(R=z,z=r)):(R=z,z=r);e.substr(R,2)===W?(z=W,R+=2):(z=r,te===0&&me(fn)),z!==r?(j=[j,J,z],_=j):(R=_,_=r)}else R=_,_=r;return _}function oi(){var _,j,J,z,ae,ce;if(_=R,e.substr(R,2)===ie?(j=ie,R+=2):(j=r,te===0&&me(Mr)),j!==r){for(J=[],z=R,ae=R,te++,ce=Ri(),te--,ce===r?ae=void 0:(R=ae,ae=r),ae!==r?(ce=gn(),ce!==r?(ae=[ae,ce],z=ae):(R=z,z=r)):(R=z,z=r);z!==r;)J.push(z),z=R,ae=R,te++,ce=Ri(),te--,ce===r?ae=void 0:(R=ae,ae=r),ae!==r?(ce=gn(),ce!==r?(ae=[ae,ce],z=ae):(R=z,z=r)):(R=z,z=r);j=[j,J],_=j}else R=_,_=r;return _}function dl(){var _,j,J,z;if(te++,_=R,j=zh(),j!==r){for(J=[],z=Gh();z!==r;)J.push(z),z=Gh();at=_,_=Mp(j,J)}else R=_,_=r;return te--,_===r&&(j=r,te===0&&me(uo)),_}function zh(){var _,j,J;return _=Zp(),_===r&&(e.charCodeAt(R)===36?(_=p,R++):(_=r,te===0&&me(ps)),_===r&&(e.charCodeAt(R)===95?(_=Ce,R++):(_=r,te===0&&me(Us)),_===r&&(_=R,e.charCodeAt(R)===92?(j=Fe,R++):(j=r,te===0&&me(Ln)),j!==r?(J=Yh(),J!==r?_=J:(R=_,_=r)):(R=_,_=r)))),_}function Gh(){var _;return _=zh(),_===r&&(_=Qp(),_===r&&(_=Wh(),_===r&&(_=Xh(),_===r&&(e.charCodeAt(R)===8204?(_=Pe,R++):(_=r,te===0&&me(xt)),_===r&&(e.charCodeAt(R)===8205?(_=rt,R++):(_=r,te===0&&me(yr))))))),_}function Zp(){var _;return _=wl(),_===r&&(_=El(),_===r&&(_=s1(),_===r&&(_=n1(),_===r&&(_=i1(),_===r&&(_=yl()))))),_}function Qp(){var _;return _=Al(),_===r&&(_=Hs()),_}function e1(){var _,j,J;return te++,_=R,j=Ji(),j!==r?(e.charCodeAt(R)===105?(J=tt,R++):(J=r,te===0&&me(ur)),J===r&&(J=null),at=_,_=Rh(j,J)):(R=_,_=r),te--,_===r&&(j=r,te===0&&me(Ze)),_}function Ji(){var _,j,J,z;if(te++,_=R,e.charCodeAt(R)===34?(j=ct,R++):(j=r,te===0&&me(or)),j!==r){for(J=[],z=ne();z!==r;)J.push(z),z=ne();e.charCodeAt(R)===34?(z=ct,R++):(z=r,te===0&&me(or)),z!==r?(at=_,_=qp(J)):(R=_,_=r)}else R=_,_=r;if(_===r)if(_=R,e.charCodeAt(R)===39?(j=ft,R++):(j=r,te===0&&me(Mt)),j!==r){for(J=[],z=he();z!==r;)J.push(z),z=he();e.charCodeAt(R)===39?(z=ft,R++):(z=r,te===0&&me(Mt)),z!==r?(at=_,_=kr(J)):(R=_,_=r)}else R=_,_=r;return te--,_===r&&(j=r,te===0&&me(Wr)),_}function ne(){var _,j,J,z;return _=R,j=R,J=R,te++,e.charCodeAt(R)===34?(z=ct,R++):(z=r,te===0&&me(or)),z===r&&(e.charCodeAt(R)===92?(z=Fe,R++):(z=r,te===0&&me(Ln)),z===r&&(z=Ri())),te--,z===r?J=void 0:(R=J,J=r),J!==r?(z=gn(),z!==r?(J=[J,z],j=J):(R=j,j=r)):(R=j,j=r),j!==r?_=e.substring(_,R):_=j,_===r&&(_=R,e.charCodeAt(R)===92?(j=Fe,R++):(j=r,te===0&&me(Ln)),j!==r?(J=pr(),J!==r?_=J:(R=_,_=r)):(R=_,_=r),_===r&&(_=St())),_}function he(){var _,j,J,z;return _=R,j=R,J=R,te++,e.charCodeAt(R)===39?(z=ft,R++):(z=r,te===0&&me(Mt)),z===r&&(e.charCodeAt(R)===92?(z=Fe,R++):(z=r,te===0&&me(Ln)),z===r&&(z=Ri())),te--,z===r?J=void 0:(R=J,J=r),J!==r?(z=gn(),z!==r?(J=[J,z],j=J):(R=j,j=r)):(R=j,j=r),j!==r?_=e.substring(_,R):_=j,_===r&&(_=R,e.charCodeAt(R)===92?(j=Fe,R++):(j=r,te===0&&me(Ln)),j!==r?(J=pr(),J!==r?_=J:(R=_,_=r)):(R=_,_=r),_===r&&(_=St())),_}function oe(){var _,j,J,z,ae,ce;if(te++,_=R,e.charCodeAt(R)===91?(j=sn,R++):(j=r,te===0&&me(ii)),j!==r){for(e.charCodeAt(R)===94?(J=nr,R++):(J=r,te===0&&me(si)),J===r&&(J=null),z=[],ae=Te(),ae===r&&(ae=Qe());ae!==r;)z.push(ae),ae=Te(),ae===r&&(ae=Qe());e.charCodeAt(R)===93?(ae=_t,R++):(ae=r,te===0&&me(jn)),ae!==r?(e.charCodeAt(R)===105?(ce=tt,R++):(ce=r,te===0&&me(ur)),ce===r&&(ce=null),at=_,_=Hc(J,z,ce)):(R=_,_=r)}else R=_,_=r;return te--,_===r&&(j=r,te===0&&me(Un)),_}function Te(){var _,j,J,z;return _=R,j=Qe(),j!==r?(e.charCodeAt(R)===45?(J=Er,R++):(J=r,te===0&&me(Tr)),J!==r?(z=Qe(),z!==r?(at=_,_=Sa(j,z)):(R=_,_=r)):(R=_,_=r)):(R=_,_=r),_}function Qe(){var _,j,J,z;return _=R,j=R,J=R,te++,e.charCodeAt(R)===93?(z=_t,R++):(z=r,te===0&&me(jn)),z===r&&(e.charCodeAt(R)===92?(z=Fe,R++):(z=r,te===0&&me(Ln)),z===r&&(z=Ri())),te--,z===r?J=void 0:(R=J,J=r),J!==r?(z=gn(),z!==r?(J=[J,z],j=J):(R=j,j=r)):(R=j,j=r),j!==r?_=e.substring(_,R):_=j,_===r&&(_=R,e.charCodeAt(R)===92?(j=Fe,R++):(j=r,te===0&&me(Ln)),j!==r?(J=pr(),J!==r?_=J:(R=_,_=r)):(R=_,_=r),_===r&&(_=St())),_}function St(){var _,j,J;return _=R,e.charCodeAt(R)===92?(j=Fe,R++):(j=r,te===0&&me(Ln)),j!==r?(J=hl(),J!==r?(at=_,_=Ph()):(R=_,_=r)):(R=_,_=r),_}function pr(){var _,j,J,z;return _=Wt(),_===r&&(_=R,e.charCodeAt(R)===48?(j=sr,R++):(j=r,te===0&&me(fr)),j!==r?(J=R,te++,z=Ra(),te--,z===r?J=void 0:(R=J,J=r),J!==r?(at=_,_=Mc()):(R=_,_=r)):(R=_,_=r),_===r&&(_=gl(),_===r&&(_=Yh()))),_}function Wt(){var _;return _=pl(),_===r&&(_=t1()),_}function pl(){var _,j;return e.charCodeAt(R)===39?(_=ft,R++):(_=r,te===0&&me(Mt)),_===r&&(e.charCodeAt(R)===34?(_=ct,R++):(_=r,te===0&&me(or)),_===r&&(e.charCodeAt(R)===92?(_=Fe,R++):(_=r,te===0&&me(Ln)),_===r&&(_=R,e.charCodeAt(R)===98?(j=dt,R++):(j=r,te===0&&me(jc)),j!==r&&(at=_,j=ai()),_=j,_===r&&(_=R,e.charCodeAt(R)===102?(j=zt,R++):(j=r,te===0&&me(oo)),j!==r&&(at=_,j=xh()),_=j,_===r&&(_=R,e.charCodeAt(R)===110?(j=nt,R++):(j=r,te===0&&me(Xr)),j!==r&&(at=_,j=Oh()),_=j,_===r&&(_=R,e.charCodeAt(R)===114?(j=Ke,R++):(j=r,te===0&&me(lo)),j!==r&&(at=_,j=Th()),_=j,_===r&&(_=R,e.charCodeAt(R)===116?(j=ar,R++):(j=r,te===0&&me(ul)),j!==r&&(at=_,j=kh()),_=j,_===r&&(_=R,e.charCodeAt(R)===118?(j=He,R++):(j=r,te===0&&me(ol)),j!==r&&(at=_,j=Nh()),_=j)))))))),_}function t1(){var _,j,J,z;return _=R,j=R,J=R,te++,z=li(),z===r&&(z=Ri()),te--,z===r?J=void 0:(R=J,J=r),J!==r?(z=gn(),z!==r?(J=[J,z],j=J):(R=j,j=r)):(R=j,j=r),j!==r?_=e.substring(_,R):_=j,_}function li(){var _;return _=pl(),_===r&&(_=Ra(),_===r&&(e.charCodeAt(R)===120?(_=Ot,R++):(_=r,te===0&&me(co)),_===r&&(e.charCodeAt(R)===117?(_=an,R++):(_=r,te===0&&me(js))))),_}function gl(){var _,j,J,z,ae,ce;return _=R,e.charCodeAt(R)===120?(j=Ot,R++):(j=r,te===0&&me(co)),j!==r?(J=R,z=R,ae=gs(),ae!==r?(ce=gs(),ce!==r?(ae=[ae,ce],z=ae):(R=z,z=r)):(R=z,z=r),z!==r?J=e.substring(J,R):J=z,J!==r?(at=_,_=Lh(J)):(R=_,_=r)):(R=_,_=r),_}function Yh(){var _,j,J,z,ae,ce,Xt,_r;return _=R,e.charCodeAt(R)===117?(j=an,R++):(j=r,te===0&&me(js)),j!==r?(J=R,z=R,ae=gs(),ae!==r?(ce=gs(),ce!==r?(Xt=gs(),Xt!==r?(_r=gs(),_r!==r?(ae=[ae,ce,Xt,_r],z=ae):(R=z,z=r)):(R=z,z=r)):(R=z,z=r)):(R=z,z=r),z!==r?J=e.substring(J,R):J=z,J!==r?(at=_,_=qn(J)):(R=_,_=r)):(R=_,_=r),_}function Ra(){var _;return Or.test(e.charAt(R))?(_=e.charAt(R),R++):(_=r,te===0&&me(fo)),_}function gs(){var _;return Fi.test(e.charAt(R))?(_=e.charAt(R),R++):(_=r,te===0&&me(ll)),_}function ml(){var _,j;return _=R,e.charCodeAt(R)===46?(j=er,R++):(j=r,te===0&&me(ho)),j!==r&&(at=_,j=Vp()),_=j,_}function Pt(){var _,j,J,z;return te++,_=R,e.charCodeAt(R)===123?(j=s,R++):(j=r,te===0&&me(Yr)),j!==r?(J=r1(),e.charCodeAt(R)===125?(z=u,R++):(z=r,te===0&&me(ds)),z!==r?_=J:(R=_,_=r)):(R=_,_=r),te--,_===r&&(j=r,te===0&&me(po)),_}function r1(){var _,j;return _=R,j=vl(),at=_,j=ui(j),_=j,_}function vl(){var _,j,J,z,ae,ce;if(_=R,j=[],J=[],z=R,ae=R,te++,un.test(e.charAt(R))?(ce=e.charAt(R),R++):(ce=r,te===0&&me(Hn)),te--,ce===r?ae=void 0:(R=ae,ae=r),ae!==r?(ce=gn(),ce!==r?(ae=[ae,ce],z=ae):(R=z,z=r)):(R=z,z=r),z!==r)for(;z!==r;)J.push(z),z=R,ae=R,te++,un.test(e.charAt(R))?(ce=e.charAt(R),R++):(ce=r,te===0&&me(Hn)),te--,ce===r?ae=void 0:(R=ae,ae=r),ae!==r?(ce=gn(),ce!==r?(ae=[ae,ce],z=ae):(R=z,z=r)):(R=z,z=r);else J=r;for(J===r&&(J=R,e.charCodeAt(R)===123?(z=s,R++):(z=r,te===0&&me(Yr)),z!==r?(ae=vl(),e.charCodeAt(R)===125?(ce=u,R++):(ce=r,te===0&&me(ds)),ce!==r?(z=[z,ae,ce],J=z):(R=J,J=r)):(R=J,J=r));J!==r;){if(j.push(J),J=[],z=R,ae=R,te++,un.test(e.charAt(R))?(ce=e.charAt(R),R++):(ce=r,te===0&&me(Hn)),te--,ce===r?ae=void 0:(R=ae,ae=r),ae!==r?(ce=gn(),ce!==r?(ae=[ae,ce],z=ae):(R=z,z=r)):(R=z,z=r),z!==r)for(;z!==r;)J.push(z),z=R,ae=R,te++,un.test(e.charAt(R))?(ce=e.charAt(R),R++):(ce=r,te===0&&me(Hn)),te--,ce===r?ae=void 0:(R=ae,ae=r),ae!==r?(ce=gn(),ce!==r?(ae=[ae,ce],z=ae):(R=z,z=r)):(R=z,z=r);else J=r;J===r&&(J=R,e.charCodeAt(R)===123?(z=s,R++):(z=r,te===0&&me(Yr)),z!==r?(ae=vl(),e.charCodeAt(R)===125?(ce=u,R++):(ce=r,te===0&&me(ds)),ce!==r?(z=[z,ae,ce],J=z):(R=J,J=r)):(R=J,J=r))}return _=e.substring(_,R),_}function El(){var _;return Ft.test(e.charAt(R))?(_=e.charAt(R),R++):(_=r,te===0&&me(x)),_}function n1(){var _;return Ue.test(e.charAt(R))?(_=e.charAt(R),R++):(_=r,te===0&&me(N)),_}function i1(){var _;return De.test(e.charAt(R))?(_=e.charAt(R),R++):(_=r,te===0&&me(V)),_}function s1(){var _;return wr.test(e.charAt(R))?(_=e.charAt(R),R++):(_=r,te===0&&me(Q)),_}function wl(){var _;return on.test(e.charAt(R))?(_=e.charAt(R),R++):(_=r,te===0&&me(ve)),_}function Hs(){var _;return it.test(e.charAt(R))?(_=e.charAt(R),R++):(_=r,te===0&&me(Ae)),_}function Al(){var _;return Da.test(e.charAt(R))?(_=e.charAt(R),R++):(_=r,te===0&&me(Ie)),_}function Wh(){var _;return ln.test(e.charAt(R))?(_=e.charAt(R),R++):(_=r,te===0&&me(xe)),_}function yl(){var _;return ge.test(e.charAt(R))?(_=e.charAt(R),R++):(_=r,te===0&&me(Yt)),_}function Xh(){var _;return Os.test(e.charAt(R))?(_=e.charAt(R),R++):(_=r,te===0&&me(br)),_}function Jh(){var _;return Rt.test(e.charAt(R))?(_=e.charAt(R),R++):(_=r,te===0&&me(hn)),_}function Lt(){var _,j;for(_=[],j=$i(),j===r&&(j=hl(),j===r&&(j=Kh()));j!==r;)_.push(j),j=$i(),j===r&&(j=hl(),j===r&&(j=Kh()));return _}function Zh(){var _,j;for(_=[],j=$i(),j===r&&(j=$a());j!==r;)_.push(j),j=$i(),j===r&&(j=$a());return _}function Pa(){var _,j,J,z;return _=R,j=Lt(),e.charCodeAt(R)===59?(J=Gt,R++):(J=r,te===0&&me(dn)),J!==r?(j=[j,J],_=j):(R=_,_=r),_===r&&(_=R,j=Zh(),J=oi(),J===r&&(J=null),z=hl(),z!==r?(j=[j,J,z],_=j):(R=_,_=r),_===r&&(_=R,j=Lt(),J=xa(),J!==r?(j=[j,J],_=j):(R=_,_=r))),_}function xa(){var _,j;return _=R,te++,e.length>R?(j=e.charAt(R),R++):(j=r,te===0&&me(Ls)),te--,j===r?_=void 0:(R=_,_=r),_}let bl=t.reservedWords||[];if(Bi=a(),Bi!==r&&R===e.length)return Bi;throw Bi!==r&&R{"use strict";var xV=Fp(),OV=g5(),TV=v5(),kV=N2(),NV=["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"],Bh={VERSION:kV,RESERVED_WORDS:NV,GrammarError:xV,parser:TV,compiler:OV,generate(e,t){t=t!==void 0?t:{};function r(a){let s={};return Object.keys(a).forEach(u=>{s[u]=a[u].slice()}),s}let n="plugins"in t?t.plugins:[],i={parser:Bh.parser,passes:r(Bh.compiler.passes),reservedWords:Bh.RESERVED_WORDS.slice()};return n.forEach(a=>{a.use(i,t)}),Bh.compiler.compile(i.parser.parse(e,{grammarSource:t.grammarSource,reservedWords:i.reservedWords}),i.passes,t)}};E5.exports=Bh});var nE=le((tE,rE)=>{(function(e,t){typeof tE=="object"&&typeof rE<"u"?rE.exports=t():typeof define=="function"&&define.amd?define(t):e.JSON5=t()})(tE,function(){"use strict";function e(re,fe){return fe={exports:{}},re(fe,fe.exports),fe.exports}var t=e(function(re){var fe=re.exports=typeof window<"u"&&window.Math==Math?window:typeof self<"u"&&self.Math==Math?self:Function("return this")();typeof __g=="number"&&(__g=fe)}),r=e(function(re){var fe=re.exports={version:"2.6.5"};typeof __e=="number"&&(__e=fe)}),n=r.version,i=function(re){return typeof re=="object"?re!==null:typeof re=="function"},a=function(re){if(!i(re))throw TypeError(re+" is not an object!");return re},s=function(re){try{return!!re()}catch{return!0}},u=!s(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7}),l=t.document,f=i(l)&&i(l.createElement),d=function(re){return f?l.createElement(re):{}},g=!u&&!s(function(){return Object.defineProperty(d("div"),"a",{get:function(){return 7}}).a!=7}),p=function(re,fe){if(!i(re))return re;var Le,Oe;if(fe&&typeof(Le=re.toString)=="function"&&!i(Oe=Le.call(re))||typeof(Le=re.valueOf)=="function"&&!i(Oe=Le.call(re))||!fe&&typeof(Le=re.toString)=="function"&&!i(Oe=Le.call(re)))return Oe;throw TypeError("Can't convert object to primitive value")},h=Object.defineProperty,E=u?Object.defineProperty:function(fe,Le,Oe){if(a(fe),Le=p(Le,!0),a(Oe),g)try{return h(fe,Le,Oe)}catch{}if("get"in Oe||"set"in Oe)throw TypeError("Accessors not supported!");return"value"in Oe&&(fe[Le]=Oe.value),fe},v={f:E},b=function(re,fe){return{enumerable:!(re&1),configurable:!(re&2),writable:!(re&4),value:fe}},m=u?function(re,fe,Le){return v.f(re,fe,b(1,Le))}:function(re,fe,Le){return re[fe]=Le,re},y={}.hasOwnProperty,D=function(re,fe){return y.call(re,fe)},C=0,F=Math.random(),L=function(re){return"Symbol(".concat(re===void 0?"":re,")_",(++C+F).toString(36))},k=!1,S=e(function(re){var fe="__core-js_shared__",Le=t[fe]||(t[fe]={});(re.exports=function(Oe,Ve){return Le[Oe]||(Le[Oe]=Ve!==void 0?Ve:{})})("versions",[]).push({version:r.version,mode:k?"pure":"global",copyright:"\xA9 2019 Denis Pushkarev (zloirock.ru)"})}),B=S("native-function-to-string",Function.toString),O=e(function(re){var fe=L("src"),Le="toString",Oe=(""+B).split(Le);r.inspectSource=function(Ve){return B.call(Ve)},(re.exports=function(Ve,st,ht,Ir){var Ht=typeof ht=="function";Ht&&(D(ht,"name")||m(ht,"name",st)),Ve[st]!==ht&&(Ht&&(D(ht,fe)||m(ht,fe,Ve[st]?""+Ve[st]:Oe.join(String(st)))),Ve===t?Ve[st]=ht:Ir?Ve[st]?Ve[st]=ht:m(Ve,st,ht):(delete Ve[st],m(Ve,st,ht)))})(Function.prototype,Le,function(){return typeof this=="function"&&this[fe]||B.call(this)})}),P=function(re){if(typeof re!="function")throw TypeError(re+" is not a function!");return re},U=function(re,fe,Le){if(P(re),fe===void 0)return re;switch(Le){case 1:return function(Oe){return re.call(fe,Oe)};case 2:return function(Oe,Ve){return re.call(fe,Oe,Ve)};case 3:return function(Oe,Ve,st){return re.call(fe,Oe,Ve,st)}}return function(){return re.apply(fe,arguments)}},Y="prototype",H=function(re,fe,Le){var Oe=re&H.F,Ve=re&H.G,st=re&H.S,ht=re&H.P,Ir=re&H.B,Ht=Ve?t:st?t[fe]||(t[fe]={}):(t[fe]||{})[Y],ni=Ve?r:r[fe]||(r[fe]={}),Yi=ni[Y]||(ni[Y]={}),cn,Dn,Ar,fn;Ve&&(Le=fe);for(cn in Le)Dn=!Oe&&Ht&&Ht[cn]!==void 0,Ar=(Dn?Ht:Le)[cn],fn=Ir&&Dn?U(Ar,t):ht&&typeof Ar=="function"?U(Function.call,Ar):Ar,Ht&&O(Ht,cn,Ar,re&H.U),ni[cn]!=Ar&&m(ni,cn,fn),ht&&Yi[cn]!=Ar&&(Yi[cn]=Ar)};t.core=r,H.F=1,H.G=2,H.S=4,H.P=8,H.B=16,H.W=32,H.U=64,H.R=128;var K=H,W=Math.ceil,ie=Math.floor,Ce=function(re){return isNaN(re=+re)?0:(re>0?ie:W)(re)},Fe=function(re){if(re==null)throw TypeError("Can't call method on "+re);return re},Pe=function(re){return function(fe,Le){var Oe=String(Fe(fe)),Ve=Ce(Le),st=Oe.length,ht,Ir;return Ve<0||Ve>=st?re?"":void 0:(ht=Oe.charCodeAt(Ve),ht<55296||ht>56319||Ve+1===st||(Ir=Oe.charCodeAt(Ve+1))<56320||Ir>57343?re?Oe.charAt(Ve):ht:re?Oe.slice(Ve,Ve+2):(ht-55296<<10)+(Ir-56320)+65536)}},rt=Pe(!1);K(K.P,"String",{codePointAt:function(fe){return rt(this,fe)}});var tt=r.String.codePointAt,ct=Math.max,ft=Math.min,sn=function(re,fe){return re=Ce(re),re<0?ct(re+fe,0):ft(re,fe)},nr=String.fromCharCode,_t=String.fromCodePoint;K(K.S+K.F*(!!_t&&_t.length!=1),"String",{fromCodePoint:function(fe){for(var Le=arguments,Oe=[],Ve=arguments.length,st=0,ht;Ve>st;){if(ht=+Le[st++],sn(ht,1114111)!==ht)throw RangeError(ht+" is not a valid code point");Oe.push(ht<65536?nr(ht):nr(((ht-=65536)>>10)+55296,ht%1024+56320))}return Oe.join("")}});var Er=r.String.fromCodePoint,sr=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,dt=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,zt=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/,nt={Space_Separator:sr,ID_Start:dt,ID_Continue:zt},Ke={isSpaceSeparator:function(fe){return typeof fe=="string"&&nt.Space_Separator.test(fe)},isIdStartChar:function(fe){return typeof fe=="string"&&(fe>="a"&&fe<="z"||fe>="A"&&fe<="Z"||fe==="$"||fe==="_"||nt.ID_Start.test(fe))},isIdContinueChar:function(fe){return typeof fe=="string"&&(fe>="a"&&fe<="z"||fe>="A"&&fe<="Z"||fe>="0"&&fe<="9"||fe==="$"||fe==="_"||fe==="\u200C"||fe==="\u200D"||nt.ID_Continue.test(fe))},isDigit:function(fe){return typeof fe=="string"&&/[0-9]/.test(fe)},isHexDigit:function(fe){return typeof fe=="string"&&/[0-9A-Fa-f]/.test(fe)}},ar,He,Ot,an,er,Gt,vt,Or,Fi,un=function(fe,Le){ar=String(fe),He="start",Ot=[],an=0,er=1,Gt=0,vt=void 0,Or=void 0,Fi=void 0;do vt=Da(),bu[He]();while(vt.type!=="eof");return typeof Le=="function"?Ft({"":Fi},"",Le):Fi};function Ft(re,fe,Le){var Oe=re[fe];if(Oe!=null&&typeof Oe=="object")if(Array.isArray(Oe))for(var Ve=0;Ve0;){var Le=ln();if(!Ke.isHexDigit(Le))throw Tt(ge());re+=ge()}return String.fromCodePoint(parseInt(re,16))}var bu={start:function(){if(vt.type==="eof")throw ri();ks()},beforePropertyName:function(){switch(vt.type){case"identifier":case"string":Or=vt.value,He="afterPropertyName";return;case"punctuator":ps();return;case"eof":throw ri()}},afterPropertyName:function(){if(vt.type==="eof")throw ri();He="beforePropertyValue"},beforePropertyValue:function(){if(vt.type==="eof")throw ri();ks()},beforeArrayValue:function(){if(vt.type==="eof")throw ri();if(vt.type==="punctuator"&&vt.value==="]"){ps();return}ks()},afterPropertyValue:function(){if(vt.type==="eof")throw ri();switch(vt.value){case",":He="beforePropertyName";return;case"}":ps()}},afterArrayValue:function(){if(vt.type==="eof")throw ri();switch(vt.value){case",":He="beforeArrayValue";return;case"]":ps()}},end:function(){}};function ks(){var re;switch(vt.type){case"punctuator":switch(vt.value){case"{":re={};break;case"[":re=[];break}break;case"null":case"boolean":case"numeric":case"string":re=vt.value;break}if(Fi===void 0)Fi=re;else{var fe=Ot[Ot.length-1];Array.isArray(fe)?fe.push(re):Object.defineProperty(fe,Or,{value:re,writable:!0,enumerable:!0,configurable:!0})}if(re!==null&&typeof re=="object")Ot.push(re),Array.isArray(re)?He="beforeArrayValue":He="beforePropertyName";else{var Le=Ot[Ot.length-1];Le==null?He="end":Array.isArray(Le)?He="afterArrayValue":He="afterPropertyValue"}}function ps(){Ot.pop();var re=Ot[Ot.length-1];re==null?He="end":Array.isArray(re)?He="afterArrayValue":He="afterPropertyValue"}function Tt(re){return Ns(re===void 0?"JSON5: invalid end of input at "+er+":"+Gt:"JSON5: invalid character '"+Du(re)+"' at "+er+":"+Gt)}function ri(){return Ns("JSON5: invalid end of input at "+er+":"+Gt)}function _u(){return Gt-=5,Ns("JSON5: invalid identifier character at "+er+":"+Gt)}function Cu(re){console.warn("JSON5: '"+Du(re)+"' in strings is not valid ECMAScript; consider escaping")}function Du(re){var fe={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};if(fe[re])return fe[re];if(re<" "){var Le=re.charCodeAt(0).toString(16);return"\\x"+("00"+Le).substring(Le.length)}return re}function Ns(re){var fe=new SyntaxError(re);return fe.lineNumber=er,fe.columnNumber=Gt,fe}var so=function(fe,Le,Oe){var Ve=[],st="",ht,Ir,Ht="",ni;if(Le!=null&&typeof Le=="object"&&!Array.isArray(Le)&&(Oe=Le.space,ni=Le.quote,Le=Le.replacer),typeof Le=="function")Ir=Le;else if(Array.isArray(Le)){ht=[];for(var Yi=0,cn=Le;Yi0&&(Oe=Math.min(10,Math.floor(Oe)),Ht=" ".substr(0,Oe)):typeof Oe=="string"&&(Ht=Oe.substr(0,10)),fn("",{"":fe});function fn(xt,yr){var Ze=yr[xt];switch(Ze!=null&&(typeof Ze.toJSON5=="function"?Ze=Ze.toJSON5(xt):typeof Ze.toJSON=="function"&&(Ze=Ze.toJSON(xt))),Ir&&(Ze=Ir.call(yr,xt,Ze)),Ze instanceof Number?Ze=Number(Ze):Ze instanceof String?Ze=String(Ze):Ze instanceof Boolean&&(Ze=Ze.valueOf()),Ze){case null:return"null";case!0:return"true";case!1:return"false"}if(typeof Ze=="string")return Mr(Ze,!1);if(typeof Ze=="number")return String(Ze);if(typeof Ze=="object")return Array.isArray(Ze)?Ln(Ze):uo(Ze)}function Mr(xt){for(var yr={"'":.1,'"':.2},Ze={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"},ur="",Wr=0;Wr=0)throw TypeError("Converting circular structure to JSON5");Ve.push(xt);var yr=st;st=st+Ht;for(var Ze=ht||Object.keys(xt),ur=[],Wr=0,or=Ze;Wr=0)throw TypeError("Converting circular structure to JSON5");Ve.push(xt);var yr=st;st=st+Ht;for(var Ze=[],ur=0;ur{let t={};return e.forEach((r,n)=>t[r]=n),t})(ff),L9=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,vn=String.fromCharCode.bind(String),eA=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):e=>new Uint8Array(Array.prototype.slice.call(e,0)),iA=e=>e.replace(/=/g,"").replace(/[+\/]/g,t=>t=="+"?"-":"_"),sA=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),aA=e=>{let t,r,n,i,a="",s=e.length%3;for(let u=0;u255||(n=e.charCodeAt(u++))>255||(i=e.charCodeAt(u++))>255)throw new TypeError("invalid character found");t=r<<16|n<<8|i,a+=ff[t>>18&63]+ff[t>>12&63]+ff[t>>6&63]+ff[t&63]}return s?a.slice(0,s-3)+"===".substring(s):a},rg=typeof btoa=="function"?e=>btoa(e):Pl?e=>Buffer.from(e,"binary").toString("base64"):aA,eg=Pl?e=>Buffer.from(e).toString("base64"):e=>{let r=[];for(let n=0,i=e.length;nt?iA(eg(e)):eg(e),U9=e=>{if(e.length<2){var t=e.charCodeAt(0);return t<128?e:t<2048?vn(192|t>>>6)+vn(128|t&63):vn(224|t>>>12&15)+vn(128|t>>>6&63)+vn(128|t&63)}else{var t=65536+(e.charCodeAt(0)-55296)*1024+(e.charCodeAt(1)-56320);return vn(240|t>>>18&7)+vn(128|t>>>12&63)+vn(128|t>>>6&63)+vn(128|t&63)}},j9=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,uA=e=>e.replace(j9,U9),tA=Pl?e=>Buffer.from(e,"utf8").toString("base64"):Qw?e=>eg(Qw.encode(e)):e=>rg(uA(e)),Rl=(e,t=!1)=>t?iA(tA(e)):tA(e),rA=e=>Rl(e,!0),H9=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,M9=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 vn((r>>>10)+55296)+vn((r&1023)+56320);case 3:return vn((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return vn((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},oA=e=>e.replace(H9,M9),lA=e=>{if(e=e.replace(/\s+/g,""),!L9.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?vn(t>>16&255,t>>8&255):vn(t>>16&255,t>>8&255,t&255);return r},ng=typeof atob=="function"?e=>atob(sA(e)):Pl?e=>Buffer.from(e,"base64").toString("binary"):lA,cA=Pl?e=>eA(Buffer.from(e,"base64")):e=>eA(ng(e).split("").map(t=>t.charCodeAt(0))),fA=e=>cA(hA(e)),q9=Pl?e=>Buffer.from(e,"base64").toString("utf8"):Zw?e=>Zw.decode(cA(e)):e=>oA(ng(e)),hA=e=>sA(e.replace(/[-_]/g,t=>t=="-"?"+":"/")),tg=e=>q9(hA(e)),V9=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)},dA=e=>({value:e,enumerable:!1,writable:!0,configurable:!0}),pA=function(){let e=(t,r)=>Object.defineProperty(String.prototype,t,dA(r));e("fromBase64",function(){return tg(this)}),e("toBase64",function(t){return Rl(this,t)}),e("toBase64URI",function(){return Rl(this,!0)}),e("toBase64URL",function(){return Rl(this,!0)}),e("toUint8Array",function(){return fA(this)})},gA=function(){let e=(t,r)=>Object.defineProperty(Uint8Array.prototype,t,dA(r));e("toBase64",function(t){return B0(this,t)}),e("toBase64URI",function(){return B0(this,!0)}),e("toBase64URL",function(){return B0(this,!0)})},K9=()=>{pA(),gA()},Dt={version:nA,VERSION:k9,atob:ng,atobPolyfill:lA,btoa:rg,btoaPolyfill:aA,fromBase64:tg,toBase64:Rl,encode:Rl,encodeURI:rA,encodeURL:rA,utob:uA,btou:oA,decode:tg,isValid:V9,fromUint8Array:B0,toUint8Array:fA,extendString:pA,extendUint8Array:gA,extendBuiltins:K9};var Tu=typeof $task<"u",Va=typeof $loon<"u",ku=typeof $httpClient<"u"&&!Va,Ks=eval('typeof process !== "undefined"'),mA=typeof $environment<"u"&&$environment["stash-version"],vA=typeof $rocket<"u",z9=typeof egern=="object",G9=typeof $native<"u",Nu=typeof $Plugins<"u";function $0(e){return e!==null&&typeof e=="object"&&[null,Object.prototype].includes(Object.getPrototypeOf(e))}function Y9(e){let[t,r,n,i,a,s,u]=e.match(/^socks5:\/\/(?:(.*?):(.*?)@)?(.*?)(?::(\d+?))?(\?.*?)?(?:#(.*?))?$/);if(a)a=parseInt(a,10);else throw $.error(`port is not present in line: ${e}`),new Error(`port is not present in line: ${e}`);return{type:5,host:i,port:a,userId:r!=null?decodeURIComponent(r):void 0,password:n!=null?decodeURIComponent(n):void 0}}var R0=class{constructor(name="untitled",debug=!1){if(this.name=name,this.debug=debug,this.http=As(),this.env=ki(),Ks){let dotenv=eval('require("dotenv")');dotenv.config()}this.node=(()=>{if(Ks){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(Tu&&(this.cache=JSON.parse($prefs.valueForKey(this.name)||"{}")),(Va||ku)&&(this.cache=JSON.parse($persistentStore.read(this.name)||"{}")),Nu&&(this.cache=JSON.parse($Plugins.SubStoreCache.get(this.name)||"{}")),Ks){let basePath=eval("process.env.SUB_STORE_DATA_BASE_PATH")||".",rootPath=`${basePath}/root.json`,backupRootPath=`${basePath}/root_${Date.now()}.json`;if(this.log(`Root path: ${rootPath}`),this.node.fs.existsSync(rootPath))try{this.root=JSON.parse(this.node.fs.readFileSync(`${rootPath}`))}catch(e){this.node.fs.copyFileSync(rootPath,backupRootPath),this.error(`Failed to parse ${rootPath}: ${e.message}. Backup created at ${backupRootPath}`)}$0(this.root)||(this.node.fs.writeFileSync(rootPath,JSON.stringify({}),{flag:"w"}),this.root={});let fpath=`${basePath}/${this.name}.json`,backupPath=`${basePath}/${this.name}_${Date.now()}.json`;if(this.log(`Data path: ${fpath}`),this.node.fs.existsSync(fpath))try{if(this.cache=JSON.parse(this.node.fs.readFileSync(`${fpath}`,"utf-8")),!$0(this.cache))throw new Error("Invalid Data")}catch{try{let t=Dt.decode(this.node.fs.readFileSync(`${fpath}`,"utf-8"));if(this.cache=JSON.parse(t),this.node.fs.writeFileSync(fpath,t,{flag:"w"}),!$0(this.cache))throw new Error("Invalid Data")}catch(t){this.node.fs.copyFileSync(fpath,backupPath),this.error(`Failed to parse ${fpath}: ${t.message}. Backup created at ${backupPath}`)}}$0(this.cache)||(this.node.fs.writeFileSync(fpath,JSON.stringify({}),{flag:"w"}),this.cache={})}}persistCache(){let data=JSON.stringify(this.cache,null,2);if(Tu&&$prefs.setValueForKey(data,this.name),(Va||ku)&&$persistentStore.write(data,this.name),Nu&&$Plugins.SubStoreCache.set(this.name,data),Ks){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),ku||Va)return $persistentStore.write(e,t);if(Tu)return $prefs.setValueForKey(e,t);if(Ks&&(this.root[t]=e),Nu)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),ku||Va)return $persistentStore.read(e);if(Tu)return $prefs.valueForKey(e);if(Ks)return this.root[e];if(Nu)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),ku||Va)return $persistentStore.write(null,e);if(Tu)return $prefs.removeValueForKey(e);if(Ks&&delete this.root[e],Nu)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(Tu&&$notify(title,subtitle,content,options),ku&&$notification.post(title,subtitle,content+`${mediaURL?` \u591A\u5A92\u4F53:`+mediaURL:""}`,{url:openURL}),Va){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(Ks){let content_=content+(openURL?` \u70B9\u51FB\u8DF3\u8F6C: ${openURL}`:"")+(mediaURL?` \u591A\u5A92\u4F53: ${mediaURL}`:"");console.log(`${title} ${subtitle} ${content_} `);let push=eval("process.env.SUB_STORE_PUSH_SERVICE");if(push)if(/^https?:\/\//.test(push)){let e=push.replace("[\u63A8\u9001\u6807\u9898]",encodeURIComponent(title||"Sub-Store")).replace("[\u63A8\u9001\u5185\u5BB9]",encodeURIComponent([subtitle,content_].map(r=>r).join(` `)));As().get({url:e}).then(r=>{console.log(`[Push Service] URL: ${e} RES: ${r.statusCode} ${r.body}`)}).catch(r=>{console.log(`[Push Service] URL: ${e} ERROR: ${r}`)})}else{let{execFile}=eval('require("child_process")');execFile("shoutrrr",["send","--url",push,"--message",`${title} ${subtitle} ${content_}`],(e,t,r)=>{if(e){console.log(`[Push Service] URL: ${push} ERROR: ${e}`);return}r&&console.log(`[Push Service] URL: ${push} stderr: ${r}`),console.log(`[Push Service] URL: ${push} stdout: ${t}`)})}}Nu&&$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={}){Tu||Va||ku||Nu?$done(e):Ks&&typeof $context<"u"&&($context.headers=e.headers,$context.statusCode=e.statusCode,$context.body=e.body)}};function ki(){return{isQX:Tu,isLoon:Va,isSurge:ku,isNode:Ks,isStash:mA,isShadowRocket:vA,isEgern:z9,isLanceX:G9,isGUIforCores:Nu}}function As(defaultOptions={baseURL:""}){let{isQX,isLoon,isSurge,isNode,isGUIforCores}=ki(),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||mA||vA)&&(opts.timeout=Math.ceil(opts.timeout/1e3),e="s")}if(isNode){let undici=eval("require('undici')"),{socksDispatcher}=eval("require('fetch-socks')"),{ProxyAgent,EnvHttpProxyAgent,request,interceptors}=undici,agentOpts={connect:{rejectUnauthorized:!(opts.strictSSL===!1||opts.insecure===!0||opts.rejectUnauthorized===!1)},bodyTimeout:opts.timeout,headersTimeout:opts.timeout,maxHeaderSize:eval("process.env.SUB_STORE_MAX_HEADER_SIZE")||32*1024},tlsOptions={rejectUnauthorized:agentOpts.connect.rejectUnauthorized};opts.tls={...opts.tls||{},...tlsOptions};try{let url=new URL(opts.url);(url.username||url.password)&&(opts.headers={...opts.headers||{},Authorization:`Basic ${Buffer.from(`${url.username||""}:${url.password||""}`).toString("base64")}`});let dispatcher;if(!opts.proxy){let allProxy=eval("process.env.all_proxy")||eval("process.env.ALL_PROXY");allProxy&&/^socks5:\/\//.test(allProxy)&&(opts.proxy=allProxy)}opts.proxy?/^socks5:\/\//.test(opts.proxy)?dispatcher=socksDispatcher(Y9(opts.proxy),{...agentOpts,requestTls:tlsOptions}):dispatcher=new ProxyAgent({...agentOpts,uri:opts.proxy,requestTls:tlsOptions}):dispatcher=new EnvHttpProxyAgent({...agentOpts,requestTls:tlsOptions});let response=await request(opts.url,{...opts,method:method.toUpperCase(),dispatcher:dispatcher.compose(interceptors.redirect({maxRedirections:3,throwOnMaxRedirects:!0}))});resolve({statusCode:response.statusCode,headers:response.headers,body:opts.encoding===null?await response.body.arrayBuffer():await response.body.text()})}catch(e){reject(e)}}else $httpClient[method.toLowerCase()](opts,(e,t,r)=>{e?reject(e):resolve({statusCode:t.status||t.statusCode,headers:t.headers,body:r})})}):isGUIforCores&&(worker=new Promise(async(e,t)=>{try{let r=await $Plugins.Requests({method,url:options.url,headers:options.headers,body:options.body,autoTransformBody:!1,options:{Proxy:options.proxy,Timeout:options.timeout?options.timeout/1e3:15}});e({statusCode:r.status,headers:r.headers,body:r.body})}catch(r){t(r)}}));let timeoutid,timer=timeout?new Promise((e,t)=>{timeoutid=setTimeout(()=>(events.onTimeout(),t(`${method} URL: ${options.url} exceeds the timeout ${timeout} ms`)),timeout)}):null;return(timer?Promise.race([timer,worker]).then(e=>(typeof clearTimeout<"u"&&clearTimeout(timeoutid),e)):worker).then(e=>events.onResponse(e))}let http={};return methods.forEach(e=>http[e.toLowerCase()]=t=>send(e,t)),http}var W9=new R0("sub-store"),G=W9;function ig(){X9()}function X9(){let e=G.read(Z1);e||J9(),e!=="2.0"&&G.write("2.0",Z1)}function J9(){G.info("Start migrating...");let e=G.read(is)||{},t=Object.values(e).map(E=>(E.source=E.source||"remote",p(E),h(E),E));G.write(t,is);let r=G.read(Ou)||{},n=Object.values(r).map(E=>(delete E.ua,p(E),h(E),E));G.write(n,Ou);let i=G.read(ws)||{},a=Object.values(i);G.write(a,ws);let s=G.read(cf)||{},u=Object.values(s);G.write(u,cf);let l=G.read(qa)||{},f=Object.values(l);G.write(f,qa);let d=G.read(Q1)||{},g=Object.values(d);G.write(g,Q1),delete G.cache.builtin,G.info("Migration complete!");function p(E){let v=E["display-name"];v&&(E.displayName=v,delete E["display-name"])}function h(E){let v=E.process;if(!v||v.length===0)return;let b=[],m={type:"Quick Setting Operator",args:{udp:"DEFAULT",tfo:"DEFAULT",scert:"DEFAULT","vmess aead":"DEFAULT",useless:"DEFAULT"}};for(let y of v)if(y.type){if(y.type==="Useless Filter")m.args.useless="ENABLED";else if(y.type==="Set Property Operator"){let{key:D,value:C}=y.args;switch(D){case"udp":m.args.udp=C?"ENABLED":"DISABLED";break;case"tfo":m.args.tfo=C?"ENABLED":"DISABLED";break;case"skip-cert-verify":m.args.scert=C?"ENABLED":"DISABLED";break;case"aead":m.args["vmess aead"]=C?"ENABLED":"DISABLED";break}}else if(y.type.indexOf("Keyword")===-1)if(y.type==="Flag Operator"){let D=typeof y.args>"u"?!0:y.args;y.args={mode:D?"add":"remove"},b.push(y)}else b.push(y)}b.unshift(m),E.process=b}}function sg({substore:$,port,host}){let{isNode}=ki(),DEFAULT_HEADERS={"Content-Type":"text/plain;charset=UTF-8","Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"POST,GET,OPTIONS,PATCH,PUT,DELETE","Access-Control-Allow-Headers":"Origin, X-Requested-With, Content-Type, Accept","X-Powered-By":isNode&&eval("process.env.SUB_STORE_X_POWERED_BY")||"Sub-Store"};if(isNode){let express_=eval('require("express")'),bodyParser=eval('require("body-parser")'),app=express_(),limit=eval("process.env.SUB_STORE_BODY_JSON_LIMIT")||"1mb";return $.info(`[BACKEND] body JSON limit: ${limit}`),app.use(bodyParser.json({verify:rawBodySaver,limit})),app.use(bodyParser.urlencoded({verify:rawBodySaver,extended:!0})),app.use(bodyParser.raw({verify:rawBodySaver,type:"*/*"})),app.use((e,t,r)=>{t.set(DEFAULT_HEADERS),r()}),app.start=()=>{app.get("*",function(t,r){r.status(404).end()});let e=app.listen(port,host,()=>{let{address:t,port:r}=e.address();$.info(`[BACKEND] listening on ${t}:${r}`)})},app}let handlers=[],METHODS_NAMES=["GET","POST","PUT","DELETE","PATCH","OPTIONS","HEAD'","ALL"],dispatch=(e,t=0)=>{let{method:r,url:n,headers:i,body:a}=e;i=Z9(i),/json/i.test(i["content-type"])&&(a=JSON.parse(a)),r=r.toUpperCase();let{path:s,query:u}=e7(n),l=null,f,d=0;for(f=t;fd&&(l=handlers[f],d=g.split("/").length)}if(l){let g=()=>{dispatch(r,n,f)},p={method:r,url:n,path:s,query:u,params:EA(l.pattern,s),headers:i,body:a},h=Response(),E=l.callback,v=b=>{h.status(500).json({status:"failed",message:`Internal Server Error: ${b}`})};if(E.constructor.name==="AsyncFunction")E(p,h,g).catch(v);else try{E(p,h,g)}catch(b){v(b)}}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}=ki(),a=DEFAULT_HEADERS,s={200:"HTTP/1.1 200 OK",201:"HTTP/1.1 201 Created",302:"HTTP/1.1 302 Found",307:"HTTP/1.1 307 Temporary Redirect",308:"HTTP/1.1 308 Permanent Redirect",404:"HTTP/1.1 404 Not Found",500:"HTTP/1.1 500 Internal Server Error"};return new class{status(u){return e=u,this}send(u=""){let l={status:t?s[e]:e,body:u,headers:a};t||i?$done(l):(r||n)&&$done({response:l})}end(){this.send()}html(u){this.set("Content-Type","text/html;charset=UTF-8"),this.send(u)}json(u){this.set("Content-Type","application/json;charset=UTF-8"),this.send(JSON.stringify(u))}set(u,l){return a[u]=l,this}}}}function Z9(e){let t={};for(let r of Object.keys(e))t[r.toLowerCase()]=e[r];return t}function Q9(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=9860||r==="Surge"&&i>=3613)return!0}catch{}return!1}var Op=Zr(j0());var Hg=Zr(xy());function ZP(e){let t=Hg.default.pemtohex(e);return Hg.default.KJUR.crypto.Util.hashHex(t,"sha256").match(/.{2}/g).join(":").toUpperCase()}var Oy={generateFingerprint:ZP};var Df=Zr(F_());function I_(e,t,...r){try{return e(t,...r)}catch{return e(B_(e(t.replace(/!\s*/g,"__SubStoreJSYAMLString__"),...r)).replace(/__SubStoreJSYAMLString__/g,""),...r)}}function Cf(e,...t){return I_(Df.default.safeLoad,JSON.parse(JSON.stringify(e)),...t)}function BT(e,...t){return I_(Df.default.load,JSON.parse(JSON.stringify(e)),...t)}function S_(e,...t){return Df.default.safeDump(JSON.parse(JSON.stringify(e)),...t)}function B_(e,...t){return Df.default.dump(JSON.parse(JSON.stringify(e)),...t)}var Xs={safeLoad:Cf,load:BT,safeDump:S_,dump:B_,parse:Cf,stringify:S_};var em=0;function bs(e){return RT($T(PT(e)))}function $T(e){return OT(TT(xT(e),e.length*8))}function RT(e){try{}catch{em=0}for(var t=em?"0123456789ABCDEF":"0123456789abcdef",r="",n,i=0;i>>4&15)+t.charAt(n&15);return r}function PT(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 xT(e){for(var t=Array(e.length>>2),r=0;r>5]|=(e.charCodeAt(r/8)&255)<>5]>>>r%32&255);return t}function TT(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 kT(e,t){return e<>>32-t}var yd=Zr(M_()),ok=/^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)(\.(?!$)|$)){4}$/,lk=/^(([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 Ur(e){return ok.test(e)}function Rr(e){return lk.test(e)}function q_(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 ta(e){return typeof e=="string"&&e.trim().length>0}function rr(e,t){return ta(e)?e:t}function tc(e){return typeof e<"u"&&e!==null}function rc(e,t){return tc(e)?e:t}function Za(e){return e?/^.+?\s*?=\s*?.+?\s*?,.+?/.test(e)?{"policy-descriptor":e}:{policy:e}:{}}function ck(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e}function If(e){let t=e.split(/,|\//),r=t[Math.floor(Math.random()*t.length)];if(r.includes("-")){let[n,i]=r.split("-").map(Number);return ck(n,i)}else return Number(r)}function V_(e){return Number.isSafeInteger(e)?String(e):BigInt(e).toString()}function bd(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 hm=class{constructor(t){this.expires=t,G.read(So)||G.write("{}",So);try{this.resourceCache=JSON.parse(G.read(So))}catch(r){G.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${So} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${r?.message??r}`),this.resourceCache={},G.write("{}",So)}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),So)}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()}},rn=new hm(36e5);var dm=class{constructor(){this.expires=hk(),G.read(Io)||G.write("{}",Io);try{this.resourceCache=JSON.parse(G.read(Io))}catch(t){G.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${Io} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${t?.message??t}`),this.resourceCache={},G.write("{}",Io)}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),Io)}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 hk(){G.read(F0)||G.write("6e4",F0);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(F0),e}var Bf=new dm;function nc(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 ra(rawUrl,ua,timeout,customProxy,flowUrl){let url=flowUrl||rawUrl||"",$arguments={},rawArgs=url.split("#");if(url=url.split("#")[0],rawArgs.length>1)try{$arguments=JSON.parse(decodeURIComponent(rawArgs[1]))}catch{for(let t of rawArgs[1].split("&")){let r=t.split("=")[0],n=t.split("=")[1];$arguments[r]=n==null||n===""?!0:decodeURIComponent(n)}}if($arguments?.noFlow||!/^https?/.test(url))return;let{isStash,isLoon,isShadowRocket,isQX}=ki(),insecure=$arguments?.insecure?G.env.isNode?{strictSSL:!1}:{insecure:!0}:void 0,{defaultProxy,defaultFlowUserAgent,defaultTimeout}=G.read(ns),proxy=customProxy||defaultProxy;G.env.isNode&&(proxy=proxy||eval("process.env.SUB_STORE_BACKEND_DEFAULT_PROXY"));let userAgent=ua||defaultFlowUserAgent||"clash.meta/v1.19.16",requestTimeout=timeout||defaultTimeout||8e3,id=bs(userAgent+url),cached=Bf.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=As();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,statusCode:r}=await e.get({url:flowUrl,headers:{"User-Agent":userAgent},timeout:requestTimeout,...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?Za(proxy):{},...insecure||{}});if(r<200||r>=400)throw new Error(`statusCode: ${r}`);flowInfo=t}else{try{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?Za(proxy):{},...insecure||{}});flowInfo=nc(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?Za(proxy):{},...insecure||{}});flowInfo=nc(t)}}flowInfo&&(flowInfo=flowInfo.trim()),flowInfo&&Bf.set(id,flowInfo)}return flowInfo}function _d(e){if(!e)return;let t=e.match(/upload=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),r=t==null?0:Number(t[1]+t[2]),n=e.match(/download=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),i=Number(n[1]+n[2]),a=e.match(/total=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),s=Number(a[1]+a[2]),u=e.match(/expire=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),l=u?Number(u[1]+u[2]):void 0,f=e.match(/reset_day=([0-9]+)/),d=f?Number(f[1]):void 0,g=e.match(/app_url=(.*?)\s*?(;|$)/),p=g?decodeURIComponent(g[1]):void 0,h=e.match(/plan_name=(.*?)\s*?(;|$)/),E=h?decodeURIComponent(h[1]):void 0;return{expires:l,total:s,usage:{upload:r,download:i},remainingDays:d,appUrl:p,planName:E}}function $f(e,t="B"){let r=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],n=r.indexOf(t);return e<1024||n===r.length-1?{value:(Math.round(e*100)/100).toString(),unit:t}:$f(e/1024,r[++n])}function Cd(e){if(!e)throw new Error("\u6CA1\u6709\u6D41\u91CF\u4FE1\u606F");if(e?.expires&&e.expires*1e3a.getTime())throw new Error("\u5F00\u59CB\u65E5\u671F\u5E94\u65E9\u4E8E\u73B0\u5728");let s=new Date(r);for(s.setDate(s.getDate()+n);s31)throw new Error("\u6708\u91CD\u7F6E\u65E5\u5E94\u4E3A 1-31 \u4E4B\u95F4\u7684\u6574\u6570");let i=new Date,a=i.getDate(),s=i.getMonth(),u=i.getFullYear(),l;return t>a?l=0:l=new Date(u,s+1,0).getDate(),l-a+t}}catch(t){G.error(`getRmainingDays failed: ${t.message??t}`)}}function ic(e){try{let t=new Map;return e.split(";").map(r=>r.trim()).filter(Boolean).forEach(r=>{let n=r.indexOf("=");if(n===-1)return;let i=r.slice(0,n).trim(),a=r.slice(n+1).trim();if(!t.has(i))try{let s=decodeURIComponent(a);if(["upload","download","total","expire"].includes(i))try{s=Number(s).toFixed(0),["expire"].includes(i)&&s<=0&&(s="")}catch(u){G.error(`Failed to convert value for key "${i}=${a}": ${u.message??u}`)}t.set(i,s)}catch{t.set(i,a)}}),Array.from(t.entries()).map(([r,n])=>`${r}=${encodeURIComponent(n)}`).join("; ")}catch(t){return G.error(`normalizeFlowHeader failed: ${t.message??t}`),e}}function Pr(e,t,r="name"){return e.find(n=>n[r]===t)}function na(e,t,r){e.status(r||200).json({status:"success",data:t})}function En(e,t,r){e.status(r||500).json({status:"failed",error:{code:t.code,type:t.type,message:t.message,details:e.req?.route?.path?.startsWith("/share/")?"\u8BE6\u60C5\u8BF7\u67E5\u770B\u65E5\u5FD7":t.details}})}var Rf=class{constructor(t,r,n){this.code=t,this.message=r,this.details=n}},Li=class extends Rf{constructor(t,r,n){super(t,r,n),this.type="InternalServerError"}};var Qa=class extends Rf{constructor(t,r,n){super(t,r,n),this.type="ResourceNotFoundError"}},Dd=class extends Rf{constructor(t,r,n){super(t,r,n),this.type="NetworkError"}};function dk(){return{name:"HTML",test:n=>/^/.test(n),parse:()=>""}}function pk(){return{name:"Clash Provider",test:n=>/^payload:/gm.exec(n).index>=0,parse:n=>n.replace("payload:","").replace(/^\s*-\s*/gm,"")}}var z_=[dk(),pk()];function gk(){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 G_(){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 mk(){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))),G_().func(r))}}function vk(){return{type:"ALL",func:r=>{let n={"DEST-PORT":"DST-PORT","SRC-IP":"SRC-IP-CIDR","IN-PORT":"SRC-PORT"},i={payload:r.map(a=>{let s=`${n[a.type]||a.type},${a.content}`;return["IP-CIDR","IP-CIDR6","GEOIP"].includes(a.type)&&(a.options&&(a.options=a.options.filter(u=>["no-resolve"].includes(u))),s+=a.options?.length>0?`,${a.options.join(",")}`:""),s})};return Xs.dump(i)}}}var Y_={QX:gk(),Surge:G_(),Loon:mk(),Clash:vk()};var Ek=[[/^(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 wk(){return{name:"Universal Rule Parser",test:()=>!0,parse:n=>{let i=n.split(` `),a=[];for(let s of i)if(s=s.trim(),s.length!==0&&!/\s*#/.test(s))try{let u=s.split(",").map(d=>d.trim()),l=u[0],f=!1;for(let d of Ek)if(d[0].test(l)){f=!0;let p={type:d[1],content:u[1]};["IP-CIDR","IP-CIDR6","GEOIP"].includes(p.type)&&(p.options=u.slice(2)),a.push(p)}if(!f)throw new Error("Invalid rule type: "+l)}catch(u){console.log(`Failed to parse line: ${s} Reason: ${u}`)}return a}}}var W_=[wk()];var Fd=function(){function e(n){for(let i of z_)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 W_){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=Y_[i];if(!a)throw new Error(`Target platform: ${i} is not supported!`);if(typeof a.type>"u"||a.type==="SINGLE")return n.map(s=>{try{return a.func(s)}catch(u){return console.log(`ERROR: cannot produce rule: ${JSON.stringify(s)} Reason: ${u}`),""}}).filter(s=>s.length>0).join(` `);if(a.type==="ALL")return a.func(n)}return{parse:t,produce:r}}();var qo=class{constructor({token,key,syncPlatform}){let{isStash,isLoon,isShadowRocket,isQX}=ki(),{defaultProxy,defaultTimeout:timeout,githubProxy}=G.read(ns),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=As({baseURL:"https://gitlab.com/api/v4",headers:{...this.headers,...isStash&&proxy?{"X-Stash-Selected-Proxy":encodeURIComponent(proxy)}:{},...isShadowRocket&&proxy?{"X-Surge-Policy":proxy}:{}},...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?Za(proxy):{},timeout:timeout||8e3,events:{onResponse:e=>{if(/^[45]/.test(String(e.statusCode))){let t=JSON.parse(e.body);return Promise.reject(`ERROR: ${t.message?.error??t.message}`)}else return e}}})):(this.headers={Authorization:`token ${token}`,"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36"},this.http=As({baseURL:`${githubProxy?`${githubProxy}/`:""}https://api.github.com`,headers:{...this.headers,...isStash&&proxy?{"X-Stash-Selected-Proxy":encodeURIComponent(proxy)}:{},...isShadowRocket&&proxy?{"X-Surge-Policy":proxy}:{}},...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?Za(proxy):{},timeout:timeout||8e3,events:{onResponse:e=>/^[45]/.test(String(e.statusCode))?Promise.reject(`ERROR: ${JSON.parse(e.body).message}`):e}})),this.key=key,this.syncPlatform=syncPlatform}async locate(){return this.syncPlatform==="gitlab"?this.http.get("/snippets").then(e=>{let t=JSON.parse(e.body);for(let r of t)if(r.title===this.key)return r}):this.http.get("/gists?per_page=100&page=1").then(e=>{let t=JSON.parse(e.body);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 pm(e){let{gistToken:t,syncPlatform:r}=G.read(ns);if(!t)return Promise.reject("\u672A\u8BBE\u7F6E GitHub Token\uFF01");let i=await new qo({token:t,key:Ww,syncPlatform:r}).upload(e),a={};try{a=JSON.parse(i.body)}catch{}let s=a?.html_url??a?.web_url,u=G.read(ns);return s?(G.log(`\u540C\u6B65 Gist \u540E, \u627E\u5230 Sub-Store Gist: ${s}`),u.artifactStore=s,u.artifactStoreStatus="VALID"):(G.error("\u540C\u6B65 Gist \u540E, \u627E\u4E0D\u5230 Sub-Store Gist"),u.artifactStoreStatus="NOT FOUND"),G.write(u,ns),i}function gm(e){G.read(ws)||G.write({},ws),e.get("/api/sync/artifacts",yk),e.get("/api/sync/artifact/:name",bk)}async function wi({type:e,name:t,platform:r,url:n,ua:i,content:a,mergeSources:s,ignoreFailedRemoteSub:u,ignoreFailedRemoteFile:l,produceType:f,produceOpts:d={},subscription:g,awaitCustomCache:p,$options:h,proxy:E,noCache:v,all:b}){if(r=r||"JSON",["subscription","sub"].includes(e)){let m;if(t){let F=G.read(is);if(m=Pr(F,t),!m)throw new Error(`\u627E\u4E0D\u5230\u8BA2\u9605 ${t}`)}else if(g)m=g;else throw new Error("\u672A\u63D0\u4F9B\u8BA2\u9605\u540D\u79F0\u6216\u8BA2\u9605\u6570\u636E");let y;if(a&&!["localFirst","remoteFirst"].includes(s))y=a;else if(n){let F={};y=await Promise.all(n.split(/[\r\n]+/).map(k=>k.trim()).filter(k=>k.length).map(async k=>{try{return await wn(k,i||m.ua,void 0,E||m.proxy,void 0,p,v||m.noCache,!0)}catch(S){return F[k]=S,G.error(`\u8BA2\u9605 ${m.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${k} \u53D1\u751F\u9519\u8BEF: ${S}`),""}}));let L=m.ignoreFailedRemoteSub;if(u!=null&&u!==""&&(L=u),Object.keys(F).length>0)if(L)L==="enabled"&&G.notify("\u{1F30D} Sub-Store \u5904\u7406\u8BA2\u9605\u5931\u8D25",`\u274C ${m.name}`,`\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(F).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);else throw new Error(`\u8BA2\u9605 ${m.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(F).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);s==="localFirst"?y.unshift(a):s==="remoteFirst"&&y.push(a)}else if(m.source==="local"&&!["localFirst","remoteFirst"].includes(m.mergeSources))y=m.content;else{let F={};y=await Promise.all(m.url.split(/[\r\n]+/).map(k=>k.trim()).filter(k=>k.length).map(async k=>{try{return await wn(k,i||m.ua,void 0,E||m.proxy,void 0,p,v||m.noCache,!0)}catch(S){return F[k]=S,G.error(`\u8BA2\u9605 ${m.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${k} \u53D1\u751F\u9519\u8BEF: ${S}`),""}}));let L=m.ignoreFailedRemoteSub;if(u!=null&&u!==""&&(L=u),Object.keys(F).length>0)if(L)L==="enabled"&&G.notify("\u{1F30D} Sub-Store \u5904\u7406\u8BA2\u9605\u5931\u8D25",`\u274C ${m.name}`,`\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(F).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);else throw new Error(`\u8BA2\u9605 ${m.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(F).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);m.mergeSources==="localFirst"?y.unshift(m.content):m.mergeSources==="remoteFirst"&&y.push(m.content)}if(f==="raw")return JSON.stringify((Array.isArray(y)?y:[y]).flat());let D=(Array.isArray(y)?y:[y]).map(F=>Nt.parse(F)).flat();if(D.forEach(F=>{F._subName=m.name,F._subDisplayName=m.displayName}),D=await Nt.process(D,m.process||[],r,{[m.name]:m},h),D.length===0)throw new Error(`\u8BA2\u9605 ${t} \u4E2D\u4E0D\u542B\u6709\u6548\u8282\u70B9`);let C={};for(let F of D){if(C[F.name]){G.notify("\u{1F30D} Sub-Store",`\u26A0\uFE0F \u8BA2\u9605 ${t} \u5305\u542B\u91CD\u590D\u8282\u70B9 ${F.name}\uFF01`,"\u8BF7\u4ED4\u7EC6\u68C0\u6D4B\u914D\u7F6E\uFF01",{"media-url":"https://cdn3.iconfinder.com/data/icons/seo-outline-1/512/25_code_program_programming_develop_bug_search_developer-512.png"});break}C[F.name]=!0}return Nt.produce(D,r,f,d)}else if(["collection","col"].includes(e)){let m=G.read(is),y=G.read(Ou),D=Pr(y,t);if(!D)throw new Error(`\u627E\u4E0D\u5230\u7EC4\u5408\u8BA2\u9605 ${t}`);let C=[...D.subscriptions],F=D.subscriptionTags;Array.isArray(F)&&F.length>0&&m.forEach(U=>{Array.isArray(U.tag)&&U.tag.length>0&&!C.includes(U.name)&&U.tag.some(Y=>F.includes(Y))&&C.push(U.name)});let L={},k={},S=0;await Promise.all(C.map(async U=>{let Y=Pr(m,U),H=Y.passThroughUA,K=Y.ua;H&&(G.info(`\u8BA2\u9605\u5F00\u542F\u4E86\u900F\u4F20 User-Agent, \u4F7F\u7528\u8BF7\u6C42\u7684 User-Agent: ${i}`),K=i);try{G.info(`\u6B63\u5728\u5904\u7406\u5B50\u8BA2\u9605\uFF1A${Y.name}...`);let W;if(Y.source==="local"&&!["localFirst","remoteFirst"].includes(Y.mergeSources))W=Y.content;else{let Ce={};if(W=await await Promise.all(Y.url.split(/[\r\n]+/).map(Fe=>Fe.trim()).filter(Fe=>Fe.length).map(async Fe=>{try{return await wn(Fe,K,void 0,E||Y.proxy||D.proxy,void 0,void 0,v||Y.noCache,!0)}catch(Pe){return Ce[Fe]=Pe,G.error(`\u8BA2\u9605 ${Y.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Fe} \u53D1\u751F\u9519\u8BEF: ${Pe}`),""}})),Object.keys(Ce).length>0)if(Y.ignoreFailedRemoteSub)Y.ignoreFailedRemoteSub==="enabled"&&G.notify("\u{1F30D} Sub-Store \u5904\u7406\u8BA2\u9605\u5931\u8D25",`\u274C ${Y.name}`,`\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(Ce).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);else throw new Error(`\u8BA2\u9605 ${Y.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(Ce).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);Y.mergeSources==="localFirst"?W.unshift(Y.content):Y.mergeSources==="remoteFirst"&&W.push(Y.content)}let ie=(Array.isArray(W)?W:[W]).map(Ce=>Nt.parse(Ce)).flat();ie.forEach(Ce=>{Ce._subName=Y.name,Ce._subDisplayName=Y.displayName,Ce._collectionName=D.name,Ce._collectionDisplayName=D.displayName}),ie=await Nt.process(ie,Y.process||[],r,{[Y.name]:Y,_collection:D,$options:h}),L[U]=ie,S++,G.info(`\u2705 \u5B50\u8BA2\u9605\uFF1A${Y.name}\u52A0\u8F7D\u6210\u529F\uFF0C\u8FDB\u5EA6--${100*(S/C.length).toFixed(1)}% `)}catch(W){S++,k[U]=W,G.error(`\u274C \u5904\u7406\u7EC4\u5408\u8BA2\u9605\u4E2D\u7684\u5B50\u8BA2\u9605: ${Y.name}\u65F6\u51FA\u73B0\u9519\u8BEF\uFF1A${W}\uFF01\u8FDB\u5EA6--${100*(S/C.length).toFixed(1)}%`)}}));let B=D.ignoreFailedRemoteSub;if(u!=null&&u!==""&&(B=u),Object.keys(k).length>0)if(B)B==="enabled"&&G.notify("\u{1F30D} Sub-Store \u5904\u7406\u7EC4\u5408\u8BA2\u9605\u5931\u8D25",`\u274C ${D.name}`,`\u5B50\u8BA2\u9605 ${Object.keys(k).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);else throw new Error(`\u7EC4\u5408\u8BA2\u9605 ${D.name} \u7684\u5B50\u8BA2\u9605 ${Object.keys(k).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);let O=Array.prototype.concat.apply([],C.map(U=>L[U]||[]));if(O.forEach(U=>{U._collectionName=D.name,U._collectionDisplayName=D.displayName}),O=await Nt.process(O,D.process||[],r,{_collection:D},h),O.length===0)throw new Error(`\u7EC4\u5408\u8BA2\u9605 ${t} \u4E2D\u4E0D\u542B\u6709\u6548\u8282\u70B9`);let P={};for(let U of O){if(P[U.name]){G.notify("\u{1F30D} Sub-Store",`\u26A0\uFE0F \u7EC4\u5408\u8BA2\u9605 ${t} \u5305\u542B\u91CD\u590D\u8282\u70B9 ${U.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}P[U.name]=!0}return Nt.produce(O,r,f,d)}else if(e==="rule"){let m=G.read(cf),y=Pr(m,t);if(!y)throw new Error(`\u627E\u4E0D\u5230\u89C4\u5219 ${t}`);let D=[];for(let C=0;CB.trim()).filter(B=>B.length).map(async B=>{try{return await wn(B,i||y.ua,void 0,y.proxy||E,void 0,void 0,v)}catch(O){return k[B]=O,G.error(`\u6587\u4EF6 ${y.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${B} \u53D1\u751F\u9519\u8BEF: ${O}`),""}}));let S=y.ignoreFailedRemoteFile;if(l!=null&&l!==""&&(S=l),!S&&Object.keys(k).length>0)throw new Error(`\u6587\u4EF6 ${y.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${Object.keys(k).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);s==="localFirst"?D.unshift(a):s==="remoteFirst"&&D.push(a)}else if(y.source==="local"&&!["localFirst","remoteFirst"].includes(y.mergeSources))D=y.content;else{let k={};D=await Promise.all(y.url.split(/[\r\n]+/).map(B=>B.trim()).filter(B=>B.length).map(async B=>{try{return await wn(B,i||y.ua,void 0,y.proxy||E,void 0,void 0,v)}catch(O){return k[B]=O,G.error(`\u6587\u4EF6 ${y.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${B} \u53D1\u751F\u9519\u8BEF: ${O}`),""}}));let S=y.ignoreFailedRemoteFile;if(l!=null&&l!==""&&(S=l),Object.keys(k).length>0)if(S)S==="enabled"&&G.notify("\u{1F30D} Sub-Store \u5904\u7406\u6587\u4EF6\u5931\u8D25",`\u274C ${y.name}`,`\u8FDC\u7A0B\u6587\u4EF6 ${Object.keys(k).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);else throw new Error(`\u6587\u4EF6 ${y.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${Object.keys(k).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);y.mergeSources==="localFirst"?D.unshift(y.content):y.mergeSources==="remoteFirst"&&D.push(y.content)}if(f==="raw")return JSON.stringify((Array.isArray(D)?D:[D]).flat());let C=(Array.isArray(D)?D:[D]).flat(),F=C.filter(k=>k!=null&&k!=="").join(` `),L=Array.isArray(y.process)&&y.process.length>0?await Nt.process({$files:C,$content:F,$options:h,$file:y},y.process):{$content:F,$files:C,$options:h};return(b?L:L?.$content)??""}}async function Ak(){G.info("\u5F00\u59CB\u540C\u6B65\u6240\u6709\u8FDC\u7A0B\u914D\u7F6E...");let e=G.read(ws),t={};try{let r=[],n=[],i=G.read(is),a=G.read(Ou),s=[],u=0;if(e.map(d=>{if(d.sync&&d.source){if(u++,d.type==="subscription"){let g=d.source,p=Pr(i,g);p&&p.url&&!s.includes(g)&&s.push(g)}else if(d.type==="collection"){let g=Pr(a,d.source);g&&Array.isArray(g.subscriptions)&&g.subscriptions.map(p=>{let h=Pr(i,p);h&&h.url&&!s.includes(p)&&s.push(p)})}}}),u===0){G.info(`\u9700\u540C\u6B65\u7684\u914D\u7F6E: ${u}, \u603B\u6570: ${e.length}`);return}if(s.length>0&&await Promise.all(s.map(async d=>{try{await wi({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 g=d.platform==="SurgeMac";g&&G.info("\u624B\u52A8\u6307\u5B9A\u4E86 target \u4E3A SurgeMac, \u5C06\u4F7F\u7528 Mihomo External");let p=await wi({type:d.type,name:d.source,platform:d.platform,produceOpts:{"include-unsupported-proxy":d.includeUnsupportedProxy,useMihomoExternal:g}});t[encodeURIComponent(d.name)]={content:p},r.push(d.name)}}catch(g){G.error(`\u751F\u6210\u540C\u6B65\u914D\u7F6E ${d.name} \u53D1\u751F\u9519\u8BEF: ${g.message??g}`),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 pm(t),f=JSON.parse(l.body);delete f.history,delete f.forks,delete f.owner,Object.values(f.files).forEach(d=>{delete d.content}),G.info("\u4E0A\u4F20\u914D\u7F6E\u54CD\u5E94:"),G.info(JSON.stringify(f,null,2));for(let d of e)if(d.sync&&d.source&&r.includes(d.name)){d.updated=new Date().getTime();let g=f.files,p;Array.isArray(g)&&(p=!0,g=Object.fromEntries(g.map(v=>[v.path,v])));let h=g[encodeURIComponent(d.name)]?.raw_url,E=p?h:h?.replace(/\/raw\/[^/]*\/(.*)/,"/raw/$1");G.info(`\u4E0A\u4F20\u914D\u7F6E\u5B8C\u6210 \u6587\u4EF6\u5217\u8868: ${Object.keys(g).join(", ")} \u5F53\u524D\u6587\u4EF6: ${encodeURIComponent(d.name)} \u54CD\u5E94\u8FD4\u56DE\u7684\u539F\u59CB\u94FE\u63A5: ${h} \u5904\u7406\u5B8C\u7684\u65B0\u94FE\u63A5: ${E}`),d.url=E}if(G.write(e,ws),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 yk(e,t){G.info("\u5F00\u59CB\u540C\u6B65\u6240\u6709\u8FDC\u7A0B\u914D\u7F6E...");try{await Ak(),na(t)}catch(r){G.error(`\u540C\u6B65\u914D\u7F6E\u5931\u8D25\uFF0C\u539F\u56E0\uFF1A${r.message??r}`),En(t,new Li("FAILED_TO_SYNC_ARTIFACTS","Failed to sync all artifacts",`Reason: ${r.message??r}`))}}async function bk(e,t){let{name:r}=e.params;G.info(`\u5F00\u59CB\u540C\u6B65\u8FDC\u7A0B\u914D\u7F6E ${r}...`);let n=G.read(ws),i=Pr(n,r);if(!i){G.error(`\u627E\u4E0D\u5230\u8FDC\u7A0B\u914D\u7F6E ${r}`),En(t,new Qa("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`),En(t,new Qa("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 wi({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 u=await pm({[encodeURIComponent(i.name)]:{content:s}});i.updated=new Date().getTime();let l=JSON.parse(u.body);delete l.history,delete l.forks,delete l.owner,Object.values(l.files).forEach(h=>{delete h.content}),G.info("\u4E0A\u4F20\u914D\u7F6E\u54CD\u5E94:"),G.info(JSON.stringify(l,null,2));let f=l.files,d;Array.isArray(f)&&(d=!0,f=Object.fromEntries(f.map(h=>[h.path,h])));let g=f[encodeURIComponent(i.name)]?.raw_url,p=d?g:g?.replace(/\/raw\/[^/]*\/(.*)/,"/raw/$1");G.info(`\u4E0A\u4F20\u914D\u7F6E\u5B8C\u6210 \u6587\u4EF6\u5217\u8868: ${Object.keys(f).join(", ")} \u5F53\u524D\u6587\u4EF6: ${encodeURIComponent(i.name)} \u54CD\u5E94\u8FD4\u56DE\u7684\u539F\u59CB\u94FE\u63A5: ${g} \u5904\u7406\u5B8C\u7684\u65B0\u94FE\u63A5: ${p}`),i.url=p,G.write(n,ws),na(t,i)}catch(a){G.error(`\u8FDC\u7A0B\u914D\u7F6E ${i.name} \u53D1\u751F\u9519\u8BEF: ${a.message??a}`),En(t,new Li("FAILED_TO_SYNC_ARTIFACT",`Failed to sync artifact ${r}`,`Reason: ${a}`))}}function _k(){return{name:"HTML",test:n=>/^/.test(n),parse:()=>""}}function Ck(){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=Dt.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 Dk(){return{name:"Fallback Base64 Pre-processor",test:function(n){return!0},parse:function(n){let i=Dt.decode(n);return/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(i)?i:(G.error("Fallback Base64 Pre-processor error: decoded line does not start with protocol"),n)}}}function Fk(){return{name:"Clash Pre-processor",test:function(n){if(!/proxies/.test(n))return!1;let i=Cf(n);return i.proxies&&Array.isArray(i.proxies)},parse:function(n,i){let a=n.replace(/short-id:([ \t]*[^#\n,}]*)/g,(l,f)=>{let d=f.trim();return!d||d===""?'short-id: ""':/^(['"]).*\1$/.test(d)?`short-id: ${d}`:["null"].includes(d)?`short-id: ${d}`:`short-id: "${d}"`}),{proxies:s,"global-client-fingerprint":u}=Cf(a);return(i?`proxies: `:"")+s.map(l=>(u&&!l["client-fingerprint"]&&(l["client-fingerprint"]=u),`${i?" - ":""}${JSON.stringify(l)} `)).join("")}}}function Sk(){return{name:"SSD Pre-processor",test:function(n){return n.indexOf("ssd://")===0},parse:function(n){let i=[],a=JSON.parse(Dt.decode(n.split("ssd://")[1])),s=a.port,u=a.encryption,l=a.password,f=a.servers;for(let d=0;de.name==="Clash Pre-processor"),mm=new Map;async function wn(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}=ki(),{defaultProxy,defaultUserAgent,defaultTimeout,cacheThreshold:defaultCacheThreshold}=G.read(ns),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=bs(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=rn.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 wn(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"),rn.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`),wn(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}}let downloadUrlMatch=url.split("#")[0].match(/^\/api\/(file|module)\/(.+)/);if(downloadUrlMatch){let e="";try{e=downloadUrlMatch?.[1];let t=downloadUrlMatch?.[2];if(t==null)throw new Error(`\u672C\u5730 ${e} URL \u65E0\u6548: ${url}`);t=decodeURIComponent(t);let r=e==="module"?D0:qa,n=Pr(G.read(r),t);if(!n)throw new Error(`\u627E\u4E0D\u5230 ${e}: ${t}`);return e==="module"?n.content:await wi({type:"file",name:t})}catch(t){throw G.error(`Error when loading ${e}: ${url.split("#")[0]}. Reason: ${t}`),new Error(`\u65E0\u6CD5\u52A0\u8F7D ${e}: ${url}`)}}else if(url?.startsWith("/"))try{let fs=eval('require("fs")');return fs.readFileSync(url.split("#")[0],"utf8")}catch(e){throw G.error(`Error when reading local file: ${url.split("#")[0]}. Reason: ${e}`),new Error(`\u65E0\u6CD5\u4ECE\u8BE5\u8DEF\u5F84\u8BFB\u53D6\u6587\u672C\u5185\u5BB9: ${url}`)}if(!isNode&&mm.has(id))return mm.get(id);let http=As({headers:{"User-Agent":userAgent,...isStash&&proxy?{"X-Stash-Selected-Proxy":encodeURIComponent(proxy)}:{},...isShadowRocket&&proxy?{"X-Surge-Policy":proxy}:{}},timeout:requestTimeout}),result,cached=rn.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?Za(proxy):{},...e||{}});if(G.info(`statusCode: ${n}`),n<200||n>=400)throw new Error(`statusCode: ${n}`);if(r){let a=nc(r);a&&Bf.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{X_.test(t)&&(t=X_.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)}if(preprocess)try{let a=Nt.parse(t);(!Array.isArray(a)||a.length===0)&&(G.error(`URL ${url} \u4E0D\u5305\u542B\u6709\u6548\u8282\u70B9, \u4E0D\u7F13\u5B58`),i=!1)}catch(a){G.error(`URL ${url} \u5C1D\u8BD5\u89E3\u6790\u8282\u70B9\u5931\u8D25 ${a.message??a}, \u4E0D\u7F13\u5B58`),i=!1}i&&(rn.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 Cd(_d(await ra(url,$arguments.flowUserAgent,void 0,proxy,$arguments.flowUrl))),isNode||mm.set(id,result),result}async function J_(url,file){let undici=eval("require('undici')"),fs=eval("require('fs')"),{pipeline}=eval("require('stream/promises')"),{Agent,interceptors,request}=undici;G.info(`Downloading file... URL: ${url} File: ${file}`);let{body,statusCode}=await request(url,{dispatcher:new Agent().compose(interceptors.redirect({maxRedirections:3,throwOnRedirect:!0}))});if(statusCode!==200)throw new Error(`Failed to download file from ${url}`);let fileStream=fs.createWriteStream(file);return await pipeline(body,fileStream),G.info(`File downloaded from ${url} to ${file}`),file}var vm=class{constructor(){this.expires=Bk(),G.read(Bo)||G.write("{}",Bo);try{this.resourceCache=JSON.parse(G.read(Bo))}catch(t){G.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${Bo} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${t?.message??t}`),this.resourceCache={},G.write("{}",Bo)}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),Bo)}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 Bk(){G.read(S0)||G.write("1728e5",S0);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(S0),e}var Em=new vm;function Id(e,t){return[...Array(e).keys()].map(()=>t)}var wm={"\u{1F3F3}\uFE0F\u200D\u{1F308}":["EXP","BAND"],"\u{1F1F8}\u{1F1F1}":["TEST","SOS"],"\u{1F1F2}\u{1F1F5}":["MP","MNP"],"\u{1F1F8}\u{1F1F4}":["SO","SOM"],"\u{1F1E6}\u{1F1F6}":["AQ","ATA"],"\u{1F1E6}\u{1F1EC}":["AG","ATG"],"\u{1F1EC}\u{1F1F1}":["GL","GRL"],"\u{1F1FF}\u{1F1FC}":["ZW","ZWE"],"\u{1F1E6}\u{1F1FC}":["AW","ABW"],"\u{1F1F2}\u{1F1F1}":["ML","MLI"],"\u{1F1E6}\u{1F1E9}":["AD","AND"],"\u{1F1E6}\u{1F1EA}":["AE","ARE"],"\u{1F1E6}\u{1F1EB}":["AF","AFG"],"\u{1F1E6}\u{1F1F1}":["AL","ALB"],"\u{1F1E6}\u{1F1F2}":["AM","ARM"],"\u{1F1E6}\u{1F1F7}":["AR","ARG"],"\u{1F1E6}\u{1F1F9}":["AT","AUT"],"\u{1F1E6}\u{1F1FA}":["AU","AUS"],"\u{1F1E6}\u{1F1FF}":["AZ","AZE"],"\u{1F1E7}\u{1F1E6}":["BA","BIH"],"\u{1F1E7}\u{1F1E9}":["BD","BGD"],"\u{1F1E7}\u{1F1EA}":["BE","BEL"],"\u{1F1E7}\u{1F1EC}":["BG","BGR"],"\u{1F1E7}\u{1F1ED}":["BH","BHR"],"\u{1F1E7}\u{1F1F4}":["BO","BOL"],"\u{1F1E7}\u{1F1F3}":["BN","BRN"],"\u{1F1E7}\u{1F1F7}":["BR","BRA"],"\u{1F1E7}\u{1F1F9}":["BT","BTN"],"\u{1F1E7}\u{1F1FE}":["BY","BLR"],"\u{1F1E8}\u{1F1E6}":["CA","CAN"],"\u{1F1E8}\u{1F1ED}":["CH","CHE"],"\u{1F1E8}\u{1F1F1}":["CL","CHL"],"\u{1F1E8}\u{1F1F4}":["CO","COL"],"\u{1F1E8}\u{1F1F7}":["CR","CRI"],"\u{1F1E8}\u{1F1FE}":["CY","CYP"],"\u{1F1E8}\u{1F1FF}":["CZ","CZE"],"\u{1F1E9}\u{1F1EA}":["DE","DEU"],"\u{1F1E9}\u{1F1F0}":["DK","DNK"],"\u{1F1E9}\u{1F1FF}":["DZ","DZA"],"\u{1F1EA}\u{1F1E8}":["EC","ECU"],"\u{1F1EA}\u{1F1EA}":["EE","EST"],"\u{1F1EA}\u{1F1EC}":["EG","EGY"],"\u{1F1EA}\u{1F1F8}":["ES","ESP"],"\u{1F1EA}\u{1F1FA}":["EU"],"\u{1F1EB}\u{1F1EE}":["FI","FIN"],"\u{1F1EB}\u{1F1F7}":["FR","FRA"],"\u{1F1EC}\u{1F1E7}":["GB","GBR","UK"],"\u{1F1EC}\u{1F1EA}":["GE","GEO"],"\u{1F1EC}\u{1F1F7}":["GR","GRC"],"\u{1F1EC}\u{1F1F9}":["GT","GTM"],"\u{1F1EC}\u{1F1FA}":["GU","GUM"],"\u{1F1ED}\u{1F1F0}":["HK","HKG","HKT","HKBN","HGC","WTT","CMI"],"\u{1F1ED}\u{1F1F7}":["HR","HRV"],"\u{1F1ED}\u{1F1FA}":["HU","HUN"],"\u{1F1EE}\u{1F1F6}":["IQ","IRQ"],"\u{1F1EF}\u{1F1F4}":["JO","JOR"],"\u{1F1EF}\u{1F1F5}":["JP","JPN","TYO"],"\u{1F1F0}\u{1F1EA}":["KE","KEN"],"\u{1F1F0}\u{1F1EC}":["KG","KGZ"],"\u{1F1F0}\u{1F1ED}":["KH","KGZ"],"\u{1F1F0}\u{1F1F5}":["KP","PRK"],"\u{1F1F0}\u{1F1F7}":["KR","KOR","SEL"],"\u{1F1F0}\u{1F1FF}":["KZ","KAZ"],"\u{1F1EE}\u{1F1E9}":["ID","IDN"],"\u{1F1EE}\u{1F1EA}":["IE","IRL"],"\u{1F1EE}\u{1F1F1}":["IL","ISR"],"\u{1F1EE}\u{1F1F2}":["IM","IMN"],"\u{1F1EE}\u{1F1F3}":["IN","IND"],"\u{1F1EE}\u{1F1F7}":["IR","IRN"],"\u{1F1EE}\u{1F1F8}":["IS","ISL"],"\u{1F1EE}\u{1F1F9}":["IT","ITA"],"\u{1F1F1}\u{1F1E6}":["LA","LAO"],"\u{1F1F1}\u{1F1F0}":["LK","LKA"],"\u{1F1F1}\u{1F1F9}":["LT","LTU"],"\u{1F1F1}\u{1F1FA}":["LU","LUX"],"\u{1F1F1}\u{1F1FB}":["LV","LVA"],"\u{1F1F2}\u{1F1E6}":["MA","MAR"],"\u{1F1F2}\u{1F1E9}":["MD","MDA"],"\u{1F1F3}\u{1F1EC}":["NG","NGA"],"\u{1F1F2}\u{1F1F2}":["MM","MMR"],"\u{1F1F2}\u{1F1F0}":["MK","MKD"],"\u{1F1F2}\u{1F1F3}":["MN","MNG"],"\u{1F1F2}\u{1F1F4}":["MO","MAC","CTM"],"\u{1F1F2}\u{1F1F9}":["MT","MLT"],"\u{1F1F2}\u{1F1FD}":["MX","MEX"],"\u{1F1F2}\u{1F1FE}":["MY","MYS"],"\u{1F1F3}\u{1F1F1}":["NL","NLD","AMS"],"\u{1F1F3}\u{1F1F4}":["NO","NOR"],"\u{1F1F3}\u{1F1F5}":["NP","NPL"],"\u{1F1F3}\u{1F1FF}":["NZ","NZL"],"\u{1F1F4}\u{1F1F2}":["OM","OMN"],"\u{1F1F5}\u{1F1E6}":["PA","PAN"],"\u{1F1F5}\u{1F1EA}":["PE","PER"],"\u{1F1F5}\u{1F1ED}":["PH","PHL"],"\u{1F1F5}\u{1F1F0}":["PK","PAK"],"\u{1F1F5}\u{1F1F1}":["PL","POL"],"\u{1F1F5}\u{1F1F7}":["PR","PRI"],"\u{1F1F5}\u{1F1F9}":["PT","PRT"],"\u{1F1F5}\u{1F1FE}":["PY","PRY"],"\u{1F1F5}\u{1F1EC}":["PG","PNG"],"\u{1F1F6}\u{1F1E6}":["QA","QAT"],"\u{1F1F7}\u{1F1F4}":["RO","ROU"],"\u{1F1F7}\u{1F1F8}":["RS","SRB"],"\u{1F1F7}\u{1F1EA}":["RE","REU"],"\u{1F1F7}\u{1F1FA}":["RU","RUS"],"\u{1F1F8}\u{1F1E6}":["SA","SAU"],"\u{1F1FC}\u{1F1F8}":["WS","WSM"],"\u{1F1F8}\u{1F1EA}":["SE","SWE"],"\u{1F1F8}\u{1F1EC}":["SG","SGP"],"\u{1F1F8}\u{1F1EE}":["SI","SVN"],"\u{1F1F8}\u{1F1F0}":["SK","SVK"],"\u{1F1F9}\u{1F1EC}":["TG","TGO"],"\u{1F1F9}\u{1F1ED}":["TH","THA"],"\u{1F1F9}\u{1F1F3}":["TN","TUN"],"\u{1F1F9}\u{1F1F7}":["TR","TUR"],"\u{1F1F9}\u{1F1FC}":["TW","TWN","CHT","HINET","ROC"],"\u{1F1FA}\u{1F1E6}":["UA","UKR"],"\u{1F1FA}\u{1F1F8}":["US","USA","LAX","SFO","SJC"],"\u{1F1FA}\u{1F1FE}":["UY","URY"],"\u{1F1FB}\u{1F1E6}":["VA","VAT"],"\u{1F1FB}\u{1F1EA}":["VE","VEN"],"\u{1F1FB}\u{1F1F3}":["VN","VNM"],"\u{1F1FF}\u{1F1E6}":["ZA","ZAF","JNB"],"\u{1F1E8}\u{1F1F3}":["CN","CHN","BACK"]};function sc(e){let t={"\u{1F3F3}\uFE0F\u200D\u{1F308}":["\u6D41\u91CF","\u65F6\u95F4","\u8FC7\u671F","Bandwidth","Expire"],"\u{1F1F8}\u{1F1F1}":["\u5E94\u6025","\u6D4B\u8BD5\u8282\u70B9"],"\u{1F1F2}\u{1F1F5}":["\u5317\u9A6C\u91CC\u4E9A\u7EB3","Northern Mariana Islands","Saipan","\u585E\u73ED"],"\u{1F1F8}\u{1F1F4}":["Somalia","\u7D22\u9A6C\u91CC","\u6469\u52A0\u8FEA\u6C99","Mogadishu"],"\u{1F1E6}\u{1F1F6}":["Antarctica","\u5357\u6781\u6D32","\u5357\u6781"],"\u{1F1E6}\u{1F1EC}":["Antigua and Barbuda","\u5B89\u63D0\u74DC\u548C\u5DF4\u5E03\u8FBE"],"\u{1F1EC}\u{1F1F1}":["Greenland","\u683C\u9675\u5170\u5C9B","\u683C\u9675\u5170"],"\u{1F1FF}\u{1F1FC}":["Zimbabwe","\u6D25\u5DF4\u5E03\u97E6"],"\u{1F1E6}\u{1F1FC}":["Aruba","\u963F\u9C81\u5DF4"],"\u{1F1F2}\u{1F1F1}":["Mali","\u9A6C\u91CC"],"\u{1F1E6}\u{1F1E9}":["Andorra","\u5B89\u9053\u5C14"],"\u{1F1E6}\u{1F1EA}":["United Arab Emirates","\u963F\u8054\u914B","\u8FEA\u62DC","Dubai"],"\u{1F1E6}\u{1F1EB}":["Afghanistan","\u963F\u5BCC\u6C57"],"\u{1F1E6}\u{1F1F1}":["Albania","\u963F\u5C14\u5DF4\u5C3C\u4E9A","\u963F\u723E\u5DF4\u5C3C\u4E9E"],"\u{1F1E6}\u{1F1F2}":["Armenia","\u4E9A\u7F8E\u5C3C\u4E9A"],"\u{1F1E6}\u{1F1F7}":["Argentina","\u963F\u6839\u5EF7"],"\u{1F1E6}\u{1F1F9}":["Austria","\u5965\u5730\u5229","\u5967\u5730\u5229","\u7EF4\u4E5F\u7EB3"],"\u{1F1FC}\u{1F1F8}":["Samoa","\u8428\u6469\u4E9A","\u85A9\u6469\u4E9E"],"\u{1F1E6}\u{1F1FA}":["Australia","\u6FB3\u5927\u5229\u4E9A","\u6FB3\u6D32","\u58A8\u5C14\u672C","\u6089\u5C3C","\u571F\u6FB3","\u4EAC\u6FB3","\u5EE3\u6FB3","\u6EEC\u6FB3","\u6CAA\u6FB3","\u5E7F\u6FB3","Sydney"],"\u{1F1E6}\u{1F1FF}":["Azerbaijan","\u963F\u585E\u62DC\u7586"],"\u{1F1E7}\u{1F1E6}":["Bosnia and Herzegovina","\u6CE2\u9ED1\u5171\u548C\u56FD","\u6CE2\u9ED1"],"\u{1F1E7}\u{1F1E9}":["Bangladesh","\u5B5F\u52A0\u62C9\u56FD","\u5B5F\u52A0\u62C9"],"\u{1F1E7}\u{1F1EA}":["Belgium","\u6BD4\u5229\u65F6","\u6BD4\u5229\u6642"],"\u{1F1E7}\u{1F1EC}":["Bulgaria","\u4FDD\u52A0\u5229\u4E9A","\u4FDD\u52A0\u5229\u4E9E"],"\u{1F1E7}\u{1F1ED}":["Bahrain","\u5DF4\u6797"],"\u{1F1E7}\u{1F1F7}":["Brazil","\u5DF4\u897F","\u5723\u4FDD\u7F57"],"\u{1F1E7}\u{1F1F3}":["Brunei","\u6587\u83B1","\u6C76\u840A"],"\u{1F1E7}\u{1F1FE}":["Belarus","\u767D\u4FC4\u7F57\u65AF","\u767D\u4FC4"],"\u{1F1E7}\u{1F1F4}":["Bolivia","\u73BB\u5229\u7EF4\u4E9A"],"\u{1F1E7}\u{1F1F9}":["Bhutan","\u4E0D\u4E39","\u4E0D\u4E39\u738B\u56FD"],"\u{1F1E8}\u{1F1E6}":["Canada","\u52A0\u62FF\u5927","\u8499\u7279\u5229\u5C14","\u6E29\u54E5\u534E","\u6953\u8449","\u67AB\u53F6","\u6ED1\u94C1\u5362","\u591A\u4F26\u591A","Waterloo","Toronto"],"\u{1F1E8}\u{1F1ED}":["Switzerland","\u745E\u58EB","\u82CF\u9ECE\u4E16","Zurich"],"\u{1F1E8}\u{1F1F1}":["Chile","\u667A\u5229"],"\u{1F1E8}\u{1F1F4}":["Colombia","\u54E5\u4F26\u6BD4\u4E9A"],"\u{1F1E8}\u{1F1F7}":["Costa Rica","\u54E5\u65AF\u8FBE\u9ECE\u52A0"],"\u{1F1E8}\u{1F1FE}":["Cyprus","\u585E\u6D66\u8DEF\u65AF"],"\u{1F1E8}\u{1F1FF}":["Czechia","\u6377\u514B","Czech","Czech Republic"],"\u{1F1E9}\u{1F1EA}":["German","\u5FB7\u56FD","\u5FB7\u570B","\u4EAC\u5FB7","\u6EEC\u5FB7","\u5EE3\u5FB7","\u6CAA\u5FB7","\u5E7F\u5FB7","\u6CD5\u5170\u514B\u798F","Frankfurt","\u5FB7\u610F\u5FD7"],"\u{1F1E9}\u{1F1F0}":["Denmark","\u4E39\u9EA6","\u4E39\u9EA5"],"\u{1F1E9}\u{1F1FF}":["Algeria","\u963F\u5C14\u53CA\u5229\u4E9A","\u963F\u723E\u53CA\u5229\u4E9E"],"\u{1F1EA}\u{1F1E8}":["Ecuador","\u5384\u74DC\u591A\u5C14"],"\u{1F1EA}\u{1F1EA}":["Estonia","\u7231\u6C99\u5C3C\u4E9A"],"\u{1F1EA}\u{1F1EC}":["Egypt","\u57C3\u53CA"],"\u{1F1EA}\u{1F1F8}":["Spain","\u897F\u73ED\u7259"],"\u{1F1EA}\u{1F1FA}":["European Union","\u6B27\u76DF","\u6B27\u7F57\u5DF4"],"\u{1F1EB}\u{1F1EE}":["Finland","\u82AC\u5170","\u82AC\u862D","\u8D6B\u5C14\u8F9B\u57FA"],"\u{1F1EB}\u{1F1F7}":["France","\u6CD5\u56FD","\u6CD5\u570B","\u5DF4\u9ECE"],"\u{1F1EC}\u{1F1E7}":["Great Britain","\u82F1\u56FD","England","United Kingdom","\u4F26\u6566","\u82F1","London"],"\u{1F1EC}\u{1F1EA}":["Georgia","\u683C\u9C81\u5409\u4E9A","\u683C\u9B6F\u5409\u4E9E"],"\u{1F1EC}\u{1F1F7}":["Greece","\u5E0C\u814A","\u5E0C\u81D8"],"\u{1F1EC}\u{1F1FA}":["Guam","\u5173\u5C9B","\u95DC\u5CF6"],"\u{1F1EC}\u{1F1F9}":["Guatemala","\u5371\u5730\u9A6C\u62C9"],"\u{1F1ED}\u{1F1F0}":["Hongkong","\u9999\u6E2F","Hong Kong","HongKong","HONG KONG","\u6DF1\u6E2F","\u6CAA\u6E2F","\u547C\u6E2F","\u7A57\u6E2F","\u4EAC\u6E2F","\u6E2F"],"\u{1F1ED}\u{1F1F7}":["Croatia","\u514B\u7F57\u5730\u4E9A","\u514B\u7F85\u5730\u4E9E"],"\u{1F1ED}\u{1F1FA}":["Hungary","\u5308\u7259\u5229"],"\u{1F1EE}\u{1F1F6}":["Iraq","\u4F0A\u62C9\u514B","\u5DF4\u683C\u8FBE","Baghdad"],"\u{1F1EF}\u{1F1F4}":["Jordan","\u7EA6\u65E6"],"\u{1F1EF}\u{1F1F5}":["Japan","\u65E5\u672C","\u4E1C\u4EAC","\u5927\u962A","\u57FC\u7389","\u6CAA\u65E5","\u7A57\u65E5","\u5DDD\u65E5","\u4E2D\u65E5","\u6CC9\u65E5","\u676D\u65E5","\u6DF1\u65E5","\u8FBD\u65E5","\u5E7F\u65E5","\u5927\u5742","Osaka","Tokyo"],"\u{1F1F0}\u{1F1EA}":["Kenya","\u80AF\u5C3C\u4E9A"],"\u{1F1F0}\u{1F1EC}":["Kyrgyzstan","\u5409\u5C14\u5409\u65AF\u65AF\u5766"],"\u{1F1F0}\u{1F1ED}":["Cambodia","\u67EC\u57D4\u5BE8"],"\u{1F1F0}\u{1F1F5}":["North Korea","\u671D\u9C9C"],"\u{1F1F0}\u{1F1F7}":["Korea","\u97E9\u56FD","\u97D3\u570B","\u97E9","\u97D3","\u9996\u5C14","\u6625\u5DDD","Chuncheon","Seoul"],"\u{1F1F0}\u{1F1FF}":["Kazakhstan","\u54C8\u8428\u514B\u65AF\u5766","\u54C8\u8428\u514B"],"\u{1F1EE}\u{1F1E9}":["Indonesia","\u5370\u5C3C","\u5370\u5EA6\u5C3C\u897F\u4E9A","\u96C5\u52A0\u8FBE"],"\u{1F1EE}\u{1F1EA}":["Ireland","\u7231\u5C14\u5170","\u611B\u723E\u862D","\u90FD\u67CF\u6797"],"\u{1F1EE}\u{1F1F1}":["Israel","\u4EE5\u8272\u5217"],"\u{1F1EE}\u{1F1F2}":["Isle of Man","\u9A6C\u6069\u5C9B","\u99AC\u6069\u5CF6"],"\u{1F1EE}\u{1F1F3}":["India","\u5370\u5EA6","\u5B5F\u4E70","MFumbai","Mumbai"],"\u{1F1EE}\u{1F1F7}":["Iran","\u4F0A\u6717"],"\u{1F1EE}\u{1F1F8}":["Iceland","\u51B0\u5C9B","\u51B0\u5CF6"],"\u{1F1EE}\u{1F1F9}":["Italy","\u610F\u5927\u5229","\u7FA9\u5927\u5229","\u7C73\u5170","Nachash"],"\u{1F1F1}\u{1F1F0}":["Sri Lanka","\u65AF\u91CC\u5170\u5361","\u65AF\u91CC\u862D\u5361"],"\u{1F1F1}\u{1F1E6}":["Laos","\u8001\u631D","\u8001\u64BE"],"\u{1F1F1}\u{1F1F9}":["Lithuania","\u7ACB\u9676\u5B9B"],"\u{1F1F1}\u{1F1FA}":["Luxembourg","\u5362\u68EE\u5821"],"\u{1F1F1}\u{1F1FB}":["Latvia","\u62C9\u8131\u7EF4\u4E9A","Latvija"],"\u{1F1F2}\u{1F1E6}":["Morocco","\u6469\u6D1B\u54E5"],"\u{1F1F2}\u{1F1E9}":["Moldova","\u6469\u5C14\u591A\u74E6","\u6469\u723E\u591A\u74E6"],"\u{1F1F2}\u{1F1F2}":["Myanmar","\u7F05\u7538","\u7DEC\u7538"],"\u{1F1F3}\u{1F1EC}":["Nigeria","\u5C3C\u65E5\u5229\u4E9A","\u5C3C\u65E5\u5229\u4E9E"],"\u{1F1F2}\u{1F1F0}":["Macedonia","\u9A6C\u5176\u987F","\u99AC\u5176\u9813"],"\u{1F1F2}\u{1F1F3}":["Mongolia","\u8499\u53E4"],"\u{1F1F2}\u{1F1F4}":["Macao","\u6FB3\u95E8","\u6FB3\u9580","CTM"],"\u{1F1F2}\u{1F1F9}":["Malta","\u9A6C\u8033\u4ED6"],"\u{1F1F2}\u{1F1FD}":["Mexico","\u58A8\u897F\u54E5"],"\u{1F1F2}\u{1F1FE}":["Malaysia","\u9A6C\u6765","\u99AC\u4F86","\u5409\u9686\u5761","\u5927\u99AC"],"\u{1F1F3}\u{1F1F1}":["Netherlands","\u8377\u5170","\u8377\u862D","\u5C3C\u5FB7\u862D","\u963F\u59C6\u65AF\u7279\u4E39","Amsterdam"],"\u{1F1F3}\u{1F1F4}":["Norway","\u632A\u5A01"],"\u{1F1F3}\u{1F1F5}":["Nepal","\u5C3C\u6CCA\u5C14"],"\u{1F1F3}\u{1F1FF}":["New Zealand","\u65B0\u897F\u5170","\u65B0\u897F\u862D"],"\u{1F1F4}\u{1F1F2}":["Oman","\u963F\u66FC","\u9A6C\u65AF\u5580\u7279"],"\u{1F1F5}\u{1F1E6}":["Panama","\u5DF4\u62FF\u9A6C"],"\u{1F1F5}\u{1F1EA}":["Peru","\u79D8\u9C81","\u7955\u9B6F"],"\u{1F1F5}\u{1F1ED}":["Philippines","\u83F2\u5F8B\u5BBE","\u83F2\u5F8B\u8CD3"],"\u{1F1F5}\u{1F1F0}":["Pakistan","\u5DF4\u57FA\u65AF\u5766"],"\u{1F1F5}\u{1F1F1}":["Poland","\u6CE2\u5170","\u6CE2\u862D","\u534E\u6C99","Warsaw"],"\u{1F1F5}\u{1F1F7}":["Puerto Rico","\u6CE2\u591A\u9ECE\u5404"],"\u{1F1F5}\u{1F1F9}":["Portugal","\u8461\u8404\u7259"],"\u{1F1F5}\u{1F1EC}":["Papua New Guinea","\u5DF4\u5E03\u4E9A\u65B0\u51E0\u5185\u4E9A"],"\u{1F1F5}\u{1F1FE}":["Paraguay","\u5DF4\u62C9\u572D"],"\u{1F1F6}\u{1F1E6}":["Qatar","\u5361\u5854\u5C14","\u5361\u5854\u723E"],"\u{1F1F7}\u{1F1F4}":["Romania","\u7F57\u9A6C\u5C3C\u4E9A"],"\u{1F1F7}\u{1F1F8}":["Serbia","\u585E\u5C14\u7EF4\u4E9A"],"\u{1F1F7}\u{1F1EA}":["R\xE9union","\u7559\u5C3C\u6C6A","\u6CD5\u5C5E\u7559\u5C3C\u6C6A"],"\u{1F1F7}\u{1F1FA}":["Russia","\u4FC4\u7F57\u65AF","\u4FC4\u56FD","\u4FC4\u7F85\u65AF","\u4F2F\u529B","\u83AB\u65AF\u79D1","\u5723\u5F7C\u5F97\u5821","\u897F\u4F2F\u5229\u4E9A","\u4EAC\u4FC4","\u676D\u4FC4","\u5EE3\u4FC4","\u6EEC\u4FC4","\u5E7F\u4FC4","\u6CAA\u4FC4","Moscow"],"\u{1F1F8}\u{1F1E6}":["Saudi","\u6C99\u7279\u963F\u62C9\u4F2F","\u6C99\u7279","Riyadh","\u5229\u96C5\u5F97"],"\u{1F1F8}\u{1F1EA}":["Sweden","\u745E\u5178","\u65AF\u5FB7\u54E5\u5C14\u6469","Stockholm"],"\u{1F1F8}\u{1F1EC}":["Singapore","\u65B0\u52A0\u5761","\u72EE\u57CE","\u6CAA\u65B0","\u4EAC\u65B0","\u4E2D\u65B0","\u6CC9\u65B0","\u7A57\u65B0","\u6DF1\u65B0","\u676D\u65B0","\u5E7F\u65B0","\u5EE3\u65B0","\u6EEC\u65B0"],"\u{1F1F8}\u{1F1EE}":["Slovenia","\u65AF\u6D1B\u6587\u5C3C\u4E9A"],"\u{1F1F8}\u{1F1F0}":["Slovakia","\u65AF\u6D1B\u4F10\u514B"],"\u{1F1F9}\u{1F1EC}":["Togo","\u591A\u54E5","\u6D1B\u7F8E","Lom\xE9","Lome"],"\u{1F1F9}\u{1F1ED}":["Thailand","\u6CF0\u56FD","\u6CF0\u570B","\u66FC\u8C37"],"\u{1F1F9}\u{1F1F3}":["Tunisia","\u7A81\u5C3C\u65AF"],"\u{1F1F9}\u{1F1F7}":["Turkey","\u571F\u8033\u5176","\u4F0A\u65AF\u5766\u5E03\u5C14","Istanbul"],"\u{1F1F9}\u{1F1FC}":["Taiwan","\u53F0\u6E7E","\u81FA\u7063","\u53F0\u7063","\u4E2D\u83EF\u6C11\u570B","\u4E2D\u534E\u6C11\u56FD","\u53F0\u5317","\u53F0\u4E2D","\u65B0\u5317","\u5F70\u5316","\u53F0","\u81FA","Taipei","Tai Wan"],"\u{1F1FA}\u{1F1E6}":["Ukraine","\u4E4C\u514B\u5170","\u70CF\u514B\u862D"],"\u{1F1FA}\u{1F1F8}":["United States","\u7F8E\u56FD","America","\u7F8E","\u4EAC\u7F8E","\u6CE2\u7279\u5170","\u8FBE\u62C9\u65AF","\u4FC4\u52D2\u5188","Oregon","\u51E4\u51F0\u57CE","\u8D39\u5229\u8499","\u7845\u8C37","\u77FD\u8C37","\u62C9\u65AF\u7EF4\u52A0\u65AF","\u6D1B\u6749\u77F6","\u5723\u4F55\u585E","\u5723\u514B\u62C9\u62C9","\u897F\u96C5\u56FE","\u829D\u52A0\u54E5","\u6CAA\u7F8E","\u54E5\u4F26\u5E03","\u7EBD\u7EA6","New York","Los Angeles","San Jose","Sillicon Valley","Michigan","\u4FC4\u4EA5\u4FC4","Ohio","\u9A6C\u7EB3\u8428\u65AF","Manassas","\u5F17\u5409\u5C3C\u4E9A","Virginia"],"\u{1F1FA}\u{1F1FE}":["Uruguay","\u4E4C\u62C9\u572D"],"\u{1F1FB}\u{1F1E6}":["Vatican","Vatican City","Holy See","\u68B5\u8482\u5188","\u68B5\u8482\u5CA1"],"\u{1F1FB}\u{1F1EA}":["Venezuela","\u59D4\u5185\u745E\u62C9"],"\u{1F1FB}\u{1F1F3}":["Vietnam","\u8D8A\u5357","\u80E1\u5FD7\u660E"],"\u{1F1FF}\u{1F1E6}":["South Africa","\u5357\u975E"],"\u{1F1E8}\u{1F1F3}":["China","\u4E2D\u56FD","\u4E2D\u570B","\u56DE\u56FD","\u56DE\u570B","\u56FD\u5185","\u570B\u5167","\u534E\u4E1C","\u534E\u897F","\u534E\u5357","\u534E\u5317","\u534E\u4E2D","\u6C5F\u82CF","\u5317\u4EAC","\u4E0A\u6D77","\u5E7F\u5DDE","\u6DF1\u5733","\u676D\u5DDE","\u5F90\u5DDE","\u9752\u5C9B","\u5B81\u6CE2","\u9547\u6C5F"]},r=e.match(/[\uD83C][\uDDE6-\uDDFF][\uD83C][\uDDE6-\uDDFF]/)?.[0]||"\u{1F3F4}\u200D\u2620\uFE0F";for(let n of Object.keys(t))if(t[n].some(a=>RegExp(`${a}`,"i").test(e)))return/内蒙古/.test(e)&&["\u{1F1F2}\u{1F1F3}"].includes(n)?r="\u{1F1E8}\u{1F1F3}":r=n;for(let n of Object.keys(wm))if(wm[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 $d(e){return wm[sc(e)]?.[0]}function Pf(e){return e.replace(/[\uD83C][\uDDE6-\uDDFF][\uD83C][\uDDE6-\uDDFF]|🏴‍☠️|🏳️‍🌈/g,"").trim()}var Bd=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 xd=Zr(oC()),Bm=Zr(j0());async function uc({url:e,domain:t,type:r="A",timeout:n,edns:i}){let a=xd.default.encode({type:"query",id:0,flags:xd.default.RECURSION_DESIRED,questions:[{type:r,name:t}],additionals:[{type:"OPT",name:".",udpPayloadSize:4096,flags:0,options:[{code:"CLIENT_SUBNET",ip:i,sourcePrefixLength:Ur(i)?24:56,scopePrefixLength:0}]}]}),u=Bm.Buffer.from(a).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),l=await G.http.get({url:`${e}?dns=${encodeURIComponent(u)}`,headers:{Accept:"application/dns-message"},"binary-mode":!0,encoding:null,timeout:n});return xd.default.decode(Bm.Buffer.from(G.env.isQX?l.bodyBytes:l.body))}var Pm=Zr($m());var{isNode:lC,isQX:Nk,isLoon:Lk,isSurge:Uk,isStash:jk,isShadowRocket:Hk,isLanceX:Mk,isEgern:qk,isGUIforCores:Vk}=ki(),ha="Node";lC&&(ha="Node");Nk&&(ha="QX");Lk&&(ha="Loon");Uk&&(ha="Surge");jk&&(ha="Stash");Hk&&(ha="Shadowrocket");qk&&(ha="Egern");Mk&&(ha="LanceX");Vk&&(ha="GUI.for.Cores");var Ko={},Kk={};try{if(typeof $environment<"u"&&(Ko.env=$environment),typeof $loon<"u"&&(Ko.loon=$loon),typeof $script<"u"&&(Ko.script=$script),typeof $Plugin<"u"&&(Ko.plugin=$Plugin),lC){Ko.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)&&(Ko.node.env[e]=env[e])}}catch(e){}var zo={backend:ha,version:C0,feature:Kk,meta:Ko};function zk(e){return e&&typeof e=="object"&&!Array.isArray(e)}function Tf(e){return e.startsWith("<")&&e.endsWith(">")?e.slice(1,-1):e}function fC(e,t){let r=typeof t=="string"?JSON.parse(t):t;for(let n in r)if(zk(r[n]))if(n.endsWith("!")){let i=Tf(n.slice(0,-1));e[i]=r[n]}else{let i=Tf(n);e[i]||Object.assign(e,{[i]:{}}),fC(e[i],r[i])}else if(Array.isArray(r[n]))if(n.startsWith("+")){let i=Tf(n.slice(1));e[i]||Object.assign(e,{[i]:[]}),e[i]=[...r[n],...e[i]]}else if(n.endsWith("+")){let i=Tf(n.slice(0,-1));e[i]||Object.assign(e,{[i]:[]}),e[i]=[...e[i],...r[n]]}else{let i=Tf(n);Object.assign(e,{[i]:r[n]})}else Object.assign(e,{[n]:r[n]});return e}function Gk({rule:e}){return{name:"Conditional Filter",func:t=>t.map(r=>Od(e,r))}}function Od(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=>Od(r,t));case"OR":return e.child.some(r=>Od(r,t));case"NOT":return!Od(e.child,t);default:throw new Error(`Unknown operator: ${e.operator}`)}}function Yk(e){return{name:"Quick Setting Operator",func:r=>{if(t(e.useless)){let i=gC().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 Wk({mode:e,tw:t}){return{name:"Flag Operator",func:r=>r.map(n=>{if(e==="remove")n.name=Pf(n.name);else{let i=sc(n.name);n.name=Pf(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 Xk(e){let{action:t,template:r,link:n,position:i}={action:"rename",template:"0 1 2 3 4 5 6 7 8 9",link:"-",position:"back",...e};return{name:"Handle Duplicate Operator",func:a=>{if(t==="delete"){let s={};return a.filter(u=>s[u.name]?!1:(s[u.name]=!0,!0))}else if(t==="rename"){let s=r.split(" "),u={},l=0;a.forEach(d=>{typeof u[d.name]>"u"?u[d.name]=1:u[d.name]++,l=Math.max(u[d.name].toString().length,l)});let f={};return a.map(d=>{if(u[d.name]>1){typeof f[d.name]>"u"&&(f[d.name]=1);let g="",p=f[d.name]++,h=0;for(;p>0;)g=s[p%10]+g,p=parseInt(p/10),h++;for(;h++{switch(e){case"asc":case"desc":return t.sort((r,n)=>{let i=r.name>n.name?1:-1;return i*=e==="desc"?-1:1,i});case"random":return oN(t);default:throw new Error("Unknown sort option: "+e)}}}}function Zk(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=>xm(i)),n.sort((i,a)=>{let s=cC(r,i.name),u=cC(r,a.name);return s&&!u?-1:u&&!s?1:s&&u?st.map(r=>{for(let{expr:n,now:i}of e)r.name=r.name.replace(xm(n,"g"),i).trim();return r})}}function Qk(e){let t=e.map(r=>({expr:r,now:""}));return{name:"Regex Delete Operator",func:hC(t).func}}function eN(e,t,r,n,i){return{name:"Script Operator",func:async a=>{let s=a;if(s?.$file?.type==="mihomoProfile")try{let u=Xs.safeLoad(e),l;if(s?.$content)try{l=Xs.safeLoad(s?.$content)}catch(f){G.error(f.message??f)}if(typeof u!="object")throw new Error("patch is not an object");return s.$content=Nt.yaml.safeDump(fC(l||(s?.$file?.sourceType==="none"?{}:{proxies:await wi({type:s?.$file?.sourceType||"collection",name:s?.$file?.sourceName,platform:"mihomo",produceType:"internal",produceOpts:{"delete-underscore-fields":!0}})}),u)),s}catch{}return await async function(){s=Td("operator",e,r,i)(a,t,{source:n,...zo})}(),s},nodeFunc:async a=>{let s=a;return await async function(){s=Td("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,...zo})}(),s}}}function tN(e){let t,r;try{let n=e.split(":");r=parseInt(n[2],16);let i=parseInt(n[3],16),a=parseInt(n[4],16),s=i>>8,u=i&255,l=a>>8,f=a&255;if(t=`${s}.${u}.${l}.${f}`,r<=0||r>65535)throw new Error(`Invalid port number: ${r}`);if(!Ur(t))throw new Error(`Invalid IP address: ${t}`)}catch(n){G.error(`IP4P \u89E3\u6790\u5931\u8D25: ${n}`)}return{server:t,port:r}}var dC={Custom:async function(e,t,r,n,i,a){let s=bs(`CUSTOM:${a}:${e}:${t}`),u=rn.get(s);if(!r&&u)return u;let l=t==="IPv6"?"AAAA":"A",f=await uc({url:a,domain:e,type:l,timeout:n,edns:i}),{answers:d}=f;if(!Array.isArray(d)||d.length===0)throw new Error("No answers");let g=d.filter(p=>p?.type===l).map(p=>p?.data).filter(p=>p);if(g.length===0)throw new Error("No answers");return rn.set(s,g),g},Google:async function(e,t,r,n,i){let a=bs(`GOOGLE:${e}:${t}`),s=rn.get(a);if(!r&&s)return s;let u=t==="IPv6"?"AAAA":"A",l=await uc({url:"https://8.8.4.4/dns-query",domain:e,type:u,timeout:n,edns:i}),{answers:f}=l;if(!Array.isArray(f)||f.length===0)throw new Error("No answers");let d=f.filter(g=>g?.type===u).map(g=>g?.data).filter(g=>g);if(d.length===0)throw new Error("No answers");return rn.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=bs(`IP-API:${e}`),a=rn.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}),u=JSON.parse(s.body);if(u.status!=="success")throw new Error(`Status is ${u.status}`);if(!u.query||u.query===0)throw new Error("No answers");let l=[u.query];if(l.length===0)throw new Error("No answers");return rn.set(i,l),l},Cloudflare:async function(e,t,r,n,i){let a=bs(`CLOUDFLARE:${e}:${t}`),s=rn.get(a);if(!r&&s)return s;let u=t==="IPv6"?"AAAA":"A",l=await uc({url:"https://1.0.0.1/dns-query",domain:e,type:u,timeout:n,edns:i}),{answers:f}=l;if(!Array.isArray(f)||f.length===0)throw new Error("No answers");let d=f.filter(g=>g?.type===u).map(g=>g?.data).filter(g=>g);if(d.length===0)throw new Error("No answers");return rn.set(a,d),d},Ali:async function(e,t,r,n,i){let a=bs(`ALI:${e}:${t}`),s=rn.get(a);if(!r&&s)return s;let u=await G.http.get({url:`http://223.6.6.6/resolve?edns_client_subnet=${i}/${Ur(i)?24:56}&name=${encodeURIComponent(e)}&type=${t==="IPv6"?"AAAA":"A"}&short=1`,headers:{accept:"application/dns-json"},timeout:n}),l=JSON.parse(u.body);if(!Array.isArray(l)||l.length===0)throw new Error("No answers");let f=l;if(f.length===0)throw new Error("No answers");return rn.set(a,f),f},Tencent:async function(e,t,r,n,i){let a=bs(`TENCENT:${e}:${t}`),s=rn.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 f=l;if(f.length===0)throw new Error("No answers");return rn.set(a,f),f}};function pC({provider:e,type:t,filter:r,cache:n,url:i,timeout:a,edns:s}){if(["IPv6","IP4P"].includes(t)&&["IP-API"].includes(e))throw new Error(`\u57DF\u540D\u89E3\u6790\u670D\u52A1\u63D0\u4F9B\u65B9 ${e} \u4E0D\u652F\u6301 ${t}`);let{defaultTimeout:u}=G.read(ns),l=a||u||8e3,f=["IPv6","IP4P"].includes(t)?"IPv6":"IPv4",d=dC[e];if(!d)throw new Error(`\u627E\u4E0D\u5230\u57DF\u540D\u89E3\u6790\u670D\u52A1\u63D0\u4F9B\u65B9: ${e}`);let g=s||"223.6.6.6";if(!Go(g))throw new Error("\u57DF\u540D\u89E3\u6790 EDNS \u5E94\u4E3A IP");return G.info(`Domain Resolver: [${t}] ${e} ${g||""} ${i||""}`),{name:"Resolve Domain Operator",func:async p=>{p.forEach((m,y)=>{!m["_no-resolve"]&&m["no-resolve"]&&(p[y]["_no-resolve"]=m["no-resolve"])});let h={},E=15,v=[...new Set(p.filter(m=>!Go(m.server)&&!m["_no-resolve"]).map(m=>m.server))],b=Math.ceil(v.length/E);for(let m=0;m{h[D]=C,G.info(`Successfully resolved domain: ${D} \u279F ${C}`)}).catch(C=>{G.error(`Failed to resolve domain: ${D} with resolver [${e}]: ${C}`)}));await Promise.all(y)}return p.forEach(m=>{if(!m["_no-resolve"])if(h[m.server]){m._resolved_ips=h[m.server];let y=Array.isArray(h[m.server])?h[m.server][Math.floor(Math.random()*h[m.server].length)]:h[m.server];if(f==="IPv6"&&Rr(y)){try{y=new yd.Address6(y).correctForm()}catch(D){G.error(`Failed to parse IPv6 address: ${y}: ${D}`)}if(/^2001::[^:]+:[^:]+:[^:]+$/.test(y)){m._IP4P=y;let{server:D,port:C}=tN(y);D&&C?(m._domain=m.server,m.server=D,m.port=C,m.resolved=!0,m._IPv4=m.server,Go(m._IP)||(m._IP=m.server)):m.resolved||(m.resolved=!1)}else m._domain=m.server,m.server=y,m.resolved=!0,m[`_${f}`]=m.server,Go(m._IP)||(m._IP=m.server)}else m._domain=m.server,m.server=y,m.resolved=!0,m[`_${f}`]=m.server,Go(m._IP)||(m._IP=m.server)}else m.resolved||(m.resolved=!1)}),p.filter(m=>r==="removeFailed"?Go(m.server)||m["_no-resolve"]||m.resolved:r==="IPOnly"?Go(m.server):r==="IPv4Only"?Ur(m.server):r==="IPv6Only"?Rr(m.server):!0)}}}function Go(e){return Ur(e)||Rr(e)}pC.resolver=dC;function Rm(e){var t=/^[\x00-\x7F]+$/;return t.test(e)}function gC(){return{name:"Useless Filter",func:e=>e.map(t=>{if(t.cipher&&!Rm(t.cipher))return!1;if(t.password&&!Rm(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&&!Rm(n)))return!1}return!/网址|流量|时间|应急|过期|Bandwidth|expire/.test(t.name)})}}function rN(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=sc(a.name),u=t.some(l=>n[l]===s);return r?u:!u})}}function nN({regex:e=[],keep:t=!0}){return{name:"Regex Filter",func:r=>r.map(n=>{let i=e.some(a=>xm(a).test(n.name));return t?i:!i})}}function xm(e,...t){return t=t.join(""),e.startsWith("(?i)")?(e=e.substring(4),new RegExp(e,"i"+t)):new RegExp(e,t)}function iN(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 sN(e,t,r,n,i){return{name:"Script Filter",func:async a=>{let s=Id(a.length,!0);return await async function(){s=Td("filter",e,r,i)(a,t,{source:n,...zo})}(),s},nodeFunc:async a=>{let s=Id(a.length,!0);return await async function(){s=Td("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,...zo})}(),s}}}var kd={"Useless Filter":gC,"Region Filter":rN,"Regex Filter":nN,"Type Filter":iN,"Script Filter":sN,"Conditional Filter":Gk,"Quick Setting Operator":Yk,"Flag Operator":Wk,"Sort Operator":Jk,"Regex Sort Operator":Zk,"Regex Rename Operator":hC,"Regex Delete Operator":Qk,"Script Operator":eN,"Handle Duplicate Operator":Xk,"Resolve Domain Operator":pC};async function aN(e,t){let r=Id(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 u="",l=`${s.message??s}`;throw i&&l===a?(u="",i=`\u6267\u884C\u5931\u8D25 ${a}`):u=`\u6267\u884C\u5FEB\u6377\u8FC7\u6EE4\u811A\u672C \u5931\u8D25 ${l}`,new Error(`\u811A\u672C\u8FC7\u6EE4 ${i}${u}`)}}return t.filter((n,i)=>r[i])}async function uN(e,t){let r=lN(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 u="",l=`${s.message??s}`;throw i&&l===a?(u="",i=`\u6267\u884C\u5931\u8D25 ${a}`):u=`\u6267\u884C\u5FEB\u6377\u811A\u672C \u5931\u8D25 ${l}`,new Error(`\u811A\u672C\u64CD\u4F5C ${i}${u}`)}}return r}async function mC(e,t){if(e.name.indexOf("Filter")!==-1)return aN(e,t);if(e.name.indexOf("Operator")!==-1)return uN(e,t)}function oN(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 lN(e){return JSON.parse(JSON.stringify(e))}function Td(name,script,$arguments,$options){let flowUtils={getFlowField:nc,getFlowHeaders:ra,parseFlowHeaders:_d,flowTransfer:$f,validCheck:Cd,getRmainingDays:K_,normalizeFlowHeader:ic};return G.env.isLoon?new Function("$arguments","$options","$substore","lodash","$persistentStore","$httpClient","$notification","ProxyUtils","yaml","Buffer","b64d","b64e","scriptResourceCache","flowUtils","produceArtifact","require",`${script} return ${name}`)($arguments,$options,G,Pm.default,$persistentStore,$httpClient,$notification,Nt,Nt.yaml,Nt.Buffer,Nt.Base64.decode,Nt.Base64.encode,Em,flowUtils,wi,eval('typeof require !== "undefined"')?Fo:void 0):new Function("$arguments","$options","$substore","lodash","ProxyUtils","yaml","Buffer","b64d","b64e","scriptResourceCache","flowUtils","produceArtifact","require",`${script} return ${name}`)($arguments,$options,G,Pm.default,Nt,Nt.yaml,Nt.Buffer,Nt.Base64.decode,Nt.Base64.encode,Em,flowUtils,wi,eval('typeof require !== "undefined"')?Fo:void 0)}var vC=Zr($m()),lt=class{constructor(t){this.proxy=t,this.output=[]}append(t){if(typeof t>"u")throw new Error("required field is missing");this.output.push(t)}appendIfPresent(t,r){ue(this.proxy,r)&&this.append(t)}toString(){return this.output.join("")}};function ue(e,t){let r=vC.default.get(e,t);return typeof r<"u"&&r!==null}var EC="Surge",Mi={dual:"dual",ipv4:"v4-only",ipv6:"v6-only","ipv4-prefer":"prefer-v4","ipv6-prefer":"prefer-v6"};function lc(){return{produce:(t,r,n={})=>{switch(t.name=t.name.replace(/=|,/g,""),t.ports&&(t.ports=String(t.ports)),t.type){case"ss":return cN(t,n["include-unsupported-proxy"]);case"trojan":return fN(t);case"vmess":return dN(t,n["include-unsupported-proxy"]);case"http":return gN(t);case"direct":return mN(t);case"socks5":return vN(t);case"snell":return EN(t);case"tuic":return wN(t);case"wireguard-surge":return yN(t);case"hysteria2":return bN(t);case"ssh":return pN(t)}if(n["include-unsupported-proxy"]&&t.type==="wireguard")return AN(t);if(n["include-unsupported-proxy"]&&t.type==="anytls"){if(t.network&&(!["tcp"].includes(t.network)||["tcp"].includes(t.network)&&t["reality-opts"]))throw new Error(`Platform ${EC} does not support proxy type ${t.type} with network or reality`);return hN(t)}throw new Error(`Platform ${EC} does not support proxy type: ${t.type}`)}}}function cN(e){let t=new lt(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=Mi[e["ip-version"]]||e["ip-version"];if(t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),ue(e,"plugin")){if(e.plugin==="obfs")t.append(`,obfs=${e["plugin-opts"].mode}`),t.appendIfPresent(`,obfs-host=${e["plugin-opts"].host}`,"plugin-opts.host"),t.appendIfPresent(`,obfs-uri=${e["plugin-opts"].path}`,"plugin-opts.path");else if(!["shadow-tls"].includes(e.plugin))throw new Error(`plugin ${e.plugin} is not supported`)}if(t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ue(e,"shadow-tls-password"))t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni"),t.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port");else if(["shadow-tls"].includes(e.plugin)&&e["plugin-opts"]){let n=e["plugin-opts"].password,i=e["plugin-opts"].host,a=e["plugin-opts"].version;if(n){if(t.append(`,shadow-tls-password=${n}`),i&&t.append(`,shadow-tls-sni=${i}`),a){if(a<2)throw new Error(`shadow-tls version ${a} is not supported`);t.append(`,shadow-tls-version=${a}`)}t.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port")}}return t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function fN(e){let t=new lt(e);t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password="${e.password}"`,"password");let r=Mi[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"),wC(t,e),t.appendIfPresent(`,tls=${e.tls}`,"tls"),t.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ue(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function hN(e){let t=new lt(e);t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password="${e.password}"`,"password");let r=Mi[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.appendIfPresent(`,reuse=${e.reuse}`,"reuse"),t.toString()}function dN(e,t){let r=new lt(e);r.append(`${e.name}=${e.type},${e.server},${e.port}`),r.appendIfPresent(`,username=${e.uuid}`,"uuid");let n=Mi[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"),wC(r,e,t),ue(e,"aead")?r.append(`,vmess-aead=${e.aead}`):r.append(`,vmess-aead=${e.alterId===0}`),r.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),r.appendIfPresent(`,tls=${e.tls}`,"tls"),r.appendIfPresent(`,sni=${e.sni}`,"sni"),r.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),r.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),r.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),r.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),r.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),r.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),r.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),r.appendIfPresent(`,tos=${e.tos}`,"tos"),r.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),r.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ue(e,"shadow-tls-password")&&(r.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),r.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),r.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),r.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),r.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),r.toString()}function pN(e){let t=new lt(e);t.append(`${e.name}=ssh,${e.server},${e.port}`),t.appendIfPresent(`,username="${e.username}"`,"username"),t.appendIfPresent(`,password="${e.password}"`,"password"),t.appendIfPresent(`,private-key=${e["keystore-private-key"]}`,"keystore-private-key"),t.appendIfPresent(`,idle-timeout=${e["idle-timeout"]}`,"idle-timeout"),t.appendIfPresent(`,server-fingerprint="${e["server-fingerprint"]}"`,"server-fingerprint");let r=Mi[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 gN(e){if(e.headers&&Object.keys(e.headers).length>0)throw new Error("headers is unsupported");let t=new lt(e),r=e.tls?"https":"http";t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,username="${e.username}"`,"username"),t.appendIfPresent(`,password="${e.password}"`,"password");let n=Mi[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${n}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ue(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function mN(e){let t=new lt(e);t.append(`${e.name}=direct`);let n=Mi[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 vN(e){let t=new lt(e),r=e.tls?"socks5-tls":"socks5";t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,username="${e.username}"`,"username"),t.appendIfPresent(`,password="${e.password}"`,"password");let n=Mi[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"),ue(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function EN(e){let t=new lt(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=Mi[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,obfs=${e["obfs-opts"]?.mode}`,"obfs-opts.mode"),t.appendIfPresent(`,obfs-host=${e["obfs-opts"]?.host}`,"obfs-opts.host"),t.appendIfPresent(`,obfs-uri=${e["obfs-opts"]?.path}`,"obfs-opts.path"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ue(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.appendIfPresent(`,reuse=${e.reuse}`,"reuse"),t.toString()}function wN(e){let t=new lt(e),r=e.type;(!e.token||e.token.length===0)&&(r="tuic-v5"),t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,uuid=${e.uuid}`,"uuid"),t.appendIfPresent(`,password="${e.password}"`,"password"),t.appendIfPresent(`,token=${e.token}`,"token"),t.appendIfPresent(`,alpn=${Array.isArray(e.alpn)?e.alpn[0]:e.alpn}`,"alpn"),ue(e,"ports")&&t.append(`,port-hopping="${e.ports.replace(/,/g,";")}"`),t.appendIfPresent(`,port-hopping-interval=${e["hop-interval"]}`,"hop-interval");let n=Mi[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${n}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),ue(e,"tfo")?t.append(`,tfo=${e.tfo}`):ue(e,"fast-open")&&t.append(`,tfo=${e["fast-open"]}`),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ue(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.appendIfPresent(`,ecn=${e.ecn}`,"ecn"),t.toString()}function AN(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 lt(e);t.append(`# > WireGuard Proxy ${e.name} # ${e.name}=wireguard`),e["section-name"]=rr(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=Mi[e["ip-version"]]||e["ip-version"];t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ue(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.append(` # > WireGuard Section ${e.name} [WireGuard ${e["section-name"]}] private-key = ${e["private-key"]}`),t.appendIfPresent(` self-ip = ${e.ip}`,"ip"),t.appendIfPresent(` self-ip-v6 = ${e.ipv6}`,"ipv6"),e.dns&&(Array.isArray(e.dns)&&(e.dns=e.dns.join(", ")),t.append(` dns-server = ${e.dns}`)),t.appendIfPresent(` mtu = ${e.mtu}`,"mtu"),r==="prefer-v6"&&t.append(` prefer-ipv6 = true`);let n=Array.isArray(e["allowed-ips"])?e["allowed-ips"].join(","):e["allowed-ips"],i=Array.isArray(e.reserved)?e.reserved.join("/"):e.reserved,a=e["preshared-key"]??e["pre-shared-key"],s={"public-key":e["public-key"],"allowed-ips":n?`"${n}"`:void 0,endpoint:`${e.server}:${e.port}`,keepalive:e["persistent-keepalive"]||e.keepalive,"client-id":i,"preshared-key":a};return t.append(` peer = (${Object.keys(s).filter(u=>s[u]!=null).map(u=>`${u} = ${s[u]}`).join(", ")})`),t.toString()}function yN(e){let t=new lt(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=Mi[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ue(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function bN(e){if(e.obfs||e["obfs-password"])throw new Error("obfs is unsupported");let t=new lt(e);t.append(`${e.name}=hysteria2,${e.server},${e.port}`),t.appendIfPresent(`,password="${e.password}"`,"password"),ue(e,"ports")&&t.append(`,port-hopping="${e.ports.replace(/,/g,";")}"`),t.appendIfPresent(`,port-hopping-interval=${e["hop-interval"]}`,"hop-interval");let r=Mi[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),ue(e,"tfo")?t.append(`,tfo=${e.tfo}`):ue(e,"fast-open")&&t.append(`,tfo=${e["fast-open"]}`),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ue(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.appendIfPresent(`,download-bandwidth=${`${e.down}`.match(/\d+/)?.[0]||0}`,"down"),t.appendIfPresent(`,ecn=${e.ecn}`,"ecn"),t.toString()}function wC(e,t,r){if(ue(t,"network"))if(t.network==="ws"){if(e.append(",ws=true"),ue(t,"ws-opts")&&(e.appendIfPresent(`,ws-path=${t["ws-opts"].path}`,"ws-opts.path"),ue(t,"ws-opts.headers"))){let n=t["ws-opts"].headers,i=Object.keys(n).map(a=>{let s=n[a];return s=`"${s}"`,`${a}:${s}`}).join("|");ta(i)&&e.append(`,ws-headers=${i}`)}}else if(r&&["http"].includes(t.network))G.info(`Include Unsupported Proxy: network ${t.network} -> tcp`);else throw new Error(`network ${t.network} is unsupported`)}var _N={dual:"dual","v4-only":"ipv4","v6-only":"ipv6","prefer-v4":"ipv4-prefer","prefer-v6":"ipv6-prefer"};function qi(){return{type:"ALL",produce:(r,n,i={})=>{let a=r.filter(s=>i["include-unsupported-proxy"]?!0:s.type==="snell"&&s.version>=4||["juicity","naive"].includes(s.type)||["ss"].includes(s.type)&&!["aes-128-ctr","aes-192-ctr","aes-256-ctr","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-gcm","aes-192-gcm","aes-256-gcm","aes-128-ccm","aes-192-ccm","aes-256-ccm","aes-128-gcm-siv","aes-256-gcm-siv","chacha20-ietf","chacha20","xchacha20","chacha20-ietf-poly1305","xchacha20-ietf-poly1305","chacha8-ietf-poly1305","xchacha8-ietf-poly1305","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm","2022-blake3-chacha20-poly1305","lea-128-gcm","lea-192-gcm","lea-256-gcm","rabbit128-poly1305","aegis-128l","aegis-256","aez-384","deoxys-ii-256-128","rc4-md5","none"].includes(s.cipher)||["anytls"].includes(s.type)&&s.network&&(!["tcp"].includes(s.network)||["tcp"].includes(s.network)&&s["reality-opts"])?!1:!["xhttp"].includes(s.network)).map(s=>{if(s.type==="vmess"?(ue(s,"aead")&&(s.aead&&(s.alterId=0),delete s.aead),ue(s,"sni")&&(s.servername=s.sni,delete s.sni),ue(s,"cipher")&&!["auto","none","zero","aes-128-gcm","chacha20-poly1305"].includes(s.cipher)&&(s.cipher="auto")):s.type==="tuic"?(ue(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),ue(s,"tfo")&&!ue(s,"fast-open")&&(s["fast-open"]=s.tfo),(!s.token||s.token.length===0)&&!ue(s,"version")&&(s.version=5)):s.type==="hysteria"?(ue(s,"auth_str")&&!ue(s,"auth-str")&&(s["auth-str"]=s.auth_str),ue(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),ue(s,"tfo")&&!ue(s,"fast-open")&&(s["fast-open"]=s.tfo)):s.type==="wireguard"?(s.keepalive=s.keepalive??s["persistent-keepalive"],s["persistent-keepalive"]=s.keepalive,s["preshared-key"]=s["preshared-key"]??s["pre-shared-key"],s["pre-shared-key"]=s["preshared-key"]):s.type==="snell"&&s.version<3?delete s.udp:s.type==="vless"?ue(s,"sni")&&(s.servername=s.sni,delete s.sni):s.type==="ss"&&ue(s,"shadow-tls-password")&&!ue(s,"plugin")&&(s.plugin="shadow-tls",s["plugin-opts"]={host:s["shadow-tls-sni"],password:s["shadow-tls-password"],version:s["shadow-tls-version"]},delete s["shadow-tls-password"],delete s["shadow-tls-sni"],delete s["shadow-tls-version"]),["vmess","vless"].includes(s.type)&&s.network==="http"){let u=s["http-opts"]?.path;ue(s,"http-opts.path")&&!Array.isArray(u)&&(s["http-opts"].path=[u]);let l=s["http-opts"]?.headers?.Host;ue(s,"http-opts.headers.Host")&&!Array.isArray(l)&&(s["http-opts"].headers.Host=[l])}if(["vmess","vless"].includes(s.type)&&s.network==="h2"){let u=s["h2-opts"]?.path;ue(s,"h2-opts.path")&&Array.isArray(u)&&(s["h2-opts"].path=u[0]);let l=s["h2-opts"]?.headers?.host;ue(s,"h2-opts.headers.Host")&&!Array.isArray(l)&&(s["h2-opts"].headers.host=[l])}if(["ws"].includes(s.network)){let u=s[`${s.network}-opts`]?.path;if(u){let l=/^(.*?)(?:\?ed=(\d+))?$/,[f,d="",g=""]=l.exec(u);s[`${s.network}-opts`].path=d,g!==""&&(s["ws-opts"]["early-data-header-name"]="Sec-WebSocket-Protocol",s["ws-opts"]["max-early-data"]=parseInt(g,10))}else s[`${s.network}-opts`]=s[`${s.network}-opts`]||{},s[`${s.network}-opts`].path="/"}if(s["plugin-opts"]?.tls&&ue(s,"skip-cert-verify")&&(s["plugin-opts"]["skip-cert-verify"]=s["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls","naive"].includes(s.type)&&delete s.tls,s["tls-fingerprint"]&&(s.fingerprint=s["tls-fingerprint"]),delete s["tls-fingerprint"],s["underlying-proxy"]&&(s["dialer-proxy"]=s["underlying-proxy"]),delete s["underlying-proxy"],ue(s,"tls")&&typeof s.tls!="boolean"&&delete s.tls,delete s.subName,delete s.collectionName,delete s.id,delete s.resolved,delete s["no-resolve"],n!=="internal"||i["delete-underscore-fields"])for(let u in s)(s[u]==null||/^_/i.test(u))&&delete s[u];return["grpc"].includes(s.network)&&s[`${s.network}-opts`]&&(delete s[`${s.network}-opts`]["_grpc-type"],delete s[`${s.network}-opts`]["_grpc-authority"]),s["ip-version"]&&(s["ip-version"]=_N[s["ip-version"]]||s["ip-version"]),s});return n==="internal"?a:`proxies: `+a.map(s=>" - "+JSON.stringify(s)+` `).join("")}}}var AC="SurgeMac",CN=lc();function Om(){return{produce:(t,r,n={})=>{switch(t.type){case"external":return yC(t);default:try{return CN.produce(t,r,n)}catch{if(n.useMihomoExternal)return G.log(`${t.name} is not supported on ${AC}, try to use Mihomo(SurgeMac - External Proxy Program) instead`),DN(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 yC(e){let t=new lt(e);if(!e.exec||!e["local-port"])throw new Error(`${e.type}: exec and local-port are required`);return t.append(`${e.name}=external,exec="${e.exec}",local-port=${e["local-port"]}`),Array.isArray(e.args)&&e.args.map(r=>{t.append(`,args="${r}"`)}),Array.isArray(e.addresses)&&e.addresses.map(r=>{t.append(`,addresses=${r}`)}),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),ue(e,"tfo")?t.append(`,tfo=${e.tfo}`):ue(e,"fast-open")&&t.append(`,tfo=${e["fast-open"]}`),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.toString()}function DN(e,t,r){let n=qi().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",Dt.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 FN(e.server)?s.addresses.push(e.server):G.log(`Platform ${AC}, proxy type ${e.type}: addresses should be an IP address, but got ${e.server}`),r.localPort=i-1,yC(s)}}function FN(e){return Ur(e)||Rr(e)}function Tm(){return{type:"ALL",produce:(r,n,i={})=>{let a=r.filter(s=>i["include-unsupported-proxy"]?!0:!["ss","ssr","vmess","vless","socks5","http","snell","trojan","wireguard"].includes(s.type)||s.type==="ss"&&!["aes-128-gcm","aes-192-gcm","aes-256-gcm","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","rc4-md5","chacha20-ietf","xchacha20","chacha20-ietf-poly1305","xchacha20-ietf-poly1305"].includes(s.cipher)||s.type==="snell"&&s.version>=4||s.type==="vless"&&(typeof s.flow<"u"||s["reality-opts"])?!1:s["underlying-proxy"]||s["dialer-proxy"]?(G.error(`Clash \u4E0D\u652F\u6301\u524D\u7F6E\u4EE3\u7406\u5B57\u6BB5. \u5DF2\u8FC7\u6EE4\u8282\u70B9 ${s.name}`),!1):!0).map(s=>{if(s.type==="vmess"?(ue(s,"aead")&&(s.aead&&(s.alterId=0),delete s.aead),ue(s,"sni")&&(s.servername=s.sni,delete s.sni),ue(s,"cipher")&&!["auto","aes-128-gcm","chacha20-poly1305","none"].includes(s.cipher)&&(s.cipher="auto")):s.type==="wireguard"?(s.keepalive=s.keepalive??s["persistent-keepalive"],s["persistent-keepalive"]=s.keepalive,s["preshared-key"]=s["preshared-key"]??s["pre-shared-key"],s["pre-shared-key"]=s["preshared-key"]):s.type==="snell"&&s.version<3?delete s.udp:s.type==="vless"&&ue(s,"sni")&&(s.servername=s.sni,delete s.sni),["vmess","vless"].includes(s.type)&&s.network==="http"){let u=s["http-opts"]?.path;ue(s,"http-opts.path")&&!Array.isArray(u)&&(s["http-opts"].path=[u]);let l=s["http-opts"]?.headers?.Host;ue(s,"http-opts.headers.Host")&&!Array.isArray(l)&&(s["http-opts"].headers.Host=[l])}if(["vmess","vless"].includes(s.type)&&s.network==="h2"){let u=s["h2-opts"]?.path;ue(s,"h2-opts.path")&&Array.isArray(u)&&(s["h2-opts"].path=u[0]);let l=s["h2-opts"]?.headers?.host;ue(s,"h2-opts.headers.Host")&&!Array.isArray(l)&&(s["h2-opts"].headers.host=[l])}if(["ws"].includes(s.network)){let u=s[`${s.network}-opts`]?.path;if(u){let l=/^(.*?)(?:\?ed=(\d+))?$/,[f,d="",g=""]=l.exec(u);s[`${s.network}-opts`].path=d,g!==""&&(s["ws-opts"]["early-data-header-name"]="Sec-WebSocket-Protocol",s["ws-opts"]["max-early-data"]=parseInt(g,10))}else s[`${s.network}-opts`]=s[`${s.network}-opts`]||{},s[`${s.network}-opts`].path="/"}if(s["plugin-opts"]?.tls&&ue(s,"skip-cert-verify")&&(s["plugin-opts"]["skip-cert-verify"]=s["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls","naive"].includes(s.type)&&delete s.tls,s["tls-fingerprint"]&&(s.fingerprint=s["tls-fingerprint"]),delete s["tls-fingerprint"],ue(s,"tls")&&typeof s.tls!="boolean"&&delete s.tls,delete s.subName,delete s.collectionName,delete s.id,delete s.resolved,delete s["no-resolve"],n!=="internal")for(let u in s)(s[u]==null||/^_/i.test(u))&&delete s[u];return["grpc"].includes(s.network)&&s[`${s.network}-opts`]&&(delete s[`${s.network}-opts`]["_grpc-type"],delete s[`${s.network}-opts`]["_grpc-authority"]),s});return n==="internal"?a:`proxies: `+a.map(s=>" - "+JSON.stringify(s)+` `).join("")}}}function Nd(){return{type:"ALL",produce:(r,n,i={})=>{let a=r.filter(s=>!["ss","ssr","vmess","socks5","http","snell","trojan","tuic","vless","wireguard","hysteria","hysteria2","ssh","juicity"].includes(s.type)||s.type==="ss"&&!["aes-128-gcm","aes-192-gcm","aes-256-gcm","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","rc4-md5","chacha20-ietf","xchacha20","chacha20-ietf-poly1305","xchacha20-ietf-poly1305","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"].includes(s.cipher)||s.type==="snell"&&s.version>=4||s.type==="vless"&&s["reality-opts"]&&!["xtls-rprx-vision"].includes(s.flow)?!1:s["underlying-proxy"]||s["dialer-proxy"]?(G.error(`Stash \u6682\u4E0D\u652F\u6301\u524D\u7F6E\u4EE3\u7406\u5B57\u6BB5. \u5DF2\u8FC7\u6EE4\u8282\u70B9 ${s.name}. \u8BF7\u4F7F\u7528 \u4EE3\u7406\u7684\u8F6C\u53D1\u94FE https://stash.wiki/proxy-protocols/proxy-groups#relay`),!1):!0).map(s=>{if(s.type==="vmess"?(ue(s,"aead")&&(s.aead&&(s.alterId=0),delete s.aead),ue(s,"sni")&&(s.servername=s.sni,delete s.sni),ue(s,"cipher")&&!["auto","aes-128-gcm","chacha20-poly1305","none"].includes(s.cipher)&&(s.cipher="auto")):s.type==="tuic"?(ue(s,"alpn")?s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]:s.alpn=["h3"],ue(s,"tfo")&&!ue(s,"fast-open")&&(s["fast-open"]=s.tfo,delete s.tfo),(!s.token||s.token.length===0)&&!ue(s,"version")&&(s.version=5)):s.type==="hysteria"?(ue(s,"auth_str")&&!ue(s,"auth-str")&&(s["auth-str"]=s.auth_str),ue(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),ue(s,"tfo")&&!ue(s,"fast-open")&&(s["fast-open"]=s.tfo,delete s.tfo),ue(s,"down")&&!ue(s,"down-speed")&&(s["down-speed"]=s.down,delete s.down),ue(s,"up")&&!ue(s,"up-speed")&&(s["up-speed"]=s.up,delete s.up),ue(s,"down-speed")&&(s["down-speed"]=`${s["down-speed"]}`.match(/\d+/)?.[0]||0),ue(s,"up-speed")&&(s["up-speed"]=`${s["up-speed"]}`.match(/\d+/)?.[0]||0)):s.type==="hysteria2"?(ue(s,"password")&&!ue(s,"auth")&&(s.auth=s.password,delete s.password),ue(s,"tfo")&&!ue(s,"fast-open")&&(s["fast-open"]=s.tfo,delete s.tfo),ue(s,"down")&&!ue(s,"down-speed")&&(s["down-speed"]=s.down,delete s.down),ue(s,"up")&&!ue(s,"up-speed")&&(s["up-speed"]=s.up,delete s.up),ue(s,"down-speed")&&(s["down-speed"]=`${s["down-speed"]}`.match(/\d+/)?.[0]||0),ue(s,"up-speed")&&(s["up-speed"]=`${s["up-speed"]}`.match(/\d+/)?.[0]||0)):s.type==="wireguard"?(s.keepalive=s.keepalive??s["persistent-keepalive"],s["persistent-keepalive"]=s.keepalive,s["preshared-key"]=s["preshared-key"]??s["pre-shared-key"],s["pre-shared-key"]=s["preshared-key"]):s.type==="snell"&&s.version<3?delete s.udp:s.type==="vless"&&ue(s,"sni")&&(s.servername=s.sni,delete s.sni),["vmess","vless"].includes(s.type)&&s.network==="http"){let u=s["http-opts"]?.path;ue(s,"http-opts.path")&&!Array.isArray(u)&&(s["http-opts"].path=[u]);let l=s["http-opts"]?.headers?.Host;ue(s,"http-opts.headers.Host")&&!Array.isArray(l)&&(s["http-opts"].headers.Host=[l])}if(["vmess","vless"].includes(s.type)&&s.network==="h2"){let u=s["h2-opts"]?.path;ue(s,"h2-opts.path")&&Array.isArray(u)&&(s["h2-opts"].path=u[0]);let l=s["h2-opts"]?.headers?.host;ue(s,"h2-opts.headers.Host")&&!Array.isArray(l)&&(s["h2-opts"].headers.host=[l])}if(["ws"].includes(s.network)){let u=s[`${s.network}-opts`]?.path;if(u){let l=/^(.*?)(?:\?ed=(\d+))?$/,[f,d="",g=""]=l.exec(u);s[`${s.network}-opts`].path=d,g!==""&&(s["ws-opts"]["early-data-header-name"]="Sec-WebSocket-Protocol",s["ws-opts"]["max-early-data"]=parseInt(g,10))}else s[`${s.network}-opts`]=s[`${s.network}-opts`]||{},s[`${s.network}-opts`].path="/"}if(s["plugin-opts"]?.tls&&ue(s,"skip-cert-verify")&&(s["plugin-opts"]["skip-cert-verify"]=s["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls","naive"].includes(s.type)&&delete s.tls,s["tls-fingerprint"]&&(s["server-cert-fingerprint"]=s["tls-fingerprint"]),delete s["tls-fingerprint"],ue(s,"tls")&&typeof s.tls!="boolean"&&delete s.tls,s["test-url"]&&(s["benchmark-url"]=s["test-url"],delete s["test-url"]),s["test-timeout"]&&(s["benchmark-timeout"]=s["test-timeout"],delete s["test-timeout"]),delete s.subName,delete s.collectionName,delete s.id,delete s.resolved,delete s["no-resolve"],n!=="internal")for(let u in s)(s[u]==null||/^_/i.test(u))&&delete s[u];return["grpc"].includes(s.network)&&s[`${s.network}-opts`]&&(delete s[`${s.network}-opts`]["_grpc-type"],delete s[`${s.network}-opts`]["_grpc-authority"]),s});return n==="internal"?a:`proxies: `+a.map(s=>" - "+JSON.stringify(s)+` `).join("")}}}var SN="Loon",cu={dual:"dual",ipv4:"v4-only",ipv6:"v6-only","ipv4-prefer":"prefer-v4","ipv6-prefer":"prefer-v6"};function km(){return{produce:(t,r,n={})=>{switch(t.type){case"ss":return IN(t);case"ssr":return BN(t);case"trojan":return $N(t);case"vmess":return RN(t,n["include-unsupported-proxy"]);case"vless":return PN(t,n["include-unsupported-proxy"]);case"http":return xN(t);case"socks5":return ON(t);case"wireguard":return TN(t);case"hysteria2":return kN(t)}throw new Error(`Platform ${SN} does not support proxy type: ${t.type}`)}}}function IN(e){let t=new lt(e);if(!["rc4","rc4-md5","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","bf-cfb","camellia-128-cfb","camellia-192-cfb","camellia-256-cfb","salsa20","chacha20","chacha20-ietf","aes-128-gcm","aes-192-gcm","aes-256-gcm","chacha20-ietf-poly1305","xchacha20-ietf-poly1305","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"].includes(e.cipher))throw new Error(`cipher ${e.cipher} is not supported`);if(t.append(`${e.name}=shadowsocks,${e.server},${e.port},${e.cipher},"${e.password}"`),ue(e,"plugin")){if(e.plugin==="obfs"){if(e["plugin-opts"]?.mode&&e.cipher.startsWith("2022-"))throw new Error(`${e.cipher} ${e.plugin} is not supported`);t.append(`,obfs-name=${e["plugin-opts"].mode}`),t.appendIfPresent(`,obfs-host=${e["plugin-opts"].host}`,"plugin-opts.host"),t.appendIfPresent(`,obfs-uri=${e["plugin-opts"].path}`,"plugin-opts.path")}else if(!["shadow-tls"].includes(e.plugin))throw new Error(`plugin ${e.plugin} is not supported`)}if(ue(e,"shadow-tls-password"))t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni"),t.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port");else if(["shadow-tls"].includes(e.plugin)&&e["plugin-opts"]){let n=e["plugin-opts"].password,i=e["plugin-opts"].host,a=e["plugin-opts"].version;if(n){if(t.append(`,shadow-tls-password=${n}`),i&&t.append(`,shadow-tls-sni=${i}`),a){if(a<2)throw new Error(`shadow-tls version ${a} is not supported`);t.append(`,shadow-tls-version=${a}`)}t.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port")}}t.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e["block-quic"]==="on"?t.append(",block-quic=true"):e["block-quic"]==="off"&&t.append(",block-quic=false"),e.udp&&t.append(",udp=true");let r=cu[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function BN(e){let t=new lt(e);if(t.append(`${e.name}=shadowsocksr,${e.server},${e.port},${e.cipher},"${e.password}"`),t.append(`,protocol=${e.protocol}`),t.appendIfPresent(`,protocol-param=${e["protocol-param"]}`,"protocol-param"),t.appendIfPresent(`,obfs=${e.obfs}`,"obfs"),t.appendIfPresent(`,obfs-param=${e["obfs-param"]}`,"obfs-param"),ue(e,"shadow-tls-password"))t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni"),t.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port");else if(["shadow-tls"].includes(e.plugin)&&e["plugin-opts"]){let n=e["plugin-opts"].password,i=e["plugin-opts"].host,a=e["plugin-opts"].version;if(n){if(t.append(`,shadow-tls-password=${n}`),i&&t.append(`,shadow-tls-sni=${i}`),a){if(a<2)throw new Error(`shadow-tls version ${a} is not supported`);t.append(`,shadow-tls-version=${a}`)}t.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port")}}t.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e["block-quic"]==="on"?t.append(",block-quic=true"):e["block-quic"]==="off"&&t.append(",block-quic=false"),e.udp&&t.append(",udp=true");let r=cu[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function $N(e){let t=new lt(e);if(t.append(`${e.name}=trojan,${e.server},${e.port},"${e.password}"`),e.network==="tcp"&&delete e.network,ue(e,"network"))if(e.network==="ws")t.append(",transport=ws"),t.appendIfPresent(`,path=${e["ws-opts"]?.path}`,"ws-opts.path"),t.appendIfPresent(`,host=${e["ws-opts"]?.headers?.Host}`,"ws-opts.headers.Host");else throw new Error(`network ${e.network} is unsupported`);t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tls-name=${e.sni}`,"sni"),t.appendIfPresent(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),t.appendIfPresent(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),t.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e["block-quic"]==="on"?t.append(",block-quic=true"):e["block-quic"]==="off"&&t.append(",block-quic=false"),e.udp&&t.append(",udp=true");let r=cu[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function RN(e){let t=!!e["reality-opts"],r=new lt(e);if(r.append(`${e.name}=vmess,${e.server},${e.port},${e.cipher},"${e.uuid}"`),e.network==="tcp"&&delete e.network,ue(e,"network"))if(e.network==="ws")r.append(",transport=ws"),r.appendIfPresent(`,path=${e["ws-opts"]?.path}`,"ws-opts.path"),r.appendIfPresent(`,host=${e["ws-opts"]?.headers?.Host}`,"ws-opts.headers.Host");else if(e.network==="http"){r.append(",transport=http");let i=e["http-opts"]?.path,a=e["http-opts"]?.headers?.Host;r.appendIfPresent(`,path=${Array.isArray(i)?i[0]:i}`,"http-opts.path"),r.appendIfPresent(`,host=${Array.isArray(a)?a[0]:a}`,"http-opts.headers.Host")}else throw new Error(`network ${e.network} is unsupported`);else r.append(",transport=tcp");r.appendIfPresent(`,over-tls=${e.tls}`,"tls"),r.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t?(r.appendIfPresent(`,sni=${e.sni}`,"sni"),r.appendIfPresent(`,public-key="${e["reality-opts"]["public-key"]}"`,"reality-opts.public-key"),r.appendIfPresent(`,short-id=${e["reality-opts"]["short-id"]}`,"reality-opts.short-id")):(r.appendIfPresent(`,tls-name=${e.sni}`,"sni"),r.appendIfPresent(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),r.appendIfPresent(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256")),ue(e,"aead")?r.append(`,alterId=${e.aead?0:1}`):r.append(`,alterId=${e.alterId}`),r.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e["block-quic"]==="on"?r.append(",block-quic=true"):e["block-quic"]==="off"&&r.append(",block-quic=false"),e.udp&&r.append(",udp=true");let n=cu[e["ip-version"]]||e["ip-version"];return r.appendIfPresent(`,ip-mode=${n}`,"ip-version"),r.toString()}function PN(e){let t=!1,r=!!e["reality-opts"];if(typeof e.flow<"u")if(["xtls-rprx-vision"].includes(e.flow))t=!0;else throw new Error(`VLESS flow(${e.flow}) is not supported`);let n=new lt(e);if(n.append(`${e.name}=vless,${e.server},${e.port},"${e.uuid}"`),e.network==="tcp"&&delete e.network,ue(e,"network"))if(e.network==="ws")n.append(",transport=ws"),n.appendIfPresent(`,path=${e["ws-opts"]?.path}`,"ws-opts.path"),n.appendIfPresent(`,host=${e["ws-opts"]?.headers?.Host}`,"ws-opts.headers.Host");else if(e.network==="http"){n.append(",transport=http");let a=e["http-opts"]?.path,s=e["http-opts"]?.headers?.Host;n.appendIfPresent(`,path=${Array.isArray(a)?a[0]:a}`,"http-opts.path"),n.appendIfPresent(`,host=${Array.isArray(s)?s[0]:s}`,"http-opts.headers.Host")}else throw new Error(`network ${e.network} is unsupported`);else n.append(",transport=tcp");n.appendIfPresent(`,over-tls=${e.tls}`,"tls"),n.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t&&n.appendIfPresent(`,flow=${e.flow}`,"flow"),r?(n.appendIfPresent(`,sni=${e.sni}`,"sni"),n.appendIfPresent(`,public-key="${e["reality-opts"]["public-key"]}"`,"reality-opts.public-key"),n.appendIfPresent(`,short-id=${e["reality-opts"]["short-id"]}`,"reality-opts.short-id")):(n.appendIfPresent(`,tls-name=${e.sni}`,"sni"),n.appendIfPresent(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),n.appendIfPresent(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256")),n.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e["block-quic"]==="on"?n.append(",block-quic=true"):e["block-quic"]==="off"&&n.append(",block-quic=false"),e.udp&&n.append(",udp=true");let i=cu[e["ip-version"]]||e["ip-version"];return n.appendIfPresent(`,ip-mode=${i}`,"ip-version"),n.toString()}function xN(e){let t=new lt(e),r=e.tls?"https":"http";t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,${e.username}`,"username"),t.appendIfPresent(`,"${e.password}"`,"password"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),e["block-quic"]==="on"?t.append(",block-quic=true"):e["block-quic"]==="off"&&t.append(",block-quic=false");let n=cu[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${n}`,"ip-version"),t.toString()}function ON(e){let t=new lt(e);t.append(`${e.name}=socks5,${e.server},${e.port}`),t.appendIfPresent(`,${e.username}`,"username"),t.appendIfPresent(`,"${e.password}"`,"password"),t.appendIfPresent(`,over-tls=${e.tls}`,"tls"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),e["block-quic"]==="on"?t.append(",block-quic=true"):e["block-quic"]==="off"&&t.append(",block-quic=false"),e.udp&&t.append(",udp=true");let r=cu[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function TN(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 lt(e);if(t.append(`${e.name}=wireguard`),t.appendIfPresent(`,interface-ip=${e.ip}`,"ip"),t.appendIfPresent(`,interface-ipv6=${e.ipv6}`,"ipv6"),t.appendIfPresent(`,private-key="${e["private-key"]}"`,"private-key"),t.appendIfPresent(`,mtu=${e.mtu}`,"mtu"),e.dns&&Array.isArray(e.dns)){e.dnsv6=e.dns.find(u=>Rr(u));let s=e.dns.find(u=>Ur(u));s||(s=e.dns.find(u=>!Ur(u)&&!Rr(u))),e.dns=s}t.appendIfPresent(`,dns=${e.dns}`,"dns"),t.appendIfPresent(`,dnsv6=${e.dnsv6}`,"dnsv6"),t.appendIfPresent(`,keepalive=${e["persistent-keepalive"]}`,"persistent-keepalive"),t.appendIfPresent(`,keepalive=${e.keepalive}`,"keepalive");let r=Array.isArray(e["allowed-ips"])?e["allowed-ips"].join(","):e["allowed-ips"],n=Array.isArray(e.reserved)?e.reserved.join(","):e.reserved;n&&(n=`,reserved=[${n}]`);let i=e["preshared-key"]??e["pre-shared-key"];i&&(i=`,preshared-key="${i}"`),t.append(`,peers=[{public-key="${e["public-key"]}",allowed-ips="${r??"0.0.0.0/0,::/0"}",endpoint=${e.server}:${e.port}${n??""}${i??""}}]`);let a=cu[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${a}`,"ip-version"),e["block-quic"]==="on"?t.append(",block-quic=true"):e["block-quic"]==="off"&&t.append(",block-quic=false"),t.toString()}function kN(e){if(e["obfs-password"]&&e.obfs!="salamander")throw new Error("only salamander obfs is supported");let t=new lt(e);t.append(`${e.name}=Hysteria2,${e.server},${e.port}`),t.appendIfPresent(`,"${e.password}"`,"password"),t.appendIfPresent(`,tls-name=${e.sni}`,"sni"),t.appendIfPresent(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),t.appendIfPresent(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),e["obfs-password"]&&e.obfs=="salamander"&&t.append(`,salamander-password=${e["obfs-password"]}`),t.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e["block-quic"]==="on"?t.append(",block-quic=true"):e["block-quic"]==="off"&&t.append(",block-quic=false"),e.udp&&t.append(",udp=true"),t.appendIfPresent(`,download-bandwidth=${`${e.down}`.match(/\d+/)?.[0]||0}`,"down"),t.appendIfPresent(`,ecn=${e.ecn}`,"ecn");let r=cu[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}var AX=Zr(o3());function l3(e){let t="none",r=e["reality-opts"],n="",i="",a="";if(r){t="reality";let C=e["reality-opts"]?.["public-key"];C&&(i=`&pbk=${encodeURIComponent(C)}`);let F=e["reality-opts"]?.["short-id"];F&&(n=`&sid=${encodeURIComponent(F)}`);let L=e["reality-opts"]?.["_spider-x"];L&&(a=`&spx=${encodeURIComponent(L)}`)}else e.tls&&(t="tls");let s="";e.alpn&&(s=`&alpn=${encodeURIComponent(Array.isArray(e.alpn)?e.alpn:e.alpn.join(","))}`);let u="";e["skip-cert-verify"]&&(u="&allowInsecure=1");let l="";e.sni&&(l=`&sni=${encodeURIComponent(e.sni)}`);let f="";e["client-fingerprint"]&&(f=`&fp=${encodeURIComponent(e["client-fingerprint"])}`);let d="";e.flow&&(d=`&flow=${encodeURIComponent(e.flow)}`);let g="";e._extra&&(g=`&extra=${encodeURIComponent(e._extra)}`);let p="";e._mode&&(p=`&mode=${encodeURIComponent(e._mode)}`);let h="";e._pqv&&(h=`&pqv=${encodeURIComponent(e._pqv)}`);let E="";e.encryption&&(E=`&encryption=${encodeURIComponent(e.encryption)}`);let v=e.network;e.network==="ws"&&e["ws-opts"]?.["v2ray-http-upgrade"]&&(v="httpupgrade");let b=`&type=${encodeURIComponent(v)}`;if(["grpc"].includes(e.network)){b+=`&mode=${encodeURIComponent(e[`${e.network}-opts`]?.["_grpc-type"]||"gun")}`;let C=e[`${e.network}-opts`]?.["_grpc-authority"];C&&(b+=`&authority=${encodeURIComponent(C)}`)}let m=e[`${e.network}-opts`]?.[`${e.network}-service-name`],y=e[`${e.network}-opts`]?.path,D=e[`${e.network}-opts`]?.headers?.Host;return y&&(b+=`&path=${encodeURIComponent(Array.isArray(y)?y[0]:y)}`),D&&(b+=`&host=${encodeURIComponent(Array.isArray(D)?D[0]:D)}`),m&&(b+=`&serviceName=${encodeURIComponent(m)}`),e.network==="kcp"&&(e.seed&&(b+=`&seed=${encodeURIComponent(e.seed)}`),e.headerType&&(b+=`&headerType=${encodeURIComponent(e.headerType)}`)),`vless://${e.uuid}@${e.server}:${e.port}?security=${encodeURIComponent(t)}${b}${s}${u}${l}${f}${d}${n}${a}${i}${p}${g}${h}${E}#${encodeURIComponent(e.name)}`}function Tc(){return{type:"SINGLE",produce:r=>{let n="";delete r.subName,delete r.collectionName,delete r.id,delete r.resolved,delete r["no-resolve"];for(let i in r)r[i]==null&&delete r[i];switch(["trojan","tuic","hysteria","hysteria2","juicity","anytls"].includes(r.type)&&delete r.tls,!["vmess"].includes(r.type)&&r.server&&Rr(r.server)&&(r.server=`[${r.server}]`),r.type){case"socks5":n=`socks://${encodeURIComponent(Dt.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)}`:Dt.encode(i)}@${r.server}:${r.port}${r.plugin?"/":""}`,r.plugin){n+="?plugin=";let P=r["plugin-opts"];switch(r.plugin){case"obfs":n+=encodeURIComponent(`simple-obfs;obfs=${P.mode}${P.host?";obfs-host="+P.host:""}`);break;case"v2ray-plugin":n+=encodeURIComponent(`v2ray-plugin;obfs=${P.mode}${P.host?";obfs-host"+P.host:""}${P.tls?";tls":""}`);break;case"shadow-tls":n+=encodeURIComponent(`shadow-tls;host=${P.host};password=${P.password};version=${P.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}:${Dt.encode(r.password)}/`,n+=`?remarks=${Dt.encode(r.name)}${r["obfs-param"]?"&obfsparam="+Dt.encode(r["obfs-param"]):""}${r["protocol-param"]?"&protocolparam="+Dt.encode(r["protocol-param"]):""}`,n="ssr://"+Dt.encode(n);break;case"vmess":let a="",s=r.network||"tcp";if(r.network==="http"?(s="tcp",a="http"):r.network==="ws"&&r["ws-opts"]?.["v2ray-http-upgrade"]&&(s="httpupgrade"),n={v:"2",ps:r.name,add:r.server,port:`${r.port}`,id:r.uuid,aid:`${r.alterId||0}`,scy:r.cipher,net:s,type:a,tls:r.tls?"tls":"",alpn:Array.isArray(r.alpn)?r.alpn.join(","):r.alpn,fp:r["client-fingerprint"]},r.tls&&r.sni&&(n.sni=r.sni),r.network){let P=r[`${r.network}-opts`]?.path,U=r[`${r.network}-opts`]?.headers?.Host;["grpc"].includes(r.network)?(n.path=r[`${r.network}-opts`]?.["grpc-service-name"],n.type=r[`${r.network}-opts`]?.["_grpc-type"]||"gun",n.host=r[`${r.network}-opts`]?.["_grpc-authority"]):["kcp","quic"].includes(r.network)?(n.type=r[`${r.network}-opts`]?.[`_${r.network}-type`]||"none",n.host=r[`${r.network}-opts`]?.[`_${r.network}-host`],n.path=r[`${r.network}-opts`]?.[`_${r.network}-path`]):(P&&(n.path=Array.isArray(P)?P[0]:P),U&&(n.host=Array.isArray(U)?U[0]:U))}n="vmess://"+Dt.encode(JSON.stringify(n));break;case"vless":n=l3(r);break;case"trojan":let u="";if(r.network){let P=r.network;if(r.network==="ws"&&r["ws-opts"]?.["v2ray-http-upgrade"]&&(P="httpupgrade"),u=`&type=${encodeURIComponent(P)}`,["grpc"].includes(r.network)){let H=r[`${r.network}-opts`]?.[`${r.network}-service-name`],K=r[`${r.network}-opts`]?.["_grpc-authority"];H&&(u+=`&serviceName=${encodeURIComponent(H)}`),K&&(u+=`&authority=${encodeURIComponent(K)}`),u+=`&mode=${encodeURIComponent(r[`${r.network}-opts`]?.["_grpc-type"]||"gun")}`}let U=r[`${r.network}-opts`]?.path,Y=r[`${r.network}-opts`]?.headers?.Host;U&&(u+=`&path=${encodeURIComponent(Array.isArray(U)?U[0]:U)}`),Y&&(u+=`&host=${encodeURIComponent(Array.isArray(Y)?Y[0]:Y)}`)}let l="";r["client-fingerprint"]&&(l=`&fp=${encodeURIComponent(r["client-fingerprint"])}`);let f="";r.alpn&&(f=`&alpn=${encodeURIComponent(Array.isArray(r.alpn)?r.alpn:r.alpn.join(","))}`);let d=r["reality-opts"],g="",p="",h="",E="",v="",b="";if(d){E="&security=reality";let P=r["reality-opts"]?.["public-key"];P&&(p=`&pbk=${encodeURIComponent(P)}`);let U=r["reality-opts"]?.["short-id"];U&&(g=`&sid=${encodeURIComponent(U)}`);let Y=r["reality-opts"]?.["_spider-x"];Y&&(h=`&spx=${encodeURIComponent(Y)}`),r._extra&&(b=`&extra=${encodeURIComponent(r._extra)}`),r._mode&&(v=`&mode=${encodeURIComponent(r._mode)}`)}n=`trojan://${r.password}@${r.server}:${r.port}?sni=${encodeURIComponent(r.sni||r.server)}${r["skip-cert-verify"]?"&allowInsecure=1":""}${u}${f}${l}${E}${g}${p}${h}${v}${b}#${encodeURIComponent(r.name)}`;break;case"hysteria2":let m=[];r["hop-interval"]&&m.push(`hop-interval=${r["hop-interval"]}`),r.keepalive&&m.push(`keepalive=${r.keepalive}`),r["skip-cert-verify"]&&m.push("insecure=1"),r.obfs&&(m.push(`obfs=${encodeURIComponent(r.obfs)}`),r["obfs-password"]&&m.push(`obfs-password=${encodeURIComponent(r["obfs-password"])}`)),r.sni&&m.push(`sni=${encodeURIComponent(r.sni)}`),r.ports&&m.push(`mport=${r.ports}`),r["tls-fingerprint"]&&m.push(`pinSHA256=${encodeURIComponent(r["tls-fingerprint"])}`),r.tfo&&m.push("fastopen=1"),n=`hysteria2://${encodeURIComponent(r.password)}@${r.server}:${r.port}?${m.join("&")}#${encodeURIComponent(r.name)}`;break;case"hysteria":let y=[];Object.keys(r).forEach(P=>{if(!["name","type","server","port"].includes(P)){let U=P.replace(/-/,"_");["alpn"].includes(P)?r[P]&&y.push(`${U}=${encodeURIComponent(Array.isArray(r[P])?r[P][0]:r[P])}`):["skip-cert-verify"].includes(P)?r[P]&&y.push("insecure=1"):["tfo","fast-open"].includes(P)?r[P]&&!y.includes("fastopen=1")&&y.push("fastopen=1"):["ports"].includes(P)?y.push(`mport=${r[P]}`):["auth-str"].includes(P)?y.push(`auth=${r[P]}`):["up"].includes(P)?y.push(`upmbps=${r[P]}`):["down"].includes(P)?y.push(`downmbps=${r[P]}`):["_obfs"].includes(P)?y.push(`obfs=${r[P]}`):["obfs"].includes(P)?y.push(`obfsParam=${r[P]}`):["sni"].includes(P)?y.push(`peer=${r[P]}`):r[P]&&!/^_/i.test(P)&&y.push(`${U}=${encodeURIComponent(r[P])}`)}}),n=`hysteria://${r.server}:${r.port}?${y.join("&")}#${encodeURIComponent(r.name)}`;break;case"tuic":if(!r.token||r.token.length===0){let P=[];Object.keys(r).forEach(U=>{if(!["name","type","uuid","password","server","port","tls"].includes(U)){let Y=U.replace(/-/,"_");["alpn"].includes(U)?r[U]&&P.push(`${Y}=${encodeURIComponent(Array.isArray(r[U])?r[U][0]:r[U])}`):["skip-cert-verify"].includes(U)?r[U]&&P.push("allow_insecure=1"):["tfo","fast-open"].includes(U)?r[U]&&!P.includes("fast_open=1")&&P.push("fast_open=1"):["disable-sni","reduce-rtt"].includes(U)&&r[U]?P.push(`${Y.replace(/-/g,"_")}=1`):["congestion-controller"].includes(U)?P.push(`congestion_control=${r[U]}`):r[U]&&!/^_/i.test(U)&&P.push(`${Y.replace(/-/g,"_")}=${encodeURIComponent(r[U])}`)}}),n=`tuic://${encodeURIComponent(r.uuid)}:${encodeURIComponent(r.password)}@${r.server}:${r.port}?${P.join("&")}#${encodeURIComponent(r.name)}`}break;case"anytls":n=l3({...r,uuid:r.password,network:r.network||"tcp"}).replace("vless","anytls");let D=[];Object.keys(r).forEach(P=>{if(!["name","type","password","server","port","tls"].includes(P)){let U=P.replace(/-/,"_");["alpn"].includes(P)?r[P]&&D.push(`${U}=${encodeURIComponent(Array.isArray(r[P])?r[P][0]:r[P])}`):["skip-cert-verify"].includes(P)?r[P]&&D.push("insecure=1"):["udp"].includes(P)?r[P]&&D.push("udp=1"):r[P]&&!/^_|client-fingerprint/i.test(P)&&["number","string","boolean"].includes(typeof r[P])&&D.push(`${U.replace(/-/g,"_")}=${encodeURIComponent(r[P])}`)}});let C=n.split("?"),F=C[0],L={};C.length>1&&C[1].split("#")[0].split("&").forEach(Y=>{let[H,K]=Y.split("=");H&&(L[H]=K)}),D.forEach(P=>{let[U,Y]=P.split("=");U&&(L[U]=Y)});let k=Object.keys(L).map(P=>`${P}=${L[P]}`).join("&"),S=n.match(/#(.*)$/),B=S?`#${S[1]}`:"";n=`${F}?${k}${B}`;break;case"wireguard":let O=[];Object.keys(r).forEach(P=>{["name","type","server","port","ip","ipv6","private-key"].includes(P)||(["public-key"].includes(P)?O.push(`publickey=${r[P]}`):["udp"].includes(P)?r[P]&&O.push(`${P}=1`):r[P]&&!/^_/i.test(P)&&O.push(`${P}=${encodeURIComponent(r[P])}`))}),r.ip&&r.ipv6?O.push(`address=${r.ip}/32,${r.ipv6}/128`):r.ip?O.push(`address=${r.ip}/32`):r.ipv6&&O.push(`address=${r.ipv6}/128`),n=`wireguard://${encodeURIComponent(r["private-key"])}@${r.server}:${r.port}/?${O.join("&")}#${encodeURIComponent(r.name)}`;break}return n}}}var QM=Tc();function yh(){return{type:"ALL",produce:r=>{let n=[];return r.map(i=>{try{n.push(QM.produce(i))}catch(a){G.error(`Cannot produce proxy: ${JSON.stringify(i,null,2)} Reason: ${a}`)}}),Dt.encode(n.join(` `))}}}var I2="QX";function bh(){let e=(t,r,n={})=>{switch(t.type){case"ss":return eq(t);case"ssr":return tq(t);case"trojan":return rq(t);case"vmess":return nq(t);case"http":return sq(t);case"socks5":return aq(t);case"vless":return iq(t)}throw new Error(`Platform ${I2} does not support proxy type: ${t.type}`)};return{produce:(t,r,n={})=>{console.log(n);let i=e(t,r,n);if(n["include-unsupported-proxy"]){if(t.flow==="xtls-rprx-vision")throw new Error(`Platform ${I2} does not support flow ${t.flow}`);t["reality-opts"]&&(t["reality-opts"]["public-key"]&&(i=`${i},reality-base64-pubkey=${t["reality-opts"]["public-key"]}`),t["reality-opts"]["short-id"]&&(i=`${i},reality-hex-shortid=${t["reality-opts"]["short-id"]}`))}else if(typeof t.flow<"u"||t["reality-opts"])throw new Error(`Platform ${I2} does not support XTLS/REALITY`);return i}}}function eq(e){let t=new lt(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t);if(e.cipher||(e.cipher="none"),!["none","rc4-md5","rc4-md5-6","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","bf-cfb","cast5-cfb","des-cfb","rc2-cfb","salsa20","chacha20","chacha20-ietf","aes-128-gcm","aes-192-gcm","aes-256-gcm","chacha20-ietf-poly1305","xchacha20-ietf-poly1305","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"].includes(e.cipher))throw new Error(`cipher ${e.cipher} is not supported`);if(r(`shadowsocks=${e.server}:${e.port}`),r(`,method=${e.cipher}`),r(`,password=${e.password}`),zi(e)&&(e.tls=!0),ue(e,"plugin")){if(e.plugin==="obfs"){let i=e["plugin-opts"];r(`,obfs=${i.mode}`)}else if(e.plugin==="v2ray-plugin"&&e["plugin-opts"].mode==="websocket")e["plugin-opts"].tls?r(",obfs=wss"):r(",obfs=ws");else throw new Error("plugin is not supported");n(`,obfs-host=${e["plugin-opts"].host}`,"plugin-opts.host"),n(`,obfs-uri=${e["plugin-opts"].path}`,"plugin-opts.path")}return zi(e)&&(n(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),n(`,tls-alpn=${e["tls-alpn"]}`,"tls-alpn"),n(`,tls-no-session-ticket=${e["tls-no-session-ticket"]}`,"tls-no-session-ticket"),n(`,tls-no-session-reuse=${e["tls-no-session-reuse"]}`,"tls-no-session-reuse"),n(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),n(`,tls-verification=${!e["skip-cert-verify"]}`,"skip-cert-verify"),n(`,tls-host=${e.sni}`,"sni")),n(`,fast-open=${e.tfo}`,"tfo"),n(`,udp-relay=${e.udp}`,"udp"),e._ssr_python_uot?r(",udp-over-tcp=true"):e["udp-over-tcp"]&&(!e["udp-over-tcp-version"]||e["udp-over-tcp-version"]===1?r(",udp-over-tcp=sp.v1"):e["udp-over-tcp-version"]===2&&r(",udp-over-tcp=sp.v2")),t.appendIfPresent(`,server_check_url=${e["test-url"]}`,"test-url"),r(`,tag=${e.name}`),t.toString()}function tq(e){let t=new lt(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 rq(e){let t=new lt(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t);if(r(`trojan=${e.server}:${e.port}`),r(`,password=${e.password}`),ue(e,"network"))if(e.network==="ws")zi(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"&&zi(e)&&r(",over-tls=true"),zi(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 nq(e){let t=new lt(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}`),zi(e)&&(e.tls=!0),ue(e,"network")){if(e.network==="ws")e.tls?r(",obfs=wss"):r(",obfs=ws");else if(e.network==="http")r(",obfs=http");else throw new Error(`network ${e.network} is unsupported`);let a=e[`${e.network}-opts`]?.path,s=e[`${e.network}-opts`]?.headers?.Host;n(`,obfs-uri=${Array.isArray(a)?a[0]:a}`,`${e.network}-opts.path`),n(`,obfs-host=${Array.isArray(s)?s[0]:s}`,`${e.network}-opts.headers.Host`)}else e.tls&&r(",obfs=over-tls");return zi(e)&&(n(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),n(`,tls-alpn=${e["tls-alpn"]}`,"tls-alpn"),n(`,tls-no-session-ticket=${e["tls-no-session-ticket"]}`,"tls-no-session-ticket"),n(`,tls-no-session-reuse=${e["tls-no-session-reuse"]}`,"tls-no-session-reuse"),n(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),n(`,tls-verification=${!e["skip-cert-verify"]}`,"skip-cert-verify"),n(`,tls-host=${e.sni}`,"sni")),ue(e,"aead")?r(`,aead=${e.aead}`):r(`,aead=${e.alterId===0}`),n(`,fast-open=${e.tfo}`,"tfo"),n(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,server_check_url=${e["test-url"]}`,"test-url"),r(`,tag=${e.name}`),t.toString()}function iq(e){let t=new lt(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}`),zi(e)&&(e.tls=!0),ue(e,"network")){if(e.network==="ws")e.tls?r(",obfs=wss"):r(",obfs=ws");else if(e.network==="http")r(",obfs=http");else if(["tcp"].includes(e.network))e.tls&&r(",obfs=over-tls");else if(!["tcp"].includes(e.network))throw new Error(`network ${e.network} is unsupported`);let a=e[`${e.network}-opts`]?.path,s=e[`${e.network}-opts`]?.headers?.Host;n(`,obfs-uri=${Array.isArray(a)?a[0]:a}`,`${e.network}-opts.path`),n(`,obfs-host=${Array.isArray(s)?s[0]:s}`,`${e.network}-opts.headers.Host`)}else e.tls&&r(",obfs=over-tls");return zi(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 sq(e){let t=new lt(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"),zi(e)&&(e.tls=!0),n(`,over-tls=${e.tls}`,"tls"),zi(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 aq(e){let t=new lt(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"),zi(e)&&(e.tls=!0),n(`,over-tls=${e.tls}`,"tls"),zi(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 zi(e){return e.tls}function _h(){return{type:"ALL",produce:(r,n,i={})=>{let a=r.filter(s=>i["include-unsupported-proxy"]?!0:s.type==="snell"&&s.version>=4?!1:!["mieru","sudoku","naive"].includes(s.type)).map(s=>{if(s.type==="vmess")ue(s,"aead")&&(s.aead&&(s.alterId=0),delete s.aead),ue(s,"sni")&&(s.servername=s.sni,delete s.sni),ue(s,"cipher")&&!["auto","none","zero","aes-128-gcm","chacha20-poly1305"].includes(s.cipher)&&(s.cipher="auto");else if(s.type==="tuic")ue(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),ue(s,"tfo")&&!ue(s,"fast-open")&&(s["fast-open"]=s.tfo),(!s.token||s.token.length===0)&&!ue(s,"version")&&(s.version=5);else if(s.type==="hysteria")ue(s,"auth_str")&&!ue(s,"auth-str")&&(s["auth-str"]=s.auth_str),ue(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),ue(s,"tfo")&&!ue(s,"fast-open")&&(s["fast-open"]=s.tfo);else if(s.type==="hysteria2")ue(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),ue(s,"tfo")&&!ue(s,"fast-open")&&(s["fast-open"]=s.tfo);else if(s.type==="wireguard")s.keepalive=s.keepalive??s["persistent-keepalive"],s["persistent-keepalive"]=s.keepalive,s["preshared-key"]=s["preshared-key"]??s["pre-shared-key"],s["pre-shared-key"]=s["preshared-key"];else if(s.type==="snell"&&s.version<3)delete s.udp;else if(s.type==="vless")ue(s,"sni")&&(s.servername=s.sni,delete s.sni);else if(s.type==="ss")ue(s,"shadow-tls-password")&&!ue(s,"plugin")&&(s.plugin="shadow-tls",s["plugin-opts"]={host:s["shadow-tls-sni"],password:s["shadow-tls-password"],version:s["shadow-tls-version"]},delete s["shadow-tls-password"],delete s["shadow-tls-sni"],delete s["shadow-tls-version"]);else{if(["anytls"].includes(s.type)&&s.network&&(!["tcp"].includes(s.network)||["tcp"].includes(s.network)&&s["reality-opts"]))return!1;if(["xhttp"].includes(s.network))return!1}if(["vmess","vless"].includes(s.type)&&s.network==="http"){let u=s["http-opts"]?.path;ue(s,"http-opts.path")&&!Array.isArray(u)&&(s["http-opts"].path=[u]);let l=s["http-opts"]?.headers?.Host;ue(s,"http-opts.headers.Host")&&!Array.isArray(l)&&(s["http-opts"].headers.Host=[l])}if(["vmess","vless"].includes(s.type)&&s.network==="h2"){let u=s["h2-opts"]?.path;ue(s,"h2-opts.path")&&Array.isArray(u)&&(s["h2-opts"].path=u[0]);let l=s["h2-opts"]?.headers?.host;ue(s,"h2-opts.headers.Host")&&!Array.isArray(l)&&(s["h2-opts"].headers.host=[l])}if(["ws"].includes(s.network)){let u=s[`${s.network}-opts`]?.path;if(u){let l=/^(.*?)(?:\?ed=(\d+))?$/,[f,d="",g=""]=l.exec(u);s[`${s.network}-opts`].path=d,g!==""&&(s["ws-opts"]["early-data-header-name"]="Sec-WebSocket-Protocol",s["ws-opts"]["max-early-data"]=parseInt(g,10))}else s[`${s.network}-opts`]=s[`${s.network}-opts`]||{},s[`${s.network}-opts`].path="/"}if(s["plugin-opts"]?.tls&&ue(s,"skip-cert-verify")&&(s["plugin-opts"]["skip-cert-verify"]=s["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls","naive"].includes(s.type)&&delete s.tls,s["tls-fingerprint"]&&(s.fingerprint=s["tls-fingerprint"]),delete s["tls-fingerprint"],s["underlying-proxy"]&&(s["dialer-proxy"]=s["underlying-proxy"]),delete s["underlying-proxy"],ue(s,"tls")&&typeof s.tls!="boolean"&&delete s.tls,delete s.subName,delete s.collectionName,delete s.id,delete s.resolved,delete s["no-resolve"],n!=="internal")for(let u in s)(s[u]==null||/^_/i.test(u))&&delete s[u];return["grpc"].includes(s.network)&&s[`${s.network}-opts`]&&(delete s[`${s.network}-opts`]["_grpc-type"],delete s[`${s.network}-opts`]["_grpc-authority"]),s});return n==="internal"?a:`proxies: `+a.map(s=>" - "+JSON.stringify(s)+` `).join("")}}}var uq="Surfboard";function bp(){return{produce:t=>{switch(t.name=t.name.replace(/=|,/g,""),t.type){case"ss":return oq(t);case"trojan":return lq(t);case"vmess":return cq(t);case"http":return fq(t);case"socks5":return hq(t);case"wireguard-surge":return dq(t)}throw new Error(`Platform ${uq} does not support proxy type: ${t.type}`)}}}function oq(e){let t=new lt(e);if(t.append(`${e.name}=${e.type},${e.server},${e.port}`),!["aes-128-gcm","aes-192-gcm","aes-256-gcm","chacha20-ietf-poly1305","xchacha20-ietf-poly1305","rc4","rc4-md5","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","bf-cfb","camellia-128-cfb","camellia-192-cfb","camellia-256-cfb","salsa20","chacha20","chacha20-ietf"].includes(e.cipher))throw new Error(`cipher ${e.cipher} is not supported`);if(t.append(`,encrypt-method=${e.cipher}`),t.appendIfPresent(`,password=${e.password}`,"password"),ue(e,"plugin"))if(e.plugin==="obfs")t.append(`,obfs=${e["plugin-opts"].mode}`),t.appendIfPresent(`,obfs-host=${e["plugin-opts"].host}`,"plugin-opts.host"),t.appendIfPresent(`,obfs-uri=${e["plugin-opts"].path}`,"plugin-opts.path");else throw new Error(`plugin ${e.plugin} is not supported`);return t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.toString()}function lq(e){let t=new lt(e);return t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password=${e.password}`,"password"),c3(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 cq(e){let t=new lt(e);return t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,username=${e.uuid}`,"uuid"),c3(t,e),ue(e,"aead")?t.append(`,vmess-aead=${e.aead}`):t.append(`,vmess-aead=${e.alterId===0}`),t.appendIfPresent(`,tls=${e.tls}`,"tls"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.toString()}function fq(e){let t=new lt(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 hq(e){let t=new lt(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 dq(e){let t=new lt(e);return t.append(`${e.name}=wireguard`),t.appendIfPresent(`,section-name=${e["section-name"]}`,"section-name"),t.toString()}function c3(e,t){if(ue(t,"network"))if(t.network==="ws"){if(e.append(",ws=true"),ue(t,"ws-opts")&&(e.appendIfPresent(`,ws-path=${t["ws-opts"].path}`,"ws-opts.path"),ue(t,"ws-opts.headers"))){let r=t["ws-opts"].headers,n=Object.keys(r).map(i=>{let a=r[i];return["Host"].includes(i)&&(a=`"${a}"`),`${i}:${a}`}).join("|");ta(n)&&e.append(`,ws-headers=${n}`)}}else throw new Error(`network ${t.network} is unsupported`)}var pq={ipv4:"ipv4_only",ipv6:"ipv6_only","v4-only":"ipv4_only","v6-only":"ipv6_only","ipv4-prefer":"prefer_ipv4","ipv6-prefer":"prefer_ipv6","prefer-v4":"prefer_ipv4","prefer-v6":"prefer_ipv6"},ei=(e,t)=>{let r=pq[e["ip-version"]];e._dns_server&&r&&(t.domain_resolver={server:e._dns_server,strategy:r})},ti=(e,t)=>{t.detour=e["dialer-proxy"]||e.detour},_a=(e,t)=>{["tcp","udp"].includes(e._network)&&(t.network=e._network)},Ci=(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},xs=(e,t)=>{!e||!e.enabled||(t.multiplex={enabled:!0},t.multiplex.protocol=e.protocol,e["max-connections"]&&(t.multiplex.max_connections=parseInt(`${e["max-connections"]}`,10)),e["max-streams"]&&(t.multiplex.max_streams=parseInt(`${e["max-streams"]}`,10)),e["min-streams"]&&(t.multiplex.min_streams=parseInt(`${e["min-streams"]}`,10)),e.padding&&(t.multiplex.padding=!0),(e["brutal-opts"]?.up||e["brutal-opts"]?.down)&&(t.multiplex.brutal={enabled:!0},e["brutal-opts"]?.up&&(t.multiplex.brutal.up_mbps=parseInt(`${e["brutal-opts"]?.up}`,10)),e["brutal-opts"]?.down&&(t.multiplex.brutal.down_mbps=parseInt(`${e["brutal-opts"]?.down}`,10))))},B2=(e,t)=>{let r={type:"ws",headers:{}};if(e["ws-opts"]){let{path:n="",headers:i={},"max-early-data":a,"early-data-header-name":s}=e["ws-opts"];if(r.early_data_header_name=s,r.max_early_data=a?parseInt(a,10):void 0,n!==""&&(r.path=`${n}`),Object.keys(i).length>0){let u={};for(let f of Object.keys(i)){let d=i[f];d!==""&&(Array.isArray(d)||(d=[`${d}`]),d.length>0&&(u[f]=d))}let{Host:l}=u;if(l.length===1)for(let f of`Host:${l[0]}`.split(` `)){let[d,g]=f.split(":");g.trim()!==""&&(u[d.trim()]=g.trim().split(","))}r.headers=u}}if(e["ws-headers"]){let n={};for(let a of Object.keys(e["ws-headers"])){let s=e["ws-headers"][a];s!==""&&(Array.isArray(s)||(s=[`${s}`]),s.length>0&&(n[a]=s))}let{Host:i}=n;if(i.length===1)for(let a of`Host:${i[0]}`.split(` `)){let[s,u]=a.split(":");u.trim()!==""&&(n[s.trim()]=u.trim().split(","))}for(let a of Object.keys(n))r.headers[a]=n[a]}if(e["ws-path"]&&e["ws-path"]!==""&&(r.path=`${e["ws-path"]}`),r.path){let n=/^(.*?)(?:\?ed=(\d+))?$/,[i,a="",s=""]=n.exec(r.path);r.path=a,s!==""&&(r.early_data_header_name="Sec-WebSocket-Protocol",r.max_early_data=parseInt(s,10))}t.tls.insecure&&(t.tls.server_name=r.headers.Host[0]),e["ws-opts"]&&e["ws-opts"]["v2ray-http-upgrade"]&&(r.type="httpupgrade",r.headers.Host&&(r.host=r.headers.Host[0],delete r.headers.Host),r.max_early_data&&delete r.max_early_data,r.early_data_header_name&&delete r.early_data_header_name);for(let n of Object.keys(r.headers)){let i=r.headers[n];i.length===1&&(r.headers[n]=i[0])}t.transport=r},f3=(e,t)=>{let r={type:"http",headers:{}};if(e["http-opts"]){let{method:n="",path:i="",headers:a={}}=e["http-opts"];n!==""&&(r.method=n),Array.isArray(i)?r.path=`${i[0]}`:i!==""&&(r.path=`${i}`);for(let s of Object.keys(a)){let u=a[s];if(u!==""){if(s.toLowerCase()==="host"){let l=u;Array.isArray(l)||(l=`${l}`.split(",").map(f=>f.trim())),l.length>0&&(r.host=l);continue}Array.isArray(u)||(u=`${u}`.split(",").map(l=>l.trim())),u.length>0&&(r.headers[s]=u)}}}if(e["http-host"]&&e["http-host"]!==""){let n=e["http-host"];Array.isArray(n)||(n=`${n}`.split(",").map(i=>i.trim())),n.length>0&&(r.host=n)}if(e["http-path"]&&e["http-path"]!==""){let n=e["http-path"];Array.isArray(n)?r.path=`${n[0]}`:n!==""&&(r.path=`${n}`)}t.tls.insecure&&(t.tls.server_name=r.host[0]),r.host?.length===1&&(r.host=r.host[0]);for(let n of Object.keys(r.headers)){let i=r.headers[n];i.length===1&&(r.headers[n]=i[0])}t.transport=r},h3=(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},$2=(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},Eu=(e,t)=>{e.tls&&(t.tls.enabled=!0),e.servername&&e.servername!==""&&(t.tls.server_name=e.servername),e.peer&&e.peer!==""&&(t.tls.server_name=e.peer),e.sni&&e.sni!==""&&(t.tls.server_name=e.sni),e["skip-cert-verify"]&&(t.tls.insecure=!0),e.insecure&&(t.tls.insecure=!0),e["disable-sni"]&&(t.tls.disable_sni=!0),typeof e.alpn=="string"?t.tls.alpn=[e.alpn]:Array.isArray(e.alpn)&&(t.tls.alpn=e.alpn),e.ca&&(t.tls.certificate_path=`${e.ca}`),e.ca_str&&(t.tls.certificate=[e.ca_str]),e["ca-str"]&&(t.tls.certificate=[e["ca-str"]]),e["reality-opts"]&&(t.tls.reality={enabled:!0},e["reality-opts"]["public-key"]&&(t.tls.reality.public_key=e["reality-opts"]["public-key"]),e["reality-opts"]["short-id"]&&(t.tls.reality.short_id=e["reality-opts"]["short-id"]),t.tls.utls={enabled:!0}),!["hysteria","hysteria2","tuic"].includes(e.type)&&e["client-fingerprint"]&&e["client-fingerprint"]!==""&&(t.tls.utls={enabled:!0,fingerprint:e["client-fingerprint"]}),e._fragment&&(t.tls.fragment=!!e._fragment),e._fragment_fallback_delay&&(t.tls.fragment_fallback_delay=e._fragment_fallback_delay),e._record_fragment&&(t.tls.record_fragment=!!e._record_fragment),e._certificate&&(t.tls.certificate=e._certificate),e._certificate_path&&(t.tls.certificate_path=e._certificate_path),e._certificate_public_key_sha256&&(t.tls.certificate_public_key_sha256=e._certificate_public_key_sha256),e._client_certificate&&(t.tls.client_certificate=e._client_certificate),e._client_certificate_path&&(t.tls.client_certificate_path=e._client_certificate_path),e._client_key&&(t.tls.client_key=e._client_key),e._client_key_path&&(t.tls.client_key_path=e._client_key_path),t.tls.enabled||delete t.tls},gq=(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),Ci(e,t),ti(e,t),ei(e,t),t},mq=(e={})=>{let t={tag:e.name,type:"http",server:e.server,server_port:parseInt(`${e.port}`,10),tls:{enabled:!1,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";if(e.username&&(t.username=e.username),e.password&&(t.password=e.password),e.headers){t.headers={};for(let r of Object.keys(e.headers))t.headers[r]=`${e.headers[r]}`;Object.keys(t.headers).length===0&&delete t.headers}return e["fast-open"]&&(t.udp_fragment=!0),Ci(e,t),ti(e,t),Eu(e,t),ei(e,t),t},vq=(e={})=>{let t={tag:e.name,type:"socks",server:e.server,server_port:parseInt(`${e.port}`,10),version:"5"};if(t.server_port<0||t.server_port>65535)throw"invalid port";return e.username&&(t.username=e.username),e.password&&(t.password=e.password),e.uot&&(t.udp_over_tcp=!0),e["udp-over-tcp"]&&(t.udp_over_tcp={enabled:!0,version:!e["udp-over-tcp-version"]||e["udp-over-tcp-version"]===1?1:2}),e["fast-open"]&&(t.udp_fragment=!0),_a(e,t),Ci(e,t),ti(e,t),ei(e,t),t},Eq=(e={})=>{let t={tag:e.name,type:"shadowsocks",method:e.cipher,password:e.password,detour:`${e.name}_shadowtls`};e.uot&&(t.udp_over_tcp=!0),e["udp-over-tcp"]&&(t.udp_over_tcp={enabled:!0,version:!e["udp-over-tcp-version"]||e["udp-over-tcp-version"]===1?1:2});let r={tag:`${e.name}_shadowtls`,type:"shadowtls",server:e.server,server_port:parseInt(`${e.port}`,10),version:e["plugin-opts"].version,password:e["plugin-opts"].password,tls:{enabled:!0,server_name:e["plugin-opts"].host,utls:{enabled:!0,fingerprint:e["client-fingerprint"]}}};if(r.server_port<0||r.server_port>65535)throw"\u7AEF\u53E3\u503C\u975E\u6CD5";return e["fast-open"]===!0&&(r.udp_fragment=!0),Ci(e,r),ti(e,r),xs(e.smux,t),ei(e,r),{type:"ss-with-st",ssPart:t,stPart:r}},wq=(e={})=>{let t={tag:e.name,type:"shadowsocks",server:e.server,server_port:parseInt(`${e.port}`,10),method:e.cipher,password:e.password};if(t.server_port<0||t.server_port>65535)throw"invalid port";if(e.uot&&(t.udp_over_tcp=!0),e["udp-over-tcp"]&&(t.udp_over_tcp={enabled:!0,version:!e["udp-over-tcp-version"]||e["udp-over-tcp-version"]===1?1:2}),e["fast-open"]&&(t.udp_fragment=!0),_a(e,t),Ci(e,t),ti(e,t),xs(e.smux,t),ei(e,t),e.plugin){let r=[];e.plugin==="obfs"&&(t.plugin="obfs-local",t.plugin_opts="",e["obfs-host"]&&(e["plugin-opts"].host=e["obfs-host"]),Object.keys(e["plugin-opts"]).forEach(n=>{switch(n){case"mode":r.push(`obfs=${e["plugin-opts"].mode}`);break;case"host":r.push(`obfs-host=${e["plugin-opts"].host}`);break;default:r.push(`${n}=${e["plugin-opts"][n]}`);break}})),e.plugin==="v2ray-plugin"&&(t.plugin="v2ray-plugin",e["ws-host"]&&(e["plugin-opts"].host=e["ws-host"]),e["ws-path"]&&(e["plugin-opts"].path=e["ws-path"]),Object.keys(e["plugin-opts"]).forEach(n=>{switch(n){case"tls":e["plugin-opts"].tls&&r.push("tls");break;case"host":r.push(`host=${e["plugin-opts"].host}`);break;case"path":r.push(`path=${e["plugin-opts"].path}`);break;case"headers":r.push(`headers=${JSON.stringify(e["plugin-opts"].headers)}`);break;case"mux":e["plugin-opts"].mux&&(t.multiplex={enabled:!0});break;default:r.push(`${n}=${e["plugin-opts"][n]}`)}})),t.plugin_opts=r.join(";")}return t},Aq=(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),Ci(e,t),ti(e,t),xs(e.smux,t),ei(e,t),t},yq=(e={})=>{let t={tag:e.name,type:"vmess",server:e.server,server_port:parseInt(`${e.port}`,10),uuid:e.uuid,security:e.cipher,alter_id:parseInt(`${e.alterId}`,10),tls:{enabled:!1,server_name:e.server,insecure:!1}};if(["auto","none","zero","aes-128-gcm","chacha20-poly1305","aes-128-ctr"].indexOf(t.security)===-1&&(t.security="auto"),t.server_port<0||t.server_port>65535)throw"invalid port";return e.xudp&&(t.packet_encoding="xudp"),e["fast-open"]&&(t.udp_fragment=!0),e.network==="ws"&&B2(e,t),e.network==="h2"&&h3(e,t),e.network==="http"&&f3(e,t),e.network==="grpc"&&$2(e,t),_a(e,t),Ci(e,t),ti(e,t),Eu(e,t),xs(e.smux,t),ei(e,t),t},bq=(e={})=>{let t={tag:e.name,type:"vless",server:e.server,server_port:parseInt(`${e.port}`,10),uuid:e.uuid,tls:{enabled:!1,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";return e.xudp&&(t.packet_encoding="xudp"),e["fast-open"]&&(t.udp_fragment=!0),e.flow!=null&&(t.flow=e.flow),e.network==="ws"&&B2(e,t),e.network==="h2"&&h3(e,t),e.network==="http"&&f3(e,t),e.network==="grpc"&&$2(e,t),_a(e,t),Ci(e,t),ti(e,t),xs(e.smux,t),Eu(e,t),ei(e,t),t},_q=(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"&&$2(e,t),e.network==="ws"&&B2(e,t),_a(e,t),Ci(e,t),ti(e,t),Eu(e,t),xs(e.smux,t),ei(e,t),t},Cq=(e={})=>{let t={tag:e.name,type:"naive",server:e.server,server_port:parseInt(`${e.port}`,10),tls:{enabled:!0,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";e.username&&(t.username=e.username),e.password&&(t.password=e.password),e.uot&&(t.udp_over_tcp=!0),e["udp-over-tcp"]&&(t.udp_over_tcp={enabled:!0,version:!e["udp-over-tcp-version"]||e["udp-over-tcp-version"]===1?1:2});let r=parseInt(`${e["insecure-concurrency"]}`,10);return Number.isInteger(r)&&r>=0&&(t.insecure_concurrency=r),e["extra-headers"]&&(t.extra_headers=e["extra-headers"]),e["fast-open"]&&(t.udp_fragment=!0),Ci(e,t),ti(e,t),Eu(e,t),xs(e.smux,t),ei(e,t),t.tls?.insecure&&(G.info("Platform sing-box: insecure is not supported on naive outbound"),delete t.tls.insecure),t},Dq=(e={})=>{let t={tag:e.name,type:"hysteria",server:e.server,server_port:parseInt(`${e.port}`,10),disable_mtu_discovery:!1,tls:{enabled:!0,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";e["hop-interval"]&&(t.hop_interval=/^\d+$/.test(e["hop-interval"])?`${e["hop-interval"]}s`:e["hop-interval"]),e.ports&&(t.server_ports=e.ports.split(/\s*,\s*/).map(n=>{let i=n.replace(/\s*-\s*/g,":");return i.includes(":")?i:`${i}:${i}`})),e.auth_str&&(t.auth_str=`${e.auth_str}`),e["auth-str"]&&(t.auth_str=`${e["auth-str"]}`),e["fast-open"]&&(t.udp_fragment=!0);let r=new RegExp("^[0-9]+[ ]*[KMGT]*[Bb]ps$");return r.test(`${e.up}`)&&!`${e.up}`.endsWith("Mbps")?t.up=`${e.up}`:t.up_mbps=parseInt(`${e.up}`,10),r.test(`${e.down}`)&&!`${e.down}`.endsWith("Mbps")?t.down=`${e.down}`:t.down_mbps=parseInt(`${e.down}`,10),e.obfs&&(t.obfs=e.obfs),e.recv_window_conn&&(t.recv_window_conn=e.recv_window_conn),e["recv-window-conn"]&&(t.recv_window_conn=e["recv-window-conn"]),e.recv_window&&(t.recv_window=e.recv_window),e["recv-window"]&&(t.recv_window=e["recv-window"]),e.disable_mtu_discovery&&(typeof e.disable_mtu_discovery=="boolean"?t.disable_mtu_discovery=e.disable_mtu_discovery:e.disable_mtu_discovery===1&&(t.disable_mtu_discovery=!0)),_a(e,t),Eu(e,t),ti(e,t),Ci(e,t),xs(e.smux,t),ei(e,t),t},Fq=(e={})=>{let t={tag:e.name,type:"hysteria2",server:e.server,server_port:parseInt(`${e.port}`,10),password:e.password,obfs:{},tls:{enabled:!0,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";return e["hop-interval"]&&(t.hop_interval=/^\d+$/.test(e["hop-interval"])?`${e["hop-interval"]}s`:e["hop-interval"]),e.ports&&(t.server_ports=e.ports.split(/\s*,\s*/).map(r=>{let n=r.replace(/\s*-\s*/g,":");return n.includes(":")?n:`${n}:${n}`})),e.up&&(t.up_mbps=parseInt(`${e.up}`,10)),e.down&&(t.down_mbps=parseInt(`${e.down}`,10)),e.obfs==="salamander"&&(t.obfs.type="salamander"),e["obfs-password"]&&(t.obfs.password=e["obfs-password"]),t.obfs.type||delete t.obfs,_a(e,t),Eu(e,t),Ci(e,t),ti(e,t),xs(e.smux,t),ei(e,t),t},Sq=(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`),_a(e,t),Ci(e,t),ti(e,t),Eu(e,t),xs(e.smux,t),ei(e,t),t},Iq=(e={})=>{let t={tag:e.name,type:"anytls",server:e.server,server_port:parseInt(`${e.port}`,10),password:e.password,tls:{enabled:!0,server_name:e.server,insecure:!1}};return/^\d+$/.test(e["idle-session-check-interval"])&&(t.idle_session_check_interval=`${e["idle-session-check-interval"]}s`),/^\d+$/.test(e["idle-session-timeout"])&&(t.idle_session_timeout=`${e["idle-session-timeout"]}s`),/^\d+$/.test(e["min-idle-session"])&&(t.min_idle_session=parseInt(`${e["min-idle-session"]}`,10)),_a(e,t),ti(e,t),Eu(e,t),ei(e,t),t},Bq=(e={})=>{let t=["ip","ipv6"].map(n=>e[n]).map(n=>{if(Ur(n))return`${n}/32`;if(Rr(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 _a(e,r),Ci(e,r),ti(e,r),xs(e.smux,r),ei(e,r),r};function _p(){return{type:"ALL",produce:(r,n,i={})=>{let a=[];return qi().produce(r,"internal",{"include-unsupported-proxy":!0}).map(s=>{try{switch(s.type){case"ssh":a.push(gq(s));break;case"http":a.push(mq(s));break;case"socks5":if(s.tls)throw new Error(`Platform sing-box does not support proxy type: ${s.type} with tls`);a.push(vq(s));break;case"ss":if(s.plugin==="shadow-tls"){let{ssPart:u,stPart:l}=Eq(s);a.push(u),a.push(l)}else a.push(wq(s));break;case"ssr":if(i["include-unsupported-proxy"])a.push(Aq(s));else throw new Error(`Platform sing-box does not support proxy type: ${s.type}`);break;case"vmess":if(!s.network||["tcp","ws","grpc","h2","http"].includes(s.network))a.push(yq(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(bq(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(_q(s));else throw new Error(`Platform sing-box does not support proxy type: ${s.type} with flow ${s.flow}`);break;case"naive":a.push(Cq(s));break;case"hysteria":a.push(Dq(s));break;case"hysteria2":a.push(Fq(s,i["include-unsupported-proxy"]));break;case"tuic":if(!s.token||s.token.length===0)a.push(Sq(s));else throw new Error("Platform sing-box does not support proxy type: TUIC v4");break;case"wireguard":a.push(Bq(s));break;case"anytls":a.push(Iq(s));break;default:throw new Error(`Platform sing-box does not support proxy type: ${s.type}`)}}catch(u){G.error(u.message??u)}}),n==="internal"?a:JSON.stringify({outbounds:a},null,2)}}}function Cp(){return{type:"ALL",produce:(r,n,i={})=>{let a=r.filter(s=>!(!["http","https","socks5","ss","trojan","hysteria2","vless","vmess","tuic"].includes(s.type)||s.type==="ss"&&(s.plugin==="obfs"&&!["http","tls"].includes(s["plugin-opts"]?.mode)||!["chacha20-ietf-poly1305","chacha20-poly1305","aes-256-gcm","aes-128-gcm","none","tbale","rc4","rc4-md5","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","bf-cfb","camellia-128-cfb","camellia-192-cfb","camellia-256-cfb","cast5-cfb","des-cfb","idea-cfb","rc2-cfb","seed-cfb","salsa20","chacha20","chacha20-ietf","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"].includes(s.cipher))||s.type==="vmess"&&!["http","ws","tcp"].includes(s.network)&&s.network||s.type==="trojan"&&!["http","ws","tcp"].includes(s.network)&&s.network||s.type==="vless"&&!["http","ws","tcp"].includes(s.network)&&s.network||s.type==="tuic"&&s.token&&s.token.length!==0)).map(s=>{let u={...s},l;s.tls&&!s.sni&&(s.sni=s.server);let f=s.prev_hop||s["underlying-proxy"]||s["dialer-proxy"]||s.detour;if(s.type==="http")s={type:s.tls?"https":"http",name:s.name,server:s.server,port:s.port,username:s.username,password:s.password,tfo:s.tfo||s["fast-open"],next_hop:s.next_hop,...s.tls?{sni:s.sni,skip_tls_verify:s["skip-cert-verify"]}:{}};else if(s.type==="socks5")s={type:"socks5",name:s.name,server:s.server,port:s.port,username:s.username,password:s.password,tfo:s.tfo||s["fast-open"],udp_relay:s.udp||s.udp_relay||s.udp_relay,next_hop:s.next_hop};else if(s.type==="ss")s={type:"shadowsocks",name:s.name,method:s.cipher==="chacha20-ietf-poly1305"?"chacha20-poly1305":s.cipher,server:s.server,port:s.port,password:s.password,tfo:s.tfo||s["fast-open"],udp_relay:s.udp||s.udp_relay||s.udp_relay,next_hop:s.next_hop},u.plugin==="obfs"&&(s.obfs=u["plugin-opts"].mode,s.obfs_host=u["plugin-opts"].host,s.obfs_uri=u["plugin-opts"].path);else if(s.type==="hysteria2")s={type:"hysteria2",name:s.name,server:s.server,port:s.port,auth:s.password,tfo:s.tfo||s["fast-open"],udp_relay:s.udp||s.udp_relay||s.udp_relay,next_hop:s.next_hop,sni:s.sni,skip_tls_verify:s["skip-cert-verify"],port_hopping:s.ports,port_hopping_interval:s["hop-interval"]},u["obfs-password"]&&u.obfs=="salamander"&&(s.obfs="salamander",s.obfs_password=u["obfs-password"]);else if(s.type==="tuic")s={type:"tuic",name:s.name,server:s.server,port:s.port,uuid:s.uuid,password:s.password,next_hop:s.next_hop,sni:s.sni,alpn:Array.isArray(s.alpn)?s.alpn:[s.alpn||"h3"],skip_tls_verify:s["skip-cert-verify"],port_hopping:s.ports,port_hopping_interval:s["hop-interval"]};else if(s.type==="trojan")s.network==="ws"&&(s.websocket={path:s["ws-opts"]?.path,host:s["ws-opts"]?.headers?.Host}),s={type:"trojan",name:s.name,server:s.server,port:s.port,password:s.password,tfo:s.tfo||s["fast-open"],udp_relay:s.udp||s.udp_relay||s.udp_relay,next_hop:s.next_hop,sni:s.sni,skip_tls_verify:s["skip-cert-verify"],websocket:s.websocket};else if(s.type==="vmess"){let d=s.cipher;d&&!["auto","none","zero","aes-128-gcm","chacha20-poly1305"].includes(d)&&(d="auto"),s.network==="ws"?s.transport={[s.tls?"wss":"ws"]:{path:s["ws-opts"]?.path,headers:{Host:s["ws-opts"]?.headers?.Host},sni:s.tls?s.sni:void 0,skip_tls_verify:s.tls?s["skip-cert-verify"]:void 0}}:s.network==="http"?s.transport={http1:{method:s["http-opts"]?.method,path:Array.isArray(s["http-opts"]?.path)?s["http-opts"]?.path[0]:s["http-opts"]?.path,headers:{Host:Array.isArray(s["http-opts"]?.headers?.Host)?s["http-opts"]?.headers?.Host[0]:s["http-opts"]?.headers?.Host},skip_tls_verify:s["skip-cert-verify"]}}:s.network==="h2"?s.transport={http2:{method:s["h2-opts"]?.method,path:Array.isArray(s["h2-opts"]?.path)?s["h2-opts"]?.path[0]:s["h2-opts"]?.path,headers:{Host:Array.isArray(s["h2-opts"]?.headers?.Host)?s["h2-opts"]?.headers?.Host[0]:s["h2-opts"]?.headers?.Host},skip_tls_verify:s["skip-cert-verify"]}}:(s.network==="tcp"||!s.network)&&s.tls&&(s.transport={tls:{sni:s.tls?s.sni:void 0,skip_tls_verify:s.tls?s["skip-cert-verify"]:void 0}});let g;(ue(s,"aead")&&!s.aead||s.alterId!==0)&&(g=!0),s={type:"vmess",name:s.name,server:s.server,port:s.port,user_id:s.uuid,security:d,tfo:s.tfo||s["fast-open"],legacy:g,udp_relay:s.udp||s.udp_relay||s.udp_relay,next_hop:s.next_hop,transport:s.transport}}else if(s.type==="vless"){if(s.network==="ws")s.transport={[s.tls?"wss":"ws"]:{path:s["ws-opts"]?.path,headers:{Host:s["ws-opts"]?.headers?.Host},sni:s.tls?s.sni:void 0,skip_tls_verify:s.tls?s["skip-cert-verify"]:void 0}};else if(s.network==="http")s.transport={http:{method:s["http-opts"]?.method,path:Array.isArray(s["http-opts"]?.path)?s["http-opts"]?.path[0]:s["http-opts"]?.path,headers:{Host:Array.isArray(s["http-opts"]?.headers?.Host)?s["http-opts"]?.headers?.Host[0]:s["http-opts"]?.headers?.Host},skip_tls_verify:s["skip-cert-verify"]}};else if(s.network==="tcp"||!s.network){let d;if((s["reality-opts"]?.["short-id"]||s["reality-opts"]?.["public-key"])&&(d={short_id:s["reality-opts"]["short-id"],public_key:s["reality-opts"]["public-key"]}),s.transport={[s.tls?"tls":"tcp"]:{sni:s.tls?s.sni:void 0,skip_tls_verify:s.tls?s["skip-cert-verify"]:void 0,reality:d}},typeof s.flow<"u"&&!["xtls-rprx-vision"].includes(s.flow))throw new Error(`VLESS flow(${s.flow}) is not supported`);l=s.flow}s={type:"vless",name:s.name,server:s.server,port:s.port,user_id:s.uuid,security:s.cipher,tfo:s.tfo||s["fast-open"],udp_relay:s.udp||s.udp_relay||s.udp_relay,next_hop:s.next_hop,transport:s.transport,flow:l}}if(["http","https","socks5","ss","trojan","vless","vmess"].includes(u.type)){if(ue(u,"shadow-tls-password")){if(u["shadow-tls-version"]!=3)throw new Error(`shadow-tls version ${u["shadow-tls-version"]} is not supported`);s.shadow_tls={password:u["shadow-tls-password"],sni:u["shadow-tls-sni"]}}else if(["shadow-tls"].includes(u.plugin)&&u["plugin-opts"]){if(u["plugin-opts"].version!=3)throw new Error(`shadow-tls version ${u["plugin-opts"].version} is not supported`);s.shadow_tls={password:u["plugin-opts"].password,sni:u["plugin-opts"].host}}}if(["socks5","ss","trojan","vless","vmess"].includes(u.type)&&(["on","true",!0,"1",1].includes(u["block-quic"])?s.block_quic=!0:["off","false",!1,"0",0].includes(u["block-quic"])&&(s.block_quic=!1)),["ss"].includes(u.type)&&s.shadow_tls&&u["udp-port"]>0&&u["udp-port"]<=65535&&(s.udp_port=u["udp-port"]),delete s.subName,delete s.collectionName,delete s.id,delete s.resolved,delete s["no-resolve"],s.transport){for(let d in s.transport)(Object.keys(s.transport[d]).length===0||Object.values(s.transport[d]).every(g=>g==null))&&delete s.transport[d];Object.keys(s.transport).length===0&&delete s.transport}if(n!=="internal")for(let d in s)(s[d]==null||/^_/i.test(d))&&delete s[d];return{[s.type]:{...s,type:void 0,prev_hop:f}}});return n==="internal"?a:`proxies: `+a.map(s=>" - "+JSON.stringify(s)+` `).join("")}}}function d3(){return{type:"ALL",produce:(r,n)=>n==="internal"?r:JSON.stringify(r,null,2)}}var Dp={qx:bh(),QX:bh(),QuantumultX:bh(),surge:lc(),Surge:lc(),SurgeMac:Om(),Loon:km(),Clash:Tm(),meta:qi(),clashmeta:qi(),"clash.meta":qi(),"Clash.Meta":qi(),ClashMeta:qi(),mihomo:qi(),Mihomo:qi(),uri:Tc(),URI:Tc(),v2:yh(),v2ray:yh(),V2Ray:yh(),json:d3(),JSON:d3(),stash:Nd(),Stash:Nd(),shadowrocket:_h(),Shadowrocket:_h(),ShadowRocket:_h(),surfboard:bp(),Surfboard:bp(),singbox:_p(),"sing-box":_p(),egern:Cp(),Egern:Cp()};var w5=Zr($h()),LV=String.raw` // global initializer {{ function $set(obj, path, value) { if (Object(obj) !== obj) return obj; if (!Array.isArray(path)) path = path.toString().match(/[^.[\]]+/g) || []; path .slice(0, -1) .reduce((a, c, i) => (Object(a[c]) === a[c] ? a[c] : (a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1] ? [] : {})), obj)[ path[path.length - 1] ] = value; return obj; } }} // per-parser initializer { const proxy = {}; const obfs = {}; const $ = {}; function handleWebsocket() { if (obfs.type === "ws") { proxy.network = "ws"; $set(proxy, "ws-opts.path", obfs.path); $set(proxy, "ws-opts.headers", obfs['ws-headers']); if (proxy['ws-opts'] && proxy['ws-opts']['headers'] && proxy['ws-opts']['headers'].Host) { proxy['ws-opts']['headers'].Host = proxy['ws-opts']['headers'].Host.replace(/^"(.*)"$/, '$1') } } } function handleShadowTLS() { if (proxy['shadow-tls-password'] && !proxy['shadow-tls-version']) { proxy['shadow-tls-version'] = 2; } } } start = (anytls/shadowsocks/vmess/trojan/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard/hysteria2/ssh/direct) { return proxy; } shadowsocks = tag equals "ss" address (method/passwordk/obfs/obfs_host/obfs_uri/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/udp_port/others)* { proxy.type = "ss"; // handle obfs if (obfs.type == "http" || obfs.type === "tls") { proxy.plugin = "obfs"; $set(proxy, "plugin-opts.mode", obfs.type); $set(proxy, "plugin-opts.host", obfs.host); $set(proxy, "plugin-opts.path", obfs.path); } handleShadowTLS(); } vmess = tag equals "vmess" address (vmess_uuid/vmess_aead/ws/ws_path/ws_headers/method/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls/sni/tls_fingerprint/tls_verification/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "vmess"; proxy.cipher = proxy.cipher || "none"; // Surfboard 与 Surge 默认不一致, 不管 Surfboard https://getsurfboard.com/docs/profile-format/proxy/external-proxy/vmess if (proxy.aead) { proxy.alterId = 0; } else { proxy.alterId = 1; } handleWebsocket(); handleShadowTLS(); } trojan = tag equals "trojan" address (passwordk/ws/ws_path/ws_headers/tls/sni/tls_fingerprint/tls_verification/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "trojan"; handleWebsocket(); handleShadowTLS(); } https = tag equals "https" address (username password)? (usernamek passwordk)? (sni/tls_fingerprint/tls_verification/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "http"; proxy.tls = true; handleShadowTLS(); } http = tag equals "http" address (username password)? (usernamek passwordk)? (ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "http"; handleShadowTLS(); } ssh = tag equals "ssh" address (username password)? (usernamek passwordk)? (server_fingerprint/idle_timeout/private_key/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "ssh"; handleShadowTLS(); } snell = tag equals "snell" address (snell_version/snell_psk/obfs/obfs_host/obfs_uri/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/reuse/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "snell"; // handle obfs if (obfs.type == "http" || obfs.type === "tls") { $set(proxy, "obfs-opts.mode", obfs.type); $set(proxy, "obfs-opts.host", obfs.host); $set(proxy, "obfs-opts.path", obfs.path); } handleShadowTLS(); } tuic = tag equals "tuic" address (alpn/token/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/sni/fast_open/tfo/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/others)* { proxy.type = "tuic"; handleShadowTLS(); } tuic_v5 = tag equals "tuic-v5" address (alpn/passwordk/uuidk/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/sni/fast_open/tfo/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/others)* { proxy.type = "tuic"; proxy.version = 5; handleShadowTLS(); } wireguard = tag equals "wireguard" (section_name/no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "wireguard-surge"; handleShadowTLS(); } hysteria2 = tag equals "hysteria2" address (no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/sni/tls_verification/passwordk/tls_fingerprint/download_bandwidth/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/others)* { proxy.type = "hysteria2"; handleShadowTLS(); } socks5 = tag equals "socks5" address (username password)? (usernamek passwordk)? (udp_relay/no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "socks5"; handleShadowTLS(); } socks5_tls = tag equals "socks5-tls" address (username password)? (usernamek passwordk)? (udp_relay/no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/sni/tls_fingerprint/tls_verification/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "socks5"; proxy.tls = true; handleShadowTLS(); } anytls = tag equals "anytls" address (passwordk/reuse/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/sni/fast_open/tfo/block_quic/others)* { proxy.type = "anytls"; proxy.tls = true; } direct = tag equals "direct" (udp_relay/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/block_quic/others)* { proxy.type = "direct"; } address = comma server:server comma port:port { proxy.server = server; proxy.port = port; } server = ip/domain ip = & { const start = peg$currPos; let j = start; while (j < input.length) { if (input[j] === ",") break; j++; } peg$currPos = j; $.ip = input.substring(start, j).trim(); return true; } { return $.ip; } domain = match:[0-9a-zA-z-_.]+ { const domain = match.join(""); if (/(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/.test(domain)) { return domain; } } port = digits:[0-9]+ { const port = parseInt(digits.join(""), 10); if (port >= 0 && port <= 65535) { return port; } } port_hopping_interval = comma "port-hopping-interval" equals match:$[0-9]+ { proxy["hop-interval"] = parseInt(match.trim()); } username = & { let j = peg$currPos; let start, end; let first = true; while (j < input.length) { if (input[j] === ',') { if (first) { start = j + 1; first = false; } else { end = j; break; } } j++; } const match = input.substring(start, end); if (match.indexOf("=") === -1) { $.username = match; peg$currPos = end; return true; } } { proxy.username = $.username.trim().replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } password = comma match:[^,]+ { proxy.password = match.join("").replace(/^"(.*)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } tls = comma "tls" equals flag:bool { proxy.tls = flag; } sni = comma "sni" equals sni:("off"/domain) { if (sni === "off") { proxy["disable-sni"] = true; } else { proxy.sni = sni; } } tls_verification = comma "skip-cert-verify" equals flag:bool { proxy["skip-cert-verify"] = flag; } tls_fingerprint = comma "server-cert-fingerprint-sha256" equals tls_fingerprint:$[^,]+ { proxy["tls-fingerprint"] = tls_fingerprint.trim(); } snell_psk = comma "psk" equals match:[^,]+ { proxy.psk = match.join(""); } snell_version = comma "version" equals match:$[0-9]+ { proxy.version = parseInt(match.trim()); } usernamek = comma "username" equals match:[^,]+ { proxy.username = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } passwordk = comma "password" equals match:[^,]+ { proxy.password = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } vmess_uuid = comma "username" equals match:[^,]+ { proxy.uuid = match.join(""); } vmess_aead = comma "vmess-aead" equals flag:bool { proxy.aead = flag; } method = comma "encrypt-method" equals cipher:cipher { proxy.cipher = cipher; } cipher = ("aes-128-cfb"/"aes-128-ctr"/"aes-128-gcm"/"aes-192-cfb"/"aes-192-ctr"/"aes-192-gcm"/"aes-256-cfb"/"aes-256-ctr"/"aes-256-gcm"/"bf-cfb"/"camellia-128-cfb"/"camellia-192-cfb"/"camellia-256-cfb"/"cast5-cfb"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"des-cfb"/"idea-cfb"/"none"/"rc2-cfb"/"rc4-md5"/"rc4"/"salsa20"/"seed-cfb"/"xchacha20-ietf-poly1305"/"2022-blake3-aes-128-gcm"/"2022-blake3-aes-256-gcm"); ws = comma "ws" equals flag:bool { obfs.type = "ws"; } ws_headers = comma "ws-headers" equals headers:$[^,]+ { const pairs = headers.split("|"); const result = {}; pairs.forEach(pair => { const [key, value] = pair.trim().split(":"); result[key.trim()] = value.trim().replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }) obfs["ws-headers"] = result; } ws_path = comma "ws-path" equals path:uri { obfs.path = path.trim().replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } obfs = comma "obfs" equals type:("http"/"tls") { obfs.type = type; } obfs_host = comma "obfs-host" equals host:domain { obfs.host = host; }; obfs_uri = comma "obfs-uri" equals path:uri { obfs.path = path } uri = $[^,]+ udp_relay = comma "udp-relay" equals flag:bool { proxy.udp = flag; } fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; } reuse = comma "reuse" equals flag:bool { proxy.reuse = flag; } ecn = comma "ecn" equals flag:bool { proxy.ecn = flag; } tfo = comma "tfo" equals flag:bool { proxy.tfo = flag; } ip_version = comma "ip-version" equals match:[^,]+ { proxy["ip-version"] = match.join(""); } section_name = comma "section-name" equals match:[^,]+ { proxy["section-name"] = match.join(""); } no_error_alert = comma "no-error-alert" equals match:[^,]+ { proxy["no-error-alert"] = match.join(""); } underlying_proxy = comma "underlying-proxy" equals match:[^,]+ { proxy["underlying-proxy"] = match.join(""); } download_bandwidth = comma "download-bandwidth" equals match:[^,]+ { proxy.down = match.join(""); } test_url = comma "test-url" equals match:[^,]+ { proxy["test-url"] = match.join(""); } test_udp = comma "test-udp" equals match:[^,]+ { proxy["test-udp"] = match.join(""); } test_timeout = comma "test-timeout" equals match:$[0-9]+ { proxy["test-timeout"] = parseInt(match.trim()); } tos = comma "tos" equals match:$[0-9]+ { proxy.tos = parseInt(match.trim()); } interface = comma "interface" equals match:[^,]+ { proxy.interface = match.join(""); } allow_other_interface = comma "allow-other-interface" equals flag:bool { proxy["allow-other-interface"] = flag; } hybrid = comma "hybrid" equals flag:bool { proxy.hybrid = flag; } idle_timeout = comma "idle-timeout" equals match:$[0-9]+ { proxy["idle-timeout"] = parseInt(match.trim()); } private_key = comma "private-key" equals match:[^,]+ { proxy["keystore-private-key"] = match.join("").replace(/^"(.*)"$/, '$1'); } server_fingerprint = comma "server-fingerprint" equals match:[^,]+ { proxy["server-fingerprint"] = match.join("").replace(/^"(.*)"$/, '$1'); } block_quic = comma "block-quic" equals match:[^,]+ { proxy["block-quic"] = match.join(""); } udp_port = comma "udp-port" equals match:$[0-9]+ { proxy["udp-port"] = parseInt(match.trim()); } shadow_tls_version = comma "shadow-tls-version" equals match:$[0-9]+ { proxy["shadow-tls-version"] = parseInt(match.trim()); } shadow_tls_sni = comma "shadow-tls-sni" equals match:[^,]+ { proxy["shadow-tls-sni"] = match.join(""); } shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { proxy["shadow-tls-password"] = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } token = comma "token" equals match:[^,]+ { proxy.token = match.join(""); } alpn = comma "alpn" equals match:[^,]+ { proxy.alpn = match.join(""); } uuidk = comma "uuid" equals match:[^,]+ { proxy.uuid = match.join(""); } tag = match:[^=,]* { proxy.name = match.join("").trim(); } comma = _ "," _ equals = _ "=" _ _ = [ \r\t]* bool = b:("true"/"false") { return b === "true" } others = comma [^=,]+ equals [^=,]+ `,X2;function Di(){return X2||(X2=w5.generate(LV)),X2}var A5=Zr($h()),UV=String.raw` // global initializer {{ function $set(obj, path, value) { if (Object(obj) !== obj) return obj; if (!Array.isArray(path)) path = path.toString().match(/[^.[\]]+/g) || []; path .slice(0, -1) .reduce((a, c, i) => (Object(a[c]) === a[c] ? a[c] : (a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1] ? [] : {})), obj)[ path[path.length - 1] ] = value; return obj; } }} // per-parser initializer { const proxy = {}; const obfs = {}; const transport = {}; const $ = {}; function handleTransport() { if (transport.type === "tcp") { /* do nothing */ } else if (transport.type === "ws") { proxy.network = "ws"; $set(proxy, "ws-opts.path", transport.path); $set(proxy, "ws-opts.headers.Host", transport.host); } else if (transport.type === "http") { proxy.network = "http"; $set(proxy, "http-opts.path", transport.path); $set(proxy, "http-opts.headers.Host", transport.host); } } } start = (shadowsocksr/shadowsocks/vmess/vless/trojan/https/http/socks5/hysteria2) { return proxy; } shadowsocksr = tag equals "shadowsocksr"i address method password (ssr_protocol/ssr_protocol_param/obfs_ssr/obfs_ssr_param/obfs_host/obfs_uri/fast_open/udp_relay/udp_port/shadow_tls_version/shadow_tls_sni/shadow_tls_password/ip_mode/block_quic/others)*{ proxy.type = "ssr"; // handle ssr obfs proxy.obfs = obfs.type; } shadowsocks = tag equals "shadowsocks"i address method password (obfs_typev obfs_hostv)? (obfs_ss/obfs_host/obfs_uri/fast_open/udp_relay/udp_port/shadow_tls_version/shadow_tls_sni/shadow_tls_password/ip_mode/block_quic/others)* { proxy.type = "ss"; // handle ss obfs if (obfs.type == "http" || obfs.type === "tls") { proxy.plugin = "obfs"; $set(proxy, "plugin-opts.mode", obfs.type); $set(proxy, "plugin-opts.host", obfs.host); $set(proxy, "plugin-opts.path", obfs.path); } } vmess = tag equals "vmess"i address method uuid (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/vmess_alterId/fast_open/udp_relay/ip_mode/public_key/short_id/block_quic/others)* { proxy.type = "vmess"; proxy.cipher = proxy.cipher || "none"; proxy.alterId = proxy.alterId || 0; handleTransport(); } vless = tag equals "vless"i address uuid (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/flow/public_key/short_id/block_quic/others)* { proxy.type = "vless"; handleTransport(); } trojan = tag equals "trojan"i address password (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/block_quic/others)* { proxy.type = "trojan"; handleTransport(); } hysteria2 = tag equals "hysteria2"i address password (tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/udp_relay/fast_open/download_bandwidth/salamander_password/ecn/ip_mode/block_quic/others)* { proxy.type = "hysteria2"; } https = tag equals "https"i address (username password)? (tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/block_quic/others)* { proxy.type = "http"; proxy.tls = true; } http = tag equals "http"i address (username password)? (fast_open/udp_relay/ip_mode/block_quic/others)* { proxy.type = "http"; } socks5 = tag equals "socks5"i address (username password)? (over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/block_quic/others)* { proxy.type = "socks5"; } address = comma server:server comma port:port { proxy.server = server; proxy.port = port; } server = ip/domain ip = & { const start = peg$currPos; let j = start; while (j < input.length) { if (input[j] === ",") break; j++; } peg$currPos = j; $.ip = input.substring(start, j).trim(); return true; } { return $.ip; } domain = match:[0-9a-zA-z-_.]+ { const domain = match.join(""); if (/(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/.test(domain)) { return domain; } throw new Error("Invalid domain: " + domain); } port = digits:[0-9]+ { const port = parseInt(digits.join(""), 10); if (port >= 0 && port <= 65535) { return port; } throw new Error("Invalid port number: " + port); } method = comma cipher:cipher { proxy.cipher = cipher; } cipher = ("aes-128-cfb"/"aes-128-ctr"/"aes-128-gcm"/"aes-192-cfb"/"aes-192-ctr"/"aes-192-gcm"/"aes-256-cfb"/"aes-256-ctr"/"aes-256-gcm"/"auto"/"bf-cfb"/"camellia-128-cfb"/"camellia-192-cfb"/"camellia-256-cfb"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"none"/"rc4-md5"/"rc4"/"salsa20"/"xchacha20-ietf-poly1305"/"2022-blake3-aes-128-gcm"/"2022-blake3-aes-256-gcm"); username = & { let j = peg$currPos; let start, end; let first = true; while (j < input.length) { if (input[j] === ',') { if (first) { start = j + 1; first = false; } else { end = j; break; } } j++; } const match = input.substring(start, end); if (match.indexOf("=") === -1) { $.username = match; peg$currPos = end; return true; } } { proxy.username = $.username; } password = comma '"' match:[^"]* '"' { proxy.password = match.join(""); } uuid = comma '"' match:[^"]+ '"' { proxy.uuid = match.join(""); } obfs_typev = comma type:("http"/"tls") { obfs.type = type; } obfs_hostv = comma match:[^,]+ { obfs.host = match.join(""); } obfs_ss = comma "obfs-name" equals type:("http"/"tls") { obfs.type = type; } obfs_ssr = comma "obfs" equals type:("plain"/"http_simple"/"http_post"/"random_head"/"tls1.2_ticket_auth"/"tls1.2_ticket_fastauth") { obfs.type = type; } obfs_ssr_param = comma "obfs-param" equals match:$[^,]+ { proxy["obfs-param"] = match; } obfs_host = comma "obfs-host" equals host:domain { obfs.host = host; } obfs_uri = comma "obfs-uri" equals uri:uri { obfs.path = uri; } uri = $[^,]+ transport = comma "transport" equals type:("tcp"/"ws"/"http") { transport.type = type; } transport_host = comma "host" equals host:domain { transport.host = host; } transport_path = comma "path" equals path:uri { transport.path = path; } ssr_protocol = comma "protocol" equals protocol:("origin"/"auth_sha1_v4"/"auth_aes128_md5"/"auth_aes128_sha1"/"auth_chain_a"/"auth_chain_b") { proxy.protocol = protocol; } ssr_protocol_param = comma "protocol-param" equals param:$[^=,]+ { proxy["protocol-param"] = param; } vmess_alterId = comma "alterId" equals alterId:$[0-9]+ { proxy.alterId = parseInt(alterId); } udp_port = comma "udp-port" equals match:$[0-9]+ { proxy["udp-port"] = parseInt(match.trim()); } shadow_tls_version = comma "shadow-tls-version" equals match:$[0-9]+ { proxy["shadow-tls-version"] = parseInt(match.trim()); } shadow_tls_sni = comma "shadow-tls-sni" equals match:[^,]+ { proxy["shadow-tls-sni"] = match.join(""); } shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { proxy["shadow-tls-password"] = match.join(""); } over_tls = comma "over-tls" equals flag:bool { proxy.tls = flag; } tls_name = comma sni:("tls-name") equals host:domain { proxy.sni = host; } sni = comma sni:("sni") equals host:domain { proxy.sni = host; } tls_verification = comma "skip-cert-verify" equals flag:bool { proxy["skip-cert-verify"] = flag; } tls_cert_sha256 = comma "tls-cert-sha256" equals match:[^,]+ { proxy["tls-fingerprint"] = match.join("").replace(/^"(.*)"$/, '$1'); } tls_pubkey_sha256 = comma "tls-pubkey-sha256" equals match:[^,]+ { proxy["tls-pubkey-sha256"] = match.join("").replace(/^"(.*)"$/, '$1'); } flow = comma "flow" equals match:[^,]+ { proxy["flow"] = match.join("").replace(/^"(.*)"$/, '$1'); } public_key = comma "public-key" equals match:[^,]+ { proxy["reality-opts"] = proxy["reality-opts"] || {}; proxy["reality-opts"]["public-key"] = match.join("").replace(/^"(.*)"$/, '$1'); } short_id = comma "short-id" equals match:[^,]+ { proxy["reality-opts"] = proxy["reality-opts"] || {}; proxy["reality-opts"]["short-id"] = match.join("").replace(/^"(.*)"$/, '$1'); } fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; } udp_relay = comma "udp" equals flag:bool { proxy.udp = flag; } ip_mode = comma "ip-mode" equals match:[^,]+ { proxy["ip-version"] = match.join(""); } ecn = comma "ecn" equals flag:bool { proxy.ecn = flag; } download_bandwidth = comma "download-bandwidth" equals match:[^,]+ { proxy.down = match.join(""); } salamander_password = comma "salamander-password" equals match:[^,]+ { proxy['obfs-password'] = match.join(""); proxy.obfs = 'salamander'; } block_quic = comma "block-quic" equals flag:bool { if(flag) proxy["block-quic"] = "on"; else proxy["block-quic"] = "off"; } tag = match:[^=,]* { proxy.name = match.join("").trim(); } comma = _ "," _ equals = _ "=" _ _ = [ \r\t]* bool = b:("true"/"false") { return b === "true" } others = comma [^=,]+ equals [^=,]+ `,J2;function Ca(){return J2||(J2=A5.generate(UV)),J2}var y5=Zr($h()),jV=String.raw` // global initializer {{ function $set(obj, path, value) { if (Object(obj) !== obj) return obj; if (!Array.isArray(path)) path = path.toString().match(/[^.[\]]+/g) || []; path .slice(0, -1) .reduce((a, c, i) => (Object(a[c]) === a[c] ? a[c] : (a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1] ? [] : {})), obj)[ path[path.length - 1] ] = value; return obj; } }} // per-parse initializer { const proxy = {}; const obfs = {}; const $ = {}; function handleObfs() { if (obfs.type === "ws" || obfs.type === "wss") { proxy.network = "ws"; if (obfs.type === 'wss') { proxy.tls = true; } $set(proxy, "ws-opts.path", obfs.path); $set(proxy, "ws-opts.headers.Host", obfs.host); } else if (obfs.type === "over-tls") { proxy.tls = true; } else if (obfs.type === "http") { proxy.network = "http"; $set(proxy, "http-opts.path", obfs.path); $set(proxy, "http-opts.headers.Host", obfs.host); } } } start = (trojan/shadowsocks/vmess/vless/http/socks5) { return proxy } trojan = "trojan" equals address (password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/obfs/obfs_host/obfs_uri/tag/udp_relay/udp_over_tcp/fast_open/server_check_url/reality_base64_pubkey/reality_hex_shortid/others)* { proxy.type = "trojan"; handleObfs(); } shadowsocks = "shadowsocks" equals address (password/method/obfs_ssr/obfs_ss/obfs_host/obfs_uri/ssr_protocol/ssr_protocol_param/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/udp_relay/udp_over_tcp_new/fast_open/tag/server_check_url/reality_base64_pubkey/reality_hex_shortid/others)* { if (proxy.protocol || proxy.type === "ssr") { proxy.type = "ssr"; if (!proxy.protocol) { proxy.protocol = "origin"; } // handle ssr obfs if (obfs.host) proxy["obfs-param"] = obfs.host; if (obfs.type) proxy.obfs = obfs.type; } else { proxy.type = "ss"; // handle ss obfs if (obfs.type == "http" || obfs.type === "tls") { proxy.plugin = "obfs"; $set(proxy, "plugin-opts", { mode: obfs.type }); } else if (obfs.type === "ws" || obfs.type === "wss") { proxy.plugin = "v2ray-plugin"; $set(proxy, "plugin-opts.mode", "websocket"); if (obfs.type === "wss") { $set(proxy, "plugin-opts.tls", true); } } else if (obfs.type === 'over-tls') { throw new Error('ss over-tls is not supported'); } if (obfs.type) { $set(proxy, "plugin-opts.host", obfs.host); $set(proxy, "plugin-opts.path", obfs.path); } } } vmess = "vmess" equals address (uuid/method/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/obfs/obfs_host/obfs_uri/udp_relay/udp_over_tcp/fast_open/aead/server_check_url/reality_base64_pubkey/reality_hex_shortid/others)* { proxy.type = "vmess"; proxy.cipher = proxy.cipher || "none"; if (proxy.aead === false) { proxy.alterId = 1; } else { proxy.alterId = 0; } handleObfs(); } vless = "vless" equals address (uuid/method/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/obfs/obfs_host/obfs_uri/udp_relay/udp_over_tcp/fast_open/aead/server_check_url/reality_base64_pubkey/reality_hex_shortid/others)* { proxy.type = "vless"; proxy.cipher = proxy.cipher || "none"; handleObfs(); } http = "http" equals address (username/password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/fast_open/udp_relay/udp_over_tcp/server_check_url/reality_base64_pubkey/reality_hex_shortid/others)*{ proxy.type = "http"; } socks5 = "socks5" equals address (username/password/password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/fast_open/udp_relay/udp_over_tcp/server_check_url/reality_base64_pubkey/reality_hex_shortid/others)* { proxy.type = "socks5"; } address = server:server ":" port:port { proxy.server = server; proxy.port = port; } server = ip/domain domain = match:[0-9a-zA-z-_.]+ { const domain = match.join(""); if (/(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/.test(domain)) { return domain; } } ip = & { const start = peg$currPos; let end; let j = start; while (j < input.length) { if (input[j] === ",") break; if (input[j] === ":") end = j; j++; } peg$currPos = end || j; $.ip = input.substring(start, end).trim(); return true; } { return $.ip; } port = digits:[0-9]+ { const port = parseInt(digits.join(""), 10); if (port >= 0 && port <= 65535) { return port; } } username = comma "username" equals username:[^,]+ { proxy.username = username.join("").trim(); } password = comma "password" equals password:[^,]+ { proxy.password = password.join("").trim(); } uuid = comma "password" equals uuid:[^,]+ { proxy.uuid = uuid.join("").trim(); } method = comma "method" equals cipher:cipher { proxy.cipher = cipher; }; cipher = ("aes-128-cfb"/"aes-128-ctr"/"aes-128-gcm"/"aes-192-cfb"/"aes-192-ctr"/"aes-192-gcm"/"aes-256-cfb"/"aes-256-ctr"/"aes-256-gcm"/"bf-cfb"/"cast5-cfb"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"des-cfb"/"none"/"rc2-cfb"/"rc4-md5-6"/"rc4-md5"/"salsa20"/"xchacha20-ietf-poly1305"/"2022-blake3-aes-128-gcm"/"2022-blake3-aes-256-gcm"); aead = comma "aead" equals flag:bool { proxy.aead = flag; } udp_relay = comma "udp-relay" equals flag:bool { proxy.udp = flag; } udp_over_tcp = comma "udp-over-tcp" equals flag:bool { throw new Error("UDP over TCP is not supported"); } udp_over_tcp_new = comma "udp-over-tcp" equals param:$[^=,]+ { if (param === "sp.v1") { proxy["udp-over-tcp"] = true; proxy["udp-over-tcp-version"] = 1; } else if (param === "sp.v2") { proxy["udp-over-tcp"] = true; proxy["udp-over-tcp-version"] = 2; } else if (param === "true") { proxy["_ssr_python_uot"] = true; } else { throw new Error("Invalid value for udp-over-tcp"); } } fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; } over_tls = comma "over-tls" equals flag:bool { proxy.tls = flag; } tls_host = comma "tls-host" equals sni:domain { proxy.sni = sni; } tls_verification = comma "tls-verification" equals flag:bool { proxy["skip-cert-verify"] = !flag; } tls_fingerprint = comma "tls-cert-sha256" equals tls_fingerprint:$[^,]+ { proxy["tls-fingerprint"] = tls_fingerprint.trim(); } tls_pubkey_sha256 = comma "tls-pubkey-sha256" equals param:$[^=,]+ { proxy["tls-pubkey-sha256"] = param; } tls_alpn = comma "tls-alpn" equals param:$[^=,]+ { proxy["tls-alpn"] = param; } tls_no_session_ticket = comma "tls-no-session-ticket" equals flag:bool { proxy["tls-no-session-ticket"] = flag; } tls_no_session_reuse = comma "tls-no-session-reuse" equals flag:bool { proxy["tls-no-session-reuse"] = flag; } obfs_ss = comma "obfs" equals type:("http"/"tls"/"wss"/"ws"/"over-tls") { obfs.type = type; return type; } obfs_ssr = comma "obfs" equals type:("plain"/"http_simple"/"http_post"/"random_head"/"tls1.2_ticket_auth"/"tls1.2_ticket_fastauth") { proxy.type = "ssr"; obfs.type = type; return type; } obfs = comma "obfs" equals type:("wss"/"ws"/"over-tls"/"http") { obfs.type = type; return type; }; obfs_host = comma "obfs-host" equals host:domain { obfs.host = host; } obfs_uri = comma "obfs-uri" equals uri:uri { obfs.path = uri; } ssr_protocol = comma "ssr-protocol" equals protocol:("origin"/"auth_sha1_v4"/"auth_aes128_md5"/"auth_aes128_sha1"/"auth_chain_a"/"auth_chain_b") { proxy.protocol = protocol; return protocol; } ssr_protocol_param = comma "ssr-protocol-param" equals param:$[^=,]+ { proxy["protocol-param"] = param; } reality_base64_pubkey = comma "reality-base64-pubkey" equals param:$[^=,]+ { $set(proxy, "reality-opts.public-key", param); } reality_hex_shortid = comma "reality-hex-shortid" equals param:$[^=,]+ { $set(proxy, "reality-opts.short-id", param); } server_check_url = comma "server_check_url" equals param:$[^=,]+ { proxy["test-url"] = param; } uri = $[^,]+ tag = comma "tag" equals tag:[^=,]+ { proxy.name = tag.join(""); } others = comma [^=,]+ equals [^=,]+ comma = _ "," _ equals = _ "=" _ _ = [ \r\t]* bool = b:("true"/"false") { return b === "true" } `,Z2;function Au(){return Z2||(Z2=y5.generate(jV)),Z2}var b5=Zr($h()),HV=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); } `,Q2;function eE(){return Q2||(Q2=b5.generate(HV)),Q2}var iE=Zr(nE());function _5(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 MV(){return{name:"URI PROXY Parser",test:n=>/^(socks5\+tls|socks5|http|https):\/\//.test(n),parse:n=>{let[i,a,s,u,l,f,d,g,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} ${f}:${d}`,type:a,tls:!!s,server:f,port:d,username:u!=null?decodeURIComponent(u):void 0,password:l!=null?decodeURIComponent(l):void 0}}}}function qV(){return{name:"URI SOCKS Parser",test:n=>/^socks:\/\//.test(n),parse:n=>{let[i,a,s,u,l,f,d]=n.match(/^(socks)?:\/\/(?:(.*)@)?(.*?)(?::(\d+?))?(\?.*?)?(?:#(.*?))?$/);if(l)l=parseInt(l,10);else throw G.error(`port is not present in line: ${n}`),new Error(`port is not present in line: ${n}`);let g,p;if(s){let E=Dt.decode(decodeURIComponent(s)).split(":");g=E[0],p=E[1]}return{name:d!=null?decodeURIComponent(d):`${a} ${u}:${l}`,type:"socks5",server:u,port:l,username:g,password:p}}}}function VV(){return{name:"URI SS Parser",test:n=>/^ss:\/\//.test(n),parse:n=>{let i=n.split("ss://")[1],a=n.split("#")[1],s={type:"ss"};i=i.split("#")[0];let u=i.match(/@([^/?]*)(\/|\?|$)/),l=decodeURIComponent(i.split("@")[0]),f;l?.startsWith("2022-blake3-")?f=l:f=Dt.decode(l);let d="";if(u)i.includes("?")&&(d=i.match(/(\?.*)$/)[1]);else{if(i.includes("?")){let b=i.match(/^(.*)(\?.*)$/);i=b[1],d=b[2]}if(i=Dt.decode(i),d){if(/(&|\?)v2ray-plugin=/.test(d)){let m=d.match(/(&|\?)v2ray-plugin=(.*?)(&|$)/)[2];m&&(s.plugin="v2ray-plugin",s["plugin-opts"]=JSON.parse(Dt.decode(m)))}i=`${i}${d}`}f=i.match(/(^.*)@/)?.[1],u=i.match(/@([^/@]*)(\/|$)/)}let g=u[1],p=g.lastIndexOf(":");s.server=g.substring(0,p),s.port=`${g.substring(p+1)}`.match(/\d+/)?.[0];let h=f.match(/(^.*?):(.*$)/);s.cipher=h?.[1],s.password=h?.[2];let E=i.match(/[?&]plugin=([^&]+)/),v=i.match(/[?&]shadow-tls=([^&]+)/);if(E){let b=("plugin="+decodeURIComponent(E[1])).split(";"),m={};for(let y of b){let[D,C]=y.split("=");D&&(m[D]=C||!0)}switch(m.plugin){case"obfs-local":case"simple-obfs":s.plugin="obfs",s["plugin-opts"]={mode:m.obfs,host:rr(m["obfs-host"])};break;case"v2ray-plugin":s.plugin="v2ray-plugin",s["plugin-opts"]={mode:"websocket",host:rr(m["obfs-host"]),path:rr(m.path),tls:rc(m.tls)};break;case"shadow-tls":{s.plugin="shadow-tls";let y=rr(m.version);s["plugin-opts"]={host:rr(m.host),password:rr(m.password),version:y?parseInt(y,10):void 0};break}default:throw new Error(`Unsupported plugin option: ${m.plugin}`)}}if(v){let b=JSON.parse(Dt.decode(v[1])),m=rr(b.version),y=rr(b.address),D=rr(b.port);s.plugin="shadow-tls",s["plugin-opts"]={host:rr(b.host),password:rr(b.password),version:m?parseInt(m,10):void 0},y&&(s.server=y),D&&(s.port=parseInt(D,10))}return/(&|\?)uot=(1|true)/i.test(d)&&(s["udp-over-tcp"]=!0),/(&|\?)tfo=(1|true)/i.test(d)&&(s.tfo=!0),a!=null&&(a=decodeURIComponent(a)),s.name=a??`SS ${s.server}:${s.port}`,s}}}function KV(){return{name:"URI SSR Parser",test:n=>/^ssr:\/\//.test(n),parse:n=>{n=Dt.decode(n.split("ssr://")[1]);let i=n.indexOf(":origin");i===-1&&(i=n.indexOf(":auth_"));let a=n.substring(0,i),s=a.substring(0,a.lastIndexOf(":")),u=a.substring(a.lastIndexOf(":")+1),l=n.substring(i+1).split("/?")[0].split(":"),f={type:"ssr",server:s,port:u,protocol:l[0],cipher:l[1],obfs:l[2],password:Dt.decode(l[3])},d={};if(n=n.split("/?")[1].split("&"),n.length>1)for(let g of n){let[p,h]=g.split("=");h=h.trim(),h.length>0&&h!=="(null)"&&(d[p]=h)}return f={...f,name:d.remarks?Dt.decode(d.remarks):f.server,"protocol-param":rr(Dt.decode(d.protoparam||"").replace(/\s/g,"")),"obfs-param":rr(Dt.decode(d.obfsparam||"").replace(/\s/g,""))},f}}}function zV(){return{name:"URI VMess Parser",test:n=>/^vmess:\/\//.test(n),parse:n=>{n=n.split("vmess://")[1];let i=Dt.decode(n.replace(/\?.*?$/,""));if(/=\s*vmess/.test(i)){let a=i.split(",").map(l=>l.trim()),s={};for(let l of a)if(l.indexOf("=")!==-1){let[f,d]=l.split("=");s[f.trim()]=d.trim()}let u={name:a[0].split("=")[0].trim(),type:"vmess",server:a[1],port:a[2],cipher:rr(a[3],"auto"),uuid:a[4].match(/^"(.*)"$/)[1],tls:s.obfs==="wss",udp:rc(s["udp-relay"]),tfo:rc(s["fast-open"]),"skip-cert-verify":tc(s["tls-verification"])?!s["tls-verification"]:void 0};if(tc(s.obfs))if(s.obfs==="ws"||s.obfs==="wss"){u.network="ws",u["ws-opts"].path=(rr(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]),ta(l)&&(u["ws-opts"].headers={Host:l})}else throw new Error(`Unsupported obfs: ${s.obfs}`);return u}else{let a={};try{a=JSON.parse(i)}catch{let[g,p,h]=/(^[^?]+?)\/?\?(.*)$/.exec(n);i=Dt.decode(p);for(let D of h.split("&")){let[C,F]=D.split("="),L=F;L=decodeURIComponent(F),L.indexOf(",")===-1?a[C]=L:a[C]=L.split(",")}let[E,v,b,m,y]=/(^[^:]+?):([^:]+?)@(.*):(\d+)$/.exec(i);a.scy=v,a.id=b,a.port=y,a.add=m}let s=a.add,u=parseInt(rc(a.port),10),l={name:a.ps??a.remarks??a.remark??`VMess ${s}:${u}`,type:"vmess",server:s,port:u,cipher:["auto","aes-128-gcm","chacha20-poly1305","none"].includes(a.scy)?a.scy:"auto",uuid:a.id,alterId:parseInt(rc(a.aid??a.alterId,0),10),tls:["tls",!0,1,"1"].includes(a.tls),"skip-cert-verify":tc(a.verify_cert)?!a.verify_cert:void 0};!l["skip-cert-verify"]&&tc(a.allowInsecure)&&(l["skip-cert-verify"]=/(TRUE)|1/i.test(a.allowInsecure)),l.tls&&(a.sni&&a.sni!==""?l.sni=a.sni:a.peer&&a.peer!==""&&(l.sni=a.peer));let f=!1;if(a.net==="ws"||a.obfs==="websocket"?l.network="ws":["http"].includes(a.net)||["http"].includes(a.obfs)||["http"].includes(a.type)?l.network="http":["grpc","kcp","quic"].includes(a.net)?l.network=a.net:a.net==="httpupgrade"||l.network==="httpupgrade"?(l.network="ws",f=!0):(a.net==="h2"||l.network==="h2")&&(l.network="h2"),l.network){let d=a.host??a.obfsParam;try{let h=JSON.parse(d)?.Host;h&&(d=h)}catch{}let g=a.path;if(["ws"].includes(l.network)&&(g=g||"/"),l.network==="http"&&(d&&(d=d.split(",").map(p=>p.trim()),d=Array.isArray(d)?d[0]:d),g?g=Array.isArray(g)?g[0]:g:g="/"),g||d||["kcp","quic"].includes(l.network))if(["grpc"].includes(l.network))l[`${l.network}-opts`]={"grpc-service-name":rr(g),"_grpc-type":rr(a.type),"_grpc-authority":rr(a.authority)};else if(["kcp","quic"].includes(l.network))l[`${l.network}-opts`]={[`_${l.network}-type`]:rr(a.type),[`_${l.network}-host`]:rr(rr(d)),[`_${l.network}-path`]:rr(g)};else{let p={path:rr(g),headers:{Host:rr(d)}};f&&(p["v2ray-http-upgrade"]=!0,p["v2ray-http-upgrade-fast-open"]=!0),l[`${l.network}-opts`]=p}else delete l.network}return l["client-fingerprint"]=a.fp,l.alpn=a.alpn?a.alpn.split(","):void 0,l}}}}function C5(){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[b,m,y]=/^(.*?)(\?.*?$)/.exec(n);n=`${Dt.decode(m)}${y}`,a=/^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(n),i=!0}let[s,u,l,f,d,g="",p]=a;i&&(u=u.replace(/^.*?:/g,"")),f=parseInt(`${f}`,10),u=decodeURIComponent(u),p!=null&&(p=decodeURIComponent(p));let h={type:"vless",name:p,server:l,port:f,uuid:u},E={};for(let b of g.split("&"))if(b){let[m,y]=b.split("="),D=y;D=decodeURIComponent(y),E[m]=D}if(h.name=p??E.remarks??E.remark??`VLESS ${l}:${f}`,h.tls=E.security&&E.security!=="none",i&&/TRUE|1/i.test(E.tls)&&(h.tls=!0,E.security=E.security??"reality"),h.sni=E.sni||E.peer,h.flow=E.flow,!h.flow&&i&&E.xtls){let b=[void 0,"xtls-rprx-direct","xtls-rprx-vision"][E.xtls];b&&(h.flow=b)}if(h["client-fingerprint"]=E.fp,h.alpn=E.alpn?E.alpn.split(","):void 0,h["skip-cert-verify"]=/(TRUE)|1/i.test(E.allowInsecure),["reality"].includes(E.security)){let b={};E.pbk&&(b["public-key"]=E.pbk),E.sid&&(b["short-id"]=E.sid),E.spx&&(b["_spider-x"]=E.spx),Object.keys(b).length>0&&(h[`${E.security}-opts`]=b)}let v=!1;if(h.network=E.type,h.network==="tcp"&&E.headerType==="http"?h.network="http":h.network==="httpupgrade"&&(h.network="ws",v=!0),!h.network&&i&&E.obfs&&(h.network=E.obfs,["none"].includes(h.network)&&(h.network="tcp")),["websocket"].includes(h.network)&&(h.network="ws"),h.network&&!["tcp","none"].includes(h.network)){let b={},m=E.host??E.obfsParam;if(m)if(E.obfsParam)try{let y=JSON.parse(m);b.headers=y}catch{b.headers={Host:m}}else b.headers={Host:m};E.serviceName?(b[`${h.network}-service-name`]=E.serviceName,["grpc"].includes(h.network)&&E.authority&&(b["_grpc-authority"]=E.authority)):i&&E.path&&(["ws","http","h2"].includes(h.network)||(b[`${h.network}-service-name`]=E.path,delete E.path)),E.path&&(b.path=E.path),["grpc"].includes(h.network)&&(b["_grpc-type"]=E.mode||"gun"),v&&(b["v2ray-http-upgrade"]=!0,b["v2ray-http-upgrade-fast-open"]=!0),Object.keys(b).length>0&&(h[`${h.network}-opts`]=b),h.network==="kcp"&&(E.seed&&(h.seed=E.seed),h.headerType=E.headerType||"none"),E.mode&&(h._mode=E.mode),E.extra&&(h._extra=E.extra)}return E.encryption&&(h.encryption=E.encryption),E.pqv&&(h._pqv=E.pqv),h}}}function GV(){return{name:"URI AnyTLS Parser",test:n=>/^anytls:\/\//.test(n),parse:n=>{let i=C5().parse(n.replace("anytls","vless"));n=n.split(/anytls:\/\//)[1];let[a,s,u,l,f="",d]=/^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(n);s=decodeURIComponent(s),l=parseInt(`${l}`,10),isNaN(l)&&(l=443),s=decodeURIComponent(s),d!=null&&(d=decodeURIComponent(d)),d=d??`AnyTLS ${u}:${l}`;let g={...i,uuid:void 0,type:"anytls",name:d,server:u,port:l,password:s};for(let p of f.split("&"))if(p){let[h,E]=p.split("=");h=h.replace(/_/g,"-"),E=decodeURIComponent(E),["alpn"].includes(h)?g[h]=E?E.split(","):void 0:["insecure"].includes(h)?g["skip-cert-verify"]=/(TRUE)|1/i.test(E):["udp"].includes(h)?g[h]=/(TRUE)|1/i.test(E):Object.keys(g).includes(h)||(g[h]=E)}return["tcp"].includes(g.network)&&!g["reality-opts"]&&(delete g.network,delete g.security),g}}}function YV(){return{name:"URI Hysteria2 Parser",test:n=>/^(hysteria2|hy2):\/\//.test(n),parse:n=>{n=n.split(/(hysteria2|hy2):\/\//)[2];let i,[a,s,u,l,f,d,g,p,h,E,v="",b]=/^(.*?)@(.*?)(:((\d+(-\d+)?)([,;]\d+(-\d+)?)*))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);/^\d+$/.test(f)?(f=parseInt(`${f}`,10),isNaN(f)&&(f=443)):f?(i=f,f=If(i)):f=443,s=decodeURIComponent(s),b!=null&&(b=decodeURIComponent(b)),b=b??`Hysteria2 ${u}:${f}`;let m={type:"hysteria2",name:b,server:u,port:f,ports:i,password:s},y={};for(let F of v.split("&"))if(F){let[L,k]=F.split("="),S=k;S=decodeURIComponent(k),y[L]=S}m.sni=y.sni,!m.sni&&y.peer&&(m.sni=y.peer),y.obfs&&y.obfs!=="none"&&(m.obfs=y.obfs),y.mport&&(m.ports=y.mport),m["obfs-password"]=y["obfs-password"],m["skip-cert-verify"]=/(TRUE)|1/i.test(y.insecure),m.tfo=/(TRUE)|1/i.test(y.fastopen),m["tls-fingerprint"]=y.pinSHA256;let D=y["hop-interval"]||y.hop_interval;/^\d+$/.test(D)&&(m["hop-interval"]=parseInt(`${D}`,10));let C=y.keepalive;return/^\d+$/.test(C)&&(m.keepalive=parseInt(`${C}`,10)),m}}}function WV(){return{name:"URI Hysteria Parser",test:n=>/^(hysteria|hy):\/\//.test(n),parse:n=>{n=n.split(/(hysteria|hy):\/\//)[2];let[i,a,s,u,l,f="",d]=/^(.*?)(:(\d+))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);u=parseInt(`${u}`,10),isNaN(u)&&(u=443),d!=null&&(d=decodeURIComponent(d)),d=d??`Hysteria ${a}:${u}`;let g={type:"hysteria",name:d,server:a,port:u},p={};for(let h of f.split("&"))if(h){let[E,v]=h.split("=");E=E.replace(/_/,"-"),v=decodeURIComponent(v),["alpn"].includes(E)?g[E]=v?v.split(","):void 0:["insecure"].includes(E)?g["skip-cert-verify"]=/(TRUE)|1/i.test(v):["auth"].includes(E)?g["auth-str"]=v:["mport"].includes(E)?g.ports=v:["obfsParam"].includes(E)?g.obfs=v:["upmbps"].includes(E)?g.up=v:["downmbps"].includes(E)?g.down=v:["obfs"].includes(E)?g._obfs=v||"":["fast-open","peer"].includes(E)?p[E]=v:Object.keys(g).includes(E)||(g[E]=v)}return!g.sni&&p.peer&&(g.sni=p.peer),!g["fast-open"]&&p.fastopen&&(g["fast-open"]=!0),g.protocol||(g.protocol="udp"),g}}}function XV(){return{name:"URI TUIC Parser",test:n=>/^tuic:\/\//.test(n),parse:n=>{n=n.split(/tuic:\/\//)[1];let[i,a,s,u,l="",f]=/^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(n);a=decodeURIComponent(a);let[d,...g]=a.split(":"),p=g.join(":");u=parseInt(`${u}`,10),isNaN(u)&&(u=443),p=decodeURIComponent(p),f!=null&&(f=decodeURIComponent(f)),f=f??`TUIC ${s}:${u}`;let h={type:"tuic",name:f,server:s,port:u,password:p,uuid:d};for(let E of l.split("&"))if(E){let[v,b]=E.split("=");v=v.replace(/_/g,"-"),b=decodeURIComponent(b),["alpn"].includes(v)?h[v]=b?b.split(","):void 0:["allow-insecure","insecure"].includes(v)?h["skip-cert-verify"]=/(TRUE)|1/i.test(b):["fast-open"].includes(v)?h.tfo=!0:["disable-sni","reduce-rtt"].includes(v)?h[v]=/(TRUE)|1/i.test(b):v==="congestion-control"?(h["congestion-controller"]=b,delete h[v]):Object.keys(h).includes(v)||(h[v]=b)}return h}}}function JV(){return{name:"URI WireGuard Parser",test:n=>/^(wireguard|wg):\/\//.test(n),parse:n=>{n=n.split(/(wireguard|wg):\/\//)[2];let[i,a,s,u,l,f,d,g="",p]=/^((.*?)@)?(.*?)(:(\d+))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);f=parseInt(`${f}`,10),isNaN(f)&&(f=51820),s=decodeURIComponent(s),p!=null&&(p=decodeURIComponent(p)),p=p??`WireGuard ${u}:${f}`;let h={type:"wireguard",name:p,server:u,port:f,"private-key":s,udp:!0};for(let E of g.split("&"))if(E){let[v,b]=E.split("=");if(v=v.replace(/_/,"-"),b=decodeURIComponent(b),["reserved"].includes(v)){let m=b.split(",").map(y=>parseInt(y.trim(),10)).filter(y=>Number.isInteger(y));m.length===3&&(h[v]=m)}else if(["address","ip"].includes(v))b.split(",").map(m=>{let y=m.trim().replace(/\/\d+$/,"").replace(/^\[/,"").replace(/\]$/,"");Ur(y)?h.ip=y:Rr(y)&&(h.ipv6=y)});else if(["mtu"].includes(v)){let m=parseInt(b.trim(),10);Number.isInteger(m)&&(h[v]=m)}else/publickey/i.test(v)?h["public-key"]=b:/privatekey/i.test(v)?h["private-key"]=b:["udp"].includes(v)?h[v]=/(TRUE)|1/i.test(b):[...Object.keys(h),"flag"].includes(v)||(h[v]=b)}return h}}}function ZV(){return{name:"URI Trojan Parser",test:n=>/^trojan:\/\//.test(n),parse:n=>{let i=/^(trojan:\/\/.*?@.*?)(:(\d+))?\/?(\?.*?)?$/.exec(n);i?.[2]||(n=n.replace(i[1],`${i[1]}:443`));let[s,u]=n.split(/#(.+)/,2),f=eE().parse(s);if(ta(u))try{f.name=decodeURIComponent(u)}catch(d){console.log(d)}return f}}}function QV(){return{name:"Clash Parser",test:n=>{let i;try{i=iE.default.parse(n)}catch{i=Xs.parse(n)}return!!i?.type},parse:n=>{let i;try{i=iE.default.parse(n)}catch{i=Xs.parse(n)}if(!["naive","anytls","mieru","sudoku","juicity","ss","ssr","vmess","socks5","http","snell","trojan","tuic","vless","hysteria","hysteria2","wireguard","ssh","direct"].includes(i.type))throw new Error(`Clash does not support proxy with type: ${i.type}`);return["vmess","vless"].includes(i.type)&&(i.sni=i.servername,delete i.servername),i["server-cert-fingerprint"]&&(i["tls-fingerprint"]=i["server-cert-fingerprint"]),i.fingerprint&&(i["tls-fingerprint"]=i.fingerprint),i["dialer-proxy"]&&(i["underlying-proxy"]=i["dialer-proxy"]),i["benchmark-url"]&&(i["test-url"]=i["benchmark-url"]),i["benchmark-timeout"]&&(i["test-timeout"]=i["benchmark-timeout"]),i}}}function eK(){return{name:"QX SS Parser",test:n=>/^shadowsocks\s*=/.test(n.split(",")[0].trim())&&n.indexOf("ssr-protocol")===-1,parse:n=>Au().parse(n)}}function tK(){return{name:"QX SSR Parser",test:n=>/^shadowsocks\s*=/.test(n.split(",")[0].trim())&&n.indexOf("ssr-protocol")!==-1,parse:n=>Au().parse(n)}}function rK(){return{name:"QX VMess Parser",test:n=>/^vmess\s*=/.test(n.split(",")[0].trim()),parse:n=>Au().parse(n)}}function nK(){return{name:"QX VLESS Parser",test:n=>/^vless\s*=/.test(n.split(",")[0].trim()),parse:n=>Au().parse(n)}}function iK(){return{name:"QX Trojan Parser",test:n=>/^trojan\s*=/.test(n.split(",")[0].trim()),parse:n=>Au().parse(n)}}function sK(){return{name:"QX HTTP Parser",test:n=>/^http\s*=/.test(n.split(",")[0].trim()),parse:n=>Au().parse(n)}}function aK(){return{name:"QX Socks5 Parser",test:n=>/^socks5\s*=/.test(n.split(",")[0].trim()),parse:n=>Au().parse(n)}}function uK(){return{name:"Loon SS Parser",test:n=>n.split(",")[0].split("=")[1].trim().toLowerCase()==="shadowsocks",parse:n=>Ca().parse(n)}}function oK(){return{name:"Loon SSR Parser",test:n=>n.split(",")[0].split("=")[1].trim().toLowerCase()==="shadowsocksr",parse:n=>Ca().parse(n)}}function lK(){return{name:"Loon VMess Parser",test:n=>/^.*=\s*vmess/i.test(n.split(",")[0])&&n.indexOf("username")===-1,parse:n=>Ca().parse(n)}}function cK(){return{name:"Loon Vless Parser",test:n=>/^.*=\s*vless/i.test(n.split(",")[0]),parse:n=>Ca().parse(n)}}function fK(){return{name:"Loon Trojan Parser",test:n=>/^.*=\s*trojan/i.test(n.split(",")[0]),parse:n=>Ca().parse(n)}}function hK(){return{name:"Loon Hysteria2 Parser",test:n=>/^.*=\s*Hysteria2/i.test(n.split(",")[0]),parse:n=>Ca().parse(n)}}function dK(){return{name:"Loon HTTP Parser",test:n=>/^.*=\s*http/i.test(n.split(",")[0]),parse:n=>Ca().parse(n)}}function pK(){return{name:"Loon SOCKS5 Parser",test:n=>/^.*=\s*socks5/i.test(n.split(",")[0]),parse:n=>Ca().parse(n)}}function gK(){return{name:"Loon WireGuard Parser",test:n=>/^.*=\s*wireguard/i.test(n.split(",")[0]),parse:n=>{let i=n.match(/(^.*?)\s*?=\s*?wireguard\s*?,.+?\s*?=\s*?.+?/i)?.[1];n=n.replace(i,"").replace(/^\s*?=\s*?wireguard\s*/i,"");let a=n.match(/,\s*?peers\s*?=\s*?\[\s*?\{\s*?(.+?)\s*?\}\s*?\]/i)?.[1],s=a.match(/(,|^)\s*?endpoint\s*?=\s*?"?(.+?):(\d+)"?\s*?(,|$)/i),u=s?.[2],l=parseInt(s?.[3],10),f=n.match(/(,|^)\s*?mtu\s*?=\s*?"?(\d+?)"?\s*?(,|$)/i)?.[2];f&&(f=parseInt(f,10));let d=n.match(/(,|^)\s*?keepalive\s*?=\s*?"?(\d+?)"?\s*?(,|$)/i)?.[2];d&&(d=parseInt(d,10));let g=a.match(/(,|^)\s*?reserved\s*?=\s*?"?(\[\s*?.+?\s*?\])"?\s*?(,|$)/i)?.[2];g&&(g=JSON.parse(g));let p,h=n.match(/(,|^)\s*?dns\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],E=n.match(/(,|^)\s*?dnsv6\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2];(h||E)&&(p=[],h&&p.push(h),E&&p.push(E));let v=a.match(/(,|^)\s*?allowed-ips\s*?=\s*?"(.+?)"\s*?(,|$)/i)?.[2]?.split(",").map(F=>F.trim()),b=a.match(/(,|^)\s*?preshared-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],m=n.match(/(,|^)\s*?interface-ip\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],y=n.match(/(,|^)\s*?interface-ipv6\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],D=a.match(/(,|^)\s*?public-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],C={type:"wireguard",name:i,server:u,port:l,ip:m,ipv6:y,"private-key":n.match(/(,|^)\s*?private-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],"public-key":D,mtu:f,keepalive:d,reserved:g,"allowed-ips":v,"preshared-key":b,dns:p,udp:!0,peers:[{server:u,port:l,ip:m,ipv6:y,"public-key":D,"pre-shared-key":b,"allowed-ips":v,reserved:g}]};return Array.isArray(C.dns)&&C.dns.length>0&&(C["remote-dns-resolve"]=!0),C}}}function mK(){return{name:"Surge Direct Parser",test:n=>/^.*=\s*direct/.test(n.split(",")[0]),parse:n=>Di().parse(n)}}function vK(){return{name:"Surge Anytls Parser",test:n=>/^.*=\s*anytls/.test(n.split(",")[0]),parse:n=>Di().parse(n)}}function EK(){return{name:"Surge SSH Parser",test:n=>/^.*=\s*ssh/.test(n.split(",")[0]),parse:n=>Di().parse(n)}}function wK(){return{name:"Surge SS Parser",test:n=>/^.*=\s*ss/.test(n.split(",")[0]),parse:n=>Di().parse(n)}}function AK(){return{name:"Surge VMess Parser",test:n=>/^.*=\s*vmess/.test(n.split(",")[0])&&n.indexOf("username")!==-1,parse:n=>Di().parse(n)}}function yK(){return{name:"Surge Trojan Parser",test:n=>/^.*=\s*trojan/.test(n.split(",")[0]),parse:n=>Di().parse(n)}}function bK(){return{name:"Surge HTTP Parser",test:n=>/^.*=\s*https?/.test(n.split(",")[0]),parse:n=>Di().parse(n)}}function _K(){return{name:"Surge Socks5 Parser",test:n=>/^.*=\s*socks5(-tls)?/.test(n.split(",")[0]),parse:n=>Di().parse(n)}}function CK(){return{name:"Surge External Parser",test:n=>/^.*=\s*external/.test(n.split(",")[0]),parse:n=>{let i=/^\s*(.*?)\s*?=\s*?external\s*?,\s*(.*?)\s*$/.exec(n),[a,s,u]=i;n=u;let l=/(,|^)\s*?exec\s*?=\s*"(.*?)"\s*?(,|$)/.exec(n)?.[2];l||(l=/(,|^)\s*?exec\s*?=\s*(.*?)\s*?(,|$)/.exec(n)?.[2]);let f=/(,|^)\s*?local-port\s*?=\s*"(.*?)"\s*?(,|$)/.exec(n)?.[2];f||(f=/(,|^)\s*?local-port\s*?=\s*(.*?)\s*?(,|$)/.exec(n)?.[2]);let d=/(,|^)\s*?args\s*?=\s*("(.*?)"|(.*?))(?=\s*?(,|$))/g,g,p=[];for(;(g=d.exec(n))!==null;)g[3]!=null?p.push(g[3]):g[4]!=null&&p.push(g[4]);let h=/(,|^)\s*?addresses\s*?=\s*("(.*?)"|(.*?))(?=\s*?(,|$))/g,E,v=[];for(;(E=h.exec(n))!==null;){let m;E[3]!=null?m=E[3]:E[4]!=null&&(m=E[4]),m!=null&&(m=`${m}`.trim().replace(/^\[/,"").replace(/\]$/,"")),BK(m)&&v.push(m)}return{type:"external",name:s,exec:l,"local-port":f,args:p,addresses:v}}}}function DK(){return{name:"Surge Snell Parser",test:n=>/^.*=\s*snell/.test(n.split(",")[0]),parse:n=>Di().parse(n)}}function FK(){return{name:"Surge Tuic Parser",test:n=>/^.*=\s*tuic(-v5)?/.test(n.split(",")[0]),parse:n=>{let{port_hopping:i,line:a}=_5(n),s=Di().parse(a);return s.ports=i,s}}}function SK(){return{name:"Surge WireGuard Parser",test:n=>/^.*=\s*wireguard/.test(n.split(",")[0]),parse:n=>Di().parse(n)}}function IK(){return{name:"Surge Hysteria2 Parser",test:n=>/^.*=\s*hysteria2/.test(n.split(",")[0]),parse:n=>{let{port_hopping:i,line:a}=_5(n),s=Di().parse(a);return s.ports=i,s}}}function BK(e){return Ur(e)||Rr(e)}var D5=[MV(),qV(),VV(),KV(),zV(),C5(),XV(),JV(),WV(),YV(),ZV(),GV(),QV(),mK(),vK(),EK(),wK(),AK(),yK(),bK(),DK(),FK(),SK(),IK(),_K(),CK(),uK(),oK(),lK(),cK(),hK(),fK(),dK(),pK(),gK(),eK(),tK(),rK(),nK(),iK(),sK(),aK()];var B5=Zr(nE());function $K(e){for(let t of Sd)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 RK(e){e=$K(e);let t=e.split(` `),r=[],n;for(let i of t){if(i=i.trim(),i.length===0)continue;let a=!1;if(n){let[s,u]=F5(n,i);u||(r.push(I5(s)),a=!0)}if(!a)for(let s of D5){let[u,l]=F5(s,i);if(!l){r.push(I5(u)),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)&&(bd(i.uuid)||G.info(`UUID may be invalid: ${i.name} ${i.uuid}`)),!0))}async function PK(proxies,operators=[],targetPlatform,source,$options){for(let item of operators){if(item.disabled){G.log(`Skipping disabled operator: "${item.type}" with arguments: >>> ${JSON.stringify(item.args,null,2)||"None"}`);continue}let script,$arguments={};if(item.type.indexOf("Script")!==-1){let{mode,content}=item.args;if(mode==="link"){let url=content||"",rawArgs=url.split("#");if(rawArgs.length>1)try{$arguments=JSON.parse(decodeURIComponent(rawArgs[1]))}catch{for(let t of rawArgs[1].split("&")){let r=t.split("=")[0],n=t.split("=")[1];$arguments[r]=n==null||n===""?!0:decodeURIComponent(n)}}url=`${url.split("#")[0]}${rawArgs[2]?`#${rawArgs[2]}`:$arguments?.noCache!=null||$arguments?.insecure!=null?`#${rawArgs[1]}`:""}`;let downloadUrlMatch=url.split("#")[0].match(/^\/api\/(file|module)\/(.+)/);if(downloadUrlMatch){let e="";try{e=downloadUrlMatch?.[1];let t=downloadUrlMatch?.[2];if(t==null)throw new Error(`\u672C\u5730 ${e} URL \u65E0\u6548: ${url}`);t=decodeURIComponent(t);let r=e==="module"?D0:qa,n=Pr(G.read(r),t);if(!n)throw new Error(`\u627E\u4E0D\u5230 ${e}: ${t}`);e==="module"?script=n.content:script=await wi({type:"file",name:t})}catch(t){throw G.error(`Error when loading ${e}: ${item.args.content}. Reason: ${t}`),new Error(`\u65E0\u6CD5\u52A0\u8F7D ${e}: ${url}`)}}else if(url?.startsWith("/"))try{let fs=eval('require("fs")');script=fs.readFileSync(url.split("#")[0],"utf8")}catch(e){throw G.error(`Error when reading local script: ${item.args.content}. Reason: ${e}`),new Error(`\u65E0\u6CD5\u4ECE\u8BE5\u8DEF\u5F84\u8BFB\u53D6\u811A\u672C\u6587\u4EF6: ${url}`)}else try{script=await wn(url)}catch(e){throw G.error(`Error when downloading remote script: ${item.args.content}. Reason: ${e}`),new Error(`\u65E0\u6CD5\u4E0B\u8F7D\u811A\u672C: ${url}`)}}else script=content,$arguments=item.args.arguments||{}}if(!kd[item.type]){G.error(`Unknown operator: "${item.type}"`);continue}G.log(`Applying "${item.type}" with arguments: >>> ${JSON.stringify(item.args,null,2)||"None"}`);let processor;item.type.indexOf("Script")!==-1?processor=kd[item.type](script,targetPlatform,$arguments,source,$options):processor=kd[item.type](item.args||{}),proxies=await mC(processor,proxies)}return proxies}function xK(e,t,r,n={}){let i=Dp[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)&&(bd(s.uuid)||G.info(`UUID may be invalid: ${s.name} ${s.uuid}`)),!0)),e=e.map(s=>(s._resolved=s.resolved,ta(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=If(s.ports))),s)),G.log(`Producing proxies for target: ${t}`),typeof i.type>"u"||i.type==="SINGLE"){let s=e.map(u=>{try{return i.produce(u,r,n)}catch(l){return G.error(`Cannot produce proxy: ${JSON.stringify(u,null,2)} Reason: ${l}`),""}}).filter(u=>u.length>0);return s=r==="internal"?s:s.join(` `),t.startsWith("Surge")&&e.length>0&&e.every(u=>u.type==="wireguard")&&(s=`#!name=${e[0]?._subName} #!desc=${e[0]?._desc??""} #!category=${e[0]?._category??""} ${s}`),s}else if(i.type==="ALL")return i.produce(e,r,n)}var Nt={parse:RK,process:PK,produce:xK,ipAddress:yd,getRandomPort:If,isIPv4:Ur,isIPv6:Rr,isIP:sE,yaml:Xs,getFlag:sc,removeFlag:Pf,getISO:$d,MMDB:Bd,Gist:qo,download:wn,downloadFile:J_,isValidUUID:bd,doh:uc,Buffer:Op.Buffer,Base64:Dt,JSON5:B5.default};function F5(e,t){if(!OK(e,t))return[null,new Error("Parser mismatch")];try{return[e.parse(t),null]}catch(r){return[null,r]}}function OK(e,t){try{return e.test(t)}catch{return!1}}function S5(e){if(typeof e=="string"||typeof e=="number"){if(e=String(e).trim(),e==="")return"/";if(!e.startsWith("/"))return"/"+e}return e}function I5(e){typeof e.cipher=="string"&&(e.cipher=e.cipher.toLowerCase()),typeof e.password=="number"&&(e.password=V_(e.password)),["ss"].includes(e.type)&&e.cipher==="none"&&!e.password&&(e.password=""),e.interface&&(e["interface-name"]=e.interface,delete e.interface),q_(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=>S5(n)):t!=null&&(e[`${e.network}-opts`].path=S5(t)),e.type==="trojan"&&e.network==="tcp"&&delete e.network,["vless"].includes(e.type)&&(e.network||(e.network="tcp")),["trojan","tuic","hysteria","hysteria2","juicity","anytls","naive"].includes(e.type)&&(e.tls=!0),e.network){let n=e[`${e.network}-opts`]?.headers?.Host,i=e[`${e.network}-opts`]?.headers?.host;e.network==="h2"?!i&&n&&(e[`${e.network}-opts`].headers.host=n,delete e[`${e.network}-opts`].headers.Host):i&&!n&&(e[`${e.network}-opts`].headers.Host=i,delete e[`${e.network}-opts`].headers.host)}if(e.network==="h2"){let n=e["h2-opts"]?.headers?.host,i=e["h2-opts"]?.path;n&&!Array.isArray(n)&&(e["h2-opts"].headers.host=[n]),Array.isArray(i)&&(e["h2-opts"].path=i[0])}if(!e.tls&&["ws","http"].includes(e.network)&&!e[`${e.network}-opts`]?.headers?.Host&&!sE(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&&(sE(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=Op.Buffer.from(e.name.data).toString("utf8"):e.name=Op.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"]=Oy.generateFingerprint(r)),["ss"].includes(e.type)&&ue(e,"shadow-tls-password")&&(e.plugin="shadow-tls",e["plugin-opts"]={host:e["shadow-tls-sni"],password:e["shadow-tls-password"],version:e["shadow-tls-version"]},delete e["shadow-tls-sni"],delete e["shadow-tls-password"],delete e["shadow-tls-version"]),e}function sE(e){return Ur(e)||Rr(e)}function aE(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 Uc(t,r)}),e.get("/share/col/:name",Uc),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 Lc(t,r)}),e.get("/share/sub/:name",Lc),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 Uc(t,r)}),e.get("/download/collection/:name",Uc),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 Lc(t,r)}),e.get("/download/:name",Lc),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 Uc(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 Lc(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 Uc(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 Lc(t,r)})}async function Lc(e,t){let{name:r,nezhaIndex:n}=e.params,i=e.query.target==="SurgeMac",a=e.query.target||hg(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:u,ua:l,content:f,mergeSources:d,ignoreFailedRemoteSub:g,produceType:p,includeUnsupportedProxy:h,resultFormat:E,proxy:v,noCache:b}=e.query,m={_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{m=JSON.parse(decodeURIComponent(e.query.$options))}catch{for(let F of e.query.$options.split("&")){let L=F.split("=")[0],k=F.split("=")[1];m[L]=k==null||k===""?!0:decodeURIComponent(k)}}G.info(`\u4F20\u5165 $options: ${JSON.stringify(m)}`)}u&&(G.info(`\u6307\u5B9A\u8FDC\u7A0B\u8BA2\u9605 URL: ${u}`),/^https?:\/\//.test(u)||(f=u,G.info("URL \u4E0D\u662F\u94FE\u63A5\uFF0C\u89C6\u4E3A\u672C\u5730\u8BA2\u9605"))),f&&G.info(`\u6307\u5B9A\u672C\u5730\u8BA2\u9605: ${f}`),v&&G.info(`\u6307\u5B9A\u8FDC\u7A0B\u8BA2\u9605\u4F7F\u7528\u4EE3\u7406/\u7B56\u7565 proxy: ${v}`),l&&G.info(`\u6307\u5B9A\u8FDC\u7A0B\u8BA2\u9605 User-Agent: ${l}`),d&&G.info(`\u6307\u5B9A\u5408\u5E76\u6765\u6E90: ${d}`),g!=null&&g!==""&&G.info(`\u6307\u5B9A\u5FFD\u7565\u5931\u8D25\u7684\u8FDC\u7A0B\u8BA2\u9605: ${g}`),p&&G.info(`\u6307\u5B9A\u751F\u4EA7\u7C7B\u578B: ${p}`),h&&G.info(`\u5305\u542B\u5B98\u65B9/\u5546\u5E97\u7248/\u672A\u7EED\u8D39\u8BA2\u9605\u4E0D\u652F\u6301\u7684\u534F\u8BAE: ${h}`),!h&&dg(a,s)&&(h=!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: ${h}`)),i&&G.info("\u624B\u52A8\u6307\u5B9A\u4E86 target \u4E3A SurgeMac, \u5C06\u4F7F\u7528 Mihomo External"),b&&G.info(`\u6307\u5B9A\u4E0D\u4F7F\u7528\u7F13\u5B58: ${b}`);let y=G.read(is),D=Pr(y,r);if(D)try{D.passThroughUA&&(G.info(`\u8BA2\u9605\u5F00\u542F\u4E86\u900F\u4F20 User-Agent, \u4F7F\u7528\u8BF7\u6C42\u7684 User-Agent: ${s}`),l=s);let F=await wi({type:"subscription",name:r,platform:a,url:u,ua:l,content:f,mergeSources:d,ignoreFailedRemoteSub:g,produceType:p,produceOpts:{"include-unsupported-proxy":h,useMihomoExternal:i},$options:m,proxy:v,noCache:b}),L;if(D.source!=="local"||["localFirst","remoteFirst"].includes(D.mergeSources))try{u=`${u||D.url}`.split(/[\r\n]+/).map(B=>B.trim()).filter(B=>B.length)?.[0]||"";let k={},S=u.split("#");if(u=u.split("#")[0],S.length>1)try{k=JSON.parse(decodeURIComponent(S[1]))}catch{for(let O of S[1].split("&")){let P=O.split("=")[0],U=O.split("=")[1];k[P]=U==null||U===""?!0:decodeURIComponent(U)}}!k.noFlow&&/^https?/.test(u)&&(L=await ra(k?.insecure?`${u}#insecure`:u,k.flowUserAgent,void 0,v||D.proxy,k.flowUrl),L&&t.set("subscription-userinfo",ic(L)))}catch(k){G.error(`\u8BA2\u9605 ${r} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(k)}`)}if(D.subUserinfo){let k;if(/^https?:\/\//.test(D.subUserinfo))try{k=await ra(void 0,void 0,void 0,v||D.proxy,D.subUserinfo)}catch(S){G.error(`\u8BA2\u9605 ${r} \u4F7F\u7528\u81EA\u5B9A\u4E49\u6D41\u91CF\u94FE\u63A5 ${D.subUserinfo} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(S)}`)}else k=D.subUserinfo;t.set("subscription-userinfo",ic([k,L].filter(S=>S).join(";")))}a==="JSON"?(E==="nezha"?F=R5(F):E==="nezha-monitor"&&(n=/^\d+$/.test(n)?parseInt(n,10):F.findIndex(k=>k.name===n),F=await $5(F[n],n,e.query)),t.set("Content-Type","application/json;charset=utf-8").send(F)):t.send(F)}catch(C){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${C.message??C}`),G.error(C.message??C),En(t,new Li("INTERNAL_SERVER_ERROR",`Failed to download subscription: ${r}`,`Reason: ${C.message??C}`))}else G.error(`\u{1F30D} Sub-Store \u4E0B\u8F7D\u8BA2\u9605\u5931\u8D25 \u274C \u672A\u627E\u5230\u8BA2\u9605\uFF1A${r}\uFF01`),En(t,new Qa("RESOURCE_NOT_FOUND",`Subscription ${r} does not exist!`),404)}async function Uc(e,t){let{name:r,nezhaIndex:n}=e.params,i=e.query.target==="SurgeMac",a=e.query.target||hg(e.headers)||"JSON",s=G.read(Ou),u=Pr(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:f,produceType:d,includeUnsupportedProxy:g,resultFormat:p,proxy:h,noCache:E}=e.query,v={_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{v=JSON.parse(decodeURIComponent(e.query.$options))}catch{for(let m of e.query.$options.split("&")){let y=m.split("=")[0],D=m.split("=")[1];v[y]=D==null||D===""?!0:decodeURIComponent(D)}}G.info(`\u4F20\u5165 $options: ${JSON.stringify(v)}`)}if(h&&G.info(`\u6307\u5B9A\u8FDC\u7A0B\u8BA2\u9605\u4F7F\u7528\u4EE3\u7406/\u7B56\u7565 proxy: ${h}`),f!=null&&f!==""&&G.info(`\u6307\u5B9A\u5FFD\u7565\u5931\u8D25\u7684\u8FDC\u7A0B\u8BA2\u9605: ${f}`),d&&G.info(`\u6307\u5B9A\u751F\u4EA7\u7C7B\u578B: ${d}`),g&&G.info(`\u5305\u542B\u5B98\u65B9/\u5546\u5E97\u7248/\u672A\u7EED\u8D39\u8BA2\u9605\u4E0D\u652F\u6301\u7684\u534F\u8BAE: ${g}`),!g&&dg(a,l)&&(g=!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: ${g}`)),i&&G.info("\u624B\u52A8\u6307\u5B9A\u4E86 target \u4E3A SurgeMac, \u5C06\u4F7F\u7528 Mihomo External"),E&&G.info(`\u6307\u5B9A\u4E0D\u4F7F\u7528\u7F13\u5B58: ${E}`),u)try{let b=await wi({type:"collection",name:r,platform:a,ignoreFailedRemoteSub:f,produceType:d,produceOpts:{"include-unsupported-proxy":g,useMihomoExternal:i},$options:v,proxy:h,noCache:E,ua:l}),m,y=G.read(is),D=u.subscriptions;if(D.length>0){let L=Pr(y,D[0]);if(L.source!=="local"||["localFirst","remoteFirst"].includes(L.mergeSources))try{let k=`${L.url}`.split(/[\r\n]+/).map(O=>O.trim()).filter(O=>O.length)?.[0]||"",S={},B=k.split("#");if(k=k.split("#")[0],B.length>1)try{S=JSON.parse(decodeURIComponent(B[1]))}catch{for(let P of B[1].split("&")){let U=P.split("=")[0],Y=P.split("=")[1];S[U]=Y==null||Y===""?!0:decodeURIComponent(Y)}}!S.noFlow&&/^https?:/.test(k)&&(m=await ra(S?.insecure?`${k}#insecure`:k,S.flowUserAgent,void 0,h||L.proxy||u.proxy,S.flowUrl))}catch(k){G.error(`\u7EC4\u5408\u8BA2\u9605 ${r} \u4E2D\u7684\u5B50\u8BA2\u9605 ${L.name} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${k.message??k}`)}if(L.subUserinfo){let k;if(/^https?:\/\//.test(L.subUserinfo))try{k=await ra(void 0,void 0,void 0,h||L.proxy,L.subUserinfo)}catch(S){G.error(`\u7EC4\u5408\u8BA2\u9605 ${r} \u4F7F\u7528\u81EA\u5B9A\u4E49\u6D41\u91CF\u94FE\u63A5 ${L.subUserinfo} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(S)}`)}else k=L.subUserinfo;m=[k,m].filter(S=>S).join("; ")}}G.info(`\u7EC4\u5408\u8BA2\u9605 ${r} \u900F\u4F20\u7684\u7684\u6D41\u91CF\u4FE1\u606F: ${m}`);let C;if(/^https?:\/\//.test(u.subUserinfo))try{C=await ra(void 0,void 0,void 0,h||u.proxy,u.subUserinfo)}catch(L){G.error(`\u7EC4\u5408\u8BA2\u9605 ${r} \u4F7F\u7528\u81EA\u5B9A\u4E49\u6D41\u91CF\u94FE\u63A5 ${u.subUserinfo} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(L)}`)}else C=u.subUserinfo;let F=[C,m].filter(L=>L).join("; ");F&&t.set("subscription-userinfo",ic(F)),a==="JSON"?(p==="nezha"?b=R5(b):p==="nezha-monitor"&&(n=/^\d+$/.test(n)?parseInt(n,10):b.findIndex(L=>L.name===n),b=await $5(b[n],n,e.query)),t.set("Content-Type","application/json;charset=utf-8").send(b)):t.send(b)}catch(b){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${b}`),En(t,new Li("INTERNAL_SERVER_ERROR",`Failed to download collection: ${r}`,`Reason: ${b.message??b}`))}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`),En(t,new Qa("RESOURCE_NOT_FOUND",`Collection ${r} does not exist!`),404)}async function $5(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=Nt.produce([e],i?"Loon":"Surge");if(!s)throw new Error("\u5F53\u524D\u5BA2\u6237\u7AEF\u4E0D\u517C\u5BB9\u6B64\u8282\u70B9");let u=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(...u.map(f=>f.number))||3;for(let f of u){let g={monitor_id:u.indexOf(f),server_id:t,monitor_name:f.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=$d(r.name)),/^[a-z]{2}$/i.test(i)){let a=Math.round(new Date().getTime()/1e3),s=r._unavailable?0:a,u=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||(Rr(r.server)?r.server:""),host:{Platform:"Sub-Store",PlatformVersion:zo.version,CPU:[],MemTotal:1024,DiskTotal:1024,SwapTotal:1024,Arch:"",Virtualization:"",BootTime:a-u,CountryCode:i,Version:"0.0.1"},status:{CPU:0,MemUsed:0,SwapUsed:0,DiskUsed:0,NetInTransfer:0,NetOutTransfer:0,NetInSpeed:0,NetOutSpeed:0,Uptime:u,Load1:0,Load5:0,Load15:0,TcpConnCount:0,UdpConnCount:0,ProcessCount:0}})}}),JSON.stringify(t,null,2)}function uE(e){e.post("/api/preview/sub",kK),e.post("/api/preview/collection",NK),e.post("/api/preview/file",TK)}async function TK(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 u={};if(n=await Promise.all(r.url.split(/[\r\n]+/).map(l=>l.trim()).filter(l=>l.length).map(async l=>{try{return await wn(l,r.ua,void 0,r.proxy)}catch(f){return u[l]=f,G.error(`\u6587\u4EF6 ${r.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${l} \u53D1\u751F\u9519\u8BEF: ${f}`),""}})),Object.keys(u).length>0)if(r.ignoreFailedRemoteFile)r.ignoreFailedRemoteFile==="enabled"&&G.notify("\u{1F30D} Sub-Store \u9884\u89C8\u6587\u4EF6\u5931\u8D25",`\u274C ${r.name}`,`\u8FDC\u7A0B\u6587\u4EF6 ${Object.keys(u).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);else throw new Error(`\u6587\u4EF6 ${r.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${Object.keys(u).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(u=>u!=null&&u!=="").join(` `),s=Array.isArray(r.process)&&r.process.length>0?await Nt.process({$files:i,$content:a,$file:r},r.process):{$content:a,$files:i};na(t,{original:a,processed:s?.$content??""})}catch(r){G.error(r.message??r),En(t,new Li("INTERNAL_SERVER_ERROR","Failed to preview file",`Reason: ${r.message??r}`))}}async function kK(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 u={};if(i=await Promise.all(r.url.split(/[\r\n]+/).map(l=>l.trim()).filter(l=>l.length).map(async l=>{try{return await wn(l,r.ua,void 0,r.proxy,void 0,void 0,void 0,!0)}catch(f){return u[l]=f,G.error(`\u8BA2\u9605 ${r.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${l} \u53D1\u751F\u9519\u8BEF: ${f}`),""}})),Object.keys(u).length>0)if(r.ignoreFailedRemoteSub)r.ignoreFailedRemoteSub==="enabled"&&G.notify("\u{1F30D} Sub-Store \u9884\u89C8\u8BA2\u9605\u5931\u8D25",`\u274C ${r.name}`,`\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(u).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);else throw new Error(`\u8BA2\u9605 ${r.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(u).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(u=>Nt.parse(u)).flat();a.forEach((u,l)=>{u.id=l,u._subName=r.name,u._subDisplayName=r.displayName});let s=await Nt.process(a,r.process||[],n,{[r.name]:r});na(t,{original:a,processed:s})}catch(r){G.error(r.message??r),En(t,new Li("INTERNAL_SERVER_ERROR","Failed to preview subscription",`Reason: ${r.message??r}`))}}async function NK(e,t){try{let r=G.read(is),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(g=>a.includes(g))&&i.push(d.name)});let s={},u={};if(await Promise.all(i.map(async d=>{let g=Pr(r,d);try{let p;if(g.source==="local"&&!["localFirst","remoteFirst"].includes(g.mergeSources))p=g.content;else{let E={};if(p=await Promise.all(g.url.split(/[\r\n]+/).map(v=>v.trim()).filter(v=>v.length).map(async v=>{try{return await wn(v,g.ua,void 0,g.proxy,void 0,void 0,void 0,!0)}catch(b){return E[v]=b,G.error(`\u8BA2\u9605 ${g.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${v} \u53D1\u751F\u9519\u8BEF: ${b}`),""}})),Object.keys(E).length>0)if(g.ignoreFailedRemoteSub)g.ignoreFailedRemoteSub==="enabled"&&G.notify("\u{1F30D} Sub-Store \u9884\u89C8\u8BA2\u9605\u5931\u8D25",`\u274C ${g.name}`,`\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(E).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);else throw new Error(`\u8BA2\u9605 ${g.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(E).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);g.mergeSources==="localFirst"?p.unshift(g.content):g.mergeSources==="remoteFirst"&&p.push(g.content)}let h=(Array.isArray(p)?p:[p]).map(E=>Nt.parse(E)).flat();h.forEach(E=>{E._subName=g.name,E._subDisplayName=g.displayName,E._collectionName=n.name,E._collectionDisplayName=n.displayName}),h=await Nt.process(h,g.process||[],"JSON",{[g.name]:g,_collection:n}),s[d]=h}catch(p){u[d]=p,G.error(`\u274C \u5904\u7406\u7EC4\u5408\u8BA2\u9605 ${n.name} \u4E2D\u7684\u5B50\u8BA2\u9605: ${g.name} \u65F6\u51FA\u73B0\u9519\u8BEF\uFF1A${p}\uFF01`)}})),Object.keys(u).length>0)if(n.ignoreFailedRemoteSub)n.ignoreFailedRemoteSub==="enabled"&&G.notify("\u{1F30D} Sub-Store \u9884\u89C8\u7EC4\u5408\u8BA2\u9605\u5931\u8D25",`\u274C ${n.name}`,`\u5B50\u8BA2\u9605 ${Object.keys(u).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);else throw new Error(`\u7EC4\u5408\u8BA2\u9605 ${n.name} \u7684\u5B50\u8BA2\u9605 ${Object.keys(u).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);let l=Array.prototype.concat.apply([],i.map(d=>s[d]||[]));l.forEach((d,g)=>{d.id=g,d._collectionName=n.name,d._collectionDisplayName=n.displayName});let f=await Nt.process(l,n.process||[],"JSON",{_collection:n});na(t,{original:l,processed:f})}catch(r){G.error(r.message??r),En(t,new Li("INTERNAL_SERVER_ERROR","Failed to preview collection",`Reason: ${r.message??r}`))}}function oE(e){e.post("/api/utils/node-info",LK)}async function LK(e,t){let r=e.body,n=e.query.lang||"zh-CN",i;try{i=Dp.URI.produce(r)}catch{}try{let s=await As().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(u=>{let l=JSON.parse(u.body);if(l.status!=="success")throw new Error(l.message);return delete l.status,l});na(t,{shareUrl:i,info:s})}catch(a){En(t,new Dd("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${C0} \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 `);ig();UK();function UK(){let e=sg({substore:G});aE(e),uE(e),gm(e),oE(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 *) */