import{TextPrompt as q,PasswordPrompt as F,ConfirmPrompt as D,SelectPrompt as U,SelectKeyPrompt as Z,MultiSelectPrompt as z,GroupMultiSelectPrompt as J,isCancel as Y,block as K}from"@clack/core";export{isCancel,updateSettings}from"@clack/core";import h from"node:process";import e from"picocolors";import{cursor as Q,erase as H}from"sisteransi";function X(){return h.platform!=="win32"?h.env.TERM!=="linux":!!h.env.CI||!!h.env.WT_SESSION||!!h.env.TERMINUS_SUBLIME||h.env.ConEmuTask==="{cmd::Cmder}"||h.env.TERM_PROGRAM==="Terminus-Sublime"||h.env.TERM_PROGRAM==="vscode"||h.env.TERM==="xterm-256color"||h.env.TERM==="alacritty"||h.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}const T=X(),u=(s,n)=>T?s:n,ee=u("\u25C6","*"),V=u("\u25A0","x"),B=u("\u25B2","x"),S=u("\u25C7","o"),te=u("\u250C","T"),a=u("\u2502","|"),m=u("\u2514","\u2014"),j=u("\u25CF",">"),E=u("\u25CB"," "),R=u("\u25FB","[\u2022]"),M=u("\u25FC","[+]"),G=u("\u25FB","[ ]"),se=u("\u25AA","\u2022"),_=u("\u2500","-"),re=u("\u256E","+"),ie=u("\u251C","+"),ne=u("\u256F","+"),ae=u("\u25CF","\u2022"),oe=u("\u25C6","*"),ce=u("\u25B2","!"),le=u("\u25A0","x"),y=s=>{switch(s){case"initial":case"active":return e.cyan(ee);case"cancel":return e.red(V);case"error":return e.yellow(B);case"submit":return e.green(S)}},A=s=>{const{cursor:n,options:t,style:i}=s,r=s.maxItems??Number.POSITIVE_INFINITY,c=Math.max(process.stdout.rows-4,0),o=Math.min(c,Math.max(r,5));let l=0;n>=l+o-3?l=Math.max(Math.min(n-o+3,t.length-o),0):n<l+2&&(l=Math.max(n-2,0));const $=o<t.length&&l>0,d=o<t.length&&l+o<t.length;return t.slice(l,l+o).map((w,b,C)=>{const I=b===0&&$,x=b===C.length-1&&d;return I||x?e.dim("..."):i(w,b+l===n)})},ue=s=>new q({validate:s.validate,placeholder:s.placeholder,defaultValue:s.defaultValue,initialValue:s.initialValue,render(){const n=`${e.gray(a)}
${y(this.state)}  ${s.message}
`,t=s.placeholder?e.inverse(s.placeholder[0])+e.dim(s.placeholder.slice(1)):e.inverse(e.hidden("_")),i=this.value?this.valueWithCursor:t;switch(this.state){case"error":return`${n.trim()}
${e.yellow(a)}  ${i}
${e.yellow(m)}  ${e.yellow(this.error)}
`;case"submit":return`${n}${e.gray(a)}  ${e.dim(this.value||s.placeholder)}`;case"cancel":return`${n}${e.gray(a)}  ${e.strikethrough(e.dim(this.value??""))}${this.value?.trim()?`
${e.gray(a)}`:""}`;default:return`${n}${e.cyan(a)}  ${i}
${e.cyan(m)}
`}}}).prompt(),$e=s=>new F({validate:s.validate,mask:s.mask??se,render(){const n=`${e.gray(a)}
${y(this.state)}  ${s.message}
`,t=this.valueWithCursor,i=this.masked;switch(this.state){case"error":return`${n.trim()}
${e.yellow(a)}  ${i}
${e.yellow(m)}  ${e.yellow(this.error)}
`;case"submit":return`${n}${e.gray(a)}  ${e.dim(i)}`;case"cancel":return`${n}${e.gray(a)}  ${e.strikethrough(e.dim(i??""))}${i?`
${e.gray(a)}`:""}`;default:return`${n}${e.cyan(a)}  ${t}
${e.cyan(m)}
`}}}).prompt(),me=s=>{const n=s.active??"Yes",t=s.inactive??"No";return new D({active:n,inactive:t,initialValue:s.initialValue??!0,render(){const i=`${e.gray(a)}
${y(this.state)}  ${s.message}
`,r=this.value?n:t;switch(this.state){case"submit":return`${i}${e.gray(a)}  ${e.dim(r)}`;case"cancel":return`${i}${e.gray(a)}  ${e.strikethrough(e.dim(r))}
${e.gray(a)}`;default:return`${i}${e.cyan(a)}  ${this.value?`${e.green(j)} ${n}`:`${e.dim(E)} ${e.dim(n)}`} ${e.dim("/")} ${this.value?`${e.dim(E)} ${e.dim(t)}`:`${e.green(j)} ${t}`}
${e.cyan(m)}
`}}}).prompt()},de=s=>{const n=(t,i)=>{const r=t.label??String(t.value);switch(i){case"selected":return`${e.dim(r)}`;case"active":return`${e.green(j)} ${r} ${t.hint?e.dim(`(${t.hint})`):""}`;case"cancelled":return`${e.strikethrough(e.dim(r))}`;default:return`${e.dim(E)} ${e.dim(r)}`}};return new U({options:s.options,initialValue:s.initialValue,render(){const t=`${e.gray(a)}
${y(this.state)}  ${s.message}
`;switch(this.state){case"submit":return`${t}${e.gray(a)}  ${n(this.options[this.cursor],"selected")}`;case"cancel":return`${t}${e.gray(a)}  ${n(this.options[this.cursor],"cancelled")}
${e.gray(a)}`;default:return`${t}${e.cyan(a)}  ${A({cursor:this.cursor,options:this.options,maxItems:s.maxItems,style:(i,r)=>n(i,r?"active":"inactive")}).join(`
${e.cyan(a)}  `)}
${e.cyan(m)}
`}}}).prompt()},pe=s=>{const n=(t,i="inactive")=>{const r=t.label??String(t.value);return i==="selected"?`${e.dim(r)}`:i==="cancelled"?`${e.strikethrough(e.dim(r))}`:i==="active"?`${e.bgCyan(e.gray(` ${t.value} `))} ${r} ${t.hint?e.dim(`(${t.hint})`):""}`:`${e.gray(e.bgWhite(e.inverse(` ${t.value} `)))} ${r} ${t.hint?e.dim(`(${t.hint})`):""}`};return new Z({options:s.options,initialValue:s.initialValue,render(){const t=`${e.gray(a)}
${y(this.state)}  ${s.message}
`;switch(this.state){case"submit":return`${t}${e.gray(a)}  ${n(this.options.find(i=>i.value===this.value)??s.options[0],"selected")}`;case"cancel":return`${t}${e.gray(a)}  ${n(this.options[0],"cancelled")}
${e.gray(a)}`;default:return`${t}${e.cyan(a)}  ${this.options.map((i,r)=>n(i,r===this.cursor?"active":"inactive")).join(`
${e.cyan(a)}  `)}
${e.cyan(m)}
`}}}).prompt()},he=s=>{const n=(t,i)=>{const r=t.label??String(t.value);return i==="active"?`${e.cyan(R)} ${r} ${t.hint?e.dim(`(${t.hint})`):""}`:i==="selected"?`${e.green(M)} ${e.dim(r)}`:i==="cancelled"?`${e.strikethrough(e.dim(r))}`:i==="active-selected"?`${e.green(M)} ${r} ${t.hint?e.dim(`(${t.hint})`):""}`:i==="submitted"?`${e.dim(r)}`:`${e.dim(G)} ${e.dim(r)}`};return new z({options:s.options,initialValues:s.initialValues,required:s.required??!0,cursorAt:s.cursorAt,validate(t){if(this.required&&t.length===0)return`Please select at least one option.
${e.reset(e.dim(`Press ${e.gray(e.bgWhite(e.inverse(" space ")))} to select, ${e.gray(e.bgWhite(e.inverse(" enter ")))} to submit`))}`},render(){const t=`${e.gray(a)}
${y(this.state)}  ${s.message}
`,i=(r,c)=>{const o=this.value.includes(r.value);return c&&o?n(r,"active-selected"):o?n(r,"selected"):n(r,c?"active":"inactive")};switch(this.state){case"submit":return`${t}${e.gray(a)}  ${this.options.filter(({value:r})=>this.value.includes(r)).map(r=>n(r,"submitted")).join(e.dim(", "))||e.dim("none")}`;case"cancel":{const r=this.options.filter(({value:c})=>this.value.includes(c)).map(c=>n(c,"cancelled")).join(e.dim(", "));return`${t}${e.gray(a)}  ${r.trim()?`${r}
${e.gray(a)}`:""}`}case"error":{const r=this.error.split(`
`).map((c,o)=>o===0?`${e.yellow(m)}  ${e.yellow(c)}`:`   ${c}`).join(`
`);return`${t+e.yellow(a)}  ${A({options:this.options,cursor:this.cursor,maxItems:s.maxItems,style:i}).join(`
${e.yellow(a)}  `)}
${r}
`}default:return`${t}${e.cyan(a)}  ${A({options:this.options,cursor:this.cursor,maxItems:s.maxItems,style:i}).join(`
${e.cyan(a)}  `)}
${e.cyan(m)}
`}}}).prompt()},ge=s=>{const n=(t,i,r=[])=>{const c=t.label??String(t.value),o=typeof t.group=="string",l=o&&(r[r.indexOf(t)+1]??{group:!0}),$=o&&l.group===!0,d=o?`${$?m:a} `:"";return i==="active"?`${e.dim(d)}${e.cyan(R)} ${c} ${t.hint?e.dim(`(${t.hint})`):""}`:i==="group-active"?`${d}${e.cyan(R)} ${e.dim(c)}`:i==="group-active-selected"?`${d}${e.green(M)} ${e.dim(c)}`:i==="selected"?`${e.dim(d)}${e.green(M)} ${e.dim(c)}`:i==="cancelled"?`${e.strikethrough(e.dim(c))}`:i==="active-selected"?`${e.dim(d)}${e.green(M)} ${c} ${t.hint?e.dim(`(${t.hint})`):""}`:i==="submitted"?`${e.dim(c)}`:`${e.dim(d)}${e.dim(G)} ${e.dim(c)}`};return new J({options:s.options,initialValues:s.initialValues,required:s.required??!0,cursorAt:s.cursorAt,validate(t){if(this.required&&t.length===0)return`Please select at least one option.
${e.reset(e.dim(`Press ${e.gray(e.bgWhite(e.inverse(" space ")))} to select, ${e.gray(e.bgWhite(e.inverse(" enter ")))} to submit`))}`},render(){const t=`${e.gray(a)}
${y(this.state)}  ${s.message}
`;switch(this.state){case"submit":return`${t}${e.gray(a)}  ${this.options.filter(({value:i})=>this.value.includes(i)).map(i=>n(i,"submitted")).join(e.dim(", "))}`;case"cancel":{const i=this.options.filter(({value:r})=>this.value.includes(r)).map(r=>n(r,"cancelled")).join(e.dim(", "));return`${t}${e.gray(a)}  ${i.trim()?`${i}
${e.gray(a)}`:""}`}case"error":{const i=this.error.split(`
`).map((r,c)=>c===0?`${e.yellow(m)}  ${e.yellow(r)}`:`   ${r}`).join(`
`);return`${t}${e.yellow(a)}  ${this.options.map((r,c,o)=>{const l=this.value.includes(r.value)||r.group===!0&&this.isGroupSelected(`${r.value}`),$=c===this.cursor;return!$&&typeof r.group=="string"&&this.options[this.cursor].value===r.group?n(r,l?"group-active-selected":"group-active",o):$&&l?n(r,"active-selected",o):l?n(r,"selected",o):n(r,$?"active":"inactive",o)}).join(`
${e.yellow(a)}  `)}
${i}
`}default:return`${t}${e.cyan(a)}  ${this.options.map((i,r,c)=>{const o=this.value.includes(i.value)||i.group===!0&&this.isGroupSelected(`${i.value}`),l=r===this.cursor;return!l&&typeof i.group=="string"&&this.options[this.cursor].value===i.group?n(i,o?"group-active-selected":"group-active",c):l&&o?n(i,"active-selected",c):o?n(i,"selected",c):n(i,l?"active":"inactive",c)}).join(`
${e.cyan(a)}  `)}
${e.cyan(m)}
`}}}).prompt()},P=s=>s.replace(be(),""),ye=(s="",n="")=>{const t=`
${s}
`.split(`
`),i=P(n).length,r=Math.max(t.reduce((o,l)=>{const $=P(l);return $.length>o?$.length:o},0),i)+2,c=t.map(o=>`${e.gray(a)}  ${e.dim(o)}${" ".repeat(r-P(o).length)}${e.gray(a)}`).join(`
`);process.stdout.write(`${e.gray(a)}
${e.green(S)}  ${e.reset(n)} ${e.gray(_.repeat(Math.max(r-i-1,1))+re)}
${c}
${e.gray(ie+_.repeat(r+2)+ne)}
`)},ve=(s="")=>{process.stdout.write(`${e.gray(m)}  ${e.red(s)}

`)},we=(s="")=>{process.stdout.write(`${e.gray(te)}  ${s}
`)},fe=(s="")=>{process.stdout.write(`${e.gray(a)}
${e.gray(m)}  ${s}

`)},v={message:(s="",{symbol:n=e.gray(a)}={})=>{const t=[`${e.gray(a)}`];if(s){const[i,...r]=s.split(`
`);t.push(`${n}  ${i}`,...r.map(c=>`${e.gray(a)}  ${c}`))}process.stdout.write(`${t.join(`
`)}
`)},info:s=>{v.message(s,{symbol:e.blue(ae)})},success:s=>{v.message(s,{symbol:e.green(oe)})},step:s=>{v.message(s,{symbol:e.green(S)})},warn:s=>{v.message(s,{symbol:e.yellow(ce)})},warning:s=>{v.warn(s)},error:s=>{v.message(s,{symbol:e.red(le)})}},L=()=>{const s=T?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],n=T?80:120,t=process.env.CI==="true";let i,r,c=!1,o="",l;const $=p=>{const g=p>1?"Something went wrong":"Canceled";c&&k(g,p)},d=()=>$(2),w=()=>$(1),b=()=>{process.on("uncaughtExceptionMonitor",d),process.on("unhandledRejection",d),process.on("SIGINT",w),process.on("SIGTERM",w),process.on("exit",$)},C=()=>{process.removeListener("uncaughtExceptionMonitor",d),process.removeListener("unhandledRejection",d),process.removeListener("SIGINT",w),process.removeListener("SIGTERM",w),process.removeListener("exit",$)},I=()=>{if(l===void 0)return;t&&process.stdout.write(`
`);const p=l.split(`
`);process.stdout.write(Q.move(-999,p.length-1)),process.stdout.write(H.down(p.length))},x=p=>p.replace(/\.+$/,""),N=(p="")=>{c=!0,i=K(),o=x(p),process.stdout.write(`${e.gray(a)}
`);let g=0,f=0;b(),r=setInterval(()=>{if(t&&o===l)return;I(),l=o;const O=e.magenta(s[g]),W=t?"...":".".repeat(Math.floor(f)).slice(0,3);process.stdout.write(`${O}  ${o}${W}`),g=g+1<s.length?g+1:0,f=f<s.length?f+.125:0},n)},k=(p="",g=0)=>{c=!1,clearInterval(r),I();const f=g===0?e.green(S):g===1?e.red(V):e.red(B);o=x(p??o),process.stdout.write(`${f}  ${o}
`),C(),i()};return{start:N,stop:k,message:(p="")=>{o=x(p??o)}}};function be(){const s=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(s,"g")}const xe=async(s,n)=>{const t={},i=Object.keys(s);for(const r of i){const c=s[r],o=await c({results:t})?.catch(l=>{throw l});if(typeof n?.onCancel=="function"&&Y(o)){t[r]="canceled",n.onCancel({results:t});continue}t[r]=o}return t},Me=async s=>{for(const n of s){if(n.enabled===!1)continue;const t=L();t.start(n.title);const i=await n.task(t.message);t.stop(i||n.title)}};export{ve as cancel,me as confirm,xe as group,ge as groupMultiselect,we as intro,v as log,he as multiselect,ye as note,fe as outro,$e as password,de as select,pe as selectKey,L as spinner,Me as tasks,ue as text};
//# sourceMappingURL=index.mjs.map
