@maz-ui/mcp 5.2.0 → 5.3.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.
@@ -1,3051 +1,10 @@
1
1
  import { Buffer as Buffer$1 } from 'node:buffer';
2
- import { sep, join, dirname, basename, resolve as resolve$1 } from 'node:path';
3
- import { formatWithOptions, parseArgs } from 'node:util';
4
- import 'node:child_process';
5
- import g$1 from 'node:process';
6
- import * as tty from 'tty';
7
- import * as tty$1 from 'node:tty';
8
- import * as fs from 'fs';
9
- import * as path from 'path';
10
- import { fileURLToPath } from 'url';
11
- import { createHash } from 'node:crypto';
12
- import { existsSync, readFileSync, rmSync, mkdirSync, writeFileSync, renameSync, readdirSync } from 'node:fs';
13
- import { fileURLToPath as fileURLToPath$1 } from 'node:url';
14
-
15
- const {
16
- env: env$1 = {},
17
- argv: argv$1 = [],
18
- platform: platform$1 = "",
19
- } = typeof process === "undefined" ? {} : process;
20
-
21
- const isDisabled$1 = "NO_COLOR" in env$1 || argv$1.includes("--no-color");
22
- const isForced$1 = "FORCE_COLOR" in env$1 || argv$1.includes("--color");
23
- const isWindows$1 = platform$1 === "win32";
24
- const isDumbTerminal$1 = env$1.TERM === "dumb";
25
-
26
- const isCompatibleTerminal$1 =
27
- tty && tty.isatty && tty.isatty(1) && env$1.TERM && !isDumbTerminal$1;
28
-
29
- const isCI$1 =
30
- "CI" in env$1 &&
31
- ("GITHUB_ACTIONS" in env$1 || "GITLAB_CI" in env$1 || "CIRCLECI" in env$1);
32
-
33
- const isColorSupported$1 =
34
- !isDisabled$1 &&
35
- (isForced$1 || (isWindows$1 && !isDumbTerminal$1) || isCompatibleTerminal$1 || isCI$1);
36
-
37
- const replaceClose$1 = (
38
- index,
39
- string,
40
- close,
41
- replace,
42
- head = string.substring(0, index) + replace,
43
- tail = string.substring(index + close.length),
44
- next = tail.indexOf(close)
45
- ) => head + (next < 0 ? tail : replaceClose$1(next, tail, close, replace));
46
-
47
- const clearBleed$1 = (index, string, open, close, replace) =>
48
- index < 0
49
- ? open + string + close
50
- : open + replaceClose$1(index, string, close, replace) + close;
51
-
52
- const filterEmpty$1 =
53
- (open, close, replace = open, at = open.length + 1) =>
54
- (string) =>
55
- string || !(string === "" || string === undefined)
56
- ? clearBleed$1(
57
- ("" + string).indexOf(close, at),
58
- string,
59
- open,
60
- close,
61
- replace
62
- )
63
- : "";
64
-
65
- const init$1 = (open, close, replace) =>
66
- filterEmpty$1(`\x1b[${open}m`, `\x1b[${close}m`, replace);
67
-
68
- const colors$1 = {
69
- reset: init$1(0, 0),
70
- bold: init$1(1, 22, "\x1b[22m\x1b[1m"),
71
- dim: init$1(2, 22, "\x1b[22m\x1b[2m"),
72
- italic: init$1(3, 23),
73
- underline: init$1(4, 24),
74
- inverse: init$1(7, 27),
75
- hidden: init$1(8, 28),
76
- strikethrough: init$1(9, 29),
77
- black: init$1(30, 39),
78
- red: init$1(31, 39),
79
- green: init$1(32, 39),
80
- yellow: init$1(33, 39),
81
- blue: init$1(34, 39),
82
- magenta: init$1(35, 39),
83
- cyan: init$1(36, 39),
84
- white: init$1(37, 39),
85
- gray: init$1(90, 39),
86
- bgBlack: init$1(40, 49),
87
- bgRed: init$1(41, 49),
88
- bgGreen: init$1(42, 49),
89
- bgYellow: init$1(43, 49),
90
- bgBlue: init$1(44, 49),
91
- bgMagenta: init$1(45, 49),
92
- bgCyan: init$1(46, 49),
93
- bgWhite: init$1(47, 49),
94
- blackBright: init$1(90, 39),
95
- redBright: init$1(91, 39),
96
- greenBright: init$1(92, 39),
97
- yellowBright: init$1(93, 39),
98
- blueBright: init$1(94, 39),
99
- magentaBright: init$1(95, 39),
100
- cyanBright: init$1(96, 39),
101
- whiteBright: init$1(97, 39),
102
- bgBlackBright: init$1(100, 49),
103
- bgRedBright: init$1(101, 49),
104
- bgGreenBright: init$1(102, 49),
105
- bgYellowBright: init$1(103, 49),
106
- bgBlueBright: init$1(104, 49),
107
- bgMagentaBright: init$1(105, 49),
108
- bgCyanBright: init$1(106, 49),
109
- bgWhiteBright: init$1(107, 49),
110
- };
111
-
112
- const createColors$1 = ({ useColor = isColorSupported$1 } = {}) =>
113
- useColor
114
- ? colors$1
115
- : Object.keys(colors$1).reduce(
116
- (colors, key) => ({ ...colors, [key]: String }),
117
- {}
118
- );
119
-
120
- const {
121
- reset,
122
- bold,
123
- dim,
124
- italic,
125
- underline,
126
- inverse,
127
- hidden,
128
- strikethrough,
129
- black,
130
- red,
131
- green,
132
- yellow,
133
- blue,
134
- magenta,
135
- cyan,
136
- white,
137
- gray,
138
- bgBlack,
139
- bgRed,
140
- bgGreen,
141
- bgYellow,
142
- bgBlue,
143
- bgMagenta,
144
- bgCyan,
145
- bgWhite,
146
- blackBright,
147
- redBright,
148
- greenBright,
149
- yellowBright,
150
- blueBright,
151
- magentaBright,
152
- cyanBright,
153
- whiteBright,
154
- bgBlackBright,
155
- bgRedBright,
156
- bgGreenBright,
157
- bgYellowBright,
158
- bgBlueBright,
159
- bgMagentaBright,
160
- bgCyanBright,
161
- bgWhiteBright,
162
- } = createColors$1();
163
-
164
- const LogLevels = {
165
- fatal: 0,
166
- error: 0,
167
- warn: 1,
168
- log: 2,
169
- info: 3,
170
- success: 3,
171
- fail: 3,
172
- debug: 4,
173
- trace: 5,
174
- verbose: Number.POSITIVE_INFINITY
175
- };
176
- const LogTypes = {
177
- // Silent
178
- silent: {
179
- level: -1
180
- },
181
- // Level 0
182
- fatal: {
183
- level: LogLevels.fatal
184
- },
185
- error: {
186
- level: LogLevels.error
187
- },
188
- // Level 1
189
- warn: {
190
- level: LogLevels.warn
191
- },
192
- // Level 2
193
- log: {
194
- level: LogLevels.log
195
- },
196
- // Level 3
197
- info: {
198
- level: LogLevels.info
199
- },
200
- success: {
201
- level: LogLevels.success
202
- },
203
- fail: {
204
- level: LogLevels.fail
205
- },
206
- ready: {
207
- level: LogLevels.info
208
- },
209
- start: {
210
- level: LogLevels.info
211
- },
212
- box: {
213
- level: LogLevels.info
214
- },
215
- // Level 4
216
- debug: {
217
- level: LogLevels.debug
218
- },
219
- // Level 5
220
- trace: {
221
- level: LogLevels.trace
222
- },
223
- // Verbose
224
- verbose: {
225
- level: LogLevels.verbose
226
- }
227
- };
228
-
229
- function isPlainObject$1$1(value) {
230
- if (value === null || typeof value !== "object") {
231
- return false;
232
- }
233
- const prototype = Object.getPrototypeOf(value);
234
- if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
235
- return false;
236
- }
237
- if (Symbol.iterator in value) {
238
- return false;
239
- }
240
- if (Symbol.toStringTag in value) {
241
- return Object.prototype.toString.call(value) === "[object Module]";
242
- }
243
- return true;
244
- }
245
-
246
- function _defu(baseObject, defaults, namespace = ".", merger) {
247
- if (!isPlainObject$1$1(defaults)) {
248
- return _defu(baseObject, {}, namespace);
249
- }
250
- const object = Object.assign({}, defaults);
251
- for (const key in baseObject) {
252
- if (key === "__proto__" || key === "constructor") {
253
- continue;
254
- }
255
- const value = baseObject[key];
256
- if (value === null || value === void 0) {
257
- continue;
258
- }
259
- if (Array.isArray(value) && Array.isArray(object[key])) {
260
- object[key] = [...value, ...object[key]];
261
- } else if (isPlainObject$1$1(value) && isPlainObject$1$1(object[key])) {
262
- object[key] = _defu(
263
- value,
264
- object[key],
265
- (namespace ? `${namespace}.` : "") + key.toString());
266
- } else {
267
- object[key] = value;
268
- }
269
- }
270
- return object;
271
- }
272
- function createDefu(merger) {
273
- return (...arguments_) => (
274
- // eslint-disable-next-line unicorn/no-array-reduce
275
- arguments_.reduce((p, c) => _defu(p, c, ""), {})
276
- );
277
- }
278
- const defu = createDefu();
279
-
280
- function isPlainObject$2(obj) {
281
- return Object.prototype.toString.call(obj) === "[object Object]";
282
- }
283
- function isLogObj(arg) {
284
- if (!isPlainObject$2(arg)) {
285
- return false;
286
- }
287
- if (!arg.message && !arg.args) {
288
- return false;
289
- }
290
- if (arg.stack) {
291
- return false;
292
- }
293
- return true;
294
- }
295
-
296
- let paused = false;
297
- const queue = [];
298
- class Consola {
299
- options;
300
- _lastLog;
301
- _mockFn;
302
- /**
303
- * Creates an instance of Consola with specified options or defaults.
304
- *
305
- * @param {Partial<ConsolaOptions>} [options={}] - Configuration options for the Consola instance.
306
- */
307
- constructor(options = {}) {
308
- const types = options.types || LogTypes;
309
- this.options = defu(
310
- {
311
- ...options,
312
- defaults: { ...options.defaults },
313
- level: _normalizeLogLevel(options.level, types),
314
- reporters: [...options.reporters || []]
315
- },
316
- {
317
- types: LogTypes,
318
- throttle: 1e3,
319
- throttleMin: 5,
320
- formatOptions: {
321
- date: true,
322
- colors: false,
323
- compact: true
324
- }
325
- }
326
- );
327
- for (const type in types) {
328
- const defaults = {
329
- type,
330
- ...this.options.defaults,
331
- ...types[type]
332
- };
333
- this[type] = this._wrapLogFn(defaults);
334
- this[type].raw = this._wrapLogFn(
335
- defaults,
336
- true
337
- );
338
- }
339
- if (this.options.mockFn) {
340
- this.mockTypes();
341
- }
342
- this._lastLog = {};
343
- }
344
- /**
345
- * Gets the current log level of the Consola instance.
346
- *
347
- * @returns {number} The current log level.
348
- */
349
- get level() {
350
- return this.options.level;
351
- }
352
- /**
353
- * Sets the minimum log level that will be output by the instance.
354
- *
355
- * @param {number} level - The new log level to set.
356
- */
357
- set level(level) {
358
- this.options.level = _normalizeLogLevel(
359
- level,
360
- this.options.types,
361
- this.options.level
362
- );
363
- }
364
- /**
365
- * Displays a prompt to the user and returns the response.
366
- * Throw an error if `prompt` is not supported by the current configuration.
367
- *
368
- * @template T
369
- * @param {string} message - The message to display in the prompt.
370
- * @param {T} [opts] - Optional options for the prompt. See {@link PromptOptions}.
371
- * @returns {promise<T>} A promise that infer with the prompt options. See {@link PromptOptions}.
372
- */
373
- prompt(message, opts) {
374
- if (!this.options.prompt) {
375
- throw new Error("prompt is not supported!");
376
- }
377
- return this.options.prompt(message, opts);
378
- }
379
- /**
380
- * Creates a new instance of Consola, inheriting options from the current instance, with possible overrides.
381
- *
382
- * @param {Partial<ConsolaOptions>} options - Optional overrides for the new instance. See {@link ConsolaOptions}.
383
- * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
384
- */
385
- create(options) {
386
- const instance = new Consola({
387
- ...this.options,
388
- ...options
389
- });
390
- if (this._mockFn) {
391
- instance.mockTypes(this._mockFn);
392
- }
393
- return instance;
394
- }
395
- /**
396
- * Creates a new Consola instance with the specified default log object properties.
397
- *
398
- * @param {InputLogObject} defaults - Default properties to include in any log from the new instance. See {@link InputLogObject}.
399
- * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
400
- */
401
- withDefaults(defaults) {
402
- return this.create({
403
- ...this.options,
404
- defaults: {
405
- ...this.options.defaults,
406
- ...defaults
407
- }
408
- });
409
- }
410
- /**
411
- * Creates a new Consola instance with a specified tag, which will be included in every log.
412
- *
413
- * @param {string} tag - The tag to include in each log of the new instance.
414
- * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
415
- */
416
- withTag(tag) {
417
- return this.withDefaults({
418
- tag: this.options.defaults.tag ? this.options.defaults.tag + ":" + tag : tag
419
- });
420
- }
421
- /**
422
- * Adds a custom reporter to the Consola instance.
423
- * Reporters will be called for each log message, depending on their implementation and log level.
424
- *
425
- * @param {ConsolaReporter} reporter - The reporter to add. See {@link ConsolaReporter}.
426
- * @returns {Consola} The current Consola instance.
427
- */
428
- addReporter(reporter) {
429
- this.options.reporters.push(reporter);
430
- return this;
431
- }
432
- /**
433
- * Removes a custom reporter from the Consola instance.
434
- * If no reporter is specified, all reporters will be removed.
435
- *
436
- * @param {ConsolaReporter} reporter - The reporter to remove. See {@link ConsolaReporter}.
437
- * @returns {Consola} The current Consola instance.
438
- */
439
- removeReporter(reporter) {
440
- if (reporter) {
441
- const i = this.options.reporters.indexOf(reporter);
442
- if (i !== -1) {
443
- return this.options.reporters.splice(i, 1);
444
- }
445
- } else {
446
- this.options.reporters.splice(0);
447
- }
448
- return this;
449
- }
450
- /**
451
- * Replaces all reporters of the Consola instance with the specified array of reporters.
452
- *
453
- * @param {ConsolaReporter[]} reporters - The new reporters to set. See {@link ConsolaReporter}.
454
- * @returns {Consola} The current Consola instance.
455
- */
456
- setReporters(reporters) {
457
- this.options.reporters = Array.isArray(reporters) ? reporters : [reporters];
458
- return this;
459
- }
460
- wrapAll() {
461
- this.wrapConsole();
462
- this.wrapStd();
463
- }
464
- restoreAll() {
465
- this.restoreConsole();
466
- this.restoreStd();
467
- }
468
- /**
469
- * Overrides console methods with Consola logging methods for consistent logging.
470
- */
471
- wrapConsole() {
472
- for (const type in this.options.types) {
473
- if (!console["__" + type]) {
474
- console["__" + type] = console[type];
475
- }
476
- console[type] = this[type].raw;
477
- }
478
- }
479
- /**
480
- * Restores the original console methods, removing Consola overrides.
481
- */
482
- restoreConsole() {
483
- for (const type in this.options.types) {
484
- if (console["__" + type]) {
485
- console[type] = console["__" + type];
486
- delete console["__" + type];
487
- }
488
- }
489
- }
490
- /**
491
- * Overrides standard output and error streams to redirect them through Consola.
492
- */
493
- wrapStd() {
494
- this._wrapStream(this.options.stdout, "log");
495
- this._wrapStream(this.options.stderr, "log");
496
- }
497
- _wrapStream(stream, type) {
498
- if (!stream) {
499
- return;
500
- }
501
- if (!stream.__write) {
502
- stream.__write = stream.write;
503
- }
504
- stream.write = (data) => {
505
- this[type].raw(String(data).trim());
506
- };
507
- }
508
- /**
509
- * Restores the original standard output and error streams, removing the Consola redirection.
510
- */
511
- restoreStd() {
512
- this._restoreStream(this.options.stdout);
513
- this._restoreStream(this.options.stderr);
514
- }
515
- _restoreStream(stream) {
516
- if (!stream) {
517
- return;
518
- }
519
- if (stream.__write) {
520
- stream.write = stream.__write;
521
- delete stream.__write;
522
- }
523
- }
524
- /**
525
- * Pauses logging, queues incoming logs until resumed.
526
- */
527
- pauseLogs() {
528
- paused = true;
529
- }
530
- /**
531
- * Resumes logging, processing any queued logs.
532
- */
533
- resumeLogs() {
534
- paused = false;
535
- const _queue = queue.splice(0);
536
- for (const item of _queue) {
537
- item[0]._logFn(item[1], item[2]);
538
- }
539
- }
540
- /**
541
- * Replaces logging methods with mocks if a mock function is provided.
542
- *
543
- * @param {ConsolaOptions["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link ConsolaOptions["mockFn"]}.
544
- */
545
- mockTypes(mockFn) {
546
- const _mockFn = mockFn || this.options.mockFn;
547
- this._mockFn = _mockFn;
548
- if (typeof _mockFn !== "function") {
549
- return;
550
- }
551
- for (const type in this.options.types) {
552
- this[type] = _mockFn(type, this.options.types[type]) || this[type];
553
- this[type].raw = this[type];
554
- }
555
- }
556
- _wrapLogFn(defaults, isRaw) {
557
- return (...args) => {
558
- if (paused) {
559
- queue.push([this, defaults, args, isRaw]);
560
- return;
561
- }
562
- return this._logFn(defaults, args, isRaw);
563
- };
564
- }
565
- _logFn(defaults, args, isRaw) {
566
- if ((defaults.level || 0) > this.level) {
567
- return false;
568
- }
569
- const logObj = {
570
- date: /* @__PURE__ */ new Date(),
571
- args: [],
572
- ...defaults,
573
- level: _normalizeLogLevel(defaults.level, this.options.types)
574
- };
575
- if (!isRaw && args.length === 1 && isLogObj(args[0])) {
576
- Object.assign(logObj, args[0]);
577
- } else {
578
- logObj.args = [...args];
579
- }
580
- if (logObj.message) {
581
- logObj.args.unshift(logObj.message);
582
- delete logObj.message;
583
- }
584
- if (logObj.additional) {
585
- if (!Array.isArray(logObj.additional)) {
586
- logObj.additional = logObj.additional.split("\n");
587
- }
588
- logObj.args.push("\n" + logObj.additional.join("\n"));
589
- delete logObj.additional;
590
- }
591
- logObj.type = typeof logObj.type === "string" ? logObj.type.toLowerCase() : "log";
592
- logObj.tag = typeof logObj.tag === "string" ? logObj.tag : "";
593
- const resolveLog = (newLog = false) => {
594
- const repeated = (this._lastLog.count || 0) - this.options.throttleMin;
595
- if (this._lastLog.object && repeated > 0) {
596
- const args2 = [...this._lastLog.object.args];
597
- if (repeated > 1) {
598
- args2.push(`(repeated ${repeated} times)`);
599
- }
600
- this._log({ ...this._lastLog.object, args: args2 });
601
- this._lastLog.count = 1;
602
- }
603
- if (newLog) {
604
- this._lastLog.object = logObj;
605
- this._log(logObj);
606
- }
607
- };
608
- clearTimeout(this._lastLog.timeout);
609
- const diffTime = this._lastLog.time && logObj.date ? logObj.date.getTime() - this._lastLog.time.getTime() : 0;
610
- this._lastLog.time = logObj.date;
611
- if (diffTime < this.options.throttle) {
612
- try {
613
- const serializedLog = JSON.stringify([
614
- logObj.type,
615
- logObj.tag,
616
- logObj.args
617
- ]);
618
- const isSameLog = this._lastLog.serialized === serializedLog;
619
- this._lastLog.serialized = serializedLog;
620
- if (isSameLog) {
621
- this._lastLog.count = (this._lastLog.count || 0) + 1;
622
- if (this._lastLog.count > this.options.throttleMin) {
623
- this._lastLog.timeout = setTimeout(
624
- resolveLog,
625
- this.options.throttle
626
- );
627
- return;
628
- }
629
- }
630
- } catch {
631
- }
632
- }
633
- resolveLog(true);
634
- }
635
- _log(logObj) {
636
- for (const reporter of this.options.reporters) {
637
- reporter.log(logObj, {
638
- options: this.options
639
- });
640
- }
641
- }
642
- }
643
- function _normalizeLogLevel(input, types = {}, defaultLevel = 3) {
644
- if (input === void 0) {
645
- return defaultLevel;
646
- }
647
- if (typeof input === "number") {
648
- return input;
649
- }
650
- if (types[input] && types[input].level !== void 0) {
651
- return types[input].level;
652
- }
653
- return defaultLevel;
654
- }
655
- Consola.prototype.add = Consola.prototype.addReporter;
656
- Consola.prototype.remove = Consola.prototype.removeReporter;
657
- Consola.prototype.clear = Consola.prototype.removeReporter;
658
- Consola.prototype.withScope = Consola.prototype.withTag;
659
- Consola.prototype.mock = Consola.prototype.mockTypes;
660
- Consola.prototype.pause = Consola.prototype.pauseLogs;
661
- Consola.prototype.resume = Consola.prototype.resumeLogs;
662
- function createConsola$1(options = {}) {
663
- return new Consola(options);
664
- }
665
-
666
- function parseStack(stack, message) {
667
- const cwd = process.cwd() + sep;
668
- const lines = stack.split("\n").splice(message.split("\n").length).map((l) => l.trim().replace("file://", "").replace(cwd, ""));
669
- return lines;
670
- }
671
-
672
- function writeStream(data, stream) {
673
- const write = stream.__write || stream.write;
674
- return write.call(stream, data);
675
- }
676
-
677
- const bracket = (x) => x ? `[${x}]` : "";
678
- class BasicReporter {
679
- formatStack(stack, message, opts) {
680
- const indent = " ".repeat((opts?.errorLevel || 0) + 1);
681
- return indent + parseStack(stack, message).join(`
682
- ${indent}`);
683
- }
684
- formatError(err, opts) {
685
- const message = err.message ?? formatWithOptions(opts, err);
686
- const stack = err.stack ? this.formatStack(err.stack, message, opts) : "";
687
- const level = opts?.errorLevel || 0;
688
- const causedPrefix = level > 0 ? `${" ".repeat(level)}[cause]: ` : "";
689
- const causedError = err.cause ? "\n\n" + this.formatError(err.cause, { ...opts, errorLevel: level + 1 }) : "";
690
- return causedPrefix + message + "\n" + stack + causedError;
691
- }
692
- formatArgs(args, opts) {
693
- const _args = args.map((arg) => {
694
- if (arg && typeof arg.stack === "string") {
695
- return this.formatError(arg, opts);
696
- }
697
- return arg;
698
- });
699
- return formatWithOptions(opts, ..._args);
700
- }
701
- formatDate(date, opts) {
702
- return opts.date ? date.toLocaleTimeString() : "";
703
- }
704
- filterAndJoin(arr) {
705
- return arr.filter(Boolean).join(" ");
706
- }
707
- formatLogObj(logObj, opts) {
708
- const message = this.formatArgs(logObj.args, opts);
709
- if (logObj.type === "box") {
710
- return "\n" + [
711
- bracket(logObj.tag),
712
- logObj.title && logObj.title,
713
- ...message.split("\n")
714
- ].filter(Boolean).map((l) => " > " + l).join("\n") + "\n";
715
- }
716
- return this.filterAndJoin([
717
- bracket(logObj.type),
718
- bracket(logObj.tag),
719
- message
720
- ]);
721
- }
722
- log(logObj, ctx) {
723
- const line = this.formatLogObj(logObj, {
724
- columns: ctx.options.stdout.columns || 0,
725
- ...ctx.options.formatOptions
726
- });
727
- return writeStream(
728
- line + "\n",
729
- logObj.level < 2 ? ctx.options.stderr || process.stderr : ctx.options.stdout || process.stdout
730
- );
731
- }
732
- }
733
-
734
- const {
735
- env = {},
736
- argv = [],
737
- platform = ""
738
- } = typeof process === "undefined" ? {} : process;
739
- const isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
740
- const isForced = "FORCE_COLOR" in env || argv.includes("--color");
741
- const isWindows = platform === "win32";
742
- const isDumbTerminal = env.TERM === "dumb";
743
- const isCompatibleTerminal = tty$1 && tty$1.isatty && tty$1.isatty(1) && env.TERM && !isDumbTerminal;
744
- const isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
745
- const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
746
- function replaceClose(index, string, close, replace, head = string.slice(0, Math.max(0, index)) + replace, tail = string.slice(Math.max(0, index + close.length)), next = tail.indexOf(close)) {
747
- return head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
748
- }
749
- function clearBleed(index, string, open, close, replace) {
750
- return index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
751
- }
752
- function filterEmpty(open, close, replace = open, at = open.length + 1) {
753
- return (string) => string || !(string === "" || string === void 0) ? clearBleed(
754
- ("" + string).indexOf(close, at),
755
- string,
756
- open,
757
- close,
758
- replace
759
- ) : "";
760
- }
761
- function init(open, close, replace) {
762
- return filterEmpty(`\x1B[${open}m`, `\x1B[${close}m`, replace);
763
- }
764
- const colorDefs = {
765
- reset: init(0, 0),
766
- bold: init(1, 22, "\x1B[22m\x1B[1m"),
767
- dim: init(2, 22, "\x1B[22m\x1B[2m"),
768
- italic: init(3, 23),
769
- underline: init(4, 24),
770
- inverse: init(7, 27),
771
- hidden: init(8, 28),
772
- strikethrough: init(9, 29),
773
- black: init(30, 39),
774
- red: init(31, 39),
775
- green: init(32, 39),
776
- yellow: init(33, 39),
777
- blue: init(34, 39),
778
- magenta: init(35, 39),
779
- cyan: init(36, 39),
780
- white: init(37, 39),
781
- gray: init(90, 39),
782
- bgBlack: init(40, 49),
783
- bgRed: init(41, 49),
784
- bgGreen: init(42, 49),
785
- bgYellow: init(43, 49),
786
- bgBlue: init(44, 49),
787
- bgMagenta: init(45, 49),
788
- bgCyan: init(46, 49),
789
- bgWhite: init(47, 49),
790
- blackBright: init(90, 39),
791
- redBright: init(91, 39),
792
- greenBright: init(92, 39),
793
- yellowBright: init(93, 39),
794
- blueBright: init(94, 39),
795
- magentaBright: init(95, 39),
796
- cyanBright: init(96, 39),
797
- whiteBright: init(97, 39),
798
- bgBlackBright: init(100, 49),
799
- bgRedBright: init(101, 49),
800
- bgGreenBright: init(102, 49),
801
- bgYellowBright: init(103, 49),
802
- bgBlueBright: init(104, 49),
803
- bgMagentaBright: init(105, 49),
804
- bgCyanBright: init(106, 49),
805
- bgWhiteBright: init(107, 49)
806
- };
807
- function createColors(useColor = isColorSupported) {
808
- return useColor ? colorDefs : Object.fromEntries(Object.keys(colorDefs).map((key) => [key, String]));
809
- }
810
- const colors = createColors();
811
- function getColor$1(color, fallback = "reset") {
812
- return colors[color] || colors[fallback];
813
- }
814
-
815
- const ansiRegex$1 = [
816
- String.raw`[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)`,
817
- String.raw`(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))`
818
- ].join("|");
819
- function stripAnsi$1(text) {
820
- return text.replace(new RegExp(ansiRegex$1, "g"), "");
821
- }
822
-
823
- const boxStylePresets = {
824
- solid: {
825
- tl: "\u250C",
826
- tr: "\u2510",
827
- bl: "\u2514",
828
- br: "\u2518",
829
- h: "\u2500",
830
- v: "\u2502"
831
- },
832
- double: {
833
- tl: "\u2554",
834
- tr: "\u2557",
835
- bl: "\u255A",
836
- br: "\u255D",
837
- h: "\u2550",
838
- v: "\u2551"
839
- },
840
- doubleSingle: {
841
- tl: "\u2553",
842
- tr: "\u2556",
843
- bl: "\u2559",
844
- br: "\u255C",
845
- h: "\u2500",
846
- v: "\u2551"
847
- },
848
- doubleSingleRounded: {
849
- tl: "\u256D",
850
- tr: "\u256E",
851
- bl: "\u2570",
852
- br: "\u256F",
853
- h: "\u2500",
854
- v: "\u2551"
855
- },
856
- singleThick: {
857
- tl: "\u250F",
858
- tr: "\u2513",
859
- bl: "\u2517",
860
- br: "\u251B",
861
- h: "\u2501",
862
- v: "\u2503"
863
- },
864
- singleDouble: {
865
- tl: "\u2552",
866
- tr: "\u2555",
867
- bl: "\u2558",
868
- br: "\u255B",
869
- h: "\u2550",
870
- v: "\u2502"
871
- },
872
- singleDoubleRounded: {
873
- tl: "\u256D",
874
- tr: "\u256E",
875
- bl: "\u2570",
876
- br: "\u256F",
877
- h: "\u2550",
878
- v: "\u2502"
879
- },
880
- rounded: {
881
- tl: "\u256D",
882
- tr: "\u256E",
883
- bl: "\u2570",
884
- br: "\u256F",
885
- h: "\u2500",
886
- v: "\u2502"
887
- }
888
- };
889
- const defaultStyle = {
890
- borderColor: "white",
891
- borderStyle: "rounded",
892
- valign: "center",
893
- padding: 2,
894
- marginLeft: 1,
895
- marginTop: 1,
896
- marginBottom: 1
897
- };
898
- function box(text, _opts = {}) {
899
- const opts = {
900
- ..._opts,
901
- style: {
902
- ...defaultStyle,
903
- ..._opts.style
904
- }
905
- };
906
- const textLines = text.split("\n");
907
- const boxLines = [];
908
- const _color = getColor$1(opts.style.borderColor);
909
- const borderStyle = {
910
- ...typeof opts.style.borderStyle === "string" ? boxStylePresets[opts.style.borderStyle] || boxStylePresets.solid : opts.style.borderStyle
911
- };
912
- if (_color) {
913
- for (const key in borderStyle) {
914
- borderStyle[key] = _color(
915
- borderStyle[key]
916
- );
917
- }
918
- }
919
- const paddingOffset = opts.style.padding % 2 === 0 ? opts.style.padding : opts.style.padding + 1;
920
- const height = textLines.length + paddingOffset;
921
- const width = Math.max(
922
- ...textLines.map((line) => stripAnsi$1(line).length),
923
- opts.title ? stripAnsi$1(opts.title).length : 0
924
- ) + paddingOffset;
925
- const widthOffset = width + paddingOffset;
926
- const leftSpace = opts.style.marginLeft > 0 ? " ".repeat(opts.style.marginLeft) : "";
927
- if (opts.style.marginTop > 0) {
928
- boxLines.push("".repeat(opts.style.marginTop));
929
- }
930
- if (opts.title) {
931
- const title = _color ? _color(opts.title) : opts.title;
932
- const left = borderStyle.h.repeat(
933
- Math.floor((width - stripAnsi$1(opts.title).length) / 2)
934
- );
935
- const right = borderStyle.h.repeat(
936
- width - stripAnsi$1(opts.title).length - stripAnsi$1(left).length + paddingOffset
937
- );
938
- boxLines.push(
939
- `${leftSpace}${borderStyle.tl}${left}${title}${right}${borderStyle.tr}`
940
- );
941
- } else {
942
- boxLines.push(
943
- `${leftSpace}${borderStyle.tl}${borderStyle.h.repeat(widthOffset)}${borderStyle.tr}`
944
- );
945
- }
946
- const valignOffset = opts.style.valign === "center" ? Math.floor((height - textLines.length) / 2) : opts.style.valign === "top" ? height - textLines.length - paddingOffset : height - textLines.length;
947
- for (let i = 0; i < height; i++) {
948
- if (i < valignOffset || i >= valignOffset + textLines.length) {
949
- boxLines.push(
950
- `${leftSpace}${borderStyle.v}${" ".repeat(widthOffset)}${borderStyle.v}`
951
- );
952
- } else {
953
- const line = textLines[i - valignOffset];
954
- const left = " ".repeat(paddingOffset);
955
- const right = " ".repeat(width - stripAnsi$1(line).length);
956
- boxLines.push(
957
- `${leftSpace}${borderStyle.v}${left}${line}${right}${borderStyle.v}`
958
- );
959
- }
960
- }
961
- boxLines.push(
962
- `${leftSpace}${borderStyle.bl}${borderStyle.h.repeat(widthOffset)}${borderStyle.br}`
963
- );
964
- if (opts.style.marginBottom > 0) {
965
- boxLines.push("".repeat(opts.style.marginBottom));
966
- }
967
- return boxLines.join("\n");
968
- }
969
-
970
- const r=Object.create(null),i=e=>globalThis.process?.env||import.meta.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?r:globalThis),o=new Proxy(r,{get(e,s){return i()[s]??r[s]},has(e,s){const E=i();return s in E||s in r},set(e,s,E){const B=i(true);return B[s]=E,true},deleteProperty(e,s){if(!s)return false;const E=i(true);return delete E[s],true},ownKeys(){const e=i(true);return Object.keys(e)}}),t=typeof process<"u"&&process.env&&process.env.NODE_ENV||"",f=[["APPVEYOR"],["AWS_AMPLIFY","AWS_APP_ID",{ci:true}],["AZURE_PIPELINES","SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"],["AZURE_STATIC","INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"],["APPCIRCLE","AC_APPCIRCLE"],["BAMBOO","bamboo_planKey"],["BITBUCKET","BITBUCKET_COMMIT"],["BITRISE","BITRISE_IO"],["BUDDY","BUDDY_WORKSPACE_ID"],["BUILDKITE"],["CIRCLE","CIRCLECI"],["CIRRUS","CIRRUS_CI"],["CLOUDFLARE_PAGES","CF_PAGES",{ci:true}],["CODEBUILD","CODEBUILD_BUILD_ARN"],["CODEFRESH","CF_BUILD_ID"],["DRONE"],["DRONE","DRONE_BUILD_EVENT"],["DSARI"],["GITHUB_ACTIONS"],["GITLAB","GITLAB_CI"],["GITLAB","CI_MERGE_REQUEST_ID"],["GOCD","GO_PIPELINE_LABEL"],["LAYERCI"],["HUDSON","HUDSON_URL"],["JENKINS","JENKINS_URL"],["MAGNUM"],["NETLIFY"],["NETLIFY","NETLIFY_LOCAL",{ci:false}],["NEVERCODE"],["RENDER"],["SAIL","SAILCI"],["SEMAPHORE"],["SCREWDRIVER"],["SHIPPABLE"],["SOLANO","TDDIUM"],["STRIDER"],["TEAMCITY","TEAMCITY_VERSION"],["TRAVIS"],["VERCEL","NOW_BUILDER"],["VERCEL","VERCEL",{ci:false}],["VERCEL","VERCEL_ENV",{ci:false}],["APPCENTER","APPCENTER_BUILD_ID"],["CODESANDBOX","CODESANDBOX_SSE",{ci:false}],["CODESANDBOX","CODESANDBOX_HOST",{ci:false}],["STACKBLITZ"],["STORMKIT"],["CLEAVR"],["ZEABUR"],["CODESPHERE","CODESPHERE_APP_ID",{ci:true}],["RAILWAY","RAILWAY_PROJECT_ID"],["RAILWAY","RAILWAY_SERVICE_ID"],["DENO-DEPLOY","DENO_DEPLOYMENT_ID"],["FIREBASE_APP_HOSTING","FIREBASE_APP_HOSTING",{ci:true}]];function b(){if(globalThis.process?.env)for(const e of f){const s=e[1]||e[0];if(globalThis.process?.env[s])return {name:e[0].toLowerCase(),...e[2]}}return globalThis.process?.env?.SHELL==="/bin/jsh"&&globalThis.process?.versions?.webcontainer?{name:"stackblitz",ci:false}:{name:"",ci:false}}const l=b();l.name;function n(e){return e?e!=="false":false}const I=globalThis.process?.platform||"",T=n(o.CI)||l.ci!==false,a=n(globalThis.process?.stdout&&globalThis.process?.stdout.isTTY),g=n(o.DEBUG),R=t==="test"||n(o.TEST);n(o.MINIMAL)||T||R||!a;const A=/^win/i.test(I);!n(o.NO_COLOR)&&(n(o.FORCE_COLOR)||(a||A)&&o.TERM!=="dumb"||T);const C=(globalThis.process?.versions?.node||"").replace(/^v/,"")||null;Number(C?.split(".")[0])||null;const y=globalThis.process||Object.create(null),_={versions:{}};new Proxy(y,{get(e,s){if(s==="env")return o;if(s in e)return e[s];if(s in _)return _[s]}});const c=globalThis.process?.release?.name==="node",O=!!globalThis.Bun||!!globalThis.process?.versions?.bun,D=!!globalThis.Deno,L=!!globalThis.fastly,S=!!globalThis.Netlify,u=!!globalThis.EdgeRuntime,N=globalThis.navigator?.userAgent==="Cloudflare-Workers",F=[[S,"netlify"],[u,"edge-light"],[N,"workerd"],[L,"fastly"],[D,"deno"],[O,"bun"],[c,"node"]];function G(){const e=F.find(s=>s[0]);if(e)return {name:e[1]}}const P=G();P?.name||"";
971
-
972
- function ansiRegex({onlyFirst = false} = {}) {
973
- // Valid string terminator sequences are BEL, ESC\, and 0x9c
974
- const ST = '(?:\\u0007|\\u001B\\u005C|\\u009C)';
975
- const pattern = [
976
- `[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`,
977
- '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))',
978
- ].join('|');
979
-
980
- return new RegExp(pattern, onlyFirst ? undefined : 'g');
981
- }
982
-
983
- const regex = ansiRegex();
984
-
985
- function stripAnsi(string) {
986
- if (typeof string !== 'string') {
987
- throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
988
- }
989
-
990
- // Even though the regex is global, we don't need to reset the `.lastIndex`
991
- // because unlike `.exec()` and `.test()`, `.replace()` does it automatically
992
- // and doing it manually has a performance penalty.
993
- return string.replace(regex, '');
994
- }
995
-
996
- // Generated code.
997
-
998
- function isAmbiguous(x) {
999
- return x === 0xA1
1000
- || x === 0xA4
1001
- || x === 0xA7
1002
- || x === 0xA8
1003
- || x === 0xAA
1004
- || x === 0xAD
1005
- || x === 0xAE
1006
- || x >= 0xB0 && x <= 0xB4
1007
- || x >= 0xB6 && x <= 0xBA
1008
- || x >= 0xBC && x <= 0xBF
1009
- || x === 0xC6
1010
- || x === 0xD0
1011
- || x === 0xD7
1012
- || x === 0xD8
1013
- || x >= 0xDE && x <= 0xE1
1014
- || x === 0xE6
1015
- || x >= 0xE8 && x <= 0xEA
1016
- || x === 0xEC
1017
- || x === 0xED
1018
- || x === 0xF0
1019
- || x === 0xF2
1020
- || x === 0xF3
1021
- || x >= 0xF7 && x <= 0xFA
1022
- || x === 0xFC
1023
- || x === 0xFE
1024
- || x === 0x101
1025
- || x === 0x111
1026
- || x === 0x113
1027
- || x === 0x11B
1028
- || x === 0x126
1029
- || x === 0x127
1030
- || x === 0x12B
1031
- || x >= 0x131 && x <= 0x133
1032
- || x === 0x138
1033
- || x >= 0x13F && x <= 0x142
1034
- || x === 0x144
1035
- || x >= 0x148 && x <= 0x14B
1036
- || x === 0x14D
1037
- || x === 0x152
1038
- || x === 0x153
1039
- || x === 0x166
1040
- || x === 0x167
1041
- || x === 0x16B
1042
- || x === 0x1CE
1043
- || x === 0x1D0
1044
- || x === 0x1D2
1045
- || x === 0x1D4
1046
- || x === 0x1D6
1047
- || x === 0x1D8
1048
- || x === 0x1DA
1049
- || x === 0x1DC
1050
- || x === 0x251
1051
- || x === 0x261
1052
- || x === 0x2C4
1053
- || x === 0x2C7
1054
- || x >= 0x2C9 && x <= 0x2CB
1055
- || x === 0x2CD
1056
- || x === 0x2D0
1057
- || x >= 0x2D8 && x <= 0x2DB
1058
- || x === 0x2DD
1059
- || x === 0x2DF
1060
- || x >= 0x300 && x <= 0x36F
1061
- || x >= 0x391 && x <= 0x3A1
1062
- || x >= 0x3A3 && x <= 0x3A9
1063
- || x >= 0x3B1 && x <= 0x3C1
1064
- || x >= 0x3C3 && x <= 0x3C9
1065
- || x === 0x401
1066
- || x >= 0x410 && x <= 0x44F
1067
- || x === 0x451
1068
- || x === 0x2010
1069
- || x >= 0x2013 && x <= 0x2016
1070
- || x === 0x2018
1071
- || x === 0x2019
1072
- || x === 0x201C
1073
- || x === 0x201D
1074
- || x >= 0x2020 && x <= 0x2022
1075
- || x >= 0x2024 && x <= 0x2027
1076
- || x === 0x2030
1077
- || x === 0x2032
1078
- || x === 0x2033
1079
- || x === 0x2035
1080
- || x === 0x203B
1081
- || x === 0x203E
1082
- || x === 0x2074
1083
- || x === 0x207F
1084
- || x >= 0x2081 && x <= 0x2084
1085
- || x === 0x20AC
1086
- || x === 0x2103
1087
- || x === 0x2105
1088
- || x === 0x2109
1089
- || x === 0x2113
1090
- || x === 0x2116
1091
- || x === 0x2121
1092
- || x === 0x2122
1093
- || x === 0x2126
1094
- || x === 0x212B
1095
- || x === 0x2153
1096
- || x === 0x2154
1097
- || x >= 0x215B && x <= 0x215E
1098
- || x >= 0x2160 && x <= 0x216B
1099
- || x >= 0x2170 && x <= 0x2179
1100
- || x === 0x2189
1101
- || x >= 0x2190 && x <= 0x2199
1102
- || x === 0x21B8
1103
- || x === 0x21B9
1104
- || x === 0x21D2
1105
- || x === 0x21D4
1106
- || x === 0x21E7
1107
- || x === 0x2200
1108
- || x === 0x2202
1109
- || x === 0x2203
1110
- || x === 0x2207
1111
- || x === 0x2208
1112
- || x === 0x220B
1113
- || x === 0x220F
1114
- || x === 0x2211
1115
- || x === 0x2215
1116
- || x === 0x221A
1117
- || x >= 0x221D && x <= 0x2220
1118
- || x === 0x2223
1119
- || x === 0x2225
1120
- || x >= 0x2227 && x <= 0x222C
1121
- || x === 0x222E
1122
- || x >= 0x2234 && x <= 0x2237
1123
- || x === 0x223C
1124
- || x === 0x223D
1125
- || x === 0x2248
1126
- || x === 0x224C
1127
- || x === 0x2252
1128
- || x === 0x2260
1129
- || x === 0x2261
1130
- || x >= 0x2264 && x <= 0x2267
1131
- || x === 0x226A
1132
- || x === 0x226B
1133
- || x === 0x226E
1134
- || x === 0x226F
1135
- || x === 0x2282
1136
- || x === 0x2283
1137
- || x === 0x2286
1138
- || x === 0x2287
1139
- || x === 0x2295
1140
- || x === 0x2299
1141
- || x === 0x22A5
1142
- || x === 0x22BF
1143
- || x === 0x2312
1144
- || x >= 0x2460 && x <= 0x24E9
1145
- || x >= 0x24EB && x <= 0x254B
1146
- || x >= 0x2550 && x <= 0x2573
1147
- || x >= 0x2580 && x <= 0x258F
1148
- || x >= 0x2592 && x <= 0x2595
1149
- || x === 0x25A0
1150
- || x === 0x25A1
1151
- || x >= 0x25A3 && x <= 0x25A9
1152
- || x === 0x25B2
1153
- || x === 0x25B3
1154
- || x === 0x25B6
1155
- || x === 0x25B7
1156
- || x === 0x25BC
1157
- || x === 0x25BD
1158
- || x === 0x25C0
1159
- || x === 0x25C1
1160
- || x >= 0x25C6 && x <= 0x25C8
1161
- || x === 0x25CB
1162
- || x >= 0x25CE && x <= 0x25D1
1163
- || x >= 0x25E2 && x <= 0x25E5
1164
- || x === 0x25EF
1165
- || x === 0x2605
1166
- || x === 0x2606
1167
- || x === 0x2609
1168
- || x === 0x260E
1169
- || x === 0x260F
1170
- || x === 0x261C
1171
- || x === 0x261E
1172
- || x === 0x2640
1173
- || x === 0x2642
1174
- || x === 0x2660
1175
- || x === 0x2661
1176
- || x >= 0x2663 && x <= 0x2665
1177
- || x >= 0x2667 && x <= 0x266A
1178
- || x === 0x266C
1179
- || x === 0x266D
1180
- || x === 0x266F
1181
- || x === 0x269E
1182
- || x === 0x269F
1183
- || x === 0x26BF
1184
- || x >= 0x26C6 && x <= 0x26CD
1185
- || x >= 0x26CF && x <= 0x26D3
1186
- || x >= 0x26D5 && x <= 0x26E1
1187
- || x === 0x26E3
1188
- || x === 0x26E8
1189
- || x === 0x26E9
1190
- || x >= 0x26EB && x <= 0x26F1
1191
- || x === 0x26F4
1192
- || x >= 0x26F6 && x <= 0x26F9
1193
- || x === 0x26FB
1194
- || x === 0x26FC
1195
- || x === 0x26FE
1196
- || x === 0x26FF
1197
- || x === 0x273D
1198
- || x >= 0x2776 && x <= 0x277F
1199
- || x >= 0x2B56 && x <= 0x2B59
1200
- || x >= 0x3248 && x <= 0x324F
1201
- || x >= 0xE000 && x <= 0xF8FF
1202
- || x >= 0xFE00 && x <= 0xFE0F
1203
- || x === 0xFFFD
1204
- || x >= 0x1F100 && x <= 0x1F10A
1205
- || x >= 0x1F110 && x <= 0x1F12D
1206
- || x >= 0x1F130 && x <= 0x1F169
1207
- || x >= 0x1F170 && x <= 0x1F18D
1208
- || x === 0x1F18F
1209
- || x === 0x1F190
1210
- || x >= 0x1F19B && x <= 0x1F1AC
1211
- || x >= 0xE0100 && x <= 0xE01EF
1212
- || x >= 0xF0000 && x <= 0xFFFFD
1213
- || x >= 0x100000 && x <= 0x10FFFD;
1214
- }
1215
-
1216
- function isFullWidth(x) {
1217
- return x === 0x3000
1218
- || x >= 0xFF01 && x <= 0xFF60
1219
- || x >= 0xFFE0 && x <= 0xFFE6;
1220
- }
1221
-
1222
- function isWide(x) {
1223
- return x >= 0x1100 && x <= 0x115F
1224
- || x === 0x231A
1225
- || x === 0x231B
1226
- || x === 0x2329
1227
- || x === 0x232A
1228
- || x >= 0x23E9 && x <= 0x23EC
1229
- || x === 0x23F0
1230
- || x === 0x23F3
1231
- || x === 0x25FD
1232
- || x === 0x25FE
1233
- || x === 0x2614
1234
- || x === 0x2615
1235
- || x >= 0x2630 && x <= 0x2637
1236
- || x >= 0x2648 && x <= 0x2653
1237
- || x === 0x267F
1238
- || x >= 0x268A && x <= 0x268F
1239
- || x === 0x2693
1240
- || x === 0x26A1
1241
- || x === 0x26AA
1242
- || x === 0x26AB
1243
- || x === 0x26BD
1244
- || x === 0x26BE
1245
- || x === 0x26C4
1246
- || x === 0x26C5
1247
- || x === 0x26CE
1248
- || x === 0x26D4
1249
- || x === 0x26EA
1250
- || x === 0x26F2
1251
- || x === 0x26F3
1252
- || x === 0x26F5
1253
- || x === 0x26FA
1254
- || x === 0x26FD
1255
- || x === 0x2705
1256
- || x === 0x270A
1257
- || x === 0x270B
1258
- || x === 0x2728
1259
- || x === 0x274C
1260
- || x === 0x274E
1261
- || x >= 0x2753 && x <= 0x2755
1262
- || x === 0x2757
1263
- || x >= 0x2795 && x <= 0x2797
1264
- || x === 0x27B0
1265
- || x === 0x27BF
1266
- || x === 0x2B1B
1267
- || x === 0x2B1C
1268
- || x === 0x2B50
1269
- || x === 0x2B55
1270
- || x >= 0x2E80 && x <= 0x2E99
1271
- || x >= 0x2E9B && x <= 0x2EF3
1272
- || x >= 0x2F00 && x <= 0x2FD5
1273
- || x >= 0x2FF0 && x <= 0x2FFF
1274
- || x >= 0x3001 && x <= 0x303E
1275
- || x >= 0x3041 && x <= 0x3096
1276
- || x >= 0x3099 && x <= 0x30FF
1277
- || x >= 0x3105 && x <= 0x312F
1278
- || x >= 0x3131 && x <= 0x318E
1279
- || x >= 0x3190 && x <= 0x31E5
1280
- || x >= 0x31EF && x <= 0x321E
1281
- || x >= 0x3220 && x <= 0x3247
1282
- || x >= 0x3250 && x <= 0xA48C
1283
- || x >= 0xA490 && x <= 0xA4C6
1284
- || x >= 0xA960 && x <= 0xA97C
1285
- || x >= 0xAC00 && x <= 0xD7A3
1286
- || x >= 0xF900 && x <= 0xFAFF
1287
- || x >= 0xFE10 && x <= 0xFE19
1288
- || x >= 0xFE30 && x <= 0xFE52
1289
- || x >= 0xFE54 && x <= 0xFE66
1290
- || x >= 0xFE68 && x <= 0xFE6B
1291
- || x >= 0x16FE0 && x <= 0x16FE4
1292
- || x === 0x16FF0
1293
- || x === 0x16FF1
1294
- || x >= 0x17000 && x <= 0x187F7
1295
- || x >= 0x18800 && x <= 0x18CD5
1296
- || x >= 0x18CFF && x <= 0x18D08
1297
- || x >= 0x1AFF0 && x <= 0x1AFF3
1298
- || x >= 0x1AFF5 && x <= 0x1AFFB
1299
- || x === 0x1AFFD
1300
- || x === 0x1AFFE
1301
- || x >= 0x1B000 && x <= 0x1B122
1302
- || x === 0x1B132
1303
- || x >= 0x1B150 && x <= 0x1B152
1304
- || x === 0x1B155
1305
- || x >= 0x1B164 && x <= 0x1B167
1306
- || x >= 0x1B170 && x <= 0x1B2FB
1307
- || x >= 0x1D300 && x <= 0x1D356
1308
- || x >= 0x1D360 && x <= 0x1D376
1309
- || x === 0x1F004
1310
- || x === 0x1F0CF
1311
- || x === 0x1F18E
1312
- || x >= 0x1F191 && x <= 0x1F19A
1313
- || x >= 0x1F200 && x <= 0x1F202
1314
- || x >= 0x1F210 && x <= 0x1F23B
1315
- || x >= 0x1F240 && x <= 0x1F248
1316
- || x === 0x1F250
1317
- || x === 0x1F251
1318
- || x >= 0x1F260 && x <= 0x1F265
1319
- || x >= 0x1F300 && x <= 0x1F320
1320
- || x >= 0x1F32D && x <= 0x1F335
1321
- || x >= 0x1F337 && x <= 0x1F37C
1322
- || x >= 0x1F37E && x <= 0x1F393
1323
- || x >= 0x1F3A0 && x <= 0x1F3CA
1324
- || x >= 0x1F3CF && x <= 0x1F3D3
1325
- || x >= 0x1F3E0 && x <= 0x1F3F0
1326
- || x === 0x1F3F4
1327
- || x >= 0x1F3F8 && x <= 0x1F43E
1328
- || x === 0x1F440
1329
- || x >= 0x1F442 && x <= 0x1F4FC
1330
- || x >= 0x1F4FF && x <= 0x1F53D
1331
- || x >= 0x1F54B && x <= 0x1F54E
1332
- || x >= 0x1F550 && x <= 0x1F567
1333
- || x === 0x1F57A
1334
- || x === 0x1F595
1335
- || x === 0x1F596
1336
- || x === 0x1F5A4
1337
- || x >= 0x1F5FB && x <= 0x1F64F
1338
- || x >= 0x1F680 && x <= 0x1F6C5
1339
- || x === 0x1F6CC
1340
- || x >= 0x1F6D0 && x <= 0x1F6D2
1341
- || x >= 0x1F6D5 && x <= 0x1F6D7
1342
- || x >= 0x1F6DC && x <= 0x1F6DF
1343
- || x === 0x1F6EB
1344
- || x === 0x1F6EC
1345
- || x >= 0x1F6F4 && x <= 0x1F6FC
1346
- || x >= 0x1F7E0 && x <= 0x1F7EB
1347
- || x === 0x1F7F0
1348
- || x >= 0x1F90C && x <= 0x1F93A
1349
- || x >= 0x1F93C && x <= 0x1F945
1350
- || x >= 0x1F947 && x <= 0x1F9FF
1351
- || x >= 0x1FA70 && x <= 0x1FA7C
1352
- || x >= 0x1FA80 && x <= 0x1FA89
1353
- || x >= 0x1FA8F && x <= 0x1FAC6
1354
- || x >= 0x1FACE && x <= 0x1FADC
1355
- || x >= 0x1FADF && x <= 0x1FAE9
1356
- || x >= 0x1FAF0 && x <= 0x1FAF8
1357
- || x >= 0x20000 && x <= 0x2FFFD
1358
- || x >= 0x30000 && x <= 0x3FFFD;
1359
- }
1360
-
1361
- function validate$2(codePoint) {
1362
- if (!Number.isSafeInteger(codePoint)) {
1363
- throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
1364
- }
1365
- }
1366
-
1367
- function eastAsianWidth(codePoint, {ambiguousAsWide = false} = {}) {
1368
- validate$2(codePoint);
1369
-
1370
- if (
1371
- isFullWidth(codePoint)
1372
- || isWide(codePoint)
1373
- || (ambiguousAsWide && isAmbiguous(codePoint))
1374
- ) {
1375
- return 2;
1376
- }
1377
-
1378
- return 1;
1379
- }
1380
-
1381
- const emojiRegex$2 = () => {
1382
- // https://mths.be/emoji
1383
- return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
1384
- };
1385
-
1386
- const segmenter = globalThis.Intl?.Segmenter ? new Intl.Segmenter() : { segment: (str) => str.split('') };
1387
-
1388
- const defaultIgnorableCodePointRegex = /^\p{Default_Ignorable_Code_Point}$/u;
1389
-
1390
- function stringWidth$1(string, options = {}) {
1391
- if (typeof string !== 'string' || string.length === 0) {
1392
- return 0;
1393
- }
1394
-
1395
- const {
1396
- ambiguousIsNarrow = true,
1397
- countAnsiEscapeCodes = false,
1398
- } = options;
1399
-
1400
- if (!countAnsiEscapeCodes) {
1401
- string = stripAnsi(string);
1402
- }
1403
-
1404
- if (string.length === 0) {
1405
- return 0;
1406
- }
1407
-
1408
- let width = 0;
1409
- const eastAsianWidthOptions = {ambiguousAsWide: !ambiguousIsNarrow};
1410
-
1411
- for (const {segment: character} of segmenter.segment(string)) {
1412
- const codePoint = character.codePointAt(0);
1413
-
1414
- // Ignore control characters
1415
- if (codePoint <= 0x1F || (codePoint >= 0x7F && codePoint <= 0x9F)) {
1416
- continue;
1417
- }
1418
-
1419
- // Ignore zero-width characters
1420
- if (
1421
- (codePoint >= 0x20_0B && codePoint <= 0x20_0F) // Zero-width space, non-joiner, joiner, left-to-right mark, right-to-left mark
1422
- || codePoint === 0xFE_FF // Zero-width no-break space
1423
- ) {
1424
- continue;
1425
- }
1426
-
1427
- // Ignore combining characters
1428
- if (
1429
- (codePoint >= 0x3_00 && codePoint <= 0x3_6F) // Combining diacritical marks
1430
- || (codePoint >= 0x1A_B0 && codePoint <= 0x1A_FF) // Combining diacritical marks extended
1431
- || (codePoint >= 0x1D_C0 && codePoint <= 0x1D_FF) // Combining diacritical marks supplement
1432
- || (codePoint >= 0x20_D0 && codePoint <= 0x20_FF) // Combining diacritical marks for symbols
1433
- || (codePoint >= 0xFE_20 && codePoint <= 0xFE_2F) // Combining half marks
1434
- ) {
1435
- continue;
1436
- }
1437
-
1438
- // Ignore surrogate pairs
1439
- if (codePoint >= 0xD8_00 && codePoint <= 0xDF_FF) {
1440
- continue;
1441
- }
1442
-
1443
- // Ignore variation selectors
1444
- if (codePoint >= 0xFE_00 && codePoint <= 0xFE_0F) {
1445
- continue;
1446
- }
1447
-
1448
- // This covers some of the above cases, but we still keep them for performance reasons.
1449
- if (defaultIgnorableCodePointRegex.test(character)) {
1450
- continue;
1451
- }
1452
-
1453
- // TODO: Use `/\p{RGI_Emoji}/v` when targeting Node.js 20.
1454
- if (emojiRegex$2().test(character)) {
1455
- width += 2;
1456
- continue;
1457
- }
1458
-
1459
- width += eastAsianWidth(codePoint, eastAsianWidthOptions);
1460
- }
1461
-
1462
- return width;
1463
- }
1464
-
1465
- function isUnicodeSupported() {
1466
- const {env} = g$1;
1467
- const {TERM, TERM_PROGRAM} = env;
1468
-
1469
- if (g$1.platform !== 'win32') {
1470
- return TERM !== 'linux'; // Linux console (kernel)
1471
- }
1472
-
1473
- return Boolean(env.WT_SESSION) // Windows Terminal
1474
- || Boolean(env.TERMINUS_SUBLIME) // Terminus (<0.2.27)
1475
- || env.ConEmuTask === '{cmd::Cmder}' // ConEmu and cmder
1476
- || TERM_PROGRAM === 'Terminus-Sublime'
1477
- || TERM_PROGRAM === 'vscode'
1478
- || TERM === 'xterm-256color'
1479
- || TERM === 'alacritty'
1480
- || TERM === 'rxvt-unicode'
1481
- || TERM === 'rxvt-unicode-256color'
1482
- || env.TERMINAL_EMULATOR === 'JetBrains-JediTerm';
1483
- }
1484
-
1485
- const TYPE_COLOR_MAP = {
1486
- info: "cyan",
1487
- fail: "red",
1488
- success: "green",
1489
- ready: "green",
1490
- start: "magenta"
1491
- };
1492
- const LEVEL_COLOR_MAP = {
1493
- 0: "red",
1494
- 1: "yellow"
1495
- };
1496
- const unicode = isUnicodeSupported();
1497
- const s = (c, fallback) => unicode ? c : fallback;
1498
- const TYPE_ICONS = {
1499
- error: s("\u2716", "\xD7"),
1500
- fatal: s("\u2716", "\xD7"),
1501
- ready: s("\u2714", "\u221A"),
1502
- warn: s("\u26A0", "\u203C"),
1503
- info: s("\u2139", "i"),
1504
- success: s("\u2714", "\u221A"),
1505
- debug: s("\u2699", "D"),
1506
- trace: s("\u2192", "\u2192"),
1507
- fail: s("\u2716", "\xD7"),
1508
- start: s("\u25D0", "o"),
1509
- log: ""
1510
- };
1511
- function stringWidth(str) {
1512
- const hasICU = typeof Intl === "object";
1513
- if (!hasICU || !Intl.Segmenter) {
1514
- return stripAnsi$1(str).length;
1515
- }
1516
- return stringWidth$1(str);
1517
- }
1518
- class FancyReporter extends BasicReporter {
1519
- formatStack(stack, message, opts) {
1520
- const indent = " ".repeat((opts?.errorLevel || 0) + 1);
1521
- return `
1522
- ${indent}` + parseStack(stack, message).map(
1523
- (line) => " " + line.replace(/^at +/, (m) => colors.gray(m)).replace(/\((.+)\)/, (_, m) => `(${colors.cyan(m)})`)
1524
- ).join(`
1525
- ${indent}`);
1526
- }
1527
- formatType(logObj, isBadge, opts) {
1528
- const typeColor = TYPE_COLOR_MAP[logObj.type] || LEVEL_COLOR_MAP[logObj.level] || "gray";
1529
- if (isBadge) {
1530
- return getBgColor(typeColor)(
1531
- colors.black(` ${logObj.type.toUpperCase()} `)
1532
- );
1533
- }
1534
- const _type = typeof TYPE_ICONS[logObj.type] === "string" ? TYPE_ICONS[logObj.type] : logObj.icon || logObj.type;
1535
- return _type ? getColor(typeColor)(_type) : "";
1536
- }
1537
- formatLogObj(logObj, opts) {
1538
- const [message, ...additional] = this.formatArgs(logObj.args, opts).split(
1539
- "\n"
1540
- );
1541
- if (logObj.type === "box") {
1542
- return box(
1543
- characterFormat(
1544
- message + (additional.length > 0 ? "\n" + additional.join("\n") : "")
1545
- ),
1546
- {
1547
- title: logObj.title ? characterFormat(logObj.title) : void 0,
1548
- style: logObj.style
1549
- }
1550
- );
1551
- }
1552
- const date = this.formatDate(logObj.date, opts);
1553
- const coloredDate = date && colors.gray(date);
1554
- const isBadge = logObj.badge ?? logObj.level < 2;
1555
- const type = this.formatType(logObj, isBadge, opts);
1556
- const tag = logObj.tag ? colors.gray(logObj.tag) : "";
1557
- let line;
1558
- const left = this.filterAndJoin([type, characterFormat(message)]);
1559
- const right = this.filterAndJoin(opts.columns ? [tag, coloredDate] : [tag]);
1560
- const space = (opts.columns || 0) - stringWidth(left) - stringWidth(right) - 2;
1561
- line = space > 0 && (opts.columns || 0) >= 80 ? left + " ".repeat(space) + right : (right ? `${colors.gray(`[${right}]`)} ` : "") + left;
1562
- line += characterFormat(
1563
- additional.length > 0 ? "\n" + additional.join("\n") : ""
1564
- );
1565
- if (logObj.type === "trace") {
1566
- const _err = new Error("Trace: " + logObj.message);
1567
- line += this.formatStack(_err.stack || "", _err.message);
1568
- }
1569
- return isBadge ? "\n" + line + "\n" : line;
1570
- }
1571
- }
1572
- function characterFormat(str) {
1573
- return str.replace(/`([^`]+)`/gm, (_, m) => colors.cyan(m)).replace(/\s+_([^_]+)_\s+/gm, (_, m) => ` ${colors.underline(m)} `);
1574
- }
1575
- function getColor(color = "white") {
1576
- return colors[color] || colors.white;
1577
- }
1578
- function getBgColor(color = "bgWhite") {
1579
- return colors[`bg${color[0].toUpperCase()}${color.slice(1)}`] || colors.bgWhite;
1580
- }
1581
-
1582
- function createConsola(options = {}) {
1583
- let level = _getDefaultLogLevel();
1584
- if (process.env.CONSOLA_LEVEL) {
1585
- level = Number.parseInt(process.env.CONSOLA_LEVEL) ?? level;
1586
- }
1587
- const consola2 = createConsola$1({
1588
- level,
1589
- defaults: { level },
1590
- stdout: process.stdout,
1591
- stderr: process.stderr,
1592
- prompt: (...args) => import('../chunks/prompt.mjs').then((m) => m.prompt(...args)),
1593
- reporters: options.reporters || [
1594
- options.fancy ?? !(T || R) ? new FancyReporter() : new BasicReporter()
1595
- ],
1596
- ...options
1597
- });
1598
- return consola2;
1599
- }
1600
- function _getDefaultLogLevel() {
1601
- if (g) {
1602
- return LogLevels.debug;
1603
- }
1604
- if (R) {
1605
- return LogLevels.warn;
1606
- }
1607
- return LogLevels.info;
1608
- }
1609
- createConsola();
1610
-
1611
- //#region src/figlet-types.ts
1612
- var LAYOUT = {
1613
- FULL_WIDTH: 0,
1614
- FITTING: 1,
1615
- SMUSHING: 2,
1616
- CONTROLLED_SMUSHING: 3
1617
- };
1618
- var FigletFont = class {
1619
- constructor() {
1620
- this.comment = "";
1621
- this.numChars = 0;
1622
- this.options = {};
1623
- }
1624
- };
1625
- //#endregion
1626
- //#region src/font-list.ts
1627
- var fontList = [
1628
- "1Row",
1629
- "3-D",
1630
- "3D Diagonal",
1631
- "3D-ASCII",
1632
- "3x5",
1633
- "4Max",
1634
- "5 Line Oblique",
1635
- "AMC 3 Line",
1636
- "AMC 3 Liv1",
1637
- "AMC AAA01",
1638
- "AMC Neko",
1639
- "AMC Razor",
1640
- "AMC Razor2",
1641
- "AMC Slash",
1642
- "AMC Slider",
1643
- "AMC Thin",
1644
- "AMC Tubes",
1645
- "AMC Untitled",
1646
- "ANSI Compact",
1647
- "ANSI Regular",
1648
- "ANSI Shadow",
1649
- "ASCII 12",
1650
- "ASCII 9",
1651
- "ASCII New Roman",
1652
- "Acrobatic",
1653
- "Alligator",
1654
- "Alligator2",
1655
- "Alpha",
1656
- "Alphabet",
1657
- "Arrows",
1658
- "Avatar",
1659
- "B1FF",
1660
- "Babyface Lame",
1661
- "Babyface Leet",
1662
- "Banner",
1663
- "Banner3-D",
1664
- "Banner3",
1665
- "Banner4",
1666
- "Barbwire",
1667
- "Basic",
1668
- "Bear",
1669
- "Bell",
1670
- "Benjamin",
1671
- "Big ASCII 12",
1672
- "Big ASCII 9",
1673
- "Big Chief",
1674
- "Big Money-ne",
1675
- "Big Money-nw",
1676
- "Big Money-se",
1677
- "Big Money-sw",
1678
- "Big Mono 12",
1679
- "Big Mono 9",
1680
- "Big",
1681
- "Bigfig",
1682
- "Binary",
1683
- "Block",
1684
- "Blocks",
1685
- "Bloody",
1686
- "BlurVision ASCII",
1687
- "Bolger",
1688
- "Braced",
1689
- "Bright",
1690
- "Broadway KB",
1691
- "Broadway",
1692
- "Bubble",
1693
- "Bulbhead",
1694
- "Caligraphy",
1695
- "Caligraphy2",
1696
- "Calvin S",
1697
- "Cards",
1698
- "Catwalk",
1699
- "Chiseled",
1700
- "Chunky",
1701
- "Circle",
1702
- "Classy",
1703
- "Coder Mini",
1704
- "Coinstak",
1705
- "Cola",
1706
- "Colossal",
1707
- "Computer",
1708
- "Contessa",
1709
- "Contrast",
1710
- "Cosmike",
1711
- "Cosmike2",
1712
- "Crawford",
1713
- "Crawford2",
1714
- "Crazy",
1715
- "Cricket",
1716
- "Cursive",
1717
- "Cyberlarge",
1718
- "Cybermedium",
1719
- "Cybersmall",
1720
- "Cygnet",
1721
- "DANC4",
1722
- "DOS Rebel",
1723
- "DWhistled",
1724
- "Dancing Font",
1725
- "Decimal",
1726
- "Def Leppard",
1727
- "Delta Corps Priest 1",
1728
- "DiamFont",
1729
- "Diamond",
1730
- "Diet Cola",
1731
- "Digital",
1732
- "Doh",
1733
- "Doom",
1734
- "Dot Matrix",
1735
- "Double Shorts",
1736
- "Double",
1737
- "Dr Pepper",
1738
- "Efti Chess",
1739
- "Efti Font",
1740
- "Efti Italic",
1741
- "Efti Piti",
1742
- "Efti Robot",
1743
- "Efti Wall",
1744
- "Efti Water",
1745
- "Electronic",
1746
- "Elite",
1747
- "Emboss 2",
1748
- "Emboss",
1749
- "Epic",
1750
- "Fender",
1751
- "Filter",
1752
- "Fire Font-k",
1753
- "Fire Font-s",
1754
- "Flipped",
1755
- "Flower Power",
1756
- "Font Font",
1757
- "Four Tops",
1758
- "Fraktur",
1759
- "Fun Face",
1760
- "Fun Faces",
1761
- "Future Smooth",
1762
- "Future Thin",
1763
- "Future",
1764
- "Fuzzy",
1765
- "Georgi16",
1766
- "Georgia11",
1767
- "Ghost",
1768
- "Ghoulish",
1769
- "Glenyn",
1770
- "Goofy",
1771
- "Gothic",
1772
- "Graceful",
1773
- "Gradient",
1774
- "Graffiti",
1775
- "Greek",
1776
- "Heart Left",
1777
- "Heart Right",
1778
- "Henry 3D",
1779
- "Hex",
1780
- "Hieroglyphs",
1781
- "Hollywood",
1782
- "Horizontal Left",
1783
- "Horizontal Right",
1784
- "ICL-1900",
1785
- "Impossible",
1786
- "Invita",
1787
- "Isometric1",
1788
- "Isometric2",
1789
- "Isometric3",
1790
- "Isometric4",
1791
- "Italic",
1792
- "Ivrit",
1793
- "JS Block Letters",
1794
- "JS Bracket Letters",
1795
- "JS Capital Curves",
1796
- "JS Cursive",
1797
- "JS Stick Letters",
1798
- "Jacky",
1799
- "Jazmine",
1800
- "Jerusalem",
1801
- "Katakana",
1802
- "Kban",
1803
- "Keyboard",
1804
- "Knob",
1805
- "Konto Slant",
1806
- "Konto",
1807
- "LCD",
1808
- "Larry 3D 2",
1809
- "Larry 3D",
1810
- "Lean",
1811
- "Letter",
1812
- "Letters",
1813
- "Lil Devil",
1814
- "Line Blocks",
1815
- "Linguaholic Mini Block",
1816
- "Linguaholic Neon",
1817
- "Linguaholic Rounded",
1818
- "Linguaholic Shadow 3D",
1819
- "Linux",
1820
- "Lockergnome",
1821
- "Madrid",
1822
- "Marquee",
1823
- "Maxfour",
1824
- "Merlin1",
1825
- "Merlin2",
1826
- "Mike",
1827
- "Mini",
1828
- "Mirror",
1829
- "Mnemonic",
1830
- "Modular",
1831
- "Mono 12",
1832
- "Mono 9",
1833
- "Morse",
1834
- "Morse2",
1835
- "Moscow",
1836
- "Mshebrew210",
1837
- "Muzzle",
1838
- "NScript",
1839
- "NT Greek",
1840
- "NV Script",
1841
- "Nancyj-Fancy",
1842
- "Nancyj-Improved",
1843
- "Nancyj-Underlined",
1844
- "Nancyj",
1845
- "Nipples",
1846
- "O8",
1847
- "OS2",
1848
- "Octal",
1849
- "Ogre",
1850
- "Old Banner",
1851
- "Pagga",
1852
- "Patorjk's Cheese",
1853
- "Patorjk-HeX",
1854
- "Pawp",
1855
- "Peaks Slant",
1856
- "Peaks",
1857
- "Pebbles",
1858
- "Pepper",
1859
- "Poison",
1860
- "Puffy",
1861
- "Puzzle",
1862
- "Pyramid",
1863
- "Rammstein",
1864
- "Rebel",
1865
- "Rectangles",
1866
- "Red Phoenix",
1867
- "Relief",
1868
- "Relief2",
1869
- "Reverse",
1870
- "Roman",
1871
- "Rot13",
1872
- "Rotated",
1873
- "Rounded",
1874
- "Rowan Cap",
1875
- "Rozzo",
1876
- "RubiFont",
1877
- "Runic",
1878
- "Runyc",
1879
- "S Blood",
1880
- "SL Script",
1881
- "Santa Clara",
1882
- "Script",
1883
- "Serifcap",
1884
- "Shaded Blocky",
1885
- "Shadow",
1886
- "Shimrod",
1887
- "Short",
1888
- "Slant Relief",
1889
- "Slant",
1890
- "Slide",
1891
- "Small ASCII 12",
1892
- "Small ASCII 9",
1893
- "Small Block",
1894
- "Small Braille",
1895
- "Small Caps",
1896
- "Small Isometric1",
1897
- "Small Keyboard",
1898
- "Small Mono 12",
1899
- "Small Mono 9",
1900
- "Small Poison",
1901
- "Small Script",
1902
- "Small Shadow",
1903
- "Small Slant",
1904
- "Small Tengwar",
1905
- "Small",
1906
- "Soft",
1907
- "Speed",
1908
- "Spliff",
1909
- "Stacey",
1910
- "Stampate",
1911
- "Stampatello",
1912
- "Standard",
1913
- "Star Strips",
1914
- "Star Wars",
1915
- "Stellar",
1916
- "Stforek",
1917
- "Stick Letters",
1918
- "Stop",
1919
- "Straight",
1920
- "Stronger Than All",
1921
- "Sub-Zero",
1922
- "Swamp Land",
1923
- "Swan",
1924
- "Sweet",
1925
- "THIS",
1926
- "Tanja",
1927
- "Tengwar",
1928
- "Term",
1929
- "Terrace",
1930
- "Test1",
1931
- "The Edge",
1932
- "Thick",
1933
- "Thin",
1934
- "Thorned",
1935
- "Three Point",
1936
- "Ticks Slant",
1937
- "Ticks",
1938
- "Tiles",
1939
- "Tinker-Toy",
1940
- "Tmplr",
1941
- "Tombstone",
1942
- "Train",
1943
- "Trek",
1944
- "Tsalagi",
1945
- "Tubular",
1946
- "Twisted",
1947
- "Two Point",
1948
- "USA Flag",
1949
- "Univers",
1950
- "Upside Down Text",
1951
- "Varsity",
1952
- "Wavescape",
1953
- "Wavy",
1954
- "Weird",
1955
- "Wet Letter",
1956
- "Whimsy",
1957
- "WideTerm",
1958
- "Wow",
1959
- "miniwi"
1960
- ];
1961
- //#endregion
1962
- //#region src/renamed-fonts.js
1963
- var renamedFonts = { "ANSI-Compact": "ANSI Compact" };
1964
- var getFontName = (name) => {
1965
- return renamedFonts[name] ? renamedFonts[name] : name;
1966
- };
1967
- //#endregion
1968
- //#region src/figlet.ts
1969
- function escapeRegExpChar(char) {
1970
- return /[.*+?^${}()|[\]\\]/.test(char) ? "\\" + char : char;
1971
- }
1972
- var figlet = (() => {
1973
- const { FULL_WIDTH = 0, FITTING, SMUSHING, CONTROLLED_SMUSHING } = LAYOUT;
1974
- const figFonts = {};
1975
- const figDefaults = {
1976
- font: "Standard",
1977
- fontPath: "./fonts",
1978
- fetchFontIfMissing: true
1979
- };
1980
- /**
1981
- * Figures out the end char for a FIGlet line and removes it. Technically there aren't supposed to be white spaces
1982
- * after the end char, but certain TOIlet fonts have this. The FIGlet unix app handles this though so we handle it
1983
- * here too.
1984
- *
1985
- * @param line
1986
- * @param lineNum
1987
- * @param fontHeight
1988
- */
1989
- function removeEndChar(line, lineNum, fontHeight) {
1990
- const endChar = escapeRegExpChar(line.trim().slice(-1)) || "@";
1991
- const endCharRegEx = lineNum === fontHeight - 1 ? new RegExp(endChar + endChar + "?\\s*$") : new RegExp(endChar + "\\s*$");
1992
- return line.replace(endCharRegEx, "");
1993
- }
1994
- /**
1995
- * This method takes in the oldLayout and newLayout data from the FIGfont header file and returns
1996
- * the layout information.
1997
- *
1998
- */
1999
- function getSmushingRules(oldLayout = -1, newLayout = null) {
2000
- let rules = {};
2001
- let val;
2002
- let codes = [
2003
- [
2004
- 16384,
2005
- "vLayout",
2006
- SMUSHING
2007
- ],
2008
- [
2009
- 8192,
2010
- "vLayout",
2011
- FITTING
2012
- ],
2013
- [
2014
- 4096,
2015
- "vRule5",
2016
- true
2017
- ],
2018
- [
2019
- 2048,
2020
- "vRule4",
2021
- true
2022
- ],
2023
- [
2024
- 1024,
2025
- "vRule3",
2026
- true
2027
- ],
2028
- [
2029
- 512,
2030
- "vRule2",
2031
- true
2032
- ],
2033
- [
2034
- 256,
2035
- "vRule1",
2036
- true
2037
- ],
2038
- [
2039
- 128,
2040
- "hLayout",
2041
- SMUSHING
2042
- ],
2043
- [
2044
- 64,
2045
- "hLayout",
2046
- FITTING
2047
- ],
2048
- [
2049
- 32,
2050
- "hRule6",
2051
- true
2052
- ],
2053
- [
2054
- 16,
2055
- "hRule5",
2056
- true
2057
- ],
2058
- [
2059
- 8,
2060
- "hRule4",
2061
- true
2062
- ],
2063
- [
2064
- 4,
2065
- "hRule3",
2066
- true
2067
- ],
2068
- [
2069
- 2,
2070
- "hRule2",
2071
- true
2072
- ],
2073
- [
2074
- 1,
2075
- "hRule1",
2076
- true
2077
- ]
2078
- ];
2079
- val = newLayout !== null ? newLayout : oldLayout;
2080
- for (const [code, rule, value] of codes) if (val >= code) {
2081
- val -= code;
2082
- if (rules[rule] === void 0) rules[rule] = value;
2083
- } else if (rule !== "vLayout" && rule !== "hLayout") rules[rule] = false;
2084
- if (typeof rules["hLayout"] === "undefined") if (oldLayout === 0) rules["hLayout"] = FITTING;
2085
- else if (oldLayout === -1) rules["hLayout"] = FULL_WIDTH;
2086
- else if (rules["hRule1"] || rules["hRule2"] || rules["hRule3"] || rules["hRule4"] || rules["hRule5"] || rules["hRule6"]) rules["hLayout"] = CONTROLLED_SMUSHING;
2087
- else rules["hLayout"] = SMUSHING;
2088
- else if (rules["hLayout"] === SMUSHING) {
2089
- if (rules["hRule1"] || rules["hRule2"] || rules["hRule3"] || rules["hRule4"] || rules["hRule5"] || rules["hRule6"]) rules["hLayout"] = CONTROLLED_SMUSHING;
2090
- }
2091
- if (typeof rules["vLayout"] === "undefined") if (rules["vRule1"] || rules["vRule2"] || rules["vRule3"] || rules["vRule4"] || rules["vRule5"]) rules["vLayout"] = CONTROLLED_SMUSHING;
2092
- else rules["vLayout"] = FULL_WIDTH;
2093
- else if (rules["vLayout"] === SMUSHING) {
2094
- if (rules["vRule1"] || rules["vRule2"] || rules["vRule3"] || rules["vRule4"] || rules["vRule5"]) rules["vLayout"] = CONTROLLED_SMUSHING;
2095
- }
2096
- return rules;
2097
- }
2098
- /**
2099
- * Rule 1: EQUAL CHARACTER SMUSHING (code value 1)
2100
- *
2101
- * Two sub-characters are smushed into a single sub-character
2102
- * if they are the same. This rule does not smush
2103
- * hardblanks. (See rule 6 on hardblanks below)
2104
- */
2105
- function hRule1_Smush(ch1, ch2, hardBlank = "") {
2106
- if (ch1 === ch2 && ch1 !== hardBlank) return ch1;
2107
- return false;
2108
- }
2109
- /**
2110
- * Rule 2: UNDERSCORE SMUSHING (code value 2)
2111
- *
2112
- * An underscore ("_") will be replaced by any of: "|", "/",
2113
- * "\", "[", "]", "{", "}", "(", ")", "<" or ">".
2114
- */
2115
- function hRule2_Smush(ch1, ch2) {
2116
- let rule2Str = "|/\\[]{}()<>";
2117
- if (ch1 === "_") {
2118
- if (rule2Str.indexOf(ch2) !== -1) return ch2;
2119
- } else if (ch2 === "_") {
2120
- if (rule2Str.indexOf(ch1) !== -1) return ch1;
2121
- }
2122
- return false;
2123
- }
2124
- /**
2125
- * Rule 3: HIERARCHY SMUSHING (code value 4)
2126
- *
2127
- * A hierarchy of six classes is used: "|", "/\", "[]", "{}",
2128
- * "()", and "<>". When two smushing sub-characters are
2129
- * from different classes, the one from the latter class
2130
- * will be used.
2131
- */
2132
- function hRule3_Smush(ch1, ch2) {
2133
- let rule3Classes = "| /\\ [] {} () <>";
2134
- let r3_pos1 = rule3Classes.indexOf(ch1);
2135
- let r3_pos2 = rule3Classes.indexOf(ch2);
2136
- if (r3_pos1 !== -1 && r3_pos2 !== -1) {
2137
- if (r3_pos1 !== r3_pos2 && Math.abs(r3_pos1 - r3_pos2) !== 1) {
2138
- const startPos = Math.max(r3_pos1, r3_pos2);
2139
- const endPos = startPos + 1;
2140
- return rule3Classes.substring(startPos, endPos);
2141
- }
2142
- }
2143
- return false;
2144
- }
2145
- /**
2146
- * Rule 4: OPPOSITE PAIR SMUSHING (code value 8)
2147
- *
2148
- * Smushes opposing brackets ("[]" or "]["), braces ("{}" or
2149
- * "}{") and parentheses ("()" or ")(") together, replacing
2150
- * any such pair with a vertical bar ("|").
2151
- */
2152
- function hRule4_Smush(ch1, ch2) {
2153
- let rule4Str = "[] {} ()";
2154
- let r4_pos1 = rule4Str.indexOf(ch1);
2155
- let r4_pos2 = rule4Str.indexOf(ch2);
2156
- if (r4_pos1 !== -1 && r4_pos2 !== -1) {
2157
- if (Math.abs(r4_pos1 - r4_pos2) <= 1) return "|";
2158
- }
2159
- return false;
2160
- }
2161
- /**
2162
- * Rule 5: BIG X SMUSHING (code value 16)
2163
- *
2164
- * Smushes "/\" into "|", "\/" into "Y", and "><" into "X".
2165
- * Note that "<>" is not smushed in any way by this rule.
2166
- * The name "BIG X" is historical; originally all three pairs
2167
- * were smushed into "X".
2168
- */
2169
- function hRule5_Smush(ch1, ch2) {
2170
- return {
2171
- "/\\": "|",
2172
- "\\/": "Y",
2173
- "><": "X"
2174
- }[ch1 + ch2] || false;
2175
- }
2176
- /**
2177
- * Rule 6: HARDBLANK SMUSHING (code value 32)
2178
- *
2179
- * Smushes two hardblanks together, replacing them with a
2180
- * single hardblank. (See "Hardblanks" below.)
2181
- */
2182
- function hRule6_Smush(ch1, ch2, hardBlank = "") {
2183
- if (ch1 === hardBlank && ch2 === hardBlank) return hardBlank;
2184
- return false;
2185
- }
2186
- /**
2187
- * Rule 1: EQUAL CHARACTER SMUSHING (code value 256)
2188
- *
2189
- * Same as horizontal smushing rule 1.
2190
- */
2191
- function vRule1_Smush(ch1, ch2) {
2192
- if (ch1 === ch2) return ch1;
2193
- return false;
2194
- }
2195
- /**
2196
- * Rule 2: UNDERSCORE SMUSHING (code value 512)
2197
- *
2198
- * Same as horizontal smushing rule 2.
2199
- */
2200
- function vRule2_Smush(ch1, ch2) {
2201
- return hRule2_Smush(ch1, ch2);
2202
- }
2203
- /**
2204
- * Rule 3: HIERARCHY SMUSHING (code value 1024)
2205
- *
2206
- * Same as horizontal smushing rule 3.
2207
- */
2208
- function vRule3_Smush(ch1, ch2) {
2209
- return hRule3_Smush(ch1, ch2);
2210
- }
2211
- /**
2212
- * Rule 4: HORIZONTAL LINE SMUSHING (code value 2048)
2213
- *
2214
- * Smushes stacked pairs of "-" and "_", replacing them with
2215
- * a single "=" sub-character. It does not matter which is
2216
- * found above the other. Note that vertical smushing rule 1
2217
- * will smush IDENTICAL pairs of horizontal lines, while this
2218
- * rule smushes horizontal lines consisting of DIFFERENT
2219
- * sub-characters.
2220
- */
2221
- function vRule4_Smush(ch1, ch2) {
2222
- if (ch1 === "-" && ch2 === "_" || ch1 === "_" && ch2 === "-") return "=";
2223
- return false;
2224
- }
2225
- /**
2226
- * Rule 5: VERTICAL LINE SUPERSMUSHING (code value 4096)
2227
- *
2228
- * This one rule is different from all others, in that it
2229
- * "supersmushes" vertical lines consisting of several
2230
- * vertical bars ("|"). This creates the illusion that
2231
- * FIGcharacters have slid vertically against each other.
2232
- * Supersmushing continues until any sub-characters other
2233
- * than "|" would have to be smushed. Supersmushing can
2234
- * produce impressive results, but it is seldom possible,
2235
- * since other sub-characters would usually have to be
2236
- * considered for smushing as soon as any such stacked
2237
- * vertical lines are encountered.
2238
- */
2239
- function vRule5_Smush(ch1, ch2) {
2240
- if (ch1 === "|" && ch2 === "|") return "|";
2241
- return false;
2242
- }
2243
- /**
2244
- * Universal smushing simply overrides the sub-character from the
2245
- * earlier FIGcharacter with the sub-character from the later
2246
- * FIGcharacter. This produces an "overlapping" effect with some
2247
- * FIGfonts, wherin the latter FIGcharacter may appear to be "in
2248
- * front".
2249
- */
2250
- function uni_Smush(ch1, ch2, hardBlank) {
2251
- if (ch2 === " " || ch2 === "") return ch1;
2252
- else if (ch2 === hardBlank && ch1 !== " ") return ch1;
2253
- else return ch2;
2254
- }
2255
- /**
2256
- * This function takes in two lines of text and returns one of the following:
2257
- * "valid" - These liens can be smushed together given the current smushing rules.
2258
- * "end" - The lines can be smushed, but we're at a stopping point.
2259
- * "invalid" - The two liens cannot be smushed together.
2260
- *
2261
- * @param txt1 Line of text from a character
2262
- * @param txt2 Line of text from a character
2263
- * @param opts FIGlet options array
2264
- */
2265
- function canVerticalSmush(txt1, txt2, opts) {
2266
- if (opts.fittingRules && opts.fittingRules.vLayout === FULL_WIDTH) return "invalid";
2267
- let ii, len = Math.min(txt1.length, txt2.length), ch1, ch2, endSmush = false, validSmush;
2268
- if (len === 0) return "invalid";
2269
- for (ii = 0; ii < len; ii++) {
2270
- ch1 = txt1.substring(ii, ii + 1);
2271
- ch2 = txt2.substring(ii, ii + 1);
2272
- if (ch1 !== " " && ch2 !== " ") if (opts.fittingRules && opts.fittingRules.vLayout === FITTING) return "invalid";
2273
- else if (opts.fittingRules && opts.fittingRules.vLayout === SMUSHING) return "end";
2274
- else {
2275
- if (vRule5_Smush(ch1, ch2)) {
2276
- endSmush = endSmush || false;
2277
- continue;
2278
- }
2279
- validSmush = false;
2280
- validSmush = opts.fittingRules && opts.fittingRules.vRule1 ? vRule1_Smush(ch1, ch2) : validSmush;
2281
- validSmush = !validSmush && opts.fittingRules && opts.fittingRules.vRule2 ? vRule2_Smush(ch1, ch2) : validSmush;
2282
- validSmush = !validSmush && opts.fittingRules && opts.fittingRules.vRule3 ? vRule3_Smush(ch1, ch2) : validSmush;
2283
- validSmush = !validSmush && opts.fittingRules && opts.fittingRules.vRule4 ? vRule4_Smush(ch1, ch2) : validSmush;
2284
- endSmush = true;
2285
- if (!validSmush) return "invalid";
2286
- }
2287
- }
2288
- if (endSmush) return "end";
2289
- else return "valid";
2290
- }
2291
- function getVerticalSmushDist(lines1, lines2, opts) {
2292
- let maxDist = lines1.length;
2293
- let len1 = lines1.length;
2294
- let subLines1, subLines2, slen;
2295
- let curDist = 1;
2296
- let ii, ret, result;
2297
- while (curDist <= maxDist) {
2298
- subLines1 = lines1.slice(Math.max(0, len1 - curDist), len1);
2299
- subLines2 = lines2.slice(0, Math.min(maxDist, curDist));
2300
- slen = subLines2.length;
2301
- result = "";
2302
- for (ii = 0; ii < slen; ii++) {
2303
- ret = canVerticalSmush(subLines1[ii], subLines2[ii], opts);
2304
- if (ret === "end") result = ret;
2305
- else if (ret === "invalid") {
2306
- result = ret;
2307
- break;
2308
- } else if (result === "") result = "valid";
2309
- }
2310
- if (result === "invalid") {
2311
- curDist--;
2312
- break;
2313
- }
2314
- if (result === "end") break;
2315
- if (result === "valid") curDist++;
2316
- }
2317
- return Math.min(maxDist, curDist);
2318
- }
2319
- function verticallySmushLines(line1, line2, opts) {
2320
- let ii, len = Math.min(line1.length, line2.length);
2321
- let ch1, ch2, result = "", validSmush;
2322
- const fittingRules = opts.fittingRules || {};
2323
- for (ii = 0; ii < len; ii++) {
2324
- ch1 = line1.substring(ii, ii + 1);
2325
- ch2 = line2.substring(ii, ii + 1);
2326
- if (ch1 !== " " && ch2 !== " ") if (fittingRules.vLayout === FITTING) result += uni_Smush(ch1, ch2);
2327
- else if (fittingRules.vLayout === SMUSHING) result += uni_Smush(ch1, ch2);
2328
- else {
2329
- validSmush = false;
2330
- validSmush = fittingRules.vRule5 ? vRule5_Smush(ch1, ch2) : validSmush;
2331
- validSmush = !validSmush && fittingRules.vRule1 ? vRule1_Smush(ch1, ch2) : validSmush;
2332
- validSmush = !validSmush && fittingRules.vRule2 ? vRule2_Smush(ch1, ch2) : validSmush;
2333
- validSmush = !validSmush && fittingRules.vRule3 ? vRule3_Smush(ch1, ch2) : validSmush;
2334
- validSmush = !validSmush && fittingRules.vRule4 ? vRule4_Smush(ch1, ch2) : validSmush;
2335
- result += validSmush;
2336
- }
2337
- else result += uni_Smush(ch1, ch2);
2338
- }
2339
- return result;
2340
- }
2341
- function verticalSmush(lines1, lines2, overlap, opts) {
2342
- let len1 = lines1.length;
2343
- let len2 = lines2.length;
2344
- let piece1 = lines1.slice(0, Math.max(0, len1 - overlap));
2345
- let piece2_1 = lines1.slice(Math.max(0, len1 - overlap), len1);
2346
- let piece2_2 = lines2.slice(0, Math.min(overlap, len2));
2347
- let ii, len, line, piece2 = [], piece3;
2348
- len = piece2_1.length;
2349
- for (ii = 0; ii < len; ii++) {
2350
- if (ii >= len2) line = piece2_1[ii];
2351
- else line = verticallySmushLines(piece2_1[ii], piece2_2[ii], opts);
2352
- piece2.push(line);
2353
- }
2354
- piece3 = lines2.slice(Math.min(overlap, len2), len2);
2355
- return [
2356
- ...piece1,
2357
- ...piece2,
2358
- ...piece3
2359
- ];
2360
- }
2361
- function padLines(lines, numSpaces) {
2362
- const padding = " ".repeat(numSpaces);
2363
- return lines.map((line) => line + padding);
2364
- }
2365
- function smushVerticalFigLines(output, lines, opts) {
2366
- let len1 = output[0].length;
2367
- let len2 = lines[0].length;
2368
- let overlap;
2369
- if (len1 > len2) lines = padLines(lines, len1 - len2);
2370
- else if (len2 > len1) output = padLines(output, len2 - len1);
2371
- overlap = getVerticalSmushDist(output, lines, opts);
2372
- return verticalSmush(output, lines, overlap, opts);
2373
- }
2374
- function getHorizontalSmushLength(txt1, txt2, opts) {
2375
- const fittingRules = opts.fittingRules || {};
2376
- if (fittingRules.hLayout === FULL_WIDTH) return 0;
2377
- let ii, len1 = txt1.length, len2 = txt2.length;
2378
- let maxDist = len1;
2379
- let curDist = 1;
2380
- let breakAfter = false;
2381
- let seg1, seg2, ch1, ch2;
2382
- if (len1 === 0) return 0;
2383
- distCal: while (curDist <= maxDist) {
2384
- const seg1StartPos = len1 - curDist;
2385
- seg1 = txt1.substring(seg1StartPos, seg1StartPos + curDist);
2386
- seg2 = txt2.substring(0, Math.min(curDist, len2));
2387
- for (ii = 0; ii < Math.min(curDist, len2); ii++) {
2388
- ch1 = seg1.substring(ii, ii + 1);
2389
- ch2 = seg2.substring(ii, ii + 1);
2390
- if (ch1 !== " " && ch2 !== " ") if (fittingRules.hLayout === FITTING) {
2391
- curDist = curDist - 1;
2392
- break distCal;
2393
- } else if (fittingRules.hLayout === SMUSHING) {
2394
- if (ch1 === opts.hardBlank || ch2 === opts.hardBlank) curDist = curDist - 1;
2395
- break distCal;
2396
- } else {
2397
- breakAfter = true;
2398
- if (!(fittingRules.hRule1 && hRule1_Smush(ch1, ch2, opts.hardBlank) || fittingRules.hRule2 && hRule2_Smush(ch1, ch2) || fittingRules.hRule3 && hRule3_Smush(ch1, ch2) || fittingRules.hRule4 && hRule4_Smush(ch1, ch2) || fittingRules.hRule5 && hRule5_Smush(ch1, ch2) || fittingRules.hRule6 && hRule6_Smush(ch1, ch2, opts.hardBlank))) {
2399
- curDist = curDist - 1;
2400
- break distCal;
2401
- }
2402
- }
2403
- }
2404
- if (breakAfter) break;
2405
- curDist++;
2406
- }
2407
- return Math.min(maxDist, curDist);
2408
- }
2409
- function horizontalSmush(textBlock1, textBlock2, overlap, opts) {
2410
- let ii, jj, outputFig = [], overlapStart, piece1, piece2, piece3, len1, len2, txt1, txt2;
2411
- const fittingRules = opts.fittingRules || {};
2412
- if (typeof opts.height !== "number") throw new Error("height is not defined.");
2413
- for (ii = 0; ii < opts.height; ii++) {
2414
- txt1 = textBlock1[ii];
2415
- txt2 = textBlock2[ii];
2416
- len1 = txt1.length;
2417
- len2 = txt2.length;
2418
- overlapStart = len1 - overlap;
2419
- piece1 = txt1.slice(0, Math.max(0, overlapStart));
2420
- piece2 = "";
2421
- const seg1StartPos = Math.max(0, len1 - overlap);
2422
- let seg1 = txt1.substring(seg1StartPos, seg1StartPos + overlap);
2423
- let seg2 = txt2.substring(0, Math.min(overlap, len2));
2424
- for (jj = 0; jj < overlap; jj++) {
2425
- let ch1 = jj < len1 ? seg1.substring(jj, jj + 1) : " ";
2426
- let ch2 = jj < len2 ? seg2.substring(jj, jj + 1) : " ";
2427
- if (ch1 !== " " && ch2 !== " ") if (fittingRules.hLayout === FITTING || fittingRules.hLayout === SMUSHING) piece2 += uni_Smush(ch1, ch2, opts.hardBlank);
2428
- else {
2429
- const nextCh = fittingRules.hRule1 && hRule1_Smush(ch1, ch2, opts.hardBlank) || fittingRules.hRule2 && hRule2_Smush(ch1, ch2) || fittingRules.hRule3 && hRule3_Smush(ch1, ch2) || fittingRules.hRule4 && hRule4_Smush(ch1, ch2) || fittingRules.hRule5 && hRule5_Smush(ch1, ch2) || fittingRules.hRule6 && hRule6_Smush(ch1, ch2, opts.hardBlank) || uni_Smush(ch1, ch2, opts.hardBlank);
2430
- piece2 += nextCh;
2431
- }
2432
- else piece2 += uni_Smush(ch1, ch2, opts.hardBlank);
2433
- }
2434
- if (overlap >= len2) piece3 = "";
2435
- else piece3 = txt2.substring(overlap, overlap + Math.max(0, len2 - overlap));
2436
- outputFig[ii] = piece1 + piece2 + piece3;
2437
- }
2438
- return outputFig;
2439
- }
2440
- /**
2441
- * Creates new empty ASCII placeholder of given length
2442
- *
2443
- * @param len
2444
- */
2445
- function newFigChar(len) {
2446
- return new Array(len).fill("");
2447
- }
2448
- /**
2449
- * Return max line of the ASCII Art
2450
- *
2451
- * @param textLines Lines for the text
2452
- */
2453
- const figLinesWidth = function(textLines) {
2454
- return Math.max(...textLines.map((line) => line.length));
2455
- };
2456
- /**
2457
- * Join words or single characters into a single Fig line
2458
- *
2459
- * @param array Array of ASCII words or single character: {fig: array, overlap: number}
2460
- * @param len Height of the characters (number of rows)
2461
- * @param opts
2462
- */
2463
- function joinFigArray(array, len, opts) {
2464
- return array.reduce(function(acc, data) {
2465
- return horizontalSmush(acc, data.fig, data.overlap || 0, opts);
2466
- }, newFigChar(len));
2467
- }
2468
- /**
2469
- * Break long words, return leftover characters and line before the break
2470
- *
2471
- * @param figChars List of single ASCII characters in form {fig, overlap}
2472
- * @param len
2473
- * @param opts
2474
- */
2475
- function breakWord(figChars, len, opts) {
2476
- for (let i = figChars.length - 1; i > 0; i--) {
2477
- const w = joinFigArray(figChars.slice(0, i), len, opts);
2478
- if (figLinesWidth(w) <= opts.width) return {
2479
- outputFigText: w,
2480
- chars: figChars.slice(i)
2481
- };
2482
- }
2483
- if (figChars.length > 0) return {
2484
- outputFigText: joinFigArray([figChars[0]], len, opts),
2485
- chars: figChars.slice(1)
2486
- };
2487
- return {
2488
- outputFigText: newFigChar(len),
2489
- chars: figChars
2490
- };
2491
- }
2492
- function generateFigTextLines(txt, figChars, opts) {
2493
- let charIndex, figChar, overlap = 0, row, outputFigText, len, height = opts.height, outputFigLines = [], maxWidth, nextFigChars = {
2494
- chars: [],
2495
- overlap
2496
- }, figWords = [], char, isSpace, textFigWord, textFigLine, tmpBreak;
2497
- if (typeof height !== "number") throw new Error("height is not defined.");
2498
- outputFigText = newFigChar(height);
2499
- const fittingRules = opts.fittingRules || {};
2500
- const txtChars = [...txt];
2501
- if (opts.printDirection === 1) txtChars.reverse();
2502
- len = txtChars.length;
2503
- for (charIndex = 0; charIndex < len; charIndex++) {
2504
- char = txtChars[charIndex];
2505
- isSpace = char.match(/\s/);
2506
- figChar = figChars[char.codePointAt(0)] ?? figChars[0];
2507
- textFigLine = null;
2508
- if (figChar) {
2509
- if (fittingRules.hLayout !== FULL_WIDTH) {
2510
- overlap = 1e4;
2511
- for (row = 0; row < height; row++) overlap = Math.min(overlap, getHorizontalSmushLength(outputFigText[row], figChar[row], opts));
2512
- overlap = overlap === 1e4 ? 0 : overlap;
2513
- }
2514
- if (opts.width > 0) {
2515
- if (opts.whitespaceBreak) {
2516
- textFigWord = joinFigArray(nextFigChars.chars.concat([{
2517
- fig: figChar,
2518
- overlap
2519
- }]), height, opts);
2520
- textFigLine = joinFigArray(figWords.concat([{
2521
- fig: textFigWord,
2522
- overlap: nextFigChars.overlap
2523
- }]), height, opts);
2524
- maxWidth = figLinesWidth(textFigLine);
2525
- } else {
2526
- textFigLine = horizontalSmush(outputFigText, figChar, overlap, opts);
2527
- maxWidth = figLinesWidth(textFigLine);
2528
- }
2529
- if (maxWidth >= opts.width && charIndex > 0) if (opts.whitespaceBreak) {
2530
- outputFigText = joinFigArray(figWords.slice(0, -1), height, opts);
2531
- if (figWords.length > 1) {
2532
- outputFigLines.push(outputFigText);
2533
- outputFigText = newFigChar(height);
2534
- }
2535
- figWords = [];
2536
- } else {
2537
- outputFigLines.push(outputFigText);
2538
- outputFigText = newFigChar(height);
2539
- }
2540
- }
2541
- if (opts.width > 0 && opts.whitespaceBreak) {
2542
- if (!isSpace || charIndex === len - 1) nextFigChars.chars.push({
2543
- fig: figChar,
2544
- overlap
2545
- });
2546
- if (isSpace || charIndex === len - 1) {
2547
- tmpBreak = null;
2548
- while (true) {
2549
- textFigLine = joinFigArray(nextFigChars.chars, height, opts);
2550
- maxWidth = figLinesWidth(textFigLine);
2551
- if (maxWidth >= opts.width) {
2552
- tmpBreak = breakWord(nextFigChars.chars, height, opts);
2553
- nextFigChars = { chars: tmpBreak.chars };
2554
- outputFigLines.push(tmpBreak.outputFigText);
2555
- } else break;
2556
- }
2557
- if (maxWidth > 0) if (tmpBreak) figWords.push({
2558
- fig: textFigLine,
2559
- overlap: 1
2560
- });
2561
- else figWords.push({
2562
- fig: textFigLine,
2563
- overlap: nextFigChars.overlap
2564
- });
2565
- if (isSpace) {
2566
- figWords.push({
2567
- fig: figChar,
2568
- overlap
2569
- });
2570
- outputFigText = newFigChar(height);
2571
- }
2572
- if (charIndex === len - 1) outputFigText = joinFigArray(figWords, height, opts);
2573
- nextFigChars = {
2574
- chars: [],
2575
- overlap
2576
- };
2577
- continue;
2578
- }
2579
- }
2580
- outputFigText = horizontalSmush(outputFigText, figChar, overlap, opts);
2581
- }
2582
- }
2583
- if (figLinesWidth(outputFigText) > 0) outputFigLines.push(outputFigText);
2584
- if (!opts.showHardBlanks) outputFigLines.forEach(function(outputFigText) {
2585
- len = outputFigText.length;
2586
- for (row = 0; row < len; row++) outputFigText[row] = outputFigText[row].replace(new RegExp("\\" + opts.hardBlank, "g"), " ");
2587
- });
2588
- if (txt === "" && outputFigLines.length === 0) outputFigLines.push(new Array(height).fill(""));
2589
- return outputFigLines;
2590
- }
2591
- const getHorizontalFittingRules = function(layout, options) {
2592
- let params;
2593
- const fittingRules = options.fittingRules || {};
2594
- if (layout === "default") params = {
2595
- hLayout: fittingRules.hLayout,
2596
- hRule1: fittingRules.hRule1,
2597
- hRule2: fittingRules.hRule2,
2598
- hRule3: fittingRules.hRule3,
2599
- hRule4: fittingRules.hRule4,
2600
- hRule5: fittingRules.hRule5,
2601
- hRule6: fittingRules.hRule6
2602
- };
2603
- else if (layout === "full") params = {
2604
- hLayout: FULL_WIDTH,
2605
- hRule1: false,
2606
- hRule2: false,
2607
- hRule3: false,
2608
- hRule4: false,
2609
- hRule5: false,
2610
- hRule6: false
2611
- };
2612
- else if (layout === "fitted") params = {
2613
- hLayout: FITTING,
2614
- hRule1: false,
2615
- hRule2: false,
2616
- hRule3: false,
2617
- hRule4: false,
2618
- hRule5: false,
2619
- hRule6: false
2620
- };
2621
- else if (layout === "controlled smushing") params = {
2622
- hLayout: CONTROLLED_SMUSHING,
2623
- hRule1: true,
2624
- hRule2: true,
2625
- hRule3: true,
2626
- hRule4: true,
2627
- hRule5: true,
2628
- hRule6: true
2629
- };
2630
- else if (layout === "universal smushing") params = {
2631
- hLayout: SMUSHING,
2632
- hRule1: false,
2633
- hRule2: false,
2634
- hRule3: false,
2635
- hRule4: false,
2636
- hRule5: false,
2637
- hRule6: false
2638
- };
2639
- else return;
2640
- return params;
2641
- };
2642
- const getVerticalFittingRules = function(layout, options) {
2643
- let params = {};
2644
- const fittingRules = options.fittingRules || {};
2645
- if (layout === "default") params = {
2646
- vLayout: fittingRules.vLayout,
2647
- vRule1: fittingRules.vRule1,
2648
- vRule2: fittingRules.vRule2,
2649
- vRule3: fittingRules.vRule3,
2650
- vRule4: fittingRules.vRule4,
2651
- vRule5: fittingRules.vRule5
2652
- };
2653
- else if (layout === "full") params = {
2654
- vLayout: FULL_WIDTH,
2655
- vRule1: false,
2656
- vRule2: false,
2657
- vRule3: false,
2658
- vRule4: false,
2659
- vRule5: false
2660
- };
2661
- else if (layout === "fitted") params = {
2662
- vLayout: FITTING,
2663
- vRule1: false,
2664
- vRule2: false,
2665
- vRule3: false,
2666
- vRule4: false,
2667
- vRule5: false
2668
- };
2669
- else if (layout === "controlled smushing") params = {
2670
- vLayout: CONTROLLED_SMUSHING,
2671
- vRule1: true,
2672
- vRule2: true,
2673
- vRule3: true,
2674
- vRule4: true,
2675
- vRule5: true
2676
- };
2677
- else if (layout === "universal smushing") params = {
2678
- vLayout: SMUSHING,
2679
- vRule1: false,
2680
- vRule2: false,
2681
- vRule3: false,
2682
- vRule4: false,
2683
- vRule5: false
2684
- };
2685
- else return;
2686
- return params;
2687
- };
2688
- /**
2689
- * Generates the ASCII Art
2690
- *
2691
- * @param fontName Font to use
2692
- * @param options Options to override the defaults
2693
- * @param txt The text to make into ASCII Art
2694
- */
2695
- const generateText = function(fontName, options, txt) {
2696
- txt = txt.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
2697
- const actualFontName = getFontName(fontName);
2698
- let lines = txt.split("\n");
2699
- let figLines = [];
2700
- let ii, len, output;
2701
- len = lines.length;
2702
- for (ii = 0; ii < len; ii++) figLines = figLines.concat(generateFigTextLines(lines[ii], figFonts[actualFontName], options));
2703
- len = figLines.length;
2704
- output = figLines[0];
2705
- for (ii = 1; ii < len; ii++) output = smushVerticalFigLines(output, figLines[ii], options);
2706
- return output ? output.join("\n") : "";
2707
- };
2708
- function _reworkFontOpts(fontMeta, options) {
2709
- let myOpts;
2710
- if (typeof structuredClone !== "undefined") myOpts = structuredClone(fontMeta);
2711
- else myOpts = JSON.parse(JSON.stringify(fontMeta));
2712
- myOpts.showHardBlanks = options.showHardBlanks || false;
2713
- myOpts.width = options.width || -1;
2714
- myOpts.whitespaceBreak = options.whitespaceBreak || false;
2715
- if (options.horizontalLayout) {
2716
- const params = getHorizontalFittingRules(options.horizontalLayout, fontMeta);
2717
- if (params) Object.assign(myOpts.fittingRules, params);
2718
- }
2719
- if (options.verticalLayout) {
2720
- const params = getVerticalFittingRules(options.verticalLayout, fontMeta);
2721
- if (params) Object.assign(myOpts.fittingRules, params);
2722
- }
2723
- myOpts.printDirection = options.printDirection !== null && options.printDirection !== void 0 ? options.printDirection : fontMeta.printDirection;
2724
- return myOpts;
2725
- }
2726
- /**
2727
- * A short-cut for the figlet.text method
2728
- *
2729
- * @param txt The text to make into ASCII Art.
2730
- * @param optionsOrFontOrCallback Options that will override the current font's default options / a font name to use / the callback function
2731
- * @param callback A callback function, it will contain the outputted ASCII Art.
2732
- */
2733
- const me = async function(txt, optionsOrFontOrCallback, callback) {
2734
- return me.text(txt, optionsOrFontOrCallback, callback);
2735
- };
2736
- me.text = async function(txt, optionsOrFontOrCallback, callback) {
2737
- txt = txt + "";
2738
- let options, next;
2739
- if (typeof optionsOrFontOrCallback === "function") {
2740
- next = optionsOrFontOrCallback;
2741
- options = { font: figDefaults.font };
2742
- } else if (typeof optionsOrFontOrCallback === "string") {
2743
- options = { font: optionsOrFontOrCallback };
2744
- next = callback;
2745
- } else if (optionsOrFontOrCallback) {
2746
- options = optionsOrFontOrCallback;
2747
- next = callback;
2748
- } else {
2749
- options = { font: figDefaults.font };
2750
- next = callback;
2751
- }
2752
- const fontName = options.font || figDefaults.font;
2753
- try {
2754
- const fontOpts = await me.loadFont(fontName);
2755
- const generatedTxt = fontOpts ? generateText(fontName, _reworkFontOpts(fontOpts, options), txt) : "";
2756
- if (next) next(null, generatedTxt);
2757
- return generatedTxt;
2758
- } catch (err) {
2759
- const error = err instanceof Error ? err : new Error(String(err));
2760
- if (next) {
2761
- next(error);
2762
- return "";
2763
- }
2764
- throw error;
2765
- }
2766
- };
2767
- /**
2768
- * Synchronous version of figlet.text
2769
- * Accepts the same parameters (sans the callback).
2770
- *
2771
- * @param txt
2772
- * @param options
2773
- */
2774
- me.textSync = function(txt, options) {
2775
- txt = txt + "";
2776
- if (typeof options === "string") options = { font: options };
2777
- else options = options || {};
2778
- const fontName = options.font || figDefaults.font;
2779
- let fontOpts = _reworkFontOpts(me.loadFontSync(fontName), options);
2780
- return generateText(fontName, fontOpts, txt);
2781
- };
2782
- /**
2783
- * Returns metadata about a specific FIGlet font.
2784
- *
2785
- * @param fontName
2786
- * @param callback
2787
- */
2788
- me.metadata = async function(fontName, callback) {
2789
- fontName = fontName + "";
2790
- try {
2791
- const fontOpts = await me.loadFont(fontName);
2792
- if (!fontOpts) throw new Error("Error loading font.");
2793
- const actualFontName = getFontName(fontName);
2794
- const font = figFonts[actualFontName] || {};
2795
- const result = [fontOpts, font.comment || ""];
2796
- if (callback) callback(null, fontOpts, font.comment);
2797
- return result;
2798
- } catch (err) {
2799
- const error = err instanceof Error ? err : new Error(String(err));
2800
- if (callback) {
2801
- callback(error);
2802
- return null;
2803
- }
2804
- throw error;
2805
- }
2806
- };
2807
- /**
2808
- * Allows you to override the defaults. See the definition of the figDefaults object up above
2809
- * to see what properties can be overridden.
2810
- * Returns the options for the font.
2811
- *
2812
- * @param opts
2813
- */
2814
- me.defaults = function(opts) {
2815
- if (opts && typeof opts === "object") Object.assign(figDefaults, opts);
2816
- if (typeof structuredClone !== "undefined") return structuredClone(figDefaults);
2817
- else return JSON.parse(JSON.stringify(figDefaults));
2818
- };
2819
- /**
2820
- * Parses data from a FIGlet font file and places it into the figFonts object.
2821
- *
2822
- * @param fontName
2823
- * @param data
2824
- * @param override
2825
- */
2826
- me.parseFont = function(fontName, data, override = true) {
2827
- if (figFonts[fontName] && !override) return figFonts[fontName].options;
2828
- data = data.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
2829
- const font = new FigletFont();
2830
- const lines = data.split("\n");
2831
- const headerLine = lines.shift();
2832
- if (!headerLine) throw new Error("Invalid font file: missing header");
2833
- const headerData = headerLine.split(" ");
2834
- const opts = {
2835
- hardBlank: headerData[0].substring(5, 6),
2836
- height: parseInt(headerData[1], 10),
2837
- baseline: parseInt(headerData[2], 10),
2838
- maxLength: parseInt(headerData[3], 10),
2839
- oldLayout: parseInt(headerData[4], 10),
2840
- numCommentLines: parseInt(headerData[5], 10),
2841
- printDirection: headerData[6] ? parseInt(headerData[6], 10) : 0,
2842
- fullLayout: headerData[7] ? parseInt(headerData[7], 10) : null,
2843
- codeTagCount: headerData[8] ? parseInt(headerData[8], 10) : null
2844
- };
2845
- if ((opts.hardBlank || "").length !== 1 || [
2846
- opts.height,
2847
- opts.baseline,
2848
- opts.maxLength,
2849
- opts.oldLayout,
2850
- opts.numCommentLines
2851
- ].some((val) => val === null || val === void 0 || isNaN(val))) throw new Error("FIGlet header contains invalid values.");
2852
- if (opts.height == null || opts.numCommentLines == null) throw new Error("FIGlet header contains invalid values.");
2853
- if (opts.height < 1 || opts.baseline < 0 || opts.maxLength < 0 || opts.numCommentLines < 0) throw new Error("FIGlet header contains invalid values.");
2854
- opts.fittingRules = getSmushingRules(opts.oldLayout, opts.fullLayout);
2855
- font.options = opts;
2856
- const charNums = [];
2857
- for (let i = 32; i <= 126; i++) charNums.push(i);
2858
- charNums.push(196, 214, 220, 228, 246, 252, 223);
2859
- if (lines.length < opts.numCommentLines + opts.height * charNums.length) throw new Error(`FIGlet file is missing data. Line length: ${lines.length}. Comment lines: ${opts.numCommentLines}. Height: ${opts.height}. Num chars: ${charNums.length}.`);
2860
- font.comment = lines.splice(0, opts.numCommentLines).join("\n");
2861
- font.numChars = 0;
2862
- while (lines.length > 0 && font.numChars < charNums.length) {
2863
- const cNum = charNums[font.numChars];
2864
- font[cNum] = lines.splice(0, opts.height);
2865
- for (let i = 0; i < opts.height; i++) if (typeof font[cNum][i] === "undefined") font[cNum][i] = "";
2866
- else font[cNum][i] = removeEndChar(font[cNum][i], i, opts.height);
2867
- font.numChars++;
2868
- }
2869
- while (lines.length > 0) {
2870
- const cNumLine = lines.shift();
2871
- if (!cNumLine || cNumLine.trim() === "") break;
2872
- let cNum = cNumLine.split(" ")[0];
2873
- let parsedNum;
2874
- if (/^-?0[xX][0-9a-fA-F]+$/.test(cNum)) parsedNum = parseInt(cNum, 16);
2875
- else if (/^-?0[0-7]+$/.test(cNum)) parsedNum = parseInt(cNum, 8);
2876
- else if (/^-?[0-9]+$/.test(cNum)) parsedNum = parseInt(cNum, 10);
2877
- else throw new Error(`Error parsing data. Invalid data: ${cNum}`);
2878
- if (parsedNum === -1 || parsedNum < -2147483648 || parsedNum > 2147483647) throw new Error(`Error parsing data. ${parsedNum === -1 ? "The char code -1 is not permitted." : `The char code cannot be ${parsedNum < -2147483648 ? "less than -2147483648" : "greater than 2147483647"}.`}`);
2879
- font[parsedNum] = lines.splice(0, opts.height);
2880
- for (let i = 0; i < opts.height; i++) if (typeof font[parsedNum][i] === "undefined") font[parsedNum][i] = "";
2881
- else font[parsedNum][i] = removeEndChar(font[parsedNum][i], i, opts.height);
2882
- font.numChars++;
2883
- }
2884
- figFonts[fontName] = font;
2885
- return opts;
2886
- };
2887
- /**
2888
- * Returns an array of the fonts that have been parsed and loaded
2889
- */
2890
- me.loadedFonts = () => {
2891
- return Object.keys(figFonts);
2892
- };
2893
- /**
2894
- * Remove all fonts that have been loaded
2895
- */
2896
- me.clearLoadedFonts = () => {
2897
- Object.keys(figFonts).forEach((key) => {
2898
- delete figFonts[key];
2899
- });
2900
- };
2901
- /**
2902
- * Loads a font.
2903
- *
2904
- * @param fontName
2905
- * @param callback
2906
- */
2907
- me.loadFont = async function(fontName, callback) {
2908
- const actualFontName = getFontName(fontName);
2909
- if (figFonts[actualFontName]) {
2910
- const result = figFonts[actualFontName].options;
2911
- if (callback) callback(null, result);
2912
- return Promise.resolve(result);
2913
- }
2914
- try {
2915
- if (!figDefaults.fetchFontIfMissing) throw new Error(`Font is not loaded: ${actualFontName}`);
2916
- const response = await fetch(`${figDefaults.fontPath}/${actualFontName}.flf`);
2917
- if (!response.ok) throw new Error(`Network response was not ok: ${response.status}`);
2918
- const text = await response.text();
2919
- const result = me.parseFont(actualFontName, text);
2920
- if (callback) callback(null, result);
2921
- return result;
2922
- } catch (error) {
2923
- const err = error instanceof Error ? error : new Error(String(error));
2924
- if (callback) {
2925
- callback(err);
2926
- return null;
2927
- }
2928
- throw err;
2929
- }
2930
- };
2931
- /**
2932
- * Loads a font synchronously
2933
- *
2934
- * @param name
2935
- */
2936
- me.loadFontSync = function(name) {
2937
- const actualFontName = getFontName(name);
2938
- if (figFonts[actualFontName]) return figFonts[actualFontName].options;
2939
- throw new Error("Synchronous font loading is not implemented for the browser, it will only work for fonts already loaded.");
2940
- };
2941
- /**
2942
- * Preloads a list of fonts prior to using textSync
2943
- *
2944
- * @param fonts An array of font names (ex: ["Standard", "Soft"])
2945
- * @param callback Callback
2946
- */
2947
- me.preloadFonts = async function(fonts, callback) {
2948
- try {
2949
- for (const name of fonts) {
2950
- const actualFontName = getFontName(name);
2951
- const response = await fetch(`${figDefaults.fontPath}/${actualFontName}.flf`);
2952
- if (!response.ok) throw new Error(`Failed to preload fonts. Error fetching font: ${actualFontName}, status code: ${response.statusText}`);
2953
- const data = await response.text();
2954
- me.parseFont(actualFontName, data);
2955
- }
2956
- if (callback) callback();
2957
- } catch (error) {
2958
- const err = error instanceof Error ? error : new Error(String(error));
2959
- if (callback) {
2960
- callback(err);
2961
- return;
2962
- }
2963
- throw error;
2964
- }
2965
- };
2966
- /**
2967
- * Retrieves a list of the fonts.
2968
- *
2969
- * @param callback
2970
- */
2971
- me.fonts = function(callback) {
2972
- return new Promise(function(resolve, reject) {
2973
- resolve(fontList);
2974
- if (callback) callback(null, fontList);
2975
- });
2976
- };
2977
- /**
2978
- * Retrieves a list of the fonts.
2979
- */
2980
- me.fontsSync = function() {
2981
- return fontList;
2982
- };
2983
- me.figFonts = figFonts;
2984
- return me;
2985
- })();
2986
-
2987
- //#region src/node-figlet.ts
2988
- var moduleDirname = typeof import.meta !== "undefined" && import.meta.url ? path.dirname(fileURLToPath(import.meta.url)) : __dirname;
2989
- var fontPath = path.join(moduleDirname, "/../fonts/");
2990
- var nodeFiglet = figlet;
2991
- nodeFiglet.defaults({ fontPath });
2992
- nodeFiglet.loadFont = function(name, callback) {
2993
- const actualFontName = getFontName(name);
2994
- return new Promise((resolve, reject) => {
2995
- if (nodeFiglet.figFonts[actualFontName]) {
2996
- if (callback) callback(null, nodeFiglet.figFonts[actualFontName].options);
2997
- resolve(nodeFiglet.figFonts[actualFontName].options);
2998
- return;
2999
- }
3000
- fs.readFile(path.join(nodeFiglet.defaults().fontPath, actualFontName + ".flf"), { encoding: "utf-8" }, (err, fontData) => {
3001
- if (err) {
3002
- if (callback) callback(err);
3003
- reject(err);
3004
- return;
3005
- }
3006
- fontData = fontData + "";
3007
- try {
3008
- const font = nodeFiglet.parseFont(actualFontName, fontData);
3009
- if (callback) callback(null, font);
3010
- resolve(font);
3011
- } catch (error) {
3012
- const typedError = error instanceof Error ? error : new Error(String(error));
3013
- if (callback) callback(typedError);
3014
- reject(typedError);
3015
- }
3016
- });
3017
- });
3018
- };
3019
- nodeFiglet.loadFontSync = function(font) {
3020
- const actualFontName = getFontName(font);
3021
- if (nodeFiglet.figFonts[actualFontName]) return nodeFiglet.figFonts[actualFontName].options;
3022
- const fontData = fs.readFileSync(path.join(nodeFiglet.defaults().fontPath, actualFontName + ".flf"), { encoding: "utf-8" }) + "";
3023
- return nodeFiglet.parseFont(actualFontName, fontData);
3024
- };
3025
- nodeFiglet.fonts = function(next) {
3026
- return new Promise((resolve, reject) => {
3027
- const fontList = [];
3028
- fs.readdir(nodeFiglet.defaults().fontPath, (err, files) => {
3029
- if (err) {
3030
- next && next(err);
3031
- reject(err);
3032
- return;
3033
- }
3034
- files.forEach((file) => {
3035
- if (/\.flf$/.test(file)) fontList.push(file.replace(/\.flf$/, ""));
3036
- });
3037
- next && next(null, fontList);
3038
- resolve(fontList);
3039
- });
3040
- });
3041
- };
3042
- nodeFiglet.fontsSync = function() {
3043
- const fontList = [];
3044
- fs.readdirSync(nodeFiglet.defaults().fontPath).forEach((file) => {
3045
- if (/\.flf$/.test(file)) fontList.push(file.replace(/\.flf$/, ""));
3046
- });
3047
- return fontList;
3048
- };
2
+ import { join, dirname, basename, relative, sep, posix, resolve as resolve$1 } from 'node:path';
3
+ import { parseArgs } from 'node:util';
4
+ import { existsSync, readFileSync, rmSync, mkdirSync, writeFileSync, renameSync, readdirSync } from 'node:fs';
5
+ import { fileURLToPath } from 'node:url';
6
+ import { createHash } from 'node:crypto';
7
+ import g from 'node:process';
3049
8
 
3050
9
  /*---------------------------------------------------------------------------------------------
3051
10
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4503,61 +1462,27 @@ function applyEdits(text, edits) {
4503
1462
  return text;
4504
1463
  }
4505
1464
 
4506
- const LogLevelMap = {
4507
- silent: Number.NEGATIVE_INFINITY,
4508
- error: 0,
4509
- warning: 1,
4510
- normal: 2,
4511
- default: 3,
4512
- debug: 4,
4513
- trace: 5,
4514
- verbose: Number.POSITIVE_INFINITY
4515
- };
4516
- function createLogger(options) {
4517
- const consola = createConsola({
4518
- ...options,
4519
- level: LogLevelMap.default
4520
- });
4521
- return {
4522
- start: (message, ...args) => consola.start(message, ...args),
4523
- log: (message, ...args) => consola.log(message, ...args),
4524
- warn: (message, ...args) => consola.warn(message, ...args),
4525
- error: (message, ...args) => consola.error(message, ...args),
4526
- box: (message, ...args) => consola.box(message, ...args),
4527
- fail: (message, ...args) => consola.fail(message, ...args),
4528
- success: (message, ...args) => consola.success(message, ...args),
4529
- info: (message, ...args) => consola.info(message, ...args),
4530
- debug: (message, ...args) => consola.debug(message, ...args),
4531
- trace: (message, ...args) => consola.trace(message, ...args),
4532
- verbose: (message, ...args) => consola.verbose(message, ...args),
4533
- fatal: (message, ...args) => consola.fatal(message, ...args),
4534
- ready: (message, ...args) => consola.ready(message, ...args),
4535
- silent: (message, ...args) => consola.silent(message, ...args),
4536
- divider: (character = "=") => console.log(character.repeat(g$1.stdout.columns || 20)),
4537
- eot: () => console.log(),
4538
- break: (count = 1) => {
4539
- for (let i = 0; i < count; i++) {
4540
- console.log("");
4541
- }
4542
- },
4543
- brand: (message) => console.log(blueBright(message)),
4544
- clear: () => console.clear(),
4545
- addReporter: (reporter) => consola.addReporter(reporter),
4546
- removeReporter: (reporter) => consola.removeReporter(reporter),
4547
- setLevel: (level) => {
4548
- consola.level = LogLevelMap[level];
4549
- },
4550
- getLevel: () => consola.level
4551
- };
4552
- }
4553
- createLogger();
4554
- const AGENT_TARGETS = ["claude", "agents-md", "cursor", "vscode"];
1465
+ const AGENT_TARGETS = [
1466
+ "claude",
1467
+ "agents-md",
1468
+ "cursor",
1469
+ "vscode"
1470
+ ];
4555
1471
  const MAZ_UI_AGENTS_TOOL = {
4556
1472
  name: "maz-ui",
4557
1473
  mcpPackage: "@maz-ui/mcp",
4558
1474
  mcpBin: "maz-ui-mcp",
4559
1475
  generatedBy: "`npx @maz-ui/mcp init` (or the `mazUi.agents` Nuxt option)",
4560
- versionNote: (version) => `> maz-ui ${version} is installed: these rules and the docs in \`node_modules/maz-ui/docs\` match this version.`
1476
+ versionNote: (version) => `> maz-ui ${version} is installed: these rules and the docs in \`node_modules/maz-ui/docs\` match this version.`,
1477
+ packages: [
1478
+ "maz-ui",
1479
+ "@maz-ui/nuxt",
1480
+ "@maz-ui/themes",
1481
+ "@maz-ui/icons",
1482
+ "@maz-ui/utils",
1483
+ "@maz-ui/translations"
1484
+ ],
1485
+ ruleGlobs: ["**/*.{vue,ts,tsx,css,scss}"]
4561
1486
  };
4562
1487
  function escapeRegExp(value) {
4563
1488
  return value.replaceAll(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -4566,7 +1491,7 @@ const toolSetups = /* @__PURE__ */ new WeakMap();
4566
1491
  function resolveTool(tool) {
4567
1492
  let setup = toolSetups.get(tool);
4568
1493
  if (!setup) {
4569
- const marker = `Managed by ${tool.name}`;
1494
+ const marker = tool.marker ?? `Managed by ${tool.name}`;
4570
1495
  setup = {
4571
1496
  tool,
4572
1497
  marker,
@@ -4595,32 +1520,64 @@ function detectPackageManager(rootDir) {
4595
1520
  const declared = String(readPackageJson(rootDir)?.packageManager ?? "").split("@")[0];
4596
1521
  if (["pnpm", "yarn", "bun", "npm"].includes(declared))
4597
1522
  return declared;
4598
- const lockfiles = [["pnpm-lock.yaml", "pnpm"], ["yarn.lock", "yarn"], ["bun.lock", "bun"], ["bun.lockb", "bun"]];
1523
+ const lockfiles = [
1524
+ ["pnpm-lock.yaml", "pnpm"],
1525
+ ["yarn.lock", "yarn"],
1526
+ ["bun.lock", "bun"],
1527
+ ["bun.lockb", "bun"]
1528
+ ];
4599
1529
  return lockfiles.find(([file]) => existsSync(join(rootDir, file)))?.[1] ?? "npm";
4600
1530
  }
4601
1531
  function localMcpCommands(tool) {
4602
- const bin = [tool.mcpBin, ...tool.mcpArgs ?? []];
1532
+ const bin = [
1533
+ tool.mcpBin,
1534
+ ...tool.mcpArgs ?? []
1535
+ ];
4603
1536
  return {
4604
- pnpm: { command: "pnpm", args: ["exec", ...bin] },
4605
- yarn: { command: "yarn", args: ["run", ...bin] },
4606
- bun: { command: "bun", args: ["x", "--no-install", ...bin] },
4607
- npm: { command: "npx", args: ["--no-install", ...bin] }
1537
+ pnpm: {
1538
+ command: "pnpm",
1539
+ args: ["exec", ...bin]
1540
+ },
1541
+ yarn: {
1542
+ command: "yarn",
1543
+ args: ["run", ...bin]
1544
+ },
1545
+ bun: {
1546
+ command: "bun",
1547
+ args: ["x", "--no-install", ...bin]
1548
+ },
1549
+ npm: {
1550
+ command: "npx",
1551
+ args: ["--no-install", ...bin]
1552
+ }
4608
1553
  };
4609
1554
  }
4610
1555
  function mcpServerCommand(rootDir, version = "latest", tool = MAZ_UI_AGENTS_TOOL) {
4611
- return installsMcpPackage(rootDir, tool) ? localMcpCommands(tool)[detectPackageManager(rootDir)] : { command: "npx", args: ["-y", `${tool.mcpPackage}@${version}`, ...tool.mcpArgs ?? []] };
1556
+ return installsMcpPackage(rootDir, tool) ? localMcpCommands(tool)[detectPackageManager(rootDir)] : {
1557
+ command: "npx",
1558
+ args: [
1559
+ "-y",
1560
+ `${tool.mcpPackage}@${version}`,
1561
+ ...tool.mcpArgs ?? []
1562
+ ]
1563
+ };
4612
1564
  }
4613
1565
  function pinnedMcpVersion(server, tool) {
4614
1566
  const pinned = new RegExp(`^${escapeRegExp(tool.mcpPackage)}@(\\d\\S*)$`);
4615
1567
  return server.args.map((arg) => pinned.exec(arg)?.[1]).find(Boolean);
4616
1568
  }
4617
1569
  function isGeneratedMcpCommand(server, tool) {
4618
- const command = [server.command, ...Array.isArray(server.args) ? server.args : []].join(" ");
1570
+ const command = [
1571
+ server.command,
1572
+ ...Array.isArray(server.args) ? server.args : []
1573
+ ].join(" ");
4619
1574
  const args = (tool.mcpArgs ?? []).map((arg) => ` ${escapeRegExp(arg)}`).join("");
4620
1575
  return new RegExp(`^npx -y ${escapeRegExp(tool.mcpPackage)}(?:@\\S+)?${args}$`).test(command) || Object.values(localMcpCommands(tool)).some((local) => command === [local.command, ...local.args].join(" "));
4621
1576
  }
4622
1577
  const CLAUDE_MEMORY_FILES = ["CLAUDE.md", ".claude/CLAUDE.md", "CLAUDE.local.md"];
4623
1578
  function withVersion(content, version, tool) {
1579
+ if (tool.versionNote === false)
1580
+ return content;
4624
1581
  const note = tool.versionNote?.(version) ?? `> ${tool.name} ${version} is installed: these rules match this version.`;
4625
1582
  return content.replace(/^(#{1,2} .+)\n/, (_, title) => `${title}
4626
1583
 
@@ -4630,15 +1587,23 @@ ${note}
4630
1587
  function checksum(body) {
4631
1588
  return createHash("sha256").update(body.replaceAll(/\s+/g, "")).digest("hex").slice(0, 12);
4632
1589
  }
4633
- function managedContent(version, body, setup) {
4634
- return `<!-- ${setup.marker} ${version} (sha256:${checksum(body)}): generated by ${setup.tool.generatedBy}. Do not edit: edited rules are no longer updated. Write your own rules elsewhere. -->
1590
+ function ruleChecksum(frontmatter, body) {
1591
+ return checksum(frontmatter.replaceAll(/["']/g, "") + body);
1592
+ }
1593
+ function managedContent(version, body, setup, frontmatter = "") {
1594
+ const recorded = ruleChecksum(frontmatter, body);
1595
+ return `${frontmatter}<!-- ${setup.marker} ${version} (sha256:${recorded}): generated by ${setup.tool.generatedBy}. Do not edit: edited rules are no longer updated. Write your own rules elsewhere. -->
4635
1596
 
4636
1597
  ${body}`;
4637
1598
  }
4638
1599
  function isEditedManagedContent(content, tool = MAZ_UI_AGENTS_TOOL) {
4639
1600
  const header = content === void 0 ? null : resolveTool(tool).managedHeader.exec(content);
4640
1601
  const recorded = header ? /\(sha256:([\da-f]+)\)/.exec(header[0])?.[1] : void 0;
4641
- return header !== null && recorded !== void 0 && checksum(content.slice(header.index + header[0].length)) !== recorded;
1602
+ if (header === null || recorded === void 0)
1603
+ return false;
1604
+ const before = content.slice(0, header.index);
1605
+ const after = content.slice(header.index + header[0].length);
1606
+ return recorded !== checksum(after) && recorded !== ruleChecksum(before, after);
4642
1607
  }
4643
1608
  function detectAgentTargets(rootDir) {
4644
1609
  const has = (path) => existsSync(join(rootDir, path));
@@ -4672,11 +1637,14 @@ function readPackageVersion(packageDir) {
4672
1637
  const DEFAULT_WORKSPACES = ["apps/*", "packages/*"];
4673
1638
  const MAX_GLOBSTAR_DEPTH = 3;
4674
1639
  function readWorkspacePatterns(rootDir) {
1640
+ const patterns = readDeclaredWorkspacePatterns(rootDir).filter((pattern) => !pattern.startsWith("!"));
1641
+ return patterns.length > 0 ? patterns : DEFAULT_WORKSPACES;
1642
+ }
1643
+ function readDeclaredWorkspacePatterns(rootDir) {
4675
1644
  const pnpmWorkspace = join(rootDir, "pnpm-workspace.yaml");
4676
1645
  const workspaces = readPackageJson(rootDir)?.workspaces;
4677
1646
  const declared = existsSync(pnpmWorkspace) ? readPnpmWorkspacePackages(readFileSync(pnpmWorkspace, "utf8")) : (Array.isArray(workspaces) ? workspaces : workspaces?.packages) ?? [];
4678
- const patterns = declared.filter((pattern) => !pattern.startsWith("!")).map((pattern) => pattern.replace(/^\.\//, "").replace(/\/$/, ""));
4679
- return patterns.length > 0 ? patterns : DEFAULT_WORKSPACES;
1647
+ return declared.map((pattern) => pattern.replace(/^(!?)\.\//, "$1").replace(/\/$/, ""));
4680
1648
  }
4681
1649
  function readPnpmWorkspacePackages(content) {
4682
1650
  const patterns = [];
@@ -4712,8 +1680,9 @@ function findWorkspaceDirs(rootDir) {
4712
1680
  if (remaining === 0)
4713
1681
  return;
4714
1682
  for (const entry of readdirSync(join(rootDir, folder), { withFileTypes: true })) {
4715
- if (entry.isDirectory() && entry.name !== "node_modules" && !entry.name.startsWith("."))
1683
+ if (entry.isDirectory() && entry.name !== "node_modules" && !entry.name.startsWith(".")) {
4716
1684
  visit(folder ? `${folder}/${entry.name}` : entry.name, remaining - 1);
1685
+ }
4717
1686
  }
4718
1687
  };
4719
1688
  visit(base, depth);
@@ -4721,7 +1690,10 @@ function findWorkspaceDirs(rootDir) {
4721
1690
  return [...folders];
4722
1691
  }
4723
1692
  function findProjectPackage(rootDir, name) {
4724
- return [rootDir, ...findWorkspaceDirs(rootDir)].map((base) => join(base, "node_modules", name)).find((candidate) => existsSync(join(candidate, "package.json"))) ?? findInstalledPackage(rootDir, name);
1693
+ return [
1694
+ rootDir,
1695
+ ...findWorkspaceDirs(rootDir)
1696
+ ].map((base) => join(base, "node_modules", name)).find((candidate) => existsSync(join(candidate, "package.json"))) ?? findInstalledPackage(rootDir, name);
4725
1697
  }
4726
1698
  function readAgentDocs(rootDir, docsDir) {
4727
1699
  let directory = docsDir;
@@ -4765,8 +1737,9 @@ function parseVersion(version) {
4765
1737
  }
4766
1738
  function comparePrereleaseIdentifiers(a, b) {
4767
1739
  const isNumeric = (value) => /^\d+$/.test(value);
4768
- if (isNumeric(a) !== isNumeric(b))
1740
+ if (isNumeric(a) !== isNumeric(b)) {
4769
1741
  return isNumeric(a) ? -1 : 1;
1742
+ }
4770
1743
  return isNumeric(a) ? Number(a) - Number(b) : a.localeCompare(b);
4771
1744
  }
4772
1745
  function compareVersions(a, b) {
@@ -4814,7 +1787,11 @@ class ChangeSet {
4814
1787
  this.changes.push({ file, action: "unchanged" });
4815
1788
  return;
4816
1789
  }
4817
- this.changes.push({ file, action: current === void 0 ? "create" : "update", ...reason ? { reason } : {} });
1790
+ this.changes.push({
1791
+ file,
1792
+ action: current === void 0 ? "create" : "update",
1793
+ ...reason ? { reason } : {}
1794
+ });
4818
1795
  if (!this.dryRun)
4819
1796
  writeFileAtomic(this.absolute(file), content);
4820
1797
  }
@@ -4911,9 +1888,17 @@ function referencesToolMcp(server, tool) {
4911
1888
  const args = isJsonObject(server) && Array.isArray(server.args) ? server.args : [];
4912
1889
  return (serialized.includes(tool.mcpPackage) || serialized.includes(tool.mcpBin)) && (tool.mcpArgs ?? []).every((arg) => args.includes(arg));
4913
1890
  }
1891
+ function findLegacyPackage(server, tool) {
1892
+ const serialized = JSON.stringify(server);
1893
+ return tool.legacyMcpPackages?.find((name) => serialized.includes(name));
1894
+ }
4914
1895
  function detectFormatting(content) {
4915
1896
  const indent = /^( +|\t)"/m.exec(content)?.[1] ?? " ";
4916
- return { insertSpaces: !indent.includes(" "), tabSize: indent.includes(" ") ? 1 : indent.length, eol: content.includes("\r\n") ? "\r\n" : "\n" };
1897
+ return {
1898
+ insertSpaces: !indent.includes(" "),
1899
+ tabSize: indent.includes(" ") ? 1 : indent.length,
1900
+ eol: content.includes("\r\n") ? "\r\n" : "\n"
1901
+ };
4917
1902
  }
4918
1903
  function isJsonObject(value) {
4919
1904
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -4970,6 +1955,17 @@ function syncMcpConfig(changes, config, server, remove, tool) {
4970
1955
  updateMcpCommand(changes, config, existing, server, tool);
4971
1956
  return;
4972
1957
  }
1958
+ const legacy = Object.entries(servers).map(([key, entry]) => [
1959
+ key,
1960
+ findLegacyPackage(entry, tool)
1961
+ ]).find(([, name]) => name !== void 0);
1962
+ if (legacy) {
1963
+ const [key, name] = legacy;
1964
+ const migrated = applyEdits(base, modify(base, [config.rootKey, key], config.withType ? { type: "stdio", ...server } : { ...server }, { formattingOptions: formatting }));
1965
+ changes.write(config.file, migrated.endsWith("\n") ? migrated : `${migrated}
1966
+ `, current, `"${key}" migrated from ${name} to ${tool.mcpPackage}`);
1967
+ return;
1968
+ }
4973
1969
  if (servers[tool.name] !== void 0) {
4974
1970
  changes.skip(config.file, `a "${tool.name}" server already exists with another command: left untouched`);
4975
1971
  return;
@@ -4979,17 +1975,79 @@ function syncMcpConfig(changes, config, server, remove, tool) {
4979
1975
  changes.write(config.file, content.endsWith("\n") ? content : `${content}
4980
1976
  `, current);
4981
1977
  }
4982
- function syncRules(changes, rootDir, targets, docs, setup) {
1978
+ const DEPENDENCY_FIELDS = [
1979
+ "dependencies",
1980
+ "devDependencies",
1981
+ "peerDependencies",
1982
+ "optionalDependencies"
1983
+ ];
1984
+ function dependsOnAny(folder, packages) {
1985
+ const pkg = readPackageJson(folder);
1986
+ return DEPENDENCY_FIELDS.some((field) => packages.some((name) => pkg?.[field]?.[name] !== void 0));
1987
+ }
1988
+ function findWorkspacesUsing(rootDir, packages) {
1989
+ const excluded = readDeclaredWorkspacePatterns(rootDir).filter((pattern) => pattern.startsWith("!")).map((pattern) => globToRegExp(`${pattern.slice(1)}/**`));
1990
+ const folders = [
1991
+ rootDir,
1992
+ ...findWorkspaceDirs(rootDir)
1993
+ ].map((folder) => relative(rootDir, folder).split(sep).join("/")).filter((folder) => !excluded.some((matcher) => matcher.test(folder)));
1994
+ return folders.filter((folder) => dependsOnAny(join(rootDir, folder), packages));
1995
+ }
1996
+ function isUnscopedGlob(glob) {
1997
+ return ["**", "**/*", "*", "/**", "/**/*"].includes(glob.trim());
1998
+ }
1999
+ function resolveRulePaths(rootDir, tool, option = "auto") {
2000
+ if (option === "all")
2001
+ return void 0;
2002
+ const explicit = Array.isArray(option) ? option.map((glob) => glob.trim()).filter(Boolean) : [];
2003
+ const globs = Array.isArray(option) ? explicit : autoRulePaths(rootDir, tool);
2004
+ return globs.length === 0 || globs.some(isUnscopedGlob) ? void 0 : [
2005
+ ...new Set(globs)
2006
+ ];
2007
+ }
2008
+ const MAX_EXPANDED_PATTERNS = 1e3;
2009
+ function expandedPatternCount(glob) {
2010
+ const groups = glob.replaceAll(/\\./g, "").matchAll(/\{([^{}]*)\}/g);
2011
+ return [...groups].reduce((count, [, alternatives]) => count * alternatives.split(",").length, 1);
2012
+ }
2013
+ function escapeGlobFolder(folder) {
2014
+ return folder.replaceAll(/[[\]{}()*?!]/g, String.raw`\$&`);
2015
+ }
2016
+ function autoRulePaths(rootDir, tool) {
2017
+ if (!tool.packages || tool.packages.length === 0)
2018
+ return [];
2019
+ const files = tool.ruleGlobs ?? ["**/*"];
2020
+ const folders = findWorkspacesUsing(rootDir, tool.packages);
2021
+ const globsOf = (scopedFolders) => scopedFolders.flatMap((folder) => files.map((glob) => posix.join(escapeGlobFolder(folder), glob)));
2022
+ const scoped = globsOf(folders.includes("") || folders.length === 0 ? [""] : folders);
2023
+ return scoped.reduce((total, glob) => total + expandedPatternCount(glob), 0) > MAX_EXPANDED_PATTERNS ? globsOf([""]) : scoped;
2024
+ }
2025
+ function claudeFrontmatter(globs) {
2026
+ if (!globs || globs.length === 0)
2027
+ return "";
2028
+ const items = globs.map((glob) => [
2029
+ " -",
2030
+ JSON.stringify(glob)
2031
+ ].join(" ")).join("\n");
2032
+ return `---
2033
+ paths:
2034
+ ${items}
2035
+ ---
2036
+
2037
+ `;
2038
+ }
2039
+ function syncRules(changes, rootDir, targets, docs, setup, paths) {
4983
2040
  const version = docs?.version ?? "";
4984
2041
  const hasClaudeMemory = CLAUDE_MEMORY_FILES.some((file) => existsSync(join(rootDir, file)));
4985
2042
  const claudeReadsAgentsMd = targets.includes("agents-md") && !hasClaudeMemory;
4986
2043
  if (targets.includes("claude")) {
4987
- const rule = docs && !claudeReadsAgentsMd ? `${managedContent(version, withVersion(docs.claudeRule, version, setup.tool), setup)}
2044
+ const rule = docs && !claudeReadsAgentsMd ? `${managedContent(version, withVersion(docs.claudeRule, version, setup.tool), setup, claudeFrontmatter(paths))}
4988
2045
  ` : void 0;
4989
2046
  syncOwnedFile(changes, setup.ruleFile, rule, version, setup);
4990
2047
  }
4991
- if (targets.includes("agents-md"))
2048
+ if (targets.includes("agents-md")) {
4992
2049
  syncAgentsMd(changes, docs ? managedContent(version, withVersion(docs.agentsMdSection, version, setup.tool), setup) : void 0, version, setup);
2050
+ }
4993
2051
  }
4994
2052
  function resolveAgentDocs(options, tool) {
4995
2053
  if (options.agentDocs)
@@ -5006,22 +2064,30 @@ function setupAgents(options) {
5006
2064
  const version = docs?.version ?? "";
5007
2065
  const changes = new ChangeSet(rootDir, dryRun);
5008
2066
  const server = options.mcpServer ?? mcpServerCommand(rootDir, options.mcpVersion, tool);
2067
+ const claudeRulePaths = docs && targets.includes("claude") ? resolveRulePaths(rootDir, tool, options.paths) : void 0;
5009
2068
  if (rules || remove)
5010
- syncRules(changes, rootDir, targets, docs, setup);
2069
+ syncRules(changes, rootDir, targets, docs, setup, claudeRulePaths);
5011
2070
  if (mcp || remove) {
5012
2071
  for (const target of ["claude", "cursor", "vscode"]) {
5013
2072
  if (targets.includes(target))
5014
2073
  syncMcpConfig(changes, MCP_FILES[target], server, remove, tool);
5015
2074
  }
5016
2075
  }
5017
- return { targets, version, changes: changes.changes, mcpServer: server, localMcpServer: !server.args.includes("-y") };
2076
+ return {
2077
+ targets,
2078
+ version,
2079
+ changes: changes.changes,
2080
+ mcpServer: server,
2081
+ localMcpServer: !server.args.includes("-y"),
2082
+ claudeRulePaths
2083
+ };
5018
2084
  }
5019
2085
 
5020
2086
  function getErrorMessage(error) {
5021
2087
  return error instanceof Error ? error.message : typeof error == "string" ? error : error && typeof error == "object" && "message" in error ? String(error.message) : error ? String(error) : "An unexpected error occurred";
5022
2088
  }
5023
2089
 
5024
- function readOwnVersion(from = dirname(fileURLToPath$1(import.meta.url))) {
2090
+ function readOwnVersion(from = dirname(fileURLToPath(import.meta.url))) {
5025
2091
  let directory = from;
5026
2092
  for (; ; ) {
5027
2093
  const file = join(directory, "package.json");
@@ -11960,8 +9026,21 @@ function datetime(params) {
11960
9026
  }
11961
9027
 
11962
9028
  const SUPPORTED_SCHEMA_VERSION = 1;
11963
- const docCategories = ["guide", "component", "composable", "directive", "plugin", "ecosystem", "util", "node", "reference"];
11964
- const namedTokenSchema = object$1({ name: string(), value: string() });
9029
+ const docCategories = [
9030
+ "guide",
9031
+ "component",
9032
+ "composable",
9033
+ "directive",
9034
+ "plugin",
9035
+ "ecosystem",
9036
+ "util",
9037
+ "node",
9038
+ "reference"
9039
+ ];
9040
+ const namedTokenSchema = object$1({
9041
+ name: string(),
9042
+ value: string()
9043
+ });
11965
9044
  const docEntrySchema = object$1({
11966
9045
  id: string(),
11967
9046
  category: _enum$1(docCategories),
@@ -11995,16 +9074,30 @@ const componentApiSchema = object$1({
11995
9074
  import: string(),
11996
9075
  parent: string().optional(),
11997
9076
  props: array(propApiSchema),
11998
- events: array(object$1({ name: string(), description: string().optional(), payload: string().optional() })),
9077
+ events: array(object$1({
9078
+ name: string(),
9079
+ description: string().optional(),
9080
+ payload: string().optional()
9081
+ })),
11999
9082
  slots: array(object$1({
12000
9083
  name: string(),
12001
9084
  description: string().optional(),
12002
- bindings: array(object$1({ name: string(), type: string().optional(), description: string().optional() }))
9085
+ bindings: array(object$1({
9086
+ name: string(),
9087
+ type: string().optional(),
9088
+ description: string().optional()
9089
+ }))
12003
9090
  })),
12004
- expose: array(object$1({ name: string(), description: string().optional() }))
9091
+ expose: array(object$1({
9092
+ name: string(),
9093
+ description: string().optional()
9094
+ }))
12005
9095
  });
12006
9096
  const tailwindSchema = object$1({
12007
- entries: array(object$1({ path: string(), description: string() })),
9097
+ entries: array(object$1({
9098
+ path: string(),
9099
+ description: string()
9100
+ })),
12008
9101
  colors: array(object$1({
12009
9102
  name: string(),
12010
9103
  variable: string(),
@@ -12020,7 +9113,10 @@ const tailwindSchema = object$1({
12020
9113
  durations: array(namedTokenSchema),
12021
9114
  easings: array(namedTokenSchema),
12022
9115
  spacing: array(namedTokenSchema),
12023
- utilities: array(object$1({ name: string(), css: string() })),
9116
+ utilities: array(object$1({
9117
+ name: string(),
9118
+ css: string()
9119
+ })),
12024
9120
  variants: array(namedTokenSchema),
12025
9121
  containerVariables: array(namedTokenSchema),
12026
9122
  transitions: array(string())
@@ -12030,10 +9126,17 @@ const manifestSchema = object$1({
12030
9126
  name: literal("maz-ui"),
12031
9127
  version: string(),
12032
9128
  homepage: string(),
12033
- packages: array(object$1({ name: string(), description: string(), docId: string() })),
9129
+ packages: array(object$1({
9130
+ name: string(),
9131
+ description: string(),
9132
+ docId: string()
9133
+ })),
12034
9134
  docs: array(docEntrySchema),
12035
9135
  components: array(componentApiSchema),
12036
- icons: object$1({ package: string(), names: array(string()) }),
9136
+ icons: object$1({
9137
+ package: string(),
9138
+ names: array(string())
9139
+ }),
12037
9140
  tailwind: tailwindSchema
12038
9141
  });
12039
9142
 
@@ -12079,8 +9182,11 @@ class Knowledge {
12079
9182
  }
12080
9183
  }
12081
9184
  function defaultBundledDir() {
12082
- const here = dirname(fileURLToPath$1(import.meta.url));
12083
- const candidates = [resolve$1(here, "../docs"), resolve$1(here, "../../docs")];
9185
+ const here = dirname(fileURLToPath(import.meta.url));
9186
+ const candidates = [
9187
+ resolve$1(here, "../docs"),
9188
+ resolve$1(here, "../../docs")
9189
+ ];
12084
9190
  return candidates.find((candidate) => existsSync(join(candidate, "manifest.json"))) ?? candidates[0];
12085
9191
  }
12086
9192
  function readManifest(directory) {
@@ -14119,7 +11225,17 @@ const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
14119
11225
  // character
14120
11226
  const SPACE_OR_PUNCTUATION = /[\n\r\p{Z}\p{P}]+/u;
14121
11227
 
14122
- const CATEGORY_PRIORITY = ["component", "composable", "directive", "plugin", "util", "guide", "ecosystem", "reference", "node"];
11228
+ const CATEGORY_PRIORITY = [
11229
+ "component",
11230
+ "composable",
11231
+ "directive",
11232
+ "plugin",
11233
+ "util",
11234
+ "guide",
11235
+ "ecosystem",
11236
+ "reference",
11237
+ "node"
11238
+ ];
14123
11239
  function toKebab(value) {
14124
11240
  return value.replaceAll(/([a-z\d])([A-Z])/g, "$1-$2").replaceAll(/([A-Z]+)([A-Z][a-z])/g, "$1-$2").toLowerCase();
14125
11241
  }
@@ -14173,7 +11289,10 @@ function editDistance(a, b, max = 3) {
14173
11289
  }
14174
11290
  function closest(value, candidates, { max = 3, limit = 3 } = {}) {
14175
11291
  const lower = value.toLowerCase();
14176
- return [...candidates].map((candidate) => ({ candidate, distance: editDistance(lower, candidate.toLowerCase(), max) })).filter(({ distance }) => distance <= max).sort((a, b) => a.distance - b.distance || a.candidate.length - b.candidate.length).slice(0, limit).map(({ candidate }) => candidate);
11292
+ return [...candidates].map((candidate) => ({
11293
+ candidate,
11294
+ distance: editDistance(lower, candidate.toLowerCase(), max)
11295
+ })).filter(({ distance }) => distance <= max).sort((a, b) => a.distance - b.distance || a.candidate.length - b.candidate.length).slice(0, limit).map(({ candidate }) => candidate);
14177
11296
  }
14178
11297
 
14179
11298
  const SYNONYMS = {
@@ -14387,7 +11506,29 @@ const META_DOCS = /* @__PURE__ */ new Map([
14387
11506
  ["guide/migration-v5", /\b(?:migrat\w*|upgrad\w*|v4|v5|breaking)\b/i]
14388
11507
  ]);
14389
11508
  const META_DOC_FACTOR = 0.15;
14390
- const LOW_VALUE_TERMS = new Set(["add", "show", "display", "delete", "remove", "update", "set", "open", "close", "user", "users", "page", "item", "data", "value", "list", "text", "click", "between", "before", "after"].map((term) => processTerm(term) ?? term));
11509
+ const LOW_VALUE_TERMS = new Set([
11510
+ "add",
11511
+ "show",
11512
+ "display",
11513
+ "delete",
11514
+ "remove",
11515
+ "update",
11516
+ "set",
11517
+ "open",
11518
+ "close",
11519
+ "user",
11520
+ "users",
11521
+ "page",
11522
+ "item",
11523
+ "data",
11524
+ "value",
11525
+ "list",
11526
+ "text",
11527
+ "click",
11528
+ "between",
11529
+ "before",
11530
+ "after"
11531
+ ].map((term) => processTerm(term) ?? term));
14391
11532
  const LOW_VALUE_FACTOR = 0.4;
14392
11533
  const LOW_VALUE_ONLY_FACTOR = 0.25;
14393
11534
  const EXACT_MATCH_BOOST = 4;
@@ -14449,15 +11590,31 @@ class DocSearch {
14449
11590
  if (terms.length === 0)
14450
11591
  return [];
14451
11592
  const hintedCategory = category ? void 0 : terms.map((term) => CATEGORY_HINTS[term]).find(Boolean);
14452
- const expansion = [...new Set(terms.flatMap((term) => this.synonyms.get(term) ?? []))].filter((term) => !terms.includes(term));
11593
+ const expansion = [
11594
+ ...new Set(terms.flatMap((term) => this.synonyms.get(term) ?? []))
11595
+ ].filter((term) => !terms.includes(term));
14453
11596
  const exact = this.exactMatch(query);
14454
11597
  const normalizedQuery = query.trim().toLowerCase();
14455
11598
  const hasValuableTerm = terms.some((term) => !LOW_VALUE_TERMS.has(term));
14456
11599
  const results = this.index.search({
14457
11600
  combineWith: "OR",
14458
11601
  queries: [
14459
- { queries: [terms.join(" ")], combineWith: "OR", boostTerm: (term) => LOW_VALUE_TERMS.has(term) ? LOW_VALUE_FACTOR : 1 },
14460
- ...expansion.length > 0 ? [{ queries: [expansion.join(" ")], combineWith: "OR", boostTerm: () => 0.45 }] : []
11602
+ {
11603
+ queries: [
11604
+ terms.join(" ")
11605
+ ],
11606
+ combineWith: "OR",
11607
+ boostTerm: (term) => LOW_VALUE_TERMS.has(term) ? LOW_VALUE_FACTOR : 1
11608
+ },
11609
+ ...expansion.length > 0 ? [
11610
+ {
11611
+ queries: [
11612
+ expansion.join(" ")
11613
+ ],
11614
+ combineWith: "OR",
11615
+ boostTerm: () => 0.45
11616
+ }
11617
+ ] : []
14461
11618
  ]
14462
11619
  }, {
14463
11620
  boost: FIELD_BOOSTS,
@@ -14611,7 +11768,15 @@ function iconWords(name) {
14611
11768
  return cached;
14612
11769
  const flag = /^MazFlag(?:Square)?([A-Z]{2})(?:[A-Z]{2})?$/.exec(name);
14613
11770
  const country = flag ? regionName(flag[1]) : "";
14614
- const words = [...analyze(name.replace(/^Maz/, "")), ...flag ? ["flag", "country", flag[1].toLowerCase()] : [], ...analyze(country)];
11771
+ const words = [
11772
+ ...analyze(name.replace(/^Maz/, "")),
11773
+ ...flag ? [
11774
+ "flag",
11775
+ "country",
11776
+ flag[1].toLowerCase()
11777
+ ] : [],
11778
+ ...analyze(country)
11779
+ ];
14615
11780
  iconWordsCache.set(name, words);
14616
11781
  return words;
14617
11782
  }
@@ -14628,7 +11793,10 @@ function searchIcons(names, query, limit = 20) {
14628
11793
  const lowerName = name.toLowerCase();
14629
11794
  let score = 0;
14630
11795
  for (const word of words) {
14631
- const candidates = [word, ...synonyms.get(word) ?? []];
11796
+ const candidates = [
11797
+ word,
11798
+ ...synonyms.get(word) ?? []
11799
+ ];
14632
11800
  for (const [index, candidate] of candidates.entries()) {
14633
11801
  const weight = index === 0 ? 1 : 0.8;
14634
11802
  if (parts.includes(candidate))
@@ -26655,14 +23823,14 @@ const data = {
26655
23823
  };
26656
23824
 
26657
23825
  const data$1 = {
26658
- __proto__: null,
26659
- $id: $id$1,
26660
- additionalProperties: additionalProperties$1,
26661
- default: data,
26662
- description: description,
26663
- properties: properties$2,
26664
- required: required$1,
26665
- type: type$1
23826
+ __proto__: null,
23827
+ $id: $id$1,
23828
+ additionalProperties: additionalProperties$1,
23829
+ default: data,
23830
+ description: description,
23831
+ properties: properties$2,
23832
+ required: required$1,
23833
+ type: type$1
26666
23834
  };
26667
23835
 
26668
23836
  const require$$9 = /*@__PURE__*/getAugmentedNamespace(data$1);
@@ -31396,14 +28564,14 @@ const jsonSchemaDraft07 = {
31396
28564
  };
31397
28565
 
31398
28566
  const jsonSchemaDraft07$1 = {
31399
- __proto__: null,
31400
- $id: $id,
31401
- $schema: $schema,
31402
- default: jsonSchemaDraft07,
31403
- definitions: definitions,
31404
- properties: properties,
31405
- title: title,
31406
- type: type
28567
+ __proto__: null,
28568
+ $id: $id,
28569
+ $schema: $schema,
28570
+ default: jsonSchemaDraft07,
28571
+ definitions: definitions,
28572
+ properties: properties,
28573
+ title: title,
28574
+ type: type
31407
28575
  };
31408
28576
 
31409
28577
  const require$$3 = /*@__PURE__*/getAugmentedNamespace(jsonSchemaDraft07$1);
@@ -32819,6 +29987,16 @@ class McpServer {
32819
29987
  this._promptHandlersInitialized = false;
32820
29988
  this.server = new Server(serverInfo, options);
32821
29989
  this._maxToolInputElements = resolveMaxToolInputElements(options?.maxToolInputElements);
29990
+ // A capability declared in the options gets its handlers now, so registering after connect() works.
29991
+ if (options?.capabilities?.tools) {
29992
+ this.setToolRequestHandlers();
29993
+ }
29994
+ if (options?.capabilities?.resources) {
29995
+ this.setResourceRequestHandlers();
29996
+ }
29997
+ if (options?.capabilities?.prompts) {
29998
+ this.setPromptRequestHandlers();
29999
+ }
32822
30000
  }
32823
30001
  /**
32824
30002
  * Access experimental features.
@@ -33732,7 +30910,7 @@ function serializeMessage(message) {
33732
30910
  * This transport is only available in Node.js environments.
33733
30911
  */
33734
30912
  class StdioServerTransport {
33735
- constructor(_stdin = g$1.stdin, _stdout = g$1.stdout, options) {
30913
+ constructor(_stdin = g.stdin, _stdout = g.stdout, options) {
33736
30914
  this._stdin = _stdin;
33737
30915
  this._stdout = _stdout;
33738
30916
  this._started = false;
@@ -33833,8 +31011,14 @@ function listSections(markdown) {
33833
31011
  continue;
33834
31012
  }
33835
31013
  const match = !inFence && /^(#{2,4})\s+(\S.*)$/.exec(line);
33836
- if (match)
33837
- sections.push({ title: match[2].trim(), level: match[1].length, start: index, end: lines.length });
31014
+ if (match) {
31015
+ sections.push({
31016
+ title: match[2].trim(),
31017
+ level: match[1].length,
31018
+ start: index,
31019
+ end: lines.length
31020
+ });
31021
+ }
33838
31022
  }
33839
31023
  for (const [index, section] of sections.entries()) {
33840
31024
  const next = sections.slice(index + 1).find((candidate) => candidate.level <= section.level);
@@ -33939,7 +31123,14 @@ Rules:
33939
31123
  }
33940
31124
 
33941
31125
  function userMessage(text) {
33942
- return { messages: [{ role: "user", content: { type: "text", text } }] };
31126
+ return {
31127
+ messages: [
31128
+ {
31129
+ role: "user",
31130
+ content: { type: "text", text }
31131
+ }
31132
+ ]
31133
+ };
33943
31134
  }
33944
31135
  function registerPrompts(server) {
33945
31136
  server.registerPrompt("build", {
@@ -33984,7 +31175,10 @@ function registerPrompts(server) {
33984
31175
  function findIcons(context, { query, limit = 24 }) {
33985
31176
  const { iconNames } = context.knowledge;
33986
31177
  const exact = [...iconNames].find((name) => name.toLowerCase() === query.trim().toLowerCase());
33987
- const names = exact ? [exact, ...searchIcons(iconNames, query, limit).filter((name) => name !== exact)].slice(0, limit) : searchIcons(iconNames, query, limit);
31178
+ const names = exact ? [
31179
+ exact,
31180
+ ...searchIcons(iconNames, query, limit).filter((name) => name !== exact)
31181
+ ].slice(0, limit) : searchIcons(iconNames, query, limit);
33988
31182
  if (names.length === 0) {
33989
31183
  const near = closest(query.startsWith("Maz") ? query : `Maz${query}`, iconNames, { max: 4, limit: 8 });
33990
31184
  return [
@@ -34024,7 +31218,9 @@ const findIconsTool = defineTool({
34024
31218
  function getComponentApi(context, { names }) {
34025
31219
  const blocks = [];
34026
31220
  const unknown = [];
34027
- for (const name of [...new Set(names)]) {
31221
+ for (const name of [
31222
+ ...new Set(names)
31223
+ ]) {
34028
31224
  const component = resolveComponent(context.knowledge, name);
34029
31225
  if (!component) {
34030
31226
  unknown.push(name);
@@ -34047,13 +31243,17 @@ Examples: \`get_doc({ id: "${component.docId}" })\``);
34047
31243
  const suggestions = unknown.flatMap((name) => closest(name, context.knowledge.componentsByName.keys(), { max: 4 }));
34048
31244
  throw new ToolInputError([
34049
31245
  `Unknown maz-ui component${unknown.length > 1 ? "s" : ""}: ${unknown.join(", ")}.`,
34050
- suggestions.length > 0 ? `Did you mean: ${[...new Set(suggestions)].join(", ")}?` : "",
31246
+ suggestions.length > 0 ? `Did you mean: ${[
31247
+ ...new Set(suggestions)
31248
+ ].join(", ")}?` : "",
34051
31249
  'Use `search_docs` to find a component from a need, or `list_docs({ category: "component" })`.'
34052
31250
  ].filter(Boolean).join("\n"));
34053
31251
  }
34054
31252
  if (unknown.length > 0) {
34055
31253
  const suggestions = unknown.flatMap((name) => closest(name, context.knowledge.componentsByName.keys(), { max: 4 }));
34056
- blocks.push(`Unknown: ${unknown.join(", ")}.${suggestions.length > 0 ? ` Did you mean ${[...new Set(suggestions)].join(", ")}?` : ""}`);
31254
+ blocks.push(`Unknown: ${unknown.join(", ")}.${suggestions.length > 0 ? ` Did you mean ${[
31255
+ ...new Set(suggestions)
31256
+ ].join(", ")}?` : ""}`);
34057
31257
  }
34058
31258
  return [
34059
31259
  `Props are listed in kebab-case (use \`:prop\` for dynamic values). Values marked "non exhaustive" accept other values. Never use undocumented props, events or slots.`,
@@ -34101,7 +31301,11 @@ function searchDocs(context, { query, category, limit = 8 }) {
34101
31301
  "If maz-ui does not provide it, build it with maz-ui components and the theme tokens (`get_theme_tokens`)."
34102
31302
  ].join("\n");
34103
31303
  }
34104
- const lines = [header, "", ...hits.map((hit, index) => formatDocLine(hit.doc, index))];
31304
+ const lines = [
31305
+ header,
31306
+ "",
31307
+ ...hits.map((hit, index) => formatDocLine(hit.doc, index))
31308
+ ];
34105
31309
  if (hits[0].score < WEAK_MATCH_SCORE) {
34106
31310
  lines.push("", "These results are weak matches: maz-ui probably has no dedicated feature for this need. Compose it from maz-ui components (MazCard, MazBtn, MazIcon...) and theme tokens (`get_theme_tokens`) rather than adding another library.");
34107
31311
  }
@@ -34130,7 +31334,11 @@ function notFoundMessage(context, query) {
34130
31334
  const suggestions = context.search.search(query, { limit: 5 });
34131
31335
  return [
34132
31336
  `No maz-ui doc matches "${query}".`,
34133
- ...suggestions.length > 0 ? ["", "Closest docs:", ...suggestions.map((hit) => formatDocLine(hit.doc))] : [],
31337
+ ...suggestions.length > 0 ? [
31338
+ "",
31339
+ "Closest docs:",
31340
+ ...suggestions.map((hit) => formatDocLine(hit.doc))
31341
+ ] : [],
34134
31342
  "",
34135
31343
  'Pass an id from `search_docs` or `list_docs` (e.g. "components/maz-btn", "composables/use-toast", "guide/tailwind").'
34136
31344
  ].join("\n");
@@ -34147,7 +31355,10 @@ function getDoc(context, { id, sections, full = false }) {
34147
31355
  throw new ToolInputError(notFoundMessage(context, id));
34148
31356
  const markdown = linksToDocIds(stripFrontmatter(context.knowledge.readDoc(doc.id)), doc);
34149
31357
  if (sections?.length) {
34150
- const found = sections.map((title) => ({ title, section: findSection(markdown, title) }));
31358
+ const found = sections.map((title) => ({
31359
+ title,
31360
+ section: findSection(markdown, title)
31361
+ }));
34151
31362
  const missing = found.filter((entry) => !entry.section).map((entry) => entry.title);
34152
31363
  if (missing.length === found.length) {
34153
31364
  throw new ToolInputError(`No section "${missing.join('", "')}" in \`${doc.id}\`. Available sections:
@@ -34292,7 +31503,12 @@ async function reviewCodeTool(context, { paths, code, filename, framework, minSe
34292
31503
  sections.push(formatFindings(findings, filename ?? "code"));
34293
31504
  }
34294
31505
  if (paths?.length) {
34295
- const { reviews, truncated } = await reviewFiles(paths, { knowledge: context.knowledge, cwd: context.cwd, framework, minSeverity });
31506
+ const { reviews, truncated } = await reviewFiles(paths, {
31507
+ knowledge: context.knowledge,
31508
+ cwd: context.cwd,
31509
+ framework,
31510
+ minSeverity
31511
+ });
34296
31512
  if (reviews.length === 0)
34297
31513
  throw new ToolInputError(`No .vue, .ts, .js or .css file matches ${paths.join(", ")} (from ${context.cwd}).`);
34298
31514
  const withIssues = reviews.filter((review) => review.findings.length > 0);
@@ -34332,17 +31548,32 @@ const TOOLS = [
34332
31548
  ];
34333
31549
  async function runTool(context, tool, args) {
34334
31550
  try {
34335
- return { content: [{ type: "text", text: await tool.run(context, args) }] };
31551
+ return {
31552
+ content: [
31553
+ { type: "text", text: await tool.run(context, args) }
31554
+ ]
31555
+ };
34336
31556
  } catch (error) {
34337
31557
  const message = error instanceof ToolInputError ? error.message : `Unexpected error in ${tool.name}: ${getErrorMessage(error)}. Retry with other arguments or fall back to the docs in ${context.knowledge.source.directory}.`;
34338
- return { content: [{ type: "text", text: message }], isError: true };
31558
+ return {
31559
+ content: [
31560
+ { type: "text", text: message }
31561
+ ],
31562
+ isError: true
31563
+ };
34339
31564
  }
34340
31565
  }
34341
31566
  function createMazUiMcpServer(options = {}) {
34342
31567
  const context = createContext(options);
34343
31568
  const server = new McpServer(
34344
- { name: "maz-ui", title: "maz-ui", version: readOwnVersion() },
34345
- { instructions: buildInstructions(context) }
31569
+ {
31570
+ name: "maz-ui",
31571
+ title: "maz-ui",
31572
+ version: readOwnVersion()
31573
+ },
31574
+ {
31575
+ instructions: buildInstructions(context)
31576
+ }
34346
31577
  );
34347
31578
  for (const tool of TOOLS) {
34348
31579
  server.registerTool(tool.name, {
@@ -34378,6 +31609,7 @@ Usage:
34378
31609
 
34379
31610
  init options:
34380
31611
  --targets <list> Comma separated: ${AGENT_TARGETS.join(", ")} (default: detected, else claude,agents-md)
31612
+ --paths <globs> Comma separated globs the Claude Code rule is scoped to, or all (default: the workspaces that use maz-ui)
34381
31613
  --no-rules Only register the MCP server (no rule file, no AGENTS.md section)
34382
31614
  --no-mcp Do not register the MCP server
34383
31615
  --dry-run Show the changes without writing them
@@ -34413,7 +31645,12 @@ function printChanges(changes, dryRun) {
34413
31645
  console.log(` ${labels[change.action].padEnd(13)} ${change.file}${change.reason ? ` (${change.reason})` : ""}`);
34414
31646
  }
34415
31647
  }
34416
- const INSTALL_DEV_COMMANDS = { pnpm: "pnpm add -D", yarn: "yarn add -D", bun: "bun add -d", npm: "npm install -D" };
31648
+ const INSTALL_DEV_COMMANDS = {
31649
+ pnpm: "pnpm add -D",
31650
+ yarn: "yarn add -D",
31651
+ bun: "bun add -d",
31652
+ npm: "npm install -D"
31653
+ };
34417
31654
  function resolveInitTargets(values, cwd) {
34418
31655
  const requested = typeof values.targets === "string" ? values.targets.split(",").map((target) => target.trim()).filter(Boolean) : void 0;
34419
31656
  const invalid = requested?.filter((target) => !AGENT_TARGETS.includes(target)) ?? [];
@@ -34424,6 +31661,10 @@ function resolveInitTargets(values, cwd) {
34424
31661
  const detected = detectAgentTargets(cwd);
34425
31662
  return requested ?? (detected.length > 0 ? detected : ["claude", "agents-md"]);
34426
31663
  }
31664
+ function resolveInitPaths(values) {
31665
+ const globs = typeof values.paths === "string" ? values.paths.split(",").map((glob) => glob.trim()).filter(Boolean) : void 0;
31666
+ return globs?.length === 1 && globs[0] === "all" ? "all" : globs;
31667
+ }
34427
31668
  function runInit(values, cwd) {
34428
31669
  const targets = resolveInitTargets(values, cwd);
34429
31670
  if (!targets)
@@ -34442,11 +31683,15 @@ function runInit(values, cwd) {
34442
31683
  dryRun,
34443
31684
  remove,
34444
31685
  docsDir,
31686
+ paths: resolveInitPaths(values),
34445
31687
  mcpVersion: readOwnVersion()
34446
31688
  });
34447
31689
  const serverCommand = [result.mcpServer.command, ...result.mcpServer.args].join(" ");
34448
31690
  console.log(`maz-ui ${result.version ? `${result.version} ` : ""}agents setup (${targets.join(", ")})${dryRun ? " - dry run" : ""}`);
34449
31691
  printChanges(result.changes, dryRun);
31692
+ if (!remove && rules && result.claudeRulePaths)
31693
+ console.log(`
31694
+ The Claude Code rule is only loaded for: ${result.claudeRulePaths.join(", ")} (change it with --paths, or --paths all to always load it).`);
34450
31695
  if (withoutMazUi)
34451
31696
  console.log(`
34452
31697
  maz-ui is not installed in this project: only the MCP server is registered, with the docs bundled in @maz-ui/mcp. Install maz-ui and run init again to add the rules.`);
@@ -34459,7 +31704,10 @@ Codex and Windsurf read AGENTS.md. To give them the MCP server too, add \`${serv
34459
31704
  return 0;
34460
31705
  }
34461
31706
  async function runReview(values, positionals, cwd) {
34462
- const context = createContext({ cwd, docsDir: typeof values.docs === "string" ? resolve$1(values.docs) : void 0 });
31707
+ const context = createContext({
31708
+ cwd,
31709
+ docsDir: typeof values.docs === "string" ? resolve$1(values.docs) : void 0
31710
+ });
34463
31711
  const framework = values.framework;
34464
31712
  const [{ countBySeverity, formatFindings }, { REVIEWABLE_EXTENSIONS, reviewFiles }] = await Promise.all([import('../chunks/index.mjs'), import('../chunks/files.mjs')]);
34465
31713
  if (values.hook) {
@@ -34467,7 +31715,12 @@ async function runReview(values, positionals, cwd) {
34467
31715
  const file = input.tool_input?.file_path;
34468
31716
  if (!file || !REVIEWABLE_EXTENSIONS.includes(file.split(".").pop() ?? "") || /[\\/](?:node_modules|dist|\.nuxt|\.output)[\\/]/.test(file))
34469
31717
  return 0;
34470
- const { reviews: reviews2 } = await reviewFiles([file], { knowledge: context.knowledge, cwd: input.cwd ?? cwd, framework, minSeverity: "warning" });
31718
+ const { reviews: reviews2 } = await reviewFiles([file], {
31719
+ knowledge: context.knowledge,
31720
+ cwd: input.cwd ?? cwd,
31721
+ framework,
31722
+ minSeverity: "warning"
31723
+ });
34471
31724
  const findings = reviews2.flatMap((review) => review.findings);
34472
31725
  if (findings.length === 0)
34473
31726
  return 0;
@@ -34488,7 +31741,12 @@ Fix these maz-ui issues (see the maz-ui MCP tools), or add a \`maz-ui-review-ign
34488
31741
  });
34489
31742
  const totals = countBySeverity(reviews.flatMap((review) => review.findings));
34490
31743
  if (values.format === "json") {
34491
- console.log(JSON.stringify({ version: context.knowledge.version, totals, truncated, files: reviews }, null, 2));
31744
+ console.log(JSON.stringify({
31745
+ version: context.knowledge.version,
31746
+ totals,
31747
+ truncated,
31748
+ files: reviews
31749
+ }, null, 2));
34492
31750
  } else {
34493
31751
  for (const review of reviews.filter((entry) => entry.findings.length > 0)) console.log(`${formatFindings(review.findings, review.file)}
34494
31752
  `);
@@ -34506,6 +31764,7 @@ async function runCli(argv = process.argv.slice(2)) {
34506
31764
  "docs": { type: "string" },
34507
31765
  "cwd": { type: "string" },
34508
31766
  "targets": { type: "string" },
31767
+ "paths": { type: "string" },
34509
31768
  "no-rules": { type: "boolean" },
34510
31769
  "no-mcp": { type: "boolean" },
34511
31770
  "dry-run": { type: "boolean" },
@@ -34531,14 +31790,20 @@ async function runCli(argv = process.argv.slice(2)) {
34531
31790
  }
34532
31791
  switch (command) {
34533
31792
  case "serve":
34534
- await startStdioServer({ cwd, docsDir: values.docs ? resolve$1(values.docs) : void 0 });
31793
+ await startStdioServer({
31794
+ cwd,
31795
+ docsDir: values.docs ? resolve$1(values.docs) : void 0
31796
+ });
34535
31797
  return -1;
34536
31798
  case "init":
34537
31799
  return runInit(values, cwd);
34538
31800
  case "review":
34539
31801
  return runReview(values, rest, cwd);
34540
31802
  case "search": {
34541
- const context = createContext({ cwd, docsDir: values.docs ? resolve$1(values.docs) : void 0 });
31803
+ const context = createContext({
31804
+ cwd,
31805
+ docsDir: values.docs ? resolve$1(values.docs) : void 0
31806
+ });
34542
31807
  console.log(searchDocs(context, { query: rest.join(" ") || "button" }));
34543
31808
  return 0;
34544
31809
  }