You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@clack/prompts

Package Overview
Dependencies
Maintainers
5
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@clack/prompts - npm Package Compare versions

Comparing version
1.0.0-alpha.4
to
1.0.0-alpha.5
+20
-0
CHANGELOG.md
# @clack/prompts
## 1.0.0-alpha.5
### Minor Changes
- 55645c2: Support wrapping autocomplete and select prompts.
### Patch Changes
- 9999adf: fix note component overflow bug
- 2839c66: fix(note): hard wrap text to column limit
- 71b5029: Add missing nullish checks around values.
- d25f6d0: fix(note, box): handle CJK correctly
- 0b852e1: Handle `stop` calls on spinners which have not yet been started.
- 09e596c: refactor(progress): remove unnecessary return statement in start function
- 2310b43: Allow custom writables as output stream.
- Updated dependencies [71b5029]
- Updated dependencies [55645c2]
- Updated dependencies [2310b43]
- @clack/core@1.0.0-alpha.5
## 1.0.0-alpha.4

@@ -4,0 +24,0 @@

+5
-2

@@ -34,3 +34,3 @@ import { State, AutocompletePrompt } from '@clack/core';

declare const S_ERROR: string;
declare const symbol: (state: State) => string | undefined;
declare const symbol: (state: State) => string;
interface CommonOptions {

@@ -197,2 +197,4 @@ input?: Readable;

style: (option: TOption, active: boolean) => string;
columnPadding?: number;
rowPadding?: number;
}

@@ -231,4 +233,5 @@ declare const limitOptions: <TOption>(params: LimitOptionsParams<TOption>) => string[];

type FormatFn = (line: string) => string;
interface NoteOptions extends CommonOptions {
format?: (line: string) => string;
format?: FormatFn;
}

@@ -235,0 +238,0 @@ declare const note: (message?: string, title?: string, opts?: NoteOptions) => void;

@@ -1,119 +0,123 @@

import{AutocompletePrompt as ye,getColumns as te,ConfirmPrompt as Je,isCancel as Xe,GroupMultiSelectPrompt as Ye,MultiSelectPrompt as ze,PasswordPrompt as Ze,block as Qe,settings as Ee,SelectPrompt as et,SelectKeyPrompt as tt,TextPrompt as st}from"@clack/core";export{isCancel,settings,updateSettings}from"@clack/core";import t from"picocolors";import T from"node:process";import{WriteStream as rt}from"node:tty";import{stripVTControlCharacters as V}from"node:util";import{readdirSync as it,existsSync as nt,lstatSync as ve}from"node:fs";import{dirname as Ae,join as at}from"node:path";import{cursor as Ce,erase as Ie}from"sisteransi";function ot(){return T.platform!=="win32"?T.env.TERM!=="linux":!!T.env.CI||!!T.env.WT_SESSION||!!T.env.TERMINUS_SUBLIME||T.env.ConEmuTask==="{cmd::Cmder}"||T.env.TERM_PROGRAM==="Terminus-Sublime"||T.env.TERM_PROGRAM==="vscode"||T.env.TERM==="xterm-256color"||T.env.TERM==="alacritty"||T.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}const q=ot(),se=()=>process.env.CI==="true",Se=e=>e.isTTY===!0,I=(e,r)=>q?e:r,we=I("\u25C6","*"),re=I("\u25A0","x"),ie=I("\u25B2","x"),L=I("\u25C7","o"),ne=I("\u250C","T"),u=I("\u2502","|"),_=I("\u2514","\u2014"),Be=I("\u2510","T"),_e=I("\u2518","\u2014"),G=I("\u25CF",">"),H=I("\u25CB"," "),J=I("\u25FB","[\u2022]"),W=I("\u25FC","[+]"),X=I("\u25FB","[ ]"),xe=I("\u25AA","\u2022"),Y=I("\u2500","-"),ae=I("\u256E","+"),be=I("\u251C","+"),oe=I("\u256F","+"),De=I("\u2570","+"),Te=I("\u256D","+"),le=I("\u25CF","\u2022"),ue=I("\u25C6","*"),ce=I("\u25B2","!"),$e=I("\u25A0","x"),M=e=>{switch(e){case"initial":case"active":return t.cyan(we);case"cancel":return t.red(re);case"error":return t.yellow(ie);case"submit":return t.green(L)}},k=e=>{const{cursor:r,options:s,style:i}=e,n=e.output??process.stdout,o=n instanceof rt&&n.rows!==void 0?n.rows:10,c=t.dim("..."),l=e.maxItems??Number.POSITIVE_INFINITY,a=Math.max(o-4,0),h=Math.min(a,Math.max(l,5));let g=0;r>=g+h-3?g=Math.max(Math.min(r-h+3,s.length-h),0):r<g+2&&(g=Math.max(r-2,0));const F=h<s.length&&g>0,y=h<s.length&&g+h<s.length;return s.slice(g,g+h).map((m,p,$)=>{const d=p===0&&F,f=p===$.length-1&&y;return d||f?c:i(m,p+g===r)})};function Re(e){return e.label??String(e.value??"")}function Me(e,r){if(!e)return!0;const s=(r.label??String(r.value??"")).toLowerCase(),i=(r.hint??"").toLowerCase(),n=String(r.value).toLowerCase(),o=e.toLowerCase();return s.includes(o)||i.includes(o)||n.includes(o)}function lt(e,r){const s=[];for(const i of r)e.includes(i.value)&&s.push(i);return s}const Oe=e=>new ye({options:e.options,initialValue:e.initialValue?[e.initialValue]:void 0,initialUserInput:e.initialUserInput,filter:(r,s)=>Me(r,s),signal:e.signal,input:e.input,output:e.output,validate:e.validate,render(){const r=`${t.gray(u)}
${M(this.state)} ${e.message}
`,s=this.userInput,i=String(this.value??""),n=this.options,o=e.placeholder,c=i===""&&o!==void 0;switch(this.state){case"submit":{const l=lt(this.selectedValues,n),a=l.length>0?` ${t.dim(l.map(Re).join(", "))}`:"";return`${r}${t.gray(u)}${a}`}case"cancel":{const l=s?` ${t.strikethrough(t.dim(s))}`:"";return`${r}${t.gray(u)}${l}`}default:{let l="";if(this.isNavigating||c){const m=c?o:s;l=m!==""?` ${t.dim(m)}`:""}else l=` ${this.userInputWithCursor}`;const a=this.filteredOptions.length!==n.length?t.dim(` (${this.filteredOptions.length} match${this.filteredOptions.length===1?"":"es"})`):"",h=this.filteredOptions.length===0?[]:k({cursor:this.cursor,options:this.filteredOptions,style:(m,p)=>{const $=Re(m),d=m.hint&&m.value===this.focusedValue?t.dim(` (${m.hint})`):"";return p?`${t.green(G)} ${$}${d}`:`${t.dim(H)} ${t.dim($)}${d}`},maxItems:e.maxItems,output:e.output}),g=[`${t.dim("\u2191/\u2193")} to select`,`${t.dim("Enter:")} confirm`,`${t.dim("Type:")} to search`],F=this.filteredOptions.length===0&&s?[`${t.cyan(u)} ${t.yellow("No matches found")}`]:[],y=this.state==="error"?[`${t.yellow(u)} ${t.yellow(this.error)}`]:[];return[`${r}${t.cyan(u)}`,`${t.cyan(u)} ${t.dim("Search:")}${l}${a}`,...F,...y,...h.map(m=>`${t.cyan(u)} ${m}`),`${t.cyan(u)} ${t.dim(g.join(" \u2022 "))}`,`${t.cyan(_)}`].join(`
`)}}}}).prompt(),ut=e=>{const r=(i,n,o,c)=>{const l=o.includes(i.value),a=i.label??String(i.value??""),h=i.hint&&c!==void 0&&i.value===c?t.dim(` (${i.hint})`):"",g=l?t.green(W):t.dim(X);return n?`${g} ${a}${h}`:`${g} ${t.dim(a)}`},s=new ye({options:e.options,multiple:!0,filter:(i,n)=>Me(i,n),validate:()=>{if(e.required&&s.selectedValues.length===0)return"Please select at least one item"},initialValue:e.initialValues,signal:e.signal,input:e.input,output:e.output,render(){const i=`${t.gray(u)}
${M(this.state)} ${e.message}
`,n=this.userInput,o=e.placeholder,c=n===""&&o!==void 0,l=this.isNavigating||c?t.dim(c?o:n):this.userInputWithCursor,a=this.options,h=this.filteredOptions.length!==a.length?t.dim(` (${this.filteredOptions.length} match${this.filteredOptions.length===1?"":"es"})`):"";switch(this.state){case"submit":return`${i}${t.gray(u)} ${t.dim(`${this.selectedValues.length} items selected`)}`;case"cancel":return`${i}${t.gray(u)} ${t.strikethrough(t.dim(n))}`;default:{const g=[`${t.dim("\u2191/\u2193")} to navigate`,`${t.dim(this.isNavigating?"Space/Tab:":"Tab:")} select`,`${t.dim("Enter:")} confirm`,`${t.dim("Type:")} to search`],F=this.filteredOptions.length===0&&n?[`${t.cyan(u)} ${t.yellow("No matches found")}`]:[],y=this.state==="error"?[`${t.cyan(u)} ${t.yellow(this.error)}`]:[],m=k({cursor:this.cursor,options:this.filteredOptions,style:(p,$)=>r(p,$,this.selectedValues,this.focusedValue),maxItems:e.maxItems,output:e.output});return[i,`${t.cyan(u)} ${t.dim("Search:")} ${l}${h}`,...F,...y,...m.map(p=>`${t.cyan(u)} ${p}`),`${t.cyan(u)} ${t.dim(g.join(" \u2022 "))}`,`${t.cyan(_)}`].join(`
`)}}}});return s.prompt()},ct=e=>e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109,$t=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,dt=e=>e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9800&&e<=9811||e===9855||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=19968&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e===94192||e===94193||e>=94208&&e<=100343||e>=100352&&e<=101589||e>=101632&&e<=101640||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128727||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129672||e>=129680&&e<=129725||e>=129727&&e<=129733||e>=129742&&e<=129755||e>=129760&&e<=129768||e>=129776&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141,de=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,z=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Z=/\t{1,1000}/y,he=/[\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,Q=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,ht=/\p{M}+/gu,mt={limit:1/0,ellipsis:""},Ne=(e,r={},s={})=>{const i=r.limit??1/0,n=r.ellipsis??"",o=r?.ellipsisWidth??(n?Ne(n,mt,s).width:0),c=s.ansiWidth??0,l=s.controlWidth??0,a=s.tabWidth??8,h=s.ambiguousWidth??1,g=s.emojiWidth??2,F=s.fullWidthWidth??2,y=s.regularWidth??1,m=s.wideWidth??2;let p=0,$=0,d=e.length,f=0,E=!1,v=d,w=Math.max(0,i-o),B=0,x=0,A=0,C=0;e:for(;;){if(x>B||$>=d&&$>p){const O=e.slice(B,x)||e.slice(p,$);f=0;for(const N of O.replaceAll(ht,"")){const S=N.codePointAt(0)||0;if($t(S)?C=F:dt(S)?C=m:h!==y&&ct(S)?C=h:C=y,A+C>w&&(v=Math.min(v,Math.max(B,p)+f)),A+C>i){E=!0;break e}f+=N.length,A+=C}B=x=0}if($>=d)break;if(Q.lastIndex=$,Q.test(e)){if(f=Q.lastIndex-$,C=f*y,A+C>w&&(v=Math.min(v,$+Math.floor((w-A)/y))),A+C>i){E=!0;break}A+=C,B=p,x=$,$=p=Q.lastIndex;continue}if(de.lastIndex=$,de.test(e)){if(A+c>w&&(v=Math.min(v,$)),A+c>i){E=!0;break}A+=c,B=p,x=$,$=p=de.lastIndex;continue}if(z.lastIndex=$,z.test(e)){if(f=z.lastIndex-$,C=f*l,A+C>w&&(v=Math.min(v,$+Math.floor((w-A)/l))),A+C>i){E=!0;break}A+=C,B=p,x=$,$=p=z.lastIndex;continue}if(Z.lastIndex=$,Z.test(e)){if(f=Z.lastIndex-$,C=f*a,A+C>w&&(v=Math.min(v,$+Math.floor((w-A)/a))),A+C>i){E=!0;break}A+=C,B=p,x=$,$=p=Z.lastIndex;continue}if(he.lastIndex=$,he.test(e)){if(A+g>w&&(v=Math.min(v,$)),A+g>i){E=!0;break}A+=g,B=p,x=$,$=p=he.lastIndex;continue}$+=1}return{width:E?w:A,index:E?v:d,truncated:E,ellipsed:E&&i>=o}},pt={limit:1/0,ellipsis:"",ellipsisWidth:0},U=(e,r={})=>Ne(e,pt,r).width,ee="\x1B",Le="\x9B",gt=39,me="\x07",We="[",Ft="]",Pe="m",pe=`${Ft}8;;`,je=new RegExp(`(?:\\${We}(?<code>\\d+)m|\\${pe}(?<uri>.*)${me})`,"y"),ft=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},Ve=e=>`${ee}${We}${e}${Pe}`,ke=e=>`${ee}${pe}${e}${me}`,yt=e=>e.map(r=>U(r)),ge=(e,r,s)=>{const i=r[Symbol.iterator]();let n=!1,o=!1,c=e.at(-1),l=c===void 0?0:U(c),a=i.next(),h=i.next(),g=0;for(;!a.done;){const F=a.value,y=U(F);l+y<=s?e[e.length-1]+=F:(e.push(F),l=0),(F===ee||F===Le)&&(n=!0,o=r.startsWith(pe,g+1)),n?o?F===me&&(n=!1,o=!1):F===Pe&&(n=!1):(l+=y,l===s&&!h.done&&(e.push(""),l=0)),a=h,h=i.next(),g+=F.length}c=e.at(-1),!l&&c!==void 0&&c.length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Et=e=>{const r=e.split(" ");let s=r.length;for(;s>0&&!(U(r[s-1])>0);)s--;return s===r.length?e:r.slice(0,s).join(" ")+r.slice(s).join("")},vt=(e,r,s={})=>{if(s.trim!==!1&&e.trim()==="")return"";let i="",n,o;const c=e.split(" "),l=yt(c);let a=[""];for(const[p,$]of c.entries()){s.trim!==!1&&(a[a.length-1]=(a.at(-1)??"").trimStart());let d=U(a.at(-1)??"");if(p!==0&&(d>=r&&(s.wordWrap===!1||s.trim===!1)&&(a.push(""),d=0),(d>0||s.trim===!1)&&(a[a.length-1]+=" ",d++)),s.hard&&l[p]>r){const f=r-d,E=1+Math.floor((l[p]-f-1)/r);Math.floor((l[p]-1)/r)<E&&a.push(""),ge(a,$,r);continue}if(d+l[p]>r&&d>0&&l[p]>0){if(s.wordWrap===!1&&d<r){ge(a,$,r);continue}a.push("")}if(d+l[p]>r&&s.wordWrap===!1){ge(a,$,r);continue}a[a.length-1]+=$}s.trim!==!1&&(a=a.map(p=>Et(p)));const h=a.join(`
`),g=h[Symbol.iterator]();let F=g.next(),y=g.next(),m=0;for(;!F.done;){const p=F.value,$=y.value;if(i+=p,p===ee||p===Le){je.lastIndex=m+1;const E=je.exec(h)?.groups;if(E?.code!==void 0){const v=Number.parseFloat(E.code);n=v===gt?void 0:v}else E?.uri!==void 0&&(o=E.uri.length===0?void 0:E.uri)}const d=n?ft(n):void 0;$===`
`?(o&&(i+=ke("")),n&&d&&(i+=Ve(d))):p===`
`&&(n&&d&&(i+=Ve(n)),o&&(i+=ke(o))),m+=p.length,F=y,y=g.next()}return i};function Fe(e,r,s){return String(e).normalize().replaceAll(`\r
import{getColumns as H,getRows as Je,AutocompletePrompt as ye,ConfirmPrompt as Xe,isCancel as Ye,GroupMultiSelectPrompt as ze,MultiSelectPrompt as Ze,PasswordPrompt as Qe,block as et,settings as Ee,SelectPrompt as tt,SelectKeyPrompt as st,TextPrompt as rt}from"@clack/core";export{isCancel,settings,updateSettings}from"@clack/core";import t from"picocolors";import N from"node:process";import{readdirSync as it,existsSync as nt,lstatSync as ve}from"node:fs";import{dirname as Ae,join as at}from"node:path";import{cursor as Ce,erase as Ie}from"sisteransi";import{stripVTControlCharacters as se}from"node:util";function ot(){return N.platform!=="win32"?N.env.TERM!=="linux":!!N.env.CI||!!N.env.WT_SESSION||!!N.env.TERMINUS_SUBLIME||N.env.ConEmuTask==="{cmd::Cmder}"||N.env.TERM_PROGRAM==="Terminus-Sublime"||N.env.TERM_PROGRAM==="vscode"||N.env.TERM==="xterm-256color"||N.env.TERM==="alacritty"||N.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}const J=ot(),re=()=>process.env.CI==="true",Se=e=>e.isTTY===!0,S=(e,r)=>J?e:r,we=S("\u25C6","*"),ie=S("\u25A0","x"),ne=S("\u25B2","x"),W=S("\u25C7","o"),ae=S("\u250C","T"),c=S("\u2502","|"),b=S("\u2514","\u2014"),Be=S("\u2510","T"),xe=S("\u2518","\u2014"),U=S("\u25CF",">"),K=S("\u25CB"," "),X=S("\u25FB","[\u2022]"),P=S("\u25FC","[+]"),Y=S("\u25FB","[ ]"),be=S("\u25AA","\u2022"),z=S("\u2500","-"),oe=S("\u256E","+"),_e=S("\u251C","+"),le=S("\u256F","+"),De=S("\u2570","+"),Te=S("\u256D","+"),ue=S("\u25CF","\u2022"),ce=S("\u25C6","*"),$e=S("\u25B2","!"),de=S("\u25A0","x"),L=e=>{switch(e){case"initial":case"active":return t.cyan(we);case"cancel":return t.red(ie);case"error":return t.yellow(ne);case"submit":return t.green(W)}},lt=e=>e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109,ut=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,ct=e=>e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9800&&e<=9811||e===9855||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=19968&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e===94192||e===94193||e>=94208&&e<=100343||e>=100352&&e<=101589||e>=101632&&e<=101640||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128727||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129672||e>=129680&&e<=129725||e>=129727&&e<=129733||e>=129742&&e<=129755||e>=129760&&e<=129768||e>=129776&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141,he=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,Z=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Q=/\t{1,1000}/y,me=/[\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,ee=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,$t=/\p{M}+/gu,dt={limit:1/0,ellipsis:""},Re=(e,r={},s={})=>{const i=r.limit??1/0,n=r.ellipsis??"",o=r?.ellipsisWidth??(n?Re(n,dt,s).width:0),u=s.ansiWidth??0,l=s.controlWidth??0,a=s.tabWidth??8,m=s.ambiguousWidth??1,E=s.emojiWidth??2,y=s.fullWidthWidth??2,F=s.regularWidth??1,p=s.wideWidth??2;let h=0,d=0,$=e.length,g=0,f=!1,v=$,w=Math.max(0,i-o),B=0,x=0,A=0,C=0;e:for(;;){if(x>B||d>=$&&d>h){const _=e.slice(B,x)||e.slice(h,d);g=0;for(const D of _.replaceAll($t,"")){const I=D.codePointAt(0)||0;if(ut(I)?C=y:ct(I)?C=p:m!==F&&lt(I)?C=m:C=F,A+C>w&&(v=Math.min(v,Math.max(B,h)+g)),A+C>i){f=!0;break e}g+=D.length,A+=C}B=x=0}if(d>=$)break;if(ee.lastIndex=d,ee.test(e)){if(g=ee.lastIndex-d,C=g*F,A+C>w&&(v=Math.min(v,d+Math.floor((w-A)/F))),A+C>i){f=!0;break}A+=C,B=h,x=d,d=h=ee.lastIndex;continue}if(he.lastIndex=d,he.test(e)){if(A+u>w&&(v=Math.min(v,d)),A+u>i){f=!0;break}A+=u,B=h,x=d,d=h=he.lastIndex;continue}if(Z.lastIndex=d,Z.test(e)){if(g=Z.lastIndex-d,C=g*l,A+C>w&&(v=Math.min(v,d+Math.floor((w-A)/l))),A+C>i){f=!0;break}A+=C,B=h,x=d,d=h=Z.lastIndex;continue}if(Q.lastIndex=d,Q.test(e)){if(g=Q.lastIndex-d,C=g*a,A+C>w&&(v=Math.min(v,d+Math.floor((w-A)/a))),A+C>i){f=!0;break}A+=C,B=h,x=d,d=h=Q.lastIndex;continue}if(me.lastIndex=d,me.test(e)){if(A+E>w&&(v=Math.min(v,d)),A+E>i){f=!0;break}A+=E,B=h,x=d,d=h=me.lastIndex;continue}d+=1}return{width:f?w:A,index:f?v:$,truncated:f,ellipsed:f&&i>=o}},ht={limit:1/0,ellipsis:"",ellipsisWidth:0},M=(e,r={})=>Re(e,ht,r).width,te="\x1B",Me="\x9B",mt=39,pe="\x07",Oe="[",pt="]",Ne="m",ge=`${pt}8;;`,Le=new RegExp(`(?:\\${Oe}(?<code>\\d+)m|\\${ge}(?<uri>.*)${pe})`,"y"),gt=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},We=e=>`${te}${Oe}${e}${Ne}`,Pe=e=>`${te}${ge}${e}${pe}`,ft=e=>e.map(r=>M(r)),fe=(e,r,s)=>{const i=r[Symbol.iterator]();let n=!1,o=!1,u=e.at(-1),l=u===void 0?0:M(u),a=i.next(),m=i.next(),E=0;for(;!a.done;){const y=a.value,F=M(y);l+F<=s?e[e.length-1]+=y:(e.push(y),l=0),(y===te||y===Me)&&(n=!0,o=r.startsWith(ge,E+1)),n?o?y===pe&&(n=!1,o=!1):y===Ne&&(n=!1):(l+=F,l===s&&!m.done&&(e.push(""),l=0)),a=m,m=i.next(),E+=y.length}u=e.at(-1),!l&&u!==void 0&&u.length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Ft=e=>{const r=e.split(" ");let s=r.length;for(;s>0&&!(M(r[s-1])>0);)s--;return s===r.length?e:r.slice(0,s).join(" ")+r.slice(s).join("")},yt=(e,r,s={})=>{if(s.trim!==!1&&e.trim()==="")return"";let i="",n,o;const u=e.split(" "),l=ft(u);let a=[""];for(const[h,d]of u.entries()){s.trim!==!1&&(a[a.length-1]=(a.at(-1)??"").trimStart());let $=M(a.at(-1)??"");if(h!==0&&($>=r&&(s.wordWrap===!1||s.trim===!1)&&(a.push(""),$=0),($>0||s.trim===!1)&&(a[a.length-1]+=" ",$++)),s.hard&&l[h]>r){const g=r-$,f=1+Math.floor((l[h]-g-1)/r);Math.floor((l[h]-1)/r)<f&&a.push(""),fe(a,d,r);continue}if($+l[h]>r&&$>0&&l[h]>0){if(s.wordWrap===!1&&$<r){fe(a,d,r);continue}a.push("")}if($+l[h]>r&&s.wordWrap===!1){fe(a,d,r);continue}a[a.length-1]+=d}s.trim!==!1&&(a=a.map(h=>Ft(h)));const m=a.join(`
`),E=m[Symbol.iterator]();let y=E.next(),F=E.next(),p=0;for(;!y.done;){const h=y.value,d=F.value;if(i+=h,h===te||h===Me){Le.lastIndex=p+1;const f=Le.exec(m)?.groups;if(f?.code!==void 0){const v=Number.parseFloat(f.code);n=v===mt?void 0:v}else f?.uri!==void 0&&(o=f.uri.length===0?void 0:f.uri)}const $=n?gt(n):void 0;d===`
`?(o&&(i+=Pe("")),n&&$&&(i+=We($))):h===`
`&&(n&&$&&(i+=We(n)),o&&(i+=Pe(o))),p+=h.length,y=F,F=E.next()}return i};function k(e,r,s){return String(e).normalize().replaceAll(`\r
`,`
`).split(`
`).map(i=>vt(i,r,s)).join(`
`)}const At=[Te,ae,De,oe],Ct=[ne,Be,_,_e];function Ge(e,r,s,i){let n=s,o=s;return i==="center"?n=Math.floor((r-e)/2):i==="right"&&(n=r-e-s),o=r-n-e,[n,o]}const It=e=>e,St=(e="",r="",s)=>{const i=s?.output??process.stdout,n=te(i),o=2,c=s?.titlePadding??1,l=s?.contentPadding??2,a=s?.width===void 0||s.width==="auto"?1:Math.min(1,s.width),h=s?.includePrefix?`${u} `:"",g=s?.formatBorder??It,F=(s?.rounded?At:Ct).map(g),y=g(Y),m=g(u),p=n-h.length;let $=Math.floor(n*a)-h.length;if(s?.width==="auto"){const A=e.split(`
`);let C=r.length+c*2;for(const N of A){const S=N.length+l*2;S>C&&(C=S)}const O=C+o;O<$&&($=O)}$%2!==0&&($<p?$++:$--);const d=$-o,f=d-c*2,E=r.length>f?`${r.slice(0,f-3)}...`:r,[v,w]=Ge(E.length,d,c,s?.titleAlign),B=Fe(e,d-l*2,{hard:!0,trim:!1});i.write(`${h}${F[0]}${y.repeat(v)}${E}${y.repeat(w)}${F[1]}
`);const x=B.split(`
`);for(const A of x){const[C,O]=Ge(A.length,d,l,s?.contentAlign);i.write(`${h}${m}${" ".repeat(C)}${A}${" ".repeat(O)}${m}
`)}i.write(`${h}${F[2]}${y.repeat(d)}${F[3]}
`)},wt=e=>{const r=e.active??"Yes",s=e.inactive??"No";return new Je({active:r,inactive:s,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){const i=`${t.gray(u)}
${M(this.state)} ${e.message}
`,n=this.value?r:s;switch(this.state){case"submit":return`${i}${t.gray(u)} ${t.dim(n)}`;case"cancel":return`${i}${t.gray(u)} ${t.strikethrough(t.dim(n))}
${t.gray(u)}`;default:return`${i}${t.cyan(u)} ${this.value?`${t.green(G)} ${r}`:`${t.dim(H)} ${t.dim(r)}`} ${t.dim("/")} ${this.value?`${t.dim(H)} ${t.dim(s)}`:`${t.green(G)} ${s}`}
${t.cyan(_)}
`}}}).prompt()},Bt=async(e,r)=>{const s={},i=Object.keys(e);for(const n of i){const o=e[n],c=await o({results:s})?.catch(l=>{throw l});if(typeof r?.onCancel=="function"&&Xe(c)){s[n]="canceled",r.onCancel({results:s});continue}s[n]=c}return s},_t=e=>{const{selectableGroups:r=!0,groupSpacing:s=0}=e,i=(o,c,l=[])=>{const a=o.label??String(o.value),h=typeof o.group=="string",g=h&&(l[l.indexOf(o)+1]??{group:!0}),F=h&&g&&g.group===!0,y=h?r?`${F?_:u} `:" ":"";let m="";if(s>0&&!h){const $=`
${t.cyan(u)}`;m=`${$.repeat(s-1)}${$} `}if(c==="active")return`${m}${t.dim(y)}${t.cyan(J)} ${a}${o.hint?` ${t.dim(`(${o.hint})`)}`:""}`;if(c==="group-active")return`${m}${y}${t.cyan(J)} ${t.dim(a)}`;if(c==="group-active-selected")return`${m}${y}${t.green(W)} ${t.dim(a)}`;if(c==="selected"){const $=h||r?t.green(W):"";return`${m}${t.dim(y)}${$} ${t.dim(a)}${o.hint?` ${t.dim(`(${o.hint})`)}`:""}`}if(c==="cancelled")return`${t.strikethrough(t.dim(a))}`;if(c==="active-selected")return`${m}${t.dim(y)}${t.green(W)} ${a}${o.hint?` ${t.dim(`(${o.hint})`)}`:""}`;if(c==="submitted")return`${t.dim(a)}`;const p=h||r?t.dim(X):"";return`${m}${t.dim(y)}${p} ${t.dim(a)}`},n=e.required??!0;return new Ye({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValues:e.initialValues,required:n,cursorAt:e.cursorAt,selectableGroups:r,validate(o){if(n&&(o===void 0||o.length===0))return`Please select at least one option.
${t.reset(t.dim(`Press ${t.gray(t.bgWhite(t.inverse(" space ")))} to select, ${t.gray(t.bgWhite(t.inverse(" enter ")))} to submit`))}`},render(){const o=`${t.gray(u)}
${M(this.state)} ${e.message}
`,c=this.value??[];switch(this.state){case"submit":{const l=this.options.filter(({value:h})=>c.includes(h)).map(h=>i(h,"submitted")),a=l.length===0?"":` ${l.join(t.dim(", "))}`;return`${o}${t.gray(u)}${a}`}case"cancel":{const l=this.options.filter(({value:a})=>c.includes(a)).map(a=>i(a,"cancelled")).join(t.dim(", "));return`${o}${t.gray(u)} ${l.trim()?`${l}
${t.gray(u)}`:""}`}case"error":{const l=this.error.split(`
`).map((a,h)=>h===0?`${t.yellow(_)} ${t.yellow(a)}`:` ${a}`).join(`
`);return`${o}${t.yellow(u)} ${this.options.map((a,h,g)=>{const F=c.includes(a.value)||a.group===!0&&this.isGroupSelected(`${a.value}`),y=h===this.cursor;return!y&&typeof a.group=="string"&&this.options[this.cursor].value===a.group?i(a,F?"group-active-selected":"group-active",g):y&&F?i(a,"active-selected",g):F?i(a,"selected",g):i(a,y?"active":"inactive",g)}).join(`
${t.yellow(u)} `)}
`).map(i=>yt(i,r,s)).join(`
`)}const Et=(e,r,s,i,n)=>{let o=r,u=0;for(let l=s;l<i;l++){const a=e[l];if(o=o-a.length,u++,o<=n)break}return{lineCount:o,removals:u}},G=e=>{const{cursor:r,options:s,style:i}=e,n=e.output??process.stdout,o=H(n),u=e.columnPadding??0,l=e.rowPadding??4,a=o-u,m=Je(n),E=t.dim("..."),y=e.maxItems??Number.POSITIVE_INFINITY,F=Math.max(m-l,0),p=Math.max(y,5);let h=0;r>=p-3&&(h=Math.max(Math.min(r-p+3,s.length-p),0));let d=p<s.length&&h>0,$=p<s.length&&h+p<s.length;const g=Math.min(h+p,s.length),f=[];let v=0;d&&v++,$&&v++;const w=h+(d?1:0),B=g-($?1:0);for(let A=w;A<B;A++){const C=k(i(s[A],A===r),a).split(`
`);f.push(C),v+=C.length}if(v>F){let A=0,C=0,_=v;const D=r-w,I=(T,R)=>Et(f,_,T,R,F);d?({lineCount:_,removals:A}=I(0,D),_>F&&({lineCount:_,removals:C}=I(D+1,f.length))):({lineCount:_,removals:C}=I(D+1,f.length),_>F&&({lineCount:_,removals:A}=I(0,D))),A>0&&(d=!0,f.splice(0,A)),C>0&&($=!0,f.splice(f.length-C,C))}const x=[];d&&x.push(E);for(const A of f)for(const C of A)x.push(C);return $&&x.push(E),x};function je(e){return e.label??String(e.value??"")}function Ve(e,r){if(!e)return!0;const s=(r.label??String(r.value??"")).toLowerCase(),i=(r.hint??"").toLowerCase(),n=String(r.value).toLowerCase(),o=e.toLowerCase();return s.includes(o)||i.includes(o)||n.includes(o)}function vt(e,r){const s=[];for(const i of r)e.includes(i.value)&&s.push(i);return s}const ke=e=>new ye({options:e.options,initialValue:e.initialValue?[e.initialValue]:void 0,initialUserInput:e.initialUserInput,filter:(r,s)=>Ve(r,s),signal:e.signal,input:e.input,output:e.output,validate:e.validate,render(){const r=[`${t.gray(c)}`,`${L(this.state)} ${e.message}`],s=this.userInput,i=String(this.value??""),n=this.options,o=e.placeholder,u=i===""&&o!==void 0;switch(this.state){case"submit":{const l=vt(this.selectedValues,n),a=l.length>0?` ${t.dim(l.map(je).join(", "))}`:"";return`${r.join(`
`)}
${t.gray(c)}${a}`}case"cancel":{const l=s?` ${t.strikethrough(t.dim(s))}`:"";return`${r.join(`
`)}
${t.gray(c)}${l}`}default:{let l="";if(this.isNavigating||u){const h=u?o:s;l=h!==""?` ${t.dim(h)}`:""}else l=` ${this.userInputWithCursor}`;const a=this.filteredOptions.length!==n.length?t.dim(` (${this.filteredOptions.length} match${this.filteredOptions.length===1?"":"es"})`):"",m=this.filteredOptions.length===0&&s?[`${t.cyan(c)} ${t.yellow("No matches found")}`]:[],E=this.state==="error"?[`${t.yellow(c)} ${t.yellow(this.error)}`]:[];r.push(`${t.cyan(c)}`,`${t.cyan(c)} ${t.dim("Search:")}${l}${a}`,...m,...E);const y=[`${t.dim("\u2191/\u2193")} to select`,`${t.dim("Enter:")} confirm`,`${t.dim("Type:")} to search`],F=[`${t.cyan(c)} ${t.dim(y.join(" \u2022 "))}`,`${t.cyan(b)}`],p=this.filteredOptions.length===0?[]:G({cursor:this.cursor,options:this.filteredOptions,columnPadding:3,rowPadding:r.length+F.length,style:(h,d)=>{const $=je(h),g=h.hint&&h.value===this.focusedValue?t.dim(` (${h.hint})`):"";return d?`${t.green(U)} ${$}${g}`:`${t.dim(K)} ${t.dim($)}${g}`},maxItems:e.maxItems,output:e.output});return[...r,...p.map(h=>`${t.cyan(c)} ${h}`),...F].join(`
`)}}}}).prompt(),At=e=>{const r=(i,n,o,u)=>{const l=o.includes(i.value),a=i.label??String(i.value??""),m=i.hint&&u!==void 0&&i.value===u?t.dim(` (${i.hint})`):"",E=l?t.green(P):t.dim(Y);return n?`${E} ${a}${m}`:`${E} ${t.dim(a)}`},s=new ye({options:e.options,multiple:!0,filter:(i,n)=>Ve(i,n),validate:()=>{if(e.required&&s.selectedValues.length===0)return"Please select at least one item"},initialValue:e.initialValues,signal:e.signal,input:e.input,output:e.output,render(){const i=`${t.gray(c)}
${L(this.state)} ${e.message}
`,n=this.userInput,o=e.placeholder,u=n===""&&o!==void 0,l=this.isNavigating||u?t.dim(u?o:n):this.userInputWithCursor,a=this.options,m=this.filteredOptions.length!==a.length?t.dim(` (${this.filteredOptions.length} match${this.filteredOptions.length===1?"":"es"})`):"";switch(this.state){case"submit":return`${i}${t.gray(c)} ${t.dim(`${this.selectedValues.length} items selected`)}`;case"cancel":return`${i}${t.gray(c)} ${t.strikethrough(t.dim(n))}`;default:{const E=[`${t.dim("\u2191/\u2193")} to navigate`,`${t.dim(this.isNavigating?"Space/Tab:":"Tab:")} select`,`${t.dim("Enter:")} confirm`,`${t.dim("Type:")} to search`],y=this.filteredOptions.length===0&&n?[`${t.cyan(c)} ${t.yellow("No matches found")}`]:[],F=this.state==="error"?[`${t.cyan(c)} ${t.yellow(this.error)}`]:[],p=G({cursor:this.cursor,options:this.filteredOptions,style:(h,d)=>r(h,d,this.selectedValues,this.focusedValue),maxItems:e.maxItems,output:e.output});return[i,`${t.cyan(c)} ${t.dim("Search:")} ${l}${m}`,...y,...F,...p.map(h=>`${t.cyan(c)} ${h}`),`${t.cyan(c)} ${t.dim(E.join(" \u2022 "))}`,`${t.cyan(b)}`].join(`
`)}}}});return s.prompt()},Ct=[Te,oe,De,le],It=[ae,Be,b,xe];function Ge(e,r,s,i){let n=s,o=s;return i==="center"?n=Math.floor((r-e)/2):i==="right"&&(n=r-e-s),o=r-n-e,[n,o]}const St=e=>e,wt=(e="",r="",s)=>{const i=s?.output??process.stdout,n=H(i),o=2,u=s?.titlePadding??1,l=s?.contentPadding??2,a=s?.width===void 0||s.width==="auto"?1:Math.min(1,s.width),m=s?.includePrefix?`${c} `:"",E=s?.formatBorder??St,y=(s?.rounded?Ct:It).map(E),F=E(z),p=E(c),h=M(m),d=M(r),$=n-h;let g=Math.floor(n*a)-h;if(s?.width==="auto"){const _=e.split(`
`);let D=d+u*2;for(const T of _){const R=M(T)+l*2;R>D&&(D=R)}const I=D+o;I<g&&(g=I)}g%2!==0&&(g<$?g++:g--);const f=g-o,v=f-u*2,w=d>v?`${r.slice(0,v-3)}...`:r,[B,x]=Ge(M(w),f,u,s?.titleAlign),A=k(e,f-l*2,{hard:!0,trim:!1});i.write(`${m}${y[0]}${F.repeat(B)}${w}${F.repeat(x)}${y[1]}
`);const C=A.split(`
`);for(const _ of C){const[D,I]=Ge(M(_),f,l,s?.contentAlign);i.write(`${m}${p}${" ".repeat(D)}${_}${" ".repeat(I)}${p}
`)}i.write(`${m}${y[2]}${F.repeat(f)}${y[3]}
`)},Bt=e=>{const r=e.active??"Yes",s=e.inactive??"No";return new Xe({active:r,inactive:s,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){const i=`${t.gray(c)}
${L(this.state)} ${e.message}
`,n=this.value?r:s;switch(this.state){case"submit":return`${i}${t.gray(c)} ${t.dim(n)}`;case"cancel":return`${i}${t.gray(c)} ${t.strikethrough(t.dim(n))}
${t.gray(c)}`;default:return`${i}${t.cyan(c)} ${this.value?`${t.green(U)} ${r}`:`${t.dim(K)} ${t.dim(r)}`} ${t.dim("/")} ${this.value?`${t.dim(K)} ${t.dim(s)}`:`${t.green(U)} ${s}`}
${t.cyan(b)}
`}}}).prompt()},xt=async(e,r)=>{const s={},i=Object.keys(e);for(const n of i){const o=e[n],u=await o({results:s})?.catch(l=>{throw l});if(typeof r?.onCancel=="function"&&Ye(u)){s[n]="canceled",r.onCancel({results:s});continue}s[n]=u}return s},bt=e=>{const{selectableGroups:r=!0,groupSpacing:s=0}=e,i=(o,u,l=[])=>{const a=o.label??String(o.value),m=typeof o.group=="string",E=m&&(l[l.indexOf(o)+1]??{group:!0}),y=m&&E&&E.group===!0,F=m?r?`${y?b:c} `:" ":"";let p="";if(s>0&&!m){const d=`
${t.cyan(c)}`;p=`${d.repeat(s-1)}${d} `}if(u==="active")return`${p}${t.dim(F)}${t.cyan(X)} ${a}${o.hint?` ${t.dim(`(${o.hint})`)}`:""}`;if(u==="group-active")return`${p}${F}${t.cyan(X)} ${t.dim(a)}`;if(u==="group-active-selected")return`${p}${F}${t.green(P)} ${t.dim(a)}`;if(u==="selected"){const d=m||r?t.green(P):"";return`${p}${t.dim(F)}${d} ${t.dim(a)}${o.hint?` ${t.dim(`(${o.hint})`)}`:""}`}if(u==="cancelled")return`${t.strikethrough(t.dim(a))}`;if(u==="active-selected")return`${p}${t.dim(F)}${t.green(P)} ${a}${o.hint?` ${t.dim(`(${o.hint})`)}`:""}`;if(u==="submitted")return`${t.dim(a)}`;const h=m||r?t.dim(Y):"";return`${p}${t.dim(F)}${h} ${t.dim(a)}`},n=e.required??!0;return new ze({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValues:e.initialValues,required:n,cursorAt:e.cursorAt,selectableGroups:r,validate(o){if(n&&(o===void 0||o.length===0))return`Please select at least one option.
${t.reset(t.dim(`Press ${t.gray(t.bgWhite(t.inverse(" space ")))} to select, ${t.gray(t.bgWhite(t.inverse(" enter ")))} to submit`))}`},render(){const o=`${t.gray(c)}
${L(this.state)} ${e.message}
`,u=this.value??[];switch(this.state){case"submit":{const l=this.options.filter(({value:m})=>u.includes(m)).map(m=>i(m,"submitted")),a=l.length===0?"":` ${l.join(t.dim(", "))}`;return`${o}${t.gray(c)}${a}`}case"cancel":{const l=this.options.filter(({value:a})=>u.includes(a)).map(a=>i(a,"cancelled")).join(t.dim(", "));return`${o}${t.gray(c)} ${l.trim()?`${l}
${t.gray(c)}`:""}`}case"error":{const l=this.error.split(`
`).map((a,m)=>m===0?`${t.yellow(b)} ${t.yellow(a)}`:` ${a}`).join(`
`);return`${o}${t.yellow(c)} ${this.options.map((a,m,E)=>{const y=u.includes(a.value)||a.group===!0&&this.isGroupSelected(`${a.value}`),F=m===this.cursor;return!F&&typeof a.group=="string"&&this.options[this.cursor].value===a.group?i(a,y?"group-active-selected":"group-active",E):F&&y?i(a,"active-selected",E):y?i(a,"selected",E):i(a,F?"active":"inactive",E)}).join(`
${t.yellow(c)} `)}
${l}
`}default:{const l=this.options.map((h,g,F)=>{const y=c.includes(h.value)||h.group===!0&&this.isGroupSelected(`${h.value}`),m=g===this.cursor,p=!m&&typeof h.group=="string"&&this.options[this.cursor].value===h.group;let $="";return p?$=i(h,y?"group-active-selected":"group-active",F):m&&y?$=i(h,"active-selected",F):y?$=i(h,"selected",F):$=i(h,m?"active":"inactive",F),`${g!==0&&!$.startsWith(`
`)?" ":""}${$}`}).join(`
${t.cyan(u)}`),a=l.startsWith(`
`)?"":" ";return`${o}${t.cyan(u)}${a}${l}
${t.cyan(_)}
`}}}}).prompt()},b={message:(e=[],{symbol:r=t.gray(u),secondarySymbol:s=t.gray(u),output:i=process.stdout,spacing:n=1}={})=>{const o=[];for(let l=0;l<n;l++)o.push(`${s}`);const c=Array.isArray(e)?e:e.split(`
`);if(c.length>0){const[l,...a]=c;l.length>0?o.push(`${r} ${l}`):o.push(r);for(const h of a)h.length>0?o.push(`${s} ${h}`):o.push(s)}i.write(`${o.join(`
`}default:{const l=this.options.map((m,E,y)=>{const F=u.includes(m.value)||m.group===!0&&this.isGroupSelected(`${m.value}`),p=E===this.cursor,h=!p&&typeof m.group=="string"&&this.options[this.cursor].value===m.group;let d="";return h?d=i(m,F?"group-active-selected":"group-active",y):p&&F?d=i(m,"active-selected",y):F?d=i(m,"selected",y):d=i(m,p?"active":"inactive",y),`${E!==0&&!d.startsWith(`
`)?" ":""}${d}`}).join(`
${t.cyan(c)}`),a=l.startsWith(`
`)?"":" ";return`${o}${t.cyan(c)}${a}${l}
${t.cyan(b)}
`}}}}).prompt()},O={message:(e=[],{symbol:r=t.gray(c),secondarySymbol:s=t.gray(c),output:i=process.stdout,spacing:n=1}={})=>{const o=[];for(let l=0;l<n;l++)o.push(`${s}`);const u=Array.isArray(e)?e:e.split(`
`);if(u.length>0){const[l,...a]=u;l.length>0?o.push(`${r} ${l}`):o.push(r);for(const m of a)m.length>0?o.push(`${s} ${m}`):o.push(s)}i.write(`${o.join(`
`)}
`)},info:(e,r)=>{b.message(e,{...r,symbol:t.blue(le)})},success:(e,r)=>{b.message(e,{...r,symbol:t.green(ue)})},step:(e,r)=>{b.message(e,{...r,symbol:t.green(L)})},warn:(e,r)=>{b.message(e,{...r,symbol:t.yellow(ce)})},warning:(e,r)=>{b.warn(e,r)},error:(e,r)=>{b.message(e,{...r,symbol:t.red($e)})}},xt=(e="",r)=>{(r?.output??process.stdout).write(`${t.gray(_)} ${t.red(e)}
`)},info:(e,r)=>{O.message(e,{...r,symbol:t.blue(ue)})},success:(e,r)=>{O.message(e,{...r,symbol:t.green(ce)})},step:(e,r)=>{O.message(e,{...r,symbol:t.green(W)})},warn:(e,r)=>{O.message(e,{...r,symbol:t.yellow($e)})},warning:(e,r)=>{O.warn(e,r)},error:(e,r)=>{O.message(e,{...r,symbol:t.red(de)})}},_t=(e="",r)=>{(r?.output??process.stdout).write(`${t.gray(b)} ${t.red(e)}
`)},bt=(e="",r)=>{(r?.output??process.stdout).write(`${t.gray(ne)} ${e}
`)},Dt=(e="",r)=>{(r?.output??process.stdout).write(`${t.gray(u)}
${t.gray(_)} ${e}
`)},Dt=(e="",r)=>{(r?.output??process.stdout).write(`${t.gray(ae)} ${e}
`)},Tt=(e="",r)=>{(r?.output??process.stdout).write(`${t.gray(c)}
${t.gray(b)} ${e}
`)},Tt=e=>{const r=(i,n)=>{const o=i.label??String(i.value);return n==="active"?`${t.cyan(J)} ${o}${i.hint?` ${t.dim(`(${i.hint})`)}`:""}`:n==="selected"?`${t.green(W)} ${t.dim(o)}${i.hint?` ${t.dim(`(${i.hint})`)}`:""}`:n==="cancelled"?`${t.strikethrough(t.dim(o))}`:n==="active-selected"?`${t.green(W)} ${o}${i.hint?` ${t.dim(`(${i.hint})`)}`:""}`:n==="submitted"?`${t.dim(o)}`:`${t.dim(X)} ${t.dim(o)}`},s=e.required??!0;return new ze({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValues:e.initialValues,required:s,cursorAt:e.cursorAt,validate(i){if(s&&(i===void 0||i.length===0))return`Please select at least one option.
${t.reset(t.dim(`Press ${t.gray(t.bgWhite(t.inverse(" space ")))} to select, ${t.gray(t.bgWhite(t.inverse(" enter ")))} to submit`))}`},render(){const i=`${t.gray(u)}
${M(this.state)} ${e.message}
`,n=this.value??[],o=(c,l)=>{const a=n.includes(c.value);return l&&a?r(c,"active-selected"):a?r(c,"selected"):r(c,l?"active":"inactive")};switch(this.state){case"submit":return`${i}${t.gray(u)} ${this.options.filter(({value:c})=>n.includes(c)).map(c=>r(c,"submitted")).join(t.dim(", "))||t.dim("none")}`;case"cancel":{const c=this.options.filter(({value:l})=>n.includes(l)).map(l=>r(l,"cancelled")).join(t.dim(", "));return`${i}${t.gray(u)}${c.trim()?` ${c}
${t.gray(u)}`:""}`}case"error":{const c=this.error.split(`
`).map((l,a)=>a===0?`${t.yellow(_)} ${t.yellow(l)}`:` ${l}`).join(`
`);return`${i+t.yellow(u)} ${k({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,style:o}).join(`
${t.yellow(u)} `)}
${c}
`}default:return`${i}${t.cyan(u)} ${k({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,style:o}).join(`
${t.cyan(u)} `)}
${t.cyan(_)}
`}}}).prompt()},Rt=e=>t.dim(e),Mt=(e="",r="",s)=>{const i=s?.format??Rt,n=["",...e.split(`
`).map(i),""],o=V(r).length,c=s?.output??process.stdout,l=Math.max(n.reduce((h,g)=>{const F=V(g);return F.length>h?F.length:h},0),o)+2,a=n.map(h=>`${t.gray(u)} ${h}${" ".repeat(l-V(h).length)}${t.gray(u)}`).join(`
`);c.write(`${t.gray(u)}
${t.green(L)} ${t.reset(r)} ${t.gray(Y.repeat(Math.max(l-o-1,1))+ae)}
`)},Rt=e=>{const r=(i,n)=>{const o=i.label??String(i.value);return n==="active"?`${t.cyan(X)} ${o}${i.hint?` ${t.dim(`(${i.hint})`)}`:""}`:n==="selected"?`${t.green(P)} ${t.dim(o)}${i.hint?` ${t.dim(`(${i.hint})`)}`:""}`:n==="cancelled"?`${t.strikethrough(t.dim(o))}`:n==="active-selected"?`${t.green(P)} ${o}${i.hint?` ${t.dim(`(${i.hint})`)}`:""}`:n==="submitted"?`${t.dim(o)}`:`${t.dim(Y)} ${t.dim(o)}`},s=e.required??!0;return new Ze({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValues:e.initialValues,required:s,cursorAt:e.cursorAt,validate(i){if(s&&(i===void 0||i.length===0))return`Please select at least one option.
${t.reset(t.dim(`Press ${t.gray(t.bgWhite(t.inverse(" space ")))} to select, ${t.gray(t.bgWhite(t.inverse(" enter ")))} to submit`))}`},render(){const i=`${t.gray(c)}
${L(this.state)} ${e.message}
`,n=this.value??[],o=(u,l)=>{const a=n.includes(u.value);return l&&a?r(u,"active-selected"):a?r(u,"selected"):r(u,l?"active":"inactive")};switch(this.state){case"submit":return`${i}${t.gray(c)} ${this.options.filter(({value:u})=>n.includes(u)).map(u=>r(u,"submitted")).join(t.dim(", "))||t.dim("none")}`;case"cancel":{const u=this.options.filter(({value:l})=>n.includes(l)).map(l=>r(l,"cancelled")).join(t.dim(", "));return`${i}${t.gray(c)}${u.trim()?` ${u}
${t.gray(c)}`:""}`}case"error":{const u=this.error.split(`
`).map((l,a)=>a===0?`${t.yellow(b)} ${t.yellow(l)}`:` ${l}`).join(`
`);return`${i+t.yellow(c)} ${G({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,style:o}).join(`
${t.yellow(c)} `)}
${u}
`}default:return`${i}${t.cyan(c)} ${G({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,style:o}).join(`
${t.cyan(c)} `)}
${t.cyan(b)}
`}}}).prompt()},Mt=e=>t.dim(e),Ot=(e,r,s)=>{const i={hard:!0,trim:!1},n=k(e,r,i).split(`
`),o=n.reduce((a,m)=>Math.max(M(m),a),0),u=n.map(s).reduce((a,m)=>Math.max(M(m),a),0),l=r-(u-o);return k(e,l,i)},Nt=(e="",r="",s)=>{const i=s?.output??N.stdout,n=s?.format??Mt,o=["",...Ot(e,H(i)-6,n).split(`
`).map(n),""],u=M(r),l=Math.max(o.reduce((m,E)=>{const y=M(E);return y>m?y:m},0),u)+2,a=o.map(m=>`${t.gray(c)} ${m}${" ".repeat(l-M(m))}${t.gray(c)}`).join(`
`);i.write(`${t.gray(c)}
${t.green(W)} ${t.reset(r)} ${t.gray(z.repeat(Math.max(l-u-1,1))+oe)}
${a}
${t.gray(be+Y.repeat(l+2)+oe)}
`)},Ot=e=>new Ze({validate:e.validate,mask:e.mask??xe,signal:e.signal,input:e.input,output:e.output,render(){const r=`${t.gray(u)}
${M(this.state)} ${e.message}
${t.gray(_e+z.repeat(l+2)+le)}
`)},Lt=e=>new Qe({validate:e.validate,mask:e.mask??be,signal:e.signal,input:e.input,output:e.output,render(){const r=`${t.gray(c)}
${L(this.state)} ${e.message}
`,s=this.userInputWithCursor,i=this.masked;switch(this.state){case"error":{const n=i?` ${i}`:"";return e.clearOnError&&this.clear(),`${r.trim()}
${t.yellow(u)}${n}
${t.yellow(_)} ${t.yellow(this.error)}
`}case"submit":{const n=i?` ${t.dim(i)}`:"";return`${r}${t.gray(u)}${n}`}case"cancel":{const n=i?` ${t.strikethrough(t.dim(i))}`:"";return`${r}${t.gray(u)}${n}${i?`
${t.gray(u)}`:""}`}default:return`${r}${t.cyan(u)} ${s}
${t.cyan(_)}
`}}}).prompt(),Nt=e=>{const r=e.validate;return Oe({...e,initialUserInput:e.initialValue??e.root??process.cwd(),maxItems:5,validate(s){if(!Array.isArray(s)){if(!s)return"Please select a path";if(r)return r(s)}},options(){const s=this.userInput;if(s==="")return[];try{let i;return nt(s)?ve(s).isDirectory()?i=s:i=Ae(s):i=Ae(s),it(i).map(n=>{const o=at(i,n),c=ve(o);return{name:n,path:o,isDirectory:c.isDirectory()}}).filter(({path:n,isDirectory:o})=>n.startsWith(s)&&(e.directory||!o)).map(n=>({value:n.path}))}catch{return[]}}})},fe=({indicator:e="dots",onCancel:r,output:s=process.stdout,cancelMessage:i,errorMessage:n,frames:o=q?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],delay:c=q?80:120,signal:l}={})=>{const a=se();let h,g,F=!1,y=!1,m="",p,$=performance.now();const d=te(s),f=S=>{const D=S>1?n??Ee.messages.error:i??Ee.messages.cancel;y=S===1,F&&(N(D,S),y&&typeof r=="function"&&r())},E=()=>f(2),v=()=>f(1),w=()=>{process.on("uncaughtExceptionMonitor",E),process.on("unhandledRejection",E),process.on("SIGINT",v),process.on("SIGTERM",v),process.on("exit",f),l&&l.addEventListener("abort",v)},B=()=>{process.removeListener("uncaughtExceptionMonitor",E),process.removeListener("unhandledRejection",E),process.removeListener("SIGINT",v),process.removeListener("SIGTERM",v),process.removeListener("exit",f),l&&l.removeEventListener("abort",v)},x=()=>{if(p===void 0)return;a&&s.write(`
`);const S=Fe(p,d,{hard:!0,trim:!1}).split(`
`);S.length>1&&s.write(Ce.up(S.length-1)),s.write(Ce.to(0)),s.write(Ie.down())},A=S=>S.replace(/\.+$/,""),C=S=>{const D=(performance.now()-S)/1e3,R=Math.floor(D/60),j=Math.floor(D%60);return R>0?`[${R}m ${j}s]`:`[${j}s]`},O=(S="")=>{F=!0,h=Qe({output:s}),m=A(S),$=performance.now(),s.write(`${t.gray(u)}
`);let D=0,R=0;w(),g=setInterval(()=>{if(a&&m===p)return;x(),p=m;const j=t.magenta(o[D]);let K;if(a)K=`${j} ${m}...`;else if(e==="timer")K=`${j} ${m} ${C($)}`;else{const qe=".".repeat(Math.floor(R)).slice(0,3);K=`${j} ${m}${qe}`}const Ke=Fe(K,d,{hard:!0,trim:!1});s.write(Ke),D=D+1<o.length?D+1:0,R=R<4?R+.125:0},c)},N=(S="",D=0)=>{F=!1,clearInterval(g),x();const R=D===0?t.green(L):D===1?t.red(re):t.red(ie);m=S??m,e==="timer"?s.write(`${R} ${m} ${C($)}
`):s.write(`${R} ${m}
`),B(),h()};return{start:O,stop:N,message:(S="")=>{m=A(S??m)},get isCancelled(){return y}}},He={light:I("\u2500","-"),heavy:I("\u2501","="),block:I("\u2588","#")};function Lt({style:e="heavy",max:r=100,size:s=40,...i}={}){const n=fe(i);let o=0,c="";const l=Math.max(1,r),a=Math.max(1,s),h=m=>{switch(m){case"initial":case"active":return t.magenta;case"error":case"cancel":return t.red;case"submit":return t.green;default:return t.magenta}},g=(m,p)=>{const $=Math.floor(o/l*a);return`${h(m)(He[e].repeat($))}${t.dim(He[e].repeat(a-$))} ${p}`},F=(m="")=>(c=m,n.start(g("initial",m))),y=(m=1,p)=>{o=Math.min(l,m+o),n.message(g("active",p??c)),c=p??c};return{start:F,stop:n.stop,advance:y,isCancelled:n.isCancelled,message:m=>y(0,m)}}const Wt=e=>{const r=(s,i)=>{const n=s.label??String(s.value);switch(i){case"selected":return`${t.dim(n)}`;case"active":return`${t.green(G)} ${n}${s.hint?` ${t.dim(`(${s.hint})`)}`:""}`;case"cancelled":return`${t.strikethrough(t.dim(n))}`;default:return`${t.dim(H)} ${t.dim(n)}`}};return new et({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){const s=`${t.gray(u)}
${M(this.state)} ${e.message}
`;switch(this.state){case"submit":return`${s}${t.gray(u)} ${r(this.options[this.cursor],"selected")}`;case"cancel":return`${s}${t.gray(u)} ${r(this.options[this.cursor],"cancelled")}
${t.gray(u)}`;default:return`${s}${t.cyan(u)} ${k({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,style:(i,n)=>r(i,n?"active":"inactive")}).join(`
${t.cyan(u)} `)}
${t.cyan(_)}
`}}}).prompt()},Pt=e=>{const r=(s,i="inactive")=>{const n=s.label??String(s.value);return i==="selected"?`${t.dim(n)}`:i==="cancelled"?`${t.strikethrough(t.dim(n))}`:i==="active"?`${t.bgCyan(t.gray(` ${s.value} `))} ${n} ${s.hint?t.dim(`(${s.hint})`):""}`:`${t.gray(t.bgWhite(t.inverse(` ${s.value} `)))} ${n} ${s.hint?t.dim(`(${s.hint})`):""}`};return new tt({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){const s=`${t.gray(u)}
${M(this.state)} ${e.message}
`;switch(this.state){case"submit":return`${s}${t.gray(u)} ${r(this.options.find(i=>i.value===this.value)??e.options[0],"selected")}`;case"cancel":return`${s}${t.gray(u)} ${r(this.options[0],"cancelled")}
${t.gray(u)}`;default:return`${s}${t.cyan(u)} ${this.options.map((i,n)=>r(i,n===this.cursor?"active":"inactive")).join(`
${t.cyan(u)} `)}
${t.cyan(_)}
`}}}).prompt()},Ue=`${t.gray(u)} `,P={message:async(e,{symbol:r=t.gray(u)}={})=>{process.stdout.write(`${t.gray(u)}
${t.yellow(c)}${n}
${t.yellow(b)} ${t.yellow(this.error)}
`}case"submit":{const n=i?` ${t.dim(i)}`:"";return`${r}${t.gray(c)}${n}`}case"cancel":{const n=i?` ${t.strikethrough(t.dim(i))}`:"";return`${r}${t.gray(c)}${n}${i?`
${t.gray(c)}`:""}`}default:return`${r}${t.cyan(c)} ${s}
${t.cyan(b)}
`}}}).prompt(),Wt=e=>{const r=e.validate;return ke({...e,initialUserInput:e.initialValue??e.root??process.cwd(),maxItems:5,validate(s){if(!Array.isArray(s)){if(!s)return"Please select a path";if(r)return r(s)}},options(){const s=this.userInput;if(s==="")return[];try{let i;return nt(s)?ve(s).isDirectory()?i=s:i=Ae(s):i=Ae(s),it(i).map(n=>{const o=at(i,n),u=ve(o);return{name:n,path:o,isDirectory:u.isDirectory()}}).filter(({path:n,isDirectory:o})=>n.startsWith(s)&&(e.directory||!o)).map(n=>({value:n.path}))}catch{return[]}}})},Fe=({indicator:e="dots",onCancel:r,output:s=process.stdout,cancelMessage:i,errorMessage:n,frames:o=J?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],delay:u=J?80:120,signal:l}={})=>{const a=re();let m,E,y=!1,F=!1,p="",h,d=performance.now();const $=H(s),g=I=>{const T=I>1?n??Ee.messages.error:i??Ee.messages.cancel;F=I===1,y&&(D(T,I),F&&typeof r=="function"&&r())},f=()=>g(2),v=()=>g(1),w=()=>{process.on("uncaughtExceptionMonitor",f),process.on("unhandledRejection",f),process.on("SIGINT",v),process.on("SIGTERM",v),process.on("exit",g),l&&l.addEventListener("abort",v)},B=()=>{process.removeListener("uncaughtExceptionMonitor",f),process.removeListener("unhandledRejection",f),process.removeListener("SIGINT",v),process.removeListener("SIGTERM",v),process.removeListener("exit",g),l&&l.removeEventListener("abort",v)},x=()=>{if(h===void 0)return;a&&s.write(`
`);const I=k(h,$,{hard:!0,trim:!1}).split(`
`);I.length>1&&s.write(Ce.up(I.length-1)),s.write(Ce.to(0)),s.write(Ie.down())},A=I=>I.replace(/\.+$/,""),C=I=>{const T=(performance.now()-I)/1e3,R=Math.floor(T/60),V=Math.floor(T%60);return R>0?`[${R}m ${V}s]`:`[${V}s]`},_=(I="")=>{y=!0,m=et({output:s}),p=A(I),d=performance.now(),s.write(`${t.gray(c)}
`);let T=0,R=0;w(),E=setInterval(()=>{if(a&&p===h)return;x(),h=p;const V=t.magenta(o[T]);let q;if(a)q=`${V} ${p}...`;else if(e==="timer")q=`${V} ${p} ${C(d)}`;else{const qe=".".repeat(Math.floor(R)).slice(0,3);q=`${V} ${p}${qe}`}const Ke=k(q,$,{hard:!0,trim:!1});s.write(Ke),T=T+1<o.length?T+1:0,R=R<4?R+.125:0},u)},D=(I="",T=0)=>{if(!y)return;y=!1,clearInterval(E),x();const R=T===0?t.green(W):T===1?t.red(ie):t.red(ne);p=I??p,e==="timer"?s.write(`${R} ${p} ${C(d)}
`):s.write(`${R} ${p}
`),B(),m()};return{start:_,stop:D,message:(I="")=>{p=A(I??p)},get isCancelled(){return F}}},He={light:S("\u2500","-"),heavy:S("\u2501","="),block:S("\u2588","#")};function Pt({style:e="heavy",max:r=100,size:s=40,...i}={}){const n=Fe(i);let o=0,u="";const l=Math.max(1,r),a=Math.max(1,s),m=p=>{switch(p){case"initial":case"active":return t.magenta;case"error":case"cancel":return t.red;case"submit":return t.green;default:return t.magenta}},E=(p,h)=>{const d=Math.floor(o/l*a);return`${m(p)(He[e].repeat(d))}${t.dim(He[e].repeat(a-d))} ${h}`},y=(p="")=>{u=p,n.start(E("initial",p))},F=(p=1,h)=>{o=Math.min(l,p+o),n.message(E("active",h??u)),u=h??u};return{start:y,stop:n.stop,advance:F,isCancelled:n.isCancelled,message:p=>F(0,p)}}const jt=e=>{const r=(s,i)=>{const n=s.label??String(s.value);switch(i){case"selected":return`${t.dim(n)}`;case"active":return`${t.green(U)} ${n}${s.hint?` ${t.dim(`(${s.hint})`)}`:""}`;case"cancelled":return`${t.strikethrough(t.dim(n))}`;default:return`${t.dim(K)} ${t.dim(n)}`}};return new tt({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){const s=`${t.gray(c)}
${L(this.state)} ${e.message}
`;switch(this.state){case"submit":return`${s}${t.gray(c)} ${r(this.options[this.cursor],"selected")}`;case"cancel":return`${s}${t.gray(c)} ${r(this.options[this.cursor],"cancelled")}
${t.gray(c)}`;default:return`${s}${t.cyan(c)} ${G({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,style:(i,n)=>r(i,n?"active":"inactive")}).join(`
${t.cyan(c)} `)}
${t.cyan(b)}
`}}}).prompt()},Vt=e=>{const r=(s,i="inactive")=>{const n=s.label??String(s.value);return i==="selected"?`${t.dim(n)}`:i==="cancelled"?`${t.strikethrough(t.dim(n))}`:i==="active"?`${t.bgCyan(t.gray(` ${s.value} `))} ${n} ${s.hint?t.dim(`(${s.hint})`):""}`:`${t.gray(t.bgWhite(t.inverse(` ${s.value} `)))} ${n} ${s.hint?t.dim(`(${s.hint})`):""}`};return new st({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){const s=`${t.gray(c)}
${L(this.state)} ${e.message}
`;switch(this.state){case"submit":return`${s}${t.gray(c)} ${r(this.options.find(i=>i.value===this.value)??e.options[0],"selected")}`;case"cancel":return`${s}${t.gray(c)} ${r(this.options[0],"cancelled")}
${t.gray(c)}`;default:return`${s}${t.cyan(c)} ${this.options.map((i,n)=>r(i,n===this.cursor?"active":"inactive")).join(`
${t.cyan(c)} `)}
${t.cyan(b)}
`}}}).prompt()},Ue=`${t.gray(c)} `,j={message:async(e,{symbol:r=t.gray(c)}={})=>{process.stdout.write(`${t.gray(c)}
${r} `);let s=3;for await(let i of e){i=i.replace(/\n/g,`
${Ue}`),i.includes(`
`)&&(s=3+V(i.slice(i.lastIndexOf(`
`))).length);const n=V(i).length;s+n<process.stdout.columns?(s+=n,process.stdout.write(i)):(process.stdout.write(`
${Ue}${i.trimStart()}`),s=3+V(i.trimStart()).length)}process.stdout.write(`
`)},info:e=>P.message(e,{symbol:t.blue(le)}),success:e=>P.message(e,{symbol:t.green(ue)}),step:e=>P.message(e,{symbol:t.green(L)}),warn:e=>P.message(e,{symbol:t.yellow(ce)}),warning:e=>P.warn(e),error:e=>P.message(e,{symbol:t.red($e)})},jt=async(e,r)=>{for(const s of e){if(s.enabled===!1)continue;const i=fe(r);i.start(s.title);const n=await s.task(i.message);i.stop(n||s.title)}},Vt=e=>{const r=e.output??process.stdout,s=te(r),i=t.gray(u),n=e.spacing??1,o=3,c=e.retainLog===!0,l=!se()&&Se(r);r.write(`${i}
`),r.write(`${t.green(L)} ${e.title}
`);for(let d=0;d<n;d++)r.write(`${i}
`);const a=[{value:"",full:""}];let h=!1;const g=d=>{if(a.length===0)return;let f=0;d&&(f+=n+2);for(const E of a){const{value:v,result:w}=E;let B=w?.message??v;if(B.length===0)continue;w===void 0&&E.header!==void 0&&E.header!==""&&(B+=`
${E.header}`);const x=B.split(`
`).reduce((A,C)=>C===""?A+1:A+Math.ceil((C.length+o)/s),0);f+=x}f>0&&(f+=1,r.write(Ie.lines(f)))},F=(d,f,E)=>{const v=E?`${d.full}
${d.value}`:d.value;d.header!==void 0&&d.header!==""&&b.message(d.header.split(`
`).map(t.bold),{output:r,secondarySymbol:i,symbol:i,spacing:0}),b.message(v.split(`
`).map(t.dim),{output:r,secondarySymbol:i,symbol:i,spacing:f??n})},y=()=>{for(const d of a){const{header:f,value:E,full:v}=d;(f===void 0||f.length===0)&&E.length===0||F(d,void 0,c===!0&&v.length>0)}},m=(d,f,E)=>{if(g(!1),(E?.raw!==!0||!h)&&d.value!==""&&(d.value+=`
`),d.value+=f,h=E?.raw===!0,e.limit!==void 0){const v=d.value.split(`
`),w=v.length-e.limit;if(w>0){const B=v.splice(0,w);c&&(d.full+=(d.full===""?"":`
`)&&(s=3+se(i.slice(i.lastIndexOf(`
`))).length);const n=se(i).length;s+n<process.stdout.columns?(s+=n,process.stdout.write(i)):(process.stdout.write(`
${Ue}${i.trimStart()}`),s=3+se(i.trimStart()).length)}process.stdout.write(`
`)},info:e=>j.message(e,{symbol:t.blue(ue)}),success:e=>j.message(e,{symbol:t.green(ce)}),step:e=>j.message(e,{symbol:t.green(W)}),warn:e=>j.message(e,{symbol:t.yellow($e)}),warning:e=>j.warn(e),error:e=>j.message(e,{symbol:t.red(de)})},kt=async(e,r)=>{for(const s of e){if(s.enabled===!1)continue;const i=Fe(r);i.start(s.title);const n=await s.task(i.message);i.stop(n||s.title)}},Gt=e=>{const r=e.output??process.stdout,s=H(r),i=t.gray(c),n=e.spacing??1,o=3,u=e.retainLog===!0,l=!re()&&Se(r);r.write(`${i}
`),r.write(`${t.green(W)} ${e.title}
`);for(let $=0;$<n;$++)r.write(`${i}
`);const a=[{value:"",full:""}];let m=!1;const E=$=>{if(a.length===0)return;let g=0;$&&(g+=n+2);for(const f of a){const{value:v,result:w}=f;let B=w?.message??v;if(B.length===0)continue;w===void 0&&f.header!==void 0&&f.header!==""&&(B+=`
${f.header}`);const x=B.split(`
`).reduce((A,C)=>C===""?A+1:A+Math.ceil((C.length+o)/s),0);g+=x}g>0&&(g+=1,r.write(Ie.lines(g)))},y=($,g,f)=>{const v=f?`${$.full}
${$.value}`:$.value;$.header!==void 0&&$.header!==""&&O.message($.header.split(`
`).map(t.bold),{output:r,secondarySymbol:i,symbol:i,spacing:0}),O.message(v.split(`
`).map(t.dim),{output:r,secondarySymbol:i,symbol:i,spacing:g??n})},F=()=>{for(const $ of a){const{header:g,value:f,full:v}=$;(g===void 0||g.length===0)&&f.length===0||y($,void 0,u===!0&&v.length>0)}},p=($,g,f)=>{if(E(!1),(f?.raw!==!0||!m)&&$.value!==""&&($.value+=`
`),$.value+=g,m=f?.raw===!0,e.limit!==void 0){const v=$.value.split(`
`),w=v.length-e.limit;if(w>0){const B=v.splice(0,w);u&&($.full+=($.full===""?"":`
`)+B.join(`
`))}d.value=v.join(`
`)}l&&p()},p=()=>{for(const d of a)d.result?d.result.status==="error"?b.error(d.result.message,{output:r,secondarySymbol:i,spacing:0}):b.success(d.result.message,{output:r,secondarySymbol:i,spacing:0}):d.value!==""&&F(d,0)},$=(d,f)=>{g(!1),d.result=f,l&&p()};return{message(d,f){m(a[0],d,f)},group(d){const f={header:d,value:"",full:""};return a.push(f),{message(E,v){m(f,E,v)},error(E){$(f,{status:"error",message:E})},success(E){$(f,{status:"success",message:E})}}},error(d,f){g(!0),b.error(d,{output:r,secondarySymbol:i,spacing:1}),f?.showLog!==!1&&y(),a.splice(1,a.length-1),a[0].value="",a[0].full=""},success(d,f){g(!0),b.success(d,{output:r,secondarySymbol:i,spacing:1}),f?.showLog===!0&&y(),a.splice(1,a.length-1),a[0].value="",a[0].full=""}}},kt=e=>new st({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,output:e.output,signal:e.signal,input:e.input,render(){const r=`${t.gray(u)}
${M(this.state)} ${e.message}
`))}$.value=v.join(`
`)}l&&h()},h=()=>{for(const $ of a)$.result?$.result.status==="error"?O.error($.result.message,{output:r,secondarySymbol:i,spacing:0}):O.success($.result.message,{output:r,secondarySymbol:i,spacing:0}):$.value!==""&&y($,0)},d=($,g)=>{E(!1),$.result=g,l&&h()};return{message($,g){p(a[0],$,g)},group($){const g={header:$,value:"",full:""};return a.push(g),{message(f,v){p(g,f,v)},error(f){d(g,{status:"error",message:f})},success(f){d(g,{status:"success",message:f})}}},error($,g){E(!0),O.error($,{output:r,secondarySymbol:i,spacing:1}),g?.showLog!==!1&&F(),a.splice(1,a.length-1),a[0].value="",a[0].full=""},success($,g){E(!0),O.success($,{output:r,secondarySymbol:i,spacing:1}),g?.showLog===!0&&F(),a.splice(1,a.length-1),a[0].value="",a[0].full=""}}},Ht=e=>new rt({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,output:e.output,signal:e.signal,input:e.input,render(){const r=`${t.gray(c)}
${L(this.state)} ${e.message}
`,s=e.placeholder?t.inverse(e.placeholder[0])+t.dim(e.placeholder.slice(1)):t.inverse(t.hidden("_")),i=this.userInput?this.userInputWithCursor:s,n=this.value??"";switch(this.state){case"error":{const o=this.error?` ${t.yellow(this.error)}`:"";return`${r.trim()}
${t.yellow(u)} ${i}
${t.yellow(_)}${o}
`}case"submit":{const o=n?` ${t.dim(n)}`:"";return`${r}${t.gray(u)}${o}`}case"cancel":{const o=n?` ${t.strikethrough(t.dim(n))}`:"";return`${r}${t.gray(u)}${o}${n.trim()?`
${t.gray(u)}`:""}`}default:return`${r}${t.cyan(u)} ${i}
${t.cyan(_)}
`}}}).prompt();export{u as S_BAR,_ as S_BAR_END,_e as S_BAR_END_RIGHT,Y as S_BAR_H,ne as S_BAR_START,Be as S_BAR_START_RIGHT,J as S_CHECKBOX_ACTIVE,X as S_CHECKBOX_INACTIVE,W as S_CHECKBOX_SELECTED,be as S_CONNECT_LEFT,De as S_CORNER_BOTTOM_LEFT,oe as S_CORNER_BOTTOM_RIGHT,Te as S_CORNER_TOP_LEFT,ae as S_CORNER_TOP_RIGHT,$e as S_ERROR,le as S_INFO,xe as S_PASSWORD_MASK,G as S_RADIO_ACTIVE,H as S_RADIO_INACTIVE,we as S_STEP_ACTIVE,re as S_STEP_CANCEL,ie as S_STEP_ERROR,L as S_STEP_SUBMIT,ue as S_SUCCESS,ce as S_WARN,Oe as autocomplete,ut as autocompleteMultiselect,St as box,xt as cancel,wt as confirm,Bt as group,_t as groupMultiselect,bt as intro,se as isCI,Se as isTTY,k as limitOptions,b as log,Tt as multiselect,Mt as note,Dt as outro,Ot as password,Nt as path,Lt as progress,Wt as select,Pt as selectKey,fe as spinner,P as stream,M as symbol,Vt as taskLog,jt as tasks,kt as text,q as unicode,I as unicodeOr};
${t.yellow(c)} ${i}
${t.yellow(b)}${o}
`}case"submit":{const o=n?` ${t.dim(n)}`:"";return`${r}${t.gray(c)}${o}`}case"cancel":{const o=n?` ${t.strikethrough(t.dim(n))}`:"";return`${r}${t.gray(c)}${o}${n.trim()?`
${t.gray(c)}`:""}`}default:return`${r}${t.cyan(c)} ${i}
${t.cyan(b)}
`}}}).prompt();export{c as S_BAR,b as S_BAR_END,xe as S_BAR_END_RIGHT,z as S_BAR_H,ae as S_BAR_START,Be as S_BAR_START_RIGHT,X as S_CHECKBOX_ACTIVE,Y as S_CHECKBOX_INACTIVE,P as S_CHECKBOX_SELECTED,_e as S_CONNECT_LEFT,De as S_CORNER_BOTTOM_LEFT,le as S_CORNER_BOTTOM_RIGHT,Te as S_CORNER_TOP_LEFT,oe as S_CORNER_TOP_RIGHT,de as S_ERROR,ue as S_INFO,be as S_PASSWORD_MASK,U as S_RADIO_ACTIVE,K as S_RADIO_INACTIVE,we as S_STEP_ACTIVE,ie as S_STEP_CANCEL,ne as S_STEP_ERROR,W as S_STEP_SUBMIT,ce as S_SUCCESS,$e as S_WARN,ke as autocomplete,At as autocompleteMultiselect,wt as box,_t as cancel,Bt as confirm,xt as group,bt as groupMultiselect,Dt as intro,re as isCI,Se as isTTY,G as limitOptions,O as log,Rt as multiselect,Nt as note,Tt as outro,Lt as password,Wt as path,Pt as progress,jt as select,Vt as selectKey,Fe as spinner,j as stream,L as symbol,Gt as taskLog,kt as tasks,Ht as text,J as unicode,S as unicodeOr};
//# sourceMappingURL=index.mjs.map
{
"name": "@clack/prompts",
"version": "1.0.0-alpha.4",
"version": "1.0.0-alpha.5",
"type": "module",

@@ -52,10 +52,11 @@ "main": "./dist/index.mjs",

"sisteransi": "^1.0.5",
"@clack/core": "1.0.0-alpha.4"
"@clack/core": "1.0.0-alpha.5"
},
"devDependencies": {
"fast-string-width": "^1.1.0",
"fast-wrap-ansi": "^0.1.3",
"is-unicode-supported": "^1.3.0",
"memfs": "^4.17.2",
"vitest": "^3.2.4",
"vitest-ansi-serializer": "^0.1.2",
"fast-wrap-ansi": "^0.1.3"
"vitest-ansi-serializer": "^0.1.2"
},

@@ -62,0 +63,0 @@ "scripts": {

@@ -206,3 +206,5 @@ # `@clack/prompts`

```js
await p.tasks([
import { tasks } from '@clack/prompts';
await tasks([
{

@@ -209,0 +211,0 @@ title: 'Installing via npm',

Sorry, the diff of this file is too big to display