proxitor 0.8.0 → 0.9.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dist.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  import { o as __commonJSMin } from "./cli.mjs";
2
- import V, { stdin, stdout } from "node:process";
2
+ import process$1, { stdin, stdout } from "node:process";
3
3
  import { ReadStream } from "node:tty";
4
- import { stripVTControlCharacters, styleText } from "node:util";
4
+ import { styleText } from "node:util";
5
5
  import "node:fs";
6
6
  import "node:path";
7
- import * as b from "node:readline";
8
- import G from "node:readline";
7
+ import * as l from "node:readline";
8
+ import f from "node:readline";
9
9
  //#region node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
10
10
  const getCodePointsLength = (() => {
11
11
  const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
@@ -288,7 +288,7 @@ function wrapAnsi(string, columns, options) {
288
288
  return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
289
289
  }
290
290
  //#endregion
291
- //#region node_modules/.pnpm/@clack+core@1.4.0/node_modules/@clack/core/dist/index.mjs
291
+ //#region node_modules/.pnpm/@clack+core@1.4.1/node_modules/@clack/core/dist/index.mjs
292
292
  var import_src = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
293
293
  const ESC = "\x1B";
294
294
  const CSI = `${ESC}[`;
@@ -341,12 +341,12 @@ var import_src = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
341
341
  beep
342
342
  };
343
343
  })))();
344
- function f(r, t, s) {
345
- if (!s.some((o) => !o.disabled)) return r;
346
- const e = r + t, i = Math.max(s.length - 1, 0), n = e < 0 ? i : e > i ? 0 : e;
347
- return s[n].disabled ? f(n, t < 0 ? -1 : 1, s) : n;
344
+ function findCursor(s, o, l) {
345
+ if (!l.some((r) => !r.disabled)) return s;
346
+ const t = s + o, n = Math.max(l.length - 1, 0), e = t < 0 ? n : t > n ? 0 : t;
347
+ return l[e].disabled ? findCursor(e, o < 0 ? -1 : 1, l) : e;
348
348
  }
349
- const h = {
349
+ const settings = {
350
350
  actions: new Set([
351
351
  "up",
352
352
  "down",
@@ -356,7 +356,7 @@ const h = {
356
356
  "enter",
357
357
  "cancel"
358
358
  ]),
359
- aliases: new Map([
359
+ aliases: /* @__PURE__ */ new Map([
360
360
  ["k", "up"],
361
361
  ["j", "down"],
362
362
  ["h", "left"],
@@ -368,7 +368,7 @@ const h = {
368
368
  cancel: "Canceled",
369
369
  error: "Something went wrong"
370
370
  },
371
- withGuide: !0,
371
+ withGuide: true,
372
372
  date: {
373
373
  monthNames: [...[
374
374
  "January",
@@ -387,95 +387,96 @@ const h = {
387
387
  messages: {
388
388
  required: "Please enter a valid date",
389
389
  invalidMonth: "There are only 12 months in a year",
390
- invalidDay: (r, t) => `There are only ${r} days in ${t}`,
391
- afterMin: (r) => `Date must be on or after ${r.toISOString().slice(0, 10)}`,
392
- beforeMax: (r) => `Date must be on or before ${r.toISOString().slice(0, 10)}`
390
+ invalidDay: (n, e) => `There are only ${n} days in ${e}`,
391
+ afterMin: (n) => `Date must be on or after ${n.toISOString().slice(0, 10)}`,
392
+ beforeMax: (n) => `Date must be on or before ${n.toISOString().slice(0, 10)}`
393
393
  }
394
394
  }
395
395
  };
396
- function C(r, t) {
397
- if (typeof r == "string") return h.aliases.get(r) === t;
398
- for (const s of r) if (s !== void 0 && C(s, t)) return !0;
399
- return !1;
396
+ function isActionKey(n, e) {
397
+ if (typeof n == "string") return settings.aliases.get(n) === e;
398
+ for (const s of n) if (s !== void 0 && isActionKey(s, e)) return true;
399
+ return false;
400
400
  }
401
- function Y$1(r, t) {
402
- if (r === t) return;
403
- const s = r.split(`
404
- `), e = t.split(`
405
- `), i = Math.max(s.length, e.length), n = [];
406
- for (let o = 0; o < i; o++) s[o] !== e[o] && n.push(o);
401
+ function diffLines(i, s) {
402
+ if (i === s) return;
403
+ const e = i.split(`
404
+ `), t = s.split(`
405
+ `), r = Math.max(e.length, t.length), f = [];
406
+ for (let n = 0; n < r; n++) e[n] !== t[n] && f.push(n);
407
407
  return {
408
- lines: n,
409
- numLinesBefore: s.length,
410
- numLinesAfter: e.length,
411
- numLines: i
408
+ lines: f,
409
+ numLinesBefore: e.length,
410
+ numLinesAfter: t.length,
411
+ numLines: r
412
412
  };
413
413
  }
414
- const q$1 = globalThis.process.platform.startsWith("win"), k = Symbol("clack:cancel");
415
- function R(r) {
416
- return r === k;
414
+ const R = globalThis.process.platform.startsWith("win");
415
+ const CANCEL_SYMBOL = Symbol("clack:cancel");
416
+ function isCancel(e) {
417
+ return e === CANCEL_SYMBOL;
417
418
  }
418
- function w$1(r, t) {
419
- const s = r;
420
- s.isTTY && s.setRawMode(t);
419
+ function setRawMode(e, r) {
420
+ const o = e;
421
+ o.isTTY && o.setRawMode(r);
421
422
  }
422
- function W({ input: r = stdin, output: t = stdout, overwrite: s = !0, hideCursor: e = !0 } = {}) {
423
- const i = b.createInterface({
424
- input: r,
425
- output: t,
423
+ function block({ input: e = stdin, output: r = stdout, overwrite: o = true, hideCursor: t = true } = {}) {
424
+ const s = l.createInterface({
425
+ input: e,
426
+ output: r,
426
427
  prompt: "",
427
428
  tabSize: 1
428
429
  });
429
- b.emitKeypressEvents(r, i), r instanceof ReadStream && r.isTTY && r.setRawMode(!0);
430
- const n = (o, { name: u, sequence: a }) => {
431
- if (C([
432
- String(o),
433
- u,
434
- a
430
+ l.emitKeypressEvents(e, s), e instanceof ReadStream && e.isTTY && e.setRawMode(true);
431
+ const n = (f, { name: a, sequence: p }) => {
432
+ if (isActionKey([
433
+ String(f),
434
+ a,
435
+ p
435
436
  ], "cancel")) {
436
- e && t.write(import_src.cursor.show), process.exit(0);
437
+ t && r.write(import_src.cursor.show), process.exit(0);
437
438
  return;
438
439
  }
439
- if (!s) return;
440
- const c = u === "return" ? 0 : -1, y = u === "return" ? -1 : 0;
441
- b.moveCursor(t, c, y, () => {
442
- b.clearLine(t, 1, () => {
443
- r.once("keypress", n);
440
+ if (!o) return;
441
+ const i = a === "return" ? 0 : -1, m = a === "return" ? -1 : 0;
442
+ l.moveCursor(r, i, m, () => {
443
+ l.clearLine(r, 1, () => {
444
+ e.once("keypress", n);
444
445
  });
445
446
  });
446
447
  };
447
- return e && t.write(import_src.cursor.hide), r.once("keypress", n), () => {
448
- r.off("keypress", n), e && t.write(import_src.cursor.show), r instanceof ReadStream && r.isTTY && !q$1 && r.setRawMode(!1), i.terminal = !1, i.close();
448
+ return t && r.write(import_src.cursor.hide), e.once("keypress", n), () => {
449
+ e.off("keypress", n), t && r.write(import_src.cursor.show), e instanceof ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
449
450
  };
450
451
  }
451
- const A = (r) => "columns" in r && typeof r.columns == "number" ? r.columns : 80, L = (r) => "rows" in r && typeof r.rows == "number" ? r.rows : 20;
452
- function B(r, t, s, e = s, i = s, n) {
453
- return wrapAnsi(t, A(r ?? stdout) - s.length, {
454
- hard: !0,
455
- trim: !1
452
+ const getColumns = (e) => "columns" in e && typeof e.columns == "number" ? e.columns : 80, getRows = (e) => "rows" in e && typeof e.rows == "number" ? e.rows : 20;
453
+ function wrapTextWithPrefix(e, r, o, t = o, s = o, n) {
454
+ return wrapAnsi(r, getColumns(e ?? stdout) - o.length, {
455
+ hard: true,
456
+ trim: false
456
457
  }).split(`
457
- `).map((u, a, l) => {
458
- const c = n ? n(u, a) : u;
459
- return a === 0 ? `${e}${c}` : a === l.length - 1 ? `${i}${c}` : `${s}${c}`;
458
+ `).map((c, i, m) => {
459
+ const d = n ? n(c, i) : c;
460
+ return i === 0 ? `${t}${d}` : i === m.length - 1 ? `${s}${d}` : `${o}${d}`;
460
461
  }).join(`
461
462
  `);
462
463
  }
463
- function P$1(r, t) {
464
- if ("~standard" in r) {
465
- const s = r["~standard"].validate(t);
466
- if (s instanceof Promise) throw new TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");
467
- return s.issues?.at(0)?.message;
464
+ function runValidation(e, n) {
465
+ if ("~standard" in e) {
466
+ const a = e["~standard"].validate(n);
467
+ if (a instanceof Promise) throw new TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");
468
+ return a.issues?.at(0)?.message;
468
469
  }
469
- return r(t);
470
+ return e(n);
470
471
  }
471
- var m = class {
472
+ var V = class {
472
473
  input;
473
474
  output;
474
475
  _abortSignal;
475
476
  rl;
476
477
  opts;
477
478
  _render;
478
- _track = !1;
479
+ _track = false;
479
480
  _prevFrame = "";
480
481
  _subscribers = /* @__PURE__ */ new Map();
481
482
  _cursor = 0;
@@ -483,131 +484,153 @@ var m = class {
483
484
  error = "";
484
485
  value;
485
486
  userInput = "";
486
- constructor(t, s = !0) {
487
- const { input: e = stdin, output: i = stdout, render: n, signal: o, ...u } = t;
488
- this.opts = u, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = s, this._abortSignal = o, this.input = e, this.output = i;
487
+ constructor(t, e = true) {
488
+ const { input: i = stdin, output: n = stdout, render: s, signal: r, ...o } = t;
489
+ this.opts = o, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = s.bind(this), this._track = e, this._abortSignal = r, this.input = i, this.output = n;
489
490
  }
491
+ /**
492
+ * Unsubscribe all listeners
493
+ */
490
494
  unsubscribe() {
491
495
  this._subscribers.clear();
492
496
  }
493
- setSubscriber(t, s) {
494
- const e = this._subscribers.get(t) ?? [];
495
- e.push(s), this._subscribers.set(t, e);
497
+ /**
498
+ * Set a subscriber with opts
499
+ * @param event - The event name
500
+ */
501
+ setSubscriber(t, e) {
502
+ const i = this._subscribers.get(t) ?? [];
503
+ i.push(e), this._subscribers.set(t, i);
496
504
  }
497
- on(t, s) {
498
- this.setSubscriber(t, { cb: s });
505
+ /**
506
+ * Subscribe to an event
507
+ * @param event - The event name
508
+ * @param cb - The callback
509
+ */
510
+ on(t, e) {
511
+ this.setSubscriber(t, { cb: e });
499
512
  }
500
- once(t, s) {
513
+ /**
514
+ * Subscribe to an event once
515
+ * @param event - The event name
516
+ * @param cb - The callback
517
+ */
518
+ once(t, e) {
501
519
  this.setSubscriber(t, {
502
- cb: s,
503
- once: !0
520
+ cb: e,
521
+ once: true
504
522
  });
505
523
  }
506
- emit(t, ...s) {
507
- const e = this._subscribers.get(t) ?? [], i = [];
508
- for (const n of e) n.cb(...s), n.once && i.push(() => e.splice(e.indexOf(n), 1));
509
- for (const n of i) n();
524
+ /**
525
+ * Emit an event with data
526
+ * @param event - The event name
527
+ * @param data - The data to pass to the callback
528
+ */
529
+ emit(t, ...e) {
530
+ const i = this._subscribers.get(t) ?? [], n = [];
531
+ for (const s of i) s.cb(...e), s.once && n.push(() => i.splice(i.indexOf(s), 1));
532
+ for (const s of n) s();
510
533
  }
511
534
  prompt() {
512
535
  return new Promise((t) => {
513
536
  if (this._abortSignal) {
514
- if (this._abortSignal.aborted) return this.state = "cancel", this.close(), t(k);
537
+ if (this._abortSignal.aborted) return this.state = "cancel", this.close(), t(CANCEL_SYMBOL);
515
538
  this._abortSignal.addEventListener("abort", () => {
516
539
  this.state = "cancel", this.close();
517
- }, { once: !0 });
540
+ }, { once: true });
518
541
  }
519
- this.rl = G.createInterface({
542
+ this.rl = f.createInterface({
520
543
  input: this.input,
521
544
  tabSize: 2,
522
545
  prompt: "",
523
546
  escapeCodeTimeout: 50,
524
- terminal: !0
525
- }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, !0), this.input.on("keypress", this.onKeypress), w$1(this.input, !0), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
526
- this.output.write(import_src.cursor.show), this.output.off("resize", this.render), w$1(this.input, !1), t(this.value);
547
+ terminal: true
548
+ }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), setRawMode(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
549
+ this.output.write(import_src.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(this.value);
527
550
  }), this.once("cancel", () => {
528
- this.output.write(import_src.cursor.show), this.output.off("resize", this.render), w$1(this.input, !1), t(k);
551
+ this.output.write(import_src.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(CANCEL_SYMBOL);
529
552
  });
530
553
  });
531
554
  }
532
- _isActionKey(t, s) {
555
+ _isActionKey(t, e) {
533
556
  return t === " ";
534
557
  }
535
- _shouldSubmit(t, s) {
536
- return !0;
558
+ _shouldSubmit(t, e) {
559
+ return true;
537
560
  }
538
561
  _setValue(t) {
539
562
  this.value = t, this.emit("value", this.value);
540
563
  }
541
- _setUserInput(t, s) {
542
- this.userInput = t ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
564
+ _setUserInput(t, e) {
565
+ this.userInput = t ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
543
566
  }
544
567
  _clearUserInput() {
545
568
  this.rl?.write(null, {
546
- ctrl: !0,
569
+ ctrl: true,
547
570
  name: "u"
548
571
  }), this._setUserInput("");
549
572
  }
550
- onKeypress(t, s) {
551
- if (this._track && s.name !== "return" && (s.name && this._isActionKey(t, s) && this.rl?.write(null, {
552
- ctrl: !0,
573
+ onKeypress(t, e) {
574
+ if (this._track && e.name !== "return" && (e.name && this._isActionKey(t, e) && this.rl?.write(null, {
575
+ ctrl: true,
553
576
  name: "h"
554
- }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), s?.name && (!this._track && h.aliases.has(s.name) && this.emit("cursor", h.aliases.get(s.name)), h.actions.has(s.name) && this.emit("cursor", s.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t, s), s?.name === "return" && this._shouldSubmit(t, s)) {
577
+ }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track && settings.aliases.has(e.name) && this.emit("cursor", settings.aliases.get(e.name)), settings.actions.has(e.name) && this.emit("cursor", e.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t, e), e?.name === "return" && this._shouldSubmit(t, e)) {
555
578
  if (this.opts.validate) {
556
- const e = P$1(this.opts.validate, this.value);
557
- e && (this.error = e instanceof Error ? e.message : e, this.state = "error", this.rl?.write(this.userInput));
579
+ const i = runValidation(this.opts.validate, this.value);
580
+ i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
558
581
  }
559
582
  this.state !== "error" && (this.state = "submit");
560
583
  }
561
- C([
584
+ isActionKey([
562
585
  t,
563
- s?.name,
564
- s?.sequence
586
+ e?.name,
587
+ e?.sequence
565
588
  ], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
566
589
  }
567
590
  close() {
568
591
  this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
569
- `), w$1(this.input, !1), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
592
+ `), setRawMode(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
570
593
  }
571
594
  restoreCursor() {
572
595
  const t = wrapAnsi(this._prevFrame, process.stdout.columns, {
573
- hard: !0,
574
- trim: !1
596
+ hard: true,
597
+ trim: false
575
598
  }).split(`
576
599
  `).length - 1;
577
600
  this.output.write(import_src.cursor.move(-999, t * -1));
578
601
  }
579
602
  render() {
580
603
  const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
581
- hard: !0,
582
- trim: !1
604
+ hard: true,
605
+ trim: false
583
606
  });
584
607
  if (t !== this._prevFrame) {
585
608
  if (this.state === "initial") this.output.write(import_src.cursor.hide);
586
609
  else {
587
- const s = Y$1(this._prevFrame, t), e = L(this.output);
588
- if (this.restoreCursor(), s) {
589
- const i = Math.max(0, s.numLinesAfter - e), n = Math.max(0, s.numLinesBefore - e);
590
- let o = s.lines.find((u) => u >= i);
591
- if (o === void 0) {
610
+ const e = diffLines(this._prevFrame, t), i = getRows(this.output);
611
+ if (this.restoreCursor(), e) {
612
+ const n = Math.max(0, e.numLinesAfter - i), s = Math.max(0, e.numLinesBefore - i);
613
+ let r = e.lines.find((o) => o >= n);
614
+ if (r === void 0) {
592
615
  this._prevFrame = t;
593
616
  return;
594
617
  }
595
- if (s.lines.length === 1) {
596
- this.output.write(import_src.cursor.move(0, o - n)), this.output.write(import_src.erase.lines(1));
597
- const u = t.split(`
618
+ if (e.lines.length === 1) {
619
+ this.output.write(import_src.cursor.move(0, r - s)), this.output.write(import_src.erase.lines(1));
620
+ const o = t.split(`
598
621
  `);
599
- this.output.write(u[o]), this._prevFrame = t, this.output.write(import_src.cursor.move(0, u.length - o - 1));
622
+ this.output.write(o[r]), this._prevFrame = t, this.output.write(import_src.cursor.move(0, o.length - r - 1));
600
623
  return;
601
- } else if (s.lines.length > 1) {
602
- if (i < n) o = i;
624
+ } else if (e.lines.length > 1) {
625
+ if (n < s) r = n;
603
626
  else {
604
- const a = o - n;
605
- a > 0 && this.output.write(import_src.cursor.move(0, a));
627
+ const h = r - s;
628
+ h > 0 && this.output.write(import_src.cursor.move(0, h));
606
629
  }
607
630
  this.output.write(import_src.erase.down());
608
- const u = t.split(`
609
- `).slice(o);
610
- this.output.write(u.join(`
631
+ const f = t.split(`
632
+ `).slice(r);
633
+ this.output.write(f.join(`
611
634
  `)), this._prevFrame = t;
612
635
  return;
613
636
  }
@@ -618,81 +641,81 @@ var m = class {
618
641
  }
619
642
  }
620
643
  };
621
- function J(r, t) {
622
- if (r === void 0 || t.length === 0) return 0;
623
- const s = t.findIndex((e) => e.value === r);
624
- return s !== -1 ? s : 0;
644
+ function p$1(l, e) {
645
+ if (l === void 0 || e.length === 0) return 0;
646
+ const i = e.findIndex((s) => s.value === l);
647
+ return i !== -1 ? i : 0;
625
648
  }
626
- function H$1(r, t) {
627
- return (t.label ?? String(t.value)).toLowerCase().includes(r.toLowerCase());
649
+ function g(l, e) {
650
+ return (e.label ?? String(e.value)).toLowerCase().includes(l.toLowerCase());
628
651
  }
629
- function Q$1(r, t) {
630
- if (t) return r ? t : t[0];
652
+ function m(l, e) {
653
+ if (e) return l ? e : e[0];
631
654
  }
632
- let X = class extends m {
655
+ let T$1 = class T extends V {
633
656
  filteredOptions;
634
657
  multiple;
635
- isNavigating = !1;
658
+ isNavigating = false;
636
659
  selectedValues = [];
637
660
  focusedValue;
638
- #s = 0;
639
- #r = "";
661
+ #e = 0;
662
+ #s = "";
640
663
  #t;
664
+ #i;
641
665
  #n;
642
- #u;
643
666
  get cursor() {
644
- return this.#s;
667
+ return this.#e;
645
668
  }
646
669
  get userInputWithCursor() {
647
670
  if (!this.userInput) return styleText(["inverse", "hidden"], "_");
648
671
  if (this._cursor >= this.userInput.length) return `${this.userInput}\u2588`;
649
- const t = this.userInput.slice(0, this._cursor), [s, ...e] = this.userInput.slice(this._cursor);
650
- return `${t}${styleText("inverse", s)}${e.join("")}`;
672
+ const e = this.userInput.slice(0, this._cursor), [t, ...i] = this.userInput.slice(this._cursor);
673
+ return `${e}${styleText("inverse", t)}${i.join("")}`;
651
674
  }
652
675
  get options() {
653
- return typeof this.#n == "function" ? this.#n() : this.#n;
676
+ return typeof this.#i == "function" ? this.#i() : this.#i;
654
677
  }
655
- constructor(t) {
656
- super(t), this.#n = t.options, this.#u = t.placeholder;
657
- const s = this.options;
658
- this.filteredOptions = [...s], this.multiple = t.multiple === !0, this.#t = typeof t.options == "function" ? t.filter : t.filter ?? H$1;
659
- let e;
660
- if (t.initialValue && Array.isArray(t.initialValue) ? this.multiple ? e = t.initialValue : e = t.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (e = [this.options[0].value]), e) for (const i of e) {
661
- const n = s.findIndex((o) => o.value === i);
662
- n !== -1 && (this.toggleSelected(i), this.#s = n);
678
+ constructor(e) {
679
+ super(e), this.#i = e.options, this.#n = e.placeholder;
680
+ const t = this.options;
681
+ this.filteredOptions = [...t], this.multiple = e.multiple === true, this.#t = typeof e.options == "function" ? e.filter : e.filter ?? g;
682
+ let i;
683
+ if (e.initialValue && Array.isArray(e.initialValue) ? this.multiple ? i = e.initialValue : i = e.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (i = [this.options[0].value]), i) for (const s of i) {
684
+ const n = t.findIndex((o) => o.value === s);
685
+ n !== -1 && (this.toggleSelected(s), this.#e = n);
663
686
  }
664
- this.focusedValue = this.options[this.#s]?.value, this.on("key", (i, n) => this.#e(i, n)), this.on("userInput", (i) => this.#i(i));
687
+ this.focusedValue = this.options[this.#e]?.value, this.on("key", (s, n) => this.#l(s, n)), this.on("userInput", (s) => this.#u(s));
665
688
  }
666
- _isActionKey(t, s) {
667
- return t === " " || this.multiple && this.isNavigating && s.name === "space" && t !== void 0 && t !== "";
689
+ _isActionKey(e, t) {
690
+ return e === " " || this.multiple && this.isNavigating && t.name === "space" && e !== void 0 && e !== "";
668
691
  }
669
- #e(t, s) {
670
- const e = s.name === "up", i = s.name === "down", n = s.name === "return", o = this.userInput === "" || this.userInput === " ", u = this.#u, a = this.options, l = u !== void 0 && u !== "" && a.some((c) => !c.disabled && (this.#t ? this.#t(u, c) : !0));
671
- if (s.name === "tab" && o && l) {
672
- this.userInput === " " && this._clearUserInput(), this._setUserInput(u, !0), this.isNavigating = !1;
692
+ #l(e, t) {
693
+ const i = t.name === "up", s = t.name === "down", n = t.name === "return", o = this.userInput === "" || this.userInput === " ", u = this.#n, h = this.options, f = u !== void 0 && u !== "" && h.some((r) => !r.disabled && (this.#t ? this.#t(u, r) : true));
694
+ if (t.name === "tab" && o && f) {
695
+ this.userInput === " " && this._clearUserInput(), this._setUserInput(u, true), this.isNavigating = false;
673
696
  return;
674
697
  }
675
- e || i ? (this.#s = f(this.#s, e ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#s]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = !0) : n ? this.value = Q$1(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== void 0 && (s.name === "tab" || this.isNavigating && s.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = !1 : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = !1);
698
+ i || s ? (this.#e = findCursor(this.#e, i ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#e]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = true) : n ? this.value = m(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== void 0 && (t.name === "tab" || this.isNavigating && t.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
676
699
  }
677
700
  deselectAll() {
678
701
  this.selectedValues = [];
679
702
  }
680
- toggleSelected(t) {
681
- this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(t) ? this.selectedValues = this.selectedValues.filter((s) => s !== t) : this.selectedValues = [...this.selectedValues, t] : this.selectedValues = [t]);
703
+ toggleSelected(e) {
704
+ this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(e) ? this.selectedValues = this.selectedValues.filter((t) => t !== e) : this.selectedValues = [...this.selectedValues, e] : this.selectedValues = [e]);
682
705
  }
683
- #i(t) {
684
- if (t !== this.#r) {
685
- this.#r = t;
686
- const s = this.options;
687
- t && this.#t ? this.filteredOptions = s.filter((n) => this.#t?.(t, n)) : this.filteredOptions = [...s];
688
- const e = J(this.focusedValue, this.filteredOptions);
689
- this.#s = f(e, 0, this.filteredOptions);
690
- const i = this.filteredOptions[this.#s];
691
- i && !i.disabled ? this.focusedValue = i.value : this.focusedValue = void 0, this.multiple || (this.focusedValue !== void 0 ? this.toggleSelected(this.focusedValue) : this.deselectAll());
706
+ #u(e) {
707
+ if (e !== this.#s) {
708
+ this.#s = e;
709
+ const t = this.options;
710
+ e && this.#t ? this.filteredOptions = t.filter((n) => this.#t?.(e, n)) : this.filteredOptions = [...t];
711
+ const i = p$1(this.focusedValue, this.filteredOptions);
712
+ this.#e = findCursor(i, 0, this.filteredOptions);
713
+ const s = this.filteredOptions[this.#e];
714
+ s && !s.disabled ? this.focusedValue = s.value : this.focusedValue = void 0, this.multiple || (this.focusedValue !== void 0 ? this.toggleSelected(this.focusedValue) : this.deselectAll());
692
715
  }
693
716
  }
694
717
  };
695
- var Z = class extends m {
718
+ var r = class extends V {
696
719
  get cursor() {
697
720
  return this.value ? 0 : 1;
698
721
  }
@@ -700,59 +723,53 @@ var Z = class extends m {
700
723
  return this.cursor === 0;
701
724
  }
702
725
  constructor(t) {
703
- super(t, !1), this.value = !!t.initialValue, this.on("userInput", () => {
726
+ super(t, false), this.value = !!t.initialValue, this.on("userInput", () => {
704
727
  this.value = this._value;
705
- }), this.on("confirm", (s) => {
706
- this.output.write(import_src.cursor.move(0, -1)), this.value = s, this.state = "submit", this.close();
728
+ }), this.on("confirm", (i) => {
729
+ this.output.write(import_src.cursor.move(0, -1)), this.value = i, this.state = "submit", this.close();
707
730
  }), this.on("cursor", () => {
708
731
  this.value = !this.value;
709
732
  });
710
733
  }
711
734
  };
712
- new Set([
713
- "up",
714
- "down",
715
- "left",
716
- "right"
717
- ]);
718
- let ut$1 = class extends m {
735
+ let a$1 = class a extends V {
719
736
  options;
720
737
  cursor = 0;
721
738
  get _value() {
722
739
  return this.options[this.cursor].value;
723
740
  }
724
741
  get _enabledOptions() {
725
- return this.options.filter((t) => t.disabled !== !0);
742
+ return this.options.filter((e) => e.disabled !== true);
726
743
  }
727
744
  toggleAll() {
728
- const t = this._enabledOptions, s = this.value !== void 0 && this.value.length === t.length;
729
- this.value = s ? [] : t.map((e) => e.value);
745
+ const e = this._enabledOptions, i = this.value !== void 0 && this.value.length === e.length;
746
+ this.value = i ? [] : e.map((t) => t.value);
730
747
  }
731
748
  toggleInvert() {
732
- const t = this.value;
733
- if (!t) return;
734
- const s = this._enabledOptions.filter((e) => !t.includes(e.value));
735
- this.value = s.map((e) => e.value);
749
+ const e = this.value;
750
+ if (!e) return;
751
+ const i = this._enabledOptions.filter((t) => !e.includes(t.value));
752
+ this.value = i.map((t) => t.value);
736
753
  }
737
754
  toggleValue() {
738
755
  this.value === void 0 && (this.value = []);
739
- const t = this.value.includes(this._value);
740
- this.value = t ? this.value.filter((s) => s !== this._value) : [...this.value, this._value];
756
+ const e = this.value.includes(this._value);
757
+ this.value = e ? this.value.filter((i) => i !== this._value) : [...this.value, this._value];
741
758
  }
742
- constructor(t) {
743
- super(t, !1), this.options = t.options, this.value = [...t.initialValues ?? []];
744
- const s = Math.max(this.options.findIndex(({ value: e }) => e === t.cursorAt), 0);
745
- this.cursor = this.options[s].disabled ? f(s, 1, this.options) : s, this.on("key", (e, i) => {
746
- i.name === "a" && this.toggleAll(), i.name === "i" && this.toggleInvert();
747
- }), this.on("cursor", (e) => {
748
- switch (e) {
759
+ constructor(e) {
760
+ super(e, false), this.options = e.options, this.value = [...e.initialValues ?? []];
761
+ const i = Math.max(this.options.findIndex(({ value: t }) => t === e.cursorAt), 0);
762
+ this.cursor = this.options[i].disabled ? findCursor(i, 1, this.options) : i, this.on("key", (t, l) => {
763
+ l.name === "a" && this.toggleAll(), l.name === "i" && this.toggleInvert();
764
+ }), this.on("cursor", (t) => {
765
+ switch (t) {
749
766
  case "left":
750
767
  case "up":
751
- this.cursor = f(this.cursor, -1, this.options);
768
+ this.cursor = findCursor(this.cursor, -1, this.options);
752
769
  break;
753
770
  case "down":
754
771
  case "right":
755
- this.cursor = f(this.cursor, 1, this.options);
772
+ this.cursor = findCursor(this.cursor, 1, this.options);
756
773
  break;
757
774
  case "space":
758
775
  this.toggleValue();
@@ -761,7 +778,7 @@ let ut$1 = class extends m {
761
778
  });
762
779
  }
763
780
  };
764
- var ht$1 = class extends m {
781
+ var a = class extends V {
765
782
  options;
766
783
  cursor = 0;
767
784
  get _selectedValue() {
@@ -771,30 +788,30 @@ var ht$1 = class extends m {
771
788
  this.value = this._selectedValue.value;
772
789
  }
773
790
  constructor(t) {
774
- super(t, !1), this.options = t.options;
775
- const s = this.options.findIndex(({ value: i }) => i === t.initialValue), e = s === -1 ? 0 : s;
776
- this.cursor = this.options[e].disabled ? f(e, 1, this.options) : e, this.changeValue(), this.on("cursor", (i) => {
777
- switch (i) {
791
+ super(t, false), this.options = t.options;
792
+ const i = this.options.findIndex(({ value: s }) => s === t.initialValue), e = i === -1 ? 0 : i;
793
+ this.cursor = this.options[e].disabled ? findCursor(e, 1, this.options) : e, this.changeValue(), this.on("cursor", (s) => {
794
+ switch (s) {
778
795
  case "left":
779
796
  case "up":
780
- this.cursor = f(this.cursor, -1, this.options);
797
+ this.cursor = findCursor(this.cursor, -1, this.options);
781
798
  break;
782
799
  case "down":
783
800
  case "right":
784
- this.cursor = f(this.cursor, 1, this.options);
801
+ this.cursor = findCursor(this.cursor, 1, this.options);
785
802
  break;
786
803
  }
787
804
  this.changeValue();
788
805
  });
789
806
  }
790
807
  };
791
- var ct$1 = class extends m {
808
+ var n = class extends V {
792
809
  get userInputWithCursor() {
793
810
  if (this.state === "submit") return this.userInput;
794
811
  const t = this.userInput;
795
812
  if (this.cursor >= t.length) return `${this.userInput}\u2588`;
796
- const s = t.slice(0, this.cursor), [e, ...i] = t.slice(this.cursor);
797
- return `${s}${styleText("inverse", e)}${i.join("")}`;
813
+ const e = t.slice(0, this.cursor), [s, ...r] = t.slice(this.cursor);
814
+ return `${e}${styleText("inverse", s)}${r.join("")}`;
798
815
  }
799
816
  get cursor() {
800
817
  return this._cursor;
@@ -803,250 +820,258 @@ var ct$1 = class extends m {
803
820
  super({
804
821
  ...t,
805
822
  initialUserInput: t.initialUserInput ?? t.initialValue
806
- }), this.on("userInput", (s) => {
807
- this._setValue(s);
823
+ }), this.on("userInput", (e) => {
824
+ this._setValue(e);
808
825
  }), this.on("finalize", () => {
809
826
  this.value || (this.value = t.defaultValue), this.value === void 0 && (this.value = "");
810
827
  });
811
828
  }
812
829
  };
813
830
  //#endregion
814
- //#region node_modules/.pnpm/@clack+prompts@1.5.0/node_modules/@clack/prompts/dist/index.mjs
815
- function se() {
816
- return V.platform !== "win32" ? V.env.TERM !== "linux" : !!V.env.CI || !!V.env.WT_SESSION || !!V.env.TERMINUS_SUBLIME || V.env.ConEmuTask === "{cmd::Cmder}" || V.env.TERM_PROGRAM === "Terminus-Sublime" || V.env.TERM_PROGRAM === "vscode" || V.env.TERM === "xterm-256color" || V.env.TERM === "alacritty" || V.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
831
+ //#region node_modules/.pnpm/@clack+prompts@1.5.1/node_modules/@clack/prompts/dist/index.mjs
832
+ function isUnicodeSupported() {
833
+ if (process$1.platform !== "win32") return process$1.env.TERM !== "linux";
834
+ return Boolean(process$1.env.CI) || Boolean(process$1.env.WT_SESSION) || Boolean(process$1.env.TERMINUS_SUBLIME) || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
817
835
  }
818
- const tt = se(), at = () => process.env.CI === "true", w = (t, i) => tt ? t : i, _t = w("◆", "*"), ut = w("■", "x"), lt = w("▲", "x"), H = w("◇", "o"), ct = w("┌", "T"), $ = w("│", "|"), x = w("└", "—"), z = w("●", ">"), U = w("○", " "), et = w("◻", "[•]"), K = w("◼", "[+]"), Y = w("◻", "[ ]"), st = w("─", "-"), $t = w("╮", "+"), Mt = w("├", "+"), dt = w("╯", "+"), ht = w("╰", "+"), pt = w("●", "•"), mt = w("◆", "*"), gt = w("▲", "!"), yt = w("■", "x"), P = (t) => {
819
- switch (t) {
836
+ const unicode = isUnicodeSupported(), isCI = () => process.env.CI === "true", unicodeOr = (e, o) => unicode ? e : o, S_STEP_ACTIVE = unicodeOr("◆", "*"), S_STEP_CANCEL = unicodeOr("■", "x"), S_STEP_ERROR = unicodeOr("▲", "x"), S_STEP_SUBMIT = unicodeOr("◇", "o"), S_BAR_START = unicodeOr("┌", "T"), S_BAR = unicodeOr("│", "|"), S_BAR_END = unicodeOr("└", "—"), S_RADIO_ACTIVE = unicodeOr("●", ">"), S_RADIO_INACTIVE = unicodeOr("○", " "), S_CHECKBOX_ACTIVE = unicodeOr("◻", "[•]"), S_CHECKBOX_SELECTED = unicodeOr("◼", "[+]"), S_CHECKBOX_INACTIVE = unicodeOr("◻", "[ ]"), S_BAR_H = unicodeOr("─", "-"), S_CORNER_TOP_RIGHT = unicodeOr("╮", "+"), S_CONNECT_LEFT = unicodeOr("├", "+"), S_CORNER_BOTTOM_RIGHT = unicodeOr("╯", "+"), S_CORNER_BOTTOM_LEFT = unicodeOr("╰", "+"), S_INFO = unicodeOr("●", "•"), S_SUCCESS = unicodeOr("◆", "*"), S_WARN = unicodeOr("▲", "!"), S_ERROR = unicodeOr("■", "x"), symbol = (e) => {
837
+ switch (e) {
820
838
  case "initial":
821
- case "active": return styleText("cyan", _t);
822
- case "cancel": return styleText("red", ut);
823
- case "error": return styleText("yellow", lt);
824
- case "submit": return styleText("green", H);
839
+ case "active": return styleText("cyan", S_STEP_ACTIVE);
840
+ case "cancel": return styleText("red", S_STEP_CANCEL);
841
+ case "error": return styleText("yellow", S_STEP_ERROR);
842
+ case "submit": return styleText("green", S_STEP_SUBMIT);
825
843
  }
826
- }, ft = (t) => {
827
- switch (t) {
844
+ }, symbolBar = (e) => {
845
+ switch (e) {
828
846
  case "initial":
829
- case "active": return styleText("cyan", $);
830
- case "cancel": return styleText("red", $);
831
- case "error": return styleText("yellow", $);
832
- case "submit": return styleText("green", $);
847
+ case "active": return styleText("cyan", S_BAR);
848
+ case "cancel": return styleText("red", S_BAR);
849
+ case "error": return styleText("yellow", S_BAR);
850
+ case "submit": return styleText("green", S_BAR);
833
851
  }
834
- }, Pt = (t, i, s, r, u, n = !1) => {
835
- let a = i, c = 0;
836
- if (n) for (let o = r - 1; o >= s && (a -= t[o].length, c++, !(a <= u)); o--);
837
- else for (let o = s; o < r && (a -= t[o].length, c++, !(a <= u)); o++);
852
+ };
853
+ const E$1 = (l, o, g, c, h, O = false) => {
854
+ let r = o, w = 0;
855
+ if (O) for (let i = c - 1; i >= g && (r -= l[i].length, w++, !(r <= h)); i--);
856
+ else for (let i = g; i < c && (r -= l[i].length, w++, !(r <= h)); i++);
838
857
  return {
839
- lineCount: a,
840
- removals: c
858
+ lineCount: r,
859
+ removals: w
841
860
  };
842
- }, F = ({ cursor: t, options: i, style: s, output: r = process.stdout, maxItems: u = Number.POSITIVE_INFINITY, columnPadding: n = 0, rowPadding: a = 4 }) => {
843
- const c = A(r) - n, o = L(r), l = styleText("dim", "..."), d = Math.max(o - a, 0), g = Math.max(Math.min(u, d), 5);
861
+ };
862
+ const limitOptions = ({ cursor: l, options: o, style: g, output: c = process.stdout, maxItems: h = Number.POSITIVE_INFINITY, columnPadding: O = 0, rowPadding: r = 4 }) => {
863
+ const i = getColumns(c) - O, I = getRows(c), C = styleText("dim", "..."), x = Math.max(I - r, 0), m = Math.max(Math.min(h, x), 5);
844
864
  let p = 0;
845
- t >= g - 3 && (p = Math.max(Math.min(t - g + 3, i.length - g), 0));
846
- let f = g < i.length && p > 0, h = g < i.length && p + g < i.length;
847
- const I = Math.min(p + g, i.length), m = [];
848
- let y = 0;
849
- f && y++, h && y++;
850
- const v = p + (f ? 1 : 0), C = I - (h ? 1 : 0);
851
- for (let b = v; b < C; b++) {
852
- const G = wrapAnsi(s(i[b], b === t), c, {
853
- hard: !0,
854
- trim: !1
865
+ l >= m - 3 && (p = Math.max(Math.min(l - m + 3, o.length - m), 0));
866
+ let f = m < o.length && p > 0, u = m < o.length && p + m < o.length;
867
+ const W = Math.min(p + m, o.length), e = [];
868
+ let d = 0;
869
+ f && d++, u && d++;
870
+ const v = p + (f ? 1 : 0), P = W - (u ? 1 : 0);
871
+ for (let t = v; t < P; t++) {
872
+ const n = wrapAnsi(g(o[t], t === l), i, {
873
+ hard: true,
874
+ trim: false
855
875
  }).split(`
856
876
  `);
857
- m.push(G), y += G.length;
877
+ e.push(n), d += n.length;
858
878
  }
859
- if (y > d) {
860
- let b = 0, G = 0, M = y;
861
- const N = t - v;
862
- let O = d;
863
- const j = () => Pt(m, M, 0, N, O), k = () => Pt(m, M, N + 1, m.length, O, !0);
864
- f ? ({lineCount: M, removals: b} = j(), M > O && (h || (O -= 1), {lineCount: M, removals: G} = k())) : (h || (O -= 1), {lineCount: M, removals: G} = k(), M > O && (O -= 1, {lineCount: M, removals: b} = j())), b > 0 && (f = !0, m.splice(0, b)), G > 0 && (h = !0, m.splice(m.length - G, G));
879
+ if (d > x) {
880
+ let t = 0, n = 0, s = d;
881
+ const M = l - v;
882
+ let a = x;
883
+ const T = () => E$1(e, s, 0, M, a), L = () => E$1(e, s, M + 1, e.length, a, true);
884
+ f ? ({lineCount: s, removals: t} = T(), s > a && (u || (a -= 1), {lineCount: s, removals: n} = L())) : (u || (a -= 1), {lineCount: s, removals: n} = L(), s > a && (a -= 1, {lineCount: s, removals: t} = T())), t > 0 && (f = true, e.splice(0, t)), n > 0 && (u = true, e.splice(e.length - n, n));
865
885
  }
866
- const S = [];
867
- f && S.push(l);
868
- for (const b of m) for (const G of b) S.push(G);
869
- return h && S.push(l), S;
886
+ const b = [];
887
+ f && b.push(C);
888
+ for (const t of e) for (const n of t) b.push(n);
889
+ return u && b.push(C), b;
870
890
  };
871
- function Rt(t) {
891
+ function P(t) {
872
892
  return t.label ?? String(t.value ?? "");
873
893
  }
874
- function At(t, i) {
875
- if (!t) return !0;
876
- const s = (i.label ?? String(i.value ?? "")).toLowerCase(), r = (i.hint ?? "").toLowerCase(), u = String(i.value).toLowerCase(), n = t.toLowerCase();
877
- return s.includes(n) || r.includes(n) || u.includes(n);
894
+ function E(t, c) {
895
+ if (!t) return true;
896
+ const n = (c.label ?? String(c.value ?? "")).toLowerCase(), i = (c.hint ?? "").toLowerCase(), l = String(c.value).toLowerCase(), o = t.toLowerCase();
897
+ return n.includes(o) || i.includes(o) || l.includes(o);
878
898
  }
879
- function ie(t, i) {
880
- const s = [];
881
- for (const r of i) t.includes(r.value) && s.push(r);
882
- return s;
899
+ function N(t, c) {
900
+ const n = [];
901
+ for (const i of c) t.includes(i.value) && n.push(i);
902
+ return n;
883
903
  }
884
- const Vt = (t) => new X({
904
+ const autocomplete = (t) => new T$1({
885
905
  options: t.options,
886
906
  initialValue: t.initialValue ? [t.initialValue] : void 0,
887
907
  initialUserInput: t.initialUserInput,
888
908
  placeholder: t.placeholder,
889
- filter: t.filter ?? ((i, s) => At(i, s)),
909
+ filter: t.filter ?? ((n, i) => E(n, i)),
890
910
  signal: t.signal,
891
911
  input: t.input,
892
912
  output: t.output,
893
913
  validate: t.validate,
894
914
  render() {
895
- const i = t.withGuide ?? h.withGuide, s = i ? [`${styleText("gray", $)}`, `${P(this.state)} ${t.message}`] : [`${P(this.state)} ${t.message}`], r = this.userInput, u = this.options, n = t.placeholder, a = r === "" && n !== void 0, c = (o, l) => {
896
- const d = Rt(o), g = o.hint && o.value === this.focusedValue ? styleText("dim", ` (${o.hint})`) : "";
897
- switch (l) {
898
- case "active": return `${styleText("green", z)} ${d}${g}`;
899
- case "inactive": return `${styleText("dim", U)} ${styleText("dim", d)}`;
900
- case "disabled": return `${styleText("gray", U)} ${styleText(["strikethrough", "gray"], d)}`;
915
+ const n = t.withGuide ?? settings.withGuide, i = n ? [`${styleText("gray", S_BAR)}`, `${symbol(this.state)} ${t.message}`] : [`${symbol(this.state)} ${t.message}`], l = this.userInput, o = this.options, m = t.placeholder, p = l === "" && m !== void 0, $ = (r, s) => {
916
+ const a = P(r), u = r.hint && r.value === this.focusedValue ? styleText("dim", ` (${r.hint})`) : "";
917
+ switch (s) {
918
+ case "active": return `${styleText("green", S_RADIO_ACTIVE)} ${a}${u}`;
919
+ case "inactive": return `${styleText("dim", S_RADIO_INACTIVE)} ${styleText("dim", a)}`;
920
+ case "disabled": return `${styleText("gray", S_RADIO_INACTIVE)} ${styleText(["strikethrough", "gray"], a)}`;
901
921
  }
902
922
  };
903
923
  switch (this.state) {
904
924
  case "submit": {
905
- const o = ie(this.selectedValues, u), l = o.length > 0 ? ` ${styleText("dim", o.map(Rt).join(", "))}` : "", d = i ? styleText("gray", $) : "";
906
- return `${s.join(`
925
+ const r = N(this.selectedValues, o), s = r.length > 0 ? ` ${styleText("dim", r.map(P).join(", "))}` : "", a = n ? styleText("gray", S_BAR) : "";
926
+ return `${i.join(`
907
927
  `)}
908
- ${d}${l}`;
928
+ ${a}${s}`;
909
929
  }
910
930
  case "cancel": {
911
- const o = r ? ` ${styleText(["strikethrough", "dim"], r)}` : "", l = i ? styleText("gray", $) : "";
912
- return `${s.join(`
931
+ const r = l ? ` ${styleText(["strikethrough", "dim"], l)}` : "", s = n ? styleText("gray", S_BAR) : "";
932
+ return `${i.join(`
913
933
  `)}
914
- ${l}${o}`;
934
+ ${s}${r}`;
915
935
  }
916
936
  default: {
917
- const o = this.state === "error" ? "yellow" : "cyan", l = i ? `${styleText(o, $)} ` : "", d = i ? styleText(o, x) : "";
918
- let g = "";
919
- if (this.isNavigating || a) {
920
- const v = a ? n : r;
921
- g = v !== "" ? ` ${styleText("dim", v)}` : "";
922
- } else g = ` ${this.userInputWithCursor}`;
923
- const p = this.filteredOptions.length !== u.length ? styleText("dim", ` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "", f = this.filteredOptions.length === 0 && r ? [`${l}${styleText("yellow", "No matches found")}`] : [], h = this.state === "error" ? [`${l}${styleText("yellow", this.error)}`] : [];
924
- i && s.push(`${l.trimEnd()}`), s.push(`${l}${styleText("dim", "Search:")}${g}${p}`, ...f, ...h);
925
- const m = [`${l}${[
937
+ const r = this.state === "error" ? "yellow" : "cyan", s = n ? `${styleText(r, S_BAR)} ` : "", a = n ? styleText(r, S_BAR_END) : "";
938
+ let u = "";
939
+ if (this.isNavigating || p) {
940
+ const d = p ? m : l;
941
+ u = d !== "" ? ` ${styleText("dim", d)}` : "";
942
+ } else u = ` ${this.userInputWithCursor}`;
943
+ const V = this.filteredOptions.length !== o.length ? styleText("dim", ` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "", y = this.filteredOptions.length === 0 && l ? [`${s}${styleText("yellow", "No matches found")}`] : [], b = this.state === "error" ? [`${s}${styleText("yellow", this.error)}`] : [];
944
+ n && i.push(`${s.trimEnd()}`), i.push(`${s}${styleText("dim", "Search:")}${u}${V}`, ...y, ...b);
945
+ const g = [`${s}${[
926
946
  `${styleText("dim", "↑/↓")} to select`,
927
947
  `${styleText("dim", "Enter:")} confirm`,
928
948
  `${styleText("dim", "Type:")} to search`
929
- ].join(" • ")}`, d], y = this.filteredOptions.length === 0 ? [] : F({
949
+ ].join(" • ")}`, a], O = this.filteredOptions.length === 0 ? [] : limitOptions({
930
950
  cursor: this.cursor,
931
951
  options: this.filteredOptions,
932
- columnPadding: i ? 3 : 0,
933
- rowPadding: s.length + m.length,
934
- style: (v, C) => c(v, v.disabled ? "disabled" : C ? "active" : "inactive"),
952
+ columnPadding: n ? 3 : 0,
953
+ rowPadding: i.length + g.length,
954
+ style: (d, f) => $(d, d.disabled ? "disabled" : f ? "active" : "inactive"),
935
955
  maxItems: t.maxItems,
936
956
  output: t.output
937
957
  });
938
958
  return [
939
- ...s,
940
- ...y.map((v) => `${l}${v}`),
941
- ...m
959
+ ...i,
960
+ ...O.map((d) => `${s}${d}`),
961
+ ...g
942
962
  ].join(`
943
963
  `);
944
964
  }
945
965
  }
946
966
  }
947
- }).prompt(), le = (t) => {
948
- const i = t.active ?? "Yes", s = t.inactive ?? "No";
949
- return new Z({
950
- active: i,
967
+ }).prompt();
968
+ const confirm = (i) => {
969
+ const a = i.active ?? "Yes", s = i.inactive ?? "No";
970
+ return new r({
971
+ active: a,
951
972
  inactive: s,
952
- signal: t.signal,
953
- input: t.input,
954
- output: t.output,
955
- initialValue: t.initialValue ?? !0,
973
+ signal: i.signal,
974
+ input: i.input,
975
+ output: i.output,
976
+ initialValue: i.initialValue ?? true,
956
977
  render() {
957
- const r = t.withGuide ?? h.withGuide, u = `${P(this.state)} `, n = r ? `${styleText("gray", $)} ` : "", a = B(t.output, t.message, n, u), c = `${r ? `${styleText("gray", $)}
958
- ` : ""}${a}
959
- `, o = this.value ? i : s;
978
+ const e = i.withGuide ?? settings.withGuide, u = `${symbol(this.state)} `, l = e ? `${styleText("gray", S_BAR)} ` : "", f = wrapTextWithPrefix(i.output, i.message, l, u), o = `${e ? `${styleText("gray", S_BAR)}
979
+ ` : ""}${f}
980
+ `, c = this.value ? a : s;
960
981
  switch (this.state) {
961
- case "submit": return `${c}${r ? `${styleText("gray", $)} ` : ""}${styleText("dim", o)}`;
962
- case "cancel": return `${c}${r ? `${styleText("gray", $)} ` : ""}${styleText(["strikethrough", "dim"], o)}${r ? `
963
- ${styleText("gray", $)}` : ""}`;
982
+ case "submit": return `${o}${e ? `${styleText("gray", S_BAR)} ` : ""}${styleText("dim", c)}`;
983
+ case "cancel": return `${o}${e ? `${styleText("gray", S_BAR)} ` : ""}${styleText(["strikethrough", "dim"], c)}${e ? `
984
+ ${styleText("gray", S_BAR)}` : ""}`;
964
985
  default: {
965
- const l = r ? `${styleText("cyan", $)} ` : "", d = r ? styleText("cyan", x) : "";
966
- return `${c}${l}${this.value ? `${styleText("green", z)} ${i}` : `${styleText("dim", U)} ${styleText("dim", i)}`}${t.vertical ? r ? `
967
- ${styleText("cyan", $)} ` : `
968
- ` : ` ${styleText("dim", "/")} `}${this.value ? `${styleText("dim", U)} ${styleText("dim", s)}` : `${styleText("green", z)} ${s}`}
969
- ${d}
986
+ const r = e ? `${styleText("cyan", S_BAR)} ` : "", g = e ? styleText("cyan", S_BAR_END) : "";
987
+ return `${o}${r}${this.value ? `${styleText("green", S_RADIO_ACTIVE)} ${a}` : `${styleText("dim", S_RADIO_INACTIVE)} ${styleText("dim", a)}`}${i.vertical ? e ? `
988
+ ${styleText("cyan", S_BAR)} ` : `
989
+ ` : ` ${styleText("dim", "/")} `}${this.value ? `${styleText("dim", S_RADIO_INACTIVE)} ${styleText("dim", s)}` : `${styleText("green", S_RADIO_ACTIVE)} ${s}`}
990
+ ${g}
970
991
  `;
971
992
  }
972
993
  }
973
994
  }
974
995
  }).prompt();
975
- }, R$1 = {
976
- message: (t = [], { symbol: i = styleText("gray", $), secondarySymbol: s = styleText("gray", $), output: r = process.stdout, spacing: u = 1, withGuide: n } = {}) => {
977
- const a = [], c = n ?? h.withGuide, o = c ? s : "", l = c ? `${i} ` : "", d = c ? `${s} ` : "";
978
- for (let p = 0; p < u; p++) a.push(o);
979
- const g = Array.isArray(t) ? t : t.split(`
996
+ };
997
+ const log = {
998
+ message: (s = [], { symbol: e = styleText("gray", S_BAR), secondarySymbol: r = styleText("gray", S_BAR), output: m = process.stdout, spacing: l = 1, withGuide: c } = {}) => {
999
+ const t = [], o = c ?? settings.withGuide, f = o ? r : "", O = o ? `${e} ` : "", u = o ? `${r} ` : "";
1000
+ for (let i = 0; i < l; i++) t.push(f);
1001
+ const g = Array.isArray(s) ? s : s.split(`
980
1002
  `);
981
1003
  if (g.length > 0) {
982
- const [p, ...f] = g;
983
- p.length > 0 ? a.push(`${l}${p}`) : a.push(c ? i : "");
984
- for (const h of f) h.length > 0 ? a.push(`${d}${h}`) : a.push(c ? s : "");
1004
+ const [i, ...y] = g;
1005
+ i.length > 0 ? t.push(`${O}${i}`) : t.push(o ? e : "");
1006
+ for (const p of y) p.length > 0 ? t.push(`${u}${p}`) : t.push(o ? r : "");
985
1007
  }
986
- r.write(`${a.join(`
1008
+ m.write(`${t.join(`
987
1009
  `)}
988
1010
  `);
989
1011
  },
990
- info: (t, i) => {
991
- R$1.message(t, {
992
- ...i,
993
- symbol: styleText("blue", pt)
1012
+ info: (s, e) => {
1013
+ log.message(s, {
1014
+ ...e,
1015
+ symbol: styleText("blue", S_INFO)
994
1016
  });
995
1017
  },
996
- success: (t, i) => {
997
- R$1.message(t, {
998
- ...i,
999
- symbol: styleText("green", mt)
1018
+ success: (s, e) => {
1019
+ log.message(s, {
1020
+ ...e,
1021
+ symbol: styleText("green", S_SUCCESS)
1000
1022
  });
1001
1023
  },
1002
- step: (t, i) => {
1003
- R$1.message(t, {
1004
- ...i,
1005
- symbol: styleText("green", H)
1024
+ step: (s, e) => {
1025
+ log.message(s, {
1026
+ ...e,
1027
+ symbol: styleText("green", S_STEP_SUBMIT)
1006
1028
  });
1007
1029
  },
1008
- warn: (t, i) => {
1009
- R$1.message(t, {
1010
- ...i,
1011
- symbol: styleText("yellow", gt)
1030
+ warn: (s, e) => {
1031
+ log.message(s, {
1032
+ ...e,
1033
+ symbol: styleText("yellow", S_WARN)
1012
1034
  });
1013
1035
  },
1014
- warning: (t, i) => {
1015
- R$1.warn(t, i);
1036
+ /** alias for `log.warn()`. */
1037
+ warning: (s, e) => {
1038
+ log.warn(s, e);
1016
1039
  },
1017
- error: (t, i) => {
1018
- R$1.message(t, {
1019
- ...i,
1020
- symbol: styleText("red", yt)
1040
+ error: (s, e) => {
1041
+ log.message(s, {
1042
+ ...e,
1043
+ symbol: styleText("red", S_ERROR)
1021
1044
  });
1022
1045
  }
1023
- }, ye = (t = "", i) => {
1024
- const s = i?.output ?? process.stdout, r = i?.withGuide ?? h.withGuide ? `${styleText("gray", ct)} ` : "";
1025
- s.write(`${r}${t}
1046
+ }, intro = (o = "", t) => {
1047
+ const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText("gray", S_BAR_START)} ` : "";
1048
+ i.write(`${e}${o}
1026
1049
  `);
1027
- }, fe = (t = "", i) => {
1028
- const s = i?.output ?? process.stdout, r = i?.withGuide ?? h.withGuide ? `${styleText("gray", $)}
1029
- ${styleText("gray", x)} ` : "";
1030
- s.write(`${r}${t}
1050
+ }, outro = (o = "", t) => {
1051
+ const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText("gray", S_BAR)}
1052
+ ${styleText("gray", S_BAR_END)} ` : "";
1053
+ i.write(`${e}${o}
1031
1054
 
1032
1055
  `);
1033
- }, Q = (t, i) => t.split(`
1034
- `).map((s) => i(s)).join(`
1035
- `), we = (t) => {
1036
- const i = (r, u) => {
1037
- const n = r.label ?? String(r.value);
1038
- return u === "disabled" ? `${styleText("gray", Y)} ${Q(n, (a) => styleText(["strikethrough", "gray"], a))}${r.hint ? ` ${styleText("dim", `(${r.hint ?? "disabled"})`)}` : ""}` : u === "active" ? `${styleText("cyan", et)} ${n}${r.hint ? ` ${styleText("dim", `(${r.hint})`)}` : ""}` : u === "selected" ? `${styleText("green", K)} ${Q(n, (a) => styleText("dim", a))}${r.hint ? ` ${styleText("dim", `(${r.hint})`)}` : ""}` : u === "cancelled" ? `${Q(n, (a) => styleText(["strikethrough", "dim"], a))}` : u === "active-selected" ? `${styleText("green", K)} ${n}${r.hint ? ` ${styleText("dim", `(${r.hint})`)}` : ""}` : u === "submitted" ? `${Q(n, (a) => styleText("dim", a))}` : `${styleText("dim", Y)} ${Q(n, (a) => styleText("dim", a))}`;
1039
- }, s = t.required ?? !0;
1040
- return new ut$1({
1041
- options: t.options,
1042
- signal: t.signal,
1043
- input: t.input,
1044
- output: t.output,
1045
- initialValues: t.initialValues,
1046
- required: s,
1047
- cursorAt: t.cursorAt,
1048
- validate(r) {
1049
- if (s && (r === void 0 || r.length === 0)) return `Please select at least one option.
1056
+ };
1057
+ const d = (n, a) => n.split(`
1058
+ `).map((m) => a(m)).join(`
1059
+ `);
1060
+ const multiselect = (n) => {
1061
+ const a = (t, o) => {
1062
+ const r = t.label ?? String(t.value);
1063
+ return o === "disabled" ? `${styleText("gray", S_CHECKBOX_INACTIVE)} ${d(r, (l) => styleText(["strikethrough", "gray"], l))}${t.hint ? ` ${styleText("dim", `(${t.hint ?? "disabled"})`)}` : ""}` : o === "active" ? `${styleText("cyan", S_CHECKBOX_ACTIVE)} ${r}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : o === "selected" ? `${styleText("green", S_CHECKBOX_SELECTED)} ${d(r, (l) => styleText("dim", l))}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : o === "cancelled" ? `${d(r, (l) => styleText(["strikethrough", "dim"], l))}` : o === "active-selected" ? `${styleText("green", S_CHECKBOX_SELECTED)} ${r}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : o === "submitted" ? `${d(r, (l) => styleText("dim", l))}` : `${styleText("dim", S_CHECKBOX_INACTIVE)} ${d(r, (l) => styleText("dim", l))}`;
1064
+ }, m = n.required ?? true;
1065
+ return new a$1({
1066
+ options: n.options,
1067
+ signal: n.signal,
1068
+ input: n.input,
1069
+ output: n.output,
1070
+ initialValues: n.initialValues,
1071
+ required: m,
1072
+ cursorAt: n.cursorAt,
1073
+ validate(t) {
1074
+ if (m && (t === void 0 || t.length === 0)) return `Please select at least one option.
1050
1075
  ${styleText("reset", styleText("dim", `Press ${styleText([
1051
1076
  "gray",
1052
1077
  "bgWhite",
@@ -1054,86 +1079,90 @@ ${styleText("reset", styleText("dim", `Press ${styleText([
1054
1079
  ], " space ")} to select, ${styleText("gray", styleText("bgWhite", styleText("inverse", " enter ")))} to submit`))}`;
1055
1080
  },
1056
1081
  render() {
1057
- const r = t.withGuide ?? h.withGuide, u = B(t.output, t.message, r ? `${ft(this.state)} ` : "", `${P(this.state)} `), n = `${r ? `${styleText("gray", $)}
1058
- ` : ""}${u}
1059
- `, a = this.value ?? [], c = (o, l) => {
1060
- if (o.disabled) return i(o, "disabled");
1061
- const d = a.includes(o.value);
1062
- return l && d ? i(o, "active-selected") : d ? i(o, "selected") : i(o, l ? "active" : "inactive");
1082
+ const t = n.withGuide ?? settings.withGuide, o = wrapTextWithPrefix(n.output, n.message, t ? `${symbolBar(this.state)} ` : "", `${symbol(this.state)} `), r = `${t ? `${styleText("gray", S_BAR)}
1083
+ ` : ""}${o}
1084
+ `, l = this.value ?? [], g = (i, u) => {
1085
+ if (i.disabled) return a(i, "disabled");
1086
+ const s = l.includes(i.value);
1087
+ return u && s ? a(i, "active-selected") : s ? a(i, "selected") : a(i, u ? "active" : "inactive");
1063
1088
  };
1064
1089
  switch (this.state) {
1065
1090
  case "submit": {
1066
- const o = this.options.filter(({ value: d }) => a.includes(d)).map((d) => i(d, "submitted")).join(styleText("dim", ", ")) || styleText("dim", "none");
1067
- return `${n}${B(t.output, o, r ? `${styleText("gray", $)} ` : "")}`;
1091
+ const i = this.options.filter(({ value: s }) => l.includes(s)).map((s) => a(s, "submitted")).join(styleText("dim", ", ")) || styleText("dim", "none");
1092
+ return `${r}${wrapTextWithPrefix(n.output, i, t ? `${styleText("gray", S_BAR)} ` : "")}`;
1068
1093
  }
1069
1094
  case "cancel": {
1070
- const o = this.options.filter(({ value: d }) => a.includes(d)).map((d) => i(d, "cancelled")).join(styleText("dim", ", "));
1071
- if (o.trim() === "") return `${n}${styleText("gray", $)}`;
1072
- return `${n}${B(t.output, o, r ? `${styleText("gray", $)} ` : "")}${r ? `
1073
- ${styleText("gray", $)}` : ""}`;
1095
+ const i = this.options.filter(({ value: s }) => l.includes(s)).map((s) => a(s, "cancelled")).join(styleText("dim", ", "));
1096
+ if (i.trim() === "") return `${r}${styleText("gray", S_BAR)}`;
1097
+ return `${r}${wrapTextWithPrefix(n.output, i, t ? `${styleText("gray", S_BAR)} ` : "")}${t ? `
1098
+ ${styleText("gray", S_BAR)}` : ""}`;
1074
1099
  }
1075
1100
  case "error": {
1076
- const o = r ? `${styleText("yellow", $)} ` : "", l = this.error.split(`
1077
- `).map((p, f) => f === 0 ? `${r ? `${styleText("yellow", x)} ` : ""}${styleText("yellow", p)}` : ` ${p}`).join(`
1078
- `), d = n.split(`
1079
- `).length, g = l.split(`
1101
+ const i = t ? `${styleText("yellow", S_BAR)} ` : "", u = this.error.split(`
1102
+ `).map((h, x) => x === 0 ? `${t ? `${styleText("yellow", S_BAR_END)} ` : ""}${styleText("yellow", h)}` : ` ${h}`).join(`
1103
+ `), s = r.split(`
1104
+ `).length, v = u.split(`
1080
1105
  `).length + 1;
1081
- return `${n}${o}${F({
1082
- output: t.output,
1106
+ return `${r}${i}${limitOptions({
1107
+ output: n.output,
1083
1108
  options: this.options,
1084
1109
  cursor: this.cursor,
1085
- maxItems: t.maxItems,
1086
- columnPadding: o.length,
1087
- rowPadding: d + g,
1088
- style: c
1110
+ maxItems: n.maxItems,
1111
+ columnPadding: i.length,
1112
+ rowPadding: s + v,
1113
+ style: g
1089
1114
  }).join(`
1090
- ${o}`)}
1091
- ${l}
1115
+ ${i}`)}
1116
+ ${u}
1092
1117
  `;
1093
1118
  }
1094
1119
  default: {
1095
- const o = r ? `${styleText("cyan", $)} ` : "", l = n.split(`
1096
- `).length, d = r ? 2 : 1;
1097
- return `${n}${o}${F({
1098
- output: t.output,
1120
+ const i = t ? `${styleText("cyan", S_BAR)} ` : "", u = r.split(`
1121
+ `).length, s = t ? 2 : 1;
1122
+ return `${r}${i}${limitOptions({
1123
+ output: n.output,
1099
1124
  options: this.options,
1100
1125
  cursor: this.cursor,
1101
- maxItems: t.maxItems,
1102
- columnPadding: o.length,
1103
- rowPadding: l + d,
1104
- style: c
1126
+ maxItems: n.maxItems,
1127
+ columnPadding: i.length,
1128
+ rowPadding: u + s,
1129
+ style: g
1105
1130
  }).join(`
1106
- ${o}`)}
1107
- ${r ? styleText("cyan", x) : ""}
1131
+ ${i}`)}
1132
+ ${t ? styleText("cyan", S_BAR_END) : ""}
1108
1133
  `;
1109
1134
  }
1110
1135
  }
1111
1136
  }
1112
1137
  }).prompt();
1113
- }, be = (t) => styleText("dim", t), Se = (t, i, s) => {
1114
- const r = {
1115
- hard: !0,
1116
- trim: !1
1117
- }, u = wrapAnsi(t, i, r).split(`
1118
- `), n = u.reduce((o, l) => Math.max(fastStringWidth(l), o), 0);
1119
- return wrapAnsi(t, i - (u.map(s).reduce((o, l) => Math.max(fastStringWidth(l), o), 0) - n), r);
1120
- }, Ce = (t = "", i = "", s) => {
1121
- const r = s?.output ?? V.stdout, u = s?.withGuide ?? h.withGuide, n = s?.format ?? be, a = [
1138
+ };
1139
+ const W$1 = (o) => styleText("dim", o), C = (o, e, s) => {
1140
+ const a = {
1141
+ hard: true,
1142
+ trim: false
1143
+ }, i = wrapAnsi(o, e, a).split(`
1144
+ `), c = i.reduce((n, r) => Math.max(fastStringWidth(r), n), 0);
1145
+ return wrapAnsi(o, e - (i.map(s).reduce((n, r) => Math.max(fastStringWidth(r), n), 0) - c), a);
1146
+ };
1147
+ const note = (o = "", e = "", s) => {
1148
+ const a = s?.output ?? process$1.stdout, i = s?.withGuide ?? settings.withGuide, c = s?.format ?? W$1, g = [
1122
1149
  "",
1123
- ...Se(t, A(r) - 6, n).split(`
1124
- `).map(n),
1150
+ ...C(o, getColumns(a) - 6, c).split(`
1151
+ `).map(c),
1125
1152
  ""
1126
- ], c = fastStringWidth(i), o = Math.max(a.reduce((p, f) => {
1127
- const h = fastStringWidth(f);
1128
- return h > p ? h : p;
1129
- }, 0), c) + 2, l = a.map((p) => `${styleText("gray", $)} ${p}${" ".repeat(o - fastStringWidth(p))}${styleText("gray", $)}`).join(`
1130
- `), d = u ? `${styleText("gray", $)}
1131
- ` : "", g = u ? Mt : ht;
1132
- r.write(`${d}${styleText("green", H)} ${styleText("reset", i)} ${styleText("gray", st.repeat(Math.max(o - c - 1, 1)) + $t)}
1133
- ${l}
1134
- ${styleText("gray", g + st.repeat(o + 2) + dt)}
1153
+ ], n = fastStringWidth(e), r = Math.max(g.reduce((m, F) => {
1154
+ const O = fastStringWidth(F);
1155
+ return O > m ? O : m;
1156
+ }, 0), n) + 2, h = g.map((m) => `${styleText("gray", S_BAR)} ${m}${" ".repeat(r - fastStringWidth(m))}${styleText("gray", S_BAR)}`).join(`
1157
+ `), T = i ? `${styleText("gray", S_BAR)}
1158
+ ` : "", l$1 = i ? S_CONNECT_LEFT : S_CORNER_BOTTOM_LEFT;
1159
+ a.write(`${T}${styleText("green", S_STEP_SUBMIT)} ${styleText("reset", e)} ${styleText("gray", S_BAR_H.repeat(Math.max(r - n - 1, 1)) + S_CORNER_TOP_RIGHT)}
1160
+ ${h}
1161
+ ${styleText("gray", l$1 + S_BAR_H.repeat(r + 2) + S_CORNER_BOTTOM_RIGHT)}
1135
1162
  `);
1136
- }, _e = (t) => styleText("magenta", t), vt = ({ indicator: t = "dots", onCancel: i, output: s = process.stdout, cancelMessage: r, errorMessage: u, frames: n = tt ? [
1163
+ };
1164
+ const W = (l) => styleText("magenta", l);
1165
+ const spinner = ({ indicator: l = "dots", onCancel: h, output: n = process.stdout, cancelMessage: G, errorMessage: O, frames: E = unicode ? [
1137
1166
  "◒",
1138
1167
  "◐",
1139
1168
  "◓",
@@ -1143,148 +1172,129 @@ ${styleText("gray", g + st.repeat(o + 2) + dt)}
1143
1172
  "o",
1144
1173
  "O",
1145
1174
  "0"
1146
- ], delay: a = tt ? 80 : 120, signal: c, ...o } = {}) => {
1147
- const l = at();
1148
- let d, g, p = !1, f = !1, h$2 = "", I, m = performance.now();
1149
- const y = A(s), v = o?.styleFrame ?? _e, C = (_) => {
1150
- const A = _ > 1 ? u ?? h.messages.error : r ?? h.messages.cancel;
1151
- f = _ === 1, p && (W$1(A, _), f && typeof i == "function" && i());
1152
- }, S = () => C(2), b = () => C(1), G = () => {
1153
- process.on("uncaughtExceptionMonitor", S), process.on("unhandledRejection", S), process.on("SIGINT", b), process.on("SIGTERM", b), process.on("exit", C), c && c.addEventListener("abort", b);
1154
- }, M = () => {
1155
- process.removeListener("uncaughtExceptionMonitor", S), process.removeListener("unhandledRejection", S), process.removeListener("SIGINT", b), process.removeListener("SIGTERM", b), process.removeListener("exit", C), c && c.removeEventListener("abort", b);
1156
- }, N = () => {
1157
- if (I === void 0) return;
1158
- l && s.write(`
1175
+ ], delay: F = unicode ? 80 : 120, signal: m, ...I } = {}) => {
1176
+ const u = isCI();
1177
+ let M, T, d = false, S = false, s = "", p, w = performance.now();
1178
+ const x = getColumns(n), k = I?.styleFrame ?? W, g = (e) => {
1179
+ const r = e > 1 ? O ?? settings.messages.error : G ?? settings.messages.cancel;
1180
+ S = e === 1, d && (a(r, e), S && typeof h == "function" && h());
1181
+ }, f = () => g(2), i = () => g(1), A = () => {
1182
+ process.on("uncaughtExceptionMonitor", f), process.on("unhandledRejection", f), process.on("SIGINT", i), process.on("SIGTERM", i), process.on("exit", g), m && m.addEventListener("abort", i);
1183
+ }, H = () => {
1184
+ process.removeListener("uncaughtExceptionMonitor", f), process.removeListener("unhandledRejection", f), process.removeListener("SIGINT", i), process.removeListener("SIGTERM", i), process.removeListener("exit", g), m && m.removeEventListener("abort", i);
1185
+ }, y = () => {
1186
+ if (p === void 0) return;
1187
+ u && n.write(`
1159
1188
  `);
1160
- const _ = wrapAnsi(I, y, {
1161
- hard: !0,
1162
- trim: !1
1189
+ const r = wrapAnsi(p, x, {
1190
+ hard: true,
1191
+ trim: false
1163
1192
  }).split(`
1164
1193
  `);
1165
- _.length > 1 && s.write(import_src.cursor.up(_.length - 1)), s.write(import_src.cursor.to(0)), s.write(import_src.erase.down());
1166
- }, O = (_) => _.replace(/\.+$/, ""), j = (_) => {
1167
- const A = (performance.now() - _) / 1e3, L = Math.floor(A / 60), D = Math.floor(A % 60);
1168
- return L > 0 ? `[${L}m ${D}s]` : `[${D}s]`;
1169
- }, k = o.withGuide ?? h.withGuide, rt = (_ = "") => {
1170
- p = !0, d = W({ output: s }), h$2 = O(_), m = performance.now(), k && s.write(`${styleText("gray", $)}
1194
+ r.length > 1 && n.write(import_src.cursor.up(r.length - 1)), n.write(import_src.cursor.to(0)), n.write(import_src.erase.down());
1195
+ }, C = (e) => e.replace(/\.+$/, ""), _ = (e) => {
1196
+ const r = (performance.now() - e) / 1e3, t = Math.floor(r / 60), o = Math.floor(r % 60);
1197
+ return t > 0 ? `[${t}m ${o}s]` : `[${o}s]`;
1198
+ }, N = I.withGuide ?? settings.withGuide, P = (e = "") => {
1199
+ d = true, M = block({ output: n }), s = C(e), w = performance.now(), N && n.write(`${styleText("gray", S_BAR)}
1171
1200
  `);
1172
- let A = 0, L = 0;
1173
- G(), g = setInterval(() => {
1174
- if (l && h$2 === I) return;
1175
- N(), I = h$2;
1176
- const D = v(n[A]);
1177
- let Z;
1178
- if (l) Z = `${D} ${h$2}...`;
1179
- else if (t === "timer") Z = `${D} ${h$2} ${j(m)}`;
1201
+ let r = 0, t = 0;
1202
+ A(), T = setInterval(() => {
1203
+ if (u && s === p) return;
1204
+ y(), p = s;
1205
+ const o = k(E[r]);
1206
+ let v;
1207
+ if (u) v = `${o} ${s}...`;
1208
+ else if (l === "timer") v = `${o} ${s} ${_(w)}`;
1180
1209
  else {
1181
- const Lt = ".".repeat(Math.floor(L)).slice(0, 3);
1182
- Z = `${D} ${h$2}${Lt}`;
1210
+ const B = ".".repeat(Math.floor(t)).slice(0, 3);
1211
+ v = `${o} ${s}${B}`;
1183
1212
  }
1184
- const kt = wrapAnsi(Z, y, {
1185
- hard: !0,
1186
- trim: !1
1213
+ const j = wrapAnsi(v, x, {
1214
+ hard: true,
1215
+ trim: false
1187
1216
  });
1188
- s.write(kt), A = A + 1 < n.length ? A + 1 : 0, L = L < 4 ? L + .125 : 0;
1189
- }, a);
1190
- }, W$1 = (_ = "", A = 0, L = !1) => {
1191
- if (!p) return;
1192
- p = !1, clearInterval(g), N();
1193
- const D = A === 0 ? styleText("green", H) : A === 1 ? styleText("red", ut) : styleText("red", lt);
1194
- h$2 = _ ?? h$2, L || (t === "timer" ? s.write(`${D} ${h$2} ${j(m)}
1195
- `) : s.write(`${D} ${h$2}
1196
- `)), M(), d();
1217
+ n.write(j), r = r + 1 < E.length ? r + 1 : 0, t = t < 4 ? t + .125 : 0;
1218
+ }, F);
1219
+ }, a = (e = "", r = 0, t = false) => {
1220
+ if (!d) return;
1221
+ d = false, clearInterval(T), y();
1222
+ const o = r === 0 ? styleText("green", S_STEP_SUBMIT) : r === 1 ? styleText("red", S_STEP_CANCEL) : styleText("red", S_STEP_ERROR);
1223
+ s = e ?? s, t || (l === "timer" ? n.write(`${o} ${s} ${_(w)}
1224
+ `) : n.write(`${o} ${s}
1225
+ `)), H(), M();
1197
1226
  };
1198
1227
  return {
1199
- start: rt,
1200
- stop: (_ = "") => W$1(_, 0),
1201
- message: (_ = "") => {
1202
- h$2 = O(_ ?? h$2);
1228
+ start: P,
1229
+ stop: (e = "") => a(e, 0),
1230
+ message: (e = "") => {
1231
+ s = C(e ?? s);
1203
1232
  },
1204
- cancel: (_ = "") => W$1(_, 1),
1205
- error: (_ = "") => W$1(_, 2),
1206
- clear: () => W$1("", 0, !0),
1233
+ cancel: (e = "") => a(e, 1),
1234
+ error: (e = "") => a(e, 2),
1235
+ clear: () => a("", 0, true),
1207
1236
  get isCancelled() {
1208
- return f;
1237
+ return S;
1209
1238
  }
1210
1239
  };
1211
- }, it = (t, i) => t.includes(`
1212
- `) ? t.split(`
1213
- `).map((s) => i(s)).join(`
1214
- `) : i(t), Ee = (t) => {
1215
- const i = (s, r) => {
1216
- const u = s.label ?? String(s.value);
1217
- switch (r) {
1218
- case "disabled": return `${styleText("gray", U)} ${it(u, (n) => styleText("gray", n))}${s.hint ? ` ${styleText("dim", `(${s.hint ?? "disabled"})`)}` : ""}`;
1219
- case "selected": return `${it(u, (n) => styleText("dim", n))}`;
1220
- case "active": return `${styleText("green", z)} ${u}${s.hint ? ` ${styleText("dim", `(${s.hint})`)}` : ""}`;
1221
- case "cancelled": return `${it(u, (n) => styleText(["strikethrough", "dim"], n))}`;
1222
- default: return `${styleText("dim", U)} ${it(u, (n) => styleText("dim", n))}`;
1240
+ };
1241
+ const c = (e, a) => e.includes(`
1242
+ `) ? e.split(`
1243
+ `).map((t) => a(t)).join(`
1244
+ `) : a(e);
1245
+ const select = (e) => {
1246
+ const a$2 = (t, d) => {
1247
+ const s = t.label ?? String(t.value);
1248
+ switch (d) {
1249
+ case "disabled": return `${styleText("gray", S_RADIO_INACTIVE)} ${c(s, (n) => styleText("gray", n))}${t.hint ? ` ${styleText("dim", `(${t.hint ?? "disabled"})`)}` : ""}`;
1250
+ case "selected": return `${c(s, (n) => styleText("dim", n))}`;
1251
+ case "active": return `${styleText("green", S_RADIO_ACTIVE)} ${s}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}`;
1252
+ case "cancelled": return `${c(s, (n) => styleText(["strikethrough", "dim"], n))}`;
1253
+ default: return `${styleText("dim", S_RADIO_INACTIVE)} ${c(s, (n) => styleText("dim", n))}`;
1223
1254
  }
1224
1255
  };
1225
- return new ht$1({
1226
- options: t.options,
1227
- signal: t.signal,
1228
- input: t.input,
1229
- output: t.output,
1230
- initialValue: t.initialValue,
1256
+ return new a({
1257
+ options: e.options,
1258
+ signal: e.signal,
1259
+ input: e.input,
1260
+ output: e.output,
1261
+ initialValue: e.initialValue,
1231
1262
  render() {
1232
- const s = t.withGuide ?? h.withGuide, r = `${P(this.state)} `, u = `${ft(this.state)} `, n = B(t.output, t.message, u, r), a = `${s ? `${styleText("gray", $)}
1263
+ const t = e.withGuide ?? settings.withGuide, d = `${symbol(this.state)} `, s = `${symbolBar(this.state)} `, n = wrapTextWithPrefix(e.output, e.message, s, d), u = `${t ? `${styleText("gray", S_BAR)}
1233
1264
  ` : ""}${n}
1234
1265
  `;
1235
1266
  switch (this.state) {
1236
1267
  case "submit": {
1237
- const c = s ? `${styleText("gray", $)} ` : "";
1238
- return `${a}${B(t.output, i(this.options[this.cursor], "selected"), c)}`;
1268
+ const r = t ? `${styleText("gray", S_BAR)} ` : "";
1269
+ return `${u}${wrapTextWithPrefix(e.output, a$2(this.options[this.cursor], "selected"), r)}`;
1239
1270
  }
1240
1271
  case "cancel": {
1241
- const c = s ? `${styleText("gray", $)} ` : "";
1242
- return `${a}${B(t.output, i(this.options[this.cursor], "cancelled"), c)}${s ? `
1243
- ${styleText("gray", $)}` : ""}`;
1272
+ const r = t ? `${styleText("gray", S_BAR)} ` : "";
1273
+ return `${u}${wrapTextWithPrefix(e.output, a$2(this.options[this.cursor], "cancelled"), r)}${t ? `
1274
+ ${styleText("gray", S_BAR)}` : ""}`;
1244
1275
  }
1245
1276
  default: {
1246
- const c = s ? `${styleText("cyan", $)} ` : "", o = s ? styleText("cyan", x) : "", l = a.split(`
1247
- `).length, d = s ? 2 : 1;
1248
- return `${a}${c}${F({
1249
- output: t.output,
1277
+ const r = t ? `${styleText("cyan", S_BAR)} ` : "", l = t ? styleText("cyan", S_BAR_END) : "", g = u.split(`
1278
+ `).length, h = t ? 2 : 1;
1279
+ return `${u}${r}${limitOptions({
1280
+ output: e.output,
1250
1281
  cursor: this.cursor,
1251
1282
  options: this.options,
1252
- maxItems: t.maxItems,
1253
- columnPadding: c.length,
1254
- rowPadding: l + d,
1255
- style: (g, p) => i(g, g.disabled ? "disabled" : p ? "active" : "inactive")
1283
+ maxItems: e.maxItems,
1284
+ columnPadding: r.length,
1285
+ rowPadding: g + h,
1286
+ style: (p, b) => a$2(p, p.disabled ? "disabled" : b ? "active" : "inactive")
1256
1287
  }).join(`
1257
- ${c}`)}
1258
- ${o}
1288
+ ${r}`)}
1289
+ ${l}
1259
1290
  `;
1260
1291
  }
1261
1292
  }
1262
1293
  }
1263
1294
  }).prompt();
1264
- }, Bt = `${styleText("gray", $)} `, q = {
1265
- message: async (t, { symbol: i = styleText("gray", $) } = {}) => {
1266
- process.stdout.write(`${styleText("gray", $)}
1267
- ${i} `);
1268
- let s = 3;
1269
- for await (let r of t) {
1270
- r = r.replace(/\n/g, `
1271
- ${Bt}`), r.includes(`
1272
- `) && (s = 3 + stripVTControlCharacters(r.slice(r.lastIndexOf(`
1273
- `))).length);
1274
- const u = stripVTControlCharacters(r).length;
1275
- s + u < process.stdout.columns ? (s += u, process.stdout.write(r)) : (process.stdout.write(`
1276
- ${Bt}${r.trimStart()}`), s = 3 + stripVTControlCharacters(r.trimStart()).length);
1277
- }
1278
- process.stdout.write(`
1279
- `);
1280
- },
1281
- info: (t) => q.message(t, { symbol: styleText("blue", pt) }),
1282
- success: (t) => q.message(t, { symbol: styleText("green", mt) }),
1283
- step: (t) => q.message(t, { symbol: styleText("green", H) }),
1284
- warn: (t) => q.message(t, { symbol: styleText("yellow", gt) }),
1285
- warning: (t) => q.warn(t),
1286
- error: (t) => q.message(t, { symbol: styleText("red", yt) })
1287
- }, Re = (t) => new ct$1({
1295
+ };
1296
+ `${styleText("gray", S_BAR)}`;
1297
+ const text = (t) => new n({
1288
1298
  validate: t.validate,
1289
1299
  placeholder: t.placeholder,
1290
1300
  defaultValue: t.defaultValue,
@@ -1293,33 +1303,33 @@ ${Bt}${r.trimStart()}`), s = 3 + stripVTControlCharacters(r.trimStart()).length)
1293
1303
  signal: t.signal,
1294
1304
  input: t.input,
1295
1305
  render() {
1296
- const i = t?.withGuide ?? h.withGuide, s = `${`${i ? `${styleText("gray", $)}
1297
- ` : ""}${P(this.state)} `}${t.message}
1298
- `, r = t.placeholder ? styleText("inverse", t.placeholder[0]) + styleText("dim", t.placeholder.slice(1)) : styleText(["inverse", "hidden"], "_"), u = this.userInput ? this.userInputWithCursor : r, n = this.value ?? "";
1306
+ const i = t?.withGuide ?? settings.withGuide, s = `${`${i ? `${styleText("gray", S_BAR)}
1307
+ ` : ""}${symbol(this.state)} `}${t.message}
1308
+ `, c = t.placeholder ? styleText("inverse", t.placeholder[0]) + styleText("dim", t.placeholder.slice(1)) : styleText(["inverse", "hidden"], "_"), o = this.userInput ? this.userInputWithCursor : c, a = this.value ?? "";
1299
1309
  switch (this.state) {
1300
1310
  case "error": {
1301
- const a = this.error ? ` ${styleText("yellow", this.error)}` : "", c = i ? `${styleText("yellow", $)} ` : "", o = i ? styleText("yellow", x) : "";
1311
+ const n = this.error ? ` ${styleText("yellow", this.error)}` : "", r = i ? `${styleText("yellow", S_BAR)} ` : "", d = i ? styleText("yellow", S_BAR_END) : "";
1302
1312
  return `${s.trim()}
1303
- ${c}${u}
1304
- ${o}${a}
1313
+ ${r}${o}
1314
+ ${d}${n}
1305
1315
  `;
1306
1316
  }
1307
1317
  case "submit": {
1308
- const a = n ? ` ${styleText("dim", n)}` : "";
1309
- return `${s}${i ? styleText("gray", $) : ""}${a}`;
1318
+ const n = a ? ` ${styleText("dim", a)}` : "";
1319
+ return `${s}${i ? styleText("gray", S_BAR) : ""}${n}`;
1310
1320
  }
1311
1321
  case "cancel": {
1312
- const a = n ? ` ${styleText(["strikethrough", "dim"], n)}` : "", c = i ? styleText("gray", $) : "";
1313
- return `${s}${c}${a}${n.trim() ? `
1314
- ${c}` : ""}`;
1322
+ const n = a ? ` ${styleText(["strikethrough", "dim"], a)}` : "", r = i ? styleText("gray", S_BAR) : "";
1323
+ return `${s}${r}${n}${a.trim() ? `
1324
+ ${r}` : ""}`;
1315
1325
  }
1316
- default: return `${s}${i ? `${styleText("cyan", $)} ` : ""}${u}
1317
- ${i ? styleText("cyan", x) : ""}
1326
+ default: return `${s}${i ? `${styleText("cyan", S_BAR)} ` : ""}${o}
1327
+ ${i ? styleText("cyan", S_BAR_END) : ""}
1318
1328
  `;
1319
1329
  }
1320
1330
  }
1321
1331
  }).prompt();
1322
1332
  //#endregion
1323
- export { Vt as autocomplete, le as confirm, ye as intro, R as isCancel, R$1 as log, we as multiselect, Ce as note, fe as outro, Ee as select, vt as spinner, Re as text };
1333
+ export { autocomplete, confirm, intro, isCancel, log, multiselect, note, outro, select, spinner, text };
1324
1334
 
1325
1335
  //# sourceMappingURL=dist.mjs.map