@nebulahome/package-sdk 1.0.0 → 1.1.0

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