create-dstack 0.1.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.
package/dist/index.js ADDED
@@ -0,0 +1,1419 @@
1
+ #!/usr/bin/env bun
2
+ // @bun
3
+ #!/usr/bin/env node
4
+ var __create = Object.create;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __defProp = Object.defineProperty;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ function __accessProp(key) {
10
+ return this[key];
11
+ }
12
+ var __toESMCache_node;
13
+ var __toESMCache_esm;
14
+ var __toESM = (mod, isNodeMode, target) => {
15
+ var canCache = mod != null && typeof mod === "object";
16
+ if (canCache) {
17
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
18
+ var cached = cache.get(mod);
19
+ if (cached)
20
+ return cached;
21
+ }
22
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
23
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
24
+ for (let key of __getOwnPropNames(mod))
25
+ if (!__hasOwnProp.call(to, key))
26
+ __defProp(to, key, {
27
+ get: __accessProp.bind(mod, key),
28
+ enumerable: true
29
+ });
30
+ if (canCache)
31
+ cache.set(mod, to);
32
+ return to;
33
+ };
34
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
35
+
36
+ // node_modules/sisteransi/src/index.js
37
+ var require_src = __commonJS((exports, module) => {
38
+ var ESC2 = "\x1B";
39
+ var CSI2 = `${ESC2}[`;
40
+ var beep = "\x07";
41
+ var cursor = {
42
+ to(x, y) {
43
+ if (!y)
44
+ return `${CSI2}${x + 1}G`;
45
+ return `${CSI2}${y + 1};${x + 1}H`;
46
+ },
47
+ move(x, y) {
48
+ let ret = "";
49
+ if (x < 0)
50
+ ret += `${CSI2}${-x}D`;
51
+ else if (x > 0)
52
+ ret += `${CSI2}${x}C`;
53
+ if (y < 0)
54
+ ret += `${CSI2}${-y}A`;
55
+ else if (y > 0)
56
+ ret += `${CSI2}${y}B`;
57
+ return ret;
58
+ },
59
+ up: (count = 1) => `${CSI2}${count}A`,
60
+ down: (count = 1) => `${CSI2}${count}B`,
61
+ forward: (count = 1) => `${CSI2}${count}C`,
62
+ backward: (count = 1) => `${CSI2}${count}D`,
63
+ nextLine: (count = 1) => `${CSI2}E`.repeat(count),
64
+ prevLine: (count = 1) => `${CSI2}F`.repeat(count),
65
+ left: `${CSI2}G`,
66
+ hide: `${CSI2}?25l`,
67
+ show: `${CSI2}?25h`,
68
+ save: `${ESC2}7`,
69
+ restore: `${ESC2}8`
70
+ };
71
+ var scroll = {
72
+ up: (count = 1) => `${CSI2}S`.repeat(count),
73
+ down: (count = 1) => `${CSI2}T`.repeat(count)
74
+ };
75
+ var erase = {
76
+ screen: `${CSI2}2J`,
77
+ up: (count = 1) => `${CSI2}1J`.repeat(count),
78
+ down: (count = 1) => `${CSI2}J`.repeat(count),
79
+ line: `${CSI2}2K`,
80
+ lineEnd: `${CSI2}K`,
81
+ lineStart: `${CSI2}1K`,
82
+ lines(count) {
83
+ let clear = "";
84
+ for (let i = 0;i < count; i++)
85
+ clear += this.line + (i < count - 1 ? cursor.up() : "");
86
+ if (count)
87
+ clear += cursor.left;
88
+ return clear;
89
+ }
90
+ };
91
+ module.exports = { cursor, scroll, erase, beep };
92
+ });
93
+
94
+ // node_modules/picocolors/picocolors.js
95
+ var require_picocolors = __commonJS((exports, module) => {
96
+ var p2 = process || {};
97
+ var argv = p2.argv || [];
98
+ var env = p2.env || {};
99
+ var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p2.platform === "win32" || (p2.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
100
+ var formatter = (open, close, replace = open) => (input) => {
101
+ let string = "" + input, index = string.indexOf(close, open.length);
102
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
103
+ };
104
+ var replaceClose = (string, close, replace, index) => {
105
+ let result = "", cursor = 0;
106
+ do {
107
+ result += string.substring(cursor, index) + replace;
108
+ cursor = index + close.length;
109
+ index = string.indexOf(close, cursor);
110
+ } while (~index);
111
+ return result + string.substring(cursor);
112
+ };
113
+ var createColors = (enabled = isColorSupported) => {
114
+ let f = enabled ? formatter : () => String;
115
+ return {
116
+ isColorSupported: enabled,
117
+ reset: f("\x1B[0m", "\x1B[0m"),
118
+ bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
119
+ dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
120
+ italic: f("\x1B[3m", "\x1B[23m"),
121
+ underline: f("\x1B[4m", "\x1B[24m"),
122
+ inverse: f("\x1B[7m", "\x1B[27m"),
123
+ hidden: f("\x1B[8m", "\x1B[28m"),
124
+ strikethrough: f("\x1B[9m", "\x1B[29m"),
125
+ black: f("\x1B[30m", "\x1B[39m"),
126
+ red: f("\x1B[31m", "\x1B[39m"),
127
+ green: f("\x1B[32m", "\x1B[39m"),
128
+ yellow: f("\x1B[33m", "\x1B[39m"),
129
+ blue: f("\x1B[34m", "\x1B[39m"),
130
+ magenta: f("\x1B[35m", "\x1B[39m"),
131
+ cyan: f("\x1B[36m", "\x1B[39m"),
132
+ white: f("\x1B[37m", "\x1B[39m"),
133
+ gray: f("\x1B[90m", "\x1B[39m"),
134
+ bgBlack: f("\x1B[40m", "\x1B[49m"),
135
+ bgRed: f("\x1B[41m", "\x1B[49m"),
136
+ bgGreen: f("\x1B[42m", "\x1B[49m"),
137
+ bgYellow: f("\x1B[43m", "\x1B[49m"),
138
+ bgBlue: f("\x1B[44m", "\x1B[49m"),
139
+ bgMagenta: f("\x1B[45m", "\x1B[49m"),
140
+ bgCyan: f("\x1B[46m", "\x1B[49m"),
141
+ bgWhite: f("\x1B[47m", "\x1B[49m"),
142
+ blackBright: f("\x1B[90m", "\x1B[39m"),
143
+ redBright: f("\x1B[91m", "\x1B[39m"),
144
+ greenBright: f("\x1B[92m", "\x1B[39m"),
145
+ yellowBright: f("\x1B[93m", "\x1B[39m"),
146
+ blueBright: f("\x1B[94m", "\x1B[39m"),
147
+ magentaBright: f("\x1B[95m", "\x1B[39m"),
148
+ cyanBright: f("\x1B[96m", "\x1B[39m"),
149
+ whiteBright: f("\x1B[97m", "\x1B[39m"),
150
+ bgBlackBright: f("\x1B[100m", "\x1B[49m"),
151
+ bgRedBright: f("\x1B[101m", "\x1B[49m"),
152
+ bgGreenBright: f("\x1B[102m", "\x1B[49m"),
153
+ bgYellowBright: f("\x1B[103m", "\x1B[49m"),
154
+ bgBlueBright: f("\x1B[104m", "\x1B[49m"),
155
+ bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
156
+ bgCyanBright: f("\x1B[106m", "\x1B[49m"),
157
+ bgWhiteBright: f("\x1B[107m", "\x1B[49m")
158
+ };
159
+ };
160
+ module.exports = createColors();
161
+ module.exports.createColors = createColors;
162
+ });
163
+
164
+ // src/index.ts
165
+ var {$: $2 } = globalThis.Bun;
166
+ import { existsSync, cpSync, mkdirSync, appendFileSync } from "fs";
167
+ import { join, resolve, dirname } from "path";
168
+ import { fileURLToPath } from "url";
169
+
170
+ // node_modules/@clack/core/dist/index.mjs
171
+ import { styleText as y } from "node:util";
172
+ import { stdout as S, stdin as $ } from "node:process";
173
+ import * as _ from "node:readline";
174
+ import P from "node:readline";
175
+
176
+ // node_modules/fast-string-truncated-width/dist/utils.js
177
+ var isAmbiguous = (x) => {
178
+ return x === 161 || x === 164 || x === 167 || x === 168 || x === 170 || x === 173 || x === 174 || x >= 176 && x <= 180 || x >= 182 && x <= 186 || x >= 188 && x <= 191 || x === 198 || x === 208 || x === 215 || x === 216 || x >= 222 && x <= 225 || x === 230 || x >= 232 && x <= 234 || x === 236 || x === 237 || x === 240 || x === 242 || x === 243 || x >= 247 && x <= 250 || x === 252 || x === 254 || x === 257 || x === 273 || x === 275 || x === 283 || x === 294 || x === 295 || x === 299 || x >= 305 && x <= 307 || x === 312 || x >= 319 && x <= 322 || x === 324 || x >= 328 && x <= 331 || x === 333 || x === 338 || x === 339 || x === 358 || x === 359 || x === 363 || x === 462 || x === 464 || x === 466 || x === 468 || x === 470 || x === 472 || x === 474 || x === 476 || x === 593 || x === 609 || x === 708 || x === 711 || x >= 713 && x <= 715 || x === 717 || x === 720 || x >= 728 && x <= 731 || x === 733 || x === 735 || x >= 768 && x <= 879 || x >= 913 && x <= 929 || x >= 931 && x <= 937 || x >= 945 && x <= 961 || x >= 963 && x <= 969 || x === 1025 || x >= 1040 && x <= 1103 || x === 1105 || x === 8208 || x >= 8211 && x <= 8214 || x === 8216 || x === 8217 || x === 8220 || x === 8221 || x >= 8224 && x <= 8226 || x >= 8228 && x <= 8231 || x === 8240 || x === 8242 || x === 8243 || x === 8245 || x === 8251 || x === 8254 || x === 8308 || x === 8319 || x >= 8321 && x <= 8324 || x === 8364 || x === 8451 || x === 8453 || x === 8457 || x === 8467 || x === 8470 || x === 8481 || x === 8482 || x === 8486 || x === 8491 || x === 8531 || x === 8532 || x >= 8539 && x <= 8542 || x >= 8544 && x <= 8555 || x >= 8560 && x <= 8569 || x === 8585 || x >= 8592 && x <= 8601 || x === 8632 || x === 8633 || x === 8658 || x === 8660 || x === 8679 || x === 8704 || x === 8706 || x === 8707 || x === 8711 || x === 8712 || x === 8715 || x === 8719 || x === 8721 || x === 8725 || x === 8730 || x >= 8733 && x <= 8736 || x === 8739 || x === 8741 || x >= 8743 && x <= 8748 || x === 8750 || x >= 8756 && x <= 8759 || x === 8764 || x === 8765 || x === 8776 || x === 8780 || x === 8786 || x === 8800 || x === 8801 || x >= 8804 && x <= 8807 || x === 8810 || x === 8811 || x === 8814 || x === 8815 || x === 8834 || x === 8835 || x === 8838 || x === 8839 || x === 8853 || x === 8857 || x === 8869 || x === 8895 || x === 8978 || x >= 9312 && x <= 9449 || x >= 9451 && x <= 9547 || x >= 9552 && x <= 9587 || x >= 9600 && x <= 9615 || x >= 9618 && x <= 9621 || x === 9632 || x === 9633 || x >= 9635 && x <= 9641 || x === 9650 || x === 9651 || x === 9654 || x === 9655 || x === 9660 || x === 9661 || x === 9664 || x === 9665 || x >= 9670 && x <= 9672 || x === 9675 || x >= 9678 && x <= 9681 || x >= 9698 && x <= 9701 || x === 9711 || x === 9733 || x === 9734 || x === 9737 || x === 9742 || x === 9743 || x === 9756 || x === 9758 || x === 9792 || x === 9794 || x === 9824 || x === 9825 || x >= 9827 && x <= 9829 || x >= 9831 && x <= 9834 || x === 9836 || x === 9837 || x === 9839 || x === 9886 || x === 9887 || x === 9919 || x >= 9926 && x <= 9933 || x >= 9935 && x <= 9939 || x >= 9941 && x <= 9953 || x === 9955 || x === 9960 || x === 9961 || x >= 9963 && x <= 9969 || x === 9972 || x >= 9974 && x <= 9977 || x === 9979 || x === 9980 || x === 9982 || x === 9983 || x === 10045 || x >= 10102 && x <= 10111 || x >= 11094 && x <= 11097 || x >= 12872 && x <= 12879 || x >= 57344 && x <= 63743 || x >= 65024 && x <= 65039 || x === 65533 || x >= 127232 && x <= 127242 || x >= 127248 && x <= 127277 || x >= 127280 && x <= 127337 || x >= 127344 && x <= 127373 || x === 127375 || x === 127376 || x >= 127387 && x <= 127404 || x >= 917760 && x <= 917999 || x >= 983040 && x <= 1048573 || x >= 1048576 && x <= 1114109;
179
+ };
180
+ var isFullWidth = (x) => {
181
+ return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
182
+ };
183
+ var isWide = (x) => {
184
+ return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9800 && x <= 9811 || x === 9855 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 19968 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x === 94192 || x === 94193 || x >= 94208 && x <= 100343 || x >= 100352 && x <= 101589 || x >= 101632 && x <= 101640 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128727 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129672 || x >= 129680 && x <= 129725 || x >= 129727 && x <= 129733 || x >= 129742 && x <= 129755 || x >= 129760 && x <= 129768 || x >= 129776 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
185
+ };
186
+
187
+ // node_modules/fast-string-truncated-width/dist/index.js
188
+ var ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
189
+ var CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
190
+ var TAB_RE = /\t{1,1000}/y;
191
+ var EMOJI_RE = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu;
192
+ var LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
193
+ var MODIFIER_RE = /\p{M}+/gu;
194
+ var NO_TRUNCATION = { limit: Infinity, ellipsis: "" };
195
+ var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
196
+ const LIMIT = truncationOptions.limit ?? Infinity;
197
+ const ELLIPSIS = truncationOptions.ellipsis ?? "";
198
+ const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
199
+ const ANSI_WIDTH = widthOptions.ansiWidth ?? 0;
200
+ const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
201
+ const TAB_WIDTH = widthOptions.tabWidth ?? 8;
202
+ const AMBIGUOUS_WIDTH = widthOptions.ambiguousWidth ?? 1;
203
+ const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
204
+ const FULL_WIDTH_WIDTH = widthOptions.fullWidthWidth ?? 2;
205
+ const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
206
+ const WIDE_WIDTH = widthOptions.wideWidth ?? 2;
207
+ let indexPrev = 0;
208
+ let index = 0;
209
+ let length = input.length;
210
+ let lengthExtra = 0;
211
+ let truncationEnabled = false;
212
+ let truncationIndex = length;
213
+ let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
214
+ let unmatchedStart = 0;
215
+ let unmatchedEnd = 0;
216
+ let width = 0;
217
+ let widthExtra = 0;
218
+ outer:
219
+ 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 (isWide(codePoint)) {
228
+ widthExtra = WIDE_WIDTH;
229
+ } else if (AMBIGUOUS_WIDTH !== REGULAR_WIDTH && isAmbiguous(codePoint)) {
230
+ widthExtra = AMBIGUOUS_WIDTH;
231
+ } else {
232
+ widthExtra = REGULAR_WIDTH;
233
+ }
234
+ if (width + widthExtra > truncationLimit) {
235
+ truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
236
+ }
237
+ if (width + widthExtra > LIMIT) {
238
+ truncationEnabled = true;
239
+ break outer;
240
+ }
241
+ lengthExtra += char.length;
242
+ width += widthExtra;
243
+ }
244
+ unmatchedStart = unmatchedEnd = 0;
245
+ }
246
+ if (index >= length)
247
+ break;
248
+ LATIN_RE.lastIndex = index;
249
+ if (LATIN_RE.test(input)) {
250
+ lengthExtra = LATIN_RE.lastIndex - index;
251
+ widthExtra = lengthExtra * REGULAR_WIDTH;
252
+ if (width + widthExtra > truncationLimit) {
253
+ truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / REGULAR_WIDTH));
254
+ }
255
+ if (width + widthExtra > LIMIT) {
256
+ truncationEnabled = true;
257
+ break;
258
+ }
259
+ width += widthExtra;
260
+ unmatchedStart = indexPrev;
261
+ unmatchedEnd = index;
262
+ index = indexPrev = LATIN_RE.lastIndex;
263
+ continue;
264
+ }
265
+ ANSI_RE.lastIndex = index;
266
+ if (ANSI_RE.test(input)) {
267
+ if (width + ANSI_WIDTH > truncationLimit) {
268
+ truncationIndex = Math.min(truncationIndex, index);
269
+ }
270
+ if (width + ANSI_WIDTH > LIMIT) {
271
+ truncationEnabled = true;
272
+ break;
273
+ }
274
+ width += ANSI_WIDTH;
275
+ unmatchedStart = indexPrev;
276
+ unmatchedEnd = index;
277
+ index = indexPrev = ANSI_RE.lastIndex;
278
+ continue;
279
+ }
280
+ CONTROL_RE.lastIndex = index;
281
+ if (CONTROL_RE.test(input)) {
282
+ lengthExtra = CONTROL_RE.lastIndex - index;
283
+ widthExtra = lengthExtra * CONTROL_WIDTH;
284
+ if (width + widthExtra > truncationLimit) {
285
+ truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / CONTROL_WIDTH));
286
+ }
287
+ if (width + widthExtra > LIMIT) {
288
+ truncationEnabled = true;
289
+ break;
290
+ }
291
+ width += widthExtra;
292
+ unmatchedStart = indexPrev;
293
+ unmatchedEnd = index;
294
+ index = indexPrev = CONTROL_RE.lastIndex;
295
+ continue;
296
+ }
297
+ TAB_RE.lastIndex = index;
298
+ if (TAB_RE.test(input)) {
299
+ lengthExtra = TAB_RE.lastIndex - index;
300
+ widthExtra = lengthExtra * TAB_WIDTH;
301
+ if (width + widthExtra > truncationLimit) {
302
+ truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / TAB_WIDTH));
303
+ }
304
+ if (width + widthExtra > LIMIT) {
305
+ truncationEnabled = true;
306
+ break;
307
+ }
308
+ width += widthExtra;
309
+ unmatchedStart = indexPrev;
310
+ unmatchedEnd = index;
311
+ index = indexPrev = TAB_RE.lastIndex;
312
+ continue;
313
+ }
314
+ EMOJI_RE.lastIndex = index;
315
+ if (EMOJI_RE.test(input)) {
316
+ if (width + EMOJI_WIDTH > truncationLimit) {
317
+ truncationIndex = Math.min(truncationIndex, index);
318
+ }
319
+ if (width + EMOJI_WIDTH > LIMIT) {
320
+ truncationEnabled = true;
321
+ break;
322
+ }
323
+ width += EMOJI_WIDTH;
324
+ unmatchedStart = indexPrev;
325
+ unmatchedEnd = index;
326
+ index = indexPrev = EMOJI_RE.lastIndex;
327
+ continue;
328
+ }
329
+ index += 1;
330
+ }
331
+ return {
332
+ width: truncationEnabled ? truncationLimit : width,
333
+ index: truncationEnabled ? truncationIndex : length,
334
+ truncated: truncationEnabled,
335
+ ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
336
+ };
337
+ };
338
+ var dist_default = getStringTruncatedWidth;
339
+
340
+ // node_modules/fast-string-width/dist/index.js
341
+ var NO_TRUNCATION2 = {
342
+ limit: Infinity,
343
+ ellipsis: "",
344
+ ellipsisWidth: 0
345
+ };
346
+ var fastStringWidth = (input, options = {}) => {
347
+ return dist_default(input, NO_TRUNCATION2, options).width;
348
+ };
349
+ var dist_default2 = fastStringWidth;
350
+
351
+ // node_modules/fast-wrap-ansi/lib/main.js
352
+ var ESC = "\x1B";
353
+ var CSI = "›";
354
+ var END_CODE = 39;
355
+ var ANSI_ESCAPE_BELL = "\x07";
356
+ var ANSI_CSI = "[";
357
+ var ANSI_OSC = "]";
358
+ var ANSI_SGR_TERMINATOR = "m";
359
+ var ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
360
+ var GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
361
+ var getClosingCode = (openingCode) => {
362
+ if (openingCode >= 30 && openingCode <= 37)
363
+ return 39;
364
+ if (openingCode >= 90 && openingCode <= 97)
365
+ return 39;
366
+ if (openingCode >= 40 && openingCode <= 47)
367
+ return 49;
368
+ if (openingCode >= 100 && openingCode <= 107)
369
+ return 49;
370
+ if (openingCode === 1 || openingCode === 2)
371
+ return 22;
372
+ if (openingCode === 3)
373
+ return 23;
374
+ if (openingCode === 4)
375
+ return 24;
376
+ if (openingCode === 7)
377
+ return 27;
378
+ if (openingCode === 8)
379
+ return 28;
380
+ if (openingCode === 9)
381
+ return 29;
382
+ if (openingCode === 0)
383
+ return 0;
384
+ return;
385
+ };
386
+ var wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
387
+ var wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
388
+ var wrapWord = (rows, word, columns) => {
389
+ const characters = word[Symbol.iterator]();
390
+ let isInsideEscape = false;
391
+ let isInsideLinkEscape = false;
392
+ let lastRow = rows.at(-1);
393
+ let visible = lastRow === undefined ? 0 : dist_default2(lastRow);
394
+ let currentCharacter = characters.next();
395
+ let nextCharacter = characters.next();
396
+ let rawCharacterIndex = 0;
397
+ while (!currentCharacter.done) {
398
+ const character = currentCharacter.value;
399
+ const characterLength = dist_default2(character);
400
+ if (visible + characterLength <= columns) {
401
+ rows[rows.length - 1] += character;
402
+ } else {
403
+ rows.push(character);
404
+ visible = 0;
405
+ }
406
+ if (character === ESC || character === CSI) {
407
+ isInsideEscape = true;
408
+ isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
409
+ }
410
+ if (isInsideEscape) {
411
+ if (isInsideLinkEscape) {
412
+ if (character === ANSI_ESCAPE_BELL) {
413
+ isInsideEscape = false;
414
+ isInsideLinkEscape = false;
415
+ }
416
+ } else if (character === ANSI_SGR_TERMINATOR) {
417
+ isInsideEscape = false;
418
+ }
419
+ } else {
420
+ visible += characterLength;
421
+ if (visible === columns && !nextCharacter.done) {
422
+ rows.push("");
423
+ visible = 0;
424
+ }
425
+ }
426
+ currentCharacter = nextCharacter;
427
+ nextCharacter = characters.next();
428
+ rawCharacterIndex += character.length;
429
+ }
430
+ lastRow = rows.at(-1);
431
+ if (!visible && lastRow !== undefined && lastRow.length && rows.length > 1) {
432
+ rows[rows.length - 2] += rows.pop();
433
+ }
434
+ };
435
+ var stringVisibleTrimSpacesRight = (string) => {
436
+ const words = string.split(" ");
437
+ let last = words.length;
438
+ while (last) {
439
+ if (dist_default2(words[last - 1])) {
440
+ break;
441
+ }
442
+ last--;
443
+ }
444
+ if (last === words.length) {
445
+ return string;
446
+ }
447
+ return words.slice(0, last).join(" ") + words.slice(last).join("");
448
+ };
449
+ var exec = (string, columns, options = {}) => {
450
+ if (options.trim !== false && string.trim() === "") {
451
+ return "";
452
+ }
453
+ let returnValue = "";
454
+ let escapeCode;
455
+ let escapeUrl;
456
+ const words = string.split(" ");
457
+ let rows = [""];
458
+ let rowLength = 0;
459
+ for (let index = 0;index < words.length; index++) {
460
+ const word = words[index];
461
+ if (options.trim !== false) {
462
+ const row = rows.at(-1) ?? "";
463
+ const trimmed = row.trimStart();
464
+ if (row.length !== trimmed.length) {
465
+ rows[rows.length - 1] = trimmed;
466
+ rowLength = dist_default2(trimmed);
467
+ }
468
+ }
469
+ if (index !== 0) {
470
+ if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
471
+ rows.push("");
472
+ rowLength = 0;
473
+ }
474
+ if (rowLength || options.trim === false) {
475
+ rows[rows.length - 1] += " ";
476
+ rowLength++;
477
+ }
478
+ }
479
+ const wordLength = dist_default2(word);
480
+ if (options.hard && wordLength > columns) {
481
+ const remainingColumns = columns - rowLength;
482
+ const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
483
+ const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
484
+ if (breaksStartingNextLine < breaksStartingThisLine) {
485
+ rows.push("");
486
+ }
487
+ wrapWord(rows, word, columns);
488
+ rowLength = dist_default2(rows.at(-1) ?? "");
489
+ continue;
490
+ }
491
+ if (rowLength + wordLength > columns && rowLength && wordLength) {
492
+ if (options.wordWrap === false && rowLength < columns) {
493
+ wrapWord(rows, word, columns);
494
+ rowLength = dist_default2(rows.at(-1) ?? "");
495
+ continue;
496
+ }
497
+ rows.push("");
498
+ rowLength = 0;
499
+ }
500
+ if (rowLength + wordLength > columns && options.wordWrap === false) {
501
+ wrapWord(rows, word, columns);
502
+ rowLength = dist_default2(rows.at(-1) ?? "");
503
+ continue;
504
+ }
505
+ rows[rows.length - 1] += word;
506
+ rowLength += wordLength;
507
+ }
508
+ if (options.trim !== false) {
509
+ rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
510
+ }
511
+ const preString = rows.join(`
512
+ `);
513
+ let inSurrogate = false;
514
+ for (let i = 0;i < preString.length; i++) {
515
+ const character = preString[i];
516
+ returnValue += character;
517
+ if (!inSurrogate) {
518
+ inSurrogate = character >= "\uD800" && character <= "\uDBFF";
519
+ } else {
520
+ continue;
521
+ }
522
+ if (character === ESC || character === CSI) {
523
+ GROUP_REGEX.lastIndex = i + 1;
524
+ const groupsResult = GROUP_REGEX.exec(preString);
525
+ const groups = groupsResult?.groups;
526
+ if (groups?.code !== undefined) {
527
+ const code = Number.parseFloat(groups.code);
528
+ escapeCode = code === END_CODE ? undefined : code;
529
+ } else if (groups?.uri !== undefined) {
530
+ escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
531
+ }
532
+ }
533
+ if (preString[i + 1] === `
534
+ `) {
535
+ if (escapeUrl) {
536
+ returnValue += wrapAnsiHyperlink("");
537
+ }
538
+ const closingCode = escapeCode ? getClosingCode(escapeCode) : undefined;
539
+ if (escapeCode && closingCode) {
540
+ returnValue += wrapAnsiCode(closingCode);
541
+ }
542
+ } else if (character === `
543
+ `) {
544
+ if (escapeCode && getClosingCode(escapeCode)) {
545
+ returnValue += wrapAnsiCode(escapeCode);
546
+ }
547
+ if (escapeUrl) {
548
+ returnValue += wrapAnsiHyperlink(escapeUrl);
549
+ }
550
+ }
551
+ }
552
+ return returnValue;
553
+ };
554
+ var CRLF_OR_LF = /\r?\n/;
555
+ function wrapAnsi(string, columns, options) {
556
+ return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join(`
557
+ `);
558
+ }
559
+
560
+ // node_modules/@clack/core/dist/index.mjs
561
+ var import_sisteransi = __toESM(require_src(), 1);
562
+ import { ReadStream as D } from "node:tty";
563
+ function d(r, t, e) {
564
+ if (!e.some((o) => !o.disabled))
565
+ return r;
566
+ const s = r + t, i = Math.max(e.length - 1, 0), n = s < 0 ? i : s > i ? 0 : s;
567
+ return e[n].disabled ? d(n, t < 0 ? -1 : 1, e) : n;
568
+ }
569
+ var E = ["up", "down", "left", "right", "space", "enter", "cancel"];
570
+ var G = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
571
+ var u = { actions: new Set(E), aliases: new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["\x03", "cancel"], ["escape", "cancel"]]), messages: { cancel: "Canceled", error: "Something went wrong" }, withGuide: true, date: { monthNames: [...G], messages: { required: "Please enter a valid date", invalidMonth: "There are only 12 months in a year", invalidDay: (r, t) => `There are only ${r} days in ${t}`, afterMin: (r) => `Date must be on or after ${r.toISOString().slice(0, 10)}`, beforeMax: (r) => `Date must be on or before ${r.toISOString().slice(0, 10)}` } } };
572
+ function V(r, t) {
573
+ if (typeof r == "string")
574
+ return u.aliases.get(r) === t;
575
+ for (const e of r)
576
+ if (e !== undefined && V(e, t))
577
+ return true;
578
+ return false;
579
+ }
580
+ function j(r, t) {
581
+ if (r === t)
582
+ return;
583
+ const e = r.split(`
584
+ `), s = t.split(`
585
+ `), i = Math.max(e.length, s.length), n = [];
586
+ for (let o = 0;o < i; o++)
587
+ e[o] !== s[o] && n.push(o);
588
+ return { lines: n, numLinesBefore: e.length, numLinesAfter: s.length, numLines: i };
589
+ }
590
+ var Y = globalThis.process.platform.startsWith("win");
591
+ var C = Symbol("clack:cancel");
592
+ function q(r) {
593
+ return r === C;
594
+ }
595
+ function w(r, t) {
596
+ const e = r;
597
+ e.isTTY && e.setRawMode(t);
598
+ }
599
+ function z({ input: r = $, output: t = S, overwrite: e = true, hideCursor: s = true } = {}) {
600
+ const i = _.createInterface({ input: r, output: t, prompt: "", tabSize: 1 });
601
+ _.emitKeypressEvents(r, i), r instanceof D && r.isTTY && r.setRawMode(true);
602
+ const n = (o, { name: a, sequence: h }) => {
603
+ const l = String(o);
604
+ if (V([l, a, h], "cancel")) {
605
+ s && t.write(import_sisteransi.cursor.show), process.exit(0);
606
+ return;
607
+ }
608
+ if (!e)
609
+ return;
610
+ const f = a === "return" ? 0 : -1, v = a === "return" ? -1 : 0;
611
+ _.moveCursor(t, f, v, () => {
612
+ _.clearLine(t, 1, () => {
613
+ r.once("keypress", n);
614
+ });
615
+ });
616
+ };
617
+ return s && t.write(import_sisteransi.cursor.hide), r.once("keypress", n), () => {
618
+ r.off("keypress", n), s && t.write(import_sisteransi.cursor.show), r instanceof D && r.isTTY && !Y && r.setRawMode(false), i.terminal = false, i.close();
619
+ };
620
+ }
621
+ var O = (r) => ("columns" in r) && typeof r.columns == "number" ? r.columns : 80;
622
+ var A = (r) => ("rows" in r) && typeof r.rows == "number" ? r.rows : 20;
623
+ function R(r, t, e, s = e) {
624
+ const i = O(r ?? S);
625
+ return wrapAnsi(t, i - e.length, { hard: true, trim: false }).split(`
626
+ `).map((n, o) => `${o === 0 ? s : e}${n}`).join(`
627
+ `);
628
+ }
629
+ var p = class {
630
+ input;
631
+ output;
632
+ _abortSignal;
633
+ rl;
634
+ opts;
635
+ _render;
636
+ _track = false;
637
+ _prevFrame = "";
638
+ _subscribers = new Map;
639
+ _cursor = 0;
640
+ state = "initial";
641
+ error = "";
642
+ value;
643
+ userInput = "";
644
+ constructor(t, e = true) {
645
+ const { input: s = $, output: i = S, render: n, signal: o, ...a } = t;
646
+ this.opts = a, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = e, this._abortSignal = o, this.input = s, this.output = i;
647
+ }
648
+ unsubscribe() {
649
+ this._subscribers.clear();
650
+ }
651
+ setSubscriber(t, e) {
652
+ const s = this._subscribers.get(t) ?? [];
653
+ s.push(e), this._subscribers.set(t, s);
654
+ }
655
+ on(t, e) {
656
+ this.setSubscriber(t, { cb: e });
657
+ }
658
+ once(t, e) {
659
+ this.setSubscriber(t, { cb: e, once: true });
660
+ }
661
+ emit(t, ...e) {
662
+ const s = this._subscribers.get(t) ?? [], i = [];
663
+ for (const n of s)
664
+ n.cb(...e), n.once && i.push(() => s.splice(s.indexOf(n), 1));
665
+ for (const n of i)
666
+ n();
667
+ }
668
+ prompt() {
669
+ return new Promise((t) => {
670
+ if (this._abortSignal) {
671
+ if (this._abortSignal.aborted)
672
+ return this.state = "cancel", this.close(), t(C);
673
+ this._abortSignal.addEventListener("abort", () => {
674
+ this.state = "cancel", this.close();
675
+ }, { once: true });
676
+ }
677
+ this.rl = P.createInterface({ input: this.input, tabSize: 2, prompt: "", escapeCodeTimeout: 50, terminal: true }), this.rl.prompt(), this.opts.initialUserInput !== undefined && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), w(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
678
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), w(this.input, false), t(this.value);
679
+ }), this.once("cancel", () => {
680
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), w(this.input, false), t(C);
681
+ });
682
+ });
683
+ }
684
+ _isActionKey(t, e) {
685
+ return t === "\t";
686
+ }
687
+ _setValue(t) {
688
+ this.value = t, this.emit("value", this.value);
689
+ }
690
+ _setUserInput(t, e) {
691
+ this.userInput = t ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
692
+ }
693
+ _clearUserInput() {
694
+ this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
695
+ }
696
+ onKeypress(t, e) {
697
+ if (this._track && e.name !== "return" && (e.name && this._isActionKey(t, 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 && u.aliases.has(e.name) && this.emit("cursor", u.aliases.get(e.name)), u.actions.has(e.name) && this.emit("cursor", e.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t?.toLowerCase(), e), e?.name === "return") {
698
+ if (this.opts.validate) {
699
+ const s = this.opts.validate(this.value);
700
+ s && (this.error = s instanceof Error ? s.message : s, this.state = "error", this.rl?.write(this.userInput));
701
+ }
702
+ this.state !== "error" && (this.state = "submit");
703
+ }
704
+ V([t, 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();
705
+ }
706
+ close() {
707
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
708
+ `), w(this.input, false), this.rl?.close(), this.rl = undefined, this.emit(`${this.state}`, this.value), this.unsubscribe();
709
+ }
710
+ restoreCursor() {
711
+ const t = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
712
+ `).length - 1;
713
+ this.output.write(import_sisteransi.cursor.move(-999, t * -1));
714
+ }
715
+ render() {
716
+ const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, { hard: true, trim: false });
717
+ if (t !== this._prevFrame) {
718
+ if (this.state === "initial")
719
+ this.output.write(import_sisteransi.cursor.hide);
720
+ else {
721
+ const e = j(this._prevFrame, t), s = A(this.output);
722
+ if (this.restoreCursor(), e) {
723
+ const i = Math.max(0, e.numLinesAfter - s), n = Math.max(0, e.numLinesBefore - s);
724
+ let o = e.lines.find((a) => a >= i);
725
+ if (o === undefined) {
726
+ this._prevFrame = t;
727
+ return;
728
+ }
729
+ if (e.lines.length === 1) {
730
+ this.output.write(import_sisteransi.cursor.move(0, o - n)), this.output.write(import_sisteransi.erase.lines(1));
731
+ const a = t.split(`
732
+ `);
733
+ this.output.write(a[o]), this._prevFrame = t, this.output.write(import_sisteransi.cursor.move(0, a.length - o - 1));
734
+ return;
735
+ } else if (e.lines.length > 1) {
736
+ if (i < n)
737
+ o = i;
738
+ else {
739
+ const h = o - n;
740
+ h > 0 && this.output.write(import_sisteransi.cursor.move(0, h));
741
+ }
742
+ this.output.write(import_sisteransi.erase.down());
743
+ const a = t.split(`
744
+ `).slice(o);
745
+ this.output.write(a.join(`
746
+ `)), this._prevFrame = t;
747
+ return;
748
+ }
749
+ }
750
+ this.output.write(import_sisteransi.erase.down());
751
+ }
752
+ this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
753
+ }
754
+ }
755
+ };
756
+ function W(r, t) {
757
+ if (r === undefined || t.length === 0)
758
+ return 0;
759
+ const e = t.findIndex((s) => s.value === r);
760
+ return e !== -1 ? e : 0;
761
+ }
762
+ function B(r, t) {
763
+ return (t.label ?? String(t.value)).toLowerCase().includes(r.toLowerCase());
764
+ }
765
+ function J(r, t) {
766
+ if (t)
767
+ return r ? t : t[0];
768
+ }
769
+ var H = class extends p {
770
+ filteredOptions;
771
+ multiple;
772
+ isNavigating = false;
773
+ selectedValues = [];
774
+ focusedValue;
775
+ #e = 0;
776
+ #o = "";
777
+ #t;
778
+ #n;
779
+ #a;
780
+ get cursor() {
781
+ return this.#e;
782
+ }
783
+ get userInputWithCursor() {
784
+ if (!this.userInput)
785
+ return y(["inverse", "hidden"], "_");
786
+ if (this._cursor >= this.userInput.length)
787
+ return `${this.userInput}█`;
788
+ const t = this.userInput.slice(0, this._cursor), [e, ...s] = this.userInput.slice(this._cursor);
789
+ return `${t}${y("inverse", e)}${s.join("")}`;
790
+ }
791
+ get options() {
792
+ return typeof this.#n == "function" ? this.#n() : this.#n;
793
+ }
794
+ constructor(t) {
795
+ super(t), this.#n = t.options, this.#a = t.placeholder;
796
+ const e = this.options;
797
+ this.filteredOptions = [...e], this.multiple = t.multiple === true, this.#t = typeof t.options == "function" ? t.filter : t.filter ?? B;
798
+ let s;
799
+ if (t.initialValue && Array.isArray(t.initialValue) ? this.multiple ? s = t.initialValue : s = t.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (s = [this.options[0].value]), s)
800
+ for (const i of s) {
801
+ const n = e.findIndex((o) => o.value === i);
802
+ n !== -1 && (this.toggleSelected(i), this.#e = n);
803
+ }
804
+ this.focusedValue = this.options[this.#e]?.value, this.on("key", (i, n) => this.#s(i, n)), this.on("userInput", (i) => this.#i(i));
805
+ }
806
+ _isActionKey(t, e) {
807
+ return t === "\t" || this.multiple && this.isNavigating && e.name === "space" && t !== undefined && t !== "";
808
+ }
809
+ #s(t, e) {
810
+ const s = e.name === "up", i = e.name === "down", n = e.name === "return", o = this.userInput === "" || this.userInput === "\t", a = this.#a, h = this.options, l = a !== undefined && a !== "" && h.some((f) => !f.disabled && (this.#t ? this.#t(a, f) : true));
811
+ if (e.name === "tab" && o && l) {
812
+ this.userInput === "\t" && this._clearUserInput(), this._setUserInput(a, true), this.isNavigating = false;
813
+ return;
814
+ }
815
+ s || i ? (this.#e = d(this.#e, s ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#e]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = true) : n ? this.value = J(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== undefined && (e.name === "tab" || this.isNavigating && e.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
816
+ }
817
+ deselectAll() {
818
+ this.selectedValues = [];
819
+ }
820
+ toggleSelected(t) {
821
+ this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(t) ? this.selectedValues = this.selectedValues.filter((e) => e !== t) : this.selectedValues = [...this.selectedValues, t] : this.selectedValues = [t]);
822
+ }
823
+ #i(t) {
824
+ if (t !== this.#o) {
825
+ this.#o = t;
826
+ const e = this.options;
827
+ t && this.#t ? this.filteredOptions = e.filter((n) => this.#t?.(t, n)) : this.filteredOptions = [...e];
828
+ const s = W(this.focusedValue, this.filteredOptions);
829
+ this.#e = d(s, 0, this.filteredOptions);
830
+ const i = this.filteredOptions[this.#e];
831
+ i && !i.disabled ? this.focusedValue = i.value : this.focusedValue = undefined, this.multiple || (this.focusedValue !== undefined ? this.toggleSelected(this.focusedValue) : this.deselectAll());
832
+ }
833
+ }
834
+ };
835
+
836
+ class Q extends p {
837
+ get cursor() {
838
+ return this.value ? 0 : 1;
839
+ }
840
+ get _value() {
841
+ return this.cursor === 0;
842
+ }
843
+ constructor(t) {
844
+ super(t, false), this.value = !!t.initialValue, this.on("userInput", () => {
845
+ this.value = this._value;
846
+ }), this.on("confirm", (e) => {
847
+ this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = e, this.state = "submit", this.close();
848
+ }), this.on("cursor", () => {
849
+ this.value = !this.value;
850
+ });
851
+ }
852
+ }
853
+ var X = { Y: { type: "year", len: 4 }, M: { type: "month", len: 2 }, D: { type: "day", len: 2 } };
854
+ function L(r) {
855
+ return [...r].map((t) => X[t]);
856
+ }
857
+ function Z(r) {
858
+ const t = new Intl.DateTimeFormat(r, { year: "numeric", month: "2-digit", day: "2-digit" }).formatToParts(new Date(2000, 0, 15)), e = [];
859
+ let s = "/";
860
+ for (const i of t)
861
+ i.type === "literal" ? s = i.value.trim() || i.value : (i.type === "year" || i.type === "month" || i.type === "day") && e.push({ type: i.type, len: i.type === "year" ? 4 : 2 });
862
+ return { segments: e, separator: s };
863
+ }
864
+ function k(r) {
865
+ return Number.parseInt((r || "0").replace(/_/g, "0"), 10) || 0;
866
+ }
867
+ function I(r) {
868
+ return { year: k(r.year), month: k(r.month), day: k(r.day) };
869
+ }
870
+ function T(r, t) {
871
+ return new Date(r || 2001, t || 1, 0).getDate();
872
+ }
873
+ function F(r) {
874
+ const { year: t, month: e, day: s } = I(r);
875
+ if (!t || t < 0 || t > 9999 || !e || e < 1 || e > 12 || !s || s < 1)
876
+ return;
877
+ const i = new Date(Date.UTC(t, e - 1, s));
878
+ if (!(i.getUTCFullYear() !== t || i.getUTCMonth() !== e - 1 || i.getUTCDate() !== s))
879
+ return { year: t, month: e, day: s };
880
+ }
881
+ function N(r) {
882
+ const t = F(r);
883
+ return t ? new Date(Date.UTC(t.year, t.month - 1, t.day)) : undefined;
884
+ }
885
+ function tt(r, t, e, s) {
886
+ const i = e ? { year: e.getUTCFullYear(), month: e.getUTCMonth() + 1, day: e.getUTCDate() } : null, n = s ? { year: s.getUTCFullYear(), month: s.getUTCMonth() + 1, day: s.getUTCDate() } : null;
887
+ return r === "year" ? { min: i?.year ?? 1, max: n?.year ?? 9999 } : r === "month" ? { min: i && t.year === i.year ? i.month : 1, max: n && t.year === n.year ? n.month : 12 } : { min: i && t.year === i.year && t.month === i.month ? i.day : 1, max: n && t.year === n.year && t.month === n.month ? n.day : T(t.year, t.month) };
888
+ }
889
+
890
+ class et extends p {
891
+ #e;
892
+ #o;
893
+ #t;
894
+ #n;
895
+ #a;
896
+ #s = { segmentIndex: 0, positionInSegment: 0 };
897
+ #i = true;
898
+ #r = null;
899
+ inlineError = "";
900
+ get segmentCursor() {
901
+ return { ...this.#s };
902
+ }
903
+ get segmentValues() {
904
+ return { ...this.#t };
905
+ }
906
+ get segments() {
907
+ return this.#e;
908
+ }
909
+ get separator() {
910
+ return this.#o;
911
+ }
912
+ get formattedValue() {
913
+ return this.#c(this.#t);
914
+ }
915
+ #c(t) {
916
+ return this.#e.map((e) => t[e.type]).join(this.#o);
917
+ }
918
+ #h() {
919
+ this._setUserInput(this.#c(this.#t)), this._setValue(N(this.#t) ?? undefined);
920
+ }
921
+ constructor(t) {
922
+ const e = t.format ? { segments: L(t.format), separator: t.separator ?? "/" } : Z(t.locale), s = t.separator ?? e.separator, i = t.format ? L(t.format) : e.segments, n = t.initialValue ?? t.defaultValue, o = n ? { year: String(n.getUTCFullYear()).padStart(4, "0"), month: String(n.getUTCMonth() + 1).padStart(2, "0"), day: String(n.getUTCDate()).padStart(2, "0") } : { year: "____", month: "__", day: "__" }, a = i.map((h) => o[h.type]).join(s);
923
+ super({ ...t, initialUserInput: a }, false), this.#e = i, this.#o = s, this.#t = o, this.#n = t.minDate, this.#a = t.maxDate, this.#h(), this.on("cursor", (h) => this.#d(h)), this.on("key", (h, l) => this.#f(h, l)), this.on("finalize", () => this.#g(t));
924
+ }
925
+ #u() {
926
+ const t = Math.max(0, Math.min(this.#s.segmentIndex, this.#e.length - 1)), e = this.#e[t];
927
+ if (e)
928
+ return this.#s.positionInSegment = Math.max(0, Math.min(this.#s.positionInSegment, e.len - 1)), { segment: e, index: t };
929
+ }
930
+ #l(t) {
931
+ this.inlineError = "", this.#r = null;
932
+ const e = this.#u();
933
+ e && (this.#s.segmentIndex = Math.max(0, Math.min(this.#e.length - 1, e.index + t)), this.#s.positionInSegment = 0, this.#i = true);
934
+ }
935
+ #p(t) {
936
+ const e = this.#u();
937
+ if (!e)
938
+ return;
939
+ const { segment: s } = e, i = this.#t[s.type], n = !i || i.replace(/_/g, "") === "", o = Number.parseInt((i || "0").replace(/_/g, "0"), 10) || 0, a = tt(s.type, I(this.#t), this.#n, this.#a);
940
+ let h;
941
+ n ? h = t === 1 ? a.min : a.max : h = Math.max(Math.min(a.max, o + t), a.min), this.#t = { ...this.#t, [s.type]: h.toString().padStart(s.len, "0") }, this.#i = true, this.#r = null, this.#h();
942
+ }
943
+ #d(t) {
944
+ if (t)
945
+ switch (t) {
946
+ case "right":
947
+ return this.#l(1);
948
+ case "left":
949
+ return this.#l(-1);
950
+ case "up":
951
+ return this.#p(1);
952
+ case "down":
953
+ return this.#p(-1);
954
+ }
955
+ }
956
+ #f(t, e) {
957
+ if (e?.name === "backspace" || e?.sequence === "" || e?.sequence === "\b" || t === "" || t === "\b") {
958
+ this.inlineError = "";
959
+ const s = this.#u();
960
+ if (!s)
961
+ return;
962
+ if (!this.#t[s.segment.type].replace(/_/g, "")) {
963
+ this.#l(-1);
964
+ return;
965
+ }
966
+ this.#t[s.segment.type] = "_".repeat(s.segment.len), this.#i = true, this.#s.positionInSegment = 0, this.#h();
967
+ return;
968
+ }
969
+ if (e?.name === "tab") {
970
+ this.inlineError = "";
971
+ const s = this.#u();
972
+ if (!s)
973
+ return;
974
+ const i = e.shift ? -1 : 1, n = s.index + i;
975
+ n >= 0 && n < this.#e.length && (this.#s.segmentIndex = n, this.#s.positionInSegment = 0, this.#i = true);
976
+ return;
977
+ }
978
+ if (t && /^[0-9]$/.test(t)) {
979
+ const s = this.#u();
980
+ if (!s)
981
+ return;
982
+ const { segment: i } = s, n = !this.#t[i.type].replace(/_/g, "");
983
+ if (this.#i && this.#r !== null && !n) {
984
+ const m = this.#r + t, g = { ...this.#t, [i.type]: m }, b = this.#m(g, i);
985
+ if (b) {
986
+ this.inlineError = b, this.#r = null, this.#i = false;
987
+ return;
988
+ }
989
+ this.inlineError = "", this.#t[i.type] = m, this.#r = null, this.#i = false, this.#h(), s.index < this.#e.length - 1 && (this.#s.segmentIndex = s.index + 1, this.#s.positionInSegment = 0, this.#i = true);
990
+ return;
991
+ }
992
+ this.#i && !n && (this.#t[i.type] = "_".repeat(i.len), this.#s.positionInSegment = 0), this.#i = false, this.#r = null;
993
+ const o = this.#t[i.type], a = o.indexOf("_"), h = a >= 0 ? a : Math.min(this.#s.positionInSegment, i.len - 1);
994
+ if (h < 0 || h >= i.len)
995
+ return;
996
+ let l = o.slice(0, h) + t + o.slice(h + 1), f = false;
997
+ if (h === 0 && o === "__" && (i.type === "month" || i.type === "day")) {
998
+ const m = Number.parseInt(t, 10);
999
+ l = `0${t}`, f = m <= (i.type === "month" ? 1 : 2);
1000
+ }
1001
+ if (i.type === "year" && (l = (o.replace(/_/g, "") + t).padStart(i.len, "_")), !l.includes("_")) {
1002
+ const m = { ...this.#t, [i.type]: l }, g = this.#m(m, i);
1003
+ if (g) {
1004
+ this.inlineError = g;
1005
+ return;
1006
+ }
1007
+ }
1008
+ this.inlineError = "", this.#t[i.type] = l;
1009
+ const v = l.includes("_") ? undefined : F(this.#t);
1010
+ if (v) {
1011
+ const { year: m, month: g } = v, b = T(m, g);
1012
+ this.#t = { year: String(Math.max(0, Math.min(9999, m))).padStart(4, "0"), month: String(Math.max(1, Math.min(12, g))).padStart(2, "0"), day: String(Math.max(1, Math.min(b, v.day))).padStart(2, "0") };
1013
+ }
1014
+ this.#h();
1015
+ const U = l.indexOf("_");
1016
+ f ? (this.#i = true, this.#r = t) : U >= 0 ? this.#s.positionInSegment = U : a >= 0 && s.index < this.#e.length - 1 ? (this.#s.segmentIndex = s.index + 1, this.#s.positionInSegment = 0, this.#i = true) : this.#s.positionInSegment = Math.min(h + 1, i.len - 1);
1017
+ }
1018
+ }
1019
+ #m(t, e) {
1020
+ const { month: s, day: i } = I(t);
1021
+ if (e.type === "month" && (s < 0 || s > 12))
1022
+ return u.date.messages.invalidMonth;
1023
+ if (e.type === "day" && (i < 0 || i > 31))
1024
+ return u.date.messages.invalidDay(31, "any month");
1025
+ }
1026
+ #g(t) {
1027
+ const { year: e, month: s, day: i } = I(this.#t);
1028
+ if (e && s && i) {
1029
+ const n = T(e, s);
1030
+ this.#t = { ...this.#t, day: String(Math.min(i, n)).padStart(2, "0") };
1031
+ }
1032
+ this.value = N(this.#t) ?? t.defaultValue ?? undefined;
1033
+ }
1034
+ }
1035
+
1036
+ class st extends p {
1037
+ options;
1038
+ cursor = 0;
1039
+ #e;
1040
+ getGroupItems(t) {
1041
+ return this.options.filter((e) => e.group === t);
1042
+ }
1043
+ isGroupSelected(t) {
1044
+ const e = this.getGroupItems(t), s = this.value;
1045
+ return s === undefined ? false : e.every((i) => s.includes(i.value));
1046
+ }
1047
+ toggleValue() {
1048
+ const t = this.options[this.cursor];
1049
+ if (this.value === undefined && (this.value = []), t.group === true) {
1050
+ const e = t.value, s = this.getGroupItems(e);
1051
+ this.isGroupSelected(e) ? this.value = this.value.filter((i) => s.findIndex((n) => n.value === i) === -1) : this.value = [...this.value, ...s.map((i) => i.value)], this.value = Array.from(new Set(this.value));
1052
+ } else {
1053
+ const e = this.value.includes(t.value);
1054
+ this.value = e ? this.value.filter((s) => s !== t.value) : [...this.value, t.value];
1055
+ }
1056
+ }
1057
+ constructor(t) {
1058
+ super(t, false);
1059
+ const { options: e } = t;
1060
+ this.#e = t.selectableGroups !== false, this.options = Object.entries(e).flatMap(([s, i]) => [{ value: s, group: true, label: s }, ...i.map((n) => ({ ...n, group: s }))]), this.value = [...t.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: s }) => s === t.cursorAt), this.#e ? 0 : 1), this.on("cursor", (s) => {
1061
+ switch (s) {
1062
+ case "left":
1063
+ case "up": {
1064
+ this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
1065
+ const i = this.options[this.cursor]?.group === true;
1066
+ !this.#e && i && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
1067
+ break;
1068
+ }
1069
+ case "down":
1070
+ case "right": {
1071
+ this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
1072
+ const i = this.options[this.cursor]?.group === true;
1073
+ !this.#e && i && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
1074
+ break;
1075
+ }
1076
+ case "space":
1077
+ this.toggleValue();
1078
+ break;
1079
+ }
1080
+ });
1081
+ }
1082
+ }
1083
+ class at extends p {
1084
+ get userInputWithCursor() {
1085
+ if (this.state === "submit")
1086
+ return this.userInput;
1087
+ const t = this.userInput;
1088
+ if (this.cursor >= t.length)
1089
+ return `${this.userInput}█`;
1090
+ const e = t.slice(0, this.cursor), [s, ...i] = t.slice(this.cursor);
1091
+ return `${e}${y("inverse", s)}${i.join("")}`;
1092
+ }
1093
+ get cursor() {
1094
+ return this._cursor;
1095
+ }
1096
+ constructor(t) {
1097
+ super({ ...t, initialUserInput: t.initialUserInput ?? t.initialValue }), this.on("userInput", (e) => {
1098
+ this._setValue(e);
1099
+ }), this.on("finalize", () => {
1100
+ this.value || (this.value = t.defaultValue), this.value === undefined && (this.value = "");
1101
+ });
1102
+ }
1103
+ }
1104
+
1105
+ // node_modules/@clack/prompts/dist/index.mjs
1106
+ import { styleText as t, stripVTControlCharacters as ne } from "node:util";
1107
+ import P2 from "node:process";
1108
+ var import_sisteransi2 = __toESM(require_src(), 1);
1109
+ function Ze() {
1110
+ return P2.platform !== "win32" ? P2.env.TERM !== "linux" : !!P2.env.CI || !!P2.env.WT_SESSION || !!P2.env.TERMINUS_SUBLIME || P2.env.ConEmuTask === "{cmd::Cmder}" || P2.env.TERM_PROGRAM === "Terminus-Sublime" || P2.env.TERM_PROGRAM === "vscode" || P2.env.TERM === "xterm-256color" || P2.env.TERM === "alacritty" || P2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
1111
+ }
1112
+ var ee = Ze();
1113
+ var ae = () => process.env.CI === "true";
1114
+ var w2 = (e, i) => ee ? e : i;
1115
+ var _e = w2("◆", "*");
1116
+ var oe = w2("■", "x");
1117
+ var ue = w2("▲", "x");
1118
+ var F2 = w2("◇", "o");
1119
+ var le = w2("┌", "T");
1120
+ var d2 = w2("│", "|");
1121
+ var E2 = w2("└", "—");
1122
+ var Ie = w2("┐", "T");
1123
+ var Ee = w2("┘", "—");
1124
+ var z2 = w2("●", ">");
1125
+ var H2 = w2("○", " ");
1126
+ var te = w2("◻", "[•]");
1127
+ var U = w2("◼", "[+]");
1128
+ var J2 = w2("◻", "[ ]");
1129
+ var xe = w2("▪", "•");
1130
+ var se = w2("─", "-");
1131
+ var ce = w2("╮", "+");
1132
+ var Ge = w2("├", "+");
1133
+ var $e = w2("╯", "+");
1134
+ var de = w2("╰", "+");
1135
+ var Oe = w2("╭", "+");
1136
+ var he = w2("●", "•");
1137
+ var pe = w2("◆", "*");
1138
+ var me = w2("▲", "!");
1139
+ var ge = w2("■", "x");
1140
+ var V2 = (e) => {
1141
+ switch (e) {
1142
+ case "initial":
1143
+ case "active":
1144
+ return t("cyan", _e);
1145
+ case "cancel":
1146
+ return t("red", oe);
1147
+ case "error":
1148
+ return t("yellow", ue);
1149
+ case "submit":
1150
+ return t("green", F2);
1151
+ }
1152
+ };
1153
+ var ot2 = (e) => {
1154
+ const i = e.active ?? "Yes", s = e.inactive ?? "No";
1155
+ return new Q({ active: i, inactive: s, signal: e.signal, input: e.input, output: e.output, initialValue: e.initialValue ?? true, render() {
1156
+ const r = e.withGuide ?? u.withGuide, u2 = `${V2(this.state)} `, n = r ? `${t("gray", d2)} ` : "", o = R(e.output, e.message, n, u2), c2 = `${r ? `${t("gray", d2)}
1157
+ ` : ""}${o}
1158
+ `, a = this.value ? i : s;
1159
+ switch (this.state) {
1160
+ case "submit": {
1161
+ const l = r ? `${t("gray", d2)} ` : "";
1162
+ return `${c2}${l}${t("dim", a)}`;
1163
+ }
1164
+ case "cancel": {
1165
+ const l = r ? `${t("gray", d2)} ` : "";
1166
+ return `${c2}${l}${t(["strikethrough", "dim"], a)}${r ? `
1167
+ ${t("gray", d2)}` : ""}`;
1168
+ }
1169
+ default: {
1170
+ const l = r ? `${t("cyan", d2)} ` : "", $2 = r ? t("cyan", E2) : "";
1171
+ return `${c2}${l}${this.value ? `${t("green", z2)} ${i}` : `${t("dim", H2)} ${t("dim", i)}`}${e.vertical ? r ? `
1172
+ ${t("cyan", d2)} ` : `
1173
+ ` : ` ${t("dim", "/")} `}${this.value ? `${t("dim", H2)} ${t("dim", s)}` : `${t("green", z2)} ${s}`}
1174
+ ${$2}
1175
+ `;
1176
+ }
1177
+ }
1178
+ } }).prompt();
1179
+ };
1180
+ var O2 = { message: (e = [], { symbol: i = t("gray", d2), secondarySymbol: s = t("gray", d2), output: r = process.stdout, spacing: u2 = 1, withGuide: n } = {}) => {
1181
+ const o = [], c2 = n ?? u.withGuide, a = c2 ? s : "", l = c2 ? `${i} ` : "", $2 = c2 ? `${s} ` : "";
1182
+ for (let p2 = 0;p2 < u2; p2++)
1183
+ o.push(a);
1184
+ const y2 = Array.isArray(e) ? e : e.split(`
1185
+ `);
1186
+ if (y2.length > 0) {
1187
+ const [p2, ...m] = y2;
1188
+ p2.length > 0 ? o.push(`${l}${p2}`) : o.push(c2 ? i : "");
1189
+ for (const g of m)
1190
+ g.length > 0 ? o.push(`${$2}${g}`) : o.push(c2 ? s : "");
1191
+ }
1192
+ r.write(`${o.join(`
1193
+ `)}
1194
+ `);
1195
+ }, info: (e, i) => {
1196
+ O2.message(e, { ...i, symbol: t("blue", he) });
1197
+ }, success: (e, i) => {
1198
+ O2.message(e, { ...i, symbol: t("green", pe) });
1199
+ }, step: (e, i) => {
1200
+ O2.message(e, { ...i, symbol: t("green", F2) });
1201
+ }, warn: (e, i) => {
1202
+ O2.message(e, { ...i, symbol: t("yellow", me) });
1203
+ }, warning: (e, i) => {
1204
+ O2.warn(e, i);
1205
+ }, error: (e, i) => {
1206
+ O2.message(e, { ...i, symbol: t("red", ge) });
1207
+ } };
1208
+ var pt = (e = "", i) => {
1209
+ const s = i?.output ?? process.stdout, r = i?.withGuide ?? u.withGuide ? `${t("gray", E2)} ` : "";
1210
+ s.write(`${r}${t("red", e)}
1211
+
1212
+ `);
1213
+ };
1214
+ var mt = (e = "", i) => {
1215
+ const s = i?.output ?? process.stdout, r = i?.withGuide ?? u.withGuide ? `${t("gray", le)} ` : "";
1216
+ s.write(`${r}${e}
1217
+ `);
1218
+ };
1219
+ var gt = (e = "", i) => {
1220
+ const s = i?.output ?? process.stdout, r = i?.withGuide ?? u.withGuide ? `${t("gray", d2)}
1221
+ ${t("gray", E2)} ` : "";
1222
+ s.write(`${r}${e}
1223
+
1224
+ `);
1225
+ };
1226
+ var Ct = (e) => t("magenta", e);
1227
+ var fe = ({ indicator: e = "dots", onCancel: i, output: s = process.stdout, cancelMessage: r, errorMessage: u2, frames: n = ee ? ["◒", "◐", "◓", "◑"] : ["•", "o", "O", "0"], delay: o = ee ? 80 : 120, signal: c2, ...a } = {}) => {
1228
+ const l = ae();
1229
+ let $2, y2, p2 = false, m = false, g = "", S2, h = performance.now();
1230
+ const f = O(s), v = a?.styleFrame ?? Ct, T2 = (_2) => {
1231
+ const A2 = _2 > 1 ? u2 ?? u.messages.error : r ?? u.messages.cancel;
1232
+ m = _2 === 1, p2 && (W2(A2, _2), m && typeof i == "function" && i());
1233
+ }, C2 = () => T2(2), b = () => T2(1), x = () => {
1234
+ process.on("uncaughtExceptionMonitor", C2), process.on("unhandledRejection", C2), process.on("SIGINT", b), process.on("SIGTERM", b), process.on("exit", T2), c2 && c2.addEventListener("abort", b);
1235
+ }, G2 = () => {
1236
+ process.removeListener("uncaughtExceptionMonitor", C2), process.removeListener("unhandledRejection", C2), process.removeListener("SIGINT", b), process.removeListener("SIGTERM", b), process.removeListener("exit", T2), c2 && c2.removeEventListener("abort", b);
1237
+ }, M2 = () => {
1238
+ if (S2 === undefined)
1239
+ return;
1240
+ l && s.write(`
1241
+ `);
1242
+ const _2 = wrapAnsi(S2, f, { hard: true, trim: false }).split(`
1243
+ `);
1244
+ _2.length > 1 && s.write(import_sisteransi2.cursor.up(_2.length - 1)), s.write(import_sisteransi2.cursor.to(0)), s.write(import_sisteransi2.erase.down());
1245
+ }, R2 = (_2) => _2.replace(/\.+$/, ""), j2 = (_2) => {
1246
+ const A2 = (performance.now() - _2) / 1000, k2 = Math.floor(A2 / 60), L2 = Math.floor(A2 % 60);
1247
+ return k2 > 0 ? `[${k2}m ${L2}s]` : `[${L2}s]`;
1248
+ }, D2 = a.withGuide ?? u.withGuide, ie = (_2 = "") => {
1249
+ p2 = true, $2 = z({ output: s }), g = R2(_2), h = performance.now(), D2 && s.write(`${t("gray", d2)}
1250
+ `);
1251
+ let A2 = 0, k2 = 0;
1252
+ x(), y2 = setInterval(() => {
1253
+ if (l && g === S2)
1254
+ return;
1255
+ M2(), S2 = g;
1256
+ const L2 = v(n[A2]);
1257
+ let Z2;
1258
+ if (l)
1259
+ Z2 = `${L2} ${g}...`;
1260
+ else if (e === "timer")
1261
+ Z2 = `${L2} ${g} ${j2(h)}`;
1262
+ else {
1263
+ const Be = ".".repeat(Math.floor(k2)).slice(0, 3);
1264
+ Z2 = `${L2} ${g}${Be}`;
1265
+ }
1266
+ const Ne = wrapAnsi(Z2, f, { hard: true, trim: false });
1267
+ s.write(Ne), A2 = A2 + 1 < n.length ? A2 + 1 : 0, k2 = k2 < 4 ? k2 + 0.125 : 0;
1268
+ }, o);
1269
+ }, W2 = (_2 = "", A2 = 0, k2 = false) => {
1270
+ if (!p2)
1271
+ return;
1272
+ p2 = false, clearInterval(y2), M2();
1273
+ const L2 = A2 === 0 ? t("green", F2) : A2 === 1 ? t("red", oe) : t("red", ue);
1274
+ g = _2 ?? g, k2 || (e === "timer" ? s.write(`${L2} ${g} ${j2(h)}
1275
+ `) : s.write(`${L2} ${g}
1276
+ `)), G2(), $2();
1277
+ };
1278
+ return { start: ie, stop: (_2 = "") => W2(_2, 0), message: (_2 = "") => {
1279
+ g = R2(_2 ?? g);
1280
+ }, cancel: (_2 = "") => W2(_2, 1), error: (_2 = "") => W2(_2, 2), clear: () => W2("", 0, true), get isCancelled() {
1281
+ return m;
1282
+ } };
1283
+ };
1284
+ var Ve = { light: w2("─", "-"), heavy: w2("━", "="), block: w2("█", "#") };
1285
+ var je = `${t("gray", d2)} `;
1286
+ var Ot = (e) => new at({ validate: e.validate, placeholder: e.placeholder, defaultValue: e.defaultValue, initialValue: e.initialValue, output: e.output, signal: e.signal, input: e.input, render() {
1287
+ const i = e?.withGuide ?? u.withGuide, s = `${`${i ? `${t("gray", d2)}
1288
+ ` : ""}${V2(this.state)} `}${e.message}
1289
+ `, r = e.placeholder ? t("inverse", e.placeholder[0]) + t("dim", e.placeholder.slice(1)) : t(["inverse", "hidden"], "_"), u2 = this.userInput ? this.userInputWithCursor : r, n = this.value ?? "";
1290
+ switch (this.state) {
1291
+ case "error": {
1292
+ const o = this.error ? ` ${t("yellow", this.error)}` : "", c2 = i ? `${t("yellow", d2)} ` : "", a = i ? t("yellow", E2) : "";
1293
+ return `${s.trim()}
1294
+ ${c2}${u2}
1295
+ ${a}${o}
1296
+ `;
1297
+ }
1298
+ case "submit": {
1299
+ const o = n ? ` ${t("dim", n)}` : "", c2 = i ? t("gray", d2) : "";
1300
+ return `${s}${c2}${o}`;
1301
+ }
1302
+ case "cancel": {
1303
+ const o = n ? ` ${t(["strikethrough", "dim"], n)}` : "", c2 = i ? t("gray", d2) : "";
1304
+ return `${s}${c2}${o}${n.trim() ? `
1305
+ ${c2}` : ""}`;
1306
+ }
1307
+ default: {
1308
+ const o = i ? `${t("cyan", d2)} ` : "", c2 = i ? t("cyan", E2) : "";
1309
+ return `${s}${o}${u2}
1310
+ ${c2}
1311
+ `;
1312
+ }
1313
+ }
1314
+ } }).prompt();
1315
+
1316
+ // src/index.ts
1317
+ var import_picocolors = __toESM(require_picocolors(), 1);
1318
+ var __dirname2 = dirname(fileURLToPath(import.meta.url));
1319
+ var TEMPLATES_DIR = join(__dirname2, "..", "templates");
1320
+ function copyTemplate(src, dest) {
1321
+ if (!existsSync(src))
1322
+ return;
1323
+ cpSync(src, dest, { recursive: true, force: true });
1324
+ }
1325
+ async function main() {
1326
+ console.log();
1327
+ mt(import_picocolors.default.bgCyan(import_picocolors.default.black(" create-dstack ")));
1328
+ let projectName = process.argv[2];
1329
+ if (!projectName) {
1330
+ const input = await Ot({
1331
+ message: "Project name",
1332
+ placeholder: "my-app",
1333
+ validate: (v) => !v || v.length === 0 ? "Name is required" : undefined
1334
+ });
1335
+ if (q(input)) {
1336
+ pt("Cancelled.");
1337
+ process.exit(0);
1338
+ }
1339
+ projectName = input;
1340
+ }
1341
+ const useStackAuth = await ot2({ message: "Add Stack Auth?" });
1342
+ if (q(useStackAuth)) {
1343
+ pt("Cancelled.");
1344
+ process.exit(0);
1345
+ }
1346
+ const projectDir = resolve(process.cwd(), projectName);
1347
+ if (existsSync(projectDir)) {
1348
+ pt(`Directory "${projectName}" already exists.`);
1349
+ process.exit(1);
1350
+ }
1351
+ const s = fe();
1352
+ s.start("preheating the oven...");
1353
+ await $2`bunx create-next-app@latest ${projectName} --typescript --tailwind --no-eslint --app --src-dir --import-alias "@/*" --use-bun`.quiet();
1354
+ s.stop("next.js is in the chat");
1355
+ s.start("calling convex off the bench...");
1356
+ await $2`bun add convex`.cwd(projectDir).quiet();
1357
+ s.stop("convex said say less");
1358
+ s.start("the linter and formatter are suiting up...");
1359
+ await $2`bun add -d oxlint oxfmt`.cwd(projectDir).quiet();
1360
+ s.stop("no slop code allowed fr fr");
1361
+ s.start("adding the drip (shadcn)...");
1362
+ await $2`bunx shadcn@latest init -d`.cwd(projectDir).quiet();
1363
+ s.stop("looking fire already");
1364
+ if (useStackAuth) {
1365
+ s.start("sliding stack auth into the dm...");
1366
+ await $2`bun add @stackframe/stack`.cwd(projectDir).quiet();
1367
+ s.stop("auth is cooked and ready");
1368
+ mkdirSync(join(projectDir, "convex"), { recursive: true });
1369
+ copyTemplate(join(TEMPLATES_DIR, "convex", "auth.config.ts"), join(projectDir, "convex", "auth.config.ts"));
1370
+ appendFileSync(join(projectDir, ".env.local"), [
1371
+ "",
1372
+ "# Stack Auth \u2014 fill in from https://app.stack-auth.com",
1373
+ "NEXT_PUBLIC_STACK_PROJECT_ID=",
1374
+ "NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY=",
1375
+ "STACK_SECRET_SERVER_KEY=",
1376
+ ""
1377
+ ].join(`
1378
+ `));
1379
+ O2.warn(`Stack Auth needs manual steps:
1380
+ ` + ` 1. Create a project at ${import_picocolors.default.cyan("https://app.stack-auth.com")}
1381
+ ` + ` 2. Fill in ${import_picocolors.default.dim(".env.local")} with your keys
1382
+ ` + ` 3. Set the same vars in your Convex dashboard
1383
+ ` + ` 4. Run ${import_picocolors.default.cyan("bunx @stackframe/stack-cli@latest init")} inside the project to finish wiring up the provider`);
1384
+ }
1385
+ s.start("putting the secret sauce on it...");
1386
+ copyTemplate(join(TEMPLATES_DIR, "globals.css"), join(projectDir, "src", "app", "globals.css"));
1387
+ copyTemplate(join(TEMPLATES_DIR, "oxlint.json"), join(projectDir, "oxlint.json"));
1388
+ copyTemplate(join(TEMPLATES_DIR, "oxfmt.json"), join(projectDir, "oxfmt.json"));
1389
+ if (existsSync(join(TEMPLATES_DIR, ".claude"))) {
1390
+ copyTemplate(join(TEMPLATES_DIR, ".claude"), join(projectDir, ".claude"));
1391
+ }
1392
+ if (existsSync(join(TEMPLATES_DIR, ".cursor"))) {
1393
+ copyTemplate(join(TEMPLATES_DIR, ".cursor"), join(projectDir, ".cursor"));
1394
+ }
1395
+ copyTemplate(join(TEMPLATES_DIR, "agents.md"), join(projectDir, "agents.md"));
1396
+ copyTemplate(join(TEMPLATES_DIR, "CLAUDE.md"), join(projectDir, "CLAUDE.md"));
1397
+ const pkgPath = join(projectDir, "package.json");
1398
+ const pkg = await Bun.file(pkgPath).json();
1399
+ pkg.scripts = {
1400
+ ...pkg.scripts,
1401
+ lint: "oxlint .",
1402
+ format: "oxfmt .",
1403
+ "format:check": "oxfmt --check ."
1404
+ };
1405
+ await Bun.write(pkgPath, JSON.stringify(pkg, null, 2) + `
1406
+ `);
1407
+ s.stop("this thing is absolutely cooked (in a good way)");
1408
+ gt(`${import_picocolors.default.green("Ready.")} ${import_picocolors.default.dim("Next steps:")}
1409
+
1410
+ ` + ` ${import_picocolors.default.cyan("cd")} ${projectName}
1411
+ ` + ` ${import_picocolors.default.cyan("bun dev")} start dev server
1412
+ ` + ` ${import_picocolors.default.cyan("bunx convex dev")} start Convex (first run: login)
1413
+ ` + ` ${import_picocolors.default.cyan("bun lint")} run Oxlint
1414
+ ` + ` ${import_picocolors.default.cyan("bun format")} run Oxfmt`);
1415
+ }
1416
+ main().catch((e) => {
1417
+ pt(e.message ?? "Something went wrong.");
1418
+ process.exit(1);
1419
+ });