@capgo/cli
Version:
A CLI to upload to capgo servers
79 lines (77 loc) • 2.85 MB
JavaScript
#!/usr/bin/env node
import{createRequire as KmA}from"node:module";var YmA=Object.create;var{getPrototypeOf:UmA,defineProperty:Mq,getOwnPropertyNames:DIA,getOwnPropertyDescriptor:XmA}=Object,YIA=Object.prototype.hasOwnProperty;function UIA(A){return this[A]}var HmA,FmA,_A=(A,Q,B)=>{var I=A!=null&&typeof A==="object";if(I){var E=Q?HmA??=new WeakMap:FmA??=new WeakMap,$=E.get(A);if($)return $}B=A!=null?YmA(UmA(A)):{};let G=Q||!A||!A.__esModule?Mq(B,"default",{value:A,enumerable:!0}):B;for(let J of DIA(A))if(!YIA.call(G,J))Mq(G,J,{get:UIA.bind(A,J),enumerable:!0});if(I)E.set(A,G);return G},pG=(A)=>{var Q=(JIA??=new WeakMap).get(A),B;if(Q)return Q;if(Q=Mq({},"__esModule",{value:!0}),A&&typeof A==="object"||typeof A==="function"){for(var I of DIA(A))if(!YIA.call(Q,I))Mq(Q,I,{get:UIA.bind(A,I),enumerable:!(B=XmA(A,I))||B.enumerable})}return JIA.set(A,Q),Q},JIA,g=(A,Q)=>()=>(Q||A((Q={exports:{}}).exports,Q),Q.exports);var CmA=(A)=>A;function WmA(A,Q){this[A]=CmA.bind(null,Q)}var i8=(A,Q)=>{for(var B in Q)Mq(A,B,{get:Q[B],enumerable:!0,configurable:!0,set:WmA.bind(Q,B)})};var kA=(A,Q)=>()=>(A&&(Q=A(A=0)),Q);var bA=KmA(import.meta.url);var XIA,HIA=(A)=>{return A===12288||A>=65281&&A<=65376||A>=65504&&A<=65510},FIA=(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 CIA=kA(()=>{XIA=(()=>{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 qmA,ZmA,WIA,MmA,KIA,zmA,NmA,LmA,qIA=(A,Q={},B={})=>{let I=Q.limit??1/0,E=Q.ellipsis??"",$=Q?.ellipsisWidth??(E?qIA(E,LmA,B).width:0),G=0,J=B.controlWidth??0,Y=B.tabWidth??8,X=B.emojiWidth??2,H=2,F=B.regularWidth??1,W=B.wideWidth??2,q=[[zmA,F],[qmA,0],[ZmA,J],[MmA,Y],[KIA,X],[WIA,W]],Z=0,M=0,L=A.length,O=0,T=!1,R=L,S=Math.max(0,I-$),j=0,x=0,n=0,QA=0;A:while(!0){if(x>j||M>=L&&M>Z){let m=A.slice(j,x)||A.slice(Z,M);O=0;for(let $A of m.replaceAll(NmA,"")){let r=$A.codePointAt(0)||0;if(HIA(r))QA=2;else if(FIA(r))QA=W;else QA=F;if(n+QA>S)R=Math.min(R,Math.max(j,Z)+O);if(n+QA>I){T=!0;break A}O+=$A.length,n+=QA}j=x=0}if(M>=L)break A;for(let m=0,$A=q.length;m<$A;m++){let[r,UA]=q[m];if(r.lastIndex=M,r.test(A)){if(O=r===WIA?XIA(A.slice(M,r.lastIndex)):r===KIA?1:r.lastIndex-M,QA=O*UA,n+QA>S)R=Math.min(R,M+Math.floor((S-n)/UA));if(n+QA>I){T=!0;break A}n+=QA,j=Z,x=M,M=Z=r.lastIndex;continue A}}M+=1}return{width:T?S:n,index:T?R:L,truncated:T,ellipsed:T&&I>=$}},ZIA;var MIA=kA(()=>{CIA();qmA=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,ZmA=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,WIA=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,MmA=/\t{1,1000}/y,KIA=/[\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,zmA=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,NmA=/\p{M}+/gu,LmA={limit:1/0,ellipsis:""},ZIA=qIA});var wmA,OmA=(A,Q={})=>{return ZIA(A,wmA,Q).width},lJ;var vb=kA(()=>{MIA();wmA={limit:1/0,ellipsis:"",ellipsisWidth:0},lJ=OmA});function bY(A,Q,B){return String(A).normalize().split(jmA).map((I)=>SmA(I,Q,B)).join(`
`)}var kw="\x1B",OIA="",RmA=39,xb="\x07",RIA="[",VmA="]",VIA="m",bb,zIA,NIA=(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},LIA=(A)=>`${kw}${RIA}${A}${VIA}`,wIA=(A)=>`${kw}${bb}${A}${xb}`,gb=(A,Q,B)=>{let I=Q[Symbol.iterator](),E=!1,$=!1,G=A.at(-1),J=G===void 0?0:lJ(G),Y=I.next(),X=I.next(),H=0;while(!Y.done){let F=Y.value,W=lJ(F);if(J+W<=B)A[A.length-1]+=F;else A.push(F),J=0;if(F===kw||F===OIA)E=!0,$=Q.startsWith(bb,H+1);if(E){if($){if(F===xb)E=!1,$=!1}else if(F===VIA)E=!1}else if(J+=W,J===B&&!X.done)A.push(""),J=0;Y=X,X=I.next(),H+=F.length}if(G=A.at(-1),!J&&G!==void 0&&G.length&&A.length>1)A[A.length-2]+=A.pop()},TmA=(A)=>{let Q=A.split(" "),B=Q.length;while(B){if(lJ(Q[B-1]))break;B--}if(B===Q.length)return A;return Q.slice(0,B).join(" ")+Q.slice(B).join("")},SmA=(A,Q,B={})=>{if(B.trim!==!1&&A.trim()==="")return"";let I="",E,$,G=A.split(" "),J=[""],Y=0;for(let F=0;F<G.length;F++){let W=G[F];if(B.trim!==!1){let Z=J.at(-1)??"",M=Z.trimStart();if(Z.length!==M.length)J[J.length-1]=M,Y=lJ(M)}if(F!==0){if(Y>=Q&&(B.wordWrap===!1||B.trim===!1))J.push(""),Y=0;if(Y||B.trim===!1)J[J.length-1]+=" ",Y++}let q=lJ(W);if(B.hard&&q>Q){let Z=Q-Y,M=1+Math.floor((q-Z-1)/Q);if(Math.floor((q-1)/Q)<M)J.push("");gb(J,W,Q),Y=lJ(J.at(-1)??"");continue}if(Y+q>Q&&Y&&q){if(B.wordWrap===!1&&Y<Q){gb(J,W,Q),Y=lJ(J.at(-1)??"");continue}J.push(""),Y=0}if(Y+q>Q&&B.wordWrap===!1){gb(J,W,Q),Y=lJ(J.at(-1)??"");continue}J[J.length-1]+=W,Y+=q}if(B.trim!==!1)J=J.map((F)=>TmA(F));let X=J.join(`
`),H=!1;for(let F=0;F<X.length;F++){let W=X[F];if(I+=W,!H){if(H=W>="\uD800"&&W<="\uDBFF",H)continue}else H=!1;if(W===kw||W===OIA){zIA.lastIndex=F+1;let Z=zIA.exec(X)?.groups;if(Z?.code!==void 0){let M=Number.parseFloat(Z.code);E=M===RmA?void 0:M}else if(Z?.uri!==void 0)$=Z.uri.length===0?void 0:Z.uri}if(X[F+1]===`
`){if($)I+=wIA("");let q=E?NIA(E):void 0;if(E&&q)I+=LIA(q)}else if(W===`
`){if(E&&NIA(E))I+=LIA(E);if($)I+=wIA($)}}return I},jmA;var yb=kA(()=>{vb();bb=`${VmA}8;;`,zIA=new RegExp(`(?:\\${RIA}(?<code>\\d+)m|\\${bb}(?<uri>.*)${xb})`,"y"),jmA=/\r?\n/});var hb=g((kcQ,TIA)=>{var fb={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"},PmA={up:(A=1)=>"\x1B[S".repeat(A),down:(A=1)=>"\x1B[T".repeat(A)},_mA={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?fb.up():"");if(A)Q+=fb.left;return Q}};TIA.exports={cursor:fb,scroll:PmA,erase:_mA,beep:"\x07"}});import{styleText as eH}from"node:util";import{stdout as lb,stdin as _IA}from"node:process";import*as yY from"node:readline";import kmA from"node:readline";import{ReadStream as SIA}from"node:tty";function tH(A,Q,B){if(!B.some((G)=>!G.disabled))return A;let I=A+Q,E=Math.max(B.length-1,0),$=I<0?E:I>E?0:I;return B[$].disabled?tH($,Q<0?-1:1,B):$}function vw(A,Q,B,I){let E=I.split(`
`),$=0,G=A;for(let Y of E){if(G<=Y.length)break;G-=Y.length+1,$++}for($=Math.max(0,Math.min(E.length-1,$+B)),G=Math.min(G,E[$].length)+Q;G<0&&$>0;)$--,G+=E[$].length+1;for(;G>E[$].length&&$<E.length-1;)G-=E[$].length+1,$++;G=Math.max(0,Math.min(E[$].length,G));let J=0;for(let Y=0;Y<$;Y++)J+=E[Y].length+1;return J+G}function db(A,Q){if(typeof A=="string")return J8.aliases.get(A)===Q;for(let B of A)if(B!==void 0&&db(B,Q))return!0;return!1}function xmA(A,Q){if(A===Q)return;let B=A.split(`
`),I=Q.split(`
`),E=Math.max(B.length,I.length),$=[];for(let G=0;G<E;G++)B[G]!==I[G]&&$.push(G);return{lines:$,numLinesBefore:B.length,numLinesAfter:I.length,numLines:E}}function U0(A){return A===mb}function gw(A,Q){let B=A;B.isTTY&&B.setRawMode(Q)}function kIA({input:A=_IA,output:Q=lb,overwrite:B=!0,hideCursor:I=!0}={}){let E=yY.createInterface({input:A,output:Q,prompt:"",tabSize:1});yY.emitKeypressEvents(A,E),A instanceof SIA&&A.isTTY&&A.setRawMode(!0);let $=(G,{name:J,sequence:Y})=>{let X=String(G);if(db([X,J,Y],"cancel")){I&&Q.write(z4.cursor.show),process.exit(0);return}if(!B)return;yY.moveCursor(Q,J==="return"?0:-1,J==="return"?-1:0,()=>{yY.clearLine(Q,1,()=>{A.once("keypress",$)})})};return I&&Q.write(z4.cursor.hide),A.once("keypress",$),()=>{A.off("keypress",$),I&&Q.write(z4.cursor.show),A instanceof SIA&&A.isTTY&&!bmA&&A.setRawMode(!1),E.terminal=!1,E.close()}}function zq(A,Q,B,I=B,E=B,$){let G=bw(A??lb);return bY(Q,G-B.length,{hard:!0,trim:!1}).split(`
`).map((J,Y,X)=>{let H=$?$(J,Y):J;return Y===0?`${I}${H}`:Y===X.length-1?`${E}${H}`:`${B}${H}`}).join(`
`)}function vIA(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 CD{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=_IA,output:I=lb,render:E,signal:$,...G}=A;this.opts=G,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=E.bind(this),this._track=Q,this._abortSignal=$,this.input=B,this.output=I}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)??[],I=[];for(let E of B)E.cb(...Q),E.once&&I.push(()=>B.splice(B.indexOf(E),1));for(let E of I)E()}prompt(){return new Promise((A)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),A(mb);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=kmA.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),gw(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(z4.cursor.show),this.output.off("resize",this.render),gw(this.input,!1),A(this.value)}),this.once("cancel",()=>{this.output.write(z4.cursor.show),this.output.off("resize",this.render),gw(this.input,!1),A(mb)})})}_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&&J8.aliases.has(Q.name)&&this.emit("cursor",J8.aliases.get(Q.name)),J8.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=vIA(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")}db([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(`
`),gw(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let A=bY(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
`).length-1;this.output.write(z4.cursor.move(-999,A*-1))}render(){let A=bY(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(A!==this._prevFrame){if(this.state==="initial")this.output.write(z4.cursor.hide);else{let Q=xmA(this._prevFrame,A),B=pb(this.output);if(this.restoreCursor(),Q){let I=Math.max(0,Q.numLinesAfter-B),E=Math.max(0,Q.numLinesBefore-B),$=Q.lines.find((G)=>G>=I);if($===void 0){this._prevFrame=A;return}if(Q.lines.length===1){this.output.write(z4.cursor.move(0,$-E)),this.output.write(z4.erase.lines(1));let G=A.split(`
`);this.output.write(G[$]),this._prevFrame=A,this.output.write(z4.cursor.move(0,G.length-$-1));return}else if(Q.lines.length>1){if(I<E)$=I;else{let J=$-E;J>0&&this.output.write(z4.cursor.move(0,J))}this.output.write(z4.erase.down());let G=A.split(`
`).slice($);this.output.write(G.join(`
`)),this._prevFrame=A;return}}this.output.write(z4.erase.down())}this.output.write(A),this.state==="initial"&&(this.state="active"),this._prevFrame=A}}}function ymA(A,Q){if(A===void 0||Q.length===0)return 0;let B=Q.findIndex((I)=>I.value===A);return B!==-1?B:0}function fmA(A,Q){return(Q.label??String(Q.value)).toLowerCase().includes(A.toLowerCase())}function hmA(A,Q){if(Q)return A?Q:Q[0]}function jIA(A){return[...A].map((Q)=>mmA[Q])}function cmA(A){let Q=new Intl.DateTimeFormat(A,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(2000,0,15)),B=[],I="/";for(let E of Q)E.type==="literal"?I=E.value.trim()||E.value:(E.type==="year"||E.type==="month"||E.type==="day")&&B.push({type:E.type,len:E.type==="year"?4:2});return{segments:B,separator:I}}function ub(A){return Number.parseInt((A||"0").replace(/_/g,"0"),10)||0}function xw(A){return{year:ub(A.year),month:ub(A.month),day:ub(A.day)}}function cb(A,Q){return new Date(A||2001,Q||1,0).getDate()}function gIA(A){let{year:Q,month:B,day:I}=xw(A);if(!Q||Q<0||Q>9999||!B||B<1||B>12||!I||I<1)return;let E=new Date(Date.UTC(Q,B-1,I));if(!(E.getUTCFullYear()!==Q||E.getUTCMonth()!==B-1||E.getUTCDate()!==I))return{year:Q,month:B,day:I}}function PIA(A){let Q=gIA(A);return Q?new Date(Date.UTC(Q.year,Q.month-1,Q.day)):void 0}function lmA(A,Q,B,I){let E=B?{year:B.getUTCFullYear(),month:B.getUTCMonth()+1,day:B.getUTCDate()}:null,$=I?{year:I.getUTCFullYear(),month:I.getUTCMonth()+1,day:I.getUTCDate()}:null;return A==="year"?{min:E?.year??1,max:$?.year??9999}:A==="month"?{min:E&&Q.year===E.year?E.month:1,max:$&&Q.year===$.year?$.month:12}:{min:E&&Q.year===E.year&&Q.month===E.month?E.day:1,max:$&&Q.year===$.year&&Q.month===$.month?$.day:cb(Q.year,Q.month)}}var z4,vmA,gmA,J8,bmA,mb,bw=(A)=>("columns"in A)&&typeof A.columns=="number"?A.columns:80,pb=(A)=>("rows"in A)&&typeof A.rows=="number"?A.rows:20,umA,nb,mmA,xIA,dmA,pmA,bIA,ib,rb,ob;var ab=kA(()=>{yb();z4=_A(hb(),1);vmA=["up","down","left","right","space","enter","cancel"],gmA=["January","February","March","April","May","June","July","August","September","October","November","December"],J8={actions:new Set(vmA),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:[...gmA],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)}`}}};bmA=globalThis.process.platform.startsWith("win"),mb=Symbol("clack:cancel");umA=class extends CD{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#Q=0;#E="";#A;#$;#J;get cursor(){return this.#Q}get userInputWithCursor(){if(!this.userInput)return eH(["inverse","hidden"],"_");if(this._cursor>=this.userInput.length)return`${this.userInput}█`;let Q=this.userInput.slice(0,this._cursor),[B,...I]=this.userInput.slice(this._cursor);return`${Q}${eH("inverse",B)}${I.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.#A=typeof Q.options=="function"?Q.filter:Q.filter??fmA;let I;if(Q.initialValue&&Array.isArray(Q.initialValue)?this.multiple?I=Q.initialValue:I=Q.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(I=[this.options[0].value]),I)for(let E of I){let $=B.findIndex((G)=>G.value===E);$!==-1&&(this.toggleSelected(E),this.#Q=$)}this.focusedValue=this.options[this.#Q]?.value,this.on("key",(E,$)=>this.#B(E,$)),this.on("userInput",(E)=>this.#I(E))}_isActionKey(Q,B){return Q==="\t"||this.multiple&&this.isNavigating&&B.name==="space"&&Q!==void 0&&Q!==""}#B(Q,B){let I=B.name==="up",E=B.name==="down",$=B.name==="return",G=this.userInput===""||this.userInput==="\t",J=this.#J,Y=this.options,X=J!==void 0&&J!==""&&Y.some((H)=>!H.disabled&&(this.#A?this.#A(J,H):!0));if(B.name==="tab"&&G&&X){this.userInput==="\t"&&this._clearUserInput(),this._setUserInput(J,!0),this.isNavigating=!1;return}I||E?(this.#Q=tH(this.#Q,I?-1:1,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#Q]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):$?this.value=hmA(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])}#I(Q){if(Q!==this.#E){this.#E=Q;let B=this.options;Q&&this.#A?this.filteredOptions=B.filter(($)=>this.#A?.(Q,$)):this.filteredOptions=[...B];let I=ymA(this.focusedValue,this.filteredOptions);this.#Q=tH(I,0,this.filteredOptions);let E=this.filteredOptions[this.#Q];E&&!E.disabled?this.focusedValue=E.value:this.focusedValue=void 0,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}};nb=class nb extends CD{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(z4.cursor.move(0,-1)),this.value=Q,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};mmA={Y:{type:"year",len:4},M:{type:"month",len:2},D:{type:"day",len:2}};xIA=class xIA extends CD{#Q;#E;#A;#$;#J;#B={segmentIndex:0,positionInSegment:0};#I=!0;#G=null;inlineError="";get segmentCursor(){return{...this.#B}}get segmentValues(){return{...this.#A}}get segments(){return this.#Q}get separator(){return this.#E}get formattedValue(){return this.#X(this.#A)}#X(A){return this.#Q.map((Q)=>A[Q.type]).join(this.#E)}#D(){this._setUserInput(this.#X(this.#A)),this._setValue(PIA(this.#A)??void 0)}constructor(A){let Q=A.format?{segments:jIA(A.format),separator:A.separator??"/"}:cmA(A.locale),B=A.separator??Q.separator,I=A.format?jIA(A.format):Q.segments,E=A.initialValue??A.defaultValue,$=E?{year:String(E.getUTCFullYear()).padStart(4,"0"),month:String(E.getUTCMonth()+1).padStart(2,"0"),day:String(E.getUTCDate()).padStart(2,"0")}:{year:"____",month:"__",day:"__"},G=I.map((J)=>$[J.type]).join(B);super({...A,initialUserInput:G},!1),this.#Q=I,this.#E=B,this.#A=$,this.#$=A.minDate,this.#J=A.maxDate,this.#D(),this.on("cursor",(J)=>this.#C(J)),this.on("key",(J,Y)=>this.#W(J,Y)),this.on("finalize",()=>this.#K(A))}#Y(){let A=Math.max(0,Math.min(this.#B.segmentIndex,this.#Q.length-1)),Q=this.#Q[A];if(Q)return this.#B.positionInSegment=Math.max(0,Math.min(this.#B.positionInSegment,Q.len-1)),{segment:Q,index:A}}#U(A){this.inlineError="",this.#G=null;let Q=this.#Y();Q&&(this.#B.segmentIndex=Math.max(0,Math.min(this.#Q.length-1,Q.index+A)),this.#B.positionInSegment=0,this.#I=!0)}#H(A){let Q=this.#Y();if(!Q)return;let{segment:B}=Q,I=this.#A[B.type],E=!I||I.replace(/_/g,"")==="",$=Number.parseInt((I||"0").replace(/_/g,"0"),10)||0,G=lmA(B.type,xw(this.#A),this.#$,this.#J),J;E?J=A===1?G.min:G.max:J=Math.max(Math.min(G.max,$+A),G.min),this.#A={...this.#A,[B.type]:J.toString().padStart(B.len,"0")},this.#I=!0,this.#G=null,this.#D()}#C(A){if(A)switch(A){case"right":return this.#U(1);case"left":return this.#U(-1);case"up":return this.#H(1);case"down":return this.#H(-1)}}#W(A,Q){if(Q?.name==="backspace"||Q?.sequence===""||Q?.sequence==="\b"||A===""||A==="\b"){this.inlineError="";let B=this.#Y();if(!B)return;if(!this.#A[B.segment.type].replace(/_/g,"")){this.#U(-1);return}this.#A[B.segment.type]="_".repeat(B.segment.len),this.#I=!0,this.#B.positionInSegment=0,this.#D();return}if(Q?.name==="tab"){this.inlineError="";let B=this.#Y();if(!B)return;let I=Q.shift?-1:1,E=B.index+I;E>=0&&E<this.#Q.length&&(this.#B.segmentIndex=E,this.#B.positionInSegment=0,this.#I=!0);return}if(A&&/^[0-9]$/.test(A)){let B=this.#Y();if(!B)return;let{segment:I}=B,E=!this.#A[I.type].replace(/_/g,"");if(this.#I&&this.#G!==null&&!E){let W=this.#G+A,q={...this.#A,[I.type]:W},Z=this.#F(q,I);if(Z){this.inlineError=Z,this.#G=null,this.#I=!1;return}this.inlineError="",this.#A[I.type]=W,this.#G=null,this.#I=!1,this.#D(),B.index<this.#Q.length-1&&(this.#B.segmentIndex=B.index+1,this.#B.positionInSegment=0,this.#I=!0);return}this.#I&&!E&&(this.#A[I.type]="_".repeat(I.len),this.#B.positionInSegment=0),this.#I=!1,this.#G=null;let $=this.#A[I.type],G=$.indexOf("_"),J=G>=0?G:Math.min(this.#B.positionInSegment,I.len-1);if(J<0||J>=I.len)return;let Y=$.slice(0,J)+A+$.slice(J+1),X=!1;if(J===0&&$==="__"&&(I.type==="month"||I.type==="day")){let W=Number.parseInt(A,10);Y=`0${A}`,X=W<=(I.type==="month"?1:2)}if(I.type==="year"&&(Y=($.replace(/_/g,"")+A).padStart(I.len,"_")),!Y.includes("_")){let W={...this.#A,[I.type]:Y},q=this.#F(W,I);if(q){this.inlineError=q;return}}this.inlineError="",this.#A[I.type]=Y;let H=Y.includes("_")?void 0:gIA(this.#A);if(H){let{year:W,month:q}=H,Z=cb(W,q);this.#A={year:String(Math.max(0,Math.min(9999,W))).padStart(4,"0"),month:String(Math.max(1,Math.min(12,q))).padStart(2,"0"),day:String(Math.max(1,Math.min(Z,H.day))).padStart(2,"0")}}this.#D();let F=Y.indexOf("_");X?(this.#I=!0,this.#G=A):F>=0?this.#B.positionInSegment=F:G>=0&&B.index<this.#Q.length-1?(this.#B.segmentIndex=B.index+1,this.#B.positionInSegment=0,this.#I=!0):this.#B.positionInSegment=Math.min(J+1,I.len-1)}}#F(A,Q){let{month:B,day:I}=xw(A);if(Q.type==="month"&&(B<0||B>12))return J8.date.messages.invalidMonth;if(Q.type==="day"&&(I<0||I>31))return J8.date.messages.invalidDay(31,"any month")}#K(A){let{year:Q,month:B,day:I}=xw(this.#A);if(Q&&B&&I){let E=cb(Q,B);this.#A={...this.#A,day:String(Math.min(I,E)).padStart(2,"0")}}this.value=PIA(this.#A)??A.defaultValue??void 0}};dmA=class extends CD{options;cursor=0;#Q;getGroupItems(Q){return this.options.filter((B)=>B.group===Q)}isGroupSelected(Q){let B=this.getGroupItems(Q),I=this.value;return I===void 0?!1:B.every((E)=>I.includes(E.value))}toggleValue(){let Q=this.options[this.cursor];if(this.value===void 0&&(this.value=[]),Q.group===!0){let B=Q.value,I=this.getGroupItems(B);this.isGroupSelected(B)?this.value=this.value.filter((E)=>I.findIndex(($)=>$.value===E)===-1):this.value=[...this.value,...I.map((E)=>E.value)],this.value=Array.from(new Set(this.value))}else{let B=this.value.includes(Q.value);this.value=B?this.value.filter((I)=>I!==Q.value):[...this.value,Q.value]}}constructor(Q){super(Q,!1);let{options:B}=Q;this.#Q=Q.selectableGroups!==!1,this.options=Object.entries(B).flatMap(([I,E])=>[{value:I,group:!0,label:I},...E.map(($)=>({...$,group:I}))]),this.value=[...Q.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:I})=>I===Q.cursorAt),this.#Q?0:1),this.on("cursor",(I)=>{switch(I){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let E=this.options[this.cursor]?.group===!0;!this.#Q&&E&&(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 E=this.options[this.cursor]?.group===!0;!this.#Q&&E&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}},pmA=new Set(["up","down","left","right"]);bIA=class bIA extends CD{#Q=!1;#E;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],I=A.slice(this.cursor+1);return B===`
`?`${Q}█
${I}`:`${Q}${eH("inverse",B)}${I}`}get cursor(){return this._cursor}#A(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=vw(this._cursor,0,-1,Q);return;case"down":this._cursor=vw(this._cursor,0,1,Q);return;case"left":this._cursor=vw(this._cursor,-1,0,Q);return;case"right":this._cursor=vw(this._cursor,1,0,Q);return}}_shouldSubmit(A,Q){if(this.#E)return this.focused==="submit"?!0:(this.#A(`
`),this._cursor++,!1);let B=this.#Q;return this.#Q=!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.#A(`
`),this._cursor++,!1)}constructor(A){super(A,!1),this.#E=A.showSubmit??!1,this.on("key",(Q,B)=>{if(B?.name&&pmA.has(B.name)){this.#$(B.name);return}if(Q==="\t"&&this.#E){this.focused=this.focused==="editor"?"submit":"editor";return}if(B?.name!=="return"){if(this.#Q=!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.#E&&this.focused==="submit"&&(this.focused="editor"),this.#A(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="")})}};ib=class ib extends CD{_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}${eH(["inverse","hidden"],"_")}`;let Q=this.masked,B=Q.slice(0,this.cursor),I=Q.slice(this.cursor);return`${B}${eH("inverse",I[0])}${I.slice(1)}`}clear(){this._clearUserInput()}constructor({mask:A,...Q}){super(Q),this._mask=A??"•",this.on("userInput",(B)=>{this._setValue(B)})}};rb=class rb extends CD{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:I})=>I===A.initialValue),B=Q===-1?0:Q;this.cursor=this.options[B].disabled?tH(B,1,this.options):B,this.changeValue(),this.on("cursor",(I)=>{switch(I){case"left":case"up":this.cursor=tH(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=tH(this.cursor,1,this.options);break}this.changeValue()})}};ob=class ob extends CD{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,...I]=A.slice(this.cursor);return`${Q}${eH("inverse",B)}${I.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 xQ,stripVTControlCharacters as dcQ}from"node:util";import nG from"node:process";function nmA(){if(nG.platform!=="win32")return nG.env.TERM!=="linux";return Boolean(nG.env.CI)||Boolean(nG.env.WT_SESSION)||Boolean(nG.env.TERMINUS_SUBLIME)||nG.env.ConEmuTask==="{cmd::Cmder}"||nG.env.TERM_PROGRAM==="Terminus-Sublime"||nG.env.TERM_PROGRAM==="vscode"||nG.env.TERM==="xterm-256color"||nG.env.TERM==="alacritty"||nG.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var Nq,sb,imA=()=>process.env.CI==="true",cI=(A,Q)=>sb?A:Q,rmA,fIA,hIA,eb,omA,zI,fY,rcQ,ocQ,tb,fw,acQ,scQ,tcQ,amA,ecQ,AlQ,QlQ,BlQ,IlQ,ElQ,smA,tmA,emA,AcA,hw=(A)=>{switch(A){case"initial":case"active":return xQ("cyan",rmA);case"cancel":return xQ("red",fIA);case"error":return xQ("yellow",hIA);case"submit":return xQ("green",eb)}},QcA=(A)=>{switch(A){case"initial":case"active":return xQ("cyan",zI);case"cancel":return xQ("red",zI);case"error":return xQ("yellow",zI);case"submit":return xQ("green",zI)}},yIA=(A,Q,B,I,E,$=!1)=>{let G=Q,J=0;if($)for(let Y=I-1;Y>=B&&(G-=A[Y].length,J++,!(G<=E));Y--);else for(let Y=B;Y<I&&(G-=A[Y].length,J++,!(G<=E));Y++);return{lineCount:G,removals:J}},BcA=({cursor:A,options:Q,style:B,output:I=process.stdout,maxItems:E=Number.POSITIVE_INFINITY,columnPadding:$=0,rowPadding:G=4})=>{let J=bw(I)-$,Y=pb(I),X=xQ("dim","..."),H=Math.max(Y-G,0),F=Math.max(Math.min(E,H),5),W=0;A>=F-3&&(W=Math.max(Math.min(A-F+3,Q.length-F),0));let q=F<Q.length&&W>0,Z=F<Q.length&&W+F<Q.length,M=Math.min(W+F,Q.length),L=[],O=0;q&&O++,Z&&O++;let T=W+(q?1:0),R=M-(Z?1:0);for(let j=T;j<R;j++){let x=bY(B(Q[j],j===A),J,{hard:!0,trim:!1}).split(`
`);L.push(x),O+=x.length}if(O>H){let j=0,x=0,n=O,QA=A-T,m=H,$A=()=>yIA(L,n,0,QA,m),r=()=>yIA(L,n,QA+1,L.length,m,!0);q?({lineCount:n,removals:j}=$A(),n>m&&(Z||(m-=1),{lineCount:n,removals:x}=r())):(Z||(m-=1),{lineCount:n,removals:x}=r(),n>m&&(m-=1,{lineCount:n,removals:j}=$A())),j>0&&(q=!0,L.splice(0,j)),x>0&&(Z=!0,L.splice(L.length-x,x))}let S=[];q&&S.push(X);for(let j of L)for(let x of j)S.push(x);return Z&&S.push(X),S},H1=(A)=>{let Q=A.active??"Yes",B=A.inactive??"No";return new nb({active:Q,inactive:B,signal:A.signal,input:A.input,output:A.output,initialValue:A.initialValue??!0,render(){let I=A.withGuide??J8.withGuide,E=`${hw(this.state)} `,$=I?`${xQ("gray",zI)} `:"",G=zq(A.output,A.message,$,E),J=`${I?`${xQ("gray",zI)}
`:""}${G}
`,Y=this.value?Q:B;switch(this.state){case"submit":{let X=I?`${xQ("gray",zI)} `:"";return`${J}${X}${xQ("dim",Y)}`}case"cancel":{let X=I?`${xQ("gray",zI)} `:"";return`${J}${X}${xQ(["strikethrough","dim"],Y)}${I?`
${xQ("gray",zI)}`:""}`}default:{let X=I?`${xQ("cyan",zI)} `:"",H=I?xQ("cyan",fY):"";return`${J}${X}${this.value?`${xQ("green",tb)} ${Q}`:`${xQ("dim",fw)} ${xQ("dim",Q)}`}${A.vertical?I?`
${xQ("cyan",zI)} `:`
`:` ${xQ("dim","/")} `}${this.value?`${xQ("dim",fw)} ${xQ("dim",B)}`:`${xQ("green",tb)} ${B}`}
${H}
`}}}}).prompt()},w,uIA=(A="",Q)=>{let B=Q?.output??process.stdout,I=Q?.withGuide??J8.withGuide?`${xQ("gray",fY)} `:"";B.write(`${I}${xQ("red",A)}
`)},DB=(A="",Q)=>{let B=Q?.output??process.stdout,I=Q?.withGuide??J8.withGuide?`${xQ("gray",omA)} `:"";B.write(`${I}${A}
`)},YB=(A="",Q)=>{let B=Q?.output??process.stdout,I=Q?.withGuide??J8.withGuide?`${xQ("gray",zI)}
${xQ("gray",fY)} `:"";B.write(`${I}${A}
`)},mIA=(A)=>new ib({validate:A.validate,mask:A.mask??amA,signal:A.signal,input:A.input,output:A.output,render(){let Q=A.withGuide??J8.withGuide,B=`${Q?`${xQ("gray",zI)}
`:""}${hw(this.state)} ${A.message}
`,I=this.userInputWithCursor,E=this.masked;switch(this.state){case"error":{let $=Q?`${xQ("yellow",zI)} `:"",G=Q?`${xQ("yellow",fY)} `:"",J=E??"";return A.clearOnError&&this.clear(),`${B.trim()}
${$}${J}
${G}${xQ("yellow",this.error)}
`}case"submit":{let $=Q?`${xQ("gray",zI)} `:"",G=E?xQ("dim",E):"";return`${B}${$}${G}`}case"cancel":{let $=Q?`${xQ("gray",zI)} `:"",G=E?xQ(["strikethrough","dim"],E):"";return`${B}${$}${G}${E&&Q?`
${xQ("gray",zI)}`:""}`}default:{let $=Q?`${xQ("cyan",zI)} `:"",G=Q?xQ("cyan",fY):"";return`${B}${$}${I}
${G}
`}}}}).prompt(),IcA=(A)=>xQ("magenta",A),F1=({indicator:A="dots",onCancel:Q,output:B=process.stdout,cancelMessage:I,errorMessage:E,frames:$=sb?["◒","◐","◓","◑"]:["•","o","O","0"],delay:G=sb?80:120,signal:J,...Y}={})=>{let X=imA(),H,F,W=!1,q=!1,Z="",M,L=performance.now(),O=bw(B),T=Y?.styleFrame??IcA,R=(SA)=>{let o=SA>1?E??J8.messages.error:I??J8.messages.cancel;q=SA===1,W&&(WA(o,SA),q&&typeof Q=="function"&&Q())},S=()=>R(2),j=()=>R(1),x=()=>{process.on("uncaughtExceptionMonitor",S),process.on("unhandledRejection",S),process.on("SIGINT",j),process.on("SIGTERM",j),process.on("exit",R),J&&J.addEventListener("abort",j)},n=()=>{process.removeListener("uncaughtExceptionMonitor",S),process.removeListener("unhandledRejection",S),process.removeListener("SIGINT",j),process.removeListener("SIGTERM",j),process.removeListener("exit",R),J&&J.removeEventListener("abort",j)},QA=()=>{if(M===void 0)return;X&&B.write(`
`);let SA=bY(M,O,{hard:!0,trim:!1}).split(`
`);SA.length>1&&B.write(Nq.cursor.up(SA.length-1)),B.write(Nq.cursor.to(0)),B.write(Nq.erase.down())},m=(SA)=>SA.replace(/\.+$/,""),$A=(SA)=>{let o=(performance.now()-SA)/1000,_=Math.floor(o/60),v=Math.floor(o%60);return _>0?`[${_}m ${v}s]`:`[${v}s]`},r=Y.withGuide??J8.withGuide,UA=(SA="")=>{W=!0,H=kIA({output:B}),Z=m(SA),L=performance.now(),r&&B.write(`${xQ("gray",zI)}
`);let o=0,_=0;x(),F=setInterval(()=>{if(X&&Z===M)return;QA(),M=Z;let v=T($[o]),b;if(X)b=`${v} ${Z}...`;else if(A==="timer")b=`${v} ${Z} ${$A(L)}`;else{let i=".".repeat(Math.floor(_)).slice(0,3);b=`${v} ${Z}${i}`}let s=bY(b,O,{hard:!0,trim:!1});B.write(s),o=o+1<$.length?o+1:0,_=_<4?_+0.125:0},G)},WA=(SA="",o=0,_=!1)=>{if(!W)return;W=!1,clearInterval(F),QA();let v=o===0?xQ("green",eb):o===1?xQ("red",fIA):xQ("red",hIA);Z=SA??Z,_||(A==="timer"?B.write(`${v} ${Z} ${$A(L)}
`):B.write(`${v} ${Z}
`)),n(),H()};return{start:UA,stop:(SA="")=>WA(SA,0),message:(SA="")=>{Z=m(SA??Z)},cancel:(SA="")=>WA(SA,1),error:(SA="")=>WA(SA,2),clear:()=>WA("",0,!0),get isCancelled(){return q}}},$lQ,yw=(A,Q)=>A.includes(`
`)?A.split(`
`).map((B)=>Q(B)).join(`
`):Q(A),D8=(A)=>{let Q=(B,I)=>{let E=B.label??String(B.value);switch(I){case"disabled":return`${xQ("gray",fw)} ${yw(E,($)=>xQ("gray",$))}${B.hint?` ${xQ("dim",`(${B.hint??"disabled"})`)}`:""}`;case"selected":return`${yw(E,($)=>xQ("dim",$))}`;case"active":return`${xQ("green",tb)} ${E}${B.hint?` ${xQ("dim",`(${B.hint})`)}`:""}`;case"cancelled":return`${yw(E,($)=>xQ(["strikethrough","dim"],$))}`;default:return`${xQ("dim",fw)} ${yw(E,($)=>xQ("dim",$))}`}};return new rb({options:A.options,signal:A.signal,input:A.input,output:A.output,initialValue:A.initialValue,render(){let B=A.withGuide??J8.withGuide,I=`${hw(this.state)} `,E=`${QcA(this.state)} `,$=zq(A.output,A.message,E,I),G=`${B?`${xQ("gray",zI)}
`:""}${$}
`;switch(this.state){case"submit":{let J=B?`${xQ("gray",zI)} `:"",Y=zq(A.output,Q(this.options[this.cursor],"selected"),J);return`${G}${Y}`}case"cancel":{let J=B?`${xQ("gray",zI)} `:"",Y=zq(A.output,Q(this.options[this.cursor],"cancelled"),J);return`${G}${Y}${B?`
${xQ("gray",zI)}`:""}`}default:{let J=B?`${xQ("cyan",zI)} `:"",Y=B?xQ("cyan",fY):"",X=G.split(`
`).length,H=B?2:1;return`${G}${J}${BcA({output:A.output,cursor:this.cursor,options:this.options,maxItems:A.maxItems,columnPadding:J.length,rowPadding:X+H,style:(F,W)=>Q(F,F.disabled?"disabled":W?"active":"inactive")}).join(`
${J}`)}
${Y}
`}}}}).prompt()},GlQ,hY=(A)=>new ob({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??J8.withGuide,B=`${`${Q?`${xQ("gray",zI)}
`:""}${hw(this.state)} `}${A.message}
`,I=A.placeholder?xQ("inverse",A.placeholder[0])+xQ("dim",A.placeholder.slice(1)):xQ(["inverse","hidden"],"_"),E=this.userInput?this.userInputWithCursor:I,$=this.value??"";switch(this.state){case"error":{let G=this.error?` ${xQ("yellow",this.error)}`:"",J=Q?`${xQ("yellow",zI)} `:"",Y=Q?xQ("yellow",fY):"";return`${B.trim()}
${J}${E}
${Y}${G}
`}case"submit":{let G=$?` ${xQ("dim",$)}`:"",J=Q?xQ("gray",zI):"";return`${B}${J}${G}`}case"cancel":{let G=$?` ${xQ(["strikethrough","dim"],$)}`:"",J=Q?xQ("gray",zI):"";return`${B}${J}${G}${$.trim()?`
${J}`:""}`}default:{let G=Q?`${xQ("cyan",zI)} `:"",J=Q?xQ("cyan",fY):"";return`${B}${G}${E}
${J}
`}}}}).prompt();var fB=kA(()=>{ab();ab();yb();vb();Nq=_A(hb(),1);sb=nmA(),rmA=cI("◆","*"),fIA=cI("■","x"),hIA=cI("▲","x"),eb=cI("◇","o"),omA=cI("┌","T"),zI=cI("│","|"),fY=cI("└","—"),rcQ=cI("┐","T"),ocQ=cI("┘","—"),tb=cI("●",">"),fw=cI("○"," "),acQ=cI("◻","[•]"),scQ=cI("◼","[+]"),tcQ=cI("◻","[ ]"),amA=cI("▪","•"),ecQ=cI("─","-"),AlQ=cI("╮","+"),QlQ=cI("├","+"),BlQ=cI("╯","+"),IlQ=cI("╰","+"),ElQ=cI("╭","+"),smA=cI("●","•"),tmA=cI("◆","*"),emA=cI("▲","!"),AcA=cI("■","x"),w={message:(A=[],{symbol:Q=xQ("gray",zI),secondarySymbol:B=xQ("gray",zI),output:I=process.stdout,spacing:E=1,withGuide:$}={})=>{let G=[],J=$??J8.withGuide,Y=J?B:"",X=J?`${Q} `:"",H=J?`${B} `:"";for(let W=0;W<E;W++)G.push(Y);let F=Array.isArray(A)?A:A.split(`
`);if(F.length>0){let[W,...q]=F;W.length>0?G.push(`${X}${W}`):G.push(J?Q:"");for(let Z of q)Z.length>0?G.push(`${H}${Z}`):G.push(J?B:"")}I.write(`${G.join(`
`)}
`)},info:(A,Q)=>{w.message(A,{...Q,symbol:xQ("blue",smA)})},success:(A,Q)=>{w.message(A,{...Q,symbol:xQ("green",tmA)})},step:(A,Q)=>{w.message(A,{...Q,symbol:xQ("green",eb)})},warn:(A,Q)=>{w.message(A,{...Q,symbol:xQ("yellow",emA)})},warning:(A,Q)=>{w.warn(A,Q)},error:(A,Q)=>{w.message(A,{...Q,symbol:xQ("red",AcA)})}},$lQ={light:cI("─","-"),heavy:cI("━","="),block:cI("█","#")},GlQ=`${xQ("gray",zI)} `});var Lq=g((EcA)=>{class Ay 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 cIA extends Ay{constructor(A){super(1,"commander.invalidArgument",A);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}EcA.CommanderError=Ay;EcA.InvalidArgumentError=cIA});var uw=g((YcA)=>{var{InvalidArgumentError:JcA}=Lq();class lIA{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 JcA(`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 DcA(A){let Q=A.name()+(A.variadic===!0?"...":"");return A.required?"<"+Q+">":"["+Q+"]"}YcA.Argument=lIA;YcA.humanReadableArgName=DcA});var Qy=g((FcA)=>{var{humanReadableArgName:HcA}=uw();class dIA{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((I)=>!I._hidden),B=A._getHelpCommand();if(B&&!B._hidden)Q.push(B);if(this.sortSubcommands)Q.sort((I,E)=>{return I.name().localeCompare(E.name())});return Q}compareOptions(A,Q){let B=(I)=>{return I.short?I.short.replace(/^-/,""):I.long.replace(/^--/,"")};return B(A).localeCompare(B(Q))}visibleOptions(A){let Q=A.options.filter((I)=>!I.hidden),B=A._getHelpOption();if(B&&!B.hidden){let I=B.short&&A._findOption(B.short),E=B.long&&A._findOption(B.long);if(!I&&!E)Q.push(B);else if(B.long&&!E)Q.push(A.createOption(B.long,B.description));else if(B.short&&!I)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 I=B.options.filter((E)=>!E.hidden);Q.push(...I)}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)=>HcA(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,I)=>{return Math.max(B,this.displayWidth(Q.styleSubcommandTerm(Q.subcommandTerm(I))))},0)}longestOptionTermLength(A,Q){return Q.visibleOptions(A).reduce((B,I)=>{return Math.max(B,this.displayWidth(Q.styleOptionTerm(Q.optionTerm(I))))},0)}longestGlobalOptionTermLength(A,Q){return Q.visibleGlobalOptions(A).reduce((B,I)=>{return Math.max(B,this.displayWidth(Q.styleOptionTerm(Q.optionTerm(I))))},0)}longestArgumentTermLength(A,Q){return Q.visibleArguments(A).reduce((B,I)=>{return Math.max(B,this.displayWidth(Q.styleArgumentTerm(Q.argumentTerm(I))))},0)}commandUsage(A){let Q=A._name;if(A._aliases[0])Q=Q+"|"+A._aliases[0];let B="";for(let I=A.parent;I;I=I.parent)B=I.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 I=new Map;return A.forEach((E)=>{let $=B(E);if(!I.has($))I.set($,[])}),Q.forEach((E)=>{let $=B(E);if(!I.has($))I.set($,[]);I.get($).push(E)}),I}formatHelp(A,Q){let B=Q.padWidth(A,Q),I=Q.helpWidth??80;function E(H,F){return Q.formatItem(H,B,F,Q)}let $=[`${Q.styleTitle("Usage:")} ${Q.styleUsage(Q.commandUsage(A))}`,""],G=Q.commandDescription(A);if(G.length>0)$=$.concat([Q.boxWrap(Q.styleCommandDescription(G),I),""]);let J=Q.visibleArguments(A).map((H)=>{return E(Q.styleArgumentTerm(Q.argumentTerm(H)),Q.styleArgumentDescription(Q.argumentDescription(H)))});if($=$.concat(this.formatItemList("Arguments:",J,Q)),this.groupItems(A.options,Q.visibleOptions(A),(H)=>H.helpGroupHeading??"Options:").forEach((H,F)=>{let W=H.map((q)=>{return E(Q.styleOptionTerm(Q.optionTerm(q)),Q.styleOptionDescription(Q.optionDescription(q)))});$=$.concat(this.formatItemList(F,W,Q))}),Q.showGlobalOptions){let H=Q.visibleGlobalOptions(A).map((F)=>{return E(Q.styleOptionTerm(Q.optionTerm(F)),Q.styleOptionDescription(Q.optionDescription(F)))});$=$.concat(this.formatItemList("Global Options:",H,Q))}return this.groupItems(A.commands,Q.visibleCommands(A),(H)=>H.helpGroup()||"Commands:").forEach((H,F)=>{let W=H.map((q)=>{return E(Q.styleSubcommandTerm(Q.subcommandTerm(q)),Q.styleSubcommandDescription(Q.subcommandDescription(q)))});$=$.concat(this.formatItemList(F,W,Q))}),$.join(`
`)}displayWidth(A){return pIA(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,I){let $=" ".repeat(2);if(!B)return $+A;let G=A.padEnd(Q+A.length-I.displayWidth(A)),J=2,X=(this.helpWidth??80)-Q-J-2,H;if(X<this.minWidthToWrap||I.preformatted(B))H=B;else H=I.boxWrap(B,X).replace(/\n/g,`
`+" ".repeat(Q+J));return $+G+" ".repeat(J)+H.replace(/\n/g,`
${$}`)}boxWrap(A,Q){if(Q<this.minWidthToWrap)return A;let B=A.split(/\r\n|\n/),I=/[\s]*[^\s]+/g,E=[];return B.forEach(($)=>{let G=$.match(I);if(G===null){E.push("");return}let J=[G.shift()],Y=this.displayWidth(J[0]);G.forEach((X)=>{let H=this.displayWidth(X);if(Y+H<=Q){J.push(X),Y+=H;return}E.push(J.join(""));let F=X.trimStart();J=[F],Y=this.displayWidth(F)}),E.push(J.join(""))}),E.join(`
`)}}function pIA(A){let Q=/\x1b\[\d*(;\d*)*m/g;return A.replace(Q,"")}FcA.Help=dIA;FcA.stripColor=pIA});var By=g((ZcA)=>{var{InvalidArgumentError:KcA}=Lq();class iIA{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=qcA(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 KcA(`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 nIA(this.name().replace(/^no-/,""));return nIA(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 rIA{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 I=this.negativeOptions.get(B).presetArg,E=I!==void 0?I:!1;return Q.negate===(E===A)}}function nIA(A){return A.split("-").reduce((Q,B)=>{return Q+B[0].toUpperCase()+B.slice(1)})}function qcA(A){let Q,B,I=/^-[^-]$/,E=/^--[^-]/,$=A.split(/[ |,]+/).concat("guard");if(I.test($[0]))Q=$.shift();if(E.test($[0]))B=$.shift();if(!Q&&I.test($[0]))Q=$.shift();if(!Q&&E.test($[0]))Q=B,B=$.shift();if($[0].startsWith("-")){let G=$[0],J=`option creation failed due to '${G}' in option flags '${A}'`;if(/^-[^-][^-]/.test(G))throw Error(`${J}
- 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(I.test(G))throw Error(`${J}
- too many short flags`);if(E.test(G))throw Error(`${J}
- too many long flags`);throw Error(`${J}
- 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}}ZcA.Option=iIA;ZcA.DualOptions=rIA});var oIA=g((wcA)=>{function NcA(A,Q){if(Math.abs(A.length-Q.length)>3)return Math.max(A.length,Q.length);let B=[];for(let I=0;I<=A.length;I++)B[I]=[I];for(let I=0;I<=Q.length;I++)B[0][I]=I;for(let I=1;I<=Q.length;I++)for(let E=1;E<=A.length;E++){let $=1;if(A[E-1]===Q[I-1])$=0;else $=1;if(B[E][I]=Math.min(B[E-1][I]+1,B[E][I-1]+1,B[E-1][I-1]+$),E