@karmaniverous/stan-cli 0.12.2 → 0.12.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -6
- package/dist/cjs/index-CQYvnMvw-CcETnrF6.js +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cli/{apply-2mlYJk5r.js → apply-BiPfHJYS.js} +2 -2
- package/dist/cli/{index-DXJaQ46Q.js → index-C3h8BxZl.js} +67 -48
- package/dist/cli/index-CQYvnMvw-BR-mVR0o.js +20 -0
- package/dist/cli/stan.js +571 -194
- package/dist/mjs/index-CQYvnMvw-r3et3BtD.js +1 -0
- package/dist/mjs/index.js +1 -1
- package/package.json +18 -18
- package/dist/cjs/index-ucZa1KMb-CeffVEuy.js +0 -1
- package/dist/cli/index-ucZa1KMb-CNGeWGvV.js +0 -20
- package/dist/mjs/index-ucZa1KMb-DZqceYU7.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { Z as Zu } from './stan.js';
|
|
3
3
|
import 'node:fs';
|
|
4
4
|
import 'node:fs/promises';
|
|
5
5
|
import 'node:path';
|
|
@@ -35,7 +35,7 @@ const buildApplyAttempts = () => {
|
|
|
35
35
|
*/
|
|
36
36
|
const runGitApply = async (args) => {
|
|
37
37
|
const { cwd, patchAbs, cleaned, stripOrder } = args;
|
|
38
|
-
const out = await
|
|
38
|
+
const out = await Zu({
|
|
39
39
|
cwd,
|
|
40
40
|
patchAbs,
|
|
41
41
|
cleaned,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import * as readline$1 from 'node:readline';
|
|
3
3
|
import readline__default from 'node:readline';
|
|
4
4
|
import { g as getDefaultExportFromCjs, o as onExit } from './stan.js';
|
|
5
|
-
import
|
|
5
|
+
import T from 'stream';
|
|
6
6
|
import { styleText, stripVTControlCharacters } from 'node:util';
|
|
7
7
|
import process$1 from 'node:process';
|
|
8
8
|
import { AsyncLocalStorage, AsyncResource } from 'node:async_hooks';
|
|
@@ -1775,7 +1775,7 @@ var hasRequiredLib$2;
|
|
|
1775
1775
|
function requireLib$2 () {
|
|
1776
1776
|
if (hasRequiredLib$2) return lib$2;
|
|
1777
1777
|
hasRequiredLib$2 = 1;
|
|
1778
|
-
const Stream =
|
|
1778
|
+
const Stream = T;
|
|
1779
1779
|
|
|
1780
1780
|
class MuteStream extends Stream {
|
|
1781
1781
|
#isTTY = null
|
|
@@ -15156,6 +15156,8 @@ function requireStreams () {
|
|
|
15156
15156
|
return streams;
|
|
15157
15157
|
}
|
|
15158
15158
|
|
|
15159
|
+
lib.exports;
|
|
15160
|
+
|
|
15159
15161
|
var hasRequiredLib;
|
|
15160
15162
|
|
|
15161
15163
|
function requireLib () {
|
|
@@ -15167,22 +15169,21 @@ function requireLib () {
|
|
|
15167
15169
|
|
|
15168
15170
|
var bomHandling = requireBomHandling();
|
|
15169
15171
|
var mergeModules = requireMergeExports();
|
|
15170
|
-
var iconv = module.exports;
|
|
15171
15172
|
|
|
15172
15173
|
// All codecs and aliases are kept here, keyed by encoding name/alias.
|
|
15173
15174
|
// They are lazy loaded in `iconv.getCodec` from `encodings/index.js`.
|
|
15174
15175
|
// Cannot initialize with { __proto__: null } because Boolean({ __proto__: null }) === true
|
|
15175
|
-
|
|
15176
|
+
module.exports.encodings = null;
|
|
15176
15177
|
|
|
15177
15178
|
// Characters emitted in case of error.
|
|
15178
|
-
|
|
15179
|
-
|
|
15179
|
+
module.exports.defaultCharUnicode = "�";
|
|
15180
|
+
module.exports.defaultCharSingleByte = "?";
|
|
15180
15181
|
|
|
15181
15182
|
// Public API.
|
|
15182
|
-
|
|
15183
|
+
module.exports.encode = function encode (str, encoding, options) {
|
|
15183
15184
|
str = "" + (str || ""); // Ensure string.
|
|
15184
15185
|
|
|
15185
|
-
var encoder =
|
|
15186
|
+
var encoder = module.exports.getEncoder(encoding, options);
|
|
15186
15187
|
|
|
15187
15188
|
var res = encoder.write(str);
|
|
15188
15189
|
var trail = encoder.end();
|
|
@@ -15190,17 +15191,17 @@ function requireLib () {
|
|
|
15190
15191
|
return (trail && trail.length > 0) ? Buffer.concat([res, trail]) : res
|
|
15191
15192
|
};
|
|
15192
15193
|
|
|
15193
|
-
|
|
15194
|
+
module.exports.decode = function decode (buf, encoding, options) {
|
|
15194
15195
|
if (typeof buf === "string") {
|
|
15195
|
-
if (!
|
|
15196
|
+
if (!module.exports.skipDecodeWarning) {
|
|
15196
15197
|
console.error("Iconv-lite warning: decode()-ing strings is deprecated. Refer to https://github.com/ashtuchkin/iconv-lite/wiki/Use-Buffers-when-decoding");
|
|
15197
|
-
|
|
15198
|
+
module.exports.skipDecodeWarning = true;
|
|
15198
15199
|
}
|
|
15199
15200
|
|
|
15200
15201
|
buf = Buffer.from("" + (buf || ""), "binary"); // Ensure buffer.
|
|
15201
15202
|
}
|
|
15202
15203
|
|
|
15203
|
-
var decoder =
|
|
15204
|
+
var decoder = module.exports.getDecoder(encoding, options);
|
|
15204
15205
|
|
|
15205
15206
|
var res = decoder.write(buf);
|
|
15206
15207
|
var trail = decoder.end();
|
|
@@ -15208,9 +15209,9 @@ function requireLib () {
|
|
|
15208
15209
|
return trail ? (res + trail) : res
|
|
15209
15210
|
};
|
|
15210
15211
|
|
|
15211
|
-
|
|
15212
|
+
module.exports.encodingExists = function encodingExists (enc) {
|
|
15212
15213
|
try {
|
|
15213
|
-
|
|
15214
|
+
module.exports.getCodec(enc);
|
|
15214
15215
|
return true
|
|
15215
15216
|
} catch (e) {
|
|
15216
15217
|
return false
|
|
@@ -15218,31 +15219,31 @@ function requireLib () {
|
|
|
15218
15219
|
};
|
|
15219
15220
|
|
|
15220
15221
|
// Legacy aliases to convert functions
|
|
15221
|
-
|
|
15222
|
-
|
|
15222
|
+
module.exports.toEncoding = module.exports.encode;
|
|
15223
|
+
module.exports.fromEncoding = module.exports.decode;
|
|
15223
15224
|
|
|
15224
15225
|
// Search for a codec in iconv.encodings. Cache codec data in iconv._codecDataCache.
|
|
15225
|
-
|
|
15226
|
+
module.exports._codecDataCache = { __proto__: null };
|
|
15226
15227
|
|
|
15227
|
-
|
|
15228
|
-
if (!
|
|
15228
|
+
module.exports.getCodec = function getCodec (encoding) {
|
|
15229
|
+
if (!module.exports.encodings) {
|
|
15229
15230
|
var raw = requireEncodings();
|
|
15230
15231
|
// TODO: In future versions when old nodejs support is removed can use object.assign
|
|
15231
|
-
|
|
15232
|
-
mergeModules(
|
|
15232
|
+
module.exports.encodings = { __proto__: null }; // Initialize as empty object.
|
|
15233
|
+
mergeModules(module.exports.encodings, raw);
|
|
15233
15234
|
}
|
|
15234
15235
|
|
|
15235
15236
|
// Canonicalize encoding name: strip all non-alphanumeric chars and appended year.
|
|
15236
|
-
var enc =
|
|
15237
|
+
var enc = module.exports._canonicalizeEncoding(encoding);
|
|
15237
15238
|
|
|
15238
15239
|
// Traverse iconv.encodings to find actual codec.
|
|
15239
15240
|
var codecOptions = {};
|
|
15240
15241
|
while (true) {
|
|
15241
|
-
var codec =
|
|
15242
|
+
var codec = module.exports._codecDataCache[enc];
|
|
15242
15243
|
|
|
15243
15244
|
if (codec) { return codec }
|
|
15244
15245
|
|
|
15245
|
-
var codecDef =
|
|
15246
|
+
var codecDef = module.exports.encodings[enc];
|
|
15246
15247
|
|
|
15247
15248
|
switch (typeof codecDef) {
|
|
15248
15249
|
case "string": // Direct alias to other encoding.
|
|
@@ -15263,9 +15264,9 @@ function requireLib () {
|
|
|
15263
15264
|
// The codec function must load all tables and return object with .encoder and .decoder methods.
|
|
15264
15265
|
// It'll be called only once (for each different options object).
|
|
15265
15266
|
//
|
|
15266
|
-
codec = new codecDef(codecOptions,
|
|
15267
|
+
codec = new codecDef(codecOptions, module.exports);
|
|
15267
15268
|
|
|
15268
|
-
|
|
15269
|
+
module.exports._codecDataCache[codecOptions.encodingName] = codec; // Save it to be reused later.
|
|
15269
15270
|
return codec
|
|
15270
15271
|
|
|
15271
15272
|
default:
|
|
@@ -15274,13 +15275,13 @@ function requireLib () {
|
|
|
15274
15275
|
}
|
|
15275
15276
|
};
|
|
15276
15277
|
|
|
15277
|
-
|
|
15278
|
+
module.exports._canonicalizeEncoding = function (encoding) {
|
|
15278
15279
|
// Canonicalize encoding name: strip all non-alphanumeric chars and appended year.
|
|
15279
15280
|
return ("" + encoding).toLowerCase().replace(/:\d{4}$|[^0-9a-z]/g, "")
|
|
15280
15281
|
};
|
|
15281
15282
|
|
|
15282
|
-
|
|
15283
|
-
var codec =
|
|
15283
|
+
module.exports.getEncoder = function getEncoder (encoding, options) {
|
|
15284
|
+
var codec = module.exports.getCodec(encoding);
|
|
15284
15285
|
var encoder = new codec.encoder(options, codec);
|
|
15285
15286
|
|
|
15286
15287
|
if (codec.bomAware && options && options.addBOM) { encoder = new bomHandling.PrependBOM(encoder, options); }
|
|
@@ -15288,8 +15289,8 @@ function requireLib () {
|
|
|
15288
15289
|
return encoder
|
|
15289
15290
|
};
|
|
15290
15291
|
|
|
15291
|
-
|
|
15292
|
-
var codec =
|
|
15292
|
+
module.exports.getDecoder = function getDecoder (encoding, options) {
|
|
15293
|
+
var codec = module.exports.getCodec(encoding);
|
|
15293
15294
|
var decoder = new codec.decoder(options, codec);
|
|
15294
15295
|
|
|
15295
15296
|
if (codec.bomAware && !(options && options.stripBOM === false)) { decoder = new bomHandling.StripBOM(decoder, options); }
|
|
@@ -15302,26 +15303,26 @@ function requireLib () {
|
|
|
15302
15303
|
// up to 100Kb to the output bundle. To avoid unnecessary code bloat, we don't enable Streaming API in browser by default.
|
|
15303
15304
|
// If you would like to enable it explicitly, please add the following code to your app:
|
|
15304
15305
|
// > iconv.enableStreamingAPI(require('stream'));
|
|
15305
|
-
|
|
15306
|
-
if (
|
|
15306
|
+
module.exports.enableStreamingAPI = function enableStreamingAPI (streamModule) {
|
|
15307
|
+
if (module.exports.supportsStreams) { return }
|
|
15307
15308
|
|
|
15308
15309
|
// Dependency-inject stream module to create IconvLite stream classes.
|
|
15309
15310
|
var streams = requireStreams()(streamModule);
|
|
15310
15311
|
|
|
15311
15312
|
// Not public API yet, but expose the stream classes.
|
|
15312
|
-
|
|
15313
|
-
|
|
15313
|
+
module.exports.IconvLiteEncoderStream = streams.IconvLiteEncoderStream;
|
|
15314
|
+
module.exports.IconvLiteDecoderStream = streams.IconvLiteDecoderStream;
|
|
15314
15315
|
|
|
15315
15316
|
// Streaming API.
|
|
15316
|
-
|
|
15317
|
-
return new
|
|
15317
|
+
module.exports.encodeStream = function encodeStream (encoding, options) {
|
|
15318
|
+
return new module.exports.IconvLiteEncoderStream(module.exports.getEncoder(encoding, options), options)
|
|
15318
15319
|
};
|
|
15319
15320
|
|
|
15320
|
-
|
|
15321
|
-
return new
|
|
15321
|
+
module.exports.decodeStream = function decodeStream (encoding, options) {
|
|
15322
|
+
return new module.exports.IconvLiteDecoderStream(module.exports.getDecoder(encoding, options), options)
|
|
15322
15323
|
};
|
|
15323
15324
|
|
|
15324
|
-
|
|
15325
|
+
module.exports.supportsStreams = true;
|
|
15325
15326
|
};
|
|
15326
15327
|
|
|
15327
15328
|
// Enable Streaming API automatically if 'stream' module is available and non-empty (the majority of environments).
|
|
@@ -15331,10 +15332,10 @@ function requireLib () {
|
|
|
15331
15332
|
} catch (e) {}
|
|
15332
15333
|
|
|
15333
15334
|
if (streamModule && streamModule.Transform) {
|
|
15334
|
-
|
|
15335
|
+
module.exports.enableStreamingAPI(streamModule);
|
|
15335
15336
|
} else {
|
|
15336
15337
|
// In rare cases where 'stream' module is not available by default, throw a helpful exception.
|
|
15337
|
-
|
|
15338
|
+
module.exports.encodeStream = module.exports.decodeStream = function () {
|
|
15338
15339
|
throw new Error("iconv-lite Streaming API is not enabled. Use iconv.enableStreamingAPI(require('stream')); to enable it.")
|
|
15339
15340
|
};
|
|
15340
15341
|
}
|
|
@@ -15994,6 +15995,11 @@ var expand$1 = createPrompt((config, done) => {
|
|
|
15994
15995
|
});
|
|
15995
15996
|
|
|
15996
15997
|
const numberRegex = /\d+/;
|
|
15998
|
+
const rawlistTheme = {
|
|
15999
|
+
style: {
|
|
16000
|
+
description: (text) => styleText('cyan', text),
|
|
16001
|
+
},
|
|
16002
|
+
};
|
|
15997
16003
|
function isSelectableChoice(choice) {
|
|
15998
16004
|
return choice != null && !Separator.isSeparator(choice);
|
|
15999
16005
|
}
|
|
@@ -16018,6 +16024,7 @@ function normalizeChoices$2(choices) {
|
|
|
16018
16024
|
name,
|
|
16019
16025
|
short: choice.short ?? name,
|
|
16020
16026
|
key: choice.key ?? String(index),
|
|
16027
|
+
description: choice.description,
|
|
16021
16028
|
};
|
|
16022
16029
|
});
|
|
16023
16030
|
}
|
|
@@ -16046,7 +16053,7 @@ var rawlist = createPrompt((config, done) => {
|
|
|
16046
16053
|
return defaultChoice?.key ?? '';
|
|
16047
16054
|
});
|
|
16048
16055
|
const [errorMsg, setError] = useState();
|
|
16049
|
-
const theme = makeTheme(config.theme);
|
|
16056
|
+
const theme = makeTheme(rawlistTheme, config.theme);
|
|
16050
16057
|
const prefix = usePrefix({ status, theme });
|
|
16051
16058
|
const bounds = useMemo(() => {
|
|
16052
16059
|
const first = choices.findIndex(isSelectableChoice);
|
|
@@ -16106,7 +16113,7 @@ var rawlist = createPrompt((config, done) => {
|
|
|
16106
16113
|
return ` ${choice.separator}`;
|
|
16107
16114
|
}
|
|
16108
16115
|
const line = ` ${choice.key}) ${choice.name}`;
|
|
16109
|
-
if (choice.key === value
|
|
16116
|
+
if (choice.key === value) {
|
|
16110
16117
|
return theme.style.highlight(line);
|
|
16111
16118
|
}
|
|
16112
16119
|
return line;
|
|
@@ -16116,9 +16123,14 @@ var rawlist = createPrompt((config, done) => {
|
|
|
16116
16123
|
if (errorMsg) {
|
|
16117
16124
|
error = theme.style.error(errorMsg);
|
|
16118
16125
|
}
|
|
16126
|
+
const [selectedChoice] = getSelectedChoice(value, choices);
|
|
16127
|
+
let description = '';
|
|
16128
|
+
if (!errorMsg && selectedChoice?.description) {
|
|
16129
|
+
description = theme.style.description(selectedChoice.description);
|
|
16130
|
+
}
|
|
16119
16131
|
return [
|
|
16120
16132
|
`${prefix} ${message} ${value}`,
|
|
16121
|
-
[choicesStr, error].filter(Boolean).join('\n'),
|
|
16133
|
+
[choicesStr, error, description].filter(Boolean).join('\n'),
|
|
16122
16134
|
];
|
|
16123
16135
|
});
|
|
16124
16136
|
|
|
@@ -16222,6 +16234,7 @@ var search = createPrompt((config, done) => {
|
|
|
16222
16234
|
const [searchTerm, setSearchTerm] = useState('');
|
|
16223
16235
|
const [searchResults, setSearchResults] = useState([]);
|
|
16224
16236
|
const [searchError, setSearchError] = useState();
|
|
16237
|
+
const defaultApplied = useRef(false);
|
|
16225
16238
|
const prefix = usePrefix({ status, theme });
|
|
16226
16239
|
const bounds = useMemo(() => {
|
|
16227
16240
|
const first = searchResults.findIndex(isSelectable$1);
|
|
@@ -16239,10 +16252,16 @@ var search = createPrompt((config, done) => {
|
|
|
16239
16252
|
signal: controller.signal,
|
|
16240
16253
|
});
|
|
16241
16254
|
if (!controller.signal.aborted) {
|
|
16242
|
-
|
|
16243
|
-
|
|
16255
|
+
const normalized = normalizeChoices$1(results);
|
|
16256
|
+
let initialActive;
|
|
16257
|
+
if (!defaultApplied.current && 'default' in config) {
|
|
16258
|
+
const defaultIndex = normalized.findIndex((item) => isSelectable$1(item) && item.value === config.default);
|
|
16259
|
+
initialActive = defaultIndex === -1 ? undefined : defaultIndex;
|
|
16260
|
+
defaultApplied.current = true;
|
|
16261
|
+
}
|
|
16262
|
+
setActive(initialActive);
|
|
16244
16263
|
setSearchError(undefined);
|
|
16245
|
-
setSearchResults(
|
|
16264
|
+
setSearchResults(normalized);
|
|
16246
16265
|
setStatus('idle');
|
|
16247
16266
|
}
|
|
16248
16267
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import R, { EventEmitter } from 'events';
|
|
3
|
+
import i from 'fs';
|
|
4
|
+
import { EventEmitter as EventEmitter$1 } from 'node:events';
|
|
5
|
+
import r from 'node:stream';
|
|
6
|
+
import { StringDecoder } from 'node:string_decoder';
|
|
7
|
+
import path, { win32, basename, join, posix } from 'node:path';
|
|
8
|
+
import c from 'node:fs';
|
|
9
|
+
import x$1, { parse, dirname } from 'path';
|
|
10
|
+
import p from 'assert';
|
|
11
|
+
import { Buffer as Buffer$1 } from 'buffer';
|
|
12
|
+
import * as b from 'zlib';
|
|
13
|
+
import b__default from 'zlib';
|
|
14
|
+
import g from 'node:assert';
|
|
15
|
+
import { randomBytes } from 'node:crypto';
|
|
16
|
+
import fsPromises from 'node:fs/promises';
|
|
17
|
+
|
|
18
|
+
const _="object"==typeof process&&process?process:{stdout:null,stderr:null},S=t=>!!t&&"object"==typeof t&&(t instanceof ot||t instanceof r||v(t)||O(t)),v=t=>!!t&&"object"==typeof t&&t instanceof EventEmitter$1&&"function"==typeof t.pipe&&t.pipe!==r.Writable.prototype.pipe,O=t=>!!t&&"object"==typeof t&&t instanceof EventEmitter$1&&"function"==typeof t.write&&"function"==typeof t.end,T=Symbol("EOF"),k=Symbol("maybeEmitEnd"),L=Symbol("emittedEnd"),D=Symbol("emittingEnd"),A=Symbol("emittedError"),x=Symbol("closed"),I=Symbol("read"),N=Symbol("flush"),F=Symbol("flushChunk"),B=Symbol("encoding"),M=Symbol("decoder"),C=Symbol("flowing"),P=Symbol("paused"),z=Symbol("resume"),U=Symbol("buffer"),j=Symbol("pipes"),Z=Symbol("bufferLength"),H=Symbol("bufferPush"),G=Symbol("bufferShift"),W=Symbol("objectMode"),Y=Symbol("destroyed"),V=Symbol("error"),$=Symbol("emitData"),q=Symbol("emitEnd"),K=Symbol("emitEnd2"),X=Symbol("async"),Q=Symbol("abort"),J=Symbol("aborted"),tt=Symbol("signal"),et=Symbol("dataListeners"),it=Symbol("discarded"),st=t=>Promise.resolve().then(t),rt=t=>t();class nt{src;dest;opts;ondrain;constructor(t,e,i){this.src=t,this.dest=e,this.opts=i,this.ondrain=()=>t[z](),this.dest.on("drain",this.ondrain);}unpipe(){this.dest.removeListener("drain",this.ondrain);}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end();}}class ht extends nt{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe();}constructor(t,e,i){super(t,e,i),this.proxyErrors=t=>e.emit("error",t),t.on("error",this.proxyErrors);}}class ot extends EventEmitter$1{[C]=false;[P]=false;[j]=[];[U]=[];[W];[B];[X];[M];[T]=false;[L]=false;[D]=false;[x]=false;[A]=null;[Z]=0;[Y]=false;[tt];[J]=false;[et]=0;[it]=false;writable=true;readable=true;constructor(...t){const e=t[0]||{};if(super(),e.objectMode&&"string"==typeof e.encoding)throw new TypeError("Encoding and objectMode may not be used together");e.objectMode?(this[W]=true,this[B]=null):(t=>!t.objectMode&&!!t.encoding&&"buffer"!==t.encoding)(e)?(this[B]=e.encoding,this[W]=false):(this[W]=false,this[B]=null),this[X]=!!e.async,this[M]=this[B]?new StringDecoder(this[B]):null,e&&true===e.debugExposeBuffer&&Object.defineProperty(this,"buffer",{get:()=>this[U]}),e&&true===e.debugExposePipes&&Object.defineProperty(this,"pipes",{get:()=>this[j]});const{signal:i}=e;i&&(this[tt]=i,i.aborted?this[Q]():i.addEventListener("abort",()=>this[Q]()));}get bufferLength(){return this[Z]}get encoding(){return this[B]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[W]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[X]}set async(t){this[X]=this[X]||!!t;}[Q](){this[J]=true,this.emit("abort",this[tt]?.reason),this.destroy(this[tt]?.reason);}get aborted(){return this[J]}set aborted(t){}write(t,e,i){if(this[J])return false;if(this[T])throw new Error("write after end");if(this[Y])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),true;"function"==typeof e&&(i=e,e="utf8"),e||(e="utf8");const s=this[X]?st:rt;if(!this[W]&&!Buffer.isBuffer(t))if(r=t,!Buffer.isBuffer(r)&&ArrayBuffer.isView(r))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if((t=>t instanceof ArrayBuffer||!!t&&"object"==typeof t&&t.constructor&&"ArrayBuffer"===t.constructor.name&&t.byteLength>=0)(t))t=Buffer.from(t);else if("string"!=typeof t)throw new Error("Non-contiguous data written to non-objectMode stream");var r;return this[W]?(this[C]&&0!==this[Z]&&this[N](true),this[C]?this.emit("data",t):this[H](t),0!==this[Z]&&this.emit("readable"),i&&s(i),this[C]):t.length?("string"!=typeof t||e===this[B]&&!this[M]?.lastNeed||(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[B]&&(t=this[M].write(t)),this[C]&&0!==this[Z]&&this[N](true),this[C]?this.emit("data",t):this[H](t),0!==this[Z]&&this.emit("readable"),i&&s(i),this[C]):(0!==this[Z]&&this.emit("readable"),i&&s(i),this[C])}read(t){if(this[Y])return null;if(this[it]=false,0===this[Z]||0===t||t&&t>this[Z])return this[k](),null;this[W]&&(t=null),this[U].length>1&&!this[W]&&(this[U]=[this[B]?this[U].join(""):Buffer.concat(this[U],this[Z])]);const e=this[I](t||null,this[U][0]);return this[k](),e}[I](t,e){if(this[W])this[G]();else {const i=e;t===i.length||null===t?this[G]():"string"==typeof i?(this[U][0]=i.slice(t),e=i.slice(0,t),this[Z]-=t):(this[U][0]=i.subarray(t),e=i.subarray(0,t),this[Z]-=t);}return this.emit("data",e),this[U].length||this[T]||this.emit("drain"),e}end(t,e,i){return "function"==typeof t&&(i=t,t=void 0),"function"==typeof e&&(i=e,e="utf8"),void 0!==t&&this.write(t,e),i&&this.once("end",i),this[T]=true,this.writable=false,!this[C]&&this[P]||this[k](),this}[z](){this[Y]||(this[et]||this[j].length||(this[it]=true),this[P]=false,this[C]=true,this.emit("resume"),this[U].length?this[N]():this[T]?this[k]():this.emit("drain"));}resume(){return this[z]()}pause(){this[C]=false,this[P]=true,this[it]=false;}get destroyed(){return this[Y]}get flowing(){return this[C]}get paused(){return this[P]}[H](t){this[W]?this[Z]+=1:this[Z]+=t.length,this[U].push(t);}[G](){return this[W]?this[Z]-=1:this[Z]-=this[U][0].length,this[U].shift()}[N](t=false){do{}while(this[F](this[G]())&&this[U].length);t||this[U].length||this[T]||this.emit("drain");}[F](t){return this.emit("data",t),this[C]}pipe(t,e){if(this[Y])return t;this[it]=false;const i=this[L];return e=e||{},t===_.stdout||t===_.stderr?e.end=false:e.end=false!==e.end,e.proxyErrors=!!e.proxyErrors,i?e.end&&t.end():(this[j].push(e.proxyErrors?new ht(this,t,e):new nt(this,t,e)),this[X]?st(()=>this[z]()):this[z]()),t}unpipe(t){const e=this[j].find(e=>e.dest===t);e&&(1===this[j].length?(this[C]&&0===this[et]&&(this[C]=false),this[j]=[]):this[j].splice(this[j].indexOf(e),1),e.unpipe());}addListener(t,e){return this.on(t,e)}on(t,e){const i=super.on(t,e);if("data"===t)this[it]=false,this[et]++,this[j].length||this[C]||this[z]();else if("readable"===t&&0!==this[Z])super.emit("readable");else if((t=>"end"===t||"finish"===t||"prefinish"===t)(t)&&this[L])super.emit(t),this.removeAllListeners(t);else if("error"===t&&this[A]){const t=e;this[X]?st(()=>t.call(this,this[A])):t.call(this,this[A]);}return i}removeListener(t,e){return this.off(t,e)}off(t,e){const i=super.off(t,e);return "data"===t&&(this[et]=this.listeners("data").length,0!==this[et]||this[it]||this[j].length||(this[C]=false)),i}removeAllListeners(t){const e=super.removeAllListeners(t);return "data"!==t&&void 0!==t||(this[et]=0,this[it]||this[j].length||(this[C]=false)),e}get emittedEnd(){return this[L]}[k](){this[D]||this[L]||this[Y]||0!==this[U].length||!this[T]||(this[D]=true,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[x]&&this.emit("close"),this[D]=false);}emit(t,...e){const i=e[0];if("error"!==t&&"close"!==t&&t!==Y&&this[Y])return false;if("data"===t)return !(!this[W]&&!i)&&(this[X]?(st(()=>this[$](i)),true):this[$](i));if("end"===t)return this[q]();if("close"===t){if(this[x]=true,!this[L]&&!this[Y])return false;const t=super.emit("close");return this.removeAllListeners("close"),t}if("error"===t){this[A]=i,super.emit(V,i);const t=!(this[tt]&&!this.listeners("error").length)&&super.emit("error",i);return this[k](),t}if("resume"===t){const t=super.emit("resume");return this[k](),t}if("finish"===t||"prefinish"===t){const e=super.emit(t);return this.removeAllListeners(t),e}const s=super.emit(t,...e);return this[k](),s}[$](t){for(const e of this[j]) false===e.dest.write(t)&&this.pause();const e=!this[it]&&super.emit("data",t);return this[k](),e}[q](){return !this[L]&&(this[L]=true,this.readable=false,this[X]?(st(()=>this[K]()),true):this[K]())}[K](){if(this[M]){const t=this[M].end();if(t){for(const e of this[j])e.dest.write(t);this[it]||super.emit("data",t);}}for(const t of this[j])t.end();const t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){const t=Object.assign([],{dataLength:0});this[W]||(t.dataLength=0);const e=this.promise();return this.on("data",e=>{t.push(e),this[W]||(t.dataLength+=e.length);}),await e,t}async concat(){if(this[W])throw new Error("cannot concat in objectMode");const t=await this.collect();return this[B]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(Y,()=>e(new Error("stream destroyed"))),this.on("error",t=>e(t)),this.on("end",()=>t());})}[Symbol.asyncIterator](){this[it]=false;let t=false;const e=async()=>(this.pause(),t=true,{value:void 0,done:true});return {next:()=>{if(t)return e();const i=this.read();if(null!==i)return Promise.resolve({done:false,value:i});if(this[T])return e();let s,r;const n=t=>{this.off("data",h),this.off("end",o),this.off(Y,a),e(),r(t);},h=t=>{this.off("error",n),this.off("end",o),this.off(Y,a),this.pause(),s({value:t,done:!!this[T]});},o=()=>{this.off("error",n),this.off("data",h),this.off(Y,a),e(),s({done:true,value:void 0});},a=()=>n(new Error("stream destroyed"));return new Promise((t,e)=>{r=e,s=t,this.once(Y,a),this.once("error",n),this.once("end",o),this.once("data",h);})},throw:e,return:e,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[it]=false;let t=false;const e=()=>(this.pause(),this.off(V,e),this.off(Y,e),this.off("end",e),t=true,{done:true,value:void 0});return this.once("end",e),this.once(V,e),this.once(Y,e),{next:()=>{if(t)return e();const i=this.read();return null===i?e():{done:false,value:i}},throw:e,return:e,[Symbol.iterator](){return this}}}destroy(t){if(this[Y])return t?this.emit("error",t):this.emit(Y),this;this[Y]=true,this[it]=true,this[U].length=0,this[Z]=0;return "function"!=typeof this.close||this[x]||this.close(),t?this.emit("error",t):this.emit(Y),this}static get isStream(){return S}}const at=i.writev,lt=Symbol("_autoClose"),dt=Symbol("_close"),ct=Symbol("_ended"),ut=Symbol("_fd"),mt=Symbol("_finished"),ft=Symbol("_flags"),pt=Symbol("_flush"),yt=Symbol("_handleChunk"),bt=Symbol("_makeBuf"),wt=Symbol("_mode"),gt=Symbol("_needDrain"),Et=Symbol("_onerror"),Rt=Symbol("_onopen"),_t=Symbol("_onread"),St=Symbol("_onwrite"),vt=Symbol("_open"),Ot=Symbol("_path"),Tt=Symbol("_pos"),kt=Symbol("_queue"),Lt=Symbol("_read"),Dt=Symbol("_readSize"),At=Symbol("_reading"),xt=Symbol("_remain"),It=Symbol("_size"),Nt=Symbol("_write"),Ft=Symbol("_writing"),Bt=Symbol("_defaultFlag"),Mt=Symbol("_errored");class Ct extends ot{[Mt]=false;[ut];[Ot];[Dt];[At]=false;[It];[xt];[lt];constructor(t,e){if(super(e=e||{}),this.readable=true,this.writable=false,"string"!=typeof t)throw new TypeError("path must be a string");this[Mt]=false,this[ut]="number"==typeof e.fd?e.fd:void 0,this[Ot]=t,this[Dt]=e.readSize||16777216,this[At]=false,this[It]="number"==typeof e.size?e.size:1/0,this[xt]=this[It],this[lt]="boolean"!=typeof e.autoClose||e.autoClose,"number"==typeof this[ut]?this[Lt]():this[vt]();}get fd(){return this[ut]}get path(){return this[Ot]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[vt](){i.open(this[Ot],"r",(t,e)=>this[Rt](t,e));}[Rt](t,e){t?this[Et](t):(this[ut]=e,this.emit("open",e),this[Lt]());}[bt](){return Buffer.allocUnsafe(Math.min(this[Dt],this[xt]))}[Lt](){if(!this[At]){this[At]=true;const t=this[bt]();if(0===t.length)return process.nextTick(()=>this[_t](null,0,t));i.read(this[ut],t,0,t.length,null,(t,e,i)=>this[_t](t,e,i));}}[_t](t,e,i){this[At]=false,t?this[Et](t):this[yt](e,i)&&this[Lt]();}[dt](){if(this[lt]&&"number"==typeof this[ut]){const t=this[ut];this[ut]=void 0,i.close(t,t=>t?this.emit("error",t):this.emit("close"));}}[Et](t){this[At]=true,this[dt](),this.emit("error",t);}[yt](t,e){let i=false;return this[xt]-=t,t>0&&(i=super.write(t<e.length?e.subarray(0,t):e)),(0===t||this[xt]<=0)&&(i=false,this[dt](),super.end()),i}emit(t,...e){switch(t){case "prefinish":case "finish":return false;case "drain":return "number"==typeof this[ut]&&this[Lt](),false;case "error":return !this[Mt]&&(this[Mt]=true,super.emit(t,...e));default:return super.emit(t,...e)}}}class Pt extends Ct{[vt](){let t=true;try{this[Rt](null,i.openSync(this[Ot],"r")),t=!1;}finally{t&&this[dt]();}}[Lt](){let t=true;try{if(!this[At]){for(this[At]=!0;;){const t=this[bt](),e=0===t.length?0:i.readSync(this[ut],t,0,t.length,null);if(!this[yt](e,t))break}this[At]=!1;}t=!1;}finally{t&&this[dt]();}}[dt](){if(this[lt]&&"number"==typeof this[ut]){const t=this[ut];this[ut]=void 0,i.closeSync(t),this.emit("close");}}}class zt extends R{readable=false;writable=true;[Mt]=false;[Ft]=false;[ct]=false;[kt]=[];[gt]=false;[Ot];[wt];[lt];[ut];[Bt];[ft];[mt]=false;[Tt];constructor(t,e){super(e=e||{}),this[Ot]=t,this[ut]="number"==typeof e.fd?e.fd:void 0,this[wt]=void 0===e.mode?438:e.mode,this[Tt]="number"==typeof e.start?e.start:void 0,this[lt]="boolean"!=typeof e.autoClose||e.autoClose;const i=void 0!==this[Tt]?"r+":"w";this[Bt]=void 0===e.flags,this[ft]=void 0===e.flags?i:e.flags,void 0===this[ut]&&this[vt]();}emit(t,...e){if("error"===t){if(this[Mt])return false;this[Mt]=true;}return super.emit(t,...e)}get fd(){return this[ut]}get path(){return this[Ot]}[Et](t){this[dt](),this[Ft]=true,this.emit("error",t);}[vt](){i.open(this[Ot],this[ft],this[wt],(t,e)=>this[Rt](t,e));}[Rt](t,e){this[Bt]&&"r+"===this[ft]&&t&&"ENOENT"===t.code?(this[ft]="w",this[vt]()):t?this[Et](t):(this[ut]=e,this.emit("open",e),this[Ft]||this[pt]());}end(t,e){return t&&this.write(t,e),this[ct]=true,this[Ft]||this[kt].length||"number"!=typeof this[ut]||this[St](null,0),this}write(t,e){return "string"==typeof t&&(t=Buffer.from(t,e)),this[ct]?(this.emit("error",new Error("write() after end()")),false):void 0===this[ut]||this[Ft]||this[kt].length?(this[kt].push(t),this[gt]=true,false):(this[Ft]=true,this[Nt](t),true)}[Nt](t){i.write(this[ut],t,0,t.length,this[Tt],(t,e)=>this[St](t,e));}[St](t,e){t?this[Et](t):(void 0!==this[Tt]&&"number"==typeof e&&(this[Tt]+=e),this[kt].length?this[pt]():(this[Ft]=false,this[ct]&&!this[mt]?(this[mt]=true,this[dt](),this.emit("finish")):this[gt]&&(this[gt]=false,this.emit("drain"))));}[pt](){if(0===this[kt].length)this[ct]&&this[St](null,0);else if(1===this[kt].length)this[Nt](this[kt].pop());else {const t=this[kt];this[kt]=[],at(this[ut],t,this[Tt],(t,e)=>this[St](t,e));}}[dt](){if(this[lt]&&"number"==typeof this[ut]){const t=this[ut];this[ut]=void 0,i.close(t,t=>t?this.emit("error",t):this.emit("close"));}}}class Ut extends zt{[vt](){let t;if(this[Bt]&&"r+"===this[ft])try{t=i.openSync(this[Ot],this[ft],this[wt]);}catch(t){if("ENOENT"===t?.code)return this[ft]="w",this[vt]();throw t}else t=i.openSync(this[Ot],this[ft],this[wt]);this[Rt](null,t);}[dt](){if(this[lt]&&"number"==typeof this[ut]){const t=this[ut];this[ut]=void 0,i.closeSync(t),this.emit("close");}}[Nt](t){let e=true;try{this[St](null,i.writeSync(this[ut],t,0,t.length,this[Tt])),e=!1;}finally{if(e)try{this[dt]();}catch{}}}}const jt=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"]]),Zt=t=>{const e=jt.get(t);return e||t},Ht=(t={})=>{if(!t)return {};const e={};for(const[i,s]of Object.entries(t)){e[Zt(i)]=s;}return void 0===e.chmod&&false===e.noChmod&&(e.chmod=true),delete e.noChmod,e},Gt=(t,e,i,s,r)=>Object.assign((n=[],h,o)=>{Array.isArray(n)&&(h=n,n={}),"function"==typeof h&&(o=h,h=void 0),h=h?Array.from(h):[];const a=Ht(n);if(r?.(a,h),(l=a).sync&&l.file){if("function"==typeof o)throw new TypeError("callback not supported for sync tar functions");return t(a,h)}if((t=>!t.sync&&!!t.file)(a)){const t=e(a,h),i=o||void 0;return i?t.then(()=>i(),i):t}if((t=>!!t.sync&&!t.file)(a)){if("function"==typeof o)throw new TypeError("callback not supported for sync tar functions");return i(a,h)}if((t=>!t.sync&&!t.file)(a)){if("function"==typeof o)throw new TypeError("callback only supported with file option");return s(a,h)}throw new Error("impossible options??");var l;},{syncFile:t,asyncFile:e,syncNoFile:i,asyncNoFile:s,validate:r}),Wt=b__default.constants||{ZLIB_VERNUM:4736},Yt=Object.freeze(Object.assign(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},Wt)),Vt=Buffer$1.concat,$t=Object.getOwnPropertyDescriptor(Buffer$1,"concat"),qt=t=>t,Kt=true===$t?.writable||void 0!==$t?.set?t=>{Buffer$1.concat=t?qt:Vt;}:t=>{},Xt=Symbol("_superWrite");class Qt extends Error{code;errno;constructor(t,e){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);}get name(){return "ZlibError"}}const Jt=Symbol("flushFlag");class te extends ot{#t=false;#e=false;#i;#s;#r;#n;#h;get sawError(){return this.#t}get handle(){return this.#n}get flushFlag(){return this.#i}constructor(t,e){if(!t||"object"!=typeof t)throw new TypeError("invalid options for ZlibBase constructor");if(super(t),this.#i=t.flush??0,this.#s=t.finishFlush??0,this.#r=t.fullFlushFlag??0,"function"!=typeof b[e])throw new TypeError("Compression method not supported: "+e);try{this.#n=new b[e](t);}catch(t){throw new Qt(t,this.constructor)}this.#h=t=>{this.#t||(this.#t=true,this.close(),this.emit("error",t));},this.#n?.on("error",t=>this.#h(new Qt(t))),this.once("end",()=>this.close);}close(){this.#n&&(this.#n.close(),this.#n=void 0,this.emit("close"));}reset(){if(!this.#t)return p(this.#n,"zlib binding closed"),this.#n.reset?.()}flush(t){this.ended||("number"!=typeof t&&(t=this.#r),this.write(Object.assign(Buffer$1.alloc(0),{[Jt]:t})));}end(t,e,i){return "function"==typeof t&&(i=t,e=void 0,t=void 0),"function"==typeof e&&(i=e,e=void 0),t&&(e?this.write(t,e):this.write(t)),this.flush(this.#s),this.#e=true,super.end(i)}get ended(){return this.#e}[Xt](t){return super.write(t)}write(t,e,i){if("function"==typeof e&&(i=e,e="utf8"),"string"==typeof t&&(t=Buffer$1.from(t,e)),this.#t)return;p(this.#n,"zlib binding closed");const s=this.#n._handle,r=s.close;s.close=()=>{};const n=this.#n.close;let h,o;this.#n.close=()=>{},Kt(true);try{const e="number"==typeof t[Jt]?t[Jt]:this.#i;h=this.#n._processChunk(t,e),Kt(!1);}catch(t){Kt(false),this.#h(new Qt(t,this.write));}finally{this.#n&&(this.#n._handle=s,s.close=r,this.#n.close=n,this.#n.removeAllListeners("error"));}if(this.#n&&this.#n.on("error",t=>this.#h(new Qt(t,this.write))),h)if(Array.isArray(h)&&h.length>0){const t=h[0];o=this[Xt](Buffer$1.from(t));for(let t=1;t<h.length;t++)o=this[Xt](h[t]);}else o=this[Xt](Buffer$1.from(h));return i&&i(),o}}class ee extends te{#o;#a;constructor(t,e){(t=t||{}).flush=t.flush||Yt.Z_NO_FLUSH,t.finishFlush=t.finishFlush||Yt.Z_FINISH,t.fullFlushFlag=Yt.Z_FULL_FLUSH,super(t,e),this.#o=t.level,this.#a=t.strategy;}params(t,e){if(!this.sawError){if(!this.handle)throw new Error("cannot switch params when binding is closed");if(!this.handle.params)throw new Error("not supported in this implementation");if(this.#o!==t||this.#a!==e){this.flush(Yt.Z_SYNC_FLUSH),p(this.handle,"zlib binding closed");const i=this.handle.flush;this.handle.flush=(t,e)=>{"function"==typeof t&&(e=t,t=this.flushFlag),this.flush(t),e?.();};try{this.handle.params(t,e);}finally{this.handle.flush=i;}this.handle&&(this.#o=t,this.#a=e);}}}}class ie extends ee{#l;constructor(t){super(t,"Gzip"),this.#l=t&&!!t.portable;}[Xt](t){return this.#l?(this.#l=false,t[9]=255,super[Xt](t)):super[Xt](t)}}class se extends ee{constructor(t){super(t,"Unzip");}}class re extends te{constructor(t,e){(t=t||{}).flush=t.flush||Yt.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||Yt.BROTLI_OPERATION_FINISH,t.fullFlushFlag=Yt.BROTLI_OPERATION_FLUSH,super(t,e);}}class ne extends re{constructor(t){super(t,"BrotliCompress");}}class he extends re{constructor(t){super(t,"BrotliDecompress");}}class oe extends te{constructor(t,e){(t=t||{}).flush=t.flush||Yt.ZSTD_e_continue,t.finishFlush=t.finishFlush||Yt.ZSTD_e_end,t.fullFlushFlag=Yt.ZSTD_e_flush,super(t,e);}}class ae extends oe{constructor(t){super(t,"ZstdCompress");}}class le extends oe{constructor(t){super(t,"ZstdDecompress");}}const de=(t,e)=>{e[0]=128;for(var i=e.length;i>1;i--)e[i-1]=255&t,t=Math.floor(t/256);},ce=(t,e)=>{e[0]=255;var i=false;t*=-1;for(var s=e.length;s>1;s--){var r=255&t;t=Math.floor(t/256),i?e[s-1]=fe(r):0===r?e[s-1]=0:(i=true,e[s-1]=pe(r));}},ue=t=>{for(var e=t.length,i=0,s=false,r=e-1;r>-1;r--){var n,h=Number(t[r]);s?n=fe(h):0===h?n=h:(s=true,n=pe(h)),0!==n&&(i-=n*Math.pow(256,e-r-1));}return i},me=t=>{for(var e=t.length,i=0,s=e-1;s>-1;s--){var r=Number(t[s]);0!==r&&(i+=r*Math.pow(256,e-s-1));}return i},fe=t=>255&(255^t),pe=t=>1+(255^t)&255,ye=t=>be.has(t),be=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"]]),we=new Map(Array.from(be).map(t=>[t[1],t[0]]));class ge{cksumValid=false;needPax=false;nullBlock=false;block;path;mode;uid;gid;size;cksum;#d="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(t,e=0,i,s){Buffer.isBuffer(t)?this.decode(t,e||0,i,s):t&&this.#c(t);}decode(t,e,i,s){if(e||(e=0),!(t&&t.length>=e+512))throw new Error("need 512 bytes for header");this.path=i?.path??Re(t,e,100),this.mode=i?.mode??s?.mode??ve(t,e+100,8),this.uid=i?.uid??s?.uid??ve(t,e+108,8),this.gid=i?.gid??s?.gid??ve(t,e+116,8),this.size=i?.size??s?.size??ve(t,e+124,12),this.mtime=i?.mtime??s?.mtime??_e(t,e+136,12),this.cksum=ve(t,e+148,12),s&&this.#c(s,true),i&&this.#c(i);const r=Re(t,e+156,1);if(ye(r)&&(this.#d=r||"0"),"0"===this.#d&&"/"===this.path.slice(-1)&&(this.#d="5"),"5"===this.#d&&(this.size=0),this.linkpath=Re(t,e+157,100),"ustar\x0000"===t.subarray(e+257,e+265).toString())if(this.uname=i?.uname??s?.uname??Re(t,e+265,32),this.gname=i?.gname??s?.gname??Re(t,e+297,32),this.devmaj=i?.devmaj??s?.devmaj??ve(t,e+329,8)??0,this.devmin=i?.devmin??s?.devmin??ve(t,e+337,8)??0,0!==t[e+475]){const i=Re(t,e+345,155);this.path=i+"/"+this.path;}else {const r=Re(t,e+345,130);r&&(this.path=r+"/"+this.path),this.atime=i?.atime??s?.atime??_e(t,e+476,12),this.ctime=i?.ctime??s?.ctime??_e(t,e+488,12);}let n=256;for(let i=e;i<e+148;i++)n+=t[i];for(let i=e+156;i<e+512;i++)n+=t[i];this.cksumValid=n===this.cksum,void 0===this.cksum&&256===n&&(this.nullBlock=true);}#c(t,e=false){Object.assign(this,Object.fromEntries(Object.entries(t).filter(([t,i])=>!(null==i||"path"===t&&e||"linkpath"===t&&e||"global"===t))));}encode(t,e=0){if(t||(t=this.block=Buffer.alloc(512)),"Unsupported"===this.#d&&(this.#d="0"),!(t.length>=e+512))throw new Error("need 512 bytes for header");const i=this.ctime||this.atime?130:155,s=Ee(this.path||"",i),r=s[0],n=s[1];this.needPax=!!s[2],this.needPax=Ne(t,e,100,r)||this.needPax,this.needPax=ke(t,e+100,8,this.mode)||this.needPax,this.needPax=ke(t,e+108,8,this.uid)||this.needPax,this.needPax=ke(t,e+116,8,this.gid)||this.needPax,this.needPax=ke(t,e+124,12,this.size)||this.needPax,this.needPax=xe(t,e+136,12,this.mtime)||this.needPax,t[e+156]=this.#d.charCodeAt(0),this.needPax=Ne(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=Ne(t,e+265,32,this.uname)||this.needPax,this.needPax=Ne(t,e+297,32,this.gname)||this.needPax,this.needPax=ke(t,e+329,8,this.devmaj)||this.needPax,this.needPax=ke(t,e+337,8,this.devmin)||this.needPax,this.needPax=Ne(t,e+345,i,n)||this.needPax,0!==t[e+475]?this.needPax=Ne(t,e+345,155,n)||this.needPax:(this.needPax=Ne(t,e+345,130,n)||this.needPax,this.needPax=xe(t,e+476,12,this.atime)||this.needPax,this.needPax=xe(t,e+488,12,this.ctime)||this.needPax);let h=256;for(let i=e;i<e+148;i++)h+=t[i];for(let i=e+156;i<e+512;i++)h+=t[i];return this.cksum=h,ke(t,e+148,8,this.cksum),this.cksumValid=true,this.needPax}get type(){return "Unsupported"===this.#d?this.#d:be.get(this.#d)}get typeKey(){return this.#d}set type(t){const e=String(we.get(t));if(ye(e)||"Unsupported"===e)this.#d=e;else {if(!ye(t))throw new TypeError("invalid entry type: "+t);this.#d=t;}}}const Ee=(t,e)=>{const i=100;let s,r=t,n="";const h=posix.parse(t).root||".";if(Buffer.byteLength(r)<i)s=[r,n,false];else {n=posix.dirname(r),r=posix.basename(r);do{Buffer.byteLength(r)<=i&&Buffer.byteLength(n)<=e?s=[r,n,false]:Buffer.byteLength(r)>i&&Buffer.byteLength(n)<=e?s=[r.slice(0,99),n,true]:(r=posix.join(posix.basename(n),r),n=posix.dirname(n));}while(n!==h&&void 0===s);s||(s=[t.slice(0,99),"",true]);}return s},Re=(t,e,i)=>t.subarray(e,e+i).toString("utf8").replace(/\0.*/,""),_e=(t,e,i)=>Se(ve(t,e,i)),Se=t=>void 0===t?void 0:new Date(1e3*t),ve=(t,e,i)=>128&Number(t[e])?(t=>{const e=t[0],i=128===e?me(t.subarray(1,t.length)):255===e?ue(t):null;if(null===i)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(i))throw Error("parsed number outside of javascript safe integer range");return i})(t.subarray(e,e+i)):Oe(t,e,i),Oe=(t,e,i)=>{return s=parseInt(t.subarray(e,e+i).toString("utf8").replace(/\0.*$/,"").trim(),8),isNaN(s)?void 0:s;var s;},Te={12:8589934591,8:2097151},ke=(t,e,i,s)=>void 0!==s&&(s>Te[i]||s<0?(((t,e)=>{if(!Number.isSafeInteger(t))throw Error("cannot encode number outside of javascript safe integer range");t<0?ce(t,e):de(t,e);})(s,t.subarray(e,e+i)),true):(Le(t,e,i,s),false)),Le=(t,e,i,s)=>t.write(De(s,i),e,i,"ascii"),De=(t,e)=>Ae(Math.floor(t).toString(8),e),Ae=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",xe=(t,e,i,s)=>void 0!==s&&ke(t,e,i,s.getTime()/1e3),Ie=new Array(156).join("\0"),Ne=(t,e,i,s)=>void 0!==s&&(t.write(s+Ie,e,i,"utf8"),s.length!==Buffer.byteLength(s)||s.length>i);class Fe{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(t,e=false){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;}encode(){const t=this.encodeBody();if(""===t)return Buffer.allocUnsafe(0);const e=Buffer.byteLength(t),i=512*Math.ceil(1+e/512),s=Buffer.allocUnsafe(i);for(let t=0;t<512;t++)s[t]=0;new ge({path:("PaxHeader/"+basename(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(s),s.write(t,512,e,"utf8");for(let t=e+512;t<s.length;t++)s[t]=0;return s}encodeBody(){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")}encodeField(t){if(void 0===this[t])return "";const e=this[t],i=" "+("dev"===t||"ino"===t||"nlink"===t?"SCHILY.":"")+t+"="+(e instanceof Date?e.getTime()/1e3:e)+"\n",s=Buffer.byteLength(i);let r=Math.floor(Math.log(s)/Math.log(10))+1;s+r>=Math.pow(10,r)&&(r+=1);return r+s+i}static parse(t,e,i=false){return new Fe(Be(Me(t),e),i)}}const Be=(t,e)=>e?Object.assign({},e,t):t,Me=t=>t.replace(/\n$/,"").split("\n").reduce(Ce,Object.create(null)),Ce=(t,e)=>{const i=parseInt(e,10);if(i!==Buffer.byteLength(e)+1)return t;const s=(e=e.slice((i+" ").length)).split("="),r=s.shift();if(!r)return t;const n=r.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),h=s.join("=");return t[n]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(n)?new Date(1e3*Number(h)):/^[0-9]+$/.test(h)?+h:h,t},Pe="win32"!==(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform)?t=>t:t=>t&&t.replace(/\\/g,"/");class ze extends ot{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=false;ignore=false;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=false;absolute;unsupported=false;constructor(t,e,i){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){case "File":case "OldFile":case "Link":case "SymbolicLink":case "CharacterDevice":case "BlockDevice":case "Directory":case "FIFO":case "ContiguousFile":case "GNUDumpDir":break;case "NextFileHasLongLinkpath":case "NextFileHasLongPath":case "OldGnuLongPath":case "GlobalExtendedHeader":case "ExtendedHeader":case "OldExtendedHeader":this.meta=true;break;default:this.ignore=true;}if(!t.path)throw new Error("no path provided for tar.ReadEntry");this.path=Pe(t.path),this.mode=t.mode,this.mode&&(this.mode=4095&this.mode),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?Pe(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,e&&this.#c(e),i&&this.#c(i,true);}write(t){const e=t.length;if(e>this.blockRemain)throw new Error("writing more to entry than is appropriate");const i=this.remain,s=this.blockRemain;return this.remain=Math.max(0,i-e),this.blockRemain=Math.max(0,s-e),!!this.ignore||(i>=e?super.write(t):super.write(t.subarray(0,i)))}#c(t,e=false){t.path&&(t.path=Pe(t.path)),t.linkpath&&(t.linkpath=Pe(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([t,i])=>!(null==i||"path"===t&&e))));}}const Ue=(t,e,i,s={})=>{t.file&&(s.file=t.file),t.cwd&&(s.cwd=t.cwd),s.code=i instanceof Error&&i.code||e,s.tarCode=e,t.strict||false===s.recoverable?i instanceof Error?t.emit("error",Object.assign(i,s)):t.emit("error",Object.assign(new Error(`${e}: ${i}`),s)):(i instanceof Error&&(s=Object.assign(i,s),i=i.message),t.emit("warn",e,i,s));},je=Buffer.from([31,139]),Ze=Buffer.from([40,181,47,253]),He=Math.max(je.length,Ze.length),Ge=Symbol("state"),We=Symbol("writeEntry"),Ye=Symbol("readEntry"),Ve=Symbol("nextEntry"),$e=Symbol("processEntry"),qe=Symbol("extendedHeader"),Ke=Symbol("globalExtendedHeader"),Xe=Symbol("meta"),Qe=Symbol("emitMeta"),Je=Symbol("buffer"),ti=Symbol("queue"),ei=Symbol("ended"),ii=Symbol("emittedEnd"),si=Symbol("emit"),ri=Symbol("unzip"),ni=Symbol("consumeChunk"),hi=Symbol("consumeChunkSub"),oi=Symbol("consumeBody"),ai=Symbol("consumeMeta"),li=Symbol("consumeHeader"),di=Symbol("consuming"),ci=Symbol("bufferConcat"),ui=Symbol("maybeEnd"),mi=Symbol("writing"),fi=Symbol("aborted"),pi=Symbol("onDone"),yi=Symbol("sawValidEntry"),bi=Symbol("sawNullBlock"),wi=Symbol("sawEOF"),gi=Symbol("closeStream"),Ei=()=>true;class Ri extends EventEmitter{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=true;readable=false;[ti]=[];[Je];[Ye];[We];[Ge]="begin";[Xe]="";[qe];[Ke];[ei]=false;[ri];[fi]=false;[yi];[bi]=false;[wi]=false;[mi]=false;[di]=false;[ii]=false;constructor(t={}){super(),this.file=t.file||"",this.on(pi,()=>{"begin"!==this[Ge]&&false!==this[yi]||this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format");}),t.ondone?this.on(pi,t.ondone):this.on(pi,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end");}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||1048576,this.filter="function"==typeof t.filter?t.filter:Ei;const e=t.file&&(t.file.endsWith(".tar.br")||t.file.endsWith(".tbr"));this.brotli=t.gzip||t.zstd||void 0===t.brotli?!!e&&void 0:t.brotli;const i=t.file&&(t.file.endsWith(".tar.zst")||t.file.endsWith(".tzst"));this.zstd=t.gzip||t.brotli||void 0===t.zstd?!!i||void 0:t.zstd,this.on("end",()=>this[gi]()),"function"==typeof t.onwarn&&this.on("warn",t.onwarn),"function"==typeof t.onReadEntry&&this.on("entry",t.onReadEntry);}warn(t,e,i={}){Ue(this,t,e,i);}[li](t,e){let i;void 0===this[yi]&&(this[yi]=false);try{i=new ge(t,e,this[qe],this[Ke]);}catch(t){return this.warn("TAR_ENTRY_INVALID",t)}if(i.nullBlock)this[bi]?(this[wi]=true,"begin"===this[Ge]&&(this[Ge]="header"),this[si]("eof")):(this[bi]=true,this[si]("nullBlock"));else if(this[bi]=false,i.cksumValid)if(i.path){const t=i.type;if(/^(Symbolic)?Link$/.test(t)&&!i.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:i});else if(/^(Symbolic)?Link$/.test(t)||/^(Global)?ExtendedHeader$/.test(t)||!i.linkpath){const t=this[We]=new ze(i,this[qe],this[Ke]);if(!this[yi])if(t.remain){const e=()=>{t.invalid||(this[yi]=true);};t.on("end",e);}else this[yi]=true;t.meta?t.size>this.maxMetaEntrySize?(t.ignore=true,this[si]("ignoredEntry",t),this[Ge]="ignore",t.resume()):t.size>0&&(this[Xe]="",t.on("data",t=>this[Xe]+=t),this[Ge]="meta"):(this[qe]=void 0,t.ignore=t.ignore||!this.filter(t.path,t),t.ignore?(this[si]("ignoredEntry",t),this[Ge]=t.remain?"ignore":"header",t.resume()):(t.remain?this[Ge]="body":(this[Ge]="header",t.end()),this[Ye]?this[ti].push(t):(this[ti].push(t),this[Ve]())));}else this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:i});}else this.warn("TAR_ENTRY_INVALID","path is required",{header:i});else this.warn("TAR_ENTRY_INVALID","checksum failure",{header:i});}[gi](){queueMicrotask(()=>this.emit("close"));}[$e](t){let e=true;if(t)if(Array.isArray(t)){const[e,...i]=t;this.emit(e,...i);}else this[Ye]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[Ve]()),e=false);else this[Ye]=void 0,e=false;return e}[Ve](){do{}while(this[$e](this[ti].shift()));if(!this[ti].length){const t=this[Ye];!t||t.flowing||t.size===t.remain?this[mi]||this.emit("drain"):t.once("drain",()=>this.emit("drain"));}}[oi](t,e){const i=this[We];if(!i)throw new Error("attempt to consume body without entry??");const s=i.blockRemain??0,r=s>=t.length&&0===e?t:t.subarray(e,e+s);return i.write(r),i.blockRemain||(this[Ge]="header",this[We]=void 0,i.end()),r.length}[ai](t,e){const i=this[We],s=this[oi](t,e);return !this[We]&&i&&this[Qe](i),s}[si](t,e,i){this[ti].length||this[Ye]?this[ti].push([t,e,i]):this.emit(t,e,i);}[Qe](t){switch(this[si]("meta",this[Xe]),t.type){case "ExtendedHeader":case "OldExtendedHeader":this[qe]=Fe.parse(this[Xe],this[qe],false);break;case "GlobalExtendedHeader":this[Ke]=Fe.parse(this[Xe],this[Ke],true);break;case "NextFileHasLongPath":case "OldGnuLongPath":{const t=this[qe]??Object.create(null);this[qe]=t,t.path=this[Xe].replace(/\0.*/,"");break}case "NextFileHasLongLinkpath":{const t=this[qe]||Object.create(null);this[qe]=t,t.linkpath=this[Xe].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[fi]=true,this.emit("abort",t),this.warn("TAR_ABORT",t,{recoverable:false});}write(t,e,i){if("function"==typeof e&&(i=e,e=void 0),"string"==typeof t&&(t=Buffer.from(t,"string"==typeof e?e:"utf8")),this[fi])return i?.(),false;if((void 0===this[ri]||void 0===this.brotli&&false===this[ri])&&t){if(this[Je]&&(t=Buffer.concat([this[Je],t]),this[Je]=void 0),t.length<He)return this[Je]=t,i?.(),true;for(let e=0;void 0===this[ri]&&e<je.length;e++)t[e]!==je[e]&&(this[ri]=false);let e=false;if(false===this[ri]&&false!==this.zstd){e=true;for(let i=0;i<Ze.length;i++)if(t[i]!==Ze[i]){e=false;break}}const s=void 0===this.brotli&&!e;if(false===this[ri]&&s)if(t.length<512){if(!this[ei])return this[Je]=t,i?.(),true;this.brotli=true;}else try{new ge(t.subarray(0,512)),this.brotli=!1;}catch(t){this.brotli=true;}if(void 0===this[ri]||false===this[ri]&&(this.brotli||e)){const s=this[ei];this[ei]=false,this[ri]=void 0===this[ri]?new se({}):e?new le({}):new he({}),this[ri].on("data",t=>this[ni](t)),this[ri].on("error",t=>this.abort(t)),this[ri].on("end",()=>{this[ei]=true,this[ni]();}),this[mi]=true;const r=!!this[ri][s?"end":"write"](t);return this[mi]=false,i?.(),r}}this[mi]=true,this[ri]?this[ri].write(t):this[ni](t),this[mi]=false;const s=!this[ti].length&&(!this[Ye]||this[Ye].flowing);return s||this[ti].length||this[Ye]?.once("drain",()=>this.emit("drain")),i?.(),s}[ci](t){t&&!this[fi]&&(this[Je]=this[Je]?Buffer.concat([this[Je],t]):t);}[ui](){if(this[ei]&&!this[ii]&&!this[fi]&&!this[di]){this[ii]=true;const t=this[We];if(t&&t.blockRemain){const e=this[Je]?this[Je].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[Je]&&t.write(this[Je]),t.end();}this[si](pi);}}[ni](t){if(this[di]&&t)this[ci](t);else if(t||this[Je]){if(t){if(this[di]=true,this[Je]){this[ci](t);const e=this[Je];this[Je]=void 0,this[hi](e);}else this[hi](t);for(;this[Je]&&this[Je]?.length>=512&&!this[fi]&&!this[wi];){const t=this[Je];this[Je]=void 0,this[hi](t);}this[di]=false;}}else this[ui]();this[Je]&&!this[ei]||this[ui]();}[hi](t){let e=0;const i=t.length;for(;e+512<=i&&!this[fi]&&!this[wi];)switch(this[Ge]){case "begin":case "header":this[li](t,e),e+=512;break;case "ignore":case "body":e+=this[oi](t,e);break;case "meta":e+=this[ai](t,e);break;default:throw new Error("invalid state: "+this[Ge])}e<i&&(this[Je]?this[Je]=Buffer.concat([t.subarray(e),this[Je]]):this[Je]=t.subarray(e));}end(t,e,i){return "function"==typeof t&&(i=t,e=void 0,t=void 0),"function"==typeof e&&(i=e,e=void 0),"string"==typeof t&&(t=Buffer.from(t,e)),i&&this.once("finish",i),this[fi]||(this[ri]?(t&&this[ri].write(t),this[ri].end()):(this[ei]=true,void 0!==this.brotli&&void 0!==this.zstd||(t=t||Buffer.alloc(0)),t&&this.write(t),this[ui]())),this}}const _i=t=>{let e=t.length-1,i=-1;for(;e>-1&&"/"===t.charAt(e);)i=e,e--;return -1===i?t:t.slice(0,i)},Si=(t,e)=>{const i=new Map(e.map(t=>[_i(t),true])),s=t.filter,r=(t,e="")=>{const s=e||parse(t).root||".";let n;if(t===s)n=false;else {const e=i.get(t);n=void 0!==e?e:r(dirname(t),s);}return i.set(t,n),n};t.filter=s?(t,e)=>s(t,e)&&r(_i(t)):t=>r(_i(t));},vi=Gt(t=>{const e=new Ri(t),i=t.file;let s;try{s=c.openSync(i,"r");const r=c.fstatSync(s),n=t.maxReadSize||16777216;if(r.size<n){const t=Buffer.allocUnsafe(r.size),i=c.readSync(s,t,0,r.size,0);e.end(i===t.byteLength?t:t.subarray(0,i));}else {let t=0;const i=Buffer.allocUnsafe(n);for(;t<r.size;){const r=c.readSync(s,i,0,n,t);if(0===r)break;t+=r,e.write(i.subarray(0,r));}e.end();}}finally{if("number"==typeof s)try{c.closeSync(s);}catch(t){}}},(t,e)=>{const i=new Ri(t),s=t.maxReadSize||16777216,r=t.file;return new Promise((t,e)=>{i.on("error",e),i.on("end",t),c.stat(r,(t,n)=>{if(t)e(t);else {const t=new Ct(r,{readSize:s,size:n.size});t.on("error",e),t.pipe(i);}});})},t=>new Ri(t),t=>new Ri(t),(t,e)=>{e?.length&&Si(t,e),t.noResume||(t=>{const e=t.onReadEntry;t.onReadEntry=e?t=>{e(t),t.resume();}:t=>t.resume();})(t);}),Oi=(t,e,i)=>(t&=4095,i&&(t=-19&t|384),e&&(256&t&&(t|=64),32&t&&(t|=8),4&t&&(t|=1)),t),{isAbsolute:Ti,parse:ki}=win32,Li=t=>{let e="",i=ki(t);for(;Ti(t)||i.root;){const s="/"===t.charAt(0)&&"//?/"!==t.slice(0,4)?"/":i.root;t=t.slice(s.length),e+=s,i=ki(t);}return [e,t]},Di=["|","<",">","?",":"],Ai=Di.map(t=>String.fromCharCode(61440+t.charCodeAt(0))),xi=new Map(Di.map((t,e)=>[t,Ai[e]])),Ii=new Map(Ai.map((t,e)=>[t,Di[e]])),Ni=t=>Di.reduce((t,e)=>t.split(e).join(xi.get(e)),t),Fi=(t,e)=>e?(t=Pe(t).replace(/^\.(\/|$)/,""),_i(e)+"/"+t):Pe(t),Bi=Symbol("process"),Mi=Symbol("file"),Ci=Symbol("directory"),Pi=Symbol("symlink"),zi=Symbol("hardlink"),Ui=Symbol("header"),ji=Symbol("read"),Zi=Symbol("lstat"),Hi=Symbol("onlstat"),Gi=Symbol("onread"),Wi=Symbol("onreadlink"),Yi=Symbol("openfile"),Vi=Symbol("onopenfile"),$i=Symbol("close"),qi=Symbol("mode"),Ki=Symbol("awaitDrain"),Xi=Symbol("ondrain"),Qi=Symbol("prefix");class Ji extends ot{path;portable;myuid=process.getuid&&process.getuid()||0;myuser=process.env.USER||"";maxReadSize;linkCache;statCache;preservePaths;cwd;strict;mtime;noPax;noMtime;prefix;fd;blockLen=0;blockRemain=0;buf;pos=0;remain=0;length=0;offset=0;win32;absolute;header;type;linkpath;stat;onWriteEntry;#u=false;constructor(t,e={}){const i=Ht(e);super(),this.path=Pe(t),this.portable=!!i.portable,this.maxReadSize=i.maxReadSize||16777216,this.linkCache=i.linkCache||new Map,this.statCache=i.statCache||new Map,this.preservePaths=!!i.preservePaths,this.cwd=Pe(i.cwd||process.cwd()),this.strict=!!i.strict,this.noPax=!!i.noPax,this.noMtime=!!i.noMtime,this.mtime=i.mtime,this.prefix=i.prefix?Pe(i.prefix):void 0,this.onWriteEntry=i.onWriteEntry,"function"==typeof i.onwarn&&this.on("warn",i.onwarn);let s=false;if(!this.preservePaths){const[t,e]=Li(this.path);t&&"string"==typeof e&&(this.path=e,s=t);}var r;this.win32=!!i.win32||"win32"===process.platform,this.win32&&(this.path=(r=this.path.replace(/\\/g,"/"),Ai.reduce((t,e)=>t.split(e).join(Ii.get(e)),r)),t=t.replace(/\\/g,"/")),this.absolute=Pe(i.absolute||x$1.resolve(this.cwd,t)),""===this.path&&(this.path="./"),s&&this.warn("TAR_ENTRY_INFO",`stripping ${s} from absolute path`,{entry:this,path:s+this.path});const n=this.statCache.get(this.absolute);n?this[Hi](n):this[Zi]();}warn(t,e,i={}){return Ue(this,t,e,i)}emit(t,...e){return "error"===t&&(this.#u=true),super.emit(t,...e)}[Zi](){i.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Hi](e);});}[Hi](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=is(t),this.emit("stat",t),this[Bi]();}[Bi](){switch(this.type){case "File":return this[Mi]();case "Directory":return this[Ci]();case "SymbolicLink":return this[Pi]();default:return this.end()}}[qi](t){return Oi(t,"Directory"===this.type,this.portable)}[Qi](t){return Fi(t,this.prefix)}[Ui](){if(!this.stat)throw new Error("cannot write header before stat");"Directory"===this.type&&this.portable&&(this.noMtime=true),this.onWriteEntry?.(this),this.header=new ge({path:this[Qi](this.path),linkpath:"Link"===this.type&&void 0!==this.linkpath?this[Qi](this.linkpath):this.linkpath,mode:this[qi](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:"Unsupported"===this.type?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 Fe({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[Qi](this.path),linkpath:"Link"===this.type&&void 0!==this.linkpath?this[Qi](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());const t=this.header?.block;if(!t)throw new Error("failed to encode header");super.write(t);}[Ci](){if(!this.stat)throw new Error("cannot create directory entry without stat");"/"!==this.path.slice(-1)&&(this.path+="/"),this.stat.size=0,this[Ui](),this.end();}[Pi](){i.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Wi](e);});}[Wi](t){this.linkpath=Pe(t),this[Ui](),this.end();}[zi](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Pe(x$1.relative(this.cwd,t)),this.stat.size=0,this[Ui](),this.end();}[Mi](){if(!this.stat)throw new Error("cannot create file entry without stat");if(this.stat.nlink>1){const t=`${this.stat.dev}:${this.stat.ino}`,e=this.linkCache.get(t);if(0===e?.indexOf(this.cwd))return this[zi](e);this.linkCache.set(t,this.absolute);}if(this[Ui](),0===this.stat.size)return this.end();this[Yi]();}[Yi](){i.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[Vi](e);});}[Vi](t){if(this.fd=t,this.#u)return this[$i]();if(!this.stat)throw new Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;const e=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(e),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[ji]();}[ji](){const{fd:t,buf:e,offset:s,length:r,pos:n}=this;if(void 0===t||void 0===e)throw new Error("cannot read file without first opening");i.read(t,e,s,r,n,(t,e)=>{if(t)return this[$i](()=>this.emit("error",t));this[Gi](e);});}[$i](t=()=>{}){ void 0!==this.fd&&i.close(this.fd,t);}[Gi](t){if(t<=0&&this.remain>0){const t=Object.assign(new Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[$i](()=>this.emit("error",t))}if(t>this.remain){const t=Object.assign(new Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[$i](()=>this.emit("error",t))}if(!this.buf)throw new Error("should have created buffer prior to reading");if(t===this.remain)for(let e=t;e<this.length&&t<this.blockRemain;e++)this.buf[e+this.offset]=0,t++,this.remain++;const e=0===this.offset&&t===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+t);this.write(e)?this[Xi]():this[Ki](()=>this[Xi]());}[Ki](t){this.once("drain",t);}write(t,e,i){if("function"==typeof e&&(i=e,e=void 0),"string"==typeof t&&(t=Buffer.from(t,"string"==typeof e?e:"utf8")),this.blockRemain<t.length){const t=Object.assign(new Error("writing more data than expected"),{path:this.absolute});return this.emit("error",t)}return this.remain-=t.length,this.blockRemain-=t.length,this.pos+=t.length,this.offset+=t.length,super.write(t,null,i)}[Xi](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[$i](t=>t?this.emit("error",t):this.end());if(!this.buf)throw new Error("buffer lost somehow in ONDRAIN");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[ji]();}}class ts extends Ji{sync=true;[Zi](){this[Hi](i.lstatSync(this.absolute));}[Pi](){this[Wi](i.readlinkSync(this.absolute));}[Yi](){this[Vi](i.openSync(this.absolute,"r"));}[ji](){let t=true;try{const{fd:e,buf:s,offset:r,length:n,pos:h}=this;if(void 0===e||void 0===s)throw new Error("fd and buf must be set in READ method");const o=i.readSync(e,s,r,n,h);this[Gi](o),t=!1;}finally{if(t)try{this[$i](()=>{});}catch(t){}}}[Ki](t){t();}[$i](t=()=>{}){ void 0!==this.fd&&i.closeSync(this.fd),t();}}class es extends ot{blockLen=0;blockRemain=0;buf=0;pos=0;remain=0;length=0;preservePaths;portable;strict;noPax;noMtime;readEntry;type;prefix;path;mode;uid;gid;uname;gname;header;mtime;atime;ctime;linkpath;size;onWriteEntry;warn(t,e,i={}){return Ue(this,t,e,i)}constructor(t,e={}){const i=Ht(e);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;const{type:s}=t;if("Unsupported"===s)throw new Error("writing entry that should be ignored");this.type=s,"Directory"===this.type&&this.portable&&(this.noMtime=true),this.prefix=i.prefix,this.path=Pe(t.path),this.mode=void 0!==t.mode?this[qi](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=void 0!==t.linkpath?Pe(t.linkpath):void 0,"function"==typeof i.onwarn&&this.on("warn",i.onwarn);let r=false;if(!this.preservePaths){const[t,e]=Li(this.path);t&&"string"==typeof e&&(this.path=e,r=t);}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new ge({path:this[Qi](this.path),linkpath:"Link"===this.type&&void 0!==this.linkpath?this[Qi](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}),r&&this.warn("TAR_ENTRY_INFO",`stripping ${r} from absolute path`,{entry:this,path:r+this.path}),this.header.encode()&&!this.noPax&&super.write(new Fe({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[Qi](this.path),linkpath:"Link"===this.type&&void 0!==this.linkpath?this[Qi](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());const n=this.header?.block;if(!n)throw new Error("failed to encode header");super.write(n),t.pipe(this);}[Qi](t){return Fi(t,this.prefix)}[qi](t){return Oi(t,"Directory"===this.type,this.portable)}write(t,e,i){"function"==typeof e&&(i=e,e=void 0),"string"==typeof t&&(t=Buffer.from(t,"string"==typeof e?e:"utf8"));const s=t.length;if(s>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=s,super.write(t,i)}end(t,e,i){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),"function"==typeof t&&(i=t,e=void 0,t=void 0),"function"==typeof e&&(i=e,e=void 0),"string"==typeof t&&(t=Buffer.from(t,e??"utf8")),i&&this.once("finish",i),t?super.end(t,i):super.end(i),this}}const is=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported";class ss{tail;head;length=0;static create(t=[]){return new ss(t)}constructor(t=[]){for(const e of t)this.push(e);}*[Symbol.iterator](){for(let t=this.head;t;t=t.next)yield t.value;}removeNode(t){if(t.list!==this)throw new Error("removing node which does not belong to this list");const e=t.next,i=t.prev;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}unshiftNode(t){if(t===this.head)return;t.list&&t.list.removeNode(t);const e=this.head;t.list=this,t.next=e,e&&(e.prev=t),this.head=t,this.tail||(this.tail=t),this.length++;}pushNode(t){if(t===this.tail)return;t.list&&t.list.removeNode(t);const e=this.tail;t.list=this,t.prev=e,e&&(e.next=t),this.tail=t,this.head||(this.head=t),this.length++;}push(...t){for(let e=0,i=t.length;e<i;e++)ns(this,t[e]);return this.length}unshift(...t){for(var e=0,i=t.length;e<i;e++)hs(this,t[e]);return this.length}pop(){if(!this.tail)return;const t=this.tail.value,e=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,e.list=void 0,this.length--,t}shift(){if(!this.head)return;const t=this.head.value,e=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,e.list=void 0,this.length--,t}forEach(t,e){e=e||this;for(let i=this.head,s=0;i;s++)t.call(e,i.value,s,this),i=i.next;}forEachReverse(t,e){e=e||this;for(let i=this.tail,s=this.length-1;i;s--)t.call(e,i.value,s,this),i=i.prev;}get(t){let e=0,i=this.head;for(;i&&e<t;e++)i=i.next;if(e===t&&i)return i.value}getReverse(t){let e=0,i=this.tail;for(;i&&e<t;e++)i=i.prev;if(e===t&&i)return i.value}map(t,e){e=e||this;const i=new ss;for(let s=this.head;s;)i.push(t.call(e,s.value,this)),s=s.next;return i}mapReverse(t,e){e=e||this;var i=new ss;for(let s=this.tail;s;)i.push(t.call(e,s.value,this)),s=s.prev;return i}reduce(t,e){let i,s=this.head;if(arguments.length>1)i=e;else {if(!this.head)throw new TypeError("Reduce of empty list with no initial value");s=this.head.next,i=this.head.value;}for(var r=0;s;r++)i=t(i,s.value,r),s=s.next;return i}reduceReverse(t,e){let i,s=this.tail;if(arguments.length>1)i=e;else {if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");s=this.tail.prev,i=this.tail.value;}for(let e=this.length-1;s;e--)i=t(i,s.value,e),s=s.prev;return i}toArray(){const t=new Array(this.length);for(let e=0,i=this.head;i;e++)t[e]=i.value,i=i.next;return t}toArrayReverse(){const t=new Array(this.length);for(let e=0,i=this.tail;i;e++)t[e]=i.value,i=i.prev;return t}slice(t=0,e=this.length){e<0&&(e+=this.length),t<0&&(t+=this.length);const i=new ss;if(e<t||e<0)return i;t<0&&(t=0),e>this.length&&(e=this.length);let s=this.head,r=0;for(r=0;s&&r<t;r++)s=s.next;for(;s&&r<e;r++,s=s.next)i.push(s.value);return i}sliceReverse(t=0,e=this.length){e<0&&(e+=this.length),t<0&&(t+=this.length);const i=new ss;if(e<t||e<0)return i;t<0&&(t=0),e>this.length&&(e=this.length);let s=this.length,r=this.tail;for(;r&&s>e;s--)r=r.prev;for(;r&&s>t;s--,r=r.prev)i.push(r.value);return i}splice(t,e=0,...i){t>this.length&&(t=this.length-1),t<0&&(t=this.length+t);let s=this.head;for(let e=0;s&&e<t;e++)s=s.next;const r=[];for(let t=0;s&&t<e;t++)r.push(s.value),s=this.removeNode(s);s?s!==this.tail&&(s=s.prev):s=this.tail;for(const t of i)s=rs(this,s,t);return r}reverse(){const t=this.head,e=this.tail;for(let e=t;e;e=e.prev){const t=e.prev;e.prev=e.next,e.next=t;}return this.head=e,this.tail=t,this}}function rs(t,e,i){const s=e,r=e?e.next:t.head,n=new os(i,s,r,t);return void 0===n.next&&(t.tail=n),void 0===n.prev&&(t.head=n),t.length++,n}function ns(t,e){t.tail=new os(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++;}function hs(t,e){t.head=new os(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++;}class os{list;next;prev;value;constructor(t,e,i,s){this.list=s,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;}}class as{path;absolute;entry;stat;readdir;pending=false;ignore=false;piped=false;constructor(t,e){this.path=t||"./",this.absolute=e;}}const ls=Buffer.alloc(1024),ds=Symbol("onStat"),cs=Symbol("ended"),us=Symbol("queue"),ms=Symbol("current"),fs=Symbol("process"),ps=Symbol("processing"),ys=Symbol("processJob"),bs=Symbol("jobs"),ws=Symbol("jobDone"),gs=Symbol("addFSEntry"),Es=Symbol("addTarEntry"),Rs=Symbol("stat"),_s=Symbol("readdir"),Ss=Symbol("onreaddir"),vs=Symbol("pipe"),Os=Symbol("entry"),Ts=Symbol("entryOpt"),ks=Symbol("writeEntryClass"),Ls=Symbol("write"),Ds=Symbol("ondrain");class As extends ot{opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[ks];onWriteEntry;[us];[bs]=0;[ps]=false;[cs]=false;constructor(t={}){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=Pe(t.prefix||""),this.linkCache=t.linkCache||new Map,this.statCache=t.statCache||new Map,this.readdirCache=t.readdirCache||new Map,this.onWriteEntry=t.onWriteEntry,this[ks]=Ji,"function"==typeof t.onwarn&&this.on("warn",t.onwarn),this.portable=!!t.portable,t.gzip||t.brotli||t.zstd){if((t.gzip?1:0)+(t.brotli?1:0)+(t.zstd?1:0)>1)throw new TypeError("gzip, brotli, zstd are mutually exclusive");if(t.gzip&&("object"!=typeof t.gzip&&(t.gzip={}),this.portable&&(t.gzip.portable=true),this.zip=new ie(t.gzip)),t.brotli&&("object"!=typeof t.brotli&&(t.brotli={}),this.zip=new ne(t.brotli)),t.zstd&&("object"!=typeof t.zstd&&(t.zstd={}),this.zip=new ae(t.zstd)),!this.zip)throw new Error("impossible");const e=this.zip;e.on("data",t=>super.write(t)),e.on("end",()=>super.end()),e.on("drain",()=>this[Ds]()),this.on("resume",()=>e.resume());}else this.on("drain",this[Ds]);this.noDirRecurse=!!t.noDirRecurse,this.follow=!!t.follow,this.noMtime=!!t.noMtime,t.mtime&&(this.mtime=t.mtime),this.filter="function"==typeof t.filter?t.filter:()=>true,this[us]=new ss,this[bs]=0,this.jobs=Number(t.jobs)||4,this[ps]=false,this[cs]=false;}[Ls](t){return super.write(t)}add(t){return this.write(t),this}end(t,e,i){return "function"==typeof t&&(i=t,t=void 0),"function"==typeof e&&(i=e,e=void 0),t&&this.add(t),this[cs]=true,this[fs](),i&&i(),this}write(t){if(this[cs])throw new Error("write after end");return t instanceof ze?this[Es](t):this[gs](t),this.flowing}[Es](t){const e=Pe(x$1.resolve(this.cwd,t.path));if(this.filter(t.path,t)){const i=new as(t.path,e);i.entry=new es(t,this[Ts](i)),i.entry.on("end",()=>this[ws](i)),this[bs]+=1,this[us].push(i);}else t.resume();this[fs]();}[gs](t){const e=Pe(x$1.resolve(this.cwd,t));this[us].push(new as(t,e)),this[fs]();}[Rs](t){t.pending=true,this[bs]+=1;const e=this.follow?"stat":"lstat";i[e](t.absolute,(e,i)=>{t.pending=false,this[bs]-=1,e?this.emit("error",e):this[ds](t,i);});}[ds](t,e){this.statCache.set(t.absolute,e),t.stat=e,this.filter(t.path,e)||(t.ignore=true),this[fs]();}[_s](t){t.pending=true,this[bs]+=1,i.readdir(t.absolute,(e,i)=>{if(t.pending=false,this[bs]-=1,e)return this.emit("error",e);this[Ss](t,i);});}[Ss](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[fs]();}[fs](){if(!this[ps]){this[ps]=true;for(let t=this[us].head;t&&this[bs]<this.jobs;t=t.next)if(this[ys](t.value),t.value.ignore){const e=t.next;this[us].removeNode(t),t.next=e;}this[ps]=false,this[cs]&&!this[us].length&&0===this[bs]&&(this.zip?this.zip.end(ls):(super.write(ls),super.end()));}}get[ms](){return this[us]&&this[us].head&&this[us].head.value}[ws](t){this[us].shift(),this[bs]-=1,this[fs]();}[ys](t){if(!t.pending)if(t.entry)t!==this[ms]||t.piped||this[vs](t);else {if(!t.stat){const e=this.statCache.get(t.absolute);e?this[ds](t,e):this[Rs](t);}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){const e=this.readdirCache.get(t.absolute);if(e?this[Ss](t,e):this[_s](t),!t.readdir)return}t.entry=this[Os](t),t.entry?t!==this[ms]||t.piped||this[vs](t):t.ignore=true;}}}[Ts](t){return {onwarn:(t,e,i)=>this.warn(t,e,i),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}}[Os](t){this[bs]+=1;try{return new this[ks](t.path,this[Ts](t)).on("end",()=>this[ws](t)).on("error",t=>this.emit("error",t))}catch(t){this.emit("error",t);}}[Ds](){this[ms]&&this[ms].entry&&this[ms].entry.resume();}[vs](t){t.piped=true,t.readdir&&t.readdir.forEach(e=>{const i=t.path,s="./"===i?"":i.replace(/\/*$/,"/");this[gs](s+e);});const e=t.entry,i=this.zip;if(!e)throw new Error("cannot pipe without source");i?e.on("data",t=>{i.write(t)||e.pause();}):e.on("data",t=>{super.write(t)||e.pause();});}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(t,e,i={}){Ue(this,t,e,i);}}class xs extends As{sync=true;constructor(t){super(t),this[ks]=ts;}pause(){}resume(){}[Rs](t){const e=this.follow?"statSync":"lstatSync";this[ds](t,i[e](t.absolute));}[_s](t){this[Ss](t,i.readdirSync(t.absolute));}[vs](t){const e=t.entry,i=this.zip;if(t.readdir&&t.readdir.forEach(e=>{const i=t.path,s="./"===i?"":i.replace(/\/*$/,"/");this[gs](s+e);}),!e)throw new Error("Cannot pipe without source");i?e.on("data",t=>{i.write(t);}):e.on("data",t=>{super[Ls](t);});}}const Is=(t,e)=>{e.forEach(e=>{"@"===e.charAt(0)?vi({file:path.resolve(t.cwd,e.slice(1)),sync:true,noResume:true,onReadEntry:e=>t.add(e)}):t.add(e);}),t.end();},Ns=async(t,e)=>{for(let i=0;i<e.length;i++){const s=String(e[i]);"@"===s.charAt(0)?await vi({file:path.resolve(String(t.cwd),s.slice(1)),noResume:true,onReadEntry:e=>{t.add(e);}}):t.add(s);}t.end();},Fs=Gt((t,e)=>{const i=new xs(t),s=new Ut(t.file,{mode:t.mode||438});i.pipe(s),Is(i,e);},(t,e)=>{const i=new As(t),s=new zt(t.file,{mode:t.mode||438});i.pipe(s);const r=new Promise((t,e)=>{s.on("error",e),s.on("close",t),i.on("error",e);});return Ns(i,e),r},(t,e)=>{const i=new xs(t);return Is(i,e),i},(t,e)=>{const i=new As(t);return Ns(i,e),i},(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),Bs="win32"===(process.env.__FAKE_PLATFORM__||process.platform),{O_CREAT:Ms,O_TRUNC:Cs,O_WRONLY:Ps}=i.constants,zs=Number(process.env.__FAKE_FS_O_FILENAME__)||i.constants.UV_FS_O_FILEMAP||0,Us=zs|Cs|Ms|Ps,js=Bs&&!!zs?t=>t<524288?Us:"w":()=>"w",Zs=(t,e,i)=>{try{return c.lchownSync(t,e,i)}catch(t){if("ENOENT"!==t?.code)throw t}},Hs=(t,e,i,s)=>{c.lchown(t,e,i,t=>{s(t&&"ENOENT"!==t?.code?t:null);});},Gs=(t,e,i,s,r)=>{if(e.isDirectory())Ws(path.resolve(t,e.name),i,s,n=>{if(n)return r(n);const o=path.resolve(t,e.name);Hs(o,i,s,r);});else {const n=path.resolve(t,e.name);Hs(n,i,s,r);}},Ws=(t,e,i,s)=>{c.readdir(t,{withFileTypes:true},(r,n)=>{if(r){if("ENOENT"===r.code)return s();if("ENOTDIR"!==r.code&&"ENOTSUP"!==r.code)return s(r)}if(r||!n.length)return Hs(t,e,i,s);let h=n.length,o=null;const a=r=>{if(!o)return r?s(o=r):0===--h?Hs(t,e,i,s):void 0};for(const s of n)Gs(t,s,e,i,a);});},Ys=(t,e,i,s)=>{e.isDirectory()&&Vs(path.resolve(t,e.name),i,s),Zs(path.resolve(t,e.name),i,s);},Vs=(t,e,i)=>{let s;try{s=c.readdirSync(t,{withFileTypes:!0});}catch(s){const r=s;if("ENOENT"===r?.code)return;if("ENOTDIR"===r?.code||"ENOTSUP"===r?.code)return Zs(t,e,i);throw r}for(const r of s)Ys(t,r,e,i);return Zs(t,e,i)};class $s extends Error{path;code;syscall="chdir";constructor(t,e){super(`${e}: Cannot cd into '${t}'`),this.path=t,this.code=e;}get name(){return "CwdError"}}class qs extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(t,e){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=t,this.path=e;}get name(){return "SymlinkError"}}const Ks=(t,e,i)=>{t=Pe(t);const s=e.umask??18,r=448|e.mode,n=0!==(r&s),o=e.uid,a=e.gid,l="number"==typeof o&&"number"==typeof a&&(o!==e.processUid||a!==e.processGid),d=e.preserve,u=e.unlink,m=Pe(e.cwd),f=(e,s)=>{e?i(e):s&&l?Ws(s,o,a,t=>f(t)):n?c.chmod(t,r,i):i();};if(t===m)return ((t,e)=>{c.stat(t,(i,s)=>{!i&&s.isDirectory()||(i=new $s(t,i?.code||"ENOTDIR")),e(i);});})(t,f);if(d)return fsPromises.mkdir(t,{mode:r,recursive:true}).then(t=>f(null,t??void 0),f);const p=Pe(path.relative(m,t)).split("/");Xs(m,p,r,u,m,void 0,f);},Xs=(t,e,i,s,r,n,o)=>{if(!e.length)return o(null,n);const a=e.shift(),l=Pe(path.resolve(t+"/"+a));c.mkdir(l,i,Qs(l,e,i,s,r,n,o));},Qs=(t,e,i,s,r,n,h)=>o=>{o?c.lstat(t,(a,l)=>{if(a)a.path=a.path&&Pe(a.path),h(a);else if(l.isDirectory())Xs(t,e,i,s,r,n,h);else if(s)c.unlink(t,o=>{if(o)return h(o);c.mkdir(t,i,Qs(t,e,i,s,r,n,h));});else {if(l.isSymbolicLink())return h(new qs(t,t+"/"+e.join("/")));h(o);}}):Xs(t,e,i,s,r,n=n||t,h);},Js=(t,e)=>{t=Pe(t);const i=e.umask??18,s=448|e.mode,r=0!==(s&i),n=e.uid,o=e.gid,a="number"==typeof n&&"number"==typeof o&&(n!==e.processUid||o!==e.processGid),l=e.preserve,d=e.unlink,u=Pe(e.cwd),m=e=>{e&&a&&Vs(e,n,o),r&&c.chmodSync(t,s);};if(t===u)return (t=>{let e,i=false;try{i=c.statSync(t).isDirectory();}catch(t){e=t?.code;}finally{if(!i)throw new $s(t,e??"ENOTDIR")}})(u),m();if(l)return m(c.mkdirSync(t,{mode:s,recursive:true})??void 0);const f=Pe(path.relative(u,t)).split("/");let p;for(let t=f.shift(),e=u;t&&(e+="/"+t);t=f.shift()){e=Pe(path.resolve(e));try{c.mkdirSync(e,s),p=p||e;}catch(t){const i=c.lstatSync(e);if(i.isDirectory())continue;if(d){c.unlinkSync(e),c.mkdirSync(e,s),p=p||e;continue}if(i.isSymbolicLink())return new qs(e,e+"/"+f.join("/"))}}return m(p)},tr=Object.create(null),er=new Set,ir="win32"===(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform);class sr{#m=new Map;#f=new Map;#p=new Set;reserve(t,e){t=ir?["win32 parallelization disabled"]:t.map(t=>_i(join((t=>{er.has(t)?er.delete(t):tr[t]=t.normalize("NFD"),er.add(t);const e=tr[t];let i=er.size-1e4;if(i>1e3)for(const t of er)if(er.delete(t),delete tr[t],--i<=0)break;return e})(t))).toLowerCase());const i=new Set(t.map(t=>(t=>{const e=t.split("/").slice(0,-1).reduce((t,e)=>{const i=t[t.length-1];return void 0!==i&&(e=join(i,e)),t.push(e||"/"),t},[]);return e})(t)).reduce((t,e)=>t.concat(e)));this.#f.set(e,{dirs:i,paths:t});for(const i of t){const t=this.#m.get(i);t?t.push(e):this.#m.set(i,[e]);}for(const t of i){const i=this.#m.get(t);if(i){const t=i[i.length-1];t instanceof Set?t.add(e):i.push(new Set([e]));}else this.#m.set(t,[new Set([e])]);}return this.#y(e)}#b(t){const e=this.#f.get(t);if(!e)throw new Error("function does not have any path reservations");return {paths:e.paths.map(t=>this.#m.get(t)),dirs:[...e.dirs].map(t=>this.#m.get(t))}}check(t){const{paths:e,dirs:i}=this.#b(t);return e.every(e=>e&&e[0]===t)&&i.every(e=>e&&e[0]instanceof Set&&e[0].has(t))}#y(t){return !(this.#p.has(t)||!this.check(t))&&(this.#p.add(t),t(()=>this.#w(t)),true)}#w(t){if(!this.#p.has(t))return false;const e=this.#f.get(t);if(!e)throw new Error("invalid reservation");const{paths:i,dirs:s}=e,r=new Set;for(const e of i){const i=this.#m.get(e);if(!i||i?.[0]!==t)continue;const s=i[1];if(s)if(i.shift(),"function"==typeof s)r.add(s);else for(const t of s)r.add(t);else this.#m.delete(e);}for(const e of s){const i=this.#m.get(e),s=i?.[0];if(i&&s instanceof Set)if(1!==s.size||1!==i.length)if(1===s.size){i.shift();const t=i[0];"function"==typeof t&&r.add(t);}else s.delete(t);else this.#m.delete(e);}return this.#p.delete(t),r.forEach(t=>this.#y(t)),true}}const rr=Symbol("onEntry"),nr=Symbol("checkFs"),hr=Symbol("checkFs2"),or=Symbol("isReusable"),ar=Symbol("makeFs"),lr=Symbol("file"),dr=Symbol("directory"),cr=Symbol("link"),ur=Symbol("symlink"),mr=Symbol("hardlink"),fr=Symbol("unsupported"),pr=Symbol("checkPath"),yr=Symbol("stripAbsolutePath"),br=Symbol("mkdir"),wr=Symbol("onError"),gr=Symbol("pending"),Er=Symbol("pend"),Rr=Symbol("unpend"),_r=Symbol("ended"),Sr=Symbol("maybeClose"),vr=Symbol("skip"),Or=Symbol("doChown"),Tr=Symbol("uid"),kr=Symbol("gid"),Lr=Symbol("checkedCwd"),Dr="win32"===(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform),Ar=(t,e,i)=>void 0!==t&&t===t>>>0?t:void 0!==e&&e===e>>>0?e:i;class xr extends Ri{[_r]=false;[Lr]=false;[gr]=0;reservations=new sr;transform;writable=true;readable=false;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor(t={}){if(t.ondone=()=>{this[_r]=true,this[Sr]();},super(t),this.transform=t.transform,this.chmod=!!t.chmod,"number"==typeof t.uid||"number"==typeof t.gid){if("number"!=typeof t.uid||"number"!=typeof t.gid)throw new TypeError("cannot set owner without number uid and gid");if(t.preserveOwner)throw new TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=t.uid,this.gid=t.gid,this.setOwner=true;}else this.uid=void 0,this.gid=void 0,this.setOwner=false;void 0===t.preserveOwner&&"number"!=typeof t.uid?this.preserveOwner=!(!process.getuid||0!==process.getuid()):this.preserveOwner=!!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="number"==typeof t.maxDepth?t.maxDepth:1024,this.forceChown=true===t.forceChown,this.win32=!!t.win32||Dr,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Pe(path.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?"number"==typeof t.processUmask?t.processUmask:process.umask():0,this.umask="number"==typeof t.umask?t.umask:this.processUmask,this.dmode=t.dmode||511&~this.umask,this.fmode=t.fmode||438&~this.umask,this.on("entry",t=>this[rr](t));}warn(t,e,i={}){return "TAR_BAD_ARCHIVE"!==t&&"TAR_ABORT"!==t||(i.recoverable=false),super.warn(t,e,i)}[Sr](){this[_r]&&0===this[gr]&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"));}[yr](t,e){const i=t[e];if(!i||this.preservePaths)return true;const s=i.split("/");if(s.includes("..")||Dr&&/^[a-z]:\.\.$/i.test(s[0]??""))return this.warn("TAR_ENTRY_ERROR",`${e} contains '..'`,{entry:t,[e]:i}),false;const[r,n]=Li(i);return r&&(t[e]=String(n),this.warn("TAR_ENTRY_INFO",`stripping ${r} from absolute ${e}`,{entry:t,[e]:i})),true}[pr](t){const e=Pe(t.path),i=e.split("/");if(this.strip){if(i.length<this.strip)return false;if("Link"===t.type){const e=Pe(String(t.linkpath)).split("/");if(!(e.length>=this.strip))return false;t.linkpath=e.slice(this.strip).join("/");}i.splice(0,this.strip),t.path=i.join("/");}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;if(!this[yr](t,"path")||!this[yr](t,"linkpath"))return false;if(path.isAbsolute(t.path)?t.absolute=Pe(path.resolve(t.path)):t.absolute=Pe(path.resolve(this.cwd,t.path)),!this.preservePaths&&"string"==typeof t.absolute&&0!==t.absolute.indexOf(this.cwd+"/")&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path:Pe(t.path),resolvedPath:t.absolute,cwd:this.cwd}),false;if(t.absolute===this.cwd&&"Directory"!==t.type&&"GNUDumpDir"!==t.type)return false;if(this.win32){const{root:e}=path.win32.parse(String(t.absolute));t.absolute=e+Ni(String(t.absolute).slice(e.length));const{root:i}=path.win32.parse(t.path);t.path=i+Ni(t.path.slice(i.length));}return true}[rr](t){if(!this[pr](t))return t.resume();switch(g.equal(typeof t.absolute,"string"),t.type){case "Directory":case "GNUDumpDir":t.mode&&(t.mode=448|t.mode);case "File":case "OldFile":case "ContiguousFile":case "Link":case "SymbolicLink":return this[nr](t);default:return this[fr](t)}}[wr](t,e){"CwdError"===t.name?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[Rr](),e.resume());}[br](t,e,i){Ks(Pe(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);}[Or](t){return this.forceChown||this.preserveOwner&&("number"==typeof t.uid&&t.uid!==this.processUid||"number"==typeof t.gid&&t.gid!==this.processGid)||"number"==typeof this.uid&&this.uid!==this.processUid||"number"==typeof this.gid&&this.gid!==this.processGid}[Tr](t){return Ar(this.uid,t.uid,this.processUid)}[kr](t){return Ar(this.gid,t.gid,this.processGid)}[lr](t,e){const i="number"==typeof t.mode?4095&t.mode:this.fmode,s=new zt(String(t.absolute),{flags:js(t.size),mode:i,autoClose:false});s.on("error",i=>{s.fd&&c.close(s.fd,()=>{}),s.write=()=>true,this[wr](i,t),e();});let r=1;const n=i=>{if(i)return s.fd&&c.close(s.fd,()=>{}),this[wr](i,t),void e();0===--r&&void 0!==s.fd&&c.close(s.fd,i=>{i?this[wr](i,t):this[Rr](),e();});};s.on("finish",()=>{const e=String(t.absolute),i=s.fd;if("number"==typeof i&&t.mtime&&!this.noMtime){r++;const s=t.atime||new Date,h=t.mtime;c.futimes(i,s,h,t=>t?c.utimes(e,s,h,e=>n(e&&t)):n());}if("number"==typeof i&&this[Or](t)){r++;const s=this[Tr](t),h=this[kr](t);"number"==typeof s&&"number"==typeof h&&c.fchown(i,s,h,t=>t?c.chown(e,s,h,e=>n(e&&t)):n());}n();});const h=this.transform&&this.transform(t)||t;h!==t&&(h.on("error",i=>{this[wr](i,t),e();}),t.pipe(h)),h.pipe(s);}[dr](t,e){const i="number"==typeof t.mode?4095&t.mode:this.dmode;this[br](String(t.absolute),i,i=>{if(i)return this[wr](i,t),void e();let s=1;const r=()=>{0===--s&&(e(),this[Rr](),t.resume());};t.mtime&&!this.noMtime&&(s++,c.utimes(String(t.absolute),t.atime||new Date,t.mtime,r)),this[Or](t)&&(s++,c.chown(String(t.absolute),Number(this[Tr](t)),Number(this[kr](t)),r)),r();});}[fr](t){t.unsupported=true,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume();}[ur](t,e){this[cr](t,String(t.linkpath),"symlink",e);}[mr](t,e){const i=Pe(path.resolve(this.cwd,String(t.linkpath)));this[cr](t,i,"link",e);}[Er](){this[gr]++;}[Rr](){this[gr]--,this[Sr]();}[vr](t){this[Rr](),t.resume();}[or](t,e){return "File"===t.type&&!this.unlink&&e.isFile()&&e.nlink<=1&&!Dr}[nr](t){this[Er]();const e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,e=>this[hr](t,e));}[hr](t,e){const i=t=>{e(t);},s=()=>{this[br](this.cwd,this.dmode,e=>{if(e)return this[wr](e,t),void i();this[Lr]=true,r();});},r=()=>{if(t.absolute!==this.cwd){const e=Pe(path.dirname(String(t.absolute)));if(e!==this.cwd)return this[br](e,this.dmode,e=>{if(e)return this[wr](e,t),void i();n();})}n();},n=()=>{c.lstat(String(t.absolute),(e,s)=>{if(s&&(this.keep||this.newer&&s.mtime>(t.mtime??s.mtime)))return this[vr](t),void i();if(e||this[or](t,s))return this[ar](null,t,i);if(s.isDirectory()){if("Directory"===t.type){const e=e=>this[ar](e??null,t,i);return this.chmod&&t.mode&&(4095&s.mode)!==t.mode?c.chmod(String(t.absolute),Number(t.mode),e):e()}if(t.absolute!==this.cwd)return c.rmdir(String(t.absolute),e=>this[ar](e??null,t,i))}if(t.absolute===this.cwd)return this[ar](null,t,i);((t,e)=>{if(!Dr)return c.unlink(t,e);const i=t+".DELETE."+randomBytes(16).toString("hex");c.rename(t,i,t=>{if(t)return e(t);c.unlink(i,e);});})(String(t.absolute),e=>this[ar](e??null,t,i));});};this[Lr]?r():s();}[ar](t,e,i){if(t)return this[wr](t,e),void i();switch(e.type){case "File":case "OldFile":case "ContiguousFile":return this[lr](e,i);case "Link":return this[mr](e,i);case "SymbolicLink":return this[ur](e,i);case "Directory":case "GNUDumpDir":return this[dr](e,i)}}[cr](t,e,i,s){c[i](e,String(t.absolute),e=>{e?this[wr](e,t):(this[Rr](),t.resume()),s();});}}const Ir=t=>{try{return [null,t()]}catch(t){return [t,null]}};class Nr extends xr{sync=true;[ar](t,e){return super[ar](t,e,()=>{})}[nr](t){if(!this[Lr]){const e=this[br](this.cwd,this.dmode);if(e)return this[wr](e,t);this[Lr]=true;}if(t.absolute!==this.cwd){const e=Pe(path.dirname(String(t.absolute)));if(e!==this.cwd){const i=this[br](e,this.dmode);if(i)return this[wr](i,t)}}const[e,i]=Ir(()=>c.lstatSync(String(t.absolute)));if(i&&(this.keep||this.newer&&i.mtime>(t.mtime??i.mtime)))return this[vr](t);if(e||this[or](t,i))return this[ar](null,t);if(i.isDirectory()){if("Directory"===t.type){const e=this.chmod&&t.mode&&(4095&i.mode)!==t.mode,[s]=e?Ir(()=>{c.chmodSync(String(t.absolute),Number(t.mode));}):[];return this[ar](s,t)}const[e]=Ir(()=>c.rmdirSync(String(t.absolute)));this[ar](e,t);}const[s]=t.absolute===this.cwd?[]:Ir(()=>(t=>{if(!Dr)return c.unlinkSync(t);const e=t+".DELETE."+randomBytes(16).toString("hex");c.renameSync(t,e),c.unlinkSync(e);})(String(t.absolute)));this[ar](s,t);}[lr](t,e){const i="number"==typeof t.mode?4095&t.mode:this.fmode,s=i=>{let s;try{c.closeSync(r);}catch(t){s=t;}(i||s)&&this[wr](i||s,t),e();};let r;try{r=c.openSync(String(t.absolute),js(t.size),i);}catch(t){return s(t)}const n=this.transform&&this.transform(t)||t;n!==t&&(n.on("error",e=>this[wr](e,t)),t.pipe(n)),n.on("data",t=>{try{c.writeSync(r,t,0,t.length);}catch(t){s(t);}}),n.on("end",()=>{let e=null;if(t.mtime&&!this.noMtime){const i=t.atime||new Date,s=t.mtime;try{c.futimesSync(r,i,s);}catch(r){try{c.utimesSync(String(t.absolute),i,s);}catch(t){e=r;}}}if(this[Or](t)){const i=this[Tr](t),s=this[kr](t);try{c.fchownSync(r,Number(i),Number(s));}catch(r){try{c.chownSync(String(t.absolute),Number(i),Number(s));}catch(t){e=e||r;}}}s(e);});}[dr](t,e){const i="number"==typeof t.mode?4095&t.mode:this.dmode,s=this[br](String(t.absolute),i);if(s)return this[wr](s,t),void e();if(t.mtime&&!this.noMtime)try{c.utimesSync(String(t.absolute),t.atime||new Date,t.mtime);}catch(s){}if(this[Or](t))try{c.chownSync(String(t.absolute),Number(this[Tr](t)),Number(this[kr](t)));}catch(s){}e(),t.resume();}[br](t,e){try{return Js(Pe(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})}catch(t){return t}}[cr](t,e,i,s){const r=`${i}Sync`;try{c[r](e,String(t.absolute)),s(),t.resume();}catch(e){return this[wr](e,t)}}}Gt(t=>{const e=new Nr(t),i=t.file,s=c.statSync(i),r=t.maxReadSize||16777216;new Pt(i,{readSize:r,size:s.size}).pipe(e);},(t,e)=>{const i=new xr(t),s=t.maxReadSize||16777216,r=t.file;return new Promise((t,e)=>{i.on("error",e),i.on("close",t),c.stat(r,(t,n)=>{if(t)e(t);else {const t=new Ct(r,{readSize:s,size:n.size});t.on("error",e),t.pipe(i);}});})},t=>new Nr(t),t=>new xr(t),(t,e)=>{e?.length&&Si(t,e);});const Fr=(t,e,i,s,r)=>{const n=new Ut(t.file,{fd:s,start:i});e.pipe(n),Br(e,r);},Br=(t,e)=>{e.forEach(e=>{"@"===e.charAt(0)?vi({file:path.resolve(t.cwd,e.slice(1)),sync:true,noResume:true,onReadEntry:e=>t.add(e)}):t.add(e);}),t.end();},Mr=async(t,e)=>{for(let i=0;i<e.length;i++){const s=String(e[i]);"@"===s.charAt(0)?await vi({file:path.resolve(String(t.cwd),s.slice(1)),noResume:true,onReadEntry:e=>t.add(e)}):t.add(s);}t.end();},Cr=Gt((t,e)=>{const i=new xs(t);let s,r,n=true;try{try{s=c.openSync(t.file,"r+");}catch(e){if("ENOENT"!==e?.code)throw e;s=c.openSync(t.file,"w+");}const h=c.fstatSync(s),o=Buffer.alloc(512);t:for(r=0;r<h.size;r+=512){for(let t=0,e=0;t<512;t+=e){if(e=c.readSync(s,o,t,o.length-t,r+t),0===r&&31===o[0]&&139===o[1])throw new Error("cannot append to compressed archives");if(!e)break t}const e=new ge(o);if(!e.cksumValid)break;const i=512*Math.ceil((e.size||0)/512);if(r+i+512>h.size)break;r+=i,t.mtimeCache&&e.mtime&&t.mtimeCache.set(String(e.path),e.mtime);}n=!1,Fr(t,i,r,s,e);}finally{if(n)try{c.closeSync(s);}catch(t){}}},(t,e)=>{e=Array.from(e);const i=new As(t),s=new Promise((s,r)=>{i.on("error",r);let n="r+";const h=(o,a)=>o&&"ENOENT"===o.code&&"r+"===n?(n="w+",c.open(t.file,n,h)):o||!a?r(o):void c.fstat(a,(n,h)=>{if(n)return c.close(a,()=>r(n));((e,i,s)=>{const r=(t,i)=>{t?c.close(e,e=>s(t)):s(null,i);};let n=0;if(0===i)return r(null,0);let h=0;const o=Buffer.alloc(512),a=(s,l)=>{if(s||void 0===l)return r(s);if(h+=l,h<512&&l)return c.read(e,o,h,o.length-h,n+h,a);if(0===n&&31===o[0]&&139===o[1])return r(new Error("cannot append to compressed archives"));if(h<512)return r(null,n);const d=new ge(o);if(!d.cksumValid)return r(null,n);const u=512*Math.ceil((d.size??0)/512);return n+u+512>i?r(null,n):(n+=u+512,n>=i?r(null,n):(t.mtimeCache&&d.mtime&&t.mtimeCache.set(String(d.path),d.mtime),h=0,void c.read(e,o,0,512,n,a)))};c.read(e,o,0,512,n,a);})(a,h.size,(n,h)=>{if(n)return r(n);const o=new zt(t.file,{fd:a,start:h});i.pipe(o),o.on("error",r),o.on("close",s),Mr(i,e);});});c.open(t.file,n,h);});return s},()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!t.file)throw new TypeError("file is required");if(t.gzip||t.brotli||t.zstd||t.file.endsWith(".br")||t.file.endsWith(".tbr"))throw new TypeError("cannot append to compressed archives");if(!e?.length)throw new TypeError("no paths specified to add/replace")});Gt(Cr.syncFile,Cr.asyncFile,Cr.syncNoFile,Cr.asyncNoFile,(t,e=[])=>{Cr.validate?.(t,e),Pr(t);});const Pr=t=>{const e=t.filter;t.mtimeCache||(t.mtimeCache=new Map),t.filter=e?(i,s)=>e(i,s)&&!((t.mtimeCache?.get(i)??s.mtime??0)>(s.mtime??0)):(e,i)=>!((t.mtimeCache?.get(e)??i.mtime??0)>(i.mtime??0));};
|
|
19
|
+
|
|
20
|
+
export { ge as Header, As as Pack, as as PackJob, xs as PackSync, Ri as Parser, Fe as Pax, ze as ReadEntry, xr as Unpack, Nr as UnpackSync, Ji as WriteEntry, ts as WriteEntrySync, es as WriteEntryTar, Fs as c, Fs as create, Si as filesFilter, vi as list, Cr as r, Cr as replace, vi as t };
|