@milaboratories/pl-drivers 1.5.53 → 1.5.55

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 (34) hide show
  1. package/dist/drivers/{download_blob.d.ts → download_blob/download_blob.d.ts} +7 -8
  2. package/dist/drivers/download_blob/download_blob.d.ts.map +1 -0
  3. package/dist/drivers/{download_blob_task.d.ts → download_blob/download_blob_task.d.ts} +1 -1
  4. package/dist/drivers/download_blob/download_blob_task.d.ts.map +1 -0
  5. package/dist/drivers/helpers/files_cache.d.ts.map +1 -1
  6. package/dist/drivers/logs.d.ts +1 -1
  7. package/dist/drivers/logs.d.ts.map +1 -1
  8. package/dist/drivers/upload_task.d.ts +2 -0
  9. package/dist/drivers/upload_task.d.ts.map +1 -1
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +2 -2
  13. package/dist/index.js.map +1 -1
  14. package/dist/index.mjs +714 -709
  15. package/dist/index.mjs.map +1 -1
  16. package/package.json +8 -11
  17. package/src/clients/download.test.ts +1 -1
  18. package/src/clients/upload.test.ts +2 -1
  19. package/src/drivers/{download_blob.test.ts → download_blob/download_blob.test.ts} +3 -3
  20. package/src/drivers/{download_blob.ts → download_blob/download_blob.ts} +59 -42
  21. package/src/drivers/{download_blob_task.ts → download_blob/download_blob_task.ts} +3 -3
  22. package/src/drivers/download_blob_url/driver.ts +1 -1
  23. package/src/drivers/download_blob_url/url.test.ts +1 -1
  24. package/src/drivers/download_url.test.ts +1 -1
  25. package/src/drivers/helpers/files_cache.test.ts +1 -1
  26. package/src/drivers/helpers/files_cache.ts +10 -3
  27. package/src/drivers/logs.test.ts +2 -2
  28. package/src/drivers/logs.ts +1 -1
  29. package/src/drivers/ls.test.ts +1 -1
  30. package/src/drivers/upload.test.ts +1 -1
  31. package/src/drivers/upload_task.ts +2 -2
  32. package/src/index.ts +1 -1
  33. package/dist/drivers/download_blob.d.ts.map +0 -1
  34. package/dist/drivers/download_blob_task.d.ts.map +0 -1
package/dist/index.mjs CHANGED
@@ -1,35 +1,35 @@
1
- var it = Object.defineProperty;
2
- var at = (s, e, t) => e in s ? it(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var d = (s, e, t) => at(s, typeof e != "symbol" ? e + "" : e, t);
4
- import { addRTypeToMetadata as P, bigintToResourceId as ue, stringifyWithResourceId as y, resourceIdToString as lt, isNotNullResourceId as ct } from "@milaboratories/pl-client";
1
+ var at = Object.defineProperty;
2
+ var lt = (s, e, t) => e in s ? at(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var d = (s, e, t) => lt(s, typeof e != "symbol" ? e + "" : e, t);
4
+ import { addRTypeToMetadata as U, bigintToResourceId as pe, stringifyWithResourceId as b, resourceIdToString as ct, isNotNullResourceId as dt } from "@milaboratories/pl-client";
5
5
  import * as m from "node:fs/promises";
6
- import { request as $e } from "undici";
7
- import { ServiceType as _, stackIntercept as T } from "@protobuf-ts/runtime-rpc";
8
- import { MessageType as g, reflectionMergePartial as f, UnknownFieldHandler as u, WireType as h, PbLong as D, typeofJsonValue as Be, assertNever as dt } from "@protobuf-ts/runtime";
9
- import { notEmpty as H, CallersCounter as v, ensureDirExists as pe, fileExists as ge, createPathAtomically as fe, mapGet as Ue, mapEntries as ht, TaskProcessor as j, asyncPool as me, assertNever as ut } from "@milaboratories/ts-helpers";
10
- import * as we from "node:fs";
11
- import ae from "node:fs";
12
- import * as b from "node:path";
13
- import L from "node:path";
14
- import { Readable as ye, Writable as S, Transform as Ce } from "node:stream";
15
- import { text as pt, buffer as _e } from "node:stream/consumers";
16
- import { ChangeSource as N, Computable as w, PollingComputableHooks as Ee } from "@milaboratories/computable";
17
- import { rsSchema as G, treeEntryToResourceInfo as R, isPlTreeEntry as E, makeResourceSnapshot as x, isPlTreeEntryAccessor as Oe } from "@milaboratories/pl-tree";
18
- import gt from "denque";
19
- import { randomUUID as U, createHash as ft } from "node:crypto";
20
- import * as De from "node:os";
21
- import mt from "node:os";
22
- import * as wt from "node:readline/promises";
23
- import { z as k } from "zod";
24
- import * as Fe from "node:zlib";
25
- import * as le from "tar-fs";
26
- import yt from "decompress";
27
- import { scheduler as We } from "node:timers/promises";
28
- import bt from "node:assert";
29
- import { isImportFileHandleIndex as Tt } from "@milaboratories/pl-model-common";
30
- import kt from "node:util";
31
- import { exec as Lt } from "node:child_process";
32
- class Pt extends g {
6
+ import { request as Be } from "undici";
7
+ import { ServiceType as E, stackIntercept as k } from "@protobuf-ts/runtime-rpc";
8
+ import { MessageType as g, reflectionMergePartial as f, UnknownFieldHandler as u, WireType as h, PbLong as R, typeofJsonValue as Ce, assertNever as ht } from "@protobuf-ts/runtime";
9
+ import { notEmpty as j, CallersCounter as N, ensureDirExists as ge, fileExists as fe, createPathAtomically as me, mapGet as De, mapEntries as ut, TaskProcessor as G, asyncPool as we, assertNever as pt } from "@milaboratories/ts-helpers";
10
+ import * as ye from "node:fs";
11
+ import le from "node:fs";
12
+ import * as T from "node:path";
13
+ import P from "node:path";
14
+ import { Readable as be, Writable as I, Transform as _e } from "node:stream";
15
+ import { text as gt, buffer as Ee } from "node:stream/consumers";
16
+ import { ChangeSource as $, Computable as y, PollingComputableHooks as Oe } from "@milaboratories/computable";
17
+ import { rsSchema as V, treeEntryToResourceInfo as S, isPlTreeEntry as O, makeResourceSnapshot as A, isPlTreeEntryAccessor as Fe } from "@milaboratories/pl-tree";
18
+ import ft from "denque";
19
+ import { randomUUID as D, createHash as mt } from "node:crypto";
20
+ import * as Re from "node:os";
21
+ import wt from "node:os";
22
+ import * as yt from "node:readline/promises";
23
+ import { z as L } from "zod";
24
+ import * as We from "node:zlib";
25
+ import * as ce from "tar-fs";
26
+ import bt from "decompress";
27
+ import { scheduler as ze } from "node:timers/promises";
28
+ import Tt from "node:assert";
29
+ import { isImportFileHandleIndex as kt } from "@milaboratories/pl-model-common";
30
+ import Lt from "node:util";
31
+ import { exec as Pt } from "node:child_process";
32
+ class Ut extends g {
33
33
  constructor() {
34
34
  super("MiLaboratories.Controller.Shared.uploadapi", []);
35
35
  }
@@ -49,8 +49,8 @@ class Pt extends g {
49
49
  ), t;
50
50
  }
51
51
  }
52
- new Pt();
53
- class Ut extends g {
52
+ new Ut();
53
+ class Dt extends g {
54
54
  constructor() {
55
55
  super("MiLaboratories.Controller.Shared.uploadapi.Init", []);
56
56
  }
@@ -70,8 +70,8 @@ class Ut extends g {
70
70
  ), t;
71
71
  }
72
72
  }
73
- new Ut();
74
- class Dt extends g {
73
+ new Dt();
74
+ class Rt extends g {
75
75
  constructor() {
76
76
  super("MiLaboratories.Controller.Shared.uploadapi.Init.Request", [
77
77
  {
@@ -125,8 +125,8 @@ class Dt extends g {
125
125
  ), t;
126
126
  }
127
127
  }
128
- const Rt = new Dt();
129
- class St extends g {
128
+ const St = new Rt();
129
+ class It extends g {
130
130
  constructor() {
131
131
  super("MiLaboratories.Controller.Shared.uploadapi.Init.Response", [
132
132
  {
@@ -164,7 +164,7 @@ class St extends g {
164
164
  case /* repeated uint64 uploaded_parts */
165
165
  2:
166
166
  if (c === h.LengthDelimited)
167
- for (let J = e.int32() + e.pos; e.pos < J; )
167
+ for (let Z = e.int32() + e.pos; e.pos < Z; )
168
168
  r.uploadedParts.push(e.uint64().toBigInt());
169
169
  else r.uploadedParts.push(e.uint64().toBigInt());
170
170
  break;
@@ -201,8 +201,8 @@ class St extends g {
201
201
  ), t;
202
202
  }
203
203
  }
204
- const It = new St();
205
- class vt extends g {
204
+ const vt = new It();
205
+ class Nt extends g {
206
206
  constructor() {
207
207
  super("MiLaboratories.Controller.Shared.uploadapi.UpdateProgress", []);
208
208
  }
@@ -222,8 +222,8 @@ class vt extends g {
222
222
  ), t;
223
223
  }
224
224
  }
225
- new vt();
226
- class Nt extends g {
225
+ new Nt();
226
+ class $t extends g {
227
227
  constructor() {
228
228
  super("MiLaboratories.Controller.Shared.uploadapi.UpdateProgress.Request", [
229
229
  {
@@ -293,8 +293,8 @@ class Nt extends g {
293
293
  ), t;
294
294
  }
295
295
  }
296
- const $t = new Nt();
297
- class Bt extends g {
296
+ const Bt = new $t();
297
+ class Ct extends g {
298
298
  constructor() {
299
299
  super(
300
300
  "MiLaboratories.Controller.Shared.uploadapi.UpdateProgress.Response",
@@ -321,8 +321,8 @@ class Bt extends g {
321
321
  ), t;
322
322
  }
323
323
  }
324
- const Ct = new Bt();
325
- class _t extends g {
324
+ const _t = new Ct();
325
+ class Et extends g {
326
326
  constructor() {
327
327
  super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL", []);
328
328
  }
@@ -342,8 +342,8 @@ class _t extends g {
342
342
  ), t;
343
343
  }
344
344
  }
345
- new _t();
346
- class Et extends g {
345
+ new Et();
346
+ class Ot extends g {
347
347
  constructor() {
348
348
  super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.Request", [
349
349
  {
@@ -425,8 +425,8 @@ class Et extends g {
425
425
  ), t;
426
426
  }
427
427
  }
428
- const Ot = new Et();
429
- class Ft extends g {
428
+ const Ft = new Ot();
429
+ class Wt extends g {
430
430
  constructor() {
431
431
  super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.HTTPHeader", [
432
432
  {
@@ -496,8 +496,8 @@ class Ft extends g {
496
496
  ), t;
497
497
  }
498
498
  }
499
- const Z = new Ft();
500
- class Wt extends g {
499
+ const Q = new Wt();
500
+ class zt extends g {
501
501
  constructor() {
502
502
  super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.Response", [
503
503
  {
@@ -519,7 +519,7 @@ class Wt extends g {
519
519
  name: "headers",
520
520
  kind: "message",
521
521
  repeat: 1,
522
- T: () => Z
522
+ T: () => Q
523
523
  },
524
524
  {
525
525
  no: 4,
@@ -563,7 +563,7 @@ class Wt extends g {
563
563
  case /* repeated MiLaboratories.Controller.Shared.uploadapi.GetPartURL.HTTPHeader headers */
564
564
  3:
565
565
  r.headers.push(
566
- Z.internalBinaryRead(
566
+ Q.internalBinaryRead(
567
567
  e,
568
568
  e.uint32(),
569
569
  o
@@ -599,7 +599,7 @@ class Wt extends g {
599
599
  internalBinaryWrite(e, t, o) {
600
600
  e.uploadUrl !== "" && t.tag(1, h.LengthDelimited).string(e.uploadUrl), e.method !== "" && t.tag(2, h.LengthDelimited).string(e.method);
601
601
  for (let r = 0; r < e.headers.length; r++)
602
- Z.internalBinaryWrite(
602
+ Q.internalBinaryWrite(
603
603
  e.headers[r],
604
604
  t.tag(3, h.LengthDelimited).fork(),
605
605
  o
@@ -613,8 +613,8 @@ class Wt extends g {
613
613
  ), t;
614
614
  }
615
615
  }
616
- const zt = new Wt();
617
- class xt extends g {
616
+ const xt = new zt();
617
+ class At extends g {
618
618
  constructor() {
619
619
  super("MiLaboratories.Controller.Shared.uploadapi.Finalize", []);
620
620
  }
@@ -634,8 +634,8 @@ class xt extends g {
634
634
  ), t;
635
635
  }
636
636
  }
637
- new xt();
638
- class At extends g {
637
+ new At();
638
+ class Mt extends g {
639
639
  constructor() {
640
640
  super("MiLaboratories.Controller.Shared.uploadapi.Finalize.Request", [
641
641
  {
@@ -689,8 +689,8 @@ class At extends g {
689
689
  ), t;
690
690
  }
691
691
  }
692
- const Mt = new At();
693
- class Ht extends g {
692
+ const Ht = new Mt();
693
+ class jt extends g {
694
694
  constructor() {
695
695
  super("MiLaboratories.Controller.Shared.uploadapi.Finalize.Response", []);
696
696
  }
@@ -710,40 +710,40 @@ class Ht extends g {
710
710
  ), t;
711
711
  }
712
712
  }
713
- const jt = new Ht(), Q = new _(
713
+ const Gt = new jt(), X = new E(
714
714
  "MiLaboratories.Controller.Shared.Upload",
715
715
  [
716
716
  {
717
717
  name: "Init",
718
718
  options: {},
719
- I: Rt,
720
- O: It
719
+ I: St,
720
+ O: vt
721
721
  },
722
722
  {
723
723
  name: "GetPartURL",
724
724
  options: {},
725
- I: Ot,
726
- O: zt
725
+ I: Ft,
726
+ O: xt
727
727
  },
728
728
  {
729
729
  name: "UpdateProgress",
730
730
  options: {},
731
- I: $t,
732
- O: Ct
731
+ I: Bt,
732
+ O: _t
733
733
  },
734
734
  {
735
735
  name: "Finalize",
736
736
  options: {},
737
- I: Mt,
738
- O: jt
737
+ I: Ht,
738
+ O: Gt
739
739
  }
740
740
  ]
741
741
  );
742
- class Gt {
742
+ class Vt {
743
743
  constructor(e) {
744
- d(this, "typeName", Q.typeName);
745
- d(this, "methods", Q.methods);
746
- d(this, "options", Q.options);
744
+ d(this, "typeName", X.typeName);
745
+ d(this, "methods", X.methods);
746
+ d(this, "options", X.options);
747
747
  this._transport = e;
748
748
  }
749
749
  /**
@@ -755,7 +755,7 @@ class Gt {
755
755
  */
756
756
  init(e, t) {
757
757
  const o = this.methods[0], n = this._transport.mergeOptions(t);
758
- return T(
758
+ return k(
759
759
  "unary",
760
760
  this._transport,
761
761
  o,
@@ -773,7 +773,7 @@ class Gt {
773
773
  */
774
774
  getPartURL(e, t) {
775
775
  const o = this.methods[1], n = this._transport.mergeOptions(t);
776
- return T("unary", this._transport, o, n, e);
776
+ return k("unary", this._transport, o, n, e);
777
777
  }
778
778
  /**
779
779
  *
@@ -784,7 +784,7 @@ class Gt {
784
784
  */
785
785
  updateProgress(e, t) {
786
786
  const o = this.methods[2], n = this._transport.mergeOptions(t);
787
- return T("unary", this._transport, o, n, e);
787
+ return k("unary", this._transport, o, n, e);
788
788
  }
789
789
  /**
790
790
  *
@@ -797,25 +797,25 @@ class Gt {
797
797
  */
798
798
  finalize(e, t) {
799
799
  const o = this.methods[3], n = this._transport.mergeOptions(t);
800
- return T("unary", this._transport, o, n, e);
800
+ return k("unary", this._transport, o, n, e);
801
801
  }
802
802
  }
803
- function ze(s, e, t) {
803
+ function xe(s, e, t) {
804
804
  const o = Object.fromEntries(s.map(({ name: n, value: r }) => [n, r]));
805
805
  return e !== void 0 && t !== void 0 && (o.Range = `bytes=${e}-${t}`), o;
806
806
  }
807
- class xe extends Error {
808
- }
809
807
  class Ae extends Error {
810
808
  }
811
809
  class Me extends Error {
812
810
  }
813
811
  class He extends Error {
814
812
  }
815
- class Vt {
813
+ class je extends Error {
814
+ }
815
+ class qt {
816
816
  constructor(e, t, o, n) {
817
817
  d(this, "grpcClient");
818
- this.grpcTransport = e, this.httpClient = t, this.logger = n, this.grpcClient = new Gt(this.grpcTransport);
818
+ this.grpcTransport = e, this.httpClient = t, this.logger = n, this.grpcClient = new Vt(this.grpcTransport);
819
819
  }
820
820
  close() {
821
821
  }
@@ -833,14 +833,14 @@ class Vt {
833
833
  0n,
834
834
  // we update progress as a separate call later.
835
835
  a
836
- ), c = await qt(o, i.chunkStart, i.chunkEnd);
837
- await Zt(o, n);
836
+ ), c = await Jt(o, i.chunkStart, i.chunkEnd);
837
+ await Qt(o, n);
838
838
  try {
839
839
  const {
840
840
  body: l,
841
841
  statusCode: p,
842
- headers: J
843
- } = await $e(i.uploadUrl, {
842
+ headers: Z
843
+ } = await Be(i.uploadUrl, {
844
844
  dispatcher: this.httpClient,
845
845
  body: c,
846
846
  // We got headers only after we send
@@ -849,12 +849,12 @@ class Vt {
849
849
  // that's why we got big timeout here.
850
850
  headersTimeout: 6e4,
851
851
  bodyTimeout: 6e4,
852
- headers: ze(i.headers),
852
+ headers: xe(i.headers),
853
853
  method: i.method.toUpperCase()
854
- }), st = await l.text();
855
- Qt(p, st, J, i);
854
+ }), it = await l.text();
855
+ Xt(p, it, Z, i);
856
856
  } catch (l) {
857
- throw l instanceof Me ? l : new Error(`partUpload: error ${JSON.stringify(l)} happened while trying to do part upload to the url ${i.uploadUrl}, headers: ${JSON.stringify(i.headers)}`);
857
+ throw l instanceof He ? l : new Error(`partUpload: error ${JSON.stringify(l)} happened while trying to do part upload to the url ${i.uploadUrl}, headers: ${JSON.stringify(i.headers)}`);
858
858
  }
859
859
  await this.grpcUpdateProgress({ id: e, type: t }, BigInt(i.chunkEnd - i.chunkStart), a);
860
860
  }
@@ -870,12 +870,12 @@ class Vt {
870
870
  return o;
871
871
  }
872
872
  async grpcInit(e, t, o) {
873
- return await this.grpcClient.init({ resourceId: e }, P(t, o)).response;
873
+ return await this.grpcClient.init({ resourceId: e }, U(t, o)).response;
874
874
  }
875
875
  async grpcGetPartUrl({ id: e, type: t }, o, n, r) {
876
876
  return await this.grpcClient.getPartURL(
877
877
  { resourceId: e, partNumber: o, uploadedPartSize: n },
878
- P(t, r)
878
+ U(t, r)
879
879
  ).response;
880
880
  }
881
881
  async grpcUpdateProgress({ id: e, type: t }, o, n) {
@@ -884,26 +884,26 @@ class Vt {
884
884
  resourceId: e,
885
885
  bytesProcessed: o
886
886
  },
887
- P(t, n)
887
+ U(t, n)
888
888
  ).response;
889
889
  }
890
890
  async grpcFinalize({ id: e, type: t }, o) {
891
- return await this.grpcClient.finalize({ resourceId: e }, P(t, o)).response;
891
+ return await this.grpcClient.finalize({ resourceId: e }, U(t, o)).response;
892
892
  }
893
893
  }
894
- async function qt(s, e, t) {
894
+ async function Jt(s, e, t) {
895
895
  let o;
896
896
  try {
897
897
  o = await m.open(s);
898
- const n = Number(t - e), r = Number(e), a = Buffer.alloc(n), i = await Jt(o, a, n, r);
898
+ const n = Number(t - e), r = Number(e), a = Buffer.alloc(n), i = await Zt(o, a, n, r);
899
899
  return a.subarray(0, i);
900
900
  } catch (n) {
901
- throw n && typeof n == "object" && "code" in n && n.code == "ENOENT" ? new He(`there is no file ${s} for uploading`) : n;
901
+ throw n && typeof n == "object" && "code" in n && n.code == "ENOENT" ? new je(`there is no file ${s} for uploading`) : n;
902
902
  } finally {
903
903
  await (o == null ? void 0 : o.close());
904
904
  }
905
905
  }
906
- async function Jt(s, e, t, o) {
906
+ async function Zt(s, e, t, o) {
907
907
  let n = 0;
908
908
  for (; n < t; ) {
909
909
  const { bytesRead: r } = await s.read(
@@ -913,23 +913,23 @@ async function Jt(s, e, t, o) {
913
913
  o + n
914
914
  );
915
915
  if (r === 0)
916
- throw new Ae("file ended earlier than expected.");
916
+ throw new Me("file ended earlier than expected.");
917
917
  n += r;
918
918
  }
919
919
  return n;
920
920
  }
921
- async function Zt(s, e) {
921
+ async function Qt(s, e) {
922
922
  const t = BigInt(Math.floor((await m.stat(s)).mtimeMs / 1e3));
923
923
  if (t > e)
924
- throw new xe(`file was modified, expected mtime: ${e}, got: ${t}.`);
924
+ throw new Ae(`file was modified, expected mtime: ${e}, got: ${t}.`);
925
925
  }
926
- function Qt(s, e, t, o) {
926
+ function Xt(s, e, t, o) {
927
927
  if (s != 200)
928
- throw new Me(
928
+ throw new He(
929
929
  `response is not ok, status code: ${s}, body: ${e}, headers: ${JSON.stringify(t)}, url: ${o.uploadUrl}`
930
930
  );
931
931
  }
932
- class Xt extends g {
932
+ class Kt extends g {
933
933
  constructor() {
934
934
  super("google.protobuf.Duration", [
935
935
  {
@@ -953,7 +953,7 @@ class Xt extends g {
953
953
  * Encode `Duration` to JSON string like "3.000001s".
954
954
  */
955
955
  internalJsonWrite(e, t) {
956
- const o = D.from(e.seconds).toNumber();
956
+ const o = R.from(e.seconds).toNumber();
957
957
  if (o > 315576e6 || o < -315576e6)
958
958
  throw new Error("Duration value out of range.");
959
959
  let n = e.seconds.toString();
@@ -969,7 +969,7 @@ class Xt extends g {
969
969
  internalJsonRead(e, t, o) {
970
970
  if (typeof e != "string")
971
971
  throw new Error(
972
- "Unable to parse Duration from JSON " + Be(e) + ". Expected string."
972
+ "Unable to parse Duration from JSON " + Ce(e) + ". Expected string."
973
973
  );
974
974
  const n = e.match(/^(-?)([0-9]+)(?:\.([0-9]+))?s/);
975
975
  if (n === null)
@@ -977,7 +977,7 @@ class Xt extends g {
977
977
  "Unable to parse Duration from JSON string. Invalid format."
978
978
  );
979
979
  o || (o = this.create());
980
- const [, r, a, i] = n, c = D.from(r + a);
980
+ const [, r, a, i] = n, c = R.from(r + a);
981
981
  if (c.toNumber() > 315576e6 || c.toNumber() < -315576e6)
982
982
  throw new Error(
983
983
  "Unable to parse Duration from JSON string. Value out of range."
@@ -1033,8 +1033,8 @@ class Xt extends g {
1033
1033
  ), t;
1034
1034
  }
1035
1035
  }
1036
- const z = new Xt();
1037
- class Kt extends g {
1036
+ const x = new Kt();
1037
+ class Yt extends g {
1038
1038
  constructor() {
1039
1039
  super("MiLaboratories.Controller.Shared.ProgressAPI", []);
1040
1040
  }
@@ -1054,8 +1054,8 @@ class Kt extends g {
1054
1054
  ), t;
1055
1055
  }
1056
1056
  }
1057
- new Kt();
1058
- class Yt extends g {
1057
+ new Yt();
1058
+ class eo extends g {
1059
1059
  constructor() {
1060
1060
  super("MiLaboratories.Controller.Shared.ProgressAPI.Report", [
1061
1061
  {
@@ -1154,8 +1154,8 @@ class Yt extends g {
1154
1154
  ), t;
1155
1155
  }
1156
1156
  }
1157
- const I = new Yt();
1158
- class eo extends g {
1157
+ const v = new eo();
1158
+ class to extends g {
1159
1159
  constructor() {
1160
1160
  super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus", []);
1161
1161
  }
@@ -1175,8 +1175,8 @@ class eo extends g {
1175
1175
  ), t;
1176
1176
  }
1177
1177
  }
1178
- new eo();
1179
- class to extends g {
1178
+ new to();
1179
+ class oo extends g {
1180
1180
  constructor() {
1181
1181
  super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus.Request", [
1182
1182
  {
@@ -1234,11 +1234,11 @@ class to extends g {
1234
1234
  ), t;
1235
1235
  }
1236
1236
  }
1237
- const oo = new to();
1238
- class no extends g {
1237
+ const no = new oo();
1238
+ class ro extends g {
1239
1239
  constructor() {
1240
1240
  super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus.Response", [
1241
- { no: 1, name: "report", kind: "message", T: () => I }
1241
+ { no: 1, name: "report", kind: "message", T: () => v }
1242
1242
  ]);
1243
1243
  }
1244
1244
  create(e) {
@@ -1256,7 +1256,7 @@ class no extends g {
1256
1256
  switch (i) {
1257
1257
  case /* MiLaboratories.Controller.Shared.ProgressAPI.Report report */
1258
1258
  1:
1259
- r.report = I.internalBinaryRead(
1259
+ r.report = v.internalBinaryRead(
1260
1260
  e,
1261
1261
  e.uint32(),
1262
1262
  o,
@@ -1282,7 +1282,7 @@ class no extends g {
1282
1282
  return r;
1283
1283
  }
1284
1284
  internalBinaryWrite(e, t, o) {
1285
- e.report && I.internalBinaryWrite(
1285
+ e.report && v.internalBinaryWrite(
1286
1286
  e.report,
1287
1287
  t.tag(1, h.LengthDelimited).fork(),
1288
1288
  o
@@ -1295,8 +1295,8 @@ class no extends g {
1295
1295
  ), t;
1296
1296
  }
1297
1297
  }
1298
- const ro = new no();
1299
- class so extends g {
1298
+ const so = new ro();
1299
+ class io extends g {
1300
1300
  constructor() {
1301
1301
  super("MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus", []);
1302
1302
  }
@@ -1316,8 +1316,8 @@ class so extends g {
1316
1316
  ), t;
1317
1317
  }
1318
1318
  }
1319
- new so();
1320
- class io extends g {
1319
+ new io();
1320
+ class ao extends g {
1321
1321
  constructor() {
1322
1322
  super(
1323
1323
  "MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Request",
@@ -1330,7 +1330,7 @@ class io extends g {
1330
1330
  L: 0
1331
1331
  /* LongType.BIGINT */
1332
1332
  },
1333
- { no: 2, name: "update_interval", kind: "message", T: () => z }
1333
+ { no: 2, name: "update_interval", kind: "message", T: () => x }
1334
1334
  ]
1335
1335
  );
1336
1336
  }
@@ -1353,7 +1353,7 @@ class io extends g {
1353
1353
  break;
1354
1354
  case /* google.protobuf.Duration update_interval */
1355
1355
  2:
1356
- r.updateInterval = z.internalBinaryRead(
1356
+ r.updateInterval = x.internalBinaryRead(
1357
1357
  e,
1358
1358
  e.uint32(),
1359
1359
  o,
@@ -1379,7 +1379,7 @@ class io extends g {
1379
1379
  return r;
1380
1380
  }
1381
1381
  internalBinaryWrite(e, t, o) {
1382
- e.resourceId !== 0n && t.tag(1, h.Varint).uint64(e.resourceId), e.updateInterval && z.internalBinaryWrite(
1382
+ e.resourceId !== 0n && t.tag(1, h.Varint).uint64(e.resourceId), e.updateInterval && x.internalBinaryWrite(
1383
1383
  e.updateInterval,
1384
1384
  t.tag(2, h.LengthDelimited).fork(),
1385
1385
  o
@@ -1392,12 +1392,12 @@ class io extends g {
1392
1392
  ), t;
1393
1393
  }
1394
1394
  }
1395
- const ao = new io();
1396
- class lo extends g {
1395
+ const lo = new ao();
1396
+ class co extends g {
1397
1397
  constructor() {
1398
1398
  super(
1399
1399
  "MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Response",
1400
- [{ no: 1, name: "report", kind: "message", T: () => I }]
1400
+ [{ no: 1, name: "report", kind: "message", T: () => v }]
1401
1401
  );
1402
1402
  }
1403
1403
  create(e) {
@@ -1415,7 +1415,7 @@ class lo extends g {
1415
1415
  switch (i) {
1416
1416
  case /* MiLaboratories.Controller.Shared.ProgressAPI.Report report */
1417
1417
  1:
1418
- r.report = I.internalBinaryRead(
1418
+ r.report = v.internalBinaryRead(
1419
1419
  e,
1420
1420
  e.uint32(),
1421
1421
  o,
@@ -1441,7 +1441,7 @@ class lo extends g {
1441
1441
  return r;
1442
1442
  }
1443
1443
  internalBinaryWrite(e, t, o) {
1444
- e.report && I.internalBinaryWrite(
1444
+ e.report && v.internalBinaryWrite(
1445
1445
  e.report,
1446
1446
  t.tag(1, h.LengthDelimited).fork(),
1447
1447
  o
@@ -1454,7 +1454,7 @@ class lo extends g {
1454
1454
  ), t;
1455
1455
  }
1456
1456
  }
1457
- const co = new lo(), X = new _(
1457
+ const ho = new co(), K = new E(
1458
1458
  "MiLaboratories.Controller.Shared.Progress",
1459
1459
  [
1460
1460
  {
@@ -1462,23 +1462,23 @@ const co = new lo(), X = new _(
1462
1462
  options: {
1463
1463
  "google.api.http": { get: "/resources/{resource_id}/get-progress" }
1464
1464
  },
1465
- I: oo,
1466
- O: ro
1465
+ I: no,
1466
+ O: so
1467
1467
  },
1468
1468
  {
1469
1469
  name: "RealtimeStatus",
1470
1470
  serverStreaming: !0,
1471
1471
  options: {},
1472
- I: ao,
1473
- O: co
1472
+ I: lo,
1473
+ O: ho
1474
1474
  }
1475
1475
  ]
1476
1476
  );
1477
- class ho {
1477
+ class uo {
1478
1478
  constructor(e) {
1479
- d(this, "typeName", X.typeName);
1480
- d(this, "methods", X.methods);
1481
- d(this, "options", X.options);
1479
+ d(this, "typeName", K.typeName);
1480
+ d(this, "methods", K.methods);
1481
+ d(this, "options", K.options);
1482
1482
  this._transport = e;
1483
1483
  }
1484
1484
  /**
@@ -1486,20 +1486,20 @@ class ho {
1486
1486
  */
1487
1487
  getStatus(e, t) {
1488
1488
  const o = this.methods[0], n = this._transport.mergeOptions(t);
1489
- return T("unary", this._transport, o, n, e);
1489
+ return k("unary", this._transport, o, n, e);
1490
1490
  }
1491
1491
  /**
1492
1492
  * @generated from protobuf rpc: RealtimeStatus(MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Request) returns (stream MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Response);
1493
1493
  */
1494
1494
  realtimeStatus(e, t) {
1495
1495
  const o = this.methods[1], n = this._transport.mergeOptions(t);
1496
- return T("serverStreaming", this._transport, o, n, e);
1496
+ return k("serverStreaming", this._transport, o, n, e);
1497
1497
  }
1498
1498
  }
1499
- class uo {
1499
+ class po {
1500
1500
  constructor(e, t, o, n) {
1501
1501
  d(this, "grpcClient");
1502
- this.grpcTransport = e, this.client = o, this.logger = n, this.grpcClient = new ho(this.grpcTransport);
1502
+ this.grpcTransport = e, this.client = o, this.logger = n, this.grpcClient = new uo(this.grpcTransport);
1503
1503
  }
1504
1504
  close() {
1505
1505
  }
@@ -1507,8 +1507,8 @@ class uo {
1507
1507
  async getStatus({ id: e, type: t }, o) {
1508
1508
  const n = await this.grpcClient.getStatus(
1509
1509
  { resourceId: e },
1510
- P(t, o)
1511
- ), r = H(n.response.report);
1510
+ U(t, o)
1511
+ ), r = j(n.response.report);
1512
1512
  return {
1513
1513
  done: r.done,
1514
1514
  progress: r.progress,
@@ -1519,8 +1519,8 @@ class uo {
1519
1519
  // realtimeStatus returns a async generator that takes statuses from
1520
1520
  // GRPC stream every updateIntervalMs milliseconds.
1521
1521
  async *realtimeStatus({ id: e, type: t }, o = 100, n) {
1522
- n = P(t, n);
1523
- const r = Math.floor(o / 1e3), a = (o - r * 1e3) * 1e6, i = z.create({
1522
+ n = U(t, n);
1523
+ const r = Math.floor(o / 1e3), a = (o - r * 1e3) * 1e6, i = x.create({
1524
1524
  seconds: BigInt(r),
1525
1525
  nanos: a
1526
1526
  });
@@ -1538,37 +1538,37 @@ class uo {
1538
1538
  }
1539
1539
  }
1540
1540
  }
1541
- class V extends Error {
1541
+ class q extends Error {
1542
1542
  }
1543
- class je {
1543
+ class Ge {
1544
1544
  constructor(e) {
1545
1545
  this.httpClient = e;
1546
1546
  }
1547
1547
  async download(e, t, o) {
1548
- const { statusCode: n, body: r, headers: a } = await $e(e, {
1548
+ const { statusCode: n, body: r, headers: a } = await Be(e, {
1549
1549
  dispatcher: this.httpClient,
1550
1550
  headers: t,
1551
1551
  signal: o
1552
- }), i = ye.toWeb(r);
1553
- return await po(n, i, e), {
1552
+ }), i = be.toWeb(r);
1553
+ return await go(n, i, e), {
1554
1554
  content: i,
1555
1555
  size: Number(a["content-length"])
1556
1556
  };
1557
1557
  }
1558
1558
  }
1559
- async function po(s, e, t) {
1559
+ async function go(s, e, t) {
1560
1560
  if (s != 200 && s != 206) {
1561
- const o = (await pt(e)).substring(0, 1e3);
1562
- throw 400 <= s && s < 500 ? new V(
1561
+ const o = (await gt(e)).substring(0, 1e3);
1562
+ throw 400 <= s && s < 500 ? new q(
1563
1563
  `Http error: statusCode: ${s} url: ${t.toString()}, beginning of body: ${o}`
1564
1564
  ) : new Error(`Http error: statusCode: ${s} url: ${t.toString()}`);
1565
1565
  }
1566
1566
  }
1567
- function C(s) {
1568
- if (!L.isAbsolute(s)) throw new Error(`Path ${s} is not absolute.`);
1567
+ function _(s) {
1568
+ if (!P.isAbsolute(s)) throw new Error(`Path ${s} is not absolute.`);
1569
1569
  return s;
1570
1570
  }
1571
- class go extends g {
1571
+ class fo extends g {
1572
1572
  constructor() {
1573
1573
  super("MiLaboratories.Controller.Shared.DownloadAPI", []);
1574
1574
  }
@@ -1588,8 +1588,8 @@ class go extends g {
1588
1588
  ), t;
1589
1589
  }
1590
1590
  }
1591
- new go();
1592
- class fo extends g {
1591
+ new fo();
1592
+ class mo extends g {
1593
1593
  constructor() {
1594
1594
  super("MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL", []);
1595
1595
  }
@@ -1609,8 +1609,8 @@ class fo extends g {
1609
1609
  ), t;
1610
1610
  }
1611
1611
  }
1612
- new fo();
1613
- class mo extends g {
1612
+ new mo();
1613
+ class wo extends g {
1614
1614
  constructor() {
1615
1615
  super(
1616
1616
  "MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.Request",
@@ -1671,8 +1671,8 @@ class mo extends g {
1671
1671
  ), t;
1672
1672
  }
1673
1673
  }
1674
- const wo = new mo();
1675
- class yo extends g {
1674
+ const yo = new wo();
1675
+ class bo extends g {
1676
1676
  constructor() {
1677
1677
  super(
1678
1678
  "MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.HTTPHeader",
@@ -1745,8 +1745,8 @@ class yo extends g {
1745
1745
  ), t;
1746
1746
  }
1747
1747
  }
1748
- const K = new yo();
1749
- class bo extends g {
1748
+ const Y = new bo();
1749
+ class To extends g {
1750
1750
  constructor() {
1751
1751
  super(
1752
1752
  "MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.Response",
@@ -1763,7 +1763,7 @@ class bo extends g {
1763
1763
  name: "headers",
1764
1764
  kind: "message",
1765
1765
  repeat: 1,
1766
- T: () => K
1766
+ T: () => Y
1767
1767
  }
1768
1768
  ]
1769
1769
  );
@@ -1788,7 +1788,7 @@ class bo extends g {
1788
1788
  case /* repeated MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.HTTPHeader headers */
1789
1789
  2:
1790
1790
  r.headers.push(
1791
- K.internalBinaryRead(
1791
+ Y.internalBinaryRead(
1792
1792
  e,
1793
1793
  e.uint32(),
1794
1794
  o
@@ -1816,7 +1816,7 @@ class bo extends g {
1816
1816
  internalBinaryWrite(e, t, o) {
1817
1817
  e.downloadUrl !== "" && t.tag(1, h.LengthDelimited).string(e.downloadUrl);
1818
1818
  for (let r = 0; r < e.headers.length; r++)
1819
- K.internalBinaryWrite(
1819
+ Y.internalBinaryWrite(
1820
1820
  e.headers[r],
1821
1821
  t.tag(2, h.LengthDelimited).fork(),
1822
1822
  o
@@ -1829,7 +1829,7 @@ class bo extends g {
1829
1829
  ), t;
1830
1830
  }
1831
1831
  }
1832
- const To = new bo(), Y = new _(
1832
+ const ko = new To(), ee = new E(
1833
1833
  "MiLaboratories.Controller.Shared.Download",
1834
1834
  [
1835
1835
  {
@@ -1837,16 +1837,16 @@ const To = new bo(), Y = new _(
1837
1837
  options: {
1838
1838
  "google.api.http": { get: "/resources/{resource_id}/get-download-url" }
1839
1839
  },
1840
- I: wo,
1841
- O: To
1840
+ I: yo,
1841
+ O: ko
1842
1842
  }
1843
1843
  ]
1844
1844
  );
1845
- class ko {
1845
+ class Lo {
1846
1846
  constructor(e) {
1847
- d(this, "typeName", Y.typeName);
1848
- d(this, "methods", Y.methods);
1849
- d(this, "options", Y.options);
1847
+ d(this, "typeName", ee.typeName);
1848
+ d(this, "methods", ee.methods);
1849
+ d(this, "options", ee.options);
1850
1850
  this._transport = e;
1851
1851
  }
1852
1852
  /**
@@ -1854,29 +1854,29 @@ class ko {
1854
1854
  */
1855
1855
  getDownloadURL(e, t) {
1856
1856
  const o = this.methods[0], n = this._transport.mergeOptions(t);
1857
- return T("unary", this._transport, o, n, e);
1857
+ return k("unary", this._transport, o, n, e);
1858
1858
  }
1859
1859
  }
1860
- class Lo {
1860
+ class Po {
1861
1861
  constructor(e, t, o, n) {
1862
1862
  d(this, "grpcClient");
1863
1863
  d(this, "remoteFileDownloader");
1864
1864
  /** Helps to find a storage root directory by a storage id from URL scheme. */
1865
1865
  d(this, "localStorageIdsToRoot");
1866
- this.grpcTransport = e, this.httpClient = t, this.logger = o, this.grpcClient = new ko(this.grpcTransport), this.remoteFileDownloader = new je(t), this.localStorageIdsToRoot = So(n);
1866
+ this.grpcTransport = e, this.httpClient = t, this.logger = o, this.grpcClient = new Lo(this.grpcTransport), this.remoteFileDownloader = new Ge(t), this.localStorageIdsToRoot = Io(n);
1867
1867
  }
1868
1868
  close() {
1869
1869
  }
1870
1870
  /** Gets a presign URL and downloads the file.
1871
1871
  * An optional range with 2 numbers from what byte and to what byte to download can be provided. */
1872
1872
  async downloadBlob(e, t, o, n, r) {
1873
- const { downloadUrl: a, headers: i } = await this.grpcGetDownloadUrl(e, t, o), c = ze(i, n, r);
1874
- return this.logger.info(`download blob from url ${a}, headers: ${JSON.stringify(c)}`), Ro(a) ? await this.readLocalFile(a, n, r) : await this.remoteFileDownloader.download(a, c, o);
1873
+ const { downloadUrl: a, headers: i } = await this.grpcGetDownloadUrl(e, t, o), c = xe(i, n, r);
1874
+ return this.logger.info(`download blob from url ${a}, headers: ${JSON.stringify(c)}`), So(a) ? await this.readLocalFile(a, n, r) : await this.remoteFileDownloader.download(a, c, o);
1875
1875
  }
1876
1876
  async readLocalFile(e, t, o) {
1877
- const { storageId: n, relativePath: r } = Po(e), a = Uo(n, this.localStorageIdsToRoot, r);
1877
+ const { storageId: n, relativePath: r } = Uo(e), a = Do(n, this.localStorageIdsToRoot, r);
1878
1878
  return {
1879
- content: ye.toWeb(we.createReadStream(a, { start: t, end: o })),
1879
+ content: be.toWeb(ye.createReadStream(a, { start: t, end: o })),
1880
1880
  size: (await m.stat(a)).size
1881
1881
  };
1882
1882
  }
@@ -1884,39 +1884,39 @@ class Lo {
1884
1884
  const r = o ?? {};
1885
1885
  return r.abort = n, await this.grpcClient.getDownloadURL(
1886
1886
  { resourceId: e },
1887
- P(t, r)
1887
+ U(t, r)
1888
1888
  ).response;
1889
1889
  }
1890
1890
  }
1891
- function Po(s) {
1891
+ function Uo(s) {
1892
1892
  const e = new URL(s);
1893
1893
  if (e.pathname == "")
1894
- throw new be(`url for local filepath ${s} does not match url scheme`);
1894
+ throw new Te(`url for local filepath ${s} does not match url scheme`);
1895
1895
  return {
1896
1896
  storageId: e.host,
1897
1897
  relativePath: decodeURIComponent(e.pathname.slice(1))
1898
1898
  };
1899
1899
  }
1900
- function Uo(s, e, t) {
1900
+ function Do(s, e, t) {
1901
1901
  const o = e.get(s);
1902
- if (o === void 0) throw new Te(`Unknown storage location: ${s}`);
1903
- return o === "" ? t : b.join(o, t);
1904
- }
1905
- const Do = "storage://";
1906
- function Ro(s) {
1907
- return s.startsWith(Do);
1902
+ if (o === void 0) throw new ke(`Unknown storage location: ${s}`);
1903
+ return o === "" ? t : T.join(o, t);
1908
1904
  }
1909
- class be extends Error {
1905
+ const Ro = "storage://";
1906
+ function So(s) {
1907
+ return s.startsWith(Ro);
1910
1908
  }
1911
1909
  class Te extends Error {
1912
1910
  }
1913
- function So(s) {
1911
+ class ke extends Error {
1912
+ }
1913
+ function Io(s) {
1914
1914
  const e = /* @__PURE__ */ new Map();
1915
1915
  for (const t of s)
1916
- t.localPath !== "" && C(t.localPath), e.set(t.storageId, t.localPath);
1916
+ t.localPath !== "" && _(t.localPath), e.set(t.storageId, t.localPath);
1917
1917
  return e;
1918
1918
  }
1919
- class Io extends g {
1919
+ class vo extends g {
1920
1920
  constructor() {
1921
1921
  super("google.protobuf.Timestamp", [
1922
1922
  {
@@ -1941,14 +1941,14 @@ class Io extends g {
1941
1941
  */
1942
1942
  now() {
1943
1943
  const e = this.create(), t = Date.now();
1944
- return e.seconds = D.from(Math.floor(t / 1e3)).toBigInt(), e.nanos = t % 1e3 * 1e6, e;
1944
+ return e.seconds = R.from(Math.floor(t / 1e3)).toBigInt(), e.nanos = t % 1e3 * 1e6, e;
1945
1945
  }
1946
1946
  /**
1947
1947
  * Converts a `Timestamp` to a JavaScript Date.
1948
1948
  */
1949
1949
  toDate(e) {
1950
1950
  return new Date(
1951
- D.from(e.seconds).toNumber() * 1e3 + Math.ceil(e.nanos / 1e6)
1951
+ R.from(e.seconds).toNumber() * 1e3 + Math.ceil(e.nanos / 1e6)
1952
1952
  );
1953
1953
  }
1954
1954
  /**
@@ -1956,14 +1956,14 @@ class Io extends g {
1956
1956
  */
1957
1957
  fromDate(e) {
1958
1958
  const t = this.create(), o = e.getTime();
1959
- return t.seconds = D.from(Math.floor(o / 1e3)).toBigInt(), t.nanos = o % 1e3 * 1e6, t;
1959
+ return t.seconds = R.from(Math.floor(o / 1e3)).toBigInt(), t.nanos = o % 1e3 * 1e6, t;
1960
1960
  }
1961
1961
  /**
1962
1962
  * In JSON format, the `Timestamp` type is encoded as a string
1963
1963
  * in the RFC 3339 format.
1964
1964
  */
1965
1965
  internalJsonWrite(e, t) {
1966
- const o = D.from(e.seconds).toNumber() * 1e3;
1966
+ const o = R.from(e.seconds).toNumber() * 1e3;
1967
1967
  if (o < Date.parse("0001-01-01T00:00:00Z") || o > Date.parse("9999-12-31T23:59:59Z"))
1968
1968
  throw new Error(
1969
1969
  "Unable to encode Timestamp to JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive."
@@ -1986,7 +1986,7 @@ class Io extends g {
1986
1986
  internalJsonRead(e, t, o) {
1987
1987
  if (typeof e != "string")
1988
1988
  throw new Error(
1989
- "Unable to parse Timestamp from JSON " + Be(e) + "."
1989
+ "Unable to parse Timestamp from JSON " + Ce(e) + "."
1990
1990
  );
1991
1991
  const n = e.match(
1992
1992
  /^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/
@@ -2002,7 +2002,7 @@ class Io extends g {
2002
2002
  throw new globalThis.Error(
2003
2003
  "Unable to parse Timestamp from JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive."
2004
2004
  );
2005
- return o || (o = this.create()), o.seconds = D.from(r / 1e3).toBigInt(), o.nanos = 0, n[7] && (o.nanos = parseInt("1" + n[7] + "0".repeat(9 - n[7].length)) - 1e9), o;
2005
+ return o || (o = this.create()), o.seconds = R.from(r / 1e3).toBigInt(), o.nanos = 0, n[7] && (o.nanos = parseInt("1" + n[7] + "0".repeat(9 - n[7].length)) - 1e9), o;
2006
2006
  }
2007
2007
  create(e) {
2008
2008
  const t = globalThis.Object.create(this.messagePrototype);
@@ -2049,8 +2049,8 @@ class Io extends g {
2049
2049
  ), t;
2050
2050
  }
2051
2051
  }
2052
- const ee = new Io();
2053
- class vo extends g {
2052
+ const te = new vo();
2053
+ class No extends g {
2054
2054
  constructor() {
2055
2055
  super("MiLaboratories.Controller.Shared.LsAPI", []);
2056
2056
  }
@@ -2070,8 +2070,8 @@ class vo extends g {
2070
2070
  ), t;
2071
2071
  }
2072
2072
  }
2073
- new vo();
2074
- class No extends g {
2073
+ new No();
2074
+ class $o extends g {
2075
2075
  constructor() {
2076
2076
  super("MiLaboratories.Controller.Shared.LsAPI.ListItem", [
2077
2077
  {
@@ -2110,7 +2110,7 @@ class No extends g {
2110
2110
  T: 9
2111
2111
  /* ScalarType.STRING */
2112
2112
  },
2113
- { no: 12, name: "last_modified", kind: "message", T: () => ee },
2113
+ { no: 12, name: "last_modified", kind: "message", T: () => te },
2114
2114
  {
2115
2115
  no: 13,
2116
2116
  name: "version",
@@ -2151,7 +2151,7 @@ class No extends g {
2151
2151
  break;
2152
2152
  case /* google.protobuf.Timestamp last_modified */
2153
2153
  12:
2154
- r.lastModified = ee.internalBinaryRead(
2154
+ r.lastModified = te.internalBinaryRead(
2155
2155
  e,
2156
2156
  e.uint32(),
2157
2157
  o,
@@ -2181,7 +2181,7 @@ class No extends g {
2181
2181
  return r;
2182
2182
  }
2183
2183
  internalBinaryWrite(e, t, o) {
2184
- e.name !== "" && t.tag(1, h.LengthDelimited).string(e.name), e.size !== 0n && t.tag(2, h.Varint).uint64(e.size), e.isDir !== !1 && t.tag(3, h.Varint).bool(e.isDir), e.fullName !== "" && t.tag(10, h.LengthDelimited).string(e.fullName), e.directory !== "" && t.tag(11, h.LengthDelimited).string(e.directory), e.lastModified && ee.internalBinaryWrite(
2184
+ e.name !== "" && t.tag(1, h.LengthDelimited).string(e.name), e.size !== 0n && t.tag(2, h.Varint).uint64(e.size), e.isDir !== !1 && t.tag(3, h.Varint).bool(e.isDir), e.fullName !== "" && t.tag(10, h.LengthDelimited).string(e.fullName), e.directory !== "" && t.tag(11, h.LengthDelimited).string(e.directory), e.lastModified && te.internalBinaryWrite(
2185
2185
  e.lastModified,
2186
2186
  t.tag(12, h.LengthDelimited).fork(),
2187
2187
  o
@@ -2194,8 +2194,8 @@ class No extends g {
2194
2194
  ), t;
2195
2195
  }
2196
2196
  }
2197
- const te = new No();
2198
- class $o extends g {
2197
+ const oe = new $o();
2198
+ class Bo extends g {
2199
2199
  constructor() {
2200
2200
  super("MiLaboratories.Controller.Shared.LsAPI.List", []);
2201
2201
  }
@@ -2215,8 +2215,8 @@ class $o extends g {
2215
2215
  ), t;
2216
2216
  }
2217
2217
  }
2218
- new $o();
2219
- class Bo extends g {
2218
+ new Bo();
2219
+ class Co extends g {
2220
2220
  constructor() {
2221
2221
  super("MiLaboratories.Controller.Shared.LsAPI.List.Request", [
2222
2222
  {
@@ -2281,8 +2281,8 @@ class Bo extends g {
2281
2281
  ), t;
2282
2282
  }
2283
2283
  }
2284
- const Co = new Bo();
2285
- class _o extends g {
2284
+ const _o = new Co();
2285
+ class Eo extends g {
2286
2286
  constructor() {
2287
2287
  super("MiLaboratories.Controller.Shared.LsAPI.List.Response", [
2288
2288
  {
@@ -2290,7 +2290,7 @@ class _o extends g {
2290
2290
  name: "items",
2291
2291
  kind: "message",
2292
2292
  repeat: 1,
2293
- T: () => te
2293
+ T: () => oe
2294
2294
  },
2295
2295
  {
2296
2296
  no: 2,
@@ -2313,7 +2313,7 @@ class _o extends g {
2313
2313
  case /* repeated MiLaboratories.Controller.Shared.LsAPI.ListItem items */
2314
2314
  1:
2315
2315
  r.items.push(
2316
- te.internalBinaryRead(e, e.uint32(), o)
2316
+ oe.internalBinaryRead(e, e.uint32(), o)
2317
2317
  );
2318
2318
  break;
2319
2319
  case /* string delimiter */
@@ -2340,7 +2340,7 @@ class _o extends g {
2340
2340
  }
2341
2341
  internalBinaryWrite(e, t, o) {
2342
2342
  for (let r = 0; r < e.items.length; r++)
2343
- te.internalBinaryWrite(
2343
+ oe.internalBinaryWrite(
2344
2344
  e.items[r],
2345
2345
  t.tag(1, h.LengthDelimited).fork(),
2346
2346
  o
@@ -2354,14 +2354,14 @@ class _o extends g {
2354
2354
  ), t;
2355
2355
  }
2356
2356
  }
2357
- const Eo = new _o(), oe = new _("MiLaboratories.Controller.Shared.LS", [
2358
- { name: "List", options: {}, I: Co, O: Eo }
2357
+ const Oo = new Eo(), ne = new E("MiLaboratories.Controller.Shared.LS", [
2358
+ { name: "List", options: {}, I: _o, O: Oo }
2359
2359
  ]);
2360
- class Oo {
2360
+ class Fo {
2361
2361
  constructor(e) {
2362
- d(this, "typeName", oe.typeName);
2363
- d(this, "methods", oe.methods);
2364
- d(this, "options", oe.options);
2362
+ d(this, "typeName", ne.typeName);
2363
+ d(this, "methods", ne.methods);
2364
+ d(this, "options", ne.options);
2365
2365
  this._transport = e;
2366
2366
  }
2367
2367
  /**
@@ -2369,7 +2369,7 @@ class Oo {
2369
2369
  */
2370
2370
  list(e, t) {
2371
2371
  const o = this.methods[0], n = this._transport.mergeOptions(t);
2372
- return T(
2372
+ return k(
2373
2373
  "unary",
2374
2374
  this._transport,
2375
2375
  o,
@@ -2378,10 +2378,10 @@ class Oo {
2378
2378
  );
2379
2379
  }
2380
2380
  }
2381
- class Fo {
2381
+ class Wo {
2382
2382
  constructor(e, t) {
2383
2383
  d(this, "grpcClient");
2384
- this.logger = t, this.grpcClient = new Oo(e);
2384
+ this.logger = t, this.grpcClient = new Fo(e);
2385
2385
  }
2386
2386
  close() {
2387
2387
  }
@@ -2391,11 +2391,11 @@ class Fo {
2391
2391
  resourceId: e.id,
2392
2392
  location: t
2393
2393
  },
2394
- P(e.type, o)
2394
+ U(e.type, o)
2395
2395
  ).response;
2396
2396
  }
2397
2397
  }
2398
- class Wo extends g {
2398
+ class zo extends g {
2399
2399
  constructor() {
2400
2400
  super("MiLaboratories.Controller.Shared.StreamingAPI", []);
2401
2401
  }
@@ -2415,8 +2415,8 @@ class Wo extends g {
2415
2415
  ), t;
2416
2416
  }
2417
2417
  }
2418
- new Wo();
2419
- class zo extends g {
2418
+ new zo();
2419
+ class xo extends g {
2420
2420
  constructor() {
2421
2421
  super("MiLaboratories.Controller.Shared.StreamingAPI.StreamBinary", [
2422
2422
  {
@@ -2507,8 +2507,8 @@ class zo extends g {
2507
2507
  ), t;
2508
2508
  }
2509
2509
  }
2510
- const xo = new zo();
2511
- class Ao extends g {
2510
+ const Ao = new xo();
2511
+ class Mo extends g {
2512
2512
  constructor() {
2513
2513
  super("MiLaboratories.Controller.Shared.StreamingAPI.ReadBinary", [
2514
2514
  {
@@ -2586,8 +2586,8 @@ class Ao extends g {
2586
2586
  ), t;
2587
2587
  }
2588
2588
  }
2589
- const Mo = new Ao();
2590
- class Ho extends g {
2589
+ const Ho = new Mo();
2590
+ class jo extends g {
2591
2591
  constructor() {
2592
2592
  super("MiLaboratories.Controller.Shared.StreamingAPI.StreamText", [
2593
2593
  {
@@ -2690,8 +2690,8 @@ class Ho extends g {
2690
2690
  ), t;
2691
2691
  }
2692
2692
  }
2693
- const jo = new Ho();
2694
- class Go extends g {
2693
+ const Go = new jo();
2694
+ class Vo extends g {
2695
2695
  constructor() {
2696
2696
  super("MiLaboratories.Controller.Shared.StreamingAPI.ReadText", [
2697
2697
  {
@@ -2794,8 +2794,8 @@ class Go extends g {
2794
2794
  ), t;
2795
2795
  }
2796
2796
  }
2797
- const Vo = new Go();
2798
- class qo extends g {
2797
+ const qo = new Vo();
2798
+ class Jo extends g {
2799
2799
  constructor() {
2800
2800
  super("MiLaboratories.Controller.Shared.StreamingAPI.LastLines", [
2801
2801
  {
@@ -2898,8 +2898,8 @@ class qo extends g {
2898
2898
  ), t;
2899
2899
  }
2900
2900
  }
2901
- const Jo = new qo();
2902
- class Zo extends g {
2901
+ const Zo = new Jo();
2902
+ class Qo extends g {
2903
2903
  constructor() {
2904
2904
  super("MiLaboratories.Controller.Shared.StreamingAPI.Response", [
2905
2905
  {
@@ -2976,48 +2976,48 @@ class Zo extends g {
2976
2976
  ), t;
2977
2977
  }
2978
2978
  }
2979
- const $ = new Zo(), ne = new _(
2979
+ const B = new Qo(), re = new E(
2980
2980
  "MiLaboratories.Controller.Shared.Streaming",
2981
2981
  [
2982
2982
  {
2983
2983
  name: "StreamBinary",
2984
2984
  serverStreaming: !0,
2985
2985
  options: {},
2986
- I: xo,
2987
- O: $
2986
+ I: Ao,
2987
+ O: B
2988
2988
  },
2989
2989
  {
2990
2990
  name: "ReadBinary",
2991
2991
  options: {},
2992
- I: Mo,
2993
- O: $
2992
+ I: Ho,
2993
+ O: B
2994
2994
  },
2995
2995
  {
2996
2996
  name: "StreamText",
2997
2997
  serverStreaming: !0,
2998
2998
  options: {},
2999
- I: jo,
3000
- O: $
2999
+ I: Go,
3000
+ O: B
3001
3001
  },
3002
3002
  {
3003
3003
  name: "ReadText",
3004
3004
  options: {},
3005
- I: Vo,
3006
- O: $
3005
+ I: qo,
3006
+ O: B
3007
3007
  },
3008
3008
  {
3009
3009
  name: "LastLines",
3010
3010
  options: {},
3011
- I: Jo,
3012
- O: $
3011
+ I: Zo,
3012
+ O: B
3013
3013
  }
3014
3014
  ]
3015
3015
  );
3016
- class Qo {
3016
+ class Xo {
3017
3017
  constructor(e) {
3018
- d(this, "typeName", ne.typeName);
3019
- d(this, "methods", ne.methods);
3020
- d(this, "options", ne.options);
3018
+ d(this, "typeName", re.typeName);
3019
+ d(this, "methods", re.methods);
3020
+ d(this, "options", re.options);
3021
3021
  this._transport = e;
3022
3022
  }
3023
3023
  /**
@@ -3029,7 +3029,7 @@ class Qo {
3029
3029
  */
3030
3030
  streamBinary(e, t) {
3031
3031
  const o = this.methods[0], n = this._transport.mergeOptions(t);
3032
- return T(
3032
+ return k(
3033
3033
  "serverStreaming",
3034
3034
  this._transport,
3035
3035
  o,
@@ -3047,7 +3047,7 @@ class Qo {
3047
3047
  */
3048
3048
  readBinary(e, t) {
3049
3049
  const o = this.methods[1], n = this._transport.mergeOptions(t);
3050
- return T(
3050
+ return k(
3051
3051
  "unary",
3052
3052
  this._transport,
3053
3053
  o,
@@ -3063,7 +3063,7 @@ class Qo {
3063
3063
  */
3064
3064
  streamText(e, t) {
3065
3065
  const o = this.methods[2], n = this._transport.mergeOptions(t);
3066
- return T(
3066
+ return k(
3067
3067
  "serverStreaming",
3068
3068
  this._transport,
3069
3069
  o,
@@ -3081,7 +3081,7 @@ class Qo {
3081
3081
  */
3082
3082
  readText(e, t) {
3083
3083
  const o = this.methods[3], n = this._transport.mergeOptions(t);
3084
- return T(
3084
+ return k(
3085
3085
  "unary",
3086
3086
  this._transport,
3087
3087
  o,
@@ -3103,7 +3103,7 @@ class Qo {
3103
3103
  */
3104
3104
  lastLines(e, t) {
3105
3105
  const o = this.methods[4], n = this._transport.mergeOptions(t);
3106
- return T(
3106
+ return k(
3107
3107
  "unary",
3108
3108
  this._transport,
3109
3109
  o,
@@ -3112,10 +3112,10 @@ class Qo {
3112
3112
  );
3113
3113
  }
3114
3114
  }
3115
- class Xo {
3115
+ class Ko {
3116
3116
  constructor(e, t, o) {
3117
3117
  d(this, "grpcClient");
3118
- this.grpcTransport = e, this.httpClient = t, this.logger = o, this.grpcClient = new Qo(this.grpcTransport);
3118
+ this.grpcTransport = e, this.httpClient = t, this.logger = o, this.grpcClient = new Xo(this.grpcTransport);
3119
3119
  }
3120
3120
  close() {
3121
3121
  }
@@ -3130,7 +3130,7 @@ class Xo {
3130
3130
  offset: n,
3131
3131
  search: r
3132
3132
  },
3133
- P(t, a)
3133
+ U(t, a)
3134
3134
  )).response;
3135
3135
  }
3136
3136
  /** Reads the file forward and returns the text,
@@ -3139,49 +3139,49 @@ class Xo {
3139
3139
  async readText({ id: e, type: t }, o, n = 0n, r, a) {
3140
3140
  return (await this.grpcClient.readText(
3141
3141
  {
3142
- resourceId: H(e),
3142
+ resourceId: j(e),
3143
3143
  readLimit: BigInt(o),
3144
3144
  offset: n,
3145
3145
  search: r
3146
3146
  },
3147
- P(t, a)
3147
+ U(t, a)
3148
3148
  )).response;
3149
3149
  }
3150
3150
  }
3151
- function Tr(s, e, t) {
3151
+ function kr(s, e, t) {
3152
3152
  return e.getDriver({
3153
3153
  name: "DownloadBlob",
3154
- init: (o, n, r) => new Lo(n, r, s, t)
3154
+ init: (o, n, r) => new Po(n, r, s, t)
3155
3155
  });
3156
3156
  }
3157
- function kr(s, e) {
3157
+ function Lr(s, e) {
3158
3158
  return s.getDriver({
3159
3159
  name: "StreamLogs",
3160
- init: (t, o, n) => new Xo(o, n, e)
3160
+ init: (t, o, n) => new Ko(o, n, e)
3161
3161
  });
3162
3162
  }
3163
- function Lr(s, e) {
3163
+ function Pr(s, e) {
3164
3164
  return s.getDriver({
3165
3165
  name: "UploadProgress",
3166
- init: (t, o, n) => new uo(o, n, s, e)
3166
+ init: (t, o, n) => new po(o, n, s, e)
3167
3167
  });
3168
3168
  }
3169
- function Pr(s, e) {
3169
+ function Ur(s, e) {
3170
3170
  return s.getDriver({
3171
3171
  name: "UploadBlob",
3172
- init: (t, o, n) => new Vt(o, n, s, e)
3172
+ init: (t, o, n) => new qt(o, n, s, e)
3173
3173
  });
3174
3174
  }
3175
- function Ko(s, e) {
3175
+ function Yo(s, e) {
3176
3176
  return s.getDriver({
3177
3177
  name: "LsFiles",
3178
- init: (t, o, n) => new Fo(o, e)
3178
+ init: (t, o, n) => new Wo(o, e)
3179
3179
  });
3180
3180
  }
3181
- class Yo {
3181
+ class en {
3182
3182
  constructor(e, t, o, n, r) {
3183
- d(this, "counter", new v());
3184
- d(this, "change", new N());
3183
+ d(this, "counter", new N());
3184
+ d(this, "change", new $());
3185
3185
  d(this, "signalCtl", new AbortController());
3186
3186
  d(this, "error");
3187
3187
  d(this, "done", !1);
@@ -3207,20 +3207,20 @@ class Yo {
3207
3207
  const e = await this.ensureDownloaded();
3208
3208
  this.setDone(e), this.change.markChanged();
3209
3209
  } catch (e) {
3210
- throw ke(e) && (this.setError(e), this.change.markChanged(), await m.rm(this.path)), e;
3210
+ throw Le(e) && (this.setError(e), this.change.markChanged(), await m.rm(this.path)), e;
3211
3211
  }
3212
3212
  }
3213
3213
  async ensureDownloaded() {
3214
- if (await pe(b.dirname(this.path)), await ge(this.path))
3214
+ if (await ge(T.dirname(this.path)), await fe(this.path))
3215
3215
  return this.logger.info(`a blob was already downloaded: ${this.path}`), (await m.stat(this.path)).size;
3216
3216
  const { content: e, size: t } = await this.clientDownload.downloadBlob(this.rInfo);
3217
- return await fe(this.logger, this.path, async (o) => {
3218
- const n = S.toWeb(ae.createWriteStream(o, { flags: "wx" }));
3217
+ return await me(this.logger, this.path, async (o) => {
3218
+ const n = I.toWeb(le.createWriteStream(o, { flags: "wx" }));
3219
3219
  await e.pipeTo(n);
3220
3220
  }), t;
3221
3221
  }
3222
3222
  abort(e) {
3223
- this.signalCtl.abort(new Ge(e));
3223
+ this.signalCtl.abort(new Ve(e));
3224
3224
  }
3225
3225
  getBlob() {
3226
3226
  return this.done ? this.error ? {
@@ -3244,12 +3244,12 @@ class Yo {
3244
3244
  this.done = !0, this.error = e;
3245
3245
  }
3246
3246
  }
3247
- function ke(s) {
3248
- return s instanceof Ge || s instanceof V || s instanceof Te || s instanceof be || (s == null ? void 0 : s.code) == "ENOENT" || s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED");
3247
+ function Le(s) {
3248
+ return s instanceof Ve || s instanceof q || s instanceof ke || s instanceof Te || (s == null ? void 0 : s.code) == "ENOENT" || s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED");
3249
3249
  }
3250
- class Ge extends Error {
3250
+ class Ve extends Error {
3251
3251
  }
3252
- class Le {
3252
+ class Pe {
3253
3253
  constructor(e) {
3254
3254
  d(this, "cache", /* @__PURE__ */ new Map());
3255
3255
  d(this, "totalSizeBytes", 0);
@@ -3265,124 +3265,126 @@ class Le {
3265
3265
  /** Decrements a counter in a cache and if we exceeds
3266
3266
  * a soft limit, removes files with zero counters. */
3267
3267
  removeFile(e, t) {
3268
- return Ue(this.cache, e).counter.dec(t), this.toDelete();
3268
+ return De(this.cache, e).counter.dec(t), this.toDelete();
3269
3269
  }
3270
3270
  /** Returns what results should be deleted to comply with the soft limit. */
3271
3271
  toDelete() {
3272
3272
  if (this.totalSizeBytes <= this.softSizeBytes) return [];
3273
3273
  const e = [];
3274
3274
  let t = 0;
3275
- return ht(this.cache).filter(([o, n]) => n.counter.isZero()).forEach(([o, n]) => {
3276
- if (this.totalSizeBytes - t <= this.softSizeBytes) return;
3277
- const r = Ue(this.cache, o);
3275
+ return ut(this.cache).filter(([o, n]) => n.counter.isZero()).forEach(([o, n]) => {
3276
+ if (this.totalSizeBytes - t <= this.softSizeBytes)
3277
+ return;
3278
+ const r = De(this.cache, o);
3278
3279
  t += r.size, e.push(r);
3279
3280
  }), e;
3280
3281
  }
3281
3282
  addCache(e, t) {
3282
3283
  const o = this.cache.get(e.path) == null;
3283
- if (this.cache.set(e.path, e), e.counter.inc(t), e.size < 0) throw new Error(`empty sizeBytes: ${e}`);
3284
+ if (this.cache.set(e.path, e), e.counter.inc(t), e.size < 0)
3285
+ throw new Error(`empty sizeBytes: ${e}`);
3284
3286
  o && (this.totalSizeBytes += e.size);
3285
3287
  }
3286
3288
  removeCache(e) {
3287
3289
  this.cache.delete(e.path), this.totalSizeBytes -= e.size;
3288
3290
  }
3289
3291
  }
3290
- const Ve = /^blob\+local:\/\/download\/(?<path>.*)#(?<signature>.*)$/;
3291
- function en(s, e) {
3292
+ const qe = /^blob\+local:\/\/download\/(?<path>.*)#(?<signature>.*)$/;
3293
+ function tn(s, e) {
3292
3294
  return `blob+local://download/${s}#${e.sign(s)}`;
3293
3295
  }
3294
- function tn(s) {
3295
- return !!s.match(Ve);
3296
+ function on(s) {
3297
+ return !!s.match(qe);
3296
3298
  }
3297
- function re(s, e) {
3298
- const t = s.match(Ve);
3299
+ function se(s, e) {
3300
+ const t = s.match(qe);
3299
3301
  if (t === null)
3300
3302
  throw new Error(`Local handle is malformed: ${s}, matches: ${t}`);
3301
3303
  const { path: o, signature: n } = t.groups;
3302
3304
  return e.verify(o, n, `Signature verification failed for: ${s}`), { path: o, signature: n };
3303
3305
  }
3304
- const on = G({
3306
+ const nn = V({
3305
3307
  kv: {
3306
- "ctl/file/blobInfo": k.object({
3307
- sizeBytes: k.coerce.number()
3308
+ "ctl/file/blobInfo": L.object({
3309
+ sizeBytes: L.coerce.number()
3308
3310
  })
3309
3311
  }
3310
3312
  });
3311
- function nn(s) {
3313
+ function rn(s) {
3312
3314
  return s.kv["ctl/file/blobInfo"].sizeBytes;
3313
3315
  }
3314
- const q = k.object({
3316
+ const J = L.object({
3315
3317
  /** Local file path, to take data for upload */
3316
- localPath: k.string(),
3318
+ localPath: L.string(),
3317
3319
  /** Path signature, to check this data was generated by us */
3318
- pathSignature: k.string(),
3320
+ pathSignature: L.string(),
3319
3321
  /** File size in bytes */
3320
- sizeBytes: k.string(),
3322
+ sizeBytes: L.string(),
3321
3323
  /** Modification time unix timestamp in seconds */
3322
- modificationTime: k.string()
3323
- }), qe = k.object({
3324
+ modificationTime: L.string()
3325
+ }), Je = L.object({
3324
3326
  /** Pl storage id */
3325
- storageId: k.string(),
3327
+ storageId: L.string(),
3326
3328
  /** Path inside storage */
3327
- path: k.string()
3328
- }), Ur = k.union([
3329
- q,
3330
- qe
3331
- ]), rn = G({
3332
- data: q,
3329
+ path: L.string()
3330
+ }), Dr = L.union([
3331
+ J,
3332
+ Je
3333
+ ]), sn = V({
3334
+ data: J,
3333
3335
  fields: {
3334
3336
  blob: !1
3335
3337
  }
3336
- }), sn = G({
3338
+ }), an = V({
3337
3339
  fields: {
3338
3340
  incarnation: !1
3339
3341
  }
3340
- }), Je = /^blob\+remote:\/\/download\/(?<content>(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*))#(?<signature>.*)$/;
3341
- function an(s, e) {
3342
+ }), Ze = /^blob\+remote:\/\/download\/(?<content>(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*))#(?<signature>.*)$/;
3343
+ function ln(s, e) {
3342
3344
  const t = `${s.type.name}/${s.type.version}/${BigInt(s.id)}`;
3343
3345
  return `blob+remote://download/${t}#${e.sign(t)}`;
3344
3346
  }
3345
- function ln(s) {
3346
- return !!s.match(Je);
3347
+ function cn(s) {
3348
+ return !!s.match(Ze);
3347
3349
  }
3348
- function cn(s, e) {
3349
- const t = s.match(Je);
3350
+ function dn(s, e) {
3351
+ const t = s.match(Ze);
3350
3352
  if (t === null)
3351
3353
  throw new Error(`Remote handle is malformed: ${s}, matches: ${t}`);
3352
3354
  const { content: o, resourceType: n, resourceVersion: r, resourceId: a, signature: i } = t.groups;
3353
3355
  return e.verify(o, i, `Signature verification failed for ${s}`), {
3354
- id: ue(BigInt(a)),
3356
+ id: pe(BigInt(a)),
3355
3357
  type: { name: n, version: r }
3356
3358
  };
3357
3359
  }
3358
- function Ze(s, e) {
3360
+ function Qe(s, e) {
3359
3361
  return s ? `log+live://log/${e.type.name}/${e.type.version}/${BigInt(e.id)}` : `log+ready://log/${e.type.name}/${e.type.version}/${BigInt(e.id)}`;
3360
3362
  }
3361
- const Qe = /^log\+live:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
3362
- function A(s) {
3363
- return Qe.test(s);
3364
- }
3365
- const Xe = /^log\+ready:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
3366
- function dn(s) {
3363
+ const Xe = /^log\+live:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
3364
+ function M(s) {
3367
3365
  return Xe.test(s);
3368
3366
  }
3369
- function M(s) {
3367
+ const Ke = /^log\+ready:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
3368
+ function hn(s) {
3369
+ return Ke.test(s);
3370
+ }
3371
+ function H(s) {
3370
3372
  let e;
3371
- if (A(s))
3372
- e = s.match(Qe);
3373
- else if (dn(s))
3373
+ if (M(s))
3374
3374
  e = s.match(Xe);
3375
+ else if (hn(s))
3376
+ e = s.match(Ke);
3375
3377
  else throw new Error(`Log handle is malformed: ${s}`);
3376
3378
  if (e == null) throw new Error(`Log handle wasn't parsed: ${s}`);
3377
3379
  const { resourceType: t, resourceVersion: o, resourceId: n } = e.groups;
3378
3380
  return {
3379
- id: ue(BigInt(n)),
3381
+ id: pe(BigInt(n)),
3380
3382
  type: { name: t, version: o }
3381
3383
  };
3382
3384
  }
3383
- class Pe extends Error {
3385
+ class Ue extends Error {
3384
3386
  }
3385
- class hn {
3387
+ class un {
3386
3388
  constructor(e) {
3387
3389
  d(this, "updating");
3388
3390
  this.onUpdate = e;
@@ -3399,9 +3401,9 @@ class hn {
3399
3401
  })());
3400
3402
  }
3401
3403
  }
3402
- class Dr {
3404
+ class Rr {
3403
3405
  constructor(e, t, o, n, r, a) {
3404
- /** Represents a Resource Id to the path of a blob as a map. */
3406
+ /** Represents a unique key to the path of a blob as a map. */
3405
3407
  d(this, "idToDownload", /* @__PURE__ */ new Map());
3406
3408
  /** Writes and removes files to a hard drive and holds a counter for every
3407
3409
  * file that should be kept. */
@@ -3412,41 +3414,42 @@ class Dr {
3412
3414
  d(this, "idToLastLines", /* @__PURE__ */ new Map());
3413
3415
  d(this, "idToProgressLog", /* @__PURE__ */ new Map());
3414
3416
  d(this, "saveDir");
3415
- this.logger = e, this.clientDownload = t, this.clientLogs = o, this.signer = r, this.cache = new Le(a.cacheSoftSizeBytes), this.downloadQueue = new j(this.logger, a.nConcurrentDownloads), this.saveDir = b.resolve(n);
3416
- }
3417
- getDownloadedBlob(e, t) {
3418
- if (t === void 0) return w.make((a) => this.getDownloadedBlob(e, a));
3419
- const o = R(e, t), n = U();
3420
- t.addOnDestroy(() => this.releaseBlob(o.id, n));
3421
- const r = this.getDownloadedBlobNoCtx(t.watcher, o, n);
3422
- return r == null && t.markUnstable("download blob is still undefined"), r;
3423
- }
3424
- getDownloadedBlobNoCtx(e, t, o) {
3425
- B("getDownloadedBlob", t.type);
3426
- let n = this.idToDownload.get(t.id);
3427
- if (n === void 0) {
3428
- const a = this.setNewDownloadTask(t);
3417
+ this.logger = e, this.clientDownload = t, this.clientLogs = o, this.signer = r, this.cache = new Pe(a.cacheSoftSizeBytes), this.downloadQueue = new G(this.logger, a.nConcurrentDownloads), this.saveDir = T.resolve(n);
3418
+ }
3419
+ getDownloadedBlob(e, t, o, n) {
3420
+ if (t === void 0)
3421
+ return y.make((l) => this.getDownloadedBlob(e, l, o, n));
3422
+ const r = S(e, t), a = w(r.id, o, n), i = D();
3423
+ t.addOnDestroy(() => this.releaseBlob(a, i));
3424
+ const c = this.getDownloadedBlobNoCtx(t.watcher, r, i, o, n);
3425
+ return c == null && t.markUnstable("download blob is still undefined"), c;
3426
+ }
3427
+ getDownloadedBlobNoCtx(e, t, o, n, r) {
3428
+ C("getDownloadedBlob", t.type);
3429
+ let a = this.idToDownload.get(w(t.id, n, r));
3430
+ if (a === void 0) {
3431
+ const c = this.setNewDownloadTask(t);
3429
3432
  this.downloadQueue.push({
3430
- fn: () => this.downloadBlob(a, o),
3431
- recoverableErrorPredicate: (i) => !ke(i)
3432
- }), n = a;
3433
+ fn: () => this.downloadBlob(c, o),
3434
+ recoverableErrorPredicate: (l) => !Le(l)
3435
+ }), a = c;
3433
3436
  }
3434
- n.attach(e, o);
3435
- const r = n.getBlob();
3436
- if (r.done) {
3437
- if (r.result.ok) return r.result.value;
3438
- throw r.result.error;
3437
+ a.attach(e, o);
3438
+ const i = a.getBlob();
3439
+ if (i.done) {
3440
+ if (i.result.ok) return i.result.value;
3441
+ throw i.result.error;
3439
3442
  }
3440
3443
  }
3441
- setNewDownloadTask(e) {
3442
- const t = this.getFilePath(e.id), o = new Yo(
3444
+ setNewDownloadTask(e, t, o) {
3445
+ const n = T.resolve(this.saveDir, w(e.id, t, o)), r = new en(
3443
3446
  this.logger,
3444
3447
  this.clientDownload,
3445
3448
  e,
3446
- t,
3447
- en(t, this.signer)
3449
+ n,
3450
+ tn(n, this.signer)
3448
3451
  );
3449
- return this.idToDownload.set(e.id, o), o;
3452
+ return this.idToDownload.set(w(e.id, t, o), r), r;
3450
3453
  }
3451
3454
  async downloadBlob(e, t) {
3452
3455
  await e.download();
@@ -3454,27 +3457,27 @@ class Dr {
3454
3457
  o.done && o.result.ok && this.cache.addCache(e, t);
3455
3458
  }
3456
3459
  getOnDemandBlob(e, t) {
3457
- if (t === void 0) return w.make((a) => this.getOnDemandBlob(e, a));
3458
- const o = E(e) ? x(e, on, t) : e, n = U();
3460
+ if (t === void 0) return y.make((a) => this.getOnDemandBlob(e, a));
3461
+ const o = O(e) ? A(e, nn, t) : e, n = D();
3459
3462
  return t.addOnDestroy(() => this.releaseOnDemandBlob(o.id, n)), this.getOnDemandBlobNoCtx(o, n);
3460
3463
  }
3461
3464
  getOnDemandBlobNoCtx(e, t) {
3462
- B("getOnDemandBlob", e.type);
3463
- let o = this.idToOnDemand.get(e.id);
3464
- return o === void 0 && (o = new un(nn(e), an(e, this.signer)), this.idToOnDemand.set(e.id, o)), o.attach(t), o.getHandle();
3465
+ C("getOnDemandBlob", e.type);
3466
+ let o = this.idToOnDemand.get(w(e.id));
3467
+ return o === void 0 && (o = new pn(rn(e), ln(e, this.signer)), this.idToOnDemand.set(w(e.id), o)), o.attach(t), o.getHandle();
3465
3468
  }
3466
3469
  /** Gets a path from a handle. */
3467
3470
  getLocalPath(e) {
3468
- const { path: t } = re(e, this.signer);
3471
+ const { path: t } = se(e, this.signer);
3469
3472
  return t;
3470
3473
  }
3471
3474
  /** Gets a content of a blob by a handle. */
3472
3475
  async getContent(e) {
3473
- if (tn(e))
3474
- return await gn(this.getLocalPath(e));
3475
- if (ln(e)) {
3476
- const t = cn(e, this.signer), { content: o } = await this.clientDownload.downloadBlob(t);
3477
- return await _e(o);
3476
+ if (on(e))
3477
+ return await fn(this.getLocalPath(e));
3478
+ if (cn(e)) {
3479
+ const t = dn(e, this.signer), { content: o } = await this.clientDownload.downloadBlob(t);
3480
+ return await Ee(o);
3478
3481
  }
3479
3482
  throw new Error("Malformed remote handle");
3480
3483
  }
@@ -3483,7 +3486,7 @@ class Dr {
3483
3486
  * Uses downloaded blob handle under the hood, so stores corresponding blob in file system.
3484
3487
  */
3485
3488
  getComputableContent(e) {
3486
- return w.make(
3489
+ return y.make(
3487
3490
  (t) => this.getDownloadedBlob(e, t),
3488
3491
  {
3489
3492
  postprocessValue: (t) => t ? this.getContent(t.handle) : void 0
@@ -3491,21 +3494,21 @@ class Dr {
3491
3494
  ).withStableType();
3492
3495
  }
3493
3496
  getLastLogs(e, t, o) {
3494
- if (o == null) return w.make((i) => this.getLastLogs(e, t, i));
3495
- const n = R(e, o), r = U();
3496
- o.addOnDestroy(() => this.releaseBlob(n.id, r));
3497
+ if (o == null) return y.make((i) => this.getLastLogs(e, t, i));
3498
+ const n = S(e, o), r = D();
3499
+ o.addOnDestroy(() => this.releaseBlob(w(n.id), r));
3497
3500
  const a = this.getLastLogsNoCtx(o.watcher, n, t, r);
3498
3501
  return a == null && o.markUnstable("either a file was not downloaded or logs was not read"), a;
3499
3502
  }
3500
3503
  getLastLogsNoCtx(e, t, o, n) {
3501
- B("getLastLogs", t.type);
3504
+ C("getLastLogs", t.type);
3502
3505
  const r = this.getDownloadedBlobNoCtx(e, t, n);
3503
3506
  if (r == null) return;
3504
- const { path: a } = re(r.handle, this.signer);
3505
- let i = this.idToLastLines.get(t.id);
3507
+ const { path: a } = se(r.handle, this.signer);
3508
+ let i = this.idToLastLines.get(w(t.id));
3506
3509
  if (i == null) {
3507
- const l = new Re(a, o);
3508
- this.idToLastLines.set(t.id, l), i = l;
3510
+ const l = new Se(a, o);
3511
+ this.idToLastLines.set(w(t.id), l), i = l;
3509
3512
  }
3510
3513
  const c = i.getOrSchedule(e);
3511
3514
  if (c.error) throw c.error;
@@ -3513,9 +3516,9 @@ class Dr {
3513
3516
  }
3514
3517
  getProgressLog(e, t, o) {
3515
3518
  if (o == null)
3516
- return w.make((i) => this.getProgressLog(e, t, i));
3517
- const n = R(e, o), r = U();
3518
- o.addOnDestroy(() => this.releaseBlob(n.id, r));
3519
+ return y.make((i) => this.getProgressLog(e, t, i));
3520
+ const n = S(e, o), r = D();
3521
+ o.addOnDestroy(() => this.releaseBlob(w(n.id), r));
3519
3522
  const a = this.getProgressLogNoCtx(
3520
3523
  o.watcher,
3521
3524
  n,
@@ -3525,30 +3528,30 @@ class Dr {
3525
3528
  return a === void 0 && o.markUnstable("either a file was not downloaded or a progress log was not read"), a;
3526
3529
  }
3527
3530
  getProgressLogNoCtx(e, t, o, n) {
3528
- B("getProgressLog", t.type);
3531
+ C("getProgressLog", t.type);
3529
3532
  const r = this.getDownloadedBlobNoCtx(e, t, n);
3530
3533
  if (r == null) return;
3531
- const { path: a } = re(r.handle, this.signer);
3532
- let i = this.idToProgressLog.get(t.id);
3534
+ const { path: a } = se(r.handle, this.signer);
3535
+ let i = this.idToProgressLog.get(w(t.id));
3533
3536
  if (i == null) {
3534
- const l = new Re(a, 1, o);
3535
- this.idToProgressLog.set(t.id, l), i = l;
3537
+ const l = new Se(a, 1, o);
3538
+ this.idToProgressLog.set(w(t.id), l), i = l;
3536
3539
  }
3537
3540
  const c = i.getOrSchedule(e);
3538
3541
  if (c.error) throw c.error;
3539
3542
  return c.log;
3540
3543
  }
3541
3544
  getLogHandle(e, t) {
3542
- if (t == null) return w.make((n) => this.getLogHandle(e, n));
3543
- const o = R(e, t);
3545
+ if (t == null) return y.make((n) => this.getLogHandle(e, n));
3546
+ const o = S(e, t);
3544
3547
  return this.getLogHandleNoCtx(o);
3545
3548
  }
3546
3549
  getLogHandleNoCtx(e) {
3547
- return B("getLogHandle", e.type), Ze(!1, e);
3550
+ return C("getLogHandle", e.type), Qe(!1, e);
3548
3551
  }
3549
3552
  async lastLines(e, t, o, n) {
3550
3553
  const r = await this.clientLogs.lastLines(
3551
- M(e),
3554
+ H(e),
3552
3555
  t,
3553
3556
  BigInt(o ?? 0),
3554
3557
  n
@@ -3563,7 +3566,7 @@ class Dr {
3563
3566
  }
3564
3567
  async readText(e, t, o, n) {
3565
3568
  const r = await this.clientLogs.readText(
3566
- M(e),
3569
+ H(e),
3567
3570
  t,
3568
3571
  BigInt(o ?? 0),
3569
3572
  n
@@ -3585,22 +3588,22 @@ class Dr {
3585
3588
  n.map(async (r) => {
3586
3589
  await m.rm(r.path), this.cache.removeCache(r), this.removeTask(
3587
3590
  r,
3588
- `the task ${y(r.info())} was removedfrom cache along with ${y(n.map((a) => a.info()))}`
3591
+ `the task ${b(r.info())} was removedfrom cache along with ${b(n.map((a) => a.info()))}`
3589
3592
  );
3590
3593
  })
3591
3594
  );
3592
3595
  } else
3593
3596
  o.counter.dec(t) && this.removeTask(
3594
3597
  o,
3595
- `the task ${y(o.info())} was removed from cache`
3598
+ `the task ${b(o.info())} was removed from cache`
3596
3599
  );
3597
3600
  }
3598
3601
  removeTask(e, t) {
3599
- e.abort(t), e.change.markChanged(), this.idToDownload.delete(e.rInfo.id), this.idToLastLines.delete(e.rInfo.id), this.idToProgressLog.delete(e.rInfo.id);
3602
+ e.abort(t), e.change.markChanged(), this.idToDownload.delete(w(e.rInfo.id)), this.idToLastLines.delete(w(e.rInfo.id)), this.idToProgressLog.delete(w(e.rInfo.id));
3600
3603
  }
3601
3604
  async releaseOnDemandBlob(e, t) {
3602
3605
  var n;
3603
- (((n = this.idToOnDemand.get(e)) == null ? void 0 : n.release(t)) ?? !1) && this.idToOnDemand.delete(e);
3606
+ (((n = this.idToOnDemand.get(w(e))) == null ? void 0 : n.release(t)) ?? !1) && this.idToOnDemand.delete(w(e));
3604
3607
  }
3605
3608
  /** Removes all files from a hard drive. */
3606
3609
  async releaseAll() {
@@ -3608,13 +3611,10 @@ class Dr {
3608
3611
  this.idToDownload.delete(t), e.change.markChanged();
3609
3612
  });
3610
3613
  }
3611
- getFilePath(e) {
3612
- return b.resolve(this.saveDir, String(BigInt(e)));
3613
- }
3614
3614
  }
3615
- class un {
3615
+ class pn {
3616
3616
  constructor(e, t) {
3617
- d(this, "counter", new v());
3617
+ d(this, "counter", new N());
3618
3618
  this.size = e, this.handle = t;
3619
3619
  }
3620
3620
  getHandle() {
@@ -3627,13 +3627,13 @@ class un {
3627
3627
  return this.counter.dec(e);
3628
3628
  }
3629
3629
  }
3630
- class Re {
3630
+ class Se {
3631
3631
  constructor(e, t, o) {
3632
3632
  d(this, "updater");
3633
3633
  d(this, "log");
3634
- d(this, "change", new N());
3634
+ d(this, "change", new $());
3635
3635
  d(this, "error");
3636
- this.path = e, this.lines = t, this.patternToSearch = o, this.updater = new hn(async () => this.update());
3636
+ this.path = e, this.lines = t, this.patternToSearch = o, this.updater = new un(async () => this.update());
3637
3637
  }
3638
3638
  getOrSchedule(e) {
3639
3639
  return this.change.attachWatcher(e), this.updater.schedule(), {
@@ -3643,7 +3643,7 @@ class Re {
3643
3643
  }
3644
3644
  async update() {
3645
3645
  try {
3646
- const e = await pn(this.path, this.lines, this.patternToSearch);
3646
+ const e = await gn(this.path, this.lines, this.patternToSearch);
3647
3647
  this.log != e && this.change.markChanged(), this.log = e;
3648
3648
  } catch (e) {
3649
3649
  if (e.name == "RpcError" && e.code == "NOT_FOUND") {
@@ -3654,54 +3654,57 @@ class Re {
3654
3654
  }
3655
3655
  }
3656
3656
  }
3657
- function pn(s, e, t) {
3658
- const o = we.createReadStream(s), n = new S();
3657
+ function gn(s, e, t) {
3658
+ const o = ye.createReadStream(s), n = new I();
3659
3659
  return new Promise((r, a) => {
3660
- const i = wt.createInterface(o, n), c = new gt();
3660
+ const i = yt.createInterface(o, n), c = new ft();
3661
3661
  i.on("line", function(l) {
3662
3662
  t != null && !l.includes(t) || (c.push(l), c.length > e && c.shift());
3663
3663
  }), i.on("error", a), i.on("close", function() {
3664
- r(c.toArray().join(De.EOL) + De.EOL);
3664
+ r(c.toArray().join(Re.EOL) + Re.EOL);
3665
3665
  });
3666
3666
  });
3667
3667
  }
3668
- async function gn(s) {
3669
- return await _e(ye.toWeb(we.createReadStream(s)));
3668
+ async function fn(s) {
3669
+ return await Ee(be.toWeb(ye.createReadStream(s)));
3670
3670
  }
3671
- function B(s, e) {
3671
+ function C(s, e) {
3672
3672
  if (!e.name.startsWith("Blob/")) {
3673
3673
  let t = `${s}: wrong resource type: ${e.name}, expected: a resource of type that starts with 'Blob/'.`;
3674
- throw e.name == "Blob" && (t += " If it's called from workflow, should a file be exported with 'file.exportFile' function?"), new Pe(t);
3674
+ throw e.name == "Blob" && (t += " If it's called from workflow, should a file be exported with 'file.exportFile' function?"), new Ue(t);
3675
3675
  }
3676
3676
  }
3677
- const fn = G({});
3678
- function mn(s, e) {
3679
- const t = E(s) ? e.accessor(s).node() : Oe(s) ? s.node() : s;
3680
- return x(t, fn);
3677
+ function w(s, e, t) {
3678
+ return e !== void 0 && t !== void 0 ? `${BigInt(s)}_${e}-${t}` : `${BigInt(s)}`;
3681
3679
  }
3682
- function wn(s, e, t) {
3683
- const o = L.relative(e, t);
3680
+ const mn = V({});
3681
+ function wn(s, e) {
3682
+ const t = O(s) ? e.accessor(s).node() : Fe(s) ? s.node() : s;
3683
+ return A(t, mn);
3684
+ }
3685
+ function yn(s, e, t) {
3686
+ const o = P.relative(e, t);
3684
3687
  return `plblob+folder://${s.sign(o)}.${o}.blob`;
3685
3688
  }
3686
- function yn(s) {
3689
+ function bn(s) {
3687
3690
  return new URL(s).protocol == "plblob+folder:";
3688
3691
  }
3689
- function bn(s, e, t) {
3692
+ function Tn(s, e, t) {
3690
3693
  const o = new URL(e), [n, r, a] = o.host.split(".");
3691
3694
  s.verify(r, n, `signature verification failed for url: ${e}, subfolder: ${r}`);
3692
- let i = Tn(L.join(t, `${r}`), o.pathname.slice(1));
3693
- return (o.pathname == "" || o.pathname == "/") && (i = L.join(i, "index.html")), L.resolve(i);
3695
+ let i = kn(P.join(t, `${r}`), o.pathname.slice(1));
3696
+ return (o.pathname == "" || o.pathname == "/") && (i = P.join(i, "index.html")), P.resolve(i);
3694
3697
  }
3695
- function Tn(s, e) {
3696
- const t = L.resolve(s, e), o = L.resolve(s);
3698
+ function kn(s, e) {
3699
+ const t = P.resolve(s, e), o = P.resolve(s);
3697
3700
  if (!t.startsWith(o))
3698
3701
  throw new Error("Path validation failed.");
3699
3702
  return t;
3700
3703
  }
3701
- class kn {
3704
+ class Ln {
3702
3705
  constructor(e, t, o, n, r, a, i) {
3703
- d(this, "counter", new v());
3704
- d(this, "change", new N());
3706
+ d(this, "counter", new N());
3707
+ d(this, "change", new $());
3705
3708
  d(this, "signalCtl", new AbortController());
3706
3709
  d(this, "error");
3707
3710
  d(this, "done", !1);
@@ -3728,10 +3731,10 @@ class kn {
3728
3731
  async download() {
3729
3732
  try {
3730
3733
  const e = await this.downloadAndDecompress(this.signalCtl.signal);
3731
- this.setDone(e), this.change.markChanged(), this.logger.info(`blob to URL task is done: ${y(this.info())}`);
3734
+ this.setDone(e), this.change.markChanged(), this.logger.info(`blob to URL task is done: ${b(this.info())}`);
3732
3735
  } catch (e) {
3733
- if (this.logger.warn(`a error was produced: ${e} for blob to URL task: ${y(this.info())}`), Ln(e)) {
3734
- this.setError(e), this.change.markChanged(), await ce(this.path);
3736
+ if (this.logger.warn(`a error was produced: ${e} for blob to URL task: ${b(this.info())}`), Pn(e)) {
3737
+ this.setError(e), this.change.markChanged(), await de(this.path);
3735
3738
  return;
3736
3739
  }
3737
3740
  throw e;
@@ -3739,72 +3742,72 @@ class kn {
3739
3742
  }
3740
3743
  /** Does the download part and keeps a state of the process. */
3741
3744
  async downloadAndDecompress(e) {
3742
- if (this.state = {}, this.state.parentDir = L.dirname(this.path), await pe(this.state.parentDir), this.state.fileExisted = await ge(this.path), this.state.fileExisted)
3743
- return await Ke(this.path);
3745
+ if (this.state = {}, this.state.parentDir = P.dirname(this.path), await ge(this.state.parentDir), this.state.fileExisted = await fe(this.path), this.state.fileExisted)
3746
+ return await Ye(this.path);
3744
3747
  const { content: t, size: o } = await this.clientDownload.downloadBlob(
3745
3748
  this.rInfo,
3746
3749
  {},
3747
3750
  e
3748
3751
  );
3749
- return this.state.downloaded = !0, await fe(this.logger, this.path, async (n) => {
3752
+ return this.state.downloaded = !0, await me(this.logger, this.path, async (n) => {
3750
3753
  switch (this.state.tempPath = n, this.state.archiveFormat = this.format, this.format) {
3751
3754
  case "tar":
3752
3755
  await m.mkdir(n);
3753
- const r = S.toWeb(le.extract(n));
3756
+ const r = I.toWeb(ce.extract(n));
3754
3757
  await t.pipeTo(r, { signal: e });
3755
3758
  return;
3756
3759
  case "tgz":
3757
3760
  await m.mkdir(n);
3758
- const a = Ce.toWeb(Fe.createGunzip()), i = S.toWeb(le.extract(n));
3761
+ const a = _e.toWeb(We.createGunzip()), i = I.toWeb(ce.extract(n));
3759
3762
  await t.pipeThrough(a, { signal: e }).pipeTo(i, { signal: e });
3760
3763
  return;
3761
3764
  case "zip":
3762
3765
  this.state.zipPath = this.path + ".zip";
3763
- const c = S.toWeb(ae.createWriteStream(this.state.zipPath));
3764
- await t.pipeTo(c, { signal: e }), this.state.zipPathCreated = !0, await yt(this.state.zipPath, n, {
3766
+ const c = I.toWeb(le.createWriteStream(this.state.zipPath));
3767
+ await t.pipeTo(c, { signal: e }), this.state.zipPathCreated = !0, await bt(this.state.zipPath, n, {
3765
3768
  filter: (l) => !l.path.endsWith("/")
3766
- }), this.state.zipDecompressed = !0, await ae.promises.rm(this.state.zipPath), this.state.zipPathDeleted = !0;
3769
+ }), this.state.zipDecompressed = !0, await le.promises.rm(this.state.zipPath), this.state.zipPathDeleted = !0;
3767
3770
  return;
3768
3771
  default:
3769
- dt(this.format);
3772
+ ht(this.format);
3770
3773
  }
3771
3774
  }), this.state.pathCreated = !0, o;
3772
3775
  }
3773
3776
  getURL() {
3774
- if (this.done) return { url: H(this.url) };
3777
+ if (this.done) return { url: j(this.url) };
3775
3778
  if (this.error) return { error: this.error };
3776
3779
  }
3777
3780
  setDone(e) {
3778
- this.done = !0, this.size = e, this.url = wn(this.signer, this.saveDir, this.path);
3781
+ this.done = !0, this.size = e, this.url = yn(this.signer, this.saveDir, this.path);
3779
3782
  }
3780
3783
  setError(e) {
3781
3784
  this.error = String(e);
3782
3785
  }
3783
3786
  abort(e) {
3784
- this.signalCtl.abort(new Ye(e));
3787
+ this.signalCtl.abort(new et(e));
3785
3788
  }
3786
3789
  }
3787
- async function Ke(s) {
3790
+ async function Ye(s) {
3788
3791
  const e = await m.readdir(s, { withFileTypes: !0 });
3789
3792
  return (await Promise.all(
3790
3793
  e.map(async (o) => {
3791
- const n = L.join(s, o.name);
3792
- return o.isDirectory() ? await Ke(n) : (await m.stat(n)).size;
3794
+ const n = P.join(s, o.name);
3795
+ return o.isDirectory() ? await Ye(n) : (await m.stat(n)).size;
3793
3796
  })
3794
3797
  )).reduce((o, n) => o + n, 0);
3795
3798
  }
3796
- async function ce(s) {
3799
+ async function de(s) {
3797
3800
  await m.rm(s, { recursive: !0, force: !0 });
3798
3801
  }
3799
- let Ye = class extends Error {
3802
+ let et = class extends Error {
3800
3803
  };
3801
- function Ln(s) {
3802
- return s instanceof Ye || s instanceof V || s instanceof Te || s instanceof be || (s == null ? void 0 : s.code) == "ENOENT" || s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED") || String(s).includes("incorrect header check");
3804
+ function Pn(s) {
3805
+ return s instanceof et || s instanceof q || s instanceof ke || s instanceof Te || (s == null ? void 0 : s.code) == "ENOENT" || s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED") || String(s).includes("incorrect header check");
3803
3806
  }
3804
- function O(s, e) {
3807
+ function F(s, e) {
3805
3808
  return `id:${String(BigInt(s))}-${e}`;
3806
3809
  }
3807
- class Sr {
3810
+ class Ir {
3808
3811
  constructor(e, t, o, n, r = {
3809
3812
  cacheSoftSizeBytes: 50 * 1024 * 1024,
3810
3813
  nConcurrentDownloads: 50
@@ -3814,13 +3817,13 @@ class Sr {
3814
3817
  /** Writes and removes files to a hard drive and holds a counter for every
3815
3818
  * file that should be kept. */
3816
3819
  d(this, "cache");
3817
- this.logger = e, this.signer = t, this.clientDownload = o, this.saveDir = n, this.opts = r, this.downloadQueue = new j(this.logger, this.opts.nConcurrentDownloads, {
3820
+ this.logger = e, this.signer = t, this.clientDownload = o, this.saveDir = n, this.opts = r, this.downloadQueue = new G(this.logger, this.opts.nConcurrentDownloads, {
3818
3821
  type: "exponentialWithMaxDelayBackoff",
3819
3822
  initialDelay: 1e4,
3820
3823
  maxDelay: 3e4,
3821
3824
  backoffMultiplier: 1.5,
3822
3825
  jitter: 0.5
3823
- }), this.cache = new Le(this.opts.cacheSoftSizeBytes);
3826
+ }), this.cache = new Pe(this.opts.cacheSoftSizeBytes);
3824
3827
  }
3825
3828
  info() {
3826
3829
  return {
@@ -3835,14 +3838,14 @@ class Sr {
3835
3838
  * @returns full path to the referenced file
3836
3839
  */
3837
3840
  getPathForCustomProtocol(e) {
3838
- if (yn(e))
3839
- return bn(this.signer, e, this.saveDir);
3841
+ if (bn(e))
3842
+ return Tn(this.signer, e, this.saveDir);
3840
3843
  throw new Error(`getPathForCustomProtocol: ${e} is invalid`);
3841
3844
  }
3842
3845
  extractArchiveAndGetURL(e, t, o) {
3843
3846
  if (o === void 0)
3844
- return w.make((i) => this.extractArchiveAndGetURL(e, t, i));
3845
- const n = E(e) ? mn(e, o) : e, r = U();
3847
+ return y.make((i) => this.extractArchiveAndGetURL(e, t, i));
3848
+ const n = O(e) ? wn(e, o) : e, r = D();
3846
3849
  o.addOnDestroy(() => this.releasePath(n.id, t, r));
3847
3850
  const a = this.extractArchiveAndGetURLNoCtx(n, t, o.watcher, r);
3848
3851
  if ((a == null ? void 0 : a.url) === void 0 && o.markUnstable(
@@ -3852,13 +3855,13 @@ class Sr {
3852
3855
  return a == null ? void 0 : a.url;
3853
3856
  }
3854
3857
  extractArchiveAndGetURLNoCtx(e, t, o, n) {
3855
- const r = this.idToDownload.get(O(e.id, t));
3858
+ const r = this.idToDownload.get(F(e.id, t));
3856
3859
  if (r != null)
3857
3860
  return r.attach(o, n), r.getURL();
3858
3861
  const a = this.setNewTask(o, e, t, n);
3859
3862
  return this.downloadQueue.push({
3860
3863
  fn: async () => this.downloadUrl(a, n),
3861
- recoverableErrorPredicate: (i) => !ke(i)
3864
+ recoverableErrorPredicate: (i) => !Le(i)
3862
3865
  }), a.getURL();
3863
3866
  }
3864
3867
  /** Downloads and extracts a tar archive if it wasn't downloaded yet. */
@@ -3869,37 +3872,37 @@ class Sr {
3869
3872
  /** Removes a directory and aborts a downloading task when all callers
3870
3873
  * are not interested in it. */
3871
3874
  async releasePath(e, t, o) {
3872
- const n = this.idToDownload.get(O(e, t));
3875
+ const n = this.idToDownload.get(F(e, t));
3873
3876
  if (n != null)
3874
3877
  if (this.cache.existsFile(n.path)) {
3875
3878
  const r = this.cache.removeFile(n.path, o);
3876
3879
  await Promise.all(
3877
3880
  r.map(async (a) => {
3878
- await ce(a.path), this.cache.removeCache(a), this.removeTask(
3881
+ await de(a.path), this.cache.removeCache(a), this.removeTask(
3879
3882
  a,
3880
- `the task ${y(a.info())} was removedfrom cache along with ${y(r.map((i) => i.info()))}`
3883
+ `the task ${b(a.info())} was removedfrom cache along with ${b(r.map((i) => i.info()))}`
3881
3884
  );
3882
3885
  })
3883
3886
  );
3884
3887
  } else
3885
3888
  n.counter.dec(o) && this.removeTask(
3886
3889
  n,
3887
- `the task ${y(n.info())} was removed from cache`
3890
+ `the task ${b(n.info())} was removed from cache`
3888
3891
  );
3889
3892
  }
3890
3893
  /** Removes all files from a hard drive. */
3891
3894
  async releaseAll() {
3892
3895
  this.downloadQueue.stop(), await Promise.all(
3893
3896
  Array.from(this.idToDownload.entries()).map(async ([e, t]) => {
3894
- await ce(t.path), this.cache.removeCache(t), this.removeTask(
3897
+ await de(t.path), this.cache.removeCache(t), this.removeTask(
3895
3898
  t,
3896
- `the task ${y(t.info())} was released when the driver was closed`
3899
+ `the task ${b(t.info())} was released when the driver was closed`
3897
3900
  );
3898
3901
  })
3899
3902
  );
3900
3903
  }
3901
3904
  setNewTask(e, t, o, n) {
3902
- const r = new kn(
3905
+ const r = new Ln(
3903
3906
  this.logger,
3904
3907
  this.signer,
3905
3908
  this.saveDir,
@@ -3908,19 +3911,19 @@ class Sr {
3908
3911
  o,
3909
3912
  this.clientDownload
3910
3913
  );
3911
- return r.attach(e, n), this.idToDownload.set(O(t.id, o), r), r;
3914
+ return r.attach(e, n), this.idToDownload.set(F(t.id, o), r), r;
3912
3915
  }
3913
3916
  removeTask(e, t) {
3914
- e.abort(t), e.change.markChanged(), this.idToDownload.delete(O(e.rInfo.id, e.format));
3917
+ e.abort(t), e.change.markChanged(), this.idToDownload.delete(F(e.rInfo.id, e.format));
3915
3918
  }
3916
3919
  getFilePath(e, t) {
3917
- return b.join(this.saveDir, `${String(BigInt(e))}_${t}`);
3920
+ return T.join(this.saveDir, `${String(BigInt(e))}_${t}`);
3918
3921
  }
3919
3922
  }
3920
- class Pn {
3923
+ class Un {
3921
3924
  constructor(e, t, o, n, r, a) {
3922
- d(this, "change", new N());
3923
- d(this, "counter", new v());
3925
+ d(this, "change", new $());
3926
+ d(this, "counter", new N());
3924
3927
  d(this, "nMaxUploads");
3925
3928
  d(this, "nPartsWithThisUploadSpeed", 0);
3926
3929
  d(this, "nPartsToIncreaseUpload", 10);
@@ -3934,21 +3937,21 @@ class Pn {
3934
3937
  * At this case, the task will show progress == 1.0. */
3935
3938
  d(this, "alreadyExisted", !1);
3936
3939
  this.logger = e, this.clientBlob = t, this.clientProgress = o, this.maxNConcurrentPartsUpload = n, this.res = a, this.nMaxUploads = this.maxNConcurrentPartsUpload;
3937
- const { uploadData: i, progress: c } = Dn(a, r);
3940
+ const { uploadData: i, progress: c } = Rn(a, r);
3938
3941
  this.uploadData = i, this.progress = c;
3939
3942
  }
3940
3943
  getProgress(e, t) {
3941
3944
  if (this.incCounter(e, t), this.failed)
3942
3945
  throw this.logger.error(`Uploading terminally failed: ${this.progress.lastError}`), new Error(this.progress.lastError);
3943
- return Sn(this.progress);
3946
+ return In(this.progress);
3944
3947
  }
3945
3948
  shouldScheduleUpload() {
3946
- return Rn(this.progress);
3949
+ return Sn(this.progress);
3947
3950
  }
3948
3951
  /** Uploads a blob if it's not BlobIndex. */
3949
3952
  async uploadBlobTask() {
3950
3953
  try {
3951
- await Un(
3954
+ await Dn(
3952
3955
  this.logger,
3953
3956
  this.clientBlob,
3954
3957
  this.res,
@@ -3962,30 +3965,30 @@ class Pn {
3962
3965
  }
3963
3966
  ), this.change.markChanged();
3964
3967
  } catch (e) {
3965
- if (this.setRetriableError(e), Se(e)) {
3968
+ if (this.setRetriableError(e), Ie(e)) {
3966
3969
  this.logger.warn(`resource was deleted while uploading a blob: ${e}`), this.change.markChanged(), this.setDone(!0);
3967
3970
  return;
3968
3971
  }
3969
- if (this.logger.error(`error while uploading a blob: ${e}`), this.change.markChanged(), et(e)) {
3972
+ if (this.logger.error(`error while uploading a blob: ${e}`), this.change.markChanged(), tt(e)) {
3970
3973
  this.setTerminalError(e);
3971
3974
  return;
3972
3975
  }
3973
- throw Bn(e) && (this.nMaxUploads = _n(this.logger, this.nMaxUploads, 1)), e;
3976
+ throw Cn(e) && (this.nMaxUploads = En(this.logger, this.nMaxUploads, 1)), e;
3974
3977
  }
3975
3978
  }
3976
3979
  async updateStatus() {
3977
3980
  var e;
3978
3981
  try {
3979
- const t = await this.clientProgress.getStatus(this.res, { timeout: 1e4 }), o = this.progress.status, n = $n(this.alreadyExisted, Nn(t));
3982
+ const t = await this.clientProgress.getStatus(this.res, { timeout: 1e4 }), o = this.progress.status, n = Bn(this.alreadyExisted, $n(t));
3980
3983
  this.progress.status = n, this.setDone(t.done), (t.done || this.progress.status.progress != (o == null ? void 0 : o.progress)) && this.change.markChanged();
3981
3984
  } catch (t) {
3982
3985
  if (this.setRetriableError(t), t.name == "RpcError" && t.code == "DEADLINE_EXCEEDED" || (e = t == null ? void 0 : t.message) != null && e.includes("DEADLINE_EXCEEDED")) {
3983
3986
  this.logger.warn("deadline exceeded while getting a status of BlobImport");
3984
3987
  return;
3985
3988
  }
3986
- if (Se(t)) {
3989
+ if (Ie(t)) {
3987
3990
  this.logger.warn(
3988
- `resource was not found while updating a status of BlobImport: ${t}, ${y(this.res)}`
3991
+ `resource was not found while updating a status of BlobImport: ${t}, ${b(this.res)}`
3989
3992
  ), this.change.markChanged(), this.setDone(!0);
3990
3993
  return;
3991
3994
  }
@@ -4001,7 +4004,7 @@ class Pn {
4001
4004
  this.progress.lastError = String(e), this.progress.done = !1, this.failed = !0;
4002
4005
  }
4003
4006
  setDoneIfOutputSet(e) {
4004
- In(e) && (this.setDone(!0), this.alreadyExisted = !0);
4007
+ vn(e) && (this.setDone(!0), this.alreadyExisted = !0);
4005
4008
  }
4006
4009
  setDone(e) {
4007
4010
  this.progress.done = e, e && (this.progress.lastError = void 0);
@@ -4016,8 +4019,8 @@ class Pn {
4016
4019
  return this.counter.isZero();
4017
4020
  }
4018
4021
  }
4019
- async function Un(s, e, t, o, n, r) {
4020
- bt(de(t), "the upload operation can be done only for BlobUploads");
4022
+ async function Dn(s, e, t, o, n, r) {
4023
+ Tt(he(t), "the upload operation can be done only for BlobUploads");
4021
4024
  const a = 1e4;
4022
4025
  if (n()) return;
4023
4026
  const i = await e.initUpload(t, { timeout: a });
@@ -4031,78 +4034,78 @@ async function Un(s, e, t, o, n, r) {
4031
4034
  BigInt(o.modificationTime),
4032
4035
  l,
4033
4036
  { timeout: a }
4034
- ), s.info(`uploaded chunk ${l}/${i.overall} of resource: ${t.id}`), r.nPartsWithThisUploadSpeed++, r.nPartsWithThisUploadSpeed >= r.nPartsToIncreaseUpload && (r.nPartsWithThisUploadSpeed = 0, r.currentSpeed = Cn(s, r.currentSpeed, r.maxSpeed), p.setConcurrency(r.currentSpeed)));
4037
+ ), s.info(`uploaded chunk ${l}/${i.overall} of resource: ${t.id}`), r.nPartsWithThisUploadSpeed++, r.nPartsWithThisUploadSpeed >= r.nPartsToIncreaseUpload && (r.nPartsWithThisUploadSpeed = 0, r.currentSpeed = _n(s, r.currentSpeed, r.maxSpeed), p.setConcurrency(r.currentSpeed)));
4035
4038
  };
4036
- await me(r.currentSpeed, i.toUpload.map(c)), !n() && (await e.finalize(t, { timeout: a }), s.info(`uploading of resource ${t.id} finished.`));
4039
+ await we(r.currentSpeed, i.toUpload.map(c)), !n() && (await e.finalize(t, { timeout: a }), s.info(`uploading of resource ${t.id} finished.`));
4037
4040
  }
4038
- function Dn(s, e) {
4041
+ function Rn(s, e) {
4039
4042
  let t, o;
4040
- return de(s) && (o = q.parse(s.data), t = vn(e, o.localPath, o.pathSignature)), {
4043
+ return he(s) && (o = J.parse(s.data), t = Nn(e, o.localPath, o.pathSignature)), {
4041
4044
  uploadData: o,
4042
4045
  progress: {
4043
4046
  done: !1,
4044
4047
  status: void 0,
4045
- isUpload: de(s),
4048
+ isUpload: he(s),
4046
4049
  isUploadSignMatch: t,
4047
4050
  lastError: void 0
4048
4051
  }
4049
4052
  };
4050
4053
  }
4051
- function Rn(s) {
4054
+ function Sn(s) {
4052
4055
  return s.isUpload && (s.isUploadSignMatch ?? !1);
4053
4056
  }
4054
- function Sn(s) {
4057
+ function In(s) {
4055
4058
  return s.done, s.isUpload, s.isUploadSignMatch, s.lastError, s.status && (s.status.progress, s.status.bytesProcessed, s.status.bytesTotal), s;
4056
4059
  }
4057
- function In(s) {
4060
+ function vn(s) {
4058
4061
  return "blob" in s.fields ? s.fields.blob !== void 0 : s.fields.incarnation !== void 0;
4059
4062
  }
4060
- function de(s) {
4063
+ function he(s) {
4061
4064
  return s.type.name.startsWith("BlobUpload");
4062
4065
  }
4063
- function vn(s, e, t) {
4066
+ function Nn(s, e, t) {
4064
4067
  try {
4065
4068
  return s.verify(e, t), !0;
4066
4069
  } catch {
4067
4070
  return !1;
4068
4071
  }
4069
4072
  }
4070
- function Nn(s) {
4073
+ function $n(s) {
4071
4074
  return {
4072
4075
  progress: s.progress ?? 0,
4073
4076
  bytesProcessed: Number(s.bytesProcessed),
4074
4077
  bytesTotal: Number(s.bytesTotal)
4075
4078
  };
4076
4079
  }
4077
- function $n(s, e) {
4080
+ function Bn(s, e) {
4078
4081
  return s && e.bytesTotal != 0 && e.bytesProcessed == 0 ? {
4079
4082
  progress: 1,
4080
4083
  bytesProcessed: Number(e.bytesTotal),
4081
4084
  bytesTotal: Number(e.bytesTotal)
4082
4085
  } : e;
4083
4086
  }
4084
- function Se(s) {
4087
+ function Ie(s) {
4085
4088
  return s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED" || s.code == "ALREADY_EXISTS");
4086
4089
  }
4087
- function et(s) {
4088
- return s instanceof xe || s instanceof Ae || s instanceof He;
4090
+ function tt(s) {
4091
+ return s instanceof Ae || s instanceof Me || s instanceof je;
4089
4092
  }
4090
- function Bn(s) {
4093
+ function Cn(s) {
4091
4094
  return s == null ? void 0 : s.message.includes("UND_ERR_HEADERS_TIMEOUT");
4092
4095
  }
4093
- function Cn(s, e, t) {
4096
+ function _n(s, e, t) {
4094
4097
  const o = Math.min(e + 2, t);
4095
4098
  return o != e && s.info(`uploadTask.increaseConcurrency: increased from ${e} to ${o}`), o;
4096
4099
  }
4097
- function _n(s, e, t) {
4100
+ function En(s, e, t) {
4098
4101
  const o = Math.max(Math.round(e / 2), t);
4099
4102
  return o != e && s.info(`uploadTask.decreaseConcurrency: decreased from ${e} to ${o}`), o;
4100
4103
  }
4101
- function En(s, e) {
4102
- const t = E(s) ? e.accessor(s).node() : Oe(s) ? s.node() : s;
4103
- return t.resourceType.name.startsWith("BlobUpload") ? x(t, rn) : x(t, sn);
4104
+ function On(s, e) {
4105
+ const t = O(s) ? e.accessor(s).node() : Fe(s) ? s.node() : s;
4106
+ return t.resourceType.name.startsWith("BlobUpload") ? A(t, sn) : A(t, an);
4104
4107
  }
4105
- class Ir {
4108
+ class vr {
4106
4109
  constructor(e, t, o, n, r = {
4107
4110
  nConcurrentPartUploads: 10,
4108
4111
  nConcurrentGetProgresses: 10,
@@ -4118,14 +4121,14 @@ class Ir {
4118
4121
  d(this, "keepRunning", !1);
4119
4122
  /** Actual state of main loop. */
4120
4123
  d(this, "currentLoop");
4121
- this.logger = e, this.signer = t, this.clientBlob = o, this.clientProgress = n, this.opts = r, this.uploadQueue = new j(this.logger, 1, {
4124
+ this.logger = e, this.signer = t, this.clientBlob = o, this.clientProgress = n, this.opts = r, this.uploadQueue = new G(this.logger, 1, {
4122
4125
  type: "exponentialWithMaxDelayBackoff",
4123
4126
  initialDelay: 20,
4124
4127
  maxDelay: 15e3,
4125
4128
  // 15 seconds
4126
4129
  backoffMultiplier: 1.5,
4127
4130
  jitter: 0.5
4128
- }), this.hooks = new Ee(
4131
+ }), this.hooks = new Oe(
4129
4132
  () => this.startUpdating(),
4130
4133
  () => this.stopUpdating(),
4131
4134
  { stopDebounce: r.stopPollingDelay },
@@ -4133,16 +4136,16 @@ class Ir {
4133
4136
  );
4134
4137
  }
4135
4138
  getProgressId(e, t) {
4136
- if (t == null) return w.make((a) => this.getProgressId(e, a));
4137
- const o = E(e) ? En(e, t) : e, n = U();
4139
+ if (t == null) return y.make((a) => this.getProgressId(e, a));
4140
+ const o = O(e) ? On(e, t) : e, n = D();
4138
4141
  return t.attacheHooks(this.hooks), t.addOnDestroy(() => this.release(o.id, n)), this.getProgressIdNoCtx(t.watcher, o, n);
4139
4142
  }
4140
4143
  getProgressIdNoCtx(e, t, o) {
4141
- Fn("getProgressId", t.type);
4144
+ Wn("getProgressId", t.type);
4142
4145
  const n = this.idToProgress.get(t.id);
4143
4146
  if (n != null)
4144
4147
  return n.setDoneIfOutputSet(t), n.getProgress(e, o);
4145
- const r = new Pn(
4148
+ const r = new Un(
4146
4149
  this.logger,
4147
4150
  this.clientBlob,
4148
4151
  this.clientProgress,
@@ -4152,7 +4155,7 @@ class Ir {
4152
4155
  );
4153
4156
  return this.idToProgress.set(t.id, r), r.shouldScheduleUpload() && this.uploadQueue.push({
4154
4157
  fn: () => r.uploadBlobTask(),
4155
- recoverableErrorPredicate: (a) => !et(a)
4158
+ recoverableErrorPredicate: (a) => !tt(a)
4156
4159
  }), r.setDoneIfOutputSet(t), r.getProgress(e, o);
4157
4160
  }
4158
4161
  /** Decrement counters for the file and remove an uploading if counter == 0. */
@@ -4181,7 +4184,7 @@ class Ir {
4181
4184
  const e = this.scheduledOnNextState;
4182
4185
  this.scheduledOnNextState = [];
4183
4186
  try {
4184
- await me(
4187
+ await we(
4185
4188
  this.opts.nConcurrentGetProgresses,
4186
4189
  this.getAllNotDoneProgresses().map((t) => async () => await t.updateStatus())
4187
4190
  ), e.forEach((t) => t.resolve());
@@ -4189,25 +4192,25 @@ class Ir {
4189
4192
  console.error(t), e.forEach((o) => o.reject(t));
4190
4193
  }
4191
4194
  if (!this.keepRunning) break;
4192
- await We.wait(this.opts.pollingInterval);
4195
+ await ze.wait(this.opts.pollingInterval);
4193
4196
  }
4194
4197
  this.currentLoop = void 0;
4195
4198
  }
4196
4199
  getAllNotDoneProgresses() {
4197
- return Array.from(this.idToProgress.entries()).filter(([e, t]) => !On(t.progress)).map(([e, t]) => t);
4200
+ return Array.from(this.idToProgress.entries()).filter(([e, t]) => !Fn(t.progress)).map(([e, t]) => t);
4198
4201
  }
4199
4202
  }
4200
- function On(s) {
4203
+ function Fn(s) {
4201
4204
  var e;
4202
4205
  return s.done && (((e = s.status) == null ? void 0 : e.progress) ?? 0) >= 1;
4203
4206
  }
4204
- function Fn(s, e) {
4207
+ function Wn(s, e) {
4205
4208
  if (!e.name.startsWith("BlobUpload") && !e.name.startsWith("BlobIndex"))
4206
- throw new Pe(
4209
+ throw new Ue(
4207
4210
  `${s}: wrong resource type: ${e.name}, expected: a resource of either type 'BlobUpload' or 'BlobIndex'.`
4208
4211
  );
4209
4212
  }
4210
- class vr {
4213
+ class Nr {
4211
4214
  constructor(e, t, o = {
4212
4215
  nConcurrentGetLogs: 10,
4213
4216
  pollingInterval: 1e3,
@@ -4224,7 +4227,7 @@ class vr {
4224
4227
  d(this, "keepRunning", !1);
4225
4228
  /** Actual state of main loop. */
4226
4229
  d(this, "currentLoop");
4227
- this.logger = e, this.clientLogs = t, this.opts = o, this.hooks = new Ee(
4230
+ this.logger = e, this.clientLogs = t, this.opts = o, this.hooks = new Oe(
4228
4231
  () => this.startUpdating(),
4229
4232
  () => this.stopUpdating(),
4230
4233
  { stopDebounce: o.stopPollingDelay },
@@ -4232,8 +4235,8 @@ class vr {
4232
4235
  );
4233
4236
  }
4234
4237
  getLastLogs(e, t, o) {
4235
- if (o == null) return w.make((i) => this.getLastLogs(e, t, i));
4236
- const n = R(e, o), r = U();
4238
+ if (o == null) return y.make((i) => this.getLastLogs(e, t, i));
4239
+ const n = S(e, o), r = D();
4237
4240
  o.attacheHooks(this.hooks), o.addOnDestroy(() => this.releaseLastLogs(n.id, r));
4238
4241
  const a = this.getLastLogsNoCtx(o.watcher, n, t, r);
4239
4242
  return o.markUnstable(
@@ -4241,10 +4244,10 @@ class vr {
4241
4244
  ), a;
4242
4245
  }
4243
4246
  getLastLogsNoCtx(e, t, o, n) {
4244
- se("getLastLogs", t.type);
4247
+ ie("getLastLogs", t.type);
4245
4248
  let r = this.idToLastLines.get(t.id);
4246
4249
  if (r == null) {
4247
- const i = new Ie(this.logger, this.clientLogs, t, o);
4250
+ const i = new ve(this.logger, this.clientLogs, t, o);
4248
4251
  this.idToLastLines.set(t.id, i), r = i;
4249
4252
  }
4250
4253
  r.attach(e, n);
@@ -4254,8 +4257,8 @@ class vr {
4254
4257
  }
4255
4258
  getProgressLog(e, t, o) {
4256
4259
  if (o == null)
4257
- return w.make((i) => this.getProgressLog(e, t, i));
4258
- const n = R(e, o), r = U();
4260
+ return y.make((i) => this.getProgressLog(e, t, i));
4261
+ const n = S(e, o), r = D();
4259
4262
  o.attacheHooks(this.hooks), o.addOnDestroy(() => this.releaseProgressLog(n.id, r));
4260
4263
  const a = this.getProgressLogNoCtx(o.watcher, n, t, r);
4261
4264
  return o.markUnstable(
@@ -4263,10 +4266,10 @@ class vr {
4263
4266
  ), a;
4264
4267
  }
4265
4268
  getProgressLogNoCtx(e, t, o, n) {
4266
- se("getProgressLog", t.type);
4269
+ ie("getProgressLog", t.type);
4267
4270
  let r = this.idToProgressLog.get(t.id);
4268
4271
  if (r == null) {
4269
- const i = new Ie(this.logger, this.clientLogs, t, 1, o);
4272
+ const i = new ve(this.logger, this.clientLogs, t, 1, o);
4270
4273
  this.idToProgressLog.set(t.id, i), r = i;
4271
4274
  }
4272
4275
  r.attach(e, n);
@@ -4275,18 +4278,18 @@ class vr {
4275
4278
  return a.log;
4276
4279
  }
4277
4280
  getLogHandle(e, t) {
4278
- if (t == null) return w.make((r) => this.getLogHandle(e, r));
4279
- const o = R(e, t), n = this.getLogHandleNoCtx(o);
4280
- return t.markUnstable(`live_log:${lt(o.id)}`), n;
4281
+ if (t == null) return y.make((r) => this.getLogHandle(e, r));
4282
+ const o = S(e, t), n = this.getLogHandleNoCtx(o);
4283
+ return t.markUnstable(`live_log:${ct(o.id)}`), n;
4281
4284
  }
4282
4285
  getLogHandleNoCtx(e) {
4283
- return se("getLogHandle", e.type), Ze(!0, e);
4286
+ return ie("getLogHandle", e.type), Qe(!0, e);
4284
4287
  }
4285
4288
  async lastLines(e, t, o, n) {
4286
4289
  return await this.tryWithNotFound(
4287
4290
  e,
4288
4291
  () => this.clientLogs.lastLines(
4289
- M(e),
4292
+ H(e),
4290
4293
  t,
4291
4294
  BigInt(o ?? 0),
4292
4295
  n
@@ -4297,7 +4300,7 @@ class vr {
4297
4300
  return await this.tryWithNotFound(
4298
4301
  e,
4299
4302
  () => this.clientLogs.readText(
4300
- M(e),
4303
+ H(e),
4301
4304
  t,
4302
4305
  BigInt(o ?? 0),
4303
4306
  n
@@ -4305,7 +4308,7 @@ class vr {
4305
4308
  );
4306
4309
  }
4307
4310
  async tryWithNotFound(e, t) {
4308
- if (!A(e))
4311
+ if (!M(e))
4309
4312
  throw new Error(`Not live log handle was passed to live log driver, handle: ${e}`);
4310
4313
  try {
4311
4314
  const o = await t();
@@ -4349,7 +4352,7 @@ class vr {
4349
4352
  this.scheduledOnNextState = [];
4350
4353
  try {
4351
4354
  const t = this.getAllLogs();
4352
- await me(
4355
+ await we(
4353
4356
  this.opts.nConcurrentGetLogs,
4354
4357
  t.map((o) => async () => await o.update())
4355
4358
  ), e.forEach((o) => o.resolve());
@@ -4357,7 +4360,7 @@ class vr {
4357
4360
  console.error(t), e.forEach((o) => o.reject(t));
4358
4361
  }
4359
4362
  if (!this.keepRunning) break;
4360
- await We.wait(this.opts.pollingInterval);
4363
+ await ze.wait(this.opts.pollingInterval);
4361
4364
  }
4362
4365
  this.currentLoop = void 0;
4363
4366
  }
@@ -4365,12 +4368,12 @@ class vr {
4365
4368
  return Array.from(this.idToLastLines.entries()).concat(Array.from(this.idToProgressLog.entries())).map(([e, t]) => t);
4366
4369
  }
4367
4370
  }
4368
- class Ie {
4371
+ class ve {
4369
4372
  constructor(e, t, o, n, r) {
4370
4373
  d(this, "logs");
4371
4374
  d(this, "error");
4372
- d(this, "change", new N());
4373
- d(this, "counter", new v());
4375
+ d(this, "change", new $());
4376
+ d(this, "counter", new N());
4374
4377
  this.logger = e, this.clientLogs = t, this.rInfo = o, this.lines = n, this.patternToSearch = r;
4375
4378
  }
4376
4379
  getLog() {
@@ -4401,29 +4404,29 @@ class Ie {
4401
4404
  return;
4402
4405
  }
4403
4406
  throw this.logger.error(
4404
- `Stream log lines for ${y(this.rInfo.id)} failed, reason: ${e}`
4407
+ `Stream log lines for ${b(this.rInfo.id)} failed, reason: ${e}`
4405
4408
  ), e;
4406
4409
  }
4407
4410
  }
4408
4411
  }
4409
- function se(s, e) {
4412
+ function ie(s, e) {
4410
4413
  if (!e.name.startsWith("StreamWorkdir"))
4411
- throw new Pe(
4414
+ throw new Ue(
4412
4415
  `${s}: wrong resource type: ${e.name}, expected: a resource of type 'StreamWorkdir'.`
4413
4416
  );
4414
4417
  }
4415
- class Nr {
4418
+ class $r {
4416
4419
  constructor(e, t, o) {
4417
4420
  this.logger = e, this.logsStreamDriver = t, this.downloadDriver = o;
4418
4421
  }
4419
4422
  getLastLogs(e, t, o) {
4420
- if (o === void 0) return w.make((r) => this.getLastLogs(e, t, r));
4421
- const n = W(o, e);
4423
+ if (o === void 0) return y.make((r) => this.getLastLogs(e, t, r));
4424
+ const n = z(o, e);
4422
4425
  if (n === void 0) {
4423
4426
  o.markUnstable("no stream in stream manager");
4424
4427
  return;
4425
4428
  }
4426
- if (F(n)) return this.downloadDriver.getLastLogs(n, t, o);
4429
+ if (W(n)) return this.downloadDriver.getLastLogs(n, t, o);
4427
4430
  try {
4428
4431
  return this.logsStreamDriver.getLastLogs(n, t, o);
4429
4432
  } catch (r) {
@@ -4436,13 +4439,13 @@ class Nr {
4436
4439
  }
4437
4440
  getProgressLog(e, t, o) {
4438
4441
  if (o === void 0)
4439
- return w.make((r) => this.getProgressLog(e, t, r));
4440
- const n = W(o, e);
4442
+ return y.make((r) => this.getProgressLog(e, t, r));
4443
+ const n = z(o, e);
4441
4444
  if (n === void 0) {
4442
4445
  o.markUnstable("no stream in stream manager");
4443
4446
  return;
4444
4447
  }
4445
- if (F(n)) return this.downloadDriver.getProgressLog(n, t, o);
4448
+ if (W(n)) return this.downloadDriver.getProgressLog(n, t, o);
4446
4449
  try {
4447
4450
  return this.logsStreamDriver.getProgressLog(n, t, o);
4448
4451
  } catch (r) {
@@ -4455,13 +4458,13 @@ class Nr {
4455
4458
  }
4456
4459
  getProgressLogWithInfo(e, t, o) {
4457
4460
  if (o === void 0)
4458
- return w.make((r) => this.getProgressLogWithInfo(e, t, r));
4459
- const n = W(o, e);
4461
+ return y.make((r) => this.getProgressLogWithInfo(e, t, r));
4462
+ const n = z(o, e);
4460
4463
  if (n === void 0) {
4461
4464
  o.markUnstable("no stream in stream manager");
4462
4465
  return;
4463
4466
  }
4464
- if (F(n))
4467
+ if (W(n))
4465
4468
  return {
4466
4469
  progressLine: this.downloadDriver.getProgressLog(n, t, o),
4467
4470
  live: !1
@@ -4480,29 +4483,29 @@ class Nr {
4480
4483
  }
4481
4484
  }
4482
4485
  getLogHandle(e, t) {
4483
- if (t === void 0) return w.make((n) => this.getLogHandle(e, n));
4484
- const o = W(t, e);
4486
+ if (t === void 0) return y.make((n) => this.getLogHandle(e, n));
4487
+ const o = z(t, e);
4485
4488
  if (o === void 0) {
4486
4489
  t.markUnstable("no stream in stream manager");
4487
4490
  return;
4488
4491
  }
4489
- return F(o) ? this.downloadDriver.getLogHandle(o, t) : this.logsStreamDriver.getLogHandle(o, t);
4492
+ return W(o) ? this.downloadDriver.getLogHandle(o, t) : this.logsStreamDriver.getLogHandle(o, t);
4490
4493
  }
4491
4494
  async lastLines(e, t, o, n) {
4492
- return A(e) ? await this.logsStreamDriver.lastLines(e, t, o, n) : await this.downloadDriver.lastLines(e, t, o, n);
4495
+ return M(e) ? await this.logsStreamDriver.lastLines(e, t, o, n) : await this.downloadDriver.lastLines(e, t, o, n);
4493
4496
  }
4494
4497
  async readText(e, t, o, n) {
4495
- return A(e) ? await this.logsStreamDriver.readText(e, t, o, n) : await this.downloadDriver.readText(e, t, o, n);
4498
+ return M(e) ? await this.logsStreamDriver.readText(e, t, o, n) : await this.downloadDriver.readText(e, t, o, n);
4496
4499
  }
4497
4500
  }
4498
- function F(s) {
4501
+ function W(s) {
4499
4502
  return !s.type.name.startsWith("StreamWorkdir");
4500
4503
  }
4501
- function W(s, e) {
4504
+ function z(s, e) {
4502
4505
  var t;
4503
4506
  return (t = s.accessor(e).node().traverse("stream")) == null ? void 0 : t.resourceInfo;
4504
4507
  }
4505
- class $r {
4508
+ class Br {
4506
4509
  constructor(e, t, o, n = {
4507
4510
  cacheSoftSizeBytes: 50 * 1024 * 1024,
4508
4511
  withGunzip: !0,
@@ -4514,11 +4517,11 @@ class $r {
4514
4517
  /** Writes and removes files to a hard drive and holds a counter for every
4515
4518
  * file that should be kept. */
4516
4519
  d(this, "cache");
4517
- this.logger = e, this.saveDir = o, this.opts = n, this.downloadQueue = new j(this.logger, this.opts.nConcurrentDownloads), this.cache = new Le(this.opts.cacheSoftSizeBytes), this.downloadHelper = new je(t);
4520
+ this.logger = e, this.saveDir = o, this.opts = n, this.downloadQueue = new G(this.logger, this.opts.nConcurrentDownloads), this.cache = new Pe(this.opts.cacheSoftSizeBytes), this.downloadHelper = new Ge(t);
4518
4521
  }
4519
4522
  getPath(e, t) {
4520
- if (t === void 0) return w.make((r) => this.getPath(e, r));
4521
- const o = U();
4523
+ if (t === void 0) return y.make((r) => this.getPath(e, r));
4524
+ const o = D();
4522
4525
  t.addOnDestroy(() => this.releasePath(e, o));
4523
4526
  const n = this.getPathNoCtx(e, t.watcher, o);
4524
4527
  return (n == null ? void 0 : n.path) === void 0 && t.markUnstable(
@@ -4549,45 +4552,45 @@ class $r {
4549
4552
  const r = this.cache.removeFile(n.path, t);
4550
4553
  await Promise.all(
4551
4554
  r.map(async (a) => {
4552
- await he(a.path), this.cache.removeCache(a), this.removeTask(
4555
+ await ue(a.path), this.cache.removeCache(a), this.removeTask(
4553
4556
  a,
4554
- `the task ${y(a.info())} was removedfrom cache along with ${y(r.map((i) => i.info()))}`
4557
+ `the task ${b(a.info())} was removedfrom cache along with ${b(r.map((i) => i.info()))}`
4555
4558
  );
4556
4559
  })
4557
4560
  );
4558
4561
  } else
4559
4562
  n.counter.dec(t) && this.removeTask(
4560
4563
  n,
4561
- `the task ${y(n.info())} was removed from cache`
4564
+ `the task ${b(n.info())} was removed from cache`
4562
4565
  );
4563
4566
  }
4564
4567
  /** Removes all files from a hard drive. */
4565
4568
  async releaseAll() {
4566
4569
  this.downloadQueue.stop(), await Promise.all(
4567
4570
  Array.from(this.urlToDownload.entries()).map(async ([e, t]) => {
4568
- await he(t.path), this.cache.removeCache(t), this.removeTask(
4571
+ await ue(t.path), this.cache.removeCache(t), this.removeTask(
4569
4572
  t,
4570
- `the task ${y(t.info())} was released when the driver was closed`
4573
+ `the task ${b(t.info())} was released when the driver was closed`
4571
4574
  );
4572
4575
  })
4573
4576
  );
4574
4577
  }
4575
4578
  setNewTask(e, t, o) {
4576
- const n = new Wn(this.logger, this.getFilePath(t), t);
4579
+ const n = new zn(this.logger, this.getFilePath(t), t);
4577
4580
  return n.attach(e, o), this.urlToDownload.set(t.toString(), n), n;
4578
4581
  }
4579
4582
  removeTask(e, t) {
4580
4583
  e.abort(t), e.change.markChanged(), this.urlToDownload.delete(e.url.toString());
4581
4584
  }
4582
4585
  getFilePath(e) {
4583
- const t = ft("sha256").update(e.toString()).digest("hex");
4584
- return b.join(this.saveDir, t);
4586
+ const t = mt("sha256").update(e.toString()).digest("hex");
4587
+ return T.join(this.saveDir, t);
4585
4588
  }
4586
4589
  }
4587
- class Wn {
4590
+ class zn {
4588
4591
  constructor(e, t, o) {
4589
- d(this, "counter", new v());
4590
- d(this, "change", new N());
4592
+ d(this, "counter", new N());
4593
+ d(this, "change", new $());
4591
4594
  d(this, "signalCtl", new AbortController());
4592
4595
  d(this, "error");
4593
4596
  d(this, "done", !1);
@@ -4611,30 +4614,30 @@ class Wn {
4611
4614
  const o = await this.downloadAndUntar(e, t, this.signalCtl.signal);
4612
4615
  this.setDone(o), this.change.markChanged();
4613
4616
  } catch (o) {
4614
- if (o instanceof ve || o instanceof V) {
4615
- this.setError(o), this.change.markChanged(), await he(this.path);
4617
+ if (o instanceof Ne || o instanceof q) {
4618
+ this.setError(o), this.change.markChanged(), await ue(this.path);
4616
4619
  return;
4617
4620
  }
4618
4621
  throw o;
4619
4622
  }
4620
4623
  }
4621
4624
  async downloadAndUntar(e, t, o) {
4622
- if (await pe(b.dirname(this.path)), await ge(this.path))
4623
- return await tt(this.path);
4625
+ if (await ge(T.dirname(this.path)), await fe(this.path))
4626
+ return await ot(this.path);
4624
4627
  const n = await e.download(this.url.toString(), {}, o);
4625
4628
  let r = n.content;
4626
4629
  if (t) {
4627
- const a = Ce.toWeb(Fe.createGunzip());
4630
+ const a = _e.toWeb(We.createGunzip());
4628
4631
  r = r.pipeThrough(a, { signal: o });
4629
4632
  }
4630
- return await fe(this.logger, this.path, async (a) => {
4633
+ return await me(this.logger, this.path, async (a) => {
4631
4634
  await m.mkdir(a);
4632
- const i = S.toWeb(le.extract(a));
4635
+ const i = I.toWeb(ce.extract(a));
4633
4636
  await r.pipeTo(i, { signal: o });
4634
4637
  }), n.size;
4635
4638
  }
4636
4639
  getPath() {
4637
- if (this.done) return { path: H(this.path) };
4640
+ if (this.done) return { path: j(this.path) };
4638
4641
  if (this.error) return { error: this.error };
4639
4642
  }
4640
4643
  setDone(e) {
@@ -4644,30 +4647,30 @@ class Wn {
4644
4647
  this.error = String(e);
4645
4648
  }
4646
4649
  abort(e) {
4647
- this.signalCtl.abort(new ve(e));
4650
+ this.signalCtl.abort(new Ne(e));
4648
4651
  }
4649
4652
  }
4650
- class ve extends Error {
4653
+ class Ne extends Error {
4651
4654
  }
4652
- async function tt(s) {
4655
+ async function ot(s) {
4653
4656
  const e = await m.readdir(s, { withFileTypes: !0 });
4654
4657
  return (await Promise.all(
4655
4658
  e.map(async (o) => {
4656
- const n = b.join(s, o.name);
4657
- return o.isDirectory() ? await tt(n) : (await m.stat(n)).size;
4659
+ const n = T.join(s, o.name);
4660
+ return o.isDirectory() ? await ot(n) : (await m.stat(n)).size;
4658
4661
  })
4659
4662
  )).reduce((o, n) => o + n, 0);
4660
4663
  }
4661
- async function he(s) {
4664
+ async function ue(s) {
4662
4665
  await m.rm(s, { recursive: !0, force: !0 });
4663
4666
  }
4664
- function ie(s, e) {
4667
+ function ae(s, e) {
4665
4668
  return `index://index/${encodeURIComponent(JSON.stringify({
4666
4669
  storageId: s,
4667
4670
  path: e
4668
4671
  }))}`;
4669
4672
  }
4670
- function zn(s, e, t, o) {
4673
+ function xn(s, e, t, o) {
4671
4674
  const n = {
4672
4675
  localPath: s,
4673
4676
  pathSignature: e.sign(s),
@@ -4676,32 +4679,32 @@ function zn(s, e, t, o) {
4676
4679
  };
4677
4680
  return `upload://upload/${encodeURIComponent(JSON.stringify(n))}`;
4678
4681
  }
4679
- function xn(s) {
4682
+ function An(s) {
4680
4683
  const e = new URL(s);
4681
- return q.parse(
4684
+ return J.parse(
4682
4685
  JSON.parse(decodeURIComponent(e.pathname.substring(1)))
4683
4686
  );
4684
4687
  }
4685
- function An(s) {
4688
+ function Mn(s) {
4686
4689
  const e = new URL(s);
4687
- return qe.parse(JSON.parse(decodeURIComponent(e.pathname.substring(1))));
4690
+ return Je.parse(JSON.parse(decodeURIComponent(e.pathname.substring(1))));
4688
4691
  }
4689
- function Ne(s) {
4690
- if (Gn(s))
4691
- return qn(s);
4692
- if (Mn(s))
4693
- return jn(s);
4694
- ut(s);
4692
+ function $e(s) {
4693
+ if (Vn(s))
4694
+ return Jn(s);
4695
+ if (Hn(s))
4696
+ return Gn(s);
4697
+ pt(s);
4695
4698
  }
4696
- const ot = /^local:\/\/(?<name>.*)\/(?<path>.*)$/;
4697
- function Mn(s) {
4698
- return ot.test(s);
4699
+ const nt = /^local:\/\/(?<name>.*)\/(?<path>.*)$/;
4700
+ function Hn(s) {
4701
+ return nt.test(s);
4699
4702
  }
4700
- function Hn(s, e) {
4703
+ function jn(s, e) {
4701
4704
  return `local://${s}/${encodeURIComponent(e)}`;
4702
4705
  }
4703
- function jn(s) {
4704
- const e = s.match(ot);
4706
+ function Gn(s) {
4707
+ const e = s.match(nt);
4705
4708
  if (e == null) throw new Error(`Local list handle wasn't parsed: ${s}`);
4706
4709
  const { name: t, path: o } = e.groups;
4707
4710
  return {
@@ -4710,30 +4713,30 @@ function jn(s) {
4710
4713
  isRemote: !1
4711
4714
  };
4712
4715
  }
4713
- const nt = /^remote:\/\/(?<name>.*)\/(?<resourceId>.*)$/;
4714
- function Gn(s) {
4715
- return nt.test(s);
4716
+ const rt = /^remote:\/\/(?<name>.*)\/(?<resourceId>.*)$/;
4717
+ function Vn(s) {
4718
+ return rt.test(s);
4716
4719
  }
4717
- function Vn(s, e) {
4720
+ function qn(s, e) {
4718
4721
  return `remote://${s}/${BigInt(e)}`;
4719
4722
  }
4720
- function qn(s) {
4721
- const e = s.match(nt);
4723
+ function Jn(s) {
4724
+ const e = s.match(rt);
4722
4725
  if (e == null) throw new Error(`Remote list handle wasn't parsed: ${s}`);
4723
4726
  const { name: t, resourceId: o } = e.groups;
4724
4727
  return {
4725
- id: ue(BigInt(o)),
4726
- type: Jn(t),
4728
+ id: pe(BigInt(o)),
4729
+ type: Zn(t),
4727
4730
  name: t,
4728
4731
  isRemote: !0
4729
4732
  };
4730
4733
  }
4731
- function Jn(s) {
4734
+ function Zn(s) {
4732
4735
  return { name: `LS/${s}`, version: "1" };
4733
4736
  }
4734
- async function Zn() {
4735
- const s = mt.homedir();
4736
- if (L.sep == "/")
4737
+ async function Qn() {
4738
+ const s = wt.homedir();
4739
+ if (P.sep == "/")
4737
4740
  return [
4738
4741
  {
4739
4742
  name: "local",
@@ -4742,9 +4745,9 @@ async function Zn() {
4742
4745
  }
4743
4746
  ];
4744
4747
  {
4745
- const t = L.parse(s).root.replaceAll(":\\", "");
4748
+ const t = P.parse(s).root.replaceAll(":\\", "");
4746
4749
  try {
4747
- return (await kt.promisify(Lt)("wmic logicaldisk get name")).stdout.split(`\r
4750
+ return (await Lt.promisify(Pt)("wmic logicaldisk get name")).stdout.split(`\r
4748
4751
  `).filter((r) => r.includes(":")).map((r) => r.trim().replaceAll(":", "")).map((r) => {
4749
4752
  const a = r == t;
4750
4753
  return {
@@ -4764,7 +4767,7 @@ async function Zn() {
4764
4767
  }
4765
4768
  }
4766
4769
  }
4767
- class rt {
4770
+ class st {
4768
4771
  constructor(e, t, o, n, r, a, i) {
4769
4772
  this.logger = e, this.lsClient = t, this.storageIdToResourceId = o, this.signer = n, this.virtualStoragesMap = r, this.localProjectionsMap = a, this.openFileDialogCallback = i;
4770
4773
  }
@@ -4796,13 +4799,13 @@ class rt {
4796
4799
  * @private
4797
4800
  */
4798
4801
  async tryResolveLocalFileHandle(e) {
4799
- if (Tt(e)) {
4800
- const t = An(e), o = this.localProjectionsMap.get(t.storageId);
4802
+ if (kt(e)) {
4803
+ const t = Mn(e), o = this.localProjectionsMap.get(t.storageId);
4801
4804
  if (!o)
4802
4805
  throw new Error(`Storage ${t.storageId} is not mounted locally.`);
4803
- return b.join(o.localPath, t.path);
4806
+ return T.join(o.localPath, t.path);
4804
4807
  } else {
4805
- const t = xn(e);
4808
+ const t = An(e);
4806
4809
  this.signer.verify(
4807
4810
  t.localPath,
4808
4811
  t.pathSignature,
@@ -4815,17 +4818,17 @@ class rt {
4815
4818
  }
4816
4819
  }
4817
4820
  async getLocalFileHandle(e) {
4818
- C(e);
4821
+ _(e);
4819
4822
  for (const o of this.localProjectionsMap.values())
4820
4823
  if (e.startsWith(o.localPath)) {
4821
- const n = o.localPath === "" ? e : b.relative(o.localPath, e);
4822
- return ie(
4824
+ const n = o.localPath === "" ? e : T.relative(o.localPath, e);
4825
+ return ae(
4823
4826
  o.storageId,
4824
4827
  n
4825
4828
  );
4826
4829
  }
4827
4830
  const t = await m.stat(e, { bigint: !0 });
4828
- return zn(
4831
+ return xn(
4829
4832
  e,
4830
4833
  this.signer,
4831
4834
  t.size,
@@ -4836,12 +4839,12 @@ class rt {
4836
4839
  async getStorageList() {
4837
4840
  const e = [...this.virtualStoragesMap.values()].map((n) => ({
4838
4841
  name: n.name,
4839
- handle: Hn(n.name, n.root),
4842
+ handle: jn(n.name, n.root),
4840
4843
  initialFullPath: n.initialPath
4841
4844
  })), o = Object.entries(this.storageIdToResourceId).map(
4842
4845
  ([n, r]) => ({
4843
4846
  name: n,
4844
- handle: Vn(n, r),
4847
+ handle: qn(n, r),
4845
4848
  initialFullPath: "",
4846
4849
  // we don't have any additional information from where to start browsing remote storages
4847
4850
  isInitialPathHome: !1
@@ -4850,21 +4853,21 @@ class rt {
4850
4853
  return [...e, ...o];
4851
4854
  }
4852
4855
  async listFiles(e, t) {
4853
- const o = Ne(e);
4856
+ const o = $e(e);
4854
4857
  if (o.isRemote)
4855
4858
  return {
4856
4859
  entries: (await this.lsClient.list(o, t)).items.map((i) => ({
4857
4860
  type: i.isDir ? "dir" : "file",
4858
4861
  name: i.name,
4859
4862
  fullPath: i.fullName,
4860
- handle: ie(o.name, i.fullName)
4863
+ handle: ae(o.name, i.fullName)
4861
4864
  }))
4862
4865
  };
4863
- b.sep === "/" && t === "" && (t = "/"), o.rootPath === "" && C(t);
4864
- const n = b.isAbsolute(t) ? t : b.join(o.rootPath, t), r = [];
4866
+ T.sep === "/" && t === "" && (t = "/"), o.rootPath === "" && _(t);
4867
+ const n = T.isAbsolute(t) ? t : T.join(o.rootPath, t), r = [];
4865
4868
  for await (const a of await m.opendir(n)) {
4866
4869
  if (!a.isFile() && !a.isDirectory()) continue;
4867
- const i = b.join(n, a.name);
4870
+ const i = T.join(n, a.name);
4868
4871
  r.push({
4869
4872
  type: a.isFile() ? "file" : "dir",
4870
4873
  name: a.name,
@@ -4875,7 +4878,7 @@ class rt {
4875
4878
  return { entries: r };
4876
4879
  }
4877
4880
  async listRemoteFilesWithAdditionalInfo(e, t) {
4878
- const o = Ne(e);
4881
+ const o = $e(e);
4879
4882
  if (!o.isRemote)
4880
4883
  throw new Error(`Storage ${o.name} is not remote`);
4881
4884
  return {
@@ -4883,7 +4886,7 @@ class rt {
4883
4886
  type: r.isDir ? "dir" : "file",
4884
4887
  name: r.name,
4885
4888
  fullPath: r.fullName,
4886
- handle: ie(o.name, r.fullName),
4889
+ handle: ae(o.name, r.fullName),
4887
4890
  size: Number(r.size)
4888
4891
  }))
4889
4892
  };
@@ -4894,19 +4897,19 @@ class rt {
4894
4897
  );
4895
4898
  }
4896
4899
  static async init(e, t, o, n, r, a) {
4897
- const i = Ko(t, e);
4898
- a || (a = await Zn());
4899
- for (const p of a) C(p.root);
4900
- for (const p of n) p.localPath !== "" && C(p.localPath);
4900
+ const i = Yo(t, e);
4901
+ a || (a = await Qn());
4902
+ for (const p of a) _(p.root);
4903
+ for (const p of n) p.localPath !== "" && _(p.localPath);
4901
4904
  const c = new Map(a.map((p) => [p.name, p])), l = new Map(n.map((p) => [p.storageId, p]));
4902
4905
  if ((/* @__PURE__ */ new Set([...c.keys(), ...l.keys()])).size !== c.size + l.size)
4903
4906
  throw new Error(
4904
4907
  "Intersection between local projection storage ids and virtual storages names detected."
4905
4908
  );
4906
- return new rt(
4909
+ return new st(
4907
4910
  e,
4908
4911
  i,
4909
- await Qn(t),
4912
+ await Xn(t),
4910
4913
  o,
4911
4914
  c,
4912
4915
  l,
@@ -4914,62 +4917,64 @@ class rt {
4914
4917
  );
4915
4918
  }
4916
4919
  }
4917
- async function Qn(s) {
4920
+ async function Xn(s) {
4918
4921
  return s.withReadTx("GetAvailableStorageIds", async (e) => {
4919
4922
  const t = await e.getResourceByName("LSProvider"), o = await e.getResourceData(t, !0);
4920
- return Xn(o);
4923
+ return Kn(o);
4921
4924
  });
4922
4925
  }
4923
- function Xn(s) {
4926
+ function Kn(s) {
4924
4927
  return Object.fromEntries(
4925
- s.fields.filter((e) => e.type == "Dynamic" && ct(e.value)).map((e) => [e.name.substring(8), e.value])
4928
+ s.fields.filter((e) => e.type == "Dynamic" && dt(e.value)).map((e) => [e.name.substring(8), e.value])
4926
4929
  );
4927
4930
  }
4928
4931
  export {
4929
- Lo as ClientDownload,
4930
- Xo as ClientLogs,
4931
- Fo as ClientLs,
4932
- uo as ClientProgress,
4933
- Vt as ClientUpload,
4934
- Zn as DefaultVirtualLocalStorages,
4935
- Sr as DownloadBlobToURLDriver,
4936
- Dr as DownloadDriver,
4937
- $r as DownloadUrlDriver,
4938
- fn as DownloadableBlobSnapshot,
4939
- Ur as ImportFileHandleData,
4940
- qe as ImportFileHandleIndexData,
4941
- q as ImportFileHandleUploadData,
4942
- sn as IndexResourceSnapshot,
4943
- Nr as LogsDriver,
4944
- vr as LogsStreamDriver,
4945
- rt as LsDriver,
4946
- xe as MTimeError,
4947
- Me as NetworkError,
4948
- He as NoFileForUploading,
4949
- on as OnDemandBlobResourceSnapshot,
4950
- Ae as UnexpectedEOF,
4951
- Te as UnknownStorageError,
4952
- hn as Updater,
4953
- Ir as UploadDriver,
4954
- rn as UploadResourceSnapshot,
4955
- Pn as UploadTask,
4956
- be as WrongLocalFileUrl,
4957
- Pe as WrongResourceTypeError,
4958
- Tr as createDownloadClient,
4959
- kr as createLogsClient,
4960
- Ko as createLsFilesClient,
4961
- Pr as createUploadBlobClient,
4962
- Lr as createUploadProgressClient,
4963
- Uo as getFullPath,
4964
- nn as getSize,
4965
- Rn as isMyUpload,
4966
- Se as isResourceWasDeletedError,
4967
- En as makeBlobImportSnapshot,
4968
- mn as makeDownloadableBlobSnapshot,
4969
- So as newLocalStorageIdsToRoot,
4970
- et as nonRecoverableError,
4971
- Po as parseLocalUrl,
4972
- Un as uploadBlob,
4973
- C as validateAbsolute
4932
+ Po as ClientDownload,
4933
+ Ko as ClientLogs,
4934
+ Wo as ClientLs,
4935
+ po as ClientProgress,
4936
+ qt as ClientUpload,
4937
+ Qn as DefaultVirtualLocalStorages,
4938
+ Ir as DownloadBlobToURLDriver,
4939
+ Rr as DownloadDriver,
4940
+ Br as DownloadUrlDriver,
4941
+ mn as DownloadableBlobSnapshot,
4942
+ Dr as ImportFileHandleData,
4943
+ Je as ImportFileHandleIndexData,
4944
+ J as ImportFileHandleUploadData,
4945
+ an as IndexResourceSnapshot,
4946
+ $r as LogsDriver,
4947
+ Nr as LogsStreamDriver,
4948
+ st as LsDriver,
4949
+ Ae as MTimeError,
4950
+ He as NetworkError,
4951
+ je as NoFileForUploading,
4952
+ nn as OnDemandBlobResourceSnapshot,
4953
+ Me as UnexpectedEOF,
4954
+ ke as UnknownStorageError,
4955
+ un as Updater,
4956
+ vr as UploadDriver,
4957
+ sn as UploadResourceSnapshot,
4958
+ Un as UploadTask,
4959
+ Te as WrongLocalFileUrl,
4960
+ Ue as WrongResourceTypeError,
4961
+ kr as createDownloadClient,
4962
+ Lr as createLogsClient,
4963
+ Yo as createLsFilesClient,
4964
+ Ur as createUploadBlobClient,
4965
+ Pr as createUploadProgressClient,
4966
+ Do as getFullPath,
4967
+ rn as getSize,
4968
+ Sn as isMyUpload,
4969
+ Ie as isResourceWasDeletedError,
4970
+ Nn as isSignMatch,
4971
+ he as isUpload,
4972
+ On as makeBlobImportSnapshot,
4973
+ wn as makeDownloadableBlobSnapshot,
4974
+ Io as newLocalStorageIdsToRoot,
4975
+ tt as nonRecoverableError,
4976
+ Uo as parseLocalUrl,
4977
+ Dn as uploadBlob,
4978
+ _ as validateAbsolute
4974
4979
  };
4975
4980
  //# sourceMappingURL=index.mjs.map