UNPKG

@envsa/shared-config

Version:

A collection of shared configurations, linters and formatting tools for TypeScript projects. All managed as a single dependency, and invoked via a single command.

13 lines 120 kB
#!/usr/bin/env node var ro=Object.create;var Jn=Object.defineProperty;var oo=Object.getOwnPropertyDescriptor;var so=Object.getOwnPropertyNames;var ao=Object.getPrototypeOf,co=Object.prototype.hasOwnProperty;var je=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var lo=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);var fo=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of so(e))!co.call(i,r)&&r!==t&&Jn(i,r,{get:()=>e[r],enumerable:!(n=oo(e,r))||n.enumerable});return i};var uo=(i,e,t)=>(t=i!=null?ro(ao(i)):{},fo(e||!i||!i.__esModule?Jn(t,"default",{value:i,enumerable:!0}):t,i));var gr=lo((zl,mr)=>{"use strict";var Ss=function(e){return js(e)&&!Ps(e)};function js(i){return!!i&&typeof i=="object"}function Ps(i){var e=Object.prototype.toString.call(i);return e==="[object RegExp]"||e==="[object Date]"||$s(i)}var Ms=typeof Symbol=="function"&&Symbol.for,vs=Ms?Symbol.for("react.element"):60103;function $s(i){return i.$$typeof===vs}function Fs(i){return Array.isArray(i)?[]:{}}function Mt(i,e){return e.clone!==!1&&e.isMergeableObject(i)?mt(Fs(i),i,e):i}function Is(i,e,t){return i.concat(e).map(function(n){return Mt(n,t)})}function Rs(i,e){if(!e.customMerge)return mt;var t=e.customMerge(i);return typeof t=="function"?t:mt}function Ns(i){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(i).filter(function(e){return Object.propertyIsEnumerable.call(i,e)}):[]}function pr(i){return Object.keys(i).concat(Ns(i))}function hr(i,e){try{return e in i}catch{return!1}}function Ds(i,e){return hr(i,e)&&!(Object.hasOwnProperty.call(i,e)&&Object.propertyIsEnumerable.call(i,e))}function Ts(i,e,t){var n={};return t.isMergeableObject(i)&&pr(i).forEach(function(r){n[r]=Mt(i[r],t)}),pr(e).forEach(function(r){Ds(i,r)||(hr(i,r)&&t.isMergeableObject(e[r])?n[r]=Rs(r,t)(i[r],e[r],t):n[r]=Mt(e[r],t))}),n}function mt(i,e,t){t=t||{},t.arrayMerge=t.arrayMerge||Is,t.isMergeableObject=t.isMergeableObject||Ss,t.cloneUnlessOtherwiseSpecified=Mt;var n=Array.isArray(e),r=Array.isArray(i),o=n===r;return o?n?t.arrayMerge(i,e,t):Ts(i,e,t):Mt(e,t)}mt.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(n,r){return mt(n,r,t)},{})};var Ws=mt;mr.exports=Ws});var Vn=(i=0)=>e=>`\x1B[${e+i}m`,Kn=(i=0)=>e=>`\x1B[${38+i};5;${e}m`,qn=(i=0)=>(e,t,n)=>`\x1B[${38+i};2;${e};${t};${n}m`,q={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},ya=Object.keys(q.modifier),po=Object.keys(q.color),ho=Object.keys(q.bgColor),Ca=[...po,...ho];function mo(){let i=new Map;for(let[e,t]of Object.entries(q)){for(let[n,r]of Object.entries(t))q[n]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},t[n]=q[n],i.set(r[0],r[1]);Object.defineProperty(q,e,{value:t,enumerable:!1})}return Object.defineProperty(q,"codes",{value:i,enumerable:!1}),q.color.close="\x1B[39m",q.bgColor.close="\x1B[49m",q.color.ansi=Vn(),q.color.ansi256=Kn(),q.color.ansi16m=qn(),q.bgColor.ansi=Vn(10),q.bgColor.ansi256=Kn(10),q.bgColor.ansi16m=qn(10),Object.defineProperties(q,{rgbToAnsi256:{value(e,t,n){return e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(e){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(o=>o+o).join(""));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>q.rgbToAnsi256(...q.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let c=e%36;t=Math.floor(e/36)/5,n=Math.floor(c/6)/5,r=c%6/5}let o=Math.max(t,n,r)*2;if(o===0)return 30;let s=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return o===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>q.ansi256ToAnsi(q.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>q.ansi256ToAnsi(q.hexToAnsi256(e)),enumerable:!1}}),q}var go=mo(),_e=go;import an from"node:process";import bo from"node:os";import Qn from"node:tty";function he(i,e=globalThis.Deno?globalThis.Deno.args:an.argv){let t=i.startsWith("-")?"":i.length===1?"-":"--",n=e.indexOf(t+i),r=e.indexOf("--");return n!==-1&&(r===-1||n<r)}var{env:ee}=an,It;he("no-color")||he("no-colors")||he("color=false")||he("color=never")?It=0:(he("color")||he("colors")||he("color=true")||he("color=always"))&&(It=1);function yo(){if("FORCE_COLOR"in ee)return ee.FORCE_COLOR==="true"?1:ee.FORCE_COLOR==="false"?0:ee.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(ee.FORCE_COLOR,10),3)}function Co(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}function wo(i,{streamIsTTY:e,sniffFlags:t=!0}={}){let n=yo();n!==void 0&&(It=n);let r=t?It:n;if(r===0)return 0;if(t){if(he("color=16m")||he("color=full")||he("color=truecolor"))return 3;if(he("color=256"))return 2}if("TF_BUILD"in ee&&"AGENT_NAME"in ee)return 1;if(i&&!e&&r===void 0)return 0;let o=r||0;if(ee.TERM==="dumb")return o;if(an.platform==="win32"){let s=bo.release().split(".");return Number(s[0])>=10&&Number(s[2])>=10586?Number(s[2])>=14931?3:2:1}if("CI"in ee)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(s=>s in ee)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(s=>s in ee)||ee.CI_NAME==="codeship"?1:o;if("TEAMCITY_VERSION"in ee)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(ee.TEAMCITY_VERSION)?1:0;if(ee.COLORTERM==="truecolor"||ee.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in ee){let s=Number.parseInt((ee.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(ee.TERM_PROGRAM){case"iTerm.app":return s>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(ee.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(ee.TERM)||"COLORTERM"in ee?1:o}function Zn(i,e={}){let t=wo(i,{streamIsTTY:i&&i.isTTY,...e});return Co(t)}var Oo={stdout:Zn({isTTY:Qn.isatty(1)}),stderr:Zn({isTTY:Qn.isatty(2)})},Xn=Oo;function ei(i,e,t){let n=i.indexOf(e);if(n===-1)return i;let r=e.length,o=0,s="";do s+=i.slice(o,n)+e+t,o=n+r,n=i.indexOf(e,o);while(n!==-1);return s+=i.slice(o),s}function ti(i,e,t,n){let r=0,o="";do{let s=i[n-1]==="\r";o+=i.slice(r,s?n-1:n)+e+(s?`\r `:` `)+t,r=n+1,n=i.indexOf(` `,r)}while(n!==-1);return o+=i.slice(r),o}var{stdout:ni,stderr:ii}=Xn,cn=Symbol("GENERATOR"),ct=Symbol("STYLER"),wt=Symbol("IS_EMPTY"),ri=["ansi","ansi","ansi256","ansi16m"],lt=Object.create(null),xo=(i,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let t=ni?ni.level:0;i.level=e.level===void 0?t:e.level};var Ao=i=>{let e=(...t)=>t.join(" ");return xo(e,i),Object.setPrototypeOf(e,Ot.prototype),e};function Ot(i){return Ao(i)}Object.setPrototypeOf(Ot.prototype,Function.prototype);for(let[i,e]of Object.entries(_e))lt[i]={get(){let t=Rt(this,fn(e.open,e.close,this[ct]),this[wt]);return Object.defineProperty(this,i,{value:t}),t}};lt.visible={get(){let i=Rt(this,this[ct],!0);return Object.defineProperty(this,"visible",{value:i}),i}};var ln=(i,e,t,...n)=>i==="rgb"?e==="ansi16m"?_e[t].ansi16m(...n):e==="ansi256"?_e[t].ansi256(_e.rgbToAnsi256(...n)):_e[t].ansi(_e.rgbToAnsi(...n)):i==="hex"?ln("rgb",e,t,..._e.hexToRgb(...n)):_e[t][i](...n),_o=["rgb","hex","ansi256"];for(let i of _o){lt[i]={get(){let{level:t}=this;return function(...n){let r=fn(ln(i,ri[t],"color",...n),_e.color.close,this[ct]);return Rt(this,r,this[wt])}}};let e="bg"+i[0].toUpperCase()+i.slice(1);lt[e]={get(){let{level:t}=this;return function(...n){let r=fn(ln(i,ri[t],"bgColor",...n),_e.bgColor.close,this[ct]);return Rt(this,r,this[wt])}}}}var Eo=Object.defineProperties(()=>{},{...lt,level:{enumerable:!0,get(){return this[cn].level},set(i){this[cn].level=i}}}),fn=(i,e,t)=>{let n,r;return t===void 0?(n=i,r=e):(n=t.openAll+i,r=e+t.closeAll),{open:i,close:e,openAll:n,closeAll:r,parent:t}},Rt=(i,e,t)=>{let n=(...r)=>So(n,r.length===1?""+r[0]:r.join(" "));return Object.setPrototypeOf(n,Eo),n[cn]=i,n[ct]=e,n[wt]=t,n},So=(i,e)=>{if(i.level<=0||!e)return i[wt]?"":e;let t=i[ct];if(t===void 0)return e;let{openAll:n,closeAll:r}=t;if(e.includes("\x1B"))for(;t!==void 0;)e=ei(e,t.close,t.open),t=t.parent;let o=e.indexOf(` `);return o!==-1&&(e=ti(e,r,n,o)),n+e+r};Object.defineProperties(Ot.prototype,lt);var jo=Ot(),Ma=Ot({level:ii?ii.level:0});var Ne=jo;import{cosmiconfig as Gs}from"cosmiconfig";import{execa as Hs}from"execa";import Se from"fs-extra";import jr from"node:fs";import nn from"node:path";import{PassThrough as Js}from"node:stream";import{fileURLToPath as Vs}from"node:url";import ci from"node:process";import oi from"node:process";import Po from"node:fs/promises";import{fileURLToPath as Mo}from"node:url";import vo from"node:fs";import me from"node:path";var Nt=i=>i instanceof URL?Mo(i):i;async function si(i,{cwd:e=oi.cwd(),type:t="file",stopAt:n}={}){let r=me.resolve(Nt(e)??""),{root:o}=me.parse(r);for(n=me.resolve(r,Nt(n??o));r&&r!==n&&r!==o;){let s=me.isAbsolute(i)?i:me.join(r,i);try{let c=await Po.stat(s);if(t==="file"&&c.isFile()||t==="directory"&&c.isDirectory())return s}catch{}r=me.dirname(r)}}function ai(i,{cwd:e=oi.cwd(),type:t="file",stopAt:n}={}){let r=me.resolve(Nt(e)??""),{root:o}=me.parse(r);for(n=me.resolve(r,Nt(n)??o);r&&r!==n&&r!==o;){let s=me.isAbsolute(i)?i:me.join(r,i);try{let c=vo.statSync(s,{throwIfNoEntry:!1});if(t==="file"&&c?.isFile()||t==="directory"&&c?.isDirectory())return s}catch{}r=me.dirname(r)}}async function xt({cwd:i=ci.cwd()}={}){return si("package.json",{cwd:i})}function li({cwd:i=ci.cwd()}={}){return ai("package.json",{cwd:i})}import{notStrictEqual as ts,strictEqual as ns}from"assert";var $o={right:Do,center:To},Fo=0,Dt=1,Io=2,Tt=3,un=class{constructor(e){var t;this.width=e.width,this.wrap=(t=e.wrap)!==null&&t!==void 0?t:!0,this.rows=[]}span(...e){let t=this.div(...e);t.span=!0}resetOutput(){this.rows=[]}div(...e){if(e.length===0&&this.div(""),this.wrap&&this.shouldApplyLayoutDSL(...e)&&typeof e[0]=="string")return this.applyLayoutDSL(e[0]);let t=e.map(n=>typeof n=="string"?this.colFromString(n):n);return this.rows.push(t),t}shouldApplyLayoutDSL(...e){return e.length===1&&typeof e[0]=="string"&&/[\t\n]/.test(e[0])}applyLayoutDSL(e){let t=e.split(` `).map(r=>r.split(" ")),n=0;return t.forEach(r=>{r.length>1&&fe.stringWidth(r[0])>n&&(n=Math.min(Math.floor(this.width*.5),fe.stringWidth(r[0])))}),t.forEach(r=>{this.div(...r.map((o,s)=>({text:o.trim(),padding:this.measurePadding(o),width:s===0&&r.length>1?n:void 0})))}),this.rows[this.rows.length-1]}colFromString(e){return{text:e,padding:this.measurePadding(e)}}measurePadding(e){let t=fe.stripAnsi(e);return[0,t.match(/\s*$/)[0].length,0,t.match(/^\s*/)[0].length]}toString(){let e=[];return this.rows.forEach(t=>{this.rowToString(t,e)}),e.filter(t=>!t.hidden).map(t=>t.text).join(` `)}rowToString(e,t){return this.rasterize(e).forEach((n,r)=>{let o="";n.forEach((s,c)=>{let{width:g}=e[c],y=this.negatePadding(e[c]),m=s;if(y>fe.stringWidth(s)&&(m+=" ".repeat(y-fe.stringWidth(s))),e[c].align&&e[c].align!=="left"&&this.wrap){let u=$o[e[c].align];m=u(m,y),fe.stringWidth(m)<y&&(m+=" ".repeat((g||0)-fe.stringWidth(m)-1))}let f=e[c].padding||[0,0,0,0];f[Tt]&&(o+=" ".repeat(f[Tt])),o+=fi(e[c],m,"| "),o+=m,o+=fi(e[c],m," |"),f[Dt]&&(o+=" ".repeat(f[Dt])),r===0&&t.length>0&&(o=this.renderInline(o,t[t.length-1]))}),t.push({text:o.replace(/ +$/,""),span:e.span})}),t}renderInline(e,t){let n=e.match(/^ */),r=n?n[0].length:0,o=t.text,s=fe.stringWidth(o.trimRight());return t.span?this.wrap?r<s?e:(t.hidden=!0,o.trimRight()+" ".repeat(r-s)+e.trimLeft()):(t.hidden=!0,o+e):e}rasterize(e){let t=[],n=this.columnWidths(e),r;return e.forEach((o,s)=>{o.width=n[s],this.wrap?r=fe.wrap(o.text,this.negatePadding(o),{hard:!0}).split(` `):r=o.text.split(` `),o.border&&(r.unshift("."+"-".repeat(this.negatePadding(o)+2)+"."),r.push("'"+"-".repeat(this.negatePadding(o)+2)+"'")),o.padding&&(r.unshift(...new Array(o.padding[Fo]||0).fill("")),r.push(...new Array(o.padding[Io]||0).fill(""))),r.forEach((c,g)=>{t[g]||t.push([]);let y=t[g];for(let m=0;m<s;m++)y[m]===void 0&&y.push("");y.push(c)})}),t}negatePadding(e){let t=e.width||0;return e.padding&&(t-=(e.padding[Tt]||0)+(e.padding[Dt]||0)),e.border&&(t-=4),t}columnWidths(e){if(!this.wrap)return e.map(s=>s.width||fe.stringWidth(s.text));let t=e.length,n=this.width,r=e.map(s=>{if(s.width)return t--,n-=s.width,s.width}),o=t?Math.floor(n/t):0;return r.map((s,c)=>s===void 0?Math.max(o,Ro(e[c])):s)}};function fi(i,e,t){return i.border?/[.']-+[.']/.test(e)?"":e.trim().length!==0?t:" ":""}function Ro(i){let e=i.padding||[],t=1+(e[Tt]||0)+(e[Dt]||0);return i.border?t+4:t}function No(){return typeof process=="object"&&process.stdout&&process.stdout.columns?process.stdout.columns:80}function Do(i,e){i=i.trim();let t=fe.stringWidth(i);return t<e?" ".repeat(e-t)+i:i}function To(i,e){i=i.trim();let t=fe.stringWidth(i);return t>=e?i:" ".repeat(e-t>>1)+i}var fe;function ui(i,e){return fe=e,new un({width:i?.width||No(),wrap:i?.wrap})}var di=new RegExp("\x1B(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)","g");function dn(i){return i.replace(di,"")}function pi(i,e){let[t,n]=i.match(di)||["",""];i=dn(i);let r="";for(let o=0;o<i.length;o++)o!==0&&o%e===0&&(r+=` `),r+=i.charAt(o);return t&&n&&(r=`${t}${r}${n}`),r}function pn(i){return ui(i,{stringWidth:e=>[...e].length,stripAnsi:dn,wrap:pi})}import{dirname as hi,resolve as mi}from"path";import{readdirSync as Wo,statSync as Lo}from"fs";function gi(i,e){let t=mi(".",i),n;for(Lo(t).isDirectory()||(t=hi(t));;){if(n=e(t,Wo(t)),n)return mi(t,n);if(t=hi(n=t),n===t)break}}import{inspect as is}from"util";import{readFileSync as rs}from"fs";import{fileURLToPath as os}from"url";import{format as Bo}from"util";import{normalize as zo,resolve as Yo}from"path";function Je(i){if(i!==i.toLowerCase()&&i!==i.toUpperCase()||(i=i.toLowerCase()),i.indexOf("-")===-1&&i.indexOf("_")===-1)return i;{let t="",n=!1,r=i.match(/^-+/);for(let o=r?r[0].length:0;o<i.length;o++){let s=i.charAt(o);n&&(n=!1,s=s.toUpperCase()),o!==0&&(s==="-"||s==="_")?n=!0:s!=="-"&&s!=="_"&&(t+=s)}return t}}function Wt(i,e){let t=i.toLowerCase();e=e||"-";let n="";for(let r=0;r<i.length;r++){let o=t.charAt(r),s=i.charAt(r);o!==s&&r>0?n+=`${e}${t.charAt(r)}`:n+=s}return n}function Lt(i){return i==null?!1:typeof i=="number"||/^0x[0-9a-f]+$/i.test(i)?!0:/^0[^.]/.test(i)?!1:/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(i)}function bi(i){if(Array.isArray(i))return i.map(s=>typeof s!="string"?s+"":s);i=i.trim();let e=0,t=null,n=null,r=null,o=[];for(let s=0;s<i.length;s++){if(t=n,n=i.charAt(s),n===" "&&!r){t!==" "&&e++;continue}n===r?r=null:(n==="'"||n==='"')&&!r&&(r=n),o[e]||(o[e]=""),o[e]+=n}return o}var ge;(function(i){i.BOOLEAN="boolean",i.STRING="string",i.NUMBER="number",i.ARRAY="array"})(ge||(ge={}));var Fe,kt=class{constructor(e){Fe=e}parse(e,t){let n=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},t),r=bi(e),o=typeof e=="string",s=ko(Object.assign(Object.create(null),n.alias)),c=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},n.configuration),g=Object.assign(Object.create(null),n.default),y=n.configObjects||[],m=n.envPrefix,f=c["populate--"],u=f?"--":"_",b=Object.create(null),O=Object.create(null),w=n.__||Fe.format,h={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},D=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,L=new RegExp("^--"+c["negation-prefix"]+"(.+)");[].concat(n.array||[]).filter(Boolean).forEach(function(l){let p=typeof l=="object"?l.key:l,x=Object.keys(l).map(function(C){return{boolean:"bools",string:"strings",number:"numbers"}[C]}).filter(Boolean).pop();x&&(h[x][p]=!0),h.arrays[p]=!0,h.keys.push(p)}),[].concat(n.boolean||[]).filter(Boolean).forEach(function(l){h.bools[l]=!0,h.keys.push(l)}),[].concat(n.string||[]).filter(Boolean).forEach(function(l){h.strings[l]=!0,h.keys.push(l)}),[].concat(n.number||[]).filter(Boolean).forEach(function(l){h.numbers[l]=!0,h.keys.push(l)}),[].concat(n.count||[]).filter(Boolean).forEach(function(l){h.counts[l]=!0,h.keys.push(l)}),[].concat(n.normalize||[]).filter(Boolean).forEach(function(l){h.normalize[l]=!0,h.keys.push(l)}),typeof n.narg=="object"&&Object.entries(n.narg).forEach(([l,p])=>{typeof p=="number"&&(h.nargs[l]=p,h.keys.push(l))}),typeof n.coerce=="object"&&Object.entries(n.coerce).forEach(([l,p])=>{typeof p=="function"&&(h.coercions[l]=p,h.keys.push(l))}),typeof n.config<"u"&&(Array.isArray(n.config)||typeof n.config=="string"?[].concat(n.config).filter(Boolean).forEach(function(l){h.configs[l]=!0}):typeof n.config=="object"&&Object.entries(n.config).forEach(([l,p])=>{(typeof p=="boolean"||typeof p=="function")&&(h.configs[l]=p)})),He(n.key,s,n.default,h.arrays),Object.keys(g).forEach(function(l){(h.aliases[l]||[]).forEach(function(p){g[p]=g[l]})});let B=null;Ft();let k=[],G=Object.assign(Object.create(null),{_:[]}),Re={};for(let l=0;l<r.length;l++){let p=r[l],x=p.replace(/^-{3,}/,"---"),C,d,P,_,$,se;if(p!=="--"&&/^-/.test(p)&&Z(p))Oe(p);else if(x.match(/^---+(=|$)/)){Oe(p);continue}else if(p.match(/^--.+=/)||!c["short-option-groups"]&&p.match(/^-.+=/))_=p.match(/^--?([^=]+)=([\s\S]*)$/),_!==null&&Array.isArray(_)&&_.length>=3&&(R(_[1],h.arrays)?l=Ye(l,_[1],r,_[2]):R(_[1],h.nargs)!==!1?l=at(l,_[1],r,_[2]):H(_[1],_[2],!0));else if(p.match(L)&&c["boolean-negation"])_=p.match(L),_!==null&&Array.isArray(_)&&_.length>=2&&(d=_[1],H(d,R(d,h.arrays)?[!1]:!1));else if(p.match(/^--.+/)||!c["short-option-groups"]&&p.match(/^-[^-]+/))_=p.match(/^--?(.+)/),_!==null&&Array.isArray(_)&&_.length>=2&&(d=_[1],R(d,h.arrays)?l=Ye(l,d,r):R(d,h.nargs)!==!1?l=at(l,d,r):($=r[l+1],$!==void 0&&(!$.match(/^-/)||$.match(D))&&!R(d,h.bools)&&!R(d,h.counts)||/^(true|false)$/.test($)?(H(d,$),l++):H(d,X(d))));else if(p.match(/^-.\..+=/))_=p.match(/^-([^=]+)=([\s\S]*)$/),_!==null&&Array.isArray(_)&&_.length>=3&&H(_[1],_[2]);else if(p.match(/^-.\..+/)&&!p.match(D))$=r[l+1],_=p.match(/^-(.\..+)/),_!==null&&Array.isArray(_)&&_.length>=2&&(d=_[1],$!==void 0&&!$.match(/^-/)&&!R(d,h.bools)&&!R(d,h.counts)?(H(d,$),l++):H(d,X(d)));else if(p.match(/^-[^-]+/)&&!p.match(D)){P=p.slice(1,-1).split(""),C=!1;for(let ce=0;ce<P.length;ce++){if($=p.slice(ce+2),P[ce+1]&&P[ce+1]==="="){se=p.slice(ce+3),d=P[ce],R(d,h.arrays)?l=Ye(l,d,r,se):R(d,h.nargs)!==!1?l=at(l,d,r,se):H(d,se),C=!0;break}if($==="-"){H(P[ce],$);continue}if(/[A-Za-z]/.test(P[ce])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test($)&&R($,h.bools)===!1){H(P[ce],$),C=!0;break}if(P[ce+1]&&P[ce+1].match(/\W/)){H(P[ce],$),C=!0;break}else H(P[ce],X(P[ce]))}d=p.slice(-1)[0],!C&&d!=="-"&&(R(d,h.arrays)?l=Ye(l,d,r):R(d,h.nargs)!==!1?l=at(l,d,r):($=r[l+1],$!==void 0&&(!/^(-|--)[^-]/.test($)||$.match(D))&&!R(d,h.bools)&&!R(d,h.counts)||/^(true|false)$/.test($)?(H(d,$),l++):H(d,X(d))))}else if(p.match(/^-[0-9]$/)&&p.match(D)&&R(p.slice(1),h.bools))d=p.slice(1),H(d,X(d));else if(p==="--"){k=r.slice(l+1);break}else if(c["halt-at-non-option"]){k=r.slice(l);break}else Oe(p)}z(G,!0),z(G,!1),W(G),re(),Q(G,h.aliases,g,!0),oe(G),c["set-placeholder-key"]&&Ge(G),Object.keys(h.counts).forEach(function(l){ve(G,l.split("."))||H(l,0)}),f&&k.length&&(G[u]=[]),k.forEach(function(l){G[u].push(l)}),c["camel-case-expansion"]&&c["strip-dashed"]&&Object.keys(G).filter(l=>l!=="--"&&l.includes("-")).forEach(l=>{delete G[l]}),c["strip-aliased"]&&[].concat(...Object.keys(s).map(l=>s[l])).forEach(l=>{c["camel-case-expansion"]&&l.includes("-")&&delete G[l.split(".").map(p=>Je(p)).join(".")],delete G[l]});function Oe(l){let p=j("_",l);(typeof p=="string"||typeof p=="number")&&G._.push(p)}function at(l,p,x,C){let d,P=R(p,h.nargs);if(P=typeof P!="number"||isNaN(P)?1:P,P===0)return Ae(C)||(B=Error(w("Argument unexpected for: %s",p))),H(p,X(p)),l;let _=Ae(C)?0:1;if(c["nargs-eats-options"])x.length-(l+1)+_<P&&(B=Error(w("Not enough arguments following: %s",p))),_=P;else{for(d=l+1;d<x.length&&(!x[d].match(/^-[^0-9]/)||x[d].match(D)||Z(x[d]));d++)_++;_<P&&(B=Error(w("Not enough arguments following: %s",p)))}let $=Math.min(_,P);for(!Ae(C)&&$>0&&(H(p,C),$--),d=l+1;d<$+l+1;d++)H(p,x[d]);return l+$}function Ye(l,p,x,C){let d=[],P=C||x[l+1],_=R(p,h.nargs);if(R(p,h.bools)&&!/^(true|false)$/.test(P))d.push(!0);else if(Ae(P)||Ae(C)&&/^-/.test(P)&&!D.test(P)&&!Z(P)){if(g[p]!==void 0){let $=g[p];d=Array.isArray($)?$:[$]}}else{Ae(C)||d.push(A(p,C,!0));for(let $=l+1;$<x.length&&!(!c["greedy-arrays"]&&d.length>0||_&&typeof _=="number"&&d.length>=_||(P=x[$],/^-/.test(P)&&!D.test(P)&&!Z(P)));$++)l=$,d.push(A(p,P,o))}return typeof _=="number"&&(_&&d.length<_||isNaN(_)&&d.length===0)&&(B=Error(w("Not enough arguments following: %s",p))),H(p,d),l}function H(l,p,x=o){if(/-/.test(l)&&c["camel-case-expansion"]){let P=l.split(".").map(function(_){return Je(_)}).join(".");M(l,P)}let C=A(l,p,x),d=l.split(".");$e(G,d,C),h.aliases[l]&&h.aliases[l].forEach(function(P){let _=P.split(".");$e(G,_,C)}),d.length>1&&c["dot-notation"]&&(h.aliases[d[0]]||[]).forEach(function(P){let _=P.split("."),$=[].concat(d);$.shift(),_=_.concat($),(h.aliases[l]||[]).includes(_.join("."))||$e(G,_,C)}),R(l,h.normalize)&&!R(l,h.arrays)&&[l].concat(h.aliases[l]||[]).forEach(function(_){Object.defineProperty(Re,_,{enumerable:!0,get(){return p},set($){p=typeof $=="string"?Fe.normalize($):$}})})}function M(l,p){h.aliases[l]&&h.aliases[l].length||(h.aliases[l]=[p],b[p]=!0),h.aliases[p]&&h.aliases[p].length||M(p,l)}function A(l,p,x){x&&(p=Uo(p)),(R(l,h.bools)||R(l,h.counts))&&typeof p=="string"&&(p=p==="true");let C=Array.isArray(p)?p.map(function(d){return j(l,d)}):j(l,p);return R(l,h.counts)&&(Ae(C)||typeof C=="boolean")&&(C=hn()),R(l,h.normalize)&&R(l,h.arrays)&&(Array.isArray(p)?C=p.map(d=>Fe.normalize(d)):C=Fe.normalize(p)),C}function j(l,p){return!c["parse-positional-numbers"]&&l==="_"||!R(l,h.strings)&&!R(l,h.bools)&&!Array.isArray(p)&&(Lt(p)&&c["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${p}`)))||!Ae(p)&&R(l,h.numbers))&&(p=Number(p)),p}function W(l){let p=Object.create(null);Q(p,h.aliases,g),Object.keys(h.configs).forEach(function(x){let C=l[x]||p[x];if(C)try{let d=null,P=Fe.resolve(Fe.cwd(),C),_=h.configs[x];if(typeof _=="function"){try{d=_(P)}catch($){d=$}if(d instanceof Error){B=d;return}}else d=Fe.require(P);Y(d)}catch(d){d.name==="PermissionDenied"?B=d:l[x]&&(B=Error(w("Invalid JSON config file: %s",C)))}})}function Y(l,p){Object.keys(l).forEach(function(x){let C=l[x],d=p?p+"."+x:x;typeof C=="object"&&C!==null&&!Array.isArray(C)&&c["dot-notation"]?Y(C,d):(!ve(G,d.split("."))||R(d,h.arrays)&&c["combine-arrays"])&&H(d,C)})}function re(){typeof y<"u"&&y.forEach(function(l){Y(l)})}function z(l,p){if(typeof m>"u")return;let x=typeof m=="string"?m:"",C=Fe.env();Object.keys(C).forEach(function(d){if(x===""||d.lastIndexOf(x,0)===0){let P=d.split("__").map(function(_,$){return $===0&&(_=_.substring(x.length)),Je(_)});(p&&h.configs[P.join(".")]||!p)&&!ve(l,P)&&H(P.join("."),C[d])}})}function oe(l){let p,x=new Set;Object.keys(l).forEach(function(C){if(!x.has(C)&&(p=R(C,h.coercions),typeof p=="function"))try{let d=j(C,p(l[C]));[].concat(h.aliases[C]||[],C).forEach(P=>{x.add(P),l[P]=d})}catch(d){B=d}})}function Ge(l){return h.keys.forEach(p=>{~p.indexOf(".")||typeof l[p]>"u"&&(l[p]=void 0)}),l}function Q(l,p,x,C=!1){Object.keys(x).forEach(function(d){ve(l,d.split("."))||($e(l,d.split("."),x[d]),C&&(O[d]=!0),(p[d]||[]).forEach(function(P){ve(l,P.split("."))||$e(l,P.split("."),x[d])}))})}function ve(l,p){let x=l;c["dot-notation"]||(p=[p.join(".")]),p.slice(0,-1).forEach(function(d){x=x[d]||{}});let C=p[p.length-1];return typeof x!="object"?!1:C in x}function $e(l,p,x){let C=l;c["dot-notation"]||(p=[p.join(".")]),p.slice(0,-1).forEach(function(se){se=yi(se),typeof C=="object"&&C[se]===void 0&&(C[se]={}),typeof C[se]!="object"||Array.isArray(C[se])?(Array.isArray(C[se])?C[se].push({}):C[se]=[C[se],{}],C=C[se][C[se].length-1]):C=C[se]});let d=yi(p[p.length-1]),P=R(p.join("."),h.arrays),_=Array.isArray(x),$=c["duplicate-arguments-array"];!$&&R(d,h.nargs)&&($=!0,(!Ae(C[d])&&h.nargs[d]===1||Array.isArray(C[d])&&C[d].length===h.nargs[d])&&(C[d]=void 0)),x===hn()?C[d]=hn(C[d]):Array.isArray(C[d])?$&&P&&_?C[d]=c["flatten-duplicate-arrays"]?C[d].concat(x):(Array.isArray(C[d][0])?C[d]:[C[d]]).concat([x]):!$&&!!P==!!_?C[d]=x:C[d]=C[d].concat([x]):C[d]===void 0&&P?C[d]=_?x:[x]:$&&!(C[d]===void 0||R(d,h.counts)||R(d,h.bools))?C[d]=[C[d],x]:C[d]=x}function He(...l){l.forEach(function(p){Object.keys(p||{}).forEach(function(x){h.aliases[x]||(h.aliases[x]=[].concat(s[x]||[]),h.aliases[x].concat(x).forEach(function(C){if(/-/.test(C)&&c["camel-case-expansion"]){let d=Je(C);d!==x&&h.aliases[x].indexOf(d)===-1&&(h.aliases[x].push(d),b[d]=!0)}}),h.aliases[x].concat(x).forEach(function(C){if(C.length>1&&/[A-Z]/.test(C)&&c["camel-case-expansion"]){let d=Wt(C,"-");d!==x&&h.aliases[x].indexOf(d)===-1&&(h.aliases[x].push(d),b[d]=!0)}}),h.aliases[x].forEach(function(C){h.aliases[C]=[x].concat(h.aliases[x].filter(function(d){return C!==d}))}))})})}function R(l,p){let x=[].concat(h.aliases[l]||[],l),C=Object.keys(p),d=x.find(P=>C.includes(P));return d?p[d]:!1}function sn(l){let p=Object.keys(h);return[].concat(p.map(C=>h[C])).some(function(C){return Array.isArray(C)?C.includes(l):C[l]})}function F(l,...p){return[].concat(...p).some(function(C){let d=l.match(C);return d&&sn(d[1])})}function K(l){if(l.match(D)||!l.match(/^-[^-]+/))return!1;let p=!0,x,C=l.slice(1).split("");for(let d=0;d<C.length;d++){if(x=l.slice(d+2),!sn(C[d])){p=!1;break}if(C[d+1]&&C[d+1]==="="||x==="-"||/[A-Za-z]/.test(C[d])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(x)||C[d+1]&&C[d+1].match(/\W/))break}return p}function Z(l){return c["unknown-options-as-args"]&&U(l)}function U(l){return l=l.replace(/^-{3,}/,"--"),l.match(D)||K(l)?!1:!F(l,/^-+([^=]+?)=[\s\S]*$/,L,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function X(l){return!R(l,h.bools)&&!R(l,h.counts)&&`${l}`in g?g[l]:ne(xe(l))}function ne(l){return{[ge.BOOLEAN]:!0,[ge.STRING]:"",[ge.NUMBER]:void 0,[ge.ARRAY]:[]}[l]}function xe(l){let p=ge.BOOLEAN;return R(l,h.strings)?p=ge.STRING:R(l,h.numbers)?p=ge.NUMBER:R(l,h.bools)?p=ge.BOOLEAN:R(l,h.arrays)&&(p=ge.ARRAY),p}function Ae(l){return l===void 0}function Ft(){Object.keys(h.counts).find(l=>R(l,h.arrays)?(B=Error(w("Invalid configuration: %s, opts.count excludes opts.array.",l)),!0):R(l,h.nargs)?(B=Error(w("Invalid configuration: %s, opts.count excludes opts.narg.",l)),!0):!1)}return{aliases:Object.assign({},h.aliases),argv:Object.assign(Re,G),configuration:c,defaulted:Object.assign({},O),error:B,newAliases:Object.assign({},b)}}};function ko(i){let e=[],t=Object.create(null),n=!0;for(Object.keys(i).forEach(function(r){e.push([].concat(i[r],r))});n;){n=!1;for(let r=0;r<e.length;r++)for(let o=r+1;o<e.length;o++)if(e[r].filter(function(c){return e[o].indexOf(c)!==-1}).length){e[r]=e[r].concat(e[o]),e.splice(o,1),n=!0;break}}return e.forEach(function(r){r=r.filter(function(s,c,g){return g.indexOf(s)===c});let o=r.pop();o!==void 0&&typeof o=="string"&&(t[o]=r)}),t}function hn(i){return i!==void 0?i+1:1}function yi(i){return i==="__proto__"?"___proto___":i}function Uo(i){return typeof i=="string"&&(i[0]==="'"||i[0]==='"')&&i[i.length-1]===i[0]?i.substring(1,i.length-1):i}import{readFileSync as Go}from"fs";var mn,gn,bn,Ci=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,wi=(gn=(mn=process==null?void 0:process.versions)===null||mn===void 0?void 0:mn.node)!==null&&gn!==void 0?gn:(bn=process==null?void 0:process.version)===null||bn===void 0?void 0:bn.slice(1);if(wi&&Number(wi.match(/^([^.]+)/)[1])<Ci)throw Error(`yargs parser supports a minimum Node.js version of ${Ci}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);var Ho=process?process.env:{},Oi=new kt({cwd:process.cwd,env:()=>Ho,format:Bo,normalize:zo,resolve:Yo,require:i=>{if(typeof je<"u")return je(i);if(i.match(/\.json$/))return JSON.parse(Go(i,"utf8"));throw Error("only .json config files are supported in ESM")}}),At=function(e,t){return Oi.parse(e.slice(),t).argv};At.detailed=function(i,e){return Oi.parse(i.slice(),e)};At.camelCase=Je;At.decamelize=Wt;At.looksLikeNumber=Lt;var yn=At;import{basename as ss,dirname as as,extname as cs,relative as ls,resolve as ji}from"path";function xi(){return Jo()?0:1}function Jo(){return Vo()&&!process.defaultApp}function Vo(){return!!process.versions.electron}function Cn(i){return i.slice(xi()+1)}function Ai(){return process.argv[xi()]}var J=class i extends Error{constructor(e){super(e||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,i)}};import{readFileSync as Ko,statSync as qo,writeFile as Qo}from"fs";import{format as Zo}from"util";import{resolve as Xo}from"path";var _i={fs:{readFileSync:Ko,writeFile:Qo},format:Zo,resolve:Xo,exists:i=>{try{return qo(i).isFile()}catch{return!1}}};var Ee,wn=class{constructor(e){e=e||{},this.directory=e.directory||"./locales",this.updateFiles=typeof e.updateFiles=="boolean"?e.updateFiles:!0,this.locale=e.locale||"en",this.fallbackToLanguage=typeof e.fallbackToLanguage=="boolean"?e.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...e){if(typeof arguments[0]!="string")return this._taggedLiteral(arguments[0],...arguments);let t=e.shift(),n=function(){};return typeof e[e.length-1]=="function"&&(n=e.pop()),n=n||function(){},this.cache[this.locale]||this._readLocaleFile(),!this.cache[this.locale][t]&&this.updateFiles?(this.cache[this.locale][t]=t,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:n})):n(),Ee.format.apply(Ee.format,[this.cache[this.locale][t]||t].concat(e))}__n(){let e=Array.prototype.slice.call(arguments),t=e.shift(),n=e.shift(),r=e.shift(),o=function(){};typeof e[e.length-1]=="function"&&(o=e.pop()),this.cache[this.locale]||this._readLocaleFile();let s=r===1?t:n;this.cache[this.locale][t]&&(s=this.cache[this.locale][t][r===1?"one":"other"]),!this.cache[this.locale][t]&&this.updateFiles?(this.cache[this.locale][t]={one:t,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:o})):o();let c=[s];return~s.indexOf("%d")&&c.push(r),Ee.format.apply(Ee.format,c.concat(e))}setLocale(e){this.locale=e}getLocale(){return this.locale}updateLocale(e){this.cache[this.locale]||this._readLocaleFile();for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(this.cache[this.locale][t]=e[t])}_taggedLiteral(e,...t){let n="";return e.forEach(function(r,o){let s=t[o+1];n+=r,typeof s<"u"&&(n+="%s")}),this.__.apply(this,[n].concat([].slice.call(t,1)))}_enqueueWrite(e){this.writeQueue.push(e),this.writeQueue.length===1&&this._processWriteQueue()}_processWriteQueue(){let e=this,t=this.writeQueue[0],n=t.directory,r=t.locale,o=t.cb,s=this._resolveLocaleFile(n,r),c=JSON.stringify(this.cache[r],null,2);Ee.fs.writeFile(s,c,"utf-8",function(g){e.writeQueue.shift(),e.writeQueue.length>0&&e._processWriteQueue(),o(g)})}_readLocaleFile(){let e={},t=this._resolveLocaleFile(this.directory,this.locale);try{Ee.fs.readFileSync&&(e=JSON.parse(Ee.fs.readFileSync(t,"utf-8")))}catch(n){if(n instanceof SyntaxError&&(n.message="syntax error in "+t),n.code==="ENOENT")e={};else throw n}this.cache[this.locale]=e}_resolveLocaleFile(e,t){let n=Ee.resolve(e,"./",t+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~t.lastIndexOf("_")){let r=Ee.resolve(e,"./",t.split("_")[0]+".json");this._fileExistsSync(r)&&(n=r)}return n}_fileExistsSync(e){return Ee.exists(e)}};function Ei(i,e){Ee=e;let t=new wn(i);return{__:t.__.bind(t),__n:t.__n.bind(t),setLocale:t.setLocale.bind(t),getLocale:t.getLocale.bind(t),updateLocale:t.updateLocale.bind(t),locale:t.locale}}var es=i=>Ei(i,_i),Si=es;var fs="require is not supported by ESM",Pi="loading a directory of commands is not supported yet for ESM",_t;try{_t=os(import.meta.url)}catch{_t=process.cwd()}var us=_t.substring(0,_t.lastIndexOf("node_modules")),On={assert:{notStrictEqual:ts,strictEqual:ns},cliui:pn,findUp:gi,getEnv:i=>process.env[i],inspect:is,getCallerFile:()=>{throw new J(Pi)},getProcessArgvBin:Ai,mainFilename:us||process.cwd(),Parser:yn,path:{basename:ss,dirname:as,extname:cs,relative:ls,resolve:ji},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(i,e)=>process.emitWarning(i,e),execPath:()=>process.execPath,exit:process.exit,nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:rs,require:()=>{throw new J(fs)},requireDirectory:()=>{throw new J(Pi)},stringWidth:i=>[...i].length,y18n:Si({directory:ji(_t,"../../../locales"),updateFiles:!1})};function le(i,e,t,n){t.assert.notStrictEqual(i,e,n)}function xn(i,e){e.assert.strictEqual(typeof i,"string")}function ft(i){return Object.keys(i)}function V(i){return!!i&&!!i.then&&typeof i.then=="function"}function De(i){let t=i.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),n=/\.*[\][<>]/g,r=t.shift();if(!r)throw new Error(`No command found in: ${i}`);let o={cmd:r.replace(n,""),demanded:[],optional:[]};return t.forEach((s,c)=>{let g=!1;s=s.replace(/\s/g,""),/\.+[\]>]/.test(s)&&c===t.length-1&&(g=!0),/^\[/.test(s)?o.optional.push({cmd:s.replace(n,"").split("|"),variadic:g}):o.demanded.push({cmd:s.replace(n,"").split("|"),variadic:g})}),o}var ds=["first","second","third","fourth","fifth","sixth"];function E(i,e,t){function n(){return typeof i=="object"?[{demanded:[],optional:[]},i,e]:[De(`cmd ${i}`),e,t]}try{let r=0,[o,s,c]=n(),g=[].slice.call(s);for(;g.length&&g[g.length-1]===void 0;)g.pop();let y=c||g.length;if(y<o.demanded.length)throw new J(`Not enough arguments provided. Expected ${o.demanded.length} but received ${g.length}.`);let m=o.demanded.length+o.optional.length;if(y>m)throw new J(`Too many arguments provided. Expected max ${m} but received ${y}.`);o.demanded.forEach(f=>{let u=g.shift(),b=Mi(u);f.cmd.filter(w=>w===b||w==="*").length===0&&vi(b,f.cmd,r),r+=1}),o.optional.forEach(f=>{if(g.length===0)return;let u=g.shift(),b=Mi(u);f.cmd.filter(w=>w===b||w==="*").length===0&&vi(b,f.cmd,r),r+=1})}catch(r){console.warn(r.stack)}}function Mi(i){return Array.isArray(i)?"array":i===null?"null":typeof i}function vi(i,e,t){throw new J(`Invalid ${ds[t]||"manyith"} argument. Expected ${e.join(" or ")} but received ${i}.`)}var Ut=class{constructor(e){this.globalMiddleware=[],this.frozens=[],this.yargs=e}addMiddleware(e,t,n=!0,r=!1){if(E("<array|function> [boolean] [boolean] [boolean]",[e,t,n],arguments.length),Array.isArray(e)){for(let o=0;o<e.length;o++){if(typeof e[o]!="function")throw Error("middleware must be a function");let s=e[o];s.applyBeforeValidation=t,s.global=n}Array.prototype.push.apply(this.globalMiddleware,e)}else if(typeof e=="function"){let o=e;o.applyBeforeValidation=t,o.global=n,o.mutates=r,this.globalMiddleware.push(e)}return this.yargs}addCoerceMiddleware(e,t){let n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter(r=>{let o=[...n[t]||[],t];return r.option?!o.includes(r.option):!0}),e.option=t,this.addMiddleware(e,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let e=this.frozens.pop();e!==void 0&&(this.globalMiddleware=e)}reset(){this.globalMiddleware=this.globalMiddleware.filter(e=>e.global)}};function $i(i){return i?i.map(e=>(e.applyBeforeValidation=!1,e)):[]}function Ve(i,e,t,n){return t.reduce((r,o)=>{if(o.applyBeforeValidation!==n)return r;if(o.mutates){if(o.applied)return r;o.applied=!0}if(V(r))return r.then(s=>Promise.all([s,o(s,e)])).then(([s,c])=>Object.assign(s,c));{let s=o(r,e);return V(s)?s.then(c=>Object.assign(r,c)):Object.assign(r,s)}},i)}function Ke(i,e,t=n=>{throw n}){try{let n=ps(i)?i():i;return V(n)?n.then(r=>e(r)):e(n)}catch(n){return t(n)}}function ps(i){return typeof i=="function"}function An(i){if(typeof je>"u")return null;for(let e=0,t=Object.keys(je.cache),n;e<t.length;e++)if(n=je.cache[t[e]],n.exports===i)return n;return null}var ut=/(^\*)|(^\$0)/,_n=class{constructor(e,t,n,r){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=r,this.usage=e,this.globalMiddleware=n,this.validation=t}addDirectory(e,t,n,r){r=r||{},typeof r.recurse!="boolean"&&(r.recurse=!1),Array.isArray(r.extensions)||(r.extensions=["js"]);let o=typeof r.visit=="function"?r.visit:s=>s;r.visit=(s,c,g)=>{let y=o(s,c,g);if(y){if(this.requireCache.has(c))return y;this.requireCache.add(c),this.addHandler(y)}return y},this.shim.requireDirectory({require:t,filename:n},e,r)}addHandler(e,t,n,r,o,s){let c=[],g=$i(o);if(r=r||(()=>{}),Array.isArray(e))if(hs(e))[e,...c]=e;else for(let y of e)this.addHandler(y);else if(gs(e)){let y=Array.isArray(e.command)||typeof e.command=="string"?e.command:this.moduleName(e);e.aliases&&(y=[].concat(y).concat(e.aliases)),this.addHandler(y,this.extractDesc(e),e.builder,e.handler,e.middlewares,e.deprecated);return}else if(Fi(n)){this.addHandler([e].concat(c),t,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof e=="string"){let y=De(e);c=c.map(u=>De(u).cmd);let m=!1,f=[y.cmd].concat(c).filter(u=>ut.test(u)?(m=!0,!1):!0);f.length===0&&m&&f.push("$0"),m&&(y.cmd=f[0],c=f.slice(1),e=e.replace(ut,y.cmd)),c.forEach(u=>{this.aliasMap[u]=y.cmd}),t!==!1&&this.usage.command(e,t,m,c,s),this.handlers[y.cmd]={original:e,description:t,handler:r,builder:n||{},middlewares:g,deprecated:s,demanded:y.demanded,optional:y.optional},m&&(this.defaultCommand=this.handlers[y.cmd])}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(e,t,n,r,o,s){let c=this.handlers[e]||this.handlers[this.aliasMap[e]]||this.defaultCommand,g=t.getInternalMethods().getContext(),y=g.commands.slice(),m=!e;e&&(g.commands.push(e),g.fullCommands.push(c.original));let f=this.applyBuilderUpdateUsageAndParse(m,c,t,n.aliases,y,r,o,s);return V(f)?f.then(u=>this.applyMiddlewareAndGetResult(m,c,u.innerArgv,g,o,u.aliases,t)):this.applyMiddlewareAndGetResult(m,c,f.innerArgv,g,o,f.aliases,t)}applyBuilderUpdateUsageAndParse(e,t,n,r,o,s,c,g){let y=t.builder,m=n;if(Bt(y)){n.getInternalMethods().getUsageInstance().freeze();let f=y(n.getInternalMethods().reset(r),g);if(V(f))return f.then(u=>(m=Ri(u)?u:n,this.parseAndUpdateUsage(e,t,m,o,s,c)))}else ms(y)&&(n.getInternalMethods().getUsageInstance().freeze(),m=n.getInternalMethods().reset(r),Object.keys(t.builder).forEach(f=>{m.option(f,y[f])}));return this.parseAndUpdateUsage(e,t,m,o,s,c)}parseAndUpdateUsage(e,t,n,r,o,s){e&&n.getInternalMethods().getUsageInstance().unfreeze(!0),this.shouldUpdateUsage(n)&&n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(r,t),t.description);let c=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,o,s);return V(c)?c.then(g=>({aliases:n.parsed.aliases,innerArgv:g})):{aliases:n.parsed.aliases,innerArgv:c}}shouldUpdateUsage(e){return!e.getInternalMethods().getUsageInstance().getUsageDisabled()&&e.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(e,t){let n=ut.test(t.original)?t.original.replace(ut,"").trim():t.original,r=e.filter(o=>!ut.test(o));return r.push(n),`$0 ${r.join(" ")}`}handleValidationAndGetResult(e,t,n,r,o,s,c,g){if(!s.getInternalMethods().getHasOutput()){let y=s.getInternalMethods().runValidation(o,g,s.parsed.error,e);n=Ke(n,m=>(y(m),m))}if(t.handler&&!s.getInternalMethods().getHasOutput()){s.getInternalMethods().setHasOutput();let y=!!s.getOptions().configuration["populate--"];s.getInternalMethods().postProcess(n,y,!1,!1),n=Ve(n,s,c,!1),n=Ke(n,m=>{let f=t.handler(m);return V(f)?f.then(()=>m):m}),e||s.getInternalMethods().getUsageInstance().cacheHelpMessage(),V(n)&&!s.getInternalMethods().hasParseCallback()&&n.catch(m=>{try{s.getInternalMethods().getUsageInstance().fail(null,m)}catch{}})}return e||(r.commands.pop(),r.fullCommands.pop()),n}applyMiddlewareAndGetResult(e,t,n,r,o,s,c){let g={};if(o)return n;c.getInternalMethods().getHasOutput()||(g=this.populatePositionals(t,n,r,c));let y=this.globalMiddleware.getMiddleware().slice(0).concat(t.middlewares),m=Ve(n,c,y,!0);return V(m)?m.then(f=>this.handleValidationAndGetResult(e,t,f,r,s,c,y,g)):this.handleValidationAndGetResult(e,t,m,r,s,c,y,g)}populatePositionals(e,t,n,r){t._=t._.slice(n.commands.length);let o=e.demanded.slice(0),s=e.optional.slice(0),c={};for(this.validation.positionalCount(o.length,t._.length);o.length;){let g=o.shift();this.populatePositional(g,t,c)}for(;s.length;){let g=s.shift();this.populatePositional(g,t,c)}return t._=n.commands.concat(t._.map(g=>""+g)),this.postProcessPositionals(t,c,this.cmdToParseOptions(e.original),r),c}populatePositional(e,t,n){let r=e.cmd[0];e.variadic?n[r]=t._.splice(0).map(String):t._.length&&(n[r]=[String(t._.shift())])}cmdToParseOptions(e){let t={array:[],default:{},alias:{},demand:{}},n=De(e);return n.demanded.forEach(r=>{let[o,...s]=r.cmd;r.variadic&&(t.array.push(o),t.default[o]=[]),t.alias[o]=s,t.demand[o]=!0}),n.optional.forEach(r=>{let[o,...s]=r.cmd;r.variadic&&(t.array.push(o),t.default[o]=[]),t.alias[o]=s}),t}postProcessPositionals(e,t,n,r){let o=Object.assign({},r.getOptions());o.default=Object.assign(n.default,o.default);for(let y of Object.keys(n.alias))o.alias[y]=(o.alias[y]||[]).concat(n.alias[y]);o.array=o.array.concat(n.array),o.config={};let s=[];if(Object.keys(t).forEach(y=>{t[y].map(m=>{o.configuration["unknown-options-as-args"]&&(o.key[y]=!0),s.push(`--${y}`),s.push(m)})}),!s.length)return;let c=Object.assign({},o.configuration,{"populate--":!1}),g=this.shim.Parser.detailed(s,Object.assign({},o,{configuration:c}));if(g.error)r.getInternalMethods().getUsageInstance().fail(g.error.message,g.error);else{let y=Object.keys(t);Object.keys(t).forEach(m=>{y.push(...g.aliases[m])}),Object.keys(g.argv).forEach(m=>{y.includes(m)&&(t[m]||(t[m]=g.argv[m]),!this.isInConfigs(r,m)&&!this.isDefaulted(r,m)&&Object.prototype.hasOwnProperty.call(e,m)&&Object.prototype.hasOwnProperty.call(g.argv,m)&&(Array.isArray(e[m])||Array.isArray(g.argv[m]))?e[m]=[].concat(e[m],g.argv[m]):e[m]=g.argv[m])})}}isDefaulted(e,t){let{default:n}=e.getOptions();return Object.prototype.hasOwnProperty.call(n,t)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(t))}isInConfigs(e,t){let{configObjects:n}=e.getOptions();return n.some(r=>Object.prototype.hasOwnProperty.call(r,t))||n.some(r=>Object.prototype.hasOwnProperty.call(r,this.shim.Parser.camelCase(t)))}runDefaultBuilderOn(e){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(e)){let n=ut.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");e.getInternalMethods().getUsageInstance().usage(n,this.defaultCommand.description)}let t=this.defaultCommand.builder;if(Bt(t))return t(e,!0);Fi(t)||Object.keys(t).forEach(n=>{e.option(n,t[n])})}moduleName(e){let t=An(e);if(!t)throw new Error(`No command name given for module: ${this.shim.inspect(e)}`);return this.commandFromFilename(t.filename)}commandFromFilename(e){return this.shim.path.basename(e,this.shim.path.extname(e))}extractDesc({describe:e,description:t,desc:n}){for(let r of[e,t,n]){if(typeof r=="string"||r===!1)return r;le(r,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let e=this.frozens.pop();le(e,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=e}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}};function Ii(i,e,t,n){return new _n(i,e,t,n)}function Fi(i){return typeof i=="object"&&!!i.builder&&typeof i.handler=="function"}function hs(i){return i.every(e=>typeof e=="string")}function Bt(i){return typeof i=="function"}function ms(i){return typeof i=="object"}function gs(i){return typeof i=="object"&&!Array.isArray(i)}function Te(i={},e=()=>!0){let t={};return ft(i).forEach(n=>{e(n,i[n])&&(t[n]=i[n])}),t}function We(i){typeof process>"u"||[process.stdout,process.stderr].forEach(e=>{let t=e;t._handle&&t.isTTY&&typeof t._handle.setBlocking=="function"&&t._handle.setBlocking(i)})}function bs(i){return typeof i=="boolean"}function Di(i,e){let t=e.y18n.__,n={},r=[];n.failFn=function(A){r.push(A)};let o=null,s=null,c=!0;n.showHelpOnFail=function(A=!0,j){let[W,Y]=typeof A=="string"?[!0,A]:[A,j];return i.getInternalMethods().isGlobalContext()&&(s=Y),o=Y,c=W,n};let g=!1;n.fail=function(A,j){let W=i.getInternalMethods().getLoggerInstance();if(r.length)for(let Y=r.length-1;Y>=0;--Y){let re=r[Y];if(bs(re)){if(j)throw j;if(A)throw Error(A)}else re(A,j,n)}else{if(i.getExitProcess()&&We(!0),!g){g=!0,c&&(i.showHelp("error"),W.error()),(A||j)&&W.error(A||j);let Y=o||s;Y&&((A||j)&&W.error(""),W.error(Y))}if(j=j||new J(A),i.getExitProcess())return i.exit(1);if(i.getInternalMethods().hasParseCallback())return i.exit(1,j);throw j}};let y=[],m=!1;n.usage=(M,A)=>M===null?(m=!0,y=[],n):(m=!1,y.push([M,A||""]),n),n.getUsage=()=>y,n.getUsageDisabled=()=>m,n.getPositionalGroupName=()=>t("Positionals:");let f=[];n.example=(M,A)=>{f.push([M,A||""])};let u=[];n.command=function(A,j,W,Y,re=!1){W&&(u=u.map(z=>(z[2]=!1,z))),u.push([A,j||"",W,Y,re])},n.getCommands=()=>u;let b={};n.describe=function(A,j){Array.isArray(A)?A.forEach(W=>{n.describe(W,j)}):typeof A=="object"?Object.keys(A).forEach(W=>{n.describe(W,A[W])}):b[A]=j},n.getDescriptions=()=>b;let O=[];n.epilog=M=>{O.push(M)};let w=!1,h;n.wrap=M=>{w=!0,h=M},n.getWrap=()=>e.getEnv("YARGS_DISABLE_WRAP")?null:(w||(h=at(),w=!0),h);let D="__yargsString__:";n.deferY18nLookup=M=>D+M,n.help=function(){if(k)return k;B();let A=i.customScriptName?i.$0:e.path.basename(i.$0),j=i.getDemandedOptions(),W=i.getDemandedCommands(),Y=i.getDeprecatedOptions(),re=i.getGroups(),z=i.getOptions(),oe=[];oe=oe.concat(Object.keys(b)),oe=oe.concat(Object.keys(j)),oe=oe.concat(Object.keys(W)),oe=oe.concat(Object.keys(z.default)),oe=oe.filter(Re),oe=Object.keys(oe.reduce((F,K)=>(K!=="_"&&(F[K]=!0),F),{}));let Ge=n.getWrap(),Q=e.cliui({width:Ge,wrap:!!Ge});if(!m){if(y.length)y.forEach(F=>{Q.div({text:`${F[0].replace(/\$0/g,A)}`}),F[1]&&Q.div({text:`${F[1]}`,padding:[1,0,0,0]})}),Q.div();else if(u.length){let F=null;W._?F=`${A} <${t("command")}> `:F=`${A} [${t("command")}] `,Q.div(`${F}`)}}if(u.length>1||u.length===1&&!u[0][2]){Q.div(t("Commands:"));let F=i.getInternalMethods().getContext(),K=F.commands.length?`${F.commands.join(" ")} `:"";i.getInternalMethods().getParserConfiguration()["sort-commands"]===!0&&(u=u.sort((U,X)=>U[0].localeCompare(X[0])));let Z=A?`${A} `:"";u.forEach(U=>{let X=`${Z}${K}${U[0].replace(/^\$0 ?/,"")}`;Q.span({text:X,padding:[0,2,0,2],width:L(u,Ge,`${A}${K}`)+4},{text:U[1]});let ne=[];U[2]&&ne.push(`[${t("default")}]`),U[3]&&U[3].length&&ne.push(`[${t("aliases:")} ${U[3].join(", ")}]`),U[4]&&(typeof U[4]=="string"?ne.push(`[${t("deprecated: %s",U[4])}]`):ne.push(`[${t("deprecated")}]`)),ne.length?Q.div({text:ne.join(" "),padding:[0,0,0,2],align:"right"}):Q.div()}),Q.div()}let ve=(Object.keys(z.alias)||[]).concat(Object.keys(i.parsed.newAliases)||[]);oe=oe.filter(F=>!i.parsed.newAliases[F]&&ve.every(K=>(z.alias[K]||[]).indexOf(F)===-1));let $e=t("Options:");re[$e]||(re[$e]=[]),G(oe,z.alias,re,$e);let He=F=>/^--/.test(zt(F)),R=Object.keys(re).filter(F=>re[F].length>0).map(F=>{let K=re[F].filter(Re).map(Z=>{if(ve.includes(Z))return Z;for(let U=0,X;(X=ve[U])!==void 0;U++)if((z.alias[X]||[]).includes(Z))return X;return Z});return{groupName:F,normalizedKeys:K}}).filter(({normalizedKeys:F})=>F.length>0).map(({groupName:F,normalizedKeys:K})=>{let Z=K.reduce((U,X)=>(U[X]=[X].concat(z.alias[X]||[]).map(ne=>F===n.getPositionalGroupName()?ne:(/^[0-9]$/.test(ne)?z.boolean.includes(X)?"-":"--":ne.length>1?"--":"-")+ne).sort((ne,xe)=>He(ne)===He(xe)?0:He(ne)?1:-1).join(", "),U),{});return{groupName:F,normalizedKeys:K,switches:Z}});if(R.filter(({groupName:F})=>F!==n.getPositionalGroupName()).some(({normalizedKeys:F,switches:K})=>!F.every(Z=>He(K[Z])))&&R.filter(({groupName:F})=>F!==n.getPositionalGroupName()).forEach(({normalizedKeys:F,switches:K})=>{F.forEach(Z=>{He(K[Z])&&(K[Z]=ys(K[Z],4))})}),R.forEach(({groupName:F,normalizedKeys:K,switches:Z})=>{Q.div(F),K.forEach(U=>{let X=Z[U