@staff0rd/assist 0.788.1 → 0.789.1

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.
@@ -12,16 +12,16 @@ permissions:
12
12
  jobs:
13
13
  review:
14
14
  runs-on: ubuntu-latest
15
- environment: ${{ vars.ASSIST_REVIEW_ENVIRONMENT }}
15
+ environment: ${{ vars.REVIEW_CI_ENVIRONMENT }}
16
16
  env:
17
- ASSIST_REVIEW_PROVIDER: ${{ vars.ASSIST_REVIEW_PROVIDER }}
18
- ASSIST_REVIEW_BASE_URL: ${{ vars.ASSIST_REVIEW_BASE_URL }}
19
- ASSIST_REVIEW_REVIEWER_1: ${{ vars.ASSIST_REVIEW_REVIEWER_1 }}
20
- ASSIST_REVIEW_REVIEWER_2: ${{ vars.ASSIST_REVIEW_REVIEWER_2 }}
21
- ASSIST_REVIEW_SYNTHESIS: ${{ vars.ASSIST_REVIEW_SYNTHESIS }}
22
- ASSIST_REVIEW_AZURE_CLIENT_ID: ${{ vars.ASSIST_REVIEW_AZURE_CLIENT_ID }}
23
- ASSIST_REVIEW_AZURE_TENANT_ID: ${{ vars.ASSIST_REVIEW_AZURE_TENANT_ID }}
24
- ASSIST_REVIEW_API_KEY: ${{ secrets.ASSIST_REVIEW_API_KEY }}
17
+ REVIEW_CI_PROVIDER: ${{ vars.REVIEW_CI_PROVIDER }}
18
+ REVIEW_CI_BASE_URL: ${{ vars.REVIEW_CI_BASE_URL }}
19
+ REVIEW_CI_REVIEWER_1: ${{ vars.REVIEW_CI_REVIEWER_1 }}
20
+ REVIEW_CI_REVIEWER_2: ${{ vars.REVIEW_CI_REVIEWER_2 }}
21
+ REVIEW_CI_SYNTHESIS: ${{ vars.REVIEW_CI_SYNTHESIS }}
22
+ REVIEW_CI_AZURE_CLIENT_ID: ${{ vars.REVIEW_CI_AZURE_CLIENT_ID }}
23
+ REVIEW_CI_AZURE_TENANT_ID: ${{ vars.REVIEW_CI_AZURE_TENANT_ID }}
24
+ REVIEW_CI_API_KEY: ${{ secrets.REVIEW_CI_API_KEY }}
25
25
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26
26
  steps:
27
27
  - name: Checkout
@@ -36,13 +36,17 @@ jobs:
36
36
  node-version: "lts/*"
37
37
 
38
38
  - name: Install Claude Code
39
- if: startsWith(vars.ASSIST_REVIEW_REVIEWER_1, 'claude:') || startsWith(vars.ASSIST_REVIEW_REVIEWER_2, 'claude:') || startsWith(vars.ASSIST_REVIEW_SYNTHESIS, 'claude:')
39
+ if: startsWith(vars.REVIEW_CI_REVIEWER_1, 'claude:') || startsWith(vars.REVIEW_CI_REVIEWER_2, 'claude:') || startsWith(vars.REVIEW_CI_SYNTHESIS, 'claude:')
40
40
  run: npm install -g @anthropic-ai/claude-code
41
41
 
42
42
  - name: Install Codex
43
- if: startsWith(vars.ASSIST_REVIEW_REVIEWER_1, 'codex:') || startsWith(vars.ASSIST_REVIEW_REVIEWER_2, 'codex:') || startsWith(vars.ASSIST_REVIEW_SYNTHESIS, 'codex:')
43
+ if: startsWith(vars.REVIEW_CI_REVIEWER_1, 'codex:') || startsWith(vars.REVIEW_CI_REVIEWER_2, 'codex:') || startsWith(vars.REVIEW_CI_SYNTHESIS, 'codex:')
44
44
  run: npm install -g @openai/codex
45
45
 
46
+ - name: Allow unprivileged user namespaces for the Codex sandbox
47
+ if: startsWith(vars.REVIEW_CI_REVIEWER_1, 'codex:') || startsWith(vars.REVIEW_CI_REVIEWER_2, 'codex:') || startsWith(vars.REVIEW_CI_SYNTHESIS, 'codex:')
48
+ run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
49
+
46
50
  - name: Check review config
47
51
  run: node .github/review-ci/check.mjs
48
52
 
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
2
- var f=["ASSIST_REVIEW_PROVIDER","ASSIST_REVIEW_BASE_URL","ASSIST_REVIEW_REVIEWER_1","ASSIST_REVIEW_REVIEWER_2","ASSIST_REVIEW_SYNTHESIS"];var c="ASSIST_REVIEW_API_KEY",m=["litellm","foundry"],d=["claude","codex"];function E(e,r){if(e==="litellm")return{anthropic:r,responses:`${r}/v1`,anthropicKind:"gateway"};if(e==="foundry")return{anthropic:`${r}/anthropic`,responses:`${r}/openai/v1`,anthropicKind:"foundry"};throw new Error(`Unsupported ASSIST_REVIEW_PROVIDER "${e}" (expected one of: ${m.join(", ")})`)}async function l(e,r,t){try{let i=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...r},body:JSON.stringify(t),signal:AbortSignal.timeout(6e4)});if(i.ok)return;let n=(await i.text()).trim().slice(0,300);return`HTTP ${i.status}${n?`: ${n}`:""}`}catch(i){if(!(i instanceof Error))return String(i);let n=i.cause instanceof Error?i.cause.message:"";return n?`${i.message} (${n})`:i.message}}function A(e,r,t){let i={Authorization:`Bearer ${t}`};return e.auth.kind==="entra"?i:r.anthropicKind==="foundry"?{"x-api-key":t}:{...i,"x-api-key":t}}async function k(e,r,t,i){if(e.harness==="codex"){let s=`${t.responses}/responses`,a=await l(s,{Authorization:`Bearer ${i}`},{model:e.model,input:"ping",max_output_tokens:16});return a&&`Codex model "${e.model}" at ${s}: ${a}`}let n=`${t.anthropic}/v1/messages`,o=await l(n,{...A(r,t,i),"anthropic-version":"2023-06-01"},{model:e.model,max_tokens:1,messages:[{role:"user",content:"ping"}]});return o&&`Claude model "${e.model}" at ${n}: ${o}`}function x(e){let r=new Map;for(let t of Object.values(e.slots))r.set(`${t.harness}:${t.model}`,t);return[...r.values()]}async function S(e,r,t){return(await Promise.all(x(e).map(n=>k(n,e,r,t)))).filter(n=>!!n)}function $(e){return d.includes(e)}function R(e,r){let t=r.indexOf(":"),i=r.slice(0,t).trim(),n=r.slice(t+1).trim();return t===-1||!$(i)||!n?`${e} "${r}" must be ${d.map(o=>`${o}:<model>`).join(" or ")}`:{harness:i,model:n}}function p(e,r){return e==="foundry"&&r("ASSIST_REVIEW_AZURE_CLIENT_ID")?["ASSIST_REVIEW_AZURE_CLIENT_ID","ASSIST_REVIEW_AZURE_TENANT_ID"]:[c]}function w(e,r){return p(e,r).includes(c)?{kind:"key",apiKey:r(c)}:{kind:"entra",clientId:r("ASSIST_REVIEW_AZURE_CLIENT_ID"),tenantId:r("ASSIST_REVIEW_AZURE_TENANT_ID")}}var b={claude:"ASSIST_REVIEW_REVIEWER_1",codex:"ASSIST_REVIEW_REVIEWER_2",synthesis:"ASSIST_REVIEW_SYNTHESIS"};function g(e){let r=s=>e[s]?.trim()??"",t=r("ASSIST_REVIEW_PROVIDER"),i=[...f,...p(t,r)].filter(s=>!r(s));if(i.length>0)return{config:null,errors:i.map(s=>`${s} is not set`)};let n=Object.entries(b).map(([s,a])=>[s,R(a,r(a))]),o=n.flatMap(([,s])=>typeof s=="string"?[s]:[]);return o.length>0?{config:null,errors:o}:{config:{provider:t,baseUrl:r("ASSIST_REVIEW_BASE_URL").replace(/\/+$/,""),slots:Object.fromEntries(n),auth:w(t,r)},errors:o}}var u="https://cognitiveservices.azure.com";var v=3e4;async function C(e,r){if(!e.ok){let t=(await e.text()).trim().slice(0,300);throw new Error(`${r}: HTTP ${e.status}${t?`: ${t}`:""}`)}return await e.json()}async function V(e,r){let t=new URL(e);t.searchParams.set("audience","api://AzureADTokenExchange");let i=await fetch(t,{headers:{Authorization:`bearer ${r}`},signal:AbortSignal.timeout(v)}),n=await C(i,"GitHub OIDC token request failed");if(!n.value)throw new Error("GitHub OIDC token response had no value");return n.value}async function _(e,r,t){let i=await V(t.requestUrl,t.requestToken),n=await fetch(`https://login.microsoftonline.com/${encodeURIComponent(r)}/oauth2/v2.0/token`,{method:"POST",body:new URLSearchParams({grant_type:"client_credentials",client_id:e,scope:`${u}/.default`,client_assertion_type:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer",client_assertion:i}),signal:AbortSignal.timeout(v)}),o=await C(n,`Entra token exchange for client ${e} failed`);if(!o.access_token)throw new Error("Entra token response had no access_token");return o.access_token}import{execFileSync as N}from"node:child_process";function y(e){try{return N("az",["account","get-access-token","--resource",u,"--tenant",e,"--query","accessToken","-o","tsv"],{encoding:"utf8",stdio:["ignore","pipe","pipe"],shell:process.platform==="win32"}).trim()}catch(r){let t=r.stderr?.trim();throw new Error(`az account get-access-token failed for tenant ${e}${t?`: ${t}`:""}; run az login --tenant ${e}`)}}async function I(e,r){if(e.kind==="key")return e.apiKey;let t=r.ACTIONS_ID_TOKEN_REQUEST_URL,i=r.ACTIONS_ID_TOKEN_REQUEST_TOKEN;if(t&&i){let n=await _(e.clientId,e.tenantId,{requestUrl:t,requestToken:i});return console.log(`::add-mask::${n}`),n}if(r.GITHUB_ACTIONS)throw new Error("No GitHub OIDC token endpoint; give the job the id-token: write permission");return y(e.tenantId)}function h(e){return e instanceof Error?e.message:String(e)}async function T(e){let{config:r,errors:t}=g(e);if(!r)return t;let i;try{i=E(r.provider,r.baseUrl)}catch(o){return[h(o)]}let n;try{n=await I(r.auth,e)}catch(o){return[h(o)]}return S(r,i,n)}async function O(){let e=await T(process.env);if(e.length>0){for(let r of e)console.error(`review-ci: ${r}`);process.exit(1)}console.log("review-ci: config is set and every model is reachable")}await O();export{O as reviewCiCheck};
2
+ var f=["REVIEW_CI_PROVIDER","REVIEW_CI_BASE_URL","REVIEW_CI_REVIEWER_1","REVIEW_CI_REVIEWER_2","REVIEW_CI_SYNTHESIS"];var c="REVIEW_CI_API_KEY",C=["litellm","foundry"],d=["claude","codex"];function m(e,r){if(e==="litellm")return{anthropic:r,responses:`${r}/v1`,anthropicKind:"gateway"};if(e==="foundry")return{anthropic:`${r}/anthropic`,responses:`${r}/openai/v1`,anthropicKind:"foundry"};throw new Error(`Unsupported REVIEW_CI_PROVIDER "${e}" (expected one of: ${C.join(", ")})`)}async function l(e,r,t){try{let i=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...r},body:JSON.stringify(t),signal:AbortSignal.timeout(6e4)});if(i.ok)return;let n=(await i.text()).trim().slice(0,300);return`HTTP ${i.status}${n?`: ${n}`:""}`}catch(i){if(!(i instanceof Error))return String(i);let n=i.cause instanceof Error?i.cause.message:"";return n?`${i.message} (${n})`:i.message}}function k(e,r,t){let i={Authorization:`Bearer ${t}`};return e.auth.kind==="entra"?i:r.anthropicKind==="foundry"?{"x-api-key":t}:{...i,"x-api-key":t}}async function x(e,r,t,i){if(e.harness==="codex"){let s=`${t.responses}/responses`,a=await l(s,{Authorization:`Bearer ${i}`},{model:e.model,input:"ping",max_output_tokens:16});return a&&`Codex model "${e.model}" at ${s}: ${a}`}let n=`${t.anthropic}/v1/messages`,o=await l(n,{...k(r,t,i),"anthropic-version":"2023-06-01"},{model:e.model,max_tokens:1,messages:[{role:"user",content:"ping"}]});return o&&`Claude model "${e.model}" at ${n}: ${o}`}function A(e){let r=new Map;for(let t of Object.values(e.slots))r.set(`${t.harness}:${t.model}`,t);return[...r.values()]}async function E(e,r,t){return(await Promise.all(A(e).map(n=>x(n,e,r,t)))).filter(n=>!!n)}function $(e){return d.includes(e)}function R(e,r){let t=r.indexOf(":"),i=r.slice(0,t).trim(),n=r.slice(t+1).trim();return t===-1||!$(i)||!n?`${e} "${r}" must be ${d.map(o=>`${o}:<model>`).join(" or ")}`:{harness:i,model:n}}function p(e,r){return e==="foundry"&&r("REVIEW_CI_AZURE_CLIENT_ID")?["REVIEW_CI_AZURE_CLIENT_ID","REVIEW_CI_AZURE_TENANT_ID"]:[c]}function w(e,r){return p(e,r).includes(c)?{kind:"key",apiKey:r(c)}:{kind:"entra",clientId:r("REVIEW_CI_AZURE_CLIENT_ID"),tenantId:r("REVIEW_CI_AZURE_TENANT_ID")}}var b={claude:"REVIEW_CI_REVIEWER_1",codex:"REVIEW_CI_REVIEWER_2",synthesis:"REVIEW_CI_SYNTHESIS"};function g(e){let r=s=>e[s]?.trim()??"",t=r("REVIEW_CI_PROVIDER"),i=[...f,...p(t,r)].filter(s=>!r(s));if(i.length>0)return{config:null,errors:i.map(s=>`${s} is not set`)};let n=Object.entries(b).map(([s,a])=>[s,R(a,r(a))]),o=n.flatMap(([,s])=>typeof s=="string"?[s]:[]);return o.length>0?{config:null,errors:o}:{config:{provider:t,baseUrl:r("REVIEW_CI_BASE_URL").replace(/\/+$/,""),slots:Object.fromEntries(n),auth:w(t,r)},errors:o}}var u="https://cognitiveservices.azure.com";var v=3e4;async function _(e,r){if(!e.ok){let t=(await e.text()).trim().slice(0,300);throw new Error(`${r}: HTTP ${e.status}${t?`: ${t}`:""}`)}return await e.json()}async function V(e,r){let t=new URL(e);t.searchParams.set("audience","api://AzureADTokenExchange");let i=await fetch(t,{headers:{Authorization:`bearer ${r}`},signal:AbortSignal.timeout(v)}),n=await _(i,"GitHub OIDC token request failed");if(!n.value)throw new Error("GitHub OIDC token response had no value");return n.value}async function y(e,r,t){let i=await V(t.requestUrl,t.requestToken),n=await fetch(`https://login.microsoftonline.com/${encodeURIComponent(r)}/oauth2/v2.0/token`,{method:"POST",body:new URLSearchParams({grant_type:"client_credentials",client_id:e,scope:`${u}/.default`,client_assertion_type:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer",client_assertion:i}),signal:AbortSignal.timeout(v)}),o=await _(n,`Entra token exchange for client ${e} failed`);if(!o.access_token)throw new Error("Entra token response had no access_token");return o.access_token}import{execFileSync as N}from"node:child_process";function I(e){try{return N("az",["account","get-access-token","--resource",u,"--tenant",e,"--query","accessToken","-o","tsv"],{encoding:"utf8",stdio:["ignore","pipe","pipe"],shell:process.platform==="win32"}).trim()}catch(r){let t=r.stderr?.trim();throw new Error(`az account get-access-token failed for tenant ${e}${t?`: ${t}`:""}; run az login --tenant ${e}`)}}async function h(e,r){if(e.kind==="key")return e.apiKey;let t=r.ACTIONS_ID_TOKEN_REQUEST_URL,i=r.ACTIONS_ID_TOKEN_REQUEST_TOKEN;if(t&&i){let n=await y(e.clientId,e.tenantId,{requestUrl:t,requestToken:i});return console.log(`::add-mask::${n}`),n}if(r.GITHUB_ACTIONS)throw new Error("No GitHub OIDC token endpoint; give the job the id-token: write permission");return I(e.tenantId)}function S(e){return e instanceof Error?e.message:String(e)}async function T(e){let{config:r,errors:t}=g(e);if(!r)return t;let i;try{i=m(r.provider,r.baseUrl)}catch(o){return[S(o)]}let n;try{n=await h(r.auth,e)}catch(o){return[S(o)]}return E(r,i,n)}async function O(){let e=await T(process.env);if(e.length>0){for(let r of e)console.error(`review-ci: ${r}`);process.exit(1)}console.log("review-ci: config is set and every model is reachable")}await O();export{O as reviewCiCheck};
@@ -1,34 +1,34 @@
1
1
  import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
2
- var ws=Object.create;var at=Object.defineProperty;var bs=Object.getOwnPropertyDescriptor;var vs=Object.getOwnPropertyNames;var xs=Object.getPrototypeOf,Es=Object.prototype.hasOwnProperty;var X=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var d=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);var Ss=(i,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of vs(e))!Es.call(i,r)&&r!==t&&at(i,r,{get:()=>e[r],enumerable:!(s=bs(e,r))||s.enumerable});return i};var Cs=(i,e,t)=>(t=i!=null?ws(xs(i)):{},Ss(e||!i||!i.__esModule?at(t,"default",{value:i,enumerable:!0}):t,i));var St=d((Bn,G)=>{"use strict";var $s=typeof process<"u"&&process.env.TERM_PROGRAM==="Hyper",Ps=typeof process<"u"&&process.platform==="win32",vt=typeof process<"u"&&process.platform==="linux",pe={ballotDisabled:"\u2612",ballotOff:"\u2610",ballotOn:"\u2611",bullet:"\u2022",bulletWhite:"\u25E6",fullBlock:"\u2588",heart:"\u2764",identicalTo:"\u2261",line:"\u2500",mark:"\u203B",middot:"\xB7",minus:"\uFF0D",multiplication:"\xD7",obelus:"\xF7",pencilDownRight:"\u270E",pencilRight:"\u270F",pencilUpRight:"\u2710",percent:"%",pilcrow2:"\u2761",pilcrow:"\xB6",plusMinus:"\xB1",question:"?",section:"\xA7",starsOff:"\u2606",starsOn:"\u2605",upDownArrow:"\u2195"},xt=Object.assign({},pe,{check:"\u221A",cross:"\xD7",ellipsisLarge:"...",ellipsis:"...",info:"i",questionSmall:"?",pointer:">",pointerSmall:"\xBB",radioOff:"( )",radioOn:"(*)",warning:"\u203C"}),Et=Object.assign({},pe,{ballotCross:"\u2718",check:"\u2714",cross:"\u2716",ellipsisLarge:"\u22EF",ellipsis:"\u2026",info:"\u2139",questionFull:"\uFF1F",questionSmall:"\uFE56",pointer:vt?"\u25B8":"\u276F",pointerSmall:vt?"\u2023":"\u203A",radioOff:"\u25EF",radioOn:"\u25C9",warning:"\u26A0"});G.exports=Ps&&!$s?xt:Et;Reflect.defineProperty(G.exports,"common",{enumerable:!1,value:pe});Reflect.defineProperty(G.exports,"windows",{enumerable:!1,value:xt});Reflect.defineProperty(G.exports,"other",{enumerable:!1,value:Et})});var se=d((Nn,fe)=>{"use strict";var Os=i=>i!==null&&typeof i=="object"&&!Array.isArray(i),Vs=/[\u001b\u009b][[\]#;?()]*(?:(?:(?:[^\W_]*;?[^\W_]*)\u0007)|(?:(?:[0-9]{1,4}(;[0-9]{0,4})*)?[~0-9=<>cf-nqrtyA-PRZ]))/g,js=()=>typeof process<"u"?process.env.FORCE_COLOR!=="0":!1,Ct=()=>{let i={enabled:js(),visible:!0,styles:{},keys:{}},e=n=>{let a=n.open=`\x1B[${n.codes[0]}m`,l=n.close=`\x1B[${n.codes[1]}m`,o=n.regex=new RegExp(`\\u001b\\[${n.codes[1]}m`,"g");return n.wrap=(h,c)=>{h.includes(l)&&(h=h.replace(o,l+a));let u=a+h+l;return c?u.replace(/\r*\n/g,`${l}$&${a}`):u},n},t=(n,a,l)=>typeof n=="function"?n(a):n.wrap(a,l),s=(n,a)=>{if(n===""||n==null)return"";if(i.enabled===!1)return n;if(i.visible===!1)return"";let l=""+n,o=l.includes(`
3
- `),h=a.length;for(h>0&&a.includes("unstyle")&&(a=[...new Set(["unstyle",...a])].reverse());h-- >0;)l=t(i.styles[a[h]],l,o);return l},r=(n,a,l)=>{i.styles[n]=e({name:n,codes:a}),(i.keys[l]||(i.keys[l]=[])).push(n),Reflect.defineProperty(i,n,{configurable:!0,enumerable:!0,set(h){i.alias(n,h)},get(){let h=c=>s(c,h.stack);return Reflect.setPrototypeOf(h,i),h.stack=this.stack?this.stack.concat(n):[n],h}})};return r("reset",[0,0],"modifier"),r("bold",[1,22],"modifier"),r("dim",[2,22],"modifier"),r("italic",[3,23],"modifier"),r("underline",[4,24],"modifier"),r("inverse",[7,27],"modifier"),r("hidden",[8,28],"modifier"),r("strikethrough",[9,29],"modifier"),r("black",[30,39],"color"),r("red",[31,39],"color"),r("green",[32,39],"color"),r("yellow",[33,39],"color"),r("blue",[34,39],"color"),r("magenta",[35,39],"color"),r("cyan",[36,39],"color"),r("white",[37,39],"color"),r("gray",[90,39],"color"),r("grey",[90,39],"color"),r("bgBlack",[40,49],"bg"),r("bgRed",[41,49],"bg"),r("bgGreen",[42,49],"bg"),r("bgYellow",[43,49],"bg"),r("bgBlue",[44,49],"bg"),r("bgMagenta",[45,49],"bg"),r("bgCyan",[46,49],"bg"),r("bgWhite",[47,49],"bg"),r("blackBright",[90,39],"bright"),r("redBright",[91,39],"bright"),r("greenBright",[92,39],"bright"),r("yellowBright",[93,39],"bright"),r("blueBright",[94,39],"bright"),r("magentaBright",[95,39],"bright"),r("cyanBright",[96,39],"bright"),r("whiteBright",[97,39],"bright"),r("bgBlackBright",[100,49],"bgBright"),r("bgRedBright",[101,49],"bgBright"),r("bgGreenBright",[102,49],"bgBright"),r("bgYellowBright",[103,49],"bgBright"),r("bgBlueBright",[104,49],"bgBright"),r("bgMagentaBright",[105,49],"bgBright"),r("bgCyanBright",[106,49],"bgBright"),r("bgWhiteBright",[107,49],"bgBright"),i.ansiRegex=Vs,i.hasColor=i.hasAnsi=n=>(i.ansiRegex.lastIndex=0,typeof n=="string"&&n!==""&&i.ansiRegex.test(n)),i.alias=(n,a)=>{let l=typeof a=="string"?i[a]:a;if(typeof l!="function")throw new TypeError("Expected alias to be the name of an existing color (string) or a function");l.stack||(Reflect.defineProperty(l,"name",{value:n}),i.styles[n]=l,l.stack=[n]),Reflect.defineProperty(i,n,{configurable:!0,enumerable:!0,set(o){i.alias(n,o)},get(){let o=h=>s(h,o.stack);return Reflect.setPrototypeOf(o,i),o.stack=this.stack?this.stack.concat(l.stack):l.stack,o}})},i.theme=n=>{if(!Os(n))throw new TypeError("Expected theme to be an object");for(let a of Object.keys(n))i.alias(a,n[a]);return i},i.alias("unstyle",n=>typeof n=="string"&&n!==""?(i.ansiRegex.lastIndex=0,n.replace(i.ansiRegex,"")):""),i.alias("noop",n=>n),i.none=i.clear=i.noop,i.stripColor=i.unstyle,i.symbols=St(),i.define=r,i};fe.exports=Ct();fe.exports.create=Ct});var _=d(g=>{"use strict";var Ds=Object.prototype.toString,q=se(),Rt=!1,Y=new Set,_t={yellow:"blue",cyan:"red",green:"magenta",black:"white",blue:"yellow",red:"cyan",magenta:"green",white:"black"};g.longest=(i,e)=>i.reduce((t,s)=>Math.max(t,e?s[e].length:s.length),0);g.hasColor=i=>!!i&&q.hasColor(i);var re=g.isObject=i=>i!==null&&typeof i=="object"&&!Array.isArray(i);g.nativeType=i=>Ds.call(i).slice(8,-1).toLowerCase().replace(/\s/g,"");g.isAsyncFn=i=>g.nativeType(i)==="asyncfunction";g.isPrimitive=i=>i!=null&&typeof i!="object"&&typeof i!="function";g.resolve=(i,e,...t)=>typeof e=="function"?e.call(i,...t):e;g.scrollDown=(i=[])=>[...i.slice(1),i[0]];g.scrollUp=(i=[])=>[i.pop(),...i];g.reorder=(i=[])=>{let e=i.slice();return e.sort((t,s)=>t.index>s.index?1:t.index<s.index?-1:0),e};g.swap=(i,e,t)=>{let s=i.length,r=t===s?0:t<0?s-1:t,n=i[e];i[e]=i[r],i[r]=n};g.width=(i,e=80)=>{let t=i&&i.columns?i.columns:e;return i&&typeof i.getWindowSize=="function"&&(t=i.getWindowSize()[0]),process.platform==="win32"?t-1:t};g.height=(i,e=20)=>{let t=i&&i.rows?i.rows:e;return i&&typeof i.getWindowSize=="function"&&(t=i.getWindowSize()[1]),t};g.wordWrap=(i,e={})=>{if(!i)return i;typeof e=="number"&&(e={width:e});let{indent:t="",newline:s=`
4
- `+t,width:r=80}=e,n=(s+t).match(/[^\S\n]/g)||[];r-=n.length;let a=`.{1,${r}}([\\s\\u200B]+|$)|[^\\s\\u200B]+?([\\s\\u200B]+|$)`,l=i.trim(),o=new RegExp(a,"g"),h=l.match(o)||[];return h=h.map(c=>c.replace(/\n$/,"")),e.padEnd&&(h=h.map(c=>c.padEnd(r," "))),e.padStart&&(h=h.map(c=>c.padStart(r," "))),t+h.join(s)};g.unmute=i=>{let e=i.stack.find(s=>q.keys.color.includes(s));return e?q[e]:i.stack.find(s=>s.slice(2)==="bg")?q[e.slice(2)]:s=>s};g.pascal=i=>i?i[0].toUpperCase()+i.slice(1):"";g.inverse=i=>{if(!i||!i.stack)return i;let e=i.stack.find(s=>q.keys.color.includes(s));if(e){let s=q["bg"+g.pascal(e)];return s?s.black:i}let t=i.stack.find(s=>s.slice(0,2)==="bg");return t?q[t.slice(2).toLowerCase()]||i:q.none};g.complement=i=>{if(!i||!i.stack)return i;let e=i.stack.find(s=>q.keys.color.includes(s)),t=i.stack.find(s=>s.slice(0,2)==="bg");if(e&&!t)return q[_t[e]||e];if(t){let s=t.slice(2).toLowerCase(),r=_t[s];return r&&q["bg"+g.pascal(r)]||i}return q.none};g.meridiem=i=>{let e=i.getHours(),t=i.getMinutes(),s=e>=12?"pm":"am";e=e%12;let r=e===0?12:e,n=t<10?"0"+t:t;return r+":"+n+" "+s};g.set=(i={},e="",t)=>e.split(".").reduce((s,r,n,a)=>{let l=a.length-1>n?s[r]||{}:t;return!g.isObject(l)&&n<a.length-1&&(l={}),s[r]=l},i);g.get=(i={},e="",t)=>{let s=i[e]==null?e.split(".").reduce((r,n)=>r&&r[n],i):i[e];return s??t};g.mixin=(i,e)=>{if(!re(i))return e;if(!re(e))return i;for(let t of Object.keys(e)){let s=Object.getOwnPropertyDescriptor(e,t);if(hasOwnProperty.call(s,"value"))if(hasOwnProperty.call(i,t)&&re(s.value)){let r=Object.getOwnPropertyDescriptor(i,t);re(r.value)&&r.value!==s.value?i[t]=g.merge({},i[t],e[t]):Reflect.defineProperty(i,t,s)}else Reflect.defineProperty(i,t,s);else Reflect.defineProperty(i,t,s)}return i};g.merge=(...i)=>{let e={};for(let t of i)g.mixin(e,t);return e};g.mixinEmitter=(i,e)=>{let t=e.constructor.prototype;for(let s of Object.keys(t)){let r=t[s];typeof r=="function"?g.define(i,s,r.bind(e)):g.define(i,s,r)}};var ne=(i,e)=>{Rt||(Rt=!0,Y.forEach(t=>t()),i===!0&&process.exit(128+e))},It=ne.bind(null,!0,15),kt=ne.bind(null,!0,2);g.onExit=i=>(Y.size===0&&(process.once("SIGTERM",It),process.once("SIGINT",kt),process.once("exit",ne)),Y.add(i),()=>{Y.delete(i),Y.size===0&&(process.off("SIGTERM",It),process.off("SIGINT",kt),process.off("exit",ne))});g.define=(i,e,t)=>{Reflect.defineProperty(i,e,{value:t})};g.defineExport=(i,e,t)=>{let s;Reflect.defineProperty(i,e,{enumerable:!0,configurable:!0,set(r){s=r},get(){return s?s():t()}})}});var Tt=d((Mn,At)=>{"use strict";At.exports=({onlyFirst:i=!1}={})=>{let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(e,i?void 0:"g")}});var V=d((Ln,qt)=>{"use strict";var Bs=Tt();qt.exports=i=>typeof i=="string"?i.replace(Bs(),""):i});var $t=d(K=>{"use strict";K.ctrl={a:"first",b:"backward",c:"cancel",d:"deleteForward",e:"last",f:"forward",g:"reset",i:"tab",k:"cutForward",l:"reset",n:"newItem",m:"cancel",j:"submit",p:"search",r:"remove",s:"save",u:"undo",w:"cutLeft",x:"toggleCursor",v:"paste"};K.shift={up:"shiftUp",down:"shiftDown",left:"shiftLeft",right:"shiftRight",tab:"prev"};K.fn={up:"pageUp",down:"pageDown",left:"pageLeft",right:"pageRight",delete:"deleteForward"};K.option={b:"backward",f:"forward",d:"cutRight",left:"cutLeft",up:"altUp",down:"altDown"};K.keys={pageup:"pageUp",pagedown:"pageDown",home:"home",end:"end",cancel:"cancel",delete:"deleteForward",backspace:"delete",down:"down",enter:"submit",escape:"cancel",left:"left",space:"space",number:"number",return:"submit",right:"right",tab:"next",up:"up"}});var Ot=d((Un,Pt)=>{"use strict";Pt.exports=class{_queue=[];_executing=!1;_jobRunner=null;constructor(e){this._jobRunner=e}enqueue=(...e)=>{this._queue.push(e),this._dequeue()};destroy(){this._queue.length=0,this._jobRunner=null}_dequeue(){this._executing||!this._queue.length||(this._executing=!0,this._jobRunner(...this._queue.shift()),setTimeout(()=>{this._executing=!1,this._dequeue()}))}}});var me=d((Hn,jt)=>{"use strict";var Vt=X("readline"),Ns=$t(),Ws=Ot(),Ms=/^(?:\x1b)([a-zA-Z0-9])$/,Ls=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,zs={OP:"f1",OQ:"f2",OR:"f3",OS:"f4","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[A":"up","[B":"down","[C":"right","[D":"left","[E":"clear","[F":"end","[H":"home",OA:"up",OB:"down",OC:"right",OD:"left",OE:"clear",OF:"end",OH:"home","[1~":"home","[2~":"insert","[3~":"delete","[4~":"end","[5~":"pageup","[6~":"pagedown","[[5~":"pageup","[[6~":"pagedown","[7~":"home","[8~":"end","[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end",Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end","[Z":"tab"};function Ks(i){return["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(i)}function Us(i){return["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(i)}var ae=(i="",e={})=>{let t,s={name:e.name,ctrl:!1,meta:!1,shift:!1,option:!1,sequence:i,raw:i,...e};if(Buffer.isBuffer(i)?i[0]>127&&i[1]===void 0?(i[0]-=128,i="\x1B"+String(i)):i=String(i):i!==void 0&&typeof i!="string"?i=String(i):i||(i=s.sequence||""),s.sequence=s.sequence||i||s.name,i==="\r")s.raw=void 0,s.name="return";else if(i===`
5
- `)s.name="enter";else if(i===" ")s.name="tab";else if(i==="\b"||i==="\x7F"||i==="\x1B\x7F"||i==="\x1B\b")s.name="backspace",s.meta=i.charAt(0)==="\x1B";else if(i==="\x1B"||i==="\x1B\x1B")s.name="escape",s.meta=i.length===2;else if(i===" "||i==="\x1B ")s.name="space",s.meta=i.length===2;else if(i<="")s.name=String.fromCharCode(i.charCodeAt(0)+97-1),s.ctrl=!0;else if(i.length===1&&i>="0"&&i<="9")s.name="number";else if(i.length===1&&i>="a"&&i<="z")s.name=i;else if(i.length===1&&i>="A"&&i<="Z")s.name=i.toLowerCase(),s.shift=!0;else if(t=Ms.exec(i))s.meta=!0,s.shift=/^[A-Z]$/.test(t[1]);else if(t=Ls.exec(i)){let r=[...i];r[0]==="\x1B"&&r[1]==="\x1B"&&(s.option=!0);let n=[t[1],t[2],t[4],t[6]].filter(Boolean).join(""),a=(t[3]||t[5]||1)-1;s.ctrl=!!(a&4),s.meta=!!(a&10),s.shift=!!(a&1),s.code=n,s.name=zs[n],s.shift=Ks(n)||s.shift,s.ctrl=Us(n)||s.ctrl}return s};ae.listen=(i={},e)=>{let{stdin:t}=i;if(!t||t!==process.stdin&&!t.isTTY)throw new Error("Invalid stream passed");let s=Vt.createInterface({terminal:!0,input:t});Vt.emitKeypressEvents(t,s);let r=new Ws((l,o)=>e(l,ae(l,o),s)),n=t.isRaw;return t.isTTY&&t.setRawMode(!0),t.on("keypress",r.enqueue),s.resume(),()=>{t.isTTY&&t.setRawMode(n),t.removeListener("keypress",r.enqueue),r.destroy(),s.pause(),s.close()}};ae.action=(i,e,t)=>{let s={...Ns,...t};return e.ctrl?(e.action=s.ctrl[e.name],e):e.option&&s.option?(e.action=s.option[e.name],e):e.shift?(e.action=s.shift[e.name],e):(e.action=s.keys[e.name],e)};jt.exports=ae});var Bt=d((Zn,Dt)=>{"use strict";Dt.exports=i=>{i.timers=i.timers||{};let e=i.options.timers;if(e)for(let t of Object.keys(e)){let s=e[t];typeof s=="number"&&(s={interval:s}),Hs(i,t,s)}};function Hs(i,e,t={}){let s=i.timers[e]={name:e,start:Date.now(),ms:0,tick:0},r=t.interval||120;s.frames=t.frames||[],s.loading=!0;let n=setInterval(()=>{s.ms=Date.now()-s.start,s.tick++,i.render()},r);return s.stop=()=>{s.loading=!1,clearInterval(n)},Reflect.defineProperty(s,"interval",{value:n}),i.once("close",()=>s.stop()),s.stop}});var Wt=d((Fn,Nt)=>{"use strict";var{define:Zs,width:Fs}=_(),ge=class{constructor(e){let t=e.options;Zs(this,"_prompt",e),this.type=e.type,this.name=e.name,this.message="",this.header="",this.footer="",this.error="",this.hint="",this.input="",this.cursor=0,this.index=0,this.lines=0,this.tick=0,this.prompt="",this.buffer="",this.width=Fs(t.stdout||process.stdout),Object.assign(this,t),this.name=this.name||this.message,this.message=this.message||this.name,this.symbols=e.symbols,this.styles=e.styles,this.required=new Set,this.cancelled=!1,this.submitted=!1}clone(){let e={...this};return e.status=this.status,e.buffer=Buffer.from(e.buffer),delete e.clone,e}set color(e){this._color=e}get color(){let e=this.prompt.styles;if(this.cancelled)return e.cancelled;if(this.submitted)return e.submitted;let t=this._color||e[this.status];return typeof t=="function"?t:e.pending}set loading(e){this._loading=e}get loading(){return typeof this._loading=="boolean"?this._loading:this.loadingChoices?"choices":!1}get status(){return this.cancelled?"cancelled":this.submitted?"submitted":"pending"}};Nt.exports=ge});var Lt=d((Gn,Mt)=>{"use strict";var ye=_(),R=se(),we={default:R.noop,noop:R.noop,set inverse(i){this._inverse=i},get inverse(){return this._inverse||ye.inverse(this.primary)},set complement(i){this._complement=i},get complement(){return this._complement||ye.complement(this.primary)},primary:R.cyan,success:R.green,danger:R.magenta,strong:R.bold,warning:R.yellow,muted:R.dim,disabled:R.gray,dark:R.dim.gray,underline:R.underline,set info(i){this._info=i},get info(){return this._info||this.primary},set em(i){this._em=i},get em(){return this._em||this.primary.underline},set heading(i){this._heading=i},get heading(){return this._heading||this.muted.underline},set pending(i){this._pending=i},get pending(){return this._pending||this.primary},set submitted(i){this._submitted=i},get submitted(){return this._submitted||this.success},set cancelled(i){this._cancelled=i},get cancelled(){return this._cancelled||this.danger},set typing(i){this._typing=i},get typing(){return this._typing||this.dim},set placeholder(i){this._placeholder=i},get placeholder(){return this._placeholder||this.primary.dim},set highlight(i){this._highlight=i},get highlight(){return this._highlight||this.inverse}};we.merge=(i={})=>{i.styles&&typeof i.styles.enabled=="boolean"&&(R.enabled=i.styles.enabled),i.styles&&typeof i.styles.visible=="boolean"&&(R.visible=i.styles.visible);let e=ye.merge({},we,i.styles);delete e.merge;for(let t of Object.keys(R))hasOwnProperty.call(e,t)||Reflect.defineProperty(e,t,{get:()=>R[t]});for(let t of Object.keys(R.styles))hasOwnProperty.call(e,t)||Reflect.defineProperty(e,t,{get:()=>R[t]});return e};Mt.exports=we});var Kt=d((Yn,zt)=>{"use strict";var be=process.platform==="win32",O=se(),Gs=_(),ve={...O.symbols,upDownDoubleArrow:"\u21D5",upDownDoubleArrow2:"\u2B0D",upDownArrow:"\u2195",asterisk:"*",asterism:"\u2042",bulletWhite:"\u25E6",electricArrow:"\u2301",ellipsisLarge:"\u22EF",ellipsisSmall:"\u2026",fullBlock:"\u2588",identicalTo:"\u2261",indicator:O.symbols.check,leftAngle:"\u2039",mark:"\u203B",minus:"\u2212",multiplication:"\xD7",obelus:"\xF7",percent:"%",pilcrow:"\xB6",pilcrow2:"\u2761",pencilUpRight:"\u2710",pencilDownRight:"\u270E",pencilRight:"\u270F",plus:"+",plusMinus:"\xB1",pointRight:"\u261E",rightAngle:"\u203A",section:"\xA7",hexagon:{off:"\u2B21",on:"\u2B22",disabled:"\u2B22"},ballot:{on:"\u2611",off:"\u2610",disabled:"\u2612"},stars:{on:"\u2605",off:"\u2606",disabled:"\u2606"},folder:{on:"\u25BC",off:"\u25B6",disabled:"\u25B6"},prefix:{pending:O.symbols.question,submitted:O.symbols.check,cancelled:O.symbols.cross},separator:{pending:O.symbols.pointerSmall,submitted:O.symbols.middot,cancelled:O.symbols.middot},radio:{off:be?"( )":"\u25EF",on:be?"(*)":"\u25C9",disabled:be?"(|)":"\u24BE"},numbers:["\u24EA","\u2460","\u2461","\u2462","\u2463","\u2464","\u2465","\u2466","\u2467","\u2468","\u2469","\u246A","\u246B","\u246C","\u246D","\u246E","\u246F","\u2470","\u2471","\u2472","\u2473","\u3251","\u3252","\u3253","\u3254","\u3255","\u3256","\u3257","\u3258","\u3259","\u325A","\u325B","\u325C","\u325D","\u325E","\u325F","\u32B1","\u32B2","\u32B3","\u32B4","\u32B5","\u32B6","\u32B7","\u32B8","\u32B9","\u32BA","\u32BB","\u32BC","\u32BD","\u32BE","\u32BF"]};ve.merge=i=>{let e=Gs.merge({},O.symbols,ve,i.symbols);return delete e.merge,e};zt.exports=ve});var Ht=d((Jn,Ut)=>{"use strict";var Ys=Lt(),Js=Kt(),Qs=_();Ut.exports=i=>{i.options=Qs.merge({},i.options.theme,i.options),i.symbols=Js.merge(i.options),i.styles=Ys.merge(i.options)}});var Jt=d((Gt,Yt)=>{"use strict";var Zt=process.env.TERM_PROGRAM==="Apple_Terminal",Xs=V(),xe=_(),$=Yt.exports=Gt,b="\x1B[",Ft="\x07",Ee=!1,j=$.code={bell:Ft,beep:Ft,beginning:`${b}G`,down:`${b}J`,esc:b,getPosition:`${b}6n`,hide:`${b}?25l`,line:`${b}2K`,lineEnd:`${b}K`,lineStart:`${b}1K`,restorePosition:b+(Zt?"8":"u"),savePosition:b+(Zt?"7":"s"),screen:`${b}2J`,show:`${b}?25h`,up:`${b}1J`},N=$.cursor={get hidden(){return Ee},hide(){return Ee=!0,j.hide},show(){return Ee=!1,j.show},forward:(i=1)=>`${b}${i}C`,backward:(i=1)=>`${b}${i}D`,nextLine:(i=1)=>`${b}E`.repeat(i),prevLine:(i=1)=>`${b}F`.repeat(i),up:(i=1)=>i?`${b}${i}A`:"",down:(i=1)=>i?`${b}${i}B`:"",right:(i=1)=>i?`${b}${i}C`:"",left:(i=1)=>i?`${b}${i}D`:"",to(i,e){return e?`${b}${e+1};${i+1}H`:`${b}${i+1}G`},move(i=0,e=0){let t="";return t+=i<0?N.left(-i):i>0?N.right(i):"",t+=e<0?N.up(-e):e>0?N.down(e):"",t},strLen(i){for(var e=0,t=i.length,s=-1,r=0;r<t;r++)s=i.charCodeAt(r),s>=0&&s<=128?e+=1:e+=2;return e},restore(i={}){let{after:e,cursor:t,initial:s,input:r,prompt:n,size:a,value:l}=i;if(s=xe.isPrimitive(s)?String(s):"",r=xe.isPrimitive(r)?String(r):"",l=xe.isPrimitive(l)?String(l):"",a){let o=$.cursor.up(a)+$.cursor.to(this.strLen(n)),h=r.length-t;return h>0&&(o+=$.cursor.left(h)),o}if(l||e){let o=!r&&s?-this.strLen(s):-this.strLen(r)+t;return e&&(o-=this.strLen(e)),r===""&&s&&!n.includes(s)&&(o+=this.strLen(s)),$.cursor.move(o)}}},Se=$.erase={screen:j.screen,up:j.up,down:j.down,line:j.line,lineEnd:j.lineEnd,lineStart:j.lineStart,lines(i){let e="";for(let t=0;t<i;t++)e+=$.erase.line+(t<i-1?$.cursor.up(1):"");return i&&(e+=$.code.beginning),e}};$.clear=(i="",e=process.stdout.columns)=>{if(!e)return Se.line+N.to(0);let t=n=>[...Xs(n)].length,s=i.split(/\r?\n/),r=0;for(let n of s)r+=1+Math.floor(Math.max(t(n)-1,0)/e);return(Se.line+N.prevLine()).repeat(r-1)+Se.line+N.to(0)}});var U=d((Qn,Xt)=>{"use strict";var er=X("events"),Qt=V(),Ce=me(),tr=Bt(),ir=Wt(),sr=Ht(),k=_(),W=Jt(),Re=class i extends er{constructor(e={}){super(),this.name=e.name,this.type=e.type,this.options=e,sr(this),tr(this),this.state=new ir(this),this.initial=[e.initial,e.default].find(t=>t!=null),this.stdout=e.stdout||process.stdout,this.stdin=e.stdin||process.stdin,this.scale=e.scale||1,this.term=this.options.term||process.env.TERM_PROGRAM,this.margin=nr(this.options.margin),this.setMaxListeners(0),rr(this)}async keypress(e,t={}){this.keypressed=!0;let s=Ce.action(e,Ce(e,t),this.options.actions);this.state.keypress=s,this.emit("keypress",e,s),this.emit("state",this.state.clone());let r=this.options[s.action]||this[s.action]||this.dispatch;if(typeof r=="function")return await r.call(this,e,s);this.alert()}alert(){delete this.state.alert,this.options.show===!1?this.emit("alert"):this.stdout.write(W.code.beep)}cursorHide(){this.stdout.write(W.cursor.hide());let e=k.onExit(()=>this.cursorShow());this.on("close",()=>{this.cursorShow(),e()})}cursorShow(){this.stdout.write(W.cursor.show())}write(e){e&&(this.stdout&&this.state.show!==!1&&this.stdout.write(e),this.state.buffer+=e)}clear(e=0){let t=this.state.buffer;this.state.buffer="",!(!t&&!e||this.options.show===!1)&&this.stdout.write(W.cursor.down(e)+W.clear(t,this.width))}restore(){if(this.state.closed||this.options.show===!1)return;let{prompt:e,after:t,rest:s}=this.sections(),{cursor:r,initial:n="",input:a="",value:l=""}=this,o=this.state.size=s.length,h={after:t,cursor:r,initial:n,input:a,prompt:e,size:o,value:l},c=W.cursor.restore(h);c&&this.stdout.write(c)}sections(){let{buffer:e,input:t,prompt:s}=this.state;s=Qt(s);let r=Qt(e),n=r.indexOf(s),a=r.slice(0,n),o=r.slice(n).split(`
2
+ var ws=Object.create;var lt=Object.defineProperty;var bs=Object.getOwnPropertyDescriptor;var vs=Object.getOwnPropertyNames;var xs=Object.getPrototypeOf,Es=Object.prototype.hasOwnProperty;var X=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var d=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);var Cs=(i,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of vs(e))!Es.call(i,r)&&r!==t&&lt(i,r,{get:()=>e[r],enumerable:!(s=bs(e,r))||s.enumerable});return i};var Rs=(i,e,t)=>(t=i!=null?ws(xs(i)):{},Cs(e||!i||!i.__esModule?lt(t,"default",{value:i,enumerable:!0}):t,i));var Rt=d((Wn,G)=>{"use strict";var $s=typeof process<"u"&&process.env.TERM_PROGRAM==="Hyper",Ts=typeof process<"u"&&process.platform==="win32",xt=typeof process<"u"&&process.platform==="linux",pe={ballotDisabled:"\u2612",ballotOff:"\u2610",ballotOn:"\u2611",bullet:"\u2022",bulletWhite:"\u25E6",fullBlock:"\u2588",heart:"\u2764",identicalTo:"\u2261",line:"\u2500",mark:"\u203B",middot:"\xB7",minus:"\uFF0D",multiplication:"\xD7",obelus:"\xF7",pencilDownRight:"\u270E",pencilRight:"\u270F",pencilUpRight:"\u2710",percent:"%",pilcrow2:"\u2761",pilcrow:"\xB6",plusMinus:"\xB1",question:"?",section:"\xA7",starsOff:"\u2606",starsOn:"\u2605",upDownArrow:"\u2195"},Et=Object.assign({},pe,{check:"\u221A",cross:"\xD7",ellipsisLarge:"...",ellipsis:"...",info:"i",questionSmall:"?",pointer:">",pointerSmall:"\xBB",radioOff:"( )",radioOn:"(*)",warning:"\u203C"}),Ct=Object.assign({},pe,{ballotCross:"\u2718",check:"\u2714",cross:"\u2716",ellipsisLarge:"\u22EF",ellipsis:"\u2026",info:"\u2139",questionFull:"\uFF1F",questionSmall:"\uFE56",pointer:xt?"\u25B8":"\u276F",pointerSmall:xt?"\u2023":"\u203A",radioOff:"\u25EF",radioOn:"\u25C9",warning:"\u26A0"});G.exports=Ts&&!$s?Et:Ct;Reflect.defineProperty(G.exports,"common",{enumerable:!1,value:pe});Reflect.defineProperty(G.exports,"windows",{enumerable:!1,value:Et});Reflect.defineProperty(G.exports,"other",{enumerable:!1,value:Ct})});var se=d((Bn,fe)=>{"use strict";var Os=i=>i!==null&&typeof i=="object"&&!Array.isArray(i),Vs=/[\u001b\u009b][[\]#;?()]*(?:(?:(?:[^\W_]*;?[^\W_]*)\u0007)|(?:(?:[0-9]{1,4}(;[0-9]{0,4})*)?[~0-9=<>cf-nqrtyA-PRZ]))/g,Ds=()=>typeof process<"u"?process.env.FORCE_COLOR!=="0":!1,_t=()=>{let i={enabled:Ds(),visible:!0,styles:{},keys:{}},e=n=>{let a=n.open=`\x1B[${n.codes[0]}m`,l=n.close=`\x1B[${n.codes[1]}m`,o=n.regex=new RegExp(`\\u001b\\[${n.codes[1]}m`,"g");return n.wrap=(h,c)=>{h.includes(l)&&(h=h.replace(o,l+a));let u=a+h+l;return c?u.replace(/\r*\n/g,`${l}$&${a}`):u},n},t=(n,a,l)=>typeof n=="function"?n(a):n.wrap(a,l),s=(n,a)=>{if(n===""||n==null)return"";if(i.enabled===!1)return n;if(i.visible===!1)return"";let l=""+n,o=l.includes(`
3
+ `),h=a.length;for(h>0&&a.includes("unstyle")&&(a=[...new Set(["unstyle",...a])].reverse());h-- >0;)l=t(i.styles[a[h]],l,o);return l},r=(n,a,l)=>{i.styles[n]=e({name:n,codes:a}),(i.keys[l]||(i.keys[l]=[])).push(n),Reflect.defineProperty(i,n,{configurable:!0,enumerable:!0,set(h){i.alias(n,h)},get(){let h=c=>s(c,h.stack);return Reflect.setPrototypeOf(h,i),h.stack=this.stack?this.stack.concat(n):[n],h}})};return r("reset",[0,0],"modifier"),r("bold",[1,22],"modifier"),r("dim",[2,22],"modifier"),r("italic",[3,23],"modifier"),r("underline",[4,24],"modifier"),r("inverse",[7,27],"modifier"),r("hidden",[8,28],"modifier"),r("strikethrough",[9,29],"modifier"),r("black",[30,39],"color"),r("red",[31,39],"color"),r("green",[32,39],"color"),r("yellow",[33,39],"color"),r("blue",[34,39],"color"),r("magenta",[35,39],"color"),r("cyan",[36,39],"color"),r("white",[37,39],"color"),r("gray",[90,39],"color"),r("grey",[90,39],"color"),r("bgBlack",[40,49],"bg"),r("bgRed",[41,49],"bg"),r("bgGreen",[42,49],"bg"),r("bgYellow",[43,49],"bg"),r("bgBlue",[44,49],"bg"),r("bgMagenta",[45,49],"bg"),r("bgCyan",[46,49],"bg"),r("bgWhite",[47,49],"bg"),r("blackBright",[90,39],"bright"),r("redBright",[91,39],"bright"),r("greenBright",[92,39],"bright"),r("yellowBright",[93,39],"bright"),r("blueBright",[94,39],"bright"),r("magentaBright",[95,39],"bright"),r("cyanBright",[96,39],"bright"),r("whiteBright",[97,39],"bright"),r("bgBlackBright",[100,49],"bgBright"),r("bgRedBright",[101,49],"bgBright"),r("bgGreenBright",[102,49],"bgBright"),r("bgYellowBright",[103,49],"bgBright"),r("bgBlueBright",[104,49],"bgBright"),r("bgMagentaBright",[105,49],"bgBright"),r("bgCyanBright",[106,49],"bgBright"),r("bgWhiteBright",[107,49],"bgBright"),i.ansiRegex=Vs,i.hasColor=i.hasAnsi=n=>(i.ansiRegex.lastIndex=0,typeof n=="string"&&n!==""&&i.ansiRegex.test(n)),i.alias=(n,a)=>{let l=typeof a=="string"?i[a]:a;if(typeof l!="function")throw new TypeError("Expected alias to be the name of an existing color (string) or a function");l.stack||(Reflect.defineProperty(l,"name",{value:n}),i.styles[n]=l,l.stack=[n]),Reflect.defineProperty(i,n,{configurable:!0,enumerable:!0,set(o){i.alias(n,o)},get(){let o=h=>s(h,o.stack);return Reflect.setPrototypeOf(o,i),o.stack=this.stack?this.stack.concat(l.stack):l.stack,o}})},i.theme=n=>{if(!Os(n))throw new TypeError("Expected theme to be an object");for(let a of Object.keys(n))i.alias(a,n[a]);return i},i.alias("unstyle",n=>typeof n=="string"&&n!==""?(i.ansiRegex.lastIndex=0,n.replace(i.ansiRegex,"")):""),i.alias("noop",n=>n),i.none=i.clear=i.noop,i.stripColor=i.unstyle,i.symbols=Rt(),i.define=r,i};fe.exports=_t();fe.exports.create=_t});var I=d(g=>{"use strict";var js=Object.prototype.toString,P=se(),It=!1,Y=new Set,St={yellow:"blue",cyan:"red",green:"magenta",black:"white",blue:"yellow",red:"cyan",magenta:"green",white:"black"};g.longest=(i,e)=>i.reduce((t,s)=>Math.max(t,e?s[e].length:s.length),0);g.hasColor=i=>!!i&&P.hasColor(i);var re=g.isObject=i=>i!==null&&typeof i=="object"&&!Array.isArray(i);g.nativeType=i=>js.call(i).slice(8,-1).toLowerCase().replace(/\s/g,"");g.isAsyncFn=i=>g.nativeType(i)==="asyncfunction";g.isPrimitive=i=>i!=null&&typeof i!="object"&&typeof i!="function";g.resolve=(i,e,...t)=>typeof e=="function"?e.call(i,...t):e;g.scrollDown=(i=[])=>[...i.slice(1),i[0]];g.scrollUp=(i=[])=>[i.pop(),...i];g.reorder=(i=[])=>{let e=i.slice();return e.sort((t,s)=>t.index>s.index?1:t.index<s.index?-1:0),e};g.swap=(i,e,t)=>{let s=i.length,r=t===s?0:t<0?s-1:t,n=i[e];i[e]=i[r],i[r]=n};g.width=(i,e=80)=>{let t=i&&i.columns?i.columns:e;return i&&typeof i.getWindowSize=="function"&&(t=i.getWindowSize()[0]),process.platform==="win32"?t-1:t};g.height=(i,e=20)=>{let t=i&&i.rows?i.rows:e;return i&&typeof i.getWindowSize=="function"&&(t=i.getWindowSize()[1]),t};g.wordWrap=(i,e={})=>{if(!i)return i;typeof e=="number"&&(e={width:e});let{indent:t="",newline:s=`
4
+ `+t,width:r=80}=e,n=(s+t).match(/[^\S\n]/g)||[];r-=n.length;let a=`.{1,${r}}([\\s\\u200B]+|$)|[^\\s\\u200B]+?([\\s\\u200B]+|$)`,l=i.trim(),o=new RegExp(a,"g"),h=l.match(o)||[];return h=h.map(c=>c.replace(/\n$/,"")),e.padEnd&&(h=h.map(c=>c.padEnd(r," "))),e.padStart&&(h=h.map(c=>c.padStart(r," "))),t+h.join(s)};g.unmute=i=>{let e=i.stack.find(s=>P.keys.color.includes(s));return e?P[e]:i.stack.find(s=>s.slice(2)==="bg")?P[e.slice(2)]:s=>s};g.pascal=i=>i?i[0].toUpperCase()+i.slice(1):"";g.inverse=i=>{if(!i||!i.stack)return i;let e=i.stack.find(s=>P.keys.color.includes(s));if(e){let s=P["bg"+g.pascal(e)];return s?s.black:i}let t=i.stack.find(s=>s.slice(0,2)==="bg");return t?P[t.slice(2).toLowerCase()]||i:P.none};g.complement=i=>{if(!i||!i.stack)return i;let e=i.stack.find(s=>P.keys.color.includes(s)),t=i.stack.find(s=>s.slice(0,2)==="bg");if(e&&!t)return P[St[e]||e];if(t){let s=t.slice(2).toLowerCase(),r=St[s];return r&&P["bg"+g.pascal(r)]||i}return P.none};g.meridiem=i=>{let e=i.getHours(),t=i.getMinutes(),s=e>=12?"pm":"am";e=e%12;let r=e===0?12:e,n=t<10?"0"+t:t;return r+":"+n+" "+s};g.set=(i={},e="",t)=>e.split(".").reduce((s,r,n,a)=>{let l=a.length-1>n?s[r]||{}:t;return!g.isObject(l)&&n<a.length-1&&(l={}),s[r]=l},i);g.get=(i={},e="",t)=>{let s=i[e]==null?e.split(".").reduce((r,n)=>r&&r[n],i):i[e];return s??t};g.mixin=(i,e)=>{if(!re(i))return e;if(!re(e))return i;for(let t of Object.keys(e)){let s=Object.getOwnPropertyDescriptor(e,t);if(hasOwnProperty.call(s,"value"))if(hasOwnProperty.call(i,t)&&re(s.value)){let r=Object.getOwnPropertyDescriptor(i,t);re(r.value)&&r.value!==s.value?i[t]=g.merge({},i[t],e[t]):Reflect.defineProperty(i,t,s)}else Reflect.defineProperty(i,t,s);else Reflect.defineProperty(i,t,s)}return i};g.merge=(...i)=>{let e={};for(let t of i)g.mixin(e,t);return e};g.mixinEmitter=(i,e)=>{let t=e.constructor.prototype;for(let s of Object.keys(t)){let r=t[s];typeof r=="function"?g.define(i,s,r.bind(e)):g.define(i,s,r)}};var ne=(i,e)=>{It||(It=!0,Y.forEach(t=>t()),i===!0&&process.exit(128+e))},kt=ne.bind(null,!0,15),At=ne.bind(null,!0,2);g.onExit=i=>(Y.size===0&&(process.once("SIGTERM",kt),process.once("SIGINT",At),process.once("exit",ne)),Y.add(i),()=>{Y.delete(i),Y.size===0&&(process.off("SIGTERM",kt),process.off("SIGINT",At),process.off("exit",ne))});g.define=(i,e,t)=>{Reflect.defineProperty(i,e,{value:t})};g.defineExport=(i,e,t)=>{let s;Reflect.defineProperty(i,e,{enumerable:!0,configurable:!0,set(r){s=r},get(){return s?s():t()}})}});var Pt=d((Mn,qt)=>{"use strict";qt.exports=({onlyFirst:i=!1}={})=>{let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(e,i?void 0:"g")}});var V=d((zn,$t)=>{"use strict";var Ns=Pt();$t.exports=i=>typeof i=="string"?i.replace(Ns(),""):i});var Tt=d(K=>{"use strict";K.ctrl={a:"first",b:"backward",c:"cancel",d:"deleteForward",e:"last",f:"forward",g:"reset",i:"tab",k:"cutForward",l:"reset",n:"newItem",m:"cancel",j:"submit",p:"search",r:"remove",s:"save",u:"undo",w:"cutLeft",x:"toggleCursor",v:"paste"};K.shift={up:"shiftUp",down:"shiftDown",left:"shiftLeft",right:"shiftRight",tab:"prev"};K.fn={up:"pageUp",down:"pageDown",left:"pageLeft",right:"pageRight",delete:"deleteForward"};K.option={b:"backward",f:"forward",d:"cutRight",left:"cutLeft",up:"altUp",down:"altDown"};K.keys={pageup:"pageUp",pagedown:"pageDown",home:"home",end:"end",cancel:"cancel",delete:"deleteForward",backspace:"delete",down:"down",enter:"submit",escape:"cancel",left:"left",space:"space",number:"number",return:"submit",right:"right",tab:"next",up:"up"}});var Vt=d((Hn,Ot)=>{"use strict";Ot.exports=class{_queue=[];_executing=!1;_jobRunner=null;constructor(e){this._jobRunner=e}enqueue=(...e)=>{this._queue.push(e),this._dequeue()};destroy(){this._queue.length=0,this._jobRunner=null}_dequeue(){this._executing||!this._queue.length||(this._executing=!0,this._jobRunner(...this._queue.shift()),setTimeout(()=>{this._executing=!1,this._dequeue()}))}}});var me=d((Zn,jt)=>{"use strict";var Dt=X("readline"),Ws=Tt(),Bs=Vt(),Ls=/^(?:\x1b)([a-zA-Z0-9])$/,Ms=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,zs={OP:"f1",OQ:"f2",OR:"f3",OS:"f4","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[A":"up","[B":"down","[C":"right","[D":"left","[E":"clear","[F":"end","[H":"home",OA:"up",OB:"down",OC:"right",OD:"left",OE:"clear",OF:"end",OH:"home","[1~":"home","[2~":"insert","[3~":"delete","[4~":"end","[5~":"pageup","[6~":"pagedown","[[5~":"pageup","[[6~":"pagedown","[7~":"home","[8~":"end","[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end",Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end","[Z":"tab"};function Ks(i){return["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(i)}function Us(i){return["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(i)}var ae=(i="",e={})=>{let t,s={name:e.name,ctrl:!1,meta:!1,shift:!1,option:!1,sequence:i,raw:i,...e};if(Buffer.isBuffer(i)?i[0]>127&&i[1]===void 0?(i[0]-=128,i="\x1B"+String(i)):i=String(i):i!==void 0&&typeof i!="string"?i=String(i):i||(i=s.sequence||""),s.sequence=s.sequence||i||s.name,i==="\r")s.raw=void 0,s.name="return";else if(i===`
5
+ `)s.name="enter";else if(i===" ")s.name="tab";else if(i==="\b"||i==="\x7F"||i==="\x1B\x7F"||i==="\x1B\b")s.name="backspace",s.meta=i.charAt(0)==="\x1B";else if(i==="\x1B"||i==="\x1B\x1B")s.name="escape",s.meta=i.length===2;else if(i===" "||i==="\x1B ")s.name="space",s.meta=i.length===2;else if(i<="")s.name=String.fromCharCode(i.charCodeAt(0)+97-1),s.ctrl=!0;else if(i.length===1&&i>="0"&&i<="9")s.name="number";else if(i.length===1&&i>="a"&&i<="z")s.name=i;else if(i.length===1&&i>="A"&&i<="Z")s.name=i.toLowerCase(),s.shift=!0;else if(t=Ls.exec(i))s.meta=!0,s.shift=/^[A-Z]$/.test(t[1]);else if(t=Ms.exec(i)){let r=[...i];r[0]==="\x1B"&&r[1]==="\x1B"&&(s.option=!0);let n=[t[1],t[2],t[4],t[6]].filter(Boolean).join(""),a=(t[3]||t[5]||1)-1;s.ctrl=!!(a&4),s.meta=!!(a&10),s.shift=!!(a&1),s.code=n,s.name=zs[n],s.shift=Ks(n)||s.shift,s.ctrl=Us(n)||s.ctrl}return s};ae.listen=(i={},e)=>{let{stdin:t}=i;if(!t||t!==process.stdin&&!t.isTTY)throw new Error("Invalid stream passed");let s=Dt.createInterface({terminal:!0,input:t});Dt.emitKeypressEvents(t,s);let r=new Bs((l,o)=>e(l,ae(l,o),s)),n=t.isRaw;return t.isTTY&&t.setRawMode(!0),t.on("keypress",r.enqueue),s.resume(),()=>{t.isTTY&&t.setRawMode(n),t.removeListener("keypress",r.enqueue),r.destroy(),s.pause(),s.close()}};ae.action=(i,e,t)=>{let s={...Ws,...t};return e.ctrl?(e.action=s.ctrl[e.name],e):e.option&&s.option?(e.action=s.option[e.name],e):e.shift?(e.action=s.shift[e.name],e):(e.action=s.keys[e.name],e)};jt.exports=ae});var Wt=d((Fn,Nt)=>{"use strict";Nt.exports=i=>{i.timers=i.timers||{};let e=i.options.timers;if(e)for(let t of Object.keys(e)){let s=e[t];typeof s=="number"&&(s={interval:s}),Hs(i,t,s)}};function Hs(i,e,t={}){let s=i.timers[e]={name:e,start:Date.now(),ms:0,tick:0},r=t.interval||120;s.frames=t.frames||[],s.loading=!0;let n=setInterval(()=>{s.ms=Date.now()-s.start,s.tick++,i.render()},r);return s.stop=()=>{s.loading=!1,clearInterval(n)},Reflect.defineProperty(s,"interval",{value:n}),i.once("close",()=>s.stop()),s.stop}});var Lt=d((Gn,Bt)=>{"use strict";var{define:Zs,width:Fs}=I(),ge=class{constructor(e){let t=e.options;Zs(this,"_prompt",e),this.type=e.type,this.name=e.name,this.message="",this.header="",this.footer="",this.error="",this.hint="",this.input="",this.cursor=0,this.index=0,this.lines=0,this.tick=0,this.prompt="",this.buffer="",this.width=Fs(t.stdout||process.stdout),Object.assign(this,t),this.name=this.name||this.message,this.message=this.message||this.name,this.symbols=e.symbols,this.styles=e.styles,this.required=new Set,this.cancelled=!1,this.submitted=!1}clone(){let e={...this};return e.status=this.status,e.buffer=Buffer.from(e.buffer),delete e.clone,e}set color(e){this._color=e}get color(){let e=this.prompt.styles;if(this.cancelled)return e.cancelled;if(this.submitted)return e.submitted;let t=this._color||e[this.status];return typeof t=="function"?t:e.pending}set loading(e){this._loading=e}get loading(){return typeof this._loading=="boolean"?this._loading:this.loadingChoices?"choices":!1}get status(){return this.cancelled?"cancelled":this.submitted?"submitted":"pending"}};Bt.exports=ge});var zt=d((Yn,Mt)=>{"use strict";var ye=I(),_=se(),we={default:_.noop,noop:_.noop,set inverse(i){this._inverse=i},get inverse(){return this._inverse||ye.inverse(this.primary)},set complement(i){this._complement=i},get complement(){return this._complement||ye.complement(this.primary)},primary:_.cyan,success:_.green,danger:_.magenta,strong:_.bold,warning:_.yellow,muted:_.dim,disabled:_.gray,dark:_.dim.gray,underline:_.underline,set info(i){this._info=i},get info(){return this._info||this.primary},set em(i){this._em=i},get em(){return this._em||this.primary.underline},set heading(i){this._heading=i},get heading(){return this._heading||this.muted.underline},set pending(i){this._pending=i},get pending(){return this._pending||this.primary},set submitted(i){this._submitted=i},get submitted(){return this._submitted||this.success},set cancelled(i){this._cancelled=i},get cancelled(){return this._cancelled||this.danger},set typing(i){this._typing=i},get typing(){return this._typing||this.dim},set placeholder(i){this._placeholder=i},get placeholder(){return this._placeholder||this.primary.dim},set highlight(i){this._highlight=i},get highlight(){return this._highlight||this.inverse}};we.merge=(i={})=>{i.styles&&typeof i.styles.enabled=="boolean"&&(_.enabled=i.styles.enabled),i.styles&&typeof i.styles.visible=="boolean"&&(_.visible=i.styles.visible);let e=ye.merge({},we,i.styles);delete e.merge;for(let t of Object.keys(_))hasOwnProperty.call(e,t)||Reflect.defineProperty(e,t,{get:()=>_[t]});for(let t of Object.keys(_.styles))hasOwnProperty.call(e,t)||Reflect.defineProperty(e,t,{get:()=>_[t]});return e};Mt.exports=we});var Ut=d((Jn,Kt)=>{"use strict";var be=process.platform==="win32",O=se(),Gs=I(),ve={...O.symbols,upDownDoubleArrow:"\u21D5",upDownDoubleArrow2:"\u2B0D",upDownArrow:"\u2195",asterisk:"*",asterism:"\u2042",bulletWhite:"\u25E6",electricArrow:"\u2301",ellipsisLarge:"\u22EF",ellipsisSmall:"\u2026",fullBlock:"\u2588",identicalTo:"\u2261",indicator:O.symbols.check,leftAngle:"\u2039",mark:"\u203B",minus:"\u2212",multiplication:"\xD7",obelus:"\xF7",percent:"%",pilcrow:"\xB6",pilcrow2:"\u2761",pencilUpRight:"\u2710",pencilDownRight:"\u270E",pencilRight:"\u270F",plus:"+",plusMinus:"\xB1",pointRight:"\u261E",rightAngle:"\u203A",section:"\xA7",hexagon:{off:"\u2B21",on:"\u2B22",disabled:"\u2B22"},ballot:{on:"\u2611",off:"\u2610",disabled:"\u2612"},stars:{on:"\u2605",off:"\u2606",disabled:"\u2606"},folder:{on:"\u25BC",off:"\u25B6",disabled:"\u25B6"},prefix:{pending:O.symbols.question,submitted:O.symbols.check,cancelled:O.symbols.cross},separator:{pending:O.symbols.pointerSmall,submitted:O.symbols.middot,cancelled:O.symbols.middot},radio:{off:be?"( )":"\u25EF",on:be?"(*)":"\u25C9",disabled:be?"(|)":"\u24BE"},numbers:["\u24EA","\u2460","\u2461","\u2462","\u2463","\u2464","\u2465","\u2466","\u2467","\u2468","\u2469","\u246A","\u246B","\u246C","\u246D","\u246E","\u246F","\u2470","\u2471","\u2472","\u2473","\u3251","\u3252","\u3253","\u3254","\u3255","\u3256","\u3257","\u3258","\u3259","\u325A","\u325B","\u325C","\u325D","\u325E","\u325F","\u32B1","\u32B2","\u32B3","\u32B4","\u32B5","\u32B6","\u32B7","\u32B8","\u32B9","\u32BA","\u32BB","\u32BC","\u32BD","\u32BE","\u32BF"]};ve.merge=i=>{let e=Gs.merge({},O.symbols,ve,i.symbols);return delete e.merge,e};Kt.exports=ve});var Zt=d((Qn,Ht)=>{"use strict";var Ys=zt(),Js=Ut(),Qs=I();Ht.exports=i=>{i.options=Qs.merge({},i.options.theme,i.options),i.symbols=Js.merge(i.options),i.styles=Ys.merge(i.options)}});var Qt=d((Yt,Jt)=>{"use strict";var Ft=process.env.TERM_PROGRAM==="Apple_Terminal",Xs=V(),xe=I(),$=Jt.exports=Yt,b="\x1B[",Gt="\x07",Ee=!1,D=$.code={bell:Gt,beep:Gt,beginning:`${b}G`,down:`${b}J`,esc:b,getPosition:`${b}6n`,hide:`${b}?25l`,line:`${b}2K`,lineEnd:`${b}K`,lineStart:`${b}1K`,restorePosition:b+(Ft?"8":"u"),savePosition:b+(Ft?"7":"s"),screen:`${b}2J`,show:`${b}?25h`,up:`${b}1J`},W=$.cursor={get hidden(){return Ee},hide(){return Ee=!0,D.hide},show(){return Ee=!1,D.show},forward:(i=1)=>`${b}${i}C`,backward:(i=1)=>`${b}${i}D`,nextLine:(i=1)=>`${b}E`.repeat(i),prevLine:(i=1)=>`${b}F`.repeat(i),up:(i=1)=>i?`${b}${i}A`:"",down:(i=1)=>i?`${b}${i}B`:"",right:(i=1)=>i?`${b}${i}C`:"",left:(i=1)=>i?`${b}${i}D`:"",to(i,e){return e?`${b}${e+1};${i+1}H`:`${b}${i+1}G`},move(i=0,e=0){let t="";return t+=i<0?W.left(-i):i>0?W.right(i):"",t+=e<0?W.up(-e):e>0?W.down(e):"",t},strLen(i){for(var e=0,t=i.length,s=-1,r=0;r<t;r++)s=i.charCodeAt(r),s>=0&&s<=128?e+=1:e+=2;return e},restore(i={}){let{after:e,cursor:t,initial:s,input:r,prompt:n,size:a,value:l}=i;if(s=xe.isPrimitive(s)?String(s):"",r=xe.isPrimitive(r)?String(r):"",l=xe.isPrimitive(l)?String(l):"",a){let o=$.cursor.up(a)+$.cursor.to(this.strLen(n)),h=r.length-t;return h>0&&(o+=$.cursor.left(h)),o}if(l||e){let o=!r&&s?-this.strLen(s):-this.strLen(r)+t;return e&&(o-=this.strLen(e)),r===""&&s&&!n.includes(s)&&(o+=this.strLen(s)),$.cursor.move(o)}}},Ce=$.erase={screen:D.screen,up:D.up,down:D.down,line:D.line,lineEnd:D.lineEnd,lineStart:D.lineStart,lines(i){let e="";for(let t=0;t<i;t++)e+=$.erase.line+(t<i-1?$.cursor.up(1):"");return i&&(e+=$.code.beginning),e}};$.clear=(i="",e=process.stdout.columns)=>{if(!e)return Ce.line+W.to(0);let t=n=>[...Xs(n)].length,s=i.split(/\r?\n/),r=0;for(let n of s)r+=1+Math.floor(Math.max(t(n)-1,0)/e);return(Ce.line+W.prevLine()).repeat(r-1)+Ce.line+W.to(0)}});var U=d((Xn,ei)=>{"use strict";var er=X("events"),Xt=V(),Re=me(),tr=Wt(),ir=Lt(),sr=Zt(),k=I(),B=Qt(),_e=class i extends er{constructor(e={}){super(),this.name=e.name,this.type=e.type,this.options=e,sr(this),tr(this),this.state=new ir(this),this.initial=[e.initial,e.default].find(t=>t!=null),this.stdout=e.stdout||process.stdout,this.stdin=e.stdin||process.stdin,this.scale=e.scale||1,this.term=this.options.term||process.env.TERM_PROGRAM,this.margin=nr(this.options.margin),this.setMaxListeners(0),rr(this)}async keypress(e,t={}){this.keypressed=!0;let s=Re.action(e,Re(e,t),this.options.actions);this.state.keypress=s,this.emit("keypress",e,s),this.emit("state",this.state.clone());let r=this.options[s.action]||this[s.action]||this.dispatch;if(typeof r=="function")return await r.call(this,e,s);this.alert()}alert(){delete this.state.alert,this.options.show===!1?this.emit("alert"):this.stdout.write(B.code.beep)}cursorHide(){this.stdout.write(B.cursor.hide());let e=k.onExit(()=>this.cursorShow());this.on("close",()=>{this.cursorShow(),e()})}cursorShow(){this.stdout.write(B.cursor.show())}write(e){e&&(this.stdout&&this.state.show!==!1&&this.stdout.write(e),this.state.buffer+=e)}clear(e=0){let t=this.state.buffer;this.state.buffer="",!(!t&&!e||this.options.show===!1)&&this.stdout.write(B.cursor.down(e)+B.clear(t,this.width))}restore(){if(this.state.closed||this.options.show===!1)return;let{prompt:e,after:t,rest:s}=this.sections(),{cursor:r,initial:n="",input:a="",value:l=""}=this,o=this.state.size=s.length,h={after:t,cursor:r,initial:n,input:a,prompt:e,size:o,value:l},c=B.cursor.restore(h);c&&this.stdout.write(c)}sections(){let{buffer:e,input:t,prompt:s}=this.state;s=Xt(s);let r=Xt(e),n=r.indexOf(s),a=r.slice(0,n),o=r.slice(n).split(`
6
6
  `),h=o[0],c=o[o.length-1],v=(s+(t?" "+t:"")).length,y=v<h.length?h.slice(v+1):"";return{header:a,prompt:h,after:y,rest:o.slice(1),last:c}}async submit(){this.state.submitted=!0,this.state.validating=!0,this.options.onSubmit&&await this.options.onSubmit.call(this,this.name,this.value,this);let e=this.state.error||await this.validate(this.value,this.state);if(e!==!0){let t=`
7
7
  `+this.symbols.pointer+" ";typeof e=="string"?t+=e.trim():t+="Invalid input",this.state.error=`
8
- `+this.styles.danger(t),this.state.submitted=!1,await this.render(),await this.alert(),this.state.validating=!1,this.state.error=void 0;return}this.state.validating=!1,await this.render(),await this.close(),this.value=await this.result(this.value),this.emit("submit",this.value)}async cancel(e){this.state.cancelled=this.state.submitted=!0,await this.render(),await this.close(),typeof this.options.onCancel=="function"&&await this.options.onCancel.call(this,this.name,this.value,this),this.emit("cancel",await this.error(e))}async close(){this.state.closed=!0;try{let e=this.sections(),t=Math.ceil(e.prompt.length/this.width);e.rest&&this.write(W.cursor.down(e.rest.length)),this.write(`
9
- `.repeat(t))}catch{}this.emit("close")}start(){!this.stop&&this.options.show!==!1&&(this.stop=Ce.listen(this,this.keypress.bind(this)),this.once("close",this.stop),this.emit("start",this))}async skip(){return this.skipped=this.options.skip===!0,typeof this.options.skip=="function"&&(this.skipped=await this.options.skip.call(this,this.name,this.value)),this.skipped}async initialize(){let{format:e,options:t,result:s}=this;if(this.format=()=>e.call(this,this.value),this.result=()=>s.call(this,this.value),typeof t.initial=="function"&&(this.initial=await t.initial.call(this,this)),typeof t.onRun=="function"&&await t.onRun.call(this,this),typeof t.onSubmit=="function"){let r=t.onSubmit.bind(this),n=this.submit.bind(this);delete this.options.onSubmit,this.submit=async()=>(await r(this.name,this.value,this),n())}await this.start(),await this.render()}render(){throw new Error("expected prompt to have a custom render method")}run(){return new Promise(async(e,t)=>{if(this.once("submit",e),this.once("cancel",t),await this.skip())return this.render=()=>{},this.submit();await this.initialize(),this.emit("run")})}async element(e,t,s){let{options:r,state:n,symbols:a,timers:l}=this,o=l&&l[e];n.timer=o;let h=r[e]||n[e]||a[e],c=t&&t[e]!=null?t[e]:await h;if(c==="")return c;let u=await this.resolve(c,n,t,s);return!u&&t&&t[e]?this.resolve(h,n,t,s):u}async prefix(){let e=await this.element("prefix")||this.symbols,t=this.timers&&this.timers.prefix,s=this.state;return s.timer=t,k.isObject(e)&&(e=e[s.status]||e.pending),k.hasColor(e)?e:(this.styles[s.status]||this.styles.pending)(e)}async message(){let e=await this.element("message");return k.hasColor(e)?e:this.styles.strong(e)}async separator(){let e=await this.element("separator")||this.symbols,t=this.timers&&this.timers.separator,s=this.state;s.timer=t;let r=e[s.status]||e.pending||s.separator,n=await this.resolve(r,s);return k.isObject(n)&&(n=n[s.status]||n.pending),k.hasColor(n)?n:this.styles.muted(n)}async pointer(e,t){let s=await this.element("pointer",e,t);if(typeof s=="string"&&k.hasColor(s))return s;if(s){let r=this.styles,n=this.index===t,a=n?r.primary:h=>h,l=await this.resolve(s[n?"on":"off"]||s,this.state),o=k.hasColor(l)?l:a(l);return n?o:" ".repeat(l.length)}}async indicator(e,t){let s=await this.element("indicator",e,t);if(typeof s=="string"&&k.hasColor(s))return s;if(s){let r=this.styles,n=e.enabled===!0,a=n?r.success:r.dark,l=s[n?"on":"off"]||s;return k.hasColor(l)?l:a(l)}return""}body(){return null}footer(){if(this.state.status==="pending")return this.element("footer")}header(){if(this.state.status==="pending")return this.element("header")}async hint(){if(this.state.status==="pending"&&!this.isValue(this.state.input)){let e=await this.element("hint");return k.hasColor(e)?e:this.styles.muted(e)}}error(e){return this.state.submitted?"":e||this.state.error}format(e){return e}result(e){return e}validate(e){return this.options.required===!0?this.isValue(e):!0}isValue(e){return e!=null&&e!==""}resolve(e,...t){return k.resolve(this,e,...t)}get base(){return i.prototype}get style(){return this.styles[this.state.status]}get height(){return this.options.rows||k.height(this.stdout,25)}get width(){return this.options.columns||k.width(this.stdout,80)}get size(){return{width:this.width,height:this.height}}set cursor(e){this.state.cursor=e}get cursor(){return this.state.cursor}set input(e){this.state.input=e}get input(){return this.state.input}set value(e){this.state.value=e}get value(){let{input:e,value:t}=this.state,s=[t,e].find(this.isValue.bind(this));return this.isValue(s)?s:this.initial}static get prompt(){return e=>new this(e).run()}};function rr(i){let e=r=>i[r]===void 0||typeof i[r]=="function",t=["actions","choices","initial","margin","roles","styles","symbols","theme","timers","value"],s=["body","footer","error","header","hint","indicator","message","prefix","separator","skip"];for(let r of Object.keys(i.options)){if(t.includes(r)||/^on[A-Z]/.test(r))continue;let n=i.options[r];typeof n=="function"&&e(r)?s.includes(r)||(i[r]=n.bind(i)):typeof i[r]!="function"&&(i[r]=n)}}function nr(i){typeof i=="number"&&(i=[i,i,i,i]);let e=[].concat(i||[]),t=r=>r%2===0?`
10
- `:" ",s=[];for(let r=0;r<4;r++){let n=t(r);e[r]?s.push(n.repeat(e[r])):s.push("")}return s}Xt.exports=Re});var ii=d((Xn,ti)=>{"use strict";var ar=_(),ei={default(i,e){return e},checkbox(i,e){throw new Error("checkbox role is not implemented yet")},editable(i,e){throw new Error("editable role is not implemented yet")},expandable(i,e){throw new Error("expandable role is not implemented yet")},heading(i,e){return e.disabled="",e.indicator=[e.indicator," "].find(t=>t!=null),e.message=e.message||"",e},input(i,e){throw new Error("input role is not implemented yet")},option(i,e){return ei.default(i,e)},radio(i,e){throw new Error("radio role is not implemented yet")},separator(i,e){return e.disabled="",e.indicator=[e.indicator," "].find(t=>t!=null),e.message=e.message||i.symbols.line.repeat(5),e},spacer(i,e){return e}};ti.exports=(i,e={})=>{let t=ar.merge({},ei,e.roles);return t[i]||t.default}});var J=d((ea,ni)=>{"use strict";var lr=V(),or=U(),hr=ii(),le=_(),{reorder:_e,scrollUp:ur,scrollDown:cr,isObject:si,swap:dr}=le,Ie=class extends or{constructor(e){super(e),this.cursorHide(),this.maxSelected=e.maxSelected||1/0,this.multiple=e.multiple||!1,this.initial=e.initial||0,this.delay=e.delay||0,this.longest=0,this.num=""}async initialize(){typeof this.options.initial=="function"&&(this.initial=await this.options.initial.call(this)),await this.reset(!0),await super.initialize()}async reset(){let{choices:e,initial:t,autofocus:s,suggest:r}=this.options;if(this.state._choices=[],this.state.choices=[],this.choices=await Promise.all(await this.toChoices(e)),this.choices.forEach(n=>n.enabled=!1),typeof r!="function"&&this.selectable.length===0)throw new Error("At least one choice must be selectable");si(t)&&(t=Object.keys(t)),Array.isArray(t)?(s!=null&&(this.index=this.findIndex(s)),t.forEach(n=>this.enable(this.find(n))),await this.render()):(s!=null&&(t=s),typeof t=="string"&&(t=this.findIndex(t)),typeof t=="number"&&t>-1&&(this.index=Math.max(0,Math.min(t,this.choices.length)),this.enable(this.find(this.index)))),this.isDisabled(this.focused)&&await this.down()}async toChoices(e,t){this.state.loadingChoices=!0;let s=[],r=0,n=async(a,l)=>{typeof a=="function"&&(a=await a.call(this)),a instanceof Promise&&(a=await a);for(let o=0;o<a.length;o++){let h=a[o]=await this.toChoice(a[o],r++,l);s.push(h),h.choices&&await n(h.choices,h)}return s};return n(e,t).then(a=>(this.state.loadingChoices=!1,a))}async toChoice(e,t,s){if(typeof e=="function"&&(e=await e.call(this,this)),e instanceof Promise&&(e=await e),typeof e=="string"&&(e={name:e}),e.normalized)return e;e.normalized=!0;let r=e.value;if(e=hr(e.role,this.options)(this,e),typeof e.disabled=="string"&&!e.hint&&(e.hint=e.disabled,e.disabled=!0),e.disabled===!0&&e.hint==null&&(e.hint="(disabled)"),e.index!=null)return e;e.name=e.name||e.key||e.title||e.value||e.message,e.message=e.message||e.name||"",e.value=[e.value,e.name].find(this.isValue.bind(this)),e.input="",e.index=t,e.cursor=0,le.define(e,"parent",s),e.level=s?s.level+1:1,e.indent==null&&(e.indent=s?s.indent+" ":e.indent||""),e.path=s?s.path+"."+e.name:e.name,e.enabled=!!(this.multiple&&!this.isDisabled(e)&&(e.enabled||this.isSelected(e))),this.isDisabled(e)||(this.longest=Math.max(this.longest,lr(e.message).length));let a={...e};return e.reset=(l=a.input,o=a.value)=>{for(let h of Object.keys(a))e[h]=a[h];e.input=l,e.value=o},r==null&&typeof e.initial=="function"&&(e.input=await e.initial.call(this,this.state,e,t)),e}async onChoice(e,t){this.emit("choice",e,t,this),typeof e.onChoice=="function"&&await e.onChoice.call(this,this.state,e,t)}async addChoice(e,t,s){let r=await this.toChoice(e,t,s);return this.choices.push(r),this.index=this.choices.length-1,this.limit=this.choices.length,r}async newItem(e,t,s){let r={name:"New choice name?",editable:!0,newChoice:!0,...e},n=await this.addChoice(r,t,s);return n.updateChoice=()=>{delete n.newChoice,n.name=n.message=n.input,n.input="",n.cursor=0},this.render()}indent(e){return e.indent==null?e.level>1?" ".repeat(e.level-1):"":e.indent}dispatch(e,t){if(this.multiple&&this[t.name])return this[t.name]();this.alert()}focus(e,t){return typeof t!="boolean"&&(t=e.enabled),t&&!e.enabled&&this.selected.length>=this.maxSelected?this.alert():(this.index=e.index,e.enabled=t&&!this.isDisabled(e),e)}space(){if(!this.multiple)return this.alert();if(this.focused)return this.toggle(this.focused),this.render()}a(){if(this.maxSelected<this.choices.length)return this.alert();let e=this.selectable.every(t=>t.enabled);return this.choices.forEach(t=>t.enabled=!e),this.render()}i(){return this.choices.length-this.selected.length>this.maxSelected?this.alert():(this.choices.forEach(e=>e.enabled=!e.enabled),this.render())}g(){if(!this.choices.some(t=>!!t.parent))return this.a();let e=this.focused;return this.toggle(e.parent&&!e.choices?e.parent:e),this.render()}toggle(e,t){if(!e.enabled&&this.selected.length>=this.maxSelected)return this.alert();typeof t!="boolean"&&(t=!e.enabled),e.enabled=t,e.choices&&e.choices.forEach(r=>this.toggle(r,t));let s=e.parent;for(;s;){let r=s.choices.filter(n=>this.isDisabled(n));s.enabled=r.every(n=>n.enabled===!0),s=s.parent}return ri(this,this.choices),this.emit("toggle",e,this),e}enable(e){return this.selected.length>=this.maxSelected?this.alert():(e.enabled=!this.isDisabled(e),e.choices&&e.choices.forEach(this.enable.bind(this)),e)}disable(e){return e.enabled=!1,e.choices&&e.choices.forEach(this.disable.bind(this)),e}number(e){this.num+=e;let t=s=>{let r=Number(s);if(r>this.choices.length-1)return this.alert();let n=this.focused,a=this.choices.find(l=>r===l.index);if(!a.enabled&&this.selected.length>=this.maxSelected)return this.alert();if(this.visible.indexOf(a)===-1){let l=_e(this.choices),o=l.indexOf(a);if(n.index>o){let h=l.slice(o,o+this.limit),c=l.filter(u=>!h.includes(u));this.choices=h.concat(c)}else{let h=o-this.limit+1;this.choices=l.slice(h).concat(l.slice(0,h))}}return this.index=this.choices.indexOf(a),this.toggle(this.focused),this.render()};return clearTimeout(this.numberTimeout),new Promise(s=>{let r=this.choices.length,n=this.num,a=(l=!1,o)=>{clearTimeout(this.numberTimeout),l&&(o=t(n)),this.num="",s(o)};if(n==="0"||n.length===1&&+(n+"0")>r)return a(!0);if(Number(n)>r)return a(!1,this.alert());this.numberTimeout=setTimeout(()=>a(!0),this.delay)})}home(){return this.choices=_e(this.choices),this.index=0,this.render()}end(){let e=this.choices.length-this.limit,t=_e(this.choices);return this.choices=t.slice(e).concat(t.slice(0,e)),this.index=this.limit-1,this.render()}first(){return this.index=0,this.render()}last(){return this.index=this.visible.length-1,this.render()}prev(){return this.visible.length<=1?this.alert():this.up()}next(){return this.visible.length<=1?this.alert():this.down()}right(){return this.cursor>=this.input.length?this.alert():(this.cursor++,this.render())}left(){return this.cursor<=0?this.alert():(this.cursor--,this.render())}up(){let e=this.choices.length,t=this.visible.length,s=this.index;return this.options.scroll===!1&&s===0?this.alert():e>t&&s===0?this.scrollUp():(this.index=(s-1%e+e)%e,this.isDisabled()&&!this.allChoicesAreDisabled()?this.up():this.render())}down(){let e=this.choices.length,t=this.visible.length,s=this.index;return this.options.scroll===!1&&s===t-1?this.alert():e>t&&s===t-1?this.scrollDown():(this.index=(s+1)%e,this.isDisabled()&&!this.allChoicesAreDisabled()?this.down():this.render())}scrollUp(e=0){return this.choices=ur(this.choices),this.index=e,this.isDisabled()?this.up():this.render()}scrollDown(e=this.visible.length-1){return this.choices=cr(this.choices),this.index=e,this.isDisabled()?this.down():this.render()}async shiftUp(){if(this.options.sort===!0){this.sorting=!0,this.swap(this.index-1),await this.up(),this.sorting=!1;return}return this.scrollUp(this.index)}async shiftDown(){if(this.options.sort===!0){this.sorting=!0,this.swap(this.index+1),await this.down(),this.sorting=!1;return}return this.scrollDown(this.index)}pageUp(){return this.visible.length<=1?this.alert():(this.limit=Math.max(this.limit-1,0),this.index=Math.min(this.limit-1,this.index),this._limit=this.limit,this.isDisabled()?this.up():this.render())}pageDown(){return this.visible.length>=this.choices.length?this.alert():(this.index=Math.max(0,this.index),this.limit=Math.min(this.limit+1,this.choices.length),this._limit=this.limit,this.isDisabled()?this.down():this.render())}swap(e){dr(this.choices,this.index,e)}allChoicesAreDisabled(e=this.choices){return e.every(t=>this.isDisabled(t))}isDisabled(e=this.focused){return e&&["disabled","collapsed","hidden","completing","readonly"].some(s=>e[s]===!0)?!0:e&&e.role==="heading"}isEnabled(e=this.focused){if(Array.isArray(e))return e.every(t=>this.isEnabled(t));if(e.choices){let t=e.choices.filter(s=>!this.isDisabled(s));return e.enabled&&t.every(s=>this.isEnabled(s))}return e.enabled&&!this.isDisabled(e)}isChoice(e,t){return e.name===t||e.index===Number(t)}isSelected(e){return Array.isArray(this.initial)?this.initial.some(t=>this.isChoice(e,t)):this.isChoice(e,this.initial)}map(e=[],t="value"){return[].concat(e||[]).reduce((s,r)=>(s[r]=this.find(r,t),s),{})}filter(e,t){let r=typeof e=="function"?e:(l,o)=>[l.name,o].includes(e),a=(this.options.multiple?this.state._choices:this.choices).filter(r);return t?a.map(l=>l[t]):a}find(e,t){if(si(e))return t?e[t]:e;let r=typeof e=="function"?e:(a,l)=>[a.name,l].includes(e),n=this.choices.find(r);if(n)return t?n[t]:n}findIndex(e){return this.choices.indexOf(this.find(e))}async submit(){let e=this.focused;if(!e)return this.alert();if(e.newChoice)return e.input?(e.updateChoice(),this.render()):this.alert();if(this.choices.some(a=>a.newChoice))return this.alert();let{reorder:t,sort:s}=this.options,r=this.multiple===!0,n=this.selected;return n===void 0?this.alert():(Array.isArray(n)&&t!==!1&&s!==!0&&(n=le.reorder(n)),this.value=r?n.map(a=>a.name):n.name,super.submit())}set choices(e=[]){this.state._choices=this.state._choices||[],this.state.choices=e;for(let t of e)this.state._choices.some(s=>s.name===t.name)||this.state._choices.push(t);if(!this._initial&&this.options.initial){this._initial=!0;let t=this.initial;if(typeof t=="string"||typeof t=="number"){let s=this.find(t);s&&(this.initial=s.index,this.focus(s,!0))}}}get choices(){return ri(this,this.state.choices||[])}set visible(e){this.state.visible=e}get visible(){return(this.state.visible||this.choices).slice(0,this.limit)}set limit(e){this.state.limit=e}get limit(){let{state:e,options:t,choices:s}=this,r=e.limit||this._limit||t.limit||s.length;return Math.min(r,this.height)}set value(e){super.value=e}get value(){return typeof super.value!="string"&&super.value===this.initial?this.input:super.value}set index(e){this.state.index=e}get index(){return Math.max(0,this.state?this.state.index:0)}get enabled(){return this.filter(this.isEnabled.bind(this))}get focused(){let e=this.choices[this.index];return e&&this.state.submitted&&this.multiple!==!0&&(e.enabled=!0),e}get selectable(){return this.choices.filter(e=>!this.isDisabled(e))}get selected(){return this.multiple?this.enabled:this.focused}};function ri(i,e){if(e instanceof Promise)return e;if(typeof e=="function"){if(le.isAsyncFn(e))return e;e=e.call(i,i)}for(let t of e){if(Array.isArray(t.choices)){let s=t.choices.filter(r=>!i.isDisabled(r));t.enabled=s.every(r=>r.enabled===!0)}i.isDisabled(t)===!0&&delete t.enabled}return e}ni.exports=Ie});var D=d((ta,ai)=>{"use strict";var pr=J(),ke=_(),Ae=class extends pr{constructor(e){super(e),this.emptyError=this.options.emptyError||"No items were selected"}async dispatch(e,t){if(this.multiple)return this[t.name]?await this[t.name](e,t):await super.dispatch(e,t);this.alert()}separator(){if(this.options.separator)return super.separator();let e=this.styles.muted(this.symbols.ellipsis);return this.state.submitted?super.separator():e}pointer(e,t){return!this.multiple||this.options.pointer?super.pointer(e,t):""}indicator(e,t){return this.multiple?super.indicator(e,t):""}choiceMessage(e,t){let s=this.resolve(e.message,this.state,e,t);return e.role==="heading"&&!ke.hasColor(s)&&(s=this.styles.strong(s)),this.resolve(s,this.state,e,t)}choiceSeparator(){return":"}async renderChoice(e,t){await this.onChoice(e,t);let s=this.index===t,r=await this.pointer(e,t),n=await this.indicator(e,t)+(e.pad||""),a=await this.resolve(e.hint,this.state,e,t);a&&!ke.hasColor(a)&&(a=this.styles.muted(a));let l=this.indent(e),o=await this.choiceMessage(e,t),h=()=>[this.margin[3],l+r+n,o,this.margin[1],a].filter(Boolean).join(" ");return e.role==="heading"?h():e.disabled?(ke.hasColor(o)||(o=this.styles.disabled(o)),h()):(s&&(o=this.styles.em(o)),h())}async renderChoices(){if(this.state.loading==="choices")return this.styles.warning("Loading choices");if(this.state.submitted)return"";let e=this.visible.map(async(n,a)=>await this.renderChoice(n,a)),t=await Promise.all(e);t.length||t.push(this.styles.danger("No matching choices"));let s=this.margin[0]+t.join(`
8
+ `+this.styles.danger(t),this.state.submitted=!1,await this.render(),await this.alert(),this.state.validating=!1,this.state.error=void 0;return}this.state.validating=!1,await this.render(),await this.close(),this.value=await this.result(this.value),this.emit("submit",this.value)}async cancel(e){this.state.cancelled=this.state.submitted=!0,await this.render(),await this.close(),typeof this.options.onCancel=="function"&&await this.options.onCancel.call(this,this.name,this.value,this),this.emit("cancel",await this.error(e))}async close(){this.state.closed=!0;try{let e=this.sections(),t=Math.ceil(e.prompt.length/this.width);e.rest&&this.write(B.cursor.down(e.rest.length)),this.write(`
9
+ `.repeat(t))}catch{}this.emit("close")}start(){!this.stop&&this.options.show!==!1&&(this.stop=Re.listen(this,this.keypress.bind(this)),this.once("close",this.stop),this.emit("start",this))}async skip(){return this.skipped=this.options.skip===!0,typeof this.options.skip=="function"&&(this.skipped=await this.options.skip.call(this,this.name,this.value)),this.skipped}async initialize(){let{format:e,options:t,result:s}=this;if(this.format=()=>e.call(this,this.value),this.result=()=>s.call(this,this.value),typeof t.initial=="function"&&(this.initial=await t.initial.call(this,this)),typeof t.onRun=="function"&&await t.onRun.call(this,this),typeof t.onSubmit=="function"){let r=t.onSubmit.bind(this),n=this.submit.bind(this);delete this.options.onSubmit,this.submit=async()=>(await r(this.name,this.value,this),n())}await this.start(),await this.render()}render(){throw new Error("expected prompt to have a custom render method")}run(){return new Promise(async(e,t)=>{if(this.once("submit",e),this.once("cancel",t),await this.skip())return this.render=()=>{},this.submit();await this.initialize(),this.emit("run")})}async element(e,t,s){let{options:r,state:n,symbols:a,timers:l}=this,o=l&&l[e];n.timer=o;let h=r[e]||n[e]||a[e],c=t&&t[e]!=null?t[e]:await h;if(c==="")return c;let u=await this.resolve(c,n,t,s);return!u&&t&&t[e]?this.resolve(h,n,t,s):u}async prefix(){let e=await this.element("prefix")||this.symbols,t=this.timers&&this.timers.prefix,s=this.state;return s.timer=t,k.isObject(e)&&(e=e[s.status]||e.pending),k.hasColor(e)?e:(this.styles[s.status]||this.styles.pending)(e)}async message(){let e=await this.element("message");return k.hasColor(e)?e:this.styles.strong(e)}async separator(){let e=await this.element("separator")||this.symbols,t=this.timers&&this.timers.separator,s=this.state;s.timer=t;let r=e[s.status]||e.pending||s.separator,n=await this.resolve(r,s);return k.isObject(n)&&(n=n[s.status]||n.pending),k.hasColor(n)?n:this.styles.muted(n)}async pointer(e,t){let s=await this.element("pointer",e,t);if(typeof s=="string"&&k.hasColor(s))return s;if(s){let r=this.styles,n=this.index===t,a=n?r.primary:h=>h,l=await this.resolve(s[n?"on":"off"]||s,this.state),o=k.hasColor(l)?l:a(l);return n?o:" ".repeat(l.length)}}async indicator(e,t){let s=await this.element("indicator",e,t);if(typeof s=="string"&&k.hasColor(s))return s;if(s){let r=this.styles,n=e.enabled===!0,a=n?r.success:r.dark,l=s[n?"on":"off"]||s;return k.hasColor(l)?l:a(l)}return""}body(){return null}footer(){if(this.state.status==="pending")return this.element("footer")}header(){if(this.state.status==="pending")return this.element("header")}async hint(){if(this.state.status==="pending"&&!this.isValue(this.state.input)){let e=await this.element("hint");return k.hasColor(e)?e:this.styles.muted(e)}}error(e){return this.state.submitted?"":e||this.state.error}format(e){return e}result(e){return e}validate(e){return this.options.required===!0?this.isValue(e):!0}isValue(e){return e!=null&&e!==""}resolve(e,...t){return k.resolve(this,e,...t)}get base(){return i.prototype}get style(){return this.styles[this.state.status]}get height(){return this.options.rows||k.height(this.stdout,25)}get width(){return this.options.columns||k.width(this.stdout,80)}get size(){return{width:this.width,height:this.height}}set cursor(e){this.state.cursor=e}get cursor(){return this.state.cursor}set input(e){this.state.input=e}get input(){return this.state.input}set value(e){this.state.value=e}get value(){let{input:e,value:t}=this.state,s=[t,e].find(this.isValue.bind(this));return this.isValue(s)?s:this.initial}static get prompt(){return e=>new this(e).run()}};function rr(i){let e=r=>i[r]===void 0||typeof i[r]=="function",t=["actions","choices","initial","margin","roles","styles","symbols","theme","timers","value"],s=["body","footer","error","header","hint","indicator","message","prefix","separator","skip"];for(let r of Object.keys(i.options)){if(t.includes(r)||/^on[A-Z]/.test(r))continue;let n=i.options[r];typeof n=="function"&&e(r)?s.includes(r)||(i[r]=n.bind(i)):typeof i[r]!="function"&&(i[r]=n)}}function nr(i){typeof i=="number"&&(i=[i,i,i,i]);let e=[].concat(i||[]),t=r=>r%2===0?`
10
+ `:" ",s=[];for(let r=0;r<4;r++){let n=t(r);e[r]?s.push(n.repeat(e[r])):s.push("")}return s}ei.exports=_e});var si=d((ea,ii)=>{"use strict";var ar=I(),ti={default(i,e){return e},checkbox(i,e){throw new Error("checkbox role is not implemented yet")},editable(i,e){throw new Error("editable role is not implemented yet")},expandable(i,e){throw new Error("expandable role is not implemented yet")},heading(i,e){return e.disabled="",e.indicator=[e.indicator," "].find(t=>t!=null),e.message=e.message||"",e},input(i,e){throw new Error("input role is not implemented yet")},option(i,e){return ti.default(i,e)},radio(i,e){throw new Error("radio role is not implemented yet")},separator(i,e){return e.disabled="",e.indicator=[e.indicator," "].find(t=>t!=null),e.message=e.message||i.symbols.line.repeat(5),e},spacer(i,e){return e}};ii.exports=(i,e={})=>{let t=ar.merge({},ti,e.roles);return t[i]||t.default}});var J=d((ta,ai)=>{"use strict";var lr=V(),or=U(),hr=si(),le=I(),{reorder:Ie,scrollUp:ur,scrollDown:cr,isObject:ri,swap:dr}=le,Se=class extends or{constructor(e){super(e),this.cursorHide(),this.maxSelected=e.maxSelected||1/0,this.multiple=e.multiple||!1,this.initial=e.initial||0,this.delay=e.delay||0,this.longest=0,this.num=""}async initialize(){typeof this.options.initial=="function"&&(this.initial=await this.options.initial.call(this)),await this.reset(!0),await super.initialize()}async reset(){let{choices:e,initial:t,autofocus:s,suggest:r}=this.options;if(this.state._choices=[],this.state.choices=[],this.choices=await Promise.all(await this.toChoices(e)),this.choices.forEach(n=>n.enabled=!1),typeof r!="function"&&this.selectable.length===0)throw new Error("At least one choice must be selectable");ri(t)&&(t=Object.keys(t)),Array.isArray(t)?(s!=null&&(this.index=this.findIndex(s)),t.forEach(n=>this.enable(this.find(n))),await this.render()):(s!=null&&(t=s),typeof t=="string"&&(t=this.findIndex(t)),typeof t=="number"&&t>-1&&(this.index=Math.max(0,Math.min(t,this.choices.length)),this.enable(this.find(this.index)))),this.isDisabled(this.focused)&&await this.down()}async toChoices(e,t){this.state.loadingChoices=!0;let s=[],r=0,n=async(a,l)=>{typeof a=="function"&&(a=await a.call(this)),a instanceof Promise&&(a=await a);for(let o=0;o<a.length;o++){let h=a[o]=await this.toChoice(a[o],r++,l);s.push(h),h.choices&&await n(h.choices,h)}return s};return n(e,t).then(a=>(this.state.loadingChoices=!1,a))}async toChoice(e,t,s){if(typeof e=="function"&&(e=await e.call(this,this)),e instanceof Promise&&(e=await e),typeof e=="string"&&(e={name:e}),e.normalized)return e;e.normalized=!0;let r=e.value;if(e=hr(e.role,this.options)(this,e),typeof e.disabled=="string"&&!e.hint&&(e.hint=e.disabled,e.disabled=!0),e.disabled===!0&&e.hint==null&&(e.hint="(disabled)"),e.index!=null)return e;e.name=e.name||e.key||e.title||e.value||e.message,e.message=e.message||e.name||"",e.value=[e.value,e.name].find(this.isValue.bind(this)),e.input="",e.index=t,e.cursor=0,le.define(e,"parent",s),e.level=s?s.level+1:1,e.indent==null&&(e.indent=s?s.indent+" ":e.indent||""),e.path=s?s.path+"."+e.name:e.name,e.enabled=!!(this.multiple&&!this.isDisabled(e)&&(e.enabled||this.isSelected(e))),this.isDisabled(e)||(this.longest=Math.max(this.longest,lr(e.message).length));let a={...e};return e.reset=(l=a.input,o=a.value)=>{for(let h of Object.keys(a))e[h]=a[h];e.input=l,e.value=o},r==null&&typeof e.initial=="function"&&(e.input=await e.initial.call(this,this.state,e,t)),e}async onChoice(e,t){this.emit("choice",e,t,this),typeof e.onChoice=="function"&&await e.onChoice.call(this,this.state,e,t)}async addChoice(e,t,s){let r=await this.toChoice(e,t,s);return this.choices.push(r),this.index=this.choices.length-1,this.limit=this.choices.length,r}async newItem(e,t,s){let r={name:"New choice name?",editable:!0,newChoice:!0,...e},n=await this.addChoice(r,t,s);return n.updateChoice=()=>{delete n.newChoice,n.name=n.message=n.input,n.input="",n.cursor=0},this.render()}indent(e){return e.indent==null?e.level>1?" ".repeat(e.level-1):"":e.indent}dispatch(e,t){if(this.multiple&&this[t.name])return this[t.name]();this.alert()}focus(e,t){return typeof t!="boolean"&&(t=e.enabled),t&&!e.enabled&&this.selected.length>=this.maxSelected?this.alert():(this.index=e.index,e.enabled=t&&!this.isDisabled(e),e)}space(){if(!this.multiple)return this.alert();if(this.focused)return this.toggle(this.focused),this.render()}a(){if(this.maxSelected<this.choices.length)return this.alert();let e=this.selectable.every(t=>t.enabled);return this.choices.forEach(t=>t.enabled=!e),this.render()}i(){return this.choices.length-this.selected.length>this.maxSelected?this.alert():(this.choices.forEach(e=>e.enabled=!e.enabled),this.render())}g(){if(!this.choices.some(t=>!!t.parent))return this.a();let e=this.focused;return this.toggle(e.parent&&!e.choices?e.parent:e),this.render()}toggle(e,t){if(!e.enabled&&this.selected.length>=this.maxSelected)return this.alert();typeof t!="boolean"&&(t=!e.enabled),e.enabled=t,e.choices&&e.choices.forEach(r=>this.toggle(r,t));let s=e.parent;for(;s;){let r=s.choices.filter(n=>this.isDisabled(n));s.enabled=r.every(n=>n.enabled===!0),s=s.parent}return ni(this,this.choices),this.emit("toggle",e,this),e}enable(e){return this.selected.length>=this.maxSelected?this.alert():(e.enabled=!this.isDisabled(e),e.choices&&e.choices.forEach(this.enable.bind(this)),e)}disable(e){return e.enabled=!1,e.choices&&e.choices.forEach(this.disable.bind(this)),e}number(e){this.num+=e;let t=s=>{let r=Number(s);if(r>this.choices.length-1)return this.alert();let n=this.focused,a=this.choices.find(l=>r===l.index);if(!a.enabled&&this.selected.length>=this.maxSelected)return this.alert();if(this.visible.indexOf(a)===-1){let l=Ie(this.choices),o=l.indexOf(a);if(n.index>o){let h=l.slice(o,o+this.limit),c=l.filter(u=>!h.includes(u));this.choices=h.concat(c)}else{let h=o-this.limit+1;this.choices=l.slice(h).concat(l.slice(0,h))}}return this.index=this.choices.indexOf(a),this.toggle(this.focused),this.render()};return clearTimeout(this.numberTimeout),new Promise(s=>{let r=this.choices.length,n=this.num,a=(l=!1,o)=>{clearTimeout(this.numberTimeout),l&&(o=t(n)),this.num="",s(o)};if(n==="0"||n.length===1&&+(n+"0")>r)return a(!0);if(Number(n)>r)return a(!1,this.alert());this.numberTimeout=setTimeout(()=>a(!0),this.delay)})}home(){return this.choices=Ie(this.choices),this.index=0,this.render()}end(){let e=this.choices.length-this.limit,t=Ie(this.choices);return this.choices=t.slice(e).concat(t.slice(0,e)),this.index=this.limit-1,this.render()}first(){return this.index=0,this.render()}last(){return this.index=this.visible.length-1,this.render()}prev(){return this.visible.length<=1?this.alert():this.up()}next(){return this.visible.length<=1?this.alert():this.down()}right(){return this.cursor>=this.input.length?this.alert():(this.cursor++,this.render())}left(){return this.cursor<=0?this.alert():(this.cursor--,this.render())}up(){let e=this.choices.length,t=this.visible.length,s=this.index;return this.options.scroll===!1&&s===0?this.alert():e>t&&s===0?this.scrollUp():(this.index=(s-1%e+e)%e,this.isDisabled()&&!this.allChoicesAreDisabled()?this.up():this.render())}down(){let e=this.choices.length,t=this.visible.length,s=this.index;return this.options.scroll===!1&&s===t-1?this.alert():e>t&&s===t-1?this.scrollDown():(this.index=(s+1)%e,this.isDisabled()&&!this.allChoicesAreDisabled()?this.down():this.render())}scrollUp(e=0){return this.choices=ur(this.choices),this.index=e,this.isDisabled()?this.up():this.render()}scrollDown(e=this.visible.length-1){return this.choices=cr(this.choices),this.index=e,this.isDisabled()?this.down():this.render()}async shiftUp(){if(this.options.sort===!0){this.sorting=!0,this.swap(this.index-1),await this.up(),this.sorting=!1;return}return this.scrollUp(this.index)}async shiftDown(){if(this.options.sort===!0){this.sorting=!0,this.swap(this.index+1),await this.down(),this.sorting=!1;return}return this.scrollDown(this.index)}pageUp(){return this.visible.length<=1?this.alert():(this.limit=Math.max(this.limit-1,0),this.index=Math.min(this.limit-1,this.index),this._limit=this.limit,this.isDisabled()?this.up():this.render())}pageDown(){return this.visible.length>=this.choices.length?this.alert():(this.index=Math.max(0,this.index),this.limit=Math.min(this.limit+1,this.choices.length),this._limit=this.limit,this.isDisabled()?this.down():this.render())}swap(e){dr(this.choices,this.index,e)}allChoicesAreDisabled(e=this.choices){return e.every(t=>this.isDisabled(t))}isDisabled(e=this.focused){return e&&["disabled","collapsed","hidden","completing","readonly"].some(s=>e[s]===!0)?!0:e&&e.role==="heading"}isEnabled(e=this.focused){if(Array.isArray(e))return e.every(t=>this.isEnabled(t));if(e.choices){let t=e.choices.filter(s=>!this.isDisabled(s));return e.enabled&&t.every(s=>this.isEnabled(s))}return e.enabled&&!this.isDisabled(e)}isChoice(e,t){return e.name===t||e.index===Number(t)}isSelected(e){return Array.isArray(this.initial)?this.initial.some(t=>this.isChoice(e,t)):this.isChoice(e,this.initial)}map(e=[],t="value"){return[].concat(e||[]).reduce((s,r)=>(s[r]=this.find(r,t),s),{})}filter(e,t){let r=typeof e=="function"?e:(l,o)=>[l.name,o].includes(e),a=(this.options.multiple?this.state._choices:this.choices).filter(r);return t?a.map(l=>l[t]):a}find(e,t){if(ri(e))return t?e[t]:e;let r=typeof e=="function"?e:(a,l)=>[a.name,l].includes(e),n=this.choices.find(r);if(n)return t?n[t]:n}findIndex(e){return this.choices.indexOf(this.find(e))}async submit(){let e=this.focused;if(!e)return this.alert();if(e.newChoice)return e.input?(e.updateChoice(),this.render()):this.alert();if(this.choices.some(a=>a.newChoice))return this.alert();let{reorder:t,sort:s}=this.options,r=this.multiple===!0,n=this.selected;return n===void 0?this.alert():(Array.isArray(n)&&t!==!1&&s!==!0&&(n=le.reorder(n)),this.value=r?n.map(a=>a.name):n.name,super.submit())}set choices(e=[]){this.state._choices=this.state._choices||[],this.state.choices=e;for(let t of e)this.state._choices.some(s=>s.name===t.name)||this.state._choices.push(t);if(!this._initial&&this.options.initial){this._initial=!0;let t=this.initial;if(typeof t=="string"||typeof t=="number"){let s=this.find(t);s&&(this.initial=s.index,this.focus(s,!0))}}}get choices(){return ni(this,this.state.choices||[])}set visible(e){this.state.visible=e}get visible(){return(this.state.visible||this.choices).slice(0,this.limit)}set limit(e){this.state.limit=e}get limit(){let{state:e,options:t,choices:s}=this,r=e.limit||this._limit||t.limit||s.length;return Math.min(r,this.height)}set value(e){super.value=e}get value(){return typeof super.value!="string"&&super.value===this.initial?this.input:super.value}set index(e){this.state.index=e}get index(){return Math.max(0,this.state?this.state.index:0)}get enabled(){return this.filter(this.isEnabled.bind(this))}get focused(){let e=this.choices[this.index];return e&&this.state.submitted&&this.multiple!==!0&&(e.enabled=!0),e}get selectable(){return this.choices.filter(e=>!this.isDisabled(e))}get selected(){return this.multiple?this.enabled:this.focused}};function ni(i,e){if(e instanceof Promise)return e;if(typeof e=="function"){if(le.isAsyncFn(e))return e;e=e.call(i,i)}for(let t of e){if(Array.isArray(t.choices)){let s=t.choices.filter(r=>!i.isDisabled(r));t.enabled=s.every(r=>r.enabled===!0)}i.isDisabled(t)===!0&&delete t.enabled}return e}ai.exports=Se});var j=d((ia,li)=>{"use strict";var pr=J(),ke=I(),Ae=class extends pr{constructor(e){super(e),this.emptyError=this.options.emptyError||"No items were selected"}async dispatch(e,t){if(this.multiple)return this[t.name]?await this[t.name](e,t):await super.dispatch(e,t);this.alert()}separator(){if(this.options.separator)return super.separator();let e=this.styles.muted(this.symbols.ellipsis);return this.state.submitted?super.separator():e}pointer(e,t){return!this.multiple||this.options.pointer?super.pointer(e,t):""}indicator(e,t){return this.multiple?super.indicator(e,t):""}choiceMessage(e,t){let s=this.resolve(e.message,this.state,e,t);return e.role==="heading"&&!ke.hasColor(s)&&(s=this.styles.strong(s)),this.resolve(s,this.state,e,t)}choiceSeparator(){return":"}async renderChoice(e,t){await this.onChoice(e,t);let s=this.index===t,r=await this.pointer(e,t),n=await this.indicator(e,t)+(e.pad||""),a=await this.resolve(e.hint,this.state,e,t);a&&!ke.hasColor(a)&&(a=this.styles.muted(a));let l=this.indent(e),o=await this.choiceMessage(e,t),h=()=>[this.margin[3],l+r+n,o,this.margin[1],a].filter(Boolean).join(" ");return e.role==="heading"?h():e.disabled?(ke.hasColor(o)||(o=this.styles.disabled(o)),h()):(s&&(o=this.styles.em(o)),h())}async renderChoices(){if(this.state.loading==="choices")return this.styles.warning("Loading choices");if(this.state.submitted)return"";let e=this.visible.map(async(n,a)=>await this.renderChoice(n,a)),t=await Promise.all(e);t.length||t.push(this.styles.danger("No matching choices"));let s=this.margin[0]+t.join(`
11
11
  `),r;return this.options.choicesHeader&&(r=await this.resolve(this.options.choicesHeader,this.state)),[r,s].filter(Boolean).join(`
12
12
  `)}format(){return!this.state.submitted||this.state.cancelled?"":Array.isArray(this.selected)?this.selected.map(e=>this.styles.primary(e.name)).join(", "):this.styles.primary(this.selected.name)}async render(){let{submitted:e,size:t}=this.state,s="",r=await this.header(),n=await this.prefix(),a=await this.separator(),l=await this.message();this.options.promptLine!==!1&&(s=[n,l,a,""].join(" "),this.state.prompt=s);let o=await this.format(),h=await this.error()||await this.hint(),c=await this.renderChoices(),u=await this.footer();o&&(s+=o),h&&!s.includes(h)&&(s+=" "+h),e&&!o&&!c.trim()&&this.multiple&&this.emptyError!=null&&(s+=this.styles.danger(this.emptyError)),this.clear(t),this.write([r,s,c,u].filter(Boolean).join(`
13
- `)),this.write(this.margin[2]),this.restore()}};ai.exports=Ae});var oi=d((ia,li)=>{"use strict";var fr=D(),mr=(i,e)=>{let t=i?new RegExp(i,"ig"):/$^/;return s=>i?s.replace(t,r=>e(r)):s},Te=class extends fr{constructor(e){super(e),this.cursorShow()}moveCursor(e){this.state.cursor+=e}dispatch(e){return this.append(e)}space(e){return this.options.multiple?super.space(e):this.append(e)}append(e){let{cursor:t,input:s}=this.state;return this.input=s.slice(0,t)+e+s.slice(t),this.moveCursor(1),this.complete()}delete(){let{cursor:e,input:t}=this.state;return t?(this.input=t.slice(0,e-1)+t.slice(e),this.moveCursor(-1),this.complete()):this.alert()}deleteForward(){let{cursor:e,input:t}=this.state;return t[e]===void 0?this.alert():(this.input=`${t}`.slice(0,e)+`${t}`.slice(e+1),this.complete())}number(e){return this.append(e)}async complete(){this.completing=!0,this.choices=await this.suggest(this.input,this.state._choices),this.state.limit=void 0,this.index=Math.min(Math.max(this.visible.length-1,0),this.index),await this.render(),this.completing=!1}suggest(e=this.input,t=this.state._choices){if(typeof this.options.suggest=="function")return this.options.suggest.call(this,e,t);let s=e.toLowerCase();return t.filter(r=>r.message.toLowerCase().includes(s))}pointer(){return""}format(){if(!this.focused)return this.input;if(this.options.multiple&&this.state.submitted)return this.selected.map(e=>this.styles.primary(e.message)).join(", ");if(this.state.submitted){let e=this.value=this.input=this.focused.value;return this.styles.primary(e)}return this.input}async render(){if(this.state.status!=="pending")return super.render();let e=this.options.highlight||this.styles.complement,t=(n,a)=>n&&(e.stack?e(n):e.call(this,n)),s=mr(this.input,t),r=this.choices;this.choices=r.map(n=>({...n,message:s(n.message)})),await super.render(),this.choices=r}submit(){return this.options.multiple&&(this.value=this.selected.map(e=>e.name)),super.submit()}};li.exports=Te});var $e=d((sa,hi)=>{"use strict";var qe=_();hi.exports=(i,e={})=>{i.cursorHide();let{input:t="",initial:s="",pos:r,showCursor:n=!0,color:a}=e,l=a||i.styles.placeholder,o=qe.inverse(i.styles.primary),h=x=>o(i.styles.black(x)),c=t,u=" ",v=h(u);if(i.blink&&i.blink.off===!0&&(h=x=>x,v=""),n&&r===0&&s===""&&t==="")return h(u);if(n&&r===0&&(t===s||t===""))return h(s[0])+l(s.slice(1));s=qe.isPrimitive(s)?`${s}`:"",t=qe.isPrimitive(t)?`${t}`:"";let y=s&&s.startsWith(t)&&s!==t,p=y?h(s[t.length]):v;if(r!==t.length&&n===!0&&(c=t.slice(0,r)+h(t[r])+t.slice(r+1),p=""),n===!1&&(p=""),y){let x=i.styles.unstyle(c+p);return c+p+l(s.slice(x.length))}return c+p}});var oe=d((ra,ui)=>{"use strict";var gr=V(),yr=D(),wr=$e(),Pe=class extends yr{constructor(e){super({...e,multiple:!0}),this.type="form",this.initial=this.options.initial,this.align=[this.options.align,"right"].find(t=>t!=null),this.emptyError="",this.values={}}async reset(e){return await super.reset(),e===!0&&(this._index=this.index),this.index=this._index,this.values={},this.choices.forEach(t=>t.reset&&t.reset()),this.render()}dispatch(e){return!!e&&this.append(e)}append(e){let t=this.focused;if(!t)return this.alert();let{cursor:s,input:r}=t;return t.value=t.input=r.slice(0,s)+e+r.slice(s),t.cursor++,this.render()}delete(){let e=this.focused;if(!e||e.cursor<=0)return this.alert();let{cursor:t,input:s}=e;return e.value=e.input=s.slice(0,t-1)+s.slice(t),e.cursor--,this.render()}deleteForward(){let e=this.focused;if(!e)return this.alert();let{cursor:t,input:s}=e;if(s[t]===void 0)return this.alert();let r=`${s}`.slice(0,t)+`${s}`.slice(t+1);return e.value=e.input=r,this.render()}right(){let e=this.focused;return e?e.cursor>=e.input.length?this.alert():(e.cursor++,this.render()):this.alert()}left(){let e=this.focused;return e?e.cursor<=0?this.alert():(e.cursor--,this.render()):this.alert()}space(e,t){return this.dispatch(e,t)}number(e,t){return this.dispatch(e,t)}next(){let e=this.focused;if(!e)return this.alert();let{initial:t,input:s}=e;return t&&t.startsWith(s)&&s!==t?(e.value=e.input=t,e.cursor=e.value.length,this.render()):super.next()}prev(){let e=this.focused;return e?e.cursor===0?super.prev():(e.value=e.input="",e.cursor=0,this.render()):this.alert()}separator(){return""}format(e){return this.state.submitted?"":super.format(e)}pointer(){return""}indicator(e){return e.input?"\u29BF":"\u2299"}async choiceSeparator(e,t){let s=await this.resolve(e.separator,this.state,e,t)||":";return s?" "+this.styles.disabled(s):""}async renderChoice(e,t){await this.onChoice(e,t);let{state:s,styles:r}=this,{cursor:n,initial:a="",name:l,input:o=""}=e,{muted:h,submitted:c,primary:u,danger:v}=r,y=this.index===t,p=e.validate||(()=>!0),x=await this.choiceSeparator(e,t),S=e.message;this.align==="right"&&(S=S.padStart(this.longest+1," ")),this.align==="left"&&(S=S.padEnd(this.longest+1," "));let f=this.values[l]=o||a,w=o?"success":"dark";await p.call(e,f,this.state)!==!0&&(w="danger");let m=r[w],E=m(await this.indicator(e,t))+(e.pad||""),I=this.indent(e),A=()=>[I,E,S+x,o].filter(Boolean).join(" ");if(s.submitted)return S=gr(S),o=c(o),A();if(e.format)o=await e.format.call(this,o,e,t);else{let nt=this.styles.muted;o=wr(this,{input:o,initial:a,pos:n,showCursor:y,color:nt})}return this.isValue(o)||(o=this.styles.muted(this.symbols.ellipsis)),e.result&&(this.values[l]=await e.result.call(this,f,e,t)),y&&(S=u(S)),e.error?o+=(o?" ":"")+v(e.error.trim()):e.hint&&(o+=(o?" ":"")+h(e.hint.trim())),A()}async submit(){return this.value=this.values,super.base.submit.call(this)}};ui.exports=Pe});var Oe=d((na,di)=>{"use strict";var br=oe(),vr=()=>{throw new Error("expected prompt to have a custom authenticate method")},ci=(i=vr)=>{class e extends br{constructor(s){super(s)}async submit(){this.value=await i.call(this,this.values,this.state),super.base.submit.call(this)}static create(s){return ci(s)}}return e};di.exports=ci()});var mi=d((aa,fi)=>{"use strict";var xr=Oe();function Er(i,e){return i.username===this.options.username&&i.password===this.options.password}var pi=(i=Er)=>{let e=[{name:"username",message:"username"},{name:"password",message:"password",format(s){return this.options.showPassword?s:(this.state.submitted?this.styles.primary:this.styles.muted)(this.symbols.asterisk.repeat(s.length))}}];class t extends xr.create(i){constructor(r){super({...r,choices:e})}static create(r){return pi(r)}}return t};fi.exports=pi()});var he=d((la,gi)=>{"use strict";var Sr=U(),{isPrimitive:Cr,hasColor:Rr}=_(),Ve=class extends Sr{constructor(e){super(e),this.cursorHide()}async initialize(){let e=await this.resolve(this.initial,this.state);this.input=await this.cast(e),await super.initialize()}dispatch(e){return this.isValue(e)?(this.input=e,this.submit()):this.alert()}format(e){let{styles:t,state:s}=this;return s.submitted?t.success(e):t.primary(e)}cast(e){return this.isTrue(e)}isTrue(e){return/^[ty1]/i.test(e)}isFalse(e){return/^[fn0]/i.test(e)}isValue(e){return Cr(e)&&(this.isTrue(e)||this.isFalse(e))}async hint(){if(this.state.status==="pending"){let e=await this.element("hint");return Rr(e)?e:this.styles.muted(e)}}async render(){let{input:e,size:t}=this.state,s=await this.prefix(),r=await this.separator(),n=await this.message(),a=this.styles.muted(this.default),l=[s,n,a,r].filter(Boolean).join(" ");this.state.prompt=l;let o=await this.header(),h=this.value=this.cast(e),c=await this.format(h),u=await this.error()||await this.hint(),v=await this.footer();u&&!l.includes(u)&&(c+=" "+u),l+=" "+c,this.clear(t),this.write([o,l,v].filter(Boolean).join(`
14
- `)),this.restore()}set value(e){super.value=e}get value(){return this.cast(super.value)}};gi.exports=Ve});var wi=d((oa,yi)=>{"use strict";var _r=he(),je=class extends _r{constructor(e){super(e),this.default=this.options.default||(this.initial?"(Y/n)":"(y/N)")}};yi.exports=je});var vi=d((ha,bi)=>{"use strict";var Ir=D(),kr=oe(),H=kr.prototype,De=class extends Ir{constructor(e){super({...e,multiple:!0}),this.align=[this.options.align,"left"].find(t=>t!=null),this.emptyError="",this.values={}}dispatch(e,t){let s=this.focused,r=s.parent||{};return!s.editable&&!r.editable&&(e==="a"||e==="i")?super[e]():H.dispatch.call(this,e,t)}append(e,t){return H.append.call(this,e,t)}delete(e,t){return H.delete.call(this,e,t)}space(e){return this.focused.editable?this.append(e):super.space()}number(e){return this.focused.editable?this.append(e):super.number(e)}next(){return this.focused.editable?H.next.call(this):super.next()}prev(){return this.focused.editable?H.prev.call(this):super.prev()}async indicator(e,t){let s=e.indicator||"",r=e.editable?s:super.indicator(e,t);return await this.resolve(r,this.state,e,t)||""}indent(e){return e.role==="heading"?"":e.editable?" ":" "}async renderChoice(e,t){return e.indent="",e.editable?H.renderChoice.call(this,e,t):super.renderChoice(e,t)}error(){return""}footer(){return this.state.error}async validate(){let e=!0;for(let t of this.choices){if(typeof t.validate!="function"||t.role==="heading")continue;let s=t.parent?this.value[t.parent.name]:this.value;if(t.editable?s=t.value===t.name?t.initial||"":t.value:this.isDisabled(t)||(s=t.enabled===!0),e=await t.validate(s,this.state),e!==!0)break}return e!==!0&&(this.state.error=typeof e=="string"?e:"Invalid Input"),e}submit(){if(this.focused.newChoice===!0)return super.submit();if(this.choices.some(e=>e.newChoice))return this.alert();this.value={};for(let e of this.choices){let t=e.parent?this.value[e.parent.name]:this.value;if(e.role==="heading"){this.value[e.name]={};continue}e.editable?t[e.name]=e.value===e.name?e.initial||"":e.value:this.isDisabled(e)||(t[e.name]=e.enabled===!0)}return this.base.submit.call(this)}};bi.exports=De});var M=d((ua,xi)=>{"use strict";var Ar=U(),Tr=me(),qr=$e(),{isPrimitive:$r}=_(),Be=class extends Ar{constructor(e){super(e),this.initial=$r(this.initial)?String(this.initial):"",this.initial&&this.cursorHide(),this.state.prevCursor=0,this.state.clipboard=[],this.keypressTimeout=this.options.keypressTimeout!==void 0?this.options.keypressTimeout:null}async keypress(e,t=e?Tr(e,{}):{}){let s=Date.now(),r=s-this.lastKeypress;this.lastKeypress=s;let n=t.name==="return"||t.name==="enter",a=this.state.prevKeypress,l;if(this.state.prevKeypress=t,this.keypressTimeout!=null&&n){if(r<this.keypressTimeout)return this.submit();this.state.multilineBuffer=this.state.multilineBuffer||"",this.state.multilineBuffer+=e,l=!0,a=null}return(l||this.options.multiline&&n)&&(!a||a.name!=="return")?this.append(`
15
- `,t):super.keypress(e,t)}moveCursor(e){this.cursor+=e}reset(){return this.input=this.value="",this.cursor=0,this.render()}dispatch(e,t){if(!e||t.ctrl||t.code)return this.alert();this.append(e)}append(e){let{cursor:t,input:s}=this.state;this.input=`${s}`.slice(0,t)+e+`${s}`.slice(t),this.moveCursor(String(e).length),this.render()}insert(e){this.append(e)}delete(){let{cursor:e,input:t}=this.state;if(e<=0)return this.alert();this.input=`${t}`.slice(0,e-1)+`${t}`.slice(e),this.moveCursor(-1),this.render()}deleteForward(){let{cursor:e,input:t}=this.state;if(t[e]===void 0)return this.alert();this.input=`${t}`.slice(0,e)+`${t}`.slice(e+1),this.render()}cutForward(){let e=this.cursor;if(this.input.length<=e)return this.alert();this.state.clipboard.push(this.input.slice(e)),this.input=this.input.slice(0,e),this.render()}cutLeft(){let e=this.cursor;if(e===0)return this.alert();let t=this.input.slice(0,e),s=this.input.slice(e),r=t.split(" ");this.state.clipboard.push(r.pop()),this.input=r.join(" "),this.cursor=this.input.length,this.input+=s,this.render()}paste(){if(!this.state.clipboard.length)return this.alert();this.insert(this.state.clipboard.pop()),this.render()}toggleCursor(){this.state.prevCursor?(this.cursor=this.state.prevCursor,this.state.prevCursor=0):(this.state.prevCursor=this.cursor,this.cursor=0),this.render()}first(){this.cursor=0,this.render()}last(){this.cursor=this.input.length-1,this.render()}next(){let e=this.initial!=null?String(this.initial):"";if(!e||!e.startsWith(this.input))return this.alert();this.input=this.initial,this.cursor=this.initial.length,this.render()}prev(){if(!this.input)return this.alert();this.reset()}backward(){return this.left()}forward(){return this.right()}right(){return this.cursor>=this.input.length?this.alert():(this.moveCursor(1),this.render())}left(){return this.cursor<=0?this.alert():(this.moveCursor(-1),this.render())}isValue(e){return!!e}async format(e=this.value){let t=await this.resolve(this.initial,this.state);return this.state.submitted?this.styles.submitted(e||t):qr(this,{input:e,initial:t,pos:this.cursor})}async render(){let e=this.state.size,t=await this.prefix(),s=await this.separator(),r=await this.message(),n=[t,r,s].filter(Boolean).join(" ");this.state.prompt=n;let a=await this.header(),l=await this.format(),o=await this.error()||await this.hint(),h=await this.footer();o&&!l.includes(o)&&(l+=" "+o),n+=" "+l,this.clear(e),this.write([a,n,h].filter(Boolean).join(`
16
- `)),this.restore()}};xi.exports=Be});var Si=d((ca,Ei)=>{"use strict";var Pr=i=>i.filter((e,t)=>i.lastIndexOf(e)===t),ue=i=>Pr(i).filter(Boolean);Ei.exports=(i,e={},t="")=>{let{past:s=[],present:r=""}=e,n,a;switch(i){case"prev":case"undo":return n=s.slice(0,s.length-1),a=s[s.length-1]||"",{past:ue([t,...n]),present:a};case"next":case"redo":return n=s.slice(1),a=s[0]||"",{past:ue([...n,t]),present:a};case"save":return{past:ue([...s,t]),present:""};case"remove":return a=ue(s.filter(l=>l!==t)),r="",a.length&&(r=a.pop()),{past:a,present:r};default:throw new Error(`Invalid action: "${i}"`)}}});var We=d((da,Ri)=>{"use strict";var Or=M(),Ci=Si(),Ne=class extends Or{constructor(e){super(e);let t=this.options.history;if(t&&t.store){let s=t.values||this.initial;this.autosave=!!t.autosave,this.store=t.store,this.data=this.store.get("values")||{past:[],present:s},this.initial=this.data.present||this.data.past[this.data.past.length-1]}}completion(e){return this.store?(this.data=Ci(e,this.data,this.input),this.data.present?(this.input=this.data.present,this.cursor=this.input.length,this.render()):this.alert()):this.alert()}altUp(){return this.completion("prev")}altDown(){return this.completion("next")}prev(){return this.save(),super.prev()}save(){this.store&&(this.data=Ci("save",this.data,this.input),this.store.set("values",this.data))}submit(){return this.store&&this.autosave===!0&&this.save(),super.submit()}};Ri.exports=Ne});var Ii=d((pa,_i)=>{"use strict";var Vr=M(),Me=class extends Vr{format(){return""}};_i.exports=Me});var Ai=d((fa,ki)=>{"use strict";var jr=M(),Le=class extends jr{constructor(e={}){super(e),this.sep=this.options.separator||/, */,this.initial=e.initial||""}split(e=this.value){return e?String(e).split(this.sep):[]}format(){let e=this.state.submitted?this.styles.primary:t=>t;return this.list.map(e).join(", ")}async submit(e){let t=this.state.error||await this.validate(this.list,this.state);return t!==!0?(this.state.error=t,super.submit()):(this.value=this.list,super.submit())}get list(){return this.split()}};ki.exports=Le});var qi=d((ma,Ti)=>{"use strict";var Dr=D(),ze=class extends Dr{constructor(e){super({...e,multiple:!0})}};Ti.exports=ze});var Ue=d((ga,$i)=>{"use strict";var Br=M(),Ke=class extends Br{constructor(e={}){super({style:"number",...e}),this.min=this.isValue(e.min)?this.toNumber(e.min):-1/0,this.max=this.isValue(e.max)?this.toNumber(e.max):1/0,this.delay=e.delay!=null?e.delay:1e3,this.float=e.float!==!1,this.round=e.round===!0||e.float===!1,this.major=e.major||10,this.minor=e.minor||1,this.initial=e.initial!=null?e.initial:"",this.input=String(this.initial),this.cursor=this.input.length,this.cursorShow()}append(e){return!/[-+.]/.test(e)||e==="."&&this.input.includes(".")?this.alert("invalid number"):super.append(e)}number(e){return super.append(e)}next(){return this.input&&this.input!==this.initial?this.alert():this.isValue(this.initial)?(this.input=this.initial,this.cursor=String(this.initial).length,this.render()):this.alert()}up(e){let t=e||this.minor,s=this.toNumber(this.input);return s>this.max+t?this.alert():(this.input=`${s+t}`,this.render())}down(e){let t=e||this.minor,s=this.toNumber(this.input);return s<this.min-t?this.alert():(this.input=`${s-t}`,this.render())}shiftDown(){return this.down(this.major)}shiftUp(){return this.up(this.major)}format(e=this.input){return typeof this.options.format=="function"?this.options.format.call(this,e):this.styles.info(e)}toNumber(e=""){return this.float?+e:Math.round(+e)}isValue(e){return/^[-+]?[0-9]+((\.)|(\.[0-9]+))?$/.test(e)}submit(){let e=[this.input,this.initial].find(t=>this.isValue(t));return this.value=this.toNumber(e||0),super.submit()}};$i.exports=Ke});var Oi=d((ya,Pi)=>{Pi.exports=Ue()});var ji=d((wa,Vi)=>{"use strict";var Nr=M(),He=class extends Nr{constructor(e){super(e),this.cursorShow()}format(e=this.input){return this.keypressed?(this.state.submitted?this.styles.primary:this.styles.muted)(this.symbols.asterisk.repeat(e.length)):""}};Vi.exports=He});var Ni=d((ba,Bi)=>{"use strict";var Wr=V(),Mr=J(),Di=_(),Ze=class extends Mr{constructor(e={}){super(e),this.widths=[].concat(e.messageWidth||50),this.align=[].concat(e.align||"left"),this.linebreak=e.linebreak||!1,this.edgeLength=e.edgeLength||3,this.newline=e.newline||`
13
+ `)),this.write(this.margin[2]),this.restore()}};li.exports=Ae});var hi=d((sa,oi)=>{"use strict";var fr=j(),mr=(i,e)=>{let t=i?new RegExp(i,"ig"):/$^/;return s=>i?s.replace(t,r=>e(r)):s},qe=class extends fr{constructor(e){super(e),this.cursorShow()}moveCursor(e){this.state.cursor+=e}dispatch(e){return this.append(e)}space(e){return this.options.multiple?super.space(e):this.append(e)}append(e){let{cursor:t,input:s}=this.state;return this.input=s.slice(0,t)+e+s.slice(t),this.moveCursor(1),this.complete()}delete(){let{cursor:e,input:t}=this.state;return t?(this.input=t.slice(0,e-1)+t.slice(e),this.moveCursor(-1),this.complete()):this.alert()}deleteForward(){let{cursor:e,input:t}=this.state;return t[e]===void 0?this.alert():(this.input=`${t}`.slice(0,e)+`${t}`.slice(e+1),this.complete())}number(e){return this.append(e)}async complete(){this.completing=!0,this.choices=await this.suggest(this.input,this.state._choices),this.state.limit=void 0,this.index=Math.min(Math.max(this.visible.length-1,0),this.index),await this.render(),this.completing=!1}suggest(e=this.input,t=this.state._choices){if(typeof this.options.suggest=="function")return this.options.suggest.call(this,e,t);let s=e.toLowerCase();return t.filter(r=>r.message.toLowerCase().includes(s))}pointer(){return""}format(){if(!this.focused)return this.input;if(this.options.multiple&&this.state.submitted)return this.selected.map(e=>this.styles.primary(e.message)).join(", ");if(this.state.submitted){let e=this.value=this.input=this.focused.value;return this.styles.primary(e)}return this.input}async render(){if(this.state.status!=="pending")return super.render();let e=this.options.highlight||this.styles.complement,t=(n,a)=>n&&(e.stack?e(n):e.call(this,n)),s=mr(this.input,t),r=this.choices;this.choices=r.map(n=>({...n,message:s(n.message)})),await super.render(),this.choices=r}submit(){return this.options.multiple&&(this.value=this.selected.map(e=>e.name)),super.submit()}};oi.exports=qe});var $e=d((ra,ui)=>{"use strict";var Pe=I();ui.exports=(i,e={})=>{i.cursorHide();let{input:t="",initial:s="",pos:r,showCursor:n=!0,color:a}=e,l=a||i.styles.placeholder,o=Pe.inverse(i.styles.primary),h=x=>o(i.styles.black(x)),c=t,u=" ",v=h(u);if(i.blink&&i.blink.off===!0&&(h=x=>x,v=""),n&&r===0&&s===""&&t==="")return h(u);if(n&&r===0&&(t===s||t===""))return h(s[0])+l(s.slice(1));s=Pe.isPrimitive(s)?`${s}`:"",t=Pe.isPrimitive(t)?`${t}`:"";let y=s&&s.startsWith(t)&&s!==t,p=y?h(s[t.length]):v;if(r!==t.length&&n===!0&&(c=t.slice(0,r)+h(t[r])+t.slice(r+1),p=""),n===!1&&(p=""),y){let x=i.styles.unstyle(c+p);return c+p+l(s.slice(x.length))}return c+p}});var oe=d((na,ci)=>{"use strict";var gr=V(),yr=j(),wr=$e(),Te=class extends yr{constructor(e){super({...e,multiple:!0}),this.type="form",this.initial=this.options.initial,this.align=[this.options.align,"right"].find(t=>t!=null),this.emptyError="",this.values={}}async reset(e){return await super.reset(),e===!0&&(this._index=this.index),this.index=this._index,this.values={},this.choices.forEach(t=>t.reset&&t.reset()),this.render()}dispatch(e){return!!e&&this.append(e)}append(e){let t=this.focused;if(!t)return this.alert();let{cursor:s,input:r}=t;return t.value=t.input=r.slice(0,s)+e+r.slice(s),t.cursor++,this.render()}delete(){let e=this.focused;if(!e||e.cursor<=0)return this.alert();let{cursor:t,input:s}=e;return e.value=e.input=s.slice(0,t-1)+s.slice(t),e.cursor--,this.render()}deleteForward(){let e=this.focused;if(!e)return this.alert();let{cursor:t,input:s}=e;if(s[t]===void 0)return this.alert();let r=`${s}`.slice(0,t)+`${s}`.slice(t+1);return e.value=e.input=r,this.render()}right(){let e=this.focused;return e?e.cursor>=e.input.length?this.alert():(e.cursor++,this.render()):this.alert()}left(){let e=this.focused;return e?e.cursor<=0?this.alert():(e.cursor--,this.render()):this.alert()}space(e,t){return this.dispatch(e,t)}number(e,t){return this.dispatch(e,t)}next(){let e=this.focused;if(!e)return this.alert();let{initial:t,input:s}=e;return t&&t.startsWith(s)&&s!==t?(e.value=e.input=t,e.cursor=e.value.length,this.render()):super.next()}prev(){let e=this.focused;return e?e.cursor===0?super.prev():(e.value=e.input="",e.cursor=0,this.render()):this.alert()}separator(){return""}format(e){return this.state.submitted?"":super.format(e)}pointer(){return""}indicator(e){return e.input?"\u29BF":"\u2299"}async choiceSeparator(e,t){let s=await this.resolve(e.separator,this.state,e,t)||":";return s?" "+this.styles.disabled(s):""}async renderChoice(e,t){await this.onChoice(e,t);let{state:s,styles:r}=this,{cursor:n,initial:a="",name:l,input:o=""}=e,{muted:h,submitted:c,primary:u,danger:v}=r,y=this.index===t,p=e.validate||(()=>!0),x=await this.choiceSeparator(e,t),C=e.message;this.align==="right"&&(C=C.padStart(this.longest+1," ")),this.align==="left"&&(C=C.padEnd(this.longest+1," "));let f=this.values[l]=o||a,w=o?"success":"dark";await p.call(e,f,this.state)!==!0&&(w="danger");let m=r[w],E=m(await this.indicator(e,t))+(e.pad||""),S=this.indent(e),A=()=>[S,E,C+x,o].filter(Boolean).join(" ");if(s.submitted)return C=gr(C),o=c(o),A();if(e.format)o=await e.format.call(this,o,e,t);else{let at=this.styles.muted;o=wr(this,{input:o,initial:a,pos:n,showCursor:y,color:at})}return this.isValue(o)||(o=this.styles.muted(this.symbols.ellipsis)),e.result&&(this.values[l]=await e.result.call(this,f,e,t)),y&&(C=u(C)),e.error?o+=(o?" ":"")+v(e.error.trim()):e.hint&&(o+=(o?" ":"")+h(e.hint.trim())),A()}async submit(){return this.value=this.values,super.base.submit.call(this)}};ci.exports=Te});var Oe=d((aa,pi)=>{"use strict";var br=oe(),vr=()=>{throw new Error("expected prompt to have a custom authenticate method")},di=(i=vr)=>{class e extends br{constructor(s){super(s)}async submit(){this.value=await i.call(this,this.values,this.state),super.base.submit.call(this)}static create(s){return di(s)}}return e};pi.exports=di()});var gi=d((la,mi)=>{"use strict";var xr=Oe();function Er(i,e){return i.username===this.options.username&&i.password===this.options.password}var fi=(i=Er)=>{let e=[{name:"username",message:"username"},{name:"password",message:"password",format(s){return this.options.showPassword?s:(this.state.submitted?this.styles.primary:this.styles.muted)(this.symbols.asterisk.repeat(s.length))}}];class t extends xr.create(i){constructor(r){super({...r,choices:e})}static create(r){return fi(r)}}return t};mi.exports=fi()});var he=d((oa,yi)=>{"use strict";var Cr=U(),{isPrimitive:Rr,hasColor:_r}=I(),Ve=class extends Cr{constructor(e){super(e),this.cursorHide()}async initialize(){let e=await this.resolve(this.initial,this.state);this.input=await this.cast(e),await super.initialize()}dispatch(e){return this.isValue(e)?(this.input=e,this.submit()):this.alert()}format(e){let{styles:t,state:s}=this;return s.submitted?t.success(e):t.primary(e)}cast(e){return this.isTrue(e)}isTrue(e){return/^[ty1]/i.test(e)}isFalse(e){return/^[fn0]/i.test(e)}isValue(e){return Rr(e)&&(this.isTrue(e)||this.isFalse(e))}async hint(){if(this.state.status==="pending"){let e=await this.element("hint");return _r(e)?e:this.styles.muted(e)}}async render(){let{input:e,size:t}=this.state,s=await this.prefix(),r=await this.separator(),n=await this.message(),a=this.styles.muted(this.default),l=[s,n,a,r].filter(Boolean).join(" ");this.state.prompt=l;let o=await this.header(),h=this.value=this.cast(e),c=await this.format(h),u=await this.error()||await this.hint(),v=await this.footer();u&&!l.includes(u)&&(c+=" "+u),l+=" "+c,this.clear(t),this.write([o,l,v].filter(Boolean).join(`
14
+ `)),this.restore()}set value(e){super.value=e}get value(){return this.cast(super.value)}};yi.exports=Ve});var bi=d((ha,wi)=>{"use strict";var Ir=he(),De=class extends Ir{constructor(e){super(e),this.default=this.options.default||(this.initial?"(Y/n)":"(y/N)")}};wi.exports=De});var xi=d((ua,vi)=>{"use strict";var Sr=j(),kr=oe(),H=kr.prototype,je=class extends Sr{constructor(e){super({...e,multiple:!0}),this.align=[this.options.align,"left"].find(t=>t!=null),this.emptyError="",this.values={}}dispatch(e,t){let s=this.focused,r=s.parent||{};return!s.editable&&!r.editable&&(e==="a"||e==="i")?super[e]():H.dispatch.call(this,e,t)}append(e,t){return H.append.call(this,e,t)}delete(e,t){return H.delete.call(this,e,t)}space(e){return this.focused.editable?this.append(e):super.space()}number(e){return this.focused.editable?this.append(e):super.number(e)}next(){return this.focused.editable?H.next.call(this):super.next()}prev(){return this.focused.editable?H.prev.call(this):super.prev()}async indicator(e,t){let s=e.indicator||"",r=e.editable?s:super.indicator(e,t);return await this.resolve(r,this.state,e,t)||""}indent(e){return e.role==="heading"?"":e.editable?" ":" "}async renderChoice(e,t){return e.indent="",e.editable?H.renderChoice.call(this,e,t):super.renderChoice(e,t)}error(){return""}footer(){return this.state.error}async validate(){let e=!0;for(let t of this.choices){if(typeof t.validate!="function"||t.role==="heading")continue;let s=t.parent?this.value[t.parent.name]:this.value;if(t.editable?s=t.value===t.name?t.initial||"":t.value:this.isDisabled(t)||(s=t.enabled===!0),e=await t.validate(s,this.state),e!==!0)break}return e!==!0&&(this.state.error=typeof e=="string"?e:"Invalid Input"),e}submit(){if(this.focused.newChoice===!0)return super.submit();if(this.choices.some(e=>e.newChoice))return this.alert();this.value={};for(let e of this.choices){let t=e.parent?this.value[e.parent.name]:this.value;if(e.role==="heading"){this.value[e.name]={};continue}e.editable?t[e.name]=e.value===e.name?e.initial||"":e.value:this.isDisabled(e)||(t[e.name]=e.enabled===!0)}return this.base.submit.call(this)}};vi.exports=je});var L=d((ca,Ei)=>{"use strict";var Ar=U(),qr=me(),Pr=$e(),{isPrimitive:$r}=I(),Ne=class extends Ar{constructor(e){super(e),this.initial=$r(this.initial)?String(this.initial):"",this.initial&&this.cursorHide(),this.state.prevCursor=0,this.state.clipboard=[],this.keypressTimeout=this.options.keypressTimeout!==void 0?this.options.keypressTimeout:null}async keypress(e,t=e?qr(e,{}):{}){let s=Date.now(),r=s-this.lastKeypress;this.lastKeypress=s;let n=t.name==="return"||t.name==="enter",a=this.state.prevKeypress,l;if(this.state.prevKeypress=t,this.keypressTimeout!=null&&n){if(r<this.keypressTimeout)return this.submit();this.state.multilineBuffer=this.state.multilineBuffer||"",this.state.multilineBuffer+=e,l=!0,a=null}return(l||this.options.multiline&&n)&&(!a||a.name!=="return")?this.append(`
15
+ `,t):super.keypress(e,t)}moveCursor(e){this.cursor+=e}reset(){return this.input=this.value="",this.cursor=0,this.render()}dispatch(e,t){if(!e||t.ctrl||t.code)return this.alert();this.append(e)}append(e){let{cursor:t,input:s}=this.state;this.input=`${s}`.slice(0,t)+e+`${s}`.slice(t),this.moveCursor(String(e).length),this.render()}insert(e){this.append(e)}delete(){let{cursor:e,input:t}=this.state;if(e<=0)return this.alert();this.input=`${t}`.slice(0,e-1)+`${t}`.slice(e),this.moveCursor(-1),this.render()}deleteForward(){let{cursor:e,input:t}=this.state;if(t[e]===void 0)return this.alert();this.input=`${t}`.slice(0,e)+`${t}`.slice(e+1),this.render()}cutForward(){let e=this.cursor;if(this.input.length<=e)return this.alert();this.state.clipboard.push(this.input.slice(e)),this.input=this.input.slice(0,e),this.render()}cutLeft(){let e=this.cursor;if(e===0)return this.alert();let t=this.input.slice(0,e),s=this.input.slice(e),r=t.split(" ");this.state.clipboard.push(r.pop()),this.input=r.join(" "),this.cursor=this.input.length,this.input+=s,this.render()}paste(){if(!this.state.clipboard.length)return this.alert();this.insert(this.state.clipboard.pop()),this.render()}toggleCursor(){this.state.prevCursor?(this.cursor=this.state.prevCursor,this.state.prevCursor=0):(this.state.prevCursor=this.cursor,this.cursor=0),this.render()}first(){this.cursor=0,this.render()}last(){this.cursor=this.input.length-1,this.render()}next(){let e=this.initial!=null?String(this.initial):"";if(!e||!e.startsWith(this.input))return this.alert();this.input=this.initial,this.cursor=this.initial.length,this.render()}prev(){if(!this.input)return this.alert();this.reset()}backward(){return this.left()}forward(){return this.right()}right(){return this.cursor>=this.input.length?this.alert():(this.moveCursor(1),this.render())}left(){return this.cursor<=0?this.alert():(this.moveCursor(-1),this.render())}isValue(e){return!!e}async format(e=this.value){let t=await this.resolve(this.initial,this.state);return this.state.submitted?this.styles.submitted(e||t):Pr(this,{input:e,initial:t,pos:this.cursor})}async render(){let e=this.state.size,t=await this.prefix(),s=await this.separator(),r=await this.message(),n=[t,r,s].filter(Boolean).join(" ");this.state.prompt=n;let a=await this.header(),l=await this.format(),o=await this.error()||await this.hint(),h=await this.footer();o&&!l.includes(o)&&(l+=" "+o),n+=" "+l,this.clear(e),this.write([a,n,h].filter(Boolean).join(`
16
+ `)),this.restore()}};Ei.exports=Ne});var Ri=d((da,Ci)=>{"use strict";var Tr=i=>i.filter((e,t)=>i.lastIndexOf(e)===t),ue=i=>Tr(i).filter(Boolean);Ci.exports=(i,e={},t="")=>{let{past:s=[],present:r=""}=e,n,a;switch(i){case"prev":case"undo":return n=s.slice(0,s.length-1),a=s[s.length-1]||"",{past:ue([t,...n]),present:a};case"next":case"redo":return n=s.slice(1),a=s[0]||"",{past:ue([...n,t]),present:a};case"save":return{past:ue([...s,t]),present:""};case"remove":return a=ue(s.filter(l=>l!==t)),r="",a.length&&(r=a.pop()),{past:a,present:r};default:throw new Error(`Invalid action: "${i}"`)}}});var Be=d((pa,Ii)=>{"use strict";var Or=L(),_i=Ri(),We=class extends Or{constructor(e){super(e);let t=this.options.history;if(t&&t.store){let s=t.values||this.initial;this.autosave=!!t.autosave,this.store=t.store,this.data=this.store.get("values")||{past:[],present:s},this.initial=this.data.present||this.data.past[this.data.past.length-1]}}completion(e){return this.store?(this.data=_i(e,this.data,this.input),this.data.present?(this.input=this.data.present,this.cursor=this.input.length,this.render()):this.alert()):this.alert()}altUp(){return this.completion("prev")}altDown(){return this.completion("next")}prev(){return this.save(),super.prev()}save(){this.store&&(this.data=_i("save",this.data,this.input),this.store.set("values",this.data))}submit(){return this.store&&this.autosave===!0&&this.save(),super.submit()}};Ii.exports=We});var ki=d((fa,Si)=>{"use strict";var Vr=L(),Le=class extends Vr{format(){return""}};Si.exports=Le});var qi=d((ma,Ai)=>{"use strict";var Dr=L(),Me=class extends Dr{constructor(e={}){super(e),this.sep=this.options.separator||/, */,this.initial=e.initial||""}split(e=this.value){return e?String(e).split(this.sep):[]}format(){let e=this.state.submitted?this.styles.primary:t=>t;return this.list.map(e).join(", ")}async submit(e){let t=this.state.error||await this.validate(this.list,this.state);return t!==!0?(this.state.error=t,super.submit()):(this.value=this.list,super.submit())}get list(){return this.split()}};Ai.exports=Me});var $i=d((ga,Pi)=>{"use strict";var jr=j(),ze=class extends jr{constructor(e){super({...e,multiple:!0})}};Pi.exports=ze});var Ue=d((ya,Ti)=>{"use strict";var Nr=L(),Ke=class extends Nr{constructor(e={}){super({style:"number",...e}),this.min=this.isValue(e.min)?this.toNumber(e.min):-1/0,this.max=this.isValue(e.max)?this.toNumber(e.max):1/0,this.delay=e.delay!=null?e.delay:1e3,this.float=e.float!==!1,this.round=e.round===!0||e.float===!1,this.major=e.major||10,this.minor=e.minor||1,this.initial=e.initial!=null?e.initial:"",this.input=String(this.initial),this.cursor=this.input.length,this.cursorShow()}append(e){return!/[-+.]/.test(e)||e==="."&&this.input.includes(".")?this.alert("invalid number"):super.append(e)}number(e){return super.append(e)}next(){return this.input&&this.input!==this.initial?this.alert():this.isValue(this.initial)?(this.input=this.initial,this.cursor=String(this.initial).length,this.render()):this.alert()}up(e){let t=e||this.minor,s=this.toNumber(this.input);return s>this.max+t?this.alert():(this.input=`${s+t}`,this.render())}down(e){let t=e||this.minor,s=this.toNumber(this.input);return s<this.min-t?this.alert():(this.input=`${s-t}`,this.render())}shiftDown(){return this.down(this.major)}shiftUp(){return this.up(this.major)}format(e=this.input){return typeof this.options.format=="function"?this.options.format.call(this,e):this.styles.info(e)}toNumber(e=""){return this.float?+e:Math.round(+e)}isValue(e){return/^[-+]?[0-9]+((\.)|(\.[0-9]+))?$/.test(e)}submit(){let e=[this.input,this.initial].find(t=>this.isValue(t));return this.value=this.toNumber(e||0),super.submit()}};Ti.exports=Ke});var Vi=d((wa,Oi)=>{Oi.exports=Ue()});var ji=d((ba,Di)=>{"use strict";var Wr=L(),He=class extends Wr{constructor(e){super(e),this.cursorShow()}format(e=this.input){return this.keypressed?(this.state.submitted?this.styles.primary:this.styles.muted)(this.symbols.asterisk.repeat(e.length)):""}};Di.exports=He});var Bi=d((va,Wi)=>{"use strict";var Br=V(),Lr=J(),Ni=I(),Ze=class extends Lr{constructor(e={}){super(e),this.widths=[].concat(e.messageWidth||50),this.align=[].concat(e.align||"left"),this.linebreak=e.linebreak||!1,this.edgeLength=e.edgeLength||3,this.newline=e.newline||`
17
17
  `;let t=e.startNumber||1;typeof this.scale=="number"&&(this.scaleKey=!1,this.scale=Array(this.scale).fill(0).map((s,r)=>({name:r+t})))}async reset(){return this.tableized=!1,await super.reset(),this.render()}tableize(){if(this.tableized===!0)return;this.tableized=!0;let e=0;for(let t of this.choices){e=Math.max(e,t.message.length),t.scaleIndex=t.initial||2,t.scale=[];for(let s=0;s<this.scale.length;s++)t.scale.push({index:s})}this.widths[0]=Math.min(this.widths[0],e+3)}async dispatch(e,t){if(this.multiple)return this[t.name]?await this[t.name](e,t):await super.dispatch(e,t);this.alert()}heading(e,t,s){return this.styles.strong(e)}separator(){return this.styles.muted(this.symbols.ellipsis)}right(){let e=this.focused;return e.scaleIndex>=this.scale.length-1?this.alert():(e.scaleIndex++,this.render())}left(){let e=this.focused;return e.scaleIndex<=0?this.alert():(e.scaleIndex--,this.render())}indent(){return""}format(){return this.state.submitted?this.choices.map(t=>this.styles.info(t.index)).join(", "):""}pointer(){return""}renderScaleKey(){return this.scaleKey===!1||this.state.submitted?"":["",...this.scale.map(s=>` ${s.name} - ${s.message}`)].map(s=>this.styles.muted(s)).join(`
18
- `)}renderScaleHeading(e){let t=this.scale.map(o=>o.name);typeof this.options.renderScaleHeading=="function"&&(t=this.options.renderScaleHeading.call(this,e));let s=this.scaleLength-t.join("").length,r=Math.round(s/(t.length-1)),a=t.map(o=>this.styles.strong(o)).join(" ".repeat(r)),l=" ".repeat(this.widths[0]);return this.margin[3]+l+this.margin[1]+a}scaleIndicator(e,t,s){if(typeof this.options.scaleIndicator=="function")return this.options.scaleIndicator.call(this,e,t,s);let r=e.scaleIndex===t.index;return t.disabled?this.styles.hint(this.symbols.radio.disabled):r?this.styles.success(this.symbols.radio.on):this.symbols.radio.off}renderScale(e,t){let s=e.scale.map(n=>this.scaleIndicator(e,n,t)),r=this.term==="Hyper"?"":" ";return s.join(r+this.symbols.line.repeat(this.edgeLength))}async renderChoice(e,t){await this.onChoice(e,t);let s=this.index===t,r=await this.pointer(e,t),n=await e.hint;n&&!Di.hasColor(n)&&(n=this.styles.muted(n));let a=p=>this.margin[3]+p.replace(/\s+$/,"").padEnd(this.widths[0]," "),l=this.newline,o=this.indent(e),h=await this.resolve(e.message,this.state,e,t),c=await this.renderScale(e,t),u=this.margin[1]+this.margin[3];this.scaleLength=Wr(c).length,this.widths[0]=Math.min(this.widths[0],this.width-this.scaleLength-u.length);let y=Di.wordWrap(h,{width:this.widths[0],newline:l}).split(`
18
+ `)}renderScaleHeading(e){let t=this.scale.map(o=>o.name);typeof this.options.renderScaleHeading=="function"&&(t=this.options.renderScaleHeading.call(this,e));let s=this.scaleLength-t.join("").length,r=Math.round(s/(t.length-1)),a=t.map(o=>this.styles.strong(o)).join(" ".repeat(r)),l=" ".repeat(this.widths[0]);return this.margin[3]+l+this.margin[1]+a}scaleIndicator(e,t,s){if(typeof this.options.scaleIndicator=="function")return this.options.scaleIndicator.call(this,e,t,s);let r=e.scaleIndex===t.index;return t.disabled?this.styles.hint(this.symbols.radio.disabled):r?this.styles.success(this.symbols.radio.on):this.symbols.radio.off}renderScale(e,t){let s=e.scale.map(n=>this.scaleIndicator(e,n,t)),r=this.term==="Hyper"?"":" ";return s.join(r+this.symbols.line.repeat(this.edgeLength))}async renderChoice(e,t){await this.onChoice(e,t);let s=this.index===t,r=await this.pointer(e,t),n=await e.hint;n&&!Ni.hasColor(n)&&(n=this.styles.muted(n));let a=p=>this.margin[3]+p.replace(/\s+$/,"").padEnd(this.widths[0]," "),l=this.newline,o=this.indent(e),h=await this.resolve(e.message,this.state,e,t),c=await this.renderScale(e,t),u=this.margin[1]+this.margin[3];this.scaleLength=Br(c).length,this.widths[0]=Math.min(this.widths[0],this.width-this.scaleLength-u.length);let y=Ni.wordWrap(h,{width:this.widths[0],newline:l}).split(`
19
19
  `).map(p=>a(p)+this.margin[1]);return s&&(c=this.styles.info(c),y=y.map(p=>this.styles.info(p))),y[0]+=c,this.linebreak&&y.push(""),[o+r,y.join(`
20
20
  `)].filter(Boolean)}async renderChoices(){if(this.state.submitted)return"";this.tableize();let e=this.visible.map(async(r,n)=>await this.renderChoice(r,n)),t=await Promise.all(e),s=await this.renderScaleHeading();return this.margin[0]+[s,...t.map(r=>r.join(" "))].join(`
21
21
  `)}async render(){let{submitted:e,size:t}=this.state,s=await this.prefix(),r=await this.separator(),n=await this.message(),a="";this.options.promptLine!==!1&&(a=[s,n,r,""].join(" "),this.state.prompt=a);let l=await this.header(),o=await this.format(),h=await this.renderScaleKey(),c=await this.error()||await this.hint(),u=await this.renderChoices(),v=await this.footer(),y=this.emptyError;o&&(a+=o),c&&!a.includes(c)&&(a+=" "+c),e&&!o&&!u.trim()&&this.multiple&&y!=null&&(a+=this.styles.danger(y)),this.clear(t),this.write([l,a,h,u,v].filter(Boolean).join(`
22
- `)),this.state.submitted||this.write(this.margin[2]),this.restore()}submit(){this.value={};for(let e of this.choices)this.value[e.name]=e.scaleIndex;return this.base.submit.call(this)}};Bi.exports=Ze});var Li=d((va,Mi)=>{"use strict";var Wi=V(),Lr=(i="")=>typeof i=="string"?i.replace(/^['"]|['"]$/g,""):"",Ge=class{constructor(e){this.name=e.key,this.field=e.field||{},this.value=Lr(e.initial||this.field.initial||""),this.message=e.message||this.name,this.cursor=0,this.input="",this.lines=[]}},zr=async(i={},e={},t=s=>s)=>{let s=new Set,r=i.fields||[],n=i.template,a=[],l=[],o=[],h=1;typeof n=="function"&&(n=await n());let c=-1,u=()=>n[++c],v=()=>n[c+1],y=p=>{p.line=h,a.push(p)};for(y({type:"bos",value:""});c<n.length-1;){let p=u();if(/^[^\S\n ]$/.test(p)){y({type:"text",value:p});continue}if(p===`
23
- `){y({type:"newline",value:p}),h++;continue}if(p==="\\"){p+=u(),y({type:"text",value:p});continue}if((p==="$"||p==="#"||p==="{")&&v()==="{"){let S=u();p+=S;let f={type:"template",open:p,inner:"",close:"",value:p},w;for(;w=u();){if(w==="}"){v()==="}"&&(w+=u()),f.value+=w,f.close=w;break}w===":"?(f.initial="",f.key=f.inner):f.initial!==void 0&&(f.initial+=w),f.value+=w,f.inner+=w}f.template=f.open+(f.initial||f.inner)+f.close,f.key=f.key||f.inner,hasOwnProperty.call(e,f.key)&&(f.initial=e[f.key]),f=t(f),y(f),o.push(f.key),s.add(f.key);let m=l.find(E=>E.name===f.key);f.field=r.find(E=>E.name===f.key),m||(m=new Ge(f),l.push(m)),m.lines.push(f.line-1);continue}let x=a[a.length-1];x.type==="text"&&x.line===h?x.value+=p:y({type:"text",value:p})}return y({type:"eos",value:""}),{input:n,tabstops:a,unique:s,keys:o,items:l}};Mi.exports=async i=>{let e=i.options,t=new Set(e.required===!0?[]:e.required||[]),s={...e.values,...e.initial},{tabstops:r,items:n,keys:a}=await zr(e,s),l=Fe("result",i,e),o=Fe("format",i,e),h=Fe("validate",i,e,!0),c=i.isValue.bind(i);return async(u={},v=!1)=>{let y=0;u.required=t,u.items=n,u.keys=a,u.output="";let p=async(w,m,E,I)=>{let A=await h(w,m,E,I);return A===!1?"Invalid field "+E.name:A};for(let w of r){let m=w.value,E=w.key;if(w.type!=="template"){m&&(u.output+=m);continue}if(w.type==="template"){let I=n.find(L=>L.name===E);e.required===!0&&u.required.add(I.name);let A=[I.input,u.values[I.value],I.value,m].find(c),F=(I.field||{}).message||w.inner;if(v){let L=await p(u.values[E],u,I,y);if(L&&typeof L=="string"||L===!1){u.invalid.set(E,L);continue}u.invalid.delete(E);let ys=await l(u.values[E],u,I,y);u.output+=Wi(ys);continue}I.placeholder=!1;let gs=m;m=await o(m,u,I,y),A!==m?(u.values[E]=A,m=i.styles.typing(A),u.missing.delete(F)):(u.values[E]=void 0,A=`<${F}>`,m=i.styles.primary(A),I.placeholder=!0,u.required.has(E)&&u.missing.add(F)),u.missing.has(F)&&u.validating&&(m=i.styles.warning(A)),u.invalid.has(E)&&u.validating&&(m=i.styles.danger(A)),y===u.index&&(gs!==m?m=i.styles.underline(m):m=i.styles.heading(Wi(m))),y++}m&&(u.output+=m)}let x=u.output.split(`
24
- `).map(w=>" "+w),S=n.length,f=0;for(let w of n)u.invalid.has(w.name)&&w.lines.forEach(m=>{x[m][0]===" "&&(x[m]=u.styles.danger(u.symbols.bullet)+x[m].slice(1))}),i.isValue(u.values[w.name])&&f++;return u.completed=(f/S*100).toFixed(0),u.output=x.join(`
25
- `),u.output}};function Fe(i,e,t,s){return(r,n,a,l)=>typeof a.field[i]=="function"?a.field[i].call(e,r,n,a,l):[s,r].find(o=>e.isValue(o))}});var Ki=d((xa,zi)=>{"use strict";var Kr=V(),Ur=Li(),Hr=U(),Ye=class extends Hr{constructor(e){super(e),this.cursorHide(),this.reset(!0)}async initialize(){this.interpolate=await Ur(this),await super.initialize()}async reset(e){this.state.keys=[],this.state.invalid=new Map,this.state.missing=new Set,this.state.completed=0,this.state.values={},e!==!0&&(await this.initialize(),await this.render())}moveCursor(e){let t=this.getItem();this.cursor+=e,t.cursor+=e}dispatch(e,t){if(!t.code&&!t.ctrl&&e!=null&&this.getItem()){this.append(e,t);return}this.alert()}append(e,t){let s=this.getItem(),r=s.input.slice(0,this.cursor),n=s.input.slice(this.cursor);this.input=s.input=`${r}${e}${n}`,this.moveCursor(1),this.render()}delete(){let e=this.getItem();if(this.cursor<=0||!e.input)return this.alert();let t=e.input.slice(this.cursor),s=e.input.slice(0,this.cursor-1);this.input=e.input=`${s}${t}`,this.moveCursor(-1),this.render()}increment(e){return e>=this.state.keys.length-1?0:e+1}decrement(e){return e<=0?this.state.keys.length-1:e-1}first(){this.state.index=0,this.render()}last(){this.state.index=this.state.keys.length-1,this.render()}right(){if(this.cursor>=this.input.length)return this.alert();this.moveCursor(1),this.render()}left(){if(this.cursor<=0)return this.alert();this.moveCursor(-1),this.render()}prev(){this.state.index=this.decrement(this.state.index),this.getItem(),this.render()}next(){this.state.index=this.increment(this.state.index),this.getItem(),this.render()}up(){this.prev()}down(){this.next()}format(e){let t=this.state.completed<100?this.styles.warning:this.styles.success;return this.state.submitted===!0&&this.state.completed!==100&&(t=this.styles.danger),t(`${this.state.completed}% completed`)}async render(){let{index:e,keys:t=[],submitted:s,size:r}=this.state,n=[this.options.newline,`
26
- `].find(w=>w!=null),a=await this.prefix(),l=await this.separator(),o=await this.message(),h=[a,o,l].filter(Boolean).join(" ");this.state.prompt=h;let c=await this.header(),u=await this.error()||"",v=await this.hint()||"",y=s?"":await this.interpolate(this.state),p=this.state.key=t[e]||"",x=await this.format(p),S=await this.footer();x&&(h+=" "+x),v&&!x&&this.state.completed===0&&(h+=" "+v),this.clear(r);let f=[c,h,y,S,u.trim()];this.write(f.filter(Boolean).join(n)),this.restore()}getItem(e){let{items:t,keys:s,index:r}=this.state,n=t.find(a=>a.name===s[r]);return n&&n.input!=null&&(this.input=n.input,this.cursor=n.cursor),n}async submit(){typeof this.interpolate!="function"&&await this.initialize(),await this.interpolate(this.state,!0);let{invalid:e,missing:t,output:s,values:r}=this.state;if(e.size){let l="";for(let[o,h]of e)l+=`Invalid ${o}: ${h}
22
+ `)),this.state.submitted||this.write(this.margin[2]),this.restore()}submit(){this.value={};for(let e of this.choices)this.value[e.name]=e.scaleIndex;return this.base.submit.call(this)}};Wi.exports=Ze});var zi=d((xa,Mi)=>{"use strict";var Li=V(),Mr=(i="")=>typeof i=="string"?i.replace(/^['"]|['"]$/g,""):"",Ge=class{constructor(e){this.name=e.key,this.field=e.field||{},this.value=Mr(e.initial||this.field.initial||""),this.message=e.message||this.name,this.cursor=0,this.input="",this.lines=[]}},zr=async(i={},e={},t=s=>s)=>{let s=new Set,r=i.fields||[],n=i.template,a=[],l=[],o=[],h=1;typeof n=="function"&&(n=await n());let c=-1,u=()=>n[++c],v=()=>n[c+1],y=p=>{p.line=h,a.push(p)};for(y({type:"bos",value:""});c<n.length-1;){let p=u();if(/^[^\S\n ]$/.test(p)){y({type:"text",value:p});continue}if(p===`
23
+ `){y({type:"newline",value:p}),h++;continue}if(p==="\\"){p+=u(),y({type:"text",value:p});continue}if((p==="$"||p==="#"||p==="{")&&v()==="{"){let C=u();p+=C;let f={type:"template",open:p,inner:"",close:"",value:p},w;for(;w=u();){if(w==="}"){v()==="}"&&(w+=u()),f.value+=w,f.close=w;break}w===":"?(f.initial="",f.key=f.inner):f.initial!==void 0&&(f.initial+=w),f.value+=w,f.inner+=w}f.template=f.open+(f.initial||f.inner)+f.close,f.key=f.key||f.inner,hasOwnProperty.call(e,f.key)&&(f.initial=e[f.key]),f=t(f),y(f),o.push(f.key),s.add(f.key);let m=l.find(E=>E.name===f.key);f.field=r.find(E=>E.name===f.key),m||(m=new Ge(f),l.push(m)),m.lines.push(f.line-1);continue}let x=a[a.length-1];x.type==="text"&&x.line===h?x.value+=p:y({type:"text",value:p})}return y({type:"eos",value:""}),{input:n,tabstops:a,unique:s,keys:o,items:l}};Mi.exports=async i=>{let e=i.options,t=new Set(e.required===!0?[]:e.required||[]),s={...e.values,...e.initial},{tabstops:r,items:n,keys:a}=await zr(e,s),l=Fe("result",i,e),o=Fe("format",i,e),h=Fe("validate",i,e,!0),c=i.isValue.bind(i);return async(u={},v=!1)=>{let y=0;u.required=t,u.items=n,u.keys=a,u.output="";let p=async(w,m,E,S)=>{let A=await h(w,m,E,S);return A===!1?"Invalid field "+E.name:A};for(let w of r){let m=w.value,E=w.key;if(w.type!=="template"){m&&(u.output+=m);continue}if(w.type==="template"){let S=n.find(M=>M.name===E);e.required===!0&&u.required.add(S.name);let A=[S.input,u.values[S.value],S.value,m].find(c),F=(S.field||{}).message||w.inner;if(v){let M=await p(u.values[E],u,S,y);if(M&&typeof M=="string"||M===!1){u.invalid.set(E,M);continue}u.invalid.delete(E);let ys=await l(u.values[E],u,S,y);u.output+=Li(ys);continue}S.placeholder=!1;let gs=m;m=await o(m,u,S,y),A!==m?(u.values[E]=A,m=i.styles.typing(A),u.missing.delete(F)):(u.values[E]=void 0,A=`<${F}>`,m=i.styles.primary(A),S.placeholder=!0,u.required.has(E)&&u.missing.add(F)),u.missing.has(F)&&u.validating&&(m=i.styles.warning(A)),u.invalid.has(E)&&u.validating&&(m=i.styles.danger(A)),y===u.index&&(gs!==m?m=i.styles.underline(m):m=i.styles.heading(Li(m))),y++}m&&(u.output+=m)}let x=u.output.split(`
24
+ `).map(w=>" "+w),C=n.length,f=0;for(let w of n)u.invalid.has(w.name)&&w.lines.forEach(m=>{x[m][0]===" "&&(x[m]=u.styles.danger(u.symbols.bullet)+x[m].slice(1))}),i.isValue(u.values[w.name])&&f++;return u.completed=(f/C*100).toFixed(0),u.output=x.join(`
25
+ `),u.output}};function Fe(i,e,t,s){return(r,n,a,l)=>typeof a.field[i]=="function"?a.field[i].call(e,r,n,a,l):[s,r].find(o=>e.isValue(o))}});var Ui=d((Ea,Ki)=>{"use strict";var Kr=V(),Ur=zi(),Hr=U(),Ye=class extends Hr{constructor(e){super(e),this.cursorHide(),this.reset(!0)}async initialize(){this.interpolate=await Ur(this),await super.initialize()}async reset(e){this.state.keys=[],this.state.invalid=new Map,this.state.missing=new Set,this.state.completed=0,this.state.values={},e!==!0&&(await this.initialize(),await this.render())}moveCursor(e){let t=this.getItem();this.cursor+=e,t.cursor+=e}dispatch(e,t){if(!t.code&&!t.ctrl&&e!=null&&this.getItem()){this.append(e,t);return}this.alert()}append(e,t){let s=this.getItem(),r=s.input.slice(0,this.cursor),n=s.input.slice(this.cursor);this.input=s.input=`${r}${e}${n}`,this.moveCursor(1),this.render()}delete(){let e=this.getItem();if(this.cursor<=0||!e.input)return this.alert();let t=e.input.slice(this.cursor),s=e.input.slice(0,this.cursor-1);this.input=e.input=`${s}${t}`,this.moveCursor(-1),this.render()}increment(e){return e>=this.state.keys.length-1?0:e+1}decrement(e){return e<=0?this.state.keys.length-1:e-1}first(){this.state.index=0,this.render()}last(){this.state.index=this.state.keys.length-1,this.render()}right(){if(this.cursor>=this.input.length)return this.alert();this.moveCursor(1),this.render()}left(){if(this.cursor<=0)return this.alert();this.moveCursor(-1),this.render()}prev(){this.state.index=this.decrement(this.state.index),this.getItem(),this.render()}next(){this.state.index=this.increment(this.state.index),this.getItem(),this.render()}up(){this.prev()}down(){this.next()}format(e){let t=this.state.completed<100?this.styles.warning:this.styles.success;return this.state.submitted===!0&&this.state.completed!==100&&(t=this.styles.danger),t(`${this.state.completed}% completed`)}async render(){let{index:e,keys:t=[],submitted:s,size:r}=this.state,n=[this.options.newline,`
26
+ `].find(w=>w!=null),a=await this.prefix(),l=await this.separator(),o=await this.message(),h=[a,o,l].filter(Boolean).join(" ");this.state.prompt=h;let c=await this.header(),u=await this.error()||"",v=await this.hint()||"",y=s?"":await this.interpolate(this.state),p=this.state.key=t[e]||"",x=await this.format(p),C=await this.footer();x&&(h+=" "+x),v&&!x&&this.state.completed===0&&(h+=" "+v),this.clear(r);let f=[c,h,y,C,u.trim()];this.write(f.filter(Boolean).join(n)),this.restore()}getItem(e){let{items:t,keys:s,index:r}=this.state,n=t.find(a=>a.name===s[r]);return n&&n.input!=null&&(this.input=n.input,this.cursor=n.cursor),n}async submit(){typeof this.interpolate!="function"&&await this.initialize(),await this.interpolate(this.state,!0);let{invalid:e,missing:t,output:s,values:r}=this.state;if(e.size){let l="";for(let[o,h]of e)l+=`Invalid ${o}: ${h}
27
27
  `;return this.state.error=l,super.submit()}if(t.size)return this.state.error="Required: "+[...t.keys()].join(", "),super.submit();let a=Kr(s).split(`
28
28
  `).map(l=>l.slice(1)).join(`
29
- `);return this.value={values:r,result:a},super.submit()}};zi.exports=Ye});var Hi=d((Ea,Ui)=>{"use strict";var Zr="(Use <shift>+<up/down> to sort)",Fr=D(),Je=class extends Fr{constructor(e){super({...e,reorder:!1,sort:!0,multiple:!0}),this.state.hint=[this.options.hint,Zr].find(this.isValue.bind(this))}indicator(){return""}async renderChoice(e,t){let s=await super.renderChoice(e,t),r=this.symbols.identicalTo+" ",n=this.index===t&&this.sorting?this.styles.muted(r):" ";return this.options.drag===!1&&(n=""),this.options.numbered===!0?n+`${t+1} - `+s:n+s}get selected(){return this.choices}submit(){return this.value=this.choices.map(e=>e.value),super.submit()}};Ui.exports=Je});var Fi=d((Sa,Zi)=>{"use strict";var Gr=J(),Qe=class extends Gr{constructor(e={}){if(super(e),this.emptyError=e.emptyError||"No items were selected",this.term=process.env.TERM_PROGRAM,!this.options.header){let t=["","4 - Strongly Agree","3 - Agree","2 - Neutral","1 - Disagree","0 - Strongly Disagree",""];t=t.map(s=>this.styles.muted(s)),this.state.header=t.join(`
30
- `)}}async toChoices(...e){if(this.createdScales)return!1;this.createdScales=!0;let t=await super.toChoices(...e);for(let s of t)s.scale=Yr(5,this.options),s.scaleIdx=2;return t}dispatch(){this.alert()}space(){let e=this.focused,t=e.scale[e.scaleIdx],s=t.selected;return e.scale.forEach(r=>r.selected=!1),t.selected=!s,this.render()}indicator(){return""}pointer(){return""}separator(){return this.styles.muted(this.symbols.ellipsis)}right(){let e=this.focused;return e.scaleIdx>=e.scale.length-1?this.alert():(e.scaleIdx++,this.render())}left(){let e=this.focused;return e.scaleIdx<=0?this.alert():(e.scaleIdx--,this.render())}indent(){return" "}async renderChoice(e,t){await this.onChoice(e,t);let s=this.index===t,r=this.term==="Hyper",n=r?9:8,a=r?"":" ",l=this.symbols.line.repeat(n),o=" ".repeat(n+(r?0:1)),h=m=>(m?this.styles.success("\u25C9"):"\u25EF")+a,c=t+1+".",u=s?this.styles.heading:this.styles.noop,v=await this.resolve(e.message,this.state,e,t),y=this.indent(e),p=y+e.scale.map((m,E)=>h(E===e.scaleIdx)).join(l),x=m=>m===e.scaleIdx?u(m):m,S=y+e.scale.map((m,E)=>x(E)).join(o),f=()=>[c,v].filter(Boolean).join(" "),w=()=>[f(),p,S," "].filter(Boolean).join(`
31
- `);return s&&(p=this.styles.cyan(p),S=this.styles.cyan(S)),w()}async renderChoices(){if(this.state.submitted)return"";let e=this.visible.map(async(s,r)=>await this.renderChoice(s,r)),t=await Promise.all(e);return t.length||t.push(this.styles.danger("No matching choices")),t.join(`
29
+ `);return this.value={values:r,result:a},super.submit()}};Ki.exports=Ye});var Zi=d((Ca,Hi)=>{"use strict";var Zr="(Use <shift>+<up/down> to sort)",Fr=j(),Je=class extends Fr{constructor(e){super({...e,reorder:!1,sort:!0,multiple:!0}),this.state.hint=[this.options.hint,Zr].find(this.isValue.bind(this))}indicator(){return""}async renderChoice(e,t){let s=await super.renderChoice(e,t),r=this.symbols.identicalTo+" ",n=this.index===t&&this.sorting?this.styles.muted(r):" ";return this.options.drag===!1&&(n=""),this.options.numbered===!0?n+`${t+1} - `+s:n+s}get selected(){return this.choices}submit(){return this.value=this.choices.map(e=>e.value),super.submit()}};Hi.exports=Je});var Gi=d((Ra,Fi)=>{"use strict";var Gr=J(),Qe=class extends Gr{constructor(e={}){if(super(e),this.emptyError=e.emptyError||"No items were selected",this.term=process.env.TERM_PROGRAM,!this.options.header){let t=["","4 - Strongly Agree","3 - Agree","2 - Neutral","1 - Disagree","0 - Strongly Disagree",""];t=t.map(s=>this.styles.muted(s)),this.state.header=t.join(`
30
+ `)}}async toChoices(...e){if(this.createdScales)return!1;this.createdScales=!0;let t=await super.toChoices(...e);for(let s of t)s.scale=Yr(5,this.options),s.scaleIdx=2;return t}dispatch(){this.alert()}space(){let e=this.focused,t=e.scale[e.scaleIdx],s=t.selected;return e.scale.forEach(r=>r.selected=!1),t.selected=!s,this.render()}indicator(){return""}pointer(){return""}separator(){return this.styles.muted(this.symbols.ellipsis)}right(){let e=this.focused;return e.scaleIdx>=e.scale.length-1?this.alert():(e.scaleIdx++,this.render())}left(){let e=this.focused;return e.scaleIdx<=0?this.alert():(e.scaleIdx--,this.render())}indent(){return" "}async renderChoice(e,t){await this.onChoice(e,t);let s=this.index===t,r=this.term==="Hyper",n=r?9:8,a=r?"":" ",l=this.symbols.line.repeat(n),o=" ".repeat(n+(r?0:1)),h=m=>(m?this.styles.success("\u25C9"):"\u25EF")+a,c=t+1+".",u=s?this.styles.heading:this.styles.noop,v=await this.resolve(e.message,this.state,e,t),y=this.indent(e),p=y+e.scale.map((m,E)=>h(E===e.scaleIdx)).join(l),x=m=>m===e.scaleIdx?u(m):m,C=y+e.scale.map((m,E)=>x(E)).join(o),f=()=>[c,v].filter(Boolean).join(" "),w=()=>[f(),p,C," "].filter(Boolean).join(`
31
+ `);return s&&(p=this.styles.cyan(p),C=this.styles.cyan(C)),w()}async renderChoices(){if(this.state.submitted)return"";let e=this.visible.map(async(s,r)=>await this.renderChoice(s,r)),t=await Promise.all(e);return t.length||t.push(this.styles.danger("No matching choices")),t.join(`
32
32
  `)}format(){return this.state.submitted?this.choices.map(t=>this.styles.info(t.scaleIdx)).join(", "):""}async render(){let{submitted:e,size:t}=this.state,s=await this.prefix(),r=await this.separator(),n=await this.message(),a=[s,n,r].filter(Boolean).join(" ");this.state.prompt=a;let l=await this.header(),o=await this.format(),h=await this.error()||await this.hint(),c=await this.renderChoices(),u=await this.footer();(o||!h)&&(a+=" "+o),h&&!a.includes(h)&&(a+=" "+h),e&&!o&&!c&&this.multiple&&this.type!=="form"&&(a+=this.styles.danger(this.emptyError)),this.clear(t),this.write([a,l,c,u].filter(Boolean).join(`
33
- `)),this.restore()}submit(){this.value={};for(let e of this.choices)this.value[e.name]=e.scaleIdx;return this.base.submit.call(this)}};function Yr(i,e={}){if(Array.isArray(e.scale))return e.scale.map(s=>({...s}));let t=[];for(let s=1;s<i+1;s++)t.push({i:s,selected:!1});return t}Zi.exports=Qe});var Yi=d((Ca,Gi)=>{Gi.exports=We()});var Qi=d((Ra,Ji)=>{"use strict";var Jr=he(),Xe=class extends Jr{async initialize(){await super.initialize(),this.value=this.initial=this.resolve(this.options.initial),this.disabled=this.options.disabled||"no",this.enabled=this.options.enabled||"yes",await this.render()}reset(){this.value=this.initial,this.render()}delete(){this.alert()}toggle(){this.value=!this.value,this.render()}enable(){if(this.value===!0)return this.alert();this.value=!0,this.render()}disable(){if(this.value===!1)return this.alert();this.value=!1,this.render()}up(){this.toggle()}down(){this.toggle()}right(){this.toggle()}left(){this.toggle()}next(){this.toggle()}prev(){this.toggle()}dispatch(e="",t){switch(e.toLowerCase()){case" ":return this.toggle();case"1":case"y":case"t":return this.enable();case"0":case"n":case"f":return this.disable();default:return this.alert()}}format(){let e=s=>this.styles.primary.underline(s);return[this.value?this.disabled:e(this.disabled),this.value?e(this.enabled):this.enabled].join(this.styles.muted(" / "))}async render(){let{size:e}=this.state,t=await this.header(),s=await this.prefix(),r=await this.separator(),n=await this.message(),a=await this.format(),l=await this.error()||await this.hint(),o=await this.footer(),h=[s,n,r,a].join(" ");this.state.prompt=h,l&&!h.includes(l)&&(h+=" "+l),this.clear(e),this.write([t,h,o].filter(Boolean).join(`
34
- `)),this.write(this.margin[2]),this.restore()}};Ji.exports=Xe});var es=d((_a,Xi)=>{"use strict";var Qr=D(),et=class extends Qr{constructor(e){if(super(e),typeof this.options.correctChoice!="number"||this.options.correctChoice<0)throw new Error("Please specify the index of the correct answer from the list of choices")}async toChoices(e,t){let s=await super.toChoices(e,t);if(s.length<2)throw new Error("Please give at least two choices to the user");if(this.options.correctChoice>s.length)throw new Error("Please specify the index of the correct answer from the list of choices");return s}check(e){return e.index===this.options.correctChoice}async result(e){return{selectedAnswer:e,correctAnswer:this.options.choices[this.options.correctChoice].value,correct:await this.check(this.state)}}};Xi.exports=et});var is=d(tt=>{"use strict";var ts=_(),C=(i,e)=>{ts.defineExport(tt,i,e),ts.defineExport(tt,i.toLowerCase(),e)};C("AutoComplete",()=>oi());C("BasicAuth",()=>mi());C("Confirm",()=>wi());C("Editable",()=>vi());C("Form",()=>oe());C("Input",()=>We());C("Invisible",()=>Ii());C("List",()=>Ai());C("MultiSelect",()=>qi());C("Numeral",()=>Oi());C("Password",()=>ji());C("Scale",()=>Ni());C("Select",()=>D());C("Snippet",()=>Ki());C("Sort",()=>Hi());C("Survey",()=>Fi());C("Text",()=>Yi());C("Toggle",()=>Qi());C("Quiz",()=>es())});var rs=d((ka,ss)=>{ss.exports={ArrayPrompt:J(),AuthPrompt:Oe(),BooleanPrompt:he(),NumberPrompt:Ue(),StringPrompt:M()}});var ls=d((Aa,as)=>{"use strict";var ns=X("assert"),st=X("events"),B=_(),P=class extends st{constructor(e,t){super(),this.options=B.merge({},e),this.answers={...t}}register(e,t){if(B.isObject(e)){for(let r of Object.keys(e))this.register(r,e[r]);return this}ns.equal(typeof t,"function","expected a function");let s=e.toLowerCase();return t.prototype instanceof this.Prompt?this.prompts[s]=t:this.prompts[s]=t(this.Prompt,this),this}async prompt(e=[]){for(let t of[].concat(e))try{typeof t=="function"&&(t=await t.call(this)),await this.ask(B.merge({},this.options,t))}catch(s){return Promise.reject(s)}return this.answers}async ask(e){typeof e=="function"&&(e=await e.call(this));let t=B.merge({},this.options,e),{type:s,name:r}=e,{set:n,get:a}=B;if(typeof s=="function"&&(s=await s.call(this,e,this.answers)),!s)return this.answers[r];s==="number"&&(s="numeral"),ns(this.prompts[s],`Prompt "${s}" is not registered`);let l=new this.prompts[s](t),o=a(this.answers,r);l.state.answers=this.answers,l.enquirer=this,r&&l.on("submit",c=>{this.emit("answer",r,c,l),n(this.answers,r,c)});let h=l.emit.bind(l);return l.emit=(...c)=>(this.emit.call(this,...c),h(...c)),this.emit("prompt",l,this),t.autofill&&o!=null?(l.value=l.input=o,t.autofill==="show"&&await l.submit()):o=l.value=await l.run(),o}use(e){return e.call(this,this),this}set Prompt(e){this._Prompt=e}get Prompt(){return this._Prompt||this.constructor.Prompt}get prompts(){return this.constructor.prompts}static set Prompt(e){this._Prompt=e}static get Prompt(){return this._Prompt||U()}static get prompts(){return is()}static get types(){return rs()}static get prompt(){let e=(t,...s)=>{let r=new this(...s),n=r.emit.bind(r);return r.emit=(...a)=>(e.emit(...a),n(...a)),r.prompt(t)};return B.mixinEmitter(e,new st),e}};B.mixinEmitter(P,new st);var it=P.prompts;for(let i of Object.keys(it)){let e=i.toLowerCase(),t=s=>new it[i](s).run();P.prompt[e]=t,P[e]=t,P[i]||Reflect.defineProperty(P,i,{get:()=>it[i]})}var Q=i=>{B.defineExport(P,i,()=>P.types[i])};Q("ArrayPrompt");Q("AuthPrompt");Q("BooleanPrompt");Q("NumberPrompt");Q("StringPrompt");as.exports=P});var z=["ASSIST_REVIEW_PROVIDER","ASSIST_REVIEW_BASE_URL","ASSIST_REVIEW_REVIEWER_1","ASSIST_REVIEW_REVIEWER_2","ASSIST_REVIEW_SYNTHESIS"],lt=["ASSIST_REVIEW_AZURE_CLIENT_ID","ASSIST_REVIEW_AZURE_TENANT_ID","ASSIST_REVIEW_ENVIRONMENT"],T="ASSIST_REVIEW_API_KEY",ee=["litellm","foundry"],ce=["claude","codex"];function ot(i,e){if(i==="litellm")return{anthropic:e,responses:`${e}/v1`,anthropicKind:"gateway"};if(i==="foundry")return{anthropic:`${e}/anthropic`,responses:`${e}/openai/v1`,anthropicKind:"foundry"};throw new Error(`Unsupported ASSIST_REVIEW_PROVIDER "${i}" (expected one of: ${ee.join(", ")})`)}async function de(i,e,t){try{let s=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",...e},body:JSON.stringify(t),signal:AbortSignal.timeout(6e4)});if(s.ok)return;let r=(await s.text()).trim().slice(0,300);return`HTTP ${s.status}${r?`: ${r}`:""}`}catch(s){if(!(s instanceof Error))return String(s);let r=s.cause instanceof Error?s.cause.message:"";return r?`${s.message} (${r})`:s.message}}function Rs(i,e,t){let s={Authorization:`Bearer ${t}`};return i.auth.kind==="entra"?s:e.anthropicKind==="foundry"?{"x-api-key":t}:{...s,"x-api-key":t}}async function _s(i,e,t,s){if(i.harness==="codex"){let a=`${t.responses}/responses`,l=await de(a,{Authorization:`Bearer ${s}`},{model:i.model,input:"ping",max_output_tokens:16});return l&&`Codex model "${i.model}" at ${a}: ${l}`}let r=`${t.anthropic}/v1/messages`,n=await de(r,{...Rs(e,t,s),"anthropic-version":"2023-06-01"},{model:i.model,max_tokens:1,messages:[{role:"user",content:"ping"}]});return n&&`Claude model "${i.model}" at ${r}: ${n}`}function Is(i){let e=new Map;for(let t of Object.values(i.slots))e.set(`${t.harness}:${t.model}`,t);return[...e.values()]}async function ht(i,e,t){return(await Promise.all(Is(i).map(r=>_s(r,i,e,t)))).filter(r=>!!r)}function ks(i){return ce.includes(i)}function ut(i,e){let t=e.indexOf(":"),s=e.slice(0,t).trim(),r=e.slice(t+1).trim();return t===-1||!ks(s)||!r?`${i} "${e}" must be ${ce.map(n=>`${n}:<model>`).join(" or ")}`:{harness:s,model:r}}function te(i,e){return i==="foundry"&&e("ASSIST_REVIEW_AZURE_CLIENT_ID")?["ASSIST_REVIEW_AZURE_CLIENT_ID","ASSIST_REVIEW_AZURE_TENANT_ID"]:[T]}function ct(i,e){return te(i,e).includes(T)?{kind:"key",apiKey:e(T)}:{kind:"entra",clientId:e("ASSIST_REVIEW_AZURE_CLIENT_ID"),tenantId:e("ASSIST_REVIEW_AZURE_TENANT_ID")}}var As={claude:"ASSIST_REVIEW_REVIEWER_1",codex:"ASSIST_REVIEW_REVIEWER_2",synthesis:"ASSIST_REVIEW_SYNTHESIS"};function dt(i){let e=a=>i[a]?.trim()??"",t=e("ASSIST_REVIEW_PROVIDER"),s=[...z,...te(t,e)].filter(a=>!e(a));if(s.length>0)return{config:null,errors:s.map(a=>`${a} is not set`)};let r=Object.entries(As).map(([a,l])=>[a,ut(l,e(l))]),n=r.flatMap(([,a])=>typeof a=="string"?[a]:[]);return n.length>0?{config:null,errors:n}:{config:{provider:t,baseUrl:e("ASSIST_REVIEW_BASE_URL").replace(/\/+$/,""),slots:Object.fromEntries(r),auth:ct(t,e)},errors:n}}var ie="https://cognitiveservices.azure.com";var pt=3e4;async function ft(i,e){if(!i.ok){let t=(await i.text()).trim().slice(0,300);throw new Error(`${e}: HTTP ${i.status}${t?`: ${t}`:""}`)}return await i.json()}async function Ts(i,e){let t=new URL(i);t.searchParams.set("audience","api://AzureADTokenExchange");let s=await fetch(t,{headers:{Authorization:`bearer ${e}`},signal:AbortSignal.timeout(pt)}),r=await ft(s,"GitHub OIDC token request failed");if(!r.value)throw new Error("GitHub OIDC token response had no value");return r.value}async function mt(i,e,t){let s=await Ts(t.requestUrl,t.requestToken),r=await fetch(`https://login.microsoftonline.com/${encodeURIComponent(e)}/oauth2/v2.0/token`,{method:"POST",body:new URLSearchParams({grant_type:"client_credentials",client_id:i,scope:`${ie}/.default`,client_assertion_type:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer",client_assertion:s}),signal:AbortSignal.timeout(pt)}),n=await ft(r,`Entra token exchange for client ${i} failed`);if(!n.access_token)throw new Error("Entra token response had no access_token");return n.access_token}import{execFileSync as qs}from"node:child_process";function gt(i){try{return qs("az",["account","get-access-token","--resource",ie,"--tenant",i,"--query","accessToken","-o","tsv"],{encoding:"utf8",stdio:["ignore","pipe","pipe"],shell:process.platform==="win32"}).trim()}catch(e){let t=e.stderr?.trim();throw new Error(`az account get-access-token failed for tenant ${i}${t?`: ${t}`:""}; run az login --tenant ${i}`)}}async function yt(i,e){if(i.kind==="key")return i.apiKey;let t=e.ACTIONS_ID_TOKEN_REQUEST_URL,s=e.ACTIONS_ID_TOKEN_REQUEST_TOKEN;if(t&&s){let r=await mt(i.clientId,i.tenantId,{requestUrl:t,requestToken:s});return console.log(`::add-mask::${r}`),r}if(e.GITHUB_ACTIONS)throw new Error("No GitHub OIDC token endpoint; give the job the id-token: write permission");return gt(i.tenantId)}function wt(i){return i instanceof Error?i.message:String(i)}async function bt(i){let{config:e,errors:t}=dt(i);if(!e)return t;let s;try{s=ot(e.provider,e.baseUrl)}catch(n){return[wt(n)]}let r;try{r=await yt(e.auth,i)}catch(n){return[wt(n)]}return ht(e,s,r)}var hs=Cs(ls(),1);async function os(i){try{return await i}catch(e){throw(e===""||e===void 0)&&process.exit(0),e}}var rt="(claude:<model> or codex:<model>)",Xr={ASSIST_REVIEW_PROVIDER:{name:"value",type:"select",message:"Provider",choices:[...ee]},ASSIST_REVIEW_BASE_URL:{name:"value",type:"input",message:"Base URL (litellm: the proxy root; foundry: https://<resource>.services.ai.azure.com)"},ASSIST_REVIEW_REVIEWER_1:{name:"value",type:"input",message:`Reviewer 1 ${rt}`},ASSIST_REVIEW_REVIEWER_2:{name:"value",type:"input",message:`Reviewer 2 ${rt}`},ASSIST_REVIEW_SYNTHESIS:{name:"value",type:"input",message:`Synthesis ${rt}`},ASSIST_REVIEW_AZURE_CLIENT_ID:{name:"value",type:"input",message:"Azure client ID for Entra auth (blank to use an API key)"},ASSIST_REVIEW_AZURE_TENANT_ID:{name:"value",type:"input",message:"Azure tenant ID"},ASSIST_REVIEW_ENVIRONMENT:{name:"value",type:"input",message:"GitHub environment the federated credential is scoped to (blank for none)"},ASSIST_REVIEW_API_KEY:{name:"value",type:"password",message:"API key"}};async function Z(i,e,t=!1){let s=e[i]?.trim();if(s)return s;if(!process.stdin.isTTY){if(t)return"";throw new Error(`${i} was not given and stdin is not a terminal to prompt for it`)}return(await os(hs.default.prompt(Xr[i]))).value.trim()}async function us(i,e){let t={...i,[T]:e[T]},s={};for(let r of z)s[r]=await Z(r,t);if(s.ASSIST_REVIEW_PROVIDER==="foundry"){let r=await Z("ASSIST_REVIEW_AZURE_CLIENT_ID",t,!0);if(r)return s.ASSIST_REVIEW_AZURE_CLIENT_ID=r,s.ASSIST_REVIEW_AZURE_TENANT_ID=await Z("ASSIST_REVIEW_AZURE_TENANT_ID",t),s.ASSIST_REVIEW_ENVIRONMENT=await Z("ASSIST_REVIEW_ENVIRONMENT",t,!0),s}return s[T]=await Z(T,t),s}import{parseArgs as en}from"node:util";var cs={provider:"ASSIST_REVIEW_PROVIDER","base-url":"ASSIST_REVIEW_BASE_URL","reviewer-1":"ASSIST_REVIEW_REVIEWER_1","reviewer-2":"ASSIST_REVIEW_REVIEWER_2",synthesis:"ASSIST_REVIEW_SYNTHESIS","azure-client-id":"ASSIST_REVIEW_AZURE_CLIENT_ID","azure-tenant-id":"ASSIST_REVIEW_AZURE_TENANT_ID",environment:"ASSIST_REVIEW_ENVIRONMENT"};function ds(i){let{values:e}=en({args:i,options:{...Object.fromEntries(Object.keys(cs).map(r=>[r,{type:"string"}])),"skip-check":{type:"boolean"}}}),{"skip-check":t,...s}=e;return{values:Object.fromEntries(Object.entries(s).map(([r,n])=>[cs[r],n])),skipCheck:t===!0}}import{execFileSync as ps,spawnSync as tn}from"node:child_process";var sn=["ASSIST_REVIEW_CLAUDE_MODEL","ASSIST_REVIEW_CODEX_MODEL"];function fs(i){tn("gh",["variable","delete",i],{stdio:"ignore"})}function ms(i){for(let t of[...z,...lt]){let s=i[t];if(!s){fs(t);continue}ps("gh",["variable","set",t,"--body",s],{stdio:["ignore","inherit","inherit"]})}for(let t of sn)fs(t);let e=i[T];e&&ps("gh",["secret","set",T],{input:e,stdio:["pipe","inherit","inherit"]})}async function rn(){let i=ds(process.argv.slice(2)),e=await us(i.values,process.env);if(i.skipCheck)console.log("Skipping the check that the config can reach every model.");else{console.log("Checking the config can reach every model...");let t=await bt(e);if(t.length>0){for(let s of t)console.error(`review-ci: ${s}`);console.error("review-ci: nothing was set on the repo"),process.exit(1)}}ms(e),console.log("review-ci: repo variables are set")}try{await rn()}catch(i){console.error(`review-ci: ${i instanceof Error?i.message:String(i)}`),process.exit(1)}export{rn as reviewCiInit};
33
+ `)),this.restore()}submit(){this.value={};for(let e of this.choices)this.value[e.name]=e.scaleIdx;return this.base.submit.call(this)}};function Yr(i,e={}){if(Array.isArray(e.scale))return e.scale.map(s=>({...s}));let t=[];for(let s=1;s<i+1;s++)t.push({i:s,selected:!1});return t}Fi.exports=Qe});var Ji=d((_a,Yi)=>{Yi.exports=Be()});var Xi=d((Ia,Qi)=>{"use strict";var Jr=he(),Xe=class extends Jr{async initialize(){await super.initialize(),this.value=this.initial=this.resolve(this.options.initial),this.disabled=this.options.disabled||"no",this.enabled=this.options.enabled||"yes",await this.render()}reset(){this.value=this.initial,this.render()}delete(){this.alert()}toggle(){this.value=!this.value,this.render()}enable(){if(this.value===!0)return this.alert();this.value=!0,this.render()}disable(){if(this.value===!1)return this.alert();this.value=!1,this.render()}up(){this.toggle()}down(){this.toggle()}right(){this.toggle()}left(){this.toggle()}next(){this.toggle()}prev(){this.toggle()}dispatch(e="",t){switch(e.toLowerCase()){case" ":return this.toggle();case"1":case"y":case"t":return this.enable();case"0":case"n":case"f":return this.disable();default:return this.alert()}}format(){let e=s=>this.styles.primary.underline(s);return[this.value?this.disabled:e(this.disabled),this.value?e(this.enabled):this.enabled].join(this.styles.muted(" / "))}async render(){let{size:e}=this.state,t=await this.header(),s=await this.prefix(),r=await this.separator(),n=await this.message(),a=await this.format(),l=await this.error()||await this.hint(),o=await this.footer(),h=[s,n,r,a].join(" ");this.state.prompt=h,l&&!h.includes(l)&&(h+=" "+l),this.clear(e),this.write([t,h,o].filter(Boolean).join(`
34
+ `)),this.write(this.margin[2]),this.restore()}};Qi.exports=Xe});var ts=d((Sa,es)=>{"use strict";var Qr=j(),et=class extends Qr{constructor(e){if(super(e),typeof this.options.correctChoice!="number"||this.options.correctChoice<0)throw new Error("Please specify the index of the correct answer from the list of choices")}async toChoices(e,t){let s=await super.toChoices(e,t);if(s.length<2)throw new Error("Please give at least two choices to the user");if(this.options.correctChoice>s.length)throw new Error("Please specify the index of the correct answer from the list of choices");return s}check(e){return e.index===this.options.correctChoice}async result(e){return{selectedAnswer:e,correctAnswer:this.options.choices[this.options.correctChoice].value,correct:await this.check(this.state)}}};es.exports=et});var ss=d(tt=>{"use strict";var is=I(),R=(i,e)=>{is.defineExport(tt,i,e),is.defineExport(tt,i.toLowerCase(),e)};R("AutoComplete",()=>hi());R("BasicAuth",()=>gi());R("Confirm",()=>bi());R("Editable",()=>xi());R("Form",()=>oe());R("Input",()=>Be());R("Invisible",()=>ki());R("List",()=>qi());R("MultiSelect",()=>$i());R("Numeral",()=>Vi());R("Password",()=>ji());R("Scale",()=>Bi());R("Select",()=>j());R("Snippet",()=>Ui());R("Sort",()=>Zi());R("Survey",()=>Gi());R("Text",()=>Ji());R("Toggle",()=>Xi());R("Quiz",()=>ts())});var ns=d((Aa,rs)=>{rs.exports={ArrayPrompt:J(),AuthPrompt:Oe(),BooleanPrompt:he(),NumberPrompt:Ue(),StringPrompt:L()}});var os=d((qa,ls)=>{"use strict";var as=X("assert"),st=X("events"),N=I(),T=class extends st{constructor(e,t){super(),this.options=N.merge({},e),this.answers={...t}}register(e,t){if(N.isObject(e)){for(let r of Object.keys(e))this.register(r,e[r]);return this}as.equal(typeof t,"function","expected a function");let s=e.toLowerCase();return t.prototype instanceof this.Prompt?this.prompts[s]=t:this.prompts[s]=t(this.Prompt,this),this}async prompt(e=[]){for(let t of[].concat(e))try{typeof t=="function"&&(t=await t.call(this)),await this.ask(N.merge({},this.options,t))}catch(s){return Promise.reject(s)}return this.answers}async ask(e){typeof e=="function"&&(e=await e.call(this));let t=N.merge({},this.options,e),{type:s,name:r}=e,{set:n,get:a}=N;if(typeof s=="function"&&(s=await s.call(this,e,this.answers)),!s)return this.answers[r];s==="number"&&(s="numeral"),as(this.prompts[s],`Prompt "${s}" is not registered`);let l=new this.prompts[s](t),o=a(this.answers,r);l.state.answers=this.answers,l.enquirer=this,r&&l.on("submit",c=>{this.emit("answer",r,c,l),n(this.answers,r,c)});let h=l.emit.bind(l);return l.emit=(...c)=>(this.emit.call(this,...c),h(...c)),this.emit("prompt",l,this),t.autofill&&o!=null?(l.value=l.input=o,t.autofill==="show"&&await l.submit()):o=l.value=await l.run(),o}use(e){return e.call(this,this),this}set Prompt(e){this._Prompt=e}get Prompt(){return this._Prompt||this.constructor.Prompt}get prompts(){return this.constructor.prompts}static set Prompt(e){this._Prompt=e}static get Prompt(){return this._Prompt||U()}static get prompts(){return ss()}static get types(){return ns()}static get prompt(){let e=(t,...s)=>{let r=new this(...s),n=r.emit.bind(r);return r.emit=(...a)=>(e.emit(...a),n(...a)),r.prompt(t)};return N.mixinEmitter(e,new st),e}};N.mixinEmitter(T,new st);var it=T.prompts;for(let i of Object.keys(it)){let e=i.toLowerCase(),t=s=>new it[i](s).run();T.prompt[e]=t,T[e]=t,T[i]||Reflect.defineProperty(T,i,{get:()=>it[i]})}var Q=i=>{N.defineExport(T,i,()=>T.types[i])};Q("ArrayPrompt");Q("AuthPrompt");Q("BooleanPrompt");Q("NumberPrompt");Q("StringPrompt");ls.exports=T});var z=["REVIEW_CI_PROVIDER","REVIEW_CI_BASE_URL","REVIEW_CI_REVIEWER_1","REVIEW_CI_REVIEWER_2","REVIEW_CI_SYNTHESIS"],ot=["REVIEW_CI_AZURE_CLIENT_ID","REVIEW_CI_AZURE_TENANT_ID","REVIEW_CI_ENVIRONMENT"],q="REVIEW_CI_API_KEY",ee=["litellm","foundry"],ce=["claude","codex"];function ht(i,e){if(i==="litellm")return{anthropic:e,responses:`${e}/v1`,anthropicKind:"gateway"};if(i==="foundry")return{anthropic:`${e}/anthropic`,responses:`${e}/openai/v1`,anthropicKind:"foundry"};throw new Error(`Unsupported REVIEW_CI_PROVIDER "${i}" (expected one of: ${ee.join(", ")})`)}async function de(i,e,t){try{let s=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",...e},body:JSON.stringify(t),signal:AbortSignal.timeout(6e4)});if(s.ok)return;let r=(await s.text()).trim().slice(0,300);return`HTTP ${s.status}${r?`: ${r}`:""}`}catch(s){if(!(s instanceof Error))return String(s);let r=s.cause instanceof Error?s.cause.message:"";return r?`${s.message} (${r})`:s.message}}function _s(i,e,t){let s={Authorization:`Bearer ${t}`};return i.auth.kind==="entra"?s:e.anthropicKind==="foundry"?{"x-api-key":t}:{...s,"x-api-key":t}}async function Is(i,e,t,s){if(i.harness==="codex"){let a=`${t.responses}/responses`,l=await de(a,{Authorization:`Bearer ${s}`},{model:i.model,input:"ping",max_output_tokens:16});return l&&`Codex model "${i.model}" at ${a}: ${l}`}let r=`${t.anthropic}/v1/messages`,n=await de(r,{..._s(e,t,s),"anthropic-version":"2023-06-01"},{model:i.model,max_tokens:1,messages:[{role:"user",content:"ping"}]});return n&&`Claude model "${i.model}" at ${r}: ${n}`}function Ss(i){let e=new Map;for(let t of Object.values(i.slots))e.set(`${t.harness}:${t.model}`,t);return[...e.values()]}async function ut(i,e,t){return(await Promise.all(Ss(i).map(r=>Is(r,i,e,t)))).filter(r=>!!r)}function ks(i){return ce.includes(i)}function ct(i,e){let t=e.indexOf(":"),s=e.slice(0,t).trim(),r=e.slice(t+1).trim();return t===-1||!ks(s)||!r?`${i} "${e}" must be ${ce.map(n=>`${n}:<model>`).join(" or ")}`:{harness:s,model:r}}function te(i,e){return i==="foundry"&&e("REVIEW_CI_AZURE_CLIENT_ID")?["REVIEW_CI_AZURE_CLIENT_ID","REVIEW_CI_AZURE_TENANT_ID"]:[q]}function dt(i,e){return te(i,e).includes(q)?{kind:"key",apiKey:e(q)}:{kind:"entra",clientId:e("REVIEW_CI_AZURE_CLIENT_ID"),tenantId:e("REVIEW_CI_AZURE_TENANT_ID")}}var As={claude:"REVIEW_CI_REVIEWER_1",codex:"REVIEW_CI_REVIEWER_2",synthesis:"REVIEW_CI_SYNTHESIS"};function pt(i){let e=a=>i[a]?.trim()??"",t=e("REVIEW_CI_PROVIDER"),s=[...z,...te(t,e)].filter(a=>!e(a));if(s.length>0)return{config:null,errors:s.map(a=>`${a} is not set`)};let r=Object.entries(As).map(([a,l])=>[a,ct(l,e(l))]),n=r.flatMap(([,a])=>typeof a=="string"?[a]:[]);return n.length>0?{config:null,errors:n}:{config:{provider:t,baseUrl:e("REVIEW_CI_BASE_URL").replace(/\/+$/,""),slots:Object.fromEntries(r),auth:dt(t,e)},errors:n}}var ie="https://cognitiveservices.azure.com";var ft=3e4;async function mt(i,e){if(!i.ok){let t=(await i.text()).trim().slice(0,300);throw new Error(`${e}: HTTP ${i.status}${t?`: ${t}`:""}`)}return await i.json()}async function qs(i,e){let t=new URL(i);t.searchParams.set("audience","api://AzureADTokenExchange");let s=await fetch(t,{headers:{Authorization:`bearer ${e}`},signal:AbortSignal.timeout(ft)}),r=await mt(s,"GitHub OIDC token request failed");if(!r.value)throw new Error("GitHub OIDC token response had no value");return r.value}async function gt(i,e,t){let s=await qs(t.requestUrl,t.requestToken),r=await fetch(`https://login.microsoftonline.com/${encodeURIComponent(e)}/oauth2/v2.0/token`,{method:"POST",body:new URLSearchParams({grant_type:"client_credentials",client_id:i,scope:`${ie}/.default`,client_assertion_type:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer",client_assertion:s}),signal:AbortSignal.timeout(ft)}),n=await mt(r,`Entra token exchange for client ${i} failed`);if(!n.access_token)throw new Error("Entra token response had no access_token");return n.access_token}import{execFileSync as Ps}from"node:child_process";function yt(i){try{return Ps("az",["account","get-access-token","--resource",ie,"--tenant",i,"--query","accessToken","-o","tsv"],{encoding:"utf8",stdio:["ignore","pipe","pipe"],shell:process.platform==="win32"}).trim()}catch(e){let t=e.stderr?.trim();throw new Error(`az account get-access-token failed for tenant ${i}${t?`: ${t}`:""}; run az login --tenant ${i}`)}}async function wt(i,e){if(i.kind==="key")return i.apiKey;let t=e.ACTIONS_ID_TOKEN_REQUEST_URL,s=e.ACTIONS_ID_TOKEN_REQUEST_TOKEN;if(t&&s){let r=await gt(i.clientId,i.tenantId,{requestUrl:t,requestToken:s});return console.log(`::add-mask::${r}`),r}if(e.GITHUB_ACTIONS)throw new Error("No GitHub OIDC token endpoint; give the job the id-token: write permission");return yt(i.tenantId)}function bt(i){return i instanceof Error?i.message:String(i)}async function vt(i){let{config:e,errors:t}=pt(i);if(!e)return t;let s;try{s=ht(e.provider,e.baseUrl)}catch(n){return[bt(n)]}let r;try{r=await wt(e.auth,i)}catch(n){return[bt(n)]}return ut(e,s,r)}var us=Rs(os(),1);async function hs(i){try{return await i}catch(e){throw(e===""||e===void 0)&&process.exit(0),e}}var rt="(claude:<model> or codex:<model>)",Xr={REVIEW_CI_PROVIDER:{name:"value",type:"select",message:"Provider",choices:[...ee]},REVIEW_CI_BASE_URL:{name:"value",type:"input",message:"Base URL (litellm: the proxy root; foundry: https://<resource>.services.ai.azure.com)"},REVIEW_CI_REVIEWER_1:{name:"value",type:"input",message:`Reviewer 1 ${rt}`},REVIEW_CI_REVIEWER_2:{name:"value",type:"input",message:`Reviewer 2 ${rt}`},REVIEW_CI_SYNTHESIS:{name:"value",type:"input",message:`Synthesis ${rt}`},REVIEW_CI_AZURE_CLIENT_ID:{name:"value",type:"input",message:"Azure client ID for Entra auth (blank to use an API key)"},REVIEW_CI_AZURE_TENANT_ID:{name:"value",type:"input",message:"Azure tenant ID"},REVIEW_CI_ENVIRONMENT:{name:"value",type:"input",message:"GitHub environment the federated credential is scoped to (blank for none)"},REVIEW_CI_API_KEY:{name:"value",type:"password",message:"API key"}};async function Z(i,e,t=!1){let s=e[i]?.trim();if(s)return s;if(!process.stdin.isTTY){if(t)return"";throw new Error(`${i} was not given and stdin is not a terminal to prompt for it`)}return(await hs(us.default.prompt(Xr[i]))).value.trim()}async function cs(i,e){let t={...i,[q]:e[q]},s={};for(let r of z)s[r]=await Z(r,t);if(s.REVIEW_CI_PROVIDER==="foundry"){let r=await Z("REVIEW_CI_AZURE_CLIENT_ID",t,!0);if(r)return s.REVIEW_CI_AZURE_CLIENT_ID=r,s.REVIEW_CI_AZURE_TENANT_ID=await Z("REVIEW_CI_AZURE_TENANT_ID",t),s.REVIEW_CI_ENVIRONMENT=await Z("REVIEW_CI_ENVIRONMENT",t,!0),s}return s[q]=await Z(q,t),s}import{parseArgs as en}from"node:util";var ds={provider:"REVIEW_CI_PROVIDER","base-url":"REVIEW_CI_BASE_URL","reviewer-1":"REVIEW_CI_REVIEWER_1","reviewer-2":"REVIEW_CI_REVIEWER_2",synthesis:"REVIEW_CI_SYNTHESIS","azure-client-id":"REVIEW_CI_AZURE_CLIENT_ID","azure-tenant-id":"REVIEW_CI_AZURE_TENANT_ID",environment:"REVIEW_CI_ENVIRONMENT"};function ps(i){let{values:e}=en({args:i,options:{...Object.fromEntries(Object.keys(ds).map(r=>[r,{type:"string"}])),"skip-check":{type:"boolean"}}}),{"skip-check":t,...s}=e;return{values:Object.fromEntries(Object.entries(s).map(([r,n])=>[ds[r],n])),skipCheck:t===!0}}import{execFileSync as fs,spawnSync as tn}from"node:child_process";var sn=["ASSIST_REVIEW_PROVIDER","ASSIST_REVIEW_BASE_URL","ASSIST_REVIEW_CLAUDE_MODEL","ASSIST_REVIEW_CODEX_MODEL","ASSIST_REVIEW_REVIEWER_1","ASSIST_REVIEW_REVIEWER_2","ASSIST_REVIEW_SYNTHESIS","ASSIST_REVIEW_AZURE_CLIENT_ID","ASSIST_REVIEW_AZURE_TENANT_ID","ASSIST_REVIEW_ENVIRONMENT"],rn="ASSIST_REVIEW_API_KEY";function nt(i,e){tn("gh",[i,"delete",e],{stdio:"ignore"})}function ms(i){for(let t of[...z,...ot]){let s=i[t];if(!s){nt("variable",t);continue}fs("gh",["variable","set",t,"--body",s],{stdio:["ignore","inherit","inherit"]})}for(let t of sn)nt("variable",t);nt("secret",rn);let e=i[q];e&&fs("gh",["secret","set",q],{input:e,stdio:["pipe","inherit","inherit"]})}async function nn(){let i=ps(process.argv.slice(2)),e=await cs(i.values,process.env);if(i.skipCheck)console.log("Skipping the check that the config can reach every model.");else{console.log("Checking the config can reach every model...");let t=await vt(e);if(t.length>0){for(let s of t)console.error(`review-ci: ${s}`);console.error("review-ci: nothing was set on the repo"),process.exit(1)}}ms(e),console.log("review-ci: repo variables are set")}try{await nn()}catch(i){console.error(`review-ci: ${i instanceof Error?i.message:String(i)}`),process.exit(1)}export{nn as reviewCiInit};