UNPKG

@capgo/cli

Version:
79 lines (77 loc) 4.41 MB
#!/usr/bin/env node import{createRequire as AZQ}from"node:module";var nWQ=Object.create;var{getPrototypeOf:aWQ,defineProperty:c_,getOwnPropertyNames:ECA,getOwnPropertyDescriptor:oWQ}=Object,RCA=Object.prototype.hasOwnProperty;function jCA(A){return this[A]}var rWQ,sWQ,pA=(A,Q,B)=>{var $=A!=null&&typeof A==="object";if($){var J=Q?rWQ??=new WeakMap:sWQ??=new WeakMap,Y=J.get(A);if(Y)return Y}B=A!=null?nWQ(aWQ(A)):{};let X=Q||!A||!A.__esModule?c_(B,"default",{value:A,enumerable:!0}):B;for(let G of ECA(A))if(!RCA.call(X,G))c_(X,G,{get:jCA.bind(A,G),enumerable:!0});if($)J.set(A,X);return X},IW=(A)=>{var Q=(VCA??=new WeakMap).get(A),B;if(Q)return Q;if(Q=c_({},"__esModule",{value:!0}),A&&typeof A==="object"||typeof A==="function"){for(var $ of ECA(A))if(!RCA.call(Q,$))c_(Q,$,{get:jCA.bind(A,$),enumerable:!(B=oWQ(A,$))||B.enumerable})}return VCA.set(A,Q),Q},VCA,r=(A,Q)=>()=>(Q||A((Q={exports:{}}).exports,Q),Q.exports);var tWQ=(A)=>A;function eWQ(A,Q){this[A]=tWQ.bind(null,Q)}var BJ=(A,Q)=>{for(var B in Q)c_(A,B,{get:Q[B],enumerable:!0,configurable:!0,set:eWQ.bind(Q,B)})};var vA=(A,Q)=>()=>(A&&(Q=A(A=0)),Q);var GQ=AZQ(import.meta.url);var wCA,_CA=(A)=>{return A===12288||A>=65281&&A<=65376||A>=65504&&A<=65510},PCA=(A)=>{return A===8987||A===9001||A>=12272&&A<=12287||A>=12289&&A<=12350||A>=12441&&A<=12543||A>=12549&&A<=12591||A>=12593&&A<=12686||A>=12688&&A<=12771||A>=12783&&A<=12830||A>=12832&&A<=12871||A>=12880&&A<=19903||A>=65040&&A<=65049||A>=65072&&A<=65106||A>=65108&&A<=65126||A>=65128&&A<=65131||A>=127488&&A<=127490||A>=127504&&A<=127547||A>=127552&&A<=127560||A>=131072&&A<=196605||A>=196608&&A<=262141};var TCA=vA(()=>{wCA=(()=>{let A=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(Q)=>{let B=0;A.lastIndex=0;while(A.test(Q))B+=1;return Q.length-B}})()});var QZQ,BZQ,kCA,$ZQ,SCA,JZQ,YZQ,XZQ,xCA=(A,Q={},B={})=>{let $=Q.limit??1/0,J=Q.ellipsis??"",Y=Q?.ellipsisWidth??(J?xCA(J,XZQ,B).width:0),X=0,G=B.controlWidth??0,K=B.tabWidth??8,W=B.emojiWidth??2,H=2,q=B.regularWidth??1,F=B.wideWidth??2,U=[[JZQ,q],[QZQ,0],[BZQ,G],[$ZQ,K],[SCA,W],[kCA,F]],z=0,I=0,O=A.length,V=0,E=!1,M=O,L=Math.max(0,$-Y),R=0,T=0,x=0,d=0;A:while(!0){if(T>R||I>=O&&I>z){let p=A.slice(R,T)||A.slice(z,I);V=0;for(let f of p.replaceAll(YZQ,"")){let v=f.codePointAt(0)||0;if(_CA(v))d=2;else if(PCA(v))d=F;else d=q;if(x+d>L)M=Math.min(M,Math.max(R,z)+V);if(x+d>$){E=!0;break A}V+=f.length,x+=d}R=T=0}if(I>=O)break A;for(let p=0,f=U.length;p<f;p++){let[v,i]=U[p];if(v.lastIndex=I,v.test(A)){if(V=v===kCA?wCA(A.slice(I,v.lastIndex)):v===SCA?1:v.lastIndex-I,d=V*i,x+d>L)M=Math.min(M,I+Math.floor((L-x)/i));if(x+d>$){E=!0;break A}x+=d,R=z,T=I,I=z=v.lastIndex;continue A}}I+=1}return{width:E?L:x,index:E?M:O,truncated:E,ellipsed:E&&$>=Y}},bCA;var fCA=vA(()=>{TCA();QZQ=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,BZQ=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,kCA=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,$ZQ=/\t{1,1000}/y,SCA=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,JZQ=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,YZQ=/\p{M}+/gu,XZQ={limit:1/0,ellipsis:""},bCA=xCA});var GZQ,KZQ=(A,Q={})=>{return bCA(A,GZQ,Q).width},tZ;var SBA=vA(()=>{fCA();GZQ={limit:1/0,ellipsis:"",ellipsisWidth:0},tZ=KZQ});function uF(A,Q,B){return String(A).normalize().split(qZQ).map(($)=>DZQ($,Q,B)).join(` `)}var lu="\x1B",uCA="›",WZQ=39,bBA="\x07",mCA="[",ZZQ="]",cCA="m",fBA,vCA,gCA=(A)=>{if(A>=30&&A<=37)return 39;if(A>=90&&A<=97)return 39;if(A>=40&&A<=47)return 49;if(A>=100&&A<=107)return 49;if(A===1||A===2)return 22;if(A===3)return 23;if(A===4)return 24;if(A===7)return 27;if(A===8)return 28;if(A===9)return 29;if(A===0)return 0;return},yCA=(A)=>`${lu}${mCA}${A}${cCA}`,hCA=(A)=>`${lu}${fBA}${A}${bBA}`,xBA=(A,Q,B)=>{let $=Q[Symbol.iterator](),J=!1,Y=!1,X=A.at(-1),G=X===void 0?0:tZ(X),K=$.next(),W=$.next(),H=0;while(!K.done){let q=K.value,F=tZ(q);if(G+F<=B)A[A.length-1]+=q;else A.push(q),G=0;if(q===lu||q===uCA)J=!0,Y=Q.startsWith(fBA,H+1);if(J){if(Y){if(q===bBA)J=!1,Y=!1}else if(q===cCA)J=!1}else if(G+=F,G===B&&!W.done)A.push(""),G=0;K=W,W=$.next(),H+=q.length}if(X=A.at(-1),!G&&X!==void 0&&X.length&&A.length>1)A[A.length-2]+=A.pop()},HZQ=(A)=>{let Q=A.split(" "),B=Q.length;while(B){if(tZ(Q[B-1]))break;B--}if(B===Q.length)return A;return Q.slice(0,B).join(" ")+Q.slice(B).join("")},DZQ=(A,Q,B={})=>{if(B.trim!==!1&&A.trim()==="")return"";let $="",J,Y,X=A.split(" "),G=[""],K=0;for(let q=0;q<X.length;q++){let F=X[q];if(B.trim!==!1){let z=G.at(-1)??"",I=z.trimStart();if(z.length!==I.length)G[G.length-1]=I,K=tZ(I)}if(q!==0){if(K>=Q&&(B.wordWrap===!1||B.trim===!1))G.push(""),K=0;if(K||B.trim===!1)G[G.length-1]+=" ",K++}let U=tZ(F);if(B.hard&&U>Q){let z=Q-K,I=1+Math.floor((U-z-1)/Q);if(Math.floor((U-1)/Q)<I)G.push("");xBA(G,F,Q),K=tZ(G.at(-1)??"");continue}if(K+U>Q&&K&&U){if(B.wordWrap===!1&&K<Q){xBA(G,F,Q),K=tZ(G.at(-1)??"");continue}G.push(""),K=0}if(K+U>Q&&B.wordWrap===!1){xBA(G,F,Q),K=tZ(G.at(-1)??"");continue}G[G.length-1]+=F,K+=U}if(B.trim!==!1)G=G.map((q)=>HZQ(q));let W=G.join(` `),H=!1;for(let q=0;q<W.length;q++){let F=W[q];if($+=F,!H){if(H=F>="\uD800"&&F<="\uDBFF",H)continue}else H=!1;if(F===lu||F===uCA){vCA.lastIndex=q+1;let z=vCA.exec(W)?.groups;if(z?.code!==void 0){let I=Number.parseFloat(z.code);J=I===WZQ?void 0:I}else if(z?.uri!==void 0)Y=z.uri.length===0?void 0:z.uri}if(W[q+1]===` `){if(Y)$+=hCA("");let U=J?gCA(J):void 0;if(J&&U)$+=yCA(U)}else if(F===` `){if(J&&gCA(J))$+=yCA(J);if(Y)$+=hCA(Y)}}return $},qZQ;var vBA=vA(()=>{SBA();fBA=`${ZZQ}8;;`,vCA=new RegExp(`(?:\\${mCA}(?<code>\\d+)m|\\${fBA}(?<uri>.*)${bBA})`,"y"),qZQ=/\r?\n/});var yBA=r((rM0,dCA)=>{var gBA={to(A,Q){if(!Q)return`\x1B[${A+1}G`;return`\x1B[${Q+1};${A+1}H`},move(A,Q){let B="";if(A<0)B+=`\x1B[${-A}D`;else if(A>0)B+=`\x1B[${A}C`;if(Q<0)B+=`\x1B[${-Q}A`;else if(Q>0)B+=`\x1B[${Q}B`;return B},up:(A=1)=>`\x1B[${A}A`,down:(A=1)=>`\x1B[${A}B`,forward:(A=1)=>`\x1B[${A}C`,backward:(A=1)=>`\x1B[${A}D`,nextLine:(A=1)=>"\x1B[E".repeat(A),prevLine:(A=1)=>"\x1B[F".repeat(A),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},FZQ={up:(A=1)=>"\x1B[S".repeat(A),down:(A=1)=>"\x1B[T".repeat(A)},UZQ={screen:"\x1B[2J",up:(A=1)=>"\x1B[1J".repeat(A),down:(A=1)=>"\x1B[J".repeat(A),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(A){let Q="";for(let B=0;B<A;B++)Q+=this.line+(B<A-1?gBA.up():"");if(A)Q+=gBA.left;return Q}};dCA.exports={cursor:gBA,scroll:FZQ,erase:UZQ,beep:"\x07"}});import{styleText as sN}from"node:util";import{stdout as cBA,stdin as nCA}from"node:process";import*as mF from"node:readline";import zZQ from"node:readline";import{ReadStream as lCA}from"node:tty";function rN(A,Q,B){if(!B.some((X)=>!X.disabled))return A;let $=A+Q,J=Math.max(B.length-1,0),Y=$<0?J:$>J?0:$;return B[Y].disabled?rN(Y,Q<0?-1:1,B):Y}function pu(A,Q,B,$){let J=$.split(` `),Y=0,X=A;for(let K of J){if(X<=K.length)break;X-=K.length+1,Y++}for(Y=Math.max(0,Math.min(J.length-1,Y+B)),X=Math.min(X,J[Y].length)+Q;X<0&&Y>0;)Y--,X+=J[Y].length+1;for(;X>J[Y].length&&Y<J.length-1;)X-=J[Y].length+1,Y++;X=Math.max(0,Math.min(J[Y].length,X));let G=0;for(let K=0;K<Y;K++)G+=J[K].length+1;return G+X}function dBA(A,Q){if(typeof A=="string")return $J.aliases.get(A)===Q;for(let B of A)if(B!==void 0&&dBA(B,Q))return!0;return!1}function OZQ(A,Q){if(A===Q)return;let B=A.split(` `),$=Q.split(` `),J=Math.max(B.length,$.length),Y=[];for(let X=0;X<J;X++)B[X]!==$[X]&&Y.push(X);return{lines:Y,numLinesBefore:B.length,numLinesAfter:$.length,numLines:J}}function G1(A){return A===uBA}function iu(A,Q){let B=A;B.isTTY&&B.setRawMode(Q)}function aCA({input:A=nCA,output:Q=cBA,overwrite:B=!0,hideCursor:$=!0}={}){let J=mF.createInterface({input:A,output:Q,prompt:"",tabSize:1});mF.emitKeypressEvents(A,J),A instanceof lCA&&A.isTTY&&A.setRawMode(!0);let Y=(X,{name:G,sequence:K})=>{let W=String(X);if(dBA([W,G,K],"cancel")){$&&Q.write(o5.cursor.show),process.exit(0);return}if(!B)return;mF.moveCursor(Q,G==="return"?0:-1,G==="return"?-1:0,()=>{mF.clearLine(Q,1,()=>{A.once("keypress",Y)})})};return $&&Q.write(o5.cursor.hide),A.once("keypress",Y),()=>{A.off("keypress",Y),$&&Q.write(o5.cursor.show),A instanceof lCA&&A.isTTY&&!MZQ&&A.setRawMode(!1),J.terminal=!1,J.close()}}function d_(A,Q,B,$=B,J=B,Y){let X=au(A??cBA);return uF(Q,X-B.length,{hard:!0,trim:!1}).split(` `).map((G,K,W)=>{let H=Y?Y(G,K):G;return K===0?`${$}${H}`:K===W.length-1?`${J}${H}`:`${B}${H}`}).join(` `)}function oCA(A,Q){if("~standard"in A){let B=A["~standard"].validate(Q);if(B instanceof Promise)throw TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");return B.issues?.at(0)?.message}return A(Q)}class FD{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(A,Q=!0){let{input:B=nCA,output:$=cBA,render:J,signal:Y,...X}=A;this.opts=X,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=J.bind(this),this._track=Q,this._abortSignal=Y,this.input=B,this.output=$}unsubscribe(){this._subscribers.clear()}setSubscriber(A,Q){let B=this._subscribers.get(A)??[];B.push(Q),this._subscribers.set(A,B)}on(A,Q){this.setSubscriber(A,{cb:Q})}once(A,Q){this.setSubscriber(A,{cb:Q,once:!0})}emit(A,...Q){let B=this._subscribers.get(A)??[],$=[];for(let J of B)J.cb(...Q),J.once&&$.push(()=>B.splice(B.indexOf(J),1));for(let J of $)J()}prompt(){return new Promise((A)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),A(uBA);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=zZQ.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),iu(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(o5.cursor.show),this.output.off("resize",this.render),iu(this.input,!1),A(this.value)}),this.once("cancel",()=>{this.output.write(o5.cursor.show),this.output.off("resize",this.render),iu(this.input,!1),A(uBA)})})}_isActionKey(A,Q){return A==="\t"}_shouldSubmit(A,Q){return!0}_setValue(A){this.value=A,this.emit("value",this.value)}_setUserInput(A,Q){this.userInput=A??"",this.emit("userInput",this.userInput),Q&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress(A,Q){if(this._track&&Q.name!=="return"&&(Q.name&&this._isActionKey(A,Q)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),Q?.name&&(!this._track&&$J.aliases.has(Q.name)&&this.emit("cursor",$J.aliases.get(Q.name)),$J.actions.has(Q.name)&&this.emit("cursor",Q.name)),A&&(A.toLowerCase()==="y"||A.toLowerCase()==="n")&&this.emit("confirm",A.toLowerCase()==="y"),this.emit("key",A,Q),Q?.name==="return"&&this._shouldSubmit(A,Q)){if(this.opts.validate){let B=oCA(this.opts.validate,this.value);B&&(this.error=B instanceof Error?B.message:B,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}dBA([A,Q?.name,Q?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(` `),iu(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let A=uF(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(` `).length-1;this.output.write(o5.cursor.move(-999,A*-1))}render(){let A=uF(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(A!==this._prevFrame){if(this.state==="initial")this.output.write(o5.cursor.hide);else{let Q=OZQ(this._prevFrame,A),B=lBA(this.output);if(this.restoreCursor(),Q){let $=Math.max(0,Q.numLinesAfter-B),J=Math.max(0,Q.numLinesBefore-B),Y=Q.lines.find((X)=>X>=$);if(Y===void 0){this._prevFrame=A;return}if(Q.lines.length===1){this.output.write(o5.cursor.move(0,Y-J)),this.output.write(o5.erase.lines(1));let X=A.split(` `);this.output.write(X[Y]),this._prevFrame=A,this.output.write(o5.cursor.move(0,X.length-Y-1));return}else if(Q.lines.length>1){if($<J)Y=$;else{let G=Y-J;G>0&&this.output.write(o5.cursor.move(0,G))}this.output.write(o5.erase.down());let X=A.split(` `).slice(Y);this.output.write(X.join(` `)),this._prevFrame=A;return}}this.output.write(o5.erase.down())}this.output.write(A),this.state==="initial"&&(this.state="active"),this._prevFrame=A}}}function NZQ(A,Q){if(A===void 0||Q.length===0)return 0;let B=Q.findIndex(($)=>$.value===A);return B!==-1?B:0}function LZQ(A,Q){return(Q.label??String(Q.value)).toLowerCase().includes(A.toLowerCase())}function VZQ(A,Q){if(Q)return A?Q:Q[0]}function pCA(A){return[...A].map((Q)=>RZQ[Q])}function jZQ(A){let Q=new Intl.DateTimeFormat(A,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(2000,0,15)),B=[],$="/";for(let J of Q)J.type==="literal"?$=J.value.trim()||J.value:(J.type==="year"||J.type==="month"||J.type==="day")&&B.push({type:J.type,len:J.type==="year"?4:2});return{segments:B,separator:$}}function hBA(A){return Number.parseInt((A||"0").replace(/_/g,"0"),10)||0}function nu(A){return{year:hBA(A.year),month:hBA(A.month),day:hBA(A.day)}}function mBA(A,Q){return new Date(A||2001,Q||1,0).getDate()}function rCA(A){let{year:Q,month:B,day:$}=nu(A);if(!Q||Q<0||Q>9999||!B||B<1||B>12||!$||$<1)return;let J=new Date(Date.UTC(Q,B-1,$));if(!(J.getUTCFullYear()!==Q||J.getUTCMonth()!==B-1||J.getUTCDate()!==$))return{year:Q,month:B,day:$}}function iCA(A){let Q=rCA(A);return Q?new Date(Date.UTC(Q.year,Q.month-1,Q.day)):void 0}function wZQ(A,Q,B,$){let J=B?{year:B.getUTCFullYear(),month:B.getUTCMonth()+1,day:B.getUTCDate()}:null,Y=$?{year:$.getUTCFullYear(),month:$.getUTCMonth()+1,day:$.getUTCDate()}:null;return A==="year"?{min:J?.year??1,max:Y?.year??9999}:A==="month"?{min:J&&Q.year===J.year?J.month:1,max:Y&&Q.year===Y.year?Y.month:12}:{min:J&&Q.year===J.year&&Q.month===J.month?J.day:1,max:Y&&Q.year===Y.year&&Q.month===Y.month?Y.day:mBA(Q.year,Q.month)}}var o5,IZQ,CZQ,$J,MZQ,uBA,au=(A)=>("columns"in A)&&typeof A.columns=="number"?A.columns:80,lBA=(A)=>("rows"in A)&&typeof A.rows=="number"?A.rows:20,EZQ,pBA,RZQ,sCA,_ZQ,PZQ,tCA,iBA,nBA,aBA;var oBA=vA(()=>{vBA();o5=pA(yBA(),1);IZQ=["up","down","left","right","space","enter","cancel"],CZQ=["January","February","March","April","May","June","July","August","September","October","November","December"],$J={actions:new Set(IZQ),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0,date:{monthNames:[...CZQ],messages:{required:"Please enter a valid date",invalidMonth:"There are only 12 months in a year",invalidDay:(A,Q)=>`There are only ${A} days in ${Q}`,afterMin:(A)=>`Date must be on or after ${A.toISOString().slice(0,10)}`,beforeMax:(A)=>`Date must be on or before ${A.toISOString().slice(0,10)}`}}};MZQ=globalThis.process.platform.startsWith("win"),uBA=Symbol("clack:cancel");EZQ=class extends FD{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#A=0;#Q="";#B;#$;#J;get cursor(){return this.#A}get userInputWithCursor(){if(!this.userInput)return sN(["inverse","hidden"],"_");if(this._cursor>=this.userInput.length)return`${this.userInput}█`;let Q=this.userInput.slice(0,this._cursor),[B,...$]=this.userInput.slice(this._cursor);return`${Q}${sN("inverse",B)}${$.join("")}`}get options(){return typeof this.#$=="function"?this.#$():this.#$}constructor(Q){super(Q),this.#$=Q.options,this.#J=Q.placeholder;let B=this.options;this.filteredOptions=[...B],this.multiple=Q.multiple===!0,this.#B=typeof Q.options=="function"?Q.filter:Q.filter??LZQ;let $;if(Q.initialValue&&Array.isArray(Q.initialValue)?this.multiple?$=Q.initialValue:$=Q.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&($=[this.options[0].value]),$)for(let J of $){let Y=B.findIndex((X)=>X.value===J);Y!==-1&&(this.toggleSelected(J),this.#A=Y)}this.focusedValue=this.options[this.#A]?.value,this.on("key",(J,Y)=>this.#Y(J,Y)),this.on("userInput",(J)=>this.#X(J))}_isActionKey(Q,B){return Q==="\t"||this.multiple&&this.isNavigating&&B.name==="space"&&Q!==void 0&&Q!==""}#Y(Q,B){let $=B.name==="up",J=B.name==="down",Y=B.name==="return",X=this.userInput===""||this.userInput==="\t",G=this.#J,K=this.options,W=G!==void 0&&G!==""&&K.some((H)=>!H.disabled&&(this.#B?this.#B(G,H):!0));if(B.name==="tab"&&X&&W){this.userInput==="\t"&&this._clearUserInput(),this._setUserInput(G,!0),this.isNavigating=!1;return}$||J?(this.#A=rN(this.#A,$?-1:1,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#A]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):Y?this.value=VZQ(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&(B.name==="tab"||this.isNavigating&&B.name==="space")?this.toggleSelected(this.focusedValue):this.isNavigating=!1:(this.focusedValue&&(this.selectedValues=[this.focusedValue]),this.isNavigating=!1)}deselectAll(){this.selectedValues=[]}toggleSelected(Q){this.filteredOptions.length!==0&&(this.multiple?this.selectedValues.includes(Q)?this.selectedValues=this.selectedValues.filter((B)=>B!==Q):this.selectedValues=[...this.selectedValues,Q]:this.selectedValues=[Q])}#X(Q){if(Q!==this.#Q){this.#Q=Q;let B=this.options;Q&&this.#B?this.filteredOptions=B.filter((Y)=>this.#B?.(Q,Y)):this.filteredOptions=[...B];let $=NZQ(this.focusedValue,this.filteredOptions);this.#A=rN($,0,this.filteredOptions);let J=this.filteredOptions[this.#A];J&&!J.disabled?this.focusedValue=J.value:this.focusedValue=void 0,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}};pBA=class pBA extends FD{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(A){super(A,!1),this.value=!!A.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",(Q)=>{this.output.write(o5.cursor.move(0,-1)),this.value=Q,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};RZQ={Y:{type:"year",len:4},M:{type:"month",len:2},D:{type:"day",len:2}};sCA=class sCA extends FD{#A;#Q;#B;#$;#J;#Y={segmentIndex:0,positionInSegment:0};#X=!0;#G=null;inlineError="";get segmentCursor(){return{...this.#Y}}get segmentValues(){return{...this.#B}}get segments(){return this.#A}get separator(){return this.#Q}get formattedValue(){return this.#W(this.#B)}#W(A){return this.#A.map((Q)=>A[Q.type]).join(this.#Q)}#Z(){this._setUserInput(this.#W(this.#B)),this._setValue(iCA(this.#B)??void 0)}constructor(A){let Q=A.format?{segments:pCA(A.format),separator:A.separator??"/"}:jZQ(A.locale),B=A.separator??Q.separator,$=A.format?pCA(A.format):Q.segments,J=A.initialValue??A.defaultValue,Y=J?{year:String(J.getUTCFullYear()).padStart(4,"0"),month:String(J.getUTCMonth()+1).padStart(2,"0"),day:String(J.getUTCDate()).padStart(2,"0")}:{year:"____",month:"__",day:"__"},X=$.map((G)=>Y[G.type]).join(B);super({...A,initialUserInput:X},!1),this.#A=$,this.#Q=B,this.#B=Y,this.#$=A.minDate,this.#J=A.maxDate,this.#Z(),this.on("cursor",(G)=>this.#F(G)),this.on("key",(G,K)=>this.#U(G,K)),this.on("finalize",()=>this.#z(A))}#H(){let A=Math.max(0,Math.min(this.#Y.segmentIndex,this.#A.length-1)),Q=this.#A[A];if(Q)return this.#Y.positionInSegment=Math.max(0,Math.min(this.#Y.positionInSegment,Q.len-1)),{segment:Q,index:A}}#D(A){this.inlineError="",this.#G=null;let Q=this.#H();Q&&(this.#Y.segmentIndex=Math.max(0,Math.min(this.#A.length-1,Q.index+A)),this.#Y.positionInSegment=0,this.#X=!0)}#K(A){let Q=this.#H();if(!Q)return;let{segment:B}=Q,$=this.#B[B.type],J=!$||$.replace(/_/g,"")==="",Y=Number.parseInt(($||"0").replace(/_/g,"0"),10)||0,X=wZQ(B.type,nu(this.#B),this.#$,this.#J),G;J?G=A===1?X.min:X.max:G=Math.max(Math.min(X.max,Y+A),X.min),this.#B={...this.#B,[B.type]:G.toString().padStart(B.len,"0")},this.#X=!0,this.#G=null,this.#Z()}#F(A){if(A)switch(A){case"right":return this.#D(1);case"left":return this.#D(-1);case"up":return this.#K(1);case"down":return this.#K(-1)}}#U(A,Q){if(Q?.name==="backspace"||Q?.sequence===""||Q?.sequence==="\b"||A===""||A==="\b"){this.inlineError="";let B=this.#H();if(!B)return;if(!this.#B[B.segment.type].replace(/_/g,"")){this.#D(-1);return}this.#B[B.segment.type]="_".repeat(B.segment.len),this.#X=!0,this.#Y.positionInSegment=0,this.#Z();return}if(Q?.name==="tab"){this.inlineError="";let B=this.#H();if(!B)return;let $=Q.shift?-1:1,J=B.index+$;J>=0&&J<this.#A.length&&(this.#Y.segmentIndex=J,this.#Y.positionInSegment=0,this.#X=!0);return}if(A&&/^[0-9]$/.test(A)){let B=this.#H();if(!B)return;let{segment:$}=B,J=!this.#B[$.type].replace(/_/g,"");if(this.#X&&this.#G!==null&&!J){let F=this.#G+A,U={...this.#B,[$.type]:F},z=this.#q(U,$);if(z){this.inlineError=z,this.#G=null,this.#X=!1;return}this.inlineError="",this.#B[$.type]=F,this.#G=null,this.#X=!1,this.#Z(),B.index<this.#A.length-1&&(this.#Y.segmentIndex=B.index+1,this.#Y.positionInSegment=0,this.#X=!0);return}this.#X&&!J&&(this.#B[$.type]="_".repeat($.len),this.#Y.positionInSegment=0),this.#X=!1,this.#G=null;let Y=this.#B[$.type],X=Y.indexOf("_"),G=X>=0?X:Math.min(this.#Y.positionInSegment,$.len-1);if(G<0||G>=$.len)return;let K=Y.slice(0,G)+A+Y.slice(G+1),W=!1;if(G===0&&Y==="__"&&($.type==="month"||$.type==="day")){let F=Number.parseInt(A,10);K=`0${A}`,W=F<=($.type==="month"?1:2)}if($.type==="year"&&(K=(Y.replace(/_/g,"")+A).padStart($.len,"_")),!K.includes("_")){let F={...this.#B,[$.type]:K},U=this.#q(F,$);if(U){this.inlineError=U;return}}this.inlineError="",this.#B[$.type]=K;let H=K.includes("_")?void 0:rCA(this.#B);if(H){let{year:F,month:U}=H,z=mBA(F,U);this.#B={year:String(Math.max(0,Math.min(9999,F))).padStart(4,"0"),month:String(Math.max(1,Math.min(12,U))).padStart(2,"0"),day:String(Math.max(1,Math.min(z,H.day))).padStart(2,"0")}}this.#Z();let q=K.indexOf("_");W?(this.#X=!0,this.#G=A):q>=0?this.#Y.positionInSegment=q:X>=0&&B.index<this.#A.length-1?(this.#Y.segmentIndex=B.index+1,this.#Y.positionInSegment=0,this.#X=!0):this.#Y.positionInSegment=Math.min(G+1,$.len-1)}}#q(A,Q){let{month:B,day:$}=nu(A);if(Q.type==="month"&&(B<0||B>12))return $J.date.messages.invalidMonth;if(Q.type==="day"&&($<0||$>31))return $J.date.messages.invalidDay(31,"any month")}#z(A){let{year:Q,month:B,day:$}=nu(this.#B);if(Q&&B&&$){let J=mBA(Q,B);this.#B={...this.#B,day:String(Math.min($,J)).padStart(2,"0")}}this.value=iCA(this.#B)??A.defaultValue??void 0}};_ZQ=class extends FD{options;cursor=0;#A;getGroupItems(Q){return this.options.filter((B)=>B.group===Q)}isGroupSelected(Q){let B=this.getGroupItems(Q),$=this.value;return $===void 0?!1:B.every((J)=>$.includes(J.value))}toggleValue(){let Q=this.options[this.cursor];if(this.value===void 0&&(this.value=[]),Q.group===!0){let B=Q.value,$=this.getGroupItems(B);this.isGroupSelected(B)?this.value=this.value.filter((J)=>$.findIndex((Y)=>Y.value===J)===-1):this.value=[...this.value,...$.map((J)=>J.value)],this.value=Array.from(new Set(this.value))}else{let B=this.value.includes(Q.value);this.value=B?this.value.filter(($)=>$!==Q.value):[...this.value,Q.value]}}constructor(Q){super(Q,!1);let{options:B}=Q;this.#A=Q.selectableGroups!==!1,this.options=Object.entries(B).flatMap(([$,J])=>[{value:$,group:!0,label:$},...J.map((Y)=>({...Y,group:$}))]),this.value=[...Q.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:$})=>$===Q.cursorAt),this.#A?0:1),this.on("cursor",($)=>{switch($){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let J=this.options[this.cursor]?.group===!0;!this.#A&&J&&(this.cursor=this.cursor===0?this.options.length-1:this.cursor-1);break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let J=this.options[this.cursor]?.group===!0;!this.#A&&J&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}},PZQ=new Set(["up","down","left","right"]);tCA=class tCA extends FD{#A=!1;#Q;focused="editor";get userInputWithCursor(){if(this.state==="submit")return this.userInput;let A=this.userInput;if(this.cursor>=A.length)return`${A}█`;let Q=A.slice(0,this.cursor),B=A[this.cursor],$=A.slice(this.cursor+1);return B===` `?`${Q}█ ${$}`:`${Q}${sN("inverse",B)}${$}`}get cursor(){return this._cursor}#B(A){if(this.userInput.length===0){this._setUserInput(A);return}this._setUserInput(this.userInput.slice(0,this.cursor)+A+this.userInput.slice(this.cursor))}#$(A){let Q=this.value??"";switch(A){case"up":this._cursor=pu(this._cursor,0,-1,Q);return;case"down":this._cursor=pu(this._cursor,0,1,Q);return;case"left":this._cursor=pu(this._cursor,-1,0,Q);return;case"right":this._cursor=pu(this._cursor,1,0,Q);return}}_shouldSubmit(A,Q){if(this.#Q)return this.focused==="submit"?!0:(this.#B(` `),this._cursor++,!1);let B=this.#A;return this.#A=!0,B?(this.userInput[this.cursor-1]===` `&&(this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--),!0):(this.#B(` `),this._cursor++,!1)}constructor(A){super(A,!1),this.#Q=A.showSubmit??!1,this.on("key",(Q,B)=>{if(B?.name&&PZQ.has(B.name)){this.#$(B.name);return}if(Q==="\t"&&this.#Q){this.focused=this.focused==="editor"?"submit":"editor";return}if(B?.name!=="return"){if(this.#A=!1,B?.name==="backspace"&&this.cursor>0){this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--;return}if(B?.name==="delete"&&this.cursor<this.userInput.length){this._setUserInput(this.userInput.slice(0,this.cursor)+this.userInput.slice(this.cursor+1));return}Q&&(this.#Q&&this.focused==="submit"&&(this.focused="editor"),this.#B(Q??""),this._cursor++)}}),this.on("userInput",(Q)=>{this._setValue(Q)}),this.on("finalize",()=>{this.value||(this.value=A.defaultValue),this.value===void 0&&(this.value="")})}};iBA=class iBA extends FD{_mask="•";get cursor(){return this._cursor}get masked(){return this.userInput.replaceAll(/./g,this._mask)}get userInputWithCursor(){if(this.state==="submit"||this.state==="cancel")return this.masked;let A=this.userInput;if(this.cursor>=A.length)return`${this.masked}${sN(["inverse","hidden"],"_")}`;let Q=this.masked,B=Q.slice(0,this.cursor),$=Q.slice(this.cursor);return`${B}${sN("inverse",$[0])}${$.slice(1)}`}clear(){this._clearUserInput()}constructor({mask:A,...Q}){super(Q),this._mask=A??"•",this.on("userInput",(B)=>{this._setValue(B)})}};nBA=class nBA extends FD{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor(A){super(A,!1),this.options=A.options;let Q=this.options.findIndex(({value:$})=>$===A.initialValue),B=Q===-1?0:Q;this.cursor=this.options[B].disabled?rN(B,1,this.options):B,this.changeValue(),this.on("cursor",($)=>{switch($){case"left":case"up":this.cursor=rN(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=rN(this.cursor,1,this.options);break}this.changeValue()})}};aBA=class aBA extends FD{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let A=this.userInput;if(this.cursor>=A.length)return`${this.userInput}█`;let Q=A.slice(0,this.cursor),[B,...$]=A.slice(this.cursor);return`${Q}${sN("inverse",B)}${$.join("")}`}get cursor(){return this._cursor}constructor(A){super({...A,initialUserInput:A.initialUserInput??A.initialValue}),this.on("userInput",(Q)=>{this._setValue(Q)}),this.on("finalize",()=>{this.value||(this.value=A.defaultValue),this.value===void 0&&(this.value="")})}}});import{styleText as C0,stripVTControlCharacters as KN0}from"node:util";import CW from"node:process";function TZQ(){if(CW.platform!=="win32")return CW.env.TERM!=="linux";return Boolean(CW.env.CI)||Boolean(CW.env.WT_SESSION)||Boolean(CW.env.TERMINUS_SUBLIME)||CW.env.ConEmuTask==="{cmd::Cmder}"||CW.env.TERM_PROGRAM==="Terminus-Sublime"||CW.env.TERM_PROGRAM==="vscode"||CW.env.TERM==="xterm-256color"||CW.env.TERM==="alacritty"||CW.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var l_,rBA,kZQ=()=>process.env.CI==="true",i4=(A,Q)=>rBA?A:Q,SZQ,AOA,QOA,tBA,xZQ,G4,cF,DN0,qN0,sBA,ru,FN0,UN0,zN0,bZQ,IN0,CN0,ON0,MN0,NN0,LN0,fZQ,vZQ,gZQ,yZQ,su=(A)=>{switch(A){case"initial":case"active":return C0("cyan",SZQ);case"cancel":return C0("red",AOA);case"error":return C0("yellow",QOA);case"submit":return C0("green",tBA)}},hZQ=(A)=>{switch(A){case"initial":case"active":return C0("cyan",G4);case"cancel":return C0("red",G4);case"error":return C0("yellow",G4);case"submit":return C0("green",G4)}},eCA=(A,Q,B,$,J,Y=!1)=>{let X=Q,G=0;if(Y)for(let K=$-1;K>=B&&(X-=A[K].length,G++,!(X<=J));K--);else for(let K=B;K<$&&(X-=A[K].length,G++,!(X<=J));K++);return{lineCount:X,removals:G}},uZQ=({cursor:A,options:Q,style:B,output:$=process.stdout,maxItems:J=Number.POSITIVE_INFINITY,columnPadding:Y=0,rowPadding:X=4})=>{let G=au($)-Y,K=lBA($),W=C0("dim","..."),H=Math.max(K-X,0),q=Math.max(Math.min(J,H),5),F=0;A>=q-3&&(F=Math.max(Math.min(A-q+3,Q.length-q),0));let U=q<Q.length&&F>0,z=q<Q.length&&F+q<Q.length,I=Math.min(F+q,Q.length),O=[],V=0;U&&V++,z&&V++;let E=F+(U?1:0),M=I-(z?1:0);for(let R=E;R<M;R++){let T=uF(B(Q[R],R===A),G,{hard:!0,trim:!1}).split(` `);O.push(T),V+=T.length}if(V>H){let R=0,T=0,x=V,d=A-E,p=H,f=()=>eCA(O,x,0,d,p),v=()=>eCA(O,x,d+1,O.length,p,!0);U?({lineCount:x,removals:R}=f(),x>p&&(z||(p-=1),{lineCount:x,removals:T}=v())):(z||(p-=1),{lineCount:x,removals:T}=v(),x>p&&(p-=1,{lineCount:x,removals:R}=f())),R>0&&(U=!0,O.splice(0,R)),T>0&&(z=!0,O.splice(O.length-T,T))}let L=[];U&&L.push(W);for(let R of O)for(let T of R)L.push(T);return z&&L.push(W),L},x4=(A)=>{let Q=A.active??"Yes",B=A.inactive??"No";return new pBA({active:Q,inactive:B,signal:A.signal,input:A.input,output:A.output,initialValue:A.initialValue??!0,render(){let $=A.withGuide??$J.withGuide,J=`${su(this.state)} `,Y=$?`${C0("gray",G4)} `:"",X=d_(A.output,A.message,Y,J),G=`${$?`${C0("gray",G4)} `:""}${X} `,K=this.value?Q:B;switch(this.state){case"submit":{let W=$?`${C0("gray",G4)} `:"";return`${G}${W}${C0("dim",K)}`}case"cancel":{let W=$?`${C0("gray",G4)} `:"";return`${G}${W}${C0(["strikethrough","dim"],K)}${$?` ${C0("gray",G4)}`:""}`}default:{let W=$?`${C0("cyan",G4)} `:"",H=$?C0("cyan",cF):"";return`${G}${W}${this.value?`${C0("green",sBA)} ${Q}`:`${C0("dim",ru)} ${C0("dim",Q)}`}${A.vertical?$?` ${C0("cyan",G4)} `:` `:` ${C0("dim","/")} `}${this.value?`${C0("dim",ru)} ${C0("dim",B)}`:`${C0("green",sBA)} ${B}`} ${H} `}}}}).prompt()},_,BOA=(A="",Q)=>{let B=Q?.output??process.stdout,$=Q?.withGuide??$J.withGuide?`${C0("gray",cF)} `:"";B.write(`${$}${C0("red",A)} `)},AB=(A="",Q)=>{let B=Q?.output??process.stdout,$=Q?.withGuide??$J.withGuide?`${C0("gray",xZQ)} `:"";B.write(`${$}${A} `)},QB=(A="",Q)=>{let B=Q?.output??process.stdout,$=Q?.withGuide??$J.withGuide?`${C0("gray",G4)} ${C0("gray",cF)} `:"";B.write(`${$}${A} `)},$OA=(A)=>new iBA({validate:A.validate,mask:A.mask??bZQ,signal:A.signal,input:A.input,output:A.output,render(){let Q=A.withGuide??$J.withGuide,B=`${Q?`${C0("gray",G4)} `:""}${su(this.state)} ${A.message} `,$=this.userInputWithCursor,J=this.masked;switch(this.state){case"error":{let Y=Q?`${C0("yellow",G4)} `:"",X=Q?`${C0("yellow",cF)} `:"",G=J??"";return A.clearOnError&&this.clear(),`${B.trim()} ${Y}${G} ${X}${C0("yellow",this.error)} `}case"submit":{let Y=Q?`${C0("gray",G4)} `:"",X=J?C0("dim",J):"";return`${B}${Y}${X}`}case"cancel":{let Y=Q?`${C0("gray",G4)} `:"",X=J?C0(["strikethrough","dim"],J):"";return`${B}${Y}${X}${J&&Q?` ${C0("gray",G4)}`:""}`}default:{let Y=Q?`${C0("cyan",G4)} `:"",X=Q?C0("cyan",cF):"";return`${B}${Y}${$} ${X} `}}}}).prompt(),mZQ=(A)=>C0("magenta",A),L4=({indicator:A="dots",onCancel:Q,output:B=process.stdout,cancelMessage:$,errorMessage:J,frames:Y=rBA?["◒","◐","◓","◑"]:["•","o","O","0"],delay:X=rBA?80:120,signal:G,...K}={})=>{let W=kZQ(),H,q,F=!1,U=!1,z="",I,O=performance.now(),V=au(B),E=K?.styleFrame??mZQ,M=(UA)=>{let o=UA>1?J??$J.messages.error:$??$J.messages.cancel;U=UA===1,F&&(s(o,UA),U&&typeof Q=="function"&&Q())},L=()=>M(2),R=()=>M(1),T=()=>{process.on("uncaughtExceptionMonitor",L),process.on("unhandledRejection",L),process.on("SIGINT",R),process.on("SIGTERM",R),process.on("exit",M),G&&G.addEventListener("abort",R)},x=()=>{process.removeListener("uncaughtExceptionMonitor",L),process.removeListener("unhandledRejection",L),process.removeListener("SIGINT",R),process.removeListener("SIGTERM",R),process.removeListener("exit",M),G&&G.removeEventListener("abort",R)},d=()=>{if(I===void 0)return;W&&B.write(` `);let UA=uF(I,V,{hard:!0,trim:!1}).split(` `);UA.length>1&&B.write(l_.cursor.up(UA.length-1)),B.write(l_.cursor.to(0)),B.write(l_.erase.down())},p=(UA)=>UA.replace(/\.+$/,""),f=(UA)=>{let o=(performance.now()-UA)/1000,h=Math.floor(o/60),g=Math.floor(o%60);return h>0?`[${h}m ${g}s]`:`[${g}s]`},v=K.withGuide??$J.withGuide,i=(UA="")=>{F=!0,H=aCA({output:B}),z=p(UA),O=performance.now(),v&&B.write(`${C0("gray",G4)} `);let o=0,h=0;T(),q=setInterval(()=>{if(W&&z===I)return;d(),I=z;let g=E(Y[o]),S;if(W)S=`${g} ${z}...`;else if(A==="timer")S=`${g} ${z} ${f(O)}`;else{let y=".".repeat(Math.floor(h)).slice(0,3);S=`${g} ${z}${y}`}let c=uF(S,V,{hard:!0,trim:!1});B.write(c),o=o+1<Y.length?o+1:0,h=h<4?h+0.125:0},X)},s=(UA="",o=0,h=!1)=>{if(!F)return;F=!1,clearInterval(q),d();let g=o===0?C0("green",tBA):o===1?C0("red",AOA):C0("red",QOA);z=UA??z,h||(A==="timer"?B.write(`${g} ${z} ${f(O)} `):B.write(`${g} ${z} `)),x(),H()};return{start:i,stop:(UA="")=>s(UA,0),message:(UA="")=>{z=p(UA??z)},cancel:(UA="")=>s(UA,1),error:(UA="")=>s(UA,2),clear:()=>s("",0,!0),get isCancelled(){return U}}},VN0,ou=(A,Q)=>A.includes(` `)?A.split(` `).map((B)=>Q(B)).join(` `):Q(A),b9=(A)=>{let Q=(B,$)=>{let J=B.label??String(B.value);switch($){case"disabled":return`${C0("gray",ru)} ${ou(J,(Y)=>C0("gray",Y))}${B.hint?` ${C0("dim",`(${B.hint??"disabled"})`)}`:""}`;case"selected":return`${ou(J,(Y)=>C0("dim",Y))}`;case"active":return`${C0("green",sBA)} ${J}${B.hint?` ${C0("dim",`(${B.hint})`)}`:""}`;case"cancelled":return`${ou(J,(Y)=>C0(["strikethrough","dim"],Y))}`;default:return`${C0("dim",ru)} ${ou(J,(Y)=>C0("dim",Y))}`}};return new nBA({options:A.options,signal:A.signal,input:A.input,output:A.output,initialValue:A.initialValue,render(){let B=A.withGuide??$J.withGuide,$=`${su(this.state)} `,J=`${hZQ(this.state)} `,Y=d_(A.output,A.message,J,$),X=`${B?`${C0("gray",G4)} `:""}${Y} `;switch(this.state){case"submit":{let G=B?`${C0("gray",G4)} `:"",K=d_(A.output,Q(this.options[this.cursor],"selected"),G);return`${X}${K}`}case"cancel":{let G=B?`${C0("gray",G4)} `:"",K=d_(A.output,Q(this.options[this.cursor],"cancelled"),G);return`${X}${K}${B?` ${C0("gray",G4)}`:""}`}default:{let G=B?`${C0("cyan",G4)} `:"",K=B?C0("cyan",cF):"",W=X.split(` `).length,H=B?2:1;return`${X}${G}${uZQ({output:A.output,cursor:this.cursor,options:this.options,maxItems:A.maxItems,columnPadding:G.length,rowPadding:W+H,style:(q,F)=>Q(q,q.disabled?"disabled":F?"active":"inactive")}).join(` ${G}`)} ${K} `}}}}).prompt()},EN0,dF=(A)=>new aBA({validate:A.validate,placeholder:A.placeholder,defaultValue:A.defaultValue,initialValue:A.initialValue,output:A.output,signal:A.signal,input:A.input,render(){let Q=A?.withGuide??$J.withGuide,B=`${`${Q?`${C0("gray",G4)} `:""}${su(this.state)} `}${A.message} `,$=A.placeholder?C0("inverse",A.placeholder[0])+C0("dim",A.placeholder.slice(1)):C0(["inverse","hidden"],"_"),J=this.userInput?this.userInputWithCursor:$,Y=this.value??"";switch(this.state){case"error":{let X=this.error?` ${C0("yellow",this.error)}`:"",G=Q?`${C0("yellow",G4)} `:"",K=Q?C0("yellow",cF):"";return`${B.trim()} ${G}${J} ${K}${X} `}case"submit":{let X=Y?` ${C0("dim",Y)}`:"",G=Q?C0("gray",G4):"";return`${B}${G}${X}`}case"cancel":{let X=Y?` ${C0(["strikethrough","dim"],Y)}`:"",G=Q?C0("gray",G4):"";return`${B}${G}${X}${Y.trim()?` ${G}`:""}`}default:{let X=Q?`${C0("cyan",G4)} `:"",G=Q?C0("cyan",cF):"";return`${B}${X}${J} ${G} `}}}}).prompt();var TB=vA(()=>{oBA();oBA();vBA();SBA();l_=pA(yBA(),1);rBA=TZQ(),SZQ=i4("◆","*"),AOA=i4("■","x"),QOA=i4("▲","x"),tBA=i4("◇","o"),xZQ=i4("┌","T"),G4=i4("│","|"),cF=i4("└","—"),DN0=i4("┐","T"),qN0=i4("┘","—"),sBA=i4("●",">"),ru=i4("○"," "),FN0=i4("◻","[•]"),UN0=i4("◼","[+]"),zN0=i4("◻","[ ]"),bZQ=i4("▪","•"),IN0=i4("─","-"),CN0=i4("╮","+"),ON0=i4("├","+"),MN0=i4("╯","+"),NN0=i4("╰","+"),LN0=i4("╭","+"),fZQ=i4("●","•"),vZQ=i4("◆","*"),gZQ=i4("▲","!"),yZQ=i4("■","x"),_={message:(A=[],{symbol:Q=C0("gray",G4),secondarySymbol:B=C0("gray",G4),output:$=process.stdout,spacing:J=1,withGuide:Y}={})=>{let X=[],G=Y??$J.withGuide,K=G?B:"",W=G?`${Q} `:"",H=G?`${B} `:"";for(let F=0;F<J;F++)X.push(K);let q=Array.isArray(A)?A:A.split(` `);if(q.length>0){let[F,...U]=q;F.length>0?X.push(`${W}${F}`):X.push(G?Q:"");for(let z of U)z.length>0?X.push(`${H}${z}`):X.push(G?B:"")}$.write(`${X.join(` `)} `)},info:(A,Q)=>{_.message(A,{...Q,symbol:C0("blue",fZQ)})},success:(A,Q)=>{_.message(A,{...Q,symbol:C0("green",vZQ)})},step:(A,Q)=>{_.message(A,{...Q,symbol:C0("green",tBA)})},warn:(A,Q)=>{_.message(A,{...Q,symbol:C0("yellow",gZQ)})},warning:(A,Q)=>{_.warn(A,Q)},error:(A,Q)=>{_.message(A,{...Q,symbol:C0("red",yZQ)})}},VN0={light:i4("─","-"),heavy:i4("━","="),block:i4("█","#")},EN0=`${C0("gray",G4)} `});var p_=r((cZQ)=>{class eBA extends Error{constructor(A,Q,B){super(B);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=Q,this.exitCode=A,this.nestedError=void 0}}class JOA extends eBA{constructor(A){super(1,"commander.invalidArgument",A);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}cZQ.CommanderError=eBA;cZQ.InvalidArgumentError=JOA});var tu=r((nZQ)=>{var{InvalidArgumentError:pZQ}=p_();class YOA{constructor(A,Q){switch(this.description=Q||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,A[0]){case"<":this.required=!0,this._name=A.slice(1,-1);break;case"[":this.required=!1,this._name=A.slice(1,-1);break;default:this.required=!0,this._name=A;break}if(this._name.endsWith("..."))this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_collectValue(A,Q){if(Q===this.defaultValue||!Array.isArray(Q))return[A];return Q.push(A),Q}default(A,Q){return this.defaultValue=A,this.defaultValueDescription=Q,this}argParser(A){return this.parseArg=A,this}choices(A){return this.argChoices=A.slice(),this.parseArg=(Q,B)=>{if(!this.argChoices.includes(Q))throw new pZQ(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(Q,B);return Q},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function iZQ(A){let Q=A.name()+(A.variadic===!0?"...":"");return A.required?"<"+Q+">":"["+Q+"]"}nZQ.Argument=YOA;nZQ.humanReadableArgName=iZQ});var A1A=r((sZQ)=>{var{humanReadableArgName:rZQ}=tu();class XOA{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(A){this.helpWidth=this.helpWidth??A.helpWidth??80}visibleCommands(A){let Q=A.commands.filter(($)=>!$._hidden),B=A._getHelpCommand();if(B&&!B._hidden)Q.push(B);if(this.sortSubcommands)Q.sort(($,J)=>{return $.name().localeCompare(J.name())});return Q}compareOptions(A,Q){let B=($)=>{return $.short?$.short.replace(/^-/,""):$.long.replace(/^--/,"")};return B(A).localeCompare(B(Q))}visibleOptions(A){let Q=A.options.filter(($)=>!$.hidden),B=A._getHelpOption();if(B&&!B.hidden){let $=B.short&&A._findOption(B.short),J=B.long&&A._findOption(B.long);if(!$&&!J)Q.push(B);else if(B.long&&!J)Q.push(A.createOption(B.long,B.description));else if(B.short&&!$)Q.push(A.createOption(B.short,B.description))}if(this.sortOptions)Q.sort(this.compareOptions);return Q}visibleGlobalOptions(A){if(!this.showGlobalOptions)return[];let Q=[];for(let B=A.parent;B;B=B.parent){let $=B.options.filter((J)=>!J.hidden);Q.push(...$)}if(this.sortOptions)Q.sort(this.compareOptions);return Q}visibleArguments(A){if(A._argsDescription)A.registeredArguments.forEach((Q)=>{Q.description=Q.description||A._argsDescription[Q.name()]||""});if(A.registeredArguments.find((Q)=>Q.description))return A.registeredArguments;return[]}subcommandTerm(A){let Q=A.registeredArguments.map((B)=>rZQ(B)).join(" ");return A._name+(A._aliases[0]?"|"+A._aliases[0]:"")+(A.options.length?" [options]":"")+(Q?" "+Q:"")}optionTerm(A){return A.flags}argumentTerm(A){return A.name()}longestSubcommandTermLength(A,Q){return Q.visibleCommands(A).reduce((B,$)=>{return Math.max(B,this.displayWidth(Q.styleSubcommandTerm(Q.subcommandTerm($))))},0)}longestOptionTermLength(A,Q){return Q.visibleOptions(A).reduce((B,$)=>{return Math.max(B,this.displayWidth(Q.styleOptionTerm(Q.optionTerm($))))},0)}longestGlobalOptionTermLength(A,Q){return Q.visibleGlobalOptions(A).reduce((B,$)=>{return Math.max(B,this.displayWidth(Q.styleOptionTerm(Q.optionTerm($))))},0)}longestArgumentTermLength(A,Q){return Q.visibleArguments(A).reduce((B,$)=>{return Math.max(B,this.displayWidth(Q.styleArgumentTerm(Q.argumentTerm($))))},0)}commandUsage(A){let Q=A._name;if(A._aliases[0])Q=Q+"|"+A._aliases[0];let B="";for(let $=A.parent;$;$=$.parent)B=$.name()+" "+B;return B+Q+" "+A.usage()}commandDescription(A){return A.description()}subcommandDescription(A){return A.summary()||A.description()}optionDescription(A){let Q=[];if(A.argChoices)Q.push(`choices: ${A.argChoices.map((B)=>JSON.stringify(B)).join(", ")}`);if(A.defaultValue!==void 0){if(A.required||A.optional||A.isBoolean()&&typeof A.defaultValue==="boolean")Q.push(`default: ${A.defaultValueDescription||JSON.stringify(A.defaultValue)}`)}if(A.presetArg!==void 0&&A.optional)Q.push(`preset: ${JSON.stringify(A.presetArg)}`);if(A.envVar!==void 0)Q.push(`env: ${A.envVar}`);if(Q.length>0){let B=`(${Q.join(", ")})`;if(A.description)return`${A.description} ${B}`;return B}return A.description}argumentDescription(A){let Q=[];if(A.argChoices)Q.push(`choices: ${A.argChoices.map((B)=>JSON.stringify(B)).join(", ")}`);if(A.defaultValue!==void 0)Q.push(`default: ${A.defaultValueDescription||JSON.stringify(A.defaultValue)}`);if(Q.length>0){let B=`(${Q.join(", ")})`;if(A.description)return`${A.description} ${B}`;return B}return A.description}formatItemList(A,Q,B){if(Q.length===0)return[];return[B.styleTitle(A),...Q,""]}groupItems(A,Q,B){let $=new Map;return A.forEach((J)=>{let Y=B(J);if(!$.has(Y))$.set(Y,[])}),Q.forEach((J)=>{let Y=B(J);if(!$.has(Y))$.set(Y,[]);$.get(Y).push(J)}),$}formatHelp(A,Q){let B=Q.padWidth(A,Q),$=Q.helpWidth??80;function J(H,q){return Q.formatItem(H,B,q,Q)}let Y=[`${Q.styleTitle("Usage:")} ${Q.styleUsage(Q.commandUsage(A))}`,""],X=Q.commandDescription(A);if(X.length>0)Y=Y.concat([Q.boxWrap(Q.styleCommandDescription(X),$),""]);let G=Q.visibleArguments(A).map((H)=>{return J(Q.styleArgumentTerm(Q.argumentTerm(H)),Q.styleArgumentDescription(Q.argumentDescription(H)))});if(Y=Y.concat(this.formatItemList("Arguments:",G,Q)),this.groupItems(A.options,Q.visibleOptions(A),(H)=>H.helpGroupHeading??"Options:").forEach((H,q)=>{let F=H.map((U)=>{return J(Q.styleOptionTerm(Q.optionTerm(U)),Q.styleOptionDescription(Q.optionDescription(U)))});Y=Y.concat(this.formatItemList(q,F,Q))}),Q.showGlobalOptions){let H=Q.visibleGlobalOptions(A).map((q)=>{return J(Q.styleOptionTerm(Q.optionTerm(q)),Q.styleOptionDescription(Q.optionDescription(q)))});Y=Y.concat(this.formatItemList("Global Options:",H,Q))}return this.groupItems(A.commands,Q.visibleCommands(A),(H)=>H.helpGroup()||"Commands:").forEach((H,q)=>{let F=H.map((U)=>{return J(Q.styleSubcommandTerm(Q.subcommandTerm(U)),Q.styleSubcommandDescription(Q.subcommandDescription(U)))});Y=Y.concat(this.formatItemList(q,F,Q))}),Y.join(` `)}displayWidth(A){return GOA(A).length}styleTitle(A){return A}styleUsage(A){return A.split(" ").map((Q)=>{if(Q==="[options]")return this.styleOptionText(Q);if(Q==="[command]")return this.styleSubcommandText(Q);if(Q[0]==="["||Q[0]==="<")return this.styleArgumentText(Q);return this.styleCommandText(Q)}).join(" ")}styleCommandDescription(A){return this.styleDescriptionText(A)}styleOptionDescription(A){return this.styleDescriptionText(A)}styleSubcommandDescription(A){return this.styleDescriptionText(A)}styleArgumentDescription(A){return this.styleDescriptionText(A)}styleDescriptionText(A){return A}styleOptionTerm(A){return this.styleOptionText(A)}styleSubcommandTerm(A){return A.split(" ").map((Q)=>{if(Q==="[options]")return this.styleOptionText(Q);if(Q[0]==="["||Q[0]==="<")return this.styleArgumentText(Q);return this.styleSubcommandText(Q)}).join(" ")}styleArgumentTerm(A){return this.styleArgumentText(A)}styleOptionText(A){return A}styleArgumentText(A){return A}styleSubcommandText(A){return A}styleCommandText(A){return A}padWidth(A,Q){return Math.max(Q.longestOptionTermLength(A,Q),Q.longestGlobalOptionTermLength(A,Q),Q.longestSubcommandTermLength(A,Q),Q.longestArgumentTermLength(A,Q))}preformatted(A){return/\n[^\S\r\n]/.test(A)}formatItem(A,Q,B,$){let Y=" ".repeat(2);if(!B)return Y+A;let X=A.padEnd(Q+A.length-$.displayWidth(A)),G=2,W=(this.helpWidth??80)-Q-G-2,H;if(W<this.minWidthToWrap||$.preformatted(B))H=B;else H=$.boxWrap(B,W).replace(/\n/g,` `+" ".repeat(Q+G));return Y+X+" ".repeat(G)+H.replace(/\n/g,` ${Y}`)}boxWrap(A,Q){if(Q<this.minWidthToWrap)return A;let B=A.split(/\r\n|\n/),$=/[\s]*[^\s]+/g,J=[];return B.forEach((Y)=>{let X=Y.match($);if(X===null){J.push("");return}let G=[X.shift()],K=this.displayWidth(G[0]);X.forEach((W)=>{let H=this.displayWidth(W);if(K+H<=Q){G.push(W),K+=H;return}J.push(G.join(""));let q=W.trimStart();G=[q],K=this.displayWidth(q)}),J.push(G.join(""))}),J.join(` `)}}function GOA(A){let Q=/\x1b\[\d*(;\d*)*m/g;return A.replace(Q,"")}sZQ.Help=XOA;sZQ.stripColor=GOA});var Q1A=r((BHQ)=>{var{InvalidArgumentError:AHQ}=p_();class WOA{constructor(A,Q){this.flags=A,this.description=Q||"",this.required=A.includes("<"),this.optional=A.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(A),this.mandatory=!1;let B=QHQ(A);if(this.short=B.shortFlag,this.long=B.longFlag,this.negate=!1,this.long)this.negate=this.long.startsWith("--no-");this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(A,Q){return this.defaultValue=A,this.defaultValueDescription=Q,this}preset(A){return this.presetArg=A,this}conflicts(A){return this.conflictsWith=this.conflictsWith.concat(A),this}implies(A){let Q=A;if(typeof A==="string")Q={[A]:!0};return this.implied=Object.assign(this.implied||{},Q),this}env(A){return this.envVar=A,this}argParser(A){return this.parseArg=A,this}makeOptionMandatory(A=!0){return this.mandatory=!!A,this}hideHelp(A=!0){return this.hidden=!!A,this}_collectValue(A,Q){if(Q===this.defaultValue||!Array.isArray(Q))return[A];return Q.push(A),Q}choices(A){return this.argChoices=A.slice(),this.parseArg=(Q,B)=>{if(!this.argChoices.includes(Q))throw new AHQ(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(Q,B);return Q},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){if(this.negate)return KOA(this.name().replace(/^no-/,""));return KOA(this.name())}helpGroup(A){return this.helpGroupHeading=A,this}is(A){return this.short===A||this.long===A}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class ZOA{constructor(A){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,A.forEach((Q)=>{if(Q.negate)this.negativeOptions.set(Q.attributeName(),Q);else this.positiveOptions.set(Q.attributeName(),Q)}),this.negativeOptions.forEach((Q,B)=>{if(this.positiveOptions.has(B))this.dualOptions.add(B)})}valueFromOption(A,Q){let B=Q.attributeName();if(!this.dualOptions.has(B))return!0;let $=this.negativeOptions.get(B).presetArg,J=$!==void 0?$:!1;return Q.negate===(J===A)}}function KOA(A){return A.split("-").reduce((Q,B)=>{return Q+B[0].toUpperCase()+B.slice(1)})}function QHQ(A){let Q,B,$=/^-[^-]$/,J=/^--[^-]/,Y=A.split(/[ |,]+/).concat("guard");if($.test(Y[0]))Q=Y.shift();if(J.test(Y[0]))B=Y.shift();if(!Q&&$.test(Y[0]))Q=Y.shift();if(!Q&&J.test(Y[0]))Q=B,B=Y.shift();if(Y[0].startsWith("-")){let X=Y[0],G=`option creation failed due to '${X}' in option flags '${A}'`;if(/^-[^-][^-]/.test(X))throw Error(`${G} - a short flag is a single dash and a single character - either use a single dash and a single character (for a short flag) - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if($.test(X))throw Error(`${G} - too many short flags`);if(J.test(X))throw Error(`${G} - too many long flags`);throw Error(`${G} - unrecognised flag format`)}if(Q===void 0&&B===void 0)throw Error(`option creation failed due to no flags found in '${A}'.`);return{shortFlag:Q,longFlag:B}}BHQ.Option=WOA;BHQ.DualOptions=ZOA});var HOA=r((GHQ)=>{function YHQ(A,Q){if(Math.abs(A.length-Q.length)>3)return Math.max(A.length,Q.length);let B=[];for(let $=0;$<=A.length;$++)B[$]=[$];for(let $=0;$<=Q.length;$++)B[0][$]=$;for(let $=1;$<=Q.length;$++)for(let J=1;J<=A.length;J++){let Y=1;if(A[J-1]===Q[$-1])Y=0;else Y=1;if(B[J][$]