archiver-ts 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +390 -378
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,24 +1,24 @@
1
1
  #!/usr/bin/env node
2
- import We from "node:fs";
2
+ import Je from "node:fs";
3
3
  import h, { join as D } from "node:path";
4
4
  import p from "node:fs/promises";
5
- import { parse as ut, printParseErrorCode as mt, modify as vt, applyEdits as ht } from "jsonc-parser";
6
- import Je, { homedir as ft } from "node:os";
7
- import { Command as gt } from "commander";
5
+ import { parse as mt, printParseErrorCode as vt, modify as ht, applyEdits as ft } from "jsonc-parser";
6
+ import Ge, { homedir as gt } from "node:os";
7
+ import { Command as pt } from "commander";
8
8
  import v from "chalk";
9
- import ge from "node:readline";
10
- import pt from "node:readline/promises";
11
- import { stdout as _t, stdin as wt } from "node:process";
12
- import { execFile as It } from "node:child_process";
13
- import { promisify as yt } from "node:util";
14
- function bt(e) {
9
+ import pe from "node:readline";
10
+ import _t from "node:readline/promises";
11
+ import { stdout as wt, stdin as It } from "node:process";
12
+ import { execFile as yt } from "node:child_process";
13
+ import { promisify as bt } from "node:util";
14
+ function kt(e) {
15
15
  const t = h.join(import.meta.dirname, e);
16
- return We.existsSync(t) ? t : h.resolve(import.meta.dirname, "..", "..", "public", e);
16
+ return Je.existsSync(t) ? t : h.resolve(import.meta.dirname, "..", "..", "public", e);
17
17
  }
18
- function Ge(e) {
19
- return We.readFileSync(bt(e), "utf8");
18
+ function Ke(e) {
19
+ return Je.readFileSync(kt(e), "utf8");
20
20
  }
21
- const de = Ge("config.default.jsonc"), ue = Ge("auto-incr.default.jsonc"), kt = {
21
+ const ue = Ke("config.default.jsonc"), me = Ke("auto-incr.default.jsonc"), Ct = {
22
22
  "app.description": "Archive files and folders into ~/.archiver with audit logs",
23
23
  "defaults.vault.remark": "Default vault",
24
24
  "common.action.list": "list",
@@ -334,7 +334,7 @@ const de = Ge("config.default.jsonc"), ue = Ge("auto-incr.default.jsonc"), kt =
334
334
  "terminal.status.log.warn": "WARN",
335
335
  "terminal.status.log.error": "ERROR",
336
336
  "terminal.status.log.fatal": "FATAL"
337
- }, Ct = {
337
+ }, Et = {
338
338
  "app.description": "将文件和文件夹归档到 ~/.archiver,并记录审计日志",
339
339
  "defaults.vault.remark": "默认 vault",
340
340
  "common.action.list": "list",
@@ -650,18 +650,18 @@ const de = Ge("config.default.jsonc"), ue = Ge("auto-incr.default.jsonc"), kt =
650
650
  "terminal.status.log.warn": "警告",
651
651
  "terminal.status.log.error": "错误",
652
652
  "terminal.status.log.fatal": "致命"
653
- }, Ae = {
654
- zh: Ct,
655
- en: kt
653
+ }, Se = {
654
+ zh: Et,
655
+ en: Ct
656
656
  };
657
- let me = "zh";
658
- function Et(e) {
657
+ let ve = "zh";
658
+ function At(e) {
659
659
  return e === "en" ? "en" : "zh";
660
660
  }
661
661
  function Z(e) {
662
- return me = Et(e), me;
662
+ return ve = At(e), ve;
663
663
  }
664
- function At(e, t) {
664
+ function St(e, t) {
665
665
  return t ? e.replace(/\{([a-zA-Z0-9_]+)\}/g, (a, i) => {
666
666
  if (!(i in t))
667
667
  return `{${i}}`;
@@ -670,15 +670,15 @@ function At(e, t) {
670
670
  }) : e;
671
671
  }
672
672
  function r(e, t) {
673
- const a = Ae[me][e] ?? Ae.zh[e] ?? e;
674
- return At(a, t);
673
+ const a = Se[ve][e] ?? Se.zh[e] ?? e;
674
+ return St(a, t);
675
675
  }
676
- function Ke(e) {
676
+ function Xe(e) {
677
677
  return e.endsWith(`
678
678
  `) ? e : `${e}
679
679
  `;
680
680
  }
681
- async function pe(e) {
681
+ async function _e(e) {
682
682
  try {
683
683
  return await p.readFile(e, "utf8");
684
684
  } catch (t) {
@@ -688,9 +688,9 @@ async function pe(e) {
688
688
  }
689
689
  }
690
690
  function Q(e, t) {
691
- const a = [], i = ut(e, a, { allowTrailingComma: !0 });
691
+ const a = [], i = mt(e, a, { allowTrailingComma: !0 });
692
692
  if (a.length > 0) {
693
- const n = a.map((o) => `${mt(o.error)}@${o.offset}`).join(", ");
693
+ const n = a.map((o) => `${vt(o.error)}@${o.offset}`).join(", ");
694
694
  throw new Error(
695
695
  r("util.jsonc.error.parse_file", {
696
696
  filePath: t,
@@ -700,10 +700,10 @@ function Q(e, t) {
700
700
  }
701
701
  return i;
702
702
  }
703
- function St(e, t) {
703
+ function xt(e, t) {
704
704
  let a = e;
705
705
  for (const [i, n] of Object.entries(t)) {
706
- const o = vt(a, [i], n, {
706
+ const o = ht(a, [i], n, {
707
707
  isArrayInsertion: !1,
708
708
  formattingOptions: {
709
709
  insertSpaces: !0,
@@ -712,27 +712,27 @@ function St(e, t) {
712
712
  `
713
713
  }
714
714
  });
715
- a = ht(a, o);
715
+ a = ft(a, o);
716
716
  }
717
- return Ke(a);
717
+ return Xe(a);
718
718
  }
719
- async function ve(e, t) {
720
- const a = await pe(e);
719
+ async function he(e, t) {
720
+ const a = await _e(e);
721
721
  return !a || !a.trim() ? t : Q(a, e);
722
722
  }
723
- async function Se(e, t) {
724
- await pe(e) === void 0 && await p.writeFile(e, Ke(t), "utf8");
723
+ async function xe(e, t) {
724
+ await _e(e) === void 0 && await p.writeFile(e, Xe(t), "utf8");
725
725
  }
726
- async function xe(e, t, a) {
727
- const i = await pe(e), n = i && i.trim().length > 0 ? i : a;
726
+ async function Ve(e, t, a) {
727
+ const i = await _e(e), n = i && i.trim().length > 0 ? i : a;
728
728
  Q(n, e);
729
- const o = St(n, t);
729
+ const o = xt(n, t);
730
730
  await p.writeFile(e, o, "utf8");
731
731
  }
732
732
  var S = /* @__PURE__ */ ((e) => (e.Valid = "Valid", e.Removed = "Removed", e.Protected = "Protected", e))(S || {}), y = /* @__PURE__ */ ((e) => (e.Archived = "Archived", e.Restored = "Restored", e))(y || {}), w = /* @__PURE__ */ ((e) => (e.Info = "Info", e.Warn = "Warn", e.Error = "Error", e))(w || {}), g;
733
733
  ((e) => {
734
- e.VaultId = 0, e.VaultName = "@", e.Config = Q(de, "default-files/config.default.jsonc"), e.AutoIncr = Q(
735
- ue,
734
+ e.VaultId = 0, e.VaultName = "@", e.Config = Q(ue, "default-files/config.default.jsonc"), e.AutoIncr = Q(
735
+ me,
736
736
  "default-files/auto-incr.default.jsonc"
737
737
  ), e.Vault = {
738
738
  id: e.VaultId,
@@ -742,7 +742,7 @@ var S = /* @__PURE__ */ ((e) => (e.Valid = "Valid", e.Removed = "Removed", e.Pro
742
742
  status: S.Protected
743
743
  }, e.LogTail = 15;
744
744
  })(g || (g = {}));
745
- const xt = () => process.env.ARCHIVER_PATH ?? D(ft(), ".archiver"), $ = xt();
745
+ const Vt = () => process.env.ARCHIVER_PATH ?? D(gt(), ".archiver"), $ = Vt();
746
746
  var f;
747
747
  ((e) => {
748
748
  e.Dir = {
@@ -760,19 +760,19 @@ var M;
760
760
  ((e) => {
761
761
  e.CheckInterval = 1440 * 60 * 1e3, e.Repo = process.env.ARCHIVER_GITHUB_REPO ?? "aldia/archiver", e.Timeout = 1e4;
762
762
  })(M || (M = {}));
763
- const Vt = "archiver", z = (e) => e.toString().padStart(2, "0"), Rt = () => (/* @__PURE__ */ new Date()).toISOString();
764
- function _e(e = /* @__PURE__ */ new Date()) {
763
+ const Rt = "archiver", z = (e) => e.toString().padStart(2, "0"), Lt = () => (/* @__PURE__ */ new Date()).toISOString();
764
+ function we(e = /* @__PURE__ */ new Date()) {
765
765
  const t = e.getFullYear(), a = z(e.getMonth() + 1), i = z(e.getDate()), n = z(e.getHours()), o = z(e.getMinutes()), c = z(e.getSeconds());
766
766
  return `${t}-${a}-${i} ${n}:${o}:${c}`;
767
767
  }
768
- function ce(e) {
768
+ function se(e) {
769
769
  if (!/^\d{6}$/.test(e))
770
770
  return;
771
771
  const t = Number(e.slice(0, 4)), a = Number(e.slice(4, 6));
772
772
  if (!(a < 1 || a > 12))
773
773
  return { year: t, month: a };
774
774
  }
775
- function Ve(e) {
775
+ function Re(e) {
776
776
  if (e.length === 0)
777
777
  throw new Error(r("util.parse.error.at_least_one_id"));
778
778
  const t = e.map((i) => {
@@ -784,19 +784,19 @@ function Ve(e) {
784
784
  throw new Error(r("util.parse.error.duplicate_ids"));
785
785
  return t;
786
786
  }
787
- function Lt(e) {
787
+ function Tt(e) {
788
788
  if (!e)
789
789
  return { mode: "all" };
790
790
  if (["all", "*", "a"].includes(e.toLowerCase()))
791
791
  return { mode: "all" };
792
792
  if (/^\d{6}$/.test(e)) {
793
- if (!ce(e))
793
+ if (!se(e))
794
794
  throw new Error(r("util.parse.error.invalid_month_range", { range: e }));
795
795
  return { mode: "month", from: e, to: e };
796
796
  }
797
797
  const t = e.split("-");
798
798
  if (t.length === 2 && /^\d{6}$/.test(t[0]) && /^\d{6}$/.test(t[1])) {
799
- const a = ce(t[0]), i = ce(t[1]);
799
+ const a = se(t[0]), i = se(t[1]);
800
800
  if (!a || !i)
801
801
  throw new Error(r("util.parse.error.invalid_range", { range: e }));
802
802
  if (t[0] > t[1])
@@ -808,19 +808,19 @@ function Lt(e) {
808
808
  function ne(e, t) {
809
809
  return t === "green" ? v.black.bgGreen(` ${e} `) : t === "cyan" ? v.black.bgCyan(` ${e} `) : t === "yellow" ? v.black.bgYellow(` ${e} `) : v.white.bgRed(` ${e} `);
810
810
  }
811
- function C(e) {
811
+ function k(e) {
812
812
  console.log(`${ne(r("terminal.badge.ok"), "green")} ${v.green(e)}`);
813
813
  }
814
- function A(e) {
814
+ function E(e) {
815
815
  console.log(`${ne(r("terminal.badge.info"), "cyan")} ${v.cyan(e)}`);
816
816
  }
817
- function se(e) {
817
+ function le(e) {
818
818
  console.log(`${ne(r("terminal.badge.warn"), "yellow")} ${v.yellow(e)}`);
819
819
  }
820
820
  function j(e) {
821
821
  console.error(`${ne(r("terminal.badge.error"), "red")} ${v.red(e)}`);
822
822
  }
823
- function Tt(e, t) {
823
+ function $t(e, t) {
824
824
  return Array.from({ length: t }, (a, i) => e[i] ?? "");
825
825
  }
826
826
  function B(e, t) {
@@ -829,27 +829,27 @@ function B(e, t) {
829
829
  const a = e.length, i = [];
830
830
  i.push(v.bold(e.join(" "))), i.push(v.dim(e.map((n) => "-".repeat(Math.max(n.length, 3))).join(" ")));
831
831
  for (const n of t)
832
- i.push(Tt(n, a).join(" "));
832
+ i.push($t(n, a).join(" "));
833
833
  return i.join(`
834
834
  `);
835
835
  }
836
- function Xe(e) {
836
+ function Ze(e) {
837
837
  const t = e.toLowerCase();
838
838
  return e === "A" || t === "archived" ? e === "A" ? v.green(e) : v.green(r("terminal.status.archive.archived")) : e === "R" || t === "restored" ? e === "R" ? v.gray(e) : v.gray(r("terminal.status.archive.restored")) : e;
839
839
  }
840
- function $t(e) {
840
+ function Nt(e) {
841
841
  return e === "Valid" ? v.green(r("terminal.status.vault.valid")) : e === "Removed" ? v.yellow(r("terminal.status.vault.removed")) : e === "Protected" ? v.cyan(r("terminal.status.vault.protected")) : e;
842
842
  }
843
- function Re(e) {
843
+ function Le(e) {
844
844
  return e === "ERROR" || e === "FATAL" ? v.red(r(e === "ERROR" ? "terminal.status.log.error" : "terminal.status.log.fatal")) : e === "WARN" ? v.yellow(r("terminal.status.log.warn")) : e === "INFO" ? v.cyan(r("terminal.status.log.info")) : e;
845
845
  }
846
- function Nt(e) {
846
+ function Dt(e) {
847
847
  return e === "put" ? r("command.batch.operation.put") : e === "restore" ? r("command.batch.operation.restore") : e === "move" ? r("command.batch.operation.move") : e;
848
848
  }
849
849
  function K(e, t) {
850
- A(
850
+ E(
851
851
  r("command.batch.summary", {
852
- operation: Nt(e),
852
+ operation: Dt(e),
853
853
  ok: t.ok.length,
854
854
  failed: t.failed.length
855
855
  })
@@ -865,7 +865,7 @@ async function V(e) {
865
865
  }
866
866
  try {
867
867
  const a = await e.updateService.checkLatest();
868
- await e.configService.updateLastCheck(Rt()), a.hasUpdate && A(
868
+ await e.configService.updateLastCheck(Lt()), a.hasUpdate && E(
869
869
  r("command.auto_update.new_available", {
870
870
  latestVersion: a.latestVersion,
871
871
  currentVersion: a.currentVersion
@@ -882,12 +882,12 @@ async function b(e) {
882
882
  j(t.message), process.exitCode = 1;
883
883
  }
884
884
  }
885
- function Dt(e, t) {
885
+ function Pt(e, t) {
886
886
  e.command("put").description(r("command.archive.put.description")).argument("<items...>", r("command.archive.put.argument.items")).option("-v, --vault <vault>", r("command.archive.put.option.vault")).option("-m, --message <message>", r("command.archive.put.option.message")).option("-r, --remark <remark>", r("command.archive.put.option.remark")).action(
887
887
  (a, i) => b(async () => {
888
888
  const n = await t.archiveService.put(a, i);
889
889
  for (const o of n.ok)
890
- C(
890
+ k(
891
891
  r("command.archive.result.put.ok", {
892
892
  id: o.id,
893
893
  input: o.input,
@@ -906,9 +906,9 @@ function Dt(e, t) {
906
906
  })
907
907
  ), e.command("restore").description(r("command.archive.restore.description")).argument("<ids...>", r("command.archive.restore.argument.ids")).action(
908
908
  (a) => b(async () => {
909
- const i = Ve(a), n = await t.archiveService.restore(i);
909
+ const i = Re(a), n = await t.archiveService.restore(i);
910
910
  for (const o of n.ok)
911
- C(
911
+ k(
912
912
  r("command.archive.result.restore.ok", {
913
913
  id: o.id,
914
914
  message: o.message
@@ -925,9 +925,9 @@ function Dt(e, t) {
925
925
  })
926
926
  ), e.command("move").description(r("command.archive.move.description")).argument("<ids...>", r("command.archive.move.argument.ids")).requiredOption("--to <vault>", r("command.archive.move.option.to")).action(
927
927
  (a, i) => b(async () => {
928
- const n = Ve(a), o = await t.archiveService.move(n, i.to);
928
+ const n = Re(a), o = await t.archiveService.move(n, i.to);
929
929
  for (const c of o.ok)
930
- C(
930
+ k(
931
931
  r("command.archive.result.move.ok", {
932
932
  id: c.id,
933
933
  message: c.message
@@ -944,35 +944,35 @@ function Dt(e, t) {
944
944
  })
945
945
  );
946
946
  }
947
- const Pt = v.level;
948
- function Mt(e) {
947
+ const Mt = v.level;
948
+ function Ot(e) {
949
949
  if (typeof e != "string")
950
950
  return;
951
951
  const t = e.trim().toLowerCase();
952
952
  if (t === "on" || t === "off")
953
953
  return t;
954
954
  }
955
- function Ot(e, t = process.env) {
956
- return Mt(t.ARCHIVER_STYLE) ?? e;
955
+ function Ft(e, t = process.env) {
956
+ return Ot(t.ARCHIVER_STYLE) ?? e;
957
957
  }
958
- function Ft(e) {
958
+ function jt(e) {
959
959
  if (e === "off") {
960
960
  v.level = 0;
961
961
  return;
962
962
  }
963
- v.level = Math.max(Pt, 1);
963
+ v.level = Math.max(Mt, 1);
964
964
  }
965
965
  function ee(e, t = process.env) {
966
- const a = Ot(e.style, t);
967
- return Ft(a), a;
966
+ const a = Ft(e.style, t);
967
+ return jt(a), a;
968
968
  }
969
- function Ze(e, t) {
969
+ function Qe(e, t) {
970
970
  return e < 0 ? 0 : e > t.length ? t.length : e;
971
971
  }
972
972
  function P(e, t) {
973
- return { value: e, cursor: Ze(t, e) };
973
+ return { value: e, cursor: Qe(t, e) };
974
974
  }
975
- function jt(e) {
975
+ function Yt(e) {
976
976
  if (!e)
977
977
  return !1;
978
978
  for (const t of e) {
@@ -982,13 +982,13 @@ function jt(e) {
982
982
  }
983
983
  return !0;
984
984
  }
985
- function Yt(e = "") {
985
+ function Ht(e = "") {
986
986
  return { value: e, cursor: e.length };
987
987
  }
988
- function Le(e, t) {
988
+ function Te(e, t) {
989
989
  return t === "left" ? P(e.value, e.cursor - 1) : P(e.value, e.cursor + 1);
990
990
  }
991
- function Te(e, t, a) {
991
+ function $e(e, t, a) {
992
992
  if (a.ctrl && a.name === "c")
993
993
  return { state: e, action: "cancel" };
994
994
  if (a.name === "escape")
@@ -996,9 +996,9 @@ function Te(e, t, a) {
996
996
  if (a.name === "return" || a.name === "enter")
997
997
  return { state: e, action: "submit" };
998
998
  if (a.name === "left")
999
- return { state: Le(e, "left"), action: "continue" };
999
+ return { state: Te(e, "left"), action: "continue" };
1000
1000
  if (a.name === "right")
1001
- return { state: Le(e, "right"), action: "continue" };
1001
+ return { state: Te(e, "right"), action: "continue" };
1002
1002
  if (a.name === "home")
1003
1003
  return { state: P(e.value, 0), action: "continue" };
1004
1004
  if (a.name === "end")
@@ -1015,36 +1015,43 @@ function Te(e, t, a) {
1015
1015
  const n = `${e.value.slice(0, e.cursor)}${e.value.slice(e.cursor + 1)}`;
1016
1016
  return { state: P(n, e.cursor), action: "continue" };
1017
1017
  }
1018
- if (!jt(t))
1018
+ if (!Yt(t))
1019
1019
  return { state: e, action: "continue" };
1020
1020
  const i = `${e.value.slice(0, e.cursor)}${t}${e.value.slice(e.cursor)}`;
1021
1021
  return { state: P(i, e.cursor + t.length), action: "continue" };
1022
1022
  }
1023
- function Ht(e, t = !0, a = "") {
1023
+ function Ut(e, t = !0, a = "") {
1024
1024
  if (!t) {
1025
1025
  const s = e.value || a;
1026
1026
  return v.dim(`[${s}]`);
1027
1027
  }
1028
1028
  if (!e.value)
1029
1029
  return a ? `[${v.dim(a)}]` : `[${v.inverse(" ")}]`;
1030
- const i = Ze(e.cursor, e.value);
1030
+ const i = Qe(e.cursor, e.value);
1031
1031
  if (i >= e.value.length)
1032
1032
  return `[${e.value}${v.inverse(" ")}]`;
1033
1033
  const n = e.value.slice(0, i), o = e.value.slice(i, i + 1), c = e.value.slice(i + 1);
1034
1034
  return `[${n}${v.inverse(o)}${c}]`;
1035
1035
  }
1036
- function Ut(e) {
1036
+ function zt(e) {
1037
1037
  return typeof e == "number" && Number.isFinite(e) && e > 0 ? Math.floor(e) : 24;
1038
1038
  }
1039
- function we(e) {
1040
- const t = e.contentLines.length > 0 ? e.contentLines : [""], a = e.footerLines ?? [], i = Ut(e.rows), n = Math.max(i - t.length - a.length, 0);
1039
+ function Bt(e) {
1040
+ const t = e.contentLines.length > 0 ? e.contentLines : [""], a = e.footerLines ?? [], i = zt(e.rows), n = Math.max(i - t.length - a.length, 0);
1041
1041
  return [...t, ...Array.from({ length: n }, () => ""), ...a];
1042
1042
  }
1043
- function Ie(e = {}) {
1043
+ function Ie(e) {
1044
+ return Bt({
1045
+ contentLines: e.contentLines,
1046
+ footerLines: [e.hintLine ?? "", e.statusLine ?? ""],
1047
+ rows: e.rows
1048
+ });
1049
+ }
1050
+ function ye(e = {}) {
1044
1051
  const t = e.stdinIsTTY ?? !!process.stdin.isTTY, a = e.stdoutIsTTY ?? !!process.stdout.isTTY, i = e.forceInteractive ?? process.env.ARCHIVER_FORCE_INTERACTIVE === "1", n = e.hasRawMode ?? typeof process.stdin.setRawMode == "function";
1045
1052
  return t && n && (a || i);
1046
1053
  }
1047
- function Qe(e, t, a) {
1054
+ function et(e, t, a) {
1048
1055
  if (e.length === 0)
1049
1056
  return;
1050
1057
  const i = a === "left" ? -1 : 1;
@@ -1059,46 +1066,51 @@ function O(e, t) {
1059
1066
  return { options: e, selectedIndex: 0 };
1060
1067
  let a = t === void 0 ? 0 : e.findIndex((i) => Object.is(i.value, t));
1061
1068
  if (a < 0 && (a = 0), e[a]?.disabled) {
1062
- const i = Qe(e, a, "right");
1069
+ const i = et(e, a, "right");
1063
1070
  i !== void 0 && (a = i);
1064
1071
  }
1065
1072
  return { options: e, selectedIndex: a };
1066
1073
  }
1067
1074
  function q(e, t) {
1068
- const a = Qe(e.options, e.selectedIndex, t);
1075
+ const a = et(e.options, e.selectedIndex, t);
1069
1076
  return a === void 0 ? e : { ...e, selectedIndex: a };
1070
1077
  }
1071
1078
  function H(e) {
1072
1079
  return e.options[e.selectedIndex];
1073
1080
  }
1074
- function zt(e) {
1081
+ function qt(e) {
1075
1082
  return Math.max(...e.map((t) => t.label.length), 1);
1076
1083
  }
1077
- function Bt(e, t, a, i) {
1084
+ function Wt(e, t, a, i) {
1078
1085
  const o = `${e.disabled ? "x" : t ? ">" : " "} ${e.label.padEnd(i, " ")}`;
1079
1086
  return e.disabled ? v.dim(`[${o}]`) : t && a ? v.black.bgGreen(`[${o}]`) : t ? v.green(`[${o}]`) : a ? v.green(`[${o}]`) : v.dim(`[${o}]`);
1080
1087
  }
1081
1088
  function te(e, t = !0) {
1082
- const a = zt(e.options);
1083
- return e.options.map((i, n) => Bt(i, n === e.selectedIndex, t, a)).join(" ");
1089
+ const a = qt(e.options);
1090
+ return e.options.map((i, n) => Wt(i, n === e.selectedIndex, t, a)).join(" ");
1084
1091
  }
1085
1092
  function R(e) {
1086
1093
  return v.black.bgWhite(` ${e} `);
1087
1094
  }
1088
- async function qt(e) {
1095
+ async function Jt(e) {
1089
1096
  const t = O(e.options, e.initialValue);
1090
1097
  if (e.options.length === 0)
1091
1098
  return null;
1092
- if (!Ie())
1099
+ if (!ye())
1093
1100
  return H(t)?.value ?? null;
1094
1101
  const a = process.stdin;
1095
1102
  let i = t;
1096
- return ge.emitKeypressEvents(a), a.setRawMode(!0), a.resume(), new Promise((n) => {
1103
+ return pe.emitKeypressEvents(a), a.setRawMode(!0), a.resume(), new Promise((n) => {
1097
1104
  const o = () => {
1098
1105
  const l = [e.title];
1099
1106
  e.description && l.push(v.dim(e.description)), l.push("", te(i));
1100
- const d = e.hint ? [e.hint] : [], m = we({ contentLines: l, footerLines: d, rows: process.stdout.rows });
1101
- process.stdout.write("\x1B[2J\x1B[H\x1B[?25l"), process.stdout.write(m.join(`
1107
+ const d = Ie({
1108
+ contentLines: l,
1109
+ hintLine: e.hint,
1110
+ statusLine: "",
1111
+ rows: process.stdout.rows
1112
+ });
1113
+ process.stdout.write("\x1B[2J\x1B[H\x1B[?25l"), process.stdout.write(d.join(`
1102
1114
  `));
1103
1115
  }, c = (l) => {
1104
1116
  a.off("keypress", s), a.setRawMode(!1), a.pause(), process.stdout.write(`\x1B[2J\x1B[H\x1B[?25h
@@ -1126,8 +1138,8 @@ async function qt(e) {
1126
1138
  a.on("keypress", s), o();
1127
1139
  });
1128
1140
  }
1129
- const Wt = ["updateCheck", "vaultItemSeparator", "style", "language", "noCommandAction"];
1130
- function Jt(e) {
1141
+ const Gt = ["updateCheck", "vaultItemSeparator", "style", "language", "noCommandAction"];
1142
+ function Kt(e) {
1131
1143
  return {
1132
1144
  updateCheck: e.updateCheck,
1133
1145
  vaultItemSeparator: e.vaultItemSeparator,
@@ -1136,7 +1148,7 @@ function Jt(e) {
1136
1148
  noCommandAction: e.noCommandAction
1137
1149
  };
1138
1150
  }
1139
- function Gt(e, t) {
1151
+ function Xt(e, t) {
1140
1152
  return {
1141
1153
  ...e,
1142
1154
  updateCheck: t.updateCheck,
@@ -1146,17 +1158,17 @@ function Gt(e, t) {
1146
1158
  noCommandAction: t.noCommandAction
1147
1159
  };
1148
1160
  }
1149
- function et(e, t) {
1150
- return Wt.every((a) => e[a] === t[a]);
1161
+ function tt(e, t) {
1162
+ return Gt.every((a) => e[a] === t[a]);
1151
1163
  }
1152
- function Kt(e) {
1164
+ function Zt(e) {
1153
1165
  if (!e.vaultItemSeparator.trim())
1154
1166
  return "command.config.vault_item_sep.error.empty";
1155
1167
  }
1156
- function Xt() {
1168
+ function Qt() {
1157
1169
  return !!(process.stdin.isTTY && process.stdout.isTTY && typeof process.stdin.setRawMode == "function");
1158
1170
  }
1159
- function Zt(e) {
1171
+ function ea(e) {
1160
1172
  return [
1161
1173
  {
1162
1174
  kind: "select",
@@ -1174,7 +1186,7 @@ function Zt(e) {
1174
1186
  kind: "input",
1175
1187
  key: "vaultItemSeparator",
1176
1188
  label: r("command.config.edit.field.vault_item_sep"),
1177
- state: Yt(e.vaultItemSeparator)
1189
+ state: Ht(e.vaultItemSeparator)
1178
1190
  },
1179
1191
  {
1180
1192
  kind: "select",
@@ -1215,10 +1227,10 @@ function Zt(e) {
1215
1227
  }
1216
1228
  ];
1217
1229
  }
1218
- function $e(e, t, a) {
1230
+ function Ne(e, t, a) {
1219
1231
  return a <= 0 ? 0 : t === "up" ? (e - 1 + a) % a : (e + 1) % a;
1220
1232
  }
1221
- function tt(e, t) {
1233
+ function at(e, t) {
1222
1234
  const a = { ...t };
1223
1235
  for (const i of e) {
1224
1236
  if (i.kind === "input") {
@@ -1244,11 +1256,11 @@ function tt(e, t) {
1244
1256
  }
1245
1257
  return a;
1246
1258
  }
1247
- function Qt(e) {
1259
+ function ta(e) {
1248
1260
  return Math.max(...e.map((t) => t.label.length), 1);
1249
1261
  }
1250
1262
  function N(e, t, a, i, n) {
1251
- const o = tt(e, a), c = !et(o, a), s = Qt(e), l = e.length, d = t === l, m = r("command.config.edit.hint", {
1263
+ const o = at(e, a), c = !tt(o, a), s = ta(e), l = e.length, d = t === l, m = r("command.config.edit.hint", {
1252
1264
  upDown: R(r("command.config.edit.key.up_down")),
1253
1265
  leftRight: R(r("command.config.edit.key.left_right")),
1254
1266
  type: R(r("command.config.edit.key.type")),
@@ -1256,36 +1268,37 @@ function N(e, t, a, i, n) {
1256
1268
  cancel: R(r("command.config.edit.key.cancel"))
1257
1269
  }), u = [];
1258
1270
  u.push(v.bold(r("command.config.edit.title"))), u.push("");
1259
- for (let k = 0; k < e.length; k += 1) {
1260
- const x = e[k];
1271
+ for (let L = 0; L < e.length; L += 1) {
1272
+ const x = e[L];
1261
1273
  if (!x)
1262
1274
  continue;
1263
- const L = k === t, T = L ? v.cyan(">") : " ", re = L ? v.bold(x.label.padEnd(s, " ")) : x.label.padEnd(s, " "), oe = x.kind === "select" ? te(x.state, L) : Ht(x.state, L, r("command.config.edit.input.placeholder"));
1264
- u.push(`${T} ${re} ${oe}`);
1275
+ const T = L === t, re = T ? v.cyan(">") : " ", oe = T ? v.bold(x.label.padEnd(s, " ")) : x.label.padEnd(s, " "), ce = x.kind === "select" ? te(x.state, T) : Ut(x.state, T, r("command.config.edit.input.placeholder"));
1276
+ u.push(`${re} ${oe} ${ce}`);
1265
1277
  }
1266
- u.push(""), u.push(`${r("command.config.edit.action_prefix")} ${te(i, d)}`), u.push(""), u.push(v.dim(r(c ? "command.config.edit.state.dirty" : "command.config.edit.state.clean"))), n && u.push(v.yellow(n));
1267
- const _ = we({
1278
+ u.push(""), u.push(`${r("command.config.edit.action_prefix")} ${te(i, d)}`), u.push("");
1279
+ const _ = n ? v.yellow(n) : v.dim(r(c ? "command.config.edit.state.dirty" : "command.config.edit.state.clean")), A = Ie({
1268
1280
  contentLines: u,
1269
- footerLines: [m],
1281
+ hintLine: m,
1282
+ statusLine: _,
1270
1283
  rows: process.stdout.rows
1271
1284
  });
1272
- process.stdout.write("\x1B[2J\x1B[H\x1B[?25l"), process.stdout.write(_.join(`
1285
+ process.stdout.write("\x1B[2J\x1B[H\x1B[?25l"), process.stdout.write(A.join(`
1273
1286
  `));
1274
1287
  }
1275
- async function ea(e) {
1276
- if (!Xt())
1288
+ async function aa(e) {
1289
+ if (!Qt())
1277
1290
  throw new Error(r("command.config.edit.error.no_tty"));
1278
- const t = process.stdin, a = Zt(e);
1291
+ const t = process.stdin, a = ea(e);
1279
1292
  let i = O([
1280
1293
  { value: "save", label: r("command.config.edit.action.save") },
1281
1294
  { value: "cancel", label: r("command.config.edit.action.cancel") }
1282
1295
  ]), n = 0, o = "";
1283
- return ge.emitKeypressEvents(t), t.setRawMode(!0), t.resume(), new Promise((c) => {
1296
+ return pe.emitKeypressEvents(t), t.setRawMode(!0), t.resume(), new Promise((c) => {
1284
1297
  const s = (m) => {
1285
1298
  t.off("keypress", d), t.setRawMode(!1), t.pause(), process.stdout.write(`\x1B[2J\x1B[H\x1B[?25h
1286
1299
  `), c(m);
1287
1300
  }, l = () => {
1288
- const m = tt(a, e), u = Kt(m);
1301
+ const m = at(a, e), u = Zt(m);
1289
1302
  if (u) {
1290
1303
  o = r(u), N(a, n, e, i, o);
1291
1304
  return;
@@ -1301,11 +1314,11 @@ async function ea(e) {
1301
1314
  return;
1302
1315
  }
1303
1316
  if (u.name === "up") {
1304
- n = $e(n, "up", a.length + 1), o = "", N(a, n, e, i, o);
1317
+ n = Ne(n, "up", a.length + 1), o = "", N(a, n, e, i, o);
1305
1318
  return;
1306
1319
  }
1307
1320
  if (u.name === "down") {
1308
- n = $e(n, "down", a.length + 1), o = "", N(a, n, e, i, o);
1321
+ n = Ne(n, "down", a.length + 1), o = "", N(a, n, e, i, o);
1309
1322
  return;
1310
1323
  }
1311
1324
  if (n === a.length) {
@@ -1336,16 +1349,16 @@ async function ea(e) {
1336
1349
  return;
1337
1350
  }
1338
1351
  if (u.name === "left" || u.name === "right") {
1339
- _.kind === "select" ? _.state = q(_.state, u.name) : _.state = Te(_.state, m, u).state, o = "", N(a, n, e, i, o);
1352
+ _.kind === "select" ? _.state = q(_.state, u.name) : _.state = $e(_.state, m, u).state, o = "", N(a, n, e, i, o);
1340
1353
  return;
1341
1354
  }
1342
1355
  if (_.kind === "input") {
1343
- const k = Te(_.state, m, u);
1344
- if (_.state = k.state, k.action === "cancel") {
1356
+ const A = $e(_.state, m, u);
1357
+ if (_.state = A.state, A.action === "cancel") {
1345
1358
  s(null);
1346
1359
  return;
1347
1360
  }
1348
- if (k.action === "submit") {
1361
+ if (A.action === "submit") {
1349
1362
  l();
1350
1363
  return;
1351
1364
  }
@@ -1357,7 +1370,7 @@ async function ea(e) {
1357
1370
  t.on("keypress", d), N(a, n, e, i, o);
1358
1371
  });
1359
1372
  }
1360
- function ta(e, t) {
1373
+ function ia(e, t) {
1361
1374
  const a = e.command("config").description(r("command.config.description"));
1362
1375
  a.command("list").description(r("command.config.list.description")).option("-c, --comment", r("command.config.list.option.comment")).action(
1363
1376
  (i) => b(async () => {
@@ -1387,17 +1400,17 @@ function ta(e, t) {
1387
1400
  })
1388
1401
  ), a.command("edit").alias("e").description(r("command.config.edit.description")).action(
1389
1402
  () => b(async () => {
1390
- const i = await t.configService.getConfig(), n = Jt(i), o = await ea(n);
1403
+ const i = await t.configService.getConfig(), n = Kt(i), o = await aa(n);
1391
1404
  if (!o) {
1392
- A(r("command.config.edit.cancelled"));
1405
+ E(r("command.config.edit.cancelled"));
1393
1406
  return;
1394
1407
  }
1395
- if (et(n, o)) {
1396
- A(r("command.config.edit.no_changes"));
1408
+ if (tt(n, o)) {
1409
+ E(r("command.config.edit.no_changes"));
1397
1410
  return;
1398
1411
  }
1399
- const c = Gt(i, o);
1400
- await t.context.saveConfig(c), ee(c), C(r("command.config.edit.saved")), await t.auditLogger.log(
1412
+ const c = Xt(i, o);
1413
+ await t.context.saveConfig(c), ee(c), k(r("command.config.edit.saved")), await t.auditLogger.log(
1401
1414
  "INFO",
1402
1415
  { main: "config", sub: "edit", source: "u" },
1403
1416
  r("command.config.edit.audit.saved")
@@ -1408,7 +1421,7 @@ function ta(e, t) {
1408
1421
  const n = i.toLowerCase();
1409
1422
  if (n !== "on" && n !== "off")
1410
1423
  throw new Error(r("command.config.state.error"));
1411
- await t.configService.setUpdateCheck(n), C(r("command.config.update_check.updated", { state: n })), await t.auditLogger.log(
1424
+ await t.configService.setUpdateCheck(n), k(r("command.config.update_check.updated", { state: n })), await t.auditLogger.log(
1412
1425
  "INFO",
1413
1426
  { main: "config", sub: "update-check", args: [n], source: "u" },
1414
1427
  r("command.config.update_check.updated", { state: n })
@@ -1420,7 +1433,7 @@ function ta(e, t) {
1420
1433
  if (n !== "on" && n !== "off")
1421
1434
  throw new Error(r("command.config.state.error"));
1422
1435
  const o = await t.configService.setStyle(n);
1423
- ee(o), C(r("command.config.style.updated", { state: n })), await t.auditLogger.log(
1436
+ ee(o), k(r("command.config.style.updated", { state: n })), await t.auditLogger.log(
1424
1437
  "INFO",
1425
1438
  { main: "config", sub: "style", args: [n], source: "u" },
1426
1439
  r("command.config.style.updated", { state: n })
@@ -1430,7 +1443,7 @@ function ta(e, t) {
1430
1443
  (i) => b(async () => {
1431
1444
  if (!i.trim())
1432
1445
  throw new Error(r("command.config.vault_item_sep.error.empty"));
1433
- await t.configService.setVaultItemSeparator(i), C(
1446
+ await t.configService.setVaultItemSeparator(i), k(
1434
1447
  r("command.config.vault_item_sep.updated", {
1435
1448
  separator: i
1436
1449
  })
@@ -1447,7 +1460,7 @@ function ta(e, t) {
1447
1460
  const n = i.toLowerCase();
1448
1461
  if (n !== "help" && n !== "list" && n !== "unknown")
1449
1462
  throw new Error(r("command.config.no_command_action.error.invalid"));
1450
- await t.configService.setNoCommandAction(n), C(r("command.config.no_command_action.updated", { action: n })), await t.auditLogger.log(
1463
+ await t.configService.setNoCommandAction(n), k(r("command.config.no_command_action.updated", { action: n })), await t.auditLogger.log(
1451
1464
  "INFO",
1452
1465
  { main: "config", sub: "no-command-action", args: [n], source: "u" },
1453
1466
  r("command.config.no_command_action.updated", { action: n })
@@ -1458,7 +1471,7 @@ function ta(e, t) {
1458
1471
  const n = i.toLowerCase();
1459
1472
  if (n !== "zh" && n !== "en")
1460
1473
  throw new Error(r("command.config.language.error.invalid"));
1461
- await t.configService.setLanguage(n), C(r("command.config.language.updated", { language: n })), await t.auditLogger.log(
1474
+ await t.configService.setLanguage(n), k(r("command.config.language.updated", { language: n })), await t.auditLogger.log(
1462
1475
  "INFO",
1463
1476
  { main: "config", sub: "language", args: [n], source: "u" },
1464
1477
  r("command.config.language.updated", { language: n })
@@ -1466,8 +1479,8 @@ function ta(e, t) {
1466
1479
  })
1467
1480
  );
1468
1481
  }
1469
- const aa = "__ARCHIVER_CD__:";
1470
- function ia(e, t) {
1482
+ const na = "__ARCHIVER_CD__:";
1483
+ function ra(e, t) {
1471
1484
  if (e.includes(`
1472
1485
  `) || e.includes("\r"))
1473
1486
  throw new Error(
@@ -1476,38 +1489,38 @@ function ia(e, t) {
1476
1489
  })
1477
1490
  );
1478
1491
  }
1479
- function na(e) {
1480
- return ia(e, r("util.cd.label.archive_slot_path")), `${aa}${e}`;
1492
+ function oa(e) {
1493
+ return ra(e, r("util.cd.label.archive_slot_path")), `${na}${e}`;
1481
1494
  }
1482
- async function ra(e) {
1483
- console.log(na(e));
1495
+ async function ca(e) {
1496
+ console.log(oa(e));
1484
1497
  }
1485
- function Ne(e) {
1498
+ function De(e) {
1486
1499
  return r(e === "enter" ? "command.list.interactive.action.enter" : "command.list.interactive.action.restore");
1487
1500
  }
1488
- function at() {
1489
- return Ie();
1501
+ function it() {
1502
+ return ye();
1490
1503
  }
1491
- function he(e, t) {
1504
+ function fe(e, t) {
1492
1505
  return t === "enter" || t === "restore" ? e.status === y.Archived : !1;
1493
1506
  }
1494
- function ye(e, t) {
1507
+ function be(e, t) {
1495
1508
  return O(
1496
1509
  [
1497
- { value: "enter", label: Ne("enter"), disabled: !he(e, "enter") },
1498
- { value: "restore", label: Ne("restore"), disabled: !he(e, "restore") }
1510
+ { value: "enter", label: De("enter"), disabled: !fe(e, "enter") },
1511
+ { value: "restore", label: De("restore"), disabled: !fe(e, "restore") }
1499
1512
  ],
1500
1513
  t
1501
1514
  );
1502
1515
  }
1503
- function oa(e, t) {
1504
- return H(ye(e, t))?.value ?? t;
1516
+ function sa(e, t) {
1517
+ return H(be(e, t))?.value ?? t;
1505
1518
  }
1506
- function De(e, t, a) {
1507
- const i = ye(e, t), n = q(i, a);
1519
+ function Pe(e, t, a) {
1520
+ const i = be(e, t), n = q(i, a);
1508
1521
  return H(n)?.value ?? t;
1509
1522
  }
1510
- function Pe(e, t, a) {
1523
+ function Me(e, t, a) {
1511
1524
  return a <= 0 ? 0 : t === "up" ? (e - 1 + a) % a : (e + 1) % a;
1512
1525
  }
1513
1526
  function F(e, t, a, i) {
@@ -1519,37 +1532,36 @@ function F(e, t, a, i) {
1519
1532
  leftRight: R(r("command.list.interactive.key.left_right")),
1520
1533
  enter: R(r("command.list.interactive.key.enter")),
1521
1534
  cancel: R(r("command.list.interactive.key.cancel"))
1522
- }), s = ye(n, a), l = [
1535
+ }), s = be(n, a), l = [
1523
1536
  `${r("command.list.interactive.action_prefix")} ${te(s)}`,
1524
- i ? v.yellow(i) : "",
1525
1537
  ""
1526
- ], m = Math.max(o - l.length - 2, 2), u = Math.max(Math.floor(m / 2), 1), _ = Math.floor(u / 2), k = Math.max(e.length - u, 0), x = Math.min(Math.max(t - _, 0), k), L = Math.min(x + u, e.length), T = [...l];
1527
- for (let W = x; W < L; W += 1) {
1538
+ ], m = Math.max(o - l.length - 2, 2), u = Math.max(Math.floor(m / 2), 1), _ = Math.floor(u / 2), A = Math.max(e.length - u, 0), L = Math.min(Math.max(t - _, 0), A), x = Math.min(L + u, e.length), T = [...l];
1539
+ for (let W = L; W < x; W += 1) {
1528
1540
  const U = e[W];
1529
1541
  if (!U)
1530
1542
  continue;
1531
- const ke = W === t, lt = ke ? v.cyan(">") : " ", dt = U.status === y.Archived ? v.green("A") : v.gray("R"), Ce = `${lt} [${String(U.id).padStart(4, " ")}] ${dt} ${U.title}`, Ee = ` ${v.dim(U.path)}`;
1532
- ke ? (T.push(v.bold(Ce)), T.push(v.cyan(Ee))) : (T.push(Ce), T.push(Ee));
1533
- }
1534
- const re = [
1535
- v.dim(
1536
- r("command.list.interactive.showing", {
1537
- start: x + 1,
1538
- end: L,
1539
- total: e.length
1540
- })
1541
- ),
1542
- c
1543
- ], oe = we({ contentLines: T, footerLines: re, rows: o });
1544
- process.stdout.write("\x1B[2J\x1B[H\x1B[?25l"), process.stdout.write(oe.join(`
1543
+ const Ce = W === t, dt = Ce ? v.cyan(">") : " ", ut = U.status === y.Archived ? v.green("A") : v.gray("R"), Ee = `${dt} [${String(U.id).padStart(4, " ")}] ${ut} ${U.title}`, Ae = ` ${v.dim(U.path)}`;
1544
+ Ce ? (T.push(v.bold(Ee)), T.push(v.cyan(Ae))) : (T.push(Ee), T.push(Ae));
1545
+ }
1546
+ const re = r("command.list.interactive.showing", {
1547
+ start: L + 1,
1548
+ end: x,
1549
+ total: e.length
1550
+ }), oe = i ? v.yellow(i) : v.dim(re), ce = Ie({
1551
+ contentLines: T,
1552
+ hintLine: c,
1553
+ statusLine: oe,
1554
+ rows: o
1555
+ });
1556
+ process.stdout.write("\x1B[2J\x1B[H\x1B[?25l"), process.stdout.write(ce.join(`
1545
1557
  `));
1546
1558
  }
1547
- async function ca(e) {
1548
- if (e.length === 0 || !at())
1559
+ async function la(e) {
1560
+ if (e.length === 0 || !it())
1549
1561
  return null;
1550
1562
  const t = process.stdin;
1551
1563
  let a = 0, i = "enter", n = "";
1552
- return ge.emitKeypressEvents(t), t.setRawMode(!0), t.resume(), new Promise((o) => {
1564
+ return pe.emitKeypressEvents(t), t.setRawMode(!0), t.resume(), new Promise((o) => {
1553
1565
  const c = (l) => {
1554
1566
  t.off("keypress", s), t.setRawMode(!1), t.pause(), process.stdout.write(`\x1B[2J\x1B[H\x1B[?25h
1555
1567
  `), o(l);
@@ -1559,11 +1571,11 @@ async function ca(e) {
1559
1571
  return;
1560
1572
  }
1561
1573
  if (d.name === "up") {
1562
- a = Pe(a, "up", e.length), n = "", F(e, a, i, n);
1574
+ a = Me(a, "up", e.length), n = "", F(e, a, i, n);
1563
1575
  return;
1564
1576
  }
1565
1577
  if (d.name === "down") {
1566
- a = Pe(a, "down", e.length), n = "", F(e, a, i, n);
1578
+ a = Me(a, "down", e.length), n = "", F(e, a, i, n);
1567
1579
  return;
1568
1580
  }
1569
1581
  if (d.name === "left") {
@@ -1572,7 +1584,7 @@ async function ca(e) {
1572
1584
  c(null);
1573
1585
  return;
1574
1586
  }
1575
- i = De(m, i, "left"), n = "", F(e, a, i, n);
1587
+ i = Pe(m, i, "left"), n = "", F(e, a, i, n);
1576
1588
  return;
1577
1589
  }
1578
1590
  if (d.name === "right") {
@@ -1581,7 +1593,7 @@ async function ca(e) {
1581
1593
  c(null);
1582
1594
  return;
1583
1595
  }
1584
- i = De(m, i, "right"), n = "", F(e, a, i, n);
1596
+ i = Pe(m, i, "right"), n = "", F(e, a, i, n);
1585
1597
  return;
1586
1598
  }
1587
1599
  if (d.name === "return" || d.name === "enter") {
@@ -1590,8 +1602,8 @@ async function ca(e) {
1590
1602
  c(null);
1591
1603
  return;
1592
1604
  }
1593
- const u = oa(m, i);
1594
- if (!he(m, u)) {
1605
+ const u = sa(m, i);
1606
+ if (!fe(m, u)) {
1595
1607
  n = r("command.list.interactive.note.restored_unavailable"), F(e, a, i, n);
1596
1608
  return;
1597
1609
  }
@@ -1603,41 +1615,41 @@ async function ca(e) {
1603
1615
  t.on("keypress", s), F(e, a, i, n);
1604
1616
  });
1605
1617
  }
1606
- function be(e, t) {
1618
+ function ke(e, t) {
1607
1619
  return e.vaultId === g.Vault.id ? e.item : `${e.vaultName}${t}${e.item}`;
1608
1620
  }
1609
- function sa(e) {
1621
+ function da(e) {
1610
1622
  return String(e).padStart(4, "0");
1611
1623
  }
1612
- function it(e) {
1624
+ function nt(e) {
1613
1625
  return e.status === y.Archived ? "A" : "R";
1614
1626
  }
1615
- function la(e, t) {
1616
- const a = Xe(it(e));
1617
- return `[${sa(e.id)}] ${a} ${be(e, t)}`;
1627
+ function ua(e, t) {
1628
+ const a = Ze(nt(e));
1629
+ return `[${da(e.id)}] ${a} ${ke(e, t)}`;
1618
1630
  }
1619
- function da(e, t) {
1620
- return e.map((a) => la(a, t)).join(`
1631
+ function ma(e, t) {
1632
+ return e.map((a) => ua(a, t)).join(`
1621
1633
  `);
1622
1634
  }
1623
- function ua(e, t) {
1624
- return e.map((a) => `${a.id} ${it(a)} ${be(a, t)}`).join(`
1635
+ function va(e, t) {
1636
+ return e.map((a) => `${a.id} ${nt(a)} ${ke(a, t)}`).join(`
1625
1637
  `);
1626
1638
  }
1627
- function ma(e, t) {
1639
+ function ha(e, t) {
1628
1640
  return e.map((a) => ({
1629
1641
  id: a.id,
1630
1642
  status: a.status,
1631
- title: be(a, t),
1643
+ title: ke(a, t),
1632
1644
  path: a.displayPath
1633
1645
  }));
1634
1646
  }
1635
- async function va(e, t) {
1647
+ async function fa(e, t) {
1636
1648
  const a = t.entry.id;
1637
1649
  if (t.action === "restore") {
1638
1650
  const n = await e.archiveService.restore([a]);
1639
1651
  for (const o of n.ok)
1640
- C(
1652
+ k(
1641
1653
  r("command.archive.result.restore.ok", {
1642
1654
  id: o.id,
1643
1655
  message: o.message
@@ -1667,37 +1679,37 @@ async function va(e, t) {
1667
1679
  archiveId: i.archiveId
1668
1680
  }),
1669
1681
  { aid: i.archiveId, vid: i.vault.id }
1670
- ), await ra(i.slotPath);
1682
+ ), await ca(i.slotPath);
1671
1683
  }
1672
- function ha(e, t) {
1684
+ function ga(e, t) {
1673
1685
  e.command("list").description(r("command.list.description")).option("-r, --restored", r("command.list.option.restored")).option("-a, --all", r("command.list.option.all")).option("-v, --vault <vault>", r("command.list.option.vault")).option("--no-interactive", r("command.list.option.no_interactive")).option("-p, --plain", r("command.list.option.plain")).action(
1674
1686
  (a) => b(async () => {
1675
1687
  const i = await t.archiveService.listEntries(a), n = await t.archiveService.decorateEntries(i), o = await t.configService.getConfig();
1676
1688
  if (n.length === 0) {
1677
1689
  if (a.plain)
1678
1690
  return;
1679
- A(r("command.list.empty"));
1691
+ E(r("command.list.empty"));
1680
1692
  return;
1681
1693
  }
1682
1694
  if (a.plain) {
1683
- console.log(ua(n, o.vaultItemSeparator));
1695
+ console.log(va(n, o.vaultItemSeparator));
1684
1696
  return;
1685
1697
  }
1686
- const c = a.interactive !== !1 && at(), s = n.some((d) => d.status === y.Archived);
1698
+ const c = a.interactive !== !1 && it(), s = n.some((d) => d.status === y.Archived);
1687
1699
  if (!c || !s) {
1688
- console.log(da(n, o.vaultItemSeparator)), c && !s && A(r("command.list.restored_only_notice"));
1700
+ console.log(ma(n, o.vaultItemSeparator)), c && !s && E(r("command.list.restored_only_notice"));
1689
1701
  return;
1690
1702
  }
1691
- const l = await ca(ma(n, o.vaultItemSeparator));
1703
+ const l = await la(ha(n, o.vaultItemSeparator));
1692
1704
  if (!l) {
1693
- A(r("command.list.cancelled"));
1705
+ E(r("command.list.cancelled"));
1694
1706
  return;
1695
1707
  }
1696
- await va(t, l);
1708
+ await fa(t, l);
1697
1709
  })
1698
1710
  );
1699
1711
  }
1700
- function fa(e, t) {
1712
+ function pa(e, t) {
1701
1713
  e.command("log").description(r("command.log.description")).argument("[range]", r("command.log.argument.range")).option("--id <id>", r("command.log.option.id")).action(
1702
1714
  (a, i) => b(async () => {
1703
1715
  if (i.id !== void 0) {
@@ -1706,7 +1718,7 @@ function fa(e, t) {
1706
1718
  const s = Number(i.id), l = await t.logService.getLogById(s);
1707
1719
  if (!l)
1708
1720
  throw new Error(r("command.log.error.not_found", { id: s }));
1709
- A(
1721
+ E(
1710
1722
  r("command.log.detail.title", {
1711
1723
  id: l.log.id
1712
1724
  })
@@ -1716,7 +1728,7 @@ function fa(e, t) {
1716
1728
  [
1717
1729
  [r("command.log.detail.field.id"), String(l.log.id)],
1718
1730
  [r("command.log.detail.field.time"), l.log.operedAt],
1719
- [r("command.log.detail.field.level"), Re(l.log.level)],
1731
+ [r("command.log.detail.field.level"), Le(l.log.level)],
1720
1732
  [
1721
1733
  r("command.log.detail.field.operation"),
1722
1734
  `${l.log.oper.main}${l.log.oper.sub ? `/${l.log.oper.sub}` : ""}`
@@ -1732,7 +1744,7 @@ function fa(e, t) {
1732
1744
  ]
1733
1745
  ]
1734
1746
  )
1735
- ), l.archive && (A(r("command.log.detail.linked_archive")), console.log(
1747
+ ), l.archive && (E(r("command.log.detail.linked_archive")), console.log(
1736
1748
  B(
1737
1749
  [
1738
1750
  r("command.log.detail.archive.table.id"),
@@ -1744,14 +1756,14 @@ function fa(e, t) {
1744
1756
  [
1745
1757
  [
1746
1758
  String(l.archive.id),
1747
- Xe(l.archive.status),
1759
+ Ze(l.archive.status),
1748
1760
  String(l.archive.vaultId),
1749
1761
  l.archive.item,
1750
1762
  l.archive.directory
1751
1763
  ]
1752
1764
  ]
1753
1765
  )
1754
- )), l.vault && (A(r("command.log.detail.linked_vault")), console.log(
1766
+ )), l.vault && (E(r("command.log.detail.linked_vault")), console.log(
1755
1767
  B(
1756
1768
  [
1757
1769
  r("command.log.detail.vault.table.id"),
@@ -1763,7 +1775,7 @@ function fa(e, t) {
1763
1775
  [
1764
1776
  String(l.vault.id),
1765
1777
  l.vault.name,
1766
- $t(l.vault.status),
1778
+ Nt(l.vault.status),
1767
1779
  l.vault.remark
1768
1780
  ]
1769
1781
  ]
@@ -1771,15 +1783,15 @@ function fa(e, t) {
1771
1783
  ));
1772
1784
  return;
1773
1785
  }
1774
- const n = Lt(a), o = await t.logService.getLogs(n);
1786
+ const n = Tt(a), o = await t.logService.getLogs(n);
1775
1787
  if (o.length === 0) {
1776
- A(r("command.log.empty"));
1788
+ E(r("command.log.empty"));
1777
1789
  return;
1778
1790
  }
1779
1791
  const c = o.map((s) => [
1780
1792
  String(s.id),
1781
1793
  s.operedAt,
1782
- Re(s.level),
1794
+ Le(s.level),
1783
1795
  `${s.oper.main}${s.oper.sub ? `/${s.oper.sub}` : ""}`,
1784
1796
  s.message,
1785
1797
  s.archiveIds !== void 0 ? String(s.archiveIds) : "",
@@ -1805,17 +1817,17 @@ function fa(e, t) {
1805
1817
  async function Y(e) {
1806
1818
  await p.mkdir(e, { recursive: !0 });
1807
1819
  }
1808
- const E = (e) => p.access(e).then(() => !0).catch(() => !1), Me = (e) => p.realpath(e).catch(() => h.resolve(e)), ga = (e, t) => h.normalize(e) === h.normalize(t);
1809
- function nt(e, t) {
1820
+ const C = (e) => p.access(e).then(() => !0).catch(() => !1), Oe = (e) => p.realpath(e).catch(() => h.resolve(e)), _a = (e, t) => h.normalize(e) === h.normalize(t);
1821
+ function rt(e, t) {
1810
1822
  const a = h.relative(h.resolve(e), h.resolve(t));
1811
1823
  return a.length > 0 && !a.startsWith("..") && !h.isAbsolute(a);
1812
1824
  }
1813
- function pa(e, t) {
1814
- return ga(e, t) || nt(e, t);
1825
+ function wa(e, t) {
1826
+ return _a(e, t) || rt(e, t);
1815
1827
  }
1816
1828
  async function X(e) {
1817
1829
  const t = h.dirname(e);
1818
- await Y(t), await E(e) || await p.writeFile(e, "", "utf8");
1830
+ await Y(t), await C(e) || await p.writeFile(e, "", "utf8");
1819
1831
  }
1820
1832
  async function ae(e) {
1821
1833
  try {
@@ -1826,7 +1838,7 @@ async function ae(e) {
1826
1838
  throw t;
1827
1839
  }
1828
1840
  }
1829
- async function _a(e) {
1841
+ async function Ia(e) {
1830
1842
  try {
1831
1843
  return (await p.readdir(e, { withFileTypes: !0 })).filter((a) => a.isDirectory()).map((a) => a.name);
1832
1844
  } catch (t) {
@@ -1835,7 +1847,7 @@ async function _a(e) {
1835
1847
  throw t;
1836
1848
  }
1837
1849
  }
1838
- class rt extends Error {
1850
+ class ot extends Error {
1839
1851
  constructor(t) {
1840
1852
  super(
1841
1853
  r("service.vault.error.removed_exists", {
@@ -1844,7 +1856,7 @@ class rt extends Error {
1844
1856
  ), this.name = "VaultRemovedExistsError";
1845
1857
  }
1846
1858
  }
1847
- class wa {
1859
+ class ya {
1848
1860
  constructor(t, a) {
1849
1861
  this.context = t, this.configService = a;
1850
1862
  }
@@ -1870,14 +1882,14 @@ class wa {
1870
1882
  );
1871
1883
  if (n?.status === "Removed") {
1872
1884
  if (!t.recoverRemoved)
1873
- throw new rt(a);
1885
+ throw new ot(a);
1874
1886
  return n.status = S.Valid, await this.context.ensureVaultDir(n.id), await this.context.saveVaults(i), t.activate && await this.configService.setCurrentVault(n.id), { vault: n, recovered: !0 };
1875
1887
  }
1876
1888
  const c = {
1877
1889
  id: await this.context.nextAutoIncrement("vaultId"),
1878
1890
  name: a,
1879
1891
  remark: t.remark ?? "",
1880
- createdAt: _e(),
1892
+ createdAt: we(),
1881
1893
  status: S.Valid
1882
1894
  };
1883
1895
  return i.push(c), await this.context.saveVaults(i), await this.context.ensureVaultDir(c.id), t.activate && await this.configService.setCurrentVault(c.id), { vault: c, recovered: !1 };
@@ -1985,13 +1997,13 @@ class wa {
1985
1997
  async validateMoveToDefault(t) {
1986
1998
  for (const a of t) {
1987
1999
  const i = this.context.archivePath(a.vaultId, a.id), n = this.context.archivePath(g.Vault.id, a.id);
1988
- if (!await E(i))
2000
+ if (!await C(i))
1989
2001
  throw new Error(
1990
2002
  r("service.vault.error.archived_object_missing", {
1991
2003
  path: i
1992
2004
  })
1993
2005
  );
1994
- if (await E(n))
2006
+ if (await C(n))
1995
2007
  throw new Error(
1996
2008
  r("service.vault.error.default_contains_archive_id", {
1997
2009
  id: a.id
@@ -2008,7 +2020,7 @@ class wa {
2008
2020
  }
2009
2021
  async listArchivedIdsInVault(t) {
2010
2022
  const a = this.context.vaultDir(t);
2011
- return await E(a) ? (await p.readdir(a, { withFileTypes: !0 })).filter((o) => o.isFile() || o.isDirectory() || o.isSymbolicLink()).map((o) => o.name).filter((o) => /^\d+$/.test(o)).map((o) => Number(o)).sort((o, c) => o - c) : [];
2023
+ return await C(a) ? (await p.readdir(a, { withFileTypes: !0 })).filter((o) => o.isFile() || o.isDirectory() || o.isSymbolicLink()).map((o) => o.name).filter((o) => /^\d+$/.test(o)).map((o) => Number(o)).sort((o, c) => o - c) : [];
2012
2024
  }
2013
2025
  getVaultDisplay(t) {
2014
2026
  return t.id === g.Vault.id ? `${t.name}(${t.id})` : `${t.name}(${t.id})`;
@@ -2017,24 +2029,24 @@ class wa {
2017
2029
  return h.join(f.Dir.vaults, String(t.id));
2018
2030
  }
2019
2031
  }
2020
- async function ot(e) {
2021
- const t = pt.createInterface({ input: wt, output: _t });
2032
+ async function ct(e) {
2033
+ const t = _t.createInterface({ input: It, output: wt });
2022
2034
  try {
2023
2035
  return (await t.question(e)).trim();
2024
2036
  } finally {
2025
2037
  t.close();
2026
2038
  }
2027
2039
  }
2028
- async function Oe(e, t = !0) {
2029
- const a = (await ot(e)).toLowerCase();
2040
+ async function Fe(e, t = !0) {
2041
+ const a = (await ct(e)).toLowerCase();
2030
2042
  return a ? ["y", "yes"].includes(a) : !t;
2031
2043
  }
2032
- function Ia(e, t) {
2044
+ function ba(e, t) {
2033
2045
  const a = e.command("vault").description(r("command.vault.description"));
2034
2046
  a.command("use").description(r("command.vault.use.description")).argument("<name-or-id>", r("command.vault.use.argument")).action(
2035
2047
  (i) => b(async () => {
2036
2048
  const n = await t.vaultService.useVault(i);
2037
- C(
2049
+ k(
2038
2050
  r("command.vault.use.updated", {
2039
2051
  name: n.name,
2040
2052
  id: n.id
@@ -2059,12 +2071,12 @@ function Ia(e, t) {
2059
2071
  activate: n.activate,
2060
2072
  recoverRemoved: s
2061
2073
  });
2062
- o = l.recovered, C(
2074
+ o = l.recovered, k(
2063
2075
  r(o ? "command.vault.create.recovered" : "command.vault.create.created", {
2064
2076
  name: l.vault.name,
2065
2077
  id: l.vault.id
2066
2078
  })
2067
- ), n.activate && C(
2079
+ ), n.activate && k(
2068
2080
  r("command.vault.create.activated", {
2069
2081
  name: l.vault.name,
2070
2082
  id: l.vault.id
@@ -2090,13 +2102,13 @@ function Ia(e, t) {
2090
2102
  try {
2091
2103
  await c(!1);
2092
2104
  } catch (s) {
2093
- if (s instanceof rt) {
2094
- if (!await Oe(
2105
+ if (s instanceof ot) {
2106
+ if (!await Fe(
2095
2107
  r("command.vault.create.confirm_recover", {
2096
2108
  name: i
2097
2109
  })
2098
2110
  )) {
2099
- se(r("command.vault.operation.cancelled"));
2111
+ le(r("command.vault.operation.cancelled"));
2100
2112
  return;
2101
2113
  }
2102
2114
  await c(!0);
@@ -2107,30 +2119,30 @@ function Ia(e, t) {
2107
2119
  })
2108
2120
  ), a.command("remove").description(r("command.vault.remove.description")).argument("<name-or-id>", r("command.vault.remove.argument")).action(
2109
2121
  (i) => b(async () => {
2110
- if (!await Oe(
2122
+ if (!await Fe(
2111
2123
  r("command.vault.remove.confirm", {
2112
2124
  nameOrId: i
2113
2125
  })
2114
2126
  )) {
2115
- se(r("command.vault.operation.cancelled"));
2127
+ le(r("command.vault.operation.cancelled"));
2116
2128
  return;
2117
2129
  }
2118
2130
  const o = Math.random().toString(36).slice(2, 8).toUpperCase();
2119
- if (await ot(
2131
+ if (await ct(
2120
2132
  r("command.vault.remove.verify_prompt", {
2121
2133
  verifyCode: o
2122
2134
  })
2123
2135
  ) !== o) {
2124
- se(r("command.vault.remove.verify_mismatch"));
2136
+ le(r("command.vault.remove.verify_mismatch"));
2125
2137
  return;
2126
2138
  }
2127
2139
  const s = await t.vaultService.removeVault(i);
2128
- C(
2140
+ k(
2129
2141
  r("command.vault.remove.done", {
2130
2142
  name: s.vault.name,
2131
2143
  id: s.vault.id
2132
2144
  })
2133
- ), s.movedArchiveIds.length > 0 && A(
2145
+ ), s.movedArchiveIds.length > 0 && E(
2134
2146
  r("command.vault.remove.moved_to_default", {
2135
2147
  count: s.movedArchiveIds.length,
2136
2148
  name: g.Vault.name
@@ -2153,7 +2165,7 @@ function Ia(e, t) {
2153
2165
  ), a.command("recover").description(r("command.vault.recover.description")).argument("<name-or-id>", r("command.vault.recover.argument")).action(
2154
2166
  (i) => b(async () => {
2155
2167
  const n = await t.vaultService.recoverVault(i);
2156
- C(
2168
+ k(
2157
2169
  r("command.vault.recover.done", {
2158
2170
  name: n.name,
2159
2171
  id: n.id
@@ -2176,7 +2188,7 @@ function Ia(e, t) {
2176
2188
  ), a.command("rename").description(r("command.vault.rename.description")).argument("<old>", r("command.vault.rename.argument.old")).argument("<new>", r("command.vault.rename.argument.new")).action(
2177
2189
  (i, n) => b(async () => {
2178
2190
  const o = await t.vaultService.renameVault(i, n);
2179
- C(
2191
+ k(
2180
2192
  r("command.vault.rename.done", {
2181
2193
  name: o.name,
2182
2194
  id: o.id
@@ -2200,7 +2212,7 @@ function Ia(e, t) {
2200
2212
  (i) => b(async () => {
2201
2213
  const n = await t.vaultService.listVaults(!!i.all);
2202
2214
  if (n.length === 0) {
2203
- A(r("command.vault.list.empty"));
2215
+ E(r("command.vault.list.empty"));
2204
2216
  return;
2205
2217
  }
2206
2218
  const o = n.map((c) => `${String(c.id).padStart(3, " ")} ${c.name}`).join(`
@@ -2209,11 +2221,11 @@ function Ia(e, t) {
2209
2221
  })
2210
2222
  );
2211
2223
  }
2212
- function ya(e) {
2213
- const t = new gt();
2214
- return t.name(Vt).description(r("app.description")).version(e.version), Dt(t, e), Ia(t, e), ha(t, e), fa(t, e), ta(t, e), t;
2224
+ function ka(e) {
2225
+ const t = new pt();
2226
+ return t.name(Rt).description(r("app.description")).version(e.version), Pt(t, e), ba(t, e), ga(t, e), pa(t, e), ia(t, e), t;
2215
2227
  }
2216
- const Fe = {
2228
+ const je = {
2217
2229
  startMarker: "# >>> archiver arv wrapper >>>",
2218
2230
  endMarker: "# <<< archiver arv wrapper <<<",
2219
2231
  functionPattern: /(^|\n)\s*(function\s+)?arv\s*(\(\))?\s*\{/m,
@@ -2238,7 +2250,7 @@ const Fe = {
2238
2250
  fi
2239
2251
  return $status
2240
2252
  }`
2241
- }, ba = {
2253
+ }, Ca = {
2242
2254
  startMarker: "# >>> archiver arv wrapper >>>",
2243
2255
  endMarker: "# <<< archiver arv wrapper <<<",
2244
2256
  functionPattern: /(^|\n)\s*function\s+arv\b/m,
@@ -2264,7 +2276,7 @@ const Fe = {
2264
2276
  rm -f $target_tmp
2265
2277
  return $status
2266
2278
  end`
2267
- }, ka = {
2279
+ }, Ea = {
2268
2280
  startMarker: "# >>> archiver arv wrapper >>>",
2269
2281
  endMarker: "# <<< archiver arv wrapper <<<",
2270
2282
  functionPattern: /(^|\r?\n)\s*function\s+arv\b/im,
@@ -2304,7 +2316,7 @@ end`
2304
2316
  $global:LASTEXITCODE = $status
2305
2317
  }`
2306
2318
  };
2307
- function Ca(e) {
2319
+ function Aa(e) {
2308
2320
  const t = h.basename(e).toLowerCase();
2309
2321
  if (t.includes("bash"))
2310
2322
  return "bash";
@@ -2315,17 +2327,17 @@ function Ca(e) {
2315
2327
  if (t.includes("pwsh") || t.includes("powershell"))
2316
2328
  return "powershell";
2317
2329
  }
2318
- function je(e) {
2330
+ function Ye(e) {
2319
2331
  return e.endsWith(`
2320
2332
  `) ? e : `${e}
2321
2333
  `;
2322
2334
  }
2323
- function ct(e) {
2335
+ function st(e) {
2324
2336
  return `${e.startMarker}
2325
2337
  ${e.body}
2326
2338
  ${e.endMarker}`;
2327
2339
  }
2328
- function Ea(e, t) {
2340
+ function Sa(e, t) {
2329
2341
  const a = e.indexOf(t.startMarker);
2330
2342
  if (a === -1)
2331
2343
  return;
@@ -2336,8 +2348,8 @@ function Ea(e, t) {
2336
2348
  end: i + t.endMarker.length
2337
2349
  };
2338
2350
  }
2339
- function Aa(e, t) {
2340
- const a = ct(t);
2351
+ function xa(e, t) {
2352
+ const a = st(t);
2341
2353
  if (e.trim().length === 0)
2342
2354
  return `${a}
2343
2355
  `;
@@ -2349,99 +2361,99 @@ function Aa(e, t) {
2349
2361
  return `${e}${i}${a}
2350
2362
  `;
2351
2363
  }
2352
- async function Sa(e, t) {
2364
+ async function Va(e, t) {
2353
2365
  for (const a of t) {
2354
2366
  const i = h.join(e, a);
2355
- if (await E(i))
2367
+ if (await C(i))
2356
2368
  return i;
2357
2369
  }
2358
2370
  return h.join(e, t[0] ?? ".bashrc");
2359
2371
  }
2360
2372
  async function J(e, t) {
2361
2373
  await X(e);
2362
- const a = await p.readFile(e, "utf8"), i = Ea(a, t);
2374
+ const a = await p.readFile(e, "utf8"), i = Sa(a, t);
2363
2375
  if (i) {
2364
- const o = a.slice(i.start, i.end), c = ct(t);
2376
+ const o = a.slice(i.start, i.end), c = st(t);
2365
2377
  if (o === c)
2366
2378
  return !1;
2367
2379
  const s = `${a.slice(0, i.start)}${c}${a.slice(i.end)}`;
2368
- return await p.writeFile(e, je(s), "utf8"), !0;
2380
+ return await p.writeFile(e, Ye(s), "utf8"), !0;
2369
2381
  }
2370
2382
  if (t.functionPattern.test(a))
2371
2383
  return !1;
2372
- const n = je(Aa(a, t));
2384
+ const n = Ye(xa(a, t));
2373
2385
  return await p.writeFile(e, n, "utf8"), !0;
2374
2386
  }
2375
- function xa(e, t) {
2387
+ function Ra(e, t) {
2376
2388
  const a = h.resolve(t), i = h.resolve(e);
2377
2389
  if (i === a)
2378
2390
  return "~";
2379
2391
  const n = `${a}${h.sep}`;
2380
2392
  return i.startsWith(n) ? `~${i.slice(a.length)}` : e;
2381
2393
  }
2382
- function Va(e) {
2394
+ function La(e) {
2383
2395
  return `'${e.replaceAll("'", "'\\''")}'`;
2384
2396
  }
2385
- function Ra(e) {
2397
+ function Ta(e) {
2386
2398
  return `'${e.replaceAll("'", "''")}'`;
2387
2399
  }
2388
- async function La(e) {
2400
+ async function $a(e) {
2389
2401
  if (process.platform === "win32") {
2390
2402
  const t = [
2391
2403
  h.join(e, "Documents", "PowerShell", "Microsoft.PowerShell_profile.ps1"),
2392
2404
  h.join(e, "Documents", "WindowsPowerShell", "Microsoft.PowerShell_profile.ps1")
2393
2405
  ];
2394
2406
  for (const a of t)
2395
- if (await E(a))
2407
+ if (await C(a))
2396
2408
  return a;
2397
2409
  return t[0];
2398
2410
  }
2399
2411
  return h.join(e, ".config", "powershell", "Microsoft.PowerShell_profile.ps1");
2400
2412
  }
2401
2413
  function G(e, t, a, i) {
2402
- const n = xa(t, a);
2414
+ const n = Ra(t, a);
2403
2415
  return e === "powershell" ? {
2404
2416
  installed: i,
2405
2417
  shell: e,
2406
2418
  profilePath: n,
2407
- reloadCommand: `. ${Ra(t)}`
2419
+ reloadCommand: `. ${Ta(t)}`
2408
2420
  } : {
2409
2421
  installed: i,
2410
2422
  shell: e,
2411
2423
  profilePath: n,
2412
- reloadCommand: `source ${Va(t)}`
2424
+ reloadCommand: `source ${La(t)}`
2413
2425
  };
2414
2426
  }
2415
- async function Ta(e = {}) {
2427
+ async function Na(e = {}) {
2416
2428
  const t = e.env ?? process.env;
2417
2429
  if (t.ARCHIVER_DISABLE_SHELL_INIT === "1")
2418
2430
  return { installed: !1 };
2419
2431
  if (!(e.stdinIsTTY ?? !!process.stdin.isTTY))
2420
2432
  return { installed: !1 };
2421
- const i = e.homeDir ?? t.HOME ?? t.USERPROFILE ?? Je.homedir();
2433
+ const i = e.homeDir ?? t.HOME ?? t.USERPROFILE ?? Ge.homedir();
2422
2434
  if (!i)
2423
2435
  return { installed: !1 };
2424
- const n = e.shellPath ?? t.SHELL ?? "", o = Ca(n);
2436
+ const n = e.shellPath ?? t.SHELL ?? "", o = Aa(n);
2425
2437
  if (!o)
2426
2438
  return { installed: !1 };
2427
2439
  try {
2428
2440
  if (o === "bash") {
2429
- const l = await Sa(i, [".bashrc", ".bash_profile", ".profile"]), d = await J(l, Fe);
2441
+ const l = await Va(i, [".bashrc", ".bash_profile", ".profile"]), d = await J(l, je);
2430
2442
  return G(o, l, i, d);
2431
2443
  }
2432
2444
  if (o === "zsh") {
2433
- const l = h.join(i, ".zshrc"), d = await J(l, Fe);
2445
+ const l = h.join(i, ".zshrc"), d = await J(l, je);
2434
2446
  return G(o, l, i, d);
2435
2447
  }
2436
2448
  if (o === "fish") {
2437
2449
  const l = h.join(i, ".config", "fish", "functions", "arv.fish");
2438
2450
  await Y(h.dirname(l));
2439
- const d = await J(l, ba);
2451
+ const d = await J(l, Ca);
2440
2452
  return G(o, l, i, d);
2441
2453
  }
2442
- const c = await La(i);
2454
+ const c = await $a(i);
2443
2455
  await Y(h.dirname(c));
2444
- const s = await J(c, ka);
2456
+ const s = await J(c, Ea);
2445
2457
  return G(o, c, i, s);
2446
2458
  } catch {
2447
2459
  return { installed: !1 };
@@ -2468,17 +2480,17 @@ async function ie(e) {
2468
2480
  throw t;
2469
2481
  }
2470
2482
  }
2471
- async function Ye(e, t) {
2483
+ async function He(e, t) {
2472
2484
  const a = t.map((i) => JSON.stringify(i)).join(`
2473
2485
  `);
2474
2486
  await p.writeFile(e, a.length > 0 ? `${a}
2475
2487
  ` : "", "utf8");
2476
2488
  }
2477
- async function st(e, t) {
2489
+ async function lt(e, t) {
2478
2490
  await p.appendFile(e, `${JSON.stringify(t)}
2479
2491
  `, "utf8");
2480
2492
  }
2481
- function He(e) {
2493
+ function Ue(e) {
2482
2494
  return {
2483
2495
  currentVaultId: Number.isInteger(e.currentVaultId) && e.currentVaultId >= 0 ? e.currentVaultId : g.Config.currentVaultId,
2484
2496
  updateCheck: e.updateCheck === "off" ? "off" : "on",
@@ -2489,14 +2501,14 @@ function He(e) {
2489
2501
  noCommandAction: e.noCommandAction === "help" || e.noCommandAction === "list" ? e.noCommandAction : "unknown"
2490
2502
  };
2491
2503
  }
2492
- function Ue(e) {
2504
+ function ze(e) {
2493
2505
  return {
2494
2506
  logId: Number.isInteger(e.logId) && e.logId >= 0 ? e.logId : 0,
2495
2507
  vaultId: Number.isInteger(e.vaultId) && e.vaultId >= 0 ? e.vaultId : 0,
2496
2508
  archiveId: Number.isInteger(e.archiveId) && e.archiveId >= 0 ? e.archiveId : 0
2497
2509
  };
2498
2510
  }
2499
- function ze(e) {
2511
+ function Be(e) {
2500
2512
  const t = e.isDirectory === 1 ? 1 : 0, a = e.status === y.Restored ? y.Restored : y.Archived;
2501
2513
  return {
2502
2514
  archivedAt: String(e.archivedAt ?? ""),
@@ -2510,7 +2522,7 @@ function ze(e) {
2510
2522
  remark: String(e.remark ?? "")
2511
2523
  };
2512
2524
  }
2513
- function Be(e) {
2525
+ function qe(e) {
2514
2526
  const t = S[e.status] ?? S.Valid;
2515
2527
  return {
2516
2528
  id: e.id,
@@ -2520,7 +2532,7 @@ function Be(e) {
2520
2532
  status: t
2521
2533
  };
2522
2534
  }
2523
- class $a {
2535
+ class Da {
2524
2536
  configCache;
2525
2537
  autoIncrCache;
2526
2538
  listCache;
@@ -2528,27 +2540,27 @@ class $a {
2528
2540
  async init() {
2529
2541
  for (const a of Object.values(f.Dir))
2530
2542
  await Y(a);
2531
- await Y(this.vaultDir(g.Vault.id)), await Se(f.File.config, de), await Se(f.File.autoIncr, ue), await X(f.File.list), await X(f.File.vaults), await X(f.File.log);
2543
+ await Y(this.vaultDir(g.Vault.id)), await xe(f.File.config, ue), await xe(f.File.autoIncr, me), await X(f.File.list), await X(f.File.vaults), await X(f.File.log);
2532
2544
  const t = await this.loadConfig();
2533
- t.currentVaultId === 0 || await E(this.vaultDir(t.currentVaultId)) || (t.currentVaultId = g.Vault.id, await this.saveConfig(t));
2545
+ t.currentVaultId === 0 || await C(this.vaultDir(t.currentVaultId)) || (t.currentVaultId = g.Vault.id, await this.saveConfig(t));
2534
2546
  }
2535
2547
  async loadConfig(t = !1) {
2536
2548
  if (this.configCache && !t)
2537
2549
  return this.configCache;
2538
- const a = await ve(f.File.config, g.Config), i = He({ ...g.Config, ...a });
2550
+ const a = await he(f.File.config, g.Config), i = Ue({ ...g.Config, ...a });
2539
2551
  return Z(i.language), this.configCache = i, i;
2540
2552
  }
2541
2553
  async saveConfig(t) {
2542
- this.configCache = He(t), Z(this.configCache.language), await xe(f.File.config, this.configCache, de);
2554
+ this.configCache = Ue(t), Z(this.configCache.language), await Ve(f.File.config, this.configCache, ue);
2543
2555
  }
2544
2556
  async loadAutoIncr(t = !1) {
2545
2557
  if (this.autoIncrCache && !t)
2546
2558
  return this.autoIncrCache;
2547
- const a = await ve(f.File.autoIncr, g.AutoIncr), i = Ue({ ...g.AutoIncr, ...a });
2559
+ const a = await he(f.File.autoIncr, g.AutoIncr), i = ze({ ...g.AutoIncr, ...a });
2548
2560
  return this.autoIncrCache = i, i;
2549
2561
  }
2550
2562
  async saveAutoIncr(t) {
2551
- this.autoIncrCache = Ue(t), await xe(f.File.autoIncr, this.autoIncrCache, ue);
2563
+ this.autoIncrCache = ze(t), await Ve(f.File.autoIncr, this.autoIncrCache, me);
2552
2564
  }
2553
2565
  async nextAutoIncrement(t) {
2554
2566
  const a = await this.loadAutoIncr();
@@ -2558,24 +2570,24 @@ class $a {
2558
2570
  if (this.listCache && !t)
2559
2571
  return this.listCache;
2560
2572
  const a = await ie(f.File.list);
2561
- return this.listCache = a.map((i) => ze(i)).filter((i) => Number.isInteger(i.id) && i.id > 0), this.listCache.sort((i, n) => i.id - n.id), this.listCache;
2573
+ return this.listCache = a.map((i) => Be(i)).filter((i) => Number.isInteger(i.id) && i.id > 0), this.listCache.sort((i, n) => i.id - n.id), this.listCache;
2562
2574
  }
2563
2575
  async saveListEntries(t) {
2564
- this.listCache = [...t].sort((a, i) => a.id - i.id), await Ye(f.File.list, this.listCache);
2576
+ this.listCache = [...t].sort((a, i) => a.id - i.id), await He(f.File.list, this.listCache);
2565
2577
  }
2566
2578
  async appendListEntry(t) {
2567
- const a = ze(t);
2568
- this.listCache || (this.listCache = await this.loadListEntries()), this.listCache.push(a), this.listCache.sort((i, n) => i.id - n.id), await st(f.File.list, a);
2579
+ const a = Be(t);
2580
+ this.listCache || (this.listCache = await this.loadListEntries()), this.listCache.push(a), this.listCache.sort((i, n) => i.id - n.id), await lt(f.File.list, a);
2569
2581
  }
2570
2582
  async loadVaults(t = !1) {
2571
2583
  if (this.vaultCache && !t)
2572
2584
  return this.vaultCache;
2573
2585
  const a = await ie(f.File.vaults);
2574
- return this.vaultCache = a.map((i) => Be(i)).filter((i) => Number.isInteger(i.id) && i.id > 0).sort((i, n) => i.id - n.id), this.vaultCache;
2586
+ return this.vaultCache = a.map((i) => qe(i)).filter((i) => Number.isInteger(i.id) && i.id > 0).sort((i, n) => i.id - n.id), this.vaultCache;
2575
2587
  }
2576
2588
  async saveVaults(t) {
2577
- const a = t.map((i) => Be(i)).filter((i) => i.id > 0).sort((i, n) => i.id - n.id);
2578
- this.vaultCache = a, await Ye(f.File.vaults, a);
2589
+ const a = t.map((i) => qe(i)).filter((i) => i.id > 0).sort((i, n) => i.id - n.id);
2590
+ this.vaultCache = a, await He(f.File.vaults, a);
2579
2591
  }
2580
2592
  async getVaults(t) {
2581
2593
  const a = t?.includeRemoved ?? !1, i = t?.withDefault ?? !0, n = await this.loadVaults(), o = a ? n : n.filter((c) => c.status === "Valid");
@@ -2617,7 +2629,7 @@ class $a {
2617
2629
  if (!i || !i.isDirectory())
2618
2630
  return;
2619
2631
  const n = this.archiveObjectPath(t.vaultId, t.id, t.item);
2620
- if (await E(n))
2632
+ if (await C(n))
2621
2633
  return {
2622
2634
  slotPath: a,
2623
2635
  objectPath: n
@@ -2630,7 +2642,7 @@ class $a {
2630
2642
  t !== g.Vault.id && await p.rm(this.vaultDir(t), { recursive: !0, force: !0 });
2631
2643
  }
2632
2644
  }
2633
- class Na {
2645
+ class Pa {
2634
2646
  constructor(t, a) {
2635
2647
  this.context = t, this.logger = a;
2636
2648
  }
@@ -2644,7 +2656,7 @@ class Na {
2644
2656
  const o = { ok: [], failed: [] };
2645
2657
  for (const c of n) {
2646
2658
  const s = await this.context.nextAutoIncrement("archiveId"), l = this.context.archivePath(i.id, s), d = {
2647
- archivedAt: _e(),
2659
+ archivedAt: we(),
2648
2660
  status: y.Archived,
2649
2661
  isDirectory: c.stats.isDirectory() ? 1 : 0,
2650
2662
  vaultId: i.id,
@@ -2655,7 +2667,7 @@ class Na {
2655
2667
  remark: a.remark ?? ""
2656
2668
  };
2657
2669
  try {
2658
- if (await E(l))
2670
+ if (await C(l))
2659
2671
  throw new Error(
2660
2672
  r("service.archive.error.slot_exists", {
2661
2673
  path: l
@@ -2757,7 +2769,7 @@ class Na {
2757
2769
  path: this.context.archivePath(s.vaultId, s.id)
2758
2770
  })
2759
2771
  );
2760
- if (await E(d))
2772
+ if (await C(d))
2761
2773
  throw new Error(
2762
2774
  r("service.archive.error.restore_target_exists", {
2763
2775
  path: d
@@ -2838,17 +2850,17 @@ class Na {
2838
2850
  vault: i.name
2839
2851
  })
2840
2852
  );
2841
- const u = await this.context.resolveArchiveStorageLocation(m), _ = this.context.archivePath(m.vaultId, m.id), k = this.context.archivePath(i.id, m.id);
2853
+ const u = await this.context.resolveArchiveStorageLocation(m), _ = this.context.archivePath(m.vaultId, m.id), A = this.context.archivePath(i.id, m.id);
2842
2854
  if (!u)
2843
2855
  throw new Error(
2844
2856
  r("service.archive.error.object_missing", {
2845
2857
  path: _
2846
2858
  })
2847
2859
  );
2848
- if (await E(k))
2860
+ if (await C(A))
2849
2861
  throw new Error(
2850
2862
  r("service.archive.error.target_slot_exists", {
2851
- path: k
2863
+ path: A
2852
2864
  })
2853
2865
  );
2854
2866
  c.set(d, u);
@@ -2869,7 +2881,7 @@ class Na {
2869
2881
  });
2870
2882
  continue;
2871
2883
  }
2872
- const _ = this.context.archivePath(i.id, m.id), k = m.vaultId;
2884
+ const _ = this.context.archivePath(i.id, m.id), A = m.vaultId;
2873
2885
  try {
2874
2886
  await p.rename(u.slotPath, _), m.vaultId = i.id, l = !0, await this.logger.log(
2875
2887
  "INFO",
@@ -2881,7 +2893,7 @@ class Na {
2881
2893
  },
2882
2894
  r("service.archive.log.moved", {
2883
2895
  id: d,
2884
- fromVaultId: k,
2896
+ fromVaultId: A,
2885
2897
  toVaultId: i.id
2886
2898
  }),
2887
2899
  { aid: d, vid: i.id }
@@ -2894,8 +2906,8 @@ class Na {
2894
2906
  id: i.id
2895
2907
  })
2896
2908
  });
2897
- } catch (x) {
2898
- const L = x.message;
2909
+ } catch (L) {
2910
+ const x = L.message;
2899
2911
  await this.logger.log(
2900
2912
  "ERROR",
2901
2913
  {
@@ -2906,14 +2918,14 @@ class Na {
2906
2918
  },
2907
2919
  r("service.archive.log.move_failed", {
2908
2920
  id: d,
2909
- message: L
2921
+ message: x
2910
2922
  }),
2911
- { aid: d, vid: k }
2923
+ { aid: d, vid: A }
2912
2924
  ), s.failed.push({
2913
2925
  id: d,
2914
2926
  input: String(d),
2915
2927
  success: !1,
2916
- message: L
2928
+ message: x
2917
2929
  });
2918
2930
  }
2919
2931
  }
@@ -3059,7 +3071,7 @@ class Na {
3059
3071
  };
3060
3072
  }
3061
3073
  async preValidatePutItems(t) {
3062
- const a = [], i = /* @__PURE__ */ new Set(), n = await Me(f.Dir.root);
3074
+ const a = [], i = /* @__PURE__ */ new Set(), n = await Oe(f.Dir.root);
3063
3075
  for (const o of t) {
3064
3076
  const c = h.resolve(o), s = await ae(c);
3065
3077
  if (!s)
@@ -3068,8 +3080,8 @@ class Na {
3068
3080
  path: o
3069
3081
  })
3070
3082
  );
3071
- const l = await Me(c);
3072
- if (pa(l, n) || nt(n, l))
3083
+ const l = await Oe(c);
3084
+ if (wa(l, n) || rt(n, l))
3073
3085
  throw new Error(
3074
3086
  r("service.archive.error.path_forbidden_archiver_scope", {
3075
3087
  path: o
@@ -3094,7 +3106,7 @@ class Na {
3094
3106
  const i = await this.context.loadAutoIncr();
3095
3107
  for (let n = 1; n <= a; n += 1) {
3096
3108
  const o = i.archiveId + n, c = this.context.archivePath(t, o);
3097
- if (await E(c))
3109
+ if (await C(c))
3098
3110
  throw new Error(
3099
3111
  r("service.archive.error.slot_already_occupied", {
3100
3112
  path: c
@@ -3103,24 +3115,24 @@ class Na {
3103
3115
  }
3104
3116
  }
3105
3117
  }
3106
- class Da {
3118
+ class Ma {
3107
3119
  constructor(t) {
3108
3120
  this.context = t;
3109
3121
  }
3110
3122
  async log(t, a, i, n) {
3111
3123
  const s = {
3112
3124
  id: await this.context.nextAutoIncrement("logId"),
3113
- operedAt: _e(/* @__PURE__ */ new Date()),
3125
+ operedAt: we(/* @__PURE__ */ new Date()),
3114
3126
  level: t,
3115
3127
  oper: a,
3116
3128
  message: i,
3117
3129
  ...n?.aid !== void 0 ? { archiveIds: n.aid } : {},
3118
3130
  ...n?.vid !== void 0 ? { vaultIds: n.vid } : {}
3119
3131
  };
3120
- return await st(f.File.log, s), s;
3132
+ return await lt(f.File.log, s), s;
3121
3133
  }
3122
3134
  }
3123
- function le(e) {
3135
+ function de(e) {
3124
3136
  const t = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
3125
3137
  for (const i of e)
3126
3138
  t.has(i) ? a.add(i) : t.add(i);
@@ -3129,7 +3141,7 @@ function le(e) {
3129
3141
  function I(e, t, a, i) {
3130
3142
  e.push({ level: t, code: a, message: i });
3131
3143
  }
3132
- class Pa {
3144
+ class Oa {
3133
3145
  constructor(t) {
3134
3146
  this.context = t;
3135
3147
  }
@@ -3157,7 +3169,7 @@ class Pa {
3157
3169
  this.context.vaultDir(g.Vault.id)
3158
3170
  ];
3159
3171
  for (const i of a)
3160
- await E(i) || I(
3172
+ await C(i) || I(
3161
3173
  t.issues,
3162
3174
  w.Error,
3163
3175
  "MISSING_PATH",
@@ -3177,7 +3189,7 @@ class Pa {
3177
3189
  );
3178
3190
  }
3179
3191
  checkListIds(t, a, i) {
3180
- const n = a.map((s) => s.id), o = le(n);
3192
+ const n = a.map((s) => s.id), o = de(n);
3181
3193
  o.length > 0 && I(
3182
3194
  t.issues,
3183
3195
  w.Error,
@@ -3198,7 +3210,7 @@ class Pa {
3198
3210
  );
3199
3211
  }
3200
3212
  checkVaultIds(t, a, i) {
3201
- const n = a.filter((m) => m.id !== g.Vault.id), o = n.map((m) => m.id), c = le(o);
3213
+ const n = a.filter((m) => m.id !== g.Vault.id), o = n.map((m) => m.id), c = de(o);
3202
3214
  c.length > 0 && I(
3203
3215
  t.issues,
3204
3216
  w.Error,
@@ -3271,7 +3283,7 @@ class Pa {
3271
3283
  );
3272
3284
  }
3273
3285
  }
3274
- await E(l) && I(
3286
+ await C(l) && I(
3275
3287
  t.issues,
3276
3288
  w.Warn,
3277
3289
  "RESTORE_TARGET_ALREADY_EXISTS",
@@ -3281,7 +3293,7 @@ class Pa {
3281
3293
  })
3282
3294
  );
3283
3295
  } else if (o.status === y.Restored)
3284
- if (await E(s) && I(
3296
+ if (await C(s) && I(
3285
3297
  t.issues,
3286
3298
  w.Warn,
3287
3299
  "RESTORED_BUT_ARCHIVE_EXISTS",
@@ -3289,7 +3301,7 @@ class Pa {
3289
3301
  archiveId: o.id,
3290
3302
  archivePath: s
3291
3303
  })
3292
- ), await E(l)) {
3304
+ ), await C(l)) {
3293
3305
  const d = await ae(l);
3294
3306
  if (d) {
3295
3307
  const m = d.isDirectory(), u = o.isDirectory === 1;
@@ -3329,7 +3341,7 @@ class Pa {
3329
3341
  async checkVaultDirectoryConsistency(t, a, i) {
3330
3342
  const n = new Set(i.map((s) => s.id)), o = new Set(
3331
3343
  a.filter((s) => s.status === y.Archived).map((s) => `${s.vaultId}/${s.id}`)
3332
- ), c = await _a(f.Dir.vaults);
3344
+ ), c = await Ia(f.Dir.vaults);
3333
3345
  for (const s of c) {
3334
3346
  if (!/^\d+$/.test(s)) {
3335
3347
  I(
@@ -3392,7 +3404,7 @@ class Pa {
3392
3404
  if (s.status !== "Valid" && s.status !== "Protected")
3393
3405
  continue;
3394
3406
  const l = this.context.vaultDir(s.id);
3395
- await E(l) || I(
3407
+ await C(l) || I(
3396
3408
  t.issues,
3397
3409
  w.Error,
3398
3410
  "MISSING_VAULT_DIR",
@@ -3405,7 +3417,7 @@ class Pa {
3405
3417
  }
3406
3418
  }
3407
3419
  async checkLogConsistency(t, a) {
3408
- const n = (await ie(f.File.log)).map((s) => Number(s.id)).filter((s) => Number.isInteger(s)), o = le(n);
3420
+ const n = (await ie(f.File.log)).map((s) => Number(s.id)).filter((s) => Number.isInteger(s)), o = de(n);
3409
3421
  o.length > 0 && I(
3410
3422
  t.issues,
3411
3423
  w.Error,
@@ -3426,7 +3438,7 @@ class Pa {
3426
3438
  );
3427
3439
  }
3428
3440
  }
3429
- class Ma {
3441
+ class Fa {
3430
3442
  constructor(t) {
3431
3443
  this.context = t;
3432
3444
  }
@@ -3462,7 +3474,7 @@ class Ma {
3462
3474
  a.lastUpdateCheck = t, await this.context.saveConfig(a);
3463
3475
  }
3464
3476
  }
3465
- function Oa(e) {
3477
+ function ja(e) {
3466
3478
  return {
3467
3479
  id: Number(e.id),
3468
3480
  operedAt: String(e.operedAt ?? ""),
@@ -3473,17 +3485,17 @@ function Oa(e) {
3473
3485
  ...e.vaultIds !== void 0 ? { vaultIds: Number(e.vaultIds) } : {}
3474
3486
  };
3475
3487
  }
3476
- function Fa(e) {
3488
+ function Ya(e) {
3477
3489
  return e.operedAt.replace(/[-:\sT]/g, "").slice(0, 6);
3478
3490
  }
3479
- class ja {
3491
+ class Ha {
3480
3492
  constructor(t) {
3481
3493
  this.context = t;
3482
3494
  }
3483
3495
  async getLogs(t) {
3484
3496
  const a = await this.loadAllLogs();
3485
3497
  return t.mode === "all" ? a : a.filter((i) => {
3486
- const n = Fa(i);
3498
+ const n = Ya(i);
3487
3499
  return !n || n.length !== 6 ? !1 : n >= t.from && n <= t.to;
3488
3500
  });
3489
3501
  }
@@ -3503,19 +3515,19 @@ class ja {
3503
3515
  return n;
3504
3516
  }
3505
3517
  async loadAllLogs() {
3506
- const a = (await ie(f.File.log)).map((i) => Oa(i));
3518
+ const a = (await ie(f.File.log)).map((i) => ja(i));
3507
3519
  return a.sort((i, n) => i.id - n.id), a;
3508
3520
  }
3509
3521
  }
3510
- const Ya = yt(It);
3511
- function fe(e) {
3522
+ const Ua = bt(yt);
3523
+ function ge(e) {
3512
3524
  return e.trim().replace(/^v/i, "");
3513
3525
  }
3514
- function qe(e) {
3515
- return fe(e).split(".").map((t) => Number(t.replace(/[^0-9].*$/, ""))).map((t) => Number.isFinite(t) ? t : 0);
3526
+ function We(e) {
3527
+ return ge(e).split(".").map((t) => Number(t.replace(/[^0-9].*$/, ""))).map((t) => Number.isFinite(t) ? t : 0);
3516
3528
  }
3517
- function Ha(e, t) {
3518
- const a = qe(e), i = qe(t), n = Math.max(a.length, i.length);
3529
+ function za(e, t) {
3530
+ const a = We(e), i = We(t), n = Math.max(a.length, i.length);
3519
3531
  for (let o = 0; o < n; o += 1) {
3520
3532
  const c = a[o] ?? 0, s = i[o] ?? 0;
3521
3533
  if (s > c)
@@ -3525,17 +3537,17 @@ function Ha(e, t) {
3525
3537
  }
3526
3538
  return !1;
3527
3539
  }
3528
- class Ua {
3540
+ class Ba {
3529
3541
  currentVersion;
3530
3542
  constructor(t) {
3531
- this.currentVersion = fe(t);
3543
+ this.currentVersion = ge(t);
3532
3544
  }
3533
3545
  async checkLatest(t = M.Repo) {
3534
- const a = await this.fetchLatestRelease(t), i = fe(a.tag_name);
3546
+ const a = await this.fetchLatestRelease(t), i = ge(a.tag_name);
3535
3547
  return {
3536
3548
  currentVersion: this.currentVersion,
3537
3549
  latestVersion: i,
3538
- hasUpdate: Ha(this.currentVersion, i),
3550
+ hasUpdate: za(this.currentVersion, i),
3539
3551
  htmlUrl: a.html_url,
3540
3552
  publishedAt: a.published_at
3541
3553
  };
@@ -3556,10 +3568,10 @@ class Ua {
3556
3568
  status: n.status
3557
3569
  })
3558
3570
  );
3559
- const o = await n.text(), c = h.join(Je.tmpdir(), `archiver-update-${Date.now()}.sh`);
3571
+ const o = await n.text(), c = h.join(Ge.tmpdir(), `archiver-update-${Date.now()}.sh`);
3560
3572
  await p.writeFile(c, o, { encoding: "utf8", mode: 493 });
3561
3573
  try {
3562
- const s = await Ya("bash", [c], { maxBuffer: 4194304 });
3574
+ const s = await Ua("bash", [c], { maxBuffer: 4194304 });
3563
3575
  return [s.stdout, s.stderr].filter(Boolean).join(`
3564
3576
  `).trim();
3565
3577
  } finally {
@@ -3591,10 +3603,10 @@ class Ua {
3591
3603
  return n;
3592
3604
  }
3593
3605
  }
3594
- async function za() {
3595
- const e = new $a();
3606
+ async function qa() {
3607
+ const e = new Da();
3596
3608
  await e.init();
3597
- const t = new Ma(e), a = new Da(e), i = new Na(e, a), n = new wa(e, t), o = new ja(e), c = new Pa(e), s = "0.3.2", l = new Ua(s);
3609
+ const t = new Fa(e), a = new Ma(e), i = new Pa(e, a), n = new ya(e, t), o = new Ha(e), c = new Oa(e), s = "0.3.3", l = new Ba(s);
3598
3610
  return {
3599
3611
  context: e,
3600
3612
  archiveService: i,
@@ -3607,11 +3619,11 @@ async function za() {
3607
3619
  version: s
3608
3620
  };
3609
3621
  }
3610
- async function Ba(e) {
3611
- if (!Ie())
3622
+ async function Wa(e) {
3623
+ if (!ye())
3612
3624
  return "help";
3613
- A(r("index.no_command_action.unknown"));
3614
- const t = await qt({
3625
+ E(r("index.no_command_action.unknown"));
3626
+ const t = await Jt({
3615
3627
  title: r("index.no_command_action.question"),
3616
3628
  description: r("index.no_command_action.note"),
3617
3629
  options: [
@@ -3624,28 +3636,28 @@ async function Ba(e) {
3624
3636
  enter: R(r("index.no_command_action.key.enter"))
3625
3637
  })
3626
3638
  });
3627
- return t || process.exit(130), await e.configService.setNoCommandAction(t), C(r("index.no_command_action.updated", { action: t })), t;
3639
+ return t || process.exit(130), await e.configService.setNoCommandAction(t), k(r("index.no_command_action.updated", { action: t })), t;
3628
3640
  }
3629
- async function qa() {
3630
- const e = await ve(f.File.config, g.Config);
3641
+ async function Ja() {
3642
+ const e = await he(f.File.config, g.Config);
3631
3643
  Z(e.language), ee({
3632
3644
  style: e.style === "off" ? "off" : "on"
3633
3645
  });
3634
- const t = await Ta();
3646
+ const t = await Na();
3635
3647
  if (t.installed) {
3636
3648
  const o = t.profilePath ? ` ${t.profilePath}` : "";
3637
- A(r("index.shell_wrapper.installed", { where: o })), t.reloadCommand && A(
3649
+ E(r("index.shell_wrapper.installed", { where: o })), t.reloadCommand && E(
3638
3650
  r("index.shell_wrapper.reload_hint", {
3639
3651
  reloadCommand: t.reloadCommand
3640
3652
  })
3641
3653
  );
3642
3654
  return;
3643
3655
  }
3644
- const a = await za(), i = await a.configService.getConfig();
3656
+ const a = await qa(), i = await a.configService.getConfig();
3645
3657
  Z(i.language), ee(i);
3646
- const n = ya(a);
3658
+ const n = ka(a);
3647
3659
  if (process.argv.length <= 2) {
3648
- if ((i.noCommandAction === "unknown" ? await Ba(a) : i.noCommandAction) === "list") {
3660
+ if ((i.noCommandAction === "unknown" ? await Wa(a) : i.noCommandAction) === "list") {
3649
3661
  await n.parseAsync([...process.argv, "list"]);
3650
3662
  return;
3651
3663
  }
@@ -3654,6 +3666,6 @@ async function qa() {
3654
3666
  }
3655
3667
  await n.parseAsync(process.argv);
3656
3668
  }
3657
- qa().catch((e) => {
3669
+ Ja().catch((e) => {
3658
3670
  j(e.message), process.exit(1);
3659
3671
  });