import{styleText as l}from"node:util";import G,{stdin as Ce,stdout as ve}from"node:process";import*as oe from"node:readline";import ut from"node:readline";import{ReadStream as Oe}from"node:tty";import E from"node:fs";import A from"node:path";import{execa as K}from"execa";import ct from"open";import Le from"which";import{fileURLToPath as lt}from"node:url";const pt=(()=>{const e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let r=0;for(e.lastIndex=0;e.test(t);)r+=1;return t.length-r}})(),ft=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,ht=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||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>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,dt=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,mt=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Ne=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,gt=/\t{1,1000}/y,je=new RegExp("[\\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"),vt=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,wt=new RegExp("\\p{M}+","gu"),yt={limit:1/0,ellipsis:""},De=(e,t={},r={})=>{const i=t.limit??1/0,n=t.ellipsis??"",a=t?.ellipsisWidth??(n?De(n,yt,r).width:0),s=0,o=r.controlWidth??0,u=r.tabWidth??8,c=r.emojiWidth??2,v=2,m=r.regularWidth??1,p=r.wideWidth??v,w=[[vt,m],[dt,s],[mt,o],[gt,u],[je,c],[Ne,p]];let h=0,f=0,g=e.length,I=0,j=!1,k=g,S=Math.max(0,i-a),_=0,$=0,d=0,b=0;e:for(;;){if($>_||f>=g&&f>h){const T=e.slice(_,$)||e.slice(h,f);I=0;for(const y of T.replaceAll(wt,"")){const C=y.codePointAt(0)||0;if(ft(C)?b=v:ht(C)?b=p:b=m,d+b>S&&(k=Math.min(k,Math.max(_,h)+I)),d+b>i){j=!0;break e}I+=y.length,d+=b}_=$=0}if(f>=g)break e;for(let T=0,y=w.length;T<y;T++){const[C,V]=w[T];if(C.lastIndex=f,C.test(e)){if(I=C===Ne?pt(e.slice(f,C.lastIndex)):C===je?1:C.lastIndex-f,b=I*V,d+b>S&&(k=Math.min(k,f+Math.floor((S-d)/V))),d+b>i){j=!0;break e}d+=b,_=h,$=f,f=h=C.lastIndex;continue e}}f+=1}return{width:j?S:d,index:j?k:g,truncated:j,ellipsed:j&&i>=a}},bt={limit:1/0,ellipsis:"",ellipsisWidth:0},J=(e,t={})=>De(e,bt,t).width,ue="\x1B",Me="\x9B",$t=39,we="\x07",Ve="[",Et="]",Ue="m",ye=`${Et}8;;`,Pe=new RegExp(`(?:\\${Ve}(?<code>\\d+)m|\\${ye}(?<uri>.*)${we})`,"y"),Be=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=>`${ue}${Ve}${e}${Ue}`,Ge=e=>`${ue}${ye}${e}${we}`,be=(e,t,r)=>{const i=t[Symbol.iterator]();let n=!1,a=!1,s=e.at(-1),o=s===void 0?0:J(s),u=i.next(),c=i.next(),v=0;for(;!u.done;){const m=u.value,p=J(m);o+p<=r?e[e.length-1]+=m:(e.push(m),o=0),(m===ue||m===Me)&&(n=!0,a=t.startsWith(ye,v+1)),n?a?m===we&&(n=!1,a=!1):m===Ue&&(n=!1):(o+=p,o===r&&!c.done&&(e.push(""),o=0)),u=c,c=i.next(),v+=m.length}s=e.at(-1),!o&&s!==void 0&&s.length&&e.length>1&&(e[e.length-2]+=e.pop())},It=e=>{const t=e.split(" ");let r=t.length;for(;r&&!J(t[r-1]);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},St=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let i="",n,a;const s=e.split(" ");let o=[""],u=0;for(let m=0;m<s.length;m++){const p=s[m];if(r.trim!==!1){const h=o.at(-1)??"",f=h.trimStart();h.length!==f.length&&(o[o.length-1]=f,u=J(f))}m!==0&&(u>=t&&(r.wordWrap===!1||r.trim===!1)&&(o.push(""),u=0),(u||r.trim===!1)&&(o[o.length-1]+=" ",u++));const w=J(p);if(r.hard&&w>t){const h=t-u,f=1+Math.floor((w-h-1)/t);Math.floor((w-1)/t)<f&&o.push(""),be(o,p,t),u=J(o.at(-1)??"");continue}if(u+w>t&&u&&w){if(r.wordWrap===!1&&u<t){be(o,p,t),u=J(o.at(-1)??"");continue}o.push(""),u=0}if(u+w>t&&r.wordWrap===!1){be(o,p,t),u=J(o.at(-1)??"");continue}o[o.length-1]+=p,u+=w}r.trim!==!1&&(o=o.map(m=>It(m)));const c=o.join(`
`);let v=!1;for(let m=0;m<c.length;m++){const p=c[m];if(i+=p,v)v=!1;else if(v=p>="\uD800"&&p<="\uDBFF",v)continue;if(p===ue||p===Me){Pe.lastIndex=m+1;const h=Pe.exec(c)?.groups;if(h?.code!==void 0){const f=Number.parseFloat(h.code);n=f===$t?void 0:f}else h?.uri!==void 0&&(a=h.uri.length===0?void 0:h.uri)}if(c[m+1]===`
`){a&&(i+=Ge(""));const w=n?Be(n):void 0;n&&w&&(i+=We(w))}else p===`
`&&(n&&Be(n)&&(i+=We(n)),a&&(i+=Ge(a)))}return i},_t=/\r?\n/;function ee(e,t,r){return String(e).normalize().split(_t).map(i=>St(i,t,r)).join(`
`)}function Ft(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var $e,Ke;function Tt(){if(Ke)return $e;Ke=1;const e="\x1B",t=`${e}[`,r="\x07",i={to(s,o){return o?`${t}${o+1};${s+1}H`:`${t}${s+1}G`},move(s,o){let u="";return s<0?u+=`${t}${-s}D`:s>0&&(u+=`${t}${s}C`),o<0?u+=`${t}${-o}A`:o>0&&(u+=`${t}${o}B`),u},up:(s=1)=>`${t}${s}A`,down:(s=1)=>`${t}${s}B`,forward:(s=1)=>`${t}${s}C`,backward:(s=1)=>`${t}${s}D`,nextLine:(s=1)=>`${t}E`.repeat(s),prevLine:(s=1)=>`${t}F`.repeat(s),left:`${t}G`,hide:`${t}?25l`,show:`${t}?25h`,save:`${e}7`,restore:`${e}8`},n={up:(s=1)=>`${t}S`.repeat(s),down:(s=1)=>`${t}T`.repeat(s)},a={screen:`${t}2J`,up:(s=1)=>`${t}1J`.repeat(s),down:(s=1)=>`${t}J`.repeat(s),line:`${t}2K`,lineEnd:`${t}K`,lineStart:`${t}1K`,lines(s){let o="";for(let u=0;u<s;u++)o+=this.line+(u<s-1?i.up():"");return s&&(o+=i.left),o}};return $e={cursor:i,scroll:n,erase:a,beep:r},$e}var L=Tt();function ce(e,t,r){if(!r.some(s=>!s.disabled))return e;const i=e+t,n=Math.max(r.length-1,0),a=i<0?n:i>n?0:i;return r[a].disabled?ce(a,t<0?-1:1,r):a}const xt=["up","down","left","right","space","enter","cancel"],H={actions:new Set(xt),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0};function Ee(e,t){if(typeof e=="string")return H.aliases.get(e)===t;for(const r of e)if(r!==void 0&&Ee(r,t))return!0;return!1}function Rt(e,t){if(e===t)return;const r=e.split(`
`),i=t.split(`
`),n=Math.max(r.length,i.length),a=[];for(let s=0;s<n;s++)r[s]!==i[s]&&a.push(s);return{lines:a,numLinesBefore:r.length,numLinesAfter:i.length,numLines:n}}const At=globalThis.process.platform.startsWith("win"),Ie=Symbol("clack:cancel");function D(e){return e===Ie}function le(e,t){const r=e;r.isTTY&&r.setRawMode(t)}function kt({input:e=Ce,output:t=ve,overwrite:r=!0,hideCursor:i=!0}={}){const n=oe.createInterface({input:e,output:t,prompt:"",tabSize:1});oe.emitKeypressEvents(e,n),e instanceof Oe&&e.isTTY&&e.setRawMode(!0);const a=(s,{name:o,sequence:u})=>{const c=String(s);if(Ee([c,o,u],"cancel")){i&&t.write(L.cursor.show),process.exit(0);return}if(!r)return;const v=o==="return"?0:-1,m=o==="return"?-1:0;oe.moveCursor(t,v,m,()=>{oe.clearLine(t,1,()=>{e.once("keypress",a)})})};return i&&t.write(L.cursor.hide),e.once("keypress",a),()=>{e.off("keypress",a),i&&t.write(L.cursor.show),e instanceof Oe&&e.isTTY&&!At&&e.setRawMode(!1),n.terminal=!1,n.close()}}const Se=e=>"columns"in e&&typeof e.columns=="number"?e.columns:80,He=e=>"rows"in e&&typeof e.rows=="number"?e.rows:20;function pe(e,t,r,i=r,n=r,a){const s=Se(e??ve);return ee(t,s-r.length,{hard:!0,trim:!1}).split(`
`).map((o,u,c)=>{const v=o;return u===0?`${i}${v}`:u===c.length-1?`${n}${v}`:`${r}${v}`}).join(`
`)}function Ct(e,t){if("~standard"in e){const r=e["~standard"].validate(t);if(r instanceof Promise)throw new TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");return r.issues?.at(0)?.message}return e(t)}class _e{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(t,r=!0){const{input:i=Ce,output:n=ve,render:a,signal:s,...o}=t;this.opts=o,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=a.bind(this),this._track=r,this._abortSignal=s,this.input=i,this.output=n}unsubscribe(){this._subscribers.clear()}setSubscriber(t,r){const i=this._subscribers.get(t)??[];i.push(r),this._subscribers.set(t,i)}on(t,r){this.setSubscriber(t,{cb:r})}once(t,r){this.setSubscriber(t,{cb:r,once:!0})}emit(t,...r){const i=this._subscribers.get(t)??[],n=[];for(const a of i)a.cb(...r),a.once&&n.push(()=>i.splice(i.indexOf(a),1));for(const a of n)a()}prompt(){return new Promise(t=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),t(Ie);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=ut.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),le(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(L.cursor.show),this.output.off("resize",this.render),le(this.input,!1),t(this.value)}),this.once("cancel",()=>{this.output.write(L.cursor.show),this.output.off("resize",this.render),le(this.input,!1),t(Ie)})})}_isActionKey(t,r){return t==="	"}_shouldSubmit(t,r){return!0}_setValue(t){this.value=t,this.emit("value",this.value)}_setUserInput(t,r){this.userInput=t??"",this.emit("userInput",this.userInput),r&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress(t,r){if(this._track&&r.name!=="return"&&(r.name&&this._isActionKey(t,r)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),r?.name&&(!this._track&&H.aliases.has(r.name)&&this.emit("cursor",H.aliases.get(r.name)),H.actions.has(r.name)&&this.emit("cursor",r.name)),t&&(t.toLowerCase()==="y"||t.toLowerCase()==="n")&&this.emit("confirm",t.toLowerCase()==="y"),this.emit("key",t,r),r?.name==="return"&&this._shouldSubmit(t,r)){if(this.opts.validate){const i=Ct(this.opts.validate,this.value);i&&(this.error=i instanceof Error?i.message:i,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}Ee([t,r?.name,r?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
`),le(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){const t=ee(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
`).length-1;this.output.write(L.cursor.move(-999,t*-1))}render(){const t=ee(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(t!==this._prevFrame){if(this.state==="initial")this.output.write(L.cursor.hide);else{const r=Rt(this._prevFrame,t),i=He(this.output);if(this.restoreCursor(),r){const n=Math.max(0,r.numLinesAfter-i),a=Math.max(0,r.numLinesBefore-i);let s=r.lines.find(o=>o>=n);if(s===void 0){this._prevFrame=t;return}if(r.lines.length===1){this.output.write(L.cursor.move(0,s-a)),this.output.write(L.erase.lines(1));const o=t.split(`
`);this.output.write(o[s]),this._prevFrame=t,this.output.write(L.cursor.move(0,o.length-s-1));return}else if(r.lines.length>1){if(n<a)s=n;else{const u=s-a;u>0&&this.output.write(L.cursor.move(0,u))}this.output.write(L.erase.down());const o=t.split(`
`).slice(s);this.output.write(o.join(`
`)),this._prevFrame=t;return}}this.output.write(L.erase.down())}this.output.write(t),this.state==="initial"&&(this.state="active"),this._prevFrame=t}}}class Ot extends _e{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(t){super(t,!1),this.value=!!t.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",r=>{this.output.write(L.cursor.move(0,-1)),this.value=r,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}class Lt extends _e{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor(t){super(t,!1),this.options=t.options;const r=this.options.findIndex(({value:n})=>n===t.initialValue),i=r===-1?0:r;this.cursor=this.options[i].disabled?ce(i,1,this.options):i,this.changeValue(),this.on("cursor",n=>{switch(n){case"left":case"up":this.cursor=ce(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=ce(this.cursor,1,this.options);break}this.changeValue()})}}class Nt extends _e{get userInputWithCursor(){if(this.state==="submit")return this.userInput;const t=this.userInput;if(this.cursor>=t.length)return`${this.userInput}\u2588`;const r=t.slice(0,this.cursor),[i,...n]=t.slice(this.cursor);return`${r}${l("inverse",i)}${n.join("")}`}get cursor(){return this._cursor}constructor(t){super({...t,initialUserInput:t.initialUserInput??t.initialValue}),this.on("userInput",r=>{this._setValue(r)}),this.on("finalize",()=>{this.value||(this.value=t.defaultValue),this.value===void 0&&(this.value="")})}}function jt(){return G.platform!=="win32"?G.env.TERM!=="linux":!!G.env.CI||!!G.env.WT_SESSION||!!G.env.TERMINUS_SUBLIME||G.env.ConEmuTask==="{cmd::Cmder}"||G.env.TERM_PROGRAM==="Terminus-Sublime"||G.env.TERM_PROGRAM==="vscode"||G.env.TERM==="xterm-256color"||G.env.TERM==="alacritty"||G.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}const Fe=jt(),Dt=()=>process.env.CI==="true",B=(e,t)=>Fe?e:t,Mt=B("\u25C6","*"),ze=B("\u25A0","x"),Ye=B("\u25B2","x"),Te=B("\u25C7","o"),Vt=B("\u250C","T"),x=B("\u2502","|"),te=B("\u2514","\u2014"),xe=B("\u25CF",">"),fe=B("\u25CB"," "),Ut=B("\u25CF","\u2022"),Pt=B("\u25C6","*"),Bt=B("\u25B2","!"),Wt=B("\u25A0","x"),Re=e=>{switch(e){case"initial":case"active":return l("cyan",Mt);case"cancel":return l("red",ze);case"error":return l("yellow",Ye);case"submit":return l("green",Te)}},Gt=e=>{switch(e){case"initial":case"active":return l("cyan",x);case"cancel":return l("red",x);case"error":return l("yellow",x);case"submit":return l("green",x)}},qe=(e,t,r,i,n,a=!1)=>{let s=t,o=0;if(a)for(let u=i-1;u>=r&&(s-=e[u].length,o++,!(s<=n));u--);else for(let u=r;u<i&&(s-=e[u].length,o++,!(s<=n));u++);return{lineCount:s,removals:o}},Kt=({cursor:e,options:t,style:r,output:i=process.stdout,maxItems:n=Number.POSITIVE_INFINITY,columnPadding:a=0,rowPadding:s=4})=>{const o=Se(i)-a,u=He(i),c=l("dim","..."),v=Math.max(u-s,0),m=Math.max(Math.min(n,v),5);let p=0;e>=m-3&&(p=Math.max(Math.min(e-m+3,t.length-m),0));let w=m<t.length&&p>0,h=m<t.length&&p+m<t.length;const f=Math.min(p+m,t.length),g=[];let I=0;w&&I++,h&&I++;const j=p+(w?1:0),k=f-(h?1:0);for(let _=j;_<k;_++){const $=ee(r(t[_],_===e),o,{hard:!0,trim:!1}).split(`
`);g.push($),I+=$.length}if(I>v){let _=0,$=0,d=I;const b=e-j;let T=v;const y=()=>qe(g,d,0,b,T),C=()=>qe(g,d,b+1,g.length,T,!0);w?({lineCount:d,removals:_}=y(),d>T&&(h||(T-=1),{lineCount:d,removals:$}=C())):(h||(T-=1),{lineCount:d,removals:$}=C(),d>T&&(T-=1,{lineCount:d,removals:_}=y())),_>0&&(w=!0,g.splice(0,_)),$>0&&(h=!0,g.splice(g.length-$,$))}const S=[];w&&S.push(c);for(const _ of g)for(const $ of _)S.push($);return h&&S.push(c),S},Je=e=>{const t=e.active??"Yes",r=e.inactive??"No";return new Ot({active:t,inactive:r,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){const i=e.withGuide??H.withGuide,n=`${Re(this.state)}  `,a=i?`${l("gray",x)}  `:"",s=pe(e.output,e.message,a,n),o=`${i?`${l("gray",x)}
`:""}${s}
`,u=this.value?t:r;switch(this.state){case"submit":{const c=i?`${l("gray",x)}  `:"";return`${o}${c}${l("dim",u)}`}case"cancel":{const c=i?`${l("gray",x)}  `:"";return`${o}${c}${l(["strikethrough","dim"],u)}${i?`
${l("gray",x)}`:""}`}default:{const c=i?`${l("cyan",x)}  `:"",v=i?l("cyan",te):"";return`${o}${c}${this.value?`${l("green",xe)} ${t}`:`${l("dim",fe)} ${l("dim",t)}`}${e.vertical?i?`
${l("cyan",x)}  `:`
`:` ${l("dim","/")} `}${this.value?`${l("dim",fe)} ${l("dim",r)}`:`${l("green",xe)} ${r}`}
${v}
`}}}}).prompt()},P={message:(e=[],{symbol:t=l("gray",x),secondarySymbol:r=l("gray",x),output:i=process.stdout,spacing:n=1,withGuide:a}={})=>{const s=[],o=a??H.withGuide,u=o?r:"",c=o?`${t}  `:"",v=o?`${r}  `:"";for(let p=0;p<n;p++)s.push(u);const m=Array.isArray(e)?e:e.split(`
`);if(m.length>0){const[p,...w]=m;p.length>0?s.push(`${c}${p}`):s.push(o?t:"");for(const h of w)h.length>0?s.push(`${v}${h}`):s.push(o?r:"")}i.write(`${s.join(`
`)}
`)},info:(e,t)=>{P.message(e,{...t,symbol:l("blue",Ut)})},success:(e,t)=>{P.message(e,{...t,symbol:l("green",Pt)})},step:(e,t)=>{P.message(e,{...t,symbol:l("green",Te)})},warn:(e,t)=>{P.message(e,{...t,symbol:l("yellow",Bt)})},warning:(e,t)=>{P.warn(e,t)},error:(e,t)=>{P.message(e,{...t,symbol:l("red",Wt)})}},F=(e="",t)=>{const r=process.stdout,i=`${l("gray",te)}  `;r.write(`${i}${l("red",e)}

`)},Ht=(e="",t)=>{const r=process.stdout,i=`${l("gray",Vt)}  `;r.write(`${i}${e}
`)},zt=(e="",t)=>{const r=process.stdout,i=`${l("gray",x)}
${l("gray",te)}  `;r.write(`${i}${e}

`)},Yt=e=>l("magenta",e),qt=({indicator:e="dots",onCancel:t,output:r=process.stdout,cancelMessage:i,errorMessage:n,frames:a=Fe?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],delay:s=Fe?80:120,signal:o,...u}={})=>{const c=Dt();let v,m,p=!1,w=!1,h="",f,g=performance.now();const I=Se(r),j=u?.styleFrame??Yt,k=R=>{const W=R>1?n??H.messages.error:i??H.messages.cancel;w=R===1,p&&(U(W,R),w&&typeof t=="function"&&t())},S=()=>k(2),_=()=>k(1),$=()=>{process.on("uncaughtExceptionMonitor",S),process.on("unhandledRejection",S),process.on("SIGINT",_),process.on("SIGTERM",_),process.on("exit",k),o&&o.addEventListener("abort",_)},d=()=>{process.removeListener("uncaughtExceptionMonitor",S),process.removeListener("unhandledRejection",S),process.removeListener("SIGINT",_),process.removeListener("SIGTERM",_),process.removeListener("exit",k),o&&o.removeEventListener("abort",_)},b=()=>{if(f===void 0)return;c&&r.write(`
`);const R=ee(f,I,{hard:!0,trim:!1}).split(`
`);R.length>1&&r.write(L.cursor.up(R.length-1)),r.write(L.cursor.to(0)),r.write(L.erase.down())},T=R=>R.replace(/\.+$/,""),y=R=>{const W=(performance.now()-R)/1e3,Y=Math.floor(W/60),q=Math.floor(W%60);return Y>0?`[${Y}m ${q}s]`:`[${q}s]`},C=u.withGuide??H.withGuide,V=(R="")=>{p=!0,v=kt({output:r}),h=T(R),g=performance.now(),C&&r.write(`${l("gray",x)}
`);let W=0,Y=0;$(),m=setInterval(()=>{if(c&&h===f)return;b(),f=h;const q=j(a[W]);let ae;if(c)ae=`${q}  ${h}...`;else if(e==="timer")ae=`${q}  ${h} ${y(g)}`;else{const ot=".".repeat(Math.floor(Y)).slice(0,3);ae=`${q}  ${h}${ot}`}const at=ee(ae,I,{hard:!0,trim:!1});r.write(at),W=W+1<a.length?W+1:0,Y=Y<4?Y+.125:0},s)},U=(R="",W=0,Y=!1)=>{if(!p)return;p=!1,clearInterval(m),b();const q=W===0?l("green",Te):W===1?l("red",ze):l("red",Ye);h=R??h,Y||(e==="timer"?r.write(`${q}  ${h} ${y(g)}
`):r.write(`${q}  ${h}
`)),d(),v()};return{start:V,stop:(R="")=>U(R,0),message:(R="")=>{h=T(R??h)},cancel:(R="")=>U(R,1),error:(R="")=>U(R,2),clear:()=>U("",0,!0),get isCancelled(){return w}}},he=(e,t)=>e.includes(`
`)?e.split(`
`).map(r=>t(r)).join(`
`):t(e),X=e=>{const t=(r,i)=>{const n=r.label??String(r.value);switch(i){case"disabled":return`${l("gray",fe)} ${he(n,a=>l("gray",a))}${r.hint?` ${l("dim",`(${r.hint??"disabled"})`)}`:""}`;case"selected":return`${he(n,a=>l("dim",a))}`;case"active":return`${l("green",xe)} ${n}${r.hint?` ${l("dim",`(${r.hint})`)}`:""}`;case"cancelled":return`${he(n,a=>l(["strikethrough","dim"],a))}`;default:return`${l("dim",fe)} ${he(n,a=>l("dim",a))}`}};return new Lt({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){const r=e.withGuide??H.withGuide,i=`${Re(this.state)}  `,n=`${Gt(this.state)}  `,a=pe(e.output,e.message,n,i),s=`${r?`${l("gray",x)}
`:""}${a}
`;switch(this.state){case"submit":{const o=r?`${l("gray",x)}  `:"",u=pe(e.output,t(this.options[this.cursor],"selected"),o);return`${s}${u}`}case"cancel":{const o=r?`${l("gray",x)}  `:"",u=pe(e.output,t(this.options[this.cursor],"cancelled"),o);return`${s}${u}${r?`
${l("gray",x)}`:""}`}default:{const o=r?`${l("cyan",x)}  `:"",u=r?l("cyan",te):"",c=s.split(`
`).length,v=r?2:1;return`${s}${o}${Kt({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,columnPadding:o.length,rowPadding:c+v,style:(m,p)=>t(m,m.disabled?"disabled":p?"active":"inactive")}).join(`
${o}`)}
${u}
`}}}}).prompt()};`${l("gray",x)}`;const de=async(e,t)=>{for(const r of e){if(r.enabled===!1)continue;const i=qt(t);i.start(r.title);const n=await r.task(i.message);i.stop(n||r.title)}},se=e=>new Nt({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,output:e.output,signal:e.signal,input:e.input,render(){const t=e?.withGuide??H.withGuide,r=`${`${t?`${l("gray",x)}
`:""}${Re(this.state)}  `}${e.message}
`,i=e.placeholder?l("inverse",e.placeholder[0])+l("dim",e.placeholder.slice(1)):l(["inverse","hidden"],"_"),n=this.userInput?this.userInputWithCursor:i,a=this.value??"";switch(this.state){case"error":{const s=this.error?`  ${l("yellow",this.error)}`:"",o=t?`${l("yellow",x)}  `:"",u=t?l("yellow",te):"";return`${r.trim()}
${o}${n}
${u}${s}
`}case"submit":{const s=a?`  ${l("dim",a)}`:"",o=t?l("gray",x):"";return`${r}${o}${s}`}case"cancel":{const s=a?`  ${l(["strikethrough","dim"],a)}`:"",o=t?l("gray",x):"";return`${r}${o}${s}${a.trim()?`
${o}`:""}`}default:{const s=t?`${l("cyan",x)}  `:"",o=t?l("cyan",te):"";return`${r}${s}${n}
${o}
`}}}}).prompt();let Q=!0;const re=typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};let ne=0;if(re.process&&re.process.env&&re.process.stdout){const{FORCE_COLOR:e,NODE_DISABLE_COLORS:t,NO_COLOR:r,TERM:i,COLORTERM:n}=re.process.env;t||r||e==="0"?Q=!1:e==="1"||e==="2"||e==="3"?Q=!0:i==="dumb"?Q=!1:"CI"in re.process.env&&["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(a=>a in re.process.env)?Q=!0:Q=process.stdout.isTTY,Q&&(process.platform==="win32"||n&&(n==="truecolor"||n==="24bit")?ne=3:i&&(i.endsWith("-256color")||i.endsWith("256"))?ne=2:ne=1)}let Ze={enabled:Q,supportLevel:ne};function me(e,t,r=1){const i=`\x1B[${e}m`,n=`\x1B[${t}m`,a=new RegExp(`\\x1b\\[${t}m`,"g");return s=>Ze.enabled&&Ze.supportLevel>=r?i+(""+s).replace(a,i)+n:""+s}const Jt=me(31,39),ge=me(36,39),Zt=me(90,39),Xt=me(91,39);var Ae,Xe;function Qt(){if(Xe)return Ae;Xe=1;function e(i,n){var a=i;n.slice(0,-1).forEach(function(o){a=a[o]||{}});var s=n[n.length-1];return s in a}function t(i){return typeof i=="number"||/^0x[0-9a-f]+$/i.test(i)?!0:/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(i)}function r(i,n){return n==="constructor"&&typeof i[n]=="function"||n==="__proto__"}return Ae=function(i,n){n||(n={});var a={bools:{},strings:{},unknownFn:null};typeof n.unknown=="function"&&(a.unknownFn=n.unknown),typeof n.boolean=="boolean"&&n.boolean?a.allBools=!0:[].concat(n.boolean).filter(Boolean).forEach(function(d){a.bools[d]=!0});var s={};function o(d){return s[d].some(function(b){return a.bools[b]})}Object.keys(n.alias||{}).forEach(function(d){s[d]=[].concat(n.alias[d]),s[d].forEach(function(b){s[b]=[d].concat(s[d].filter(function(T){return b!==T}))})}),[].concat(n.string).filter(Boolean).forEach(function(d){a.strings[d]=!0,s[d]&&[].concat(s[d]).forEach(function(b){a.strings[b]=!0})});var u=n.default||{},c={_:[]};function v(d,b){return a.allBools&&/^--[^=]+$/.test(b)||a.strings[d]||a.bools[d]||s[d]}function m(d,b,T){for(var y=d,C=0;C<b.length-1;C++){var V=b[C];if(r(y,V))return;y[V]===void 0&&(y[V]={}),(y[V]===Object.prototype||y[V]===Number.prototype||y[V]===String.prototype)&&(y[V]={}),y[V]===Array.prototype&&(y[V]=[]),y=y[V]}var U=b[b.length-1];r(y,U)||((y===Object.prototype||y===Number.prototype||y===String.prototype)&&(y={}),y===Array.prototype&&(y=[]),y[U]===void 0||a.bools[U]||typeof y[U]=="boolean"?y[U]=T:Array.isArray(y[U])?y[U].push(T):y[U]=[y[U],T])}function p(d,b,T){if(!(T&&a.unknownFn&&!v(d,T)&&a.unknownFn(T)===!1)){var y=!a.strings[d]&&t(b)?Number(b):b;m(c,d.split("."),y),(s[d]||[]).forEach(function(C){m(c,C.split("."),y)})}}Object.keys(a.bools).forEach(function(d){p(d,u[d]===void 0?!1:u[d])});var w=[];i.indexOf("--")!==-1&&(w=i.slice(i.indexOf("--")+1),i=i.slice(0,i.indexOf("--")));for(var h=0;h<i.length;h++){var f=i[h],g,I;if(/^--.+=/.test(f)){var j=f.match(/^--([^=]+)=([\s\S]*)$/);g=j[1];var k=j[2];a.bools[g]&&(k=k!=="false"),p(g,k,f)}else if(/^--no-.+/.test(f))g=f.match(/^--no-(.+)/)[1],p(g,!1,f);else if(/^--.+/.test(f))g=f.match(/^--(.+)/)[1],I=i[h+1],I!==void 0&&!/^(-|--)[^-]/.test(I)&&!a.bools[g]&&!a.allBools&&(!s[g]||!o(g))?(p(g,I,f),h+=1):/^(true|false)$/.test(I)?(p(g,I==="true",f),h+=1):p(g,a.strings[g]?"":!0,f);else if(/^-[^-]+/.test(f)){for(var S=f.slice(1,-1).split(""),_=!1,$=0;$<S.length;$++){if(I=f.slice($+2),I==="-"){p(S[$],I,f);continue}if(/[A-Za-z]/.test(S[$])&&I[0]==="="){p(S[$],I.slice(1),f),_=!0;break}if(/[A-Za-z]/.test(S[$])&&/-?\d+(\.\d*)?(e-?\d+)?$/.test(I)){p(S[$],I,f),_=!0;break}if(S[$+1]&&S[$+1].match(/\W/)){p(S[$],f.slice($+2),f),_=!0;break}else p(S[$],a.strings[S[$]]?"":!0,f)}g=f.slice(-1)[0],!_&&g!=="-"&&(i[h+1]&&!/^(-|--)[^-]/.test(i[h+1])&&!a.bools[g]&&(!s[g]||!o(g))?(p(g,i[h+1],f),h+=1):i[h+1]&&/^(true|false)$/.test(i[h+1])?(p(g,i[h+1]==="true",f),h+=1):p(g,a.strings[g]?"":!0,f))}else if((!a.unknownFn||a.unknownFn(f)!==!1)&&c._.push(a.strings._||!t(f)?f:Number(f)),n.stopEarly){c._.push.apply(c._,i.slice(h+1));break}}return Object.keys(u).forEach(function(d){e(c,d.split("."))||(m(c,d.split("."),u[d]),(s[d]||[]).forEach(function(b){m(c,b.split("."),u[d])}))}),n["--"]?c["--"]=w.slice():w.forEach(function(d){c._.push(d)}),c},Ae}var er=Qt();const tr=Ft(er);async function rr({rootFolder:e}){const t=A.join(e,".git");try{if(E.existsSync(t)){P.warn("Git repository already exists.");return}}catch(i){P.error(`Error checking git folder: ${i}`);return}const r=await X({message:"Do you want to initialize a git repository? (recommended)",options:[{value:!0,label:"Yes",hint:"You can use GitHub to track changes and collaborate with others."},{value:!1,label:"No",hint:"It is not recommended to skip this step."}],initialValue:!0});if(D(r)&&(F("Operation cancelled."),process.exit(0)),r){const i=await de([{title:"Initializing git repository...",task:async n=>{const a=await K("git",["init","-b","main"],{cwd:e});n(a.stdout);const s=await K("git",["add","."],{cwd:e});n(s.stdout);const o=await K("git",["config","user.name"]).then(c=>c.stdout.trim()).catch(()=>""),u=await K("git",["config","user.email"]).then(c=>c.stdout.trim()).catch(()=>"");return o&&u&&(await K("git",["commit","-m","Initial commit"],{cwd:e}),n("Initial commit created.")),"Git repository initialized."}}]);D(i)&&(F("Operation cancelled."),process.exit(0)),P.message(`Now, you can use GitHub Desktop upload your project to GitHub.
GitHub Desktop: https://github.com/apps/desktop`)}}var ie=(e=>(e.VisualStudioCode="vscode",e.Cursor="cursor",e.VSCodium="codium",e.Other="other",e))(ie||{});async function ir({rootFolder:e,fileToOpen:t}){const r=await X({message:"Which IDE do you want to use?",options:[{value:ie.VisualStudioCode,label:"Visual Studio Code"},{value:ie.Cursor,label:"Cursor"},{value:ie.VSCodium,label:"VSCodium"},{value:ie.Other,label:"Other"}],initialValue:ie.VisualStudioCode});if(D(r)&&(F("Operation cancelled."),process.exit(0)),r===void 0)return;let i,n;switch(r){case"vscode":n="Opening in Visual Studio Code...",i="code";break;case"cursor":n="Opening in Cursor...",i="cursor";break;case"codium":n="Opening in VSCodium...",i="codium";break;default:return}await de([{title:n,task:async a=>{try{await Le(i);const s=await K(i,[e]);if(a(s.stdout),t){const o=await K(i,[`${e}/${t}`]);a(o.stdout)}return`Opened project using ${r}`}catch{return`Could not open project using ${r}, since ${r} was not in your PATH`}}}])}var z=(e=>(e[e.VisualNovel=0]="VisualNovel",e[e.TextStory=1]="TextStory",e[e.PointAndClick=2]="PointAndClick",e[e.GameEngine=3]="GameEngine",e[e.Library=4]="Library",e))(z||{}),O=(e=>(e[e.Ink=0]="Ink",e[e.Renpy=1]="Renpy",e[e.Typescript=2]="Typescript",e))(O||{}),M=(e=>(e[e.React=0]="React",e[e.Vue=1]="Vue",e[e.Angular=2]="Angular",e))(M||{});const Qe="My Game",Z=[{type:z.VisualNovel,name:"Visual Novel",availableUI:[M.React],availableNarrativeLanguages:[O.Ink,O.Typescript],isMultidevice:!0,canReplaceUI:!0},{type:z.TextStory,name:"Text-based Story",availableUI:[M.React],availableNarrativeLanguages:[O.Ink,O.Typescript],isMultidevice:!0,canReplaceUI:!1},{type:z.PointAndClick,name:"Point & Click Adventure",availableUI:[M.React],availableNarrativeLanguages:[O.Ink,O.Typescript],isMultidevice:!0,canReplaceUI:!1},{type:z.GameEngine,name:"Game Engine",availableUI:[],availableNarrativeLanguages:[],isMultidevice:!1,canReplaceUI:!1},{type:z.Library,name:"Library",availableUI:[],availableNarrativeLanguages:[],isMultidevice:!1,canReplaceUI:!1}];async function sr({packageName:e}){const t=await X({message:"Select the type of game you want to create:",options:Z.map(c=>({label:c.name,value:c.type})),initialValue:Z[0].type});D(t)&&(F("Operation cancelled."),process.exit(0));const r=Z.find(c=>c.type===t)?.availableUI.map(c=>{let v="";switch(c){case M.React:v=ge("React");break;case M.Vue:v=Zt("Vue");break;case M.Angular:v=Jt("Angular");break}return{label:v,value:c}})||[];let i;r.length===1?(P.warning(`Only one UI framework available: ${r[0].label}. Using it by default.`),i=r[0].value):r.length>0?(i=await X({message:"Select the UI framework you want to use:",options:r,initialValue:Z.find(c=>c.type===t)?.availableUI[0]}),D(i)&&(F("Operation cancelled."),process.exit(0))):i=void 0;const n=Z.find(c=>c.type===t)?.availableNarrativeLanguages.map(c=>{let v="";switch(c){case O.Ink:v="Ink + Typescript";break;case O.Renpy:v=Xt("Renpy");break;case O.Typescript:v=ge("Typescript");break}return{label:v,value:c}})||[];let a;n.length===1?(P.warning(`Only one narrative language available: ${n[0].label}. Using it by default.`),a=n[0].value):n.length>0?(a=await X({message:"Select the narrative language you want to use:",options:n,initialValue:Z.find(c=>c.type===t)?.availableNarrativeLanguages[0]}),D(a)&&(F("Operation cancelled."),process.exit(0))):a=void 0;const s=Z.find(c=>c.type===t)?.isMultidevice;let o=!1,u="";return s&&(o=await X({message:"Which devices is the project intended for?",options:[{label:"Web page",value:!1},{label:"Web page + Desktop + Mobile (Tauri)",value:!0}],initialValue:!1}),D(o)&&(F("Operation cancelled."),process.exit(0)),o?(u=await se({message:"Project identifier:",initialValue:`com.${e}.app`,validate:c=>{if(!c)return"Identifier is required.";if(!/^[a-zA-Z0-9_.\-]+$/.test(c))return"Identifier can only contain letters, numbers, underscores, dots and dashes."}}),D(u)&&(F("Operation cancelled."),process.exit(0))):u=""),{gameType:t,UIFramework:i,narrativeLanguage:a,multidevice:o,identifier:u}}var N=(e=>(e.Delete="delete",e.Overwrite="overwrite",e.Skip="skip",e.Ask="ask",e.Cancel="cancel",e))(N||{});function nr(e){const t=E.readdirSync(e);return t.length===0||t.length===1&&t[0]===".git"}function et(e,t,r){if(!E.existsSync(t))return;const i=E.statSync(t);if(i.isFile())(r===N.Overwrite||r===N.Delete)&&E.rmSync(t,{force:!0});else if(i.isDirectory()){const n=E.readdirSync(e);for(const a of n){const s=A.join(e,a),o=A.join(t,a);et(s,o,r)}}}function ke(e,t,r){if(E.statSync(e).isDirectory()){E.mkdirSync(t,{recursive:!0});for(const i of E.readdirSync(e)){const n=A.join(e,i),a=A.join(t,i);ke(n,a,r)}}else{if(r!==void 0&&E.existsSync(t)){if(r===N.Skip)return;(r===N.Overwrite||r===N.Delete)&&E.rmSync(t,{force:!0})}E.copyFileSync(e,t)}}function ar(e){return/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(e)}function tt(e){return e.trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z\d\-~]+/g,"-")}async function or(){const e=await se({message:"Project name:",defaultValue:Qe,placeholder:Qe,validate:s=>{if(!s)return"Project name cannot be empty"}});D(e)&&(F("Operation cancelled."),process.exit(0));const t=await se({message:"Project description:",defaultValue:"A new game project",placeholder:"A new game project"});D(t)&&(F("Operation cancelled."),process.exit(0));const r=await se({message:"Package name:",defaultValue:tt(e),placeholder:tt(e),validate:s=>{if(s&&!ar(s))return"Invalid package name. The name can only include URL-friendly characters."}});D(r)&&(F("Operation cancelled."),process.exit(0));const i=A.basename(A.resolve()),n=await se({message:"Target directory:",defaultValue:r,placeholder:`${r} (If is equal to ".", the current directory (${i}) will be used)`});D(n)&&(F("Operation cancelled."),process.exit(0));let a;return E.existsSync(n)&&!nr(n)?(a=await X({message:"Overwrite existing files?",options:[{hint:"Delete all existing files and create a new project",label:"Delete all",value:N.Delete},{hint:"Overwrite existing conflicting files",label:"Overwrite",value:N.Overwrite},{hint:"Skip existing conflicting files",label:"Skip",value:N.Skip},{hint:"Ask for each file",label:"Ask",value:N.Ask},{hint:"Cancel operation",label:"Cancel",value:N.Cancel}],initialValue:N.Overwrite}),(D(a)||a===N.Cancel)&&(F("Operation cancelled."),process.exit(0))):a=void 0,{projectName:e,foltderName:n,description:t,packageName:r,overwrite:a}}const rt={_gitignore:".gitignore"};function it(e,t,r,i,n){return e=e.replace(/my-app-package-name/g,t),e=e.replace(/my-app-description/g,r),e=e.replace(/my-app-project-name/g,i),n&&(e=e.replace(/com\.my-app-project-name\.app/g,n)),e}function st(e,t,r,i,n){E.existsSync(e)&&E.writeFileSync(e,it(E.readFileSync(e,"utf-8"),t,r,i,n))}async function ur({rootFolder:e,overwrite:t,template:r,packageName:i,description:n,projectName:a,identifier:s}){const o=await de([{title:`Creating project in ${e}...`,task:async()=>{E.existsSync(e)||E.mkdirSync(e,{recursive:!0});const u=A.resolve(lt(import.meta.url),"../..",`${r}`),c=(w,h)=>{const f=A.join(e,rt[w]??w);h?E.writeFileSync(f,h):ke(A.join(u,w),f,t)},v=E.readdirSync(u).map(async w=>{const h=A.join(u,w),f=A.join(e,rt[w]??w);if(E.existsSync(f))switch(t){case N.Ask:if(E.statSync(f).isFile()){const g=await Je({message:`File ${f} already exists. Do you want to overwrite it?`,initialValue:!1});if(D(g)&&(F("Operation cancelled."),process.exit(0)),!g)return;E.rmSync(f,{force:!0})}else{const g=E.readdirSync(h);for(const I of g){const j=A.join(h,I),k=A.join(f,I);if(E.existsSync(k)){const S=await Je({message:`File ${k} already exists. Do you want to overwrite it?`,initialValue:!1});if(D(S)&&(F("Operation cancelled."),process.exit(0)),!S)continue;E.rmSync(k,{force:!0})}ke(j,k,t)}return}break;case N.Skip:return;case N.Overwrite:case N.Delete:et(h,f,t);break}switch(w){case"package.json":case"vite.config.ts":case"index.html":case"README.md":{c(w,it(E.readFileSync(h,"utf-8"),i,n,a));break}case".git":case"package-lock.json":break;default:c(w)}});await Promise.all(v),st(A.join(e,".vscode","launch.json"),i,n,a);const m=A.join(e,"src-tauri");if(E.existsSync(m))for(const w of["Cargo.toml","tauri.conf.json"])st(A.join(m,w),i,n,a,s);const p=A.join(e,"_github");return E.existsSync(p)&&E.renameSync(p,A.join(e,".github")),"Project created"}}]);D(o)&&(F("Operation cancelled."),process.exit(0))}const cr=process.cwd();async function lr(){let e,{description:t,overwrite:r,packageName:i,projectName:n,foltderName:a}=await or(),{UIFramework:s,gameType:o,narrativeLanguage:u,multidevice:c,identifier:v}=await sr({packageName:i});const m=A.join(cr,a);let p;switch(o){case z.VisualNovel:switch(s){case M.React:switch(u){case O.Typescript:c?p="template-react-vite-muijoy-tauri":p="template-react-vite-muijoy",e="src/content/labels/start.label.ts";break;case O.Ink:c?p="template-react-vite-muijoy-ink-tauri":p="template-react-vite-muijoy-ink",e="ink/start.ink";break;case O.Renpy:F("Error: There are no templates for this narrative language"),process.exit(0);default:F("Error: Unknown narrative language"),process.exit(0)}break;case M.Vue:case M.Angular:F("Error: There are no templates for this game type and UI framework"),process.exit(0);default:F("Error: Unknown UI framework"),process.exit(0)}break;case z.TextStory:switch(s){case M.React:switch(u){case O.Typescript:c?p="template-story-react-vite-muijoy-tauri":p="template-story-react-vite-muijoy",e="src/labels/startLabel.ts";break;case O.Ink:c?p="template-story-react-vite-muijoy-ink-tauri":p="template-story-react-vite-muijoy-ink",e="src/ink/start.ink";break;case O.Renpy:F("Error: There are no templates for this narrative language"),process.exit(0);default:F("Error: Unknown narrative language"),process.exit(0)}break;case M.Vue:case M.Angular:F("Error: There are no templates for this game type and UI framework"),process.exit(0);default:F("Error: Unknown UI framework"),process.exit(0)}break;case z.PointAndClick:switch(s){case M.React:switch(u){case O.Typescript:c?p="template-nqtr-react-vite-muijoy-tauri":p="template-nqtr-react-vite-muijoy",e="src/labels/startLabel.ts";break;case O.Ink:c?p="template-nqtr-react-vite-muijoy-ink-tauri":p="template-nqtr-react-vite-muijoy-ink",e="src/ink/variousActionsLabels.ink";break;case O.Renpy:F("Error: There are no templates for this narrative language"),process.exit(0);default:F("Error: Unknown narrative language"),process.exit(0)}break;case M.Vue:case M.Angular:F("Error: There are no templates for this game type and UI framework"),process.exit(0);default:F("Error: Unknown UI framework"),process.exit(0)}break;case z.GameEngine:p="template-game-engine",e="src/index.ts";break;case z.Library:p="template-lib",e="src/index.ts";break;default:F("Error: Unknown game type"),process.exit(0)}await ur({rootFolder:m,template:p,packageName:i,description:t,projectName:n,overwrite:r,identifier:v});const w=Z.find(h=>h.type===o)?.canReplaceUI??!1;return{rootFolder:m,fileToOpen:e,canReplaceUI:w}}function pr(){console.info(`
\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2557  \u2588\u2588\u2557\u2588\u2588\u2557      \u2588\u2588\u2557   \u2588\u2588\u2557\u2588\u2588\u2588\u2557   \u2588\u2588\u2557
\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2554\u255D\u2588\u2588\u2551      \u2588\u2588\u2551   \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2557  \u2588\u2588\u2551
\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551   \u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551
\u2588\u2588\u2554\u2550\u2550\u2550\u255D \u2588\u2588\u2551 \u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551\u255A\u2550\u2550\u2550\u2550\u255D\u255A\u2588\u2588\u2557 \u2588\u2588\u2554\u255D\u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2551
\u2588\u2588\u2551     \u2588\u2588\u2551\u2588\u2588\u2554\u255D \u2588\u2588\u2557\u2588\u2588\u2551       \u255A\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2551
\u255A\u2550\u255D     \u255A\u2550\u255D\u255A\u2550\u255D  \u255A\u2550\u255D\u255A\u2550\u255D        \u255A\u2550\u2550\u2550\u255D  \u255A\u2550\u255D  \u255A\u2550\u2550\u2550\u255D
`)}function fr(e){if(!e)return;const t=e.split(" ")[0].split("/");return{name:t[0],version:t[1]}}const hr=tr(process.argv.slice(2),{default:{help:!1},alias:{h:"help",t:"template"},string:["_"]}),nt=process.cwd(),dr=`Usage: create-pixi-vn [OPTION]... [DIRECTORY]

Create a new Pixi\u2019VN project.
With no arguments, start the CLI in interactive mode.

Options:
  -t, --template NAME        use a specific template

Available templates:
${ge("basic-visual-novel       react")}`;async function mr(){try{if(pr(),Ht(`Welcome to ${ge("Pixi\u2019VN")}! \u{1F3A8}\u2728`),hr.help){console.log(dr);return}const{rootFolder:e,fileToOpen:t,canReplaceUI:r}=await lr(),i=A.join(e,"package-lock.json");E.existsSync(i)&&E.rmSync(i);const n=fr(process.env.npm_config_user_agent),a=n?n.name:"npm",s=A.relative(nt,e);r&&(P.info("You will need to select a UI theme for your project."),await de([{title:"Installing shadcn globally...",task:async()=>{try{await Le(a),a==="yarn"?await K("yarn",["global","add","shadcn@latest"]):await K(a,["install","-g","shadcn@latest"])}catch{return"Could not install shadcn globally"}return"shadcn installed globally."}}]),P.step("Running ui:reinit..."),a==="yarn"?await K("yarn",["ui:reinit"],{cwd:e,stdio:"inherit"}):await K(a,["run","ui:reinit"],{cwd:e,stdio:"inherit"})),await rr({rootFolder:e}),await ir({rootFolder:e,fileToOpen:t});let o="To run the game:";switch(e!==nt&&(o+=`
  cd ${s.includes(" ")?`"${s}"`:s}`),a){case"yarn":o+=`
  yarn`,o+=`
  yarn dev`;break;default:o+=`
  ${a} install`,o+=`
  ${a} run start`;break}P.message(o),zt("You're all set! \u{1F389} Now go build your game! \u{1F680}"),await ct("https://pixi-vn.com/start/templates"),console.log()}catch(e){console.error(e)}}mr().catch(e=>{console.error(e)});
