@willbooster/wb 4.12.2 → 4.13.0

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,4 +1,4 @@
1
- import t,{resolve as e,dirname as s,normalize as n,basename as i,extname as r,relative as o}from"node:path";import{notStrictEqual as a,strictEqual as c}from"node:assert";import l,{statSync as h,readdirSync as d,readFileSync as u,writeFile as f}from"node:fs";import{format as p,inspect as g}from"node:util";import{fileURLToPath as m}from"node:url";import y,{spawn as b,spawnSync as w}from"node:child_process";import{createHash as v}from"node:crypto";import O from"node:fs/promises";import k from"chalk";import{config as A}from"dotenv";import{PromisePool as E}from"minimal-promise-pool";import j from"kill-port";import _ from"tree-kill";import x from"node:os";function $(t){return new Promise((e=>{l.access(t,l.constants.F_OK,(t=>{e(!t)}))}))}async function P(t,e,s){return new Promise(((n,i)=>{try{const r=b(t,e??[],s??{});let o="",a="";s?.input&&(r.stdin?.write(s.input),r.stdin?.end()),r.stdout?.on("data",(t=>{o+=t})),r.stderr?.on("data",(t=>{s?.mergeOutAndError?o+=t:a+=t}));let c=!1;const l=()=>{!c&&r.pid&&(c=!0,s?.verbose&&console.info(`treeKill(${r.pid})`),_(r.pid))};s?.killOnExit&&(process.on("beforeExit",l),process.on("SIGINT",l)),r.on("error",(t=>{process.removeListener("exit",l),r.removeAllListeners("close"),i(t)})),r.on("close",((t,e)=>{process.removeListener("exit",l),void 0===r.pid?i(new Error("Process has no pid.")):n({pid:r.pid,stdout:o,stderr:a,status:t,signal:e})}))}catch(t){i(t)}}))}const C={right:function(t,e){t=t.trim();const s=N.stringWidth(t);if(s<e)return" ".repeat(e-s)+t;return t},center:function(t,e){t=t.trim();const s=N.stringWidth(t);if(s>=e)return t;return" ".repeat(e-s>>1)+t}};class S{constructor(t){var e;this.width=t.width,this.wrap=null===(e=t.wrap)||void 0===e||e,this.rows=[]}span(...t){this.div(...t).span=!0}resetOutput(){this.rows=[]}div(...t){if(0===t.length&&this.div(""),this.wrap&&this.shouldApplyLayoutDSL(...t)&&"string"==typeof t[0])return this.applyLayoutDSL(t[0]);const e=t.map((t=>"string"==typeof t?this.colFromString(t):t));return this.rows.push(e),e}shouldApplyLayoutDSL(...t){return 1===t.length&&"string"==typeof t[0]&&/[\t\n]/.test(t[0])}applyLayoutDSL(t){const e=t.split("\n").map((t=>t.split("\t")));let s=0;return e.forEach((t=>{t.length>1&&N.stringWidth(t[0])>s&&(s=Math.min(Math.floor(.5*this.width),N.stringWidth(t[0])))})),e.forEach((t=>{this.div(...t.map(((e,n)=>({text:e.trim(),padding:this.measurePadding(e),width:0===n&&t.length>1?s:void 0}))))})),this.rows[this.rows.length-1]}colFromString(t){return{text:t,padding:this.measurePadding(t)}}measurePadding(t){const e=N.stripAnsi(t);return[0,e.match(/\s*$/)[0].length,0,e.match(/^\s*/)[0].length]}toString(){const t=[];return this.rows.forEach((e=>{this.rowToString(e,t)})),t.filter((t=>!t.hidden)).map((t=>t.text)).join("\n")}rowToString(t,e){return this.rasterize(t).forEach(((s,n)=>{let i="";s.forEach(((s,r)=>{const{width:o}=t[r],a=this.negatePadding(t[r]);let c=s;if(a>N.stringWidth(s)&&(c+=" ".repeat(a-N.stringWidth(s))),t[r].align&&"left"!==t[r].align&&this.wrap){c=(0,C[t[r].align])(c,a),N.stringWidth(c)<a&&(c+=" ".repeat((o||0)-N.stringWidth(c)-1))}const l=t[r].padding||[0,0,0,0];l[3]&&(i+=" ".repeat(l[3])),i+=M(t[r],c,"| "),i+=c,i+=M(t[r],c," |"),l[1]&&(i+=" ".repeat(l[1])),0===n&&e.length>0&&(i=this.renderInline(i,e[e.length-1]))})),e.push({text:i.replace(/ +$/,""),span:t.span})})),e}renderInline(t,e){const s=t.match(/^ */),n=s?s[0].length:0,i=e.text,r=N.stringWidth(i.trimRight());return e.span?this.wrap?n<r?t:(e.hidden=!0,i.trimRight()+" ".repeat(n-r)+t.trimLeft()):(e.hidden=!0,i+t):t}rasterize(t){const e=[],s=this.columnWidths(t);let n;return t.forEach(((t,i)=>{t.width=s[i],n=this.wrap?N.wrap(t.text,this.negatePadding(t),{hard:!0}).split("\n"):t.text.split("\n"),t.border&&(n.unshift("."+"-".repeat(this.negatePadding(t)+2)+"."),n.push("'"+"-".repeat(this.negatePadding(t)+2)+"'")),t.padding&&(n.unshift(...new Array(t.padding[0]||0).fill("")),n.push(...new Array(t.padding[2]||0).fill(""))),n.forEach(((t,s)=>{e[s]||e.push([]);const n=e[s];for(let t=0;t<i;t++)void 0===n[t]&&n.push("");n.push(t)}))})),e}negatePadding(t){let e=t.width||0;return t.padding&&(e-=(t.padding[3]||0)+(t.padding[1]||0)),t.border&&(e-=4),e}columnWidths(t){if(!this.wrap)return t.map((t=>t.width||N.stringWidth(t.text)));let e=t.length,s=this.width;const n=t.map((t=>{if(t.width)return e--,s-=t.width,t.width})),i=e?Math.floor(s/e):0;return n.map(((e,s)=>void 0===e?Math.max(i,function(t){const e=t.padding||[],s=1+(e[3]||0)+(e[1]||0);if(t.border)return s+4;return s}(t[s])):e))}}function M(t,e,s){return t.border?/[.']-+[.']/.test(e)?"":0!==e.trim().length?s:" ":""}let N;const D=new RegExp("(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)","g");function I(t){return t.replace(D,"")}function R(t,e){const[s,n]=t.match(D)||["",""];t=I(t);let i="";for(let s=0;s<t.length;s++)0!==s&&s%e==0&&(i+="\n"),i+=t.charAt(s);return s&&n&&(i=`${s}${i}${n}`),i}
1
+ import t,{resolve as e,dirname as s,normalize as n,basename as i,extname as r,relative as o}from"node:path";import{notStrictEqual as a,strictEqual as c}from"node:assert";import l,{statSync as h,readdirSync as d,readFileSync as u,writeFile as f}from"node:fs";import{format as p,inspect as g}from"node:util";import{fileURLToPath as m}from"node:url";import y,{spawn as b,spawnSync as w}from"node:child_process";import{createHash as v}from"node:crypto";import k from"node:fs/promises";import O from"chalk";import{config as A}from"dotenv";import{PromisePool as E}from"minimal-promise-pool";import j from"kill-port";import _ from"tree-kill";import x from"node:os";function $(t){return new Promise((e=>{l.access(t,l.constants.F_OK,(t=>{e(!t)}))}))}async function P(t,e,s){return new Promise(((n,i)=>{try{const r=b(t,e??[],s??{});let o="",a="";s?.input&&(r.stdin?.write(s.input),r.stdin?.end()),r.stdout?.on("data",(t=>{o+=t})),r.stderr?.on("data",(t=>{s?.mergeOutAndError?o+=t:a+=t}));let c=!1;const l=()=>{!c&&r.pid&&(c=!0,s?.verbose&&console.info(`treeKill(${r.pid})`),_(r.pid))};s?.killOnExit&&(process.on("beforeExit",l),process.on("SIGINT",l)),r.on("error",(t=>{process.removeListener("exit",l),r.removeAllListeners("close"),i(t)})),r.on("close",((t,e)=>{process.removeListener("exit",l),void 0===r.pid?i(new Error("Process has no pid.")):n({pid:r.pid,stdout:o,stderr:a,status:t,signal:e})}))}catch(t){i(t)}}))}const C={right:function(t,e){t=t.trim();const s=N.stringWidth(t);if(s<e)return" ".repeat(e-s)+t;return t},center:function(t,e){t=t.trim();const s=N.stringWidth(t);if(s>=e)return t;return" ".repeat(e-s>>1)+t}};class S{constructor(t){var e;this.width=t.width,this.wrap=null===(e=t.wrap)||void 0===e||e,this.rows=[]}span(...t){this.div(...t).span=!0}resetOutput(){this.rows=[]}div(...t){if(0===t.length&&this.div(""),this.wrap&&this.shouldApplyLayoutDSL(...t)&&"string"==typeof t[0])return this.applyLayoutDSL(t[0]);const e=t.map((t=>"string"==typeof t?this.colFromString(t):t));return this.rows.push(e),e}shouldApplyLayoutDSL(...t){return 1===t.length&&"string"==typeof t[0]&&/[\t\n]/.test(t[0])}applyLayoutDSL(t){const e=t.split("\n").map((t=>t.split("\t")));let s=0;return e.forEach((t=>{t.length>1&&N.stringWidth(t[0])>s&&(s=Math.min(Math.floor(.5*this.width),N.stringWidth(t[0])))})),e.forEach((t=>{this.div(...t.map(((e,n)=>({text:e.trim(),padding:this.measurePadding(e),width:0===n&&t.length>1?s:void 0}))))})),this.rows[this.rows.length-1]}colFromString(t){return{text:t,padding:this.measurePadding(t)}}measurePadding(t){const e=N.stripAnsi(t);return[0,e.match(/\s*$/)[0].length,0,e.match(/^\s*/)[0].length]}toString(){const t=[];return this.rows.forEach((e=>{this.rowToString(e,t)})),t.filter((t=>!t.hidden)).map((t=>t.text)).join("\n")}rowToString(t,e){return this.rasterize(t).forEach(((s,n)=>{let i="";s.forEach(((s,r)=>{const{width:o}=t[r],a=this.negatePadding(t[r]);let c=s;if(a>N.stringWidth(s)&&(c+=" ".repeat(a-N.stringWidth(s))),t[r].align&&"left"!==t[r].align&&this.wrap){c=(0,C[t[r].align])(c,a),N.stringWidth(c)<a&&(c+=" ".repeat((o||0)-N.stringWidth(c)-1))}const l=t[r].padding||[0,0,0,0];l[3]&&(i+=" ".repeat(l[3])),i+=M(t[r],c,"| "),i+=c,i+=M(t[r],c," |"),l[1]&&(i+=" ".repeat(l[1])),0===n&&e.length>0&&(i=this.renderInline(i,e[e.length-1]))})),e.push({text:i.replace(/ +$/,""),span:t.span})})),e}renderInline(t,e){const s=t.match(/^ */),n=s?s[0].length:0,i=e.text,r=N.stringWidth(i.trimRight());return e.span?this.wrap?n<r?t:(e.hidden=!0,i.trimRight()+" ".repeat(n-r)+t.trimLeft()):(e.hidden=!0,i+t):t}rasterize(t){const e=[],s=this.columnWidths(t);let n;return t.forEach(((t,i)=>{t.width=s[i],n=this.wrap?N.wrap(t.text,this.negatePadding(t),{hard:!0}).split("\n"):t.text.split("\n"),t.border&&(n.unshift("."+"-".repeat(this.negatePadding(t)+2)+"."),n.push("'"+"-".repeat(this.negatePadding(t)+2)+"'")),t.padding&&(n.unshift(...new Array(t.padding[0]||0).fill("")),n.push(...new Array(t.padding[2]||0).fill(""))),n.forEach(((t,s)=>{e[s]||e.push([]);const n=e[s];for(let t=0;t<i;t++)void 0===n[t]&&n.push("");n.push(t)}))})),e}negatePadding(t){let e=t.width||0;return t.padding&&(e-=(t.padding[3]||0)+(t.padding[1]||0)),t.border&&(e-=4),e}columnWidths(t){if(!this.wrap)return t.map((t=>t.width||N.stringWidth(t.text)));let e=t.length,s=this.width;const n=t.map((t=>{if(t.width)return e--,s-=t.width,t.width})),i=e?Math.floor(s/e):0;return n.map(((e,s)=>void 0===e?Math.max(i,function(t){const e=t.padding||[],s=1+(e[3]||0)+(e[1]||0);if(t.border)return s+4;return s}(t[s])):e))}}function M(t,e,s){return t.border?/[.']-+[.']/.test(e)?"":0!==e.trim().length?s:" ":""}let N;const D=new RegExp("(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)","g");function I(t){return t.replace(D,"")}function R(t,e){const[s,n]=t.match(D)||["",""];t=I(t);let i="";for(let s=0;s<t.length;s++)0!==s&&s%e==0&&(i+="\n"),i+=t.charAt(s);return s&&n&&(i=`${s}${i}${n}`),i}
2
2
  /**
3
3
  * @license
4
4
  * Copyright (c) 2016, Contributors
@@ -30,5 +30,5 @@ let T;!function(t){t.BOOLEAN="boolean",t.STRING="string",t.NUMBER="number",t.ARR
30
30
  * Copyright (c) 2016, Contributors
31
31
  * SPDX-License-Identifier: ISC
32
32
  */
33
- var H,V,q;const Y=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,J=null!==(V=null===(H=null===process||void 0===process?void 0:process.versions)||void 0===H?void 0:H.node)&&void 0!==V?V:null===(q=null===process||void 0===process?void 0:process.version)||void 0===q?void 0:q.slice(1);if(J){if(Number(J.match(/^([^.]+)/)[1])<Y)throw Error(`yargs parser supports a minimum Node.js version of ${Y}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}const G=process?process.env:{},K=new class{constructor(t){T=t}parse(t,e){const s=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},e),n=function(t){if(Array.isArray(t))return t.map((t=>"string"!=typeof t?t+"":t));t=t.trim();let e=0,s=null,n=null,i=null;const r=[];for(let o=0;o<t.length;o++)s=n,n=t.charAt(o)," "!==n||i?(n===i?i=null:"'"!==n&&'"'!==n||i||(i=n),r[e]||(r[e]=""),r[e]+=n):" "!==s&&e++;return r}(t),i="string"==typeof t,r=function(t){const e=[],s=Object.create(null);let n=!0;Object.keys(t).forEach((function(s){e.push([].concat(t[s],s))}));for(;n;){n=!1;for(let t=0;t<e.length;t++)for(let s=t+1;s<e.length;s++){if(e[t].filter((function(t){return-1!==e[s].indexOf(t)})).length){e[t]=e[t].concat(e[s]),e.splice(s,1),n=!0;break}}}return e.forEach((function(t){const e=(t=t.filter((function(t,e,s){return s.indexOf(t)===e}))).pop();void 0!==e&&"string"==typeof e&&(s[e]=t)})),s}(Object.assign(Object.create(null),s.alias)),o=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},s.configuration),a=Object.assign(Object.create(null),s.default),c=s.configObjects||[],l=s.envPrefix,h=o["populate--"],d=h?"--":"_",u=Object.create(null),f=Object.create(null),p=s.__||T.format,g={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:[]},m=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,y=new RegExp("^--"+o["negation-prefix"]+"(.+)");[].concat(s.array||[]).filter(Boolean).forEach((function(t){const e="object"==typeof t?t.key:t,s=Object.keys(t).map((function(t){return{boolean:"bools",string:"strings",number:"numbers"}[t]})).filter(Boolean).pop();s&&(g[s][e]=!0),g.arrays[e]=!0,g.keys.push(e)})),[].concat(s.boolean||[]).filter(Boolean).forEach((function(t){g.bools[t]=!0,g.keys.push(t)})),[].concat(s.string||[]).filter(Boolean).forEach((function(t){g.strings[t]=!0,g.keys.push(t)})),[].concat(s.number||[]).filter(Boolean).forEach((function(t){g.numbers[t]=!0,g.keys.push(t)})),[].concat(s.count||[]).filter(Boolean).forEach((function(t){g.counts[t]=!0,g.keys.push(t)})),[].concat(s.normalize||[]).filter(Boolean).forEach((function(t){g.normalize[t]=!0,g.keys.push(t)})),"object"==typeof s.narg&&Object.entries(s.narg).forEach((([t,e])=>{"number"==typeof e&&(g.nargs[t]=e,g.keys.push(t))})),"object"==typeof s.coerce&&Object.entries(s.coerce).forEach((([t,e])=>{"function"==typeof e&&(g.coercions[t]=e,g.keys.push(t))})),void 0!==s.config&&(Array.isArray(s.config)||"string"==typeof s.config?[].concat(s.config).filter(Boolean).forEach((function(t){g.configs[t]=!0})):"object"==typeof s.config&&Object.entries(s.config).forEach((([t,e])=>{"boolean"!=typeof e&&"function"!=typeof e||(g.configs[t]=e)}))),function(...t){t.forEach((function(t){Object.keys(t||{}).forEach((function(t){g.aliases[t]||(g.aliases[t]=[].concat(r[t]||[]),g.aliases[t].concat(t).forEach((function(e){if(/-/.test(e)&&o["camel-case-expansion"]){const s=z(e);s!==t&&-1===g.aliases[t].indexOf(s)&&(g.aliases[t].push(s),u[s]=!0)}})),g.aliases[t].concat(t).forEach((function(e){if(e.length>1&&/[A-Z]/.test(e)&&o["camel-case-expansion"]){const s=W(e,"-");s!==t&&-1===g.aliases[t].indexOf(s)&&(g.aliases[t].push(s),u[s]=!0)}})),g.aliases[t].forEach((function(e){g.aliases[e]=[t].concat(g.aliases[t].filter((function(t){return e!==t})))})))}))}))}(s.key,r,s.default,g.arrays),Object.keys(a).forEach((function(t){(g.aliases[t]||[]).forEach((function(e){a[e]=a[t]}))}));let b=null;Object.keys(g.counts).find((t=>D(t,g.arrays)?(b=Error(p("Invalid configuration: %s, opts.count excludes opts.array.",t)),!0):!!D(t,g.nargs)&&(b=Error(p("Invalid configuration: %s, opts.count excludes opts.narg.",t)),!0)));let w=[];const v=Object.assign(Object.create(null),{_:[]}),O={};for(let t=0;t<n.length;t++){const e=n[t],s=e.replace(/^-{3,}/,"---");let i,r,a,c,l,h;if("--"!==e&&/^-/.test(e)&&R(e))k(e);else{if(s.match(/^---+(=|$)/)){k(e);continue}if(e.match(/^--.+=/)||!o["short-option-groups"]&&e.match(/^-.+=/))c=e.match(/^--?([^=]+)=([\s\S]*)$/),null!==c&&Array.isArray(c)&&c.length>=3&&(D(c[1],g.arrays)?t=E(t,c[1],n,c[2]):!1!==D(c[1],g.nargs)?t=A(t,c[1],n,c[2]):j(c[1],c[2],!0));else if(e.match(y)&&o["boolean-negation"])c=e.match(y),null!==c&&Array.isArray(c)&&c.length>=2&&(r=c[1],j(r,!!D(r,g.arrays)&&[!1]));else if(e.match(/^--.+/)||!o["short-option-groups"]&&e.match(/^-[^-]+/))c=e.match(/^--?(.+)/),null!==c&&Array.isArray(c)&&c.length>=2&&(r=c[1],D(r,g.arrays)?t=E(t,r,n):!1!==D(r,g.nargs)?t=A(t,r,n):(l=n[t+1],void 0===l||l.match(/^-/)&&!l.match(m)||D(r,g.bools)||D(r,g.counts)?/^(true|false)$/.test(l)?(j(r,l),t++):j(r,H(r)):(j(r,l),t++)));else if(e.match(/^-.\..+=/))c=e.match(/^-([^=]+)=([\s\S]*)$/),null!==c&&Array.isArray(c)&&c.length>=3&&j(c[1],c[2]);else if(e.match(/^-.\..+/)&&!e.match(m))l=n[t+1],c=e.match(/^-(.\..+)/),null!==c&&Array.isArray(c)&&c.length>=2&&(r=c[1],void 0===l||l.match(/^-/)||D(r,g.bools)||D(r,g.counts)?j(r,H(r)):(j(r,l),t++));else if(e.match(/^-[^-]+/)&&!e.match(m)){a=e.slice(1,-1).split(""),i=!1;for(let s=0;s<a.length;s++){if(l=e.slice(s+2),a[s+1]&&"="===a[s+1]){h=e.slice(s+3),r=a[s],D(r,g.arrays)?t=E(t,r,n,h):!1!==D(r,g.nargs)?t=A(t,r,n,h):j(r,h),i=!0;break}if("-"!==l){if(/[A-Za-z]/.test(a[s])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(l)&&!1===D(l,g.bools)){j(a[s],l),i=!0;break}if(a[s+1]&&a[s+1].match(/\W/)){j(a[s],l),i=!0;break}j(a[s],H(a[s]))}else j(a[s],l)}r=e.slice(-1)[0],i||"-"===r||(D(r,g.arrays)?t=E(t,r,n):!1!==D(r,g.nargs)?t=A(t,r,n):(l=n[t+1],void 0===l||/^(-|--)[^-]/.test(l)&&!l.match(m)||D(r,g.bools)||D(r,g.counts)?/^(true|false)$/.test(l)?(j(r,l),t++):j(r,H(r)):(j(r,l),t++)))}else if(e.match(/^-[0-9]$/)&&e.match(m)&&D(e.slice(1),g.bools))r=e.slice(1),j(r,H(r));else{if("--"===e){w=n.slice(t+1);break}if(o["halt-at-non-option"]){w=n.slice(t);break}k(e)}}}function k(t){const e=$("_",t);"string"!=typeof e&&"number"!=typeof e||v._.push(e)}function A(t,e,s,n){let i,r=D(e,g.nargs);if(r="number"!=typeof r||isNaN(r)?1:r,0===r)return V(n)||(b=Error(p("Argument unexpected for: %s",e))),j(e,H(e)),t;let a=V(n)?0:1;if(o["nargs-eats-options"])s.length-(t+1)+a<r&&(b=Error(p("Not enough arguments following: %s",e))),a=r;else{for(i=t+1;i<s.length&&(!s[i].match(/^-[^0-9]/)||s[i].match(m)||R(s[i]));i++)a++;a<r&&(b=Error(p("Not enough arguments following: %s",e)))}let c=Math.min(a,r);for(!V(n)&&c>0&&(j(e,n),c--),i=t+1;i<c+t+1;i++)j(e,s[i]);return t+c}function E(t,e,s,n){let r=[],c=n||s[t+1];const l=D(e,g.nargs);if(D(e,g.bools)&&!/^(true|false)$/.test(c))r.push(!0);else if(V(c)||V(n)&&/^-/.test(c)&&!m.test(c)&&!R(c)){if(void 0!==a[e]){const t=a[e];r=Array.isArray(t)?t:[t]}}else{V(n)||r.push(x(e,n,!0));for(let n=t+1;n<s.length&&!(!o["greedy-arrays"]&&r.length>0||l&&"number"==typeof l&&r.length>=l)&&(c=s[n],!/^-/.test(c)||m.test(c)||R(c));n++)t=n,r.push(x(e,c,i))}return"number"==typeof l&&(l&&r.length<l||isNaN(l)&&0===r.length)&&(b=Error(p("Not enough arguments following: %s",e))),j(e,r),t}function j(t,e,s=i){if(/-/.test(t)&&o["camel-case-expansion"]){const e=t.split(".").map((function(t){return z(t)})).join(".");_(t,e)}const n=x(t,e,s),r=t.split(".");if(N(v,r,n),g.aliases[t]&&g.aliases[t].forEach((function(t){const e=t.split(".");N(v,e,n)})),r.length>1&&o["dot-notation"]&&(g.aliases[r[0]]||[]).forEach((function(e){let s=e.split(".");const i=[].concat(r);i.shift(),s=s.concat(i),(g.aliases[t]||[]).includes(s.join("."))||N(v,s,n)})),D(t,g.normalize)&&!D(t,g.arrays)){[t].concat(g.aliases[t]||[]).forEach((function(t){Object.defineProperty(O,t,{enumerable:!0,get:()=>e,set(t){e="string"==typeof t?T.normalize(t):t}})}))}}function _(t,e){g.aliases[t]&&g.aliases[t].length||(g.aliases[t]=[e],u[e]=!0),g.aliases[e]&&g.aliases[e].length||_(e,t)}function x(t,e,s){s&&(e=function(t){return"string"!=typeof t||"'"!==t[0]&&'"'!==t[0]||t[t.length-1]!==t[0]?t:t.substring(1,t.length-1)}(e)),(D(t,g.bools)||D(t,g.counts))&&"string"==typeof e&&(e="true"===e);let n=Array.isArray(e)?e.map((function(e){return $(t,e)})):$(t,e);return D(t,g.counts)&&(V(n)||"boolean"==typeof n)&&(n=U()),D(t,g.normalize)&&D(t,g.arrays)&&(n=Array.isArray(e)?e.map((t=>T.normalize(t))):T.normalize(e)),n}function $(t,e){if(!o["parse-positional-numbers"]&&"_"===t)return e;if(!D(t,g.strings)&&!D(t,g.bools)&&!Array.isArray(e)){(F(e)&&o["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${e}`)))||!V(e)&&D(t,g.numbers))&&(e=Number(e))}return e}function P(t,e){Object.keys(t).forEach((function(s){const n=t[s],i=e?e+"."+s:s;"object"==typeof n&&null!==n&&!Array.isArray(n)&&o["dot-notation"]?P(n,i):(!M(v,i.split("."))||D(i,g.arrays)&&o["combine-arrays"])&&j(i,n)}))}function C(t,e){if(void 0===l)return;const s="string"==typeof l?l:"",n=T.env();Object.keys(n).forEach((function(i){if(""===s||0===i.lastIndexOf(s,0)){const r=i.split("__").map((function(t,e){return 0===e&&(t=t.substring(s.length)),z(t)}));(e&&g.configs[r.join(".")]||!e)&&!M(t,r)&&j(r.join("."),n[i])}}))}function S(t,e,s,n=!1){Object.keys(s).forEach((function(i){M(t,i.split("."))||(N(t,i.split("."),s[i]),n&&(f[i]=!0),(e[i]||[]).forEach((function(e){M(t,e.split("."))||N(t,e.split("."),s[i])})))}))}function M(t,e){let s=t;o["dot-notation"]||(e=[e.join(".")]),e.slice(0,-1).forEach((function(t){s=s[t]||{}}));const n=e[e.length-1];return"object"==typeof s&&n in s}function N(t,e,s){let n=t;o["dot-notation"]||(e=[e.join(".")]),e.slice(0,-1).forEach((function(t){t=B(t),"object"==typeof n&&void 0===n[t]&&(n[t]={}),"object"!=typeof n[t]||Array.isArray(n[t])?(Array.isArray(n[t])?n[t].push({}):n[t]=[n[t],{}],n=n[t][n[t].length-1]):n=n[t]}));const i=B(e[e.length-1]),r=D(e.join("."),g.arrays),a=Array.isArray(s);let c=o["duplicate-arguments-array"];!c&&D(i,g.nargs)&&(c=!0,(!V(n[i])&&1===g.nargs[i]||Array.isArray(n[i])&&n[i].length===g.nargs[i])&&(n[i]=void 0)),s===U()?n[i]=U(n[i]):Array.isArray(n[i])?c&&r&&a?n[i]=o["flatten-duplicate-arrays"]?n[i].concat(s):(Array.isArray(n[i][0])?n[i]:[n[i]]).concat([s]):c||Boolean(r)!==Boolean(a)?n[i]=n[i].concat([s]):n[i]=s:void 0===n[i]&&r?n[i]=a?s:[s]:!c||void 0===n[i]||D(i,g.counts)||D(i,g.bools)?n[i]=s:n[i]=[n[i],s]}function D(t,e){const s=[].concat(g.aliases[t]||[],t),n=Object.keys(e),i=s.find((t=>n.includes(t)));return!!i&&e[i]}function I(t){const e=Object.keys(g);return[].concat(e.map((t=>g[t]))).some((function(e){return Array.isArray(e)?e.includes(t):e[t]}))}function R(t){return o["unknown-options-as-args"]&&function(t){if(t=t.replace(/^-{3,}/,"--"),t.match(m))return!1;if(function(t){if(t.match(m)||!t.match(/^-[^-]+/))return!1;let e,s=!0;const n=t.slice(1).split("");for(let i=0;i<n.length;i++){if(e=t.slice(i+2),!I(n[i])){s=!1;break}if(n[i+1]&&"="===n[i+1]||"-"===e||/[A-Za-z]/.test(n[i])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(e)||n[i+1]&&n[i+1].match(/\W/))break}return s}(t))return!1;return!function(t,...e){return[].concat(...e).some((function(e){const s=t.match(e);return s&&I(s[1])}))}(t,/^-+([^=]+?)=[\s\S]*$/,y,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}(t)}function H(t){return D(t,g.bools)||D(t,g.counts)||!(`${t}`in a)?(e=function(t){let e=L.BOOLEAN;return D(t,g.strings)?e=L.STRING:D(t,g.numbers)?e=L.NUMBER:D(t,g.bools)?e=L.BOOLEAN:D(t,g.arrays)&&(e=L.ARRAY),e}(t),{[L.BOOLEAN]:!0,[L.STRING]:"",[L.NUMBER]:void 0,[L.ARRAY]:[]}[e]):a[t];var e}function V(t){return void 0===t}return C(v,!0),C(v,!1),function(t){const e=Object.create(null);S(e,g.aliases,a),Object.keys(g.configs).forEach((function(s){const n=t[s]||e[s];if(n)try{let t=null;const e=T.resolve(T.cwd(),n),i=g.configs[s];if("function"==typeof i){try{t=i(e)}catch(e){t=e}if(t instanceof Error)return void(b=t)}else t=T.require(e);P(t)}catch(e){"PermissionDenied"===e.name?b=e:t[s]&&(b=Error(p("Invalid JSON config file: %s",n)))}}))}(v),void 0!==c&&c.forEach((function(t){P(t)})),S(v,g.aliases,a,!0),function(t){let e;const s=new Set;Object.keys(t).forEach((function(n){if(!s.has(n)&&(e=D(n,g.coercions),"function"==typeof e))try{const i=$(n,e(t[n]));[].concat(g.aliases[n]||[],n).forEach((e=>{s.add(e),t[e]=i}))}catch(t){b=t}}))}(v),o["set-placeholder-key"]&&function(t){g.keys.forEach((e=>{~e.indexOf(".")||void 0===t[e]&&(t[e]=void 0)}))}(v),Object.keys(g.counts).forEach((function(t){M(v,t.split("."))||j(t,0)})),h&&w.length&&(v[d]=[]),w.forEach((function(t){v[d].push(t)})),o["camel-case-expansion"]&&o["strip-dashed"]&&Object.keys(v).filter((t=>"--"!==t&&t.includes("-"))).forEach((t=>{delete v[t]})),o["strip-aliased"]&&[].concat(...Object.keys(r).map((t=>r[t]))).forEach((t=>{o["camel-case-expansion"]&&t.includes("-")&&delete v[t.split(".").map((t=>z(t))).join(".")],delete v[t]})),{aliases:Object.assign({},g.aliases),argv:Object.assign(O,v),configuration:o,defaulted:Object.assign({},f),error:b,newAliases:Object.assign({},u)}}}({cwd:process.cwd,env:()=>G,format:p,normalize:n,resolve:e,require:t=>{if("undefined"!=typeof require)return require(t);if(t.match(/\.json$/))return JSON.parse(u(t,"utf8"));throw Error("only .json config files are supported in ESM")}}),Q=function(t,e){return K.parse(t.slice(),e).argv};function Z(){return process.versions.electron&&!process.defaultApp?0:1}Q.detailed=function(t,e){return K.parse(t.slice(),e)},Q.camelCase=z,Q.decamelize=W,Q.looksLikeNumber=F;class X extends Error{constructor(t){super(t||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,X)}}var tt={fs:{readFileSync:u,writeFile:f},format:p,resolve:e,exists:t=>{try{return h(t).isFile()}catch(t){return!1}}};let et;class st{constructor(t){t=t||{},this.directory=t.directory||"./locales",this.updateFiles="boolean"!=typeof t.updateFiles||t.updateFiles,this.locale=t.locale||"en",this.fallbackToLanguage="boolean"!=typeof t.fallbackToLanguage||t.fallbackToLanguage,this.cache=Object.create(null),this.writeQueue=[]}__(...t){if("string"!=typeof arguments[0])return this._taggedLiteral(arguments[0],...arguments);const e=t.shift();let s=function(){};return"function"==typeof t[t.length-1]&&(s=t.pop()),s=s||function(){},this.cache[this.locale]||this._readLocaleFile(),!this.cache[this.locale][e]&&this.updateFiles?(this.cache[this.locale][e]=e,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:s})):s(),et.format.apply(et.format,[this.cache[this.locale][e]||e].concat(t))}__n(){const t=Array.prototype.slice.call(arguments),e=t.shift(),s=t.shift(),n=t.shift();let i=function(){};"function"==typeof t[t.length-1]&&(i=t.pop()),this.cache[this.locale]||this._readLocaleFile();let r=1===n?e:s;if(this.cache[this.locale][e]){r=this.cache[this.locale][e][1===n?"one":"other"]}!this.cache[this.locale][e]&&this.updateFiles?(this.cache[this.locale][e]={one:e,other:s},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:i})):i();const o=[r];return~r.indexOf("%d")&&o.push(n),et.format.apply(et.format,o.concat(t))}setLocale(t){this.locale=t}getLocale(){return this.locale}updateLocale(t){this.cache[this.locale]||this._readLocaleFile();for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(this.cache[this.locale][e]=t[e])}_taggedLiteral(t,...e){let s="";return t.forEach((function(t,n){const i=e[n+1];s+=t,void 0!==i&&(s+="%s")})),this.__.apply(this,[s].concat([].slice.call(e,1)))}_enqueueWrite(t){this.writeQueue.push(t),1===this.writeQueue.length&&this._processWriteQueue()}_processWriteQueue(){const t=this,e=this.writeQueue[0],s=e.directory,n=e.locale,i=e.cb,r=this._resolveLocaleFile(s,n),o=JSON.stringify(this.cache[n],null,2);et.fs.writeFile(r,o,"utf-8",(function(e){t.writeQueue.shift(),t.writeQueue.length>0&&t._processWriteQueue(),i(e)}))}_readLocaleFile(){let t={};const e=this._resolveLocaleFile(this.directory,this.locale);try{et.fs.readFileSync&&(t=JSON.parse(et.fs.readFileSync(e,"utf-8")))}catch(s){if(s instanceof SyntaxError&&(s.message="syntax error in "+e),"ENOENT"!==s.code)throw s;t={}}this.cache[this.locale]=t}_resolveLocaleFile(t,e){let s=et.resolve(t,"./",e+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(s)&&~e.lastIndexOf("_")){const n=et.resolve(t,"./",e.split("_")[0]+".json");this._fileExistsSync(n)&&(s=n)}return s}_fileExistsSync(t){return et.exists(t)}}const nt="loading a directory of commands is not supported yet for ESM";let it;try{it=m(import.meta.url)}catch(t){it=process.cwd()}var rt,ot={assert:{notStrictEqual:a,strictEqual:c},cliui:function(t){return function(t,e){return N=e,new S({width:(null==t?void 0:t.width)||("object"==typeof process&&process.stdout&&process.stdout.columns?process.stdout.columns:80),wrap:null==t?void 0:t.wrap})}(t,{stringWidth:t=>[...t].length,stripAnsi:I,wrap:R})},findUp:function(t,n){let i,r=e(".",t);for(h(r).isDirectory()||(r=s(r));;){if(i=n(r,d(r)),i)return e(r,i);if(r=s(i=r),i===r)break}},getEnv:t=>process.env[t],inspect:g,getCallerFile:()=>{throw new X(nt)},getProcessArgvBin:function(){return process.argv[Z()]},mainFilename:it.substring(0,it.lastIndexOf("node_modules"))||process.cwd(),Parser:Q,path:{basename:i,dirname:s,extname:r,relative:o,resolve:e},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(t,e)=>process.emitWarning(t,e),execPath:()=>process.execPath,exit:process.exit,nextTick:process.nextTick,stdColumns:void 0!==process.stdout.columns?process.stdout.columns:null},readFileSync:u,require:()=>{throw new X("require is not supported by ESM")},requireDirectory:()=>{throw new X(nt)},stringWidth:t=>[...t].length,y18n:(rt={directory:e(it,"../../../locales"),updateFiles:!1},function(t,e){et=e;const s=new st(t);return{__:s.__.bind(s),__n:s.__n.bind(s),setLocale:s.setLocale.bind(s),getLocale:s.getLocale.bind(s),updateLocale:s.updateLocale.bind(s),locale:s.locale}}(rt,tt))};function at(t,e,s,n){s.assert.notStrictEqual(t,e,n)}function ct(t,e){e.assert.strictEqual(typeof t,"string")}function lt(t){return Object.keys(t)}function ht(t){return!!t&&!!t.then&&"function"==typeof t.then}function dt(t){const e=t.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),s=/\.*[\][<>]/g,n=e.shift();if(!n)throw new Error(`No command found in: ${t}`);const i={cmd:n.replace(s,""),demanded:[],optional:[]};return e.forEach(((t,n)=>{let r=!1;t=t.replace(/\s/g,""),/\.+[\]>]/.test(t)&&n===e.length-1&&(r=!0),/^\[/.test(t)?i.optional.push({cmd:t.replace(s,"").split("|"),variadic:r}):i.demanded.push({cmd:t.replace(s,"").split("|"),variadic:r})})),i}const ut=["first","second","third","fourth","fifth","sixth"];function ft(t,e,s){try{let n=0;const[i,r,o]="object"==typeof t?[{demanded:[],optional:[]},t,e]:[dt(`cmd ${t}`),e,s],a=[].slice.call(r);for(;a.length&&void 0===a[a.length-1];)a.pop();const c=o||a.length;if(c<i.demanded.length)throw new X(`Not enough arguments provided. Expected ${i.demanded.length} but received ${a.length}.`);const l=i.demanded.length+i.optional.length;if(c>l)throw new X(`Too many arguments provided. Expected max ${l} but received ${c}.`);i.demanded.forEach((t=>{const e=pt(a.shift());0===t.cmd.filter((t=>t===e||"*"===t)).length&&gt(e,t.cmd,n),n+=1})),i.optional.forEach((t=>{if(0===a.length)return;const e=pt(a.shift());0===t.cmd.filter((t=>t===e||"*"===t)).length&&gt(e,t.cmd,n),n+=1}))}catch(t){console.warn(t.stack)}}function pt(t){return Array.isArray(t)?"array":null===t?"null":typeof t}function gt(t,e,s){throw new X(`Invalid ${ut[s]||"manyith"} argument. Expected ${e.join(" or ")} but received ${t}.`)}class mt{constructor(t){this.globalMiddleware=[],this.frozens=[],this.yargs=t}addMiddleware(t,e,s=!0,n=!1){if(ft("<array|function> [boolean] [boolean] [boolean]",[t,e,s],arguments.length),Array.isArray(t)){for(let n=0;n<t.length;n++){if("function"!=typeof t[n])throw Error("middleware must be a function");const i=t[n];i.applyBeforeValidation=e,i.global=s}Array.prototype.push.apply(this.globalMiddleware,t)}else if("function"==typeof t){const i=t;i.applyBeforeValidation=e,i.global=s,i.mutates=n,this.globalMiddleware.push(t)}return this.yargs}addCoerceMiddleware(t,e){const s=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((t=>{const n=[...s[e]||[],e];return!t.option||!n.includes(t.option)})),t.option=e,this.addMiddleware(t,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){const t=this.frozens.pop();void 0!==t&&(this.globalMiddleware=t)}reset(){this.globalMiddleware=this.globalMiddleware.filter((t=>t.global))}}function yt(t,e,s,n){return s.reduce(((t,s)=>{if(s.applyBeforeValidation!==n)return t;if(s.mutates){if(s.applied)return t;s.applied=!0}if(ht(t))return t.then((t=>Promise.all([t,s(t,e)]))).then((([t,e])=>Object.assign(t,e)));{const n=s(t,e);return ht(n)?n.then((e=>Object.assign(t,e))):Object.assign(t,n)}}),t)}function bt(t,e,s=(t=>{throw t})){try{const s="function"==typeof t?t():t;return ht(s)?s.then((t=>e(t))):e(s)}catch(t){return s(t)}}const wt=/(^\*)|(^\$0)/;class vt{constructor(t,e,s,n){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=n,this.usage=t,this.globalMiddleware=s,this.validation=e}addDirectory(t,e,s,n){"boolean"!=typeof(n=n||{}).recurse&&(n.recurse=!1),Array.isArray(n.extensions)||(n.extensions=["js"]);const i="function"==typeof n.visit?n.visit:t=>t;n.visit=(t,e,s)=>{const n=i(t,e,s);if(n){if(this.requireCache.has(e))return n;this.requireCache.add(e),this.addHandler(n)}return n},this.shim.requireDirectory({require:e,filename:s},t,n)}addHandler(t,e,s,n,i,r){let o=[];const a=function(t){return t?t.map((t=>(t.applyBeforeValidation=!1,t))):[]}(i);if(n=n||(()=>{}),Array.isArray(t))if(function(t){return t.every((t=>"string"==typeof t))}(t))[t,...o]=t;else for(const e of t)this.addHandler(e);else{if(function(t){return"object"==typeof t&&!Array.isArray(t)}(t)){let e=Array.isArray(t.command)||"string"==typeof t.command?t.command:this.moduleName(t);return t.aliases&&(e=[].concat(e).concat(t.aliases)),void this.addHandler(e,this.extractDesc(t),t.builder,t.handler,t.middlewares,t.deprecated)}if(Ot(s))return void this.addHandler([t].concat(o),e,s.builder,s.handler,s.middlewares,s.deprecated)}if("string"==typeof t){const i=dt(t);o=o.map((t=>dt(t).cmd));let c=!1;const l=[i.cmd].concat(o).filter((t=>!wt.test(t)||(c=!0,!1)));0===l.length&&c&&l.push("$0"),c&&(i.cmd=l[0],o=l.slice(1),t=t.replace(wt,i.cmd)),o.forEach((t=>{this.aliasMap[t]=i.cmd})),!1!==e&&this.usage.command(t,e,c,o,r),this.handlers[i.cmd]={original:t,description:e,handler:n,builder:s||{},middlewares:a,deprecated:r,demanded:i.demanded,optional:i.optional},c&&(this.defaultCommand=this.handlers[i.cmd])}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(t,e,s,n,i,r){const o=this.handlers[t]||this.handlers[this.aliasMap[t]]||this.defaultCommand,a=e.getInternalMethods().getContext(),c=a.commands.slice(),l=!t;t&&(a.commands.push(t),a.fullCommands.push(o.original));const h=this.applyBuilderUpdateUsageAndParse(l,o,e,s.aliases,c,n,i,r);return ht(h)?h.then((t=>this.applyMiddlewareAndGetResult(l,o,t.innerArgv,a,i,t.aliases,e))):this.applyMiddlewareAndGetResult(l,o,h.innerArgv,a,i,h.aliases,e)}applyBuilderUpdateUsageAndParse(t,e,s,n,i,r,o,a){const c=e.builder;let l=s;if(kt(c)){s.getInternalMethods().getUsageInstance().freeze();const h=c(s.getInternalMethods().reset(n),a);if(ht(h))return h.then((n=>{var a;return l=(a=n)&&"function"==typeof a.getInternalMethods?n:s,this.parseAndUpdateUsage(t,e,l,i,r,o)}))}else(function(t){return"object"==typeof t})(c)&&(s.getInternalMethods().getUsageInstance().freeze(),l=s.getInternalMethods().reset(n),Object.keys(e.builder).forEach((t=>{l.option(t,c[t])})));return this.parseAndUpdateUsage(t,e,l,i,r,o)}parseAndUpdateUsage(t,e,s,n,i,r){t&&s.getInternalMethods().getUsageInstance().unfreeze(!0),this.shouldUpdateUsage(s)&&s.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(n,e),e.description);const o=s.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,i,r);return ht(o)?o.then((t=>({aliases:s.parsed.aliases,innerArgv:t}))):{aliases:s.parsed.aliases,innerArgv:o}}shouldUpdateUsage(t){return!t.getInternalMethods().getUsageInstance().getUsageDisabled()&&0===t.getInternalMethods().getUsageInstance().getUsage().length}usageFromParentCommandsCommandHandler(t,e){const s=wt.test(e.original)?e.original.replace(wt,"").trim():e.original,n=t.filter((t=>!wt.test(t)));return n.push(s),`$0 ${n.join(" ")}`}handleValidationAndGetResult(t,e,s,n,i,r,o,a){if(!r.getInternalMethods().getHasOutput()){const e=r.getInternalMethods().runValidation(i,a,r.parsed.error,t);s=bt(s,(t=>(e(t),t)))}if(e.handler&&!r.getInternalMethods().getHasOutput()){r.getInternalMethods().setHasOutput();const n=!!r.getOptions().configuration["populate--"];r.getInternalMethods().postProcess(s,n,!1,!1),s=bt(s=yt(s,r,o,!1),(t=>{const s=e.handler(t);return ht(s)?s.then((()=>t)):t})),t||r.getInternalMethods().getUsageInstance().cacheHelpMessage(),ht(s)&&!r.getInternalMethods().hasParseCallback()&&s.catch((t=>{try{r.getInternalMethods().getUsageInstance().fail(null,t)}catch(t){}}))}return t||(n.commands.pop(),n.fullCommands.pop()),s}applyMiddlewareAndGetResult(t,e,s,n,i,r,o){let a={};if(i)return s;o.getInternalMethods().getHasOutput()||(a=this.populatePositionals(e,s,n,o));const c=this.globalMiddleware.getMiddleware().slice(0).concat(e.middlewares),l=yt(s,o,c,!0);return ht(l)?l.then((s=>this.handleValidationAndGetResult(t,e,s,n,r,o,c,a))):this.handleValidationAndGetResult(t,e,l,n,r,o,c,a)}populatePositionals(t,e,s,n){e._=e._.slice(s.commands.length);const i=t.demanded.slice(0),r=t.optional.slice(0),o={};for(this.validation.positionalCount(i.length,e._.length);i.length;){const t=i.shift();this.populatePositional(t,e,o)}for(;r.length;){const t=r.shift();this.populatePositional(t,e,o)}return e._=s.commands.concat(e._.map((t=>""+t))),this.postProcessPositionals(e,o,this.cmdToParseOptions(t.original),n),o}populatePositional(t,e,s){const n=t.cmd[0];t.variadic?s[n]=e._.splice(0).map(String):e._.length&&(s[n]=[String(e._.shift())])}cmdToParseOptions(t){const e={array:[],default:{},alias:{},demand:{}},s=dt(t);return s.demanded.forEach((t=>{const[s,...n]=t.cmd;t.variadic&&(e.array.push(s),e.default[s]=[]),e.alias[s]=n,e.demand[s]=!0})),s.optional.forEach((t=>{const[s,...n]=t.cmd;t.variadic&&(e.array.push(s),e.default[s]=[]),e.alias[s]=n})),e}postProcessPositionals(t,e,s,n){const i=Object.assign({},n.getOptions());i.default=Object.assign(s.default,i.default);for(const t of Object.keys(s.alias))i.alias[t]=(i.alias[t]||[]).concat(s.alias[t]);i.array=i.array.concat(s.array),i.config={};const r=[];if(Object.keys(e).forEach((t=>{e[t].map((e=>{i.configuration["unknown-options-as-args"]&&(i.key[t]=!0),r.push(`--${t}`),r.push(e)}))})),!r.length)return;const o=Object.assign({},i.configuration,{"populate--":!1}),a=this.shim.Parser.detailed(r,Object.assign({},i,{configuration:o}));if(a.error)n.getInternalMethods().getUsageInstance().fail(a.error.message,a.error);else{const s=Object.keys(e);Object.keys(e).forEach((t=>{s.push(...a.aliases[t])})),Object.keys(a.argv).forEach((i=>{s.includes(i)&&(e[i]||(e[i]=a.argv[i]),!this.isInConfigs(n,i)&&!this.isDefaulted(n,i)&&Object.prototype.hasOwnProperty.call(t,i)&&Object.prototype.hasOwnProperty.call(a.argv,i)&&(Array.isArray(t[i])||Array.isArray(a.argv[i]))?t[i]=[].concat(t[i],a.argv[i]):t[i]=a.argv[i])}))}}isDefaulted(t,e){const{default:s}=t.getOptions();return Object.prototype.hasOwnProperty.call(s,e)||Object.prototype.hasOwnProperty.call(s,this.shim.Parser.camelCase(e))}isInConfigs(t,e){const{configObjects:s}=t.getOptions();return s.some((t=>Object.prototype.hasOwnProperty.call(t,e)))||s.some((t=>Object.prototype.hasOwnProperty.call(t,this.shim.Parser.camelCase(e))))}runDefaultBuilderOn(t){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(t)){const e=wt.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");t.getInternalMethods().getUsageInstance().usage(e,this.defaultCommand.description)}const e=this.defaultCommand.builder;if(kt(e))return e(t,!0);Ot(e)||Object.keys(e).forEach((s=>{t.option(s,e[s])}))}moduleName(t){const e=function(t){if("undefined"==typeof require)return null;for(let e,s=0,n=Object.keys(require.cache);s<n.length;s++)if(e=require.cache[n[s]],e.exports===t)return e;return null}(t);if(!e)throw new Error(`No command name given for module: ${this.shim.inspect(t)}`);return this.commandFromFilename(e.filename)}commandFromFilename(t){return this.shim.path.basename(t,this.shim.path.extname(t))}extractDesc({describe:t,description:e,desc:s}){for(const n of[t,e,s]){if("string"==typeof n||!1===n)return n;at(n,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){const t=this.frozens.pop();at(t,void 0,this.shim),({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=t)}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function Ot(t){return"object"==typeof t&&!!t.builder&&"function"==typeof t.handler}function kt(t){return"function"==typeof t}function At(t={},e=(()=>!0)){const s={};return lt(t).forEach((n=>{e(n,t[n])&&(s[n]=t[n])})),s}function Et(t){"undefined"!=typeof process&&[process.stdout,process.stderr].forEach((e=>{const s=e;s._handle&&s.isTTY&&"function"==typeof s._handle.setBlocking&&s._handle.setBlocking(t)}))}function jt(t){return"boolean"==typeof t}function _t(t,e){const s=e.y18n.__,n={},i=[];n.failFn=function(t){i.push(t)};let r=null,o=null,a=!0;n.showHelpOnFail=function(e=!0,s){const[i,c]="string"==typeof e?[!0,e]:[e,s];return t.getInternalMethods().isGlobalContext()&&(o=c),r=c,a=i,n};let c=!1;n.fail=function(e,s){const l=t.getInternalMethods().getLoggerInstance();if(!i.length){if(t.getExitProcess()&&Et(!0),!c){c=!0,a&&(t.showHelp("error"),l.error()),(e||s)&&l.error(e||s);const n=r||o;n&&((e||s)&&l.error(""),l.error(n))}if(s=s||new X(e),t.getExitProcess())return t.exit(1);if(t.getInternalMethods().hasParseCallback())return t.exit(1,s);throw s}for(let t=i.length-1;t>=0;--t){const r=i[t];if(jt(r)){if(s)throw s;if(e)throw Error(e)}else r(e,s,n)}};let l=[],h=!1;n.usage=(t,e)=>null===t?(h=!0,l=[],n):(h=!1,l.push([t,e||""]),n),n.getUsage=()=>l,n.getUsageDisabled=()=>h,n.getPositionalGroupName=()=>s("Positionals:");let d=[];n.example=(t,e)=>{d.push([t,e||""])};let u=[];n.command=function(t,e,s,n,i=!1){s&&(u=u.map((t=>(t[2]=!1,t)))),u.push([t,e||"",s,n,i])},n.getCommands=()=>u;let f={};n.describe=function(t,e){Array.isArray(t)?t.forEach((t=>{n.describe(t,e)})):"object"==typeof t?Object.keys(t).forEach((e=>{n.describe(e,t[e])})):f[t]=e},n.getDescriptions=()=>f;let p=[];n.epilog=t=>{p.push(t)};let g,m=!1;n.wrap=t=>{m=!0,g=t},n.getWrap=()=>e.getEnv("YARGS_DISABLE_WRAP")?null:(m||(g=function(){const t=80;return e.process.stdColumns?Math.min(t,e.process.stdColumns):t}(),m=!0),g);const y="__yargsString__:";function b(t,s,n){let i=0;return Array.isArray(t)||(t=Object.values(t).map((t=>[t]))),t.forEach((t=>{i=Math.max(e.stringWidth(n?`${n} ${Pt(t[0])}`:Pt(t[0]))+$t(t[0]),i)})),s&&(i=Math.min(i,parseInt((.5*s).toString(),10))),i}let w;function v(e){return t.getOptions().hiddenOptions.indexOf(e)<0||t.parsed.argv[t.getOptions().showHiddenOpt]}function O(t,e){let n=`[${s("default:")} `;if(void 0===t&&!e)return null;if(e)n+=e;else switch(typeof t){case"string":n+=`"${t}"`;break;case"object":n+=JSON.stringify(t);break;default:n+=t}return`${n}]`}n.deferY18nLookup=t=>y+t,n.help=function(){if(w)return w;!function(){const e=t.getDemandedOptions(),s=t.getOptions();(Object.keys(s.alias)||[]).forEach((i=>{s.alias[i].forEach((r=>{f[r]&&n.describe(i,f[r]),r in e&&t.demandOption(i,e[r]),s.boolean.includes(r)&&t.boolean(i),s.count.includes(r)&&t.count(i),s.string.includes(r)&&t.string(i),s.normalize.includes(r)&&t.normalize(i),s.array.includes(r)&&t.array(i),s.number.includes(r)&&t.number(i)}))}))}();const i=t.customScriptName?t.$0:e.path.basename(t.$0),r=t.getDemandedOptions(),o=t.getDemandedCommands(),a=t.getDeprecatedOptions(),c=t.getGroups(),g=t.getOptions();let m=[];m=m.concat(Object.keys(f)),m=m.concat(Object.keys(r)),m=m.concat(Object.keys(o)),m=m.concat(Object.keys(g.default)),m=m.filter(v),m=Object.keys(m.reduce(((t,e)=>("_"!==e&&(t[e]=!0),t)),{}));const k=n.getWrap(),A=e.cliui({width:k,wrap:!!k});if(!h)if(l.length)l.forEach((t=>{A.div({text:`${t[0].replace(/\$0/g,i)}`}),t[1]&&A.div({text:`${t[1]}`,padding:[1,0,0,0]})})),A.div();else if(u.length){let t=null;t=o._?`${i} <${s("command")}>\n`:`${i} [${s("command")}]\n`,A.div(`${t}`)}if(u.length>1||1===u.length&&!u[0][2]){A.div(s("Commands:"));const e=t.getInternalMethods().getContext(),n=e.commands.length?`${e.commands.join(" ")} `:"";!0===t.getInternalMethods().getParserConfiguration()["sort-commands"]&&(u=u.sort(((t,e)=>t[0].localeCompare(e[0]))));const r=i?`${i} `:"";u.forEach((t=>{const e=`${r}${n}${t[0].replace(/^\$0 ?/,"")}`;A.span({text:e,padding:[0,2,0,2],width:b(u,k,`${i}${n}`)+4},{text:t[1]});const o=[];t[2]&&o.push(`[${s("default")}]`),t[3]&&t[3].length&&o.push(`[${s("aliases:")} ${t[3].join(", ")}]`),t[4]&&("string"==typeof t[4]?o.push(`[${s("deprecated: %s",t[4])}]`):o.push(`[${s("deprecated")}]`)),o.length?A.div({text:o.join(" "),padding:[0,0,0,2],align:"right"}):A.div()})),A.div()}const E=(Object.keys(g.alias)||[]).concat(Object.keys(t.parsed.newAliases)||[]);m=m.filter((e=>!t.parsed.newAliases[e]&&E.every((t=>-1===(g.alias[t]||[]).indexOf(e)))));const j=s("Options:");c[j]||(c[j]=[]),function(t,e,s,n){let i=[],r=null;Object.keys(s).forEach((t=>{i=i.concat(s[t])})),t.forEach((t=>{r=[t].concat(e[t]),r.some((t=>-1!==i.indexOf(t)))||s[n].push(t)}))}(m,g.alias,c,j);const _=t=>/^--/.test(Pt(t)),x=Object.keys(c).filter((t=>c[t].length>0)).map((t=>({groupName:t,normalizedKeys:c[t].filter(v).map((t=>{if(E.includes(t))return t;for(let e,s=0;void 0!==(e=E[s]);s++)if((g.alias[e]||[]).includes(t))return e;return t}))}))).filter((({normalizedKeys:t})=>t.length>0)).map((({groupName:t,normalizedKeys:e})=>{const s=e.reduce(((e,s)=>(e[s]=[s].concat(g.alias[s]||[]).map((e=>t===n.getPositionalGroupName()?e:(/^[0-9]$/.test(e)?g.boolean.includes(s)?"-":"--":e.length>1?"--":"-")+e)).sort(((t,e)=>_(t)===_(e)?0:_(t)?1:-1)).join(", "),e)),{});return{groupName:t,normalizedKeys:e,switches:s}}));if(x.filter((({groupName:t})=>t!==n.getPositionalGroupName())).some((({normalizedKeys:t,switches:e})=>!t.every((t=>_(e[t])))))&&x.filter((({groupName:t})=>t!==n.getPositionalGroupName())).forEach((({normalizedKeys:t,switches:e})=>{t.forEach((t=>{var s,n;_(e[t])&&(e[t]=(s=e[t],n=4,xt(s)?{text:s.text,indentation:s.indentation+n}:{text:s,indentation:n}))}))})),x.forEach((({groupName:e,normalizedKeys:i,switches:o})=>{A.div(e),i.forEach((e=>{const i=o[e];let c=f[e]||"",l=null;c.includes(y)&&(c=s(c.substring(16))),g.boolean.includes(e)&&(l=`[${s("boolean")}]`),g.count.includes(e)&&(l=`[${s("count")}]`),g.string.includes(e)&&(l=`[${s("string")}]`),g.normalize.includes(e)&&(l=`[${s("string")}]`),g.array.includes(e)&&(l=`[${s("array")}]`),g.number.includes(e)&&(l=`[${s("number")}]`);const h=[e in a?(d=a[e],"string"==typeof d?`[${s("deprecated: %s",d)}]`:`[${s("deprecated")}]`):null,l,e in r?`[${s("required")}]`:null,g.choices&&g.choices[e]?`[${s("choices:")} ${n.stringifiedValues(g.choices[e])}]`:null,O(g.default[e],g.defaultDescription[e])].filter(Boolean).join(" ");var d;A.span({text:Pt(i),padding:[0,2,0,2+$t(i)],width:b(o,k)+4},c);const u=!0===t.getInternalMethods().getUsageConfiguration()["hide-types"];h&&!u?A.div({text:h,padding:[0,0,0,2],align:"right"}):A.div()})),A.div()})),d.length&&(A.div(s("Examples:")),d.forEach((t=>{t[0]=t[0].replace(/\$0/g,i)})),d.forEach((t=>{""===t[1]?A.div({text:t[0],padding:[0,2,0,2]}):A.div({text:t[0],padding:[0,2,0,2],width:b(d,k)+4},{text:t[1]})})),A.div()),p.length>0){const t=p.map((t=>t.replace(/\$0/g,i))).join("\n");A.div(`${t}\n`)}return A.toString().replace(/\s*$/,"")},n.cacheHelpMessage=function(){w=this.help()},n.clearCachedHelpMessage=function(){w=void 0},n.hasCachedHelpMessage=function(){return!!w},n.showHelp=e=>{const s=t.getInternalMethods().getLoggerInstance();e||(e="error");("function"==typeof e?e:s[e])(n.help())},n.functionDescription=t=>["(",t.name?e.Parser.decamelize(t.name,"-"):s("generated-value"),")"].join(""),n.stringifiedValues=function(t,e){let s="";const n=e||", ",i=[].concat(t);return t&&i.length?(i.forEach((t=>{s.length&&(s+=n),s+=JSON.stringify(t)})),s):s};let k=null;n.version=t=>{k=t},n.showVersion=e=>{const s=t.getInternalMethods().getLoggerInstance();e||(e="error");("function"==typeof e?e:s[e])(k)},n.reset=function(t){return r=null,c=!1,l=[],h=!1,p=[],d=[],u=[],f=At(f,(e=>!t[e])),n};const A=[];return n.freeze=function(){A.push({failMessage:r,failureOutput:c,usages:l,usageDisabled:h,epilogs:p,examples:d,commands:u,descriptions:f})},n.unfreeze=function(t=!1){const e=A.pop();e&&(t?(f={...e.descriptions,...f},u=[...e.commands,...u],l=[...e.usages,...l],d=[...e.examples,...d],p=[...e.epilogs,...p]):({failMessage:r,failureOutput:c,usages:l,usageDisabled:h,epilogs:p,examples:d,commands:u,descriptions:f}=e))},n}function xt(t){return"object"==typeof t}function $t(t){return xt(t)?t.indentation:0}function Pt(t){return xt(t)?t.text:t}class Ct{constructor(t,e,s,n){var i,r,o;this.yargs=t,this.usage=e,this.command=s,this.shim=n,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=null!==(o=(null===(i=this.shim.getEnv("SHELL"))||void 0===i?void 0:i.includes("zsh"))||(null===(r=this.shim.getEnv("ZSH_NAME"))||void 0===r?void 0:r.includes("zsh")))&&void 0!==o&&o}defaultCompletion(t,e,s,n){const i=this.command.getCommandHandlers();for(let e=0,s=t.length;e<s;++e)if(i[t[e]]&&i[t[e]].builder){const s=i[t[e]].builder;if(kt(s)){this.indexAfterLastReset=e+1;const t=this.yargs.getInternalMethods().reset();return s(t,!0),t.argv}}const r=[];this.commandCompletions(r,t,s),this.optionCompletions(r,t,e,s),this.choicesFromOptionsCompletions(r,t,e,s),this.choicesFromPositionalsCompletions(r,t,e,s),n(null,r)}commandCompletions(t,e,s){const n=this.yargs.getInternalMethods().getContext().commands;s.match(/^-/)||n[n.length-1]===s||this.previousArgHasChoices(e)||this.usage.getCommands().forEach((s=>{const n=dt(s[0]).cmd;if(-1===e.indexOf(n))if(this.zshShell){const e=s[1]||"";t.push(n.replace(/:/g,"\\:")+":"+e)}else t.push(n)}))}optionCompletions(t,e,s,n){if((n.match(/^-/)||""===n&&0===t.length)&&!this.previousArgHasChoices(e)){const s=this.yargs.getOptions(),i=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(s.key).forEach((r=>{const o=!!s.configuration["boolean-negation"]&&s.boolean.includes(r);i.includes(r)||s.hiddenOptions.includes(r)||this.argsContainKey(e,r,o)||this.completeOptionKey(r,t,n,o&&!!s.default[r])}))}}choicesFromOptionsCompletions(t,e,s,n){if(this.previousArgHasChoices(e)){const s=this.getPreviousArgChoices(e);s&&s.length>0&&t.push(...s.map((t=>t.replace(/:/g,"\\:"))))}}choicesFromPositionalsCompletions(t,e,s,n){if(""===n&&t.length>0&&this.previousArgHasChoices(e))return;const i=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],r=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),o=i[s._.length-r-1];if(!o)return;const a=this.yargs.getOptions().choices[o]||[];for(const e of a)e.startsWith(n)&&t.push(e.replace(/:/g,"\\:"))}getPreviousArgChoices(t){if(t.length<1)return;let e=t[t.length-1],s="";if(!e.startsWith("-")&&t.length>1&&(s=e,e=t[t.length-2]),!e.startsWith("-"))return;const n=e.replace(/^-+/,""),i=this.yargs.getOptions(),r=[n,...this.yargs.getAliases()[n]||[]];let o;for(const t of r)if(Object.prototype.hasOwnProperty.call(i.key,t)&&Array.isArray(i.choices[t])){o=i.choices[t];break}return o?o.filter((t=>!s||t.startsWith(s))):void 0}previousArgHasChoices(t){const e=this.getPreviousArgChoices(t);return void 0!==e&&e.length>0}argsContainKey(t,e,s){const n=e=>-1!==t.indexOf((/^[^0-9]$/.test(e)?"-":"--")+e);if(n(e))return!0;if(s&&n(`no-${e}`))return!0;if(this.aliases)for(const t of this.aliases[e])if(n(t))return!0;return!1}completeOptionKey(t,e,s,n){var i,r,o,a;let c=t;if(this.zshShell){const e=this.usage.getDescriptions(),s=null===(r=null===(i=null==this?void 0:this.aliases)||void 0===i?void 0:i[t])||void 0===r?void 0:r.find((t=>{const s=e[t];return"string"==typeof s&&s.length>0})),n=s?e[s]:void 0,l=null!==(a=null!==(o=e[t])&&void 0!==o?o:n)&&void 0!==a?a:"";c=`${t.replace(/:/g,"\\:")}:${l.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}const l=!/^--/.test(s)&&(t=>/^[^0-9]$/.test(t))(t)?"-":"--";e.push(l+c),n&&e.push(l+"no-"+c)}customCompletion(t,e,s,n){if(at(this.customCompletionFunction,null,this.shim),this.customCompletionFunction.length<3){const t=this.customCompletionFunction(s,e);return ht(t)?t.then((t=>{this.shim.process.nextTick((()=>{n(null,t)}))})).catch((t=>{this.shim.process.nextTick((()=>{n(t,void 0)}))})):n(null,t)}return function(t){return t.length>3}(this.customCompletionFunction)?this.customCompletionFunction(s,e,((i=n)=>this.defaultCompletion(t,e,s,i)),(t=>{n(null,t)})):this.customCompletionFunction(s,e,(t=>{n(null,t)}))}getCompletion(t,e){const s=t.length?t[t.length-1]:"",n=this.yargs.parse(t,!0),i=this.customCompletionFunction?n=>this.customCompletion(t,n,s,e):n=>this.defaultCompletion(t,n,s,e);return ht(n)?n.then(i):i(n)}generateCompletionScript(t,e){let s=this.zshShell?'#compdef {{app_name}}\n###-begin-{{app_name}}-completions-###\n#\n# yargs command completion script\n#\n# Installation: {{app_path}} {{completion_command}} >> ~/.zshrc\n# or {{app_path}} {{completion_command}} >> ~/.zprofile on OSX.\n#\n_{{app_name}}_yargs_completions()\n{\n local reply\n local si=$IFS\n IFS=$\'\n\' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" {{app_path}} --get-yargs-completions "${words[@]}"))\n IFS=$si\n _describe \'values\' reply\n}\ncompdef _{{app_name}}_yargs_completions {{app_name}}\n###-end-{{app_name}}-completions-###\n':'###-begin-{{app_name}}-completions-###\n#\n# yargs command completion script\n#\n# Installation: {{app_path}} {{completion_command}} >> ~/.bashrc\n# or {{app_path}} {{completion_command}} >> ~/.bash_profile on OSX.\n#\n_{{app_name}}_yargs_completions()\n{\n local cur_word args type_list\n\n cur_word="${COMP_WORDS[COMP_CWORD]}"\n args=("${COMP_WORDS[@]}")\n\n # ask yargs to generate completions.\n type_list=$({{app_path}} --get-yargs-completions "${args[@]}")\n\n COMPREPLY=( $(compgen -W "${type_list}" -- ${cur_word}) )\n\n # if no match was found, fall back to filename completion\n if [ ${#COMPREPLY[@]} -eq 0 ]; then\n COMPREPLY=()\n fi\n\n return 0\n}\ncomplete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name}}\n###-end-{{app_name}}-completions-###\n';const n=this.shim.path.basename(t);return t.match(/\.js$/)&&(t=`./${t}`),s=s.replace(/{{app_name}}/g,n),s=s.replace(/{{completion_command}}/g,e),s.replace(/{{app_path}}/g,t)}registerFunction(t){this.customCompletionFunction=t}setParsed(t){this.aliases=t.aliases}}function St(t,e){if(0===t.length)return e.length;if(0===e.length)return t.length;const s=[];let n,i;for(n=0;n<=e.length;n++)s[n]=[n];for(i=0;i<=t.length;i++)s[0][i]=i;for(n=1;n<=e.length;n++)for(i=1;i<=t.length;i++)e.charAt(n-1)===t.charAt(i-1)?s[n][i]=s[n-1][i-1]:n>1&&i>1&&e.charAt(n-2)===t.charAt(i-1)&&e.charAt(n-1)===t.charAt(i-2)?s[n][i]=s[n-2][i-2]+1:s[n][i]=Math.min(s[n-1][i-1]+1,Math.min(s[n][i-1]+1,s[n-1][i]+1));return s[e.length][t.length]}const Mt=["$0","--","_"];let Nt,Dt=[];function It(t,e,s,n){Nt=n;let i={};if(Object.prototype.hasOwnProperty.call(t,"extends")){if("string"!=typeof t.extends)return i;const n=/\.json|\..*rc$/.test(t.extends);let r=null;if(n)r=function(t,e){return Nt.path.resolve(t,e)}(e,t.extends);else try{r=require.resolve(t.extends)}catch(e){return t}!function(t){if(Dt.indexOf(t)>-1)throw new X(`Circular extended configurations: '${t}'.`)}(r),Dt.push(r),i=n?JSON.parse(Nt.readFileSync(r,"utf8")):require(t.extends),delete t.extends,i=It(i,Nt.path.dirname(r),s,Nt)}return Dt=[],s?Rt(i,t):Object.assign({},i,t)}function Rt(t,e){const s={};function n(t){return t&&"object"==typeof t&&!Array.isArray(t)}Object.assign(s,t);for(const i of Object.keys(e))n(e[i])&&n(s[i])?s[i]=Rt(t[i],e[i]):s[i]=e[i];return s}var zt,Wt,Ft,Lt,Tt,Ut,Bt,Ht,Vt,qt,Yt,Jt,Gt,Kt,Qt,Zt,Xt,te,ee,se,ne,ie,re,oe,ae,ce,le,he,de,ue,fe,pe,ge,me,ye,be=function(t,e,s,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(t,s):i?i.value=s:e.set(t,s),s},we=function(t,e,s,n){if("a"===s&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?n:"a"===s?n.call(t):n?n.value:e.get(t)};const ve=Symbol("copyDoubleDash"),Oe=Symbol("copyDoubleDash"),ke=Symbol("deleteFromParserHintObject"),Ae=Symbol("emitWarning"),Ee=Symbol("freeze"),je=Symbol("getDollarZero"),_e=Symbol("getParserConfiguration"),xe=Symbol("getUsageConfiguration"),$e=Symbol("guessLocale"),Pe=Symbol("guessVersion"),Ce=Symbol("parsePositionalNumbers"),Se=Symbol("pkgUp"),Me=Symbol("populateParserHintArray"),Ne=Symbol("populateParserHintSingleValueDictionary"),De=Symbol("populateParserHintArrayDictionary"),Ie=Symbol("populateParserHintDictionary"),Re=Symbol("sanitizeKey"),ze=Symbol("setKey"),We=Symbol("unfreeze"),Fe=Symbol("validateAsync"),Le=Symbol("getCommandInstance"),Te=Symbol("getContext"),Ue=Symbol("getHasOutput"),Be=Symbol("getLoggerInstance"),He=Symbol("getParseContext"),Ve=Symbol("getUsageInstance"),qe=Symbol("getValidationInstance"),Ye=Symbol("hasParseCallback"),Je=Symbol("isGlobalContext"),Ge=Symbol("postProcess"),Ke=Symbol("rebase"),Qe=Symbol("reset"),Ze=Symbol("runYargsParserAndExecuteCommands"),Xe=Symbol("runValidation"),ts=Symbol("setHasOutput"),es=Symbol("kTrackManuallySetKeys");class ss{constructor(t=[],e,s,n){this.customScriptName=!1,this.parsed=!1,zt.set(this,void 0),Wt.set(this,void 0),Ft.set(this,{commands:[],fullCommands:[]}),Lt.set(this,null),Tt.set(this,null),Ut.set(this,"show-hidden"),Bt.set(this,null),Ht.set(this,!0),Vt.set(this,{}),qt.set(this,!0),Yt.set(this,[]),Jt.set(this,void 0),Gt.set(this,{}),Kt.set(this,!1),Qt.set(this,null),Zt.set(this,!0),Xt.set(this,void 0),te.set(this,""),ee.set(this,void 0),se.set(this,void 0),ne.set(this,{}),ie.set(this,null),re.set(this,null),oe.set(this,{}),ae.set(this,{}),ce.set(this,void 0),le.set(this,!1),he.set(this,void 0),de.set(this,!1),ue.set(this,!1),fe.set(this,!1),pe.set(this,void 0),ge.set(this,{}),me.set(this,null),ye.set(this,void 0),be(this,he,n,"f"),be(this,ce,t,"f"),be(this,Wt,e,"f"),be(this,se,s,"f"),be(this,Jt,new mt(this),"f"),this.$0=this[je](),this[Qe](),be(this,zt,we(this,zt,"f"),"f"),be(this,pe,we(this,pe,"f"),"f"),be(this,ye,we(this,ye,"f"),"f"),be(this,ee,we(this,ee,"f"),"f"),we(this,ee,"f").showHiddenOpt=we(this,Ut,"f"),be(this,Xt,this[Oe](),"f")}addHelpOpt(t,e){return ft("[string|boolean] [string]",[t,e],arguments.length),we(this,Qt,"f")&&(this[ke](we(this,Qt,"f")),be(this,Qt,null,"f")),!1===t&&void 0===e||(be(this,Qt,"string"==typeof t?t:"help","f"),this.boolean(we(this,Qt,"f")),this.describe(we(this,Qt,"f"),e||we(this,pe,"f").deferY18nLookup("Show help"))),this}help(t,e){return this.addHelpOpt(t,e)}addShowHiddenOpt(t,e){if(ft("[string|boolean] [string]",[t,e],arguments.length),!1===t&&void 0===e)return this;const s="string"==typeof t?t:we(this,Ut,"f");return this.boolean(s),this.describe(s,e||we(this,pe,"f").deferY18nLookup("Show hidden options")),we(this,ee,"f").showHiddenOpt=s,this}showHidden(t,e){return this.addShowHiddenOpt(t,e)}alias(t,e){return ft("<object|string|array> [string|array]",[t,e],arguments.length),this[De](this.alias.bind(this),"alias",t,e),this}array(t){return ft("<array|string>",[t],arguments.length),this[Me]("array",t),this[es](t),this}boolean(t){return ft("<array|string>",[t],arguments.length),this[Me]("boolean",t),this[es](t),this}check(t,e){return ft("<function> [boolean]",[t,e],arguments.length),this.middleware(((e,s)=>bt((()=>t(e,s.getOptions())),(s=>(s?("string"==typeof s||s instanceof Error)&&we(this,pe,"f").fail(s.toString(),s):we(this,pe,"f").fail(we(this,he,"f").y18n.__("Argument check failed: %s",t.toString())),e)),(t=>(we(this,pe,"f").fail(t.message?t.message:t.toString(),t),e)))),!1,e),this}choices(t,e){return ft("<object|string|array> [string|array]",[t,e],arguments.length),this[De](this.choices.bind(this),"choices",t,e),this}coerce(t,e){if(ft("<object|string|array> [function]",[t,e],arguments.length),Array.isArray(t)){if(!e)throw new X("coerce callback must be provided");for(const s of t)this.coerce(s,e);return this}if("object"==typeof t){for(const e of Object.keys(t))this.coerce(e,t[e]);return this}if(!e)throw new X("coerce callback must be provided");return we(this,ee,"f").key[t]=!0,we(this,Jt,"f").addCoerceMiddleware(((s,n)=>{let i;return Object.prototype.hasOwnProperty.call(s,t)?bt((()=>(i=n.getAliases(),e(s[t]))),(e=>{s[t]=e;const r=n.getInternalMethods().getParserConfiguration()["strip-aliased"];if(i[t]&&!0!==r)for(const n of i[t])s[n]=e;return s}),(t=>{throw new X(t.message)})):s}),t),this}conflicts(t,e){return ft("<string|object> [string|array]",[t,e],arguments.length),we(this,ye,"f").conflicts(t,e),this}config(t="config",e,s){return ft("[object|string] [string|function] [function]",[t,e,s],arguments.length),"object"!=typeof t||Array.isArray(t)?("function"==typeof e&&(s=e,e=void 0),this.describe(t,e||we(this,pe,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(t)?t:[t]).forEach((t=>{we(this,ee,"f").config[t]=s||!0})),this):(t=It(t,we(this,Wt,"f"),this[_e]()["deep-merge-config"]||!1,we(this,he,"f")),we(this,ee,"f").configObjects=(we(this,ee,"f").configObjects||[]).concat(t),this)}completion(t,e,s){return ft("[string] [string|boolean|function] [function]",[t,e,s],arguments.length),"function"==typeof e&&(s=e,e=void 0),be(this,Tt,t||we(this,Tt,"f")||"completion","f"),e||!1===e||(e="generate completion script"),this.command(we(this,Tt,"f"),e),s&&we(this,Lt,"f").registerFunction(s),this}command(t,e,s,n,i,r){return ft("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[t,e,s,n,i,r],arguments.length),we(this,zt,"f").addHandler(t,e,s,n,i,r),this}commands(t,e,s,n,i,r){return this.command(t,e,s,n,i,r)}commandDir(t,e){ft("<string> [object]",[t,e],arguments.length);const s=we(this,se,"f")||we(this,he,"f").require;return we(this,zt,"f").addDirectory(t,s,we(this,he,"f").getCallerFile(),e),this}count(t){return ft("<array|string>",[t],arguments.length),this[Me]("count",t),this[es](t),this}default(t,e,s){return ft("<object|string|array> [*] [string]",[t,e,s],arguments.length),s&&(ct(t,we(this,he,"f")),we(this,ee,"f").defaultDescription[t]=s),"function"==typeof e&&(ct(t,we(this,he,"f")),we(this,ee,"f").defaultDescription[t]||(we(this,ee,"f").defaultDescription[t]=we(this,pe,"f").functionDescription(e)),e=e.call()),this[Ne](this.default.bind(this),"default",t,e),this}defaults(t,e,s){return this.default(t,e,s)}demandCommand(t=1,e,s,n){return ft("[number] [number|string] [string|null|undefined] [string|null|undefined]",[t,e,s,n],arguments.length),"number"!=typeof e&&(s=e,e=1/0),this.global("_",!1),we(this,ee,"f").demandedCommands._={min:t,max:e,minMsg:s,maxMsg:n},this}demand(t,e,s){return Array.isArray(e)?(e.forEach((t=>{at(s,!0,we(this,he,"f")),this.demandOption(t,s)})),e=1/0):"number"!=typeof e&&(s=e,e=1/0),"number"==typeof t?(at(s,!0,we(this,he,"f")),this.demandCommand(t,e,s,s)):Array.isArray(t)?t.forEach((t=>{at(s,!0,we(this,he,"f")),this.demandOption(t,s)})):"string"==typeof s?this.demandOption(t,s):!0!==s&&void 0!==s||this.demandOption(t),this}demandOption(t,e){return ft("<object|string|array> [string]",[t,e],arguments.length),this[Ne](this.demandOption.bind(this),"demandedOptions",t,e),this}deprecateOption(t,e){return ft("<string> [string|boolean]",[t,e],arguments.length),we(this,ee,"f").deprecatedOptions[t]=e,this}describe(t,e){return ft("<object|string|array> [string]",[t,e],arguments.length),this[ze](t,!0),we(this,pe,"f").describe(t,e),this}detectLocale(t){return ft("<boolean>",[t],arguments.length),be(this,Ht,t,"f"),this}env(t){return ft("[string|boolean]",[t],arguments.length),!1===t?delete we(this,ee,"f").envPrefix:we(this,ee,"f").envPrefix=t||"",this}epilogue(t){return ft("<string>",[t],arguments.length),we(this,pe,"f").epilog(t),this}epilog(t){return this.epilogue(t)}example(t,e){return ft("<string|array> [string]",[t,e],arguments.length),Array.isArray(t)?t.forEach((t=>this.example(...t))):we(this,pe,"f").example(t,e),this}exit(t,e){be(this,Kt,!0,"f"),be(this,Bt,e,"f"),we(this,qt,"f")&&we(this,he,"f").process.exit(t)}exitProcess(t=!0){return ft("[boolean]",[t],arguments.length),be(this,qt,t,"f"),this}fail(t){if(ft("<function|boolean>",[t],arguments.length),"boolean"==typeof t&&!1!==t)throw new X("Invalid first argument. Expected function or boolean 'false'");return we(this,pe,"f").failFn(t),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(t,e){return ft("<array> [function]",[t,e],arguments.length),e?we(this,Lt,"f").getCompletion(t,e):new Promise(((e,s)=>{we(this,Lt,"f").getCompletion(t,((t,n)=>{t?s(t):e(n)}))}))}getDemandedOptions(){return ft([],0),we(this,ee,"f").demandedOptions}getDemandedCommands(){return ft([],0),we(this,ee,"f").demandedCommands}getDeprecatedOptions(){return ft([],0),we(this,ee,"f").deprecatedOptions}getDetectLocale(){return we(this,Ht,"f")}getExitProcess(){return we(this,qt,"f")}getGroups(){return Object.assign({},we(this,Gt,"f"),we(this,ae,"f"))}getHelp(){if(be(this,Kt,!0,"f"),!we(this,pe,"f").hasCachedHelpMessage()){if(!this.parsed){const t=this[Ze](we(this,ce,"f"),void 0,void 0,0,!0);if(ht(t))return t.then((()=>we(this,pe,"f").help()))}const t=we(this,zt,"f").runDefaultBuilderOn(this);if(ht(t))return t.then((()=>we(this,pe,"f").help()))}return Promise.resolve(we(this,pe,"f").help())}getOptions(){return we(this,ee,"f")}getStrict(){return we(this,de,"f")}getStrictCommands(){return we(this,ue,"f")}getStrictOptions(){return we(this,fe,"f")}global(t,e){return ft("<string|array> [boolean]",[t,e],arguments.length),t=[].concat(t),!1!==e?we(this,ee,"f").local=we(this,ee,"f").local.filter((e=>-1===t.indexOf(e))):t.forEach((t=>{we(this,ee,"f").local.includes(t)||we(this,ee,"f").local.push(t)})),this}group(t,e){ft("<string|array> <string>",[t,e],arguments.length);const s=we(this,ae,"f")[e]||we(this,Gt,"f")[e];we(this,ae,"f")[e]&&delete we(this,ae,"f")[e];const n={};return we(this,Gt,"f")[e]=(s||[]).concat(t).filter((t=>!n[t]&&(n[t]=!0))),this}hide(t){return ft("<string>",[t],arguments.length),we(this,ee,"f").hiddenOptions.push(t),this}implies(t,e){return ft("<string|object> [number|string|array]",[t,e],arguments.length),we(this,ye,"f").implies(t,e),this}locale(t){return ft("[string]",[t],arguments.length),void 0===t?(this[$e](),we(this,he,"f").y18n.getLocale()):(be(this,Ht,!1,"f"),we(this,he,"f").y18n.setLocale(t),this)}middleware(t,e,s){return we(this,Jt,"f").addMiddleware(t,!!e,s)}nargs(t,e){return ft("<string|object|array> [number]",[t,e],arguments.length),this[Ne](this.nargs.bind(this),"narg",t,e),this}normalize(t){return ft("<array|string>",[t],arguments.length),this[Me]("normalize",t),this}number(t){return ft("<array|string>",[t],arguments.length),this[Me]("number",t),this[es](t),this}option(t,e){if(ft("<string|object> [object]",[t,e],arguments.length),"object"==typeof t)Object.keys(t).forEach((e=>{this.options(e,t[e])}));else{"object"!=typeof e&&(e={}),this[es](t),!we(this,me,"f")||"version"!==t&&"version"!==(null==e?void 0:e.alias)||this[Ae](['"version" is a reserved word.',"Please do one of the following:",'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)","- Use a different option key","https://yargs.js.org/docs/#api-reference-version"].join("\n"),void 0,"versionWarning"),we(this,ee,"f").key[t]=!0,e.alias&&this.alias(t,e.alias);const s=e.deprecate||e.deprecated;s&&this.deprecateOption(t,s);const n=e.demand||e.required||e.require;n&&this.demand(t,n),e.demandOption&&this.demandOption(t,"string"==typeof e.demandOption?e.demandOption:void 0),e.conflicts&&this.conflicts(t,e.conflicts),"default"in e&&this.default(t,e.default),void 0!==e.implies&&this.implies(t,e.implies),void 0!==e.nargs&&this.nargs(t,e.nargs),e.config&&this.config(t,e.configParser),e.normalize&&this.normalize(t),e.choices&&this.choices(t,e.choices),e.coerce&&this.coerce(t,e.coerce),e.group&&this.group(t,e.group),(e.boolean||"boolean"===e.type)&&(this.boolean(t),e.alias&&this.boolean(e.alias)),(e.array||"array"===e.type)&&(this.array(t),e.alias&&this.array(e.alias)),(e.number||"number"===e.type)&&(this.number(t),e.alias&&this.number(e.alias)),(e.string||"string"===e.type)&&(this.string(t),e.alias&&this.string(e.alias)),(e.count||"count"===e.type)&&this.count(t),"boolean"==typeof e.global&&this.global(t,e.global),e.defaultDescription&&(we(this,ee,"f").defaultDescription[t]=e.defaultDescription),e.skipValidation&&this.skipValidation(t);const i=e.describe||e.description||e.desc,r=we(this,pe,"f").getDescriptions();Object.prototype.hasOwnProperty.call(r,t)&&"string"!=typeof i||this.describe(t,i),e.hidden&&this.hide(t),e.requiresArg&&this.requiresArg(t)}return this}options(t,e){return this.option(t,e)}parse(t,e,s){ft("[string|array] [function|boolean|object] [function]",[t,e,s],arguments.length),this[Ee](),void 0===t&&(t=we(this,ce,"f")),"object"==typeof e&&(be(this,re,e,"f"),e=s),"function"==typeof e&&(be(this,ie,e,"f"),e=!1),e||be(this,ce,t,"f"),we(this,ie,"f")&&be(this,qt,!1,"f");const n=this[Ze](t,!!e),i=this.parsed;return we(this,Lt,"f").setParsed(this.parsed),ht(n)?n.then((t=>(we(this,ie,"f")&&we(this,ie,"f").call(this,we(this,Bt,"f"),t,we(this,te,"f")),t))).catch((t=>{throw we(this,ie,"f")&&we(this,ie,"f")(t,this.parsed.argv,we(this,te,"f")),t})).finally((()=>{this[We](),this.parsed=i})):(we(this,ie,"f")&&we(this,ie,"f").call(this,we(this,Bt,"f"),n,we(this,te,"f")),this[We](),this.parsed=i,n)}parseAsync(t,e,s){const n=this.parse(t,e,s);return ht(n)?n:Promise.resolve(n)}parseSync(t,e,s){const n=this.parse(t,e,s);if(ht(n))throw new X(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return n}parserConfiguration(t){return ft("<object>",[t],arguments.length),be(this,ne,t,"f"),this}pkgConf(t,e){ft("<string> [string]",[t,e],arguments.length);let s=null;const n=this[Se](e||we(this,Wt,"f"));return n[t]&&"object"==typeof n[t]&&(s=It(n[t],e||we(this,Wt,"f"),this[_e]()["deep-merge-config"]||!1,we(this,he,"f")),we(this,ee,"f").configObjects=(we(this,ee,"f").configObjects||[]).concat(s)),this}positional(t,e){ft("<string> <object>",[t,e],arguments.length);const s=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];e=At(e,((t,e)=>!("type"===t&&!["string","number","boolean"].includes(e))&&s.includes(t)));const n=we(this,Ft,"f").fullCommands[we(this,Ft,"f").fullCommands.length-1],i=n?we(this,zt,"f").cmdToParseOptions(n):{array:[],alias:{},default:{},demand:{}};return lt(i).forEach((s=>{const n=i[s];Array.isArray(n)?-1!==n.indexOf(t)&&(e[s]=!0):n[t]&&!(s in e)&&(e[s]=n[t])})),this.group(t,we(this,pe,"f").getPositionalGroupName()),this.option(t,e)}recommendCommands(t=!0){return ft("[boolean]",[t],arguments.length),be(this,le,t,"f"),this}required(t,e,s){return this.demand(t,e,s)}require(t,e,s){return this.demand(t,e,s)}requiresArg(t){return ft("<array|string|object> [number]",[t],arguments.length),"string"==typeof t&&we(this,ee,"f").narg[t]||this[Ne](this.requiresArg.bind(this),"narg",t,NaN),this}showCompletionScript(t,e){return ft("[string] [string]",[t,e],arguments.length),t=t||this.$0,we(this,Xt,"f").log(we(this,Lt,"f").generateCompletionScript(t,e||we(this,Tt,"f")||"completion")),this}showHelp(t){if(ft("[string|function]",[t],arguments.length),be(this,Kt,!0,"f"),!we(this,pe,"f").hasCachedHelpMessage()){if(!this.parsed){const e=this[Ze](we(this,ce,"f"),void 0,void 0,0,!0);if(ht(e))return e.then((()=>{we(this,pe,"f").showHelp(t)})),this}const e=we(this,zt,"f").runDefaultBuilderOn(this);if(ht(e))return e.then((()=>{we(this,pe,"f").showHelp(t)})),this}return we(this,pe,"f").showHelp(t),this}scriptName(t){return this.customScriptName=!0,this.$0=t,this}showHelpOnFail(t,e){return ft("[boolean|string] [string]",[t,e],arguments.length),we(this,pe,"f").showHelpOnFail(t,e),this}showVersion(t){return ft("[string|function]",[t],arguments.length),we(this,pe,"f").showVersion(t),this}skipValidation(t){return ft("<array|string>",[t],arguments.length),this[Me]("skipValidation",t),this}strict(t){return ft("[boolean]",[t],arguments.length),be(this,de,!1!==t,"f"),this}strictCommands(t){return ft("[boolean]",[t],arguments.length),be(this,ue,!1!==t,"f"),this}strictOptions(t){return ft("[boolean]",[t],arguments.length),be(this,fe,!1!==t,"f"),this}string(t){return ft("<array|string>",[t],arguments.length),this[Me]("string",t),this[es](t),this}terminalWidth(){return ft([],0),we(this,he,"f").process.stdColumns}updateLocale(t){return this.updateStrings(t)}updateStrings(t){return ft("<object>",[t],arguments.length),be(this,Ht,!1,"f"),we(this,he,"f").y18n.updateLocale(t),this}usage(t,e,s,n){if(ft("<string|null|undefined> [string|boolean] [function|object] [function]",[t,e,s,n],arguments.length),void 0!==e){if(at(t,null,we(this,he,"f")),(t||"").match(/^\$0( |$)/))return this.command(t,e,s,n);throw new X(".usage() description must start with $0 if being used as alias for .command()")}return we(this,pe,"f").usage(t),this}usageConfiguration(t){return ft("<object>",[t],arguments.length),be(this,ge,t,"f"),this}version(t,e,s){const n="version";if(ft("[boolean|string] [string] [string]",[t,e,s],arguments.length),we(this,me,"f")&&(this[ke](we(this,me,"f")),we(this,pe,"f").version(void 0),be(this,me,null,"f")),0===arguments.length)s=this[Pe](),t=n;else if(1===arguments.length){if(!1===t)return this;s=t,t=n}else 2===arguments.length&&(s=e,e=void 0);return be(this,me,"string"==typeof t?t:n,"f"),e=e||we(this,pe,"f").deferY18nLookup("Show version number"),we(this,pe,"f").version(s||void 0),this.boolean(we(this,me,"f")),this.describe(we(this,me,"f"),e),this}wrap(t){return ft("<number|null|undefined>",[t],arguments.length),we(this,pe,"f").wrap(t),this}[(zt=new WeakMap,Wt=new WeakMap,Ft=new WeakMap,Lt=new WeakMap,Tt=new WeakMap,Ut=new WeakMap,Bt=new WeakMap,Ht=new WeakMap,Vt=new WeakMap,qt=new WeakMap,Yt=new WeakMap,Jt=new WeakMap,Gt=new WeakMap,Kt=new WeakMap,Qt=new WeakMap,Zt=new WeakMap,Xt=new WeakMap,te=new WeakMap,ee=new WeakMap,se=new WeakMap,ne=new WeakMap,ie=new WeakMap,re=new WeakMap,oe=new WeakMap,ae=new WeakMap,ce=new WeakMap,le=new WeakMap,he=new WeakMap,de=new WeakMap,ue=new WeakMap,fe=new WeakMap,pe=new WeakMap,ge=new WeakMap,me=new WeakMap,ye=new WeakMap,ve)](t){if(!t._||!t["--"])return t;t._.push.apply(t._,t["--"]);try{delete t["--"]}catch(t){}return t}[Oe](){return{log:(...t)=>{this[Ye]()||console.log(...t),be(this,Kt,!0,"f"),we(this,te,"f").length&&be(this,te,we(this,te,"f")+"\n","f"),be(this,te,we(this,te,"f")+t.join(" "),"f")},error:(...t)=>{this[Ye]()||console.error(...t),be(this,Kt,!0,"f"),we(this,te,"f").length&&be(this,te,we(this,te,"f")+"\n","f"),be(this,te,we(this,te,"f")+t.join(" "),"f")}}}[ke](t){lt(we(this,ee,"f")).forEach((e=>{if("configObjects"===e)return;const s=we(this,ee,"f")[e];Array.isArray(s)?s.includes(t)&&s.splice(s.indexOf(t),1):"object"==typeof s&&delete s[t]})),delete we(this,pe,"f").getDescriptions()[t]}[Ae](t,e,s){we(this,Vt,"f")[s]||(we(this,he,"f").process.emitWarning(t,e),we(this,Vt,"f")[s]=!0)}[Ee](){we(this,Yt,"f").push({options:we(this,ee,"f"),configObjects:we(this,ee,"f").configObjects.slice(0),exitProcess:we(this,qt,"f"),groups:we(this,Gt,"f"),strict:we(this,de,"f"),strictCommands:we(this,ue,"f"),strictOptions:we(this,fe,"f"),completionCommand:we(this,Tt,"f"),output:we(this,te,"f"),exitError:we(this,Bt,"f"),hasOutput:we(this,Kt,"f"),parsed:this.parsed,parseFn:we(this,ie,"f"),parseContext:we(this,re,"f")}),we(this,pe,"f").freeze(),we(this,ye,"f").freeze(),we(this,zt,"f").freeze(),we(this,Jt,"f").freeze()}[je](){let t,e="";return t=/\b(node|iojs|electron)(\.exe)?$/.test(we(this,he,"f").process.argv()[0])?we(this,he,"f").process.argv().slice(1,2):we(this,he,"f").process.argv().slice(0,1),e=t.map((t=>{const e=this[Ke](we(this,Wt,"f"),t);return t.match(/^(\/|([a-zA-Z]:)?\\)/)&&e.length<t.length?e:t})).join(" ").trim(),we(this,he,"f").getEnv("_")&&we(this,he,"f").getProcessArgvBin()===we(this,he,"f").getEnv("_")&&(e=we(this,he,"f").getEnv("_").replace(`${we(this,he,"f").path.dirname(we(this,he,"f").process.execPath())}/`,"")),e}[_e](){return we(this,ne,"f")}[xe](){return we(this,ge,"f")}[$e](){if(!we(this,Ht,"f"))return;const t=we(this,he,"f").getEnv("LC_ALL")||we(this,he,"f").getEnv("LC_MESSAGES")||we(this,he,"f").getEnv("LANG")||we(this,he,"f").getEnv("LANGUAGE")||"en_US";this.locale(t.replace(/[.:].*/,""))}[Pe](){return this[Se]().version||"unknown"}[Ce](t){const e=t["--"]?t["--"]:t._;for(let t,s=0;void 0!==(t=e[s]);s++)we(this,he,"f").Parser.looksLikeNumber(t)&&Number.isSafeInteger(Math.floor(parseFloat(`${t}`)))&&(e[s]=Number(t));return t}[Se](t){const e=t||"*";if(we(this,oe,"f")[e])return we(this,oe,"f")[e];let s={};try{let e=t||we(this,he,"f").mainFilename;!t&&we(this,he,"f").path.extname(e)&&(e=we(this,he,"f").path.dirname(e));const n=we(this,he,"f").findUp(e,((t,e)=>e.includes("package.json")?"package.json":void 0));at(n,void 0,we(this,he,"f")),s=JSON.parse(we(this,he,"f").readFileSync(n,"utf8"))}catch(t){}return we(this,oe,"f")[e]=s||{},we(this,oe,"f")[e]}[Me](t,e){(e=[].concat(e)).forEach((e=>{e=this[Re](e),we(this,ee,"f")[t].push(e)}))}[Ne](t,e,s,n){this[Ie](t,e,s,n,((t,e,s)=>{we(this,ee,"f")[t][e]=s}))}[De](t,e,s,n){this[Ie](t,e,s,n,((t,e,s)=>{we(this,ee,"f")[t][e]=(we(this,ee,"f")[t][e]||[]).concat(s)}))}[Ie](t,e,s,n,i){if(Array.isArray(s))s.forEach((e=>{t(e,n)}));else if((t=>"object"==typeof t)(s))for(const e of lt(s))t(e,s[e]);else i(e,this[Re](s),n)}[Re](t){return"__proto__"===t?"___proto___":t}[ze](t,e){return this[Ne](this[ze].bind(this),"key",t,e),this}[We](){var t,e,s,n,i,r,o,a,c,l,h,d;const u=we(this,Yt,"f").pop();let f;at(u,void 0,we(this,he,"f")),t=this,e=this,s=this,n=this,i=this,r=this,o=this,a=this,c=this,l=this,h=this,d=this,({options:{set value(e){be(t,ee,e,"f")}}.value,configObjects:f,exitProcess:{set value(t){be(e,qt,t,"f")}}.value,groups:{set value(t){be(s,Gt,t,"f")}}.value,output:{set value(t){be(n,te,t,"f")}}.value,exitError:{set value(t){be(i,Bt,t,"f")}}.value,hasOutput:{set value(t){be(r,Kt,t,"f")}}.value,parsed:this.parsed,strict:{set value(t){be(o,de,t,"f")}}.value,strictCommands:{set value(t){be(a,ue,t,"f")}}.value,strictOptions:{set value(t){be(c,fe,t,"f")}}.value,completionCommand:{set value(t){be(l,Tt,t,"f")}}.value,parseFn:{set value(t){be(h,ie,t,"f")}}.value,parseContext:{set value(t){be(d,re,t,"f")}}.value}=u),we(this,ee,"f").configObjects=f,we(this,pe,"f").unfreeze(),we(this,ye,"f").unfreeze(),we(this,zt,"f").unfreeze(),we(this,Jt,"f").unfreeze()}[Fe](t,e){return bt(e,(e=>(t(e),e)))}getInternalMethods(){return{getCommandInstance:this[Le].bind(this),getContext:this[Te].bind(this),getHasOutput:this[Ue].bind(this),getLoggerInstance:this[Be].bind(this),getParseContext:this[He].bind(this),getParserConfiguration:this[_e].bind(this),getUsageConfiguration:this[xe].bind(this),getUsageInstance:this[Ve].bind(this),getValidationInstance:this[qe].bind(this),hasParseCallback:this[Ye].bind(this),isGlobalContext:this[Je].bind(this),postProcess:this[Ge].bind(this),reset:this[Qe].bind(this),runValidation:this[Xe].bind(this),runYargsParserAndExecuteCommands:this[Ze].bind(this),setHasOutput:this[ts].bind(this)}}[Le](){return we(this,zt,"f")}[Te](){return we(this,Ft,"f")}[Ue](){return we(this,Kt,"f")}[Be](){return we(this,Xt,"f")}[He](){return we(this,re,"f")||{}}[Ve](){return we(this,pe,"f")}[qe](){return we(this,ye,"f")}[Ye](){return!!we(this,ie,"f")}[Je](){return we(this,Zt,"f")}[Ge](t,e,s,n){if(s)return t;if(ht(t))return t;e||(t=this[ve](t));return(this[_e]()["parse-positional-numbers"]||void 0===this[_e]()["parse-positional-numbers"])&&(t=this[Ce](t)),n&&(t=yt(t,this,we(this,Jt,"f").getMiddleware(),!1)),t}[Qe](t={}){be(this,ee,we(this,ee,"f")||{},"f");const e={};e.local=we(this,ee,"f").local||[],e.configObjects=we(this,ee,"f").configObjects||[];const s={};e.local.forEach((e=>{s[e]=!0,(t[e]||[]).forEach((t=>{s[t]=!0}))})),Object.assign(we(this,ae,"f"),Object.keys(we(this,Gt,"f")).reduce(((t,e)=>{const n=we(this,Gt,"f")[e].filter((t=>!(t in s)));return n.length>0&&(t[e]=n),t}),{})),be(this,Gt,{},"f");return["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"].forEach((t=>{e[t]=(we(this,ee,"f")[t]||[]).filter((t=>!s[t]))})),["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"].forEach((t=>{e[t]=At(we(this,ee,"f")[t],(t=>!s[t]))})),e.envPrefix=we(this,ee,"f").envPrefix,be(this,ee,e,"f"),be(this,pe,we(this,pe,"f")?we(this,pe,"f").reset(s):_t(this,we(this,he,"f")),"f"),be(this,ye,we(this,ye,"f")?we(this,ye,"f").reset(s):function(t,e,s){const n=s.y18n.__,i=s.y18n.__n,r={nonOptionCount:function(s){const n=t.getDemandedCommands(),r=s._.length+(s["--"]?s["--"].length:0)-t.getInternalMethods().getContext().commands.length;n._&&(r<n._.min||r>n._.max)&&(r<n._.min?void 0!==n._.minMsg?e.fail(n._.minMsg?n._.minMsg.replace(/\$0/g,r.toString()).replace(/\$1/,n._.min.toString()):null):e.fail(i("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",r,r.toString(),n._.min.toString())):r>n._.max&&(void 0!==n._.maxMsg?e.fail(n._.maxMsg?n._.maxMsg.replace(/\$0/g,r.toString()).replace(/\$1/,n._.max.toString()):null):e.fail(i("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",r,r.toString(),n._.max.toString()))))},positionalCount:function(t,s){s<t&&e.fail(i("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",s,s+"",t+""))},requiredArguments:function(t,s){let n=null;for(const e of Object.keys(s))Object.prototype.hasOwnProperty.call(t,e)&&void 0!==t[e]||(n=n||{},n[e]=s[e]);if(n){const t=[];for(const e of Object.keys(n)){const s=n[e];s&&t.indexOf(s)<0&&t.push(s)}const s=t.length?`\n${t.join("\n")}`:"";e.fail(i("Missing required argument: %s","Missing required arguments: %s",Object.keys(n).length,Object.keys(n).join(", ")+s))}},unknownArguments:function(s,n,o,a,c=!0){var l;const h=t.getInternalMethods().getCommandInstance().getCommands(),d=[],u=t.getInternalMethods().getContext();if(Object.keys(s).forEach((e=>{Mt.includes(e)||Object.prototype.hasOwnProperty.call(o,e)||Object.prototype.hasOwnProperty.call(t.getInternalMethods().getParseContext(),e)||r.isValidAndSomeAliasIsNotNew(e,n)||d.push(e)})),c&&(u.commands.length>0||h.length>0||a)&&s._.slice(u.commands.length).forEach((t=>{h.includes(""+t)||d.push(""+t)})),c){const e=(null===(l=t.getDemandedCommands()._)||void 0===l?void 0:l.max)||0,n=u.commands.length+e;n<s._.length&&s._.slice(n).forEach((t=>{t=String(t),u.commands.includes(t)||d.includes(t)||d.push(t)}))}d.length&&e.fail(i("Unknown argument: %s","Unknown arguments: %s",d.length,d.map((t=>t.trim()?t:`"${t}"`)).join(", ")))},unknownCommands:function(s){const n=t.getInternalMethods().getCommandInstance().getCommands(),r=[],o=t.getInternalMethods().getContext();return(o.commands.length>0||n.length>0)&&s._.slice(o.commands.length).forEach((t=>{n.includes(""+t)||r.push(""+t)})),r.length>0&&(e.fail(i("Unknown command: %s","Unknown commands: %s",r.length,r.join(", "))),!0)},isValidAndSomeAliasIsNotNew:function(e,s){if(!Object.prototype.hasOwnProperty.call(s,e))return!1;const n=t.parsed.newAliases;return[e,...s[e]].some((t=>!Object.prototype.hasOwnProperty.call(n,t)||!n[e]))},limitedChoices:function(s){const i=t.getOptions(),r={};if(!Object.keys(i.choices).length)return;Object.keys(s).forEach((t=>{-1===Mt.indexOf(t)&&Object.prototype.hasOwnProperty.call(i.choices,t)&&[].concat(s[t]).forEach((e=>{-1===i.choices[t].indexOf(e)&&void 0!==e&&(r[t]=(r[t]||[]).concat(e))}))}));const o=Object.keys(r);if(!o.length)return;let a=n("Invalid values:");o.forEach((t=>{a+=`\n ${n("Argument: %s, Given: %s, Choices: %s",t,e.stringifiedValues(r[t]),e.stringifiedValues(i.choices[t]))}`})),e.fail(a)}};let o={};function a(t,e){const s=Number(e);return"number"==typeof(e=isNaN(s)?e:s)?e=t._.length>=e:e.match(/^--no-.+/)?(e=e.match(/^--no-(.+)/)[1],e=!Object.prototype.hasOwnProperty.call(t,e)):e=Object.prototype.hasOwnProperty.call(t,e),e}r.implies=function(e,n){ft("<string|object> [array|number|string]",[e,n],arguments.length),"object"==typeof e?Object.keys(e).forEach((t=>{r.implies(t,e[t])})):(t.global(e),o[e]||(o[e]=[]),Array.isArray(n)?n.forEach((t=>r.implies(e,t))):(at(n,void 0,s),o[e].push(n)))},r.getImplied=function(){return o},r.implications=function(t){const s=[];if(Object.keys(o).forEach((e=>{const n=e;(o[e]||[]).forEach((e=>{let i=n;const r=e;i=a(t,i),e=a(t,e),i&&!e&&s.push(` ${n} -> ${r}`)}))})),s.length){let t=`${n("Implications failed:")}\n`;s.forEach((e=>{t+=e})),e.fail(t)}};let c={};r.conflicts=function(e,s){ft("<string|object> [array|string]",[e,s],arguments.length),"object"==typeof e?Object.keys(e).forEach((t=>{r.conflicts(t,e[t])})):(t.global(e),c[e]||(c[e]=[]),Array.isArray(s)?s.forEach((t=>r.conflicts(e,t))):c[e].push(s))},r.getConflicting=()=>c,r.conflicting=function(i){Object.keys(i).forEach((t=>{c[t]&&c[t].forEach((s=>{s&&void 0!==i[t]&&void 0!==i[s]&&e.fail(n("Arguments %s and %s are mutually exclusive",t,s))}))})),t.getInternalMethods().getParserConfiguration()["strip-dashed"]&&Object.keys(c).forEach((t=>{c[t].forEach((r=>{r&&void 0!==i[s.Parser.camelCase(t)]&&void 0!==i[s.Parser.camelCase(r)]&&e.fail(n("Arguments %s and %s are mutually exclusive",t,r))}))}))},r.recommendCommands=function(t,s){s=s.sort(((t,e)=>e.length-t.length));let i=null,r=1/0;for(let e,n=0;void 0!==(e=s[n]);n++){const s=St(t,e);s<=3&&s<r&&(r=s,i=e)}i&&e.fail(n("Did you mean %s?",i))},r.reset=function(t){return o=At(o,(e=>!t[e])),c=At(c,(e=>!t[e])),r};const l=[];return r.freeze=function(){l.push({implied:o,conflicting:c})},r.unfreeze=function(){const t=l.pop();at(t,void 0,s),({implied:o,conflicting:c}=t)},r}(this,we(this,pe,"f"),we(this,he,"f")),"f"),be(this,zt,we(this,zt,"f")?we(this,zt,"f").reset():function(t,e,s,n){return new vt(t,e,s,n)}(we(this,pe,"f"),we(this,ye,"f"),we(this,Jt,"f"),we(this,he,"f")),"f"),we(this,Lt,"f")||be(this,Lt,function(t,e,s,n){return new Ct(t,e,s,n)}(this,we(this,pe,"f"),we(this,zt,"f"),we(this,he,"f")),"f"),we(this,Jt,"f").reset(),be(this,Tt,null,"f"),be(this,te,"","f"),be(this,Bt,null,"f"),be(this,Kt,!1,"f"),this.parsed=!1,this}[Ke](t,e){return we(this,he,"f").path.relative(t,e)}[Ze](t,e,s,n=0,i=!1){let r=!!s||i;t=t||we(this,ce,"f"),we(this,ee,"f").__=we(this,he,"f").y18n.__,we(this,ee,"f").configuration=this[_e]();const o=!!we(this,ee,"f").configuration["populate--"],a=Object.assign({},we(this,ee,"f").configuration,{"populate--":!0}),c=we(this,he,"f").Parser.detailed(t,Object.assign({},we(this,ee,"f"),{configuration:{"parse-positional-numbers":!1,...a}})),l=Object.assign(c.argv,we(this,re,"f"));let h;const d=c.aliases;let u=!1,f=!1;Object.keys(l).forEach((t=>{t===we(this,Qt,"f")&&l[t]?u=!0:t===we(this,me,"f")&&l[t]&&(f=!0)})),l.$0=this.$0,this.parsed=c,0===n&&we(this,pe,"f").clearCachedHelpMessage();try{if(this[$e](),e)return this[Ge](l,o,!!s,!1);if(we(this,Qt,"f")){[we(this,Qt,"f")].concat(d[we(this,Qt,"f")]||[]).filter((t=>t.length>1)).includes(""+l._[l._.length-1])&&(l._.pop(),u=!0)}be(this,Zt,!1,"f");const a=we(this,zt,"f").getCommands(),p=we(this,Lt,"f").completionKey in l,g=u||p||i;if(l._.length){if(a.length){let t;for(let e,r=n||0;void 0!==l._[r];r++){if(e=String(l._[r]),a.includes(e)&&e!==we(this,Tt,"f")){const t=we(this,zt,"f").runCommand(e,this,c,r+1,i,u||f||i);return this[Ge](t,o,!!s,!1)}if(!t&&e!==we(this,Tt,"f")){t=e;break}}!we(this,zt,"f").hasDefaultCommand()&&we(this,le,"f")&&t&&!g&&we(this,ye,"f").recommendCommands(t,a)}we(this,Tt,"f")&&l._.includes(we(this,Tt,"f"))&&!p&&(we(this,qt,"f")&&Et(!0),this.showCompletionScript(),this.exit(0))}if(we(this,zt,"f").hasDefaultCommand()&&!g){const t=we(this,zt,"f").runCommand(null,this,c,0,i,u||f||i);return this[Ge](t,o,!!s,!1)}if(p){we(this,qt,"f")&&Et(!0);const e=(t=[].concat(t)).slice(t.indexOf(`--${we(this,Lt,"f").completionKey}`)+1);return we(this,Lt,"f").getCompletion(e,((t,e)=>{if(t)throw new X(t.message);(e||[]).forEach((t=>{we(this,Xt,"f").log(t)})),this.exit(0)})),this[Ge](l,!o,!!s,!1)}if(we(this,Kt,"f")||(u?(we(this,qt,"f")&&Et(!0),r=!0,this.showHelp("log"),this.exit(0)):f&&(we(this,qt,"f")&&Et(!0),r=!0,we(this,pe,"f").showVersion("log"),this.exit(0))),!r&&we(this,ee,"f").skipValidation.length>0&&(r=Object.keys(l).some((t=>we(this,ee,"f").skipValidation.indexOf(t)>=0&&!0===l[t]))),!r){if(c.error)throw new X(c.error.message);if(!p){const t=this[Xe](d,{},c.error);s||(h=yt(l,this,we(this,Jt,"f").getMiddleware(),!0)),h=this[Fe](t,null!=h?h:l),ht(h)&&!s&&(h=h.then((()=>yt(l,this,we(this,Jt,"f").getMiddleware(),!1))))}}}catch(t){if(!(t instanceof X))throw t;we(this,pe,"f").fail(t.message,t)}return this[Ge](null!=h?h:l,o,!!s,!0)}[Xe](t,e,s,n){const i={...this.getDemandedOptions()};return r=>{if(s)throw new X(s.message);we(this,ye,"f").nonOptionCount(r),we(this,ye,"f").requiredArguments(r,i);let o=!1;we(this,ue,"f")&&(o=we(this,ye,"f").unknownCommands(r)),we(this,de,"f")&&!o?we(this,ye,"f").unknownArguments(r,t,e,!!n):we(this,fe,"f")&&we(this,ye,"f").unknownArguments(r,t,{},!1,!1),we(this,ye,"f").limitedChoices(r),we(this,ye,"f").implications(r),we(this,ye,"f").conflicting(r)}}[ts](){be(this,Kt,!0,"f")}[es](t){if("string"==typeof t)we(this,ee,"f").key[t]=!0;else for(const e of t)we(this,ee,"f").key[e]=!0}}const ns=(is=ot,(t=[],e=is.process.cwd(),s)=>{const n=new ss(t,e,s,is);return Object.defineProperty(n,"argv",{get:()=>n.parse(),enumerable:!0}),n.help(),n.version(),n});var is;const rs=new class{constructor(){this._dirPath=process.cwd()}getBuildCommand(t){return this._buildCommand??=this.packageJson.scripts?.build?.includes("buildIfNeeded")?"yarn build":"YARN wb buildIfNeeded "+(t?.verbose?"--verbose":"")}get dirPath(){return this._dirPath}set dirPath(e){this._dirPath=t.resolve(e)}get rootDirPath(){return this._rootDirPath??=l.existsSync(t.join(this.dirPath,"..","..","package.json"))?t.resolve(this.dirPath,"..",".."):this.dirPath}get dockerfile(){return this._dockerfile??=l.readFileSync(this.dockerfilePath,"utf8")}get dockerfilePath(){if(this._dockerfilePath)return this._dockerfilePath;if(l.existsSync(t.join(this.dirPath,"Dockerfile")))this._dockerfilePath=t.join(this.dirPath,"Dockerfile");else{if(!l.existsSync(t.join(this.dirPath,"..","..","Dockerfile")))throw new Error("Dockerfile not found");this._dockerfilePath=t.join(this.dirPath,"..","..","Dockerfile")}return this._dockerfilePath}get hasDockerfile(){if(void 0!==this._hasDockerfile)return this._hasDockerfile;try{this._hasDockerfile=!!this.dockerfilePath}catch{this._hasDockerfile=!1}return this._hasDockerfile}get name(){return this._name??=rs.rootPackageJson.name||"unknown"}get packageJson(){return this._packageJson??=JSON.parse(l.readFileSync(t.join(this.dirPath,"package.json"),"utf8"))}get rootPackageJson(){return this._rootPackageJson??=this.rootDirPath===this.dirPath?this.packageJson:JSON.parse(l.readFileSync(t.join(this.rootDirPath,"package.json"),"utf8"))}get dockerPackageJson(){return this._dockerPackageJson??=t.dirname(this.dockerfilePath)===this.dirPath?this.packageJson:JSON.parse(l.readFileSync(t.join(t.dirname(this.dockerfilePath),"package.json"),"utf8"))}},os={env:{description:".env files to be loaded.",type:"array"},"cascade-env":{description:"environment to load cascading .env files (e.g., `.env`, `.env.<environment>`, `.env.local` and `.env.<environment>.local`)",type:"string"},"cascade-node-env":{description:'environment to load cascading .env files (e.g., `.env`, `.env.<NODE_ENV>`, `.env.local` and `.env.<NODE_ENV>.local`). If NODE_ENV is falsy, "development" is applied. Preferred over `cascade`.',type:"boolean"},"working-dir":{description:"A working directory",type:"string",alias:"w"},"dry-run":{description:"Whether to skip actual command execution",type:"boolean",alias:"d"},verbose:{description:"Whether to show verbose information",type:"boolean",alias:"v"}},as={command:"buildIfNeeded",describe:"Build code if changes are detected",builder:{...os,command:{description:"A build command",type:"string",default:"yarn build",alias:"c"}},async handler(e){await async function(e){const[s,n,i]=await async function(e){const s=t.resolve(rs.dirPath,"node_modules",".cache","build"),n=t.resolve(s,"last-build");await O.mkdir(s,{recursive:!0});const i=v("sha256"),r=y.execSync("git rev-parse HEAD",{cwd:rs.dirPath}).toString().trim();i.update(r);const o=JSON.stringify(Object.entries(process.env).filter((([t])=>!cs.has(t))).sort((([t],[e])=>t.localeCompare(e))));i.update(o),await async function(t,e){return new Promise((s=>{const n=y.spawnSync("git",["diff","--name-only"],{cwd:rs.dirPath,stdio:"pipe",encoding:"utf8"}).stdout.trim().split("\n").map((t=>"test"===process.env.WB_ENV?t.replace(/packages\/scripts\/test-fixtures\/[^/]+\//,""):t)).filter((t=>(ls.some((e=>t.includes(e)))||hs.some((e=>t.endsWith(e))))&&!ds.some((e=>t.includes(e)))));t.verbose&&console.info(`Changed files: ${n.join(", ")}`);const i=y.spawn("git",["diff","--",...n],{cwd:rs.rootDirPath});i.stdout?.on("data",(s=>{e.update(s),t.verbose&&(console.info(s.toString()),console.info("Hash:",e.copy().digest("hex")))})),i.on("close",(()=>{s()}))}))}(e,i);const a=i.digest("hex"),c=await async function(t){try{return await t()}catch(t){if("object"==typeof t&&t&&"code"in t&&"ENOENT"===t.code)return;throw t}}((()=>O.readFile(n,"utf8")));return[c===a,n,a]}(e);if(s)return console.info(k.green(`Skip to run '${e.command}' 💫`)),!1;if(console.info(k.green(`Run '${e.command}'`)),!e.dryRun){const[t,...s]=(e.command??"").split(" "),n=y.spawnSync(t,s,{cwd:rs.dirPath,stdio:"inherit"});if(0!==n.status)return void(process.exitCode=n.status??1)}e.dryRun||await O.writeFile(n,i,"utf8");return!0}(e)}};const cs=new Set(["CI","PWDEBUG","TMPDIR"]);const ls=["src/","public/"],hs=[".js",".cjs",".mjs",".jsx",".ts",".cts",".mts",".tsx",".json",".browserslistrc","yarn.lock"],ds=["test/","tests/","__tests__/","test-fixtures/","package.json"];const us={command:"optimizeForDockerBuild",describe:"Optimize configuration when building a Docker image",builder:{...os,outside:{description:"Whether the optimization is executed outside a docker container or not",type:"boolean",alias:"o"}},async handler(e){const s={stdio:"inherit"},n=["package.json"];if(rs.packageJson.workspaces){const e=await l.promises.readdir("packages",{withFileTypes:!0});for(const s of e){if(!s.isDirectory())continue;const e=t.join("packages",s.name,"package.json");l.existsSync(e)&&n.push(e)}}for(const s of n){const n=JSON.parse(l.readFileSync(s,"utf8")),i=n.dependencies||{};if(i["@discord-bot/llm"]&&"workspace:*"!==i["@discord-bot/llm"]&&(i["@discord-bot/llm"]="./@discord-bot/llm"),i["@moti-components/go-e-mon"]&&(i["@moti-components/go-e-mon"]="./@moti-components/go-e-mon"),i["@online-judge/shared"]&&(i["@online-judge/shared"]="./@online-judge/shared"),i["program-executor"]&&(i["program-executor"]="./program-executor"),i["online-judge-shared"]&&(i["online-judge-shared"]="./online-judge-shared"),fs(e,n),ps(n),e.dryRun)continue;const r=e.outside?t.join(t.dirname(s),"dist"):t.dirname(s);await l.promises.mkdir(r,{recursive:!0}),await l.promises.writeFile(t.join(r,"package.json"),JSON.stringify(n),"utf8")}e.dryRun||e.outside||y.spawnSync("yarn",s)}};function fs(t,e){if(!t.outside)return void delete e.devDependencies;const s=e.devDependencies||{},n=["concurrently","conventional-changelog-conventionalcommits","eslint","husky","jest","kill-port","lint-staged","open-cli","playwright","prettier","pinst","sort-package-json","wait-on","semantic-release","vitest"];for(const e of Object.keys(s))(n.some((t=>e.includes(t)))||!t.outside&&e.includes("willbooster")&&e.includes("config"))&&delete s[e]}function ps(t){const e=["check","deploy","format","lint","start","test"],s=["pinst ","husky "],n=t.scripts||{};for(const[t,i]of Object.entries(n))(e.some((e=>t.includes(e)))||s.some((t=>i.includes(t))))&&delete n[t]}const gs=new class{deploy(){return"PRISMA migrate deploy"}deployForce(t){const e=rs.packageJson.dependencies?.blitz?"db":"prisma";return`rm -Rf ${e}/mount/prod.sqlite3*; PRISMA migrate reset --force && rm -Rf ${e}/mount/prod.sqlite3* && litestream restore -o ${e}/mount/prod.sqlite3 ${t} && PRISMA migrate deploy`}litestream(){return'node -e \'\nconst { PrismaClient } = require("@prisma/client");\nnew PrismaClient().$queryRaw`PRAGMA journal_mode = WAL;`\n .catch((error) => { console.log("Failed due to:", error); process.exit(1); });\n\''}migrate(){return`PRISMA migrate deploy && PRISMA generate && ${this.seed()}`}migrateDev(){return"PRISMA migrate dev"}reset(){return`PRISMA migrate reset --force --skip-seed && ${this.seed()}`}restore(t,e){return`rm -Rf ${rs.packageJson.dependencies?.blitz?"db":"prisma"}/restored.sqlite3; GOOGLE_APPLICATION_CREDENTIALS=gcp-sa-key.json litestream restore -o ${e} ${t}`}seed(){return rs.packageJson.dependencies?.blitz?"YARN blitz db seed":rs.packageJson.prisma?.seed?"YARN prisma db seed":'if [ -e "prisma/seeds.ts" ]; then YARN build-ts run prisma/seeds.ts; fi'}studio(e){let s="";if(e)try{new URL(e),s=`DATABASE_URL=${e} `}catch{const n=t.resolve(e);console.info(e,n),s=`DATABASE_URL=file://${n} `}return`${s}PRISMA studio`}},ms=new E,ys=new Set;async function bs(t){try{await j(t)}catch{}}const ws={exitIfFailed:!0};async function vs(t,e,s=ws){const[n,i]=ks(t);if(As(n),e.verbose&&As(n,"Start (detailed)",!0),e.dryRun)return Es(n,0,s),0;const r=i.match(/http:\/\/127.0.0.1:(\d+)/)?.[1];i.includes("wait-on")&&r&&!i.includes("docker run")&&await async function(t){await bs(t);const e=async()=>{ys.has(t)||(ys.add(t),await bs(t))};process.on("beforeExit",e),process.on("SIGINT",e)}(Number(r));const o=await P(i,void 0,{cwd:rs.dirPath,shell:!0,stdio:"inherit",timeout:s?.timeout,killOnExit:!0,verbose:e.verbose});return Es(n,o.status,s),o.status??1}function Os(t,e,s=ws){return ms.run((async()=>{const[n,i]=ks(t);if(As(n,"Start (parallel)",!0),e.dryRun)return As(n,"Start (log)"),void Es(n,0,s);const r=await P(i,void 0,{cwd:rs.dirPath,shell:!0,stdio:"pipe",timeout:s?.timeout,mergeOutAndError:!0,killOnExit:!0,verbose:e.verbose});As(n,"Start (log)");const o=r.stdout.trim();o&&console.info(o),Es(n,r.status,s)}))}function ks(e){const s=function(){if(js)return _s;js=!0;let e=rs.dirPath;for(;;){const s=t.join(e,"node_modules",".bin");if(l.existsSync(s)&&(process.env.PATH=`${s}:${process.env.PATH}`,_s=!0),l.existsSync(t.join(e,".git")))break;const n=t.dirname(e);if(e===n)break;e=n}return _s}(),n=e.replaceAll("\n","").replaceAll(/\s\s+/g," ").replaceAll("PRISMA ",rs.packageJson.dependencies?.blitz?"YARN blitz prisma ":"YARN prisma ").trim();return[n.replaceAll("YARN ","yarn "),n.replaceAll("YARN ",s?"":"yarn ")]}function As(t,e="Start",s=!1){console.info("\n"+(s?k.gray:k.cyan)(k.bold(`${e}:`),t)+k.gray(` at ${rs.dirPath}`))}function Es(t,e,s){0===e?console.info(k.green(k.bold("Finished:"),t)):(console.info(k.red(k.bold(`Failed (exit code ${e}): `),t)),!1!==s.exitIfFailed&&process.exit(e??1))}let js=!1,_s=!1;const xs={...os},$s={command:"prisma",describe:"Run prisma commands",builder:t=>t.command(Ps).command(Ss).command(Ms).command(Ns).command(Ds).command(Is).command(Rs).command(zs).command(Ws).demandCommand(),handler(){}},Ps={command:"deploy",describe:"Apply migration to DB without initializing it",builder:xs,async handler(t){await vs(gs.deploy(),t)}},Cs={...xs,"backup-path":{description:"Whether to skip actual command execution",demandOption:!0,type:"string",alias:"b"}},Ss={command:"deploy-force <backup-path>",describe:"Force to apply migration to DB utilizing Litestream's backup without initializing it",builder:Cs,async handler(t){await vs(gs.deployForce(t.backupPath),t)}},Ms={command:"litestream",describe:"Setup DB for Litestream",builder:xs,async handler(t){await vs(gs.litestream(),t)}},Ns={command:"migrate",describe:"Apply migration to DB with initializing it",builder:xs,async handler(t){await vs(gs.migrate(),t)}},Ds={command:"migrate-dev",describe:"Create a migration file",builder:xs,async handler(t){await vs(gs.migrateDev(),t)}},Is={command:"reset",describe:"Reset DB",builder:xs,async handler(t){await vs(gs.reset(),t)}},Rs={command:"restore <backup-path>",describe:"Restore DB from Litestream's backup",builder:{...Cs,output:{description:'Output path of the restored database. Defaults to "<db|prisma>/restored.sqlite3".',type:"string"}},async handler(t){const e=t.output||(rs.packageJson.dependencies?.blitz?"db/restored.sqlite3":"prisma/restored.sqlite3");await vs(gs.restore(t.backupPath,e),t)}},zs={command:"seed",describe:"Populate DB with seed data",builder:xs,async handler(t){await vs(gs.seed(),t)}},Ws={command:"studio [db-url-or-path]",describe:"Open Prisma Studio",builder:{...xs,"db-url-or-path":{description:"URL or path to the database",type:"string"},restored:{description:"Whether to open the default restored database (<db|prisma>/restored.sqlite3).",type:"boolean"}},async handler(t){if(t.restored&&t.dbUrlOrPath)throw new Error("You cannot specify both --restored and --db-url-or-path.");const e=t.restored?rs.packageJson.dependencies?.blitz?"db/restored.sqlite3":"prisma/restored.sqlite3":t.dbUrlOrPath?.toString();await vs(gs.studio(e),t)}},Fs={command:"retry",describe:"Retry the given command until it succeeds",builder:{...os,retry:{description:"A maximum retry count",type:"number",alias:"r",default:3}},async handler(t){const e=t._.slice(1);let s=0;for(let n=0;n<t.retry;n++)if(n>0&&console.info(`\n${k.yellow(`#${n} Retrying: ${e.join(" ")}`)}`),s=await vs(e.join(" "),t,{exitIfFailed:!1}),0===s)return;process.exit(s)}},Ls={command:"setup",describe:"Setup development environment",builder:{...os},async handler(t){await async function(t){const e=await O.readdir(rs.dirPath,{withFileTypes:!0});e.some((t=>t.isFile()&&t.name.includes("-version")))&&await vs("asdf install",t);if(e.some((t=>t.isFile()&&"pyproject.toml"===t.name))){await Os("poetry config virtualenvs.in-project true",t),await Os("poetry config virtualenvs.prefer-active-python true",t);const[,e]=y.execSync("asdf current python").toString().trim().split(/\s+/);await Os(`poetry env use ${e}`,t),await ms.promiseAll(),await vs("poetry run pip install --upgrade pip",t),await vs("poetry install --ansi",t)}if("darwin"===x.platform()){const e=["pstree"];rs.hasDockerfile&&e.push("expect"),await Os(`brew install ${e.join(" ")}`,t)}const s=rs.packageJson.dependencies??{},n=rs.packageJson.devDependencies||{},i=rs.packageJson.scripts??{},r=[],o=[];s.blitz?(r.push("pm2"),o.push("concurrently","dotenv-cli","open-cli","vitest","wait-on")):n["@remix-run/dev"]?(r.push("dotenv-cli","pm2"),o.push("concurrently","open-cli","vitest","wait-on")):(s.express||s.fastify)&&(r.push("pm2"),o.push("concurrently","vitest","wait-on"));r.length>0&&await vs(`yarn add ${r.join(" ")}`,t);o.length>0&&await vs(`yarn add -D ${o.join(" ")}`,t);i["gen-code"]&&await vs("yarn gen-code",t)}(t)}};const Ts={...os,watch:{description:"Whether to watch files",type:"boolean"},args:{description:"Arguments for core command",type:"array",alias:"a",default:[]},"docker-args":{description:'Arguments for "docker run"',type:"array",alias:"a",default:[]}};const Us=new class{buildDevImage(e="local"){const s=rs.dockerPackageJson.scripts?.["docker/build/prepare"]?"yarn run docker/build/prepare && ":"";return`cd ${t.dirname(rs.dockerfilePath)}\n && ${s}YARN wb optimizeForDockerBuild --outside\n && YARN wb retry -- docker build -t ${rs.name}\n --build-arg ARCH=$([ $(uname -m) = 'arm64' ] && echo arm64 || echo amd64)\n --build-arg WB_ENV=${e}\n --build-arg WB_VERSION=dev .`}stopAndStart(t=!1,e="",s=""){return`${this.stop()} && ${t?"unbuffer ":""}${this.start(e,s)}`}start(t="",e=""){return function(t){const e=async()=>{ys.has(t)||(ys.add(t),w(t,{shell:!0,stdio:"inherit"}))};process.on("beforeExit",e),process.on("SIGINT",e)}(this.stop()),`docker run --rm -it -p 8080:8080 --name ${rs.name} ${t} ${rs.name} ${e}`}stop(){return`true $(docker rm -f $(docker container ls -q -f name=${rs.name}) 2> /dev/null)`}stopAll(){return"true $(docker rm -f $(docker ps -q) 2> /dev/null)"}};class Bs{constructor(t=3e3){this.defaultPort=t}buildDocker(t,e="local"){return Us.buildDevImage(e)}startDocker(t){return`${this.buildDocker(t)}\n && YARN concurrently --raw --kill-others-on-fail\n "${Us.stopAndStart(!1,t.normalizedDockerArgsText??"",t.normalizedArgsText??"")}"\n "${this.waitAndOpenApp(t,8080)}"`}testE2E(t,{playwrightArgs:e,prismaDirectory:s,startCommand:n}){return`APP_ENV=production WB_ENV=test PORT=8080 YARN dotenv -c production -- concurrently --kill-others --raw --success first\n "rm -Rf ${s}/mount && ${n} && exit 1"\n "wait-on -t 600000 -i 2000 http://127.0.0.1:8080 && yarn playwright ${e}"`}testE2EDev(t,{playwrightArgs:e,startCommand:s}){return`APP_ENV=development WB_ENV=test NEXT_PUBLIC_WB_ENV=test PORT=8080 YARN dotenv -c development -- concurrently --kill-others --raw --success first\n "${s} && exit 1"\n "wait-on -t 600000 -i 2000 http://127.0.0.1:8080 && yarn playwright ${e}"`}testUnit(t){return"YARN vitest run tests/unit --color --passWithNoTests"}waitApp(t,e=this.defaultPort){return`wait-on -t 10000 http://127.0.0.1:${e} 2> /dev/null\n || wait-on -t 10000 -i 500 http://127.0.0.1:${e} 2> /dev/null\n || wait-on -t 10000 -i 1000 http://127.0.0.1:${e} 2> /dev/null\n || wait-on -t 10000 -i 2000 http://127.0.0.1:${e} 2> /dev/null\n || wait-on -t 20000 -i 4000 http://127.0.0.1:${e} 2> /dev/null\n || wait-on -t 60000 -i 5000 http://127.0.0.1:${e}`}waitAndOpenApp(t,e=this.defaultPort){return`${this.waitApp(t,e)} || wait-on http://127.0.0.1:${e} && open-cli http://localhost:${e}`}}const Hs=new class extends Bs{constructor(){super()}start(t){return`YARN concurrently --raw --kill-others-on-fail\n "blitz dev ${t.normalizedArgsText??""}"\n "${this.waitAndOpenApp(t)}"`}startProduction(t,e){return`NODE_ENV=production YARN concurrently --raw --kill-others-on-fail\n "${gs.reset()} && ${rs.getBuildCommand(t)} && PORT=${e} pm2-runtime start ecosystem.config.cjs ${t.normalizedArgsText??""}"\n "${this.waitAndOpenApp(t,e)}"`}testE2E(t,{playwrightArgs:e="test tests/e2e",startCommand:s=`${gs.reset()} && ${rs.getBuildCommand(t)} && pm2-runtime start ecosystem.config.cjs`}){return super.testE2E(t,{playwrightArgs:e,prismaDirectory:"db",startCommand:s})}testE2EDev(t,{playwrightArgs:e="test tests/e2e",startCommand:s="blitz dev -p 8080"}){return super.testE2EDev(t,{playwrightArgs:e,startCommand:s})}testStart(t){return`YARN concurrently --kill-others --raw --success first "blitz dev" "${this.waitApp(t)}"`}};const Vs=new class extends Bs{constructor(){super()}start(t){return`YARN build-ts run src/index.ts ${t.watch?"--watch":""} -- ${t.normalizedArgsText??""}`}startDocker(t){return`${this.buildDocker(t)} && ${Us.stopAndStart(!1,t.normalizedDockerArgsText??"",t.normalizedArgsText??"")}`}startProduction(t,e=8080){return`NODE_ENV=production ${rs.getBuildCommand(t)} && NODE_ENV=production PORT=\${PORT:-${e}} node dist/index.js ${t.normalizedArgsText??""}`}testE2E(t,{startCommand:e=`if [ -e "prisma" ]; then prisma migrate reset --force --skip-generate; fi && (${this.startProduction(t)})`}){return`NODE_ENV=production WB_ENV=test PORT=8080 YARN concurrently --kill-others --raw --success first\n "${e} && exit 1"\n "wait-on -t 600000 -i 2000 http://127.0.0.1:8080 && vitest run tests/e2e --color --passWithNoTests"`}testE2EDev(t,{startCommand:e}){return`NODE_ENV=production WB_ENV=test PORT=8080 YARN concurrently --kill-others --raw --success first\n "${e||this.start(t)} && exit 1"\n "wait-on -t 600000 -i 2000 http://127.0.0.1:8080 && vitest run tests/e2e --color --passWithNoTests"`}testStart(t){return`YARN concurrently --kill-others --raw --success first "${this.start(t)}" "${this.waitApp(t)}"`}};const qs=new class extends Bs{constructor(){super()}start(t){return`YARN build-ts run src/index.ts ${t.watch?"--watch":""} -- ${t.normalizedArgsText??""}`}startDocker(t){return`${this.buildDocker(t)} && ${Us.stopAndStart(!1,t.normalizedDockerArgsText??"",t.normalizedArgsText??"")}`}startProduction(t){return`NODE_ENV=production ${rs.getBuildCommand(t)} && NODE_ENV=production node dist/index.js ${t.normalizedArgsText??""}`}testE2E(){return"echo 'do nothing.'"}testE2EDev(){return"echo 'do nothing.'"}testStart(){return"echo 'do nothing.'"}};const Ys=new class extends Bs{constructor(){super()}start(t){return`YARN concurrently --raw --kill-others-on-fail\n "dotenv -c development -- remix dev ${t.normalizedArgsText??""}"\n "${this.waitAndOpenApp(t)}"`}startProduction(t,e){return`NODE_ENV=production YARN dotenv -c production -- concurrently --raw --kill-others-on-fail\n "${gs.reset()} && ${rs.getBuildCommand(t)} && PORT=${e} pm2-runtime start ecosystem.config.cjs ${t.normalizedArgsText??""}"\n "${this.waitAndOpenApp(t,e)}"`}testE2E(t,{playwrightArgs:e="test tests/e2e",startCommand:s=`${gs.reset()} && ${rs.getBuildCommand(t)} && pm2-runtime start ecosystem.config.cjs`}){return super.testE2E(t,{playwrightArgs:e,prismaDirectory:"prisma",startCommand:s})}testE2EDev(t,{playwrightArgs:e="test tests/e2e",startCommand:s="remix dev"}){return super.testE2EDev(t,{playwrightArgs:e,startCommand:s})}testStart(t){return`YARN concurrently --kill-others --raw --success first "dotenv -c development -- remix dev" "${this.waitApp(t)}"`}},Js={command:"start [args..]",describe:"Start app",builder:{...Ts,mode:{description:"Start mode: dev[elopment] (default) | prod[uction] | docker",type:"string",alias:"m"}},async handler(t){!function(t){t.normalizedArgsText=[...t.args??[],...t._?.slice(1)??[]].map((t=>`'${t}'`)).join(" "),t.normalizedDockerArgsText=(t.dockerArgs??[]).map((t=>`'${t}'`)).join(" ")}(t);const e=rs.packageJson.dependencies||{},s=rs.packageJson.devDependencies||{};let n;switch(n=e.blitz?Hs:s["@remix-run/dev"]?Ys:(e.express||e.fastify)&&!e["firebase-functions"]||rs.hasDockerfile&&/EXPOSE\s+8080/.test(rs.dockerfile)?Vs:qs,t.mode||"dev"){case"dev":case"development":await vs(n.start(t),t);break;case"prod":case"production":await vs(n.startProduction(t,8080),t);break;case"docker":await vs(n.startDocker(t),t);break;default:throw new Error(`Unknown start mode: ${t.mode}`)}}},Gs={command:"test",describe:"Test project",builder:{...os,ci:{description:"Whether to run tests on CI",type:"boolean"},e2e:{description:"Whether to run e2e tests. You may pass mode as argument: none | headless (default) | headless-dev | headed | headed-dev | docker | docker-debug | debug | generate | trace",type:"string"},start:{description:"Whether to run start tests",type:"boolean"},unit:{description:"Whether to run unit tests",type:"boolean"},"unit-timeout":{description:"Timeout for unit tests",type:"number"}},async handler(e){await async function(e){process.env.FORCE_COLOR="3",await async function(t){if(!rs.packageJson.workspaces)return;const e=process.argv.slice(2),s=e.findIndex((t=>["-w","--working-dir","--workingDir"].includes(t)));s>=0&&e.splice(s,2),process.env.CI="1",await vs(["yarn","workspaces","foreach","--all","--exclude",rs.name,"--verbose","run","wb",...e].join(" "),t),process.exit(0)}(e);const s=rs.packageJson.dependencies||{},n=rs.packageJson.devDependencies||{};let i;i=s.blitz?Hs:n["@remix-run/dev"]?Ys:!s.express&&!s.fastify||s["firebase-functions"]?qs:Vs;const r=[];if(e.ci){const s=$(t.join(rs.dirPath,"tests","unit")),n=$(t.join(rs.dirPath,"tests","e2e"));if(await Os(Us.stopAll(),e),!1!==e.unit&&await s&&await Os(i.testUnit(e),e,{timeout:e.unitTimeout}),!1!==e.start&&await Os(i.testStart(e),e),await ms.promiseAll(),"none"!==e.e2e&&await n){rs.hasDockerfile&&await vs(`${i.buildDocker(e,"test")}`,e);const t=rs.hasDockerfile?{startCommand:Us.stopAndStart(!0)}:{};process.exitCode=await vs(i.testE2E(e,t),e,{exitIfFailed:!1}),await vs(Us.stop(),e)}return}(e.unit||!e.start&&void 0===e.e2e)&&r.push(vs(i.testUnit(e),e,{timeout:e.unitTimeout}));e.start&&r.push(vs(i.testStart(e),e));switch(await Promise.all(r),e.e2e){case void 0:case"none":return;case"":case"headless":return void await vs(i.testE2E(e,{}),e);case"headless-dev":return void await vs(i.testE2EDev(e,{}),e);case"docker":return void await Ks(e,i);case"docker-debug":return void await Ks(e,i,"PWDEBUG=1 ")}if(s.blitz||n["@remix-run/dev"])switch(e.e2e){case"headed":return void await vs(i.testE2E(e,{playwrightArgs:"test tests/e2e --headed"}),e);case"headed-dev":return void await vs(i.testE2EDev(e,{playwrightArgs:"test tests/e2e --headed"}),e);case"debug":return void await vs(`PWDEBUG=1 ${i.testE2E(e,{})}`,e);case"generate":return void await vs(i.testE2E(e,{playwrightArgs:"codegen http://localhost:8080"}),e);case"trace":return void await vs("playwright show-trace",e)}throw new Error(`Unknown e2e mode: ${e.e2e}`)}(e)}};async function Ks(t,e,s=""){await vs(`${e.buildDocker(t,"test")}`,t),process.exitCode=await vs(`${s}${e.testE2E(t,{startCommand:Us.stopAndStart(!0)})}`,t,{exitIfFailed:!1}),await vs(Us.stop(),t)}const Qs={command:"typecheck",describe:"Run type checking",builder:{...os},async handler(t){const e=[];if(rs.packageJson.workspaces?e.push(`yarn workspaces foreach --all --parallel --exclude ${rs.name} --verbose run typecheck`):((rs.packageJson.dependencies?.typescript||rs.packageJson.devDependencies?.typescript)&&e.push("tsc --noEmit --Pretty"),rs.packageJson.devDependencies?.pyright&&e.push("pyright")),process.exitCode=await vs(e.join(" && "),t),0!==process.exitCode){(JSON.parse(await O.readFile("package.json","utf8")).dependencies||{}).blitz&&console.info(k.yellow('Please try "yarn gen-code" if you face unknown type errors.'))}}},Zs={...Qs,command:"tc"};var Xs;await ns((Xs=process.argv,Xs.slice(Z()+1))).scriptName("wb").options(os).middleware((e=>{const s=e["working-dir"];if(s){const e=t.resolve(s);process.chdir(e),rs.dirPath=e}!function(t){t.PATH&&t.BERRY_BIN_FOLDER&&(t.PATH=t.PATH.replace(`${t.BERRY_BIN_FOLDER}:`,"").replaceAll(/\/private\/var\/folders\/[^:]+:/g,"").replaceAll(/\/var\/tmp\/[^:]+:/g,"").replaceAll(/\/tmp\/[^:]+:/g,""));for(const e of Object.keys(t)){const s=e.toUpperCase();(s.startsWith("NPM_")||s.startsWith("YARN_")||s.startsWith("BERRY_")||"PROJECT_CWD"===s||"INIT_CWD"===s)&&delete t[e]}}(process.env),function(e,s){let n=(e.env??[]).map((t=>t.toString()));const i=e.cascadeNodeEnv?process.env.NODE_ENV||"development":e.cascadeEnv;"string"==typeof i&&(0===n.length&&n.push(".env"),n=n.flatMap((t=>i?[`${t}.${i}.local`,`${t}.local`,`${t}.${i}`,t]:[`${t}.local`,t]))),e.verbose&&console.info("Loading env files:",n);let r={};for(const e of n)r={...A({path:t.join(s,e)}).parsed,...r}}(e,rs.dirPath)})).command(as).command(us).command($s).command(Fs).command(Ls).command(Js).command(Gs).command(Qs).command(Zs).demandCommand().strict().help().argv;for(const t of["SIGINT","SIGTERM","SIGQUIT"])process.on(t,(()=>process.exit()));
33
+ var H,V,q;const Y=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,J=null!==(V=null===(H=null===process||void 0===process?void 0:process.versions)||void 0===H?void 0:H.node)&&void 0!==V?V:null===(q=null===process||void 0===process?void 0:process.version)||void 0===q?void 0:q.slice(1);if(J){if(Number(J.match(/^([^.]+)/)[1])<Y)throw Error(`yargs parser supports a minimum Node.js version of ${Y}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}const G=process?process.env:{},K=new class{constructor(t){T=t}parse(t,e){const s=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},e),n=function(t){if(Array.isArray(t))return t.map((t=>"string"!=typeof t?t+"":t));t=t.trim();let e=0,s=null,n=null,i=null;const r=[];for(let o=0;o<t.length;o++)s=n,n=t.charAt(o)," "!==n||i?(n===i?i=null:"'"!==n&&'"'!==n||i||(i=n),r[e]||(r[e]=""),r[e]+=n):" "!==s&&e++;return r}(t),i="string"==typeof t,r=function(t){const e=[],s=Object.create(null);let n=!0;Object.keys(t).forEach((function(s){e.push([].concat(t[s],s))}));for(;n;){n=!1;for(let t=0;t<e.length;t++)for(let s=t+1;s<e.length;s++){if(e[t].filter((function(t){return-1!==e[s].indexOf(t)})).length){e[t]=e[t].concat(e[s]),e.splice(s,1),n=!0;break}}}return e.forEach((function(t){const e=(t=t.filter((function(t,e,s){return s.indexOf(t)===e}))).pop();void 0!==e&&"string"==typeof e&&(s[e]=t)})),s}(Object.assign(Object.create(null),s.alias)),o=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},s.configuration),a=Object.assign(Object.create(null),s.default),c=s.configObjects||[],l=s.envPrefix,h=o["populate--"],d=h?"--":"_",u=Object.create(null),f=Object.create(null),p=s.__||T.format,g={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:[]},m=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,y=new RegExp("^--"+o["negation-prefix"]+"(.+)");[].concat(s.array||[]).filter(Boolean).forEach((function(t){const e="object"==typeof t?t.key:t,s=Object.keys(t).map((function(t){return{boolean:"bools",string:"strings",number:"numbers"}[t]})).filter(Boolean).pop();s&&(g[s][e]=!0),g.arrays[e]=!0,g.keys.push(e)})),[].concat(s.boolean||[]).filter(Boolean).forEach((function(t){g.bools[t]=!0,g.keys.push(t)})),[].concat(s.string||[]).filter(Boolean).forEach((function(t){g.strings[t]=!0,g.keys.push(t)})),[].concat(s.number||[]).filter(Boolean).forEach((function(t){g.numbers[t]=!0,g.keys.push(t)})),[].concat(s.count||[]).filter(Boolean).forEach((function(t){g.counts[t]=!0,g.keys.push(t)})),[].concat(s.normalize||[]).filter(Boolean).forEach((function(t){g.normalize[t]=!0,g.keys.push(t)})),"object"==typeof s.narg&&Object.entries(s.narg).forEach((([t,e])=>{"number"==typeof e&&(g.nargs[t]=e,g.keys.push(t))})),"object"==typeof s.coerce&&Object.entries(s.coerce).forEach((([t,e])=>{"function"==typeof e&&(g.coercions[t]=e,g.keys.push(t))})),void 0!==s.config&&(Array.isArray(s.config)||"string"==typeof s.config?[].concat(s.config).filter(Boolean).forEach((function(t){g.configs[t]=!0})):"object"==typeof s.config&&Object.entries(s.config).forEach((([t,e])=>{"boolean"!=typeof e&&"function"!=typeof e||(g.configs[t]=e)}))),function(...t){t.forEach((function(t){Object.keys(t||{}).forEach((function(t){g.aliases[t]||(g.aliases[t]=[].concat(r[t]||[]),g.aliases[t].concat(t).forEach((function(e){if(/-/.test(e)&&o["camel-case-expansion"]){const s=z(e);s!==t&&-1===g.aliases[t].indexOf(s)&&(g.aliases[t].push(s),u[s]=!0)}})),g.aliases[t].concat(t).forEach((function(e){if(e.length>1&&/[A-Z]/.test(e)&&o["camel-case-expansion"]){const s=W(e,"-");s!==t&&-1===g.aliases[t].indexOf(s)&&(g.aliases[t].push(s),u[s]=!0)}})),g.aliases[t].forEach((function(e){g.aliases[e]=[t].concat(g.aliases[t].filter((function(t){return e!==t})))})))}))}))}(s.key,r,s.default,g.arrays),Object.keys(a).forEach((function(t){(g.aliases[t]||[]).forEach((function(e){a[e]=a[t]}))}));let b=null;Object.keys(g.counts).find((t=>D(t,g.arrays)?(b=Error(p("Invalid configuration: %s, opts.count excludes opts.array.",t)),!0):!!D(t,g.nargs)&&(b=Error(p("Invalid configuration: %s, opts.count excludes opts.narg.",t)),!0)));let w=[];const v=Object.assign(Object.create(null),{_:[]}),k={};for(let t=0;t<n.length;t++){const e=n[t],s=e.replace(/^-{3,}/,"---");let i,r,a,c,l,h;if("--"!==e&&/^-/.test(e)&&R(e))O(e);else{if(s.match(/^---+(=|$)/)){O(e);continue}if(e.match(/^--.+=/)||!o["short-option-groups"]&&e.match(/^-.+=/))c=e.match(/^--?([^=]+)=([\s\S]*)$/),null!==c&&Array.isArray(c)&&c.length>=3&&(D(c[1],g.arrays)?t=E(t,c[1],n,c[2]):!1!==D(c[1],g.nargs)?t=A(t,c[1],n,c[2]):j(c[1],c[2],!0));else if(e.match(y)&&o["boolean-negation"])c=e.match(y),null!==c&&Array.isArray(c)&&c.length>=2&&(r=c[1],j(r,!!D(r,g.arrays)&&[!1]));else if(e.match(/^--.+/)||!o["short-option-groups"]&&e.match(/^-[^-]+/))c=e.match(/^--?(.+)/),null!==c&&Array.isArray(c)&&c.length>=2&&(r=c[1],D(r,g.arrays)?t=E(t,r,n):!1!==D(r,g.nargs)?t=A(t,r,n):(l=n[t+1],void 0===l||l.match(/^-/)&&!l.match(m)||D(r,g.bools)||D(r,g.counts)?/^(true|false)$/.test(l)?(j(r,l),t++):j(r,H(r)):(j(r,l),t++)));else if(e.match(/^-.\..+=/))c=e.match(/^-([^=]+)=([\s\S]*)$/),null!==c&&Array.isArray(c)&&c.length>=3&&j(c[1],c[2]);else if(e.match(/^-.\..+/)&&!e.match(m))l=n[t+1],c=e.match(/^-(.\..+)/),null!==c&&Array.isArray(c)&&c.length>=2&&(r=c[1],void 0===l||l.match(/^-/)||D(r,g.bools)||D(r,g.counts)?j(r,H(r)):(j(r,l),t++));else if(e.match(/^-[^-]+/)&&!e.match(m)){a=e.slice(1,-1).split(""),i=!1;for(let s=0;s<a.length;s++){if(l=e.slice(s+2),a[s+1]&&"="===a[s+1]){h=e.slice(s+3),r=a[s],D(r,g.arrays)?t=E(t,r,n,h):!1!==D(r,g.nargs)?t=A(t,r,n,h):j(r,h),i=!0;break}if("-"!==l){if(/[A-Za-z]/.test(a[s])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(l)&&!1===D(l,g.bools)){j(a[s],l),i=!0;break}if(a[s+1]&&a[s+1].match(/\W/)){j(a[s],l),i=!0;break}j(a[s],H(a[s]))}else j(a[s],l)}r=e.slice(-1)[0],i||"-"===r||(D(r,g.arrays)?t=E(t,r,n):!1!==D(r,g.nargs)?t=A(t,r,n):(l=n[t+1],void 0===l||/^(-|--)[^-]/.test(l)&&!l.match(m)||D(r,g.bools)||D(r,g.counts)?/^(true|false)$/.test(l)?(j(r,l),t++):j(r,H(r)):(j(r,l),t++)))}else if(e.match(/^-[0-9]$/)&&e.match(m)&&D(e.slice(1),g.bools))r=e.slice(1),j(r,H(r));else{if("--"===e){w=n.slice(t+1);break}if(o["halt-at-non-option"]){w=n.slice(t);break}O(e)}}}function O(t){const e=$("_",t);"string"!=typeof e&&"number"!=typeof e||v._.push(e)}function A(t,e,s,n){let i,r=D(e,g.nargs);if(r="number"!=typeof r||isNaN(r)?1:r,0===r)return V(n)||(b=Error(p("Argument unexpected for: %s",e))),j(e,H(e)),t;let a=V(n)?0:1;if(o["nargs-eats-options"])s.length-(t+1)+a<r&&(b=Error(p("Not enough arguments following: %s",e))),a=r;else{for(i=t+1;i<s.length&&(!s[i].match(/^-[^0-9]/)||s[i].match(m)||R(s[i]));i++)a++;a<r&&(b=Error(p("Not enough arguments following: %s",e)))}let c=Math.min(a,r);for(!V(n)&&c>0&&(j(e,n),c--),i=t+1;i<c+t+1;i++)j(e,s[i]);return t+c}function E(t,e,s,n){let r=[],c=n||s[t+1];const l=D(e,g.nargs);if(D(e,g.bools)&&!/^(true|false)$/.test(c))r.push(!0);else if(V(c)||V(n)&&/^-/.test(c)&&!m.test(c)&&!R(c)){if(void 0!==a[e]){const t=a[e];r=Array.isArray(t)?t:[t]}}else{V(n)||r.push(x(e,n,!0));for(let n=t+1;n<s.length&&!(!o["greedy-arrays"]&&r.length>0||l&&"number"==typeof l&&r.length>=l)&&(c=s[n],!/^-/.test(c)||m.test(c)||R(c));n++)t=n,r.push(x(e,c,i))}return"number"==typeof l&&(l&&r.length<l||isNaN(l)&&0===r.length)&&(b=Error(p("Not enough arguments following: %s",e))),j(e,r),t}function j(t,e,s=i){if(/-/.test(t)&&o["camel-case-expansion"]){const e=t.split(".").map((function(t){return z(t)})).join(".");_(t,e)}const n=x(t,e,s),r=t.split(".");if(N(v,r,n),g.aliases[t]&&g.aliases[t].forEach((function(t){const e=t.split(".");N(v,e,n)})),r.length>1&&o["dot-notation"]&&(g.aliases[r[0]]||[]).forEach((function(e){let s=e.split(".");const i=[].concat(r);i.shift(),s=s.concat(i),(g.aliases[t]||[]).includes(s.join("."))||N(v,s,n)})),D(t,g.normalize)&&!D(t,g.arrays)){[t].concat(g.aliases[t]||[]).forEach((function(t){Object.defineProperty(k,t,{enumerable:!0,get:()=>e,set(t){e="string"==typeof t?T.normalize(t):t}})}))}}function _(t,e){g.aliases[t]&&g.aliases[t].length||(g.aliases[t]=[e],u[e]=!0),g.aliases[e]&&g.aliases[e].length||_(e,t)}function x(t,e,s){s&&(e=function(t){return"string"!=typeof t||"'"!==t[0]&&'"'!==t[0]||t[t.length-1]!==t[0]?t:t.substring(1,t.length-1)}(e)),(D(t,g.bools)||D(t,g.counts))&&"string"==typeof e&&(e="true"===e);let n=Array.isArray(e)?e.map((function(e){return $(t,e)})):$(t,e);return D(t,g.counts)&&(V(n)||"boolean"==typeof n)&&(n=U()),D(t,g.normalize)&&D(t,g.arrays)&&(n=Array.isArray(e)?e.map((t=>T.normalize(t))):T.normalize(e)),n}function $(t,e){if(!o["parse-positional-numbers"]&&"_"===t)return e;if(!D(t,g.strings)&&!D(t,g.bools)&&!Array.isArray(e)){(F(e)&&o["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${e}`)))||!V(e)&&D(t,g.numbers))&&(e=Number(e))}return e}function P(t,e){Object.keys(t).forEach((function(s){const n=t[s],i=e?e+"."+s:s;"object"==typeof n&&null!==n&&!Array.isArray(n)&&o["dot-notation"]?P(n,i):(!M(v,i.split("."))||D(i,g.arrays)&&o["combine-arrays"])&&j(i,n)}))}function C(t,e){if(void 0===l)return;const s="string"==typeof l?l:"",n=T.env();Object.keys(n).forEach((function(i){if(""===s||0===i.lastIndexOf(s,0)){const r=i.split("__").map((function(t,e){return 0===e&&(t=t.substring(s.length)),z(t)}));(e&&g.configs[r.join(".")]||!e)&&!M(t,r)&&j(r.join("."),n[i])}}))}function S(t,e,s,n=!1){Object.keys(s).forEach((function(i){M(t,i.split("."))||(N(t,i.split("."),s[i]),n&&(f[i]=!0),(e[i]||[]).forEach((function(e){M(t,e.split("."))||N(t,e.split("."),s[i])})))}))}function M(t,e){let s=t;o["dot-notation"]||(e=[e.join(".")]),e.slice(0,-1).forEach((function(t){s=s[t]||{}}));const n=e[e.length-1];return"object"==typeof s&&n in s}function N(t,e,s){let n=t;o["dot-notation"]||(e=[e.join(".")]),e.slice(0,-1).forEach((function(t){t=B(t),"object"==typeof n&&void 0===n[t]&&(n[t]={}),"object"!=typeof n[t]||Array.isArray(n[t])?(Array.isArray(n[t])?n[t].push({}):n[t]=[n[t],{}],n=n[t][n[t].length-1]):n=n[t]}));const i=B(e[e.length-1]),r=D(e.join("."),g.arrays),a=Array.isArray(s);let c=o["duplicate-arguments-array"];!c&&D(i,g.nargs)&&(c=!0,(!V(n[i])&&1===g.nargs[i]||Array.isArray(n[i])&&n[i].length===g.nargs[i])&&(n[i]=void 0)),s===U()?n[i]=U(n[i]):Array.isArray(n[i])?c&&r&&a?n[i]=o["flatten-duplicate-arrays"]?n[i].concat(s):(Array.isArray(n[i][0])?n[i]:[n[i]]).concat([s]):c||Boolean(r)!==Boolean(a)?n[i]=n[i].concat([s]):n[i]=s:void 0===n[i]&&r?n[i]=a?s:[s]:!c||void 0===n[i]||D(i,g.counts)||D(i,g.bools)?n[i]=s:n[i]=[n[i],s]}function D(t,e){const s=[].concat(g.aliases[t]||[],t),n=Object.keys(e),i=s.find((t=>n.includes(t)));return!!i&&e[i]}function I(t){const e=Object.keys(g);return[].concat(e.map((t=>g[t]))).some((function(e){return Array.isArray(e)?e.includes(t):e[t]}))}function R(t){return o["unknown-options-as-args"]&&function(t){if(t=t.replace(/^-{3,}/,"--"),t.match(m))return!1;if(function(t){if(t.match(m)||!t.match(/^-[^-]+/))return!1;let e,s=!0;const n=t.slice(1).split("");for(let i=0;i<n.length;i++){if(e=t.slice(i+2),!I(n[i])){s=!1;break}if(n[i+1]&&"="===n[i+1]||"-"===e||/[A-Za-z]/.test(n[i])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(e)||n[i+1]&&n[i+1].match(/\W/))break}return s}(t))return!1;return!function(t,...e){return[].concat(...e).some((function(e){const s=t.match(e);return s&&I(s[1])}))}(t,/^-+([^=]+?)=[\s\S]*$/,y,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}(t)}function H(t){return D(t,g.bools)||D(t,g.counts)||!(`${t}`in a)?(e=function(t){let e=L.BOOLEAN;return D(t,g.strings)?e=L.STRING:D(t,g.numbers)?e=L.NUMBER:D(t,g.bools)?e=L.BOOLEAN:D(t,g.arrays)&&(e=L.ARRAY),e}(t),{[L.BOOLEAN]:!0,[L.STRING]:"",[L.NUMBER]:void 0,[L.ARRAY]:[]}[e]):a[t];var e}function V(t){return void 0===t}return C(v,!0),C(v,!1),function(t){const e=Object.create(null);S(e,g.aliases,a),Object.keys(g.configs).forEach((function(s){const n=t[s]||e[s];if(n)try{let t=null;const e=T.resolve(T.cwd(),n),i=g.configs[s];if("function"==typeof i){try{t=i(e)}catch(e){t=e}if(t instanceof Error)return void(b=t)}else t=T.require(e);P(t)}catch(e){"PermissionDenied"===e.name?b=e:t[s]&&(b=Error(p("Invalid JSON config file: %s",n)))}}))}(v),void 0!==c&&c.forEach((function(t){P(t)})),S(v,g.aliases,a,!0),function(t){let e;const s=new Set;Object.keys(t).forEach((function(n){if(!s.has(n)&&(e=D(n,g.coercions),"function"==typeof e))try{const i=$(n,e(t[n]));[].concat(g.aliases[n]||[],n).forEach((e=>{s.add(e),t[e]=i}))}catch(t){b=t}}))}(v),o["set-placeholder-key"]&&function(t){g.keys.forEach((e=>{~e.indexOf(".")||void 0===t[e]&&(t[e]=void 0)}))}(v),Object.keys(g.counts).forEach((function(t){M(v,t.split("."))||j(t,0)})),h&&w.length&&(v[d]=[]),w.forEach((function(t){v[d].push(t)})),o["camel-case-expansion"]&&o["strip-dashed"]&&Object.keys(v).filter((t=>"--"!==t&&t.includes("-"))).forEach((t=>{delete v[t]})),o["strip-aliased"]&&[].concat(...Object.keys(r).map((t=>r[t]))).forEach((t=>{o["camel-case-expansion"]&&t.includes("-")&&delete v[t.split(".").map((t=>z(t))).join(".")],delete v[t]})),{aliases:Object.assign({},g.aliases),argv:Object.assign(k,v),configuration:o,defaulted:Object.assign({},f),error:b,newAliases:Object.assign({},u)}}}({cwd:process.cwd,env:()=>G,format:p,normalize:n,resolve:e,require:t=>{if("undefined"!=typeof require)return require(t);if(t.match(/\.json$/))return JSON.parse(u(t,"utf8"));throw Error("only .json config files are supported in ESM")}}),Q=function(t,e){return K.parse(t.slice(),e).argv};function Z(){return process.versions.electron&&!process.defaultApp?0:1}Q.detailed=function(t,e){return K.parse(t.slice(),e)},Q.camelCase=z,Q.decamelize=W,Q.looksLikeNumber=F;class X extends Error{constructor(t){super(t||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,X)}}var tt={fs:{readFileSync:u,writeFile:f},format:p,resolve:e,exists:t=>{try{return h(t).isFile()}catch(t){return!1}}};let et;class st{constructor(t){t=t||{},this.directory=t.directory||"./locales",this.updateFiles="boolean"!=typeof t.updateFiles||t.updateFiles,this.locale=t.locale||"en",this.fallbackToLanguage="boolean"!=typeof t.fallbackToLanguage||t.fallbackToLanguage,this.cache=Object.create(null),this.writeQueue=[]}__(...t){if("string"!=typeof arguments[0])return this._taggedLiteral(arguments[0],...arguments);const e=t.shift();let s=function(){};return"function"==typeof t[t.length-1]&&(s=t.pop()),s=s||function(){},this.cache[this.locale]||this._readLocaleFile(),!this.cache[this.locale][e]&&this.updateFiles?(this.cache[this.locale][e]=e,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:s})):s(),et.format.apply(et.format,[this.cache[this.locale][e]||e].concat(t))}__n(){const t=Array.prototype.slice.call(arguments),e=t.shift(),s=t.shift(),n=t.shift();let i=function(){};"function"==typeof t[t.length-1]&&(i=t.pop()),this.cache[this.locale]||this._readLocaleFile();let r=1===n?e:s;if(this.cache[this.locale][e]){r=this.cache[this.locale][e][1===n?"one":"other"]}!this.cache[this.locale][e]&&this.updateFiles?(this.cache[this.locale][e]={one:e,other:s},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:i})):i();const o=[r];return~r.indexOf("%d")&&o.push(n),et.format.apply(et.format,o.concat(t))}setLocale(t){this.locale=t}getLocale(){return this.locale}updateLocale(t){this.cache[this.locale]||this._readLocaleFile();for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(this.cache[this.locale][e]=t[e])}_taggedLiteral(t,...e){let s="";return t.forEach((function(t,n){const i=e[n+1];s+=t,void 0!==i&&(s+="%s")})),this.__.apply(this,[s].concat([].slice.call(e,1)))}_enqueueWrite(t){this.writeQueue.push(t),1===this.writeQueue.length&&this._processWriteQueue()}_processWriteQueue(){const t=this,e=this.writeQueue[0],s=e.directory,n=e.locale,i=e.cb,r=this._resolveLocaleFile(s,n),o=JSON.stringify(this.cache[n],null,2);et.fs.writeFile(r,o,"utf-8",(function(e){t.writeQueue.shift(),t.writeQueue.length>0&&t._processWriteQueue(),i(e)}))}_readLocaleFile(){let t={};const e=this._resolveLocaleFile(this.directory,this.locale);try{et.fs.readFileSync&&(t=JSON.parse(et.fs.readFileSync(e,"utf-8")))}catch(s){if(s instanceof SyntaxError&&(s.message="syntax error in "+e),"ENOENT"!==s.code)throw s;t={}}this.cache[this.locale]=t}_resolveLocaleFile(t,e){let s=et.resolve(t,"./",e+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(s)&&~e.lastIndexOf("_")){const n=et.resolve(t,"./",e.split("_")[0]+".json");this._fileExistsSync(n)&&(s=n)}return s}_fileExistsSync(t){return et.exists(t)}}const nt="loading a directory of commands is not supported yet for ESM";let it;try{it=m(import.meta.url)}catch(t){it=process.cwd()}var rt,ot={assert:{notStrictEqual:a,strictEqual:c},cliui:function(t){return function(t,e){return N=e,new S({width:(null==t?void 0:t.width)||("object"==typeof process&&process.stdout&&process.stdout.columns?process.stdout.columns:80),wrap:null==t?void 0:t.wrap})}(t,{stringWidth:t=>[...t].length,stripAnsi:I,wrap:R})},findUp:function(t,n){let i,r=e(".",t);for(h(r).isDirectory()||(r=s(r));;){if(i=n(r,d(r)),i)return e(r,i);if(r=s(i=r),i===r)break}},getEnv:t=>process.env[t],inspect:g,getCallerFile:()=>{throw new X(nt)},getProcessArgvBin:function(){return process.argv[Z()]},mainFilename:it.substring(0,it.lastIndexOf("node_modules"))||process.cwd(),Parser:Q,path:{basename:i,dirname:s,extname:r,relative:o,resolve:e},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(t,e)=>process.emitWarning(t,e),execPath:()=>process.execPath,exit:process.exit,nextTick:process.nextTick,stdColumns:void 0!==process.stdout.columns?process.stdout.columns:null},readFileSync:u,require:()=>{throw new X("require is not supported by ESM")},requireDirectory:()=>{throw new X(nt)},stringWidth:t=>[...t].length,y18n:(rt={directory:e(it,"../../../locales"),updateFiles:!1},function(t,e){et=e;const s=new st(t);return{__:s.__.bind(s),__n:s.__n.bind(s),setLocale:s.setLocale.bind(s),getLocale:s.getLocale.bind(s),updateLocale:s.updateLocale.bind(s),locale:s.locale}}(rt,tt))};function at(t,e,s,n){s.assert.notStrictEqual(t,e,n)}function ct(t,e){e.assert.strictEqual(typeof t,"string")}function lt(t){return Object.keys(t)}function ht(t){return!!t&&!!t.then&&"function"==typeof t.then}function dt(t){const e=t.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),s=/\.*[\][<>]/g,n=e.shift();if(!n)throw new Error(`No command found in: ${t}`);const i={cmd:n.replace(s,""),demanded:[],optional:[]};return e.forEach(((t,n)=>{let r=!1;t=t.replace(/\s/g,""),/\.+[\]>]/.test(t)&&n===e.length-1&&(r=!0),/^\[/.test(t)?i.optional.push({cmd:t.replace(s,"").split("|"),variadic:r}):i.demanded.push({cmd:t.replace(s,"").split("|"),variadic:r})})),i}const ut=["first","second","third","fourth","fifth","sixth"];function ft(t,e,s){try{let n=0;const[i,r,o]="object"==typeof t?[{demanded:[],optional:[]},t,e]:[dt(`cmd ${t}`),e,s],a=[].slice.call(r);for(;a.length&&void 0===a[a.length-1];)a.pop();const c=o||a.length;if(c<i.demanded.length)throw new X(`Not enough arguments provided. Expected ${i.demanded.length} but received ${a.length}.`);const l=i.demanded.length+i.optional.length;if(c>l)throw new X(`Too many arguments provided. Expected max ${l} but received ${c}.`);i.demanded.forEach((t=>{const e=pt(a.shift());0===t.cmd.filter((t=>t===e||"*"===t)).length&&gt(e,t.cmd,n),n+=1})),i.optional.forEach((t=>{if(0===a.length)return;const e=pt(a.shift());0===t.cmd.filter((t=>t===e||"*"===t)).length&&gt(e,t.cmd,n),n+=1}))}catch(t){console.warn(t.stack)}}function pt(t){return Array.isArray(t)?"array":null===t?"null":typeof t}function gt(t,e,s){throw new X(`Invalid ${ut[s]||"manyith"} argument. Expected ${e.join(" or ")} but received ${t}.`)}class mt{constructor(t){this.globalMiddleware=[],this.frozens=[],this.yargs=t}addMiddleware(t,e,s=!0,n=!1){if(ft("<array|function> [boolean] [boolean] [boolean]",[t,e,s],arguments.length),Array.isArray(t)){for(let n=0;n<t.length;n++){if("function"!=typeof t[n])throw Error("middleware must be a function");const i=t[n];i.applyBeforeValidation=e,i.global=s}Array.prototype.push.apply(this.globalMiddleware,t)}else if("function"==typeof t){const i=t;i.applyBeforeValidation=e,i.global=s,i.mutates=n,this.globalMiddleware.push(t)}return this.yargs}addCoerceMiddleware(t,e){const s=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((t=>{const n=[...s[e]||[],e];return!t.option||!n.includes(t.option)})),t.option=e,this.addMiddleware(t,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){const t=this.frozens.pop();void 0!==t&&(this.globalMiddleware=t)}reset(){this.globalMiddleware=this.globalMiddleware.filter((t=>t.global))}}function yt(t,e,s,n){return s.reduce(((t,s)=>{if(s.applyBeforeValidation!==n)return t;if(s.mutates){if(s.applied)return t;s.applied=!0}if(ht(t))return t.then((t=>Promise.all([t,s(t,e)]))).then((([t,e])=>Object.assign(t,e)));{const n=s(t,e);return ht(n)?n.then((e=>Object.assign(t,e))):Object.assign(t,n)}}),t)}function bt(t,e,s=(t=>{throw t})){try{const s="function"==typeof t?t():t;return ht(s)?s.then((t=>e(t))):e(s)}catch(t){return s(t)}}const wt=/(^\*)|(^\$0)/;class vt{constructor(t,e,s,n){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=n,this.usage=t,this.globalMiddleware=s,this.validation=e}addDirectory(t,e,s,n){"boolean"!=typeof(n=n||{}).recurse&&(n.recurse=!1),Array.isArray(n.extensions)||(n.extensions=["js"]);const i="function"==typeof n.visit?n.visit:t=>t;n.visit=(t,e,s)=>{const n=i(t,e,s);if(n){if(this.requireCache.has(e))return n;this.requireCache.add(e),this.addHandler(n)}return n},this.shim.requireDirectory({require:e,filename:s},t,n)}addHandler(t,e,s,n,i,r){let o=[];const a=function(t){return t?t.map((t=>(t.applyBeforeValidation=!1,t))):[]}(i);if(n=n||(()=>{}),Array.isArray(t))if(function(t){return t.every((t=>"string"==typeof t))}(t))[t,...o]=t;else for(const e of t)this.addHandler(e);else{if(function(t){return"object"==typeof t&&!Array.isArray(t)}(t)){let e=Array.isArray(t.command)||"string"==typeof t.command?t.command:this.moduleName(t);return t.aliases&&(e=[].concat(e).concat(t.aliases)),void this.addHandler(e,this.extractDesc(t),t.builder,t.handler,t.middlewares,t.deprecated)}if(kt(s))return void this.addHandler([t].concat(o),e,s.builder,s.handler,s.middlewares,s.deprecated)}if("string"==typeof t){const i=dt(t);o=o.map((t=>dt(t).cmd));let c=!1;const l=[i.cmd].concat(o).filter((t=>!wt.test(t)||(c=!0,!1)));0===l.length&&c&&l.push("$0"),c&&(i.cmd=l[0],o=l.slice(1),t=t.replace(wt,i.cmd)),o.forEach((t=>{this.aliasMap[t]=i.cmd})),!1!==e&&this.usage.command(t,e,c,o,r),this.handlers[i.cmd]={original:t,description:e,handler:n,builder:s||{},middlewares:a,deprecated:r,demanded:i.demanded,optional:i.optional},c&&(this.defaultCommand=this.handlers[i.cmd])}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(t,e,s,n,i,r){const o=this.handlers[t]||this.handlers[this.aliasMap[t]]||this.defaultCommand,a=e.getInternalMethods().getContext(),c=a.commands.slice(),l=!t;t&&(a.commands.push(t),a.fullCommands.push(o.original));const h=this.applyBuilderUpdateUsageAndParse(l,o,e,s.aliases,c,n,i,r);return ht(h)?h.then((t=>this.applyMiddlewareAndGetResult(l,o,t.innerArgv,a,i,t.aliases,e))):this.applyMiddlewareAndGetResult(l,o,h.innerArgv,a,i,h.aliases,e)}applyBuilderUpdateUsageAndParse(t,e,s,n,i,r,o,a){const c=e.builder;let l=s;if(Ot(c)){s.getInternalMethods().getUsageInstance().freeze();const h=c(s.getInternalMethods().reset(n),a);if(ht(h))return h.then((n=>{var a;return l=(a=n)&&"function"==typeof a.getInternalMethods?n:s,this.parseAndUpdateUsage(t,e,l,i,r,o)}))}else(function(t){return"object"==typeof t})(c)&&(s.getInternalMethods().getUsageInstance().freeze(),l=s.getInternalMethods().reset(n),Object.keys(e.builder).forEach((t=>{l.option(t,c[t])})));return this.parseAndUpdateUsage(t,e,l,i,r,o)}parseAndUpdateUsage(t,e,s,n,i,r){t&&s.getInternalMethods().getUsageInstance().unfreeze(!0),this.shouldUpdateUsage(s)&&s.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(n,e),e.description);const o=s.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,i,r);return ht(o)?o.then((t=>({aliases:s.parsed.aliases,innerArgv:t}))):{aliases:s.parsed.aliases,innerArgv:o}}shouldUpdateUsage(t){return!t.getInternalMethods().getUsageInstance().getUsageDisabled()&&0===t.getInternalMethods().getUsageInstance().getUsage().length}usageFromParentCommandsCommandHandler(t,e){const s=wt.test(e.original)?e.original.replace(wt,"").trim():e.original,n=t.filter((t=>!wt.test(t)));return n.push(s),`$0 ${n.join(" ")}`}handleValidationAndGetResult(t,e,s,n,i,r,o,a){if(!r.getInternalMethods().getHasOutput()){const e=r.getInternalMethods().runValidation(i,a,r.parsed.error,t);s=bt(s,(t=>(e(t),t)))}if(e.handler&&!r.getInternalMethods().getHasOutput()){r.getInternalMethods().setHasOutput();const n=!!r.getOptions().configuration["populate--"];r.getInternalMethods().postProcess(s,n,!1,!1),s=bt(s=yt(s,r,o,!1),(t=>{const s=e.handler(t);return ht(s)?s.then((()=>t)):t})),t||r.getInternalMethods().getUsageInstance().cacheHelpMessage(),ht(s)&&!r.getInternalMethods().hasParseCallback()&&s.catch((t=>{try{r.getInternalMethods().getUsageInstance().fail(null,t)}catch(t){}}))}return t||(n.commands.pop(),n.fullCommands.pop()),s}applyMiddlewareAndGetResult(t,e,s,n,i,r,o){let a={};if(i)return s;o.getInternalMethods().getHasOutput()||(a=this.populatePositionals(e,s,n,o));const c=this.globalMiddleware.getMiddleware().slice(0).concat(e.middlewares),l=yt(s,o,c,!0);return ht(l)?l.then((s=>this.handleValidationAndGetResult(t,e,s,n,r,o,c,a))):this.handleValidationAndGetResult(t,e,l,n,r,o,c,a)}populatePositionals(t,e,s,n){e._=e._.slice(s.commands.length);const i=t.demanded.slice(0),r=t.optional.slice(0),o={};for(this.validation.positionalCount(i.length,e._.length);i.length;){const t=i.shift();this.populatePositional(t,e,o)}for(;r.length;){const t=r.shift();this.populatePositional(t,e,o)}return e._=s.commands.concat(e._.map((t=>""+t))),this.postProcessPositionals(e,o,this.cmdToParseOptions(t.original),n),o}populatePositional(t,e,s){const n=t.cmd[0];t.variadic?s[n]=e._.splice(0).map(String):e._.length&&(s[n]=[String(e._.shift())])}cmdToParseOptions(t){const e={array:[],default:{},alias:{},demand:{}},s=dt(t);return s.demanded.forEach((t=>{const[s,...n]=t.cmd;t.variadic&&(e.array.push(s),e.default[s]=[]),e.alias[s]=n,e.demand[s]=!0})),s.optional.forEach((t=>{const[s,...n]=t.cmd;t.variadic&&(e.array.push(s),e.default[s]=[]),e.alias[s]=n})),e}postProcessPositionals(t,e,s,n){const i=Object.assign({},n.getOptions());i.default=Object.assign(s.default,i.default);for(const t of Object.keys(s.alias))i.alias[t]=(i.alias[t]||[]).concat(s.alias[t]);i.array=i.array.concat(s.array),i.config={};const r=[];if(Object.keys(e).forEach((t=>{e[t].map((e=>{i.configuration["unknown-options-as-args"]&&(i.key[t]=!0),r.push(`--${t}`),r.push(e)}))})),!r.length)return;const o=Object.assign({},i.configuration,{"populate--":!1}),a=this.shim.Parser.detailed(r,Object.assign({},i,{configuration:o}));if(a.error)n.getInternalMethods().getUsageInstance().fail(a.error.message,a.error);else{const s=Object.keys(e);Object.keys(e).forEach((t=>{s.push(...a.aliases[t])})),Object.keys(a.argv).forEach((i=>{s.includes(i)&&(e[i]||(e[i]=a.argv[i]),!this.isInConfigs(n,i)&&!this.isDefaulted(n,i)&&Object.prototype.hasOwnProperty.call(t,i)&&Object.prototype.hasOwnProperty.call(a.argv,i)&&(Array.isArray(t[i])||Array.isArray(a.argv[i]))?t[i]=[].concat(t[i],a.argv[i]):t[i]=a.argv[i])}))}}isDefaulted(t,e){const{default:s}=t.getOptions();return Object.prototype.hasOwnProperty.call(s,e)||Object.prototype.hasOwnProperty.call(s,this.shim.Parser.camelCase(e))}isInConfigs(t,e){const{configObjects:s}=t.getOptions();return s.some((t=>Object.prototype.hasOwnProperty.call(t,e)))||s.some((t=>Object.prototype.hasOwnProperty.call(t,this.shim.Parser.camelCase(e))))}runDefaultBuilderOn(t){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(t)){const e=wt.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");t.getInternalMethods().getUsageInstance().usage(e,this.defaultCommand.description)}const e=this.defaultCommand.builder;if(Ot(e))return e(t,!0);kt(e)||Object.keys(e).forEach((s=>{t.option(s,e[s])}))}moduleName(t){const e=function(t){if("undefined"==typeof require)return null;for(let e,s=0,n=Object.keys(require.cache);s<n.length;s++)if(e=require.cache[n[s]],e.exports===t)return e;return null}(t);if(!e)throw new Error(`No command name given for module: ${this.shim.inspect(t)}`);return this.commandFromFilename(e.filename)}commandFromFilename(t){return this.shim.path.basename(t,this.shim.path.extname(t))}extractDesc({describe:t,description:e,desc:s}){for(const n of[t,e,s]){if("string"==typeof n||!1===n)return n;at(n,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){const t=this.frozens.pop();at(t,void 0,this.shim),({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=t)}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function kt(t){return"object"==typeof t&&!!t.builder&&"function"==typeof t.handler}function Ot(t){return"function"==typeof t}function At(t={},e=(()=>!0)){const s={};return lt(t).forEach((n=>{e(n,t[n])&&(s[n]=t[n])})),s}function Et(t){"undefined"!=typeof process&&[process.stdout,process.stderr].forEach((e=>{const s=e;s._handle&&s.isTTY&&"function"==typeof s._handle.setBlocking&&s._handle.setBlocking(t)}))}function jt(t){return"boolean"==typeof t}function _t(t,e){const s=e.y18n.__,n={},i=[];n.failFn=function(t){i.push(t)};let r=null,o=null,a=!0;n.showHelpOnFail=function(e=!0,s){const[i,c]="string"==typeof e?[!0,e]:[e,s];return t.getInternalMethods().isGlobalContext()&&(o=c),r=c,a=i,n};let c=!1;n.fail=function(e,s){const l=t.getInternalMethods().getLoggerInstance();if(!i.length){if(t.getExitProcess()&&Et(!0),!c){c=!0,a&&(t.showHelp("error"),l.error()),(e||s)&&l.error(e||s);const n=r||o;n&&((e||s)&&l.error(""),l.error(n))}if(s=s||new X(e),t.getExitProcess())return t.exit(1);if(t.getInternalMethods().hasParseCallback())return t.exit(1,s);throw s}for(let t=i.length-1;t>=0;--t){const r=i[t];if(jt(r)){if(s)throw s;if(e)throw Error(e)}else r(e,s,n)}};let l=[],h=!1;n.usage=(t,e)=>null===t?(h=!0,l=[],n):(h=!1,l.push([t,e||""]),n),n.getUsage=()=>l,n.getUsageDisabled=()=>h,n.getPositionalGroupName=()=>s("Positionals:");let d=[];n.example=(t,e)=>{d.push([t,e||""])};let u=[];n.command=function(t,e,s,n,i=!1){s&&(u=u.map((t=>(t[2]=!1,t)))),u.push([t,e||"",s,n,i])},n.getCommands=()=>u;let f={};n.describe=function(t,e){Array.isArray(t)?t.forEach((t=>{n.describe(t,e)})):"object"==typeof t?Object.keys(t).forEach((e=>{n.describe(e,t[e])})):f[t]=e},n.getDescriptions=()=>f;let p=[];n.epilog=t=>{p.push(t)};let g,m=!1;n.wrap=t=>{m=!0,g=t},n.getWrap=()=>e.getEnv("YARGS_DISABLE_WRAP")?null:(m||(g=function(){const t=80;return e.process.stdColumns?Math.min(t,e.process.stdColumns):t}(),m=!0),g);const y="__yargsString__:";function b(t,s,n){let i=0;return Array.isArray(t)||(t=Object.values(t).map((t=>[t]))),t.forEach((t=>{i=Math.max(e.stringWidth(n?`${n} ${Pt(t[0])}`:Pt(t[0]))+$t(t[0]),i)})),s&&(i=Math.min(i,parseInt((.5*s).toString(),10))),i}let w;function v(e){return t.getOptions().hiddenOptions.indexOf(e)<0||t.parsed.argv[t.getOptions().showHiddenOpt]}function k(t,e){let n=`[${s("default:")} `;if(void 0===t&&!e)return null;if(e)n+=e;else switch(typeof t){case"string":n+=`"${t}"`;break;case"object":n+=JSON.stringify(t);break;default:n+=t}return`${n}]`}n.deferY18nLookup=t=>y+t,n.help=function(){if(w)return w;!function(){const e=t.getDemandedOptions(),s=t.getOptions();(Object.keys(s.alias)||[]).forEach((i=>{s.alias[i].forEach((r=>{f[r]&&n.describe(i,f[r]),r in e&&t.demandOption(i,e[r]),s.boolean.includes(r)&&t.boolean(i),s.count.includes(r)&&t.count(i),s.string.includes(r)&&t.string(i),s.normalize.includes(r)&&t.normalize(i),s.array.includes(r)&&t.array(i),s.number.includes(r)&&t.number(i)}))}))}();const i=t.customScriptName?t.$0:e.path.basename(t.$0),r=t.getDemandedOptions(),o=t.getDemandedCommands(),a=t.getDeprecatedOptions(),c=t.getGroups(),g=t.getOptions();let m=[];m=m.concat(Object.keys(f)),m=m.concat(Object.keys(r)),m=m.concat(Object.keys(o)),m=m.concat(Object.keys(g.default)),m=m.filter(v),m=Object.keys(m.reduce(((t,e)=>("_"!==e&&(t[e]=!0),t)),{}));const O=n.getWrap(),A=e.cliui({width:O,wrap:!!O});if(!h)if(l.length)l.forEach((t=>{A.div({text:`${t[0].replace(/\$0/g,i)}`}),t[1]&&A.div({text:`${t[1]}`,padding:[1,0,0,0]})})),A.div();else if(u.length){let t=null;t=o._?`${i} <${s("command")}>\n`:`${i} [${s("command")}]\n`,A.div(`${t}`)}if(u.length>1||1===u.length&&!u[0][2]){A.div(s("Commands:"));const e=t.getInternalMethods().getContext(),n=e.commands.length?`${e.commands.join(" ")} `:"";!0===t.getInternalMethods().getParserConfiguration()["sort-commands"]&&(u=u.sort(((t,e)=>t[0].localeCompare(e[0]))));const r=i?`${i} `:"";u.forEach((t=>{const e=`${r}${n}${t[0].replace(/^\$0 ?/,"")}`;A.span({text:e,padding:[0,2,0,2],width:b(u,O,`${i}${n}`)+4},{text:t[1]});const o=[];t[2]&&o.push(`[${s("default")}]`),t[3]&&t[3].length&&o.push(`[${s("aliases:")} ${t[3].join(", ")}]`),t[4]&&("string"==typeof t[4]?o.push(`[${s("deprecated: %s",t[4])}]`):o.push(`[${s("deprecated")}]`)),o.length?A.div({text:o.join(" "),padding:[0,0,0,2],align:"right"}):A.div()})),A.div()}const E=(Object.keys(g.alias)||[]).concat(Object.keys(t.parsed.newAliases)||[]);m=m.filter((e=>!t.parsed.newAliases[e]&&E.every((t=>-1===(g.alias[t]||[]).indexOf(e)))));const j=s("Options:");c[j]||(c[j]=[]),function(t,e,s,n){let i=[],r=null;Object.keys(s).forEach((t=>{i=i.concat(s[t])})),t.forEach((t=>{r=[t].concat(e[t]),r.some((t=>-1!==i.indexOf(t)))||s[n].push(t)}))}(m,g.alias,c,j);const _=t=>/^--/.test(Pt(t)),x=Object.keys(c).filter((t=>c[t].length>0)).map((t=>({groupName:t,normalizedKeys:c[t].filter(v).map((t=>{if(E.includes(t))return t;for(let e,s=0;void 0!==(e=E[s]);s++)if((g.alias[e]||[]).includes(t))return e;return t}))}))).filter((({normalizedKeys:t})=>t.length>0)).map((({groupName:t,normalizedKeys:e})=>{const s=e.reduce(((e,s)=>(e[s]=[s].concat(g.alias[s]||[]).map((e=>t===n.getPositionalGroupName()?e:(/^[0-9]$/.test(e)?g.boolean.includes(s)?"-":"--":e.length>1?"--":"-")+e)).sort(((t,e)=>_(t)===_(e)?0:_(t)?1:-1)).join(", "),e)),{});return{groupName:t,normalizedKeys:e,switches:s}}));if(x.filter((({groupName:t})=>t!==n.getPositionalGroupName())).some((({normalizedKeys:t,switches:e})=>!t.every((t=>_(e[t])))))&&x.filter((({groupName:t})=>t!==n.getPositionalGroupName())).forEach((({normalizedKeys:t,switches:e})=>{t.forEach((t=>{var s,n;_(e[t])&&(e[t]=(s=e[t],n=4,xt(s)?{text:s.text,indentation:s.indentation+n}:{text:s,indentation:n}))}))})),x.forEach((({groupName:e,normalizedKeys:i,switches:o})=>{A.div(e),i.forEach((e=>{const i=o[e];let c=f[e]||"",l=null;c.includes(y)&&(c=s(c.substring(16))),g.boolean.includes(e)&&(l=`[${s("boolean")}]`),g.count.includes(e)&&(l=`[${s("count")}]`),g.string.includes(e)&&(l=`[${s("string")}]`),g.normalize.includes(e)&&(l=`[${s("string")}]`),g.array.includes(e)&&(l=`[${s("array")}]`),g.number.includes(e)&&(l=`[${s("number")}]`);const h=[e in a?(d=a[e],"string"==typeof d?`[${s("deprecated: %s",d)}]`:`[${s("deprecated")}]`):null,l,e in r?`[${s("required")}]`:null,g.choices&&g.choices[e]?`[${s("choices:")} ${n.stringifiedValues(g.choices[e])}]`:null,k(g.default[e],g.defaultDescription[e])].filter(Boolean).join(" ");var d;A.span({text:Pt(i),padding:[0,2,0,2+$t(i)],width:b(o,O)+4},c);const u=!0===t.getInternalMethods().getUsageConfiguration()["hide-types"];h&&!u?A.div({text:h,padding:[0,0,0,2],align:"right"}):A.div()})),A.div()})),d.length&&(A.div(s("Examples:")),d.forEach((t=>{t[0]=t[0].replace(/\$0/g,i)})),d.forEach((t=>{""===t[1]?A.div({text:t[0],padding:[0,2,0,2]}):A.div({text:t[0],padding:[0,2,0,2],width:b(d,O)+4},{text:t[1]})})),A.div()),p.length>0){const t=p.map((t=>t.replace(/\$0/g,i))).join("\n");A.div(`${t}\n`)}return A.toString().replace(/\s*$/,"")},n.cacheHelpMessage=function(){w=this.help()},n.clearCachedHelpMessage=function(){w=void 0},n.hasCachedHelpMessage=function(){return!!w},n.showHelp=e=>{const s=t.getInternalMethods().getLoggerInstance();e||(e="error");("function"==typeof e?e:s[e])(n.help())},n.functionDescription=t=>["(",t.name?e.Parser.decamelize(t.name,"-"):s("generated-value"),")"].join(""),n.stringifiedValues=function(t,e){let s="";const n=e||", ",i=[].concat(t);return t&&i.length?(i.forEach((t=>{s.length&&(s+=n),s+=JSON.stringify(t)})),s):s};let O=null;n.version=t=>{O=t},n.showVersion=e=>{const s=t.getInternalMethods().getLoggerInstance();e||(e="error");("function"==typeof e?e:s[e])(O)},n.reset=function(t){return r=null,c=!1,l=[],h=!1,p=[],d=[],u=[],f=At(f,(e=>!t[e])),n};const A=[];return n.freeze=function(){A.push({failMessage:r,failureOutput:c,usages:l,usageDisabled:h,epilogs:p,examples:d,commands:u,descriptions:f})},n.unfreeze=function(t=!1){const e=A.pop();e&&(t?(f={...e.descriptions,...f},u=[...e.commands,...u],l=[...e.usages,...l],d=[...e.examples,...d],p=[...e.epilogs,...p]):({failMessage:r,failureOutput:c,usages:l,usageDisabled:h,epilogs:p,examples:d,commands:u,descriptions:f}=e))},n}function xt(t){return"object"==typeof t}function $t(t){return xt(t)?t.indentation:0}function Pt(t){return xt(t)?t.text:t}class Ct{constructor(t,e,s,n){var i,r,o;this.yargs=t,this.usage=e,this.command=s,this.shim=n,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=null!==(o=(null===(i=this.shim.getEnv("SHELL"))||void 0===i?void 0:i.includes("zsh"))||(null===(r=this.shim.getEnv("ZSH_NAME"))||void 0===r?void 0:r.includes("zsh")))&&void 0!==o&&o}defaultCompletion(t,e,s,n){const i=this.command.getCommandHandlers();for(let e=0,s=t.length;e<s;++e)if(i[t[e]]&&i[t[e]].builder){const s=i[t[e]].builder;if(Ot(s)){this.indexAfterLastReset=e+1;const t=this.yargs.getInternalMethods().reset();return s(t,!0),t.argv}}const r=[];this.commandCompletions(r,t,s),this.optionCompletions(r,t,e,s),this.choicesFromOptionsCompletions(r,t,e,s),this.choicesFromPositionalsCompletions(r,t,e,s),n(null,r)}commandCompletions(t,e,s){const n=this.yargs.getInternalMethods().getContext().commands;s.match(/^-/)||n[n.length-1]===s||this.previousArgHasChoices(e)||this.usage.getCommands().forEach((s=>{const n=dt(s[0]).cmd;if(-1===e.indexOf(n))if(this.zshShell){const e=s[1]||"";t.push(n.replace(/:/g,"\\:")+":"+e)}else t.push(n)}))}optionCompletions(t,e,s,n){if((n.match(/^-/)||""===n&&0===t.length)&&!this.previousArgHasChoices(e)){const s=this.yargs.getOptions(),i=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(s.key).forEach((r=>{const o=!!s.configuration["boolean-negation"]&&s.boolean.includes(r);i.includes(r)||s.hiddenOptions.includes(r)||this.argsContainKey(e,r,o)||this.completeOptionKey(r,t,n,o&&!!s.default[r])}))}}choicesFromOptionsCompletions(t,e,s,n){if(this.previousArgHasChoices(e)){const s=this.getPreviousArgChoices(e);s&&s.length>0&&t.push(...s.map((t=>t.replace(/:/g,"\\:"))))}}choicesFromPositionalsCompletions(t,e,s,n){if(""===n&&t.length>0&&this.previousArgHasChoices(e))return;const i=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],r=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),o=i[s._.length-r-1];if(!o)return;const a=this.yargs.getOptions().choices[o]||[];for(const e of a)e.startsWith(n)&&t.push(e.replace(/:/g,"\\:"))}getPreviousArgChoices(t){if(t.length<1)return;let e=t[t.length-1],s="";if(!e.startsWith("-")&&t.length>1&&(s=e,e=t[t.length-2]),!e.startsWith("-"))return;const n=e.replace(/^-+/,""),i=this.yargs.getOptions(),r=[n,...this.yargs.getAliases()[n]||[]];let o;for(const t of r)if(Object.prototype.hasOwnProperty.call(i.key,t)&&Array.isArray(i.choices[t])){o=i.choices[t];break}return o?o.filter((t=>!s||t.startsWith(s))):void 0}previousArgHasChoices(t){const e=this.getPreviousArgChoices(t);return void 0!==e&&e.length>0}argsContainKey(t,e,s){const n=e=>-1!==t.indexOf((/^[^0-9]$/.test(e)?"-":"--")+e);if(n(e))return!0;if(s&&n(`no-${e}`))return!0;if(this.aliases)for(const t of this.aliases[e])if(n(t))return!0;return!1}completeOptionKey(t,e,s,n){var i,r,o,a;let c=t;if(this.zshShell){const e=this.usage.getDescriptions(),s=null===(r=null===(i=null==this?void 0:this.aliases)||void 0===i?void 0:i[t])||void 0===r?void 0:r.find((t=>{const s=e[t];return"string"==typeof s&&s.length>0})),n=s?e[s]:void 0,l=null!==(a=null!==(o=e[t])&&void 0!==o?o:n)&&void 0!==a?a:"";c=`${t.replace(/:/g,"\\:")}:${l.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}const l=!/^--/.test(s)&&(t=>/^[^0-9]$/.test(t))(t)?"-":"--";e.push(l+c),n&&e.push(l+"no-"+c)}customCompletion(t,e,s,n){if(at(this.customCompletionFunction,null,this.shim),this.customCompletionFunction.length<3){const t=this.customCompletionFunction(s,e);return ht(t)?t.then((t=>{this.shim.process.nextTick((()=>{n(null,t)}))})).catch((t=>{this.shim.process.nextTick((()=>{n(t,void 0)}))})):n(null,t)}return function(t){return t.length>3}(this.customCompletionFunction)?this.customCompletionFunction(s,e,((i=n)=>this.defaultCompletion(t,e,s,i)),(t=>{n(null,t)})):this.customCompletionFunction(s,e,(t=>{n(null,t)}))}getCompletion(t,e){const s=t.length?t[t.length-1]:"",n=this.yargs.parse(t,!0),i=this.customCompletionFunction?n=>this.customCompletion(t,n,s,e):n=>this.defaultCompletion(t,n,s,e);return ht(n)?n.then(i):i(n)}generateCompletionScript(t,e){let s=this.zshShell?'#compdef {{app_name}}\n###-begin-{{app_name}}-completions-###\n#\n# yargs command completion script\n#\n# Installation: {{app_path}} {{completion_command}} >> ~/.zshrc\n# or {{app_path}} {{completion_command}} >> ~/.zprofile on OSX.\n#\n_{{app_name}}_yargs_completions()\n{\n local reply\n local si=$IFS\n IFS=$\'\n\' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" {{app_path}} --get-yargs-completions "${words[@]}"))\n IFS=$si\n _describe \'values\' reply\n}\ncompdef _{{app_name}}_yargs_completions {{app_name}}\n###-end-{{app_name}}-completions-###\n':'###-begin-{{app_name}}-completions-###\n#\n# yargs command completion script\n#\n# Installation: {{app_path}} {{completion_command}} >> ~/.bashrc\n# or {{app_path}} {{completion_command}} >> ~/.bash_profile on OSX.\n#\n_{{app_name}}_yargs_completions()\n{\n local cur_word args type_list\n\n cur_word="${COMP_WORDS[COMP_CWORD]}"\n args=("${COMP_WORDS[@]}")\n\n # ask yargs to generate completions.\n type_list=$({{app_path}} --get-yargs-completions "${args[@]}")\n\n COMPREPLY=( $(compgen -W "${type_list}" -- ${cur_word}) )\n\n # if no match was found, fall back to filename completion\n if [ ${#COMPREPLY[@]} -eq 0 ]; then\n COMPREPLY=()\n fi\n\n return 0\n}\ncomplete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name}}\n###-end-{{app_name}}-completions-###\n';const n=this.shim.path.basename(t);return t.match(/\.js$/)&&(t=`./${t}`),s=s.replace(/{{app_name}}/g,n),s=s.replace(/{{completion_command}}/g,e),s.replace(/{{app_path}}/g,t)}registerFunction(t){this.customCompletionFunction=t}setParsed(t){this.aliases=t.aliases}}function St(t,e){if(0===t.length)return e.length;if(0===e.length)return t.length;const s=[];let n,i;for(n=0;n<=e.length;n++)s[n]=[n];for(i=0;i<=t.length;i++)s[0][i]=i;for(n=1;n<=e.length;n++)for(i=1;i<=t.length;i++)e.charAt(n-1)===t.charAt(i-1)?s[n][i]=s[n-1][i-1]:n>1&&i>1&&e.charAt(n-2)===t.charAt(i-1)&&e.charAt(n-1)===t.charAt(i-2)?s[n][i]=s[n-2][i-2]+1:s[n][i]=Math.min(s[n-1][i-1]+1,Math.min(s[n][i-1]+1,s[n-1][i]+1));return s[e.length][t.length]}const Mt=["$0","--","_"];let Nt,Dt=[];function It(t,e,s,n){Nt=n;let i={};if(Object.prototype.hasOwnProperty.call(t,"extends")){if("string"!=typeof t.extends)return i;const n=/\.json|\..*rc$/.test(t.extends);let r=null;if(n)r=function(t,e){return Nt.path.resolve(t,e)}(e,t.extends);else try{r=require.resolve(t.extends)}catch(e){return t}!function(t){if(Dt.indexOf(t)>-1)throw new X(`Circular extended configurations: '${t}'.`)}(r),Dt.push(r),i=n?JSON.parse(Nt.readFileSync(r,"utf8")):require(t.extends),delete t.extends,i=It(i,Nt.path.dirname(r),s,Nt)}return Dt=[],s?Rt(i,t):Object.assign({},i,t)}function Rt(t,e){const s={};function n(t){return t&&"object"==typeof t&&!Array.isArray(t)}Object.assign(s,t);for(const i of Object.keys(e))n(e[i])&&n(s[i])?s[i]=Rt(t[i],e[i]):s[i]=e[i];return s}var zt,Wt,Ft,Lt,Tt,Ut,Bt,Ht,Vt,qt,Yt,Jt,Gt,Kt,Qt,Zt,Xt,te,ee,se,ne,ie,re,oe,ae,ce,le,he,de,ue,fe,pe,ge,me,ye,be=function(t,e,s,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(t,s):i?i.value=s:e.set(t,s),s},we=function(t,e,s,n){if("a"===s&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?n:"a"===s?n.call(t):n?n.value:e.get(t)};const ve=Symbol("copyDoubleDash"),ke=Symbol("copyDoubleDash"),Oe=Symbol("deleteFromParserHintObject"),Ae=Symbol("emitWarning"),Ee=Symbol("freeze"),je=Symbol("getDollarZero"),_e=Symbol("getParserConfiguration"),xe=Symbol("getUsageConfiguration"),$e=Symbol("guessLocale"),Pe=Symbol("guessVersion"),Ce=Symbol("parsePositionalNumbers"),Se=Symbol("pkgUp"),Me=Symbol("populateParserHintArray"),Ne=Symbol("populateParserHintSingleValueDictionary"),De=Symbol("populateParserHintArrayDictionary"),Ie=Symbol("populateParserHintDictionary"),Re=Symbol("sanitizeKey"),ze=Symbol("setKey"),We=Symbol("unfreeze"),Fe=Symbol("validateAsync"),Le=Symbol("getCommandInstance"),Te=Symbol("getContext"),Ue=Symbol("getHasOutput"),Be=Symbol("getLoggerInstance"),He=Symbol("getParseContext"),Ve=Symbol("getUsageInstance"),qe=Symbol("getValidationInstance"),Ye=Symbol("hasParseCallback"),Je=Symbol("isGlobalContext"),Ge=Symbol("postProcess"),Ke=Symbol("rebase"),Qe=Symbol("reset"),Ze=Symbol("runYargsParserAndExecuteCommands"),Xe=Symbol("runValidation"),ts=Symbol("setHasOutput"),es=Symbol("kTrackManuallySetKeys");class ss{constructor(t=[],e,s,n){this.customScriptName=!1,this.parsed=!1,zt.set(this,void 0),Wt.set(this,void 0),Ft.set(this,{commands:[],fullCommands:[]}),Lt.set(this,null),Tt.set(this,null),Ut.set(this,"show-hidden"),Bt.set(this,null),Ht.set(this,!0),Vt.set(this,{}),qt.set(this,!0),Yt.set(this,[]),Jt.set(this,void 0),Gt.set(this,{}),Kt.set(this,!1),Qt.set(this,null),Zt.set(this,!0),Xt.set(this,void 0),te.set(this,""),ee.set(this,void 0),se.set(this,void 0),ne.set(this,{}),ie.set(this,null),re.set(this,null),oe.set(this,{}),ae.set(this,{}),ce.set(this,void 0),le.set(this,!1),he.set(this,void 0),de.set(this,!1),ue.set(this,!1),fe.set(this,!1),pe.set(this,void 0),ge.set(this,{}),me.set(this,null),ye.set(this,void 0),be(this,he,n,"f"),be(this,ce,t,"f"),be(this,Wt,e,"f"),be(this,se,s,"f"),be(this,Jt,new mt(this),"f"),this.$0=this[je](),this[Qe](),be(this,zt,we(this,zt,"f"),"f"),be(this,pe,we(this,pe,"f"),"f"),be(this,ye,we(this,ye,"f"),"f"),be(this,ee,we(this,ee,"f"),"f"),we(this,ee,"f").showHiddenOpt=we(this,Ut,"f"),be(this,Xt,this[ke](),"f")}addHelpOpt(t,e){return ft("[string|boolean] [string]",[t,e],arguments.length),we(this,Qt,"f")&&(this[Oe](we(this,Qt,"f")),be(this,Qt,null,"f")),!1===t&&void 0===e||(be(this,Qt,"string"==typeof t?t:"help","f"),this.boolean(we(this,Qt,"f")),this.describe(we(this,Qt,"f"),e||we(this,pe,"f").deferY18nLookup("Show help"))),this}help(t,e){return this.addHelpOpt(t,e)}addShowHiddenOpt(t,e){if(ft("[string|boolean] [string]",[t,e],arguments.length),!1===t&&void 0===e)return this;const s="string"==typeof t?t:we(this,Ut,"f");return this.boolean(s),this.describe(s,e||we(this,pe,"f").deferY18nLookup("Show hidden options")),we(this,ee,"f").showHiddenOpt=s,this}showHidden(t,e){return this.addShowHiddenOpt(t,e)}alias(t,e){return ft("<object|string|array> [string|array]",[t,e],arguments.length),this[De](this.alias.bind(this),"alias",t,e),this}array(t){return ft("<array|string>",[t],arguments.length),this[Me]("array",t),this[es](t),this}boolean(t){return ft("<array|string>",[t],arguments.length),this[Me]("boolean",t),this[es](t),this}check(t,e){return ft("<function> [boolean]",[t,e],arguments.length),this.middleware(((e,s)=>bt((()=>t(e,s.getOptions())),(s=>(s?("string"==typeof s||s instanceof Error)&&we(this,pe,"f").fail(s.toString(),s):we(this,pe,"f").fail(we(this,he,"f").y18n.__("Argument check failed: %s",t.toString())),e)),(t=>(we(this,pe,"f").fail(t.message?t.message:t.toString(),t),e)))),!1,e),this}choices(t,e){return ft("<object|string|array> [string|array]",[t,e],arguments.length),this[De](this.choices.bind(this),"choices",t,e),this}coerce(t,e){if(ft("<object|string|array> [function]",[t,e],arguments.length),Array.isArray(t)){if(!e)throw new X("coerce callback must be provided");for(const s of t)this.coerce(s,e);return this}if("object"==typeof t){for(const e of Object.keys(t))this.coerce(e,t[e]);return this}if(!e)throw new X("coerce callback must be provided");return we(this,ee,"f").key[t]=!0,we(this,Jt,"f").addCoerceMiddleware(((s,n)=>{let i;return Object.prototype.hasOwnProperty.call(s,t)?bt((()=>(i=n.getAliases(),e(s[t]))),(e=>{s[t]=e;const r=n.getInternalMethods().getParserConfiguration()["strip-aliased"];if(i[t]&&!0!==r)for(const n of i[t])s[n]=e;return s}),(t=>{throw new X(t.message)})):s}),t),this}conflicts(t,e){return ft("<string|object> [string|array]",[t,e],arguments.length),we(this,ye,"f").conflicts(t,e),this}config(t="config",e,s){return ft("[object|string] [string|function] [function]",[t,e,s],arguments.length),"object"!=typeof t||Array.isArray(t)?("function"==typeof e&&(s=e,e=void 0),this.describe(t,e||we(this,pe,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(t)?t:[t]).forEach((t=>{we(this,ee,"f").config[t]=s||!0})),this):(t=It(t,we(this,Wt,"f"),this[_e]()["deep-merge-config"]||!1,we(this,he,"f")),we(this,ee,"f").configObjects=(we(this,ee,"f").configObjects||[]).concat(t),this)}completion(t,e,s){return ft("[string] [string|boolean|function] [function]",[t,e,s],arguments.length),"function"==typeof e&&(s=e,e=void 0),be(this,Tt,t||we(this,Tt,"f")||"completion","f"),e||!1===e||(e="generate completion script"),this.command(we(this,Tt,"f"),e),s&&we(this,Lt,"f").registerFunction(s),this}command(t,e,s,n,i,r){return ft("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[t,e,s,n,i,r],arguments.length),we(this,zt,"f").addHandler(t,e,s,n,i,r),this}commands(t,e,s,n,i,r){return this.command(t,e,s,n,i,r)}commandDir(t,e){ft("<string> [object]",[t,e],arguments.length);const s=we(this,se,"f")||we(this,he,"f").require;return we(this,zt,"f").addDirectory(t,s,we(this,he,"f").getCallerFile(),e),this}count(t){return ft("<array|string>",[t],arguments.length),this[Me]("count",t),this[es](t),this}default(t,e,s){return ft("<object|string|array> [*] [string]",[t,e,s],arguments.length),s&&(ct(t,we(this,he,"f")),we(this,ee,"f").defaultDescription[t]=s),"function"==typeof e&&(ct(t,we(this,he,"f")),we(this,ee,"f").defaultDescription[t]||(we(this,ee,"f").defaultDescription[t]=we(this,pe,"f").functionDescription(e)),e=e.call()),this[Ne](this.default.bind(this),"default",t,e),this}defaults(t,e,s){return this.default(t,e,s)}demandCommand(t=1,e,s,n){return ft("[number] [number|string] [string|null|undefined] [string|null|undefined]",[t,e,s,n],arguments.length),"number"!=typeof e&&(s=e,e=1/0),this.global("_",!1),we(this,ee,"f").demandedCommands._={min:t,max:e,minMsg:s,maxMsg:n},this}demand(t,e,s){return Array.isArray(e)?(e.forEach((t=>{at(s,!0,we(this,he,"f")),this.demandOption(t,s)})),e=1/0):"number"!=typeof e&&(s=e,e=1/0),"number"==typeof t?(at(s,!0,we(this,he,"f")),this.demandCommand(t,e,s,s)):Array.isArray(t)?t.forEach((t=>{at(s,!0,we(this,he,"f")),this.demandOption(t,s)})):"string"==typeof s?this.demandOption(t,s):!0!==s&&void 0!==s||this.demandOption(t),this}demandOption(t,e){return ft("<object|string|array> [string]",[t,e],arguments.length),this[Ne](this.demandOption.bind(this),"demandedOptions",t,e),this}deprecateOption(t,e){return ft("<string> [string|boolean]",[t,e],arguments.length),we(this,ee,"f").deprecatedOptions[t]=e,this}describe(t,e){return ft("<object|string|array> [string]",[t,e],arguments.length),this[ze](t,!0),we(this,pe,"f").describe(t,e),this}detectLocale(t){return ft("<boolean>",[t],arguments.length),be(this,Ht,t,"f"),this}env(t){return ft("[string|boolean]",[t],arguments.length),!1===t?delete we(this,ee,"f").envPrefix:we(this,ee,"f").envPrefix=t||"",this}epilogue(t){return ft("<string>",[t],arguments.length),we(this,pe,"f").epilog(t),this}epilog(t){return this.epilogue(t)}example(t,e){return ft("<string|array> [string]",[t,e],arguments.length),Array.isArray(t)?t.forEach((t=>this.example(...t))):we(this,pe,"f").example(t,e),this}exit(t,e){be(this,Kt,!0,"f"),be(this,Bt,e,"f"),we(this,qt,"f")&&we(this,he,"f").process.exit(t)}exitProcess(t=!0){return ft("[boolean]",[t],arguments.length),be(this,qt,t,"f"),this}fail(t){if(ft("<function|boolean>",[t],arguments.length),"boolean"==typeof t&&!1!==t)throw new X("Invalid first argument. Expected function or boolean 'false'");return we(this,pe,"f").failFn(t),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(t,e){return ft("<array> [function]",[t,e],arguments.length),e?we(this,Lt,"f").getCompletion(t,e):new Promise(((e,s)=>{we(this,Lt,"f").getCompletion(t,((t,n)=>{t?s(t):e(n)}))}))}getDemandedOptions(){return ft([],0),we(this,ee,"f").demandedOptions}getDemandedCommands(){return ft([],0),we(this,ee,"f").demandedCommands}getDeprecatedOptions(){return ft([],0),we(this,ee,"f").deprecatedOptions}getDetectLocale(){return we(this,Ht,"f")}getExitProcess(){return we(this,qt,"f")}getGroups(){return Object.assign({},we(this,Gt,"f"),we(this,ae,"f"))}getHelp(){if(be(this,Kt,!0,"f"),!we(this,pe,"f").hasCachedHelpMessage()){if(!this.parsed){const t=this[Ze](we(this,ce,"f"),void 0,void 0,0,!0);if(ht(t))return t.then((()=>we(this,pe,"f").help()))}const t=we(this,zt,"f").runDefaultBuilderOn(this);if(ht(t))return t.then((()=>we(this,pe,"f").help()))}return Promise.resolve(we(this,pe,"f").help())}getOptions(){return we(this,ee,"f")}getStrict(){return we(this,de,"f")}getStrictCommands(){return we(this,ue,"f")}getStrictOptions(){return we(this,fe,"f")}global(t,e){return ft("<string|array> [boolean]",[t,e],arguments.length),t=[].concat(t),!1!==e?we(this,ee,"f").local=we(this,ee,"f").local.filter((e=>-1===t.indexOf(e))):t.forEach((t=>{we(this,ee,"f").local.includes(t)||we(this,ee,"f").local.push(t)})),this}group(t,e){ft("<string|array> <string>",[t,e],arguments.length);const s=we(this,ae,"f")[e]||we(this,Gt,"f")[e];we(this,ae,"f")[e]&&delete we(this,ae,"f")[e];const n={};return we(this,Gt,"f")[e]=(s||[]).concat(t).filter((t=>!n[t]&&(n[t]=!0))),this}hide(t){return ft("<string>",[t],arguments.length),we(this,ee,"f").hiddenOptions.push(t),this}implies(t,e){return ft("<string|object> [number|string|array]",[t,e],arguments.length),we(this,ye,"f").implies(t,e),this}locale(t){return ft("[string]",[t],arguments.length),void 0===t?(this[$e](),we(this,he,"f").y18n.getLocale()):(be(this,Ht,!1,"f"),we(this,he,"f").y18n.setLocale(t),this)}middleware(t,e,s){return we(this,Jt,"f").addMiddleware(t,!!e,s)}nargs(t,e){return ft("<string|object|array> [number]",[t,e],arguments.length),this[Ne](this.nargs.bind(this),"narg",t,e),this}normalize(t){return ft("<array|string>",[t],arguments.length),this[Me]("normalize",t),this}number(t){return ft("<array|string>",[t],arguments.length),this[Me]("number",t),this[es](t),this}option(t,e){if(ft("<string|object> [object]",[t,e],arguments.length),"object"==typeof t)Object.keys(t).forEach((e=>{this.options(e,t[e])}));else{"object"!=typeof e&&(e={}),this[es](t),!we(this,me,"f")||"version"!==t&&"version"!==(null==e?void 0:e.alias)||this[Ae](['"version" is a reserved word.',"Please do one of the following:",'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)","- Use a different option key","https://yargs.js.org/docs/#api-reference-version"].join("\n"),void 0,"versionWarning"),we(this,ee,"f").key[t]=!0,e.alias&&this.alias(t,e.alias);const s=e.deprecate||e.deprecated;s&&this.deprecateOption(t,s);const n=e.demand||e.required||e.require;n&&this.demand(t,n),e.demandOption&&this.demandOption(t,"string"==typeof e.demandOption?e.demandOption:void 0),e.conflicts&&this.conflicts(t,e.conflicts),"default"in e&&this.default(t,e.default),void 0!==e.implies&&this.implies(t,e.implies),void 0!==e.nargs&&this.nargs(t,e.nargs),e.config&&this.config(t,e.configParser),e.normalize&&this.normalize(t),e.choices&&this.choices(t,e.choices),e.coerce&&this.coerce(t,e.coerce),e.group&&this.group(t,e.group),(e.boolean||"boolean"===e.type)&&(this.boolean(t),e.alias&&this.boolean(e.alias)),(e.array||"array"===e.type)&&(this.array(t),e.alias&&this.array(e.alias)),(e.number||"number"===e.type)&&(this.number(t),e.alias&&this.number(e.alias)),(e.string||"string"===e.type)&&(this.string(t),e.alias&&this.string(e.alias)),(e.count||"count"===e.type)&&this.count(t),"boolean"==typeof e.global&&this.global(t,e.global),e.defaultDescription&&(we(this,ee,"f").defaultDescription[t]=e.defaultDescription),e.skipValidation&&this.skipValidation(t);const i=e.describe||e.description||e.desc,r=we(this,pe,"f").getDescriptions();Object.prototype.hasOwnProperty.call(r,t)&&"string"!=typeof i||this.describe(t,i),e.hidden&&this.hide(t),e.requiresArg&&this.requiresArg(t)}return this}options(t,e){return this.option(t,e)}parse(t,e,s){ft("[string|array] [function|boolean|object] [function]",[t,e,s],arguments.length),this[Ee](),void 0===t&&(t=we(this,ce,"f")),"object"==typeof e&&(be(this,re,e,"f"),e=s),"function"==typeof e&&(be(this,ie,e,"f"),e=!1),e||be(this,ce,t,"f"),we(this,ie,"f")&&be(this,qt,!1,"f");const n=this[Ze](t,!!e),i=this.parsed;return we(this,Lt,"f").setParsed(this.parsed),ht(n)?n.then((t=>(we(this,ie,"f")&&we(this,ie,"f").call(this,we(this,Bt,"f"),t,we(this,te,"f")),t))).catch((t=>{throw we(this,ie,"f")&&we(this,ie,"f")(t,this.parsed.argv,we(this,te,"f")),t})).finally((()=>{this[We](),this.parsed=i})):(we(this,ie,"f")&&we(this,ie,"f").call(this,we(this,Bt,"f"),n,we(this,te,"f")),this[We](),this.parsed=i,n)}parseAsync(t,e,s){const n=this.parse(t,e,s);return ht(n)?n:Promise.resolve(n)}parseSync(t,e,s){const n=this.parse(t,e,s);if(ht(n))throw new X(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return n}parserConfiguration(t){return ft("<object>",[t],arguments.length),be(this,ne,t,"f"),this}pkgConf(t,e){ft("<string> [string]",[t,e],arguments.length);let s=null;const n=this[Se](e||we(this,Wt,"f"));return n[t]&&"object"==typeof n[t]&&(s=It(n[t],e||we(this,Wt,"f"),this[_e]()["deep-merge-config"]||!1,we(this,he,"f")),we(this,ee,"f").configObjects=(we(this,ee,"f").configObjects||[]).concat(s)),this}positional(t,e){ft("<string> <object>",[t,e],arguments.length);const s=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];e=At(e,((t,e)=>!("type"===t&&!["string","number","boolean"].includes(e))&&s.includes(t)));const n=we(this,Ft,"f").fullCommands[we(this,Ft,"f").fullCommands.length-1],i=n?we(this,zt,"f").cmdToParseOptions(n):{array:[],alias:{},default:{},demand:{}};return lt(i).forEach((s=>{const n=i[s];Array.isArray(n)?-1!==n.indexOf(t)&&(e[s]=!0):n[t]&&!(s in e)&&(e[s]=n[t])})),this.group(t,we(this,pe,"f").getPositionalGroupName()),this.option(t,e)}recommendCommands(t=!0){return ft("[boolean]",[t],arguments.length),be(this,le,t,"f"),this}required(t,e,s){return this.demand(t,e,s)}require(t,e,s){return this.demand(t,e,s)}requiresArg(t){return ft("<array|string|object> [number]",[t],arguments.length),"string"==typeof t&&we(this,ee,"f").narg[t]||this[Ne](this.requiresArg.bind(this),"narg",t,NaN),this}showCompletionScript(t,e){return ft("[string] [string]",[t,e],arguments.length),t=t||this.$0,we(this,Xt,"f").log(we(this,Lt,"f").generateCompletionScript(t,e||we(this,Tt,"f")||"completion")),this}showHelp(t){if(ft("[string|function]",[t],arguments.length),be(this,Kt,!0,"f"),!we(this,pe,"f").hasCachedHelpMessage()){if(!this.parsed){const e=this[Ze](we(this,ce,"f"),void 0,void 0,0,!0);if(ht(e))return e.then((()=>{we(this,pe,"f").showHelp(t)})),this}const e=we(this,zt,"f").runDefaultBuilderOn(this);if(ht(e))return e.then((()=>{we(this,pe,"f").showHelp(t)})),this}return we(this,pe,"f").showHelp(t),this}scriptName(t){return this.customScriptName=!0,this.$0=t,this}showHelpOnFail(t,e){return ft("[boolean|string] [string]",[t,e],arguments.length),we(this,pe,"f").showHelpOnFail(t,e),this}showVersion(t){return ft("[string|function]",[t],arguments.length),we(this,pe,"f").showVersion(t),this}skipValidation(t){return ft("<array|string>",[t],arguments.length),this[Me]("skipValidation",t),this}strict(t){return ft("[boolean]",[t],arguments.length),be(this,de,!1!==t,"f"),this}strictCommands(t){return ft("[boolean]",[t],arguments.length),be(this,ue,!1!==t,"f"),this}strictOptions(t){return ft("[boolean]",[t],arguments.length),be(this,fe,!1!==t,"f"),this}string(t){return ft("<array|string>",[t],arguments.length),this[Me]("string",t),this[es](t),this}terminalWidth(){return ft([],0),we(this,he,"f").process.stdColumns}updateLocale(t){return this.updateStrings(t)}updateStrings(t){return ft("<object>",[t],arguments.length),be(this,Ht,!1,"f"),we(this,he,"f").y18n.updateLocale(t),this}usage(t,e,s,n){if(ft("<string|null|undefined> [string|boolean] [function|object] [function]",[t,e,s,n],arguments.length),void 0!==e){if(at(t,null,we(this,he,"f")),(t||"").match(/^\$0( |$)/))return this.command(t,e,s,n);throw new X(".usage() description must start with $0 if being used as alias for .command()")}return we(this,pe,"f").usage(t),this}usageConfiguration(t){return ft("<object>",[t],arguments.length),be(this,ge,t,"f"),this}version(t,e,s){const n="version";if(ft("[boolean|string] [string] [string]",[t,e,s],arguments.length),we(this,me,"f")&&(this[Oe](we(this,me,"f")),we(this,pe,"f").version(void 0),be(this,me,null,"f")),0===arguments.length)s=this[Pe](),t=n;else if(1===arguments.length){if(!1===t)return this;s=t,t=n}else 2===arguments.length&&(s=e,e=void 0);return be(this,me,"string"==typeof t?t:n,"f"),e=e||we(this,pe,"f").deferY18nLookup("Show version number"),we(this,pe,"f").version(s||void 0),this.boolean(we(this,me,"f")),this.describe(we(this,me,"f"),e),this}wrap(t){return ft("<number|null|undefined>",[t],arguments.length),we(this,pe,"f").wrap(t),this}[(zt=new WeakMap,Wt=new WeakMap,Ft=new WeakMap,Lt=new WeakMap,Tt=new WeakMap,Ut=new WeakMap,Bt=new WeakMap,Ht=new WeakMap,Vt=new WeakMap,qt=new WeakMap,Yt=new WeakMap,Jt=new WeakMap,Gt=new WeakMap,Kt=new WeakMap,Qt=new WeakMap,Zt=new WeakMap,Xt=new WeakMap,te=new WeakMap,ee=new WeakMap,se=new WeakMap,ne=new WeakMap,ie=new WeakMap,re=new WeakMap,oe=new WeakMap,ae=new WeakMap,ce=new WeakMap,le=new WeakMap,he=new WeakMap,de=new WeakMap,ue=new WeakMap,fe=new WeakMap,pe=new WeakMap,ge=new WeakMap,me=new WeakMap,ye=new WeakMap,ve)](t){if(!t._||!t["--"])return t;t._.push.apply(t._,t["--"]);try{delete t["--"]}catch(t){}return t}[ke](){return{log:(...t)=>{this[Ye]()||console.log(...t),be(this,Kt,!0,"f"),we(this,te,"f").length&&be(this,te,we(this,te,"f")+"\n","f"),be(this,te,we(this,te,"f")+t.join(" "),"f")},error:(...t)=>{this[Ye]()||console.error(...t),be(this,Kt,!0,"f"),we(this,te,"f").length&&be(this,te,we(this,te,"f")+"\n","f"),be(this,te,we(this,te,"f")+t.join(" "),"f")}}}[Oe](t){lt(we(this,ee,"f")).forEach((e=>{if("configObjects"===e)return;const s=we(this,ee,"f")[e];Array.isArray(s)?s.includes(t)&&s.splice(s.indexOf(t),1):"object"==typeof s&&delete s[t]})),delete we(this,pe,"f").getDescriptions()[t]}[Ae](t,e,s){we(this,Vt,"f")[s]||(we(this,he,"f").process.emitWarning(t,e),we(this,Vt,"f")[s]=!0)}[Ee](){we(this,Yt,"f").push({options:we(this,ee,"f"),configObjects:we(this,ee,"f").configObjects.slice(0),exitProcess:we(this,qt,"f"),groups:we(this,Gt,"f"),strict:we(this,de,"f"),strictCommands:we(this,ue,"f"),strictOptions:we(this,fe,"f"),completionCommand:we(this,Tt,"f"),output:we(this,te,"f"),exitError:we(this,Bt,"f"),hasOutput:we(this,Kt,"f"),parsed:this.parsed,parseFn:we(this,ie,"f"),parseContext:we(this,re,"f")}),we(this,pe,"f").freeze(),we(this,ye,"f").freeze(),we(this,zt,"f").freeze(),we(this,Jt,"f").freeze()}[je](){let t,e="";return t=/\b(node|iojs|electron)(\.exe)?$/.test(we(this,he,"f").process.argv()[0])?we(this,he,"f").process.argv().slice(1,2):we(this,he,"f").process.argv().slice(0,1),e=t.map((t=>{const e=this[Ke](we(this,Wt,"f"),t);return t.match(/^(\/|([a-zA-Z]:)?\\)/)&&e.length<t.length?e:t})).join(" ").trim(),we(this,he,"f").getEnv("_")&&we(this,he,"f").getProcessArgvBin()===we(this,he,"f").getEnv("_")&&(e=we(this,he,"f").getEnv("_").replace(`${we(this,he,"f").path.dirname(we(this,he,"f").process.execPath())}/`,"")),e}[_e](){return we(this,ne,"f")}[xe](){return we(this,ge,"f")}[$e](){if(!we(this,Ht,"f"))return;const t=we(this,he,"f").getEnv("LC_ALL")||we(this,he,"f").getEnv("LC_MESSAGES")||we(this,he,"f").getEnv("LANG")||we(this,he,"f").getEnv("LANGUAGE")||"en_US";this.locale(t.replace(/[.:].*/,""))}[Pe](){return this[Se]().version||"unknown"}[Ce](t){const e=t["--"]?t["--"]:t._;for(let t,s=0;void 0!==(t=e[s]);s++)we(this,he,"f").Parser.looksLikeNumber(t)&&Number.isSafeInteger(Math.floor(parseFloat(`${t}`)))&&(e[s]=Number(t));return t}[Se](t){const e=t||"*";if(we(this,oe,"f")[e])return we(this,oe,"f")[e];let s={};try{let e=t||we(this,he,"f").mainFilename;!t&&we(this,he,"f").path.extname(e)&&(e=we(this,he,"f").path.dirname(e));const n=we(this,he,"f").findUp(e,((t,e)=>e.includes("package.json")?"package.json":void 0));at(n,void 0,we(this,he,"f")),s=JSON.parse(we(this,he,"f").readFileSync(n,"utf8"))}catch(t){}return we(this,oe,"f")[e]=s||{},we(this,oe,"f")[e]}[Me](t,e){(e=[].concat(e)).forEach((e=>{e=this[Re](e),we(this,ee,"f")[t].push(e)}))}[Ne](t,e,s,n){this[Ie](t,e,s,n,((t,e,s)=>{we(this,ee,"f")[t][e]=s}))}[De](t,e,s,n){this[Ie](t,e,s,n,((t,e,s)=>{we(this,ee,"f")[t][e]=(we(this,ee,"f")[t][e]||[]).concat(s)}))}[Ie](t,e,s,n,i){if(Array.isArray(s))s.forEach((e=>{t(e,n)}));else if((t=>"object"==typeof t)(s))for(const e of lt(s))t(e,s[e]);else i(e,this[Re](s),n)}[Re](t){return"__proto__"===t?"___proto___":t}[ze](t,e){return this[Ne](this[ze].bind(this),"key",t,e),this}[We](){var t,e,s,n,i,r,o,a,c,l,h,d;const u=we(this,Yt,"f").pop();let f;at(u,void 0,we(this,he,"f")),t=this,e=this,s=this,n=this,i=this,r=this,o=this,a=this,c=this,l=this,h=this,d=this,({options:{set value(e){be(t,ee,e,"f")}}.value,configObjects:f,exitProcess:{set value(t){be(e,qt,t,"f")}}.value,groups:{set value(t){be(s,Gt,t,"f")}}.value,output:{set value(t){be(n,te,t,"f")}}.value,exitError:{set value(t){be(i,Bt,t,"f")}}.value,hasOutput:{set value(t){be(r,Kt,t,"f")}}.value,parsed:this.parsed,strict:{set value(t){be(o,de,t,"f")}}.value,strictCommands:{set value(t){be(a,ue,t,"f")}}.value,strictOptions:{set value(t){be(c,fe,t,"f")}}.value,completionCommand:{set value(t){be(l,Tt,t,"f")}}.value,parseFn:{set value(t){be(h,ie,t,"f")}}.value,parseContext:{set value(t){be(d,re,t,"f")}}.value}=u),we(this,ee,"f").configObjects=f,we(this,pe,"f").unfreeze(),we(this,ye,"f").unfreeze(),we(this,zt,"f").unfreeze(),we(this,Jt,"f").unfreeze()}[Fe](t,e){return bt(e,(e=>(t(e),e)))}getInternalMethods(){return{getCommandInstance:this[Le].bind(this),getContext:this[Te].bind(this),getHasOutput:this[Ue].bind(this),getLoggerInstance:this[Be].bind(this),getParseContext:this[He].bind(this),getParserConfiguration:this[_e].bind(this),getUsageConfiguration:this[xe].bind(this),getUsageInstance:this[Ve].bind(this),getValidationInstance:this[qe].bind(this),hasParseCallback:this[Ye].bind(this),isGlobalContext:this[Je].bind(this),postProcess:this[Ge].bind(this),reset:this[Qe].bind(this),runValidation:this[Xe].bind(this),runYargsParserAndExecuteCommands:this[Ze].bind(this),setHasOutput:this[ts].bind(this)}}[Le](){return we(this,zt,"f")}[Te](){return we(this,Ft,"f")}[Ue](){return we(this,Kt,"f")}[Be](){return we(this,Xt,"f")}[He](){return we(this,re,"f")||{}}[Ve](){return we(this,pe,"f")}[qe](){return we(this,ye,"f")}[Ye](){return!!we(this,ie,"f")}[Je](){return we(this,Zt,"f")}[Ge](t,e,s,n){if(s)return t;if(ht(t))return t;e||(t=this[ve](t));return(this[_e]()["parse-positional-numbers"]||void 0===this[_e]()["parse-positional-numbers"])&&(t=this[Ce](t)),n&&(t=yt(t,this,we(this,Jt,"f").getMiddleware(),!1)),t}[Qe](t={}){be(this,ee,we(this,ee,"f")||{},"f");const e={};e.local=we(this,ee,"f").local||[],e.configObjects=we(this,ee,"f").configObjects||[];const s={};e.local.forEach((e=>{s[e]=!0,(t[e]||[]).forEach((t=>{s[t]=!0}))})),Object.assign(we(this,ae,"f"),Object.keys(we(this,Gt,"f")).reduce(((t,e)=>{const n=we(this,Gt,"f")[e].filter((t=>!(t in s)));return n.length>0&&(t[e]=n),t}),{})),be(this,Gt,{},"f");return["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"].forEach((t=>{e[t]=(we(this,ee,"f")[t]||[]).filter((t=>!s[t]))})),["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"].forEach((t=>{e[t]=At(we(this,ee,"f")[t],(t=>!s[t]))})),e.envPrefix=we(this,ee,"f").envPrefix,be(this,ee,e,"f"),be(this,pe,we(this,pe,"f")?we(this,pe,"f").reset(s):_t(this,we(this,he,"f")),"f"),be(this,ye,we(this,ye,"f")?we(this,ye,"f").reset(s):function(t,e,s){const n=s.y18n.__,i=s.y18n.__n,r={nonOptionCount:function(s){const n=t.getDemandedCommands(),r=s._.length+(s["--"]?s["--"].length:0)-t.getInternalMethods().getContext().commands.length;n._&&(r<n._.min||r>n._.max)&&(r<n._.min?void 0!==n._.minMsg?e.fail(n._.minMsg?n._.minMsg.replace(/\$0/g,r.toString()).replace(/\$1/,n._.min.toString()):null):e.fail(i("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",r,r.toString(),n._.min.toString())):r>n._.max&&(void 0!==n._.maxMsg?e.fail(n._.maxMsg?n._.maxMsg.replace(/\$0/g,r.toString()).replace(/\$1/,n._.max.toString()):null):e.fail(i("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",r,r.toString(),n._.max.toString()))))},positionalCount:function(t,s){s<t&&e.fail(i("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",s,s+"",t+""))},requiredArguments:function(t,s){let n=null;for(const e of Object.keys(s))Object.prototype.hasOwnProperty.call(t,e)&&void 0!==t[e]||(n=n||{},n[e]=s[e]);if(n){const t=[];for(const e of Object.keys(n)){const s=n[e];s&&t.indexOf(s)<0&&t.push(s)}const s=t.length?`\n${t.join("\n")}`:"";e.fail(i("Missing required argument: %s","Missing required arguments: %s",Object.keys(n).length,Object.keys(n).join(", ")+s))}},unknownArguments:function(s,n,o,a,c=!0){var l;const h=t.getInternalMethods().getCommandInstance().getCommands(),d=[],u=t.getInternalMethods().getContext();if(Object.keys(s).forEach((e=>{Mt.includes(e)||Object.prototype.hasOwnProperty.call(o,e)||Object.prototype.hasOwnProperty.call(t.getInternalMethods().getParseContext(),e)||r.isValidAndSomeAliasIsNotNew(e,n)||d.push(e)})),c&&(u.commands.length>0||h.length>0||a)&&s._.slice(u.commands.length).forEach((t=>{h.includes(""+t)||d.push(""+t)})),c){const e=(null===(l=t.getDemandedCommands()._)||void 0===l?void 0:l.max)||0,n=u.commands.length+e;n<s._.length&&s._.slice(n).forEach((t=>{t=String(t),u.commands.includes(t)||d.includes(t)||d.push(t)}))}d.length&&e.fail(i("Unknown argument: %s","Unknown arguments: %s",d.length,d.map((t=>t.trim()?t:`"${t}"`)).join(", ")))},unknownCommands:function(s){const n=t.getInternalMethods().getCommandInstance().getCommands(),r=[],o=t.getInternalMethods().getContext();return(o.commands.length>0||n.length>0)&&s._.slice(o.commands.length).forEach((t=>{n.includes(""+t)||r.push(""+t)})),r.length>0&&(e.fail(i("Unknown command: %s","Unknown commands: %s",r.length,r.join(", "))),!0)},isValidAndSomeAliasIsNotNew:function(e,s){if(!Object.prototype.hasOwnProperty.call(s,e))return!1;const n=t.parsed.newAliases;return[e,...s[e]].some((t=>!Object.prototype.hasOwnProperty.call(n,t)||!n[e]))},limitedChoices:function(s){const i=t.getOptions(),r={};if(!Object.keys(i.choices).length)return;Object.keys(s).forEach((t=>{-1===Mt.indexOf(t)&&Object.prototype.hasOwnProperty.call(i.choices,t)&&[].concat(s[t]).forEach((e=>{-1===i.choices[t].indexOf(e)&&void 0!==e&&(r[t]=(r[t]||[]).concat(e))}))}));const o=Object.keys(r);if(!o.length)return;let a=n("Invalid values:");o.forEach((t=>{a+=`\n ${n("Argument: %s, Given: %s, Choices: %s",t,e.stringifiedValues(r[t]),e.stringifiedValues(i.choices[t]))}`})),e.fail(a)}};let o={};function a(t,e){const s=Number(e);return"number"==typeof(e=isNaN(s)?e:s)?e=t._.length>=e:e.match(/^--no-.+/)?(e=e.match(/^--no-(.+)/)[1],e=!Object.prototype.hasOwnProperty.call(t,e)):e=Object.prototype.hasOwnProperty.call(t,e),e}r.implies=function(e,n){ft("<string|object> [array|number|string]",[e,n],arguments.length),"object"==typeof e?Object.keys(e).forEach((t=>{r.implies(t,e[t])})):(t.global(e),o[e]||(o[e]=[]),Array.isArray(n)?n.forEach((t=>r.implies(e,t))):(at(n,void 0,s),o[e].push(n)))},r.getImplied=function(){return o},r.implications=function(t){const s=[];if(Object.keys(o).forEach((e=>{const n=e;(o[e]||[]).forEach((e=>{let i=n;const r=e;i=a(t,i),e=a(t,e),i&&!e&&s.push(` ${n} -> ${r}`)}))})),s.length){let t=`${n("Implications failed:")}\n`;s.forEach((e=>{t+=e})),e.fail(t)}};let c={};r.conflicts=function(e,s){ft("<string|object> [array|string]",[e,s],arguments.length),"object"==typeof e?Object.keys(e).forEach((t=>{r.conflicts(t,e[t])})):(t.global(e),c[e]||(c[e]=[]),Array.isArray(s)?s.forEach((t=>r.conflicts(e,t))):c[e].push(s))},r.getConflicting=()=>c,r.conflicting=function(i){Object.keys(i).forEach((t=>{c[t]&&c[t].forEach((s=>{s&&void 0!==i[t]&&void 0!==i[s]&&e.fail(n("Arguments %s and %s are mutually exclusive",t,s))}))})),t.getInternalMethods().getParserConfiguration()["strip-dashed"]&&Object.keys(c).forEach((t=>{c[t].forEach((r=>{r&&void 0!==i[s.Parser.camelCase(t)]&&void 0!==i[s.Parser.camelCase(r)]&&e.fail(n("Arguments %s and %s are mutually exclusive",t,r))}))}))},r.recommendCommands=function(t,s){s=s.sort(((t,e)=>e.length-t.length));let i=null,r=1/0;for(let e,n=0;void 0!==(e=s[n]);n++){const s=St(t,e);s<=3&&s<r&&(r=s,i=e)}i&&e.fail(n("Did you mean %s?",i))},r.reset=function(t){return o=At(o,(e=>!t[e])),c=At(c,(e=>!t[e])),r};const l=[];return r.freeze=function(){l.push({implied:o,conflicting:c})},r.unfreeze=function(){const t=l.pop();at(t,void 0,s),({implied:o,conflicting:c}=t)},r}(this,we(this,pe,"f"),we(this,he,"f")),"f"),be(this,zt,we(this,zt,"f")?we(this,zt,"f").reset():function(t,e,s,n){return new vt(t,e,s,n)}(we(this,pe,"f"),we(this,ye,"f"),we(this,Jt,"f"),we(this,he,"f")),"f"),we(this,Lt,"f")||be(this,Lt,function(t,e,s,n){return new Ct(t,e,s,n)}(this,we(this,pe,"f"),we(this,zt,"f"),we(this,he,"f")),"f"),we(this,Jt,"f").reset(),be(this,Tt,null,"f"),be(this,te,"","f"),be(this,Bt,null,"f"),be(this,Kt,!1,"f"),this.parsed=!1,this}[Ke](t,e){return we(this,he,"f").path.relative(t,e)}[Ze](t,e,s,n=0,i=!1){let r=!!s||i;t=t||we(this,ce,"f"),we(this,ee,"f").__=we(this,he,"f").y18n.__,we(this,ee,"f").configuration=this[_e]();const o=!!we(this,ee,"f").configuration["populate--"],a=Object.assign({},we(this,ee,"f").configuration,{"populate--":!0}),c=we(this,he,"f").Parser.detailed(t,Object.assign({},we(this,ee,"f"),{configuration:{"parse-positional-numbers":!1,...a}})),l=Object.assign(c.argv,we(this,re,"f"));let h;const d=c.aliases;let u=!1,f=!1;Object.keys(l).forEach((t=>{t===we(this,Qt,"f")&&l[t]?u=!0:t===we(this,me,"f")&&l[t]&&(f=!0)})),l.$0=this.$0,this.parsed=c,0===n&&we(this,pe,"f").clearCachedHelpMessage();try{if(this[$e](),e)return this[Ge](l,o,!!s,!1);if(we(this,Qt,"f")){[we(this,Qt,"f")].concat(d[we(this,Qt,"f")]||[]).filter((t=>t.length>1)).includes(""+l._[l._.length-1])&&(l._.pop(),u=!0)}be(this,Zt,!1,"f");const a=we(this,zt,"f").getCommands(),p=we(this,Lt,"f").completionKey in l,g=u||p||i;if(l._.length){if(a.length){let t;for(let e,r=n||0;void 0!==l._[r];r++){if(e=String(l._[r]),a.includes(e)&&e!==we(this,Tt,"f")){const t=we(this,zt,"f").runCommand(e,this,c,r+1,i,u||f||i);return this[Ge](t,o,!!s,!1)}if(!t&&e!==we(this,Tt,"f")){t=e;break}}!we(this,zt,"f").hasDefaultCommand()&&we(this,le,"f")&&t&&!g&&we(this,ye,"f").recommendCommands(t,a)}we(this,Tt,"f")&&l._.includes(we(this,Tt,"f"))&&!p&&(we(this,qt,"f")&&Et(!0),this.showCompletionScript(),this.exit(0))}if(we(this,zt,"f").hasDefaultCommand()&&!g){const t=we(this,zt,"f").runCommand(null,this,c,0,i,u||f||i);return this[Ge](t,o,!!s,!1)}if(p){we(this,qt,"f")&&Et(!0);const e=(t=[].concat(t)).slice(t.indexOf(`--${we(this,Lt,"f").completionKey}`)+1);return we(this,Lt,"f").getCompletion(e,((t,e)=>{if(t)throw new X(t.message);(e||[]).forEach((t=>{we(this,Xt,"f").log(t)})),this.exit(0)})),this[Ge](l,!o,!!s,!1)}if(we(this,Kt,"f")||(u?(we(this,qt,"f")&&Et(!0),r=!0,this.showHelp("log"),this.exit(0)):f&&(we(this,qt,"f")&&Et(!0),r=!0,we(this,pe,"f").showVersion("log"),this.exit(0))),!r&&we(this,ee,"f").skipValidation.length>0&&(r=Object.keys(l).some((t=>we(this,ee,"f").skipValidation.indexOf(t)>=0&&!0===l[t]))),!r){if(c.error)throw new X(c.error.message);if(!p){const t=this[Xe](d,{},c.error);s||(h=yt(l,this,we(this,Jt,"f").getMiddleware(),!0)),h=this[Fe](t,null!=h?h:l),ht(h)&&!s&&(h=h.then((()=>yt(l,this,we(this,Jt,"f").getMiddleware(),!1))))}}}catch(t){if(!(t instanceof X))throw t;we(this,pe,"f").fail(t.message,t)}return this[Ge](null!=h?h:l,o,!!s,!0)}[Xe](t,e,s,n){const i={...this.getDemandedOptions()};return r=>{if(s)throw new X(s.message);we(this,ye,"f").nonOptionCount(r),we(this,ye,"f").requiredArguments(r,i);let o=!1;we(this,ue,"f")&&(o=we(this,ye,"f").unknownCommands(r)),we(this,de,"f")&&!o?we(this,ye,"f").unknownArguments(r,t,e,!!n):we(this,fe,"f")&&we(this,ye,"f").unknownArguments(r,t,{},!1,!1),we(this,ye,"f").limitedChoices(r),we(this,ye,"f").implications(r),we(this,ye,"f").conflicting(r)}}[ts](){be(this,Kt,!0,"f")}[es](t){if("string"==typeof t)we(this,ee,"f").key[t]=!0;else for(const e of t)we(this,ee,"f").key[e]=!0}}const ns=(is=ot,(t=[],e=is.process.cwd(),s)=>{const n=new ss(t,e,s,is);return Object.defineProperty(n,"argv",{get:()=>n.parse(),enumerable:!0}),n.help(),n.version(),n});var is;const rs=new class{constructor(){this._dirPath=process.cwd()}getBuildCommand(t){return this._buildCommand??=this.packageJson.scripts?.build?.includes("buildIfNeeded")?"yarn build":"YARN wb buildIfNeeded "+(t?.verbose?"--verbose":"")}get dirPath(){return this._dirPath}set dirPath(e){this._dirPath=t.resolve(e)}get rootDirPath(){return this._rootDirPath??=l.existsSync(t.join(this.dirPath,"..","..","package.json"))?t.resolve(this.dirPath,"..",".."):this.dirPath}get dockerfile(){return this._dockerfile??=l.readFileSync(this.dockerfilePath,"utf8")}get dockerfilePath(){if(this._dockerfilePath)return this._dockerfilePath;if(l.existsSync(t.join(this.dirPath,"Dockerfile")))this._dockerfilePath=t.join(this.dirPath,"Dockerfile");else{if(!l.existsSync(t.join(this.dirPath,"..","..","Dockerfile")))throw new Error("Dockerfile not found");this._dockerfilePath=t.join(this.dirPath,"..","..","Dockerfile")}return this._dockerfilePath}get hasDockerfile(){if(void 0!==this._hasDockerfile)return this._hasDockerfile;try{this._hasDockerfile=!!this.dockerfilePath}catch{this._hasDockerfile=!1}return this._hasDockerfile}get name(){return this._name??=rs.rootPackageJson.name||"unknown"}get packageJson(){return this._packageJson??=JSON.parse(l.readFileSync(t.join(this.dirPath,"package.json"),"utf8"))}get rootPackageJson(){return this._rootPackageJson??=this.rootDirPath===this.dirPath?this.packageJson:JSON.parse(l.readFileSync(t.join(this.rootDirPath,"package.json"),"utf8"))}get dockerPackageJson(){return this._dockerPackageJson??=t.dirname(this.dockerfilePath)===this.dirPath?this.packageJson:JSON.parse(l.readFileSync(t.join(t.dirname(this.dockerfilePath),"package.json"),"utf8"))}},os={env:{description:".env files to be loaded.",type:"array"},"cascade-env":{description:"environment to load cascading .env files (e.g., `.env`, `.env.<environment>`, `.env.local` and `.env.<environment>.local`)",type:"string"},"cascade-node-env":{description:'environment to load cascading .env files (e.g., `.env`, `.env.<NODE_ENV>`, `.env.local` and `.env.<NODE_ENV>.local`). If NODE_ENV is falsy, "development" is applied. Preferred over `cascade`.',type:"boolean"},"working-dir":{description:"A working directory",type:"string",alias:"w"},"dry-run":{description:"Whether to skip actual command execution",type:"boolean",alias:"d"},verbose:{description:"Whether to show verbose information",type:"boolean",alias:"v"}},as={command:"buildIfNeeded",describe:"Build code if changes are detected",builder:{...os,command:{description:"A build command",type:"string",default:"yarn build",alias:"c"}},async handler(e){await async function(e){const[s,n,i]=await async function(e){const s=t.resolve(rs.dirPath,"node_modules",".cache","build"),n=t.resolve(s,"last-build");await k.mkdir(s,{recursive:!0});const i=v("sha256"),r=y.execSync("git rev-parse HEAD",{cwd:rs.dirPath}).toString().trim();i.update(r);const o=JSON.stringify(Object.entries(process.env).filter((([t])=>!cs.has(t))).sort((([t],[e])=>t.localeCompare(e))));i.update(o),await async function(t,e){return new Promise((s=>{const n=y.spawnSync("git",["diff","--name-only"],{cwd:rs.dirPath,stdio:"pipe",encoding:"utf8"}).stdout.trim().split("\n").map((t=>"test"===process.env.WB_ENV?t.replace(/packages\/scripts\/test-fixtures\/[^/]+\//,""):t)).filter((t=>(ls.some((e=>t.includes(e)))||hs.some((e=>t.endsWith(e))))&&!ds.some((e=>t.includes(e)))));t.verbose&&console.info(`Changed files: ${n.join(", ")}`);const i=y.spawn("git",["diff","--",...n],{cwd:rs.rootDirPath});i.stdout?.on("data",(s=>{e.update(s),t.verbose&&(console.info(s.toString()),console.info("Hash:",e.copy().digest("hex")))})),i.on("close",(()=>{s()}))}))}(e,i);const a=i.digest("hex"),c=await async function(t){try{return await t()}catch(t){if("object"==typeof t&&t&&"code"in t&&"ENOENT"===t.code)return;throw t}}((()=>k.readFile(n,"utf8")));return[c===a,n,a]}(e);if(s)return console.info(O.green(`Skip to run '${e.command}' 💫`)),!1;if(console.info(O.green(`Run '${e.command}'`)),!e.dryRun){const[t,...s]=(e.command??"").split(" "),n=y.spawnSync(t,s,{cwd:rs.dirPath,stdio:"inherit"});if(0!==n.status)return void(process.exitCode=n.status??1)}e.dryRun||await k.writeFile(n,i,"utf8");return!0}(e)}};const cs=new Set(["CI","PWDEBUG","TMPDIR"]);const ls=["src/","public/"],hs=[".js",".cjs",".mjs",".jsx",".ts",".cts",".mts",".tsx",".json",".browserslistrc","yarn.lock"],ds=["test/","tests/","__tests__/","test-fixtures/","package.json"];const us={command:"optimizeForDockerBuild",describe:"Optimize configuration when building a Docker image",builder:{...os,outside:{description:"Whether the optimization is executed outside a docker container or not",type:"boolean",alias:"o"}},async handler(e){const s={stdio:"inherit"},n=["package.json"];if(rs.packageJson.workspaces){const e=await l.promises.readdir("packages",{withFileTypes:!0});for(const s of e){if(!s.isDirectory())continue;const e=t.join("packages",s.name,"package.json");l.existsSync(e)&&n.push(e)}}for(const s of n){const n=JSON.parse(l.readFileSync(s,"utf8")),i=n.dependencies||{};if(i["@discord-bot/llm"]&&"workspace:*"!==i["@discord-bot/llm"]&&(i["@discord-bot/llm"]="./@discord-bot/llm"),i["@moti-components/go-e-mon"]&&(i["@moti-components/go-e-mon"]="./@moti-components/go-e-mon"),i["@online-judge/shared"]&&(i["@online-judge/shared"]="./@online-judge/shared"),i["program-executor"]&&(i["program-executor"]="./program-executor"),i["online-judge-shared"]&&(i["online-judge-shared"]="./online-judge-shared"),fs(e,n),ps(n),e.dryRun)continue;const r=e.outside?t.join(t.dirname(s),"dist"):t.dirname(s);await l.promises.mkdir(r,{recursive:!0}),await l.promises.writeFile(t.join(r,"package.json"),JSON.stringify(n),"utf8")}e.dryRun||e.outside||y.spawnSync("yarn",s)}};function fs(t,e){if(!t.outside)return void delete e.devDependencies;const s=e.devDependencies||{},n=["concurrently","conventional-changelog-conventionalcommits","eslint","husky","jest","kill-port","lint-staged","open-cli","playwright","prettier","pinst","sort-package-json","wait-on","semantic-release","vitest"];for(const e of Object.keys(s))(n.some((t=>e.includes(t)))||!t.outside&&e.includes("willbooster")&&e.includes("config"))&&delete s[e]}function ps(t){const e=["check","deploy","format","lint","start","test"],s=["pinst ","husky "],n=t.scripts||{};for(const[t,i]of Object.entries(n))(e.some((e=>t.includes(e)))||s.some((t=>i.includes(t))))&&delete n[t]}const gs=new class{deploy(){return"PRISMA migrate deploy"}deployForce(t){const e=rs.packageJson.dependencies?.blitz?"db":"prisma";return`rm -Rf ${e}/mount/prod.sqlite3*; PRISMA migrate reset --force && rm -Rf ${e}/mount/prod.sqlite3* && litestream restore -o ${e}/mount/prod.sqlite3 ${t} && PRISMA migrate deploy`}litestream(){return'node -e \'\nconst { PrismaClient } = require("@prisma/client");\nnew PrismaClient().$queryRaw`PRAGMA journal_mode = WAL;`\n .catch((error) => { console.log("Failed due to:", error); process.exit(1); });\n\''}migrate(){return`PRISMA migrate deploy && PRISMA generate && ${this.seed()}`}migrateDev(){return"PRISMA migrate dev"}reset(){return`PRISMA migrate reset --force --skip-seed && ${this.seed()}`}restore(t,e){return`rm -Rf ${rs.packageJson.dependencies?.blitz?"db":"prisma"}/restored.sqlite3; GOOGLE_APPLICATION_CREDENTIALS=gcp-sa-key.json litestream restore -o ${e} ${t}`}seed(){return rs.packageJson.dependencies?.blitz?"YARN blitz db seed":rs.packageJson.prisma?.seed?"YARN prisma db seed":'if [ -e "prisma/seeds.ts" ]; then YARN build-ts run prisma/seeds.ts; fi'}studio(e){let s="";if(e)try{new URL(e),s=`DATABASE_URL=${e} `}catch{const n=t.resolve(e);console.info(e,n),s=`DATABASE_URL=file://${n} `}return`${s}PRISMA studio`}},ms=new E,ys=new Set;async function bs(t){try{await j(t)}catch{}}const ws={exitIfFailed:!0};async function vs(t,e,s=ws){const[n,i]=Os(t);if(As(n),e.verbose&&As(n,"Start (detailed)",!0),e.dryRun)return Es(n,0,s),0;const r=i.match(/http:\/\/127.0.0.1:(\d+)/)?.[1];i.includes("wait-on")&&r&&!i.includes("docker run")&&await async function(t){await bs(t);const e=async()=>{ys.has(t)||(ys.add(t),await bs(t))};process.on("beforeExit",e),process.on("SIGINT",e)}(Number(r));const o=await P(i,void 0,{cwd:rs.dirPath,shell:!0,stdio:"inherit",timeout:s?.timeout,killOnExit:!0,verbose:e.verbose});return Es(n,o.status,s),o.status??1}function ks(t,e,s=ws){return ms.run((async()=>{const[n,i]=Os(t);if(As(n,"Start (parallel)",!0),e.dryRun)return As(n,"Start (log)"),void Es(n,0,s);const r=await P(i,void 0,{cwd:rs.dirPath,shell:!0,stdio:"pipe",timeout:s?.timeout,mergeOutAndError:!0,killOnExit:!0,verbose:e.verbose});As(n,"Start (log)");const o=r.stdout.trim();o&&console.info(o),Es(n,r.status,s)}))}function Os(e){const s=function(){if(js)return _s;js=!0;let e=rs.dirPath;for(;;){const s=t.join(e,"node_modules",".bin");if(l.existsSync(s)&&(process.env.PATH=`${s}:${process.env.PATH}`,_s=!0),l.existsSync(t.join(e,".git")))break;const n=t.dirname(e);if(e===n)break;e=n}return _s}(),n=e.replaceAll("\n","").replaceAll(/\s\s+/g," ").replaceAll("PRISMA ",rs.packageJson.dependencies?.blitz?"YARN blitz prisma ":"YARN prisma ").trim();return[n.replaceAll("YARN ","yarn "),n.replaceAll("YARN ",s?"":"yarn ")]}function As(t,e="Start",s=!1){console.info("\n"+(s?O.gray:O.cyan)(O.bold(`${e}:`),t)+O.gray(` at ${rs.dirPath}`))}function Es(t,e,s){0===e?console.info(O.green(O.bold("Finished:"),t)):(console.info(O.red(O.bold(`Failed (exit code ${e}): `),t)),!1!==s.exitIfFailed&&process.exit(e??1))}let js=!1,_s=!1;const xs={...os},$s={command:"prisma",describe:"Run prisma commands",builder:t=>t.command(Ps).command(Ss).command(Ms).command(Ns).command(Ds).command(Is).command(Rs).command(zs).command(Ws).demandCommand(),handler(){}},Ps={command:"deploy",describe:"Apply migration to DB without initializing it",builder:xs,async handler(t){await vs(gs.deploy(),t)}},Cs={...xs,"backup-path":{description:"Whether to skip actual command execution",demandOption:!0,type:"string",alias:"b"}},Ss={command:"deploy-force <backup-path>",describe:"Force to apply migration to DB utilizing Litestream's backup without initializing it",builder:Cs,async handler(t){await vs(gs.deployForce(t.backupPath),t)}},Ms={command:"litestream",describe:"Setup DB for Litestream",builder:xs,async handler(t){await vs(gs.litestream(),t)}},Ns={command:"migrate",describe:"Apply migration to DB with initializing it",builder:xs,async handler(t){await vs(gs.migrate(),t)}},Ds={command:"migrate-dev",describe:"Create a migration file",builder:xs,async handler(t){await vs(gs.migrateDev(),t)}},Is={command:"reset",describe:"Reset DB",builder:xs,async handler(t){await vs(gs.reset(),t)}},Rs={command:"restore <backup-path>",describe:"Restore DB from Litestream's backup",builder:{...Cs,output:{description:'Output path of the restored database. Defaults to "<db|prisma>/restored.sqlite3".',type:"string"}},async handler(t){const e=t.output||(rs.packageJson.dependencies?.blitz?"db/restored.sqlite3":"prisma/restored.sqlite3");await vs(gs.restore(t.backupPath,e),t)}},zs={command:"seed",describe:"Populate DB with seed data",builder:xs,async handler(t){await vs(gs.seed(),t)}},Ws={command:"studio [db-url-or-path]",describe:"Open Prisma Studio",builder:{...xs,"db-url-or-path":{description:"URL or path to the database",type:"string"},restored:{description:"Whether to open the default restored database (<db|prisma>/restored.sqlite3).",type:"boolean"}},async handler(t){if(t.restored&&t.dbUrlOrPath)throw new Error("You cannot specify both --restored and --db-url-or-path.");const e=t.restored?rs.packageJson.dependencies?.blitz?"db/restored.sqlite3":"prisma/restored.sqlite3":t.dbUrlOrPath?.toString();await vs(gs.studio(e),t)}},Fs={command:"retry",describe:"Retry the given command until it succeeds",builder:{...os,retry:{description:"A maximum retry count",type:"number",alias:"r",default:3}},async handler(t){const e=t._.slice(1);let s=0;for(let n=0;n<t.retry;n++)if(n>0&&console.info(`\n${O.yellow(`#${n} Retrying: ${e.join(" ")}`)}`),s=await vs(e.join(" "),t,{exitIfFailed:!1}),0===s)return;process.exit(s)}},Ls={command:"setup",describe:"Setup development environment",builder:{...os},async handler(t){await async function(t){const e=await k.readdir(rs.dirPath,{withFileTypes:!0});e.some((t=>t.isFile()&&t.name.includes("-version")))&&await vs("asdf install",t);if(e.some((t=>t.isFile()&&"pyproject.toml"===t.name))){await ks("poetry config virtualenvs.in-project true",t),await ks("poetry config virtualenvs.prefer-active-python true",t);const[,e]=y.execSync("asdf current python").toString().trim().split(/\s+/);await ks(`poetry env use ${e}`,t),await ms.promiseAll(),await vs("poetry run pip install --upgrade pip",t),await vs("poetry install --ansi",t)}if("darwin"===x.platform()){const e=["pstree"];rs.hasDockerfile&&e.push("expect"),await ks(`brew install ${e.join(" ")}`,t)}const s=rs.packageJson.dependencies??{},n=rs.packageJson.devDependencies||{},i=rs.packageJson.scripts??{},r=[],o=[];s.blitz?(r.push("pm2"),o.push("concurrently","dotenv-cli","open-cli","vitest","wait-on")):n["@remix-run/dev"]?(r.push("dotenv-cli","pm2"),o.push("concurrently","open-cli","vitest","wait-on")):(s.express||s.fastify)&&(r.push("pm2"),o.push("concurrently","vitest","wait-on"));r.length>0&&await vs(`yarn add ${r.join(" ")}`,t);o.length>0&&await vs(`yarn add -D ${o.join(" ")}`,t);i["gen-code"]&&await vs("yarn gen-code",t)}(t)}};const Ts={...os,watch:{description:"Whether to watch files",type:"boolean"},args:{description:"Arguments for core command",type:"array",alias:"a",default:[]},"docker-args":{description:'Arguments for "docker run"',type:"array",alias:"a",default:[]}};const Us=new class{buildDevImage(e="local"){const s=rs.dockerPackageJson.scripts?.["docker/build/prepare"]?"yarn run docker/build/prepare && ":"";return`cd ${t.dirname(rs.dockerfilePath)}\n && ${s}YARN wb optimizeForDockerBuild --outside\n && YARN wb retry -- docker build -t ${rs.name}\n --build-arg ARCH=$([ $(uname -m) = 'arm64' ] && echo arm64 || echo amd64)\n --build-arg WB_ENV=${e}\n --build-arg WB_VERSION=dev .`}stopAndStart(t=!1,e="",s=""){return`${this.stop()} && ${t?"unbuffer ":""}${this.start(e,s)}`}start(t="",e=""){return function(t){const e=async()=>{ys.has(t)||(ys.add(t),w(t,{shell:!0,stdio:"inherit"}))};process.on("beforeExit",e),process.on("SIGINT",e)}(this.stop()),`docker run --rm -it -p 8080:8080 --name ${rs.name} ${t} ${rs.name} ${e}`}stop(){return`true $(docker rm -f $(docker container ls -q -f name=${rs.name}) 2> /dev/null)`}stopAll(){return"true $(docker rm -f $(docker ps -q) 2> /dev/null)"}};class Bs{constructor(t=3e3){this.defaultPort=t}buildDocker(t,e="local"){return Us.buildDevImage(e)}startDocker(t){return`${this.buildDocker(t)}\n && YARN concurrently --raw --kill-others-on-fail\n "${Us.stopAndStart(!1,t.normalizedDockerArgsText??"",t.normalizedArgsText??"")}"\n "${this.waitAndOpenApp(t,8080)}"`}testE2E(t,{playwrightArgs:e,prismaDirectory:s,startCommand:n}){return`APP_ENV=production WB_ENV=test PORT=8080 YARN dotenv -c production -- concurrently --kill-others --raw --success first\n "rm -Rf ${s}/mount && ${n} && exit 1"\n "concurrently --kill-others-on-fail --raw 'wait-on -t 600000 -i 2000 http://127.0.0.1:8080' 'yarn playwright install --with-deps'\n && yarn playwright ${e}"`}testE2EDev(t,{playwrightArgs:e,startCommand:s}){return`APP_ENV=development WB_ENV=test NEXT_PUBLIC_WB_ENV=test PORT=8080 YARN dotenv -c development -- concurrently --kill-others --raw --success first\n "${s} && exit 1"\n "concurrently --kill-others-on-fail --raw 'wait-on -t 600000 -i 2000 http://127.0.0.1:8080' 'yarn playwright install --with-deps'\n && yarn playwright ${e}"`}testUnit(t){return"YARN vitest run tests/unit --color --passWithNoTests"}waitApp(t,e=this.defaultPort){return`wait-on -t 10000 http://127.0.0.1:${e} 2> /dev/null\n || wait-on -t 10000 -i 500 http://127.0.0.1:${e} 2> /dev/null\n || wait-on -t 10000 -i 1000 http://127.0.0.1:${e} 2> /dev/null\n || wait-on -t 10000 -i 2000 http://127.0.0.1:${e} 2> /dev/null\n || wait-on -t 20000 -i 4000 http://127.0.0.1:${e} 2> /dev/null\n || wait-on -t 60000 -i 5000 http://127.0.0.1:${e}`}waitAndOpenApp(t,e=this.defaultPort){return`${this.waitApp(t,e)} || wait-on http://127.0.0.1:${e} && open-cli http://localhost:${e}`}}const Hs=new class extends Bs{constructor(){super()}start(t){return`YARN concurrently --raw --kill-others-on-fail\n "blitz dev ${t.normalizedArgsText??""}"\n "${this.waitAndOpenApp(t)}"`}startProduction(t,e){return`NODE_ENV=production YARN concurrently --raw --kill-others-on-fail\n "${gs.reset()} && ${rs.getBuildCommand(t)} && PORT=${e} pm2-runtime start ecosystem.config.cjs ${t.normalizedArgsText??""}"\n "${this.waitAndOpenApp(t,e)}"`}testE2E(t,{playwrightArgs:e="test tests/e2e",startCommand:s=`${gs.reset()} && ${rs.getBuildCommand(t)} && pm2-runtime start ecosystem.config.cjs`}){return super.testE2E(t,{playwrightArgs:e,prismaDirectory:"db",startCommand:s})}testE2EDev(t,{playwrightArgs:e="test tests/e2e",startCommand:s="blitz dev -p 8080"}){return super.testE2EDev(t,{playwrightArgs:e,startCommand:s})}testStart(t){return`YARN concurrently --kill-others --raw --success first "blitz dev" "${this.waitApp(t)}"`}};const Vs=new class extends Bs{constructor(){super()}start(t){return`YARN build-ts run src/index.ts ${t.watch?"--watch":""} -- ${t.normalizedArgsText??""}`}startDocker(t){return`${this.buildDocker(t)} && ${Us.stopAndStart(!1,t.normalizedDockerArgsText??"",t.normalizedArgsText??"")}`}startProduction(t,e=8080){return`NODE_ENV=production ${rs.getBuildCommand(t)} && NODE_ENV=production PORT=\${PORT:-${e}} node dist/index.js ${t.normalizedArgsText??""}`}testE2E(t,{startCommand:e=`if [ -e "prisma" ]; then prisma migrate reset --force --skip-generate; fi && (${this.startProduction(t)})`}){return`NODE_ENV=production WB_ENV=test PORT=8080 YARN concurrently --kill-others --raw --success first\n "${e} && exit 1"\n "wait-on -t 600000 -i 2000 http://127.0.0.1:8080 && vitest run tests/e2e --color --passWithNoTests"`}testE2EDev(t,{startCommand:e}){return`NODE_ENV=production WB_ENV=test PORT=8080 YARN concurrently --kill-others --raw --success first\n "${e||this.start(t)} && exit 1"\n "wait-on -t 600000 -i 2000 http://127.0.0.1:8080 && vitest run tests/e2e --color --passWithNoTests"`}testStart(t){return`YARN concurrently --kill-others --raw --success first "${this.start(t)}" "${this.waitApp(t)}"`}};const qs=new class extends Bs{constructor(){super()}start(t){return`YARN build-ts run src/index.ts ${t.watch?"--watch":""} -- ${t.normalizedArgsText??""}`}startDocker(t){return`${this.buildDocker(t)} && ${Us.stopAndStart(!1,t.normalizedDockerArgsText??"",t.normalizedArgsText??"")}`}startProduction(t){return`NODE_ENV=production ${rs.getBuildCommand(t)} && NODE_ENV=production node dist/index.js ${t.normalizedArgsText??""}`}testE2E(){return"echo 'do nothing.'"}testE2EDev(){return"echo 'do nothing.'"}testStart(){return"echo 'do nothing.'"}};const Ys=new class extends Bs{constructor(){super()}start(t){return`YARN concurrently --raw --kill-others-on-fail\n "dotenv -c development -- remix dev ${t.normalizedArgsText??""}"\n "${this.waitAndOpenApp(t)}"`}startProduction(t,e){return`NODE_ENV=production YARN dotenv -c production -- concurrently --raw --kill-others-on-fail\n "${gs.reset()} && ${rs.getBuildCommand(t)} && PORT=${e} pm2-runtime start ecosystem.config.cjs ${t.normalizedArgsText??""}"\n "${this.waitAndOpenApp(t,e)}"`}testE2E(t,{playwrightArgs:e="test tests/e2e",startCommand:s=`${gs.reset()} && ${rs.getBuildCommand(t)} && pm2-runtime start ecosystem.config.cjs`}){return super.testE2E(t,{playwrightArgs:e,prismaDirectory:"prisma",startCommand:s})}testE2EDev(t,{playwrightArgs:e="test tests/e2e",startCommand:s="remix dev"}){return super.testE2EDev(t,{playwrightArgs:e,startCommand:s})}testStart(t){return`YARN concurrently --kill-others --raw --success first "dotenv -c development -- remix dev" "${this.waitApp(t)}"`}},Js={command:"start [args..]",describe:"Start app",builder:{...Ts,mode:{description:"Start mode: dev[elopment] (default) | prod[uction] | docker",type:"string",alias:"m"}},async handler(t){!function(t){t.normalizedArgsText=[...t.args??[],...t._?.slice(1)??[]].map((t=>`'${t}'`)).join(" "),t.normalizedDockerArgsText=(t.dockerArgs??[]).map((t=>`'${t}'`)).join(" ")}(t);const e=rs.packageJson.dependencies||{},s=rs.packageJson.devDependencies||{};let n;switch(n=e.blitz?Hs:s["@remix-run/dev"]?Ys:(e.express||e.fastify)&&!e["firebase-functions"]||rs.hasDockerfile&&/EXPOSE\s+8080/.test(rs.dockerfile)?Vs:qs,t.mode||"dev"){case"dev":case"development":await vs(n.start(t),t);break;case"prod":case"production":await vs(n.startProduction(t,8080),t);break;case"docker":await vs(n.startDocker(t),t);break;default:throw new Error(`Unknown start mode: ${t.mode}`)}}},Gs={command:"test",describe:"Test project",builder:{...os,ci:{description:"Whether to run tests on CI",type:"boolean"},e2e:{description:"Whether to run e2e tests. You may pass mode as argument: none | headless (default) | headless-dev | headed | headed-dev | docker | docker-debug | debug | generate | trace",type:"string"},start:{description:"Whether to run start tests",type:"boolean"},unit:{description:"Whether to run unit tests",type:"boolean"},"unit-timeout":{description:"Timeout for unit tests",type:"number"}},async handler(e){await async function(e){process.env.FORCE_COLOR="3",await async function(t){if(!rs.packageJson.workspaces)return;const e=process.argv.slice(2),s=e.findIndex((t=>["-w","--working-dir","--workingDir"].includes(t)));s>=0&&e.splice(s,2),process.env.CI="1",await vs(["yarn","workspaces","foreach","--all","--exclude",rs.name,"--verbose","run","wb",...e].join(" "),t),process.exit(0)}(e);const s=rs.packageJson.dependencies||{},n=rs.packageJson.devDependencies||{};let i;i=s.blitz?Hs:n["@remix-run/dev"]?Ys:!s.express&&!s.fastify||s["firebase-functions"]?qs:Vs;const r=[];if(e.ci){const s=$(t.join(rs.dirPath,"tests","unit")),n=$(t.join(rs.dirPath,"tests","e2e"));if(await ks(Us.stopAll(),e),!1!==e.unit&&await s&&await ks(i.testUnit(e),e,{timeout:e.unitTimeout}),!1!==e.start&&await ks(i.testStart(e),e),await ms.promiseAll(),"none"!==e.e2e&&await n){rs.hasDockerfile&&await vs(`${i.buildDocker(e,"test")}`,e);const t=rs.hasDockerfile?{startCommand:Us.stopAndStart(!0)}:{};process.exitCode=await vs(i.testE2E(e,t),e,{exitIfFailed:!1}),await vs(Us.stop(),e)}return}(e.unit||!e.start&&void 0===e.e2e)&&r.push(vs(i.testUnit(e),e,{timeout:e.unitTimeout}));e.start&&r.push(vs(i.testStart(e),e));switch(await Promise.all(r),e.e2e){case void 0:case"none":return;case"":case"headless":return void await vs(i.testE2E(e,{}),e);case"headless-dev":return void await vs(i.testE2EDev(e,{}),e);case"docker":return void await Ks(e,i);case"docker-debug":return void await Ks(e,i,"PWDEBUG=1 ")}if(s.blitz||n["@remix-run/dev"])switch(e.e2e){case"headed":return void await vs(i.testE2E(e,{playwrightArgs:"test tests/e2e --headed"}),e);case"headed-dev":return void await vs(i.testE2EDev(e,{playwrightArgs:"test tests/e2e --headed"}),e);case"debug":return void await vs(`PWDEBUG=1 ${i.testE2E(e,{})}`,e);case"generate":return void await vs(i.testE2E(e,{playwrightArgs:"codegen http://localhost:8080"}),e);case"trace":return void await vs("playwright show-trace",e)}throw new Error(`Unknown e2e mode: ${e.e2e}`)}(e)}};async function Ks(t,e,s=""){await vs(`${e.buildDocker(t,"test")}`,t),process.exitCode=await vs(`${s}${e.testE2E(t,{startCommand:Us.stopAndStart(!0)})}`,t,{exitIfFailed:!1}),await vs(Us.stop(),t)}const Qs={command:"typecheck",describe:"Run type checking",builder:{...os},async handler(t){const e=[];if(rs.packageJson.workspaces?e.push(`yarn workspaces foreach --all --parallel --exclude ${rs.name} --verbose run typecheck`):((rs.packageJson.dependencies?.typescript||rs.packageJson.devDependencies?.typescript)&&e.push("tsc --noEmit --Pretty"),rs.packageJson.devDependencies?.pyright&&e.push("pyright")),process.exitCode=await vs(e.join(" && "),t),0!==process.exitCode){(JSON.parse(await k.readFile("package.json","utf8")).dependencies||{}).blitz&&console.info(O.yellow('Please try "yarn gen-code" if you face unknown type errors.'))}}},Zs={...Qs,command:"tc"};var Xs;await ns((Xs=process.argv,Xs.slice(Z()+1))).scriptName("wb").options(os).middleware((e=>{const s=e["working-dir"];if(s){const e=t.resolve(s);process.chdir(e),rs.dirPath=e}!function(t){t.PATH&&t.BERRY_BIN_FOLDER&&(t.PATH=t.PATH.replace(`${t.BERRY_BIN_FOLDER}:`,"").replaceAll(/\/private\/var\/folders\/[^:]+:/g,"").replaceAll(/\/var\/tmp\/[^:]+:/g,"").replaceAll(/\/tmp\/[^:]+:/g,""));for(const e of Object.keys(t)){const s=e.toUpperCase();(s.startsWith("NPM_")||s.startsWith("YARN_")||s.startsWith("BERRY_")||"PROJECT_CWD"===s||"INIT_CWD"===s)&&delete t[e]}}(process.env),function(e,s){let n=(e.env??[]).map((t=>t.toString()));const i=e.cascadeNodeEnv?process.env.NODE_ENV||"development":e.cascadeEnv;"string"==typeof i&&(0===n.length&&n.push(".env"),n=n.flatMap((t=>i?[`${t}.${i}.local`,`${t}.local`,`${t}.${i}`,t]:[`${t}.local`,t]))),e.verbose&&console.info("Loading env files:",n);let r={};for(const e of n)r={...A({path:t.join(s,e)}).parsed,...r}}(e,rs.dirPath)})).command(as).command(us).command($s).command(Fs).command(Ls).command(Js).command(Gs).command(Qs).command(Zs).demandCommand().strict().help().argv;for(const t of["SIGINT","SIGTERM","SIGQUIT"])process.on(t,(()=>process.exit()));
34
34
  //# sourceMappingURL=index.js.map