UNPKG

@themoin/diff-calculator-cli

Version:

CLI for aggregating diff between two revisions, which can ignore deletions, whitespaces and comments

58 lines (53 loc) 93.1 kB
#!/usr/bin/env node "use strict";var Ii=Object.create;var yn=Object.defineProperty;var Mi=Object.getOwnPropertyDescriptor;var $i=Object.getOwnPropertyNames;var Fi=Object.getPrototypeOf,Li=Object.prototype.hasOwnProperty;var Wi=(s,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of $i(t))!Li.call(s,i)&&i!==e&&yn(s,i,{get:()=>t[i],enumerable:!(n=Mi(t,i))||n.enumerable});return s};var _n=(s,t,e)=>(e=s!=null?Ii(Fi(s)):{},Wi(t||!s||!s.__esModule?yn(e,"default",{value:s,enumerable:!0}):e,s));var _e=require("assert");var Di={right:Hi,center:Ui},vi=0,de=1,Ni=2,pe=3,ze=class{constructor(t){var e;this.width=t.width,this.wrap=(e=t.wrap)!==null&&e!==void 0?e:!0,this.rows=[]}span(...t){let e=this.div(...t);e.span=!0}resetOutput(){this.rows=[]}div(...t){if(t.length===0&&this.div(""),this.wrap&&this.shouldApplyLayoutDSL(...t)&&typeof t[0]=="string")return this.applyLayoutDSL(t[0]);let e=t.map(n=>typeof n=="string"?this.colFromString(n):n);return this.rows.push(e),e}shouldApplyLayoutDSL(...t){return t.length===1&&typeof t[0]=="string"&&/[\t\n]/.test(t[0])}applyLayoutDSL(t){let e=t.split(` `).map(i=>i.split(" ")),n=0;return e.forEach(i=>{i.length>1&&lt.stringWidth(i[0])>n&&(n=Math.min(Math.floor(this.width*.5),lt.stringWidth(i[0])))}),e.forEach(i=>{this.div(...i.map((r,a)=>({text:r.trim(),padding:this.measurePadding(r),width:a===0&&i.length>1?n:void 0})))}),this.rows[this.rows.length-1]}colFromString(t){return{text:t,padding:this.measurePadding(t)}}measurePadding(t){let e=lt.stripAnsi(t);return[0,e.match(/\s*$/)[0].length,0,e.match(/^\s*/)[0].length]}toString(){let t=[];return this.rows.forEach(e=>{this.rowToString(e,t)}),t.filter(e=>!e.hidden).map(e=>e.text).join(` `)}rowToString(t,e){return this.rasterize(t).forEach((n,i)=>{let r="";n.forEach((a,f)=>{let{width:m}=t[f],b=this.negatePadding(t[f]),d=a;if(b>lt.stringWidth(a)&&(d+=" ".repeat(b-lt.stringWidth(a))),t[f].align&&t[f].align!=="left"&&this.wrap){let g=Di[t[f].align];d=g(d,b),lt.stringWidth(d)<b&&(d+=" ".repeat((m||0)-lt.stringWidth(d)-1))}let u=t[f].padding||[0,0,0,0];u[pe]&&(r+=" ".repeat(u[pe])),r+=On(t[f],d,"| "),r+=d,r+=On(t[f],d," |"),u[de]&&(r+=" ".repeat(u[de])),i===0&&e.length>0&&(r=this.renderInline(r,e[e.length-1]))}),e.push({text:r.replace(/ +$/,""),span:t.span})}),e}renderInline(t,e){let n=t.match(/^ */),i=n?n[0].length:0,r=e.text,a=lt.stringWidth(r.trimRight());return e.span?this.wrap?i<a?t:(e.hidden=!0,r.trimRight()+" ".repeat(i-a)+t.trimLeft()):(e.hidden=!0,r+t):t}rasterize(t){let e=[],n=this.columnWidths(t),i;return t.forEach((r,a)=>{r.width=n[a],this.wrap?i=lt.wrap(r.text,this.negatePadding(r),{hard:!0}).split(` `):i=r.text.split(` `),r.border&&(i.unshift("."+"-".repeat(this.negatePadding(r)+2)+"."),i.push("'"+"-".repeat(this.negatePadding(r)+2)+"'")),r.padding&&(i.unshift(...new Array(r.padding[vi]||0).fill("")),i.push(...new Array(r.padding[Ni]||0).fill(""))),i.forEach((f,m)=>{e[m]||e.push([]);let b=e[m];for(let d=0;d<a;d++)b[d]===void 0&&b.push("");b.push(f)})}),e}negatePadding(t){let e=t.width||0;return t.padding&&(e-=(t.padding[pe]||0)+(t.padding[de]||0)),t.border&&(e-=4),e}columnWidths(t){if(!this.wrap)return t.map(a=>a.width||lt.stringWidth(a.text));let e=t.length,n=this.width,i=t.map(a=>{if(a.width)return e--,n-=a.width,a.width}),r=e?Math.floor(n/e):0;return i.map((a,f)=>a===void 0?Math.max(r,zi(t[f])):a)}};function On(s,t,e){return s.border?/[.']-+[.']/.test(t)?"":t.trim().length!==0?e:" ":""}function zi(s){let t=s.padding||[],e=1+(t[pe]||0)+(t[de]||0);return s.border?e+4:e}function Ri(){return typeof process=="object"&&process.stdout&&process.stdout.columns?process.stdout.columns:80}function Hi(s,t){s=s.trim();let e=lt.stringWidth(s);return e<t?" ".repeat(t-e)+s:s}function Ui(s,t){s=s.trim();let e=lt.stringWidth(s);return e>=t?s:" ".repeat(t-e>>1)+s}var lt;function Cn(s,t){return lt=t,new ze({width:s?.width||Ri(),wrap:s?.wrap})}var xn=new RegExp("\x1B(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)","g");function Re(s){return s.replace(xn,"")}function jn(s,t){let[e,n]=s.match(xn)||["",""];s=Re(s);let i="";for(let r=0;r<s.length;r++)r!==0&&r%t===0&&(i+=` `),i+=s.charAt(r);return e&&n&&(i=`${e}${i}${n}`),i}function He(s){return Cn(s,{stringWidth:t=>[...t].length,stripAnsi:Re,wrap:jn})}var Qt=require("path"),me=require("fs");function An(s,t){let e=(0,Qt.resolve)(".",s),n;for((0,me.statSync)(e).isDirectory()||(e=(0,Qt.dirname)(e));;){if(n=t(e,(0,me.readdirSync)(e)),n)return(0,Qt.resolve)(e,n);if(e=(0,Qt.dirname)(n=e),n===e)break}}var Un=require("util"),Bn=require("fs"),Tn=require("url");var Mn=require("util"),ye=require("path");function vt(s){if(s!==s.toLowerCase()&&s!==s.toUpperCase()||(s=s.toLowerCase()),s.indexOf("-")===-1&&s.indexOf("_")===-1)return s;{let e="",n=!1,i=s.match(/^-+/);for(let r=i?i[0].length:0;r<s.length;r++){let a=s.charAt(r);n&&(n=!1,a=a.toUpperCase()),r!==0&&(a==="-"||a==="_")?n=!0:a!=="-"&&a!=="_"&&(e+=a)}return e}}function ge(s,t){let e=s.toLowerCase();t=t||"-";let n="";for(let i=0;i<s.length;i++){let r=e.charAt(i),a=s.charAt(i);r!==a&&i>0?n+=`${t}${e.charAt(i)}`:n+=a}return n}function be(s){return s==null?!1:typeof s=="number"||/^0x[0-9a-f]+$/i.test(s)?!0:/^0[^.]/.test(s)?!1:/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(s)}function En(s){if(Array.isArray(s))return s.map(a=>typeof a!="string"?a+"":a);s=s.trim();let t=0,e=null,n=null,i=null,r=[];for(let a=0;a<s.length;a++){if(e=n,n=s.charAt(a),n===" "&&!i){e!==" "&&t++;continue}n===i?i=null:(n==="'"||n==='"')&&!i&&(i=n),r[t]||(r[t]=""),r[t]+=n}return r}var ut;(function(s){s.BOOLEAN="boolean",s.STRING="string",s.NUMBER="number",s.ARRAY="array"})(ut||(ut={}));var Et,we=class{constructor(t){Et=t}parse(t,e){let n=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},e),i=En(t),r=typeof t=="string",a=Bi(Object.assign(Object.create(null),n.alias)),f=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),m=Object.assign(Object.create(null),n.default),b=n.configObjects||[],d=n.envPrefix,u=f["populate--"],g=u?"--":"_",y=Object.create(null),_=Object.create(null),C=n.__||Et.format,p={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:[]},F=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,v=new RegExp("^--"+f["negation-prefix"]+"(.+)");[].concat(n.array||[]).filter(Boolean).forEach(function(l){let h=typeof l=="object"?l.key:l,O=Object.keys(l).map(function(w){return{boolean:"bools",string:"strings",number:"numbers"}[w]}).filter(Boolean).pop();O&&(p[O][h]=!0),p.arrays[h]=!0,p.keys.push(h)}),[].concat(n.boolean||[]).filter(Boolean).forEach(function(l){p.bools[l]=!0,p.keys.push(l)}),[].concat(n.string||[]).filter(Boolean).forEach(function(l){p.strings[l]=!0,p.keys.push(l)}),[].concat(n.number||[]).filter(Boolean).forEach(function(l){p.numbers[l]=!0,p.keys.push(l)}),[].concat(n.count||[]).filter(Boolean).forEach(function(l){p.counts[l]=!0,p.keys.push(l)}),[].concat(n.normalize||[]).filter(Boolean).forEach(function(l){p.normalize[l]=!0,p.keys.push(l)}),typeof n.narg=="object"&&Object.entries(n.narg).forEach(([l,h])=>{typeof h=="number"&&(p.nargs[l]=h,p.keys.push(l))}),typeof n.coerce=="object"&&Object.entries(n.coerce).forEach(([l,h])=>{typeof h=="function"&&(p.coercions[l]=h,p.keys.push(l))}),typeof n.config<"u"&&(Array.isArray(n.config)||typeof n.config=="string"?[].concat(n.config).filter(Boolean).forEach(function(l){p.configs[l]=!0}):typeof n.config=="object"&&Object.entries(n.config).forEach(([l,h])=>{(typeof h=="boolean"||typeof h=="function")&&(p.configs[l]=h)})),Dt(n.key,a,n.default,p.arrays),Object.keys(m).forEach(function(l){(p.aliases[l]||[]).forEach(function(h){m[h]=m[l]})});let B=null;ue();let H=[],N=Object.assign(Object.create(null),{_:[]}),it={};for(let l=0;l<i.length;l++){let h=i[l],O=h.replace(/^-{3,}/,"---"),w,c,P,j,$,st;if(h!=="--"&&/^-/.test(h)&&Q(h))bt(h);else if(O.match(/^---+(=|$)/)){bt(h);continue}else if(h.match(/^--.+=/)||!f["short-option-groups"]&&h.match(/^-.+=/))j=h.match(/^--?([^=]+)=([\s\S]*)$/),j!==null&&Array.isArray(j)&&j.length>=3&&(W(j[1],p.arrays)?l=Lt(l,j[1],i,j[2]):W(j[1],p.nargs)!==!1?l=Jt(l,j[1],i,j[2]):G(j[1],j[2],!0));else if(h.match(v)&&f["boolean-negation"])j=h.match(v),j!==null&&Array.isArray(j)&&j.length>=2&&(c=j[1],G(c,W(c,p.arrays)?[!1]:!1));else if(h.match(/^--.+/)||!f["short-option-groups"]&&h.match(/^-[^-]+/))j=h.match(/^--?(.+)/),j!==null&&Array.isArray(j)&&j.length>=2&&(c=j[1],W(c,p.arrays)?l=Lt(l,c,i):W(c,p.nargs)!==!1?l=Jt(l,c,i):($=i[l+1],$!==void 0&&(!$.match(/^-/)||$.match(F))&&!W(c,p.bools)&&!W(c,p.counts)||/^(true|false)$/.test($)?(G(c,$),l++):G(c,Z(c))));else if(h.match(/^-.\..+=/))j=h.match(/^-([^=]+)=([\s\S]*)$/),j!==null&&Array.isArray(j)&&j.length>=3&&G(j[1],j[2]);else if(h.match(/^-.\..+/)&&!h.match(F))$=i[l+1],j=h.match(/^-(.\..+)/),j!==null&&Array.isArray(j)&&j.length>=2&&(c=j[1],$!==void 0&&!$.match(/^-/)&&!W(c,p.bools)&&!W(c,p.counts)?(G(c,$),l++):G(c,Z(c)));else if(h.match(/^-[^-]+/)&&!h.match(F)){P=h.slice(1,-1).split(""),w=!1;for(let ot=0;ot<P.length;ot++){if($=h.slice(ot+2),P[ot+1]&&P[ot+1]==="="){st=h.slice(ot+3),c=P[ot],W(c,p.arrays)?l=Lt(l,c,i,st):W(c,p.nargs)!==!1?l=Jt(l,c,i,st):G(c,st),w=!0;break}if($==="-"){G(P[ot],$);continue}if(/[A-Za-z]/.test(P[ot])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test($)&&W($,p.bools)===!1){G(P[ot],$),w=!0;break}if(P[ot+1]&&P[ot+1].match(/\W/)){G(P[ot],$),w=!0;break}else G(P[ot],Z(P[ot]))}c=h.slice(-1)[0],!w&&c!=="-"&&(W(c,p.arrays)?l=Lt(l,c,i):W(c,p.nargs)!==!1?l=Jt(l,c,i):($=i[l+1],$!==void 0&&(!/^(-|--)[^-]/.test($)||$.match(F))&&!W(c,p.bools)&&!W(c,p.counts)||/^(true|false)$/.test($)?(G(c,$),l++):G(c,Z(c))))}else if(h.match(/^-[0-9]$/)&&h.match(F)&&W(h.slice(1),p.bools))c=h.slice(1),G(c,Z(c));else if(h==="--"){H=i.slice(l+1);break}else if(f["halt-at-non-option"]){H=i.slice(l);break}else bt(h)}T(N,!0),T(N,!1),R(N),et(),J(N,p.aliases,m,!0),nt(N),f["set-placeholder-key"]&&Wt(N),Object.keys(p.counts).forEach(function(l){jt(N,l.split("."))||G(l,0)}),u&&H.length&&(N[g]=[]),H.forEach(function(l){N[g].push(l)}),f["camel-case-expansion"]&&f["strip-dashed"]&&Object.keys(N).filter(l=>l!=="--"&&l.includes("-")).forEach(l=>{delete N[l]}),f["strip-aliased"]&&[].concat(...Object.keys(a).map(l=>a[l])).forEach(l=>{f["camel-case-expansion"]&&l.includes("-")&&delete N[l.split(".").map(h=>vt(h)).join(".")],delete N[l]});function bt(l){let h=S("_",l);(typeof h=="string"||typeof h=="number")&&N._.push(h)}function Jt(l,h,O,w){let c,P=W(h,p.nargs);if(P=typeof P!="number"||isNaN(P)?1:P,P===0)return yt(w)||(B=Error(C("Argument unexpected for: %s",h))),G(h,Z(h)),l;let j=yt(w)?0:1;if(f["nargs-eats-options"])O.length-(l+1)+j<P&&(B=Error(C("Not enough arguments following: %s",h))),j=P;else{for(c=l+1;c<O.length&&(!O[c].match(/^-[^0-9]/)||O[c].match(F)||Q(O[c]));c++)j++;j<P&&(B=Error(C("Not enough arguments following: %s",h)))}let $=Math.min(j,P);for(!yt(w)&&$>0&&(G(h,w),$--),c=l+1;c<$+l+1;c++)G(h,O[c]);return l+$}function Lt(l,h,O,w){let c=[],P=w||O[l+1],j=W(h,p.nargs);if(W(h,p.bools)&&!/^(true|false)$/.test(P))c.push(!0);else if(yt(P)||yt(w)&&/^-/.test(P)&&!F.test(P)&&!Q(P)){if(m[h]!==void 0){let $=m[h];c=Array.isArray($)?$:[$]}}else{yt(w)||c.push(x(h,w,!0));for(let $=l+1;$<O.length&&!(!f["greedy-arrays"]&&c.length>0||j&&typeof j=="number"&&c.length>=j||(P=O[$],/^-/.test(P)&&!F.test(P)&&!Q(P)));$++)l=$,c.push(x(h,P,r))}return typeof j=="number"&&(j&&c.length<j||isNaN(j)&&c.length===0)&&(B=Error(C("Not enough arguments following: %s",h))),G(h,c),l}function G(l,h,O=r){if(/-/.test(l)&&f["camel-case-expansion"]){let P=l.split(".").map(function(j){return vt(j)}).join(".");I(l,P)}let w=x(l,h,O),c=l.split(".");At(N,c,w),p.aliases[l]&&p.aliases[l].forEach(function(P){let j=P.split(".");At(N,j,w)}),c.length>1&&f["dot-notation"]&&(p.aliases[c[0]]||[]).forEach(function(P){let j=P.split("."),$=[].concat(c);$.shift(),j=j.concat($),(p.aliases[l]||[]).includes(j.join("."))||At(N,j,w)}),W(l,p.normalize)&&!W(l,p.arrays)&&[l].concat(p.aliases[l]||[]).forEach(function(j){Object.defineProperty(it,j,{enumerable:!0,get(){return h},set($){h=typeof $=="string"?Et.normalize($):$}})})}function I(l,h){p.aliases[l]&&p.aliases[l].length||(p.aliases[l]=[h],y[h]=!0),p.aliases[h]&&p.aliases[h].length||I(h,l)}function x(l,h,O){O&&(h=Ti(h)),(W(l,p.bools)||W(l,p.counts))&&typeof h=="string"&&(h=h==="true");let w=Array.isArray(h)?h.map(function(c){return S(l,c)}):S(l,h);return W(l,p.counts)&&(yt(w)||typeof w=="boolean")&&(w=Ue()),W(l,p.normalize)&&W(l,p.arrays)&&(Array.isArray(h)?w=h.map(c=>Et.normalize(c)):w=Et.normalize(h)),w}function S(l,h){return!f["parse-positional-numbers"]&&l==="_"||!W(l,p.strings)&&!W(l,p.bools)&&!Array.isArray(h)&&(be(h)&&f["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${h}`)))||!yt(h)&&W(l,p.numbers))&&(h=Number(h)),h}function R(l){let h=Object.create(null);J(h,p.aliases,m),Object.keys(p.configs).forEach(function(O){let w=l[O]||h[O];if(w)try{let c=null,P=Et.resolve(Et.cwd(),w),j=p.configs[O];if(typeof j=="function"){try{c=j(P)}catch($){c=$}if(c instanceof Error){B=c;return}}else c=Et.require(P);Y(c)}catch(c){c.name==="PermissionDenied"?B=c:l[O]&&(B=Error(C("Invalid JSON config file: %s",w)))}})}function Y(l,h){Object.keys(l).forEach(function(O){let w=l[O],c=h?h+"."+O:O;typeof w=="object"&&w!==null&&!Array.isArray(w)&&f["dot-notation"]?Y(w,c):(!jt(N,c.split("."))||W(c,p.arrays)&&f["combine-arrays"])&&G(c,w)})}function et(){typeof b<"u"&&b.forEach(function(l){Y(l)})}function T(l,h){if(typeof d>"u")return;let O=typeof d=="string"?d:"",w=Et.env();Object.keys(w).forEach(function(c){if(O===""||c.lastIndexOf(O,0)===0){let P=c.split("__").map(function(j,$){return $===0&&(j=j.substring(O.length)),vt(j)});(h&&p.configs[P.join(".")]||!h)&&!jt(l,P)&&G(P.join("."),w[c])}})}function nt(l){let h,O=new Set;Object.keys(l).forEach(function(w){if(!O.has(w)&&(h=W(w,p.coercions),typeof h=="function"))try{let c=S(w,h(l[w]));[].concat(p.aliases[w]||[],w).forEach(P=>{O.add(P),l[P]=c})}catch(c){B=c}})}function Wt(l){return p.keys.forEach(h=>{~h.indexOf(".")||typeof l[h]>"u"&&(l[h]=void 0)}),l}function J(l,h,O,w=!1){Object.keys(O).forEach(function(c){jt(l,c.split("."))||(At(l,c.split("."),O[c]),w&&(_[c]=!0),(h[c]||[]).forEach(function(P){jt(l,P.split("."))||At(l,P.split("."),O[c])}))})}function jt(l,h){let O=l;f["dot-notation"]||(h=[h.join(".")]),h.slice(0,-1).forEach(function(c){O=O[c]||{}});let w=h[h.length-1];return typeof O!="object"?!1:w in O}function At(l,h,O){let w=l;f["dot-notation"]||(h=[h.join(".")]),h.slice(0,-1).forEach(function(st){st=Sn(st),typeof w=="object"&&w[st]===void 0&&(w[st]={}),typeof w[st]!="object"||Array.isArray(w[st])?(Array.isArray(w[st])?w[st].push({}):w[st]=[w[st],{}],w=w[st][w[st].length-1]):w=w[st]});let c=Sn(h[h.length-1]),P=W(h.join("."),p.arrays),j=Array.isArray(O),$=f["duplicate-arguments-array"];!$&&W(c,p.nargs)&&($=!0,(!yt(w[c])&&p.nargs[c]===1||Array.isArray(w[c])&&w[c].length===p.nargs[c])&&(w[c]=void 0)),O===Ue()?w[c]=Ue(w[c]):Array.isArray(w[c])?$&&P&&j?w[c]=f["flatten-duplicate-arrays"]?w[c].concat(O):(Array.isArray(w[c][0])?w[c]:[w[c]]).concat([O]):!$&&!!P==!!j?w[c]=O:w[c]=w[c].concat([O]):w[c]===void 0&&P?w[c]=j?O:[O]:$&&!(w[c]===void 0||W(c,p.counts)||W(c,p.bools))?w[c]=[w[c],O]:w[c]=O}function Dt(...l){l.forEach(function(h){Object.keys(h||{}).forEach(function(O){p.aliases[O]||(p.aliases[O]=[].concat(a[O]||[]),p.aliases[O].concat(O).forEach(function(w){if(/-/.test(w)&&f["camel-case-expansion"]){let c=vt(w);c!==O&&p.aliases[O].indexOf(c)===-1&&(p.aliases[O].push(c),y[c]=!0)}}),p.aliases[O].concat(O).forEach(function(w){if(w.length>1&&/[A-Z]/.test(w)&&f["camel-case-expansion"]){let c=ge(w,"-");c!==O&&p.aliases[O].indexOf(c)===-1&&(p.aliases[O].push(c),y[c]=!0)}}),p.aliases[O].forEach(function(w){p.aliases[w]=[O].concat(p.aliases[O].filter(function(c){return w!==c}))}))})})}function W(l,h){let O=[].concat(p.aliases[l]||[],l),w=Object.keys(h),c=O.find(P=>w.includes(P));return c?h[c]:!1}function Ne(l){let h=Object.keys(p);return[].concat(h.map(w=>p[w])).some(function(w){return Array.isArray(w)?w.includes(l):w[l]})}function L(l,...h){return[].concat(...h).some(function(w){let c=l.match(w);return c&&Ne(c[1])})}function K(l){if(l.match(F)||!l.match(/^-[^-]+/))return!1;let h=!0,O,w=l.slice(1).split("");for(let c=0;c<w.length;c++){if(O=l.slice(c+2),!Ne(w[c])){h=!1;break}if(w[c+1]&&w[c+1]==="="||O==="-"||/[A-Za-z]/.test(w[c])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(O)||w[c+1]&&w[c+1].match(/\W/))break}return h}function Q(l){return f["unknown-options-as-args"]&&U(l)}function U(l){return l=l.replace(/^-{3,}/,"--"),l.match(F)||K(l)?!1:!L(l,/^-+([^=]+?)=[\s\S]*$/,v,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function Z(l){return!W(l,p.bools)&&!W(l,p.counts)&&`${l}`in m?m[l]:k(wt(l))}function k(l){return{[ut.BOOLEAN]:!0,[ut.STRING]:"",[ut.NUMBER]:void 0,[ut.ARRAY]:[]}[l]}function wt(l){let h=ut.BOOLEAN;return W(l,p.strings)?h=ut.STRING:W(l,p.numbers)?h=ut.NUMBER:W(l,p.bools)?h=ut.BOOLEAN:W(l,p.arrays)&&(h=ut.ARRAY),h}function yt(l){return l===void 0}function ue(){Object.keys(p.counts).find(l=>W(l,p.arrays)?(B=Error(C("Invalid configuration: %s, opts.count excludes opts.array.",l)),!0):W(l,p.nargs)?(B=Error(C("Invalid configuration: %s, opts.count excludes opts.narg.",l)),!0):!1)}return{aliases:Object.assign({},p.aliases),argv:Object.assign(it,N),configuration:f,defaulted:Object.assign({},_),error:B,newAliases:Object.assign({},y)}}};function Bi(s){let t=[],e=Object.create(null),n=!0;for(Object.keys(s).forEach(function(i){t.push([].concat(s[i],i))});n;){n=!1;for(let i=0;i<t.length;i++)for(let r=i+1;r<t.length;r++)if(t[i].filter(function(f){return t[r].indexOf(f)!==-1}).length){t[i]=t[i].concat(t[r]),t.splice(r,1),n=!0;break}}return t.forEach(function(i){i=i.filter(function(a,f,m){return m.indexOf(a)===f});let r=i.pop();r!==void 0&&typeof r=="string"&&(e[r]=i)}),e}function Ue(s){return s!==void 0?s+1:1}function Sn(s){return s==="__proto__"?"___proto___":s}function Ti(s){return typeof s=="string"&&(s[0]==="'"||s[0]==='"')&&s[s.length-1]===s[0]?s.substring(1,s.length-1):s}var $n=require("fs");var Be,Te,Ye,Pn=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,In=(Te=(Be=process==null?void 0:process.versions)===null||Be===void 0?void 0:Be.node)!==null&&Te!==void 0?Te:(Ye=process==null?void 0:process.version)===null||Ye===void 0?void 0:Ye.slice(1);if(In&&Number(In.match(/^([^.]+)/)[1])<Pn)throw Error(`yargs parser supports a minimum Node.js version of ${Pn}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);var Yi=process?process.env:{},Fn=new we({cwd:process.cwd,env:()=>Yi,format:Mn.format,normalize:ye.normalize,resolve:ye.resolve,require:s=>{if(typeof require<"u")return require(s);if(s.match(/\.json$/))return JSON.parse((0,$n.readFileSync)(s,"utf8"));throw Error("only .json config files are supported in ESM")}}),ie=function(t,e){return Fn.parse(t.slice(),e).argv};ie.detailed=function(s,t){return Fn.parse(s.slice(),t)};ie.camelCase=vt;ie.decamelize=ge;ie.looksLikeNumber=be;var Ge=ie;var Ot=require("path");function Ln(){return Gi()?0:1}function Gi(){return qi()&&!process.defaultApp}function qi(){return!!process.versions.electron}function qe(s){return s.slice(Ln()+1)}function Wn(){return process.argv[Ln()]}var q=class s extends Error{constructor(t){super(t||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,s)}};var Zt=require("fs"),Dn=require("util"),vn=require("path"),Nn={fs:{readFileSync:Zt.readFileSync,writeFile:Zt.writeFile},format:Dn.format,resolve:vn.resolve,exists:s=>{try{return(0,Zt.statSync)(s).isFile()}catch{return!1}}};var _t,Ve=class{constructor(t){t=t||{},this.directory=t.directory||"./locales",this.updateFiles=typeof t.updateFiles=="boolean"?t.updateFiles:!0,this.locale=t.locale||"en",this.fallbackToLanguage=typeof t.fallbackToLanguage=="boolean"?t.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...t){if(typeof arguments[0]!="string")return this._taggedLiteral(arguments[0],...arguments);let e=t.shift(),n=function(){};return typeof t[t.length-1]=="function"&&(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(),_t.format.apply(_t.format,[this.cache[this.locale][e]||e].concat(t))}__n(){let t=Array.prototype.slice.call(arguments),e=t.shift(),n=t.shift(),i=t.shift(),r=function(){};typeof t[t.length-1]=="function"&&(r=t.pop()),this.cache[this.locale]||this._readLocaleFile();let a=i===1?e:n;this.cache[this.locale][e]&&(a=this.cache[this.locale][e][i===1?"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:r})):r();let f=[a];return~a.indexOf("%d")&&f.push(i),_t.format.apply(_t.format,f.concat(t))}setLocale(t){this.locale=t}getLocale(){return this.locale}updateLocale(t){this.cache[this.locale]||this._readLocaleFile();for(let 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(i,r){let a=e[r+1];n+=i,typeof a<"u"&&(n+="%s")}),this.__.apply(this,[n].concat([].slice.call(e,1)))}_enqueueWrite(t){this.writeQueue.push(t),this.writeQueue.length===1&&this._processWriteQueue()}_processWriteQueue(){let t=this,e=this.writeQueue[0],n=e.directory,i=e.locale,r=e.cb,a=this._resolveLocaleFile(n,i),f=JSON.stringify(this.cache[i],null,2);_t.fs.writeFile(a,f,"utf-8",function(m){t.writeQueue.shift(),t.writeQueue.length>0&&t._processWriteQueue(),r(m)})}_readLocaleFile(){let t={},e=this._resolveLocaleFile(this.directory,this.locale);try{_t.fs.readFileSync&&(t=JSON.parse(_t.fs.readFileSync(e,"utf-8")))}catch(n){if(n instanceof SyntaxError&&(n.message="syntax error in "+e),n.code==="ENOENT")t={};else throw n}this.cache[this.locale]=t}_resolveLocaleFile(t,e){let n=_t.resolve(t,"./",e+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~e.lastIndexOf("_")){let i=_t.resolve(t,"./",e.split("_")[0]+".json");this._fileExistsSync(i)&&(n=i)}return n}_fileExistsSync(t){return _t.exists(t)}};function zn(s,t){_t=t;let e=new Ve(s);return{__:e.__.bind(e),__n:e.__n.bind(e),setLocale:e.setLocale.bind(e),getLocale:e.getLocale.bind(e),updateLocale:e.updateLocale.bind(e),locale:e.locale}}var Vi=s=>zn(s,Nn),Rn=Vi;var Qi={},Ki="require is not supported by ESM",Hn="loading a directory of commands is not supported yet for ESM",se;try{se=(0,Tn.fileURLToPath)(Qi.url)}catch{se=process.cwd()}var Ji=se.substring(0,se.lastIndexOf("node_modules")),Ke={assert:{notStrictEqual:_e.notStrictEqual,strictEqual:_e.strictEqual},cliui:He,findUp:An,getEnv:s=>process.env[s],inspect:Un.inspect,getCallerFile:()=>{throw new q(Hn)},getProcessArgvBin:Wn,mainFilename:Ji||process.cwd(),Parser:Ge,path:{basename:Ot.basename,dirname:Ot.dirname,extname:Ot.extname,relative:Ot.relative,resolve:Ot.resolve},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(s,t)=>process.emitWarning(s,t),execPath:()=>process.execPath,exit:process.exit,nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:Bn.readFileSync,require:()=>{throw new q(Ki)},requireDirectory:()=>{throw new q(Hn)},stringWidth:s=>[...s].length,y18n:Rn({directory:(0,Ot.resolve)(se,"../../../locales"),updateFiles:!1})};function at(s,t,e,n){e.assert.notStrictEqual(s,t,n)}function Je(s,t){t.assert.strictEqual(typeof s,"string")}function Xt(s){return Object.keys(s)}function V(s){return!!s&&!!s.then&&typeof s.then=="function"}function St(s){let e=s.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),n=/\.*[\][<>]/g,i=e.shift();if(!i)throw new Error(`No command found in: ${s}`);let r={cmd:i.replace(n,""),demanded:[],optional:[]};return e.forEach((a,f)=>{let m=!1;a=a.replace(/\s/g,""),/\.+[\]>]/.test(a)&&f===e.length-1&&(m=!0),/^\[/.test(a)?r.optional.push({cmd:a.replace(n,"").split("|"),variadic:m}):r.demanded.push({cmd:a.replace(n,"").split("|"),variadic:m})}),r}var Zi=["first","second","third","fourth","fifth","sixth"];function A(s,t,e){function n(){return typeof s=="object"?[{demanded:[],optional:[]},s,t]:[St(`cmd ${s}`),t,e]}try{let i=0,[r,a,f]=n(),m=[].slice.call(a);for(;m.length&&m[m.length-1]===void 0;)m.pop();let b=f||m.length;if(b<r.demanded.length)throw new q(`Not enough arguments provided. Expected ${r.demanded.length} but received ${m.length}.`);let d=r.demanded.length+r.optional.length;if(b>d)throw new q(`Too many arguments provided. Expected max ${d} but received ${b}.`);r.demanded.forEach(u=>{let g=m.shift(),y=Yn(g);u.cmd.filter(C=>C===y||C==="*").length===0&&Gn(y,u.cmd,i),i+=1}),r.optional.forEach(u=>{if(m.length===0)return;let g=m.shift(),y=Yn(g);u.cmd.filter(C=>C===y||C==="*").length===0&&Gn(y,u.cmd,i),i+=1})}catch(i){console.warn(i.stack)}}function Yn(s){return Array.isArray(s)?"array":s===null?"null":typeof s}function Gn(s,t,e){throw new q(`Invalid ${Zi[e]||"manyith"} argument. Expected ${t.join(" or ")} but received ${s}.`)}var Oe=class{constructor(t){this.globalMiddleware=[],this.frozens=[],this.yargs=t}addMiddleware(t,e,n=!0,i=!1){if(A("<array|function> [boolean] [boolean] [boolean]",[t,e,n],arguments.length),Array.isArray(t)){for(let r=0;r<t.length;r++){if(typeof t[r]!="function")throw Error("middleware must be a function");let a=t[r];a.applyBeforeValidation=e,a.global=n}Array.prototype.push.apply(this.globalMiddleware,t)}else if(typeof t=="function"){let r=t;r.applyBeforeValidation=e,r.global=n,r.mutates=i,this.globalMiddleware.push(t)}return this.yargs}addCoerceMiddleware(t,e){let n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter(i=>{let r=[...n[e]||[],e];return i.option?!r.includes(i.option):!0}),t.option=e,this.addMiddleware(t,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let t=this.frozens.pop();t!==void 0&&(this.globalMiddleware=t)}reset(){this.globalMiddleware=this.globalMiddleware.filter(t=>t.global)}};function qn(s){return s?s.map(t=>(t.applyBeforeValidation=!1,t)):[]}function Nt(s,t,e,n){return e.reduce((i,r)=>{if(r.applyBeforeValidation!==n)return i;if(r.mutates){if(r.applied)return i;r.applied=!0}if(V(i))return i.then(a=>Promise.all([a,r(a,t)])).then(([a,f])=>Object.assign(a,f));{let a=r(i,t);return V(a)?a.then(f=>Object.assign(i,f)):Object.assign(i,a)}},s)}function zt(s,t,e=n=>{throw n}){try{let n=Xi(s)?s():s;return V(n)?n.then(i=>t(i)):t(n)}catch(n){return e(n)}}function Xi(s){return typeof s=="function"}function Qe(s){if(typeof require>"u")return null;for(let t=0,e=Object.keys(require.cache),n;t<e.length;t++)if(n=require.cache[e[t]],n.exports===s)return n;return null}var kt=/(^\*)|(^\$0)/,Ze=class{constructor(t,e,n,i){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=i,this.usage=t,this.globalMiddleware=n,this.validation=e}addDirectory(t,e,n,i){i=i||{},typeof i.recurse!="boolean"&&(i.recurse=!1),Array.isArray(i.extensions)||(i.extensions=["js"]);let r=typeof i.visit=="function"?i.visit:a=>a;i.visit=(a,f,m)=>{let b=r(a,f,m);if(b){if(this.requireCache.has(f))return b;this.requireCache.add(f),this.addHandler(b)}return b},this.shim.requireDirectory({require:e,filename:n},t,i)}addHandler(t,e,n,i,r,a){let f=[],m=qn(r);if(i=i||(()=>{}),Array.isArray(t))if(ki(t))[t,...f]=t;else for(let b of t)this.addHandler(b);else if(es(t)){let b=Array.isArray(t.command)||typeof t.command=="string"?t.command:this.moduleName(t);t.aliases&&(b=[].concat(b).concat(t.aliases)),this.addHandler(b,this.extractDesc(t),t.builder,t.handler,t.middlewares,t.deprecated);return}else if(Vn(n)){this.addHandler([t].concat(f),e,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof t=="string"){let b=St(t);f=f.map(g=>St(g).cmd);let d=!1,u=[b.cmd].concat(f).filter(g=>kt.test(g)?(d=!0,!1):!0);u.length===0&&d&&u.push("$0"),d&&(b.cmd=u[0],f=u.slice(1),t=t.replace(kt,b.cmd)),f.forEach(g=>{this.aliasMap[g]=b.cmd}),e!==!1&&this.usage.command(t,e,d,f,a),this.handlers[b.cmd]={original:t,description:e,handler:i,builder:n||{},middlewares:m,deprecated:a,demanded:b.demanded,optional:b.optional},d&&(this.defaultCommand=this.handlers[b.cmd])}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(t,e,n,i,r,a){let f=this.handlers[t]||this.handlers[this.aliasMap[t]]||this.defaultCommand,m=e.getInternalMethods().getContext(),b=m.commands.slice(),d=!t;t&&(m.commands.push(t),m.fullCommands.push(f.original));let u=this.applyBuilderUpdateUsageAndParse(d,f,e,n.aliases,b,i,r,a);return V(u)?u.then(g=>this.applyMiddlewareAndGetResult(d,f,g.innerArgv,m,r,g.aliases,e)):this.applyMiddlewareAndGetResult(d,f,u.innerArgv,m,r,u.aliases,e)}applyBuilderUpdateUsageAndParse(t,e,n,i,r,a,f,m){let b=e.builder,d=n;if(Ce(b)){n.getInternalMethods().getUsageInstance().freeze();let u=b(n.getInternalMethods().reset(i),m);if(V(u))return u.then(g=>(d=Jn(g)?g:n,this.parseAndUpdateUsage(t,e,d,r,a,f)))}else ts(b)&&(n.getInternalMethods().getUsageInstance().freeze(),d=n.getInternalMethods().reset(i),Object.keys(e.builder).forEach(u=>{d.option(u,b[u])}));return this.parseAndUpdateUsage(t,e,d,r,a,f)}parseAndUpdateUsage(t,e,n,i,r,a){t&&n.getInternalMethods().getUsageInstance().unfreeze(!0),this.shouldUpdateUsage(n)&&n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(i,e),e.description);let f=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,r,a);return V(f)?f.then(m=>({aliases:n.parsed.aliases,innerArgv:m})):{aliases:n.parsed.aliases,innerArgv:f}}shouldUpdateUsage(t){return!t.getInternalMethods().getUsageInstance().getUsageDisabled()&&t.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(t,e){let n=kt.test(e.original)?e.original.replace(kt,"").trim():e.original,i=t.filter(r=>!kt.test(r));return i.push(n),`$0 ${i.join(" ")}`}handleValidationAndGetResult(t,e,n,i,r,a,f,m){if(!a.getInternalMethods().getHasOutput()){let b=a.getInternalMethods().runValidation(r,m,a.parsed.error,t);n=zt(n,d=>(b(d),d))}if(e.handler&&!a.getInternalMethods().getHasOutput()){a.getInternalMethods().setHasOutput();let b=!!a.getOptions().configuration["populate--"];a.getInternalMethods().postProcess(n,b,!1,!1),n=Nt(n,a,f,!1),n=zt(n,d=>{let u=e.handler(d);return V(u)?u.then(()=>d):d}),t||a.getInternalMethods().getUsageInstance().cacheHelpMessage(),V(n)&&!a.getInternalMethods().hasParseCallback()&&n.catch(d=>{try{a.getInternalMethods().getUsageInstance().fail(null,d)}catch{}})}return t||(i.commands.pop(),i.fullCommands.pop()),n}applyMiddlewareAndGetResult(t,e,n,i,r,a,f){let m={};if(r)return n;f.getInternalMethods().getHasOutput()||(m=this.populatePositionals(e,n,i,f));let b=this.globalMiddleware.getMiddleware().slice(0).concat(e.middlewares),d=Nt(n,f,b,!0);return V(d)?d.then(u=>this.handleValidationAndGetResult(t,e,u,i,a,f,b,m)):this.handleValidationAndGetResult(t,e,d,i,a,f,b,m)}populatePositionals(t,e,n,i){e._=e._.slice(n.commands.length);let r=t.demanded.slice(0),a=t.optional.slice(0),f={};for(this.validation.positionalCount(r.length,e._.length);r.length;){let m=r.shift();this.populatePositional(m,e,f)}for(;a.length;){let m=a.shift();this.populatePositional(m,e,f)}return e._=n.commands.concat(e._.map(m=>""+m)),this.postProcessPositionals(e,f,this.cmdToParseOptions(t.original),i),f}populatePositional(t,e,n){let i=t.cmd[0];t.variadic?n[i]=e._.splice(0).map(String):e._.length&&(n[i]=[String(e._.shift())])}cmdToParseOptions(t){let e={array:[],default:{},alias:{},demand:{}},n=St(t);return n.demanded.forEach(i=>{let[r,...a]=i.cmd;i.variadic&&(e.array.push(r),e.default[r]=[]),e.alias[r]=a,e.demand[r]=!0}),n.optional.forEach(i=>{let[r,...a]=i.cmd;i.variadic&&(e.array.push(r),e.default[r]=[]),e.alias[r]=a}),e}postProcessPositionals(t,e,n,i){let r=Object.assign({},i.getOptions());r.default=Object.assign(n.default,r.default);for(let b of Object.keys(n.alias))r.alias[b]=(r.alias[b]||[]).concat(n.alias[b]);r.array=r.array.concat(n.array),r.config={};let a=[];if(Object.keys(e).forEach(b=>{e[b].map(d=>{r.configuration["unknown-options-as-args"]&&(r.key[b]=!0),a.push(`--${b}`),a.push(d)})}),!a.length)return;let f=Object.assign({},r.configuration,{"populate--":!1}),m=this.shim.Parser.detailed(a,Object.assign({},r,{configuration:f}));if(m.error)i.getInternalMethods().getUsageInstance().fail(m.error.message,m.error);else{let b=Object.keys(e);Object.keys(e).forEach(d=>{b.push(...m.aliases[d])}),Object.keys(m.argv).forEach(d=>{b.includes(d)&&(e[d]||(e[d]=m.argv[d]),!this.isInConfigs(i,d)&&!this.isDefaulted(i,d)&&Object.prototype.hasOwnProperty.call(t,d)&&Object.prototype.hasOwnProperty.call(m.argv,d)&&(Array.isArray(t[d])||Array.isArray(m.argv[d]))?t[d]=[].concat(t[d],m.argv[d]):t[d]=m.argv[d])})}}isDefaulted(t,e){let{default:n}=t.getOptions();return Object.prototype.hasOwnProperty.call(n,e)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(e))}isInConfigs(t,e){let{configObjects:n}=t.getOptions();return n.some(i=>Object.prototype.hasOwnProperty.call(i,e))||n.some(i=>Object.prototype.hasOwnProperty.call(i,this.shim.Parser.camelCase(e)))}runDefaultBuilderOn(t){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(t)){let n=kt.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");t.getInternalMethods().getUsageInstance().usage(n,this.defaultCommand.description)}let e=this.defaultCommand.builder;if(Ce(e))return e(t,!0);Vn(e)||Object.keys(e).forEach(n=>{t.option(n,e[n])})}moduleName(t){let e=Qe(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(let i of[t,e,n]){if(typeof i=="string"||i===!1)return i;at(i,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let t=this.frozens.pop();at(t,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=t}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}};function Kn(s,t,e,n){return new Ze(s,t,e,n)}function Vn(s){return typeof s=="object"&&!!s.builder&&typeof s.handler=="function"}function ki(s){return s.every(t=>typeof t=="string")}function Ce(s){return typeof s=="function"}function ts(s){return typeof s=="object"}function es(s){return typeof s=="object"&&!Array.isArray(s)}function Pt(s={},t=()=>!0){let e={};return Xt(s).forEach(n=>{t(n,s[n])&&(e[n]=s[n])}),e}function It(s){typeof process>"u"||[process.stdout,process.stderr].forEach(t=>{let e=t;e._handle&&e.isTTY&&typeof e._handle.setBlocking=="function"&&e._handle.setBlocking(s)})}function ns(s){return typeof s=="boolean"}function Zn(s,t){let e=t.y18n.__,n={},i=[];n.failFn=function(x){i.push(x)};let r=null,a=null,f=!0;n.showHelpOnFail=function(x=!0,S){let[R,Y]=typeof x=="string"?[!0,x]:[x,S];return s.getInternalMethods().isGlobalContext()&&(a=Y),r=Y,f=R,n};let m=!1;n.fail=function(x,S){let R=s.getInternalMethods().getLoggerInstance();if(i.length)for(let Y=i.length-1;Y>=0;--Y){let et=i[Y];if(ns(et)){if(S)throw S;if(x)throw Error(x)}else et(x,S,n)}else{if(s.getExitProcess()&&It(!0),!m){m=!0,f&&(s.showHelp("error"),R.error()),(x||S)&&R.error(x||S);let Y=r||a;Y&&((x||S)&&R.error(""),R.error(Y))}if(S=S||new q(x),s.getExitProcess())return s.exit(1);if(s.getInternalMethods().hasParseCallback())return s.exit(1,S);throw S}};let b=[],d=!1;n.usage=(I,x)=>I===null?(d=!0,b=[],n):(d=!1,b.push([I,x||""]),n),n.getUsage=()=>b,n.getUsageDisabled=()=>d,n.getPositionalGroupName=()=>e("Positionals:");let u=[];n.example=(I,x)=>{u.push([I,x||""])};let g=[];n.command=function(x,S,R,Y,et=!1){R&&(g=g.map(T=>(T[2]=!1,T))),g.push([x,S||"",R,Y,et])},n.getCommands=()=>g;let y={};n.describe=function(x,S){Array.isArray(x)?x.forEach(R=>{n.describe(R,S)}):typeof x=="object"?Object.keys(x).forEach(R=>{n.describe(R,x[R])}):y[x]=S},n.getDescriptions=()=>y;let _=[];n.epilog=I=>{_.push(I)};let C=!1,p;n.wrap=I=>{C=!0,p=I},n.getWrap=()=>t.getEnv("YARGS_DISABLE_WRAP")?null:(C||(p=Jt(),C=!0),p);let F="__yargsString__:";n.deferY18nLookup=I=>F+I,n.help=function(){if(H)return H;B();let x=s.customScriptName?s.$0:t.path.basename(s.$0),S=s.getDemandedOptions(),R=s.getDemandedCommands(),Y=s.getDeprecatedOptions(),et=s.getGroups(),T=s.getOptions(),nt=[];nt=nt.concat(Object.keys(y)),nt=nt.concat(Object.keys(S)),nt=nt.concat(Object.keys(R)),nt=nt.concat(Object.keys(T.default)),nt=nt.filter(it),nt=Object.keys(nt.reduce((L,K)=>(K!=="_"&&(L[K]=!0),L),{}));let Wt=n.getWrap(),J=t.cliui({width:Wt,wrap:!!Wt});if(!d){if(b.length)b.forEach(L=>{J.div({text:`${L[0].replace(/\$0/g,x)}`}),L[1]&&J.div({text:`${L[1]}`,padding:[1,0,0,0]})}),J.div();else if(g.length){let L=null;R._?L=`${x} <${e("command")}> `:L=`${x} [${e("command")}] `,J.div(`${L}`)}}if(g.length>1||g.length===1&&!g[0][2]){J.div(e("Commands:"));let L=s.getInternalMethods().getContext(),K=L.commands.length?`${L.commands.join(" ")} `:"";s.getInternalMethods().getParserConfiguration()["sort-commands"]===!0&&(g=g.sort((U,Z)=>U[0].localeCompare(Z[0])));let Q=x?`${x} `:"";g.forEach(U=>{let Z=`${Q}${K}${U[0].replace(/^\$0 ?/,"")}`;J.span({text:Z,padding:[0,2,0,2],width:v(g,Wt,`${x}${K}`)+4},{text:U[1]});let k=[];U[2]&&k.push(`[${e("default")}]`),U[3]&&U[3].length&&k.push(`[${e("aliases:")} ${U[3].join(", ")}]`),U[4]&&(typeof U[4]=="string"?k.push(`[${e("deprecated: %s",U[4])}]`):k.push(`[${e("deprecated")}]`)),k.length?J.div({text:k.join(" "),padding:[0,0,0,2],align:"right"}):J.div()}),J.div()}let jt=(Object.keys(T.alias)||[]).concat(Object.keys(s.parsed.newAliases)||[]);nt=nt.filter(L=>!s.parsed.newAliases[L]&&jt.every(K=>(T.alias[K]||[]).indexOf(L)===-1));let At=e("Options:");et[At]||(et[At]=[]),N(nt,T.alias,et,At);let Dt=L=>/^--/.test(xe(L)),W=Object.keys(et).filter(L=>et[L].length>0).map(L=>{let K=et[L].filter(it).map(Q=>{if(jt.includes(Q))return Q;for(let U=0,Z;(Z=jt[U])!==void 0;U++)if((T.alias[Z]||[]).includes(Q))return Z;return Q});return{groupName:L,normalizedKeys:K}}).filter(({normalizedKeys:L})=>L.length>0).map(({groupName:L,normalizedKeys:K})=>{let Q=K.reduce((U,Z)=>(U[Z]=[Z].concat(T.alias[Z]||[]).map(k=>L===n.getPositionalGroupName()?k:(/^[0-9]$/.test(k)?T.boolean.includes(Z)?"-":"--":k.length>1?"--":"-")+k).sort((k,wt)=>Dt(k)===Dt(wt)?0:Dt(k)?1:-1).join(", "),U),{});return{groupName:L,normalizedKeys:K,switches:Q}});if(W.filter(({groupName:L})=>L!==n.getPositionalGroupName()).some(({normalizedKeys:L,switches:K})=>!L.every(Q=>Dt(K[Q])))&&W.filter(({groupName:L})=>L!==n.getPositionalGroupName()).forEach(({normalizedKeys:L,switches:K})=>{L.forEach(Q=>{Dt(K[Q])&&(K[Q]=is(K[Q],4))})}),W.forEach(({groupName:L,normalizedKeys:K,switches:Q})=>{J.div(L),K.forEach(U=>{let Z=Q[U],k=y[U]||"",wt=null;k.includes(F)&&(k=e(k.substring(F.length))),T.boolean.includes(U)&&(wt=`[${e("boolean")}]`),T.count.includes(U)&&(wt=`[${e("count")}]`),T.string.includes(U)&&(wt=`[${e("string")}]`),T.normalize.includes(U)&&(wt=`[${e("string")}]`),T.array.includes(U)&&(wt=`[${e("array")}]`),T.number.includes(U)&&(wt=`[${e("number")}]`);let yt=h=>typeof h=="string"?`[${e("deprecated: %s",h)}]`:`[${e("deprecated")}]`,ue=[U in Y?yt(Y[U]):null,wt,U in S?`[${e("required")}]`:null,T.choices&&T.choices[U]?`[${e("choices:")} ${n.stringifiedValues(T.choices[U])}]`:null,bt(T.default[U],T.defaultDescription[U])].filter(Boolean).join(" ");J.span({text:xe(Z),padding:[0,2,0,2+Qn(Z)],width:v(Q,Wt)+4},k);let l=s.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;ue&&!l?J.div({text:ue,padding:[0,0,0,2],align:"right"}):J.div()}),J.div()}),u.length&&(J.div(e("Examples:")),u.forEach(L=>{L[0]=L[0].replace(/\$0/g,x)}),u.forEach(L=>{L[1]===""?J.div({text:L[0],padding:[0,2,0,2]}):J.div({text:L[0],padding:[0,2,0,2],width:v(u,Wt)+4},{text:L[1]})}),J.div()),_.length>0){let L=_.map(K=>K.replace(/\$0/g,x)).join(` `);J.div(`${L} `)}return J.toString().replace(/\s*$/,"")};function v(I,x,S){let R=0;return Array.isArray(I)||(I=Object.values(I).map(Y=>[Y])),I.forEach(Y=>{R=Math.max(t.stringWidth(S?`${S} ${xe(Y[0])}`:xe(Y[0]))+Qn(Y[0]),R)}),x&&(R=Math.min(R,parseInt((x*.5).toString(),10))),R}function B(){let I=s.getDemandedOptions(),x=s.getOptions();(Object.keys(x.alias)||[]).forEach(S=>{x.alias[S].forEach(R=>{y[R]&&n.describe(S,y[R]),R in I&&s.demandOption(S,I[R]),x.boolean.includes(R)&&s.boolean(S),x.count.includes(R)&&s.count(S),x.string.includes(R)&&s.string(S),x.normalize.includes(R)&&s.normalize(S),x.array.includes(R)&&s.array(S),x.number.includes(R)&&s.number(S)})})}let H;n.cacheHelpMessage=function(){H=this.help()},n.clearCachedHelpMessage=function(){H=void 0},n.hasCachedHelpMessage=function(){return!!H};function N(I,x,S,R){let Y=[],et=null;return Object.keys(S).forEach(T=>{Y=Y.concat(S[T])}),I.forEach(T=>{et=[T].concat(x[T]),et.some(nt=>Y.indexOf(nt)!==-1)||S[R].push(T)}),Y}function it(I){return s.getOptions().hiddenOptions.indexOf(I)<0||s.parsed.argv[s.getOptions().showHiddenOpt]}n.showHelp=I=>{let x=s.getInternalMethods().getLoggerInstance();I||(I="error"),(typeof I=="function"?I:x[I])(n.help())},n.functionDescription=I=>["(",I.name?t.Parser.decamelize(I.name,"-"):e("generated-value"),")"].join(""),n.stringifiedValues=function(x,S){let R="",Y=S||", ",et=[].concat(x);return!x||!et.length||et.forEach(T=>{R.length&&(R+=Y),R+=JSON.stringify(T)}),R};function bt(I,x){let S=`[${e("default:")} `;if(I===void 0&&!x)return null;if(x)S+=x;else switch(typeof I){case"string":S+=`"${I}"`;break;case"object":S+=JSON.stringify(I);break;default:S+=I}return`${S}]`}function Jt(){return t.process.stdColumns?Math.min(80,t.process.stdColumns):80}let Lt=null;n.version=I=>{Lt=I},n.showVersion=I=>{let x=s.getInternalMethods().getLoggerInstance();I||(I="error"),(typeof I=="function"?I:x[I])(Lt)},n.reset=function(x){return r=null,m=!1,b=[],d=!1,_=[],u=[],g=[],y=Pt(y,S=>!x[S]),n};let G=[];return n.freeze=function(){G.push({failMessage:r,failureOutput:m,usages:b,usageDisabled:d,epilogs:_,examples:u,commands:g,descriptions:y})},n.unfreeze=function(x=!1){let S=G.pop();S&&(x?(y={...S.descriptions,...y},g=[...S.commands,...g],b=[...S.usages,...b],u=[...S.examples,...u],_=[...S.epilogs,..._]):{failMessage:r,failureOutput:m,usages:b,usageDisabled:d,epilogs:_,examples:u,commands:g,descriptions:y}=S)},n}function Xe(s){return typeof s=="object"}function is(s,t){return Xe(s)?{text:s.text,indentation:s.indentation+t}:{text:s,indentation:t}}function Qn(s){return Xe(s)?s.indentation:0}function xe(s){return Xe(s)?s.text:s}var Xn=`###-begin-{{app_name}}-completions-### # # yargs command completion script # # Installation: {{app_path}} {{completion_command}} >> ~/.bashrc # or {{app_path}} {{completion_command}} >> ~/.bash_profile on OSX. # _{{app_name}}_yargs_completions() { local cur_word args type_list cur_word="\${COMP_WORDS[COMP_CWORD]}" args=("\${COMP_WORDS[@]}") # ask yargs to generate completions. type_list=$({{app_path}} --get-yargs-completions "\${args[@]}") COMPREPLY=( $(compgen -W "\${type_list}" -- \${cur_word}) ) # if no match was found, fall back to filename completion if [ \${#COMPREPLY[@]} -eq 0 ]; then COMPREPLY=() fi return 0 } complete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name}} ###-end-{{app_name}}-completions-### `,kn=`#compdef {{app_name}} ###-begin-{{app_name}}-completions-### # # yargs command completion script # # Installation: {{app_path}} {{completion_command}} >> ~/.zshrc # or {{app_path}} {{completion_command}} >> ~/.zprofile on OSX. # _{{app_name}}_yargs_completions() { local reply local si=$IFS IFS=$' ' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" {{app_path}} --get-yargs-completions "\${words[@]}")) IFS=$si _describe 'values' reply } compdef _{{app_name}}_yargs_completions {{app_name}} ###-end-{{app_name}}-completions-### `;var ke=class{constructor(t,e,n,i){var r,a,f;this.yargs=t,this.usage=e,this.command=n,this.shim=i,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=(f=((r=this.shim.getEnv("SHELL"))===null||r===void 0?void 0:r.includes("zsh"))||((a=this.shim.getEnv("ZSH_NAME"))===null||a===void 0?void 0:a.includes("zsh")))!==null&&f!==void 0?f:!1}defaultCompletion(t,e,n,i){let r=this.command.getCommandHandlers();for(let f=0,m=t.length;f<m;++f)if(r[t[f]]&&r[t[f]].builder){let b=r[t[f]].builder;if(Ce(b)){this.indexAfterLastReset=f+1;let d=this.yargs.getInternalMethods().reset();return b(d,!0),d.argv}}let a=[];this.commandCompletions(a,t,n),this.optionCompletions(a,t,e,n),this.choicesFromOptionsCompletions(a,t,e,n),this.choicesFromPositionalsCompletions(a,t,e,n),i(null,a)}commandCompletions(t,e,n){let i=this.yargs.getInternalMethods().getContext().commands;!n.match(/^-/)&&i[i.length-1]!==n&&!this.previousArgHasChoices(e)&&this.usage.getCommands().forEach(r=>{let a=St(r[0]).cmd;if(e.indexOf(a)===-1)if(!this.zshShell)t.push(a);else{let f=r[1]||"";t.push(a.replace(/:/g,"\\:")+":"+f)}})}optionCompletions(t,e,n,i){if((i.match(/^-/)||i===""&&t.length===0)&&!this.previousArgHasChoices(e)){let r=this.yargs.getOptions(),a=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(r.key).forEach(f=>{let m=!!r.configuration["boolean-negation"]&&r.boolean.includes(f);!a.includes(f)&&!r.hiddenOptions.includes(f)&&!this.argsContainKey(e,f,m)&&this.completeOptionKey(f,t,i,m&&!!r.default[f])})}}choicesFromOptionsCompletions(t,e,n,i){if(this.previousArgHasChoices(e)){let r=this.getPreviousArgChoices(e);r&&r.length>0&&t.push(...r.map(a=>a.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(t,e,n,i){if(i===""&&t.length>0&&this.previousArgHasChoices(e))return;let r=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],a=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),f=r[n._.length-a-1];if(!f)return;let m=this.yargs.getOptions().choices[f]||[];for(let b of m)b.startsWith(i)&&t.push(b.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;let i=e.replace(/^-+/,""),r=this.yargs.getOptions(),a=[i,...this.yargs.getAliases()[i]||[]],f;for(let m of a)if(Object.prototype.hasOwnProperty.call(r.key,m)&&Array.isArray(r.choices[m])){f=r.choices[m];break}if(f)return f.filter(m=>!n||m.startsWith(n))}previousArgHasChoices(t){let e=this.getPreviousArgChoices(t);return e!==void 0&&e.length>0}argsContainKey(t,e,n){let i=r=>t.indexOf((/^[^0-9]$/.test(r)?"-":"--")+r)!==-1;if(i(e)||n&&i(`no-${e}`))return!0;if(this.aliases){for(let r of this.aliases[e])if(i(r))return!0}return!1}completeOptionKey(t,e,n,i){var r,a,f,m;let b=t;if(this.zshShell){let y=this.usage.getDescriptions(),_=(a=(r=this===null||this===void 0?void 0:this.aliases)===null||r===void 0?void 0:r[t])===null||a===void 0?void 0:a.find(F=>{let v=y[F];return typeof v=="string"&&v.length>0}),C=_?y[_]:void 0,p=(m=(f=y[t])!==null&&f!==void 0?f:C)!==null&&m!==void 0?m:"";b=`${t.replace(/:/g,"\\:")}:${p.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}let d=y=>/^--/.test(y),u=y=>/^[^0-9]$/.test(y),g=!d(n)&&u(t)?"-":"--";e.push(g+b),i&&e.push(g+"no-"+b)}customCompletion(t,e,n,i){if(at(this.customCompletionFunction,null,this.shim),rs(this.customCompletionFunction)){let r=this.customCompletionFunction(n,e);return V(r)?r.then(a=>{this.shim.process.nextTick(()=>{i(null,a)})}).catch(a=>{this.shim.process.nextTick(()=>{i(a,void 0)})}):i(null,r)}else return os(this.customCompletionFunction)?this.customCompletionFunction(n,e,(r=i)=>this.defaultCompletion(t,e,n,r),r=>{i(null,r)}):this.customCompletionFunction(n,e,r=>{i(null,r)})}getCompletion(t,e){let n=t.length?t[t.length-1]:"",i=this.yargs.parse(t,!0),r=this.customCompletionFunction?a=>this.customCompletion(t,a,n,e):a=>this.defaultCompletion(t,a,n,e);return V(i)?i.then(r):r(i)}generateCompletionScript(t,e){let n=this.zshShell?kn:Xn,i=this.shim.path.basename(t);return t.match(/\.js$/)&&(t=`./${t}`),n=n.replace(/{{app_name}}/g,i),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 ti(s,t,e,n){return new ke(s,t,e,n)}function rs(s){return s.length<3}function os(s){return s.length>3}function ei(s,t){if(s.length===0)return t.length;if(t.length===0)return s.length;let e=[],n;for(n=0;n<=t.length;n++)e[n]=[n];let i;for(i=0;i<=s.length;i++)e[0][i]=i;for(n=1;n<=t.length;n++)for(i=1;i<=s.length;i++)t.charAt(n-1)===s.charAt(i-1)?e[n][i]=e[n-1][i-1]:n>1&&i>1&&t.charAt(n-2)===s.charAt(i-1)&&t.charAt(n-1)===s.charAt(i-2)?e[n][i]=e[n-2][i-2]+1:e[n][i]=Math.min(e[n-1][i-1]+1,Math.min(e[n][i-1]+1,e[n-1][i]