create-chuntianxiaozhu
Version:
春天小猪模板工具
48 lines • 54.8 kB
JavaScript
import E from"node:fs";import P from"node:path";import{fileURLToPath as He}from"node:url";import Ye from"child_process";import ht from"path";import ct from"fs";import Be from"readline";import Ve from"events";var ke=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ut(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var J={exports:{}},dt,Yt;function ze(){if(Yt)return dt;Yt=1,dt=i,i.sync=n;var e=ct;function t(o,r){var l=r.pathExt!==void 0?r.pathExt:process.env.PATHEXT;if(!l||(l=l.split(";"),l.indexOf("")!==-1))return!0;for(var d=0;d<l.length;d++){var a=l[d].toLowerCase();if(a&&o.substr(-a.length).toLowerCase()===a)return!0}return!1}function s(o,r,l){return!o.isSymbolicLink()&&!o.isFile()?!1:t(r,l)}function i(o,r,l){e.stat(o,function(d,a){l(d,d?!1:s(a,o,r))})}function n(o,r){return s(e.statSync(o),o,r)}return dt}var ft,Bt;function Je(){if(Bt)return ft;Bt=1,ft=t,t.sync=s;var e=ct;function t(o,r,l){e.stat(o,function(d,a){l(d,d?!1:i(a,r))})}function s(o,r){return i(e.statSync(o),r)}function i(o,r){return o.isFile()&&n(o,r)}function n(o,r){var l=o.mode,d=o.uid,a=o.gid,y=r.uid!==void 0?r.uid:process.getuid&&process.getuid(),f=r.gid!==void 0?r.gid:process.getgid&&process.getgid(),h=parseInt("100",8),u=parseInt("010",8),g=parseInt("001",8),$=h|u,D=l&g||l&u&&a===f||l&h&&d===y||l&$&&y===0;return D}return ft}var st;process.platform==="win32"||ke.TESTING_WINDOWS?st=ze():st=Je();var We=pt;pt.sync=Ue;function pt(e,t,s){if(typeof t=="function"&&(s=t,t={}),!s){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(i,n){pt(e,t||{},function(o,r){o?n(o):i(r)})})}st(e,t||{},function(i,n){i&&(i.code==="EACCES"||t&&t.ignoreErrors)&&(i=null,n=!1),s(i,n)})}function Ue(e,t){try{return st.sync(e,t||{})}catch(s){if(t&&t.ignoreErrors||s.code==="EACCES")return!1;throw s}}const W=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Vt=ht,Ge=W?";":":",kt=We,zt=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),Jt=(e,t)=>{const s=t.colon||Ge,i=e.match(/\//)||W&&e.match(/\\/)?[""]:[...W?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(s)],n=W?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",o=W?n.split(s):[""];return W&&e.indexOf(".")!==-1&&o[0]!==""&&o.unshift(""),{pathEnv:i,pathExt:o,pathExtExe:n}},Wt=(e,t,s)=>{typeof t=="function"&&(s=t,t={}),t||(t={});const{pathEnv:i,pathExt:n,pathExtExe:o}=Jt(e,t),r=[],l=a=>new Promise((y,f)=>{if(a===i.length)return t.all&&r.length?y(r):f(zt(e));const h=i[a],u=/^".*"$/.test(h)?h.slice(1,-1):h,g=Vt.join(u,e),$=!u&&/^\.[\\\/]/.test(e)?e.slice(0,2)+g:g;y(d($,a,0))}),d=(a,y,f)=>new Promise((h,u)=>{if(f===n.length)return h(l(y+1));const g=n[f];kt(a+g,{pathExt:o},($,D)=>{if(!$&&D)if(t.all)r.push(a+g);else return h(a+g);return h(d(a,y,f+1))})});return s?l(0).then(a=>s(null,a),s):l(0)},qe=(e,t)=>{t=t||{};const{pathEnv:s,pathExt:i,pathExtExe:n}=Jt(e,t),o=[];for(let r=0;r<s.length;r++){const l=s[r],d=/^".*"$/.test(l)?l.slice(1,-1):l,a=Vt.join(d,e),y=!d&&/^\.[\\\/]/.test(e)?e.slice(0,2)+a:a;for(let f=0;f<i.length;f++){const h=y+i[f];try{if(kt.sync(h,{pathExt:n}))if(t.all)o.push(h);else return h}catch{}}}if(t.all&&o.length)return o;if(t.nothrow)return null;throw zt(e)};var Ke=Wt;Wt.sync=qe;var mt={exports:{}};const Ut=(e={})=>{const t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(i=>i.toUpperCase()==="PATH")||"Path"};mt.exports=Ut,mt.exports.default=Ut;var Ze=mt.exports;const Gt=ht,Xe=Ke,Qe=Ze;function qt(e,t){const s=e.options.env||process.env,i=process.cwd(),n=e.options.cwd!=null,o=n&&process.chdir!==void 0&&!process.chdir.disabled;if(o)try{process.chdir(e.options.cwd)}catch{}let r;try{r=Xe.sync(e.command,{path:s[Qe({env:s})],pathExt:t?Gt.delimiter:void 0})}catch{}finally{o&&process.chdir(i)}return r&&(r=Gt.resolve(n?e.options.cwd:"",r)),r}function ts(e){return qt(e)||qt(e,!0)}var es=ts,gt={};const vt=/([()\][%!^"`<>&|;, *?])/g;function ss(e){return e=e.replace(vt,"^$1"),e}function is(e,t){return e=`${e}`,e=e.replace(/(\\*)"/g,'$1$1\\"'),e=e.replace(/(\\*)$/,"$1$1"),e=`"${e}"`,e=e.replace(vt,"^$1"),t&&(e=e.replace(vt,"^$1")),e}gt.command=ss,gt.argument=is;var rs=/^#!(.*)/;const ns=rs;var os=(e="")=>{const t=e.match(ns);if(!t)return null;const[s,i]=t[0].replace(/#! ?/,"").split(" "),n=s.split("/").pop();return n==="env"?i:i?`${n} ${i}`:n};const bt=ct,ls=os;function as(e){const s=Buffer.alloc(150);let i;try{i=bt.openSync(e,"r"),bt.readSync(i,s,0,150,0),bt.closeSync(i)}catch{}return ls(s.toString())}var hs=as;const cs=ht,Kt=es,Zt=gt,us=hs,ds=process.platform==="win32",fs=/\.(?:com|exe)$/i,ps=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function ms(e){e.file=Kt(e);const t=e.file&&us(e.file);return t?(e.args.unshift(e.file),e.command=t,Kt(e)):e.file}function gs(e){if(!ds)return e;const t=ms(e),s=!fs.test(t);if(e.options.forceShell||s){const i=ps.test(t);e.command=cs.normalize(e.command),e.command=Zt.command(e.command),e.args=e.args.map(o=>Zt.argument(o,i));const n=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${n}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}function vs(e,t,s){t&&!Array.isArray(t)&&(s=t,t=null),t=t?t.slice(0):[],s=Object.assign({},s);const i={command:e,args:t,options:s,file:void 0,original:{command:e,args:t}};return s.shell?i:gs(i)}var bs=vs;const wt=process.platform==="win32";function yt(e,t){return Object.assign(new Error(`${t} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function ws(e,t){if(!wt)return;const s=e.emit;e.emit=function(i,n){if(i==="exit"){const o=Xt(n,t);if(o)return s.call(e,"error",o)}return s.apply(e,arguments)}}function Xt(e,t){return wt&&e===1&&!t.file?yt(t.original,"spawn"):null}function ys(e,t){return wt&&e===1&&!t.file?yt(t.original,"spawnSync"):null}var $s={hookChildProcess:ws,verifyENOENT:Xt,verifyENOENTSync:ys,notFoundError:yt};const Qt=Ye,$t=bs,xt=$s;function te(e,t,s){const i=$t(e,t,s),n=Qt.spawn(i.command,i.args,i.options);return xt.hookChildProcess(n,i),n}function xs(e,t,s){const i=$t(e,t,s),n=Qt.spawnSync(i.command,i.args,i.options);return n.error=n.error||xt.verifyENOENTSync(n.status,i),n}J.exports=te,J.exports.spawn=te,J.exports.sync=xs,J.exports._parse=$t,J.exports._enoent=xt;var Ss=J.exports;const Es=ut(Ss);function Os(e,t){var s=e;t.slice(0,-1).forEach(function(n){s=s[n]||{}});var i=t[t.length-1];return i in s}function ee(e){return typeof e=="number"||/^0x[0-9a-f]+$/i.test(e)?!0:/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(e)}function se(e,t){return t==="constructor"&&typeof e[t]=="function"||t==="__proto__"}var Cs=function(e,t){t||(t={});var s={bools:{},strings:{},unknownFn:null};typeof t.unknown=="function"&&(s.unknownFn=t.unknown),typeof t.boolean=="boolean"&&t.boolean?s.allBools=!0:[].concat(t.boolean).filter(Boolean).forEach(function(c){s.bools[c]=!0});var i={};function n(c){return i[c].some(function(p){return s.bools[p]})}Object.keys(t.alias||{}).forEach(function(c){i[c]=[].concat(t.alias[c]),i[c].forEach(function(p){i[p]=[c].concat(i[c].filter(function(S){return p!==S}))})}),[].concat(t.string).filter(Boolean).forEach(function(c){s.strings[c]=!0,i[c]&&[].concat(i[c]).forEach(function(p){s.strings[p]=!0})});var o=t.default||{},r={_:[]};function l(c,p){return s.allBools&&/^--[^=]+$/.test(p)||s.strings[c]||s.bools[c]||i[c]}function d(c,p,S){for(var m=c,V=0;V<p.length-1;V++){var T=p[V];if(se(m,T))return;m[T]===void 0&&(m[T]={}),(m[T]===Object.prototype||m[T]===Number.prototype||m[T]===String.prototype)&&(m[T]={}),m[T]===Array.prototype&&(m[T]=[]),m=m[T]}var R=p[p.length-1];se(m,R)||((m===Object.prototype||m===Number.prototype||m===String.prototype)&&(m={}),m===Array.prototype&&(m=[]),m[R]===void 0||s.bools[R]||typeof m[R]=="boolean"?m[R]=S:Array.isArray(m[R])?m[R].push(S):m[R]=[m[R],S])}function a(c,p,S){if(!(S&&s.unknownFn&&!l(c,S)&&s.unknownFn(S)===!1)){var m=!s.strings[c]&&ee(p)?Number(p):p;d(r,c.split("."),m),(i[c]||[]).forEach(function(V){d(r,V.split("."),m)})}}Object.keys(s.bools).forEach(function(c){a(c,o[c]===void 0?!1:o[c])});var y=[];e.indexOf("--")!==-1&&(y=e.slice(e.indexOf("--")+1),e=e.slice(0,e.indexOf("--")));for(var f=0;f<e.length;f++){var h=e[f],u,g;if(/^--.+=/.test(h)){var $=h.match(/^--([^=]+)=([\s\S]*)$/);u=$[1];var D=$[2];s.bools[u]&&(D=D!=="false"),a(u,D,h)}else if(/^--no-.+/.test(h))u=h.match(/^--no-(.+)/)[1],a(u,!1,h);else if(/^--.+/.test(h))u=h.match(/^--(.+)/)[1],g=e[f+1],g!==void 0&&!/^(-|--)[^-]/.test(g)&&!s.bools[u]&&!s.allBools&&(!i[u]||!n(u))?(a(u,g,h),f+=1):/^(true|false)$/.test(g)?(a(u,g==="true",h),f+=1):a(u,s.strings[u]?"":!0,h);else if(/^-[^-]+/.test(h)){for(var C=h.slice(1,-1).split(""),B=!1,x=0;x<C.length;x++){if(g=h.slice(x+2),g==="-"){a(C[x],g,h);continue}if(/[A-Za-z]/.test(C[x])&&g[0]==="="){a(C[x],g.slice(1),h),B=!0;break}if(/[A-Za-z]/.test(C[x])&&/-?\d+(\.\d*)?(e-?\d+)?$/.test(g)){a(C[x],g,h),B=!0;break}if(C[x+1]&&C[x+1].match(/\W/)){a(C[x],h.slice(x+2),h),B=!0;break}else a(C[x],s.strings[C[x]]?"":!0,h)}u=h.slice(-1)[0],!B&&u!=="-"&&(e[f+1]&&!/^(-|--)[^-]/.test(e[f+1])&&!s.bools[u]&&(!i[u]||!n(u))?(a(u,e[f+1],h),f+=1):e[f+1]&&/^(true|false)$/.test(e[f+1])?(a(u,e[f+1]==="true",h),f+=1):a(u,s.strings[u]?"":!0,h))}else if((!s.unknownFn||s.unknownFn(h)!==!1)&&r._.push(s.strings._||!ee(h)?h:Number(h)),t.stopEarly){r._.push.apply(r._,e.slice(f+1));break}}return Object.keys(o).forEach(function(c){Os(r,c.split("."))||(d(r,c.split("."),o[c]),(i[c]||[]).forEach(function(p){d(r,p.split("."),o[c])}))}),t["--"]?r["--"]=y.slice():y.forEach(function(c){r._.push(c)}),r};const Ts=ut(Cs);var ie={};const{FORCE_COLOR:Ps,NODE_DISABLE_COLORS:Ms,TERM:_s}=process.env,v={enabled:!Ms&&_s!=="dumb"&&Ps!=="0",reset:b(0,0),bold:b(1,22),dim:b(2,22),italic:b(3,23),underline:b(4,24),inverse:b(7,27),hidden:b(8,28),strikethrough:b(9,29),black:b(30,39),red:b(31,39),green:b(32,39),yellow:b(33,39),blue:b(34,39),magenta:b(35,39),cyan:b(36,39),white:b(37,39),gray:b(90,39),grey:b(90,39),bgBlack:b(40,49),bgRed:b(41,49),bgGreen:b(42,49),bgYellow:b(43,49),bgBlue:b(44,49),bgMagenta:b(45,49),bgCyan:b(46,49),bgWhite:b(47,49)};function re(e,t){let s=0,i,n="",o="";for(;s<e.length;s++)i=e[s],n+=i.open,o+=i.close,t.includes(i.close)&&(t=t.replace(i.rgx,i.close+i.open));return n+t+o}function Ds(e,t){let s={has:e,keys:t};return s.reset=v.reset.bind(s),s.bold=v.bold.bind(s),s.dim=v.dim.bind(s),s.italic=v.italic.bind(s),s.underline=v.underline.bind(s),s.inverse=v.inverse.bind(s),s.hidden=v.hidden.bind(s),s.strikethrough=v.strikethrough.bind(s),s.black=v.black.bind(s),s.red=v.red.bind(s),s.green=v.green.bind(s),s.yellow=v.yellow.bind(s),s.blue=v.blue.bind(s),s.magenta=v.magenta.bind(s),s.cyan=v.cyan.bind(s),s.white=v.white.bind(s),s.gray=v.gray.bind(s),s.grey=v.grey.bind(s),s.bgBlack=v.bgBlack.bind(s),s.bgRed=v.bgRed.bind(s),s.bgGreen=v.bgGreen.bind(s),s.bgYellow=v.bgYellow.bind(s),s.bgBlue=v.bgBlue.bind(s),s.bgMagenta=v.bgMagenta.bind(s),s.bgCyan=v.bgCyan.bind(s),s.bgWhite=v.bgWhite.bind(s),s}function b(e,t){let s={open:`\x1B[${e}m`,close:`\x1B[${t}m`,rgx:new RegExp(`\\x1b\\[${t}m`,"g")};return function(i){return this!==void 0&&this.has!==void 0?(this.has.includes(e)||(this.has.push(e),this.keys.push(s)),i===void 0?this:v.enabled?re(this.keys,i+""):i+""):i===void 0?Ds([e],[s]):v.enabled?re([s],i+""):i+""}}var M=v,Is=(e,t)=>{if(!(e.meta&&e.name!=="escape")){if(e.ctrl){if(e.name==="a")return"first";if(e.name==="c"||e.name==="d")return"abort";if(e.name==="e")return"last";if(e.name==="g")return"reset"}if(t){if(e.name==="j")return"down";if(e.name==="k")return"up"}return e.name==="return"||e.name==="enter"?"submit":e.name==="backspace"?"delete":e.name==="delete"?"deleteForward":e.name==="abort"?"abort":e.name==="escape"?"exit":e.name==="tab"?"next":e.name==="pagedown"?"nextPage":e.name==="pageup"?"prevPage":e.name==="home"?"home":e.name==="end"?"end":e.name==="up"?"up":e.name==="down"?"down":e.name==="right"?"right":e.name==="left"?"left":!1}},St=e=>{const t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"].join("|"),s=new RegExp(t,"g");return typeof e=="string"?e.replace(s,""):e};const Et="\x1B",w=`${Et}[`,As="\x07",Ot={to(e,t){return t?`${w}${t+1};${e+1}H`:`${w}${e+1}G`},move(e,t){let s="";return e<0?s+=`${w}${-e}D`:e>0&&(s+=`${w}${e}C`),t<0?s+=`${w}${-t}A`:t>0&&(s+=`${w}${t}B`),s},up:(e=1)=>`${w}${e}A`,down:(e=1)=>`${w}${e}B`,forward:(e=1)=>`${w}${e}C`,backward:(e=1)=>`${w}${e}D`,nextLine:(e=1)=>`${w}E`.repeat(e),prevLine:(e=1)=>`${w}F`.repeat(e),left:`${w}G`,hide:`${w}?25l`,show:`${w}?25h`,save:`${Et}7`,restore:`${Et}8`},Rs={up:(e=1)=>`${w}S`.repeat(e),down:(e=1)=>`${w}T`.repeat(e)},js={screen:`${w}2J`,up:(e=1)=>`${w}1J`.repeat(e),down:(e=1)=>`${w}J`.repeat(e),line:`${w}2K`,lineEnd:`${w}K`,lineStart:`${w}1K`,lines(e){let t="";for(let s=0;s<e;s++)t+=this.line+(s<e-1?Ot.up():"");return e&&(t+=Ot.left),t}};var _={cursor:Ot,scroll:Rs,erase:js,beep:As};const Ns=St,{erase:ne,cursor:Fs}=_,Ls=e=>[...Ns(e)].length;var Hs=function(e,t){if(!t)return ne.line+Fs.to(0);let s=0;const i=e.split(/\r?\n/);for(let n of i)s+=1+Math.floor(Math.max(Ls(n)-1,0)/t);return ne.lines(s)};const K={arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",radioOn:"\u25C9",radioOff:"\u25EF",tick:"\u2714",cross:"\u2716",ellipsis:"\u2026",pointerSmall:"\u203A",line:"\u2500",pointer:"\u276F"},Ys={arrowUp:K.arrowUp,arrowDown:K.arrowDown,arrowLeft:K.arrowLeft,arrowRight:K.arrowRight,radioOn:"(*)",radioOff:"( )",tick:"\u221A",cross:"\xD7",ellipsis:"...",pointerSmall:"\xBB",line:"\u2500",pointer:">"},Bs=process.platform==="win32"?Ys:K;var oe=Bs;const U=M,k=oe,Ct=Object.freeze({password:{scale:1,render:e=>"*".repeat(e.length)},emoji:{scale:2,render:e=>"\u{1F603}".repeat(e.length)},invisible:{scale:0,render:e=>""},default:{scale:1,render:e=>`${e}`}}),Vs=e=>Ct[e]||Ct.default,Z=Object.freeze({aborted:U.red(k.cross),done:U.green(k.tick),exited:U.yellow(k.cross),default:U.cyan("?")}),ks=(e,t,s)=>t?Z.aborted:s?Z.exited:e?Z.done:Z.default,zs=e=>U.gray(e?k.ellipsis:k.pointerSmall),Js=(e,t)=>U.gray(e?t?k.pointerSmall:"+":k.line);var Ws={styles:Ct,render:Vs,symbols:Z,symbol:ks,delimiter:zs,item:Js};const Us=St;var Gs=function(e,t){let s=String(Us(e)||"").split(/\r?\n/);return t?s.map(i=>Math.ceil(i.length/t)).reduce((i,n)=>i+n):s.length},qs=(e,t={})=>{const s=Number.isSafeInteger(parseInt(t.margin))?new Array(parseInt(t.margin)).fill(" ").join(""):t.margin||"",i=t.width;return(e||"").split(/\r?\n/g).map(n=>n.split(/\s+/g).reduce((o,r)=>(r.length+s.length>=i||o[o.length-1].length+r.length+1<i?o[o.length-1]+=` ${r}`:o.push(`${s}${r}`),o),[s]).join(`
`)).join(`
`)},Ks=(e,t,s)=>{s=s||t;let i=Math.min(t-s,e-Math.floor(s/2));i<0&&(i=0);let n=Math.min(i+s,t);return{startIndex:i,endIndex:n}},I={action:Is,clear:Hs,style:Ws,strip:St,figures:oe,lines:Gs,wrap:qs,entriesToDisplay:Ks};const le=Be,{action:Zs}=I,Xs=Ve,{beep:Qs,cursor:ti}=_,ei=M;let si=class extends Xs{constructor(t={}){super(),this.firstRender=!0,this.in=t.stdin||process.stdin,this.out=t.stdout||process.stdout,this.onRender=(t.onRender||(()=>{})).bind(this);const s=le.createInterface({input:this.in,escapeCodeTimeout:50});le.emitKeypressEvents(this.in,s),this.in.isTTY&&this.in.setRawMode(!0);const i=["SelectPrompt","MultiselectPrompt"].indexOf(this.constructor.name)>-1,n=(o,r)=>{let l=Zs(r,i);l===!1?this._&&this._(o,r):typeof this[l]=="function"?this[l](r):this.bell()};this.close=()=>{this.out.write(ti.show),this.in.removeListener("keypress",n),this.in.isTTY&&this.in.setRawMode(!1),s.close(),this.emit(this.aborted?"abort":this.exited?"exit":"submit",this.value),this.closed=!0},this.in.on("keypress",n)}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted,exited:!!this.exited})}bell(){this.out.write(Qs)}render(){this.onRender(ei),this.firstRender&&(this.firstRender=!1)}};var L=si;const it=M,ii=L,{erase:ri,cursor:X}=_,{style:Tt,clear:Pt,lines:ni,figures:oi}=I;class li extends ii{constructor(t={}){super(t),this.transform=Tt.render(t.style),this.scale=this.transform.scale,this.msg=t.message,this.initial=t.initial||"",this.validator=t.validate||(()=>!0),this.value="",this.errorMsg=t.error||"Please Enter A Valid Value",this.cursor=+!!this.initial,this.cursorOffset=0,this.clear=Pt("",this.out.columns),this.render()}set value(t){!t&&this.initial?(this.placeholder=!0,this.rendered=it.gray(this.transform.render(this.initial))):(this.placeholder=!1,this.rendered=this.transform.render(t)),this._value=t,this.fire()}get value(){return this._value}reset(){this.value="",this.cursor=+!!this.initial,this.cursorOffset=0,this.fire(),this.render()}exit(){this.abort()}abort(){this.value=this.value||this.initial,this.done=this.aborted=!0,this.error=!1,this.red=!1,this.fire(),this.render(),this.out.write(`
`),this.close()}async validate(){let t=await this.validator(this.value);typeof t=="string"&&(this.errorMsg=t,t=!1),this.error=!t}async submit(){if(this.value=this.value||this.initial,this.cursorOffset=0,this.cursor=this.rendered.length,await this.validate(),this.error){this.red=!0,this.fire(),this.render();return}this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
`),this.close()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor(t){this.placeholder||(this.cursor=this.cursor+t,this.cursorOffset+=t)}_(t,s){let i=this.value.slice(0,this.cursor),n=this.value.slice(this.cursor);this.value=`${i}${t}${n}`,this.red=!1,this.cursor=this.placeholder?0:i.length+1,this.render()}delete(){if(this.isCursorAtStart())return this.bell();let t=this.value.slice(0,this.cursor-1),s=this.value.slice(this.cursor);this.value=`${t}${s}`,this.red=!1,this.isCursorAtStart()?this.cursorOffset=0:(this.cursorOffset++,this.moveCursor(-1)),this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();let t=this.value.slice(0,this.cursor),s=this.value.slice(this.cursor+1);this.value=`${t}${s}`,this.red=!1,this.isCursorAtEnd()?this.cursorOffset=0:this.cursorOffset++,this.render()}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length,this.render()}left(){if(this.cursor<=0||this.placeholder)return this.bell();this.moveCursor(-1),this.render()}right(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();this.moveCursor(1),this.render()}isCursorAtStart(){return this.cursor===0||this.placeholder&&this.cursor===1}isCursorAtEnd(){return this.cursor===this.rendered.length||this.placeholder&&this.cursor===this.rendered.length+1}render(){this.closed||(this.firstRender||(this.outputError&&this.out.write(X.down(ni(this.outputError,this.out.columns)-1)+Pt(this.outputError,this.out.columns)),this.out.write(Pt(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[Tt.symbol(this.done,this.aborted),it.bold(this.msg),Tt.delimiter(this.done),this.red?it.red(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
`).reduce((t,s,i)=>t+`
${i?" ":oi.pointerSmall} ${it.red().italic(s)}`,"")),this.out.write(ri.line+X.to(0)+this.outputText+X.save+this.outputError+X.restore+X.move(this.cursorOffset,0)))}}var ai=li;const j=M,hi=L,{style:ae,clear:he,figures:rt,wrap:ci,entriesToDisplay:ui}=I,{cursor:di}=_;class fi extends hi{constructor(t={}){super(t),this.msg=t.message,this.hint=t.hint||"- Use arrow-keys. Return to submit.",this.warn=t.warn||"- This option is disabled",this.cursor=t.initial||0,this.choices=t.choices.map((s,i)=>(typeof s=="string"&&(s={title:s,value:i}),{title:s&&(s.title||s.value||s),value:s&&(s.value===void 0?i:s.value),description:s&&s.description,selected:s&&s.selected,disabled:s&&s.disabled})),this.optionsPerPage=t.optionsPerPage||10,this.value=(this.choices[this.cursor]||{}).value,this.clear=he("",this.out.columns),this.render()}moveCursor(t){this.cursor=t,this.value=this.choices[t].value,this.fire()}reset(){this.moveCursor(0),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
`),this.close()}submit(){this.selection.disabled?this.bell():(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
`),this.close())}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.choices.length-1),this.render()}up(){this.cursor===0?this.moveCursor(this.choices.length-1):this.moveCursor(this.cursor-1),this.render()}down(){this.cursor===this.choices.length-1?this.moveCursor(0):this.moveCursor(this.cursor+1),this.render()}next(){this.moveCursor((this.cursor+1)%this.choices.length),this.render()}_(t,s){if(t===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;this.firstRender?this.out.write(di.hide):this.out.write(he(this.outputText,this.out.columns)),super.render();let{startIndex:t,endIndex:s}=ui(this.cursor,this.choices.length,this.optionsPerPage);if(this.outputText=[ae.symbol(this.done,this.aborted),j.bold(this.msg),ae.delimiter(!1),this.done?this.selection.title:this.selection.disabled?j.yellow(this.warn):j.gray(this.hint)].join(" "),!this.done){this.outputText+=`
`;for(let i=t;i<s;i++){let n,o,r="",l=this.choices[i];i===t&&t>0?o=rt.arrowUp:i===s-1&&s<this.choices.length?o=rt.arrowDown:o=" ",l.disabled?(n=this.cursor===i?j.gray().underline(l.title):j.strikethrough().gray(l.title),o=(this.cursor===i?j.bold().gray(rt.pointer)+" ":" ")+o):(n=this.cursor===i?j.cyan().underline(l.title):l.title,o=(this.cursor===i?j.cyan(rt.pointer)+" ":" ")+o,l.description&&this.cursor===i&&(r=` - ${l.description}`,(o.length+n.length+r.length>=this.out.columns||l.description.split(/\r?\n/).length>1)&&(r=`
`+ci(l.description,{margin:3,width:this.out.columns})))),this.outputText+=`${o} ${n}${j.gray(r)}
`}}this.out.write(this.outputText)}}var pi=fi;const nt=M,mi=L,{style:ce,clear:gi}=I,{cursor:ue,erase:vi}=_;class bi extends mi{constructor(t={}){super(t),this.msg=t.message,this.value=!!t.initial,this.active=t.active||"on",this.inactive=t.inactive||"off",this.initialValue=this.value,this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
`),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
`),this.close()}deactivate(){if(this.value===!1)return this.bell();this.value=!1,this.render()}activate(){if(this.value===!0)return this.bell();this.value=!0,this.render()}delete(){this.deactivate()}left(){this.deactivate()}right(){this.activate()}down(){this.deactivate()}up(){this.activate()}next(){this.value=!this.value,this.fire(),this.render()}_(t,s){if(t===" ")this.value=!this.value;else if(t==="1")this.value=!0;else if(t==="0")this.value=!1;else return this.bell();this.render()}render(){this.closed||(this.firstRender?this.out.write(ue.hide):this.out.write(gi(this.outputText,this.out.columns)),super.render(),this.outputText=[ce.symbol(this.done,this.aborted),nt.bold(this.msg),ce.delimiter(this.done),this.value?this.inactive:nt.cyan().underline(this.inactive),nt.gray("/"),this.value?nt.cyan().underline(this.active):this.active].join(" "),this.out.write(vi.line+ue.to(0)+this.outputText))}}var wi=bi;let yi=class Ht{constructor({token:t,date:s,parts:i,locales:n}){this.token=t,this.date=s||new Date,this.parts=i||[this],this.locales=n||{}}up(){}down(){}next(){const t=this.parts.indexOf(this);return this.parts.find((s,i)=>i>t&&s instanceof Ht)}setTo(t){}prev(){let t=[].concat(this.parts).reverse();const s=t.indexOf(this);return t.find((i,n)=>n>s&&i instanceof Ht)}toString(){return String(this.date)}};var N=yi;const $i=N;let xi=class extends $i{constructor(t={}){super(t)}up(){this.date.setHours((this.date.getHours()+12)%24)}down(){this.up()}toString(){let t=this.date.getHours()>12?"pm":"am";return/\A/.test(this.token)?t.toUpperCase():t}};var Si=xi;const Ei=N,Oi=e=>(e=e%10,e===1?"st":e===2?"nd":e===3?"rd":"th");let Ci=class extends Ei{constructor(t={}){super(t)}up(){this.date.setDate(this.date.getDate()+1)}down(){this.date.setDate(this.date.getDate()-1)}setTo(t){this.date.setDate(parseInt(t.substr(-2)))}toString(){let t=this.date.getDate(),s=this.date.getDay();return this.token==="DD"?String(t).padStart(2,"0"):this.token==="Do"?t+Oi(t):this.token==="d"?s+1:this.token==="ddd"?this.locales.weekdaysShort[s]:this.token==="dddd"?this.locales.weekdays[s]:t}};var Ti=Ci;const Pi=N;let Mi=class extends Pi{constructor(t={}){super(t)}up(){this.date.setHours(this.date.getHours()+1)}down(){this.date.setHours(this.date.getHours()-1)}setTo(t){this.date.setHours(parseInt(t.substr(-2)))}toString(){let t=this.date.getHours();return/h/.test(this.token)&&(t=t%12||12),this.token.length>1?String(t).padStart(2,"0"):t}};var _i=Mi;const Di=N;let Ii=class extends Di{constructor(t={}){super(t)}up(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}down(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setTo(t){this.date.setMilliseconds(parseInt(t.substr(-this.token.length)))}toString(){return String(this.date.getMilliseconds()).padStart(4,"0").substr(0,this.token.length)}};var Ai=Ii;const Ri=N;let ji=class extends Ri{constructor(t={}){super(t)}up(){this.date.setMinutes(this.date.getMinutes()+1)}down(){this.date.setMinutes(this.date.getMinutes()-1)}setTo(t){this.date.setMinutes(parseInt(t.substr(-2)))}toString(){let t=this.date.getMinutes();return this.token.length>1?String(t).padStart(2,"0"):t}};var Ni=ji;const Fi=N;let Li=class extends Fi{constructor(t={}){super(t)}up(){this.date.setMonth(this.date.getMonth()+1)}down(){this.date.setMonth(this.date.getMonth()-1)}setTo(t){t=parseInt(t.substr(-2))-1,this.date.setMonth(t<0?0:t)}toString(){let t=this.date.getMonth(),s=this.token.length;return s===2?String(t+1).padStart(2,"0"):s===3?this.locales.monthsShort[t]:s===4?this.locales.months[t]:String(t+1)}};var Hi=Li;const Yi=N;let Bi=class extends Yi{constructor(t={}){super(t)}up(){this.date.setSeconds(this.date.getSeconds()+1)}down(){this.date.setSeconds(this.date.getSeconds()-1)}setTo(t){this.date.setSeconds(parseInt(t.substr(-2)))}toString(){let t=this.date.getSeconds();return this.token.length>1?String(t).padStart(2,"0"):t}};var Vi=Bi;const ki=N;let zi=class extends ki{constructor(t={}){super(t)}up(){this.date.setFullYear(this.date.getFullYear()+1)}down(){this.date.setFullYear(this.date.getFullYear()-1)}setTo(t){this.date.setFullYear(t.substr(-4))}toString(){let t=String(this.date.getFullYear()).padStart(4,"0");return this.token.length===2?t.substr(-2):t}};var Ji=zi,Wi={DatePart:N,Meridiem:Si,Day:Ti,Hours:_i,Milliseconds:Ai,Minutes:Ni,Month:Hi,Seconds:Vi,Year:Ji};const Mt=M,Ui=L,{style:de,clear:fe,figures:Gi}=I,{erase:qi,cursor:pe}=_,{DatePart:me,Meridiem:Ki,Day:Zi,Hours:Xi,Milliseconds:Qi,Minutes:tr,Month:er,Seconds:sr,Year:ir}=Wi,rr=/\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g,ge={1:({token:e})=>e.replace(/\\(.)/g,"$1"),2:e=>new Zi(e),3:e=>new er(e),4:e=>new ir(e),5:e=>new Ki(e),6:e=>new Xi(e),7:e=>new tr(e),8:e=>new sr(e),9:e=>new Qi(e)},nr={months:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),monthsShort:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),weekdays:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),weekdaysShort:"Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(",")};class or extends Ui{constructor(t={}){super(t),this.msg=t.message,this.cursor=0,this.typed="",this.locales=Object.assign(nr,t.locales),this._date=t.initial||new Date,this.errorMsg=t.error||"Please Enter A Valid Value",this.validator=t.validate||(()=>!0),this.mask=t.mask||"YYYY-MM-DD HH:mm:ss",this.clear=fe("",this.out.columns),this.render()}get value(){return this.date}get date(){return this._date}set date(t){t&&this._date.setTime(t.getTime())}set mask(t){let s;for(this.parts=[];s=rr.exec(t);){let n=s.shift(),o=s.findIndex(r=>r!=null);this.parts.push(o in ge?ge[o]({token:s[o]||n,date:this.date,parts:this.parts,locales:this.locales}):s[o]||n)}let i=this.parts.reduce((n,o)=>(typeof o=="string"&&typeof n[n.length-1]=="string"?n[n.length-1]+=o:n.push(o),n),[]);this.parts.splice(0),this.parts.push(...i),this.reset()}moveCursor(t){this.typed="",this.cursor=t,this.fire()}reset(){this.moveCursor(this.parts.findIndex(t=>t instanceof me)),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
`),this.close()}async validate(){let t=await this.validator(this.value);typeof t=="string"&&(this.errorMsg=t,t=!1),this.error=!t}async submit(){if(await this.validate(),this.error){this.color="red",this.fire(),this.render();return}this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
`),this.close()}up(){this.typed="",this.parts[this.cursor].up(),this.render()}down(){this.typed="",this.parts[this.cursor].down(),this.render()}left(){let t=this.parts[this.cursor].prev();if(t==null)return this.bell();this.moveCursor(this.parts.indexOf(t)),this.render()}right(){let t=this.parts[this.cursor].next();if(t==null)return this.bell();this.moveCursor(this.parts.indexOf(t)),this.render()}next(){let t=this.parts[this.cursor].next();this.moveCursor(t?this.parts.indexOf(t):this.parts.findIndex(s=>s instanceof me)),this.render()}_(t){/\d/.test(t)&&(this.typed+=t,this.parts[this.cursor].setTo(this.typed),this.render())}render(){this.closed||(this.firstRender?this.out.write(pe.hide):this.out.write(fe(this.outputText,this.out.columns)),super.render(),this.outputText=[de.symbol(this.done,this.aborted),Mt.bold(this.msg),de.delimiter(!1),this.parts.reduce((t,s,i)=>t.concat(i===this.cursor&&!this.done?Mt.cyan().underline(s.toString()):s),[]).join("")].join(" "),this.error&&(this.outputText+=this.errorMsg.split(`
`).reduce((t,s,i)=>t+`
${i?" ":Gi.pointerSmall} ${Mt.red().italic(s)}`,"")),this.out.write(qi.line+pe.to(0)+this.outputText))}}var lr=or;const ot=M,ar=L,{cursor:lt,erase:hr}=_,{style:_t,figures:cr,clear:ve,lines:ur}=I,dr=/[0-9]/,Dt=e=>e!==void 0,be=(e,t)=>{let s=Math.pow(10,t);return Math.round(e*s)/s};class fr extends ar{constructor(t={}){super(t),this.transform=_t.render(t.style),this.msg=t.message,this.initial=Dt(t.initial)?t.initial:"",this.float=!!t.float,this.round=t.round||2,this.inc=t.increment||1,this.min=Dt(t.min)?t.min:-1/0,this.max=Dt(t.max)?t.max:1/0,this.errorMsg=t.error||"Please Enter A Valid Value",this.validator=t.validate||(()=>!0),this.color="cyan",this.value="",this.typed="",this.lastHit=0,this.render()}set value(t){!t&&t!==0?(this.placeholder=!0,this.rendered=ot.gray(this.transform.render(`${this.initial}`)),this._value=""):(this.placeholder=!1,this.rendered=this.transform.render(`${be(t,this.round)}`),this._value=be(t,this.round)),this.fire()}get value(){return this._value}parse(t){return this.float?parseFloat(t):parseInt(t)}valid(t){return t==="-"||t==="."&&this.float||dr.test(t)}reset(){this.typed="",this.value="",this.fire(),this.render()}exit(){this.abort()}abort(){let t=this.value;this.value=t!==""?t:this.initial,this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
`),this.close()}async validate(){let t=await this.validator(this.value);typeof t=="string"&&(this.errorMsg=t,t=!1),this.error=!t}async submit(){if(await this.validate(),this.error){this.color="red",this.fire(),this.render();return}let t=this.value;this.value=t!==""?t:this.initial,this.done=!0,this.aborted=!1,this.error=!1,this.fire(),this.render(),this.out.write(`
`),this.close()}up(){if(this.typed="",this.value===""&&(this.value=this.min-this.inc),this.value>=this.max)return this.bell();this.value+=this.inc,this.color="cyan",this.fire(),this.render()}down(){if(this.typed="",this.value===""&&(this.value=this.min+this.inc),this.value<=this.min)return this.bell();this.value-=this.inc,this.color="cyan",this.fire(),this.render()}delete(){let t=this.value.toString();if(t.length===0)return this.bell();this.value=this.parse(t=t.slice(0,-1))||"",this.value!==""&&this.value<this.min&&(this.value=this.min),this.color="cyan",this.fire(),this.render()}next(){this.value=this.initial,this.fire(),this.render()}_(t,s){if(!this.valid(t))return this.bell();const i=Date.now();if(i-this.lastHit>1e3&&(this.typed=""),this.typed+=t,this.lastHit=i,this.color="cyan",t===".")return this.fire();this.value=Math.min(this.parse(this.typed),this.max),this.value>this.max&&(this.value=this.max),this.value<this.min&&(this.value=this.min),this.fire(),this.render()}render(){this.closed||(this.firstRender||(this.outputError&&this.out.write(lt.down(ur(this.outputError,this.out.columns)-1)+ve(this.outputError,this.out.columns)),this.out.write(ve(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[_t.symbol(this.done,this.aborted),ot.bold(this.msg),_t.delimiter(this.done),!this.done||!this.done&&!this.placeholder?ot[this.color]().underline(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
`).reduce((t,s,i)=>t+`
${i?" ":cr.pointerSmall} ${ot.red().italic(s)}`,"")),this.out.write(hr.line+lt.to(0)+this.outputText+lt.save+this.outputError+lt.restore))}}var pr=fr;const A=M,{cursor:mr}=_,gr=L,{clear:we,figures:H,style:ye,wrap:vr,entriesToDisplay:br}=I;let wr=class extends gr{constructor(t={}){super(t),this.msg=t.message,this.cursor=t.cursor||0,this.scrollIndex=t.cursor||0,this.hint=t.hint||"",this.warn=t.warn||"- This option is disabled -",this.minSelected=t.min,this.showMinError=!1,this.maxChoices=t.max,this.instructions=t.instructions,this.optionsPerPage=t.optionsPerPage||10,this.value=t.choices.map((s,i)=>(typeof s=="string"&&(s={title:s,value:i}),{title:s&&(s.title||s.value||s),description:s&&s.description,value:s&&(s.value===void 0?i:s.value),selected:s&&s.selected,disabled:s&&s.disabled})),this.clear=we("",this.out.columns),t.overrideRender||this.render()}reset(){this.value.map(t=>!t.selected),this.cursor=0,this.fire(),this.render()}selected(){return this.value.filter(t=>t.selected)}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
`),this.close()}submit(){const t=this.value.filter(s=>s.selected);this.minSelected&&t.length<this.minSelected?(this.showMinError=!0,this.render()):(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
`),this.close())}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.value.length,this.render()}up(){this.cursor===0?this.cursor=this.value.length-1:this.cursor--,this.render()}down(){this.cursor===this.value.length-1?this.cursor=0:this.cursor++,this.render()}left(){this.value[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(t=>t.selected).length>=this.maxChoices)return this.bell();this.value[this.cursor].selected=!0,this.render()}handleSpaceToggle(){const t=this.value[this.cursor];if(t.selected)t.selected=!1,this.render();else{if(t.disabled||this.value.filter(s=>s.selected).length>=this.maxChoices)return this.bell();t.selected=!0,this.render()}}toggleAll(){if(this.maxChoices!==void 0||this.value[this.cursor].disabled)return this.bell();const t=!this.value[this.cursor].selected;this.value.filter(s=>!s.disabled).forEach(s=>s.selected=t),this.render()}_(t,s){if(t===" ")this.handleSpaceToggle();else if(t==="a")this.toggleAll();else return this.bell()}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
Instructions:
${H.arrowUp}/${H.arrowDown}: Highlight option
${H.arrowLeft}/${H.arrowRight}/[space]: Toggle selection
`+(this.maxChoices===void 0?` a: Toggle all
`:"")+" enter/return: Complete answer":""}renderOption(t,s,i,n){const o=(s.selected?A.green(H.radioOn):H.radioOff)+" "+n+" ";let r,l;return s.disabled?r=t===i?A.gray().underline(s.title):A.strikethrough().gray(s.title):(r=t===i?A.cyan().underline(s.title):s.title,t===i&&s.description&&(l=` - ${s.description}`,(o.length+r.length+l.length>=this.out.columns||s.description.split(/\r?\n/).length>1)&&(l=`
`+vr(s.description,{margin:o.length,width:this.out.columns})))),o+r+A.gray(l||"")}paginateOptions(t){if(t.length===0)return A.red("No matches for this query.");let{startIndex:s,endIndex:i}=br(this.cursor,t.length,this.optionsPerPage),n,o=[];for(let r=s;r<i;r++)r===s&&s>0?n=H.arrowUp:r===i-1&&i<t.length?n=H.arrowDown:n=" ",o.push(this.renderOption(this.cursor,t[r],r,n));return`
`+o.join(`
`)}renderOptions(t){return this.done?"":this.paginateOptions(t)}renderDoneOrInstructions(){if(this.done)return this.value.filter(s=>s.selected).map(s=>s.title).join(", ");const t=[A.gray(this.hint),this.renderInstructions()];return this.value[this.cursor].disabled&&t.push(A.yellow(this.warn)),t.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(mr.hide),super.render();let t=[ye.symbol(this.done,this.aborted),A.bold(this.msg),ye.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(t+=A.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),t+=this.renderOptions(this.value),this.out.write(this.clear+t),this.clear=we(t,this.out.columns)}};var $e=wr;const Q=M,yr=L,{erase:$r,cursor:xe}=_,{style:It,clear:Se,figures:At,wrap:xr,entriesToDisplay:Sr}=I,Ee=(e,t)=>e[t]&&(e[t].value||e[t].title||e[t]),Er=(e,t)=>e[t]&&(e[t].title||e[t].value||e[t]),Or=(e,t)=>{const s=e.findIndex(i=>i.value===t||i.title===t);return s>-1?s:void 0};class Cr extends yr{constructor(t={}){super(t),this.msg=t.message,this.suggest=t.suggest,this.choices=t.choices,this.initial=typeof t.initial=="number"?t.initial:Or(t.choices,t.initial),this.select=this.initial||t.cursor||0,this.i18n={noMatches:t.noMatches||"no matches found"},this.fallback=t.fallback||this.initial,this.clearFirst=t.clearFirst||!1,this.suggestions=[],this.input="",this.limit=t.limit||10,this.cursor=0,this.transform=It.render(t.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=Se("",this.out.columns),this.complete(this.render),this.render()}set fallback(t){this._fb=Number.isSafeInteger(parseInt(t))?parseInt(t):t}get fallback(){let t;return typeof this._fb=="number"?t=this.choices[this._fb]:typeof this._fb=="string"&&(t={title:this._fb}),t||this._fb||{title:this.i18n.noMatches}}moveSelect(t){this.select=t,this.suggestions.length>0?this.value=Ee(this.suggestions,t):this.value=this.fallback.value,this.fire()}async complete(t){const s=this.completing=this.suggest(this.input,this.choices),i=await s;if(this.completing!==s)return;this.suggestions=i.map((o,r,l)=>({title:Er(l,r),value:Ee(l,r),description:o.description})),this.completing=!1;const n=Math.max(i.length-1,0);this.moveSelect(Math.min(n,this.select)),t&&t()}reset(){this.input="",this.complete(()=>{this.moveSelect(this.initial!==void 0?this.initial:0),this.render()}),this.render()}exit(){this.clearFirst&&this.input.length>0?this.reset():(this.done=this.exited=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
`),this.close())}abort(){this.done=this.aborted=!0,this.exited=!1,this.fire(),this.render(),this.out.write(`
`),this.close()}submit(){this.done=!0,this.aborted=this.exited=!1,this.fire(),this.render(),this.out.write(`
`),this.close()}_(t,s){let i=this.input.slice(0,this.cursor),n=this.input.slice(this.cursor);this.input=`${i}${t}${n}`,this.cursor=i.length+1,this.complete(this.render),this.render()}delete(){if(this.cursor===0)return this.bell();let t=this.input.slice(0,this.cursor-1),s=this.input.slice(this.cursor);this.input=`${t}${s}`,this.complete(this.render),this.cursor=this.cursor-1,this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();let t=this.input.slice(0,this.cursor),s=this.input.slice(this.cursor+1);this.input=`${t}${s}`,this.complete(this.render),this.render()}first(){this.moveSelect(0),this.render()}last(){this.moveSelect(this.suggestions.length-1),this.render()}up(){this.select===0?this.moveSelect(this.suggestions.length-1):this.moveSelect(this.select-1),this.render()}down(){this.select===this.suggestions.length-1?this.moveSelect(0):this.moveSelect(this.select+1),this.render()}next(){this.select===this.suggestions.length-1?this.moveSelect(0):this.moveSelect(this.select+1),this.render()}nextPage(){this.moveSelect(Math.min(this.select+this.limit,this.suggestions.length-1)),this.render()}prevPage(){this.moveSelect(Math.max(this.select-this.limit,0)),this.render()}left(){if(this.cursor<=0)return this.bell();this.cursor=this.cursor-1,this.render()}right(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();this.cursor=this.cursor+1,this.render()}renderOption(t,s,i,n){let o,r=i?At.arrowUp:n?At.arrowDown:" ",l=s?Q.cyan().underline(t.title):t.title;return r=(s?Q.cyan(At.pointer)+" ":" ")+r,t.description&&(o=` - ${t.description}`,(r.length+l.length+o.length>=this.out.columns||t.description.split(/\r?\n/).length>1)&&(o=`
`+xr(t.description,{margin:3,width:this.out.columns}))),r+" "+l+Q.gray(o||"")}render(){if(this.closed)return;this.firstRender?this.out.write(xe.hide):this.out.write(Se(this.outputText,this.out.columns)),super.render();let{startIndex:t,endIndex:s}=Sr(this.select,this.choices.length,this.limit);if(this.outputText=[It.symbol(this.done,this.aborted,this.exited),Q.bold(this.msg),It.delimiter(this.completing),this.done&&this.suggestions[this.select]?this.suggestions[this.select].title:this.rendered=this.transform.render(this.input)].join(" "),!this.done){const i=this.suggestions.slice(t,s).map((n,o)=>this.renderOption(n,this.select===o+t,o===0&&t>0,o+t===s-1&&s<this.choices.length)).join(`
`);this.outputText+=`
`+(i||Q.gray(this.fallback.title))}this.out.write($r.line+xe.to(0)+this.outputText)}}var Tr=Cr;const F=M,{cursor:Pr}=_,Mr=$e,{clear:Oe,style:Ce,figures:G}=I;class _r extends Mr{constructor(t={}){t.overrideRender=!0,super(t),this.inputValue="",this.clear=Oe("",this.out.columns),this.filteredOptions=this.value,this.render()}last(){this.cursor=this.filteredOptions.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.filteredOptions.length,this.render()}up(){this.cursor===0?this.cursor=this.filteredOptions.length-1:this.cursor--,this.render()}down(){this.cursor===this.filteredOptions.length-1?this.cursor=0:this.cursor++,this.render()}left(){this.filteredOptions[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(t=>t.selected).length>=this.maxChoices)return this.bell();this.filteredOptions[this.cursor].selected=!0,this.render()}delete(){this.inputValue.length&&(this.inputValue=this.inputValue.substr(0,this.inputValue.length-1),this.updateFilteredOptions())}updateFilteredOptions(){const t=this.filteredOptions[this.cursor];this.filteredOptions=this.value.filter(i=>this.inputValue?!!(typeof i.title=="string"&&i.title.toLowerCase().includes(this.inputValue.toLowerCase())||typeof i.value=="string"&&i.value.toLowerCase().includes(this.inputValue.toLowerCase())):!0);const s=this.filteredOptions.findIndex(i=>i===t);this.cursor=s<0?0:s,this.render()}handleSpaceToggle(){const t=this.filteredOptions[this.cursor];if(t.selected)t.selected=!1,this.render();else{if(t.disabled||this.value.filter(s=>s.selected).length>=this.maxChoices)return this.bell();t.selected=!0,this.render()}}handleInputChange(t){this.inputValue=this.inputValue+t,this.updateFilteredOptions()}_(t,s){t===" "?this.handleSpaceToggle():this.handleInputChange(t)}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
Instructions:
${G.arrowUp}/${G.arrowDown}: Highlight option
${G.arrowLeft}/${G.arrowRight}/[space]: Toggle selection
[a,b,c]/delete: Filter choices
enter/return: Complete answer
`:""}renderCurrentInput(){return`
Filtered results for: ${this.inputValue?this.inputValue:F.gray("Enter something to filter")}
`}renderOption(t,s,i){let n;return s.disabled?n=t===i?F.gray().underline(s.title):F.strikethrough().gray(s.title):n=t===i?F.cyan().underline(s.title):s.title,(s.selected?F.green(G.radioOn):G.radioOff)+" "+n}renderDoneOrInstructions(){if(this.done)return this.value.filter(s=>s.selected).map(s=>s.title).join(", ");const t=[F.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];return this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled&&t.push(F.yellow(this.warn)),t.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(Pr.hide),super.render();let t=[Ce.symbol(this.done,this.aborted),F.bold(this.msg),Ce.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(t+=F.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),t+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+t),this.clear=Oe(t,this.out.columns)}}var Dr=_r;const Te=M,Ir=L,{style:Pe,clear:Ar}=I,{erase:Rr,cursor:Me}=_;class jr extends Ir{constructor(t={}){super(t),this.msg=t.message,this.value=t.initial,this.initialValue=!!t.initial,this.yesMsg=t.yes||"yes",this.yesOption=t.yesOption||"(Y/n)",this.noMsg=t.no||"no",this.noOption=t.noOption||"(y/N)",this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
`),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
`),this.close()}_(t,s){return t.toLowerCase()==="y"?(this.value=!0,this.submit()):t.toLowerCase()==="n"?(this.value=!1,this.submit()):this.bell()}render(){this.closed||(this.firstRender?this.out.write(Me.hide):this.out.write(Ar(this.outputText,this.out.columns)),super.render(),this.outputText=[Pe.symbol(this.done,this.aborted),Te.bold(this.msg),Pe.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:Te.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(Rr.line+Me.to(0)+this.outputText))}}var Nr=jr,Fr={TextPrompt:ai,SelectPrompt:pi,TogglePrompt:wi,DatePrompt:lr,NumberPrompt:pr,MultiselectPrompt:$e,AutocompletePrompt:Tr,AutocompleteMultiselectPrompt:Dr,ConfirmPrompt:Nr};(function(e){const t=e,s=Fr,i=r=>r;function n(r,l,d={}){return new Promise((a,y)=>{const f=new s[r](l),h=d.onAbort||i,u=d.onSubmit||i,g=d.onExit||i;f.on("state",l.onState||i),f.on("submit",$=>a(u($))),f.on("exit",$=>a(g($))),f.on("abort",$=>y(h($)))})}t.text=r=>n("TextPrompt",r),t.password=r=>(r.style="password",t.text(r)),t.invisible=r=>(r.style="invisible",t.text(r)),t.number=r=>n("NumberPrompt",r),t.date=r=>n("DatePrompt",r),t.confirm=r=>n("ConfirmPrompt",r),t.list=r=>{const l=r.separator||",";return n("TextPrompt",r,{onSubmit:d=>d.split(l).map(a=>a.trim())})},t.toggle=r=>n("TogglePrompt",r),t.select=r=>n("SelectPrompt",r),t.multiselect=r=>{r.choices=[].concat(r.choices||[]);const l=d=>d.filter(a=>a.selected).map(a=>a.value);return n("MultiselectPrompt",r,{onAbort:l,onSubmit:l})},t.autocompleteMultiselect=r=>{r.choices=[].concat(r.choices||[]);const l=d=>d.filter(a=>a.selected).map(a=>a.value);return n("AutocompleteMultiselectPrompt",r,{onAbort:l,onSubmit:l})};const o=(r,l)=>Promise.resolve(l.filter(d=>d.title.slice(0,r.length).toLowerCase()===r.toLowerCase()));t.autocomplete=r=>(r.suggest=r.suggest||o,r.choices=[].concat(r.choices||[]),n("AutocompletePrompt",r))})(ie);const Rt=ie,Lr=["suggest","format","onState","validate","onRender","type"],_e=()=>{};async function Y(e=[],{onSubmit:t=_e,onCancel:s=_e}={}){const i={},n=Y._override||{};e=[].concat(e);let o,r,l,d,a,y;const f=async(h,u,g=!1)=>{if(!(!g&&h.validate&&h.validate(u)!==!0))return h.format?await h.format(u,i):u};for(r of e)if({name:d,type:a}=r,typeof a=="function"&&(a=await a(o,{...i},r),r.type=a),!!a){for(let h in r){if(Lr.includes(h))continue;let u=r[h];r[h]=typeof u=="function"?await u(o,{...i},y):u}if(y=r,typeof r.message!="string")throw new Error("prompt message is required");if({name:d,type:a}=r,Rt[a]===void 0)throw new Error(`prompt type (${a}) is not defined`);if(n[r.name]!==void 0&&(o=await f(r,n[r.name]),o!==void 0)){i[d]=o;continue}try{o=Y._injected?Hr(Y._injected,r.initial):await Rt[a](r),i[d]=o=await f(r,o,!0),l=await t(r,o,i)}catch{l=!await s(r,i)}if(l)return i}return i}function Hr(e,t){const s=e.shift();if(s instanceof Error)throw s;return s===void 0?t:s}function Yr(e){Y._injected=(Y._injected||[]).concat(e)}function Br(e){Y._override=Object.assign({},e)}var Vr=Object.assign(Y,{prompt:Y,prompts:Rt,inject:Yr,override:Br});const kr=ut(Vr);let z=!0;const q=typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};let tt=0;if(q.process&&q.process.env&&q.process.stdout){const{FORCE_COLOR:e,NODE_DISABLE_COLORS:t,NO_COLOR:s,TERM:i,COLORTERM:n}=q.process.env;t||s||e==="0"?z=!1:e==="1"||e==="2"||e==="3"?z=!0:i==="dumb"?z=!1:"CI"in q.process.env&&["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(o=>o in q.process.env)?z=!0:z=process.stdout.isTTY,z&&(process.platform==="win32"||n&&(n==="truecolor"||n==="24bit")?tt=3:i&&(i.endsWith("-256color")||i.endsWith("256"))?tt=2:tt=1)}let De={enabled:z,supportLevel:tt};function O(e,t,s=1){const i=`\x1B[${e}m`,n=`\x1B[${t}m`,o=new RegExp(`\\x1b\\[${t}m`,"g");return r=>De.enabled&&De.supportLevel>=s?i+(""+r).replace(o,i)+n:""+r}const et=O(0,0),Ie=O(31,39),Ae=O(32,39),at=O(33,39),Re=O(34,39),zr=O(35,39),Jr=O(36,39),Wr=O(91,39),Ur=O(92,39),Gr=O(94,39),qr=O(96,39),Kr=O(43,49),Zr=O(46,49),Xr=O(104,49),jt=Ts(process.argv.slice(2),{string:["_"]}),Nt=process.cwd(),Ft=[{name:"react",display:"React",color:Jr,variants:[{name:"react",display:"JavaScript",color:at},{name:"react-h5",displ