@willbooster/wb 7.6.0 → 7.6.1

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 H;!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 J,G,K;const Q=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,X=null!==(G=null===(J=null===process||void 0===process?void 0:process.versions)||void 0===J?void 0:J.node)&&void 0!==G?G:null===(K=null===process||void 0===process?void 0:process.version)||void 0===K?void 0:K.slice(1);if(X){if(Number(X.match(/^([^.]+)/)[1])<Q)throw Error(`yargs parser supports a minimum Node.js version of ${Q}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}const Z=process?process.env:{},tt=new class{constructor(t){H=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.__||H.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=L(e,"-");n!==t&&-1===g.aliases[t].indexOf(n)&&(g.aliases[t].push(n),u[n]=!0)}})),g.aliases[t].forEach((function(e){g.aliases[e]=[t].concat(g.aliases[t].filter((function(t){return e!==t})))})))}))}))}(n.key,r,n.default,g.arrays),Object.keys(a).forEach((function(t){(g.aliases[t]||[]).forEach((function(e){a[e]=a[t]}))}));let b=null;Object.keys(g.counts).find((t=>D(t,g.arrays)?(b=Error(p("Invalid configuration: %s, opts.count excludes opts.array.",t)),!0):!!D(t,g.nargs)&&(b=Error(p("Invalid configuration: %s, opts.count excludes opts.narg.",t)),!0)));let v=[];const w=Object.assign(Object.create(null),{_:[]}),O={};for(let t=0;t<s.length;t++){const e=s[t],n=e.replace(/^-{3,}/,"---");let i,r,a,c,l,h;if("--"!==e&&/^-/.test(e)&&R(e))E(e);else{if(n.match(/^---+(=|$)/)){E(e);continue}if(e.match(/^--.+=/)||!o["short-option-groups"]&&e.match(/^-.+=/))c=e.match(/^--?([^=]+)=([\s\S]*)$/),null!==c&&Array.isArray(c)&&c.length>=3&&(D(c[1],g.arrays)?t=A(t,c[1],s,c[2]):!1!==D(c[1],g.nargs)?t=k(t,c[1],s,c[2]):j(c[1],c[2],!0));else if(e.match(y)&&o["boolean-negation"])c=e.match(y),null!==c&&Array.isArray(c)&&c.length>=2&&(r=c[1],j(r,!!D(r,g.arrays)&&[!1]));else if(e.match(/^--.+/)||!o["short-option-groups"]&&e.match(/^-[^-]+/))c=e.match(/^--?(.+)/),null!==c&&Array.isArray(c)&&c.length>=2&&(r=c[1],D(r,g.arrays)?t=A(t,r,s):!1!==D(r,g.nargs)?t=k(t,r,s):(l=s[t+1],void 0===l||l.match(/^-/)&&!l.match(m)||D(r,g.bools)||D(r,g.counts)?/^(true|false)$/.test(l)?(j(r,l),t++):j(r,W(r)):(j(r,l),t++)));else if(e.match(/^-.\..+=/))c=e.match(/^-([^=]+)=([\s\S]*)$/),null!==c&&Array.isArray(c)&&c.length>=3&&j(c[1],c[2]);else if(e.match(/^-.\..+/)&&!e.match(m))l=s[t+1],c=e.match(/^-(.\..+)/),null!==c&&Array.isArray(c)&&c.length>=2&&(r=c[1],void 0===l||l.match(/^-/)||D(r,g.bools)||D(r,g.counts)?j(r,W(r)):(j(r,l),t++));else if(e.match(/^-[^-]+/)&&!e.match(m)){a=e.slice(1,-1).split(""),i=!1;for(let n=0;n<a.length;n++){if(l=e.slice(n+2),a[n+1]&&"="===a[n+1]){h=e.slice(n+3),r=a[n],D(r,g.arrays)?t=A(t,r,s,h):!1!==D(r,g.nargs)?t=k(t,r,s,h):j(r,h),i=!0;break}if("-"!==l){if(/[A-Za-z]/.test(a[n])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(l)&&!1===D(l,g.bools)){j(a[n],l),i=!0;break}if(a[n+1]&&a[n+1].match(/\W/)){j(a[n],l),i=!0;break}j(a[n],W(a[n]))}else j(a[n],l)}r=e.slice(-1)[0],i||"-"===r||(D(r,g.arrays)?t=A(t,r,s):!1!==D(r,g.nargs)?t=k(t,r,s):(l=s[t+1],void 0===l||/^(-|--)[^-]/.test(l)&&!l.match(m)||D(r,g.bools)||D(r,g.counts)?/^(true|false)$/.test(l)?(j(r,l),t++):j(r,W(r)):(j(r,l),t++)))}else if(e.match(/^-[0-9]$/)&&e.match(m)&&D(e.slice(1),g.bools))r=e.slice(1),j(r,W(r));else{if("--"===e){v=s.slice(t+1);break}if(o["halt-at-non-option"]){v=s.slice(t);break}E(e)}}}function E(t){const e=x("_",t);"string"!=typeof e&&"number"!=typeof e||w._.push(e)}function k(t,e,n,s){let i,r=D(e,g.nargs);if(r="number"!=typeof r||isNaN(r)?1:r,0===r)return z(s)||(b=Error(p("Argument unexpected for: %s",e))),j(e,W(e)),t;let a=z(s)?0:1;if(o["nargs-eats-options"])n.length-(t+1)+a<r&&(b=Error(p("Not enough arguments following: %s",e))),a=r;else{for(i=t+1;i<n.length&&(!n[i].match(/^-[^0-9]/)||n[i].match(m)||R(n[i]));i++)a++;a<r&&(b=Error(p("Not enough arguments following: %s",e)))}let c=Math.min(a,r);for(!z(s)&&c>0&&(j(e,s),c--),i=t+1;i<c+t+1;i++)j(e,n[i]);return t+c}function A(t,e,n,s){let r=[],c=s||n[t+1];const l=D(e,g.nargs);if(D(e,g.bools)&&!/^(true|false)$/.test(c))r.push(!0);else if(z(c)||z(s)&&/^-/.test(c)&&!m.test(c)&&!R(c)){if(void 0!==a[e]){const t=a[e];r=Array.isArray(t)?t:[t]}}else{z(s)||r.push(_(e,s,!0));for(let s=t+1;s<n.length&&!(!o["greedy-arrays"]&&r.length>0||l&&"number"==typeof l&&r.length>=l)&&(c=n[s],!/^-/.test(c)||m.test(c)||R(c));s++)t=s,r.push(_(e,c,i))}return"number"==typeof l&&(l&&r.length<l||isNaN(l)&&0===r.length)&&(b=Error(p("Not enough arguments following: %s",e))),j(e,r),t}function j(t,e,n=i){if(/-/.test(t)&&o["camel-case-expansion"]){const e=t.split(".").map((function(t){return 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?H.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=Y()),D(t,g.normalize)&&D(t,g.arrays)&&(s=Array.isArray(e)?e.map((t=>H.normalize(t))):H.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)){(V(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 S(t,e){if(void 0===l)return;const n="string"==typeof l?l:"",s=H.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 P(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===Y()?s[i]=Y(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=U.BOOLEAN;return D(t,g.strings)?e=U.STRING:D(t,g.numbers)?e=U.NUMBER:D(t,g.bools)?e=U.BOOLEAN:D(t,g.arrays)&&(e=U.ARRAY),e}(t),{[U.BOOLEAN]:!0,[U.STRING]:"",[U.NUMBER]:void 0,[U.ARRAY]:[]}[e]):a[t];var e}function z(t){return void 0===t}return S(w,!0),S(w,!1),function(t){const e=Object.create(null);P(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=H.resolve(H.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=H.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)})),P(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:()=>Z,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")}}),et=function(t,e){return tt.parse(t.slice(),e).argv};function nt(){return process.versions.electron&&!process.defaultApp?0:1}et.detailed=function(t,e){return tt.parse(t.slice(),e)},et.camelCase=B,et.decamelize=L,et.looksLikeNumber=V;class st extends Error{constructor(t){super(t||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,st)}}var it={fs:{readFileSync:u,writeFile:f},format:p,resolve:e,exists:t=>{try{return h(t).isFile()}catch(t){return!1}}};let rt;class ot{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(),rt.format.apply(rt.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),rt.format.apply(rt.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);rt.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{rt.fs.readFileSync&&(t=JSON.parse(rt.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=rt.resolve(t,"./",e+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~e.lastIndexOf("_")){const s=rt.resolve(t,"./",e.split("_")[0]+".json");this._fileExistsSync(s)&&(n=s)}return n}_fileExistsSync(t){return rt.exists(t)}}const at="loading a directory of commands is not supported yet for ESM";let ct;try{ct=m(import.meta.url)}catch(t){ct=process.cwd()}var lt,ht={assert:{notStrictEqual:a,strictEqual:c},cliui:function(t){return function(t,e){return W=e,new I({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:T,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 st(at)},getProcessArgvBin:function(){return process.argv[nt()]},mainFilename:ct.substring(0,ct.lastIndexOf("node_modules"))||process.cwd(),Parser:et,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 st("require is not supported by ESM")},requireDirectory:()=>{throw new st(at)},stringWidth:t=>[...t].length,y18n:(lt={directory:e(ct,"../../../locales"),updateFiles:!1},function(t,e){rt=e;const n=new ot(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}}(lt,it))};function dt(t,e,n,s){n.assert.notStrictEqual(t,e,s)}function ut(t,e){e.assert.strictEqual(typeof t,"string")}function ft(t){return Object.keys(t)}function pt(t){return!!t&&!!t.then&&"function"==typeof t.then}function gt(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 mt=["first","second","third","fourth","fifth","sixth"];function yt(t,e,n){try{let s=0;const[i,r,o]="object"==typeof t?[{demanded:[],optional:[]},t,e]:[gt(`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 st(`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 st(`Too many arguments provided. Expected max ${l} but received ${c}.`);i.demanded.forEach((t=>{const e=bt(a.shift());0===t.cmd.filter((t=>t===e||"*"===t)).length&&vt(e,t.cmd,s),s+=1})),i.optional.forEach((t=>{if(0===a.length)return;const e=bt(a.shift());0===t.cmd.filter((t=>t===e||"*"===t)).length&&vt(e,t.cmd,s),s+=1}))}catch(t){console.warn(t.stack)}}function bt(t){return Array.isArray(t)?"array":null===t?"null":typeof t}function vt(t,e,n){throw new st(`Invalid ${mt[n]||"manyith"} argument. Expected ${e.join(" or ")} but received ${t}.`)}class wt{constructor(t){this.globalMiddleware=[],this.frozens=[],this.yargs=t}addMiddleware(t,e,n=!0,s=!1){if(yt("<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 Ot(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(pt(t))return t.then((t=>Promise.all([t,n(t,e)]))).then((([t,e])=>Object.assign(t,e)));{const s=n(t,e);return pt(s)?s.then((e=>Object.assign(t,e))):Object.assign(t,s)}}),t)}function Et(t,e,n=(t=>{throw t})){try{const n="function"==typeof t?t():t;return pt(n)?n.then((t=>e(t))):e(n)}catch(t){return n(t)}}const kt=/(^\*)|(^\$0)/;class At{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(jt(n))return void this.addHandler([t].concat(o),e,n.builder,n.handler,n.middlewares,n.deprecated)}if("string"==typeof t){const i=gt(t);o=o.map((t=>gt(t).cmd));let c=!1;const l=[i.cmd].concat(o).filter((t=>!kt.test(t)||(c=!0,!1)));0===l.length&&c&&l.push("$0"),c&&(i.cmd=l[0],o=l.slice(1),t=t.replace(kt,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 pt(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($t(c)){n.getInternalMethods().getUsageInstance().freeze();const h=c(n.getInternalMethods().reset(s),a);if(pt(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 pt(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=kt.test(e.original)?e.original.replace(kt,"").trim():e.original,s=t.filter((t=>!kt.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=Et(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=Et(n=Ot(n,r,o,!1),(t=>{const n=e.handler(t);return pt(n)?n.then((()=>t)):t})),t||r.getInternalMethods().getUsageInstance().cacheHelpMessage(),pt(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=Ot(n,o,c,!0);return pt(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=gt(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=kt.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($t(e))return e(t,!0);jt(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;dt(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();dt(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 jt(t){return"object"==typeof t&&!!t.builder&&"function"==typeof t.handler}function $t(t){return"function"==typeof t}function _t(t={},e=(()=>!0)){const n={};return ft(t).forEach((s=>{e(s,t[s])&&(n[s]=t[s])})),n}function xt(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 Ct(t){return"boolean"==typeof t}function St(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()&&xt(!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 st(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(Ct(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} ${Mt(t[0])}`:Mt(t[0]))+Nt(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(Mt(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:Mt(i),padding:[0,2,0,2+Nt(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 Nt(t){return Pt(t)?t.indentation:0}function Mt(t){return Pt(t)?t.text:t}class Dt{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($t(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=gt(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(dt(this.customCompletionFunction,null,this.shim),this.customCompletionFunction.length<3){const t=this.customCompletionFunction(n,e);return pt(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 pt(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 It(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 Rt=["$0","--","_"];let Wt,zt=[];function Tt(t,e,n,s){Wt=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 Wt.path.resolve(t,e)}(e,t.extends);else try{r=require.resolve(t.extends)}catch(e){return t}!function(t){if(zt.indexOf(t)>-1)throw new st(`Circular extended configurations: '${t}'.`)}(r),zt.push(r),i=s?JSON.parse(Wt.readFileSync(r,"utf8")):require(t.extends),delete t.extends,i=Tt(i,Wt.path.dirname(r),n,Wt)}return zt=[],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,Lt,Vt,Ut,Ht,Yt,qt,Jt,Gt,Kt,Qt,Xt,Zt,te,ee,ne,se,ie,re,oe,ae,ce,le,he,de,ue,fe,pe,ge,me,ye,be,ve,we,Oe,Ee=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},ke=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 Ae=Symbol("copyDoubleDash"),je=Symbol("copyDoubleDash"),$e=Symbol("deleteFromParserHintObject"),_e=Symbol("emitWarning"),xe=Symbol("freeze"),Ce=Symbol("getDollarZero"),Se=Symbol("getParserConfiguration"),Pe=Symbol("getUsageConfiguration"),Ne=Symbol("guessLocale"),Me=Symbol("guessVersion"),De=Symbol("parsePositionalNumbers"),Ie=Symbol("pkgUp"),Re=Symbol("populateParserHintArray"),We=Symbol("populateParserHintSingleValueDictionary"),ze=Symbol("populateParserHintArrayDictionary"),Te=Symbol("populateParserHintDictionary"),Fe=Symbol("sanitizeKey"),Be=Symbol("setKey"),Le=Symbol("unfreeze"),Ve=Symbol("validateAsync"),Ue=Symbol("getCommandInstance"),He=Symbol("getContext"),Ye=Symbol("getHasOutput"),qe=Symbol("getLoggerInstance"),Je=Symbol("getParseContext"),Ge=Symbol("getUsageInstance"),Ke=Symbol("getValidationInstance"),Qe=Symbol("hasParseCallback"),Xe=Symbol("isGlobalContext"),Ze=Symbol("postProcess"),tn=Symbol("rebase"),en=Symbol("reset"),nn=Symbol("runYargsParserAndExecuteCommands"),sn=Symbol("runValidation"),rn=Symbol("setHasOutput"),on=Symbol("kTrackManuallySetKeys");class an{constructor(t=[],e,n,s){this.customScriptName=!1,this.parsed=!1,Bt.set(this,void 0),Lt.set(this,void 0),Vt.set(this,{commands:[],fullCommands:[]}),Ut.set(this,null),Ht.set(this,null),Yt.set(this,"show-hidden"),qt.set(this,null),Jt.set(this,!0),Gt.set(this,{}),Kt.set(this,!0),Qt.set(this,[]),Xt.set(this,void 0),Zt.set(this,{}),te.set(this,!1),ee.set(this,null),ne.set(this,!0),se.set(this,void 0),ie.set(this,""),re.set(this,void 0),oe.set(this,void 0),ae.set(this,{}),ce.set(this,null),le.set(this,null),he.set(this,{}),de.set(this,{}),ue.set(this,void 0),fe.set(this,!1),pe.set(this,void 0),ge.set(this,!1),me.set(this,!1),ye.set(this,!1),be.set(this,void 0),ve.set(this,{}),we.set(this,null),Oe.set(this,void 0),Ee(this,pe,s,"f"),Ee(this,ue,t,"f"),Ee(this,Lt,e,"f"),Ee(this,oe,n,"f"),Ee(this,Xt,new wt(this),"f"),this.$0=this[Ce](),this[en](),Ee(this,Bt,ke(this,Bt,"f"),"f"),Ee(this,be,ke(this,be,"f"),"f"),Ee(this,Oe,ke(this,Oe,"f"),"f"),Ee(this,re,ke(this,re,"f"),"f"),ke(this,re,"f").showHiddenOpt=ke(this,Yt,"f"),Ee(this,se,this[je](),"f")}addHelpOpt(t,e){return yt("[string|boolean] [string]",[t,e],arguments.length),ke(this,ee,"f")&&(this[$e](ke(this,ee,"f")),Ee(this,ee,null,"f")),!1===t&&void 0===e||(Ee(this,ee,"string"==typeof t?t:"help","f"),this.boolean(ke(this,ee,"f")),this.describe(ke(this,ee,"f"),e||ke(this,be,"f").deferY18nLookup("Show help"))),this}help(t,e){return this.addHelpOpt(t,e)}addShowHiddenOpt(t,e){if(yt("[string|boolean] [string]",[t,e],arguments.length),!1===t&&void 0===e)return this;const n="string"==typeof t?t:ke(this,Yt,"f");return this.boolean(n),this.describe(n,e||ke(this,be,"f").deferY18nLookup("Show hidden options")),ke(this,re,"f").showHiddenOpt=n,this}showHidden(t,e){return this.addShowHiddenOpt(t,e)}alias(t,e){return yt("<object|string|array> [string|array]",[t,e],arguments.length),this[ze](this.alias.bind(this),"alias",t,e),this}array(t){return yt("<array|string>",[t],arguments.length),this[Re]("array",t),this[on](t),this}boolean(t){return yt("<array|string>",[t],arguments.length),this[Re]("boolean",t),this[on](t),this}check(t,e){return yt("<function> [boolean]",[t,e],arguments.length),this.middleware(((e,n)=>Et((()=>t(e,n.getOptions())),(n=>(n?("string"==typeof n||n instanceof Error)&&ke(this,be,"f").fail(n.toString(),n):ke(this,be,"f").fail(ke(this,pe,"f").y18n.__("Argument check failed: %s",t.toString())),e)),(t=>(ke(this,be,"f").fail(t.message?t.message:t.toString(),t),e)))),!1,e),this}choices(t,e){return yt("<object|string|array> [string|array]",[t,e],arguments.length),this[ze](this.choices.bind(this),"choices",t,e),this}coerce(t,e){if(yt("<object|string|array> [function]",[t,e],arguments.length),Array.isArray(t)){if(!e)throw new st("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 st("coerce callback must be provided");return ke(this,re,"f").key[t]=!0,ke(this,Xt,"f").addCoerceMiddleware(((n,s)=>{let i;return Object.prototype.hasOwnProperty.call(n,t)?Et((()=>(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 st(t.message)})):n}),t),this}conflicts(t,e){return yt("<string|object> [string|array]",[t,e],arguments.length),ke(this,Oe,"f").conflicts(t,e),this}config(t="config",e,n){return yt("[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||ke(this,be,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(t)?t:[t]).forEach((t=>{ke(this,re,"f").config[t]=n||!0})),this):(t=Tt(t,ke(this,Lt,"f"),this[Se]()["deep-merge-config"]||!1,ke(this,pe,"f")),ke(this,re,"f").configObjects=(ke(this,re,"f").configObjects||[]).concat(t),this)}completion(t,e,n){return yt("[string] [string|boolean|function] [function]",[t,e,n],arguments.length),"function"==typeof e&&(n=e,e=void 0),Ee(this,Ht,t||ke(this,Ht,"f")||"completion","f"),e||!1===e||(e="generate completion script"),this.command(ke(this,Ht,"f"),e),n&&ke(this,Ut,"f").registerFunction(n),this}command(t,e,n,s,i,r){return yt("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[t,e,n,s,i,r],arguments.length),ke(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){yt("<string> [object]",[t,e],arguments.length);const n=ke(this,oe,"f")||ke(this,pe,"f").require;return ke(this,Bt,"f").addDirectory(t,n,ke(this,pe,"f").getCallerFile(),e),this}count(t){return yt("<array|string>",[t],arguments.length),this[Re]("count",t),this[on](t),this}default(t,e,n){return yt("<object|string|array> [*] [string]",[t,e,n],arguments.length),n&&(ut(t,ke(this,pe,"f")),ke(this,re,"f").defaultDescription[t]=n),"function"==typeof e&&(ut(t,ke(this,pe,"f")),ke(this,re,"f").defaultDescription[t]||(ke(this,re,"f").defaultDescription[t]=ke(this,be,"f").functionDescription(e)),e=e.call()),this[We](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 yt("[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),ke(this,re,"f").demandedCommands._={min:t,max:e,minMsg:n,maxMsg:s},this}demand(t,e,n){return Array.isArray(e)?(e.forEach((t=>{dt(n,!0,ke(this,pe,"f")),this.demandOption(t,n)})),e=1/0):"number"!=typeof e&&(n=e,e=1/0),"number"==typeof t?(dt(n,!0,ke(this,pe,"f")),this.demandCommand(t,e,n,n)):Array.isArray(t)?t.forEach((t=>{dt(n,!0,ke(this,pe,"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 yt("<object|string|array> [string]",[t,e],arguments.length),this[We](this.demandOption.bind(this),"demandedOptions",t,e),this}deprecateOption(t,e){return yt("<string> [string|boolean]",[t,e],arguments.length),ke(this,re,"f").deprecatedOptions[t]=e,this}describe(t,e){return yt("<object|string|array> [string]",[t,e],arguments.length),this[Be](t,!0),ke(this,be,"f").describe(t,e),this}detectLocale(t){return yt("<boolean>",[t],arguments.length),Ee(this,Jt,t,"f"),this}env(t){return yt("[string|boolean]",[t],arguments.length),!1===t?delete ke(this,re,"f").envPrefix:ke(this,re,"f").envPrefix=t||"",this}epilogue(t){return yt("<string>",[t],arguments.length),ke(this,be,"f").epilog(t),this}epilog(t){return this.epilogue(t)}example(t,e){return yt("<string|array> [string]",[t,e],arguments.length),Array.isArray(t)?t.forEach((t=>this.example(...t))):ke(this,be,"f").example(t,e),this}exit(t,e){Ee(this,te,!0,"f"),Ee(this,qt,e,"f"),ke(this,Kt,"f")&&ke(this,pe,"f").process.exit(t)}exitProcess(t=!0){return yt("[boolean]",[t],arguments.length),Ee(this,Kt,t,"f"),this}fail(t){if(yt("<function|boolean>",[t],arguments.length),"boolean"==typeof t&&!1!==t)throw new st("Invalid first argument. Expected function or boolean 'false'");return ke(this,be,"f").failFn(t),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(t,e){return yt("<array> [function]",[t,e],arguments.length),e?ke(this,Ut,"f").getCompletion(t,e):new Promise(((e,n)=>{ke(this,Ut,"f").getCompletion(t,((t,s)=>{t?n(t):e(s)}))}))}getDemandedOptions(){return yt([],0),ke(this,re,"f").demandedOptions}getDemandedCommands(){return yt([],0),ke(this,re,"f").demandedCommands}getDeprecatedOptions(){return yt([],0),ke(this,re,"f").deprecatedOptions}getDetectLocale(){return ke(this,Jt,"f")}getExitProcess(){return ke(this,Kt,"f")}getGroups(){return Object.assign({},ke(this,Zt,"f"),ke(this,de,"f"))}getHelp(){if(Ee(this,te,!0,"f"),!ke(this,be,"f").hasCachedHelpMessage()){if(!this.parsed){const t=this[nn](ke(this,ue,"f"),void 0,void 0,0,!0);if(pt(t))return t.then((()=>ke(this,be,"f").help()))}const t=ke(this,Bt,"f").runDefaultBuilderOn(this);if(pt(t))return t.then((()=>ke(this,be,"f").help()))}return Promise.resolve(ke(this,be,"f").help())}getOptions(){return ke(this,re,"f")}getStrict(){return ke(this,ge,"f")}getStrictCommands(){return ke(this,me,"f")}getStrictOptions(){return ke(this,ye,"f")}global(t,e){return yt("<string|array> [boolean]",[t,e],arguments.length),t=[].concat(t),!1!==e?ke(this,re,"f").local=ke(this,re,"f").local.filter((e=>-1===t.indexOf(e))):t.forEach((t=>{ke(this,re,"f").local.includes(t)||ke(this,re,"f").local.push(t)})),this}group(t,e){yt("<string|array> <string>",[t,e],arguments.length);const n=ke(this,de,"f")[e]||ke(this,Zt,"f")[e];ke(this,de,"f")[e]&&delete ke(this,de,"f")[e];const s={};return ke(this,Zt,"f")[e]=(n||[]).concat(t).filter((t=>!s[t]&&(s[t]=!0))),this}hide(t){return yt("<string>",[t],arguments.length),ke(this,re,"f").hiddenOptions.push(t),this}implies(t,e){return yt("<string|object> [number|string|array]",[t,e],arguments.length),ke(this,Oe,"f").implies(t,e),this}locale(t){return yt("[string]",[t],arguments.length),void 0===t?(this[Ne](),ke(this,pe,"f").y18n.getLocale()):(Ee(this,Jt,!1,"f"),ke(this,pe,"f").y18n.setLocale(t),this)}middleware(t,e,n){return ke(this,Xt,"f").addMiddleware(t,!!e,n)}nargs(t,e){return yt("<string|object|array> [number]",[t,e],arguments.length),this[We](this.nargs.bind(this),"narg",t,e),this}normalize(t){return yt("<array|string>",[t],arguments.length),this[Re]("normalize",t),this}number(t){return yt("<array|string>",[t],arguments.length),this[Re]("number",t),this[on](t),this}option(t,e){if(yt("<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[on](t),!ke(this,we,"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"),ke(this,re,"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&&(ke(this,re,"f").defaultDescription[t]=e.defaultDescription),e.skipValidation&&this.skipValidation(t);const i=e.describe||e.description||e.desc,r=ke(this,be,"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){yt("[string|array] [function|boolean|object] [function]",[t,e,n],arguments.length),this[xe](),void 0===t&&(t=ke(this,ue,"f")),"object"==typeof e&&(Ee(this,le,e,"f"),e=n),"function"==typeof e&&(Ee(this,ce,e,"f"),e=!1),e||Ee(this,ue,t,"f"),ke(this,ce,"f")&&Ee(this,Kt,!1,"f");const s=this[nn](t,!!e),i=this.parsed;return ke(this,Ut,"f").setParsed(this.parsed),pt(s)?s.then((t=>(ke(this,ce,"f")&&ke(this,ce,"f").call(this,ke(this,qt,"f"),t,ke(this,ie,"f")),t))).catch((t=>{throw ke(this,ce,"f")&&ke(this,ce,"f")(t,this.parsed.argv,ke(this,ie,"f")),t})).finally((()=>{this[Le](),this.parsed=i})):(ke(this,ce,"f")&&ke(this,ce,"f").call(this,ke(this,qt,"f"),s,ke(this,ie,"f")),this[Le](),this.parsed=i,s)}parseAsync(t,e,n){const s=this.parse(t,e,n);return pt(s)?s:Promise.resolve(s)}parseSync(t,e,n){const s=this.parse(t,e,n);if(pt(s))throw new st(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return s}parserConfiguration(t){return yt("<object>",[t],arguments.length),Ee(this,ae,t,"f"),this}pkgConf(t,e){yt("<string> [string]",[t,e],arguments.length);let n=null;const s=this[Ie](e||ke(this,Lt,"f"));return s[t]&&"object"==typeof s[t]&&(n=Tt(s[t],e||ke(this,Lt,"f"),this[Se]()["deep-merge-config"]||!1,ke(this,pe,"f")),ke(this,re,"f").configObjects=(ke(this,re,"f").configObjects||[]).concat(n)),this}positional(t,e){yt("<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=ke(this,Vt,"f").fullCommands[ke(this,Vt,"f").fullCommands.length-1],i=s?ke(this,Bt,"f").cmdToParseOptions(s):{array:[],alias:{},default:{},demand:{}};return ft(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,ke(this,be,"f").getPositionalGroupName()),this.option(t,e)}recommendCommands(t=!0){return yt("[boolean]",[t],arguments.length),Ee(this,fe,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 yt("<array|string|object> [number]",[t],arguments.length),"string"==typeof t&&ke(this,re,"f").narg[t]||this[We](this.requiresArg.bind(this),"narg",t,NaN),this}showCompletionScript(t,e){return yt("[string] [string]",[t,e],arguments.length),t=t||this.$0,ke(this,se,"f").log(ke(this,Ut,"f").generateCompletionScript(t,e||ke(this,Ht,"f")||"completion")),this}showHelp(t){if(yt("[string|function]",[t],arguments.length),Ee(this,te,!0,"f"),!ke(this,be,"f").hasCachedHelpMessage()){if(!this.parsed){const e=this[nn](ke(this,ue,"f"),void 0,void 0,0,!0);if(pt(e))return e.then((()=>{ke(this,be,"f").showHelp(t)})),this}const e=ke(this,Bt,"f").runDefaultBuilderOn(this);if(pt(e))return e.then((()=>{ke(this,be,"f").showHelp(t)})),this}return ke(this,be,"f").showHelp(t),this}scriptName(t){return this.customScriptName=!0,this.$0=t,this}showHelpOnFail(t,e){return yt("[boolean|string] [string]",[t,e],arguments.length),ke(this,be,"f").showHelpOnFail(t,e),this}showVersion(t){return yt("[string|function]",[t],arguments.length),ke(this,be,"f").showVersion(t),this}skipValidation(t){return yt("<array|string>",[t],arguments.length),this[Re]("skipValidation",t),this}strict(t){return yt("[boolean]",[t],arguments.length),Ee(this,ge,!1!==t,"f"),this}strictCommands(t){return yt("[boolean]",[t],arguments.length),Ee(this,me,!1!==t,"f"),this}strictOptions(t){return yt("[boolean]",[t],arguments.length),Ee(this,ye,!1!==t,"f"),this}string(t){return yt("<array|string>",[t],arguments.length),this[Re]("string",t),this[on](t),this}terminalWidth(){return yt([],0),ke(this,pe,"f").process.stdColumns}updateLocale(t){return this.updateStrings(t)}updateStrings(t){return yt("<object>",[t],arguments.length),Ee(this,Jt,!1,"f"),ke(this,pe,"f").y18n.updateLocale(t),this}usage(t,e,n,s){if(yt("<string|null|undefined> [string|boolean] [function|object] [function]",[t,e,n,s],arguments.length),void 0!==e){if(dt(t,null,ke(this,pe,"f")),(t||"").match(/^\$0( |$)/))return this.command(t,e,n,s);throw new st(".usage() description must start with $0 if being used as alias for .command()")}return ke(this,be,"f").usage(t),this}usageConfiguration(t){return yt("<object>",[t],arguments.length),Ee(this,ve,t,"f"),this}version(t,e,n){const s="version";if(yt("[boolean|string] [string] [string]",[t,e,n],arguments.length),ke(this,we,"f")&&(this[$e](ke(this,we,"f")),ke(this,be,"f").version(void 0),Ee(this,we,null,"f")),0===arguments.length)n=this[Me](),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 Ee(this,we,"string"==typeof t?t:s,"f"),e=e||ke(this,be,"f").deferY18nLookup("Show version number"),ke(this,be,"f").version(n||void 0),this.boolean(ke(this,we,"f")),this.describe(ke(this,we,"f"),e),this}wrap(t){return yt("<number|null|undefined>",[t],arguments.length),ke(this,be,"f").wrap(t),this}[(Bt=new WeakMap,Lt=new WeakMap,Vt=new WeakMap,Ut=new WeakMap,Ht=new WeakMap,Yt=new WeakMap,qt=new WeakMap,Jt=new WeakMap,Gt=new WeakMap,Kt=new WeakMap,Qt=new WeakMap,Xt=new WeakMap,Zt=new WeakMap,te=new WeakMap,ee=new WeakMap,ne=new WeakMap,se=new WeakMap,ie=new WeakMap,re=new WeakMap,oe=new WeakMap,ae=new WeakMap,ce=new WeakMap,le=new WeakMap,he=new WeakMap,de=new WeakMap,ue=new WeakMap,fe=new WeakMap,pe=new WeakMap,ge=new WeakMap,me=new WeakMap,ye=new WeakMap,be=new WeakMap,ve=new WeakMap,we=new WeakMap,Oe=new WeakMap,Ae)](t){if(!t._||!t["--"])return t;t._.push.apply(t._,t["--"]);try{delete t["--"]}catch(t){}return t}[je](){return{log:(...t)=>{this[Qe]()||console.log(...t),Ee(this,te,!0,"f"),ke(this,ie,"f").length&&Ee(this,ie,ke(this,ie,"f")+"\n","f"),Ee(this,ie,ke(this,ie,"f")+t.join(" "),"f")},error:(...t)=>{this[Qe]()||console.error(...t),Ee(this,te,!0,"f"),ke(this,ie,"f").length&&Ee(this,ie,ke(this,ie,"f")+"\n","f"),Ee(this,ie,ke(this,ie,"f")+t.join(" "),"f")}}}[$e](t){ft(ke(this,re,"f")).forEach((e=>{if("configObjects"===e)return;const n=ke(this,re,"f")[e];Array.isArray(n)?n.includes(t)&&n.splice(n.indexOf(t),1):"object"==typeof n&&delete n[t]})),delete ke(this,be,"f").getDescriptions()[t]}[_e](t,e,n){ke(this,Gt,"f")[n]||(ke(this,pe,"f").process.emitWarning(t,e),ke(this,Gt,"f")[n]=!0)}[xe](){ke(this,Qt,"f").push({options:ke(this,re,"f"),configObjects:ke(this,re,"f").configObjects.slice(0),exitProcess:ke(this,Kt,"f"),groups:ke(this,Zt,"f"),strict:ke(this,ge,"f"),strictCommands:ke(this,me,"f"),strictOptions:ke(this,ye,"f"),completionCommand:ke(this,Ht,"f"),output:ke(this,ie,"f"),exitError:ke(this,qt,"f"),hasOutput:ke(this,te,"f"),parsed:this.parsed,parseFn:ke(this,ce,"f"),parseContext:ke(this,le,"f")}),ke(this,be,"f").freeze(),ke(this,Oe,"f").freeze(),ke(this,Bt,"f").freeze(),ke(this,Xt,"f").freeze()}[Ce](){let t,e="";return t=/\b(node|iojs|electron)(\.exe)?$/.test(ke(this,pe,"f").process.argv()[0])?ke(this,pe,"f").process.argv().slice(1,2):ke(this,pe,"f").process.argv().slice(0,1),e=t.map((t=>{const e=this[tn](ke(this,Lt,"f"),t);return t.match(/^(\/|([a-zA-Z]:)?\\)/)&&e.length<t.length?e:t})).join(" ").trim(),ke(this,pe,"f").getEnv("_")&&ke(this,pe,"f").getProcessArgvBin()===ke(this,pe,"f").getEnv("_")&&(e=ke(this,pe,"f").getEnv("_").replace(`${ke(this,pe,"f").path.dirname(ke(this,pe,"f").process.execPath())}/`,"")),e}[Se](){return ke(this,ae,"f")}[Pe](){return ke(this,ve,"f")}[Ne](){if(!ke(this,Jt,"f"))return;const t=ke(this,pe,"f").getEnv("LC_ALL")||ke(this,pe,"f").getEnv("LC_MESSAGES")||ke(this,pe,"f").getEnv("LANG")||ke(this,pe,"f").getEnv("LANGUAGE")||"en_US";this.locale(t.replace(/[.:].*/,""))}[Me](){return this[Ie]().version||"unknown"}[De](t){const e=t["--"]?t["--"]:t._;for(let t,n=0;void 0!==(t=e[n]);n++)ke(this,pe,"f").Parser.looksLikeNumber(t)&&Number.isSafeInteger(Math.floor(parseFloat(`${t}`)))&&(e[n]=Number(t));return t}[Ie](t){const e=t||"*";if(ke(this,he,"f")[e])return ke(this,he,"f")[e];let n={};try{let e=t||ke(this,pe,"f").mainFilename;!t&&ke(this,pe,"f").path.extname(e)&&(e=ke(this,pe,"f").path.dirname(e));const s=ke(this,pe,"f").findUp(e,((t,e)=>e.includes("package.json")?"package.json":void 0));dt(s,void 0,ke(this,pe,"f")),n=JSON.parse(ke(this,pe,"f").readFileSync(s,"utf8"))}catch(t){}return ke(this,he,"f")[e]=n||{},ke(this,he,"f")[e]}[Re](t,e){(e=[].concat(e)).forEach((e=>{e=this[Fe](e),ke(this,re,"f")[t].push(e)}))}[We](t,e,n,s){this[Te](t,e,n,s,((t,e,n)=>{ke(this,re,"f")[t][e]=n}))}[ze](t,e,n,s){this[Te](t,e,n,s,((t,e,n)=>{ke(this,re,"f")[t][e]=(ke(this,re,"f")[t][e]||[]).concat(n)}))}[Te](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 ft(n))t(e,n[e]);else i(e,this[Fe](n),s)}[Fe](t){return"__proto__"===t?"___proto___":t}[Be](t,e){return this[We](this[Be].bind(this),"key",t,e),this}[Le](){var t,e,n,s,i,r,o,a,c,l,h,d;const u=ke(this,Qt,"f").pop();let f;dt(u,void 0,ke(this,pe,"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){Ee(t,re,e,"f")}}.value,configObjects:f,exitProcess:{set value(t){Ee(e,Kt,t,"f")}}.value,groups:{set value(t){Ee(n,Zt,t,"f")}}.value,output:{set value(t){Ee(s,ie,t,"f")}}.value,exitError:{set value(t){Ee(i,qt,t,"f")}}.value,hasOutput:{set value(t){Ee(r,te,t,"f")}}.value,parsed:this.parsed,strict:{set value(t){Ee(o,ge,t,"f")}}.value,strictCommands:{set value(t){Ee(a,me,t,"f")}}.value,strictOptions:{set value(t){Ee(c,ye,t,"f")}}.value,completionCommand:{set value(t){Ee(l,Ht,t,"f")}}.value,parseFn:{set value(t){Ee(h,ce,t,"f")}}.value,parseContext:{set value(t){Ee(d,le,t,"f")}}.value}=u),ke(this,re,"f").configObjects=f,ke(this,be,"f").unfreeze(),ke(this,Oe,"f").unfreeze(),ke(this,Bt,"f").unfreeze(),ke(this,Xt,"f").unfreeze()}[Ve](t,e){return Et(e,(e=>(t(e),e)))}getInternalMethods(){return{getCommandInstance:this[Ue].bind(this),getContext:this[He].bind(this),getHasOutput:this[Ye].bind(this),getLoggerInstance:this[qe].bind(this),getParseContext:this[Je].bind(this),getParserConfiguration:this[Se].bind(this),getUsageConfiguration:this[Pe].bind(this),getUsageInstance:this[Ge].bind(this),getValidationInstance:this[Ke].bind(this),hasParseCallback:this[Qe].bind(this),isGlobalContext:this[Xe].bind(this),postProcess:this[Ze].bind(this),reset:this[en].bind(this),runValidation:this[sn].bind(this),runYargsParserAndExecuteCommands:this[nn].bind(this),setHasOutput:this[rn].bind(this)}}[Ue](){return ke(this,Bt,"f")}[He](){return ke(this,Vt,"f")}[Ye](){return ke(this,te,"f")}[qe](){return ke(this,se,"f")}[Je](){return ke(this,le,"f")||{}}[Ge](){return ke(this,be,"f")}[Ke](){return ke(this,Oe,"f")}[Qe](){return!!ke(this,ce,"f")}[Xe](){return ke(this,ne,"f")}[Ze](t,e,n,s){if(n)return t;if(pt(t))return t;e||(t=this[Ae](t));return(this[Se]()["parse-positional-numbers"]||void 0===this[Se]()["parse-positional-numbers"])&&(t=this[De](t)),s&&(t=Ot(t,this,ke(this,Xt,"f").getMiddleware(),!1)),t}[en](t={}){Ee(this,re,ke(this,re,"f")||{},"f");const e={};e.local=ke(this,re,"f").local||[],e.configObjects=ke(this,re,"f").configObjects||[];const n={};e.local.forEach((e=>{n[e]=!0,(t[e]||[]).forEach((t=>{n[t]=!0}))})),Object.assign(ke(this,de,"f"),Object.keys(ke(this,Zt,"f")).reduce(((t,e)=>{const s=ke(this,Zt,"f")[e].filter((t=>!(t in n)));return s.length>0&&(t[e]=s),t}),{})),Ee(this,Zt,{},"f");return["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"].forEach((t=>{e[t]=(ke(this,re,"f")[t]||[]).filter((t=>!n[t]))})),["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"].forEach((t=>{e[t]=_t(ke(this,re,"f")[t],(t=>!n[t]))})),e.envPrefix=ke(this,re,"f").envPrefix,Ee(this,re,e,"f"),Ee(this,be,ke(this,be,"f")?ke(this,be,"f").reset(n):St(this,ke(this,pe,"f")),"f"),Ee(this,Oe,ke(this,Oe,"f")?ke(this,Oe,"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=>{Rt.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===Rt.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){yt("<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))):(dt(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){yt("<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=It(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();dt(t,void 0,n),({implied:o,conflicting:c}=t)},r}(this,ke(this,be,"f"),ke(this,pe,"f")),"f"),Ee(this,Bt,ke(this,Bt,"f")?ke(this,Bt,"f").reset():function(t,e,n,s){return new At(t,e,n,s)}(ke(this,be,"f"),ke(this,Oe,"f"),ke(this,Xt,"f"),ke(this,pe,"f")),"f"),ke(this,Ut,"f")||Ee(this,Ut,function(t,e,n,s){return new Dt(t,e,n,s)}(this,ke(this,be,"f"),ke(this,Bt,"f"),ke(this,pe,"f")),"f"),ke(this,Xt,"f").reset(),Ee(this,Ht,null,"f"),Ee(this,ie,"","f"),Ee(this,qt,null,"f"),Ee(this,te,!1,"f"),this.parsed=!1,this}[tn](t,e){return ke(this,pe,"f").path.relative(t,e)}[nn](t,e,n,s=0,i=!1){let r=!!n||i;t=t||ke(this,ue,"f"),ke(this,re,"f").__=ke(this,pe,"f").y18n.__,ke(this,re,"f").configuration=this[Se]();const o=!!ke(this,re,"f").configuration["populate--"],a=Object.assign({},ke(this,re,"f").configuration,{"populate--":!0}),c=ke(this,pe,"f").Parser.detailed(t,Object.assign({},ke(this,re,"f"),{configuration:{"parse-positional-numbers":!1,...a}})),l=Object.assign(c.argv,ke(this,le,"f"));let h;const d=c.aliases;let u=!1,f=!1;Object.keys(l).forEach((t=>{t===ke(this,ee,"f")&&l[t]?u=!0:t===ke(this,we,"f")&&l[t]&&(f=!0)})),l.$0=this.$0,this.parsed=c,0===s&&ke(this,be,"f").clearCachedHelpMessage();try{if(this[Ne](),e)return this[Ze](l,o,!!n,!1);if(ke(this,ee,"f")){[ke(this,ee,"f")].concat(d[ke(this,ee,"f")]||[]).filter((t=>t.length>1)).includes(""+l._[l._.length-1])&&(l._.pop(),u=!0)}Ee(this,ne,!1,"f");const a=ke(this,Bt,"f").getCommands(),p=ke(this,Ut,"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!==ke(this,Ht,"f")){const t=ke(this,Bt,"f").runCommand(e,this,c,r+1,i,u||f||i);return this[Ze](t,o,!!n,!1)}if(!t&&e!==ke(this,Ht,"f")){t=e;break}}!ke(this,Bt,"f").hasDefaultCommand()&&ke(this,fe,"f")&&t&&!g&&ke(this,Oe,"f").recommendCommands(t,a)}ke(this,Ht,"f")&&l._.includes(ke(this,Ht,"f"))&&!p&&(ke(this,Kt,"f")&&xt(!0),this.showCompletionScript(),this.exit(0))}if(ke(this,Bt,"f").hasDefaultCommand()&&!g){const t=ke(this,Bt,"f").runCommand(null,this,c,0,i,u||f||i);return this[Ze](t,o,!!n,!1)}if(p){ke(this,Kt,"f")&&xt(!0);const e=(t=[].concat(t)).slice(t.indexOf(`--${ke(this,Ut,"f").completionKey}`)+1);return ke(this,Ut,"f").getCompletion(e,((t,e)=>{if(t)throw new st(t.message);(e||[]).forEach((t=>{ke(this,se,"f").log(t)})),this.exit(0)})),this[Ze](l,!o,!!n,!1)}if(ke(this,te,"f")||(u?(ke(this,Kt,"f")&&xt(!0),r=!0,this.showHelp("log"),this.exit(0)):f&&(ke(this,Kt,"f")&&xt(!0),r=!0,ke(this,be,"f").showVersion("log"),this.exit(0))),!r&&ke(this,re,"f").skipValidation.length>0&&(r=Object.keys(l).some((t=>ke(this,re,"f").skipValidation.indexOf(t)>=0&&!0===l[t]))),!r){if(c.error)throw new st(c.error.message);if(!p){const t=this[sn](d,{},c.error);n||(h=Ot(l,this,ke(this,Xt,"f").getMiddleware(),!0)),h=this[Ve](t,null!=h?h:l),pt(h)&&!n&&(h=h.then((()=>Ot(l,this,ke(this,Xt,"f").getMiddleware(),!1))))}}}catch(t){if(!(t instanceof st))throw t;ke(this,be,"f").fail(t.message,t)}return this[Ze](null!=h?h:l,o,!!n,!0)}[sn](t,e,n,s){const i={...this.getDemandedOptions()};return r=>{if(n)throw new st(n.message);ke(this,Oe,"f").nonOptionCount(r),ke(this,Oe,"f").requiredArguments(r,i);let o=!1;ke(this,me,"f")&&(o=ke(this,Oe,"f").unknownCommands(r)),ke(this,ge,"f")&&!o?ke(this,Oe,"f").unknownArguments(r,t,e,!!s):ke(this,ye,"f")&&ke(this,Oe,"f").unknownArguments(r,t,{},!1,!1),ke(this,Oe,"f").limitedChoices(r),ke(this,Oe,"f").implications(r),ke(this,Oe,"f").conflicting(r)}}[rn](){Ee(this,te,!0,"f")}[on](t){if("string"==typeof t)ke(this,re,"f").key[t]=!0;else for(const e of t)ke(this,re,"f").key[e]=!0}}const cn=(ln=ht,(t=[],e=ln.process.cwd(),n)=>{const s=new an(t,e,n,ln);return Object.defineProperty(s,"argv",{get:()=>s.parse(),enumerable:!0}),s.help(),s.version(),s});var ln;function hn(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 dn(t,e,n){"symbol"==typeof e&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:n?n+" "+e:e})}catch(t){}return t}function un(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var s=n.call(t,e||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}let fn;const pn=function({cacheDuration:t=Number.POSITIVE_INFINITY,calcKey:e=(t=>function(t,e=0){const[n,s]=function(t,e=0){let n=3735928559^e,s=1103547991^e;for(let e,i=0;i<t.length;i++)e=t.codePointAt(i),n=Math.imul(n^e,2654435761),s=Math.imul(s^e,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507),s^=Math.imul(n^n>>>13,3266489909),[s>>>0,n>>>0]}(t,e);return t.length.toString(36)+n.toString(36).padStart(7,"0")+s.toString(36).padStart(7,"0")}(JSON.stringify(t))),maxCachedArgsSize:n=100,maxCachedThisSize:s=10}={}){return function(i,r){if("getter"===r?.kind){const e=new Map;return function(){const n=Date.now();if(e.has(this)){const[s,i]=e.get(this);if(n-i<=t)return s}const r=i.call(this);if(e.size>=s){const t=e.keys().next().value;e.delete(t)}return e.set(this,[r,n]),r}}{const o=new Map;return function(...a){const c=e(a);let l=o.get(this);const h=Date.now();if(l){if(l.has(c)){const[e,n]=l.get(c);if(h-n<=t)return e}}else{if(l=new Map,o.size>=s){const t=o.keys().next().value;o.delete(t)}o.set(this,l)}const d=r?i.call(this,...a):i(...a);if(l.size>=n){const t=l.keys().next().value;l.delete(t)}return l.set(c,[d,h]),d}}}}({maxCachedThisSize:Number.MAX_SAFE_INTEGER,maxCachedArgsSize:1});class gn{static{[fn]=function(t,e,n,s,i,r){var o,a,c,l,h,d,u,f=Symbol.metadata||Symbol.for("Symbol.metadata"),p=Object.defineProperty,g=Object.create,m=[g(null),g(null)],y=e.length;function b(e,n,s){return function(i,r){n&&(r=i,i=t);for(var o=0;o<e.length;o++)r=e[o].apply(i,s?[r]:[]);return s?r:i}}function v(t,e,n,s){if("function"!=typeof t&&(s||void 0!==t))throw new TypeError(e+" must "+(n||"be")+" a function"+(s?"":" or undefined"));return t}function w(t,e,n,s,i,r,c,l,h,d,u){function f(t){if(!u(t))throw new TypeError("Attempted to access private element on non-instance")}var g=[].concat(e[0]),y=e[3],w=!c,O=1===i,E=3===i,k=4===i,A=2===i;function j(e,n,s){return function(i,r){return n&&(r=i,i=t),s&&s(i),$[e].call(i,r)}}if(!w){var $={},_=[],x=E?"get":k||O?"set":"value";if(h?(d||O?$={get:dn((function(){return y(this)}),s,"get"),set:function(t){e[4](this,t)}}:$[x]=y,d||dn($[x],s,A?"":x)):d||($=Object.getOwnPropertyDescriptor(t,s)),!d&&!h){if((a=m[+l][s])&&7!=(a^i))throw Error("Decorating two elements with the same name ("+$[x].name+") is not supported yet");m[+l][s]=i<3?1:i}}for(var C=t,S=g.length-1;S>=0;S-=n?2:1){var P=v(g[S],"A decorator","be",!0),N=n?g[S-1]:void 0,M={},D={kind:["field","accessor","method","getter","setter","class"][i],name:s,metadata:o,addInitializer:function(t,e){if(t.v)throw Error("attempted to call addInitializer after decoration was finished");v(e,"An initializer","be",!0),r.push(e)}.bind(null,M)};if(w)a=P.call(N,C,D),M.v=1,v(a,"class decorators","return")&&(C=a);else if(D.static=l,D.private=h,a=D.access={has:h?u.bind():function(t){return s in t}},k||(a.get=h?A?function(t){return f(t),$.value}:j("get",0,f):function(t){return t[s]}),A||E||(a.set=h?j("set",0,f):function(t,e){t[s]=e}),C=P.call(N,O?{get:$.get,set:$.set}:$[x],D),M.v=1,O){if("object"==typeof C&&C)(a=v(C.get,"accessor.get"))&&($.get=a),(a=v(C.set,"accessor.set"))&&($.set=a),(a=v(C.init,"accessor.init"))&&_.unshift(a);else if(void 0!==C)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else v(C,(d?"field":"method")+" decorators","return")&&(d?_.unshift(C):$[x]=C)}return i<2&&c.push(b(_,l,1),b(r,l,0)),d||w||(h?O?c.splice(-1,0,j("get",l),j("set",l)):c.push(A?$[x]:v.call.bind($[x])):p(t,s,$)),C}function O(t){return p(t,f,{configurable:!0,enumerable:!0,value:o})}return o=g(null==o?null:o),h=[],d=function(t){t&&h.push(b(t))},u=function(e,s){for(var r=0;r<n.length;r++){var o=n[r],a=o[1],d=7&a;if((8&a)==e&&!d==s){var u=o[2],f=!!o[3],p=16&a;w(e?t:t.prototype,o,p,f?"#"+u:un(u),d,d<2?[]:e?l=l||[]:c=c||[],h,!!e,f,s,e&&f?function(e){return hn(e)===t}:i)}}},u(8,0),u(0,0),u(8,1),u(0,1),d(c),d(l),a=h,y||O(t),{e:a,get c(){var n=[];return y&&[O(t=w(t,[e],s,t.name,5,n)),b(n,1)]}}}(this,[],[[pn,3,"isBunProject"],[pn,3,"isBunAvailable"],[pn,3,"buildCommand"],[pn,3,"rootDirPath"],[pn,3,"dockerfile"],[pn,3,"hasDockerfile"],[pn,3,"hasSourceCode"],[pn,3,"name"],[pn,3,"dockerImageName"],[pn,3,"env"],[pn,3,"packageJson"],[pn,3,"hasPrisma"],[pn,3,"dockerPackageJson"],[pn,3,"binExists"]]).e}argv=void fn(this);pathByName=new Map;constructor(e,n,s){this._dirPath=t.resolve(e),this.argv=n,this.loadEnv=s}get isBunProject(){return l.existsSync(t.join(this.rootDirPath,"bunfig.toml"))}get isBunAvailable(){try{return/(^|\n)bun\s/.test(l.readFileSync(t.join(this.rootDirPath,".tool-versions"),"utf8"))}catch{return!1}}get buildCommand(){return this.packageJson.scripts?.build?.includes("buildIfNeeded")?"yarn build":"YARN wb buildIfNeeded "+(this.argv.verbose?"--verbose":"")}get dirPath(){return this._dirPath}get rootDirPath(){return l.existsSync(t.join(this.dirPath,"..","..","package.json"))?t.resolve(this.dirPath,"..",".."):this.dirPath}get dockerfile(){return l.readFileSync(this.findFile("Dockerfile"),"utf8")}get hasDockerfile(){try{return!!this.findFile("Dockerfile")}catch{return!1}}get hasSourceCode(){return l.existsSync(t.join(this.dirPath,"src"))}get name(){return this.packageJson.name||"unknown"}get dockerImageName(){return(this.packageJson.name||"unknown").replaceAll("@","").replaceAll("/","-")}get env(){return this.loadEnv?{...C(this.argv,this.dirPath),...process.env}:process.env}get packageJson(){return JSON.parse(l.readFileSync(t.join(this.dirPath,"package.json"),"utf8"))}get hasPrisma(){return!(!this.packageJson.dependencies?.prisma&&!this.packageJson.devDependencies?.prisma)}get dockerPackageJson(){return t.dirname(this.findFile("Dockerfile"))===this.dirPath?this.packageJson:JSON.parse(l.readFileSync(t.join(t.dirname(this.findFile("Dockerfile")),"package.json"),"utf8"))}get binExists(){let e=!1,n=this.dirPath;for(;;){const s=t.join(n,"node_modules",".bin");if(l.existsSync(s)&&(this.env.PATH=`${s}:${this.env.PATH}`,e=!0),l.existsSync(t.join(n,".git")))break;const i=t.dirname(n);if(n===i)break;n=i}return e}findFile(e){let n=this.pathByName.get(e);if(n)return n;if(n=[e,t.join("..","..",e)].map((e=>t.resolve(this.dirPath,e))).find((t=>l.existsSync(t))),!n)throw new Error(`File not found: ${e}`);return this.pathByName.set(e,n),n}}function mn(e,n=!0,s){if(s??=process.cwd(),l.existsSync(t.join(s,"package.json")))return new gn(s,e,n)}async function yn(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 gn(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 gn(i,e,n))}return{root:r,self:i}}(e,n,s);if(i)return{...i,all:i.root===i.self?await bn(e,i.root,n):[i.self]}}async function bn(e,n,s){const i=[n],r=n.packageJson.workspaces;if(!Array.isArray(r))return i;const o=[],a=[];for(const e of r.map((e=>t.join(n.dirPath,e))))l.existsSync(e)?a.push(e):o.push(e);a.push(...await E(o,{dot:!0,onlyDirectories:!0}));for(const n of a)l.existsSync(t.join(n,"package.json"))&&i.push(new gn(n,e,s));return i}const vn={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 mn(e,!0,n);if(!s)return console.error(O.red("No project found.")),!0;if(!l.existsSync(t.join(s.rootDirPath,".git")))return wn(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])=>!On.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=>(En.some((e=>t.includes(e)))||kn.some((e=>t.endsWith(e))))&&!An.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(!wn(s,e))return;e.dryRun||await l.promises.writeFile(r,o,"utf8");return!0}(e)}};function wn(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 On=new Set(["CI","PWDEBUG","TMPDIR"]);const En=["src/","public/"],kn=[".js",".cjs",".mjs",".jsx",".ts",".cts",".mts",".tsx",".json",".browserslistrc","package.json","yarn.lock"],An=["test/","tests/","__tests__/","test-fixtures/"];function*jn(t,e){for(const n of e)console.info(`Running "${t}" for ${n.name} ...`),yield n}const $n={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 yn(e);n||(console.error(O.red("No project found.")),process.exit(1));for(const s of jn("optimizeForDockerBuild",n.all)){const n=s.packageJson,i=["dependencies","devDependencies"];for(const t of i){const e=n[t]||{};for(const[t,n]of Object.entries(e))n?.startsWith("git@github.com:")&&(e[t]=`./${t}`)}if(_n(e,n),xn(n),Cn(n),e.dryRun)continue;const r=e.outside?t.join(s.dirPath,"dist"):s.dirPath;await l.promises.mkdir(r,{recursive:!0}),await l.promises.writeFile(t.join(r,"package.json"),JSON.stringify(n),"utf8")}e.dryRun||e.outside||y.spawnSync("yarn",{stdio:"inherit"})}};function _n(t,e){if(!t.outside)return void delete e.devDependencies;const n=e.devDependencies||{},s=["artillery","concurrently","conventional-changelog-conventionalcommits","eslint","husky","imagemin","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 xn(t){const e=["check","deploy","format","lint","start","test"],n=["pinst ","husky "],s=t.scripts||{};for(const[t,i]of Object.entries(s))(e.some((e=>t.includes(e)))||n.some((t=>i.includes(t)||i.trim()===t.trim())))&&delete s[t]}function Cn(t){delete t.private,delete t.publishConfig,delete t.prettier}const Sn=process.argv[0].endsWith("/bun"),Pn=Sn?"bun --bun":"node",Nn=Sn?"bun --bun":"yarn";const Mn=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`${Pn} -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`}},Dn=new Set;async function In(t){try{await A(t)}catch{}}const Rn=new j,Wn={exitIfFailed:!0};async function zn(t,e,n,s=Wn){const[i,r]=Fn(t,e);if(Bn(i,e),n.verbose&&Bn(r,e,"Start (raw)",!0),n.dryRun)return Ln(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 In(t);const e=async()=>{Dn.has(t)||(Dn.add(t),await In(t))};for(const t of["beforeExit","SIGINT","SIGTERM","SIGQUIT"])process.on(t,e)}(Number(o));const a=await M(r,void 0,{cwd:e.dirPath,env:e.env,shell:!0,stdio:"inherit",timeout:s?.timeout,killOnExit:!0,verbose:n.verbose});return Ln(i,a.status,s),a.status??1}function Tn(t,e,n,s=Wn){return Rn.run((async()=>{const[i,r]=Fn(t,e);if(Bn(i,e,"Start (parallel)",!0),n.dryRun)return Bn(i,e,"Started (log)"),n.verbose&&Bn(r,e,"Started (raw)",!0),void Ln(i,0,s);const o=await M(r,void 0,{cwd:e.dirPath,env:e.env,shell:!0,stdio:"pipe",timeout:s?.timeout,mergeOutAndError:!0,killOnExit:!0,verbose:n.verbose});Bn(i,e,"Started (log)"),n.verbose&&Bn(r,e,"Started (raw)",!0);const a=o.stdout.trim();a&&console.info(a),Ln(i,o.status,s)}))}function Fn(t,e){const n=t.replaceAll("\n","").replaceAll(/\s\s+/g," ").replaceAll("PRISMA ",e.packageJson.dependencies?.blitz?"YARN blitz prisma ":"YARN prisma ").replaceAll("BUN ",e.isBunAvailable?"bun --bun ":"YARN ").trim();return[n.replaceAll("YARN ",`${Nn} `),n.replaceAll("YARN ",!Sn&&e.binExists?"":`${Nn} `)]}function Bn(t,e,n="Start",s=!1){console.info("\n"+(s?O.gray:O.cyan)(O.bold(`${n}:`),t)+O.gray(` at ${e.dirPath}`))}function Ln(t,e,n){0===e?console.info(O.green(O.bold("Finished:"),t)):(console.info(O.red(O.bold(`Failed (exit code ${e}): `),t)),!1!==n.exitIfFailed&&process.exit(e??1))}const Vn={},Un={command:"prisma",describe:"Run prisma commands",builder:t=>t.command(Hn).command(qn).command(Jn).command(Gn).command(Kn).command(Qn).command(Xn).command(Zn).command(ts).command(es).demandCommand(),handler(){}},Hn={command:"deploy",describe:"Apply migration to DB without initializing it",builder:Vn,async handler(t){const e=await ns(t);for(const n of jn("prisma deploy",e))await zn(Mn.deploy(n),n,t)}},Yn={...Vn,"backup-path":{description:"Whether to skip actual command execution",demandOption:!0,type:"string",alias:"b"}},qn={command:"deploy-force <backup-path>",describe:"Force to apply migration to DB utilizing Litestream's backup without initializing it",builder:Yn,async handler(t){const e=await ns(t);for(const n of jn("prisma deploy-force",e))await zn(Mn.deployForce(n,t.backupPath),n,t)}},Jn={command:"litestream",describe:"Setup DB for Litestream",builder:Vn,async handler(t){const e=await ns(t);for(const n of jn("prisma litestream",e))await zn(Mn.litestream(n),n,t)}},Gn={command:"migrate",describe:"Apply migration to DB with initializing it",builder:Vn,async handler(t){const e=await ns(t);for(const n of jn("prisma migrate",e))await zn(Mn.migrate(n),n,t)}},Kn={command:"migrate-dev",describe:"Create a migration file",builder:Vn,async handler(t){const e=await ns(t);for(const n of jn("prisma migrate-dev",e))await zn(Mn.migrateDev(n),n,t)}},Qn={command:"reset",describe:"Reset DB",builder:Vn,async handler(t){const e=await ns(t);for(const n of jn("prisma reset",e))await zn(Mn.reset(n),n,t)}},Xn={command:"restore <backup-path>",describe:"Restore DB from Litestream's backup",builder:{...Yn,output:{description:'Output path of the restored database. Defaults to "<db|prisma>/restored.sqlite3".',type:"string"}},async handler(t){const e=await ns(t);for(const n of jn("prisma restore",e)){const e=t.output||(n.packageJson.dependencies?.blitz?"db/restored.sqlite3":"prisma/restored.sqlite3");await zn(Mn.restore(n,t.backupPath,e),n,t)}}},Zn={command:"seed",describe:"Populate DB with seed data",builder:{...Vn,file:{alias:"f",description:"Path of the seed script.",type:"string"}},async handler(t){const e=await ns(t);for(const n of jn("prisma seed",e))await zn(Mn.seed(n,t.file),n,t)}},ts={command:"studio [db-url-or-path]",describe:"Open Prisma Studio",builder:{...Vn,"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 ns(t);for(const n of jn("prisma studio",e)){const e=t.restored?n.packageJson.dependencies?.blitz?"db/restored.sqlite3":"prisma/restored.sqlite3":t.dbUrlOrPath?.toString();await zn(Mn.studio(n,e),n,t)}}},es={command:"$0 [args..]",describe:"Pass the command and arguments to prisma as is",builder:{args:{type:"array"}},async handler(t){const e=await ns(t),n=`${t.args?.join(" ")??""}`.trimEnd();for(const s of jn(`prisma ${n}`,e))await zn(`PRISMA ${n}`,s,t)}};async function ns(t){const e=await yn(t);e||(console.error(O.red("No project found.")),process.exit(1));const n=e.all.filter((t=>t.packageJson.dependencies?.prisma||t.packageJson.devDependencies?.prisma));return 0===n.length&&(console.error(O.red("No prisma project found.")),process.exit(1)),n}const ss={command:"retry [command] [args...]",describe:"Retry the given command until it succeeds",builder:{retry:{description:"A maximum retry count",type:"number",alias:"r",default:3}},async handler(t){const e=mn(t);e||(console.error(O.red("No project found.")),process.exit(1));const n=[t.command,...t.args??[],...t._.slice(1)].filter(Boolean);let s=0;for(let i=0;i<t.retry;i++)if(i>0&&console.info(`\n${O.yellow(`#${i} Retrying: ${n.join(" ")}`)}`),s=await zn(n.join(" "),e,t,{exitIfFailed:!1}),0===s)return;process.exit(s)}},is={command:"setup",describe:"Setup development environment. .env files are ignored.",builder:{},async handler(t){await async function(t,e){const n=await yn(t,!1,e);n||(console.error(O.red("No project found.")),process.exit(1));for(const e of jn("setup",n.all)){const s=await _.readdir(e.dirPath,{withFileTypes:!0});if(e===n.root){if("darwin"===x.platform()){const n=["pstree"];e.hasDockerfile&&n.push("expect"),await Tn(`brew install ${n.join(" ")}`,e,t)}s.some((t=>t.isFile()&&t.name.includes("-version")))&&await zn("asdf install",e,t)}if(s.some((t=>t.isFile()&&"pyproject.toml"===t.name))){await Tn("poetry config virtualenvs.in-project true",e,t),await Tn("poetry config virtualenvs.prefer-active-python true",e,t);const[,n]=y.execSync("asdf current python").toString().trim().split(/\s+/);await Tn(`poetry env use ${n}`,e,t),await Rn.promiseAll(),await zn("poetry run pip install --upgrade pip",e,t),await zn("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 zn(`yarn add ${a.join(" ")}`,e,t),c.length>0&&await zn(`yarn add -D ${c.join(" ")}`,e,t),o["gen-code"]&&await zn("yarn gen-code",e,t)}}(t)}};const rs=new class{buildDevImage(e,n){const s=e.dockerPackageJson.scripts?.["docker/build/prepare"]?"yarn run docker/build/prepare && ":"";return`cd ${t.dirname(e.findFile("Dockerfile"))}\n && ${s}YARN wb optimizeForDockerBuild --outside\n && YARN wb retry -- docker build -t ${e.dockerImageName}\n --build-arg ARCH=$([ $(uname -m) = 'arm64' ] && echo arm64 || echo amd64)\n --build-arg WB_ENV=${e.env.WB_ENV}\n --build-arg WB_VERSION=${n} .`}stopAndStart(t,e=!1,n="",s=""){return`${this.stop(t)} && ${e?"unbuffer ":""}${this.start(t,n,s)}`}start(t,e="",n=""){return function(t,e){const n=async()=>{if(Dn.has(t))return;Dn.add(t),Bn(t,e);const{status:n}=v(t,{cwd:e.dirPath,shell:!0,stdio:"inherit"});Ln(t,n,{})};for(const t of["beforeExit","SIGINT","SIGTERM","SIGQUIT"])process.on(t,n)}(this.stop(t),t),`docker run --rm -it -p 8080:8080 --name ${t.dockerImageName} ${e} ${t.dockerImageName} ${n}`}stop(t){return`true $(docker rm -f $(docker container ls -q -f name=${t.dockerImageName}) 2> /dev/null)`}stopAll(){return"true $(docker rm -f $(docker ps -q) 2> /dev/null)"}};class os{constructor(t=Number(process.env.PORT)||3e3){this.defaultPort=t}buildDocker(t,e="development"){return rs.buildDevImage(t,e)}startDocker(t,e){return`${this.buildDocker(t)}\n && YARN concurrently --raw --kill-others-on-fail\n "${rs.stopAndStart(t,!1,e.normalizedDockerOptionsText??"",e.normalizedArgsText??"")}"\n "${this.waitAndOpenApp(t,e,8080)}"`}testE2E(t,e,{playwrightArgs:n="test tests/e2e",prismaDirectory:s,startCommand:i}){const r=t.env.WB_ENV;return`WB_ENV=${r} NEXT_PUBLIC_WB_ENV=${r} APP_ENV=${r} PORT=8080 YARN concurrently --kill-others --raw --success first\n "rm -Rf ${s}/mount && ${i} && exit 1"\n "concurrently --kill-others-on-fail --raw 'wait-on -t 600000 -i 2000 http://127.0.0.1:8080' 'yarn playwright install --with-deps'\n && yarn playwright ${n.replace("tests/e2e",e.target||"tests/e2e")}"`}testE2EDev(t,e,{playwrightArgs:n="test tests/e2e",startCommand:s}){const i=t.env.WB_ENV;return`WB_ENV=${i} NEXT_PUBLIC_WB_ENV=${i} APP_ENV=${i} PORT=8080 YARN concurrently --kill-others --raw --success first\n "${s} && exit 1"\n "concurrently --kill-others-on-fail --raw 'wait-on -t 600000 -i 2000 http://127.0.0.1:8080' 'yarn playwright install --with-deps'\n && yarn playwright ${n.replace("tests/e2e",e.target||"tests/e2e")}"`}testUnit(t,e){return`WB_ENV=${t.env.WB_ENV} YARN vitest run ${e.target||"tests/unit"} --color --passWithNoTests --allowOnly`}waitApp(t,e,n=this.defaultPort){return`wait-on -t 10000 http://127.0.0.1:${n} 2> /dev/null\n || wait-on -t 10000 -i 500 http://127.0.0.1:${n} 2> /dev/null\n || wait-on -t 10000 -i 1000 http://127.0.0.1:${n} 2> /dev/null\n || wait-on -t 10000 -i 2000 http://127.0.0.1:${n} 2> /dev/null\n || wait-on -t 20000 -i 4000 http://127.0.0.1:${n} 2> /dev/null\n || wait-on -t 60000 -i 5000 http://127.0.0.1:${n}`}waitAndOpenApp(t,e,n=this.defaultPort){return`${this.waitApp(t,e,n)} || wait-on http://127.0.0.1:${n} && open-cli "http://\${HOST:-localhost}:${n}"`}}const as=new class extends os{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 "${Mn.reset(t)} && ${t.buildCommand} && PORT=${n} pm2-runtime start ${t.findFile("ecosystem.config.cjs")} ${e.normalizedArgsText??""}"\n "${this.waitAndOpenApp(t,e,n)}"`}testE2E(t,e,{playwrightArgs:n,startCommand:s=`${Mn.reset(t)} && ${t.buildCommand} && pm2-runtime start ${t.findFile("ecosystem.config.cjs")}`}){return super.testE2E(t,e,{playwrightArgs:n,prismaDirectory:"db",startCommand:s})}testE2EDev(t,e,{playwrightArgs:n,startCommand:s="blitz dev -p 8080"}){return super.testE2EDev(t,e,{playwrightArgs:n,startCommand:s})}testStart(t,e){return`YARN concurrently --kill-others --raw --success first "blitz dev" "${this.waitApp(t,e)}"`}};const cs=new class extends os{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)} && ${rs.stopAndStart(t,!1,e.normalizedDockerOptionsText??"",e.normalizedArgsText??"")}`}startProduction(t,e,n=8080){return`NODE_ENV=production ${t.buildCommand} && NODE_ENV=production PORT=\${PORT:-${n}} ${Pn} 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 ${e.target||"tests/e2e"} --color --passWithNoTests --allowOnly"`}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 ${e.target||"tests/e2e"} --color --passWithNoTests --allowOnly"`}testStart(t,e){return`YARN concurrently --kill-others --raw --success first "${this.start(t,e)}" "${this.waitApp(t,e)}"`}};const ls=new class extends os{constructor(){super()}start(t,e){return`YARN concurrently --raw --kill-others-on-fail\n "next dev --turbo ${e.normalizedArgsText??""}"\n "${this.waitAndOpenApp(t,e)}"`}startProduction(t,e,n){return`NODE_ENV=production YARN concurrently --raw --kill-others-on-fail\n "${[...t.hasPrisma?[Mn.reset(t)]:[],t.buildCommand,`PORT=${n} pm2-runtime start ${t.findFile("ecosystem.config.cjs")} ${e.normalizedArgsText??""}`].join(" && ")}"\n "${this.waitAndOpenApp(t,e,n)}"`}testE2E(t,e,n){return super.testE2E(t,e,{playwrightArgs:n.playwrightArgs,prismaDirectory:"db",startCommand:n.startCommand??[...t.hasPrisma?[Mn.reset(t)]:[],t.buildCommand,`pm2-runtime start ${t.findFile("ecosystem.config.cjs")}`].join(" && ")})}testE2EDev(t,e,{startCommand:n="next dev --turbo -p 8080"}){return super.testE2EDev(t,e,{startCommand:n})}testStart(t,e){return`YARN concurrently --kill-others --raw --success first "next dev --turbo" "${this.waitApp(t,e)}"`}};const hs=new class extends os{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)} && ${rs.stopAndStart(t,!1,e.normalizedDockerOptionsText??"",e.normalizedArgsText??"")}`}startProduction(t,e){return`NODE_ENV=production ${t.buildCommand} && NODE_ENV=production ${Pn} dist/index.js ${e.normalizedArgsText??""}`}testE2E(){return"echo 'do nothing.'"}testE2EDev(){return"echo 'do nothing.'"}testStart(){return"echo 'do nothing.'"}};const ds=new class extends os{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 "${Mn.reset(t)} && ${t.buildCommand} && PORT=${n} pm2-runtime start ${t.findFile("ecosystem.config.cjs")} ${e.normalizedArgsText??""}"\n "${this.waitAndOpenApp(t,e,n)}"`}testE2E(t,e,{playwrightArgs:n,startCommand:s=`${Mn.reset(t)} && ${t.buildCommand} && pm2-runtime start ${t.findFile("ecosystem.config.cjs")}`}){return super.testE2E(t,e,{playwrightArgs:n,prismaDirectory:"prisma",startCommand:s})}testE2EDev(t,e,{playwrightArgs:n,startCommand:s="remix dev"}){return super.testE2EDev(t,e,{playwrightArgs:n,startCommand:s})}testStart(t,e){return`YARN concurrently --kill-others --raw --success first "remix dev" "${this.waitApp(t,e)}"`}},us={command:"start [args..]",describe:"Start app",builder:{watch:{description:"Whether to watch files",type:"boolean"},args:{description:"Arguments for core command",type:"array",alias:"a",default:[]},"docker-options":{description:'Arguments for "docker run"',type:"array",default:[]},mode:{description:"Start mode: dev[elopment] (default) | staging | docker | docker-debug",type:"string",alias:"m"}},async handler(t){!function(t){t.normalizedArgsText=[...t.args??[],...t._?.slice(1)??[]].map((t=>`'${t}'`)).join(" "),t.normalizedDockerOptionsText=(t.dockerOptions??[]).map((t=>`'${t}'`)).join(" ")}(t);const e=await yn(t);e||(console.error(O.red("No project found.")),process.exit(1));for(const n of e.all){const e=n.packageJson.dependencies||{},s=n.packageJson.devDependencies||{};let i;if(e.blitz)i=as;else if(e.next)i=ls;else if(s["@remix-run/dev"])i=ds;else if((e.express||e.fastify)&&!e["firebase-functions"]||n.hasDockerfile&&/EXPOSE\s+8080/.test(n.dockerfile))i=cs;else{if(!e["build-ts"]&&!s["build-ts"])continue;i=hs}switch(console.info(`Running "start" for ${n.name} ...`),t.mode||"dev"){case"dev":case"development":{const s=fs(e,"development");await zn(`${s}${i.start(n,t)}`,n,t);break}case"staging":{const s=fs(e,"staging");await zn(`${s}${i.startProduction(n,t,8080)}`,n,t);break}case"docker":{const s=fs(e,"staging");await zn(`${s}${i.startDocker(n,t)}`,n,t);break}case"docker-debug":{const s=fs(e,"staging");t.normalizedArgsText="'/bin/bash'",await zn(`${s}${i.startDocker(n,t)}`,n,t);break}default:throw new Error(`Unknown start mode: ${t.mode}`)}}}};function fs(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 ps={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"},target:{description:"Test target",type:"string",alias:"t"}},async handler(e){await async function(e){const n=await yn(e);n||(console.error(O.red("No project found.")),process.exit(1));n.all.length>1&&(process.env.CI="1");process.env.FORCE_COLOR||="3",process.env.WB_ENV||="test";for(const s of n.all){const n=s.packageJson.dependencies||{},i=s.packageJson.devDependencies||{};let r;r=n.blitz?as:n.next?ls:i["@remix-run/dev"]?ds:!n.express&&!n.fastify||n["firebase-functions"]?hs:cs,console.info(`Running "test" for ${s.name} ...`);const o=[];if(!e.ci){switch((e.unit||!e.start&&void 0===e.e2e)&&o.push(zn(r.testUnit(s,e),s,e,{timeout:e.unitTimeout})),e.start&&o.push(zn(r.testStart(s,e),s,e)),await Promise.all(o),e.e2e){case void 0:case"none":continue;case"":case"headless":await zn(r.testE2E(s,e,{}),s,e);continue;case"headless-dev":await zn(r.testE2EDev(s,e,{}),s,e);continue;case"docker":await gs(s,e,r);continue;case"docker-debug":await gs(s,e,r,`test ${e.target||"tests/e2e"} --debug`);continue}if(n.blitz||n.next||i["@remix-run/dev"])switch(e.e2e){case"headed":await zn(r.testE2E(s,e,{playwrightArgs:`test ${e.target||"tests/e2e"} --headed`}),s,e);continue;case"headed-dev":await zn(r.testE2EDev(s,e,{playwrightArgs:`test ${e.target||"tests/e2e"} --headed`}),s,e);continue;case"debug":await zn(r.testE2E(s,e,{playwrightArgs:`test ${e.target||"tests/e2e"} --debug`}),s,e);continue;case"generate":await zn(r.testE2E(s,e,{playwrightArgs:"codegen http://localhost:8080"}),s,e);continue;case"trace":await zn("playwright show-trace",s,e);continue}throw new Error(`Unknown e2e mode: ${e.e2e}`)}{const n=N(t.join(s.dirPath,"tests","unit")),i=N(t.join(s.dirPath,"tests","e2e"));if(await Tn(rs.stopAll(),s,e),!1!==e.unit&&await n&&await Tn(r.testUnit(s,e).replaceAll(" --allowOnly",""),s,e,{timeout:e.unitTimeout}),!1!==e.start&&await Tn(r.testStart(s,e),s,e),await Rn.promiseAll(),"none"!==e.e2e&&await i){s.hasDockerfile&&await zn(`${r.buildDocker(s,"test")}`,s,e);const t=s.hasDockerfile?{startCommand:rs.stopAndStart(s,!0)}:{};process.exitCode=await zn(r.testE2E(s,e,t).replaceAll(" --allowOnly",""),s,e,{exitIfFailed:!1}),await zn(rs.stop(s),s,e)}}}}(e)}};async function gs(t,e,n,s){await zn(`${n.buildDocker(t,"test")}`,t,e),process.exitCode=await zn(`${n.testE2E(t,e,{playwrightArgs:s,startCommand:rs.stopAndStart(t,!0)})}`,t,e,{exitIfFailed:!1}),await zn(rs.stop(t),t,e)}const ms={command:"typecheck",describe:"Run type checking. .env files are ignored.",builder:{},async handler(t){const e=await yn(t,!1);e||(console.error(O.red("No project found.")),process.exit(1));for(const n of e.all){const s=[];if(n.packageJson.workspaces?n.hasSourceCode&&(n.packageJson.dependencies?.typescript||n.packageJson.devDependencies?.typescript)&&s.push("BUN tsc --noEmit --Pretty"):((n.packageJson.dependencies?.typescript||n.packageJson.devDependencies?.typescript)&&s.push("BUN tsc --noEmit --Pretty"),n.packageJson.devDependencies?.pyright&&s.push("YARN 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 zn(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.'))}}}},ys={...ms,command:"tc"},bs={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 vs;await cn((vs=process.argv,vs.slice(nt()+1))).scriptName("wb").options(bs).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(vn).command($n).command(Un).command(ss).command(is).command(us).command(ps).command(ms).command(ys).demandCommand().strict().help().argv;for(const t of["SIGINT","SIGTERM","SIGQUIT"])process.on(t,(()=>process.exit()));
33
+ var J,G,K;const Q=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,X=null!==(G=null===(J=null===process||void 0===process?void 0:process.versions)||void 0===J?void 0:J.node)&&void 0!==G?G:null===(K=null===process||void 0===process?void 0:process.version)||void 0===K?void 0:K.slice(1);if(X){if(Number(X.match(/^([^.]+)/)[1])<Q)throw Error(`yargs parser supports a minimum Node.js version of ${Q}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}const Z=process?process.env:{},tt=new class{constructor(t){H=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.__||H.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=L(e,"-");n!==t&&-1===g.aliases[t].indexOf(n)&&(g.aliases[t].push(n),u[n]=!0)}})),g.aliases[t].forEach((function(e){g.aliases[e]=[t].concat(g.aliases[t].filter((function(t){return e!==t})))})))}))}))}(n.key,r,n.default,g.arrays),Object.keys(a).forEach((function(t){(g.aliases[t]||[]).forEach((function(e){a[e]=a[t]}))}));let b=null;Object.keys(g.counts).find((t=>D(t,g.arrays)?(b=Error(p("Invalid configuration: %s, opts.count excludes opts.array.",t)),!0):!!D(t,g.nargs)&&(b=Error(p("Invalid configuration: %s, opts.count excludes opts.narg.",t)),!0)));let v=[];const w=Object.assign(Object.create(null),{_:[]}),O={};for(let t=0;t<s.length;t++){const e=s[t],n=e.replace(/^-{3,}/,"---");let i,r,a,c,l,h;if("--"!==e&&/^-/.test(e)&&R(e))E(e);else{if(n.match(/^---+(=|$)/)){E(e);continue}if(e.match(/^--.+=/)||!o["short-option-groups"]&&e.match(/^-.+=/))c=e.match(/^--?([^=]+)=([\s\S]*)$/),null!==c&&Array.isArray(c)&&c.length>=3&&(D(c[1],g.arrays)?t=A(t,c[1],s,c[2]):!1!==D(c[1],g.nargs)?t=k(t,c[1],s,c[2]):j(c[1],c[2],!0));else if(e.match(y)&&o["boolean-negation"])c=e.match(y),null!==c&&Array.isArray(c)&&c.length>=2&&(r=c[1],j(r,!!D(r,g.arrays)&&[!1]));else if(e.match(/^--.+/)||!o["short-option-groups"]&&e.match(/^-[^-]+/))c=e.match(/^--?(.+)/),null!==c&&Array.isArray(c)&&c.length>=2&&(r=c[1],D(r,g.arrays)?t=A(t,r,s):!1!==D(r,g.nargs)?t=k(t,r,s):(l=s[t+1],void 0===l||l.match(/^-/)&&!l.match(m)||D(r,g.bools)||D(r,g.counts)?/^(true|false)$/.test(l)?(j(r,l),t++):j(r,W(r)):(j(r,l),t++)));else if(e.match(/^-.\..+=/))c=e.match(/^-([^=]+)=([\s\S]*)$/),null!==c&&Array.isArray(c)&&c.length>=3&&j(c[1],c[2]);else if(e.match(/^-.\..+/)&&!e.match(m))l=s[t+1],c=e.match(/^-(.\..+)/),null!==c&&Array.isArray(c)&&c.length>=2&&(r=c[1],void 0===l||l.match(/^-/)||D(r,g.bools)||D(r,g.counts)?j(r,W(r)):(j(r,l),t++));else if(e.match(/^-[^-]+/)&&!e.match(m)){a=e.slice(1,-1).split(""),i=!1;for(let n=0;n<a.length;n++){if(l=e.slice(n+2),a[n+1]&&"="===a[n+1]){h=e.slice(n+3),r=a[n],D(r,g.arrays)?t=A(t,r,s,h):!1!==D(r,g.nargs)?t=k(t,r,s,h):j(r,h),i=!0;break}if("-"!==l){if(/[A-Za-z]/.test(a[n])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(l)&&!1===D(l,g.bools)){j(a[n],l),i=!0;break}if(a[n+1]&&a[n+1].match(/\W/)){j(a[n],l),i=!0;break}j(a[n],W(a[n]))}else j(a[n],l)}r=e.slice(-1)[0],i||"-"===r||(D(r,g.arrays)?t=A(t,r,s):!1!==D(r,g.nargs)?t=k(t,r,s):(l=s[t+1],void 0===l||/^(-|--)[^-]/.test(l)&&!l.match(m)||D(r,g.bools)||D(r,g.counts)?/^(true|false)$/.test(l)?(j(r,l),t++):j(r,W(r)):(j(r,l),t++)))}else if(e.match(/^-[0-9]$/)&&e.match(m)&&D(e.slice(1),g.bools))r=e.slice(1),j(r,W(r));else{if("--"===e){v=s.slice(t+1);break}if(o["halt-at-non-option"]){v=s.slice(t);break}E(e)}}}function E(t){const e=x("_",t);"string"!=typeof e&&"number"!=typeof e||w._.push(e)}function k(t,e,n,s){let i,r=D(e,g.nargs);if(r="number"!=typeof r||isNaN(r)?1:r,0===r)return z(s)||(b=Error(p("Argument unexpected for: %s",e))),j(e,W(e)),t;let a=z(s)?0:1;if(o["nargs-eats-options"])n.length-(t+1)+a<r&&(b=Error(p("Not enough arguments following: %s",e))),a=r;else{for(i=t+1;i<n.length&&(!n[i].match(/^-[^0-9]/)||n[i].match(m)||R(n[i]));i++)a++;a<r&&(b=Error(p("Not enough arguments following: %s",e)))}let c=Math.min(a,r);for(!z(s)&&c>0&&(j(e,s),c--),i=t+1;i<c+t+1;i++)j(e,n[i]);return t+c}function A(t,e,n,s){let r=[],c=s||n[t+1];const l=D(e,g.nargs);if(D(e,g.bools)&&!/^(true|false)$/.test(c))r.push(!0);else if(z(c)||z(s)&&/^-/.test(c)&&!m.test(c)&&!R(c)){if(void 0!==a[e]){const t=a[e];r=Array.isArray(t)?t:[t]}}else{z(s)||r.push(_(e,s,!0));for(let s=t+1;s<n.length&&!(!o["greedy-arrays"]&&r.length>0||l&&"number"==typeof l&&r.length>=l)&&(c=n[s],!/^-/.test(c)||m.test(c)||R(c));s++)t=s,r.push(_(e,c,i))}return"number"==typeof l&&(l&&r.length<l||isNaN(l)&&0===r.length)&&(b=Error(p("Not enough arguments following: %s",e))),j(e,r),t}function j(t,e,n=i){if(/-/.test(t)&&o["camel-case-expansion"]){const e=t.split(".").map((function(t){return 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?H.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=Y()),D(t,g.normalize)&&D(t,g.arrays)&&(s=Array.isArray(e)?e.map((t=>H.normalize(t))):H.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)){(V(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 S(t,e){if(void 0===l)return;const n="string"==typeof l?l:"",s=H.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 P(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===Y()?s[i]=Y(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=U.BOOLEAN;return D(t,g.strings)?e=U.STRING:D(t,g.numbers)?e=U.NUMBER:D(t,g.bools)?e=U.BOOLEAN:D(t,g.arrays)&&(e=U.ARRAY),e}(t),{[U.BOOLEAN]:!0,[U.STRING]:"",[U.NUMBER]:void 0,[U.ARRAY]:[]}[e]):a[t];var e}function z(t){return void 0===t}return S(w,!0),S(w,!1),function(t){const e=Object.create(null);P(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=H.resolve(H.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=H.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)})),P(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:()=>Z,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")}}),et=function(t,e){return tt.parse(t.slice(),e).argv};function nt(){return process.versions.electron&&!process.defaultApp?0:1}et.detailed=function(t,e){return tt.parse(t.slice(),e)},et.camelCase=B,et.decamelize=L,et.looksLikeNumber=V;class st extends Error{constructor(t){super(t||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,st)}}var it={fs:{readFileSync:u,writeFile:f},format:p,resolve:e,exists:t=>{try{return h(t).isFile()}catch(t){return!1}}};let rt;class ot{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(),rt.format.apply(rt.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),rt.format.apply(rt.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);rt.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{rt.fs.readFileSync&&(t=JSON.parse(rt.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=rt.resolve(t,"./",e+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~e.lastIndexOf("_")){const s=rt.resolve(t,"./",e.split("_")[0]+".json");this._fileExistsSync(s)&&(n=s)}return n}_fileExistsSync(t){return rt.exists(t)}}const at="loading a directory of commands is not supported yet for ESM";let ct;try{ct=m(import.meta.url)}catch(t){ct=process.cwd()}var lt,ht={assert:{notStrictEqual:a,strictEqual:c},cliui:function(t){return function(t,e){return W=e,new I({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:T,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 st(at)},getProcessArgvBin:function(){return process.argv[nt()]},mainFilename:ct.substring(0,ct.lastIndexOf("node_modules"))||process.cwd(),Parser:et,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 st("require is not supported by ESM")},requireDirectory:()=>{throw new st(at)},stringWidth:t=>[...t].length,y18n:(lt={directory:e(ct,"../../../locales"),updateFiles:!1},function(t,e){rt=e;const n=new ot(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}}(lt,it))};function dt(t,e,n,s){n.assert.notStrictEqual(t,e,s)}function ut(t,e){e.assert.strictEqual(typeof t,"string")}function ft(t){return Object.keys(t)}function pt(t){return!!t&&!!t.then&&"function"==typeof t.then}function gt(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 mt=["first","second","third","fourth","fifth","sixth"];function yt(t,e,n){try{let s=0;const[i,r,o]="object"==typeof t?[{demanded:[],optional:[]},t,e]:[gt(`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 st(`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 st(`Too many arguments provided. Expected max ${l} but received ${c}.`);i.demanded.forEach((t=>{const e=bt(a.shift());0===t.cmd.filter((t=>t===e||"*"===t)).length&&vt(e,t.cmd,s),s+=1})),i.optional.forEach((t=>{if(0===a.length)return;const e=bt(a.shift());0===t.cmd.filter((t=>t===e||"*"===t)).length&&vt(e,t.cmd,s),s+=1}))}catch(t){console.warn(t.stack)}}function bt(t){return Array.isArray(t)?"array":null===t?"null":typeof t}function vt(t,e,n){throw new st(`Invalid ${mt[n]||"manyith"} argument. Expected ${e.join(" or ")} but received ${t}.`)}class wt{constructor(t){this.globalMiddleware=[],this.frozens=[],this.yargs=t}addMiddleware(t,e,n=!0,s=!1){if(yt("<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 Ot(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(pt(t))return t.then((t=>Promise.all([t,n(t,e)]))).then((([t,e])=>Object.assign(t,e)));{const s=n(t,e);return pt(s)?s.then((e=>Object.assign(t,e))):Object.assign(t,s)}}),t)}function Et(t,e,n=(t=>{throw t})){try{const n="function"==typeof t?t():t;return pt(n)?n.then((t=>e(t))):e(n)}catch(t){return n(t)}}const kt=/(^\*)|(^\$0)/;class At{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(jt(n))return void this.addHandler([t].concat(o),e,n.builder,n.handler,n.middlewares,n.deprecated)}if("string"==typeof t){const i=gt(t);o=o.map((t=>gt(t).cmd));let c=!1;const l=[i.cmd].concat(o).filter((t=>!kt.test(t)||(c=!0,!1)));0===l.length&&c&&l.push("$0"),c&&(i.cmd=l[0],o=l.slice(1),t=t.replace(kt,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 pt(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($t(c)){n.getInternalMethods().getUsageInstance().freeze();const h=c(n.getInternalMethods().reset(s),a);if(pt(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 pt(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=kt.test(e.original)?e.original.replace(kt,"").trim():e.original,s=t.filter((t=>!kt.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=Et(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=Et(n=Ot(n,r,o,!1),(t=>{const n=e.handler(t);return pt(n)?n.then((()=>t)):t})),t||r.getInternalMethods().getUsageInstance().cacheHelpMessage(),pt(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=Ot(n,o,c,!0);return pt(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=gt(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=kt.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($t(e))return e(t,!0);jt(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;dt(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();dt(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 jt(t){return"object"==typeof t&&!!t.builder&&"function"==typeof t.handler}function $t(t){return"function"==typeof t}function _t(t={},e=(()=>!0)){const n={};return ft(t).forEach((s=>{e(s,t[s])&&(n[s]=t[s])})),n}function xt(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 Ct(t){return"boolean"==typeof t}function St(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()&&xt(!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 st(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(Ct(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} ${Mt(t[0])}`:Mt(t[0]))+Nt(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(Mt(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:Mt(i),padding:[0,2,0,2+Nt(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 Nt(t){return Pt(t)?t.indentation:0}function Mt(t){return Pt(t)?t.text:t}class Dt{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($t(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=gt(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=!(t=>/^--/.test(t))(n)&&(t=>/^[^0-9]$/.test(t))(t)?"-":"--";e.push(l+c),s&&e.push(l+"no-"+c)}customCompletion(t,e,n,s){if(dt(this.customCompletionFunction,null,this.shim),this.customCompletionFunction.length<3){const t=this.customCompletionFunction(n,e);return pt(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 pt(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 It(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 Rt=["$0","--","_"];let Wt,zt=[];function Tt(t,e,n,s){Wt=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 Wt.path.resolve(t,e)}(e,t.extends);else try{r=require.resolve(t.extends)}catch(e){return t}!function(t){if(zt.indexOf(t)>-1)throw new st(`Circular extended configurations: '${t}'.`)}(r),zt.push(r),i=s?JSON.parse(Wt.readFileSync(r,"utf8")):require(t.extends),delete t.extends,i=Tt(i,Wt.path.dirname(r),n,Wt)}return zt=[],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,Lt,Vt,Ut,Ht,Yt,qt,Jt,Gt,Kt,Qt,Xt,Zt,te,ee,ne,se,ie,re,oe,ae,ce,le,he,de,ue,fe,pe,ge,me,ye,be,ve,we,Oe,Ee=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},ke=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 Ae=Symbol("copyDoubleDash"),je=Symbol("copyDoubleDash"),$e=Symbol("deleteFromParserHintObject"),_e=Symbol("emitWarning"),xe=Symbol("freeze"),Ce=Symbol("getDollarZero"),Se=Symbol("getParserConfiguration"),Pe=Symbol("getUsageConfiguration"),Ne=Symbol("guessLocale"),Me=Symbol("guessVersion"),De=Symbol("parsePositionalNumbers"),Ie=Symbol("pkgUp"),Re=Symbol("populateParserHintArray"),We=Symbol("populateParserHintSingleValueDictionary"),ze=Symbol("populateParserHintArrayDictionary"),Te=Symbol("populateParserHintDictionary"),Fe=Symbol("sanitizeKey"),Be=Symbol("setKey"),Le=Symbol("unfreeze"),Ve=Symbol("validateAsync"),Ue=Symbol("getCommandInstance"),He=Symbol("getContext"),Ye=Symbol("getHasOutput"),qe=Symbol("getLoggerInstance"),Je=Symbol("getParseContext"),Ge=Symbol("getUsageInstance"),Ke=Symbol("getValidationInstance"),Qe=Symbol("hasParseCallback"),Xe=Symbol("isGlobalContext"),Ze=Symbol("postProcess"),tn=Symbol("rebase"),en=Symbol("reset"),nn=Symbol("runYargsParserAndExecuteCommands"),sn=Symbol("runValidation"),rn=Symbol("setHasOutput"),on=Symbol("kTrackManuallySetKeys");class an{constructor(t=[],e,n,s){this.customScriptName=!1,this.parsed=!1,Bt.set(this,void 0),Lt.set(this,void 0),Vt.set(this,{commands:[],fullCommands:[]}),Ut.set(this,null),Ht.set(this,null),Yt.set(this,"show-hidden"),qt.set(this,null),Jt.set(this,!0),Gt.set(this,{}),Kt.set(this,!0),Qt.set(this,[]),Xt.set(this,void 0),Zt.set(this,{}),te.set(this,!1),ee.set(this,null),ne.set(this,!0),se.set(this,void 0),ie.set(this,""),re.set(this,void 0),oe.set(this,void 0),ae.set(this,{}),ce.set(this,null),le.set(this,null),he.set(this,{}),de.set(this,{}),ue.set(this,void 0),fe.set(this,!1),pe.set(this,void 0),ge.set(this,!1),me.set(this,!1),ye.set(this,!1),be.set(this,void 0),ve.set(this,{}),we.set(this,null),Oe.set(this,void 0),Ee(this,pe,s,"f"),Ee(this,ue,t,"f"),Ee(this,Lt,e,"f"),Ee(this,oe,n,"f"),Ee(this,Xt,new wt(this),"f"),this.$0=this[Ce](),this[en](),Ee(this,Bt,ke(this,Bt,"f"),"f"),Ee(this,be,ke(this,be,"f"),"f"),Ee(this,Oe,ke(this,Oe,"f"),"f"),Ee(this,re,ke(this,re,"f"),"f"),ke(this,re,"f").showHiddenOpt=ke(this,Yt,"f"),Ee(this,se,this[je](),"f")}addHelpOpt(t,e){return yt("[string|boolean] [string]",[t,e],arguments.length),ke(this,ee,"f")&&(this[$e](ke(this,ee,"f")),Ee(this,ee,null,"f")),!1===t&&void 0===e||(Ee(this,ee,"string"==typeof t?t:"help","f"),this.boolean(ke(this,ee,"f")),this.describe(ke(this,ee,"f"),e||ke(this,be,"f").deferY18nLookup("Show help"))),this}help(t,e){return this.addHelpOpt(t,e)}addShowHiddenOpt(t,e){if(yt("[string|boolean] [string]",[t,e],arguments.length),!1===t&&void 0===e)return this;const n="string"==typeof t?t:ke(this,Yt,"f");return this.boolean(n),this.describe(n,e||ke(this,be,"f").deferY18nLookup("Show hidden options")),ke(this,re,"f").showHiddenOpt=n,this}showHidden(t,e){return this.addShowHiddenOpt(t,e)}alias(t,e){return yt("<object|string|array> [string|array]",[t,e],arguments.length),this[ze](this.alias.bind(this),"alias",t,e),this}array(t){return yt("<array|string>",[t],arguments.length),this[Re]("array",t),this[on](t),this}boolean(t){return yt("<array|string>",[t],arguments.length),this[Re]("boolean",t),this[on](t),this}check(t,e){return yt("<function> [boolean]",[t,e],arguments.length),this.middleware(((e,n)=>Et((()=>t(e,n.getOptions())),(n=>(n?("string"==typeof n||n instanceof Error)&&ke(this,be,"f").fail(n.toString(),n):ke(this,be,"f").fail(ke(this,pe,"f").y18n.__("Argument check failed: %s",t.toString())),e)),(t=>(ke(this,be,"f").fail(t.message?t.message:t.toString(),t),e)))),!1,e),this}choices(t,e){return yt("<object|string|array> [string|array]",[t,e],arguments.length),this[ze](this.choices.bind(this),"choices",t,e),this}coerce(t,e){if(yt("<object|string|array> [function]",[t,e],arguments.length),Array.isArray(t)){if(!e)throw new st("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 st("coerce callback must be provided");return ke(this,re,"f").key[t]=!0,ke(this,Xt,"f").addCoerceMiddleware(((n,s)=>{let i;return Object.prototype.hasOwnProperty.call(n,t)?Et((()=>(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 st(t.message)})):n}),t),this}conflicts(t,e){return yt("<string|object> [string|array]",[t,e],arguments.length),ke(this,Oe,"f").conflicts(t,e),this}config(t="config",e,n){return yt("[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||ke(this,be,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(t)?t:[t]).forEach((t=>{ke(this,re,"f").config[t]=n||!0})),this):(t=Tt(t,ke(this,Lt,"f"),this[Se]()["deep-merge-config"]||!1,ke(this,pe,"f")),ke(this,re,"f").configObjects=(ke(this,re,"f").configObjects||[]).concat(t),this)}completion(t,e,n){return yt("[string] [string|boolean|function] [function]",[t,e,n],arguments.length),"function"==typeof e&&(n=e,e=void 0),Ee(this,Ht,t||ke(this,Ht,"f")||"completion","f"),e||!1===e||(e="generate completion script"),this.command(ke(this,Ht,"f"),e),n&&ke(this,Ut,"f").registerFunction(n),this}command(t,e,n,s,i,r){return yt("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[t,e,n,s,i,r],arguments.length),ke(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){yt("<string> [object]",[t,e],arguments.length);const n=ke(this,oe,"f")||ke(this,pe,"f").require;return ke(this,Bt,"f").addDirectory(t,n,ke(this,pe,"f").getCallerFile(),e),this}count(t){return yt("<array|string>",[t],arguments.length),this[Re]("count",t),this[on](t),this}default(t,e,n){return yt("<object|string|array> [*] [string]",[t,e,n],arguments.length),n&&(ut(t,ke(this,pe,"f")),ke(this,re,"f").defaultDescription[t]=n),"function"==typeof e&&(ut(t,ke(this,pe,"f")),ke(this,re,"f").defaultDescription[t]||(ke(this,re,"f").defaultDescription[t]=ke(this,be,"f").functionDescription(e)),e=e.call()),this[We](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 yt("[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),ke(this,re,"f").demandedCommands._={min:t,max:e,minMsg:n,maxMsg:s},this}demand(t,e,n){return Array.isArray(e)?(e.forEach((t=>{dt(n,!0,ke(this,pe,"f")),this.demandOption(t,n)})),e=1/0):"number"!=typeof e&&(n=e,e=1/0),"number"==typeof t?(dt(n,!0,ke(this,pe,"f")),this.demandCommand(t,e,n,n)):Array.isArray(t)?t.forEach((t=>{dt(n,!0,ke(this,pe,"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 yt("<object|string|array> [string]",[t,e],arguments.length),this[We](this.demandOption.bind(this),"demandedOptions",t,e),this}deprecateOption(t,e){return yt("<string> [string|boolean]",[t,e],arguments.length),ke(this,re,"f").deprecatedOptions[t]=e,this}describe(t,e){return yt("<object|string|array> [string]",[t,e],arguments.length),this[Be](t,!0),ke(this,be,"f").describe(t,e),this}detectLocale(t){return yt("<boolean>",[t],arguments.length),Ee(this,Jt,t,"f"),this}env(t){return yt("[string|boolean]",[t],arguments.length),!1===t?delete ke(this,re,"f").envPrefix:ke(this,re,"f").envPrefix=t||"",this}epilogue(t){return yt("<string>",[t],arguments.length),ke(this,be,"f").epilog(t),this}epilog(t){return this.epilogue(t)}example(t,e){return yt("<string|array> [string]",[t,e],arguments.length),Array.isArray(t)?t.forEach((t=>this.example(...t))):ke(this,be,"f").example(t,e),this}exit(t,e){Ee(this,te,!0,"f"),Ee(this,qt,e,"f"),ke(this,Kt,"f")&&ke(this,pe,"f").process.exit(t)}exitProcess(t=!0){return yt("[boolean]",[t],arguments.length),Ee(this,Kt,t,"f"),this}fail(t){if(yt("<function|boolean>",[t],arguments.length),"boolean"==typeof t&&!1!==t)throw new st("Invalid first argument. Expected function or boolean 'false'");return ke(this,be,"f").failFn(t),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(t,e){return yt("<array> [function]",[t,e],arguments.length),e?ke(this,Ut,"f").getCompletion(t,e):new Promise(((e,n)=>{ke(this,Ut,"f").getCompletion(t,((t,s)=>{t?n(t):e(s)}))}))}getDemandedOptions(){return yt([],0),ke(this,re,"f").demandedOptions}getDemandedCommands(){return yt([],0),ke(this,re,"f").demandedCommands}getDeprecatedOptions(){return yt([],0),ke(this,re,"f").deprecatedOptions}getDetectLocale(){return ke(this,Jt,"f")}getExitProcess(){return ke(this,Kt,"f")}getGroups(){return Object.assign({},ke(this,Zt,"f"),ke(this,de,"f"))}getHelp(){if(Ee(this,te,!0,"f"),!ke(this,be,"f").hasCachedHelpMessage()){if(!this.parsed){const t=this[nn](ke(this,ue,"f"),void 0,void 0,0,!0);if(pt(t))return t.then((()=>ke(this,be,"f").help()))}const t=ke(this,Bt,"f").runDefaultBuilderOn(this);if(pt(t))return t.then((()=>ke(this,be,"f").help()))}return Promise.resolve(ke(this,be,"f").help())}getOptions(){return ke(this,re,"f")}getStrict(){return ke(this,ge,"f")}getStrictCommands(){return ke(this,me,"f")}getStrictOptions(){return ke(this,ye,"f")}global(t,e){return yt("<string|array> [boolean]",[t,e],arguments.length),t=[].concat(t),!1!==e?ke(this,re,"f").local=ke(this,re,"f").local.filter((e=>-1===t.indexOf(e))):t.forEach((t=>{ke(this,re,"f").local.includes(t)||ke(this,re,"f").local.push(t)})),this}group(t,e){yt("<string|array> <string>",[t,e],arguments.length);const n=ke(this,de,"f")[e]||ke(this,Zt,"f")[e];ke(this,de,"f")[e]&&delete ke(this,de,"f")[e];const s={};return ke(this,Zt,"f")[e]=(n||[]).concat(t).filter((t=>!s[t]&&(s[t]=!0))),this}hide(t){return yt("<string>",[t],arguments.length),ke(this,re,"f").hiddenOptions.push(t),this}implies(t,e){return yt("<string|object> [number|string|array]",[t,e],arguments.length),ke(this,Oe,"f").implies(t,e),this}locale(t){return yt("[string]",[t],arguments.length),void 0===t?(this[Ne](),ke(this,pe,"f").y18n.getLocale()):(Ee(this,Jt,!1,"f"),ke(this,pe,"f").y18n.setLocale(t),this)}middleware(t,e,n){return ke(this,Xt,"f").addMiddleware(t,!!e,n)}nargs(t,e){return yt("<string|object|array> [number]",[t,e],arguments.length),this[We](this.nargs.bind(this),"narg",t,e),this}normalize(t){return yt("<array|string>",[t],arguments.length),this[Re]("normalize",t),this}number(t){return yt("<array|string>",[t],arguments.length),this[Re]("number",t),this[on](t),this}option(t,e){if(yt("<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[on](t),!ke(this,we,"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"),ke(this,re,"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&&(ke(this,re,"f").defaultDescription[t]=e.defaultDescription),e.skipValidation&&this.skipValidation(t);const i=e.describe||e.description||e.desc,r=ke(this,be,"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){yt("[string|array] [function|boolean|object] [function]",[t,e,n],arguments.length),this[xe](),void 0===t&&(t=ke(this,ue,"f")),"object"==typeof e&&(Ee(this,le,e,"f"),e=n),"function"==typeof e&&(Ee(this,ce,e,"f"),e=!1),e||Ee(this,ue,t,"f"),ke(this,ce,"f")&&Ee(this,Kt,!1,"f");const s=this[nn](t,!!e),i=this.parsed;return ke(this,Ut,"f").setParsed(this.parsed),pt(s)?s.then((t=>(ke(this,ce,"f")&&ke(this,ce,"f").call(this,ke(this,qt,"f"),t,ke(this,ie,"f")),t))).catch((t=>{throw ke(this,ce,"f")&&ke(this,ce,"f")(t,this.parsed.argv,ke(this,ie,"f")),t})).finally((()=>{this[Le](),this.parsed=i})):(ke(this,ce,"f")&&ke(this,ce,"f").call(this,ke(this,qt,"f"),s,ke(this,ie,"f")),this[Le](),this.parsed=i,s)}parseAsync(t,e,n){const s=this.parse(t,e,n);return pt(s)?s:Promise.resolve(s)}parseSync(t,e,n){const s=this.parse(t,e,n);if(pt(s))throw new st(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return s}parserConfiguration(t){return yt("<object>",[t],arguments.length),Ee(this,ae,t,"f"),this}pkgConf(t,e){yt("<string> [string]",[t,e],arguments.length);let n=null;const s=this[Ie](e||ke(this,Lt,"f"));return s[t]&&"object"==typeof s[t]&&(n=Tt(s[t],e||ke(this,Lt,"f"),this[Se]()["deep-merge-config"]||!1,ke(this,pe,"f")),ke(this,re,"f").configObjects=(ke(this,re,"f").configObjects||[]).concat(n)),this}positional(t,e){yt("<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=ke(this,Vt,"f").fullCommands[ke(this,Vt,"f").fullCommands.length-1],i=s?ke(this,Bt,"f").cmdToParseOptions(s):{array:[],alias:{},default:{},demand:{}};return ft(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,ke(this,be,"f").getPositionalGroupName()),this.option(t,e)}recommendCommands(t=!0){return yt("[boolean]",[t],arguments.length),Ee(this,fe,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 yt("<array|string|object> [number]",[t],arguments.length),"string"==typeof t&&ke(this,re,"f").narg[t]||this[We](this.requiresArg.bind(this),"narg",t,NaN),this}showCompletionScript(t,e){return yt("[string] [string]",[t,e],arguments.length),t=t||this.$0,ke(this,se,"f").log(ke(this,Ut,"f").generateCompletionScript(t,e||ke(this,Ht,"f")||"completion")),this}showHelp(t){if(yt("[string|function]",[t],arguments.length),Ee(this,te,!0,"f"),!ke(this,be,"f").hasCachedHelpMessage()){if(!this.parsed){const e=this[nn](ke(this,ue,"f"),void 0,void 0,0,!0);if(pt(e))return e.then((()=>{ke(this,be,"f").showHelp(t)})),this}const e=ke(this,Bt,"f").runDefaultBuilderOn(this);if(pt(e))return e.then((()=>{ke(this,be,"f").showHelp(t)})),this}return ke(this,be,"f").showHelp(t),this}scriptName(t){return this.customScriptName=!0,this.$0=t,this}showHelpOnFail(t,e){return yt("[boolean|string] [string]",[t,e],arguments.length),ke(this,be,"f").showHelpOnFail(t,e),this}showVersion(t){return yt("[string|function]",[t],arguments.length),ke(this,be,"f").showVersion(t),this}skipValidation(t){return yt("<array|string>",[t],arguments.length),this[Re]("skipValidation",t),this}strict(t){return yt("[boolean]",[t],arguments.length),Ee(this,ge,!1!==t,"f"),this}strictCommands(t){return yt("[boolean]",[t],arguments.length),Ee(this,me,!1!==t,"f"),this}strictOptions(t){return yt("[boolean]",[t],arguments.length),Ee(this,ye,!1!==t,"f"),this}string(t){return yt("<array|string>",[t],arguments.length),this[Re]("string",t),this[on](t),this}terminalWidth(){return yt([],0),ke(this,pe,"f").process.stdColumns}updateLocale(t){return this.updateStrings(t)}updateStrings(t){return yt("<object>",[t],arguments.length),Ee(this,Jt,!1,"f"),ke(this,pe,"f").y18n.updateLocale(t),this}usage(t,e,n,s){if(yt("<string|null|undefined> [string|boolean] [function|object] [function]",[t,e,n,s],arguments.length),void 0!==e){if(dt(t,null,ke(this,pe,"f")),(t||"").match(/^\$0( |$)/))return this.command(t,e,n,s);throw new st(".usage() description must start with $0 if being used as alias for .command()")}return ke(this,be,"f").usage(t),this}usageConfiguration(t){return yt("<object>",[t],arguments.length),Ee(this,ve,t,"f"),this}version(t,e,n){const s="version";if(yt("[boolean|string] [string] [string]",[t,e,n],arguments.length),ke(this,we,"f")&&(this[$e](ke(this,we,"f")),ke(this,be,"f").version(void 0),Ee(this,we,null,"f")),0===arguments.length)n=this[Me](),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 Ee(this,we,"string"==typeof t?t:s,"f"),e=e||ke(this,be,"f").deferY18nLookup("Show version number"),ke(this,be,"f").version(n||void 0),this.boolean(ke(this,we,"f")),this.describe(ke(this,we,"f"),e),this}wrap(t){return yt("<number|null|undefined>",[t],arguments.length),ke(this,be,"f").wrap(t),this}[(Bt=new WeakMap,Lt=new WeakMap,Vt=new WeakMap,Ut=new WeakMap,Ht=new WeakMap,Yt=new WeakMap,qt=new WeakMap,Jt=new WeakMap,Gt=new WeakMap,Kt=new WeakMap,Qt=new WeakMap,Xt=new WeakMap,Zt=new WeakMap,te=new WeakMap,ee=new WeakMap,ne=new WeakMap,se=new WeakMap,ie=new WeakMap,re=new WeakMap,oe=new WeakMap,ae=new WeakMap,ce=new WeakMap,le=new WeakMap,he=new WeakMap,de=new WeakMap,ue=new WeakMap,fe=new WeakMap,pe=new WeakMap,ge=new WeakMap,me=new WeakMap,ye=new WeakMap,be=new WeakMap,ve=new WeakMap,we=new WeakMap,Oe=new WeakMap,Ae)](t){if(!t._||!t["--"])return t;t._.push.apply(t._,t["--"]);try{delete t["--"]}catch(t){}return t}[je](){return{log:(...t)=>{this[Qe]()||console.log(...t),Ee(this,te,!0,"f"),ke(this,ie,"f").length&&Ee(this,ie,ke(this,ie,"f")+"\n","f"),Ee(this,ie,ke(this,ie,"f")+t.join(" "),"f")},error:(...t)=>{this[Qe]()||console.error(...t),Ee(this,te,!0,"f"),ke(this,ie,"f").length&&Ee(this,ie,ke(this,ie,"f")+"\n","f"),Ee(this,ie,ke(this,ie,"f")+t.join(" "),"f")}}}[$e](t){ft(ke(this,re,"f")).forEach((e=>{if("configObjects"===e)return;const n=ke(this,re,"f")[e];Array.isArray(n)?n.includes(t)&&n.splice(n.indexOf(t),1):"object"==typeof n&&delete n[t]})),delete ke(this,be,"f").getDescriptions()[t]}[_e](t,e,n){ke(this,Gt,"f")[n]||(ke(this,pe,"f").process.emitWarning(t,e),ke(this,Gt,"f")[n]=!0)}[xe](){ke(this,Qt,"f").push({options:ke(this,re,"f"),configObjects:ke(this,re,"f").configObjects.slice(0),exitProcess:ke(this,Kt,"f"),groups:ke(this,Zt,"f"),strict:ke(this,ge,"f"),strictCommands:ke(this,me,"f"),strictOptions:ke(this,ye,"f"),completionCommand:ke(this,Ht,"f"),output:ke(this,ie,"f"),exitError:ke(this,qt,"f"),hasOutput:ke(this,te,"f"),parsed:this.parsed,parseFn:ke(this,ce,"f"),parseContext:ke(this,le,"f")}),ke(this,be,"f").freeze(),ke(this,Oe,"f").freeze(),ke(this,Bt,"f").freeze(),ke(this,Xt,"f").freeze()}[Ce](){let t,e="";return t=/\b(node|iojs|electron)(\.exe)?$/.test(ke(this,pe,"f").process.argv()[0])?ke(this,pe,"f").process.argv().slice(1,2):ke(this,pe,"f").process.argv().slice(0,1),e=t.map((t=>{const e=this[tn](ke(this,Lt,"f"),t);return t.match(/^(\/|([a-zA-Z]:)?\\)/)&&e.length<t.length?e:t})).join(" ").trim(),ke(this,pe,"f").getEnv("_")&&ke(this,pe,"f").getProcessArgvBin()===ke(this,pe,"f").getEnv("_")&&(e=ke(this,pe,"f").getEnv("_").replace(`${ke(this,pe,"f").path.dirname(ke(this,pe,"f").process.execPath())}/`,"")),e}[Se](){return ke(this,ae,"f")}[Pe](){return ke(this,ve,"f")}[Ne](){if(!ke(this,Jt,"f"))return;const t=ke(this,pe,"f").getEnv("LC_ALL")||ke(this,pe,"f").getEnv("LC_MESSAGES")||ke(this,pe,"f").getEnv("LANG")||ke(this,pe,"f").getEnv("LANGUAGE")||"en_US";this.locale(t.replace(/[.:].*/,""))}[Me](){return this[Ie]().version||"unknown"}[De](t){const e=t["--"]?t["--"]:t._;for(let t,n=0;void 0!==(t=e[n]);n++)ke(this,pe,"f").Parser.looksLikeNumber(t)&&Number.isSafeInteger(Math.floor(parseFloat(`${t}`)))&&(e[n]=Number(t));return t}[Ie](t){const e=t||"*";if(ke(this,he,"f")[e])return ke(this,he,"f")[e];let n={};try{let e=t||ke(this,pe,"f").mainFilename;!t&&ke(this,pe,"f").path.extname(e)&&(e=ke(this,pe,"f").path.dirname(e));const s=ke(this,pe,"f").findUp(e,((t,e)=>e.includes("package.json")?"package.json":void 0));dt(s,void 0,ke(this,pe,"f")),n=JSON.parse(ke(this,pe,"f").readFileSync(s,"utf8"))}catch(t){}return ke(this,he,"f")[e]=n||{},ke(this,he,"f")[e]}[Re](t,e){(e=[].concat(e)).forEach((e=>{e=this[Fe](e),ke(this,re,"f")[t].push(e)}))}[We](t,e,n,s){this[Te](t,e,n,s,((t,e,n)=>{ke(this,re,"f")[t][e]=n}))}[ze](t,e,n,s){this[Te](t,e,n,s,((t,e,n)=>{ke(this,re,"f")[t][e]=(ke(this,re,"f")[t][e]||[]).concat(n)}))}[Te](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 ft(n))t(e,n[e]);else i(e,this[Fe](n),s)}[Fe](t){return"__proto__"===t?"___proto___":t}[Be](t,e){return this[We](this[Be].bind(this),"key",t,e),this}[Le](){var t,e,n,s,i,r,o,a,c,l,h,d;const u=ke(this,Qt,"f").pop();let f;dt(u,void 0,ke(this,pe,"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){Ee(t,re,e,"f")}}.value,configObjects:f,exitProcess:{set value(t){Ee(e,Kt,t,"f")}}.value,groups:{set value(t){Ee(n,Zt,t,"f")}}.value,output:{set value(t){Ee(s,ie,t,"f")}}.value,exitError:{set value(t){Ee(i,qt,t,"f")}}.value,hasOutput:{set value(t){Ee(r,te,t,"f")}}.value,parsed:this.parsed,strict:{set value(t){Ee(o,ge,t,"f")}}.value,strictCommands:{set value(t){Ee(a,me,t,"f")}}.value,strictOptions:{set value(t){Ee(c,ye,t,"f")}}.value,completionCommand:{set value(t){Ee(l,Ht,t,"f")}}.value,parseFn:{set value(t){Ee(h,ce,t,"f")}}.value,parseContext:{set value(t){Ee(d,le,t,"f")}}.value}=u),ke(this,re,"f").configObjects=f,ke(this,be,"f").unfreeze(),ke(this,Oe,"f").unfreeze(),ke(this,Bt,"f").unfreeze(),ke(this,Xt,"f").unfreeze()}[Ve](t,e){return Et(e,(e=>(t(e),e)))}getInternalMethods(){return{getCommandInstance:this[Ue].bind(this),getContext:this[He].bind(this),getHasOutput:this[Ye].bind(this),getLoggerInstance:this[qe].bind(this),getParseContext:this[Je].bind(this),getParserConfiguration:this[Se].bind(this),getUsageConfiguration:this[Pe].bind(this),getUsageInstance:this[Ge].bind(this),getValidationInstance:this[Ke].bind(this),hasParseCallback:this[Qe].bind(this),isGlobalContext:this[Xe].bind(this),postProcess:this[Ze].bind(this),reset:this[en].bind(this),runValidation:this[sn].bind(this),runYargsParserAndExecuteCommands:this[nn].bind(this),setHasOutput:this[rn].bind(this)}}[Ue](){return ke(this,Bt,"f")}[He](){return ke(this,Vt,"f")}[Ye](){return ke(this,te,"f")}[qe](){return ke(this,se,"f")}[Je](){return ke(this,le,"f")||{}}[Ge](){return ke(this,be,"f")}[Ke](){return ke(this,Oe,"f")}[Qe](){return!!ke(this,ce,"f")}[Xe](){return ke(this,ne,"f")}[Ze](t,e,n,s){if(n)return t;if(pt(t))return t;e||(t=this[Ae](t));return(this[Se]()["parse-positional-numbers"]||void 0===this[Se]()["parse-positional-numbers"])&&(t=this[De](t)),s&&(t=Ot(t,this,ke(this,Xt,"f").getMiddleware(),!1)),t}[en](t={}){Ee(this,re,ke(this,re,"f")||{},"f");const e={};e.local=ke(this,re,"f").local||[],e.configObjects=ke(this,re,"f").configObjects||[];const n={};e.local.forEach((e=>{n[e]=!0,(t[e]||[]).forEach((t=>{n[t]=!0}))})),Object.assign(ke(this,de,"f"),Object.keys(ke(this,Zt,"f")).reduce(((t,e)=>{const s=ke(this,Zt,"f")[e].filter((t=>!(t in n)));return s.length>0&&(t[e]=s),t}),{})),Ee(this,Zt,{},"f");return["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"].forEach((t=>{e[t]=(ke(this,re,"f")[t]||[]).filter((t=>!n[t]))})),["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"].forEach((t=>{e[t]=_t(ke(this,re,"f")[t],(t=>!n[t]))})),e.envPrefix=ke(this,re,"f").envPrefix,Ee(this,re,e,"f"),Ee(this,be,ke(this,be,"f")?ke(this,be,"f").reset(n):St(this,ke(this,pe,"f")),"f"),Ee(this,Oe,ke(this,Oe,"f")?ke(this,Oe,"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=>{Rt.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===Rt.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){yt("<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))):(dt(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){yt("<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=It(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();dt(t,void 0,n),({implied:o,conflicting:c}=t)},r}(this,ke(this,be,"f"),ke(this,pe,"f")),"f"),Ee(this,Bt,ke(this,Bt,"f")?ke(this,Bt,"f").reset():function(t,e,n,s){return new At(t,e,n,s)}(ke(this,be,"f"),ke(this,Oe,"f"),ke(this,Xt,"f"),ke(this,pe,"f")),"f"),ke(this,Ut,"f")||Ee(this,Ut,function(t,e,n,s){return new Dt(t,e,n,s)}(this,ke(this,be,"f"),ke(this,Bt,"f"),ke(this,pe,"f")),"f"),ke(this,Xt,"f").reset(),Ee(this,Ht,null,"f"),Ee(this,ie,"","f"),Ee(this,qt,null,"f"),Ee(this,te,!1,"f"),this.parsed=!1,this}[tn](t,e){return ke(this,pe,"f").path.relative(t,e)}[nn](t,e,n,s=0,i=!1){let r=!!n||i;t=t||ke(this,ue,"f"),ke(this,re,"f").__=ke(this,pe,"f").y18n.__,ke(this,re,"f").configuration=this[Se]();const o=!!ke(this,re,"f").configuration["populate--"],a=Object.assign({},ke(this,re,"f").configuration,{"populate--":!0}),c=ke(this,pe,"f").Parser.detailed(t,Object.assign({},ke(this,re,"f"),{configuration:{"parse-positional-numbers":!1,...a}})),l=Object.assign(c.argv,ke(this,le,"f"));let h;const d=c.aliases;let u=!1,f=!1;Object.keys(l).forEach((t=>{t===ke(this,ee,"f")&&l[t]?u=!0:t===ke(this,we,"f")&&l[t]&&(f=!0)})),l.$0=this.$0,this.parsed=c,0===s&&ke(this,be,"f").clearCachedHelpMessage();try{if(this[Ne](),e)return this[Ze](l,o,!!n,!1);if(ke(this,ee,"f")){[ke(this,ee,"f")].concat(d[ke(this,ee,"f")]||[]).filter((t=>t.length>1)).includes(""+l._[l._.length-1])&&(l._.pop(),u=!0)}Ee(this,ne,!1,"f");const a=ke(this,Bt,"f").getCommands(),p=ke(this,Ut,"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!==ke(this,Ht,"f")){const t=ke(this,Bt,"f").runCommand(e,this,c,r+1,i,u||f||i);return this[Ze](t,o,!!n,!1)}if(!t&&e!==ke(this,Ht,"f")){t=e;break}}!ke(this,Bt,"f").hasDefaultCommand()&&ke(this,fe,"f")&&t&&!g&&ke(this,Oe,"f").recommendCommands(t,a)}ke(this,Ht,"f")&&l._.includes(ke(this,Ht,"f"))&&!p&&(ke(this,Kt,"f")&&xt(!0),this.showCompletionScript(),this.exit(0))}if(ke(this,Bt,"f").hasDefaultCommand()&&!g){const t=ke(this,Bt,"f").runCommand(null,this,c,0,i,u||f||i);return this[Ze](t,o,!!n,!1)}if(p){ke(this,Kt,"f")&&xt(!0);const e=(t=[].concat(t)).slice(t.indexOf(`--${ke(this,Ut,"f").completionKey}`)+1);return ke(this,Ut,"f").getCompletion(e,((t,e)=>{if(t)throw new st(t.message);(e||[]).forEach((t=>{ke(this,se,"f").log(t)})),this.exit(0)})),this[Ze](l,!o,!!n,!1)}if(ke(this,te,"f")||(u?(ke(this,Kt,"f")&&xt(!0),r=!0,this.showHelp("log"),this.exit(0)):f&&(ke(this,Kt,"f")&&xt(!0),r=!0,ke(this,be,"f").showVersion("log"),this.exit(0))),!r&&ke(this,re,"f").skipValidation.length>0&&(r=Object.keys(l).some((t=>ke(this,re,"f").skipValidation.indexOf(t)>=0&&!0===l[t]))),!r){if(c.error)throw new st(c.error.message);if(!p){const t=this[sn](d,{},c.error);n||(h=Ot(l,this,ke(this,Xt,"f").getMiddleware(),!0)),h=this[Ve](t,null!=h?h:l),pt(h)&&!n&&(h=h.then((()=>Ot(l,this,ke(this,Xt,"f").getMiddleware(),!1))))}}}catch(t){if(!(t instanceof st))throw t;ke(this,be,"f").fail(t.message,t)}return this[Ze](null!=h?h:l,o,!!n,!0)}[sn](t,e,n,s){const i={...this.getDemandedOptions()};return r=>{if(n)throw new st(n.message);ke(this,Oe,"f").nonOptionCount(r),ke(this,Oe,"f").requiredArguments(r,i);let o=!1;ke(this,me,"f")&&(o=ke(this,Oe,"f").unknownCommands(r)),ke(this,ge,"f")&&!o?ke(this,Oe,"f").unknownArguments(r,t,e,!!s):ke(this,ye,"f")&&ke(this,Oe,"f").unknownArguments(r,t,{},!1,!1),ke(this,Oe,"f").limitedChoices(r),ke(this,Oe,"f").implications(r),ke(this,Oe,"f").conflicting(r)}}[rn](){Ee(this,te,!0,"f")}[on](t){if("string"==typeof t)ke(this,re,"f").key[t]=!0;else for(const e of t)ke(this,re,"f").key[e]=!0}}const cn=(ln=ht,(t=[],e=ln.process.cwd(),n)=>{const s=new an(t,e,n,ln);return Object.defineProperty(s,"argv",{get:()=>s.parse(),enumerable:!0}),s.help(),s.version(),s});var ln;function hn(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 dn(t,e,n){"symbol"==typeof e&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:n?n+" "+e:e})}catch(t){}return t}function un(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var s=n.call(t,e||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}let fn;const pn=function({cacheDuration:t=Number.POSITIVE_INFINITY,caches:e,calcKey:n=(t=>function(t,e=0){const[n,s]=function(t,e=0){let n=3735928559^e,s=1103547991^e;for(let e,i=0;i<t.length;i++)e=t.codePointAt(i),n=Math.imul(n^e,2654435761),s=Math.imul(s^e,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507),s^=Math.imul(n^n>>>13,3266489909),[s>>>0,n>>>0]}(t,e);return t.length.toString(36)+n.toString(36).padStart(7,"0")+s.toString(36).padStart(7,"0")}(JSON.stringify(t))),maxCachedArgsSize:s=100,maxCachedThisSize:i=10}={}){return function(r,o){if("getter"===o?.kind){const n=new Map;return e?.push(n),function(){const e=Date.now();if(n.has(this)){const[s,i]=n.get(this);if(e-i<=t)return s}const s=r.call(this);if(n.size>=i){const t=n.keys().next().value;n.delete(t)}return n.set(this,[s,e]),s}}{const a=new Map;return e?.push(a),function(...e){const c=n(e);let l=a.get(this);const h=Date.now();if(l){if(l.has(c)){const[e,n]=l.get(c);if(h-n<=t)return e}}else{if(l=new Map,a.size>=i){const t=a.keys().next().value;a.delete(t)}a.set(this,l)}const d=o?r.call(this,...e):r(...e);if(l.size>=s){const t=l.keys().next().value;l.delete(t)}return l.set(c,[d,h]),d}}}}({maxCachedThisSize:Number.MAX_SAFE_INTEGER,maxCachedArgsSize:1});class gn{static{[fn]=function(t,e,n,s,i,r){var o,a,c,l,h,d,u,f=Symbol.metadata||Symbol.for("Symbol.metadata"),p=Object.defineProperty,g=Object.create,m=[g(null),g(null)],y=e.length;function b(e,n,s){return function(i,r){n&&(r=i,i=t);for(var o=0;o<e.length;o++)r=e[o].apply(i,s?[r]:[]);return s?r:i}}function v(t,e,n,s){if("function"!=typeof t&&(s||void 0!==t))throw new TypeError(e+" must "+(n||"be")+" a function"+(s?"":" or undefined"));return t}function w(t,e,n,s,i,r,c,l,h,d,u){function f(t){if(!u(t))throw new TypeError("Attempted to access private element on non-instance")}var g=[].concat(e[0]),y=e[3],w=!c,O=1===i,E=3===i,k=4===i,A=2===i;function j(e,n,s){return function(i,r){return n&&(r=i,i=t),s&&s(i),$[e].call(i,r)}}if(!w){var $={},_=[],x=E?"get":k||O?"set":"value";if(h?(d||O?$={get:dn((function(){return y(this)}),s,"get"),set:function(t){e[4](this,t)}}:$[x]=y,d||dn($[x],s,A?"":x)):d||($=Object.getOwnPropertyDescriptor(t,s)),!d&&!h){if((a=m[+l][s])&&7!=(a^i))throw Error("Decorating two elements with the same name ("+$[x].name+") is not supported yet");m[+l][s]=i<3?1:i}}for(var C=t,S=g.length-1;S>=0;S-=n?2:1){var P=v(g[S],"A decorator","be",!0),N=n?g[S-1]:void 0,M={},D={kind:["field","accessor","method","getter","setter","class"][i],name:s,metadata:o,addInitializer:function(t,e){if(t.v)throw Error("attempted to call addInitializer after decoration was finished");v(e,"An initializer","be",!0),r.push(e)}.bind(null,M)};if(w)a=P.call(N,C,D),M.v=1,v(a,"class decorators","return")&&(C=a);else if(D.static=l,D.private=h,a=D.access={has:h?u.bind():function(t){return s in t}},k||(a.get=h?A?function(t){return f(t),$.value}:j("get",0,f):function(t){return t[s]}),A||E||(a.set=h?j("set",0,f):function(t,e){t[s]=e}),C=P.call(N,O?{get:$.get,set:$.set}:$[x],D),M.v=1,O){if("object"==typeof C&&C)(a=v(C.get,"accessor.get"))&&($.get=a),(a=v(C.set,"accessor.set"))&&($.set=a),(a=v(C.init,"accessor.init"))&&_.unshift(a);else if(void 0!==C)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else v(C,(d?"field":"method")+" decorators","return")&&(d?_.unshift(C):$[x]=C)}return i<2&&c.push(b(_,l,1),b(r,l,0)),d||w||(h?O?c.splice(-1,0,j("get",l),j("set",l)):c.push(A?$[x]:v.call.bind($[x])):p(t,s,$)),C}function O(t){return p(t,f,{configurable:!0,enumerable:!0,value:o})}return o=g(null==o?null:o),h=[],d=function(t){t&&h.push(b(t))},u=function(e,s){for(var r=0;r<n.length;r++){var o=n[r],a=o[1],d=7&a;if((8&a)==e&&!d==s){var u=o[2],f=!!o[3],p=16&a;w(e?t:t.prototype,o,p,f?"#"+u:un(u),d,d<2?[]:e?l=l||[]:c=c||[],h,!!e,f,s,e&&f?function(e){return hn(e)===t}:i)}}},u(8,0),u(0,0),u(8,1),u(0,1),d(c),d(l),a=h,y||O(t),{e:a,get c(){var n=[];return y&&[O(t=w(t,[e],s,t.name,5,n)),b(n,1)]}}}(this,[],[[pn,3,"isBunProject"],[pn,3,"isBunAvailable"],[pn,3,"buildCommand"],[pn,3,"rootDirPath"],[pn,3,"dockerfile"],[pn,3,"hasDockerfile"],[pn,3,"hasSourceCode"],[pn,3,"name"],[pn,3,"dockerImageName"],[pn,3,"env"],[pn,3,"packageJson"],[pn,3,"hasPrisma"],[pn,3,"dockerPackageJson"],[pn,3,"binExists"]]).e}argv=void fn(this);pathByName=new Map;constructor(e,n,s){this._dirPath=t.resolve(e),this.argv=n,this.loadEnv=s}get isBunProject(){return l.existsSync(t.join(this.rootDirPath,"bunfig.toml"))}get isBunAvailable(){try{return/(^|\n)bun\s/.test(l.readFileSync(t.join(this.rootDirPath,".tool-versions"),"utf8"))}catch{return!1}}get buildCommand(){return this.packageJson.scripts?.build?.includes("buildIfNeeded")?"yarn build":"YARN wb buildIfNeeded "+(this.argv.verbose?"--verbose":"")}get dirPath(){return this._dirPath}get rootDirPath(){return l.existsSync(t.join(this.dirPath,"..","..","package.json"))?t.resolve(this.dirPath,"..",".."):this.dirPath}get dockerfile(){return l.readFileSync(this.findFile("Dockerfile"),"utf8")}get hasDockerfile(){try{return!!this.findFile("Dockerfile")}catch{return!1}}get hasSourceCode(){return l.existsSync(t.join(this.dirPath,"src"))}get name(){return this.packageJson.name||"unknown"}get dockerImageName(){return(this.packageJson.name||"unknown").replaceAll("@","").replaceAll("/","-")}get env(){return this.loadEnv?{...C(this.argv,this.dirPath),...process.env}:process.env}get packageJson(){return JSON.parse(l.readFileSync(t.join(this.dirPath,"package.json"),"utf8"))}get hasPrisma(){return!(!this.packageJson.dependencies?.prisma&&!this.packageJson.devDependencies?.prisma)}get dockerPackageJson(){return t.dirname(this.findFile("Dockerfile"))===this.dirPath?this.packageJson:JSON.parse(l.readFileSync(t.join(t.dirname(this.findFile("Dockerfile")),"package.json"),"utf8"))}get binExists(){let e=!1,n=this.dirPath;for(;;){const s=t.join(n,"node_modules",".bin");if(l.existsSync(s)&&(this.env.PATH=`${s}:${this.env.PATH}`,e=!0),l.existsSync(t.join(n,".git")))break;const i=t.dirname(n);if(n===i)break;n=i}return e}findFile(e){let n=this.pathByName.get(e);if(n)return n;if(n=[e,t.join("..","..",e)].map((e=>t.resolve(this.dirPath,e))).find((t=>l.existsSync(t))),!n)throw new Error(`File not found: ${e}`);return this.pathByName.set(e,n),n}}function mn(e,n=!0,s){if(s??=process.cwd(),l.existsSync(t.join(s,"package.json")))return new gn(s,e,n)}async function yn(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 gn(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 gn(i,e,n))}return{root:r,self:i}}(e,n,s);if(i)return{...i,all:i.root===i.self?await bn(e,i.root,n):[i.self]}}async function bn(e,n,s){const i=[n],r=n.packageJson.workspaces;if(!Array.isArray(r))return i;const o=[],a=[];for(const e of r.map((e=>t.join(n.dirPath,e))))l.existsSync(e)?a.push(e):o.push(e);a.push(...await E(o,{dot:!0,onlyDirectories:!0}));for(const n of a)l.existsSync(t.join(n,"package.json"))&&i.push(new gn(n,e,s));return i}const vn={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 mn(e,!0,n);if(!s)return console.error(O.red("No project found.")),!0;if(!l.existsSync(t.join(s.rootDirPath,".git")))return wn(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])=>!On.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=>(En.some((e=>t.includes(e)))||kn.some((e=>t.endsWith(e))))&&!An.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(!wn(s,e))return;e.dryRun||await l.promises.writeFile(r,o,"utf8");return!0}(e)}};function wn(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 On=new Set(["CI","PWDEBUG","TMPDIR"]);const En=["src/","public/"],kn=[".js",".cjs",".mjs",".jsx",".ts",".cts",".mts",".tsx",".json",".browserslistrc","package.json","yarn.lock"],An=["test/","tests/","__tests__/","test-fixtures/"];function*jn(t,e){for(const n of e)console.info(`Running "${t}" for ${n.name} ...`),yield n}const $n={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 yn(e);n||(console.error(O.red("No project found.")),process.exit(1));for(const s of jn("optimizeForDockerBuild",n.all)){const n=s.packageJson,i=["dependencies","devDependencies"];for(const t of i){const e=n[t]||{};for(const[t,n]of Object.entries(e))n?.startsWith("git@github.com:")&&(e[t]=`./${t}`)}if(_n(e,n),xn(n),Cn(n),e.dryRun)continue;const r=e.outside?t.join(s.dirPath,"dist"):s.dirPath;await l.promises.mkdir(r,{recursive:!0}),await l.promises.writeFile(t.join(r,"package.json"),JSON.stringify(n),"utf8")}e.dryRun||e.outside||y.spawnSync("yarn",{stdio:"inherit"})}};function _n(t,e){if(!t.outside)return void delete e.devDependencies;const n=e.devDependencies||{},s=["artillery","concurrently","conventional-changelog-conventionalcommits","eslint","husky","imagemin","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 xn(t){const e=["check","deploy","format","lint","start","test"],n=["pinst ","husky "],s=t.scripts||{};for(const[t,i]of Object.entries(s))(e.some((e=>t.includes(e)))||n.some((t=>i.includes(t)||i.trim()===t.trim())))&&delete s[t]}function Cn(t){delete t.private,delete t.publishConfig,delete t.prettier}const Sn=process.argv[0].endsWith("/bun"),Pn=Sn?"bun --bun":"node",Nn=Sn?"bun --bun":"yarn";const Mn=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`${Pn} -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`}},Dn=new Set;async function In(t){try{await A(t)}catch{}}const Rn=new j,Wn={exitIfFailed:!0};async function zn(t,e,n,s=Wn){const[i,r]=Fn(t,e);if(Bn(i,e),n.verbose&&Bn(r,e,"Start (raw)",!0),n.dryRun)return Ln(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 In(t);const e=async()=>{Dn.has(t)||(Dn.add(t),await In(t))};for(const t of["beforeExit","SIGINT","SIGTERM","SIGQUIT"])process.on(t,e)}(Number(o));const a=await M(r,void 0,{cwd:e.dirPath,env:e.env,shell:!0,stdio:"inherit",timeout:s?.timeout,killOnExit:!0,verbose:n.verbose});return Ln(i,a.status,s),a.status??1}function Tn(t,e,n,s=Wn){return Rn.run((async()=>{const[i,r]=Fn(t,e);if(Bn(i,e,"Start (parallel)",!0),n.dryRun)return Bn(i,e,"Started (log)"),n.verbose&&Bn(r,e,"Started (raw)",!0),void Ln(i,0,s);const o=await M(r,void 0,{cwd:e.dirPath,env:e.env,shell:!0,stdio:"pipe",timeout:s?.timeout,mergeOutAndError:!0,killOnExit:!0,verbose:n.verbose});Bn(i,e,"Started (log)"),n.verbose&&Bn(r,e,"Started (raw)",!0);const a=o.stdout.trim();a&&console.info(a),Ln(i,o.status,s)}))}function Fn(t,e){const n=t.replaceAll("\n","").replaceAll(/\s\s+/g," ").replaceAll("PRISMA ",e.packageJson.dependencies?.blitz?"YARN blitz prisma ":"YARN prisma ").replaceAll("BUN ",e.isBunAvailable?"bun --bun ":"YARN ").trim();return[n.replaceAll("YARN ",`${Nn} `),n.replaceAll("YARN ",!Sn&&e.binExists?"":`${Nn} `)]}function Bn(t,e,n="Start",s=!1){console.info("\n"+(s?O.gray:O.cyan)(O.bold(`${n}:`),t)+O.gray(` at ${e.dirPath}`))}function Ln(t,e,n){0===e?console.info(O.green(O.bold("Finished:"),t)):(console.info(O.red(O.bold(`Failed (exit code ${e}): `),t)),!1!==n.exitIfFailed&&process.exit(e??1))}const Vn={},Un={command:"prisma",describe:"Run prisma commands",builder:t=>t.command(Hn).command(qn).command(Jn).command(Gn).command(Kn).command(Qn).command(Xn).command(Zn).command(ts).command(es).demandCommand(),handler(){}},Hn={command:"deploy",describe:"Apply migration to DB without initializing it",builder:Vn,async handler(t){const e=await ns(t);for(const n of jn("prisma deploy",e))await zn(Mn.deploy(n),n,t)}},Yn={...Vn,"backup-path":{description:"Whether to skip actual command execution",demandOption:!0,type:"string",alias:"b"}},qn={command:"deploy-force <backup-path>",describe:"Force to apply migration to DB utilizing Litestream's backup without initializing it",builder:Yn,async handler(t){const e=await ns(t);for(const n of jn("prisma deploy-force",e))await zn(Mn.deployForce(n,t.backupPath),n,t)}},Jn={command:"litestream",describe:"Setup DB for Litestream",builder:Vn,async handler(t){const e=await ns(t);for(const n of jn("prisma litestream",e))await zn(Mn.litestream(n),n,t)}},Gn={command:"migrate",describe:"Apply migration to DB with initializing it",builder:Vn,async handler(t){const e=await ns(t);for(const n of jn("prisma migrate",e))await zn(Mn.migrate(n),n,t)}},Kn={command:"migrate-dev",describe:"Create a migration file",builder:Vn,async handler(t){const e=await ns(t);for(const n of jn("prisma migrate-dev",e))await zn(Mn.migrateDev(n),n,t)}},Qn={command:"reset",describe:"Reset DB",builder:Vn,async handler(t){const e=await ns(t);for(const n of jn("prisma reset",e))await zn(Mn.reset(n),n,t)}},Xn={command:"restore <backup-path>",describe:"Restore DB from Litestream's backup",builder:{...Yn,output:{description:'Output path of the restored database. Defaults to "<db|prisma>/restored.sqlite3".',type:"string"}},async handler(t){const e=await ns(t);for(const n of jn("prisma restore",e)){const e=t.output||(n.packageJson.dependencies?.blitz?"db/restored.sqlite3":"prisma/restored.sqlite3");await zn(Mn.restore(n,t.backupPath,e),n,t)}}},Zn={command:"seed",describe:"Populate DB with seed data",builder:{...Vn,file:{alias:"f",description:"Path of the seed script.",type:"string"}},async handler(t){const e=await ns(t);for(const n of jn("prisma seed",e))await zn(Mn.seed(n,t.file),n,t)}},ts={command:"studio [db-url-or-path]",describe:"Open Prisma Studio",builder:{...Vn,"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 ns(t);for(const n of jn("prisma studio",e)){const e=t.restored?n.packageJson.dependencies?.blitz?"db/restored.sqlite3":"prisma/restored.sqlite3":t.dbUrlOrPath?.toString();await zn(Mn.studio(n,e),n,t)}}},es={command:"$0 [args..]",describe:"Pass the command and arguments to prisma as is",builder:{args:{type:"array"}},async handler(t){const e=await ns(t),n=`${t.args?.join(" ")??""}`.trimEnd();for(const s of jn(`prisma ${n}`,e))await zn(`PRISMA ${n}`,s,t)}};async function ns(t){const e=await yn(t);e||(console.error(O.red("No project found.")),process.exit(1));const n=e.all.filter((t=>t.packageJson.dependencies?.prisma||t.packageJson.devDependencies?.prisma));return 0===n.length&&(console.error(O.red("No prisma project found.")),process.exit(1)),n}const ss={command:"retry [command] [args...]",describe:"Retry the given command until it succeeds",builder:{retry:{description:"A maximum retry count",type:"number",alias:"r",default:3}},async handler(t){const e=mn(t);e||(console.error(O.red("No project found.")),process.exit(1));const n=[t.command,...t.args??[],...t._.slice(1)].filter(Boolean);let s=0;for(let i=0;i<t.retry;i++)if(i>0&&console.info(`\n${O.yellow(`#${i} Retrying: ${n.join(" ")}`)}`),s=await zn(n.join(" "),e,t,{exitIfFailed:!1}),0===s)return;process.exit(s)}},is={command:"setup",describe:"Setup development environment. .env files are ignored.",builder:{},async handler(t){await async function(t,e){const n=await yn(t,!1,e);n||(console.error(O.red("No project found.")),process.exit(1));for(const e of jn("setup",n.all)){const s=await _.readdir(e.dirPath,{withFileTypes:!0});if(e===n.root){if("darwin"===x.platform()){const n=["pstree"];e.hasDockerfile&&n.push("expect"),await Tn(`brew install ${n.join(" ")}`,e,t)}s.some((t=>t.isFile()&&t.name.includes("-version")))&&await zn("asdf install",e,t)}if(s.some((t=>t.isFile()&&"pyproject.toml"===t.name))){await Tn("poetry config virtualenvs.in-project true",e,t),await Tn("poetry config virtualenvs.prefer-active-python true",e,t);const[,n]=y.execSync("asdf current python").toString().trim().split(/\s+/);await Tn(`poetry env use ${n}`,e,t),await Rn.promiseAll(),await zn("poetry run pip install --upgrade pip",e,t),await zn("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 zn(`yarn add ${a.join(" ")}`,e,t),c.length>0&&await zn(`yarn add -D ${c.join(" ")}`,e,t),o["gen-code"]&&await zn("yarn gen-code",e,t)}}(t)}};const rs=new class{buildDevImage(e,n){const s=e.dockerPackageJson.scripts?.["docker/build/prepare"]?"yarn run docker/build/prepare && ":"";return`cd ${t.dirname(e.findFile("Dockerfile"))}\n && ${s}YARN wb optimizeForDockerBuild --outside\n && YARN wb retry -- docker build -t ${e.dockerImageName}\n --build-arg ARCH=$([ $(uname -m) = 'arm64' ] && echo arm64 || echo amd64)\n --build-arg WB_ENV=${e.env.WB_ENV}\n --build-arg WB_VERSION=${n} .`}stopAndStart(t,e=!1,n="",s=""){return`${this.stop(t)} && ${e?"unbuffer ":""}${this.start(t,n,s)}`}start(t,e="",n=""){return function(t,e){const n=async()=>{if(Dn.has(t))return;Dn.add(t),Bn(t,e);const{status:n}=v(t,{cwd:e.dirPath,shell:!0,stdio:"inherit"});Ln(t,n,{})};for(const t of["beforeExit","SIGINT","SIGTERM","SIGQUIT"])process.on(t,n)}(this.stop(t),t),`docker run --rm -it -p 8080:8080 --name ${t.dockerImageName} ${e} ${t.dockerImageName} ${n}`}stop(t){return`true $(docker rm -f $(docker container ls -q -f name=${t.dockerImageName}) 2> /dev/null)`}stopAll(){return"true $(docker rm -f $(docker ps -q) 2> /dev/null)"}};class os{constructor(t=Number(process.env.PORT)||3e3){this.defaultPort=t}buildDocker(t,e="development"){return rs.buildDevImage(t,e)}startDocker(t,e){return`${this.buildDocker(t)}\n && YARN concurrently --raw --kill-others-on-fail\n "${rs.stopAndStart(t,!1,e.normalizedDockerOptionsText??"",e.normalizedArgsText??"")}"\n "${this.waitAndOpenApp(t,e,8080)}"`}testE2E(t,e,{playwrightArgs:n="test tests/e2e",prismaDirectory:s,startCommand:i}){const r=t.env.WB_ENV;return`WB_ENV=${r} NEXT_PUBLIC_WB_ENV=${r} APP_ENV=${r} PORT=8080 YARN concurrently --kill-others --raw --success first\n "rm -Rf ${s}/mount && ${i} && exit 1"\n "concurrently --kill-others-on-fail --raw 'wait-on -t 600000 -i 2000 http://127.0.0.1:8080' 'yarn playwright install --with-deps'\n && yarn playwright ${n.replace("tests/e2e",e.target||"tests/e2e")}"`}testE2EDev(t,e,{playwrightArgs:n="test tests/e2e",startCommand:s}){const i=t.env.WB_ENV;return`WB_ENV=${i} NEXT_PUBLIC_WB_ENV=${i} APP_ENV=${i} PORT=8080 YARN concurrently --kill-others --raw --success first\n "${s} && exit 1"\n "concurrently --kill-others-on-fail --raw 'wait-on -t 600000 -i 2000 http://127.0.0.1:8080' 'yarn playwright install --with-deps'\n && yarn playwright ${n.replace("tests/e2e",e.target||"tests/e2e")}"`}testUnit(t,e){return`WB_ENV=${t.env.WB_ENV} YARN vitest run ${e.target||"tests/unit"} --color --passWithNoTests --allowOnly`}waitApp(t,e,n=this.defaultPort){return`wait-on -t 10000 http://127.0.0.1:${n} 2> /dev/null\n || wait-on -t 10000 -i 500 http://127.0.0.1:${n} 2> /dev/null\n || wait-on -t 10000 -i 1000 http://127.0.0.1:${n} 2> /dev/null\n || wait-on -t 10000 -i 2000 http://127.0.0.1:${n} 2> /dev/null\n || wait-on -t 20000 -i 4000 http://127.0.0.1:${n} 2> /dev/null\n || wait-on -t 60000 -i 5000 http://127.0.0.1:${n}`}waitAndOpenApp(t,e,n=this.defaultPort){return`${this.waitApp(t,e,n)} || wait-on http://127.0.0.1:${n} && open-cli "http://\${HOST:-localhost}:${n}"`}}const as=new class extends os{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 "${Mn.reset(t)} && ${t.buildCommand} && PORT=${n} pm2-runtime start ${t.findFile("ecosystem.config.cjs")} ${e.normalizedArgsText??""}"\n "${this.waitAndOpenApp(t,e,n)}"`}testE2E(t,e,{playwrightArgs:n,startCommand:s=`${Mn.reset(t)} && ${t.buildCommand} && pm2-runtime start ${t.findFile("ecosystem.config.cjs")}`}){return super.testE2E(t,e,{playwrightArgs:n,prismaDirectory:"db",startCommand:s})}testE2EDev(t,e,{playwrightArgs:n,startCommand:s="blitz dev -p 8080"}){return super.testE2EDev(t,e,{playwrightArgs:n,startCommand:s})}testStart(t,e){return`YARN concurrently --kill-others --raw --success first "blitz dev" "${this.waitApp(t,e)}"`}};const cs=new class extends os{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)} && ${rs.stopAndStart(t,!1,e.normalizedDockerOptionsText??"",e.normalizedArgsText??"")}`}startProduction(t,e,n=8080){return`NODE_ENV=production ${t.buildCommand} && NODE_ENV=production PORT=\${PORT:-${n}} ${Pn} 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 ${e.target||"tests/e2e"} --color --passWithNoTests --allowOnly"`}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 ${e.target||"tests/e2e"} --color --passWithNoTests --allowOnly"`}testStart(t,e){return`YARN concurrently --kill-others --raw --success first "${this.start(t,e)}" "${this.waitApp(t,e)}"`}};const ls=new class extends os{constructor(){super()}start(t,e){return`YARN concurrently --raw --kill-others-on-fail\n "next dev --turbo ${e.normalizedArgsText??""}"\n "${this.waitAndOpenApp(t,e)}"`}startProduction(t,e,n){return`NODE_ENV=production YARN concurrently --raw --kill-others-on-fail\n "${[...t.hasPrisma?[Mn.reset(t)]:[],t.buildCommand,`PORT=${n} pm2-runtime start ${t.findFile("ecosystem.config.cjs")} ${e.normalizedArgsText??""}`].join(" && ")}"\n "${this.waitAndOpenApp(t,e,n)}"`}testE2E(t,e,n){return super.testE2E(t,e,{playwrightArgs:n.playwrightArgs,prismaDirectory:"db",startCommand:n.startCommand??[...t.hasPrisma?[Mn.reset(t)]:[],t.buildCommand,`pm2-runtime start ${t.findFile("ecosystem.config.cjs")}`].join(" && ")})}testE2EDev(t,e,{startCommand:n="next dev --turbo -p 8080"}){return super.testE2EDev(t,e,{startCommand:n})}testStart(t,e){return`YARN concurrently --kill-others --raw --success first "next dev --turbo" "${this.waitApp(t,e)}"`}};const hs=new class extends os{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)} && ${rs.stopAndStart(t,!1,e.normalizedDockerOptionsText??"",e.normalizedArgsText??"")}`}startProduction(t,e){return`NODE_ENV=production ${t.buildCommand} && NODE_ENV=production ${Pn} dist/index.js ${e.normalizedArgsText??""}`}testE2E(){return"echo 'do nothing.'"}testE2EDev(){return"echo 'do nothing.'"}testStart(){return"echo 'do nothing.'"}};const ds=new class extends os{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 "${Mn.reset(t)} && ${t.buildCommand} && PORT=${n} pm2-runtime start ${t.findFile("ecosystem.config.cjs")} ${e.normalizedArgsText??""}"\n "${this.waitAndOpenApp(t,e,n)}"`}testE2E(t,e,{playwrightArgs:n,startCommand:s=`${Mn.reset(t)} && ${t.buildCommand} && pm2-runtime start ${t.findFile("ecosystem.config.cjs")}`}){return super.testE2E(t,e,{playwrightArgs:n,prismaDirectory:"prisma",startCommand:s})}testE2EDev(t,e,{playwrightArgs:n,startCommand:s="remix dev"}){return super.testE2EDev(t,e,{playwrightArgs:n,startCommand:s})}testStart(t,e){return`YARN concurrently --kill-others --raw --success first "remix dev" "${this.waitApp(t,e)}"`}},us={command:"start [args..]",describe:"Start app",builder:{watch:{description:"Whether to watch files",type:"boolean"},args:{description:"Arguments for core command",type:"array",alias:"a",default:[]},"docker-options":{description:'Arguments for "docker run"',type:"array",default:[]},mode:{description:"Start mode: dev[elopment] (default) | staging | docker | docker-debug",type:"string",alias:"m"}},async handler(t){!function(t){t.normalizedArgsText=[...t.args??[],...t._?.slice(1)??[]].map((t=>`'${t}'`)).join(" "),t.normalizedDockerOptionsText=(t.dockerOptions??[]).map((t=>`'${t}'`)).join(" ")}(t);const e=await yn(t);e||(console.error(O.red("No project found.")),process.exit(1));for(const n of e.all){const e=n.packageJson.dependencies||{},s=n.packageJson.devDependencies||{};let i;if(e.blitz)i=as;else if(e.next)i=ls;else if(s["@remix-run/dev"])i=ds;else if((e.express||e.fastify)&&!e["firebase-functions"]||n.hasDockerfile&&/EXPOSE\s+8080/.test(n.dockerfile))i=cs;else{if(!e["build-ts"]&&!s["build-ts"])continue;i=hs}switch(console.info(`Running "start" for ${n.name} ...`),t.mode||"dev"){case"dev":case"development":{const s=fs(e,"development");await zn(`${s}${i.start(n,t)}`,n,t);break}case"staging":{const s=fs(e,"staging");await zn(`${s}${i.startProduction(n,t,8080)}`,n,t);break}case"docker":{const s=fs(e,"staging");await zn(`${s}${i.startDocker(n,t)}`,n,t);break}case"docker-debug":{const s=fs(e,"staging");t.normalizedArgsText="'/bin/bash'",await zn(`${s}${i.startDocker(n,t)}`,n,t);break}default:throw new Error(`Unknown start mode: ${t.mode}`)}}}};function fs(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 ps={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"},target:{description:"Test target",type:"string",alias:"t"}},async handler(e){await async function(e){const n=await yn(e);n||(console.error(O.red("No project found.")),process.exit(1));n.all.length>1&&(process.env.CI="1");process.env.FORCE_COLOR||="3",process.env.WB_ENV||="test";for(const s of n.all){const n=s.packageJson.dependencies||{},i=s.packageJson.devDependencies||{};let r;r=n.blitz?as:n.next?ls:i["@remix-run/dev"]?ds:!n.express&&!n.fastify||n["firebase-functions"]?hs:cs,console.info(`Running "test" for ${s.name} ...`);const o=[];if(!e.ci){switch((e.unit||!e.start&&void 0===e.e2e)&&o.push(zn(r.testUnit(s,e),s,e,{timeout:e.unitTimeout})),e.start&&o.push(zn(r.testStart(s,e),s,e)),await Promise.all(o),e.e2e){case void 0:case"none":continue;case"":case"headless":await zn(r.testE2E(s,e,{}),s,e);continue;case"headless-dev":await zn(r.testE2EDev(s,e,{}),s,e);continue;case"docker":await gs(s,e,r);continue;case"docker-debug":await gs(s,e,r,`test ${e.target||"tests/e2e"} --debug`);continue}if(n.blitz||n.next||i["@remix-run/dev"])switch(e.e2e){case"headed":await zn(r.testE2E(s,e,{playwrightArgs:`test ${e.target||"tests/e2e"} --headed`}),s,e);continue;case"headed-dev":await zn(r.testE2EDev(s,e,{playwrightArgs:`test ${e.target||"tests/e2e"} --headed`}),s,e);continue;case"debug":await zn(r.testE2E(s,e,{playwrightArgs:`test ${e.target||"tests/e2e"} --debug`}),s,e);continue;case"generate":await zn(r.testE2E(s,e,{playwrightArgs:"codegen http://localhost:8080"}),s,e);continue;case"trace":await zn("playwright show-trace",s,e);continue}throw new Error(`Unknown e2e mode: ${e.e2e}`)}{const n=N(t.join(s.dirPath,"tests","unit")),i=N(t.join(s.dirPath,"tests","e2e"));if(await Tn(rs.stopAll(),s,e),!1!==e.unit&&await n&&await Tn(r.testUnit(s,e).replaceAll(" --allowOnly",""),s,e,{timeout:e.unitTimeout}),!1!==e.start&&await Tn(r.testStart(s,e),s,e),await Rn.promiseAll(),"none"!==e.e2e&&await i){s.hasDockerfile&&await zn(`${r.buildDocker(s,"test")}`,s,e);const t=s.hasDockerfile?{startCommand:rs.stopAndStart(s,!0)}:{};process.exitCode=await zn(r.testE2E(s,e,t).replaceAll(" --allowOnly",""),s,e,{exitIfFailed:!1}),await zn(rs.stop(s),s,e)}}}}(e)}};async function gs(t,e,n,s){await zn(`${n.buildDocker(t,"test")}`,t,e),process.exitCode=await zn(`${n.testE2E(t,e,{playwrightArgs:s,startCommand:rs.stopAndStart(t,!0)})}`,t,e,{exitIfFailed:!1}),await zn(rs.stop(t),t,e)}const ms={command:"typecheck",describe:"Run type checking. .env files are ignored.",builder:{},async handler(t){const e=await yn(t,!1);e||(console.error(O.red("No project found.")),process.exit(1));for(const n of e.all){const s=[];if(n.packageJson.workspaces?n.hasSourceCode&&(n.packageJson.dependencies?.typescript||n.packageJson.devDependencies?.typescript)&&s.push("BUN tsc --noEmit --Pretty"):((n.packageJson.dependencies?.typescript||n.packageJson.devDependencies?.typescript)&&s.push("BUN tsc --noEmit --Pretty"),n.packageJson.devDependencies?.pyright&&s.push("YARN 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 zn(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.'))}}}},ys={...ms,command:"tc"},bs={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 vs;await cn((vs=process.argv,vs.slice(nt()+1))).scriptName("wb").options(bs).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(vn).command($n).command(Un).command(ss).command(is).command(us).command(ps).command(ms).command(ys).demandCommand().strict().help().argv;for(const t of["SIGINT","SIGTERM","SIGQUIT"])process.on(t,(()=>process.exit()));
34
34
  //# sourceMappingURL=index.js.map