@camstack/system 1.1.6 → 1.1.7

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.
@@ -3,19 +3,3006 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_tar$1 = require("../../tar-BgAEMRBR.js");
7
6
  let node_fs = require("node:fs");
7
+ let node_fs$1 = require_chunk.__toESM(node_fs, 1);
8
8
  node_fs = require_chunk.__toESM(node_fs);
9
9
  let node_path = require("node:path");
10
+ let node_path$1 = require_chunk.__toESM(node_path, 1);
10
11
  node_path = require_chunk.__toESM(node_path);
11
12
  let _camstack_types = require("@camstack/types");
12
13
  let node_crypto = require("node:crypto");
13
14
  let node_fs_promises = require("node:fs/promises");
15
+ let node_fs_promises$1 = require_chunk.__toESM(node_fs_promises, 1);
14
16
  node_fs_promises = require_chunk.__toESM(node_fs_promises);
17
+ let buffer = require("buffer");
18
+ let node_events = require("node:events");
19
+ let node_stream = require("node:stream");
20
+ node_stream = require_chunk.__toESM(node_stream, 1);
21
+ let node_string_decoder = require("node:string_decoder");
22
+ let fs = require("fs");
23
+ fs = require_chunk.__toESM(fs, 1);
24
+ let path = require("path");
25
+ path = require_chunk.__toESM(path, 1);
26
+ let zlib = require("zlib");
27
+ zlib = require_chunk.__toESM(zlib, 1);
28
+ let assert = require("assert");
29
+ assert = require_chunk.__toESM(assert, 1);
30
+ let events = require("events");
31
+ events = require_chunk.__toESM(events, 1);
15
32
  let node_zlib = require("node:zlib");
16
33
  node_zlib = require_chunk.__toESM(node_zlib);
34
+ let node_assert = require("node:assert");
35
+ node_assert = require_chunk.__toESM(node_assert, 1);
36
+ //#region node_modules/tar/dist/esm/index.min.js
37
+ var Mr = Object.defineProperty;
38
+ var Br = (s, t) => {
39
+ for (var e in t) Mr(s, e, {
40
+ get: t[e],
41
+ enumerable: !0
42
+ });
43
+ };
44
+ var xs = typeof process == "object" && process ? process : {
45
+ stdout: null,
46
+ stderr: null
47
+ }, zr = (s) => !!s && typeof s == "object" && (s instanceof A$1 || s instanceof node_stream.default || Ur(s) || Hr(s)), Ur = (s) => !!s && typeof s == "object" && s instanceof node_events.EventEmitter && typeof s.pipe == "function" && s.pipe !== node_stream.default.Writable.prototype.pipe, Hr = (s) => !!s && typeof s == "object" && s instanceof node_events.EventEmitter && typeof s.write == "function" && typeof s.end == "function", q = Symbol("EOF"), Q = Symbol("maybeEmitEnd"), rt = Symbol("emittedEnd"), Le = Symbol("emittingEnd"), qt = Symbol("emittedError"), Ne = Symbol("closed"), Ls = Symbol("read"), De = Symbol("flush"), Ns = Symbol("flushChunk"), z = Symbol("encoding"), Mt = Symbol("decoder"), g$1 = Symbol("flowing"), Qt = Symbol("paused"), Bt = Symbol("resume"), b$1 = Symbol("buffer"), D$1 = Symbol("pipes"), _$1 = Symbol("bufferLength"), gi = Symbol("bufferPush"), Ae = Symbol("bufferShift"), L = Symbol("objectMode"), w$1 = Symbol("destroyed"), bi = Symbol("error"), _i = Symbol("emitData"), Ds = Symbol("emitEnd"), Oi = Symbol("emitEnd2"), Z = Symbol("async"), Ti = Symbol("abort"), Ie = Symbol("aborted"), Jt = Symbol("signal"), Rt = Symbol("dataListeners"), F = Symbol("discarded"), jt = (s) => Promise.resolve().then(s), Wr = (s) => s(), Gr = (s) => s === "end" || s === "finish" || s === "prefinish", Zr = (s) => s instanceof ArrayBuffer || !!s && typeof s == "object" && s.constructor && s.constructor.name === "ArrayBuffer" && s.byteLength >= 0, Yr = (s) => !Buffer.isBuffer(s) && ArrayBuffer.isView(s), Fe = class {
48
+ src;
49
+ dest;
50
+ opts;
51
+ ondrain;
52
+ constructor(t, e, i) {
53
+ this.src = t, this.dest = e, this.opts = i, this.ondrain = () => t[Bt](), this.dest.on("drain", this.ondrain);
54
+ }
55
+ unpipe() {
56
+ this.dest.removeListener("drain", this.ondrain);
57
+ }
58
+ proxyErrors(t) {}
59
+ end() {
60
+ this.unpipe(), this.opts.end && this.dest.end();
61
+ }
62
+ }, xi = class extends Fe {
63
+ unpipe() {
64
+ this.src.removeListener("error", this.proxyErrors), super.unpipe();
65
+ }
66
+ constructor(t, e, i) {
67
+ super(t, e, i), this.proxyErrors = (r) => this.dest.emit("error", r), t.on("error", this.proxyErrors);
68
+ }
69
+ }, Kr = (s) => !!s.objectMode, Vr = (s) => !s.objectMode && !!s.encoding && s.encoding !== "buffer", A$1 = class extends node_events.EventEmitter {
70
+ [g$1] = !1;
71
+ [Qt] = !1;
72
+ [D$1] = [];
73
+ [b$1] = [];
74
+ [L];
75
+ [z];
76
+ [Z];
77
+ [Mt];
78
+ [q] = !1;
79
+ [rt] = !1;
80
+ [Le] = !1;
81
+ [Ne] = !1;
82
+ [qt] = null;
83
+ [_$1] = 0;
84
+ [w$1] = !1;
85
+ [Jt];
86
+ [Ie] = !1;
87
+ [Rt] = 0;
88
+ [F] = !1;
89
+ writable = !0;
90
+ readable = !0;
91
+ constructor(...t) {
92
+ let e = t[0] || {};
93
+ if (super(), e.objectMode && typeof e.encoding == "string") throw new TypeError("Encoding and objectMode may not be used together");
94
+ Kr(e) ? (this[L] = !0, this[z] = null) : Vr(e) ? (this[z] = e.encoding, this[L] = !1) : (this[L] = !1, this[z] = null), this[Z] = !!e.async, this[Mt] = this[z] ? new node_string_decoder.StringDecoder(this[z]) : null, e && e.debugExposeBuffer === !0 && Object.defineProperty(this, "buffer", { get: () => this[b$1] }), e && e.debugExposePipes === !0 && Object.defineProperty(this, "pipes", { get: () => this[D$1] });
95
+ let { signal: i } = e;
96
+ i && (this[Jt] = i, i.aborted ? this[Ti]() : i.addEventListener("abort", () => this[Ti]()));
97
+ }
98
+ get bufferLength() {
99
+ return this[_$1];
100
+ }
101
+ get encoding() {
102
+ return this[z];
103
+ }
104
+ set encoding(t) {
105
+ throw new Error("Encoding must be set at instantiation time");
106
+ }
107
+ setEncoding(t) {
108
+ throw new Error("Encoding must be set at instantiation time");
109
+ }
110
+ get objectMode() {
111
+ return this[L];
112
+ }
113
+ set objectMode(t) {
114
+ throw new Error("objectMode must be set at instantiation time");
115
+ }
116
+ get async() {
117
+ return this[Z];
118
+ }
119
+ set async(t) {
120
+ this[Z] = this[Z] || !!t;
121
+ }
122
+ [Ti]() {
123
+ this[Ie] = !0, this.emit("abort", this[Jt]?.reason), this.destroy(this[Jt]?.reason);
124
+ }
125
+ get aborted() {
126
+ return this[Ie];
127
+ }
128
+ set aborted(t) {}
129
+ write(t, e, i) {
130
+ if (this[Ie]) return !1;
131
+ if (this[q]) throw new Error("write after end");
132
+ if (this[w$1]) return this.emit("error", Object.assign(/* @__PURE__ */ new Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" })), !0;
133
+ typeof e == "function" && (i = e, e = "utf8"), e || (e = "utf8");
134
+ let r = this[Z] ? jt : Wr;
135
+ if (!this[L] && !Buffer.isBuffer(t)) {
136
+ if (Yr(t)) t = Buffer.from(t.buffer, t.byteOffset, t.byteLength);
137
+ else if (Zr(t)) t = Buffer.from(t);
138
+ else if (typeof t != "string") throw new Error("Non-contiguous data written to non-objectMode stream");
139
+ }
140
+ return this[L] ? (this[g$1] && this[_$1] !== 0 && this[De](!0), this[g$1] ? this.emit("data", t) : this[gi](t), this[_$1] !== 0 && this.emit("readable"), i && r(i), this[g$1]) : t.length ? (typeof t == "string" && !(e === this[z] && !this[Mt]?.lastNeed) && (t = Buffer.from(t, e)), Buffer.isBuffer(t) && this[z] && (t = this[Mt].write(t)), this[g$1] && this[_$1] !== 0 && this[De](!0), this[g$1] ? this.emit("data", t) : this[gi](t), this[_$1] !== 0 && this.emit("readable"), i && r(i), this[g$1]) : (this[_$1] !== 0 && this.emit("readable"), i && r(i), this[g$1]);
141
+ }
142
+ read(t) {
143
+ if (this[w$1]) return null;
144
+ if (this[F] = !1, this[_$1] === 0 || t === 0 || t && t > this[_$1]) return this[Q](), null;
145
+ this[L] && (t = null), this[b$1].length > 1 && !this[L] && (this[b$1] = [this[z] ? this[b$1].join("") : Buffer.concat(this[b$1], this[_$1])]);
146
+ let e = this[Ls](t || null, this[b$1][0]);
147
+ return this[Q](), e;
148
+ }
149
+ [Ls](t, e) {
150
+ if (this[L]) this[Ae]();
151
+ else {
152
+ let i = e;
153
+ t === i.length || t === null ? this[Ae]() : typeof i == "string" ? (this[b$1][0] = i.slice(t), e = i.slice(0, t), this[_$1] -= t) : (this[b$1][0] = i.subarray(t), e = i.subarray(0, t), this[_$1] -= t);
154
+ }
155
+ return this.emit("data", e), !this[b$1].length && !this[q] && this.emit("drain"), e;
156
+ }
157
+ end(t, e, i) {
158
+ return typeof t == "function" && (i = t, t = void 0), typeof e == "function" && (i = e, e = "utf8"), t !== void 0 && this.write(t, e), i && this.once("end", i), this[q] = !0, this.writable = !1, (this[g$1] || !this[Qt]) && this[Q](), this;
159
+ }
160
+ [Bt]() {
161
+ this[w$1] || (!this[Rt] && !this[D$1].length && (this[F] = !0), this[Qt] = !1, this[g$1] = !0, this.emit("resume"), this[b$1].length ? this[De]() : this[q] ? this[Q]() : this.emit("drain"));
162
+ }
163
+ resume() {
164
+ return this[Bt]();
165
+ }
166
+ pause() {
167
+ this[g$1] = !1, this[Qt] = !0, this[F] = !1;
168
+ }
169
+ get destroyed() {
170
+ return this[w$1];
171
+ }
172
+ get flowing() {
173
+ return this[g$1];
174
+ }
175
+ get paused() {
176
+ return this[Qt];
177
+ }
178
+ [gi](t) {
179
+ this[L] ? this[_$1] += 1 : this[_$1] += t.length, this[b$1].push(t);
180
+ }
181
+ [Ae]() {
182
+ return this[L] ? this[_$1] -= 1 : this[_$1] -= this[b$1][0].length, this[b$1].shift();
183
+ }
184
+ [De](t = !1) {
185
+ do ;
186
+ while (this[Ns](this[Ae]()) && this[b$1].length);
187
+ !t && !this[b$1].length && !this[q] && this.emit("drain");
188
+ }
189
+ [Ns](t) {
190
+ return this.emit("data", t), this[g$1];
191
+ }
192
+ pipe(t, e) {
193
+ if (this[w$1]) return t;
194
+ this[F] = !1;
195
+ let i = this[rt];
196
+ return e = e || {}, t === xs.stdout || t === xs.stderr ? e.end = !1 : e.end = e.end !== !1, e.proxyErrors = !!e.proxyErrors, i ? e.end && t.end() : (this[D$1].push(e.proxyErrors ? new xi(this, t, e) : new Fe(this, t, e)), this[Z] ? jt(() => this[Bt]()) : this[Bt]()), t;
197
+ }
198
+ unpipe(t) {
199
+ let e = this[D$1].find((i) => i.dest === t);
200
+ e && (this[D$1].length === 1 ? (this[g$1] && this[Rt] === 0 && (this[g$1] = !1), this[D$1] = []) : this[D$1].splice(this[D$1].indexOf(e), 1), e.unpipe());
201
+ }
202
+ addListener(t, e) {
203
+ return this.on(t, e);
204
+ }
205
+ on(t, e) {
206
+ let i = super.on(t, e);
207
+ if (t === "data") this[F] = !1, this[Rt]++, !this[D$1].length && !this[g$1] && this[Bt]();
208
+ else if (t === "readable" && this[_$1] !== 0) super.emit("readable");
209
+ else if (Gr(t) && this[rt]) super.emit(t), this.removeAllListeners(t);
210
+ else if (t === "error" && this[qt]) {
211
+ let r = e;
212
+ this[Z] ? jt(() => r.call(this, this[qt])) : r.call(this, this[qt]);
213
+ }
214
+ return i;
215
+ }
216
+ removeListener(t, e) {
217
+ return this.off(t, e);
218
+ }
219
+ off(t, e) {
220
+ let i = super.off(t, e);
221
+ return t === "data" && (this[Rt] = this.listeners("data").length, this[Rt] === 0 && !this[F] && !this[D$1].length && (this[g$1] = !1)), i;
222
+ }
223
+ removeAllListeners(t) {
224
+ let e = super.removeAllListeners(t);
225
+ return (t === "data" || t === void 0) && (this[Rt] = 0, !this[F] && !this[D$1].length && (this[g$1] = !1)), e;
226
+ }
227
+ get emittedEnd() {
228
+ return this[rt];
229
+ }
230
+ [Q]() {
231
+ !this[Le] && !this[rt] && !this[w$1] && this[b$1].length === 0 && this[q] && (this[Le] = !0, this.emit("end"), this.emit("prefinish"), this.emit("finish"), this[Ne] && this.emit("close"), this[Le] = !1);
232
+ }
233
+ emit(t, ...e) {
234
+ let i = e[0];
235
+ if (t !== "error" && t !== "close" && t !== w$1 && this[w$1]) return !1;
236
+ if (t === "data") return !this[L] && !i ? !1 : this[Z] ? (jt(() => this[_i](i)), !0) : this[_i](i);
237
+ if (t === "end") return this[Ds]();
238
+ if (t === "close") {
239
+ if (this[Ne] = !0, !this[rt] && !this[w$1]) return !1;
240
+ let n = super.emit("close");
241
+ return this.removeAllListeners("close"), n;
242
+ } else if (t === "error") {
243
+ this[qt] = i, super.emit(bi, i);
244
+ let n = !this[Jt] || this.listeners("error").length ? super.emit("error", i) : !1;
245
+ return this[Q](), n;
246
+ } else if (t === "resume") {
247
+ let n = super.emit("resume");
248
+ return this[Q](), n;
249
+ } else if (t === "finish" || t === "prefinish") {
250
+ let n = super.emit(t);
251
+ return this.removeAllListeners(t), n;
252
+ }
253
+ let r = super.emit(t, ...e);
254
+ return this[Q](), r;
255
+ }
256
+ [_i](t) {
257
+ for (let i of this[D$1]) i.dest.write(t) === !1 && this.pause();
258
+ let e = this[F] ? !1 : super.emit("data", t);
259
+ return this[Q](), e;
260
+ }
261
+ [Ds]() {
262
+ return this[rt] ? !1 : (this[rt] = !0, this.readable = !1, this[Z] ? (jt(() => this[Oi]()), !0) : this[Oi]());
263
+ }
264
+ [Oi]() {
265
+ if (this[Mt]) {
266
+ let e = this[Mt].end();
267
+ if (e) {
268
+ for (let i of this[D$1]) i.dest.write(e);
269
+ this[F] || super.emit("data", e);
270
+ }
271
+ }
272
+ for (let e of this[D$1]) e.end();
273
+ let t = super.emit("end");
274
+ return this.removeAllListeners("end"), t;
275
+ }
276
+ async collect() {
277
+ let t = Object.assign([], { dataLength: 0 });
278
+ this[L] || (t.dataLength = 0);
279
+ let e = this.promise();
280
+ return this.on("data", (i) => {
281
+ t.push(i), this[L] || (t.dataLength += i.length);
282
+ }), await e, t;
283
+ }
284
+ async concat() {
285
+ if (this[L]) throw new Error("cannot concat in objectMode");
286
+ let t = await this.collect();
287
+ return this[z] ? t.join("") : Buffer.concat(t, t.dataLength);
288
+ }
289
+ async promise() {
290
+ return new Promise((t, e) => {
291
+ this.on(w$1, () => e(/* @__PURE__ */ new Error("stream destroyed"))), this.on("error", (i) => e(i)), this.on("end", () => t());
292
+ });
293
+ }
294
+ [Symbol.asyncIterator]() {
295
+ this[F] = !1;
296
+ let t = !1, e = async () => (this.pause(), t = !0, {
297
+ value: void 0,
298
+ done: !0
299
+ });
300
+ return {
301
+ next: () => {
302
+ if (t) return e();
303
+ let r = this.read();
304
+ if (r !== null) return Promise.resolve({
305
+ done: !1,
306
+ value: r
307
+ });
308
+ if (this[q]) return e();
309
+ let n, o, a = (d) => {
310
+ this.off("data", h), this.off("end", l), this.off(w$1, c), e(), o(d);
311
+ }, h = (d) => {
312
+ this.off("error", a), this.off("end", l), this.off(w$1, c), this.pause(), n({
313
+ value: d,
314
+ done: !!this[q]
315
+ });
316
+ }, l = () => {
317
+ this.off("error", a), this.off("data", h), this.off(w$1, c), e(), n({
318
+ done: !0,
319
+ value: void 0
320
+ });
321
+ }, c = () => a(/* @__PURE__ */ new Error("stream destroyed"));
322
+ return new Promise((d, S) => {
323
+ o = S, n = d, this.once(w$1, c), this.once("error", a), this.once("end", l), this.once("data", h);
324
+ });
325
+ },
326
+ throw: e,
327
+ return: e,
328
+ [Symbol.asyncIterator]() {
329
+ return this;
330
+ },
331
+ [Symbol.asyncDispose]: async () => {}
332
+ };
333
+ }
334
+ [Symbol.iterator]() {
335
+ this[F] = !1;
336
+ let t = !1, e = () => (this.pause(), this.off(bi, e), this.off(w$1, e), this.off("end", e), t = !0, {
337
+ done: !0,
338
+ value: void 0
339
+ }), i = () => {
340
+ if (t) return e();
341
+ let r = this.read();
342
+ return r === null ? e() : {
343
+ done: !1,
344
+ value: r
345
+ };
346
+ };
347
+ return this.once("end", e), this.once(bi, e), this.once(w$1, e), {
348
+ next: i,
349
+ throw: e,
350
+ return: e,
351
+ [Symbol.iterator]() {
352
+ return this;
353
+ },
354
+ [Symbol.dispose]: () => {}
355
+ };
356
+ }
357
+ destroy(t) {
358
+ if (this[w$1]) return t ? this.emit("error", t) : this.emit(w$1), this;
359
+ this[w$1] = !0, this[F] = !0, this[b$1].length = 0, this[_$1] = 0;
360
+ let e = this;
361
+ return typeof e.close == "function" && !this[Ne] && e.close(), t ? this.emit("error", t) : this.emit(w$1), this;
362
+ }
363
+ static get isStream() {
364
+ return zr;
365
+ }
366
+ };
367
+ var Xr = fs.default.writev, ot = Symbol("_autoClose"), H = Symbol("_close"), te = Symbol("_ended"), m$1 = Symbol("_fd"), Ni = Symbol("_finished"), j = Symbol("_flags"), Di = Symbol("_flush"), Ci = Symbol("_handleChunk"), ki = Symbol("_makeBuf"), ie = Symbol("_mode"), Ce = Symbol("_needDrain"), Ut = Symbol("_onerror"), Ht = Symbol("_onopen"), Ai = Symbol("_onread"), Pt = Symbol("_onwrite"), ht = Symbol("_open"), U = Symbol("_path"), nt = Symbol("_pos"), Y = Symbol("_queue"), zt = Symbol("_read"), Ii = Symbol("_readSize"), J = Symbol("_reading"), ee = Symbol("_remain"), Fi = Symbol("_size"), ke = Symbol("_write"), gt = Symbol("_writing"), ve = Symbol("_defaultFlag"), bt = Symbol("_errored"), _t = class extends A$1 {
368
+ [bt] = !1;
369
+ [m$1];
370
+ [U];
371
+ [Ii];
372
+ [J] = !1;
373
+ [Fi];
374
+ [ee];
375
+ [ot];
376
+ constructor(t, e) {
377
+ if (e = e || {}, super(e), this.readable = !0, this.writable = !1, typeof t != "string") throw new TypeError("path must be a string");
378
+ this[bt] = !1, this[m$1] = typeof e.fd == "number" ? e.fd : void 0, this[U] = t, this[Ii] = e.readSize || 16 * 1024 * 1024, this[J] = !1, this[Fi] = typeof e.size == "number" ? e.size : Infinity, this[ee] = this[Fi], this[ot] = typeof e.autoClose == "boolean" ? e.autoClose : !0, typeof this[m$1] == "number" ? this[zt]() : this[ht]();
379
+ }
380
+ get fd() {
381
+ return this[m$1];
382
+ }
383
+ get path() {
384
+ return this[U];
385
+ }
386
+ write() {
387
+ throw new TypeError("this is a readable stream");
388
+ }
389
+ end() {
390
+ throw new TypeError("this is a readable stream");
391
+ }
392
+ [ht]() {
393
+ fs.default.open(this[U], "r", (t, e) => this[Ht](t, e));
394
+ }
395
+ [Ht](t, e) {
396
+ t ? this[Ut](t) : (this[m$1] = e, this.emit("open", e), this[zt]());
397
+ }
398
+ [ki]() {
399
+ return Buffer.allocUnsafe(Math.min(this[Ii], this[ee]));
400
+ }
401
+ [zt]() {
402
+ if (!this[J]) {
403
+ this[J] = !0;
404
+ let t = this[ki]();
405
+ if (t.length === 0) return process.nextTick(() => this[Ai](null, 0, t));
406
+ fs.default.read(this[m$1], t, 0, t.length, null, (e, i, r) => this[Ai](e, i, r));
407
+ }
408
+ }
409
+ [Ai](t, e, i) {
410
+ this[J] = !1, t ? this[Ut](t) : this[Ci](e, i) && this[zt]();
411
+ }
412
+ [H]() {
413
+ if (this[ot] && typeof this[m$1] == "number") {
414
+ let t = this[m$1];
415
+ this[m$1] = void 0, fs.default.close(t, (e) => e ? this.emit("error", e) : this.emit("close"));
416
+ }
417
+ }
418
+ [Ut](t) {
419
+ this[J] = !0, this[H](), this.emit("error", t);
420
+ }
421
+ [Ci](t, e) {
422
+ let i = !1;
423
+ return this[ee] -= t, t > 0 && (i = super.write(t < e.length ? e.subarray(0, t) : e)), (t === 0 || this[ee] <= 0) && (i = !1, this[H](), super.end()), i;
424
+ }
425
+ emit(t, ...e) {
426
+ switch (t) {
427
+ case "prefinish":
428
+ case "finish": return !1;
429
+ case "drain": return typeof this[m$1] == "number" && this[zt](), !1;
430
+ case "error": return this[bt] ? !1 : (this[bt] = !0, super.emit(t, ...e));
431
+ default: return super.emit(t, ...e);
432
+ }
433
+ }
434
+ }, Me = class extends _t {
435
+ [ht]() {
436
+ let t = !0;
437
+ try {
438
+ this[Ht](null, fs.default.openSync(this[U], "r")), t = !1;
439
+ } finally {
440
+ t && this[H]();
441
+ }
442
+ }
443
+ [zt]() {
444
+ let t = !0;
445
+ try {
446
+ if (!this[J]) {
447
+ this[J] = !0;
448
+ do {
449
+ let e = this[ki](), i = e.length === 0 ? 0 : fs.default.readSync(this[m$1], e, 0, e.length, null);
450
+ if (!this[Ci](i, e)) break;
451
+ } while (!0);
452
+ this[J] = !1;
453
+ }
454
+ t = !1;
455
+ } finally {
456
+ t && this[H]();
457
+ }
458
+ }
459
+ [H]() {
460
+ if (this[ot] && typeof this[m$1] == "number") {
461
+ let t = this[m$1];
462
+ this[m$1] = void 0, fs.default.closeSync(t), this.emit("close");
463
+ }
464
+ }
465
+ }, tt = class extends events.default {
466
+ readable = !1;
467
+ writable = !0;
468
+ [bt] = !1;
469
+ [gt] = !1;
470
+ [te] = !1;
471
+ [Y] = [];
472
+ [Ce] = !1;
473
+ [U];
474
+ [ie];
475
+ [ot];
476
+ [m$1];
477
+ [ve];
478
+ [j];
479
+ [Ni] = !1;
480
+ [nt];
481
+ constructor(t, e) {
482
+ e = e || {}, super(e), this[U] = t, this[m$1] = typeof e.fd == "number" ? e.fd : void 0, this[ie] = e.mode === void 0 ? 438 : e.mode, this[nt] = typeof e.start == "number" ? e.start : void 0, this[ot] = typeof e.autoClose == "boolean" ? e.autoClose : !0;
483
+ let i = this[nt] !== void 0 ? "r+" : "w";
484
+ this[ve] = e.flags === void 0, this[j] = e.flags === void 0 ? i : e.flags, this[m$1] === void 0 && this[ht]();
485
+ }
486
+ emit(t, ...e) {
487
+ if (t === "error") {
488
+ if (this[bt]) return !1;
489
+ this[bt] = !0;
490
+ }
491
+ return super.emit(t, ...e);
492
+ }
493
+ get fd() {
494
+ return this[m$1];
495
+ }
496
+ get path() {
497
+ return this[U];
498
+ }
499
+ [Ut](t) {
500
+ this[H](), this[gt] = !0, this.emit("error", t);
501
+ }
502
+ [ht]() {
503
+ fs.default.open(this[U], this[j], this[ie], (t, e) => this[Ht](t, e));
504
+ }
505
+ [Ht](t, e) {
506
+ this[ve] && this[j] === "r+" && t && t.code === "ENOENT" ? (this[j] = "w", this[ht]()) : t ? this[Ut](t) : (this[m$1] = e, this.emit("open", e), this[gt] || this[Di]());
507
+ }
508
+ end(t, e) {
509
+ return t && this.write(t, e), this[te] = !0, !this[gt] && !this[Y].length && typeof this[m$1] == "number" && this[Pt](null, 0), this;
510
+ }
511
+ write(t, e) {
512
+ return typeof t == "string" && (t = Buffer.from(t, e)), this[te] ? (this.emit("error", /* @__PURE__ */ new Error("write() after end()")), !1) : this[m$1] === void 0 || this[gt] || this[Y].length ? (this[Y].push(t), this[Ce] = !0, !1) : (this[gt] = !0, this[ke](t), !0);
513
+ }
514
+ [ke](t) {
515
+ fs.default.write(this[m$1], t, 0, t.length, this[nt], (e, i) => this[Pt](e, i));
516
+ }
517
+ [Pt](t, e) {
518
+ t ? this[Ut](t) : (this[nt] !== void 0 && typeof e == "number" && (this[nt] += e), this[Y].length ? this[Di]() : (this[gt] = !1, this[te] && !this[Ni] ? (this[Ni] = !0, this[H](), this.emit("finish")) : this[Ce] && (this[Ce] = !1, this.emit("drain"))));
519
+ }
520
+ [Di]() {
521
+ if (this[Y].length === 0) this[te] && this[Pt](null, 0);
522
+ else if (this[Y].length === 1) this[ke](this[Y].pop());
523
+ else {
524
+ let t = this[Y];
525
+ this[Y] = [], Xr(this[m$1], t, this[nt], (e, i) => this[Pt](e, i));
526
+ }
527
+ }
528
+ [H]() {
529
+ if (this[ot] && typeof this[m$1] == "number") {
530
+ let t = this[m$1];
531
+ this[m$1] = void 0, fs.default.close(t, (e) => e ? this.emit("error", e) : this.emit("close"));
532
+ }
533
+ }
534
+ }, Wt = class extends tt {
535
+ [ht]() {
536
+ let t;
537
+ if (this[ve] && this[j] === "r+") try {
538
+ t = fs.default.openSync(this[U], this[j], this[ie]);
539
+ } catch (e) {
540
+ if (e?.code === "ENOENT") return this[j] = "w", this[ht]();
541
+ throw e;
542
+ }
543
+ else t = fs.default.openSync(this[U], this[j], this[ie]);
544
+ this[Ht](null, t);
545
+ }
546
+ [H]() {
547
+ if (this[ot] && typeof this[m$1] == "number") {
548
+ let t = this[m$1];
549
+ this[m$1] = void 0, fs.default.closeSync(t), this.emit("close");
550
+ }
551
+ }
552
+ [ke](t) {
553
+ let e = !0;
554
+ try {
555
+ this[Pt](null, fs.default.writeSync(this[m$1], t, 0, t.length, this[nt])), e = !1;
556
+ } finally {
557
+ if (e) try {
558
+ this[H]();
559
+ } catch {}
560
+ }
561
+ }
562
+ };
563
+ var qr = new Map([
564
+ ["C", "cwd"],
565
+ ["f", "file"],
566
+ ["z", "gzip"],
567
+ ["P", "preservePaths"],
568
+ ["U", "unlink"],
569
+ ["strip-components", "strip"],
570
+ ["stripComponents", "strip"],
571
+ ["keep-newer", "newer"],
572
+ ["keepNewer", "newer"],
573
+ ["keep-newer-files", "newer"],
574
+ ["keepNewerFiles", "newer"],
575
+ ["k", "keep"],
576
+ ["keep-existing", "keep"],
577
+ ["keepExisting", "keep"],
578
+ ["m", "noMtime"],
579
+ ["no-mtime", "noMtime"],
580
+ ["p", "preserveOwner"],
581
+ ["L", "follow"],
582
+ ["h", "follow"],
583
+ ["onentry", "onReadEntry"]
584
+ ]), Is = (s) => !!s.sync && !!s.file, Fs = (s) => !s.sync && !!s.file, Cs = (s) => !!s.sync && !s.file, ks = (s) => !s.sync && !s.file;
585
+ var vs = (s) => !!s.file;
586
+ var Qr = (s) => {
587
+ return qr.get(s) || s;
588
+ }, se = (s = {}) => {
589
+ if (!s) return {};
590
+ let t = {};
591
+ for (let [e, i] of Object.entries(s)) {
592
+ let r = Qr(e);
593
+ t[r] = i;
594
+ }
595
+ return t.chmod === void 0 && t.noChmod === !1 && (t.chmod = !0), delete t.noChmod, t;
596
+ };
597
+ var K = (s, t, e, i, r) => Object.assign((n = [], o, a) => {
598
+ Array.isArray(n) && (o = n, n = {}), typeof o == "function" && (a = o, o = void 0), o = o ? Array.from(o) : [];
599
+ let h = se(n);
600
+ if (r?.(h, o), Is(h)) {
601
+ if (typeof a == "function") throw new TypeError("callback not supported for sync tar functions");
602
+ return s(h, o);
603
+ } else if (Fs(h)) {
604
+ let l = t(h, o);
605
+ return a ? l.then(() => a(), a) : l;
606
+ } else if (Cs(h)) {
607
+ if (typeof a == "function") throw new TypeError("callback not supported for sync tar functions");
608
+ return e(h, o);
609
+ } else if (ks(h)) {
610
+ if (typeof a == "function") throw new TypeError("callback only supported with file option");
611
+ return i(h, o);
612
+ }
613
+ throw new Error("impossible options??");
614
+ }, {
615
+ syncFile: s,
616
+ asyncFile: t,
617
+ syncNoFile: e,
618
+ asyncNoFile: i,
619
+ validate: r
620
+ });
621
+ var jr = zlib.default.constants || { ZLIB_VERNUM: 4736 }, M = Object.freeze(Object.assign(Object.create(null), {
622
+ Z_NO_FLUSH: 0,
623
+ Z_PARTIAL_FLUSH: 1,
624
+ Z_SYNC_FLUSH: 2,
625
+ Z_FULL_FLUSH: 3,
626
+ Z_FINISH: 4,
627
+ Z_BLOCK: 5,
628
+ Z_OK: 0,
629
+ Z_STREAM_END: 1,
630
+ Z_NEED_DICT: 2,
631
+ Z_ERRNO: -1,
632
+ Z_STREAM_ERROR: -2,
633
+ Z_DATA_ERROR: -3,
634
+ Z_MEM_ERROR: -4,
635
+ Z_BUF_ERROR: -5,
636
+ Z_VERSION_ERROR: -6,
637
+ Z_NO_COMPRESSION: 0,
638
+ Z_BEST_SPEED: 1,
639
+ Z_BEST_COMPRESSION: 9,
640
+ Z_DEFAULT_COMPRESSION: -1,
641
+ Z_FILTERED: 1,
642
+ Z_HUFFMAN_ONLY: 2,
643
+ Z_RLE: 3,
644
+ Z_FIXED: 4,
645
+ Z_DEFAULT_STRATEGY: 0,
646
+ DEFLATE: 1,
647
+ INFLATE: 2,
648
+ GZIP: 3,
649
+ GUNZIP: 4,
650
+ DEFLATERAW: 5,
651
+ INFLATERAW: 6,
652
+ UNZIP: 7,
653
+ BROTLI_DECODE: 8,
654
+ BROTLI_ENCODE: 9,
655
+ Z_MIN_WINDOWBITS: 8,
656
+ Z_MAX_WINDOWBITS: 15,
657
+ Z_DEFAULT_WINDOWBITS: 15,
658
+ Z_MIN_CHUNK: 64,
659
+ Z_MAX_CHUNK: Infinity,
660
+ Z_DEFAULT_CHUNK: 16384,
661
+ Z_MIN_MEMLEVEL: 1,
662
+ Z_MAX_MEMLEVEL: 9,
663
+ Z_DEFAULT_MEMLEVEL: 8,
664
+ Z_MIN_LEVEL: -1,
665
+ Z_MAX_LEVEL: 9,
666
+ Z_DEFAULT_LEVEL: -1,
667
+ BROTLI_OPERATION_PROCESS: 0,
668
+ BROTLI_OPERATION_FLUSH: 1,
669
+ BROTLI_OPERATION_FINISH: 2,
670
+ BROTLI_OPERATION_EMIT_METADATA: 3,
671
+ BROTLI_MODE_GENERIC: 0,
672
+ BROTLI_MODE_TEXT: 1,
673
+ BROTLI_MODE_FONT: 2,
674
+ BROTLI_DEFAULT_MODE: 0,
675
+ BROTLI_MIN_QUALITY: 0,
676
+ BROTLI_MAX_QUALITY: 11,
677
+ BROTLI_DEFAULT_QUALITY: 11,
678
+ BROTLI_MIN_WINDOW_BITS: 10,
679
+ BROTLI_MAX_WINDOW_BITS: 24,
680
+ BROTLI_LARGE_MAX_WINDOW_BITS: 30,
681
+ BROTLI_DEFAULT_WINDOW: 22,
682
+ BROTLI_MIN_INPUT_BLOCK_BITS: 16,
683
+ BROTLI_MAX_INPUT_BLOCK_BITS: 24,
684
+ BROTLI_PARAM_MODE: 0,
685
+ BROTLI_PARAM_QUALITY: 1,
686
+ BROTLI_PARAM_LGWIN: 2,
687
+ BROTLI_PARAM_LGBLOCK: 3,
688
+ BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING: 4,
689
+ BROTLI_PARAM_SIZE_HINT: 5,
690
+ BROTLI_PARAM_LARGE_WINDOW: 6,
691
+ BROTLI_PARAM_NPOSTFIX: 7,
692
+ BROTLI_PARAM_NDIRECT: 8,
693
+ BROTLI_DECODER_RESULT_ERROR: 0,
694
+ BROTLI_DECODER_RESULT_SUCCESS: 1,
695
+ BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT: 2,
696
+ BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT: 3,
697
+ BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION: 0,
698
+ BROTLI_DECODER_PARAM_LARGE_WINDOW: 1,
699
+ BROTLI_DECODER_NO_ERROR: 0,
700
+ BROTLI_DECODER_SUCCESS: 1,
701
+ BROTLI_DECODER_NEEDS_MORE_INPUT: 2,
702
+ BROTLI_DECODER_NEEDS_MORE_OUTPUT: 3,
703
+ BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE: -1,
704
+ BROTLI_DECODER_ERROR_FORMAT_RESERVED: -2,
705
+ BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE: -3,
706
+ BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET: -4,
707
+ BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME: -5,
708
+ BROTLI_DECODER_ERROR_FORMAT_CL_SPACE: -6,
709
+ BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE: -7,
710
+ BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT: -8,
711
+ BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1: -9,
712
+ BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2: -10,
713
+ BROTLI_DECODER_ERROR_FORMAT_TRANSFORM: -11,
714
+ BROTLI_DECODER_ERROR_FORMAT_DICTIONARY: -12,
715
+ BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS: -13,
716
+ BROTLI_DECODER_ERROR_FORMAT_PADDING_1: -14,
717
+ BROTLI_DECODER_ERROR_FORMAT_PADDING_2: -15,
718
+ BROTLI_DECODER_ERROR_FORMAT_DISTANCE: -16,
719
+ BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET: -19,
720
+ BROTLI_DECODER_ERROR_INVALID_ARGUMENTS: -20,
721
+ BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES: -21,
722
+ BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS: -22,
723
+ BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP: -25,
724
+ BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1: -26,
725
+ BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2: -27,
726
+ BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES: -30,
727
+ BROTLI_DECODER_ERROR_UNREACHABLE: -31
728
+ }, jr));
729
+ var tn = buffer.Buffer.concat, Bs = Object.getOwnPropertyDescriptor(buffer.Buffer, "concat"), en = (s) => s, Mi = Bs?.writable === !0 || Bs?.set !== void 0 ? (s) => {
730
+ buffer.Buffer.concat = s ? en : tn;
731
+ } : (s) => {}, Tt = Symbol("_superWrite"), Gt = class extends Error {
732
+ code;
733
+ errno;
734
+ constructor(t, e) {
735
+ super("zlib: " + t.message, { cause: t }), this.code = t.code, this.errno = t.errno, this.code || (this.code = "ZLIB_ERROR"), this.message = "zlib: " + t.message, Error.captureStackTrace(this, e ?? this.constructor);
736
+ }
737
+ get name() {
738
+ return "ZlibError";
739
+ }
740
+ }, Bi = Symbol("flushFlag"), re = class extends A$1 {
741
+ #t = !1;
742
+ #i = !1;
743
+ #s;
744
+ #n;
745
+ #r;
746
+ #e;
747
+ #o;
748
+ get sawError() {
749
+ return this.#t;
750
+ }
751
+ get handle() {
752
+ return this.#e;
753
+ }
754
+ get flushFlag() {
755
+ return this.#s;
756
+ }
757
+ constructor(t, e) {
758
+ if (!t || typeof t != "object") throw new TypeError("invalid options for ZlibBase constructor");
759
+ if (super(t), this.#s = t.flush ?? 0, this.#n = t.finishFlush ?? 0, this.#r = t.fullFlushFlag ?? 0, typeof zlib[e] != "function") throw new TypeError("Compression method not supported: " + e);
760
+ try {
761
+ this.#e = new zlib[e](t);
762
+ } catch (i) {
763
+ throw new Gt(i, this.constructor);
764
+ }
765
+ this.#o = (i) => {
766
+ this.#t || (this.#t = !0, this.close(), this.emit("error", i));
767
+ }, this.#e?.on("error", (i) => this.#o(new Gt(i))), this.once("end", () => this.close);
768
+ }
769
+ close() {
770
+ this.#e && (this.#e.close(), this.#e = void 0, this.emit("close"));
771
+ }
772
+ reset() {
773
+ if (!this.#t) return (0, assert.default)(this.#e, "zlib binding closed"), this.#e.reset?.();
774
+ }
775
+ flush(t) {
776
+ this.ended || (typeof t != "number" && (t = this.#r), this.write(Object.assign(buffer.Buffer.alloc(0), { [Bi]: t })));
777
+ }
778
+ end(t, e, i) {
779
+ return typeof t == "function" && (i = t, e = void 0, t = void 0), typeof e == "function" && (i = e, e = void 0), t && (e ? this.write(t, e) : this.write(t)), this.flush(this.#n), this.#i = !0, super.end(i);
780
+ }
781
+ get ended() {
782
+ return this.#i;
783
+ }
784
+ [Tt](t) {
785
+ return super.write(t);
786
+ }
787
+ write(t, e, i) {
788
+ if (typeof e == "function" && (i = e, e = "utf8"), typeof t == "string" && (t = buffer.Buffer.from(t, e)), this.#t) return;
789
+ (0, assert.default)(this.#e, "zlib binding closed");
790
+ let r = this.#e._handle, n = r.close;
791
+ r.close = () => {};
792
+ let o = this.#e.close;
793
+ this.#e.close = () => {}, Mi(!0);
794
+ let a;
795
+ try {
796
+ let l = typeof t[Bi] == "number" ? t[Bi] : this.#s;
797
+ a = this.#e._processChunk(t, l), Mi(!1);
798
+ } catch (l) {
799
+ Mi(!1), this.#o(new Gt(l, this.write));
800
+ } finally {
801
+ this.#e && (this.#e._handle = r, r.close = n, this.#e.close = o, this.#e.removeAllListeners("error"));
802
+ }
803
+ this.#e && this.#e.on("error", (l) => this.#o(new Gt(l, this.write)));
804
+ let h;
805
+ if (a) if (Array.isArray(a) && a.length > 0) {
806
+ let l = a[0];
807
+ h = this[Tt](buffer.Buffer.from(l));
808
+ for (let c = 1; c < a.length; c++) h = this[Tt](a[c]);
809
+ } else h = this[Tt](buffer.Buffer.from(a));
810
+ return i && i(), h;
811
+ }
812
+ }, Be = class extends re {
813
+ #t;
814
+ #i;
815
+ constructor(t, e) {
816
+ t = t || {}, t.flush = t.flush || M.Z_NO_FLUSH, t.finishFlush = t.finishFlush || M.Z_FINISH, t.fullFlushFlag = M.Z_FULL_FLUSH, super(t, e), this.#t = t.level, this.#i = t.strategy;
817
+ }
818
+ params(t, e) {
819
+ if (!this.sawError) {
820
+ if (!this.handle) throw new Error("cannot switch params when binding is closed");
821
+ if (!this.handle.params) throw new Error("not supported in this implementation");
822
+ if (this.#t !== t || this.#i !== e) {
823
+ this.flush(M.Z_SYNC_FLUSH), (0, assert.default)(this.handle, "zlib binding closed");
824
+ let i = this.handle.flush;
825
+ this.handle.flush = (r, n) => {
826
+ typeof r == "function" && (n = r, r = this.flushFlag), this.flush(r), n?.();
827
+ };
828
+ try {
829
+ this.handle.params(t, e);
830
+ } finally {
831
+ this.handle.flush = i;
832
+ }
833
+ this.handle && (this.#t = t, this.#i = e);
834
+ }
835
+ }
836
+ }
837
+ };
838
+ var Pe = class extends Be {
839
+ #t;
840
+ constructor(t) {
841
+ super(t, "Gzip"), this.#t = t && !!t.portable;
842
+ }
843
+ [Tt](t) {
844
+ return this.#t ? (this.#t = !1, t[9] = 255, super[Tt](t)) : super[Tt](t);
845
+ }
846
+ };
847
+ var ze = class extends Be {
848
+ constructor(t) {
849
+ super(t, "Unzip");
850
+ }
851
+ }, Ue = class extends re {
852
+ constructor(t, e) {
853
+ t = t || {}, t.flush = t.flush || M.BROTLI_OPERATION_PROCESS, t.finishFlush = t.finishFlush || M.BROTLI_OPERATION_FINISH, t.fullFlushFlag = M.BROTLI_OPERATION_FLUSH, super(t, e);
854
+ }
855
+ }, He = class extends Ue {
856
+ constructor(t) {
857
+ super(t, "BrotliCompress");
858
+ }
859
+ }, We = class extends Ue {
860
+ constructor(t) {
861
+ super(t, "BrotliDecompress");
862
+ }
863
+ }, Ge = class extends re {
864
+ constructor(t, e) {
865
+ t = t || {}, t.flush = t.flush || M.ZSTD_e_continue, t.finishFlush = t.finishFlush || M.ZSTD_e_end, t.fullFlushFlag = M.ZSTD_e_flush, super(t, e);
866
+ }
867
+ }, Ze = class extends Ge {
868
+ constructor(t) {
869
+ super(t, "ZstdCompress");
870
+ }
871
+ }, Ye = class extends Ge {
872
+ constructor(t) {
873
+ super(t, "ZstdDecompress");
874
+ }
875
+ };
876
+ var Ps = (s, t) => {
877
+ if (Number.isSafeInteger(s)) s < 0 ? nn(s, t) : rn(s, t);
878
+ else throw Error("cannot encode number outside of javascript safe integer range");
879
+ return t;
880
+ }, rn = (s, t) => {
881
+ t[0] = 128;
882
+ for (var e = t.length; e > 1; e--) t[e - 1] = s & 255, s = Math.floor(s / 256);
883
+ }, nn = (s, t) => {
884
+ t[0] = 255;
885
+ var e = !1;
886
+ s = s * -1;
887
+ for (var i = t.length; i > 1; i--) {
888
+ var r = s & 255;
889
+ s = Math.floor(s / 256), e ? t[i - 1] = Us(r) : r === 0 ? t[i - 1] = 0 : (e = !0, t[i - 1] = Hs(r));
890
+ }
891
+ }, zs = (s) => {
892
+ let t = s[0], e = t === 128 ? hn(s.subarray(1, s.length)) : t === 255 ? on(s) : null;
893
+ if (e === null) throw Error("invalid base256 encoding");
894
+ if (!Number.isSafeInteger(e)) throw Error("parsed number outside of javascript safe integer range");
895
+ return e;
896
+ }, on = (s) => {
897
+ for (var t = s.length, e = 0, i = !1, r = t - 1; r > -1; r--) {
898
+ var n = Number(s[r]), o;
899
+ i ? o = Us(n) : n === 0 ? o = n : (i = !0, o = Hs(n)), o !== 0 && (e -= o * Math.pow(256, t - r - 1));
900
+ }
901
+ return e;
902
+ }, hn = (s) => {
903
+ for (var t = s.length, e = 0, i = t - 1; i > -1; i--) {
904
+ var r = Number(s[i]);
905
+ r !== 0 && (e += r * Math.pow(256, t - i - 1));
906
+ }
907
+ return e;
908
+ }, Us = (s) => (255 ^ s) & 255, Hs = (s) => (255 ^ s) + 1 & 255;
909
+ Br({}, {
910
+ code: () => Ke,
911
+ isCode: () => ne,
912
+ isName: () => ln,
913
+ name: () => oe,
914
+ normalFsTypes: () => zi
915
+ });
916
+ var ne = (s) => oe.has(s), ln = (s) => Ke.has(s), zi = new Set([
917
+ "0",
918
+ "",
919
+ "1",
920
+ "2",
921
+ "3",
922
+ "4",
923
+ "5",
924
+ "6",
925
+ "7",
926
+ "D"
927
+ ]), oe = new Map([
928
+ ["0", "File"],
929
+ ["", "OldFile"],
930
+ ["1", "Link"],
931
+ ["2", "SymbolicLink"],
932
+ ["3", "CharacterDevice"],
933
+ ["4", "BlockDevice"],
934
+ ["5", "Directory"],
935
+ ["6", "FIFO"],
936
+ ["7", "ContiguousFile"],
937
+ ["g", "GlobalExtendedHeader"],
938
+ ["x", "ExtendedHeader"],
939
+ ["A", "SolarisACL"],
940
+ ["D", "GNUDumpDir"],
941
+ ["I", "Inode"],
942
+ ["K", "NextFileHasLongLinkpath"],
943
+ ["L", "NextFileHasLongPath"],
944
+ ["M", "ContinuationFile"],
945
+ ["N", "OldGnuLongPath"],
946
+ ["S", "SparseFile"],
947
+ ["V", "TapeVolumeHeader"],
948
+ ["X", "OldExtendedHeader"]
949
+ ]), Ke = new Map(Array.from(oe).map((s) => [s[1], s[0]]));
950
+ var C$1 = class {
951
+ cksumValid = !1;
952
+ needPax = !1;
953
+ nullBlock = !1;
954
+ block;
955
+ path;
956
+ mode;
957
+ uid;
958
+ gid;
959
+ size;
960
+ cksum;
961
+ #t = "Unsupported";
962
+ linkpath;
963
+ uname;
964
+ gname;
965
+ devmaj = 0;
966
+ devmin = 0;
967
+ atime;
968
+ ctime;
969
+ mtime;
970
+ charset;
971
+ comment;
972
+ constructor(t, e = 0, i, r) {
973
+ Buffer.isBuffer(t) ? this.decode(t, e || 0, i, r) : t && this.#i(t);
974
+ }
975
+ decode(t, e, i, r) {
976
+ if (e || (e = 0), !t || !(t.length >= e + 512)) throw new Error("need 512 bytes for header");
977
+ let n = xt(t, e + 156, 1), o = zi.has(n), a = o ? i : void 0, h = o ? r : void 0;
978
+ if (this.path = a?.path ?? xt(t, e, 100), this.mode = a?.mode ?? h?.mode ?? at(t, e + 100, 8), this.uid = a?.uid ?? h?.uid ?? at(t, e + 108, 8), this.gid = a?.gid ?? h?.gid ?? at(t, e + 116, 8), this.size = a?.size ?? h?.size ?? at(t, e + 124, 12), this.mtime = a?.mtime ?? h?.mtime ?? Hi(t, e + 136, 12), this.cksum = at(t, e + 148, 12), h && this.#i(h, !0), a && this.#i(a), ne(n) && (this.#t = n || "0"), this.#t === "0" && this.path.slice(-1) === "/" && (this.#t = "5"), this.#t === "5" && (this.size = 0), this.linkpath = xt(t, e + 157, 100), t.subarray(e + 257, e + 265).toString() === "ustar\x0000") if (this.uname = a?.uname ?? h?.uname ?? xt(t, e + 265, 32), this.gname = a?.gname ?? h?.gname ?? xt(t, e + 297, 32), this.devmaj = a?.devmaj ?? h?.devmaj ?? at(t, e + 329, 8) ?? 0, this.devmin = a?.devmin ?? h?.devmin ?? at(t, e + 337, 8) ?? 0, t[e + 475] !== 0) {
979
+ let c = xt(t, e + 345, 155);
980
+ this.path = c + "/" + this.path;
981
+ } else {
982
+ let c = xt(t, e + 345, 130);
983
+ c && (this.path = c + "/" + this.path), this.atime = i?.atime ?? r?.atime ?? Hi(t, e + 476, 12), this.ctime = i?.ctime ?? r?.ctime ?? Hi(t, e + 488, 12);
984
+ }
985
+ let l = 256;
986
+ for (let c = e; c < e + 148; c++) l += t[c];
987
+ for (let c = e + 156; c < e + 512; c++) l += t[c];
988
+ this.cksumValid = l === this.cksum, this.cksum === void 0 && l === 256 && (this.nullBlock = !0);
989
+ }
990
+ #i(t, e = !1) {
991
+ Object.assign(this, Object.fromEntries(Object.entries(t).filter(([i, r]) => !(r == null || i === "path" && e || i === "linkpath" && e || i === "global"))));
992
+ }
993
+ encode(t, e = 0) {
994
+ if (t || (t = this.block = Buffer.alloc(512)), this.#t === "Unsupported" && (this.#t = "0"), !(t.length >= e + 512)) throw new Error("need 512 bytes for header");
995
+ let i = this.ctime || this.atime ? 130 : 155, r = cn(this.path || "", i), n = r[0], o = r[1];
996
+ this.needPax = !!r[2], this.needPax = Lt(t, e, 100, n) || this.needPax, this.needPax = lt(t, e + 100, 8, this.mode) || this.needPax, this.needPax = lt(t, e + 108, 8, this.uid) || this.needPax, this.needPax = lt(t, e + 116, 8, this.gid) || this.needPax, this.needPax = lt(t, e + 124, 12, this.size) || this.needPax, this.needPax = Wi(t, e + 136, 12, this.mtime) || this.needPax, t[e + 156] = Number(this.#t.codePointAt(0)), this.needPax = Lt(t, e + 157, 100, this.linkpath) || this.needPax, t.write("ustar\x0000", e + 257, 8), this.needPax = Lt(t, e + 265, 32, this.uname) || this.needPax, this.needPax = Lt(t, e + 297, 32, this.gname) || this.needPax, this.needPax = lt(t, e + 329, 8, this.devmaj) || this.needPax, this.needPax = lt(t, e + 337, 8, this.devmin) || this.needPax, this.needPax = Lt(t, e + 345, i, o) || this.needPax, t[e + 475] !== 0 ? this.needPax = Lt(t, e + 345, 155, o) || this.needPax : (this.needPax = Lt(t, e + 345, 130, o) || this.needPax, this.needPax = Wi(t, e + 476, 12, this.atime) || this.needPax, this.needPax = Wi(t, e + 488, 12, this.ctime) || this.needPax);
997
+ let a = 256;
998
+ for (let h = e; h < e + 148; h++) a += t[h];
999
+ for (let h = e + 156; h < e + 512; h++) a += t[h];
1000
+ return this.cksum = a, lt(t, e + 148, 8, this.cksum), this.cksumValid = !0, this.needPax;
1001
+ }
1002
+ get type() {
1003
+ return this.#t === "Unsupported" ? this.#t : oe.get(this.#t);
1004
+ }
1005
+ get typeKey() {
1006
+ return this.#t;
1007
+ }
1008
+ set type(t) {
1009
+ let e = String(Ke.get(t));
1010
+ if (ne(e) || e === "Unsupported") this.#t = e;
1011
+ else if (ne(t)) this.#t = t;
1012
+ else throw new TypeError("invalid entry type: " + t);
1013
+ }
1014
+ }, cn = (s, t) => {
1015
+ let i = s, r = "", n, o = node_path$1.posix.parse(s).root || ".";
1016
+ if (Buffer.byteLength(i) < 100) n = [
1017
+ i,
1018
+ r,
1019
+ !1
1020
+ ];
1021
+ else {
1022
+ r = node_path$1.posix.dirname(i), i = node_path$1.posix.basename(i);
1023
+ do
1024
+ Buffer.byteLength(i) <= 100 && Buffer.byteLength(r) <= t ? n = [
1025
+ i,
1026
+ r,
1027
+ !1
1028
+ ] : Buffer.byteLength(i) > 100 && Buffer.byteLength(r) <= t ? n = [
1029
+ i.slice(0, 99),
1030
+ r,
1031
+ !0
1032
+ ] : (i = node_path$1.posix.join(node_path$1.posix.basename(r), i), r = node_path$1.posix.dirname(r));
1033
+ while (r !== o && n === void 0);
1034
+ n || (n = [
1035
+ s.slice(0, 99),
1036
+ "",
1037
+ !0
1038
+ ]);
1039
+ }
1040
+ return n;
1041
+ }, xt = (s, t, e) => s.subarray(t, t + e).toString("utf8").replace(/\0.*/, ""), Hi = (s, t, e) => fn(at(s, t, e)), fn = (s) => s === void 0 ? void 0 : /* @__PURE__ */ new Date(s * 1e3), at = (s, t, e) => Number(s[t]) & 128 ? zs(s.subarray(t, t + e)) : un(s, t, e), dn = (s) => isNaN(s) ? void 0 : s, un = (s, t, e) => dn(parseInt(s.subarray(t, t + e).toString("utf8").replace(/\0.*$/, "").trim(), 8)), mn = {
1042
+ 12: 8589934591,
1043
+ 8: 2097151
1044
+ }, lt = (s, t, e, i) => i === void 0 ? !1 : i > mn[e] || i < 0 ? (Ps(i, s.subarray(t, t + e)), !0) : (pn(s, t, e, i), !1), pn = (s, t, e, i) => s.write(En(i, e), t, e, "ascii"), En = (s, t) => wn(Math.floor(s).toString(8), t), wn = (s, t) => (s.length === t - 1 ? s : new Array(t - s.length - 1).join("0") + s + " ") + "\0", Wi = (s, t, e, i) => i === void 0 ? !1 : lt(s, t, e, i.getTime() / 1e3), Sn = new Array(156).join("\0"), Lt = (s, t, e, i) => i === void 0 ? !1 : (s.write(i + Sn, t, e, "utf8"), i.length !== Buffer.byteLength(i) || i.length > e);
1045
+ var ct = class s {
1046
+ atime;
1047
+ mtime;
1048
+ ctime;
1049
+ charset;
1050
+ comment;
1051
+ gid;
1052
+ uid;
1053
+ gname;
1054
+ uname;
1055
+ linkpath;
1056
+ dev;
1057
+ ino;
1058
+ nlink;
1059
+ path;
1060
+ size;
1061
+ mode;
1062
+ global;
1063
+ constructor(t, e = !1) {
1064
+ this.atime = t.atime, this.charset = t.charset, this.comment = t.comment, this.ctime = t.ctime, this.dev = t.dev, this.gid = t.gid, this.global = e, this.gname = t.gname, this.ino = t.ino, this.linkpath = t.linkpath, this.mtime = t.mtime, this.nlink = t.nlink, this.path = t.path, this.size = t.size, this.uid = t.uid, this.uname = t.uname;
1065
+ }
1066
+ encode() {
1067
+ let t = this.encodeBody();
1068
+ if (t === "") return Buffer.allocUnsafe(0);
1069
+ let e = Buffer.byteLength(t), i = 512 * Math.ceil(1 + e / 512), r = Buffer.allocUnsafe(i);
1070
+ for (let n = 0; n < 512; n++) r[n] = 0;
1071
+ new C$1({
1072
+ path: ("PaxHeader/" + (0, node_path$1.basename)(this.path ?? "")).slice(0, 99),
1073
+ mode: this.mode || 420,
1074
+ uid: this.uid,
1075
+ gid: this.gid,
1076
+ size: e,
1077
+ mtime: this.mtime,
1078
+ type: this.global ? "GlobalExtendedHeader" : "ExtendedHeader",
1079
+ linkpath: "",
1080
+ uname: this.uname || "",
1081
+ gname: this.gname || "",
1082
+ devmaj: 0,
1083
+ devmin: 0,
1084
+ atime: this.atime,
1085
+ ctime: this.ctime
1086
+ }).encode(r), r.write(t, 512, e, "utf8");
1087
+ for (let n = e + 512; n < r.length; n++) r[n] = 0;
1088
+ return r;
1089
+ }
1090
+ encodeBody() {
1091
+ return this.encodeField("path") + this.encodeField("ctime") + this.encodeField("atime") + this.encodeField("dev") + this.encodeField("ino") + this.encodeField("nlink") + this.encodeField("charset") + this.encodeField("comment") + this.encodeField("gid") + this.encodeField("gname") + this.encodeField("linkpath") + this.encodeField("mtime") + this.encodeField("size") + this.encodeField("uid") + this.encodeField("uname");
1092
+ }
1093
+ encodeField(t) {
1094
+ if (this[t] === void 0) return "";
1095
+ let e = this[t], i = e instanceof Date ? e.getTime() / 1e3 : e, r = " " + (t === "dev" || t === "ino" || t === "nlink" ? "SCHILY." : "") + t + "=" + i + `
1096
+ `, n = Buffer.byteLength(r), o = Math.floor(Math.log(n) / Math.log(10)) + 1;
1097
+ return n + o >= Math.pow(10, o) && (o += 1), o + n + r;
1098
+ }
1099
+ static parse(t, e, i = !1) {
1100
+ return new s(Rn(gn(t), e), i);
1101
+ }
1102
+ }, Rn = (s, t) => t ? Object.assign({}, t, s) : s, gn = (s) => s.replace(/\n$/, "").split(`
1103
+ `).reduce(bn, Object.create(null)), bn = (s, t) => {
1104
+ let e = parseInt(t, 10);
1105
+ if (e !== Buffer.byteLength(t) + 1) return s;
1106
+ t = t.slice((e + " ").length);
1107
+ let i = t.split("="), r = i.shift();
1108
+ if (!r) return s;
1109
+ let n = r.replace(/^SCHILY\.(dev|ino|nlink)/, "$1"), o = i.join("=");
1110
+ return s[n] = /^([A-Z]+\.)?([mac]|birth|creation)time$/.test(n) ? /* @__PURE__ */ new Date(Number(o) * 1e3) : /^[0-9]+$/.test(o) ? +o : o, s;
1111
+ };
1112
+ var f$1 = (process.env.TESTING_TAR_FAKE_PLATFORM || process.platform) !== "win32" ? (s) => s : (s) => s && s.replaceAll(/\\/g, "/");
1113
+ var Ve = class extends A$1 {
1114
+ extended;
1115
+ globalExtended;
1116
+ header;
1117
+ startBlockSize;
1118
+ blockRemain;
1119
+ remain;
1120
+ type;
1121
+ meta = !1;
1122
+ ignore = !1;
1123
+ path;
1124
+ mode;
1125
+ uid;
1126
+ gid;
1127
+ uname;
1128
+ gname;
1129
+ size = 0;
1130
+ mtime;
1131
+ atime;
1132
+ ctime;
1133
+ linkpath;
1134
+ dev;
1135
+ ino;
1136
+ nlink;
1137
+ invalid = !1;
1138
+ absolute;
1139
+ unsupported = !1;
1140
+ constructor(t, e, i) {
1141
+ switch (super({}), this.pause(), this.extended = e, this.globalExtended = i, this.header = t, this.remain = t.size ?? 0, this.startBlockSize = 512 * Math.ceil(this.remain / 512), this.blockRemain = this.startBlockSize, this.type = t.type, this.type) {
1142
+ case "File":
1143
+ case "OldFile":
1144
+ case "Link":
1145
+ case "SymbolicLink":
1146
+ case "CharacterDevice":
1147
+ case "BlockDevice":
1148
+ case "Directory":
1149
+ case "FIFO":
1150
+ case "ContiguousFile":
1151
+ case "GNUDumpDir": break;
1152
+ case "NextFileHasLongLinkpath":
1153
+ case "NextFileHasLongPath":
1154
+ case "OldGnuLongPath":
1155
+ case "GlobalExtendedHeader":
1156
+ case "ExtendedHeader":
1157
+ case "OldExtendedHeader":
1158
+ this.meta = !0;
1159
+ break;
1160
+ default: this.ignore = !0;
1161
+ }
1162
+ if (!t.path) throw new Error("no path provided for tar.ReadEntry");
1163
+ this.path = f$1(t.path), this.mode = t.mode, this.mode && (this.mode = this.mode & 4095), this.uid = t.uid, this.gid = t.gid, this.uname = t.uname, this.gname = t.gname, this.size = this.remain, this.mtime = t.mtime, this.atime = t.atime, this.ctime = t.ctime, this.linkpath = t.linkpath ? f$1(t.linkpath) : void 0, this.uname = t.uname, this.gname = t.gname, e && this.#t(e), i && this.#t(i, !0);
1164
+ }
1165
+ write(t) {
1166
+ let e = t.length;
1167
+ if (e > this.blockRemain) throw new Error("writing more to entry than is appropriate");
1168
+ let i = this.remain, r = this.blockRemain;
1169
+ return this.remain = Math.max(0, i - e), this.blockRemain = Math.max(0, r - e), this.ignore ? !0 : i >= e ? super.write(t) : super.write(t.subarray(0, i));
1170
+ }
1171
+ #t(t, e = !1) {
1172
+ t.path && (t.path = f$1(t.path)), t.linkpath && (t.linkpath = f$1(t.linkpath)), Object.assign(this, Object.fromEntries(Object.entries(t).filter(([i, r]) => !(r == null || i === "path" && e))));
1173
+ }
1174
+ };
1175
+ var Nt = (s, t, e, i = {}) => {
1176
+ s.file && (i.file = s.file), s.cwd && (i.cwd = s.cwd), i.code = e instanceof Error && e.code || t, i.tarCode = t, !s.strict && i.recoverable !== !1 ? (e instanceof Error && (i = Object.assign(e, i), e = e.message), s.emit("warn", t, e, i)) : e instanceof Error ? s.emit("error", Object.assign(e, i)) : s.emit("error", Object.assign(/* @__PURE__ */ new Error(`${t}: ${e}`), i));
1177
+ };
1178
+ var Tn = 1024 * 1024, Vi = Buffer.from([31, 139]), $i = Buffer.from([
1179
+ 40,
1180
+ 181,
1181
+ 47,
1182
+ 253
1183
+ ]), xn = Math.max(Vi.length, $i.length), B = Symbol("state"), Dt = Symbol("writeEntry"), et = Symbol("readEntry"), Gi = Symbol("nextEntry"), Ws = Symbol("processEntry"), V = Symbol("extendedHeader"), he = Symbol("globalExtendedHeader"), ft = Symbol("meta"), Gs = Symbol("emitMeta"), p$1 = Symbol("buffer"), it = Symbol("queue"), dt = Symbol("ended"), Zi = Symbol("emittedEnd"), At = Symbol("emit"), y = Symbol("unzip"), $e = Symbol("consumeChunk"), Xe = Symbol("consumeChunkSub"), Yi = Symbol("consumeBody"), Zs = Symbol("consumeMeta"), Ys = Symbol("consumeHeader"), ae = Symbol("consuming"), Ki = Symbol("bufferConcat"), qe = Symbol("maybeEnd"), Yt = Symbol("writing"), ut = Symbol("aborted"), Qe = Symbol("onDone"), It = Symbol("sawValidEntry"), Je = Symbol("sawNullBlock"), je = Symbol("sawEOF"), Ks = Symbol("closeStream"), Ln = () => !0, st = class extends events.EventEmitter {
1184
+ file;
1185
+ strict;
1186
+ maxMetaEntrySize;
1187
+ filter;
1188
+ brotli;
1189
+ zstd;
1190
+ writable = !0;
1191
+ readable = !1;
1192
+ [it] = [];
1193
+ [p$1];
1194
+ [et];
1195
+ [Dt];
1196
+ [B] = "begin";
1197
+ [ft] = "";
1198
+ [V];
1199
+ [he];
1200
+ [dt] = !1;
1201
+ [y];
1202
+ [ut] = !1;
1203
+ [It];
1204
+ [Je] = !1;
1205
+ [je] = !1;
1206
+ [Yt] = !1;
1207
+ [ae] = !1;
1208
+ [Zi] = !1;
1209
+ constructor(t = {}) {
1210
+ super(), this.file = t.file || "", this.on(Qe, () => {
1211
+ (this[B] === "begin" || this[It] === !1) && this.warn("TAR_BAD_ARCHIVE", "Unrecognized archive format");
1212
+ }), t.ondone ? this.on(Qe, t.ondone) : this.on(Qe, () => {
1213
+ this.emit("prefinish"), this.emit("finish"), this.emit("end");
1214
+ }), this.strict = !!t.strict, this.maxMetaEntrySize = t.maxMetaEntrySize || Tn, this.filter = typeof t.filter == "function" ? t.filter : Ln;
1215
+ let e = t.file && (t.file.endsWith(".tar.br") || t.file.endsWith(".tbr"));
1216
+ this.brotli = !(t.gzip || t.zstd) && t.brotli !== void 0 ? t.brotli : e ? void 0 : !1;
1217
+ let i = t.file && (t.file.endsWith(".tar.zst") || t.file.endsWith(".tzst"));
1218
+ this.zstd = !(t.gzip || t.brotli) && t.zstd !== void 0 ? t.zstd : i ? !0 : void 0, this.on("end", () => this[Ks]()), typeof t.onwarn == "function" && this.on("warn", t.onwarn), typeof t.onReadEntry == "function" && this.on("entry", t.onReadEntry);
1219
+ }
1220
+ warn(t, e, i = {}) {
1221
+ Nt(this, t, e, i);
1222
+ }
1223
+ [Ys](t, e) {
1224
+ this[It] === void 0 && (this[It] = !1);
1225
+ let i;
1226
+ try {
1227
+ i = new C$1(t, e, this[V], this[he]);
1228
+ } catch (r) {
1229
+ return this.warn("TAR_ENTRY_INVALID", r);
1230
+ }
1231
+ if (i.nullBlock) this[Je] ? (this[je] = !0, this[B] === "begin" && (this[B] = "header"), this[At]("eof")) : (this[Je] = !0, this[At]("nullBlock"));
1232
+ else if (this[Je] = !1, !i.cksumValid) this.warn("TAR_ENTRY_INVALID", "checksum failure", { header: i });
1233
+ else if (!i.path) this.warn("TAR_ENTRY_INVALID", "path is required", { header: i });
1234
+ else {
1235
+ let r = i.type;
1236
+ if (/^(Symbolic)?Link$/.test(r) && !i.linkpath) this.warn("TAR_ENTRY_INVALID", "linkpath required", { header: i });
1237
+ else if (!/^(Symbolic)?Link$/.test(r) && !/^(Global)?ExtendedHeader$/.test(r) && i.linkpath) this.warn("TAR_ENTRY_INVALID", "linkpath forbidden", { header: i });
1238
+ else {
1239
+ let n = this[Dt] = new Ve(i, this[V], this[he]);
1240
+ if (!this[It]) if (n.remain) {
1241
+ let o = () => {
1242
+ n.invalid || (this[It] = !0);
1243
+ };
1244
+ n.on("end", o);
1245
+ } else this[It] = !0;
1246
+ n.meta ? n.size > this.maxMetaEntrySize ? (n.ignore = !0, this[At]("ignoredEntry", n), this[B] = "ignore", n.resume()) : n.size > 0 && (this[ft] = "", n.on("data", (o) => this[ft] += o), this[B] = "meta") : (this[V] = void 0, n.ignore = n.ignore || !this.filter(n.path, n), n.ignore ? (this[At]("ignoredEntry", n), this[B] = n.remain ? "ignore" : "header", n.resume()) : (n.remain ? this[B] = "body" : (this[B] = "header", n.end()), this[et] ? this[it].push(n) : (this[it].push(n), this[Gi]())));
1247
+ }
1248
+ }
1249
+ }
1250
+ [Ks]() {
1251
+ queueMicrotask(() => this.emit("close"));
1252
+ }
1253
+ [Ws](t) {
1254
+ let e = !0;
1255
+ if (!t) this[et] = void 0, e = !1;
1256
+ else if (Array.isArray(t)) {
1257
+ let [i, ...r] = t;
1258
+ this.emit(i, ...r);
1259
+ } else this[et] = t, this.emit("entry", t), t.emittedEnd || (t.on("end", () => this[Gi]()), e = !1);
1260
+ return e;
1261
+ }
1262
+ [Gi]() {
1263
+ do ;
1264
+ while (this[Ws](this[it].shift()));
1265
+ if (this[it].length === 0) {
1266
+ let t = this[et];
1267
+ !t || t.flowing || t.size === t.remain ? this[Yt] || this.emit("drain") : t.once("drain", () => this.emit("drain"));
1268
+ }
1269
+ }
1270
+ [Yi](t, e) {
1271
+ let i = this[Dt];
1272
+ if (!i) throw new Error("attempt to consume body without entry??");
1273
+ let r = i.blockRemain ?? 0, n = r >= t.length && e === 0 ? t : t.subarray(e, e + r);
1274
+ return i.write(n), i.blockRemain || (this[B] = "header", this[Dt] = void 0, i.end()), n.length;
1275
+ }
1276
+ [Zs](t, e) {
1277
+ let i = this[Dt], r = this[Yi](t, e);
1278
+ return !this[Dt] && i && this[Gs](i), r;
1279
+ }
1280
+ [At](t, e, i) {
1281
+ this[it].length === 0 && !this[et] ? this.emit(t, e, i) : this[it].push([
1282
+ t,
1283
+ e,
1284
+ i
1285
+ ]);
1286
+ }
1287
+ [Gs](t) {
1288
+ switch (this[At]("meta", this[ft]), t.type) {
1289
+ case "ExtendedHeader":
1290
+ case "OldExtendedHeader":
1291
+ this[V] = ct.parse(this[ft], this[V], !1);
1292
+ break;
1293
+ case "GlobalExtendedHeader":
1294
+ this[he] = ct.parse(this[ft], this[he], !0);
1295
+ break;
1296
+ case "NextFileHasLongPath":
1297
+ case "OldGnuLongPath": {
1298
+ let e = this[V] ?? Object.create(null);
1299
+ this[V] = e, e.path = this[ft].replace(/\0.*/, "");
1300
+ break;
1301
+ }
1302
+ case "NextFileHasLongLinkpath": {
1303
+ let e = this[V] || Object.create(null);
1304
+ this[V] = e, e.linkpath = this[ft].replace(/\0.*/, "");
1305
+ break;
1306
+ }
1307
+ default: throw new Error("unknown meta: " + t.type);
1308
+ }
1309
+ }
1310
+ abort(t) {
1311
+ this[ut] = !0, this.emit("abort", t), this.warn("TAR_ABORT", t, { recoverable: !1 });
1312
+ }
1313
+ write(t, e, i) {
1314
+ if (typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, typeof e == "string" ? e : "utf8")), this[ut]) return i?.(), !1;
1315
+ if ((this[y] === void 0 || this.brotli === void 0 && this[y] === !1) && t) {
1316
+ if (this[p$1] && (t = Buffer.concat([this[p$1], t]), this[p$1] = void 0), t.length < xn) return this[p$1] = t, i?.(), !0;
1317
+ for (let h = 0; this[y] === void 0 && h < Vi.length; h++) t[h] !== Vi[h] && (this[y] = !1);
1318
+ let o = !1;
1319
+ if (this[y] === !1 && this.zstd !== !1) {
1320
+ o = !0;
1321
+ for (let h = 0; h < $i.length; h++) if (t[h] !== $i[h]) {
1322
+ o = !1;
1323
+ break;
1324
+ }
1325
+ }
1326
+ let a = this.brotli === void 0 && !o;
1327
+ if (this[y] === !1 && a) if (t.length < 512) if (this[dt]) this.brotli = !0;
1328
+ else return this[p$1] = t, i?.(), !0;
1329
+ else try {
1330
+ new C$1(t.subarray(0, 512)), this.brotli = !1;
1331
+ } catch {
1332
+ this.brotli = !0;
1333
+ }
1334
+ if (this[y] === void 0 || this[y] === !1 && (this.brotli || o)) {
1335
+ let h = this[dt];
1336
+ this[dt] = !1, this[y] = this[y] === void 0 ? new ze({}) : o ? new Ye({}) : new We({}), this[y].on("data", (c) => this[$e](c)), this[y].on("error", (c) => this.abort(c)), this[y].on("end", () => {
1337
+ this[dt] = !0, this[$e]();
1338
+ }), this[Yt] = !0;
1339
+ let l = !!this[y][h ? "end" : "write"](t);
1340
+ return this[Yt] = !1, i?.(), l;
1341
+ }
1342
+ }
1343
+ this[Yt] = !0, this[y] ? this[y].write(t) : this[$e](t), this[Yt] = !1;
1344
+ let n = this[it].length > 0 ? !1 : this[et] ? this[et].flowing : !0;
1345
+ return !n && this[it].length === 0 && this[et]?.once("drain", () => this.emit("drain")), i?.(), n;
1346
+ }
1347
+ [Ki](t) {
1348
+ t && !this[ut] && (this[p$1] = this[p$1] ? Buffer.concat([this[p$1], t]) : t);
1349
+ }
1350
+ [qe]() {
1351
+ if (this[dt] && !this[Zi] && !this[ut] && !this[ae]) {
1352
+ this[Zi] = !0;
1353
+ let t = this[Dt];
1354
+ if (t && t.blockRemain) {
1355
+ let e = this[p$1] ? this[p$1].length : 0;
1356
+ this.warn("TAR_BAD_ARCHIVE", `Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`, { entry: t }), this[p$1] && t.write(this[p$1]), t.end();
1357
+ }
1358
+ this[At](Qe);
1359
+ }
1360
+ }
1361
+ [$e](t) {
1362
+ if (this[ae] && t) this[Ki](t);
1363
+ else if (!t && !this[p$1]) this[qe]();
1364
+ else if (t) {
1365
+ if (this[ae] = !0, this[p$1]) {
1366
+ this[Ki](t);
1367
+ let e = this[p$1];
1368
+ this[p$1] = void 0, this[Xe](e);
1369
+ } else this[Xe](t);
1370
+ for (; this[p$1] && this[p$1]?.length >= 512 && !this[ut] && !this[je];) {
1371
+ let e = this[p$1];
1372
+ this[p$1] = void 0, this[Xe](e);
1373
+ }
1374
+ this[ae] = !1;
1375
+ }
1376
+ (!this[p$1] || this[dt]) && this[qe]();
1377
+ }
1378
+ [Xe](t) {
1379
+ let e = 0, i = t.length;
1380
+ for (; e + 512 <= i && !this[ut] && !this[je];) switch (this[B]) {
1381
+ case "begin":
1382
+ case "header":
1383
+ this[Ys](t, e), e += 512;
1384
+ break;
1385
+ case "ignore":
1386
+ case "body":
1387
+ e += this[Yi](t, e);
1388
+ break;
1389
+ case "meta":
1390
+ e += this[Zs](t, e);
1391
+ break;
1392
+ default: throw new Error("invalid state: " + this[B]);
1393
+ }
1394
+ e < i && (this[p$1] = this[p$1] ? Buffer.concat([t.subarray(e), this[p$1]]) : t.subarray(e));
1395
+ }
1396
+ end(t, e, i) {
1397
+ return typeof t == "function" && (i = t, e = void 0, t = void 0), typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, e)), i && this.once("finish", i), this[ut] || (this[y] ? (t && this[y].write(t), this[y].end()) : (this[dt] = !0, (this.brotli === void 0 || this.zstd === void 0) && (t = t || Buffer.alloc(0)), t && this.write(t), this[qe]())), this;
1398
+ }
1399
+ };
1400
+ var mt = (s) => {
1401
+ let t = s.length - 1, e = -1;
1402
+ for (; t > -1 && s.charAt(t) === "/";) e = t, t--;
1403
+ return e === -1 ? s : s.slice(0, e);
1404
+ };
1405
+ var An = (s) => {
1406
+ let t = s.onReadEntry;
1407
+ s.onReadEntry = t ? (e) => {
1408
+ t(e), e.resume();
1409
+ } : (e) => e.resume();
1410
+ }, Xi = (s, t) => {
1411
+ let e = new Map(t.map((n) => [mt(n), !0])), i = s.filter, r = (n, o = "") => {
1412
+ let a = o || (0, path.parse)(n).root || ".", h;
1413
+ if (n === a) h = !1;
1414
+ else {
1415
+ let l = e.get(n);
1416
+ h = l !== void 0 ? l : r((0, path.dirname)(n), a);
1417
+ }
1418
+ return e.set(n, h), h;
1419
+ };
1420
+ s.filter = i ? (n, o) => i(n, o) && r(mt(n)) : (n) => r(mt(n));
1421
+ }, In = (s) => {
1422
+ let t = new st(s), e = s.file, i;
1423
+ try {
1424
+ i = node_fs$1.default.openSync(e, "r");
1425
+ let r = node_fs$1.default.fstatSync(i), n = s.maxReadSize || 16 * 1024 * 1024;
1426
+ if (r.size < n) {
1427
+ let o = Buffer.allocUnsafe(r.size), a = node_fs$1.default.readSync(i, o, 0, r.size, 0);
1428
+ t.end(a === o.byteLength ? o : o.subarray(0, a));
1429
+ } else {
1430
+ let o = 0, a = Buffer.allocUnsafe(n);
1431
+ for (; o < r.size;) {
1432
+ let h = node_fs$1.default.readSync(i, a, 0, n, o);
1433
+ if (h === 0) break;
1434
+ o += h, t.write(a.subarray(0, h));
1435
+ }
1436
+ t.end();
1437
+ }
1438
+ } finally {
1439
+ if (typeof i == "number") try {
1440
+ node_fs$1.default.closeSync(i);
1441
+ } catch {}
1442
+ }
1443
+ }, Fn = (s, t) => {
1444
+ let e = new st(s), i = s.maxReadSize || 16 * 1024 * 1024, r = s.file;
1445
+ return new Promise((o, a) => {
1446
+ e.on("error", a), e.on("end", o), node_fs$1.default.stat(r, (h, l) => {
1447
+ if (h) a(h);
1448
+ else {
1449
+ let c = new _t(r, {
1450
+ readSize: i,
1451
+ size: l.size
1452
+ });
1453
+ c.on("error", a), c.pipe(e);
1454
+ }
1455
+ });
1456
+ });
1457
+ }, Ft = K(In, Fn, (s) => new st(s), (s) => new st(s), (s, t) => {
1458
+ t?.length && Xi(s, t), s.noResume || An(s);
1459
+ });
1460
+ var qi = (s, t, e) => (s &= 4095, e && (s = (s | 384) & -19), t && (s & 256 && (s |= 64), s & 32 && (s |= 8), s & 4 && (s |= 1)), s);
1461
+ var { isAbsolute: kn, parse: Vs } = node_path$1.win32, le = (s) => {
1462
+ let t = "", e = Vs(s);
1463
+ for (; kn(s) || e.root;) {
1464
+ let i = s.charAt(0) === "/" && s.slice(0, 4) !== "//?/" ? "/" : e.root;
1465
+ s = s.slice(i.length), t += i, e = Vs(s);
1466
+ }
1467
+ return [t, s];
1468
+ };
1469
+ var ti = [
1470
+ "|",
1471
+ "<",
1472
+ ">",
1473
+ "?",
1474
+ ":"
1475
+ ], Qi = ti.map((s) => String.fromCodePoint(61440 + Number(s.codePointAt(0)))), vn = new Map(ti.map((s, t) => [s, Qi[t]])), Mn = new Map(Qi.map((s, t) => [s, ti[t]])), Ji = (s) => ti.reduce((t, e) => t.split(e).join(vn.get(e)), s), $s = (s) => Qi.reduce((t, e) => t.split(e).join(Mn.get(e)), s);
1476
+ var er = (s, t) => t ? (s = f$1(s).replace(/^\.(\/|$)/, ""), mt(t) + "/" + s) : f$1(s), Bn = 16 * 1024 * 1024, Qs = Symbol("process"), Js = Symbol("file"), js = Symbol("directory"), ts = Symbol("symlink"), tr = Symbol("hardlink"), ce = Symbol("header"), ei = Symbol("read"), es = Symbol("lstat"), ii = Symbol("onlstat"), is = Symbol("onread"), ss = Symbol("onreadlink"), rs = Symbol("openfile"), ns = Symbol("onopenfile"), pt = Symbol("close"), si = Symbol("mode"), os = Symbol("awaitDrain"), ji = Symbol("ondrain"), X = Symbol("prefix"), fe = class extends A$1 {
1477
+ path;
1478
+ portable;
1479
+ myuid = process.getuid && process.getuid() || 0;
1480
+ myuser = process.env.USER || "";
1481
+ maxReadSize;
1482
+ linkCache;
1483
+ statCache;
1484
+ preservePaths;
1485
+ cwd;
1486
+ strict;
1487
+ mtime;
1488
+ noPax;
1489
+ noMtime;
1490
+ prefix;
1491
+ fd;
1492
+ blockLen = 0;
1493
+ blockRemain = 0;
1494
+ buf;
1495
+ pos = 0;
1496
+ remain = 0;
1497
+ length = 0;
1498
+ offset = 0;
1499
+ win32;
1500
+ absolute;
1501
+ header;
1502
+ type;
1503
+ linkpath;
1504
+ stat;
1505
+ onWriteEntry;
1506
+ #t = !1;
1507
+ constructor(t, e = {}) {
1508
+ let i = se(e);
1509
+ super(), this.path = f$1(t), this.portable = !!i.portable, this.maxReadSize = i.maxReadSize || Bn, this.linkCache = i.linkCache || /* @__PURE__ */ new Map(), this.statCache = i.statCache || /* @__PURE__ */ new Map(), this.preservePaths = !!i.preservePaths, this.cwd = f$1(i.cwd || process.cwd()), this.strict = !!i.strict, this.noPax = !!i.noPax, this.noMtime = !!i.noMtime, this.mtime = i.mtime, this.prefix = i.prefix ? f$1(i.prefix) : void 0, this.onWriteEntry = i.onWriteEntry, typeof i.onwarn == "function" && this.on("warn", i.onwarn);
1510
+ let r = !1;
1511
+ if (!this.preservePaths) {
1512
+ let [o, a] = le(this.path);
1513
+ o && typeof a == "string" && (this.path = a, r = o);
1514
+ }
1515
+ this.win32 = !!i.win32 || process.platform === "win32", this.win32 && (this.path = $s(this.path.replaceAll(/\\/g, "/")), t = t.replaceAll(/\\/g, "/")), this.absolute = f$1(i.absolute || path.default.resolve(this.cwd, t)), this.path === "" && (this.path = "./"), r && this.warn("TAR_ENTRY_INFO", `stripping ${r} from absolute path`, {
1516
+ entry: this,
1517
+ path: r + this.path
1518
+ });
1519
+ let n = this.statCache.get(this.absolute);
1520
+ n ? this[ii](n) : this[es]();
1521
+ }
1522
+ warn(t, e, i = {}) {
1523
+ return Nt(this, t, e, i);
1524
+ }
1525
+ emit(t, ...e) {
1526
+ return t === "error" && (this.#t = !0), super.emit(t, ...e);
1527
+ }
1528
+ [es]() {
1529
+ fs.default.lstat(this.absolute, (t, e) => {
1530
+ if (t) return this.emit("error", t);
1531
+ this[ii](e);
1532
+ });
1533
+ }
1534
+ [ii](t) {
1535
+ this.statCache.set(this.absolute, t), this.stat = t, t.isFile() || (t.size = 0), this.type = Pn(t), this.emit("stat", t), this[Qs]();
1536
+ }
1537
+ [Qs]() {
1538
+ switch (this.type) {
1539
+ case "File": return this[Js]();
1540
+ case "Directory": return this[js]();
1541
+ case "SymbolicLink": return this[ts]();
1542
+ default: return this.end();
1543
+ }
1544
+ }
1545
+ [si](t) {
1546
+ return qi(t, this.type === "Directory", this.portable);
1547
+ }
1548
+ [X](t) {
1549
+ return er(t, this.prefix);
1550
+ }
1551
+ [ce]() {
1552
+ if (!this.stat) throw new Error("cannot write header before stat");
1553
+ this.type === "Directory" && this.portable && (this.noMtime = !0), this.onWriteEntry?.(this), this.header = new C$1({
1554
+ path: this[X](this.path),
1555
+ linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[X](this.linkpath) : this.linkpath,
1556
+ mode: this[si](this.stat.mode),
1557
+ uid: this.portable ? void 0 : this.stat.uid,
1558
+ gid: this.portable ? void 0 : this.stat.gid,
1559
+ size: this.stat.size,
1560
+ mtime: this.noMtime ? void 0 : this.mtime || this.stat.mtime,
1561
+ type: this.type === "Unsupported" ? void 0 : this.type,
1562
+ uname: this.portable ? void 0 : this.stat.uid === this.myuid ? this.myuser : "",
1563
+ atime: this.portable ? void 0 : this.stat.atime,
1564
+ ctime: this.portable ? void 0 : this.stat.ctime
1565
+ }), this.header.encode() && !this.noPax && super.write(new ct({
1566
+ atime: this.portable ? void 0 : this.header.atime,
1567
+ ctime: this.portable ? void 0 : this.header.ctime,
1568
+ gid: this.portable ? void 0 : this.header.gid,
1569
+ mtime: this.noMtime ? void 0 : this.mtime || this.header.mtime,
1570
+ path: this[X](this.path),
1571
+ linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[X](this.linkpath) : this.linkpath,
1572
+ size: this.header.size,
1573
+ uid: this.portable ? void 0 : this.header.uid,
1574
+ uname: this.portable ? void 0 : this.header.uname,
1575
+ dev: this.portable ? void 0 : this.stat.dev,
1576
+ ino: this.portable ? void 0 : this.stat.ino,
1577
+ nlink: this.portable ? void 0 : this.stat.nlink
1578
+ }).encode());
1579
+ let t = this.header?.block;
1580
+ if (!t) throw new Error("failed to encode header");
1581
+ super.write(t);
1582
+ }
1583
+ [js]() {
1584
+ if (!this.stat) throw new Error("cannot create directory entry without stat");
1585
+ this.path.slice(-1) !== "/" && (this.path += "/"), this.stat.size = 0, this[ce](), this.end();
1586
+ }
1587
+ [ts]() {
1588
+ fs.default.readlink(this.absolute, (t, e) => {
1589
+ if (t) return this.emit("error", t);
1590
+ this[ss](e);
1591
+ });
1592
+ }
1593
+ [ss](t) {
1594
+ this.linkpath = f$1(t), this[ce](), this.end();
1595
+ }
1596
+ [tr](t) {
1597
+ if (!this.stat) throw new Error("cannot create link entry without stat");
1598
+ this.type = "Link", this.linkpath = f$1(path.default.relative(this.cwd, t)), this.stat.size = 0, this[ce](), this.end();
1599
+ }
1600
+ [Js]() {
1601
+ if (!this.stat) throw new Error("cannot create file entry without stat");
1602
+ if (this.stat.nlink > 1) {
1603
+ let t = `${this.stat.dev}:${this.stat.ino}`, e = this.linkCache.get(t);
1604
+ if (e?.indexOf(this.cwd) === 0) return this[tr](e);
1605
+ this.linkCache.set(t, this.absolute);
1606
+ }
1607
+ if (this[ce](), this.stat.size === 0) return this.end();
1608
+ this[rs]();
1609
+ }
1610
+ [rs]() {
1611
+ fs.default.open(this.absolute, "r", (t, e) => {
1612
+ if (t) return this.emit("error", t);
1613
+ this[ns](e);
1614
+ });
1615
+ }
1616
+ [ns](t) {
1617
+ if (this.fd = t, this.#t) return this[pt]();
1618
+ if (!this.stat) throw new Error("should stat before calling onopenfile");
1619
+ this.blockLen = 512 * Math.ceil(this.stat.size / 512), this.blockRemain = this.blockLen;
1620
+ let e = Math.min(this.blockLen, this.maxReadSize);
1621
+ this.buf = Buffer.allocUnsafe(e), this.offset = 0, this.pos = 0, this.remain = this.stat.size, this.length = this.buf.length, this[ei]();
1622
+ }
1623
+ [ei]() {
1624
+ let { fd: t, buf: e, offset: i, length: r, pos: n } = this;
1625
+ if (t === void 0 || e === void 0) throw new Error("cannot read file without first opening");
1626
+ fs.default.read(t, e, i, r, n, (o, a) => {
1627
+ if (o) return this[pt](() => this.emit("error", o));
1628
+ this[is](a);
1629
+ });
1630
+ }
1631
+ [pt](t = () => {}) {
1632
+ this.fd !== void 0 && fs.default.close(this.fd, t);
1633
+ }
1634
+ [is](t) {
1635
+ if (t <= 0 && this.remain > 0) {
1636
+ let r = Object.assign(/* @__PURE__ */ new Error("encountered unexpected EOF"), {
1637
+ path: this.absolute,
1638
+ syscall: "read",
1639
+ code: "EOF"
1640
+ });
1641
+ return this[pt](() => this.emit("error", r));
1642
+ }
1643
+ if (t > this.remain) {
1644
+ let r = Object.assign(/* @__PURE__ */ new Error("did not encounter expected EOF"), {
1645
+ path: this.absolute,
1646
+ syscall: "read",
1647
+ code: "EOF"
1648
+ });
1649
+ return this[pt](() => this.emit("error", r));
1650
+ }
1651
+ if (!this.buf) throw new Error("should have created buffer prior to reading");
1652
+ if (t === this.remain) for (let r = t; r < this.length && t < this.blockRemain; r++) this.buf[r + this.offset] = 0, t++, this.remain++;
1653
+ let e = this.offset === 0 && t === this.buf.length ? this.buf : this.buf.subarray(this.offset, this.offset + t);
1654
+ this.write(e) ? this[ji]() : this[os](() => this[ji]());
1655
+ }
1656
+ [os](t) {
1657
+ this.once("drain", t);
1658
+ }
1659
+ write(t, e, i) {
1660
+ if (typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, typeof e == "string" ? e : "utf8")), this.blockRemain < t.length) {
1661
+ let r = Object.assign(/* @__PURE__ */ new Error("writing more data than expected"), { path: this.absolute });
1662
+ return this.emit("error", r);
1663
+ }
1664
+ return this.remain -= t.length, this.blockRemain -= t.length, this.pos += t.length, this.offset += t.length, super.write(t, null, i);
1665
+ }
1666
+ [ji]() {
1667
+ if (!this.remain) return this.blockRemain && super.write(Buffer.alloc(this.blockRemain)), this[pt]((t) => t ? this.emit("error", t) : this.end());
1668
+ if (!this.buf) throw new Error("buffer lost somehow in ONDRAIN");
1669
+ this.offset >= this.length && (this.buf = Buffer.allocUnsafe(Math.min(this.blockRemain, this.buf.length)), this.offset = 0), this.length = this.buf.length - this.offset, this[ei]();
1670
+ }
1671
+ }, ri = class extends fe {
1672
+ sync = !0;
1673
+ [es]() {
1674
+ this[ii](fs.default.lstatSync(this.absolute));
1675
+ }
1676
+ [ts]() {
1677
+ this[ss](fs.default.readlinkSync(this.absolute));
1678
+ }
1679
+ [rs]() {
1680
+ this[ns](fs.default.openSync(this.absolute, "r"));
1681
+ }
1682
+ [ei]() {
1683
+ let t = !0;
1684
+ try {
1685
+ let { fd: e, buf: i, offset: r, length: n, pos: o } = this;
1686
+ if (e === void 0 || i === void 0) throw new Error("fd and buf must be set in READ method");
1687
+ let a = fs.default.readSync(e, i, r, n, o);
1688
+ this[is](a), t = !1;
1689
+ } finally {
1690
+ if (t) try {
1691
+ this[pt](() => {});
1692
+ } catch {}
1693
+ }
1694
+ }
1695
+ [os](t) {
1696
+ t();
1697
+ }
1698
+ [pt](t = () => {}) {
1699
+ this.fd !== void 0 && fs.default.closeSync(this.fd), t();
1700
+ }
1701
+ }, ni = class extends A$1 {
1702
+ blockLen = 0;
1703
+ blockRemain = 0;
1704
+ buf = 0;
1705
+ pos = 0;
1706
+ remain = 0;
1707
+ length = 0;
1708
+ preservePaths;
1709
+ portable;
1710
+ strict;
1711
+ noPax;
1712
+ noMtime;
1713
+ readEntry;
1714
+ type;
1715
+ prefix;
1716
+ path;
1717
+ mode;
1718
+ uid;
1719
+ gid;
1720
+ uname;
1721
+ gname;
1722
+ header;
1723
+ mtime;
1724
+ atime;
1725
+ ctime;
1726
+ linkpath;
1727
+ size;
1728
+ onWriteEntry;
1729
+ warn(t, e, i = {}) {
1730
+ return Nt(this, t, e, i);
1731
+ }
1732
+ constructor(t, e = {}) {
1733
+ let i = se(e);
1734
+ super(), this.preservePaths = !!i.preservePaths, this.portable = !!i.portable, this.strict = !!i.strict, this.noPax = !!i.noPax, this.noMtime = !!i.noMtime, this.onWriteEntry = i.onWriteEntry, this.readEntry = t;
1735
+ let { type: r } = t;
1736
+ if (r === "Unsupported") throw new Error("writing entry that should be ignored");
1737
+ this.type = r, this.type === "Directory" && this.portable && (this.noMtime = !0), this.prefix = i.prefix, this.path = f$1(t.path), this.mode = t.mode !== void 0 ? this[si](t.mode) : void 0, this.uid = this.portable ? void 0 : t.uid, this.gid = this.portable ? void 0 : t.gid, this.uname = this.portable ? void 0 : t.uname, this.gname = this.portable ? void 0 : t.gname, this.size = t.size, this.mtime = this.noMtime ? void 0 : i.mtime || t.mtime, this.atime = this.portable ? void 0 : t.atime, this.ctime = this.portable ? void 0 : t.ctime, this.linkpath = t.linkpath !== void 0 ? f$1(t.linkpath) : void 0, typeof i.onwarn == "function" && this.on("warn", i.onwarn);
1738
+ let n = !1;
1739
+ if (!this.preservePaths) {
1740
+ let [a, h] = le(this.path);
1741
+ a && typeof h == "string" && (this.path = h, n = a);
1742
+ }
1743
+ this.remain = t.size, this.blockRemain = t.startBlockSize, this.onWriteEntry?.(this), this.header = new C$1({
1744
+ path: this[X](this.path),
1745
+ linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[X](this.linkpath) : this.linkpath,
1746
+ mode: this.mode,
1747
+ uid: this.portable ? void 0 : this.uid,
1748
+ gid: this.portable ? void 0 : this.gid,
1749
+ size: this.size,
1750
+ mtime: this.noMtime ? void 0 : this.mtime,
1751
+ type: this.type,
1752
+ uname: this.portable ? void 0 : this.uname,
1753
+ atime: this.portable ? void 0 : this.atime,
1754
+ ctime: this.portable ? void 0 : this.ctime
1755
+ }), n && this.warn("TAR_ENTRY_INFO", `stripping ${n} from absolute path`, {
1756
+ entry: this,
1757
+ path: n + this.path
1758
+ }), this.header.encode() && !this.noPax && super.write(new ct({
1759
+ atime: this.portable ? void 0 : this.atime,
1760
+ ctime: this.portable ? void 0 : this.ctime,
1761
+ gid: this.portable ? void 0 : this.gid,
1762
+ mtime: this.noMtime ? void 0 : this.mtime,
1763
+ path: this[X](this.path),
1764
+ linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[X](this.linkpath) : this.linkpath,
1765
+ size: this.size,
1766
+ uid: this.portable ? void 0 : this.uid,
1767
+ uname: this.portable ? void 0 : this.uname,
1768
+ dev: this.portable ? void 0 : this.readEntry.dev,
1769
+ ino: this.portable ? void 0 : this.readEntry.ino,
1770
+ nlink: this.portable ? void 0 : this.readEntry.nlink
1771
+ }).encode());
1772
+ let o = this.header?.block;
1773
+ if (!o) throw new Error("failed to encode header");
1774
+ super.write(o), t.pipe(this);
1775
+ }
1776
+ [X](t) {
1777
+ return er(t, this.prefix);
1778
+ }
1779
+ [si](t) {
1780
+ return qi(t, this.type === "Directory", this.portable);
1781
+ }
1782
+ write(t, e, i) {
1783
+ typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, typeof e == "string" ? e : "utf8"));
1784
+ let r = t.length;
1785
+ if (r > this.blockRemain) throw new Error("writing more to entry than is appropriate");
1786
+ return this.blockRemain -= r, super.write(t, i);
1787
+ }
1788
+ end(t, e, i) {
1789
+ return this.blockRemain && super.write(Buffer.alloc(this.blockRemain)), typeof t == "function" && (i = t, e = void 0, t = void 0), typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, e ?? "utf8")), i && this.once("finish", i), t ? super.end(t, i) : super.end(i), this;
1790
+ }
1791
+ }, Pn = (s) => s.isFile() ? "File" : s.isDirectory() ? "Directory" : s.isSymbolicLink() ? "SymbolicLink" : "Unsupported";
1792
+ var oi = class s {
1793
+ tail;
1794
+ head;
1795
+ length = 0;
1796
+ static create(t = []) {
1797
+ return new s(t);
1798
+ }
1799
+ constructor(t = []) {
1800
+ for (let e of t) this.push(e);
1801
+ }
1802
+ *[Symbol.iterator]() {
1803
+ for (let t = this.head; t; t = t.next) yield t.value;
1804
+ }
1805
+ removeNode(t) {
1806
+ if (t.list !== this) throw new Error("removing node which does not belong to this list");
1807
+ let e = t.next, i = t.prev;
1808
+ return e && (e.prev = i), i && (i.next = e), t === this.head && (this.head = e), t === this.tail && (this.tail = i), this.length--, t.next = void 0, t.prev = void 0, t.list = void 0, e;
1809
+ }
1810
+ unshiftNode(t) {
1811
+ if (t === this.head) return;
1812
+ t.list && t.list.removeNode(t);
1813
+ let e = this.head;
1814
+ t.list = this, t.next = e, e && (e.prev = t), this.head = t, this.tail || (this.tail = t), this.length++;
1815
+ }
1816
+ pushNode(t) {
1817
+ if (t === this.tail) return;
1818
+ t.list && t.list.removeNode(t);
1819
+ let e = this.tail;
1820
+ t.list = this, t.prev = e, e && (e.next = t), this.tail = t, this.head || (this.head = t), this.length++;
1821
+ }
1822
+ push(...t) {
1823
+ for (let e = 0, i = t.length; e < i; e++) Un(this, t[e]);
1824
+ return this.length;
1825
+ }
1826
+ unshift(...t) {
1827
+ for (var e = 0, i = t.length; e < i; e++) Hn(this, t[e]);
1828
+ return this.length;
1829
+ }
1830
+ pop() {
1831
+ if (!this.tail) return;
1832
+ let t = this.tail.value, e = this.tail;
1833
+ return this.tail = this.tail.prev, this.tail ? this.tail.next = void 0 : this.head = void 0, e.list = void 0, this.length--, t;
1834
+ }
1835
+ shift() {
1836
+ if (!this.head) return;
1837
+ let t = this.head.value, e = this.head;
1838
+ return this.head = this.head.next, this.head ? this.head.prev = void 0 : this.tail = void 0, e.list = void 0, this.length--, t;
1839
+ }
1840
+ forEach(t, e) {
1841
+ e = e || this;
1842
+ for (let i = this.head, r = 0; i; r++) t.call(e, i.value, r, this), i = i.next;
1843
+ }
1844
+ forEachReverse(t, e) {
1845
+ e = e || this;
1846
+ for (let i = this.tail, r = this.length - 1; i; r--) t.call(e, i.value, r, this), i = i.prev;
1847
+ }
1848
+ get(t) {
1849
+ let e = 0, i = this.head;
1850
+ for (; i && e < t; e++) i = i.next;
1851
+ if (e === t && i) return i.value;
1852
+ }
1853
+ getReverse(t) {
1854
+ let e = 0, i = this.tail;
1855
+ for (; i && e < t; e++) i = i.prev;
1856
+ if (e === t && i) return i.value;
1857
+ }
1858
+ map(t, e) {
1859
+ e = e || this;
1860
+ let i = new s();
1861
+ for (let r = this.head; r;) i.push(t.call(e, r.value, this)), r = r.next;
1862
+ return i;
1863
+ }
1864
+ mapReverse(t, e) {
1865
+ e = e || this;
1866
+ var i = new s();
1867
+ for (let r = this.tail; r;) i.push(t.call(e, r.value, this)), r = r.prev;
1868
+ return i;
1869
+ }
1870
+ reduce(t, e) {
1871
+ let i, r = this.head;
1872
+ if (arguments.length > 1) i = e;
1873
+ else if (this.head) r = this.head.next, i = this.head.value;
1874
+ else throw new TypeError("Reduce of empty list with no initial value");
1875
+ for (var n = 0; r; n++) i = t(i, r.value, n), r = r.next;
1876
+ return i;
1877
+ }
1878
+ reduceReverse(t, e) {
1879
+ let i, r = this.tail;
1880
+ if (arguments.length > 1) i = e;
1881
+ else if (this.tail) r = this.tail.prev, i = this.tail.value;
1882
+ else throw new TypeError("Reduce of empty list with no initial value");
1883
+ for (let n = this.length - 1; r; n--) i = t(i, r.value, n), r = r.prev;
1884
+ return i;
1885
+ }
1886
+ toArray() {
1887
+ let t = new Array(this.length);
1888
+ for (let e = 0, i = this.head; i; e++) t[e] = i.value, i = i.next;
1889
+ return t;
1890
+ }
1891
+ toArrayReverse() {
1892
+ let t = new Array(this.length);
1893
+ for (let e = 0, i = this.tail; i; e++) t[e] = i.value, i = i.prev;
1894
+ return t;
1895
+ }
1896
+ slice(t = 0, e = this.length) {
1897
+ e < 0 && (e += this.length), t < 0 && (t += this.length);
1898
+ let i = new s();
1899
+ if (e < t || e < 0) return i;
1900
+ t < 0 && (t = 0), e > this.length && (e = this.length);
1901
+ let r = this.head, n = 0;
1902
+ for (n = 0; r && n < t; n++) r = r.next;
1903
+ for (; r && n < e; n++, r = r.next) i.push(r.value);
1904
+ return i;
1905
+ }
1906
+ sliceReverse(t = 0, e = this.length) {
1907
+ e < 0 && (e += this.length), t < 0 && (t += this.length);
1908
+ let i = new s();
1909
+ if (e < t || e < 0) return i;
1910
+ t < 0 && (t = 0), e > this.length && (e = this.length);
1911
+ let r = this.length, n = this.tail;
1912
+ for (; n && r > e; r--) n = n.prev;
1913
+ for (; n && r > t; r--, n = n.prev) i.push(n.value);
1914
+ return i;
1915
+ }
1916
+ splice(t, e = 0, ...i) {
1917
+ t > this.length && (t = this.length - 1), t < 0 && (t = this.length + t);
1918
+ let r = this.head;
1919
+ for (let o = 0; r && o < t; o++) r = r.next;
1920
+ let n = [];
1921
+ for (let o = 0; r && o < e; o++) n.push(r.value), r = this.removeNode(r);
1922
+ r ? r !== this.tail && (r = r.prev) : r = this.tail;
1923
+ for (let o of i) r = zn(this, r, o);
1924
+ return n;
1925
+ }
1926
+ reverse() {
1927
+ let t = this.head, e = this.tail;
1928
+ for (let i = t; i; i = i.prev) {
1929
+ let r = i.prev;
1930
+ i.prev = i.next, i.next = r;
1931
+ }
1932
+ return this.head = e, this.tail = t, this;
1933
+ }
1934
+ };
1935
+ function zn(s, t, e) {
1936
+ let n = new de(e, t, t ? t.next : s.head, s);
1937
+ return n.next === void 0 && (s.tail = n), n.prev === void 0 && (s.head = n), s.length++, n;
1938
+ }
1939
+ function Un(s, t) {
1940
+ s.tail = new de(t, s.tail, void 0, s), s.head || (s.head = s.tail), s.length++;
1941
+ }
1942
+ function Hn(s, t) {
1943
+ s.head = new de(t, void 0, s.head, s), s.tail || (s.tail = s.head), s.length++;
1944
+ }
1945
+ var de = class {
1946
+ list;
1947
+ next;
1948
+ prev;
1949
+ value;
1950
+ constructor(t, e, i, r) {
1951
+ this.list = r, this.value = t, e ? (e.next = this, this.prev = e) : this.prev = void 0, i ? (i.prev = this, this.next = i) : this.next = void 0;
1952
+ }
1953
+ };
1954
+ var mi = class {
1955
+ path;
1956
+ absolute;
1957
+ entry;
1958
+ stat;
1959
+ readdir;
1960
+ pending = !1;
1961
+ pendingLink = !1;
1962
+ ignore = !1;
1963
+ piped = !1;
1964
+ constructor(t, e) {
1965
+ this.path = t || "./", this.absolute = e;
1966
+ }
1967
+ }, ir = Buffer.alloc(1024), ai = Symbol("onStat"), ue = Symbol("ended"), W$1 = Symbol("queue"), me = Symbol("pendingLinks"), Et = Symbol("current"), Ct = Symbol("process"), pe = Symbol("processing"), hi = Symbol("processJob"), G = Symbol("jobs"), hs = Symbol("jobDone"), li = Symbol("addFSEntry"), sr = Symbol("addTarEntry"), cs = Symbol("stat"), fs$1 = Symbol("readdir"), ci = Symbol("onreaddir"), fi = Symbol("pipe"), rr = Symbol("entry"), as = Symbol("entryOpt"), di = Symbol("writeEntryClass"), or = Symbol("write"), ls = Symbol("ondrain"), wt = class extends A$1 {
1968
+ sync = !1;
1969
+ opt;
1970
+ cwd;
1971
+ maxReadSize;
1972
+ preservePaths;
1973
+ strict;
1974
+ noPax;
1975
+ prefix;
1976
+ linkCache;
1977
+ statCache;
1978
+ file;
1979
+ portable;
1980
+ zip;
1981
+ readdirCache;
1982
+ noDirRecurse;
1983
+ follow;
1984
+ noMtime;
1985
+ mtime;
1986
+ filter;
1987
+ jobs;
1988
+ [di];
1989
+ onWriteEntry;
1990
+ [W$1];
1991
+ [me] = /* @__PURE__ */ new Map();
1992
+ [G] = 0;
1993
+ [pe] = !1;
1994
+ [ue] = !1;
1995
+ constructor(t = {}) {
1996
+ if (super(), this.opt = t, this.file = t.file || "", this.cwd = t.cwd || process.cwd(), this.maxReadSize = t.maxReadSize, this.preservePaths = !!t.preservePaths, this.strict = !!t.strict, this.noPax = !!t.noPax, this.prefix = f$1(t.prefix || ""), this.linkCache = t.linkCache || /* @__PURE__ */ new Map(), this.statCache = t.statCache || /* @__PURE__ */ new Map(), this.readdirCache = t.readdirCache || /* @__PURE__ */ new Map(), this.onWriteEntry = t.onWriteEntry, this[di] = fe, typeof t.onwarn == "function" && this.on("warn", t.onwarn), this.portable = !!t.portable, t.gzip || t.brotli || t.zstd) {
1997
+ if ((t.gzip ? 1 : 0) + (t.brotli ? 1 : 0) + (t.zstd ? 1 : 0) > 1) throw new TypeError("gzip, brotli, zstd are mutually exclusive");
1998
+ if (t.gzip && (typeof t.gzip != "object" && (t.gzip = {}), this.portable && (t.gzip.portable = !0), this.zip = new Pe(t.gzip)), t.brotli && (typeof t.brotli != "object" && (t.brotli = {}), this.zip = new He(t.brotli)), t.zstd && (typeof t.zstd != "object" && (t.zstd = {}), this.zip = new Ze(t.zstd)), !this.zip) throw new Error("impossible");
1999
+ let e = this.zip;
2000
+ e.on("data", (i) => super.write(i)), e.on("end", () => super.end()), e.on("drain", () => this[ls]()), this.on("resume", () => e.resume());
2001
+ } else this.on("drain", this[ls]);
2002
+ this.noDirRecurse = !!t.noDirRecurse, this.follow = !!t.follow, this.noMtime = !!t.noMtime, t.mtime && (this.mtime = t.mtime), this.filter = typeof t.filter == "function" ? t.filter : () => !0, this[W$1] = new oi(), this[G] = 0, this.jobs = Number(t.jobs) || 4, this[pe] = !1, this[ue] = !1;
2003
+ }
2004
+ [or](t) {
2005
+ return super.write(t);
2006
+ }
2007
+ add(t) {
2008
+ return this.write(t), this;
2009
+ }
2010
+ end(t, e, i) {
2011
+ return typeof t == "function" && (i = t, t = void 0), typeof e == "function" && (i = e, e = void 0), t && this.add(t), this[ue] = !0, this[Ct](), i && i(), this;
2012
+ }
2013
+ write(t) {
2014
+ if (this[ue]) throw new Error("write after end");
2015
+ return typeof t == "string" ? this[li](t) : this[sr](t), this.flowing;
2016
+ }
2017
+ [sr](t) {
2018
+ let e = f$1(path.default.resolve(this.cwd, t.path));
2019
+ if (!this.filter(t.path, t)) t.resume();
2020
+ else {
2021
+ let i = new mi(t.path, e);
2022
+ i.entry = new ni(t, this[as](i)), i.entry.on("end", () => this[hs](i)), this[G] += 1, this[W$1].push(i);
2023
+ }
2024
+ this[Ct]();
2025
+ }
2026
+ [li](t) {
2027
+ let e = f$1(path.default.resolve(this.cwd, t));
2028
+ this[W$1].push(new mi(t, e)), this[Ct]();
2029
+ }
2030
+ [cs](t) {
2031
+ t.pending = !0, this[G] += 1;
2032
+ fs.default[this.follow ? "stat" : "lstat"](t.absolute, (i, r) => {
2033
+ t.pending = !1, this[G] -= 1, i ? this.emit("error", i) : this[ai](t, r);
2034
+ });
2035
+ }
2036
+ [ai](t, e) {
2037
+ if (this.statCache.set(t.absolute, e), t.stat = e, !this.filter(t.path, e)) t.ignore = !0;
2038
+ else if (e.isFile() && e.nlink > 1 && !this.linkCache.get(`${e.dev}:${e.ino}`) && !this.sync) if (t === this[Et]) this[hi](t);
2039
+ else {
2040
+ let i = `${e.dev}:${e.ino}`, r = this[me].get(i);
2041
+ r ? r.push(t) : this[me].set(i, [t]), t.pendingLink = !0, t.pending = !0;
2042
+ }
2043
+ this[Ct]();
2044
+ }
2045
+ [fs$1](t) {
2046
+ t.pending = !0, this[G] += 1, fs.default.readdir(t.absolute, (e, i) => {
2047
+ if (t.pending = !1, this[G] -= 1, e) return this.emit("error", e);
2048
+ this[ci](t, i);
2049
+ });
2050
+ }
2051
+ [ci](t, e) {
2052
+ this.readdirCache.set(t.absolute, e), t.readdir = e, this[Ct]();
2053
+ }
2054
+ [Ct]() {
2055
+ if (!this[pe]) {
2056
+ this[pe] = !0;
2057
+ for (let t = this[W$1].head; t && this[G] < this.jobs; t = t.next) if (this[hi](t.value), t.value.ignore) {
2058
+ let e = t.next;
2059
+ this[W$1].removeNode(t), t.next = e;
2060
+ }
2061
+ this[pe] = !1, this[ue] && this[W$1].length === 0 && this[G] === 0 && (this.zip ? this.zip.end(ir) : (super.write(ir), super.end()));
2062
+ }
2063
+ }
2064
+ get [Et]() {
2065
+ return this[W$1] && this[W$1].head && this[W$1].head.value;
2066
+ }
2067
+ [hs](t) {
2068
+ this[W$1].shift(), this[G] -= 1;
2069
+ let { stat: e } = t;
2070
+ if (e && e.isFile() && e.nlink > 1) {
2071
+ let i = `${e.dev}:${e.ino}`, r = this[me].get(i);
2072
+ if (r) {
2073
+ this[me].delete(i);
2074
+ for (let n of r) n.pending = !1, this[hi](n);
2075
+ }
2076
+ }
2077
+ this[Ct]();
2078
+ }
2079
+ [hi](t) {
2080
+ if (t.pending && t.pendingLink && t === this[Et] && (t.pending = !1, t.pendingLink = !1), !t.pending) {
2081
+ if (t.entry) {
2082
+ t === this[Et] && !t.piped && this[fi](t);
2083
+ return;
2084
+ }
2085
+ if (!t.stat) {
2086
+ let e = this.statCache.get(t.absolute);
2087
+ e ? this[ai](t, e) : this[cs](t);
2088
+ }
2089
+ if (t.stat && !t.ignore) {
2090
+ if (!this.noDirRecurse && t.stat.isDirectory() && !t.readdir) {
2091
+ let e = this.readdirCache.get(t.absolute);
2092
+ if (e ? this[ci](t, e) : this[fs$1](t), !t.readdir) return;
2093
+ }
2094
+ if (t.entry = this[rr](t), !t.entry) {
2095
+ t.ignore = !0;
2096
+ return;
2097
+ }
2098
+ t === this[Et] && !t.piped && this[fi](t);
2099
+ }
2100
+ }
2101
+ }
2102
+ [as](t) {
2103
+ return {
2104
+ onwarn: (e, i, r) => this.warn(e, i, r),
2105
+ noPax: this.noPax,
2106
+ cwd: this.cwd,
2107
+ absolute: t.absolute,
2108
+ preservePaths: this.preservePaths,
2109
+ maxReadSize: this.maxReadSize,
2110
+ strict: this.strict,
2111
+ portable: this.portable,
2112
+ linkCache: this.linkCache,
2113
+ statCache: this.statCache,
2114
+ noMtime: this.noMtime,
2115
+ mtime: this.mtime,
2116
+ prefix: this.prefix,
2117
+ onWriteEntry: this.onWriteEntry
2118
+ };
2119
+ }
2120
+ [rr](t) {
2121
+ this[G] += 1;
2122
+ try {
2123
+ return new this[di](t.path, this[as](t)).on("end", () => this[hs](t)).on("error", (i) => this.emit("error", i));
2124
+ } catch (e) {
2125
+ this.emit("error", e);
2126
+ }
2127
+ }
2128
+ [ls]() {
2129
+ this[Et] && this[Et].entry && this[Et].entry.resume();
2130
+ }
2131
+ [fi](t) {
2132
+ t.piped = !0, t.readdir && t.readdir.forEach((r) => {
2133
+ let n = t.path, o = n === "./" ? "" : n.replace(/\/*$/, "/");
2134
+ this[li](o + r);
2135
+ });
2136
+ let e = t.entry, i = this.zip;
2137
+ if (!e) throw new Error("cannot pipe without source");
2138
+ i ? e.on("data", (r) => {
2139
+ i.write(r) || e.pause();
2140
+ }) : e.on("data", (r) => {
2141
+ super.write(r) || e.pause();
2142
+ });
2143
+ }
2144
+ pause() {
2145
+ return this.zip && this.zip.pause(), super.pause();
2146
+ }
2147
+ warn(t, e, i = {}) {
2148
+ Nt(this, t, e, i);
2149
+ }
2150
+ }, kt = class extends wt {
2151
+ sync = !0;
2152
+ constructor(t) {
2153
+ super(t), this[di] = ri;
2154
+ }
2155
+ pause() {}
2156
+ resume() {}
2157
+ [cs](t) {
2158
+ let e = this.follow ? "statSync" : "lstatSync";
2159
+ this[ai](t, fs.default[e](t.absolute));
2160
+ }
2161
+ [fs$1](t) {
2162
+ this[ci](t, fs.default.readdirSync(t.absolute));
2163
+ }
2164
+ [fi](t) {
2165
+ let e = t.entry, i = this.zip;
2166
+ if (t.readdir && t.readdir.forEach((r) => {
2167
+ let n = t.path, o = n === "./" ? "" : n.replace(/\/*$/, "/");
2168
+ this[li](o + r);
2169
+ }), !e) throw new Error("Cannot pipe without source");
2170
+ i ? e.on("data", (r) => {
2171
+ i.write(r);
2172
+ }) : e.on("data", (r) => {
2173
+ super[or](r);
2174
+ });
2175
+ }
2176
+ };
2177
+ var Wn = (s, t) => {
2178
+ let e = new kt(s), i = new Wt(s.file, { mode: s.mode || 438 });
2179
+ e.pipe(i), ar(e, t);
2180
+ }, Gn = (s, t) => {
2181
+ let e = new wt(s), i = new tt(s.file, { mode: s.mode || 438 });
2182
+ e.pipe(i);
2183
+ let r = new Promise((n, o) => {
2184
+ i.on("error", o), i.on("close", n), e.on("error", o);
2185
+ });
2186
+ return lr(e, t).catch((n) => e.emit("error", n)), r;
2187
+ }, ar = (s, t) => {
2188
+ t.forEach((e) => {
2189
+ e.charAt(0) === "@" ? Ft({
2190
+ file: node_path$1.default.resolve(s.cwd, e.slice(1)),
2191
+ sync: !0,
2192
+ noResume: !0,
2193
+ onReadEntry: (i) => s.add(i)
2194
+ }) : s.add(e);
2195
+ }), s.end();
2196
+ }, lr = async (s, t) => {
2197
+ for (let e of t) e.charAt(0) === "@" ? await Ft({
2198
+ file: node_path$1.default.resolve(String(s.cwd), e.slice(1)),
2199
+ noResume: !0,
2200
+ onReadEntry: (i) => {
2201
+ s.add(i);
2202
+ }
2203
+ }) : s.add(e);
2204
+ s.end();
2205
+ }, Zn = (s, t) => {
2206
+ let e = new kt(s);
2207
+ return ar(e, t), e;
2208
+ }, Yn = (s, t) => {
2209
+ let e = new wt(s);
2210
+ return lr(e, t).catch((i) => e.emit("error", i)), e;
2211
+ }, Kn = K(Wn, Gn, Zn, Yn, (s, t) => {
2212
+ if (!t?.length) throw new TypeError("no paths specified to add to archive");
2213
+ });
2214
+ var ur = (process.env.__FAKE_PLATFORM__ || process.platform) === "win32", { O_CREAT: mr, O_NOFOLLOW: cr, O_TRUNC: pr, O_WRONLY: Er } = fs.default.constants, wr = Number(process.env.__FAKE_FS_O_FILENAME__) || fs.default.constants.UV_FS_O_FILEMAP || 0, $n = ur && !!wr, Xn = 512 * 1024, qn = wr | pr | mr | Er, fr = !ur && typeof cr == "number" ? cr | pr | mr | Er : null, ds = fr !== null ? () => fr : $n ? (s) => s < Xn ? qn : "w" : () => "w";
2215
+ var us = (s, t, e) => {
2216
+ try {
2217
+ return node_fs$1.default.lchownSync(s, t, e);
2218
+ } catch (i) {
2219
+ if (i?.code !== "ENOENT") throw i;
2220
+ }
2221
+ }, pi = (s, t, e, i) => {
2222
+ node_fs$1.default.lchown(s, t, e, (r) => {
2223
+ i(r && r?.code !== "ENOENT" ? r : null);
2224
+ });
2225
+ }, Qn = (s, t, e, i, r) => {
2226
+ if (t.isDirectory()) ms(node_path$1.default.resolve(s, t.name), e, i, (n) => {
2227
+ if (n) return r(n);
2228
+ pi(node_path$1.default.resolve(s, t.name), e, i, r);
2229
+ });
2230
+ else pi(node_path$1.default.resolve(s, t.name), e, i, r);
2231
+ }, ms = (s, t, e, i) => {
2232
+ node_fs$1.default.readdir(s, { withFileTypes: !0 }, (r, n) => {
2233
+ if (r) {
2234
+ if (r.code === "ENOENT") return i();
2235
+ if (r.code !== "ENOTDIR" && r.code !== "ENOTSUP") return i(r);
2236
+ }
2237
+ if (r || !n.length) return pi(s, t, e, i);
2238
+ let o = n.length, a = null, h = (l) => {
2239
+ if (!a) {
2240
+ if (l) return i(a = l);
2241
+ if (--o === 0) return pi(s, t, e, i);
2242
+ }
2243
+ };
2244
+ for (let l of n) Qn(s, l, t, e, h);
2245
+ });
2246
+ }, Jn = (s, t, e, i) => {
2247
+ t.isDirectory() && ps(node_path$1.default.resolve(s, t.name), e, i), us(node_path$1.default.resolve(s, t.name), e, i);
2248
+ }, ps = (s, t, e) => {
2249
+ let i;
2250
+ try {
2251
+ i = node_fs$1.default.readdirSync(s, { withFileTypes: !0 });
2252
+ } catch (r) {
2253
+ let n = r;
2254
+ if (n?.code === "ENOENT") return;
2255
+ if (n?.code === "ENOTDIR" || n?.code === "ENOTSUP") return us(s, t, e);
2256
+ throw n;
2257
+ }
2258
+ for (let r of i) Jn(s, r, t, e);
2259
+ return us(s, t, e);
2260
+ };
2261
+ var we = class extends Error {
2262
+ path;
2263
+ code;
2264
+ syscall = "chdir";
2265
+ constructor(t, e) {
2266
+ super(`${e}: Cannot cd into '${t}'`), this.path = t, this.code = e;
2267
+ }
2268
+ get name() {
2269
+ return "CwdError";
2270
+ }
2271
+ };
2272
+ var St = class extends Error {
2273
+ path;
2274
+ symlink;
2275
+ syscall = "symlink";
2276
+ code = "TAR_SYMLINK_ERROR";
2277
+ constructor(t, e) {
2278
+ super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"), this.symlink = t, this.path = e;
2279
+ }
2280
+ get name() {
2281
+ return "SymlinkError";
2282
+ }
2283
+ };
2284
+ var to = (s, t) => {
2285
+ node_fs$1.default.stat(s, (e, i) => {
2286
+ (e || !i.isDirectory()) && (e = new we(s, e?.code || "ENOTDIR")), t(e);
2287
+ });
2288
+ }, Sr = (s, t, e) => {
2289
+ s = f$1(s);
2290
+ let i = t.umask ?? 18, r = t.mode | 448, n = (r & i) !== 0, o = t.uid, a = t.gid, h = typeof o == "number" && typeof a == "number" && (o !== t.processUid || a !== t.processGid), l = t.preserve, c = t.unlink, d = f$1(t.cwd), S = (E, x) => {
2291
+ E ? e(E) : x && h ? ms(x, o, a, (xe) => S(xe)) : n ? node_fs$1.default.chmod(s, r, e) : e();
2292
+ };
2293
+ if (s === d) return to(s, S);
2294
+ if (l) return node_fs_promises$1.default.mkdir(s, {
2295
+ mode: r,
2296
+ recursive: !0
2297
+ }).then((E) => S(null, E ?? void 0), S);
2298
+ Es(d, f$1(node_path$1.default.relative(d, s)).split("/"), r, c, d, void 0, S);
2299
+ }, Es = (s, t, e, i, r, n, o) => {
2300
+ if (t.length === 0) return o(null, n);
2301
+ let a = t.shift(), h = f$1(node_path$1.default.resolve(s + "/" + a));
2302
+ node_fs$1.default.mkdir(h, e, yr(h, t, e, i, r, n, o));
2303
+ }, yr = (s, t, e, i, r, n, o) => (a) => {
2304
+ a ? node_fs$1.default.lstat(s, (h, l) => {
2305
+ if (h) h.path = h.path && f$1(h.path), o(h);
2306
+ else if (l.isDirectory()) Es(s, t, e, i, r, n, o);
2307
+ else if (i) node_fs$1.default.unlink(s, (c) => {
2308
+ if (c) return o(c);
2309
+ node_fs$1.default.mkdir(s, e, yr(s, t, e, i, r, n, o));
2310
+ });
2311
+ else {
2312
+ if (l.isSymbolicLink()) return o(new St(s, s + "/" + t.join("/")));
2313
+ o(a);
2314
+ }
2315
+ }) : (n = n || s, Es(s, t, e, i, r, n, o));
2316
+ }, eo = (s) => {
2317
+ let t = !1, e;
2318
+ try {
2319
+ t = node_fs$1.default.statSync(s).isDirectory();
2320
+ } catch (i) {
2321
+ e = i?.code;
2322
+ } finally {
2323
+ if (!t) throw new we(s, e ?? "ENOTDIR");
2324
+ }
2325
+ }, Rr = (s, t) => {
2326
+ s = f$1(s);
2327
+ let e = t.umask ?? 18, i = t.mode | 448, r = (i & e) !== 0, n = t.uid, o = t.gid, a = typeof n == "number" && typeof o == "number" && (n !== t.processUid || o !== t.processGid), h = t.preserve, l = t.unlink, c = f$1(t.cwd), d = (E) => {
2328
+ E && a && ps(E, n, o), r && node_fs$1.default.chmodSync(s, i);
2329
+ };
2330
+ if (s === c) return eo(c), d();
2331
+ if (h) return d(node_fs$1.default.mkdirSync(s, {
2332
+ mode: i,
2333
+ recursive: !0
2334
+ }) ?? void 0);
2335
+ let T = f$1(node_path$1.default.relative(c, s)).split("/"), N;
2336
+ for (let E = T.shift(), x = c; E && (x += "/" + E); E = T.shift()) {
2337
+ x = f$1(node_path$1.default.resolve(x));
2338
+ try {
2339
+ node_fs$1.default.mkdirSync(x, i), N = N || x;
2340
+ } catch {
2341
+ let xe = node_fs$1.default.lstatSync(x);
2342
+ if (xe.isDirectory()) continue;
2343
+ if (l) {
2344
+ node_fs$1.default.unlinkSync(x), node_fs$1.default.mkdirSync(x, i), N = N || x;
2345
+ continue;
2346
+ } else if (xe.isSymbolicLink()) return new St(x, x + "/" + T.join("/"));
2347
+ }
2348
+ }
2349
+ return d(N);
2350
+ };
2351
+ var ws = Object.create(null), gr = 1e4, Vt = /* @__PURE__ */ new Set(), br = (s) => {
2352
+ Vt.has(s) ? Vt.delete(s) : ws[s] = s.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"), Vt.add(s);
2353
+ let t = ws[s], e = Vt.size - gr;
2354
+ if (e > gr / 10) {
2355
+ for (let i of Vt) if (Vt.delete(i), delete ws[i], --e <= 0) break;
2356
+ }
2357
+ return t;
2358
+ };
2359
+ var so = (process.env.TESTING_TAR_FAKE_PLATFORM || process.platform) === "win32", ro = (s) => s.split("/").slice(0, -1).reduce((e, i) => {
2360
+ let r = e.at(-1);
2361
+ return r !== void 0 && (i = (0, node_path$1.join)(r, i)), e.push(i || "/"), e;
2362
+ }, []), Si = class {
2363
+ #t = /* @__PURE__ */ new Map();
2364
+ #i = /* @__PURE__ */ new Map();
2365
+ #s = /* @__PURE__ */ new Set();
2366
+ reserve(t, e) {
2367
+ t = so ? ["win32 parallelization disabled"] : t.map((r) => mt((0, node_path$1.join)(br(r))));
2368
+ let i = new Set(t.map((r) => ro(r)).reduce((r, n) => r.concat(n)));
2369
+ this.#i.set(e, {
2370
+ dirs: i,
2371
+ paths: t
2372
+ });
2373
+ for (let r of t) {
2374
+ let n = this.#t.get(r);
2375
+ n ? n.push(e) : this.#t.set(r, [e]);
2376
+ }
2377
+ for (let r of i) {
2378
+ let n = this.#t.get(r);
2379
+ if (!n) this.#t.set(r, [new Set([e])]);
2380
+ else {
2381
+ let o = n.at(-1);
2382
+ o instanceof Set ? o.add(e) : n.push(new Set([e]));
2383
+ }
2384
+ }
2385
+ return this.#r(e);
2386
+ }
2387
+ #n(t) {
2388
+ let e = this.#i.get(t);
2389
+ if (!e) throw new Error("function does not have any path reservations");
2390
+ return {
2391
+ paths: e.paths.map((i) => this.#t.get(i)),
2392
+ dirs: [...e.dirs].map((i) => this.#t.get(i))
2393
+ };
2394
+ }
2395
+ check(t) {
2396
+ let { paths: e, dirs: i } = this.#n(t);
2397
+ return e.every((r) => r && r[0] === t) && i.every((r) => r && r[0] instanceof Set && r[0].has(t));
2398
+ }
2399
+ #r(t) {
2400
+ return this.#s.has(t) || !this.check(t) ? !1 : (this.#s.add(t), t(() => this.#e(t)), !0);
2401
+ }
2402
+ #e(t) {
2403
+ if (!this.#s.has(t)) return !1;
2404
+ let e = this.#i.get(t);
2405
+ if (!e) throw new Error("invalid reservation");
2406
+ let { paths: i, dirs: r } = e, n = /* @__PURE__ */ new Set();
2407
+ for (let o of i) {
2408
+ let a = this.#t.get(o);
2409
+ if (!a || a?.[0] !== t) continue;
2410
+ let h = a[1];
2411
+ if (!h) {
2412
+ this.#t.delete(o);
2413
+ continue;
2414
+ }
2415
+ if (a.shift(), typeof h == "function") n.add(h);
2416
+ else for (let l of h) n.add(l);
2417
+ }
2418
+ for (let o of r) {
2419
+ let a = this.#t.get(o), h = a?.[0];
2420
+ if (!(!a || !(h instanceof Set))) if (h.size === 1 && a.length === 1) {
2421
+ this.#t.delete(o);
2422
+ continue;
2423
+ } else if (h.size === 1) {
2424
+ a.shift();
2425
+ let l = a[0];
2426
+ typeof l == "function" && n.add(l);
2427
+ } else h.delete(t);
2428
+ }
2429
+ return this.#s.delete(t), n.forEach((o) => this.#r(o)), !0;
2430
+ }
2431
+ };
2432
+ var Or = () => process.umask();
2433
+ var Tr = Symbol("onEntry"), gs = Symbol("checkFs"), xr = Symbol("checkFs2"), bs = Symbol("isReusable"), P$1 = Symbol("makeFs"), _s = Symbol("file"), Os = Symbol("directory"), Ri = Symbol("link"), Lr = Symbol("symlink"), Nr = Symbol("hardlink"), ye = Symbol("ensureNoSymlink"), Dr = Symbol("unsupported"), Ar = Symbol("checkPath"), Ss = Symbol("stripAbsolutePath"), yt = Symbol("mkdir"), O$1 = Symbol("onError"), yi = Symbol("pending"), Ir = Symbol("pend"), $t = Symbol("unpend"), ys = Symbol("ended"), Rs = Symbol("maybeClose"), Ts = Symbol("skip"), Re = Symbol("doChown"), ge = Symbol("uid"), be = Symbol("gid"), _e = Symbol("checkedCwd"), Oe = (process.env.TESTING_TAR_FAKE_PLATFORM || process.platform) === "win32", ho = 1024, ao = (s, t) => {
2434
+ if (!Oe) return node_fs$1.default.unlink(s, t);
2435
+ let e = s + ".DELETE." + (0, node_crypto.randomBytes)(16).toString("hex");
2436
+ node_fs$1.default.rename(s, e, (i) => {
2437
+ if (i) return t(i);
2438
+ node_fs$1.default.unlink(e, t);
2439
+ });
2440
+ }, lo = (s) => {
2441
+ if (!Oe) return node_fs$1.default.unlinkSync(s);
2442
+ let t = s + ".DELETE." + (0, node_crypto.randomBytes)(16).toString("hex");
2443
+ node_fs$1.default.renameSync(s, t), node_fs$1.default.unlinkSync(t);
2444
+ }, Fr = (s, t, e) => s !== void 0 && s === s >>> 0 ? s : t !== void 0 && t === t >>> 0 ? t : e, Xt = class extends st {
2445
+ [ys] = !1;
2446
+ [_e] = !1;
2447
+ [yi] = 0;
2448
+ reservations = new Si();
2449
+ transform;
2450
+ writable = !0;
2451
+ readable = !1;
2452
+ uid;
2453
+ gid;
2454
+ setOwner;
2455
+ preserveOwner;
2456
+ processGid;
2457
+ processUid;
2458
+ maxDepth;
2459
+ forceChown;
2460
+ win32;
2461
+ newer;
2462
+ keep;
2463
+ noMtime;
2464
+ preservePaths;
2465
+ unlink;
2466
+ cwd;
2467
+ strip;
2468
+ processUmask;
2469
+ umask;
2470
+ dmode;
2471
+ fmode;
2472
+ chmod;
2473
+ constructor(t = {}) {
2474
+ if (t.ondone = () => {
2475
+ this[ys] = !0, this[Rs]();
2476
+ }, super(t), this.transform = t.transform, this.chmod = !!t.chmod, typeof t.uid == "number" || typeof t.gid == "number") {
2477
+ if (typeof t.uid != "number" || typeof t.gid != "number") throw new TypeError("cannot set owner without number uid and gid");
2478
+ if (t.preserveOwner) throw new TypeError("cannot preserve owner in archive and also set owner explicitly");
2479
+ this.uid = t.uid, this.gid = t.gid, this.setOwner = !0;
2480
+ } else this.uid = void 0, this.gid = void 0, this.setOwner = !1;
2481
+ this.preserveOwner = t.preserveOwner === void 0 && typeof t.uid != "number" ? !!(process.getuid && process.getuid() === 0) : !!t.preserveOwner, this.processUid = (this.preserveOwner || this.setOwner) && process.getuid ? process.getuid() : void 0, this.processGid = (this.preserveOwner || this.setOwner) && process.getgid ? process.getgid() : void 0, this.maxDepth = typeof t.maxDepth == "number" ? t.maxDepth : ho, this.forceChown = t.forceChown === !0, this.win32 = !!t.win32 || Oe, this.newer = !!t.newer, this.keep = !!t.keep, this.noMtime = !!t.noMtime, this.preservePaths = !!t.preservePaths, this.unlink = !!t.unlink, this.cwd = f$1(node_path$1.default.resolve(t.cwd || process.cwd())), this.strip = Number(t.strip) || 0, this.processUmask = this.chmod ? typeof t.processUmask == "number" ? t.processUmask : Or() : 0, this.umask = typeof t.umask == "number" ? t.umask : this.processUmask, this.dmode = t.dmode || 511 & ~this.umask, this.fmode = t.fmode || 438 & ~this.umask, this.on("entry", (e) => this[Tr](e));
2482
+ }
2483
+ warn(t, e, i = {}) {
2484
+ return (t === "TAR_BAD_ARCHIVE" || t === "TAR_ABORT") && (i.recoverable = !1), super.warn(t, e, i);
2485
+ }
2486
+ [Rs]() {
2487
+ this[ys] && this[yi] === 0 && (this.emit("prefinish"), this.emit("finish"), this.emit("end"));
2488
+ }
2489
+ [Ss](t, e) {
2490
+ let i = t[e], { type: r } = t;
2491
+ if (!i || this.preservePaths) return !0;
2492
+ let [n, o] = le(i), a = o.replaceAll(/\\/g, "/").split("/");
2493
+ if (a.includes("..") || Oe && /^[a-z]:\.\.$/i.test(a[0] ?? "")) {
2494
+ if (e === "path" || r === "Link") return this.warn("TAR_ENTRY_ERROR", `${e} contains '..'`, {
2495
+ entry: t,
2496
+ [e]: i
2497
+ }), !1;
2498
+ let h = node_path$1.default.posix.dirname(t.path), l = node_path$1.default.posix.normalize(node_path$1.default.posix.join(h, a.join("/")));
2499
+ if (l.startsWith("../") || l === "..") return this.warn("TAR_ENTRY_ERROR", `${e} escapes extraction directory`, {
2500
+ entry: t,
2501
+ [e]: i
2502
+ }), !1;
2503
+ }
2504
+ return n && (t[e] = String(o), this.warn("TAR_ENTRY_INFO", `stripping ${n} from absolute ${e}`, {
2505
+ entry: t,
2506
+ [e]: i
2507
+ })), !0;
2508
+ }
2509
+ [Ar](t) {
2510
+ let e = f$1(t.path), i = e.split("/");
2511
+ if (this.strip) {
2512
+ if (i.length < this.strip) return !1;
2513
+ if (t.type === "Link") {
2514
+ let r = f$1(String(t.linkpath)).split("/");
2515
+ if (r.length >= this.strip) t.linkpath = r.slice(this.strip).join("/");
2516
+ else return !1;
2517
+ }
2518
+ i.splice(0, this.strip), t.path = i.join("/");
2519
+ }
2520
+ if (isFinite(this.maxDepth) && i.length > this.maxDepth) return this.warn("TAR_ENTRY_ERROR", "path excessively deep", {
2521
+ entry: t,
2522
+ path: e,
2523
+ depth: i.length,
2524
+ maxDepth: this.maxDepth
2525
+ }), !1;
2526
+ if (!this[Ss](t, "path") || !this[Ss](t, "linkpath")) return !1;
2527
+ if (t.absolute = node_path$1.default.isAbsolute(t.path) ? f$1(node_path$1.default.resolve(t.path)) : f$1(node_path$1.default.resolve(this.cwd, t.path)), !this.preservePaths && typeof t.absolute == "string" && t.absolute.indexOf(this.cwd + "/") !== 0 && t.absolute !== this.cwd) return this.warn("TAR_ENTRY_ERROR", "path escaped extraction target", {
2528
+ entry: t,
2529
+ path: f$1(t.path),
2530
+ resolvedPath: t.absolute,
2531
+ cwd: this.cwd
2532
+ }), !1;
2533
+ if (t.absolute === this.cwd && t.type !== "Directory" && t.type !== "GNUDumpDir") return !1;
2534
+ if (this.win32) {
2535
+ let { root: r } = node_path$1.default.win32.parse(String(t.absolute));
2536
+ t.absolute = r + Ji(String(t.absolute).slice(r.length));
2537
+ let { root: n } = node_path$1.default.win32.parse(t.path);
2538
+ t.path = n + Ji(t.path.slice(n.length));
2539
+ }
2540
+ return !0;
2541
+ }
2542
+ [Tr](t) {
2543
+ if (!this[Ar](t)) return t.resume();
2544
+ switch (node_assert.default.equal(typeof t.absolute, "string"), t.type) {
2545
+ case "Directory":
2546
+ case "GNUDumpDir": t.mode && (t.mode = t.mode | 448);
2547
+ case "File":
2548
+ case "OldFile":
2549
+ case "ContiguousFile":
2550
+ case "Link":
2551
+ case "SymbolicLink": return this[gs](t);
2552
+ default: return this[Dr](t);
2553
+ }
2554
+ }
2555
+ [O$1](t, e) {
2556
+ t.name === "CwdError" ? this.emit("error", t) : (this.warn("TAR_ENTRY_ERROR", t, { entry: e }), this[$t](), e.resume());
2557
+ }
2558
+ [yt](t, e, i) {
2559
+ Sr(f$1(t), {
2560
+ uid: this.uid,
2561
+ gid: this.gid,
2562
+ processUid: this.processUid,
2563
+ processGid: this.processGid,
2564
+ umask: this.processUmask,
2565
+ preserve: this.preservePaths,
2566
+ unlink: this.unlink,
2567
+ cwd: this.cwd,
2568
+ mode: e
2569
+ }, i);
2570
+ }
2571
+ [Re](t) {
2572
+ return this.forceChown || this.preserveOwner && (typeof t.uid == "number" && t.uid !== this.processUid || typeof t.gid == "number" && t.gid !== this.processGid) || typeof this.uid == "number" && this.uid !== this.processUid || typeof this.gid == "number" && this.gid !== this.processGid;
2573
+ }
2574
+ [ge](t) {
2575
+ return Fr(this.uid, t.uid, this.processUid);
2576
+ }
2577
+ [be](t) {
2578
+ return Fr(this.gid, t.gid, this.processGid);
2579
+ }
2580
+ [_s](t, e) {
2581
+ let i = typeof t.mode == "number" ? t.mode & 4095 : this.fmode, r = new tt(String(t.absolute), {
2582
+ flags: ds(t.size),
2583
+ mode: i,
2584
+ autoClose: !1
2585
+ });
2586
+ r.on("error", (h) => {
2587
+ r.fd && node_fs$1.default.close(r.fd, () => {}), r.write = () => !0, this[O$1](h, t), e();
2588
+ });
2589
+ let n = 1, o = (h) => {
2590
+ if (h) {
2591
+ r.fd && node_fs$1.default.close(r.fd, () => {}), this[O$1](h, t), e();
2592
+ return;
2593
+ }
2594
+ --n === 0 && r.fd !== void 0 && node_fs$1.default.close(r.fd, (l) => {
2595
+ l ? this[O$1](l, t) : this[$t](), e();
2596
+ });
2597
+ };
2598
+ r.on("finish", () => {
2599
+ let h = String(t.absolute), l = r.fd;
2600
+ if (typeof l == "number" && t.mtime && !this.noMtime) {
2601
+ n++;
2602
+ let c = t.atime || /* @__PURE__ */ new Date(), d = t.mtime;
2603
+ node_fs$1.default.futimes(l, c, d, (S) => S ? node_fs$1.default.utimes(h, c, d, (T) => o(T && S)) : o());
2604
+ }
2605
+ if (typeof l == "number" && this[Re](t)) {
2606
+ n++;
2607
+ let c = this[ge](t), d = this[be](t);
2608
+ typeof c == "number" && typeof d == "number" && node_fs$1.default.fchown(l, c, d, (S) => S ? node_fs$1.default.chown(h, c, d, (T) => o(T && S)) : o());
2609
+ }
2610
+ o();
2611
+ });
2612
+ let a = this.transform && this.transform(t) || t;
2613
+ a !== t && (a.on("error", (h) => {
2614
+ this[O$1](h, t), e();
2615
+ }), t.pipe(a)), a.pipe(r);
2616
+ }
2617
+ [Os](t, e) {
2618
+ let i = typeof t.mode == "number" ? t.mode & 4095 : this.dmode;
2619
+ this[yt](String(t.absolute), i, (r) => {
2620
+ if (r) {
2621
+ this[O$1](r, t), e();
2622
+ return;
2623
+ }
2624
+ let n = 1, o = () => {
2625
+ --n === 0 && (e(), this[$t](), t.resume());
2626
+ };
2627
+ t.mtime && !this.noMtime && (n++, node_fs$1.default.utimes(String(t.absolute), t.atime || /* @__PURE__ */ new Date(), t.mtime, o)), this[Re](t) && (n++, node_fs$1.default.chown(String(t.absolute), Number(this[ge](t)), Number(this[be](t)), o)), o();
2628
+ });
2629
+ }
2630
+ [Dr](t) {
2631
+ t.unsupported = !0, this.warn("TAR_ENTRY_UNSUPPORTED", `unsupported entry type: ${t.type}`, { entry: t }), t.resume();
2632
+ }
2633
+ [Lr](t, e) {
2634
+ let i = f$1(node_path$1.default.relative(this.cwd, node_path$1.default.resolve(node_path$1.default.dirname(String(t.absolute)), String(t.linkpath)))).split("/");
2635
+ this[ye](t, this.cwd, i, () => this[Ri](t, String(t.linkpath), "symlink", e), (r) => {
2636
+ this[O$1](r, t), e();
2637
+ });
2638
+ }
2639
+ [Nr](t, e) {
2640
+ let i = f$1(node_path$1.default.resolve(this.cwd, String(t.linkpath))), r = f$1(String(t.linkpath)).split("/");
2641
+ this[ye](t, this.cwd, r, () => this[Ri](t, i, "link", e), (n) => {
2642
+ this[O$1](n, t), e();
2643
+ });
2644
+ }
2645
+ [ye](t, e, i, r, n) {
2646
+ let o = i.shift();
2647
+ if (this.preservePaths || o === void 0) return r();
2648
+ let a = node_path$1.default.resolve(e, o);
2649
+ node_fs$1.default.lstat(a, (h, l) => {
2650
+ if (h) return r();
2651
+ if (l?.isSymbolicLink()) return n(new St(a, node_path$1.default.resolve(a, i.join("/"))));
2652
+ this[ye](t, a, i, r, n);
2653
+ });
2654
+ }
2655
+ [Ir]() {
2656
+ this[yi]++;
2657
+ }
2658
+ [$t]() {
2659
+ this[yi]--, this[Rs]();
2660
+ }
2661
+ [Ts](t) {
2662
+ this[$t](), t.resume();
2663
+ }
2664
+ [bs](t, e) {
2665
+ return t.type === "File" && !this.unlink && e.isFile() && e.nlink <= 1 && !Oe;
2666
+ }
2667
+ [gs](t) {
2668
+ this[Ir]();
2669
+ let e = [t.path];
2670
+ t.linkpath && e.push(t.linkpath), this.reservations.reserve(e, (i) => this[xr](t, i));
2671
+ }
2672
+ [xr](t, e) {
2673
+ let i = (a) => {
2674
+ e(a);
2675
+ }, r = () => {
2676
+ this[yt](this.cwd, this.dmode, (a) => {
2677
+ if (a) {
2678
+ this[O$1](a, t), i();
2679
+ return;
2680
+ }
2681
+ this[_e] = !0, n();
2682
+ });
2683
+ }, n = () => {
2684
+ if (t.absolute !== this.cwd) {
2685
+ let a = f$1(node_path$1.default.dirname(String(t.absolute)));
2686
+ if (a !== this.cwd) return this[yt](a, this.dmode, (h) => {
2687
+ if (h) {
2688
+ this[O$1](h, t), i();
2689
+ return;
2690
+ }
2691
+ o();
2692
+ });
2693
+ }
2694
+ o();
2695
+ }, o = () => {
2696
+ node_fs$1.default.lstat(String(t.absolute), (a, h) => {
2697
+ if (h && (this.keep || this.newer && h.mtime > (t.mtime ?? h.mtime))) {
2698
+ this[Ts](t), i();
2699
+ return;
2700
+ }
2701
+ if (a || this[bs](t, h)) return this[P$1](null, t, i);
2702
+ if (h.isDirectory()) {
2703
+ if (t.type === "Directory") {
2704
+ let l = this.chmod && t.mode && (h.mode & 4095) !== t.mode, c = (d) => this[P$1](d ?? null, t, i);
2705
+ return l ? node_fs$1.default.chmod(String(t.absolute), Number(t.mode), c) : c();
2706
+ }
2707
+ if (t.absolute !== this.cwd) return node_fs$1.default.rmdir(String(t.absolute), (l) => this[P$1](l ?? null, t, i));
2708
+ }
2709
+ if (t.absolute === this.cwd) return this[P$1](null, t, i);
2710
+ ao(String(t.absolute), (l) => this[P$1](l ?? null, t, i));
2711
+ });
2712
+ };
2713
+ this[_e] ? n() : r();
2714
+ }
2715
+ [P$1](t, e, i) {
2716
+ if (t) {
2717
+ this[O$1](t, e), i();
2718
+ return;
2719
+ }
2720
+ switch (e.type) {
2721
+ case "File":
2722
+ case "OldFile":
2723
+ case "ContiguousFile": return this[_s](e, i);
2724
+ case "Link": return this[Nr](e, i);
2725
+ case "SymbolicLink": return this[Lr](e, i);
2726
+ case "Directory":
2727
+ case "GNUDumpDir": return this[Os](e, i);
2728
+ }
2729
+ }
2730
+ [Ri](t, e, i, r) {
2731
+ node_fs$1.default[i](e, String(t.absolute), (n) => {
2732
+ n ? this[O$1](n, t) : (this[$t](), t.resume()), r();
2733
+ });
2734
+ }
2735
+ }, Se = (s) => {
2736
+ try {
2737
+ return [null, s()];
2738
+ } catch (t) {
2739
+ return [t, null];
2740
+ }
2741
+ }, Te = class extends Xt {
2742
+ sync = !0;
2743
+ [P$1](t, e) {
2744
+ return super[P$1](t, e, () => {});
2745
+ }
2746
+ [gs](t) {
2747
+ if (!this[_e]) {
2748
+ let n = this[yt](this.cwd, this.dmode);
2749
+ if (n) return this[O$1](n, t);
2750
+ this[_e] = !0;
2751
+ }
2752
+ if (t.absolute !== this.cwd) {
2753
+ let n = f$1(node_path$1.default.dirname(String(t.absolute)));
2754
+ if (n !== this.cwd) {
2755
+ let o = this[yt](n, this.dmode);
2756
+ if (o) return this[O$1](o, t);
2757
+ }
2758
+ }
2759
+ let [e, i] = Se(() => node_fs$1.default.lstatSync(String(t.absolute)));
2760
+ if (i && (this.keep || this.newer && i.mtime > (t.mtime ?? i.mtime))) return this[Ts](t);
2761
+ if (e || this[bs](t, i)) return this[P$1](null, t);
2762
+ if (i.isDirectory()) {
2763
+ if (t.type === "Directory") {
2764
+ let [a] = this.chmod && t.mode && (i.mode & 4095) !== t.mode ? Se(() => {
2765
+ node_fs$1.default.chmodSync(String(t.absolute), Number(t.mode));
2766
+ }) : [];
2767
+ return this[P$1](a, t);
2768
+ }
2769
+ let [n] = Se(() => node_fs$1.default.rmdirSync(String(t.absolute)));
2770
+ this[P$1](n, t);
2771
+ }
2772
+ let [r] = t.absolute === this.cwd ? [] : Se(() => lo(String(t.absolute)));
2773
+ this[P$1](r, t);
2774
+ }
2775
+ [_s](t, e) {
2776
+ let i = typeof t.mode == "number" ? t.mode & 4095 : this.fmode, r = (a) => {
2777
+ let h;
2778
+ try {
2779
+ node_fs$1.default.closeSync(n);
2780
+ } catch (l) {
2781
+ h = l;
2782
+ }
2783
+ (a || h) && this[O$1](a || h, t), e();
2784
+ }, n;
2785
+ try {
2786
+ n = node_fs$1.default.openSync(String(t.absolute), ds(t.size), i);
2787
+ } catch (a) {
2788
+ return r(a);
2789
+ }
2790
+ let o = this.transform && this.transform(t) || t;
2791
+ o !== t && (o.on("error", (a) => this[O$1](a, t)), t.pipe(o)), o.on("data", (a) => {
2792
+ try {
2793
+ node_fs$1.default.writeSync(n, a, 0, a.length);
2794
+ } catch (h) {
2795
+ r(h);
2796
+ }
2797
+ }), o.on("end", () => {
2798
+ let a = null;
2799
+ if (t.mtime && !this.noMtime) {
2800
+ let h = t.atime || /* @__PURE__ */ new Date(), l = t.mtime;
2801
+ try {
2802
+ node_fs$1.default.futimesSync(n, h, l);
2803
+ } catch (c) {
2804
+ try {
2805
+ node_fs$1.default.utimesSync(String(t.absolute), h, l);
2806
+ } catch {
2807
+ a = c;
2808
+ }
2809
+ }
2810
+ }
2811
+ if (this[Re](t)) {
2812
+ let h = this[ge](t), l = this[be](t);
2813
+ try {
2814
+ node_fs$1.default.fchownSync(n, Number(h), Number(l));
2815
+ } catch (c) {
2816
+ try {
2817
+ node_fs$1.default.chownSync(String(t.absolute), Number(h), Number(l));
2818
+ } catch {
2819
+ a = a || c;
2820
+ }
2821
+ }
2822
+ }
2823
+ r(a);
2824
+ });
2825
+ }
2826
+ [Os](t, e) {
2827
+ let i = typeof t.mode == "number" ? t.mode & 4095 : this.dmode, r = this[yt](String(t.absolute), i);
2828
+ if (r) {
2829
+ this[O$1](r, t), e();
2830
+ return;
2831
+ }
2832
+ if (t.mtime && !this.noMtime) try {
2833
+ node_fs$1.default.utimesSync(String(t.absolute), t.atime || /* @__PURE__ */ new Date(), t.mtime);
2834
+ } catch {}
2835
+ if (this[Re](t)) try {
2836
+ node_fs$1.default.chownSync(String(t.absolute), Number(this[ge](t)), Number(this[be](t)));
2837
+ } catch {}
2838
+ e(), t.resume();
2839
+ }
2840
+ [yt](t, e) {
2841
+ try {
2842
+ return Rr(f$1(t), {
2843
+ uid: this.uid,
2844
+ gid: this.gid,
2845
+ processUid: this.processUid,
2846
+ processGid: this.processGid,
2847
+ umask: this.processUmask,
2848
+ preserve: this.preservePaths,
2849
+ unlink: this.unlink,
2850
+ cwd: this.cwd,
2851
+ mode: e
2852
+ });
2853
+ } catch (i) {
2854
+ return i;
2855
+ }
2856
+ }
2857
+ [ye](t, e, i, r, n) {
2858
+ if (this.preservePaths || i.length === 0) return r();
2859
+ let o = e;
2860
+ for (let a of i) {
2861
+ o = node_path$1.default.resolve(o, a);
2862
+ let [h, l] = Se(() => node_fs$1.default.lstatSync(o));
2863
+ if (h) return r();
2864
+ if (l.isSymbolicLink()) return n(new St(o, node_path$1.default.resolve(e, i.join("/"))));
2865
+ }
2866
+ r();
2867
+ }
2868
+ [Ri](t, e, i, r) {
2869
+ let n = `${i}Sync`;
2870
+ try {
2871
+ node_fs$1.default[n](e, String(t.absolute)), r(), t.resume();
2872
+ } catch (o) {
2873
+ return this[O$1](o, t);
2874
+ }
2875
+ }
2876
+ };
2877
+ var co = (s) => {
2878
+ let t = new Te(s), e = s.file, i = node_fs$1.default.statSync(e);
2879
+ new Me(e, {
2880
+ readSize: s.maxReadSize || 16 * 1024 * 1024,
2881
+ size: i.size
2882
+ }).pipe(t);
2883
+ }, fo = (s, t) => {
2884
+ let e = new Xt(s), i = s.maxReadSize || 16 * 1024 * 1024, r = s.file;
2885
+ return new Promise((o, a) => {
2886
+ e.on("error", a), e.on("close", o), node_fs$1.default.stat(r, (h, l) => {
2887
+ if (h) a(h);
2888
+ else {
2889
+ let c = new _t(r, {
2890
+ readSize: i,
2891
+ size: l.size
2892
+ });
2893
+ c.on("error", a), c.pipe(e);
2894
+ }
2895
+ });
2896
+ });
2897
+ }, uo = K(co, fo, (s) => new Te(s), (s) => new Xt(s), (s, t) => {
2898
+ t?.length && Xi(s, t);
2899
+ });
2900
+ var mo = (s, t) => {
2901
+ let e = new kt(s), i = !0, r, n;
2902
+ try {
2903
+ try {
2904
+ r = node_fs$1.default.openSync(s.file, "r+");
2905
+ } catch (h) {
2906
+ if (h?.code === "ENOENT") r = node_fs$1.default.openSync(s.file, "w+");
2907
+ else throw h;
2908
+ }
2909
+ let o = node_fs$1.default.fstatSync(r), a = Buffer.alloc(512);
2910
+ t: for (n = 0; n < o.size; n += 512) {
2911
+ for (let c = 0, d = 0; c < 512; c += d) {
2912
+ if (d = node_fs$1.default.readSync(r, a, c, a.length - c, n + c), n === 0 && a[0] === 31 && a[1] === 139) throw new Error("cannot append to compressed archives");
2913
+ if (!d) break t;
2914
+ }
2915
+ let h = new C$1(a);
2916
+ if (!h.cksumValid) break;
2917
+ let l = 512 * Math.ceil((h.size || 0) / 512);
2918
+ if (n + l + 512 > o.size) break;
2919
+ n += l, s.mtimeCache && h.mtime && s.mtimeCache.set(String(h.path), h.mtime);
2920
+ }
2921
+ i = !1, po(s, e, n, r, t);
2922
+ } finally {
2923
+ if (i) try {
2924
+ node_fs$1.default.closeSync(r);
2925
+ } catch {}
2926
+ }
2927
+ }, po = (s, t, e, i, r) => {
2928
+ let n = new Wt(s.file, {
2929
+ fd: i,
2930
+ start: e
2931
+ });
2932
+ t.pipe(n), wo(t, r);
2933
+ }, Eo = (s, t) => {
2934
+ t = Array.from(t);
2935
+ let e = new wt(s), i = (n, o, a) => {
2936
+ let h = (T, N) => {
2937
+ T ? node_fs$1.default.close(n, (E) => a(T)) : a(null, N);
2938
+ }, l = 0;
2939
+ if (o === 0) return h(null, 0);
2940
+ let c = 0, d = Buffer.alloc(512), S = (T, N) => {
2941
+ if (T || N === void 0) return h(T);
2942
+ if (c += N, c < 512 && N) return node_fs$1.default.read(n, d, c, d.length - c, l + c, S);
2943
+ if (l === 0 && d[0] === 31 && d[1] === 139) return h(/* @__PURE__ */ new Error("cannot append to compressed archives"));
2944
+ if (c < 512) return h(null, l);
2945
+ let E = new C$1(d);
2946
+ if (!E.cksumValid) return h(null, l);
2947
+ let x = 512 * Math.ceil((E.size ?? 0) / 512);
2948
+ if (l + x + 512 > o || (l += x + 512, l >= o)) return h(null, l);
2949
+ s.mtimeCache && E.mtime && s.mtimeCache.set(String(E.path), E.mtime), c = 0, node_fs$1.default.read(n, d, 0, 512, l, S);
2950
+ };
2951
+ node_fs$1.default.read(n, d, 0, 512, l, S);
2952
+ };
2953
+ return new Promise((n, o) => {
2954
+ e.on("error", o);
2955
+ let a = "r+", h = (l, c) => {
2956
+ if (l && l.code === "ENOENT" && a === "r+") return a = "w+", node_fs$1.default.open(s.file, a, h);
2957
+ if (l || !c) return o(l);
2958
+ node_fs$1.default.fstat(c, (d, S) => {
2959
+ if (d) return node_fs$1.default.close(c, () => o(d));
2960
+ i(c, S.size, (T, N) => {
2961
+ if (T) return o(T);
2962
+ let E = new tt(s.file, {
2963
+ fd: c,
2964
+ start: N
2965
+ });
2966
+ e.pipe(E), E.on("error", o), E.on("close", n), So(e, t);
2967
+ });
2968
+ });
2969
+ };
2970
+ node_fs$1.default.open(s.file, a, h);
2971
+ });
2972
+ }, wo = (s, t) => {
2973
+ t.forEach((e) => {
2974
+ e.charAt(0) === "@" ? Ft({
2975
+ file: node_path$1.default.resolve(s.cwd, e.slice(1)),
2976
+ sync: !0,
2977
+ noResume: !0,
2978
+ onReadEntry: (i) => s.add(i)
2979
+ }) : s.add(e);
2980
+ }), s.end();
2981
+ }, So = async (s, t) => {
2982
+ for (let e of t) e.charAt(0) === "@" ? await Ft({
2983
+ file: node_path$1.default.resolve(String(s.cwd), e.slice(1)),
2984
+ noResume: !0,
2985
+ onReadEntry: (i) => s.add(i)
2986
+ }) : s.add(e);
2987
+ s.end();
2988
+ }, vt = K(mo, Eo, () => {
2989
+ throw new TypeError("file is required");
2990
+ }, () => {
2991
+ throw new TypeError("file is required");
2992
+ }, (s, t) => {
2993
+ if (!vs(s)) throw new TypeError("file is required");
2994
+ if (s.gzip || s.brotli || s.zstd || s.file.endsWith(".br") || s.file.endsWith(".tbr")) throw new TypeError("cannot append to compressed archives");
2995
+ if (!t?.length) throw new TypeError("no paths specified to add/replace");
2996
+ });
2997
+ K(vt.syncFile, vt.asyncFile, vt.syncNoFile, vt.asyncNoFile, (s, t = []) => {
2998
+ vt.validate?.(s, t), Ro(s);
2999
+ });
3000
+ var Ro = (s) => {
3001
+ let t = s.filter;
3002
+ s.mtimeCache || (s.mtimeCache = /* @__PURE__ */ new Map()), s.filter = t ? (e, i) => t(e, i) && !((s.mtimeCache?.get(e) ?? i.mtime ?? 0) > (i.mtime ?? 0)) : (e, i) => !((s.mtimeCache?.get(e) ?? i.mtime ?? 0) > (i.mtime ?? 0));
3003
+ };
3004
+ //#endregion
17
3005
  //#region src/builtins/system-backup/system-backup.service.ts
18
- var import_tar = /* @__PURE__ */ require_chunk.__toESM(require_tar$1.require_tar());
19
3006
  /**
20
3007
  * Default set of paths considered part of a "system backup". Includes
21
3008
  * everything that isn't pure backend code — config, sqlite, addons
@@ -120,7 +3107,7 @@ var SystemBackupService = class {
120
3107
  const stagedInDataDir = node_path.join(this.dataDir, ARCHIVE_MANIFEST_NAME);
121
3108
  node_fs.copyFileSync(manifestStagePath, stagedInDataDir);
122
3109
  try {
123
- await import_tar.create({
3110
+ await Kn({
124
3111
  file: opts.archivePath,
125
3112
  gzip: true,
126
3113
  cwd: this.dataDir,
@@ -156,7 +3143,7 @@ var SystemBackupService = class {
156
3143
  const chunks = [];
157
3144
  let found = false;
158
3145
  let resolved = false;
159
- const parser = new import_tar.Parse({ onentry: (entry) => {
3146
+ const parser = new st({ onentry: (entry) => {
160
3147
  if (entry.path === ".camstack-backup-manifest.json" && !found) {
161
3148
  found = true;
162
3149
  entry.on("data", (chunk) => chunks.push(chunk));
@@ -213,7 +3200,7 @@ var SystemBackupService = class {
213
3200
  locations: opts.locations
214
3201
  } });
215
3202
  const allowedPrefixes = opts.locations ? opts.locations.map(normalizeLocation) : null;
216
- await import_tar.extract({
3203
+ await uo({
217
3204
  file: opts.archivePath,
218
3205
  cwd: opts.targetDir,
219
3206
  filter: (p) => {