nuxi
Version:
Nuxt CLI
1,356 lines • 104 kB
JavaScript
import { t as __exportAll } from "./rolldown-runtime-B3UnZhx8.mjs";
import { randomBytes } from "node:crypto";
import path, { basename, join, posix, win32 } from "node:path";
import fs from "node:fs";
import { EventEmitter as EventEmitter$1 } from "node:events";
import n from "node:fs/promises";
import assert from "node:assert";
import r from "node:stream";
import d from "fs";
import p, { dirname as dirname$1, parse } from "path";
import l, { EventEmitter as EventEmitter$2 } from "events";
import { StringDecoder } from "node:string_decoder";
import ne from "assert";
import { Buffer as Buffer$1 } from "buffer";
import * as ie from "zlib";
import ae from "zlib";
//#region ../../node_modules/.pnpm/giget@3.2.0/node_modules/giget/dist/_chunks/libs/tar.mjs
var ce = __exportAll({
Header: () => I,
Pack: () => ni,
PackJob: () => Ir,
PackSync: () => ri,
Parser: () => Jn,
Pax: () => hn,
ReadEntry: () => yn,
Unpack: () => _a,
UnpackSync: () => ya,
WriteEntry: () => Dr,
WriteEntrySync: () => Or,
WriteEntryTar: () => kr,
c: () => ci,
create: () => ci,
extract: () => ba,
filesFilter: () => Zn,
list: () => Qn,
r: () => Ea,
replace: () => Ea,
t: () => Qn,
types: () => Xt,
x: () => ba
}), le = Object.defineProperty, ue = (e, t) => {
for (var n in t) le(e, n, {
get: t[n],
enumerable: !0
});
}, de = typeof process == `object` && process ? process : {
stdout: null,
stderr: null
}, fe = (e) => !!e && typeof e == `object` && (e instanceof Ue || e instanceof r || pe(e) || me(e)), pe = (e) => !!e && typeof e == `object` && e instanceof EventEmitter$1 && typeof e.pipe == `function` && e.pipe !== r.Writable.prototype.pipe, me = (e) => !!e && typeof e == `object` && e instanceof EventEmitter$1 && typeof e.write == `function` && typeof e.end == `function`, h = Symbol(`EOF`), g = Symbol(`maybeEmitEnd`), _ = Symbol(`emittedEnd`), he = Symbol(`emittingEnd`), ge = Symbol(`emittedError`), _e = Symbol(`closed`), ve = Symbol(`read`), ye = Symbol(`flush`), be = Symbol(`flushChunk`), v = Symbol(`encoding`), xe = Symbol(`decoder`), y = Symbol(`flowing`), Se = Symbol(`paused`), Ce = Symbol(`resume`), b = Symbol(`buffer`), x = Symbol(`pipes`), S = Symbol(`bufferLength`), we = Symbol(`bufferPush`), Te = Symbol(`bufferShift`), C = Symbol(`objectMode`), w = Symbol(`destroyed`), Ee = Symbol(`error`), De = Symbol(`emitData`), Oe = Symbol(`emitEnd`), ke = Symbol(`emitEnd2`), T = Symbol(`async`), Ae = Symbol(`abort`), je = Symbol(`aborted`), Me = Symbol(`signal`), Ne = Symbol(`dataListeners`), E = Symbol(`discarded`), Pe = (e) => Promise.resolve().then(e), Fe = (e) => e(), Ie = (e) => e === `end` || e === `finish` || e === `prefinish`, Le = (e) => e instanceof ArrayBuffer || !!e && typeof e == `object` && e.constructor && e.constructor.name === `ArrayBuffer` && e.byteLength >= 0, Re = (e) => !Buffer.isBuffer(e) && ArrayBuffer.isView(e), ze = class {
src;
dest;
opts;
ondrain;
constructor(e, t, n) {
this.src = e, this.dest = t, this.opts = n, this.ondrain = () => e[Ce](), this.dest.on(`drain`, this.ondrain);
}
unpipe() {
this.dest.removeListener(`drain`, this.ondrain);
}
proxyErrors(e) {}
end() {
this.unpipe(), this.opts.end && this.dest.end();
}
}, Be = class extends ze {
unpipe() {
this.src.removeListener(`error`, this.proxyErrors), super.unpipe();
}
constructor(e, t, n) {
super(e, t, n), this.proxyErrors = (e) => this.dest.emit(`error`, e), e.on(`error`, this.proxyErrors);
}
}, Ve = (e) => !!e.objectMode, He = (e) => !e.objectMode && !!e.encoding && e.encoding !== `buffer`, Ue = class extends EventEmitter$1 {
[y] = !1;
[Se] = !1;
[x] = [];
[b] = [];
[C];
[v];
[T];
[xe];
[h] = !1;
[_] = !1;
[he] = !1;
[_e] = !1;
[ge] = null;
[S] = 0;
[w] = !1;
[Me];
[je] = !1;
[Ne] = 0;
[E] = !1;
writable = !0;
readable = !0;
constructor(...e) {
let t = e[0] || {};
if (super(), t.objectMode && typeof t.encoding == `string`) throw TypeError(`Encoding and objectMode may not be used together`);
Ve(t) ? (this[C] = !0, this[v] = null) : He(t) ? (this[v] = t.encoding, this[C] = !1) : (this[C] = !1, this[v] = null), this[T] = !!t.async, this[xe] = this[v] ? new StringDecoder(this[v]) : null, t && t.debugExposeBuffer === !0 && Object.defineProperty(this, `buffer`, { get: () => this[b] }), t && t.debugExposePipes === !0 && Object.defineProperty(this, `pipes`, { get: () => this[x] });
let { signal: n } = t;
n && (this[Me] = n, n.aborted ? this[Ae]() : n.addEventListener(`abort`, () => this[Ae]()));
}
get bufferLength() {
return this[S];
}
get encoding() {
return this[v];
}
set encoding(e) {
throw Error(`Encoding must be set at instantiation time`);
}
setEncoding(e) {
throw Error(`Encoding must be set at instantiation time`);
}
get objectMode() {
return this[C];
}
set objectMode(e) {
throw Error(`objectMode must be set at instantiation time`);
}
get async() {
return this[T];
}
set async(e) {
this[T] = this[T] || !!e;
}
[Ae]() {
this[je] = !0, this.emit(`abort`, this[Me]?.reason), this.destroy(this[Me]?.reason);
}
get aborted() {
return this[je];
}
set aborted(e) {}
write(e, t, n) {
if (this[je]) return !1;
if (this[h]) throw Error(`write after end`);
if (this[w]) return this.emit(`error`, Object.assign(Error(`Cannot call write after a stream was destroyed`), { code: `ERR_STREAM_DESTROYED` })), !0;
typeof t == `function` && (n = t, t = `utf8`), t ||= `utf8`;
let r = this[T] ? Pe : Fe;
if (!this[C] && !Buffer.isBuffer(e)) {
if (Re(e)) e = Buffer.from(e.buffer, e.byteOffset, e.byteLength);
else if (Le(e)) e = Buffer.from(e);
else if (typeof e != `string`) throw Error(`Non-contiguous data written to non-objectMode stream`);
}
return this[C] ? (this[y] && this[S] !== 0 && this[ye](!0), this[y] ? this.emit(`data`, e) : this[we](e), this[S] !== 0 && this.emit(`readable`), n && r(n), this[y]) : e.length ? (typeof e == `string` && !(t === this[v] && !this[xe]?.lastNeed) && (e = Buffer.from(e, t)), Buffer.isBuffer(e) && this[v] && (e = this[xe].write(e)), this[y] && this[S] !== 0 && this[ye](!0), this[y] ? this.emit(`data`, e) : this[we](e), this[S] !== 0 && this.emit(`readable`), n && r(n), this[y]) : (this[S] !== 0 && this.emit(`readable`), n && r(n), this[y]);
}
read(e) {
if (this[w]) return null;
if (this[E] = !1, this[S] === 0 || e === 0 || e && e > this[S]) return this[g](), null;
this[C] && (e = null), this[b].length > 1 && !this[C] && (this[b] = [this[v] ? this[b].join(``) : Buffer.concat(this[b], this[S])]);
let t = this[ve](e || null, this[b][0]);
return this[g](), t;
}
[ve](e, t) {
if (this[C]) this[Te]();
else {
let n = t;
e === n.length || e === null ? this[Te]() : typeof n == `string` ? (this[b][0] = n.slice(e), t = n.slice(0, e), this[S] -= e) : (this[b][0] = n.subarray(e), t = n.subarray(0, e), this[S] -= e);
}
return this.emit(`data`, t), !this[b].length && !this[h] && this.emit(`drain`), t;
}
end(e, t, n) {
return typeof e == `function` && (n = e, e = void 0), typeof t == `function` && (n = t, t = `utf8`), e !== void 0 && this.write(e, t), n && this.once(`end`, n), this[h] = !0, this.writable = !1, (this[y] || !this[Se]) && this[g](), this;
}
[Ce]() {
this[w] || (!this[Ne] && !this[x].length && (this[E] = !0), this[Se] = !1, this[y] = !0, this.emit(`resume`), this[b].length ? this[ye]() : this[h] ? this[g]() : this.emit(`drain`));
}
resume() {
return this[Ce]();
}
pause() {
this[y] = !1, this[Se] = !0, this[E] = !1;
}
get destroyed() {
return this[w];
}
get flowing() {
return this[y];
}
get paused() {
return this[Se];
}
[we](e) {
this[C] ? this[S] += 1 : this[S] += e.length, this[b].push(e);
}
[Te]() {
return this[C] ? --this[S] : this[S] -= this[b][0].length, this[b].shift();
}
[ye](e = !1) {
do ;
while (this[be](this[Te]()) && this[b].length);
!e && !this[b].length && !this[h] && this.emit(`drain`);
}
[be](e) {
return this.emit(`data`, e), this[y];
}
pipe(e, t) {
if (this[w]) return e;
this[E] = !1;
let n = this[_];
return t ||= {}, e === de.stdout || e === de.stderr ? t.end = !1 : t.end = t.end !== !1, t.proxyErrors = !!t.proxyErrors, n ? t.end && e.end() : (this[x].push(t.proxyErrors ? new Be(this, e, t) : new ze(this, e, t)), this[T] ? Pe(() => this[Ce]()) : this[Ce]()), e;
}
unpipe(e) {
let t = this[x].find((t) => t.dest === e);
t && (this[x].length === 1 ? (this[y] && this[Ne] === 0 && (this[y] = !1), this[x] = []) : this[x].splice(this[x].indexOf(t), 1), t.unpipe());
}
addListener(e, t) {
return this.on(e, t);
}
on(e, t) {
let n = super.on(e, t);
if (e === `data`) this[E] = !1, this[Ne]++, !this[x].length && !this[y] && this[Ce]();
else if (e === `readable` && this[S] !== 0) super.emit(`readable`);
else if (Ie(e) && this[_]) super.emit(e), this.removeAllListeners(e);
else if (e === `error` && this[ge]) {
let e = t;
this[T] ? Pe(() => e.call(this, this[ge])) : e.call(this, this[ge]);
}
return n;
}
removeListener(e, t) {
return this.off(e, t);
}
off(e, t) {
let n = super.off(e, t);
return e === `data` && (this[Ne] = this.listeners(`data`).length, this[Ne] === 0 && !this[E] && !this[x].length && (this[y] = !1)), n;
}
removeAllListeners(e) {
let t = super.removeAllListeners(e);
return (e === `data` || e === void 0) && (this[Ne] = 0, !this[E] && !this[x].length && (this[y] = !1)), t;
}
get emittedEnd() {
return this[_];
}
[g]() {
!this[he] && !this[_] && !this[w] && this[b].length === 0 && this[h] && (this[he] = !0, this.emit(`end`), this.emit(`prefinish`), this.emit(`finish`), this[_e] && this.emit(`close`), this[he] = !1);
}
emit(e, ...t) {
let n = t[0];
if (e !== `error` && e !== `close` && e !== w && this[w]) return !1;
if (e === `data`) return !this[C] && !n ? !1 : this[T] ? (Pe(() => this[De](n)), !0) : this[De](n);
if (e === `end`) return this[Oe]();
if (e === `close`) {
if (this[_e] = !0, !this[_] && !this[w]) return !1;
let e = super.emit(`close`);
return this.removeAllListeners(`close`), e;
} else if (e === `error`) {
this[ge] = n, super.emit(Ee, n);
let e = !this[Me] || this.listeners(`error`).length ? super.emit(`error`, n) : !1;
return this[g](), e;
} else if (e === `resume`) {
let e = super.emit(`resume`);
return this[g](), e;
} else if (e === `finish` || e === `prefinish`) {
let t = super.emit(e);
return this.removeAllListeners(e), t;
}
let r = super.emit(e, ...t);
return this[g](), r;
}
[De](e) {
for (let t of this[x]) t.dest.write(e) === !1 && this.pause();
let t = this[E] ? !1 : super.emit(`data`, e);
return this[g](), t;
}
[Oe]() {
return this[_] ? !1 : (this[_] = !0, this.readable = !1, this[T] ? (Pe(() => this[ke]()), !0) : this[ke]());
}
[ke]() {
if (this[xe]) {
let e = this[xe].end();
if (e) {
for (let t of this[x]) t.dest.write(e);
this[E] || super.emit(`data`, e);
}
}
for (let e of this[x]) e.end();
let e = super.emit(`end`);
return this.removeAllListeners(`end`), e;
}
async collect() {
let e = Object.assign([], { dataLength: 0 });
this[C] || (e.dataLength = 0);
let t = this.promise();
return this.on(`data`, (t) => {
e.push(t), this[C] || (e.dataLength += t.length);
}), await t, e;
}
async concat() {
if (this[C]) throw Error(`cannot concat in objectMode`);
let e = await this.collect();
return this[v] ? e.join(``) : Buffer.concat(e, e.dataLength);
}
async promise() {
return new Promise((e, t) => {
this.on(w, () => t(Error(`stream destroyed`))), this.on(`error`, (e) => t(e)), this.on(`end`, () => e());
});
}
[Symbol.asyncIterator]() {
this[E] = !1;
let e = !1, t = async () => (this.pause(), e = !0, {
value: void 0,
done: !0
});
return {
next: () => {
if (e) return t();
let n = this.read();
if (n !== null) return Promise.resolve({
done: !1,
value: n
});
if (this[h]) return t();
let r, i, a = (e) => {
this.off(`data`, o), this.off(`end`, s), this.off(w, c), t(), i(e);
}, o = (e) => {
this.off(`error`, a), this.off(`end`, s), this.off(w, c), this.pause(), r({
value: e,
done: !!this[h]
});
}, s = () => {
this.off(`error`, a), this.off(`data`, o), this.off(w, c), t(), r({
done: !0,
value: void 0
});
}, c = () => a(Error(`stream destroyed`));
return new Promise((e, t) => {
i = t, r = e, this.once(w, c), this.once(`error`, a), this.once(`end`, s), this.once(`data`, o);
});
},
throw: t,
return: t,
[Symbol.asyncIterator]() {
return this;
},
[Symbol.asyncDispose]: async () => {}
};
}
[Symbol.iterator]() {
this[E] = !1;
let e = !1, t = () => (this.pause(), this.off(Ee, t), this.off(w, t), this.off(`end`, t), e = !0, {
done: !0,
value: void 0
});
return this.once(`end`, t), this.once(Ee, t), this.once(w, t), {
next: () => {
if (e) return t();
let n = this.read();
return n === null ? t() : {
done: !1,
value: n
};
},
throw: t,
return: t,
[Symbol.iterator]() {
return this;
},
[Symbol.dispose]: () => {}
};
}
destroy(e) {
if (this[w]) return e ? this.emit(`error`, e) : this.emit(w), this;
this[w] = !0, this[E] = !0, this[b].length = 0, this[S] = 0;
let t = this;
return typeof t.close == `function` && !this[_e] && t.close(), e ? this.emit(`error`, e) : this.emit(w), this;
}
static get isStream() {
return fe;
}
}, We = d.writev, D = Symbol(`_autoClose`), O = Symbol(`_close`), Ge = Symbol(`_ended`), k = Symbol(`_fd`), Ke = Symbol(`_finished`), A = Symbol(`_flags`), qe = Symbol(`_flush`), Je = Symbol(`_handleChunk`), Ye = Symbol(`_makeBuf`), Xe = Symbol(`_mode`), Ze = Symbol(`_needDrain`), Qe = Symbol(`_onerror`), $e = Symbol(`_onopen`), et = Symbol(`_onread`), tt = Symbol(`_onwrite`), j = Symbol(`_open`), M = Symbol(`_path`), nt = Symbol(`_pos`), N = Symbol(`_queue`), rt = Symbol(`_read`), it = Symbol(`_readSize`), P = Symbol(`_reading`), at = Symbol(`_remain`), ot = Symbol(`_size`), st = Symbol(`_write`), ct = Symbol(`_writing`), lt = Symbol(`_defaultFlag`), ut = Symbol(`_errored`), dt = class extends Ue {
[ut] = !1;
[k];
[M];
[it];
[P] = !1;
[ot];
[at];
[D];
constructor(e, t) {
if (t ||= {}, super(t), this.readable = !0, this.writable = !1, typeof e != `string`) throw TypeError(`path must be a string`);
this[ut] = !1, this[k] = typeof t.fd == `number` ? t.fd : void 0, this[M] = e, this[it] = t.readSize || 16 * 1024 * 1024, this[P] = !1, this[ot] = typeof t.size == `number` ? t.size : Infinity, this[at] = this[ot], this[D] = typeof t.autoClose == `boolean` ? t.autoClose : !0, typeof this[k] == `number` ? this[rt]() : this[j]();
}
get fd() {
return this[k];
}
get path() {
return this[M];
}
write() {
throw TypeError(`this is a readable stream`);
}
end() {
throw TypeError(`this is a readable stream`);
}
[j]() {
d.open(this[M], `r`, (e, t) => this[$e](e, t));
}
[$e](e, t) {
e ? this[Qe](e) : (this[k] = t, this.emit(`open`, t), this[rt]());
}
[Ye]() {
return Buffer.allocUnsafe(Math.min(this[it], this[at]));
}
[rt]() {
if (!this[P]) {
this[P] = !0;
let e = this[Ye]();
if (e.length === 0) return process.nextTick(() => this[et](null, 0, e));
d.read(this[k], e, 0, e.length, null, (e, t, n) => this[et](e, t, n));
}
}
[et](e, t, n) {
this[P] = !1, e ? this[Qe](e) : this[Je](t, n) && this[rt]();
}
[O]() {
if (this[D] && typeof this[k] == `number`) {
let e = this[k];
this[k] = void 0, d.close(e, (e) => e ? this.emit(`error`, e) : this.emit(`close`));
}
}
[Qe](e) {
this[P] = !0, this[O](), this.emit(`error`, e);
}
[Je](e, t) {
let n = !1;
return this[at] -= e, e > 0 && (n = super.write(e < t.length ? t.subarray(0, e) : t)), (e === 0 || this[at] <= 0) && (n = !1, this[O](), super.end()), n;
}
emit(e, ...t) {
switch (e) {
case `prefinish`:
case `finish`: return !1;
case `drain`: return typeof this[k] == `number` && this[rt](), !1;
case `error`: return this[ut] ? !1 : (this[ut] = !0, super.emit(e, ...t));
default: return super.emit(e, ...t);
}
}
}, ft = class extends dt {
[j]() {
let e = !0;
try {
this[$e](null, d.openSync(this[M], `r`)), e = !1;
} finally {
e && this[O]();
}
}
[rt]() {
let e = !0;
try {
if (!this[P]) {
this[P] = !0;
do {
let e = this[Ye](), t = e.length === 0 ? 0 : d.readSync(this[k], e, 0, e.length, null);
if (!this[Je](t, e)) break;
} while (!0);
this[P] = !1;
}
e = !1;
} finally {
e && this[O]();
}
}
[O]() {
if (this[D] && typeof this[k] == `number`) {
let e = this[k];
this[k] = void 0, d.closeSync(e), this.emit(`close`);
}
}
}, pt = class extends l {
readable = !1;
writable = !0;
[ut] = !1;
[ct] = !1;
[Ge] = !1;
[N] = [];
[Ze] = !1;
[M];
[Xe];
[D];
[k];
[lt];
[A];
[Ke] = !1;
[nt];
constructor(e, t) {
t ||= {}, super(t), this[M] = e, this[k] = typeof t.fd == `number` ? t.fd : void 0, this[Xe] = t.mode === void 0 ? 438 : t.mode, this[nt] = typeof t.start == `number` ? t.start : void 0, this[D] = typeof t.autoClose == `boolean` ? t.autoClose : !0;
let n = this[nt] === void 0 ? `w` : `r+`;
this[lt] = t.flags === void 0, this[A] = t.flags === void 0 ? n : t.flags, this[k] === void 0 && this[j]();
}
emit(e, ...t) {
if (e === `error`) {
if (this[ut]) return !1;
this[ut] = !0;
}
return super.emit(e, ...t);
}
get fd() {
return this[k];
}
get path() {
return this[M];
}
[Qe](e) {
this[O](), this[ct] = !0, this.emit(`error`, e);
}
[j]() {
d.open(this[M], this[A], this[Xe], (e, t) => this[$e](e, t));
}
[$e](e, t) {
this[lt] && this[A] === `r+` && e && e.code === `ENOENT` ? (this[A] = `w`, this[j]()) : e ? this[Qe](e) : (this[k] = t, this.emit(`open`, t), this[ct] || this[qe]());
}
end(e, t) {
return e && this.write(e, t), this[Ge] = !0, !this[ct] && !this[N].length && typeof this[k] == `number` && this[tt](null, 0), this;
}
write(e, t) {
return typeof e == `string` && (e = Buffer.from(e, t)), this[Ge] ? (this.emit(`error`, Error(`write() after end()`)), !1) : this[k] === void 0 || this[ct] || this[N].length ? (this[N].push(e), this[Ze] = !0, !1) : (this[ct] = !0, this[st](e), !0);
}
[st](e) {
d.write(this[k], e, 0, e.length, this[nt], (e, t) => this[tt](e, t));
}
[tt](e, t) {
e ? this[Qe](e) : (this[nt] !== void 0 && typeof t == `number` && (this[nt] += t), this[N].length ? this[qe]() : (this[ct] = !1, this[Ge] && !this[Ke] ? (this[Ke] = !0, this[O](), this.emit(`finish`)) : this[Ze] && (this[Ze] = !1, this.emit(`drain`))));
}
[qe]() {
if (this[N].length === 0) this[Ge] && this[tt](null, 0);
else if (this[N].length === 1) this[st](this[N].pop());
else {
let e = this[N];
this[N] = [], We(this[k], e, this[nt], (e, t) => this[tt](e, t));
}
}
[O]() {
if (this[D] && typeof this[k] == `number`) {
let e = this[k];
this[k] = void 0, d.close(e, (e) => e ? this.emit(`error`, e) : this.emit(`close`));
}
}
}, mt = class extends pt {
[j]() {
let e;
if (this[lt] && this[A] === `r+`) try {
e = d.openSync(this[M], this[A], this[Xe]);
} catch (e) {
if (e?.code === `ENOENT`) return this[A] = `w`, this[j]();
throw e;
}
else e = d.openSync(this[M], this[A], this[Xe]);
this[$e](null, e);
}
[O]() {
if (this[D] && typeof this[k] == `number`) {
let e = this[k];
this[k] = void 0, d.closeSync(e), this.emit(`close`);
}
}
[st](e) {
let t = !0;
try {
this[tt](null, d.writeSync(this[k], e, 0, e.length, this[nt])), t = !1;
} finally {
if (t) try {
this[O]();
} catch {}
}
}
}, ht = 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`]
]), gt = (e) => !!e.sync && !!e.file, _t = (e) => !e.sync && !!e.file, vt = (e) => !!e.sync && !e.file, yt = (e) => !e.sync && !e.file, bt = (e) => !!e.file, xt = (e) => ht.get(e) || e, St = (e = {}) => {
if (!e) return {};
let t = {};
for (let [n, r] of Object.entries(e)) {
let e = xt(n);
t[e] = r;
}
return t.chmod === void 0 && t.noChmod === !1 && (t.chmod = !0), delete t.noChmod, t;
}, Ct = (e, t, n, r, i) => Object.assign((a = [], o, s) => {
Array.isArray(a) && (o = a, a = {}), typeof o == `function` && (s = o, o = void 0), o = o ? Array.from(o) : [];
let c = St(a);
if (i?.(c, o), gt(c)) {
if (typeof s == `function`) throw TypeError(`callback not supported for sync tar functions`);
return e(c, o);
} else if (_t(c)) {
let e = t(c, o);
return s ? e.then(() => s(), s) : e;
} else if (vt(c)) {
if (typeof s == `function`) throw TypeError(`callback not supported for sync tar functions`);
return n(c, o);
} else if (yt(c)) {
if (typeof s == `function`) throw TypeError(`callback only supported with file option`);
return r(c, o);
}
throw Error(`impossible options??`);
}, {
syncFile: e,
asyncFile: t,
syncNoFile: n,
asyncNoFile: r,
validate: i
}), wt = ae.constants || { ZLIB_VERNUM: 4736 }, F = 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: Infinity,
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)), Tt = Buffer$1.concat, Et = Object.getOwnPropertyDescriptor(Buffer$1, `concat`), Dt = (e) => e, Ot = Et?.writable === !0 || Et?.set !== void 0 ? (e) => {
Buffer$1.concat = e ? Dt : Tt;
} : (e) => {}, kt = Symbol(`_superWrite`), At = class extends Error {
code;
errno;
constructor(e, t) {
super(`zlib: ` + e.message, { cause: e }), this.code = e.code, this.errno = e.errno, this.code ||= `ZLIB_ERROR`, this.message = `zlib: ` + e.message, Error.captureStackTrace(this, t ?? this.constructor);
}
get name() {
return `ZlibError`;
}
}, jt = Symbol(`flushFlag`), Mt = class extends Ue {
#t = !1;
#i = !1;
#s;
#n;
#r;
#e;
#o;
get sawError() {
return this.#t;
}
get handle() {
return this.#e;
}
get flushFlag() {
return this.#s;
}
constructor(e, t) {
if (!e || typeof e != `object`) throw TypeError(`invalid options for ZlibBase constructor`);
if (super(e), this.#s = e.flush ?? 0, this.#n = e.finishFlush ?? 0, this.#r = e.fullFlushFlag ?? 0, typeof ie[t] != `function`) throw TypeError(`Compression method not supported: ` + t);
try {
this.#e = new ie[t](e);
} catch (e) {
throw new At(e, this.constructor);
}
this.#o = (e) => {
this.#t || (this.#t = !0, this.close(), this.emit(`error`, e));
}, this.#e?.on(`error`, (e) => this.#o(new At(e))), this.once(`end`, () => this.close);
}
close() {
this.#e && (this.#e.close(), this.#e = void 0, this.emit(`close`));
}
reset() {
if (!this.#t) return ne(this.#e, `zlib binding closed`), this.#e.reset?.();
}
flush(e) {
this.ended || (typeof e != `number` && (e = this.#r), this.write(Object.assign(Buffer$1.alloc(0), { [jt]: e })));
}
end(e, t, n) {
return typeof e == `function` && (n = e, t = void 0, e = void 0), typeof t == `function` && (n = t, t = void 0), e && (t ? this.write(e, t) : this.write(e)), this.flush(this.#n), this.#i = !0, super.end(n);
}
get ended() {
return this.#i;
}
[kt](e) {
return super.write(e);
}
write(e, t, n) {
if (typeof t == `function` && (n = t, t = `utf8`), typeof e == `string` && (e = Buffer$1.from(e, t)), this.#t) return;
ne(this.#e, `zlib binding closed`);
let r = this.#e._handle, i = r.close;
r.close = () => {};
let a = this.#e.close;
this.#e.close = () => {}, Ot(!0);
let o;
try {
let t = typeof e[jt] == `number` ? e[jt] : this.#s;
o = this.#e._processChunk(e, t), Ot(!1);
} catch (e) {
Ot(!1), this.#o(new At(e, this.write));
} finally {
this.#e && (this.#e._handle = r, r.close = i, this.#e.close = a, this.#e.removeAllListeners(`error`));
}
this.#e && this.#e.on(`error`, (e) => this.#o(new At(e, this.write)));
let s;
if (o) if (Array.isArray(o) && o.length > 0) {
let e = o[0];
s = this[kt](Buffer$1.from(e));
for (let e = 1; e < o.length; e++) s = this[kt](o[e]);
} else s = this[kt](Buffer$1.from(o));
return n && n(), s;
}
}, Nt = class extends Mt {
#t;
#i;
constructor(e, t) {
e ||= {}, e.flush = e.flush || F.Z_NO_FLUSH, e.finishFlush = e.finishFlush || F.Z_FINISH, e.fullFlushFlag = F.Z_FULL_FLUSH, super(e, t), this.#t = e.level, this.#i = e.strategy;
}
params(e, t) {
if (!this.sawError) {
if (!this.handle) throw Error(`cannot switch params when binding is closed`);
if (!this.handle.params) throw Error(`not supported in this implementation`);
if (this.#t !== e || this.#i !== t) {
this.flush(F.Z_SYNC_FLUSH), ne(this.handle, `zlib binding closed`);
let n = this.handle.flush;
this.handle.flush = (e, t) => {
typeof e == `function` && (t = e, e = this.flushFlag), this.flush(e), t?.();
};
try {
this.handle.params(e, t);
} finally {
this.handle.flush = n;
}
this.handle && (this.#t = e, this.#i = t);
}
}
}
}, Pt = class extends Nt {
#t;
constructor(e) {
super(e, `Gzip`), this.#t = e && !!e.portable;
}
[kt](e) {
return this.#t ? (this.#t = !1, e[9] = 255, super[kt](e)) : super[kt](e);
}
}, Ft = class extends Nt {
constructor(e) {
super(e, `Unzip`);
}
}, It = class extends Mt {
constructor(e, t) {
e ||= {}, e.flush = e.flush || F.BROTLI_OPERATION_PROCESS, e.finishFlush = e.finishFlush || F.BROTLI_OPERATION_FINISH, e.fullFlushFlag = F.BROTLI_OPERATION_FLUSH, super(e, t);
}
}, Lt = class extends It {
constructor(e) {
super(e, `BrotliCompress`);
}
}, Rt = class extends It {
constructor(e) {
super(e, `BrotliDecompress`);
}
}, zt = class extends Mt {
constructor(e, t) {
e ||= {}, e.flush = e.flush || F.ZSTD_e_continue, e.finishFlush = e.finishFlush || F.ZSTD_e_end, e.fullFlushFlag = F.ZSTD_e_flush, super(e, t);
}
}, Bt = class extends zt {
constructor(e) {
super(e, `ZstdCompress`);
}
}, Vt = class extends zt {
constructor(e) {
super(e, `ZstdDecompress`);
}
}, Ht = (e, t) => {
if (Number.isSafeInteger(e)) e < 0 ? Wt(e, t) : Ut(e, t);
else throw Error(`cannot encode number outside of javascript safe integer range`);
return t;
}, Ut = (e, t) => {
t[0] = 128;
for (var n = t.length; n > 1; n--) t[n - 1] = e & 255, e = Math.floor(e / 256);
}, Wt = (e, t) => {
t[0] = 255;
var n = !1;
e *= -1;
for (var r = t.length; r > 1; r--) {
var i = e & 255;
e = Math.floor(e / 256), n ? t[r - 1] = Jt(i) : i === 0 ? t[r - 1] = 0 : (n = !0, t[r - 1] = Yt(i));
}
}, Gt = (e) => {
let t = e[0], n = t === 128 ? qt(e.subarray(1, e.length)) : t === 255 ? Kt(e) : null;
if (n === null) throw Error(`invalid base256 encoding`);
if (!Number.isSafeInteger(n)) throw Error(`parsed number outside of javascript safe integer range`);
return n;
}, Kt = (e) => {
for (var t = e.length, n = 0, r = !1, i = t - 1; i > -1; i--) {
var a = Number(e[i]), o;
r ? o = Jt(a) : a === 0 ? o = a : (r = !0, o = Yt(a)), o !== 0 && (n -= o * 256 ** (t - i - 1));
}
return n;
}, qt = (e) => {
for (var t = e.length, n = 0, r = t - 1; r > -1; r--) {
var i = Number(e[r]);
i !== 0 && (n += i * 256 ** (t - r - 1));
}
return n;
}, Jt = (e) => (255 ^ e) & 255, Yt = (e) => (255 ^ e) + 1 & 255, Xt = {};
ue(Xt, {
code: () => en,
isCode: () => Zt,
isName: () => Qt,
name: () => $t
});
var Zt = (e) => $t.has(e), Qt = (e) => en.has(e), $t = 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`]
]), en = new Map(Array.from($t).map((e) => [e[1], e[0]])), I = class {
cksumValid = !1;
needPax = !1;
nullBlock = !1;
block;
path;
mode;
uid;
gid;
size;
cksum;
#t = `Unsupported`;
linkpath;
uname;
gname;
devmaj = 0;
devmin = 0;
atime;
ctime;
mtime;
charset;
comment;
constructor(e, t = 0, n, r) {
Buffer.isBuffer(e) ? this.decode(e, t || 0, n, r) : e && this.#i(e);
}
decode(e, t, n, r) {
if (t ||= 0, !e || !(e.length >= t + 512)) throw Error(`need 512 bytes for header`);
this.path = n?.path ?? nn(e, t, 100), this.mode = n?.mode ?? r?.mode ?? L(e, t + 100, 8), this.uid = n?.uid ?? r?.uid ?? L(e, t + 108, 8), this.gid = n?.gid ?? r?.gid ?? L(e, t + 116, 8), this.size = n?.size ?? r?.size ?? L(e, t + 124, 12), this.mtime = n?.mtime ?? r?.mtime ?? rn(e, t + 136, 12), this.cksum = L(e, t + 148, 12), r && this.#i(r, !0), n && this.#i(n);
let i = nn(e, t + 156, 1);
if (Zt(i) && (this.#t = i || `0`), this.#t === `0` && this.path.slice(-1) === `/` && (this.#t = `5`), this.#t === `5` && (this.size = 0), this.linkpath = nn(e, t + 157, 100), e.subarray(t + 257, t + 265).toString() === `ustar\x0000`) if (this.uname = n?.uname ?? r?.uname ?? nn(e, t + 265, 32), this.gname = n?.gname ?? r?.gname ?? nn(e, t + 297, 32), this.devmaj = n?.devmaj ?? r?.devmaj ?? L(e, t + 329, 8) ?? 0, this.devmin = n?.devmin ?? r?.devmin ?? L(e, t + 337, 8) ?? 0, e[t + 475] !== 0) this.path = nn(e, t + 345, 155) + `/` + this.path;
else {
let i = nn(e, t + 345, 130);
i && (this.path = i + `/` + this.path), this.atime = n?.atime ?? r?.atime ?? rn(e, t + 476, 12), this.ctime = n?.ctime ?? r?.ctime ?? rn(e, t + 488, 12);
}
let a = 256;
for (let n = t; n < t + 148; n++) a += e[n];
for (let n = t + 156; n < t + 512; n++) a += e[n];
this.cksumValid = a === this.cksum, this.cksum === void 0 && a === 256 && (this.nullBlock = !0);
}
#i(e, t = !1) {
Object.assign(this, Object.fromEntries(Object.entries(e).filter(([e, n]) => !(n == null || e === `path` && t || e === `linkpath` && t || e === `global`))));
}
encode(e, t = 0) {
if (e ||= this.block = Buffer.alloc(512), this.#t === `Unsupported` && (this.#t = `0`), !(e.length >= t + 512)) throw Error(`need 512 bytes for header`);
let n = this.ctime || this.atime ? 130 : 155, r = tn(this.path || ``, n), i = r[0], a = r[1];
this.needPax = !!r[2], this.needPax = mn(e, t, 100, i) || this.needPax, this.needPax = R(e, t + 100, 8, this.mode) || this.needPax, this.needPax = R(e, t + 108, 8, this.uid) || this.needPax, this.needPax = R(e, t + 116, 8, this.gid) || this.needPax, this.needPax = R(e, t + 124, 12, this.size) || this.needPax, this.needPax = fn(e, t + 136, 12, this.mtime) || this.needPax, e[t + 156] = Number(this.#t.codePointAt(0)), this.needPax = mn(e, t + 157, 100, this.linkpath) || this.needPax, e.write(`ustar\x0000`, t + 257, 8), this.needPax = mn(e, t + 265, 32, this.uname) || this.needPax, this.needPax = mn(e, t + 297, 32, this.gname) || this.needPax, this.needPax = R(e, t + 329, 8, this.devmaj) || this.needPax, this.needPax = R(e, t + 337, 8, this.devmin) || this.needPax, this.needPax = mn(e, t + 345, n, a) || this.needPax, e[t + 475] === 0 ? (this.needPax = mn(e, t + 345, 130, a) || this.needPax, this.needPax = fn(e, t + 476, 12, this.atime) || this.needPax, this.needPax = fn(e, t + 488, 12, this.ctime) || this.needPax) : this.needPax = mn(e, t + 345, 155, a) || this.needPax;
let o = 256;
for (let n = t; n < t + 148; n++) o += e[n];
for (let n = t + 156; n < t + 512; n++) o += e[n];
return this.cksum = o, R(e, t + 148, 8, this.cksum), this.cksumValid = !0, this.needPax;
}
get type() {
return this.#t === `Unsupported` ? this.#t : $t.get(this.#t);
}
get typeKey() {
return this.#t;
}
set type(e) {
let t = String(en.get(e));
if (Zt(t) || t === `Unsupported`) this.#t = t;
else if (Zt(e)) this.#t = e;
else throw TypeError(`invalid entry type: ` + e);
}
}, tn = (e, t) => {
let n = e, r = ``, i, a = posix.parse(e).root || `.`;
if (Buffer.byteLength(n) < 100) i = [
n,
r,
!1
];
else {
r = posix.dirname(n), n = posix.basename(n);
do
Buffer.byteLength(n) <= 100 && Buffer.byteLength(r) <= t ? i = [
n,
r,
!1
] : Buffer.byteLength(n) > 100 && Buffer.byteLength(r) <= t ? i = [
n.slice(0, 99),
r,
!0
] : (n = posix.join(posix.basename(r), n), r = posix.dirname(r));
while (r !== a && i === void 0);
i ||= [
e.slice(0, 99),
``,
!0
];
}
return i;
}, nn = (e, t, n) => e.subarray(t, t + n).toString(`utf8`).replace(/\0.*/, ``), rn = (e, t, n) => an(L(e, t, n)), an = (e) => e === void 0 ? void 0 : /* @__PURE__ */ new Date(e * 1e3), L = (e, t, n) => Number(e[t]) & 128 ? Gt(e.subarray(t, t + n)) : sn(e, t, n), on = (e) => isNaN(e) ? void 0 : e, sn = (e, t, n) => on(parseInt(e.subarray(t, t + n).toString(`utf8`).replace(/\0.*$/, ``).trim(), 8)), cn = {
12: 8589934591,
8: 2097151
}, R = (e, t, n, r) => r === void 0 ? !1 : r > cn[n] || r < 0 ? (Ht(r, e.subarray(t, t + n)), !0) : (ln(e, t, n, r), !1), ln = (e, t, n, r) => e.write(un(r, n), t, n, `ascii`), un = (e, t) => dn(Math.floor(e).toString(8), t), dn = (e, t) => (e.length === t - 1 ? e : Array(t - e.length - 1).join(`0`) + e + ` `) + `\0`, fn = (e, t, n, r) => r === void 0 ? !1 : R(e, t, n, r.getTime() / 1e3), pn = Array(156).join(`\0`), mn = (e, t, n, r) => r === void 0 ? !1 : (e.write(r + pn, t, n, `utf8`), r.length !== Buffer.byteLength(r) || r.length > n), hn = class e {
atime;
mtime;
ctime;
charset;
comment;
gid;
uid;
gname;
uname;
linkpath;
dev;
ino;
nlink;
path;
size;
mode;
global;
constructor(e, t = !1) {
this.atime = e.atime, this.charset = e.charset, this.comment = e.comment, this.ctime = e.ctime, this.dev = e.dev, this.gid = e.gid, this.global = t, this.gname = e.gname, this.ino = e.ino, this.linkpath = e.linkpath, this.mtime = e.mtime, this.nlink = e.nlink, this.path = e.path, this.size = e.size, this.uid = e.uid, this.uname = e.uname;
}
encode() {
let e = this.encodeBody();
if (e === ``) return Buffer.allocUnsafe(0);
let t = Buffer.byteLength(e), n = 512 * Math.ceil(1 + t / 512), r = Buffer.allocUnsafe(n);
for (let e = 0; e < 512; e++) r[e] = 0;
new I({
path: (`PaxHeader/` + basename(this.path ?? ``)).slice(0, 99),
mode: this.mode || 420,
uid: this.uid,
gid: this.gid,
size: t,
mtime: this.mtime,
type: this.global ? `GlobalExtendedHeader` : `ExtendedHeader`,
linkpath: ``,
uname: this.uname || ``,
gname: this.gname || ``,
devmaj: 0,
devmin: 0,
atime: this.atime,
ctime: this.ctime
}).encode(r), r.write(e, 512, t, `utf8`);
for (let e = t + 512; e < r.length; e++) r[e] = 0;
return r;
}
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(e) {
if (this[e] === void 0) return ``;
let t = this[e], n = t instanceof Date ? t.getTime() / 1e3 : t, r = ` ` + (e === `dev` || e === `ino` || e === `nlink` ? `SCHILY.` : ``) + e + `=` + n + `
`, i = Buffer.byteLength(r), a = Math.floor(Math.log(i) / Math.log(10)) + 1;
return i + a >= 10 ** a && (a += 1), a + i + r;
}
static parse(t, n, r = !1) {
return new e(gn(_n(t), n), r);
}
}, gn = (e, t) => t ? Object.assign({}, t, e) : e, _n = (e) => e.replace(/\n$/, ``).split(`
`).reduce(vn, Object.create(null)), vn = (e, t) => {
let n = parseInt(t, 10);
if (n !== Buffer.byteLength(t) + 1) return e;
t = t.slice((n + ` `).length);
let r = t.split(`=`), i = r.shift();
if (!i) return e;
let a = i.replace(/^SCHILY\.(dev|ino|nlink)/, `$1`), o = r.join(`=`);
return e[a] = /^([A-Z]+\.)?([mac]|birth|creation)time$/.test(a) ? /* @__PURE__ */ new Date(Number(o) * 1e3) : /^[0-9]+$/.test(o) ? +o : o, e;
}, z = (process.env.TESTING_TAR_FAKE_PLATFORM || process.platform) === `win32` ? (e) => e && e.replaceAll(/\\/g, `/`) : (e) => e, yn = class extends Ue {
extended;
globalExtended;
header;
startBlockSize;
blockRemain;
remain;
type;
meta = !1;
ignore = !1;
path;
mode;
uid;
gid;
uname;
gname;
size = 0;
mtime;
atime;
ctime;
linkpath;
dev;
ino;
nlink;
invalid = !1;
absolute;
unsupported = !1;
constructor(e, t, n) {
switch (super({}), this.pause(), this.extended = t, this.globalExtended = n, this.header = e, this.remain = e.size ?? 0, this.startBlockSize = 512 * Math.ceil(this.remain / 512), this.blockRemain = this.startBlockSize, this.type = e.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 = !0;
break;
default: this.ignore = !0;
}
if (!e.path) throw Error(`no path provided for tar.ReadEntry`);
this.path = z(e.path), this.mode = e.mode, this.mode && (this.mode &= 4095), this.uid = e.uid, this.gid = e.gid, this.uname = e.uname, this.gname = e.gname, this.size = this.remain, this.mtime = e.mtime, this.atime = e.atime, this.ctime = e.ctime, this.linkpath = e.linkpath ? z(e.linkpath) : void 0, this.uname = e.uname, this.gname = e.gname, t && this.#t(t), n && this.#t(n, !0);
}
write(e) {
let t = e.length;
if (t > this.blockRemain) throw Error(`writing more to entry than is appropriate`);
let n = this.remain, r = this.blockRemain;
return this.remain = Math.max(0, n - t), this.blockRemain = Math.max(0, r - t), this.ignore ? !0 : n >= t ? super.write(e) : super.write(e.subarray(0, n));
}
#t(e, t = !1) {
e.path &&= z(e.path), e.linkpath &&= z(e.linkpath), Object.assign(this, Object.fromEntries(Object.entries(e).filter(([e, n]) => !(n == null || e === `path` && t))));
}
}, bn = (e, t, n, r = {}) => {
e.file && (r.file = e.file), e.cwd && (r.cwd = e.cwd), r.code = n instanceof Error && n.code || t, r.tarCode = t, !e.strict && r.recoverable !== !1 ? (n instanceof Error && (r = Object.assign(n, r), n = n.message), e.emit(`warn`, t, n, r)) : n instanceof Error ? e.emit(`error`, Object.assign(n, r)) : e.emit(`error`, Object.assign(Error(`${t}: ${n}`), r));
}, xn = 1024 * 1024, Sn = Buffer.from([31, 139]), Cn = Buffer.from([
40,
181,
47,
253
]), wn = Math.max(Sn.length, Cn.length), B = Symbol(`state`), Tn = Symbol(`writeEntry`), V = Symbol(`readEntry`), En = Symbol(`nextEntry`), Dn = Symbol(`processEntry`), H = Symbol(`extendedHeader`), On = Symbol(`globalExtendedHeader`), kn = Symbol(`meta`), An = Symbol(`emitMeta`), U = Symbol(`buffer`), W = Symbol(`queue`), G = Symbol(`ended`), jn = Symbol(`emittedEnd`), Mn = Symbol(`emit`), K = Symbol(`unzip`), Nn = Symbol(`consumeChunk`), Pn = Symbol(`consumeChunkSub`), Fn = Symbol(`consumeBody`), In = Symbol(`consumeMeta`), Ln = Symbol(`consumeHeader`), Rn = Symbol(`consuming`), zn = Symbol(`bufferConcat`), Bn = Symbol(`maybeEnd`), Vn = Symbol(`writing`), q = Symbol(`aborted`), Hn = Symbol(`onDone`), Un = Symbol(`sawValidEntry`), Wn = Symbol(`sawNullBlock`), Gn = Symbol(`sawEOF`), Kn = Symbol(`closeStream`), qn = () => !0, Jn = class extends EventEmitter$2 {
file;
strict;
maxMetaEntrySize;
filter;
brotli;
zstd;
writable = !0;
readable = !1;
[W] = [];
[U];
[V];
[Tn];
[B] = `begin`;
[kn] = ``;
[H];
[On];
[G] = !1;
[K];
[q] = !1;
[Un];
[Wn] = !1;
[Gn] = !1;
[Vn] = !1;
[Rn] = !1;
[jn] = !1;
constructor(e = {}) {
super(), this.file = e.file || ``, this.on(Hn, () => {
(this[B] === `begin` || this[Un] === !1) && this.warn(`TAR_BAD_ARCHIVE`, `Unrecognized archive format`);
}), e.ondone ? this.on(Hn, e.ondone) : this.on(Hn, () => {
this.emit(`prefinish`), this.emit(`finish`), this.emit(`end`);
}), this.strict = !!e.strict, this.maxMetaEntrySize = e.maxMetaEntrySize || xn, this.filter = typeof e.filter == `function` ? e.filter : qn;
let t = e.file && (e.file.endsWith(`.tar.br`) || e.file.endsWith(`.tbr`));
this.brotli = !(e.gzip || e.zstd) && e.brotli !== void 0 ? e.brotli : t ? void 0 : !1;
let n = e.file && (e.file.endsWith(`.tar.zst`) || e.file.endsWith(`.tzst`));
this.zstd = !(e.gzip || e.brotli) && e.zstd !== void 0 ? e.zstd : n ? !0 : void 0, this.on(`end`, () => this[Kn]()), typeof e.onwarn == `function` && this.on(`warn`, e.onwarn), typeof e.onReadEntry == `function` && this.on(`entry`, e.onReadEntry);
}
warn(e, t, n = {}) {
bn(this, e, t, n);
}
[Ln](e, t) {
this[Un] === void 0 && (this[Un] = !1);
let n;
try {
n = new I(e, t, this[H], this[On]);
} catch (e) {
return this.warn(`TAR_ENTRY_INVALID`, e);
}
if (n.nullBlock) this[Wn] ? (this[Gn] = !0, this[B] === `begin` && (this[B] = `header`), this[Mn](`eof`)) : (this[Wn] = !0, this[Mn](`nullBlock`));
else if (this[Wn] = !1, !n.cksumValid) this.warn(`TAR_ENTRY_INVALID`, `checksum failure`, { header: n });
else if (!n.path) this.warn(`TAR_ENTRY_INVALID`, `path is required`, { header: n });
else {
let e = n.type;
if (/^(Symbolic)?Link$/.test(e) && !n.linkpath) this.warn(`TAR_ENTRY_INVALID`, `linkpath required`, { header: n });
else if (!/^(Symbolic)?Link$/.test(e) && !/^(Global)?ExtendedHeader$/.test(e) && n.linkpath) this.warn(`TAR_ENTRY_INVALID`, `linkpath forbidden`, { header: n });
else {
let e = this[Tn] = new yn(n, this[H], this[On]);
this[Un] || (e.remain ? e.on(`end`, () => {
e.invalid || (this[Un] = !0);
}) : this[Un] = !0), e.meta ? e.size > this.maxMetaEntrySize ? (e.ignore = !0, this[Mn](`ignoredEntry`, e), this[B] = `ignore`, e.resume()) : e.size > 0 && (this[kn] = ``, e.on(`data`, (e) => this[kn] += e), this[B] = `meta`) : (this[H] = void 0, e.ignore = e.ignore || !this.filter(e.path, e), e.ignore ? (this[Mn](`ignoredEntry`, e), this[B] = e.remain ? `ignore` : `header`, e.resume()) : (e.remain ? this[B] = `body` : (this[B] = `header`, e.end()), this[V] ? this[W].push(e) : (this[W].push(e), this[En]())));
}
}
}
[Kn]() {
queueMicrotask(() => this.emit(`close`));
}
[Dn](e) {
let t = !0;
if (!e) this[V] = void 0, t = !1;
else if (Array.isArray(e)) {
let [t, ...n] = e;
this.emit(t, ...n);
} else this[V] = e, this.emit(`entry`, e), e.emittedEnd || (e.on(`end`, () => this[En]()), t = !1);
return t;
}
[En]() {
do ;
while (this[Dn](this[W].shift()));
if (this[W].length === 0) {
let e = this[V];
!e || e.flowing || e.size === e.remain ? this[Vn] || this.emit(`drain`) : e.once(`drain`, () => this.emit(`drain`));
}
}
[Fn](e, t) {
let n = this[Tn];
if (!n) throw Error(`attempt to consume body without entry??`);
let r = n.blockRemain ?? 0, i = r >= e.length && t === 0 ? e : e.subarray(t, t + r);
return n.write(i), n.blockRemain || (this[B] = `header`, this[Tn] = void 0, n.end()), i.length;
}
[In](e, t) {
let n = this[Tn], r = this[Fn](e, t);
return !this[Tn] && n && this[An](n), r;
}
[Mn](e, t, n) {
this[W].length === 0 && !this[V] ? this.emit(e, t, n) : this[W].push([
e,
t,
n
]);
}
[An](e) {
switch (this[Mn](`meta`, this[kn]), e.type) {
case `ExtendedHeader`:
case `OldExtendedHeader`:
this[H] = hn.parse(this[kn], this[H], !1);
break;
case `GlobalExtendedHeader`:
this[On] = hn.parse(this[kn], this[On], !0);
break;
case `NextFileHasLongPath`:
case `OldGnuLongPath`: {
let e = this[H] ?? Object.create(null);
this[H] = e, e.path = this[kn].replace(/\0.*/, ``);
break;
}
case `NextFileHasLongLinkpath`: {
let e = this[H] || Object.create(null);
this[H] = e, e.linkpath = this[kn].replace(/\0.*/, ``);
break;
}
default: throw Error(`unknown meta: ` + e.type);
}
}
abort(e) {
this[q] = !0, this.emit(`abort`, e), this.warn(`TAR_ABORT`, e, { recoverable: !1 });
}
write(e, t, n) {
if (typeof t == `function` && (n = t, t = void 0), typeof e == `string` && (e = Buffer.from(e, typeof t == `string` ? t : `utf8`)), this[q]) return n?.(), !1;
if ((this[K] === void 0 || this.brotli === void 0 && this[K] === !1) && e) {
if (this[U] && (e = Buffer.concat([this[U], e]), this[U] = void 0), e.length < wn) return this[U] = e, n?.(), !0;
for (let t = 0; this[K] === void 0 && t < Sn.length; t++) e[t] !== Sn[t] && (this[K] = !1);
let t = !1;
if (this[K] === !1 && this.zstd !== !1) {
t = !0;
for (let n = 0; n < Cn.length; n++) if (e[n] !== Cn[n]) {
t = !1;
break;
}
}
let r = this.brotli === void 0 && !t;
if (this[K] === !1 && r) if (e.length < 512) if (this[G]) this.brotli = !0;
else return this[U] = e, n?.(), !0;
else try {
new I(e.subarray(0, 512)), this.brotli = !1;
} catch {
this.brotli = !0;
}
if (this[K] === void 0 || this[K] === !1 && (this.brotli || t)) {
let r = this[G];
this[G] = !1, this[K] = this[K] === void 0 ? new Ft({}) : t ? new Vt({}) : new Rt({}), this[K].on(`data`, (e) => this[Nn](e)), this[K].on(`error`, (e) => this.abort(e)), this[K].on(`end`, () => {
this[G] = !0, this[Nn]();
}), this[Vn] = !0;
let i = !!this[K][r ? `end` : `write`](e);
return this[Vn] = !1, n?.(), i;
}
}
this[Vn] = !0, this[K] ? this[K].write(e) : this[Nn](e), this[Vn] = !1;
let r = this[W].length > 0 ? !1 : this[V] ? this[V].flowing : !0;
return !r && this[W].length === 0 && this[V]?.once(`drain`, () => this.emit(`drain`)), n?.(), r;
}
[zn](e) {
e && !this[q] && (this[U] = this[U] ? Buffer.concat([this[U], e]) : e);
}
[Bn]() {
if (this[G] && !this[jn] && !this[q] && !this[Rn]) {
this[jn] = !0;
let e = this[Tn];
if (e && e.blockRemain) {
let t = this[U] ? this[U].length : 0;
this.warn(`TAR_BAD_ARCHIVE`, `Truncated input (needed ${e.blockRemain} more bytes, only ${t} available)`, { entry: e }), this[U] && e.write(this[U]), e.end();
}
this[Mn](Hn);
}
}
[Nn](e) {
if (this[Rn] && e) this[zn](e);
else if (!e && !this[U]) this[Bn]();
else if (e) {
if (this[Rn] = !0, this[U]) {
this[zn](e);
let t = this[U];
this[U] = void 0, this[Pn](t);
} else this[Pn](e);
for (; this[U] && this[U]?.length >= 512 && !this[q] && !this[Gn];) {
let e = this[U];
this[U] = void 0, this[Pn](e);
}
this[Rn] = !1;
}
(!this[U] || this[G]) && this[Bn]();
}
[Pn](e) {
let t = 0, n = e.length;
for (; t + 512 <= n && !this[q] && !this[Gn];) switch (this[B]) {
case `begin`:
case `header`:
this[Ln](e, t), t += 512;
break;
case `ignore`:
case `body`:
t += this[Fn](e, t);
break;
ca