@onedotmint/siftpath 0.0.0-stage → 2.0.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 (58) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +165 -2
  3. package/THIRD_PARTY_NOTICES.md +26 -0
  4. package/dist/cli.d.ts +2 -0
  5. package/dist/cli.js +116 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/client.d.ts +144 -0
  8. package/dist/client.js +130 -0
  9. package/dist/client.js.map +1 -0
  10. package/dist/config.d.ts +107 -0
  11. package/dist/config.js +127 -0
  12. package/dist/config.js.map +1 -0
  13. package/dist/defaults.d.ts +38 -0
  14. package/dist/defaults.js +31 -0
  15. package/dist/defaults.js.map +1 -0
  16. package/dist/diagnostics.d.ts +158 -0
  17. package/dist/diagnostics.js +202 -0
  18. package/dist/diagnostics.js.map +1 -0
  19. package/dist/errors.d.ts +15 -0
  20. package/dist/errors.js +16 -0
  21. package/dist/errors.js.map +1 -0
  22. package/dist/index.d.ts +8 -0
  23. package/dist/index.js +5 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/inputs.d.ts +25 -0
  26. package/dist/inputs.js +27 -0
  27. package/dist/inputs.js.map +1 -0
  28. package/dist/mcp/stdio.d.ts +2 -0
  29. package/dist/mcp/stdio.js +43 -0
  30. package/dist/mcp/stdio.js.map +1 -0
  31. package/dist/output.d.ts +23 -0
  32. package/dist/output.js +118 -0
  33. package/dist/output.js.map +1 -0
  34. package/dist/router.d.ts +20 -0
  35. package/dist/router.js +85 -0
  36. package/dist/router.js.map +1 -0
  37. package/dist/setup-ui.d.ts +8 -0
  38. package/dist/setup-ui.js +3032 -0
  39. package/dist/setup-ui.js.map +1 -0
  40. package/dist/setup.d.ts +2 -0
  41. package/dist/setup.js +50 -0
  42. package/dist/setup.js.map +1 -0
  43. package/dist/tools.d.ts +35 -0
  44. package/dist/tools.js +17 -0
  45. package/dist/tools.js.map +1 -0
  46. package/dist/version.d.ts +1 -0
  47. package/dist/version.js +4 -0
  48. package/dist/version.js.map +1 -0
  49. package/docs/ARCHITECTURE.md +33 -0
  50. package/docs/CONFIGURATION.md +127 -0
  51. package/docs/DIAGNOSTICS.md +109 -0
  52. package/docs/MIGRATION.md +13 -0
  53. package/docs/PROVIDERS.md +43 -0
  54. package/docs/SECURITY.md +15 -0
  55. package/docs/TESTING.md +138 -0
  56. package/examples/anonymous.json +36 -0
  57. package/extensions/siftpath.mjs +32 -0
  58. package/package.json +60 -4
@@ -0,0 +1,3032 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+
31
+ // node_modules/sisteransi/src/index.js
32
+ var require_src = __commonJS({
33
+ "node_modules/sisteransi/src/index.js"(exports, module) {
34
+ "use strict";
35
+ var ESC2 = "\x1B";
36
+ var CSI2 = `${ESC2}[`;
37
+ var beep = "\x07";
38
+ var cursor3 = {
39
+ to(x2, y2) {
40
+ if (!y2) return `${CSI2}${x2 + 1}G`;
41
+ return `${CSI2}${y2 + 1};${x2 + 1}H`;
42
+ },
43
+ move(x2, y2) {
44
+ let ret = "";
45
+ if (x2 < 0) ret += `${CSI2}${-x2}D`;
46
+ else if (x2 > 0) ret += `${CSI2}${x2}C`;
47
+ if (y2 < 0) ret += `${CSI2}${-y2}A`;
48
+ else if (y2 > 0) ret += `${CSI2}${y2}B`;
49
+ return ret;
50
+ },
51
+ up: (count = 1) => `${CSI2}${count}A`,
52
+ down: (count = 1) => `${CSI2}${count}B`,
53
+ forward: (count = 1) => `${CSI2}${count}C`,
54
+ backward: (count = 1) => `${CSI2}${count}D`,
55
+ nextLine: (count = 1) => `${CSI2}E`.repeat(count),
56
+ prevLine: (count = 1) => `${CSI2}F`.repeat(count),
57
+ left: `${CSI2}G`,
58
+ hide: `${CSI2}?25l`,
59
+ show: `${CSI2}?25h`,
60
+ save: `${ESC2}7`,
61
+ restore: `${ESC2}8`
62
+ };
63
+ var scroll = {
64
+ up: (count = 1) => `${CSI2}S`.repeat(count),
65
+ down: (count = 1) => `${CSI2}T`.repeat(count)
66
+ };
67
+ var erase3 = {
68
+ screen: `${CSI2}2J`,
69
+ up: (count = 1) => `${CSI2}1J`.repeat(count),
70
+ down: (count = 1) => `${CSI2}J`.repeat(count),
71
+ line: `${CSI2}2K`,
72
+ lineEnd: `${CSI2}K`,
73
+ lineStart: `${CSI2}1K`,
74
+ lines(count) {
75
+ let clear = "";
76
+ for (let i2 = 0; i2 < count; i2++)
77
+ clear += this.line + (i2 < count - 1 ? cursor3.up() : "");
78
+ if (count)
79
+ clear += cursor3.left;
80
+ return clear;
81
+ }
82
+ };
83
+ module.exports = { cursor: cursor3, scroll, erase: erase3, beep };
84
+ }
85
+ });
86
+
87
+ // node_modules/@clack/prompts/dist/index.mjs
88
+ var dist_exports = {};
89
+ __export(dist_exports, {
90
+ CANCEL_SYMBOL: () => CANCEL_SYMBOL,
91
+ MULTISELECT_INSTRUCTIONS: () => MULTISELECT_INSTRUCTIONS,
92
+ SELECT_INSTRUCTIONS: () => SELECT_INSTRUCTIONS,
93
+ S_BAR: () => S_BAR,
94
+ S_BAR_END: () => S_BAR_END,
95
+ S_BAR_END_RIGHT: () => S_BAR_END_RIGHT,
96
+ S_BAR_H: () => S_BAR_H,
97
+ S_BAR_START: () => S_BAR_START,
98
+ S_BAR_START_RIGHT: () => S_BAR_START_RIGHT,
99
+ S_CHECKBOX_ACTIVE: () => S_CHECKBOX_ACTIVE,
100
+ S_CHECKBOX_INACTIVE: () => S_CHECKBOX_INACTIVE,
101
+ S_CHECKBOX_SELECTED: () => S_CHECKBOX_SELECTED,
102
+ S_CONNECT_LEFT: () => S_CONNECT_LEFT,
103
+ S_CORNER_BOTTOM_LEFT: () => S_CORNER_BOTTOM_LEFT,
104
+ S_CORNER_BOTTOM_RIGHT: () => S_CORNER_BOTTOM_RIGHT,
105
+ S_CORNER_TOP_LEFT: () => S_CORNER_TOP_LEFT,
106
+ S_CORNER_TOP_RIGHT: () => S_CORNER_TOP_RIGHT,
107
+ S_ERROR: () => S_ERROR,
108
+ S_INFO: () => S_INFO,
109
+ S_PASSWORD_MASK: () => S_PASSWORD_MASK,
110
+ S_RADIO_ACTIVE: () => S_RADIO_ACTIVE,
111
+ S_RADIO_INACTIVE: () => S_RADIO_INACTIVE,
112
+ S_STEP_ACTIVE: () => S_STEP_ACTIVE,
113
+ S_STEP_CANCEL: () => S_STEP_CANCEL,
114
+ S_STEP_ERROR: () => S_STEP_ERROR,
115
+ S_STEP_SUBMIT: () => S_STEP_SUBMIT,
116
+ S_SUCCESS: () => S_SUCCESS,
117
+ S_WARN: () => S_WARN,
118
+ autocomplete: () => autocomplete,
119
+ autocompleteMultiselect: () => autocompleteMultiselect,
120
+ box: () => box,
121
+ cancel: () => cancel,
122
+ confirm: () => confirm,
123
+ date: () => date,
124
+ formatInstructionFooter: () => formatInstructionFooter,
125
+ group: () => group,
126
+ groupMultiselect: () => groupMultiselect,
127
+ intro: () => intro,
128
+ isCI: () => isCI,
129
+ isCancel: () => isCancel,
130
+ isTTY: () => isTTY,
131
+ limitOptions: () => limitOptions,
132
+ log: () => log,
133
+ multiline: () => multiline,
134
+ multiselect: () => multiselect,
135
+ note: () => note,
136
+ outro: () => outro,
137
+ password: () => password,
138
+ path: () => path,
139
+ progress: () => progress,
140
+ select: () => select,
141
+ selectKey: () => selectKey,
142
+ settings: () => settings,
143
+ spinner: () => spinner,
144
+ stream: () => stream,
145
+ symbol: () => symbol,
146
+ symbolBar: () => symbolBar,
147
+ taskLog: () => taskLog,
148
+ tasks: () => tasks,
149
+ text: () => text,
150
+ unicode: () => unicode,
151
+ unicodeOr: () => unicodeOr,
152
+ updateSettings: () => updateSettings
153
+ });
154
+
155
+ // node_modules/@clack/core/dist/index.mjs
156
+ import { styleText } from "node:util";
157
+ import { stdout, stdin } from "node:process";
158
+ import * as l from "node:readline";
159
+ import l__default from "node:readline";
160
+
161
+ // node_modules/fast-string-truncated-width/dist/utils.js
162
+ var getCodePointsLength = /* @__PURE__ */ (() => {
163
+ const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
164
+ return (input) => {
165
+ let surrogatePairsNr = 0;
166
+ SURROGATE_PAIR_RE.lastIndex = 0;
167
+ while (SURROGATE_PAIR_RE.test(input)) {
168
+ surrogatePairsNr += 1;
169
+ }
170
+ return input.length - surrogatePairsNr;
171
+ };
172
+ })();
173
+ var isFullWidth = (x2) => {
174
+ return x2 === 12288 || x2 >= 65281 && x2 <= 65376 || x2 >= 65504 && x2 <= 65510;
175
+ };
176
+ var isWideNotCJKTNotEmoji = (x2) => {
177
+ return x2 === 8987 || x2 === 9001 || x2 >= 12272 && x2 <= 12287 || x2 >= 12289 && x2 <= 12350 || x2 >= 12441 && x2 <= 12543 || x2 >= 12549 && x2 <= 12591 || x2 >= 12593 && x2 <= 12686 || x2 >= 12688 && x2 <= 12771 || x2 >= 12783 && x2 <= 12830 || x2 >= 12832 && x2 <= 12871 || x2 >= 12880 && x2 <= 19903 || x2 >= 65040 && x2 <= 65049 || x2 >= 65072 && x2 <= 65106 || x2 >= 65108 && x2 <= 65126 || x2 >= 65128 && x2 <= 65131 || x2 >= 127488 && x2 <= 127490 || x2 >= 127504 && x2 <= 127547 || x2 >= 127552 && x2 <= 127560 || x2 >= 131072 && x2 <= 196605 || x2 >= 196608 && x2 <= 262141;
178
+ };
179
+
180
+ // node_modules/fast-string-truncated-width/dist/index.js
181
+ var ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
182
+ var CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
183
+ var CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu;
184
+ var TAB_RE = /\t{1,1000}/y;
185
+ var EMOJI_RE = new RegExp("[\\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?))*", "yu");
186
+ var LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
187
+ var MODIFIER_RE = new RegExp("\\p{M}+", "gu");
188
+ var NO_TRUNCATION = { limit: Infinity, ellipsis: "" };
189
+ var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
190
+ const LIMIT = truncationOptions.limit ?? Infinity;
191
+ const ELLIPSIS = truncationOptions.ellipsis ?? "";
192
+ const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
193
+ const ANSI_WIDTH = 0;
194
+ const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
195
+ const TAB_WIDTH = widthOptions.tabWidth ?? 8;
196
+ const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
197
+ const FULL_WIDTH_WIDTH = 2;
198
+ const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
199
+ const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
200
+ const PARSE_BLOCKS = [
201
+ [LATIN_RE, REGULAR_WIDTH],
202
+ [ANSI_RE, ANSI_WIDTH],
203
+ [CONTROL_RE, CONTROL_WIDTH],
204
+ [TAB_RE, TAB_WIDTH],
205
+ [EMOJI_RE, EMOJI_WIDTH],
206
+ [CJKT_WIDE_RE, WIDE_WIDTH]
207
+ ];
208
+ let indexPrev = 0;
209
+ let index = 0;
210
+ let length = input.length;
211
+ let lengthExtra = 0;
212
+ let truncationEnabled = false;
213
+ let truncationIndex = length;
214
+ let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
215
+ let unmatchedStart = 0;
216
+ let unmatchedEnd = 0;
217
+ let width = 0;
218
+ let widthExtra = 0;
219
+ outer: while (true) {
220
+ if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
221
+ const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
222
+ lengthExtra = 0;
223
+ for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
224
+ const codePoint = char.codePointAt(0) || 0;
225
+ if (isFullWidth(codePoint)) {
226
+ widthExtra = FULL_WIDTH_WIDTH;
227
+ } else if (isWideNotCJKTNotEmoji(codePoint)) {
228
+ widthExtra = WIDE_WIDTH;
229
+ } else {
230
+ widthExtra = REGULAR_WIDTH;
231
+ }
232
+ if (width + widthExtra > truncationLimit) {
233
+ truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
234
+ }
235
+ if (width + widthExtra > LIMIT) {
236
+ truncationEnabled = true;
237
+ break outer;
238
+ }
239
+ lengthExtra += char.length;
240
+ width += widthExtra;
241
+ }
242
+ unmatchedStart = unmatchedEnd = 0;
243
+ }
244
+ if (index >= length) {
245
+ break outer;
246
+ }
247
+ for (let i2 = 0, l2 = PARSE_BLOCKS.length; i2 < l2; i2++) {
248
+ const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i2];
249
+ BLOCK_RE.lastIndex = index;
250
+ if (BLOCK_RE.test(input)) {
251
+ lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
252
+ widthExtra = lengthExtra * BLOCK_WIDTH;
253
+ if (width + widthExtra > truncationLimit) {
254
+ truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
255
+ }
256
+ if (width + widthExtra > LIMIT) {
257
+ truncationEnabled = true;
258
+ break outer;
259
+ }
260
+ width += widthExtra;
261
+ unmatchedStart = indexPrev;
262
+ unmatchedEnd = index;
263
+ index = indexPrev = BLOCK_RE.lastIndex;
264
+ continue outer;
265
+ }
266
+ }
267
+ index += 1;
268
+ }
269
+ return {
270
+ width: truncationEnabled ? truncationLimit : width,
271
+ index: truncationEnabled ? truncationIndex : length,
272
+ truncated: truncationEnabled,
273
+ ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
274
+ };
275
+ };
276
+ var dist_default = getStringTruncatedWidth;
277
+
278
+ // node_modules/fast-string-width/dist/index.js
279
+ var NO_TRUNCATION2 = {
280
+ limit: Infinity,
281
+ ellipsis: "",
282
+ ellipsisWidth: 0
283
+ };
284
+ var fastStringWidth = (input, options = {}) => {
285
+ return dist_default(input, NO_TRUNCATION2, options).width;
286
+ };
287
+ var dist_default2 = fastStringWidth;
288
+
289
+ // node_modules/fast-wrap-ansi/lib/main.js
290
+ var ESC = "\x1B";
291
+ var CSI = "\x9B";
292
+ var END_CODE = 39;
293
+ var ANSI_ESCAPE_BELL = "\x07";
294
+ var ANSI_CSI = "[";
295
+ var ANSI_OSC = "]";
296
+ var ANSI_SGR_TERMINATOR = "m";
297
+ var ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
298
+ var GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
299
+ var getClosingCode = (openingCode) => {
300
+ if (openingCode >= 30 && openingCode <= 37)
301
+ return 39;
302
+ if (openingCode >= 90 && openingCode <= 97)
303
+ return 39;
304
+ if (openingCode >= 40 && openingCode <= 47)
305
+ return 49;
306
+ if (openingCode >= 100 && openingCode <= 107)
307
+ return 49;
308
+ if (openingCode === 1 || openingCode === 2)
309
+ return 22;
310
+ if (openingCode === 3)
311
+ return 23;
312
+ if (openingCode === 4)
313
+ return 24;
314
+ if (openingCode === 7)
315
+ return 27;
316
+ if (openingCode === 8)
317
+ return 28;
318
+ if (openingCode === 9)
319
+ return 29;
320
+ if (openingCode === 0)
321
+ return 0;
322
+ return void 0;
323
+ };
324
+ var wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
325
+ var wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
326
+ var wrapWord = (rows, word, columns) => {
327
+ const characters = word[Symbol.iterator]();
328
+ let isInsideEscape = false;
329
+ let isInsideLinkEscape = false;
330
+ let lastRow = rows.at(-1);
331
+ let visible = lastRow === void 0 ? 0 : dist_default2(lastRow);
332
+ let currentCharacter = characters.next();
333
+ let nextCharacter = characters.next();
334
+ let rawCharacterIndex = 0;
335
+ while (!currentCharacter.done) {
336
+ const character = currentCharacter.value;
337
+ const characterLength = dist_default2(character);
338
+ if (visible + characterLength <= columns) {
339
+ rows[rows.length - 1] += character;
340
+ } else {
341
+ rows.push(character);
342
+ visible = 0;
343
+ }
344
+ if (character === ESC || character === CSI) {
345
+ isInsideEscape = true;
346
+ isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
347
+ }
348
+ if (isInsideEscape) {
349
+ if (isInsideLinkEscape) {
350
+ if (character === ANSI_ESCAPE_BELL) {
351
+ isInsideEscape = false;
352
+ isInsideLinkEscape = false;
353
+ }
354
+ } else if (character === ANSI_SGR_TERMINATOR) {
355
+ isInsideEscape = false;
356
+ }
357
+ } else {
358
+ visible += characterLength;
359
+ if (visible === columns && !nextCharacter.done) {
360
+ rows.push("");
361
+ visible = 0;
362
+ }
363
+ }
364
+ currentCharacter = nextCharacter;
365
+ nextCharacter = characters.next();
366
+ rawCharacterIndex += character.length;
367
+ }
368
+ lastRow = rows.at(-1);
369
+ if (!visible && lastRow !== void 0 && lastRow.length && rows.length > 1) {
370
+ rows[rows.length - 2] += rows.pop();
371
+ }
372
+ };
373
+ var stringVisibleTrimSpacesRight = (string) => {
374
+ const words = string.split(" ");
375
+ let last = words.length;
376
+ while (last) {
377
+ if (dist_default2(words[last - 1])) {
378
+ break;
379
+ }
380
+ last--;
381
+ }
382
+ if (last === words.length) {
383
+ return string;
384
+ }
385
+ return words.slice(0, last).join(" ") + words.slice(last).join("");
386
+ };
387
+ var exec = (string, columns, options = {}) => {
388
+ if (options.trim !== false && string.trim() === "") {
389
+ return "";
390
+ }
391
+ let returnValue = "";
392
+ let escapeCode;
393
+ let escapeUrl;
394
+ const words = string.split(" ");
395
+ let rows = [""];
396
+ let rowLength = 0;
397
+ for (let index = 0; index < words.length; index++) {
398
+ const word = words[index];
399
+ if (options.trim !== false) {
400
+ const row = rows.at(-1) ?? "";
401
+ const trimmed = row.trimStart();
402
+ if (row.length !== trimmed.length) {
403
+ rows[rows.length - 1] = trimmed;
404
+ rowLength = dist_default2(trimmed);
405
+ }
406
+ }
407
+ if (index !== 0) {
408
+ if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
409
+ rows.push("");
410
+ rowLength = 0;
411
+ }
412
+ if (rowLength || options.trim === false) {
413
+ rows[rows.length - 1] += " ";
414
+ rowLength++;
415
+ }
416
+ }
417
+ const wordLength = dist_default2(word);
418
+ if (options.hard && wordLength > columns) {
419
+ const remainingColumns = columns - rowLength;
420
+ const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
421
+ const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
422
+ if (breaksStartingNextLine < breaksStartingThisLine) {
423
+ rows.push("");
424
+ }
425
+ wrapWord(rows, word, columns);
426
+ rowLength = dist_default2(rows.at(-1) ?? "");
427
+ continue;
428
+ }
429
+ if (rowLength + wordLength > columns && rowLength && wordLength) {
430
+ if (options.wordWrap === false && rowLength < columns) {
431
+ wrapWord(rows, word, columns);
432
+ rowLength = dist_default2(rows.at(-1) ?? "");
433
+ continue;
434
+ }
435
+ rows.push("");
436
+ rowLength = 0;
437
+ }
438
+ if (rowLength + wordLength > columns && options.wordWrap === false) {
439
+ wrapWord(rows, word, columns);
440
+ rowLength = dist_default2(rows.at(-1) ?? "");
441
+ continue;
442
+ }
443
+ rows[rows.length - 1] += word;
444
+ rowLength += wordLength;
445
+ }
446
+ if (options.trim !== false) {
447
+ rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
448
+ }
449
+ const preString = rows.join("\n");
450
+ let inSurrogate = false;
451
+ for (let i2 = 0; i2 < preString.length; i2++) {
452
+ const character = preString[i2];
453
+ returnValue += character;
454
+ if (!inSurrogate) {
455
+ inSurrogate = character >= "\uD800" && character <= "\uDBFF";
456
+ if (inSurrogate) {
457
+ continue;
458
+ }
459
+ } else {
460
+ inSurrogate = false;
461
+ }
462
+ if (character === ESC || character === CSI) {
463
+ GROUP_REGEX.lastIndex = i2 + 1;
464
+ const groupsResult = GROUP_REGEX.exec(preString);
465
+ const groups = groupsResult?.groups;
466
+ if (groups?.code !== void 0) {
467
+ const code = Number.parseFloat(groups.code);
468
+ escapeCode = code === END_CODE ? void 0 : code;
469
+ } else if (groups?.uri !== void 0) {
470
+ escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
471
+ }
472
+ }
473
+ if (preString[i2 + 1] === "\n") {
474
+ if (escapeUrl) {
475
+ returnValue += wrapAnsiHyperlink("");
476
+ }
477
+ const closingCode = escapeCode ? getClosingCode(escapeCode) : void 0;
478
+ if (escapeCode && closingCode) {
479
+ returnValue += wrapAnsiCode(closingCode);
480
+ }
481
+ } else if (character === "\n") {
482
+ if (escapeCode && getClosingCode(escapeCode)) {
483
+ returnValue += wrapAnsiCode(escapeCode);
484
+ }
485
+ if (escapeUrl) {
486
+ returnValue += wrapAnsiHyperlink(escapeUrl);
487
+ }
488
+ }
489
+ }
490
+ return returnValue;
491
+ };
492
+ var CRLF_OR_LF = /\r?\n/;
493
+ function wrapAnsi(string, columns, options) {
494
+ return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
495
+ }
496
+
497
+ // node_modules/@clack/core/dist/index.mjs
498
+ var import_sisteransi = __toESM(require_src(), 1);
499
+ import { ReadStream } from "node:tty";
500
+ function findCursor(s, o2, l2) {
501
+ if (!l2.some((r2) => !r2.disabled))
502
+ return s;
503
+ const t2 = s + o2, n3 = Math.max(l2.length - 1, 0), e = t2 < 0 ? n3 : t2 > n3 ? 0 : t2;
504
+ return l2[e]?.disabled ? findCursor(e, o2 < 0 ? -1 : 1, l2) : e;
505
+ }
506
+ function findTextCursor(s, o2, l2, i2) {
507
+ const t2 = i2.split(`
508
+ `);
509
+ let n3 = 0, e = s;
510
+ for (const r2 of t2) {
511
+ if (e <= r2.length)
512
+ break;
513
+ e -= r2.length + 1, n3++;
514
+ }
515
+ for (n3 = Math.max(0, Math.min(t2.length - 1, n3 + l2)), e = Math.min(e, t2[n3].length) + o2; e < 0 && n3 > 0; )
516
+ n3--, e += t2[n3].length + 1;
517
+ for (; e > t2[n3].length && n3 < t2.length - 1; )
518
+ e -= t2[n3].length + 1, n3++;
519
+ e = Math.max(0, Math.min(t2[n3].length, e));
520
+ let h2 = 0;
521
+ for (let r2 = 0; r2 < n3; r2++)
522
+ h2 += t2[r2].length + 1;
523
+ return h2 + e;
524
+ }
525
+ var a$1 = ["up", "down", "left", "right", "space", "enter", "cancel"];
526
+ var t = [
527
+ "January",
528
+ "February",
529
+ "March",
530
+ "April",
531
+ "May",
532
+ "June",
533
+ "July",
534
+ "August",
535
+ "September",
536
+ "October",
537
+ "November",
538
+ "December"
539
+ ];
540
+ var settings = {
541
+ actions: new Set(a$1),
542
+ aliases: /* @__PURE__ */ new Map([
543
+ // vim support
544
+ ["k", "up"],
545
+ ["j", "down"],
546
+ ["h", "left"],
547
+ ["l", "right"],
548
+ ["", "cancel"],
549
+ // opinionated defaults!
550
+ ["escape", "cancel"]
551
+ ]),
552
+ messages: {
553
+ cancel: "Canceled",
554
+ error: "Something went wrong"
555
+ },
556
+ withGuide: true,
557
+ accessible: void 0,
558
+ date: {
559
+ monthNames: [...t],
560
+ messages: {
561
+ required: "Please enter a valid date",
562
+ invalidMonth: "There are only 12 months in a year",
563
+ invalidDay: (n3, e) => `There are only ${n3} days in ${e}`,
564
+ afterMin: (n3) => `Date must be on or after ${n3.toISOString().slice(0, 10)}`,
565
+ beforeMax: (n3) => `Date must be on or before ${n3.toISOString().slice(0, 10)}`
566
+ }
567
+ }
568
+ };
569
+ function updateSettings(n3) {
570
+ if (n3.aliases !== void 0) {
571
+ const e = n3.aliases;
572
+ for (const s in e) {
573
+ if (!Object.hasOwn(e, s)) continue;
574
+ const i2 = e[s];
575
+ i2 === void 0 || !settings.actions.has(i2) || settings.aliases.has(s) || settings.aliases.set(s, i2);
576
+ }
577
+ }
578
+ if (n3.messages !== void 0) {
579
+ const e = n3.messages;
580
+ e.cancel !== void 0 && (settings.messages.cancel = e.cancel), e.error !== void 0 && (settings.messages.error = e.error);
581
+ }
582
+ if (n3.withGuide !== void 0 && (settings.withGuide = n3.withGuide !== false), n3.accessible !== void 0 && (settings.accessible = n3.accessible === true), n3.date !== void 0) {
583
+ const e = n3.date;
584
+ 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));
585
+ }
586
+ }
587
+ function isAccessible(n3) {
588
+ if (n3 !== void 0) return n3;
589
+ if (settings.accessible !== void 0) return settings.accessible;
590
+ const e = process.env.ACCESSIBLE;
591
+ return e !== void 0 && e !== "" && e !== "0" && e !== "false";
592
+ }
593
+ function isActionKey(n3, e) {
594
+ if (typeof n3 == "string")
595
+ return settings.aliases.get(n3) === e;
596
+ for (const s of n3)
597
+ if (s !== void 0 && isActionKey(s, e))
598
+ return true;
599
+ return false;
600
+ }
601
+ function diffLines(i2, s) {
602
+ if (i2 === s) return;
603
+ const e = i2.split(`
604
+ `), t2 = s.split(`
605
+ `), r2 = Math.max(e.length, t2.length), f2 = [];
606
+ for (let n3 = 0; n3 < r2; n3++)
607
+ e[n3] !== t2[n3] && f2.push(n3);
608
+ return {
609
+ lines: f2,
610
+ numLinesBefore: e.length,
611
+ numLinesAfter: t2.length,
612
+ numLines: r2
613
+ };
614
+ }
615
+ var R = globalThis.process.platform.startsWith("win");
616
+ var CANCEL_SYMBOL = Symbol("clack:cancel");
617
+ function isCancel(e) {
618
+ return e === CANCEL_SYMBOL;
619
+ }
620
+ function setRawMode(e, r2) {
621
+ const o2 = e;
622
+ o2.isTTY && o2.setRawMode(r2);
623
+ }
624
+ function block({
625
+ input: e = stdin,
626
+ output: r2 = stdout,
627
+ overwrite: o2 = true,
628
+ hideCursor: n3 = true
629
+ } = {}) {
630
+ const s = l.createInterface({
631
+ input: e,
632
+ output: r2,
633
+ prompt: "",
634
+ tabSize: 1
635
+ });
636
+ l.emitKeypressEvents(e, s), e instanceof ReadStream && e.isTTY && e.setRawMode(true);
637
+ const t2 = (f2, { name: a2, sequence: w }) => {
638
+ const c3 = String(f2);
639
+ if (isActionKey([c3, a2, w], "cancel")) {
640
+ n3 && r2.write(import_sisteransi.cursor.show), process.exit(0);
641
+ return;
642
+ }
643
+ if (!o2) return;
644
+ const i2 = a2 === "return" ? 0 : -1, m3 = a2 === "return" ? -1 : 0;
645
+ l.moveCursor(r2, i2, m3, () => {
646
+ l.clearLine(r2, 1, () => {
647
+ e.once("keypress", t2);
648
+ });
649
+ });
650
+ };
651
+ return n3 && r2.write(import_sisteransi.cursor.hide), e.once("keypress", t2), () => {
652
+ e.off("keypress", t2), n3 && r2.write(import_sisteransi.cursor.show), e instanceof ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
653
+ };
654
+ }
655
+ var getColumns = (e) => "columns" in e && typeof e.columns == "number" ? e.columns : 80;
656
+ var getRows = (e) => "rows" in e && typeof e.rows == "number" ? e.rows : 20;
657
+ function wrapTextWithPrefix(e, r2, o2, n3 = o2, s = o2, t2) {
658
+ const f2 = getColumns(e ?? stdout);
659
+ return wrapAnsi(r2, f2 - o2.length, {
660
+ hard: true,
661
+ trim: false
662
+ }).split(`
663
+ `).map((c3, i2, m3) => {
664
+ const d = t2 ? t2(c3, i2) : c3;
665
+ return i2 === 0 ? `${n3}${d}` : i2 === m3.length - 1 ? `${s}${d}` : `${o2}${d}`;
666
+ }).join(`
667
+ `);
668
+ }
669
+ function runValidation(e, a2) {
670
+ if ("~standard" in e) {
671
+ const n3 = e["~standard"].validate(a2);
672
+ return n3 instanceof Promise ? n3.then((r2) => r2.issues?.at(0)?.message) : n3.issues?.at(0)?.message;
673
+ }
674
+ return e(a2);
675
+ }
676
+ var y = class {
677
+ input;
678
+ output;
679
+ _abortSignal;
680
+ rl;
681
+ opts;
682
+ _render;
683
+ _track = false;
684
+ _prevFrame = "";
685
+ _subscribers = /* @__PURE__ */ new Map();
686
+ _cursor = 0;
687
+ state = "initial";
688
+ error = "";
689
+ value;
690
+ userInput = "";
691
+ /**
692
+ * Whether accessible (static, screen-reader friendly) output is enabled for
693
+ * this prompt, resolved from the `accessible` option, the global setting,
694
+ * and the `ACCESSIBLE` env var.
695
+ */
696
+ get accessible() {
697
+ return isAccessible(this.opts.accessible);
698
+ }
699
+ constructor(t2, e = true) {
700
+ const { input: i2 = stdin, output: s = stdout, render: r2, signal: n3, ...o2 } = t2;
701
+ this.opts = o2, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = r2.bind(this), this._track = e, this._abortSignal = n3, this.input = i2, this.output = s;
702
+ }
703
+ /**
704
+ * Unsubscribe all listeners
705
+ */
706
+ unsubscribe() {
707
+ this._subscribers.clear();
708
+ }
709
+ /**
710
+ * Set a subscriber with opts
711
+ * @param event - The event name
712
+ */
713
+ setSubscriber(t2, e) {
714
+ const i2 = this._subscribers.get(t2) ?? [];
715
+ i2.push(e), this._subscribers.set(t2, i2);
716
+ }
717
+ /**
718
+ * Subscribe to an event
719
+ * @param event - The event name
720
+ * @param cb - The callback
721
+ */
722
+ on(t2, e) {
723
+ this.setSubscriber(t2, { cb: e });
724
+ }
725
+ /**
726
+ * Subscribe to an event once
727
+ * @param event - The event name
728
+ * @param cb - The callback
729
+ */
730
+ once(t2, e) {
731
+ this.setSubscriber(t2, { cb: e, once: true });
732
+ }
733
+ /**
734
+ * Emit an event with data
735
+ * @param event - The event name
736
+ * @param data - The data to pass to the callback
737
+ */
738
+ emit(t2, ...e) {
739
+ const i2 = this._subscribers.get(t2) ?? [], s = [];
740
+ for (const r2 of i2)
741
+ r2.cb(...e), r2.once && s.push(() => i2.splice(i2.indexOf(r2), 1));
742
+ for (const r2 of s)
743
+ r2();
744
+ }
745
+ prompt() {
746
+ return new Promise((t2) => {
747
+ if (this._abortSignal) {
748
+ if (this._abortSignal.aborted)
749
+ return this.state = "cancel", this.close(), t2(CANCEL_SYMBOL);
750
+ this._abortSignal.addEventListener(
751
+ "abort",
752
+ () => {
753
+ this.state = "cancel", this.close();
754
+ },
755
+ { once: true }
756
+ );
757
+ }
758
+ this.rl = l__default.createInterface({
759
+ input: this.input,
760
+ tabSize: 2,
761
+ prompt: "",
762
+ escapeCodeTimeout: 50,
763
+ terminal: true
764
+ }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), setRawMode(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
765
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(this.value);
766
+ }), this.once("cancel", () => {
767
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(CANCEL_SYMBOL);
768
+ });
769
+ });
770
+ }
771
+ _isActionKey(t2, e) {
772
+ return t2 === " ";
773
+ }
774
+ _shouldSubmit(t2, e) {
775
+ return true;
776
+ }
777
+ _setValue(t2) {
778
+ this.value = t2, this.emit("value", this.value);
779
+ }
780
+ _setUserInput(t2, e) {
781
+ this.userInput = t2 ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
782
+ }
783
+ _clearUserInput() {
784
+ this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
785
+ }
786
+ async onKeypress(t2, e) {
787
+ if (this.state !== "validating") {
788
+ if (this._track && e.name !== "return" && (e.name && this._isActionKey(t2, e) && this.rl?.write(null, { ctrl: true, name: "h" }), 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)), t2 && (t2.toLowerCase() === "y" || t2.toLowerCase() === "n") && this.emit("confirm", t2.toLowerCase() === "y"), this.emit("key", t2, e), e?.name === "return" && this._shouldSubmit(t2, e)) {
789
+ if (this.opts.validate) {
790
+ const i2 = runValidation(this.opts.validate, this.value);
791
+ let s;
792
+ i2 instanceof Promise ? (this.state = "validating", this.render(), s = await i2) : s = i2, s && (this.error = s instanceof Error ? s.message : s, this.state = "error", this.rl?.write(this.userInput));
793
+ }
794
+ this.state !== "error" && (this.state = "submit");
795
+ }
796
+ isActionKey([t2, e?.name, e?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
797
+ }
798
+ }
799
+ close() {
800
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
801
+ `), setRawMode(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
802
+ }
803
+ restoreCursor() {
804
+ const t2 = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
805
+ `).length - 1;
806
+ this.output.write(import_sisteransi.cursor.move(-999, t2 * -1));
807
+ }
808
+ render() {
809
+ const t2 = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
810
+ hard: true,
811
+ trim: false
812
+ });
813
+ if (t2 !== this._prevFrame) {
814
+ if (this.state === "initial")
815
+ this.output.write(import_sisteransi.cursor.hide);
816
+ else {
817
+ const e = diffLines(this._prevFrame, t2), i2 = getRows(this.output);
818
+ if (this.restoreCursor(), e) {
819
+ const s = Math.max(0, e.numLinesAfter - i2), r2 = Math.max(0, e.numLinesBefore - i2);
820
+ let n3 = e.lines.find((o2) => o2 >= s);
821
+ if (n3 === void 0) {
822
+ this._prevFrame = t2;
823
+ return;
824
+ }
825
+ if (e.lines.length === 1) {
826
+ this.output.write(import_sisteransi.cursor.move(0, n3 - r2)), this.output.write(import_sisteransi.erase.lines(1));
827
+ const o2 = t2.split(`
828
+ `);
829
+ this.output.write(o2[n3]), this._prevFrame = t2, this.output.write(import_sisteransi.cursor.move(0, o2.length - n3 - 1));
830
+ return;
831
+ } else if (e.lines.length > 1) {
832
+ if (s < r2)
833
+ n3 = s;
834
+ else {
835
+ const h2 = n3 - r2;
836
+ h2 > 0 && this.output.write(import_sisteransi.cursor.move(0, h2));
837
+ }
838
+ this.output.write(import_sisteransi.erase.down());
839
+ const f2 = t2.split(`
840
+ `).slice(n3);
841
+ this.output.write(f2.join(`
842
+ `)), this._prevFrame = t2;
843
+ return;
844
+ }
845
+ }
846
+ this.output.write(import_sisteransi.erase.down());
847
+ }
848
+ this.output.write(t2), this.state === "initial" && (this.state = "active"), this._prevFrame = t2;
849
+ }
850
+ }
851
+ };
852
+ function p$1(l2, e) {
853
+ if (l2 === void 0 || e.length === 0)
854
+ return 0;
855
+ const i2 = e.findIndex((s) => s.value === l2);
856
+ return i2 !== -1 ? i2 : 0;
857
+ }
858
+ function m(l2, e) {
859
+ return (e.label ?? String(e.value)).toLowerCase().includes(l2.toLowerCase());
860
+ }
861
+ function g(l2, e) {
862
+ if (e)
863
+ return l2 ? e : e[0];
864
+ }
865
+ var T$1 = class T extends y {
866
+ filteredOptions;
867
+ multiple;
868
+ isNavigating = false;
869
+ selectedValues = [];
870
+ focusedValue;
871
+ #e = 0;
872
+ #s = "";
873
+ #t;
874
+ #i;
875
+ #n;
876
+ #l;
877
+ get cursor() {
878
+ return this.#e;
879
+ }
880
+ get userInputWithCursor() {
881
+ if (!this.userInput)
882
+ return styleText(["inverse", "hidden"], "_");
883
+ if (this._cursor >= this.userInput.length)
884
+ return `${this.userInput}\u2588`;
885
+ const e = this.userInput.slice(0, this.cursor), t2 = this.userInput.slice(this.cursor, this.cursor + 1), i2 = this.userInput.slice(this.cursor + 1);
886
+ return `${e}${styleText("inverse", t2)}${i2}`;
887
+ }
888
+ get options() {
889
+ return typeof this.#i == "function" ? this.#i() : this.#i;
890
+ }
891
+ constructor(e) {
892
+ super(e), this.#i = e.options, this.#n = e.placeholder, this.#l = e.completeOnTab === true;
893
+ const t2 = this.options;
894
+ this.filteredOptions = [...t2], this.multiple = e.multiple === true, this.#t = typeof e.options == "function" ? e.filter : e.filter ?? m;
895
+ let i2;
896
+ if (e.initialValue && Array.isArray(e.initialValue) ? this.multiple ? i2 = e.initialValue : i2 = e.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (i2 = [this.options[0]?.value]), i2)
897
+ for (const s of i2) {
898
+ const n3 = t2.findIndex((r2) => r2.value === s);
899
+ n3 !== -1 && (this.toggleSelected(s), this.#e = n3);
900
+ }
901
+ this.focusedValue = this.options[this.#e]?.value, this.on("key", (s, n3) => this.#u(s, n3)), this.on("userInput", (s) => this.#o(s));
902
+ }
903
+ _isActionKey(e, t2) {
904
+ return e === " " || this.multiple && this.isNavigating && t2.name === "space" && e !== void 0 && e !== "";
905
+ }
906
+ #u(e, t2) {
907
+ const i2 = t2.name === "up", s = t2.name === "down", n3 = t2.name === "return", r2 = this.userInput === "" || this.userInput === " ", u5 = this.#n, d = this.options, c3 = u5 !== void 0 && u5 !== "" && d.some(
908
+ (o2) => !o2.disabled && (this.#t ? this.#t(u5, o2) : true)
909
+ );
910
+ if (t2.name === "tab" && r2 && c3) {
911
+ this.userInput === " " && this._clearUserInput(), this._setUserInput(u5, true), this.isNavigating = false;
912
+ return;
913
+ }
914
+ if (t2.name === "tab" && this.#l && !this.multiple && this.focusedValue !== void 0) {
915
+ const o2 = String(this.focusedValue);
916
+ this._clearUserInput(), this._setUserInput(o2, true), this.isNavigating = false;
917
+ return;
918
+ }
919
+ i2 || s ? (this.#e = findCursor(this.#e, i2 ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#e]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = true) : n3 ? this.value = g(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== void 0 && (t2.name === "tab" || this.isNavigating && t2.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
920
+ }
921
+ deselectAll() {
922
+ this.selectedValues = [];
923
+ }
924
+ toggleSelected(e) {
925
+ this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(e) ? this.selectedValues = this.selectedValues.filter((t2) => t2 !== e) : this.selectedValues = [...this.selectedValues, e] : this.selectedValues = [e]);
926
+ }
927
+ #o(e) {
928
+ if (e !== this.#s) {
929
+ this.#s = e;
930
+ const t2 = this.options;
931
+ e && this.#t ? this.filteredOptions = t2.filter((n3) => this.#t?.(e, n3)) : this.filteredOptions = [...t2];
932
+ const i2 = p$1(this.focusedValue, this.filteredOptions);
933
+ this.#e = findCursor(i2, 0, this.filteredOptions);
934
+ const s = this.filteredOptions[this.#e];
935
+ s && !s.disabled ? this.focusedValue = s.value : this.focusedValue = void 0, this.multiple || (this.focusedValue !== void 0 ? this.toggleSelected(this.focusedValue) : this.deselectAll());
936
+ }
937
+ }
938
+ };
939
+ var r = class extends y {
940
+ get cursor() {
941
+ return this.value ? 0 : 1;
942
+ }
943
+ get _value() {
944
+ return this.cursor === 0;
945
+ }
946
+ constructor(t2) {
947
+ super(t2, false), this.value = !!t2.initialValue, this.on("userInput", () => {
948
+ this.value = this._value;
949
+ }), this.on("confirm", (i2) => {
950
+ this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = i2, this.state = "submit", this.close();
951
+ }), this.on("cursor", () => {
952
+ this.value = !this.value;
953
+ });
954
+ }
955
+ };
956
+ var _ = {
957
+ Y: { type: "year", len: 4 },
958
+ M: { type: "month", len: 2 },
959
+ D: { type: "day", len: 2 }
960
+ };
961
+ function M(r2) {
962
+ return [...r2].map((t2) => _[t2]);
963
+ }
964
+ function P(r2) {
965
+ const i2 = new Intl.DateTimeFormat(r2, {
966
+ year: "numeric",
967
+ month: "2-digit",
968
+ day: "2-digit"
969
+ }).formatToParts(new Date(2e3, 0, 15)), s = [];
970
+ let n3 = "/";
971
+ for (const e of i2)
972
+ e.type === "literal" ? n3 = e.value.trim() || e.value : (e.type === "year" || e.type === "month" || e.type === "day") && s.push({ type: e.type, len: e.type === "year" ? 4 : 2 });
973
+ return { segments: s, separator: n3 };
974
+ }
975
+ function p(r2) {
976
+ return Number.parseInt((r2 || "0").replace(/_/g, "0"), 10) || 0;
977
+ }
978
+ function f(r2) {
979
+ return {
980
+ year: p(r2.year),
981
+ month: p(r2.month),
982
+ day: p(r2.day)
983
+ };
984
+ }
985
+ function c(r2, t2) {
986
+ return new Date(r2 || 2001, t2 || 1, 0).getDate();
987
+ }
988
+ function b(r2) {
989
+ const { year: t2, month: i2, day: s } = f(r2);
990
+ if (!t2 || t2 < 0 || t2 > 9999 || !i2 || i2 < 1 || i2 > 12 || !s || s < 1) return;
991
+ const n3 = new Date(Date.UTC(t2, i2 - 1, s));
992
+ if (!(n3.getUTCFullYear() !== t2 || n3.getUTCMonth() !== i2 - 1 || n3.getUTCDate() !== s))
993
+ return { year: t2, month: i2, day: s };
994
+ }
995
+ function C(r2) {
996
+ const t2 = b(r2);
997
+ return t2 ? new Date(Date.UTC(t2.year, t2.month - 1, t2.day)) : void 0;
998
+ }
999
+ function T2(r2, t2, i2, s) {
1000
+ const n3 = i2 ? {
1001
+ year: i2.getUTCFullYear(),
1002
+ month: i2.getUTCMonth() + 1,
1003
+ day: i2.getUTCDate()
1004
+ } : null, e = s ? {
1005
+ year: s.getUTCFullYear(),
1006
+ month: s.getUTCMonth() + 1,
1007
+ day: s.getUTCDate()
1008
+ } : null;
1009
+ return r2 === "year" ? { min: n3?.year ?? 1, max: e?.year ?? 9999 } : r2 === "month" ? {
1010
+ min: n3 && t2.year === n3.year ? n3.month : 1,
1011
+ max: e && t2.year === e.year ? e.month : 12
1012
+ } : {
1013
+ min: n3 && t2.year === n3.year && t2.month === n3.month ? n3.day : 1,
1014
+ max: e && t2.year === e.year && t2.month === e.month ? e.day : c(t2.year, t2.month)
1015
+ };
1016
+ }
1017
+ var U = class extends y {
1018
+ #i;
1019
+ #o;
1020
+ #t;
1021
+ #h;
1022
+ #u;
1023
+ #e = { segmentIndex: 0, positionInSegment: 0 };
1024
+ #n = true;
1025
+ #s = null;
1026
+ inlineError = "";
1027
+ get segmentCursor() {
1028
+ return { ...this.#e };
1029
+ }
1030
+ get segmentValues() {
1031
+ return { ...this.#t };
1032
+ }
1033
+ get segments() {
1034
+ return this.#i;
1035
+ }
1036
+ get separator() {
1037
+ return this.#o;
1038
+ }
1039
+ get formattedValue() {
1040
+ return this.#l(this.#t);
1041
+ }
1042
+ #l(t2) {
1043
+ return this.#i.map((i2) => t2[i2.type]).join(this.#o);
1044
+ }
1045
+ #r() {
1046
+ this._setUserInput(this.#l(this.#t)), this._setValue(C(this.#t) ?? void 0);
1047
+ }
1048
+ constructor(t2) {
1049
+ const i2 = t2.format ? { segments: M(t2.format), separator: t2.separator ?? "/" } : P(t2.locale), s = t2.separator ?? i2.separator, n3 = t2.format ? M(t2.format) : i2.segments, e = t2.initialValue ?? t2.defaultValue, m3 = e ? {
1050
+ year: String(e.getUTCFullYear()).padStart(4, "0"),
1051
+ month: String(e.getUTCMonth() + 1).padStart(2, "0"),
1052
+ day: String(e.getUTCDate()).padStart(2, "0")
1053
+ } : { year: "____", month: "__", day: "__" }, o2 = n3.map((a2) => m3[a2.type]).join(s);
1054
+ super({ ...t2, initialUserInput: o2 }, false), this.#i = n3, this.#o = s, this.#t = m3, this.#h = t2.minDate, this.#u = t2.maxDate, this.#r(), this.on("cursor", (a2) => this.#f(a2)), this.on("key", (a2, u5) => this.#y(a2, u5)), this.on("finalize", () => this.#p(t2));
1055
+ }
1056
+ #a() {
1057
+ const t2 = Math.max(0, Math.min(this.#e.segmentIndex, this.#i.length - 1)), i2 = this.#i[t2];
1058
+ if (i2)
1059
+ return this.#e.positionInSegment = Math.max(
1060
+ 0,
1061
+ Math.min(this.#e.positionInSegment, i2.len - 1)
1062
+ ), { segment: i2, index: t2 };
1063
+ }
1064
+ #m(t2) {
1065
+ this.inlineError = "", this.#s = null;
1066
+ const i2 = this.#a();
1067
+ i2 && (this.#e.segmentIndex = Math.max(
1068
+ 0,
1069
+ Math.min(this.#i.length - 1, i2.index + t2)
1070
+ ), this.#e.positionInSegment = 0, this.#n = true);
1071
+ }
1072
+ #d(t2) {
1073
+ const i2 = this.#a();
1074
+ if (!i2) return;
1075
+ const { segment: s } = i2, n3 = this.#t[s.type], e = !n3 || n3.replace(/_/g, "") === "", m3 = Number.parseInt((n3 || "0").replace(/_/g, "0"), 10) || 0, o2 = T2(
1076
+ s.type,
1077
+ f(this.#t),
1078
+ this.#h,
1079
+ this.#u
1080
+ );
1081
+ let a2;
1082
+ e ? a2 = t2 === 1 ? o2.min : o2.max : a2 = Math.max(Math.min(o2.max, m3 + t2), o2.min), this.#t = {
1083
+ ...this.#t,
1084
+ [s.type]: a2.toString().padStart(s.len, "0")
1085
+ }, this.#n = true, this.#s = null, this.#r();
1086
+ }
1087
+ #f(t2) {
1088
+ if (t2)
1089
+ switch (t2) {
1090
+ case "right":
1091
+ return this.#m(1);
1092
+ case "left":
1093
+ return this.#m(-1);
1094
+ case "up":
1095
+ return this.#d(1);
1096
+ case "down":
1097
+ return this.#d(-1);
1098
+ }
1099
+ }
1100
+ #y(t2, i2) {
1101
+ if (i2?.name === "backspace" || i2?.sequence === "\x7F" || i2?.sequence === "\b" || t2 === "\x7F" || t2 === "\b") {
1102
+ this.inlineError = "";
1103
+ const n3 = this.#a();
1104
+ if (!n3) return;
1105
+ if (!this.#t[n3.segment.type].replace(/_/g, "")) {
1106
+ this.#m(-1);
1107
+ return;
1108
+ }
1109
+ this.#t[n3.segment.type] = "_".repeat(n3.segment.len), this.#n = true, this.#e.positionInSegment = 0, this.#r();
1110
+ return;
1111
+ }
1112
+ if (i2?.name === "tab") {
1113
+ this.inlineError = "";
1114
+ const n3 = this.#a();
1115
+ if (!n3) return;
1116
+ const e = i2.shift ? -1 : 1, m3 = n3.index + e;
1117
+ m3 >= 0 && m3 < this.#i.length && (this.#e.segmentIndex = m3, this.#e.positionInSegment = 0, this.#n = true);
1118
+ return;
1119
+ }
1120
+ if (t2 && /^[0-9]$/.test(t2)) {
1121
+ const n3 = this.#a();
1122
+ if (!n3) return;
1123
+ const { segment: e } = n3, m3 = !this.#t[e.type].replace(/_/g, "");
1124
+ if (this.#n && this.#s !== null && !m3) {
1125
+ const h2 = this.#s + t2, d = { ...this.#t, [e.type]: h2 }, g2 = this.#g(d, e);
1126
+ if (g2) {
1127
+ this.inlineError = g2, this.#s = null, this.#n = false;
1128
+ return;
1129
+ }
1130
+ this.inlineError = "", this.#t[e.type] = h2, this.#s = null, this.#n = false, this.#r(), n3.index < this.#i.length - 1 && (this.#e.segmentIndex = n3.index + 1, this.#e.positionInSegment = 0, this.#n = true);
1131
+ return;
1132
+ }
1133
+ this.#n && !m3 && (this.#t[e.type] = "_".repeat(e.len), this.#e.positionInSegment = 0), this.#n = false, this.#s = null;
1134
+ const o2 = this.#t[e.type], a2 = o2.indexOf("_"), u5 = a2 >= 0 ? a2 : Math.min(this.#e.positionInSegment, e.len - 1);
1135
+ if (u5 < 0 || u5 >= e.len) return;
1136
+ let l2 = o2.slice(0, u5) + t2 + o2.slice(u5 + 1), D = false;
1137
+ if (u5 === 0 && o2 === "__" && (e.type === "month" || e.type === "day")) {
1138
+ const h2 = Number.parseInt(t2, 10);
1139
+ l2 = `0${t2}`, D = h2 <= (e.type === "month" ? 1 : 2);
1140
+ }
1141
+ if (e.type === "year" && (l2 = (o2.replace(/_/g, "") + t2).padStart(e.len, "_")), !l2.includes("_")) {
1142
+ const h2 = { ...this.#t, [e.type]: l2 }, d = this.#g(h2, e);
1143
+ if (d) {
1144
+ this.inlineError = d;
1145
+ return;
1146
+ }
1147
+ }
1148
+ this.inlineError = "", this.#t[e.type] = l2;
1149
+ const y2 = l2.includes("_") ? void 0 : b(this.#t);
1150
+ if (y2) {
1151
+ const { year: h2, month: d } = y2, g2 = c(h2, d);
1152
+ this.#t = {
1153
+ year: String(Math.max(0, Math.min(9999, h2))).padStart(4, "0"),
1154
+ month: String(Math.max(1, Math.min(12, d))).padStart(2, "0"),
1155
+ day: String(Math.max(1, Math.min(g2, y2.day))).padStart(2, "0")
1156
+ };
1157
+ }
1158
+ this.#r();
1159
+ const S = l2.indexOf("_");
1160
+ D ? (this.#n = true, this.#s = t2) : S >= 0 ? this.#e.positionInSegment = S : a2 >= 0 && n3.index < this.#i.length - 1 ? (this.#e.segmentIndex = n3.index + 1, this.#e.positionInSegment = 0, this.#n = true) : this.#e.positionInSegment = Math.min(u5 + 1, e.len - 1);
1161
+ }
1162
+ }
1163
+ #g(t2, i2) {
1164
+ const { month: s, day: n3 } = f(t2);
1165
+ if (i2.type === "month" && (s < 0 || s > 12))
1166
+ return settings.date.messages.invalidMonth;
1167
+ if (i2.type === "day" && (n3 < 0 || n3 > 31))
1168
+ return settings.date.messages.invalidDay(31, "any month");
1169
+ }
1170
+ #p(t2) {
1171
+ const { year: i2, month: s, day: n3 } = f(this.#t);
1172
+ if (i2 && s && n3) {
1173
+ const e = c(i2, s);
1174
+ this.#t = {
1175
+ ...this.#t,
1176
+ day: String(Math.min(n3, e)).padStart(2, "0")
1177
+ };
1178
+ }
1179
+ this.value = C(this.#t) ?? t2.defaultValue ?? void 0;
1180
+ }
1181
+ };
1182
+ var u$2 = class u extends y {
1183
+ options;
1184
+ cursor = 0;
1185
+ #t;
1186
+ getGroupItems(t2) {
1187
+ return this.options.filter((r2) => r2.group === t2);
1188
+ }
1189
+ isGroupSelected(t2) {
1190
+ const r2 = this.getGroupItems(t2), e = this.value;
1191
+ return e === void 0 ? false : r2.every((s) => e.includes(s.value));
1192
+ }
1193
+ toggleValue() {
1194
+ const t2 = this.options[this.cursor];
1195
+ if (t2 !== void 0)
1196
+ if (this.value === void 0 && (this.value = []), t2.group === true) {
1197
+ const r2 = t2.value, e = this.getGroupItems(r2);
1198
+ this.isGroupSelected(r2) ? this.value = this.value.filter(
1199
+ (s) => e.findIndex((i2) => i2.value === s) === -1
1200
+ ) : this.value = [...this.value, ...e.map((s) => s.value)], this.value = Array.from(new Set(this.value));
1201
+ } else {
1202
+ const r2 = this.value.includes(t2.value);
1203
+ this.value = r2 ? this.value.filter((e) => e !== t2.value) : [...this.value, t2.value];
1204
+ }
1205
+ }
1206
+ constructor(t2) {
1207
+ super(t2, false);
1208
+ const { options: r2 } = t2;
1209
+ this.#t = t2.selectableGroups !== false, this.options = Object.entries(r2).flatMap(([e, s]) => [
1210
+ { value: e, group: true, label: e },
1211
+ ...s.map((i2) => ({ ...i2, group: e }))
1212
+ ]), this.value = [...t2.initialValues ?? []], this.cursor = Math.max(
1213
+ this.options.findIndex(({ value: e }) => e === t2.cursorAt),
1214
+ this.#t ? 0 : 1
1215
+ ), this.on("cursor", (e) => {
1216
+ switch (e) {
1217
+ case "left":
1218
+ case "up": {
1219
+ this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
1220
+ const s = this.options[this.cursor]?.group === true;
1221
+ !this.#t && s && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
1222
+ break;
1223
+ }
1224
+ case "down":
1225
+ case "right": {
1226
+ this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
1227
+ const s = this.options[this.cursor]?.group === true;
1228
+ !this.#t && s && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
1229
+ break;
1230
+ }
1231
+ case "space":
1232
+ this.toggleValue();
1233
+ break;
1234
+ }
1235
+ });
1236
+ }
1237
+ };
1238
+ var o = /* @__PURE__ */ new Set(["up", "down", "left", "right"]);
1239
+ var h = class extends y {
1240
+ #t = false;
1241
+ #s;
1242
+ focused = "editor";
1243
+ get userInputWithCursor() {
1244
+ if (this.state === "submit")
1245
+ return this.userInput;
1246
+ const t2 = this.userInput;
1247
+ if (this.cursor >= t2.length)
1248
+ return `${t2}\u2588`;
1249
+ const s = t2.slice(0, this.cursor), r2 = t2.slice(this.cursor, this.cursor + 1), i2 = t2.slice(this.cursor + 1);
1250
+ return r2 === `
1251
+ ` ? `${s}\u2588
1252
+ ${i2}` : `${s}${styleText("inverse", r2)}${i2}`;
1253
+ }
1254
+ get cursor() {
1255
+ return this._cursor;
1256
+ }
1257
+ #r(t2) {
1258
+ if (this.userInput.length === 0) {
1259
+ this._setUserInput(t2);
1260
+ return;
1261
+ }
1262
+ this._setUserInput(
1263
+ this.userInput.slice(0, this.cursor) + t2 + this.userInput.slice(this.cursor)
1264
+ );
1265
+ }
1266
+ #i(t2) {
1267
+ const s = this.value ?? "";
1268
+ switch (t2) {
1269
+ case "up":
1270
+ this._cursor = findTextCursor(this._cursor, 0, -1, s);
1271
+ return;
1272
+ case "down":
1273
+ this._cursor = findTextCursor(this._cursor, 0, 1, s);
1274
+ return;
1275
+ case "left":
1276
+ this._cursor = findTextCursor(this._cursor, -1, 0, s);
1277
+ return;
1278
+ case "right":
1279
+ this._cursor = findTextCursor(this._cursor, 1, 0, s);
1280
+ return;
1281
+ }
1282
+ }
1283
+ _shouldSubmit(t2, s) {
1284
+ if (this.#s)
1285
+ return this.focused === "submit" ? true : (this.#r(`
1286
+ `), this._cursor++, false);
1287
+ const r2 = this.#t;
1288
+ return this.#t = true, r2 && this.cursor === this.userInput.length ? (this.userInput[this.cursor - 1] === `
1289
+ ` && (this._setUserInput(
1290
+ this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)
1291
+ ), this._cursor--), true) : (this.#r(`
1292
+ `), this._cursor++, false);
1293
+ }
1294
+ constructor(t2) {
1295
+ const s = t2.initialUserInput ?? t2.initialValue;
1296
+ super(
1297
+ {
1298
+ ...t2,
1299
+ initialUserInput: s
1300
+ },
1301
+ false
1302
+ ), s !== void 0 && (this._cursor = s.length), this.#s = t2.showSubmit ?? false, this.on("key", (r2, i2) => {
1303
+ if (i2?.name && o.has(i2.name)) {
1304
+ this.#t = false, this.#i(i2.name);
1305
+ return;
1306
+ }
1307
+ if (r2 === " " && this.#s) {
1308
+ this.focused = this.focused === "editor" ? "submit" : "editor";
1309
+ return;
1310
+ }
1311
+ if (i2?.name !== "return") {
1312
+ if (this.#t = false, i2?.name === "backspace" && this.cursor > 0) {
1313
+ this._setUserInput(
1314
+ this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)
1315
+ ), this._cursor--;
1316
+ return;
1317
+ }
1318
+ if (i2?.name === "delete" && this.cursor < this.userInput.length) {
1319
+ this._setUserInput(
1320
+ this.userInput.slice(0, this.cursor) + this.userInput.slice(this.cursor + 1)
1321
+ );
1322
+ return;
1323
+ }
1324
+ r2 && (this.#s && this.focused === "submit" && (this.focused = "editor"), this.#r(r2 ?? ""), this._cursor++);
1325
+ }
1326
+ }), this.on("userInput", (r2) => {
1327
+ this._setValue(r2);
1328
+ }), this.on("finalize", () => {
1329
+ this.value || (this.value = t2.defaultValue), this.value === void 0 && (this.value = "");
1330
+ });
1331
+ }
1332
+ };
1333
+ var a = class extends y {
1334
+ options;
1335
+ cursor = 0;
1336
+ get _value() {
1337
+ return this.options[this.cursor]?.value;
1338
+ }
1339
+ get _enabledOptions() {
1340
+ return this.options.filter((e) => e.disabled !== true);
1341
+ }
1342
+ toggleAll() {
1343
+ const e = this._enabledOptions, i2 = this.value !== void 0 && this.value.length === e.length;
1344
+ this.value = i2 ? [] : e.map((t2) => t2.value);
1345
+ }
1346
+ toggleInvert() {
1347
+ const e = this.value;
1348
+ if (!e)
1349
+ return;
1350
+ const i2 = this._enabledOptions.filter((t2) => !e.includes(t2.value));
1351
+ this.value = i2.map((t2) => t2.value);
1352
+ }
1353
+ toggleValue() {
1354
+ this.value === void 0 && (this.value = []);
1355
+ const e = this.value.includes(this._value);
1356
+ this.value = e ? this.value.filter((i2) => i2 !== this._value) : [...this.value, this._value];
1357
+ }
1358
+ constructor(e) {
1359
+ super(e, false), this.options = e.options, this.value = [...e.initialValues ?? []];
1360
+ const i2 = Math.max(
1361
+ this.options.findIndex(({ value: t2 }) => t2 === e.cursorAt),
1362
+ 0
1363
+ );
1364
+ this.cursor = this.options[i2]?.disabled ? findCursor(i2, 1, this.options) : i2, this.on("key", (t2, l2) => {
1365
+ l2.name === "a" && this.toggleAll(), l2.name === "i" && this.toggleInvert();
1366
+ }), this.on("cursor", (t2) => {
1367
+ switch (t2) {
1368
+ case "left":
1369
+ case "up":
1370
+ this.cursor = findCursor(this.cursor, -1, this.options);
1371
+ break;
1372
+ case "down":
1373
+ case "right":
1374
+ this.cursor = findCursor(this.cursor, 1, this.options);
1375
+ break;
1376
+ case "space":
1377
+ this.toggleValue();
1378
+ break;
1379
+ }
1380
+ });
1381
+ }
1382
+ };
1383
+ var u$1 = class u2 extends y {
1384
+ _mask = "\u2022";
1385
+ get cursor() {
1386
+ return this._cursor;
1387
+ }
1388
+ get masked() {
1389
+ return this.userInput.replaceAll(/./g, this._mask);
1390
+ }
1391
+ get userInputWithCursor() {
1392
+ if (this.state === "submit" || this.state === "cancel")
1393
+ return this.masked;
1394
+ const t2 = this.userInput;
1395
+ if (this.cursor >= t2.length)
1396
+ return `${this.masked}${styleText(["inverse", "hidden"], "_")}`;
1397
+ const s = this.masked, r2 = s.slice(0, this.cursor), i2 = s.slice(this.cursor, this.cursor + 1), o2 = s.slice(this.cursor + 1);
1398
+ return `${r2}${styleText("inverse", i2)}${o2}`;
1399
+ }
1400
+ clear() {
1401
+ this._clearUserInput();
1402
+ }
1403
+ constructor({ mask: t2, ...s }) {
1404
+ super(s), this._mask = t2 ?? "\u2022", this.on("userInput", (r2) => {
1405
+ this._setValue(r2);
1406
+ }), this.on("finalize", () => {
1407
+ this.value === void 0 && (this.value = "");
1408
+ });
1409
+ }
1410
+ };
1411
+ var n$1 = class n extends y {
1412
+ options;
1413
+ cursor = 0;
1414
+ get _selectedValue() {
1415
+ return this.options[this.cursor];
1416
+ }
1417
+ changeValue() {
1418
+ const e = this._selectedValue;
1419
+ this.value = e === void 0 ? void 0 : e.value;
1420
+ }
1421
+ constructor(e) {
1422
+ super(e, false), this.options = e.options;
1423
+ const o2 = this.options.findIndex(({ value: s }) => s === e.initialValue), t2 = o2 === -1 ? 0 : o2;
1424
+ this.cursor = this.options[t2]?.disabled ? findCursor(t2, 1, this.options) : t2, this.changeValue(), this.on("cursor", (s) => {
1425
+ switch (s) {
1426
+ case "left":
1427
+ case "up":
1428
+ this.cursor = findCursor(this.cursor, -1, this.options);
1429
+ break;
1430
+ case "down":
1431
+ case "right":
1432
+ this.cursor = findCursor(this.cursor, 1, this.options);
1433
+ break;
1434
+ }
1435
+ this.changeValue();
1436
+ });
1437
+ }
1438
+ };
1439
+ var u3 = class extends y {
1440
+ options;
1441
+ cursor = 0;
1442
+ constructor(t2) {
1443
+ super(t2, false), this.options = t2.options;
1444
+ const s = t2.caseSensitive === true, i2 = this.options.map(({ value: [e] }) => s ? e : e?.toLowerCase());
1445
+ this.cursor = Math.max(i2.indexOf(t2.initialValue), 0), this.on("key", (e) => {
1446
+ if (!e)
1447
+ return;
1448
+ const o2 = s ? e : e.toLowerCase();
1449
+ if (!i2.includes(o2))
1450
+ return;
1451
+ const n3 = this.options.find(({ value: [r2] }) => s ? r2 === o2 : r2?.toLowerCase() === o2);
1452
+ n3 && (this.value = n3.value, this.state = "submit", this.emit("submit"));
1453
+ });
1454
+ }
1455
+ };
1456
+ var n2 = class extends y {
1457
+ get userInputWithCursor() {
1458
+ if (this.state === "submit")
1459
+ return this.userInput;
1460
+ const t2 = this.userInput;
1461
+ if (this.cursor >= t2.length)
1462
+ return `${this.userInput}\u2588`;
1463
+ const r2 = t2.slice(0, this.cursor), s = t2.slice(this.cursor, this.cursor + 1), e = t2.slice(this.cursor + 1);
1464
+ return `${r2}${styleText("inverse", s)}${e}`;
1465
+ }
1466
+ get cursor() {
1467
+ return this._cursor;
1468
+ }
1469
+ constructor(t2) {
1470
+ super({
1471
+ ...t2,
1472
+ initialUserInput: t2.initialUserInput ?? t2.initialValue
1473
+ }), this.on("userInput", (r2) => {
1474
+ this._setValue(r2);
1475
+ }), this.on("finalize", () => {
1476
+ this.value || (this.value = t2.defaultValue), this.value === void 0 && (this.value = "");
1477
+ });
1478
+ }
1479
+ };
1480
+
1481
+ // node_modules/@clack/prompts/dist/index.mjs
1482
+ import { styleText as styleText2, stripVTControlCharacters } from "node:util";
1483
+ import process$1 from "node:process";
1484
+ var import_sisteransi2 = __toESM(require_src(), 1);
1485
+ import { existsSync, lstatSync, readdirSync } from "node:fs";
1486
+ import { dirname, join } from "node:path";
1487
+ function isUnicodeSupported() {
1488
+ if (process$1.platform !== "win32") {
1489
+ return process$1.env.TERM !== "linux";
1490
+ }
1491
+ 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";
1492
+ }
1493
+ var unicode = isUnicodeSupported();
1494
+ var isCI = () => process.env.CI === "true";
1495
+ var isTTY = (o2) => o2.isTTY === true;
1496
+ var unicodeOr = (o2, e) => unicode ? o2 : e;
1497
+ var S_STEP_ACTIVE = unicodeOr("\u25C6", "*");
1498
+ var S_STEP_CANCEL = unicodeOr("\u25A0", "x");
1499
+ var S_STEP_ERROR = unicodeOr("\u25B2", "x");
1500
+ var S_STEP_SUBMIT = unicodeOr("\u25C7", "o");
1501
+ var S_BAR_START = unicodeOr("\u250C", "T");
1502
+ var S_BAR = unicodeOr("\u2502", "|");
1503
+ var S_BAR_END = unicodeOr("\u2514", "\u2014");
1504
+ var S_BAR_START_RIGHT = unicodeOr("\u2510", "T");
1505
+ var S_BAR_END_RIGHT = unicodeOr("\u2518", "\u2014");
1506
+ var S_RADIO_ACTIVE = unicodeOr("\u25CF", ">");
1507
+ var S_RADIO_INACTIVE = unicodeOr("\u25CB", " ");
1508
+ var S_CHECKBOX_ACTIVE = unicodeOr("\u25FB", "[\u2022]");
1509
+ var S_CHECKBOX_SELECTED = unicodeOr("\u25FC", "[+]");
1510
+ var S_CHECKBOX_INACTIVE = unicodeOr("\u25FB", "[ ]");
1511
+ var S_PASSWORD_MASK = unicodeOr("\u25AA", "\u2022");
1512
+ var S_BAR_H = unicodeOr("\u2500", "-");
1513
+ var S_CORNER_TOP_RIGHT = unicodeOr("\u256E", "+");
1514
+ var S_CONNECT_LEFT = unicodeOr("\u251C", "+");
1515
+ var S_CORNER_BOTTOM_RIGHT = unicodeOr("\u256F", "+");
1516
+ var S_CORNER_BOTTOM_LEFT = unicodeOr("\u2570", "+");
1517
+ var S_CORNER_TOP_LEFT = unicodeOr("\u256D", "+");
1518
+ var S_INFO = unicodeOr("\u25CF", "\u2022");
1519
+ var S_SUCCESS = unicodeOr("\u25C6", "*");
1520
+ var S_WARN = unicodeOr("\u25B2", "!");
1521
+ var S_ERROR = unicodeOr("\u25A0", "x");
1522
+ var symbol = (o2) => {
1523
+ switch (o2) {
1524
+ case "initial":
1525
+ case "active":
1526
+ return styleText2("cyan", S_STEP_ACTIVE);
1527
+ case "cancel":
1528
+ return styleText2("red", S_STEP_CANCEL);
1529
+ case "error":
1530
+ return styleText2("yellow", S_STEP_ERROR);
1531
+ case "submit":
1532
+ return styleText2("green", S_STEP_SUBMIT);
1533
+ case "validating":
1534
+ return styleText2("dim", S_STEP_ACTIVE);
1535
+ }
1536
+ };
1537
+ var symbolBar = (o2) => {
1538
+ switch (o2) {
1539
+ case "initial":
1540
+ case "active":
1541
+ return styleText2("cyan", S_BAR);
1542
+ case "cancel":
1543
+ return styleText2("red", S_BAR);
1544
+ case "error":
1545
+ return styleText2("yellow", S_BAR);
1546
+ case "submit":
1547
+ return styleText2("green", S_BAR);
1548
+ }
1549
+ };
1550
+ function formatInstructionFooter(o2, e) {
1551
+ const r2 = [`${e ? `${styleText2("cyan", S_BAR)} ` : ""}${o2.join(" \u2022 ")}`];
1552
+ return e && r2.push(styleText2("cyan", S_BAR_END)), r2;
1553
+ }
1554
+ var I = (l2, e, w, p3, b3, C3 = false) => {
1555
+ let r2 = e, O = 0;
1556
+ if (C3)
1557
+ for (let i2 = p3 - 1; i2 >= w; i2--) {
1558
+ const m3 = l2[i2];
1559
+ if (m3 && (r2 -= m3.length), O++, r2 <= b3) break;
1560
+ }
1561
+ else
1562
+ for (let i2 = w; i2 < p3; i2++) {
1563
+ const m3 = l2[i2];
1564
+ if (m3 && (r2 -= m3.length), O++, r2 <= b3) break;
1565
+ }
1566
+ return { lineCount: r2, removals: O };
1567
+ };
1568
+ var limitOptions = ({
1569
+ cursor: l2,
1570
+ options: e,
1571
+ style: w,
1572
+ output: p3 = process.stdout,
1573
+ maxItems: b3 = Number.POSITIVE_INFINITY,
1574
+ columnPadding: C3 = 0,
1575
+ rowPadding: r2 = 4
1576
+ }) => {
1577
+ const i2 = getColumns(p3) - C3, m3 = getRows(p3), M2 = styleText2("dim", "..."), v = Math.max(m3 - r2, 0), a2 = Math.max(Math.min(b3, v), 5);
1578
+ let f2 = 0;
1579
+ l2 >= a2 - 3 && (f2 = Math.max(
1580
+ Math.min(l2 - a2 + 3, e.length - a2),
1581
+ 0
1582
+ ));
1583
+ let d = a2 < e.length && f2 > 0, c3 = a2 < e.length && f2 + a2 < e.length;
1584
+ const W2 = Math.min(
1585
+ f2 + a2,
1586
+ e.length
1587
+ ), s = [];
1588
+ let g2 = 0;
1589
+ d && g2++, c3 && g2++;
1590
+ const T3 = f2 + (d ? 1 : 0), y2 = W2 - (c3 ? 1 : 0);
1591
+ for (let t2 = T3; t2 < y2; t2++) {
1592
+ const n3 = e[t2], o2 = n3 ? w(n3, t2 === l2) : "", h2 = wrapAnsi(o2, i2, {
1593
+ hard: true,
1594
+ trim: false
1595
+ }).split(`
1596
+ `);
1597
+ s.push(h2), g2 += h2.length;
1598
+ }
1599
+ if (g2 > v) {
1600
+ let t2 = 0, n3 = 0, o2 = g2;
1601
+ const h2 = l2 - T3;
1602
+ let u5 = v;
1603
+ const L = () => I(s, o2, 0, h2, u5), E2 = () => I(
1604
+ s,
1605
+ o2,
1606
+ h2 + 1,
1607
+ s.length,
1608
+ u5,
1609
+ true
1610
+ );
1611
+ d ? ({ lineCount: o2, removals: t2 } = L(), o2 > u5 && (c3 || (u5 -= 1), { lineCount: o2, removals: n3 } = E2())) : (c3 || (u5 -= 1), { lineCount: o2, removals: n3 } = E2(), o2 > u5 && (u5 -= 1, { lineCount: o2, removals: t2 } = L())), t2 > 0 && (d = true, s.splice(0, t2)), n3 > 0 && (c3 = true, s.splice(s.length - n3, n3));
1612
+ }
1613
+ const x2 = [];
1614
+ d && x2.push(M2);
1615
+ for (const t2 of s)
1616
+ for (const n3 of t2)
1617
+ x2.push(n3);
1618
+ return c3 && x2.push(M2), x2;
1619
+ };
1620
+ function E(t2) {
1621
+ return t2.label ?? String(t2.value ?? "");
1622
+ }
1623
+ function P2(t2, c3) {
1624
+ if (!t2)
1625
+ return true;
1626
+ const n3 = (c3.label ?? String(c3.value ?? "")).toLowerCase(), i2 = (c3.hint ?? "").toLowerCase(), r2 = String(c3.value).toLowerCase(), o2 = t2.toLowerCase();
1627
+ return n3.includes(o2) || i2.includes(o2) || r2.includes(o2);
1628
+ }
1629
+ function j(t2, c3) {
1630
+ const n3 = [];
1631
+ for (const i2 of c3)
1632
+ t2.includes(i2.value) && n3.push(i2);
1633
+ return n3;
1634
+ }
1635
+ var autocomplete = (t2) => new T$1({
1636
+ options: t2.options,
1637
+ initialValue: t2.initialValue ? [t2.initialValue] : void 0,
1638
+ initialUserInput: t2.initialUserInput,
1639
+ placeholder: t2.placeholder,
1640
+ completeOnTab: t2.completeOnTab,
1641
+ filter: t2.filter ?? ((n3, i2) => P2(n3, i2)),
1642
+ signal: t2.signal,
1643
+ input: t2.input,
1644
+ output: t2.output,
1645
+ validate: t2.validate,
1646
+ render() {
1647
+ const n3 = t2.withGuide ?? settings.withGuide, i2 = n3 ? [`${styleText2("gray", S_BAR)}`, `${symbol(this.state)} ${t2.message}`] : [`${symbol(this.state)} ${t2.message}`], r2 = this.userInput, o2 = this.options, m3 = t2.placeholder, p3 = r2 === "" && m3 !== void 0, $ = (l2, s) => {
1648
+ const a2 = E(l2), u5 = l2.hint && l2.value === this.focusedValue ? styleText2("dim", ` (${l2.hint})`) : "";
1649
+ switch (s) {
1650
+ case "active":
1651
+ return `${styleText2("green", S_RADIO_ACTIVE)} ${a2}${u5}`;
1652
+ case "inactive":
1653
+ return `${styleText2("dim", S_RADIO_INACTIVE)} ${styleText2("dim", a2)}`;
1654
+ case "disabled":
1655
+ return `${styleText2("gray", S_RADIO_INACTIVE)} ${styleText2(["strikethrough", "gray"], a2)}`;
1656
+ }
1657
+ };
1658
+ switch (this.state) {
1659
+ case "submit": {
1660
+ const l2 = j(this.selectedValues, o2), s = l2.length > 0 ? ` ${styleText2("dim", l2.map(E).join(", "))}` : "", a2 = n3 ? styleText2("gray", S_BAR) : "";
1661
+ return `${i2.join(`
1662
+ `)}
1663
+ ${a2}${s}`;
1664
+ }
1665
+ case "cancel": {
1666
+ const l2 = r2 ? ` ${styleText2(["strikethrough", "dim"], r2)}` : "", s = n3 ? styleText2("gray", S_BAR) : "";
1667
+ return `${i2.join(`
1668
+ `)}
1669
+ ${s}${l2}`;
1670
+ }
1671
+ default: {
1672
+ const l2 = this.state === "error" ? "yellow" : "cyan", s = n3 ? `${styleText2(l2, S_BAR)} ` : "", a2 = n3 ? styleText2(l2, S_BAR_END) : "";
1673
+ let u5 = "";
1674
+ if (this.isNavigating || p3) {
1675
+ const d = p3 ? m3 : r2;
1676
+ u5 = d !== "" ? ` ${styleText2("dim", d)}` : "";
1677
+ } else
1678
+ u5 = ` ${this.userInputWithCursor}`;
1679
+ const V = this.filteredOptions.length !== o2.length ? styleText2(
1680
+ "dim",
1681
+ ` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`
1682
+ ) : "", b3 = this.filteredOptions.length === 0 && r2 ? [`${s}${styleText2("yellow", "No matches found")}`] : [], y2 = this.state === "error" ? [`${s}${styleText2("yellow", this.error)}`] : [];
1683
+ n3 && i2.push(`${s.trimEnd()}`), i2.push(
1684
+ `${s}${styleText2("dim", "Search:")}${u5}${V}`,
1685
+ ...b3,
1686
+ ...y2
1687
+ );
1688
+ const S = [
1689
+ `${styleText2("dim", "\u2191/\u2193")} to select`,
1690
+ ...t2.completeOnTab ? [`${styleText2("dim", "Tab:")} complete`] : [],
1691
+ `${styleText2("dim", "Enter:")} confirm`,
1692
+ `${styleText2("dim", "Type:")} to search`
1693
+ ], g2 = [`${s}${S.join(" \u2022 ")}`, a2], O = this.filteredOptions.length === 0 ? [] : limitOptions({
1694
+ cursor: this.cursor,
1695
+ options: this.filteredOptions,
1696
+ columnPadding: n3 ? 3 : 0,
1697
+ // for `| ` when guide is shown
1698
+ rowPadding: i2.length + g2.length,
1699
+ style: (d, f2) => $(
1700
+ d,
1701
+ d.disabled ? "disabled" : f2 ? "active" : "inactive"
1702
+ ),
1703
+ maxItems: t2.maxItems,
1704
+ output: t2.output
1705
+ });
1706
+ return [
1707
+ ...i2,
1708
+ ...O.map((d) => `${s}${d}`),
1709
+ ...g2
1710
+ ].join(`
1711
+ `);
1712
+ }
1713
+ }
1714
+ }
1715
+ }).prompt();
1716
+ var autocompleteMultiselect = (t2) => {
1717
+ const c3 = (i2, r2, o2, m3) => {
1718
+ const p3 = o2.includes(i2.value), $ = i2.label ?? String(i2.value ?? ""), l2 = i2.hint && m3 !== void 0 && i2.value === m3 ? styleText2("dim", ` (${i2.hint})`) : "", s = p3 ? styleText2("green", S_CHECKBOX_SELECTED) : styleText2("dim", S_CHECKBOX_INACTIVE);
1719
+ return i2.disabled ? `${styleText2("gray", S_CHECKBOX_INACTIVE)} ${styleText2(["strikethrough", "gray"], $)}` : r2 ? `${s} ${$}${l2}` : `${s} ${styleText2("dim", $)}`;
1720
+ }, n3 = new T$1({
1721
+ options: t2.options,
1722
+ multiple: true,
1723
+ placeholder: t2.placeholder,
1724
+ filter: t2.filter ?? ((i2, r2) => P2(i2, r2)),
1725
+ validate: () => {
1726
+ if (t2.required && n3.selectedValues.length === 0)
1727
+ return "Please select at least one item";
1728
+ },
1729
+ initialValue: t2.initialValues,
1730
+ signal: t2.signal,
1731
+ input: t2.input,
1732
+ output: t2.output,
1733
+ render() {
1734
+ const i2 = t2.withGuide ?? settings.withGuide, r2 = `${i2 ? `${styleText2("gray", S_BAR)}
1735
+ ` : ""}${symbol(this.state)} ${t2.message}
1736
+ `, o2 = this.userInput, m3 = t2.placeholder, p3 = o2 === "" && m3 !== void 0, $ = this.isNavigating || p3 ? styleText2("dim", p3 ? m3 : o2) : this.userInputWithCursor, l2 = this.options, s = this.filteredOptions.length !== l2.length ? styleText2(
1737
+ "dim",
1738
+ ` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`
1739
+ ) : "";
1740
+ switch (this.state) {
1741
+ case "submit":
1742
+ return `${r2}${i2 ? `${styleText2("gray", S_BAR)} ` : ""}${styleText2(
1743
+ "dim",
1744
+ `${this.selectedValues.length} items selected`
1745
+ )}`;
1746
+ case "cancel":
1747
+ return `${r2}${i2 ? `${styleText2("gray", S_BAR)} ` : ""}${styleText2(
1748
+ ["strikethrough", "dim"],
1749
+ o2
1750
+ )}`;
1751
+ default: {
1752
+ const a2 = this.state === "error" ? "yellow" : "cyan", u5 = i2 ? `${styleText2(a2, S_BAR)} ` : "", V = i2 ? styleText2(a2, S_BAR_END) : "", b3 = [
1753
+ `${styleText2("dim", "\u2191/\u2193")} to navigate`,
1754
+ `${styleText2("dim", this.isNavigating ? "Space/Tab:" : "Tab:")} select`,
1755
+ `${styleText2("dim", "Enter:")} confirm`,
1756
+ `${styleText2("dim", "Type:")} to search`
1757
+ ], y2 = this.filteredOptions.length === 0 && o2 ? [`${u5}${styleText2("yellow", "No matches found")}`] : [], S = this.state === "error" ? [`${u5}${styleText2("yellow", this.error)}`] : [], g2 = [
1758
+ ...`${r2}${i2 ? styleText2(a2, S_BAR) : ""}`.split(`
1759
+ `),
1760
+ `${u5}${styleText2("dim", "Search:")} ${$}${s}`,
1761
+ ...y2,
1762
+ ...S
1763
+ ], O = [`${u5}${b3.join(" \u2022 ")}`, V], d = limitOptions({
1764
+ cursor: this.cursor,
1765
+ options: this.filteredOptions,
1766
+ style: (f2, L) => c3(f2, L, this.selectedValues, this.focusedValue),
1767
+ maxItems: t2.maxItems,
1768
+ output: t2.output,
1769
+ rowPadding: g2.length + O.length
1770
+ });
1771
+ return [
1772
+ ...g2,
1773
+ ...d.map((f2) => `${u5}${f2}`),
1774
+ ...O
1775
+ ].join(`
1776
+ `);
1777
+ }
1778
+ }
1779
+ }
1780
+ });
1781
+ return n3.prompt();
1782
+ };
1783
+ var K = [
1784
+ S_CORNER_TOP_LEFT,
1785
+ S_CORNER_TOP_RIGHT,
1786
+ S_CORNER_BOTTOM_LEFT,
1787
+ S_CORNER_BOTTOM_RIGHT
1788
+ ];
1789
+ var Q = [S_BAR_START, S_BAR_START_RIGHT, S_BAR_END, S_BAR_END_RIGHT];
1790
+ function A$1(n3, e, t2, o2) {
1791
+ let i2 = t2, f2 = t2;
1792
+ return o2 === "center" ? i2 = Math.floor((e - n3) / 2) : o2 === "right" && (i2 = e - n3 - t2), f2 = e - i2 - n3, [i2, f2];
1793
+ }
1794
+ var U2 = (n3) => n3;
1795
+ var box = (n3 = "", e = "", t2) => {
1796
+ const o2 = t2?.output ?? process.stdout, i2 = getColumns(o2), R2 = 1 * 2, u5 = t2?.titlePadding ?? 1, h2 = t2?.contentPadding ?? 2, w = t2?.width === void 0 || t2.width === "auto" ? 1 : Math.min(1, t2.width), m3 = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR)} ` : "", b3 = t2?.formatBorder ?? U2, a2 = (t2?.rounded ? K : Q).map(b3), _2 = b3(S_BAR_H), p3 = b3(S_BAR), x2 = dist_default2(m3), B = dist_default2(e), y2 = i2 - x2;
1797
+ let r2 = Math.floor(i2 * w) - x2;
1798
+ if (t2?.width === "auto") {
1799
+ const c3 = n3.split(`
1800
+ `);
1801
+ let s = B + u5 * 2;
1802
+ for (const G of c3) {
1803
+ const P3 = dist_default2(G) + h2 * 2;
1804
+ P3 > s && (s = P3);
1805
+ }
1806
+ const g2 = s + R2;
1807
+ g2 < r2 && (r2 = g2);
1808
+ }
1809
+ r2 % 2 !== 0 && (r2 < y2 ? r2++ : r2--);
1810
+ const d = r2 - R2, T3 = d - u5 * 2, S = B > T3 ? `${e.slice(0, T3 - 3)}...` : e, [O, W2] = A$1(
1811
+ dist_default2(S),
1812
+ d,
1813
+ u5,
1814
+ t2?.titleAlign
1815
+ ), L = wrapAnsi(n3, d - h2 * 2, {
1816
+ hard: true,
1817
+ trim: false
1818
+ });
1819
+ o2.write(
1820
+ `${m3}${a2[0]}${_2.repeat(O)}${S}${_2.repeat(W2)}${a2[1]}
1821
+ `
1822
+ );
1823
+ const E2 = L.split(`
1824
+ `);
1825
+ for (const c3 of E2) {
1826
+ const [s, g2] = A$1(
1827
+ dist_default2(c3),
1828
+ d,
1829
+ h2,
1830
+ t2?.contentAlign
1831
+ );
1832
+ o2.write(
1833
+ `${m3}${p3}${" ".repeat(s)}${c3}${" ".repeat(g2)}${p3}
1834
+ `
1835
+ );
1836
+ }
1837
+ o2.write(`${m3}${a2[2]}${_2.repeat(d)}${a2[3]}
1838
+ `);
1839
+ };
1840
+ var confirm = (e) => {
1841
+ const a2 = e.active ?? "Yes", o2 = e.inactive ?? "No";
1842
+ return new r({
1843
+ active: a2,
1844
+ inactive: o2,
1845
+ signal: e.signal,
1846
+ input: e.input,
1847
+ output: e.output,
1848
+ initialValue: e.initialValue ?? true,
1849
+ render() {
1850
+ const i2 = e.withGuide ?? settings.withGuide, u5 = `${symbol(this.state)} `, l2 = i2 ? `${styleText2("gray", S_BAR)} ` : "", f2 = wrapTextWithPrefix(
1851
+ e.output,
1852
+ e.message,
1853
+ l2,
1854
+ u5
1855
+ ), s = `${i2 ? `${styleText2("gray", S_BAR)}
1856
+ ` : ""}${f2}
1857
+ `, c3 = this.value ? a2 : o2;
1858
+ switch (this.state) {
1859
+ case "submit": {
1860
+ const r2 = i2 ? `${styleText2("gray", S_BAR)} ` : "";
1861
+ return `${s}${r2}${styleText2("dim", c3)}`;
1862
+ }
1863
+ case "cancel": {
1864
+ const r2 = i2 ? `${styleText2("gray", S_BAR)} ` : "";
1865
+ return `${s}${r2}${styleText2(["strikethrough", "dim"], c3)}${i2 ? `
1866
+ ${styleText2("gray", S_BAR)}` : ""}`;
1867
+ }
1868
+ default: {
1869
+ const r2 = i2 ? `${styleText2("cyan", S_BAR)} ` : "", g2 = i2 ? styleText2("cyan", S_BAR_END) : "";
1870
+ return `${s}${r2}${this.value ? `${styleText2("green", S_RADIO_ACTIVE)} ${a2}` : `${styleText2("dim", S_RADIO_INACTIVE)} ${styleText2("dim", a2)}`}${e.vertical ? i2 ? `
1871
+ ${styleText2("cyan", S_BAR)} ` : `
1872
+ ` : ` ${styleText2("dim", "/")} `}${this.value ? `${styleText2("dim", S_RADIO_INACTIVE)} ${styleText2("dim", o2)}` : `${styleText2("green", S_RADIO_ACTIVE)} ${o2}`}
1873
+ ${g2}
1874
+ `;
1875
+ }
1876
+ }
1877
+ }
1878
+ }).prompt();
1879
+ };
1880
+ var date = (e) => {
1881
+ const r2 = e.validate;
1882
+ return new U({
1883
+ ...e,
1884
+ validate(t2) {
1885
+ if (t2 === void 0)
1886
+ return e.defaultValue !== void 0 ? void 0 : r2 ? runValidation(r2, t2) : settings.date.messages.required;
1887
+ const o2 = (i2) => i2.toISOString().slice(0, 10);
1888
+ if (e.minDate && o2(t2) < o2(e.minDate))
1889
+ return settings.date.messages.afterMin(e.minDate);
1890
+ if (e.maxDate && o2(t2) > o2(e.maxDate))
1891
+ return settings.date.messages.beforeMax(e.maxDate);
1892
+ if (r2) return runValidation(r2, t2);
1893
+ },
1894
+ render() {
1895
+ const t2 = (e?.withGuide ?? settings.withGuide) !== false, i2 = `${`${t2 ? `${styleText2("gray", S_BAR)}
1896
+ ` : ""}${symbol(this.state)} `}${e.message}
1897
+ `, l2 = this.state !== "initial" ? this.state : "active", d = b2(this, l2), c3 = this.value instanceof Date ? this.formattedValue : "";
1898
+ switch (this.state) {
1899
+ case "error": {
1900
+ const a2 = this.error ? ` ${styleText2("yellow", this.error)}` : "", s = t2 ? `${styleText2("yellow", S_BAR)} ` : "", f2 = t2 ? styleText2("yellow", S_BAR_END) : "";
1901
+ return `${i2.trim()}
1902
+ ${s}${d}
1903
+ ${f2}${a2}
1904
+ `;
1905
+ }
1906
+ case "submit": {
1907
+ const a2 = c3 ? ` ${styleText2("dim", c3)}` : "", s = t2 ? styleText2("gray", S_BAR) : "";
1908
+ return `${i2}${s}${a2}`;
1909
+ }
1910
+ case "cancel": {
1911
+ const a2 = c3 ? ` ${styleText2(["strikethrough", "dim"], c3)}` : "", s = t2 ? styleText2("gray", S_BAR) : "";
1912
+ return `${i2}${s}${a2}${c3.trim() ? `
1913
+ ${s}` : ""}`;
1914
+ }
1915
+ default: {
1916
+ const a2 = t2 ? `${styleText2("cyan", S_BAR)} ` : "", s = t2 ? styleText2("cyan", S_BAR_END) : "", f2 = t2 ? `${styleText2("cyan", S_BAR)} ` : "", g2 = this.inlineError ? `
1917
+ ${f2}${styleText2("yellow", this.inlineError)}` : "";
1918
+ return `${i2}${a2}${d}${g2}
1919
+ ${s}
1920
+ `;
1921
+ }
1922
+ }
1923
+ }
1924
+ }).prompt();
1925
+ };
1926
+ function b2(e, r2) {
1927
+ const t2 = e.segmentValues, o2 = e.segmentCursor;
1928
+ if (r2 === "submit" || r2 === "cancel")
1929
+ return e.formattedValue;
1930
+ const i2 = styleText2("gray", e.separator);
1931
+ return e.segments.map((l2, d) => {
1932
+ const c3 = d === o2.segmentIndex && !["submit", "cancel"].includes(r2), a2 = p2[l2.type];
1933
+ return x(t2[l2.type], { isActive: c3, label: a2 });
1934
+ }).join(i2);
1935
+ }
1936
+ function x(e, r2) {
1937
+ const t2 = !e || e.replace(/_/g, "") === "";
1938
+ return r2.isActive ? styleText2("inverse", t2 ? r2.label : e.replace(/_/g, " ")) : t2 ? styleText2("dim", r2.label) : e.replace(/_/g, styleText2("dim", " "));
1939
+ }
1940
+ var p2 = {
1941
+ year: "yyyy",
1942
+ month: "mm",
1943
+ day: "dd"
1944
+ };
1945
+ var group = async (o2, r2) => {
1946
+ const t2 = {}, p3 = Object.keys(o2);
1947
+ for (const e of p3) {
1948
+ const i2 = o2[e], n3 = await i2({ results: t2 })?.catch((a2) => {
1949
+ throw a2;
1950
+ });
1951
+ if (typeof r2?.onCancel == "function" && isCancel(n3)) {
1952
+ t2[e] = "canceled", r2.onCancel({ results: t2 });
1953
+ continue;
1954
+ }
1955
+ t2[e] = n3;
1956
+ }
1957
+ return t2;
1958
+ };
1959
+ var MULTISELECT_INSTRUCTIONS = [
1960
+ `${styleText2("dim", "\u2191/\u2193")} to navigate`,
1961
+ `${styleText2("dim", "Space:")} select`,
1962
+ `${styleText2("dim", "Enter:")} confirm`
1963
+ ];
1964
+ var m2 = (i2, u5) => i2.split(`
1965
+ `).map((d) => u5(d)).join(`
1966
+ `);
1967
+ var multiselect = (i2) => {
1968
+ const u5 = (t2, a2) => {
1969
+ const r2 = t2.label ?? String(t2.value);
1970
+ return a2 === "disabled" ? `${styleText2("gray", S_CHECKBOX_INACTIVE)} ${m2(r2, (o2) => styleText2(["strikethrough", "gray"], o2))}${t2.hint ? ` ${styleText2("dim", `(${t2.hint ?? "disabled"})`)}` : ""}` : a2 === "active" ? `${styleText2("cyan", S_CHECKBOX_ACTIVE)} ${r2}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : a2 === "selected" ? `${styleText2("green", S_CHECKBOX_SELECTED)} ${m2(r2, (o2) => styleText2("dim", o2))}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : a2 === "cancelled" ? `${m2(r2, (o2) => styleText2(["strikethrough", "dim"], o2))}` : a2 === "active-selected" ? `${styleText2("green", S_CHECKBOX_SELECTED)} ${r2}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : a2 === "submitted" ? `${m2(r2, (o2) => styleText2("dim", o2))}` : `${styleText2("dim", S_CHECKBOX_INACTIVE)} ${m2(r2, (o2) => styleText2("dim", o2))}`;
1971
+ }, d = i2.required ?? true, x2 = i2.showInstructions ?? true;
1972
+ return new a({
1973
+ options: i2.options,
1974
+ signal: i2.signal,
1975
+ input: i2.input,
1976
+ output: i2.output,
1977
+ initialValues: i2.initialValues,
1978
+ required: d,
1979
+ cursorAt: i2.cursorAt,
1980
+ validate(t2) {
1981
+ if (d && (t2 === void 0 || t2.length === 0))
1982
+ return `Please select at least one option.
1983
+ ${styleText2(
1984
+ "reset",
1985
+ styleText2(
1986
+ "dim",
1987
+ `Press ${styleText2(["gray", "bgWhite", "inverse"], " space ")} to select, ${styleText2(
1988
+ "gray",
1989
+ styleText2("bgWhite", styleText2("inverse", " enter "))
1990
+ )} to submit`
1991
+ )
1992
+ )}`;
1993
+ },
1994
+ render() {
1995
+ const t2 = i2.withGuide ?? settings.withGuide, a2 = wrapTextWithPrefix(
1996
+ i2.output,
1997
+ i2.message,
1998
+ t2 ? `${symbolBar(this.state)} ` : "",
1999
+ `${symbol(this.state)} `
2000
+ ), r2 = `${t2 ? `${styleText2("gray", S_BAR)}
2001
+ ` : ""}${a2}
2002
+ `, o2 = this.value ?? [], g2 = (n3, l2) => {
2003
+ if (n3.disabled)
2004
+ return u5(n3, "disabled");
2005
+ const s = o2.includes(n3.value);
2006
+ return l2 && s ? u5(n3, "active-selected") : s ? u5(n3, "selected") : u5(n3, l2 ? "active" : "inactive");
2007
+ };
2008
+ switch (this.state) {
2009
+ case "submit": {
2010
+ const n3 = this.options.filter(({ value: s }) => o2.includes(s)).map((s) => u5(s, "submitted")).join(styleText2("dim", ", ")) || styleText2("dim", "none"), l2 = wrapTextWithPrefix(
2011
+ i2.output,
2012
+ n3,
2013
+ t2 ? `${styleText2("gray", S_BAR)} ` : ""
2014
+ );
2015
+ return `${r2}${l2}`;
2016
+ }
2017
+ case "cancel": {
2018
+ const n3 = this.options.filter(({ value: s }) => o2.includes(s)).map((s) => u5(s, "cancelled")).join(styleText2("dim", ", "));
2019
+ if (n3.trim() === "")
2020
+ return `${r2}${styleText2("gray", S_BAR)}`;
2021
+ const l2 = wrapTextWithPrefix(
2022
+ i2.output,
2023
+ n3,
2024
+ t2 ? `${styleText2("gray", S_BAR)} ` : ""
2025
+ );
2026
+ return `${r2}${l2}${t2 ? `
2027
+ ${styleText2("gray", S_BAR)}` : ""}`;
2028
+ }
2029
+ case "error": {
2030
+ const n3 = t2 ? `${styleText2("yellow", S_BAR)} ` : "", l2 = this.error.split(`
2031
+ `).map(
2032
+ ($, v) => v === 0 ? `${t2 ? `${styleText2("yellow", S_BAR_END)} ` : ""}${styleText2("yellow", $)}` : ` ${$}`
2033
+ ).join(`
2034
+ `), s = r2.split(`
2035
+ `).length, h2 = l2.split(`
2036
+ `).length + 1;
2037
+ return `${r2}${n3}${limitOptions({
2038
+ output: i2.output,
2039
+ options: this.options,
2040
+ cursor: this.cursor,
2041
+ maxItems: i2.maxItems,
2042
+ columnPadding: n3.length,
2043
+ rowPadding: s + h2,
2044
+ style: g2
2045
+ }).join(`
2046
+ ${n3}`)}
2047
+ ${l2}
2048
+ `;
2049
+ }
2050
+ default: {
2051
+ const n3 = t2 ? `${styleText2("cyan", S_BAR)} ` : "", l2 = r2.split(`
2052
+ `).length, s = x2 ? formatInstructionFooter(MULTISELECT_INSTRUCTIONS, t2) : t2 ? [styleText2("cyan", S_BAR_END)] : [], h2 = s.join(`
2053
+ `), $ = s.length + 1;
2054
+ return `${r2}${n3}${limitOptions({
2055
+ output: i2.output,
2056
+ options: this.options,
2057
+ cursor: this.cursor,
2058
+ maxItems: i2.maxItems,
2059
+ columnPadding: n3.length,
2060
+ rowPadding: l2 + $,
2061
+ style: g2
2062
+ }).join(`
2063
+ ${n3}`)}
2064
+ ${h2}
2065
+ `;
2066
+ }
2067
+ }
2068
+ }
2069
+ }).prompt();
2070
+ };
2071
+ var groupMultiselect = (o2) => {
2072
+ const { selectableGroups: f2 = true, groupSpacing: x2 = 0 } = o2, d = (n3, l2, p3 = []) => {
2073
+ const a2 = n3.label ?? String(n3.value), t2 = typeof n3.group == "string", s = t2 && (p3[p3.indexOf(n3) + 1] ?? { group: true }), u5 = t2 && s && s.group === true;
2074
+ let r2 = "", c3 = "";
2075
+ t2 && (f2 ? (r2 = u5 ? `${S_BAR_END} ` : `${S_BAR} `, c3 = u5 ? " " : `${S_BAR} `) : r2 = " ");
2076
+ let i2 = "";
2077
+ if (x2 > 0 && !t2 && (i2 = `
2078
+ `.repeat(x2)), l2 === "active")
2079
+ return wrapTextWithPrefix(
2080
+ o2.output,
2081
+ `${a2}${n3.hint ? ` ${styleText2("dim", `(${n3.hint})`)}` : ""}`,
2082
+ `${i2}${styleText2("dim", r2)} `,
2083
+ `${i2}${styleText2("dim", r2)}${styleText2("cyan", S_CHECKBOX_ACTIVE)} `,
2084
+ `${i2}${styleText2("dim", c3)} `
2085
+ );
2086
+ if (l2 === "group-active")
2087
+ return wrapTextWithPrefix(
2088
+ o2.output,
2089
+ a2,
2090
+ `${i2}${r2} `,
2091
+ `${i2}${r2}${styleText2("cyan", S_CHECKBOX_ACTIVE)} `,
2092
+ `${i2}${c3} `,
2093
+ (m3) => styleText2("dim", m3)
2094
+ );
2095
+ if (l2 === "group-active-selected")
2096
+ return wrapTextWithPrefix(
2097
+ o2.output,
2098
+ a2,
2099
+ `${i2}${r2} `,
2100
+ `${i2}${r2}${styleText2("green", S_CHECKBOX_SELECTED)} `,
2101
+ `${i2}${c3} `,
2102
+ (m3) => styleText2("dim", m3)
2103
+ );
2104
+ if (l2 === "selected") {
2105
+ const m3 = t2 || f2 ? styleText2("green", S_CHECKBOX_SELECTED) : "";
2106
+ return wrapTextWithPrefix(
2107
+ o2.output,
2108
+ `${a2}${n3.hint ? ` (${n3.hint})` : ""}`,
2109
+ `${i2}${styleText2("dim", r2)} `,
2110
+ `${i2}${styleText2("dim", r2)}${m3} `,
2111
+ `${i2}${styleText2("dim", c3)} `,
2112
+ (I2) => styleText2("dim", I2)
2113
+ );
2114
+ }
2115
+ if (l2 === "cancelled")
2116
+ return `${styleText2(["strikethrough", "dim"], a2)}`;
2117
+ if (l2 === "active-selected")
2118
+ return wrapTextWithPrefix(
2119
+ o2.output,
2120
+ `${a2}${n3.hint ? ` ${styleText2("dim", `(${n3.hint})`)}` : ""}`,
2121
+ `${i2}${styleText2("dim", r2)} `,
2122
+ `${i2}${styleText2("dim", r2)}${styleText2("green", S_CHECKBOX_SELECTED)} `,
2123
+ `${i2}${styleText2("dim", c3)} `
2124
+ );
2125
+ if (l2 === "submitted")
2126
+ return `${styleText2("dim", a2)}`;
2127
+ const h2 = t2 || f2 ? styleText2("dim", S_CHECKBOX_INACTIVE) : "";
2128
+ return wrapTextWithPrefix(
2129
+ o2.output,
2130
+ a2,
2131
+ `${i2}${styleText2("dim", r2)} `,
2132
+ `${i2}${styleText2("dim", r2)}${h2} `,
2133
+ `${i2}${styleText2("dim", c3)} `,
2134
+ (m3) => styleText2("dim", m3)
2135
+ );
2136
+ }, y2 = o2.required ?? true, S = o2.showInstructions ?? true;
2137
+ return new u$2({
2138
+ options: o2.options,
2139
+ signal: o2.signal,
2140
+ input: o2.input,
2141
+ output: o2.output,
2142
+ initialValues: o2.initialValues,
2143
+ required: y2,
2144
+ cursorAt: o2.cursorAt,
2145
+ selectableGroups: f2,
2146
+ validate(n3) {
2147
+ if (y2 && (n3 === void 0 || n3.length === 0))
2148
+ return `Please select at least one option.
2149
+ ${styleText2(
2150
+ "reset",
2151
+ styleText2(
2152
+ "dim",
2153
+ `Press ${styleText2(["gray", "bgWhite", "inverse"], " space ")} to select, ${styleText2(
2154
+ "gray",
2155
+ styleText2(["bgWhite", "inverse"], " enter ")
2156
+ )} to submit`
2157
+ )
2158
+ )}`;
2159
+ },
2160
+ render() {
2161
+ const n3 = o2.withGuide ?? settings.withGuide, l2 = `${n3 ? `${styleText2("gray", S_BAR)}
2162
+ ` : ""}${symbol(this.state)} ${o2.message}
2163
+ `, p3 = this.value ?? [], a2 = (t2, s) => {
2164
+ const u5 = this.options, r2 = p3.includes(t2.value) || t2.group === true && this.isGroupSelected(`${t2.value}`);
2165
+ return !s && typeof t2.group == "string" && this.options[this.cursor]?.value === t2.group ? d(t2, r2 ? "group-active-selected" : "group-active", u5) : s && r2 ? d(t2, "active-selected", u5) : r2 ? d(t2, "selected", u5) : d(t2, s ? "active" : "inactive", u5);
2166
+ };
2167
+ switch (this.state) {
2168
+ case "submit": {
2169
+ const t2 = this.options.filter(({ value: u5 }) => p3.includes(u5)).map((u5) => d(u5, "submitted")), s = t2.length === 0 ? "" : ` ${t2.join(styleText2("dim", ", "))}`;
2170
+ return `${l2}${n3 ? styleText2("gray", S_BAR) : ""}${s}`;
2171
+ }
2172
+ case "cancel": {
2173
+ const t2 = this.options.filter(({ value: s }) => p3.includes(s)).map((s) => d(s, "cancelled")).join(styleText2("dim", ", "));
2174
+ return `${l2}${n3 ? `${styleText2("gray", S_BAR)} ` : ""}${t2.trim() ? `${t2}${n3 ? `
2175
+ ${styleText2("gray", S_BAR)}` : ""}` : ""}`;
2176
+ }
2177
+ case "error": {
2178
+ const t2 = n3 ? `${styleText2("yellow", S_BAR)} ` : "", s = this.error.split(`
2179
+ `).map(
2180
+ (i2, h2) => h2 === 0 ? `${n3 ? `${styleText2("yellow", S_BAR_END)} ` : ""}${styleText2("yellow", i2)}` : ` ${i2}`
2181
+ ).join(`
2182
+ `), u5 = l2.split(`
2183
+ `).length, r2 = s.split(`
2184
+ `).length + 1, c3 = limitOptions({
2185
+ output: o2.output,
2186
+ options: this.options,
2187
+ cursor: this.cursor,
2188
+ maxItems: o2.maxItems,
2189
+ columnPadding: t2.length,
2190
+ rowPadding: u5 + r2,
2191
+ style: a2
2192
+ }).join(`
2193
+ ${t2}`);
2194
+ return `${l2}${t2}${c3}
2195
+ ${s}
2196
+ `;
2197
+ }
2198
+ default: {
2199
+ const t2 = n3 ? `${styleText2("cyan", S_BAR)} ` : "", s = l2.split(`
2200
+ `).length, u5 = S ? formatInstructionFooter(MULTISELECT_INSTRUCTIONS, n3) : n3 ? [styleText2("cyan", S_BAR_END)] : [], r2 = u5.join(`
2201
+ `), c3 = u5.length + 1, i2 = limitOptions({
2202
+ output: o2.output,
2203
+ options: this.options,
2204
+ cursor: this.cursor,
2205
+ maxItems: o2.maxItems,
2206
+ columnPadding: t2.length,
2207
+ rowPadding: s + c3,
2208
+ style: a2
2209
+ }).join(`
2210
+ ${t2}`);
2211
+ return `${l2}${t2}${i2}
2212
+ ${r2}
2213
+ `;
2214
+ }
2215
+ }
2216
+ }
2217
+ }).prompt();
2218
+ };
2219
+ var log = {
2220
+ message: (s = [], {
2221
+ symbol: e = styleText2("gray", S_BAR),
2222
+ secondarySymbol: r2 = styleText2("gray", S_BAR),
2223
+ output: m3 = process.stdout,
2224
+ spacing: l2 = 1,
2225
+ withGuide: c3
2226
+ } = {}) => {
2227
+ const t2 = [], o2 = c3 ?? settings.withGuide, f2 = o2 ? r2 : "", O = o2 ? `${e} ` : "", u5 = o2 ? `${r2} ` : "";
2228
+ for (let i2 = 0; i2 < l2; i2++)
2229
+ t2.push(f2);
2230
+ const g2 = Array.isArray(s) ? s : s.split(`
2231
+ `);
2232
+ if (g2.length > 0) {
2233
+ const [i2, ...y2] = g2;
2234
+ i2.length > 0 ? t2.push(`${O}${i2}`) : t2.push(o2 ? e : "");
2235
+ for (const p3 of y2)
2236
+ p3.length > 0 ? t2.push(`${u5}${p3}`) : t2.push(o2 ? r2 : "");
2237
+ }
2238
+ m3.write(`${t2.join(`
2239
+ `)}
2240
+ `);
2241
+ },
2242
+ info: (s, e) => {
2243
+ log.message(s, { ...e, symbol: styleText2("blue", S_INFO) });
2244
+ },
2245
+ success: (s, e) => {
2246
+ log.message(s, { ...e, symbol: styleText2("green", S_SUCCESS) });
2247
+ },
2248
+ step: (s, e) => {
2249
+ log.message(s, { ...e, symbol: styleText2("green", S_STEP_SUBMIT) });
2250
+ },
2251
+ warn: (s, e) => {
2252
+ log.message(s, { ...e, symbol: styleText2("yellow", S_WARN) });
2253
+ },
2254
+ /** alias for `log.warn()`. */
2255
+ warning: (s, e) => {
2256
+ log.warn(s, e);
2257
+ },
2258
+ error: (s, e) => {
2259
+ log.message(s, { ...e, symbol: styleText2("red", S_ERROR) });
2260
+ }
2261
+ };
2262
+ var cancel = (o2 = "", t2) => {
2263
+ const i2 = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR_END)} ` : "";
2264
+ i2.write(`${e}${styleText2("red", o2)}
2265
+
2266
+ `);
2267
+ };
2268
+ var intro = (o2 = "", t2) => {
2269
+ const i2 = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR_START)} ` : "";
2270
+ i2.write(`${e}${o2}
2271
+ `);
2272
+ };
2273
+ var outro = (o2 = "", t2) => {
2274
+ const i2 = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR)}
2275
+ ${styleText2("gray", S_BAR_END)} ` : "";
2276
+ i2.write(`${e}${o2}
2277
+
2278
+ `);
2279
+ };
2280
+ var multiline = (e) => new h({
2281
+ validate: e.validate,
2282
+ placeholder: e.placeholder,
2283
+ defaultValue: e.defaultValue,
2284
+ initialValue: e.initialValue,
2285
+ showSubmit: e.showSubmit,
2286
+ output: e.output,
2287
+ signal: e.signal,
2288
+ input: e.input,
2289
+ render() {
2290
+ const i2 = e?.withGuide ?? settings.withGuide, o2 = `${`${i2 ? `${styleText2("gray", S_BAR)}
2291
+ ` : ""}${symbol(this.state)} `}${e.message}
2292
+ `, h2 = e.placeholder && e.placeholder.length > 0 ? (
2293
+ // biome-ignore lint/style/noNonNullAssertion: guarded by placeholder.length > 0
2294
+ styleText2("inverse", e.placeholder[0]) + styleText2("dim", e.placeholder.slice(1))
2295
+ ) : styleText2(["inverse", "hidden"], "_"), a2 = this.userInput ? this.userInputWithCursor : h2, l2 = this.value ?? "", d = e.showSubmit ? `
2296
+ ${styleText2(this.focused === "submit" ? "cyan" : "dim", "[ submit ]")}` : "";
2297
+ switch (this.state) {
2298
+ case "error": {
2299
+ const n3 = `${styleText2("yellow", S_BAR)} `, r2 = i2 ? wrapTextWithPrefix(e.output, a2, n3, void 0) : a2, u5 = styleText2("yellow", S_BAR_END);
2300
+ return `${o2}${r2}
2301
+ ${u5} ${styleText2("yellow", this.error)}${d}
2302
+ `;
2303
+ }
2304
+ case "submit": {
2305
+ const n3 = `${styleText2("gray", S_BAR)} `, r2 = i2 ? wrapTextWithPrefix(
2306
+ e.output,
2307
+ l2,
2308
+ n3,
2309
+ void 0,
2310
+ void 0,
2311
+ (u5) => styleText2("dim", u5)
2312
+ ) : l2 ? styleText2("dim", l2) : "";
2313
+ return `${o2}${r2}`;
2314
+ }
2315
+ case "cancel": {
2316
+ const n3 = `${styleText2("gray", S_BAR)} `, r2 = i2 ? wrapTextWithPrefix(
2317
+ e.output,
2318
+ l2,
2319
+ n3,
2320
+ void 0,
2321
+ void 0,
2322
+ (u5) => styleText2(["strikethrough", "dim"], u5)
2323
+ ) : l2 ? styleText2(["strikethrough", "dim"], l2) : "";
2324
+ return `${o2}${r2}`;
2325
+ }
2326
+ default: {
2327
+ const n3 = i2 ? `${styleText2("cyan", S_BAR)} ` : "", r2 = i2 ? styleText2("cyan", S_BAR_END) : "", u5 = i2 ? wrapTextWithPrefix(e.output, a2, n3) : a2;
2328
+ return `${o2}${u5}
2329
+ ${r2}${d}
2330
+ `;
2331
+ }
2332
+ }
2333
+ }
2334
+ }).prompt();
2335
+ var W$1 = (o2) => o2;
2336
+ var C2 = (o2, e, s) => {
2337
+ const a2 = {
2338
+ hard: true,
2339
+ trim: false
2340
+ }, i2 = wrapAnsi(o2, e, a2).split(`
2341
+ `), c3 = i2.reduce((n3, t2) => Math.max(dist_default2(t2), n3), 0), u5 = i2.map(s).reduce((n3, t2) => Math.max(dist_default2(t2), n3), 0), g2 = e - (u5 - c3);
2342
+ return wrapAnsi(o2, g2, a2);
2343
+ };
2344
+ var note = (o2 = "", e = "", s) => {
2345
+ const a2 = s?.output ?? process$1.stdout, i2 = s?.withGuide ?? settings.withGuide, c3 = s?.format ?? W$1, g2 = ["", ...C2(o2, getColumns(a2) - 6, c3).split(`
2346
+ `).map(c3), ""], n3 = dist_default2(e), t2 = Math.max(
2347
+ g2.reduce((m3, F) => {
2348
+ const O = dist_default2(F);
2349
+ return O > m3 ? O : m3;
2350
+ }, 0),
2351
+ n3
2352
+ ) + 2, h2 = g2.map(
2353
+ (m3) => `${styleText2("gray", S_BAR)} ${m3}${" ".repeat(t2 - dist_default2(m3))}${styleText2("gray", S_BAR)}`
2354
+ ).join(`
2355
+ `), T3 = i2 ? `${styleText2("gray", S_BAR)}
2356
+ ` : "", l$1 = i2 ? S_CONNECT_LEFT : S_CORNER_BOTTOM_LEFT;
2357
+ a2.write(
2358
+ `${T3}${styleText2("green", S_STEP_SUBMIT)} ${styleText2("reset", e)} ${styleText2(
2359
+ "gray",
2360
+ S_BAR_H.repeat(Math.max(t2 - n3 - 1, 1)) + S_CORNER_TOP_RIGHT
2361
+ )}
2362
+ ${h2}
2363
+ ${styleText2("gray", l$1 + S_BAR_H.repeat(t2 + 2) + S_CORNER_BOTTOM_RIGHT)}
2364
+ `
2365
+ );
2366
+ };
2367
+ var password = (e) => new u$1({
2368
+ validate: e.validate,
2369
+ mask: e.mask ?? S_PASSWORD_MASK,
2370
+ signal: e.signal,
2371
+ input: e.input,
2372
+ output: e.output,
2373
+ render() {
2374
+ const r2 = e.withGuide ?? settings.withGuide, o2 = `${r2 ? `${styleText2("gray", S_BAR)}
2375
+ ` : ""}${symbol(this.state)} ${e.message}
2376
+ `, m3 = this.userInputWithCursor, i2 = this.masked;
2377
+ switch (this.state) {
2378
+ case "error": {
2379
+ const s = r2 ? `${styleText2("yellow", S_BAR)} ` : "", n3 = r2 ? `${styleText2("yellow", S_BAR_END)} ` : "", d = i2 ?? "";
2380
+ return e.clearOnError && this.clear(), `${o2.trim()}
2381
+ ${s}${d}
2382
+ ${n3}${styleText2("yellow", this.error)}
2383
+ `;
2384
+ }
2385
+ case "submit": {
2386
+ const s = r2 ? `${styleText2("gray", S_BAR)} ` : "", n3 = i2 ? styleText2("dim", i2) : "";
2387
+ return `${o2}${s}${n3}`;
2388
+ }
2389
+ case "cancel": {
2390
+ const s = r2 ? `${styleText2("gray", S_BAR)} ` : "", n3 = i2 ? styleText2(["strikethrough", "dim"], i2) : "";
2391
+ return `${o2}${s}${n3}${i2 && r2 ? `
2392
+ ${styleText2("gray", S_BAR)}` : ""}`;
2393
+ }
2394
+ default: {
2395
+ const s = r2 ? `${styleText2("cyan", S_BAR)} ` : "", n3 = r2 ? styleText2("cyan", S_BAR_END) : "";
2396
+ return `${o2}${s}${m3}
2397
+ ${n3}
2398
+ `;
2399
+ }
2400
+ }
2401
+ }
2402
+ }).prompt();
2403
+ var path = (e) => {
2404
+ const a2 = e.validate;
2405
+ return autocomplete({
2406
+ ...e,
2407
+ initialUserInput: e.initialValue ?? e.root ?? process.cwd(),
2408
+ maxItems: 5,
2409
+ completeOnTab: true,
2410
+ validate(t2) {
2411
+ if (!Array.isArray(t2)) {
2412
+ if (!t2)
2413
+ return "Please select a path";
2414
+ if (a2)
2415
+ return runValidation(a2, t2);
2416
+ }
2417
+ },
2418
+ options() {
2419
+ const t2 = this.userInput;
2420
+ if (t2 === "")
2421
+ return [];
2422
+ try {
2423
+ let i2;
2424
+ existsSync(t2) ? lstatSync(t2).isDirectory() && (!e.directory || t2.endsWith("/")) ? i2 = t2 : i2 = dirname(t2) : i2 = dirname(t2);
2425
+ const c3 = t2.length > 1 && t2.endsWith("/") ? t2.slice(0, -1) : t2;
2426
+ return readdirSync(i2).map((r2) => {
2427
+ const n3 = join(i2, r2), m3 = lstatSync(n3);
2428
+ return {
2429
+ name: r2,
2430
+ path: n3,
2431
+ isDirectory: m3.isDirectory()
2432
+ };
2433
+ }).filter(
2434
+ ({ path: r2, isDirectory: n3 }) => r2.startsWith(c3) && (n3 || !e.directory)
2435
+ ).map((r2) => ({
2436
+ value: r2.path
2437
+ }));
2438
+ } catch {
2439
+ return [];
2440
+ }
2441
+ }
2442
+ });
2443
+ };
2444
+ var W = (l2) => styleText2("magenta", l2);
2445
+ var spinner = ({
2446
+ indicator: l2 = "dots",
2447
+ onCancel: h2,
2448
+ output: n3 = process.stdout,
2449
+ cancelMessage: G,
2450
+ errorMessage: O,
2451
+ frames: E2 = unicode ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"],
2452
+ delay: F = unicode ? 80 : 120,
2453
+ signal: m3,
2454
+ ...I2
2455
+ } = {}) => {
2456
+ const u5 = isCI();
2457
+ let M2, T3, d = false, S = false, s = "", p3, w = performance.now();
2458
+ const x2 = getColumns(n3), k = I2?.styleFrame ?? W, g2 = (e) => {
2459
+ const r2 = e > 1 ? O ?? settings.messages.error : G ?? settings.messages.cancel;
2460
+ S = e === 1, d && (a2(r2, e), S && typeof h2 == "function" && h2());
2461
+ }, f2 = () => g2(2), i2 = () => g2(1), A2 = () => {
2462
+ process.on("uncaughtExceptionMonitor", f2), process.on("unhandledRejection", f2), process.on("SIGINT", i2), process.on("SIGTERM", i2), process.on("exit", g2), m3 && m3.addEventListener("abort", i2);
2463
+ }, H = () => {
2464
+ process.removeListener("uncaughtExceptionMonitor", f2), process.removeListener("unhandledRejection", f2), process.removeListener("SIGINT", i2), process.removeListener("SIGTERM", i2), process.removeListener("exit", g2), m3 && m3.removeEventListener("abort", i2);
2465
+ }, y2 = () => {
2466
+ if (p3 === void 0) return;
2467
+ u5 && n3.write(`
2468
+ `);
2469
+ const r2 = wrapAnsi(p3, x2, {
2470
+ hard: true,
2471
+ trim: false
2472
+ }).split(`
2473
+ `);
2474
+ r2.length > 1 && n3.write(import_sisteransi2.cursor.up(r2.length - 1)), n3.write(import_sisteransi2.cursor.to(0)), n3.write(import_sisteransi2.erase.down());
2475
+ }, C3 = (e) => e.replace(/\.+$/, ""), _2 = (e) => {
2476
+ const r2 = (performance.now() - e) / 1e3, t2 = Math.floor(r2 / 60), o2 = Math.floor(r2 % 60);
2477
+ return t2 > 0 ? `[${t2}m ${o2}s]` : `[${o2}s]`;
2478
+ }, N = I2.withGuide ?? settings.withGuide, P3 = (e = "") => {
2479
+ d = true, M2 = block({ output: n3 }), s = C3(e), w = performance.now(), N && n3.write(`${styleText2("gray", S_BAR)}
2480
+ `);
2481
+ let r2 = 0, t2 = 0;
2482
+ A2(), T3 = setInterval(() => {
2483
+ if (u5 && s === p3)
2484
+ return;
2485
+ y2(), p3 = s;
2486
+ const o2 = k(E2[r2]);
2487
+ let v;
2488
+ if (u5)
2489
+ v = `${o2} ${s}...`;
2490
+ else if (l2 === "timer")
2491
+ v = `${o2} ${s} ${_2(w)}`;
2492
+ else {
2493
+ const B = ".".repeat(Math.floor(t2)).slice(0, 3);
2494
+ v = `${o2} ${s}${B}`;
2495
+ }
2496
+ const j2 = wrapAnsi(v, x2, {
2497
+ hard: true,
2498
+ trim: false
2499
+ });
2500
+ n3.write(j2), r2 = r2 + 1 < E2.length ? r2 + 1 : 0, t2 = t2 < 4 ? t2 + 0.125 : 0;
2501
+ }, F);
2502
+ }, a2 = (e = "", r2 = 0, t2 = false) => {
2503
+ if (!d) return;
2504
+ d = false, clearInterval(T3), y2();
2505
+ const o2 = r2 === 0 ? styleText2("green", S_STEP_SUBMIT) : r2 === 1 ? styleText2("red", S_STEP_CANCEL) : styleText2("red", S_STEP_ERROR);
2506
+ s = e ?? s, t2 || (l2 === "timer" ? n3.write(`${o2} ${s} ${_2(w)}
2507
+ `) : n3.write(`${o2} ${s}
2508
+ `)), H(), M2();
2509
+ };
2510
+ return {
2511
+ start: P3,
2512
+ stop: (e = "") => a2(e, 0),
2513
+ message: (e = "") => {
2514
+ s = C3(e ?? s);
2515
+ },
2516
+ cancel: (e = "") => a2(e, 1),
2517
+ error: (e = "") => a2(e, 2),
2518
+ clear: () => a2("", 0, true),
2519
+ get isCancelled() {
2520
+ return S;
2521
+ }
2522
+ };
2523
+ };
2524
+ var u4 = {
2525
+ light: unicodeOr("\u2500", "-"),
2526
+ heavy: unicodeOr("\u2501", "="),
2527
+ block: unicodeOr("\u2588", "#")
2528
+ };
2529
+ function progress({
2530
+ style: o2 = "heavy",
2531
+ max: d = 100,
2532
+ size: v = 40,
2533
+ ...x2
2534
+ } = {}) {
2535
+ const r2 = spinner(x2);
2536
+ let a2 = 0, n3 = "";
2537
+ const c3 = Math.max(1, d), l2 = Math.max(1, v), S = (t2) => {
2538
+ switch (t2) {
2539
+ case "initial":
2540
+ case "active":
2541
+ return (e) => styleText2("magenta", e);
2542
+ case "error":
2543
+ case "cancel":
2544
+ return (e) => styleText2("red", e);
2545
+ case "submit":
2546
+ return (e) => styleText2("green", e);
2547
+ default:
2548
+ return (e) => styleText2("magenta", e);
2549
+ }
2550
+ }, p3 = (t2, e) => {
2551
+ const m3 = Math.floor(a2 / c3 * l2);
2552
+ return `${S(t2)(u4[o2].repeat(m3))}${styleText2("dim", u4[o2].repeat(l2 - m3))} ${e}`;
2553
+ }, h2 = (t2 = "") => {
2554
+ n3 = t2, r2.start(p3("initial", t2));
2555
+ }, g2 = (t2 = 1, e) => {
2556
+ a2 = Math.min(c3, t2 + a2), r2.message(p3("active", e ?? n3)), n3 = e ?? n3;
2557
+ };
2558
+ return {
2559
+ start: h2,
2560
+ stop: r2.stop,
2561
+ cancel: r2.cancel,
2562
+ error: r2.error,
2563
+ clear: r2.clear,
2564
+ advance: g2,
2565
+ isCancelled: r2.isCancelled,
2566
+ message: (t2) => g2(0, t2)
2567
+ };
2568
+ }
2569
+ var SELECT_INSTRUCTIONS = [
2570
+ `${styleText2("dim", "\u2191/\u2193")} to navigate`,
2571
+ `${styleText2("dim", "Enter:")} confirm`
2572
+ ];
2573
+ var c2 = (t2, o2) => t2.includes(`
2574
+ `) ? t2.split(`
2575
+ `).map((d) => o2(d)).join(`
2576
+ `) : o2(t2);
2577
+ var select = (t2) => {
2578
+ const o2 = (n3, m3) => {
2579
+ if (n3 === void 0)
2580
+ return "";
2581
+ const s = n3.label ?? String(n3.value);
2582
+ switch (m3) {
2583
+ case "disabled":
2584
+ return `${styleText2("gray", S_RADIO_INACTIVE)} ${c2(s, (i2) => styleText2("gray", i2))}${n3.hint ? ` ${styleText2("dim", `(${n3.hint ?? "disabled"})`)}` : ""}`;
2585
+ case "selected":
2586
+ return `${c2(s, (i2) => styleText2("dim", i2))}`;
2587
+ case "active":
2588
+ return `${styleText2("green", S_RADIO_ACTIVE)} ${s}${n3.hint ? ` ${styleText2("dim", `(${n3.hint})`)}` : ""}`;
2589
+ case "cancelled":
2590
+ return `${c2(s, (i2) => styleText2(["strikethrough", "dim"], i2))}`;
2591
+ default:
2592
+ return `${styleText2("dim", S_RADIO_INACTIVE)} ${c2(s, (i2) => styleText2("dim", i2))}`;
2593
+ }
2594
+ }, d = t2.showInstructions ?? true;
2595
+ return new n$1({
2596
+ options: t2.options,
2597
+ signal: t2.signal,
2598
+ input: t2.input,
2599
+ output: t2.output,
2600
+ initialValue: t2.initialValue,
2601
+ render() {
2602
+ const n3 = t2.withGuide ?? settings.withGuide, m3 = `${symbol(this.state)} `, s = `${symbolBar(this.state)} `, i2 = wrapTextWithPrefix(
2603
+ t2.output,
2604
+ t2.message,
2605
+ s,
2606
+ m3
2607
+ ), u5 = `${n3 ? `${styleText2("gray", S_BAR)}
2608
+ ` : ""}${i2}
2609
+ `;
2610
+ switch (this.state) {
2611
+ case "submit": {
2612
+ const r2 = n3 ? `${styleText2("gray", S_BAR)} ` : "", a2 = wrapTextWithPrefix(
2613
+ t2.output,
2614
+ o2(this.options[this.cursor], "selected"),
2615
+ r2
2616
+ );
2617
+ return `${u5}${a2}`;
2618
+ }
2619
+ case "cancel": {
2620
+ const r2 = n3 ? `${styleText2("gray", S_BAR)} ` : "", a2 = wrapTextWithPrefix(
2621
+ t2.output,
2622
+ o2(this.options[this.cursor], "cancelled"),
2623
+ r2
2624
+ );
2625
+ return `${u5}${a2}${n3 ? `
2626
+ ${styleText2("gray", S_BAR)}` : ""}`;
2627
+ }
2628
+ default: {
2629
+ const r2 = n3 ? `${styleText2("cyan", S_BAR)} ` : "", a2 = u5.split(`
2630
+ `).length, p3 = d ? formatInstructionFooter(SELECT_INSTRUCTIONS, n3) : n3 ? [styleText2("cyan", S_BAR_END)] : [], f2 = p3.join(`
2631
+ `), b3 = p3.length + 1;
2632
+ return `${u5}${r2}${limitOptions({
2633
+ output: t2.output,
2634
+ cursor: this.cursor,
2635
+ options: this.options,
2636
+ maxItems: t2.maxItems,
2637
+ columnPadding: r2.length,
2638
+ rowPadding: a2 + b3,
2639
+ style: (g2, x2) => o2(g2, g2.disabled ? "disabled" : x2 ? "active" : "inactive")
2640
+ }).join(`
2641
+ ${r2}`)}
2642
+ ${f2}
2643
+ `;
2644
+ }
2645
+ }
2646
+ }
2647
+ }).prompt();
2648
+ };
2649
+ var selectKey = (t2) => {
2650
+ const c3 = (e, a2 = "inactive") => {
2651
+ if (e === void 0)
2652
+ return "";
2653
+ const n3 = e.label ?? String(e.value);
2654
+ return a2 === "selected" ? `${styleText2("dim", n3)}` : a2 === "cancelled" ? `${styleText2(["strikethrough", "dim"], n3)}` : a2 === "active" ? `${styleText2(["bgCyan", "gray"], ` ${e.value} `)} ${n3}${e.hint ? ` ${styleText2("dim", `(${e.hint})`)}` : ""}` : `${styleText2(["gray", "bgWhite", "inverse"], ` ${e.value} `)} ${n3}${e.hint ? ` ${styleText2("dim", `(${e.hint})`)}` : ""}`;
2655
+ };
2656
+ return new u3({
2657
+ options: t2.options,
2658
+ signal: t2.signal,
2659
+ input: t2.input,
2660
+ output: t2.output,
2661
+ initialValue: t2.initialValue,
2662
+ caseSensitive: t2.caseSensitive,
2663
+ render() {
2664
+ const e = t2.withGuide ?? settings.withGuide, a2 = `${e ? `${styleText2("gray", S_BAR)}
2665
+ ` : ""}${symbol(this.state)} ${t2.message}
2666
+ `;
2667
+ switch (this.state) {
2668
+ case "submit": {
2669
+ const n3 = e ? `${styleText2("gray", S_BAR)} ` : "", r2 = this.options.find((u5) => u5.value === this.value) ?? t2.options[0], l2 = wrapTextWithPrefix(
2670
+ t2.output,
2671
+ c3(r2, "selected"),
2672
+ n3
2673
+ );
2674
+ return `${a2}${l2}`;
2675
+ }
2676
+ case "cancel": {
2677
+ const n3 = e ? `${styleText2("gray", S_BAR)} ` : "", r2 = wrapTextWithPrefix(
2678
+ t2.output,
2679
+ c3(this.options[0], "cancelled"),
2680
+ n3
2681
+ );
2682
+ return `${a2}${r2}${e ? `
2683
+ ${styleText2("gray", S_BAR)}` : ""}`;
2684
+ }
2685
+ default: {
2686
+ const n3 = e ? `${styleText2("cyan", S_BAR)} ` : "", r2 = e ? styleText2("cyan", S_BAR_END) : "", l2 = this.options.map(
2687
+ (u5, d) => wrapTextWithPrefix(
2688
+ t2.output,
2689
+ c3(u5, d === this.cursor ? "active" : "inactive"),
2690
+ n3
2691
+ )
2692
+ ).join(`
2693
+ `);
2694
+ return `${a2}${l2}
2695
+ ${r2}
2696
+ `;
2697
+ }
2698
+ }
2699
+ }
2700
+ }).prompt();
2701
+ };
2702
+ var i = `${styleText2("gray", S_BAR)} `;
2703
+ var stream = {
2704
+ message: async (e, { symbol: l2 = styleText2("gray", S_BAR) } = {}) => {
2705
+ process.stdout.write(`${styleText2("gray", S_BAR)}
2706
+ ${l2} `);
2707
+ let s = 3;
2708
+ for await (let r2 of e) {
2709
+ r2 = r2.replace(/\n/g, `
2710
+ ${i}`), r2.includes(`
2711
+ `) && (s = 3 + stripVTControlCharacters(r2.slice(r2.lastIndexOf(`
2712
+ `))).length);
2713
+ const o2 = stripVTControlCharacters(r2).length;
2714
+ s + o2 < process.stdout.columns ? (s += o2, process.stdout.write(r2)) : (process.stdout.write(`
2715
+ ${i}${r2.trimStart()}`), s = 3 + stripVTControlCharacters(r2.trimStart()).length);
2716
+ }
2717
+ process.stdout.write(`
2718
+ `);
2719
+ },
2720
+ info: (e) => stream.message(e, { symbol: styleText2("blue", S_INFO) }),
2721
+ success: (e) => stream.message(e, { symbol: styleText2("green", S_SUCCESS) }),
2722
+ step: (e) => stream.message(e, { symbol: styleText2("green", S_STEP_SUBMIT) }),
2723
+ warn: (e) => stream.message(e, { symbol: styleText2("yellow", S_WARN) }),
2724
+ /** alias for `log.warn()`. */
2725
+ warning: (e) => stream.warn(e),
2726
+ error: (e) => stream.message(e, { symbol: styleText2("red", S_ERROR) })
2727
+ };
2728
+ var tasks = async (o2, e) => {
2729
+ for (const t2 of o2) {
2730
+ if (t2.enabled === false) continue;
2731
+ const s = spinner(e);
2732
+ s.start(t2.title);
2733
+ const n3 = await t2.task(s.message);
2734
+ s.stop(n3 || t2.title);
2735
+ }
2736
+ };
2737
+ var A = (l2) => l2.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g, "");
2738
+ var taskLog = (l2) => {
2739
+ const r2 = l2.output ?? process.stdout, O = getColumns(r2), i2 = styleText2("gray", S_BAR), p3 = l2.spacing ?? 1, k = 3, m3 = l2.retainLog === true, d = !isCI() && isTTY(r2);
2740
+ r2.write(`${i2}
2741
+ `), r2.write(`${styleText2("green", S_STEP_SUBMIT)} ${l2.title}
2742
+ `);
2743
+ for (let e = 0; e < p3; e++)
2744
+ r2.write(`${i2}
2745
+ `);
2746
+ const n3 = [
2747
+ {
2748
+ value: "",
2749
+ full: ""
2750
+ }
2751
+ ];
2752
+ let v = false;
2753
+ const f2 = (e) => {
2754
+ if (n3.length === 0)
2755
+ return;
2756
+ let s = 0;
2757
+ e && (s += p3 + 2);
2758
+ for (const t2 of n3) {
2759
+ const { value: o2, result: a2 } = t2;
2760
+ let g2 = a2?.message ?? o2;
2761
+ if (g2.length === 0)
2762
+ continue;
2763
+ a2 === void 0 && t2.header !== void 0 && t2.header !== "" && (g2 += `
2764
+ ${t2.header}`);
2765
+ const E2 = g2.split(`
2766
+ `).reduce((b3, w) => w === "" ? b3 + 1 : b3 + Math.ceil((w.length + k) / O), 0);
2767
+ s += E2;
2768
+ }
2769
+ s > 0 && (s += 1, r2.write(import_sisteransi2.erase.lines(s)));
2770
+ }, h2 = (e, s, t2) => {
2771
+ const o2 = t2 ? `${e.full}
2772
+ ${e.value}` : e.value;
2773
+ e.header !== void 0 && e.header !== "" && log.message(
2774
+ e.header.split(`
2775
+ `).map((a2) => styleText2("bold", a2)),
2776
+ {
2777
+ output: r2,
2778
+ secondarySymbol: i2,
2779
+ symbol: i2,
2780
+ spacing: 0
2781
+ }
2782
+ ), log.message(
2783
+ o2.split(`
2784
+ `).map((a2) => styleText2("dim", a2)),
2785
+ {
2786
+ output: r2,
2787
+ secondarySymbol: i2,
2788
+ symbol: i2,
2789
+ spacing: s ?? p3
2790
+ }
2791
+ );
2792
+ }, T3 = () => {
2793
+ for (const e of n3) {
2794
+ const { header: s, value: t2, full: o2 } = e;
2795
+ (s === void 0 || s.length === 0) && t2.length === 0 || h2(e, void 0, m3 === true && o2.length > 0);
2796
+ }
2797
+ }, L = (e, s, t2) => {
2798
+ if (f2(false), (t2?.raw !== true || !v) && e.value !== "" && (e.value += `
2799
+ `), e.value += A(s), v = t2?.raw === true, l2.limit !== void 0) {
2800
+ const o2 = e.value.split(`
2801
+ `), a2 = o2.length - l2.limit;
2802
+ if (a2 > 0) {
2803
+ const g2 = o2.splice(0, a2);
2804
+ m3 && (e.full += (e.full === "" ? "" : `
2805
+ `) + g2.join(`
2806
+ `));
2807
+ }
2808
+ e.value = o2.join(`
2809
+ `);
2810
+ }
2811
+ d && y2();
2812
+ }, y2 = () => {
2813
+ for (const e of n3)
2814
+ e.result ? e.result.status === "error" ? log.error(e.result.message, { output: r2, secondarySymbol: i2, spacing: 0 }) : log.success(e.result.message, { output: r2, secondarySymbol: i2, spacing: 0 }) : e.value !== "" && h2(e, 0);
2815
+ }, B = (e, s) => {
2816
+ f2(false), e.result = s, d && y2();
2817
+ };
2818
+ return {
2819
+ message(e, s) {
2820
+ L(n3[0], e, s);
2821
+ },
2822
+ group(e) {
2823
+ const s = {
2824
+ header: e,
2825
+ value: "",
2826
+ full: ""
2827
+ };
2828
+ return n3.push(s), {
2829
+ message(t2, o2) {
2830
+ L(s, t2, o2);
2831
+ },
2832
+ error(t2) {
2833
+ B(s, {
2834
+ status: "error",
2835
+ message: t2
2836
+ });
2837
+ },
2838
+ success(t2) {
2839
+ B(s, {
2840
+ status: "success",
2841
+ message: t2
2842
+ });
2843
+ }
2844
+ };
2845
+ },
2846
+ error(e, s) {
2847
+ f2(true), log.error(e, { output: r2, secondarySymbol: i2, spacing: 1 }), s?.showLog !== false && T3(), n3.splice(1, n3.length - 1), n3[0].value = "", n3[0].full = "";
2848
+ },
2849
+ success(e, s) {
2850
+ f2(true), log.success(e, { output: r2, secondarySymbol: i2, spacing: 1 }), s?.showLog === true && T3(), n3.splice(1, n3.length - 1), n3[0].value = "", n3[0].full = "";
2851
+ }
2852
+ };
2853
+ };
2854
+ var text = (t2) => new n2({
2855
+ validate: t2.validate,
2856
+ placeholder: t2.placeholder,
2857
+ defaultValue: t2.defaultValue,
2858
+ initialValue: t2.initialValue,
2859
+ output: t2.output,
2860
+ signal: t2.signal,
2861
+ input: t2.input,
2862
+ render() {
2863
+ const r2 = t2?.withGuide ?? settings.withGuide, l2 = `${`${r2 ? `${styleText2("gray", S_BAR)}
2864
+ ` : ""}${symbol(this.state)} `}${t2.message}
2865
+ `, d = t2.placeholder && t2.placeholder.length > 0 ? (
2866
+ // biome-ignore lint/style/noNonNullAssertion: guarded by placeholder.length > 0
2867
+ styleText2("inverse", t2.placeholder[0]) + styleText2("dim", t2.placeholder.slice(1))
2868
+ ) : styleText2(["inverse", "hidden"], "_"), o2 = this.userInput ? this.userInputWithCursor : d, s = this.value ?? "";
2869
+ switch (this.state) {
2870
+ case "validating": {
2871
+ const n3 = r2 ? `${styleText2("cyan", S_BAR)} ` : "", i2 = r2 ? styleText2("cyan", S_BAR_END) : "", c3 = styleText2("dim", o2), $ = styleText2("dim", "Validating...");
2872
+ return `${l2}${n3}${c3}
2873
+ ${i2} ${$}
2874
+ `;
2875
+ }
2876
+ case "error": {
2877
+ const n3 = this.error ? ` ${styleText2("yellow", this.error)}` : "", i2 = r2 ? `${styleText2("yellow", S_BAR)} ` : "", c3 = r2 ? styleText2("yellow", S_BAR_END) : "";
2878
+ return `${l2.trim()}
2879
+ ${i2}${o2}
2880
+ ${c3}${n3}
2881
+ `;
2882
+ }
2883
+ case "submit": {
2884
+ const n3 = s ? `${r2 ? " " : ""}${styleText2("dim", s)}` : "", i2 = r2 ? styleText2("gray", S_BAR) : "";
2885
+ return `${l2}${i2}${n3}`;
2886
+ }
2887
+ case "cancel": {
2888
+ const n3 = s ? ` ${styleText2(["strikethrough", "dim"], s)}` : "", i2 = r2 ? styleText2("gray", S_BAR) : "";
2889
+ return `${l2}${i2}${n3}${s.trim() ? `
2890
+ ${i2}` : ""}`;
2891
+ }
2892
+ default: {
2893
+ const n3 = r2 ? `${styleText2("cyan", S_BAR)} ` : "", i2 = r2 ? styleText2("cyan", S_BAR_END) : "";
2894
+ return `${l2}${n3}${o2}
2895
+ ${i2}
2896
+ `;
2897
+ }
2898
+ }
2899
+ }
2900
+ }).prompt();
2901
+
2902
+ // src/setup-ui.ts
2903
+ import { providerStatus } from "./config.js";
2904
+ import { providerPresets, anonymousPresets } from "./defaults.js";
2905
+ var catalog = [
2906
+ { id: "brave", label: "Brave", hint: "General web search", key: "BRAVE_API_KEY" },
2907
+ { id: "exa", label: "Exa", hint: "Semantic search", key: "EXA_API_KEY" },
2908
+ { id: "tavily", label: "Tavily", hint: "General web search", key: "TAVILY_API_KEY" },
2909
+ { id: "jina", label: "Jina", hint: "Web reading (native focus with Key)", key: "JINA_API_KEY" },
2910
+ { id: "firecrawl", label: "Firecrawl", hint: "Optional complex page reading", key: "FIRECRAWL_API_KEY" }
2911
+ ];
2912
+ async function runSetupWizard(saved, env = process.env, prompts = dist_exports) {
2913
+ const canceled = Symbol("setup-cancelled");
2914
+ const answer = async (pending) => {
2915
+ const value = await pending;
2916
+ if (prompts.isCancel(value)) throw canceled;
2917
+ return value;
2918
+ };
2919
+ const config = structuredClone(saved);
2920
+ try {
2921
+ prompts.intro("Siftpath setup");
2922
+ prompts.log.info("Arrow keys: move; Space: toggle; Enter: confirm; Esc/Ctrl+C: cancel. Keys are never displayed.");
2923
+ const options = [
2924
+ ...catalog.map((p3) => ({ value: p3.id, label: p3.label, hint: p3.hint })),
2925
+ ...Object.keys(config.providers).filter((id) => !catalog.some((p3) => p3.id === id)).map((id) => ({ value: id, label: id, hint: "Existing custom MCP (kept as configured)" }))
2926
+ ];
2927
+ const chosen = await answer(prompts.multiselect({
2928
+ message: "Providers (Space: toggle, Enter: continue)",
2929
+ options,
2930
+ initialValues: Object.keys(config.providers).filter((id) => config.providers[id].enabled),
2931
+ required: true
2932
+ }));
2933
+ const selected = options.map((option) => option.value).filter((id) => chosen.includes(id));
2934
+ for (const [id, provider] of Object.entries(config.providers)) provider.enabled = selected.includes(id);
2935
+ for (const id of selected) {
2936
+ const entry = catalog.find((p3) => p3.id === id);
2937
+ if (!entry) continue;
2938
+ config.providers[id] ??= structuredClone(providerPresets[id]);
2939
+ config.providers[id].enabled = true;
2940
+ const existing = env[entry.key]?.trim() || config.credentials[entry.key];
2941
+ const anonymous = anonymousPresets[id];
2942
+ const current = providerStatus(id, config, env);
2943
+ prompts.log.info(entry.label + ": " + (existing ? entry.key + " configured" : "No saved/environment Key") + "; connection=" + current.code);
2944
+ const action = await answer(prompts.select({
2945
+ message: entry.label + " credentials",
2946
+ options: [
2947
+ ...current.code === "READY" ? [{ value: "keep", label: "Keep current connection", hint: existing ? "Key configured; no re-entry needed" : "No missing credential references" }] : [],
2948
+ ...existing ? [{ value: "existing", label: "Use existing API Key", hint: "Official authenticated preset" }] : [],
2949
+ { value: "key", label: existing ? "Replace API Key" : "Add API Key", hint: env[entry.key]?.trim() ? "Environment overrides saved Key until unset" : "Hidden input; private local storage" },
2950
+ ...anonymous ? [{ value: "anonymous", label: "Use official anonymous access", hint: "Limited quota; availability may change" }] : []
2951
+ ],
2952
+ initialValue: current.code === "READY" ? "keep" : existing ? "existing" : anonymous ? "anonymous" : "key"
2953
+ }));
2954
+ if (action === "keep") continue;
2955
+ if (action === "anonymous" && id === "tavily") prompts.log.warn("The official Tavily stdio server may load a local .env. Use a clean working directory for strictly anonymous access.");
2956
+ if (action === "key") {
2957
+ if (env[entry.key]?.trim()) prompts.log.warn(entry.key + " is set in the environment and still takes precedence over a saved replacement.");
2958
+ const key = await answer(prompts.password({
2959
+ message: entry.key + (existing ? " (Enter keeps existing Key)" : " (required)"),
2960
+ validate: (value) => {
2961
+ if (!(value ?? "").trim() && !existing) return "Enter an API Key or press Esc to cancel.";
2962
+ if ((value?.length ?? 0) > 4096 || /[\r\n\0]/.test(value ?? "")) return "Invalid Key format.";
2963
+ }
2964
+ }));
2965
+ if (key.trim()) config.credentials[entry.key] = key.trim();
2966
+ }
2967
+ config.providers[id] = structuredClone(action === "anonymous" ? anonymous : providerPresets[id]);
2968
+ }
2969
+ const ready = (kind) => Object.keys(config.providers).filter((id) => config.providers[id][kind] && providerStatus(id, config, env).code === "READY");
2970
+ const search = ready("search"), read = ready("read");
2971
+ if (!search.length && !read.length) {
2972
+ prompts.log.error("No ready Search or Read connection. Nothing saved.");
2973
+ return null;
2974
+ }
2975
+ const choose = (message, ids, preferred) => answer(prompts.select({
2976
+ message,
2977
+ options: ids.map((value) => ({ value, label: value })),
2978
+ initialValue: ids.includes(preferred ?? "") ? preferred : ids[0]
2979
+ }));
2980
+ const routes = config.routes;
2981
+ if (search.length) {
2982
+ const ordered = [.../* @__PURE__ */ new Set(["tavily", "brave", "exa", ...search])].filter((id) => search.includes(id));
2983
+ routes.search = await choose("Default search provider", ordered, routes.search);
2984
+ routes.intents = {
2985
+ general: routes.search,
2986
+ semantic: await choose("Semantic search provider", ordered, search.includes(routes.intents.semantic ?? "") ? routes.intents.semantic : search.includes("exa") ? "exa" : routes.search),
2987
+ research: await choose("Research search provider", ordered, search.includes(routes.intents.research ?? "") ? routes.intents.research : search.includes("tavily") ? "tavily" : routes.search)
2988
+ };
2989
+ } else {
2990
+ routes.search = "unconfigured";
2991
+ routes.intents = {};
2992
+ routes.searchFallback = [];
2993
+ }
2994
+ if (read.length) routes.read = await choose("Default webpage reader", read, read.includes(routes.read) ? routes.read : read.includes("jina") ? "jina" : read[0]);
2995
+ else {
2996
+ routes.read = "unconfigured";
2997
+ routes.readFallback = [];
2998
+ }
2999
+ for (const [kind, ids] of [["search", search], ["read", read]]) {
3000
+ const primary = routes[kind], field = kind === "search" ? "searchFallback" : "readFallback";
3001
+ const available = kind === "search" && ids.length > 1 ? [...ids] : ids.filter((id) => id !== primary), initial = [.../* @__PURE__ */ new Set([...routes[field], ...available])].filter((id) => available.includes(id));
3002
+ if (!available.length) {
3003
+ routes[field] = [];
3004
+ continue;
3005
+ }
3006
+ if (kind === "search") prompts.log.info("Search fallbacks apply to all intents; the active primary is automatically deduplicated.");
3007
+ const fallback = await answer(prompts.multiselect({
3008
+ message: kind + " fallback providers (shown order)",
3009
+ options: initial.map((value) => ({ value, label: value })),
3010
+ initialValues: routes[field].filter((id) => available.includes(id)),
3011
+ required: false
3012
+ }));
3013
+ routes[field] = [];
3014
+ while (fallback.length) {
3015
+ const next = fallback.length === 1 ? fallback[0] : await choose(kind + " fallback: choose next in order", fallback, initial.find((id) => fallback.includes(id)));
3016
+ routes[field].push(next);
3017
+ fallback.splice(fallback.indexOf(next), 1);
3018
+ }
3019
+ }
3020
+ prompts.log.info("Selected: " + selected.join(", ") + "\nSearch: " + (search.length ? routes.search : "not configured") + "; default intent=" + routes.defaultIntent + "; semantic: " + (routes.intents.semantic ?? "none") + "\nRead: " + (read.length ? routes.read : "not configured") + "\nFallbacks: search=" + (routes.searchFallback.join(" -> ") || "none") + "; read=" + (routes.readFallback.join(" -> ") || "none"));
3021
+ const test = await answer(prompts.confirm({ message: "After saving, run real provider tests? (may use API quota)", initialValue: false }));
3022
+ prompts.outro("Ready to save private configuration.");
3023
+ return { configuration: config, test };
3024
+ } catch (error) {
3025
+ if (error !== canceled) throw error;
3026
+ prompts.cancel("Cancelled; no changes saved.");
3027
+ return null;
3028
+ }
3029
+ }
3030
+ export {
3031
+ runSetupWizard
3032
+ };