"use strict";const core=require("@clack/core"),process$1=require("node:process"),e=require("picocolors"),sisteransi=require("sisteransi");function _interopDefaultCompat(t){return t&&typeof t=="object"&&"default"in t?t.default:t}const process__default=_interopDefaultCompat(process$1),e__default=_interopDefaultCompat(e);function isUnicodeSupported(){return process__default.platform!=="win32"?process__default.env.TERM!=="linux":!!process__default.env.CI||!!process__default.env.WT_SESSION||!!process__default.env.TERMINUS_SUBLIME||process__default.env.ConEmuTask==="{cmd::Cmder}"||process__default.env.TERM_PROGRAM==="Terminus-Sublime"||process__default.env.TERM_PROGRAM==="vscode"||process__default.env.TERM==="xterm-256color"||process__default.env.TERM==="alacritty"||process__default.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}const P=isUnicodeSupported(),u=(t,n)=>P?t:n,Y=u("\u25C6","*"),R=u("\u25A0","x"),C=u("\u25B2","x"),S=u("\u25C7","o"),J=u("\u250C","T"),a=u("\u2502","|"),$=u("\u2514","\u2014"),T=u("\u25CF",">"),O=u("\u25CB"," "),_=u("\u25FB","[\u2022]"),x=u("\u25FC","[+]"),M=u("\u25FB","[ ]"),Q=u("\u25AA","\u2022"),k=u("\u2500","-"),ee=u("\u256E","+"),te=u("\u251C","+"),re=u("\u256F","+"),se=u("\u25CF","\u2022"),ne=u("\u25C6","*"),ie=u("\u25B2","!"),ae=u("\u25A0","x"),h=t=>{switch(t){case"initial":case"active":return e__default.cyan(Y);case"cancel":return e__default.red(R);case"error":return e__default.yellow(C);case"submit":return e__default.green(S)}},I=t=>{const{cursor:n,options:s,style:i}=t,r=t.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,s.length-o),0):n<l+2&&(l=Math.max(n-2,0));const d=o<s.length&&l>0,p=o<s.length&&l+o<s.length;return s.slice(l,l+o).map((y,w,j)=>{const b=w===0&&d,f=w===j.length-1&&p;return b||f?e__default.dim("..."):i(y,w+l===n)})},text=t=>new core.TextPrompt({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,render(){const n=`${e__default.gray(a)}
${h(this.state)}  ${t.message}
`,s=t.placeholder?e__default.inverse(t.placeholder[0])+e__default.dim(t.placeholder.slice(1)):e__default.inverse(e__default.hidden("_")),i=this.value?this.valueWithCursor:s;switch(this.state){case"error":return`${n.trim()}
${e__default.yellow(a)}  ${i}
${e__default.yellow($)}  ${e__default.yellow(this.error)}
`;case"submit":return`${n}${e__default.gray(a)}  ${e__default.dim(this.value||t.placeholder)}`;case"cancel":return`${n}${e__default.gray(a)}  ${e__default.strikethrough(e__default.dim(this.value??""))}${this.value?.trim()?`
${e__default.gray(a)}`:""}`;default:return`${n}${e__default.cyan(a)}  ${i}
${e__default.cyan($)}
`}}}).prompt(),password=t=>new core.PasswordPrompt({validate:t.validate,mask:t.mask??Q,render(){const n=`${e__default.gray(a)}
${h(this.state)}  ${t.message}
`,s=this.valueWithCursor,i=this.masked;switch(this.state){case"error":return`${n.trim()}
${e__default.yellow(a)}  ${i}
${e__default.yellow($)}  ${e__default.yellow(this.error)}
`;case"submit":return`${n}${e__default.gray(a)}  ${e__default.dim(i)}`;case"cancel":return`${n}${e__default.gray(a)}  ${e__default.strikethrough(e__default.dim(i??""))}${i?`
${e__default.gray(a)}`:""}`;default:return`${n}${e__default.cyan(a)}  ${s}
${e__default.cyan($)}
`}}}).prompt(),confirm=t=>{const n=t.active??"Yes",s=t.inactive??"No";return new core.ConfirmPrompt({active:n,inactive:s,initialValue:t.initialValue??!0,render(){const i=`${e__default.gray(a)}
${h(this.state)}  ${t.message}
`,r=this.value?n:s;switch(this.state){case"submit":return`${i}${e__default.gray(a)}  ${e__default.dim(r)}`;case"cancel":return`${i}${e__default.gray(a)}  ${e__default.strikethrough(e__default.dim(r))}
${e__default.gray(a)}`;default:return`${i}${e__default.cyan(a)}  ${this.value?`${e__default.green(T)} ${n}`:`${e__default.dim(O)} ${e__default.dim(n)}`} ${e__default.dim("/")} ${this.value?`${e__default.dim(O)} ${e__default.dim(s)}`:`${e__default.green(T)} ${s}`}
${e__default.cyan($)}
`}}}).prompt()},select=t=>{const n=(s,i)=>{const r=s.label??String(s.value);switch(i){case"selected":return`${e__default.dim(r)}`;case"active":return`${e__default.green(T)} ${r} ${s.hint?e__default.dim(`(${s.hint})`):""}`;case"cancelled":return`${e__default.strikethrough(e__default.dim(r))}`;default:return`${e__default.dim(O)} ${e__default.dim(r)}`}};return new core.SelectPrompt({options:t.options,initialValue:t.initialValue,render(){const s=`${e__default.gray(a)}
${h(this.state)}  ${t.message}
`;switch(this.state){case"submit":return`${s}${e__default.gray(a)}  ${n(this.options[this.cursor],"selected")}`;case"cancel":return`${s}${e__default.gray(a)}  ${n(this.options[this.cursor],"cancelled")}
${e__default.gray(a)}`;default:return`${s}${e__default.cyan(a)}  ${I({cursor:this.cursor,options:this.options,maxItems:t.maxItems,style:(i,r)=>n(i,r?"active":"inactive")}).join(`
${e__default.cyan(a)}  `)}
${e__default.cyan($)}
`}}}).prompt()},selectKey=t=>{const n=(s,i="inactive")=>{const r=s.label??String(s.value);return i==="selected"?`${e__default.dim(r)}`:i==="cancelled"?`${e__default.strikethrough(e__default.dim(r))}`:i==="active"?`${e__default.bgCyan(e__default.gray(` ${s.value} `))} ${r} ${s.hint?e__default.dim(`(${s.hint})`):""}`:`${e__default.gray(e__default.bgWhite(e__default.inverse(` ${s.value} `)))} ${r} ${s.hint?e__default.dim(`(${s.hint})`):""}`};return new core.SelectKeyPrompt({options:t.options,initialValue:t.initialValue,render(){const s=`${e__default.gray(a)}
${h(this.state)}  ${t.message}
`;switch(this.state){case"submit":return`${s}${e__default.gray(a)}  ${n(this.options.find(i=>i.value===this.value)??t.options[0],"selected")}`;case"cancel":return`${s}${e__default.gray(a)}  ${n(this.options[0],"cancelled")}
${e__default.gray(a)}`;default:return`${s}${e__default.cyan(a)}  ${this.options.map((i,r)=>n(i,r===this.cursor?"active":"inactive")).join(`
${e__default.cyan(a)}  `)}
${e__default.cyan($)}
`}}}).prompt()},multiselect=t=>{const n=(s,i)=>{const r=s.label??String(s.value);return i==="active"?`${e__default.cyan(_)} ${r} ${s.hint?e__default.dim(`(${s.hint})`):""}`:i==="selected"?`${e__default.green(x)} ${e__default.dim(r)}`:i==="cancelled"?`${e__default.strikethrough(e__default.dim(r))}`:i==="active-selected"?`${e__default.green(x)} ${r} ${s.hint?e__default.dim(`(${s.hint})`):""}`:i==="submitted"?`${e__default.dim(r)}`:`${e__default.dim(M)} ${e__default.dim(r)}`};return new core.MultiSelectPrompt({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(s){if(this.required&&s.length===0)return`Please select at least one option.
${e__default.reset(e__default.dim(`Press ${e__default.gray(e__default.bgWhite(e__default.inverse(" space ")))} to select, ${e__default.gray(e__default.bgWhite(e__default.inverse(" enter ")))} to submit`))}`},render(){const s=`${e__default.gray(a)}
${h(this.state)}  ${t.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`${s}${e__default.gray(a)}  ${this.options.filter(({value:r})=>this.value.includes(r)).map(r=>n(r,"submitted")).join(e__default.dim(", "))||e__default.dim("none")}`;case"cancel":{const r=this.options.filter(({value:c})=>this.value.includes(c)).map(c=>n(c,"cancelled")).join(e__default.dim(", "));return`${s}${e__default.gray(a)}  ${r.trim()?`${r}
${e__default.gray(a)}`:""}`}case"error":{const r=this.error.split(`
`).map((c,o)=>o===0?`${e__default.yellow($)}  ${e__default.yellow(c)}`:`   ${c}`).join(`
`);return`${s+e__default.yellow(a)}  ${I({options:this.options,cursor:this.cursor,maxItems:t.maxItems,style:i}).join(`
${e__default.yellow(a)}  `)}
${r}
`}default:return`${s}${e__default.cyan(a)}  ${I({options:this.options,cursor:this.cursor,maxItems:t.maxItems,style:i}).join(`
${e__default.cyan(a)}  `)}
${e__default.cyan($)}
`}}}).prompt()},groupMultiselect=t=>{const n=(s,i,r=[])=>{const c=s.label??String(s.value),o=typeof s.group=="string",l=o&&(r[r.indexOf(s)+1]??{group:!0}),d=o&&l.group===!0,p=o?`${d?$:a} `:"";return i==="active"?`${e__default.dim(p)}${e__default.cyan(_)} ${c} ${s.hint?e__default.dim(`(${s.hint})`):""}`:i==="group-active"?`${p}${e__default.cyan(_)} ${e__default.dim(c)}`:i==="group-active-selected"?`${p}${e__default.green(x)} ${e__default.dim(c)}`:i==="selected"?`${e__default.dim(p)}${e__default.green(x)} ${e__default.dim(c)}`:i==="cancelled"?`${e__default.strikethrough(e__default.dim(c))}`:i==="active-selected"?`${e__default.dim(p)}${e__default.green(x)} ${c} ${s.hint?e__default.dim(`(${s.hint})`):""}`:i==="submitted"?`${e__default.dim(c)}`:`${e__default.dim(p)}${e__default.dim(M)} ${e__default.dim(c)}`};return new core.GroupMultiSelectPrompt({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(s){if(this.required&&s.length===0)return`Please select at least one option.
${e__default.reset(e__default.dim(`Press ${e__default.gray(e__default.bgWhite(e__default.inverse(" space ")))} to select, ${e__default.gray(e__default.bgWhite(e__default.inverse(" enter ")))} to submit`))}`},render(){const s=`${e__default.gray(a)}
${h(this.state)}  ${t.message}
`;switch(this.state){case"submit":return`${s}${e__default.gray(a)}  ${this.options.filter(({value:i})=>this.value.includes(i)).map(i=>n(i,"submitted")).join(e__default.dim(", "))}`;case"cancel":{const i=this.options.filter(({value:r})=>this.value.includes(r)).map(r=>n(r,"cancelled")).join(e__default.dim(", "));return`${s}${e__default.gray(a)}  ${i.trim()?`${i}
${e__default.gray(a)}`:""}`}case"error":{const i=this.error.split(`
`).map((r,c)=>c===0?`${e__default.yellow($)}  ${e__default.yellow(r)}`:`   ${r}`).join(`
`);return`${s}${e__default.yellow(a)}  ${this.options.map((r,c,o)=>{const l=this.value.includes(r.value)||r.group===!0&&this.isGroupSelected(`${r.value}`),d=c===this.cursor;return!d&&typeof r.group=="string"&&this.options[this.cursor].value===r.group?n(r,l?"group-active-selected":"group-active",o):d&&l?n(r,"active-selected",o):l?n(r,"selected",o):n(r,d?"active":"inactive",o)}).join(`
${e__default.yellow(a)}  `)}
${i}
`}default:return`${s}${e__default.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__default.cyan(a)}  `)}
${e__default.cyan($)}
`}}}).prompt()},A=t=>t.replace(oe(),""),note=(t="",n="")=>{const s=`
${t}
`.split(`
`),i=A(n).length,r=Math.max(s.reduce((o,l)=>{const d=A(l);return d.length>o?d.length:o},0),i)+2,c=s.map(o=>`${e__default.gray(a)}  ${e__default.dim(o)}${" ".repeat(r-A(o).length)}${e__default.gray(a)}`).join(`
`);process.stdout.write(`${e__default.gray(a)}
${e__default.green(S)}  ${e__default.reset(n)} ${e__default.gray(k.repeat(Math.max(r-i-1,1))+ee)}
${c}
${e__default.gray(te+k.repeat(r+2)+re)}
`)},cancel=(t="")=>{process.stdout.write(`${e__default.gray($)}  ${e__default.red(t)}

`)},intro=(t="")=>{process.stdout.write(`${e__default.gray(J)}  ${t}
`)},outro=(t="")=>{process.stdout.write(`${e__default.gray(a)}
${e__default.gray($)}  ${t}

`)},log={message:(t="",{symbol:n=e__default.gray(a)}={})=>{const s=[`${e__default.gray(a)}`];if(t){const[i,...r]=t.split(`
`);s.push(`${n}  ${i}`,...r.map(c=>`${e__default.gray(a)}  ${c}`))}process.stdout.write(`${s.join(`
`)}
`)},info:t=>{log.message(t,{symbol:e__default.blue(se)})},success:t=>{log.message(t,{symbol:e__default.green(ne)})},step:t=>{log.message(t,{symbol:e__default.green(S)})},warn:t=>{log.message(t,{symbol:e__default.yellow(ie)})},warning:t=>{log.warn(t)},error:t=>{log.message(t,{symbol:e__default.red(ae)})}},spinner=()=>{const t=P?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],n=P?80:120,s=process.env.CI==="true";let i,r,c=!1,o="",l;const d=m=>{const g=m>1?"Something went wrong":"Canceled";c&&E(g,m)},p=()=>d(2),y=()=>d(1),w=()=>{process.on("uncaughtExceptionMonitor",p),process.on("unhandledRejection",p),process.on("SIGINT",y),process.on("SIGTERM",y),process.on("exit",d)},j=()=>{process.removeListener("uncaughtExceptionMonitor",p),process.removeListener("unhandledRejection",p),process.removeListener("SIGINT",y),process.removeListener("SIGTERM",y),process.removeListener("exit",d)},b=()=>{if(l===void 0)return;s&&process.stdout.write(`
`);const m=l.split(`
`);process.stdout.write(sisteransi.cursor.move(-999,m.length-1)),process.stdout.write(sisteransi.erase.down(m.length))},f=m=>m.replace(/\.+$/,""),V=(m="")=>{c=!0,i=core.block(),o=f(m),process.stdout.write(`${e__default.gray(a)}
`);let g=0,v=0;w(),r=setInterval(()=>{if(s&&o===l)return;b(),l=o;const B=e__default.magenta(t[g]),q=s?"...":".".repeat(Math.floor(v)).slice(0,3);process.stdout.write(`${B}  ${o}${q}`),g=g+1<t.length?g+1:0,v=v<t.length?v+.125:0},n)},E=(m="",g=0)=>{c=!1,clearInterval(r),b();const v=g===0?e__default.green(S):g===1?e__default.red(R):e__default.red(C);o=f(m??o),process.stdout.write(`${v}  ${o}
`),j(),i()};return{start:V,stop:E,message:(m="")=>{o=f(m??o)}}};function oe(){const t=["[\\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(t,"g")}const group=async(t,n)=>{const s={},i=Object.keys(t);for(const r of i){const c=t[r],o=await c({results:s})?.catch(l=>{throw l});if(typeof n?.onCancel=="function"&&core.isCancel(o)){s[r]="canceled",n.onCancel({results:s});continue}s[r]=o}return s},tasks=async t=>{for(const n of t){if(n.enabled===!1)continue;const s=spinner();s.start(n.title);const i=await n.task(s.message);s.stop(i||n.title)}};exports.isCancel=core.isCancel,exports.updateSettings=core.updateSettings,exports.cancel=cancel,exports.confirm=confirm,exports.group=group,exports.groupMultiselect=groupMultiselect,exports.intro=intro,exports.log=log,exports.multiselect=multiselect,exports.note=note,exports.outro=outro,exports.password=password,exports.select=select,exports.selectKey=selectKey,exports.spinner=spinner,exports.tasks=tasks,exports.text=text;
//# sourceMappingURL=index.cjs.map
