// Loaded from https://deno.land/x/cliffy@v0.18.0/prompt/prompt.ts // deno-lint-ignore-file import { tty } from "../ansi/tty.ts"; import { GenericPrompt, GenericPromptOptions, StaticGenericPrompt, } from "./_generic_prompt.ts"; type Awaited = T extends PromiseLike ? U : T; type AwaitedReturnType any> = Awaited< ReturnType >; type Next = ( next?: N | number | true | null, ) => Promise; type PromptOptions< N0 extends string, G0 extends StaticGenericPrompt, R extends PromptResult, U = Parameters[0], > = & { name: N0; type: G0; before?: ( opts: R, next: Next>, ) => void | Promise; after?: ( opts: R, next: Next>, ) => void | Promise; } // exclude none options parameter & (U extends GenericPromptOptions ? U : {}); type PromptResult< N0 extends string, G0 extends StaticGenericPrompt, > = { [K in N0]?: AwaitedReturnType; }; interface PromptListOptions { cbreak?: boolean; before?: ( name: N, opts: R, next: Next>, ) => void | Promise; after?: ( name: N, opts: R, next: Next>, ) => void | Promise; } /** Global prompt options. */ export interface GlobalPromptOptions extends PromptListOptions { initial?: N extends symbol ? never : N; } export function prompt< N0 extends string, O0 extends GenericPromptOptions, P0 extends GenericPrompt, G0 extends StaticGenericPrompt, N1 extends string, O1 extends GenericPromptOptions, P1 extends GenericPrompt, G1 extends StaticGenericPrompt, N2 extends string, O2 extends GenericPromptOptions, P2 extends GenericPrompt, G2 extends StaticGenericPrompt, N3 extends string, O3 extends GenericPromptOptions, P3 extends GenericPrompt, G3 extends StaticGenericPrompt, N4 extends string, O4 extends GenericPromptOptions, P4 extends GenericPrompt, G4 extends StaticGenericPrompt, N5 extends string, O5 extends GenericPromptOptions, P5 extends GenericPrompt, G5 extends StaticGenericPrompt, N6 extends string, O6 extends GenericPromptOptions, P6 extends GenericPrompt, G6 extends StaticGenericPrompt, N7 extends string, O7 extends GenericPromptOptions, P7 extends GenericPrompt, G7 extends StaticGenericPrompt, N8 extends string, O8 extends GenericPromptOptions, P8 extends GenericPrompt, G8 extends StaticGenericPrompt, N9 extends string, O9 extends GenericPromptOptions, P9 extends GenericPrompt, G9 extends StaticGenericPrompt, N10 extends string, O10 extends GenericPromptOptions, P10 extends GenericPrompt, G10 extends StaticGenericPrompt, N11 extends string, O11 extends GenericPromptOptions, P11 extends GenericPrompt, G11 extends StaticGenericPrompt, N12 extends string, O12 extends GenericPromptOptions, P12 extends GenericPrompt, G12 extends StaticGenericPrompt, N13 extends string, O13 extends GenericPromptOptions, P13 extends GenericPrompt, G13 extends StaticGenericPrompt, N14 extends string, O14 extends GenericPromptOptions, P14 extends GenericPrompt, G14 extends StaticGenericPrompt, N15 extends string, O15 extends GenericPromptOptions, P15 extends GenericPrompt, G15 extends StaticGenericPrompt, N16 extends string, O16 extends GenericPromptOptions, P16 extends GenericPrompt, G16 extends StaticGenericPrompt, N17 extends string, O17 extends GenericPromptOptions, P17 extends GenericPrompt, G17 extends StaticGenericPrompt, N18 extends string, O18 extends GenericPromptOptions, P18 extends GenericPrompt, G18 extends StaticGenericPrompt, N19 extends string, O19 extends GenericPromptOptions, P19 extends GenericPrompt, G19 extends StaticGenericPrompt, N20 extends string, O20 extends GenericPromptOptions, P20 extends GenericPrompt, G20 extends StaticGenericPrompt, N21 extends string, O21 extends GenericPromptOptions, P21 extends GenericPrompt, G21 extends StaticGenericPrompt, N22 extends string, O22 extends GenericPromptOptions, P22 extends GenericPrompt, G22 extends StaticGenericPrompt, N23 extends string, O23 extends GenericPromptOptions, P23 extends GenericPrompt, G23 extends StaticGenericPrompt, R = & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult, >(prompts: [ PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, ], options?: GlobalPromptOptions): Promise; export function prompt< N0 extends string, O0 extends GenericPromptOptions, P0 extends GenericPrompt, G0 extends StaticGenericPrompt, N1 extends string, O1 extends GenericPromptOptions, P1 extends GenericPrompt, G1 extends StaticGenericPrompt, N2 extends string, O2 extends GenericPromptOptions, P2 extends GenericPrompt, G2 extends StaticGenericPrompt, N3 extends string, O3 extends GenericPromptOptions, P3 extends GenericPrompt, G3 extends StaticGenericPrompt, N4 extends string, O4 extends GenericPromptOptions, P4 extends GenericPrompt, G4 extends StaticGenericPrompt, N5 extends string, O5 extends GenericPromptOptions, P5 extends GenericPrompt, G5 extends StaticGenericPrompt, N6 extends string, O6 extends GenericPromptOptions, P6 extends GenericPrompt, G6 extends StaticGenericPrompt, N7 extends string, O7 extends GenericPromptOptions, P7 extends GenericPrompt, G7 extends StaticGenericPrompt, N8 extends string, O8 extends GenericPromptOptions, P8 extends GenericPrompt, G8 extends StaticGenericPrompt, N9 extends string, O9 extends GenericPromptOptions, P9 extends GenericPrompt, G9 extends StaticGenericPrompt, N10 extends string, O10 extends GenericPromptOptions, P10 extends GenericPrompt, G10 extends StaticGenericPrompt, N11 extends string, O11 extends GenericPromptOptions, P11 extends GenericPrompt, G11 extends StaticGenericPrompt, N12 extends string, O12 extends GenericPromptOptions, P12 extends GenericPrompt, G12 extends StaticGenericPrompt, N13 extends string, O13 extends GenericPromptOptions, P13 extends GenericPrompt, G13 extends StaticGenericPrompt, N14 extends string, O14 extends GenericPromptOptions, P14 extends GenericPrompt, G14 extends StaticGenericPrompt, N15 extends string, O15 extends GenericPromptOptions, P15 extends GenericPrompt, G15 extends StaticGenericPrompt, N16 extends string, O16 extends GenericPromptOptions, P16 extends GenericPrompt, G16 extends StaticGenericPrompt, N17 extends string, O17 extends GenericPromptOptions, P17 extends GenericPrompt, G17 extends StaticGenericPrompt, N18 extends string, O18 extends GenericPromptOptions, P18 extends GenericPrompt, G18 extends StaticGenericPrompt, N19 extends string, O19 extends GenericPromptOptions, P19 extends GenericPrompt, G19 extends StaticGenericPrompt, N20 extends string, O20 extends GenericPromptOptions, P20 extends GenericPrompt, G20 extends StaticGenericPrompt, N21 extends string, O21 extends GenericPromptOptions, P21 extends GenericPrompt, G21 extends StaticGenericPrompt, N22 extends string, O22 extends GenericPromptOptions, P22 extends GenericPrompt, G22 extends StaticGenericPrompt, R = & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult, >(prompts: [ PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, ], options?: GlobalPromptOptions): Promise; export function prompt< N0 extends string, O0 extends GenericPromptOptions, P0 extends GenericPrompt, G0 extends StaticGenericPrompt, N1 extends string, O1 extends GenericPromptOptions, P1 extends GenericPrompt, G1 extends StaticGenericPrompt, N2 extends string, O2 extends GenericPromptOptions, P2 extends GenericPrompt, G2 extends StaticGenericPrompt, N3 extends string, O3 extends GenericPromptOptions, P3 extends GenericPrompt, G3 extends StaticGenericPrompt, N4 extends string, O4 extends GenericPromptOptions, P4 extends GenericPrompt, G4 extends StaticGenericPrompt, N5 extends string, O5 extends GenericPromptOptions, P5 extends GenericPrompt, G5 extends StaticGenericPrompt, N6 extends string, O6 extends GenericPromptOptions, P6 extends GenericPrompt, G6 extends StaticGenericPrompt, N7 extends string, O7 extends GenericPromptOptions, P7 extends GenericPrompt, G7 extends StaticGenericPrompt, N8 extends string, O8 extends GenericPromptOptions, P8 extends GenericPrompt, G8 extends StaticGenericPrompt, N9 extends string, O9 extends GenericPromptOptions, P9 extends GenericPrompt, G9 extends StaticGenericPrompt, N10 extends string, O10 extends GenericPromptOptions, P10 extends GenericPrompt, G10 extends StaticGenericPrompt, N11 extends string, O11 extends GenericPromptOptions, P11 extends GenericPrompt, G11 extends StaticGenericPrompt, N12 extends string, O12 extends GenericPromptOptions, P12 extends GenericPrompt, G12 extends StaticGenericPrompt, N13 extends string, O13 extends GenericPromptOptions, P13 extends GenericPrompt, G13 extends StaticGenericPrompt, N14 extends string, O14 extends GenericPromptOptions, P14 extends GenericPrompt, G14 extends StaticGenericPrompt, N15 extends string, O15 extends GenericPromptOptions, P15 extends GenericPrompt, G15 extends StaticGenericPrompt, N16 extends string, O16 extends GenericPromptOptions, P16 extends GenericPrompt, G16 extends StaticGenericPrompt, N17 extends string, O17 extends GenericPromptOptions, P17 extends GenericPrompt, G17 extends StaticGenericPrompt, N18 extends string, O18 extends GenericPromptOptions, P18 extends GenericPrompt, G18 extends StaticGenericPrompt, N19 extends string, O19 extends GenericPromptOptions, P19 extends GenericPrompt, G19 extends StaticGenericPrompt, N20 extends string, O20 extends GenericPromptOptions, P20 extends GenericPrompt, G20 extends StaticGenericPrompt, N21 extends string, O21 extends GenericPromptOptions, P21 extends GenericPrompt, G21 extends StaticGenericPrompt, R = & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult, >(prompts: [ PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, ], options?: GlobalPromptOptions): Promise; export function prompt< N0 extends string, O0 extends GenericPromptOptions, P0 extends GenericPrompt, G0 extends StaticGenericPrompt, N1 extends string, O1 extends GenericPromptOptions, P1 extends GenericPrompt, G1 extends StaticGenericPrompt, N2 extends string, O2 extends GenericPromptOptions, P2 extends GenericPrompt, G2 extends StaticGenericPrompt, N3 extends string, O3 extends GenericPromptOptions, P3 extends GenericPrompt, G3 extends StaticGenericPrompt, N4 extends string, O4 extends GenericPromptOptions, P4 extends GenericPrompt, G4 extends StaticGenericPrompt, N5 extends string, O5 extends GenericPromptOptions, P5 extends GenericPrompt, G5 extends StaticGenericPrompt, N6 extends string, O6 extends GenericPromptOptions, P6 extends GenericPrompt, G6 extends StaticGenericPrompt, N7 extends string, O7 extends GenericPromptOptions, P7 extends GenericPrompt, G7 extends StaticGenericPrompt, N8 extends string, O8 extends GenericPromptOptions, P8 extends GenericPrompt, G8 extends StaticGenericPrompt, N9 extends string, O9 extends GenericPromptOptions, P9 extends GenericPrompt, G9 extends StaticGenericPrompt, N10 extends string, O10 extends GenericPromptOptions, P10 extends GenericPrompt, G10 extends StaticGenericPrompt, N11 extends string, O11 extends GenericPromptOptions, P11 extends GenericPrompt, G11 extends StaticGenericPrompt, N12 extends string, O12 extends GenericPromptOptions, P12 extends GenericPrompt, G12 extends StaticGenericPrompt, N13 extends string, O13 extends GenericPromptOptions, P13 extends GenericPrompt, G13 extends StaticGenericPrompt, N14 extends string, O14 extends GenericPromptOptions, P14 extends GenericPrompt, G14 extends StaticGenericPrompt, N15 extends string, O15 extends GenericPromptOptions, P15 extends GenericPrompt, G15 extends StaticGenericPrompt, N16 extends string, O16 extends GenericPromptOptions, P16 extends GenericPrompt, G16 extends StaticGenericPrompt, N17 extends string, O17 extends GenericPromptOptions, P17 extends GenericPrompt, G17 extends StaticGenericPrompt, N18 extends string, O18 extends GenericPromptOptions, P18 extends GenericPrompt, G18 extends StaticGenericPrompt, N19 extends string, O19 extends GenericPromptOptions, P19 extends GenericPrompt, G19 extends StaticGenericPrompt, N20 extends string, O20 extends GenericPromptOptions, P20 extends GenericPrompt, G20 extends StaticGenericPrompt, R = & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult, >(prompts: [ PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, ], options?: GlobalPromptOptions): Promise; export function prompt< N0 extends string, O0 extends GenericPromptOptions, P0 extends GenericPrompt, G0 extends StaticGenericPrompt, N1 extends string, O1 extends GenericPromptOptions, P1 extends GenericPrompt, G1 extends StaticGenericPrompt, N2 extends string, O2 extends GenericPromptOptions, P2 extends GenericPrompt, G2 extends StaticGenericPrompt, N3 extends string, O3 extends GenericPromptOptions, P3 extends GenericPrompt, G3 extends StaticGenericPrompt, N4 extends string, O4 extends GenericPromptOptions, P4 extends GenericPrompt, G4 extends StaticGenericPrompt, N5 extends string, O5 extends GenericPromptOptions, P5 extends GenericPrompt, G5 extends StaticGenericPrompt, N6 extends string, O6 extends GenericPromptOptions, P6 extends GenericPrompt, G6 extends StaticGenericPrompt, N7 extends string, O7 extends GenericPromptOptions, P7 extends GenericPrompt, G7 extends StaticGenericPrompt, N8 extends string, O8 extends GenericPromptOptions, P8 extends GenericPrompt, G8 extends StaticGenericPrompt, N9 extends string, O9 extends GenericPromptOptions, P9 extends GenericPrompt, G9 extends StaticGenericPrompt, N10 extends string, O10 extends GenericPromptOptions, P10 extends GenericPrompt, G10 extends StaticGenericPrompt, N11 extends string, O11 extends GenericPromptOptions, P11 extends GenericPrompt, G11 extends StaticGenericPrompt, N12 extends string, O12 extends GenericPromptOptions, P12 extends GenericPrompt, G12 extends StaticGenericPrompt, N13 extends string, O13 extends GenericPromptOptions, P13 extends GenericPrompt, G13 extends StaticGenericPrompt, N14 extends string, O14 extends GenericPromptOptions, P14 extends GenericPrompt, G14 extends StaticGenericPrompt, N15 extends string, O15 extends GenericPromptOptions, P15 extends GenericPrompt, G15 extends StaticGenericPrompt, N16 extends string, O16 extends GenericPromptOptions, P16 extends GenericPrompt, G16 extends StaticGenericPrompt, N17 extends string, O17 extends GenericPromptOptions, P17 extends GenericPrompt, G17 extends StaticGenericPrompt, N18 extends string, O18 extends GenericPromptOptions, P18 extends GenericPrompt, G18 extends StaticGenericPrompt, N19 extends string, O19 extends GenericPromptOptions, P19 extends GenericPrompt, G19 extends StaticGenericPrompt, R = & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult, >(prompts: [ PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, ], options?: GlobalPromptOptions): Promise; export function prompt< N0 extends string, O0 extends GenericPromptOptions, P0 extends GenericPrompt, G0 extends StaticGenericPrompt, N1 extends string, O1 extends GenericPromptOptions, P1 extends GenericPrompt, G1 extends StaticGenericPrompt, N2 extends string, O2 extends GenericPromptOptions, P2 extends GenericPrompt, G2 extends StaticGenericPrompt, N3 extends string, O3 extends GenericPromptOptions, P3 extends GenericPrompt, G3 extends StaticGenericPrompt, N4 extends string, O4 extends GenericPromptOptions, P4 extends GenericPrompt, G4 extends StaticGenericPrompt, N5 extends string, O5 extends GenericPromptOptions, P5 extends GenericPrompt, G5 extends StaticGenericPrompt, N6 extends string, O6 extends GenericPromptOptions, P6 extends GenericPrompt, G6 extends StaticGenericPrompt, N7 extends string, O7 extends GenericPromptOptions, P7 extends GenericPrompt, G7 extends StaticGenericPrompt, N8 extends string, O8 extends GenericPromptOptions, P8 extends GenericPrompt, G8 extends StaticGenericPrompt, N9 extends string, O9 extends GenericPromptOptions, P9 extends GenericPrompt, G9 extends StaticGenericPrompt, N10 extends string, O10 extends GenericPromptOptions, P10 extends GenericPrompt, G10 extends StaticGenericPrompt, N11 extends string, O11 extends GenericPromptOptions, P11 extends GenericPrompt, G11 extends StaticGenericPrompt, N12 extends string, O12 extends GenericPromptOptions, P12 extends GenericPrompt, G12 extends StaticGenericPrompt, N13 extends string, O13 extends GenericPromptOptions, P13 extends GenericPrompt, G13 extends StaticGenericPrompt, N14 extends string, O14 extends GenericPromptOptions, P14 extends GenericPrompt, G14 extends StaticGenericPrompt, N15 extends string, O15 extends GenericPromptOptions, P15 extends GenericPrompt, G15 extends StaticGenericPrompt, N16 extends string, O16 extends GenericPromptOptions, P16 extends GenericPrompt, G16 extends StaticGenericPrompt, N17 extends string, O17 extends GenericPromptOptions, P17 extends GenericPrompt, G17 extends StaticGenericPrompt, N18 extends string, O18 extends GenericPromptOptions, P18 extends GenericPrompt, G18 extends StaticGenericPrompt, R = & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult, >(prompts: [ PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, ], options?: GlobalPromptOptions): Promise; export function prompt< N0 extends string, O0 extends GenericPromptOptions, P0 extends GenericPrompt, G0 extends StaticGenericPrompt, N1 extends string, O1 extends GenericPromptOptions, P1 extends GenericPrompt, G1 extends StaticGenericPrompt, N2 extends string, O2 extends GenericPromptOptions, P2 extends GenericPrompt, G2 extends StaticGenericPrompt, N3 extends string, O3 extends GenericPromptOptions, P3 extends GenericPrompt, G3 extends StaticGenericPrompt, N4 extends string, O4 extends GenericPromptOptions, P4 extends GenericPrompt, G4 extends StaticGenericPrompt, N5 extends string, O5 extends GenericPromptOptions, P5 extends GenericPrompt, G5 extends StaticGenericPrompt, N6 extends string, O6 extends GenericPromptOptions, P6 extends GenericPrompt, G6 extends StaticGenericPrompt, N7 extends string, O7 extends GenericPromptOptions, P7 extends GenericPrompt, G7 extends StaticGenericPrompt, N8 extends string, O8 extends GenericPromptOptions, P8 extends GenericPrompt, G8 extends StaticGenericPrompt, N9 extends string, O9 extends GenericPromptOptions, P9 extends GenericPrompt, G9 extends StaticGenericPrompt, N10 extends string, O10 extends GenericPromptOptions, P10 extends GenericPrompt, G10 extends StaticGenericPrompt, N11 extends string, O11 extends GenericPromptOptions, P11 extends GenericPrompt, G11 extends StaticGenericPrompt, N12 extends string, O12 extends GenericPromptOptions, P12 extends GenericPrompt, G12 extends StaticGenericPrompt, N13 extends string, O13 extends GenericPromptOptions, P13 extends GenericPrompt, G13 extends StaticGenericPrompt, N14 extends string, O14 extends GenericPromptOptions, P14 extends GenericPrompt, G14 extends StaticGenericPrompt, N15 extends string, O15 extends GenericPromptOptions, P15 extends GenericPrompt, G15 extends StaticGenericPrompt, N16 extends string, O16 extends GenericPromptOptions, P16 extends GenericPrompt, G16 extends StaticGenericPrompt, N17 extends string, O17 extends GenericPromptOptions, P17 extends GenericPrompt, G17 extends StaticGenericPrompt, R = & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult, >(prompts: [ PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, ], options?: GlobalPromptOptions): Promise; export function prompt< N0 extends string, O0 extends GenericPromptOptions, P0 extends GenericPrompt, G0 extends StaticGenericPrompt, N1 extends string, O1 extends GenericPromptOptions, P1 extends GenericPrompt, G1 extends StaticGenericPrompt, N2 extends string, O2 extends GenericPromptOptions, P2 extends GenericPrompt, G2 extends StaticGenericPrompt, N3 extends string, O3 extends GenericPromptOptions, P3 extends GenericPrompt, G3 extends StaticGenericPrompt, N4 extends string, O4 extends GenericPromptOptions, P4 extends GenericPrompt, G4 extends StaticGenericPrompt, N5 extends string, O5 extends GenericPromptOptions, P5 extends GenericPrompt, G5 extends StaticGenericPrompt, N6 extends string, O6 extends GenericPromptOptions, P6 extends GenericPrompt, G6 extends StaticGenericPrompt, N7 extends string, O7 extends GenericPromptOptions, P7 extends GenericPrompt, G7 extends StaticGenericPrompt, N8 extends string, O8 extends GenericPromptOptions, P8 extends GenericPrompt, G8 extends StaticGenericPrompt, N9 extends string, O9 extends GenericPromptOptions, P9 extends GenericPrompt, G9 extends StaticGenericPrompt, N10 extends string, O10 extends GenericPromptOptions, P10 extends GenericPrompt, G10 extends StaticGenericPrompt, N11 extends string, O11 extends GenericPromptOptions, P11 extends GenericPrompt, G11 extends StaticGenericPrompt, N12 extends string, O12 extends GenericPromptOptions, P12 extends GenericPrompt, G12 extends StaticGenericPrompt, N13 extends string, O13 extends GenericPromptOptions, P13 extends GenericPrompt, G13 extends StaticGenericPrompt, N14 extends string, O14 extends GenericPromptOptions, P14 extends GenericPrompt, G14 extends StaticGenericPrompt, N15 extends string, O15 extends GenericPromptOptions, P15 extends GenericPrompt, G15 extends StaticGenericPrompt, N16 extends string, O16 extends GenericPromptOptions, P16 extends GenericPrompt, G16 extends StaticGenericPrompt, R = & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult, >(prompts: [ PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, ], options?: GlobalPromptOptions): Promise; export function prompt< N0 extends string, O0 extends GenericPromptOptions, P0 extends GenericPrompt, G0 extends StaticGenericPrompt, N1 extends string, O1 extends GenericPromptOptions, P1 extends GenericPrompt, G1 extends StaticGenericPrompt, N2 extends string, O2 extends GenericPromptOptions, P2 extends GenericPrompt, G2 extends StaticGenericPrompt, N3 extends string, O3 extends GenericPromptOptions, P3 extends GenericPrompt, G3 extends StaticGenericPrompt, N4 extends string, O4 extends GenericPromptOptions, P4 extends GenericPrompt, G4 extends StaticGenericPrompt, N5 extends string, O5 extends GenericPromptOptions, P5 extends GenericPrompt, G5 extends StaticGenericPrompt, N6 extends string, O6 extends GenericPromptOptions, P6 extends GenericPrompt, G6 extends StaticGenericPrompt, N7 extends string, O7 extends GenericPromptOptions, P7 extends GenericPrompt, G7 extends StaticGenericPrompt, N8 extends string, O8 extends GenericPromptOptions, P8 extends GenericPrompt, G8 extends StaticGenericPrompt, N9 extends string, O9 extends GenericPromptOptions, P9 extends GenericPrompt, G9 extends StaticGenericPrompt, N10 extends string, O10 extends GenericPromptOptions, P10 extends GenericPrompt, G10 extends StaticGenericPrompt, N11 extends string, O11 extends GenericPromptOptions, P11 extends GenericPrompt, G11 extends StaticGenericPrompt, N12 extends string, O12 extends GenericPromptOptions, P12 extends GenericPrompt, G12 extends StaticGenericPrompt, N13 extends string, O13 extends GenericPromptOptions, P13 extends GenericPrompt, G13 extends StaticGenericPrompt, N14 extends string, O14 extends GenericPromptOptions, P14 extends GenericPrompt, G14 extends StaticGenericPrompt, N15 extends string, O15 extends GenericPromptOptions, P15 extends GenericPrompt, G15 extends StaticGenericPrompt, R = & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult, >(prompts: [ PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, ], options?: GlobalPromptOptions): Promise; export function prompt< N0 extends string, O0 extends GenericPromptOptions, P0 extends GenericPrompt, G0 extends StaticGenericPrompt, N1 extends string, O1 extends GenericPromptOptions, P1 extends GenericPrompt, G1 extends StaticGenericPrompt, N2 extends string, O2 extends GenericPromptOptions, P2 extends GenericPrompt, G2 extends StaticGenericPrompt, N3 extends string, O3 extends GenericPromptOptions, P3 extends GenericPrompt, G3 extends StaticGenericPrompt, N4 extends string, O4 extends GenericPromptOptions, P4 extends GenericPrompt, G4 extends StaticGenericPrompt, N5 extends string, O5 extends GenericPromptOptions, P5 extends GenericPrompt, G5 extends StaticGenericPrompt, N6 extends string, O6 extends GenericPromptOptions, P6 extends GenericPrompt, G6 extends StaticGenericPrompt, N7 extends string, O7 extends GenericPromptOptions, P7 extends GenericPrompt, G7 extends StaticGenericPrompt, N8 extends string, O8 extends GenericPromptOptions, P8 extends GenericPrompt, G8 extends StaticGenericPrompt, N9 extends string, O9 extends GenericPromptOptions, P9 extends GenericPrompt, G9 extends StaticGenericPrompt, N10 extends string, O10 extends GenericPromptOptions, P10 extends GenericPrompt, G10 extends StaticGenericPrompt, N11 extends string, O11 extends GenericPromptOptions, P11 extends GenericPrompt, G11 extends StaticGenericPrompt, N12 extends string, O12 extends GenericPromptOptions, P12 extends GenericPrompt, G12 extends StaticGenericPrompt, N13 extends string, O13 extends GenericPromptOptions, P13 extends GenericPrompt, G13 extends StaticGenericPrompt, N14 extends string, O14 extends GenericPromptOptions, P14 extends GenericPrompt, G14 extends StaticGenericPrompt, R = & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult, >(prompts: [ PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, ], options?: GlobalPromptOptions): Promise; export function prompt< N0 extends string, O0 extends GenericPromptOptions, P0 extends GenericPrompt, G0 extends StaticGenericPrompt, N1 extends string, O1 extends GenericPromptOptions, P1 extends GenericPrompt, G1 extends StaticGenericPrompt, N2 extends string, O2 extends GenericPromptOptions, P2 extends GenericPrompt, G2 extends StaticGenericPrompt, N3 extends string, O3 extends GenericPromptOptions, P3 extends GenericPrompt, G3 extends StaticGenericPrompt, N4 extends string, O4 extends GenericPromptOptions, P4 extends GenericPrompt, G4 extends StaticGenericPrompt, N5 extends string, O5 extends GenericPromptOptions, P5 extends GenericPrompt, G5 extends StaticGenericPrompt, N6 extends string, O6 extends GenericPromptOptions, P6 extends GenericPrompt, G6 extends StaticGenericPrompt, N7 extends string, O7 extends GenericPromptOptions, P7 extends GenericPrompt, G7 extends StaticGenericPrompt, N8 extends string, O8 extends GenericPromptOptions, P8 extends GenericPrompt, G8 extends StaticGenericPrompt, N9 extends string, O9 extends GenericPromptOptions, P9 extends GenericPrompt, G9 extends StaticGenericPrompt, N10 extends string, O10 extends GenericPromptOptions, P10 extends GenericPrompt, G10 extends StaticGenericPrompt, N11 extends string, O11 extends GenericPromptOptions, P11 extends GenericPrompt, G11 extends StaticGenericPrompt, N12 extends string, O12 extends GenericPromptOptions, P12 extends GenericPrompt, G12 extends StaticGenericPrompt, N13 extends string, O13 extends GenericPromptOptions, P13 extends GenericPrompt, G13 extends StaticGenericPrompt, R = & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult, >(prompts: [ PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, ], options?: GlobalPromptOptions): Promise; export function prompt< N0 extends string, O0 extends GenericPromptOptions, P0 extends GenericPrompt, G0 extends StaticGenericPrompt, N1 extends string, O1 extends GenericPromptOptions, P1 extends GenericPrompt, G1 extends StaticGenericPrompt, N2 extends string, O2 extends GenericPromptOptions, P2 extends GenericPrompt, G2 extends StaticGenericPrompt, N3 extends string, O3 extends GenericPromptOptions, P3 extends GenericPrompt, G3 extends StaticGenericPrompt, N4 extends string, O4 extends GenericPromptOptions, P4 extends GenericPrompt, G4 extends StaticGenericPrompt, N5 extends string, O5 extends GenericPromptOptions, P5 extends GenericPrompt, G5 extends StaticGenericPrompt, N6 extends string, O6 extends GenericPromptOptions, P6 extends GenericPrompt, G6 extends StaticGenericPrompt, N7 extends string, O7 extends GenericPromptOptions, P7 extends GenericPrompt, G7 extends StaticGenericPrompt, N8 extends string, O8 extends GenericPromptOptions, P8 extends GenericPrompt, G8 extends StaticGenericPrompt, N9 extends string, O9 extends GenericPromptOptions, P9 extends GenericPrompt, G9 extends StaticGenericPrompt, N10 extends string, O10 extends GenericPromptOptions, P10 extends GenericPrompt, G10 extends StaticGenericPrompt, N11 extends string, O11 extends GenericPromptOptions, P11 extends GenericPrompt, G11 extends StaticGenericPrompt, N12 extends string, O12 extends GenericPromptOptions, P12 extends GenericPrompt, G12 extends StaticGenericPrompt, R = & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult, >(prompts: [ PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, ], options?: GlobalPromptOptions): Promise; export function prompt< N0 extends string, O0 extends GenericPromptOptions, P0 extends GenericPrompt, G0 extends StaticGenericPrompt, N1 extends string, O1 extends GenericPromptOptions, P1 extends GenericPrompt, G1 extends StaticGenericPrompt, N2 extends string, O2 extends GenericPromptOptions, P2 extends GenericPrompt, G2 extends StaticGenericPrompt, N3 extends string, O3 extends GenericPromptOptions, P3 extends GenericPrompt, G3 extends StaticGenericPrompt, N4 extends string, O4 extends GenericPromptOptions, P4 extends GenericPrompt, G4 extends StaticGenericPrompt, N5 extends string, O5 extends GenericPromptOptions, P5 extends GenericPrompt, G5 extends StaticGenericPrompt, N6 extends string, O6 extends GenericPromptOptions, P6 extends GenericPrompt, G6 extends StaticGenericPrompt, N7 extends string, O7 extends GenericPromptOptions, P7 extends GenericPrompt, G7 extends StaticGenericPrompt, N8 extends string, O8 extends GenericPromptOptions, P8 extends GenericPrompt, G8 extends StaticGenericPrompt, N9 extends string, O9 extends GenericPromptOptions, P9 extends GenericPrompt, G9 extends StaticGenericPrompt, N10 extends string, O10 extends GenericPromptOptions, P10 extends GenericPrompt, G10 extends StaticGenericPrompt, N11 extends string, O11 extends GenericPromptOptions, P11 extends GenericPrompt, G11 extends StaticGenericPrompt, R = & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult, >(prompts: [ PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, ], options?: GlobalPromptOptions): Promise; export function prompt< N0 extends string, O0 extends GenericPromptOptions, P0 extends GenericPrompt, G0 extends StaticGenericPrompt, N1 extends string, O1 extends GenericPromptOptions, P1 extends GenericPrompt, G1 extends StaticGenericPrompt, N2 extends string, O2 extends GenericPromptOptions, P2 extends GenericPrompt, G2 extends StaticGenericPrompt, N3 extends string, O3 extends GenericPromptOptions, P3 extends GenericPrompt, G3 extends StaticGenericPrompt, N4 extends string, O4 extends GenericPromptOptions, P4 extends GenericPrompt, G4 extends StaticGenericPrompt, N5 extends string, O5 extends GenericPromptOptions, P5 extends GenericPrompt, G5 extends StaticGenericPrompt, N6 extends string, O6 extends GenericPromptOptions, P6 extends GenericPrompt, G6 extends StaticGenericPrompt, N7 extends string, O7 extends GenericPromptOptions, P7 extends GenericPrompt, G7 extends StaticGenericPrompt, N8 extends string, O8 extends GenericPromptOptions, P8 extends GenericPrompt, G8 extends StaticGenericPrompt, N9 extends string, O9 extends GenericPromptOptions, P9 extends GenericPrompt, G9 extends StaticGenericPrompt, N10 extends string, O10 extends GenericPromptOptions, P10 extends GenericPrompt, G10 extends StaticGenericPrompt, R = & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult, >(prompts: [ PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, ], options?: GlobalPromptOptions): Promise; export function prompt< N0 extends string, O0 extends GenericPromptOptions, P0 extends GenericPrompt, G0 extends StaticGenericPrompt, N1 extends string, O1 extends GenericPromptOptions, P1 extends GenericPrompt, G1 extends StaticGenericPrompt, N2 extends string, O2 extends GenericPromptOptions, P2 extends GenericPrompt, G2 extends StaticGenericPrompt, N3 extends string, O3 extends GenericPromptOptions, P3 extends GenericPrompt, G3 extends StaticGenericPrompt, N4 extends string, O4 extends GenericPromptOptions, P4 extends GenericPrompt, G4 extends StaticGenericPrompt, N5 extends string, O5 extends GenericPromptOptions, P5 extends GenericPrompt, G5 extends StaticGenericPrompt, N6 extends string, O6 extends GenericPromptOptions, P6 extends GenericPrompt, G6 extends StaticGenericPrompt, N7 extends string, O7 extends GenericPromptOptions, P7 extends GenericPrompt, G7 extends StaticGenericPrompt, N8 extends string, O8 extends GenericPromptOptions, P8 extends GenericPrompt, G8 extends StaticGenericPrompt, N9 extends string, O9 extends GenericPromptOptions, P9 extends GenericPrompt, G9 extends StaticGenericPrompt, R = & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult, >(prompts: [ PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, ], options?: GlobalPromptOptions): Promise; export function prompt< N0 extends string, O0 extends GenericPromptOptions, P0 extends GenericPrompt, G0 extends StaticGenericPrompt, N1 extends string, O1 extends GenericPromptOptions, P1 extends GenericPrompt, G1 extends StaticGenericPrompt, N2 extends string, O2 extends GenericPromptOptions, P2 extends GenericPrompt, G2 extends StaticGenericPrompt, N3 extends string, O3 extends GenericPromptOptions, P3 extends GenericPrompt, G3 extends StaticGenericPrompt, N4 extends string, O4 extends GenericPromptOptions, P4 extends GenericPrompt, G4 extends StaticGenericPrompt, N5 extends string, O5 extends GenericPromptOptions, P5 extends GenericPrompt, G5 extends StaticGenericPrompt, N6 extends string, O6 extends GenericPromptOptions, P6 extends GenericPrompt, G6 extends StaticGenericPrompt, N7 extends string, O7 extends GenericPromptOptions, P7 extends GenericPrompt, G7 extends StaticGenericPrompt, N8 extends string, O8 extends GenericPromptOptions, P8 extends GenericPrompt, G8 extends StaticGenericPrompt, R = & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult, >(prompts: [ PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, ], options?: GlobalPromptOptions): Promise; export function prompt< N0 extends string, O0 extends GenericPromptOptions, P0 extends GenericPrompt, G0 extends StaticGenericPrompt, N1 extends string, O1 extends GenericPromptOptions, P1 extends GenericPrompt, G1 extends StaticGenericPrompt, N2 extends string, O2 extends GenericPromptOptions, P2 extends GenericPrompt, G2 extends StaticGenericPrompt, N3 extends string, O3 extends GenericPromptOptions, P3 extends GenericPrompt, G3 extends StaticGenericPrompt, N4 extends string, O4 extends GenericPromptOptions, P4 extends GenericPrompt, G4 extends StaticGenericPrompt, N5 extends string, O5 extends GenericPromptOptions, P5 extends GenericPrompt, G5 extends StaticGenericPrompt, N6 extends string, O6 extends GenericPromptOptions, P6 extends GenericPrompt, G6 extends StaticGenericPrompt, N7 extends string, O7 extends GenericPromptOptions, P7 extends GenericPrompt, G7 extends StaticGenericPrompt, R = & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult, >(prompts: [ PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, ], options?: GlobalPromptOptions): Promise; export function prompt< N0 extends string, O0 extends GenericPromptOptions, P0 extends GenericPrompt, G0 extends StaticGenericPrompt, N1 extends string, O1 extends GenericPromptOptions, P1 extends GenericPrompt, G1 extends StaticGenericPrompt, N2 extends string, O2 extends GenericPromptOptions, P2 extends GenericPrompt, G2 extends StaticGenericPrompt, N3 extends string, O3 extends GenericPromptOptions, P3 extends GenericPrompt, G3 extends StaticGenericPrompt, N4 extends string, O4 extends GenericPromptOptions, P4 extends GenericPrompt, G4 extends StaticGenericPrompt, N5 extends string, O5 extends GenericPromptOptions, P5 extends GenericPrompt, G5 extends StaticGenericPrompt, N6 extends string, O6 extends GenericPromptOptions, P6 extends GenericPrompt, G6 extends StaticGenericPrompt, R = & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult, >(prompts: [ PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, ], options?: GlobalPromptOptions): Promise; export function prompt< N0 extends string, O0 extends GenericPromptOptions, P0 extends GenericPrompt, G0 extends StaticGenericPrompt, N1 extends string, O1 extends GenericPromptOptions, P1 extends GenericPrompt, G1 extends StaticGenericPrompt, N2 extends string, O2 extends GenericPromptOptions, P2 extends GenericPrompt, G2 extends StaticGenericPrompt, N3 extends string, O3 extends GenericPromptOptions, P3 extends GenericPrompt, G3 extends StaticGenericPrompt, N4 extends string, O4 extends GenericPromptOptions, P4 extends GenericPrompt, G4 extends StaticGenericPrompt, N5 extends string, O5 extends GenericPromptOptions, P5 extends GenericPrompt, G5 extends StaticGenericPrompt, R = & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult, >(prompts: [ PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, ], options?: GlobalPromptOptions): Promise; export function prompt< N0 extends string, O0 extends GenericPromptOptions, P0 extends GenericPrompt, G0 extends StaticGenericPrompt, N1 extends string, O1 extends GenericPromptOptions, P1 extends GenericPrompt, G1 extends StaticGenericPrompt, N2 extends string, O2 extends GenericPromptOptions, P2 extends GenericPrompt, G2 extends StaticGenericPrompt, N3 extends string, O3 extends GenericPromptOptions, P3 extends GenericPrompt, G3 extends StaticGenericPrompt, N4 extends string, O4 extends GenericPromptOptions, P4 extends GenericPrompt, G4 extends StaticGenericPrompt, R = & PromptResult & PromptResult & PromptResult & PromptResult & PromptResult, >(prompts: [ PromptOptions, PromptOptions, PromptOptions, PromptOptions, PromptOptions, ], options?: GlobalPromptOptions): Promise; export function prompt< N0 extends string, O0 extends GenericPromptOptions, P0 extends GenericPrompt, G0 extends StaticGenericPrompt, N1 extends string, O1 extends GenericPromptOptions, P1 extends GenericPrompt, G1 extends StaticGenericPrompt, N2 extends string, O2 extends GenericPromptOptions, P2 extends GenericPrompt, G2 extends StaticGenericPrompt, N3 extends string, O3 extends GenericPromptOptions, P3 extends GenericPrompt, G3 extends StaticGenericPrompt, R = & PromptResult & PromptResult & PromptResult & PromptResult, >(prompts: [ PromptOptions, PromptOptions, PromptOptions, PromptOptions, ], options?: GlobalPromptOptions): Promise; export function prompt< N0 extends string, O0 extends GenericPromptOptions, P0 extends GenericPrompt, G0 extends StaticGenericPrompt, N1 extends string, O1 extends GenericPromptOptions, P1 extends GenericPrompt, G1 extends StaticGenericPrompt, N2 extends string, O2 extends GenericPromptOptions, P2 extends GenericPrompt, G2 extends StaticGenericPrompt, R = & PromptResult & PromptResult & PromptResult, >(prompts: [ PromptOptions, PromptOptions, PromptOptions, ], options?: GlobalPromptOptions): Promise; export function prompt< N0 extends string, O0 extends GenericPromptOptions, P0 extends GenericPrompt, G0 extends StaticGenericPrompt, N1 extends string, O1 extends GenericPromptOptions, P1 extends GenericPrompt, G1 extends StaticGenericPrompt, R = & PromptResult & PromptResult, >(prompts: [ PromptOptions, PromptOptions, ], options?: GlobalPromptOptions): Promise; export function prompt< N0 extends string, O0 extends GenericPromptOptions, P0 extends GenericPrompt, G0 extends StaticGenericPrompt, R = PromptResult, >(prompts: [ PromptOptions, ], options?: GlobalPromptOptions): Promise; /** * Run a list of prompts. * @param prompts Array of prompt options. * @param options Global prompt options. */ export function prompt( prompts: PromptOptions[], options?: GlobalPromptOptions, ) { return new PromptList(prompts, options).run(options?.initial); } let injected: Record = {}; /** * Inject prompt values. Can be used for unit tests or pre selections. * @param values Input values object. */ export function inject(values: Record): void { injected = values; } class PromptList { private result: Record = {}; private index: number = -1; private names: string[] = this.prompts.map((prompt) => prompt.name); private isInBeforeHook = false; private get prompt(): PromptOptions { return this.prompts[this.index]; } public constructor( private prompts: PromptOptions[], private options?: PromptListOptions, ) {} public async run( name?: string | number | true, ): Promise> { this.index = -1; this.result = {}; this.isInBeforeHook = false; await this.next(name); return this.result; } private async next(name?: string | number | true | null): Promise { if (this.updateIndex(name)) { await this.runBeforeHook(async () => { this.isInBeforeHook = false; await this.runPrompt(); await this.runAfterHook(); }); } } private updateIndex(name?: string | number | true | null): boolean { if (name && typeof name === "string") { this.index = this.names.indexOf(name); if (this.index === -1) { throw new Error( `Invalid prompt name: ${name}, allowed prompt names: ${ this.names.join(", ") }`, ); } } else if (typeof name === "number") { if (name < 0 || name > this.names.length) { throw new Error( `Invalid prompt index: ${name}, prompt length: ${this.names.length}`, ); } this.index = name; } else if (name === true && !this.isInBeforeHook) { this.index++; if (this.index < this.names.length - 1) { this.index++; } } else { this.index++; } this.isInBeforeHook = false; if (this.index < this.names.length) { return true; } else if (this.index === this.names.length) { return false; } else { throw new Error("next() called multiple times"); } } private async runBeforeHook(run: () => Promise): Promise { this.isInBeforeHook = true; const next = async (name?: string | number | true | null) => { if (name || typeof name === "number") { return this.next(name as (string | number | true)); } await run(); }; if (this.options?.before) { await this.options.before( this.prompt.name, this.result, async (name?: string | number | true | null) => { if (name || typeof name === "number") { return this.next(name as (string | number | true)); } else if (this.prompt.before) { await this.prompt.before(this.result, next); } else { await run(); } }, ); return; } else if (this.prompt.before) { await this.prompt.before(this.result, next); return; } await run(); } private async runPrompt(): Promise { const prompt: StaticGenericPrompt = this.prompt.type; if (typeof injected[this.prompt.name] !== "undefined") { if (prompt.inject) { prompt.inject(injected[this.prompt.name]); } else { GenericPrompt.inject(injected[this.prompt.name]); } } try { this.result[this.prompt.name] = await prompt.prompt({ cbreak: this.options?.cbreak, ...this.prompt, }); } finally { tty.cursorShow(); } } private async runAfterHook(): Promise { if (this.options?.after) { await this.options.after(this.prompt.name, this.result, async (name) => { if (name) { return this.next(name as string); } else if (this.prompt.after) { await this.prompt.after(this.result, (name) => this.next(name)); } else { await this.next(); } }); } else if (this.prompt.after) { await this.prompt.after(this.result, (name) => this.next(name)); } else { await this.next(); } } }