archiver-ts 0.3.2 → 0.3.4

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 +426 -393
  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,37 +742,37 @@ 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"), T = Vt();
746
746
  var f;
747
747
  ((e) => {
748
748
  e.Dir = {
749
- root: $,
750
- vaults: D($, "vaults")
749
+ root: T,
750
+ vaults: D(T, "vaults")
751
751
  }, e.File = {
752
- config: D($, "config.jsonc"),
753
- autoIncr: D($, "auto-incr.jsonc"),
754
- list: D($, "list.jsonl"),
755
- vaults: D($, "vaults.jsonl"),
756
- log: D($, "log.jsonl")
752
+ config: D(T, "config.jsonc"),
753
+ autoIncr: D(T, "auto-incr.jsonc"),
754
+ list: D(T, "list.jsonl"),
755
+ vaults: D(T, "vaults.jsonl"),
756
+ log: D(T, "log.jsonl")
757
757
  };
758
758
  })(f || (f = {}));
759
- var M;
759
+ var O;
760
760
  ((e) => {
761
761
  e.CheckInterval = 1440 * 60 * 1e3, e.Repo = process.env.ARCHIVER_GITHUB_REPO ?? "aldia/archiver", e.Timeout = 1e4;
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()) {
762
+ })(O || (O = {}));
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 $t(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,13 +808,13 @@ 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) {
@@ -833,23 +833,23 @@ function B(e, t) {
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
  })
@@ -860,12 +860,12 @@ async function V(e) {
860
860
  if (t.updateCheck === "on") {
861
861
  if (t.lastUpdateCheck) {
862
862
  const a = new Date(t.lastUpdateCheck);
863
- if (!Number.isNaN(a.getTime()) && Date.now() - a.getTime() < M.CheckInterval)
863
+ if (!Number.isNaN(a.getTime()) && Date.now() - a.getTime() < O.CheckInterval)
864
864
  return;
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,7 +944,7 @@ function Dt(e, t) {
944
944
  })
945
945
  );
946
946
  }
947
- const Pt = v.level;
947
+ const Ot = v.level;
948
948
  function Mt(e) {
949
949
  if (typeof e != "string")
950
950
  return;
@@ -952,27 +952,27 @@ function Mt(e) {
952
952
  if (t === "on" || t === "off")
953
953
  return t;
954
954
  }
955
- function Ot(e, t = process.env) {
955
+ function Ft(e, t = process.env) {
956
956
  return Mt(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(Ot, 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,10 +982,10 @@ 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 $e(e, t) {
989
989
  return t === "left" ? P(e.value, e.cursor - 1) : P(e.value, e.cursor + 1);
990
990
  }
991
991
  function Te(e, t, a) {
@@ -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: $e(e, "left"), action: "continue" };
1000
1000
  if (a.name === "right")
1001
- return { state: Le(e, "right"), action: "continue" };
1001
+ return { state: $e(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;
@@ -1054,51 +1061,56 @@ function Qe(e, t, a) {
1054
1061
  return o;
1055
1062
  }
1056
1063
  }
1057
- function O(e, t) {
1064
+ function M(e, t) {
1058
1065
  if (e.length === 0)
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) {
1089
- const t = O(e.options, e.initialValue);
1095
+ async function Jt(e) {
1096
+ const t = M(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,23 +1158,23 @@ 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() {
1157
- return !!(process.stdin.isTTY && process.stdout.isTTY && typeof process.stdin.setRawMode == "function");
1168
+ function Qt() {
1169
+ return typeof process.stdin.setRawMode == "function";
1158
1170
  }
1159
- function Zt(e) {
1171
+ function ea(e) {
1160
1172
  return [
1161
1173
  {
1162
1174
  kind: "select",
1163
1175
  key: "updateCheck",
1164
1176
  label: r("command.config.edit.field.update_check"),
1165
- state: O(
1177
+ state: M(
1166
1178
  [
1167
1179
  { value: "on", label: r("common.state.on") },
1168
1180
  { value: "off", label: r("common.state.off") }
@@ -1174,13 +1186,13 @@ 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",
1181
1193
  key: "style",
1182
1194
  label: r("command.config.edit.field.style"),
1183
- state: O(
1195
+ state: M(
1184
1196
  [
1185
1197
  { value: "on", label: r("common.state.on") },
1186
1198
  { value: "off", label: r("common.state.off") }
@@ -1192,7 +1204,7 @@ function Zt(e) {
1192
1204
  kind: "select",
1193
1205
  key: "language",
1194
1206
  label: r("command.config.edit.field.language"),
1195
- state: O(
1207
+ state: M(
1196
1208
  [
1197
1209
  { value: "zh", label: "zh" },
1198
1210
  { value: "en", label: "en" }
@@ -1204,7 +1216,7 @@ function Zt(e) {
1204
1216
  kind: "select",
1205
1217
  key: "noCommandAction",
1206
1218
  label: r("command.config.edit.field.no_command_action"),
1207
- state: O(
1219
+ state: M(
1208
1220
  [
1209
1221
  { value: "list", label: r("common.action.list") },
1210
1222
  { value: "help", label: r("common.action.help") },
@@ -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 $ = L === t, re = $ ? v.cyan(">") : " ", oe = $ ? v.bold(x.label.padEnd(s, " ")) : x.label.padEnd(s, " "), ce = x.kind === "select" ? te(x.state, $) : Ut(x.state, $, 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);
1279
- let i = O([
1291
+ const t = process.stdin, a = ea(e);
1292
+ let i = M([
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) {
@@ -1340,12 +1353,12 @@ async function ea(e) {
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 = Te(_.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) {
1495
- return O(
1507
+ function be(e, t) {
1508
+ return M(
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 Oe(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), $ = [...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 ? ($.push(v.bold(Ee)), $.push(v.cyan(Ae))) : ($.push(Ee), $.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: $,
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 = Oe(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 = Oe(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 = $t(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), Me = (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,15 +2221,20 @@ 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,
2220
2232
  body: `arv() {
2233
+ if [[ ! -t 0 || ! -t 1 ]]; then
2234
+ command arv "$@"
2235
+ return $?
2236
+ fi
2237
+
2221
2238
  local line target status
2222
2239
  while IFS= read -r line; do
2223
2240
  if [[ "$line" == *__ARCHIVER_CD__:* ]]; then
@@ -2238,11 +2255,20 @@ const Fe = {
2238
2255
  fi
2239
2256
  return $status
2240
2257
  }`
2241
- }, ba = {
2258
+ }, Ca = {
2242
2259
  startMarker: "# >>> archiver arv wrapper >>>",
2243
2260
  endMarker: "# <<< archiver arv wrapper <<<",
2244
2261
  functionPattern: /(^|\n)\s*function\s+arv\b/m,
2245
2262
  body: `function arv
2263
+ if not test -t 0
2264
+ command arv $argv
2265
+ return $status
2266
+ end
2267
+ if not test -t 1
2268
+ command arv $argv
2269
+ return $status
2270
+ end
2271
+
2246
2272
  set -l target_tmp (mktemp)
2247
2273
  env ARCHIVER_FORCE_INTERACTIVE=1 command arv $argv | while read -l line
2248
2274
  if string match -q "__ARCHIVER_CD__:*" -- $line
@@ -2264,7 +2290,7 @@ const Fe = {
2264
2290
  rm -f $target_tmp
2265
2291
  return $status
2266
2292
  end`
2267
- }, ka = {
2293
+ }, Ea = {
2268
2294
  startMarker: "# >>> archiver arv wrapper >>>",
2269
2295
  endMarker: "# <<< archiver arv wrapper <<<",
2270
2296
  functionPattern: /(^|\r?\n)\s*function\s+arv\b/im,
@@ -2274,6 +2300,13 @@ end`
2274
2300
  [string[]]$argv
2275
2301
  )
2276
2302
 
2303
+ if ([Console]::IsInputRedirected -or [Console]::IsOutputRedirected) {
2304
+ $app = Get-Command arv -CommandType Application -ErrorAction Stop | Select-Object -First 1
2305
+ & $app.Source @argv
2306
+ $global:LASTEXITCODE = $LASTEXITCODE
2307
+ return
2308
+ }
2309
+
2277
2310
  $target = $null
2278
2311
  $status = 1
2279
2312
  $oldForce = $env:ARCHIVER_FORCE_INTERACTIVE
@@ -2304,7 +2337,7 @@ end`
2304
2337
  $global:LASTEXITCODE = $status
2305
2338
  }`
2306
2339
  };
2307
- function Ca(e) {
2340
+ function Aa(e) {
2308
2341
  const t = h.basename(e).toLowerCase();
2309
2342
  if (t.includes("bash"))
2310
2343
  return "bash";
@@ -2315,17 +2348,17 @@ function Ca(e) {
2315
2348
  if (t.includes("pwsh") || t.includes("powershell"))
2316
2349
  return "powershell";
2317
2350
  }
2318
- function je(e) {
2351
+ function Ye(e) {
2319
2352
  return e.endsWith(`
2320
2353
  `) ? e : `${e}
2321
2354
  `;
2322
2355
  }
2323
- function ct(e) {
2356
+ function st(e) {
2324
2357
  return `${e.startMarker}
2325
2358
  ${e.body}
2326
2359
  ${e.endMarker}`;
2327
2360
  }
2328
- function Ea(e, t) {
2361
+ function Sa(e, t) {
2329
2362
  const a = e.indexOf(t.startMarker);
2330
2363
  if (a === -1)
2331
2364
  return;
@@ -2336,8 +2369,8 @@ function Ea(e, t) {
2336
2369
  end: i + t.endMarker.length
2337
2370
  };
2338
2371
  }
2339
- function Aa(e, t) {
2340
- const a = ct(t);
2372
+ function xa(e, t) {
2373
+ const a = st(t);
2341
2374
  if (e.trim().length === 0)
2342
2375
  return `${a}
2343
2376
  `;
@@ -2349,99 +2382,99 @@ function Aa(e, t) {
2349
2382
  return `${e}${i}${a}
2350
2383
  `;
2351
2384
  }
2352
- async function Sa(e, t) {
2385
+ async function Va(e, t) {
2353
2386
  for (const a of t) {
2354
2387
  const i = h.join(e, a);
2355
- if (await E(i))
2388
+ if (await C(i))
2356
2389
  return i;
2357
2390
  }
2358
2391
  return h.join(e, t[0] ?? ".bashrc");
2359
2392
  }
2360
2393
  async function J(e, t) {
2361
2394
  await X(e);
2362
- const a = await p.readFile(e, "utf8"), i = Ea(a, t);
2395
+ const a = await p.readFile(e, "utf8"), i = Sa(a, t);
2363
2396
  if (i) {
2364
- const o = a.slice(i.start, i.end), c = ct(t);
2397
+ const o = a.slice(i.start, i.end), c = st(t);
2365
2398
  if (o === c)
2366
2399
  return !1;
2367
2400
  const s = `${a.slice(0, i.start)}${c}${a.slice(i.end)}`;
2368
- return await p.writeFile(e, je(s), "utf8"), !0;
2401
+ return await p.writeFile(e, Ye(s), "utf8"), !0;
2369
2402
  }
2370
2403
  if (t.functionPattern.test(a))
2371
2404
  return !1;
2372
- const n = je(Aa(a, t));
2405
+ const n = Ye(xa(a, t));
2373
2406
  return await p.writeFile(e, n, "utf8"), !0;
2374
2407
  }
2375
- function xa(e, t) {
2408
+ function Ra(e, t) {
2376
2409
  const a = h.resolve(t), i = h.resolve(e);
2377
2410
  if (i === a)
2378
2411
  return "~";
2379
2412
  const n = `${a}${h.sep}`;
2380
2413
  return i.startsWith(n) ? `~${i.slice(a.length)}` : e;
2381
2414
  }
2382
- function Va(e) {
2415
+ function La(e) {
2383
2416
  return `'${e.replaceAll("'", "'\\''")}'`;
2384
2417
  }
2385
- function Ra(e) {
2418
+ function $a(e) {
2386
2419
  return `'${e.replaceAll("'", "''")}'`;
2387
2420
  }
2388
- async function La(e) {
2421
+ async function Ta(e) {
2389
2422
  if (process.platform === "win32") {
2390
2423
  const t = [
2391
2424
  h.join(e, "Documents", "PowerShell", "Microsoft.PowerShell_profile.ps1"),
2392
2425
  h.join(e, "Documents", "WindowsPowerShell", "Microsoft.PowerShell_profile.ps1")
2393
2426
  ];
2394
2427
  for (const a of t)
2395
- if (await E(a))
2428
+ if (await C(a))
2396
2429
  return a;
2397
2430
  return t[0];
2398
2431
  }
2399
2432
  return h.join(e, ".config", "powershell", "Microsoft.PowerShell_profile.ps1");
2400
2433
  }
2401
2434
  function G(e, t, a, i) {
2402
- const n = xa(t, a);
2435
+ const n = Ra(t, a);
2403
2436
  return e === "powershell" ? {
2404
2437
  installed: i,
2405
2438
  shell: e,
2406
2439
  profilePath: n,
2407
- reloadCommand: `. ${Ra(t)}`
2440
+ reloadCommand: `. ${$a(t)}`
2408
2441
  } : {
2409
2442
  installed: i,
2410
2443
  shell: e,
2411
2444
  profilePath: n,
2412
- reloadCommand: `source ${Va(t)}`
2445
+ reloadCommand: `source ${La(t)}`
2413
2446
  };
2414
2447
  }
2415
- async function Ta(e = {}) {
2448
+ async function Na(e = {}) {
2416
2449
  const t = e.env ?? process.env;
2417
2450
  if (t.ARCHIVER_DISABLE_SHELL_INIT === "1")
2418
2451
  return { installed: !1 };
2419
2452
  if (!(e.stdinIsTTY ?? !!process.stdin.isTTY))
2420
2453
  return { installed: !1 };
2421
- const i = e.homeDir ?? t.HOME ?? t.USERPROFILE ?? Je.homedir();
2454
+ const i = e.homeDir ?? t.HOME ?? t.USERPROFILE ?? Ge.homedir();
2422
2455
  if (!i)
2423
2456
  return { installed: !1 };
2424
- const n = e.shellPath ?? t.SHELL ?? "", o = Ca(n);
2457
+ const n = e.shellPath ?? t.SHELL ?? "", o = Aa(n);
2425
2458
  if (!o)
2426
2459
  return { installed: !1 };
2427
2460
  try {
2428
2461
  if (o === "bash") {
2429
- const l = await Sa(i, [".bashrc", ".bash_profile", ".profile"]), d = await J(l, Fe);
2462
+ const l = await Va(i, [".bashrc", ".bash_profile", ".profile"]), d = await J(l, je);
2430
2463
  return G(o, l, i, d);
2431
2464
  }
2432
2465
  if (o === "zsh") {
2433
- const l = h.join(i, ".zshrc"), d = await J(l, Fe);
2466
+ const l = h.join(i, ".zshrc"), d = await J(l, je);
2434
2467
  return G(o, l, i, d);
2435
2468
  }
2436
2469
  if (o === "fish") {
2437
2470
  const l = h.join(i, ".config", "fish", "functions", "arv.fish");
2438
2471
  await Y(h.dirname(l));
2439
- const d = await J(l, ba);
2472
+ const d = await J(l, Ca);
2440
2473
  return G(o, l, i, d);
2441
2474
  }
2442
- const c = await La(i);
2475
+ const c = await Ta(i);
2443
2476
  await Y(h.dirname(c));
2444
- const s = await J(c, ka);
2477
+ const s = await J(c, Ea);
2445
2478
  return G(o, c, i, s);
2446
2479
  } catch {
2447
2480
  return { installed: !1 };
@@ -2468,17 +2501,17 @@ async function ie(e) {
2468
2501
  throw t;
2469
2502
  }
2470
2503
  }
2471
- async function Ye(e, t) {
2504
+ async function He(e, t) {
2472
2505
  const a = t.map((i) => JSON.stringify(i)).join(`
2473
2506
  `);
2474
2507
  await p.writeFile(e, a.length > 0 ? `${a}
2475
2508
  ` : "", "utf8");
2476
2509
  }
2477
- async function st(e, t) {
2510
+ async function lt(e, t) {
2478
2511
  await p.appendFile(e, `${JSON.stringify(t)}
2479
2512
  `, "utf8");
2480
2513
  }
2481
- function He(e) {
2514
+ function Ue(e) {
2482
2515
  return {
2483
2516
  currentVaultId: Number.isInteger(e.currentVaultId) && e.currentVaultId >= 0 ? e.currentVaultId : g.Config.currentVaultId,
2484
2517
  updateCheck: e.updateCheck === "off" ? "off" : "on",
@@ -2489,14 +2522,14 @@ function He(e) {
2489
2522
  noCommandAction: e.noCommandAction === "help" || e.noCommandAction === "list" ? e.noCommandAction : "unknown"
2490
2523
  };
2491
2524
  }
2492
- function Ue(e) {
2525
+ function ze(e) {
2493
2526
  return {
2494
2527
  logId: Number.isInteger(e.logId) && e.logId >= 0 ? e.logId : 0,
2495
2528
  vaultId: Number.isInteger(e.vaultId) && e.vaultId >= 0 ? e.vaultId : 0,
2496
2529
  archiveId: Number.isInteger(e.archiveId) && e.archiveId >= 0 ? e.archiveId : 0
2497
2530
  };
2498
2531
  }
2499
- function ze(e) {
2532
+ function Be(e) {
2500
2533
  const t = e.isDirectory === 1 ? 1 : 0, a = e.status === y.Restored ? y.Restored : y.Archived;
2501
2534
  return {
2502
2535
  archivedAt: String(e.archivedAt ?? ""),
@@ -2510,7 +2543,7 @@ function ze(e) {
2510
2543
  remark: String(e.remark ?? "")
2511
2544
  };
2512
2545
  }
2513
- function Be(e) {
2546
+ function qe(e) {
2514
2547
  const t = S[e.status] ?? S.Valid;
2515
2548
  return {
2516
2549
  id: e.id,
@@ -2520,7 +2553,7 @@ function Be(e) {
2520
2553
  status: t
2521
2554
  };
2522
2555
  }
2523
- class $a {
2556
+ class Da {
2524
2557
  configCache;
2525
2558
  autoIncrCache;
2526
2559
  listCache;
@@ -2528,27 +2561,27 @@ class $a {
2528
2561
  async init() {
2529
2562
  for (const a of Object.values(f.Dir))
2530
2563
  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);
2564
+ 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
2565
  const t = await this.loadConfig();
2533
- t.currentVaultId === 0 || await E(this.vaultDir(t.currentVaultId)) || (t.currentVaultId = g.Vault.id, await this.saveConfig(t));
2566
+ t.currentVaultId === 0 || await C(this.vaultDir(t.currentVaultId)) || (t.currentVaultId = g.Vault.id, await this.saveConfig(t));
2534
2567
  }
2535
2568
  async loadConfig(t = !1) {
2536
2569
  if (this.configCache && !t)
2537
2570
  return this.configCache;
2538
- const a = await ve(f.File.config, g.Config), i = He({ ...g.Config, ...a });
2571
+ const a = await he(f.File.config, g.Config), i = Ue({ ...g.Config, ...a });
2539
2572
  return Z(i.language), this.configCache = i, i;
2540
2573
  }
2541
2574
  async saveConfig(t) {
2542
- this.configCache = He(t), Z(this.configCache.language), await xe(f.File.config, this.configCache, de);
2575
+ this.configCache = Ue(t), Z(this.configCache.language), await Ve(f.File.config, this.configCache, ue);
2543
2576
  }
2544
2577
  async loadAutoIncr(t = !1) {
2545
2578
  if (this.autoIncrCache && !t)
2546
2579
  return this.autoIncrCache;
2547
- const a = await ve(f.File.autoIncr, g.AutoIncr), i = Ue({ ...g.AutoIncr, ...a });
2580
+ const a = await he(f.File.autoIncr, g.AutoIncr), i = ze({ ...g.AutoIncr, ...a });
2548
2581
  return this.autoIncrCache = i, i;
2549
2582
  }
2550
2583
  async saveAutoIncr(t) {
2551
- this.autoIncrCache = Ue(t), await xe(f.File.autoIncr, this.autoIncrCache, ue);
2584
+ this.autoIncrCache = ze(t), await Ve(f.File.autoIncr, this.autoIncrCache, me);
2552
2585
  }
2553
2586
  async nextAutoIncrement(t) {
2554
2587
  const a = await this.loadAutoIncr();
@@ -2558,24 +2591,24 @@ class $a {
2558
2591
  if (this.listCache && !t)
2559
2592
  return this.listCache;
2560
2593
  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;
2594
+ 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
2595
  }
2563
2596
  async saveListEntries(t) {
2564
- this.listCache = [...t].sort((a, i) => a.id - i.id), await Ye(f.File.list, this.listCache);
2597
+ this.listCache = [...t].sort((a, i) => a.id - i.id), await He(f.File.list, this.listCache);
2565
2598
  }
2566
2599
  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);
2600
+ const a = Be(t);
2601
+ 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
2602
  }
2570
2603
  async loadVaults(t = !1) {
2571
2604
  if (this.vaultCache && !t)
2572
2605
  return this.vaultCache;
2573
2606
  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;
2607
+ 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
2608
  }
2576
2609
  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);
2610
+ const a = t.map((i) => qe(i)).filter((i) => i.id > 0).sort((i, n) => i.id - n.id);
2611
+ this.vaultCache = a, await He(f.File.vaults, a);
2579
2612
  }
2580
2613
  async getVaults(t) {
2581
2614
  const a = t?.includeRemoved ?? !1, i = t?.withDefault ?? !0, n = await this.loadVaults(), o = a ? n : n.filter((c) => c.status === "Valid");
@@ -2617,7 +2650,7 @@ class $a {
2617
2650
  if (!i || !i.isDirectory())
2618
2651
  return;
2619
2652
  const n = this.archiveObjectPath(t.vaultId, t.id, t.item);
2620
- if (await E(n))
2653
+ if (await C(n))
2621
2654
  return {
2622
2655
  slotPath: a,
2623
2656
  objectPath: n
@@ -2630,7 +2663,7 @@ class $a {
2630
2663
  t !== g.Vault.id && await p.rm(this.vaultDir(t), { recursive: !0, force: !0 });
2631
2664
  }
2632
2665
  }
2633
- class Na {
2666
+ class Pa {
2634
2667
  constructor(t, a) {
2635
2668
  this.context = t, this.logger = a;
2636
2669
  }
@@ -2644,7 +2677,7 @@ class Na {
2644
2677
  const o = { ok: [], failed: [] };
2645
2678
  for (const c of n) {
2646
2679
  const s = await this.context.nextAutoIncrement("archiveId"), l = this.context.archivePath(i.id, s), d = {
2647
- archivedAt: _e(),
2680
+ archivedAt: we(),
2648
2681
  status: y.Archived,
2649
2682
  isDirectory: c.stats.isDirectory() ? 1 : 0,
2650
2683
  vaultId: i.id,
@@ -2655,7 +2688,7 @@ class Na {
2655
2688
  remark: a.remark ?? ""
2656
2689
  };
2657
2690
  try {
2658
- if (await E(l))
2691
+ if (await C(l))
2659
2692
  throw new Error(
2660
2693
  r("service.archive.error.slot_exists", {
2661
2694
  path: l
@@ -2757,7 +2790,7 @@ class Na {
2757
2790
  path: this.context.archivePath(s.vaultId, s.id)
2758
2791
  })
2759
2792
  );
2760
- if (await E(d))
2793
+ if (await C(d))
2761
2794
  throw new Error(
2762
2795
  r("service.archive.error.restore_target_exists", {
2763
2796
  path: d
@@ -2838,17 +2871,17 @@ class Na {
2838
2871
  vault: i.name
2839
2872
  })
2840
2873
  );
2841
- const u = await this.context.resolveArchiveStorageLocation(m), _ = this.context.archivePath(m.vaultId, m.id), k = this.context.archivePath(i.id, m.id);
2874
+ const u = await this.context.resolveArchiveStorageLocation(m), _ = this.context.archivePath(m.vaultId, m.id), A = this.context.archivePath(i.id, m.id);
2842
2875
  if (!u)
2843
2876
  throw new Error(
2844
2877
  r("service.archive.error.object_missing", {
2845
2878
  path: _
2846
2879
  })
2847
2880
  );
2848
- if (await E(k))
2881
+ if (await C(A))
2849
2882
  throw new Error(
2850
2883
  r("service.archive.error.target_slot_exists", {
2851
- path: k
2884
+ path: A
2852
2885
  })
2853
2886
  );
2854
2887
  c.set(d, u);
@@ -2869,7 +2902,7 @@ class Na {
2869
2902
  });
2870
2903
  continue;
2871
2904
  }
2872
- const _ = this.context.archivePath(i.id, m.id), k = m.vaultId;
2905
+ const _ = this.context.archivePath(i.id, m.id), A = m.vaultId;
2873
2906
  try {
2874
2907
  await p.rename(u.slotPath, _), m.vaultId = i.id, l = !0, await this.logger.log(
2875
2908
  "INFO",
@@ -2881,7 +2914,7 @@ class Na {
2881
2914
  },
2882
2915
  r("service.archive.log.moved", {
2883
2916
  id: d,
2884
- fromVaultId: k,
2917
+ fromVaultId: A,
2885
2918
  toVaultId: i.id
2886
2919
  }),
2887
2920
  { aid: d, vid: i.id }
@@ -2894,8 +2927,8 @@ class Na {
2894
2927
  id: i.id
2895
2928
  })
2896
2929
  });
2897
- } catch (x) {
2898
- const L = x.message;
2930
+ } catch (L) {
2931
+ const x = L.message;
2899
2932
  await this.logger.log(
2900
2933
  "ERROR",
2901
2934
  {
@@ -2906,14 +2939,14 @@ class Na {
2906
2939
  },
2907
2940
  r("service.archive.log.move_failed", {
2908
2941
  id: d,
2909
- message: L
2942
+ message: x
2910
2943
  }),
2911
- { aid: d, vid: k }
2944
+ { aid: d, vid: A }
2912
2945
  ), s.failed.push({
2913
2946
  id: d,
2914
2947
  input: String(d),
2915
2948
  success: !1,
2916
- message: L
2949
+ message: x
2917
2950
  });
2918
2951
  }
2919
2952
  }
@@ -3069,7 +3102,7 @@ class Na {
3069
3102
  })
3070
3103
  );
3071
3104
  const l = await Me(c);
3072
- if (pa(l, n) || nt(n, l))
3105
+ if (wa(l, n) || rt(n, l))
3073
3106
  throw new Error(
3074
3107
  r("service.archive.error.path_forbidden_archiver_scope", {
3075
3108
  path: o
@@ -3094,7 +3127,7 @@ class Na {
3094
3127
  const i = await this.context.loadAutoIncr();
3095
3128
  for (let n = 1; n <= a; n += 1) {
3096
3129
  const o = i.archiveId + n, c = this.context.archivePath(t, o);
3097
- if (await E(c))
3130
+ if (await C(c))
3098
3131
  throw new Error(
3099
3132
  r("service.archive.error.slot_already_occupied", {
3100
3133
  path: c
@@ -3103,24 +3136,24 @@ class Na {
3103
3136
  }
3104
3137
  }
3105
3138
  }
3106
- class Da {
3139
+ class Oa {
3107
3140
  constructor(t) {
3108
3141
  this.context = t;
3109
3142
  }
3110
3143
  async log(t, a, i, n) {
3111
3144
  const s = {
3112
3145
  id: await this.context.nextAutoIncrement("logId"),
3113
- operedAt: _e(/* @__PURE__ */ new Date()),
3146
+ operedAt: we(/* @__PURE__ */ new Date()),
3114
3147
  level: t,
3115
3148
  oper: a,
3116
3149
  message: i,
3117
3150
  ...n?.aid !== void 0 ? { archiveIds: n.aid } : {},
3118
3151
  ...n?.vid !== void 0 ? { vaultIds: n.vid } : {}
3119
3152
  };
3120
- return await st(f.File.log, s), s;
3153
+ return await lt(f.File.log, s), s;
3121
3154
  }
3122
3155
  }
3123
- function le(e) {
3156
+ function de(e) {
3124
3157
  const t = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
3125
3158
  for (const i of e)
3126
3159
  t.has(i) ? a.add(i) : t.add(i);
@@ -3129,7 +3162,7 @@ function le(e) {
3129
3162
  function I(e, t, a, i) {
3130
3163
  e.push({ level: t, code: a, message: i });
3131
3164
  }
3132
- class Pa {
3165
+ class Ma {
3133
3166
  constructor(t) {
3134
3167
  this.context = t;
3135
3168
  }
@@ -3157,7 +3190,7 @@ class Pa {
3157
3190
  this.context.vaultDir(g.Vault.id)
3158
3191
  ];
3159
3192
  for (const i of a)
3160
- await E(i) || I(
3193
+ await C(i) || I(
3161
3194
  t.issues,
3162
3195
  w.Error,
3163
3196
  "MISSING_PATH",
@@ -3177,7 +3210,7 @@ class Pa {
3177
3210
  );
3178
3211
  }
3179
3212
  checkListIds(t, a, i) {
3180
- const n = a.map((s) => s.id), o = le(n);
3213
+ const n = a.map((s) => s.id), o = de(n);
3181
3214
  o.length > 0 && I(
3182
3215
  t.issues,
3183
3216
  w.Error,
@@ -3198,7 +3231,7 @@ class Pa {
3198
3231
  );
3199
3232
  }
3200
3233
  checkVaultIds(t, a, i) {
3201
- const n = a.filter((m) => m.id !== g.Vault.id), o = n.map((m) => m.id), c = le(o);
3234
+ const n = a.filter((m) => m.id !== g.Vault.id), o = n.map((m) => m.id), c = de(o);
3202
3235
  c.length > 0 && I(
3203
3236
  t.issues,
3204
3237
  w.Error,
@@ -3271,7 +3304,7 @@ class Pa {
3271
3304
  );
3272
3305
  }
3273
3306
  }
3274
- await E(l) && I(
3307
+ await C(l) && I(
3275
3308
  t.issues,
3276
3309
  w.Warn,
3277
3310
  "RESTORE_TARGET_ALREADY_EXISTS",
@@ -3281,7 +3314,7 @@ class Pa {
3281
3314
  })
3282
3315
  );
3283
3316
  } else if (o.status === y.Restored)
3284
- if (await E(s) && I(
3317
+ if (await C(s) && I(
3285
3318
  t.issues,
3286
3319
  w.Warn,
3287
3320
  "RESTORED_BUT_ARCHIVE_EXISTS",
@@ -3289,7 +3322,7 @@ class Pa {
3289
3322
  archiveId: o.id,
3290
3323
  archivePath: s
3291
3324
  })
3292
- ), await E(l)) {
3325
+ ), await C(l)) {
3293
3326
  const d = await ae(l);
3294
3327
  if (d) {
3295
3328
  const m = d.isDirectory(), u = o.isDirectory === 1;
@@ -3329,7 +3362,7 @@ class Pa {
3329
3362
  async checkVaultDirectoryConsistency(t, a, i) {
3330
3363
  const n = new Set(i.map((s) => s.id)), o = new Set(
3331
3364
  a.filter((s) => s.status === y.Archived).map((s) => `${s.vaultId}/${s.id}`)
3332
- ), c = await _a(f.Dir.vaults);
3365
+ ), c = await Ia(f.Dir.vaults);
3333
3366
  for (const s of c) {
3334
3367
  if (!/^\d+$/.test(s)) {
3335
3368
  I(
@@ -3392,7 +3425,7 @@ class Pa {
3392
3425
  if (s.status !== "Valid" && s.status !== "Protected")
3393
3426
  continue;
3394
3427
  const l = this.context.vaultDir(s.id);
3395
- await E(l) || I(
3428
+ await C(l) || I(
3396
3429
  t.issues,
3397
3430
  w.Error,
3398
3431
  "MISSING_VAULT_DIR",
@@ -3405,7 +3438,7 @@ class Pa {
3405
3438
  }
3406
3439
  }
3407
3440
  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);
3441
+ const n = (await ie(f.File.log)).map((s) => Number(s.id)).filter((s) => Number.isInteger(s)), o = de(n);
3409
3442
  o.length > 0 && I(
3410
3443
  t.issues,
3411
3444
  w.Error,
@@ -3426,7 +3459,7 @@ class Pa {
3426
3459
  );
3427
3460
  }
3428
3461
  }
3429
- class Ma {
3462
+ class Fa {
3430
3463
  constructor(t) {
3431
3464
  this.context = t;
3432
3465
  }
@@ -3462,7 +3495,7 @@ class Ma {
3462
3495
  a.lastUpdateCheck = t, await this.context.saveConfig(a);
3463
3496
  }
3464
3497
  }
3465
- function Oa(e) {
3498
+ function ja(e) {
3466
3499
  return {
3467
3500
  id: Number(e.id),
3468
3501
  operedAt: String(e.operedAt ?? ""),
@@ -3473,17 +3506,17 @@ function Oa(e) {
3473
3506
  ...e.vaultIds !== void 0 ? { vaultIds: Number(e.vaultIds) } : {}
3474
3507
  };
3475
3508
  }
3476
- function Fa(e) {
3509
+ function Ya(e) {
3477
3510
  return e.operedAt.replace(/[-:\sT]/g, "").slice(0, 6);
3478
3511
  }
3479
- class ja {
3512
+ class Ha {
3480
3513
  constructor(t) {
3481
3514
  this.context = t;
3482
3515
  }
3483
3516
  async getLogs(t) {
3484
3517
  const a = await this.loadAllLogs();
3485
3518
  return t.mode === "all" ? a : a.filter((i) => {
3486
- const n = Fa(i);
3519
+ const n = Ya(i);
3487
3520
  return !n || n.length !== 6 ? !1 : n >= t.from && n <= t.to;
3488
3521
  });
3489
3522
  }
@@ -3503,19 +3536,19 @@ class ja {
3503
3536
  return n;
3504
3537
  }
3505
3538
  async loadAllLogs() {
3506
- const a = (await ie(f.File.log)).map((i) => Oa(i));
3539
+ const a = (await ie(f.File.log)).map((i) => ja(i));
3507
3540
  return a.sort((i, n) => i.id - n.id), a;
3508
3541
  }
3509
3542
  }
3510
- const Ya = yt(It);
3511
- function fe(e) {
3543
+ const Ua = bt(yt);
3544
+ function ge(e) {
3512
3545
  return e.trim().replace(/^v/i, "");
3513
3546
  }
3514
- function qe(e) {
3515
- return fe(e).split(".").map((t) => Number(t.replace(/[^0-9].*$/, ""))).map((t) => Number.isFinite(t) ? t : 0);
3547
+ function We(e) {
3548
+ return ge(e).split(".").map((t) => Number(t.replace(/[^0-9].*$/, ""))).map((t) => Number.isFinite(t) ? t : 0);
3516
3549
  }
3517
- function Ha(e, t) {
3518
- const a = qe(e), i = qe(t), n = Math.max(a.length, i.length);
3550
+ function za(e, t) {
3551
+ const a = We(e), i = We(t), n = Math.max(a.length, i.length);
3519
3552
  for (let o = 0; o < n; o += 1) {
3520
3553
  const c = a[o] ?? 0, s = i[o] ?? 0;
3521
3554
  if (s > c)
@@ -3525,22 +3558,22 @@ function Ha(e, t) {
3525
3558
  }
3526
3559
  return !1;
3527
3560
  }
3528
- class Ua {
3561
+ class Ba {
3529
3562
  currentVersion;
3530
3563
  constructor(t) {
3531
- this.currentVersion = fe(t);
3564
+ this.currentVersion = ge(t);
3532
3565
  }
3533
- async checkLatest(t = M.Repo) {
3534
- const a = await this.fetchLatestRelease(t), i = fe(a.tag_name);
3566
+ async checkLatest(t = O.Repo) {
3567
+ const a = await this.fetchLatestRelease(t), i = ge(a.tag_name);
3535
3568
  return {
3536
3569
  currentVersion: this.currentVersion,
3537
3570
  latestVersion: i,
3538
- hasUpdate: Ha(this.currentVersion, i),
3571
+ hasUpdate: za(this.currentVersion, i),
3539
3572
  htmlUrl: a.html_url,
3540
3573
  publishedAt: a.published_at
3541
3574
  };
3542
3575
  }
3543
- async installLatest(t = M.Repo) {
3576
+ async installLatest(t = O.Repo) {
3544
3577
  const i = (await this.fetchLatestRelease(t)).assets?.find((s) => /install.*\.sh$/i.test(s.name));
3545
3578
  if (!i)
3546
3579
  throw new Error(r("service.update.error.no_install_asset"));
@@ -3548,7 +3581,7 @@ class Ua {
3548
3581
  headers: {
3549
3582
  "user-agent": "archiver-ts"
3550
3583
  },
3551
- signal: AbortSignal.timeout(M.Timeout)
3584
+ signal: AbortSignal.timeout(O.Timeout)
3552
3585
  });
3553
3586
  if (!n.ok)
3554
3587
  throw new Error(
@@ -3556,10 +3589,10 @@ class Ua {
3556
3589
  status: n.status
3557
3590
  })
3558
3591
  );
3559
- const o = await n.text(), c = h.join(Je.tmpdir(), `archiver-update-${Date.now()}.sh`);
3592
+ const o = await n.text(), c = h.join(Ge.tmpdir(), `archiver-update-${Date.now()}.sh`);
3560
3593
  await p.writeFile(c, o, { encoding: "utf8", mode: 493 });
3561
3594
  try {
3562
- const s = await Ya("bash", [c], { maxBuffer: 4194304 });
3595
+ const s = await Ua("bash", [c], { maxBuffer: 4194304 });
3563
3596
  return [s.stdout, s.stderr].filter(Boolean).join(`
3564
3597
  `).trim();
3565
3598
  } finally {
@@ -3572,7 +3605,7 @@ class Ua {
3572
3605
  accept: "application/vnd.github+json",
3573
3606
  "user-agent": "archiver-ts"
3574
3607
  },
3575
- signal: AbortSignal.timeout(M.Timeout)
3608
+ signal: AbortSignal.timeout(O.Timeout)
3576
3609
  });
3577
3610
  if (!i.ok)
3578
3611
  throw new Error(
@@ -3591,10 +3624,10 @@ class Ua {
3591
3624
  return n;
3592
3625
  }
3593
3626
  }
3594
- async function za() {
3595
- const e = new $a();
3627
+ async function qa() {
3628
+ const e = new Da();
3596
3629
  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);
3630
+ const t = new Fa(e), a = new Oa(e), i = new Pa(e, a), n = new ya(e, t), o = new Ha(e), c = new Ma(e), s = "0.3.4", l = new Ba(s);
3598
3631
  return {
3599
3632
  context: e,
3600
3633
  archiveService: i,
@@ -3607,11 +3640,11 @@ async function za() {
3607
3640
  version: s
3608
3641
  };
3609
3642
  }
3610
- async function Ba(e) {
3611
- if (!Ie())
3643
+ async function Wa(e) {
3644
+ if (!ye())
3612
3645
  return "help";
3613
- A(r("index.no_command_action.unknown"));
3614
- const t = await qt({
3646
+ E(r("index.no_command_action.unknown"));
3647
+ const t = await Jt({
3615
3648
  title: r("index.no_command_action.question"),
3616
3649
  description: r("index.no_command_action.note"),
3617
3650
  options: [
@@ -3624,28 +3657,28 @@ async function Ba(e) {
3624
3657
  enter: R(r("index.no_command_action.key.enter"))
3625
3658
  })
3626
3659
  });
3627
- return t || process.exit(130), await e.configService.setNoCommandAction(t), C(r("index.no_command_action.updated", { action: t })), t;
3660
+ return t || process.exit(130), await e.configService.setNoCommandAction(t), k(r("index.no_command_action.updated", { action: t })), t;
3628
3661
  }
3629
- async function qa() {
3630
- const e = await ve(f.File.config, g.Config);
3662
+ async function Ja() {
3663
+ const e = await he(f.File.config, g.Config);
3631
3664
  Z(e.language), ee({
3632
3665
  style: e.style === "off" ? "off" : "on"
3633
3666
  });
3634
- const t = await Ta();
3667
+ const t = await Na();
3635
3668
  if (t.installed) {
3636
3669
  const o = t.profilePath ? ` ${t.profilePath}` : "";
3637
- A(r("index.shell_wrapper.installed", { where: o })), t.reloadCommand && A(
3670
+ E(r("index.shell_wrapper.installed", { where: o })), t.reloadCommand && E(
3638
3671
  r("index.shell_wrapper.reload_hint", {
3639
3672
  reloadCommand: t.reloadCommand
3640
3673
  })
3641
3674
  );
3642
3675
  return;
3643
3676
  }
3644
- const a = await za(), i = await a.configService.getConfig();
3677
+ const a = await qa(), i = await a.configService.getConfig();
3645
3678
  Z(i.language), ee(i);
3646
- const n = ya(a);
3679
+ const n = ka(a);
3647
3680
  if (process.argv.length <= 2) {
3648
- if ((i.noCommandAction === "unknown" ? await Ba(a) : i.noCommandAction) === "list") {
3681
+ if ((i.noCommandAction === "unknown" ? await Wa(a) : i.noCommandAction) === "list") {
3649
3682
  await n.parseAsync([...process.argv, "list"]);
3650
3683
  return;
3651
3684
  }
@@ -3654,6 +3687,6 @@ async function qa() {
3654
3687
  }
3655
3688
  await n.parseAsync(process.argv);
3656
3689
  }
3657
- qa().catch((e) => {
3690
+ Ja().catch((e) => {
3658
3691
  j(e.message), process.exit(1);
3659
3692
  });