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