@jannael/glinter 1.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 (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +58 -0
  3. package/dist/index.js +1242 -0
  4. package/package.json +58 -0
package/dist/index.js ADDED
@@ -0,0 +1,1242 @@
1
+ #!/usr/bin/env bun
2
+ // @bun
3
+ var __create = Object.create;
4
+ var __getProtoOf = Object.getPrototypeOf;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __toESM = (mod, isNodeMode, target) => {
9
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
10
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
11
+ for (let key of __getOwnPropNames(mod))
12
+ if (!__hasOwnProp.call(to, key))
13
+ __defProp(to, key, {
14
+ get: () => mod[key],
15
+ enumerable: true
16
+ });
17
+ return to;
18
+ };
19
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
20
+
21
+ // node_modules/sisteransi/src/index.js
22
+ var require_src = __commonJS((exports, module) => {
23
+ var ESC2 = "\x1B";
24
+ var CSI2 = `${ESC2}[`;
25
+ var beep = "\x07";
26
+ var cursor = {
27
+ to(x, y) {
28
+ if (!y)
29
+ return `${CSI2}${x + 1}G`;
30
+ return `${CSI2}${y + 1};${x + 1}H`;
31
+ },
32
+ move(x, y) {
33
+ let ret = "";
34
+ if (x < 0)
35
+ ret += `${CSI2}${-x}D`;
36
+ else if (x > 0)
37
+ ret += `${CSI2}${x}C`;
38
+ if (y < 0)
39
+ ret += `${CSI2}${-y}A`;
40
+ else if (y > 0)
41
+ ret += `${CSI2}${y}B`;
42
+ return ret;
43
+ },
44
+ up: (count = 1) => `${CSI2}${count}A`,
45
+ down: (count = 1) => `${CSI2}${count}B`,
46
+ forward: (count = 1) => `${CSI2}${count}C`,
47
+ backward: (count = 1) => `${CSI2}${count}D`,
48
+ nextLine: (count = 1) => `${CSI2}E`.repeat(count),
49
+ prevLine: (count = 1) => `${CSI2}F`.repeat(count),
50
+ left: `${CSI2}G`,
51
+ hide: `${CSI2}?25l`,
52
+ show: `${CSI2}?25h`,
53
+ save: `${ESC2}7`,
54
+ restore: `${ESC2}8`
55
+ };
56
+ var scroll = {
57
+ up: (count = 1) => `${CSI2}S`.repeat(count),
58
+ down: (count = 1) => `${CSI2}T`.repeat(count)
59
+ };
60
+ var erase = {
61
+ screen: `${CSI2}2J`,
62
+ up: (count = 1) => `${CSI2}1J`.repeat(count),
63
+ down: (count = 1) => `${CSI2}J`.repeat(count),
64
+ line: `${CSI2}2K`,
65
+ lineEnd: `${CSI2}K`,
66
+ lineStart: `${CSI2}1K`,
67
+ lines(count) {
68
+ let clear = "";
69
+ for (let i = 0;i < count; i++)
70
+ clear += this.line + (i < count - 1 ? cursor.up() : "");
71
+ if (count)
72
+ clear += cursor.left;
73
+ return clear;
74
+ }
75
+ };
76
+ module.exports = { cursor, scroll, erase, beep };
77
+ });
78
+
79
+ // node_modules/@clack/core/dist/index.mjs
80
+ import { styleText as y } from "util";
81
+ import { stdout as S, stdin as $ } from "process";
82
+ import P from "readline";
83
+
84
+ // node_modules/fast-string-truncated-width/dist/utils.js
85
+ var isAmbiguous = (x) => {
86
+ 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;
87
+ };
88
+ var isFullWidth = (x) => {
89
+ return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
90
+ };
91
+ var isWide = (x) => {
92
+ 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;
93
+ };
94
+
95
+ // node_modules/fast-string-truncated-width/dist/index.js
96
+ var ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
97
+ var CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
98
+ var TAB_RE = /\t{1,1000}/y;
99
+ 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;
100
+ var LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
101
+ var MODIFIER_RE = /\p{M}+/gu;
102
+ var NO_TRUNCATION = { limit: Infinity, ellipsis: "" };
103
+ var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
104
+ const LIMIT = truncationOptions.limit ?? Infinity;
105
+ const ELLIPSIS = truncationOptions.ellipsis ?? "";
106
+ const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
107
+ const ANSI_WIDTH = widthOptions.ansiWidth ?? 0;
108
+ const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
109
+ const TAB_WIDTH = widthOptions.tabWidth ?? 8;
110
+ const AMBIGUOUS_WIDTH = widthOptions.ambiguousWidth ?? 1;
111
+ const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
112
+ const FULL_WIDTH_WIDTH = widthOptions.fullWidthWidth ?? 2;
113
+ const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
114
+ const WIDE_WIDTH = widthOptions.wideWidth ?? 2;
115
+ let indexPrev = 0;
116
+ let index = 0;
117
+ let length = input.length;
118
+ let lengthExtra = 0;
119
+ let truncationEnabled = false;
120
+ let truncationIndex = length;
121
+ let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
122
+ let unmatchedStart = 0;
123
+ let unmatchedEnd = 0;
124
+ let width = 0;
125
+ let widthExtra = 0;
126
+ outer:
127
+ while (true) {
128
+ if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
129
+ const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
130
+ lengthExtra = 0;
131
+ for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
132
+ const codePoint = char.codePointAt(0) || 0;
133
+ if (isFullWidth(codePoint)) {
134
+ widthExtra = FULL_WIDTH_WIDTH;
135
+ } else if (isWide(codePoint)) {
136
+ widthExtra = WIDE_WIDTH;
137
+ } else if (AMBIGUOUS_WIDTH !== REGULAR_WIDTH && isAmbiguous(codePoint)) {
138
+ widthExtra = AMBIGUOUS_WIDTH;
139
+ } else {
140
+ widthExtra = REGULAR_WIDTH;
141
+ }
142
+ if (width + widthExtra > truncationLimit) {
143
+ truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
144
+ }
145
+ if (width + widthExtra > LIMIT) {
146
+ truncationEnabled = true;
147
+ break outer;
148
+ }
149
+ lengthExtra += char.length;
150
+ width += widthExtra;
151
+ }
152
+ unmatchedStart = unmatchedEnd = 0;
153
+ }
154
+ if (index >= length)
155
+ break;
156
+ LATIN_RE.lastIndex = index;
157
+ if (LATIN_RE.test(input)) {
158
+ lengthExtra = LATIN_RE.lastIndex - index;
159
+ widthExtra = lengthExtra * REGULAR_WIDTH;
160
+ if (width + widthExtra > truncationLimit) {
161
+ truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / REGULAR_WIDTH));
162
+ }
163
+ if (width + widthExtra > LIMIT) {
164
+ truncationEnabled = true;
165
+ break;
166
+ }
167
+ width += widthExtra;
168
+ unmatchedStart = indexPrev;
169
+ unmatchedEnd = index;
170
+ index = indexPrev = LATIN_RE.lastIndex;
171
+ continue;
172
+ }
173
+ ANSI_RE.lastIndex = index;
174
+ if (ANSI_RE.test(input)) {
175
+ if (width + ANSI_WIDTH > truncationLimit) {
176
+ truncationIndex = Math.min(truncationIndex, index);
177
+ }
178
+ if (width + ANSI_WIDTH > LIMIT) {
179
+ truncationEnabled = true;
180
+ break;
181
+ }
182
+ width += ANSI_WIDTH;
183
+ unmatchedStart = indexPrev;
184
+ unmatchedEnd = index;
185
+ index = indexPrev = ANSI_RE.lastIndex;
186
+ continue;
187
+ }
188
+ CONTROL_RE.lastIndex = index;
189
+ if (CONTROL_RE.test(input)) {
190
+ lengthExtra = CONTROL_RE.lastIndex - index;
191
+ widthExtra = lengthExtra * CONTROL_WIDTH;
192
+ if (width + widthExtra > truncationLimit) {
193
+ truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / CONTROL_WIDTH));
194
+ }
195
+ if (width + widthExtra > LIMIT) {
196
+ truncationEnabled = true;
197
+ break;
198
+ }
199
+ width += widthExtra;
200
+ unmatchedStart = indexPrev;
201
+ unmatchedEnd = index;
202
+ index = indexPrev = CONTROL_RE.lastIndex;
203
+ continue;
204
+ }
205
+ TAB_RE.lastIndex = index;
206
+ if (TAB_RE.test(input)) {
207
+ lengthExtra = TAB_RE.lastIndex - index;
208
+ widthExtra = lengthExtra * TAB_WIDTH;
209
+ if (width + widthExtra > truncationLimit) {
210
+ truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / TAB_WIDTH));
211
+ }
212
+ if (width + widthExtra > LIMIT) {
213
+ truncationEnabled = true;
214
+ break;
215
+ }
216
+ width += widthExtra;
217
+ unmatchedStart = indexPrev;
218
+ unmatchedEnd = index;
219
+ index = indexPrev = TAB_RE.lastIndex;
220
+ continue;
221
+ }
222
+ EMOJI_RE.lastIndex = index;
223
+ if (EMOJI_RE.test(input)) {
224
+ if (width + EMOJI_WIDTH > truncationLimit) {
225
+ truncationIndex = Math.min(truncationIndex, index);
226
+ }
227
+ if (width + EMOJI_WIDTH > LIMIT) {
228
+ truncationEnabled = true;
229
+ break;
230
+ }
231
+ width += EMOJI_WIDTH;
232
+ unmatchedStart = indexPrev;
233
+ unmatchedEnd = index;
234
+ index = indexPrev = EMOJI_RE.lastIndex;
235
+ continue;
236
+ }
237
+ index += 1;
238
+ }
239
+ return {
240
+ width: truncationEnabled ? truncationLimit : width,
241
+ index: truncationEnabled ? truncationIndex : length,
242
+ truncated: truncationEnabled,
243
+ ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
244
+ };
245
+ };
246
+ var dist_default = getStringTruncatedWidth;
247
+
248
+ // node_modules/fast-string-width/dist/index.js
249
+ var NO_TRUNCATION2 = {
250
+ limit: Infinity,
251
+ ellipsis: "",
252
+ ellipsisWidth: 0
253
+ };
254
+ var fastStringWidth = (input, options = {}) => {
255
+ return dist_default(input, NO_TRUNCATION2, options).width;
256
+ };
257
+ var dist_default2 = fastStringWidth;
258
+
259
+ // node_modules/fast-wrap-ansi/lib/main.js
260
+ var ESC = "\x1B";
261
+ var CSI = "\x9B";
262
+ var END_CODE = 39;
263
+ var ANSI_ESCAPE_BELL = "\x07";
264
+ var ANSI_CSI = "[";
265
+ var ANSI_OSC = "]";
266
+ var ANSI_SGR_TERMINATOR = "m";
267
+ var ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
268
+ var GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
269
+ var getClosingCode = (openingCode) => {
270
+ if (openingCode >= 30 && openingCode <= 37)
271
+ return 39;
272
+ if (openingCode >= 90 && openingCode <= 97)
273
+ return 39;
274
+ if (openingCode >= 40 && openingCode <= 47)
275
+ return 49;
276
+ if (openingCode >= 100 && openingCode <= 107)
277
+ return 49;
278
+ if (openingCode === 1 || openingCode === 2)
279
+ return 22;
280
+ if (openingCode === 3)
281
+ return 23;
282
+ if (openingCode === 4)
283
+ return 24;
284
+ if (openingCode === 7)
285
+ return 27;
286
+ if (openingCode === 8)
287
+ return 28;
288
+ if (openingCode === 9)
289
+ return 29;
290
+ if (openingCode === 0)
291
+ return 0;
292
+ return;
293
+ };
294
+ var wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
295
+ var wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
296
+ var wrapWord = (rows, word, columns) => {
297
+ const characters = word[Symbol.iterator]();
298
+ let isInsideEscape = false;
299
+ let isInsideLinkEscape = false;
300
+ let lastRow = rows.at(-1);
301
+ let visible = lastRow === undefined ? 0 : dist_default2(lastRow);
302
+ let currentCharacter = characters.next();
303
+ let nextCharacter = characters.next();
304
+ let rawCharacterIndex = 0;
305
+ while (!currentCharacter.done) {
306
+ const character = currentCharacter.value;
307
+ const characterLength = dist_default2(character);
308
+ if (visible + characterLength <= columns) {
309
+ rows[rows.length - 1] += character;
310
+ } else {
311
+ rows.push(character);
312
+ visible = 0;
313
+ }
314
+ if (character === ESC || character === CSI) {
315
+ isInsideEscape = true;
316
+ isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
317
+ }
318
+ if (isInsideEscape) {
319
+ if (isInsideLinkEscape) {
320
+ if (character === ANSI_ESCAPE_BELL) {
321
+ isInsideEscape = false;
322
+ isInsideLinkEscape = false;
323
+ }
324
+ } else if (character === ANSI_SGR_TERMINATOR) {
325
+ isInsideEscape = false;
326
+ }
327
+ } else {
328
+ visible += characterLength;
329
+ if (visible === columns && !nextCharacter.done) {
330
+ rows.push("");
331
+ visible = 0;
332
+ }
333
+ }
334
+ currentCharacter = nextCharacter;
335
+ nextCharacter = characters.next();
336
+ rawCharacterIndex += character.length;
337
+ }
338
+ lastRow = rows.at(-1);
339
+ if (!visible && lastRow !== undefined && lastRow.length && rows.length > 1) {
340
+ rows[rows.length - 2] += rows.pop();
341
+ }
342
+ };
343
+ var stringVisibleTrimSpacesRight = (string) => {
344
+ const words = string.split(" ");
345
+ let last = words.length;
346
+ while (last) {
347
+ if (dist_default2(words[last - 1])) {
348
+ break;
349
+ }
350
+ last--;
351
+ }
352
+ if (last === words.length) {
353
+ return string;
354
+ }
355
+ return words.slice(0, last).join(" ") + words.slice(last).join("");
356
+ };
357
+ var exec = (string, columns, options = {}) => {
358
+ if (options.trim !== false && string.trim() === "") {
359
+ return "";
360
+ }
361
+ let returnValue = "";
362
+ let escapeCode;
363
+ let escapeUrl;
364
+ const words = string.split(" ");
365
+ let rows = [""];
366
+ let rowLength = 0;
367
+ for (let index = 0;index < words.length; index++) {
368
+ const word = words[index];
369
+ if (options.trim !== false) {
370
+ const row = rows.at(-1) ?? "";
371
+ const trimmed = row.trimStart();
372
+ if (row.length !== trimmed.length) {
373
+ rows[rows.length - 1] = trimmed;
374
+ rowLength = dist_default2(trimmed);
375
+ }
376
+ }
377
+ if (index !== 0) {
378
+ if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
379
+ rows.push("");
380
+ rowLength = 0;
381
+ }
382
+ if (rowLength || options.trim === false) {
383
+ rows[rows.length - 1] += " ";
384
+ rowLength++;
385
+ }
386
+ }
387
+ const wordLength = dist_default2(word);
388
+ if (options.hard && wordLength > columns) {
389
+ const remainingColumns = columns - rowLength;
390
+ const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
391
+ const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
392
+ if (breaksStartingNextLine < breaksStartingThisLine) {
393
+ rows.push("");
394
+ }
395
+ wrapWord(rows, word, columns);
396
+ rowLength = dist_default2(rows.at(-1) ?? "");
397
+ continue;
398
+ }
399
+ if (rowLength + wordLength > columns && rowLength && wordLength) {
400
+ if (options.wordWrap === false && rowLength < columns) {
401
+ wrapWord(rows, word, columns);
402
+ rowLength = dist_default2(rows.at(-1) ?? "");
403
+ continue;
404
+ }
405
+ rows.push("");
406
+ rowLength = 0;
407
+ }
408
+ if (rowLength + wordLength > columns && options.wordWrap === false) {
409
+ wrapWord(rows, word, columns);
410
+ rowLength = dist_default2(rows.at(-1) ?? "");
411
+ continue;
412
+ }
413
+ rows[rows.length - 1] += word;
414
+ rowLength += wordLength;
415
+ }
416
+ if (options.trim !== false) {
417
+ rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
418
+ }
419
+ const preString = rows.join(`
420
+ `);
421
+ let inSurrogate = false;
422
+ for (let i = 0;i < preString.length; i++) {
423
+ const character = preString[i];
424
+ returnValue += character;
425
+ if (!inSurrogate) {
426
+ inSurrogate = character >= "\uD800" && character <= "\uDBFF";
427
+ } else {
428
+ continue;
429
+ }
430
+ if (character === ESC || character === CSI) {
431
+ GROUP_REGEX.lastIndex = i + 1;
432
+ const groupsResult = GROUP_REGEX.exec(preString);
433
+ const groups = groupsResult?.groups;
434
+ if (groups?.code !== undefined) {
435
+ const code = Number.parseFloat(groups.code);
436
+ escapeCode = code === END_CODE ? undefined : code;
437
+ } else if (groups?.uri !== undefined) {
438
+ escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
439
+ }
440
+ }
441
+ if (preString[i + 1] === `
442
+ `) {
443
+ if (escapeUrl) {
444
+ returnValue += wrapAnsiHyperlink("");
445
+ }
446
+ const closingCode = escapeCode ? getClosingCode(escapeCode) : undefined;
447
+ if (escapeCode && closingCode) {
448
+ returnValue += wrapAnsiCode(closingCode);
449
+ }
450
+ } else if (character === `
451
+ `) {
452
+ if (escapeCode && getClosingCode(escapeCode)) {
453
+ returnValue += wrapAnsiCode(escapeCode);
454
+ }
455
+ if (escapeUrl) {
456
+ returnValue += wrapAnsiHyperlink(escapeUrl);
457
+ }
458
+ }
459
+ }
460
+ return returnValue;
461
+ };
462
+ var CRLF_OR_LF = /\r?\n/;
463
+ function wrapAnsi(string, columns, options) {
464
+ return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join(`
465
+ `);
466
+ }
467
+
468
+ // node_modules/@clack/core/dist/index.mjs
469
+ var import_sisteransi = __toESM(require_src(), 1);
470
+ function d(r, t, e) {
471
+ if (!e.some((o) => !o.disabled))
472
+ return r;
473
+ const s = r + t, i = Math.max(e.length - 1, 0), n = s < 0 ? i : s > i ? 0 : s;
474
+ return e[n].disabled ? d(n, t < 0 ? -1 : 1, e) : n;
475
+ }
476
+ var E = ["up", "down", "left", "right", "space", "enter", "cancel"];
477
+ var G = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
478
+ 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)}` } } };
479
+ function V(r, t) {
480
+ if (typeof r == "string")
481
+ return u.aliases.get(r) === t;
482
+ for (const e of r)
483
+ if (e !== undefined && V(e, t))
484
+ return true;
485
+ return false;
486
+ }
487
+ function j(r, t) {
488
+ if (r === t)
489
+ return;
490
+ const e = r.split(`
491
+ `), s = t.split(`
492
+ `), i = Math.max(e.length, s.length), n = [];
493
+ for (let o = 0;o < i; o++)
494
+ e[o] !== s[o] && n.push(o);
495
+ return { lines: n, numLinesBefore: e.length, numLinesAfter: s.length, numLines: i };
496
+ }
497
+ var Y = globalThis.process.platform.startsWith("win");
498
+ var C = Symbol("clack:cancel");
499
+ function q(r) {
500
+ return r === C;
501
+ }
502
+ function w(r, t) {
503
+ const e = r;
504
+ e.isTTY && e.setRawMode(t);
505
+ }
506
+ var O = (r) => ("columns" in r) && typeof r.columns == "number" ? r.columns : 80;
507
+ var A = (r) => ("rows" in r) && typeof r.rows == "number" ? r.rows : 20;
508
+ function R(r, t, e, s = e) {
509
+ const i = O(r ?? S);
510
+ return wrapAnsi(t, i - e.length, { hard: true, trim: false }).split(`
511
+ `).map((n, o) => `${o === 0 ? s : e}${n}`).join(`
512
+ `);
513
+ }
514
+ var p = class {
515
+ input;
516
+ output;
517
+ _abortSignal;
518
+ rl;
519
+ opts;
520
+ _render;
521
+ _track = false;
522
+ _prevFrame = "";
523
+ _subscribers = new Map;
524
+ _cursor = 0;
525
+ state = "initial";
526
+ error = "";
527
+ value;
528
+ userInput = "";
529
+ constructor(t, e = true) {
530
+ const { input: s = $, output: i = S, render: n, signal: o, ...a } = t;
531
+ 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;
532
+ }
533
+ unsubscribe() {
534
+ this._subscribers.clear();
535
+ }
536
+ setSubscriber(t, e) {
537
+ const s = this._subscribers.get(t) ?? [];
538
+ s.push(e), this._subscribers.set(t, s);
539
+ }
540
+ on(t, e) {
541
+ this.setSubscriber(t, { cb: e });
542
+ }
543
+ once(t, e) {
544
+ this.setSubscriber(t, { cb: e, once: true });
545
+ }
546
+ emit(t, ...e) {
547
+ const s = this._subscribers.get(t) ?? [], i = [];
548
+ for (const n of s)
549
+ n.cb(...e), n.once && i.push(() => s.splice(s.indexOf(n), 1));
550
+ for (const n of i)
551
+ n();
552
+ }
553
+ prompt() {
554
+ return new Promise((t) => {
555
+ if (this._abortSignal) {
556
+ if (this._abortSignal.aborted)
557
+ return this.state = "cancel", this.close(), t(C);
558
+ this._abortSignal.addEventListener("abort", () => {
559
+ this.state = "cancel", this.close();
560
+ }, { once: true });
561
+ }
562
+ 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", () => {
563
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), w(this.input, false), t(this.value);
564
+ }), this.once("cancel", () => {
565
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), w(this.input, false), t(C);
566
+ });
567
+ });
568
+ }
569
+ _isActionKey(t, e) {
570
+ return t === "\t";
571
+ }
572
+ _setValue(t) {
573
+ this.value = t, this.emit("value", this.value);
574
+ }
575
+ _setUserInput(t, e) {
576
+ this.userInput = t ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
577
+ }
578
+ _clearUserInput() {
579
+ this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
580
+ }
581
+ onKeypress(t, e) {
582
+ 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") {
583
+ if (this.opts.validate) {
584
+ const s = this.opts.validate(this.value);
585
+ s && (this.error = s instanceof Error ? s.message : s, this.state = "error", this.rl?.write(this.userInput));
586
+ }
587
+ this.state !== "error" && (this.state = "submit");
588
+ }
589
+ 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();
590
+ }
591
+ close() {
592
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
593
+ `), w(this.input, false), this.rl?.close(), this.rl = undefined, this.emit(`${this.state}`, this.value), this.unsubscribe();
594
+ }
595
+ restoreCursor() {
596
+ const t = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
597
+ `).length - 1;
598
+ this.output.write(import_sisteransi.cursor.move(-999, t * -1));
599
+ }
600
+ render() {
601
+ const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, { hard: true, trim: false });
602
+ if (t !== this._prevFrame) {
603
+ if (this.state === "initial")
604
+ this.output.write(import_sisteransi.cursor.hide);
605
+ else {
606
+ const e = j(this._prevFrame, t), s = A(this.output);
607
+ if (this.restoreCursor(), e) {
608
+ const i = Math.max(0, e.numLinesAfter - s), n = Math.max(0, e.numLinesBefore - s);
609
+ let o = e.lines.find((a) => a >= i);
610
+ if (o === undefined) {
611
+ this._prevFrame = t;
612
+ return;
613
+ }
614
+ if (e.lines.length === 1) {
615
+ this.output.write(import_sisteransi.cursor.move(0, o - n)), this.output.write(import_sisteransi.erase.lines(1));
616
+ const a = t.split(`
617
+ `);
618
+ this.output.write(a[o]), this._prevFrame = t, this.output.write(import_sisteransi.cursor.move(0, a.length - o - 1));
619
+ return;
620
+ } else if (e.lines.length > 1) {
621
+ if (i < n)
622
+ o = i;
623
+ else {
624
+ const h = o - n;
625
+ h > 0 && this.output.write(import_sisteransi.cursor.move(0, h));
626
+ }
627
+ this.output.write(import_sisteransi.erase.down());
628
+ const a = t.split(`
629
+ `).slice(o);
630
+ this.output.write(a.join(`
631
+ `)), this._prevFrame = t;
632
+ return;
633
+ }
634
+ }
635
+ this.output.write(import_sisteransi.erase.down());
636
+ }
637
+ this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
638
+ }
639
+ }
640
+ };
641
+ function W(r, t) {
642
+ if (r === undefined || t.length === 0)
643
+ return 0;
644
+ const e = t.findIndex((s) => s.value === r);
645
+ return e !== -1 ? e : 0;
646
+ }
647
+ function B(r, t) {
648
+ return (t.label ?? String(t.value)).toLowerCase().includes(r.toLowerCase());
649
+ }
650
+ function J(r, t) {
651
+ if (t)
652
+ return r ? t : t[0];
653
+ }
654
+ var H = class extends p {
655
+ filteredOptions;
656
+ multiple;
657
+ isNavigating = false;
658
+ selectedValues = [];
659
+ focusedValue;
660
+ #e = 0;
661
+ #o = "";
662
+ #t;
663
+ #n;
664
+ #a;
665
+ get cursor() {
666
+ return this.#e;
667
+ }
668
+ get userInputWithCursor() {
669
+ if (!this.userInput)
670
+ return y(["inverse", "hidden"], "_");
671
+ if (this._cursor >= this.userInput.length)
672
+ return `${this.userInput}\u2588`;
673
+ const t = this.userInput.slice(0, this._cursor), [e, ...s] = this.userInput.slice(this._cursor);
674
+ return `${t}${y("inverse", e)}${s.join("")}`;
675
+ }
676
+ get options() {
677
+ return typeof this.#n == "function" ? this.#n() : this.#n;
678
+ }
679
+ constructor(t) {
680
+ super(t), this.#n = t.options, this.#a = t.placeholder;
681
+ const e = this.options;
682
+ this.filteredOptions = [...e], this.multiple = t.multiple === true, this.#t = typeof t.options == "function" ? t.filter : t.filter ?? B;
683
+ let s;
684
+ 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)
685
+ for (const i of s) {
686
+ const n = e.findIndex((o) => o.value === i);
687
+ n !== -1 && (this.toggleSelected(i), this.#e = n);
688
+ }
689
+ this.focusedValue = this.options[this.#e]?.value, this.on("key", (i, n) => this.#s(i, n)), this.on("userInput", (i) => this.#i(i));
690
+ }
691
+ _isActionKey(t, e) {
692
+ return t === "\t" || this.multiple && this.isNavigating && e.name === "space" && t !== undefined && t !== "";
693
+ }
694
+ #s(t, e) {
695
+ 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));
696
+ if (e.name === "tab" && o && l) {
697
+ this.userInput === "\t" && this._clearUserInput(), this._setUserInput(a, true), this.isNavigating = false;
698
+ return;
699
+ }
700
+ 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);
701
+ }
702
+ deselectAll() {
703
+ this.selectedValues = [];
704
+ }
705
+ toggleSelected(t) {
706
+ 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]);
707
+ }
708
+ #i(t) {
709
+ if (t !== this.#o) {
710
+ this.#o = t;
711
+ const e = this.options;
712
+ t && this.#t ? this.filteredOptions = e.filter((n) => this.#t?.(t, n)) : this.filteredOptions = [...e];
713
+ const s = W(this.focusedValue, this.filteredOptions);
714
+ this.#e = d(s, 0, this.filteredOptions);
715
+ const i = this.filteredOptions[this.#e];
716
+ i && !i.disabled ? this.focusedValue = i.value : this.focusedValue = undefined, this.multiple || (this.focusedValue !== undefined ? this.toggleSelected(this.focusedValue) : this.deselectAll());
717
+ }
718
+ }
719
+ };
720
+ var X = { Y: { type: "year", len: 4 }, M: { type: "month", len: 2 }, D: { type: "day", len: 2 } };
721
+ function L(r) {
722
+ return [...r].map((t) => X[t]);
723
+ }
724
+ function Z(r) {
725
+ const t = new Intl.DateTimeFormat(r, { year: "numeric", month: "2-digit", day: "2-digit" }).formatToParts(new Date(2000, 0, 15)), e = [];
726
+ let s = "/";
727
+ for (const i of t)
728
+ 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 });
729
+ return { segments: e, separator: s };
730
+ }
731
+ function k(r) {
732
+ return Number.parseInt((r || "0").replace(/_/g, "0"), 10) || 0;
733
+ }
734
+ function I(r) {
735
+ return { year: k(r.year), month: k(r.month), day: k(r.day) };
736
+ }
737
+ function T(r, t) {
738
+ return new Date(r || 2001, t || 1, 0).getDate();
739
+ }
740
+ function F(r) {
741
+ const { year: t, month: e, day: s } = I(r);
742
+ if (!t || t < 0 || t > 9999 || !e || e < 1 || e > 12 || !s || s < 1)
743
+ return;
744
+ const i = new Date(Date.UTC(t, e - 1, s));
745
+ if (!(i.getUTCFullYear() !== t || i.getUTCMonth() !== e - 1 || i.getUTCDate() !== s))
746
+ return { year: t, month: e, day: s };
747
+ }
748
+ function N(r) {
749
+ const t = F(r);
750
+ return t ? new Date(Date.UTC(t.year, t.month - 1, t.day)) : undefined;
751
+ }
752
+ function tt(r, t, e, s) {
753
+ 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;
754
+ 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) };
755
+ }
756
+
757
+ class et extends p {
758
+ #e;
759
+ #o;
760
+ #t;
761
+ #n;
762
+ #a;
763
+ #s = { segmentIndex: 0, positionInSegment: 0 };
764
+ #i = true;
765
+ #r = null;
766
+ inlineError = "";
767
+ get segmentCursor() {
768
+ return { ...this.#s };
769
+ }
770
+ get segmentValues() {
771
+ return { ...this.#t };
772
+ }
773
+ get segments() {
774
+ return this.#e;
775
+ }
776
+ get separator() {
777
+ return this.#o;
778
+ }
779
+ get formattedValue() {
780
+ return this.#c(this.#t);
781
+ }
782
+ #c(t) {
783
+ return this.#e.map((e) => t[e.type]).join(this.#o);
784
+ }
785
+ #h() {
786
+ this._setUserInput(this.#c(this.#t)), this._setValue(N(this.#t) ?? undefined);
787
+ }
788
+ constructor(t) {
789
+ 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);
790
+ 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));
791
+ }
792
+ #u() {
793
+ const t = Math.max(0, Math.min(this.#s.segmentIndex, this.#e.length - 1)), e = this.#e[t];
794
+ if (e)
795
+ return this.#s.positionInSegment = Math.max(0, Math.min(this.#s.positionInSegment, e.len - 1)), { segment: e, index: t };
796
+ }
797
+ #l(t) {
798
+ this.inlineError = "", this.#r = null;
799
+ const e = this.#u();
800
+ e && (this.#s.segmentIndex = Math.max(0, Math.min(this.#e.length - 1, e.index + t)), this.#s.positionInSegment = 0, this.#i = true);
801
+ }
802
+ #p(t) {
803
+ const e = this.#u();
804
+ if (!e)
805
+ return;
806
+ 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);
807
+ let h;
808
+ 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();
809
+ }
810
+ #d(t) {
811
+ if (t)
812
+ switch (t) {
813
+ case "right":
814
+ return this.#l(1);
815
+ case "left":
816
+ return this.#l(-1);
817
+ case "up":
818
+ return this.#p(1);
819
+ case "down":
820
+ return this.#p(-1);
821
+ }
822
+ }
823
+ #f(t, e) {
824
+ if (e?.name === "backspace" || e?.sequence === "\x7F" || e?.sequence === "\b" || t === "\x7F" || t === "\b") {
825
+ this.inlineError = "";
826
+ const s = this.#u();
827
+ if (!s)
828
+ return;
829
+ if (!this.#t[s.segment.type].replace(/_/g, "")) {
830
+ this.#l(-1);
831
+ return;
832
+ }
833
+ this.#t[s.segment.type] = "_".repeat(s.segment.len), this.#i = true, this.#s.positionInSegment = 0, this.#h();
834
+ return;
835
+ }
836
+ if (e?.name === "tab") {
837
+ this.inlineError = "";
838
+ const s = this.#u();
839
+ if (!s)
840
+ return;
841
+ const i = e.shift ? -1 : 1, n = s.index + i;
842
+ n >= 0 && n < this.#e.length && (this.#s.segmentIndex = n, this.#s.positionInSegment = 0, this.#i = true);
843
+ return;
844
+ }
845
+ if (t && /^[0-9]$/.test(t)) {
846
+ const s = this.#u();
847
+ if (!s)
848
+ return;
849
+ const { segment: i } = s, n = !this.#t[i.type].replace(/_/g, "");
850
+ if (this.#i && this.#r !== null && !n) {
851
+ const m = this.#r + t, g = { ...this.#t, [i.type]: m }, b = this.#m(g, i);
852
+ if (b) {
853
+ this.inlineError = b, this.#r = null, this.#i = false;
854
+ return;
855
+ }
856
+ 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);
857
+ return;
858
+ }
859
+ this.#i && !n && (this.#t[i.type] = "_".repeat(i.len), this.#s.positionInSegment = 0), this.#i = false, this.#r = null;
860
+ const o = this.#t[i.type], a = o.indexOf("_"), h = a >= 0 ? a : Math.min(this.#s.positionInSegment, i.len - 1);
861
+ if (h < 0 || h >= i.len)
862
+ return;
863
+ let l = o.slice(0, h) + t + o.slice(h + 1), f = false;
864
+ if (h === 0 && o === "__" && (i.type === "month" || i.type === "day")) {
865
+ const m = Number.parseInt(t, 10);
866
+ l = `0${t}`, f = m <= (i.type === "month" ? 1 : 2);
867
+ }
868
+ if (i.type === "year" && (l = (o.replace(/_/g, "") + t).padStart(i.len, "_")), !l.includes("_")) {
869
+ const m = { ...this.#t, [i.type]: l }, g = this.#m(m, i);
870
+ if (g) {
871
+ this.inlineError = g;
872
+ return;
873
+ }
874
+ }
875
+ this.inlineError = "", this.#t[i.type] = l;
876
+ const v = l.includes("_") ? undefined : F(this.#t);
877
+ if (v) {
878
+ const { year: m, month: g } = v, b = T(m, g);
879
+ 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") };
880
+ }
881
+ this.#h();
882
+ const U = l.indexOf("_");
883
+ 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);
884
+ }
885
+ }
886
+ #m(t, e) {
887
+ const { month: s, day: i } = I(t);
888
+ if (e.type === "month" && (s < 0 || s > 12))
889
+ return u.date.messages.invalidMonth;
890
+ if (e.type === "day" && (i < 0 || i > 31))
891
+ return u.date.messages.invalidDay(31, "any month");
892
+ }
893
+ #g(t) {
894
+ const { year: e, month: s, day: i } = I(this.#t);
895
+ if (e && s && i) {
896
+ const n = T(e, s);
897
+ this.#t = { ...this.#t, day: String(Math.min(i, n)).padStart(2, "0") };
898
+ }
899
+ this.value = N(this.#t) ?? t.defaultValue ?? undefined;
900
+ }
901
+ }
902
+
903
+ class st extends p {
904
+ options;
905
+ cursor = 0;
906
+ #e;
907
+ getGroupItems(t) {
908
+ return this.options.filter((e) => e.group === t);
909
+ }
910
+ isGroupSelected(t) {
911
+ const e = this.getGroupItems(t), s = this.value;
912
+ return s === undefined ? false : e.every((i) => s.includes(i.value));
913
+ }
914
+ toggleValue() {
915
+ const t = this.options[this.cursor];
916
+ if (this.value === undefined && (this.value = []), t.group === true) {
917
+ const e = t.value, s = this.getGroupItems(e);
918
+ 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));
919
+ } else {
920
+ const e = this.value.includes(t.value);
921
+ this.value = e ? this.value.filter((s) => s !== t.value) : [...this.value, t.value];
922
+ }
923
+ }
924
+ constructor(t) {
925
+ super(t, false);
926
+ const { options: e } = t;
927
+ 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) => {
928
+ switch (s) {
929
+ case "left":
930
+ case "up": {
931
+ this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
932
+ const i = this.options[this.cursor]?.group === true;
933
+ !this.#e && i && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
934
+ break;
935
+ }
936
+ case "down":
937
+ case "right": {
938
+ this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
939
+ const i = this.options[this.cursor]?.group === true;
940
+ !this.#e && i && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
941
+ break;
942
+ }
943
+ case "space":
944
+ this.toggleValue();
945
+ break;
946
+ }
947
+ });
948
+ }
949
+ }
950
+ var it = class extends p {
951
+ options;
952
+ cursor = 0;
953
+ get _value() {
954
+ return this.options[this.cursor].value;
955
+ }
956
+ get _enabledOptions() {
957
+ return this.options.filter((t) => t.disabled !== true);
958
+ }
959
+ toggleAll() {
960
+ const t = this._enabledOptions, e = this.value !== undefined && this.value.length === t.length;
961
+ this.value = e ? [] : t.map((s) => s.value);
962
+ }
963
+ toggleInvert() {
964
+ const t = this.value;
965
+ if (!t)
966
+ return;
967
+ const e = this._enabledOptions.filter((s) => !t.includes(s.value));
968
+ this.value = e.map((s) => s.value);
969
+ }
970
+ toggleValue() {
971
+ this.value === undefined && (this.value = []);
972
+ const t = this.value.includes(this._value);
973
+ this.value = t ? this.value.filter((e) => e !== this._value) : [...this.value, this._value];
974
+ }
975
+ constructor(t) {
976
+ super(t, false), this.options = t.options, this.value = [...t.initialValues ?? []];
977
+ const e = Math.max(this.options.findIndex(({ value: s }) => s === t.cursorAt), 0);
978
+ this.cursor = this.options[e].disabled ? d(e, 1, this.options) : e, this.on("key", (s) => {
979
+ s === "a" && this.toggleAll(), s === "i" && this.toggleInvert();
980
+ }), this.on("cursor", (s) => {
981
+ switch (s) {
982
+ case "left":
983
+ case "up":
984
+ this.cursor = d(this.cursor, -1, this.options);
985
+ break;
986
+ case "down":
987
+ case "right":
988
+ this.cursor = d(this.cursor, 1, this.options);
989
+ break;
990
+ case "space":
991
+ this.toggleValue();
992
+ break;
993
+ }
994
+ });
995
+ }
996
+ };
997
+
998
+ // node_modules/@clack/prompts/dist/index.mjs
999
+ import { styleText as t, stripVTControlCharacters as ne } from "util";
1000
+ import P2 from "process";
1001
+ var import_sisteransi2 = __toESM(require_src(), 1);
1002
+ function Ze() {
1003
+ 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";
1004
+ }
1005
+ var ee = Ze();
1006
+ var w2 = (e, i) => ee ? e : i;
1007
+ var _e = w2("\u25C6", "*");
1008
+ var oe = w2("\u25A0", "x");
1009
+ var ue = w2("\u25B2", "x");
1010
+ var F2 = w2("\u25C7", "o");
1011
+ var le = w2("\u250C", "T");
1012
+ var d2 = w2("\u2502", "|");
1013
+ var E2 = w2("\u2514", "\u2014");
1014
+ var Ie = w2("\u2510", "T");
1015
+ var Ee = w2("\u2518", "\u2014");
1016
+ var z2 = w2("\u25CF", ">");
1017
+ var H2 = w2("\u25CB", " ");
1018
+ var te = w2("\u25FB", "[\u2022]");
1019
+ var U = w2("\u25FC", "[+]");
1020
+ var J2 = w2("\u25FB", "[ ]");
1021
+ var xe = w2("\u25AA", "\u2022");
1022
+ var se = w2("\u2500", "-");
1023
+ var ce = w2("\u256E", "+");
1024
+ var Ge = w2("\u251C", "+");
1025
+ var $e = w2("\u256F", "+");
1026
+ var de = w2("\u2570", "+");
1027
+ var Oe = w2("\u256D", "+");
1028
+ var he = w2("\u25CF", "\u2022");
1029
+ var pe = w2("\u25C6", "*");
1030
+ var me = w2("\u25B2", "!");
1031
+ var ge = w2("\u25A0", "x");
1032
+ var V2 = (e) => {
1033
+ switch (e) {
1034
+ case "initial":
1035
+ case "active":
1036
+ return t("cyan", _e);
1037
+ case "cancel":
1038
+ return t("red", oe);
1039
+ case "error":
1040
+ return t("yellow", ue);
1041
+ case "submit":
1042
+ return t("green", F2);
1043
+ }
1044
+ };
1045
+ var ye = (e) => {
1046
+ switch (e) {
1047
+ case "initial":
1048
+ case "active":
1049
+ return t("cyan", d2);
1050
+ case "cancel":
1051
+ return t("red", d2);
1052
+ case "error":
1053
+ return t("yellow", d2);
1054
+ case "submit":
1055
+ return t("green", d2);
1056
+ }
1057
+ };
1058
+ var et2 = (e, i, s, r, u2) => {
1059
+ let n = i, o = 0;
1060
+ for (let c2 = s;c2 < r; c2++) {
1061
+ const a = e[c2];
1062
+ if (n = n - a.length, o++, n <= u2)
1063
+ break;
1064
+ }
1065
+ return { lineCount: n, removals: o };
1066
+ };
1067
+ var Y2 = ({ cursor: e, options: i, style: s, output: r = process.stdout, maxItems: u2 = Number.POSITIVE_INFINITY, columnPadding: n = 0, rowPadding: o = 4 }) => {
1068
+ const c2 = O(r) - n, a = A(r), l = t("dim", "..."), $2 = Math.max(a - o, 0), y2 = Math.max(Math.min(u2, $2), 5);
1069
+ let p2 = 0;
1070
+ e >= y2 - 3 && (p2 = Math.max(Math.min(e - y2 + 3, i.length - y2), 0));
1071
+ let m = y2 < i.length && p2 > 0, g = y2 < i.length && p2 + y2 < i.length;
1072
+ const S2 = Math.min(p2 + y2, i.length), h = [];
1073
+ let f = 0;
1074
+ m && f++, g && f++;
1075
+ const v = p2 + (m ? 1 : 0), T2 = S2 - (g ? 1 : 0);
1076
+ for (let b = v;b < T2; b++) {
1077
+ const x = wrapAnsi(s(i[b], b === e), c2, { hard: true, trim: false }).split(`
1078
+ `);
1079
+ h.push(x), f += x.length;
1080
+ }
1081
+ if (f > $2) {
1082
+ let b = 0, x = 0, G2 = f;
1083
+ const M2 = e - v, R2 = (j2, D) => et2(h, G2, j2, D, $2);
1084
+ m ? ({ lineCount: G2, removals: b } = R2(0, M2), G2 > $2 && ({ lineCount: G2, removals: x } = R2(M2 + 1, h.length))) : ({ lineCount: G2, removals: x } = R2(M2 + 1, h.length), G2 > $2 && ({ lineCount: G2, removals: b } = R2(0, M2))), b > 0 && (m = true, h.splice(0, b)), x > 0 && (g = true, h.splice(h.length - x, x));
1085
+ }
1086
+ const C2 = [];
1087
+ m && C2.push(l);
1088
+ for (const b of h)
1089
+ for (const x of b)
1090
+ C2.push(x);
1091
+ return g && C2.push(l), C2;
1092
+ };
1093
+ var pt = (e = "", i) => {
1094
+ const s = i?.output ?? process.stdout, r = i?.withGuide ?? u.withGuide ? `${t("gray", E2)} ` : "";
1095
+ s.write(`${r}${t("red", e)}
1096
+
1097
+ `);
1098
+ };
1099
+ var Q2 = (e, i) => e.split(`
1100
+ `).map((s) => i(s)).join(`
1101
+ `);
1102
+ var yt = (e) => {
1103
+ const i = (r, u2) => {
1104
+ const n = r.label ?? String(r.value);
1105
+ return u2 === "disabled" ? `${t("gray", J2)} ${Q2(n, (o) => t(["strikethrough", "gray"], o))}${r.hint ? ` ${t("dim", `(${r.hint ?? "disabled"})`)}` : ""}` : u2 === "active" ? `${t("cyan", te)} ${n}${r.hint ? ` ${t("dim", `(${r.hint})`)}` : ""}` : u2 === "selected" ? `${t("green", U)} ${Q2(n, (o) => t("dim", o))}${r.hint ? ` ${t("dim", `(${r.hint})`)}` : ""}` : u2 === "cancelled" ? `${Q2(n, (o) => t(["strikethrough", "dim"], o))}` : u2 === "active-selected" ? `${t("green", U)} ${n}${r.hint ? ` ${t("dim", `(${r.hint})`)}` : ""}` : u2 === "submitted" ? `${Q2(n, (o) => t("dim", o))}` : `${t("dim", J2)} ${Q2(n, (o) => t("dim", o))}`;
1106
+ }, s = e.required ?? true;
1107
+ return new it({ options: e.options, signal: e.signal, input: e.input, output: e.output, initialValues: e.initialValues, required: s, cursorAt: e.cursorAt, validate(r) {
1108
+ if (s && (r === undefined || r.length === 0))
1109
+ return `Please select at least one option.
1110
+ ${t("reset", t("dim", `Press ${t(["gray", "bgWhite", "inverse"], " space ")} to select, ${t("gray", t("bgWhite", t("inverse", " enter ")))} to submit`))}`;
1111
+ }, render() {
1112
+ const r = e.withGuide ?? u.withGuide, u2 = R(e.output, e.message, r ? `${ye(this.state)} ` : "", `${V2(this.state)} `), n = `${r ? `${t("gray", d2)}
1113
+ ` : ""}${u2}
1114
+ `, o = this.value ?? [], c2 = (a, l) => {
1115
+ if (a.disabled)
1116
+ return i(a, "disabled");
1117
+ const $2 = o.includes(a.value);
1118
+ return l && $2 ? i(a, "active-selected") : $2 ? i(a, "selected") : i(a, l ? "active" : "inactive");
1119
+ };
1120
+ switch (this.state) {
1121
+ case "submit": {
1122
+ const a = this.options.filter(({ value: $2 }) => o.includes($2)).map(($2) => i($2, "submitted")).join(t("dim", ", ")) || t("dim", "none"), l = R(e.output, a, r ? `${t("gray", d2)} ` : "");
1123
+ return `${n}${l}`;
1124
+ }
1125
+ case "cancel": {
1126
+ const a = this.options.filter(({ value: $2 }) => o.includes($2)).map(($2) => i($2, "cancelled")).join(t("dim", ", "));
1127
+ if (a.trim() === "")
1128
+ return `${n}${t("gray", d2)}`;
1129
+ const l = R(e.output, a, r ? `${t("gray", d2)} ` : "");
1130
+ return `${n}${l}${r ? `
1131
+ ${t("gray", d2)}` : ""}`;
1132
+ }
1133
+ case "error": {
1134
+ const a = r ? `${t("yellow", d2)} ` : "", l = this.error.split(`
1135
+ `).map((p2, m) => m === 0 ? `${r ? `${t("yellow", E2)} ` : ""}${t("yellow", p2)}` : ` ${p2}`).join(`
1136
+ `), $2 = n.split(`
1137
+ `).length, y2 = l.split(`
1138
+ `).length + 1;
1139
+ return `${n}${a}${Y2({ output: e.output, options: this.options, cursor: this.cursor, maxItems: e.maxItems, columnPadding: a.length, rowPadding: $2 + y2, style: c2 }).join(`
1140
+ ${a}`)}
1141
+ ${l}
1142
+ `;
1143
+ }
1144
+ default: {
1145
+ const a = r ? `${t("cyan", d2)} ` : "", l = n.split(`
1146
+ `).length, $2 = r ? 2 : 1;
1147
+ return `${n}${a}${Y2({ output: e.output, options: this.options, cursor: this.cursor, maxItems: e.maxItems, columnPadding: a.length, rowPadding: l + $2, style: c2 }).join(`
1148
+ ${a}`)}
1149
+ ${r ? t("cyan", E2) : ""}
1150
+ `;
1151
+ }
1152
+ }
1153
+ } }).prompt();
1154
+ };
1155
+ var Ve = { light: w2("\u2500", "-"), heavy: w2("\u2501", "="), block: w2("\u2588", "#") };
1156
+ var je = `${t("gray", d2)} `;
1157
+
1158
+ // src/main.ts
1159
+ var {$: $2 } = globalThis.Bun;
1160
+ async function main() {
1161
+ const output = await $2`git status --porcelain`.quiet().text();
1162
+ if (!output.trim()) {
1163
+ console.log("\x1B[32m\u2714\x1B[0m No changes detected.");
1164
+ return;
1165
+ }
1166
+ const warnings = new Set;
1167
+ const lines = output.trim().split(`
1168
+ `);
1169
+ const changes = lines.map((line) => {
1170
+ const status = line.slice(0, 2);
1171
+ const file = line.slice(2).trim();
1172
+ let label = "";
1173
+ if (status.includes("M")) {
1174
+ label = `\x1B[33mmodified:\x1B[0m ${file}`;
1175
+ } else if (status.includes("A") || status.includes("?")) {
1176
+ label = `\x1B[32mnew file:\x1B[0m ${file}`;
1177
+ } else if (status.includes("D")) {
1178
+ label = `\x1B[31mdeleted:\x1B[0m ${file}`;
1179
+ } else if (status.includes("R")) {
1180
+ label = `\x1B[35mrenamed:\x1B[0m ${file}`;
1181
+ } else {
1182
+ label = `${status}: ${file}`;
1183
+ }
1184
+ return { value: file, label };
1185
+ }).filter((change) => {
1186
+ const isSensitive = change.value.includes(".env") || change.value.includes("node_modules");
1187
+ if (change.value.includes(".env")) {
1188
+ warnings.add("\x1B[33m .env file hidden\x1B[0m (Add to .gitignore to avoid leaks)");
1189
+ }
1190
+ if (change.value.includes("node_modules")) {
1191
+ warnings.add("\x1B[33m node_modules hidden\x1B[0m (Add to .gitignore to save space)");
1192
+ }
1193
+ return !isSensitive;
1194
+ });
1195
+ if (changes.length === 0) {
1196
+ console.log("\x1B[32m\u2714\x1B[0m All changes are either staged or sensitive (like .env).");
1197
+ return;
1198
+ }
1199
+ const options = [
1200
+ { value: "all", label: "\x1B[1mall changes\x1B[0m" },
1201
+ ...changes
1202
+ ];
1203
+ const selectedChanges = await yt({
1204
+ message: "Select the changes you want to commit. (select with space and confirm with enter)",
1205
+ options,
1206
+ required: true
1207
+ });
1208
+ if (q(selectedChanges)) {
1209
+ pt("Operation cancelled.");
1210
+ process.exit(0);
1211
+ }
1212
+ let selected = selectedChanges.map((file) => file.trim());
1213
+ if (selected.includes("all")) {
1214
+ selected = changes.map((c2) => c2.value);
1215
+ }
1216
+ if (selected.length > 0) {
1217
+ const proc = Bun.spawn(["git", "add", ...selected], {
1218
+ stdio: ["inherit", "inherit", "inherit"]
1219
+ });
1220
+ const exitCode = await proc.exited;
1221
+ if (warnings.size > 0) {
1222
+ console.log(`
1223
+ \x1B[43m\x1B[30m WARNING \x1B[0m`);
1224
+ for (const warning of warnings) {
1225
+ console.log(warning);
1226
+ }
1227
+ console.log("");
1228
+ }
1229
+ process.exit(exitCode);
1230
+ }
1231
+ }
1232
+
1233
+ // src/index.ts
1234
+ var args = Bun.argv.slice(2);
1235
+ if (args[0] === "add" && !args[1]) {
1236
+ await main();
1237
+ } else {
1238
+ const proc = Bun.spawn(["git", ...args], {
1239
+ stdio: ["inherit", "inherit", "inherit"]
1240
+ });
1241
+ process.exit(await proc.exited);
1242
+ }