@willbooster/wb 7.1.4 → 7.1.5

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,10 +1,10 @@
1
- import e,{resolve as t,dirname as n,normalize as s,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 v}from"node:child_process";import{createHash as w}from"node:crypto";import O from"chalk";import{config as E}from"dotenv";import k from"kill-port";import{PromisePool as A}from"minimal-promise-pool";import j from"tree-kill";import $ from"node:fs/promises";import _ from"node:os";function x(t,n,s=!0){let i=(t.env??[]).map((t=>e.resolve(n,t.toString())));const r=t.cascadeEnv??(t.cascadeNodeEnv?process.env.NODE_ENV||"development":t.autoCascadeEnv?process.env.WB_ENV||process.env.NODE_ENV||"development":void 0);if("string"==typeof r){if(0===i.length&&(i.push(e.join(n,".env")),t.includeRootEnv)){const t=e.resolve(n,"..","..");l.existsSync(e.join(t,"package.json"))&&i.push(e.join(t,".env"))}i=i.flatMap((e=>r?[`${e}.${r}.local`,`${e}.local`,`${e}.${r}`,e]:[`${e}.local`,e]))}i=i.map((t=>e.relative(n,t))),t.verbose&&(console.info(`WB_ENV: ${process.env.WB_ENV}, NODE_ENV: ${process.env.NODE_ENV}`),console.info("Reading env files:",i));let o={};const a={...process.env};for(const t of i){o={...P(e.join(n,t),s),...o};let i=0;for(const[e,t]of Object.entries(o))a[e]!==t&&(a[e]=t,i++);i>0&&console.info(`Read ${i} environment variables:`,t)}if(t.checkEnv){const r=Object.keys(P(e.join(n,t.checkEnv),s)||{}).filter((e=>!(e in o)));if(r.length>0)throw new Error(`Missing environment variables in [${i.join(", ")}]: [${r.join(", ")}]`)}return o}const C=new Map;function P(t,n=!0){const s=n&&C.get(t);if(s)return s;const i=E({path:e.resolve(t),processEnv:{}}).parsed??{};return n&&C.set(t,i),i}function S(e){return new Promise((t=>{l.access(e,l.constants.F_OK,(e=>{t(!e)}))}))}async function N(e,t,n){return new Promise(((s,i)=>{try{const r=b(e,t??[],n??{});let o="",a="";n?.input&&(r.stdin?.write(n.input),r.stdin?.end()),r.stdout?.on("data",(e=>{o+=e})),r.stderr?.on("data",(e=>{n?.mergeOutAndError?o+=e:a+=e}));let c=!1;const l=()=>{!c&&r.pid&&(c=!0,n?.verbose&&console.info(`treeKill(${r.pid})`),j(r.pid))};n?.killOnExit&&(process.on("beforeExit",l),process.on("SIGINT",l)),r.on("error",(e=>{process.removeListener("exit",l),r.removeAllListeners("close"),i(e)})),r.on("close",((e,t)=>{process.removeListener("exit",l),void 0===r.pid?i(new Error("Process has no pid.")):s({pid:r.pid,stdout:o,stderr:a,status:e,signal:t})}))}catch(e){i(e)}}))}const M={right:function(e,t){e=e.trim();const n=R.stringWidth(e);if(n<t)return" ".repeat(t-n)+e;return e},center:function(e,t){e=e.trim();const n=R.stringWidth(e);if(n>=t)return e;return" ".repeat(t-n>>1)+e}};class D{constructor(e){var t;this.width=e.width,this.wrap=null===(t=e.wrap)||void 0===t||t,this.rows=[]}span(...e){this.div(...e).span=!0}resetOutput(){this.rows=[]}div(...e){if(0===e.length&&this.div(""),this.wrap&&this.shouldApplyLayoutDSL(...e)&&"string"==typeof e[0])return this.applyLayoutDSL(e[0]);const t=e.map((e=>"string"==typeof e?this.colFromString(e):e));return this.rows.push(t),t}shouldApplyLayoutDSL(...e){return 1===e.length&&"string"==typeof e[0]&&/[\t\n]/.test(e[0])}applyLayoutDSL(e){const t=e.split("\n").map((e=>e.split("\t")));let n=0;return t.forEach((e=>{e.length>1&&R.stringWidth(e[0])>n&&(n=Math.min(Math.floor(.5*this.width),R.stringWidth(e[0])))})),t.forEach((e=>{this.div(...e.map(((t,s)=>({text:t.trim(),padding:this.measurePadding(t),width:0===s&&e.length>1?n:void 0}))))})),this.rows[this.rows.length-1]}colFromString(e){return{text:e,padding:this.measurePadding(e)}}measurePadding(e){const t=R.stripAnsi(e);return[0,t.match(/\s*$/)[0].length,0,t.match(/^\s*/)[0].length]}toString(){const e=[];return this.rows.forEach((t=>{this.rowToString(t,e)})),e.filter((e=>!e.hidden)).map((e=>e.text)).join("\n")}rowToString(e,t){return this.rasterize(e).forEach(((n,s)=>{let i="";n.forEach(((n,r)=>{const{width:o}=e[r],a=this.negatePadding(e[r]);let c=n;if(a>R.stringWidth(n)&&(c+=" ".repeat(a-R.stringWidth(n))),e[r].align&&"left"!==e[r].align&&this.wrap){c=(0,M[e[r].align])(c,a),R.stringWidth(c)<a&&(c+=" ".repeat((o||0)-R.stringWidth(c)-1))}const l=e[r].padding||[0,0,0,0];l[3]&&(i+=" ".repeat(l[3])),i+=I(e[r],c,"| "),i+=c,i+=I(e[r],c," |"),l[1]&&(i+=" ".repeat(l[1])),0===s&&t.length>0&&(i=this.renderInline(i,t[t.length-1]))})),t.push({text:i.replace(/ +$/,""),span:e.span})})),t}renderInline(e,t){const n=e.match(/^ */),s=n?n[0].length:0,i=t.text,r=R.stringWidth(i.trimRight());return t.span?this.wrap?s<r?e:(t.hidden=!0,i.trimRight()+" ".repeat(s-r)+e.trimLeft()):(t.hidden=!0,i+e):e}rasterize(e){const t=[],n=this.columnWidths(e);let s;return e.forEach(((e,i)=>{e.width=n[i],s=this.wrap?R.wrap(e.text,this.negatePadding(e),{hard:!0}).split("\n"):e.text.split("\n"),e.border&&(s.unshift("."+"-".repeat(this.negatePadding(e)+2)+"."),s.push("'"+"-".repeat(this.negatePadding(e)+2)+"'")),e.padding&&(s.unshift(...new Array(e.padding[0]||0).fill("")),s.push(...new Array(e.padding[2]||0).fill(""))),s.forEach(((e,n)=>{t[n]||t.push([]);const s=t[n];for(let e=0;e<i;e++)void 0===s[e]&&s.push("");s.push(e)}))})),t}negatePadding(e){let t=e.width||0;return e.padding&&(t-=(e.padding[3]||0)+(e.padding[1]||0)),e.border&&(t-=4),t}columnWidths(e){if(!this.wrap)return e.map((e=>e.width||R.stringWidth(e.text)));let t=e.length,n=this.width;const s=e.map((e=>{if(e.width)return t--,n-=e.width,e.width})),i=t?Math.floor(n/t):0;return s.map(((t,n)=>void 0===t?Math.max(i,function(e){const t=e.padding||[],n=1+(t[3]||0)+(t[1]||0);if(e.border)return n+4;return n}(e[n])):t))}}function I(e,t,n){return e.border?/[.']-+[.']/.test(t)?"":0!==t.trim().length?n:" ":""}let R;const W=new RegExp("(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)","g");function z(e){return e.replace(W,"")}function F(e,t){const[n,s]=e.match(W)||["",""];e=z(e);let i="";for(let n=0;n<e.length;n++)0!==n&&n%t==0&&(i+="\n"),i+=e.charAt(n);return n&&s&&(i=`${n}${i}${s}`),i}
1
+ import t,{resolve as e,dirname as n,normalize as s,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 v}from"node:child_process";import{createHash as w}from"node:crypto";import O from"chalk";import{config as E}from"dotenv";import k from"kill-port";import{PromisePool as A}from"minimal-promise-pool";import j from"tree-kill";import $ from"node:fs/promises";import _ from"node:os";function x(e,n,s=!0){let i=(e.env??[]).map((e=>t.resolve(n,e.toString())));const r=e.cascadeEnv??(e.cascadeNodeEnv?process.env.NODE_ENV||"development":e.autoCascadeEnv?process.env.WB_ENV||process.env.NODE_ENV||"development":void 0);if("string"==typeof r){if(0===i.length&&(i.push(t.join(n,".env")),e.includeRootEnv)){const e=t.resolve(n,"..","..");l.existsSync(t.join(e,"package.json"))&&i.push(t.join(e,".env"))}i=i.flatMap((t=>r?[`${t}.${r}.local`,`${t}.local`,`${t}.${r}`,t]:[`${t}.local`,t]))}i=i.map((e=>t.relative(n,e))),e.verbose&&(console.info(`WB_ENV: ${process.env.WB_ENV}, NODE_ENV: ${process.env.NODE_ENV}`),console.info("Reading env files:",i));let o={};const a={...process.env};for(const e of i){o={...P(t.join(n,e),s),...o};let i=0;for(const[t,e]of Object.entries(o))a[t]!==e&&(a[t]=e,i++);i>0&&console.info(`Read ${i} environment variables:`,e)}if(e.checkEnv){const r=Object.keys(P(t.join(n,e.checkEnv),s)||{}).filter((t=>!(t in o)));if(r.length>0)throw new Error(`Missing environment variables in [${i.join(", ")}]: [${r.join(", ")}]`)}return o}const C=new Map;function P(e,n=!0){const s=n&&C.get(e);if(s)return s;const i=E({path:t.resolve(e),processEnv:{}}).parsed??{};return n&&C.set(e,i),i}function S(t){return new Promise((e=>{l.access(t,l.constants.F_OK,(t=>{e(!t)}))}))}async function N(t,e,n){return new Promise(((s,i)=>{try{const r=b(t,e??[],n??{});let o="",a="";n?.input&&(r.stdin?.write(n.input),r.stdin?.end()),r.stdout?.on("data",(t=>{o+=t})),r.stderr?.on("data",(t=>{n?.mergeOutAndError?o+=t:a+=t}));let c=!1;const l=()=>{!c&&r.pid&&(c=!0,n?.verbose&&console.info(`treeKill(${r.pid})`),j(r.pid))};n?.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.")):s({pid:r.pid,stdout:o,stderr:a,status:t,signal:e})}))}catch(t){i(t)}}))}const M={right:function(t,e){t=t.trim();const n=R.stringWidth(t);if(n<e)return" ".repeat(e-n)+t;return t},center:function(t,e){t=t.trim();const n=R.stringWidth(t);if(n>=e)return t;return" ".repeat(e-n>>1)+t}};class D{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 n=0;return e.forEach((t=>{t.length>1&&R.stringWidth(t[0])>n&&(n=Math.min(Math.floor(.5*this.width),R.stringWidth(t[0])))})),e.forEach((t=>{this.div(...t.map(((e,s)=>({text:e.trim(),padding:this.measurePadding(e),width:0===s&&t.length>1?n:void 0}))))})),this.rows[this.rows.length-1]}colFromString(t){return{text:t,padding:this.measurePadding(t)}}measurePadding(t){const e=R.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(((n,s)=>{let i="";n.forEach(((n,r)=>{const{width:o}=t[r],a=this.negatePadding(t[r]);let c=n;if(a>R.stringWidth(n)&&(c+=" ".repeat(a-R.stringWidth(n))),t[r].align&&"left"!==t[r].align&&this.wrap){c=(0,M[t[r].align])(c,a),R.stringWidth(c)<a&&(c+=" ".repeat((o||0)-R.stringWidth(c)-1))}const l=t[r].padding||[0,0,0,0];l[3]&&(i+=" ".repeat(l[3])),i+=I(t[r],c,"| "),i+=c,i+=I(t[r],c," |"),l[1]&&(i+=" ".repeat(l[1])),0===s&&e.length>0&&(i=this.renderInline(i,e[e.length-1]))})),e.push({text:i.replace(/ +$/,""),span:t.span})})),e}renderInline(t,e){const n=t.match(/^ */),s=n?n[0].length:0,i=e.text,r=R.stringWidth(i.trimRight());return e.span?this.wrap?s<r?t:(e.hidden=!0,i.trimRight()+" ".repeat(s-r)+t.trimLeft()):(e.hidden=!0,i+t):t}rasterize(t){const e=[],n=this.columnWidths(t);let s;return t.forEach(((t,i)=>{t.width=n[i],s=this.wrap?R.wrap(t.text,this.negatePadding(t),{hard:!0}).split("\n"):t.text.split("\n"),t.border&&(s.unshift("."+"-".repeat(this.negatePadding(t)+2)+"."),s.push("'"+"-".repeat(this.negatePadding(t)+2)+"'")),t.padding&&(s.unshift(...new Array(t.padding[0]||0).fill("")),s.push(...new Array(t.padding[2]||0).fill(""))),s.forEach(((t,n)=>{e[n]||e.push([]);const s=e[n];for(let t=0;t<i;t++)void 0===s[t]&&s.push("");s.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||R.stringWidth(t.text)));let e=t.length,n=this.width;const s=t.map((t=>{if(t.width)return e--,n-=t.width,t.width})),i=e?Math.floor(n/e):0;return s.map(((e,n)=>void 0===e?Math.max(i,function(t){const e=t.padding||[],n=1+(e[3]||0)+(e[1]||0);if(t.border)return n+4;return n}(t[n])):e))}}function I(t,e,n){return t.border?/[.']-+[.']/.test(e)?"":0!==e.trim().length?n:" ":""}let R;const W=new RegExp("(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)","g");function z(t){return t.replace(W,"")}function F(t,e){const[n,s]=t.match(W)||["",""];t=z(t);let i="";for(let n=0;n<t.length;n++)0!==n&&n%e==0&&(i+="\n"),i+=t.charAt(n);return n&&s&&(i=`${n}${i}${s}`),i}
2
2
  /**
3
3
  * @license
4
4
  * Copyright (c) 2016, Contributors
5
5
  * SPDX-License-Identifier: ISC
6
6
  */
7
- function T(e){if(e!==e.toLowerCase()&&e!==e.toUpperCase()||(e=e.toLowerCase()),-1===e.indexOf("-")&&-1===e.indexOf("_"))return e;{let t="",n=!1;const s=e.match(/^-+/);for(let i=s?s[0].length:0;i<e.length;i++){let s=e.charAt(i);n&&(n=!1,s=s.toUpperCase()),0===i||"-"!==s&&"_"!==s?"-"!==s&&"_"!==s&&(t+=s):n=!0}return t}}function L(e,t){const n=e.toLowerCase();t=t||"-";let s="";for(let i=0;i<e.length;i++){const r=n.charAt(i),o=e.charAt(i);s+=r!==o&&i>0?`${t}${n.charAt(i)}`:o}return s}function B(e){return null!=e&&("number"==typeof e||(!!/^0x[0-9a-f]+$/i.test(e)||!/^0[^.]/.test(e)&&/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(e)))}
7
+ function T(t){if(t!==t.toLowerCase()&&t!==t.toUpperCase()||(t=t.toLowerCase()),-1===t.indexOf("-")&&-1===t.indexOf("_"))return t;{let e="",n=!1;const s=t.match(/^-+/);for(let i=s?s[0].length:0;i<t.length;i++){let s=t.charAt(i);n&&(n=!1,s=s.toUpperCase()),0===i||"-"!==s&&"_"!==s?"-"!==s&&"_"!==s&&(e+=s):n=!0}return e}}function L(t,e){const n=t.toLowerCase();e=e||"-";let s="";for(let i=0;i<t.length;i++){const r=n.charAt(i),o=t.charAt(i);s+=r!==o&&i>0?`${e}${n.charAt(i)}`:o}return s}function B(t){return null!=t&&("number"==typeof t||(!!/^0x[0-9a-f]+$/i.test(t)||!/^0[^.]/.test(t)&&/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(t)))}
8
8
  /**
9
9
  * @license
10
10
  * Copyright (c) 2016, Contributors
@@ -21,7 +21,7 @@ var V;
21
21
  * Copyright (c) 2016, Contributors
22
22
  * SPDX-License-Identifier: ISC
23
23
  */
24
- let U;!function(e){e.BOOLEAN="boolean",e.STRING="string",e.NUMBER="number",e.ARRAY="array"}(V||(V={}));function H(e){return void 0!==e?e+1:1}function Y(e){return"__proto__"===e?"___proto___":e}
24
+ let U;!function(t){t.BOOLEAN="boolean",t.STRING="string",t.NUMBER="number",t.ARRAY="array"}(V||(V={}));function H(t){return void 0!==t?t+1:1}function Y(t){return"__proto__"===t?"___proto___":t}
25
25
  /**
26
26
  * @fileoverview Main entrypoint for libraries using yargs-parser in Node.js
27
27
  * CJS and ESM environments.
@@ -30,5 +30,5 @@ let U;!function(e){e.BOOLEAN="boolean",e.STRING="string",e.NUMBER="number",e.ARR
30
30
  * Copyright (c) 2016, Contributors
31
31
  * SPDX-License-Identifier: ISC
32
32
  */
33
- var q,J,G;const K=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,Q=null!==(J=null===(q=null===process||void 0===process?void 0:process.versions)||void 0===q?void 0:q.node)&&void 0!==J?J:null===(G=null===process||void 0===process?void 0:process.version)||void 0===G?void 0:G.slice(1);if(Q){if(Number(Q.match(/^([^.]+)/)[1])<K)throw Error(`yargs parser supports a minimum Node.js version of ${K}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}const X=process?process.env:{},Z=new class{constructor(e){U=e}parse(e,t){const n=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},t),s=function(e){if(Array.isArray(e))return e.map((e=>"string"!=typeof e?e+"":e));e=e.trim();let t=0,n=null,s=null,i=null;const r=[];for(let o=0;o<e.length;o++)n=s,s=e.charAt(o)," "!==s||i?(s===i?i=null:"'"!==s&&'"'!==s||i||(i=s),r[t]||(r[t]=""),r[t]+=s):" "!==n&&t++;return r}(e),i="string"==typeof e,r=function(e){const t=[],n=Object.create(null);let s=!0;Object.keys(e).forEach((function(n){t.push([].concat(e[n],n))}));for(;s;){s=!1;for(let e=0;e<t.length;e++)for(let n=e+1;n<t.length;n++){if(t[e].filter((function(e){return-1!==t[n].indexOf(e)})).length){t[e]=t[e].concat(t[n]),t.splice(n,1),s=!0;break}}}return t.forEach((function(e){const t=(e=e.filter((function(e,t,n){return n.indexOf(e)===t}))).pop();void 0!==t&&"string"==typeof t&&(n[t]=e)})),n}(Object.assign(Object.create(null),n.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},n.configuration),a=Object.assign(Object.create(null),n.default),c=n.configObjects||[],l=n.envPrefix,h=o["populate--"],d=h?"--":"_",u=Object.create(null),f=Object.create(null),p=n.__||U.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(n.array||[]).filter(Boolean).forEach((function(e){const t="object"==typeof e?e.key:e,n=Object.keys(e).map((function(e){return{boolean:"bools",string:"strings",number:"numbers"}[e]})).filter(Boolean).pop();n&&(g[n][t]=!0),g.arrays[t]=!0,g.keys.push(t)})),[].concat(n.boolean||[]).filter(Boolean).forEach((function(e){g.bools[e]=!0,g.keys.push(e)})),[].concat(n.string||[]).filter(Boolean).forEach((function(e){g.strings[e]=!0,g.keys.push(e)})),[].concat(n.number||[]).filter(Boolean).forEach((function(e){g.numbers[e]=!0,g.keys.push(e)})),[].concat(n.count||[]).filter(Boolean).forEach((function(e){g.counts[e]=!0,g.keys.push(e)})),[].concat(n.normalize||[]).filter(Boolean).forEach((function(e){g.normalize[e]=!0,g.keys.push(e)})),"object"==typeof n.narg&&Object.entries(n.narg).forEach((([e,t])=>{"number"==typeof t&&(g.nargs[e]=t,g.keys.push(e))})),"object"==typeof n.coerce&&Object.entries(n.coerce).forEach((([e,t])=>{"function"==typeof t&&(g.coercions[e]=t,g.keys.push(e))})),void 0!==n.config&&(Array.isArray(n.config)||"string"==typeof n.config?[].concat(n.config).filter(Boolean).forEach((function(e){g.configs[e]=!0})):"object"==typeof n.config&&Object.entries(n.config).forEach((([e,t])=>{"boolean"!=typeof t&&"function"!=typeof t||(g.configs[e]=t)}))),function(...e){e.forEach((function(e){Object.keys(e||{}).forEach((function(e){g.aliases[e]||(g.aliases[e]=[].concat(r[e]||[]),g.aliases[e].concat(e).forEach((function(t){if(/-/.test(t)&&o["camel-case-expansion"]){const n=T(t);n!==e&&-1===g.aliases[e].indexOf(n)&&(g.aliases[e].push(n),u[n]=!0)}})),g.aliases[e].concat(e).forEach((function(t){if(t.length>1&&/[A-Z]/.test(t)&&o["camel-case-expansion"]){const n=L(t,"-");n!==e&&-1===g.aliases[e].indexOf(n)&&(g.aliases[e].push(n),u[n]=!0)}})),g.aliases[e].forEach((function(t){g.aliases[t]=[e].concat(g.aliases[e].filter((function(e){return t!==e})))})))}))}))}(n.key,r,n.default,g.arrays),Object.keys(a).forEach((function(e){(g.aliases[e]||[]).forEach((function(t){a[t]=a[e]}))}));let b=null;Object.keys(g.counts).find((e=>D(e,g.arrays)?(b=Error(p("Invalid configuration: %s, opts.count excludes opts.array.",e)),!0):!!D(e,g.nargs)&&(b=Error(p("Invalid configuration: %s, opts.count excludes opts.narg.",e)),!0)));let v=[];const w=Object.assign(Object.create(null),{_:[]}),O={};for(let e=0;e<s.length;e++){const t=s[e],n=t.replace(/^-{3,}/,"---");let i,r,a,c,l,h;if("--"!==t&&/^-/.test(t)&&R(t))E(t);else{if(n.match(/^---+(=|$)/)){E(t);continue}if(t.match(/^--.+=/)||!o["short-option-groups"]&&t.match(/^-.+=/))c=t.match(/^--?([^=]+)=([\s\S]*)$/),null!==c&&Array.isArray(c)&&c.length>=3&&(D(c[1],g.arrays)?e=A(e,c[1],s,c[2]):!1!==D(c[1],g.nargs)?e=k(e,c[1],s,c[2]):j(c[1],c[2],!0));else if(t.match(y)&&o["boolean-negation"])c=t.match(y),null!==c&&Array.isArray(c)&&c.length>=2&&(r=c[1],j(r,!!D(r,g.arrays)&&[!1]));else if(t.match(/^--.+/)||!o["short-option-groups"]&&t.match(/^-[^-]+/))c=t.match(/^--?(.+)/),null!==c&&Array.isArray(c)&&c.length>=2&&(r=c[1],D(r,g.arrays)?e=A(e,r,s):!1!==D(r,g.nargs)?e=k(e,r,s):(l=s[e+1],void 0===l||l.match(/^-/)&&!l.match(m)||D(r,g.bools)||D(r,g.counts)?/^(true|false)$/.test(l)?(j(r,l),e++):j(r,W(r)):(j(r,l),e++)));else if(t.match(/^-.\..+=/))c=t.match(/^-([^=]+)=([\s\S]*)$/),null!==c&&Array.isArray(c)&&c.length>=3&&j(c[1],c[2]);else if(t.match(/^-.\..+/)&&!t.match(m))l=s[e+1],c=t.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,W(r)):(j(r,l),e++));else if(t.match(/^-[^-]+/)&&!t.match(m)){a=t.slice(1,-1).split(""),i=!1;for(let n=0;n<a.length;n++){if(l=t.slice(n+2),a[n+1]&&"="===a[n+1]){h=t.slice(n+3),r=a[n],D(r,g.arrays)?e=A(e,r,s,h):!1!==D(r,g.nargs)?e=k(e,r,s,h):j(r,h),i=!0;break}if("-"!==l){if(/[A-Za-z]/.test(a[n])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(l)&&!1===D(l,g.bools)){j(a[n],l),i=!0;break}if(a[n+1]&&a[n+1].match(/\W/)){j(a[n],l),i=!0;break}j(a[n],W(a[n]))}else j(a[n],l)}r=t.slice(-1)[0],i||"-"===r||(D(r,g.arrays)?e=A(e,r,s):!1!==D(r,g.nargs)?e=k(e,r,s):(l=s[e+1],void 0===l||/^(-|--)[^-]/.test(l)&&!l.match(m)||D(r,g.bools)||D(r,g.counts)?/^(true|false)$/.test(l)?(j(r,l),e++):j(r,W(r)):(j(r,l),e++)))}else if(t.match(/^-[0-9]$/)&&t.match(m)&&D(t.slice(1),g.bools))r=t.slice(1),j(r,W(r));else{if("--"===t){v=s.slice(e+1);break}if(o["halt-at-non-option"]){v=s.slice(e);break}E(t)}}}function E(e){const t=x("_",e);"string"!=typeof t&&"number"!=typeof t||w._.push(t)}function k(e,t,n,s){let i,r=D(t,g.nargs);if(r="number"!=typeof r||isNaN(r)?1:r,0===r)return z(s)||(b=Error(p("Argument unexpected for: %s",t))),j(t,W(t)),e;let a=z(s)?0:1;if(o["nargs-eats-options"])n.length-(e+1)+a<r&&(b=Error(p("Not enough arguments following: %s",t))),a=r;else{for(i=e+1;i<n.length&&(!n[i].match(/^-[^0-9]/)||n[i].match(m)||R(n[i]));i++)a++;a<r&&(b=Error(p("Not enough arguments following: %s",t)))}let c=Math.min(a,r);for(!z(s)&&c>0&&(j(t,s),c--),i=e+1;i<c+e+1;i++)j(t,n[i]);return e+c}function A(e,t,n,s){let r=[],c=s||n[e+1];const l=D(t,g.nargs);if(D(t,g.bools)&&!/^(true|false)$/.test(c))r.push(!0);else if(z(c)||z(s)&&/^-/.test(c)&&!m.test(c)&&!R(c)){if(void 0!==a[t]){const e=a[t];r=Array.isArray(e)?e:[e]}}else{z(s)||r.push(_(t,s,!0));for(let s=e+1;s<n.length&&!(!o["greedy-arrays"]&&r.length>0||l&&"number"==typeof l&&r.length>=l)&&(c=n[s],!/^-/.test(c)||m.test(c)||R(c));s++)e=s,r.push(_(t,c,i))}return"number"==typeof l&&(l&&r.length<l||isNaN(l)&&0===r.length)&&(b=Error(p("Not enough arguments following: %s",t))),j(t,r),e}function j(e,t,n=i){if(/-/.test(e)&&o["camel-case-expansion"]){const t=e.split(".").map((function(e){return T(e)})).join(".");$(e,t)}const s=_(e,t,n),r=e.split(".");if(M(w,r,s),g.aliases[e]&&g.aliases[e].forEach((function(e){const t=e.split(".");M(w,t,s)})),r.length>1&&o["dot-notation"]&&(g.aliases[r[0]]||[]).forEach((function(t){let n=t.split(".");const i=[].concat(r);i.shift(),n=n.concat(i),(g.aliases[e]||[]).includes(n.join("."))||M(w,n,s)})),D(e,g.normalize)&&!D(e,g.arrays)){[e].concat(g.aliases[e]||[]).forEach((function(e){Object.defineProperty(O,e,{enumerable:!0,get:()=>t,set(e){t="string"==typeof e?U.normalize(e):e}})}))}}function $(e,t){g.aliases[e]&&g.aliases[e].length||(g.aliases[e]=[t],u[t]=!0),g.aliases[t]&&g.aliases[t].length||$(t,e)}function _(e,t,n){n&&(t=function(e){return"string"!=typeof e||"'"!==e[0]&&'"'!==e[0]||e[e.length-1]!==e[0]?e:e.substring(1,e.length-1)}(t)),(D(e,g.bools)||D(e,g.counts))&&"string"==typeof t&&(t="true"===t);let s=Array.isArray(t)?t.map((function(t){return x(e,t)})):x(e,t);return D(e,g.counts)&&(z(s)||"boolean"==typeof s)&&(s=H()),D(e,g.normalize)&&D(e,g.arrays)&&(s=Array.isArray(t)?t.map((e=>U.normalize(e))):U.normalize(t)),s}function x(e,t){if(!o["parse-positional-numbers"]&&"_"===e)return t;if(!D(e,g.strings)&&!D(e,g.bools)&&!Array.isArray(t)){(B(t)&&o["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${t}`)))||!z(t)&&D(e,g.numbers))&&(t=Number(t))}return t}function C(e,t){Object.keys(e).forEach((function(n){const s=e[n],i=t?t+"."+n:n;"object"==typeof s&&null!==s&&!Array.isArray(s)&&o["dot-notation"]?C(s,i):(!N(w,i.split("."))||D(i,g.arrays)&&o["combine-arrays"])&&j(i,s)}))}function P(e,t){if(void 0===l)return;const n="string"==typeof l?l:"",s=U.env();Object.keys(s).forEach((function(i){if(""===n||0===i.lastIndexOf(n,0)){const r=i.split("__").map((function(e,t){return 0===t&&(e=e.substring(n.length)),T(e)}));(t&&g.configs[r.join(".")]||!t)&&!N(e,r)&&j(r.join("."),s[i])}}))}function S(e,t,n,s=!1){Object.keys(n).forEach((function(i){N(e,i.split("."))||(M(e,i.split("."),n[i]),s&&(f[i]=!0),(t[i]||[]).forEach((function(t){N(e,t.split("."))||M(e,t.split("."),n[i])})))}))}function N(e,t){let n=e;o["dot-notation"]||(t=[t.join(".")]),t.slice(0,-1).forEach((function(e){n=n[e]||{}}));const s=t[t.length-1];return"object"==typeof n&&s in n}function M(e,t,n){let s=e;o["dot-notation"]||(t=[t.join(".")]),t.slice(0,-1).forEach((function(e){e=Y(e),"object"==typeof s&&void 0===s[e]&&(s[e]={}),"object"!=typeof s[e]||Array.isArray(s[e])?(Array.isArray(s[e])?s[e].push({}):s[e]=[s[e],{}],s=s[e][s[e].length-1]):s=s[e]}));const i=Y(t[t.length-1]),r=D(t.join("."),g.arrays),a=Array.isArray(n);let c=o["duplicate-arguments-array"];!c&&D(i,g.nargs)&&(c=!0,(!z(s[i])&&1===g.nargs[i]||Array.isArray(s[i])&&s[i].length===g.nargs[i])&&(s[i]=void 0)),n===H()?s[i]=H(s[i]):Array.isArray(s[i])?c&&r&&a?s[i]=o["flatten-duplicate-arrays"]?s[i].concat(n):(Array.isArray(s[i][0])?s[i]:[s[i]]).concat([n]):c||Boolean(r)!==Boolean(a)?s[i]=s[i].concat([n]):s[i]=n:void 0===s[i]&&r?s[i]=a?n:[n]:!c||void 0===s[i]||D(i,g.counts)||D(i,g.bools)?s[i]=n:s[i]=[s[i],n]}function D(e,t){const n=[].concat(g.aliases[e]||[],e),s=Object.keys(t),i=n.find((e=>s.includes(e)));return!!i&&t[i]}function I(e){const t=Object.keys(g);return[].concat(t.map((e=>g[e]))).some((function(t){return Array.isArray(t)?t.includes(e):t[e]}))}function R(e){return o["unknown-options-as-args"]&&function(e){if(e=e.replace(/^-{3,}/,"--"),e.match(m))return!1;if(function(e){if(e.match(m)||!e.match(/^-[^-]+/))return!1;let t,n=!0;const s=e.slice(1).split("");for(let i=0;i<s.length;i++){if(t=e.slice(i+2),!I(s[i])){n=!1;break}if(s[i+1]&&"="===s[i+1]||"-"===t||/[A-Za-z]/.test(s[i])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(t)||s[i+1]&&s[i+1].match(/\W/))break}return n}(e))return!1;return!function(e,...t){return[].concat(...t).some((function(t){const n=e.match(t);return n&&I(n[1])}))}(e,/^-+([^=]+?)=[\s\S]*$/,y,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}(e)}function W(e){return D(e,g.bools)||D(e,g.counts)||!(`${e}`in a)?(t=function(e){let t=V.BOOLEAN;return D(e,g.strings)?t=V.STRING:D(e,g.numbers)?t=V.NUMBER:D(e,g.bools)?t=V.BOOLEAN:D(e,g.arrays)&&(t=V.ARRAY),t}(e),{[V.BOOLEAN]:!0,[V.STRING]:"",[V.NUMBER]:void 0,[V.ARRAY]:[]}[t]):a[e];var t}function z(e){return void 0===e}return P(w,!0),P(w,!1),function(e){const t=Object.create(null);S(t,g.aliases,a),Object.keys(g.configs).forEach((function(n){const s=e[n]||t[n];if(s)try{let e=null;const t=U.resolve(U.cwd(),s),i=g.configs[n];if("function"==typeof i){try{e=i(t)}catch(t){e=t}if(e instanceof Error)return void(b=e)}else e=U.require(t);C(e)}catch(t){"PermissionDenied"===t.name?b=t:e[n]&&(b=Error(p("Invalid JSON config file: %s",s)))}}))}(w),void 0!==c&&c.forEach((function(e){C(e)})),S(w,g.aliases,a,!0),function(e){let t;const n=new Set;Object.keys(e).forEach((function(s){if(!n.has(s)&&(t=D(s,g.coercions),"function"==typeof t))try{const i=x(s,t(e[s]));[].concat(g.aliases[s]||[],s).forEach((t=>{n.add(t),e[t]=i}))}catch(e){b=e}}))}(w),o["set-placeholder-key"]&&function(e){g.keys.forEach((t=>{~t.indexOf(".")||void 0===e[t]&&(e[t]=void 0)}))}(w),Object.keys(g.counts).forEach((function(e){N(w,e.split("."))||j(e,0)})),h&&v.length&&(w[d]=[]),v.forEach((function(e){w[d].push(e)})),o["camel-case-expansion"]&&o["strip-dashed"]&&Object.keys(w).filter((e=>"--"!==e&&e.includes("-"))).forEach((e=>{delete w[e]})),o["strip-aliased"]&&[].concat(...Object.keys(r).map((e=>r[e]))).forEach((e=>{o["camel-case-expansion"]&&e.includes("-")&&delete w[e.split(".").map((e=>T(e))).join(".")],delete w[e]})),{aliases:Object.assign({},g.aliases),argv:Object.assign(O,w),configuration:o,defaulted:Object.assign({},f),error:b,newAliases:Object.assign({},u)}}}({cwd:process.cwd,env:()=>X,format:p,normalize:s,resolve:t,require:e=>{if("undefined"!=typeof require)return require(e);if(e.match(/\.json$/))return JSON.parse(u(e,"utf8"));throw Error("only .json config files are supported in ESM")}}),ee=function(e,t){return Z.parse(e.slice(),t).argv};function te(){return process.versions.electron&&!process.defaultApp?0:1}ee.detailed=function(e,t){return Z.parse(e.slice(),t)},ee.camelCase=T,ee.decamelize=L,ee.looksLikeNumber=B;class ne extends Error{constructor(e){super(e||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,ne)}}var se={fs:{readFileSync:u,writeFile:f},format:p,resolve:t,exists:e=>{try{return h(e).isFile()}catch(e){return!1}}};let ie;class re{constructor(e){e=e||{},this.directory=e.directory||"./locales",this.updateFiles="boolean"!=typeof e.updateFiles||e.updateFiles,this.locale=e.locale||"en",this.fallbackToLanguage="boolean"!=typeof e.fallbackToLanguage||e.fallbackToLanguage,this.cache=Object.create(null),this.writeQueue=[]}__(...e){if("string"!=typeof arguments[0])return this._taggedLiteral(arguments[0],...arguments);const t=e.shift();let n=function(){};return"function"==typeof e[e.length-1]&&(n=e.pop()),n=n||function(){},this.cache[this.locale]||this._readLocaleFile(),!this.cache[this.locale][t]&&this.updateFiles?(this.cache[this.locale][t]=t,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:n})):n(),ie.format.apply(ie.format,[this.cache[this.locale][t]||t].concat(e))}__n(){const e=Array.prototype.slice.call(arguments),t=e.shift(),n=e.shift(),s=e.shift();let i=function(){};"function"==typeof e[e.length-1]&&(i=e.pop()),this.cache[this.locale]||this._readLocaleFile();let r=1===s?t:n;if(this.cache[this.locale][t]){r=this.cache[this.locale][t][1===s?"one":"other"]}!this.cache[this.locale][t]&&this.updateFiles?(this.cache[this.locale][t]={one:t,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:i})):i();const o=[r];return~r.indexOf("%d")&&o.push(s),ie.format.apply(ie.format,o.concat(e))}setLocale(e){this.locale=e}getLocale(){return this.locale}updateLocale(e){this.cache[this.locale]||this._readLocaleFile();for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(this.cache[this.locale][t]=e[t])}_taggedLiteral(e,...t){let n="";return e.forEach((function(e,s){const i=t[s+1];n+=e,void 0!==i&&(n+="%s")})),this.__.apply(this,[n].concat([].slice.call(t,1)))}_enqueueWrite(e){this.writeQueue.push(e),1===this.writeQueue.length&&this._processWriteQueue()}_processWriteQueue(){const e=this,t=this.writeQueue[0],n=t.directory,s=t.locale,i=t.cb,r=this._resolveLocaleFile(n,s),o=JSON.stringify(this.cache[s],null,2);ie.fs.writeFile(r,o,"utf-8",(function(t){e.writeQueue.shift(),e.writeQueue.length>0&&e._processWriteQueue(),i(t)}))}_readLocaleFile(){let e={};const t=this._resolveLocaleFile(this.directory,this.locale);try{ie.fs.readFileSync&&(e=JSON.parse(ie.fs.readFileSync(t,"utf-8")))}catch(n){if(n instanceof SyntaxError&&(n.message="syntax error in "+t),"ENOENT"!==n.code)throw n;e={}}this.cache[this.locale]=e}_resolveLocaleFile(e,t){let n=ie.resolve(e,"./",t+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~t.lastIndexOf("_")){const s=ie.resolve(e,"./",t.split("_")[0]+".json");this._fileExistsSync(s)&&(n=s)}return n}_fileExistsSync(e){return ie.exists(e)}}const oe="loading a directory of commands is not supported yet for ESM";let ae;try{ae=m(import.meta.url)}catch(e){ae=process.cwd()}var ce,le={assert:{notStrictEqual:a,strictEqual:c},cliui:function(e){return function(e,t){return R=t,new D({width:(null==e?void 0:e.width)||("object"==typeof process&&process.stdout&&process.stdout.columns?process.stdout.columns:80),wrap:null==e?void 0:e.wrap})}(e,{stringWidth:e=>[...e].length,stripAnsi:z,wrap:F})},findUp:function(e,s){let i,r=t(".",e);for(h(r).isDirectory()||(r=n(r));;){if(i=s(r,d(r)),i)return t(r,i);if(r=n(i=r),i===r)break}},getEnv:e=>process.env[e],inspect:g,getCallerFile:()=>{throw new ne(oe)},getProcessArgvBin:function(){return process.argv[te()]},mainFilename:ae.substring(0,ae.lastIndexOf("node_modules"))||process.cwd(),Parser:ee,path:{basename:i,dirname:n,extname:r,relative:o,resolve:t},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(e,t)=>process.emitWarning(e,t),execPath:()=>process.execPath,exit:process.exit,nextTick:process.nextTick,stdColumns:void 0!==process.stdout.columns?process.stdout.columns:null},readFileSync:u,require:()=>{throw new ne("require is not supported by ESM")},requireDirectory:()=>{throw new ne(oe)},stringWidth:e=>[...e].length,y18n:(ce={directory:t(ae,"../../../locales"),updateFiles:!1},function(e,t){ie=t;const n=new re(e);return{__:n.__.bind(n),__n:n.__n.bind(n),setLocale:n.setLocale.bind(n),getLocale:n.getLocale.bind(n),updateLocale:n.updateLocale.bind(n),locale:n.locale}}(ce,se))};function he(e,t,n,s){n.assert.notStrictEqual(e,t,s)}function de(e,t){t.assert.strictEqual(typeof e,"string")}function ue(e){return Object.keys(e)}function fe(e){return!!e&&!!e.then&&"function"==typeof e.then}function pe(e){const t=e.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),n=/\.*[\][<>]/g,s=t.shift();if(!s)throw new Error(`No command found in: ${e}`);const i={cmd:s.replace(n,""),demanded:[],optional:[]};return t.forEach(((e,s)=>{let r=!1;e=e.replace(/\s/g,""),/\.+[\]>]/.test(e)&&s===t.length-1&&(r=!0),/^\[/.test(e)?i.optional.push({cmd:e.replace(n,"").split("|"),variadic:r}):i.demanded.push({cmd:e.replace(n,"").split("|"),variadic:r})})),i}const ge=["first","second","third","fourth","fifth","sixth"];function me(e,t,n){try{let s=0;const[i,r,o]="object"==typeof e?[{demanded:[],optional:[]},e,t]:[pe(`cmd ${e}`),t,n],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 ne(`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 ne(`Too many arguments provided. Expected max ${l} but received ${c}.`);i.demanded.forEach((e=>{const t=ye(a.shift());0===e.cmd.filter((e=>e===t||"*"===e)).length&&be(t,e.cmd,s),s+=1})),i.optional.forEach((e=>{if(0===a.length)return;const t=ye(a.shift());0===e.cmd.filter((e=>e===t||"*"===e)).length&&be(t,e.cmd,s),s+=1}))}catch(e){console.warn(e.stack)}}function ye(e){return Array.isArray(e)?"array":null===e?"null":typeof e}function be(e,t,n){throw new ne(`Invalid ${ge[n]||"manyith"} argument. Expected ${t.join(" or ")} but received ${e}.`)}class ve{constructor(e){this.globalMiddleware=[],this.frozens=[],this.yargs=e}addMiddleware(e,t,n=!0,s=!1){if(me("<array|function> [boolean] [boolean] [boolean]",[e,t,n],arguments.length),Array.isArray(e)){for(let s=0;s<e.length;s++){if("function"!=typeof e[s])throw Error("middleware must be a function");const i=e[s];i.applyBeforeValidation=t,i.global=n}Array.prototype.push.apply(this.globalMiddleware,e)}else if("function"==typeof e){const i=e;i.applyBeforeValidation=t,i.global=n,i.mutates=s,this.globalMiddleware.push(e)}return this.yargs}addCoerceMiddleware(e,t){const n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((e=>{const s=[...n[t]||[],t];return!e.option||!s.includes(e.option)})),e.option=t,this.addMiddleware(e,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){const e=this.frozens.pop();void 0!==e&&(this.globalMiddleware=e)}reset(){this.globalMiddleware=this.globalMiddleware.filter((e=>e.global))}}function we(e,t,n,s){return n.reduce(((e,n)=>{if(n.applyBeforeValidation!==s)return e;if(n.mutates){if(n.applied)return e;n.applied=!0}if(fe(e))return e.then((e=>Promise.all([e,n(e,t)]))).then((([e,t])=>Object.assign(e,t)));{const s=n(e,t);return fe(s)?s.then((t=>Object.assign(e,t))):Object.assign(e,s)}}),e)}function Oe(e,t,n=(e=>{throw e})){try{const n="function"==typeof e?e():e;return fe(n)?n.then((e=>t(e))):t(n)}catch(e){return n(e)}}const Ee=/(^\*)|(^\$0)/;class ke{constructor(e,t,n,s){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=s,this.usage=e,this.globalMiddleware=n,this.validation=t}addDirectory(e,t,n,s){"boolean"!=typeof(s=s||{}).recurse&&(s.recurse=!1),Array.isArray(s.extensions)||(s.extensions=["js"]);const i="function"==typeof s.visit?s.visit:e=>e;s.visit=(e,t,n)=>{const s=i(e,t,n);if(s){if(this.requireCache.has(t))return s;this.requireCache.add(t),this.addHandler(s)}return s},this.shim.requireDirectory({require:t,filename:n},e,s)}addHandler(e,t,n,s,i,r){let o=[];const a=function(e){return e?e.map((e=>(e.applyBeforeValidation=!1,e))):[]}(i);if(s=s||(()=>{}),Array.isArray(e))if(function(e){return e.every((e=>"string"==typeof e))}(e))[e,...o]=e;else for(const t of e)this.addHandler(t);else{if(function(e){return"object"==typeof e&&!Array.isArray(e)}(e)){let t=Array.isArray(e.command)||"string"==typeof e.command?e.command:this.moduleName(e);return e.aliases&&(t=[].concat(t).concat(e.aliases)),void this.addHandler(t,this.extractDesc(e),e.builder,e.handler,e.middlewares,e.deprecated)}if(Ae(n))return void this.addHandler([e].concat(o),t,n.builder,n.handler,n.middlewares,n.deprecated)}if("string"==typeof e){const i=pe(e);o=o.map((e=>pe(e).cmd));let c=!1;const l=[i.cmd].concat(o).filter((e=>!Ee.test(e)||(c=!0,!1)));0===l.length&&c&&l.push("$0"),c&&(i.cmd=l[0],o=l.slice(1),e=e.replace(Ee,i.cmd)),o.forEach((e=>{this.aliasMap[e]=i.cmd})),!1!==t&&this.usage.command(e,t,c,o,r),this.handlers[i.cmd]={original:e,description:t,handler:s,builder:n||{},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(e,t,n,s,i,r){const o=this.handlers[e]||this.handlers[this.aliasMap[e]]||this.defaultCommand,a=t.getInternalMethods().getContext(),c=a.commands.slice(),l=!e;e&&(a.commands.push(e),a.fullCommands.push(o.original));const h=this.applyBuilderUpdateUsageAndParse(l,o,t,n.aliases,c,s,i,r);return fe(h)?h.then((e=>this.applyMiddlewareAndGetResult(l,o,e.innerArgv,a,i,e.aliases,t))):this.applyMiddlewareAndGetResult(l,o,h.innerArgv,a,i,h.aliases,t)}applyBuilderUpdateUsageAndParse(e,t,n,s,i,r,o,a){const c=t.builder;let l=n;if(je(c)){n.getInternalMethods().getUsageInstance().freeze();const h=c(n.getInternalMethods().reset(s),a);if(fe(h))return h.then((s=>{var a;return l=(a=s)&&"function"==typeof a.getInternalMethods?s:n,this.parseAndUpdateUsage(e,t,l,i,r,o)}))}else(function(e){return"object"==typeof e})(c)&&(n.getInternalMethods().getUsageInstance().freeze(),l=n.getInternalMethods().reset(s),Object.keys(t.builder).forEach((e=>{l.option(e,c[e])})));return this.parseAndUpdateUsage(e,t,l,i,r,o)}parseAndUpdateUsage(e,t,n,s,i,r){e&&n.getInternalMethods().getUsageInstance().unfreeze(!0),this.shouldUpdateUsage(n)&&n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(s,t),t.description);const o=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,i,r);return fe(o)?o.then((e=>({aliases:n.parsed.aliases,innerArgv:e}))):{aliases:n.parsed.aliases,innerArgv:o}}shouldUpdateUsage(e){return!e.getInternalMethods().getUsageInstance().getUsageDisabled()&&0===e.getInternalMethods().getUsageInstance().getUsage().length}usageFromParentCommandsCommandHandler(e,t){const n=Ee.test(t.original)?t.original.replace(Ee,"").trim():t.original,s=e.filter((e=>!Ee.test(e)));return s.push(n),`$0 ${s.join(" ")}`}handleValidationAndGetResult(e,t,n,s,i,r,o,a){if(!r.getInternalMethods().getHasOutput()){const t=r.getInternalMethods().runValidation(i,a,r.parsed.error,e);n=Oe(n,(e=>(t(e),e)))}if(t.handler&&!r.getInternalMethods().getHasOutput()){r.getInternalMethods().setHasOutput();const s=!!r.getOptions().configuration["populate--"];r.getInternalMethods().postProcess(n,s,!1,!1),n=Oe(n=we(n,r,o,!1),(e=>{const n=t.handler(e);return fe(n)?n.then((()=>e)):e})),e||r.getInternalMethods().getUsageInstance().cacheHelpMessage(),fe(n)&&!r.getInternalMethods().hasParseCallback()&&n.catch((e=>{try{r.getInternalMethods().getUsageInstance().fail(null,e)}catch(e){}}))}return e||(s.commands.pop(),s.fullCommands.pop()),n}applyMiddlewareAndGetResult(e,t,n,s,i,r,o){let a={};if(i)return n;o.getInternalMethods().getHasOutput()||(a=this.populatePositionals(t,n,s,o));const c=this.globalMiddleware.getMiddleware().slice(0).concat(t.middlewares),l=we(n,o,c,!0);return fe(l)?l.then((n=>this.handleValidationAndGetResult(e,t,n,s,r,o,c,a))):this.handleValidationAndGetResult(e,t,l,s,r,o,c,a)}populatePositionals(e,t,n,s){t._=t._.slice(n.commands.length);const i=e.demanded.slice(0),r=e.optional.slice(0),o={};for(this.validation.positionalCount(i.length,t._.length);i.length;){const e=i.shift();this.populatePositional(e,t,o)}for(;r.length;){const e=r.shift();this.populatePositional(e,t,o)}return t._=n.commands.concat(t._.map((e=>""+e))),this.postProcessPositionals(t,o,this.cmdToParseOptions(e.original),s),o}populatePositional(e,t,n){const s=e.cmd[0];e.variadic?n[s]=t._.splice(0).map(String):t._.length&&(n[s]=[String(t._.shift())])}cmdToParseOptions(e){const t={array:[],default:{},alias:{},demand:{}},n=pe(e);return n.demanded.forEach((e=>{const[n,...s]=e.cmd;e.variadic&&(t.array.push(n),t.default[n]=[]),t.alias[n]=s,t.demand[n]=!0})),n.optional.forEach((e=>{const[n,...s]=e.cmd;e.variadic&&(t.array.push(n),t.default[n]=[]),t.alias[n]=s})),t}postProcessPositionals(e,t,n,s){const i=Object.assign({},s.getOptions());i.default=Object.assign(n.default,i.default);for(const e of Object.keys(n.alias))i.alias[e]=(i.alias[e]||[]).concat(n.alias[e]);i.array=i.array.concat(n.array),i.config={};const r=[];if(Object.keys(t).forEach((e=>{t[e].map((t=>{i.configuration["unknown-options-as-args"]&&(i.key[e]=!0),r.push(`--${e}`),r.push(t)}))})),!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)s.getInternalMethods().getUsageInstance().fail(a.error.message,a.error);else{const n=Object.keys(t);Object.keys(t).forEach((e=>{n.push(...a.aliases[e])})),Object.keys(a.argv).forEach((i=>{n.includes(i)&&(t[i]||(t[i]=a.argv[i]),!this.isInConfigs(s,i)&&!this.isDefaulted(s,i)&&Object.prototype.hasOwnProperty.call(e,i)&&Object.prototype.hasOwnProperty.call(a.argv,i)&&(Array.isArray(e[i])||Array.isArray(a.argv[i]))?e[i]=[].concat(e[i],a.argv[i]):e[i]=a.argv[i])}))}}isDefaulted(e,t){const{default:n}=e.getOptions();return Object.prototype.hasOwnProperty.call(n,t)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(t))}isInConfigs(e,t){const{configObjects:n}=e.getOptions();return n.some((e=>Object.prototype.hasOwnProperty.call(e,t)))||n.some((e=>Object.prototype.hasOwnProperty.call(e,this.shim.Parser.camelCase(t))))}runDefaultBuilderOn(e){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(e)){const t=Ee.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");e.getInternalMethods().getUsageInstance().usage(t,this.defaultCommand.description)}const t=this.defaultCommand.builder;if(je(t))return t(e,!0);Ae(t)||Object.keys(t).forEach((n=>{e.option(n,t[n])}))}moduleName(e){const t=function(e){if("undefined"==typeof require)return null;for(let t,n=0,s=Object.keys(require.cache);n<s.length;n++)if(t=require.cache[s[n]],t.exports===e)return t;return null}(e);if(!t)throw new Error(`No command name given for module: ${this.shim.inspect(e)}`);return this.commandFromFilename(t.filename)}commandFromFilename(e){return this.shim.path.basename(e,this.shim.path.extname(e))}extractDesc({describe:e,description:t,desc:n}){for(const s of[e,t,n]){if("string"==typeof s||!1===s)return s;he(s,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){const e=this.frozens.pop();he(e,void 0,this.shim),({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=e)}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function Ae(e){return"object"==typeof e&&!!e.builder&&"function"==typeof e.handler}function je(e){return"function"==typeof e}function $e(e={},t=(()=>!0)){const n={};return ue(e).forEach((s=>{t(s,e[s])&&(n[s]=e[s])})),n}function _e(e){"undefined"!=typeof process&&[process.stdout,process.stderr].forEach((t=>{const n=t;n._handle&&n.isTTY&&"function"==typeof n._handle.setBlocking&&n._handle.setBlocking(e)}))}function xe(e){return"boolean"==typeof e}function Ce(e,t){const n=t.y18n.__,s={},i=[];s.failFn=function(e){i.push(e)};let r=null,o=null,a=!0;s.showHelpOnFail=function(t=!0,n){const[i,c]="string"==typeof t?[!0,t]:[t,n];return e.getInternalMethods().isGlobalContext()&&(o=c),r=c,a=i,s};let c=!1;s.fail=function(t,n){const l=e.getInternalMethods().getLoggerInstance();if(!i.length){if(e.getExitProcess()&&_e(!0),!c){c=!0,a&&(e.showHelp("error"),l.error()),(t||n)&&l.error(t||n);const s=r||o;s&&((t||n)&&l.error(""),l.error(s))}if(n=n||new ne(t),e.getExitProcess())return e.exit(1);if(e.getInternalMethods().hasParseCallback())return e.exit(1,n);throw n}for(let e=i.length-1;e>=0;--e){const r=i[e];if(xe(r)){if(n)throw n;if(t)throw Error(t)}else r(t,n,s)}};let l=[],h=!1;s.usage=(e,t)=>null===e?(h=!0,l=[],s):(h=!1,l.push([e,t||""]),s),s.getUsage=()=>l,s.getUsageDisabled=()=>h,s.getPositionalGroupName=()=>n("Positionals:");let d=[];s.example=(e,t)=>{d.push([e,t||""])};let u=[];s.command=function(e,t,n,s,i=!1){n&&(u=u.map((e=>(e[2]=!1,e)))),u.push([e,t||"",n,s,i])},s.getCommands=()=>u;let f={};s.describe=function(e,t){Array.isArray(e)?e.forEach((e=>{s.describe(e,t)})):"object"==typeof e?Object.keys(e).forEach((t=>{s.describe(t,e[t])})):f[e]=t},s.getDescriptions=()=>f;let p=[];s.epilog=e=>{p.push(e)};let g,m=!1;s.wrap=e=>{m=!0,g=e},s.getWrap=()=>t.getEnv("YARGS_DISABLE_WRAP")?null:(m||(g=function(){const e=80;return t.process.stdColumns?Math.min(e,t.process.stdColumns):e}(),m=!0),g);const y="__yargsString__:";function b(e,n,s){let i=0;return Array.isArray(e)||(e=Object.values(e).map((e=>[e]))),e.forEach((e=>{i=Math.max(t.stringWidth(s?`${s} ${Ne(e[0])}`:Ne(e[0]))+Se(e[0]),i)})),n&&(i=Math.min(i,parseInt((.5*n).toString(),10))),i}let v;function w(t){return e.getOptions().hiddenOptions.indexOf(t)<0||e.parsed.argv[e.getOptions().showHiddenOpt]}function O(e,t){let s=`[${n("default:")} `;if(void 0===e&&!t)return null;if(t)s+=t;else switch(typeof e){case"string":s+=`"${e}"`;break;case"object":s+=JSON.stringify(e);break;default:s+=e}return`${s}]`}s.deferY18nLookup=e=>y+e,s.help=function(){if(v)return v;!function(){const t=e.getDemandedOptions(),n=e.getOptions();(Object.keys(n.alias)||[]).forEach((i=>{n.alias[i].forEach((r=>{f[r]&&s.describe(i,f[r]),r in t&&e.demandOption(i,t[r]),n.boolean.includes(r)&&e.boolean(i),n.count.includes(r)&&e.count(i),n.string.includes(r)&&e.string(i),n.normalize.includes(r)&&e.normalize(i),n.array.includes(r)&&e.array(i),n.number.includes(r)&&e.number(i)}))}))}();const i=e.customScriptName?e.$0:t.path.basename(e.$0),r=e.getDemandedOptions(),o=e.getDemandedCommands(),a=e.getDeprecatedOptions(),c=e.getGroups(),g=e.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(w),m=Object.keys(m.reduce(((e,t)=>("_"!==t&&(e[t]=!0),e)),{}));const E=s.getWrap(),k=t.cliui({width:E,wrap:!!E});if(!h)if(l.length)l.forEach((e=>{k.div({text:`${e[0].replace(/\$0/g,i)}`}),e[1]&&k.div({text:`${e[1]}`,padding:[1,0,0,0]})})),k.div();else if(u.length){let e=null;e=o._?`${i} <${n("command")}>\n`:`${i} [${n("command")}]\n`,k.div(`${e}`)}if(u.length>1||1===u.length&&!u[0][2]){k.div(n("Commands:"));const t=e.getInternalMethods().getContext(),s=t.commands.length?`${t.commands.join(" ")} `:"";!0===e.getInternalMethods().getParserConfiguration()["sort-commands"]&&(u=u.sort(((e,t)=>e[0].localeCompare(t[0]))));const r=i?`${i} `:"";u.forEach((e=>{const t=`${r}${s}${e[0].replace(/^\$0 ?/,"")}`;k.span({text:t,padding:[0,2,0,2],width:b(u,E,`${i}${s}`)+4},{text:e[1]});const o=[];e[2]&&o.push(`[${n("default")}]`),e[3]&&e[3].length&&o.push(`[${n("aliases:")} ${e[3].join(", ")}]`),e[4]&&("string"==typeof e[4]?o.push(`[${n("deprecated: %s",e[4])}]`):o.push(`[${n("deprecated")}]`)),o.length?k.div({text:o.join(" "),padding:[0,0,0,2],align:"right"}):k.div()})),k.div()}const A=(Object.keys(g.alias)||[]).concat(Object.keys(e.parsed.newAliases)||[]);m=m.filter((t=>!e.parsed.newAliases[t]&&A.every((e=>-1===(g.alias[e]||[]).indexOf(t)))));const j=n("Options:");c[j]||(c[j]=[]),function(e,t,n,s){let i=[],r=null;Object.keys(n).forEach((e=>{i=i.concat(n[e])})),e.forEach((e=>{r=[e].concat(t[e]),r.some((e=>-1!==i.indexOf(e)))||n[s].push(e)}))}(m,g.alias,c,j);const $=e=>/^--/.test(Ne(e)),_=Object.keys(c).filter((e=>c[e].length>0)).map((e=>({groupName:e,normalizedKeys:c[e].filter(w).map((e=>{if(A.includes(e))return e;for(let t,n=0;void 0!==(t=A[n]);n++)if((g.alias[t]||[]).includes(e))return t;return e}))}))).filter((({normalizedKeys:e})=>e.length>0)).map((({groupName:e,normalizedKeys:t})=>{const n=t.reduce(((t,n)=>(t[n]=[n].concat(g.alias[n]||[]).map((t=>e===s.getPositionalGroupName()?t:(/^[0-9]$/.test(t)?g.boolean.includes(n)?"-":"--":t.length>1?"--":"-")+t)).sort(((e,t)=>$(e)===$(t)?0:$(e)?1:-1)).join(", "),t)),{});return{groupName:e,normalizedKeys:t,switches:n}}));if(_.filter((({groupName:e})=>e!==s.getPositionalGroupName())).some((({normalizedKeys:e,switches:t})=>!e.every((e=>$(t[e])))))&&_.filter((({groupName:e})=>e!==s.getPositionalGroupName())).forEach((({normalizedKeys:e,switches:t})=>{e.forEach((e=>{var n,s;$(t[e])&&(t[e]=(n=t[e],s=4,Pe(n)?{text:n.text,indentation:n.indentation+s}:{text:n,indentation:s}))}))})),_.forEach((({groupName:t,normalizedKeys:i,switches:o})=>{k.div(t),i.forEach((t=>{const i=o[t];let c=f[t]||"",l=null;c.includes(y)&&(c=n(c.substring(16))),g.boolean.includes(t)&&(l=`[${n("boolean")}]`),g.count.includes(t)&&(l=`[${n("count")}]`),g.string.includes(t)&&(l=`[${n("string")}]`),g.normalize.includes(t)&&(l=`[${n("string")}]`),g.array.includes(t)&&(l=`[${n("array")}]`),g.number.includes(t)&&(l=`[${n("number")}]`);const h=[t in a?(d=a[t],"string"==typeof d?`[${n("deprecated: %s",d)}]`:`[${n("deprecated")}]`):null,l,t in r?`[${n("required")}]`:null,g.choices&&g.choices[t]?`[${n("choices:")} ${s.stringifiedValues(g.choices[t])}]`:null,O(g.default[t],g.defaultDescription[t])].filter(Boolean).join(" ");var d;k.span({text:Ne(i),padding:[0,2,0,2+Se(i)],width:b(o,E)+4},c);const u=!0===e.getInternalMethods().getUsageConfiguration()["hide-types"];h&&!u?k.div({text:h,padding:[0,0,0,2],align:"right"}):k.div()})),k.div()})),d.length&&(k.div(n("Examples:")),d.forEach((e=>{e[0]=e[0].replace(/\$0/g,i)})),d.forEach((e=>{""===e[1]?k.div({text:e[0],padding:[0,2,0,2]}):k.div({text:e[0],padding:[0,2,0,2],width:b(d,E)+4},{text:e[1]})})),k.div()),p.length>0){const e=p.map((e=>e.replace(/\$0/g,i))).join("\n");k.div(`${e}\n`)}return k.toString().replace(/\s*$/,"")},s.cacheHelpMessage=function(){v=this.help()},s.clearCachedHelpMessage=function(){v=void 0},s.hasCachedHelpMessage=function(){return!!v},s.showHelp=t=>{const n=e.getInternalMethods().getLoggerInstance();t||(t="error");("function"==typeof t?t:n[t])(s.help())},s.functionDescription=e=>["(",e.name?t.Parser.decamelize(e.name,"-"):n("generated-value"),")"].join(""),s.stringifiedValues=function(e,t){let n="";const s=t||", ",i=[].concat(e);return e&&i.length?(i.forEach((e=>{n.length&&(n+=s),n+=JSON.stringify(e)})),n):n};let E=null;s.version=e=>{E=e},s.showVersion=t=>{const n=e.getInternalMethods().getLoggerInstance();t||(t="error");("function"==typeof t?t:n[t])(E)},s.reset=function(e){return r=null,c=!1,l=[],h=!1,p=[],d=[],u=[],f=$e(f,(t=>!e[t])),s};const k=[];return s.freeze=function(){k.push({failMessage:r,failureOutput:c,usages:l,usageDisabled:h,epilogs:p,examples:d,commands:u,descriptions:f})},s.unfreeze=function(e=!1){const t=k.pop();t&&(e?(f={...t.descriptions,...f},u=[...t.commands,...u],l=[...t.usages,...l],d=[...t.examples,...d],p=[...t.epilogs,...p]):({failMessage:r,failureOutput:c,usages:l,usageDisabled:h,epilogs:p,examples:d,commands:u,descriptions:f}=t))},s}function Pe(e){return"object"==typeof e}function Se(e){return Pe(e)?e.indentation:0}function Ne(e){return Pe(e)?e.text:e}class Me{constructor(e,t,n,s){var i,r,o;this.yargs=e,this.usage=t,this.command=n,this.shim=s,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(e,t,n,s){const i=this.command.getCommandHandlers();for(let t=0,n=e.length;t<n;++t)if(i[e[t]]&&i[e[t]].builder){const n=i[e[t]].builder;if(je(n)){this.indexAfterLastReset=t+1;const e=this.yargs.getInternalMethods().reset();return n(e,!0),e.argv}}const r=[];this.commandCompletions(r,e,n),this.optionCompletions(r,e,t,n),this.choicesFromOptionsCompletions(r,e,t,n),this.choicesFromPositionalsCompletions(r,e,t,n),s(null,r)}commandCompletions(e,t,n){const s=this.yargs.getInternalMethods().getContext().commands;n.match(/^-/)||s[s.length-1]===n||this.previousArgHasChoices(t)||this.usage.getCommands().forEach((n=>{const s=pe(n[0]).cmd;if(-1===t.indexOf(s))if(this.zshShell){const t=n[1]||"";e.push(s.replace(/:/g,"\\:")+":"+t)}else e.push(s)}))}optionCompletions(e,t,n,s){if((s.match(/^-/)||""===s&&0===e.length)&&!this.previousArgHasChoices(t)){const n=this.yargs.getOptions(),i=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(n.key).forEach((r=>{const o=!!n.configuration["boolean-negation"]&&n.boolean.includes(r);i.includes(r)||n.hiddenOptions.includes(r)||this.argsContainKey(t,r,o)||this.completeOptionKey(r,e,s,o&&!!n.default[r])}))}}choicesFromOptionsCompletions(e,t,n,s){if(this.previousArgHasChoices(t)){const n=this.getPreviousArgChoices(t);n&&n.length>0&&e.push(...n.map((e=>e.replace(/:/g,"\\:"))))}}choicesFromPositionalsCompletions(e,t,n,s){if(""===s&&e.length>0&&this.previousArgHasChoices(t))return;const i=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],r=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),o=i[n._.length-r-1];if(!o)return;const a=this.yargs.getOptions().choices[o]||[];for(const t of a)t.startsWith(s)&&e.push(t.replace(/:/g,"\\:"))}getPreviousArgChoices(e){if(e.length<1)return;let t=e[e.length-1],n="";if(!t.startsWith("-")&&e.length>1&&(n=t,t=e[e.length-2]),!t.startsWith("-"))return;const s=t.replace(/^-+/,""),i=this.yargs.getOptions(),r=[s,...this.yargs.getAliases()[s]||[]];let o;for(const e of r)if(Object.prototype.hasOwnProperty.call(i.key,e)&&Array.isArray(i.choices[e])){o=i.choices[e];break}return o?o.filter((e=>!n||e.startsWith(n))):void 0}previousArgHasChoices(e){const t=this.getPreviousArgChoices(e);return void 0!==t&&t.length>0}argsContainKey(e,t,n){const s=t=>-1!==e.indexOf((/^[^0-9]$/.test(t)?"-":"--")+t);if(s(t))return!0;if(n&&s(`no-${t}`))return!0;if(this.aliases)for(const e of this.aliases[t])if(s(e))return!0;return!1}completeOptionKey(e,t,n,s){var i,r,o,a;let c=e;if(this.zshShell){const t=this.usage.getDescriptions(),n=null===(r=null===(i=null==this?void 0:this.aliases)||void 0===i?void 0:i[e])||void 0===r?void 0:r.find((e=>{const n=t[e];return"string"==typeof n&&n.length>0})),s=n?t[n]:void 0,l=null!==(a=null!==(o=t[e])&&void 0!==o?o:s)&&void 0!==a?a:"";c=`${e.replace(/:/g,"\\:")}:${l.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}const l=!/^--/.test(n)&&(e=>/^[^0-9]$/.test(e))(e)?"-":"--";t.push(l+c),s&&t.push(l+"no-"+c)}customCompletion(e,t,n,s){if(he(this.customCompletionFunction,null,this.shim),this.customCompletionFunction.length<3){const e=this.customCompletionFunction(n,t);return fe(e)?e.then((e=>{this.shim.process.nextTick((()=>{s(null,e)}))})).catch((e=>{this.shim.process.nextTick((()=>{s(e,void 0)}))})):s(null,e)}return function(e){return e.length>3}(this.customCompletionFunction)?this.customCompletionFunction(n,t,((i=s)=>this.defaultCompletion(e,t,n,i)),(e=>{s(null,e)})):this.customCompletionFunction(n,t,(e=>{s(null,e)}))}getCompletion(e,t){const n=e.length?e[e.length-1]:"",s=this.yargs.parse(e,!0),i=this.customCompletionFunction?s=>this.customCompletion(e,s,n,t):s=>this.defaultCompletion(e,s,n,t);return fe(s)?s.then(i):i(s)}generateCompletionScript(e,t){let n=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 s=this.shim.path.basename(e);return e.match(/\.js$/)&&(e=`./${e}`),n=n.replace(/{{app_name}}/g,s),n=n.replace(/{{completion_command}}/g,t),n.replace(/{{app_path}}/g,e)}registerFunction(e){this.customCompletionFunction=e}setParsed(e){this.aliases=e.aliases}}function De(e,t){if(0===e.length)return t.length;if(0===t.length)return e.length;const n=[];let s,i;for(s=0;s<=t.length;s++)n[s]=[s];for(i=0;i<=e.length;i++)n[0][i]=i;for(s=1;s<=t.length;s++)for(i=1;i<=e.length;i++)t.charAt(s-1)===e.charAt(i-1)?n[s][i]=n[s-1][i-1]:s>1&&i>1&&t.charAt(s-2)===e.charAt(i-1)&&t.charAt(s-1)===e.charAt(i-2)?n[s][i]=n[s-2][i-2]+1:n[s][i]=Math.min(n[s-1][i-1]+1,Math.min(n[s][i-1]+1,n[s-1][i]+1));return n[t.length][e.length]}const Ie=["$0","--","_"];let Re,We=[];function ze(e,t,n,s){Re=s;let i={};if(Object.prototype.hasOwnProperty.call(e,"extends")){if("string"!=typeof e.extends)return i;const s=/\.json|\..*rc$/.test(e.extends);let r=null;if(s)r=function(e,t){return Re.path.resolve(e,t)}(t,e.extends);else try{r=require.resolve(e.extends)}catch(t){return e}!function(e){if(We.indexOf(e)>-1)throw new ne(`Circular extended configurations: '${e}'.`)}(r),We.push(r),i=s?JSON.parse(Re.readFileSync(r,"utf8")):require(e.extends),delete e.extends,i=ze(i,Re.path.dirname(r),n,Re)}return We=[],n?Fe(i,e):Object.assign({},i,e)}function Fe(e,t){const n={};function s(e){return e&&"object"==typeof e&&!Array.isArray(e)}Object.assign(n,e);for(const i of Object.keys(t))s(t[i])&&s(n[i])?n[i]=Fe(e[i],t[i]):n[i]=t[i];return n}var Te,Le,Be,Ve,Ue,He,Ye,qe,Je,Ge,Ke,Qe,Xe,Ze,et,tt,nt,st,it,rt,ot,at,ct,lt,ht,dt,ut,ft,pt,gt,mt,yt,bt,vt,wt,Ot=function(e,t,n,s,i){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?i.call(e,n):i?i.value=n:t.set(e,n),n},Et=function(e,t,n,s){if("a"===n&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(e):s?s.value:t.get(e)};const kt=Symbol("copyDoubleDash"),At=Symbol("copyDoubleDash"),jt=Symbol("deleteFromParserHintObject"),$t=Symbol("emitWarning"),_t=Symbol("freeze"),xt=Symbol("getDollarZero"),Ct=Symbol("getParserConfiguration"),Pt=Symbol("getUsageConfiguration"),St=Symbol("guessLocale"),Nt=Symbol("guessVersion"),Mt=Symbol("parsePositionalNumbers"),Dt=Symbol("pkgUp"),It=Symbol("populateParserHintArray"),Rt=Symbol("populateParserHintSingleValueDictionary"),Wt=Symbol("populateParserHintArrayDictionary"),zt=Symbol("populateParserHintDictionary"),Ft=Symbol("sanitizeKey"),Tt=Symbol("setKey"),Lt=Symbol("unfreeze"),Bt=Symbol("validateAsync"),Vt=Symbol("getCommandInstance"),Ut=Symbol("getContext"),Ht=Symbol("getHasOutput"),Yt=Symbol("getLoggerInstance"),qt=Symbol("getParseContext"),Jt=Symbol("getUsageInstance"),Gt=Symbol("getValidationInstance"),Kt=Symbol("hasParseCallback"),Qt=Symbol("isGlobalContext"),Xt=Symbol("postProcess"),Zt=Symbol("rebase"),en=Symbol("reset"),tn=Symbol("runYargsParserAndExecuteCommands"),nn=Symbol("runValidation"),sn=Symbol("setHasOutput"),rn=Symbol("kTrackManuallySetKeys");class on{constructor(e=[],t,n,s){this.customScriptName=!1,this.parsed=!1,Te.set(this,void 0),Le.set(this,void 0),Be.set(this,{commands:[],fullCommands:[]}),Ve.set(this,null),Ue.set(this,null),He.set(this,"show-hidden"),Ye.set(this,null),qe.set(this,!0),Je.set(this,{}),Ge.set(this,!0),Ke.set(this,[]),Qe.set(this,void 0),Xe.set(this,{}),Ze.set(this,!1),et.set(this,null),tt.set(this,!0),nt.set(this,void 0),st.set(this,""),it.set(this,void 0),rt.set(this,void 0),ot.set(this,{}),at.set(this,null),ct.set(this,null),lt.set(this,{}),ht.set(this,{}),dt.set(this,void 0),ut.set(this,!1),ft.set(this,void 0),pt.set(this,!1),gt.set(this,!1),mt.set(this,!1),yt.set(this,void 0),bt.set(this,{}),vt.set(this,null),wt.set(this,void 0),Ot(this,ft,s,"f"),Ot(this,dt,e,"f"),Ot(this,Le,t,"f"),Ot(this,rt,n,"f"),Ot(this,Qe,new ve(this),"f"),this.$0=this[xt](),this[en](),Ot(this,Te,Et(this,Te,"f"),"f"),Ot(this,yt,Et(this,yt,"f"),"f"),Ot(this,wt,Et(this,wt,"f"),"f"),Ot(this,it,Et(this,it,"f"),"f"),Et(this,it,"f").showHiddenOpt=Et(this,He,"f"),Ot(this,nt,this[At](),"f")}addHelpOpt(e,t){return me("[string|boolean] [string]",[e,t],arguments.length),Et(this,et,"f")&&(this[jt](Et(this,et,"f")),Ot(this,et,null,"f")),!1===e&&void 0===t||(Ot(this,et,"string"==typeof e?e:"help","f"),this.boolean(Et(this,et,"f")),this.describe(Et(this,et,"f"),t||Et(this,yt,"f").deferY18nLookup("Show help"))),this}help(e,t){return this.addHelpOpt(e,t)}addShowHiddenOpt(e,t){if(me("[string|boolean] [string]",[e,t],arguments.length),!1===e&&void 0===t)return this;const n="string"==typeof e?e:Et(this,He,"f");return this.boolean(n),this.describe(n,t||Et(this,yt,"f").deferY18nLookup("Show hidden options")),Et(this,it,"f").showHiddenOpt=n,this}showHidden(e,t){return this.addShowHiddenOpt(e,t)}alias(e,t){return me("<object|string|array> [string|array]",[e,t],arguments.length),this[Wt](this.alias.bind(this),"alias",e,t),this}array(e){return me("<array|string>",[e],arguments.length),this[It]("array",e),this[rn](e),this}boolean(e){return me("<array|string>",[e],arguments.length),this[It]("boolean",e),this[rn](e),this}check(e,t){return me("<function> [boolean]",[e,t],arguments.length),this.middleware(((t,n)=>Oe((()=>e(t,n.getOptions())),(n=>(n?("string"==typeof n||n instanceof Error)&&Et(this,yt,"f").fail(n.toString(),n):Et(this,yt,"f").fail(Et(this,ft,"f").y18n.__("Argument check failed: %s",e.toString())),t)),(e=>(Et(this,yt,"f").fail(e.message?e.message:e.toString(),e),t)))),!1,t),this}choices(e,t){return me("<object|string|array> [string|array]",[e,t],arguments.length),this[Wt](this.choices.bind(this),"choices",e,t),this}coerce(e,t){if(me("<object|string|array> [function]",[e,t],arguments.length),Array.isArray(e)){if(!t)throw new ne("coerce callback must be provided");for(const n of e)this.coerce(n,t);return this}if("object"==typeof e){for(const t of Object.keys(e))this.coerce(t,e[t]);return this}if(!t)throw new ne("coerce callback must be provided");return Et(this,it,"f").key[e]=!0,Et(this,Qe,"f").addCoerceMiddleware(((n,s)=>{let i;return Object.prototype.hasOwnProperty.call(n,e)?Oe((()=>(i=s.getAliases(),t(n[e]))),(t=>{n[e]=t;const r=s.getInternalMethods().getParserConfiguration()["strip-aliased"];if(i[e]&&!0!==r)for(const s of i[e])n[s]=t;return n}),(e=>{throw new ne(e.message)})):n}),e),this}conflicts(e,t){return me("<string|object> [string|array]",[e,t],arguments.length),Et(this,wt,"f").conflicts(e,t),this}config(e="config",t,n){return me("[object|string] [string|function] [function]",[e,t,n],arguments.length),"object"!=typeof e||Array.isArray(e)?("function"==typeof t&&(n=t,t=void 0),this.describe(e,t||Et(this,yt,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(e)?e:[e]).forEach((e=>{Et(this,it,"f").config[e]=n||!0})),this):(e=ze(e,Et(this,Le,"f"),this[Ct]()["deep-merge-config"]||!1,Et(this,ft,"f")),Et(this,it,"f").configObjects=(Et(this,it,"f").configObjects||[]).concat(e),this)}completion(e,t,n){return me("[string] [string|boolean|function] [function]",[e,t,n],arguments.length),"function"==typeof t&&(n=t,t=void 0),Ot(this,Ue,e||Et(this,Ue,"f")||"completion","f"),t||!1===t||(t="generate completion script"),this.command(Et(this,Ue,"f"),t),n&&Et(this,Ve,"f").registerFunction(n),this}command(e,t,n,s,i,r){return me("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[e,t,n,s,i,r],arguments.length),Et(this,Te,"f").addHandler(e,t,n,s,i,r),this}commands(e,t,n,s,i,r){return this.command(e,t,n,s,i,r)}commandDir(e,t){me("<string> [object]",[e,t],arguments.length);const n=Et(this,rt,"f")||Et(this,ft,"f").require;return Et(this,Te,"f").addDirectory(e,n,Et(this,ft,"f").getCallerFile(),t),this}count(e){return me("<array|string>",[e],arguments.length),this[It]("count",e),this[rn](e),this}default(e,t,n){return me("<object|string|array> [*] [string]",[e,t,n],arguments.length),n&&(de(e,Et(this,ft,"f")),Et(this,it,"f").defaultDescription[e]=n),"function"==typeof t&&(de(e,Et(this,ft,"f")),Et(this,it,"f").defaultDescription[e]||(Et(this,it,"f").defaultDescription[e]=Et(this,yt,"f").functionDescription(t)),t=t.call()),this[Rt](this.default.bind(this),"default",e,t),this}defaults(e,t,n){return this.default(e,t,n)}demandCommand(e=1,t,n,s){return me("[number] [number|string] [string|null|undefined] [string|null|undefined]",[e,t,n,s],arguments.length),"number"!=typeof t&&(n=t,t=1/0),this.global("_",!1),Et(this,it,"f").demandedCommands._={min:e,max:t,minMsg:n,maxMsg:s},this}demand(e,t,n){return Array.isArray(t)?(t.forEach((e=>{he(n,!0,Et(this,ft,"f")),this.demandOption(e,n)})),t=1/0):"number"!=typeof t&&(n=t,t=1/0),"number"==typeof e?(he(n,!0,Et(this,ft,"f")),this.demandCommand(e,t,n,n)):Array.isArray(e)?e.forEach((e=>{he(n,!0,Et(this,ft,"f")),this.demandOption(e,n)})):"string"==typeof n?this.demandOption(e,n):!0!==n&&void 0!==n||this.demandOption(e),this}demandOption(e,t){return me("<object|string|array> [string]",[e,t],arguments.length),this[Rt](this.demandOption.bind(this),"demandedOptions",e,t),this}deprecateOption(e,t){return me("<string> [string|boolean]",[e,t],arguments.length),Et(this,it,"f").deprecatedOptions[e]=t,this}describe(e,t){return me("<object|string|array> [string]",[e,t],arguments.length),this[Tt](e,!0),Et(this,yt,"f").describe(e,t),this}detectLocale(e){return me("<boolean>",[e],arguments.length),Ot(this,qe,e,"f"),this}env(e){return me("[string|boolean]",[e],arguments.length),!1===e?delete Et(this,it,"f").envPrefix:Et(this,it,"f").envPrefix=e||"",this}epilogue(e){return me("<string>",[e],arguments.length),Et(this,yt,"f").epilog(e),this}epilog(e){return this.epilogue(e)}example(e,t){return me("<string|array> [string]",[e,t],arguments.length),Array.isArray(e)?e.forEach((e=>this.example(...e))):Et(this,yt,"f").example(e,t),this}exit(e,t){Ot(this,Ze,!0,"f"),Ot(this,Ye,t,"f"),Et(this,Ge,"f")&&Et(this,ft,"f").process.exit(e)}exitProcess(e=!0){return me("[boolean]",[e],arguments.length),Ot(this,Ge,e,"f"),this}fail(e){if(me("<function|boolean>",[e],arguments.length),"boolean"==typeof e&&!1!==e)throw new ne("Invalid first argument. Expected function or boolean 'false'");return Et(this,yt,"f").failFn(e),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(e,t){return me("<array> [function]",[e,t],arguments.length),t?Et(this,Ve,"f").getCompletion(e,t):new Promise(((t,n)=>{Et(this,Ve,"f").getCompletion(e,((e,s)=>{e?n(e):t(s)}))}))}getDemandedOptions(){return me([],0),Et(this,it,"f").demandedOptions}getDemandedCommands(){return me([],0),Et(this,it,"f").demandedCommands}getDeprecatedOptions(){return me([],0),Et(this,it,"f").deprecatedOptions}getDetectLocale(){return Et(this,qe,"f")}getExitProcess(){return Et(this,Ge,"f")}getGroups(){return Object.assign({},Et(this,Xe,"f"),Et(this,ht,"f"))}getHelp(){if(Ot(this,Ze,!0,"f"),!Et(this,yt,"f").hasCachedHelpMessage()){if(!this.parsed){const e=this[tn](Et(this,dt,"f"),void 0,void 0,0,!0);if(fe(e))return e.then((()=>Et(this,yt,"f").help()))}const e=Et(this,Te,"f").runDefaultBuilderOn(this);if(fe(e))return e.then((()=>Et(this,yt,"f").help()))}return Promise.resolve(Et(this,yt,"f").help())}getOptions(){return Et(this,it,"f")}getStrict(){return Et(this,pt,"f")}getStrictCommands(){return Et(this,gt,"f")}getStrictOptions(){return Et(this,mt,"f")}global(e,t){return me("<string|array> [boolean]",[e,t],arguments.length),e=[].concat(e),!1!==t?Et(this,it,"f").local=Et(this,it,"f").local.filter((t=>-1===e.indexOf(t))):e.forEach((e=>{Et(this,it,"f").local.includes(e)||Et(this,it,"f").local.push(e)})),this}group(e,t){me("<string|array> <string>",[e,t],arguments.length);const n=Et(this,ht,"f")[t]||Et(this,Xe,"f")[t];Et(this,ht,"f")[t]&&delete Et(this,ht,"f")[t];const s={};return Et(this,Xe,"f")[t]=(n||[]).concat(e).filter((e=>!s[e]&&(s[e]=!0))),this}hide(e){return me("<string>",[e],arguments.length),Et(this,it,"f").hiddenOptions.push(e),this}implies(e,t){return me("<string|object> [number|string|array]",[e,t],arguments.length),Et(this,wt,"f").implies(e,t),this}locale(e){return me("[string]",[e],arguments.length),void 0===e?(this[St](),Et(this,ft,"f").y18n.getLocale()):(Ot(this,qe,!1,"f"),Et(this,ft,"f").y18n.setLocale(e),this)}middleware(e,t,n){return Et(this,Qe,"f").addMiddleware(e,!!t,n)}nargs(e,t){return me("<string|object|array> [number]",[e,t],arguments.length),this[Rt](this.nargs.bind(this),"narg",e,t),this}normalize(e){return me("<array|string>",[e],arguments.length),this[It]("normalize",e),this}number(e){return me("<array|string>",[e],arguments.length),this[It]("number",e),this[rn](e),this}option(e,t){if(me("<string|object> [object]",[e,t],arguments.length),"object"==typeof e)Object.keys(e).forEach((t=>{this.options(t,e[t])}));else{"object"!=typeof t&&(t={}),this[rn](e),!Et(this,vt,"f")||"version"!==e&&"version"!==(null==t?void 0:t.alias)||this[$t](['"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"),Et(this,it,"f").key[e]=!0,t.alias&&this.alias(e,t.alias);const n=t.deprecate||t.deprecated;n&&this.deprecateOption(e,n);const s=t.demand||t.required||t.require;s&&this.demand(e,s),t.demandOption&&this.demandOption(e,"string"==typeof t.demandOption?t.demandOption:void 0),t.conflicts&&this.conflicts(e,t.conflicts),"default"in t&&this.default(e,t.default),void 0!==t.implies&&this.implies(e,t.implies),void 0!==t.nargs&&this.nargs(e,t.nargs),t.config&&this.config(e,t.configParser),t.normalize&&this.normalize(e),t.choices&&this.choices(e,t.choices),t.coerce&&this.coerce(e,t.coerce),t.group&&this.group(e,t.group),(t.boolean||"boolean"===t.type)&&(this.boolean(e),t.alias&&this.boolean(t.alias)),(t.array||"array"===t.type)&&(this.array(e),t.alias&&this.array(t.alias)),(t.number||"number"===t.type)&&(this.number(e),t.alias&&this.number(t.alias)),(t.string||"string"===t.type)&&(this.string(e),t.alias&&this.string(t.alias)),(t.count||"count"===t.type)&&this.count(e),"boolean"==typeof t.global&&this.global(e,t.global),t.defaultDescription&&(Et(this,it,"f").defaultDescription[e]=t.defaultDescription),t.skipValidation&&this.skipValidation(e);const i=t.describe||t.description||t.desc,r=Et(this,yt,"f").getDescriptions();Object.prototype.hasOwnProperty.call(r,e)&&"string"!=typeof i||this.describe(e,i),t.hidden&&this.hide(e),t.requiresArg&&this.requiresArg(e)}return this}options(e,t){return this.option(e,t)}parse(e,t,n){me("[string|array] [function|boolean|object] [function]",[e,t,n],arguments.length),this[_t](),void 0===e&&(e=Et(this,dt,"f")),"object"==typeof t&&(Ot(this,ct,t,"f"),t=n),"function"==typeof t&&(Ot(this,at,t,"f"),t=!1),t||Ot(this,dt,e,"f"),Et(this,at,"f")&&Ot(this,Ge,!1,"f");const s=this[tn](e,!!t),i=this.parsed;return Et(this,Ve,"f").setParsed(this.parsed),fe(s)?s.then((e=>(Et(this,at,"f")&&Et(this,at,"f").call(this,Et(this,Ye,"f"),e,Et(this,st,"f")),e))).catch((e=>{throw Et(this,at,"f")&&Et(this,at,"f")(e,this.parsed.argv,Et(this,st,"f")),e})).finally((()=>{this[Lt](),this.parsed=i})):(Et(this,at,"f")&&Et(this,at,"f").call(this,Et(this,Ye,"f"),s,Et(this,st,"f")),this[Lt](),this.parsed=i,s)}parseAsync(e,t,n){const s=this.parse(e,t,n);return fe(s)?s:Promise.resolve(s)}parseSync(e,t,n){const s=this.parse(e,t,n);if(fe(s))throw new ne(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return s}parserConfiguration(e){return me("<object>",[e],arguments.length),Ot(this,ot,e,"f"),this}pkgConf(e,t){me("<string> [string]",[e,t],arguments.length);let n=null;const s=this[Dt](t||Et(this,Le,"f"));return s[e]&&"object"==typeof s[e]&&(n=ze(s[e],t||Et(this,Le,"f"),this[Ct]()["deep-merge-config"]||!1,Et(this,ft,"f")),Et(this,it,"f").configObjects=(Et(this,it,"f").configObjects||[]).concat(n)),this}positional(e,t){me("<string> <object>",[e,t],arguments.length);const n=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];t=$e(t,((e,t)=>!("type"===e&&!["string","number","boolean"].includes(t))&&n.includes(e)));const s=Et(this,Be,"f").fullCommands[Et(this,Be,"f").fullCommands.length-1],i=s?Et(this,Te,"f").cmdToParseOptions(s):{array:[],alias:{},default:{},demand:{}};return ue(i).forEach((n=>{const s=i[n];Array.isArray(s)?-1!==s.indexOf(e)&&(t[n]=!0):s[e]&&!(n in t)&&(t[n]=s[e])})),this.group(e,Et(this,yt,"f").getPositionalGroupName()),this.option(e,t)}recommendCommands(e=!0){return me("[boolean]",[e],arguments.length),Ot(this,ut,e,"f"),this}required(e,t,n){return this.demand(e,t,n)}require(e,t,n){return this.demand(e,t,n)}requiresArg(e){return me("<array|string|object> [number]",[e],arguments.length),"string"==typeof e&&Et(this,it,"f").narg[e]||this[Rt](this.requiresArg.bind(this),"narg",e,NaN),this}showCompletionScript(e,t){return me("[string] [string]",[e,t],arguments.length),e=e||this.$0,Et(this,nt,"f").log(Et(this,Ve,"f").generateCompletionScript(e,t||Et(this,Ue,"f")||"completion")),this}showHelp(e){if(me("[string|function]",[e],arguments.length),Ot(this,Ze,!0,"f"),!Et(this,yt,"f").hasCachedHelpMessage()){if(!this.parsed){const t=this[tn](Et(this,dt,"f"),void 0,void 0,0,!0);if(fe(t))return t.then((()=>{Et(this,yt,"f").showHelp(e)})),this}const t=Et(this,Te,"f").runDefaultBuilderOn(this);if(fe(t))return t.then((()=>{Et(this,yt,"f").showHelp(e)})),this}return Et(this,yt,"f").showHelp(e),this}scriptName(e){return this.customScriptName=!0,this.$0=e,this}showHelpOnFail(e,t){return me("[boolean|string] [string]",[e,t],arguments.length),Et(this,yt,"f").showHelpOnFail(e,t),this}showVersion(e){return me("[string|function]",[e],arguments.length),Et(this,yt,"f").showVersion(e),this}skipValidation(e){return me("<array|string>",[e],arguments.length),this[It]("skipValidation",e),this}strict(e){return me("[boolean]",[e],arguments.length),Ot(this,pt,!1!==e,"f"),this}strictCommands(e){return me("[boolean]",[e],arguments.length),Ot(this,gt,!1!==e,"f"),this}strictOptions(e){return me("[boolean]",[e],arguments.length),Ot(this,mt,!1!==e,"f"),this}string(e){return me("<array|string>",[e],arguments.length),this[It]("string",e),this[rn](e),this}terminalWidth(){return me([],0),Et(this,ft,"f").process.stdColumns}updateLocale(e){return this.updateStrings(e)}updateStrings(e){return me("<object>",[e],arguments.length),Ot(this,qe,!1,"f"),Et(this,ft,"f").y18n.updateLocale(e),this}usage(e,t,n,s){if(me("<string|null|undefined> [string|boolean] [function|object] [function]",[e,t,n,s],arguments.length),void 0!==t){if(he(e,null,Et(this,ft,"f")),(e||"").match(/^\$0( |$)/))return this.command(e,t,n,s);throw new ne(".usage() description must start with $0 if being used as alias for .command()")}return Et(this,yt,"f").usage(e),this}usageConfiguration(e){return me("<object>",[e],arguments.length),Ot(this,bt,e,"f"),this}version(e,t,n){const s="version";if(me("[boolean|string] [string] [string]",[e,t,n],arguments.length),Et(this,vt,"f")&&(this[jt](Et(this,vt,"f")),Et(this,yt,"f").version(void 0),Ot(this,vt,null,"f")),0===arguments.length)n=this[Nt](),e=s;else if(1===arguments.length){if(!1===e)return this;n=e,e=s}else 2===arguments.length&&(n=t,t=void 0);return Ot(this,vt,"string"==typeof e?e:s,"f"),t=t||Et(this,yt,"f").deferY18nLookup("Show version number"),Et(this,yt,"f").version(n||void 0),this.boolean(Et(this,vt,"f")),this.describe(Et(this,vt,"f"),t),this}wrap(e){return me("<number|null|undefined>",[e],arguments.length),Et(this,yt,"f").wrap(e),this}[(Te=new WeakMap,Le=new WeakMap,Be=new WeakMap,Ve=new WeakMap,Ue=new WeakMap,He=new WeakMap,Ye=new WeakMap,qe=new WeakMap,Je=new WeakMap,Ge=new WeakMap,Ke=new WeakMap,Qe=new WeakMap,Xe=new WeakMap,Ze=new WeakMap,et=new WeakMap,tt=new WeakMap,nt=new WeakMap,st=new WeakMap,it=new WeakMap,rt=new WeakMap,ot=new WeakMap,at=new WeakMap,ct=new WeakMap,lt=new WeakMap,ht=new WeakMap,dt=new WeakMap,ut=new WeakMap,ft=new WeakMap,pt=new WeakMap,gt=new WeakMap,mt=new WeakMap,yt=new WeakMap,bt=new WeakMap,vt=new WeakMap,wt=new WeakMap,kt)](e){if(!e._||!e["--"])return e;e._.push.apply(e._,e["--"]);try{delete e["--"]}catch(e){}return e}[At](){return{log:(...e)=>{this[Kt]()||console.log(...e),Ot(this,Ze,!0,"f"),Et(this,st,"f").length&&Ot(this,st,Et(this,st,"f")+"\n","f"),Ot(this,st,Et(this,st,"f")+e.join(" "),"f")},error:(...e)=>{this[Kt]()||console.error(...e),Ot(this,Ze,!0,"f"),Et(this,st,"f").length&&Ot(this,st,Et(this,st,"f")+"\n","f"),Ot(this,st,Et(this,st,"f")+e.join(" "),"f")}}}[jt](e){ue(Et(this,it,"f")).forEach((t=>{if("configObjects"===t)return;const n=Et(this,it,"f")[t];Array.isArray(n)?n.includes(e)&&n.splice(n.indexOf(e),1):"object"==typeof n&&delete n[e]})),delete Et(this,yt,"f").getDescriptions()[e]}[$t](e,t,n){Et(this,Je,"f")[n]||(Et(this,ft,"f").process.emitWarning(e,t),Et(this,Je,"f")[n]=!0)}[_t](){Et(this,Ke,"f").push({options:Et(this,it,"f"),configObjects:Et(this,it,"f").configObjects.slice(0),exitProcess:Et(this,Ge,"f"),groups:Et(this,Xe,"f"),strict:Et(this,pt,"f"),strictCommands:Et(this,gt,"f"),strictOptions:Et(this,mt,"f"),completionCommand:Et(this,Ue,"f"),output:Et(this,st,"f"),exitError:Et(this,Ye,"f"),hasOutput:Et(this,Ze,"f"),parsed:this.parsed,parseFn:Et(this,at,"f"),parseContext:Et(this,ct,"f")}),Et(this,yt,"f").freeze(),Et(this,wt,"f").freeze(),Et(this,Te,"f").freeze(),Et(this,Qe,"f").freeze()}[xt](){let e,t="";return e=/\b(node|iojs|electron)(\.exe)?$/.test(Et(this,ft,"f").process.argv()[0])?Et(this,ft,"f").process.argv().slice(1,2):Et(this,ft,"f").process.argv().slice(0,1),t=e.map((e=>{const t=this[Zt](Et(this,Le,"f"),e);return e.match(/^(\/|([a-zA-Z]:)?\\)/)&&t.length<e.length?t:e})).join(" ").trim(),Et(this,ft,"f").getEnv("_")&&Et(this,ft,"f").getProcessArgvBin()===Et(this,ft,"f").getEnv("_")&&(t=Et(this,ft,"f").getEnv("_").replace(`${Et(this,ft,"f").path.dirname(Et(this,ft,"f").process.execPath())}/`,"")),t}[Ct](){return Et(this,ot,"f")}[Pt](){return Et(this,bt,"f")}[St](){if(!Et(this,qe,"f"))return;const e=Et(this,ft,"f").getEnv("LC_ALL")||Et(this,ft,"f").getEnv("LC_MESSAGES")||Et(this,ft,"f").getEnv("LANG")||Et(this,ft,"f").getEnv("LANGUAGE")||"en_US";this.locale(e.replace(/[.:].*/,""))}[Nt](){return this[Dt]().version||"unknown"}[Mt](e){const t=e["--"]?e["--"]:e._;for(let e,n=0;void 0!==(e=t[n]);n++)Et(this,ft,"f").Parser.looksLikeNumber(e)&&Number.isSafeInteger(Math.floor(parseFloat(`${e}`)))&&(t[n]=Number(e));return e}[Dt](e){const t=e||"*";if(Et(this,lt,"f")[t])return Et(this,lt,"f")[t];let n={};try{let t=e||Et(this,ft,"f").mainFilename;!e&&Et(this,ft,"f").path.extname(t)&&(t=Et(this,ft,"f").path.dirname(t));const s=Et(this,ft,"f").findUp(t,((e,t)=>t.includes("package.json")?"package.json":void 0));he(s,void 0,Et(this,ft,"f")),n=JSON.parse(Et(this,ft,"f").readFileSync(s,"utf8"))}catch(e){}return Et(this,lt,"f")[t]=n||{},Et(this,lt,"f")[t]}[It](e,t){(t=[].concat(t)).forEach((t=>{t=this[Ft](t),Et(this,it,"f")[e].push(t)}))}[Rt](e,t,n,s){this[zt](e,t,n,s,((e,t,n)=>{Et(this,it,"f")[e][t]=n}))}[Wt](e,t,n,s){this[zt](e,t,n,s,((e,t,n)=>{Et(this,it,"f")[e][t]=(Et(this,it,"f")[e][t]||[]).concat(n)}))}[zt](e,t,n,s,i){if(Array.isArray(n))n.forEach((t=>{e(t,s)}));else if((e=>"object"==typeof e)(n))for(const t of ue(n))e(t,n[t]);else i(t,this[Ft](n),s)}[Ft](e){return"__proto__"===e?"___proto___":e}[Tt](e,t){return this[Rt](this[Tt].bind(this),"key",e,t),this}[Lt](){var e,t,n,s,i,r,o,a,c,l,h,d;const u=Et(this,Ke,"f").pop();let f;he(u,void 0,Et(this,ft,"f")),e=this,t=this,n=this,s=this,i=this,r=this,o=this,a=this,c=this,l=this,h=this,d=this,({options:{set value(t){Ot(e,it,t,"f")}}.value,configObjects:f,exitProcess:{set value(e){Ot(t,Ge,e,"f")}}.value,groups:{set value(e){Ot(n,Xe,e,"f")}}.value,output:{set value(e){Ot(s,st,e,"f")}}.value,exitError:{set value(e){Ot(i,Ye,e,"f")}}.value,hasOutput:{set value(e){Ot(r,Ze,e,"f")}}.value,parsed:this.parsed,strict:{set value(e){Ot(o,pt,e,"f")}}.value,strictCommands:{set value(e){Ot(a,gt,e,"f")}}.value,strictOptions:{set value(e){Ot(c,mt,e,"f")}}.value,completionCommand:{set value(e){Ot(l,Ue,e,"f")}}.value,parseFn:{set value(e){Ot(h,at,e,"f")}}.value,parseContext:{set value(e){Ot(d,ct,e,"f")}}.value}=u),Et(this,it,"f").configObjects=f,Et(this,yt,"f").unfreeze(),Et(this,wt,"f").unfreeze(),Et(this,Te,"f").unfreeze(),Et(this,Qe,"f").unfreeze()}[Bt](e,t){return Oe(t,(t=>(e(t),t)))}getInternalMethods(){return{getCommandInstance:this[Vt].bind(this),getContext:this[Ut].bind(this),getHasOutput:this[Ht].bind(this),getLoggerInstance:this[Yt].bind(this),getParseContext:this[qt].bind(this),getParserConfiguration:this[Ct].bind(this),getUsageConfiguration:this[Pt].bind(this),getUsageInstance:this[Jt].bind(this),getValidationInstance:this[Gt].bind(this),hasParseCallback:this[Kt].bind(this),isGlobalContext:this[Qt].bind(this),postProcess:this[Xt].bind(this),reset:this[en].bind(this),runValidation:this[nn].bind(this),runYargsParserAndExecuteCommands:this[tn].bind(this),setHasOutput:this[sn].bind(this)}}[Vt](){return Et(this,Te,"f")}[Ut](){return Et(this,Be,"f")}[Ht](){return Et(this,Ze,"f")}[Yt](){return Et(this,nt,"f")}[qt](){return Et(this,ct,"f")||{}}[Jt](){return Et(this,yt,"f")}[Gt](){return Et(this,wt,"f")}[Kt](){return!!Et(this,at,"f")}[Qt](){return Et(this,tt,"f")}[Xt](e,t,n,s){if(n)return e;if(fe(e))return e;t||(e=this[kt](e));return(this[Ct]()["parse-positional-numbers"]||void 0===this[Ct]()["parse-positional-numbers"])&&(e=this[Mt](e)),s&&(e=we(e,this,Et(this,Qe,"f").getMiddleware(),!1)),e}[en](e={}){Ot(this,it,Et(this,it,"f")||{},"f");const t={};t.local=Et(this,it,"f").local||[],t.configObjects=Et(this,it,"f").configObjects||[];const n={};t.local.forEach((t=>{n[t]=!0,(e[t]||[]).forEach((e=>{n[e]=!0}))})),Object.assign(Et(this,ht,"f"),Object.keys(Et(this,Xe,"f")).reduce(((e,t)=>{const s=Et(this,Xe,"f")[t].filter((e=>!(e in n)));return s.length>0&&(e[t]=s),e}),{})),Ot(this,Xe,{},"f");return["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"].forEach((e=>{t[e]=(Et(this,it,"f")[e]||[]).filter((e=>!n[e]))})),["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"].forEach((e=>{t[e]=$e(Et(this,it,"f")[e],(e=>!n[e]))})),t.envPrefix=Et(this,it,"f").envPrefix,Ot(this,it,t,"f"),Ot(this,yt,Et(this,yt,"f")?Et(this,yt,"f").reset(n):Ce(this,Et(this,ft,"f")),"f"),Ot(this,wt,Et(this,wt,"f")?Et(this,wt,"f").reset(n):function(e,t,n){const s=n.y18n.__,i=n.y18n.__n,r={nonOptionCount:function(n){const s=e.getDemandedCommands(),r=n._.length+(n["--"]?n["--"].length:0)-e.getInternalMethods().getContext().commands.length;s._&&(r<s._.min||r>s._.max)&&(r<s._.min?void 0!==s._.minMsg?t.fail(s._.minMsg?s._.minMsg.replace(/\$0/g,r.toString()).replace(/\$1/,s._.min.toString()):null):t.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(),s._.min.toString())):r>s._.max&&(void 0!==s._.maxMsg?t.fail(s._.maxMsg?s._.maxMsg.replace(/\$0/g,r.toString()).replace(/\$1/,s._.max.toString()):null):t.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(),s._.max.toString()))))},positionalCount:function(e,n){n<e&&t.fail(i("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",n,n+"",e+""))},requiredArguments:function(e,n){let s=null;for(const t of Object.keys(n))Object.prototype.hasOwnProperty.call(e,t)&&void 0!==e[t]||(s=s||{},s[t]=n[t]);if(s){const e=[];for(const t of Object.keys(s)){const n=s[t];n&&e.indexOf(n)<0&&e.push(n)}const n=e.length?`\n${e.join("\n")}`:"";t.fail(i("Missing required argument: %s","Missing required arguments: %s",Object.keys(s).length,Object.keys(s).join(", ")+n))}},unknownArguments:function(n,s,o,a,c=!0){var l;const h=e.getInternalMethods().getCommandInstance().getCommands(),d=[],u=e.getInternalMethods().getContext();if(Object.keys(n).forEach((t=>{Ie.includes(t)||Object.prototype.hasOwnProperty.call(o,t)||Object.prototype.hasOwnProperty.call(e.getInternalMethods().getParseContext(),t)||r.isValidAndSomeAliasIsNotNew(t,s)||d.push(t)})),c&&(u.commands.length>0||h.length>0||a)&&n._.slice(u.commands.length).forEach((e=>{h.includes(""+e)||d.push(""+e)})),c){const t=(null===(l=e.getDemandedCommands()._)||void 0===l?void 0:l.max)||0,s=u.commands.length+t;s<n._.length&&n._.slice(s).forEach((e=>{e=String(e),u.commands.includes(e)||d.includes(e)||d.push(e)}))}d.length&&t.fail(i("Unknown argument: %s","Unknown arguments: %s",d.length,d.map((e=>e.trim()?e:`"${e}"`)).join(", ")))},unknownCommands:function(n){const s=e.getInternalMethods().getCommandInstance().getCommands(),r=[],o=e.getInternalMethods().getContext();return(o.commands.length>0||s.length>0)&&n._.slice(o.commands.length).forEach((e=>{s.includes(""+e)||r.push(""+e)})),r.length>0&&(t.fail(i("Unknown command: %s","Unknown commands: %s",r.length,r.join(", "))),!0)},isValidAndSomeAliasIsNotNew:function(t,n){if(!Object.prototype.hasOwnProperty.call(n,t))return!1;const s=e.parsed.newAliases;return[t,...n[t]].some((e=>!Object.prototype.hasOwnProperty.call(s,e)||!s[t]))},limitedChoices:function(n){const i=e.getOptions(),r={};if(!Object.keys(i.choices).length)return;Object.keys(n).forEach((e=>{-1===Ie.indexOf(e)&&Object.prototype.hasOwnProperty.call(i.choices,e)&&[].concat(n[e]).forEach((t=>{-1===i.choices[e].indexOf(t)&&void 0!==t&&(r[e]=(r[e]||[]).concat(t))}))}));const o=Object.keys(r);if(!o.length)return;let a=s("Invalid values:");o.forEach((e=>{a+=`\n ${s("Argument: %s, Given: %s, Choices: %s",e,t.stringifiedValues(r[e]),t.stringifiedValues(i.choices[e]))}`})),t.fail(a)}};let o={};function a(e,t){const n=Number(t);return"number"==typeof(t=isNaN(n)?t:n)?t=e._.length>=t:t.match(/^--no-.+/)?(t=t.match(/^--no-(.+)/)[1],t=!Object.prototype.hasOwnProperty.call(e,t)):t=Object.prototype.hasOwnProperty.call(e,t),t}r.implies=function(t,s){me("<string|object> [array|number|string]",[t,s],arguments.length),"object"==typeof t?Object.keys(t).forEach((e=>{r.implies(e,t[e])})):(e.global(t),o[t]||(o[t]=[]),Array.isArray(s)?s.forEach((e=>r.implies(t,e))):(he(s,void 0,n),o[t].push(s)))},r.getImplied=function(){return o},r.implications=function(e){const n=[];if(Object.keys(o).forEach((t=>{const s=t;(o[t]||[]).forEach((t=>{let i=s;const r=t;i=a(e,i),t=a(e,t),i&&!t&&n.push(` ${s} -> ${r}`)}))})),n.length){let e=`${s("Implications failed:")}\n`;n.forEach((t=>{e+=t})),t.fail(e)}};let c={};r.conflicts=function(t,n){me("<string|object> [array|string]",[t,n],arguments.length),"object"==typeof t?Object.keys(t).forEach((e=>{r.conflicts(e,t[e])})):(e.global(t),c[t]||(c[t]=[]),Array.isArray(n)?n.forEach((e=>r.conflicts(t,e))):c[t].push(n))},r.getConflicting=()=>c,r.conflicting=function(i){Object.keys(i).forEach((e=>{c[e]&&c[e].forEach((n=>{n&&void 0!==i[e]&&void 0!==i[n]&&t.fail(s("Arguments %s and %s are mutually exclusive",e,n))}))})),e.getInternalMethods().getParserConfiguration()["strip-dashed"]&&Object.keys(c).forEach((e=>{c[e].forEach((r=>{r&&void 0!==i[n.Parser.camelCase(e)]&&void 0!==i[n.Parser.camelCase(r)]&&t.fail(s("Arguments %s and %s are mutually exclusive",e,r))}))}))},r.recommendCommands=function(e,n){n=n.sort(((e,t)=>t.length-e.length));let i=null,r=1/0;for(let t,s=0;void 0!==(t=n[s]);s++){const n=De(e,t);n<=3&&n<r&&(r=n,i=t)}i&&t.fail(s("Did you mean %s?",i))},r.reset=function(e){return o=$e(o,(t=>!e[t])),c=$e(c,(t=>!e[t])),r};const l=[];return r.freeze=function(){l.push({implied:o,conflicting:c})},r.unfreeze=function(){const e=l.pop();he(e,void 0,n),({implied:o,conflicting:c}=e)},r}(this,Et(this,yt,"f"),Et(this,ft,"f")),"f"),Ot(this,Te,Et(this,Te,"f")?Et(this,Te,"f").reset():function(e,t,n,s){return new ke(e,t,n,s)}(Et(this,yt,"f"),Et(this,wt,"f"),Et(this,Qe,"f"),Et(this,ft,"f")),"f"),Et(this,Ve,"f")||Ot(this,Ve,function(e,t,n,s){return new Me(e,t,n,s)}(this,Et(this,yt,"f"),Et(this,Te,"f"),Et(this,ft,"f")),"f"),Et(this,Qe,"f").reset(),Ot(this,Ue,null,"f"),Ot(this,st,"","f"),Ot(this,Ye,null,"f"),Ot(this,Ze,!1,"f"),this.parsed=!1,this}[Zt](e,t){return Et(this,ft,"f").path.relative(e,t)}[tn](e,t,n,s=0,i=!1){let r=!!n||i;e=e||Et(this,dt,"f"),Et(this,it,"f").__=Et(this,ft,"f").y18n.__,Et(this,it,"f").configuration=this[Ct]();const o=!!Et(this,it,"f").configuration["populate--"],a=Object.assign({},Et(this,it,"f").configuration,{"populate--":!0}),c=Et(this,ft,"f").Parser.detailed(e,Object.assign({},Et(this,it,"f"),{configuration:{"parse-positional-numbers":!1,...a}})),l=Object.assign(c.argv,Et(this,ct,"f"));let h;const d=c.aliases;let u=!1,f=!1;Object.keys(l).forEach((e=>{e===Et(this,et,"f")&&l[e]?u=!0:e===Et(this,vt,"f")&&l[e]&&(f=!0)})),l.$0=this.$0,this.parsed=c,0===s&&Et(this,yt,"f").clearCachedHelpMessage();try{if(this[St](),t)return this[Xt](l,o,!!n,!1);if(Et(this,et,"f")){[Et(this,et,"f")].concat(d[Et(this,et,"f")]||[]).filter((e=>e.length>1)).includes(""+l._[l._.length-1])&&(l._.pop(),u=!0)}Ot(this,tt,!1,"f");const a=Et(this,Te,"f").getCommands(),p=Et(this,Ve,"f").completionKey in l,g=u||p||i;if(l._.length){if(a.length){let e;for(let t,r=s||0;void 0!==l._[r];r++){if(t=String(l._[r]),a.includes(t)&&t!==Et(this,Ue,"f")){const e=Et(this,Te,"f").runCommand(t,this,c,r+1,i,u||f||i);return this[Xt](e,o,!!n,!1)}if(!e&&t!==Et(this,Ue,"f")){e=t;break}}!Et(this,Te,"f").hasDefaultCommand()&&Et(this,ut,"f")&&e&&!g&&Et(this,wt,"f").recommendCommands(e,a)}Et(this,Ue,"f")&&l._.includes(Et(this,Ue,"f"))&&!p&&(Et(this,Ge,"f")&&_e(!0),this.showCompletionScript(),this.exit(0))}if(Et(this,Te,"f").hasDefaultCommand()&&!g){const e=Et(this,Te,"f").runCommand(null,this,c,0,i,u||f||i);return this[Xt](e,o,!!n,!1)}if(p){Et(this,Ge,"f")&&_e(!0);const t=(e=[].concat(e)).slice(e.indexOf(`--${Et(this,Ve,"f").completionKey}`)+1);return Et(this,Ve,"f").getCompletion(t,((e,t)=>{if(e)throw new ne(e.message);(t||[]).forEach((e=>{Et(this,nt,"f").log(e)})),this.exit(0)})),this[Xt](l,!o,!!n,!1)}if(Et(this,Ze,"f")||(u?(Et(this,Ge,"f")&&_e(!0),r=!0,this.showHelp("log"),this.exit(0)):f&&(Et(this,Ge,"f")&&_e(!0),r=!0,Et(this,yt,"f").showVersion("log"),this.exit(0))),!r&&Et(this,it,"f").skipValidation.length>0&&(r=Object.keys(l).some((e=>Et(this,it,"f").skipValidation.indexOf(e)>=0&&!0===l[e]))),!r){if(c.error)throw new ne(c.error.message);if(!p){const e=this[nn](d,{},c.error);n||(h=we(l,this,Et(this,Qe,"f").getMiddleware(),!0)),h=this[Bt](e,null!=h?h:l),fe(h)&&!n&&(h=h.then((()=>we(l,this,Et(this,Qe,"f").getMiddleware(),!1))))}}}catch(e){if(!(e instanceof ne))throw e;Et(this,yt,"f").fail(e.message,e)}return this[Xt](null!=h?h:l,o,!!n,!0)}[nn](e,t,n,s){const i={...this.getDemandedOptions()};return r=>{if(n)throw new ne(n.message);Et(this,wt,"f").nonOptionCount(r),Et(this,wt,"f").requiredArguments(r,i);let o=!1;Et(this,gt,"f")&&(o=Et(this,wt,"f").unknownCommands(r)),Et(this,pt,"f")&&!o?Et(this,wt,"f").unknownArguments(r,e,t,!!s):Et(this,mt,"f")&&Et(this,wt,"f").unknownArguments(r,e,{},!1,!1),Et(this,wt,"f").limitedChoices(r),Et(this,wt,"f").implications(r),Et(this,wt,"f").conflicting(r)}}[sn](){Ot(this,Ze,!0,"f")}[rn](e){if("string"==typeof e)Et(this,it,"f").key[e]=!0;else for(const t of e)Et(this,it,"f").key[t]=!0}}const an=(cn=le,(e=[],t=cn.process.cwd(),n)=>{const s=new on(e,t,n,cn);return Object.defineProperty(s,"argv",{get:()=>s.parse(),enumerable:!0}),s.help(),s.version(),s});var cn,ln;function hn(e){if(Object(e)!==e)throw TypeError("right-hand side of 'in' should be an object, got "+(null!==e?typeof e:"null"));return e}function dn(e,t,n){"symbol"==typeof t&&(t=(t=t.description)?"["+t+"]":"");try{Object.defineProperty(e,"name",{configurable:!0,value:n?n+" "+t:t})}catch(e){}return e}function un(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}const fn=function(e,t,n=Number.POSITIVE_INFINITY){return function(s,i){if("getter"===i?.kind){const t=new Map;return function(){const i=Date.now();if(t.has(this)){const[e,s]=t.get(this);if(i-s<=n)return e}const r=s.call(this);if(t.size>=e){const e=t.keys().next().value;t.delete(e)}return t.set(this,[r,i]),r}}{const r=new Map;return function(...o){const a=JSON.stringify(o);let c=r.get(this);const l=Date.now();if(c){if(c.has(a)){const[e,t]=c.get(a);if(l-t<=n)return e}}else{if(c=new Map,r.size>=e){const e=r.keys().next().value;r.delete(e)}r.set(this,c)}const h=i?s.call(this,...o):s(...o);if(c.size>=t){const e=c.keys().next().value;c.delete(e)}return c.set(a,[h,l]),h}}}}(Number.MAX_SAFE_INTEGER,1);class pn{static{[ln]=function(e,t,n,s,i,r){var o,a,c,l,h,d,u,f=Symbol.metadata||Symbol.for("Symbol.metadata"),p=Object.defineProperty,g=Object.create,m=[g(null),g(null)],y=t.length;function b(t,n,s){return function(i,r){n&&(r=i,i=e);for(var o=0;o<t.length;o++)r=t[o].apply(i,s?[r]:[]);return s?r:i}}function v(e,t,n,s){if("function"!=typeof e&&(s||void 0!==e))throw new TypeError(t+" must "+(n||"be")+" a function"+(s?"":" or undefined"));return e}function w(e,t,n,s,i,r,c,l,h,d,u){function f(e){if(!u(e))throw new TypeError("Attempted to access private element on non-instance")}var g=[].concat(t[0]),y=t[3],w=!c,O=1===i,E=3===i,k=4===i,A=2===i;function j(t,n,s){return function(i,r){return n&&(r=i,i=e),s&&s(i),$[t].call(i,r)}}if(!w){var $={},_=[],x=E?"get":k||O?"set":"value";if(h?(d||O?$={get:dn((function(){return y(this)}),s,"get"),set:function(e){t[4](this,e)}}:$[x]=y,d||dn($[x],s,A?"":x)):d||($=Object.getOwnPropertyDescriptor(e,s)),!d&&!h){if((a=m[+l][s])&&7!=(a^i))throw new Error("Decorating two elements with the same name ("+$[x].name+") is not supported yet");m[+l][s]=i<3?1:i}}for(var C=e,P=g.length-1;P>=0;P-=n?2:1){var S=g[P],N=n?g[P-1]:void 0,M={},D={kind:["field","accessor","method","getter","setter","class"][i],name:s,metadata:o,addInitializer:function(e,t){if(e.v)throw new Error("attempted to call addInitializer after decoration was finished");v(t,"An initializer","be",!0),r.push(t)}.bind(null,M)};if(w)a=S.call(N,C,D),M.v=1,v(a,"class decorators","return")&&(C=a);else if(D.static=l,D.private=h,a=D.access={has:h?u.bind():function(e){return s in e}},k||(a.get=h?A?function(e){return f(e),$.value}:j("get",0,f):function(e){return e[s]}),A||E||(a.set=h?j("set",0,f):function(e,t){e[s]=t}),C=S.call(N,O?{get:$.get,set:$.set}:$[x],D),M.v=1,O){if("object"==typeof C&&C)(a=v(C.get,"accessor.get"))&&($.get=a),(a=v(C.set,"accessor.set"))&&($.set=a),(a=v(C.init,"accessor.init"))&&_.unshift(a);else if(void 0!==C)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else v(C,(d?"field":"method")+" decorators","return")&&(d?_.unshift(C):$[x]=C)}return i<2&&c.push(b(_,l,1),b(r,l,0)),d||w||(h?O?c.splice(-1,0,j("get",l),j("set",l)):c.push(A?$[x]:v.call.bind($[x])):p(e,s,$)),C}function O(e){return p(e,f,{configurable:!0,enumerable:!0,value:o})}return void 0!==r&&(o=r[f]),o=g(null==o?null:o),h=[],d=function(e){e&&h.push(b(e))},u=function(t,s){for(var r=0;r<n.length;r++){var o=n[r],a=o[1],d=7&a;if((8&a)==t&&!d==s){var u=o[2],f=!!o[3],p=16&a;w(t?e:e.prototype,o,p,f?"#"+u:un(u),d,d<2?[]:t?l=l||[]:c=c||[],h,!!t,f,s,t&&f?function(t){return hn(t)===e}:i)}}},u(8,0),u(0,0),u(8,1),u(0,1),d(c),d(l),a=h,y||O(e),{e:a,get c(){var n=[];return y&&[O(e=w(e,[t],s,e.name,5,n)),b(n,1)]}}}(this,[],[[fn,3,"buildCommand"],[fn,3,"rootDirPath"],[fn,3,"dockerfile"],[fn,3,"hasDockerfile"],[fn,3,"name"],[fn,3,"dockerImageName"],[fn,3,"env"],[fn,3,"packageJson"],[fn,3,"hasPrisma"],[fn,3,"dockerPackageJson"],[fn,3,"binExists"]]).e}argv=void ln(this);pathByName=new Map;constructor(t,n,s){this._dirPath=e.resolve(t),this.argv=n,this.loadEnv=s}get buildCommand(){return this.packageJson.scripts?.build?.includes("buildIfNeeded")?"yarn build":"YARN wb buildIfNeeded "+(this.argv.verbose?"--verbose":"")}get dirPath(){return this._dirPath}get rootDirPath(){return l.existsSync(e.join(this.dirPath,"..","..","package.json"))?e.resolve(this.dirPath,"..",".."):this.dirPath}get dockerfile(){return l.readFileSync(this.findFile("Dockerfile"),"utf8")}get hasDockerfile(){try{return!!this.findFile("Dockerfile")}catch{return!1}}get name(){return this.packageJson.name||"unknown"}get dockerImageName(){return(this.packageJson.name||"unknown").replaceAll("@","").replaceAll("/","-")}get env(){return this.loadEnv?{...x(this.argv,this.dirPath),...process.env}:process.env}get packageJson(){return JSON.parse(l.readFileSync(e.join(this.dirPath,"package.json"),"utf8"))}get hasPrisma(){return!(!this.packageJson.dependencies?.prisma&&!this.packageJson.devDependencies?.prisma)}get dockerPackageJson(){return e.dirname(this.findFile("Dockerfile"))===this.dirPath?this.packageJson:JSON.parse(l.readFileSync(e.join(e.dirname(this.findFile("Dockerfile")),"package.json"),"utf8"))}get binExists(){let t=!1,n=this.dirPath;for(;;){const s=e.join(n,"node_modules",".bin");if(l.existsSync(s)&&(this.env.PATH=`${s}:${this.env.PATH}`,t=!0),l.existsSync(e.join(n,".git")))break;const i=e.dirname(n);if(n===i)break;n=i}return t}findFile(t){let n=this.pathByName.get(t);if(n)return n;if(n=[t,e.join("..","..",t)].map((t=>e.resolve(this.dirPath,t))).find((e=>l.existsSync(e))),!n)throw new Error(`File not found: ${t}`);return this.pathByName.set(t,n),n}}function gn(t,n=!0,s){if(s??=process.cwd(),l.existsSync(e.join(s,"package.json")))return new pn(s,t,n)}async function mn(t,n=!0,s){const i=function(t,n=!0,s){if(s??=process.cwd(),!l.existsSync(e.join(s,"package.json")))return;const i=new pn(s,t,n);let r=i;if(!i.packageJson.workspaces&&e.dirname(s).endsWith("/packages")){const i=e.resolve(s,"..","..");l.existsSync(e.join(i,"package.json"))&&(r=new pn(i,t,n))}return{root:r,self:i}}(t,n,s);if(i)return{...i,all:i.root===i.self?await yn(t,i.root,n):[i.self]}}async function yn(t,n,s){const i=[n],r=e.join(n.dirPath,"packages");if(!l.existsSync(r))return i;const o=await l.promises.readdir(r,{withFileTypes:!0});for(const n of o){if(!n.isDirectory())continue;const o=e.join(r,n.name);l.existsSync(e.join(o,"package.json"))&&i.push(new pn(o,t,s))}return i}const bn={command:"buildIfNeeded",describe:"Build code if changes are detected",builder:{command:{description:"A build command",type:"string",default:"yarn build",alias:"c"}},async handler(t){await async function(t,n){const s=await gn(t,!0,n);if(!s)return console.error(O.red("No project found.")),!0;if(!l.existsSync(e.join(s.rootDirPath,".git")))return vn(s,t),!0;const[i,r,o]=await async function(t,n){const s=e.resolve(t.dirPath,"node_modules",".cache","build"),i=e.resolve(s,"last-build");await l.promises.mkdir(s,{recursive:!0});const r=w("sha256"),o=y.execSync("git rev-parse HEAD",{cwd:t.dirPath}).toString().trim();r.update(o);const a=JSON.stringify(Object.entries(t.env).filter((([e])=>!wn.has(e))).sort((([e],[t])=>e.localeCompare(t))));r.update(a),await async function(e,t,n){return new Promise((s=>{const i=y.spawnSync("git",["diff","--name-only"],{cwd:e.dirPath,env:e.env,stdio:"pipe",encoding:"utf8"}).stdout.trim().split("\n").map((t=>"test"===e.env.WB_ENV?t.replace(/packages\/scripts\/test-fixtures\/[^/]+\//,""):t)).filter((e=>(On.some((t=>e.includes(t)))||En.some((t=>e.endsWith(t))))&&!kn.some((t=>e.includes(t)))));t.verbose&&console.info(`Changed files: ${i.join(", ")}`);const r=y.spawn("git",["diff","--",...i],{cwd:e.rootDirPath});r.stdout?.on("data",(e=>{n.update(e),t.verbose&&(console.info(e.toString()),console.info("Hash:",n.copy().digest("hex")))})),r.on("close",(()=>{s()}))}))}(t,n,r);const c=r.digest("hex"),h=await async function(e){try{return await e()}catch(e){if("object"==typeof e&&e&&"code"in e&&"ENOENT"===e.code)return;throw e}}((()=>l.promises.readFile(i,"utf8")));return[h===c,i,c]}(s,t);if(i)return console.info(O.green(`Skip to run '${t.command}' 💫`)),!1;if(!vn(s,t))return;t.dryRun||await l.promises.writeFile(r,o,"utf8");return!0}(t)}};function vn(e,t){if(console.info(O.green(`Run '${t.command}'`)),!t.dryRun){const n=y.spawnSync(t.command??"",{cwd:e.dirPath,env:e.env,shell:!0,stdio:"inherit"});if(0!==n.status)return process.exitCode=n.status??1,!1}return!0}const wn=new Set(["CI","PWDEBUG","TMPDIR"]);const On=["src/","public/"],En=[".js",".cjs",".mjs",".jsx",".ts",".cts",".mts",".tsx",".json",".browserslistrc","package.json","yarn.lock"],kn=["test/","tests/","__tests__/","test-fixtures/"];function*An(e,t){for(const n of t)console.info(`Running "${e}" for ${n.name} ...`),yield n}const jn={command:"optimizeForDockerBuild",describe:"Optimize configuration when building a Docker image",builder:{outside:{description:"Whether the optimization is executed outside a docker container or not",type:"boolean",alias:"o"}},async handler(t){const n=await mn(t);n||(console.error(O.red("No project found.")),process.exit(1));for(const s of An("optimizeForDockerBuild",n.all)){const n=s.packageJson,i=["dependencies","devDependencies"];for(const e of i){const t=n[e]||{};for(const[e,n]of Object.entries(t))n?.startsWith("git@github.com:")&&(t[e]=`./${e}`)}if($n(t,n),_n(n),xn(n),t.dryRun)continue;const r=t.outside?e.join(s.dirPath,"dist"):s.dirPath;await l.promises.mkdir(r,{recursive:!0}),await l.promises.writeFile(e.join(r,"package.json"),JSON.stringify(n),"utf8")}t.dryRun||t.outside||y.spawnSync("yarn",{stdio:"inherit"})}};function $n(e,t){if(!e.outside)return void delete t.devDependencies;const n=t.devDependencies||{},s=["artillery","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 t of Object.keys(n))(s.some((e=>t.includes(e)))||!e.outside&&t.includes("willbooster")&&t.includes("config"))&&delete n[t]}function _n(e){const t=["check","deploy","format","lint","start","test"],n=["pinst ","husky "],s=e.scripts||{};for(const[e,i]of Object.entries(s))(t.some((t=>e.includes(t)))||n.some((e=>i.includes(e)||i.trim()===e.trim())))&&delete s[e]}function xn(e){delete e.private,delete e.publishConfig,delete e.prettier}const Cn=new class{deploy(e){return"PRISMA migrate deploy"}deployForce(e,t){const n=e.packageJson.dependencies?.blitz?"db":"prisma";return`rm -Rf ${n}/mount/prod.sqlite3*; PRISMA migrate reset --force && rm -Rf ${n}/mount/prod.sqlite3*\n && litestream restore -o ${n}/mount/prod.sqlite3 ${t} && ALLOW_TO_SKIP_SEED=0 PRISMA migrate deploy`}litestream(e){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(e){return`PRISMA migrate deploy && PRISMA generate && ${this.seed(e)}`}migrateDev(e){return"PRISMA migrate dev"}reset(e){return`PRISMA migrate reset --force --skip-seed && ${this.seed(e)}`}restore(e,t,n){return`rm -Rf ${e.packageJson.dependencies?.blitz?"db":"prisma"}/restored.sqlite3; GOOGLE_APPLICATION_CREDENTIALS=gcp-sa-key.json litestream restore -o ${n} ${t}`}seed(e,t){return e.packageJson.dependencies?.blitz?"YARN blitz db seed"+(t?` -f ${t}`:""):t?"YARN build-ts run prisma/seeds.ts":e.packageJson.prisma?.seed?"YARN prisma db seed":'if [ -e "prisma/seeds.ts" ]; then YARN build-ts run prisma/seeds.ts; fi'}studio(t,n){let s="";if(n)try{new URL(n),s=`DATABASE_URL=${n} `}catch{const t=e.resolve(n);console.info(n,t),s=`DATABASE_URL=file://${t} `}return`${s}PRISMA studio`}},Pn=new Set;async function Sn(e){try{await k(e)}catch{}}const Nn=new A,Mn={exitIfFailed:!0};async function Dn(e,t,n,s=Mn){const[i,r]=Rn(e,t);if(Wn(i,t),n.verbose&&Wn(r,t,"Start (raw)",!0),n.dryRun)return zn(i,0,s),0;const o=r.match(/http:\/\/127.0.0.1:(\d+)/)?.[1];r.includes("wait-on")&&o&&!r.includes("docker run")&&await async function(e){await Sn(e);const t=async()=>{Pn.has(e)||(Pn.add(e),await Sn(e))};for(const e of["beforeExit","SIGINT","SIGTERM","SIGQUIT"])process.on(e,t)}(Number(o));const a=await N(r,void 0,{cwd:t.dirPath,env:t.env,shell:!0,stdio:"inherit",timeout:s?.timeout,killOnExit:!0,verbose:n.verbose});return zn(i,a.status,s),a.status??1}function In(e,t,n,s=Mn){return Nn.run((async()=>{const[i,r]=Rn(e,t);if(Wn(i,t,"Start (parallel)",!0),n.dryRun)return Wn(i,t,"Started (log)"),n.verbose&&Wn(r,t,"Started (raw)",!0),void zn(i,0,s);const o=await N(r,void 0,{cwd:t.dirPath,env:t.env,shell:!0,stdio:"pipe",timeout:s?.timeout,mergeOutAndError:!0,killOnExit:!0,verbose:n.verbose});Wn(i,t,"Started (log)"),n.verbose&&Wn(r,t,"Started (raw)",!0);const a=o.stdout.trim();a&&console.info(a),zn(i,o.status,s)}))}function Rn(e,t){const n=e.replaceAll("\n","").replaceAll(/\s\s+/g," ").replaceAll("PRISMA ",t.packageJson.dependencies?.blitz?"YARN blitz prisma ":"YARN prisma ").trim();return[n.replaceAll("YARN ","yarn "),n.replaceAll("YARN ",t.binExists?"":"yarn ")]}function Wn(e,t,n="Start",s=!1){console.info("\n"+(s?O.gray:O.cyan)(O.bold(`${n}:`),e)+O.gray(` at ${t.dirPath}`))}function zn(e,t,n){0===t?console.info(O.green(O.bold("Finished:"),e)):(console.info(O.red(O.bold(`Failed (exit code ${t}): `),e)),!1!==n.exitIfFailed&&process.exit(t??1))}const Fn={},Tn={command:"prisma",describe:"Run prisma commands",builder:e=>e.command(Ln).command(Vn).command(Un).command(Hn).command(Yn).command(qn).command(Jn).command(Gn).command(Kn).demandCommand(),handler(){}},Ln={command:"deploy",describe:"Apply migration to DB without initializing it",builder:Fn,async handler(e){const t=await Qn(e);for(const n of An("prisma deploy",t))await Dn(Cn.deploy(n),n,e)}},Bn={...Fn,"backup-path":{description:"Whether to skip actual command execution",demandOption:!0,type:"string",alias:"b"}},Vn={command:"deploy-force <backup-path>",describe:"Force to apply migration to DB utilizing Litestream's backup without initializing it",builder:Bn,async handler(e){const t=await Qn(e);for(const n of An("prisma deploy-force",t))await Dn(Cn.deployForce(n,e.backupPath),n,e)}},Un={command:"litestream",describe:"Setup DB for Litestream",builder:Fn,async handler(e){const t=await Qn(e);for(const n of An("prisma litestream",t))await Dn(Cn.litestream(n),n,e)}},Hn={command:"migrate",describe:"Apply migration to DB with initializing it",builder:Fn,async handler(e){const t=await Qn(e);for(const n of An("prisma migrate",t))await Dn(Cn.migrate(n),n,e)}},Yn={command:"migrate-dev",describe:"Create a migration file",builder:Fn,async handler(e){const t=await Qn(e);for(const n of An("prisma migrate-dev",t))await Dn(Cn.migrateDev(n),n,e)}},qn={command:"reset",describe:"Reset DB",builder:Fn,async handler(e){const t=await Qn(e);for(const n of An("prisma reset",t))await Dn(Cn.reset(n),n,e)}},Jn={command:"restore <backup-path>",describe:"Restore DB from Litestream's backup",builder:{...Bn,output:{description:'Output path of the restored database. Defaults to "<db|prisma>/restored.sqlite3".',type:"string"}},async handler(e){const t=await Qn(e);for(const n of An("prisma restore",t)){const t=e.output||(n.packageJson.dependencies?.blitz?"db/restored.sqlite3":"prisma/restored.sqlite3");await Dn(Cn.restore(n,e.backupPath,t),n,e)}}},Gn={command:"seed",describe:"Populate DB with seed data",builder:{...Fn,file:{alias:"f",description:"Path of the seed script.",type:"string"}},async handler(e){const t=await Qn(e);for(const n of An("prisma seed",t))await Dn(Cn.seed(n,e.file),n,e)}},Kn={command:"studio [db-url-or-path]",describe:"Open Prisma Studio",builder:{...Fn,"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(e){if(e.restored&&e.dbUrlOrPath)throw new Error("You cannot specify both --restored and --db-url-or-path.");const t=await Qn(e);for(const n of An("prisma studio",t)){const t=e.restored?n.packageJson.dependencies?.blitz?"db/restored.sqlite3":"prisma/restored.sqlite3":e.dbUrlOrPath?.toString();await Dn(Cn.studio(n,t),n,e)}}};async function Qn(e){const t=await mn(e);t||(console.error(O.red("No project found.")),process.exit(1));const n=t.all.filter((e=>e.packageJson.dependencies?.prisma||e.packageJson.devDependencies?.prisma));return 0===n.length&&(console.error(O.red("No prisma project found.")),process.exit(1)),n}const Xn={command:"retry [command] [args...]",describe:"Retry the given command until it succeeds",builder:{retry:{description:"A maximum retry count",type:"number",alias:"r",default:3}},async handler(e){const t=gn(e);t||(console.error(O.red("No project found.")),process.exit(1));const n=[e.command,...e.args??[],...e._.slice(1)].filter(Boolean);let s=0;for(let i=0;i<e.retry;i++)if(i>0&&console.info(`\n${O.yellow(`#${i} Retrying: ${n.join(" ")}`)}`),s=await Dn(n.join(" "),t,e,{exitIfFailed:!1}),0===s)return;process.exit(s)}},Zn={command:"setup",describe:"Setup development environment. .env files are ignored.",builder:{},async handler(e){await async function(e,t){const n=await mn(e,!1,t);n||(console.error(O.red("No project found.")),process.exit(1));for(const t of An("setup",n.all)){const s=await $.readdir(t.dirPath,{withFileTypes:!0});if(t===n.root){if("darwin"===_.platform()){const n=["pstree"];t.hasDockerfile&&n.push("expect"),await In(`brew install ${n.join(" ")}`,t,e)}s.some((e=>e.isFile()&&e.name.includes("-version")))&&await Dn("asdf install",t,e)}if(s.some((e=>e.isFile()&&"pyproject.toml"===e.name))){await In("poetry config virtualenvs.in-project true",t,e),await In("poetry config virtualenvs.prefer-active-python true",t,e);const[,n]=y.execSync("asdf current python").toString().trim().split(/\s+/);await In(`poetry env use ${n}`,t,e),await Nn.promiseAll(),await Dn("poetry run pip install --upgrade pip",t,e),await Dn("poetry install --ansi",t,e)}const i=t.packageJson.dependencies??{},r=t.packageJson.devDependencies||{},o=t.packageJson.scripts??{},a=[],c=[];i.blitz||i.next||r["@remix-run/dev"]?(a.push("pm2"),c.push("concurrently","open-cli","vitest","wait-on")):(i.express||i.fastify)&&(a.push("pm2"),c.push("concurrently","vitest","wait-on")),a.length>0&&await Dn(`yarn add ${a.join(" ")}`,t,e),c.length>0&&await Dn(`yarn add -D ${c.join(" ")}`,t,e),o["gen-code"]&&await Dn("yarn gen-code",t,e)}}(e)}};const es=new class{buildDevImage(t,n){const s=t.dockerPackageJson.scripts?.["docker/build/prepare"]?"yarn run docker/build/prepare && ":"";return`cd ${e.dirname(t.findFile("Dockerfile"))}\n && ${s}YARN wb optimizeForDockerBuild --outside\n && YARN wb retry -- docker build -t ${t.dockerImageName}\n --build-arg ARCH=$([ $(uname -m) = 'arm64' ] && echo arm64 || echo amd64)\n --build-arg WB_ENV=${t.env.WB_ENV}\n --build-arg WB_VERSION=${n} .`}stopAndStart(e,t=!1,n="",s=""){return`${this.stop(e)} && ${t?"unbuffer ":""}${this.start(e,n,s)}`}start(e,t="",n=""){return function(e,t){const n=async()=>{if(Pn.has(e))return;Pn.add(e),Wn(e,t);const{status:n}=v(e,{cwd:t.dirPath,shell:!0,stdio:"inherit"});zn(e,n,{})};for(const e of["beforeExit","SIGINT","SIGTERM","SIGQUIT"])process.on(e,n)}(this.stop(e),e),`docker run --rm -it -p 8080:8080 --name ${e.dockerImageName} ${t} ${e.dockerImageName} ${n}`}stop(e){return`true $(docker rm -f $(docker container ls -q -f name=${e.dockerImageName}) 2> /dev/null)`}stopAll(){return"true $(docker rm -f $(docker ps -q) 2> /dev/null)"}};class ts{constructor(e=3e3){this.defaultPort=e}buildDocker(e,t="development"){return es.buildDevImage(e,t)}startDocker(e,t){return`${this.buildDocker(e)}\n && YARN concurrently --raw --kill-others-on-fail\n "${es.stopAndStart(e,!1,t.normalizedDockerOptionsText??"",t.normalizedArgsText??"")}"\n "${this.waitAndOpenApp(e,t,8080)}"`}testE2E(e,t,{playwrightArgs:n="test tests/e2e",prismaDirectory:s,startCommand:i}){const r=e.env.WB_ENV;return`WB_ENV=${r} NEXT_PUBLIC_WB_ENV=${r} APP_ENV=${r} PORT=8080 YARN concurrently --kill-others --raw --success first\n "rm -Rf ${s}/mount && ${i} && 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 ${n}"`}testE2EDev(e,t,{playwrightArgs:n="test tests/e2e",startCommand:s}){const i=e.env.WB_ENV;return`WB_ENV=${i} NEXT_PUBLIC_WB_ENV=${i} APP_ENV=${i} PORT=8080 YARN 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 ${n}"`}testUnit(e,t){return`WB_ENV=${e.env.WB_ENV} YARN vitest run tests/unit --color --passWithNoTests`}waitApp(e,t,n=this.defaultPort){return`wait-on -t 10000 http://127.0.0.1:${n} 2> /dev/null\n || wait-on -t 10000 -i 500 http://127.0.0.1:${n} 2> /dev/null\n || wait-on -t 10000 -i 1000 http://127.0.0.1:${n} 2> /dev/null\n || wait-on -t 10000 -i 2000 http://127.0.0.1:${n} 2> /dev/null\n || wait-on -t 20000 -i 4000 http://127.0.0.1:${n} 2> /dev/null\n || wait-on -t 60000 -i 5000 http://127.0.0.1:${n}`}waitAndOpenApp(e,t,n=this.defaultPort){return`${this.waitApp(e,t,n)} || wait-on http://127.0.0.1:${n} && open-cli "http://\${HOST:-localhost}:${n}"`}}const ns=new class extends ts{constructor(){super()}start(e,t){return`${e.env.WB_ENV?`APP_ENV=${e.env.WB_ENV} `:""}YARN concurrently --raw --kill-others-on-fail\n "blitz dev ${t.normalizedArgsText??""}"\n "${this.waitAndOpenApp(e,t)}"`}startProduction(e,t,n){return`${e.env.WB_ENV?`APP_ENV=${e.env.WB_ENV} `:""}NODE_ENV=production YARN concurrently --raw --kill-others-on-fail\n "${Cn.reset(e)} && ${e.buildCommand} && PORT=${n} pm2-runtime start ${e.findFile("ecosystem.config.cjs")} ${t.normalizedArgsText??""}"\n "${this.waitAndOpenApp(e,t,n)}"`}testE2E(e,t,{playwrightArgs:n,startCommand:s=`${Cn.reset(e)} && ${e.buildCommand} && pm2-runtime start ${e.findFile("ecosystem.config.cjs")}`}){return super.testE2E(e,t,{playwrightArgs:n,prismaDirectory:"db",startCommand:s})}testE2EDev(e,t,{playwrightArgs:n,startCommand:s="blitz dev -p 8080"}){return super.testE2EDev(e,t,{playwrightArgs:n,startCommand:s})}testStart(e,t){return`YARN concurrently --kill-others --raw --success first "blitz dev" "${this.waitApp(e,t)}"`}};const ss=new class extends ts{constructor(){super()}start(e,t){return`YARN build-ts run src/index.ts ${t.watch?"--watch":""} -- ${t.normalizedArgsText??""}`}startDocker(e,t){return`${this.buildDocker(e)} && ${es.stopAndStart(e,!1,t.normalizedDockerOptionsText??"",t.normalizedArgsText??"")}`}startProduction(e,t,n=8080){return`NODE_ENV=production ${e.buildCommand} && NODE_ENV=production PORT=\${PORT:-${n}} node dist/index.js ${t.normalizedArgsText??""}`}testE2E(e,t,{startCommand:n=`if [ -e "prisma" ]; then prisma migrate reset --force --skip-generate; fi && (${this.startProduction(e,t)})`}){return`NODE_ENV=production WB_ENV=${e.env.WB_ENV} PORT=8080 YARN concurrently --kill-others --raw --success first\n "${n} && exit 1"\n "wait-on -t 600000 -i 2000 http://127.0.0.1:8080 && vitest run tests/e2e --color --passWithNoTests"`}testE2EDev(e,t,{startCommand:n}){return`NODE_ENV=production WB_ENV=${e.env.WB_ENV} PORT=8080 YARN concurrently --kill-others --raw --success first\n "${n||this.start(e,t)} && exit 1"\n "wait-on -t 600000 -i 2000 http://127.0.0.1:8080 && vitest run tests/e2e --color --passWithNoTests"`}testStart(e,t){return`YARN concurrently --kill-others --raw --success first "${this.start(e,t)}" "${this.waitApp(e,t)}"`}};const is=new class extends ts{constructor(){super()}start(e,t){return`YARN concurrently --raw --kill-others-on-fail\n "next dev ${t.normalizedArgsText??""}"\n "${this.waitAndOpenApp(e,t)}"`}startProduction(e,t,n){return`NODE_ENV=production YARN concurrently --raw --kill-others-on-fail\n "${[...e.hasPrisma?[Cn.reset(e)]:[],e.buildCommand,`PORT=${n} pm2-runtime start ${e.findFile("ecosystem.config.cjs")} ${t.normalizedArgsText??""}`].join(" && ")}"\n "${this.waitAndOpenApp(e,t,n)}"`}testE2E(e,t,n){return super.testE2E(e,t,{playwrightArgs:n.playwrightArgs,prismaDirectory:"db",startCommand:n.startCommand??[...e.hasPrisma?[Cn.reset(e)]:[],e.buildCommand,`pm2-runtime start ${e.findFile("ecosystem.config.cjs")}`].join(" && ")})}testE2EDev(e,t,{startCommand:n="next dev -p 8080"}){return super.testE2EDev(e,t,{startCommand:n})}testStart(e,t){return`YARN concurrently --kill-others --raw --success first "next dev" "${this.waitApp(e,t)}"`}};const rs=new class extends ts{constructor(){super()}start(e,t){return`YARN build-ts run src/index.ts ${t.watch?"--watch":""} -- ${t.normalizedArgsText??""}`}startDocker(e,t){return`${this.buildDocker(e)} && ${es.stopAndStart(e,!1,t.normalizedDockerOptionsText??"",t.normalizedArgsText??"")}`}startProduction(e,t){return`NODE_ENV=production ${e.buildCommand} && NODE_ENV=production node dist/index.js ${t.normalizedArgsText??""}`}testE2E(e){return"echo 'do nothing.'"}testE2EDev(e){return"echo 'do nothing.'"}testStart(e){return"echo 'do nothing.'"}};const os=new class extends ts{constructor(){super()}start(e,t){return`YARN concurrently --raw --kill-others-on-fail\n "remix dev ${t.normalizedArgsText??""}"\n "${this.waitAndOpenApp(e,t)}"`}startProduction(e,t,n){return`NODE_ENV=production YARN concurrently --raw --kill-others-on-fail\n "${Cn.reset(e)} && ${e.buildCommand} && PORT=${n} pm2-runtime start ${e.findFile("ecosystem.config.cjs")} ${t.normalizedArgsText??""}"\n "${this.waitAndOpenApp(e,t,n)}"`}testE2E(e,t,{playwrightArgs:n,startCommand:s=`${Cn.reset(e)} && ${e.buildCommand} && pm2-runtime start ${e.findFile("ecosystem.config.cjs")}`}){return super.testE2E(e,t,{playwrightArgs:n,prismaDirectory:"prisma",startCommand:s})}testE2EDev(e,t,{playwrightArgs:n,startCommand:s="remix dev"}){return super.testE2EDev(e,t,{playwrightArgs:n,startCommand:s})}testStart(e,t){return`YARN concurrently --kill-others --raw --success first "remix dev" "${this.waitApp(e,t)}"`}},as={command:"start [args..]",describe:"Start app",builder:{watch:{description:"Whether to watch files",type:"boolean"},args:{description:"Arguments for core command",type:"array",alias:"a",default:[]},"docker-options":{description:'Arguments for "docker run"',type:"array",default:[]},mode:{description:"Start mode: dev[elopment] (default) | staging | docker | docker-debug",type:"string",alias:"m"}},async handler(e){!function(e){e.normalizedArgsText=[...e.args??[],...e._?.slice(1)??[]].map((e=>`'${e}'`)).join(" "),e.normalizedDockerOptionsText=(e.dockerOptions??[]).map((e=>`'${e}'`)).join(" ")}(e);const t=await mn(e);t||(console.error(O.red("No project found.")),process.exit(1));for(const n of t.all){const t=n.packageJson.dependencies||{},s=n.packageJson.devDependencies||{};let i;if(t.blitz)i=ns;else if(t.next)i=is;else if(s["@remix-run/dev"])i=os;else if((t.express||t.fastify)&&!t["firebase-functions"]||n.hasDockerfile&&/EXPOSE\s+8080/.test(n.dockerfile))i=ss;else{if(!t["build-ts"]&&!s["build-ts"])continue;i=rs}switch(console.info(`Running "start" for ${n.name} ...`),e.mode||"dev"){case"dev":case"development":{const s=cs(t,"development");await Dn(`${s}${i.start(n,e)}`,n,e);break}case"staging":{const s=cs(t,"staging");await Dn(`${s}${i.startProduction(n,e,8080)}`,n,e);break}case"docker":{const s=cs(t,"staging");await Dn(`${s}${i.startDocker(n,e)}`,n,e);break}case"docker-debug":{const s=cs(t,"staging");e.normalizedArgsText="'/bin/bash'",await Dn(`${s}${i.startDocker(n,e)}`,n,e);break}default:throw new Error(`Unknown start mode: ${e.mode}`)}}}};function cs(e,t){process.env.WB_ENV||=t;let n=`WB_ENV=${process.env.WB_ENV} `;return e.next&&(process.env.NEXT_PUBLIC_WB_ENV=process.env.WB_ENV,n+=`NEXT_PUBLIC_WB_ENV=${process.env.WB_ENV} `),n}const ls={command:"test",describe:"Test project",builder:{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(t){await async function(t){const n=await mn(t);n||(console.error(O.red("No project found.")),process.exit(1));n.all.length>1&&(process.env.CI="1");process.env.FORCE_COLOR||="3",process.env.WB_ENV||="test";for(const s of n.all){const n=s.packageJson.dependencies||{},i=s.packageJson.devDependencies||{};let r;r=n.blitz?ns:n.next?is:i["@remix-run/dev"]?os:!n.express&&!n.fastify||n["firebase-functions"]?rs:ss,console.info(`Running "test" for ${s.name} ...`);const o=[];if(!t.ci){switch((t.unit||!t.start&&void 0===t.e2e)&&o.push(Dn(r.testUnit(s,t),s,t,{timeout:t.unitTimeout})),t.start&&o.push(Dn(r.testStart(s,t),s,t)),await Promise.all(o),t.e2e){case void 0:case"none":continue;case"":case"headless":await Dn(r.testE2E(s,t,{}),s,t);continue;case"headless-dev":await Dn(r.testE2EDev(s,t,{}),s,t);continue;case"docker":await hs(s,t,r);continue;case"docker-debug":await hs(s,t,r,"test tests/e2e --debug");continue}if(n.blitz||n.next||i["@remix-run/dev"])switch(t.e2e){case"headed":await Dn(r.testE2E(s,t,{playwrightArgs:"test tests/e2e --headed"}),s,t);continue;case"headed-dev":await Dn(r.testE2EDev(s,t,{playwrightArgs:"test tests/e2e --headed"}),s,t);continue;case"debug":await Dn(r.testE2E(s,t,{playwrightArgs:"test tests/e2e --debug"}),s,t);continue;case"generate":await Dn(r.testE2E(s,t,{playwrightArgs:"codegen http://localhost:8080"}),s,t);continue;case"trace":await Dn("playwright show-trace",s,t);continue}throw new Error(`Unknown e2e mode: ${t.e2e}`)}{const n=S(e.join(s.dirPath,"tests","unit")),i=S(e.join(s.dirPath,"tests","e2e"));if(await In(es.stopAll(),s,t),!1!==t.unit&&await n&&await In(r.testUnit(s,t),s,t,{timeout:t.unitTimeout}),!1!==t.start&&await In(r.testStart(s,t),s,t),await Nn.promiseAll(),"none"!==t.e2e&&await i){s.hasDockerfile&&await Dn(`${r.buildDocker(s,"test")}`,s,t);const e=s.hasDockerfile?{startCommand:es.stopAndStart(s,!0)}:{};process.exitCode=await Dn(r.testE2E(s,t,e),s,t,{exitIfFailed:!1}),await Dn(es.stop(s),s,t)}}}}(t)}};async function hs(e,t,n,s){await Dn(`${n.buildDocker(e,"test")}`,e,t),process.exitCode=await Dn(`${n.testE2E(e,t,{playwrightArgs:s,startCommand:es.stopAndStart(e,!0)})}`,e,t,{exitIfFailed:!1}),await Dn(es.stop(e),e,t)}const ds={command:"typecheck",describe:"Run type checking. .env files are ignored.",builder:{},async handler(e){const t=await mn(e,!1);t||(console.error(O.red("No project found.")),process.exit(1));for(const n of t.all){const s=[];if(n.packageJson.workspaces||((n.packageJson.dependencies?.typescript||n.packageJson.devDependencies?.typescript)&&s.push("tsc --noEmit --Pretty"),n.packageJson.devDependencies?.pyright&&s.push("pyright")),0===s.length)continue;console.info(`Running "typecheck" for ${n.name} ...`),t.all.length>1&&(n.env.CI="1"),n.env.FORCE_COLOR||="3";if(0!==await Dn(s.join(" && "),n,e)){(JSON.parse(await $.readFile("package.json","utf8")).dependencies||{}).blitz&&console.info(O.yellow('Please try "yarn gen-code" if you face unknown type errors.'))}}}},us={...ds,command:"tc"},fs={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`). Preferred over `cascade-node-env` and `auto-cascade-env`.",type:"string"},"cascade-node-env":{description:'Same with --cascade-env=<NODE_ENV || "development">. Preferred over `auto-cascade-env`.',type:"boolean"},"auto-cascade-env":{description:'Same with --cascade-env=<WB_ENV || NODE_ENV || "development">.',type:"boolean",default:!0},"include-root-env":{description:"Include .env files in root directory if the project is in a monorepo and --env option is not used.",type:"boolean",default:!0},"check-env":{description:"Check whether the keys of the loaded .env files are same with the given .env file.",type:"string",default:".env.example"},verbose:{description:"Whether to show verbose information",type:"boolean",alias:"v"},"working-dir":{description:"A working directory",type:"string",alias:"w"},"dry-run":{description:"Whether to skip actual command execution",type:"boolean",alias:"d"}};var ps;await an((ps=process.argv,ps.slice(te()+1))).scriptName("wb").options(fs).middleware((t=>{const n=t["working-dir"];if(n){const t=e.resolve(n);process.chdir(t)}!function(e){e.PATH&&e.BERRY_BIN_FOLDER&&(e.PATH=e.PATH.replace(`${e.BERRY_BIN_FOLDER}:`,"").replaceAll(/\/private\/var\/folders\/[^:]+:/g,"").replaceAll(/\/var\/tmp\/[^:]+:/g,"").replaceAll(/\/tmp\/[^:]+:/g,""));for(const t of Object.keys(e)){const n=t.toUpperCase();(n.startsWith("NPM_")||n.startsWith("YARN_")||n.startsWith("BERRY_")||"PROJECT_CWD"===n||"INIT_CWD"===n)&&delete e[t]}}(process.env)})).command(bn).command(jn).command(Tn).command(Xn).command(Zn).command(as).command(ls).command(ds).command(us).demandCommand().strict().help().argv;for(const e of["SIGINT","SIGTERM","SIGQUIT"])process.on(e,(()=>process.exit()));
33
+ var q,J,G;const K=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,Q=null!==(J=null===(q=null===process||void 0===process?void 0:process.versions)||void 0===q?void 0:q.node)&&void 0!==J?J:null===(G=null===process||void 0===process?void 0:process.version)||void 0===G?void 0:G.slice(1);if(Q){if(Number(Q.match(/^([^.]+)/)[1])<K)throw Error(`yargs parser supports a minimum Node.js version of ${K}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}const X=process?process.env:{},Z=new class{constructor(t){U=t}parse(t,e){const n=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},e),s=function(t){if(Array.isArray(t))return t.map((t=>"string"!=typeof t?t+"":t));t=t.trim();let e=0,n=null,s=null,i=null;const r=[];for(let o=0;o<t.length;o++)n=s,s=t.charAt(o)," "!==s||i?(s===i?i=null:"'"!==s&&'"'!==s||i||(i=s),r[e]||(r[e]=""),r[e]+=s):" "!==n&&e++;return r}(t),i="string"==typeof t,r=function(t){const e=[],n=Object.create(null);let s=!0;Object.keys(t).forEach((function(n){e.push([].concat(t[n],n))}));for(;s;){s=!1;for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++){if(e[t].filter((function(t){return-1!==e[n].indexOf(t)})).length){e[t]=e[t].concat(e[n]),e.splice(n,1),s=!0;break}}}return e.forEach((function(t){const e=(t=t.filter((function(t,e,n){return n.indexOf(t)===e}))).pop();void 0!==e&&"string"==typeof e&&(n[e]=t)})),n}(Object.assign(Object.create(null),n.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},n.configuration),a=Object.assign(Object.create(null),n.default),c=n.configObjects||[],l=n.envPrefix,h=o["populate--"],d=h?"--":"_",u=Object.create(null),f=Object.create(null),p=n.__||U.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(n.array||[]).filter(Boolean).forEach((function(t){const e="object"==typeof t?t.key:t,n=Object.keys(t).map((function(t){return{boolean:"bools",string:"strings",number:"numbers"}[t]})).filter(Boolean).pop();n&&(g[n][e]=!0),g.arrays[e]=!0,g.keys.push(e)})),[].concat(n.boolean||[]).filter(Boolean).forEach((function(t){g.bools[t]=!0,g.keys.push(t)})),[].concat(n.string||[]).filter(Boolean).forEach((function(t){g.strings[t]=!0,g.keys.push(t)})),[].concat(n.number||[]).filter(Boolean).forEach((function(t){g.numbers[t]=!0,g.keys.push(t)})),[].concat(n.count||[]).filter(Boolean).forEach((function(t){g.counts[t]=!0,g.keys.push(t)})),[].concat(n.normalize||[]).filter(Boolean).forEach((function(t){g.normalize[t]=!0,g.keys.push(t)})),"object"==typeof n.narg&&Object.entries(n.narg).forEach((([t,e])=>{"number"==typeof e&&(g.nargs[t]=e,g.keys.push(t))})),"object"==typeof n.coerce&&Object.entries(n.coerce).forEach((([t,e])=>{"function"==typeof e&&(g.coercions[t]=e,g.keys.push(t))})),void 0!==n.config&&(Array.isArray(n.config)||"string"==typeof n.config?[].concat(n.config).filter(Boolean).forEach((function(t){g.configs[t]=!0})):"object"==typeof n.config&&Object.entries(n.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 n=T(e);n!==t&&-1===g.aliases[t].indexOf(n)&&(g.aliases[t].push(n),u[n]=!0)}})),g.aliases[t].concat(t).forEach((function(e){if(e.length>1&&/[A-Z]/.test(e)&&o["camel-case-expansion"]){const n=L(e,"-");n!==t&&-1===g.aliases[t].indexOf(n)&&(g.aliases[t].push(n),u[n]=!0)}})),g.aliases[t].forEach((function(e){g.aliases[e]=[t].concat(g.aliases[t].filter((function(t){return e!==t})))})))}))}))}(n.key,r,n.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 v=[];const w=Object.assign(Object.create(null),{_:[]}),O={};for(let t=0;t<s.length;t++){const e=s[t],n=e.replace(/^-{3,}/,"---");let i,r,a,c,l,h;if("--"!==e&&/^-/.test(e)&&R(e))E(e);else{if(n.match(/^---+(=|$)/)){E(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=A(t,c[1],s,c[2]):!1!==D(c[1],g.nargs)?t=k(t,c[1],s,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=A(t,r,s):!1!==D(r,g.nargs)?t=k(t,r,s):(l=s[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,W(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=s[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,W(r)):(j(r,l),t++));else if(e.match(/^-[^-]+/)&&!e.match(m)){a=e.slice(1,-1).split(""),i=!1;for(let n=0;n<a.length;n++){if(l=e.slice(n+2),a[n+1]&&"="===a[n+1]){h=e.slice(n+3),r=a[n],D(r,g.arrays)?t=A(t,r,s,h):!1!==D(r,g.nargs)?t=k(t,r,s,h):j(r,h),i=!0;break}if("-"!==l){if(/[A-Za-z]/.test(a[n])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(l)&&!1===D(l,g.bools)){j(a[n],l),i=!0;break}if(a[n+1]&&a[n+1].match(/\W/)){j(a[n],l),i=!0;break}j(a[n],W(a[n]))}else j(a[n],l)}r=e.slice(-1)[0],i||"-"===r||(D(r,g.arrays)?t=A(t,r,s):!1!==D(r,g.nargs)?t=k(t,r,s):(l=s[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,W(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,W(r));else{if("--"===e){v=s.slice(t+1);break}if(o["halt-at-non-option"]){v=s.slice(t);break}E(e)}}}function E(t){const e=x("_",t);"string"!=typeof e&&"number"!=typeof e||w._.push(e)}function k(t,e,n,s){let i,r=D(e,g.nargs);if(r="number"!=typeof r||isNaN(r)?1:r,0===r)return z(s)||(b=Error(p("Argument unexpected for: %s",e))),j(e,W(e)),t;let a=z(s)?0:1;if(o["nargs-eats-options"])n.length-(t+1)+a<r&&(b=Error(p("Not enough arguments following: %s",e))),a=r;else{for(i=t+1;i<n.length&&(!n[i].match(/^-[^0-9]/)||n[i].match(m)||R(n[i]));i++)a++;a<r&&(b=Error(p("Not enough arguments following: %s",e)))}let c=Math.min(a,r);for(!z(s)&&c>0&&(j(e,s),c--),i=t+1;i<c+t+1;i++)j(e,n[i]);return t+c}function A(t,e,n,s){let r=[],c=s||n[t+1];const l=D(e,g.nargs);if(D(e,g.bools)&&!/^(true|false)$/.test(c))r.push(!0);else if(z(c)||z(s)&&/^-/.test(c)&&!m.test(c)&&!R(c)){if(void 0!==a[e]){const t=a[e];r=Array.isArray(t)?t:[t]}}else{z(s)||r.push(_(e,s,!0));for(let s=t+1;s<n.length&&!(!o["greedy-arrays"]&&r.length>0||l&&"number"==typeof l&&r.length>=l)&&(c=n[s],!/^-/.test(c)||m.test(c)||R(c));s++)t=s,r.push(_(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,n=i){if(/-/.test(t)&&o["camel-case-expansion"]){const e=t.split(".").map((function(t){return T(t)})).join(".");$(t,e)}const s=_(t,e,n),r=t.split(".");if(M(w,r,s),g.aliases[t]&&g.aliases[t].forEach((function(t){const e=t.split(".");M(w,e,s)})),r.length>1&&o["dot-notation"]&&(g.aliases[r[0]]||[]).forEach((function(e){let n=e.split(".");const i=[].concat(r);i.shift(),n=n.concat(i),(g.aliases[t]||[]).includes(n.join("."))||M(w,n,s)})),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?U.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 _(t,e,n){n&&(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 s=Array.isArray(e)?e.map((function(e){return x(t,e)})):x(t,e);return D(t,g.counts)&&(z(s)||"boolean"==typeof s)&&(s=H()),D(t,g.normalize)&&D(t,g.arrays)&&(s=Array.isArray(e)?e.map((t=>U.normalize(t))):U.normalize(e)),s}function x(t,e){if(!o["parse-positional-numbers"]&&"_"===t)return e;if(!D(t,g.strings)&&!D(t,g.bools)&&!Array.isArray(e)){(B(e)&&o["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${e}`)))||!z(e)&&D(t,g.numbers))&&(e=Number(e))}return e}function C(t,e){Object.keys(t).forEach((function(n){const s=t[n],i=e?e+"."+n:n;"object"==typeof s&&null!==s&&!Array.isArray(s)&&o["dot-notation"]?C(s,i):(!N(w,i.split("."))||D(i,g.arrays)&&o["combine-arrays"])&&j(i,s)}))}function P(t,e){if(void 0===l)return;const n="string"==typeof l?l:"",s=U.env();Object.keys(s).forEach((function(i){if(""===n||0===i.lastIndexOf(n,0)){const r=i.split("__").map((function(t,e){return 0===e&&(t=t.substring(n.length)),T(t)}));(e&&g.configs[r.join(".")]||!e)&&!N(t,r)&&j(r.join("."),s[i])}}))}function S(t,e,n,s=!1){Object.keys(n).forEach((function(i){N(t,i.split("."))||(M(t,i.split("."),n[i]),s&&(f[i]=!0),(e[i]||[]).forEach((function(e){N(t,e.split("."))||M(t,e.split("."),n[i])})))}))}function N(t,e){let n=t;o["dot-notation"]||(e=[e.join(".")]),e.slice(0,-1).forEach((function(t){n=n[t]||{}}));const s=e[e.length-1];return"object"==typeof n&&s in n}function M(t,e,n){let s=t;o["dot-notation"]||(e=[e.join(".")]),e.slice(0,-1).forEach((function(t){t=Y(t),"object"==typeof s&&void 0===s[t]&&(s[t]={}),"object"!=typeof s[t]||Array.isArray(s[t])?(Array.isArray(s[t])?s[t].push({}):s[t]=[s[t],{}],s=s[t][s[t].length-1]):s=s[t]}));const i=Y(e[e.length-1]),r=D(e.join("."),g.arrays),a=Array.isArray(n);let c=o["duplicate-arguments-array"];!c&&D(i,g.nargs)&&(c=!0,(!z(s[i])&&1===g.nargs[i]||Array.isArray(s[i])&&s[i].length===g.nargs[i])&&(s[i]=void 0)),n===H()?s[i]=H(s[i]):Array.isArray(s[i])?c&&r&&a?s[i]=o["flatten-duplicate-arrays"]?s[i].concat(n):(Array.isArray(s[i][0])?s[i]:[s[i]]).concat([n]):c||Boolean(r)!==Boolean(a)?s[i]=s[i].concat([n]):s[i]=n:void 0===s[i]&&r?s[i]=a?n:[n]:!c||void 0===s[i]||D(i,g.counts)||D(i,g.bools)?s[i]=n:s[i]=[s[i],n]}function D(t,e){const n=[].concat(g.aliases[t]||[],t),s=Object.keys(e),i=n.find((t=>s.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,n=!0;const s=t.slice(1).split("");for(let i=0;i<s.length;i++){if(e=t.slice(i+2),!I(s[i])){n=!1;break}if(s[i+1]&&"="===s[i+1]||"-"===e||/[A-Za-z]/.test(s[i])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(e)||s[i+1]&&s[i+1].match(/\W/))break}return n}(t))return!1;return!function(t,...e){return[].concat(...e).some((function(e){const n=t.match(e);return n&&I(n[1])}))}(t,/^-+([^=]+?)=[\s\S]*$/,y,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}(t)}function W(t){return D(t,g.bools)||D(t,g.counts)||!(`${t}`in a)?(e=function(t){let e=V.BOOLEAN;return D(t,g.strings)?e=V.STRING:D(t,g.numbers)?e=V.NUMBER:D(t,g.bools)?e=V.BOOLEAN:D(t,g.arrays)&&(e=V.ARRAY),e}(t),{[V.BOOLEAN]:!0,[V.STRING]:"",[V.NUMBER]:void 0,[V.ARRAY]:[]}[e]):a[t];var e}function z(t){return void 0===t}return P(w,!0),P(w,!1),function(t){const e=Object.create(null);S(e,g.aliases,a),Object.keys(g.configs).forEach((function(n){const s=t[n]||e[n];if(s)try{let t=null;const e=U.resolve(U.cwd(),s),i=g.configs[n];if("function"==typeof i){try{t=i(e)}catch(e){t=e}if(t instanceof Error)return void(b=t)}else t=U.require(e);C(t)}catch(e){"PermissionDenied"===e.name?b=e:t[n]&&(b=Error(p("Invalid JSON config file: %s",s)))}}))}(w),void 0!==c&&c.forEach((function(t){C(t)})),S(w,g.aliases,a,!0),function(t){let e;const n=new Set;Object.keys(t).forEach((function(s){if(!n.has(s)&&(e=D(s,g.coercions),"function"==typeof e))try{const i=x(s,e(t[s]));[].concat(g.aliases[s]||[],s).forEach((e=>{n.add(e),t[e]=i}))}catch(t){b=t}}))}(w),o["set-placeholder-key"]&&function(t){g.keys.forEach((e=>{~e.indexOf(".")||void 0===t[e]&&(t[e]=void 0)}))}(w),Object.keys(g.counts).forEach((function(t){N(w,t.split("."))||j(t,0)})),h&&v.length&&(w[d]=[]),v.forEach((function(t){w[d].push(t)})),o["camel-case-expansion"]&&o["strip-dashed"]&&Object.keys(w).filter((t=>"--"!==t&&t.includes("-"))).forEach((t=>{delete w[t]})),o["strip-aliased"]&&[].concat(...Object.keys(r).map((t=>r[t]))).forEach((t=>{o["camel-case-expansion"]&&t.includes("-")&&delete w[t.split(".").map((t=>T(t))).join(".")],delete w[t]})),{aliases:Object.assign({},g.aliases),argv:Object.assign(O,w),configuration:o,defaulted:Object.assign({},f),error:b,newAliases:Object.assign({},u)}}}({cwd:process.cwd,env:()=>X,format:p,normalize:s,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")}}),tt=function(t,e){return Z.parse(t.slice(),e).argv};function et(){return process.versions.electron&&!process.defaultApp?0:1}tt.detailed=function(t,e){return Z.parse(t.slice(),e)},tt.camelCase=T,tt.decamelize=L,tt.looksLikeNumber=B;class nt extends Error{constructor(t){super(t||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,nt)}}var st={fs:{readFileSync:u,writeFile:f},format:p,resolve:e,exists:t=>{try{return h(t).isFile()}catch(t){return!1}}};let it;class rt{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 n=function(){};return"function"==typeof t[t.length-1]&&(n=t.pop()),n=n||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:n})):n(),it.format.apply(it.format,[this.cache[this.locale][e]||e].concat(t))}__n(){const t=Array.prototype.slice.call(arguments),e=t.shift(),n=t.shift(),s=t.shift();let i=function(){};"function"==typeof t[t.length-1]&&(i=t.pop()),this.cache[this.locale]||this._readLocaleFile();let r=1===s?e:n;if(this.cache[this.locale][e]){r=this.cache[this.locale][e][1===s?"one":"other"]}!this.cache[this.locale][e]&&this.updateFiles?(this.cache[this.locale][e]={one:e,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:i})):i();const o=[r];return~r.indexOf("%d")&&o.push(s),it.format.apply(it.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 n="";return t.forEach((function(t,s){const i=e[s+1];n+=t,void 0!==i&&(n+="%s")})),this.__.apply(this,[n].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],n=e.directory,s=e.locale,i=e.cb,r=this._resolveLocaleFile(n,s),o=JSON.stringify(this.cache[s],null,2);it.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{it.fs.readFileSync&&(t=JSON.parse(it.fs.readFileSync(e,"utf-8")))}catch(n){if(n instanceof SyntaxError&&(n.message="syntax error in "+e),"ENOENT"!==n.code)throw n;t={}}this.cache[this.locale]=t}_resolveLocaleFile(t,e){let n=it.resolve(t,"./",e+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~e.lastIndexOf("_")){const s=it.resolve(t,"./",e.split("_")[0]+".json");this._fileExistsSync(s)&&(n=s)}return n}_fileExistsSync(t){return it.exists(t)}}const ot="loading a directory of commands is not supported yet for ESM";let at;try{at=m(import.meta.url)}catch(t){at=process.cwd()}var ct,lt={assert:{notStrictEqual:a,strictEqual:c},cliui:function(t){return function(t,e){return R=e,new D({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:z,wrap:F})},findUp:function(t,s){let i,r=e(".",t);for(h(r).isDirectory()||(r=n(r));;){if(i=s(r,d(r)),i)return e(r,i);if(r=n(i=r),i===r)break}},getEnv:t=>process.env[t],inspect:g,getCallerFile:()=>{throw new nt(ot)},getProcessArgvBin:function(){return process.argv[et()]},mainFilename:at.substring(0,at.lastIndexOf("node_modules"))||process.cwd(),Parser:tt,path:{basename:i,dirname:n,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 nt("require is not supported by ESM")},requireDirectory:()=>{throw new nt(ot)},stringWidth:t=>[...t].length,y18n:(ct={directory:e(at,"../../../locales"),updateFiles:!1},function(t,e){it=e;const n=new rt(t);return{__:n.__.bind(n),__n:n.__n.bind(n),setLocale:n.setLocale.bind(n),getLocale:n.getLocale.bind(n),updateLocale:n.updateLocale.bind(n),locale:n.locale}}(ct,st))};function ht(t,e,n,s){n.assert.notStrictEqual(t,e,s)}function dt(t,e){e.assert.strictEqual(typeof t,"string")}function ut(t){return Object.keys(t)}function ft(t){return!!t&&!!t.then&&"function"==typeof t.then}function pt(t){const e=t.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),n=/\.*[\][<>]/g,s=e.shift();if(!s)throw new Error(`No command found in: ${t}`);const i={cmd:s.replace(n,""),demanded:[],optional:[]};return e.forEach(((t,s)=>{let r=!1;t=t.replace(/\s/g,""),/\.+[\]>]/.test(t)&&s===e.length-1&&(r=!0),/^\[/.test(t)?i.optional.push({cmd:t.replace(n,"").split("|"),variadic:r}):i.demanded.push({cmd:t.replace(n,"").split("|"),variadic:r})})),i}const gt=["first","second","third","fourth","fifth","sixth"];function mt(t,e,n){try{let s=0;const[i,r,o]="object"==typeof t?[{demanded:[],optional:[]},t,e]:[pt(`cmd ${t}`),e,n],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 nt(`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 nt(`Too many arguments provided. Expected max ${l} but received ${c}.`);i.demanded.forEach((t=>{const e=yt(a.shift());0===t.cmd.filter((t=>t===e||"*"===t)).length&&bt(e,t.cmd,s),s+=1})),i.optional.forEach((t=>{if(0===a.length)return;const e=yt(a.shift());0===t.cmd.filter((t=>t===e||"*"===t)).length&&bt(e,t.cmd,s),s+=1}))}catch(t){console.warn(t.stack)}}function yt(t){return Array.isArray(t)?"array":null===t?"null":typeof t}function bt(t,e,n){throw new nt(`Invalid ${gt[n]||"manyith"} argument. Expected ${e.join(" or ")} but received ${t}.`)}class vt{constructor(t){this.globalMiddleware=[],this.frozens=[],this.yargs=t}addMiddleware(t,e,n=!0,s=!1){if(mt("<array|function> [boolean] [boolean] [boolean]",[t,e,n],arguments.length),Array.isArray(t)){for(let s=0;s<t.length;s++){if("function"!=typeof t[s])throw Error("middleware must be a function");const i=t[s];i.applyBeforeValidation=e,i.global=n}Array.prototype.push.apply(this.globalMiddleware,t)}else if("function"==typeof t){const i=t;i.applyBeforeValidation=e,i.global=n,i.mutates=s,this.globalMiddleware.push(t)}return this.yargs}addCoerceMiddleware(t,e){const n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((t=>{const s=[...n[e]||[],e];return!t.option||!s.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 wt(t,e,n,s){return n.reduce(((t,n)=>{if(n.applyBeforeValidation!==s)return t;if(n.mutates){if(n.applied)return t;n.applied=!0}if(ft(t))return t.then((t=>Promise.all([t,n(t,e)]))).then((([t,e])=>Object.assign(t,e)));{const s=n(t,e);return ft(s)?s.then((e=>Object.assign(t,e))):Object.assign(t,s)}}),t)}function Ot(t,e,n=(t=>{throw t})){try{const n="function"==typeof t?t():t;return ft(n)?n.then((t=>e(t))):e(n)}catch(t){return n(t)}}const Et=/(^\*)|(^\$0)/;class kt{constructor(t,e,n,s){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=s,this.usage=t,this.globalMiddleware=n,this.validation=e}addDirectory(t,e,n,s){"boolean"!=typeof(s=s||{}).recurse&&(s.recurse=!1),Array.isArray(s.extensions)||(s.extensions=["js"]);const i="function"==typeof s.visit?s.visit:t=>t;s.visit=(t,e,n)=>{const s=i(t,e,n);if(s){if(this.requireCache.has(e))return s;this.requireCache.add(e),this.addHandler(s)}return s},this.shim.requireDirectory({require:e,filename:n},t,s)}addHandler(t,e,n,s,i,r){let o=[];const a=function(t){return t?t.map((t=>(t.applyBeforeValidation=!1,t))):[]}(i);if(s=s||(()=>{}),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(At(n))return void this.addHandler([t].concat(o),e,n.builder,n.handler,n.middlewares,n.deprecated)}if("string"==typeof t){const i=pt(t);o=o.map((t=>pt(t).cmd));let c=!1;const l=[i.cmd].concat(o).filter((t=>!Et.test(t)||(c=!0,!1)));0===l.length&&c&&l.push("$0"),c&&(i.cmd=l[0],o=l.slice(1),t=t.replace(Et,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:s,builder:n||{},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,n,s,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,n.aliases,c,s,i,r);return ft(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,n,s,i,r,o,a){const c=e.builder;let l=n;if(jt(c)){n.getInternalMethods().getUsageInstance().freeze();const h=c(n.getInternalMethods().reset(s),a);if(ft(h))return h.then((s=>{var a;return l=(a=s)&&"function"==typeof a.getInternalMethods?s:n,this.parseAndUpdateUsage(t,e,l,i,r,o)}))}else(function(t){return"object"==typeof t})(c)&&(n.getInternalMethods().getUsageInstance().freeze(),l=n.getInternalMethods().reset(s),Object.keys(e.builder).forEach((t=>{l.option(t,c[t])})));return this.parseAndUpdateUsage(t,e,l,i,r,o)}parseAndUpdateUsage(t,e,n,s,i,r){t&&n.getInternalMethods().getUsageInstance().unfreeze(!0),this.shouldUpdateUsage(n)&&n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(s,e),e.description);const o=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,i,r);return ft(o)?o.then((t=>({aliases:n.parsed.aliases,innerArgv:t}))):{aliases:n.parsed.aliases,innerArgv:o}}shouldUpdateUsage(t){return!t.getInternalMethods().getUsageInstance().getUsageDisabled()&&0===t.getInternalMethods().getUsageInstance().getUsage().length}usageFromParentCommandsCommandHandler(t,e){const n=Et.test(e.original)?e.original.replace(Et,"").trim():e.original,s=t.filter((t=>!Et.test(t)));return s.push(n),`$0 ${s.join(" ")}`}handleValidationAndGetResult(t,e,n,s,i,r,o,a){if(!r.getInternalMethods().getHasOutput()){const e=r.getInternalMethods().runValidation(i,a,r.parsed.error,t);n=Ot(n,(t=>(e(t),t)))}if(e.handler&&!r.getInternalMethods().getHasOutput()){r.getInternalMethods().setHasOutput();const s=!!r.getOptions().configuration["populate--"];r.getInternalMethods().postProcess(n,s,!1,!1),n=Ot(n=wt(n,r,o,!1),(t=>{const n=e.handler(t);return ft(n)?n.then((()=>t)):t})),t||r.getInternalMethods().getUsageInstance().cacheHelpMessage(),ft(n)&&!r.getInternalMethods().hasParseCallback()&&n.catch((t=>{try{r.getInternalMethods().getUsageInstance().fail(null,t)}catch(t){}}))}return t||(s.commands.pop(),s.fullCommands.pop()),n}applyMiddlewareAndGetResult(t,e,n,s,i,r,o){let a={};if(i)return n;o.getInternalMethods().getHasOutput()||(a=this.populatePositionals(e,n,s,o));const c=this.globalMiddleware.getMiddleware().slice(0).concat(e.middlewares),l=wt(n,o,c,!0);return ft(l)?l.then((n=>this.handleValidationAndGetResult(t,e,n,s,r,o,c,a))):this.handleValidationAndGetResult(t,e,l,s,r,o,c,a)}populatePositionals(t,e,n,s){e._=e._.slice(n.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._=n.commands.concat(e._.map((t=>""+t))),this.postProcessPositionals(e,o,this.cmdToParseOptions(t.original),s),o}populatePositional(t,e,n){const s=t.cmd[0];t.variadic?n[s]=e._.splice(0).map(String):e._.length&&(n[s]=[String(e._.shift())])}cmdToParseOptions(t){const e={array:[],default:{},alias:{},demand:{}},n=pt(t);return n.demanded.forEach((t=>{const[n,...s]=t.cmd;t.variadic&&(e.array.push(n),e.default[n]=[]),e.alias[n]=s,e.demand[n]=!0})),n.optional.forEach((t=>{const[n,...s]=t.cmd;t.variadic&&(e.array.push(n),e.default[n]=[]),e.alias[n]=s})),e}postProcessPositionals(t,e,n,s){const i=Object.assign({},s.getOptions());i.default=Object.assign(n.default,i.default);for(const t of Object.keys(n.alias))i.alias[t]=(i.alias[t]||[]).concat(n.alias[t]);i.array=i.array.concat(n.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)s.getInternalMethods().getUsageInstance().fail(a.error.message,a.error);else{const n=Object.keys(e);Object.keys(e).forEach((t=>{n.push(...a.aliases[t])})),Object.keys(a.argv).forEach((i=>{n.includes(i)&&(e[i]||(e[i]=a.argv[i]),!this.isInConfigs(s,i)&&!this.isDefaulted(s,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:n}=t.getOptions();return Object.prototype.hasOwnProperty.call(n,e)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(e))}isInConfigs(t,e){const{configObjects:n}=t.getOptions();return n.some((t=>Object.prototype.hasOwnProperty.call(t,e)))||n.some((t=>Object.prototype.hasOwnProperty.call(t,this.shim.Parser.camelCase(e))))}runDefaultBuilderOn(t){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(t)){const e=Et.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(jt(e))return e(t,!0);At(e)||Object.keys(e).forEach((n=>{t.option(n,e[n])}))}moduleName(t){const e=function(t){if("undefined"==typeof require)return null;for(let e,n=0,s=Object.keys(require.cache);n<s.length;n++)if(e=require.cache[s[n]],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:n}){for(const s of[t,e,n]){if("string"==typeof s||!1===s)return s;ht(s,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){const t=this.frozens.pop();ht(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 At(t){return"object"==typeof t&&!!t.builder&&"function"==typeof t.handler}function jt(t){return"function"==typeof t}function $t(t={},e=(()=>!0)){const n={};return ut(t).forEach((s=>{e(s,t[s])&&(n[s]=t[s])})),n}function _t(t){"undefined"!=typeof process&&[process.stdout,process.stderr].forEach((e=>{const n=e;n._handle&&n.isTTY&&"function"==typeof n._handle.setBlocking&&n._handle.setBlocking(t)}))}function xt(t){return"boolean"==typeof t}function Ct(t,e){const n=e.y18n.__,s={},i=[];s.failFn=function(t){i.push(t)};let r=null,o=null,a=!0;s.showHelpOnFail=function(e=!0,n){const[i,c]="string"==typeof e?[!0,e]:[e,n];return t.getInternalMethods().isGlobalContext()&&(o=c),r=c,a=i,s};let c=!1;s.fail=function(e,n){const l=t.getInternalMethods().getLoggerInstance();if(!i.length){if(t.getExitProcess()&&_t(!0),!c){c=!0,a&&(t.showHelp("error"),l.error()),(e||n)&&l.error(e||n);const s=r||o;s&&((e||n)&&l.error(""),l.error(s))}if(n=n||new nt(e),t.getExitProcess())return t.exit(1);if(t.getInternalMethods().hasParseCallback())return t.exit(1,n);throw n}for(let t=i.length-1;t>=0;--t){const r=i[t];if(xt(r)){if(n)throw n;if(e)throw Error(e)}else r(e,n,s)}};let l=[],h=!1;s.usage=(t,e)=>null===t?(h=!0,l=[],s):(h=!1,l.push([t,e||""]),s),s.getUsage=()=>l,s.getUsageDisabled=()=>h,s.getPositionalGroupName=()=>n("Positionals:");let d=[];s.example=(t,e)=>{d.push([t,e||""])};let u=[];s.command=function(t,e,n,s,i=!1){n&&(u=u.map((t=>(t[2]=!1,t)))),u.push([t,e||"",n,s,i])},s.getCommands=()=>u;let f={};s.describe=function(t,e){Array.isArray(t)?t.forEach((t=>{s.describe(t,e)})):"object"==typeof t?Object.keys(t).forEach((e=>{s.describe(e,t[e])})):f[t]=e},s.getDescriptions=()=>f;let p=[];s.epilog=t=>{p.push(t)};let g,m=!1;s.wrap=t=>{m=!0,g=t},s.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,n,s){let i=0;return Array.isArray(t)||(t=Object.values(t).map((t=>[t]))),t.forEach((t=>{i=Math.max(e.stringWidth(s?`${s} ${Nt(t[0])}`:Nt(t[0]))+St(t[0]),i)})),n&&(i=Math.min(i,parseInt((.5*n).toString(),10))),i}let v;function w(e){return t.getOptions().hiddenOptions.indexOf(e)<0||t.parsed.argv[t.getOptions().showHiddenOpt]}function O(t,e){let s=`[${n("default:")} `;if(void 0===t&&!e)return null;if(e)s+=e;else switch(typeof t){case"string":s+=`"${t}"`;break;case"object":s+=JSON.stringify(t);break;default:s+=t}return`${s}]`}s.deferY18nLookup=t=>y+t,s.help=function(){if(v)return v;!function(){const e=t.getDemandedOptions(),n=t.getOptions();(Object.keys(n.alias)||[]).forEach((i=>{n.alias[i].forEach((r=>{f[r]&&s.describe(i,f[r]),r in e&&t.demandOption(i,e[r]),n.boolean.includes(r)&&t.boolean(i),n.count.includes(r)&&t.count(i),n.string.includes(r)&&t.string(i),n.normalize.includes(r)&&t.normalize(i),n.array.includes(r)&&t.array(i),n.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(w),m=Object.keys(m.reduce(((t,e)=>("_"!==e&&(t[e]=!0),t)),{}));const E=s.getWrap(),k=e.cliui({width:E,wrap:!!E});if(!h)if(l.length)l.forEach((t=>{k.div({text:`${t[0].replace(/\$0/g,i)}`}),t[1]&&k.div({text:`${t[1]}`,padding:[1,0,0,0]})})),k.div();else if(u.length){let t=null;t=o._?`${i} <${n("command")}>\n`:`${i} [${n("command")}]\n`,k.div(`${t}`)}if(u.length>1||1===u.length&&!u[0][2]){k.div(n("Commands:"));const e=t.getInternalMethods().getContext(),s=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}${s}${t[0].replace(/^\$0 ?/,"")}`;k.span({text:e,padding:[0,2,0,2],width:b(u,E,`${i}${s}`)+4},{text:t[1]});const o=[];t[2]&&o.push(`[${n("default")}]`),t[3]&&t[3].length&&o.push(`[${n("aliases:")} ${t[3].join(", ")}]`),t[4]&&("string"==typeof t[4]?o.push(`[${n("deprecated: %s",t[4])}]`):o.push(`[${n("deprecated")}]`)),o.length?k.div({text:o.join(" "),padding:[0,0,0,2],align:"right"}):k.div()})),k.div()}const A=(Object.keys(g.alias)||[]).concat(Object.keys(t.parsed.newAliases)||[]);m=m.filter((e=>!t.parsed.newAliases[e]&&A.every((t=>-1===(g.alias[t]||[]).indexOf(e)))));const j=n("Options:");c[j]||(c[j]=[]),function(t,e,n,s){let i=[],r=null;Object.keys(n).forEach((t=>{i=i.concat(n[t])})),t.forEach((t=>{r=[t].concat(e[t]),r.some((t=>-1!==i.indexOf(t)))||n[s].push(t)}))}(m,g.alias,c,j);const $=t=>/^--/.test(Nt(t)),_=Object.keys(c).filter((t=>c[t].length>0)).map((t=>({groupName:t,normalizedKeys:c[t].filter(w).map((t=>{if(A.includes(t))return t;for(let e,n=0;void 0!==(e=A[n]);n++)if((g.alias[e]||[]).includes(t))return e;return t}))}))).filter((({normalizedKeys:t})=>t.length>0)).map((({groupName:t,normalizedKeys:e})=>{const n=e.reduce(((e,n)=>(e[n]=[n].concat(g.alias[n]||[]).map((e=>t===s.getPositionalGroupName()?e:(/^[0-9]$/.test(e)?g.boolean.includes(n)?"-":"--":e.length>1?"--":"-")+e)).sort(((t,e)=>$(t)===$(e)?0:$(t)?1:-1)).join(", "),e)),{});return{groupName:t,normalizedKeys:e,switches:n}}));if(_.filter((({groupName:t})=>t!==s.getPositionalGroupName())).some((({normalizedKeys:t,switches:e})=>!t.every((t=>$(e[t])))))&&_.filter((({groupName:t})=>t!==s.getPositionalGroupName())).forEach((({normalizedKeys:t,switches:e})=>{t.forEach((t=>{var n,s;$(e[t])&&(e[t]=(n=e[t],s=4,Pt(n)?{text:n.text,indentation:n.indentation+s}:{text:n,indentation:s}))}))})),_.forEach((({groupName:e,normalizedKeys:i,switches:o})=>{k.div(e),i.forEach((e=>{const i=o[e];let c=f[e]||"",l=null;c.includes(y)&&(c=n(c.substring(16))),g.boolean.includes(e)&&(l=`[${n("boolean")}]`),g.count.includes(e)&&(l=`[${n("count")}]`),g.string.includes(e)&&(l=`[${n("string")}]`),g.normalize.includes(e)&&(l=`[${n("string")}]`),g.array.includes(e)&&(l=`[${n("array")}]`),g.number.includes(e)&&(l=`[${n("number")}]`);const h=[e in a?(d=a[e],"string"==typeof d?`[${n("deprecated: %s",d)}]`:`[${n("deprecated")}]`):null,l,e in r?`[${n("required")}]`:null,g.choices&&g.choices[e]?`[${n("choices:")} ${s.stringifiedValues(g.choices[e])}]`:null,O(g.default[e],g.defaultDescription[e])].filter(Boolean).join(" ");var d;k.span({text:Nt(i),padding:[0,2,0,2+St(i)],width:b(o,E)+4},c);const u=!0===t.getInternalMethods().getUsageConfiguration()["hide-types"];h&&!u?k.div({text:h,padding:[0,0,0,2],align:"right"}):k.div()})),k.div()})),d.length&&(k.div(n("Examples:")),d.forEach((t=>{t[0]=t[0].replace(/\$0/g,i)})),d.forEach((t=>{""===t[1]?k.div({text:t[0],padding:[0,2,0,2]}):k.div({text:t[0],padding:[0,2,0,2],width:b(d,E)+4},{text:t[1]})})),k.div()),p.length>0){const t=p.map((t=>t.replace(/\$0/g,i))).join("\n");k.div(`${t}\n`)}return k.toString().replace(/\s*$/,"")},s.cacheHelpMessage=function(){v=this.help()},s.clearCachedHelpMessage=function(){v=void 0},s.hasCachedHelpMessage=function(){return!!v},s.showHelp=e=>{const n=t.getInternalMethods().getLoggerInstance();e||(e="error");("function"==typeof e?e:n[e])(s.help())},s.functionDescription=t=>["(",t.name?e.Parser.decamelize(t.name,"-"):n("generated-value"),")"].join(""),s.stringifiedValues=function(t,e){let n="";const s=e||", ",i=[].concat(t);return t&&i.length?(i.forEach((t=>{n.length&&(n+=s),n+=JSON.stringify(t)})),n):n};let E=null;s.version=t=>{E=t},s.showVersion=e=>{const n=t.getInternalMethods().getLoggerInstance();e||(e="error");("function"==typeof e?e:n[e])(E)},s.reset=function(t){return r=null,c=!1,l=[],h=!1,p=[],d=[],u=[],f=$t(f,(e=>!t[e])),s};const k=[];return s.freeze=function(){k.push({failMessage:r,failureOutput:c,usages:l,usageDisabled:h,epilogs:p,examples:d,commands:u,descriptions:f})},s.unfreeze=function(t=!1){const e=k.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))},s}function Pt(t){return"object"==typeof t}function St(t){return Pt(t)?t.indentation:0}function Nt(t){return Pt(t)?t.text:t}class Mt{constructor(t,e,n,s){var i,r,o;this.yargs=t,this.usage=e,this.command=n,this.shim=s,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,n,s){const i=this.command.getCommandHandlers();for(let e=0,n=t.length;e<n;++e)if(i[t[e]]&&i[t[e]].builder){const n=i[t[e]].builder;if(jt(n)){this.indexAfterLastReset=e+1;const t=this.yargs.getInternalMethods().reset();return n(t,!0),t.argv}}const r=[];this.commandCompletions(r,t,n),this.optionCompletions(r,t,e,n),this.choicesFromOptionsCompletions(r,t,e,n),this.choicesFromPositionalsCompletions(r,t,e,n),s(null,r)}commandCompletions(t,e,n){const s=this.yargs.getInternalMethods().getContext().commands;n.match(/^-/)||s[s.length-1]===n||this.previousArgHasChoices(e)||this.usage.getCommands().forEach((n=>{const s=pt(n[0]).cmd;if(-1===e.indexOf(s))if(this.zshShell){const e=n[1]||"";t.push(s.replace(/:/g,"\\:")+":"+e)}else t.push(s)}))}optionCompletions(t,e,n,s){if((s.match(/^-/)||""===s&&0===t.length)&&!this.previousArgHasChoices(e)){const n=this.yargs.getOptions(),i=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(n.key).forEach((r=>{const o=!!n.configuration["boolean-negation"]&&n.boolean.includes(r);i.includes(r)||n.hiddenOptions.includes(r)||this.argsContainKey(e,r,o)||this.completeOptionKey(r,t,s,o&&!!n.default[r])}))}}choicesFromOptionsCompletions(t,e,n,s){if(this.previousArgHasChoices(e)){const n=this.getPreviousArgChoices(e);n&&n.length>0&&t.push(...n.map((t=>t.replace(/:/g,"\\:"))))}}choicesFromPositionalsCompletions(t,e,n,s){if(""===s&&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[n._.length-r-1];if(!o)return;const a=this.yargs.getOptions().choices[o]||[];for(const e of a)e.startsWith(s)&&t.push(e.replace(/:/g,"\\:"))}getPreviousArgChoices(t){if(t.length<1)return;let e=t[t.length-1],n="";if(!e.startsWith("-")&&t.length>1&&(n=e,e=t[t.length-2]),!e.startsWith("-"))return;const s=e.replace(/^-+/,""),i=this.yargs.getOptions(),r=[s,...this.yargs.getAliases()[s]||[]];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=>!n||t.startsWith(n))):void 0}previousArgHasChoices(t){const e=this.getPreviousArgChoices(t);return void 0!==e&&e.length>0}argsContainKey(t,e,n){const s=e=>-1!==t.indexOf((/^[^0-9]$/.test(e)?"-":"--")+e);if(s(e))return!0;if(n&&s(`no-${e}`))return!0;if(this.aliases)for(const t of this.aliases[e])if(s(t))return!0;return!1}completeOptionKey(t,e,n,s){var i,r,o,a;let c=t;if(this.zshShell){const e=this.usage.getDescriptions(),n=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 n=e[t];return"string"==typeof n&&n.length>0})),s=n?e[n]:void 0,l=null!==(a=null!==(o=e[t])&&void 0!==o?o:s)&&void 0!==a?a:"";c=`${t.replace(/:/g,"\\:")}:${l.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}const l=!/^--/.test(n)&&(t=>/^[^0-9]$/.test(t))(t)?"-":"--";e.push(l+c),s&&e.push(l+"no-"+c)}customCompletion(t,e,n,s){if(ht(this.customCompletionFunction,null,this.shim),this.customCompletionFunction.length<3){const t=this.customCompletionFunction(n,e);return ft(t)?t.then((t=>{this.shim.process.nextTick((()=>{s(null,t)}))})).catch((t=>{this.shim.process.nextTick((()=>{s(t,void 0)}))})):s(null,t)}return function(t){return t.length>3}(this.customCompletionFunction)?this.customCompletionFunction(n,e,((i=s)=>this.defaultCompletion(t,e,n,i)),(t=>{s(null,t)})):this.customCompletionFunction(n,e,(t=>{s(null,t)}))}getCompletion(t,e){const n=t.length?t[t.length-1]:"",s=this.yargs.parse(t,!0),i=this.customCompletionFunction?s=>this.customCompletion(t,s,n,e):s=>this.defaultCompletion(t,s,n,e);return ft(s)?s.then(i):i(s)}generateCompletionScript(t,e){let n=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 s=this.shim.path.basename(t);return t.match(/\.js$/)&&(t=`./${t}`),n=n.replace(/{{app_name}}/g,s),n=n.replace(/{{completion_command}}/g,e),n.replace(/{{app_path}}/g,t)}registerFunction(t){this.customCompletionFunction=t}setParsed(t){this.aliases=t.aliases}}function Dt(t,e){if(0===t.length)return e.length;if(0===e.length)return t.length;const n=[];let s,i;for(s=0;s<=e.length;s++)n[s]=[s];for(i=0;i<=t.length;i++)n[0][i]=i;for(s=1;s<=e.length;s++)for(i=1;i<=t.length;i++)e.charAt(s-1)===t.charAt(i-1)?n[s][i]=n[s-1][i-1]:s>1&&i>1&&e.charAt(s-2)===t.charAt(i-1)&&e.charAt(s-1)===t.charAt(i-2)?n[s][i]=n[s-2][i-2]+1:n[s][i]=Math.min(n[s-1][i-1]+1,Math.min(n[s][i-1]+1,n[s-1][i]+1));return n[e.length][t.length]}const It=["$0","--","_"];let Rt,Wt=[];function zt(t,e,n,s){Rt=s;let i={};if(Object.prototype.hasOwnProperty.call(t,"extends")){if("string"!=typeof t.extends)return i;const s=/\.json|\..*rc$/.test(t.extends);let r=null;if(s)r=function(t,e){return Rt.path.resolve(t,e)}(e,t.extends);else try{r=require.resolve(t.extends)}catch(e){return t}!function(t){if(Wt.indexOf(t)>-1)throw new nt(`Circular extended configurations: '${t}'.`)}(r),Wt.push(r),i=s?JSON.parse(Rt.readFileSync(r,"utf8")):require(t.extends),delete t.extends,i=zt(i,Rt.path.dirname(r),n,Rt)}return Wt=[],n?Ft(i,t):Object.assign({},i,t)}function Ft(t,e){const n={};function s(t){return t&&"object"==typeof t&&!Array.isArray(t)}Object.assign(n,t);for(const i of Object.keys(e))s(e[i])&&s(n[i])?n[i]=Ft(t[i],e[i]):n[i]=e[i];return n}var Tt,Lt,Bt,Vt,Ut,Ht,Yt,qt,Jt,Gt,Kt,Qt,Xt,Zt,te,ee,ne,se,ie,re,oe,ae,ce,le,he,de,ue,fe,pe,ge,me,ye,be,ve,we,Oe=function(t,e,n,s,i){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!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"===s?i.call(t,n):i?i.value=n:e.set(t,n),n},Ee=function(t,e,n,s){if("a"===n&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(t):s?s.value:e.get(t)};const ke=Symbol("copyDoubleDash"),Ae=Symbol("copyDoubleDash"),je=Symbol("deleteFromParserHintObject"),$e=Symbol("emitWarning"),_e=Symbol("freeze"),xe=Symbol("getDollarZero"),Ce=Symbol("getParserConfiguration"),Pe=Symbol("getUsageConfiguration"),Se=Symbol("guessLocale"),Ne=Symbol("guessVersion"),Me=Symbol("parsePositionalNumbers"),De=Symbol("pkgUp"),Ie=Symbol("populateParserHintArray"),Re=Symbol("populateParserHintSingleValueDictionary"),We=Symbol("populateParserHintArrayDictionary"),ze=Symbol("populateParserHintDictionary"),Fe=Symbol("sanitizeKey"),Te=Symbol("setKey"),Le=Symbol("unfreeze"),Be=Symbol("validateAsync"),Ve=Symbol("getCommandInstance"),Ue=Symbol("getContext"),He=Symbol("getHasOutput"),Ye=Symbol("getLoggerInstance"),qe=Symbol("getParseContext"),Je=Symbol("getUsageInstance"),Ge=Symbol("getValidationInstance"),Ke=Symbol("hasParseCallback"),Qe=Symbol("isGlobalContext"),Xe=Symbol("postProcess"),Ze=Symbol("rebase"),tn=Symbol("reset"),en=Symbol("runYargsParserAndExecuteCommands"),nn=Symbol("runValidation"),sn=Symbol("setHasOutput"),rn=Symbol("kTrackManuallySetKeys");class on{constructor(t=[],e,n,s){this.customScriptName=!1,this.parsed=!1,Tt.set(this,void 0),Lt.set(this,void 0),Bt.set(this,{commands:[],fullCommands:[]}),Vt.set(this,null),Ut.set(this,null),Ht.set(this,"show-hidden"),Yt.set(this,null),qt.set(this,!0),Jt.set(this,{}),Gt.set(this,!0),Kt.set(this,[]),Qt.set(this,void 0),Xt.set(this,{}),Zt.set(this,!1),te.set(this,null),ee.set(this,!0),ne.set(this,void 0),se.set(this,""),ie.set(this,void 0),re.set(this,void 0),oe.set(this,{}),ae.set(this,null),ce.set(this,null),le.set(this,{}),he.set(this,{}),de.set(this,void 0),ue.set(this,!1),fe.set(this,void 0),pe.set(this,!1),ge.set(this,!1),me.set(this,!1),ye.set(this,void 0),be.set(this,{}),ve.set(this,null),we.set(this,void 0),Oe(this,fe,s,"f"),Oe(this,de,t,"f"),Oe(this,Lt,e,"f"),Oe(this,re,n,"f"),Oe(this,Qt,new vt(this),"f"),this.$0=this[xe](),this[tn](),Oe(this,Tt,Ee(this,Tt,"f"),"f"),Oe(this,ye,Ee(this,ye,"f"),"f"),Oe(this,we,Ee(this,we,"f"),"f"),Oe(this,ie,Ee(this,ie,"f"),"f"),Ee(this,ie,"f").showHiddenOpt=Ee(this,Ht,"f"),Oe(this,ne,this[Ae](),"f")}addHelpOpt(t,e){return mt("[string|boolean] [string]",[t,e],arguments.length),Ee(this,te,"f")&&(this[je](Ee(this,te,"f")),Oe(this,te,null,"f")),!1===t&&void 0===e||(Oe(this,te,"string"==typeof t?t:"help","f"),this.boolean(Ee(this,te,"f")),this.describe(Ee(this,te,"f"),e||Ee(this,ye,"f").deferY18nLookup("Show help"))),this}help(t,e){return this.addHelpOpt(t,e)}addShowHiddenOpt(t,e){if(mt("[string|boolean] [string]",[t,e],arguments.length),!1===t&&void 0===e)return this;const n="string"==typeof t?t:Ee(this,Ht,"f");return this.boolean(n),this.describe(n,e||Ee(this,ye,"f").deferY18nLookup("Show hidden options")),Ee(this,ie,"f").showHiddenOpt=n,this}showHidden(t,e){return this.addShowHiddenOpt(t,e)}alias(t,e){return mt("<object|string|array> [string|array]",[t,e],arguments.length),this[We](this.alias.bind(this),"alias",t,e),this}array(t){return mt("<array|string>",[t],arguments.length),this[Ie]("array",t),this[rn](t),this}boolean(t){return mt("<array|string>",[t],arguments.length),this[Ie]("boolean",t),this[rn](t),this}check(t,e){return mt("<function> [boolean]",[t,e],arguments.length),this.middleware(((e,n)=>Ot((()=>t(e,n.getOptions())),(n=>(n?("string"==typeof n||n instanceof Error)&&Ee(this,ye,"f").fail(n.toString(),n):Ee(this,ye,"f").fail(Ee(this,fe,"f").y18n.__("Argument check failed: %s",t.toString())),e)),(t=>(Ee(this,ye,"f").fail(t.message?t.message:t.toString(),t),e)))),!1,e),this}choices(t,e){return mt("<object|string|array> [string|array]",[t,e],arguments.length),this[We](this.choices.bind(this),"choices",t,e),this}coerce(t,e){if(mt("<object|string|array> [function]",[t,e],arguments.length),Array.isArray(t)){if(!e)throw new nt("coerce callback must be provided");for(const n of t)this.coerce(n,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 nt("coerce callback must be provided");return Ee(this,ie,"f").key[t]=!0,Ee(this,Qt,"f").addCoerceMiddleware(((n,s)=>{let i;return Object.prototype.hasOwnProperty.call(n,t)?Ot((()=>(i=s.getAliases(),e(n[t]))),(e=>{n[t]=e;const r=s.getInternalMethods().getParserConfiguration()["strip-aliased"];if(i[t]&&!0!==r)for(const s of i[t])n[s]=e;return n}),(t=>{throw new nt(t.message)})):n}),t),this}conflicts(t,e){return mt("<string|object> [string|array]",[t,e],arguments.length),Ee(this,we,"f").conflicts(t,e),this}config(t="config",e,n){return mt("[object|string] [string|function] [function]",[t,e,n],arguments.length),"object"!=typeof t||Array.isArray(t)?("function"==typeof e&&(n=e,e=void 0),this.describe(t,e||Ee(this,ye,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(t)?t:[t]).forEach((t=>{Ee(this,ie,"f").config[t]=n||!0})),this):(t=zt(t,Ee(this,Lt,"f"),this[Ce]()["deep-merge-config"]||!1,Ee(this,fe,"f")),Ee(this,ie,"f").configObjects=(Ee(this,ie,"f").configObjects||[]).concat(t),this)}completion(t,e,n){return mt("[string] [string|boolean|function] [function]",[t,e,n],arguments.length),"function"==typeof e&&(n=e,e=void 0),Oe(this,Ut,t||Ee(this,Ut,"f")||"completion","f"),e||!1===e||(e="generate completion script"),this.command(Ee(this,Ut,"f"),e),n&&Ee(this,Vt,"f").registerFunction(n),this}command(t,e,n,s,i,r){return mt("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[t,e,n,s,i,r],arguments.length),Ee(this,Tt,"f").addHandler(t,e,n,s,i,r),this}commands(t,e,n,s,i,r){return this.command(t,e,n,s,i,r)}commandDir(t,e){mt("<string> [object]",[t,e],arguments.length);const n=Ee(this,re,"f")||Ee(this,fe,"f").require;return Ee(this,Tt,"f").addDirectory(t,n,Ee(this,fe,"f").getCallerFile(),e),this}count(t){return mt("<array|string>",[t],arguments.length),this[Ie]("count",t),this[rn](t),this}default(t,e,n){return mt("<object|string|array> [*] [string]",[t,e,n],arguments.length),n&&(dt(t,Ee(this,fe,"f")),Ee(this,ie,"f").defaultDescription[t]=n),"function"==typeof e&&(dt(t,Ee(this,fe,"f")),Ee(this,ie,"f").defaultDescription[t]||(Ee(this,ie,"f").defaultDescription[t]=Ee(this,ye,"f").functionDescription(e)),e=e.call()),this[Re](this.default.bind(this),"default",t,e),this}defaults(t,e,n){return this.default(t,e,n)}demandCommand(t=1,e,n,s){return mt("[number] [number|string] [string|null|undefined] [string|null|undefined]",[t,e,n,s],arguments.length),"number"!=typeof e&&(n=e,e=1/0),this.global("_",!1),Ee(this,ie,"f").demandedCommands._={min:t,max:e,minMsg:n,maxMsg:s},this}demand(t,e,n){return Array.isArray(e)?(e.forEach((t=>{ht(n,!0,Ee(this,fe,"f")),this.demandOption(t,n)})),e=1/0):"number"!=typeof e&&(n=e,e=1/0),"number"==typeof t?(ht(n,!0,Ee(this,fe,"f")),this.demandCommand(t,e,n,n)):Array.isArray(t)?t.forEach((t=>{ht(n,!0,Ee(this,fe,"f")),this.demandOption(t,n)})):"string"==typeof n?this.demandOption(t,n):!0!==n&&void 0!==n||this.demandOption(t),this}demandOption(t,e){return mt("<object|string|array> [string]",[t,e],arguments.length),this[Re](this.demandOption.bind(this),"demandedOptions",t,e),this}deprecateOption(t,e){return mt("<string> [string|boolean]",[t,e],arguments.length),Ee(this,ie,"f").deprecatedOptions[t]=e,this}describe(t,e){return mt("<object|string|array> [string]",[t,e],arguments.length),this[Te](t,!0),Ee(this,ye,"f").describe(t,e),this}detectLocale(t){return mt("<boolean>",[t],arguments.length),Oe(this,qt,t,"f"),this}env(t){return mt("[string|boolean]",[t],arguments.length),!1===t?delete Ee(this,ie,"f").envPrefix:Ee(this,ie,"f").envPrefix=t||"",this}epilogue(t){return mt("<string>",[t],arguments.length),Ee(this,ye,"f").epilog(t),this}epilog(t){return this.epilogue(t)}example(t,e){return mt("<string|array> [string]",[t,e],arguments.length),Array.isArray(t)?t.forEach((t=>this.example(...t))):Ee(this,ye,"f").example(t,e),this}exit(t,e){Oe(this,Zt,!0,"f"),Oe(this,Yt,e,"f"),Ee(this,Gt,"f")&&Ee(this,fe,"f").process.exit(t)}exitProcess(t=!0){return mt("[boolean]",[t],arguments.length),Oe(this,Gt,t,"f"),this}fail(t){if(mt("<function|boolean>",[t],arguments.length),"boolean"==typeof t&&!1!==t)throw new nt("Invalid first argument. Expected function or boolean 'false'");return Ee(this,ye,"f").failFn(t),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(t,e){return mt("<array> [function]",[t,e],arguments.length),e?Ee(this,Vt,"f").getCompletion(t,e):new Promise(((e,n)=>{Ee(this,Vt,"f").getCompletion(t,((t,s)=>{t?n(t):e(s)}))}))}getDemandedOptions(){return mt([],0),Ee(this,ie,"f").demandedOptions}getDemandedCommands(){return mt([],0),Ee(this,ie,"f").demandedCommands}getDeprecatedOptions(){return mt([],0),Ee(this,ie,"f").deprecatedOptions}getDetectLocale(){return Ee(this,qt,"f")}getExitProcess(){return Ee(this,Gt,"f")}getGroups(){return Object.assign({},Ee(this,Xt,"f"),Ee(this,he,"f"))}getHelp(){if(Oe(this,Zt,!0,"f"),!Ee(this,ye,"f").hasCachedHelpMessage()){if(!this.parsed){const t=this[en](Ee(this,de,"f"),void 0,void 0,0,!0);if(ft(t))return t.then((()=>Ee(this,ye,"f").help()))}const t=Ee(this,Tt,"f").runDefaultBuilderOn(this);if(ft(t))return t.then((()=>Ee(this,ye,"f").help()))}return Promise.resolve(Ee(this,ye,"f").help())}getOptions(){return Ee(this,ie,"f")}getStrict(){return Ee(this,pe,"f")}getStrictCommands(){return Ee(this,ge,"f")}getStrictOptions(){return Ee(this,me,"f")}global(t,e){return mt("<string|array> [boolean]",[t,e],arguments.length),t=[].concat(t),!1!==e?Ee(this,ie,"f").local=Ee(this,ie,"f").local.filter((e=>-1===t.indexOf(e))):t.forEach((t=>{Ee(this,ie,"f").local.includes(t)||Ee(this,ie,"f").local.push(t)})),this}group(t,e){mt("<string|array> <string>",[t,e],arguments.length);const n=Ee(this,he,"f")[e]||Ee(this,Xt,"f")[e];Ee(this,he,"f")[e]&&delete Ee(this,he,"f")[e];const s={};return Ee(this,Xt,"f")[e]=(n||[]).concat(t).filter((t=>!s[t]&&(s[t]=!0))),this}hide(t){return mt("<string>",[t],arguments.length),Ee(this,ie,"f").hiddenOptions.push(t),this}implies(t,e){return mt("<string|object> [number|string|array]",[t,e],arguments.length),Ee(this,we,"f").implies(t,e),this}locale(t){return mt("[string]",[t],arguments.length),void 0===t?(this[Se](),Ee(this,fe,"f").y18n.getLocale()):(Oe(this,qt,!1,"f"),Ee(this,fe,"f").y18n.setLocale(t),this)}middleware(t,e,n){return Ee(this,Qt,"f").addMiddleware(t,!!e,n)}nargs(t,e){return mt("<string|object|array> [number]",[t,e],arguments.length),this[Re](this.nargs.bind(this),"narg",t,e),this}normalize(t){return mt("<array|string>",[t],arguments.length),this[Ie]("normalize",t),this}number(t){return mt("<array|string>",[t],arguments.length),this[Ie]("number",t),this[rn](t),this}option(t,e){if(mt("<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[rn](t),!Ee(this,ve,"f")||"version"!==t&&"version"!==(null==e?void 0:e.alias)||this[$e](['"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"),Ee(this,ie,"f").key[t]=!0,e.alias&&this.alias(t,e.alias);const n=e.deprecate||e.deprecated;n&&this.deprecateOption(t,n);const s=e.demand||e.required||e.require;s&&this.demand(t,s),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&&(Ee(this,ie,"f").defaultDescription[t]=e.defaultDescription),e.skipValidation&&this.skipValidation(t);const i=e.describe||e.description||e.desc,r=Ee(this,ye,"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,n){mt("[string|array] [function|boolean|object] [function]",[t,e,n],arguments.length),this[_e](),void 0===t&&(t=Ee(this,de,"f")),"object"==typeof e&&(Oe(this,ce,e,"f"),e=n),"function"==typeof e&&(Oe(this,ae,e,"f"),e=!1),e||Oe(this,de,t,"f"),Ee(this,ae,"f")&&Oe(this,Gt,!1,"f");const s=this[en](t,!!e),i=this.parsed;return Ee(this,Vt,"f").setParsed(this.parsed),ft(s)?s.then((t=>(Ee(this,ae,"f")&&Ee(this,ae,"f").call(this,Ee(this,Yt,"f"),t,Ee(this,se,"f")),t))).catch((t=>{throw Ee(this,ae,"f")&&Ee(this,ae,"f")(t,this.parsed.argv,Ee(this,se,"f")),t})).finally((()=>{this[Le](),this.parsed=i})):(Ee(this,ae,"f")&&Ee(this,ae,"f").call(this,Ee(this,Yt,"f"),s,Ee(this,se,"f")),this[Le](),this.parsed=i,s)}parseAsync(t,e,n){const s=this.parse(t,e,n);return ft(s)?s:Promise.resolve(s)}parseSync(t,e,n){const s=this.parse(t,e,n);if(ft(s))throw new nt(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return s}parserConfiguration(t){return mt("<object>",[t],arguments.length),Oe(this,oe,t,"f"),this}pkgConf(t,e){mt("<string> [string]",[t,e],arguments.length);let n=null;const s=this[De](e||Ee(this,Lt,"f"));return s[t]&&"object"==typeof s[t]&&(n=zt(s[t],e||Ee(this,Lt,"f"),this[Ce]()["deep-merge-config"]||!1,Ee(this,fe,"f")),Ee(this,ie,"f").configObjects=(Ee(this,ie,"f").configObjects||[]).concat(n)),this}positional(t,e){mt("<string> <object>",[t,e],arguments.length);const n=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];e=$t(e,((t,e)=>!("type"===t&&!["string","number","boolean"].includes(e))&&n.includes(t)));const s=Ee(this,Bt,"f").fullCommands[Ee(this,Bt,"f").fullCommands.length-1],i=s?Ee(this,Tt,"f").cmdToParseOptions(s):{array:[],alias:{},default:{},demand:{}};return ut(i).forEach((n=>{const s=i[n];Array.isArray(s)?-1!==s.indexOf(t)&&(e[n]=!0):s[t]&&!(n in e)&&(e[n]=s[t])})),this.group(t,Ee(this,ye,"f").getPositionalGroupName()),this.option(t,e)}recommendCommands(t=!0){return mt("[boolean]",[t],arguments.length),Oe(this,ue,t,"f"),this}required(t,e,n){return this.demand(t,e,n)}require(t,e,n){return this.demand(t,e,n)}requiresArg(t){return mt("<array|string|object> [number]",[t],arguments.length),"string"==typeof t&&Ee(this,ie,"f").narg[t]||this[Re](this.requiresArg.bind(this),"narg",t,NaN),this}showCompletionScript(t,e){return mt("[string] [string]",[t,e],arguments.length),t=t||this.$0,Ee(this,ne,"f").log(Ee(this,Vt,"f").generateCompletionScript(t,e||Ee(this,Ut,"f")||"completion")),this}showHelp(t){if(mt("[string|function]",[t],arguments.length),Oe(this,Zt,!0,"f"),!Ee(this,ye,"f").hasCachedHelpMessage()){if(!this.parsed){const e=this[en](Ee(this,de,"f"),void 0,void 0,0,!0);if(ft(e))return e.then((()=>{Ee(this,ye,"f").showHelp(t)})),this}const e=Ee(this,Tt,"f").runDefaultBuilderOn(this);if(ft(e))return e.then((()=>{Ee(this,ye,"f").showHelp(t)})),this}return Ee(this,ye,"f").showHelp(t),this}scriptName(t){return this.customScriptName=!0,this.$0=t,this}showHelpOnFail(t,e){return mt("[boolean|string] [string]",[t,e],arguments.length),Ee(this,ye,"f").showHelpOnFail(t,e),this}showVersion(t){return mt("[string|function]",[t],arguments.length),Ee(this,ye,"f").showVersion(t),this}skipValidation(t){return mt("<array|string>",[t],arguments.length),this[Ie]("skipValidation",t),this}strict(t){return mt("[boolean]",[t],arguments.length),Oe(this,pe,!1!==t,"f"),this}strictCommands(t){return mt("[boolean]",[t],arguments.length),Oe(this,ge,!1!==t,"f"),this}strictOptions(t){return mt("[boolean]",[t],arguments.length),Oe(this,me,!1!==t,"f"),this}string(t){return mt("<array|string>",[t],arguments.length),this[Ie]("string",t),this[rn](t),this}terminalWidth(){return mt([],0),Ee(this,fe,"f").process.stdColumns}updateLocale(t){return this.updateStrings(t)}updateStrings(t){return mt("<object>",[t],arguments.length),Oe(this,qt,!1,"f"),Ee(this,fe,"f").y18n.updateLocale(t),this}usage(t,e,n,s){if(mt("<string|null|undefined> [string|boolean] [function|object] [function]",[t,e,n,s],arguments.length),void 0!==e){if(ht(t,null,Ee(this,fe,"f")),(t||"").match(/^\$0( |$)/))return this.command(t,e,n,s);throw new nt(".usage() description must start with $0 if being used as alias for .command()")}return Ee(this,ye,"f").usage(t),this}usageConfiguration(t){return mt("<object>",[t],arguments.length),Oe(this,be,t,"f"),this}version(t,e,n){const s="version";if(mt("[boolean|string] [string] [string]",[t,e,n],arguments.length),Ee(this,ve,"f")&&(this[je](Ee(this,ve,"f")),Ee(this,ye,"f").version(void 0),Oe(this,ve,null,"f")),0===arguments.length)n=this[Ne](),t=s;else if(1===arguments.length){if(!1===t)return this;n=t,t=s}else 2===arguments.length&&(n=e,e=void 0);return Oe(this,ve,"string"==typeof t?t:s,"f"),e=e||Ee(this,ye,"f").deferY18nLookup("Show version number"),Ee(this,ye,"f").version(n||void 0),this.boolean(Ee(this,ve,"f")),this.describe(Ee(this,ve,"f"),e),this}wrap(t){return mt("<number|null|undefined>",[t],arguments.length),Ee(this,ye,"f").wrap(t),this}[(Tt=new WeakMap,Lt=new WeakMap,Bt=new WeakMap,Vt=new WeakMap,Ut=new WeakMap,Ht=new WeakMap,Yt=new WeakMap,qt=new WeakMap,Jt=new WeakMap,Gt=new WeakMap,Kt=new WeakMap,Qt=new WeakMap,Xt=new WeakMap,Zt=new WeakMap,te=new WeakMap,ee=new WeakMap,ne=new WeakMap,se=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,be=new WeakMap,ve=new WeakMap,we=new WeakMap,ke)](t){if(!t._||!t["--"])return t;t._.push.apply(t._,t["--"]);try{delete t["--"]}catch(t){}return t}[Ae](){return{log:(...t)=>{this[Ke]()||console.log(...t),Oe(this,Zt,!0,"f"),Ee(this,se,"f").length&&Oe(this,se,Ee(this,se,"f")+"\n","f"),Oe(this,se,Ee(this,se,"f")+t.join(" "),"f")},error:(...t)=>{this[Ke]()||console.error(...t),Oe(this,Zt,!0,"f"),Ee(this,se,"f").length&&Oe(this,se,Ee(this,se,"f")+"\n","f"),Oe(this,se,Ee(this,se,"f")+t.join(" "),"f")}}}[je](t){ut(Ee(this,ie,"f")).forEach((e=>{if("configObjects"===e)return;const n=Ee(this,ie,"f")[e];Array.isArray(n)?n.includes(t)&&n.splice(n.indexOf(t),1):"object"==typeof n&&delete n[t]})),delete Ee(this,ye,"f").getDescriptions()[t]}[$e](t,e,n){Ee(this,Jt,"f")[n]||(Ee(this,fe,"f").process.emitWarning(t,e),Ee(this,Jt,"f")[n]=!0)}[_e](){Ee(this,Kt,"f").push({options:Ee(this,ie,"f"),configObjects:Ee(this,ie,"f").configObjects.slice(0),exitProcess:Ee(this,Gt,"f"),groups:Ee(this,Xt,"f"),strict:Ee(this,pe,"f"),strictCommands:Ee(this,ge,"f"),strictOptions:Ee(this,me,"f"),completionCommand:Ee(this,Ut,"f"),output:Ee(this,se,"f"),exitError:Ee(this,Yt,"f"),hasOutput:Ee(this,Zt,"f"),parsed:this.parsed,parseFn:Ee(this,ae,"f"),parseContext:Ee(this,ce,"f")}),Ee(this,ye,"f").freeze(),Ee(this,we,"f").freeze(),Ee(this,Tt,"f").freeze(),Ee(this,Qt,"f").freeze()}[xe](){let t,e="";return t=/\b(node|iojs|electron)(\.exe)?$/.test(Ee(this,fe,"f").process.argv()[0])?Ee(this,fe,"f").process.argv().slice(1,2):Ee(this,fe,"f").process.argv().slice(0,1),e=t.map((t=>{const e=this[Ze](Ee(this,Lt,"f"),t);return t.match(/^(\/|([a-zA-Z]:)?\\)/)&&e.length<t.length?e:t})).join(" ").trim(),Ee(this,fe,"f").getEnv("_")&&Ee(this,fe,"f").getProcessArgvBin()===Ee(this,fe,"f").getEnv("_")&&(e=Ee(this,fe,"f").getEnv("_").replace(`${Ee(this,fe,"f").path.dirname(Ee(this,fe,"f").process.execPath())}/`,"")),e}[Ce](){return Ee(this,oe,"f")}[Pe](){return Ee(this,be,"f")}[Se](){if(!Ee(this,qt,"f"))return;const t=Ee(this,fe,"f").getEnv("LC_ALL")||Ee(this,fe,"f").getEnv("LC_MESSAGES")||Ee(this,fe,"f").getEnv("LANG")||Ee(this,fe,"f").getEnv("LANGUAGE")||"en_US";this.locale(t.replace(/[.:].*/,""))}[Ne](){return this[De]().version||"unknown"}[Me](t){const e=t["--"]?t["--"]:t._;for(let t,n=0;void 0!==(t=e[n]);n++)Ee(this,fe,"f").Parser.looksLikeNumber(t)&&Number.isSafeInteger(Math.floor(parseFloat(`${t}`)))&&(e[n]=Number(t));return t}[De](t){const e=t||"*";if(Ee(this,le,"f")[e])return Ee(this,le,"f")[e];let n={};try{let e=t||Ee(this,fe,"f").mainFilename;!t&&Ee(this,fe,"f").path.extname(e)&&(e=Ee(this,fe,"f").path.dirname(e));const s=Ee(this,fe,"f").findUp(e,((t,e)=>e.includes("package.json")?"package.json":void 0));ht(s,void 0,Ee(this,fe,"f")),n=JSON.parse(Ee(this,fe,"f").readFileSync(s,"utf8"))}catch(t){}return Ee(this,le,"f")[e]=n||{},Ee(this,le,"f")[e]}[Ie](t,e){(e=[].concat(e)).forEach((e=>{e=this[Fe](e),Ee(this,ie,"f")[t].push(e)}))}[Re](t,e,n,s){this[ze](t,e,n,s,((t,e,n)=>{Ee(this,ie,"f")[t][e]=n}))}[We](t,e,n,s){this[ze](t,e,n,s,((t,e,n)=>{Ee(this,ie,"f")[t][e]=(Ee(this,ie,"f")[t][e]||[]).concat(n)}))}[ze](t,e,n,s,i){if(Array.isArray(n))n.forEach((e=>{t(e,s)}));else if((t=>"object"==typeof t)(n))for(const e of ut(n))t(e,n[e]);else i(e,this[Fe](n),s)}[Fe](t){return"__proto__"===t?"___proto___":t}[Te](t,e){return this[Re](this[Te].bind(this),"key",t,e),this}[Le](){var t,e,n,s,i,r,o,a,c,l,h,d;const u=Ee(this,Kt,"f").pop();let f;ht(u,void 0,Ee(this,fe,"f")),t=this,e=this,n=this,s=this,i=this,r=this,o=this,a=this,c=this,l=this,h=this,d=this,({options:{set value(e){Oe(t,ie,e,"f")}}.value,configObjects:f,exitProcess:{set value(t){Oe(e,Gt,t,"f")}}.value,groups:{set value(t){Oe(n,Xt,t,"f")}}.value,output:{set value(t){Oe(s,se,t,"f")}}.value,exitError:{set value(t){Oe(i,Yt,t,"f")}}.value,hasOutput:{set value(t){Oe(r,Zt,t,"f")}}.value,parsed:this.parsed,strict:{set value(t){Oe(o,pe,t,"f")}}.value,strictCommands:{set value(t){Oe(a,ge,t,"f")}}.value,strictOptions:{set value(t){Oe(c,me,t,"f")}}.value,completionCommand:{set value(t){Oe(l,Ut,t,"f")}}.value,parseFn:{set value(t){Oe(h,ae,t,"f")}}.value,parseContext:{set value(t){Oe(d,ce,t,"f")}}.value}=u),Ee(this,ie,"f").configObjects=f,Ee(this,ye,"f").unfreeze(),Ee(this,we,"f").unfreeze(),Ee(this,Tt,"f").unfreeze(),Ee(this,Qt,"f").unfreeze()}[Be](t,e){return Ot(e,(e=>(t(e),e)))}getInternalMethods(){return{getCommandInstance:this[Ve].bind(this),getContext:this[Ue].bind(this),getHasOutput:this[He].bind(this),getLoggerInstance:this[Ye].bind(this),getParseContext:this[qe].bind(this),getParserConfiguration:this[Ce].bind(this),getUsageConfiguration:this[Pe].bind(this),getUsageInstance:this[Je].bind(this),getValidationInstance:this[Ge].bind(this),hasParseCallback:this[Ke].bind(this),isGlobalContext:this[Qe].bind(this),postProcess:this[Xe].bind(this),reset:this[tn].bind(this),runValidation:this[nn].bind(this),runYargsParserAndExecuteCommands:this[en].bind(this),setHasOutput:this[sn].bind(this)}}[Ve](){return Ee(this,Tt,"f")}[Ue](){return Ee(this,Bt,"f")}[He](){return Ee(this,Zt,"f")}[Ye](){return Ee(this,ne,"f")}[qe](){return Ee(this,ce,"f")||{}}[Je](){return Ee(this,ye,"f")}[Ge](){return Ee(this,we,"f")}[Ke](){return!!Ee(this,ae,"f")}[Qe](){return Ee(this,ee,"f")}[Xe](t,e,n,s){if(n)return t;if(ft(t))return t;e||(t=this[ke](t));return(this[Ce]()["parse-positional-numbers"]||void 0===this[Ce]()["parse-positional-numbers"])&&(t=this[Me](t)),s&&(t=wt(t,this,Ee(this,Qt,"f").getMiddleware(),!1)),t}[tn](t={}){Oe(this,ie,Ee(this,ie,"f")||{},"f");const e={};e.local=Ee(this,ie,"f").local||[],e.configObjects=Ee(this,ie,"f").configObjects||[];const n={};e.local.forEach((e=>{n[e]=!0,(t[e]||[]).forEach((t=>{n[t]=!0}))})),Object.assign(Ee(this,he,"f"),Object.keys(Ee(this,Xt,"f")).reduce(((t,e)=>{const s=Ee(this,Xt,"f")[e].filter((t=>!(t in n)));return s.length>0&&(t[e]=s),t}),{})),Oe(this,Xt,{},"f");return["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"].forEach((t=>{e[t]=(Ee(this,ie,"f")[t]||[]).filter((t=>!n[t]))})),["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"].forEach((t=>{e[t]=$t(Ee(this,ie,"f")[t],(t=>!n[t]))})),e.envPrefix=Ee(this,ie,"f").envPrefix,Oe(this,ie,e,"f"),Oe(this,ye,Ee(this,ye,"f")?Ee(this,ye,"f").reset(n):Ct(this,Ee(this,fe,"f")),"f"),Oe(this,we,Ee(this,we,"f")?Ee(this,we,"f").reset(n):function(t,e,n){const s=n.y18n.__,i=n.y18n.__n,r={nonOptionCount:function(n){const s=t.getDemandedCommands(),r=n._.length+(n["--"]?n["--"].length:0)-t.getInternalMethods().getContext().commands.length;s._&&(r<s._.min||r>s._.max)&&(r<s._.min?void 0!==s._.minMsg?e.fail(s._.minMsg?s._.minMsg.replace(/\$0/g,r.toString()).replace(/\$1/,s._.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(),s._.min.toString())):r>s._.max&&(void 0!==s._.maxMsg?e.fail(s._.maxMsg?s._.maxMsg.replace(/\$0/g,r.toString()).replace(/\$1/,s._.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(),s._.max.toString()))))},positionalCount:function(t,n){n<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",n,n+"",t+""))},requiredArguments:function(t,n){let s=null;for(const e of Object.keys(n))Object.prototype.hasOwnProperty.call(t,e)&&void 0!==t[e]||(s=s||{},s[e]=n[e]);if(s){const t=[];for(const e of Object.keys(s)){const n=s[e];n&&t.indexOf(n)<0&&t.push(n)}const n=t.length?`\n${t.join("\n")}`:"";e.fail(i("Missing required argument: %s","Missing required arguments: %s",Object.keys(s).length,Object.keys(s).join(", ")+n))}},unknownArguments:function(n,s,o,a,c=!0){var l;const h=t.getInternalMethods().getCommandInstance().getCommands(),d=[],u=t.getInternalMethods().getContext();if(Object.keys(n).forEach((e=>{It.includes(e)||Object.prototype.hasOwnProperty.call(o,e)||Object.prototype.hasOwnProperty.call(t.getInternalMethods().getParseContext(),e)||r.isValidAndSomeAliasIsNotNew(e,s)||d.push(e)})),c&&(u.commands.length>0||h.length>0||a)&&n._.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,s=u.commands.length+e;s<n._.length&&n._.slice(s).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(n){const s=t.getInternalMethods().getCommandInstance().getCommands(),r=[],o=t.getInternalMethods().getContext();return(o.commands.length>0||s.length>0)&&n._.slice(o.commands.length).forEach((t=>{s.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,n){if(!Object.prototype.hasOwnProperty.call(n,e))return!1;const s=t.parsed.newAliases;return[e,...n[e]].some((t=>!Object.prototype.hasOwnProperty.call(s,t)||!s[e]))},limitedChoices:function(n){const i=t.getOptions(),r={};if(!Object.keys(i.choices).length)return;Object.keys(n).forEach((t=>{-1===It.indexOf(t)&&Object.prototype.hasOwnProperty.call(i.choices,t)&&[].concat(n[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=s("Invalid values:");o.forEach((t=>{a+=`\n ${s("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 n=Number(e);return"number"==typeof(e=isNaN(n)?e:n)?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,s){mt("<string|object> [array|number|string]",[e,s],arguments.length),"object"==typeof e?Object.keys(e).forEach((t=>{r.implies(t,e[t])})):(t.global(e),o[e]||(o[e]=[]),Array.isArray(s)?s.forEach((t=>r.implies(e,t))):(ht(s,void 0,n),o[e].push(s)))},r.getImplied=function(){return o},r.implications=function(t){const n=[];if(Object.keys(o).forEach((e=>{const s=e;(o[e]||[]).forEach((e=>{let i=s;const r=e;i=a(t,i),e=a(t,e),i&&!e&&n.push(` ${s} -> ${r}`)}))})),n.length){let t=`${s("Implications failed:")}\n`;n.forEach((e=>{t+=e})),e.fail(t)}};let c={};r.conflicts=function(e,n){mt("<string|object> [array|string]",[e,n],arguments.length),"object"==typeof e?Object.keys(e).forEach((t=>{r.conflicts(t,e[t])})):(t.global(e),c[e]||(c[e]=[]),Array.isArray(n)?n.forEach((t=>r.conflicts(e,t))):c[e].push(n))},r.getConflicting=()=>c,r.conflicting=function(i){Object.keys(i).forEach((t=>{c[t]&&c[t].forEach((n=>{n&&void 0!==i[t]&&void 0!==i[n]&&e.fail(s("Arguments %s and %s are mutually exclusive",t,n))}))})),t.getInternalMethods().getParserConfiguration()["strip-dashed"]&&Object.keys(c).forEach((t=>{c[t].forEach((r=>{r&&void 0!==i[n.Parser.camelCase(t)]&&void 0!==i[n.Parser.camelCase(r)]&&e.fail(s("Arguments %s and %s are mutually exclusive",t,r))}))}))},r.recommendCommands=function(t,n){n=n.sort(((t,e)=>e.length-t.length));let i=null,r=1/0;for(let e,s=0;void 0!==(e=n[s]);s++){const n=Dt(t,e);n<=3&&n<r&&(r=n,i=e)}i&&e.fail(s("Did you mean %s?",i))},r.reset=function(t){return o=$t(o,(e=>!t[e])),c=$t(c,(e=>!t[e])),r};const l=[];return r.freeze=function(){l.push({implied:o,conflicting:c})},r.unfreeze=function(){const t=l.pop();ht(t,void 0,n),({implied:o,conflicting:c}=t)},r}(this,Ee(this,ye,"f"),Ee(this,fe,"f")),"f"),Oe(this,Tt,Ee(this,Tt,"f")?Ee(this,Tt,"f").reset():function(t,e,n,s){return new kt(t,e,n,s)}(Ee(this,ye,"f"),Ee(this,we,"f"),Ee(this,Qt,"f"),Ee(this,fe,"f")),"f"),Ee(this,Vt,"f")||Oe(this,Vt,function(t,e,n,s){return new Mt(t,e,n,s)}(this,Ee(this,ye,"f"),Ee(this,Tt,"f"),Ee(this,fe,"f")),"f"),Ee(this,Qt,"f").reset(),Oe(this,Ut,null,"f"),Oe(this,se,"","f"),Oe(this,Yt,null,"f"),Oe(this,Zt,!1,"f"),this.parsed=!1,this}[Ze](t,e){return Ee(this,fe,"f").path.relative(t,e)}[en](t,e,n,s=0,i=!1){let r=!!n||i;t=t||Ee(this,de,"f"),Ee(this,ie,"f").__=Ee(this,fe,"f").y18n.__,Ee(this,ie,"f").configuration=this[Ce]();const o=!!Ee(this,ie,"f").configuration["populate--"],a=Object.assign({},Ee(this,ie,"f").configuration,{"populate--":!0}),c=Ee(this,fe,"f").Parser.detailed(t,Object.assign({},Ee(this,ie,"f"),{configuration:{"parse-positional-numbers":!1,...a}})),l=Object.assign(c.argv,Ee(this,ce,"f"));let h;const d=c.aliases;let u=!1,f=!1;Object.keys(l).forEach((t=>{t===Ee(this,te,"f")&&l[t]?u=!0:t===Ee(this,ve,"f")&&l[t]&&(f=!0)})),l.$0=this.$0,this.parsed=c,0===s&&Ee(this,ye,"f").clearCachedHelpMessage();try{if(this[Se](),e)return this[Xe](l,o,!!n,!1);if(Ee(this,te,"f")){[Ee(this,te,"f")].concat(d[Ee(this,te,"f")]||[]).filter((t=>t.length>1)).includes(""+l._[l._.length-1])&&(l._.pop(),u=!0)}Oe(this,ee,!1,"f");const a=Ee(this,Tt,"f").getCommands(),p=Ee(this,Vt,"f").completionKey in l,g=u||p||i;if(l._.length){if(a.length){let t;for(let e,r=s||0;void 0!==l._[r];r++){if(e=String(l._[r]),a.includes(e)&&e!==Ee(this,Ut,"f")){const t=Ee(this,Tt,"f").runCommand(e,this,c,r+1,i,u||f||i);return this[Xe](t,o,!!n,!1)}if(!t&&e!==Ee(this,Ut,"f")){t=e;break}}!Ee(this,Tt,"f").hasDefaultCommand()&&Ee(this,ue,"f")&&t&&!g&&Ee(this,we,"f").recommendCommands(t,a)}Ee(this,Ut,"f")&&l._.includes(Ee(this,Ut,"f"))&&!p&&(Ee(this,Gt,"f")&&_t(!0),this.showCompletionScript(),this.exit(0))}if(Ee(this,Tt,"f").hasDefaultCommand()&&!g){const t=Ee(this,Tt,"f").runCommand(null,this,c,0,i,u||f||i);return this[Xe](t,o,!!n,!1)}if(p){Ee(this,Gt,"f")&&_t(!0);const e=(t=[].concat(t)).slice(t.indexOf(`--${Ee(this,Vt,"f").completionKey}`)+1);return Ee(this,Vt,"f").getCompletion(e,((t,e)=>{if(t)throw new nt(t.message);(e||[]).forEach((t=>{Ee(this,ne,"f").log(t)})),this.exit(0)})),this[Xe](l,!o,!!n,!1)}if(Ee(this,Zt,"f")||(u?(Ee(this,Gt,"f")&&_t(!0),r=!0,this.showHelp("log"),this.exit(0)):f&&(Ee(this,Gt,"f")&&_t(!0),r=!0,Ee(this,ye,"f").showVersion("log"),this.exit(0))),!r&&Ee(this,ie,"f").skipValidation.length>0&&(r=Object.keys(l).some((t=>Ee(this,ie,"f").skipValidation.indexOf(t)>=0&&!0===l[t]))),!r){if(c.error)throw new nt(c.error.message);if(!p){const t=this[nn](d,{},c.error);n||(h=wt(l,this,Ee(this,Qt,"f").getMiddleware(),!0)),h=this[Be](t,null!=h?h:l),ft(h)&&!n&&(h=h.then((()=>wt(l,this,Ee(this,Qt,"f").getMiddleware(),!1))))}}}catch(t){if(!(t instanceof nt))throw t;Ee(this,ye,"f").fail(t.message,t)}return this[Xe](null!=h?h:l,o,!!n,!0)}[nn](t,e,n,s){const i={...this.getDemandedOptions()};return r=>{if(n)throw new nt(n.message);Ee(this,we,"f").nonOptionCount(r),Ee(this,we,"f").requiredArguments(r,i);let o=!1;Ee(this,ge,"f")&&(o=Ee(this,we,"f").unknownCommands(r)),Ee(this,pe,"f")&&!o?Ee(this,we,"f").unknownArguments(r,t,e,!!s):Ee(this,me,"f")&&Ee(this,we,"f").unknownArguments(r,t,{},!1,!1),Ee(this,we,"f").limitedChoices(r),Ee(this,we,"f").implications(r),Ee(this,we,"f").conflicting(r)}}[sn](){Oe(this,Zt,!0,"f")}[rn](t){if("string"==typeof t)Ee(this,ie,"f").key[t]=!0;else for(const e of t)Ee(this,ie,"f").key[e]=!0}}const an=(cn=lt,(t=[],e=cn.process.cwd(),n)=>{const s=new on(t,e,n,cn);return Object.defineProperty(s,"argv",{get:()=>s.parse(),enumerable:!0}),s.help(),s.version(),s});var cn;function ln(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(null!==t?typeof t:"null"));return t}function hn(t,e,n){"symbol"==typeof e&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:n?n+" "+e:e})}catch(t){}return t}function dn(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var s=n.call(t,e||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}let un;const fn=function(t,e,n=Number.POSITIVE_INFINITY){return function(s,i){if("getter"===i?.kind){const e=new Map;return function(){const i=Date.now();if(e.has(this)){const[t,s]=e.get(this);if(i-s<=n)return t}const r=s.call(this);if(e.size>=t){const t=e.keys().next().value;e.delete(t)}return e.set(this,[r,i]),r}}{const r=new Map;return function(...o){const a=JSON.stringify(o);let c=r.get(this);const l=Date.now();if(c){if(c.has(a)){const[t,e]=c.get(a);if(l-e<=n)return t}}else{if(c=new Map,r.size>=t){const t=r.keys().next().value;r.delete(t)}r.set(this,c)}const h=i?s.call(this,...o):s(...o);if(c.size>=e){const t=c.keys().next().value;c.delete(t)}return c.set(a,[h,l]),h}}}}(Number.MAX_SAFE_INTEGER,1);class pn{static{[un]=function(t,e,n,s,i,r){var o,a,c,l,h,d,u,f=Symbol.metadata||Symbol.for("Symbol.metadata"),p=Object.defineProperty,g=Object.create,m=[g(null),g(null)],y=e.length;function b(e,n,s){return function(i,r){n&&(r=i,i=t);for(var o=0;o<e.length;o++)r=e[o].apply(i,s?[r]:[]);return s?r:i}}function v(t,e,n,s){if("function"!=typeof t&&(s||void 0!==t))throw new TypeError(e+" must "+(n||"be")+" a function"+(s?"":" or undefined"));return t}function w(t,e,n,s,i,r,c,l,h,d,u){function f(t){if(!u(t))throw new TypeError("Attempted to access private element on non-instance")}var g=[].concat(e[0]),y=e[3],w=!c,O=1===i,E=3===i,k=4===i,A=2===i;function j(e,n,s){return function(i,r){return n&&(r=i,i=t),s&&s(i),$[e].call(i,r)}}if(!w){var $={},_=[],x=E?"get":k||O?"set":"value";if(h?(d||O?$={get:hn((function(){return y(this)}),s,"get"),set:function(t){e[4](this,t)}}:$[x]=y,d||hn($[x],s,A?"":x)):d||($=Object.getOwnPropertyDescriptor(t,s)),!d&&!h){if((a=m[+l][s])&&7!=(a^i))throw Error("Decorating two elements with the same name ("+$[x].name+") is not supported yet");m[+l][s]=i<3?1:i}}for(var C=t,P=g.length-1;P>=0;P-=n?2:1){var S=g[P],N=n?g[P-1]:void 0,M={},D={kind:["field","accessor","method","getter","setter","class"][i],name:s,metadata:o,addInitializer:function(t,e){if(t.v)throw Error("attempted to call addInitializer after decoration was finished");v(e,"An initializer","be",!0),r.push(e)}.bind(null,M)};if(w)a=S.call(N,C,D),M.v=1,v(a,"class decorators","return")&&(C=a);else if(D.static=l,D.private=h,a=D.access={has:h?u.bind():function(t){return s in t}},k||(a.get=h?A?function(t){return f(t),$.value}:j("get",0,f):function(t){return t[s]}),A||E||(a.set=h?j("set",0,f):function(t,e){t[s]=e}),C=S.call(N,O?{get:$.get,set:$.set}:$[x],D),M.v=1,O){if("object"==typeof C&&C)(a=v(C.get,"accessor.get"))&&($.get=a),(a=v(C.set,"accessor.set"))&&($.set=a),(a=v(C.init,"accessor.init"))&&_.unshift(a);else if(void 0!==C)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else v(C,(d?"field":"method")+" decorators","return")&&(d?_.unshift(C):$[x]=C)}return i<2&&c.push(b(_,l,1),b(r,l,0)),d||w||(h?O?c.splice(-1,0,j("get",l),j("set",l)):c.push(A?$[x]:v.call.bind($[x])):p(t,s,$)),C}function O(t){return p(t,f,{configurable:!0,enumerable:!0,value:o})}return void 0!==r&&(o=r[f]),o=g(null==o?null:o),h=[],d=function(t){t&&h.push(b(t))},u=function(e,s){for(var r=0;r<n.length;r++){var o=n[r],a=o[1],d=7&a;if((8&a)==e&&!d==s){var u=o[2],f=!!o[3],p=16&a;w(e?t:t.prototype,o,p,f?"#"+u:dn(u),d,d<2?[]:e?l=l||[]:c=c||[],h,!!e,f,s,e&&f?function(e){return ln(e)===t}:i)}}},u(8,0),u(0,0),u(8,1),u(0,1),d(c),d(l),a=h,y||O(t),{e:a,get c(){var n=[];return y&&[O(t=w(t,[e],s,t.name,5,n)),b(n,1)]}}}(this,[],[[fn,3,"buildCommand"],[fn,3,"rootDirPath"],[fn,3,"dockerfile"],[fn,3,"hasDockerfile"],[fn,3,"name"],[fn,3,"dockerImageName"],[fn,3,"env"],[fn,3,"packageJson"],[fn,3,"hasPrisma"],[fn,3,"dockerPackageJson"],[fn,3,"binExists"]]).e}argv=void un(this);pathByName=new Map;constructor(e,n,s){this._dirPath=t.resolve(e),this.argv=n,this.loadEnv=s}get buildCommand(){return this.packageJson.scripts?.build?.includes("buildIfNeeded")?"yarn build":"YARN wb buildIfNeeded "+(this.argv.verbose?"--verbose":"")}get dirPath(){return this._dirPath}get rootDirPath(){return l.existsSync(t.join(this.dirPath,"..","..","package.json"))?t.resolve(this.dirPath,"..",".."):this.dirPath}get dockerfile(){return l.readFileSync(this.findFile("Dockerfile"),"utf8")}get hasDockerfile(){try{return!!this.findFile("Dockerfile")}catch{return!1}}get name(){return this.packageJson.name||"unknown"}get dockerImageName(){return(this.packageJson.name||"unknown").replaceAll("@","").replaceAll("/","-")}get env(){return this.loadEnv?{...x(this.argv,this.dirPath),...process.env}:process.env}get packageJson(){return JSON.parse(l.readFileSync(t.join(this.dirPath,"package.json"),"utf8"))}get hasPrisma(){return!(!this.packageJson.dependencies?.prisma&&!this.packageJson.devDependencies?.prisma)}get dockerPackageJson(){return t.dirname(this.findFile("Dockerfile"))===this.dirPath?this.packageJson:JSON.parse(l.readFileSync(t.join(t.dirname(this.findFile("Dockerfile")),"package.json"),"utf8"))}get binExists(){let e=!1,n=this.dirPath;for(;;){const s=t.join(n,"node_modules",".bin");if(l.existsSync(s)&&(this.env.PATH=`${s}:${this.env.PATH}`,e=!0),l.existsSync(t.join(n,".git")))break;const i=t.dirname(n);if(n===i)break;n=i}return e}findFile(e){let n=this.pathByName.get(e);if(n)return n;if(n=[e,t.join("..","..",e)].map((e=>t.resolve(this.dirPath,e))).find((t=>l.existsSync(t))),!n)throw new Error(`File not found: ${e}`);return this.pathByName.set(e,n),n}}function gn(e,n=!0,s){if(s??=process.cwd(),l.existsSync(t.join(s,"package.json")))return new pn(s,e,n)}async function mn(e,n=!0,s){const i=function(e,n=!0,s){if(s??=process.cwd(),!l.existsSync(t.join(s,"package.json")))return;const i=new pn(s,e,n);let r=i;if(!i.packageJson.workspaces&&t.dirname(s).endsWith("/packages")){const i=t.resolve(s,"..","..");l.existsSync(t.join(i,"package.json"))&&(r=new pn(i,e,n))}return{root:r,self:i}}(e,n,s);if(i)return{...i,all:i.root===i.self?await yn(e,i.root,n):[i.self]}}async function yn(e,n,s){const i=[n],r=t.join(n.dirPath,"packages");if(!l.existsSync(r))return i;const o=await l.promises.readdir(r,{withFileTypes:!0});for(const n of o){if(!n.isDirectory())continue;const o=t.join(r,n.name);l.existsSync(t.join(o,"package.json"))&&i.push(new pn(o,e,s))}return i}const bn={command:"buildIfNeeded",describe:"Build code if changes are detected",builder:{command:{description:"A build command",type:"string",default:"yarn build",alias:"c"}},async handler(e){await async function(e,n){const s=await gn(e,!0,n);if(!s)return console.error(O.red("No project found.")),!0;if(!l.existsSync(t.join(s.rootDirPath,".git")))return vn(s,e),!0;const[i,r,o]=await async function(e,n){const s=t.resolve(e.dirPath,"node_modules",".cache","build"),i=t.resolve(s,"last-build");await l.promises.mkdir(s,{recursive:!0});const r=w("sha256"),o=y.execSync("git rev-parse HEAD",{cwd:e.dirPath}).toString().trim();r.update(o);const a=JSON.stringify(Object.entries(e.env).filter((([t])=>!wn.has(t))).sort((([t],[e])=>t.localeCompare(e))));r.update(a),await async function(t,e,n){return new Promise((s=>{const i=y.spawnSync("git",["diff","--name-only"],{cwd:t.dirPath,env:t.env,stdio:"pipe",encoding:"utf8"}).stdout.trim().split("\n").map((e=>"test"===t.env.WB_ENV?e.replace(/packages\/scripts\/test-fixtures\/[^/]+\//,""):e)).filter((t=>(On.some((e=>t.includes(e)))||En.some((e=>t.endsWith(e))))&&!kn.some((e=>t.includes(e)))));e.verbose&&console.info(`Changed files: ${i.join(", ")}`);const r=y.spawn("git",["diff","--",...i],{cwd:t.rootDirPath});r.stdout?.on("data",(t=>{n.update(t),e.verbose&&(console.info(t.toString()),console.info("Hash:",n.copy().digest("hex")))})),r.on("close",(()=>{s()}))}))}(e,n,r);const c=r.digest("hex"),h=await async function(t){try{return await t()}catch(t){if("object"==typeof t&&t&&"code"in t&&"ENOENT"===t.code)return;throw t}}((()=>l.promises.readFile(i,"utf8")));return[h===c,i,c]}(s,e);if(i)return console.info(O.green(`Skip to run '${e.command}' 💫`)),!1;if(!vn(s,e))return;e.dryRun||await l.promises.writeFile(r,o,"utf8");return!0}(e)}};function vn(t,e){if(console.info(O.green(`Run '${e.command}'`)),!e.dryRun){const n=y.spawnSync(e.command??"",{cwd:t.dirPath,env:t.env,shell:!0,stdio:"inherit"});if(0!==n.status)return process.exitCode=n.status??1,!1}return!0}const wn=new Set(["CI","PWDEBUG","TMPDIR"]);const On=["src/","public/"],En=[".js",".cjs",".mjs",".jsx",".ts",".cts",".mts",".tsx",".json",".browserslistrc","package.json","yarn.lock"],kn=["test/","tests/","__tests__/","test-fixtures/"];function*An(t,e){for(const n of e)console.info(`Running "${t}" for ${n.name} ...`),yield n}const jn={command:"optimizeForDockerBuild",describe:"Optimize configuration when building a Docker image",builder:{outside:{description:"Whether the optimization is executed outside a docker container or not",type:"boolean",alias:"o"}},async handler(e){const n=await mn(e);n||(console.error(O.red("No project found.")),process.exit(1));for(const s of An("optimizeForDockerBuild",n.all)){const n=s.packageJson,i=["dependencies","devDependencies"];for(const t of i){const e=n[t]||{};for(const[t,n]of Object.entries(e))n?.startsWith("git@github.com:")&&(e[t]=`./${t}`)}if($n(e,n),_n(n),xn(n),e.dryRun)continue;const r=e.outside?t.join(s.dirPath,"dist"):s.dirPath;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",{stdio:"inherit"})}};function $n(t,e){if(!t.outside)return void delete e.devDependencies;const n=e.devDependencies||{},s=["artillery","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(n))(s.some((t=>e.includes(t)))||!t.outside&&e.includes("willbooster")&&e.includes("config"))&&delete n[e]}function _n(t){const e=["check","deploy","format","lint","start","test"],n=["pinst ","husky "],s=t.scripts||{};for(const[t,i]of Object.entries(s))(e.some((e=>t.includes(e)))||n.some((t=>i.includes(t)||i.trim()===t.trim())))&&delete s[t]}function xn(t){delete t.private,delete t.publishConfig,delete t.prettier}const Cn=new class{deploy(t){return"PRISMA migrate deploy"}deployForce(t,e){const n=t.packageJson.dependencies?.blitz?"db":"prisma";return`rm -Rf ${n}/mount/prod.sqlite3*; PRISMA migrate reset --force && rm -Rf ${n}/mount/prod.sqlite3*\n && litestream restore -o ${n}/mount/prod.sqlite3 ${e} && ALLOW_TO_SKIP_SEED=0 PRISMA migrate deploy`}litestream(t){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(t){return`PRISMA migrate deploy && PRISMA generate && ${this.seed(t)}`}migrateDev(t){return"PRISMA migrate dev"}reset(t){return`PRISMA migrate reset --force --skip-seed && ${this.seed(t)}`}restore(t,e,n){return`rm -Rf ${t.packageJson.dependencies?.blitz?"db":"prisma"}/restored.sqlite3; GOOGLE_APPLICATION_CREDENTIALS=gcp-sa-key.json litestream restore -o ${n} ${e}`}seed(t,e){return t.packageJson.dependencies?.blitz?"YARN blitz db seed"+(e?` -f ${e}`:""):e?"YARN build-ts run prisma/seeds.ts":t.packageJson.prisma?.seed?"YARN prisma db seed":'if [ -e "prisma/seeds.ts" ]; then YARN build-ts run prisma/seeds.ts; fi'}studio(e,n){let s="";if(n)try{new URL(n),s=`DATABASE_URL=${n} `}catch{const e=t.resolve(n);console.info(n,e),s=`DATABASE_URL=file://${e} `}return`${s}PRISMA studio`}},Pn=new Set;async function Sn(t){try{await k(t)}catch{}}const Nn=new A,Mn={exitIfFailed:!0};async function Dn(t,e,n,s=Mn){const[i,r]=Rn(t,e);if(Wn(i,e),n.verbose&&Wn(r,e,"Start (raw)",!0),n.dryRun)return zn(i,0,s),0;const o=r.match(/http:\/\/127.0.0.1:(\d+)/)?.[1];r.includes("wait-on")&&o&&!r.includes("docker run")&&await async function(t){await Sn(t);const e=async()=>{Pn.has(t)||(Pn.add(t),await Sn(t))};for(const t of["beforeExit","SIGINT","SIGTERM","SIGQUIT"])process.on(t,e)}(Number(o));const a=await N(r,void 0,{cwd:e.dirPath,env:e.env,shell:!0,stdio:"inherit",timeout:s?.timeout,killOnExit:!0,verbose:n.verbose});return zn(i,a.status,s),a.status??1}function In(t,e,n,s=Mn){return Nn.run((async()=>{const[i,r]=Rn(t,e);if(Wn(i,e,"Start (parallel)",!0),n.dryRun)return Wn(i,e,"Started (log)"),n.verbose&&Wn(r,e,"Started (raw)",!0),void zn(i,0,s);const o=await N(r,void 0,{cwd:e.dirPath,env:e.env,shell:!0,stdio:"pipe",timeout:s?.timeout,mergeOutAndError:!0,killOnExit:!0,verbose:n.verbose});Wn(i,e,"Started (log)"),n.verbose&&Wn(r,e,"Started (raw)",!0);const a=o.stdout.trim();a&&console.info(a),zn(i,o.status,s)}))}function Rn(t,e){const n=t.replaceAll("\n","").replaceAll(/\s\s+/g," ").replaceAll("PRISMA ",e.packageJson.dependencies?.blitz?"YARN blitz prisma ":"YARN prisma ").trim();return[n.replaceAll("YARN ","yarn "),n.replaceAll("YARN ",e.binExists?"":"yarn ")]}function Wn(t,e,n="Start",s=!1){console.info("\n"+(s?O.gray:O.cyan)(O.bold(`${n}:`),t)+O.gray(` at ${e.dirPath}`))}function zn(t,e,n){0===e?console.info(O.green(O.bold("Finished:"),t)):(console.info(O.red(O.bold(`Failed (exit code ${e}): `),t)),!1!==n.exitIfFailed&&process.exit(e??1))}const Fn={},Tn={command:"prisma",describe:"Run prisma commands",builder:t=>t.command(Ln).command(Vn).command(Un).command(Hn).command(Yn).command(qn).command(Jn).command(Gn).command(Kn).demandCommand(),handler(){}},Ln={command:"deploy",describe:"Apply migration to DB without initializing it",builder:Fn,async handler(t){const e=await Qn(t);for(const n of An("prisma deploy",e))await Dn(Cn.deploy(n),n,t)}},Bn={...Fn,"backup-path":{description:"Whether to skip actual command execution",demandOption:!0,type:"string",alias:"b"}},Vn={command:"deploy-force <backup-path>",describe:"Force to apply migration to DB utilizing Litestream's backup without initializing it",builder:Bn,async handler(t){const e=await Qn(t);for(const n of An("prisma deploy-force",e))await Dn(Cn.deployForce(n,t.backupPath),n,t)}},Un={command:"litestream",describe:"Setup DB for Litestream",builder:Fn,async handler(t){const e=await Qn(t);for(const n of An("prisma litestream",e))await Dn(Cn.litestream(n),n,t)}},Hn={command:"migrate",describe:"Apply migration to DB with initializing it",builder:Fn,async handler(t){const e=await Qn(t);for(const n of An("prisma migrate",e))await Dn(Cn.migrate(n),n,t)}},Yn={command:"migrate-dev",describe:"Create a migration file",builder:Fn,async handler(t){const e=await Qn(t);for(const n of An("prisma migrate-dev",e))await Dn(Cn.migrateDev(n),n,t)}},qn={command:"reset",describe:"Reset DB",builder:Fn,async handler(t){const e=await Qn(t);for(const n of An("prisma reset",e))await Dn(Cn.reset(n),n,t)}},Jn={command:"restore <backup-path>",describe:"Restore DB from Litestream's backup",builder:{...Bn,output:{description:'Output path of the restored database. Defaults to "<db|prisma>/restored.sqlite3".',type:"string"}},async handler(t){const e=await Qn(t);for(const n of An("prisma restore",e)){const e=t.output||(n.packageJson.dependencies?.blitz?"db/restored.sqlite3":"prisma/restored.sqlite3");await Dn(Cn.restore(n,t.backupPath,e),n,t)}}},Gn={command:"seed",describe:"Populate DB with seed data",builder:{...Fn,file:{alias:"f",description:"Path of the seed script.",type:"string"}},async handler(t){const e=await Qn(t);for(const n of An("prisma seed",e))await Dn(Cn.seed(n,t.file),n,t)}},Kn={command:"studio [db-url-or-path]",describe:"Open Prisma Studio",builder:{...Fn,"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=await Qn(t);for(const n of An("prisma studio",e)){const e=t.restored?n.packageJson.dependencies?.blitz?"db/restored.sqlite3":"prisma/restored.sqlite3":t.dbUrlOrPath?.toString();await Dn(Cn.studio(n,e),n,t)}}};async function Qn(t){const e=await mn(t);e||(console.error(O.red("No project found.")),process.exit(1));const n=e.all.filter((t=>t.packageJson.dependencies?.prisma||t.packageJson.devDependencies?.prisma));return 0===n.length&&(console.error(O.red("No prisma project found.")),process.exit(1)),n}const Xn={command:"retry [command] [args...]",describe:"Retry the given command until it succeeds",builder:{retry:{description:"A maximum retry count",type:"number",alias:"r",default:3}},async handler(t){const e=gn(t);e||(console.error(O.red("No project found.")),process.exit(1));const n=[t.command,...t.args??[],...t._.slice(1)].filter(Boolean);let s=0;for(let i=0;i<t.retry;i++)if(i>0&&console.info(`\n${O.yellow(`#${i} Retrying: ${n.join(" ")}`)}`),s=await Dn(n.join(" "),e,t,{exitIfFailed:!1}),0===s)return;process.exit(s)}},Zn={command:"setup",describe:"Setup development environment. .env files are ignored.",builder:{},async handler(t){await async function(t,e){const n=await mn(t,!1,e);n||(console.error(O.red("No project found.")),process.exit(1));for(const e of An("setup",n.all)){const s=await $.readdir(e.dirPath,{withFileTypes:!0});if(e===n.root){if("darwin"===_.platform()){const n=["pstree"];e.hasDockerfile&&n.push("expect"),await In(`brew install ${n.join(" ")}`,e,t)}s.some((t=>t.isFile()&&t.name.includes("-version")))&&await Dn("asdf install",e,t)}if(s.some((t=>t.isFile()&&"pyproject.toml"===t.name))){await In("poetry config virtualenvs.in-project true",e,t),await In("poetry config virtualenvs.prefer-active-python true",e,t);const[,n]=y.execSync("asdf current python").toString().trim().split(/\s+/);await In(`poetry env use ${n}`,e,t),await Nn.promiseAll(),await Dn("poetry run pip install --upgrade pip",e,t),await Dn("poetry install --ansi",e,t)}const i=e.packageJson.dependencies??{},r=e.packageJson.devDependencies||{},o=e.packageJson.scripts??{},a=[],c=[];i.blitz||i.next||r["@remix-run/dev"]?(a.push("pm2"),c.push("concurrently","open-cli","vitest","wait-on")):(i.express||i.fastify)&&(a.push("pm2"),c.push("concurrently","vitest","wait-on")),a.length>0&&await Dn(`yarn add ${a.join(" ")}`,e,t),c.length>0&&await Dn(`yarn add -D ${c.join(" ")}`,e,t),o["gen-code"]&&await Dn("yarn gen-code",e,t)}}(t)}};const ts=new class{buildDevImage(e,n){const s=e.dockerPackageJson.scripts?.["docker/build/prepare"]?"yarn run docker/build/prepare && ":"";return`cd ${t.dirname(e.findFile("Dockerfile"))}\n && ${s}YARN wb optimizeForDockerBuild --outside\n && YARN wb retry -- docker build -t ${e.dockerImageName}\n --build-arg ARCH=$([ $(uname -m) = 'arm64' ] && echo arm64 || echo amd64)\n --build-arg WB_ENV=${e.env.WB_ENV}\n --build-arg WB_VERSION=${n} .`}stopAndStart(t,e=!1,n="",s=""){return`${this.stop(t)} && ${e?"unbuffer ":""}${this.start(t,n,s)}`}start(t,e="",n=""){return function(t,e){const n=async()=>{if(Pn.has(t))return;Pn.add(t),Wn(t,e);const{status:n}=v(t,{cwd:e.dirPath,shell:!0,stdio:"inherit"});zn(t,n,{})};for(const t of["beforeExit","SIGINT","SIGTERM","SIGQUIT"])process.on(t,n)}(this.stop(t),t),`docker run --rm -it -p 8080:8080 --name ${t.dockerImageName} ${e} ${t.dockerImageName} ${n}`}stop(t){return`true $(docker rm -f $(docker container ls -q -f name=${t.dockerImageName}) 2> /dev/null)`}stopAll(){return"true $(docker rm -f $(docker ps -q) 2> /dev/null)"}};class es{constructor(t=3e3){this.defaultPort=t}buildDocker(t,e="development"){return ts.buildDevImage(t,e)}startDocker(t,e){return`${this.buildDocker(t)}\n && YARN concurrently --raw --kill-others-on-fail\n "${ts.stopAndStart(t,!1,e.normalizedDockerOptionsText??"",e.normalizedArgsText??"")}"\n "${this.waitAndOpenApp(t,e,8080)}"`}testE2E(t,e,{playwrightArgs:n="test tests/e2e",prismaDirectory:s,startCommand:i}){const r=t.env.WB_ENV;return`WB_ENV=${r} NEXT_PUBLIC_WB_ENV=${r} APP_ENV=${r} PORT=8080 YARN concurrently --kill-others --raw --success first\n "rm -Rf ${s}/mount && ${i} && 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 ${n}"`}testE2EDev(t,e,{playwrightArgs:n="test tests/e2e",startCommand:s}){const i=t.env.WB_ENV;return`WB_ENV=${i} NEXT_PUBLIC_WB_ENV=${i} APP_ENV=${i} PORT=8080 YARN 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 ${n}"`}testUnit(t,e){return`WB_ENV=${t.env.WB_ENV} YARN vitest run tests/unit --color --passWithNoTests`}waitApp(t,e,n=this.defaultPort){return`wait-on -t 10000 http://127.0.0.1:${n} 2> /dev/null\n || wait-on -t 10000 -i 500 http://127.0.0.1:${n} 2> /dev/null\n || wait-on -t 10000 -i 1000 http://127.0.0.1:${n} 2> /dev/null\n || wait-on -t 10000 -i 2000 http://127.0.0.1:${n} 2> /dev/null\n || wait-on -t 20000 -i 4000 http://127.0.0.1:${n} 2> /dev/null\n || wait-on -t 60000 -i 5000 http://127.0.0.1:${n}`}waitAndOpenApp(t,e,n=this.defaultPort){return`${this.waitApp(t,e,n)} || wait-on http://127.0.0.1:${n} && open-cli "http://\${HOST:-localhost}:${n}"`}}const ns=new class extends es{constructor(){super()}start(t,e){return`${t.env.WB_ENV?`APP_ENV=${t.env.WB_ENV} `:""}YARN concurrently --raw --kill-others-on-fail\n "blitz dev ${e.normalizedArgsText??""}"\n "${this.waitAndOpenApp(t,e)}"`}startProduction(t,e,n){return`${t.env.WB_ENV?`APP_ENV=${t.env.WB_ENV} `:""}NODE_ENV=production YARN concurrently --raw --kill-others-on-fail\n "${Cn.reset(t)} && ${t.buildCommand} && PORT=${n} pm2-runtime start ${t.findFile("ecosystem.config.cjs")} ${e.normalizedArgsText??""}"\n "${this.waitAndOpenApp(t,e,n)}"`}testE2E(t,e,{playwrightArgs:n,startCommand:s=`${Cn.reset(t)} && ${t.buildCommand} && pm2-runtime start ${t.findFile("ecosystem.config.cjs")}`}){return super.testE2E(t,e,{playwrightArgs:n,prismaDirectory:"db",startCommand:s})}testE2EDev(t,e,{playwrightArgs:n,startCommand:s="blitz dev -p 8080"}){return super.testE2EDev(t,e,{playwrightArgs:n,startCommand:s})}testStart(t,e){return`YARN concurrently --kill-others --raw --success first "blitz dev" "${this.waitApp(t,e)}"`}};const ss=new class extends es{constructor(){super()}start(t,e){return`YARN build-ts run src/index.ts ${e.watch?"--watch":""} -- ${e.normalizedArgsText??""}`}startDocker(t,e){return`${this.buildDocker(t)} && ${ts.stopAndStart(t,!1,e.normalizedDockerOptionsText??"",e.normalizedArgsText??"")}`}startProduction(t,e,n=8080){return`NODE_ENV=production ${t.buildCommand} && NODE_ENV=production PORT=\${PORT:-${n}} node dist/index.js ${e.normalizedArgsText??""}`}testE2E(t,e,{startCommand:n=`if [ -e "prisma" ]; then prisma migrate reset --force --skip-generate; fi && (${this.startProduction(t,e)})`}){return`NODE_ENV=production WB_ENV=${t.env.WB_ENV} PORT=8080 YARN concurrently --kill-others --raw --success first\n "${n} && exit 1"\n "wait-on -t 600000 -i 2000 http://127.0.0.1:8080 && vitest run tests/e2e --color --passWithNoTests"`}testE2EDev(t,e,{startCommand:n}){return`NODE_ENV=production WB_ENV=${t.env.WB_ENV} PORT=8080 YARN concurrently --kill-others --raw --success first\n "${n||this.start(t,e)} && exit 1"\n "wait-on -t 600000 -i 2000 http://127.0.0.1:8080 && vitest run tests/e2e --color --passWithNoTests"`}testStart(t,e){return`YARN concurrently --kill-others --raw --success first "${this.start(t,e)}" "${this.waitApp(t,e)}"`}};const is=new class extends es{constructor(){super()}start(t,e){return`YARN concurrently --raw --kill-others-on-fail\n "next dev ${e.normalizedArgsText??""}"\n "${this.waitAndOpenApp(t,e)}"`}startProduction(t,e,n){return`NODE_ENV=production YARN concurrently --raw --kill-others-on-fail\n "${[...t.hasPrisma?[Cn.reset(t)]:[],t.buildCommand,`PORT=${n} pm2-runtime start ${t.findFile("ecosystem.config.cjs")} ${e.normalizedArgsText??""}`].join(" && ")}"\n "${this.waitAndOpenApp(t,e,n)}"`}testE2E(t,e,n){return super.testE2E(t,e,{playwrightArgs:n.playwrightArgs,prismaDirectory:"db",startCommand:n.startCommand??[...t.hasPrisma?[Cn.reset(t)]:[],t.buildCommand,`pm2-runtime start ${t.findFile("ecosystem.config.cjs")}`].join(" && ")})}testE2EDev(t,e,{startCommand:n="next dev -p 8080"}){return super.testE2EDev(t,e,{startCommand:n})}testStart(t,e){return`YARN concurrently --kill-others --raw --success first "next dev" "${this.waitApp(t,e)}"`}};const rs=new class extends es{constructor(){super()}start(t,e){return`YARN build-ts run src/index.ts ${e.watch?"--watch":""} -- ${e.normalizedArgsText??""}`}startDocker(t,e){return`${this.buildDocker(t)} && ${ts.stopAndStart(t,!1,e.normalizedDockerOptionsText??"",e.normalizedArgsText??"")}`}startProduction(t,e){return`NODE_ENV=production ${t.buildCommand} && NODE_ENV=production node dist/index.js ${e.normalizedArgsText??""}`}testE2E(t){return"echo 'do nothing.'"}testE2EDev(t){return"echo 'do nothing.'"}testStart(t){return"echo 'do nothing.'"}};const os=new class extends es{constructor(){super()}start(t,e){return`YARN concurrently --raw --kill-others-on-fail\n "remix dev ${e.normalizedArgsText??""}"\n "${this.waitAndOpenApp(t,e)}"`}startProduction(t,e,n){return`NODE_ENV=production YARN concurrently --raw --kill-others-on-fail\n "${Cn.reset(t)} && ${t.buildCommand} && PORT=${n} pm2-runtime start ${t.findFile("ecosystem.config.cjs")} ${e.normalizedArgsText??""}"\n "${this.waitAndOpenApp(t,e,n)}"`}testE2E(t,e,{playwrightArgs:n,startCommand:s=`${Cn.reset(t)} && ${t.buildCommand} && pm2-runtime start ${t.findFile("ecosystem.config.cjs")}`}){return super.testE2E(t,e,{playwrightArgs:n,prismaDirectory:"prisma",startCommand:s})}testE2EDev(t,e,{playwrightArgs:n,startCommand:s="remix dev"}){return super.testE2EDev(t,e,{playwrightArgs:n,startCommand:s})}testStart(t,e){return`YARN concurrently --kill-others --raw --success first "remix dev" "${this.waitApp(t,e)}"`}},as={command:"start [args..]",describe:"Start app",builder:{watch:{description:"Whether to watch files",type:"boolean"},args:{description:"Arguments for core command",type:"array",alias:"a",default:[]},"docker-options":{description:'Arguments for "docker run"',type:"array",default:[]},mode:{description:"Start mode: dev[elopment] (default) | staging | docker | docker-debug",type:"string",alias:"m"}},async handler(t){!function(t){t.normalizedArgsText=[...t.args??[],...t._?.slice(1)??[]].map((t=>`'${t}'`)).join(" "),t.normalizedDockerOptionsText=(t.dockerOptions??[]).map((t=>`'${t}'`)).join(" ")}(t);const e=await mn(t);e||(console.error(O.red("No project found.")),process.exit(1));for(const n of e.all){const e=n.packageJson.dependencies||{},s=n.packageJson.devDependencies||{};let i;if(e.blitz)i=ns;else if(e.next)i=is;else if(s["@remix-run/dev"])i=os;else if((e.express||e.fastify)&&!e["firebase-functions"]||n.hasDockerfile&&/EXPOSE\s+8080/.test(n.dockerfile))i=ss;else{if(!e["build-ts"]&&!s["build-ts"])continue;i=rs}switch(console.info(`Running "start" for ${n.name} ...`),t.mode||"dev"){case"dev":case"development":{const s=cs(e,"development");await Dn(`${s}${i.start(n,t)}`,n,t);break}case"staging":{const s=cs(e,"staging");await Dn(`${s}${i.startProduction(n,t,8080)}`,n,t);break}case"docker":{const s=cs(e,"staging");await Dn(`${s}${i.startDocker(n,t)}`,n,t);break}case"docker-debug":{const s=cs(e,"staging");t.normalizedArgsText="'/bin/bash'",await Dn(`${s}${i.startDocker(n,t)}`,n,t);break}default:throw new Error(`Unknown start mode: ${t.mode}`)}}}};function cs(t,e){process.env.WB_ENV||=e;let n=`WB_ENV=${process.env.WB_ENV} `;return t.next&&(process.env.NEXT_PUBLIC_WB_ENV=process.env.WB_ENV,n+=`NEXT_PUBLIC_WB_ENV=${process.env.WB_ENV} `),n}const ls={command:"test",describe:"Test project",builder:{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){const n=await mn(e);n||(console.error(O.red("No project found.")),process.exit(1));n.all.length>1&&(process.env.CI="1");process.env.FORCE_COLOR||="3",process.env.WB_ENV||="test";for(const s of n.all){const n=s.packageJson.dependencies||{},i=s.packageJson.devDependencies||{};let r;r=n.blitz?ns:n.next?is:i["@remix-run/dev"]?os:!n.express&&!n.fastify||n["firebase-functions"]?rs:ss,console.info(`Running "test" for ${s.name} ...`);const o=[];if(!e.ci){switch((e.unit||!e.start&&void 0===e.e2e)&&o.push(Dn(r.testUnit(s,e),s,e,{timeout:e.unitTimeout})),e.start&&o.push(Dn(r.testStart(s,e),s,e)),await Promise.all(o),e.e2e){case void 0:case"none":continue;case"":case"headless":await Dn(r.testE2E(s,e,{}),s,e);continue;case"headless-dev":await Dn(r.testE2EDev(s,e,{}),s,e);continue;case"docker":await hs(s,e,r);continue;case"docker-debug":await hs(s,e,r,"test tests/e2e --debug");continue}if(n.blitz||n.next||i["@remix-run/dev"])switch(e.e2e){case"headed":await Dn(r.testE2E(s,e,{playwrightArgs:"test tests/e2e --headed"}),s,e);continue;case"headed-dev":await Dn(r.testE2EDev(s,e,{playwrightArgs:"test tests/e2e --headed"}),s,e);continue;case"debug":await Dn(r.testE2E(s,e,{playwrightArgs:"test tests/e2e --debug"}),s,e);continue;case"generate":await Dn(r.testE2E(s,e,{playwrightArgs:"codegen http://localhost:8080"}),s,e);continue;case"trace":await Dn("playwright show-trace",s,e);continue}throw new Error(`Unknown e2e mode: ${e.e2e}`)}{const n=S(t.join(s.dirPath,"tests","unit")),i=S(t.join(s.dirPath,"tests","e2e"));if(await In(ts.stopAll(),s,e),!1!==e.unit&&await n&&await In(r.testUnit(s,e),s,e,{timeout:e.unitTimeout}),!1!==e.start&&await In(r.testStart(s,e),s,e),await Nn.promiseAll(),"none"!==e.e2e&&await i){s.hasDockerfile&&await Dn(`${r.buildDocker(s,"test")}`,s,e);const t=s.hasDockerfile?{startCommand:ts.stopAndStart(s,!0)}:{};process.exitCode=await Dn(r.testE2E(s,e,t),s,e,{exitIfFailed:!1}),await Dn(ts.stop(s),s,e)}}}}(e)}};async function hs(t,e,n,s){await Dn(`${n.buildDocker(t,"test")}`,t,e),process.exitCode=await Dn(`${n.testE2E(t,e,{playwrightArgs:s,startCommand:ts.stopAndStart(t,!0)})}`,t,e,{exitIfFailed:!1}),await Dn(ts.stop(t),t,e)}const ds={command:"typecheck",describe:"Run type checking. .env files are ignored.",builder:{},async handler(t){const e=await mn(t,!1);e||(console.error(O.red("No project found.")),process.exit(1));for(const n of e.all){const s=[];if(n.packageJson.workspaces||((n.packageJson.dependencies?.typescript||n.packageJson.devDependencies?.typescript)&&s.push("tsc --noEmit --Pretty"),n.packageJson.devDependencies?.pyright&&s.push("pyright")),0===s.length)continue;console.info(`Running "typecheck" for ${n.name} ...`),e.all.length>1&&(n.env.CI="1"),n.env.FORCE_COLOR||="3";if(0!==await Dn(s.join(" && "),n,t)){(JSON.parse(await $.readFile("package.json","utf8")).dependencies||{}).blitz&&console.info(O.yellow('Please try "yarn gen-code" if you face unknown type errors.'))}}}},us={...ds,command:"tc"},fs={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`). Preferred over `cascade-node-env` and `auto-cascade-env`.",type:"string"},"cascade-node-env":{description:'Same with --cascade-env=<NODE_ENV || "development">. Preferred over `auto-cascade-env`.',type:"boolean"},"auto-cascade-env":{description:'Same with --cascade-env=<WB_ENV || NODE_ENV || "development">.',type:"boolean",default:!0},"include-root-env":{description:"Include .env files in root directory if the project is in a monorepo and --env option is not used.",type:"boolean",default:!0},"check-env":{description:"Check whether the keys of the loaded .env files are same with the given .env file.",type:"string",default:".env.example"},verbose:{description:"Whether to show verbose information",type:"boolean",alias:"v"},"working-dir":{description:"A working directory",type:"string",alias:"w"},"dry-run":{description:"Whether to skip actual command execution",type:"boolean",alias:"d"}};var ps;await an((ps=process.argv,ps.slice(et()+1))).scriptName("wb").options(fs).middleware((e=>{const n=e["working-dir"];if(n){const e=t.resolve(n);process.chdir(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 n=e.toUpperCase();(n.startsWith("NPM_")||n.startsWith("YARN_")||n.startsWith("BERRY_")||"PROJECT_CWD"===n||"INIT_CWD"===n)&&delete t[e]}}(process.env)})).command(bn).command(jn).command(Tn).command(Xn).command(Zn).command(as).command(ls).command(ds).command(us).demandCommand().strict().help().argv;for(const t of["SIGINT","SIGTERM","SIGQUIT"])process.on(t,(()=>process.exit()));
34
34
  //# sourceMappingURL=index.js.map