@subconverter/browser 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/README.md +55 -0
- package/dist/subconverter.global.js +87 -87
- package/dist/subconverter.global.js.map +1 -1
- package/package.json +21 -2
|
@@ -1,136 +1,136 @@
|
|
|
1
|
-
var SubConverter=(()=>{var ws=Object.defineProperty;var
|
|
2
|
-
`)}};Ne.defaultYaml={explicit:!1,version:"1.2"};Ne.defaultTags={"!!":"tag:yaml.org,2002:"};function
|
|
3
|
-
`)?
|
|
1
|
+
var SubConverter=(()=>{var ws=Object.defineProperty;var kn=Object.getOwnPropertyDescriptor;var $n=Object.getOwnPropertyNames;var In=Object.prototype.hasOwnProperty;var nr=(t,e)=>{for(var s in e)ws(t,s,{get:e[s],enumerable:!0})},An=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of $n(e))!In.call(t,n)&&n!==s&&ws(t,n,{get:()=>e[n],enumerable:!(r=kn(e,n))||r.enumerable});return t};var Nn=t=>An(ws({},"__esModule",{value:!0}),t);var uo={};nr(uo,{default:()=>lo});var bs={};nr(bs,{createExtraSettings:()=>on,fetchSubscription:()=>Sn,loadNodes:()=>co,parseSubscription:()=>ys,toClash:()=>wn,toSurge:()=>vn});var Tt=Symbol.for("yaml.alias"),Lt=Symbol.for("yaml.document"),de=Symbol.for("yaml.map"),vs=Symbol.for("yaml.pair"),ce=Symbol.for("yaml.scalar"),Te=Symbol.for("yaml.seq"),ne=Symbol.for("yaml.node.type"),he=t=>!!t&&typeof t=="object"&&t[ne]===Tt,me=t=>!!t&&typeof t=="object"&&t[ne]===Lt,ge=t=>!!t&&typeof t=="object"&&t[ne]===de,j=t=>!!t&&typeof t=="object"&&t[ne]===vs,F=t=>!!t&&typeof t=="object"&&t[ne]===ce,ye=t=>!!t&&typeof t=="object"&&t[ne]===Te;function G(t){if(t&&typeof t=="object")switch(t[ne]){case de:case Te:return!0}return!1}function B(t){if(t&&typeof t=="object")switch(t[ne]){case Tt:case de:case ce:case Te:return!0}return!1}var Rt=t=>(F(t)||G(t))&&!!t.anchor;var oe=Symbol("break visit"),ir=Symbol("skip children"),Ie=Symbol("remove node");function Ae(t,e){let s=or(e);me(t)?Xe(null,t.contents,s,Object.freeze([t]))===Ie&&(t.contents=null):Xe(null,t,s,Object.freeze([]))}Ae.BREAK=oe;Ae.SKIP=ir;Ae.REMOVE=Ie;function Xe(t,e,s,r){let n=ar(t,e,s,r);if(B(n)||j(n))return cr(t,r,n),Xe(t,n,s,r);if(typeof n!="symbol"){if(G(e)){r=Object.freeze(r.concat(e));for(let i=0;i<e.items.length;++i){let o=Xe(i,e.items[i],s,r);if(typeof o=="number")i=o-1;else{if(o===oe)return oe;o===Ie&&(e.items.splice(i,1),i-=1)}}}else if(j(e)){r=Object.freeze(r.concat(e));let i=Xe("key",e.key,s,r);if(i===oe)return oe;i===Ie&&(e.key=null);let o=Xe("value",e.value,s,r);if(o===oe)return oe;o===Ie&&(e.value=null)}}return n}async function _t(t,e){let s=or(e);me(t)?await Qe(null,t.contents,s,Object.freeze([t]))===Ie&&(t.contents=null):await Qe(null,t,s,Object.freeze([]))}_t.BREAK=oe;_t.SKIP=ir;_t.REMOVE=Ie;async function Qe(t,e,s,r){let n=await ar(t,e,s,r);if(B(n)||j(n))return cr(t,r,n),Qe(t,n,s,r);if(typeof n!="symbol"){if(G(e)){r=Object.freeze(r.concat(e));for(let i=0;i<e.items.length;++i){let o=await Qe(i,e.items[i],s,r);if(typeof o=="number")i=o-1;else{if(o===oe)return oe;o===Ie&&(e.items.splice(i,1),i-=1)}}}else if(j(e)){r=Object.freeze(r.concat(e));let i=await Qe("key",e.key,s,r);if(i===oe)return oe;i===Ie&&(e.key=null);let o=await Qe("value",e.value,s,r);if(o===oe)return oe;o===Ie&&(e.value=null)}}return n}function or(t){return typeof t=="object"&&(t.Collection||t.Node||t.Value)?Object.assign({Alias:t.Node,Map:t.Node,Scalar:t.Node,Seq:t.Node},t.Value&&{Map:t.Value,Scalar:t.Value,Seq:t.Value},t.Collection&&{Map:t.Collection,Seq:t.Collection},t):t}function ar(t,e,s,r){if(typeof s=="function")return s(t,e,r);if(ge(e))return s.Map?.(t,e,r);if(ye(e))return s.Seq?.(t,e,r);if(j(e))return s.Pair?.(t,e,r);if(F(e))return s.Scalar?.(t,e,r);if(he(e))return s.Alias?.(t,e,r)}function cr(t,e,s){let r=e[e.length-1];if(G(r))r.items[t]=s;else if(j(r))t==="key"?r.key=s:r.value=s;else if(me(r))r.contents=s;else{let n=he(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}var On={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},En=t=>t.replace(/[!,[\]{}]/g,e=>On[e]),Ne=class t{constructor(e,s){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,s)}clone(){let e=new t(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new t(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:t.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},t.defaultTags);break}return e}add(e,s){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let r=e.trim().split(/[ \t]+/),n=r.shift();switch(n){case"%TAG":{if(r.length!==2&&(s(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;let[i,o]=r;return this.tags[i]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return s(0,"%YAML directive should contain exactly one part"),!1;let[i]=r;if(i==="1.1"||i==="1.2")return this.yaml.version=i,!0;{let o=/^\d+\.\d+$/.test(i);return s(6,`Unsupported YAML version ${i}`,o),!1}}default:return s(0,`Unknown directive ${n}`,!0),!1}}tagName(e,s){if(e==="!")return"!";if(e[0]!=="!")return s(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);return o==="!"||o==="!!"?(s(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&s("Verbatim tags must end with a >"),o)}let[,r,n]=e.match(/^(.*!)([^!]*)$/s);n||s(`The ${e} tag has no suffix`);let i=this.tags[r];if(i)try{return i+decodeURIComponent(n)}catch(o){return s(String(o)),null}return r==="!"?e:(s(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[s,r]of Object.entries(this.tags))if(e.startsWith(r))return s+En(e.substring(r.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let s=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),n;if(e&&r.length>0&&B(e.contents)){let i={};Ae(e.contents,(o,a)=>{B(a)&&a.tag&&(i[a.tag]=!0)}),n=Object.keys(i)}else n=[];for(let[i,o]of r)i==="!!"&&o==="tag:yaml.org,2002:"||(!e||n.some(a=>a.startsWith(o)))&&s.push(`%TAG ${i} ${o}`);return s.join(`
|
|
2
|
+
`)}};Ne.defaultYaml={explicit:!1,version:"1.2"};Ne.defaultTags={"!!":"tag:yaml.org,2002:"};function Ft(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let s=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(s)}return!0}function Ss(t){let e=new Set;return Ae(t,{Value(s,r){r.anchor&&e.add(r.anchor)}}),e}function ks(t,e){for(let s=1;;++s){let r=`${t}${s}`;if(!e.has(r))return r}}function lr(t,e){let s=[],r=new Map,n=null;return{onAnchor:i=>{s.push(i),n??(n=Ss(t));let o=ks(e,n);return n.add(o),o},setAnchors:()=>{for(let i of s){let o=r.get(i);if(typeof o=="object"&&o.anchor&&(F(o.node)||G(o.node)))o.node.anchor=o.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=i,a}}},sourceObjects:r}}function De(t,e,s,r){if(r&&typeof r=="object")if(Array.isArray(r))for(let n=0,i=r.length;n<i;++n){let o=r[n],a=De(t,r,String(n),o);a===void 0?delete r[n]:a!==o&&(r[n]=a)}else if(r instanceof Map)for(let n of Array.from(r.keys())){let i=r.get(n),o=De(t,r,n,i);o===void 0?r.delete(n):o!==i&&r.set(n,o)}else if(r instanceof Set)for(let n of Array.from(r)){let i=De(t,r,n,n);i===void 0?r.delete(n):i!==n&&(r.delete(n),r.add(i))}else for(let[n,i]of Object.entries(r)){let o=De(t,r,n,i);o===void 0?delete r[n]:o!==i&&(r[n]=o)}return t.call(e,s,r)}function z(t,e,s){if(Array.isArray(t))return t.map((r,n)=>z(r,String(n),s));if(t&&typeof t.toJSON=="function"){if(!s||!Rt(t))return t.toJSON(e,s);let r={aliasCount:0,count:1,res:void 0};s.anchors.set(t,r),s.onCreate=i=>{r.res=i,delete s.onCreate};let n=t.toJSON(e,s);return s.onCreate&&s.onCreate(n),n}return typeof t=="bigint"&&!s?.keep?Number(t):t}var je=class{constructor(e){Object.defineProperty(this,ne,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:s,maxAliasCount:r,onAnchor:n,reviver:i}={}){if(!me(e))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:s===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},a=z(this,"",o);if(typeof n=="function")for(let{count:c,res:u}of o.anchors.values())n(u,c);return typeof i=="function"?De(i,{"":a},"",a):a}};var Le=class extends je{constructor(e){super(Tt),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,s){if(s?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let r;s?.aliasResolveCache?r=s.aliasResolveCache:(r=[],Ae(e,{Node:(i,o)=>{(he(o)||Rt(o))&&r.push(o)}}),s&&(s.aliasResolveCache=r));let n;for(let i of r){if(i===this)break;i.anchor===this.source&&(n=i)}if(n&&s){let{anchors:i,doc:o,maxAliasCount:a}=s,c=i.get(n);if(c||(z(n,null,s),c=i.get(n)),c?.res===void 0){let u="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(u)}if(a>=0&&(c.count+=1,c.aliasCount===0&&(c.aliasCount=Mt(o,n,i)),c.count*c.aliasCount>a)){let u="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(u)}}return n}toJSON(e,s){if(!s)return{source:this.source};let r=this.resolve(s.doc,s);if(!r){let n=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(n)}return s.anchors.get(r).res}toString(e,s,r){let n=`*${this.source}`;if(e){if(Ft(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let i=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(i)}if(e.implicitKey)return`${n} `}return n}};function Mt(t,e,s){if(he(e)){let r=e.resolve(t),n=s&&r&&s.get(r);return n?n.count*n.aliasCount:0}else if(G(e)){let r=0;for(let n of e.items){let i=Mt(t,n,s);i>r&&(r=i)}return r}else if(j(e)){let r=Mt(t,e.key,s),n=Mt(t,e.value,s);return Math.max(r,n)}return 1}var Dt=t=>!t||typeof t!="function"&&typeof t!="object",C=class extends je{constructor(e){super(ce),this.value=e}toJSON(e,s){return s?.keep?this.value:z(this.value,e,s)}toString(){return String(this.value)}};C.BLOCK_FOLDED="BLOCK_FOLDED";C.BLOCK_LITERAL="BLOCK_LITERAL";C.PLAIN="PLAIN";C.QUOTE_DOUBLE="QUOTE_DOUBLE";C.QUOTE_SINGLE="QUOTE_SINGLE";var Cn="tag:yaml.org,2002:";function Pn(t,e,s){if(e){let r=s.filter(i=>i.tag===e),n=r.find(i=>!i.format)??r[0];if(!n)throw new Error(`Tag ${e} not found`);return n}return s.find(r=>r.identify?.(t)&&!r.format)}function Re(t,e,s){if(me(t)&&(t=t.contents),B(t))return t;if(j(t)){let f=s.schema[de].createNode?.(s.schema,null,s);return f.items.push(t),f}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:r,onAnchor:n,onTagObj:i,schema:o,sourceObjects:a}=s,c;if(r&&t&&typeof t=="object"){if(c=a.get(t),c)return c.anchor??(c.anchor=n(t)),new Le(c.anchor);c={anchor:null,node:null},a.set(t,c)}e?.startsWith("!!")&&(e=Cn+e.slice(2));let u=Pn(t,e,o.tags);if(!u){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let f=new C(t);return c&&(c.node=f),f}u=t instanceof Map?o[de]:Symbol.iterator in Object(t)?o[Te]:o[de]}i&&(i(u),delete s.onTagObj);let p=u?.createNode?u.createNode(s.schema,t,s):typeof u?.nodeClass?.from=="function"?u.nodeClass.from(s.schema,t,s):new C(t);return e?p.tag=e:u.default||(p.tag=u.tag),c&&(c.node=p),p}function ut(t,e,s){let r=s;for(let n=e.length-1;n>=0;--n){let i=e[n];if(typeof i=="number"&&Number.isInteger(i)&&i>=0){let o=[];o[i]=r,r=o}else r=new Map([[i,r]])}return Re(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}var Ze=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,ze=class extends je{constructor(e,s){super(e),Object.defineProperty(this,"schema",{value:s,configurable:!0,enumerable:!1,writable:!0})}clone(e){let s=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(s.schema=e),s.items=s.items.map(r=>B(r)||j(r)?r.clone(e):r),this.range&&(s.range=this.range.slice()),s}addIn(e,s){if(Ze(e))this.add(s);else{let[r,...n]=e,i=this.get(r,!0);if(G(i))i.addIn(n,s);else if(i===void 0&&this.schema)this.set(r,ut(this.schema,n,s));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}deleteIn(e){let[s,...r]=e;if(r.length===0)return this.delete(s);let n=this.get(s,!0);if(G(n))return n.deleteIn(r);throw new Error(`Expected YAML collection at ${s}. Remaining path: ${r}`)}getIn(e,s){let[r,...n]=e,i=this.get(r,!0);return n.length===0?!s&&F(i)?i.value:i:G(i)?i.getIn(n,s):void 0}hasAllNullValues(e){return this.items.every(s=>{if(!j(s))return!1;let r=s.value;return r==null||e&&F(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[s,...r]=e;if(r.length===0)return this.has(s);let n=this.get(s,!0);return G(n)?n.hasIn(r):!1}setIn(e,s){let[r,...n]=e;if(n.length===0)this.set(r,s);else{let i=this.get(r,!0);if(G(i))i.setIn(n,s);else if(i===void 0&&this.schema)this.set(r,ut(this.schema,n,s));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}};var ur=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function fe(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var Oe=(t,e,s)=>t.endsWith(`
|
|
3
|
+
`)?fe(s,e):s.includes(`
|
|
4
4
|
`)?`
|
|
5
|
-
`+
|
|
6
|
-
`)s===
|
|
5
|
+
`+fe(s,e):(t.endsWith(" ")?"":" ")+s;var $s="flow",jt="block",ft="quoted";function pt(t,e,s="flow",{indentAtStart:r,lineWidth:n=80,minContentWidth:i=20,onFold:o,onOverflow:a}={}){if(!n||n<0)return t;n<i&&(i=0);let c=Math.max(1+i,1+n-e.length);if(t.length<=c)return t;let u=[],p={},f=n-e.length;typeof r=="number"&&(r>n-Math.max(2,i)?u.push(0):f=n-r);let l,m,y=!1,d=-1,h=-1,v=-1;s===jt&&(d=fr(t,d,e.length),d!==-1&&(f=d+c));for(let S;S=t[d+=1];){if(s===ft&&S==="\\"){switch(h=d,t[d+1]){case"x":d+=3;break;case"u":d+=5;break;case"U":d+=9;break;default:d+=1}v=d}if(S===`
|
|
6
|
+
`)s===jt&&(d=fr(t,d,e.length)),f=d+e.length+c,l=void 0;else{if(S===" "&&m&&m!==" "&&m!==`
|
|
7
7
|
`&&m!==" "){let $=t[d+1];$&&$!==" "&&$!==`
|
|
8
|
-
`&&$!==" "&&(l=d)}if(d>=
|
|
9
|
-
${e}${t.slice(0,
|
|
10
|
-
${e}${t.slice($+1,
|
|
11
|
-
`);r=e,n=e+1,i=t[n]}return r}var Ut=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),
|
|
12
|
-
`){if(i-o>r)return!0;if(o=i+1,n-o<=r)return!1}return!0}function dt(t,e){let s=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return s;let{implicitKey:r}=e,n=e.options.doubleQuotedMinMultiLineLength,i=e.indent||(
|
|
8
|
+
`&&$!==" "&&(l=d)}if(d>=f)if(l)u.push(l),f=l+c,l=void 0;else if(s===ft){for(;m===" "||m===" ";)m=S,S=t[d+=1],y=!0;let $=d>v+1?d-2:h-1;if(p[$])return t;u.push($),p[$]=!0,f=$+c,l=void 0}else y=!0}m=S}if(y&&a&&a(),u.length===0)return t;o&&o();let b=t.slice(0,u[0]);for(let S=0;S<u.length;++S){let $=u[S],k=u[S+1]||t.length;$===0?b=`
|
|
9
|
+
${e}${t.slice(0,k)}`:(s===ft&&p[$]&&(b+=`${t[$]}\\`),b+=`
|
|
10
|
+
${e}${t.slice($+1,k)}`)}return b}function fr(t,e,s){let r=e,n=e+1,i=t[n];for(;i===" "||i===" ";)if(e<n+s)i=t[++e];else{do i=t[++e];while(i&&i!==`
|
|
11
|
+
`);r=e,n=e+1,i=t[n]}return r}var Ut=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),Kt=t=>/^(%|---|\.\.\.)/m.test(t);function Tn(t,e,s){if(!e||e<0)return!1;let r=e-s,n=t.length;if(n<=r)return!1;for(let i=0,o=0;i<n;++i)if(t[i]===`
|
|
12
|
+
`){if(i-o>r)return!0;if(o=i+1,n-o<=r)return!1}return!0}function dt(t,e){let s=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return s;let{implicitKey:r}=e,n=e.options.doubleQuotedMinMultiLineLength,i=e.indent||(Kt(t)?" ":""),o="",a=0;for(let c=0,u=s[c];u;u=s[++c])if(u===" "&&s[c+1]==="\\"&&s[c+2]==="n"&&(o+=s.slice(a,c)+"\\ ",c+=1,a=c,u="\\"),u==="\\")switch(s[c+1]){case"u":{o+=s.slice(a,c);let p=s.substr(c+2,4);switch(p){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:p.substr(0,2)==="00"?o+="\\x"+p.substr(2):o+=s.substr(c,6)}c+=5,a=c+1}break;case"n":if(r||s[c+2]==='"'||s.length<n)c+=1;else{for(o+=s.slice(a,c)+`
|
|
13
13
|
|
|
14
14
|
`;s[c+2]==="\\"&&s[c+3]==="n"&&s[c+4]!=='"';)o+=`
|
|
15
|
-
`,c+=2;o+=i,s[c+2]===" "&&(o+="\\"),c+=1,a=c+1}break;default:c+=1}return o=a?o+s.slice(a):s,r?o:pt(o,i,
|
|
16
|
-
`)||/[ \t]\n|\n[ \t]/.test(t))return dt(t,e);let s=e.indent||(
|
|
17
|
-
${s}`)+"'";return e.implicitKey?r:pt(r,s,$s,Ut(e,!1))}function xe(t,e){let{singleQuote:s}=e.options,r;if(s===!1)r=dt;else{let n=t.includes('"'),i=t.includes("'");n&&!i?r=
|
|
15
|
+
`,c+=2;o+=i,s[c+2]===" "&&(o+="\\"),c+=1,a=c+1}break;default:c+=1}return o=a?o+s.slice(a):s,r?o:pt(o,i,ft,Ut(e,!1))}function Is(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
|
|
16
|
+
`)||/[ \t]\n|\n[ \t]/.test(t))return dt(t,e);let s=e.indent||(Kt(t)?" ":""),r="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
17
|
+
${s}`)+"'";return e.implicitKey?r:pt(r,s,$s,Ut(e,!1))}function xe(t,e){let{singleQuote:s}=e.options,r;if(s===!1)r=dt;else{let n=t.includes('"'),i=t.includes("'");n&&!i?r=Is:i&&!n?r=dt:r=s?Is:dt}return r(t,e)}var As;try{As=new RegExp(`(^|(?<!
|
|
18
18
|
))
|
|
19
19
|
+(?!
|
|
20
|
-
|$)`,"g")}catch{
|
|
20
|
+
|$)`,"g")}catch{As=/\n+(?!\n|$)/g}function Bt({comment:t,type:e,value:s},r,n,i){let{blockQuote:o,commentString:a,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(s))return xe(s,r);let u=r.indent||(r.forceBlockIndent||Kt(s)?" ":""),p=o==="literal"?!0:o==="folded"||e===C.BLOCK_FOLDED?!1:e===C.BLOCK_LITERAL?!0:!Tn(s,c,u.length);if(!s)return p?`|
|
|
21
21
|
`:`>
|
|
22
|
-
`;let
|
|
23
|
-
`&&
|
|
24
|
-
`);y===-1?
|
|
25
|
-
`&&(m=m.slice(0,-1)),m=m.replace(
|
|
26
|
-
`)
|
|
27
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${
|
|
28
|
-
${
|
|
29
|
-
${
|
|
22
|
+
`;let f,l;for(l=s.length;l>0;--l){let k=s[l-1];if(k!==`
|
|
23
|
+
`&&k!==" "&&k!==" ")break}let m=s.substring(l),y=m.indexOf(`
|
|
24
|
+
`);y===-1?f="-":s===m||y!==m.length-1?(f="+",i&&i()):f="",m&&(s=s.slice(0,-m.length),m[m.length-1]===`
|
|
25
|
+
`&&(m=m.slice(0,-1)),m=m.replace(As,`$&${u}`));let d=!1,h,v=-1;for(h=0;h<s.length;++h){let k=s[h];if(k===" ")d=!0;else if(k===`
|
|
26
|
+
`)v=h;else break}let b=s.substring(0,v<h?v+1:h);b&&(s=s.substring(b.length),b=b.replace(/\n+/g,`$&${u}`));let $=(d?u?"2":"1":"")+f;if(t&&($+=" "+a(t.replace(/ ?[\r\n]+/g," ")),n&&n()),!p){let k=s.replace(/\n+/g,`
|
|
27
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${u}`),N=!1,O=Ut(r,!0);o!=="folded"&&e!==C.BLOCK_FOLDED&&(O.onOverflow=()=>{N=!0});let I=pt(`${b}${k}${m}`,u,jt,O);if(!N)return`>${$}
|
|
28
|
+
${u}${I}`}return s=s.replace(/\n+/g,`$&${u}`),`|${$}
|
|
29
|
+
${u}${b}${s}${m}`}function Ln(t,e,s,r){let{type:n,value:i}=t,{actualString:o,implicitKey:a,indent:c,indentStep:u,inFlow:p}=e;if(a&&i.includes(`
|
|
30
30
|
`)||p&&/[[\]{},]/.test(i))return xe(i,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(i))return a||p||!i.includes(`
|
|
31
|
-
`)?xe(i,e):
|
|
32
|
-
`))return
|
|
33
|
-
${c}`);if(o){let l=d=>d.default&&d.tag!=="tag:yaml.org,2002:str"&&d.test?.test(
|
|
34
|
-
${e.indent}${a}`:a}function pr({key:t,value:e},s,r,n){let{allNullValues:i,doc:o,indent:a,indentStep:c,options:{commentString:
|
|
35
|
-
${a}:`):(h=`${h}:`,l&&(h+=
|
|
36
|
-
`:"",b){let
|
|
37
|
-
${
|
|
31
|
+
`)?xe(i,e):Bt(t,e,s,r);if(!a&&!p&&n!==C.PLAIN&&i.includes(`
|
|
32
|
+
`))return Bt(t,e,s,r);if(Kt(i)){if(c==="")return e.forceBlockIndent=!0,Bt(t,e,s,r);if(a&&c===u)return xe(i,e)}let f=i.replace(/\n+/g,`$&
|
|
33
|
+
${c}`);if(o){let l=d=>d.default&&d.tag!=="tag:yaml.org,2002:str"&&d.test?.test(f),{compat:m,tags:y}=e.doc.schema;if(y.some(l)||m?.some(l))return xe(i,e)}return a?f:pt(f,c,$s,Ut(e,!1))}function qe(t,e,s,r){let{implicitKey:n,inFlow:i}=e,o=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)}),{type:a}=t;a!==C.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=C.QUOTE_DOUBLE);let c=p=>{switch(p){case C.BLOCK_FOLDED:case C.BLOCK_LITERAL:return n||i?xe(o.value,e):Bt(o,e,s,r);case C.QUOTE_DOUBLE:return dt(o.value,e);case C.QUOTE_SINGLE:return Is(o.value,e);case C.PLAIN:return Ln(o,e,s,r);default:return null}},u=c(a);if(u===null){let{defaultKeyType:p,defaultStringType:f}=e.options,l=n&&p||f;if(u=c(l),u===null)throw new Error(`Unsupported default string type ${l}`)}return u}function Gt(t,e){let s=Object.assign({blockQuote:!0,commentString:ur,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},t.schema.toStringOptions,e),r;switch(s.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:t,flowCollectionPadding:s.flowCollectionPadding?" ":"",indent:"",indentStep:typeof s.indent=="number"?" ".repeat(s.indent):" ",inFlow:r,options:s}}function Rn(t,e){if(e.tag){let n=t.filter(i=>i.tag===e.tag);if(n.length>0)return n.find(i=>i.format===e.format)??n[0]}let s,r;if(F(e)){r=e.value;let n=t.filter(i=>i.identify?.(r));if(n.length>1){let i=n.filter(o=>o.test);i.length>0&&(n=i)}s=n.find(i=>i.format===e.format)??n.find(i=>!i.format)}else r=e,s=t.find(n=>n.nodeClass&&r instanceof n.nodeClass);if(!s){let n=r?.constructor?.name??(r===null?"null":typeof r);throw new Error(`Tag not resolved for ${n} value`)}return s}function _n(t,e,{anchors:s,doc:r}){if(!r.directives)return"";let n=[],i=(F(t)||G(t))&&t.anchor;i&&Ft(i)&&(s.add(i),n.push(`&${i}`));let o=t.tag??(e.default?null:e.tag);return o&&n.push(r.directives.tagString(o)),n.join(" ")}function _e(t,e,s,r){if(j(t))return t.toString(e,s,r);if(he(t)){if(e.doc.directives)return t.toString(e);if(e.resolvedAliases?.has(t))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(t):e.resolvedAliases=new Set([t]),t=t.resolve(e.doc)}let n,i=B(t)?t:e.doc.createNode(t,{onTagObj:c=>n=c});n??(n=Rn(e.doc.schema.tags,i));let o=_n(i,n,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);let a=typeof n.stringify=="function"?n.stringify(i,e,s,r):F(i)?qe(i,e,s,r):i.toString(e,s,r);return o?F(i)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
|
|
34
|
+
${e.indent}${a}`:a}function pr({key:t,value:e},s,r,n){let{allNullValues:i,doc:o,indent:a,indentStep:c,options:{commentString:u,indentSeq:p,simpleKeys:f}}=s,l=B(t)&&t.comment||null;if(f){if(l)throw new Error("With simple keys, key nodes cannot have comments");if(G(t)||!B(t)&&typeof t=="object"){let O="With simple keys, collection cannot be used as a key value";throw new Error(O)}}let m=!f&&(!t||l&&e==null&&!s.inFlow||G(t)||(F(t)?t.type===C.BLOCK_FOLDED||t.type===C.BLOCK_LITERAL:typeof t=="object"));s=Object.assign({},s,{allNullValues:!1,implicitKey:!m&&(f||!i),indent:a+c});let y=!1,d=!1,h=_e(t,s,()=>y=!0,()=>d=!0);if(!m&&!s.inFlow&&h.length>1024){if(f)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");m=!0}if(s.inFlow){if(i||e==null)return y&&r&&r(),h===""?"?":m?`? ${h}`:h}else if(i&&!f||e==null&&m)return h=`? ${h}`,l&&!y?h+=Oe(h,s.indent,u(l)):d&&n&&n(),h;y&&(l=null),m?(l&&(h+=Oe(h,s.indent,u(l))),h=`? ${h}
|
|
35
|
+
${a}:`):(h=`${h}:`,l&&(h+=Oe(h,s.indent,u(l))));let v,b,S;B(e)?(v=!!e.spaceBefore,b=e.commentBefore,S=e.comment):(v=!1,b=null,S=null,e&&typeof e=="object"&&(e=o.createNode(e))),s.implicitKey=!1,!m&&!l&&F(e)&&(s.indentAtStart=h.length+1),d=!1,!p&&c.length>=2&&!s.inFlow&&!m&&ye(e)&&!e.flow&&!e.tag&&!e.anchor&&(s.indent=s.indent.substring(2));let $=!1,k=_e(e,s,()=>$=!0,()=>d=!0),N=" ";if(l||v||b){if(N=v?`
|
|
36
|
+
`:"",b){let O=u(b);N+=`
|
|
37
|
+
${fe(O,s.indent)}`}k===""&&!s.inFlow?N===`
|
|
38
38
|
`&&S&&(N=`
|
|
39
39
|
|
|
40
40
|
`):N+=`
|
|
41
|
-
${s.indent}`}else if(!m&&
|
|
42
|
-
`),
|
|
43
|
-
${s.indent}`)}}else(
|
|
44
|
-
`)&&(N="");return h+=N+
|
|
41
|
+
${s.indent}`}else if(!m&&G(e)){let O=k[0],I=k.indexOf(`
|
|
42
|
+
`),R=I!==-1,U=s.inFlow??e.flow??e.items.length===0;if(R||!U){let Z=!1;if(R&&(O==="&"||O==="!")){let E=k.indexOf(" ");O==="&"&&E!==-1&&E<I&&k[E+1]==="!"&&(E=k.indexOf(" ",E+1)),(E===-1||I<E)&&(Z=!0)}Z||(N=`
|
|
43
|
+
${s.indent}`)}}else(k===""||k[0]===`
|
|
44
|
+
`)&&(N="");return h+=N+k,s.inFlow?$&&r&&r():S&&!$?h+=Oe(h,s.indent,u(S)):d&&n&&n(),h}function Vt(t,e){(t==="debug"||t==="warn")&&console.warn(e)}var qt="<<",be={identify:t=>t===qt||typeof t=="symbol"&&t.description===qt,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new C(Symbol(qt)),{addToJSMap:Os}),stringify:()=>qt},dr=(t,e)=>(be.identify(e)||F(e)&&(!e.type||e.type===C.PLAIN)&&be.identify(e.value))&&t?.doc.schema.tags.some(s=>s.tag===be.tag&&s.default);function Os(t,e,s){let r=hr(t,s);if(ye(r))for(let n of r.items)Ns(t,e,n);else if(Array.isArray(r))for(let n of r)Ns(t,e,n);else Ns(t,e,r)}function Ns(t,e,s){let r=hr(t,s);if(!ge(r))throw new Error("Merge sources must be maps or map aliases");let n=r.toJSON(null,t,Map);for(let[i,o]of n)e instanceof Map?e.has(i)||e.set(i,o):e instanceof Set?e.add(i):Object.prototype.hasOwnProperty.call(e,i)||Object.defineProperty(e,i,{value:o,writable:!0,enumerable:!0,configurable:!0});return e}function hr(t,e){return t&&he(e)?e.resolve(t.doc,t):e}function Wt(t,e,{key:s,value:r}){if(B(s)&&s.addToJSMap)s.addToJSMap(t,e,r);else if(dr(t,s))Os(t,e,r);else{let n=z(s,"",t);if(e instanceof Map)e.set(n,z(r,n,t));else if(e instanceof Set)e.add(n);else{let i=Fn(s,n,t),o=z(r,i,t);i in e?Object.defineProperty(e,i,{value:o,writable:!0,enumerable:!0,configurable:!0}):e[i]=o}}return e}function Fn(t,e,s){if(e===null)return"";if(typeof e!="object")return String(e);if(B(t)&&s?.doc){let r=Gt(s.doc,{});r.anchors=new Set;for(let i of s.anchors.keys())r.anchors.add(i.anchor);r.inFlow=!0,r.inStringifyKey=!0;let n=t.toString(r);if(!s.mapKeyWarned){let i=JSON.stringify(n);i.length>40&&(i=i.substring(0,36)+'..."'),Vt(s.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${i}. Set mapAsMap: true to use object keys.`),s.mapKeyWarned=!0}return n}return JSON.stringify(e)}function et(t,e,s){let r=Re(t,void 0,s),n=Re(e,void 0,s);return new J(r,n)}var J=class t{constructor(e,s=null){Object.defineProperty(this,ne,{value:vs}),this.key=e,this.value=s}clone(e){let{key:s,value:r}=this;return B(s)&&(s=s.clone(e)),B(r)&&(r=r.clone(e)),new t(s,r)}toJSON(e,s){let r=s?.mapAsMap?new Map:{};return Wt(s,r,this)}toString(e,s,r){return e?.doc?pr(this,e,s,r):JSON.stringify(this)}};function Yt(t,e,s){return(e.inFlow??t.flow?Dn:Mn)(t,e,s)}function Mn({comment:t,items:e},s,{blockItemPrefix:r,flowChars:n,itemIndent:i,onChompKeep:o,onComment:a}){let{indent:c,options:{commentString:u}}=s,p=Object.assign({},s,{indent:i,type:null}),f=!1,l=[];for(let y=0;y<e.length;++y){let d=e[y],h=null;if(B(d))!f&&d.spaceBefore&&l.push(""),Ht(s,l,d.commentBefore,f),d.comment&&(h=d.comment);else if(j(d)){let b=B(d.key)?d.key:null;b&&(!f&&b.spaceBefore&&l.push(""),Ht(s,l,b.commentBefore,f))}f=!1;let v=_e(d,p,()=>h=null,()=>f=!0);h&&(v+=Oe(v,i,u(h))),f&&h&&(f=!1),l.push(r+v)}let m;if(l.length===0)m=n.start+n.end;else{m=l[0];for(let y=1;y<l.length;++y){let d=l[y];m+=d?`
|
|
45
45
|
${c}${d}`:`
|
|
46
46
|
`}}return t?(m+=`
|
|
47
|
-
`+
|
|
48
|
-
`)),y<t.length-1?
|
|
47
|
+
`+fe(u(t),c),a&&a()):f&&o&&o(),m}function Dn({items:t},e,{flowChars:s,itemIndent:r}){let{indent:n,indentStep:i,flowCollectionPadding:o,options:{commentString:a}}=e;r+=i;let c=Object.assign({},e,{indent:r,inFlow:!0,type:null}),u=!1,p=0,f=[];for(let y=0;y<t.length;++y){let d=t[y],h=null;if(B(d))d.spaceBefore&&f.push(""),Ht(e,f,d.commentBefore,!1),d.comment&&(h=d.comment);else if(j(d)){let b=B(d.key)?d.key:null;b&&(b.spaceBefore&&f.push(""),Ht(e,f,b.commentBefore,!1),b.comment&&(u=!0));let S=B(d.value)?d.value:null;S?(S.comment&&(h=S.comment),S.commentBefore&&(u=!0)):d.value==null&&b?.comment&&(h=b.comment)}h&&(u=!0);let v=_e(d,c,()=>h=null);u||(u=f.length>p||v.includes(`
|
|
48
|
+
`)),y<t.length-1?v+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(u||(u=f.reduce((b,S)=>b+S.length+2,2)+(v.length+2)>e.options.lineWidth)),u&&(v+=",")),h&&(v+=Oe(v,r,a(h))),f.push(v),p=f.length}let{start:l,end:m}=s;if(f.length===0)return l+m;if(!u){let y=f.reduce((d,h)=>d+h.length+2,2);u=e.options.lineWidth>0&&y>e.options.lineWidth}if(u){let y=l;for(let d of f)y+=d?`
|
|
49
49
|
${i}${n}${d}`:`
|
|
50
50
|
`;return`${y}
|
|
51
|
-
${n}${m}`}else return`${l}${o}${
|
|
52
|
-
`:" ")}return
|
|
51
|
+
${n}${m}`}else return`${l}${o}${f.join(" ")}${o}${m}`}function Ht({indent:t,options:{commentString:e}},s,r,n){if(r&&n&&(r=r.replace(/^\n+/,"")),r){let i=fe(e(r),t);s.push(i.trimStart())}}function Be(t,e){let s=F(e)?e.value:e;for(let r of t)if(j(r)&&(r.key===e||r.key===s||F(r.key)&&r.key.value===s))return r}var X=class extends ze{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(de,e),this.items=[]}static from(e,s,r){let{keepUndefined:n,replacer:i}=r,o=new this(e),a=(c,u)=>{if(typeof i=="function")u=i.call(s,c,u);else if(Array.isArray(i)&&!i.includes(c))return;(u!==void 0||n)&&o.items.push(et(c,u,r))};if(s instanceof Map)for(let[c,u]of s)a(c,u);else if(s&&typeof s=="object")for(let c of Object.keys(s))a(c,s[c]);return typeof e.sortMapEntries=="function"&&o.items.sort(e.sortMapEntries),o}add(e,s){let r;j(e)?r=e:!e||typeof e!="object"||!("key"in e)?r=new J(e,e?.value):r=new J(e.key,e.value);let n=Be(this.items,r.key),i=this.schema?.sortMapEntries;if(n){if(!s)throw new Error(`Key ${r.key} already set`);F(n.value)&&Dt(r.value)?n.value.value=r.value:n.value=r.value}else if(i){let o=this.items.findIndex(a=>i(r,a)<0);o===-1?this.items.push(r):this.items.splice(o,0,r)}else this.items.push(r)}delete(e){let s=Be(this.items,e);return s?this.items.splice(this.items.indexOf(s),1).length>0:!1}get(e,s){let n=Be(this.items,e)?.value;return(!s&&F(n)?n.value:n)??void 0}has(e){return!!Be(this.items,e)}set(e,s){this.add(new J(e,s),!0)}toJSON(e,s,r){let n=r?new r:s?.mapAsMap?new Map:{};s?.onCreate&&s.onCreate(n);for(let i of this.items)Wt(s,n,i);return n}toString(e,s,r){if(!e)return JSON.stringify(this);for(let n of this.items)if(!j(n))throw new Error(`Map items must all be pairs; found ${JSON.stringify(n)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),Yt(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:s})}};var we={collection:"map",default:!0,nodeClass:X,tag:"tag:yaml.org,2002:map",resolve(t,e){return ge(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,s)=>X.from(t,e,s)};var te=class extends ze{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(Te,e),this.items=[]}add(e){this.items.push(e)}delete(e){let s=Jt(e);return typeof s!="number"?!1:this.items.splice(s,1).length>0}get(e,s){let r=Jt(e);if(typeof r!="number")return;let n=this.items[r];return!s&&F(n)?n.value:n}has(e){let s=Jt(e);return typeof s=="number"&&s<this.items.length}set(e,s){let r=Jt(e);if(typeof r!="number")throw new Error(`Expected a valid index, not ${e}.`);let n=this.items[r];F(n)&&Dt(s)?n.value=s:this.items[r]=s}toJSON(e,s){let r=[];s?.onCreate&&s.onCreate(r);let n=0;for(let i of this.items)r.push(z(i,String(n++),s));return r}toString(e,s,r){return e?Yt(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:r,onComment:s}):JSON.stringify(this)}static from(e,s,r){let{replacer:n}=r,i=new this(e);if(s&&Symbol.iterator in Object(s)){let o=0;for(let a of s){if(typeof n=="function"){let c=s instanceof Set?a:String(o++);a=n.call(s,c,a)}i.items.push(Re(a,void 0,r))}}return i}};function Jt(t){let e=F(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}var ve={collection:"seq",default:!0,nodeClass:te,tag:"tag:yaml.org,2002:seq",resolve(t,e){return ye(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,s)=>te.from(t,e,s)};var Ue={identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify(t,e,s,r){return e=Object.assign({actualString:!0},e),qe(t,e,s,r)}};var We={identify:t=>t==null,createNode:()=>new C(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new C(null),stringify:({source:t},e)=>typeof t=="string"&&We.test.test(t)?t:e.options.nullStr};var ht={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new C(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},s){if(t&&ht.test.test(t)){let r=t[0]==="t"||t[0]==="T";if(e===r)return t}return e?s.options.trueStr:s.options.falseStr}};function se({format:t,minFractionDigits:e,tag:s,value:r}){if(typeof r=="bigint")return String(r);let n=typeof r=="number"?r:Number(r);if(!isFinite(n))return isNaN(n)?".nan":n<0?"-.inf":".inf";let i=Object.is(r,-0)?"-0":JSON.stringify(r);if(!t&&e&&(!s||s==="tag:yaml.org,2002:float")&&/^-?\d/.test(i)&&!i.includes("e")){let o=i.indexOf(".");o<0&&(o=i.length,i+=".");let a=e-(i.length-o-1);for(;a-- >0;)i+="0"}return i}var Xt={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:se},Qt={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():se(t)}},zt={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(t){let e=new C(parseFloat(t)),s=t.indexOf(".");return s!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-s-1),e},stringify:se};var Zt=t=>typeof t=="bigint"||Number.isInteger(t),Es=(t,e,s,{intAsBigInt:r})=>r?BigInt(t):parseInt(t.substring(e),s);function mr(t,e,s){let{value:r}=t;return Zt(r)&&r>=0?s+r.toString(e):se(t)}var xt={identify:t=>Zt(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,s)=>Es(t,2,8,s),stringify:t=>mr(t,8,"0o")},es={identify:Zt,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,s)=>Es(t,0,10,s),stringify:se},ts={identify:t=>Zt(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,s)=>Es(t,2,16,s),stringify:t=>mr(t,16,"0x")};var gr=[we,ve,Ue,We,ht,xt,es,ts,Xt,Qt,zt];function yr(t){return typeof t=="bigint"||Number.isInteger(t)}var ss=({value:t})=>JSON.stringify(t),jn=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:ss},{identify:t=>t==null,createNode:()=>new C(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:ss},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:ss},{identify:yr,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(t,e,{intAsBigInt:s})=>s?BigInt(t):parseInt(t,10),stringify:({value:t})=>yr(t)?t.toString():JSON.stringify(t)},{identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:t=>parseFloat(t),stringify:ss}],Bn={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},br=[we,ve].concat(jn,Bn);var mt={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof atob=="function"){let s=atob(t.replace(/[\n\r]/g,"")),r=new Uint8Array(s.length);for(let n=0;n<s.length;++n)r[n]=s.charCodeAt(n);return r}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),t},stringify({comment:t,type:e,value:s},r,n,i){if(!s)return"";let o=s,a;if(typeof btoa=="function"){let c="";for(let u=0;u<o.length;++u)c+=String.fromCharCode(o[u]);a=btoa(c)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=C.BLOCK_LITERAL),e!==C.QUOTE_DOUBLE){let c=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),u=Math.ceil(a.length/c),p=new Array(u);for(let f=0,l=0;f<u;++f,l+=c)p[f]=a.substr(l,c);a=p.join(e===C.BLOCK_LITERAL?`
|
|
52
|
+
`:" ")}return qe({comment:t,type:e,value:a},r,n,i)}};function Cs(t,e){if(ye(t))for(let s=0;s<t.items.length;++s){let r=t.items[s];if(!j(r)){if(ge(r)){r.items.length>1&&e("Each pair must have its own sequence indicator");let n=r.items[0]||new J(new C(null));if(r.commentBefore&&(n.key.commentBefore=n.key.commentBefore?`${r.commentBefore}
|
|
53
53
|
${n.key.commentBefore}`:r.commentBefore),r.comment){let i=n.value??n.key;i.comment=i.comment?`${r.comment}
|
|
54
|
-
${i.comment}`:r.comment}r=n}t.items[s]=
|
|
55
|
-
`)?(s.push("..."),s.push(
|
|
54
|
+
${i.comment}`:r.comment}r=n}t.items[s]=j(r)?r:new J(r)}}else e("Expected a sequence for this tag");return t}function Ps(t,e,s){let{replacer:r}=s,n=new te(t);n.tag="tag:yaml.org,2002:pairs";let i=0;if(e&&Symbol.iterator in Object(e))for(let o of e){typeof r=="function"&&(o=r.call(e,String(i++),o));let a,c;if(Array.isArray(o))if(o.length===2)a=o[0],c=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let u=Object.keys(o);if(u.length===1)a=u[0],c=o[a];else throw new TypeError(`Expected tuple with one key, not ${u.length} keys`)}else a=o;n.items.push(et(a,c,s))}return n}var gt={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Cs,createNode:Ps};var tt=class t extends te{constructor(){super(),this.add=X.prototype.add.bind(this),this.delete=X.prototype.delete.bind(this),this.get=X.prototype.get.bind(this),this.has=X.prototype.has.bind(this),this.set=X.prototype.set.bind(this),this.tag=t.tag}toJSON(e,s){if(!s)return super.toJSON(e);let r=new Map;s?.onCreate&&s.onCreate(r);for(let n of this.items){let i,o;if(j(n)?(i=z(n.key,"",s),o=z(n.value,i,s)):i=z(n,"",s),r.has(i))throw new Error("Ordered maps must not include duplicate keys");r.set(i,o)}return r}static from(e,s,r){let n=Ps(e,s,r),i=new this;return i.items=n.items,i}};tt.tag="tag:yaml.org,2002:omap";var yt={collection:"seq",identify:t=>t instanceof Map,nodeClass:tt,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let s=Cs(t,e),r=[];for(let{key:n}of s.items)F(n)&&(r.includes(n.value)?e(`Ordered maps must not include duplicate keys: ${n.value}`):r.push(n.value));return Object.assign(new tt,s)},createNode:(t,e,s)=>tt.from(t,e,s)};function wr({value:t,source:e},s){return e&&(t?Ts:Ls).test.test(e)?e:t?s.options.trueStr:s.options.falseStr}var Ts={identify:t=>t===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new C(!0),stringify:wr},Ls={identify:t=>t===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new C(!1),stringify:wr};var vr={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:se},Sr={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t.replace(/_/g,"")),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():se(t)}},kr={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(t){let e=new C(parseFloat(t.replace(/_/g,""))),s=t.indexOf(".");if(s!==-1){let r=t.substring(s+1).replace(/_/g,"");r[r.length-1]==="0"&&(e.minFractionDigits=r.length)}return e},stringify:se};var bt=t=>typeof t=="bigint"||Number.isInteger(t);function rs(t,e,s,{intAsBigInt:r}){let n=t[0];if((n==="-"||n==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),r){switch(s){case 2:t=`0b${t}`;break;case 8:t=`0o${t}`;break;case 16:t=`0x${t}`;break}let o=BigInt(t);return n==="-"?BigInt(-1)*o:o}let i=parseInt(t,s);return n==="-"?-1*i:i}function Rs(t,e,s){let{value:r}=t;if(bt(r)){let n=r.toString(e);return r<0?"-"+s+n.substr(1):s+n}return se(t)}var $r={identify:bt,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,s)=>rs(t,2,2,s),stringify:t=>Rs(t,2,"0b")},Ir={identify:bt,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,s)=>rs(t,1,8,s),stringify:t=>Rs(t,8,"0")},Ar={identify:bt,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,s)=>rs(t,0,10,s),stringify:se},Nr={identify:bt,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,s)=>rs(t,2,16,s),stringify:t=>Rs(t,16,"0x")};var st=class t extends X{constructor(e){super(e),this.tag=t.tag}add(e){let s;j(e)?s=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?s=new J(e.key,null):s=new J(e,null),Be(this.items,s.key)||this.items.push(s)}get(e,s){let r=Be(this.items,e);return!s&&j(r)?F(r.key)?r.key.value:r.key:r}set(e,s){if(typeof s!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof s}`);let r=Be(this.items,e);r&&!s?this.items.splice(this.items.indexOf(r),1):!r&&s&&this.items.push(new J(e))}toJSON(e,s){return super.toJSON(e,s,Set)}toString(e,s,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),s,r);throw new Error("Set items must all have null values")}static from(e,s,r){let{replacer:n}=r,i=new this(e);if(s&&Symbol.iterator in Object(s))for(let o of s)typeof n=="function"&&(o=n.call(s,o,o)),i.items.push(et(o,null,r));return i}};st.tag="tag:yaml.org,2002:set";var wt={collection:"map",identify:t=>t instanceof Set,nodeClass:st,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,s)=>st.from(t,e,s),resolve(t,e){if(ge(t)){if(t.hasAllNullValues(!0))return Object.assign(new st,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};function _s(t,e){let s=t[0],r=s==="-"||s==="+"?t.substring(1):t,n=o=>e?BigInt(o):Number(o),i=r.replace(/_/g,"").split(":").reduce((o,a)=>o*n(60)+n(a),n(0));return s==="-"?n(-1)*i:i}function Or(t){let{value:e}=t,s=o=>o;if(typeof e=="bigint")s=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return se(t);let r="";e<0&&(r="-",e*=s(-1));let n=s(60),i=[e%n];return e<60?i.unshift(0):(e=(e-i[0])/n,i.unshift(e%n),e>=60&&(e=(e-i[0])/n,i.unshift(e))),r+i.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var ns={identify:t=>typeof t=="bigint"||Number.isInteger(t),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(t,e,{intAsBigInt:s})=>_s(t,s),stringify:Or},is={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:t=>_s(t,!1),stringify:Or},rt={identify:t=>t instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(t){let e=t.match(rt.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,s,r,n,i,o,a]=e.map(Number),c=e[7]?Number((e[7]+"00").substr(1,3)):0,u=Date.UTC(s,r-1,n,i||0,o||0,a||0,c),p=e[8];if(p&&p!=="Z"){let f=_s(p,!1);Math.abs(f)<30&&(f*=60),u-=6e4*f}return new Date(u)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};var Fs=[we,ve,Ue,We,Ts,Ls,$r,Ir,Ar,Nr,vr,Sr,kr,mt,be,yt,gt,wt,ns,is,rt];var Er=new Map([["core",gr],["failsafe",[we,ve,Ue]],["json",br],["yaml11",Fs],["yaml-1.1",Fs]]),Cr={binary:mt,bool:ht,float:zt,floatExp:Qt,floatNaN:Xt,floatTime:is,int:es,intHex:ts,intOct:xt,intTime:ns,map:we,merge:be,null:We,omap:yt,pairs:gt,seq:ve,set:wt,timestamp:rt},Pr={"tag:yaml.org,2002:binary":mt,"tag:yaml.org,2002:merge":be,"tag:yaml.org,2002:omap":yt,"tag:yaml.org,2002:pairs":gt,"tag:yaml.org,2002:set":wt,"tag:yaml.org,2002:timestamp":rt};function os(t,e,s){let r=Er.get(e);if(r&&!t)return s&&!r.includes(be)?r.concat(be):r.slice();let n=r;if(!n)if(Array.isArray(t))n=[];else{let i=Array.from(Er.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${i} or define customTags array`)}if(Array.isArray(t))for(let i of t)n=n.concat(i);else typeof t=="function"&&(n=t(n.slice()));return s&&(n=n.concat(be)),n.reduce((i,o)=>{let a=typeof o=="string"?Cr[o]:o;if(!a){let c=JSON.stringify(o),u=Object.keys(Cr).map(p=>JSON.stringify(p)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${u}`)}return i.includes(a)||i.push(a),i},[])}var Un=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,vt=class t{constructor({compat:e,customTags:s,merge:r,resolveKnownTags:n,schema:i,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?os(e,"compat"):e?os(null,e):null,this.name=typeof i=="string"&&i||"core",this.knownTags=n?Pr:{},this.tags=os(s,this.name,r),this.toStringOptions=a??null,Object.defineProperty(this,de,{value:we}),Object.defineProperty(this,ce,{value:Ue}),Object.defineProperty(this,Te,{value:ve}),this.sortMapEntries=typeof o=="function"?o:o===!0?Un:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};function Tr(t,e){let s=[],r=e.directives===!0;if(e.directives!==!1&&t.directives){let c=t.directives.toString(t);c?(s.push(c),r=!0):t.directives.docStart&&(r=!0)}r&&s.push("---");let n=Gt(t,e),{commentString:i}=n.options;if(t.commentBefore){s.length!==1&&s.unshift("");let c=i(t.commentBefore);s.unshift(fe(c,""))}let o=!1,a=null;if(t.contents){if(B(t.contents)){if(t.contents.spaceBefore&&r&&s.push(""),t.contents.commentBefore){let p=i(t.contents.commentBefore);s.push(fe(p,""))}n.forceBlockIndent=!!t.comment,a=t.contents.comment}let c=a?void 0:()=>o=!0,u=_e(t.contents,n,()=>a=null,c);a&&(u+=Oe(u,"",i(a))),(u[0]==="|"||u[0]===">")&&s[s.length-1]==="---"?s[s.length-1]=`--- ${u}`:s.push(u)}else s.push(_e(t.contents,n));if(t.directives?.docEnd)if(t.comment){let c=i(t.comment);c.includes(`
|
|
55
|
+
`)?(s.push("..."),s.push(fe(c,""))):s.push(`... ${c}`)}else s.push("...");else{let c=t.comment;c&&o&&(c=c.replace(/^\n+/,"")),c&&((!o||a)&&s[s.length-1]!==""&&s.push(""),s.push(fe(i(c),"")))}return s.join(`
|
|
56
56
|
`)+`
|
|
57
|
-
`}var
|
|
58
|
-
`),o=a+o}if(/[^ ]/.test(o)){let a=1,c=s.linePos[1];c?.line===r&&c.col>n&&(a=Math.max(1,Math.min(c.col-n,80-i)));let
|
|
57
|
+
`}var Fe=class t{constructor(e,s,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,ne,{value:Lt});let n=null;typeof s=="function"||Array.isArray(s)?n=s:r===void 0&&s&&(r=s,s=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},r);this.options=i;let{version:o}=i;r?._directives?(this.directives=r._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new Ne({version:o}),this.setSchema(o,r),this.contents=e===void 0?null:this.createNode(e,n,r)}clone(){let e=Object.create(t.prototype,{[ne]:{value:Lt}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=B(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){nt(this.contents)&&this.contents.add(e)}addIn(e,s){nt(this.contents)&&this.contents.addIn(e,s)}createAlias(e,s){if(!e.anchor){let r=Ss(this);e.anchor=!s||r.has(s)?ks(s||"a",r):s}return new Le(e.anchor)}createNode(e,s,r){let n;if(typeof s=="function")e=s.call({"":e},"",e),n=s;else if(Array.isArray(s)){let h=b=>typeof b=="number"||b instanceof String||b instanceof Number,v=s.filter(h).map(String);v.length>0&&(s=s.concat(v)),n=s}else r===void 0&&s&&(r=s,s=void 0);let{aliasDuplicateObjects:i,anchorPrefix:o,flow:a,keepUndefined:c,onTagObj:u,tag:p}=r??{},{onAnchor:f,setAnchors:l,sourceObjects:m}=lr(this,o||"a"),y={aliasDuplicateObjects:i??!0,keepUndefined:c??!1,onAnchor:f,onTagObj:u,replacer:n,schema:this.schema,sourceObjects:m},d=Re(e,p,y);return a&&G(d)&&(d.flow=!0),l(),d}createPair(e,s,r={}){let n=this.createNode(e,null,r),i=this.createNode(s,null,r);return new J(n,i)}delete(e){return nt(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Ze(e)?this.contents==null?!1:(this.contents=null,!0):nt(this.contents)?this.contents.deleteIn(e):!1}get(e,s){return G(this.contents)?this.contents.get(e,s):void 0}getIn(e,s){return Ze(e)?!s&&F(this.contents)?this.contents.value:this.contents:G(this.contents)?this.contents.getIn(e,s):void 0}has(e){return G(this.contents)?this.contents.has(e):!1}hasIn(e){return Ze(e)?this.contents!==void 0:G(this.contents)?this.contents.hasIn(e):!1}set(e,s){this.contents==null?this.contents=ut(this.schema,[e],s):nt(this.contents)&&this.contents.set(e,s)}setIn(e,s){Ze(e)?this.contents=s:this.contents==null?this.contents=ut(this.schema,Array.from(e),s):nt(this.contents)&&this.contents.setIn(e,s)}setSchema(e,s={}){typeof e=="number"&&(e=String(e));let r;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new Ne({version:"1.1"}),r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new Ne({version:e}),r={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,r=null;break;default:{let n=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${n}`)}}if(s.schema instanceof Object)this.schema=s.schema;else if(r)this.schema=new vt(Object.assign(r,s));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:s,mapAsMap:r,maxAliasCount:n,onAnchor:i,reviver:o}={}){let a={anchors:new Map,doc:this,keep:!e,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},c=z(this.contents,s??"",a);if(typeof i=="function")for(let{count:u,res:p}of a.anchors.values())i(p,u);return typeof o=="function"?De(o,{"":c},"",c):c}toJSON(e,s){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:s})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let s=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${s}`)}return Tr(this,e)}};function nt(t){if(G(t))return!0;throw new Error("Expected a YAML collection as document contents")}var St=class extends Error{constructor(e,s,r,n){super(),this.name=e,this.code=r,this.message=n,this.pos=s}},Se=class extends St{constructor(e,s,r){super("YAMLParseError",e,s,r)}},kt=class extends St{constructor(e,s,r){super("YAMLWarning",e,s,r)}},Ms=(t,e)=>s=>{if(s.pos[0]===-1)return;s.linePos=s.pos.map(a=>e.linePos(a));let{line:r,col:n}=s.linePos[0];s.message+=` at line ${r}, column ${n}`;let i=n-1,o=t.substring(e.lineStarts[r-1],e.lineStarts[r]).replace(/[\n\r]+$/,"");if(i>=60&&o.length>80){let a=Math.min(i-39,o.length-79);o="\u2026"+o.substring(a),i-=a-1}if(o.length>80&&(o=o.substring(0,79)+"\u2026"),r>1&&/^ *$/.test(o.substring(0,i))){let a=t.substring(e.lineStarts[r-2],e.lineStarts[r-1]);a.length>80&&(a=a.substring(0,79)+`\u2026
|
|
58
|
+
`),o=a+o}if(/[^ ]/.test(o)){let a=1,c=s.linePos[1];c?.line===r&&c.col>n&&(a=Math.max(1,Math.min(c.col-n,80-i)));let u=" ".repeat(i)+"^".repeat(a);s.message+=`:
|
|
59
59
|
|
|
60
60
|
${o}
|
|
61
|
-
${
|
|
62
|
-
`}};function Ee(t,{flow:e,indicator:s,next:r,offset:n,onError:i,parentIndent:o,startOnNewline:a}){let c=!1,
|
|
63
|
-
`))return!0;if(t.end){for(let e of t.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of t.items){for(let s of e.start)if(s.type==="newline")return!0;if(e.sep){for(let s of e.sep)if(s.type==="newline")return!0}if(
|
|
64
|
-
`+d.comment:a.comment=d.comment);continue}(d.newlineAfterProp||
|
|
65
|
-
`+S.comment:b.comment=S.comment);let $=new J(b);s.options.keepSourceTokens&&($.srcToken=p),a.items.push($)}}return
|
|
66
|
-
`+N.comment:
|
|
67
|
-
`+
|
|
68
|
-
`+
|
|
69
|
-
`+h.comment:
|
|
70
|
-
`.repeat(Math.max(1,o.length-1)):"",h=r+n.length;return e.source&&(h+=e.source.length),{value:d,type:i,comment:n.comment,range:[r,h,h]}}let c=e.indent+n.indent,
|
|
71
|
-
`;for(let d=p;d<a;++d){let[h,
|
|
72
|
-
`):h.length>c||
|
|
61
|
+
${u}
|
|
62
|
+
`}};function Ee(t,{flow:e,indicator:s,next:r,offset:n,onError:i,parentIndent:o,startOnNewline:a}){let c=!1,u=a,p=a,f="",l="",m=!1,y=!1,d=null,h=null,v=null,b=null,S=null,$=null,k=null;for(let I of t)switch(y&&(I.type!=="space"&&I.type!=="newline"&&I.type!=="comma"&&i(I.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),y=!1),d&&(u&&I.type!=="comment"&&I.type!=="newline"&&i(d,"TAB_AS_INDENT","Tabs are not allowed as indentation"),d=null),I.type){case"space":!e&&(s!=="doc-start"||r?.type!=="flow-collection")&&I.source.includes(" ")&&(d=I),p=!0;break;case"comment":{p||i(I,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let R=I.source.substring(1)||" ";f?f+=l+R:f=R,l="",u=!1;break}case"newline":u?f?f+=I.source:(!$||s!=="seq-item-ind")&&(c=!0):l+=I.source,u=!0,m=!0,(h||v)&&(b=I),p=!0;break;case"anchor":h&&i(I,"MULTIPLE_ANCHORS","A node can have at most one anchor"),I.source.endsWith(":")&&i(I.offset+I.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),h=I,k??(k=I.offset),u=!1,p=!1,y=!0;break;case"tag":{v&&i(I,"MULTIPLE_TAGS","A node can have at most one tag"),v=I,k??(k=I.offset),u=!1,p=!1,y=!0;break}case s:(h||v)&&i(I,"BAD_PROP_ORDER",`Anchors and tags must be after the ${I.source} indicator`),$&&i(I,"UNEXPECTED_TOKEN",`Unexpected ${I.source} in ${e??"collection"}`),$=I,u=s==="seq-item-ind"||s==="explicit-key-ind",p=!1;break;case"comma":if(e){S&&i(I,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),S=I,u=!1,p=!1;break}default:i(I,"UNEXPECTED_TOKEN",`Unexpected ${I.type} token`),u=!1,p=!1}let N=t[t.length-1],O=N?N.offset+N.source.length:n;return y&&r&&r.type!=="space"&&r.type!=="newline"&&r.type!=="comma"&&(r.type!=="scalar"||r.source!=="")&&i(r.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),d&&(u&&d.indent<=o||r?.type==="block-map"||r?.type==="block-seq")&&i(d,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:S,found:$,spaceBefore:c,comment:f,hasNewline:m,anchor:h,tag:v,newlineAfterProp:b,end:O,start:k??O}}function Ke(t){if(!t)return null;switch(t.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(t.source.includes(`
|
|
63
|
+
`))return!0;if(t.end){for(let e of t.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of t.items){for(let s of e.start)if(s.type==="newline")return!0;if(e.sep){for(let s of e.sep)if(s.type==="newline")return!0}if(Ke(e.key)||Ke(e.value))return!0}return!1;default:return!0}}function $t(t,e,s){if(e?.type==="flow-collection"){let r=e.end[0];r.indent===t&&(r.source==="]"||r.source==="}")&&Ke(e)&&s(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}function as(t,e,s){let{uniqueKeys:r}=t.options;if(r===!1)return!1;let n=typeof r=="function"?r:(i,o)=>i===o||F(i)&&F(o)&&i.value===o.value;return e.some(i=>n(i.key,s))}var Lr="All mapping items must start at the same column";function Rr({composeNode:t,composeEmptyNode:e},s,r,n,i){let o=i?.nodeClass??X,a=new o(s.schema);s.atRoot&&(s.atRoot=!1);let c=r.offset,u=null;for(let p of r.items){let{start:f,key:l,sep:m,value:y}=p,d=Ee(f,{indicator:"explicit-key-ind",next:l??m?.[0],offset:c,onError:n,parentIndent:r.indent,startOnNewline:!0}),h=!d.found;if(h){if(l&&(l.type==="block-seq"?n(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in l&&l.indent!==r.indent&&n(c,"BAD_INDENT",Lr)),!d.anchor&&!d.tag&&!m){u=d.end,d.comment&&(a.comment?a.comment+=`
|
|
64
|
+
`+d.comment:a.comment=d.comment);continue}(d.newlineAfterProp||Ke(l))&&n(l??f[f.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else d.found?.indent!==r.indent&&n(c,"BAD_INDENT",Lr);s.atKey=!0;let v=d.end,b=l?t(s,l,d,n):e(s,v,f,null,d,n);s.schema.compat&&$t(r.indent,l,n),s.atKey=!1,as(s,a.items,b)&&n(v,"DUPLICATE_KEY","Map keys must be unique");let S=Ee(m??[],{indicator:"map-value-ind",next:y,offset:b.range[2],onError:n,parentIndent:r.indent,startOnNewline:!l||l.type==="block-scalar"});if(c=S.end,S.found){h&&(y?.type==="block-map"&&!S.hasNewline&&n(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),s.options.strict&&d.start<S.found.offset-1024&&n(b.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let $=y?t(s,y,S,n):e(s,c,m,null,S,n);s.schema.compat&&$t(r.indent,y,n),c=$.range[2];let k=new J(b,$);s.options.keepSourceTokens&&(k.srcToken=p),a.items.push(k)}else{h&&n(b.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),S.comment&&(b.comment?b.comment+=`
|
|
65
|
+
`+S.comment:b.comment=S.comment);let $=new J(b);s.options.keepSourceTokens&&($.srcToken=p),a.items.push($)}}return u&&u<c&&n(u,"IMPOSSIBLE","Map comment with trailing content"),a.range=[r.offset,c,u??c],a}function _r({composeNode:t,composeEmptyNode:e},s,r,n,i){let o=i?.nodeClass??te,a=new o(s.schema);s.atRoot&&(s.atRoot=!1),s.atKey&&(s.atKey=!1);let c=r.offset,u=null;for(let{start:p,value:f}of r.items){let l=Ee(p,{indicator:"seq-item-ind",next:f,offset:c,onError:n,parentIndent:r.indent,startOnNewline:!0});if(!l.found)if(l.anchor||l.tag||f)f?.type==="block-seq"?n(l.end,"BAD_INDENT","All sequence items must start at the same column"):n(c,"MISSING_CHAR","Sequence item without - indicator");else{u=l.end,l.comment&&(a.comment=l.comment);continue}let m=f?t(s,f,l,n):e(s,l.end,p,null,l,n);s.schema.compat&&$t(r.indent,f,n),c=m.range[2],a.items.push(m)}return a.range=[r.offset,c,u??c],a}function Ce(t,e,s,r){let n="";if(t){let i=!1,o="";for(let a of t){let{source:c,type:u}=a;switch(u){case"space":i=!0;break;case"comment":{s&&!i&&r(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let p=c.substring(1)||" ";n?n+=o+p:n=p,o="";break}case"newline":n&&(o+=c),i=!0;break;default:r(a,"UNEXPECTED_TOKEN",`Unexpected ${u} at node end`)}e+=c.length}}return{comment:n,offset:e}}var Ds="Block collections are not allowed within flow collections",js=t=>t&&(t.type==="block-map"||t.type==="block-seq");function Fr({composeNode:t,composeEmptyNode:e},s,r,n,i){let o=r.start.source==="{",a=o?"flow map":"flow sequence",c=i?.nodeClass??(o?X:te),u=new c(s.schema);u.flow=!0;let p=s.atRoot;p&&(s.atRoot=!1),s.atKey&&(s.atKey=!1);let f=r.offset+r.start.source.length;for(let h=0;h<r.items.length;++h){let v=r.items[h],{start:b,key:S,sep:$,value:k}=v,N=Ee(b,{flow:a,indicator:"explicit-key-ind",next:S??$?.[0],offset:f,onError:n,parentIndent:r.indent,startOnNewline:!1});if(!N.found){if(!N.anchor&&!N.tag&&!$&&!k){h===0&&N.comma?n(N.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):h<r.items.length-1&&n(N.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),N.comment&&(u.comment?u.comment+=`
|
|
66
|
+
`+N.comment:u.comment=N.comment),f=N.end;continue}!o&&s.options.strict&&Ke(S)&&n(S,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(h===0)N.comma&&n(N.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(N.comma||n(N.start,"MISSING_CHAR",`Missing , between ${a} items`),N.comment){let O="";e:for(let I of b)switch(I.type){case"comma":case"space":break;case"comment":O=I.source.substring(1);break e;default:break e}if(O){let I=u.items[u.items.length-1];j(I)&&(I=I.value??I.key),I.comment?I.comment+=`
|
|
67
|
+
`+O:I.comment=O,N.comment=N.comment.substring(O.length+1)}}if(!o&&!$&&!N.found){let O=k?t(s,k,N,n):e(s,N.end,$,null,N,n);u.items.push(O),f=O.range[2],js(k)&&n(O.range,"BLOCK_IN_FLOW",Ds)}else{s.atKey=!0;let O=N.end,I=S?t(s,S,N,n):e(s,O,b,null,N,n);js(S)&&n(I.range,"BLOCK_IN_FLOW",Ds),s.atKey=!1;let R=Ee($??[],{flow:a,indicator:"map-value-ind",next:k,offset:I.range[2],onError:n,parentIndent:r.indent,startOnNewline:!1});if(R.found){if(!o&&!N.found&&s.options.strict){if($)for(let E of $){if(E===R.found)break;if(E.type==="newline"){n(E,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}N.start<R.found.offset-1024&&n(R.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else k&&("source"in k&&k.source?.[0]===":"?n(k,"MISSING_CHAR",`Missing space after : in ${a}`):n(R.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let U=k?t(s,k,R,n):R.found?e(s,R.end,$,null,R,n):null;U?js(k)&&n(U.range,"BLOCK_IN_FLOW",Ds):R.comment&&(I.comment?I.comment+=`
|
|
68
|
+
`+R.comment:I.comment=R.comment);let Z=new J(I,U);if(s.options.keepSourceTokens&&(Z.srcToken=v),o){let E=u;as(s,E.items,I)&&n(O,"DUPLICATE_KEY","Map keys must be unique"),E.items.push(Z)}else{let E=new X(s.schema);E.flow=!0,E.items.push(Z);let W=(U??I).range;E.range=[I.range[0],W[1],W[2]],u.items.push(E)}f=U?U.range[2]:R.end}}let l=o?"}":"]",[m,...y]=r.end,d=f;if(m?.source===l)d=m.offset+m.source.length;else{let h=a[0].toUpperCase()+a.substring(1),v=p?`${h} must end with a ${l}`:`${h} in block collection must be sufficiently indented and end with a ${l}`;n(f,p?"MISSING_CHAR":"BAD_INDENT",v),m&&m.source.length!==1&&y.unshift(m)}if(y.length>0){let h=Ce(y,d,s.options.strict,n);h.comment&&(u.comment?u.comment+=`
|
|
69
|
+
`+h.comment:u.comment=h.comment),u.range=[r.offset,d,h.offset]}else u.range=[r.offset,d,d];return u}function Bs(t,e,s,r,n,i){let o=s.type==="block-map"?Rr(t,e,s,r,i):s.type==="block-seq"?_r(t,e,s,r,i):Fr(t,e,s,r,i),a=o.constructor;return n==="!"||n===a.tagName?(o.tag=a.tagName,o):(n&&(o.tag=n),o)}function Mr(t,e,s,r,n){let i=r.tag,o=i?e.directives.tagName(i.source,l=>n(i,"TAG_RESOLVE_FAILED",l)):null;if(s.type==="block-seq"){let{anchor:l,newlineAfterProp:m}=r,y=l&&i?l.offset>i.offset?l:i:l??i;y&&(!m||m.offset<y.offset)&&n(y,"MISSING_CHAR","Missing newline after block sequence props")}let a=s.type==="block-map"?"map":s.type==="block-seq"?"seq":s.start.source==="{"?"map":"seq";if(!i||!o||o==="!"||o===X.tagName&&a==="map"||o===te.tagName&&a==="seq")return Bs(t,e,s,n,o);let c=e.schema.tags.find(l=>l.tag===o&&l.collection===a);if(!c){let l=e.schema.knownTags[o];if(l?.collection===a)e.schema.tags.push(Object.assign({},l,{default:!1})),c=l;else return l?n(i,"BAD_COLLECTION_TYPE",`${l.tag} used for ${a} collection, but expects ${l.collection??"scalar"}`,!0):n(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),Bs(t,e,s,n,o)}let u=Bs(t,e,s,n,o,c),p=c.resolve?.(u,l=>n(i,"TAG_RESOLVE_FAILED",l),e.options)??u,f=B(p)?p:new C(p);return f.range=u.range,f.tag=o,c?.format&&(f.format=c.format),f}function Us(t,e,s){let r=e.offset,n=Kn(e,t.options.strict,s);if(!n)return{value:"",type:null,comment:"",range:[r,r,r]};let i=n.mode===">"?C.BLOCK_FOLDED:C.BLOCK_LITERAL,o=e.source?Gn(e.source):[],a=o.length;for(let d=o.length-1;d>=0;--d){let h=o[d][1];if(h===""||h==="\r")a=d;else break}if(a===0){let d=n.chomp==="+"&&o.length>0?`
|
|
70
|
+
`.repeat(Math.max(1,o.length-1)):"",h=r+n.length;return e.source&&(h+=e.source.length),{value:d,type:i,comment:n.comment,range:[r,h,h]}}let c=e.indent+n.indent,u=e.offset+n.length,p=0;for(let d=0;d<a;++d){let[h,v]=o[d];if(v===""||v==="\r")n.indent===0&&h.length>c&&(c=h.length);else{h.length<c&&s(u+h.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),n.indent===0&&(c=h.length),p=d,c===0&&!t.atRoot&&s(u,"BAD_INDENT","Block scalar values in collections must be indented");break}u+=h.length+v.length+1}for(let d=o.length-1;d>=a;--d)o[d][0].length>c&&(a=d+1);let f="",l="",m=!1;for(let d=0;d<p;++d)f+=o[d][0].slice(c)+`
|
|
71
|
+
`;for(let d=p;d<a;++d){let[h,v]=o[d];u+=h.length+v.length+1;let b=v[v.length-1]==="\r";if(b&&(v=v.slice(0,-1)),v&&h.length<c){let $=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;s(u-v.length-(b?2:1),"BAD_INDENT",$),h=""}i===C.BLOCK_LITERAL?(f+=l+h.slice(c)+v,l=`
|
|
72
|
+
`):h.length>c||v[0]===" "?(l===" "?l=`
|
|
73
73
|
`:!m&&l===`
|
|
74
74
|
`&&(l=`
|
|
75
75
|
|
|
76
|
-
`),
|
|
77
|
-
`,m=!0):
|
|
78
|
-
`?
|
|
76
|
+
`),f+=l+h.slice(c)+v,l=`
|
|
77
|
+
`,m=!0):v===""?l===`
|
|
78
|
+
`?f+=`
|
|
79
79
|
`:l=`
|
|
80
|
-
`:(
|
|
81
|
-
`+o[d][0].slice(c);
|
|
82
|
-
`&&(
|
|
83
|
-
`);break;default:
|
|
84
|
-
`}let y=r+n.length+e.source.length;return{value:
|
|
80
|
+
`:(f+=l+v,l=" ",m=!1)}switch(n.chomp){case"-":break;case"+":for(let d=a;d<o.length;++d)f+=`
|
|
81
|
+
`+o[d][0].slice(c);f[f.length-1]!==`
|
|
82
|
+
`&&(f+=`
|
|
83
|
+
`);break;default:f+=`
|
|
84
|
+
`}let y=r+n.length+e.source.length;return{value:f,type:i,comment:n.comment,range:[r,y,y]}}function Kn({offset:t,props:e},s,r){if(e[0].type!=="block-scalar-header")return r(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:n}=e[0],i=n[0],o=0,a="",c=-1;for(let l=1;l<n.length;++l){let m=n[l];if(!a&&(m==="-"||m==="+"))a=m;else{let y=Number(m);!o&&y?o=y:c===-1&&(c=t+l)}}c!==-1&&r(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let u=!1,p="",f=n.length;for(let l=1;l<e.length;++l){let m=e[l];switch(m.type){case"space":u=!0;case"newline":f+=m.source.length;break;case"comment":s&&!u&&r(m,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),f+=m.source.length,p=m.source.substring(1);break;case"error":r(m,"UNEXPECTED_TOKEN",m.message),f+=m.source.length;break;default:{let y=`Unexpected token in block scalar header: ${m.type}`;r(m,"UNEXPECTED_TOKEN",y);let d=m.source;d&&typeof d=="string"&&(f+=d.length)}}}return{mode:i,indent:o,chomp:a,comment:p,length:f}}function Gn(t){let e=t.split(/\n( *)/),s=e[0],r=s.match(/^( *)/),i=[r?.[1]?[r[1],s.slice(r[1].length)]:["",s]];for(let o=1;o<e.length;o+=2)i.push([e[o],e[o+1]]);return i}function Ks(t,e,s){let{offset:r,type:n,source:i,end:o}=t,a,c,u=(l,m,y)=>s(r+l,m,y);switch(n){case"scalar":a=C.PLAIN,c=Vn(i,u);break;case"single-quoted-scalar":a=C.QUOTE_SINGLE,c=qn(i,u);break;case"double-quoted-scalar":a=C.QUOTE_DOUBLE,c=Wn(i,u);break;default:return s(t,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[r,r+i.length,r+i.length]}}let p=r+i.length,f=Ce(o,p,e,s);return{value:c,type:a,comment:f.comment,range:[r,p,f.offset]}}function Vn(t,e){let s="";switch(t[0]){case" ":s="a tab character";break;case",":s="flow indicator character ,";break;case"%":s="directive indicator character %";break;case"|":case">":{s=`block scalar indicator ${t[0]}`;break}case"@":case"`":{s=`reserved character ${t[0]}`;break}}return s&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${s}`),Dr(t)}function qn(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),Dr(t.slice(1,-1)).replace(/''/g,"'")}function Dr(t){let e=/(.*?)\r?\n/sy,s=e.exec(t);if(!s)return t;let r,n;try{r=new RegExp("(?<![ ])[ ]+$"),n=new RegExp("^[ ]+|(?<![ ])[ ]+$","g")}catch{r=/[ \t]+$/,n=/^[ \t]+|[ \t]+$/g}let i=s[1].replace(r,""),o=" ",a=e.lastIndex;for(;s=e.exec(t);){let u=s[1].replace(n,"");u===""?o===`
|
|
85
85
|
`?i+=o:o=`
|
|
86
|
-
`:(i+=o+
|
|
86
|
+
`:(i+=o+u,o=" "),a=e.lastIndex}let c=/[ \t]*(.*)/sy;return c.lastIndex=a,s=c.exec(t),i+o+(s?.[1]??"")}function Wn(t,e){let s="";for(let r=1;r<t.length-1;++r){let n=t[r];if(!(n==="\r"&&t[r+1]===`
|
|
87
87
|
`))if(n===`
|
|
88
|
-
`){let{fold:i,offset:o}=Hn(t,r);s+=i,r=o}else if(n==="\\"){let i=t[++r],o=
|
|
88
|
+
`){let{fold:i,offset:o}=Hn(t,r);s+=i,r=o}else if(n==="\\"){let i=t[++r],o=Yn[i];if(o)s+=o;else if(i===`
|
|
89
89
|
`)for(i=t[r+1];i===" "||i===" ";)i=t[++r+1];else if(i==="\r"&&t[r+1]===`
|
|
90
|
-
`)for(i=t[++r+1];i===" "||i===" ";)i=t[++r+1];else if(i==="x"||i==="u"||i==="U"){let a=i==="x"?2:i==="u"?4:8;s+=
|
|
90
|
+
`)for(i=t[++r+1];i===" "||i===" ";)i=t[++r+1];else if(i==="x"||i==="u"||i==="U"){let a=i==="x"?2:i==="u"?4:8;s+=Jn(t,r+1,a,e),r+=a}else{let a=t.substr(r-1,2);e(r-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),s+=a}}else if(n===" "||n===" "){let i=r,o=t[r+1];for(;o===" "||o===" ";)o=t[++r+1];o!==`
|
|
91
91
|
`&&!(o==="\r"&&t[r+2]===`
|
|
92
92
|
`)&&(s+=r>i?t.slice(i,r+1):n)}else s+=n}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),s}function Hn(t,e){let s="",r=t[e+1];for(;(r===" "||r===" "||r===`
|
|
93
93
|
`||r==="\r")&&!(r==="\r"&&t[e+2]!==`
|
|
94
94
|
`);)r===`
|
|
95
95
|
`&&(s+=`
|
|
96
|
-
`),e+=1,r=t[e+1];return s||(s=" "),{fold:s,offset:e}}var
|
|
97
|
-
`,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function
|
|
96
|
+
`),e+=1,r=t[e+1];return s||(s=" "),{fold:s,offset:e}}var Yn={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
|
|
97
|
+
`,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function Jn(t,e,s,r){let n=t.substr(e,s),o=n.length===s&&/^[0-9a-fA-F]+$/.test(n)?parseInt(n,16):NaN;try{return String.fromCodePoint(o)}catch{let a=t.substr(e-2,s+2);return r(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}function Gs(t,e,s,r){let{value:n,type:i,comment:o,range:a}=e.type==="block-scalar"?Us(t,e,r):Ks(e,t.options.strict,r),c=s?t.directives.tagName(s.source,f=>r(s,"TAG_RESOLVE_FAILED",f)):null,u;t.options.stringKeys&&t.atKey?u=t.schema[ce]:c?u=Xn(t.schema,n,c,s,r):e.type==="scalar"?u=Qn(t,n,e,r):u=t.schema[ce];let p;try{let f=u.resolve(n,l=>r(s??e,"TAG_RESOLVE_FAILED",l),t.options);p=F(f)?f:new C(f)}catch(f){let l=f instanceof Error?f.message:String(f);r(s??e,"TAG_RESOLVE_FAILED",l),p=new C(n)}return p.range=a,p.source=n,i&&(p.type=i),c&&(p.tag=c),u.format&&(p.format=u.format),o&&(p.comment=o),p}function Xn(t,e,s,r,n){if(s==="!")return t[ce];let i=[];for(let a of t.tags)if(!a.collection&&a.tag===s)if(a.default&&a.test)i.push(a);else return a;for(let a of i)if(a.test?.test(e))return a;let o=t.knownTags[s];return o&&!o.collection?(t.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(n(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${s}`,s!=="tag:yaml.org,2002:str"),t[ce])}function Qn({atKey:t,directives:e,schema:s},r,n,i){let o=s.tags.find(a=>(a.default===!0||t&&a.default==="key")&&a.test?.test(r))||s[ce];if(s.compat){let a=s.compat.find(c=>c.default&&c.test?.test(r))??s[ce];if(o.tag!==a.tag){let c=e.tagString(o.tag),u=e.tagString(a.tag),p=`Value may be parsed as either ${c} or ${u}`;i(n,"TAG_RESOLVE_FAILED",p,!0)}}return o}function jr(t,e,s){if(e){s??(s=e.length);for(let r=s-1;r>=0;--r){let n=e[r];switch(n.type){case"space":case"comment":case"newline":t-=n.source.length;continue}for(n=e[++r];n?.type==="space";)t+=n.source.length,n=e[++r];break}}return t}var zn={composeNode:Vs,composeEmptyNode:cs};function Vs(t,e,s,r){let n=t.atKey,{spaceBefore:i,comment:o,anchor:a,tag:c}=s,u,p=!0;switch(e.type){case"alias":u=Zn(t,e,r),(a||c)&&r(e,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":u=Gs(t,e,c,r),a&&(u.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{u=Mr(zn,t,e,s,r),a&&(u.anchor=a.source.substring(1))}catch(f){let l=f instanceof Error?f.message:String(f);r(e,"RESOURCE_EXHAUSTION",l)}break;default:{let f=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;r(e,"UNEXPECTED_TOKEN",f),p=!1}}return u??(u=cs(t,e.offset,void 0,null,s,r)),a&&u.anchor===""&&r(a,"BAD_ALIAS","Anchor cannot be an empty string"),n&&t.options.stringKeys&&(!F(u)||typeof u.value!="string"||u.tag&&u.tag!=="tag:yaml.org,2002:str")&&r(c??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),i&&(u.spaceBefore=!0),o&&(e.type==="scalar"&&e.source===""?u.comment=o:u.commentBefore=o),t.options.keepSourceTokens&&p&&(u.srcToken=e),u}function cs(t,e,s,r,{spaceBefore:n,comment:i,anchor:o,tag:a,end:c},u){let p={type:"scalar",offset:jr(e,s,r),indent:-1,source:""},f=Gs(t,p,a,u);return o&&(f.anchor=o.source.substring(1),f.anchor===""&&u(o,"BAD_ALIAS","Anchor cannot be an empty string")),n&&(f.spaceBefore=!0),i&&(f.comment=i,f.range[2]=c),f}function Zn({options:t},{offset:e,source:s,end:r},n){let i=new Le(s.substring(1));i.source===""&&n(e,"BAD_ALIAS","Alias cannot be an empty string"),i.source.endsWith(":")&&n(e+s.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=e+s.length,a=Ce(r,o,t.strict,n);return i.range=[e,o,a.offset],a.comment&&(i.comment=a.comment),i}function Br(t,e,{offset:s,start:r,value:n,end:i},o){let a=Object.assign({_directives:e},t),c=new Fe(void 0,a),u={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},p=Ee(r,{indicator:"doc-start",next:n??i?.[0],offset:s,onError:o,parentIndent:0,startOnNewline:!0});p.found&&(c.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!p.hasNewline&&o(p.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=n?Vs(u,n,p,o):cs(u,p.end,r,null,p,o);let f=c.contents.range[2],l=Ce(i,f,!1,o);return l.comment&&(c.comment=l.comment),c.range=[s,f,l.offset],c}function It(t){if(typeof t=="number")return[t,t+1];if(Array.isArray(t))return t.length===2?t:[t[0],t[1]];let{offset:e,source:s}=t;return[e,e+(typeof s=="string"?s.length:1)]}function Ur(t){let e="",s=!1,r=!1;for(let n=0;n<t.length;++n){let i=t[n];switch(i[0]){case"#":e+=(e===""?"":r?`
|
|
98
98
|
|
|
99
99
|
`:`
|
|
100
|
-
`)+(i.substring(1)||" "),s=!0,r=!1;break;case"%":t[n+1]?.[0]!=="#"&&(n+=1),s=!1;break;default:s||(r=!0),s=!1}}return{comment:e,afterEmptyLine:r}}var
|
|
101
|
-
${r}`:r;else if(n||e.directives.docStart||!i)e.commentBefore=r;else if(
|
|
100
|
+
`)+(i.substring(1)||" "),s=!0,r=!1;break;case"%":t[n+1]?.[0]!=="#"&&(n+=1),s=!1;break;default:s||(r=!0),s=!1}}return{comment:e,afterEmptyLine:r}}var At=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(s,r,n,i)=>{let o=It(s);i?this.warnings.push(new kt(o,r,n)):this.errors.push(new Se(o,r,n))},this.directives=new Ne({version:e.version||"1.2"}),this.options=e}decorate(e,s){let{comment:r,afterEmptyLine:n}=Ur(this.prelude);if(r){let i=e.contents;if(s)e.comment=e.comment?`${e.comment}
|
|
101
|
+
${r}`:r;else if(n||e.directives.docStart||!i)e.commentBefore=r;else if(G(i)&&!i.flow&&i.items.length>0){let o=i.items[0];j(o)&&(o=o.key);let a=o.commentBefore;o.commentBefore=a?`${r}
|
|
102
102
|
${a}`:r}else{let o=i.commentBefore;i.commentBefore=o?`${r}
|
|
103
|
-
${o}`:r}}if(s){for(let i=0;i<this.errors.length;++i)e.errors.push(this.errors[i]);for(let i=0;i<this.warnings.length;++i)e.warnings.push(this.warnings[i])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Ur(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,s=!1,r=-1){for(let n of e)yield*this.next(n);yield*this.end(s,r)}*next(e){switch(e.type){case"directive":this.directives.add(e.source,(s,r,n)=>{let i=
|
|
104
|
-
${s.comment}`:s.comment}this.doc.range[2]=s.offset;break}default:this.errors.push(new Se(
|
|
103
|
+
${o}`:r}}if(s){for(let i=0;i<this.errors.length;++i)e.errors.push(this.errors[i]);for(let i=0;i<this.warnings.length;++i)e.warnings.push(this.warnings[i])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Ur(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,s=!1,r=-1){for(let n of e)yield*this.next(n);yield*this.end(s,r)}*next(e){switch(e.type){case"directive":this.directives.add(e.source,(s,r,n)=>{let i=It(e);i[0]+=s,this.onError(i,"BAD_DIRECTIVE",r,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let s=Br(this.options,this.directives,e,this.onError);this.atDirectives&&!s.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(s,!1),this.doc&&(yield this.doc),this.doc=s,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let s=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,r=new Se(It(e),"UNEXPECTED_TOKEN",s);this.atDirectives||!this.doc?this.errors.push(r):this.doc.errors.push(r);break}case"doc-end":{if(!this.doc){let r="Unexpected doc-end without preceding document";this.errors.push(new Se(It(e),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let s=Ce(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),s.comment){let r=this.doc.comment;this.doc.comment=r?`${r}
|
|
104
|
+
${s.comment}`:s.comment}this.doc.range[2]=s.offset;break}default:this.errors.push(new Se(It(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,s=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let r=Object.assign({_directives:this.directives},this.options),n=new Fe(void 0,r);this.atDirectives&&this.onError(s,"MISSING_CHAR","Missing directives-end indicator line"),n.range=[0,s,s],this.decorate(n,!1),yield n}}};var qs=Symbol("break visit"),xn=Symbol("skip children"),Kr=Symbol("remove item");function He(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),Gr(Object.freeze([]),t,e)}He.BREAK=qs;He.SKIP=xn;He.REMOVE=Kr;He.itemAtPath=(t,e)=>{let s=t;for(let[r,n]of e){let i=s?.[r];if(i&&"items"in i)s=i.items[n];else return}return s};He.parentCollection=(t,e)=>{let s=He.itemAtPath(t,e.slice(0,-1)),r=e[e.length-1][0],n=s?.[r];if(n&&"items"in n)return n;throw new Error("Parent collection not found")};function Gr(t,e,s){let r=s(e,t);if(typeof r=="symbol")return r;for(let n of["key","value"]){let i=e[n];if(i&&"items"in i){for(let o=0;o<i.items.length;++o){let a=Gr(Object.freeze(t.concat([[n,o]])),i.items[o],s);if(typeof a=="number")o=a-1;else{if(a===qs)return qs;a===Kr&&(i.items.splice(o,1),o-=1)}}typeof r=="function"&&n==="key"&&(r=r(e,t))}}return typeof r=="function"?r(e,t):r}var Ws="\uFEFF",Hs="",Ys="",ls="";function Vr(t){switch(t){case Ws:return"byte-order-mark";case Hs:return"doc-mode";case Ys:return"flow-error-end";case ls:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
|
|
105
105
|
`:case`\r
|
|
106
|
-
`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(t[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}function
|
|
107
|
-
`:case"\r":case" ":return!0;default:return!1}}var
|
|
108
|
-
\r `),Js=t=>!t||
|
|
106
|
+
`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(t[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}function ke(t){switch(t){case void 0:case" ":case`
|
|
107
|
+
`:case"\r":case" ":return!0;default:return!1}}var qr=new Set("0123456789ABCDEFabcdef"),ti=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),us=new Set(",[]{}"),si=new Set(` ,[]{}
|
|
108
|
+
\r `),Js=t=>!t||si.has(t),Nt=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,s=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!s;let r=this.next??"stream";for(;r&&(s||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let e=this.pos,s=this.buffer[e];for(;s===" "||s===" ";)s=this.buffer[++e];return!s||s==="#"||s===`
|
|
109
109
|
`?!0:s==="\r"?this.buffer[e+1]===`
|
|
110
110
|
`:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let s=this.buffer[e];if(this.indentNext>0){let r=0;for(;s===" ";)s=this.buffer[++r+e];if(s==="\r"){let n=this.buffer[r+e+1];if(n===`
|
|
111
111
|
`||!n&&!this.atEnd)return e+r+1}return s===`
|
|
112
|
-
`||r>=this.indentNext||!s&&!this.atEnd?e+r:-1}if(s==="-"||s==="."){let r=this.buffer.substr(e,3);if((r==="---"||r==="...")&&
|
|
113
|
-
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===
|
|
112
|
+
`||r>=this.indentNext||!s&&!this.atEnd?e+r:-1}if(s==="-"||s==="."){let r=this.buffer.substr(e,3);if((r==="---"||r==="...")&&ke(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!="number"||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
|
|
113
|
+
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===Ws&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let s=e.length,r=e.indexOf("#");for(;r!==-1;){let i=e[r-1];if(i===" "||i===" "){s=r-1;break}else r=e.indexOf("#",r+1)}for(;;){let i=e[s-1];if(i===" "||i===" ")s-=1;else break}let n=(yield*this.pushCount(s))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let s=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-s),yield*this.pushNewline(),"stream"}return yield Hs,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let s=this.peek(3);if((s==="---"||s==="...")&&ke(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,s==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!ke(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,s]=this.peek(2);if(!s&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&ke(s)){let r=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=r,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let s=yield*this.pushIndicators();switch(e[s]){case"#":yield*this.pushCount(e.length-s);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(Js),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return s+=yield*this.parseBlockScalarHeader(),s+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-s),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,s,r=-1;do e=yield*this.pushNewline(),e>0?(s=yield*this.pushSpaces(!1),this.indentValue=r=s):s=0,s+=yield*this.pushSpaces(!0);while(e+s>0);let n=this.getLine();if(n===null)return this.setNext("flow");if((r!==-1&&r<this.indentNext&&n[0]!=="#"||r===0&&(n.startsWith("---")||n.startsWith("..."))&&ke(n[3]))&&!(r===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield Ys,yield*this.parseLineStart();let i=0;for(;n[i]===",";)i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(i+=yield*this.pushIndicators(),n[i]){case void 0:return"flow";case"#":return yield*this.pushCount(n.length-i),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(Js),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||ke(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),s=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;s!==-1&&this.buffer[s+1]==="'";)s=this.buffer.indexOf("'",s+2);else for(;s!==-1;){let i=0;for(;this.buffer[s-1-i]==="\\";)i+=1;if(i%2===0)break;s=this.buffer.indexOf('"',s+1)}let r=this.buffer.substring(0,s),n=r.indexOf(`
|
|
114
114
|
`,this.pos);if(n!==-1){for(;n!==-1;){let i=this.continueScalar(n+1);if(i===-1)break;n=r.indexOf(`
|
|
115
|
-
`,i)}n!==-1&&(s=n-(r[n-1]==="\r"?2:1))}if(s===-1){if(!this.atEnd)return this.setNext("quoted-scalar");s=this.buffer.length}return yield*this.pushToIndex(s+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let s=this.buffer[++e];if(s==="+")this.blockScalarKeep=!0;else if(s>"0"&&s<="9")this.blockScalarIndent=Number(s)-1;else if(s!=="-")break}return yield*this.pushUntil(s=>
|
|
115
|
+
`,i)}n!==-1&&(s=n-(r[n-1]==="\r"?2:1))}if(s===-1){if(!this.atEnd)return this.setNext("quoted-scalar");s=this.buffer.length}return yield*this.pushToIndex(s+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let s=this.buffer[++e];if(s==="+")this.blockScalarKeep=!0;else if(s>"0"&&s<="9")this.blockScalarIndent=Number(s)-1;else if(s!=="-")break}return yield*this.pushUntil(s=>ke(s)||s==="#")}*parseBlockScalar(){let e=this.pos-1,s=0,r;e:for(let i=this.pos;r=this.buffer[i];++i)switch(r){case" ":s+=1;break;case`
|
|
116
116
|
`:e=i,s=0;break;case"\r":{let o=this.buffer[i+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
|
|
117
117
|
`)break}default:break e}if(!r&&!this.atEnd)return this.setNext("block-scalar");if(s>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=s:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let i=this.continueScalar(e+1);if(i===-1)break;e=this.buffer.indexOf(`
|
|
118
118
|
`,i)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let n=e+1;for(r=this.buffer[n];r===" ";)r=this.buffer[++n];if(r===" "){for(;r===" "||r===" "||r==="\r"||r===`
|
|
119
119
|
`;)r=this.buffer[++n];e=n-1}else if(!this.blockScalarKeep)do{let i=e-1,o=this.buffer[i];o==="\r"&&(o=this.buffer[--i]);let a=i;for(;o===" ";)o=this.buffer[--i];if(o===`
|
|
120
|
-
`&&i>=this.pos&&i+1+s>a)e=i;else break}while(!0);return yield ls,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,s=this.pos-1,r=this.pos-1,n;for(;n=this.buffer[++r];)if(n===":"){let i=this.buffer[r+1];if(
|
|
120
|
+
`&&i>=this.pos&&i+1+s>a)e=i;else break}while(!0);return yield ls,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,s=this.pos-1,r=this.pos-1,n;for(;n=this.buffer[++r];)if(n===":"){let i=this.buffer[r+1];if(ke(i)||e&&us.has(i))break;s=r}else if(ke(n)){let i=this.buffer[r+1];if(n==="\r"&&(i===`
|
|
121
121
|
`?(r+=1,n=`
|
|
122
|
-
`,i=this.buffer[r+1]):s=r),i==="#"||e&&
|
|
123
|
-
`){let o=this.continueScalar(r+1);if(o===-1)break;r=Math.max(r,o-2)}}else{if(e&&
|
|
122
|
+
`,i=this.buffer[r+1]):s=r),i==="#"||e&&us.has(i))break;if(n===`
|
|
123
|
+
`){let o=this.continueScalar(r+1);if(o===-1)break;r=Math.max(r,o-2)}}else{if(e&&us.has(n))break;s=r}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield ls,yield*this.pushToIndex(s+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,s){let r=this.buffer.slice(this.pos,e);return r?(yield r,this.pos+=r.length,r.length):(s&&(yield""),0)}*pushIndicators(){let e=0;e:for(;;){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(Js),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let s=this.flowLevel>0,r=this.charAt(1);if(ke(r)||s&&us.has(r)){s?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,s=this.buffer[e];for(;!ke(s)&&s!==">";)s=this.buffer[++e];return yield*this.pushToIndex(s===">"?e+1:e,!1)}else{let e=this.pos+1,s=this.buffer[e];for(;s;)if(ti.has(s))s=this.buffer[++e];else if(s==="%"&&qr.has(this.buffer[e+1])&&qr.has(this.buffer[e+2]))s=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
|
|
124
124
|
`?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
|
|
125
|
-
`?yield*this.pushCount(2):0}*pushSpaces(e){let s=this.pos-1,r;do r=this.buffer[++s];while(r===" "||e&&r===" ");let n=s-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=s),n}*pushUntil(e){let s=this.pos,r=this.buffer[s];for(;!e(r);)r=this.buffer[++s];return yield*this.pushToIndex(s,!1)}};var
|
|
125
|
+
`?yield*this.pushCount(2):0}*pushSpaces(e){let s=this.pos-1,r;do r=this.buffer[++s];while(r===" "||e&&r===" ");let n=s-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=s),n}*pushUntil(e){let s=this.pos,r=this.buffer[s];for(;!e(r);)r=this.buffer[++s];return yield*this.pushToIndex(s,!1)}};var Ot=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let s=0,r=this.lineStarts.length;for(;s<r;){let i=s+r>>1;this.lineStarts[i]<e?s=i+1:r=i}if(this.lineStarts[s]===e)return{line:s+1,col:1};if(s===0)return{line:0,col:e};let n=this.lineStarts[s-1];return{line:s,col:e-n+1}}}};function Ge(t,e){for(let s=0;s<t.length;++s)if(t[s].type===e)return!0;return!1}function Wr(t){for(let e=0;e<t.length;++e)switch(t[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function Yr(t){switch(t?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function fs(t){switch(t.type){case"document":return t.start;case"block-map":{let e=t.items[t.items.length-1];return e.sep??e.start}case"block-seq":return t.items[t.items.length-1].start;default:return[]}}function it(t){if(t.length===0)return[];let e=t.length;e:for(;--e>=0;)switch(t[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;t[++e]?.type==="space";);return t.splice(e,t.length)}function ps(t,e){if(e.length<1e5)Array.prototype.push.apply(t,e);else for(let s=0;s<e.length;++s)t.push(e[s])}function Hr(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!Ge(e.start,"explicit-key-ind")&&!Ge(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Yr(e.value)?e.value.end?ps(e.value.end,e.sep):e.value.end=e.sep:ps(e.start,e.sep),delete e.sep)}var Et=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new Nt,this.onNewLine=e}*parse(e,s=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let r of this.lexer.lex(e,s))yield*this.next(r);s||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let s=Vr(e);if(s)if(s==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=s,yield*this.step(),s){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let r=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:r,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let s=e??this.stack.pop();if(!s)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield s;else{let r=this.peek(1);switch(s.type==="block-scalar"?s.indent="indent"in r?r.indent:0:s.type==="flow-collection"&&r.type==="document"&&(s.indent=0),s.type==="flow-collection"&&Hr(s),r.type){case"document":r.value=s;break;case"block-scalar":r.props.push(s);break;case"block-map":{let n=r.items[r.items.length-1];if(n.value){r.items.push({start:[],key:s,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=s;else{Object.assign(n,{key:s,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case"block-seq":{let n=r.items[r.items.length-1];n.value?r.items.push({start:[],value:s}):n.value=s;break}case"flow-collection":{let n=r.items[r.items.length-1];!n||n.value?r.items.push({start:[],key:s,sep:[]}):n.sep?n.value=s:Object.assign(n,{key:s,sep:[]});return}default:yield*this.pop(),yield*this.pop(s)}if((r.type==="document"||r.type==="block-map"||r.type==="block-seq")&&(s.type==="block-map"||s.type==="block-seq")){let n=s.items[s.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&Wr(n.start)===-1&&(s.indent===0||n.start.every(i=>i.type!=="comment"||i.indent<s.indent))&&(r.type==="document"?r.end=n.start:r.items.push({start:n.start}),s.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{Wr(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let s=this.startBlockValue(e);s?this.stack.push(s):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let s=fs(this.peek(2)),r=it(s),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let i={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let s=this.source.indexOf(`
|
|
126
126
|
`)+1;for(;s!==0;)this.onNewLine(this.offset+s),s=this.source.indexOf(`
|
|
127
|
-
`,s)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let s=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,s.value){let r="end"in s.value?s.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else s.sep?s.sep.push(this.sourceToken):s.start.push(this.sourceToken);return;case"space":case"comment":if(s.value)e.items.push({start:[this.sourceToken]});else if(s.sep)s.sep.push(this.sourceToken);else{if(this.atIndentedComment(s.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){ps(n,s.start),n.push(this.sourceToken),e.items.pop();return}}s.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let r=!this.onKeyLine&&this.indent===e.indent,n=r&&(s.sep||s.explicitKey)&&this.type!=="seq-item-ind",i=[];if(n&&s.sep&&!s.value){let o=[];for(let a=0;a<s.sep.length;++a){let c=s.sep[a];switch(c.type){case"newline":o.push(a);break;case"space":break;case"comment":c.indent>e.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(i=s.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":n||s.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):s.sep?s.sep.push(this.sourceToken):s.start.push(this.sourceToken);return;case"explicit-key-ind":!s.sep&&!s.explicitKey?(s.start.push(this.sourceToken),s.explicitKey=!0):n||s.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(s.explicitKey)if(s.sep)if(s.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(
|
|
127
|
+
`,s)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let s=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,s.value){let r="end"in s.value?s.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else s.sep?s.sep.push(this.sourceToken):s.start.push(this.sourceToken);return;case"space":case"comment":if(s.value)e.items.push({start:[this.sourceToken]});else if(s.sep)s.sep.push(this.sourceToken);else{if(this.atIndentedComment(s.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){ps(n,s.start),n.push(this.sourceToken),e.items.pop();return}}s.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let r=!this.onKeyLine&&this.indent===e.indent,n=r&&(s.sep||s.explicitKey)&&this.type!=="seq-item-ind",i=[];if(n&&s.sep&&!s.value){let o=[];for(let a=0;a<s.sep.length;++a){let c=s.sep[a];switch(c.type){case"newline":o.push(a);break;case"space":break;case"comment":c.indent>e.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(i=s.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":n||s.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):s.sep?s.sep.push(this.sourceToken):s.start.push(this.sourceToken);return;case"explicit-key-ind":!s.sep&&!s.explicitKey?(s.start.push(this.sourceToken),s.explicitKey=!0):n||s.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(s.explicitKey)if(s.sep)if(s.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Ge(s.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(Yr(s.key)&&!Ge(s.sep,"newline")){let o=it(s.start),a=s.key,c=s.sep;c.push(this.sourceToken),delete s.key,delete s.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:a,sep:c}]})}else i.length>0?s.sep=s.sep.concat(i,this.sourceToken):s.sep.push(this.sourceToken);else if(Ge(s.start,"newline"))Object.assign(s,{key:null,sep:[this.sourceToken]});else{let o=it(s.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else s.sep?s.value||n?e.items.push({start:i,key:null,sep:[this.sourceToken]}):Ge(s.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):s.sep.push(this.sourceToken):Object.assign(s,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);n||s.value?(e.items.push({start:i,key:o,sep:[]}),this.onKeyLine=!0):s.sep?this.stack.push(o):(Object.assign(s,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{let o=this.startBlockValue(e);if(o){if(o.type==="block-seq"){if(!s.explicitKey&&s.sep&&!Ge(s.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else r&&e.items.push({start:i});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let s=e.items[e.items.length-1];switch(this.type){case"newline":if(s.value){let r="end"in s.value?s.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else s.start.push(this.sourceToken);return;case"space":case"comment":if(s.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(s.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){ps(n,s.start),n.push(this.sourceToken),e.items.pop();return}}s.start.push(this.sourceToken)}return;case"anchor":case"tag":if(s.value||this.indent<=e.indent)break;s.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;s.value||Ge(s.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):s.start.push(this.sourceToken);return}if(this.indent>e.indent){let r=this.startBlockValue(e);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let s=e.items[e.items.length-1];if(this.type==="flow-error-end"){let r;do yield*this.pop(),r=this.peek(1);while(r?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!s||s.sep?e.items.push({start:[this.sourceToken]}):s.start.push(this.sourceToken);return;case"map-value-ind":!s||s.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):s.sep?s.sep.push(this.sourceToken):Object.assign(s,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!s||s.value?e.items.push({start:[this.sourceToken]}):s.sep?s.sep.push(this.sourceToken):s.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let n=this.flowScalar(this.type);!s||s.value?e.items.push({start:[],key:n,sep:[]}):s.sep?this.stack.push(n):Object.assign(s,{key:n,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let r=this.startBlockValue(e);r?this.stack.push(r):(yield*this.pop(),yield*this.step())}else{let r=this.peek(2);if(r.type==="block-map"&&(this.type==="map-value-ind"&&r.indent===e.indent||this.type==="newline"&&!r.items[r.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&r.type!=="flow-collection"){let n=fs(r),i=it(n);Hr(e);let o=e.end.splice(1,e.end.length);o.push(this.sourceToken);let a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:i,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let s=this.source.indexOf(`
|
|
128
128
|
`)+1;for(;s!==0;)this.onNewLine(this.offset+s),s=this.source.indexOf(`
|
|
129
|
-
`,s)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let s=us(e),r=it(s);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let s=us(e),r=it(s);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,s){return this.type!=="comment"||this.indent<=s?!1:e.every(r=>r.type==="newline"||r.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};function si(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new At||null,prettyErrors:e}}function Jr(t,e={}){let{lineCounter:s,prettyErrors:r}=si(e),n=new Et(s?.addNewLine),i=new It(e),o=null;for(let a of i.compose(n.parse(t),!0,t.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new Se(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&s&&(o.errors.forEach(js(t,s)),o.warnings.forEach(js(t,s))),o}function Qs(t,e,s){let r;typeof e=="function"?r=e:s===void 0&&e&&typeof e=="object"&&(s=e);let n=Jr(t,s);if(!n)return null;if(n.warnings.forEach(i=>Vt(n.options.logLevel,i)),n.errors.length>0){if(n.options.logLevel!=="silent")throw n.errors[0];n.errors=[]}return n.toJS(Object.assign({reviver:r},s))}function zs(t,e,s){let r=null;if(typeof e=="function"||Array.isArray(e)?r=e:s===void 0&&e&&(s=e),typeof s=="string"&&(s=s.length),typeof s=="number"){let n=Math.round(s);s=n<1?void 0:n>8?{indent:8}:{indent:n}}if(t===void 0){let{keepUndefined:n}=s??e??{};if(!n)return}return me(t)&&!r?t.toString(s):new Me(t,r,s).toString(s)}function sn(t){switch(t){case"ss":return"SS";case"ssr":return"SSR";case"vmess":return"VMess";case"vless":return"VLESS";case"trojan":return"Trojan";case"snell":return"Snell";case"http":return"HTTP";case"https":return"HTTPS";case"socks5":return"SOCKS5";case"wireguard":return"WireGuard";case"hysteria":return"Hysteria";case"hysteria2":return"Hysteria2";case"tuic":return"TUIC";case"anytls":return"AnyTLS";default:return"Unknown"}}var L={anytls:"AnyTLSProvider",http:"HTTPProvider",hysteria:"HysteriaProvider",hysteria2:"Hysteria2Provider",snell:"SnellProvider",socks:"SocksProvider",ss:"SSProvider",ssr:"SSRProvider",trojan:"TrojanProvider",tuic:"TUICProvider",v2ray:"V2RayProvider",wireguard:"WireGuardProvider"};function pe(){return{allowedIps:"0.0.0.0/0, ::/0",allowInsecure:void 0,alpn:[],alterId:0,authStr:"",ca:"",caStr:"",clientId:"",congestionControl:"",cwnd:0,disableMtuDiscovery:void 0,dnsServers:[],down:"",downSpeed:0,edge:"",encryptMethod:"",fakeType:"",fingerprint:"",flow:"",group:"",groupId:0,hopInterval:0,host:"",hostname:"",id:0,keepAlive:0,mtu:0,obfs:"",obfsParam:"",password:"",path:"",plugin:"",pluginOption:"",port:0,ports:"",preSharedKey:"",privateKey:"",protocol:"",protocolParam:"",publicKey:"",quicSecret:"",quicSecure:"",recvWindow:0,recvWindowConn:0,remark:"",selfIp:"",selfIpv6:"",serverName:"",snellVersion:0,sni:"",tcpFastOpen:void 0,testUrl:"",tls13:void 0,tlsSecure:!1,transferProtocol:"",type:"unknown",udp:void 0,underlyingProxy:"",up:"",upSpeed:0,userId:"",username:""}}var rn=(t=>(t.Clash="clash",t.ClashR="clashr",t.Surge="surge",t.QuantumultX="quanx",t.Quantumult="quan",t.Loon="loon",t.Mellow="mellow",t.V2Ray="v2ray",t.Trojan="trojan",t.SSD="ssd",t.SSC="ss",t.SSR="ssr",t.SingBox="singbox",t.Mixed="mixed",t.NodeList="nodelist",t.Auto="auto",t))(rn||{});function nn(){return{addEmoji:!1,appendProxyType:!1,authorized:!1,clashClassicalRuleset:!1,clashNewFieldName:!1,clashProxiesStyle:"flow",clashProxyGroupsStyle:"flow",clashScript:!1,dedupe:!1,emojiArray:[],enableRuleGenerator:!0,filterDeprecated:!1,managedConfigPrefix:"",nodeList:!1,overwriteOriginalRules:!0,quanxDevId:"",removeEmoji:!1,renameArray:[],skipCertVerify:void 0,sortFlag:!1,sortScript:"",surgeSsrPath:"",tfo:void 0,tls13:void 0,udp:void 0}}var Zs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var hs={};for(let t=0;t<Zs.length;t+=1)hs[Zs[t]]=t;hs["-"]=62;hs._=63;function ni(t){return new TextEncoder().encode(t)}function ii(t){return new TextDecoder("utf-8",{fatal:!1}).decode(t)}function oi(t,e){let s=ni(t),r="";for(let n=0;n<s.length;n+=3){let i=s[n],o=n+1<s.length?s[n+1]:0,a=n+2<s.length?s[n+2]:0,c=i<<16|o<<8|a;r+=e[c>>18&63],r+=e[c>>12&63],r+=n+1<s.length?e[c>>6&63]:"=",r+=n+2<s.length?e[c&63]:"="}return r}function ai(t){let s=t.replace(/\s+/g,"").replace(/=+$/,""),r=[],n=0,i=0;for(let o of s){let a=hs[o];a!==void 0&&(n=n<<6|a,i+=6,i>=8&&(i-=8,r.push(n>>i&255)))}return Uint8Array.from(r)}function on(t){return oi(t,Zs)}function an(t){return ii(ai(t))}function re(t){return an(t)}function T(t){return t.replace(/^\s+|\s+$/g,"")}function Y(t){if(t==null)return 0;if(typeof t=="number")return Number.isFinite(t)?Math.trunc(t):0;let e=/[+-]?\d+/.exec(t);if(!e)return 0;let s=Number.parseInt(e[0],10);return Number.isNaN(s)?0:s}function ie(t,e){return t.startsWith(e)}function Qr(t,e){if(e==="")return 0;let s=0,r=t.indexOf(e);for(;r!==-1;)s+=1,r=t.indexOf(e,r+e.length);return s}function z(t,e,s=!1){let r=t.split(e);return s?r.filter(n=>n!==""):r}function cn(t){let e=t.split(".");return e.length!==4?!1:e.every(s=>/^\d{1,3}$/.test(s)&&Number(s)<=255)}function ln(t){return/^\[?[0-9A-Fa-f:]{2,}\]?$/.test(t)&&t.includes(":")}function W(t){try{return decodeURIComponent(t)}catch{return t.replace(/%([0-9A-Fa-f]{2})/g,(e,s)=>String.fromCharCode(Number.parseInt(s,16)))}}function I(t,e){if(t==="")return"";let r=(t.startsWith("?")?t.slice(1):t).split("&"),n="",i=e.toLowerCase();for(let o of r){if(o==="")continue;let a=o.indexOf("=");if((a>=0?o.slice(0,a):o).toLowerCase()!==i)continue;let f=a>=0?o.slice(a+1):"";n=W(f)}return n.trim()}function ci(t){let e=0xcbf29ce484222325n,s=0x100000001b3n;for(let r of t)e^=BigInt(r.codePointAt(0)),e=BigInt.asUintN(64,e*s);return e}function li(t){return ci(t).toString(16)}var Hu=new Set(Object.values(rn));var fi=["2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm","2022-blake3-chacha20-poly1305","2022-blake3-chacha12-poly1305","2022-blake3-chacha8-poly1305","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","chacha20","chacha20-ietf","chacha20-ietf-poly1305","rc4-md5","salsa20","xchacha20-ietf-poly1305"];function ui(t){return fi.includes(t.toLowerCase())}function ms(t,e,s){return ui(t)&&(e===""||e==="plain")&&(s===""||s==="origin")}function fe(t,e,s,r,n,i,o,a,c,f,p){t.type=e,t.group=s,t.remark=r,t.hostname=n,t.underlyingProxy=p,t.port=Y(i),t.udp=o,t.tcpFastOpen=a,t.allowInsecure=c,t.tls13=f}function $e(t,e){let{add:s,aid:r=0,cipher:n="",edge:i="",group:o,host:a="",id:c="",net:f="",path:p="",port:u,remark:l,scv:m,sni:y="",tfo:d,tls:h="",tls13:k,type:b="",udp:S,underlyingProxy:$=""}=e;fe(t,"vmess",o,l,s,u,S,d,m,k,$),t.userId=c===""?"00000000-0000-0000-0000-000000000000":c,t.alterId=Y(r),t.encryptMethod=n,t.transferProtocol=f===""?"tcp":f,t.edge=i,t.serverName=y,f==="quic"?(t.quicSecure=a,t.quicSecret=p):(t.host=a===""&&!cn(s)&&!ln(s)?s:T(a),t.path=p===""?"/":T(p)),t.fakeType=b,t.tlsSecure=h==="tls"}function Ye(t,e){fe(t,"ssr",e.group,e.remark,e.server,e.port,e.udp,e.tfo,e.scv,void 0,e.underlyingProxy??""),t.password=e.password,t.encryptMethod=e.method,t.protocol=e.protocol,t.protocolParam=e.protocolParam??"",t.obfs=e.obfs,t.obfsParam=e.obfsParam??""}function ae(t,e){fe(t,"ss",e.group,e.remark,e.server,e.port,e.udp,e.tfo,e.scv,e.tls13,e.underlyingProxy??""),t.password=e.password,t.encryptMethod=e.method,t.plugin=e.plugin??"",t.pluginOption=e.pluginOption??""}function ot(t,e){fe(t,"socks5",e.group,e.remark,e.server,e.port,e.udp,e.tfo,e.scv,void 0,e.underlyingProxy??""),t.username=e.username??"",t.password=e.password??""}function at(t,e){fe(t,e.tls?"https":"http",e.group,e.remark,e.server,e.port,void 0,e.tfo,e.scv,e.tls13,e.underlyingProxy??""),t.username=e.username??"",t.password=e.password??"",t.tlsSecure=e.tls}function Pt(t,e){fe(t,"trojan",e.group,e.remark,e.server,e.port,e.udp,e.tfo,e.scv,e.tls13,e.underlyingProxy??""),t.password=e.password,t.host=e.host??"",t.tlsSecure=e.tlsSecure??!0,t.transferProtocol=e.network===void 0||e.network===""?"tcp":e.network,t.path=e.path??"",t.serverName=e.sni??""}function tr(t,e){fe(t,"snell",e.group,e.remark,e.server,e.port,e.udp,e.tfo,e.scv,void 0,e.underlyingProxy??""),t.password=e.password,t.obfs=e.obfs??"",t.host=e.host??"",t.snellVersion=e.version??0}function gs(t,e){fe(t,"anytls",e.group,e.remark,e.server,e.port,e.udp,e.tfo,e.scv,void 0,e.underlyingProxy??""),t.tlsSecure=!0,t.password=e.password,t.sni=e.sni??""}function fn(t,e){fe(t,"wireguard",e.group,e.remark,e.server,e.port,e.udp,void 0,void 0,void 0,e.underlyingProxy??""),t.selfIp=e.selfIp??"",t.selfIpv6=e.selfIpv6??"",t.privateKey=e.privateKey??"",t.publicKey=e.publicKey??"",t.preSharedKey=e.preSharedKey??"",t.dnsServers=e.dnsServers??[],t.mtu=Y(e.mtu),t.keepAlive=Y(e.keepAlive),t.testUrl=e.testUrl??"",t.clientId=e.clientId??""}function pi(t,e){fe(t,"hysteria",e.group,e.remark,e.server,e.port,void 0,e.tfo,e.scv,void 0,e.underlyingProxy??""),t.ports=e.ports??"",t.protocol=e.protocol??"",t.obfsParam=e.obfsProtocol??"";let s=e.up??"";s!==""&&(s.length>4&&s.endsWith("bps")?t.up=s:Y(s)&&(t.upSpeed=Y(s),t.up=`${s} Mbps`)),e.upSpeed&&(t.upSpeed=Y(e.upSpeed));let r=e.down??"";r!==""&&(r.length>4&&r.endsWith("bps")?t.down=r:Y(r)&&(t.downSpeed=Y(r),t.down=`${r} Mbps`)),e.downSpeed&&(t.downSpeed=Y(e.downSpeed)),t.authStr=e.authStr??"",e.auth&&(t.authStr=an(e.auth)),t.tlsSecure=!0,t.obfs=e.obfs??"",t.sni=e.sni??"",t.fingerprint=e.fingerprint??"",t.ca=e.ca??"",t.caStr=e.caStr??"",t.recvWindowConn=Y(e.recvWindowConn),t.recvWindow=Y(e.recvWindow),t.disableMtuDiscovery=e.disableMtuDiscovery?e.disableMtuDiscovery==="true":void 0,t.hopInterval=Y(e.hopInterval),e.alpn&&(t.alpn=[e.alpn])}function un(t,e){fe(t,"hysteria2",e.group,e.remark,e.server,e.port,void 0,e.tfo,e.scv,void 0,e.underlyingProxy??""),t.tlsSecure=!0,t.upSpeed=Y(e.up),t.downSpeed=Y(e.down),t.ports=e.ports??"",t.password=e.password??"",t.obfs=e.obfs??"",t.obfsParam=e.obfsPassword??"",t.sni=e.sni??"",t.fingerprint=e.fingerprint??"",e.alpn&&(t.alpn=[e.alpn]),t.ca=e.ca??"",t.caStr=e.caStr??"",t.cwnd=Y(e.cwnd),t.hopInterval=Y(e.hopInterval)}function pn(t,e){fe(t,"vless",e.group,e.remark,e.server,e.port,e.udp,e.tfo,e.scv,void 0,e.underlyingProxy??""),t.userId=e.userId,t.flow=e.flow??"",t.encryptMethod=e.encryption??"none",t.transferProtocol=e.network===void 0||e.network===""?"tcp":e.network,t.tlsSecure=e.tls==="tls"||e.tls==="reality",t.serverName=e.sni??"",t.host=e.host??"",t.path=e.path??"",t.fingerprint=e.fingerprint??"",e.alpn&&(t.alpn=e.alpn)}function dn(t,e){fe(t,"tuic",e.group,e.remark,e.server,e.port,e.udp,e.tfo,e.scv,void 0,e.underlyingProxy??""),t.tlsSecure=!0,t.userId=e.userId,t.password=e.password,t.congestionControl=e.congestionControl??"",t.serverName=e.sni??"",e.alpn&&(t.alpn=e.alpn)}function Xs(t){if(!(t==null||t===""))return String(t).toLowerCase()==="true"}function F(t){return t==null?"":String(t)}function hn(t,e){let s;try{s=JSON.parse(re(t.slice(8)))}catch{return}if(s===null||typeof s!="object")return;let r=F(s.Type),n=F(s.Group),i=F(s.Remark),o=F(s.Hostname),a=Xs(s.EnableUDP),c=Xs(s.EnableTFO),f=Xs(s.AllowInsecure),p=F(s.Port);if(p==="0"||p==="")return;let u=F(s.EncryptMethod),l=F(s.Password);switch(i===""&&(i=`${o}:${p}`),r){case"SS":ae(e,{group:n===""?L.ss:n,method:u,password:l,plugin:F(s.Plugin),pluginOption:F(s.PluginOption),port:p,remark:i,scv:f,server:o,tfo:c,udp:a});break;case"SSR":{let m=F(s.Protocol),y=F(s.OBFS);ms(u,y,m)?ae(e,{group:n===""?L.ss:n,method:u,password:l,plugin:F(s.Plugin),pluginOption:F(s.PluginOption),port:p,remark:i,scv:f,server:o,tfo:c,udp:a}):Ye(e,{group:n===""?L.ssr:n,method:u,obfs:y,obfsParam:F(s.OBFSParam),password:l,port:p,protocol:m,protocolParam:F(s.ProtocolParam),remark:i,scv:f,server:o,tfo:c,udp:a});break}case"VMess":$e(e,{add:o,aid:F(s.AlterID),cipher:u,edge:F(s.Edge),group:n===""?L.v2ray:n,host:F(s.Host),id:F(s.UserID),net:F(s.TransferProtocol),path:F(s.Path),port:p,remark:i,scv:f,sni:F(s.ServerName),tfo:c,tls:F(s.TLSSecure),type:F(s.FakeType),udp:a});break;case"Socks5":ot(e,{group:n===""?L.socks:n,password:l,port:p,remark:i,scv:f,server:o,tfo:c,udp:a,username:F(s.Username)});break;case"HTTP":case"HTTPS":at(e,{group:n===""?L.http:n,password:l,port:p,remark:i,scv:f,server:o,tfo:c,tls:r==="HTTPS"});break;case"Trojan":Pt(e,{group:n===""?L.trojan:n,host:F(s.Host),network:F(s.TransferProtocol),password:l,path:F(s.Path),port:p,remark:i,scv:f,server:o,tfo:c,tlsSecure:F(s.TLSSecure)==="true",udp:a});break;case"Snell":tr(e,{group:n===""?L.snell:n,host:F(s.Host),obfs:F(s.OBFS),password:l,port:p,remark:i,scv:f,server:o,tfo:c,udp:a,version:Y(F(s.SnellVersion))});break;default:break}}function g(t){return t==null?"":String(t)}function ds(t){return typeof t=="boolean"?t:g(t).toLowerCase()==="true"}function G(t){if(!(t==null||t===""))return ds(t)}function w(t,e){return t!==null&&typeof t=="object"?t[e]:void 0}function di(t,e){let s=w(t,"proxies")!==void 0?"proxies":"Proxy",r=w(t,s);if(!Array.isArray(r))return;let n=e.length;for(let i of r){let o=g(w(i,"type")).toLowerCase(),a=g(w(i,"name")),c=g(w(i,"server")),f=g(w(i,"port")),p=g(w(i,"underlying-proxy"));if(p===""&&(p=g(w(i,"dialer-proxy"))),f===""||f==="0")continue;let u=G(w(i,"udp")),l=G(w(i,"fast-open")),m=G(w(i,"skip-cert-verify")),y=pe(),d="";switch(o){case"vmess":{d=L.v2ray;let h=g(w(i,"uuid")),k=g(w(i,"alterId")),b=g(w(i,"cipher")),S=w(i,"network")!==void 0?g(w(i,"network")):"tcp",$=g(w(i,"servername")),v="",N="",A="";switch(S){case"http":v=g(w(w(w(i,"http-opts"),"path"),0)),N=g(w(w(w(w(i,"http-opts"),"headers"),"Host"),0)),A="";break;case"ws":if(w(i,"ws-opts")!==void 0){let _=w(i,"ws-opts");v=w(_,"path")!==void 0?g(w(_,"path")):"/",N=g(w(w(_,"headers"),"Host")),A=g(w(w(_,"headers"),"Edge"))}else v=w(i,"ws-path")!==void 0?g(w(i,"ws-path")):"/",N=g(w(w(i,"ws-headers"),"Host")),A=g(w(w(i,"ws-headers"),"Edge"));break;case"h2":v=g(w(w(i,"h2-opts"),"path")),N=g(w(w(w(i,"h2-opts"),"host"),0)),A="";break;case"grpc":N=g(w(i,"servername")),v=g(w(w(i,"grpc-opts"),"grpc-service-name")),A="";break;default:break}let O=ds(w(i,"tls"))?"tls":"";$e(y,{add:c,aid:k,cipher:b,edge:A,group:d,host:N,id:h,net:S,path:v,port:f,remark:a,scv:m,sni:$,tfo:l,tls:O,type:"",udp:u,underlyingProxy:p});break}case"ss":{d=L.ss;let h=g(w(i,"cipher")),k=g(w(i,"password")),b="",S="",$="",v="",N="",A="",O="";if(w(i,"plugin")!==void 0){let _=g(w(i,"plugin")).toLowerCase(),U=w(i,"plugin-opts");_==="obfs"?(b="obfs-local",$=g(w(U,"mode")),v=g(w(U,"host"))):_==="v2ray-plugin"&&(b="v2ray-plugin",$=g(w(U,"mode")),v=g(w(U,"host")),A=ds(w(U,"tls"))?"tls;":"",O=g(w(U,"path")),N=ds(w(U,"mux"))?"mux=4;":"")}else w(i,"obfs")!==void 0&&(b="obfs-local",$=g(w(i,"obfs")),v=g(w(i,"obfs-host")));b==="simple-obfs"||b==="obfs-local"?(S=`obfs=${$}`,S+=v===""?"":`;obfs-host=${v}`):b==="v2ray-plugin"&&(S=`mode=${$};${A}${N}`,v!==""&&(S+=`host=${v};`),O!==""&&(S+=`path=${O};`),N!==""&&(S+=`mux=${N};`)),h==="AEAD_CHACHA20_POLY1305"?h="chacha20-ietf-poly1305":h.includes("AEAD")&&(h=h.replace(/AEAD_/g,"").replace(/_/g,"-").toLowerCase()),ae(y,{group:d,method:h,password:k,plugin:b,pluginOption:S,port:f,remark:a,scv:m,server:c,tfo:l,udp:u,underlyingProxy:p});break}case"socks5":{d=L.socks;let h=g(w(i,"username")),k=g(w(i,"password"));ot(y,{group:d,password:k,port:f,remark:a,server:c,underlyingProxy:p,username:h});break}case"ssr":{d=L.ssr;let h=g(w(i,"cipher"));h==="dummy"&&(h="none");let k=g(w(i,"password")),b=g(w(i,"protocol")),S=g(w(i,"obfs")),$=w(i,"protocol-param")!==void 0?g(w(i,"protocol-param")):g(w(i,"protocolparam")),v=w(i,"obfs-param")!==void 0?g(w(i,"obfs-param")):g(w(i,"obfsparam"));Ye(y,{group:d,method:h,obfs:S,obfsParam:v,password:k,port:f,protocol:b,protocolParam:$,remark:a,scv:m,server:c,tfo:l,udp:u,underlyingProxy:p});break}case"http":{d=L.http;let h=g(w(i,"username")),k=g(w(i,"password")),b=g(w(i,"tls"));at(y,{group:d,password:k,port:f,remark:a,scv:m,server:c,tfo:l,tls:b==="true",underlyingProxy:p,username:h});break}case"trojan":{d=L.trojan;let h=g(w(i,"password")),k=g(w(i,"sni")),b=g(w(i,"network")),S="";switch(b){case"grpc":S=g(w(w(i,"grpc-opts"),"grpc-service-name"));break;case"ws":S=g(w(w(i,"ws-opts"),"path"));break;default:b="tcp",S="";break}Pt(y,{group:d,host:k,network:b,password:h,path:S,port:f,remark:a,scv:m,server:c,tfo:l,tlsSecure:!0,udp:u,underlyingProxy:p});break}case"snell":{d=L.snell;let h=g(w(i,"psk")),k=g(w(w(i,"obfs-opts"),"mode")),b=g(w(w(i,"obfs-opts"),"host")),S=g(w(i,"version"));tr(y,{group:d,host:b,obfs:k,password:h,port:f,remark:a,scv:m,server:c,tfo:l,udp:u,underlyingProxy:p,version:Y(S)});break}case"wireguard":{d=L.wireguard;let h=g(w(i,"public-key")),k=g(w(i,"private-key")),b=w(i,"dns"),S=Array.isArray(b)?b.map(O=>String(O)):b?[String(b)]:[],$=g(w(i,"mtu")),v=g(w(i,"preshared-key")),N=g(w(i,"ip")),A=g(w(i,"ipv6"));fn(y,{dnsServers:S,group:d,keepAlive:"0",mtu:$,port:f,preSharedKey:v,privateKey:k,publicKey:h,remark:a,selfIp:N,selfIpv6:A,server:c,testUrl:"",udp:u,underlyingProxy:p});break}case"hysteria":{d=L.hysteria;let h=g(w(i,"ports")),k=g(w(i,"protocol")),b=g(w(i,"obfs-protocol")),S=g(w(i,"up")),$=g(w(i,"up-speed")),v=g(w(i,"down")),N=g(w(i,"down-speed")),A=g(w(i,"auth")),O=g(w(i,"auth-str"));O===""&&(O=g(w(i,"auth_str")));let _=g(w(i,"obfs")),U=g(w(i,"sni")),Z=g(w(i,"fingerprint")),E=w(i,"alpn"),H=Array.isArray(E)?g(E[0]):g(E),V=g(w(i,"ca")),x=g(w(i,"ca-str")),ee=g(w(i,"recv-window-conn")),lt=g(w(i,"recv-window")),j=g(w(i,"disable-mtu-discovery"));j===""&&(j=g(w(i,"disable_mtu_discovery")));let D=g(w(i,"hop-interval"));pi(y,{alpn:H,auth:A,authStr:O,ca:V,caStr:x,disableMtuDiscovery:j,down:v,downSpeed:N,fingerprint:Z,group:d,hopInterval:D,obfs:_,obfsProtocol:b,port:f,ports:h,protocol:k,recvWindow:lt,recvWindowConn:ee,remark:a,scv:m,server:c,sni:U,tfo:l,underlyingProxy:p,up:S,upSpeed:$});break}case"hysteria2":{d=L.hysteria2;let h=g(w(i,"ports")),k=g(w(i,"up")),b=g(w(i,"down")),S=g(w(i,"password"));S===""&&(S=g(w(i,"auth")));let $=g(w(i,"obfs")),v=g(w(i,"obfs-password")),N=g(w(i,"sni")),A=g(w(i,"fingerprint")),O=w(i,"alpn"),_=Array.isArray(O)?g(O[0]):g(O),U=g(w(i,"ca")),Z=g(w(i,"ca-str")),E=g(w(i,"cwnd")),H=g(w(i,"hop-interval"));un(y,{alpn:_,ca:U,caStr:Z,cwnd:E,down:b,fingerprint:A,group:d,hopInterval:H,obfs:$,obfsPassword:v,password:S,port:f,ports:h,remark:a,scv:m,server:c,sni:N,tfo:l,underlyingProxy:p,up:k});break}case"anytls":{d=L.anytls;let h=g(w(i,"password")),k=g(w(i,"sni"));gs(y,{group:d,password:h,port:f,remark:a,scv:m,server:c,sni:k,tfo:l,udp:u,underlyingProxy:p});break}case"vless":{d=L.v2ray;let h=g(w(i,"uuid")),k=g(w(i,"network")),b=g(w(i,"tls")),S="",$="";k==="ws"?(S=g(w(w(i,"ws-opts"),"path")),$=g(w(w(w(i,"ws-opts"),"headers"),"Host"))):k==="grpc"&&(S=g(w(w(i,"grpc-opts"),"grpc-service-name")));let v=w(i,"alpn");pn(y,{alpn:Array.isArray(v)?v.map(N=>String(N)):void 0,encryption:g(w(i,"encryption")),fingerprint:g(w(i,"client-fingerprint")),flow:g(w(i,"flow")),group:d,host:$,network:k,path:S,port:f,remark:a,scv:m,server:c,sni:g(w(i,"servername")),tfo:l,tls:b==="true"?"tls":"",udp:u,underlyingProxy:p,userId:h});break}case"tuic":{d=L.v2ray;let h=w(i,"alpn");dn(y,{alpn:Array.isArray(h)?h.map(k=>String(k)):void 0,congestionControl:g(w(i,"congestion-controller")),group:d,password:g(w(i,"password")),port:f,remark:a,scv:m,server:c,sni:g(w(i,"sni")),tfo:l,udp:u,underlyingProxy:p,userId:g(w(i,"uuid"))});break}default:continue}y.id=n,e.push(y),n+=1}}function hi(t){let e=[],s=[],r;for(let n of t.split(/\r?\n/)){let i=n.trim(),o=/^\[(.*)\]$/.exec(i);if(o){r={lines:[],name:o[1].trim()},e.push(r);continue}i===""||i.startsWith("#")||i.startsWith(";")||(r?r.lines.push(i):s.push(i))}return s.length>0&&e.unshift({lines:s,name:"Proxy"}),e}function zr(t,e){let s=[];for(let r of t)r.name===e&&s.push(...r.lines);return s}function mi(t,e,s){for(let r=e;r<t.length;r+=1){let n=T(t[r]),i=n.indexOf("=");i!==-1&&(s[T(n.slice(0,i))]=T(n.slice(i+1)))}}function Xr(t,e){let s=t;s.includes("[Proxy]")&&(s=s.replace(/^[\s\S]*?\[/,"["));let r=hi(s),n=zr(r,"Proxy");if(n.length===0)return!1;let i=e.length,o=e.length;for(let a of n){let c=/^(.*?)\s*=\s*(.*)$/.exec(a);if(!c)continue;let f=c[1],p=c[2],u=z(p,",");if(u.length<3)continue;let l=pe(),m="",y="",d="",h="",k="",b="",S="",$="",v="",N="",A="tcp",O="",_="",U="",Z="",E="",H="1",V,x,ee,lt;switch(u[0].toLowerCase()){case"direct":case"reject":case"reject-tinygif":continue;case"custom":{if(u.length<5||(m=T(u[1]),y=T(u[2]),y==="0"))continue;d=T(u[3]),k=T(u[4]);for(let j=6;j<u.length;j+=1){let D=z(u[j],"=");if(D.length<2)continue;let R=T(D[0]),C=T(D[1]);R==="obfs"?(b="simple-obfs",$=C):R==="obfs-host"?v=C:R==="udp-relay"?V=G(C):R==="tfo"&&(x=G(C))}b!==""&&(S=`obfs=${$}`,S+=v===""?"":`;obfs-host=${v}`),ae(l,{group:L.ss,method:d,password:k,plugin:b,pluginOption:S,port:y,remark:f,scv:ee,server:m,tfo:x,udp:V});break}case"ss":{if(m=T(u[1]),y=T(u[2]),y==="0")continue;for(let j=3;j<u.length;j+=1){let D=z(u[j],"=");if(D.length<2)continue;let R=T(D[0]),C=T(D[1]);R==="encrypt-method"?d=C:R==="password"?k=C:R==="obfs"?(b="simple-obfs",$=C):R==="obfs-host"?v=C:R==="udp-relay"?V=G(C):R==="tfo"&&(x=G(C))}b!==""&&(S=`obfs=${$}`,S+=v===""?"":`;obfs-host=${v}`),ae(l,{group:L.ss,method:d,password:k,plugin:b,pluginOption:S,port:y,remark:f,scv:ee,server:m,tfo:x,udp:V});break}case"socks5":{if(m=T(u[1]),y=T(u[2]),y==="0")continue;u.length>=5&&(h=T(u[3]),k=T(u[4]));for(let j=5;j<u.length;j+=1){let D=z(u[j],"=");if(D.length<2)continue;let R=T(D[0]),C=T(D[1]);R==="udp-relay"?V=G(C):R==="tfo"?x=G(C):R==="skip-cert-verify"&&(ee=G(C))}ot(l,{group:L.socks,password:k,port:y,remark:f,scv:ee,server:m,tfo:x,udp:V,username:h});break}case"vmess":{if(m=T(u[1]),y=T(u[2]),y==="0")continue;A="tcp",d="auto";for(let j=3;j<u.length;j+=1){let D=z(u[j],"=");if(D.length!==2)continue;let R=T(D[0]),C=T(D[1]);switch(R){case"username":N=C;break;case"ws":A=C==="true"?"ws":"tcp";break;case"tls":O=C==="true"?"tls":"";break;case"ws-path":Z=C;break;case"obfs-host":_=C;break;case"ws-headers":{let Ct=z(C,"|");for(let Ve of Ct){let Ce=z(T(Ve),":");Ce.length===2&&(/host/i.test(Ce[0])?_=xs(Ce[1]):/edge/i.test(Ce[0])&&(U=xs(Ce[1])))}break}case"udp-relay":V=G(C);break;case"tfo":x=G(C);break;case"skip-cert-verify":ee=G(C);break;case"tls13":lt=G(C);break;case"vmess-aead":H=C==="true"?"0":"1";break;default:break}}$e(l,{add:m,aid:H,cipher:d,edge:U,group:L.v2ray,host:_,id:N,net:A,path:Z,port:y,remark:f,scv:ee,tfo:x,tls:O,tls13:lt,udp:V});break}case"http":{if(m=T(u[1]),y=T(u[2]),y==="0")continue;for(let j=3;j<u.length;j+=1){let D=z(u[j],"=");if(D.length<2)continue;let R=T(D[0]),C=T(D[1]);R==="username"?h=C:R==="password"?k=C:R==="skip-cert-verify"&&(ee=G(C))}at(l,{group:L.http,password:k,port:y,remark:f,scv:ee,server:m,tfo:x,tls:!1,username:h});break}case"trojan":{if(m=T(u[1]),y=T(u[2]),y==="0")continue;for(let j=3;j<u.length;j+=1){let D=z(u[j],"=");if(D.length!==2)continue;let R=T(D[0]),C=T(D[1]);R==="password"?k=C:R==="sni"?_=C:R==="udp-relay"?V=G(C):R==="tfo"?x=G(C):R==="skip-cert-verify"&&(ee=G(C))}Pt(l,{group:L.trojan,host:_,password:k,port:y,remark:f,scv:ee,server:m,tfo:x,tlsSecure:!0,udp:V});break}case"snell":{if(m=T(u[1]),y=T(u[2]),y==="0")continue;for(let j=3;j<u.length;j+=1){let D=z(u[j],"=");if(D.length!==2)continue;let R=T(D[0]),C=T(D[1]);R==="psk"?k=C:R==="obfs"?b=C:R==="obfs-host"?_=C:R==="udp-relay"?V=G(C):R==="tfo"?x=G(C):R==="skip-cert-verify"?ee=G(C):R==="version"&&(E=C)}tr(l,{group:L.snell,host:_,obfs:b,password:k,port:y,remark:f,scv:ee,server:m,tfo:x,udp:V,version:Y(E)});break}case"wireguard":{let j="",D="";for(let Ve=1;Ve<u.length;Ve+=1){let Ce=z(T(u[Ve]),"=");if(Ce.length!==2)continue;let sr=T(Ce[0]),rr=T(Ce[1]);sr==="section-name"?j=rr:sr==="test-url"&&(D=rr)}if(j==="")continue;let R=zr(r,`WireGuard ${j}`);if(R.length===0)continue;let C={};mi(R,0,C);let Ct=[];if(C["dns-server"])for(let Ve of z(C["dns-server"],","))Ct.push(T(Ve));fn(l,{dnsServers:Ct,group:L.wireguard,keepAlive:C.keepalive??"",mtu:C.mtu??"",port:"0",privateKey:C["private-key"]??"",remark:f,selfIp:C["self-ip"]??"",selfIpv6:C["self-ip-v6"]??"",server:"",testUrl:D,udp:V}),yi(l,C.peer??"");break}case"anytls":{if(m=T(u[1]),y=T(u[2]),y==="0")continue;for(let j=3;j<u.length;j+=1){let D=z(u[j],"=");if(D.length!==2)continue;let R=T(D[0]),C=T(D[1]);R==="password"?k=C:R==="sni"?_=C:R==="udp-relay"?V=G(C):R==="tfo"?x=G(C):R==="skip-cert-verify"&&(ee=G(C))}gs(l,{group:L.anytls,password:k,port:y,remark:f,scv:ee,server:m,sni:_,tfo:x,udp:V});break}default:{if(!gi(f,u,l,{scv:ee,tfo:x,tls13:lt,udp:V}))continue;break}}l.id=o,e.push(l),o+=1}return e.length>i}function gi(t,e,s,r){let n=t.toLowerCase(),i=e[0],o=i.lastIndexOf(":"),a=T(i.slice(0,o)),c=T(i.slice(o+1));if(c==="0")return!1;let f="",p="",u="",l="",m="",y="",d="",h="",k="",b="",S="",$="tcp",v="",N="1",A=t,O=r.udp,_=r.tfo,U=r.scv,Z=r.tls13,E={};for(let H=1;H<e.length;H+=1){let V=z(T(e[H]),"=");V.length===2&&(E[T(V[0])]=T(V[1]))}if(n==="shadowsocks"){if(f=E.method??"",p=E.password??"",E.tag&&(A=E.tag),k=E["ssr-protocol"]??"",b=E["ssr-protocol-param"]??"",E.obfs){let V=E.obfs;V==="http"||V==="tls"?(y="simple-obfs",d=V):V==="wss"||V==="ws"?(V==="wss"&&(S="tls"),d="websocket",y="v2ray-plugin"):d=V}h=E["obfs-host"]??"",m=E["obfs-uri"]??"",A===""&&(A=`${a}:${c}`);let H="";return y==="simple-obfs"?(H=`obfs=${d}`,h!==""&&(H+=`;obfs-host=${h}`)):y==="v2ray-plugin"&&(h===""&&!/^\d+(\.\d+){3}$/.test(a)&&!a.includes(":")&&(h=a),H=`mode=${d}`,h!==""&&(H+=`;host=${h}`),m!==""&&(H+=`;path=${m}`),H+=`;${S}`),k!==""?Ye(s,{group:L.ssr,method:f,obfs:d,obfsParam:h,password:p,port:c,protocol:k,protocolParam:b,remark:A,scv:U,server:a,tfo:_,udp:O}):ae(s,{group:L.ss,method:f,password:p,plugin:y,pluginOption:H,port:c,remark:A,scv:U,server:a,tfo:_,tls13:Z,udp:O}),!0}if(n==="vmess"){if($="tcp",f=E.method??"",v=E.password??"",E.tag&&(A=E.tag),E.obfs){let H=E.obfs;H==="ws"?$="ws":H==="over-tls"?S="tls":H==="wss"&&($="ws",S="tls")}return l=E["obfs-host"]??"",m=E["obfs-uri"]??"",E["over-tls"]&&(S=E["over-tls"]==="true"?"tls":""),E.aead&&(N=E.aead==="true"?"0":"1"),A===""&&(A=`${a}:${c}`),$e(s,{add:a,aid:N,cipher:f,group:L.v2ray,host:l,id:v,net:$,path:m,port:c,remark:A,scv:U,tfo:_,tls:S,tls13:Z,udp:O}),!0}return n==="trojan"?(p=E.password??"",E.tag&&(A=E.tag),E["over-tls"]&&(S=E["over-tls"]),l=E["tls-host"]??"",E["tls-verification"]==="false"&&(U=!0),A===""&&(A=`${a}:${c}`),Pt(s,{group:L.trojan,host:l,password:p,port:c,remark:A,scv:U,server:a,tfo:_,tls13:Z,tlsSecure:S==="true",udp:O}),!0):n==="http"?(u=E.username??"",p=E.password??"",E.tag&&(A=E.tag),E["over-tls"]&&(S=E["over-tls"]),E["tls-verification"]==="false"&&(U=!0),A===""&&(A=`${a}:${c}`),u==="none"&&(u=""),p==="none"&&(p=""),at(s,{group:L.http,password:p,port:c,remark:A,scv:U,server:a,tfo:_,tls:S==="true",tls13:Z,username:u}),!0):n==="anytls"?(p=E.password??"",E.tag&&(A=E.tag),l=E.sni??"",E["tls-verification"]==="false"&&(U=!0),A===""&&(A=`${a}:${c}`),gs(s,{group:L.anytls,password:p,port:c,remark:A,scv:U,server:a,sni:l,tfo:_,udp:O}),!0):!1}function xs(t){let e=T(t);return(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1)),e}function yi(t,e){let s=[...e.matchAll(/\((.*?)\)/g)].map(i=>i[1]);if(s.length===0)return;let n=[...s[0].matchAll(/([a-z-]+)\s?=\s?([^" ),]+|".*?"),?\s?/g)];for(let i of n){let o=i[1],a=i[2];switch(o){case"public-key":t.publicKey=a;break;case"endpoint":{let c=a.lastIndexOf(":");t.hostname=a.slice(0,c),t.port=Y(a.slice(c+1));break}case"client-id":t.clientId=a;break;case"allowed-ips":t.allowedIps=xs(a);break;default:break}}}function bi(t,e){try{let s=Qs(t);if(s&&typeof s=="object"&&(w(s,"Proxy")!==void 0||w(s,"proxies")!==void 0))return di(s,e),!0}catch{return!1}return!1}function wi(t,e){if(t.includes('"version"'))ki(t,e);else if(t.includes('"serverSubscribes"'))Zr(t,e);else if(t.includes('"uiItem"')||t.includes("vnext"))vi(t,e);else if(t.includes('"proxy_apps"'))Si(t,e);else if(t.includes('"idInUse"'))$i(t,e);else if(t.includes('"local_address"')&&t.includes('"local_port"'))Zr(t,e);else if(t.includes('"ModeFileNameType"'))Oi(t,e);else return!1;return e.length>0}function ki(t,e){let s;try{s=JSON.parse(t)}catch{return}if(s===null||typeof s!="object")return;let r="version"in s&&"servers"in s?"servers":"configs";if(!(r in s))return;let n=g(s.remarks),i=s[r];if(!Array.isArray(i))return;let o=e.length;for(let a of i){let c=g(a.remarks),f=g(a.server_port);if(f==="0")continue;let p=g(a.server),u=pe();ae(u,{group:n,method:g(a.method),password:g(a.password),plugin:g(a.plugin),pluginOption:g(a.plugin_opts),port:f,remark:c===""?`${p}:${f}`:c,server:p}),u.id=o,e.push(u),o+=1}}function Si(t,e){let s;try{s=JSON.parse(`{"nodes":${t}}`)}catch{return}if(s===null||typeof s!="object"||!Array.isArray(s.nodes))return;let r=e.length;for(let n of s.nodes){let i=g(n.server);if(i==="")continue;let o=g(n.server_port);if(o==="0"||o==="")continue;let a=g(n.remarks),c=pe();ae(c,{group:L.ss,method:g(n.method),password:g(n.password),plugin:g(n.plugin),pluginOption:g(n.plugin_opts),port:o,remark:a===""?`${i}:${o}`:a,server:i}),c.id=r,e.push(c),r+=1}}function Zr(t,e){let s;try{s=JSON.parse(t)}catch{return}if(s===null||typeof s!="object")return;let r=e.length;if("local_port"in s&&"local_address"in s){let i=pe(),o=g(s.server),a=g(s.server_port),c=`${o}:${a}`,f=g(s.method),p=g(s.obfs),u=g(s.protocol),l=g(s.password);ms(f,p,u)?ae(i,{group:L.ss,method:f,password:l,plugin:g(s.plugin),pluginOption:g(s.plugin_opts),port:a,remark:c,server:o}):Ye(i,{group:L.ssr,method:f,obfs:p,obfsParam:g(s.obfs_param),password:l,port:a,protocol:u,protocolParam:g(s.protocol_param),remark:c,server:o}),i.id=r,e.push(i);return}let n=s.configs??[];if(Array.isArray(n))for(let i of n){let o=g(i.group)===""?L.ssr:g(i.group),a=g(i.server),c=g(i.server_port);if(c==="0"||c==="")continue;let f=g(i.remarks)===""?`${a}:${c}`:g(i.remarks),p=pe();Ye(p,{group:o,method:g(i.method),obfs:g(i.obfs),obfsParam:g(i.obfsparam),password:g(i.password),port:c,protocol:g(i.protocol),protocolParam:g(i.protocolparam),remark:f,server:a}),p.id=r,e.push(p),r+=1}}function vi(t,e){let s;try{s=JSON.parse(t)}catch{return}if(s===null||typeof s!="object")return;let r=e.length;if("outbounds"in s){let a=s.outbounds;if(Array.isArray(a)&&a.length>0&&a[0]?.settings?.vnext?.length>0){let c=a[0].settings.vnext[0],f=g(c.address),p=g(c.port);if(p==="0")return;let u=c.users,l=Array.isArray(u)&&u.length?g(u[0].id):"",m=Array.isArray(u)&&u.length?g(u[0].alterId):"",y=Array.isArray(u)&&u.length?g(u[0].security):"",d=a[0].streamSettings??{},h=g(d.network),k=g(d.security),b="",S="",$="",v="";if(h==="ws"){let O=d.wsSettings??{};b=g(O.path),O.headers&&(S=g(O.headers.Host),$=g(O.headers.Edge))}let N=d.tcpSettings;N&&N.header&&(v=g(N.header.type),v==="http"&&N.header.request&&(Array.isArray(N.header.request.path)&&N.header.request.path.length&&(b=g(N.header.request.path[0])),N.header.request.headers&&(S=g(N.header.request.headers.Host),$=g(N.header.request.headers.Edge))));let A=pe();$e(A,{add:f,aid:m,cipher:y,edge:$,group:L.v2ray,host:S,id:l,net:h,path:b,port:p,remark:`${f}:${p}`,tls:k,type:v}),e.push(A)}return}let n=new Map,i=s.subItem??[];for(let a of i)n.set(g(a.id),g(a.remarks));let o=s.vmess??[];for(let a of o){if(a.address===null||a.address===void 0||a.port===null||a.id===null)continue;let c=g(a.remarks),f=g(a.address),p=g(a.port);if(p==="0"||p==="")continue;let u=g(a.subid),l="";u!==""&&(l=n.get(u)??""),c===""&&(c=`${f}:${p}`);let m=G(a.allowInsecure),y=Y(a.configType),d=pe();if(y===1)$e(d,{add:f,aid:g(a.alterId),cipher:g(a.security),group:l||L.v2ray,host:g(a.requestHost),id:g(a.id),net:g(a.network),path:g(a.path),port:p,remark:c,scv:m,sni:g(a.sni),tls:g(a.streamSecurity),type:g(a.headerType)});else if(y===3)ae(d,{group:l||L.ss,method:g(a.security),password:g(a.id),port:p,remark:c,scv:m,server:f});else if(y===4)ot(d,{group:l||L.socks,port:p,remark:c,scv:m,server:f});else continue;d.id=r,e.push(d),r+=1}}function $i(t,e){let s;try{s=JSON.parse(t)}catch{return}if(s===null||typeof s!="object"||!Array.isArray(s.configs))return;let r=e.length;for(let n of s.configs){let i=g(n.group),o=g(n.server),a=g(n.server_port);if(a==="0"||a==="")continue;let c=g(n.remarks)===""?`${o}:${a}`:g(n.remarks),f=g(n.password),p=pe(),u=Y(n.type);if(u===5)ot(p,{group:i,password:f,port:a,remark:c,server:o,username:g(n.username)});else if(u===6){let l=g(n.protocol),m=g(n.obfs),y=g(n.method);ms(y,m,l)?ae(p,{group:i,method:y,password:f,port:a,remark:c,server:o}):Ye(p,{group:i,method:y,obfs:m,obfsParam:g(n.obfsparam),password:f,port:a,protocol:l,protocolParam:g(n.protocolparam),remark:c,server:o})}else continue;p.id=r,e.push(p),r+=1}}function Oi(t,e){let s;try{s=JSON.parse(t)}catch{return}if(s===null||typeof s!="object"||!Array.isArray(s.Server))return;let r=e.length;for(let n of s.Server){let i=pe();hn(`Netch://${on(JSON.stringify(n))}`,i),i.id=r,e.push(i),r+=1}}function Ii(t){return t.startsWith("http://")||t.startsWith("https://")}function je(t,e){let s=new RegExp(e).exec(t);return s?s.slice():null}function Ni(t,e){if(/^vmess:\/\/[A-Za-z0-9-_]+\?.*/.test(t)){Ei(t,e);return}if(/^vmess:\/\/.*?@.*/.test(t)){Ai(t,e);return}if(/^vmess1:\/\/.*?\?.*/.test(t)){Pi(t,e);return}let s=re(t.replace(/(vmess|vmess1):\/\//,""));if(/.*?\s=\s.*/.test(s)){Ci(s,e);return}let r;try{let h=JSON.parse(s);if(h===null||typeof h!="object")return;r=h}catch{return}let n="1";r.v!==void 0&&(n=String(r.v));let i=String(r.ps??""),o=String(r.add??""),a=String(r.port??"");if(a==="0"||a==="")return;let c=String(r.type??""),f=String(r.id??""),p=String(r.aid??""),u=String(r.net??""),l=String(r.tls??""),m=String(r.host??""),y=String(r.sni??""),d="";switch(Y(n)){case 1:{if(m!==""){let h=z(m,";");h.length===2&&(m=h[0],d=h[1])}break}case 2:{d=String(r.path??"");break}default:break}o=T(o),$e(e,{add:o,aid:p,cipher:"auto",group:L.v2ray,host:m,id:f,net:u,path:d,port:a,remark:i,sni:y,tls:l,type:c})}function Ai(t,e){let s=t.slice(8),r="",n=s.lastIndexOf("#");n!==-1&&(r=W(s.slice(n+1)),s=s.slice(0,n));let o=/^([a-z]+)(?:\+([a-z]+))?:([\da-f]{4}(?:[\da-f]{4}-){4}[\da-f]{12})-(\d+)@(.+):(\d+)(?:\/?\?(.*))?$/.exec(s);if(!o)return;let a=o[1],c=o[2]??"",f=o[3],p=o[4],u=o[5],l=o[6],m=o[7]??"",y="",d="",h="";switch(a){case"tcp":case"kcp":y=I(m,"type");break;case"http":case"ws":d=I(m,"host"),h=I(m,"path");break;case"quic":y=I(m,"security"),d=I(m,"type"),h=I(m,"key");break;default:return}r===""&&(r=`${u}:${l}`),$e(e,{add:u,aid:p,cipher:"auto",group:L.v2ray,host:d,id:f,net:a,path:h,port:l,remark:r,tls:c,type:y})}function Ei(t,e){let s=t.slice(8),r="tcp",n=s.indexOf("?"),i=n>=0?s.slice(n+1):"";s=n>=0?s.slice(0,n):s;let o=je(re(s),"(.*?):(.*)@(.*):(.*)");if(!o)return;let a=o[1],c=o[2],f=o[3],p=o[4];if(p==="0")return;let u=W(I(i,"remarks")),l=I(i,"obfs"),m="",y="",d="";l!==""?l==="websocket"&&(r="ws",m=I(i,"obfsParam"),y=I(i,"path")):(r=I(i,"network"),m=I(i,"wsHost"),y=I(i,"wspath"));let h=I(i,"tls")==="1"?"tls":"",k=I(i,"aid");k===""&&(k="0"),u===""&&(u=`${f}:${p}`),$e(e,{add:f,aid:k,cipher:a,group:L.v2ray,host:m,id:c,net:r,path:y,port:p,remark:u,tls:h,type:d})}function Pi(t,e){let s=t.slice(9),r="",n="",i=s.indexOf("#");i!==-1&&(r=s.slice(i+1),s=s.slice(0,i));let o=s.indexOf("?"),a=o>=0?s.slice(o+1):"";s=o>=0?s.slice(0,o):s;let c=je(s,"(.*?)@(.*):(.*)");if(!c)return;let f=c[1],p=c[2],u=c[3],l=u.indexOf("/");if(l!==-1&&(n=u.slice(l),u=u.slice(0,l)),u==="0")return;let m=I(a,"network"),y=I(a,"tls")==="true"?"tls":"",d=I(a,"ws.host");r===""&&(r=`${p}:${u}`),$e(e,{add:p,aid:"0",cipher:"auto",group:L.v2ray,host:d,id:f,net:m,path:n,port:u,remark:r,tls:y,type:""})}function Ci(t,e){let s=t.replace(/(.*?)\s=\s(.*)/,"$1,$2"),r=z(s,",");if(r.length<6||r[1]!=="vmess")return;let n=T(r[0]),i=T(r[2]),o=T(r[3]);if(o==="0")return;let a=T(r[4]),c=T(r[5].replace(/"/g,"")),f=L.v2ray,p="",u="",l="",m="tcp",y="";for(let d=6;d<r.length;d+=1){let h=z(r[d],"=");if(h.length<2)continue;let k=T(h[0]),b=T(h.slice(1).join("="));switch(k){case"group":f=b;break;case"over-tls":p=b==="true"?"tls":"";break;case"tls-host":u=b;break;case"obfs-path":l=b.replace(/"/g,"");break;case"obfs-header":{let S=z(b.replace(/"/g,"").replace(/\[Rr\]\[Nn\]/g,"|"),"|");for(let $ of S)/Host: /i.test($)?u=$.slice(6):/Edge: /i.test($)&&(y=$.slice(6));break}case"obfs":b==="ws"&&(m="ws");break;default:break}}l===""&&(l="/"),$e(e,{add:i,aid:"0",cipher:a,edge:y,group:f,host:u,id:c,net:m,path:l,port:o,remark:n,tls:p,type:"none"})}function Ti(t,e){let s=t.slice(5).replace(/\/\?/g,"?"),r=L.ss,n="",i="",o="",a="",c=r,f=s.indexOf("#");f!==-1&&(n=W(s.slice(f+1)),s=s.slice(0,f));let p=s.indexOf("?");if(p!==-1){i=s.slice(p+1);let d=W(I(i,"plugin")),h=d.indexOf(";");o=h===-1?d:d.slice(0,h),a=h===-1?"":d.slice(h+1);let k=I(i,"group");k!==""&&(c=re(k)),s=s.slice(0,p)}let u="",l="",m="",y="";if(s.includes("@")){let d=je(s,"(\\S+?)@(\\S+):(\\d+)");if(!d)return;let h=d[1];m=d[2],y=d[3];let k=je(re(h),"(\\S+?):(\\S+)");if(!k)return;u=k[1],l=k[2]}else{let d=je(re(s),"(\\S+?):(\\S+)@(\\S+):(\\d+)");if(!d)return;u=d[1],l=d[2],m=d[3],y=d[4]}y!=="0"&&(n===""&&(n=`${m}:${y}`),ae(e,{group:c,method:u,password:l,plugin:o,pluginOption:a,port:y,remark:n,server:m}))}function Li(t,e){let s=t.slice(6).replace(/\r/g,"");s=re(s);let r="",n="",i="",o="",a=s.indexOf("/?");if(a!==-1){let k=s.slice(a+2);s=s.slice(0,a),r=re(I(k,"group")),n=re(I(k,"remarks")),i=re(I(k,"obfsparam")).replace(/\s/g,""),o=re(I(k,"protoparam")).replace(/\s/g,"")}let c=je(s,"(\\S+):(\\d+?):(\\S+?):(\\S+?):(\\S+?):(\\S+)");if(!c)return;let f=c[1],p=c[2],u=c[3],l=c[4],m=c[5],y=re(c[6]);if(p==="0")return;let d=r===""?L.ssr:r,h=n===""?`${f}:${p}`:n;ms(l,m,u)?ae(e,{group:d,method:l,password:y,port:p,remark:h,server:f}):Ye(e,{group:d,method:l,obfs:m,obfsParam:i,password:y,port:p,protocol:u,protocolParam:o,remark:h,server:f})}function _i(t,e){let s=e.length,r=re(t.slice(6)),n;try{n=JSON.parse(r)}catch{return}if(n===null||typeof n!="object"||!("servers"in n))return;let i=String(n.airport??""),o=n.servers,a;if(Array.isArray(o))a=o;else if(o!==null&&typeof o=="object")a=Object.keys(o).map(c=>o[c]);else return;for(let c of a){if(c===null||typeof c!="object")continue;let f=String(c.server??""),p=String(c.port??n.port??"");if(f===""||p===""||p==="0")continue;let u=String(c.remarks??""),l=String(c.encryption??n.encryption??""),m=String(c.password??n.password??""),y=String(c.plugin??n.plugin??""),d=String(c.plugin_options??n.plugin_options??""),h=pe();ae(h,{group:i,method:l,password:m,plugin:y,pluginOption:d,port:p,remark:u,server:f}),h.id=s,e.push(h),s+=1}}function Ri(t,e){let s="",r="",n="",i="",o="",a="";if(t.includes("socks://")){let c=t,f=c.indexOf("#");if(f!==-1&&(r=W(c.slice(f+1)),c=c.slice(0,f)),c=re(c.slice(8)),c.includes("@")){let u=z(c,"@");if(u.length<2)return;c=u[1];let l=z(u[0],":");if(l.length<2)return;o=l[0],a=l[1]}let p=z(c,":");if(p.length<2)return;n=p[0],i=p[1]}else(t.includes("https://t.me/socks")||t.includes("tg://socks"))&&(n=I(t,"server"),i=I(t,"port"),o=W(I(t,"user")),a=W(I(t,"pass")),r=W(I(t,"remarks")),s=W(I(t,"group")));s===""&&(s=L.socks),r===""&&(r=`${n}:${i}`),!(i==="0"||i==="")&&ot(e,{group:s,password:a,port:i,remark:r,server:n,username:o})}function Mi(t,e){let s=I(t,"server"),r=I(t,"port"),n=W(I(t,"user")),i=W(I(t,"pass")),o=W(I(t,"remarks")),a=W(I(t,"group"));a===""&&(a=L.http),o===""&&(o=`${s}:${r}`),!(r==="0"||r==="")&&at(e,{group:a,password:i,port:r,remark:o,server:s,tls:t.includes("/https"),username:n})}function ji(t,e){let s=t,r="",n="",i=s.includes("https://"),o=s.indexOf("?");if(o!==-1){let u=s.slice(o+1);s=s.slice(0,o),r=W(I(u,"remarks")),n=W(I(u,"group"))}s=s.slice(s.indexOf("://")+3),s=re(s);let a="",c="",f="",p="";if(s.includes("@")){let u=je(s,"(.*?):(.*?)@(.*):(.*)");if(!u)return;f=u[1],p=u[2],a=u[3],c=u[4]}else{let u=je(s,"(.*):(.*)");if(!u)return;a=u[1],c=u[2]}n===""&&(n=L.http),r===""&&(r=`${a}:${c}`),c!=="0"&&at(e,{group:n,password:p,port:c,remark:r,server:a,tls:i,username:f})}function Di(t,e){let s=t.slice(9),r="",n="",i="",o="",a="",c=s.lastIndexOf("#");c!==-1&&(r=W(s.slice(c+1)),s=s.slice(0,c));let f=s.indexOf("?");f!==-1&&(n=s.slice(f+1),s=s.slice(0,f));let p=je(s,"(.*?)@(.*):(.*)");if(!p)return;let u=p[1],l=p[2],m=p[3];if(m==="0")return;i=I(n,"sni"),i===""&&(i=I(n,"peer"));let y=I(n,"tfo"),d=W(I(n,"group"));I(n,"ws")==="1"?(o=I(n,"wspath"),a="ws"):I(n,"type")==="ws"&&(o=I(n,"path"),o.startsWith("%2F")&&(o=W(o)),a="ws");let h=I(n,"type"),k=I(n,"sni"),b=I(n,"allowInsecure");r===""&&(r=`${l}:${m}`),Pt(e,{group:d===""?L.trojan:d,host:i,network:a,password:u,path:o,port:m,remark:r,scv:b===""?void 0:Je(b),server:l,sni:k,tfo:y===""?void 0:Je(y),tlsSecure:h!==""||!0})}function Je(t){let e=t.trim().toLowerCase();if(["1","true","yes","on"].includes(e))return!0;if(["0","false","no","off"].includes(e))return!1}function Bi(t,e){let s=t.replace(/(hysteria2|hy2):\/\//,"hysteria2://").replace(/\/\?/g,"?");/hysteria2:\/\/.*?[:].*/.test(s)&&Ki(s,e)}function Ki(t,e){let s=t.slice(12),r="",n="",i=s.lastIndexOf("#");i!==-1&&(r=W(s.slice(i+1)),s=s.slice(0,i));let o=s.lastIndexOf("?");o!==-1&&(n=s.slice(o+1),s=s.slice(0,o));let a="",c="",f="";if(s.includes("@")){let v=/^(.*?)@(.*)[:](\d+)$/.exec(s);if(!v)return;a=v[1],c=v[2],f=v[3]}else{if(a=I(n,"password"),a===""||!s.includes(":"))return;let v=/^(.*)[:](\d+)$/.exec(s);if(!v)return;c=v[1],f=v[2]}let p=I(n,"insecure"),u=I(n,"up"),l=I(n,"down"),m=I(n,"alpn"),y=I(n,"obfs"),d=I(n,"obfs-password"),h=I(n,"sni"),k=I(n,"pinSHA256"),b=I(n,"mport"),S=I(n,"ports"),$=S!==""?S:b!==""?b:f;r===""&&(r=`${c}:${f}`),un(e,{alpn:m,down:l,fingerprint:k,group:L.hysteria2,obfs:y,obfsPassword:d,password:a,port:f,ports:$,remark:r,scv:p===""?void 0:Je(p),server:c,sni:h,up:u})}function Ui(t,e){let s=t.slice(9),r="",n="",i=s.lastIndexOf("#");i!==-1&&(r=W(s.slice(i+1)),s=s.slice(0,i));let o=s.lastIndexOf("?");o!==-1&&(n=s.slice(o+1),s=s.slice(0,o));let a=/^(.*?)@(.*)[:](\d+)$/.exec(s);if(!a)return;let c=a[1],f=a[2],p=a[3];if(p==="0")return;let u=I(n,"sni"),l=I(n,"udp"),m=I(n,"insecure");r===""&&(r=`${f}:${p}`),gs(e,{group:L.anytls,password:c,port:p,remark:r,scv:m===""?void 0:Je(m),server:f,sni:u,udp:l===""?void 0:Je(l)})}function Fi(t,e){let s=t.slice(8),r="",n="",i=s.lastIndexOf("#");i!==-1&&(r=W(s.slice(i+1)),s=s.slice(0,i));let o=s.indexOf("?");o!==-1&&(n=s.slice(o+1),s=s.slice(0,o));let a=/^(.*?)@\[?(.*?)\]?:(\d+)$/.exec(s);if(!a)return;let c=a[1],f=a[2],p=a[3];if(p==="0")return;let u=I(n,"type"),l=I(n,"security"),m=I(n,"host"),y=W(I(n,"path")),d=I(n,"sni"),h=I(n,"flow"),k=I(n,"fp"),b=I(n,"alpn");r===""&&(r=`${f}:${p}`),pn(e,{alpn:b===""?void 0:b.split(","),fingerprint:k,flow:h,group:L.v2ray,host:m,network:u,path:y,port:p,remark:r,scv:I(n,"allowInsecure")===""?void 0:Je(I(n,"allowInsecure")),server:f,sni:d,tls:l,userId:c})}function qi(t,e){let s=t.slice(7),r="",n="",i=s.lastIndexOf("#");i!==-1&&(r=W(s.slice(i+1)),s=s.slice(0,i));let o=s.indexOf("?");o!==-1&&(n=s.slice(o+1),s=s.slice(0,o));let a=/^(.*?):(.*?)@\[?(.*?)\]?:(\d+)$/.exec(s);if(!a)return;let c=a[1],f=a[2],p=a[3],u=a[4];if(u==="0")return;let l=I(n,"congestion_control")||I(n,"congestion-controller"),m=I(n,"alpn"),y=I(n,"sni");r===""&&(r=`${p}:${u}`),dn(e,{alpn:m===""?void 0:m.split(","),congestionControl:l,group:L.v2ray,password:f,port:u,remark:r,scv:I(n,"allow_insecure")===""?void 0:Je(I(n,"allow_insecure")),server:p,sni:y,userId:c})}function Vi(t,e){ie(t,"ssr://")?Li(t,e):ie(t,"vmess://")||ie(t,"vmess1://")?Ni(t,e):ie(t,"ss://")?Ti(t,e):ie(t,"socks://")||ie(t,"https://t.me/socks")||ie(t,"tg://socks")?Ri(t,e):ie(t,"https://t.me/http")||ie(t,"tg://http")?Mi(t,e):ie(t,"Netch://")?hn(t,e):ie(t,"trojan://")?Di(t,e):ie(t,"vless://")?Fi(t,e):ie(t,"tuic://")?qi(t,e):t.includes("hysteria2://")||t.includes("hy2://")?Bi(t,e):ie(t,"anytls://")?Ui(t,e):Ii(t)&&ji(t,e)}function Wi(t,e){let s=!1;if(ie(t,"ssd://")&&(_i(t,e),s=!0),!s&&/"?(Proxy|proxies)"?:/.test(t)&&bi(t,e)&&(s=!0),!s&&Xr(t,e)&&(s=!0),s)return;let r=re(t);if(/(vmess|shadowsocks|http|trojan)\s*?=/.test(r)&&Xr(r,e))return;let n=e.length;xr(r,e),e.length===n&&r!==t&&xr(t,e)}function xr(t,e){let s=t.replace(/\r\n/g,`
|
|
130
|
-
`),r=
|
|
131
|
-
`)<1?
|
|
132
|
-
`;for(let n of s.split(r)){let i=n.replace(/\r/g,"");if(i==="")continue;let o=pe();Vi(i,o),o.type!=="unknown"&&e.push(o)}}function ys(t){let e=[];return wi(t,e)||Wi(t,e),e}function mn(t){try{return new RegExp(t)}catch{return/$^/}}function er(t,e){return mn(e).test(t)}function Hi(t,e){let s=mn(e).exec(t);return s!==null&&s[0]===t}var Gi={anytls:"ANYTLS",http:"HTTP",https:"HTTPS",hysteria:"HYSTERIA",hysteria2:"HYSTERIA2",ss:"SS",ssr:"SSR",snell:"SNELL",socks5:"SOCKS5",trojan:"TROJAN",tuic:"TUIC",vless:"VLESS",vmess:"VMESS",wireguard:"WIREGUARD"};function en(t,e){let s=t.split(","),r=!1;for(let n of s)if(/^-?\d+$/.test(n))Number.parseInt(n,10)===e&&(r=!0);else if(/^(\d+)-(\d+)$/.test(n)){let i=/^(\d+)-(\d+)$/.exec(n),o=Number.parseInt(i[1],10),a=Number.parseInt(i[2],10);e>=o&&e<=a&&(r=!0)}else if(/^!-?(\d+)$/.test(n)){r=!0;let i=/^!-?(\d+)$/.exec(n);Number.parseInt(i[1],10)===e&&(r=!1)}else if(/^!(\d+)-(\d+)$/.test(n)){r=!0;let i=/^!(\d+)-(\d+)$/.exec(n),o=Number.parseInt(i[1],10),a=Number.parseInt(i[2],10);e>=o&&e<=a&&(r=!1)}else if(/^(\d+)-$/.test(n)){let i=/^(\d+)-$/.exec(n);Number.parseInt(i[1],10)>=e&&(r=!0)}else if(/^(\d+)\+$/.test(n)){let i=/^(\d+)\+$/.exec(n);Number.parseInt(i[1],10)<=e&&(r=!0)}return r}function Yi(t,e){if(t.startsWith("!!GROUP=")){let s=/^!!(?:GROUP)=(.+?)(?:!!(.*))?$/.exec(t),r=s?.[1]??"",n=s?.[2]??"";return{matched:er(e.group,r),realRule:n}}if(t.startsWith("!!GROUPID=")||t.startsWith("!!INSERT=")){let s=/^!!(?:GROUPID|INSERT)=([\d\-+!,]+)(?:!!(.*))?$/.exec(t),r=s?.[1]??"",n=s?.[2]??"",i=t.startsWith("!!INSERT=")?-1:1;return{matched:en(r,i*e.groupId),realRule:n}}if(t.startsWith("!!TYPE=")){let s=/^!!(?:TYPE)=(.+?)(?:!!(.*))?$/.exec(t),r=s?.[1]??"",n=s?.[2]??"";if(e.type==="unknown")return{matched:!1,realRule:n};let i=Gi[e.type]??"";return{matched:Hi(i,r),realRule:n}}if(t.startsWith("!!PORT=")){let s=/^!!(?:PORT)=(.+?)(?:!!(.*))?$/.exec(t),r=s?.[1]??"",n=s?.[2]??"";return{matched:en(r,e.port),realRule:n}}if(t.startsWith("!!SERVER=")){let s=/^!!(?:SERVER)=(.+?)(?:!!(.*))?$/.exec(t),r=s?.[1]??"",n=s?.[2]??"";return{matched:er(e.hostname,r),realRule:n}}return{matched:!0,realRule:t}}function gn(t,e,s=!0){let r=t.replace(/=/g,"-");s&&r.includes(",")&&(r=`"${r}"`);let n=r,i=2;for(;e.includes(n);)n=`${r} ${i}`,i+=1;return n}function yn(t,e,s,r){if(t.startsWith("[]")&&r){s.push(t.slice(2));return}for(let n of e){let{matched:i,realRule:o}=Yi(t,n);i&&(o===""||er(n.remark,o))&&!s.includes(n.remark)&&s.push(n.remark)}}var Ji=["origin","auth_sha1_v4","auth_aes128_md5","auth_aes128_sha1","auth_chain_a","auth_chain_b"],Qi=["plain","http_simple","http_post","random_head","tls1.2_ticket_auth","tls1.2_ticket_fastauth"],zi=["rc4-md5","aes-128-ctr","aes-192-ctr","aes-256-ctr","aes-128-cfb","aes-192-cfb","aes-256-cfb","chacha20-ietf","xchacha20","none"];function Xi(t){return t.replace(/^\[+/,"").replace(/\]+$/,"")}function Zi(t,e,s,r,n,i){let o={name:r,port:t.port,server:Xi(t.hostname)};switch(t.type){case"ss":{if(e.filterDeprecated&&t.encryptMethod==="chacha20")return;o.type="ss",o.cipher=t.encryptMethod,o.password=t.password;let a=t.pluginOption.replace(/;/g,"&");if(t.plugin==="simple-obfs"||t.plugin==="obfs-local")o.plugin="obfs",o["plugin-opts"]={host:W(I(a,"obfs-host")),mode:W(I(a,"obfs"))};else if(t.plugin==="v2ray-plugin"){o.plugin="v2ray-plugin";let c={host:I(a,"host"),mode:I(a,"mode"),mux:a.includes("mux"),path:I(a,"path"),tls:a.includes("tls")};n!==void 0&&(c["skip-cert-verify"]=n),o["plugin-opts"]=c}break}case"vmess":{switch(o.type="vmess",o.uuid=t.userId,o.alterId=t.alterId,o.cipher=t.encryptMethod,o.tls=t.tlsSecure,n!==void 0&&(o["skip-cert-verify"]=n),t.serverName!==""&&(o.servername=t.serverName),t.transferProtocol){case"tcp":break;case"ws":o.network=t.transferProtocol,e.clashNewFieldName?o["ws-opts"]={...t.host!==""||t.edge!==""?{headers:{...t.edge!==""?{Edge:t.edge}:{},...t.host!==""?{Host:t.host}:{}}}:{},path:t.path}:(o["ws-path"]=t.path,(t.host!==""||t.edge!=="")&&(o["ws-headers"]={...t.edge!==""?{Edge:t.edge}:{},...t.host!==""?{Host:t.host}:{}}));break;case"http":o.network=t.transferProtocol,o["http-opts"]={...t.host!==""||t.edge!==""?{headers:{...t.edge!==""?{Edge:[t.edge]}:{},...t.host!==""?{Host:[t.host]}:{}}}:{},method:"GET",path:[t.path]};break;case"h2":o.network=t.transferProtocol,o["h2-opts"]={...t.host!==""?{host:[t.host]}:{},path:t.path};break;case"grpc":o.network=t.transferProtocol,o.servername=t.host,o["grpc-opts"]={"grpc-service-name":t.path};break;default:return}break}case"ssr":{if(e.filterDeprecated&&(!s&&!zi.includes(t.encryptMethod)||!Ji.includes(t.protocol)||!Qi.includes(t.obfs)))return;o.type="ssr",o.cipher=t.encryptMethod==="none"?"dummy":t.encryptMethod,o.password=t.password,o.protocol=t.protocol,o.obfs=t.obfs,s?(o.protocolparam=t.protocolParam,o.obfsparam=t.obfsParam):(o["protocol-param"]=t.protocolParam,o["obfs-param"]=t.obfsParam);break}case"socks5":o.type="socks5",t.username!==""&&(o.username=t.username),t.password!==""&&(o.password=t.password),n!==void 0&&(o["skip-cert-verify"]=n);break;case"http":case"https":o.type="http",t.username!==""&&(o.username=t.username),t.password!==""&&(o.password=t.password),o.tls=t.tlsSecure,n!==void 0&&(o["skip-cert-verify"]=n);break;case"trojan":switch(o.type="trojan",o.password=t.password,t.host!==""&&(o.sni=t.host),n!==void 0&&(o["skip-cert-verify"]=n),t.transferProtocol){case"tcp":break;case"grpc":o.network=t.transferProtocol,t.path!==""&&(o["grpc-opts"]={"grpc-service-name":t.path});break;case"ws":o.network=t.transferProtocol,o["ws-opts"]={...t.host!==""?{headers:{Host:t.host}}:{},path:t.path};break;default:break}break;case"snell":if(t.snellVersion>=4)return;o.type="snell",o.psk=t.password,t.snellVersion!==0&&(o.version=t.snellVersion),t.obfs!==""&&(o["obfs-opts"]={...t.host!==""?{host:t.host}:{},mode:t.obfs});break;case"wireguard":o.type="wireguard",o["public-key"]=t.publicKey,o["private-key"]=t.privateKey,o.ip=t.selfIp,t.selfIpv6!==""&&(o.ipv6=t.selfIpv6),t.preSharedKey!==""&&(o["preshared-key"]=t.preSharedKey),t.dnsServers.length>0&&(o.dns=t.dnsServers),t.mtu>0&&(o.mtu=t.mtu);break;case"hysteria":{o.type="hysteria",t.ports!==""&&(o.ports=t.ports),t.protocol!==""&&(o.protocol=t.protocol),t.obfsParam!==""&&(o["obfs-protocol"]=t.obfsParam),t.up!==""&&(o.up=t.up),t.upSpeed&&(o["up-speed"]=t.upSpeed),t.down!==""&&(o.down=t.down),t.downSpeed&&(o["down-speed"]=t.downSpeed),t.authStr!==""&&(o["auth-str"]=t.authStr,o.auth=on(t.authStr)),t.obfs!==""&&(o.obfs=t.obfs),t.sni!==""&&(o.sni=t.sni),n!==void 0&&(o["skip-cert-verify"]=n),t.fingerprint!==""&&(o.fingerprint=t.fingerprint),t.alpn.length>0&&(o.alpn=t.alpn),t.ca!==""&&(o.ca=t.ca),t.caStr!==""&&(o["ca-str"]=t.caStr),t.recvWindowConn&&(o["recv-window-conn"]=t.recvWindowConn),t.recvWindow&&(o["recv-window"]=t.recvWindow),t.disableMtuDiscovery!==void 0&&(o["disable-mtu-discovery"]=t.disableMtuDiscovery),t.tcpFastOpen!==void 0&&(o["fast-open"]=t.tcpFastOpen),t.hopInterval&&(o["hop-interval"]=t.hopInterval);break}case"hysteria2":o.type="hysteria2",t.ports!==""&&(o.ports=t.ports),t.upSpeed&&(o.up=t.upSpeed),t.downSpeed&&(o.down=t.downSpeed),t.password!==""&&(o.password=t.password),t.obfs!==""&&(o.obfs=t.obfs),t.obfsParam!==""&&(o["obfs-password"]=t.obfsParam),t.sni!==""&&(o.sni=t.sni),n!==void 0&&(o["skip-cert-verify"]=n),t.fingerprint!==""&&(o.fingerprint=t.fingerprint),t.alpn.length>0&&(o.alpn=t.alpn),t.ca!==""&&(o.ca=t.ca),t.caStr!==""&&(o["ca-str"]=t.caStr),t.cwnd&&(o.cwnd=t.cwnd),t.hopInterval&&(o["hop-interval"]=t.hopInterval);break;case"anytls":o.type="anytls",o.password=t.password,t.sni!==""&&(o.sni=t.sni),n!==void 0&&(o["skip-cert-verify"]=n);break;case"vless":switch(o.type="vless",o.uuid=t.userId,t.flow!==""&&(o.flow=t.flow),o.tls=t.tlsSecure,t.serverName!==""&&(o.servername=t.serverName),t.fingerprint!==""&&(o["client-fingerprint"]=t.fingerprint),t.alpn.length>0&&(o.alpn=t.alpn),n!==void 0&&(o["skip-cert-verify"]=n),t.transferProtocol){case"tcp":break;case"ws":o.network=t.transferProtocol,o["ws-opts"]={...t.host!==""?{headers:{Host:t.host}}:{},path:t.path};break;case"grpc":o.network=t.transferProtocol,o["grpc-opts"]={"grpc-service-name":t.path};break;default:break}break;case"tuic":o.type="tuic",o.uuid=t.userId,o.password=t.password,t.congestionControl!==""&&(o["congestion-controller"]=t.congestionControl),t.alpn.length>0&&(o.alpn=t.alpn),t.serverName!==""&&(o.sni=t.serverName),n!==void 0&&(o["skip-cert-verify"]=n);break;default:return}return xi(t,e)&&t.type!=="snell"&&(o.udp=!0),i!==void 0&&(o.tfo=i),e.clashNewFieldName&&t.underlyingProxy!==""&&(o["dialer-proxy"]=t.underlyingProxy),o}function xi(t,e){return t.udp!==void 0?t.udp:e.udp===!0}function eo(t,e,s,r=!1){let n=[],i=[],o=[];for(let f of t){let p=sn(f.type);s.appendProxyType&&(f.remark=`[${p}] ${f.remark}`);let u=gn(f.remark,o,!1);f.remark=u;let l=f.allowInsecure!==void 0?f.allowInsecure:s.skipCertVerify,m=f.tcpFastOpen!==void 0?f.tcpFastOpen:s.tfo,y=Zi(f,s,r,u,l,m);y&&(n.push(y),o.push(u),i.push(f))}if(s.nodeList)return{doc:{proxies:n},nodeList:i};let a=[];for(let f of e){let p={name:f.name,type:f.type==="smart"?"url-test":f.type};switch(f.type){case"select":case"relay":break;case"load-balance":p.strategy=f.strategy,p.lazy=f.lazy,p.url=f.url,f.interval>0&&(p.interval=f.interval),f.tolerance>0&&(p.tolerance=f.tolerance);break;case"smart":case"url-test":f.lazy!==void 0&&(p.lazy=f.lazy),p.url=f.url,f.interval>0&&(p.interval=f.interval),f.tolerance>0&&(p.tolerance=f.tolerance);break;case"fallback":p.url=f.url,f.interval>0&&(p.interval=f.interval),f.tolerance>0&&(p.tolerance=f.tolerance);break;default:continue}f.disableUdp!==void 0&&(p["disable-udp"]=f.disableUdp);let u=[];for(let l of f.proxies)yn(l,i,u,!0);f.usingProvider.length>0?p.use=f.usingProvider:(u.length===0&&u.push("DIRECT"),p.proxies=u),a.push(p)}let c={};return s.clashNewFieldName?(c.proxies=n,a.length>0&&(c["proxy-groups"]=a)):(c.Proxy=n,a.length>0&&(c["Proxy Group"]=a)),{doc:c,nodeList:i}}function to(t){return zs(t,{aliasDuplicateObjects:!1,lineWidth:0})}function bn(t,e,s,r=!1){let{doc:n}=eo(t,e,s,r);return to(n)}function so(t){let e=[],s;for(let r of t.split(/\r?\n/)){let n=r,i=/^\[(.*)\]$/.exec(n.trim());if(i){s={lines:[],name:i[1].trim()},e.push(s);continue}n.trim()!==""&&s&&s.lines.push(n)}return e}function le(t){return t?"true":"false"}function tn(t,e){let s=`http, ${t.hostname}, ${t.port}`;return t.username!==""&&(s+=`, username=${t.username}`),t.password!==""&&(s+=`, password=${t.password}`),s+=`, tls=${le(t.tlsSecure)}`,e!==void 0&&(s+=`, skip-cert-verify=${le(e)}`),s}function ro(t,e=!1){let s=`public-key = ${t.publicKey}`;return s+=`, endpoint = ${t.hostname}:${t.port}`,t.preSharedKey!==""&&(s+=`, preshared-key = ${t.preSharedKey}`),t.allowedIps!==""&&(s+=`, allowed-ips = "${t.allowedIps}"`),t.keepAlive>0&&(s+=`, keepalive = ${t.keepAlive}`),t.clientId!==""&&(s+=e?`, reserved = [${t.clientId}]`:`, client-id = ${t.clientId}`),s}function no(t,e,s,r){let n=r.version,i=[],o=[],a=[],c=new Map,f=[],p=1080;for(let l of t){s.appendProxyType&&(l.remark=`[${sn(l.type)}] ${l.remark}`);let m=gn(l.remark,i);l.remark=m;let y=l.udp!==void 0?l.udp:s.udp,d=l.tcpFastOpen!==void 0?l.tcpFastOpen:s.tfo,h=l.allowInsecure!==void 0?l.allowInsecure:s.skipCertVerify,k=l.tls13!==void 0?l.tls13:s.tls13,b="";switch(l.type){case"ss":if(n>=3||n===-3?b=`ss, ${l.hostname}, ${l.port}, encrypt-method=${l.encryptMethod}, password=${l.password}`:b=`custom, ${l.hostname}, ${l.port}, ${l.encryptMethod}, ${l.password}, https://github.com/pobizhe/SSEncrypt/raw/master/SSEncrypt.module`,l.plugin!=="")if(l.plugin==="simple-obfs"||l.plugin==="obfs-local")l.pluginOption!==""&&(b+=`,${l.pluginOption.replace(/;/g,",")}`);else continue;break;case"vmess":{if(n<4&&n!==-3)continue;b=`vmess, ${l.hostname}, ${l.port}, username=${l.userId}, tls=${le(l.tlsSecure)}, vmess-aead=${l.alterId===0?"true":"false"}`,l.tlsSecure&&k!==void 0&&(b+=`, tls13=${le(k)}`);let S=[];switch(l.transferProtocol){case"tcp":break;case"ws":{l.host===""?b+=`, ws=true, ws-path=${l.path}, sni=${l.hostname}`:b+=`, ws=true, ws-path=${l.path}, sni=${l.host}`,l.host!==""&&S.push(`Host:${l.host}`),l.edge!==""&&S.push(`Edge:${l.edge}`),S.length>0&&(b+=`, ws-headers=${S.join("|")}`);break}default:continue}h!==void 0&&(b+=`, skip-cert-verify=${le(h)}`);break}case"ssr":{if(s.surgeSsrPath===""||n<2)continue;let S=["-l",String(p),"-s",l.hostname,"-p",String(l.port),"-m",l.encryptMethod,"-k",l.password,"-o",l.obfs,"-O",l.protocol];l.obfsParam!==""&&S.push("-g",l.obfsParam),l.protocolParam!==""&&S.push("-G",l.protocolParam),b=`external, exec="${s.surgeSsrPath}", args="${S.join('", args="')}", local-port=${p}`,(cn(l.hostname)||ln(l.hostname))&&(b+=`, addresses=${l.hostname}`),p+=1;break}case"socks5":b=`socks5, ${l.hostname}, ${l.port}`,l.username!==""&&(b+=`, username=${l.username}`),l.password!==""&&(b+=`, password=${l.password}`),h!==void 0&&(b+=`, skip-cert-verify=${le(h)}`);break;case"https":if(n===-3){b=`https, ${l.hostname}, ${l.port}, ${l.username}, ${l.password}`,h!==void 0&&(b+=`, skip-cert-verify=${le(h)}`);break}b=tn(l,h);break;case"http":b=tn(l,h);break;case"trojan":if(n<4&&n!==-3)continue;b=`trojan, ${l.hostname}, ${l.port}, password=${l.password}`,l.snellVersion!==0&&(b+=`, version=${l.snellVersion}`),l.host!==""&&(b+=`, sni=${l.host}`),h!==void 0&&(b+=`, skip-cert-verify=${le(h)}`);break;case"snell":b=`snell, ${l.hostname}, ${l.port}, psk=${l.password}`,l.obfs!==""&&(b+=`, obfs=${l.obfs}`,l.host!==""&&(b+=`, obfs-host=${l.host}`)),l.snellVersion!==0&&(b+=`, version=${l.snellVersion}`);break;case"wireguard":{if(n<4&&n!==-3)continue;let S=li(l.remark).slice(0,5);b=`wireguard, section-name=${S}`,l.testUrl!==""&&(b+=`, test-url=${l.testUrl}`);let $=[`private-key = ${l.privateKey}`,`self-ip = ${l.selfIp}`];l.selfIpv6!==""&&$.push(`self-ip-v6 = ${l.selfIpv6}`),l.dnsServers.length>0&&$.push(`dns-server = ${l.dnsServers.join(",")}`),l.mtu>0&&$.push(`mtu = ${l.mtu}`),$.push(`peer = (${ro(l)})`);let v=`WireGuard ${S}`;c.set(v,$),f.push(v);break}case"hysteria2":if(n<4)continue;b=`hysteria, ${l.hostname}, ${l.port}, password=${l.password}`,l.downSpeed&&(b+=`, download-bandwidth=${l.downSpeed}`),h!==void 0&&(b+=`,skip-cert-verify=${le(h)}`),l.fingerprint!==""&&(b+=`,server-cert-fingerprint-sha256=${l.fingerprint}`),l.sni!==""&&(b+=`,sni=${l.sni}`);break;case"anytls":if(n<4&&n!==-3)continue;b=`anytls, ${l.hostname}, ${l.port}, password=${l.password}`,l.sni!==""&&(b+=`,sni=${l.sni}`);break;default:continue}d!==void 0&&(b+=`, tfo=${le(d)}`),y!==void 0&&(b+=`, udp-relay=${le(y)}`),l.underlyingProxy!==""&&(b+=`, underlying-proxy=${l.underlyingProxy}`),o.push(`${m} = ${b}`),i.push(m),a.push(l)}if(r.nodeList)return{extraSections:c,groups:[],proxies:o,sectionOrder:f};let u=[];for(let l of e){let m=[],y="";switch(l.type){case"select":case"smart":case"url-test":case"fallback":break;case"load-balance":if(n<1&&n!==-3)continue;break;case"ssid":{let d=l.proxies.slice(1).join(","),h=`${l.type},default=${l.proxies[0]??""},${d}`;u.push(`${l.name} = ${h}`);continue}default:continue}for(let d of l.proxies)yn(d,a,m,!0);if(m.length===0&&m.push("DIRECT"),m.length===1){let d=m[0].toLowerCase();if(d==="direct"||d==="reject"||d==="reject-tinygif"){o.push(`${l.name} = ${d}`);continue}}y=`${l.type},${m.join(",")}`,(l.type==="url-test"||l.type==="fallback"||l.type==="load-balance")&&(y+=`,url=${l.url},interval=${l.interval}`,l.tolerance>0&&(y+=`,tolerance=${l.tolerance}`),l.timeout>0&&(y+=`,timeout=${l.timeout}`),l.persistent!==void 0&&(y+=`,persistent=${le(l.persistent)}`),l.evaluateBeforeUse!==void 0&&(y+=`,evaluate-before-use=${le(l.evaluateBeforeUse)}`)),u.push(`${l.name} = ${y}`)}return{extraSections:c,groups:u,proxies:o,sectionOrder:f}}function wn(t,e,s,r){let n=no(t,e,s,r);if(r.nodeList)return n.proxies.join(`
|
|
133
|
-
`);let i=r.baseConf===""?[]:
|
|
129
|
+
`,s)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let s=fs(e),r=it(s);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let s=fs(e),r=it(s);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,s){return this.type!=="comment"||this.indent<=s?!1:e.every(r=>r.type==="newline"||r.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};function ri(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new Ot||null,prettyErrors:e}}function Jr(t,e={}){let{lineCounter:s,prettyErrors:r}=ri(e),n=new Et(s?.addNewLine),i=new At(e),o=null;for(let a of i.compose(n.parse(t),!0,t.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new Se(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&s&&(o.errors.forEach(Ms(t,s)),o.warnings.forEach(Ms(t,s))),o}function Xs(t,e,s){let r;typeof e=="function"?r=e:s===void 0&&e&&typeof e=="object"&&(s=e);let n=Jr(t,s);if(!n)return null;if(n.warnings.forEach(i=>Vt(n.options.logLevel,i)),n.errors.length>0){if(n.options.logLevel!=="silent")throw n.errors[0];n.errors=[]}return n.toJS(Object.assign({reviver:r},s))}function Qs(t,e,s){let r=null;if(typeof e=="function"||Array.isArray(e)?r=e:s===void 0&&e&&(s=e),typeof s=="string"&&(s=s.length),typeof s=="number"){let n=Math.round(s);s=n<1?void 0:n>8?{indent:8}:{indent:n}}if(t===void 0){let{keepUndefined:n}=s??e??{};if(!n)return}return me(t)&&!r?t.toString(s):new Fe(t,r,s).toString(s)}function rn(t){switch(t){case"ss":return"SS";case"ssr":return"SSR";case"vmess":return"VMess";case"vless":return"VLESS";case"trojan":return"Trojan";case"snell":return"Snell";case"http":return"HTTP";case"https":return"HTTPS";case"socks5":return"SOCKS5";case"wireguard":return"WireGuard";case"hysteria":return"Hysteria";case"hysteria2":return"Hysteria2";case"tuic":return"TUIC";case"anytls":return"AnyTLS";default:return"Unknown"}}var L={anytls:"AnyTLSProvider",http:"HTTPProvider",hysteria:"HysteriaProvider",hysteria2:"Hysteria2Provider",snell:"SnellProvider",socks:"SocksProvider",ss:"SSProvider",ssr:"SSRProvider",trojan:"TrojanProvider",tuic:"TUICProvider",v2ray:"V2RayProvider",wireguard:"WireGuardProvider"};function pe(){return{allowedIps:"0.0.0.0/0, ::/0",allowInsecure:void 0,alpn:[],alterId:0,authStr:"",ca:"",caStr:"",clientId:"",congestionControl:"",cwnd:0,disableMtuDiscovery:void 0,dnsServers:[],down:"",downSpeed:0,edge:"",encryptMethod:"",fakeType:"",fingerprint:"",flow:"",group:"",groupId:0,hopInterval:0,host:"",hostname:"",id:0,keepAlive:0,mtu:0,obfs:"",obfsParam:"",password:"",path:"",plugin:"",pluginOption:"",port:0,ports:"",preSharedKey:"",privateKey:"",protocol:"",protocolParam:"",publicKey:"",quicSecret:"",quicSecure:"",recvWindow:0,recvWindowConn:0,remark:"",selfIp:"",selfIpv6:"",serverName:"",shortId:"",snellVersion:0,sni:"",tcpFastOpen:void 0,testUrl:"",tls13:void 0,tlsSecure:!1,transferProtocol:"",type:"unknown",udp:void 0,underlyingProxy:"",up:"",upSpeed:0,userId:"",username:""}}var nn=(t=>(t.Clash="clash",t.ClashR="clashr",t.Surge="surge",t.Surfboard="surfboard",t.QuantumultX="quanx",t.Quantumult="quan",t.Loon="loon",t.Mellow="mellow",t.V2Ray="v2ray",t.Trojan="trojan",t.SSD="ssd",t.SSC="ss",t.SSSub="sssub",t.SSR="ssr",t.SingBox="singbox",t.Mixed="mixed",t.NodeList="nodelist",t.Auto="auto",t))(nn||{});function on(){return{addEmoji:!1,appendProxyType:!1,authorized:!1,autoCountry:!1,clashClassicalRuleset:!1,clashNewFieldName:!0,clashProxiesStyle:"flow",clashProxyGroupsStyle:"flow",clashScript:!1,countryLocale:"zh-CN",countryResolver:void 0,dedupe:!1,emojiArray:[],enableRuleGenerator:!0,filterDeprecated:!1,managedConfigPrefix:"",nameRegexArray:[],nameRemove:[],nodeList:!1,overwriteOriginalRules:!0,quanxDevId:"",removeEmoji:!1,renameArray:[],skipCertVerify:void 0,sortFlag:!1,sortScript:"",surgeSsrPath:"",tfo:void 0,tls13:void 0,udp:void 0}}var Zs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var hs={};for(let t=0;t<Zs.length;t+=1)hs[Zs[t]]=t;hs["-"]=62;hs._=63;function ii(t){return new TextEncoder().encode(t)}function oi(t){return new TextDecoder("utf-8",{fatal:!1}).decode(t)}function ai(t,e){let s=ii(t),r="";for(let n=0;n<s.length;n+=3){let i=s[n],o=n+1<s.length?s[n+1]:0,a=n+2<s.length?s[n+2]:0,c=i<<16|o<<8|a;r+=e[c>>18&63],r+=e[c>>12&63],r+=n+1<s.length?e[c>>6&63]:"=",r+=n+2<s.length?e[c&63]:"="}return r}function ci(t){let s=t.replace(/\s+/g,"").replace(/=+$/,""),r=[],n=0,i=0;for(let o of s){let a=hs[o];a!==void 0&&(n=n<<6|a,i+=6,i>=8&&(i-=8,r.push(n>>i&255)))}return Uint8Array.from(r)}function an(t){return ai(t,Zs)}function cn(t){return oi(ci(t))}function re(t){return cn(t)}function T(t){return t.replace(/^\s+|\s+$/g,"")}function Y(t){if(t==null)return 0;if(typeof t=="number")return Number.isFinite(t)?Math.trunc(t):0;let e=/[+-]?\d+/.exec(t);if(!e)return 0;let s=Number.parseInt(e[0],10);return Number.isNaN(s)?0:s}function ie(t,e){return t.startsWith(e)}function Xr(t,e){if(e==="")return 0;let s=0,r=t.indexOf(e);for(;r!==-1;)s+=1,r=t.indexOf(e,r+e.length);return s}function Q(t,e,s=!1){let r=t.split(e);return s?r.filter(n=>n!==""):r}function ln(t){let e=t.split(".");return e.length!==4?!1:e.every(s=>/^\d{1,3}$/.test(s)&&Number(s)<=255)}function un(t){return/^\[?[0-9A-Fa-f:]{2,}\]?$/.test(t)&&t.includes(":")}function q(t){try{return decodeURIComponent(t)}catch{return t.replace(/%([0-9A-Fa-f]{2})/g,(e,s)=>String.fromCharCode(Number.parseInt(s,16)))}}function Qr(t){return t.toLowerCase().replace(/_/g,"-")}function li(t,e){if(t==="")return[];let s=t.split("#",1)[0],r=s.indexOf("?"),n=r>=0?s.slice(r+1):s,i=n.startsWith("?")?n.slice(1):n,o=[],a=Qr(e);for(let c of i.split("&")){if(c==="")continue;let u=c.indexOf("="),p=u>=0?c.slice(0,u):c;Qr(q(p))===a&&o.push(q(u>=0?c.slice(u+1):""))}return o}function A(t,e){let s=li(t,e);return s.length>0?s[s.length-1].trim():""}function ui(t){let e=0xcbf29ce484222325n,s=0x100000001b3n;for(let r of t)e^=BigInt(r.codePointAt(0)),e=BigInt.asUintN(64,e*s);return e}function fi(t){return ui(t).toString(16)}var Jf=new Set(Object.values(nn));var Xf=1024**3/1e3**3;var pi=["2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm","2022-blake3-chacha20-poly1305","2022-blake3-chacha12-poly1305","2022-blake3-chacha8-poly1305","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","chacha20","chacha20-ietf","chacha20-ietf-poly1305","rc4-md5","salsa20","xchacha20-ietf-poly1305"];function di(t){return pi.includes(t.toLowerCase())}function ms(t,e,s){return di(t)&&(e===""||e==="plain")&&(s===""||s==="origin")}function ue(t,e,s,r,n,i,o,a,c,u,p){t.type=e,t.group=s,t.remark=r,t.hostname=n,t.underlyingProxy=p,t.port=Y(i),t.udp=o,t.tcpFastOpen=a,t.allowInsecure=c,t.tls13=u}function $e(t,e){let{add:s,aid:r=0,cipher:n="",edge:i="",group:o,host:a="",id:c="",net:u="",path:p="",port:f,remark:l,scv:m,sni:y="",tfo:d,tls:h="",tls13:v,type:b="",udp:S,underlyingProxy:$=""}=e;ue(t,"vmess",o,l,s,f,S,d,m,v,$),t.userId=c===""?"00000000-0000-0000-0000-000000000000":c,t.alterId=Y(r),t.encryptMethod=n,t.transferProtocol=u===""?"tcp":u,t.edge=i,t.serverName=y,u==="quic"?(t.quicSecure=a,t.quicSecret=p):(t.host=a===""&&!ln(s)&&!un(s)?s:T(a),t.path=p===""?"/":T(p)),t.fakeType=b,t.tlsSecure=h==="tls"}function Ye(t,e){ue(t,"ssr",e.group,e.remark,e.server,e.port,e.udp,e.tfo,e.scv,void 0,e.underlyingProxy??""),t.password=e.password,t.encryptMethod=e.method,t.protocol=e.protocol,t.protocolParam=e.protocolParam??"",t.obfs=e.obfs,t.obfsParam=e.obfsParam??""}function ae(t,e){ue(t,"ss",e.group,e.remark,e.server,e.port,e.udp,e.tfo,e.scv,e.tls13,e.underlyingProxy??""),t.password=e.password,t.encryptMethod=e.method,t.plugin=e.plugin??"",t.pluginOption=e.pluginOption??""}function ot(t,e){ue(t,"socks5",e.group,e.remark,e.server,e.port,e.udp,e.tfo,e.scv,void 0,e.underlyingProxy??""),t.username=e.username??"",t.password=e.password??""}function at(t,e){ue(t,e.tls?"https":"http",e.group,e.remark,e.server,e.port,void 0,e.tfo,e.scv,e.tls13,e.underlyingProxy??""),t.username=e.username??"",t.password=e.password??"",t.tlsSecure=e.tls}function Ct(t,e){ue(t,"trojan",e.group,e.remark,e.server,e.port,e.udp,e.tfo,e.scv,e.tls13,e.underlyingProxy??""),t.password=e.password,t.host=e.host??"",t.tlsSecure=e.tlsSecure??!0,t.transferProtocol=e.network===void 0||e.network===""?"tcp":e.network,t.path=e.path??"",t.serverName=e.sni??""}function tr(t,e){ue(t,"snell",e.group,e.remark,e.server,e.port,e.udp,e.tfo,e.scv,void 0,e.underlyingProxy??""),t.password=e.password,t.obfs=e.obfs??"",t.host=e.host??"",t.snellVersion=e.version??0}function gs(t,e){ue(t,"anytls",e.group,e.remark,e.server,e.port,e.udp,e.tfo,e.scv,void 0,e.underlyingProxy??""),t.tlsSecure=!0,t.password=e.password,t.sni=e.sni??""}function fn(t,e){ue(t,"wireguard",e.group,e.remark,e.server,e.port,e.udp,void 0,void 0,void 0,e.underlyingProxy??""),t.selfIp=e.selfIp??"",t.selfIpv6=e.selfIpv6??"",t.privateKey=e.privateKey??"",t.publicKey=e.publicKey??"",t.preSharedKey=e.preSharedKey??"",t.dnsServers=e.dnsServers??[],t.mtu=Y(e.mtu),t.keepAlive=Y(e.keepAlive),t.testUrl=e.testUrl??"",t.clientId=e.clientId??""}function hi(t,e){ue(t,"hysteria",e.group,e.remark,e.server,e.port,void 0,e.tfo,e.scv,void 0,e.underlyingProxy??""),t.ports=e.ports??"",t.protocol=e.protocol??"",t.obfsParam=e.obfsProtocol??"";let s=e.up??"";s!==""&&(s.length>4&&s.endsWith("bps")?t.up=s:Y(s)&&(t.upSpeed=Y(s),t.up=`${s} Mbps`)),e.upSpeed&&(t.upSpeed=Y(e.upSpeed));let r=e.down??"";r!==""&&(r.length>4&&r.endsWith("bps")?t.down=r:Y(r)&&(t.downSpeed=Y(r),t.down=`${r} Mbps`)),e.downSpeed&&(t.downSpeed=Y(e.downSpeed)),t.authStr=e.authStr??"",e.auth&&(t.authStr=cn(e.auth)),t.tlsSecure=!0,t.obfs=e.obfs??"",t.sni=e.sni??"",t.fingerprint=e.fingerprint??"",t.ca=e.ca??"",t.caStr=e.caStr??"",t.recvWindowConn=Y(e.recvWindowConn),t.recvWindow=Y(e.recvWindow),t.disableMtuDiscovery=e.disableMtuDiscovery?e.disableMtuDiscovery==="true":void 0,t.hopInterval=Y(e.hopInterval),e.alpn&&(t.alpn=[e.alpn])}function pn(t,e){ue(t,"hysteria2",e.group,e.remark,e.server,e.port,void 0,e.tfo,e.scv,void 0,e.underlyingProxy??""),t.tlsSecure=!0,t.upSpeed=Y(e.up),t.downSpeed=Y(e.down),t.ports=e.ports??"",t.password=e.password??"",t.obfs=e.obfs??"",t.obfsParam=e.obfsPassword??"",t.sni=e.sni??"",t.fingerprint=e.fingerprint??"",e.alpn&&(t.alpn=[e.alpn]),t.ca=e.ca??"",t.caStr=e.caStr??"",t.cwnd=Y(e.cwnd),t.hopInterval=Y(e.hopInterval)}function dn(t,e){ue(t,"vless",e.group,e.remark,e.server,e.port,e.udp,e.tfo,e.scv,void 0,e.underlyingProxy??""),t.userId=e.userId,t.flow=e.flow??"",t.encryptMethod=e.encryption??"none",t.transferProtocol=e.network===void 0||e.network===""?"tcp":e.network,t.tlsSecure=e.tls==="tls"||e.tls==="reality",t.serverName=e.sni??"",t.host=e.host??"",t.path=e.path??"",t.fingerprint=e.fingerprint??"",t.publicKey=e.publicKey??"",t.shortId=e.shortId??"",e.alpn&&(t.alpn=e.alpn)}function hn(t,e){ue(t,"tuic",e.group,e.remark,e.server,e.port,e.udp,e.tfo,e.scv,void 0,e.underlyingProxy??""),t.tlsSecure=!0,t.userId=e.userId,t.password=e.password,t.congestionControl=e.congestionControl??"",t.serverName=e.sni??"",e.alpn&&(t.alpn=e.alpn)}function zs(t){if(!(t==null||t===""))return String(t).toLowerCase()==="true"}function K(t){return t==null?"":String(t)}function mn(t,e){let s;try{s=JSON.parse(re(t.slice(8)))}catch{return}if(s===null||typeof s!="object")return;let r=K(s.Type),n=K(s.Group),i=K(s.Remark),o=K(s.Hostname),a=zs(s.EnableUDP),c=zs(s.EnableTFO),u=zs(s.AllowInsecure),p=K(s.Port);if(p==="0"||p==="")return;let f=K(s.EncryptMethod),l=K(s.Password);switch(i===""&&(i=`${o}:${p}`),r){case"SS":ae(e,{group:n===""?L.ss:n,method:f,password:l,plugin:K(s.Plugin),pluginOption:K(s.PluginOption),port:p,remark:i,scv:u,server:o,tfo:c,udp:a});break;case"SSR":{let m=K(s.Protocol),y=K(s.OBFS);ms(f,y,m)?ae(e,{group:n===""?L.ss:n,method:f,password:l,plugin:K(s.Plugin),pluginOption:K(s.PluginOption),port:p,remark:i,scv:u,server:o,tfo:c,udp:a}):Ye(e,{group:n===""?L.ssr:n,method:f,obfs:y,obfsParam:K(s.OBFSParam),password:l,port:p,protocol:m,protocolParam:K(s.ProtocolParam),remark:i,scv:u,server:o,tfo:c,udp:a});break}case"VMess":$e(e,{add:o,aid:K(s.AlterID),cipher:f,edge:K(s.Edge),group:n===""?L.v2ray:n,host:K(s.Host),id:K(s.UserID),net:K(s.TransferProtocol),path:K(s.Path),port:p,remark:i,scv:u,sni:K(s.ServerName),tfo:c,tls:K(s.TLSSecure),type:K(s.FakeType),udp:a});break;case"Socks5":ot(e,{group:n===""?L.socks:n,password:l,port:p,remark:i,scv:u,server:o,tfo:c,udp:a,username:K(s.Username)});break;case"HTTP":case"HTTPS":at(e,{group:n===""?L.http:n,password:l,port:p,remark:i,scv:u,server:o,tfo:c,tls:r==="HTTPS"});break;case"Trojan":Ct(e,{group:n===""?L.trojan:n,host:K(s.Host),network:K(s.TransferProtocol),password:l,path:K(s.Path),port:p,remark:i,scv:u,server:o,tfo:c,tlsSecure:K(s.TLSSecure)==="true",udp:a});break;case"Snell":tr(e,{group:n===""?L.snell:n,host:K(s.Host),obfs:K(s.OBFS),password:l,port:p,remark:i,scv:u,server:o,tfo:c,udp:a,version:Y(K(s.SnellVersion))});break;default:break}}function g(t){return t==null?"":String(t)}function ds(t){return typeof t=="boolean"?t:g(t).toLowerCase()==="true"}function H(t){if(!(t==null||t===""))return ds(t)}function w(t,e){return t!==null&&typeof t=="object"?t[e]:void 0}function mi(t,e){let s=w(t,"proxies")!==void 0?"proxies":"Proxy",r=w(t,s);if(!Array.isArray(r))return;let n=e.length;for(let i of r){let o=g(w(i,"type")).toLowerCase(),a=g(w(i,"name")),c=g(w(i,"server")),u=g(w(i,"port")),p=g(w(i,"underlying-proxy"));if(p===""&&(p=g(w(i,"dialer-proxy"))),u===""||u==="0")continue;let f=H(w(i,"udp")),l=H(w(i,"fast-open")),m=H(w(i,"skip-cert-verify")),y=pe(),d="";switch(o){case"vmess":{d=L.v2ray;let h=g(w(i,"uuid")),v=g(w(i,"alterId")),b=g(w(i,"cipher")),S=w(i,"network")!==void 0?g(w(i,"network")):"tcp",$=g(w(i,"servername")),k="",N="",O="";switch(S){case"http":k=g(w(w(w(i,"http-opts"),"path"),0)),N=g(w(w(w(w(i,"http-opts"),"headers"),"Host"),0)),O="";break;case"ws":if(w(i,"ws-opts")!==void 0){let R=w(i,"ws-opts");k=w(R,"path")!==void 0?g(w(R,"path")):"/",N=g(w(w(R,"headers"),"Host")),O=g(w(w(R,"headers"),"Edge"))}else k=w(i,"ws-path")!==void 0?g(w(i,"ws-path")):"/",N=g(w(w(i,"ws-headers"),"Host")),O=g(w(w(i,"ws-headers"),"Edge"));break;case"h2":k=g(w(w(i,"h2-opts"),"path")),N=g(w(w(w(i,"h2-opts"),"host"),0)),O="";break;case"grpc":N=g(w(i,"servername")),k=g(w(w(i,"grpc-opts"),"grpc-service-name")),O="";break;default:break}let I=ds(w(i,"tls"))?"tls":"";$e(y,{add:c,aid:v,cipher:b,edge:O,group:d,host:N,id:h,net:S,path:k,port:u,remark:a,scv:m,sni:$,tfo:l,tls:I,type:"",udp:f,underlyingProxy:p});break}case"ss":{d=L.ss;let h=g(w(i,"cipher")),v=g(w(i,"password")),b="",S="",$="",k="",N="",O="",I="";if(w(i,"plugin")!==void 0){let R=g(w(i,"plugin")).toLowerCase(),U=w(i,"plugin-opts");R==="obfs"?(b="obfs-local",$=g(w(U,"mode")),k=g(w(U,"host"))):R==="v2ray-plugin"&&(b="v2ray-plugin",$=g(w(U,"mode")),k=g(w(U,"host")),O=ds(w(U,"tls"))?"tls;":"",I=g(w(U,"path")),N=ds(w(U,"mux"))?"mux=4;":"")}else w(i,"obfs")!==void 0&&(b="obfs-local",$=g(w(i,"obfs")),k=g(w(i,"obfs-host")));b==="simple-obfs"||b==="obfs-local"?(S=`obfs=${$}`,S+=k===""?"":`;obfs-host=${k}`):b==="v2ray-plugin"&&(S=`mode=${$};${O}${N}`,k!==""&&(S+=`host=${k};`),I!==""&&(S+=`path=${I};`),N!==""&&(S+=`mux=${N};`)),h==="AEAD_CHACHA20_POLY1305"?h="chacha20-ietf-poly1305":h.includes("AEAD")&&(h=h.replace(/AEAD_/g,"").replace(/_/g,"-").toLowerCase()),ae(y,{group:d,method:h,password:v,plugin:b,pluginOption:S,port:u,remark:a,scv:m,server:c,tfo:l,udp:f,underlyingProxy:p});break}case"socks5":{d=L.socks;let h=g(w(i,"username")),v=g(w(i,"password"));ot(y,{group:d,password:v,port:u,remark:a,server:c,underlyingProxy:p,username:h});break}case"ssr":{d=L.ssr;let h=g(w(i,"cipher"));h==="dummy"&&(h="none");let v=g(w(i,"password")),b=g(w(i,"protocol")),S=g(w(i,"obfs")),$=w(i,"protocol-param")!==void 0?g(w(i,"protocol-param")):g(w(i,"protocolparam")),k=w(i,"obfs-param")!==void 0?g(w(i,"obfs-param")):g(w(i,"obfsparam"));Ye(y,{group:d,method:h,obfs:S,obfsParam:k,password:v,port:u,protocol:b,protocolParam:$,remark:a,scv:m,server:c,tfo:l,udp:f,underlyingProxy:p});break}case"http":{d=L.http;let h=g(w(i,"username")),v=g(w(i,"password")),b=g(w(i,"tls"));at(y,{group:d,password:v,port:u,remark:a,scv:m,server:c,tfo:l,tls:b==="true",underlyingProxy:p,username:h});break}case"trojan":{d=L.trojan;let h=g(w(i,"password")),v=g(w(i,"sni")),b=g(w(i,"network")),S="";switch(b){case"grpc":S=g(w(w(i,"grpc-opts"),"grpc-service-name"));break;case"ws":S=g(w(w(i,"ws-opts"),"path"));break;default:b="tcp",S="";break}Ct(y,{group:d,host:v,network:b,password:h,path:S,port:u,remark:a,scv:m,server:c,tfo:l,tlsSecure:!0,udp:f,underlyingProxy:p});break}case"snell":{d=L.snell;let h=g(w(i,"psk")),v=g(w(w(i,"obfs-opts"),"mode")),b=g(w(w(i,"obfs-opts"),"host")),S=g(w(i,"version"));tr(y,{group:d,host:b,obfs:v,password:h,port:u,remark:a,scv:m,server:c,tfo:l,udp:f,underlyingProxy:p,version:Y(S)});break}case"wireguard":{d=L.wireguard;let h=g(w(i,"public-key")),v=g(w(i,"private-key")),b=w(i,"dns"),S=Array.isArray(b)?b.map(I=>String(I)):b?[String(b)]:[],$=g(w(i,"mtu")),k=g(w(i,"preshared-key")),N=g(w(i,"ip")),O=g(w(i,"ipv6"));fn(y,{dnsServers:S,group:d,keepAlive:"0",mtu:$,port:u,preSharedKey:k,privateKey:v,publicKey:h,remark:a,selfIp:N,selfIpv6:O,server:c,testUrl:"",udp:f,underlyingProxy:p});break}case"hysteria":{d=L.hysteria;let h=g(w(i,"ports")),v=g(w(i,"protocol")),b=g(w(i,"obfs-protocol")),S=g(w(i,"up")),$=g(w(i,"up-speed")),k=g(w(i,"down")),N=g(w(i,"down-speed")),O=g(w(i,"auth")),I=g(w(i,"auth-str"));I===""&&(I=g(w(i,"auth_str")));let R=g(w(i,"obfs")),U=g(w(i,"sni")),Z=g(w(i,"fingerprint")),E=w(i,"alpn"),W=Array.isArray(E)?g(E[0]):g(E),V=g(w(i,"ca")),x=g(w(i,"ca-str")),ee=g(w(i,"recv-window-conn")),lt=g(w(i,"recv-window")),M=g(w(i,"disable-mtu-discovery"));M===""&&(M=g(w(i,"disable_mtu_discovery")));let D=g(w(i,"hop-interval"));hi(y,{alpn:W,auth:O,authStr:I,ca:V,caStr:x,disableMtuDiscovery:M,down:k,downSpeed:N,fingerprint:Z,group:d,hopInterval:D,obfs:R,obfsProtocol:b,port:u,ports:h,protocol:v,recvWindow:lt,recvWindowConn:ee,remark:a,scv:m,server:c,sni:U,tfo:l,underlyingProxy:p,up:S,upSpeed:$});break}case"hysteria2":{d=L.hysteria2;let h=g(w(i,"ports")),v=g(w(i,"up")),b=g(w(i,"down")),S=g(w(i,"password"));S===""&&(S=g(w(i,"auth")));let $=g(w(i,"obfs")),k=g(w(i,"obfs-password")),N=g(w(i,"sni")),O=g(w(i,"fingerprint")),I=w(i,"alpn"),R=Array.isArray(I)?g(I[0]):g(I),U=g(w(i,"ca")),Z=g(w(i,"ca-str")),E=g(w(i,"cwnd")),W=g(w(i,"hop-interval"));pn(y,{alpn:R,ca:U,caStr:Z,cwnd:E,down:b,fingerprint:O,group:d,hopInterval:W,obfs:$,obfsPassword:k,password:S,port:u,ports:h,remark:a,scv:m,server:c,sni:N,tfo:l,underlyingProxy:p,up:v});break}case"anytls":{d=L.anytls;let h=g(w(i,"password")),v=g(w(i,"sni"));gs(y,{group:d,password:h,port:u,remark:a,scv:m,server:c,sni:v,tfo:l,udp:f,underlyingProxy:p});break}case"vless":{d=L.v2ray;let h=g(w(i,"uuid")),v=g(w(i,"network")),b=g(w(i,"tls")),S="",$="";v==="ws"?(S=g(w(w(i,"ws-opts"),"path")),$=g(w(w(w(i,"ws-opts"),"headers"),"Host"))):v==="grpc"&&(S=g(w(w(i,"grpc-opts"),"grpc-service-name")));let k=w(i,"alpn");dn(y,{alpn:Array.isArray(k)?k.map(N=>String(N)):void 0,encryption:g(w(i,"encryption")),fingerprint:g(w(i,"client-fingerprint")),flow:g(w(i,"flow")),group:d,host:$,network:v,path:S,port:u,remark:a,scv:m,server:c,sni:g(w(i,"servername")),tfo:l,tls:b==="true"?"tls":"",udp:f,underlyingProxy:p,userId:h});break}case"tuic":{d=L.v2ray;let h=w(i,"alpn");hn(y,{alpn:Array.isArray(h)?h.map(v=>String(v)):void 0,congestionControl:g(w(i,"congestion-controller")),group:d,password:g(w(i,"password")),port:u,remark:a,scv:m,server:c,sni:g(w(i,"sni")),tfo:l,udp:f,underlyingProxy:p,userId:g(w(i,"uuid"))});break}default:continue}y.id=n,e.push(y),n+=1}}function gi(t){let e=[],s=[],r;for(let n of t.split(/\r?\n/)){let i=n.trim(),o=/^\[(.*)\]$/.exec(i);if(o){r={lines:[],name:o[1].trim()},e.push(r);continue}i===""||i.startsWith("#")||i.startsWith(";")||(r?r.lines.push(i):s.push(i))}return s.length>0&&e.unshift({lines:s,name:"Proxy"}),e}function zr(t,e){let s=[];for(let r of t)r.name===e&&s.push(...r.lines);return s}function yi(t,e,s){for(let r=e;r<t.length;r+=1){let n=T(t[r]),i=n.indexOf("=");i!==-1&&(s[T(n.slice(0,i))]=T(n.slice(i+1)))}}function Zr(t,e){let s=t;s.includes("[Proxy]")&&(s=s.replace(/^[\s\S]*?\[/,"["));let r=gi(s),n=zr(r,"Proxy");if(n.length===0)return!1;let i=e.length,o=e.length;for(let a of n){let c=/^(.*?)\s*=\s*(.*)$/.exec(a);if(!c)continue;let u=c[1],p=c[2],f=Q(p,",");if(f.length<3)continue;let l=pe(),m="",y="",d="",h="",v="",b="",S="",$="",k="",N="",O="tcp",I="",R="",U="",Z="",E="",W="1",V,x,ee,lt;switch(f[0].toLowerCase()){case"direct":case"reject":case"reject-tinygif":continue;case"custom":{if(f.length<5||(m=T(f[1]),y=T(f[2]),y==="0"))continue;d=T(f[3]),v=T(f[4]);for(let M=6;M<f.length;M+=1){let D=Q(f[M],"=");if(D.length<2)continue;let _=T(D[0]),P=T(D[1]);_==="obfs"?(b="simple-obfs",$=P):_==="obfs-host"?k=P:_==="udp-relay"?V=H(P):_==="tfo"&&(x=H(P))}b!==""&&(S=`obfs=${$}`,S+=k===""?"":`;obfs-host=${k}`),ae(l,{group:L.ss,method:d,password:v,plugin:b,pluginOption:S,port:y,remark:u,scv:ee,server:m,tfo:x,udp:V});break}case"ss":{if(m=T(f[1]),y=T(f[2]),y==="0")continue;for(let M=3;M<f.length;M+=1){let D=Q(f[M],"=");if(D.length<2)continue;let _=T(D[0]),P=T(D[1]);_==="encrypt-method"?d=P:_==="password"?v=P:_==="obfs"?(b="simple-obfs",$=P):_==="obfs-host"?k=P:_==="udp-relay"?V=H(P):_==="tfo"&&(x=H(P))}b!==""&&(S=`obfs=${$}`,S+=k===""?"":`;obfs-host=${k}`),ae(l,{group:L.ss,method:d,password:v,plugin:b,pluginOption:S,port:y,remark:u,scv:ee,server:m,tfo:x,udp:V});break}case"socks5":{if(m=T(f[1]),y=T(f[2]),y==="0")continue;f.length>=5&&(h=T(f[3]),v=T(f[4]));for(let M=5;M<f.length;M+=1){let D=Q(f[M],"=");if(D.length<2)continue;let _=T(D[0]),P=T(D[1]);_==="udp-relay"?V=H(P):_==="tfo"?x=H(P):_==="skip-cert-verify"&&(ee=H(P))}ot(l,{group:L.socks,password:v,port:y,remark:u,scv:ee,server:m,tfo:x,udp:V,username:h});break}case"vmess":{if(m=T(f[1]),y=T(f[2]),y==="0")continue;O="tcp",d="auto";for(let M=3;M<f.length;M+=1){let D=Q(f[M],"=");if(D.length!==2)continue;let _=T(D[0]),P=T(D[1]);switch(_){case"username":N=P;break;case"ws":O=P==="true"?"ws":"tcp";break;case"tls":I=P==="true"?"tls":"";break;case"ws-path":Z=P;break;case"obfs-host":R=P;break;case"ws-headers":{let Pt=Q(P,"|");for(let Ve of Pt){let Pe=Q(T(Ve),":");Pe.length===2&&(/host/i.test(Pe[0])?R=xs(Pe[1]):/edge/i.test(Pe[0])&&(U=xs(Pe[1])))}break}case"udp-relay":V=H(P);break;case"tfo":x=H(P);break;case"skip-cert-verify":ee=H(P);break;case"tls13":lt=H(P);break;case"vmess-aead":W=P==="true"?"0":"1";break;default:break}}$e(l,{add:m,aid:W,cipher:d,edge:U,group:L.v2ray,host:R,id:N,net:O,path:Z,port:y,remark:u,scv:ee,tfo:x,tls:I,tls13:lt,udp:V});break}case"http":{if(m=T(f[1]),y=T(f[2]),y==="0")continue;for(let M=3;M<f.length;M+=1){let D=Q(f[M],"=");if(D.length<2)continue;let _=T(D[0]),P=T(D[1]);_==="username"?h=P:_==="password"?v=P:_==="skip-cert-verify"&&(ee=H(P))}at(l,{group:L.http,password:v,port:y,remark:u,scv:ee,server:m,tfo:x,tls:!1,username:h});break}case"trojan":{if(m=T(f[1]),y=T(f[2]),y==="0")continue;for(let M=3;M<f.length;M+=1){let D=Q(f[M],"=");if(D.length!==2)continue;let _=T(D[0]),P=T(D[1]);_==="password"?v=P:_==="sni"?R=P:_==="udp-relay"?V=H(P):_==="tfo"?x=H(P):_==="skip-cert-verify"&&(ee=H(P))}Ct(l,{group:L.trojan,host:R,password:v,port:y,remark:u,scv:ee,server:m,tfo:x,tlsSecure:!0,udp:V});break}case"snell":{if(m=T(f[1]),y=T(f[2]),y==="0")continue;for(let M=3;M<f.length;M+=1){let D=Q(f[M],"=");if(D.length!==2)continue;let _=T(D[0]),P=T(D[1]);_==="psk"?v=P:_==="obfs"?b=P:_==="obfs-host"?R=P:_==="udp-relay"?V=H(P):_==="tfo"?x=H(P):_==="skip-cert-verify"?ee=H(P):_==="version"&&(E=P)}tr(l,{group:L.snell,host:R,obfs:b,password:v,port:y,remark:u,scv:ee,server:m,tfo:x,udp:V,version:Y(E)});break}case"wireguard":{let M="",D="";for(let Ve=1;Ve<f.length;Ve+=1){let Pe=Q(T(f[Ve]),"=");if(Pe.length!==2)continue;let sr=T(Pe[0]),rr=T(Pe[1]);sr==="section-name"?M=rr:sr==="test-url"&&(D=rr)}if(M==="")continue;let _=zr(r,`WireGuard ${M}`);if(_.length===0)continue;let P={};yi(_,0,P);let Pt=[];if(P["dns-server"])for(let Ve of Q(P["dns-server"],","))Pt.push(T(Ve));fn(l,{dnsServers:Pt,group:L.wireguard,keepAlive:P.keepalive??"",mtu:P.mtu??"",port:"0",privateKey:P["private-key"]??"",remark:u,selfIp:P["self-ip"]??"",selfIpv6:P["self-ip-v6"]??"",server:"",testUrl:D,udp:V}),wi(l,P.peer??"");break}case"anytls":{if(m=T(f[1]),y=T(f[2]),y==="0")continue;for(let M=3;M<f.length;M+=1){let D=Q(f[M],"=");if(D.length!==2)continue;let _=T(D[0]),P=T(D[1]);_==="password"?v=P:_==="sni"?R=P:_==="udp-relay"?V=H(P):_==="tfo"?x=H(P):_==="skip-cert-verify"&&(ee=H(P))}gs(l,{group:L.anytls,password:v,port:y,remark:u,scv:ee,server:m,sni:R,tfo:x,udp:V});break}default:{if(!bi(u,f,l,{scv:ee,tfo:x,tls13:lt,udp:V}))continue;break}}l.id=o,e.push(l),o+=1}return e.length>i}function bi(t,e,s,r){let n=t.toLowerCase(),i=e[0],o=i.lastIndexOf(":"),a=T(i.slice(0,o)),c=T(i.slice(o+1));if(c==="0")return!1;let u="",p="",f="",l="",m="",y="",d="",h="",v="",b="",S="",$="tcp",k="",N="1",O=t,I=r.udp,R=r.tfo,U=r.scv,Z=r.tls13,E={};for(let W=1;W<e.length;W+=1){let V=Q(T(e[W]),"=");V.length===2&&(E[T(V[0])]=T(V[1]))}if(n==="shadowsocks"){if(u=E.method??"",p=E.password??"",E.tag&&(O=E.tag),v=E["ssr-protocol"]??"",b=E["ssr-protocol-param"]??"",E.obfs){let V=E.obfs;V==="http"||V==="tls"?(y="simple-obfs",d=V):V==="wss"||V==="ws"?(V==="wss"&&(S="tls"),d="websocket",y="v2ray-plugin"):d=V}h=E["obfs-host"]??"",m=E["obfs-uri"]??"",O===""&&(O=`${a}:${c}`);let W="";return y==="simple-obfs"?(W=`obfs=${d}`,h!==""&&(W+=`;obfs-host=${h}`)):y==="v2ray-plugin"&&(h===""&&!/^\d+(\.\d+){3}$/.test(a)&&!a.includes(":")&&(h=a),W=`mode=${d}`,h!==""&&(W+=`;host=${h}`),m!==""&&(W+=`;path=${m}`),W+=`;${S}`),v!==""?Ye(s,{group:L.ssr,method:u,obfs:d,obfsParam:h,password:p,port:c,protocol:v,protocolParam:b,remark:O,scv:U,server:a,tfo:R,udp:I}):ae(s,{group:L.ss,method:u,password:p,plugin:y,pluginOption:W,port:c,remark:O,scv:U,server:a,tfo:R,tls13:Z,udp:I}),!0}if(n==="vmess"){if($="tcp",u=E.method??"",k=E.password??"",E.tag&&(O=E.tag),E.obfs){let W=E.obfs;W==="ws"?$="ws":W==="over-tls"?S="tls":W==="wss"&&($="ws",S="tls")}return l=E["obfs-host"]??"",m=E["obfs-uri"]??"",E["over-tls"]&&(S=E["over-tls"]==="true"?"tls":""),E.aead&&(N=E.aead==="true"?"0":"1"),O===""&&(O=`${a}:${c}`),$e(s,{add:a,aid:N,cipher:u,group:L.v2ray,host:l,id:k,net:$,path:m,port:c,remark:O,scv:U,tfo:R,tls:S,tls13:Z,udp:I}),!0}return n==="trojan"?(p=E.password??"",E.tag&&(O=E.tag),E["over-tls"]&&(S=E["over-tls"]),l=E["tls-host"]??"",E["tls-verification"]==="false"&&(U=!0),O===""&&(O=`${a}:${c}`),Ct(s,{group:L.trojan,host:l,password:p,port:c,remark:O,scv:U,server:a,tfo:R,tls13:Z,tlsSecure:S==="true",udp:I}),!0):n==="http"?(f=E.username??"",p=E.password??"",E.tag&&(O=E.tag),E["over-tls"]&&(S=E["over-tls"]),E["tls-verification"]==="false"&&(U=!0),O===""&&(O=`${a}:${c}`),f==="none"&&(f=""),p==="none"&&(p=""),at(s,{group:L.http,password:p,port:c,remark:O,scv:U,server:a,tfo:R,tls:S==="true",tls13:Z,username:f}),!0):n==="anytls"?(p=E.password??"",E.tag&&(O=E.tag),l=E.sni??"",E["tls-verification"]==="false"&&(U=!0),O===""&&(O=`${a}:${c}`),gs(s,{group:L.anytls,password:p,port:c,remark:O,scv:U,server:a,sni:l,tfo:R,udp:I}),!0):!1}function xs(t){let e=T(t);return(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1)),e}function wi(t,e){let s=[...e.matchAll(/\((.*?)\)/g)].map(i=>i[1]);if(s.length===0)return;let n=[...s[0].matchAll(/([a-z-]+)\s?=\s?([^" ),]+|".*?"),?\s?/g)];for(let i of n){let o=i[1],a=i[2];switch(o){case"public-key":t.publicKey=a;break;case"endpoint":{let c=a.lastIndexOf(":");t.hostname=a.slice(0,c),t.port=Y(a.slice(c+1));break}case"client-id":t.clientId=a;break;case"allowed-ips":t.allowedIps=xs(a);break;default:break}}}function vi(t,e){try{let s=Xs(t);if(s&&typeof s=="object"&&(w(s,"Proxy")!==void 0||w(s,"proxies")!==void 0))return mi(s,e),!0}catch{return!1}return!1}function Si(t,e){if(t.includes('"version"'))ki(t,e);else if(t.includes('"serverSubscribes"'))xr(t,e);else if(t.includes('"uiItem"')||t.includes("vnext"))Ii(t,e);else if(t.includes('"proxy_apps"'))$i(t,e);else if(t.includes('"idInUse"'))Ai(t,e);else if(t.includes('"local_address"')&&t.includes('"local_port"'))xr(t,e);else if(t.includes('"ModeFileNameType"'))Ni(t,e);else return!1;return e.length>0}function ki(t,e){let s;try{s=JSON.parse(t)}catch{return}if(s===null||typeof s!="object")return;let r="version"in s&&"servers"in s?"servers":"configs";if(!(r in s))return;let n=g(s.remarks),i=s[r];if(!Array.isArray(i))return;let o=e.length;for(let a of i){let c=g(a.remarks),u=g(a.server_port);if(u==="0")continue;let p=g(a.server),f=pe();ae(f,{group:n,method:g(a.method),password:g(a.password),plugin:g(a.plugin),pluginOption:g(a.plugin_opts),port:u,remark:c===""?`${p}:${u}`:c,server:p}),f.id=o,e.push(f),o+=1}}function $i(t,e){let s;try{s=JSON.parse(`{"nodes":${t}}`)}catch{return}if(s===null||typeof s!="object"||!Array.isArray(s.nodes))return;let r=e.length;for(let n of s.nodes){let i=g(n.server);if(i==="")continue;let o=g(n.server_port);if(o==="0"||o==="")continue;let a=g(n.remarks),c=pe();ae(c,{group:L.ss,method:g(n.method),password:g(n.password),plugin:g(n.plugin),pluginOption:g(n.plugin_opts),port:o,remark:a===""?`${i}:${o}`:a,server:i}),c.id=r,e.push(c),r+=1}}function xr(t,e){let s;try{s=JSON.parse(t)}catch{return}if(s===null||typeof s!="object")return;let r=e.length;if("local_port"in s&&"local_address"in s){let i=pe(),o=g(s.server),a=g(s.server_port),c=`${o}:${a}`,u=g(s.method),p=g(s.obfs),f=g(s.protocol),l=g(s.password);ms(u,p,f)?ae(i,{group:L.ss,method:u,password:l,plugin:g(s.plugin),pluginOption:g(s.plugin_opts),port:a,remark:c,server:o}):Ye(i,{group:L.ssr,method:u,obfs:p,obfsParam:g(s.obfs_param),password:l,port:a,protocol:f,protocolParam:g(s.protocol_param),remark:c,server:o}),i.id=r,e.push(i);return}let n=s.configs??[];if(Array.isArray(n))for(let i of n){let o=g(i.group)===""?L.ssr:g(i.group),a=g(i.server),c=g(i.server_port);if(c==="0"||c==="")continue;let u=g(i.remarks)===""?`${a}:${c}`:g(i.remarks),p=pe();Ye(p,{group:o,method:g(i.method),obfs:g(i.obfs),obfsParam:g(i.obfsparam),password:g(i.password),port:c,protocol:g(i.protocol),protocolParam:g(i.protocolparam),remark:u,server:a}),p.id=r,e.push(p),r+=1}}function Ii(t,e){let s;try{s=JSON.parse(t)}catch{return}if(s===null||typeof s!="object")return;let r=e.length;if("outbounds"in s){let a=s.outbounds;if(Array.isArray(a)&&a.length>0&&a[0]?.settings?.vnext?.length>0){let c=a[0].settings.vnext[0],u=g(c.address),p=g(c.port);if(p==="0")return;let f=c.users,l=Array.isArray(f)&&f.length?g(f[0].id):"",m=Array.isArray(f)&&f.length?g(f[0].alterId):"",y=Array.isArray(f)&&f.length?g(f[0].security):"",d=a[0].streamSettings??{},h=g(d.network),v=g(d.security),b="",S="",$="",k="";if(h==="ws"){let I=d.wsSettings??{};b=g(I.path),I.headers&&(S=g(I.headers.Host),$=g(I.headers.Edge))}let N=d.tcpSettings;N&&N.header&&(k=g(N.header.type),k==="http"&&N.header.request&&(Array.isArray(N.header.request.path)&&N.header.request.path.length&&(b=g(N.header.request.path[0])),N.header.request.headers&&(S=g(N.header.request.headers.Host),$=g(N.header.request.headers.Edge))));let O=pe();$e(O,{add:u,aid:m,cipher:y,edge:$,group:L.v2ray,host:S,id:l,net:h,path:b,port:p,remark:`${u}:${p}`,tls:v,type:k}),e.push(O)}return}let n=new Map,i=s.subItem??[];for(let a of i)n.set(g(a.id),g(a.remarks));let o=s.vmess??[];for(let a of o){if(a.address===null||a.address===void 0||a.port===null||a.id===null)continue;let c=g(a.remarks),u=g(a.address),p=g(a.port);if(p==="0"||p==="")continue;let f=g(a.subid),l="";f!==""&&(l=n.get(f)??""),c===""&&(c=`${u}:${p}`);let m=H(a.allowInsecure),y=Y(a.configType),d=pe();if(y===1)$e(d,{add:u,aid:g(a.alterId),cipher:g(a.security),group:l||L.v2ray,host:g(a.requestHost),id:g(a.id),net:g(a.network),path:g(a.path),port:p,remark:c,scv:m,sni:g(a.sni),tls:g(a.streamSecurity),type:g(a.headerType)});else if(y===3)ae(d,{group:l||L.ss,method:g(a.security),password:g(a.id),port:p,remark:c,scv:m,server:u});else if(y===4)ot(d,{group:l||L.socks,port:p,remark:c,scv:m,server:u});else continue;d.id=r,e.push(d),r+=1}}function Ai(t,e){let s;try{s=JSON.parse(t)}catch{return}if(s===null||typeof s!="object"||!Array.isArray(s.configs))return;let r=e.length;for(let n of s.configs){let i=g(n.group),o=g(n.server),a=g(n.server_port);if(a==="0"||a==="")continue;let c=g(n.remarks)===""?`${o}:${a}`:g(n.remarks),u=g(n.password),p=pe(),f=Y(n.type);if(f===5)ot(p,{group:i,password:u,port:a,remark:c,server:o,username:g(n.username)});else if(f===6){let l=g(n.protocol),m=g(n.obfs),y=g(n.method);ms(y,m,l)?ae(p,{group:i,method:y,password:u,port:a,remark:c,server:o}):Ye(p,{group:i,method:y,obfs:m,obfsParam:g(n.obfsparam),password:u,port:a,protocol:l,protocolParam:g(n.protocolparam),remark:c,server:o})}else continue;p.id=r,e.push(p),r+=1}}function Ni(t,e){let s;try{s=JSON.parse(t)}catch{return}if(s===null||typeof s!="object"||!Array.isArray(s.Server))return;let r=e.length;for(let n of s.Server){let i=pe();mn(`Netch://${an(JSON.stringify(n))}`,i),i.id=r,e.push(i),r+=1}}function Oi(t){return t.startsWith("http://")||t.startsWith("https://")}function Me(t,e){let s=new RegExp(e).exec(t);return s?s.slice():null}function Ei(t,e){if(/^vmess:\/\/[A-Za-z0-9-_]+\?.*/.test(t)){Pi(t,e);return}if(/^vmess:\/\/.*?@.*/.test(t)){Ci(t,e);return}if(/^vmess1:\/\/.*?\?.*/.test(t)){Ti(t,e);return}let s=re(t.replace(/(vmess|vmess1):\/\//,""));if(/.*?\s=\s.*/.test(s)){Li(s,e);return}let r;try{let h=JSON.parse(s);if(h===null||typeof h!="object")return;r=h}catch{return}let n="1";r.v!==void 0&&(n=String(r.v));let i=String(r.ps??""),o=String(r.add??""),a=String(r.port??"");if(a==="0"||a==="")return;let c=String(r.type??""),u=String(r.id??""),p=String(r.aid??""),f=String(r.net??""),l=String(r.tls??""),m=String(r.host??""),y=String(r.sni??""),d="";switch(Y(n)){case 1:{if(m!==""){let h=Q(m,";");h.length===2&&(m=h[0],d=h[1])}break}case 2:{d=String(r.path??"");break}default:break}o=T(o),$e(e,{add:o,aid:p,cipher:"auto",group:L.v2ray,host:m,id:u,net:f,path:d,port:a,remark:i,sni:y,tls:l,type:c})}function Ci(t,e){let s=t.slice(8),r="",n=s.lastIndexOf("#");n!==-1&&(r=q(s.slice(n+1)),s=s.slice(0,n));let o=/^([a-z]+)(?:\+([a-z]+))?:([\da-f]{4}(?:[\da-f]{4}-){4}[\da-f]{12})-(\d+)@(.+):(\d+)(?:\/?\?(.*))?$/.exec(s);if(!o)return;let a=o[1],c=o[2]??"",u=o[3],p=o[4],f=o[5],l=o[6],m=o[7]??"",y="",d="",h="";switch(a){case"tcp":case"kcp":y=A(m,"type");break;case"http":case"ws":d=A(m,"host"),h=A(m,"path");break;case"quic":y=A(m,"security"),d=A(m,"type"),h=A(m,"key");break;default:return}r===""&&(r=`${f}:${l}`),$e(e,{add:f,aid:p,cipher:"auto",group:L.v2ray,host:d,id:u,net:a,path:h,port:l,remark:r,tls:c,type:y})}function Pi(t,e){let s=t.slice(8),r="tcp",n=s.indexOf("?"),i=n>=0?s.slice(n+1):"";s=n>=0?s.slice(0,n):s;let o=Me(re(s),"(.*?):(.*)@(.*):(.*)");if(!o)return;let a=o[1],c=o[2],u=o[3],p=o[4];if(p==="0")return;let f=q(A(i,"remarks")),l=A(i,"obfs"),m="",y="",d="";l!==""?l==="websocket"&&(r="ws",m=A(i,"obfsParam"),y=A(i,"path")):(r=A(i,"network"),m=A(i,"wsHost"),y=A(i,"wspath"));let h=A(i,"tls")==="1"?"tls":"",v=A(i,"aid");v===""&&(v="0"),f===""&&(f=`${u}:${p}`),$e(e,{add:u,aid:v,cipher:a,group:L.v2ray,host:m,id:c,net:r,path:y,port:p,remark:f,tls:h,type:d})}function Ti(t,e){let s=t.slice(9),r="",n="",i=s.indexOf("#");i!==-1&&(r=s.slice(i+1),s=s.slice(0,i));let o=s.indexOf("?"),a=o>=0?s.slice(o+1):"";s=o>=0?s.slice(0,o):s;let c=Me(s,"(.*?)@(.*):(.*)");if(!c)return;let u=c[1],p=c[2],f=c[3],l=f.indexOf("/");if(l!==-1&&(n=f.slice(l),f=f.slice(0,l)),f==="0")return;let m=A(a,"network"),y=A(a,"tls")==="true"?"tls":"",d=A(a,"ws.host");r===""&&(r=`${p}:${f}`),$e(e,{add:p,aid:"0",cipher:"auto",group:L.v2ray,host:d,id:u,net:m,path:n,port:f,remark:r,tls:y,type:""})}function Li(t,e){let s=t.replace(/(.*?)\s=\s(.*)/,"$1,$2"),r=Q(s,",");if(r.length<6||r[1]!=="vmess")return;let n=T(r[0]),i=T(r[2]),o=T(r[3]);if(o==="0")return;let a=T(r[4]),c=T(r[5].replace(/"/g,"")),u=L.v2ray,p="",f="",l="",m="tcp",y="";for(let d=6;d<r.length;d+=1){let h=Q(r[d],"=");if(h.length<2)continue;let v=T(h[0]),b=T(h.slice(1).join("="));switch(v){case"group":u=b;break;case"over-tls":p=b==="true"?"tls":"";break;case"tls-host":f=b;break;case"obfs-path":l=b.replace(/"/g,"");break;case"obfs-header":{let S=Q(b.replace(/"/g,"").replace(/\[Rr\]\[Nn\]/g,"|"),"|");for(let $ of S)/Host: /i.test($)?f=$.slice(6):/Edge: /i.test($)&&(y=$.slice(6));break}case"obfs":b==="ws"&&(m="ws");break;default:break}}l===""&&(l="/"),$e(e,{add:i,aid:"0",cipher:a,edge:y,group:u,host:f,id:c,net:m,path:l,port:o,remark:n,tls:p,type:"none"})}function Ri(t,e){let s=t.slice(5).replace(/\/\?/g,"?"),r=L.ss,n="",i="",o="",a="",c=r,u=s.indexOf("#");u!==-1&&(n=q(s.slice(u+1)),s=s.slice(0,u));let p=s.indexOf("?");if(p!==-1){i=s.slice(p+1);let d=q(A(i,"plugin")),h=d.indexOf(";");o=h===-1?d:d.slice(0,h),a=h===-1?"":d.slice(h+1);let v=A(i,"group");v!==""&&(c=re(v)),s=s.slice(0,p)}let f="",l="",m="",y="";if(s.includes("@")){let d=Me(s,"(\\S+?)@(\\S+):(\\d+)");if(!d)return;let h=d[1];m=d[2],y=d[3];let v=Me(re(h),"(\\S+?):(\\S+)");if(!v)return;f=v[1],l=v[2]}else{let d=Me(re(s),"(\\S+?):(\\S+)@(\\S+):(\\d+)");if(!d)return;f=d[1],l=d[2],m=d[3],y=d[4]}y!=="0"&&(n===""&&(n=`${m}:${y}`),ae(e,{group:c,method:f,password:l,plugin:o,pluginOption:a,port:y,remark:n,server:m}))}function _i(t,e){let s=t.slice(6).replace(/\r/g,"");s=re(s);let r="",n="",i="",o="",a=s.indexOf("/?");if(a!==-1){let v=s.slice(a+2);s=s.slice(0,a),r=re(A(v,"group")),n=re(A(v,"remarks")),i=re(A(v,"obfsparam")).replace(/\s/g,""),o=re(A(v,"protoparam")).replace(/\s/g,"")}let c=Me(s,"(\\S+):(\\d+?):(\\S+?):(\\S+?):(\\S+?):(\\S+)");if(!c)return;let u=c[1],p=c[2],f=c[3],l=c[4],m=c[5],y=re(c[6]);if(p==="0")return;let d=r===""?L.ssr:r,h=n===""?`${u}:${p}`:n;ms(l,m,f)?ae(e,{group:d,method:l,password:y,port:p,remark:h,server:u}):Ye(e,{group:d,method:l,obfs:m,obfsParam:i,password:y,port:p,protocol:f,protocolParam:o,remark:h,server:u})}function Fi(t,e){let s=e.length,r=re(t.slice(6)),n;try{n=JSON.parse(r)}catch{return}if(n===null||typeof n!="object"||!("servers"in n))return;let i=String(n.airport??""),o=n.servers,a;if(Array.isArray(o))a=o;else if(o!==null&&typeof o=="object")a=Object.keys(o).map(c=>o[c]);else return;for(let c of a){if(c===null||typeof c!="object")continue;let u=String(c.server??""),p=String(c.port??n.port??"");if(u===""||p===""||p==="0")continue;let f=String(c.remarks??""),l=String(c.encryption??n.encryption??""),m=String(c.password??n.password??""),y=String(c.plugin??n.plugin??""),d=String(c.plugin_options??n.plugin_options??""),h=pe();ae(h,{group:i,method:l,password:m,plugin:y,pluginOption:d,port:p,remark:f,server:u}),h.id=s,e.push(h),s+=1}}function Mi(t,e){let s="",r="",n="",i="",o="",a="";if(t.includes("socks://")){let c=t,u=c.indexOf("#");if(u!==-1&&(r=q(c.slice(u+1)),c=c.slice(0,u)),c=re(c.slice(8)),c.includes("@")){let f=Q(c,"@");if(f.length<2)return;c=f[1];let l=Q(f[0],":");if(l.length<2)return;o=l[0],a=l[1]}let p=Q(c,":");if(p.length<2)return;n=p[0],i=p[1]}else(t.includes("https://t.me/socks")||t.includes("tg://socks"))&&(n=A(t,"server"),i=A(t,"port"),o=q(A(t,"user")),a=q(A(t,"pass")),r=q(A(t,"remarks")),s=q(A(t,"group")));s===""&&(s=L.socks),r===""&&(r=`${n}:${i}`),!(i==="0"||i==="")&&ot(e,{group:s,password:a,port:i,remark:r,server:n,username:o})}function Di(t,e){let s=A(t,"server"),r=A(t,"port"),n=q(A(t,"user")),i=q(A(t,"pass")),o=q(A(t,"remarks")),a=q(A(t,"group"));a===""&&(a=L.http),o===""&&(o=`${s}:${r}`),!(r==="0"||r==="")&&at(e,{group:a,password:i,port:r,remark:o,server:s,tls:t.includes("/https"),username:n})}function ji(t,e){let s=t,r="",n="",i=s.includes("https://"),o=s.indexOf("?");if(o!==-1){let f=s.slice(o+1);s=s.slice(0,o),r=q(A(f,"remarks")),n=q(A(f,"group"))}s=s.slice(s.indexOf("://")+3),s=re(s);let a="",c="",u="",p="";if(s.includes("@")){let f=Me(s,"(.*?):(.*?)@(.*):(.*)");if(!f)return;u=f[1],p=f[2],a=f[3],c=f[4]}else{let f=Me(s,"(.*):(.*)");if(!f)return;a=f[1],c=f[2]}n===""&&(n=L.http),r===""&&(r=`${a}:${c}`),c!=="0"&&at(e,{group:n,password:p,port:c,remark:r,server:a,tls:i,username:u})}function Bi(t,e){let s=t.slice(9),r="",n="",i="",o="",a="",c=s.lastIndexOf("#");c!==-1&&(r=q(s.slice(c+1)),s=s.slice(0,c));let u=s.indexOf("?");u!==-1&&(n=s.slice(u+1),s=s.slice(0,u));let p=Me(s,"(.*?)@(.*):(.*)");if(!p)return;let f=p[1],l=p[2],m=p[3];if(m==="0")return;i=A(n,"sni"),i===""&&(i=A(n,"peer"));let y=A(n,"tfo"),d=q(A(n,"group"));A(n,"ws")==="1"?(o=A(n,"wspath"),a="ws"):A(n,"type")==="ws"&&(o=A(n,"path"),o.startsWith("%2F")&&(o=q(o)),a="ws");let h=A(n,"type"),v=A(n,"sni"),b=A(n,"allowInsecure");r===""&&(r=`${l}:${m}`),Ct(e,{group:d===""?L.trojan:d,host:i,network:a,password:f,path:o,port:m,remark:r,scv:b===""?void 0:Je(b),server:l,sni:v,tfo:y===""?void 0:Je(y),tlsSecure:h!==""||!0})}function Je(t){let e=t.trim().toLowerCase();if(["1","true","yes","on"].includes(e))return!0;if(["0","false","no","off"].includes(e))return!1}function Ui(t,e){let s=t.replace(/(hysteria2|hy2):\/\//,"hysteria2://").replace(/\/\?/g,"?");/hysteria2:\/\/.*?[:].*/.test(s)&&Ki(s,e)}function Ki(t,e){let s=t.slice(12),r="",n="",i=s.lastIndexOf("#");i!==-1&&(r=q(s.slice(i+1)),s=s.slice(0,i));let o=s.lastIndexOf("?");o!==-1&&(n=s.slice(o+1),s=s.slice(0,o));let a="",c="",u="";if(s.includes("@")){let k=/^(.*?)@(.*)[:](\d+)$/.exec(s);if(!k)return;a=k[1],c=k[2],u=k[3]}else{if(a=A(n,"password"),a===""||!s.includes(":"))return;let k=/^(.*)[:](\d+)$/.exec(s);if(!k)return;c=k[1],u=k[2]}let p=A(n,"insecure"),f=A(n,"up"),l=A(n,"down"),m=A(n,"alpn"),y=A(n,"obfs"),d=A(n,"obfs-password"),h=A(n,"sni"),v=A(n,"pinSHA256"),b=A(n,"mport"),S=A(n,"ports"),$=S!==""?S:b!==""?b:u;r===""&&(r=`${c}:${u}`),pn(e,{alpn:m,down:l,fingerprint:v,group:L.hysteria2,obfs:y,obfsPassword:d,password:a,port:u,ports:$,remark:r,scv:p===""?void 0:Je(p),server:c,sni:h,up:f})}function Gi(t,e){let s=t.slice(9),r="",n="",i=s.lastIndexOf("#");i!==-1&&(r=q(s.slice(i+1)),s=s.slice(0,i));let o=s.lastIndexOf("?");o!==-1&&(n=s.slice(o+1),s=s.slice(0,o));let a=/^(.*?)@(.*)[:](\d+)$/.exec(s);if(!a)return;let c=a[1],u=a[2],p=a[3];if(p==="0")return;let f=A(n,"sni"),l=A(n,"udp"),m=A(n,"insecure");r===""&&(r=`${u}:${p}`),gs(e,{group:L.anytls,password:c,port:p,remark:r,scv:m===""?void 0:Je(m),server:u,sni:f,udp:l===""?void 0:Je(l)})}function Vi(t,e){let s=t.slice(8),r="",n="",i=s.lastIndexOf("#");i!==-1&&(r=q(s.slice(i+1)),s=s.slice(0,i));let o=s.indexOf("?");o!==-1&&(n=s.slice(o+1),s=s.slice(0,o));let a=/^(.*?)@\[?(.*?)\]?:(\d+)$/.exec(s);if(!a)return;let c=a[1],u=a[2],p=a[3];if(p==="0")return;let f=A(n,"type"),l=A(n,"security"),m=A(n,"host"),y=q(A(n,"path")),d=q(A(n,"serviceName")),h=y!==""?y:d,v=A(n,"sni"),b=A(n,"flow"),S=A(n,"fp"),$=A(n,"pbk"),k=A(n,"sid"),N=A(n,"alpn");r===""&&(r=`${u}:${p}`),dn(e,{alpn:N===""?void 0:N.split(","),fingerprint:S,flow:b,group:L.v2ray,host:m,network:f,path:h,port:p,publicKey:$,remark:r,scv:A(n,"allowInsecure")===""?void 0:Je(A(n,"allowInsecure")),server:u,shortId:k,sni:v,tls:l,userId:c})}function qi(t,e){let s=t.slice(7),r="",n="",i=s.lastIndexOf("#");i!==-1&&(r=q(s.slice(i+1)),s=s.slice(0,i));let o=s.indexOf("?");o!==-1&&(n=s.slice(o+1),s=s.slice(0,o));let a=/^(.*?):(.*?)@\[?(.*?)\]?:(\d+)$/.exec(s);if(!a)return;let c=a[1],u=a[2],p=a[3],f=a[4];if(f==="0")return;let l=A(n,"congestion_control")||A(n,"congestion-controller"),m=A(n,"alpn"),y=A(n,"sni");r===""&&(r=`${p}:${f}`),hn(e,{alpn:m===""?void 0:m.split(","),congestionControl:l,group:L.v2ray,password:u,port:f,remark:r,scv:A(n,"allow_insecure")===""?void 0:Je(A(n,"allow_insecure")),server:p,sni:y,userId:c})}function Wi(t,e){ie(t,"ssr://")?_i(t,e):ie(t,"vmess://")||ie(t,"vmess1://")?Ei(t,e):ie(t,"ss://")?Ri(t,e):ie(t,"socks://")||ie(t,"https://t.me/socks")||ie(t,"tg://socks")?Mi(t,e):ie(t,"https://t.me/http")||ie(t,"tg://http")?Di(t,e):ie(t,"Netch://")?mn(t,e):ie(t,"trojan://")?Bi(t,e):ie(t,"vless://")?Vi(t,e):ie(t,"tuic://")?qi(t,e):t.includes("hysteria2://")||t.includes("hy2://")?Ui(t,e):ie(t,"anytls://")?Gi(t,e):Oi(t)&&ji(t,e)}function Hi(t,e){let s=!1;if(ie(t,"ssd://")&&(Fi(t,e),s=!0),!s&&/"?(Proxy|proxies)"?:/.test(t)&&vi(t,e)&&(s=!0),!s&&Zr(t,e)&&(s=!0),s)return;let r=re(t);if(/(vmess|shadowsocks|http|trojan)\s*?=/.test(r)&&Zr(r,e))return;let n=e.length;en(r,e),e.length===n&&r!==t&&en(t,e)}function en(t,e){let s=t.replace(/\r\n/g,`
|
|
130
|
+
`),r=Xr(s,`
|
|
131
|
+
`)<1?Xr(s,"\r")<1?" ":"\r":`
|
|
132
|
+
`;for(let n of s.split(r)){let i=n.replace(/\r/g,"");if(i==="")continue;let o=pe();Wi(i,o),o.type!=="unknown"&&e.push(o)}}function ys(t){let e=[];return Si(t,e)||Hi(t,e),e}var Yi=["AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AS","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CW","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FM","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IR","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","YE","YT","ZA","ZM","ZW"],Zf=new Set(Yi);function gn(t){try{return new RegExp(t)}catch{return/$^/}}function er(t,e){return gn(e).test(t)}function Ji(t,e){let s=gn(e).exec(t);return s!==null&&s[0]===t}var Xi={anytls:"ANYTLS",http:"HTTP",https:"HTTPS",hysteria:"HYSTERIA",hysteria2:"HYSTERIA2",ss:"SS",ssr:"SSR",snell:"SNELL",socks5:"SOCKS5",trojan:"TROJAN",tuic:"TUIC",vless:"VLESS",vmess:"VMESS",wireguard:"WIREGUARD"};function tn(t,e){let s=t.split(","),r=!1;for(let n of s)if(/^-?\d+$/.test(n))Number.parseInt(n,10)===e&&(r=!0);else if(/^(\d+)-(\d+)$/.test(n)){let i=/^(\d+)-(\d+)$/.exec(n),o=Number.parseInt(i[1],10),a=Number.parseInt(i[2],10);e>=o&&e<=a&&(r=!0)}else if(/^!-?(\d+)$/.test(n)){r=!0;let i=/^!-?(\d+)$/.exec(n);Number.parseInt(i[1],10)===e&&(r=!1)}else if(/^!(\d+)-(\d+)$/.test(n)){r=!0;let i=/^!(\d+)-(\d+)$/.exec(n),o=Number.parseInt(i[1],10),a=Number.parseInt(i[2],10);e>=o&&e<=a&&(r=!1)}else if(/^(\d+)-$/.test(n)){let i=/^(\d+)-$/.exec(n);Number.parseInt(i[1],10)>=e&&(r=!0)}else if(/^(\d+)\+$/.test(n)){let i=/^(\d+)\+$/.exec(n);Number.parseInt(i[1],10)<=e&&(r=!0)}return r}function Qi(t,e){if(t.startsWith("!!GROUP=")){let s=/^!!(?:GROUP)=(.+?)(?:!!(.*))?$/.exec(t),r=s?.[1]??"",n=s?.[2]??"";return{matched:er(e.group,r),realRule:n}}if(t.startsWith("!!GROUPID=")||t.startsWith("!!INSERT=")){let s=/^!!(?:GROUPID|INSERT)=([\d\-+!,]+)(?:!!(.*))?$/.exec(t),r=s?.[1]??"",n=s?.[2]??"",i=t.startsWith("!!INSERT=")?-1:1;return{matched:tn(r,i*e.groupId),realRule:n}}if(t.startsWith("!!TYPE=")){let s=/^!!(?:TYPE)=(.+?)(?:!!(.*))?$/.exec(t),r=s?.[1]??"",n=s?.[2]??"";if(e.type==="unknown")return{matched:!1,realRule:n};let i=Xi[e.type]??"";return{matched:Ji(i,r),realRule:n}}if(t.startsWith("!!PORT=")){let s=/^!!(?:PORT)=(.+?)(?:!!(.*))?$/.exec(t),r=s?.[1]??"",n=s?.[2]??"";return{matched:tn(r,e.port),realRule:n}}if(t.startsWith("!!SERVER=")){let s=/^!!(?:SERVER)=(.+?)(?:!!(.*))?$/.exec(t),r=s?.[1]??"",n=s?.[2]??"";return{matched:er(e.hostname,r),realRule:n}}return{matched:!0,realRule:t}}function yn(t,e,s=!0){let r=t.replace(/=/g,"-");s&&r.includes(",")&&(r=`"${r}"`);let n=r,i=2;for(;e.includes(n);)n=`${r} ${i}`,i+=1;return n}function bn(t,e,s,r){if(t.startsWith("[]")&&r){s.push(t.slice(2));return}for(let n of e){let{matched:i,realRule:o}=Qi(t,n);i&&(o===""||er(n.remark,o))&&!s.includes(n.remark)&&s.push(n.remark)}}var zi=["origin","auth_sha1_v4","auth_aes128_md5","auth_aes128_sha1","auth_chain_a","auth_chain_b"],Zi=["plain","http_simple","http_post","random_head","tls1.2_ticket_auth","tls1.2_ticket_fastauth"],xi=["rc4-md5","aes-128-ctr","aes-192-ctr","aes-256-ctr","aes-128-cfb","aes-192-cfb","aes-256-cfb","chacha20-ietf","xchacha20","none"];function eo(t){return t.replace(/^\[+/,"").replace(/\]+$/,"")}function to(t,e,s,r,n,i){let o={name:r,port:t.port,server:eo(t.hostname)};switch(t.type){case"ss":{if(e.filterDeprecated&&t.encryptMethod==="chacha20")return;o.type="ss",o.cipher=t.encryptMethod,o.password=t.password;let a=t.pluginOption.replace(/;/g,"&");if(t.plugin==="simple-obfs"||t.plugin==="obfs-local")o.plugin="obfs",o["plugin-opts"]={host:q(A(a,"obfs-host")),mode:q(A(a,"obfs"))};else if(t.plugin==="v2ray-plugin"){o.plugin="v2ray-plugin";let c={host:A(a,"host"),mode:A(a,"mode"),mux:a.includes("mux"),path:A(a,"path"),tls:a.includes("tls")};n!==void 0&&(c["skip-cert-verify"]=n),o["plugin-opts"]=c}break}case"vmess":{switch(o.type="vmess",o.uuid=t.userId,o.alterId=t.alterId,o.cipher=t.encryptMethod,o.tls=t.tlsSecure,n!==void 0&&(o["skip-cert-verify"]=n),t.serverName!==""&&(o.servername=t.serverName),t.transferProtocol){case"tcp":break;case"ws":o.network=t.transferProtocol,e.clashNewFieldName?o["ws-opts"]={...t.host!==""||t.edge!==""?{headers:{...t.edge!==""?{Edge:t.edge}:{},...t.host!==""?{Host:t.host}:{}}}:{},path:t.path}:(o["ws-path"]=t.path,(t.host!==""||t.edge!=="")&&(o["ws-headers"]={...t.edge!==""?{Edge:t.edge}:{},...t.host!==""?{Host:t.host}:{}}));break;case"http":o.network=t.transferProtocol,o["http-opts"]={...t.host!==""||t.edge!==""?{headers:{...t.edge!==""?{Edge:[t.edge]}:{},...t.host!==""?{Host:[t.host]}:{}}}:{},method:"GET",path:[t.path]};break;case"h2":o.network=t.transferProtocol,o["h2-opts"]={...t.host!==""?{host:[t.host]}:{},path:t.path};break;case"grpc":o.network=t.transferProtocol,o.servername=t.host,o["grpc-opts"]={"grpc-service-name":t.path};break;default:return}break}case"ssr":{if(e.filterDeprecated&&(!s&&!xi.includes(t.encryptMethod)||!zi.includes(t.protocol)||!Zi.includes(t.obfs)))return;o.type="ssr",o.cipher=t.encryptMethod==="none"?"dummy":t.encryptMethod,o.password=t.password,o.protocol=t.protocol,o.obfs=t.obfs,s?(o.protocolparam=t.protocolParam,o.obfsparam=t.obfsParam):(o["protocol-param"]=t.protocolParam,o["obfs-param"]=t.obfsParam);break}case"socks5":o.type="socks5",t.username!==""&&(o.username=t.username),t.password!==""&&(o.password=t.password),n!==void 0&&(o["skip-cert-verify"]=n);break;case"http":case"https":o.type="http",t.username!==""&&(o.username=t.username),t.password!==""&&(o.password=t.password),o.tls=t.tlsSecure,n!==void 0&&(o["skip-cert-verify"]=n);break;case"trojan":switch(o.type="trojan",o.password=t.password,t.host!==""&&(o.sni=t.host),n!==void 0&&(o["skip-cert-verify"]=n),t.transferProtocol){case"tcp":break;case"grpc":o.network=t.transferProtocol,t.path!==""&&(o["grpc-opts"]={"grpc-service-name":t.path});break;case"ws":o.network=t.transferProtocol,o["ws-opts"]={...t.host!==""?{headers:{Host:t.host}}:{},path:t.path};break;default:break}break;case"snell":if(t.snellVersion>=4)return;o.type="snell",o.psk=t.password,t.snellVersion!==0&&(o.version=t.snellVersion),t.obfs!==""&&(o["obfs-opts"]={...t.host!==""?{host:t.host}:{},mode:t.obfs});break;case"wireguard":o.type="wireguard",o["public-key"]=t.publicKey,o["private-key"]=t.privateKey,o.ip=t.selfIp,t.selfIpv6!==""&&(o.ipv6=t.selfIpv6),t.preSharedKey!==""&&(o["preshared-key"]=t.preSharedKey),t.dnsServers.length>0&&(o.dns=t.dnsServers),t.mtu>0&&(o.mtu=t.mtu);break;case"hysteria":{o.type="hysteria",t.ports!==""&&(o.ports=t.ports),t.protocol!==""&&(o.protocol=t.protocol),t.obfsParam!==""&&(o["obfs-protocol"]=t.obfsParam),t.up!==""&&(o.up=t.up),t.upSpeed&&(o["up-speed"]=t.upSpeed),t.down!==""&&(o.down=t.down),t.downSpeed&&(o["down-speed"]=t.downSpeed),t.authStr!==""&&(o["auth-str"]=t.authStr,o.auth=an(t.authStr)),t.obfs!==""&&(o.obfs=t.obfs),t.sni!==""&&(o.sni=t.sni),n!==void 0&&(o["skip-cert-verify"]=n),t.fingerprint!==""&&(o.fingerprint=t.fingerprint),t.alpn.length>0&&(o.alpn=t.alpn),t.ca!==""&&(o.ca=t.ca),t.caStr!==""&&(o["ca-str"]=t.caStr),t.recvWindowConn&&(o["recv-window-conn"]=t.recvWindowConn),t.recvWindow&&(o["recv-window"]=t.recvWindow),t.disableMtuDiscovery!==void 0&&(o["disable-mtu-discovery"]=t.disableMtuDiscovery),t.tcpFastOpen!==void 0&&(o["fast-open"]=t.tcpFastOpen),t.hopInterval&&(o["hop-interval"]=t.hopInterval);break}case"hysteria2":o.type="hysteria2",t.ports!==""&&(o.ports=t.ports),t.upSpeed&&(o.up=t.upSpeed),t.downSpeed&&(o.down=t.downSpeed),t.password!==""&&(o.password=t.password),t.obfs!==""&&(o.obfs=t.obfs),t.obfsParam!==""&&(o["obfs-password"]=t.obfsParam),t.sni!==""&&(o.sni=t.sni),n!==void 0&&(o["skip-cert-verify"]=n),t.fingerprint!==""&&(o.fingerprint=t.fingerprint),t.alpn.length>0&&(o.alpn=t.alpn),t.ca!==""&&(o.ca=t.ca),t.caStr!==""&&(o["ca-str"]=t.caStr),t.cwnd&&(o.cwnd=t.cwnd),t.hopInterval&&(o["hop-interval"]=t.hopInterval);break;case"anytls":o.type="anytls",o.password=t.password,t.sni!==""&&(o.sni=t.sni),n!==void 0&&(o["skip-cert-verify"]=n);break;case"vless":if(o.type="vless",o.uuid=t.userId,t.flow!==""&&(o.flow=t.flow),o.tls=t.tlsSecure,t.serverName!==""&&(o.servername=t.serverName),t.fingerprint!==""&&(o["client-fingerprint"]=t.fingerprint),t.publicKey!==""||t.shortId!==""){let a={};t.publicKey!==""&&(a["public-key"]=t.publicKey),a["short-id"]=t.shortId,o["reality-opts"]=a}switch(t.alpn.length>0&&(o.alpn=t.alpn),n!==void 0&&(o["skip-cert-verify"]=n),t.transferProtocol){case"tcp":break;case"ws":o.network=t.transferProtocol,o["ws-opts"]={...t.host!==""?{headers:{Host:t.host}}:{},path:t.path};break;case"grpc":o.network=t.transferProtocol,o["grpc-opts"]={"grpc-service-name":t.path};break;default:break}break;case"tuic":o.type="tuic",o.uuid=t.userId,o.password=t.password,t.congestionControl!==""&&(o["congestion-controller"]=t.congestionControl),t.alpn.length>0&&(o.alpn=t.alpn),t.serverName!==""&&(o.sni=t.serverName),n!==void 0&&(o["skip-cert-verify"]=n);break;default:return}return so(t,e)&&t.type!=="snell"&&(o.udp=!0),i!==void 0&&(o.tfo=i),e.clashNewFieldName&&t.underlyingProxy!==""&&(o["dialer-proxy"]=t.underlyingProxy),o}function so(t,e){return t.udp!==void 0?t.udp:e.udp===!0}function ro(t,e,s,r=!1){let n=[],i=[],o=[];for(let u of t){let p=rn(u.type);s.appendProxyType&&(u.remark=`[${p}] ${u.remark}`);let f=yn(u.remark,o,!1);u.remark=f;let l=u.allowInsecure!==void 0?u.allowInsecure:s.skipCertVerify,m=u.tcpFastOpen!==void 0?u.tcpFastOpen:s.tfo,y=to(u,s,r,f,l,m);y&&(n.push(y),o.push(f),i.push(u))}if(s.nodeList)return{doc:{proxies:n},nodeList:i};let a=[];for(let u of e){let p={name:u.name,type:u.type==="smart"?"url-test":u.type};switch(u.type){case"select":case"relay":break;case"load-balance":p.strategy=u.strategy,p.lazy=u.lazy,p.url=u.url,u.interval>0&&(p.interval=u.interval),u.tolerance>0&&(p.tolerance=u.tolerance);break;case"smart":case"url-test":u.lazy!==void 0&&(p.lazy=u.lazy),p.url=u.url,u.interval>0&&(p.interval=u.interval),u.tolerance>0&&(p.tolerance=u.tolerance);break;case"fallback":p.url=u.url,u.interval>0&&(p.interval=u.interval),u.tolerance>0&&(p.tolerance=u.tolerance);break;default:continue}u.disableUdp!==void 0&&(p["disable-udp"]=u.disableUdp);let f=[];for(let l of u.proxies)bn(l,i,f,!0);u.usingProvider.length>0?p.use=u.usingProvider:(f.length===0&&f.push("DIRECT"),p.proxies=f),a.push(p)}let c={};return s.clashNewFieldName?(c.proxies=n,a.length>0&&(c["proxy-groups"]=a)):(c.Proxy=n,a.length>0&&(c["Proxy Group"]=a)),{doc:c,nodeList:i}}function no(t){return Qs(t,{aliasDuplicateObjects:!1,lineWidth:0})}function wn(t,e,s,r=!1){let{doc:n}=ro(t,e,s,r);return no(n)}function io(t){let e=[],s;for(let r of t.split(/\r?\n/)){let n=r,i=/^\[(.*)\]$/.exec(n.trim());if(i){s={lines:[],name:i[1].trim()},e.push(s);continue}n.trim()!==""&&s&&s.lines.push(n)}return e}function le(t){return t?"true":"false"}function sn(t,e){let s=`http, ${t.hostname}, ${t.port}`;return t.username!==""&&(s+=`, username=${t.username}`),t.password!==""&&(s+=`, password=${t.password}`),s+=`, tls=${le(t.tlsSecure)}`,e!==void 0&&(s+=`, skip-cert-verify=${le(e)}`),s}function oo(t,e=!1){let s=`public-key = ${t.publicKey}`;return s+=`, endpoint = ${t.hostname}:${t.port}`,t.preSharedKey!==""&&(s+=`, preshared-key = ${t.preSharedKey}`),t.allowedIps!==""&&(s+=`, allowed-ips = "${t.allowedIps}"`),t.keepAlive>0&&(s+=`, keepalive = ${t.keepAlive}`),t.clientId!==""&&(s+=e?`, reserved = [${t.clientId}]`:`, client-id = ${t.clientId}`),s}function ao(t,e,s,r){let n=r.version,i=[],o=[],a=[],c=new Map,u=[],p=1080;for(let l of t){s.appendProxyType&&(l.remark=`[${rn(l.type)}] ${l.remark}`);let m=yn(l.remark,i);l.remark=m;let y=l.udp!==void 0?l.udp:s.udp,d=l.tcpFastOpen!==void 0?l.tcpFastOpen:s.tfo,h=l.allowInsecure!==void 0?l.allowInsecure:s.skipCertVerify,v=l.tls13!==void 0?l.tls13:s.tls13,b="";switch(l.type){case"ss":if(n>=3||n===-3?b=`ss, ${l.hostname}, ${l.port}, encrypt-method=${l.encryptMethod}, password=${l.password}`:b=`custom, ${l.hostname}, ${l.port}, ${l.encryptMethod}, ${l.password}, https://github.com/pobizhe/SSEncrypt/raw/master/SSEncrypt.module`,l.plugin!=="")if(l.plugin==="simple-obfs"||l.plugin==="obfs-local")l.pluginOption!==""&&(b+=`,${l.pluginOption.replace(/;/g,",")}`);else continue;break;case"vmess":{if(n<4&&n!==-3)continue;b=`vmess, ${l.hostname}, ${l.port}, username=${l.userId}, tls=${le(l.tlsSecure)}, vmess-aead=${l.alterId===0?"true":"false"}`,l.tlsSecure&&v!==void 0&&(b+=`, tls13=${le(v)}`);let S=[];switch(l.transferProtocol){case"tcp":break;case"ws":{l.host===""?b+=`, ws=true, ws-path=${l.path}, sni=${l.hostname}`:b+=`, ws=true, ws-path=${l.path}, sni=${l.host}`,l.host!==""&&S.push(`Host:${l.host}`),l.edge!==""&&S.push(`Edge:${l.edge}`),S.length>0&&(b+=`, ws-headers=${S.join("|")}`);break}default:continue}h!==void 0&&(b+=`, skip-cert-verify=${le(h)}`);break}case"ssr":{if(s.surgeSsrPath===""||n<2)continue;let S=["-l",String(p),"-s",l.hostname,"-p",String(l.port),"-m",l.encryptMethod,"-k",l.password,"-o",l.obfs,"-O",l.protocol];l.obfsParam!==""&&S.push("-g",l.obfsParam),l.protocolParam!==""&&S.push("-G",l.protocolParam),b=`external, exec="${s.surgeSsrPath}", args="${S.join('", args="')}", local-port=${p}`,(ln(l.hostname)||un(l.hostname))&&(b+=`, addresses=${l.hostname}`),p+=1;break}case"socks5":b=`socks5, ${l.hostname}, ${l.port}`,l.username!==""&&(b+=`, username=${l.username}`),l.password!==""&&(b+=`, password=${l.password}`),h!==void 0&&(b+=`, skip-cert-verify=${le(h)}`);break;case"https":if(n===-3){b=`https, ${l.hostname}, ${l.port}, ${l.username}, ${l.password}`,h!==void 0&&(b+=`, skip-cert-verify=${le(h)}`);break}b=sn(l,h);break;case"http":b=sn(l,h);break;case"trojan":if(n<4&&n!==-3)continue;if(b=`trojan, ${l.hostname}, ${l.port}, password=${l.password}`,l.snellVersion!==0&&(b+=`, version=${l.snellVersion}`),l.host!==""&&(b+=`, sni=${l.host}`),l.transferProtocol==="ws"){b+=", ws=true",l.path!==""&&(b+=`, ws-path=${l.path}`);let S=l.host!==""?l.host:l.hostname;b+=`, ws-headers=Host:"${S}"`}h!==void 0&&(b+=`, skip-cert-verify=${le(h)}`);break;case"snell":b=`snell, ${l.hostname}, ${l.port}, psk=${l.password}`,l.obfs!==""&&(b+=`, obfs=${l.obfs}`,l.host!==""&&(b+=`, obfs-host=${l.host}`)),l.snellVersion!==0&&(b+=`, version=${l.snellVersion}`);break;case"wireguard":{if(n<4&&n!==-3)continue;let S=fi(l.remark).slice(0,5);b=`wireguard, section-name=${S}`,l.testUrl!==""&&(b+=`, test-url=${l.testUrl}`);let $=[`private-key = ${l.privateKey}`,`self-ip = ${l.selfIp}`];l.selfIpv6!==""&&$.push(`self-ip-v6 = ${l.selfIpv6}`),l.dnsServers.length>0&&$.push(`dns-server = ${l.dnsServers.join(",")}`),l.mtu>0&&$.push(`mtu = ${l.mtu}`),$.push(`peer = (${oo(l)})`);let k=`WireGuard ${S}`;c.set(k,$),u.push(k);break}case"hysteria2":if(n<4)continue;b=`hysteria2, ${l.hostname}, ${l.port}, password=${l.password}`,l.downSpeed&&(b+=`, download-bandwidth=${l.downSpeed}`),h!==void 0&&(b+=`,skip-cert-verify=${le(h)}`),l.fingerprint!==""&&(b+=`,server-cert-fingerprint-sha256=${l.fingerprint}`),l.sni!==""&&(b+=`,sni=${l.sni}`);break;case"anytls":if(n<4&&n!==-3)continue;b=`anytls, ${l.hostname}, ${l.port}, password=${l.password}`,l.sni!==""&&(b+=`,sni=${l.sni}`);break;default:continue}d!==void 0&&(b+=`, tfo=${le(d)}`),y!==void 0&&(b+=`, udp-relay=${le(y)}`),l.underlyingProxy!==""&&(b+=`, underlying-proxy=${l.underlyingProxy}`),o.push(`${m} = ${b}`),i.push(m),a.push(l)}if(r.nodeList)return{extraSections:c,groups:[],proxies:o,sectionOrder:u};let f=[];for(let l of e){let m=[],y="";switch(l.type){case"select":case"smart":case"url-test":case"fallback":break;case"load-balance":if(n<1&&n!==-3)continue;break;case"ssid":{let d=l.proxies.slice(1).join(","),h=`${l.type},default=${l.proxies[0]??""},${d}`;f.push(`${l.name} = ${h}`);continue}default:continue}for(let d of l.proxies)bn(d,a,m,!0);if(m.length===0&&m.push("DIRECT"),m.length===1){let d=m[0].toLowerCase();if(d==="direct"||d==="reject"||d==="reject-tinygif"){o.push(`${l.name} = ${d}`);continue}}y=`${l.type},${m.join(",")}`,(l.type==="url-test"||l.type==="fallback"||l.type==="load-balance")&&(y+=`,url=${l.url},interval=${l.interval}`,l.tolerance>0&&(y+=`,tolerance=${l.tolerance}`),l.timeout>0&&(y+=`,timeout=${l.timeout}`),l.persistent!==void 0&&(y+=`,persistent=${le(l.persistent)}`),l.evaluateBeforeUse!==void 0&&(y+=`,evaluate-before-use=${le(l.evaluateBeforeUse)}`)),f.push(`${l.name} = ${y}`)}return{extraSections:c,groups:f,proxies:o,sectionOrder:u}}function vn(t,e,s,r){let n=ao(t,e,s,r);if(r.nodeList)return n.proxies.join(`
|
|
133
|
+
`);let i=r.baseConf===""?[]:io(r.baseConf),o=new Map,a=[];for(let p of i)o.set(p.name,p),a.push(p.name);let c=(p,f)=>{o.has(p)||a.push(p),o.set(p,{lines:f,name:p})};c("Proxy",["DIRECT = direct",...n.proxies]),n.groups.length>0&&c("Proxy Group",n.groups);for(let p of n.sectionOrder)c(p,n.extraSections.get(p));r.rules&&r.rules.lines.length>0&&c(r.rules.section,r.rules.lines);let u=[];for(let p of a){let f=o.get(p);f&&(u.push(`[${p}]`),u.push(...f.lines),u.push(""))}return u.join(`
|
|
134
134
|
`).trimEnd()+`
|
|
135
|
-
`}var ct=["DOMAIN","DOMAIN-SUFFIX","DOMAIN-KEYWORD","IP-CIDR","SRC-IP-CIDR","GEOIP","MATCH","FINAL"],
|
|
135
|
+
`}var ct=["DOMAIN","DOMAIN-SUFFIX","DOMAIN-KEYWORD","IP-CIDR","SRC-IP-CIDR","GEOIP","MATCH","FINAL"],xf=[...ct,"IP-CIDR6","SRC-PORT","DST-PORT","PROCESS-NAME"],ep=[...ct,"IP-CIDR6","USER-AGENT","URL-REGEX","PROCESS-NAME","IN-PORT","DEST-PORT","SRC-IP"],tp=[...ct,"IP-CIDR6","USER-AGENT","URL-REGEX","AND","OR","NOT","PROCESS-NAME","IN-PORT","DEST-PORT","SRC-IP"],sp=[...ct,"USER-AGENT","HOST","HOST-SUFFIX","HOST-KEYWORD"],rp=[...ct,"IP-CIDR6","PROCESS-NAME","IN-PORT","DEST-PORT","SRC-IP"];var np=[...ct,"IP-VERSION","INBOUND","PROTOCOL","NETWORK","GEOSITE","SRC-GEOIP","DOMAIN-REGEX","PROCESS-NAME","PROCESS-PATH","PACKAGE-NAME","PORT","PORT-RANGE","SRC-PORT","SRC-PORT-RANGE","USER","USER-ID"];async function Sn(t,e){let s=await fetch(t,e);if(!s.ok)throw new Error(`Failed to fetch ${t}: ${s.status} ${s.statusText}`);return s.text()}async function co(t,e){return ys(await Sn(t,e))}typeof globalThis<"u"&&(globalThis.SubConverter=bs);var lo=bs;return Nn(uo);})();
|
|
136
136
|
//# sourceMappingURL=subconverter.global.js.map
|