@ttmg/cli 0.0.12-beta.1 → 0.0.12-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
* @ignore
|
|
55
55
|
* @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE}
|
|
56
56
|
* @copyright (c) 2012-2014 Chris Talkington, contributors.
|
|
57
|
-
*/()),EC=r}function MC(){if(SC)return CC;SC=1;const e=t,r=c,n=h,{MINIS_MANIFEST_FILE_NAME:u}=_b();function i(e,t){let r=t.find(t=>"folder"===t.type&&t.name===e[0]);return r||(r={type:"folder",name:e[0],children:[]},t.push(r)),e.length>1?i(e.slice(1),r.children):r}function o(e,t=e){const u={};return r.readdirSync(e).forEach(i=>{const a=n.join(e,i);if(r.statSync(a).isDirectory()){const e=o(a,t);Object.assign(u,e)}else if(""!==n.extname(i)&&i){const e="/"+n.relative(t,a).replace(/\\/g,"/");u[a]=e}}),u}return CC={buildMinisManifest:async function(){try{const e=n.join(process.cwd()),t=[],a=o(e);Object.keys(a).filter(e=>!e.endsWith(".map")).forEach(e=>{const r=a[e].split("/").filter(Boolean),n=r.pop()||"";if(0===r.length)t.push({type:"file",name:n});else{i(r,t).children.push({type:"file",name:n})}}),r.writeFileSync(n.join(e,u),JSON.stringify({name:u,resource_list:t},null,2))}catch(t){console.error(e.red(`Error during debug process: ${t.message}`)),t instanceof Error&&t.stack&&console.error(e.red(`Stack trace: ${t.stack}`)),process.exit(1)}}},CC}var IC=function(){if(BC)return OC;BC=1;const e=c,r=g,n=h,u=cb(),i=t,o=TC(),a=u.createPromptModule(),{buildMinisManifest:s}=MC();return OC=async function(){try{const{zipName:t}=await a({type:"input",name:"zipName",default:"game",message:"Please input zip name"}),u=Date.now();console.log(i.bold.blue("start build your game, it will take a few minutes..."));e.readdirSync(process.cwd()).forEach(t=>{t.endsWith(".zip")&&e.unlinkSync(n.join(process.cwd(),t))}),await s();const c=o("zip",{zlib:{level:9}});c.on("error",function(e){throw e});const l=function(){const t=r.homedir(),u=["Desktop","桌面"];for(const r of u){const u=n.join(t,r);if(e.existsSync(u))return u}return n.join(t,"Desktop")}(),f=n.join(l,`${t}.zip`);return await c.pipe(e.createWriteStream(f)),await c.directory(n.resolve(process.cwd()),!1),await c.finalize(),console.log(i.yellow.bold(`build ${t}.zip success, you can find it in desktop, use time ${Date.now()-u} ms`)),new Promise((e,t)=>{c.on("end",e),c.on("error",t)})}catch(e){console.log(i.red(`auto build ${zipNameInput}.zip failed: ${e.message}, you should zip it manually`))}},OC}(),LC=T(IC);function RC(e){return`https://www.tiktok.com/ttmg/dev/${e}?host=${function(){const e=g.networkInterfaces();for(const t in e){const r=e[t];if(r)for(const e of r)if("IPv4"===e.family&&!e.internal)return e.address}}()}&port=9527`}const NC=e=>"up"===e.name||"k"===e.name||e.ctrl&&"p"===e.name,UC=e=>"down"===e.name||"j"===e.name||e.ctrl&&"n"===e.name,zC=e=>"backspace"===e.name,$C=e=>"1234567890".includes(e.name),qC=e=>"enter"===e.name||"return"===e.name;class WC extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(e){super(),this.cause=e?.cause}}class GC extends Error{name="CancelPromptError";message="Prompt was canceled"}class VC extends Error{name="ExitPromptError"}class KC extends Error{name="HookError"}class YC extends Error{name="ValidationError"}const HC=new r.AsyncLocalStorage;function ZC(){const e=HC.getStore();if(!e)throw new KC("[Inquirer] Hook functions can only be called from within a prompt");return e}function QC(){return ZC().rl}function JC(e){return r.AsyncResource.bind((...t)=>{const r=ZC();let n=!1;const u=r.handleChange;r.handleChange=()=>{n=!0};const i=e(...t);return n&&u(),r.handleChange=u,i})}function XC(e){const t=ZC(),{index:r}=t,n=e({get:()=>t.hooks[r],set(e){t.hooks[r]=e},initialized:r in t.hooks});return t.index++,n}const eS={queue(e){const t=ZC(),{index:r}=t;t.hooksEffect.push(()=>{t.hooksCleanup[r]?.();const n=e(QC());if(null!=n&&"function"!=typeof n)throw new YC("useEffect return value must be a cleanup function or nothing.");t.hooksCleanup[r]=n})},run(){const e=ZC();JC(()=>{e.hooksEffect.forEach(e=>{e()}),e.hooksEffect.length=0})()},clearAll(){const e=ZC();e.hooksCleanup.forEach(e=>{e?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function tS(e){return XC(t=>{const n=r.AsyncResource.bind(function(e){t.get()!==e&&(t.set(e),ZC().handleChange())});if(t.initialized)return[t.get(),n];const u="function"==typeof e?e():e;return t.set(u),[u,n]})}function rS(e,t){XC(r=>{const n=r.get();(!Array.isArray(n)||t.some((e,t)=>!Object.is(e,n[t])))&&eS.queue(e),r.set(t)})}var nS=T(ie());const uS={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"█",squareDarkShade:"▓",squareMediumShade:"▒",squareLightShade:"░",squareTop:"▀",squareBottom:"▄",squareLeft:"▌",squareRight:"▐",squareCenter:"■",bullet:"●",dot:"․",ellipsis:"…",pointerSmall:"›",triangleUp:"▲",triangleUpSmall:"▴",triangleDown:"▼",triangleDownSmall:"▾",triangleLeftSmall:"◂",triangleRightSmall:"▸",home:"⌂",heart:"♥",musicNote:"♪",musicNoteBeamed:"♫",arrowUp:"↑",arrowDown:"↓",arrowLeft:"←",arrowRight:"→",arrowLeftRight:"↔",arrowUpDown:"↕",almostEqual:"≈",notEqual:"≠",lessOrEqual:"≤",greaterOrEqual:"≥",identical:"≡",infinity:"∞",subscriptZero:"₀",subscriptOne:"₁",subscriptTwo:"₂",subscriptThree:"₃",subscriptFour:"₄",subscriptFive:"₅",subscriptSix:"₆",subscriptSeven:"₇",subscriptEight:"₈",subscriptNine:"₉",oneHalf:"½",oneThird:"⅓",oneQuarter:"¼",oneFifth:"⅕",oneSixth:"⅙",oneEighth:"⅛",twoThirds:"⅔",twoFifths:"⅖",threeQuarters:"¾",threeFifths:"⅗",threeEighths:"⅜",fourFifths:"⅘",fiveSixths:"⅚",fiveEighths:"⅝",sevenEighths:"⅞",line:"─",lineBold:"━",lineDouble:"═",lineDashed0:"┄",lineDashed1:"┅",lineDashed2:"┈",lineDashed3:"┉",lineDashed4:"╌",lineDashed5:"╍",lineDashed6:"╴",lineDashed7:"╶",lineDashed8:"╸",lineDashed9:"╺",lineDashed10:"╼",lineDashed11:"╾",lineDashed12:"−",lineDashed13:"–",lineDashed14:"‐",lineDashed15:"⁃",lineVertical:"│",lineVerticalBold:"┃",lineVerticalDouble:"║",lineVerticalDashed0:"┆",lineVerticalDashed1:"┇",lineVerticalDashed2:"┊",lineVerticalDashed3:"┋",lineVerticalDashed4:"╎",lineVerticalDashed5:"╏",lineVerticalDashed6:"╵",lineVerticalDashed7:"╷",lineVerticalDashed8:"╹",lineVerticalDashed9:"╻",lineVerticalDashed10:"╽",lineVerticalDashed11:"╿",lineDownLeft:"┐",lineDownLeftArc:"╮",lineDownBoldLeftBold:"┓",lineDownBoldLeft:"┒",lineDownLeftBold:"┑",lineDownDoubleLeftDouble:"╗",lineDownDoubleLeft:"╖",lineDownLeftDouble:"╕",lineDownRight:"┌",lineDownRightArc:"╭",lineDownBoldRightBold:"┏",lineDownBoldRight:"┎",lineDownRightBold:"┍",lineDownDoubleRightDouble:"╔",lineDownDoubleRight:"╓",lineDownRightDouble:"╒",lineUpLeft:"┘",lineUpLeftArc:"╯",lineUpBoldLeftBold:"┛",lineUpBoldLeft:"┚",lineUpLeftBold:"┙",lineUpDoubleLeftDouble:"╝",lineUpDoubleLeft:"╜",lineUpLeftDouble:"╛",lineUpRight:"└",lineUpRightArc:"╰",lineUpBoldRightBold:"┗",lineUpBoldRight:"┖",lineUpRightBold:"┕",lineUpDoubleRightDouble:"╚",lineUpDoubleRight:"╙",lineUpRightDouble:"╘",lineUpDownLeft:"┤",lineUpBoldDownBoldLeftBold:"┫",lineUpBoldDownBoldLeft:"┨",lineUpDownLeftBold:"┥",lineUpBoldDownLeftBold:"┩",lineUpDownBoldLeftBold:"┪",lineUpDownBoldLeft:"┧",lineUpBoldDownLeft:"┦",lineUpDoubleDownDoubleLeftDouble:"╣",lineUpDoubleDownDoubleLeft:"╢",lineUpDownLeftDouble:"╡",lineUpDownRight:"├",lineUpBoldDownBoldRightBold:"┣",lineUpBoldDownBoldRight:"┠",lineUpDownRightBold:"┝",lineUpBoldDownRightBold:"┡",lineUpDownBoldRightBold:"┢",lineUpDownBoldRight:"┟",lineUpBoldDownRight:"┞",lineUpDoubleDownDoubleRightDouble:"╠",lineUpDoubleDownDoubleRight:"╟",lineUpDownRightDouble:"╞",lineDownLeftRight:"┬",lineDownBoldLeftBoldRightBold:"┳",lineDownLeftBoldRightBold:"┯",lineDownBoldLeftRight:"┰",lineDownBoldLeftBoldRight:"┱",lineDownBoldLeftRightBold:"┲",lineDownLeftRightBold:"┮",lineDownLeftBoldRight:"┭",lineDownDoubleLeftDoubleRightDouble:"╦",lineDownDoubleLeftRight:"╥",lineDownLeftDoubleRightDouble:"╤",lineUpLeftRight:"┴",lineUpBoldLeftBoldRightBold:"┻",lineUpLeftBoldRightBold:"┷",lineUpBoldLeftRight:"┸",lineUpBoldLeftBoldRight:"┹",lineUpBoldLeftRightBold:"┺",lineUpLeftRightBold:"┶",lineUpLeftBoldRight:"┵",lineUpDoubleLeftDoubleRightDouble:"╩",lineUpDoubleLeftRight:"╨",lineUpLeftDoubleRightDouble:"╧",lineUpDownLeftRight:"┼",lineUpBoldDownBoldLeftBoldRightBold:"╋",lineUpDownBoldLeftBoldRightBold:"╈",lineUpBoldDownLeftBoldRightBold:"╇",lineUpBoldDownBoldLeftRightBold:"╊",lineUpBoldDownBoldLeftBoldRight:"╉",lineUpBoldDownLeftRight:"╀",lineUpDownBoldLeftRight:"╁",lineUpDownLeftBoldRight:"┽",lineUpDownLeftRightBold:"┾",lineUpBoldDownBoldLeftRight:"╂",lineUpDownLeftBoldRightBold:"┿",lineUpBoldDownLeftBoldRight:"╃",lineUpBoldDownLeftRightBold:"╄",lineUpDownBoldLeftBoldRight:"╅",lineUpDownBoldLeftRightBold:"╆",lineUpDoubleDownDoubleLeftDoubleRightDouble:"╬",lineUpDoubleDownDoubleLeftRight:"╫",lineUpDownLeftDoubleRightDouble:"╪",lineCross:"╳",lineBackslash:"╲",lineSlash:"╱"},iS={...uS,tick:"✔",info:"ℹ",warning:"⚠",cross:"✘",squareSmall:"◻",squareSmallFilled:"◼",circle:"◯",circleFilled:"◉",circleDotted:"◌",circleDouble:"◎",circleCircle:"ⓞ",circleCross:"ⓧ",circlePipe:"Ⓘ",radioOn:"◉",radioOff:"◯",checkboxOn:"☒",checkboxOff:"☐",checkboxCircleOn:"ⓧ",checkboxCircleOff:"Ⓘ",pointer:"❯",triangleUpOutline:"△",triangleLeft:"◀",triangleRight:"▶",lozenge:"◆",lozengeOutline:"◇",hamburger:"☰",smiley:"㋡",mustache:"෴",star:"★",play:"▶",nodejs:"⬢",oneSeventh:"⅐",oneNinth:"⅑",oneTenth:"⅒"},oS={...uS,tick:"√",info:"i",warning:"‼",cross:"×",squareSmall:"□",squareSmallFilled:"■",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(○)",circleCross:"(×)",circlePipe:"(│)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[×]",checkboxOff:"[ ]",checkboxCircleOn:"(×)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"∆",triangleLeft:"◄",triangleRight:"►",lozenge:"♦",lozengeOutline:"◊",hamburger:"≡",smiley:"☺",mustache:"┌─┐",star:"✶",play:"►",nodejs:"♦",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},aS=("win32"!==u.platform?"linux"!==u.env.TERM:Boolean(u.env.WT_SESSION)||Boolean(u.env.TERMINUS_SUBLIME)||"{cmd::Cmder}"===u.env.ConEmuTask||"Terminus-Sublime"===u.env.TERM_PROGRAM||"vscode"===u.env.TERM_PROGRAM||"xterm-256color"===u.env.TERM||"alacritty"===u.env.TERM||"JetBrains-JediTerm"===u.env.TERMINAL_EMULATOR)?iS:oS,sS={prefix:{idle:nS.blue("?"),done:nS.green(aS.tick)},spinner:{interval:80,frames:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"].map(e=>nS.yellow(e))},style:{answer:nS.cyan,message:nS.bold,error:e=>nS.red(`> ${e}`),defaultAnswer:e=>nS.dim(`(${e})`),help:nS.dim,highlight:nS.cyan,key:e=>nS.cyan(nS.bold(`<${e}>`))}};function cS(e){if("object"!=typeof e||null===e)return!1;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function lS(...e){const t={};for(const r of e)for(const[e,n]of Object.entries(r)){const r=t[e];t[e]=cS(r)&&cS(n)?lS(r,n):n}return t}function fS(...e){const t=[sS,...e.filter(e=>null!=e)];return lS(...t)}function dS({status:e="idle",theme:t}){const[r,n]=tS(!1),[u,i]=tS(0),{prefix:o,spinner:a}=fS(t);if(rS(()=>{if("loading"===e){let e,t=-1;const r=setTimeout(()=>{n(!0),e=setInterval(()=>{t+=1,i(t%a.frames.length)},a.interval)},300);return()=>{clearTimeout(r),clearInterval(e)}}n(!1)},[e]),r)return a.frames[u];return"string"==typeof o?o:o["loading"===e?"idle":e]??o.idle}function pS(e,t){return XC(r=>{const n=r.get();if(!n||n.dependencies.length!==t.length||n.dependencies.some((e,r)=>e!==t[r])){const n=e();return r.set({value:n,dependencies:t}),n}return n.value})}function hS(e){return tS({current:e})[0]}function DS(e){const t=hS(e);t.current=e,rS(e=>{let r=!1;const n=JC((n,u)=>{r||t.current(u,e)});return e.input.on("keypress",n),()=>{r=!0,e.input.removeListener("keypress",n)}},[])}var bS=T(we()),yS=T(ut());function vS(e,t){return e.split("\n").flatMap(e=>yS(e,t,{trim:!1,hard:!0}).split("\n").map(e=>e.trimEnd())).join("\n")}function mS(){return bS({defaultWidth:80,output:QC().output})}function gS({items:e,active:t,renderItem:r,pageSize:n,loop:u=!0}){const i=mS(),o=t=>(t%e.length+e.length)%e.length,a=e.map((e,n)=>null==e?[]:vS(r({item:e,index:n,isActive:n===t}),i).split("\n")),s=a.reduce((e,t)=>e+t.length,0),c=e=>a[e]??[],l=function({active:e,renderedItems:t,pageSize:r,loop:n}){const u=hS({lastPointer:e,lastActive:void 0}),{lastPointer:i,lastActive:o}=u.current,a=Math.floor(r/2),s=t.reduce((e,t)=>e+t.length,0),c=t.slice(0,e).reduce((e,t)=>e+t.length,0);let l=c;if(s>r)if(n)l=i,null!=o&&o<e&&e-o<r&&(l=Math.min(a,1===Math.abs(e-o)?Math.min(i+(t[o]?.length??0),Math.max(c,i)):i+e-o));else{const n=t.slice(e).reduce((e,t)=>e+t.length,0);l=n<r-a?r-n:Math.min(c,a)}return u.current.lastPointer=l,u.current.lastActive=e,l}({active:t,renderedItems:a,pageSize:n,loop:u}),f=c(t).slice(0,n),d=l+f.length<=n?l:n-f.length,p=Array.from({length:n});p.splice(d,f.length,...f);const h=new Set([t]);let D=d+f.length,b=o(t+1);for(;D<n&&!h.has(b)&&(u&&s>n?b!==t:b>t);){const e=c(b).slice(0,n-D);p.splice(D,e.length,...e),h.add(b),D+=e.length,b=o(b+1)}for(D=d-1,b=o(t-1);D>=0&&!h.has(b)&&(u&&s>n?b!==t:b<t);){const e=c(b),t=e.slice(Math.max(0,e.length-D-1));p.splice(D-t.length+1,t.length,...t),h.add(b),D-=t.length,b=o(b-1)}return p.filter(e=>"string"==typeof e).join("\n")}var FS=T(lt());const _S=[];_S.push("SIGHUP","SIGINT","SIGTERM"),"win32"!==process.platform&&_S.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT"),"linux"===process.platform&&_S.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");const ES=e=>!!e&&"object"==typeof e&&"function"==typeof e.removeListener&&"function"==typeof e.emit&&"function"==typeof e.reallyExit&&"function"==typeof e.listeners&&"function"==typeof e.kill&&"number"==typeof e.pid&&"function"==typeof e.on,wS=Symbol.for("signal-exit emitter"),CS=globalThis,SS=Object.defineProperty.bind(Object);class OS{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(CS[wS])return CS[wS];SS(CS,wS,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,t){this.listeners[e].push(t)}removeListener(e,t){const r=this.listeners[e],n=r.indexOf(t);-1!==n&&(0===n&&1===r.length?r.length=0:r.splice(n,1))}emit(e,t,r){if(this.emitted[e])return!1;this.emitted[e]=!0;let n=!1;for(const u of this.listeners[e])n=!0===u(t,r)||n;return"exit"===e&&(n=this.emit("afterExit",t,r)||n),n}}class BS{}const xS=globalThis.process,{onExit:AS}=(PS=ES(xS)?new class extends BS{#n="win32"===xS.platform?"SIGINT":"SIGHUP";#u=new OS;#i;#o;#a;#s={};#c=!1;constructor(e){super(),this.#i=e,this.#s={};for(const t of _S)this.#s[t]=()=>{const r=this.#i.listeners(t);let{count:n}=this.#u;const u=e;if("object"==typeof u.__signal_exit_emitter__&&"number"==typeof u.__signal_exit_emitter__.count&&(n+=u.__signal_exit_emitter__.count),r.length===n){this.unload();const r=this.#u.emit("exit",null,t),n="SIGHUP"===t?this.#n:t;r||e.kill(e.pid,n)}};this.#a=e.reallyExit,this.#o=e.emit}onExit(e,t){if(!ES(this.#i))return()=>{};!1===this.#c&&this.load();const r=t?.alwaysLast?"afterExit":"exit";return this.#u.on(r,e),()=>{this.#u.removeListener(r,e),0===this.#u.listeners.exit.length&&0===this.#u.listeners.afterExit.length&&this.unload()}}load(){if(!this.#c){this.#c=!0,this.#u.count+=1;for(const e of _S)try{const t=this.#s[e];t&&this.#i.on(e,t)}catch(e){}this.#i.emit=(e,...t)=>this.#l(e,...t),this.#i.reallyExit=e=>this.#f(e)}}unload(){this.#c&&(this.#c=!1,_S.forEach(e=>{const t=this.#s[e];if(!t)throw new Error("Listener not defined for signal: "+e);try{this.#i.removeListener(e,t)}catch(e){}}),this.#i.emit=this.#o,this.#i.reallyExit=this.#a,this.#u.count-=1)}#f(e){return ES(this.#i)?(this.#i.exitCode=e||0,this.#u.emit("exit",this.#i.exitCode,null),this.#a.call(this.#i,this.#i.exitCode)):0}#l(e,...t){const r=this.#o;if("exit"===e&&ES(this.#i)){"number"==typeof t[0]&&(this.#i.exitCode=t[0]);const n=r.call(this.#i,e,...t);return this.#u.emit("exit",this.#i.exitCode,null),n}return r.call(this.#i,e,...t)}}(xS):new class extends BS{onExit(){return()=>{}}load(){}unload(){}},{onExit:(e,t)=>PS.onExit(e,t),load:()=>PS.load(),unload:()=>PS.unload()});var PS,jS=T(gt());const kS=e=>e.split("\n").length;function TS(e){return e>0?jS.cursorDown(e):""}class MS{height=0;extraLinesUnderPrompt=0;cursorPos;rl;constructor(e){this.rl=e,this.cursorPos=e.getCursorPos()}write(e){this.rl.output.unmute(),this.rl.output.write(e),this.rl.output.mute()}render(e,t=""){const r=(e=>e.split("\n").pop()??"")(e),n=s.stripVTControlCharacters(r);let u=n;this.rl.line.length>0&&(u=u.slice(0,-this.rl.line.length)),this.rl.setPrompt(u),this.cursorPos=this.rl.getCursorPos();const i=mS();e=vS(e,i),t=vS(t,i),n.length%i===0&&(e+="\n");let o=e+(t?"\n"+t:"");const a=Math.floor(n.length/i)-this.cursorPos.rows+(t?kS(t):0);a>0&&(o+=jS.cursorUp(a)),o+=jS.cursorTo(this.cursorPos.cols),this.write(TS(this.extraLinesUnderPrompt)+jS.eraseLines(this.height)+o),this.extraLinesUnderPrompt=a,this.height=kS(o)}checkCursorPos(){const e=this.rl.getCursorPos();e.cols!==this.cursorPos.cols&&(this.write(jS.cursorTo(e.cols)),this.cursorPos=e)}done({clearContent:e}){this.rl.setPrompt("");let t=TS(this.extraLinesUnderPrompt);t+=e?jS.eraseLines(this.height):"\n",t+=jS.cursorShow,this.write(t),this.rl.close()}}class IS extends Promise{static withResolver(){let e,t;return{promise:new Promise((r,n)=>{e=r,t=n}),resolve:e,reject:t}}}function LS(e){const t=function(){const e=Error.prepareStackTrace;let t=[];try{Error.prepareStackTrace=(e,r)=>{const n=r.slice(1);return t=n,n},(new Error).stack}catch{return t}return Error.prepareStackTrace=e,t}();return(n,u={})=>{const{input:i=process.stdin,signal:o}=u,a=new Set,s=new FS;s.pipe(u.output??process.stdout);const c=j.createInterface({terminal:!0,input:i,output:s}),l=new MS(c),{promise:f,resolve:d,reject:p}=IS.withResolver(),h=()=>p(new GC);if(o){const e=()=>p(new WC({cause:o.reason}));if(o.aborted)return e(),Object.assign(f,{cancel:h});o.addEventListener("abort",e),a.add(()=>o.removeEventListener("abort",e))}a.add(AS((e,t)=>{p(new VC(`User force closed the prompt with ${e} ${t}`))}));const D=()=>p(new VC("User force closed the prompt with SIGINT"));c.on("SIGINT",D),a.add(()=>c.removeListener("SIGINT",D));const b=()=>l.checkCursorPos();return c.input.on("keypress",b),a.add(()=>c.input.removeListener("keypress",b)),function(e,t){const r=function(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}(e);return HC.run(r,()=>t(function(e){r.handleChange=()=>{r.index=0,e()},r.handleChange()}))}(c,i=>{const o=r.AsyncResource.bind(()=>eS.clearAll());return c.on("close",o),a.add(()=>c.removeListener("close",o)),i(()=>{try{const r=e(n,e=>{setImmediate(()=>d(e))});if(void 0===r){const e=t[1]?.getFileName();throw new Error(`Prompt functions must return a string.\n at ${e}`)}const[u,i]="string"==typeof r?[r]:r;l.render(u,i),eS.run()}catch(e){p(e)}}),Object.assign(f.then(e=>(eS.clearAll(),e),e=>{throw eS.clearAll(),e}).finally(()=>{a.forEach(e=>e()),l.done({clearContent:Boolean(u.clearPromptOnDone)}),s.end()}).then(()=>f),{cancel:h})})}}class RS{separator=nS.dim(Array.from({length:15}).join(aS.line));type="separator";constructor(e){e&&(this.separator=e)}static isSeparator(e){return Boolean(e&&"object"==typeof e&&"type"in e&&"separator"===e.type)}}const NS={icon:{checked:nS.green(aS.circleFilled),unchecked:aS.circle,cursor:aS.pointer},style:{disabledChoice:e=>nS.dim(`- ${e}`),renderSelectedChoices:e=>e.map(e=>e.short).join(", "),description:e=>nS.cyan(e)},helpMode:"auto"};function US(e){return!RS.isSeparator(e)&&!e.disabled}function zS(e){return US(e)&&Boolean(e.checked)}function $S(e){return US(e)?{...e,checked:!e.checked}:e}var qS=LS((e,t)=>{const{instructions:r,pageSize:n=7,loop:u=!0,required:i,validate:o=()=>!0}=e,a={all:"a",invert:"i",...e.shortcuts},s=fS(NS,e.theme),c=hS(!0),[l,f]=tS("idle"),d=dS({status:l,theme:s}),[p,h]=tS(e.choices.map(e=>{if(RS.isSeparator(e))return e;if("string"==typeof e)return{value:e,name:e,short:e,disabled:!1,checked:!1};const t=e.name??String(e.value),r={value:e.value,name:t,short:e.short??t,disabled:e.disabled??!1,checked:e.checked??!1};return e.description&&(r.description=e.description),r}));const D=pS(()=>{const e=p.findIndex(US),t=p.findLastIndex(US);if(-1===e)throw new YC("[checkbox prompt] No selectable choices. All choices are disabled.");return{first:e,last:t}},[p]),[b,y]=tS(D.first),[v,m]=tS(!0),[g,F]=tS();DS(async e=>{if(qC(e)){const e=p.filter(zS),r=await o([...e]);i&&!p.some(zS)?F("At least one choice must be selected"):!0===r?(f("done"),t(e.map(e=>e.value))):F(r||"You must select a valid value")}else if(NC(e)||UC(e)){if(u||NC(e)&&b!==D.first||UC(e)&&b!==D.last){const t=NC(e)?-1:1;let r=b;do{r=(r+t+p.length)%p.length}while(!US(p[r]));y(r)}}else if((e=>"space"===e.name)(e))F(void 0),m(!1),h(p.map((e,t)=>t===b?$S(e):e));else if(e.name===a.all){const e=p.some(e=>US(e)&&!e.checked);h(p.map((r=e,function(e){return US(e)?{...e,checked:r}:e})))}else if(e.name===a.invert)h(p.map($S));else if($C(e)){const t=Number(e.name)-1,r=p[t];null!=r&&US(r)&&(y(t),h(p.map((e,r)=>r===t?$S(e):e)))}var r});const _=s.style.message(e.message,l);let E;const w=gS({items:p,active:b,renderItem({item:e,isActive:t}){if(RS.isSeparator(e))return` ${e.separator}`;if(e.disabled){const t="string"==typeof e.disabled?e.disabled:"(disabled)";return s.style.disabledChoice(`${e.name} ${t}`)}t&&(E=e.description);const r=e.checked?s.icon.checked:s.icon.unchecked;return(t?s.style.highlight:e=>e)(`${t?s.icon.cursor:" "}${r} ${e.name}`)},pageSize:n,loop:u});if("done"===l){const e=p.filter(zS);return`${d} ${_} ${s.style.answer(s.style.renderSelectedChoices(e,p))}`}let C="",S="";if("always"===s.helpMode||"auto"===s.helpMode&&v&&(void 0===r||r)){if("string"==typeof r)C=r;else{C=` (Press ${[`${s.style.key("space")} to select`,a.all?`${s.style.key(a.all)} to toggle all`:"",a.invert?`${s.style.key(a.invert)} to invert selection`:"",`and ${s.style.key("enter")} to proceed`].filter(e=>""!==e).join(", ")})`}p.length>n&&("always"===s.helpMode||"auto"===s.helpMode&&c.current)&&(S=`\n${s.style.help("(Use arrow keys to reveal more choices)")}`,c.current=!1)}const O=E?`\n${s.style.description(E)}`:"";let B="";return g&&(B=`\n${s.style.error(g)}`),`${d} ${_}${C}\n${w}${S}${O}${B}${jS.cursorHide}`}),WS=un();const GS={validationFailureMode:"keep"};var VS=LS((e,t)=>{const{waitForUseInput:r=!0,file:{postfix:n=e.postfix??".txt",...u}={},validate:i=()=>!0}=e,o=fS(GS,e.theme),[a,s]=tS("idle"),[c="",l]=tS(e.default),[f,d]=tS(),p=dS({status:a,theme:o});function h(r){r.pause();WS.editAsync(c,(n,u)=>{(async(n,u)=>{if(r.resume(),n)d(n.toString());else{s("loading");const r=await i(u);!0===r?(d(void 0),s("done"),t(u)):("clear"===o.validationFailureMode?l(e.default):l(u),d(r||"You must provide a valid value"),s("idle"))}})(n,u)},{postfix:n,...u})}rS(e=>{r||h(e)},[]),DS((e,t)=>{"idle"===a&&qC(e)&&h(t)});const D=o.style.message(e.message,a);let b="";if("loading"===a)b=o.style.help("Received");else if("idle"===a){const e=o.style.key("enter");b=o.style.help(`Press ${e} to launch your preferred editor.`)}let y="";return f&&(y=o.style.error(f)),[[p,D,b].filter(Boolean).join(" "),y]});function KS(e,t){let r=!1!==t;return/^(y|yes)/i.test(e)?r=!0:/^(n|no)/i.test(e)&&(r=!1),r}function YS(e){return e?"Yes":"No"}var HS=LS((e,t)=>{const{transformer:r=YS}=e,[n,u]=tS("idle"),[i,o]=tS(""),a=fS(e.theme),s=dS({status:n,theme:a});DS((n,a)=>{if(qC(n)){const n=KS(i,e.default);o(r(n)),u("done"),t(n)}else if("tab"===n.name){const t=YS(!KS(i,e.default));a.clearLine(0),a.write(t),o(t)}else o(a.line)});let c=i,l="";"done"===n?c=a.style.answer(i):l=` ${a.style.defaultAnswer(!1===e.default?"y/N":"Y/n")}`;return`${s} ${a.style.message(e.message,n)}${l} ${c}`});const ZS={validationFailureMode:"keep"};var QS=LS((e,t)=>{const{required:r,validate:n=()=>!0,prefill:u="tab"}=e,i=fS(ZS,e.theme),[o,a]=tS("idle"),[s="",c]=tS(e.default),[l,f]=tS(),[d,p]=tS(""),h=dS({status:o,theme:i});DS(async(e,u)=>{if("idle"===o)if(qC(e)){const e=d||s;a("loading");const o=r&&!e?"You must provide a value":await n(e);!0===o?(p(e),a("done"),t(e)):("clear"===i.validationFailureMode?p(""):u.write(d),f(o||"You must provide a valid value"),a("idle"))}else zC(e)&&!d?c(void 0):"tab"!==e.name||d?(p(u.line),f(void 0)):(c(void 0),u.clearLine(0),u.write(s),p(s))}),rS(e=>{"editable"===u&&s&&(e.write(s),p(s))},[]);const D=i.style.message(e.message,o);let b,y=d;"function"==typeof e.transformer?y=e.transformer(d,{isFinal:"done"===o}):"done"===o&&(y=i.style.answer(d)),s&&"done"!==o&&!d&&(b=i.style.defaultAnswer(s));let v="";return l&&(v=i.style.error(l)),[[h,D,b,y].filter(e=>void 0!==e).join(" "),v]});function JS(e,{min:t,max:r,step:n}){return null!=e&&!Number.isNaN(e)&&(e<t||e>r?`Value must be between ${t} and ${r}`:!("any"!==n&&!function(e,t,r){const n=e*Math.pow(10,6),u=t*Math.pow(10,6),i=r*Math.pow(10,6);return(n-(Number.isFinite(r)?i:0))%u===0}(e,n,t))||`Value must be a multiple of ${n}${Number.isFinite(t)?` starting from ${t}`:""}`)}var XS=LS((e,t)=>{const{validate:r=()=>!0,min:n=-1/0,max:u=1/0,step:i=1,required:o=!1}=e,a=fS(e.theme),[s,c]=tS("idle"),[l,f]=tS(""),d=!0===JS(e.default,{min:n,max:u,step:i})?e.default?.toString():void 0,[p="",h]=tS(d),[D,b]=tS(),y=dS({status:s,theme:a});DS(async(e,a)=>{if("idle"===s)if(qC(e)){const e=l||p,s=""===e?void 0:Number(e);c("loading");let d=!0;(o||null!=s)&&(d=JS(s,{min:n,max:u,step:i})),!0===d&&(d=await r(s)),!0===d?(f(String(s??"")),c("done"),t(s)):(a.write(l),b(d||"You must provide a valid numeric value"),c("idle"))}else zC(e)&&!l?h(void 0):"tab"!==e.name||l?(f(a.line),b(void 0)):(h(void 0),a.clearLine(0),a.write(p),f(p))});const v=a.style.message(e.message,s);let m,g=l;"done"===s&&(g=a.style.answer(l)),p&&"done"!==s&&!l&&(m=a.style.defaultAnswer(p));let F="";return D&&(F=a.style.error(D)),[[y,v,m,g].filter(e=>void 0!==e).join(" "),F]});const eO={key:"h",name:"Help, list all options",value:void 0};var tO=LS((e,t)=>{const{default:r="h"}=e,n=pS(()=>function(e){return e.map(e=>{if(RS.isSeparator(e))return e;const t="name"in e?e.name:String(e.value);return{value:"value"in e?e.value:t,name:t,key:e.key.toLowerCase()}})}(e.choices),[e.choices]),[u,i]=tS("idle"),[o,a]=tS(""),[s,c]=tS(e.expanded??!1),[l,f]=tS(),d=fS(e.theme),p=dS({theme:d,status:u});DS((e,u)=>{if(qC(e)){const e=(o||r).toLowerCase();if("h"!==e||s){const r=n.find(t=>!RS.isSeparator(t)&&t.key===e);r?(i("done"),a(e),t(r.value)):f(""===o?"Please input a value":`"${nS.red(o)}" isn't an available option`)}else c(!0)}else a(u.line),f(void 0)});const h=d.style.message(e.message,u);if("done"===u){const e=n.find(e=>!RS.isSeparator(e)&&e.key===o.toLowerCase());return`${p} ${h} ${d.style.answer(e.name)}`}const D=s?n:[...n,eO];let b="",y=D.map(e=>RS.isSeparator(e)?"":e.key===r?e.key.toUpperCase():e.key).join("");y=` ${d.style.defaultAnswer(y)}`,s&&(y="",b=D.map(e=>{if(RS.isSeparator(e))return` ${e.separator}`;const t=` ${e.key}) ${e.name}`;return e.key===o.toLowerCase()?d.style.highlight(t):t}).join("\n"));let v="";const m=n.find(e=>!RS.isSeparator(e)&&e.key===o.toLowerCase());m&&(v=`${nS.cyan(">>")} ${m.name}`);let g="";return l&&(g=d.style.error(l)),[`${p} ${h}${y} ${o}`,[b,v,g].filter(Boolean).join("\n")]});const rO=/\d+/;function nO(e){return null!=e&&!RS.isSeparator(e)}function uO(e,t){let r;const n=t.filter(nO);if(rO.test(e)){r=n[Number.parseInt(e,10)-1]}else r=n.find(t=>t.key===e);return r?[r,t.indexOf(r)]:[void 0,void 0]}var iO=LS((e,t)=>{const{loop:r=!0}=e,n=pS(()=>function(e){let t=0;return e.map(e=>{if(RS.isSeparator(e))return e;if(t+=1,"string"==typeof e)return{value:e,name:e,short:e,key:String(t)};const r=e.name??String(e.value);return{value:e.value,name:r,short:e.short??r,key:e.key??String(t)}})}(e.choices),[e.choices]),[u,i]=tS("idle"),[o,a]=tS(""),[s,c]=tS(),l=fS(e.theme),f=dS({status:u,theme:l}),d=pS(()=>{const e=n.findIndex(nO),t=n.findLastIndex(nO);if(-1===e)throw new YC("[select prompt] No selectable choices. All choices are disabled.");return{first:e,last:t}},[n]);DS((e,u)=>{if(qC(e)){const[e]=uO(o,n);nO(e)?(a(e.short),i("done"),t(e.value)):c(""===o?"Please input a value":`"${nS.red(o)}" isn't an available option`)}else if("up"===e.name||"down"===e.name){u.clearLine(0);const[t,i]=uO(o,n);if(t){if(r||"up"===e.name&&i!==d.first||"down"===e.name&&i!==d.last){const t="up"===e.name?-1:1;let r=i;do{r=(r+t+n.length)%n.length}while(!nO(n[r]));a(n[r].key)}}else{const t="down"===e.name?n.find(nO):n.findLast(nO);a(t.key)}}else a(u.line),c(void 0)});const p=l.style.message(e.message,u);if("done"===u)return`${f} ${p} ${l.style.answer(o)}`;const h=n.map(e=>{if(RS.isSeparator(e))return` ${e.separator}`;const t=` ${e.key}) ${e.name}`;return e.key===o.toLowerCase()?l.style.highlight(t):t}).join("\n");let D="";return s&&(D=l.style.error(s)),[`${f} ${p} ${o}`,[h,D].filter(Boolean).join("\n")]}),oO=LS((e,t)=>{const{validate:r=()=>!0}=e,n=fS(e.theme),[u,i]=tS("idle"),[o,a]=tS(),[s,c]=tS(""),l=dS({status:u,theme:n});DS(async(e,n)=>{if("idle"===u)if(qC(e)){const e=s;i("loading");const u=await r(e);!0===u?(c(e),i("done"),t(e)):(n.write(s),a(u||"You must provide a valid value"),i("idle"))}else c(n.line),a(void 0)});const f=n.style.message(e.message,u);let d,p="";if(e.mask){p=("string"==typeof e.mask?e.mask:"*").repeat(s.length)}else"done"!==u&&(d=`${n.style.help("[input is masked]")}${jS.cursorHide}`);"done"===u&&(p=n.style.answer(p));let h="";return o&&(h=n.style.error(o)),[[l,f,e.mask?p:d].join(" "),h]});const aO={icon:{cursor:aS.pointer},style:{disabled:e=>nS.dim(`- ${e}`),searchTerm:e=>nS.cyan(e),description:e=>nS.cyan(e)},helpMode:"auto"};function sO(e){return!RS.isSeparator(e)&&!e.disabled}var cO=LS((e,t)=>{const{pageSize:r=7,validate:n=()=>!0}=e,u=fS(aO,e.theme),i=hS(!0),[o,a]=tS("loading"),[s,c]=tS(""),[l,f]=tS([]),[d,p]=tS(),h=dS({status:o,theme:u}),D=pS(()=>({first:l.findIndex(sO),last:l.findLastIndex(sO)}),[l]),[b=D.first,y]=tS();rS(()=>{const t=new AbortController;a("loading"),p(void 0);return(async()=>{try{const r=await e.source(s||void 0,{signal:t.signal});t.signal.aborted||(y(void 0),p(void 0),f(r.map(e=>{if(RS.isSeparator(e))return e;if("string"==typeof e)return{value:e,name:e,short:e,disabled:!1};const t=e.name??String(e.value),r={value:e.value,name:t,short:e.short??t,disabled:e.disabled??!1};return e.description&&(r.description=e.description),r})),a("idle"))}catch(e){!t.signal.aborted&&e instanceof Error&&p(e.message)}})(),()=>{t.abort()}},[s]);const v=l[b];DS(async(e,r)=>{if(qC(e))if(v){a("loading");const e=await n(v.value);a("idle"),!0===e?(a("done"),t(v.value)):v.name===s?p(e||"You must provide a valid value"):(r.write(v.name),c(v.name))}else r.write(s);else if("tab"===e.name&&v)r.clearLine(0),r.write(v.name),c(v.name);else if("loading"===o||"up"!==e.name&&"down"!==e.name)c(r.line);else if(r.clearLine(0),"up"===e.name&&b!==D.first||"down"===e.name&&b!==D.last){const t="up"===e.name?-1:1;let r=b;do{r=(r+t+l.length)%l.length}while(!sO(l[r]));y(r)}});const m=u.style.message(e.message,o);b>0&&(i.current=!1);let g="";l.length>1&&("always"===u.helpMode||"auto"===u.helpMode&&i.current)&&(g=l.length>r?`\n${u.style.help("(Use arrow keys to reveal more choices)")}`:`\n${u.style.help("(Use arrow keys)")}`);const F=gS({items:l,active:b,renderItem({item:e,isActive:t}){if(RS.isSeparator(e))return` ${e.separator}`;if(e.disabled){const t="string"==typeof e.disabled?e.disabled:"(disabled)";return u.style.disabled(`${e.name} ${t}`)}return(t?u.style.highlight:e=>e)(`${t?u.icon.cursor:" "} ${e.name}`)},pageSize:r,loop:!1});let _,E;if(d?_=u.style.error(d):0===l.length&&""!==s&&"idle"===o&&(_=u.style.error("No results found")),"done"===o&&v){const e=v.short;return`${h} ${m} ${u.style.answer(e)}`}E=u.style.searchTerm(s);const w=v?.description?`\n${u.style.description(v.description)}`:"";return[[h,m,E].filter(Boolean).join(" "),`${_??F}${g}${w}`]});const lO={icon:{cursor:aS.pointer},style:{disabled:e=>nS.dim(`- ${e}`),description:e=>nS.cyan(e)},helpMode:"auto",indexMode:"hidden"};function fO(e){return!RS.isSeparator(e)&&!e.disabled}var dO=LS((e,t)=>{const{loop:r=!0,pageSize:n=7}=e,u=hS(!0),i=fS(lO,e.theme),[o,a]=tS("idle"),s=dS({status:o,theme:i}),c=hS(),l=pS(()=>e.choices.map(e=>{if(RS.isSeparator(e))return e;if("string"==typeof e)return{value:e,name:e,short:e,disabled:!1};const t=e.name??String(e.value),r={value:e.value,name:t,short:e.short??t,disabled:e.disabled??!1};return e.description&&(r.description=e.description),r}),[e.choices]),f=pS(()=>{const e=l.findIndex(fO),t=l.findLastIndex(fO);if(-1===e)throw new YC("[select prompt] No selectable choices. All choices are disabled.");return{first:e,last:t}},[l]),d=pS(()=>"default"in e?l.findIndex(t=>fO(t)&&t.value===e.default):-1,[e.default,l]),[p,h]=tS(-1===d?f.first:d),D=l[p];DS((e,n)=>{if(clearTimeout(c.current),qC(e))a("done"),t(D.value);else if(NC(e)||UC(e)){if(n.clearLine(0),r||NC(e)&&p!==f.first||UC(e)&&p!==f.last){const t=NC(e)?-1:1;let r=p;do{r=(r+t+l.length)%l.length}while(!fO(l[r]));h(r)}}else if($C(e)&&!Number.isNaN(Number(n.line))){const e=Number(n.line)-1,t=l[e];null!=t&&fO(t)&&h(e),c.current=setTimeout(()=>{n.clearLine(0)},700)}else if(zC(e))n.clearLine(0);else{const e=n.line.toLowerCase(),t=l.findIndex(t=>!(RS.isSeparator(t)||!fO(t))&&t.name.toLowerCase().startsWith(e));-1!==t&&h(t),c.current=setTimeout(()=>{n.clearLine(0)},700)}}),rS(()=>()=>{clearTimeout(c.current)},[]);const b=i.style.message(e.message,o);let y="",v="";("always"===i.helpMode||"auto"===i.helpMode&&u.current)&&(u.current=!1,l.length>n?v=`\n${i.style.help(`(${e.instructions?.pager??"Use arrow keys to reveal more choices"})`)}`:y=i.style.help(`(${e.instructions?.navigation??"Use arrow keys"})`));const m=gS({items:l,active:p,renderItem({item:e,isActive:t,index:r}){if(RS.isSeparator(e))return` ${e.separator}`;const n="number"===i.indexMode?`${r+1}. `:"";if(e.disabled){const t="string"==typeof e.disabled?e.disabled:"(disabled)";return i.style.disabled(`${n}${e.name} ${t}`)}return(t?i.style.highlight:e=>e)(`${t?i.icon.cursor:" "} ${n}${e.name}`)},pageSize:n,loop:r});if("done"===o)return`${s} ${b} ${i.style.answer(D.short)}`;const g=D.description?`\n${i.style.description(D.description)}`:"";return`${[s,b,y].filter(Boolean).join(" ")}\n${m}${v}${g}${jS.cursorHide}`}),pO=function(e,t){return pO=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},pO(e,t)};function hO(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}pO(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function DO(e,t,r,n){return new(r||(r=Promise))(function(u,i){function o(e){try{s(n.next(e))}catch(e){i(e)}}function a(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?u(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,a)}s((n=n.apply(e,t||[])).next())})}function bO(e,t){var r,n,u,i={label:0,sent:function(){if(1&u[0])throw u[1];return u[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(s){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(i=0)),i;)try{if(r=1,n&&(u=2&a[0]?n.return:a[0]?n.throw||((u=n.return)&&u.call(n),0):n.next)&&!(u=u.call(n,a[1])).done)return u;switch(n=0,u&&(a=[2&a[0],u.value]),a[0]){case 0:case 1:u=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(u=i.trys,(u=u.length>0&&u[u.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!u||a[1]>u[0]&&a[1]<u[3])){i.label=a[1];break}if(6===a[0]&&i.label<u[1]){i.label=u[1],u=a;break}if(u&&i.label<u[2]){i.label=u[2],i.ops.push(a);break}u[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],n=0}finally{r=u=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}function yO(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function vO(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,u,i=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)o.push(n.value)}catch(e){u={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(u)throw u.error}}return o}function mO(e,t,r){if(r||2===arguments.length)for(var n,u=0,i=t.length;u<i;u++)!n&&u in t||(n||(n=Array.prototype.slice.call(t,0,u)),n[u]=t[u]);return e.concat(n||Array.prototype.slice.call(t))}function gO(e){return this instanceof gO?(this.v=e,this):new gO(e)}function FO(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,u=r.apply(e,t||[]),i=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",function(e){return function(t){return Promise.resolve(t).then(e,c)}}),n[Symbol.asyncIterator]=function(){return this},n;function o(e,t){u[e]&&(n[e]=function(t){return new Promise(function(r,n){i.push([e,t,r,n])>1||a(e,t)})},t&&(n[e]=t(n[e])))}function a(e,t){try{(r=u[e](t)).value instanceof gO?Promise.resolve(r.value.v).then(s,c):l(i[0][2],r)}catch(e){l(i[0][3],e)}var r}function s(e){a("next",e)}function c(e){a("throw",e)}function l(e,t){e(t),i.shift(),i.length&&a(i[0][0],i[0][1])}}function _O(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=yO(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise(function(n,u){(function(e,t,r,n){Promise.resolve(n).then(function(t){e({value:t,done:r})},t)})(n,u,(t=e[r](t)).done,t.value)})}}}function EO(e){return"function"==typeof e}function wO(e){var t=e(function(e){Error.call(e),e.stack=(new Error).stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}"function"==typeof SuppressedError&&SuppressedError;var CO=wO(function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map(function(e,t){return t+1+") "+e.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}});function SO(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var OO=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var e,t,r,n,u;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var o=yO(i),a=o.next();!a.done;a=o.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}else i.remove(this);var s=this.initialTeardown;if(EO(s))try{s()}catch(e){u=e instanceof CO?e.errors:[e]}var c=this._finalizers;if(c){this._finalizers=null;try{for(var l=yO(c),f=l.next();!f.done;f=l.next()){var d=f.value;try{xO(d)}catch(e){u=null!=u?u:[],e instanceof CO?u=mO(mO([],vO(u)),vO(e.errors)):u.push(e)}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}}if(u)throw new CO(u)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)xO(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&SO(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&SO(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}();function BO(e){return e instanceof OO||e&&"closed"in e&&EO(e.remove)&&EO(e.add)&&EO(e.unsubscribe)}function xO(e){EO(e)?e():e.unsubscribe()}OO.EMPTY;var AO={Promise:void 0},PO=function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,mO([e,t],vO(r)))};function jO(e){PO(function(){throw e})}function kO(){}var TO=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,BO(t)&&t.add(r)):r.destination=RO,r}return hO(t,e),t.create=function(e,t,r){return new IO(e,t,r)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(OO),MO=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){LO(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){LO(e)}else LO(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){LO(e)}},e}(),IO=function(e){function t(t,r,n){var u,i=e.call(this)||this;return u=EO(t)||!t?{next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:t,i.destination=new MO(u),i}return hO(t,e),t}(TO);function LO(e){jO(e)}var RO={closed:!0,next:kO,error:function(e){throw e},complete:kO},NO="function"==typeof Symbol&&Symbol.observable||"@@observable";function UO(e){return e}var zO=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var n,u=this,i=(n=e)&&n instanceof TO||function(e){return e&&EO(e.next)&&EO(e.error)&&EO(e.complete)}(n)&&BO(n)?e:new IO(e,t,r);return function(){var e=u,t=e.operator,r=e.source;i.add(t?t.call(i,r):r?u._subscribe(i):u._trySubscribe(i))}(),i},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=$O(t))(function(t,n){var u=new IO({next:function(t){try{e(t)}catch(e){n(e),u.unsubscribe()}},error:n,complete:t});r.subscribe(u)})},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[NO]=function(){return this},e.prototype.pipe=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return(0===(e=t).length?UO:1===e.length?e[0]:function(t){return e.reduce(function(e,t){return t(e)},t)})(this)},e.prototype.toPromise=function(e){var t=this;return new(e=$O(e))(function(e,r){var n;t.subscribe(function(e){return n=e},function(e){return r(e)},function(){return e(n)})})},e.create=function(t){return new e(t)},e}();function $O(e){var t;return null!==(t=null!=e?e:AO.Promise)&&void 0!==t?t:Promise}function qO(e){return function(t){if(function(e){return EO(null==e?void 0:e.lift)}(t))return t.lift(function(t){try{return e(t,this)}catch(e){this.error(e)}});throw new TypeError("Unable to lift unknown Observable type")}}function WO(e,t,r,n,u){return new GO(e,t,r,n,u)}var GO=function(e){function t(t,r,n,u,i,o){var a=e.call(this,t)||this;return a.onFinalize=i,a.shouldUnsubscribe=o,a._next=r?function(e){try{r(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=u?function(e){try{u(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=n?function(){try{n()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return hO(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(TO),VO=new zO(function(e){return e.complete()});function KO(e){return(t=(r=e)[r.length-1])&&EO(t.schedule)?e.pop():void 0;var t,r}var YO=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};function HO(e){return EO(null==e?void 0:e.then)}function ZO(e){return EO(e[NO])}function QO(e){return Symbol.asyncIterator&&EO(null==e?void 0:e[Symbol.asyncIterator])}function JO(e){return new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}var XO="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function eB(e){return EO(null==e?void 0:e[XO])}function tB(e){return FO(this,arguments,function(){var t,r,n;return bO(this,function(u){switch(u.label){case 0:t=e.getReader(),u.label=1;case 1:u.trys.push([1,,9,10]),u.label=2;case 2:return[4,gO(t.read())];case 3:return r=u.sent(),n=r.value,r.done?[4,gO(void 0)]:[3,5];case 4:return[2,u.sent()];case 5:return[4,gO(n)];case 6:return[4,u.sent()];case 7:return u.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function rB(e){return EO(null==e?void 0:e.getReader)}function nB(e){if(e instanceof zO)return e;if(null!=e){if(ZO(e))return u=e,new zO(function(e){var t=u[NO]();if(EO(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")});if(YO(e))return n=e,new zO(function(e){for(var t=0;t<n.length&&!e.closed;t++)e.next(n[t]);e.complete()});if(HO(e))return r=e,new zO(function(e){r.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,jO)});if(QO(e))return uB(e);if(eB(e))return t=e,new zO(function(e){var r,n;try{for(var u=yO(t),i=u.next();!i.done;i=u.next()){var o=i.value;if(e.next(o),e.closed)return}}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=u.return)&&n.call(u)}finally{if(r)throw r.error}}e.complete()});if(rB(e))return uB(tB(e))}var t,r,n,u;throw JO(e)}function uB(e){return new zO(function(t){(function(e,t){var r,n,u,i;return DO(this,void 0,void 0,function(){var o,a;return bO(this,function(s){switch(s.label){case 0:s.trys.push([0,5,6,11]),r=_O(e),s.label=1;case 1:return[4,r.next()];case 2:if((n=s.sent()).done)return[3,4];if(o=n.value,t.next(o),t.closed)return[2];s.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=s.sent(),u={error:a},[3,11];case 6:return s.trys.push([6,,9,10]),n&&!n.done&&(i=r.return)?[4,i.call(r)]:[3,8];case 7:s.sent(),s.label=8;case 8:return[3,10];case 9:if(u)throw u.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})})(e,t).catch(function(e){return t.error(e)})})}function iB(e,t,r,n,u){void 0===n&&(n=0),void 0===u&&(u=!1);var i=t.schedule(function(){r(),u?e.add(this.schedule(null,n)):this.unsubscribe()},n);if(e.add(i),!u)return i}function oB(e,t){return void 0===t&&(t=0),qO(function(r,n){r.subscribe(WO(n,function(r){return iB(n,e,function(){return n.next(r)},t)},function(){return iB(n,e,function(){return n.complete()},t)},function(r){return iB(n,e,function(){return n.error(r)},t)}))})}function aB(e,t){return void 0===t&&(t=0),qO(function(r,n){n.add(e.schedule(function(){return r.subscribe(n)},t))})}function sB(e,t){if(!e)throw new Error("Iterable cannot be null");return new zO(function(r){iB(r,t,function(){var n=e[Symbol.asyncIterator]();iB(r,t,function(){n.next().then(function(e){e.done?r.complete():r.next(e.value)})},0,!0)})})}function cB(e,t){if(null!=e){if(ZO(e))return function(e,t){return nB(e).pipe(aB(t),oB(t))}(e,t);if(YO(e))return function(e,t){return new zO(function(r){var n=0;return t.schedule(function(){n===e.length?r.complete():(r.next(e[n++]),r.closed||this.schedule())})})}(e,t);if(HO(e))return function(e,t){return nB(e).pipe(aB(t),oB(t))}(e,t);if(QO(e))return sB(e,t);if(eB(e))return function(e,t){return new zO(function(r){var n;return iB(r,t,function(){n=e[XO](),iB(r,t,function(){var e,t,u;try{t=(e=n.next()).value,u=e.done}catch(e){return void r.error(e)}u?r.complete():r.next(t)},0,!0)}),function(){return EO(null==n?void 0:n.return)&&n.return()}})}(e,t);if(rB(e))return function(e,t){return sB(tB(e),t)}(e,t)}throw JO(e)}function lB(e,t){return t?cB(e,t):nB(e)}var fB=wO(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function dB(e,t,r){return void 0===r&&(r=1/0),EO(t)?dB(function(r,n){return function(e,t){return qO(function(r,n){var u=0;r.subscribe(WO(n,function(r){n.next(e.call(t,r,u++))}))})}(function(e,u){return t(r,e,n,u)})(nB(e(r,n)))},r):("number"==typeof t&&(r=t),qO(function(t,n){return function(e,t,r,n,u,i,o){var a=[],s=0,c=0,l=!1,f=function(){!l||a.length||s||t.complete()},d=function(e){s++;var u=!1;nB(r(e,c++)).subscribe(WO(t,function(e){t.next(e)},function(){u=!0},void 0,function(){if(u)try{s--;for(var e=function(){var e=a.shift();o||d(e)};a.length&&s<n;)e();f()}catch(e){t.error(e)}}))};return e.subscribe(WO(t,function(e){return s<n?d(e):a.push(e)},function(){l=!0,f()})),function(){}}(t,n,e,r)}))}function pB(e,t){return qO(function(e,t,r){return function(n,u){var i=r,o=t,a=0;n.subscribe(WO(u,function(t){var r=a++;o=i?e(o,t,r):(i=!0,t)},function(){i&&u.next(o),u.complete()}))}}(e,t,arguments.length>=2))}function hB(e,t){return EO(t)?dB(e,t,1):dB(e,1)}var DB=T(ab());const bB=(e,t="",r)=>{let n=e;t.split(".").forEach((e,t,u)=>{"__proto__"!==e&&"constructor"!==e&&(t===u.length-1?n[e]=r:e in n&&"object"==typeof n[e]||(n[e]={}),n=n[e])})},yB=(e,t="",r)=>{const n=r=>String.prototype.split.call(t,r).filter(Boolean).reduce((e,t)=>null==e?e:e[t],e),u=n(/[,[\]]+?/)||n(/[,.[\]]+?/);return void 0===u||u===e?r:u};async function vB(e,t,r){const n=e[t];return"function"==typeof n?DB(n)(r):n}class mB extends Error{name="TTYError";isTtyError=!0}class gB{prompts;answers={};process=VO;abortController=new AbortController;opt;constructor(e,t={}){this.opt=t,this.prompts=e}async run(e,t){let r;var n,u;return this.abortController=new AbortController,this.answers="object"==typeof t?{...t}:{},!function(e){return Array.isArray(e)}(e)?r=(n=e)&&(n instanceof zO||EO(n.lift)&&EO(n.subscribe))?e:function(e){return Object.values(e).every(e=>"object"==typeof e&&!Array.isArray(e)&&null!=e)}(e)?lB(Object.entries(e).map(([e,t])=>Object.assign({},t,{name:e}))):lB([e]):r=lB(e),this.process=r.pipe(hB(e=>function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return lB(e,KO(e))}(e).pipe(hB(e=>{return lB(this.shouldRun(e).then(t=>{if(t)return e})).pipe((t=e=>null!=e,qO(function(e,n){var u=0;e.subscribe(WO(n,function(e){return t.call(r,e,u++)&&n.next(e)}))})));var t,r}),hB(e=>{return t=()=>lB(this.fetchAnswer(e)),new zO(function(e){nB(t()).subscribe(e)});var t})))),(u=this.process.pipe(pB((e,t)=>(bB(e,t.name,t.answer),e),this.answers)),new Promise(function(e,t){var r,n=!1;u.subscribe({next:function(e){r=e,n=!0},error:t,complete:function(){n?e(r):t(new fB)}})})).then(()=>this.answers).finally(()=>this.close())}prepareQuestion=async e=>{const[t,r,n]=await Promise.all([vB(e,"message",this.answers),vB(e,"default",this.answers),vB(e,"choices",this.answers)]);let u;return Array.isArray(n)&&(u=n.map(e=>{const t="object"!=typeof e||null==e?{name:e,value:e}:{...e,value:"value"in e?e.value:"name"in e?e.name:void 0};return"value"in t&&Array.isArray(r)?{checked:r.includes(t.value),...t}:t})),Object.assign({},e,{message:t,default:r,choices:u,type:e.type in this.prompts?e.type:"input"})};fetchAnswer=async e=>{const t=await this.prepareQuestion(e),r=this.prompts[t.type];if(null==r)throw new Error(`Prompt for type ${t.type} not found`);let n;const u=function(e){return Boolean(e.prototype&&"run"in e.prototype&&"function"==typeof e.prototype.run)}(r)?(e,t)=>new Promise((u,i)=>{const{signal:a}=t;if(a.aborted)return void i(new WC({cause:a.reason}));const s=o.createInterface(function(e){e.skipTTYChecks=void 0===e.skipTTYChecks||e.skipTTYChecks;const t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY)throw new mB("Prompts can not be meaningfully rendered in non-TTY environments");const r=new FS;r.pipe(e.output||process.stdout);const n=r;return{terminal:!0,...e,input:t,output:n}}(t)),c=()=>{this.close(),process.kill(process.pid,"SIGINT"),console.log("")};process.on("exit",c),s.on("SIGINT",c);const l=new r(e,s,this.answers),f=()=>{process.removeListener("exit",c),s.removeListener("SIGINT",c),s.setPrompt(""),s.output.unmute(),s.output.write(jS.cursorShow),s.output.end(),s.close(),n?.()},d=()=>{i(new WC({cause:a.reason})),f()};a.addEventListener("abort",d),n=()=>{a.removeEventListener("abort",d),n=void 0},l.run().then(u,i).finally(f)}):r;let i;const{signal:a}=this.opt;if(a?.aborted)this.abortController.abort(a.reason);else if(a){const e=()=>this.abortController.abort(a.reason);a.addEventListener("abort",e),i=()=>{a.removeEventListener("abort",e)}}const{filter:s=e=>e}=t,{signal:c}=this.abortController;return u(t,{...this.opt,signal:c}).then(e=>({name:t.name,answer:s(e,this.answers)})).finally(()=>{n?.(),i?.()})};close=()=>{this.abortController.abort()};shouldRun=async e=>{if(!0!==e.askAnswered&&void 0!==yB(this.answers,e.name))return!1;const{when:t}=e;if("function"==typeof t){const e=await DB(t)(this.answers);return Boolean(e)}return!1!==t}}const FB={input:QS,select:dO,list:dO,number:XS,confirm:HS,rawlist:iO,expand:tO,checkbox:qS,password:oO,editor:VS,search:cO};function _B(e){function t(r,n){const u=new gB(t.prompts,e),i=u.run(r,n);return Object.assign(i,{ui:u})}return t.prompts={...FB},t.registerPrompt=function(e,r){return t.prompts[e]=r,this},t.restoreDefaultPrompts=function(){t.prompts={...FB}},t}const EB=_B();const wB={prompt:EB,ui:{Prompt:gB},createPromptModule:_B,registerPrompt:function(e,t){EB.registerPrompt(e,t)},restoreDefaultPrompts:function(){EB.restoreDefaultPrompts()},Separator:RS},CB=h.join(g.homedir(),".ttmg-cli"),SB=h.join(CB,"config.json");function OB(e){let t=[];if(c.existsSync(SB))try{const e=JSON.parse(c.readFileSync(SB,"utf-8"));t=Array.isArray(e.clientKeys)?e.clientKeys:[]}catch(e){t=[]}t.includes(e)||(t.push(e),c.existsSync(CB)||c.mkdirSync(CB,{recursive:!0}),c.writeFileSync(SB,JSON.stringify({clientKeys:t},null,2),{encoding:"utf-8"}))}async function BB(){const e=function(){if(!c.existsSync(SB))return[];try{const e=JSON.parse(c.readFileSync(SB,"utf-8"));return Array.isArray(e.clientKeys)?e.clientKeys:[]}catch(e){return[]}}();let t;if(e.length>0){const{selectedKey:r}=await wB.prompt([{type:"list",name:"selectedKey",message:"Please select your game id(client_key):",choices:[...e,new wB.Separator,"Add new game id"]}]);if("Add new game id"===r){const{newKey:e}=await wB.prompt([{type:"input",name:"newKey",message:"Please input your new game id(client_key):",validate:e=>!!e||"Please input game id"}]);OB(e),t=e}else t=r}else{const{newKey:e}=await wB.prompt([{type:"input",name:"newKey",message:"Please input your game id(client_key):",validate:e=>!!e||"Please input game id"}]);OB(e),t=e}return t}const xB=y();function AB(){xB.use(y.json()),xB.post("/game/env",(e,r)=>{const n=e.body,{host:u,port:i}=n;r.json({code:0,msg:"ok"});const o=`http://${u}:${i}`;!function(e){const{exec:t}=require("child_process");t(`open ${e}`)}(o),console.log(t.bold.yellow(`Game debug is ready! Visit ${o} in your browser.`))}),xB.listen(9527,()=>{})}async function PB(){const e=await BB(),r=process.cwd(),n=function(){const e=g.homedir(),t=["Desktop","桌面"];for(const r of t){const t=h.join(e,r);if(c.existsSync(t))return t}return h.join(e,"Desktop")}();if(!n)return void console.log(t.redBright("Desktop path not found"));const u=h.join(n,"__TTMG_DEV_TEMP__",e);c.existsSync(u)?c.rmSync(u,{recursive:!0,force:!0}):c.mkdirSync(u,{recursive:!0});const i=await A.buildPkgs({entry:r,output:u,enableDev:!0,enableLog:!1,rules:{mainPackageSizeLimit:31457280,projectSizeLimit:31457280}});if(!(null==i?void 0:i.isSuccess))return console.log(t.redBright("Build game package failed, Please check the error message below:")),void console.log(t.redBright(null==i?void 0:i.errorMsg));console.log(t.cyan("\n==============================")),console.log(t.greenBright("✅ Game package built successfully!")),console.log(t.cyan("==============================\n")),console.log(t.yellow("Next steps:")),console.log(` 1. ${t.blue("Scan the QR code to start the client devServer.")}`),console.log(` 2. ${t.blue("Upload the dev package from:")} ${t.bold(u)}`),console.log(` 3. ${t.blue("Debug your game in the browser.")}\n`),AB();const o=RC(e);x.generate(o,{small:!0},e=>{console.log(function(e){const t=process.stdout.columns||80,r=e.split("\n"),n=r.reduce((e,t)=>Math.max(e,t.length),0),u=Math.floor((t-n)/3),i=" ".repeat(u>0?u:0);return r.map(e=>i+e).join("\n")}(e))})}const jB=new e.Command;jB.name("ttmg").description("TikTok Mini Game Command Line Tool").version("0.0.1"),jB.command("init").option("--h5","H5 Mini Game").option("--native","Native Mini Game").description("Initialize project").action(e=>{e.h5?Ob():e.native?console.log("Native Mini Game initialize"):console.log(t.red.bold("Please run ttmg init --h5 or ttmg init --native"))}),jB.command("dev").description("Open browser dev environment").option("--h5","H5 Mini Game").option("--native","Native Mini Game").action(e=>{e.h5?Nb():e.native?PB():console.log(t.red.bold("Please run ttmg dev --h5 or ttmg dev --native"))}),jB.command("build").option("--h5","H5 Mini Game").option("--native","Native Mini Game").description("Bundle project").action(async e=>{e.h5?LC():e.native?console.log("Native Mini Game bundle"):console.log(t.red.bold("Please run ttmg build --h5 or ttmg build --native"))}),jB.parse(process.argv);
|
|
57
|
+
*/()),EC=r}function MC(){if(SC)return CC;SC=1;const e=t,r=c,n=h,{MINIS_MANIFEST_FILE_NAME:u}=_b();function i(e,t){let r=t.find(t=>"folder"===t.type&&t.name===e[0]);return r||(r={type:"folder",name:e[0],children:[]},t.push(r)),e.length>1?i(e.slice(1),r.children):r}function o(e,t=e){const u={};return r.readdirSync(e).forEach(i=>{const a=n.join(e,i);if(r.statSync(a).isDirectory()){const e=o(a,t);Object.assign(u,e)}else if(""!==n.extname(i)&&i){const e="/"+n.relative(t,a).replace(/\\/g,"/");u[a]=e}}),u}return CC={buildMinisManifest:async function(){try{const e=n.join(process.cwd()),t=[],a=o(e);Object.keys(a).filter(e=>!e.endsWith(".map")).forEach(e=>{const r=a[e].split("/").filter(Boolean),n=r.pop()||"";if(0===r.length)t.push({type:"file",name:n});else{i(r,t).children.push({type:"file",name:n})}}),r.writeFileSync(n.join(e,u),JSON.stringify({name:u,resource_list:t},null,2))}catch(t){console.error(e.red(`Error during debug process: ${t.message}`)),t instanceof Error&&t.stack&&console.error(e.red(`Stack trace: ${t.stack}`)),process.exit(1)}}},CC}var IC=function(){if(BC)return OC;BC=1;const e=c,r=g,n=h,u=cb(),i=t,o=TC(),a=u.createPromptModule(),{buildMinisManifest:s}=MC();return OC=async function(){try{const{zipName:t}=await a({type:"input",name:"zipName",default:"game",message:"Please input zip name"}),u=Date.now();console.log(i.bold.blue("start build your game, it will take a few minutes..."));e.readdirSync(process.cwd()).forEach(t=>{t.endsWith(".zip")&&e.unlinkSync(n.join(process.cwd(),t))}),await s();const c=o("zip",{zlib:{level:9}});c.on("error",function(e){throw e});const l=function(){const t=r.homedir(),u=["Desktop","桌面"];for(const r of u){const u=n.join(t,r);if(e.existsSync(u))return u}return n.join(t,"Desktop")}(),f=n.join(l,`${t}.zip`);return await c.pipe(e.createWriteStream(f)),await c.directory(n.resolve(process.cwd()),!1),await c.finalize(),console.log(i.yellow.bold(`build ${t}.zip success, you can find it in desktop, use time ${Date.now()-u} ms`)),new Promise((e,t)=>{c.on("end",e),c.on("error",t)})}catch(e){console.log(i.red(`auto build ${zipNameInput}.zip failed: ${e.message}, you should zip it manually`))}},OC}(),LC=T(IC);function RC(e){return`https://www.tiktok.com/ttmg/dev/${e}?host=${function(){const e=g.networkInterfaces();for(const t in e){const r=e[t];if(r)for(const e of r)if("IPv4"===e.family&&!e.internal)return e.address}}()}&port=9527`}const NC=e=>"up"===e.name||"k"===e.name||e.ctrl&&"p"===e.name,UC=e=>"down"===e.name||"j"===e.name||e.ctrl&&"n"===e.name,zC=e=>"backspace"===e.name,$C=e=>"1234567890".includes(e.name),qC=e=>"enter"===e.name||"return"===e.name;class WC extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(e){super(),this.cause=e?.cause}}class GC extends Error{name="CancelPromptError";message="Prompt was canceled"}class VC extends Error{name="ExitPromptError"}class KC extends Error{name="HookError"}class YC extends Error{name="ValidationError"}const HC=new r.AsyncLocalStorage;function ZC(){const e=HC.getStore();if(!e)throw new KC("[Inquirer] Hook functions can only be called from within a prompt");return e}function QC(){return ZC().rl}function JC(e){return r.AsyncResource.bind((...t)=>{const r=ZC();let n=!1;const u=r.handleChange;r.handleChange=()=>{n=!0};const i=e(...t);return n&&u(),r.handleChange=u,i})}function XC(e){const t=ZC(),{index:r}=t,n=e({get:()=>t.hooks[r],set(e){t.hooks[r]=e},initialized:r in t.hooks});return t.index++,n}const eS={queue(e){const t=ZC(),{index:r}=t;t.hooksEffect.push(()=>{t.hooksCleanup[r]?.();const n=e(QC());if(null!=n&&"function"!=typeof n)throw new YC("useEffect return value must be a cleanup function or nothing.");t.hooksCleanup[r]=n})},run(){const e=ZC();JC(()=>{e.hooksEffect.forEach(e=>{e()}),e.hooksEffect.length=0})()},clearAll(){const e=ZC();e.hooksCleanup.forEach(e=>{e?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function tS(e){return XC(t=>{const n=r.AsyncResource.bind(function(e){t.get()!==e&&(t.set(e),ZC().handleChange())});if(t.initialized)return[t.get(),n];const u="function"==typeof e?e():e;return t.set(u),[u,n]})}function rS(e,t){XC(r=>{const n=r.get();(!Array.isArray(n)||t.some((e,t)=>!Object.is(e,n[t])))&&eS.queue(e),r.set(t)})}var nS=T(ie());const uS={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"█",squareDarkShade:"▓",squareMediumShade:"▒",squareLightShade:"░",squareTop:"▀",squareBottom:"▄",squareLeft:"▌",squareRight:"▐",squareCenter:"■",bullet:"●",dot:"․",ellipsis:"…",pointerSmall:"›",triangleUp:"▲",triangleUpSmall:"▴",triangleDown:"▼",triangleDownSmall:"▾",triangleLeftSmall:"◂",triangleRightSmall:"▸",home:"⌂",heart:"♥",musicNote:"♪",musicNoteBeamed:"♫",arrowUp:"↑",arrowDown:"↓",arrowLeft:"←",arrowRight:"→",arrowLeftRight:"↔",arrowUpDown:"↕",almostEqual:"≈",notEqual:"≠",lessOrEqual:"≤",greaterOrEqual:"≥",identical:"≡",infinity:"∞",subscriptZero:"₀",subscriptOne:"₁",subscriptTwo:"₂",subscriptThree:"₃",subscriptFour:"₄",subscriptFive:"₅",subscriptSix:"₆",subscriptSeven:"₇",subscriptEight:"₈",subscriptNine:"₉",oneHalf:"½",oneThird:"⅓",oneQuarter:"¼",oneFifth:"⅕",oneSixth:"⅙",oneEighth:"⅛",twoThirds:"⅔",twoFifths:"⅖",threeQuarters:"¾",threeFifths:"⅗",threeEighths:"⅜",fourFifths:"⅘",fiveSixths:"⅚",fiveEighths:"⅝",sevenEighths:"⅞",line:"─",lineBold:"━",lineDouble:"═",lineDashed0:"┄",lineDashed1:"┅",lineDashed2:"┈",lineDashed3:"┉",lineDashed4:"╌",lineDashed5:"╍",lineDashed6:"╴",lineDashed7:"╶",lineDashed8:"╸",lineDashed9:"╺",lineDashed10:"╼",lineDashed11:"╾",lineDashed12:"−",lineDashed13:"–",lineDashed14:"‐",lineDashed15:"⁃",lineVertical:"│",lineVerticalBold:"┃",lineVerticalDouble:"║",lineVerticalDashed0:"┆",lineVerticalDashed1:"┇",lineVerticalDashed2:"┊",lineVerticalDashed3:"┋",lineVerticalDashed4:"╎",lineVerticalDashed5:"╏",lineVerticalDashed6:"╵",lineVerticalDashed7:"╷",lineVerticalDashed8:"╹",lineVerticalDashed9:"╻",lineVerticalDashed10:"╽",lineVerticalDashed11:"╿",lineDownLeft:"┐",lineDownLeftArc:"╮",lineDownBoldLeftBold:"┓",lineDownBoldLeft:"┒",lineDownLeftBold:"┑",lineDownDoubleLeftDouble:"╗",lineDownDoubleLeft:"╖",lineDownLeftDouble:"╕",lineDownRight:"┌",lineDownRightArc:"╭",lineDownBoldRightBold:"┏",lineDownBoldRight:"┎",lineDownRightBold:"┍",lineDownDoubleRightDouble:"╔",lineDownDoubleRight:"╓",lineDownRightDouble:"╒",lineUpLeft:"┘",lineUpLeftArc:"╯",lineUpBoldLeftBold:"┛",lineUpBoldLeft:"┚",lineUpLeftBold:"┙",lineUpDoubleLeftDouble:"╝",lineUpDoubleLeft:"╜",lineUpLeftDouble:"╛",lineUpRight:"└",lineUpRightArc:"╰",lineUpBoldRightBold:"┗",lineUpBoldRight:"┖",lineUpRightBold:"┕",lineUpDoubleRightDouble:"╚",lineUpDoubleRight:"╙",lineUpRightDouble:"╘",lineUpDownLeft:"┤",lineUpBoldDownBoldLeftBold:"┫",lineUpBoldDownBoldLeft:"┨",lineUpDownLeftBold:"┥",lineUpBoldDownLeftBold:"┩",lineUpDownBoldLeftBold:"┪",lineUpDownBoldLeft:"┧",lineUpBoldDownLeft:"┦",lineUpDoubleDownDoubleLeftDouble:"╣",lineUpDoubleDownDoubleLeft:"╢",lineUpDownLeftDouble:"╡",lineUpDownRight:"├",lineUpBoldDownBoldRightBold:"┣",lineUpBoldDownBoldRight:"┠",lineUpDownRightBold:"┝",lineUpBoldDownRightBold:"┡",lineUpDownBoldRightBold:"┢",lineUpDownBoldRight:"┟",lineUpBoldDownRight:"┞",lineUpDoubleDownDoubleRightDouble:"╠",lineUpDoubleDownDoubleRight:"╟",lineUpDownRightDouble:"╞",lineDownLeftRight:"┬",lineDownBoldLeftBoldRightBold:"┳",lineDownLeftBoldRightBold:"┯",lineDownBoldLeftRight:"┰",lineDownBoldLeftBoldRight:"┱",lineDownBoldLeftRightBold:"┲",lineDownLeftRightBold:"┮",lineDownLeftBoldRight:"┭",lineDownDoubleLeftDoubleRightDouble:"╦",lineDownDoubleLeftRight:"╥",lineDownLeftDoubleRightDouble:"╤",lineUpLeftRight:"┴",lineUpBoldLeftBoldRightBold:"┻",lineUpLeftBoldRightBold:"┷",lineUpBoldLeftRight:"┸",lineUpBoldLeftBoldRight:"┹",lineUpBoldLeftRightBold:"┺",lineUpLeftRightBold:"┶",lineUpLeftBoldRight:"┵",lineUpDoubleLeftDoubleRightDouble:"╩",lineUpDoubleLeftRight:"╨",lineUpLeftDoubleRightDouble:"╧",lineUpDownLeftRight:"┼",lineUpBoldDownBoldLeftBoldRightBold:"╋",lineUpDownBoldLeftBoldRightBold:"╈",lineUpBoldDownLeftBoldRightBold:"╇",lineUpBoldDownBoldLeftRightBold:"╊",lineUpBoldDownBoldLeftBoldRight:"╉",lineUpBoldDownLeftRight:"╀",lineUpDownBoldLeftRight:"╁",lineUpDownLeftBoldRight:"┽",lineUpDownLeftRightBold:"┾",lineUpBoldDownBoldLeftRight:"╂",lineUpDownLeftBoldRightBold:"┿",lineUpBoldDownLeftBoldRight:"╃",lineUpBoldDownLeftRightBold:"╄",lineUpDownBoldLeftBoldRight:"╅",lineUpDownBoldLeftRightBold:"╆",lineUpDoubleDownDoubleLeftDoubleRightDouble:"╬",lineUpDoubleDownDoubleLeftRight:"╫",lineUpDownLeftDoubleRightDouble:"╪",lineCross:"╳",lineBackslash:"╲",lineSlash:"╱"},iS={...uS,tick:"✔",info:"ℹ",warning:"⚠",cross:"✘",squareSmall:"◻",squareSmallFilled:"◼",circle:"◯",circleFilled:"◉",circleDotted:"◌",circleDouble:"◎",circleCircle:"ⓞ",circleCross:"ⓧ",circlePipe:"Ⓘ",radioOn:"◉",radioOff:"◯",checkboxOn:"☒",checkboxOff:"☐",checkboxCircleOn:"ⓧ",checkboxCircleOff:"Ⓘ",pointer:"❯",triangleUpOutline:"△",triangleLeft:"◀",triangleRight:"▶",lozenge:"◆",lozengeOutline:"◇",hamburger:"☰",smiley:"㋡",mustache:"෴",star:"★",play:"▶",nodejs:"⬢",oneSeventh:"⅐",oneNinth:"⅑",oneTenth:"⅒"},oS={...uS,tick:"√",info:"i",warning:"‼",cross:"×",squareSmall:"□",squareSmallFilled:"■",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(○)",circleCross:"(×)",circlePipe:"(│)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[×]",checkboxOff:"[ ]",checkboxCircleOn:"(×)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"∆",triangleLeft:"◄",triangleRight:"►",lozenge:"♦",lozengeOutline:"◊",hamburger:"≡",smiley:"☺",mustache:"┌─┐",star:"✶",play:"►",nodejs:"♦",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},aS=("win32"!==u.platform?"linux"!==u.env.TERM:Boolean(u.env.WT_SESSION)||Boolean(u.env.TERMINUS_SUBLIME)||"{cmd::Cmder}"===u.env.ConEmuTask||"Terminus-Sublime"===u.env.TERM_PROGRAM||"vscode"===u.env.TERM_PROGRAM||"xterm-256color"===u.env.TERM||"alacritty"===u.env.TERM||"JetBrains-JediTerm"===u.env.TERMINAL_EMULATOR)?iS:oS,sS={prefix:{idle:nS.blue("?"),done:nS.green(aS.tick)},spinner:{interval:80,frames:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"].map(e=>nS.yellow(e))},style:{answer:nS.cyan,message:nS.bold,error:e=>nS.red(`> ${e}`),defaultAnswer:e=>nS.dim(`(${e})`),help:nS.dim,highlight:nS.cyan,key:e=>nS.cyan(nS.bold(`<${e}>`))}};function cS(e){if("object"!=typeof e||null===e)return!1;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function lS(...e){const t={};for(const r of e)for(const[e,n]of Object.entries(r)){const r=t[e];t[e]=cS(r)&&cS(n)?lS(r,n):n}return t}function fS(...e){const t=[sS,...e.filter(e=>null!=e)];return lS(...t)}function dS({status:e="idle",theme:t}){const[r,n]=tS(!1),[u,i]=tS(0),{prefix:o,spinner:a}=fS(t);if(rS(()=>{if("loading"===e){let e,t=-1;const r=setTimeout(()=>{n(!0),e=setInterval(()=>{t+=1,i(t%a.frames.length)},a.interval)},300);return()=>{clearTimeout(r),clearInterval(e)}}n(!1)},[e]),r)return a.frames[u];return"string"==typeof o?o:o["loading"===e?"idle":e]??o.idle}function pS(e,t){return XC(r=>{const n=r.get();if(!n||n.dependencies.length!==t.length||n.dependencies.some((e,r)=>e!==t[r])){const n=e();return r.set({value:n,dependencies:t}),n}return n.value})}function hS(e){return tS({current:e})[0]}function DS(e){const t=hS(e);t.current=e,rS(e=>{let r=!1;const n=JC((n,u)=>{r||t.current(u,e)});return e.input.on("keypress",n),()=>{r=!0,e.input.removeListener("keypress",n)}},[])}var bS=T(we()),yS=T(ut());function vS(e,t){return e.split("\n").flatMap(e=>yS(e,t,{trim:!1,hard:!0}).split("\n").map(e=>e.trimEnd())).join("\n")}function mS(){return bS({defaultWidth:80,output:QC().output})}function gS({items:e,active:t,renderItem:r,pageSize:n,loop:u=!0}){const i=mS(),o=t=>(t%e.length+e.length)%e.length,a=e.map((e,n)=>null==e?[]:vS(r({item:e,index:n,isActive:n===t}),i).split("\n")),s=a.reduce((e,t)=>e+t.length,0),c=e=>a[e]??[],l=function({active:e,renderedItems:t,pageSize:r,loop:n}){const u=hS({lastPointer:e,lastActive:void 0}),{lastPointer:i,lastActive:o}=u.current,a=Math.floor(r/2),s=t.reduce((e,t)=>e+t.length,0),c=t.slice(0,e).reduce((e,t)=>e+t.length,0);let l=c;if(s>r)if(n)l=i,null!=o&&o<e&&e-o<r&&(l=Math.min(a,1===Math.abs(e-o)?Math.min(i+(t[o]?.length??0),Math.max(c,i)):i+e-o));else{const n=t.slice(e).reduce((e,t)=>e+t.length,0);l=n<r-a?r-n:Math.min(c,a)}return u.current.lastPointer=l,u.current.lastActive=e,l}({active:t,renderedItems:a,pageSize:n,loop:u}),f=c(t).slice(0,n),d=l+f.length<=n?l:n-f.length,p=Array.from({length:n});p.splice(d,f.length,...f);const h=new Set([t]);let D=d+f.length,b=o(t+1);for(;D<n&&!h.has(b)&&(u&&s>n?b!==t:b>t);){const e=c(b).slice(0,n-D);p.splice(D,e.length,...e),h.add(b),D+=e.length,b=o(b+1)}for(D=d-1,b=o(t-1);D>=0&&!h.has(b)&&(u&&s>n?b!==t:b<t);){const e=c(b),t=e.slice(Math.max(0,e.length-D-1));p.splice(D-t.length+1,t.length,...t),h.add(b),D-=t.length,b=o(b-1)}return p.filter(e=>"string"==typeof e).join("\n")}var FS=T(lt());const _S=[];_S.push("SIGHUP","SIGINT","SIGTERM"),"win32"!==process.platform&&_S.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT"),"linux"===process.platform&&_S.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");const ES=e=>!!e&&"object"==typeof e&&"function"==typeof e.removeListener&&"function"==typeof e.emit&&"function"==typeof e.reallyExit&&"function"==typeof e.listeners&&"function"==typeof e.kill&&"number"==typeof e.pid&&"function"==typeof e.on,wS=Symbol.for("signal-exit emitter"),CS=globalThis,SS=Object.defineProperty.bind(Object);class OS{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(CS[wS])return CS[wS];SS(CS,wS,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,t){this.listeners[e].push(t)}removeListener(e,t){const r=this.listeners[e],n=r.indexOf(t);-1!==n&&(0===n&&1===r.length?r.length=0:r.splice(n,1))}emit(e,t,r){if(this.emitted[e])return!1;this.emitted[e]=!0;let n=!1;for(const u of this.listeners[e])n=!0===u(t,r)||n;return"exit"===e&&(n=this.emit("afterExit",t,r)||n),n}}class BS{}const xS=globalThis.process,{onExit:AS}=(PS=ES(xS)?new class extends BS{#n="win32"===xS.platform?"SIGINT":"SIGHUP";#u=new OS;#i;#o;#a;#s={};#c=!1;constructor(e){super(),this.#i=e,this.#s={};for(const t of _S)this.#s[t]=()=>{const r=this.#i.listeners(t);let{count:n}=this.#u;const u=e;if("object"==typeof u.__signal_exit_emitter__&&"number"==typeof u.__signal_exit_emitter__.count&&(n+=u.__signal_exit_emitter__.count),r.length===n){this.unload();const r=this.#u.emit("exit",null,t),n="SIGHUP"===t?this.#n:t;r||e.kill(e.pid,n)}};this.#a=e.reallyExit,this.#o=e.emit}onExit(e,t){if(!ES(this.#i))return()=>{};!1===this.#c&&this.load();const r=t?.alwaysLast?"afterExit":"exit";return this.#u.on(r,e),()=>{this.#u.removeListener(r,e),0===this.#u.listeners.exit.length&&0===this.#u.listeners.afterExit.length&&this.unload()}}load(){if(!this.#c){this.#c=!0,this.#u.count+=1;for(const e of _S)try{const t=this.#s[e];t&&this.#i.on(e,t)}catch(e){}this.#i.emit=(e,...t)=>this.#l(e,...t),this.#i.reallyExit=e=>this.#f(e)}}unload(){this.#c&&(this.#c=!1,_S.forEach(e=>{const t=this.#s[e];if(!t)throw new Error("Listener not defined for signal: "+e);try{this.#i.removeListener(e,t)}catch(e){}}),this.#i.emit=this.#o,this.#i.reallyExit=this.#a,this.#u.count-=1)}#f(e){return ES(this.#i)?(this.#i.exitCode=e||0,this.#u.emit("exit",this.#i.exitCode,null),this.#a.call(this.#i,this.#i.exitCode)):0}#l(e,...t){const r=this.#o;if("exit"===e&&ES(this.#i)){"number"==typeof t[0]&&(this.#i.exitCode=t[0]);const n=r.call(this.#i,e,...t);return this.#u.emit("exit",this.#i.exitCode,null),n}return r.call(this.#i,e,...t)}}(xS):new class extends BS{onExit(){return()=>{}}load(){}unload(){}},{onExit:(e,t)=>PS.onExit(e,t),load:()=>PS.load(),unload:()=>PS.unload()});var PS,jS=T(gt());const kS=e=>e.split("\n").length;function TS(e){return e>0?jS.cursorDown(e):""}class MS{height=0;extraLinesUnderPrompt=0;cursorPos;rl;constructor(e){this.rl=e,this.cursorPos=e.getCursorPos()}write(e){this.rl.output.unmute(),this.rl.output.write(e),this.rl.output.mute()}render(e,t=""){const r=(e=>e.split("\n").pop()??"")(e),n=s.stripVTControlCharacters(r);let u=n;this.rl.line.length>0&&(u=u.slice(0,-this.rl.line.length)),this.rl.setPrompt(u),this.cursorPos=this.rl.getCursorPos();const i=mS();e=vS(e,i),t=vS(t,i),n.length%i===0&&(e+="\n");let o=e+(t?"\n"+t:"");const a=Math.floor(n.length/i)-this.cursorPos.rows+(t?kS(t):0);a>0&&(o+=jS.cursorUp(a)),o+=jS.cursorTo(this.cursorPos.cols),this.write(TS(this.extraLinesUnderPrompt)+jS.eraseLines(this.height)+o),this.extraLinesUnderPrompt=a,this.height=kS(o)}checkCursorPos(){const e=this.rl.getCursorPos();e.cols!==this.cursorPos.cols&&(this.write(jS.cursorTo(e.cols)),this.cursorPos=e)}done({clearContent:e}){this.rl.setPrompt("");let t=TS(this.extraLinesUnderPrompt);t+=e?jS.eraseLines(this.height):"\n",t+=jS.cursorShow,this.write(t),this.rl.close()}}class IS extends Promise{static withResolver(){let e,t;return{promise:new Promise((r,n)=>{e=r,t=n}),resolve:e,reject:t}}}function LS(e){const t=function(){const e=Error.prepareStackTrace;let t=[];try{Error.prepareStackTrace=(e,r)=>{const n=r.slice(1);return t=n,n},(new Error).stack}catch{return t}return Error.prepareStackTrace=e,t}();return(n,u={})=>{const{input:i=process.stdin,signal:o}=u,a=new Set,s=new FS;s.pipe(u.output??process.stdout);const c=j.createInterface({terminal:!0,input:i,output:s}),l=new MS(c),{promise:f,resolve:d,reject:p}=IS.withResolver(),h=()=>p(new GC);if(o){const e=()=>p(new WC({cause:o.reason}));if(o.aborted)return e(),Object.assign(f,{cancel:h});o.addEventListener("abort",e),a.add(()=>o.removeEventListener("abort",e))}a.add(AS((e,t)=>{p(new VC(`User force closed the prompt with ${e} ${t}`))}));const D=()=>p(new VC("User force closed the prompt with SIGINT"));c.on("SIGINT",D),a.add(()=>c.removeListener("SIGINT",D));const b=()=>l.checkCursorPos();return c.input.on("keypress",b),a.add(()=>c.input.removeListener("keypress",b)),function(e,t){const r=function(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}(e);return HC.run(r,()=>t(function(e){r.handleChange=()=>{r.index=0,e()},r.handleChange()}))}(c,i=>{const o=r.AsyncResource.bind(()=>eS.clearAll());return c.on("close",o),a.add(()=>c.removeListener("close",o)),i(()=>{try{const r=e(n,e=>{setImmediate(()=>d(e))});if(void 0===r){const e=t[1]?.getFileName();throw new Error(`Prompt functions must return a string.\n at ${e}`)}const[u,i]="string"==typeof r?[r]:r;l.render(u,i),eS.run()}catch(e){p(e)}}),Object.assign(f.then(e=>(eS.clearAll(),e),e=>{throw eS.clearAll(),e}).finally(()=>{a.forEach(e=>e()),l.done({clearContent:Boolean(u.clearPromptOnDone)}),s.end()}).then(()=>f),{cancel:h})})}}class RS{separator=nS.dim(Array.from({length:15}).join(aS.line));type="separator";constructor(e){e&&(this.separator=e)}static isSeparator(e){return Boolean(e&&"object"==typeof e&&"type"in e&&"separator"===e.type)}}const NS={icon:{checked:nS.green(aS.circleFilled),unchecked:aS.circle,cursor:aS.pointer},style:{disabledChoice:e=>nS.dim(`- ${e}`),renderSelectedChoices:e=>e.map(e=>e.short).join(", "),description:e=>nS.cyan(e)},helpMode:"auto"};function US(e){return!RS.isSeparator(e)&&!e.disabled}function zS(e){return US(e)&&Boolean(e.checked)}function $S(e){return US(e)?{...e,checked:!e.checked}:e}var qS=LS((e,t)=>{const{instructions:r,pageSize:n=7,loop:u=!0,required:i,validate:o=()=>!0}=e,a={all:"a",invert:"i",...e.shortcuts},s=fS(NS,e.theme),c=hS(!0),[l,f]=tS("idle"),d=dS({status:l,theme:s}),[p,h]=tS(e.choices.map(e=>{if(RS.isSeparator(e))return e;if("string"==typeof e)return{value:e,name:e,short:e,disabled:!1,checked:!1};const t=e.name??String(e.value),r={value:e.value,name:t,short:e.short??t,disabled:e.disabled??!1,checked:e.checked??!1};return e.description&&(r.description=e.description),r}));const D=pS(()=>{const e=p.findIndex(US),t=p.findLastIndex(US);if(-1===e)throw new YC("[checkbox prompt] No selectable choices. All choices are disabled.");return{first:e,last:t}},[p]),[b,y]=tS(D.first),[v,m]=tS(!0),[g,F]=tS();DS(async e=>{if(qC(e)){const e=p.filter(zS),r=await o([...e]);i&&!p.some(zS)?F("At least one choice must be selected"):!0===r?(f("done"),t(e.map(e=>e.value))):F(r||"You must select a valid value")}else if(NC(e)||UC(e)){if(u||NC(e)&&b!==D.first||UC(e)&&b!==D.last){const t=NC(e)?-1:1;let r=b;do{r=(r+t+p.length)%p.length}while(!US(p[r]));y(r)}}else if((e=>"space"===e.name)(e))F(void 0),m(!1),h(p.map((e,t)=>t===b?$S(e):e));else if(e.name===a.all){const e=p.some(e=>US(e)&&!e.checked);h(p.map((r=e,function(e){return US(e)?{...e,checked:r}:e})))}else if(e.name===a.invert)h(p.map($S));else if($C(e)){const t=Number(e.name)-1,r=p[t];null!=r&&US(r)&&(y(t),h(p.map((e,r)=>r===t?$S(e):e)))}var r});const _=s.style.message(e.message,l);let E;const w=gS({items:p,active:b,renderItem({item:e,isActive:t}){if(RS.isSeparator(e))return` ${e.separator}`;if(e.disabled){const t="string"==typeof e.disabled?e.disabled:"(disabled)";return s.style.disabledChoice(`${e.name} ${t}`)}t&&(E=e.description);const r=e.checked?s.icon.checked:s.icon.unchecked;return(t?s.style.highlight:e=>e)(`${t?s.icon.cursor:" "}${r} ${e.name}`)},pageSize:n,loop:u});if("done"===l){const e=p.filter(zS);return`${d} ${_} ${s.style.answer(s.style.renderSelectedChoices(e,p))}`}let C="",S="";if("always"===s.helpMode||"auto"===s.helpMode&&v&&(void 0===r||r)){if("string"==typeof r)C=r;else{C=` (Press ${[`${s.style.key("space")} to select`,a.all?`${s.style.key(a.all)} to toggle all`:"",a.invert?`${s.style.key(a.invert)} to invert selection`:"",`and ${s.style.key("enter")} to proceed`].filter(e=>""!==e).join(", ")})`}p.length>n&&("always"===s.helpMode||"auto"===s.helpMode&&c.current)&&(S=`\n${s.style.help("(Use arrow keys to reveal more choices)")}`,c.current=!1)}const O=E?`\n${s.style.description(E)}`:"";let B="";return g&&(B=`\n${s.style.error(g)}`),`${d} ${_}${C}\n${w}${S}${O}${B}${jS.cursorHide}`}),WS=un();const GS={validationFailureMode:"keep"};var VS=LS((e,t)=>{const{waitForUseInput:r=!0,file:{postfix:n=e.postfix??".txt",...u}={},validate:i=()=>!0}=e,o=fS(GS,e.theme),[a,s]=tS("idle"),[c="",l]=tS(e.default),[f,d]=tS(),p=dS({status:a,theme:o});function h(r){r.pause();WS.editAsync(c,(n,u)=>{(async(n,u)=>{if(r.resume(),n)d(n.toString());else{s("loading");const r=await i(u);!0===r?(d(void 0),s("done"),t(u)):("clear"===o.validationFailureMode?l(e.default):l(u),d(r||"You must provide a valid value"),s("idle"))}})(n,u)},{postfix:n,...u})}rS(e=>{r||h(e)},[]),DS((e,t)=>{"idle"===a&&qC(e)&&h(t)});const D=o.style.message(e.message,a);let b="";if("loading"===a)b=o.style.help("Received");else if("idle"===a){const e=o.style.key("enter");b=o.style.help(`Press ${e} to launch your preferred editor.`)}let y="";return f&&(y=o.style.error(f)),[[p,D,b].filter(Boolean).join(" "),y]});function KS(e,t){let r=!1!==t;return/^(y|yes)/i.test(e)?r=!0:/^(n|no)/i.test(e)&&(r=!1),r}function YS(e){return e?"Yes":"No"}var HS=LS((e,t)=>{const{transformer:r=YS}=e,[n,u]=tS("idle"),[i,o]=tS(""),a=fS(e.theme),s=dS({status:n,theme:a});DS((n,a)=>{if(qC(n)){const n=KS(i,e.default);o(r(n)),u("done"),t(n)}else if("tab"===n.name){const t=YS(!KS(i,e.default));a.clearLine(0),a.write(t),o(t)}else o(a.line)});let c=i,l="";"done"===n?c=a.style.answer(i):l=` ${a.style.defaultAnswer(!1===e.default?"y/N":"Y/n")}`;return`${s} ${a.style.message(e.message,n)}${l} ${c}`});const ZS={validationFailureMode:"keep"};var QS=LS((e,t)=>{const{required:r,validate:n=()=>!0,prefill:u="tab"}=e,i=fS(ZS,e.theme),[o,a]=tS("idle"),[s="",c]=tS(e.default),[l,f]=tS(),[d,p]=tS(""),h=dS({status:o,theme:i});DS(async(e,u)=>{if("idle"===o)if(qC(e)){const e=d||s;a("loading");const o=r&&!e?"You must provide a value":await n(e);!0===o?(p(e),a("done"),t(e)):("clear"===i.validationFailureMode?p(""):u.write(d),f(o||"You must provide a valid value"),a("idle"))}else zC(e)&&!d?c(void 0):"tab"!==e.name||d?(p(u.line),f(void 0)):(c(void 0),u.clearLine(0),u.write(s),p(s))}),rS(e=>{"editable"===u&&s&&(e.write(s),p(s))},[]);const D=i.style.message(e.message,o);let b,y=d;"function"==typeof e.transformer?y=e.transformer(d,{isFinal:"done"===o}):"done"===o&&(y=i.style.answer(d)),s&&"done"!==o&&!d&&(b=i.style.defaultAnswer(s));let v="";return l&&(v=i.style.error(l)),[[h,D,b,y].filter(e=>void 0!==e).join(" "),v]});function JS(e,{min:t,max:r,step:n}){return null!=e&&!Number.isNaN(e)&&(e<t||e>r?`Value must be between ${t} and ${r}`:!("any"!==n&&!function(e,t,r){const n=e*Math.pow(10,6),u=t*Math.pow(10,6),i=r*Math.pow(10,6);return(n-(Number.isFinite(r)?i:0))%u===0}(e,n,t))||`Value must be a multiple of ${n}${Number.isFinite(t)?` starting from ${t}`:""}`)}var XS=LS((e,t)=>{const{validate:r=()=>!0,min:n=-1/0,max:u=1/0,step:i=1,required:o=!1}=e,a=fS(e.theme),[s,c]=tS("idle"),[l,f]=tS(""),d=!0===JS(e.default,{min:n,max:u,step:i})?e.default?.toString():void 0,[p="",h]=tS(d),[D,b]=tS(),y=dS({status:s,theme:a});DS(async(e,a)=>{if("idle"===s)if(qC(e)){const e=l||p,s=""===e?void 0:Number(e);c("loading");let d=!0;(o||null!=s)&&(d=JS(s,{min:n,max:u,step:i})),!0===d&&(d=await r(s)),!0===d?(f(String(s??"")),c("done"),t(s)):(a.write(l),b(d||"You must provide a valid numeric value"),c("idle"))}else zC(e)&&!l?h(void 0):"tab"!==e.name||l?(f(a.line),b(void 0)):(h(void 0),a.clearLine(0),a.write(p),f(p))});const v=a.style.message(e.message,s);let m,g=l;"done"===s&&(g=a.style.answer(l)),p&&"done"!==s&&!l&&(m=a.style.defaultAnswer(p));let F="";return D&&(F=a.style.error(D)),[[y,v,m,g].filter(e=>void 0!==e).join(" "),F]});const eO={key:"h",name:"Help, list all options",value:void 0};var tO=LS((e,t)=>{const{default:r="h"}=e,n=pS(()=>function(e){return e.map(e=>{if(RS.isSeparator(e))return e;const t="name"in e?e.name:String(e.value);return{value:"value"in e?e.value:t,name:t,key:e.key.toLowerCase()}})}(e.choices),[e.choices]),[u,i]=tS("idle"),[o,a]=tS(""),[s,c]=tS(e.expanded??!1),[l,f]=tS(),d=fS(e.theme),p=dS({theme:d,status:u});DS((e,u)=>{if(qC(e)){const e=(o||r).toLowerCase();if("h"!==e||s){const r=n.find(t=>!RS.isSeparator(t)&&t.key===e);r?(i("done"),a(e),t(r.value)):f(""===o?"Please input a value":`"${nS.red(o)}" isn't an available option`)}else c(!0)}else a(u.line),f(void 0)});const h=d.style.message(e.message,u);if("done"===u){const e=n.find(e=>!RS.isSeparator(e)&&e.key===o.toLowerCase());return`${p} ${h} ${d.style.answer(e.name)}`}const D=s?n:[...n,eO];let b="",y=D.map(e=>RS.isSeparator(e)?"":e.key===r?e.key.toUpperCase():e.key).join("");y=` ${d.style.defaultAnswer(y)}`,s&&(y="",b=D.map(e=>{if(RS.isSeparator(e))return` ${e.separator}`;const t=` ${e.key}) ${e.name}`;return e.key===o.toLowerCase()?d.style.highlight(t):t}).join("\n"));let v="";const m=n.find(e=>!RS.isSeparator(e)&&e.key===o.toLowerCase());m&&(v=`${nS.cyan(">>")} ${m.name}`);let g="";return l&&(g=d.style.error(l)),[`${p} ${h}${y} ${o}`,[b,v,g].filter(Boolean).join("\n")]});const rO=/\d+/;function nO(e){return null!=e&&!RS.isSeparator(e)}function uO(e,t){let r;const n=t.filter(nO);if(rO.test(e)){r=n[Number.parseInt(e,10)-1]}else r=n.find(t=>t.key===e);return r?[r,t.indexOf(r)]:[void 0,void 0]}var iO=LS((e,t)=>{const{loop:r=!0}=e,n=pS(()=>function(e){let t=0;return e.map(e=>{if(RS.isSeparator(e))return e;if(t+=1,"string"==typeof e)return{value:e,name:e,short:e,key:String(t)};const r=e.name??String(e.value);return{value:e.value,name:r,short:e.short??r,key:e.key??String(t)}})}(e.choices),[e.choices]),[u,i]=tS("idle"),[o,a]=tS(""),[s,c]=tS(),l=fS(e.theme),f=dS({status:u,theme:l}),d=pS(()=>{const e=n.findIndex(nO),t=n.findLastIndex(nO);if(-1===e)throw new YC("[select prompt] No selectable choices. All choices are disabled.");return{first:e,last:t}},[n]);DS((e,u)=>{if(qC(e)){const[e]=uO(o,n);nO(e)?(a(e.short),i("done"),t(e.value)):c(""===o?"Please input a value":`"${nS.red(o)}" isn't an available option`)}else if("up"===e.name||"down"===e.name){u.clearLine(0);const[t,i]=uO(o,n);if(t){if(r||"up"===e.name&&i!==d.first||"down"===e.name&&i!==d.last){const t="up"===e.name?-1:1;let r=i;do{r=(r+t+n.length)%n.length}while(!nO(n[r]));a(n[r].key)}}else{const t="down"===e.name?n.find(nO):n.findLast(nO);a(t.key)}}else a(u.line),c(void 0)});const p=l.style.message(e.message,u);if("done"===u)return`${f} ${p} ${l.style.answer(o)}`;const h=n.map(e=>{if(RS.isSeparator(e))return` ${e.separator}`;const t=` ${e.key}) ${e.name}`;return e.key===o.toLowerCase()?l.style.highlight(t):t}).join("\n");let D="";return s&&(D=l.style.error(s)),[`${f} ${p} ${o}`,[h,D].filter(Boolean).join("\n")]}),oO=LS((e,t)=>{const{validate:r=()=>!0}=e,n=fS(e.theme),[u,i]=tS("idle"),[o,a]=tS(),[s,c]=tS(""),l=dS({status:u,theme:n});DS(async(e,n)=>{if("idle"===u)if(qC(e)){const e=s;i("loading");const u=await r(e);!0===u?(c(e),i("done"),t(e)):(n.write(s),a(u||"You must provide a valid value"),i("idle"))}else c(n.line),a(void 0)});const f=n.style.message(e.message,u);let d,p="";if(e.mask){p=("string"==typeof e.mask?e.mask:"*").repeat(s.length)}else"done"!==u&&(d=`${n.style.help("[input is masked]")}${jS.cursorHide}`);"done"===u&&(p=n.style.answer(p));let h="";return o&&(h=n.style.error(o)),[[l,f,e.mask?p:d].join(" "),h]});const aO={icon:{cursor:aS.pointer},style:{disabled:e=>nS.dim(`- ${e}`),searchTerm:e=>nS.cyan(e),description:e=>nS.cyan(e)},helpMode:"auto"};function sO(e){return!RS.isSeparator(e)&&!e.disabled}var cO=LS((e,t)=>{const{pageSize:r=7,validate:n=()=>!0}=e,u=fS(aO,e.theme),i=hS(!0),[o,a]=tS("loading"),[s,c]=tS(""),[l,f]=tS([]),[d,p]=tS(),h=dS({status:o,theme:u}),D=pS(()=>({first:l.findIndex(sO),last:l.findLastIndex(sO)}),[l]),[b=D.first,y]=tS();rS(()=>{const t=new AbortController;a("loading"),p(void 0);return(async()=>{try{const r=await e.source(s||void 0,{signal:t.signal});t.signal.aborted||(y(void 0),p(void 0),f(r.map(e=>{if(RS.isSeparator(e))return e;if("string"==typeof e)return{value:e,name:e,short:e,disabled:!1};const t=e.name??String(e.value),r={value:e.value,name:t,short:e.short??t,disabled:e.disabled??!1};return e.description&&(r.description=e.description),r})),a("idle"))}catch(e){!t.signal.aborted&&e instanceof Error&&p(e.message)}})(),()=>{t.abort()}},[s]);const v=l[b];DS(async(e,r)=>{if(qC(e))if(v){a("loading");const e=await n(v.value);a("idle"),!0===e?(a("done"),t(v.value)):v.name===s?p(e||"You must provide a valid value"):(r.write(v.name),c(v.name))}else r.write(s);else if("tab"===e.name&&v)r.clearLine(0),r.write(v.name),c(v.name);else if("loading"===o||"up"!==e.name&&"down"!==e.name)c(r.line);else if(r.clearLine(0),"up"===e.name&&b!==D.first||"down"===e.name&&b!==D.last){const t="up"===e.name?-1:1;let r=b;do{r=(r+t+l.length)%l.length}while(!sO(l[r]));y(r)}});const m=u.style.message(e.message,o);b>0&&(i.current=!1);let g="";l.length>1&&("always"===u.helpMode||"auto"===u.helpMode&&i.current)&&(g=l.length>r?`\n${u.style.help("(Use arrow keys to reveal more choices)")}`:`\n${u.style.help("(Use arrow keys)")}`);const F=gS({items:l,active:b,renderItem({item:e,isActive:t}){if(RS.isSeparator(e))return` ${e.separator}`;if(e.disabled){const t="string"==typeof e.disabled?e.disabled:"(disabled)";return u.style.disabled(`${e.name} ${t}`)}return(t?u.style.highlight:e=>e)(`${t?u.icon.cursor:" "} ${e.name}`)},pageSize:r,loop:!1});let _,E;if(d?_=u.style.error(d):0===l.length&&""!==s&&"idle"===o&&(_=u.style.error("No results found")),"done"===o&&v){const e=v.short;return`${h} ${m} ${u.style.answer(e)}`}E=u.style.searchTerm(s);const w=v?.description?`\n${u.style.description(v.description)}`:"";return[[h,m,E].filter(Boolean).join(" "),`${_??F}${g}${w}`]});const lO={icon:{cursor:aS.pointer},style:{disabled:e=>nS.dim(`- ${e}`),description:e=>nS.cyan(e)},helpMode:"auto",indexMode:"hidden"};function fO(e){return!RS.isSeparator(e)&&!e.disabled}var dO=LS((e,t)=>{const{loop:r=!0,pageSize:n=7}=e,u=hS(!0),i=fS(lO,e.theme),[o,a]=tS("idle"),s=dS({status:o,theme:i}),c=hS(),l=pS(()=>e.choices.map(e=>{if(RS.isSeparator(e))return e;if("string"==typeof e)return{value:e,name:e,short:e,disabled:!1};const t=e.name??String(e.value),r={value:e.value,name:t,short:e.short??t,disabled:e.disabled??!1};return e.description&&(r.description=e.description),r}),[e.choices]),f=pS(()=>{const e=l.findIndex(fO),t=l.findLastIndex(fO);if(-1===e)throw new YC("[select prompt] No selectable choices. All choices are disabled.");return{first:e,last:t}},[l]),d=pS(()=>"default"in e?l.findIndex(t=>fO(t)&&t.value===e.default):-1,[e.default,l]),[p,h]=tS(-1===d?f.first:d),D=l[p];DS((e,n)=>{if(clearTimeout(c.current),qC(e))a("done"),t(D.value);else if(NC(e)||UC(e)){if(n.clearLine(0),r||NC(e)&&p!==f.first||UC(e)&&p!==f.last){const t=NC(e)?-1:1;let r=p;do{r=(r+t+l.length)%l.length}while(!fO(l[r]));h(r)}}else if($C(e)&&!Number.isNaN(Number(n.line))){const e=Number(n.line)-1,t=l[e];null!=t&&fO(t)&&h(e),c.current=setTimeout(()=>{n.clearLine(0)},700)}else if(zC(e))n.clearLine(0);else{const e=n.line.toLowerCase(),t=l.findIndex(t=>!(RS.isSeparator(t)||!fO(t))&&t.name.toLowerCase().startsWith(e));-1!==t&&h(t),c.current=setTimeout(()=>{n.clearLine(0)},700)}}),rS(()=>()=>{clearTimeout(c.current)},[]);const b=i.style.message(e.message,o);let y="",v="";("always"===i.helpMode||"auto"===i.helpMode&&u.current)&&(u.current=!1,l.length>n?v=`\n${i.style.help(`(${e.instructions?.pager??"Use arrow keys to reveal more choices"})`)}`:y=i.style.help(`(${e.instructions?.navigation??"Use arrow keys"})`));const m=gS({items:l,active:p,renderItem({item:e,isActive:t,index:r}){if(RS.isSeparator(e))return` ${e.separator}`;const n="number"===i.indexMode?`${r+1}. `:"";if(e.disabled){const t="string"==typeof e.disabled?e.disabled:"(disabled)";return i.style.disabled(`${n}${e.name} ${t}`)}return(t?i.style.highlight:e=>e)(`${t?i.icon.cursor:" "} ${n}${e.name}`)},pageSize:n,loop:r});if("done"===o)return`${s} ${b} ${i.style.answer(D.short)}`;const g=D.description?`\n${i.style.description(D.description)}`:"";return`${[s,b,y].filter(Boolean).join(" ")}\n${m}${v}${g}${jS.cursorHide}`}),pO=function(e,t){return pO=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},pO(e,t)};function hO(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}pO(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function DO(e,t,r,n){return new(r||(r=Promise))(function(u,i){function o(e){try{s(n.next(e))}catch(e){i(e)}}function a(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?u(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,a)}s((n=n.apply(e,t||[])).next())})}function bO(e,t){var r,n,u,i={label:0,sent:function(){if(1&u[0])throw u[1];return u[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(s){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(i=0)),i;)try{if(r=1,n&&(u=2&a[0]?n.return:a[0]?n.throw||((u=n.return)&&u.call(n),0):n.next)&&!(u=u.call(n,a[1])).done)return u;switch(n=0,u&&(a=[2&a[0],u.value]),a[0]){case 0:case 1:u=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(u=i.trys,(u=u.length>0&&u[u.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!u||a[1]>u[0]&&a[1]<u[3])){i.label=a[1];break}if(6===a[0]&&i.label<u[1]){i.label=u[1],u=a;break}if(u&&i.label<u[2]){i.label=u[2],i.ops.push(a);break}u[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],n=0}finally{r=u=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}function yO(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function vO(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,u,i=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)o.push(n.value)}catch(e){u={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(u)throw u.error}}return o}function mO(e,t,r){if(r||2===arguments.length)for(var n,u=0,i=t.length;u<i;u++)!n&&u in t||(n||(n=Array.prototype.slice.call(t,0,u)),n[u]=t[u]);return e.concat(n||Array.prototype.slice.call(t))}function gO(e){return this instanceof gO?(this.v=e,this):new gO(e)}function FO(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,u=r.apply(e,t||[]),i=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",function(e){return function(t){return Promise.resolve(t).then(e,c)}}),n[Symbol.asyncIterator]=function(){return this},n;function o(e,t){u[e]&&(n[e]=function(t){return new Promise(function(r,n){i.push([e,t,r,n])>1||a(e,t)})},t&&(n[e]=t(n[e])))}function a(e,t){try{(r=u[e](t)).value instanceof gO?Promise.resolve(r.value.v).then(s,c):l(i[0][2],r)}catch(e){l(i[0][3],e)}var r}function s(e){a("next",e)}function c(e){a("throw",e)}function l(e,t){e(t),i.shift(),i.length&&a(i[0][0],i[0][1])}}function _O(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=yO(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise(function(n,u){(function(e,t,r,n){Promise.resolve(n).then(function(t){e({value:t,done:r})},t)})(n,u,(t=e[r](t)).done,t.value)})}}}function EO(e){return"function"==typeof e}function wO(e){var t=e(function(e){Error.call(e),e.stack=(new Error).stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}"function"==typeof SuppressedError&&SuppressedError;var CO=wO(function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map(function(e,t){return t+1+") "+e.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}});function SO(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var OO=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var e,t,r,n,u;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var o=yO(i),a=o.next();!a.done;a=o.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}else i.remove(this);var s=this.initialTeardown;if(EO(s))try{s()}catch(e){u=e instanceof CO?e.errors:[e]}var c=this._finalizers;if(c){this._finalizers=null;try{for(var l=yO(c),f=l.next();!f.done;f=l.next()){var d=f.value;try{xO(d)}catch(e){u=null!=u?u:[],e instanceof CO?u=mO(mO([],vO(u)),vO(e.errors)):u.push(e)}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}}if(u)throw new CO(u)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)xO(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&SO(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&SO(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}();function BO(e){return e instanceof OO||e&&"closed"in e&&EO(e.remove)&&EO(e.add)&&EO(e.unsubscribe)}function xO(e){EO(e)?e():e.unsubscribe()}OO.EMPTY;var AO={Promise:void 0},PO=function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,mO([e,t],vO(r)))};function jO(e){PO(function(){throw e})}function kO(){}var TO=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,BO(t)&&t.add(r)):r.destination=RO,r}return hO(t,e),t.create=function(e,t,r){return new IO(e,t,r)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(OO),MO=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){LO(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){LO(e)}else LO(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){LO(e)}},e}(),IO=function(e){function t(t,r,n){var u,i=e.call(this)||this;return u=EO(t)||!t?{next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:t,i.destination=new MO(u),i}return hO(t,e),t}(TO);function LO(e){jO(e)}var RO={closed:!0,next:kO,error:function(e){throw e},complete:kO},NO="function"==typeof Symbol&&Symbol.observable||"@@observable";function UO(e){return e}var zO=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var n,u=this,i=(n=e)&&n instanceof TO||function(e){return e&&EO(e.next)&&EO(e.error)&&EO(e.complete)}(n)&&BO(n)?e:new IO(e,t,r);return function(){var e=u,t=e.operator,r=e.source;i.add(t?t.call(i,r):r?u._subscribe(i):u._trySubscribe(i))}(),i},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=$O(t))(function(t,n){var u=new IO({next:function(t){try{e(t)}catch(e){n(e),u.unsubscribe()}},error:n,complete:t});r.subscribe(u)})},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[NO]=function(){return this},e.prototype.pipe=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return(0===(e=t).length?UO:1===e.length?e[0]:function(t){return e.reduce(function(e,t){return t(e)},t)})(this)},e.prototype.toPromise=function(e){var t=this;return new(e=$O(e))(function(e,r){var n;t.subscribe(function(e){return n=e},function(e){return r(e)},function(){return e(n)})})},e.create=function(t){return new e(t)},e}();function $O(e){var t;return null!==(t=null!=e?e:AO.Promise)&&void 0!==t?t:Promise}function qO(e){return function(t){if(function(e){return EO(null==e?void 0:e.lift)}(t))return t.lift(function(t){try{return e(t,this)}catch(e){this.error(e)}});throw new TypeError("Unable to lift unknown Observable type")}}function WO(e,t,r,n,u){return new GO(e,t,r,n,u)}var GO=function(e){function t(t,r,n,u,i,o){var a=e.call(this,t)||this;return a.onFinalize=i,a.shouldUnsubscribe=o,a._next=r?function(e){try{r(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=u?function(e){try{u(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=n?function(){try{n()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return hO(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(TO),VO=new zO(function(e){return e.complete()});function KO(e){return(t=(r=e)[r.length-1])&&EO(t.schedule)?e.pop():void 0;var t,r}var YO=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};function HO(e){return EO(null==e?void 0:e.then)}function ZO(e){return EO(e[NO])}function QO(e){return Symbol.asyncIterator&&EO(null==e?void 0:e[Symbol.asyncIterator])}function JO(e){return new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}var XO="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function eB(e){return EO(null==e?void 0:e[XO])}function tB(e){return FO(this,arguments,function(){var t,r,n;return bO(this,function(u){switch(u.label){case 0:t=e.getReader(),u.label=1;case 1:u.trys.push([1,,9,10]),u.label=2;case 2:return[4,gO(t.read())];case 3:return r=u.sent(),n=r.value,r.done?[4,gO(void 0)]:[3,5];case 4:return[2,u.sent()];case 5:return[4,gO(n)];case 6:return[4,u.sent()];case 7:return u.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function rB(e){return EO(null==e?void 0:e.getReader)}function nB(e){if(e instanceof zO)return e;if(null!=e){if(ZO(e))return u=e,new zO(function(e){var t=u[NO]();if(EO(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")});if(YO(e))return n=e,new zO(function(e){for(var t=0;t<n.length&&!e.closed;t++)e.next(n[t]);e.complete()});if(HO(e))return r=e,new zO(function(e){r.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,jO)});if(QO(e))return uB(e);if(eB(e))return t=e,new zO(function(e){var r,n;try{for(var u=yO(t),i=u.next();!i.done;i=u.next()){var o=i.value;if(e.next(o),e.closed)return}}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=u.return)&&n.call(u)}finally{if(r)throw r.error}}e.complete()});if(rB(e))return uB(tB(e))}var t,r,n,u;throw JO(e)}function uB(e){return new zO(function(t){(function(e,t){var r,n,u,i;return DO(this,void 0,void 0,function(){var o,a;return bO(this,function(s){switch(s.label){case 0:s.trys.push([0,5,6,11]),r=_O(e),s.label=1;case 1:return[4,r.next()];case 2:if((n=s.sent()).done)return[3,4];if(o=n.value,t.next(o),t.closed)return[2];s.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=s.sent(),u={error:a},[3,11];case 6:return s.trys.push([6,,9,10]),n&&!n.done&&(i=r.return)?[4,i.call(r)]:[3,8];case 7:s.sent(),s.label=8;case 8:return[3,10];case 9:if(u)throw u.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})})(e,t).catch(function(e){return t.error(e)})})}function iB(e,t,r,n,u){void 0===n&&(n=0),void 0===u&&(u=!1);var i=t.schedule(function(){r(),u?e.add(this.schedule(null,n)):this.unsubscribe()},n);if(e.add(i),!u)return i}function oB(e,t){return void 0===t&&(t=0),qO(function(r,n){r.subscribe(WO(n,function(r){return iB(n,e,function(){return n.next(r)},t)},function(){return iB(n,e,function(){return n.complete()},t)},function(r){return iB(n,e,function(){return n.error(r)},t)}))})}function aB(e,t){return void 0===t&&(t=0),qO(function(r,n){n.add(e.schedule(function(){return r.subscribe(n)},t))})}function sB(e,t){if(!e)throw new Error("Iterable cannot be null");return new zO(function(r){iB(r,t,function(){var n=e[Symbol.asyncIterator]();iB(r,t,function(){n.next().then(function(e){e.done?r.complete():r.next(e.value)})},0,!0)})})}function cB(e,t){if(null!=e){if(ZO(e))return function(e,t){return nB(e).pipe(aB(t),oB(t))}(e,t);if(YO(e))return function(e,t){return new zO(function(r){var n=0;return t.schedule(function(){n===e.length?r.complete():(r.next(e[n++]),r.closed||this.schedule())})})}(e,t);if(HO(e))return function(e,t){return nB(e).pipe(aB(t),oB(t))}(e,t);if(QO(e))return sB(e,t);if(eB(e))return function(e,t){return new zO(function(r){var n;return iB(r,t,function(){n=e[XO](),iB(r,t,function(){var e,t,u;try{t=(e=n.next()).value,u=e.done}catch(e){return void r.error(e)}u?r.complete():r.next(t)},0,!0)}),function(){return EO(null==n?void 0:n.return)&&n.return()}})}(e,t);if(rB(e))return function(e,t){return sB(tB(e),t)}(e,t)}throw JO(e)}function lB(e,t){return t?cB(e,t):nB(e)}var fB=wO(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function dB(e,t,r){return void 0===r&&(r=1/0),EO(t)?dB(function(r,n){return function(e,t){return qO(function(r,n){var u=0;r.subscribe(WO(n,function(r){n.next(e.call(t,r,u++))}))})}(function(e,u){return t(r,e,n,u)})(nB(e(r,n)))},r):("number"==typeof t&&(r=t),qO(function(t,n){return function(e,t,r,n,u,i,o){var a=[],s=0,c=0,l=!1,f=function(){!l||a.length||s||t.complete()},d=function(e){s++;var u=!1;nB(r(e,c++)).subscribe(WO(t,function(e){t.next(e)},function(){u=!0},void 0,function(){if(u)try{s--;for(var e=function(){var e=a.shift();o||d(e)};a.length&&s<n;)e();f()}catch(e){t.error(e)}}))};return e.subscribe(WO(t,function(e){return s<n?d(e):a.push(e)},function(){l=!0,f()})),function(){}}(t,n,e,r)}))}function pB(e,t){return qO(function(e,t,r){return function(n,u){var i=r,o=t,a=0;n.subscribe(WO(u,function(t){var r=a++;o=i?e(o,t,r):(i=!0,t)},function(){i&&u.next(o),u.complete()}))}}(e,t,arguments.length>=2))}function hB(e,t){return EO(t)?dB(e,t,1):dB(e,1)}var DB=T(ab());const bB=(e,t="",r)=>{let n=e;t.split(".").forEach((e,t,u)=>{"__proto__"!==e&&"constructor"!==e&&(t===u.length-1?n[e]=r:e in n&&"object"==typeof n[e]||(n[e]={}),n=n[e])})},yB=(e,t="",r)=>{const n=r=>String.prototype.split.call(t,r).filter(Boolean).reduce((e,t)=>null==e?e:e[t],e),u=n(/[,[\]]+?/)||n(/[,.[\]]+?/);return void 0===u||u===e?r:u};async function vB(e,t,r){const n=e[t];return"function"==typeof n?DB(n)(r):n}class mB extends Error{name="TTYError";isTtyError=!0}class gB{prompts;answers={};process=VO;abortController=new AbortController;opt;constructor(e,t={}){this.opt=t,this.prompts=e}async run(e,t){let r;var n,u;return this.abortController=new AbortController,this.answers="object"==typeof t?{...t}:{},!function(e){return Array.isArray(e)}(e)?r=(n=e)&&(n instanceof zO||EO(n.lift)&&EO(n.subscribe))?e:function(e){return Object.values(e).every(e=>"object"==typeof e&&!Array.isArray(e)&&null!=e)}(e)?lB(Object.entries(e).map(([e,t])=>Object.assign({},t,{name:e}))):lB([e]):r=lB(e),this.process=r.pipe(hB(e=>function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return lB(e,KO(e))}(e).pipe(hB(e=>{return lB(this.shouldRun(e).then(t=>{if(t)return e})).pipe((t=e=>null!=e,qO(function(e,n){var u=0;e.subscribe(WO(n,function(e){return t.call(r,e,u++)&&n.next(e)}))})));var t,r}),hB(e=>{return t=()=>lB(this.fetchAnswer(e)),new zO(function(e){nB(t()).subscribe(e)});var t})))),(u=this.process.pipe(pB((e,t)=>(bB(e,t.name,t.answer),e),this.answers)),new Promise(function(e,t){var r,n=!1;u.subscribe({next:function(e){r=e,n=!0},error:t,complete:function(){n?e(r):t(new fB)}})})).then(()=>this.answers).finally(()=>this.close())}prepareQuestion=async e=>{const[t,r,n]=await Promise.all([vB(e,"message",this.answers),vB(e,"default",this.answers),vB(e,"choices",this.answers)]);let u;return Array.isArray(n)&&(u=n.map(e=>{const t="object"!=typeof e||null==e?{name:e,value:e}:{...e,value:"value"in e?e.value:"name"in e?e.name:void 0};return"value"in t&&Array.isArray(r)?{checked:r.includes(t.value),...t}:t})),Object.assign({},e,{message:t,default:r,choices:u,type:e.type in this.prompts?e.type:"input"})};fetchAnswer=async e=>{const t=await this.prepareQuestion(e),r=this.prompts[t.type];if(null==r)throw new Error(`Prompt for type ${t.type} not found`);let n;const u=function(e){return Boolean(e.prototype&&"run"in e.prototype&&"function"==typeof e.prototype.run)}(r)?(e,t)=>new Promise((u,i)=>{const{signal:a}=t;if(a.aborted)return void i(new WC({cause:a.reason}));const s=o.createInterface(function(e){e.skipTTYChecks=void 0===e.skipTTYChecks||e.skipTTYChecks;const t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY)throw new mB("Prompts can not be meaningfully rendered in non-TTY environments");const r=new FS;r.pipe(e.output||process.stdout);const n=r;return{terminal:!0,...e,input:t,output:n}}(t)),c=()=>{this.close(),process.kill(process.pid,"SIGINT"),console.log("")};process.on("exit",c),s.on("SIGINT",c);const l=new r(e,s,this.answers),f=()=>{process.removeListener("exit",c),s.removeListener("SIGINT",c),s.setPrompt(""),s.output.unmute(),s.output.write(jS.cursorShow),s.output.end(),s.close(),n?.()},d=()=>{i(new WC({cause:a.reason})),f()};a.addEventListener("abort",d),n=()=>{a.removeEventListener("abort",d),n=void 0},l.run().then(u,i).finally(f)}):r;let i;const{signal:a}=this.opt;if(a?.aborted)this.abortController.abort(a.reason);else if(a){const e=()=>this.abortController.abort(a.reason);a.addEventListener("abort",e),i=()=>{a.removeEventListener("abort",e)}}const{filter:s=e=>e}=t,{signal:c}=this.abortController;return u(t,{...this.opt,signal:c}).then(e=>({name:t.name,answer:s(e,this.answers)})).finally(()=>{n?.(),i?.()})};close=()=>{this.abortController.abort()};shouldRun=async e=>{if(!0!==e.askAnswered&&void 0!==yB(this.answers,e.name))return!1;const{when:t}=e;if("function"==typeof t){const e=await DB(t)(this.answers);return Boolean(e)}return!1!==t}}const FB={input:QS,select:dO,list:dO,number:XS,confirm:HS,rawlist:iO,expand:tO,checkbox:qS,password:oO,editor:VS,search:cO};function _B(e){function t(r,n){const u=new gB(t.prompts,e),i=u.run(r,n);return Object.assign(i,{ui:u})}return t.prompts={...FB},t.registerPrompt=function(e,r){return t.prompts[e]=r,this},t.restoreDefaultPrompts=function(){t.prompts={...FB}},t}const EB=_B();const wB={prompt:EB,ui:{Prompt:gB},createPromptModule:_B,registerPrompt:function(e,t){EB.registerPrompt(e,t)},restoreDefaultPrompts:function(){EB.restoreDefaultPrompts()},Separator:RS},CB=h.join(g.homedir(),".ttmg-cli"),SB=h.join(CB,"config.json");function OB(e){let t=[];if(c.existsSync(SB))try{const e=JSON.parse(c.readFileSync(SB,"utf-8"));t=Array.isArray(e.clientKeys)?e.clientKeys:[]}catch(e){t=[]}t.includes(e)||(t.push(e),c.existsSync(CB)||c.mkdirSync(CB,{recursive:!0}),c.writeFileSync(SB,JSON.stringify({clientKeys:t},null,2),{encoding:"utf-8"}))}async function BB(){const e=function(){if(!c.existsSync(SB))return[];try{const e=JSON.parse(c.readFileSync(SB,"utf-8"));return Array.isArray(e.clientKeys)?e.clientKeys:[]}catch(e){return[]}}();let t;if(e.length>0){const{selectedKey:r}=await wB.prompt([{type:"list",name:"selectedKey",message:"Please select your game id(client_key):",choices:[...e,new wB.Separator,"Add new game id"]}]);if("Add new game id"===r){const{newKey:e}=await wB.prompt([{type:"input",name:"newKey",message:"Please input your new game id(client_key):",validate:e=>!!e||"Please input game id"}]);OB(e),t=e}else t=r}else{const{newKey:e}=await wB.prompt([{type:"input",name:"newKey",message:"Please input your game id(client_key):",validate:e=>!!e||"Please input game id"}]);OB(e),t=e}return t}const xB=y();function AB(){xB.use(y.json()),xB.post("/game/env",(e,r)=>{const n=e.body,{host:u,port:i}=n;r.json({code:0,msg:"ok"});const o=`http://${u}:${i}`;!function(e){const{exec:t}=require("child_process");t(`open ${e}`)}(o),console.log(t.bold.yellow(`Game debug is ready! Visit ${o} in your browser.`))}),xB.listen(9527,()=>{})}async function PB(){const e=await BB(),r=process.cwd(),n=function(){const e=g.homedir(),t=["Desktop","桌面"];for(const r of t){const t=h.join(e,r);if(c.existsSync(t))return t}return h.join(e,"Desktop")}();if(!n)return void console.log(t.redBright("Desktop path not found"));const u=h.join(n,"__TTMG_DEV_TEMP__",e);c.existsSync(u)?c.rmSync(u,{recursive:!0,force:!0}):c.mkdirSync(u,{recursive:!0});const i=await A.debugPkgs({entry:r,output:u,rules:{mainPackageSizeLimit:209715200,projectSizeLimit:209715200}});if(!(null==i?void 0:i.isSuccess))return console.log(t.redBright("Build game package failed, Please check the error message below:")),void console.log(t.redBright(null==i?void 0:i.errorMsg));console.log(t.cyan("\n==============================")),console.log(t.greenBright("✅ Game package built successfully!")),console.log(t.cyan("==============================\n")),console.log(t.yellow("Next steps:")),console.log(` 1. ${t.blue("Scan the QR code to start the client devServer.")}`),console.log(` 2. ${t.blue("Upload the dev package from:")} ${t.bold(u)}`),console.log(` 3. ${t.blue("Debug your game in the browser.")}\n`),AB();const o=RC(e);x.generate(o,{small:!0},e=>{console.log(function(e){const t=process.stdout.columns||80,r=e.split("\n"),n=r.reduce((e,t)=>Math.max(e,t.length),0),u=Math.floor((t-n)/3),i=" ".repeat(u>0?u:0);return r.map(e=>i+e).join("\n")}(e))})}const jB=new e.Command;jB.name("ttmg").description("TikTok Mini Game Command Line Tool").version("0.0.1"),jB.command("init").option("--h5","H5 Mini Game").option("--native","Native Mini Game").description("Initialize project").action(e=>{e.h5?Ob():e.native?console.log("Native Mini Game initialize"):console.log(t.red.bold("Please run ttmg init --h5 or ttmg init --native"))}),jB.command("dev").description("Open browser dev environment").option("--h5","H5 Mini Game").option("--native","Native Mini Game").action(e=>{e.h5?Nb():e.native?PB():console.log(t.red.bold("Please run ttmg dev --h5 or ttmg dev --native"))}),jB.command("build").option("--h5","H5 Mini Game").option("--native","Native Mini Game").description("Bundle project").action(async e=>{e.h5?LC():e.native?console.log("Native Mini Game bundle"):console.log(t.red.bold("Please run ttmg build --h5 or ttmg build --native"))}),jB.parse(process.argv);
|
|
58
58
|
//# sourceMappingURL=index.js.map
|