@willbooster/wb 6.1.1 → 6.1.3

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
@@ -30,5 +30,5 @@ let U;!function(t){t.BOOLEAN="boolean",t.STRING="string",t.NUMBER="number",t.ARR
30
30
  * Copyright (c) 2016, Contributors
31
31
  * SPDX-License-Identifier: ISC
32
32
  */
33
- var Y,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===(Y=null===process||void 0===process?void 0:process.versions)||void 0===Y?void 0:Y.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=B(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=T(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 B(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)){(L(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)),B(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=q(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=q(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=>B(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=B,tt.decamelize=T,tt.looksLikeNumber=L;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 Bt,Tt,Lt,Vt,Ut,Ht,qt,Yt,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"),Be=Symbol("setKey"),Te=Symbol("unfreeze"),Le=Symbol("validateAsync"),Ve=Symbol("getCommandInstance"),Ue=Symbol("getContext"),He=Symbol("getHasOutput"),qe=Symbol("getLoggerInstance"),Ye=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,Bt.set(this,void 0),Tt.set(this,void 0),Lt.set(this,{commands:[],fullCommands:[]}),Vt.set(this,null),Ut.set(this,null),Ht.set(this,"show-hidden"),qt.set(this,null),Yt.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,Tt,e,"f"),Oe(this,re,n,"f"),Oe(this,Qt,new vt(this),"f"),this.$0=this[xe](),this[tn](),Oe(this,Bt,Ee(this,Bt,"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,Tt,"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,Bt,"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,Bt,"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[Be](t,!0),Ee(this,ye,"f").describe(t,e),this}detectLocale(t){return mt("<boolean>",[t],arguments.length),Oe(this,Yt,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,qt,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,Yt,"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,Bt,"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,Yt,!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,qt,"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[Te](),this.parsed=i})):(Ee(this,ae,"f")&&Ee(this,ae,"f").call(this,Ee(this,qt,"f"),s,Ee(this,se,"f")),this[Te](),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,Tt,"f"));return s[t]&&"object"==typeof s[t]&&(n=zt(s[t],e||Ee(this,Tt,"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,Lt,"f").fullCommands[Ee(this,Lt,"f").fullCommands.length-1],i=s?Ee(this,Bt,"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,Bt,"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,Yt,!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}[(Bt=new WeakMap,Tt=new WeakMap,Lt=new WeakMap,Vt=new WeakMap,Ut=new WeakMap,Ht=new WeakMap,qt=new WeakMap,Yt=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,qt,"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,Bt,"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,Tt,"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,Yt,"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}[Be](t,e){return this[Re](this[Be].bind(this),"key",t,e),this}[Te](){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,qt,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,Bt,"f").unfreeze(),Ee(this,Qt,"f").unfreeze()}[Le](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[qe].bind(this),getParseContext:this[Ye].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,Bt,"f")}[Ue](){return Ee(this,Lt,"f")}[He](){return Ee(this,Zt,"f")}[qe](){return Ee(this,ne,"f")}[Ye](){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,Bt,Ee(this,Bt,"f")?Ee(this,Bt,"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,Bt,"f"),Ee(this,fe,"f")),"f"),Ee(this,Qt,"f").reset(),Oe(this,Ut,null,"f"),Oe(this,se,"","f"),Oe(this,qt,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,Bt,"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,Bt,"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,Bt,"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,Bt,"f").hasDefaultCommand()&&!g){const t=Ee(this,Bt,"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[Le](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,ln;function hn(t,e){return function(n){(function(t,e){if(t.v)throw new Error("attempted to call "+e+" after decoration was finished")})(e,"addInitializer"),fn(n,"An initializer"),t.push(n)}}function dn(t,e){if(!t(e))throw new TypeError("Attempted to access private element on non-instance")}function un(t,e,n,s,i,r,o,a,c,l,h){var d;switch(r){case 1:d="accessor";break;case 2:d="method";break;case 3:d="getter";break;case 4:d="setter";break;default:d="field"}var u,f,p={kind:d,name:a?"#"+n:n,static:o,private:a,metadata:h},g={v:!1};if(0!==r&&(p.addInitializer=hn(i,g)),a||0!==r&&2!==r)if(2===r)u=function(t){return dn(l,t),s.value};else{var m=0===r||1===r;(m||3===r)&&(u=a?function(t){return dn(l,t),s.get.call(t)}:function(t){return s.get.call(t)}),(m||4===r)&&(f=a?function(t,e){dn(l,t),s.set.call(t,e)}:function(t,e){s.set.call(t,e)})}else u=function(t){return t[n]},0===r&&(f=function(t,e){t[n]=e});var y=a?l.bind():function(t){return n in t};p.access=u&&f?{get:u,set:f,has:y}:u?{get:u,has:y}:{set:f,has:y};try{return t.call(e,c,p)}finally{g.v=!0}}function fn(t,e){if("function"!=typeof t)throw new TypeError(e+" must be a function")}function pn(t,e){var n=typeof e;if(1===t){if("object"!==n||null===e)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");void 0!==e.get&&fn(e.get,"accessor.get"),void 0!==e.set&&fn(e.set,"accessor.set"),void 0!==e.init&&fn(e.init,"accessor.init")}else if("function"!==n){throw new TypeError((0===t?"field":5===t?"class":"method")+" decorators must return a function or void 0")}}function gn(t){return function(){return t(this)}}function mn(t){return function(e){t(this,e)}}function yn(t,e,n,s,i,r,o,a,c,l,h){var d,u,f,p,g,m,y=n[0];s||Array.isArray(y)||(y=[y]),a?d=0===r||1===r?{get:gn(n[3]),set:mn(n[4])}:3===r?{get:n[3]}:4===r?{set:n[3]}:{value:n[3]}:0!==r&&(d=Object.getOwnPropertyDescriptor(e,i)),1===r?f={get:d.get,set:d.set}:2===r?f=d.value:3===r?f=d.get:4===r&&(f=d.set);for(var b=s?2:1,v=y.length-1;v>=0;v-=b){var w;void 0!==(p=un(y[v],s?y[v-1]:void 0,i,d,c,r,o,a,f,l,h))&&(pn(r,p),0===r?w=p:1===r?(w=p.init,g=p.get||f.get,m=p.set||f.set,f={get:g,set:m}):f=p,void 0!==w&&(void 0===u?u=w:"function"==typeof u?u=[u,w]:u.push(w)))}if(0===r||1===r){if(void 0===u)u=function(t,e){return e};else if("function"!=typeof u){var O=u;u=function(t,e){for(var n=e,s=O.length-1;s>=0;s--)n=O[s].call(t,n);return n}}else{var E=u;u=function(t,e){return E.call(t,e)}}t.push(u)}0!==r&&(1===r?(d.get=f.get,d.set=f.set):2===r?d.value=f:3===r?d.get=f:4===r&&(d.set=f),a?1===r?(t.push((function(t,e){return f.get.call(t,e)})),t.push((function(t,e){return f.set.call(t,e)}))):2===r?t.push(f):t.push((function(t,e){return f.call(t,e)})):Object.defineProperty(e,i,d))}function bn(t,e){e&&t.push((function(t){for(var n=0;n<e.length;n++)e[n].call(t);return t}))}function vn(t,e){return Object.defineProperty(t,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:e})}function wn(t,e,n,s,i,r){if(arguments.length>=6)var o=r[Symbol.metadata||Symbol.for("Symbol.metadata")];var a=Object.create(void 0===o?null:o),c=function(t,e,n,s){for(var i,r,o,a=[],c=new Map,l=new Map,h=0;h<e.length;h++){var d=e[h];if(Array.isArray(d)){var u,f,p=d[1],g=d[2],m=d.length>3,y=16&p,b=!!(8&p),v=n;if(p&=7,b?(u=t,0!==p&&(f=r=r||[]),m&&!o&&(o=function(e){return On(e)===t}),v=o):(u=t.prototype,0!==p&&(f=i=i||[])),0!==p&&!m){var w=b?l:c,O=w.get(g)||0;if(!0===O||3===O&&4!==p||4===O&&3!==p)throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+g);w.set(g,!(!O&&p>2)||p)}yn(a,u,d,y,g,p,b,m,f,v,s)}}return bn(a,i),bn(a,r),a}(t,e,i,a);return n.length||vn(t,a),{e:c,get c(){return function(t,e,n,s){if(e.length){for(var i=[],r=t,o=t.name,a=n?2:1,c=e.length-1;c>=0;c-=a){var l={v:!1};try{var h=e[c].call(n?e[c-1]:void 0,r,{kind:"class",name:o,addInitializer:hn(i,l),metadata:s})}finally{l.v=!0}void 0!==h&&(pn(5,h),r=h)}return[vn(r,s),function(){for(var t=0;t<i.length;t++)i[t].call(r)}]}}(t,n,s,a)}}}function On(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 En(t,e){let n,s;if("getter"===e?.kind){let e=!1;return function(){return e||(e=!0,n=t.call(this)),n}}return function(...i){const r=JSON.stringify(i);return s!==r&&(s=r,n=e?t.call(this,...i):t(...i)),n}}class kn{static{[ln]=wn(this,[[En,2,"getBuildCommand"],[En,3,"rootDirPath"],[En,3,"dockerfile"],[En,3,"hasDockerfile"],[En,3,"name"],[En,3,"nameWithoutNamespace"],[En,3,"env"],[En,3,"packageJson"],[En,3,"rootPackageJson"],[En,3,"dockerPackageJson"]],[]).e}_pathByName=new Map;constructor(e,n,s){ln(this),this._dirPath=t.resolve(e),this.argv=n,this.loadEnv=s}getBuildCommand(t){return this.packageJson.scripts?.build?.includes("buildIfNeeded")?"yarn build":"YARN wb buildIfNeeded "+(t?.verbose?"--verbose":"")}get dirPath(){return this._dirPath}set dirPath(e){this._dirPath=t.resolve(e)}get rootDirPath(){return 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.rootPackageJson.name||"unknown"}get nameWithoutNamespace(){const t=this.rootPackageJson.name||"unknown",e=t.lastIndexOf("/");return-1===e?t:t.slice(e+1)}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 rootPackageJson(){return this.rootDirPath===this.dirPath?this.packageJson:JSON.parse(l.readFileSync(t.join(this.rootDirPath,"package.json"),"utf8"))}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"))}findFile(e){let n=this._pathByName.get(e);if(n)return n;if(n=[e,t.join("..","..",e)].find((t=>l.existsSync(t))),!n)throw new Error(`File not found: ${e}`);return this._pathByName.set(e,n),n}}function An(e,n=!0,s){if(s??=process.cwd(),l.existsSync(t.join(s,"package.json")))return new kn(s,e,n)}async function jn(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 kn(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 kn(i,e,n))}return{root:r,self:i}}(e,n,s);if(i)return{...i,all:i.root===i.self?await $n(e,i.root,n):[i.self]}}async function $n(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,"package.json");l.existsSync(o)&&i.push(new kn(o,e,s))}return i}const _n={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 An(e,!0,n);if(!s)return!0;if(!l.existsSync(t.join(s.rootDirPath,".git")))return xn(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])=>!Cn.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,stdio:"pipe",encoding:"utf8"}).stdout.trim().split("\n").map((e=>"test"===t.env.WB_ENV?e.replace(/packages\/scripts\/test-fixtures\/[^/]+\//,""):e)).filter((t=>(Pn.some((e=>t.includes(e)))||Sn.some((e=>t.endsWith(e))))&&!Nn.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(!xn(s,e))return;e.dryRun||await l.promises.writeFile(r,o,"utf8");return!0}(e)}};function xn(t,e){if(console.info(O.green(`Run '${e.command}'`)),!e.dryRun){const n=y.spawnSync(e.command??"",{cwd:t.dirPath,shell:!0,stdio:"inherit"});if(0!==n.status)return process.exitCode=n.status??1,!1}return!0}const Cn=new Set(["CI","PWDEBUG","TMPDIR"]);const Pn=["src/","public/"],Sn=[".js",".cjs",".mjs",".jsx",".ts",".cts",".mts",".tsx",".json",".browserslistrc","yarn.lock"],Nn=["test/","tests/","__tests__/","test-fixtures/","package.json"];function*Mn(t,e){for(const n of e)console.info(`Running "${t}" for ${n.name} ...`),yield n}const Dn={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 jn(e);if(!n)return;const s={stdio:"inherit"};for(const s of Mn("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(In(e,n),Rn(n),Wn(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",s)}};function In(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 Rn(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))))&&delete s[t]}function Wn(t){delete t.private,delete t.publishConfig,delete t.prettier}const zn=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`}},Fn=new Set;async function Bn(t){try{await k(t)}catch{}}const Tn=new A,Ln={exitIfFailed:!0};async function Vn(t,e,n,s=Ln){const[i,r]=Hn(t,e);if(qn(i,e),n.verbose&&qn(r,e,"Start (raw)",!0),n.dryRun)return Yn(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 Bn(t);const e=async()=>{Fn.has(t)||(Fn.add(t),await Bn(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 Yn(i,a.status,s),a.status??1}function Un(t,e,n,s=Ln){return Tn.run((async()=>{const[i,r]=Hn(t,e);if(qn(i,e,"Start (parallel)",!0),n.dryRun)return qn(i,e,"Started (log)"),n.verbose&&qn(r,e,"Started (raw)",!0),void Yn(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});qn(i,e,"Started (log)"),n.verbose&&qn(r,e,"Started (raw)",!0);const a=o.stdout.trim();a&&console.info(a),Yn(i,o.status,s)}))}function Hn(e,n){const s=function(e){if(Jn)return Gn;Jn=!0;let n=e.dirPath;for(;;){const s=t.join(n,"node_modules",".bin");if(l.existsSync(s)&&(e.env.PATH=`${s}:${e.env.PATH}`,Gn=!0),l.existsSync(t.join(n,".git")))break;const i=t.dirname(n);if(n===i)break;n=i}return Gn}(n),i=e.replaceAll("\n","").replaceAll(/\s\s+/g," ").replaceAll("PRISMA ",n.packageJson.dependencies?.blitz?"YARN blitz prisma ":"YARN prisma ").trim();return[i.replaceAll("YARN ","yarn "),i.replaceAll("YARN ",s?"":"yarn ")]}function qn(t,e,n="Start",s=!1){console.info("\n"+(s?O.gray:O.cyan)(O.bold(`${n}:`),t)+O.gray(` at ${e.dirPath}`))}function Yn(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))}let Jn=!1,Gn=!1;const Kn={},Qn={command:"prisma",describe:"Run prisma commands",builder:t=>t.command(Xn).command(ts).command(es).command(ns).command(ss).command(is).command(rs).command(os).command(as).demandCommand(),handler(){}},Xn={command:"deploy",describe:"Apply migration to DB without initializing it",builder:Kn,async handler(t){const e=await cs(t);for(const n of Mn("prisma deploy",e))await Vn(zn.deploy(n),n,t)}},Zn={...Kn,"backup-path":{description:"Whether to skip actual command execution",demandOption:!0,type:"string",alias:"b"}},ts={command:"deploy-force <backup-path>",describe:"Force to apply migration to DB utilizing Litestream's backup without initializing it",builder:Zn,async handler(t){const e=await cs(t);for(const n of Mn("prisma deploy-force",e))await Vn(zn.deployForce(n,t.backupPath),n,t)}},es={command:"litestream",describe:"Setup DB for Litestream",builder:Kn,async handler(t){const e=await cs(t);for(const n of Mn("prisma litestream",e))await Vn(zn.litestream(n),n,t)}},ns={command:"migrate",describe:"Apply migration to DB with initializing it",builder:Kn,async handler(t){const e=await cs(t);for(const n of Mn("prisma migrate",e))await Vn(zn.migrate(n),n,t)}},ss={command:"migrate-dev",describe:"Create a migration file",builder:Kn,async handler(t){const e=await cs(t);for(const n of Mn("prisma migrate-dev",e))await Vn(zn.migrateDev(n),n,t)}},is={command:"reset",describe:"Reset DB",builder:Kn,async handler(t){const e=await cs(t);for(const n of Mn("prisma reset",e))await Vn(zn.reset(n),n,t)}},rs={command:"restore <backup-path>",describe:"Restore DB from Litestream's backup",builder:{...Zn,output:{description:'Output path of the restored database. Defaults to "<db|prisma>/restored.sqlite3".',type:"string"}},async handler(t){const e=await cs(t);for(const n of Mn("prisma restore",e)){const e=t.output||(n.packageJson.dependencies?.blitz?"db/restored.sqlite3":"prisma/restored.sqlite3");await Vn(zn.restore(n,t.backupPath,e),n,t)}}},os={command:"seed",describe:"Populate DB with seed data",builder:{...Kn,file:{alias:"f",description:"Path of the seed script.",type:"string"}},async handler(t){const e=await cs(t);for(const n of Mn("prisma seed",e))await Vn(zn.seed(n,t.file),n,t)}},as={command:"studio [db-url-or-path]",describe:"Open Prisma Studio",builder:{...Kn,"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 cs(t);for(const n of Mn("prisma studio",e)){const e=t.restored?n.packageJson.dependencies?.blitz?"db/restored.sqlite3":"prisma/restored.sqlite3":t.dbUrlOrPath?.toString();await Vn(zn.studio(n,e),n,t)}}};async function cs(t){const e=await jn(t);return e?e.all.filter((t=>t.packageJson.dependencies?.prisma||t.packageJson.devDependencies?.prisma)):[]}const ls={command:"retry",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=An(t);if(!e)return;const n=t._.slice(1);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 Vn(n.join(" "),e,t,{exitIfFailed:!1}),0===s)return;process.exit(s)}},hs={command:"setup",describe:"Setup development environment. .env files are ignored.",builder:{},async handler(t){await async function(t,e){const n=await jn(t,!1,e);if(!n)return;for(const e of Mn("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 Un(`brew install ${n.join(" ")}`,e,t)}s.some((t=>t.isFile()&&t.name.includes("-version")))&&await Vn("asdf install",e,t)}if(s.some((t=>t.isFile()&&"pyproject.toml"===t.name))){await Un("poetry config virtualenvs.in-project true",e,t),await Un("poetry config virtualenvs.prefer-active-python true",e,t);const[,n]=y.execSync("asdf current python").toString().trim().split(/\s+/);await Un(`poetry env use ${n}`,e,t),await Tn.promiseAll(),await Vn("poetry run pip install --upgrade pip",e,t),await Vn("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 Vn(`yarn add ${a.join(" ")}`,e,t),c.length>0&&await Vn(`yarn add -D ${c.join(" ")}`,e,t),o["gen-code"]&&await Vn("yarn gen-code",e,t)}}(t)}};const ds=new class{buildDevImage(e){const n=e.dockerPackageJson.scripts?.["docker/build/prepare"]?"yarn run docker/build/prepare && ":"";return`cd ${t.dirname(e.findFile("Dockerfile"))}\n && ${n}YARN wb optimizeForDockerBuild --outside\n && YARN wb retry -- docker build -t ${e.nameWithoutNamespace}\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=dev .`}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(Fn.has(t))return;Fn.add(t),qn(t,e);const{status:n}=v(t,{cwd:e.dirPath,shell:!0,stdio:"inherit"});Yn(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.nameWithoutNamespace} ${e} ${t.nameWithoutNamespace} ${n}`}stop(t){return`true $(docker rm -f $(docker container ls -q -f name=${t.nameWithoutNamespace}) 2> /dev/null)`}stopAll(){return"true $(docker rm -f $(docker ps -q) 2> /dev/null)"}};class us{constructor(t=3e3){this.defaultPort=t}buildDocker(t){return ds.buildDevImage(t)}startDocker(t,e){return`${this.buildDocker(t)}\n && YARN concurrently --raw --kill-others-on-fail\n "${ds.stopAndStart(t,!1,e.normalizedDockerArgsText??"",e.normalizedArgsText??"")}"\n "${this.waitAndOpenApp(t,e,8080)}"`}testE2E(t,e,{playwrightArgs:n,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,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://localhost:${n}`}}const fs=new class extends us{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 "${zn.reset(t)} && ${t.getBuildCommand(e)} && PORT=${n} pm2-runtime start ${t.findFile("ecosystem.config.cjs")} ${e.normalizedArgsText??""}"\n "${this.waitAndOpenApp(t,e,n)}"`}testE2E(t,e,{playwrightArgs:n="test tests/e2e",startCommand:s=`${zn.reset(t)} && ${t.getBuildCommand(e)} && pm2-runtime start ${t.findFile("ecosystem.config.cjs")}`}){return super.testE2E(t,e,{playwrightArgs:n,prismaDirectory:"db",startCommand:s})}testE2EDev(t,e,{playwrightArgs:n="test tests/e2e",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 ps=new class extends us{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)} && ${ds.stopAndStart(t,!1,e.normalizedDockerArgsText??"",e.normalizedArgsText??"")}`}startProduction(t,e,n=8080){return`NODE_ENV=production ${t.getBuildCommand(e)} && 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 gs=new class extends us{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 "${zn.reset(t)} && ${t.getBuildCommand(e)} && PORT=${n} pm2-runtime start ${t.findFile("ecosystem.config.cjs")} ${e.normalizedArgsText??""}"\n "${this.waitAndOpenApp(t,e,n)}"`}testE2E(t,e,{playwrightArgs:n="test tests/e2e",startCommand:s=`${zn.reset(t)} && ${t.getBuildCommand(e)} && pm2-runtime start ${t.findFile("ecosystem.config.cjs")}`}){return super.testE2E(t,e,{playwrightArgs:n,prismaDirectory:"db",startCommand:s})}testE2EDev(t,e,{playwrightArgs:n="test tests/e2e",startCommand:s="next dev -p 8080"}){return super.testE2EDev(t,e,{playwrightArgs:n,startCommand:s})}testStart(t,e){return`YARN concurrently --kill-others --raw --success first "next dev" "${this.waitApp(t,e)}"`}};const ms=new class extends us{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)} && ${ds.stopAndStart(t,!1,e.normalizedDockerArgsText??"",e.normalizedArgsText??"")}`}startProduction(t,e){return`NODE_ENV=production ${t.getBuildCommand(e)} && 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 ys=new class extends us{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 "${zn.reset(t)} && ${t.getBuildCommand(e)} && PORT=${n} pm2-runtime start ${t.findFile("ecosystem.config.cjs")} ${e.normalizedArgsText??""}"\n "${this.waitAndOpenApp(t,e,n)}"`}testE2E(t,e,{playwrightArgs:n="test tests/e2e",startCommand:s=`${zn.reset(t)} && ${t.getBuildCommand(e)} && pm2-runtime start ${t.findFile("ecosystem.config.cjs")}`}){return super.testE2E(t,e,{playwrightArgs:n,prismaDirectory:"prisma",startCommand:s})}testE2EDev(t,e,{playwrightArgs:n="test tests/e2e",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)}"`}},bs={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-args":{description:'Arguments for "docker run"',type:"array",default:[]},mode:{description:"Start mode: dev[elopment] (default) | staging | docker",type:"string",alias:"m"}},async handler(t){!function(t){t.normalizedArgsText=[...t.args??[],...t._?.slice(1)??[]].map((t=>`'${t}'`)).join(" "),t.normalizedDockerArgsText=(t.dockerArgs??[]).map((t=>`'${t}'`)).join(" ")}(t);const e=await jn(t);if(e)for(const n of e.all){const e=n.packageJson.dependencies||{},s=n.packageJson.devDependencies||{};let i;if(e.blitz)i=fs;else if(e.next)i=gs;else if(s["@remix-run/dev"])i=ys;else if((e.express||e.fastify)&&!e["firebase-functions"]||n.hasDockerfile&&/EXPOSE\s+8080/.test(n.dockerfile))i=ps;else{if(!e["build-ts"]&&!s["build-ts"])continue;i=ms}switch(console.info(`Running "start" for ${n.name} ...`),t.mode||"dev"){case"dev":case"development":{const s=vs(n,e,"development");await Vn(`${s}${i.start(n,t)}`,n,t);break}case"staging":{const s=vs(n,e,"staging");await Vn(`${s}${i.startProduction(n,t,8080)}`,n,t);break}case"docker":{const s=vs(n,e,"staging");await Vn(`${s}${i.startDocker(n,t)}`,n,t);break}default:throw new Error(`Unknown start mode: ${t.mode}`)}}}};function vs(t,e,n){t.env.WB_ENV||=n;let s=`WB_ENV=${t.env.WB_ENV} `;return e.next&&(t.env.NEXT_PUBLIC_WB_ENV=t.env.WB_ENV,s+=`NEXT_PUBLIC_WB_ENV=${t.env.WB_ENV} `),s}const ws={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 jn(e);if(!n)return;for(const s of n.all){const i=s.packageJson.dependencies||{},r=s.packageJson.devDependencies||{};let o;o=i.blitz?fs:i.next?gs:r["@remix-run/dev"]?ys:!i.express&&!i.fastify||i["firebase-functions"]?ms:ps,console.info(`Running "test" for ${s.name} ...`),n.all.length>1&&(s.env.CI="1"),s.env.FORCE_COLOR||="3",s.env.WB_ENV||="test";const a=[];if(e.ci){const n=S(t.join(s.dirPath,"tests","unit")),i=S(t.join(s.dirPath,"tests","e2e"));if(await Un(ds.stopAll(),s,e),!1!==e.unit&&await n&&await Un(o.testUnit(s,e),s,e,{timeout:e.unitTimeout}),!1!==e.start&&await Un(o.testStart(s,e),s,e),await Tn.promiseAll(),"none"!==e.e2e&&await i){s.hasDockerfile&&await Vn(`${o.buildDocker(s)}`,s,e);const t=s.hasDockerfile?{startCommand:ds.stopAndStart(s,!0)}:{};process.exitCode=await Vn(o.testE2E(s,e,t),s,e,{exitIfFailed:!1}),await Vn(ds.stop(s),s,e)}return}switch((e.unit||!e.start&&void 0===e.e2e)&&a.push(Vn(o.testUnit(s,e),s,e,{timeout:e.unitTimeout})),e.start&&a.push(Vn(o.testStart(s,e),s,e)),await Promise.all(a),e.e2e){case void 0:case"none":return;case"":case"headless":return void await Vn(o.testE2E(s,e,{}),s,e);case"headless-dev":return void await Vn(o.testE2EDev(s,e,{}),s,e);case"docker":return void await Os(s,e,o);case"docker-debug":return void await Os(s,e,o,"PWDEBUG=1 ")}if(i.blitz||i.next||r["@remix-run/dev"])switch(e.e2e){case"headed":return void await Vn(o.testE2E(s,e,{playwrightArgs:"test tests/e2e --headed"}),s,e);case"headed-dev":return void await Vn(o.testE2EDev(s,e,{playwrightArgs:"test tests/e2e --headed"}),s,e);case"debug":return void await Vn(`PWDEBUG=1 ${o.testE2E(s,e,{})}`,s,e);case"generate":return void await Vn(o.testE2E(s,e,{playwrightArgs:"codegen http://localhost:8080"}),s,e);case"trace":return void await Vn("playwright show-trace",s,e)}throw new Error(`Unknown e2e mode: ${e.e2e}`)}}(e)}};async function Os(t,e,n,s=""){await Vn(`${n.buildDocker(t)}`,t,e),process.exitCode=await Vn(`${s}${n.testE2E(t,e,{startCommand:ds.stopAndStart(t,!0)})}`,t,e,{exitIfFailed:!1}),await Vn(ds.stop(t),t,e)}const Es={command:"typecheck",describe:"Run type checking. .env files are ignored.",builder:{},async handler(t){const e=await jn(t,!1);if(e)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 Vn(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.'))}}}},ks={...Es,command:"tc"},As={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 js;await an((js=process.argv,js.slice(et()+1))).scriptName("wb").options(As).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(_n).command(Dn).command(Qn).command(ls).command(hs).command(bs).command(ws).command(Es).command(ks).demandCommand().strict().help().argv;for(const t of["SIGINT","SIGTERM","SIGQUIT"])process.on(t,(()=>process.exit()));
33
+ var Y,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===(Y=null===process||void 0===process?void 0:process.versions)||void 0===Y?void 0:Y.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=B(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=T(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 B(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)){(L(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)),B(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=q(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=q(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=>B(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=B,tt.decamelize=T,tt.looksLikeNumber=L;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 Bt,Tt,Lt,Vt,Ut,Ht,qt,Yt,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"),Be=Symbol("setKey"),Te=Symbol("unfreeze"),Le=Symbol("validateAsync"),Ve=Symbol("getCommandInstance"),Ue=Symbol("getContext"),He=Symbol("getHasOutput"),qe=Symbol("getLoggerInstance"),Ye=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,Bt.set(this,void 0),Tt.set(this,void 0),Lt.set(this,{commands:[],fullCommands:[]}),Vt.set(this,null),Ut.set(this,null),Ht.set(this,"show-hidden"),qt.set(this,null),Yt.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,Tt,e,"f"),Oe(this,re,n,"f"),Oe(this,Qt,new vt(this),"f"),this.$0=this[xe](),this[tn](),Oe(this,Bt,Ee(this,Bt,"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,Tt,"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,Bt,"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,Bt,"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[Be](t,!0),Ee(this,ye,"f").describe(t,e),this}detectLocale(t){return mt("<boolean>",[t],arguments.length),Oe(this,Yt,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,qt,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,Yt,"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,Bt,"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,Yt,!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,qt,"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[Te](),this.parsed=i})):(Ee(this,ae,"f")&&Ee(this,ae,"f").call(this,Ee(this,qt,"f"),s,Ee(this,se,"f")),this[Te](),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,Tt,"f"));return s[t]&&"object"==typeof s[t]&&(n=zt(s[t],e||Ee(this,Tt,"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,Lt,"f").fullCommands[Ee(this,Lt,"f").fullCommands.length-1],i=s?Ee(this,Bt,"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,Bt,"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,Yt,!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}[(Bt=new WeakMap,Tt=new WeakMap,Lt=new WeakMap,Vt=new WeakMap,Ut=new WeakMap,Ht=new WeakMap,qt=new WeakMap,Yt=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,qt,"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,Bt,"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,Tt,"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,Yt,"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}[Be](t,e){return this[Re](this[Be].bind(this),"key",t,e),this}[Te](){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,qt,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,Bt,"f").unfreeze(),Ee(this,Qt,"f").unfreeze()}[Le](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[qe].bind(this),getParseContext:this[Ye].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,Bt,"f")}[Ue](){return Ee(this,Lt,"f")}[He](){return Ee(this,Zt,"f")}[qe](){return Ee(this,ne,"f")}[Ye](){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,Bt,Ee(this,Bt,"f")?Ee(this,Bt,"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,Bt,"f"),Ee(this,fe,"f")),"f"),Ee(this,Qt,"f").reset(),Oe(this,Ut,null,"f"),Oe(this,se,"","f"),Oe(this,qt,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,Bt,"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,Bt,"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,Bt,"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,Bt,"f").hasDefaultCommand()&&!g){const t=Ee(this,Bt,"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[Le](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,ln;function hn(t,e){return function(n){(function(t,e){if(t.v)throw new Error("attempted to call "+e+" after decoration was finished")})(e,"addInitializer"),fn(n,"An initializer"),t.push(n)}}function dn(t,e){if(!t(e))throw new TypeError("Attempted to access private element on non-instance")}function un(t,e,n,s,i,r,o,a,c,l,h){var d;switch(r){case 1:d="accessor";break;case 2:d="method";break;case 3:d="getter";break;case 4:d="setter";break;default:d="field"}var u,f,p={kind:d,name:a?"#"+n:n,static:o,private:a,metadata:h},g={v:!1};if(0!==r&&(p.addInitializer=hn(i,g)),a||0!==r&&2!==r)if(2===r)u=function(t){return dn(l,t),s.value};else{var m=0===r||1===r;(m||3===r)&&(u=a?function(t){return dn(l,t),s.get.call(t)}:function(t){return s.get.call(t)}),(m||4===r)&&(f=a?function(t,e){dn(l,t),s.set.call(t,e)}:function(t,e){s.set.call(t,e)})}else u=function(t){return t[n]},0===r&&(f=function(t,e){t[n]=e});var y=a?l.bind():function(t){return n in t};p.access=u&&f?{get:u,set:f,has:y}:u?{get:u,has:y}:{set:f,has:y};try{return t.call(e,c,p)}finally{g.v=!0}}function fn(t,e){if("function"!=typeof t)throw new TypeError(e+" must be a function")}function pn(t,e){var n=typeof e;if(1===t){if("object"!==n||null===e)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");void 0!==e.get&&fn(e.get,"accessor.get"),void 0!==e.set&&fn(e.set,"accessor.set"),void 0!==e.init&&fn(e.init,"accessor.init")}else if("function"!==n){throw new TypeError((0===t?"field":5===t?"class":"method")+" decorators must return a function or void 0")}}function gn(t){return function(){return t(this)}}function mn(t){return function(e){t(this,e)}}function yn(t,e,n,s,i,r,o,a,c,l,h){var d,u,f,p,g,m,y=n[0];s||Array.isArray(y)||(y=[y]),a?d=0===r||1===r?{get:gn(n[3]),set:mn(n[4])}:3===r?{get:n[3]}:4===r?{set:n[3]}:{value:n[3]}:0!==r&&(d=Object.getOwnPropertyDescriptor(e,i)),1===r?f={get:d.get,set:d.set}:2===r?f=d.value:3===r?f=d.get:4===r&&(f=d.set);for(var b=s?2:1,v=y.length-1;v>=0;v-=b){var w;void 0!==(p=un(y[v],s?y[v-1]:void 0,i,d,c,r,o,a,f,l,h))&&(pn(r,p),0===r?w=p:1===r?(w=p.init,g=p.get||f.get,m=p.set||f.set,f={get:g,set:m}):f=p,void 0!==w&&(void 0===u?u=w:"function"==typeof u?u=[u,w]:u.push(w)))}if(0===r||1===r){if(void 0===u)u=function(t,e){return e};else if("function"!=typeof u){var O=u;u=function(t,e){for(var n=e,s=O.length-1;s>=0;s--)n=O[s].call(t,n);return n}}else{var E=u;u=function(t,e){return E.call(t,e)}}t.push(u)}0!==r&&(1===r?(d.get=f.get,d.set=f.set):2===r?d.value=f:3===r?d.get=f:4===r&&(d.set=f),a?1===r?(t.push((function(t,e){return f.get.call(t,e)})),t.push((function(t,e){return f.set.call(t,e)}))):2===r?t.push(f):t.push((function(t,e){return f.call(t,e)})):Object.defineProperty(e,i,d))}function bn(t,e){e&&t.push((function(t){for(var n=0;n<e.length;n++)e[n].call(t);return t}))}function vn(t,e){return Object.defineProperty(t,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:e})}function wn(t,e,n,s,i,r){if(arguments.length>=6)var o=r[Symbol.metadata||Symbol.for("Symbol.metadata")];var a=Object.create(void 0===o?null:o),c=function(t,e,n,s){for(var i,r,o,a=[],c=new Map,l=new Map,h=0;h<e.length;h++){var d=e[h];if(Array.isArray(d)){var u,f,p=d[1],g=d[2],m=d.length>3,y=16&p,b=!!(8&p),v=n;if(p&=7,b?(u=t,0!==p&&(f=r=r||[]),m&&!o&&(o=function(e){return On(e)===t}),v=o):(u=t.prototype,0!==p&&(f=i=i||[])),0!==p&&!m){var w=b?l:c,O=w.get(g)||0;if(!0===O||3===O&&4!==p||4===O&&3!==p)throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+g);w.set(g,!(!O&&p>2)||p)}yn(a,u,d,y,g,p,b,m,f,v,s)}}return bn(a,i),bn(a,r),a}(t,e,i,a);return n.length||vn(t,a),{e:c,get c(){return function(t,e,n,s){if(e.length){for(var i=[],r=t,o=t.name,a=n?2:1,c=e.length-1;c>=0;c-=a){var l={v:!1};try{var h=e[c].call(n?e[c-1]:void 0,r,{kind:"class",name:o,addInitializer:hn(i,l),metadata:s})}finally{l.v=!0}void 0!==h&&(pn(5,h),r=h)}return[vn(r,s),function(){for(var t=0;t<i.length;t++)i[t].call(r)}]}}(t,n,s,a)}}}function On(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 En(t,e){let n,s;if("getter"===e?.kind){let e=!1;return function(){return e||(e=!0,n=t.call(this)),n}}return function(...i){const r=JSON.stringify(i);return s!==r&&(s=r,n=e?t.call(this,...i):t(...i)),n}}class kn{static{[ln]=wn(this,[[En,2,"getBuildCommand"],[En,3,"rootDirPath"],[En,3,"dockerfile"],[En,3,"hasDockerfile"],[En,3,"name"],[En,3,"nameWithoutNamespace"],[En,3,"env"],[En,3,"packageJson"],[En,3,"rootPackageJson"],[En,3,"dockerPackageJson"]],[]).e}_pathByName=new Map;constructor(e,n,s){ln(this),this._dirPath=t.resolve(e),this.argv=n,this.loadEnv=s}getBuildCommand(t){return this.packageJson.scripts?.build?.includes("buildIfNeeded")?"yarn build":"YARN wb buildIfNeeded "+(t?.verbose?"--verbose":"")}get dirPath(){return this._dirPath}set dirPath(e){this._dirPath=t.resolve(e)}get rootDirPath(){return 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.rootPackageJson.name||"unknown"}get nameWithoutNamespace(){const t=this.rootPackageJson.name||"unknown",e=t.lastIndexOf("/");return-1===e?t:t.slice(e+1)}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 rootPackageJson(){return this.rootDirPath===this.dirPath?this.packageJson:JSON.parse(l.readFileSync(t.join(this.rootDirPath,"package.json"),"utf8"))}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"))}findFile(e){let n=this._pathByName.get(e);if(n)return n;if(n=[e,t.join("..","..",e)].find((t=>l.existsSync(t))),!n)throw new Error(`File not found: ${e}`);return this._pathByName.set(e,n),n}}function An(e,n=!0,s){if(s??=process.cwd(),l.existsSync(t.join(s,"package.json")))return new kn(s,e,n)}async function jn(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 kn(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 kn(i,e,n))}return{root:r,self:i}}(e,n,s);if(i)return{...i,all:i.root===i.self?await $n(e,i.root,n):[i.self]}}async function $n(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,"package.json");l.existsSync(o)&&i.push(new kn(o,e,s))}return i}const _n={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 An(e,!0,n);if(!s)return!0;if(!l.existsSync(t.join(s.rootDirPath,".git")))return xn(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])=>!Cn.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=>(Pn.some((e=>t.includes(e)))||Sn.some((e=>t.endsWith(e))))&&!Nn.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(!xn(s,e))return;e.dryRun||await l.promises.writeFile(r,o,"utf8");return!0}(e)}};function xn(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 Cn=new Set(["CI","PWDEBUG","TMPDIR"]);const Pn=["src/","public/"],Sn=[".js",".cjs",".mjs",".jsx",".ts",".cts",".mts",".tsx",".json",".browserslistrc","yarn.lock"],Nn=["test/","tests/","__tests__/","test-fixtures/","package.json"];function*Mn(t,e){for(const n of e)console.info(`Running "${t}" for ${n.name} ...`),yield n}const Dn={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 jn(e);if(n){for(const s of Mn("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(In(e,n),Rn(n),Wn(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 In(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 Rn(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))))&&delete s[t]}function Wn(t){delete t.private,delete t.publishConfig,delete t.prettier}const zn=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`}},Fn=new Set;async function Bn(t){try{await k(t)}catch{}}const Tn=new A,Ln={exitIfFailed:!0};async function Vn(t,e,n,s=Ln){const[i,r]=Hn(t,e);if(qn(i,e),n.verbose&&qn(r,e,"Start (raw)",!0),n.dryRun)return Yn(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 Bn(t);const e=async()=>{Fn.has(t)||(Fn.add(t),await Bn(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 Yn(i,a.status,s),a.status??1}function Un(t,e,n,s=Ln){return Tn.run((async()=>{const[i,r]=Hn(t,e);if(qn(i,e,"Start (parallel)",!0),n.dryRun)return qn(i,e,"Started (log)"),n.verbose&&qn(r,e,"Started (raw)",!0),void Yn(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});qn(i,e,"Started (log)"),n.verbose&&qn(r,e,"Started (raw)",!0);const a=o.stdout.trim();a&&console.info(a),Yn(i,o.status,s)}))}function Hn(e,n){const s=function(e){if(Jn)return Gn;Jn=!0;let n=e.dirPath;for(;;){const s=t.join(n,"node_modules",".bin");if(l.existsSync(s)&&(e.env.PATH=`${s}:${e.env.PATH}`,Gn=!0),l.existsSync(t.join(n,".git")))break;const i=t.dirname(n);if(n===i)break;n=i}return Gn}(n),i=e.replaceAll("\n","").replaceAll(/\s\s+/g," ").replaceAll("PRISMA ",n.packageJson.dependencies?.blitz?"YARN blitz prisma ":"YARN prisma ").trim();return[i.replaceAll("YARN ","yarn "),i.replaceAll("YARN ",s?"":"yarn ")]}function qn(t,e,n="Start",s=!1){console.info("\n"+(s?O.gray:O.cyan)(O.bold(`${n}:`),t)+O.gray(` at ${e.dirPath}`))}function Yn(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))}let Jn=!1,Gn=!1;const Kn={},Qn={command:"prisma",describe:"Run prisma commands",builder:t=>t.command(Xn).command(ts).command(es).command(ns).command(ss).command(is).command(rs).command(os).command(as).demandCommand(),handler(){}},Xn={command:"deploy",describe:"Apply migration to DB without initializing it",builder:Kn,async handler(t){const e=await cs(t);for(const n of Mn("prisma deploy",e))await Vn(zn.deploy(n),n,t)}},Zn={...Kn,"backup-path":{description:"Whether to skip actual command execution",demandOption:!0,type:"string",alias:"b"}},ts={command:"deploy-force <backup-path>",describe:"Force to apply migration to DB utilizing Litestream's backup without initializing it",builder:Zn,async handler(t){const e=await cs(t);for(const n of Mn("prisma deploy-force",e))await Vn(zn.deployForce(n,t.backupPath),n,t)}},es={command:"litestream",describe:"Setup DB for Litestream",builder:Kn,async handler(t){const e=await cs(t);for(const n of Mn("prisma litestream",e))await Vn(zn.litestream(n),n,t)}},ns={command:"migrate",describe:"Apply migration to DB with initializing it",builder:Kn,async handler(t){const e=await cs(t);for(const n of Mn("prisma migrate",e))await Vn(zn.migrate(n),n,t)}},ss={command:"migrate-dev",describe:"Create a migration file",builder:Kn,async handler(t){const e=await cs(t);for(const n of Mn("prisma migrate-dev",e))await Vn(zn.migrateDev(n),n,t)}},is={command:"reset",describe:"Reset DB",builder:Kn,async handler(t){const e=await cs(t);for(const n of Mn("prisma reset",e))await Vn(zn.reset(n),n,t)}},rs={command:"restore <backup-path>",describe:"Restore DB from Litestream's backup",builder:{...Zn,output:{description:'Output path of the restored database. Defaults to "<db|prisma>/restored.sqlite3".',type:"string"}},async handler(t){const e=await cs(t);for(const n of Mn("prisma restore",e)){const e=t.output||(n.packageJson.dependencies?.blitz?"db/restored.sqlite3":"prisma/restored.sqlite3");await Vn(zn.restore(n,t.backupPath,e),n,t)}}},os={command:"seed",describe:"Populate DB with seed data",builder:{...Kn,file:{alias:"f",description:"Path of the seed script.",type:"string"}},async handler(t){const e=await cs(t);for(const n of Mn("prisma seed",e))await Vn(zn.seed(n,t.file),n,t)}},as={command:"studio [db-url-or-path]",describe:"Open Prisma Studio",builder:{...Kn,"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 cs(t);for(const n of Mn("prisma studio",e)){const e=t.restored?n.packageJson.dependencies?.blitz?"db/restored.sqlite3":"prisma/restored.sqlite3":t.dbUrlOrPath?.toString();await Vn(zn.studio(n,e),n,t)}}};async function cs(t){const e=await jn(t);return e?e.all.filter((t=>t.packageJson.dependencies?.prisma||t.packageJson.devDependencies?.prisma)):[]}const ls={command:"retry",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=An(t);if(!e)return;const n=t._.slice(1);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 Vn(n.join(" "),e,t,{exitIfFailed:!1}),0===s)return;process.exit(s)}},hs={command:"setup",describe:"Setup development environment. .env files are ignored.",builder:{},async handler(t){await async function(t,e){const n=await jn(t,!1,e);if(!n)return;for(const e of Mn("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 Un(`brew install ${n.join(" ")}`,e,t)}s.some((t=>t.isFile()&&t.name.includes("-version")))&&await Vn("asdf install",e,t)}if(s.some((t=>t.isFile()&&"pyproject.toml"===t.name))){await Un("poetry config virtualenvs.in-project true",e,t),await Un("poetry config virtualenvs.prefer-active-python true",e,t);const[,n]=y.execSync("asdf current python").toString().trim().split(/\s+/);await Un(`poetry env use ${n}`,e,t),await Tn.promiseAll(),await Vn("poetry run pip install --upgrade pip",e,t),await Vn("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 Vn(`yarn add ${a.join(" ")}`,e,t),c.length>0&&await Vn(`yarn add -D ${c.join(" ")}`,e,t),o["gen-code"]&&await Vn("yarn gen-code",e,t)}}(t)}};const ds=new class{buildDevImage(e){const n=e.dockerPackageJson.scripts?.["docker/build/prepare"]?"yarn run docker/build/prepare && ":"";return`cd ${t.dirname(e.findFile("Dockerfile"))}\n && ${n}YARN wb optimizeForDockerBuild --outside\n && YARN wb retry -- docker build -t ${e.nameWithoutNamespace}\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=dev .`}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(Fn.has(t))return;Fn.add(t),qn(t,e);const{status:n}=v(t,{cwd:e.dirPath,shell:!0,stdio:"inherit"});Yn(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.nameWithoutNamespace} ${e} ${t.nameWithoutNamespace} ${n}`}stop(t){return`true $(docker rm -f $(docker container ls -q -f name=${t.nameWithoutNamespace}) 2> /dev/null)`}stopAll(){return"true $(docker rm -f $(docker ps -q) 2> /dev/null)"}};class us{constructor(t=3e3){this.defaultPort=t}buildDocker(t){return ds.buildDevImage(t)}startDocker(t,e){return`${this.buildDocker(t)}\n && YARN concurrently --raw --kill-others-on-fail\n "${ds.stopAndStart(t,!1,e.normalizedDockerArgsText??"",e.normalizedArgsText??"")}"\n "${this.waitAndOpenApp(t,e,8080)}"`}testE2E(t,e,{playwrightArgs:n,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,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://localhost:${n}`}}const fs=new class extends us{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 "${zn.reset(t)} && ${t.getBuildCommand(e)} && PORT=${n} pm2-runtime start ${t.findFile("ecosystem.config.cjs")} ${e.normalizedArgsText??""}"\n "${this.waitAndOpenApp(t,e,n)}"`}testE2E(t,e,{playwrightArgs:n="test tests/e2e",startCommand:s=`${zn.reset(t)} && ${t.getBuildCommand(e)} && pm2-runtime start ${t.findFile("ecosystem.config.cjs")}`}){return super.testE2E(t,e,{playwrightArgs:n,prismaDirectory:"db",startCommand:s})}testE2EDev(t,e,{playwrightArgs:n="test tests/e2e",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 ps=new class extends us{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)} && ${ds.stopAndStart(t,!1,e.normalizedDockerArgsText??"",e.normalizedArgsText??"")}`}startProduction(t,e,n=8080){return`NODE_ENV=production ${t.getBuildCommand(e)} && 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 gs=new class extends us{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 "${zn.reset(t)} && ${t.getBuildCommand(e)} && PORT=${n} pm2-runtime start ${t.findFile("ecosystem.config.cjs")} ${e.normalizedArgsText??""}"\n "${this.waitAndOpenApp(t,e,n)}"`}testE2E(t,e,{playwrightArgs:n="test tests/e2e",startCommand:s=`${zn.reset(t)} && ${t.getBuildCommand(e)} && pm2-runtime start ${t.findFile("ecosystem.config.cjs")}`}){return super.testE2E(t,e,{playwrightArgs:n,prismaDirectory:"db",startCommand:s})}testE2EDev(t,e,{playwrightArgs:n="test tests/e2e",startCommand:s="next dev -p 8080"}){return super.testE2EDev(t,e,{playwrightArgs:n,startCommand:s})}testStart(t,e){return`YARN concurrently --kill-others --raw --success first "next dev" "${this.waitApp(t,e)}"`}};const ms=new class extends us{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)} && ${ds.stopAndStart(t,!1,e.normalizedDockerArgsText??"",e.normalizedArgsText??"")}`}startProduction(t,e){return`NODE_ENV=production ${t.getBuildCommand(e)} && 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 ys=new class extends us{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 "${zn.reset(t)} && ${t.getBuildCommand(e)} && PORT=${n} pm2-runtime start ${t.findFile("ecosystem.config.cjs")} ${e.normalizedArgsText??""}"\n "${this.waitAndOpenApp(t,e,n)}"`}testE2E(t,e,{playwrightArgs:n="test tests/e2e",startCommand:s=`${zn.reset(t)} && ${t.getBuildCommand(e)} && pm2-runtime start ${t.findFile("ecosystem.config.cjs")}`}){return super.testE2E(t,e,{playwrightArgs:n,prismaDirectory:"prisma",startCommand:s})}testE2EDev(t,e,{playwrightArgs:n="test tests/e2e",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)}"`}},bs={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-args":{description:'Arguments for "docker run"',type:"array",default:[]},mode:{description:"Start mode: dev[elopment] (default) | staging | docker",type:"string",alias:"m"}},async handler(t){!function(t){t.normalizedArgsText=[...t.args??[],...t._?.slice(1)??[]].map((t=>`'${t}'`)).join(" "),t.normalizedDockerArgsText=(t.dockerArgs??[]).map((t=>`'${t}'`)).join(" ")}(t);const e=await jn(t);if(e)for(const n of e.all){const e=n.packageJson.dependencies||{},s=n.packageJson.devDependencies||{};let i;if(e.blitz)i=fs;else if(e.next)i=gs;else if(s["@remix-run/dev"])i=ys;else if((e.express||e.fastify)&&!e["firebase-functions"]||n.hasDockerfile&&/EXPOSE\s+8080/.test(n.dockerfile))i=ps;else{if(!e["build-ts"]&&!s["build-ts"])continue;i=ms}switch(console.info(`Running "start" for ${n.name} ...`),t.mode||"dev"){case"dev":case"development":{const s=vs(e,"development");await Vn(`${s}${i.start(n,t)}`,n,t);break}case"staging":{const s=vs(e,"staging");await Vn(`${s}${i.startProduction(n,t,8080)}`,n,t);break}case"docker":{const s=vs(e,"staging");await Vn(`${s}${i.startDocker(n,t)}`,n,t);break}default:throw new Error(`Unknown start mode: ${t.mode}`)}}}};function vs(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 ws={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 jn(e);if(!n)return;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?fs:n.next?gs:i["@remix-run/dev"]?ys:!n.express&&!n.fastify||n["firebase-functions"]?ms:ps,console.info(`Running "test" for ${s.name} ...`);const o=[];if(e.ci){const n=S(t.join(s.dirPath,"tests","unit")),i=S(t.join(s.dirPath,"tests","e2e"));if(await Un(ds.stopAll(),s,e),!1!==e.unit&&await n&&await Un(r.testUnit(s,e),s,e,{timeout:e.unitTimeout}),!1!==e.start&&await Un(r.testStart(s,e),s,e),await Tn.promiseAll(),"none"!==e.e2e&&await i){s.hasDockerfile&&await Vn(`${r.buildDocker(s)}`,s,e);const t=s.hasDockerfile?{startCommand:ds.stopAndStart(s,!0)}:{};process.exitCode=await Vn(r.testE2E(s,e,t),s,e,{exitIfFailed:!1}),await Vn(ds.stop(s),s,e)}return}switch((e.unit||!e.start&&void 0===e.e2e)&&o.push(Vn(r.testUnit(s,e),s,e,{timeout:e.unitTimeout})),e.start&&o.push(Vn(r.testStart(s,e),s,e)),await Promise.all(o),e.e2e){case void 0:case"none":return;case"":case"headless":return void await Vn(r.testE2E(s,e,{}),s,e);case"headless-dev":return void await Vn(r.testE2EDev(s,e,{}),s,e);case"docker":return void await Os(s,e,r);case"docker-debug":return void await Os(s,e,r,"PWDEBUG=1 ")}if(n.blitz||n.next||i["@remix-run/dev"])switch(e.e2e){case"headed":return void await Vn(r.testE2E(s,e,{playwrightArgs:"test tests/e2e --headed"}),s,e);case"headed-dev":return void await Vn(r.testE2EDev(s,e,{playwrightArgs:"test tests/e2e --headed"}),s,e);case"debug":return void await Vn(`PWDEBUG=1 ${r.testE2E(s,e,{})}`,s,e);case"generate":return void await Vn(r.testE2E(s,e,{playwrightArgs:"codegen http://localhost:8080"}),s,e);case"trace":return void await Vn("playwright show-trace",s,e)}throw new Error(`Unknown e2e mode: ${e.e2e}`)}}(e)}};async function Os(t,e,n,s=""){await Vn(`${n.buildDocker(t)}`,t,e),process.exitCode=await Vn(`${s}${n.testE2E(t,e,{startCommand:ds.stopAndStart(t,!0)})}`,t,e,{exitIfFailed:!1}),await Vn(ds.stop(t),t,e)}const Es={command:"typecheck",describe:"Run type checking. .env files are ignored.",builder:{},async handler(t){const e=await jn(t,!1);if(e)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 Vn(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.'))}}}},ks={...Es,command:"tc"},As={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 js;await an((js=process.argv,js.slice(et()+1))).scriptName("wb").options(As).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(_n).command(Dn).command(Qn).command(ls).command(hs).command(bs).command(ws).command(Es).command(ks).demandCommand().strict().help().argv;for(const t of["SIGINT","SIGTERM","SIGQUIT"])process.on(t,(()=>process.exit()));
34
34
  //# sourceMappingURL=index.js.map