cligr 1.0.6 → 1.0.7

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/dist/index.js CHANGED
@@ -1,43 +1,44 @@
1
1
  #!/usr/bin/env node
2
- import Z from"fs";import _n from"os";import q from"path";function De(e){return typeof e>"u"||e===null}function Ln(e){return typeof e=="object"&&e!==null}function Nn(e){return Array.isArray(e)?e:De(e)?[]:[e]}function Rn(e,n){var r,i,o,t;if(n)for(t=Object.keys(n),r=0,i=t.length;r<i;r+=1)o=t[r],e[o]=n[o];return e}function Dn(e,n){var r="",i;for(i=0;i<n;i+=1)r+=e;return r}function Mn(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var jn=De,$n=Ln,Gn=Nn,Yn=Dn,Bn=Mn,Hn=Rn,A={isNothing:jn,isObject:$n,toArray:Gn,repeat:Yn,isNegativeZero:Bn,extend:Hn};function Me(e,n){var r="",i=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(r+='in "'+e.mark.name+'" '),r+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!n&&e.mark.snippet&&(r+=`
3
-
4
- `+e.mark.snippet),i+" "+r):i}function B(e,n){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=n,this.message=Me(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}B.prototype=Object.create(Error.prototype);B.prototype.constructor=B;B.prototype.toString=function(n){return this.name+": "+Me(this,n)};var E=B;function oe(e,n,r,i,o){var t="",l="",u=Math.floor(o/2)-1;return i-n>u&&(t=" ... ",n=i-u+t.length),r-i>u&&(l=" ...",r=i+u-l.length),{str:t+e.slice(n,r).replace(/\t/g,"\u2192")+l,pos:i-n+t.length}}function le(e,n){return A.repeat(" ",n-e.length)+e}function Un(e,n){if(n=Object.create(n||null),!e.buffer)return null;n.maxLength||(n.maxLength=79),typeof n.indent!="number"&&(n.indent=1),typeof n.linesBefore!="number"&&(n.linesBefore=3),typeof n.linesAfter!="number"&&(n.linesAfter=2);for(var r=/\r?\n|\r|\0/g,i=[0],o=[],t,l=-1;t=r.exec(e.buffer);)o.push(t.index),i.push(t.index+t[0].length),e.position<=t.index&&l<0&&(l=i.length-2);l<0&&(l=i.length-1);var u="",c,a,f=Math.min(e.line+n.linesAfter,o.length).toString().length,s=n.maxLength-(n.indent+f+3);for(c=1;c<=n.linesBefore&&!(l-c<0);c++)a=oe(e.buffer,i[l-c],o[l-c],e.position-(i[l]-i[l-c]),s),u=A.repeat(" ",n.indent)+le((e.line-c+1).toString(),f)+" | "+a.str+`
5
- `+u;for(a=oe(e.buffer,i[l],o[l],e.position,s),u+=A.repeat(" ",n.indent)+le((e.line+1).toString(),f)+" | "+a.str+`
6
- `,u+=A.repeat("-",n.indent+f+3+a.pos)+`^
7
- `,c=1;c<=n.linesAfter&&!(l+c>=o.length);c++)a=oe(e.buffer,i[l+c],o[l+c],e.position-(i[l]-i[l+c]),s),u+=A.repeat(" ",n.indent)+le((e.line+c+1).toString(),f)+" | "+a.str+`
8
- `;return u.replace(/\n$/,"")}var Kn=Un,qn=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],Wn=["scalar","sequence","mapping"];function Qn(e){var n={};return e!==null&&Object.keys(e).forEach(function(r){e[r].forEach(function(i){n[String(i)]=r})}),n}function Vn(e,n){if(n=n||{},Object.keys(n).forEach(function(r){if(qn.indexOf(r)===-1)throw new E('Unknown option "'+r+'" is met in definition of "'+e+'" YAML type.')}),this.options=n,this.tag=e,this.kind=n.kind||null,this.resolve=n.resolve||function(){return!0},this.construct=n.construct||function(r){return r},this.instanceOf=n.instanceOf||null,this.predicate=n.predicate||null,this.represent=n.represent||null,this.representName=n.representName||null,this.defaultStyle=n.defaultStyle||null,this.multi=n.multi||!1,this.styleAliases=Qn(n.styleAliases||null),Wn.indexOf(this.kind)===-1)throw new E('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var w=Vn;function we(e,n){var r=[];return e[n].forEach(function(i){var o=r.length;r.forEach(function(t,l){t.tag===i.tag&&t.kind===i.kind&&t.multi===i.multi&&(o=l)}),r[o]=i}),r}function Xn(){var e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},n,r;function i(o){o.multi?(e.multi[o.kind].push(o),e.multi.fallback.push(o)):e[o.kind][o.tag]=e.fallback[o.tag]=o}for(n=0,r=arguments.length;n<r;n+=1)arguments[n].forEach(i);return e}function ue(e){return this.extend(e)}ue.prototype.extend=function(n){var r=[],i=[];if(n instanceof w)i.push(n);else if(Array.isArray(n))i=i.concat(n);else if(n&&(Array.isArray(n.implicit)||Array.isArray(n.explicit)))n.implicit&&(r=r.concat(n.implicit)),n.explicit&&(i=i.concat(n.explicit));else throw new E("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");r.forEach(function(t){if(!(t instanceof w))throw new E("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(t.loadKind&&t.loadKind!=="scalar")throw new E("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(t.multi)throw new E("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),i.forEach(function(t){if(!(t instanceof w))throw new E("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var o=Object.create(ue.prototype);return o.implicit=(this.implicit||[]).concat(r),o.explicit=(this.explicit||[]).concat(i),o.compiledImplicit=we(o,"implicit"),o.compiledExplicit=we(o,"explicit"),o.compiledTypeMap=Xn(o.compiledImplicit,o.compiledExplicit),o};var je=ue,$e=new w("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),Ge=new w("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),Ye=new w("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),Be=new je({explicit:[$e,Ge,Ye]});function zn(e){if(e===null)return!0;var n=e.length;return n===1&&e==="~"||n===4&&(e==="null"||e==="Null"||e==="NULL")}function Jn(){return null}function Zn(e){return e===null}var He=new w("tag:yaml.org,2002:null",{kind:"scalar",resolve:zn,construct:Jn,predicate:Zn,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function er(e){if(e===null)return!1;var n=e.length;return n===4&&(e==="true"||e==="True"||e==="TRUE")||n===5&&(e==="false"||e==="False"||e==="FALSE")}function nr(e){return e==="true"||e==="True"||e==="TRUE"}function rr(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var Ue=new w("tag:yaml.org,2002:bool",{kind:"scalar",resolve:er,construct:nr,predicate:rr,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"});function ir(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function or(e){return 48<=e&&e<=55}function lr(e){return 48<=e&&e<=57}function tr(e){if(e===null)return!1;var n=e.length,r=0,i=!1,o;if(!n)return!1;if(o=e[r],(o==="-"||o==="+")&&(o=e[++r]),o==="0"){if(r+1===n)return!0;if(o=e[++r],o==="b"){for(r++;r<n;r++)if(o=e[r],o!=="_"){if(o!=="0"&&o!=="1")return!1;i=!0}return i&&o!=="_"}if(o==="x"){for(r++;r<n;r++)if(o=e[r],o!=="_"){if(!ir(e.charCodeAt(r)))return!1;i=!0}return i&&o!=="_"}if(o==="o"){for(r++;r<n;r++)if(o=e[r],o!=="_"){if(!or(e.charCodeAt(r)))return!1;i=!0}return i&&o!=="_"}}if(o==="_")return!1;for(;r<n;r++)if(o=e[r],o!=="_"){if(!lr(e.charCodeAt(r)))return!1;i=!0}return!(!i||o==="_")}function ur(e){var n=e,r=1,i;if(n.indexOf("_")!==-1&&(n=n.replace(/_/g,"")),i=n[0],(i==="-"||i==="+")&&(i==="-"&&(r=-1),n=n.slice(1),i=n[0]),n==="0")return 0;if(i==="0"){if(n[1]==="b")return r*parseInt(n.slice(2),2);if(n[1]==="x")return r*parseInt(n.slice(2),16);if(n[1]==="o")return r*parseInt(n.slice(2),8)}return r*parseInt(n,10)}function cr(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!A.isNegativeZero(e)}var Ke=new w("tag:yaml.org,2002:int",{kind:"scalar",resolve:tr,construct:ur,predicate:cr,represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),ar=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function sr(e){return!(e===null||!ar.test(e)||e[e.length-1]==="_")}function fr(e){var n,r;return n=e.replace(/_/g,"").toLowerCase(),r=n[0]==="-"?-1:1,"+-".indexOf(n[0])>=0&&(n=n.slice(1)),n===".inf"?r===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:n===".nan"?NaN:r*parseFloat(n,10)}var pr=/^[-+]?[0-9]+e/;function dr(e,n){var r;if(isNaN(e))switch(n){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(n){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(n){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(A.isNegativeZero(e))return"-0.0";return r=e.toString(10),pr.test(r)?r.replace("e",".e"):r}function hr(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||A.isNegativeZero(e))}var qe=new w("tag:yaml.org,2002:float",{kind:"scalar",resolve:sr,construct:fr,predicate:hr,represent:dr,defaultStyle:"lowercase"}),We=Be.extend({implicit:[He,Ue,Ke,qe]}),Qe=We,Ve=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Xe=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function mr(e){return e===null?!1:Ve.exec(e)!==null||Xe.exec(e)!==null}function gr(e){var n,r,i,o,t,l,u,c=0,a=null,f,s,d;if(n=Ve.exec(e),n===null&&(n=Xe.exec(e)),n===null)throw new Error("Date resolve error");if(r=+n[1],i=+n[2]-1,o=+n[3],!n[4])return new Date(Date.UTC(r,i,o));if(t=+n[4],l=+n[5],u=+n[6],n[7]){for(c=n[7].slice(0,3);c.length<3;)c+="0";c=+c}return n[9]&&(f=+n[10],s=+(n[11]||0),a=(f*60+s)*6e4,n[9]==="-"&&(a=-a)),d=new Date(Date.UTC(r,i,o,t,l,u,c)),a&&d.setTime(d.getTime()-a),d}function xr(e){return e.toISOString()}var ze=new w("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:mr,construct:gr,instanceOf:Date,represent:xr});function vr(e){return e==="<<"||e===null}var Je=new w("tag:yaml.org,2002:merge",{kind:"scalar",resolve:vr}),pe=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
9
- \r`;function yr(e){if(e===null)return!1;var n,r,i=0,o=e.length,t=pe;for(r=0;r<o;r++)if(n=t.indexOf(e.charAt(r)),!(n>64)){if(n<0)return!1;i+=6}return i%8===0}function Ar(e){var n,r,i=e.replace(/[\r\n=]/g,""),o=i.length,t=pe,l=0,u=[];for(n=0;n<o;n++)n%4===0&&n&&(u.push(l>>16&255),u.push(l>>8&255),u.push(l&255)),l=l<<6|t.indexOf(i.charAt(n));return r=o%4*6,r===0?(u.push(l>>16&255),u.push(l>>8&255),u.push(l&255)):r===18?(u.push(l>>10&255),u.push(l>>2&255)):r===12&&u.push(l>>4&255),new Uint8Array(u)}function wr(e){var n="",r=0,i,o,t=e.length,l=pe;for(i=0;i<t;i++)i%3===0&&i&&(n+=l[r>>18&63],n+=l[r>>12&63],n+=l[r>>6&63],n+=l[r&63]),r=(r<<8)+e[i];return o=t%3,o===0?(n+=l[r>>18&63],n+=l[r>>12&63],n+=l[r>>6&63],n+=l[r&63]):o===2?(n+=l[r>>10&63],n+=l[r>>4&63],n+=l[r<<2&63],n+=l[64]):o===1&&(n+=l[r>>2&63],n+=l[r<<4&63],n+=l[64],n+=l[64]),n}function Cr(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var Ze=new w("tag:yaml.org,2002:binary",{kind:"scalar",resolve:yr,construct:Ar,predicate:Cr,represent:wr}),Er=Object.prototype.hasOwnProperty,Sr=Object.prototype.toString;function br(e){if(e===null)return!0;var n=[],r,i,o,t,l,u=e;for(r=0,i=u.length;r<i;r+=1){if(o=u[r],l=!1,Sr.call(o)!=="[object Object]")return!1;for(t in o)if(Er.call(o,t))if(!l)l=!0;else return!1;if(!l)return!1;if(n.indexOf(t)===-1)n.push(t);else return!1}return!0}function _r(e){return e!==null?e:[]}var en=new w("tag:yaml.org,2002:omap",{kind:"sequence",resolve:br,construct:_r}),Ir=Object.prototype.toString;function Tr(e){if(e===null)return!0;var n,r,i,o,t,l=e;for(t=new Array(l.length),n=0,r=l.length;n<r;n+=1){if(i=l[n],Ir.call(i)!=="[object Object]"||(o=Object.keys(i),o.length!==1))return!1;t[n]=[o[0],i[o[0]]]}return!0}function kr(e){if(e===null)return[];var n,r,i,o,t,l=e;for(t=new Array(l.length),n=0,r=l.length;n<r;n+=1)i=l[n],o=Object.keys(i),t[n]=[o[0],i[o[0]]];return t}var nn=new w("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:Tr,construct:kr}),Fr=Object.prototype.hasOwnProperty;function Or(e){if(e===null)return!0;var n,r=e;for(n in r)if(Fr.call(r,n)&&r[n]!==null)return!1;return!0}function Pr(e){return e!==null?e:{}}var rn=new w("tag:yaml.org,2002:set",{kind:"mapping",resolve:Or,construct:Pr}),de=Qe.extend({implicit:[ze,Je],explicit:[Ze,en,nn,rn]}),F=Object.prototype.hasOwnProperty,W=1,on=2,ln=3,Q=4,te=1,Lr=2,Ce=3,Nr=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,Rr=/[\x85\u2028\u2029]/,Dr=/[,\[\]\{\}]/,tn=/^(?:!|!!|![a-z\-]+!)$/i,un=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function Ee(e){return Object.prototype.toString.call(e)}function _(e){return e===10||e===13}function L(e){return e===9||e===32}function S(e){return e===9||e===32||e===10||e===13}function D(e){return e===44||e===91||e===93||e===123||e===125}function Mr(e){var n;return 48<=e&&e<=57?e-48:(n=e|32,97<=n&&n<=102?n-97+10:-1)}function jr(e){return e===120?2:e===117?4:e===85?8:0}function $r(e){return 48<=e&&e<=57?e-48:-1}function Se(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
10
- `:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"\x85":e===95?"\xA0":e===76?"\u2028":e===80?"\u2029":""}function Gr(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function cn(e,n,r){n==="__proto__"?Object.defineProperty(e,n,{configurable:!0,enumerable:!0,writable:!0,value:r}):e[n]=r}var an=new Array(256),sn=new Array(256);for(P=0;P<256;P++)an[P]=Se(P)?1:0,sn[P]=Se(P);var P;function Yr(e,n){this.input=e,this.filename=n.filename||null,this.schema=n.schema||de,this.onWarning=n.onWarning||null,this.legacy=n.legacy||!1,this.json=n.json||!1,this.listener=n.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function fn(e,n){var r={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return r.snippet=Kn(r),new E(n,r)}function p(e,n){throw fn(e,n)}function V(e,n){e.onWarning&&e.onWarning.call(null,fn(e,n))}var be={YAML:function(n,r,i){var o,t,l;n.version!==null&&p(n,"duplication of %YAML directive"),i.length!==1&&p(n,"YAML directive accepts exactly one argument"),o=/^([0-9]+)\.([0-9]+)$/.exec(i[0]),o===null&&p(n,"ill-formed argument of the YAML directive"),t=parseInt(o[1],10),l=parseInt(o[2],10),t!==1&&p(n,"unacceptable YAML version of the document"),n.version=i[0],n.checkLineBreaks=l<2,l!==1&&l!==2&&V(n,"unsupported YAML version of the document")},TAG:function(n,r,i){var o,t;i.length!==2&&p(n,"TAG directive accepts exactly two arguments"),o=i[0],t=i[1],tn.test(o)||p(n,"ill-formed tag handle (first argument) of the TAG directive"),F.call(n.tagMap,o)&&p(n,'there is a previously declared suffix for "'+o+'" tag handle'),un.test(t)||p(n,"ill-formed tag prefix (second argument) of the TAG directive");try{t=decodeURIComponent(t)}catch{p(n,"tag prefix is malformed: "+t)}n.tagMap[o]=t}};function k(e,n,r,i){var o,t,l,u;if(n<r){if(u=e.input.slice(n,r),i)for(o=0,t=u.length;o<t;o+=1)l=u.charCodeAt(o),l===9||32<=l&&l<=1114111||p(e,"expected valid JSON character");else Nr.test(u)&&p(e,"the stream contains non-printable characters");e.result+=u}}function _e(e,n,r,i){var o,t,l,u;for(A.isObject(r)||p(e,"cannot merge mappings; the provided source object is unacceptable"),o=Object.keys(r),l=0,u=o.length;l<u;l+=1)t=o[l],F.call(n,t)||(cn(n,t,r[t]),i[t]=!0)}function M(e,n,r,i,o,t,l,u,c){var a,f;if(Array.isArray(o))for(o=Array.prototype.slice.call(o),a=0,f=o.length;a<f;a+=1)Array.isArray(o[a])&&p(e,"nested arrays are not supported inside keys"),typeof o=="object"&&Ee(o[a])==="[object Object]"&&(o[a]="[object Object]");if(typeof o=="object"&&Ee(o)==="[object Object]"&&(o="[object Object]"),o=String(o),n===null&&(n={}),i==="tag:yaml.org,2002:merge")if(Array.isArray(t))for(a=0,f=t.length;a<f;a+=1)_e(e,n,t[a],r);else _e(e,n,t,r);else!e.json&&!F.call(r,o)&&F.call(n,o)&&(e.line=l||e.line,e.lineStart=u||e.lineStart,e.position=c||e.position,p(e,"duplicated mapping key")),cn(n,o,t),delete r[o];return n}function he(e){var n;n=e.input.charCodeAt(e.position),n===10?e.position++:n===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):p(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function y(e,n,r){for(var i=0,o=e.input.charCodeAt(e.position);o!==0;){for(;L(o);)o===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),o=e.input.charCodeAt(++e.position);if(n&&o===35)do o=e.input.charCodeAt(++e.position);while(o!==10&&o!==13&&o!==0);if(_(o))for(he(e),o=e.input.charCodeAt(e.position),i++,e.lineIndent=0;o===32;)e.lineIndent++,o=e.input.charCodeAt(++e.position);else break}return r!==-1&&i!==0&&e.lineIndent<r&&V(e,"deficient indentation"),i}function J(e){var n=e.position,r;return r=e.input.charCodeAt(n),!!((r===45||r===46)&&r===e.input.charCodeAt(n+1)&&r===e.input.charCodeAt(n+2)&&(n+=3,r=e.input.charCodeAt(n),r===0||S(r)))}function me(e,n){n===1?e.result+=" ":n>1&&(e.result+=A.repeat(`
11
- `,n-1))}function Br(e,n,r){var i,o,t,l,u,c,a,f,s=e.kind,d=e.result,h;if(h=e.input.charCodeAt(e.position),S(h)||D(h)||h===35||h===38||h===42||h===33||h===124||h===62||h===39||h===34||h===37||h===64||h===96||(h===63||h===45)&&(o=e.input.charCodeAt(e.position+1),S(o)||r&&D(o)))return!1;for(e.kind="scalar",e.result="",t=l=e.position,u=!1;h!==0;){if(h===58){if(o=e.input.charCodeAt(e.position+1),S(o)||r&&D(o))break}else if(h===35){if(i=e.input.charCodeAt(e.position-1),S(i))break}else{if(e.position===e.lineStart&&J(e)||r&&D(h))break;if(_(h))if(c=e.line,a=e.lineStart,f=e.lineIndent,y(e,!1,-1),e.lineIndent>=n){u=!0,h=e.input.charCodeAt(e.position);continue}else{e.position=l,e.line=c,e.lineStart=a,e.lineIndent=f;break}}u&&(k(e,t,l,!1),me(e,e.line-c),t=l=e.position,u=!1),L(h)||(l=e.position+1),h=e.input.charCodeAt(++e.position)}return k(e,t,l,!1),e.result?!0:(e.kind=s,e.result=d,!1)}function Hr(e,n){var r,i,o;if(r=e.input.charCodeAt(e.position),r!==39)return!1;for(e.kind="scalar",e.result="",e.position++,i=o=e.position;(r=e.input.charCodeAt(e.position))!==0;)if(r===39)if(k(e,i,e.position,!0),r=e.input.charCodeAt(++e.position),r===39)i=e.position,e.position++,o=e.position;else return!0;else _(r)?(k(e,i,o,!0),me(e,y(e,!1,n)),i=o=e.position):e.position===e.lineStart&&J(e)?p(e,"unexpected end of the document within a single quoted scalar"):(e.position++,o=e.position);p(e,"unexpected end of the stream within a single quoted scalar")}function Ur(e,n){var r,i,o,t,l,u;if(u=e.input.charCodeAt(e.position),u!==34)return!1;for(e.kind="scalar",e.result="",e.position++,r=i=e.position;(u=e.input.charCodeAt(e.position))!==0;){if(u===34)return k(e,r,e.position,!0),e.position++,!0;if(u===92){if(k(e,r,e.position,!0),u=e.input.charCodeAt(++e.position),_(u))y(e,!1,n);else if(u<256&&an[u])e.result+=sn[u],e.position++;else if((l=jr(u))>0){for(o=l,t=0;o>0;o--)u=e.input.charCodeAt(++e.position),(l=Mr(u))>=0?t=(t<<4)+l:p(e,"expected hexadecimal character");e.result+=Gr(t),e.position++}else p(e,"unknown escape sequence");r=i=e.position}else _(u)?(k(e,r,i,!0),me(e,y(e,!1,n)),r=i=e.position):e.position===e.lineStart&&J(e)?p(e,"unexpected end of the document within a double quoted scalar"):(e.position++,i=e.position)}p(e,"unexpected end of the stream within a double quoted scalar")}function Kr(e,n){var r=!0,i,o,t,l=e.tag,u,c=e.anchor,a,f,s,d,h,m=Object.create(null),x,v,b,g;if(g=e.input.charCodeAt(e.position),g===91)f=93,h=!1,u=[];else if(g===123)f=125,h=!0,u={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=u),g=e.input.charCodeAt(++e.position);g!==0;){if(y(e,!0,n),g=e.input.charCodeAt(e.position),g===f)return e.position++,e.tag=l,e.anchor=c,e.kind=h?"mapping":"sequence",e.result=u,!0;r?g===44&&p(e,"expected the node content, but found ','"):p(e,"missed comma between flow collection entries"),v=x=b=null,s=d=!1,g===63&&(a=e.input.charCodeAt(e.position+1),S(a)&&(s=d=!0,e.position++,y(e,!0,n))),i=e.line,o=e.lineStart,t=e.position,j(e,n,W,!1,!0),v=e.tag,x=e.result,y(e,!0,n),g=e.input.charCodeAt(e.position),(d||e.line===i)&&g===58&&(s=!0,g=e.input.charCodeAt(++e.position),y(e,!0,n),j(e,n,W,!1,!0),b=e.result),h?M(e,u,m,v,x,b,i,o,t):s?u.push(M(e,null,m,v,x,b,i,o,t)):u.push(x),y(e,!0,n),g=e.input.charCodeAt(e.position),g===44?(r=!0,g=e.input.charCodeAt(++e.position)):r=!1}p(e,"unexpected end of the stream within a flow collection")}function qr(e,n){var r,i,o=te,t=!1,l=!1,u=n,c=0,a=!1,f,s;if(s=e.input.charCodeAt(e.position),s===124)i=!1;else if(s===62)i=!0;else return!1;for(e.kind="scalar",e.result="";s!==0;)if(s=e.input.charCodeAt(++e.position),s===43||s===45)te===o?o=s===43?Ce:Lr:p(e,"repeat of a chomping mode identifier");else if((f=$r(s))>=0)f===0?p(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):l?p(e,"repeat of an indentation width identifier"):(u=n+f-1,l=!0);else break;if(L(s)){do s=e.input.charCodeAt(++e.position);while(L(s));if(s===35)do s=e.input.charCodeAt(++e.position);while(!_(s)&&s!==0)}for(;s!==0;){for(he(e),e.lineIndent=0,s=e.input.charCodeAt(e.position);(!l||e.lineIndent<u)&&s===32;)e.lineIndent++,s=e.input.charCodeAt(++e.position);if(!l&&e.lineIndent>u&&(u=e.lineIndent),_(s)){c++;continue}if(e.lineIndent<u){o===Ce?e.result+=A.repeat(`
12
- `,t?1+c:c):o===te&&t&&(e.result+=`
13
- `);break}for(i?L(s)?(a=!0,e.result+=A.repeat(`
14
- `,t?1+c:c)):a?(a=!1,e.result+=A.repeat(`
15
- `,c+1)):c===0?t&&(e.result+=" "):e.result+=A.repeat(`
16
- `,c):e.result+=A.repeat(`
17
- `,t?1+c:c),t=!0,l=!0,c=0,r=e.position;!_(s)&&s!==0;)s=e.input.charCodeAt(++e.position);k(e,r,e.position,!1)}return!0}function Ie(e,n){var r,i=e.tag,o=e.anchor,t=[],l,u=!1,c;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=t),c=e.input.charCodeAt(e.position);c!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,p(e,"tab characters must not be used in indentation")),!(c!==45||(l=e.input.charCodeAt(e.position+1),!S(l))));){if(u=!0,e.position++,y(e,!0,-1)&&e.lineIndent<=n){t.push(null),c=e.input.charCodeAt(e.position);continue}if(r=e.line,j(e,n,ln,!1,!0),t.push(e.result),y(e,!0,-1),c=e.input.charCodeAt(e.position),(e.line===r||e.lineIndent>n)&&c!==0)p(e,"bad indentation of a sequence entry");else if(e.lineIndent<n)break}return u?(e.tag=i,e.anchor=o,e.kind="sequence",e.result=t,!0):!1}function Wr(e,n,r){var i,o,t,l,u,c,a=e.tag,f=e.anchor,s={},d=Object.create(null),h=null,m=null,x=null,v=!1,b=!1,g;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=s),g=e.input.charCodeAt(e.position);g!==0;){if(!v&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,p(e,"tab characters must not be used in indentation")),i=e.input.charCodeAt(e.position+1),t=e.line,(g===63||g===58)&&S(i))g===63?(v&&(M(e,s,d,h,m,null,l,u,c),h=m=x=null),b=!0,v=!0,o=!0):v?(v=!1,o=!0):p(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,g=i;else{if(l=e.line,u=e.lineStart,c=e.position,!j(e,r,on,!1,!0))break;if(e.line===t){for(g=e.input.charCodeAt(e.position);L(g);)g=e.input.charCodeAt(++e.position);if(g===58)g=e.input.charCodeAt(++e.position),S(g)||p(e,"a whitespace character is expected after the key-value separator within a block mapping"),v&&(M(e,s,d,h,m,null,l,u,c),h=m=x=null),b=!0,v=!1,o=!1,h=e.tag,m=e.result;else if(b)p(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=a,e.anchor=f,!0}else if(b)p(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=a,e.anchor=f,!0}if((e.line===t||e.lineIndent>n)&&(v&&(l=e.line,u=e.lineStart,c=e.position),j(e,n,Q,!0,o)&&(v?m=e.result:x=e.result),v||(M(e,s,d,h,m,x,l,u,c),h=m=x=null),y(e,!0,-1),g=e.input.charCodeAt(e.position)),(e.line===t||e.lineIndent>n)&&g!==0)p(e,"bad indentation of a mapping entry");else if(e.lineIndent<n)break}return v&&M(e,s,d,h,m,null,l,u,c),b&&(e.tag=a,e.anchor=f,e.kind="mapping",e.result=s),b}function Qr(e){var n,r=!1,i=!1,o,t,l;if(l=e.input.charCodeAt(e.position),l!==33)return!1;if(e.tag!==null&&p(e,"duplication of a tag property"),l=e.input.charCodeAt(++e.position),l===60?(r=!0,l=e.input.charCodeAt(++e.position)):l===33?(i=!0,o="!!",l=e.input.charCodeAt(++e.position)):o="!",n=e.position,r){do l=e.input.charCodeAt(++e.position);while(l!==0&&l!==62);e.position<e.length?(t=e.input.slice(n,e.position),l=e.input.charCodeAt(++e.position)):p(e,"unexpected end of the stream within a verbatim tag")}else{for(;l!==0&&!S(l);)l===33&&(i?p(e,"tag suffix cannot contain exclamation marks"):(o=e.input.slice(n-1,e.position+1),tn.test(o)||p(e,"named tag handle cannot contain such characters"),i=!0,n=e.position+1)),l=e.input.charCodeAt(++e.position);t=e.input.slice(n,e.position),Dr.test(t)&&p(e,"tag suffix cannot contain flow indicator characters")}t&&!un.test(t)&&p(e,"tag name cannot contain such characters: "+t);try{t=decodeURIComponent(t)}catch{p(e,"tag name is malformed: "+t)}return r?e.tag=t:F.call(e.tagMap,o)?e.tag=e.tagMap[o]+t:o==="!"?e.tag="!"+t:o==="!!"?e.tag="tag:yaml.org,2002:"+t:p(e,'undeclared tag handle "'+o+'"'),!0}function Vr(e){var n,r;if(r=e.input.charCodeAt(e.position),r!==38)return!1;for(e.anchor!==null&&p(e,"duplication of an anchor property"),r=e.input.charCodeAt(++e.position),n=e.position;r!==0&&!S(r)&&!D(r);)r=e.input.charCodeAt(++e.position);return e.position===n&&p(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(n,e.position),!0}function Xr(e){var n,r,i;if(i=e.input.charCodeAt(e.position),i!==42)return!1;for(i=e.input.charCodeAt(++e.position),n=e.position;i!==0&&!S(i)&&!D(i);)i=e.input.charCodeAt(++e.position);return e.position===n&&p(e,"name of an alias node must contain at least one character"),r=e.input.slice(n,e.position),F.call(e.anchorMap,r)||p(e,'unidentified alias "'+r+'"'),e.result=e.anchorMap[r],y(e,!0,-1),!0}function j(e,n,r,i,o){var t,l,u,c=1,a=!1,f=!1,s,d,h,m,x,v;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,t=l=u=Q===r||ln===r,i&&y(e,!0,-1)&&(a=!0,e.lineIndent>n?c=1:e.lineIndent===n?c=0:e.lineIndent<n&&(c=-1)),c===1)for(;Qr(e)||Vr(e);)y(e,!0,-1)?(a=!0,u=t,e.lineIndent>n?c=1:e.lineIndent===n?c=0:e.lineIndent<n&&(c=-1)):u=!1;if(u&&(u=a||o),(c===1||Q===r)&&(W===r||on===r?x=n:x=n+1,v=e.position-e.lineStart,c===1?u&&(Ie(e,v)||Wr(e,v,x))||Kr(e,x)?f=!0:(l&&qr(e,x)||Hr(e,x)||Ur(e,x)?f=!0:Xr(e)?(f=!0,(e.tag!==null||e.anchor!==null)&&p(e,"alias node should not have any properties")):Br(e,x,W===r)&&(f=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):c===0&&(f=u&&Ie(e,v))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&p(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),s=0,d=e.implicitTypes.length;s<d;s+=1)if(m=e.implicitTypes[s],m.resolve(e.result)){e.result=m.construct(e.result),e.tag=m.tag,e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);break}}else if(e.tag!=="!"){if(F.call(e.typeMap[e.kind||"fallback"],e.tag))m=e.typeMap[e.kind||"fallback"][e.tag];else for(m=null,h=e.typeMap.multi[e.kind||"fallback"],s=0,d=h.length;s<d;s+=1)if(e.tag.slice(0,h[s].tag.length)===h[s].tag){m=h[s];break}m||p(e,"unknown tag !<"+e.tag+">"),e.result!==null&&m.kind!==e.kind&&p(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+m.kind+'", not "'+e.kind+'"'),m.resolve(e.result,e.tag)?(e.result=m.construct(e.result,e.tag),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):p(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||f}function zr(e){var n=e.position,r,i,o,t=!1,l;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(l=e.input.charCodeAt(e.position))!==0&&(y(e,!0,-1),l=e.input.charCodeAt(e.position),!(e.lineIndent>0||l!==37));){for(t=!0,l=e.input.charCodeAt(++e.position),r=e.position;l!==0&&!S(l);)l=e.input.charCodeAt(++e.position);for(i=e.input.slice(r,e.position),o=[],i.length<1&&p(e,"directive name must not be less than one character in length");l!==0;){for(;L(l);)l=e.input.charCodeAt(++e.position);if(l===35){do l=e.input.charCodeAt(++e.position);while(l!==0&&!_(l));break}if(_(l))break;for(r=e.position;l!==0&&!S(l);)l=e.input.charCodeAt(++e.position);o.push(e.input.slice(r,e.position))}l!==0&&he(e),F.call(be,i)?be[i](e,i,o):V(e,'unknown document directive "'+i+'"')}if(y(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,y(e,!0,-1)):t&&p(e,"directives end mark is expected"),j(e,e.lineIndent-1,Q,!1,!0),y(e,!0,-1),e.checkLineBreaks&&Rr.test(e.input.slice(n,e.position))&&V(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&J(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,y(e,!0,-1));return}if(e.position<e.length-1)p(e,"end of the stream or a document separator is expected");else return}function pn(e,n){e=String(e),n=n||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
18
- `),e.charCodeAt(0)===65279&&(e=e.slice(1)));var r=new Yr(e,n),i=e.indexOf("\0");for(i!==-1&&(r.position=i,p(r,"null byte is not allowed in input")),r.input+="\0";r.input.charCodeAt(r.position)===32;)r.lineIndent+=1,r.position+=1;for(;r.position<r.length-1;)zr(r);return r.documents}function Jr(e,n,r){n!==null&&typeof n=="object"&&typeof r>"u"&&(r=n,n=null);var i=pn(e,r);if(typeof n!="function")return i;for(var o=0,t=i.length;o<t;o+=1)n(i[o])}function Zr(e,n){var r=pn(e,n);if(r.length!==0){if(r.length===1)return r[0];throw new E("expected a single document in the stream, but found more")}}var ei=Jr,ni=Zr,dn={loadAll:ei,load:ni},hn=Object.prototype.toString,mn=Object.prototype.hasOwnProperty,ge=65279,ri=9,H=10,ii=13,oi=32,li=33,ti=34,ce=35,ui=37,ci=38,ai=39,si=42,gn=44,fi=45,X=58,pi=61,di=62,hi=63,mi=64,xn=91,vn=93,gi=96,yn=123,xi=124,An=125,C={};C[0]="\\0";C[7]="\\a";C[8]="\\b";C[9]="\\t";C[10]="\\n";C[11]="\\v";C[12]="\\f";C[13]="\\r";C[27]="\\e";C[34]='\\"';C[92]="\\\\";C[133]="\\N";C[160]="\\_";C[8232]="\\L";C[8233]="\\P";var vi=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],yi=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function Ai(e,n){var r,i,o,t,l,u,c;if(n===null)return{};for(r={},i=Object.keys(n),o=0,t=i.length;o<t;o+=1)l=i[o],u=String(n[l]),l.slice(0,2)==="!!"&&(l="tag:yaml.org,2002:"+l.slice(2)),c=e.compiledTypeMap.fallback[l],c&&mn.call(c.styleAliases,u)&&(u=c.styleAliases[u]),r[l]=u;return r}function wi(e){var n,r,i;if(n=e.toString(16).toUpperCase(),e<=255)r="x",i=2;else if(e<=65535)r="u",i=4;else if(e<=4294967295)r="U",i=8;else throw new E("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+r+A.repeat("0",i-n.length)+n}var Ci=1,U=2;function Ei(e){this.schema=e.schema||de,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=A.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=Ai(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType=e.quotingType==='"'?U:Ci,this.forceQuotes=e.forceQuotes||!1,this.replacer=typeof e.replacer=="function"?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function Te(e,n){for(var r=A.repeat(" ",n),i=0,o=-1,t="",l,u=e.length;i<u;)o=e.indexOf(`
19
- `,i),o===-1?(l=e.slice(i),i=u):(l=e.slice(i,o+1),i=o+1),l.length&&l!==`
20
- `&&(t+=r),t+=l;return t}function ae(e,n){return`
21
- `+A.repeat(" ",e.indent*n)}function Si(e,n){var r,i,o;for(r=0,i=e.implicitTypes.length;r<i;r+=1)if(o=e.implicitTypes[r],o.resolve(n))return!0;return!1}function z(e){return e===oi||e===ri}function K(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==ge||65536<=e&&e<=1114111}function ke(e){return K(e)&&e!==ge&&e!==ii&&e!==H}function Fe(e,n,r){var i=ke(e),o=i&&!z(e);return(r?i:i&&e!==gn&&e!==xn&&e!==vn&&e!==yn&&e!==An)&&e!==ce&&!(n===X&&!o)||ke(n)&&!z(n)&&e===ce||n===X&&o}function bi(e){return K(e)&&e!==ge&&!z(e)&&e!==fi&&e!==hi&&e!==X&&e!==gn&&e!==xn&&e!==vn&&e!==yn&&e!==An&&e!==ce&&e!==ci&&e!==si&&e!==li&&e!==xi&&e!==pi&&e!==di&&e!==ai&&e!==ti&&e!==ui&&e!==mi&&e!==gi}function _i(e){return!z(e)&&e!==X}function Y(e,n){var r=e.charCodeAt(n),i;return r>=55296&&r<=56319&&n+1<e.length&&(i=e.charCodeAt(n+1),i>=56320&&i<=57343)?(r-55296)*1024+i-56320+65536:r}function wn(e){var n=/^\n* /;return n.test(e)}var Cn=1,se=2,En=3,Sn=4,R=5;function Ii(e,n,r,i,o,t,l,u){var c,a=0,f=null,s=!1,d=!1,h=i!==-1,m=-1,x=bi(Y(e,0))&&_i(Y(e,e.length-1));if(n||l)for(c=0;c<e.length;a>=65536?c+=2:c++){if(a=Y(e,c),!K(a))return R;x=x&&Fe(a,f,u),f=a}else{for(c=0;c<e.length;a>=65536?c+=2:c++){if(a=Y(e,c),a===H)s=!0,h&&(d=d||c-m-1>i&&e[m+1]!==" ",m=c);else if(!K(a))return R;x=x&&Fe(a,f,u),f=a}d=d||h&&c-m-1>i&&e[m+1]!==" "}return!s&&!d?x&&!l&&!o(e)?Cn:t===U?R:se:r>9&&wn(e)?R:l?t===U?R:se:d?Sn:En}function Ti(e,n,r,i,o){e.dump=function(){if(n.length===0)return e.quotingType===U?'""':"''";if(!e.noCompatMode&&(vi.indexOf(n)!==-1||yi.test(n)))return e.quotingType===U?'"'+n+'"':"'"+n+"'";var t=e.indent*Math.max(1,r),l=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-t),u=i||e.flowLevel>-1&&r>=e.flowLevel;function c(a){return Si(e,a)}switch(Ii(n,u,e.indent,l,c,e.quotingType,e.forceQuotes&&!i,o)){case Cn:return n;case se:return"'"+n.replace(/'/g,"''")+"'";case En:return"|"+Oe(n,e.indent)+Pe(Te(n,t));case Sn:return">"+Oe(n,e.indent)+Pe(Te(ki(n,l),t));case R:return'"'+Fi(n)+'"';default:throw new E("impossible error: invalid scalar style")}}()}function Oe(e,n){var r=wn(e)?String(n):"",i=e[e.length-1]===`
2
+ import Q from"fs";import Nn from"os";import X from"path";function Ke(e){return typeof e>"u"||e===null}function Yn(e){return typeof e=="object"&&e!==null}function Un(e){return Array.isArray(e)?e:Ke(e)?[]:[e]}function Kn(e,n){var r,i,o,l;if(n)for(l=Object.keys(n),r=0,i=l.length;r<i;r+=1)o=l[r],e[o]=n[o];return e}function Wn(e,n){var r="",i;for(i=0;i<n;i+=1)r+=e;return r}function Jn(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var zn=Ke,qn=Yn,Qn=Un,Xn=Wn,Vn=Jn,Zn=Kn,C={isNothing:zn,isObject:qn,toArray:Qn,repeat:Xn,isNegativeZero:Vn,extend:Zn};function We(e,n){var r="",i=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(r+='in "'+e.mark.name+'" '),r+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!n&&e.mark.snippet&&(r+=`
3
+
4
+ `+e.mark.snippet),i+" "+r):i}function W(e,n){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=n,this.message=We(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}W.prototype=Object.create(Error.prototype);W.prototype.constructor=W;W.prototype.toString=function(n){return this.name+": "+We(this,n)};var S=W;function pe(e,n,r,i,o){var l="",t="",s=Math.floor(o/2)-1;return i-n>s&&(l=" ... ",n=i-s+l.length),r-i>s&&(t=" ...",r=i+s-t.length),{str:l+e.slice(n,r).replace(/\t/g,"\u2192")+t,pos:i-n+l.length}}function de(e,n){return C.repeat(" ",n-e.length)+e}function er(e,n){if(n=Object.create(n||null),!e.buffer)return null;n.maxLength||(n.maxLength=79),typeof n.indent!="number"&&(n.indent=1),typeof n.linesBefore!="number"&&(n.linesBefore=3),typeof n.linesAfter!="number"&&(n.linesAfter=2);for(var r=/\r?\n|\r|\0/g,i=[0],o=[],l,t=-1;l=r.exec(e.buffer);)o.push(l.index),i.push(l.index+l[0].length),e.position<=l.index&&t<0&&(t=i.length-2);t<0&&(t=i.length-1);var s="",a,u,f=Math.min(e.line+n.linesAfter,o.length).toString().length,c=n.maxLength-(n.indent+f+3);for(a=1;a<=n.linesBefore&&!(t-a<0);a++)u=pe(e.buffer,i[t-a],o[t-a],e.position-(i[t]-i[t-a]),c),s=C.repeat(" ",n.indent)+de((e.line-a+1).toString(),f)+" | "+u.str+`
5
+ `+s;for(u=pe(e.buffer,i[t],o[t],e.position,c),s+=C.repeat(" ",n.indent)+de((e.line+1).toString(),f)+" | "+u.str+`
6
+ `,s+=C.repeat("-",n.indent+f+3+u.pos)+`^
7
+ `,a=1;a<=n.linesAfter&&!(t+a>=o.length);a++)u=pe(e.buffer,i[t+a],o[t+a],e.position-(i[t]-i[t+a]),c),s+=C.repeat(" ",n.indent)+de((e.line+a+1).toString(),f)+" | "+u.str+`
8
+ `;return s.replace(/\n$/,"")}var nr=er,rr=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],ir=["scalar","sequence","mapping"];function or(e){var n={};return e!==null&&Object.keys(e).forEach(function(r){e[r].forEach(function(i){n[String(i)]=r})}),n}function tr(e,n){if(n=n||{},Object.keys(n).forEach(function(r){if(rr.indexOf(r)===-1)throw new S('Unknown option "'+r+'" is met in definition of "'+e+'" YAML type.')}),this.options=n,this.tag=e,this.kind=n.kind||null,this.resolve=n.resolve||function(){return!0},this.construct=n.construct||function(r){return r},this.instanceOf=n.instanceOf||null,this.predicate=n.predicate||null,this.represent=n.represent||null,this.representName=n.representName||null,this.defaultStyle=n.defaultStyle||null,this.multi=n.multi||!1,this.styleAliases=or(n.styleAliases||null),ir.indexOf(this.kind)===-1)throw new S('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var A=tr;function _e(e,n){var r=[];return e[n].forEach(function(i){var o=r.length;r.forEach(function(l,t){l.tag===i.tag&&l.kind===i.kind&&l.multi===i.multi&&(o=t)}),r[o]=i}),r}function lr(){var e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},n,r;function i(o){o.multi?(e.multi[o.kind].push(o),e.multi.fallback.push(o)):e[o.kind][o.tag]=e.fallback[o.tag]=o}for(n=0,r=arguments.length;n<r;n+=1)arguments[n].forEach(i);return e}function me(e){return this.extend(e)}me.prototype.extend=function(n){var r=[],i=[];if(n instanceof A)i.push(n);else if(Array.isArray(n))i=i.concat(n);else if(n&&(Array.isArray(n.implicit)||Array.isArray(n.explicit)))n.implicit&&(r=r.concat(n.implicit)),n.explicit&&(i=i.concat(n.explicit));else throw new S("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");r.forEach(function(l){if(!(l instanceof A))throw new S("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(l.loadKind&&l.loadKind!=="scalar")throw new S("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(l.multi)throw new S("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),i.forEach(function(l){if(!(l instanceof A))throw new S("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var o=Object.create(me.prototype);return o.implicit=(this.implicit||[]).concat(r),o.explicit=(this.explicit||[]).concat(i),o.compiledImplicit=_e(o,"implicit"),o.compiledExplicit=_e(o,"explicit"),o.compiledTypeMap=lr(o.compiledImplicit,o.compiledExplicit),o};var Je=me,ze=new A("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),qe=new A("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),Qe=new A("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),Xe=new Je({explicit:[ze,qe,Qe]});function sr(e){if(e===null)return!0;var n=e.length;return n===1&&e==="~"||n===4&&(e==="null"||e==="Null"||e==="NULL")}function ar(){return null}function cr(e){return e===null}var Ve=new A("tag:yaml.org,2002:null",{kind:"scalar",resolve:sr,construct:ar,predicate:cr,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function ur(e){if(e===null)return!1;var n=e.length;return n===4&&(e==="true"||e==="True"||e==="TRUE")||n===5&&(e==="false"||e==="False"||e==="FALSE")}function fr(e){return e==="true"||e==="True"||e==="TRUE"}function pr(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var Ze=new A("tag:yaml.org,2002:bool",{kind:"scalar",resolve:ur,construct:fr,predicate:pr,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"});function dr(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function hr(e){return 48<=e&&e<=55}function mr(e){return 48<=e&&e<=57}function gr(e){if(e===null)return!1;var n=e.length,r=0,i=!1,o;if(!n)return!1;if(o=e[r],(o==="-"||o==="+")&&(o=e[++r]),o==="0"){if(r+1===n)return!0;if(o=e[++r],o==="b"){for(r++;r<n;r++)if(o=e[r],o!=="_"){if(o!=="0"&&o!=="1")return!1;i=!0}return i&&o!=="_"}if(o==="x"){for(r++;r<n;r++)if(o=e[r],o!=="_"){if(!dr(e.charCodeAt(r)))return!1;i=!0}return i&&o!=="_"}if(o==="o"){for(r++;r<n;r++)if(o=e[r],o!=="_"){if(!hr(e.charCodeAt(r)))return!1;i=!0}return i&&o!=="_"}}if(o==="_")return!1;for(;r<n;r++)if(o=e[r],o!=="_"){if(!mr(e.charCodeAt(r)))return!1;i=!0}return!(!i||o==="_")}function xr(e){var n=e,r=1,i;if(n.indexOf("_")!==-1&&(n=n.replace(/_/g,"")),i=n[0],(i==="-"||i==="+")&&(i==="-"&&(r=-1),n=n.slice(1),i=n[0]),n==="0")return 0;if(i==="0"){if(n[1]==="b")return r*parseInt(n.slice(2),2);if(n[1]==="x")return r*parseInt(n.slice(2),16);if(n[1]==="o")return r*parseInt(n.slice(2),8)}return r*parseInt(n,10)}function vr(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!C.isNegativeZero(e)}var en=new A("tag:yaml.org,2002:int",{kind:"scalar",resolve:gr,construct:xr,predicate:vr,represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),yr=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function wr(e){return!(e===null||!yr.test(e)||e[e.length-1]==="_")}function Cr(e){var n,r;return n=e.replace(/_/g,"").toLowerCase(),r=n[0]==="-"?-1:1,"+-".indexOf(n[0])>=0&&(n=n.slice(1)),n===".inf"?r===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:n===".nan"?NaN:r*parseFloat(n,10)}var Ar=/^[-+]?[0-9]+e/;function Er(e,n){var r;if(isNaN(e))switch(n){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(n){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(n){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(C.isNegativeZero(e))return"-0.0";return r=e.toString(10),Ar.test(r)?r.replace("e",".e"):r}function br(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||C.isNegativeZero(e))}var nn=new A("tag:yaml.org,2002:float",{kind:"scalar",resolve:wr,construct:Cr,predicate:br,represent:Er,defaultStyle:"lowercase"}),rn=Xe.extend({implicit:[Ve,Ze,en,nn]}),on=rn,tn=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),ln=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function Sr(e){return e===null?!1:tn.exec(e)!==null||ln.exec(e)!==null}function Ir(e){var n,r,i,o,l,t,s,a=0,u=null,f,c,p;if(n=tn.exec(e),n===null&&(n=ln.exec(e)),n===null)throw new Error("Date resolve error");if(r=+n[1],i=+n[2]-1,o=+n[3],!n[4])return new Date(Date.UTC(r,i,o));if(l=+n[4],t=+n[5],s=+n[6],n[7]){for(a=n[7].slice(0,3);a.length<3;)a+="0";a=+a}return n[9]&&(f=+n[10],c=+(n[11]||0),u=(f*60+c)*6e4,n[9]==="-"&&(u=-u)),p=new Date(Date.UTC(r,i,o,l,t,s,a)),u&&p.setTime(p.getTime()-u),p}function Tr(e){return e.toISOString()}var sn=new A("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:Sr,construct:Ir,instanceOf:Date,represent:Tr});function kr(e){return e==="<<"||e===null}var an=new A("tag:yaml.org,2002:merge",{kind:"scalar",resolve:kr}),we=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
9
+ \r`;function Or(e){if(e===null)return!1;var n,r,i=0,o=e.length,l=we;for(r=0;r<o;r++)if(n=l.indexOf(e.charAt(r)),!(n>64)){if(n<0)return!1;i+=6}return i%8===0}function _r(e){var n,r,i=e.replace(/[\r\n=]/g,""),o=i.length,l=we,t=0,s=[];for(n=0;n<o;n++)n%4===0&&n&&(s.push(t>>16&255),s.push(t>>8&255),s.push(t&255)),t=t<<6|l.indexOf(i.charAt(n));return r=o%4*6,r===0?(s.push(t>>16&255),s.push(t>>8&255),s.push(t&255)):r===18?(s.push(t>>10&255),s.push(t>>2&255)):r===12&&s.push(t>>4&255),new Uint8Array(s)}function Pr(e){var n="",r=0,i,o,l=e.length,t=we;for(i=0;i<l;i++)i%3===0&&i&&(n+=t[r>>18&63],n+=t[r>>12&63],n+=t[r>>6&63],n+=t[r&63]),r=(r<<8)+e[i];return o=l%3,o===0?(n+=t[r>>18&63],n+=t[r>>12&63],n+=t[r>>6&63],n+=t[r&63]):o===2?(n+=t[r>>10&63],n+=t[r>>4&63],n+=t[r<<2&63],n+=t[64]):o===1&&(n+=t[r>>2&63],n+=t[r<<4&63],n+=t[64],n+=t[64]),n}function Fr(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var cn=new A("tag:yaml.org,2002:binary",{kind:"scalar",resolve:Or,construct:_r,predicate:Fr,represent:Pr}),Lr=Object.prototype.hasOwnProperty,Nr=Object.prototype.toString;function Rr(e){if(e===null)return!0;var n=[],r,i,o,l,t,s=e;for(r=0,i=s.length;r<i;r+=1){if(o=s[r],t=!1,Nr.call(o)!=="[object Object]")return!1;for(l in o)if(Lr.call(o,l))if(!t)t=!0;else return!1;if(!t)return!1;if(n.indexOf(l)===-1)n.push(l);else return!1}return!0}function Dr(e){return e!==null?e:[]}var un=new A("tag:yaml.org,2002:omap",{kind:"sequence",resolve:Rr,construct:Dr}),Mr=Object.prototype.toString;function Gr(e){if(e===null)return!0;var n,r,i,o,l,t=e;for(l=new Array(t.length),n=0,r=t.length;n<r;n+=1){if(i=t[n],Mr.call(i)!=="[object Object]"||(o=Object.keys(i),o.length!==1))return!1;l[n]=[o[0],i[o[0]]]}return!0}function $r(e){if(e===null)return[];var n,r,i,o,l,t=e;for(l=new Array(t.length),n=0,r=t.length;n<r;n+=1)i=t[n],o=Object.keys(i),l[n]=[o[0],i[o[0]]];return l}var fn=new A("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:Gr,construct:$r}),jr=Object.prototype.hasOwnProperty;function Hr(e){if(e===null)return!0;var n,r=e;for(n in r)if(jr.call(r,n)&&r[n]!==null)return!1;return!0}function Br(e){return e!==null?e:{}}var pn=new A("tag:yaml.org,2002:set",{kind:"mapping",resolve:Hr,construct:Br}),Ce=on.extend({implicit:[sn,an],explicit:[cn,un,fn,pn]}),F=Object.prototype.hasOwnProperty,V=1,dn=2,hn=3,Z=4,he=1,Yr=2,Pe=3,Ur=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,Kr=/[\x85\u2028\u2029]/,Wr=/[,\[\]\{\}]/,mn=/^(?:!|!!|![a-z\-]+!)$/i,gn=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function Fe(e){return Object.prototype.toString.call(e)}function T(e){return e===10||e===13}function R(e){return e===9||e===32}function I(e){return e===9||e===32||e===10||e===13}function $(e){return e===44||e===91||e===93||e===123||e===125}function Jr(e){var n;return 48<=e&&e<=57?e-48:(n=e|32,97<=n&&n<=102?n-97+10:-1)}function zr(e){return e===120?2:e===117?4:e===85?8:0}function qr(e){return 48<=e&&e<=57?e-48:-1}function Le(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
10
+ `:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"\x85":e===95?"\xA0":e===76?"\u2028":e===80?"\u2029":""}function Qr(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function xn(e,n,r){n==="__proto__"?Object.defineProperty(e,n,{configurable:!0,enumerable:!0,writable:!0,value:r}):e[n]=r}var vn=new Array(256),yn=new Array(256);for(N=0;N<256;N++)vn[N]=Le(N)?1:0,yn[N]=Le(N);var N;function Xr(e,n){this.input=e,this.filename=n.filename||null,this.schema=n.schema||Ce,this.onWarning=n.onWarning||null,this.legacy=n.legacy||!1,this.json=n.json||!1,this.listener=n.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function wn(e,n){var r={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return r.snippet=nr(r),new S(n,r)}function h(e,n){throw wn(e,n)}function ee(e,n){e.onWarning&&e.onWarning.call(null,wn(e,n))}var Ne={YAML:function(n,r,i){var o,l,t;n.version!==null&&h(n,"duplication of %YAML directive"),i.length!==1&&h(n,"YAML directive accepts exactly one argument"),o=/^([0-9]+)\.([0-9]+)$/.exec(i[0]),o===null&&h(n,"ill-formed argument of the YAML directive"),l=parseInt(o[1],10),t=parseInt(o[2],10),l!==1&&h(n,"unacceptable YAML version of the document"),n.version=i[0],n.checkLineBreaks=t<2,t!==1&&t!==2&&ee(n,"unsupported YAML version of the document")},TAG:function(n,r,i){var o,l;i.length!==2&&h(n,"TAG directive accepts exactly two arguments"),o=i[0],l=i[1],mn.test(o)||h(n,"ill-formed tag handle (first argument) of the TAG directive"),F.call(n.tagMap,o)&&h(n,'there is a previously declared suffix for "'+o+'" tag handle'),gn.test(l)||h(n,"ill-formed tag prefix (second argument) of the TAG directive");try{l=decodeURIComponent(l)}catch{h(n,"tag prefix is malformed: "+l)}n.tagMap[o]=l}};function P(e,n,r,i){var o,l,t,s;if(n<r){if(s=e.input.slice(n,r),i)for(o=0,l=s.length;o<l;o+=1)t=s.charCodeAt(o),t===9||32<=t&&t<=1114111||h(e,"expected valid JSON character");else Ur.test(s)&&h(e,"the stream contains non-printable characters");e.result+=s}}function Re(e,n,r,i){var o,l,t,s;for(C.isObject(r)||h(e,"cannot merge mappings; the provided source object is unacceptable"),o=Object.keys(r),t=0,s=o.length;t<s;t+=1)l=o[t],F.call(n,l)||(xn(n,l,r[l]),i[l]=!0)}function j(e,n,r,i,o,l,t,s,a){var u,f;if(Array.isArray(o))for(o=Array.prototype.slice.call(o),u=0,f=o.length;u<f;u+=1)Array.isArray(o[u])&&h(e,"nested arrays are not supported inside keys"),typeof o=="object"&&Fe(o[u])==="[object Object]"&&(o[u]="[object Object]");if(typeof o=="object"&&Fe(o)==="[object Object]"&&(o="[object Object]"),o=String(o),n===null&&(n={}),i==="tag:yaml.org,2002:merge")if(Array.isArray(l))for(u=0,f=l.length;u<f;u+=1)Re(e,n,l[u],r);else Re(e,n,l,r);else!e.json&&!F.call(r,o)&&F.call(n,o)&&(e.line=t||e.line,e.lineStart=s||e.lineStart,e.position=a||e.position,h(e,"duplicated mapping key")),xn(n,o,l),delete r[o];return n}function Ae(e){var n;n=e.input.charCodeAt(e.position),n===10?e.position++:n===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):h(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function w(e,n,r){for(var i=0,o=e.input.charCodeAt(e.position);o!==0;){for(;R(o);)o===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),o=e.input.charCodeAt(++e.position);if(n&&o===35)do o=e.input.charCodeAt(++e.position);while(o!==10&&o!==13&&o!==0);if(T(o))for(Ae(e),o=e.input.charCodeAt(e.position),i++,e.lineIndent=0;o===32;)e.lineIndent++,o=e.input.charCodeAt(++e.position);else break}return r!==-1&&i!==0&&e.lineIndent<r&&ee(e,"deficient indentation"),i}function ie(e){var n=e.position,r;return r=e.input.charCodeAt(n),!!((r===45||r===46)&&r===e.input.charCodeAt(n+1)&&r===e.input.charCodeAt(n+2)&&(n+=3,r=e.input.charCodeAt(n),r===0||I(r)))}function Ee(e,n){n===1?e.result+=" ":n>1&&(e.result+=C.repeat(`
11
+ `,n-1))}function Vr(e,n,r){var i,o,l,t,s,a,u,f,c=e.kind,p=e.result,d;if(d=e.input.charCodeAt(e.position),I(d)||$(d)||d===35||d===38||d===42||d===33||d===124||d===62||d===39||d===34||d===37||d===64||d===96||(d===63||d===45)&&(o=e.input.charCodeAt(e.position+1),I(o)||r&&$(o)))return!1;for(e.kind="scalar",e.result="",l=t=e.position,s=!1;d!==0;){if(d===58){if(o=e.input.charCodeAt(e.position+1),I(o)||r&&$(o))break}else if(d===35){if(i=e.input.charCodeAt(e.position-1),I(i))break}else{if(e.position===e.lineStart&&ie(e)||r&&$(d))break;if(T(d))if(a=e.line,u=e.lineStart,f=e.lineIndent,w(e,!1,-1),e.lineIndent>=n){s=!0,d=e.input.charCodeAt(e.position);continue}else{e.position=t,e.line=a,e.lineStart=u,e.lineIndent=f;break}}s&&(P(e,l,t,!1),Ee(e,e.line-a),l=t=e.position,s=!1),R(d)||(t=e.position+1),d=e.input.charCodeAt(++e.position)}return P(e,l,t,!1),e.result?!0:(e.kind=c,e.result=p,!1)}function Zr(e,n){var r,i,o;if(r=e.input.charCodeAt(e.position),r!==39)return!1;for(e.kind="scalar",e.result="",e.position++,i=o=e.position;(r=e.input.charCodeAt(e.position))!==0;)if(r===39)if(P(e,i,e.position,!0),r=e.input.charCodeAt(++e.position),r===39)i=e.position,e.position++,o=e.position;else return!0;else T(r)?(P(e,i,o,!0),Ee(e,w(e,!1,n)),i=o=e.position):e.position===e.lineStart&&ie(e)?h(e,"unexpected end of the document within a single quoted scalar"):(e.position++,o=e.position);h(e,"unexpected end of the stream within a single quoted scalar")}function ei(e,n){var r,i,o,l,t,s;if(s=e.input.charCodeAt(e.position),s!==34)return!1;for(e.kind="scalar",e.result="",e.position++,r=i=e.position;(s=e.input.charCodeAt(e.position))!==0;){if(s===34)return P(e,r,e.position,!0),e.position++,!0;if(s===92){if(P(e,r,e.position,!0),s=e.input.charCodeAt(++e.position),T(s))w(e,!1,n);else if(s<256&&vn[s])e.result+=yn[s],e.position++;else if((t=zr(s))>0){for(o=t,l=0;o>0;o--)s=e.input.charCodeAt(++e.position),(t=Jr(s))>=0?l=(l<<4)+t:h(e,"expected hexadecimal character");e.result+=Qr(l),e.position++}else h(e,"unknown escape sequence");r=i=e.position}else T(s)?(P(e,r,i,!0),Ee(e,w(e,!1,n)),r=i=e.position):e.position===e.lineStart&&ie(e)?h(e,"unexpected end of the document within a double quoted scalar"):(e.position++,i=e.position)}h(e,"unexpected end of the stream within a double quoted scalar")}function ni(e,n){var r=!0,i,o,l,t=e.tag,s,a=e.anchor,u,f,c,p,d,x=Object.create(null),m,v,y,g;if(g=e.input.charCodeAt(e.position),g===91)f=93,d=!1,s=[];else if(g===123)f=125,d=!0,s={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=s),g=e.input.charCodeAt(++e.position);g!==0;){if(w(e,!0,n),g=e.input.charCodeAt(e.position),g===f)return e.position++,e.tag=t,e.anchor=a,e.kind=d?"mapping":"sequence",e.result=s,!0;r?g===44&&h(e,"expected the node content, but found ','"):h(e,"missed comma between flow collection entries"),v=m=y=null,c=p=!1,g===63&&(u=e.input.charCodeAt(e.position+1),I(u)&&(c=p=!0,e.position++,w(e,!0,n))),i=e.line,o=e.lineStart,l=e.position,H(e,n,V,!1,!0),v=e.tag,m=e.result,w(e,!0,n),g=e.input.charCodeAt(e.position),(p||e.line===i)&&g===58&&(c=!0,g=e.input.charCodeAt(++e.position),w(e,!0,n),H(e,n,V,!1,!0),y=e.result),d?j(e,s,x,v,m,y,i,o,l):c?s.push(j(e,null,x,v,m,y,i,o,l)):s.push(m),w(e,!0,n),g=e.input.charCodeAt(e.position),g===44?(r=!0,g=e.input.charCodeAt(++e.position)):r=!1}h(e,"unexpected end of the stream within a flow collection")}function ri(e,n){var r,i,o=he,l=!1,t=!1,s=n,a=0,u=!1,f,c;if(c=e.input.charCodeAt(e.position),c===124)i=!1;else if(c===62)i=!0;else return!1;for(e.kind="scalar",e.result="";c!==0;)if(c=e.input.charCodeAt(++e.position),c===43||c===45)he===o?o=c===43?Pe:Yr:h(e,"repeat of a chomping mode identifier");else if((f=qr(c))>=0)f===0?h(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):t?h(e,"repeat of an indentation width identifier"):(s=n+f-1,t=!0);else break;if(R(c)){do c=e.input.charCodeAt(++e.position);while(R(c));if(c===35)do c=e.input.charCodeAt(++e.position);while(!T(c)&&c!==0)}for(;c!==0;){for(Ae(e),e.lineIndent=0,c=e.input.charCodeAt(e.position);(!t||e.lineIndent<s)&&c===32;)e.lineIndent++,c=e.input.charCodeAt(++e.position);if(!t&&e.lineIndent>s&&(s=e.lineIndent),T(c)){a++;continue}if(e.lineIndent<s){o===Pe?e.result+=C.repeat(`
12
+ `,l?1+a:a):o===he&&l&&(e.result+=`
13
+ `);break}for(i?R(c)?(u=!0,e.result+=C.repeat(`
14
+ `,l?1+a:a)):u?(u=!1,e.result+=C.repeat(`
15
+ `,a+1)):a===0?l&&(e.result+=" "):e.result+=C.repeat(`
16
+ `,a):e.result+=C.repeat(`
17
+ `,l?1+a:a),l=!0,t=!0,a=0,r=e.position;!T(c)&&c!==0;)c=e.input.charCodeAt(++e.position);P(e,r,e.position,!1)}return!0}function De(e,n){var r,i=e.tag,o=e.anchor,l=[],t,s=!1,a;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=l),a=e.input.charCodeAt(e.position);a!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,h(e,"tab characters must not be used in indentation")),!(a!==45||(t=e.input.charCodeAt(e.position+1),!I(t))));){if(s=!0,e.position++,w(e,!0,-1)&&e.lineIndent<=n){l.push(null),a=e.input.charCodeAt(e.position);continue}if(r=e.line,H(e,n,hn,!1,!0),l.push(e.result),w(e,!0,-1),a=e.input.charCodeAt(e.position),(e.line===r||e.lineIndent>n)&&a!==0)h(e,"bad indentation of a sequence entry");else if(e.lineIndent<n)break}return s?(e.tag=i,e.anchor=o,e.kind="sequence",e.result=l,!0):!1}function ii(e,n,r){var i,o,l,t,s,a,u=e.tag,f=e.anchor,c={},p=Object.create(null),d=null,x=null,m=null,v=!1,y=!1,g;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=c),g=e.input.charCodeAt(e.position);g!==0;){if(!v&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,h(e,"tab characters must not be used in indentation")),i=e.input.charCodeAt(e.position+1),l=e.line,(g===63||g===58)&&I(i))g===63?(v&&(j(e,c,p,d,x,null,t,s,a),d=x=m=null),y=!0,v=!0,o=!0):v?(v=!1,o=!0):h(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,g=i;else{if(t=e.line,s=e.lineStart,a=e.position,!H(e,r,dn,!1,!0))break;if(e.line===l){for(g=e.input.charCodeAt(e.position);R(g);)g=e.input.charCodeAt(++e.position);if(g===58)g=e.input.charCodeAt(++e.position),I(g)||h(e,"a whitespace character is expected after the key-value separator within a block mapping"),v&&(j(e,c,p,d,x,null,t,s,a),d=x=m=null),y=!0,v=!1,o=!1,d=e.tag,x=e.result;else if(y)h(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=u,e.anchor=f,!0}else if(y)h(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=u,e.anchor=f,!0}if((e.line===l||e.lineIndent>n)&&(v&&(t=e.line,s=e.lineStart,a=e.position),H(e,n,Z,!0,o)&&(v?x=e.result:m=e.result),v||(j(e,c,p,d,x,m,t,s,a),d=x=m=null),w(e,!0,-1),g=e.input.charCodeAt(e.position)),(e.line===l||e.lineIndent>n)&&g!==0)h(e,"bad indentation of a mapping entry");else if(e.lineIndent<n)break}return v&&j(e,c,p,d,x,null,t,s,a),y&&(e.tag=u,e.anchor=f,e.kind="mapping",e.result=c),y}function oi(e){var n,r=!1,i=!1,o,l,t;if(t=e.input.charCodeAt(e.position),t!==33)return!1;if(e.tag!==null&&h(e,"duplication of a tag property"),t=e.input.charCodeAt(++e.position),t===60?(r=!0,t=e.input.charCodeAt(++e.position)):t===33?(i=!0,o="!!",t=e.input.charCodeAt(++e.position)):o="!",n=e.position,r){do t=e.input.charCodeAt(++e.position);while(t!==0&&t!==62);e.position<e.length?(l=e.input.slice(n,e.position),t=e.input.charCodeAt(++e.position)):h(e,"unexpected end of the stream within a verbatim tag")}else{for(;t!==0&&!I(t);)t===33&&(i?h(e,"tag suffix cannot contain exclamation marks"):(o=e.input.slice(n-1,e.position+1),mn.test(o)||h(e,"named tag handle cannot contain such characters"),i=!0,n=e.position+1)),t=e.input.charCodeAt(++e.position);l=e.input.slice(n,e.position),Wr.test(l)&&h(e,"tag suffix cannot contain flow indicator characters")}l&&!gn.test(l)&&h(e,"tag name cannot contain such characters: "+l);try{l=decodeURIComponent(l)}catch{h(e,"tag name is malformed: "+l)}return r?e.tag=l:F.call(e.tagMap,o)?e.tag=e.tagMap[o]+l:o==="!"?e.tag="!"+l:o==="!!"?e.tag="tag:yaml.org,2002:"+l:h(e,'undeclared tag handle "'+o+'"'),!0}function ti(e){var n,r;if(r=e.input.charCodeAt(e.position),r!==38)return!1;for(e.anchor!==null&&h(e,"duplication of an anchor property"),r=e.input.charCodeAt(++e.position),n=e.position;r!==0&&!I(r)&&!$(r);)r=e.input.charCodeAt(++e.position);return e.position===n&&h(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(n,e.position),!0}function li(e){var n,r,i;if(i=e.input.charCodeAt(e.position),i!==42)return!1;for(i=e.input.charCodeAt(++e.position),n=e.position;i!==0&&!I(i)&&!$(i);)i=e.input.charCodeAt(++e.position);return e.position===n&&h(e,"name of an alias node must contain at least one character"),r=e.input.slice(n,e.position),F.call(e.anchorMap,r)||h(e,'unidentified alias "'+r+'"'),e.result=e.anchorMap[r],w(e,!0,-1),!0}function H(e,n,r,i,o){var l,t,s,a=1,u=!1,f=!1,c,p,d,x,m,v;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,l=t=s=Z===r||hn===r,i&&w(e,!0,-1)&&(u=!0,e.lineIndent>n?a=1:e.lineIndent===n?a=0:e.lineIndent<n&&(a=-1)),a===1)for(;oi(e)||ti(e);)w(e,!0,-1)?(u=!0,s=l,e.lineIndent>n?a=1:e.lineIndent===n?a=0:e.lineIndent<n&&(a=-1)):s=!1;if(s&&(s=u||o),(a===1||Z===r)&&(V===r||dn===r?m=n:m=n+1,v=e.position-e.lineStart,a===1?s&&(De(e,v)||ii(e,v,m))||ni(e,m)?f=!0:(t&&ri(e,m)||Zr(e,m)||ei(e,m)?f=!0:li(e)?(f=!0,(e.tag!==null||e.anchor!==null)&&h(e,"alias node should not have any properties")):Vr(e,m,V===r)&&(f=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):a===0&&(f=s&&De(e,v))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&h(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),c=0,p=e.implicitTypes.length;c<p;c+=1)if(x=e.implicitTypes[c],x.resolve(e.result)){e.result=x.construct(e.result),e.tag=x.tag,e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);break}}else if(e.tag!=="!"){if(F.call(e.typeMap[e.kind||"fallback"],e.tag))x=e.typeMap[e.kind||"fallback"][e.tag];else for(x=null,d=e.typeMap.multi[e.kind||"fallback"],c=0,p=d.length;c<p;c+=1)if(e.tag.slice(0,d[c].tag.length)===d[c].tag){x=d[c];break}x||h(e,"unknown tag !<"+e.tag+">"),e.result!==null&&x.kind!==e.kind&&h(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+x.kind+'", not "'+e.kind+'"'),x.resolve(e.result,e.tag)?(e.result=x.construct(e.result,e.tag),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):h(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||f}function si(e){var n=e.position,r,i,o,l=!1,t;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(t=e.input.charCodeAt(e.position))!==0&&(w(e,!0,-1),t=e.input.charCodeAt(e.position),!(e.lineIndent>0||t!==37));){for(l=!0,t=e.input.charCodeAt(++e.position),r=e.position;t!==0&&!I(t);)t=e.input.charCodeAt(++e.position);for(i=e.input.slice(r,e.position),o=[],i.length<1&&h(e,"directive name must not be less than one character in length");t!==0;){for(;R(t);)t=e.input.charCodeAt(++e.position);if(t===35){do t=e.input.charCodeAt(++e.position);while(t!==0&&!T(t));break}if(T(t))break;for(r=e.position;t!==0&&!I(t);)t=e.input.charCodeAt(++e.position);o.push(e.input.slice(r,e.position))}t!==0&&Ae(e),F.call(Ne,i)?Ne[i](e,i,o):ee(e,'unknown document directive "'+i+'"')}if(w(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,w(e,!0,-1)):l&&h(e,"directives end mark is expected"),H(e,e.lineIndent-1,Z,!1,!0),w(e,!0,-1),e.checkLineBreaks&&Kr.test(e.input.slice(n,e.position))&&ee(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&ie(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,w(e,!0,-1));return}if(e.position<e.length-1)h(e,"end of the stream or a document separator is expected");else return}function Cn(e,n){e=String(e),n=n||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
18
+ `),e.charCodeAt(0)===65279&&(e=e.slice(1)));var r=new Xr(e,n),i=e.indexOf("\0");for(i!==-1&&(r.position=i,h(r,"null byte is not allowed in input")),r.input+="\0";r.input.charCodeAt(r.position)===32;)r.lineIndent+=1,r.position+=1;for(;r.position<r.length-1;)si(r);return r.documents}function ai(e,n,r){n!==null&&typeof n=="object"&&typeof r>"u"&&(r=n,n=null);var i=Cn(e,r);if(typeof n!="function")return i;for(var o=0,l=i.length;o<l;o+=1)n(i[o])}function ci(e,n){var r=Cn(e,n);if(r.length!==0){if(r.length===1)return r[0];throw new S("expected a single document in the stream, but found more")}}var ui=ai,fi=ci,An={loadAll:ui,load:fi},En=Object.prototype.toString,bn=Object.prototype.hasOwnProperty,be=65279,pi=9,J=10,di=13,hi=32,mi=33,gi=34,ge=35,xi=37,vi=38,yi=39,wi=42,Sn=44,Ci=45,ne=58,Ai=61,Ei=62,bi=63,Si=64,In=91,Tn=93,Ii=96,kn=123,Ti=124,On=125,E={};E[0]="\\0";E[7]="\\a";E[8]="\\b";E[9]="\\t";E[10]="\\n";E[11]="\\v";E[12]="\\f";E[13]="\\r";E[27]="\\e";E[34]='\\"';E[92]="\\\\";E[133]="\\N";E[160]="\\_";E[8232]="\\L";E[8233]="\\P";var ki=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],Oi=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function _i(e,n){var r,i,o,l,t,s,a;if(n===null)return{};for(r={},i=Object.keys(n),o=0,l=i.length;o<l;o+=1)t=i[o],s=String(n[t]),t.slice(0,2)==="!!"&&(t="tag:yaml.org,2002:"+t.slice(2)),a=e.compiledTypeMap.fallback[t],a&&bn.call(a.styleAliases,s)&&(s=a.styleAliases[s]),r[t]=s;return r}function Pi(e){var n,r,i;if(n=e.toString(16).toUpperCase(),e<=255)r="x",i=2;else if(e<=65535)r="u",i=4;else if(e<=4294967295)r="U",i=8;else throw new S("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+r+C.repeat("0",i-n.length)+n}var Fi=1,z=2;function Li(e){this.schema=e.schema||Ce,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=C.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=_i(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType=e.quotingType==='"'?z:Fi,this.forceQuotes=e.forceQuotes||!1,this.replacer=typeof e.replacer=="function"?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function Me(e,n){for(var r=C.repeat(" ",n),i=0,o=-1,l="",t,s=e.length;i<s;)o=e.indexOf(`
19
+ `,i),o===-1?(t=e.slice(i),i=s):(t=e.slice(i,o+1),i=o+1),t.length&&t!==`
20
+ `&&(l+=r),l+=t;return l}function xe(e,n){return`
21
+ `+C.repeat(" ",e.indent*n)}function Ni(e,n){var r,i,o;for(r=0,i=e.implicitTypes.length;r<i;r+=1)if(o=e.implicitTypes[r],o.resolve(n))return!0;return!1}function re(e){return e===hi||e===pi}function q(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==be||65536<=e&&e<=1114111}function Ge(e){return q(e)&&e!==be&&e!==di&&e!==J}function $e(e,n,r){var i=Ge(e),o=i&&!re(e);return(r?i:i&&e!==Sn&&e!==In&&e!==Tn&&e!==kn&&e!==On)&&e!==ge&&!(n===ne&&!o)||Ge(n)&&!re(n)&&e===ge||n===ne&&o}function Ri(e){return q(e)&&e!==be&&!re(e)&&e!==Ci&&e!==bi&&e!==ne&&e!==Sn&&e!==In&&e!==Tn&&e!==kn&&e!==On&&e!==ge&&e!==vi&&e!==wi&&e!==mi&&e!==Ti&&e!==Ai&&e!==Ei&&e!==yi&&e!==gi&&e!==xi&&e!==Si&&e!==Ii}function Di(e){return!re(e)&&e!==ne}function K(e,n){var r=e.charCodeAt(n),i;return r>=55296&&r<=56319&&n+1<e.length&&(i=e.charCodeAt(n+1),i>=56320&&i<=57343)?(r-55296)*1024+i-56320+65536:r}function _n(e){var n=/^\n* /;return n.test(e)}var Pn=1,ve=2,Fn=3,Ln=4,G=5;function Mi(e,n,r,i,o,l,t,s){var a,u=0,f=null,c=!1,p=!1,d=i!==-1,x=-1,m=Ri(K(e,0))&&Di(K(e,e.length-1));if(n||t)for(a=0;a<e.length;u>=65536?a+=2:a++){if(u=K(e,a),!q(u))return G;m=m&&$e(u,f,s),f=u}else{for(a=0;a<e.length;u>=65536?a+=2:a++){if(u=K(e,a),u===J)c=!0,d&&(p=p||a-x-1>i&&e[x+1]!==" ",x=a);else if(!q(u))return G;m=m&&$e(u,f,s),f=u}p=p||d&&a-x-1>i&&e[x+1]!==" "}return!c&&!p?m&&!t&&!o(e)?Pn:l===z?G:ve:r>9&&_n(e)?G:t?l===z?G:ve:p?Ln:Fn}function Gi(e,n,r,i,o){e.dump=function(){if(n.length===0)return e.quotingType===z?'""':"''";if(!e.noCompatMode&&(ki.indexOf(n)!==-1||Oi.test(n)))return e.quotingType===z?'"'+n+'"':"'"+n+"'";var l=e.indent*Math.max(1,r),t=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-l),s=i||e.flowLevel>-1&&r>=e.flowLevel;function a(u){return Ni(e,u)}switch(Mi(n,s,e.indent,t,a,e.quotingType,e.forceQuotes&&!i,o)){case Pn:return n;case ve:return"'"+n.replace(/'/g,"''")+"'";case Fn:return"|"+je(n,e.indent)+He(Me(n,l));case Ln:return">"+je(n,e.indent)+He(Me($i(n,t),l));case G:return'"'+ji(n)+'"';default:throw new S("impossible error: invalid scalar style")}}()}function je(e,n){var r=_n(e)?String(n):"",i=e[e.length-1]===`
22
22
  `,o=i&&(e[e.length-2]===`
23
23
  `||e===`
24
- `),t=o?"+":i?"":"-";return r+t+`
25
- `}function Pe(e){return e[e.length-1]===`
26
- `?e.slice(0,-1):e}function ki(e,n){for(var r=/(\n+)([^\n]*)/g,i=function(){var a=e.indexOf(`
27
- `);return a=a!==-1?a:e.length,r.lastIndex=a,Le(e.slice(0,a),n)}(),o=e[0]===`
28
- `||e[0]===" ",t,l;l=r.exec(e);){var u=l[1],c=l[2];t=c[0]===" ",i+=u+(!o&&!t&&c!==""?`
29
- `:"")+Le(c,n),o=t}return i}function Le(e,n){if(e===""||e[0]===" ")return e;for(var r=/ [^ ]/g,i,o=0,t,l=0,u=0,c="";i=r.exec(e);)u=i.index,u-o>n&&(t=l>o?l:u,c+=`
30
- `+e.slice(o,t),o=t+1),l=u;return c+=`
31
- `,e.length-o>n&&l>o?c+=e.slice(o,l)+`
32
- `+e.slice(l+1):c+=e.slice(o),c.slice(1)}function Fi(e){for(var n="",r=0,i,o=0;o<e.length;r>=65536?o+=2:o++)r=Y(e,o),i=C[r],!i&&K(r)?(n+=e[o],r>=65536&&(n+=e[o+1])):n+=i||wi(r);return n}function Oi(e,n,r){var i="",o=e.tag,t,l,u;for(t=0,l=r.length;t<l;t+=1)u=r[t],e.replacer&&(u=e.replacer.call(r,String(t),u)),(T(e,n,u,!1,!1)||typeof u>"u"&&T(e,n,null,!1,!1))&&(i!==""&&(i+=","+(e.condenseFlow?"":" ")),i+=e.dump);e.tag=o,e.dump="["+i+"]"}function Ne(e,n,r,i){var o="",t=e.tag,l,u,c;for(l=0,u=r.length;l<u;l+=1)c=r[l],e.replacer&&(c=e.replacer.call(r,String(l),c)),(T(e,n+1,c,!0,!0,!1,!0)||typeof c>"u"&&T(e,n+1,null,!0,!0,!1,!0))&&((!i||o!=="")&&(o+=ae(e,n)),e.dump&&H===e.dump.charCodeAt(0)?o+="-":o+="- ",o+=e.dump);e.tag=t,e.dump=o||"[]"}function Pi(e,n,r){var i="",o=e.tag,t=Object.keys(r),l,u,c,a,f;for(l=0,u=t.length;l<u;l+=1)f="",i!==""&&(f+=", "),e.condenseFlow&&(f+='"'),c=t[l],a=r[c],e.replacer&&(a=e.replacer.call(r,c,a)),T(e,n,c,!1,!1)&&(e.dump.length>1024&&(f+="? "),f+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),T(e,n,a,!1,!1)&&(f+=e.dump,i+=f));e.tag=o,e.dump="{"+i+"}"}function Li(e,n,r,i){var o="",t=e.tag,l=Object.keys(r),u,c,a,f,s,d;if(e.sortKeys===!0)l.sort();else if(typeof e.sortKeys=="function")l.sort(e.sortKeys);else if(e.sortKeys)throw new E("sortKeys must be a boolean or a function");for(u=0,c=l.length;u<c;u+=1)d="",(!i||o!=="")&&(d+=ae(e,n)),a=l[u],f=r[a],e.replacer&&(f=e.replacer.call(r,a,f)),T(e,n+1,a,!0,!0,!0)&&(s=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,s&&(e.dump&&H===e.dump.charCodeAt(0)?d+="?":d+="? "),d+=e.dump,s&&(d+=ae(e,n)),T(e,n+1,f,!0,s)&&(e.dump&&H===e.dump.charCodeAt(0)?d+=":":d+=": ",d+=e.dump,o+=d));e.tag=t,e.dump=o||"{}"}function Re(e,n,r){var i,o,t,l,u,c;for(o=r?e.explicitTypes:e.implicitTypes,t=0,l=o.length;t<l;t+=1)if(u=o[t],(u.instanceOf||u.predicate)&&(!u.instanceOf||typeof n=="object"&&n instanceof u.instanceOf)&&(!u.predicate||u.predicate(n))){if(r?u.multi&&u.representName?e.tag=u.representName(n):e.tag=u.tag:e.tag="?",u.represent){if(c=e.styleMap[u.tag]||u.defaultStyle,hn.call(u.represent)==="[object Function]")i=u.represent(n,c);else if(mn.call(u.represent,c))i=u.represent[c](n,c);else throw new E("!<"+u.tag+'> tag resolver accepts not "'+c+'" style');e.dump=i}return!0}return!1}function T(e,n,r,i,o,t,l){e.tag=null,e.dump=r,Re(e,r,!1)||Re(e,r,!0);var u=hn.call(e.dump),c=i,a;i&&(i=e.flowLevel<0||e.flowLevel>n);var f=u==="[object Object]"||u==="[object Array]",s,d;if(f&&(s=e.duplicates.indexOf(r),d=s!==-1),(e.tag!==null&&e.tag!=="?"||d||e.indent!==2&&n>0)&&(o=!1),d&&e.usedDuplicates[s])e.dump="*ref_"+s;else{if(f&&d&&!e.usedDuplicates[s]&&(e.usedDuplicates[s]=!0),u==="[object Object]")i&&Object.keys(e.dump).length!==0?(Li(e,n,e.dump,o),d&&(e.dump="&ref_"+s+e.dump)):(Pi(e,n,e.dump),d&&(e.dump="&ref_"+s+" "+e.dump));else if(u==="[object Array]")i&&e.dump.length!==0?(e.noArrayIndent&&!l&&n>0?Ne(e,n-1,e.dump,o):Ne(e,n,e.dump,o),d&&(e.dump="&ref_"+s+e.dump)):(Oi(e,n,e.dump),d&&(e.dump="&ref_"+s+" "+e.dump));else if(u==="[object String]")e.tag!=="?"&&Ti(e,e.dump,n,t,c);else{if(u==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new E("unacceptable kind of an object to dump "+u)}e.tag!==null&&e.tag!=="?"&&(a=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?a="!"+a:a.slice(0,18)==="tag:yaml.org,2002:"?a="!!"+a.slice(18):a="!<"+a+">",e.dump=a+" "+e.dump)}return!0}function Ni(e,n){var r=[],i=[],o,t;for(fe(e,r,i),o=0,t=i.length;o<t;o+=1)n.duplicates.push(r[i[o]]);n.usedDuplicates=new Array(t)}function fe(e,n,r){var i,o,t;if(e!==null&&typeof e=="object")if(o=n.indexOf(e),o!==-1)r.indexOf(o)===-1&&r.push(o);else if(n.push(e),Array.isArray(e))for(o=0,t=e.length;o<t;o+=1)fe(e[o],n,r);else for(i=Object.keys(e),o=0,t=i.length;o<t;o+=1)fe(e[i[o]],n,r)}function Ri(e,n){n=n||{};var r=new Ei(n);r.noRefs||Ni(e,r);var i=e;return r.replacer&&(i=r.replacer.call({"":i},"",i)),T(r,0,i,!0,!0)?r.dump+`
33
- `:""}var Di=Ri,Mi={dump:Di};function xe(e,n){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+n+" instead, which is now safe by default.")}}var ji=w,$i=je,Gi=Be,Yi=We,Bi=Qe,Hi=de,Ui=dn.load,Ki=dn.loadAll,qi=Mi.dump,Wi=E,Qi={binary:Ze,float:qe,map:Ye,null:He,pairs:nn,set:rn,timestamp:ze,bool:Ue,int:Ke,merge:Je,omap:en,seq:Ge,str:$e},Vi=xe("safeLoad","load"),Xi=xe("safeLoadAll","loadAll"),zi=xe("safeDump","dump"),bn={Type:ji,Schema:$i,FAILSAFE_SCHEMA:Gi,JSON_SCHEMA:Yi,CORE_SCHEMA:Bi,DEFAULT_SCHEMA:Hi,load:Ui,loadAll:Ki,dump:qi,YAMLException:Wi,types:Qi,safeLoad:Vi,safeLoadAll:Xi,safeDump:zi};var ee=".cligr.yml",I=class extends Error{constructor(n){super(n),this.name="ConfigError"}},O=class{configPath;constructor(n){if(n)this.configPath=q.resolve(n);else{let r=q.join(_n.homedir(),ee),i=q.resolve(ee);Z.existsSync(r)?this.configPath=r:Z.existsSync(i)?this.configPath=i:this.configPath=r}}load(){if(!Z.existsSync(this.configPath))throw new I(`Config file not found. Looking for:
34
- - ${q.join(_n.homedir(),ee)}
35
- - ${q.resolve(ee)}`);let n=Z.readFileSync(this.configPath,"utf-8"),r;try{r=bn.load(n)}catch(i){throw new I(`Invalid YAML: ${i.message}`)}return this.validate(r)}validate(n){if(!n||typeof n!="object")throw new I("Config must be an object");let r=n;if(!r.groups||typeof r.groups!="object")throw new I('Config must have a "groups" object');for(let[i,o]of Object.entries(r.groups))if(o&&typeof o=="object"){let t=o;this.validateItems(t.items,i)}return r}validateItems(n,r){if(!n||typeof n!="object"||Array.isArray(n))throw new I(`Group "${r}": items must be an object with named entries, e.g.:
24
+ `),l=o?"+":i?"":"-";return r+l+`
25
+ `}function He(e){return e[e.length-1]===`
26
+ `?e.slice(0,-1):e}function $i(e,n){for(var r=/(\n+)([^\n]*)/g,i=function(){var u=e.indexOf(`
27
+ `);return u=u!==-1?u:e.length,r.lastIndex=u,Be(e.slice(0,u),n)}(),o=e[0]===`
28
+ `||e[0]===" ",l,t;t=r.exec(e);){var s=t[1],a=t[2];l=a[0]===" ",i+=s+(!o&&!l&&a!==""?`
29
+ `:"")+Be(a,n),o=l}return i}function Be(e,n){if(e===""||e[0]===" ")return e;for(var r=/ [^ ]/g,i,o=0,l,t=0,s=0,a="";i=r.exec(e);)s=i.index,s-o>n&&(l=t>o?t:s,a+=`
30
+ `+e.slice(o,l),o=l+1),t=s;return a+=`
31
+ `,e.length-o>n&&t>o?a+=e.slice(o,t)+`
32
+ `+e.slice(t+1):a+=e.slice(o),a.slice(1)}function ji(e){for(var n="",r=0,i,o=0;o<e.length;r>=65536?o+=2:o++)r=K(e,o),i=E[r],!i&&q(r)?(n+=e[o],r>=65536&&(n+=e[o+1])):n+=i||Pi(r);return n}function Hi(e,n,r){var i="",o=e.tag,l,t,s;for(l=0,t=r.length;l<t;l+=1)s=r[l],e.replacer&&(s=e.replacer.call(r,String(l),s)),(O(e,n,s,!1,!1)||typeof s>"u"&&O(e,n,null,!1,!1))&&(i!==""&&(i+=","+(e.condenseFlow?"":" ")),i+=e.dump);e.tag=o,e.dump="["+i+"]"}function Ye(e,n,r,i){var o="",l=e.tag,t,s,a;for(t=0,s=r.length;t<s;t+=1)a=r[t],e.replacer&&(a=e.replacer.call(r,String(t),a)),(O(e,n+1,a,!0,!0,!1,!0)||typeof a>"u"&&O(e,n+1,null,!0,!0,!1,!0))&&((!i||o!=="")&&(o+=xe(e,n)),e.dump&&J===e.dump.charCodeAt(0)?o+="-":o+="- ",o+=e.dump);e.tag=l,e.dump=o||"[]"}function Bi(e,n,r){var i="",o=e.tag,l=Object.keys(r),t,s,a,u,f;for(t=0,s=l.length;t<s;t+=1)f="",i!==""&&(f+=", "),e.condenseFlow&&(f+='"'),a=l[t],u=r[a],e.replacer&&(u=e.replacer.call(r,a,u)),O(e,n,a,!1,!1)&&(e.dump.length>1024&&(f+="? "),f+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),O(e,n,u,!1,!1)&&(f+=e.dump,i+=f));e.tag=o,e.dump="{"+i+"}"}function Yi(e,n,r,i){var o="",l=e.tag,t=Object.keys(r),s,a,u,f,c,p;if(e.sortKeys===!0)t.sort();else if(typeof e.sortKeys=="function")t.sort(e.sortKeys);else if(e.sortKeys)throw new S("sortKeys must be a boolean or a function");for(s=0,a=t.length;s<a;s+=1)p="",(!i||o!=="")&&(p+=xe(e,n)),u=t[s],f=r[u],e.replacer&&(f=e.replacer.call(r,u,f)),O(e,n+1,u,!0,!0,!0)&&(c=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,c&&(e.dump&&J===e.dump.charCodeAt(0)?p+="?":p+="? "),p+=e.dump,c&&(p+=xe(e,n)),O(e,n+1,f,!0,c)&&(e.dump&&J===e.dump.charCodeAt(0)?p+=":":p+=": ",p+=e.dump,o+=p));e.tag=l,e.dump=o||"{}"}function Ue(e,n,r){var i,o,l,t,s,a;for(o=r?e.explicitTypes:e.implicitTypes,l=0,t=o.length;l<t;l+=1)if(s=o[l],(s.instanceOf||s.predicate)&&(!s.instanceOf||typeof n=="object"&&n instanceof s.instanceOf)&&(!s.predicate||s.predicate(n))){if(r?s.multi&&s.representName?e.tag=s.representName(n):e.tag=s.tag:e.tag="?",s.represent){if(a=e.styleMap[s.tag]||s.defaultStyle,En.call(s.represent)==="[object Function]")i=s.represent(n,a);else if(bn.call(s.represent,a))i=s.represent[a](n,a);else throw new S("!<"+s.tag+'> tag resolver accepts not "'+a+'" style');e.dump=i}return!0}return!1}function O(e,n,r,i,o,l,t){e.tag=null,e.dump=r,Ue(e,r,!1)||Ue(e,r,!0);var s=En.call(e.dump),a=i,u;i&&(i=e.flowLevel<0||e.flowLevel>n);var f=s==="[object Object]"||s==="[object Array]",c,p;if(f&&(c=e.duplicates.indexOf(r),p=c!==-1),(e.tag!==null&&e.tag!=="?"||p||e.indent!==2&&n>0)&&(o=!1),p&&e.usedDuplicates[c])e.dump="*ref_"+c;else{if(f&&p&&!e.usedDuplicates[c]&&(e.usedDuplicates[c]=!0),s==="[object Object]")i&&Object.keys(e.dump).length!==0?(Yi(e,n,e.dump,o),p&&(e.dump="&ref_"+c+e.dump)):(Bi(e,n,e.dump),p&&(e.dump="&ref_"+c+" "+e.dump));else if(s==="[object Array]")i&&e.dump.length!==0?(e.noArrayIndent&&!t&&n>0?Ye(e,n-1,e.dump,o):Ye(e,n,e.dump,o),p&&(e.dump="&ref_"+c+e.dump)):(Hi(e,n,e.dump),p&&(e.dump="&ref_"+c+" "+e.dump));else if(s==="[object String]")e.tag!=="?"&&Gi(e,e.dump,n,l,a);else{if(s==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new S("unacceptable kind of an object to dump "+s)}e.tag!==null&&e.tag!=="?"&&(u=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?u="!"+u:u.slice(0,18)==="tag:yaml.org,2002:"?u="!!"+u.slice(18):u="!<"+u+">",e.dump=u+" "+e.dump)}return!0}function Ui(e,n){var r=[],i=[],o,l;for(ye(e,r,i),o=0,l=i.length;o<l;o+=1)n.duplicates.push(r[i[o]]);n.usedDuplicates=new Array(l)}function ye(e,n,r){var i,o,l;if(e!==null&&typeof e=="object")if(o=n.indexOf(e),o!==-1)r.indexOf(o)===-1&&r.push(o);else if(n.push(e),Array.isArray(e))for(o=0,l=e.length;o<l;o+=1)ye(e[o],n,r);else for(i=Object.keys(e),o=0,l=i.length;o<l;o+=1)ye(e[i[o]],n,r)}function Ki(e,n){n=n||{};var r=new Li(n);r.noRefs||Ui(e,r);var i=e;return r.replacer&&(i=r.replacer.call({"":i},"",i)),O(r,0,i,!0,!0)?r.dump+`
33
+ `:""}var Wi=Ki,Ji={dump:Wi};function Se(e,n){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+n+" instead, which is now safe by default.")}}var zi=A,qi=Je,Qi=Xe,Xi=rn,Vi=on,Zi=Ce,eo=An.load,no=An.loadAll,ro=Ji.dump,io=S,oo={binary:cn,float:nn,map:Qe,null:Ve,pairs:fn,set:pn,timestamp:sn,bool:Ze,int:en,merge:an,omap:un,seq:qe,str:ze},to=Se("safeLoad","load"),lo=Se("safeLoadAll","loadAll"),so=Se("safeDump","dump"),Ie={Type:zi,Schema:qi,FAILSAFE_SCHEMA:Qi,JSON_SCHEMA:Xi,CORE_SCHEMA:Vi,DEFAULT_SCHEMA:Zi,load:eo,loadAll:no,dump:ro,YAMLException:io,types:oo,safeLoad:to,safeLoadAll:lo,safeDump:so};var oe=".cligr.yml",b=class extends Error{constructor(n){super(n),this.name="ConfigError"}},k=class{configPath;constructor(n){if(n)this.configPath=X.resolve(n);else{let r=X.join(Nn.homedir(),oe),i=X.resolve(oe);Q.existsSync(r)?this.configPath=r:Q.existsSync(i)?this.configPath=i:this.configPath=r}}load(){if(!Q.existsSync(this.configPath))throw new b(`Config file not found. Looking for:
34
+ - ${X.join(Nn.homedir(),oe)}
35
+ - ${X.resolve(oe)}`);let n=Q.readFileSync(this.configPath,"utf-8"),r;try{r=Ie.load(n)}catch(i){throw new b(`Invalid YAML: ${i.message}`)}return this.validate(r)}validate(n){if(!n||typeof n!="object")throw new b("Config must be an object");let r=n;if(!r.groups||typeof r.groups!="object")throw new b('Config must have a "groups" object');for(let[i,o]of Object.entries(r.groups))if(o&&typeof o=="object"){let l=o;this.validateItems(l.items,i),this.validateDisabledItems(l.items,l.disabledItems,i)}return r}validateItems(n,r){if(!n||typeof n!="object"||Array.isArray(n))throw new b(`Group "${r}": items must be an object with named entries, e.g.:
36
36
  items:
37
- serviceName: "value1,value2"`);let i=new Set;for(let[o,t]of Object.entries(n)){if(typeof t!="string")throw new I(`Group "${r}": item "${o}" must have a string value`);if(i.has(o))throw new I(`Group "${r}": duplicate item name "${o}". Item names must be unique within a group.`);i.add(o)}}normalizeItems(n){return Object.entries(n).map(([r,i])=>({name:r,value:i}))}getGroup(n){let r=this.load(),i=r.groups[n];if(!i){let c=Object.keys(r.groups).join(", ");throw new I(`Unknown group: ${n}. Available: ${c}`)}let o=this.normalizeItems(i.items),t=null,l=null;r.tools&&r.tools[i.tool]?(t=r.tools[i.tool].cmd,l=i.tool):(l=null,t=null);let u=i.params||{};return{config:i,items:o,tool:l,toolTemplate:t,params:u}}listGroups(){let n=this.load();return Object.keys(n.groups)}};var ne=class{static expandNamedParams(n,r){let i=n;for(let[o,t]of Object.entries(r)){let l=`$${o}`;i=i.replaceAll(l,t)}return i}static expand(n,r,i,o={}){let t=r.value.split(",").map(c=>c.trim()),l=r.name,u=n;for(let c=t.length-1;c>=0;c--){let a=`$${c+1}`;u=u.replaceAll(a,t[c])}return u=this.expandNamedParams(u,o),{name:l,args:t,fullCmd:u}}static parseItem(n,r,i,o,t={}){if(r){let l=this.expand(r,i,o,t),u=r.match(/\$\d+/g)||[],c=0;for(let a of u){let f=parseInt(a.substring(1),10);f>c&&(c=f)}if(c>0&&l.args.length>c){let a=l.args.slice(c);l.fullCmd=`${l.fullCmd} ${a.join(" ")}`}return l}else{let l=i.value.split(",").map(a=>a.trim()),u=i.name,c=n?`${n} ${i.value}`:i.value;return{name:u,args:l,fullCmd:c}}}};import{spawn as Zi}from"child_process";import{promises as N}from"fs";import re from"path";import Ji from"os";var $=class{pidsDir;constructor(){this.pidsDir=re.join(Ji.homedir(),".cligr","pids")}async ensureDir(){try{await N.mkdir(this.pidsDir,{recursive:!0})}catch(n){if(n.code!=="EEXIST")throw n}}sanitizeItemName(n){return n.replace(/[<>:"/\\|?*]/g,"_")}getPidFilePath(n,r){let i=this.sanitizeItemName(r);return re.join(this.pidsDir,`${n}_${i}.pid`)}async writePid(n){await this.ensureDir();let r=this.getPidFilePath(n.groupName,n.itemName);await N.writeFile(r,JSON.stringify(n,null,2),"utf-8")}async readPidsByGroup(n){await this.ensureDir();let r=[];try{let i=await N.readdir(this.pidsDir),o=`${n}_`;for(let t of i)if(t.startsWith(o)&&t.endsWith(".pid"))try{let l=await N.readFile(re.join(this.pidsDir,t),"utf-8");r.push(JSON.parse(l))}catch{continue}}catch{return[]}return r}async readAllPids(){await this.ensureDir();let n=[];try{let r=await N.readdir(this.pidsDir);for(let i of r)if(i.endsWith(".pid"))try{let o=await N.readFile(re.join(this.pidsDir,i),"utf-8");n.push(JSON.parse(o))}catch{continue}}catch{return[]}return n}async deletePid(n,r){let i=this.getPidFilePath(n,r);try{await N.unlink(i)}catch(o){if(o.code!=="ENOENT")throw o}}async deleteGroupPids(n){let r=await this.readPidsByGroup(n);for(let i of r)await this.deletePid(i.groupName,i.itemName)}isPidRunning(n){try{return process.kill(n,0),!0}catch{return!1}}isPidEntryValid(n){if(!this.isPidRunning(n.pid))return!1;let r=Date.now()-5*60*1e3;return n.startTime>r}async cleanupStalePids(){let n=await this.readAllPids(),r=[];for(let i of n)this.isPidEntryValid(i)||(r.push(i),await this.deletePid(i.groupName,i.itemName));return r}async getRunningGroups(){let n=await this.readAllPids(),r=new Set(n.map(i=>i.groupName));return Array.from(r)}};var ve=class{constructor(n,r,i="running"){this.item=n;this.process=r;this.status=i}},ie=class{groups=new Map;restartTimestamps=new Map;maxRestarts=3;restartWindow=1e4;pidStore=new $;spawnGroup(n,r,i){if(this.groups.has(n))throw new Error(`Group ${n} is already running`);let o=[];for(let t of r){let l=this.spawnProcess(t,n,i);o.push(new ve(t,l))}this.groups.set(n,o)}spawnProcess(n,r,i){let{cmd:o,args:t}=this.parseCommand(n.fullCmd),l=Zi(o,t,{stdio:["inherit","pipe","pipe"],shell:!1,windowsHide:!0});if(this.pidStore.deletePid(r,n.name).catch(()=>{}),l.pid){let u={pid:l.pid,groupName:r,itemName:n.name,startTime:Date.now(),restartPolicy:i,fullCmd:n.fullCmd};this.pidStore.writePid(u).catch(c=>{console.error(`[${n.name}] Failed to write PID file:`,c)})}return l.stdout&&l.stdout.on("data",u=>{process.stdout.write(`[${n.name}] ${u}`)}),l.stderr&&l.stderr.on("data",u=>{process.stderr.write(`[${n.name}] ${u}`)}),l.on("exit",(u,c)=>{this.handleExit(r,n,i,u,c)}),l}parseCommand(n){let r=[],i="",o=!1,t="";for(let l=0;l<n.length;l++){let u=n[l],c=n[l+1];(u==='"'||u==="'")&&!o?(o=!0,t=u):u===t&&o?(o=!1,t=""):u===" "&&!o?i&&(r.push(i),i=""):i+=u}return i&&r.push(i),{cmd:r[0]||"",args:r.slice(1)}}handleExit(n,r,i,o,t){if(i==="unless-stopped"&&t==="SIGTERM"){this.pidStore.deletePid(n,r.name).catch(()=>{});return}if(i==="no"){this.pidStore.deletePid(n,r.name).catch(()=>{});return}let l=`${n}-${r.name}`,u=Date.now(),a=(this.restartTimestamps.get(l)||[]).filter(f=>u-f<this.restartWindow);if(a.push(u),this.restartTimestamps.set(l,a),a.length>this.maxRestarts){console.error(`[${r.name}] Crash loop detected. Stopping restarts.`),this.pidStore.deletePid(n,r.name).catch(()=>{});return}setTimeout(()=>{console.log(`[${r.name}] Restarting... (exit code: ${o})`);let f=this.spawnProcess(r,n,i),s=this.groups.get(n);if(s){let d=s.find(h=>h.item.name===r.name);d&&(d.process=f)}},1e3)}killGroup(n){let r=this.groups.get(n);if(!r)return Promise.resolve();let i=r.map(o=>this.killProcess(o.process));return this.groups.delete(n),Promise.all(i).then(async()=>{await this.pidStore.deleteGroupPids(n)})}killPid(n){return new Promise((r,i)=>{try{process.kill(n,"SIGTERM");let o=setTimeout(()=>{try{process.kill(n,"SIGKILL")}catch{}},5e3),t=setInterval(()=>{this.pidStore.isPidRunning(n)||(clearTimeout(o),clearInterval(t),r())},100);this.pidStore.isPidRunning(n)||(clearTimeout(o),clearInterval(t),r())}catch(o){i(o)}})}killProcess(n){return new Promise(r=>{n.kill("SIGTERM");let i=setTimeout(()=>{n.killed||n.kill("SIGKILL")},5e3);n.on("exit",()=>{clearTimeout(i),r()}),(n.killed||n.exitCode!==null)&&(clearTimeout(i),r())})}killAll(){let n=[];for(let r of this.groups.keys())n.push(this.killGroup(r));return Promise.all(n).then(()=>{})}getGroupStatus(n){let r=this.groups.get(n);return r?r.map(i=>i.status):[]}isGroupRunning(n){return this.groups.has(n)}getRunningGroups(){return Array.from(this.groups.keys())}};async function ye(e){let n=new O,r=new ie,i=new $;try{await i.cleanupStalePids();let{config:o,items:t,tool:l,toolTemplate:u,params:c}=n.getGroup(e),a=t.map((f,s)=>ne.parseItem(l,u,f,s,c));return r.spawnGroup(e,a,o.restart),console.log(`Started group ${e} with ${a.length} process(es)`),console.log("Press Ctrl+C to stop..."),new Promise(f=>{let s=async()=>{console.log(`
38
- Shutting down...`),process.removeListener("SIGINT",s),process.removeListener("SIGTERM",s),await r.killAll(),f(0)};process.on("SIGINT",s),process.on("SIGTERM",s)})}catch(o){if(o instanceof Error&&o.name==="ConfigError")return console.error(o.message),1;throw o}}async function In(e){let n=new O;try{let{config:r,items:i}=n.getGroup(e);console.log(`
37
+ serviceName: "value1,value2"`);let i=new Set;for(let[o,l]of Object.entries(n)){if(typeof l!="string")throw new b(`Group "${r}": item "${o}" must have a string value`);if(i.has(o))throw new b(`Group "${r}": duplicate item name "${o}". Item names must be unique within a group.`);i.add(o)}}validateDisabledItems(n,r,i){if(r==null)return;if(!Array.isArray(r))throw new b(`Group "${i}": disabledItems must be an array of strings`);let o=new Set,l=n&&typeof n=="object"&&!Array.isArray(n)?new Set(Object.keys(n)):new Set;for(let t of r){if(typeof t!="string")throw new b(`Group "${i}": disabledItems must be an array of strings`);if(o.has(t))throw new b(`Group "${i}": disabledItems contains duplicate "${t}"`);if(o.add(t),!l.has(t))throw new b(`Group "${i}": disabledItems entry "${t}" does not match any item`)}}normalizeItems(n){return Object.entries(n).map(([r,i])=>({name:r,value:i}))}getGroup(n){let r=this.load(),i=r.groups[n];if(!i){let f=Object.keys(r.groups).join(", ");throw new b(`Unknown group: ${n}. Available: ${f}`)}let o=new Set(i.disabledItems||[]),l={};for(let[f,c]of Object.entries(i.items))o.has(f)||(l[f]=c);let t=this.normalizeItems(l),s=null,a=null;r.tools&&r.tools[i.tool]?(s=r.tools[i.tool].cmd,a=i.tool):(a=null,s=null);let u=i.params||{};return{config:i,items:t,tool:a,toolTemplate:s,params:u}}saveConfig(n){let r=Ie.dump(n,{indent:2,lineWidth:-1});Q.writeFileSync(this.configPath,r,"utf-8")}toggleItem(n,r,i){let o=this.load(),l=o.groups[n];if(!l)throw new b(`Unknown group: ${n}`);if(!Object.hasOwn(l.items||{},r))throw new b(`Item "${r}" not found in group "${n}"`);let t=new Set(l.disabledItems||[]);i?t.delete(r):t.add(r),t.size===0?delete l.disabledItems:l.disabledItems=Array.from(t),this.saveConfig(o)}listGroups(){let n=this.load();return Object.keys(n.groups)}};var D=class{static expandNamedParams(n,r){let i=n;for(let[o,l]of Object.entries(r)){let t=`$${o}`;i=i.replaceAll(t,l)}return i}static expand(n,r,i,o={}){let l=r.value.split(",").map(a=>a.trim()),t=r.name,s=n;for(let a=l.length-1;a>=0;a--){let u=`$${a+1}`;s=s.replaceAll(u,l[a])}return s=this.expandNamedParams(s,o),{name:t,args:l,fullCmd:s}}static parseItem(n,r,i,o,l={}){if(r){let t=this.expand(r,i,o,l),s=r.match(/\$\d+/g)||[],a=0;for(let u of s){let f=parseInt(u.substring(1),10);f>a&&(a=f)}if(a>0&&t.args.length>a){let u=t.args.slice(a);t.fullCmd=`${t.fullCmd} ${u.join(" ")}`}return t}else{let t=i.value.split(",").map(u=>u.trim()),s=i.name,a=n?`${n} ${i.value}`:i.value;return{name:s,args:t,fullCmd:a}}}};import{spawn as co}from"child_process";import{EventEmitter as uo}from"events";import{promises as M}from"fs";import te from"path";import ao from"os";var B=class{pidsDir;constructor(){this.pidsDir=te.join(ao.homedir(),".cligr","pids")}async ensureDir(){try{await M.mkdir(this.pidsDir,{recursive:!0})}catch(n){if(n.code!=="EEXIST")throw n}}sanitizeItemName(n){return n.replace(/[<>:"/\\|?*]/g,"_")}getPidFilePath(n,r){let i=this.sanitizeItemName(r);return te.join(this.pidsDir,`${n}_${i}.pid`)}async writePid(n){await this.ensureDir();let r=this.getPidFilePath(n.groupName,n.itemName);await M.writeFile(r,JSON.stringify(n,null,2),"utf-8")}async readPidsByGroup(n){await this.ensureDir();let r=[];try{let i=await M.readdir(this.pidsDir),o=`${n}_`;for(let l of i)if(l.startsWith(o)&&l.endsWith(".pid"))try{let t=await M.readFile(te.join(this.pidsDir,l),"utf-8");r.push(JSON.parse(t))}catch{continue}}catch{return[]}return r}async readAllPids(){await this.ensureDir();let n=[];try{let r=await M.readdir(this.pidsDir);for(let i of r)if(i.endsWith(".pid"))try{let o=await M.readFile(te.join(this.pidsDir,i),"utf-8");n.push(JSON.parse(o))}catch{continue}}catch{return[]}return n}async deletePid(n,r){let i=this.getPidFilePath(n,r);try{await M.unlink(i)}catch(o){if(o.code!=="ENOENT")throw o}}async deleteGroupPids(n){let r=await this.readPidsByGroup(n);for(let i of r)await this.deletePid(i.groupName,i.itemName)}isPidRunning(n){try{return process.kill(n,0),!0}catch{return!1}}isPidEntryValid(n){if(!this.isPidRunning(n.pid))return!1;let r=Date.now()-5*60*1e3;return n.startTime>r}async cleanupStalePids(){let n=await this.readAllPids(),r=[];for(let i of n)this.isPidEntryValid(i)||(r.push(i),await this.deletePid(i.groupName,i.itemName));return r}async getRunningGroups(){let n=await this.readAllPids(),r=new Set(n.map(i=>i.groupName));return Array.from(r)}};var Te=class{constructor(n,r,i="running"){this.item=n;this.process=r;this.status=i}},Y=class extends uo{groups=new Map;restartTimestamps=new Map;maxRestarts=3;restartWindow=1e4;pidStore=new B;spawnGroup(n,r,i){if(this.groups.has(n))throw new Error(`Group ${n} is already running`);let o=[];for(let l of r){let t=this.spawnProcess(l,n,i);o.push(new Te(l,t))}this.groups.set(n,o),this.emit("group-started",n)}async restartGroup(n,r,i){this.isGroupRunning(n)&&await this.killGroup(n),this.spawnGroup(n,r,i)}spawnProcess(n,r,i){let{cmd:o,args:l}=this.parseCommand(n.fullCmd),t=co(o,l,{stdio:["inherit","pipe","pipe"],shell:!1,windowsHide:!0});if(this.pidStore.deletePid(r,n.name).catch(()=>{}),t.pid){let a={pid:t.pid,groupName:r,itemName:n.name,startTime:Date.now(),restartPolicy:i,fullCmd:n.fullCmd};this.pidStore.writePid(a).catch(u=>{console.error(`[${n.name}] Failed to write PID file:`,u)})}let s=(a,u)=>{let c=a.toString("utf-8").split(`
38
+ `);for(let p of c)p.length>0&&this.emit("process-log",r,n.name,p,u)};return t.stdout&&t.stdout.on("data",a=>{process.stdout.write(`[${n.name}] ${a}`),s(a,!1)}),t.stderr&&t.stderr.on("data",a=>{process.stderr.write(`[${n.name}] ${a}`),s(a,!0)}),t.on("exit",(a,u)=>{this.handleExit(r,n,i,a,u)}),t}parseCommand(n){let r=[],i="",o=!1,l="";for(let t=0;t<n.length;t++){let s=n[t],a=n[t+1];(s==='"'||s==="'")&&!o?(o=!0,l=s):s===l&&o?(o=!1,l=""):s===" "&&!o?i&&(r.push(i),i=""):i+=s}return i&&r.push(i),{cmd:r[0]||"",args:r.slice(1)}}handleExit(n,r,i,o,l){if(l==="SIGTERM"&&!this.groups.has(n)){this.pidStore.deletePid(n,r.name).catch(()=>{});return}if(i==="unless-stopped"&&l==="SIGTERM"){this.pidStore.deletePid(n,r.name).catch(()=>{});return}if(i==="no"){this.pidStore.deletePid(n,r.name).catch(()=>{});return}let t=`${n}-${r.name}`,s=Date.now(),u=(this.restartTimestamps.get(t)||[]).filter(f=>s-f<this.restartWindow);if(u.push(s),this.restartTimestamps.set(t,u),u.length>this.maxRestarts){console.error(`[${r.name}] Crash loop detected. Stopping restarts.`),this.pidStore.deletePid(n,r.name).catch(()=>{});return}setTimeout(()=>{console.log(`[${r.name}] Restarting... (exit code: ${o})`);let f=this.spawnProcess(r,n,i);this.emit("item-restarted",n,r.name);let c=this.groups.get(n);if(c){let p=c.find(d=>d.item.name===r.name);p&&(p.process=f)}},1e3)}killGroup(n){let r=this.groups.get(n);if(!r)return Promise.resolve();let i=r.map(o=>this.killProcess(o.process));return this.groups.delete(n),Promise.all(i).then(async()=>{await this.pidStore.deleteGroupPids(n),this.emit("group-stopped",n)})}killPid(n){return new Promise((r,i)=>{try{process.kill(n,"SIGTERM");let o=setTimeout(()=>{try{process.kill(n,"SIGKILL")}catch{}},5e3),l=setInterval(()=>{this.pidStore.isPidRunning(n)||(clearTimeout(o),clearInterval(l),r())},100);this.pidStore.isPidRunning(n)||(clearTimeout(o),clearInterval(l),r())}catch(o){i(o)}})}killProcess(n){return new Promise(r=>{n.kill("SIGTERM");let i=setTimeout(()=>{n.killed||n.kill("SIGKILL")},5e3);n.on("exit",()=>{clearTimeout(i),r()}),(n.killed||n.exitCode!==null)&&(clearTimeout(i),r())})}killAll(){let n=[];for(let r of this.groups.keys())n.push(this.killGroup(r));return Promise.all(n).then(()=>{})}async cleanupStalePids(){await this.pidStore.cleanupStalePids()}getGroupStatus(n){let r=this.groups.get(n);return r?r.map(i=>i.status):[]}isGroupRunning(n){return this.groups.has(n)}getRunningGroups(){return Array.from(this.groups.keys())}};async function ke(e){let n=new k,r=new Y,i=new B;try{await i.cleanupStalePids();let{config:o,items:l,tool:t,toolTemplate:s,params:a}=n.getGroup(e),u=l.map((f,c)=>D.parseItem(t,s,f,c,a));return r.spawnGroup(e,u,o.restart),console.log(`Started group ${e} with ${u.length} process(es)`),console.log("Press Ctrl+C to stop..."),new Promise(f=>{let c=async()=>{console.log(`
39
+ Shutting down...`),process.removeListener("SIGINT",c),process.removeListener("SIGTERM",c),await r.killAll(),f(0)};process.on("SIGINT",c),process.on("SIGTERM",c)})}catch(o){if(o instanceof Error&&o.name==="ConfigError")return console.error(o.message),1;throw o}}async function Rn(e){let n=new k;try{let{config:r}=n.getGroup(e);console.log(`
39
40
  Group: ${e}`),console.log(`Tool: ${r.tool}`),console.log(`Restart: ${r.restart}`),console.log(`
40
- Items:`);for(let o of i)console.log(` ${o.name}: ${o.value}`);return console.log(""),0}catch(r){return console.error(r.message),1}}import{spawn as eo,spawnSync as kn}from"child_process";import G from"fs";import no from"os";import Ae from"path";var Tn=".cligr.yml",ro=`# Cligr Configuration
41
+ Items:`);let i=new Set(r.disabledItems||[]);for(let[o,l]of Object.entries(r.items)){let t=i.has(o)?" [disabled]":"";console.log(` ${o}: ${l}${t}`)}return console.log(""),0}catch(r){if(r instanceof Error&&r.name==="ConfigError")return console.error(r.message),1;throw r}}import{spawn as fo,spawnSync as Mn}from"child_process";import U from"fs";import po from"os";import Oe from"path";var Dn=".cligr.yml",ho=`# Cligr Configuration
41
42
 
42
43
  groups:
43
44
  web:
@@ -63,18 +64,166 @@ tools:
63
64
  # - $1 = name (first value)
64
65
  # - $2, $3... = additional arguments
65
66
  # - If no tool specified, executes directly
66
- `;function io(){let e=process.platform;return kn(e==="win32"?"where":"which",["code"],{stdio:"ignore"}).status===0?"code":process.env.EDITOR?process.env.EDITOR:e==="win32"?"notepad.exe":"vim"}function oo(e,n){let r=process.platform;if(kn(r==="win32"?"where":"which",[n],{stdio:"ignore"}).status!==0&&n!==process.env.EDITOR)throw new Error(`Editor '${n}' not found.
67
+ `;function mo(){let e=process.platform;return Mn(e==="win32"?"where":"which",["code"],{stdio:"ignore"}).status===0?"code":process.env.EDITOR?process.env.EDITOR:e==="win32"?"notepad.exe":"vim"}function go(e,n){let r=process.platform;if(Mn(r==="win32"?"where":"which",[n],{stdio:"ignore"}).status!==0&&n!==process.env.EDITOR)throw new Error(`Editor '${n}' not found.
67
68
  Install VS Code or set EDITOR environment variable.
68
69
 
69
70
  Example:
70
71
  export EDITOR=vim
71
- cligr config`);eo(n,[e],{detached:!0,stdio:"ignore",shell:r==="win32"}).unref()}function lo(e){let n=Ae.dirname(e);G.existsSync(n)||G.mkdirSync(n,{recursive:!0}),G.writeFileSync(e,ro,"utf-8")}async function Fn(){try{let e=Ae.join(no.homedir(),Tn),n=Ae.resolve(Tn),r;G.existsSync(e)?r=e:G.existsSync(n)?r=n:r=e,G.existsSync(r)||lo(r);let i=io();return oo(r,i),console.log(`Opening ${r} in ${i}...`),0}catch(e){return console.error(`Error: ${e.message}`),1}}async function On(e){let n=new O;try{let r=n.listGroups();if(r.length===0)return 0;if(e){let i=n.load(),o=[];for(let a of r){let f=i.groups[a];o.push({name:a,tool:f.tool||"(none)",restart:f.restart||"(none)",itemCount:Object.keys(f.items).length})}let t=Math.max(5,...o.map(a=>a.name.length)),l=Math.max(4,...o.map(a=>a.tool.length)),u=Math.max(7,...o.map(a=>a.restart.length)),c="GROUP".padEnd(t)+" "+"TOOL".padEnd(l)+" "+"RESTART".padEnd(u)+" ITEMS";console.log(c);for(let a of o){let f=a.name.padEnd(t)+" "+a.tool.padEnd(l)+" "+a.restart.padEnd(u)+" "+String(a.itemCount);console.log(f)}}else for(let i of r)console.log(i);return 0}catch(r){return console.error(r.message),1}}async function to(){let e=process.argv.slice(2);if(e.length===0){Pn(),process.exit(1);return}let[n,...r]=e,i=!1;if(["config","up","ls","groups"].includes(n)){let t=n,l;if(t==="groups"){let c=r.findIndex(a=>a==="-v"||a==="--verbose");c!==-1&&(i=!0,r.splice(c,1))}if(l=r[0],t!=="config"&&t!=="groups"&&!l){console.error("Error: group name required"),Pn(),process.exit(1);return}let u=0;switch(t){case"config":u=await Fn();break;case"up":u=await ye(l);break;case"ls":u=await In(l);break;case"groups":u=await On(i);break}process.exit(u)}else{let t=await ye(n);process.exit(t)}}function Pn(){console.log(`
72
+ cligr config`);fo(n,[e],{detached:!0,stdio:"ignore",shell:r==="win32"}).unref()}function xo(e){let n=Oe.dirname(e);U.existsSync(n)||U.mkdirSync(n,{recursive:!0}),U.writeFileSync(e,ho,"utf-8")}async function Gn(){try{let e=Oe.join(po.homedir(),Dn),n=Oe.resolve(Dn),r;U.existsSync(e)?r=e:U.existsSync(n)?r=n:r=e,U.existsSync(r)||xo(r);let i=mo();return go(r,i),console.log(`Opening ${r} in ${i}...`),0}catch(e){return console.error(`Error: ${e.message}`),1}}async function $n(e){let n=new k;try{let r=n.listGroups();if(r.length===0)return 0;if(e){let i=n.load(),o=[];for(let u of r){let f=i.groups[u];o.push({name:u,tool:f.tool||"(none)",restart:f.restart||"(none)",itemCount:Object.keys(f.items).length})}let l=Math.max(5,...o.map(u=>u.name.length)),t=Math.max(4,...o.map(u=>u.tool.length)),s=Math.max(7,...o.map(u=>u.restart.length)),a="GROUP".padEnd(l)+" "+"TOOL".padEnd(t)+" "+"RESTART".padEnd(s)+" ITEMS";console.log(a);for(let u of o){let f=u.name.padEnd(l)+" "+u.tool.padEnd(t)+" "+u.restart.padEnd(s)+" "+String(u.itemCount);console.log(f)}}else for(let i of r)console.log(i);return 0}catch(r){return console.error(r.message),1}}import vo from"http";async function jn(e){let n=e?parseInt(e,10):7373,r=new k,i=new Y;await i.cleanupStalePids();let o=[],l=(f,c)=>{let p=`event: ${f}
73
+ data: ${JSON.stringify(c)}
74
+
75
+ `;for(let d=o.length-1;d>=0;d--){let x=o[d];try{x.write(p)}catch{o.splice(d,1);try{x.end()}catch{}}}};i.on("group-started",f=>{l("status",{type:"group-started",groupName:f})}),i.on("group-stopped",f=>{l("status",{type:"group-stopped",groupName:f})}),i.on("item-restarted",(f,c)=>{l("status",{type:"item-restarted",groupName:f,itemName:c})}),i.on("process-log",(f,c,p,d)=>{l("log",{group:f,item:c,line:p,isError:d})});let t=vo.createServer((f,c)=>{let p=new URL(f.url||"/",`http://localhost:${n}`);if(c.setHeader("Access-Control-Allow-Origin","*"),c.setHeader("Access-Control-Allow-Methods","GET, POST, OPTIONS"),c.setHeader("Access-Control-Allow-Headers","Content-Type"),f.method==="OPTIONS"){c.writeHead(204),c.end();return}if(p.pathname==="/"){c.setHeader("Content-Type","text/html"),c.writeHead(200),c.end(yo());return}if(p.pathname==="/api/groups"){try{let m=r.load(),v=Object.entries(m.groups).map(([y,g])=>({name:y,tool:g.tool,restart:g.restart,items:Object.entries(g.items).map(([_,L])=>({name:_,value:L,enabled:!(g.disabledItems||[]).includes(_)})),running:i.isGroupRunning(y)}));c.setHeader("Content-Type","application/json"),c.writeHead(200),c.end(JSON.stringify({groups:v}))}catch(m){c.setHeader("Content-Type","application/json"),c.writeHead(500),c.end(JSON.stringify({error:m.message}))}return}if(p.pathname==="/api/events"){c.setHeader("Content-Type","text/event-stream"),c.setHeader("Cache-Control","no-cache"),c.setHeader("Connection","keep-alive"),c.writeHead(200),c.write(`:ok
76
+
77
+ `),o.push(c),f.on("close",()=>{let m=o.indexOf(c);m!==-1&&o.splice(m,1)});return}let d=p.pathname.match(/^\/api\/groups\/([^/]+)\/toggle$/);if(d&&f.method==="POST"){let m=decodeURIComponent(d[1]),v="";f.on("data",y=>v+=y),f.on("end",async()=>{let y;try{y=JSON.parse(v)}catch{c.writeHead(400),c.end(JSON.stringify({error:"Invalid JSON"}));return}let{enabled:g}=y;try{if(g){let{config:_,items:L,tool:le,toolTemplate:se,params:ae}=r.getGroup(m),ce=L.map((ue,fe)=>D.parseItem(le,se,ue,fe,ae));i.spawnGroup(m,ce,_.restart)}else await i.killGroup(m);c.setHeader("Content-Type","application/json"),c.writeHead(200),c.end(JSON.stringify({success:!0}))}catch(_){c.setHeader("Content-Type","application/json"),c.writeHead(500),c.end(JSON.stringify({error:_.message}))}});return}let x=p.pathname.match(/^\/api\/groups\/([^/]+)\/items\/([^/]+)\/toggle$/);if(x&&f.method==="POST"){let m=decodeURIComponent(x[1]),v=decodeURIComponent(x[2]),y="";f.on("data",g=>y+=g),f.on("end",async()=>{let g;try{g=JSON.parse(y)}catch{c.writeHead(400),c.end(JSON.stringify({error:"Invalid JSON"}));return}let{enabled:_}=g;try{if(r.toggleItem(m,v,_),i.isGroupRunning(m)){let{config:L,items:le,tool:se,toolTemplate:ae,params:ce}=r.getGroup(m),ue=le.map((fe,Bn)=>D.parseItem(se,ae,fe,Bn,ce));await i.restartGroup(m,ue,L.restart)}c.setHeader("Content-Type","application/json"),c.writeHead(200),c.end(JSON.stringify({success:!0}))}catch(L){c.setHeader("Content-Type","application/json"),c.writeHead(500),c.end(JSON.stringify({error:L.message}))}});return}c.writeHead(404),c.end("Not found")});t.on("error",f=>{f.code==="EADDRINUSE"?(console.error(`Port ${n} is already in use`),process.exit(1)):(console.error("Server error:",f),process.exit(2))});let s,a=new Promise(f=>{s=f}),u=async()=>{console.log(`
78
+ Shutting down...`),t.close(),await i.killAll(),s(0)};return process.on("SIGINT",u),process.on("SIGTERM",u),t.listen(n,()=>{console.log(`cligr serve running at http://localhost:${n}`)}),a}function yo(){return`<!DOCTYPE html>
79
+ <html>
80
+ <head>
81
+ <meta charset="utf-8">
82
+ <title>cligr serve</title>
83
+ <style>
84
+ * { box-sizing: border-box; }
85
+ html, body { height: 100%; margin: 0; }
86
+ body { font-family: system-ui, sans-serif; display: flex; flex-direction: column; }
87
+ h1 { font-size: 1.25rem; margin: 0; padding: 0.75rem 1rem; border-bottom: 1px solid #ccc; background: #f8f8f8; }
88
+ .container { display: flex; flex: 1; overflow: hidden; }
89
+ .sidebar { width: 320px; min-width: 180px; max-width: 60vw; border-right: 1px solid #ccc; padding: 1rem; overflow-y: auto; background: #fafafa; }
90
+ .resizer { width: 6px; background: #e0e0e0; cursor: col-resize; flex-shrink: 0; }
91
+ .resizer:hover { background: #bbb; }
92
+ .main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
93
+ .main h2 { font-size: 1rem; margin: 0; padding: 0.5rem 1rem; border-bottom: 1px solid #ccc; background: #f0f0f0; }
94
+ .group { border: 1px solid #ccc; border-radius: 6px; padding: 0.75rem; margin: 0 0 0.75rem 0; background: #fff; }
95
+ .group-header { display: flex; align-items: center; gap: 0.5rem; font-weight: bold; font-size: 1rem; }
96
+ .items { margin: 0.5rem 0 0 1.25rem; }
97
+ .item { display: flex; align-items: center; gap: 0.4rem; margin: 0.2rem 0; font-size: 0.9rem; }
98
+ .logs { flex: 1; background: #111; color: #0f0; font-family: monospace; font-size: 0.85rem; overflow-y: auto; padding: 0.75rem; white-space: pre-wrap; }
99
+ .error { color: #f55; }
100
+ </style>
101
+ </head>
102
+ <body>
103
+ <h1>cligr serve</h1>
104
+ <div class="container">
105
+ <div class="sidebar" id="groups"></div>
106
+ <div class="resizer" id="resizer"></div>
107
+ <div class="main">
108
+ <h2>Console</h2>
109
+ <div class="logs" id="logs"></div>
110
+ </div>
111
+ </div>
112
+
113
+ <script>
114
+ const groupsEl = document.getElementById('groups');
115
+ const logsEl = document.getElementById('logs');
116
+ const resizer = document.getElementById('resizer');
117
+ let autoScroll = true;
118
+
119
+ resizer.addEventListener('mousedown', (e) => {
120
+ e.preventDefault();
121
+ document.body.style.cursor = 'col-resize';
122
+ const startX = e.clientX;
123
+ const startWidth = groupsEl.offsetWidth;
124
+
125
+ const onMove = (ev) => {
126
+ const newWidth = startWidth + (ev.clientX - startX);
127
+ groupsEl.style.width = Math.max(180, Math.min(newWidth, window.innerWidth * 0.6)) + 'px';
128
+ };
129
+
130
+ const onUp = () => {
131
+ document.removeEventListener('mousemove', onMove);
132
+ document.removeEventListener('mouseup', onUp);
133
+ document.body.style.cursor = '';
134
+ };
135
+
136
+ document.addEventListener('mousemove', onMove);
137
+ document.addEventListener('mouseup', onUp);
138
+ });
139
+
140
+ async function fetchGroups() {
141
+ const res = await fetch('/api/groups');
142
+ const data = await res.json();
143
+ renderGroups(data.groups);
144
+ }
145
+
146
+ function renderGroups(groups) {
147
+ groupsEl.innerHTML = '';
148
+ for (const g of groups) {
149
+ const div = document.createElement('div');
150
+ div.className = 'group';
151
+
152
+ const header = document.createElement('div');
153
+ header.className = 'group-header';
154
+ const checkbox = document.createElement('input');
155
+ checkbox.type = 'checkbox';
156
+ checkbox.checked = g.running;
157
+ checkbox.onchange = async () => {
158
+ await fetch(\`/api/groups/\${encodeURIComponent(g.name)}/toggle\`, {
159
+ method: 'POST',
160
+ headers: { 'Content-Type': 'application/json' },
161
+ body: JSON.stringify({ enabled: checkbox.checked })
162
+ });
163
+ };
164
+ header.appendChild(checkbox);
165
+ header.appendChild(document.createTextNode(g.name + ' (' + g.tool + ')' + (g.running ? ' - running' : '')));
166
+ div.appendChild(header);
167
+
168
+ const itemsDiv = document.createElement('div');
169
+ itemsDiv.className = 'items';
170
+ for (const item of g.items) {
171
+ const itemDiv = document.createElement('div');
172
+ itemDiv.className = 'item';
173
+ const itemCb = document.createElement('input');
174
+ itemCb.type = 'checkbox';
175
+ itemCb.checked = item.enabled;
176
+ itemCb.onchange = async () => {
177
+ await fetch(\`/api/groups/\${encodeURIComponent(g.name)}/items/\${encodeURIComponent(item.name)}/toggle\`, {
178
+ method: 'POST',
179
+ headers: { 'Content-Type': 'application/json' },
180
+ body: JSON.stringify({ enabled: itemCb.checked })
181
+ });
182
+ };
183
+ itemDiv.appendChild(itemCb);
184
+ itemDiv.appendChild(document.createTextNode(item.name + ': ' + item.value));
185
+ itemsDiv.appendChild(itemDiv);
186
+ }
187
+ div.appendChild(itemsDiv);
188
+ groupsEl.appendChild(div);
189
+ }
190
+ }
191
+
192
+ logsEl.addEventListener('scroll', () => {
193
+ autoScroll = logsEl.scrollTop + logsEl.clientHeight >= logsEl.scrollHeight - 10;
194
+ });
195
+
196
+ function appendLog(line, isError) {
197
+ const span = document.createElement('div');
198
+ span.textContent = line;
199
+ if (isError) span.className = 'error';
200
+ logsEl.appendChild(span);
201
+ if (autoScroll) logsEl.scrollTop = logsEl.scrollHeight;
202
+ }
203
+
204
+ const evtSource = new EventSource('/api/events');
205
+ evtSource.addEventListener('status', (e) => {
206
+ fetchGroups();
207
+ });
208
+ evtSource.addEventListener('log', (e) => {
209
+ const data = JSON.parse(e.data);
210
+ appendLog(\`[\${data.group}/\${data.item}] \${data.line}\`, data.isError);
211
+ });
212
+ evtSource.onerror = () => {
213
+ appendLog('[SSE connection error]', true);
214
+ };
215
+
216
+ fetchGroups();
217
+ </script>
218
+ </body>
219
+ </html>`}async function wo(){let e=process.argv.slice(2);if(e.length===0){Hn(),process.exit(1);return}let[n,...r]=e,i=!1;if(["config","up","ls","groups","serve"].includes(n)){let l=n,t;if(l==="groups"){let a=r.findIndex(u=>u==="-v"||u==="--verbose");a!==-1&&(i=!0,r.splice(a,1))}if(t=r[0],l!=="config"&&l!=="groups"&&l!=="serve"&&!t){console.error("Error: group name required"),Hn(),process.exit(1);return}let s=0;switch(l){case"config":s=await Gn();break;case"up":s=await ke(t);break;case"ls":s=await Rn(t);break;case"groups":s=await $n(i);break;case"serve":s=await jn(r[0]);break}process.exit(s)}else{let l=await ke(n);process.exit(l)}}function Hn(){console.log(`
72
220
  Usage: cligr <group> | <command> [options]
73
221
 
74
222
  Commands:
75
223
  config Open config file in editor
76
224
  ls <group> List all items in the group
77
- groups [-v|--verbose] List all groups
225
+ groups [-v|--verbose] List all groups
226
+ serve [port] Start web UI server (default port 7373)
78
227
 
79
228
  Options:
80
229
  -v, --verbose Show detailed group information
@@ -85,7 +234,9 @@ Examples:
85
234
  cligr ls test1
86
235
  cligr groups
87
236
  cligr groups -v
88
- `)}to().catch(e=>{console.error(e),process.exit(2)});
237
+ cligr serve
238
+ cligr serve 8080
239
+ `)}wo().catch(e=>{console.error(e),process.exit(2)});
89
240
  /*! Bundled license information:
90
241
 
91
242
  js-yaml/dist/js-yaml.mjs: