vite-plus 1.0.0 → 1.2.0

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.
Files changed (85) hide show
  1. package/LICENSE +59 -6
  2. package/README.md +7 -7
  3. package/binding/index.cjs +54 -55
  4. package/binding/index.d.cts +53 -12
  5. package/dist/{agent-CKMI1a8W.js → agent-KeDc6vmg.js} +2 -2
  6. package/dist/bin.js +14 -11
  7. package/dist/command-DaRqSNpP.js +1 -0
  8. package/dist/comparison-CmVirWIW-DUGaiYqF.js +121 -0
  9. package/dist/config/bin.js +4 -4
  10. package/dist/{constants-BqJiMVVU.js → constants-BW3g7VnD.js} +3 -3
  11. package/dist/create/bin.d.ts +2 -1
  12. package/dist/create/bin.js +126 -26
  13. package/dist/{define-config-Cf_5GHmY.d.ts → define-config-Bexdd6RZ.d.ts} +25 -9
  14. package/dist/{define-config-DhEJaYRc.js → define-config-CIlk9scU.js} +111 -6
  15. package/dist/{define-config-C_KGDLUZ.cjs → define-config-Dq_23Eyr.cjs} +89 -3
  16. package/dist/define-config.cjs +1 -1
  17. package/dist/define-config.d.ts +1 -1
  18. package/dist/define-config.js +1 -2
  19. package/dist/{dist-BsAzy8OW.js → dist-Bi7ZEK3c.js} +1 -2
  20. package/dist/dist-CBWGibx8.js +3 -0
  21. package/dist/{dist-DfmT__Aw.js → dist-Cqz8OtiO.js} +24 -21
  22. package/dist/{editor-CHfGUhxP.js → editor-b1XUwt9v.js} +114 -65
  23. package/dist/fmt.js +1 -2
  24. package/dist/hooks/bin.js +1 -1
  25. package/dist/{hooks-C-4gykWR.js → hooks-DhwsWb46.js} +34 -22
  26. package/dist/index.cjs +1 -1
  27. package/dist/index.d.ts +1 -1
  28. package/dist/index.js +1 -1
  29. package/dist/lint-plugins-dev.js +1 -2
  30. package/dist/lint-plugins.cjs +1 -1
  31. package/dist/lint-plugins.js +1 -2
  32. package/dist/migration/bin.js +63 -57
  33. package/dist/{oxlint-plugin-config-lMMD5fAC.js → oxlint-plugin-config-Dx-ZY2MN.js} +1 -1
  34. package/dist/oxlint-plugin.js +2 -2
  35. package/dist/pack-bin.js +4 -3
  36. package/dist/{package-Cgdlhamw.js → package-BP16iQby.js} +7 -2
  37. package/dist/package-overrides-D1RcXSFl.js +411 -0
  38. package/dist/{prompts-jMH8S4Wp.js → prompts-BGpQtC5z.js} +548 -262
  39. package/dist/resolve-vite-config-CGzlyhGr.js +1 -0
  40. package/dist/{resolve-vite-config-BJYYtfY3.js → resolve-vite-config-x47JetlI.js} +2 -2
  41. package/dist/staged/bin.js +792 -743
  42. package/dist/sync-versions/bin.js +4761 -3373
  43. package/dist/sync-versions/bin.mjs +5304 -5083
  44. package/dist/test/browser/providers/playwright.d.ts +7 -2
  45. package/dist/test/browser-playwright.d.ts +7 -2
  46. package/dist/toolchain.js +12 -12
  47. package/dist/toolchain.json +12 -12
  48. package/dist/tsconfig-C5PnJfW4.js +1 -0
  49. package/dist/{tsconfig-BoYTBNX_.js → tsconfig-D2DzAQ_D.js} +2 -2
  50. package/dist/version.js +2 -2
  51. package/dist/versions.js +7 -7
  52. package/docs/config/run.md +9 -5
  53. package/docs/config/staged.md +1 -1
  54. package/docs/guide/automatic-data-tracking.md +7 -6
  55. package/docs/guide/cache.md +3 -3
  56. package/docs/guide/check.md +7 -7
  57. package/docs/guide/ci.md +3 -4
  58. package/docs/guide/commit-hooks.md +3 -1
  59. package/docs/guide/create.md +14 -4
  60. package/docs/guide/env.md +19 -7
  61. package/docs/guide/github-actions-cache.md +2 -4
  62. package/docs/guide/global-cli.md +36 -10
  63. package/docs/guide/ide-integration.md +4 -2
  64. package/docs/guide/implode.md +2 -0
  65. package/docs/guide/index.md +8 -8
  66. package/docs/guide/local-cli.md +27 -11
  67. package/docs/guide/migrate-rules.md +11 -3
  68. package/docs/guide/migrate.md +11 -11
  69. package/docs/guide/{install.md → package-management.md} +28 -4
  70. package/docs/guide/run.md +10 -8
  71. package/docs/guide/test.md +3 -1
  72. package/docs/guide/troubleshooting.md +9 -7
  73. package/docs/guide/upgrade-project.md +2 -6
  74. package/docs/guide/upgrade.md +6 -0
  75. package/docs/guide/vitest-v5.md +2 -2
  76. package/docs/guide/vpx.md +5 -5
  77. package/package.json +37 -33
  78. package/templates/generator/bin/index.ts +0 -0
  79. package/templates/generator/package.json +2 -2
  80. package/templates/generator/src/template.ts +1 -0
  81. package/dist/command-CLJK5jGW.js +0 -2
  82. package/dist/dist-BWiANxFS.js +0 -8052
  83. package/dist/package-overrides-Dpn4scvN.js +0 -17
  84. package/dist/resolve-vite-config-BPgpYMYp.js +0 -2
  85. package/dist/tsconfig-CmKidmRD.js +0 -2
@@ -1,16 +1,16 @@
1
1
  import { r as __toESM, t as __commonJSMin } from "./rolldown-runtime-CMFfr-1z.js";
2
2
  import { t as accent } from "./terminal-MKGAuy-p.js";
3
- import { f as VITE_PLUS_VERSION } from "./constants-BqJiMVVU.js";
3
+ import { f as VITE_PLUS_VERSION } from "./constants-BW3g7VnD.js";
4
4
  import { a as writeJsonFile, i as readJsonFile } from "./json-JP24qHUF.js";
5
- import { n as require_semver, t as require_dist } from "./dist-BWiANxFS.js";
5
+ import { _ as isGreaterThanOrEqual, b as safeRegex, g as formatComparableVersion, l as PRERELEASE, n as COERCE, r as COERCE_FULL, u as PRERELEASE_LOOSE, x as tryParse, y as parse } from "./comparison-CmVirWIW-DUGaiYqF.js";
6
6
  import { n as runCommandSilently } from "./command-CguLh2KL.js";
7
+ import { t as require_dist } from "./dist-Bi7ZEK3c.js";
7
8
  import path from "node:path";
8
9
  import { downloadPackageManager } from "../binding/index.js";
9
10
  import { stripVTControlCharacters, styleText } from "node:util";
10
11
  import fs from "node:fs";
11
12
  import process$1, { stdin, stdout } from "node:process";
12
- import * as l from "node:readline";
13
- import l__default from "node:readline";
13
+ import l__default, * as l from "node:readline";
14
14
  import { ReadStream } from "node:tty";
15
15
  import { randomBytes } from "node:crypto";
16
16
  //#region ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
@@ -23,7 +23,7 @@ const getCodePointsLength$1 = (() => {
23
23
  return input.length - surrogatePairsNr;
24
24
  };
25
25
  })();
26
- const isFullWidth = (x) => {
26
+ const isFullWidth$2 = (x) => {
27
27
  return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
28
28
  };
29
29
  const isWideNotCJKTNotEmoji$1 = (x) => {
@@ -31,21 +31,21 @@ const isWideNotCJKTNotEmoji$1 = (x) => {
31
31
  };
32
32
  //#endregion
33
33
  //#region ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/index.js
34
- const ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
35
- const CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
34
+ const ANSI_RE$2 = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
35
+ const CONTROL_RE$2 = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
36
36
  const CJKT_WIDE_RE$1 = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy;
37
- const TAB_RE = /\t{1,1000}/y;
38
- const EMOJI_RE = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy;
39
- const LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
40
- const MODIFIER_RE = /\p{M}+/gu;
41
- const NO_TRUNCATION$1 = {
37
+ const TAB_RE$2 = /\t{1,1000}/y;
38
+ const EMOJI_RE$2 = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy;
39
+ const LATIN_RE$2 = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
40
+ const MODIFIER_RE$2 = /\p{M}+/gu;
41
+ const NO_TRUNCATION$5 = {
42
42
  limit: Infinity,
43
43
  ellipsis: ""
44
44
  };
45
- const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
45
+ const getStringTruncatedWidth$2 = (input, truncationOptions = {}, widthOptions = {}) => {
46
46
  const LIMIT = truncationOptions.limit ?? Infinity;
47
47
  const ELLIPSIS = truncationOptions.ellipsis ?? "";
48
- const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION$1, widthOptions).width : 0);
48
+ const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth$2(ELLIPSIS, NO_TRUNCATION$5, widthOptions).width : 0);
49
49
  const ANSI_WIDTH = 0;
50
50
  const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
51
51
  const TAB_WIDTH = widthOptions.tabWidth ?? 8;
@@ -54,11 +54,11 @@ const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {
54
54
  const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
55
55
  const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
56
56
  const PARSE_BLOCKS = [
57
- [LATIN_RE, REGULAR_WIDTH],
58
- [ANSI_RE, ANSI_WIDTH],
59
- [CONTROL_RE, CONTROL_WIDTH],
60
- [TAB_RE, TAB_WIDTH],
61
- [EMOJI_RE, EMOJI_WIDTH],
57
+ [LATIN_RE$2, REGULAR_WIDTH],
58
+ [ANSI_RE$2, ANSI_WIDTH],
59
+ [CONTROL_RE$2, CONTROL_WIDTH],
60
+ [TAB_RE$2, TAB_WIDTH],
61
+ [EMOJI_RE$2, EMOJI_WIDTH],
62
62
  [CJKT_WIDE_RE$1, WIDE_WIDTH]
63
63
  ];
64
64
  let indexPrev = 0;
@@ -76,9 +76,9 @@ const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {
76
76
  if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
77
77
  const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
78
78
  lengthExtra = 0;
79
- for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
79
+ for (const char of unmatched.replaceAll(MODIFIER_RE$2, "")) {
80
80
  const codePoint = char.codePointAt(0) || 0;
81
- if (isFullWidth(codePoint)) widthExtra = FULL_WIDTH_WIDTH;
81
+ if (isFullWidth$2(codePoint)) widthExtra = FULL_WIDTH_WIDTH;
82
82
  else if (isWideNotCJKTNotEmoji$1(codePoint)) widthExtra = WIDE_WIDTH;
83
83
  else widthExtra = REGULAR_WIDTH;
84
84
  if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
@@ -96,7 +96,7 @@ const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {
96
96
  const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
97
97
  BLOCK_RE.lastIndex = index;
98
98
  if (BLOCK_RE.test(input)) {
99
- lengthExtra = BLOCK_RE === CJKT_WIDE_RE$1 ? getCodePointsLength$1(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
99
+ lengthExtra = BLOCK_RE === CJKT_WIDE_RE$1 ? getCodePointsLength$1(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE$2 ? 1 : BLOCK_RE.lastIndex - index;
100
100
  widthExtra = lengthExtra * BLOCK_WIDTH;
101
101
  if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
102
102
  if (width + widthExtra > LIMIT) {
@@ -121,13 +121,13 @@ const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {
121
121
  };
122
122
  //#endregion
123
123
  //#region ../../node_modules/.pnpm/fast-string-width@3.0.2/node_modules/fast-string-width/dist/index.js
124
- const NO_TRUNCATION = {
124
+ const NO_TRUNCATION$4 = {
125
125
  limit: Infinity,
126
126
  ellipsis: "",
127
127
  ellipsisWidth: 0
128
128
  };
129
- const fastStringWidth = (input, options = {}) => {
130
- return getStringTruncatedWidth(input, NO_TRUNCATION, options).width;
129
+ const fastStringWidth$2 = (input, options = {}) => {
130
+ return getStringTruncatedWidth$2(input, NO_TRUNCATION$4, options).width;
131
131
  };
132
132
  //#endregion
133
133
  //#region ../../node_modules/.pnpm/fast-wrap-ansi@0.2.0/node_modules/fast-wrap-ansi/lib/main.js
@@ -160,13 +160,13 @@ const wrapWord$1 = (rows, word, columns) => {
160
160
  let isInsideEscape = false;
161
161
  let isInsideLinkEscape = false;
162
162
  let lastRow = rows.at(-1);
163
- let visible = lastRow === void 0 ? 0 : fastStringWidth(lastRow);
163
+ let visible = lastRow === void 0 ? 0 : fastStringWidth$2(lastRow);
164
164
  let currentCharacter = characters.next();
165
165
  let nextCharacter = characters.next();
166
166
  let rawCharacterIndex = 0;
167
167
  while (!currentCharacter.done) {
168
168
  const character = currentCharacter.value;
169
- const characterLength = fastStringWidth(character);
169
+ const characterLength = fastStringWidth$2(character);
170
170
  if (visible + characterLength <= columns) rows[rows.length - 1] += character;
171
171
  else {
172
172
  rows.push(character);
@@ -201,7 +201,7 @@ const stringVisibleTrimSpacesRight$1 = (string) => {
201
201
  const words = string.split(" ");
202
202
  let last = words.length;
203
203
  while (last) {
204
- if (fastStringWidth(words[last - 1])) break;
204
+ if (fastStringWidth$2(words[last - 1])) break;
205
205
  last--;
206
206
  }
207
207
  if (last === words.length) return string;
@@ -222,7 +222,7 @@ const exec$1 = (string, columns, options = {}) => {
222
222
  const trimmed = row.trimStart();
223
223
  if (row.length !== trimmed.length) {
224
224
  rows[rows.length - 1] = trimmed;
225
- rowLength = fastStringWidth(trimmed);
225
+ rowLength = fastStringWidth$2(trimmed);
226
226
  }
227
227
  }
228
228
  if (index !== 0) {
@@ -235,19 +235,19 @@ const exec$1 = (string, columns, options = {}) => {
235
235
  rowLength++;
236
236
  }
237
237
  }
238
- const wordLength = fastStringWidth(word);
238
+ const wordLength = fastStringWidth$2(word);
239
239
  if (options.hard && wordLength > columns) {
240
240
  const remainingColumns = columns - rowLength;
241
241
  const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
242
242
  if (Math.floor((wordLength - 1) / columns) < breaksStartingThisLine) rows.push("");
243
243
  wrapWord$1(rows, word, columns);
244
- rowLength = fastStringWidth(rows.at(-1) ?? "");
244
+ rowLength = fastStringWidth$2(rows.at(-1) ?? "");
245
245
  continue;
246
246
  }
247
247
  if (rowLength + wordLength > columns && rowLength && wordLength) {
248
248
  if (options.wordWrap === false && rowLength < columns) {
249
249
  wrapWord$1(rows, word, columns);
250
- rowLength = fastStringWidth(rows.at(-1) ?? "");
250
+ rowLength = fastStringWidth$2(rows.at(-1) ?? "");
251
251
  continue;
252
252
  }
253
253
  rows.push("");
@@ -255,7 +255,7 @@ const exec$1 = (string, columns, options = {}) => {
255
255
  }
256
256
  if (rowLength + wordLength > columns && options.wordWrap === false) {
257
257
  wrapWord$1(rows, word, columns);
258
- rowLength = fastStringWidth(rows.at(-1) ?? "");
258
+ rowLength = fastStringWidth$2(rows.at(-1) ?? "");
259
259
  continue;
260
260
  }
261
261
  rows[rows.length - 1] += word;
@@ -295,7 +295,7 @@ function wrapAnsi$1(string, columns, options) {
295
295
  return String(string).normalize().split(CRLF_OR_LF$1).map((line) => exec$1(line, columns, options)).join("\n");
296
296
  }
297
297
  //#endregion
298
- //#region ../../node_modules/.pnpm/@clack+core@1.4.3/node_modules/@clack/core/dist/index.mjs
298
+ //#region ../../node_modules/.pnpm/@clack+core@1.5.1/node_modules/@clack/core/dist/index.mjs
299
299
  var import_src = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
300
300
  const ESC = "\x1B";
301
301
  const CSI = `${ESC}[`;
@@ -376,6 +376,7 @@ const settings = {
376
376
  error: "Something went wrong"
377
377
  },
378
378
  withGuide: true,
379
+ accessible: void 0,
379
380
  date: {
380
381
  monthNames: [...[
381
382
  "January",
@@ -400,6 +401,30 @@ const settings = {
400
401
  }
401
402
  }
402
403
  };
404
+ function updateSettings(n) {
405
+ if (n.aliases !== void 0) {
406
+ const e = n.aliases;
407
+ for (const s in e) {
408
+ if (!Object.hasOwn(e, s)) continue;
409
+ const i = e[s];
410
+ i === void 0 || !settings.actions.has(i) || settings.aliases.has(s) || settings.aliases.set(s, i);
411
+ }
412
+ }
413
+ if (n.messages !== void 0) {
414
+ const e = n.messages;
415
+ e.cancel !== void 0 && (settings.messages.cancel = e.cancel), e.error !== void 0 && (settings.messages.error = e.error);
416
+ }
417
+ if (n.withGuide !== void 0 && (settings.withGuide = n.withGuide !== false), n.accessible !== void 0 && (settings.accessible = n.accessible === true), n.date !== void 0) {
418
+ const e = n.date;
419
+ e.monthNames !== void 0 && (settings.date.monthNames = [...e.monthNames]), e.messages !== void 0 && (e.messages.required !== void 0 && (settings.date.messages.required = e.messages.required), e.messages.invalidMonth !== void 0 && (settings.date.messages.invalidMonth = e.messages.invalidMonth), e.messages.invalidDay !== void 0 && (settings.date.messages.invalidDay = e.messages.invalidDay), e.messages.afterMin !== void 0 && (settings.date.messages.afterMin = e.messages.afterMin), e.messages.beforeMax !== void 0 && (settings.date.messages.beforeMax = e.messages.beforeMax));
420
+ }
421
+ }
422
+ function isAccessible(n) {
423
+ if (n !== void 0) return n;
424
+ if (settings.accessible !== void 0) return settings.accessible;
425
+ const e = process.env.ACCESSIBLE;
426
+ return e !== void 0 && e !== "" && e !== "0" && e !== "false";
427
+ }
403
428
  function isActionKey(n, e) {
404
429
  if (typeof n == "string") return settings.aliases.get(n) === e;
405
430
  for (const s of n) if (s !== void 0 && isActionKey(s, e)) return true;
@@ -427,7 +452,7 @@ function setRawMode(e, r) {
427
452
  const o = e;
428
453
  o.isTTY && o.setRawMode(r);
429
454
  }
430
- function block({ input: e = stdin, output: r = stdout, overwrite: o = true, hideCursor: t = true } = {}) {
455
+ function block({ input: e = stdin, output: r = stdout, overwrite: o = true, hideCursor: n = true } = {}) {
431
456
  const s = l.createInterface({
432
457
  input: e,
433
458
  output: r,
@@ -435,49 +460,37 @@ function block({ input: e = stdin, output: r = stdout, overwrite: o = true, hide
435
460
  tabSize: 1
436
461
  });
437
462
  l.emitKeypressEvents(e, s), e instanceof ReadStream && e.isTTY && e.setRawMode(true);
438
- const n = (f, { name: a, sequence: p }) => {
463
+ const t = (f, { name: a, sequence: w }) => {
439
464
  if (isActionKey([
440
465
  String(f),
441
466
  a,
442
- p
467
+ w
443
468
  ], "cancel")) {
444
- t && r.write(import_src.cursor.show), process.exit(0);
469
+ n && r.write(import_src.cursor.show), process.exit(0);
445
470
  return;
446
471
  }
447
472
  if (!o) return;
448
473
  const i = a === "return" ? 0 : -1, m = a === "return" ? -1 : 0;
449
474
  l.moveCursor(r, i, m, () => {
450
475
  l.clearLine(r, 1, () => {
451
- e.once("keypress", n);
476
+ e.once("keypress", t);
452
477
  });
453
478
  });
454
479
  };
455
- return t && r.write(import_src.cursor.hide), e.once("keypress", n), () => {
456
- e.off("keypress", n), t && r.write(import_src.cursor.show), e instanceof ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
480
+ return n && r.write(import_src.cursor.hide), e.once("keypress", t), () => {
481
+ e.off("keypress", t), n && r.write(import_src.cursor.show), e instanceof ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
457
482
  };
458
483
  }
459
484
  const getColumns = (e) => "columns" in e && typeof e.columns == "number" ? e.columns : 80;
460
485
  const getRows = (e) => "rows" in e && typeof e.rows == "number" ? e.rows : 20;
461
- function wrapTextWithPrefix(e, r, o, t = o, s = o, n) {
462
- return wrapAnsi$1(r, getColumns(e ?? stdout) - o.length, {
463
- hard: true,
464
- trim: false
465
- }).split(`
466
- `).map((c, i, m) => {
467
- const d = n ? n(c, i) : c;
468
- return i === 0 ? `${t}${d}` : i === m.length - 1 ? `${s}${d}` : `${o}${d}`;
469
- }).join(`
470
- `);
471
- }
472
- function runValidation(e, n) {
486
+ function runValidation(e, a) {
473
487
  if ("~standard" in e) {
474
- const a = e["~standard"].validate(n);
475
- if (a instanceof Promise) throw new TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");
476
- return a.issues?.at(0)?.message;
488
+ const n = e["~standard"].validate(a);
489
+ return n instanceof Promise ? n.then((r) => r.issues?.at(0)?.message) : n.issues?.at(0)?.message;
477
490
  }
478
- return e(n);
491
+ return e(a);
479
492
  }
480
- var V = class {
493
+ var y = class {
481
494
  input;
482
495
  output;
483
496
  _abortSignal;
@@ -492,9 +505,17 @@ var V = class {
492
505
  error = "";
493
506
  value;
494
507
  userInput = "";
508
+ /**
509
+ * Whether accessible (static, screen-reader friendly) output is enabled for
510
+ * this prompt, resolved from the `accessible` option, the global setting,
511
+ * and the `ACCESSIBLE` env var.
512
+ */
513
+ get accessible() {
514
+ return isAccessible(this.opts.accessible);
515
+ }
495
516
  constructor(t, e = true) {
496
- const { input: i = stdin, output: n = stdout, render: s, signal: r, ...o } = t;
497
- this.opts = o, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = s.bind(this), this._track = e, this._abortSignal = r, this.input = i, this.output = n;
517
+ const { input: i = stdin, output: s = stdout, render: r, signal: n, ...o } = t;
518
+ this.opts = o, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = r.bind(this), this._track = e, this._abortSignal = n, this.input = i, this.output = s;
498
519
  }
499
520
  /**
500
521
  * Unsubscribe all listeners
@@ -535,9 +556,9 @@ var V = class {
535
556
  * @param data - The data to pass to the callback
536
557
  */
537
558
  emit(t, ...e) {
538
- const i = this._subscribers.get(t) ?? [], n = [];
539
- for (const s of i) s.cb(...e), s.once && n.push(() => i.splice(i.indexOf(s), 1));
540
- for (const s of n) s();
559
+ const i = this._subscribers.get(t) ?? [], s = [];
560
+ for (const r of i) r.cb(...e), r.once && s.push(() => i.splice(i.indexOf(r), 1));
561
+ for (const r of s) r();
541
562
  }
542
563
  prompt() {
543
564
  return new Promise((t) => {
@@ -578,22 +599,25 @@ var V = class {
578
599
  name: "u"
579
600
  }), this._setUserInput("");
580
601
  }
581
- onKeypress(t, e) {
582
- if (this._track && e.name !== "return" && (e.name && this._isActionKey(t, e) && this.rl?.write(null, {
583
- ctrl: true,
584
- name: "h"
585
- }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track && settings.aliases.has(e.name) && this.emit("cursor", settings.aliases.get(e.name)), settings.actions.has(e.name) && this.emit("cursor", e.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t, e), e?.name === "return" && this._shouldSubmit(t, e)) {
586
- if (this.opts.validate) {
587
- const i = runValidation(this.opts.validate, this.value);
588
- i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
602
+ async onKeypress(t, e) {
603
+ if (this.state !== "validating") {
604
+ if (this._track && e.name !== "return" && (e.name && this._isActionKey(t, e) && this.rl?.write(null, {
605
+ ctrl: true,
606
+ name: "h"
607
+ }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track && settings.aliases.has(e.name) && this.emit("cursor", settings.aliases.get(e.name)), settings.actions.has(e.name) && this.emit("cursor", e.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t, e), e?.name === "return" && this._shouldSubmit(t, e)) {
608
+ if (this.opts.validate) {
609
+ const i = runValidation(this.opts.validate, this.value);
610
+ let s;
611
+ i instanceof Promise ? (this.state = "validating", this.render(), s = await i) : s = i, s && (this.error = s instanceof Error ? s.message : s, this.state = "error", this.rl?.write(this.userInput));
612
+ }
613
+ this.state !== "error" && (this.state = "submit");
589
614
  }
590
- this.state !== "error" && (this.state = "submit");
615
+ isActionKey([
616
+ t,
617
+ e?.name,
618
+ e?.sequence
619
+ ], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
591
620
  }
592
- isActionKey([
593
- t,
594
- e?.name,
595
- e?.sequence
596
- ], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
597
621
  }
598
622
  close() {
599
623
  this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
@@ -617,27 +641,27 @@ var V = class {
617
641
  else {
618
642
  const e = diffLines(this._prevFrame, t), i = getRows(this.output);
619
643
  if (this.restoreCursor(), e) {
620
- const n = Math.max(0, e.numLinesAfter - i), s = Math.max(0, e.numLinesBefore - i);
621
- let r = e.lines.find((o) => o >= n);
622
- if (r === void 0) {
644
+ const s = Math.max(0, e.numLinesAfter - i), r = Math.max(0, e.numLinesBefore - i);
645
+ let n = e.lines.find((o) => o >= s);
646
+ if (n === void 0) {
623
647
  this._prevFrame = t;
624
648
  return;
625
649
  }
626
650
  if (e.lines.length === 1) {
627
- this.output.write(import_src.cursor.move(0, r - s)), this.output.write(import_src.erase.lines(1));
651
+ this.output.write(import_src.cursor.move(0, n - r)), this.output.write(import_src.erase.lines(1));
628
652
  const o = t.split(`
629
653
  `);
630
- this.output.write(o[r]), this._prevFrame = t, this.output.write(import_src.cursor.move(0, o.length - r - 1));
654
+ this.output.write(o[n]), this._prevFrame = t, this.output.write(import_src.cursor.move(0, o.length - n - 1));
631
655
  return;
632
656
  } else if (e.lines.length > 1) {
633
- if (n < s) r = n;
657
+ if (s < r) n = s;
634
658
  else {
635
- const h = r - s;
659
+ const h = n - r;
636
660
  h > 0 && this.output.write(import_src.cursor.move(0, h));
637
661
  }
638
662
  this.output.write(import_src.erase.down());
639
663
  const f = t.split(`
640
- `).slice(r);
664
+ `).slice(n);
641
665
  this.output.write(f.join(`
642
666
  `)), this._prevFrame = t;
643
667
  return;
@@ -649,7 +673,7 @@ var V = class {
649
673
  }
650
674
  }
651
675
  };
652
- var r = class extends V {
676
+ var r = class extends y {
653
677
  get cursor() {
654
678
  return this.value ? 0 : 1;
655
679
  }
@@ -666,7 +690,7 @@ var r = class extends V {
666
690
  });
667
691
  }
668
692
  };
669
- var a = class extends V {
693
+ var a = class extends y {
670
694
  options;
671
695
  cursor = 0;
672
696
  get _value() {
@@ -710,7 +734,7 @@ var a = class extends V {
710
734
  });
711
735
  }
712
736
  };
713
- let n$1 = class n extends V {
737
+ let n$1 = class n extends y {
714
738
  options;
715
739
  cursor = 0;
716
740
  get _selectedValue() {
@@ -736,7 +760,7 @@ let n$1 = class n extends V {
736
760
  });
737
761
  }
738
762
  };
739
- var n = class extends V {
763
+ var n = class extends y {
740
764
  get userInputWithCursor() {
741
765
  if (this.state === "submit") return this.userInput;
742
766
  const t = this.userInput;
@@ -831,47 +855,156 @@ var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
831
855
  //#endregion
832
856
  //#region ../prompts/dist/index.mjs
833
857
  var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
834
- function isUnicodeSupported() {
835
- if (process$1.platform !== "win32") return process$1.env.TERM !== "linux";
836
- return Boolean(process$1.env.CI) || Boolean(process$1.env.WT_SESSION) || Boolean(process$1.env.TERMINUS_SUBLIME) || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
837
- }
838
- const unicode = isUnicodeSupported();
839
- const isCI = () => process.env.CI === "true";
840
- const unicodeOr = (c, fallback) => unicode ? c : fallback;
841
- const S_POINTER_ACTIVE = unicodeOr("›", ">");
842
- const S_STEP_ACTIVE = S_POINTER_ACTIVE;
843
- const S_STEP_CANCEL = unicodeOr("■", "x");
844
- const S_STEP_ERROR = unicodeOr("▲", "x");
845
- const S_STEP_SUBMIT = unicodeOr("◇", "o");
846
- const S_BAR = unicodeOr("│", "|");
847
- const S_BAR_END = unicodeOr("└", "—");
848
- const S_CHECKBOX_ACTIVE = unicodeOr("◻", "[•]");
849
- const S_CHECKBOX_SELECTED = unicodeOr("◼", "[+]");
850
- const S_CHECKBOX_INACTIVE = unicodeOr("◻", "[ ]");
851
- const S_INFO = unicodeOr("●", "•");
852
- const S_SUCCESS = unicodeOr("◆", "*");
853
- const S_WARN = unicodeOr("▲", "!");
854
- const S_ERROR = unicodeOr("■", "x");
855
- const completeColor = (value) => import_picocolors.default.gray(value);
856
- const symbol = (state) => {
857
- switch (state) {
858
- case "initial":
859
- case "active": return import_picocolors.default.blue(S_STEP_ACTIVE);
860
- case "cancel": return import_picocolors.default.red(S_STEP_CANCEL);
861
- case "error": return import_picocolors.default.yellow(S_STEP_ERROR);
862
- case "submit": return completeColor(S_STEP_SUBMIT);
863
- default: return import_picocolors.default.blue(S_STEP_ACTIVE);
864
- }
858
+ const isAmbiguous = (x) => {
859
+ return x === 161 || x === 164 || x === 167 || x === 168 || x === 170 || x === 173 || x === 174 || x >= 176 && x <= 180 || x >= 182 && x <= 186 || x >= 188 && x <= 191 || x === 198 || x === 208 || x === 215 || x === 216 || x >= 222 && x <= 225 || x === 230 || x >= 232 && x <= 234 || x === 236 || x === 237 || x === 240 || x === 242 || x === 243 || x >= 247 && x <= 250 || x === 252 || x === 254 || x === 257 || x === 273 || x === 275 || x === 283 || x === 294 || x === 295 || x === 299 || x >= 305 && x <= 307 || x === 312 || x >= 319 && x <= 322 || x === 324 || x >= 328 && x <= 331 || x === 333 || x === 338 || x === 339 || x === 358 || x === 359 || x === 363 || x === 462 || x === 464 || x === 466 || x === 468 || x === 470 || x === 472 || x === 474 || x === 476 || x === 593 || x === 609 || x === 708 || x === 711 || x >= 713 && x <= 715 || x === 717 || x === 720 || x >= 728 && x <= 731 || x === 733 || x === 735 || x >= 768 && x <= 879 || x >= 913 && x <= 929 || x >= 931 && x <= 937 || x >= 945 && x <= 961 || x >= 963 && x <= 969 || x === 1025 || x >= 1040 && x <= 1103 || x === 1105 || x === 8208 || x >= 8211 && x <= 8214 || x === 8216 || x === 8217 || x === 8220 || x === 8221 || x >= 8224 && x <= 8226 || x >= 8228 && x <= 8231 || x === 8240 || x === 8242 || x === 8243 || x === 8245 || x === 8251 || x === 8254 || x === 8308 || x === 8319 || x >= 8321 && x <= 8324 || x === 8364 || x === 8451 || x === 8453 || x === 8457 || x === 8467 || x === 8470 || x === 8481 || x === 8482 || x === 8486 || x === 8491 || x === 8531 || x === 8532 || x >= 8539 && x <= 8542 || x >= 8544 && x <= 8555 || x >= 8560 && x <= 8569 || x === 8585 || x >= 8592 && x <= 8601 || x === 8632 || x === 8633 || x === 8658 || x === 8660 || x === 8679 || x === 8704 || x === 8706 || x === 8707 || x === 8711 || x === 8712 || x === 8715 || x === 8719 || x === 8721 || x === 8725 || x === 8730 || x >= 8733 && x <= 8736 || x === 8739 || x === 8741 || x >= 8743 && x <= 8748 || x === 8750 || x >= 8756 && x <= 8759 || x === 8764 || x === 8765 || x === 8776 || x === 8780 || x === 8786 || x === 8800 || x === 8801 || x >= 8804 && x <= 8807 || x === 8810 || x === 8811 || x === 8814 || x === 8815 || x === 8834 || x === 8835 || x === 8838 || x === 8839 || x === 8853 || x === 8857 || x === 8869 || x === 8895 || x === 8978 || x >= 9312 && x <= 9449 || x >= 9451 && x <= 9547 || x >= 9552 && x <= 9587 || x >= 9600 && x <= 9615 || x >= 9618 && x <= 9621 || x === 9632 || x === 9633 || x >= 9635 && x <= 9641 || x === 9650 || x === 9651 || x === 9654 || x === 9655 || x === 9660 || x === 9661 || x === 9664 || x === 9665 || x >= 9670 && x <= 9672 || x === 9675 || x >= 9678 && x <= 9681 || x >= 9698 && x <= 9701 || x === 9711 || x === 9733 || x === 9734 || x === 9737 || x === 9742 || x === 9743 || x === 9756 || x === 9758 || x === 9792 || x === 9794 || x === 9824 || x === 9825 || x >= 9827 && x <= 9829 || x >= 9831 && x <= 9834 || x === 9836 || x === 9837 || x === 9839 || x === 9886 || x === 9887 || x === 9919 || x >= 9926 && x <= 9933 || x >= 9935 && x <= 9939 || x >= 9941 && x <= 9953 || x === 9955 || x === 9960 || x === 9961 || x >= 9963 && x <= 9969 || x === 9972 || x >= 9974 && x <= 9977 || x === 9979 || x === 9980 || x === 9982 || x === 9983 || x === 10045 || x >= 10102 && x <= 10111 || x >= 11094 && x <= 11097 || x >= 12872 && x <= 12879 || x >= 57344 && x <= 63743 || x >= 65024 && x <= 65039 || x === 65533 || x >= 127232 && x <= 127242 || x >= 127248 && x <= 127277 || x >= 127280 && x <= 127337 || x >= 127344 && x <= 127373 || x === 127375 || x === 127376 || x >= 127387 && x <= 127404 || x >= 917760 && x <= 917999 || x >= 983040 && x <= 1048573 || x >= 1048576 && x <= 1114109;
865
860
  };
866
- const symbolBar = (state) => {
867
- switch (state) {
868
- case "initial":
869
- case "active": return import_picocolors.default.blue(S_BAR);
870
- case "cancel": return import_picocolors.default.red(S_BAR);
871
- case "error": return import_picocolors.default.yellow(S_BAR);
872
- case "submit": return completeColor(S_BAR);
873
- default: return import_picocolors.default.blue(S_BAR);
861
+ const isFullWidth$1 = (x) => {
862
+ return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
863
+ };
864
+ const isWide = (x) => {
865
+ return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9800 && x <= 9811 || x === 9855 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 19968 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x === 94192 || x === 94193 || x >= 94208 && x <= 100343 || x >= 100352 && x <= 101589 || x >= 101632 && x <= 101640 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128727 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129672 || x >= 129680 && x <= 129725 || x >= 129727 && x <= 129733 || x >= 129742 && x <= 129755 || x >= 129760 && x <= 129768 || x >= 129776 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
866
+ };
867
+ const ANSI_RE$1 = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
868
+ const CONTROL_RE$1 = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
869
+ const TAB_RE$1 = /\t{1,1000}/y;
870
+ const EMOJI_RE$1 = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy;
871
+ const LATIN_RE$1 = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
872
+ const MODIFIER_RE$1 = /\p{M}+/gu;
873
+ const NO_TRUNCATION$3 = {
874
+ limit: Infinity,
875
+ ellipsis: ""
876
+ };
877
+ const getStringTruncatedWidth$1 = (input, truncationOptions = {}, widthOptions = {}) => {
878
+ const LIMIT = truncationOptions.limit ?? Infinity;
879
+ const ELLIPSIS = truncationOptions.ellipsis ?? "";
880
+ const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth$1(ELLIPSIS, NO_TRUNCATION$3, widthOptions).width : 0);
881
+ const ANSI_WIDTH = widthOptions.ansiWidth ?? 0;
882
+ const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
883
+ const TAB_WIDTH = widthOptions.tabWidth ?? 8;
884
+ const AMBIGUOUS_WIDTH = widthOptions.ambiguousWidth ?? 1;
885
+ const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
886
+ const FULL_WIDTH_WIDTH = widthOptions.fullWidthWidth ?? 2;
887
+ const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
888
+ const WIDE_WIDTH = widthOptions.wideWidth ?? 2;
889
+ let indexPrev = 0;
890
+ let index = 0;
891
+ let length = input.length;
892
+ let lengthExtra = 0;
893
+ let truncationEnabled = false;
894
+ let truncationIndex = length;
895
+ let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
896
+ let unmatchedStart = 0;
897
+ let unmatchedEnd = 0;
898
+ let width = 0;
899
+ let widthExtra = 0;
900
+ outer: while (true) {
901
+ if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
902
+ const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
903
+ lengthExtra = 0;
904
+ for (const char of unmatched.replaceAll(MODIFIER_RE$1, "")) {
905
+ const codePoint = char.codePointAt(0) || 0;
906
+ if (isFullWidth$1(codePoint)) widthExtra = FULL_WIDTH_WIDTH;
907
+ else if (isWide(codePoint)) widthExtra = WIDE_WIDTH;
908
+ else if (AMBIGUOUS_WIDTH !== REGULAR_WIDTH && isAmbiguous(codePoint)) widthExtra = AMBIGUOUS_WIDTH;
909
+ else widthExtra = REGULAR_WIDTH;
910
+ if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
911
+ if (width + widthExtra > LIMIT) {
912
+ truncationEnabled = true;
913
+ break outer;
914
+ }
915
+ lengthExtra += char.length;
916
+ width += widthExtra;
917
+ }
918
+ unmatchedStart = unmatchedEnd = 0;
919
+ }
920
+ if (index >= length) break;
921
+ LATIN_RE$1.lastIndex = index;
922
+ if (LATIN_RE$1.test(input)) {
923
+ lengthExtra = LATIN_RE$1.lastIndex - index;
924
+ widthExtra = lengthExtra * REGULAR_WIDTH;
925
+ if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / REGULAR_WIDTH));
926
+ if (width + widthExtra > LIMIT) {
927
+ truncationEnabled = true;
928
+ break;
929
+ }
930
+ width += widthExtra;
931
+ unmatchedStart = indexPrev;
932
+ unmatchedEnd = index;
933
+ index = indexPrev = LATIN_RE$1.lastIndex;
934
+ continue;
935
+ }
936
+ ANSI_RE$1.lastIndex = index;
937
+ if (ANSI_RE$1.test(input)) {
938
+ if (width + ANSI_WIDTH > truncationLimit) truncationIndex = Math.min(truncationIndex, index);
939
+ if (width + ANSI_WIDTH > LIMIT) {
940
+ truncationEnabled = true;
941
+ break;
942
+ }
943
+ width += ANSI_WIDTH;
944
+ unmatchedStart = indexPrev;
945
+ unmatchedEnd = index;
946
+ index = indexPrev = ANSI_RE$1.lastIndex;
947
+ continue;
948
+ }
949
+ CONTROL_RE$1.lastIndex = index;
950
+ if (CONTROL_RE$1.test(input)) {
951
+ lengthExtra = CONTROL_RE$1.lastIndex - index;
952
+ widthExtra = lengthExtra * CONTROL_WIDTH;
953
+ if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / CONTROL_WIDTH));
954
+ if (width + widthExtra > LIMIT) {
955
+ truncationEnabled = true;
956
+ break;
957
+ }
958
+ width += widthExtra;
959
+ unmatchedStart = indexPrev;
960
+ unmatchedEnd = index;
961
+ index = indexPrev = CONTROL_RE$1.lastIndex;
962
+ continue;
963
+ }
964
+ TAB_RE$1.lastIndex = index;
965
+ if (TAB_RE$1.test(input)) {
966
+ lengthExtra = TAB_RE$1.lastIndex - index;
967
+ widthExtra = lengthExtra * TAB_WIDTH;
968
+ if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / TAB_WIDTH));
969
+ if (width + widthExtra > LIMIT) {
970
+ truncationEnabled = true;
971
+ break;
972
+ }
973
+ width += widthExtra;
974
+ unmatchedStart = indexPrev;
975
+ unmatchedEnd = index;
976
+ index = indexPrev = TAB_RE$1.lastIndex;
977
+ continue;
978
+ }
979
+ EMOJI_RE$1.lastIndex = index;
980
+ if (EMOJI_RE$1.test(input)) {
981
+ if (width + EMOJI_WIDTH > truncationLimit) truncationIndex = Math.min(truncationIndex, index);
982
+ if (width + EMOJI_WIDTH > LIMIT) {
983
+ truncationEnabled = true;
984
+ break;
985
+ }
986
+ width += EMOJI_WIDTH;
987
+ unmatchedStart = indexPrev;
988
+ unmatchedEnd = index;
989
+ index = indexPrev = EMOJI_RE$1.lastIndex;
990
+ continue;
991
+ }
992
+ index += 1;
874
993
  }
994
+ return {
995
+ width: truncationEnabled ? truncationLimit : width,
996
+ index: truncationEnabled ? truncationIndex : length,
997
+ truncated: truncationEnabled,
998
+ ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
999
+ };
1000
+ };
1001
+ const NO_TRUNCATION$2 = {
1002
+ limit: Infinity,
1003
+ ellipsis: "",
1004
+ ellipsisWidth: 0
1005
+ };
1006
+ const fastStringWidth$1 = (input, options = {}) => {
1007
+ return getStringTruncatedWidth$1(input, NO_TRUNCATION$2, options).width;
875
1008
  };
876
1009
  const getCodePointsLength = (() => {
877
1010
  const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
@@ -882,27 +1015,27 @@ const getCodePointsLength = (() => {
882
1015
  return input.length - surrogatePairsNr;
883
1016
  };
884
1017
  })();
885
- const isFullWidth$1 = (x) => {
1018
+ const isFullWidth = (x) => {
886
1019
  return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
887
1020
  };
888
1021
  const isWideNotCJKTNotEmoji = (x) => {
889
1022
  return x === 8987 || x === 9001 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
890
1023
  };
891
- const ANSI_RE$1 = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
892
- const CONTROL_RE$1 = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
1024
+ const ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
1025
+ const CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
893
1026
  const CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy;
894
- const TAB_RE$1 = /\t{1,1000}/y;
895
- const EMOJI_RE$1 = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy;
896
- const LATIN_RE$1 = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
897
- const MODIFIER_RE$1 = /\p{M}+/gu;
898
- const NO_TRUNCATION$3 = {
1027
+ const TAB_RE = /\t{1,1000}/y;
1028
+ const EMOJI_RE = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy;
1029
+ const LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
1030
+ const MODIFIER_RE = /\p{M}+/gu;
1031
+ const NO_TRUNCATION$1 = {
899
1032
  limit: Infinity,
900
1033
  ellipsis: ""
901
1034
  };
902
- const getStringTruncatedWidth$1 = (input, truncationOptions = {}, widthOptions = {}) => {
1035
+ const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
903
1036
  const LIMIT = truncationOptions.limit ?? Infinity;
904
1037
  const ELLIPSIS = truncationOptions.ellipsis ?? "";
905
- const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth$1(ELLIPSIS, NO_TRUNCATION$3, widthOptions).width : 0);
1038
+ const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION$1, widthOptions).width : 0);
906
1039
  const ANSI_WIDTH = 0;
907
1040
  const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
908
1041
  const TAB_WIDTH = widthOptions.tabWidth ?? 8;
@@ -911,11 +1044,11 @@ const getStringTruncatedWidth$1 = (input, truncationOptions = {}, widthOptions =
911
1044
  const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
912
1045
  const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
913
1046
  const PARSE_BLOCKS = [
914
- [LATIN_RE$1, REGULAR_WIDTH],
915
- [ANSI_RE$1, ANSI_WIDTH],
916
- [CONTROL_RE$1, CONTROL_WIDTH],
917
- [TAB_RE$1, TAB_WIDTH],
918
- [EMOJI_RE$1, EMOJI_WIDTH],
1047
+ [LATIN_RE, REGULAR_WIDTH],
1048
+ [ANSI_RE, ANSI_WIDTH],
1049
+ [CONTROL_RE, CONTROL_WIDTH],
1050
+ [TAB_RE, TAB_WIDTH],
1051
+ [EMOJI_RE, EMOJI_WIDTH],
919
1052
  [CJKT_WIDE_RE, WIDE_WIDTH]
920
1053
  ];
921
1054
  let indexPrev = 0;
@@ -933,9 +1066,9 @@ const getStringTruncatedWidth$1 = (input, truncationOptions = {}, widthOptions =
933
1066
  if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
934
1067
  const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
935
1068
  lengthExtra = 0;
936
- for (const char of unmatched.replaceAll(MODIFIER_RE$1, "")) {
1069
+ for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
937
1070
  const codePoint = char.codePointAt(0) || 0;
938
- if (isFullWidth$1(codePoint)) widthExtra = FULL_WIDTH_WIDTH;
1071
+ if (isFullWidth(codePoint)) widthExtra = FULL_WIDTH_WIDTH;
939
1072
  else if (isWideNotCJKTNotEmoji(codePoint)) widthExtra = WIDE_WIDTH;
940
1073
  else widthExtra = REGULAR_WIDTH;
941
1074
  if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
@@ -953,7 +1086,7 @@ const getStringTruncatedWidth$1 = (input, truncationOptions = {}, widthOptions =
953
1086
  const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
954
1087
  BLOCK_RE.lastIndex = index;
955
1088
  if (BLOCK_RE.test(input)) {
956
- lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE$1 ? 1 : BLOCK_RE.lastIndex - index;
1089
+ lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
957
1090
  widthExtra = lengthExtra * BLOCK_WIDTH;
958
1091
  if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
959
1092
  if (width + widthExtra > LIMIT) {
@@ -976,13 +1109,13 @@ const getStringTruncatedWidth$1 = (input, truncationOptions = {}, widthOptions =
976
1109
  ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
977
1110
  };
978
1111
  };
979
- const NO_TRUNCATION$2 = {
1112
+ const NO_TRUNCATION = {
980
1113
  limit: Infinity,
981
1114
  ellipsis: "",
982
1115
  ellipsisWidth: 0
983
1116
  };
984
- const fastStringWidth$1 = (input, options = {}) => {
985
- return getStringTruncatedWidth$1(input, NO_TRUNCATION$2, options).width;
1117
+ const fastStringWidth = (input, options = {}) => {
1118
+ return getStringTruncatedWidth(input, NO_TRUNCATION, options).width;
986
1119
  };
987
1120
  const ESC = "\x1B";
988
1121
  const CSI = "›";
@@ -1013,13 +1146,13 @@ const wrapWord = (rows, word, columns) => {
1013
1146
  let isInsideEscape = false;
1014
1147
  let isInsideLinkEscape = false;
1015
1148
  let lastRow = rows.at(-1);
1016
- let visible = lastRow === void 0 ? 0 : fastStringWidth$1(lastRow);
1149
+ let visible = lastRow === void 0 ? 0 : fastStringWidth(lastRow);
1017
1150
  let currentCharacter = characters.next();
1018
1151
  let nextCharacter = characters.next();
1019
1152
  let rawCharacterIndex = 0;
1020
1153
  while (!currentCharacter.done) {
1021
1154
  const character = currentCharacter.value;
1022
- const characterLength = fastStringWidth$1(character);
1155
+ const characterLength = fastStringWidth(character);
1023
1156
  if (visible + characterLength <= columns) rows[rows.length - 1] += character;
1024
1157
  else {
1025
1158
  rows.push(character);
@@ -1054,7 +1187,7 @@ const stringVisibleTrimSpacesRight = (string) => {
1054
1187
  const words = string.split(" ");
1055
1188
  let last = words.length;
1056
1189
  while (last) {
1057
- if (fastStringWidth$1(words[last - 1])) break;
1190
+ if (fastStringWidth(words[last - 1])) break;
1058
1191
  last--;
1059
1192
  }
1060
1193
  if (last === words.length) return string;
@@ -1075,7 +1208,7 @@ const exec = (string, columns, options = {}) => {
1075
1208
  const trimmed = row.trimStart();
1076
1209
  if (row.length !== trimmed.length) {
1077
1210
  rows[rows.length - 1] = trimmed;
1078
- rowLength = fastStringWidth$1(trimmed);
1211
+ rowLength = fastStringWidth(trimmed);
1079
1212
  }
1080
1213
  }
1081
1214
  if (index !== 0) {
@@ -1088,19 +1221,19 @@ const exec = (string, columns, options = {}) => {
1088
1221
  rowLength++;
1089
1222
  }
1090
1223
  }
1091
- const wordLength = fastStringWidth$1(word);
1224
+ const wordLength = fastStringWidth(word);
1092
1225
  if (options.hard && wordLength > columns) {
1093
1226
  const remainingColumns = columns - rowLength;
1094
1227
  const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
1095
1228
  if (Math.floor((wordLength - 1) / columns) < breaksStartingThisLine) rows.push("");
1096
1229
  wrapWord(rows, word, columns);
1097
- rowLength = fastStringWidth$1(rows.at(-1) ?? "");
1230
+ rowLength = fastStringWidth(rows.at(-1) ?? "");
1098
1231
  continue;
1099
1232
  }
1100
1233
  if (rowLength + wordLength > columns && rowLength && wordLength) {
1101
1234
  if (options.wordWrap === false && rowLength < columns) {
1102
1235
  wrapWord(rows, word, columns);
1103
- rowLength = fastStringWidth$1(rows.at(-1) ?? "");
1236
+ rowLength = fastStringWidth(rows.at(-1) ?? "");
1104
1237
  continue;
1105
1238
  }
1106
1239
  rows.push("");
@@ -1108,7 +1241,7 @@ const exec = (string, columns, options = {}) => {
1108
1241
  }
1109
1242
  if (rowLength + wordLength > columns && options.wordWrap === false) {
1110
1243
  wrapWord(rows, word, columns);
1111
- rowLength = fastStringWidth$1(rows.at(-1) ?? "");
1244
+ rowLength = fastStringWidth(rows.at(-1) ?? "");
1112
1245
  continue;
1113
1246
  }
1114
1247
  rows[rows.length - 1] += word;
@@ -1147,12 +1280,96 @@ const CRLF_OR_LF = /\r?\n/;
1147
1280
  function wrapAnsi(string, columns, options) {
1148
1281
  return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
1149
1282
  }
1150
- const trimLines = (groups, initialLineCount, startIndex, endIndex, maxLines) => {
1283
+ function isUnicodeSupported() {
1284
+ if (process$1.platform !== "win32") return process$1.env.TERM !== "linux";
1285
+ return Boolean(process$1.env.CI) || Boolean(process$1.env.WT_SESSION) || Boolean(process$1.env.TERMINUS_SUBLIME) || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
1286
+ }
1287
+ updateSettings({ withGuide: false });
1288
+ /** Wrap using visible columns rather than the length of ANSI escape sequences. */
1289
+ const wrapTextWithPrefix = (output, text, prefix, startPrefix = prefix) => {
1290
+ return wrapAnsi(text, Math.max(1, getColumns(output ?? process.stdout) - Math.max(fastStringWidth$1(prefix), fastStringWidth$1(startPrefix))), {
1291
+ hard: true,
1292
+ trim: false
1293
+ }).split("\n").map((line, index) => `${index === 0 ? startPrefix : prefix}${line}`).join("\n");
1294
+ };
1295
+ const getGuide = (opts) => opts?.withGuide ?? settings.withGuide;
1296
+ const promptTitle = (message, state, opts) => {
1297
+ if (!message.trim()) return "";
1298
+ const hasGuide = getGuide(opts);
1299
+ return `${hasGuide ? `${import_picocolors.default.gray(S_BAR)}\n` : ""}${wrapTextWithPrefix(opts.output, message, hasGuide ? `${symbolBar(state)} ` : " ", `${symbol(state)} `)}\n`;
1300
+ };
1301
+ const optionText = (output, marker, label, format, suffix = "") => {
1302
+ const continuation = " ".repeat(fastStringWidth$1(marker));
1303
+ const width = Math.max(1, getColumns(output ?? process.stdout) - 2 - fastStringWidth$1(marker));
1304
+ const [first, ...rest] = label.split("\n");
1305
+ return wrapAnsi([format(first) + suffix, ...rest.map(format)].join("\n"), width, {
1306
+ hard: true,
1307
+ trim: false
1308
+ }).split("\n").map((line, index) => `${index === 0 ? marker : continuation}${line}`).join("\n");
1309
+ };
1310
+ const SELECT_INSTRUCTIONS = ["↑/↓ navigate", "Enter confirm"];
1311
+ const MULTISELECT_INSTRUCTIONS = [
1312
+ "↑/↓ navigate",
1313
+ "Space select",
1314
+ "Enter confirm"
1315
+ ];
1316
+ const formatInstructionFooter = (instructions, hasGuide, output) => wrapTextWithPrefix(output, import_picocolors.default.dim(instructions.join(" · ")), hasGuide ? `${import_picocolors.default.blue(S_BAR)} ` : " ").split("\n");
1317
+ const unicode = isUnicodeSupported();
1318
+ const isCI = () => process.env.CI === "true";
1319
+ const isTTY = (output) => {
1320
+ return output.isTTY === true;
1321
+ };
1322
+ const unicodeOr = (c, fallback) => unicode ? c : fallback;
1323
+ const S_POINTER_ACTIVE = unicodeOr("›", ">");
1324
+ const S_STEP_ACTIVE = S_POINTER_ACTIVE;
1325
+ const S_STEP_CANCEL = unicodeOr("■", "x");
1326
+ const S_STEP_ERROR = unicodeOr("▲", "x");
1327
+ const S_STEP_SUBMIT = unicodeOr("◇", "o");
1328
+ const S_BAR_START = unicodeOr("┌", "T");
1329
+ const S_BAR = unicodeOr("│", "|");
1330
+ const S_BAR_END = unicodeOr("└", "—");
1331
+ const S_CHECKBOX_ACTIVE = unicodeOr("◻", "[•]");
1332
+ const S_CHECKBOX_SELECTED = unicodeOr("◼", "[+]");
1333
+ const S_CHECKBOX_INACTIVE = unicodeOr("◻", "[ ]");
1334
+ const S_INFO = unicodeOr("●", "•");
1335
+ const S_SUCCESS = unicodeOr("◆", "*");
1336
+ const S_WARN = unicodeOr("▲", "!");
1337
+ const S_ERROR = unicodeOr("■", "x");
1338
+ const completeColor = (value) => import_picocolors.default.gray(value);
1339
+ const symbol = (state) => {
1340
+ switch (state) {
1341
+ case "initial":
1342
+ case "active": return import_picocolors.default.blue(S_STEP_ACTIVE);
1343
+ case "cancel": return import_picocolors.default.red(S_STEP_CANCEL);
1344
+ case "error": return import_picocolors.default.yellow(S_STEP_ERROR);
1345
+ case "validating": return import_picocolors.default.dim(S_STEP_ACTIVE);
1346
+ case "submit": return completeColor(S_STEP_SUBMIT);
1347
+ default: return import_picocolors.default.blue(S_STEP_ACTIVE);
1348
+ }
1349
+ };
1350
+ const symbolBar = (state) => {
1351
+ switch (state) {
1352
+ case "initial":
1353
+ case "active": return import_picocolors.default.blue(S_BAR);
1354
+ case "cancel": return import_picocolors.default.red(S_BAR);
1355
+ case "error": return import_picocolors.default.yellow(S_BAR);
1356
+ case "validating": return import_picocolors.default.dim(S_BAR);
1357
+ case "submit": return completeColor(S_BAR);
1358
+ default: return import_picocolors.default.blue(S_BAR);
1359
+ }
1360
+ };
1361
+ const trimLines = (groups, initialLineCount, startIndex, endIndex, maxLines, fromEnd = false) => {
1151
1362
  let lineCount = initialLineCount;
1152
1363
  let removals = 0;
1153
- for (let i = startIndex; i < endIndex; i++) {
1364
+ if (fromEnd) for (let i = endIndex - 1; i >= startIndex; i--) {
1154
1365
  const group = groups[i];
1155
- lineCount = lineCount - group.length;
1366
+ if (group) lineCount -= group.length;
1367
+ removals++;
1368
+ if (lineCount <= maxLines) break;
1369
+ }
1370
+ else for (let i = startIndex; i < endIndex; i++) {
1371
+ const group = groups[i];
1372
+ if (group) lineCount -= group.length;
1156
1373
  removals++;
1157
1374
  if (lineCount <= maxLines) break;
1158
1375
  }
@@ -1161,23 +1378,41 @@ const trimLines = (groups, initialLineCount, startIndex, endIndex, maxLines) =>
1161
1378
  removals
1162
1379
  };
1163
1380
  };
1164
- const limitOptions = (params) => {
1165
- const { cursor, options, style } = params;
1166
- const output = params.output ?? process.stdout;
1381
+ /**
1382
+ * Trims an option list to what fits the terminal, while keeping the active
1383
+ * option (cursor) visible using a Clack style sliding window.
1384
+ *
1385
+ * @returns The lines to render.
1386
+ *
1387
+ * @see https://bomb.sh/docs/clack/packages/prompts/#limitoptions
1388
+ *
1389
+ * @example
1390
+ * ```ts
1391
+ * import { limitOptions } from '@voidzero-dev/vite-plus-prompts';
1392
+ * import color from 'picocolors';
1393
+ *
1394
+ * const options = ['apple', 'banana', 'cherry', 'date'];
1395
+ * const lines = limitOptions({
1396
+ * options,
1397
+ * cursor: 2,
1398
+ * maxItems: 8,
1399
+ * style: (opt, active) =>
1400
+ * active ? color.blue(opt) : color.dim(opt),
1401
+ * });
1402
+ * ```
1403
+ */
1404
+ const limitOptions = ({ cursor, options, style, output = process.stdout, maxItems = Number.POSITIVE_INFINITY, columnPadding = 0, rowPadding = 4 }) => {
1167
1405
  const columns = getColumns(output);
1168
- const columnPadding = params.columnPadding ?? 0;
1169
- const rowPadding = params.rowPadding ?? 4;
1170
- const maxWidth = columns - columnPadding;
1406
+ const maxWidth = Math.max(1, columns - columnPadding);
1171
1407
  const rows = getRows(output);
1172
1408
  const overflowFormat = import_picocolors.default.dim("...");
1173
- const paramMaxItems = params.maxItems ?? Number.POSITIVE_INFINITY;
1174
1409
  const outputMaxItems = Math.max(rows - rowPadding, 0);
1175
- const maxItems = Math.max(Math.min(paramMaxItems, outputMaxItems), 5);
1410
+ const computedMaxItems = Math.max(Math.min(maxItems, outputMaxItems), 5);
1176
1411
  let slidingWindowLocation = 0;
1177
- if (cursor >= maxItems - 3) slidingWindowLocation = Math.max(Math.min(cursor - maxItems + 3, options.length - maxItems), 0);
1178
- let shouldRenderTopEllipsis = maxItems < options.length && slidingWindowLocation > 0;
1179
- let shouldRenderBottomEllipsis = maxItems < options.length && slidingWindowLocation + maxItems < options.length;
1180
- const slidingWindowLocationEnd = Math.min(slidingWindowLocation + maxItems, options.length);
1412
+ if (cursor >= computedMaxItems - 3) slidingWindowLocation = Math.max(Math.min(cursor - computedMaxItems + 3, options.length - computedMaxItems), 0);
1413
+ let shouldRenderTopEllipsis = computedMaxItems < options.length && slidingWindowLocation > 0;
1414
+ let shouldRenderBottomEllipsis = computedMaxItems < options.length && slidingWindowLocation + computedMaxItems < options.length;
1415
+ const slidingWindowLocationEnd = Math.min(slidingWindowLocation + computedMaxItems, options.length);
1181
1416
  const lineGroups = [];
1182
1417
  let lineCount = 0;
1183
1418
  if (shouldRenderTopEllipsis) lineCount++;
@@ -1185,7 +1420,8 @@ const limitOptions = (params) => {
1185
1420
  const slidingWindowLocationWithEllipsis = slidingWindowLocation + (shouldRenderTopEllipsis ? 1 : 0);
1186
1421
  const slidingWindowLocationEndWithEllipsis = slidingWindowLocationEnd - (shouldRenderBottomEllipsis ? 1 : 0);
1187
1422
  for (let i = slidingWindowLocationWithEllipsis; i < slidingWindowLocationEndWithEllipsis; i++) {
1188
- const wrappedLines = wrapAnsi(style(options[i], i === cursor), maxWidth, {
1423
+ const option = options[i];
1424
+ const wrappedLines = wrapAnsi(option === void 0 ? "" : style(option, i === cursor), maxWidth, {
1189
1425
  hard: true,
1190
1426
  trim: false
1191
1427
  }).split("\n");
@@ -1197,13 +1433,22 @@ const limitOptions = (params) => {
1197
1433
  let followingRemovals = 0;
1198
1434
  let newLineCount = lineCount;
1199
1435
  const cursorGroupIndex = cursor - slidingWindowLocationWithEllipsis;
1200
- const trimLinesLocal = (startIndex, endIndex) => trimLines(lineGroups, newLineCount, startIndex, endIndex, outputMaxItems);
1436
+ let adjustedMax = outputMaxItems;
1437
+ const trimPreceding = () => trimLines(lineGroups, newLineCount, 0, cursorGroupIndex, adjustedMax);
1438
+ const trimFollowing = () => trimLines(lineGroups, newLineCount, cursorGroupIndex + 1, lineGroups.length, adjustedMax, true);
1201
1439
  if (shouldRenderTopEllipsis) {
1202
- ({lineCount: newLineCount, removals: precedingRemovals} = trimLinesLocal(0, cursorGroupIndex));
1203
- if (newLineCount > outputMaxItems) ({lineCount: newLineCount, removals: followingRemovals} = trimLinesLocal(cursorGroupIndex + 1, lineGroups.length));
1440
+ ({lineCount: newLineCount, removals: precedingRemovals} = trimPreceding());
1441
+ if (newLineCount > adjustedMax) {
1442
+ if (!shouldRenderBottomEllipsis) adjustedMax -= 1;
1443
+ ({lineCount: newLineCount, removals: followingRemovals} = trimFollowing());
1444
+ }
1204
1445
  } else {
1205
- ({lineCount: newLineCount, removals: followingRemovals} = trimLinesLocal(cursorGroupIndex + 1, lineGroups.length));
1206
- if (newLineCount > outputMaxItems) ({lineCount: newLineCount, removals: precedingRemovals} = trimLinesLocal(0, cursorGroupIndex));
1446
+ if (!shouldRenderBottomEllipsis) adjustedMax -= 1;
1447
+ ({lineCount: newLineCount, removals: followingRemovals} = trimFollowing());
1448
+ if (newLineCount > adjustedMax) {
1449
+ adjustedMax -= 1;
1450
+ ({lineCount: newLineCount, removals: precedingRemovals} = trimPreceding());
1451
+ }
1207
1452
  }
1208
1453
  if (precedingRemovals > 0) {
1209
1454
  shouldRenderTopEllipsis = true;
@@ -1220,6 +1465,7 @@ const limitOptions = (params) => {
1220
1465
  if (shouldRenderBottomEllipsis) result.push(overflowFormat);
1221
1466
  return result;
1222
1467
  };
1468
+ import_picocolors.default.gray;
1223
1469
  /**
1224
1470
  * Render-milestone markers for the PTY snapshot suite
1225
1471
  * (crates/vp_cli_snapshots): invisible window-title updates the runner
@@ -1228,13 +1474,13 @@ const limitOptions = (params) => {
1228
1474
  * piped output never see these markers as content (they only update the
1229
1475
  * window title, which the runner's PTY captures).
1230
1476
  *
1231
- * Protocol (shared with vite-task's `pty_terminal_test_client` crate):
1232
- * `OSC 2 ; pty-terminal-test:<32-hex-id>:<base64url(name)> ST`. The runner
1477
+ * Protocol (shared with vite-task's `vt_pty_terminal_test_client` crate):
1478
+ * `OSC 2 ; vt-pty-terminal-test:<32-hex-id>:<base64url(name)> ST`. The runner
1233
1479
  * decodes the title with `decode_milestone_title`, ignoring ordinary title
1234
1480
  * updates. A fresh random id per emission keeps repeated milestones with the
1235
1481
  * same name observable as distinct title changes through Windows ConPTY.
1236
1482
  */
1237
- const MILESTONE_TITLE_MARKER = "pty-terminal-test:";
1483
+ const MILESTONE_TITLE_MARKER = "vt-pty-terminal-test:";
1238
1484
  const OSC2_OPEN = "\x1B]2;";
1239
1485
  const ST = "\x1B\\";
1240
1486
  const MILESTONES_ENABLED = process.env.VP_EMIT_MILESTONES === "1";
@@ -1266,12 +1512,13 @@ const confirm = (opts) => {
1266
1512
  inactive,
1267
1513
  signal: opts.signal,
1268
1514
  input: opts.input,
1515
+ accessible: opts.accessible,
1269
1516
  output: opts.output,
1270
1517
  initialValue: opts.initialValue ?? true,
1271
1518
  render() {
1272
- const hasGuide = opts.withGuide ?? false;
1519
+ const hasGuide = getGuide(opts);
1273
1520
  const nestedPrefix = " ";
1274
- const title = `${hasGuide ? `${import_picocolors.default.gray(S_BAR)}\n` : ""}${symbol(this.state)} ${opts.message}\n`;
1521
+ const title = promptTitle(opts.message, this.state, opts);
1275
1522
  const value = this.value ? active : inactive;
1276
1523
  switch (this.state) {
1277
1524
  case "submit": return `${title}${hasGuide ? `${import_picocolors.default.gray(S_BAR)} ` : nestedPrefix}${import_picocolors.default.dim(value)}\n${promptMilestone("confirm", opts.testId, "submit")}`;
@@ -1279,26 +1526,27 @@ const confirm = (opts) => {
1279
1526
  default: {
1280
1527
  const defaultPrefix = hasGuide ? `${import_picocolors.default.blue(S_BAR)} ` : nestedPrefix;
1281
1528
  const defaultPrefixEnd = hasGuide ? import_picocolors.default.blue(S_BAR_END) : "";
1282
- return `${title}${defaultPrefix}${this.value ? `${import_picocolors.default.blue(S_POINTER_ACTIVE)} ${import_picocolors.default.bold(active)}` : `${import_picocolors.default.dim(" ")} ${import_picocolors.default.dim(active)}`}${opts.vertical ? hasGuide ? `\n${import_picocolors.default.blue(S_BAR)} ` : `\n${nestedPrefix}` : ` ${import_picocolors.default.dim("/")} `}${!this.value ? `${import_picocolors.default.blue(S_POINTER_ACTIVE)} ${import_picocolors.default.bold(inactive)}` : `${import_picocolors.default.dim(" ")} ${import_picocolors.default.dim(inactive)}`}\n${defaultPrefixEnd}\n${promptMilestone("confirm", opts.testId, this.value ? "yes" : "no")}`;
1529
+ return `${title}${defaultPrefix}${this.value ? `${import_picocolors.default.blue(S_POINTER_ACTIVE)} ${import_picocolors.default.bold(active)}` : `${import_picocolors.default.dim(" ")} ${import_picocolors.default.dim(active)}`}${opts.vertical ? hasGuide ? `\n${import_picocolors.default.blue(S_BAR)} ` : `\n${nestedPrefix}` : ` ${import_picocolors.default.dim("/")} `}${!this.value ? `${import_picocolors.default.blue(S_POINTER_ACTIVE)} ${import_picocolors.default.bold(inactive)}` : `${import_picocolors.default.dim(" ")} ${import_picocolors.default.dim(inactive)}`}${hasGuide ? `\n${defaultPrefixEnd}` : ""}\n${promptMilestone("confirm", opts.testId, this.value ? "yes" : "no")}`;
1283
1530
  }
1284
1531
  }
1285
1532
  }
1286
1533
  }).prompt();
1287
1534
  };
1288
1535
  const log = {
1289
- message: (message = [], { symbol = import_picocolors.default.gray(S_BAR), secondarySymbol = import_picocolors.default.gray(S_BAR), output = process.stdout, spacing = 1, withGuide } = {}) => {
1536
+ message: (message = [], { symbol, secondarySymbol = import_picocolors.default.gray(S_BAR), output = process.stdout, spacing = 0, withGuide } = {}) => {
1290
1537
  const parts = [];
1291
- const hasGuide = withGuide ?? false;
1538
+ const hasGuide = getGuide({ withGuide });
1292
1539
  const spacingString = !hasGuide ? "" : secondarySymbol;
1293
- const prefix = !hasGuide ? "" : `${symbol} `;
1294
- const secondaryPrefix = !hasGuide ? "" : `${secondarySymbol} `;
1540
+ const prefix = symbol ? `${symbol} ` : hasGuide ? `${secondarySymbol} ` : "";
1541
+ const marker = symbol ?? secondarySymbol;
1542
+ const secondaryPrefix = hasGuide ? `${secondarySymbol} ` : symbol ? " " : "";
1295
1543
  for (let i = 0; i < spacing; i++) parts.push(spacingString);
1296
1544
  const messageParts = Array.isArray(message) ? message : message.split("\n");
1297
1545
  if (messageParts.length > 0) {
1298
1546
  const [firstLine, ...lines] = messageParts;
1299
- if (firstLine.length > 0) parts.push(`${prefix}${firstLine}`);
1300
- else parts.push(hasGuide ? symbol : "");
1301
- for (const ln of lines) if (ln.length > 0) parts.push(`${secondaryPrefix}${ln}`);
1547
+ if (firstLine.length > 0) parts.push(wrapTextWithPrefix(output, firstLine, secondaryPrefix, prefix));
1548
+ else parts.push(hasGuide || symbol ? marker : "");
1549
+ for (const ln of lines) if (ln.length > 0) parts.push(wrapTextWithPrefix(output, ln, secondaryPrefix));
1302
1550
  else parts.push(hasGuide ? secondarySymbol : "");
1303
1551
  }
1304
1552
  output.write(`${parts.join("\n")}\n`);
@@ -1339,58 +1587,56 @@ const log = {
1339
1587
  }
1340
1588
  };
1341
1589
  const cancel = (message = "", opts) => {
1342
- (opts?.output ?? process.stdout).write(`${import_picocolors.default.red(message)}\n\n`);
1590
+ const output = opts?.output ?? process.stdout;
1591
+ const prefix = getGuide(opts) ? `${import_picocolors.default.gray(S_BAR_END)} ` : "";
1592
+ output.write(`${prefix}${import_picocolors.default.red(message)}\n\n`);
1343
1593
  };
1344
1594
  const intro = (title = "", opts) => {
1345
- (opts?.output ?? process.stdout).write(`${title}\n\n`);
1595
+ const output = opts?.output ?? process.stdout;
1596
+ const prefix = getGuide(opts) ? `${import_picocolors.default.gray(S_BAR_START)} ` : "";
1597
+ output.write(`${prefix}${title}\n\n`);
1346
1598
  };
1347
1599
  const outro = (message = "", opts) => {
1348
- (opts?.output ?? process.stdout).write(`${message}\n\n`);
1600
+ const output = opts?.output ?? process.stdout;
1601
+ const prefix = getGuide(opts) ? `${import_picocolors.default.gray(S_BAR)}\n${import_picocolors.default.gray(S_BAR_END)} ` : "";
1602
+ output.write(`${prefix}${message}\n\n`);
1349
1603
  };
1350
1604
  const computeLabel$1 = (label, format) => {
1351
1605
  return label.split("\n").map((line) => format(line)).join("\n");
1352
1606
  };
1353
- const withMarkerAndCheckbox = (marker, checkbox, checkboxWidth, label, format, firstLineSuffix = "") => {
1354
- const lines = label.split("\n");
1355
- const continuationPrefix = ` ${" ".repeat(checkboxWidth)} `;
1356
- if (lines.length === 1) return `${marker} ${checkbox} ${format(lines[0])}${firstLineSuffix}`;
1357
- const [firstLine, ...rest] = lines;
1358
- return [`${marker} ${checkbox} ${format(firstLine)}${firstLineSuffix}`, ...rest.map((line) => `${continuationPrefix}${format(line)}`)].join("\n");
1359
- };
1360
1607
  const multiselect = (opts) => {
1608
+ const withMarkerAndCheckbox = (marker, checkbox, _width, label, format, suffix = "") => optionText(opts.output, `${marker} ${checkbox} `, label, format, suffix);
1361
1609
  const opt = (option, state) => {
1362
1610
  const label = option.label ?? String(option.value);
1363
1611
  const hint = option.hint ? ` ${import_picocolors.default.gray(`(${option.hint})`)}` : "";
1364
1612
  if (state === "disabled") return withMarkerAndCheckbox(import_picocolors.default.gray(" "), import_picocolors.default.gray(S_CHECKBOX_INACTIVE), S_CHECKBOX_INACTIVE.length, label, (str) => import_picocolors.default.strikethrough(import_picocolors.default.gray(str)), option.hint ? ` ${import_picocolors.default.dim(`(${option.hint ?? "disabled"})`)}` : "");
1365
1613
  if (state === "active") return withMarkerAndCheckbox(import_picocolors.default.blue(S_POINTER_ACTIVE), import_picocolors.default.blue(S_CHECKBOX_ACTIVE), S_CHECKBOX_ACTIVE.length, label, (text) => import_picocolors.default.blue(import_picocolors.default.bold(text)), hint);
1366
- if (state === "selected") return withMarkerAndCheckbox(import_picocolors.default.dim(" "), import_picocolors.default.blue(S_CHECKBOX_SELECTED), S_CHECKBOX_SELECTED.length, label, import_picocolors.default.dim, hint);
1614
+ if (state === "selected") return withMarkerAndCheckbox(import_picocolors.default.dim(" "), import_picocolors.default.blue(S_CHECKBOX_SELECTED), S_CHECKBOX_SELECTED.length, label, import_picocolors.default.dim);
1367
1615
  if (state === "cancelled") return computeLabel$1(label, (text) => import_picocolors.default.strikethrough(import_picocolors.default.dim(text)));
1368
1616
  if (state === "active-selected") return withMarkerAndCheckbox(import_picocolors.default.blue(S_POINTER_ACTIVE), import_picocolors.default.blue(S_CHECKBOX_SELECTED), S_CHECKBOX_SELECTED.length, label, (text) => import_picocolors.default.blue(import_picocolors.default.bold(text)), hint);
1369
1617
  if (state === "submitted") return computeLabel$1(label, import_picocolors.default.dim);
1370
1618
  return withMarkerAndCheckbox(import_picocolors.default.dim(" "), import_picocolors.default.dim(S_CHECKBOX_INACTIVE), S_CHECKBOX_INACTIVE.length, label, import_picocolors.default.dim);
1371
1619
  };
1372
1620
  const required = opts.required ?? true;
1373
- const hint = " " + import_picocolors.default.reset(import_picocolors.default.dim(`Press ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" space ")))} to select, ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" enter ")))} to submit`));
1374
1621
  return new a({
1375
1622
  options: opts.options,
1376
1623
  signal: opts.signal,
1377
1624
  input: opts.input,
1625
+ accessible: opts.accessible,
1378
1626
  output: opts.output,
1379
1627
  initialValues: opts.initialValues,
1380
1628
  required,
1381
1629
  cursorAt: opts.cursorAt,
1382
1630
  validate(selected) {
1383
- if (required && (selected === void 0 || selected.length === 0)) return `Please select at least one option.\n${hint}`;
1631
+ if (required && (selected === void 0 || selected.length === 0)) return "Please select at least one option.";
1384
1632
  },
1385
1633
  render() {
1386
- const hasGuide = opts.withGuide ?? false;
1634
+ const hasGuide = getGuide(opts);
1387
1635
  const nestedPrefix = " ";
1388
- const formatMessageLines = (message) => {
1389
- return message.split("\n").map((line, index) => `${index === 0 ? `${symbol(this.state)} ` : nestedPrefix}${line}`).join("\n");
1390
- };
1391
- const wrappedMessage = hasGuide ? wrapTextWithPrefix(opts.output, opts.message, `${symbolBar(this.state)} `, `${symbol(this.state)} `) : formatMessageLines(opts.message);
1392
- const title = `${hasGuide ? `${import_picocolors.default.gray(S_BAR)}\n` : ""}${wrappedMessage}\n`;
1636
+ const title = promptTitle(opts.message, this.state, opts);
1393
1637
  const value = this.value ?? [];
1638
+ const instructions = opts.showInstructions === false ? [] : formatInstructionFooter(MULTISELECT_INSTRUCTIONS, hasGuide, opts.output);
1639
+ const hint = instructions.join("\n");
1394
1640
  const styleOption = (option, active) => {
1395
1641
  if (option.disabled) return opt(option, "disabled");
1396
1642
  const selected = value.includes(option.value);
@@ -1413,15 +1659,15 @@ const multiselect = (opts) => {
1413
1659
  }
1414
1660
  case "error": {
1415
1661
  const prefix = hasGuide ? `${import_picocolors.default.yellow(S_BAR)} ` : nestedPrefix;
1416
- const footer = hasGuide ? this.error.split("\n").map((ln, i) => i === 0 ? `${import_picocolors.default.yellow(S_BAR_END)} ${import_picocolors.default.yellow(ln)}` : ` ${ln}`).join("\n") : `${nestedPrefix}${import_picocolors.default.yellow(this.error)}`;
1662
+ const footer = wrapTextWithPrefix(opts.output, import_picocolors.default.yellow(this.error), hasGuide ? `${import_picocolors.default.yellow(S_BAR_END)} ` : nestedPrefix);
1417
1663
  const titleLineCount = title.split("\n").length;
1418
- const footerLineCount = footer.split("\n").length + 1;
1664
+ const footerLineCount = footer.split("\n").length + instructions.length + 1;
1419
1665
  return `${title}${prefix}${limitOptions({
1420
1666
  output: opts.output,
1421
1667
  options: this.options,
1422
1668
  cursor: this.cursor,
1423
1669
  maxItems: opts.maxItems,
1424
- columnPadding: prefix.length,
1670
+ columnPadding: 2,
1425
1671
  rowPadding: titleLineCount + footerLineCount,
1426
1672
  style: styleOption
1427
1673
  }).join(`\n${prefix}`)}\n${hint}\n${footer}\n`;
@@ -1429,22 +1675,22 @@ const multiselect = (opts) => {
1429
1675
  default: {
1430
1676
  const prefix = hasGuide ? `${import_picocolors.default.blue(S_BAR)} ` : nestedPrefix;
1431
1677
  const titleLineCount = title.split("\n").length;
1432
- const footerLineCount = hasGuide ? 2 : 1;
1678
+ const footerLineCount = instructions.length + (hasGuide ? 2 : 1);
1433
1679
  return `${title}${prefix}${limitOptions({
1434
1680
  output: opts.output,
1435
1681
  options: this.options,
1436
1682
  cursor: this.cursor,
1437
1683
  maxItems: opts.maxItems,
1438
- columnPadding: prefix.length,
1684
+ columnPadding: 2,
1439
1685
  rowPadding: titleLineCount + footerLineCount,
1440
1686
  style: styleOption
1441
- }).join(`\n${prefix}`)}\n${hint}\n${hasGuide ? import_picocolors.default.blue(S_BAR_END) : ""}\n`;
1687
+ }).join(`\n${prefix}`)}\n${hint}${hasGuide ? `\n${import_picocolors.default.blue(S_BAR_END)}` : ""}\n`;
1442
1688
  }
1443
1689
  }
1444
1690
  }
1445
1691
  }).prompt();
1446
1692
  };
1447
- const defaultStyleFn = import_picocolors.default.magenta;
1693
+ const defaultStyleFn = import_picocolors.default.blue;
1448
1694
  const removeTrailingDots = (msg) => {
1449
1695
  return msg.replace(/\.+$/, "");
1450
1696
  };
@@ -1465,7 +1711,7 @@ const spinner = ({ indicator = "dots", onCancel, output = process.stdout, cancel
1465
1711
  "O",
1466
1712
  "0"
1467
1713
  ], delay = unicode ? 80 : 120, signal, ...opts } = {}) => {
1468
- const isCI$1 = isCI();
1714
+ const isCI$1 = isCI() || !isTTY(output) || isAccessible(opts.accessible);
1469
1715
  let unblock;
1470
1716
  let loop;
1471
1717
  let isSpinnerActive = false;
@@ -1508,7 +1754,7 @@ const spinner = ({ indicator = "dots", onCancel, output = process.stdout, cancel
1508
1754
  };
1509
1755
  const clearPrevMessage = () => {
1510
1756
  if (_prevMessage === void 0) return;
1511
- if (isCI$1) output.write("\n");
1757
+ if (isCI$1) return;
1512
1758
  const prevLines = wrapAnsi(_prevMessage, columns, {
1513
1759
  hard: true,
1514
1760
  trim: false
@@ -1517,10 +1763,10 @@ const spinner = ({ indicator = "dots", onCancel, output = process.stdout, cancel
1517
1763
  output.write(import_src.cursor.to(0));
1518
1764
  output.write(import_src.erase.down());
1519
1765
  };
1520
- const hasGuide = opts.withGuide ?? false;
1766
+ const hasGuide = getGuide(opts);
1521
1767
  const startLoop = () => {
1522
1768
  isSpinnerActive = true;
1523
- unblock = block({ output });
1769
+ unblock = isCI$1 ? () => {} : block({ output });
1524
1770
  _origin = performance.now();
1525
1771
  _prevMessage = void 0;
1526
1772
  if (hasGuide) output.write(`${import_picocolors.default.gray(S_BAR)}\n`);
@@ -1528,49 +1774,53 @@ const spinner = ({ indicator = "dots", onCancel, output = process.stdout, cancel
1528
1774
  let indicatorTimer = 0;
1529
1775
  registerHooks();
1530
1776
  const renderFrame = () => {
1531
- if (isCI$1 && _message === _prevMessage) return;
1777
+ if (isCI$1 && _prevMessage !== void 0) return;
1532
1778
  clearPrevMessage();
1533
- _prevMessage = _message;
1534
- const frame = styleFn(frames[frameIndex]);
1779
+ const frame = styleFn(frames[frameIndex] ?? (unicode ? "◒" : "o"));
1535
1780
  let outputMessage;
1536
- if (isCI$1) outputMessage = `${frame} ${_message}...`;
1537
- else if (indicator === "timer") outputMessage = `${frame} ${_message} ${formatTimer(getElapsedMs())}`;
1781
+ if (isCI$1) outputMessage = `${frame} ${_message}...`;
1782
+ else if (indicator === "timer") outputMessage = `${frame} ${_message} ${formatTimer(getElapsedMs())}`;
1538
1783
  else {
1539
1784
  const loadingDots = ".".repeat(Math.floor(indicatorTimer)).slice(0, 3);
1540
- outputMessage = `${frame} ${_message}${loadingDots}`;
1785
+ outputMessage = `${frame} ${_message}${loadingDots}`;
1541
1786
  }
1542
1787
  const wrapped = wrapAnsi(outputMessage, columns, {
1543
1788
  hard: true,
1544
1789
  trim: false
1545
1790
  });
1546
- output.write(wrapped);
1791
+ output.write(isCI$1 ? `${wrapped}\n` : wrapped);
1792
+ _prevMessage = wrapped;
1547
1793
  frameIndex = frameIndex + 1 < frames.length ? frameIndex + 1 : 0;
1548
1794
  indicatorTimer = indicatorTimer < 4 ? indicatorTimer + .125 : 0;
1549
1795
  };
1550
1796
  renderFrame();
1551
- loop = setInterval(renderFrame, delay);
1797
+ if (!isCI$1) loop = setInterval(renderFrame, delay);
1798
+ if (signal?.aborted) signalEventHandler();
1552
1799
  };
1553
1800
  const start = (msg = "") => {
1801
+ if (isSpinnerActive) return;
1802
+ isCancelled = false;
1554
1803
  _elapsedMs = 0;
1555
1804
  _message = removeTrailingDots(msg);
1556
1805
  startLoop();
1557
1806
  };
1558
1807
  const _stop = (msg = "", code = 0, silent = false, preserveElapsed = false) => {
1559
1808
  if (!isSpinnerActive) return;
1809
+ const elapsedMs = getElapsedMs();
1560
1810
  isSpinnerActive = false;
1811
+ isCancelled = code === 1;
1561
1812
  clearInterval(loop);
1562
1813
  clearPrevMessage();
1563
- const elapsedMs = getElapsedMs();
1564
1814
  const step = code === 0 ? completeColor(S_STEP_SUBMIT) : code === 1 ? import_picocolors.default.red(S_STEP_CANCEL) : import_picocolors.default.red(S_STEP_ERROR);
1565
1815
  _message = msg ?? _message;
1566
1816
  if (!silent) {
1567
- if (indicator === "timer") output.write(`${step} ${_message} ${formatTimer(elapsedMs)}\n\n`);
1568
- else output.write(`${step} ${_message}\n\n`);
1817
+ if (indicator === "timer") output.write(`${step} ${_message} ${formatTimer(elapsedMs)}\n`);
1818
+ else output.write(`${step} ${_message}\n`);
1569
1819
  }
1570
1820
  if (!preserveElapsed) _elapsedMs = 0;
1571
1821
  _prevMessage = void 0;
1572
1822
  clearHooks();
1573
- unblock();
1823
+ unblock?.();
1574
1824
  };
1575
1825
  const pause = () => {
1576
1826
  if (!isSpinnerActive) return;
@@ -1607,14 +1857,10 @@ const computeLabel = (label, format) => {
1607
1857
  if (!label.includes("\n")) return format(label);
1608
1858
  return label.split("\n").map((line) => format(line)).join("\n");
1609
1859
  };
1610
- const withMarker = (marker, label, format, firstLineSuffix = "") => {
1611
- const lines = label.split("\n");
1612
- if (lines.length === 1) return `${marker} ${format(lines[0])}${firstLineSuffix}`;
1613
- const [firstLine, ...rest] = lines;
1614
- return [`${marker} ${format(firstLine)}${firstLineSuffix}`, ...rest.map((line) => ` ${format(line)}`)].join("\n");
1615
- };
1616
1860
  const select = (opts) => {
1861
+ const withMarker = (marker, label, format, suffix = "") => optionText(opts.output, `${marker} `, label, format, suffix);
1617
1862
  const opt = (option, state) => {
1863
+ if (!option) return "";
1618
1864
  const label = option.label ?? String(option.value);
1619
1865
  const hint = option.hint ? `: ${import_picocolors.default.gray(option.hint)}` : "";
1620
1866
  switch (state) {
@@ -1622,24 +1868,20 @@ const select = (opts) => {
1622
1868
  case "selected": return computeLabel(label, import_picocolors.default.dim);
1623
1869
  case "active": return withMarker(import_picocolors.default.blue(S_POINTER_ACTIVE), label, (text) => import_picocolors.default.blue(import_picocolors.default.bold(text)), hint);
1624
1870
  case "cancelled": return computeLabel(label, (str) => import_picocolors.default.strikethrough(import_picocolors.default.dim(str)));
1625
- default: return withMarker(import_picocolors.default.dim(" "), label, (text) => text, hint);
1871
+ default: return withMarker(import_picocolors.default.dim(" "), label, import_picocolors.default.dim);
1626
1872
  }
1627
1873
  };
1628
1874
  return new n$1({
1629
1875
  options: opts.options,
1630
1876
  signal: opts.signal,
1631
1877
  input: opts.input,
1878
+ accessible: opts.accessible,
1632
1879
  output: opts.output,
1633
1880
  initialValue: opts.initialValue,
1634
1881
  render() {
1635
- const hasGuide = opts.withGuide ?? false;
1882
+ const hasGuide = getGuide(opts);
1636
1883
  const nestedPrefix = " ";
1637
- const formatMessageLines = (message) => {
1638
- return message.split("\n").map((line, index) => `${index === 0 ? `${symbol(this.state)} ` : nestedPrefix}${line}`).join("\n");
1639
- };
1640
- const hasMessage = opts.message.trim().length > 0;
1641
- const messageLines = !hasMessage ? "" : hasGuide ? wrapTextWithPrefix(opts.output, opts.message, `${symbolBar(this.state)} `, `${symbol(this.state)} `) : formatMessageLines(opts.message);
1642
- const title = hasMessage ? `${hasGuide ? `${import_picocolors.default.gray(S_BAR)}\n` : ""}${messageLines}\n` : "";
1884
+ const title = promptTitle(opts.message, this.state, opts);
1643
1885
  switch (this.state) {
1644
1886
  case "submit": {
1645
1887
  const submitPrefix = hasGuide ? `${import_picocolors.default.gray(S_BAR)} ` : nestedPrefix;
@@ -1651,15 +1893,17 @@ const select = (opts) => {
1651
1893
  }
1652
1894
  default: {
1653
1895
  const prefix = hasGuide ? `${import_picocolors.default.blue(S_BAR)} ` : nestedPrefix;
1654
- const prefixEnd = hasGuide ? import_picocolors.default.blue(S_BAR_END) : "";
1896
+ const footer = opts.showInstructions === false ? [] : formatInstructionFooter(SELECT_INSTRUCTIONS, hasGuide, opts.output);
1897
+ if (hasGuide) footer.push(import_picocolors.default.blue(S_BAR_END));
1898
+ const prefixEnd = footer.join("\n");
1655
1899
  const titleLineCount = title ? title.split("\n").length : 0;
1656
- const footerLineCount = hasGuide ? 2 : 1;
1900
+ const footerLineCount = footer.length + 1;
1657
1901
  return `${title}${prefix}${limitOptions({
1658
1902
  output: opts.output,
1659
1903
  cursor: this.cursor,
1660
1904
  options: this.options,
1661
1905
  maxItems: opts.maxItems,
1662
- columnPadding: prefix.length,
1906
+ columnPadding: 2,
1663
1907
  rowPadding: titleLineCount + footerLineCount,
1664
1908
  style: (item, active) => opt(item, item.disabled ? "disabled" : active ? "active" : "inactive")
1665
1909
  }).join(`\n${prefix}`)}\n${prefixEnd}\n${promptMilestone("select", opts.testId, String(this.cursor))}`;
@@ -1677,19 +1921,23 @@ const text = (opts) => {
1677
1921
  output: opts.output,
1678
1922
  signal: opts.signal,
1679
1923
  input: opts.input,
1924
+ accessible: opts.accessible,
1680
1925
  render() {
1681
- const hasGuide = opts?.withGuide ?? false;
1926
+ const hasGuide = getGuide(opts);
1682
1927
  const nestedPrefix = " ";
1683
- const title = `${hasGuide ? `${import_picocolors.default.gray(S_BAR)}\n` : ""}${symbol(this.state)} ${opts.message}\n`;
1928
+ const title = promptTitle(opts.message, this.state, opts);
1684
1929
  const placeholder = opts.placeholder ? import_picocolors.default.inverse(opts.placeholder[0]) + import_picocolors.default.dim(opts.placeholder.slice(1)) : import_picocolors.default.inverse(import_picocolors.default.hidden("_"));
1685
1930
  const userInput = !this.userInput ? placeholder : this.userInputWithCursor;
1686
1931
  const value = this.value ?? "";
1687
1932
  switch (this.state) {
1933
+ case "validating": {
1934
+ const prefix = hasGuide ? `${import_picocolors.default.blue(S_BAR)} ` : nestedPrefix;
1935
+ return `${title}${prefix}${import_picocolors.default.dim(value)}\n${prefix}${import_picocolors.default.dim("Validating…")}\n`;
1936
+ }
1688
1937
  case "error": {
1689
- const errorText = this.error ? ` ${import_picocolors.default.yellow(this.error)}` : "";
1938
+ const errorText = this.error ? wrapTextWithPrefix(opts.output, import_picocolors.default.yellow(this.error), hasGuide ? `${import_picocolors.default.yellow(S_BAR_END)} ` : nestedPrefix) : "";
1690
1939
  const errorPrefix = hasGuide ? `${import_picocolors.default.yellow(S_BAR)} ` : nestedPrefix;
1691
- const errorPrefixEnd = hasGuide ? import_picocolors.default.yellow(S_BAR_END) : "";
1692
- return `${title.trim()}\n${errorPrefix}${userInput}\n${errorPrefixEnd}${errorText}\n${promptMilestone("text", opts.testId, "error")}`;
1940
+ return `${title.trim()}\n${errorPrefix}${userInput}\n${errorText}\n${promptMilestone("text", opts.testId, "error")}`;
1693
1941
  }
1694
1942
  case "submit": {
1695
1943
  const valueText = value ? import_picocolors.default.dim(value) : "";
@@ -1700,12 +1948,50 @@ const text = (opts) => {
1700
1948
  const cancelPrefix = hasGuide ? `${import_picocolors.default.gray(S_BAR)} ` : nestedPrefix;
1701
1949
  return `${title}${cancelPrefix}${valueText}${value.trim() ? `\n${cancelPrefix}` : ""}\n${promptMilestone("text", opts.testId, "cancel")}`;
1702
1950
  }
1703
- default: return `${title}${hasGuide ? `${import_picocolors.default.blue(S_BAR)} ` : nestedPrefix}${userInput}\n${hasGuide ? import_picocolors.default.blue(S_BAR_END) : ""}\n${promptMilestone("text", opts.testId, this.value ?? "")}`;
1951
+ default: {
1952
+ const defaultPrefix = hasGuide ? `${import_picocolors.default.blue(S_BAR)} ` : nestedPrefix;
1953
+ const defaultPrefixEnd = hasGuide ? import_picocolors.default.blue(S_BAR_END) : "";
1954
+ return `${title}${defaultPrefix}${userInput}${hasGuide ? `\n${defaultPrefixEnd}` : ""}\n${promptMilestone("text", opts.testId, this.value ?? "")}`;
1955
+ }
1704
1956
  }
1705
1957
  }
1706
1958
  }).prompt();
1707
1959
  };
1708
1960
  //#endregion
1961
+ //#region ../../node_modules/.pnpm/verkit@0.5.0/node_modules/verkit/dist/version-Co1j9Tpq.js
1962
+ const COERCE_EXACT = safeRegex(COERCE);
1963
+ const COERCE_FULL_EXACT = safeRegex(COERCE_FULL);
1964
+ safeRegex(`^${PRERELEASE}$`);
1965
+ safeRegex(`^${PRERELEASE_LOOSE}$`);
1966
+ function normalize$1(version, options = {}) {
1967
+ const parsed = tryParse(version, options);
1968
+ return parsed ? formatComparableVersion(parsed) : null;
1969
+ }
1970
+ function coerce(value, options = {}) {
1971
+ if (typeof value === "object") return value;
1972
+ const input = typeof value === "number" ? String(value) : value;
1973
+ let match = null;
1974
+ if (options.rtl) {
1975
+ const source = options.includePrerelease ? COERCE_FULL : COERCE;
1976
+ const expression = safeRegex(source, "g");
1977
+ let next;
1978
+ while ((next = expression.exec(input)) && (!match || match.index + match[0].length !== input.length)) {
1979
+ if (!match || next.index + next[0].length !== match.index + match[0].length) match = next;
1980
+ expression.lastIndex = next.index + next[1].length + next[2].length;
1981
+ }
1982
+ } else match = (options.includePrerelease ? COERCE_FULL_EXACT : COERCE_EXACT).exec(input);
1983
+ if (!match) return null;
1984
+ const major = match[2];
1985
+ const minor = match[3] || "0";
1986
+ const patch = match[4] || "0";
1987
+ const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : "";
1988
+ const build = options.includePrerelease && match[6] ? `+${match[6]}` : "";
1989
+ return tryParse(`${major}.${minor}.${patch}${prerelease}${build}`, options);
1990
+ }
1991
+ function getMajor(version, options = {}) {
1992
+ return parse(version, options).major;
1993
+ }
1994
+ //#endregion
1709
1995
  //#region src/types/package.ts
1710
1996
  const PackageManager = {
1711
1997
  pnpm: "pnpm",
@@ -1721,7 +2007,6 @@ const DependencyType = {
1721
2007
  };
1722
2008
  //#endregion
1723
2009
  //#region src/utils/spinner.ts
1724
- var import_semver = /* @__PURE__ */ __toESM(require_semver(), 1);
1725
2010
  function getSpinner(interactive) {
1726
2011
  if (interactive) return spinner();
1727
2012
  return {
@@ -2312,9 +2597,9 @@ function reconcilePreviewBridgeRegistry(projectRoot, version = process.env.VP_VE
2312
2597
  */
2313
2598
  function shouldIgnoreScriptsForAutoInstall(packageManager, packageManagerVersion) {
2314
2599
  if (packageManager !== PackageManager.pnpm) return false;
2315
- const coerced = packageManagerVersion ? import_semver.default.coerce(packageManagerVersion)?.version : void 0;
2600
+ const coerced = packageManagerVersion ? coerce(packageManagerVersion) : void 0;
2316
2601
  if (!coerced) return false;
2317
- return import_semver.default.gte(coerced, "11.0.0");
2602
+ return isGreaterThanOrEqual(coerced, "11.0.0");
2318
2603
  }
2319
2604
  function cancelAndExit(message = "Operation cancelled", exitCode = 0) {
2320
2605
  cancel(message);
@@ -2342,12 +2627,13 @@ async function selectPackageManager(interactive, silent = false) {
2342
2627
  return PackageManager.pnpm;
2343
2628
  }
2344
2629
  }
2345
- async function downloadPackageManager$1(packageManager, version, interactive, silent = false) {
2630
+ async function downloadPackageManager$1(packageManager, version, interactive, silent = false, cwd) {
2346
2631
  const spinner = silent ? getSilentSpinner() : getSpinner(interactive);
2347
2632
  spinner.start(`${packageManager}@${version} installing...`);
2348
2633
  const downloadResult = await downloadPackageManager({
2349
2634
  name: packageManager,
2350
- version
2635
+ version,
2636
+ cwd
2351
2637
  });
2352
2638
  spinner.stop(`${packageManager}@${downloadResult.version} installed`);
2353
2639
  return downloadResult;
@@ -2488,4 +2774,4 @@ function defaultInteractive() {
2488
2774
  return !process.env.CI && process.stdin.isTTY;
2489
2775
  }
2490
2776
  //#endregion
2491
- export { multiselect as C, text as D, spinner as E, require_picocolors as O, log as S, select as T, getSpinner as _, resolveGitInit as a, confirm as b, selectPackageManager as c, readYamlFile as d, scalarString as f, getSilentSpinner as g, resolveApproveBuildTargets as h, promptGitHooks as i, isCancel as k, upgradeYarn as l, detectGatedBuilds as m, defaultInteractive as n, runViteFmt as o, approveBuilds as p, downloadPackageManager$1 as r, runViteInstall as s, cancelAndExit as t, editYamlFile as u, DependencyType as v, outro as w, intro as x, PackageManager as y };
2777
+ export { text as A, confirm as C, outro as D, multiselect as E, isCancel as M, select as O, normalize$1 as S, log as T, getSpinner as _, resolveGitInit as a, coerce as b, selectPackageManager as c, readYamlFile as d, scalarString as f, getSilentSpinner as g, resolveApproveBuildTargets as h, promptGitHooks as i, require_picocolors as j, spinner as k, upgradeYarn as l, detectGatedBuilds as m, defaultInteractive as n, runViteFmt as o, approveBuilds as p, downloadPackageManager$1 as r, runViteInstall as s, cancelAndExit as t, editYamlFile as u, DependencyType as v, intro as w, getMajor as x, PackageManager as y };