@aventusjs/cli 0.0.16 → 0.0.18
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/out/RealInteraction.js +8 -4
- package/out/RealServer.js +390 -95
- package/out/cli.js +1 -1
- package/package.json +1 -1
package/out/RealInteraction.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require("@inquirer/core"),l=require("yoctocolors-cjs");l=s(l);let u=require("@inquirer/figures");u=s(u);let d=require("ansi-escapes");d=s(d);let f=require("path"),p=require("chalk");p=s(p);let m=require("fs"),h=require("vscode-languageserver"),g=require("node:async_hooks"),_=require("@inquirer/ansi");function v(e){return e.name==`l`&&e.ctrl}const y={icon:{checked:l.default.green(u.default.circleFilled),unchecked:u.default.circle,cursor:u.default.pointer},style:{disabledChoice:e=>l.default.dim(`- ${e}`),renderSelectedChoices:e=>e.map(e=>e.short).join(`, `),description:e=>l.default.cyan(e)},helpMode:`auto`};function b(e){return!c.Separator.isSeparator(e)&&!e.disabled}function x(e){return b(e)&&!!e.checked}function S(e){return b(e)?{...e,checked:!e.checked}:e}function C(e){return function(t){return b(t)?{...t,checked:e}:t}}function w(e){return e.map(e=>{if(c.Separator.isSeparator(e))return e;if(typeof e==`string`)return{value:e,name:e,short:e,disabled:!1,checked:!1};let t=e.name??String(e.value);return{value:e.value,name:t,short:e.short??t,description:e.description,disabled:e.disabled??!1,checked:e.checked??!1}})}var T=(0,c.createPrompt)((e,t)=>{let{instructions:n,pageSize:r=7,loop:i=!0,required:a,validate:o=()=>!0}=e,s=(0,c.makeTheme)(y,e.theme),l=(0,c.useRef)(!0),[u,f]=(0,c.useState)(`idle`),p=(0,c.usePrefix)({status:u,theme:s}),[m,h]=(0,c.useState)(w(e.choices)),g=(0,c.useMemo)(()=>{let e=m.findIndex(b),t=m.findLastIndex(b);if(e===-1)throw new c.ValidationError(`[checkbox prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[m]),[_,T]=(0,c.useState)(g.first),[E,D]=(0,c.useState)(!0),[O,k]=(0,c.useState)();(0,c.useKeypress)(async e=>{if((0,c.isEnterKey)(e)){let e=m.filter(x),n=await o([...e]);a&&!m.some(x)?k(`At least one choice must be selected`):n===!0?(f(`done`),t(e.map(e=>e.value))):k(n||`You must select a valid value`)}else if((0,c.isUpKey)(e)||(0,c.isDownKey)(e)){if(i||(0,c.isUpKey)(e)&&_!==g.first||(0,c.isDownKey)(e)&&_!==g.last){let t=(0,c.isUpKey)(e)?-1:1,n=_;do n=(n+t+m.length)%m.length;while(!b(m[n]));T(n)}}else if((0,c.isSpaceKey)(e))k(void 0),D(!1),h(m.map((e,t)=>t===_?S(e):e));else if(e.name===`a`){let e=m.some(e=>b(e)&&!e.checked);h(m.map(C(e)))}else if(e.name===`i`)h(m.map(S));else if((0,c.isNumberKey)(e)){let t=Number(e.name)-1,n=m[t];n!=null&&b(n)&&(T(t),h(m.map((e,n)=>n===t?S(e):e)))}else v(e)&&(f(`done`),t(null))});let A=s.style.message(e.message,u),j,M=(0,c.usePagination)({items:m,active:_,renderItem({item:e,isActive:t}){if(c.Separator.isSeparator(e))return` ${e.separator}`;if(e.disabled){let t=typeof e.disabled==`string`?e.disabled:`(disabled)`;return s.style.disabledChoice(`${e.name} ${t}`)}t&&(j=e.description);let n=e.checked?s.icon.checked:s.icon.unchecked;return(t?s.style.highlight:e=>e)(`${t?s.icon.cursor:` `}${n} ${e.name}`)},pageSize:r,loop:i});if(u===`done`){let e=m.filter(x);return`${p} ${A} ${s.style.answer(s.style.renderSelectedChoices(e,m))}`}let N=``,P=``;(s.helpMode===`always`||s.helpMode===`auto`&&E&&(n===void 0||n))&&(N=typeof n==`string`?n:` (Press ${[`${s.style.key(`space`)} to select`,`${s.style.key(`a`)} to toggle all`,`${s.style.key(`i`)} to invert selection`,`and ${s.style.key(`enter`)} to proceed`].join(`, `)})`,m.length>r&&(s.helpMode===`always`||s.helpMode===`auto`&&l.current)&&(P=`\n${s.style.help(`(Use arrow keys to reveal more choices)`)}`,l.current=!1));let F=j?`\n${s.style.description(j)}`:``,I=``;return O&&(I=`\n${s.style.error(O)}`),`${p} ${A}${N}\n${M}${P}${F}${I}${d.default.cursorHide}`});function E(e){return e.name===`escape`}function D(e){return e.endsWith(f.sep)?e:`${e}${f.sep}`}function O(e){return e.replace(/\x1B\[\d+m/g,``)}function k(e){return e.reduce((e,t)=>Math.max(e,O(t).length),0)}function A(e){return(0,m.readdirSync)(e).map(t=>{let n=(0,f.join)(e,t),r=(0,m.statSync)(n);return Object.assign(r,{name:t,path:n,isDisabled:!1})})}function j(e,t){return e.sort((e,t)=>e.isDisabled&&!t.isDisabled?1:!e.isDisabled&&t.isDisabled||e.isDirectory()&&!t.isDirectory()?-1:!e.isDirectory()&&t.isDirectory()?1:e.name.localeCompare(t.name)).filter(e=>t||!e.isDisabled)}const M={prefix:{idle:p.default.cyan(`?`),done:p.default.green(u.default.tick),canceled:p.default.red(u.default.cross)},icon:{linePrefix:e=>e?`${u.default.lineUpRight}${u.default.line.repeat(2)} `:`${u.default.lineUpDownRight}${u.default.line.repeat(2)} `},style:{disabled:e=>p.default.dim(e),active:e=>p.default.cyan(e),cancelText:e=>p.default.red(e),emptyText:e=>p.default.red(e),directory:e=>p.default.yellow(e),file:e=>p.default.white(e),currentDir:e=>p.default.magenta(e),message:(e,t)=>p.default.bold(e),help:e=>p.default.white(e),key:e=>p.default.cyan(e)}};var N=(0,c.createPrompt)((e,t)=>{let{type:n=`file`,pageSize:r=10,loop:i=!1,showExcluded:a=!1,disabledLabel:o=` (not allowed)`,allowCancel:s=!1,cancelText:l=`Canceled.`,emptyText:d=`Directory is empty.`}=e,[p,m]=(0,c.useState)(`idle`),h=(0,c.makeTheme)(M,e.theme),g=(0,c.usePrefix)({status:p,theme:h}),[_,y]=(0,c.useState)((0,f.resolve)(process.cwd(),e.basePath||`.`)),b=(0,c.useMemo)(()=>{let t=A(_);for(let n of t)n.isDisabled=e.filter?!e.filter(n):!1;return j(t,a)},[_]),x=(0,c.useMemo)(()=>{let e=b.findIndex(e=>!e.isDisabled),t=b.findLastIndex(e=>!e.isDisabled);return e===-1?{first:0,last:0}:{first:e,last:t}},[b]),[S,C]=(0,c.useState)(x.first),w=b[S];(0,c.useKeypress)((e,r)=>{if((0,c.isEnterKey)(e)){if(console.log(w.isDisabled),console.log(n),w.isDisabled||n===`file`&&w.isDirectory()||n===`directory`&&!w.isDirectory())return;m(`done`),t(w.path)}else if((0,c.isSpaceKey)(e)&&w.isDirectory())y(w.path),C(x.first);else if((0,c.isUpKey)(e)||(0,c.isDownKey)(e)){if(r.clearLine(0),i||(0,c.isUpKey)(e)&&S!==x.first||(0,c.isDownKey)(e)&&S!==x.last){let t=(0,c.isUpKey)(e)?-1:1,n=S;do n=(n+t+b.length)%b.length;while(b[n].isDisabled);C(n)}}else (0,c.isBackspaceKey)(e)?(y((0,f.resolve)(_,`..`)),C(x.first)):(E(e)&&s||v(e))&&(m(`canceled`),t(null))});let T=(0,c.usePagination)({items:b,active:S,renderItem({item:e,index:t,isActive:n}){let r=t===b.length-1,i=h.icon.linePrefix(r),a=e.isDirectory()?`${i}${D(e.name)}`:`${i}${e.name}`;if(e.isDisabled)return h.style.disabled(`${a}${o}`);let s=e.isDirectory()?h.style.directory:h.style.file;return(n?h.style.active:s)(a)},pageSize:r,loop:i}),O=h.style.message(e.message,p);if(p===`canceled`)return`${g} ${O} ${h.style.cancelText(l)}`;if(p===`done`)return`${g} ${O} ${h.style.answer(w.path)}`;let N=h.style.currentDir(D(_)),P=(0,c.useMemo)(()=>{let e=[`${h.style.key(u.default.arrowUp+u.default.arrowDown)} navigate, ${h.style.key(`<enter>`)} select${s?`, ${h.style.key(`<esc>`)} cancel`:``}`,`${h.style.key(`<space>`)} open directory, ${h.style.key(`<backspace>`)} go back`],t=k(e);return`${u.default.lineBold.repeat(t)}\n${e.join(`
|
|
2
|
-
|
|
3
|
-
`)
|
|
4
|
-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let l=require("@inquirer/core"),u=require("node:tty");u=c(u,1);let d=require("node:process");d=c(d,1);let f=require("path"),p=require("node:os");p=c(p,1);let m=require("fs"),h=require("vscode-languageserver"),g=require("node:async_hooks");var _=c(o(((e,t)=>{let n=require("node:tty")?.WriteStream?.prototype?.hasColors?.()??!1,r=(e,t)=>{if(!n)return e=>e;let r=`\u001B[${e}m`,i=`\u001B[${t}m`;return e=>{let t=e+``,n=t.indexOf(i);if(n===-1)return r+t+i;let a=r,o=0;for(;n!==-1;)a+=t.slice(o,n)+r,o=n+i.length,n=t.indexOf(i,o);return a+=t.slice(o)+i,a}},i={};i.reset=r(0,0),i.bold=r(1,22),i.dim=r(2,22),i.italic=r(3,23),i.underline=r(4,24),i.overline=r(53,55),i.inverse=r(7,27),i.hidden=r(8,28),i.strikethrough=r(9,29),i.black=r(30,39),i.red=r(31,39),i.green=r(32,39),i.yellow=r(33,39),i.blue=r(34,39),i.magenta=r(35,39),i.cyan=r(36,39),i.white=r(37,39),i.gray=r(90,39),i.bgBlack=r(40,49),i.bgRed=r(41,49),i.bgGreen=r(42,49),i.bgYellow=r(43,49),i.bgBlue=r(44,49),i.bgMagenta=r(45,49),i.bgCyan=r(46,49),i.bgWhite=r(47,49),i.bgGray=r(100,49),i.redBright=r(91,39),i.greenBright=r(92,39),i.yellowBright=r(93,39),i.blueBright=r(94,39),i.magentaBright=r(95,39),i.cyanBright=r(96,39),i.whiteBright=r(97,39),i.bgRedBright=r(101,49),i.bgGreenBright=r(102,49),i.bgYellowBright=r(103,49),i.bgBlueBright=r(104,49),i.bgMagentaBright=r(105,49),i.bgCyanBright=r(106,49),i.bgWhiteBright=r(107,49),t.exports=i}))());function v(){return d.default.platform.startsWith(`win`)?!!d.default.env.CI||!!d.default.env.WT_SESSION||!!d.default.env.TERMINUS_SUBLIME||d.default.env.ConEmuTask===`{cmd::Cmder}`||d.default.env.TERM_PROGRAM===`Terminus-Sublime`||d.default.env.TERM_PROGRAM===`vscode`||d.default.env.TERM===`xterm-256color`||d.default.env.TERM===`alacritty`||d.default.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:d.default.env.TERM!==`linux`}const y={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:`╱`},b={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:`⅒`},x={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`},S={...y,...b},C={...y,...x},w=v()?S:C;Object.entries(b);var T=c(o(((e,t)=>{let n=t.exports;t.exports.default=n;let r=process.env.TERM_PROGRAM===`Apple_Terminal`;n.cursorTo=(e,t)=>{if(typeof e!=`number`)throw TypeError("The `x` argument is required");return typeof t==`number`?`\x1B[`+(t+1)+`;`+(e+1)+`H`:`\x1B[`+(e+1)+`G`},n.cursorMove=(e,t)=>{if(typeof e!=`number`)throw TypeError("The `x` argument is required");let n=``;return e<0?n+=`\x1B[`+-e+`D`:e>0&&(n+=`\x1B[`+e+`C`),t<0?n+=`\x1B[`+-t+`A`:t>0&&(n+=`\x1B[`+t+`B`),n},n.cursorUp=(e=1)=>`\x1B[`+e+`A`,n.cursorDown=(e=1)=>`\x1B[`+e+`B`,n.cursorForward=(e=1)=>`\x1B[`+e+`C`,n.cursorBackward=(e=1)=>`\x1B[`+e+`D`,n.cursorLeft=`\x1B[G`,n.cursorSavePosition=r?`\x1B7`:`\x1B[s`,n.cursorRestorePosition=r?`\x1B8`:`\x1B[u`,n.cursorGetPosition=`\x1B[6n`,n.cursorNextLine=`\x1B[E`,n.cursorPrevLine=`\x1B[F`,n.cursorHide=`\x1B[?25l`,n.cursorShow=`\x1B[?25h`,n.eraseLines=e=>{let t=``;for(let r=0;r<e;r++)t+=n.eraseLine+(r<e-1?n.cursorUp():``);return e&&(t+=n.cursorLeft),t},n.eraseEndLine=`\x1B[K`,n.eraseStartLine=`\x1B[1K`,n.eraseLine=`\x1B[2K`,n.eraseDown=`\x1B[J`,n.eraseUp=`\x1B[1J`,n.eraseScreen=`\x1B[2J`,n.scrollUp=`\x1B[S`,n.scrollDown=`\x1B[T`,n.clearScreen=`\x1Bc`,n.clearTerminal=process.platform===`win32`?`${n.eraseScreen}[0f`:`${n.eraseScreen}[3J[H`,n.beep=`\x07`,n.link=(e,t)=>[`\x1B]`,`8`,`;`,`;`,t,`\x07`,e,`\x1B]`,`8`,`;`,`;`,`\x07`].join(``),n.image=(e,t={})=>{let n=`\x1B]1337;File=inline=1`;return t.width&&(n+=`;width=${t.width}`),t.height&&(n+=`;height=${t.height}`),t.preserveAspectRatio===!1&&(n+=`;preserveAspectRatio=0`),n+`:`+e.toString(`base64`)+`\x07`},n.iTerm={setCwd:(e=process.cwd())=>`]50;CurrentDir=${e}`,annotation:(e,t={})=>{let n=`\x1B]1337;`,r=t.x!==void 0,i=t.y!==void 0;if((r||i)&&!(r&&i&&t.length!==void 0))throw Error("`x`, `y` and `length` must be defined when `x` or `y` is defined");return e=e.replace(/\|/g,``),n+=t.isHidden?`AddHiddenAnnotation=`:`AddAnnotation=`,t.length>0?n+=(r?[e,t.length,t.x,t.y]:[t.length,e]).join(`|`):n+=e,n+`\x07`}}}))());function E(e){return e.name==`l`&&e.ctrl}const ee={icon:{checked:_.default.green(w.circleFilled),unchecked:w.circle,cursor:w.pointer},style:{disabledChoice:e=>_.default.dim(`- ${e}`),renderSelectedChoices:e=>e.map(e=>e.short).join(`, `),description:e=>_.default.cyan(e)},helpMode:`auto`};function D(e){return!l.Separator.isSeparator(e)&&!e.disabled}function O(e){return D(e)&&!!e.checked}function k(e){return D(e)?{...e,checked:!e.checked}:e}function te(e){return function(t){return D(t)?{...t,checked:e}:t}}function ne(e){return e.map(e=>{if(l.Separator.isSeparator(e))return e;if(typeof e==`string`)return{value:e,name:e,short:e,disabled:!1,checked:!1};let t=e.name??String(e.value);return{value:e.value,name:t,short:e.short??t,description:e.description,disabled:e.disabled??!1,checked:e.checked??!1}})}var A=(0,l.createPrompt)((e,t)=>{let{instructions:n,pageSize:r=7,loop:i=!0,required:a,validate:o=()=>!0}=e,s=(0,l.makeTheme)(ee,e.theme),c=(0,l.useRef)(!0),[u,d]=(0,l.useState)(`idle`),f=(0,l.usePrefix)({status:u,theme:s}),[p,m]=(0,l.useState)(ne(e.choices)),h=(0,l.useMemo)(()=>{let e=p.findIndex(D),t=p.findLastIndex(D);if(e===-1)throw new l.ValidationError(`[checkbox prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[p]),[g,_]=(0,l.useState)(h.first),[v,y]=(0,l.useState)(!0),[b,x]=(0,l.useState)();(0,l.useKeypress)(async e=>{if((0,l.isEnterKey)(e)){let e=p.filter(O),n=await o([...e]);a&&!p.some(O)?x(`At least one choice must be selected`):n===!0?(d(`done`),t(e.map(e=>e.value))):x(n||`You must select a valid value`)}else if((0,l.isUpKey)(e)||(0,l.isDownKey)(e)){if(i||(0,l.isUpKey)(e)&&g!==h.first||(0,l.isDownKey)(e)&&g!==h.last){let t=(0,l.isUpKey)(e)?-1:1,n=g;do n=(n+t+p.length)%p.length;while(!D(p[n]));_(n)}}else if((0,l.isSpaceKey)(e))x(void 0),y(!1),m(p.map((e,t)=>t===g?k(e):e));else if(e.name===`a`){let e=p.some(e=>D(e)&&!e.checked);m(p.map(te(e)))}else if(e.name===`i`)m(p.map(k));else if((0,l.isNumberKey)(e)){let t=Number(e.name)-1,n=p[t];n!=null&&D(n)&&(_(t),m(p.map((e,n)=>n===t?k(e):e)))}else E(e)&&(d(`done`),t(null))});let S=s.style.message(e.message,u),C,w=(0,l.usePagination)({items:p,active:g,renderItem({item:e,isActive:t}){if(l.Separator.isSeparator(e))return` ${e.separator}`;if(e.disabled){let t=typeof e.disabled==`string`?e.disabled:`(disabled)`;return s.style.disabledChoice(`${e.name} ${t}`)}t&&(C=e.description);let n=e.checked?s.icon.checked:s.icon.unchecked;return(t?s.style.highlight:e=>e)(`${t?s.icon.cursor:` `}${n} ${e.name}`)},pageSize:r,loop:i});if(u===`done`){let e=p.filter(O);return`${f} ${S} ${s.style.answer(s.style.renderSelectedChoices(e,p))}`}let A=``,j=``;(s.helpMode===`always`||s.helpMode===`auto`&&v&&(n===void 0||n))&&(A=typeof n==`string`?n:` (Press ${[`${s.style.key(`space`)} to select`,`${s.style.key(`a`)} to toggle all`,`${s.style.key(`i`)} to invert selection`,`and ${s.style.key(`enter`)} to proceed`].join(`, `)})`,p.length>r&&(s.helpMode===`always`||s.helpMode===`auto`&&c.current)&&(j=`\n${s.style.help(`(Use arrow keys to reveal more choices)`)}`,c.current=!1));let M=C?`\n${s.style.description(C)}`:``,N=``;return b&&(N=`\n${s.style.error(b)}`),`${f} ${S}${A}\n${w}${j}${M}${N}${T.default.cursorHide}`});const j=(e=0)=>t=>`\u001B[${t+e}m`,M=(e=0)=>t=>`\u001B[${38+e};5;${t}m`,N=(e=0)=>(t,n,r)=>`\u001B[${38+e};2;${t};${n};${r}m`,P={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(P.modifier);const re=Object.keys(P.color),ie=Object.keys(P.bgColor);[...re,...ie];function ae(){let e=new Map;for(let[t,n]of Object.entries(P)){for(let[t,r]of Object.entries(n))P[t]={open:`\u001B[${r[0]}m`,close:`\u001B[${r[1]}m`},n[t]=P[t],e.set(r[0],r[1]);Object.defineProperty(P,t,{value:n,enumerable:!1})}return Object.defineProperty(P,"codes",{value:e,enumerable:!1}),P.color.close=`\x1B[39m`,P.bgColor.close=`\x1B[49m`,P.color.ansi=j(),P.color.ansi256=M(),P.color.ansi16m=N(),P.bgColor.ansi=j(10),P.bgColor.ansi256=M(10),P.bgColor.ansi16m=N(10),Object.defineProperties(P,{rgbToAnsi256:{value(e,t,n){return e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(e){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>P.rgbToAnsi256(...P.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>P.ansi256ToAnsi(P.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>P.ansi256ToAnsi(P.hexToAnsi256(e)),enumerable:!1}}),P}const F=ae();function I(e,t=globalThis.Deno?globalThis.Deno.args:d.default.argv){let n=e.startsWith(`-`)?``:e.length===1?`-`:`--`,r=t.indexOf(n+e),i=t.indexOf(`--`);return r!==-1&&(i===-1||r<i)}const{env:L}=d.default;let R;I(`no-color`)||I(`no-colors`)||I(`color=false`)||I(`color=never`)?R=0:(I(`color`)||I(`colors`)||I(`color=true`)||I(`color=always`))&&(R=1);function oe(){if(`FORCE_COLOR`in L)return L.FORCE_COLOR===`true`?1:L.FORCE_COLOR===`false`?0:L.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(L.FORCE_COLOR,10),3)}function se(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function ce(e,{streamIsTTY:t,sniffFlags:n=!0}={}){let r=oe();r!==void 0&&(R=r);let i=n?R:r;if(i===0)return 0;if(n){if(I(`color=16m`)||I(`color=full`)||I(`color=truecolor`))return 3;if(I(`color=256`))return 2}if(`TF_BUILD`in L&&`AGENT_NAME`in L)return 1;if(e&&!t&&i===void 0)return 0;let a=i||0;if(L.TERM===`dumb`)return a;if(d.default.platform===`win32`){let e=p.default.release().split(`.`);return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if(`CI`in L)return[`GITHUB_ACTIONS`,`GITEA_ACTIONS`,`CIRCLECI`].some(e=>e in L)?3:[`TRAVIS`,`APPVEYOR`,`GITLAB_CI`,`BUILDKITE`,`DRONE`].some(e=>e in L)||L.CI_NAME===`codeship`?1:a;if(`TEAMCITY_VERSION`in L)return+!!/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(L.TEAMCITY_VERSION);if(L.COLORTERM===`truecolor`||L.TERM===`xterm-kitty`||L.TERM===`xterm-ghostty`||L.TERM===`wezterm`)return 3;if(`TERM_PROGRAM`in L){let e=Number.parseInt((L.TERM_PROGRAM_VERSION||``).split(`.`)[0],10);switch(L.TERM_PROGRAM){case`iTerm.app`:return e>=3?3:2;case`Apple_Terminal`:return 2}}return/-256(color)?$/i.test(L.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(L.TERM)||`COLORTERM`in L?1:a}function z(e,t={}){return se(ce(e,{streamIsTTY:e&&e.isTTY,...t}))}const le={stdout:z({isTTY:u.default.isatty(1)}),stderr:z({isTTY:u.default.isatty(2)})};function ue(e,t,n){let r=e.indexOf(t);if(r===-1)return e;let i=t.length,a=0,o=``;do o+=e.slice(a,r)+t+n,a=r+i,r=e.indexOf(t,a);while(r!==-1);return o+=e.slice(a),o}function de(e,t,n,r){let i=0,a=``;do{let o=e[r-1]===`\r`;a+=e.slice(i,o?r-1:r)+t+(o?`\r
|
|
2
|
+
`:`
|
|
3
|
+
`)+n,i=r+1,r=e.indexOf(`
|
|
4
|
+
`,i)}while(r!==-1);return a+=e.slice(i),a}const{stdout:B,stderr:V}=le,H=Symbol(`GENERATOR`),U=Symbol(`STYLER`),W=Symbol(`IS_EMPTY`),G=[`ansi`,`ansi`,`ansi256`,`ansi16m`],K=Object.create(null),fe=(e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw Error("The `level` option should be an integer from 0 to 3");let n=B?B.level:0;e.level=t.level===void 0?n:t.level},pe=e=>{let t=(...e)=>e.join(` `);return fe(t,e),Object.setPrototypeOf(t,q.prototype),t};function q(e){return pe(e)}Object.setPrototypeOf(q.prototype,Function.prototype);for(let[e,t]of Object.entries(F))K[e]={get(){let n=X(this,Y(t.open,t.close,this[U]),this[W]);return Object.defineProperty(this,e,{value:n}),n}};K.visible={get(){let e=X(this,this[U],!0);return Object.defineProperty(this,"visible",{value:e}),e}};const J=(e,t,n,...r)=>e===`rgb`?t===`ansi16m`?F[n].ansi16m(...r):t===`ansi256`?F[n].ansi256(F.rgbToAnsi256(...r)):F[n].ansi(F.rgbToAnsi(...r)):e===`hex`?J(`rgb`,t,n,...F.hexToRgb(...r)):F[n][e](...r);for(let e of[`rgb`,`hex`,`ansi256`]){K[e]={get(){let{level:t}=this;return function(...n){let r=Y(J(e,G[t],`color`,...n),F.color.close,this[U]);return X(this,r,this[W])}}};let t=`bg`+e[0].toUpperCase()+e.slice(1);K[t]={get(){let{level:t}=this;return function(...n){let r=Y(J(e,G[t],`bgColor`,...n),F.bgColor.close,this[U]);return X(this,r,this[W])}}}}const me=Object.defineProperties(()=>{},{...K,level:{enumerable:!0,get(){return this[H].level},set(e){this[H].level=e}}}),Y=(e,t,n)=>{let r,i;return n===void 0?(r=e,i=t):(r=n.openAll+e,i=t+n.closeAll),{open:e,close:t,openAll:r,closeAll:i,parent:n}},X=(e,t,n)=>{let r=(...e)=>he(r,e.length===1?``+e[0]:e.join(` `));return Object.setPrototypeOf(r,me),r[H]=e,r[U]=t,r[W]=n,r},he=(e,t)=>{if(e.level<=0||!t)return e[W]?``:t;let n=e[U];if(n===void 0)return t;let{openAll:r,closeAll:i}=n;if(t.includes(`\x1B`))for(;n!==void 0;)t=ue(t,n.close,n.open),n=n.parent;let a=t.indexOf(`
|
|
5
|
+
`);return a!==-1&&(t=de(t,i,r,a)),r+t+i};Object.defineProperties(q.prototype,K);const Z=q();q({level:V?V.level:0});function ge(e){return e.name===`escape`}function Q(e){return e.endsWith(f.sep)?e:`${e}${f.sep}`}function _e(e){return e.replace(/\x1B\[\d+m/g,``)}function ve(e){return e.reduce((e,t)=>Math.max(e,_e(t).length),0)}function ye(e){return(0,m.readdirSync)(e).map(t=>{let n=(0,f.join)(e,t),r=(0,m.statSync)(n);return Object.assign(r,{name:t,path:n,isDisabled:!1})})}function be(e,t){return e.sort((e,t)=>e.isDisabled&&!t.isDisabled?1:!e.isDisabled&&t.isDisabled||e.isDirectory()&&!t.isDirectory()?-1:!e.isDirectory()&&t.isDirectory()?1:e.name.localeCompare(t.name)).filter(e=>t||!e.isDisabled)}const xe={prefix:{idle:Z.cyan(`?`),done:Z.green(w.tick),canceled:Z.red(w.cross)},icon:{linePrefix:e=>e?`${w.lineUpRight}${w.line.repeat(2)} `:`${w.lineUpDownRight}${w.line.repeat(2)} `},style:{disabled:e=>Z.dim(e),active:e=>Z.cyan(e),cancelText:e=>Z.red(e),emptyText:e=>Z.red(e),directory:e=>Z.yellow(e),file:e=>Z.white(e),currentDir:e=>Z.magenta(e),message:(e,t)=>Z.bold(e),help:e=>Z.white(e),key:e=>Z.cyan(e)}};var Se=(0,l.createPrompt)((e,t)=>{let{type:n=`file`,pageSize:r=10,loop:i=!1,showExcluded:a=!1,disabledLabel:o=` (not allowed)`,allowCancel:s=!1,cancelText:c=`Canceled.`,emptyText:u=`Directory is empty.`}=e,[d,p]=(0,l.useState)(`idle`),m=(0,l.makeTheme)(xe,e.theme),h=(0,l.usePrefix)({status:d,theme:m}),[g,_]=(0,l.useState)((0,f.resolve)(process.cwd(),e.basePath||`.`)),v=(0,l.useMemo)(()=>{let t=ye(g);for(let n of t)n.isDisabled=e.filter?!e.filter(n):!1;return be(t,a)},[g]),y=(0,l.useMemo)(()=>{let e=v.findIndex(e=>!e.isDisabled),t=v.findLastIndex(e=>!e.isDisabled);return e===-1?{first:0,last:0}:{first:e,last:t}},[v]),[b,x]=(0,l.useState)(y.first),S=v[b];(0,l.useKeypress)((e,r)=>{if((0,l.isEnterKey)(e)){if(console.log(S.isDisabled),console.log(n),S.isDisabled||n===`file`&&S.isDirectory()||n===`directory`&&!S.isDirectory())return;p(`done`),t(S.path)}else if((0,l.isSpaceKey)(e)&&S.isDirectory())_(S.path),x(y.first);else if((0,l.isUpKey)(e)||(0,l.isDownKey)(e)){if(r.clearLine(0),i||(0,l.isUpKey)(e)&&b!==y.first||(0,l.isDownKey)(e)&&b!==y.last){let t=(0,l.isUpKey)(e)?-1:1,n=b;do n=(n+t+v.length)%v.length;while(v[n].isDisabled);x(n)}}else (0,l.isBackspaceKey)(e)?(_((0,f.resolve)(g,`..`)),x(y.first)):(ge(e)&&s||E(e))&&(p(`canceled`),t(null))});let C=(0,l.usePagination)({items:v,active:b,renderItem({item:e,index:t,isActive:n}){let r=t===v.length-1,i=m.icon.linePrefix(r),a=e.isDirectory()?`${i}${Q(e.name)}`:`${i}${e.name}`;if(e.isDisabled)return m.style.disabled(`${a}${o}`);let s=e.isDirectory()?m.style.directory:m.style.file;return(n?m.style.active:s)(a)},pageSize:r,loop:i}),T=m.style.message(e.message,d);if(d===`canceled`)return`${h} ${T} ${m.style.cancelText(c)}`;if(d===`done`)return`${h} ${T} ${m.style.answer(S.path)}`;let ee=m.style.currentDir(Q(g)),D=(0,l.useMemo)(()=>{let e=[`${m.style.key(w.arrowUp+w.arrowDown)} navigate, ${m.style.key(`<enter>`)} select${s?`, ${m.style.key(`<esc>`)} cancel`:``}`,`${m.style.key(`<space>`)} open directory, ${m.style.key(`<backspace>`)} go back`],t=ve(e);return`${w.lineBold.repeat(t)}\n${e.join(`
|
|
6
|
+
`)}`},[]);return`${h} ${T}\n${ee}\n${C.length?C:m.style.emptyText(u)}\n${D}[?25l`}),Ce=(0,l.createPrompt)((e,t)=>{let{required:n,validate:r=()=>!0}=e,i=(0,l.makeTheme)(e.theme),[a,o]=(0,l.useState)(`idle`),[s=``,c]=(0,l.useState)(e.default),[u,d]=(0,l.useState)(),[f,p]=(0,l.useState)(``),m=(0,l.usePrefix)({status:a,theme:i});(0,l.useKeypress)(async(e,i)=>{if(a===`idle`)if((0,l.isEnterKey)(e)){let e=f||s;o(`loading`);let a=n&&!e?`You must provide a value`:await r(e);a===!0?(p(e),o(`done`),t(e)):(i.write(f),d(a||`You must provide a valid value`),o(`idle`))}else (0,l.isBackspaceKey)(e)&&!f?c(void 0):e.name===`tab`&&!f?(c(void 0),i.clearLine(0),i.write(s),p(s)):E(e)?(o(`done`),t(null)):(p(i.line),d(void 0))});let h=i.style.message(e.message,a),g=f;typeof e.transformer==`function`?g=e.transformer(f,{isFinal:a===`done`}):a===`done`&&(g=i.style.answer(f));let _;s&&a!==`done`&&!f&&(_=i.style.defaultAnswer(s));let v=``;return u&&(v=i.style.error(u)),[[m,h,_,g].filter(e=>e!==void 0).join(` `),v]}),we=(0,l.createPrompt)((e,t)=>{let[n,r]=(0,l.useState)({...e.errors[``]??{}});(0,l.useEffect)(()=>{let t,n=g.AsyncResource.bind(()=>{r({...e.errors[``]??{}})});return clearTimeout(t),t=setTimeout(()=>{e.refresh(n)},300),()=>{clearTimeout(t),e.stopRefresh(n)}},[e]);let i=(0,l.useMemo)(()=>{let e=[],t=n;for(let n in t)for(let r of t[n]){let t=``;switch(r.severity){case h.DiagnosticSeverity.Error:t=`\x1B[31m[error]\x1B[0m`;break;case h.DiagnosticSeverity.Warning:t=`\x1B[33m[warning]\x1B[0m`;break;case h.DiagnosticSeverity.Information:t=`\x1B[34m[info]\x1B[0m`;break;case h.DiagnosticSeverity.Hint:t=`\x1B[90m[hint]\x1B[0m`;continue}e.push(`${n}:${r.range.start.line+1} - ${t} : ${r.message}`)}return e.length===0?`No error`:e.join(`\r
|
|
7
|
+
`)},[n]);return(0,l.useKeypress)(async(e,n)=>{E(e)&&t()}),i});const Te={icon:{cursor:w.pointer},style:{disabled:e=>_.default.dim(`- ${e}`),description:e=>_.default.cyan(e)},helpMode:`auto`};function $(e){return!l.Separator.isSeparator(e)&&!e.disabled}function Ee(e){return e.map(e=>{if(l.Separator.isSeparator(e))return e;if(typeof e==`string`)return{value:e,name:e,short:e,disabled:!1};let t=e.name??String(e.value);return{value:e.value,name:t,description:e.description,short:e.short??t,disabled:e.disabled??!1}})}var De=(0,l.createPrompt)((e,t)=>{let{loop:n=!0,pageSize:r=7}=e,i=(0,l.useRef)(!0),a=(0,l.makeTheme)(Te,e.theme),[o,s]=(0,l.useState)(`idle`),c=(0,l.usePrefix)({status:o,theme:a}),u=(0,l.useRef)(),d=(0,l.useMemo)(()=>Ee(e.choices),[e.choices]),f=(0,l.useMemo)(()=>{let e=d.findIndex($),t=d.findLastIndex($);if(e===-1)throw new l.ValidationError(`[select prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[d]),p=(0,l.useMemo)(()=>`default`in e?d.findIndex(t=>$(t)&&t.value===e.default):-1,[e.default,d]),[m,h]=(0,l.useState)(p===-1?f.first:p),g=d[m];(0,l.useKeypress)((e,r)=>{if(clearTimeout(u.current),(0,l.isEnterKey)(e))s(`done`),t(g.value);else if((0,l.isUpKey)(e)||(0,l.isDownKey)(e)){if(r.clearLine(0),n||(0,l.isUpKey)(e)&&m!==f.first||(0,l.isDownKey)(e)&&m!==f.last){let t=(0,l.isUpKey)(e)?-1:1,n=m;do n=(n+t+d.length)%d.length;while(!$(d[n]));h(n)}}else if((0,l.isNumberKey)(e)){r.clearLine(0);let t=Number(e.name)-1,n=d[t];n!=null&&$(n)&&h(t)}else if((0,l.isBackspaceKey)(e))r.clearLine(0);else if(E(e))s(`done`),t(null);else{let e=r.line.toLowerCase(),t=d.findIndex(t=>l.Separator.isSeparator(t)||!$(t)?!1:t.name.toLowerCase().startsWith(e));t!==-1&&h(t),u.current=setTimeout(()=>{r.clearLine(0)},700)}}),(0,l.useEffect)(()=>()=>{clearTimeout(u.current)},[]);let _=a.style.message(e.message,o),v=``,y=``;(a.helpMode===`always`||a.helpMode===`auto`&&i.current)&&(i.current=!1,d.length>r?y=`\n${a.style.help(`(Use arrow keys to reveal more choices)`)}`:v=a.style.help(`(Use arrow keys)`));let b=(0,l.usePagination)({items:d,active:m,renderItem({item:e,isActive:t}){if(l.Separator.isSeparator(e))return` ${e.separator}`;if(e.disabled){let t=typeof e.disabled==`string`?e.disabled:`(disabled)`;return a.style.disabled(`${e.name} ${t}`)}return(t?a.style.highlight:e=>e)(`${t?a.icon.cursor:` `} ${e.name}`)},pageSize:r,loop:n});if(o===`done`)return`${c} ${_} ${a.style.answer(g.short)}`;let x=g.description?`\n${a.style.description(g.description)}`:``;return`${[c,_,v].filter(Boolean).join(` `)}\n${b}${y}${x}${T.default.cursorHide}`});const Oe=[` /\\ | | `,` / \\ __ __ ___ _ __ | |_ _ _ ___ `,` / /\\ \\\\ \\ / // _ \\| _ \\ | __|| | | |/ __|`,` / ____ \\\\ V /| __/| | | || |_ | |_| |\\__ \\`,` /_/ \\_\\\\_/ \\___||_| |_| \\__| \\____||___/`];function ke(){console.log(`\x1B[31m`),console.log(Oe.join(`\r
|
|
8
|
+
`)),console.log(`\x1B[0m`)}var Ae=(0,l.createPrompt)((e,t)=>{let{validate:n=()=>!0}=e,r=(0,l.makeTheme)(e.theme),[i,a]=(0,l.useState)(`idle`),[o,s]=(0,l.useState)(),[c,u]=(0,l.useState)(``),d=(0,l.usePrefix)({status:i,theme:r});(0,l.useKeypress)(async(e,r)=>{if(i===`idle`)if((0,l.isEnterKey)(e)){let e=c;a(`loading`);let i=await n(e);i===!0?(u(e),a(`done`),t(e)):(r.write(c),s(i||`You must provide a valid value`),a(`idle`))}else u(r.line),s(void 0)});let f=r.style.message(e.message,i),p=``,m;e.mask?p=(typeof e.mask==`string`?e.mask:`*`).repeat(c.length):i!==`done`&&(m=`${r.style.help(`[input is masked]`)}[?25l`),i===`done`&&(p=r.style.answer(p));let h=``;return o&&(h=r.style.error(o)),[[d,f,e.mask?p:m].join(` `),h]}),je=class{static _server;static get server(){return this._server}static config={clear:!1,printLogo:!1};static clear(){this.config.clear&&console.clear(),this.config.printLogo&&ke()}static async select(e,t){if(t.length==0)return console.error(`No choice available`),null;let n=await De({message:e,choices:t});return this.clear(),n}static async selectMultiple(e,t){let n=await A({message:e,choices:t});return this.clear(),n}static async input(e,t,n){n||=()=>!0,t||=``;let r=await Ce({message:e,default:t,validate:n});return this.clear(),r}static async password(e,t){t||=()=>!0;let n=await Ae({message:e,validate:t});return this.clear(),n}static async tree(e,t,n){let r;t==`directory`&&(r=e=>e.isDirectory());let i=await Se({message:e,basePath:n,type:t,filter:r});return this.clear(),i}static async log(){await we({errors:this.server.getErrors(),refresh:e=>{this.server.subscribeErrors(e)},stopRefresh:e=>{this.server.unsubscribeErrors(e)}})}};exports.RealInteraction=je;
|