UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

5,085 lines • 143 kB
import { r as __exportAll } from "./rolldown-runtime-C_OpTf0N.mjs";
import fs from "node:fs";
import path, { basename, join, posix, win32 } from "node:path";
import { randomBytes } from "node:crypto";
import fs$1 from "node:fs/promises";
import { EventEmitter } from "node:events";
import { StringDecoder } from "node:string_decoder";
import Stream from "node:stream";
import EE, { EventEmitter as EventEmitter$1 } from "events";
import fs$2 from "fs";
import path$1, { dirname as dirname$1, parse as parse$1 } from "path";
import assert from "assert";
import { Buffer as Buffer$1 } from "buffer";
import * as realZlib$1 from "zlib";
import realZlib from "zlib";
import assert$1 from "node:assert";
//#region node_modules/.pnpm/minipass@7.1.3/node_modules/minipass/dist/esm/index.js
const proc = typeof process === "object" && process ? process : {
	stdout: null,
	stderr: null
};
/**
* Return true if the argument is a Minipass stream, Node stream, or something
* else that Minipass can interact with.
*/
const isStream = (e) => !!e && typeof e === "object" && (e instanceof Minipass || e instanceof Stream || isReadable(e) || isWritable(e));
/**
* Return true if the argument is a valid {@link Minipass.Readable}
*/
const isReadable = (e) => !!e && typeof e === "object" && e instanceof EventEmitter && typeof e.pipe === "function" && e.pipe !== Stream.Writable.prototype.pipe;
/**
* Return true if the argument is a valid {@link Minipass.Writable}
*/
const isWritable = (e) => !!e && typeof e === "object" && e instanceof EventEmitter && typeof e.write === "function" && typeof e.end === "function";
const EOF$1 = Symbol("EOF");
const MAYBE_EMIT_END = Symbol("maybeEmitEnd");
const EMITTED_END = Symbol("emittedEnd");
const EMITTING_END = Symbol("emittingEnd");
const EMITTED_ERROR = Symbol("emittedError");
const CLOSED = Symbol("closed");
const READ$1 = Symbol("read");
const FLUSH = Symbol("flush");
const FLUSHCHUNK = Symbol("flushChunk");
const ENCODING = Symbol("encoding");
const DECODER = Symbol("decoder");
const FLOWING = Symbol("flowing");
const PAUSED = Symbol("paused");
const RESUME = Symbol("resume");
const BUFFER$1 = Symbol("buffer");
const PIPES = Symbol("pipes");
const BUFFERLENGTH = Symbol("bufferLength");
const BUFFERPUSH = Symbol("bufferPush");
const BUFFERSHIFT = Symbol("bufferShift");
const OBJECTMODE = Symbol("objectMode");
const DESTROYED = Symbol("destroyed");
const ERROR = Symbol("error");
const EMITDATA = Symbol("emitData");
const EMITEND = Symbol("emitEnd");
const EMITEND2 = Symbol("emitEnd2");
const ASYNC = Symbol("async");
const ABORT = Symbol("abort");
const ABORTED$1 = Symbol("aborted");
const SIGNAL = Symbol("signal");
const DATALISTENERS = Symbol("dataListeners");
const DISCARDED = Symbol("discarded");
const defer = (e) => Promise.resolve().then(e);
const nodefer = (e) => e();
const isEndish = (e) => e === "end" || e === "finish" || e === "prefinish";
const isArrayBufferLike = (e) => e instanceof ArrayBuffer || !!e && typeof e === "object" && e.constructor && e.constructor.name === "ArrayBuffer" && e.byteLength >= 0;
const isArrayBufferView = (e) => !Buffer.isBuffer(e) && ArrayBuffer.isView(e);
/**
* Internal class representing a pipe to a destination stream.
*
* @internal
*/
var Pipe = class {
	src;
	dest;
	opts;
	ondrain;
	constructor(e, t, n) {
		this.src = e;
		this.dest = t;
		this.opts = n;
		this.ondrain = () => e[RESUME]();
		this.dest.on("drain", this.ondrain);
	}
	unpipe() {
		this.dest.removeListener("drain", this.ondrain);
	}
	/* c8 ignore start */
	proxyErrors(e) {}
	/* c8 ignore stop */
	end() {
		this.unpipe();
		if (this.opts.end) this.dest.end();
	}
};
/**
* Internal class representing a pipe to a destination stream where
* errors are proxied.
*
* @internal
*/
var PipeProxyErrors = class extends Pipe {
	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);
	}
};
const isObjectModeOptions = (e) => !!e.objectMode;
const isEncodingOptions = (e) => !e.objectMode && !!e.encoding && e.encoding !== "buffer";
/**
* Main export, the Minipass class
*
* `RType` is the type of data emitted, defaults to Buffer
*
* `WType` is the type of data to be written, if RType is buffer or string,
* then any {@link Minipass.ContiguousData} is allowed.
*
* `Events` is the set of event handler signatures that this object
* will emit, see {@link Minipass.Events}
*/
var Minipass = class extends EventEmitter {
	[FLOWING] = false;
	[PAUSED] = false;
	[PIPES] = [];
	[BUFFER$1] = [];
	[OBJECTMODE];
	[ENCODING];
	[ASYNC];
	[DECODER];
	[EOF$1] = false;
	[EMITTED_END] = false;
	[EMITTING_END] = false;
	[CLOSED] = false;
	[EMITTED_ERROR] = null;
	[BUFFERLENGTH] = 0;
	[DESTROYED] = false;
	[SIGNAL];
	[ABORTED$1] = false;
	[DATALISTENERS] = 0;
	[DISCARDED] = false;
	/**
	* true if the stream can be written
	*/
	writable = true;
	/**
	* true if the stream can be read
	*/
	readable = true;
	/**
	* If `RType` is Buffer, then options do not need to be provided.
	* Otherwise, an options object must be provided to specify either
	* {@link Minipass.SharedOptions.objectMode} or
	* {@link Minipass.SharedOptions.encoding}, as appropriate.
	*/
	constructor(...e) {
		const t = e[0] || {};
		super();
		if (t.objectMode && typeof t.encoding === "string") throw new TypeError("Encoding and objectMode may not be used together");
		if (isObjectModeOptions(t)) {
			this[OBJECTMODE] = true;
			this[ENCODING] = null;
		} else if (isEncodingOptions(t)) {
			this[ENCODING] = t.encoding;
			this[OBJECTMODE] = false;
		} else {
			this[OBJECTMODE] = false;
			this[ENCODING] = null;
		}
		this[ASYNC] = !!t.async;
		this[DECODER] = this[ENCODING] ? new StringDecoder(this[ENCODING]) : null;
		if (t && t.debugExposeBuffer === true) Object.defineProperty(this, "buffer", { get: () => this[BUFFER$1] });
		if (t && t.debugExposePipes === true) Object.defineProperty(this, "pipes", { get: () => this[PIPES] });
		const { signal: n } = t;
		if (n) {
			this[SIGNAL] = n;
			if (n.aborted) this[ABORT]();
			else n.addEventListener("abort", () => this[ABORT]());
		}
	}
	/**
	* The amount of data stored in the buffer waiting to be read.
	*
	* For Buffer strings, this will be the total byte length.
	* For string encoding streams, this will be the string character length,
	* according to JavaScript's `string.length` logic.
	* For objectMode streams, this is a count of the items waiting to be
	* emitted.
	*/
	get bufferLength() {
		return this[BUFFERLENGTH];
	}
	/**
	* The `BufferEncoding` currently in use, or `null`
	*/
	get encoding() {
		return this[ENCODING];
	}
	/**
	* @deprecated - This is a read only property
	*/
	set encoding(e) {
		throw new Error("Encoding must be set at instantiation time");
	}
	/**
	* @deprecated - Encoding may only be set at instantiation time
	*/
	setEncoding(e) {
		throw new Error("Encoding must be set at instantiation time");
	}
	/**
	* True if this is an objectMode stream
	*/
	get objectMode() {
		return this[OBJECTMODE];
	}
	/**
	* @deprecated - This is a read-only property
	*/
	set objectMode(e) {
		throw new Error("objectMode must be set at instantiation time");
	}
	/**
	* true if this is an async stream
	*/
	get ["async"]() {
		return this[ASYNC];
	}
	/**
	* Set to true to make this stream async.
	*
	* Once set, it cannot be unset, as this would potentially cause incorrect
	* behavior.  Ie, a sync stream can be made async, but an async stream
	* cannot be safely made sync.
	*/
	set ["async"](e) {
		this[ASYNC] = this[ASYNC] || !!e;
	}
	[ABORT]() {
		this[ABORTED$1] = true;
		this.emit("abort", this[SIGNAL]?.reason);
		this.destroy(this[SIGNAL]?.reason);
	}
	/**
	* True if the stream has been aborted.
	*/
	get aborted() {
		return this[ABORTED$1];
	}
	/**
	* No-op setter. Stream aborted status is set via the AbortSignal provided
	* in the constructor options.
	*/
	set aborted(e) {}
	write(e, t, n) {
		if (this[ABORTED$1]) return false;
		if (this[EOF$1]) throw new Error("write after end");
		if (this[DESTROYED]) {
			this.emit("error", Object.assign(/* @__PURE__ */ new Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" }));
			return true;
		}
		if (typeof t === "function") {
			n = t;
			t = "utf8";
		}
		if (!t) t = "utf8";
		const r = this[ASYNC] ? defer : nodefer;
		if (!this[OBJECTMODE] && !Buffer.isBuffer(e)) {
			if (isArrayBufferView(e)) e = Buffer.from(e.buffer, e.byteOffset, e.byteLength);
			else if (isArrayBufferLike(e)) e = Buffer.from(e);
			else if (typeof e !== "string") throw new Error("Non-contiguous data written to non-objectMode stream");
		}
		if (this[OBJECTMODE]) {
			/* c8 ignore start */
			if (this[FLOWING] && this[BUFFERLENGTH] !== 0) this[FLUSH](true);
			/* c8 ignore stop */
			if (this[FLOWING]) this.emit("data", e);
			else this[BUFFERPUSH](e);
			if (this[BUFFERLENGTH] !== 0) this.emit("readable");
			if (n) r(n);
			return this[FLOWING];
		}
		if (!e.length) {
			if (this[BUFFERLENGTH] !== 0) this.emit("readable");
			if (n) r(n);
			return this[FLOWING];
		}
		if (typeof e === "string" && !(t === this[ENCODING] && !this[DECODER]?.lastNeed)) e = Buffer.from(e, t);
		if (Buffer.isBuffer(e) && this[ENCODING]) e = this[DECODER].write(e);
		if (this[FLOWING] && this[BUFFERLENGTH] !== 0) this[FLUSH](true);
		if (this[FLOWING]) this.emit("data", e);
		else this[BUFFERPUSH](e);
		if (this[BUFFERLENGTH] !== 0) this.emit("readable");
		if (n) r(n);
		return this[FLOWING];
	}
	/**
	* Low-level explicit read method.
	*
	* In objectMode, the argument is ignored, and one item is returned if
	* available.
	*
	* `n` is the number of bytes (or in the case of encoding streams,
	* characters) to consume. If `n` is not provided, then the entire buffer
	* is returned, or `null` is returned if no data is available.
	*
	* If `n` is greater that the amount of data in the internal buffer,
	* then `null` is returned.
	*/
	read(e) {
		if (this[DESTROYED]) return null;
		this[DISCARDED] = false;
		if (this[BUFFERLENGTH] === 0 || e === 0 || e && e > this[BUFFERLENGTH]) {
			this[MAYBE_EMIT_END]();
			return null;
		}
		if (this[OBJECTMODE]) e = null;
		if (this[BUFFER$1].length > 1 && !this[OBJECTMODE]) this[BUFFER$1] = [this[ENCODING] ? this[BUFFER$1].join("") : Buffer.concat(this[BUFFER$1], this[BUFFERLENGTH])];
		const t = this[READ$1](e || null, this[BUFFER$1][0]);
		this[MAYBE_EMIT_END]();
		return t;
	}
	[READ$1](e, t) {
		if (this[OBJECTMODE]) this[BUFFERSHIFT]();
		else {
			const n = t;
			if (e === n.length || e === null) this[BUFFERSHIFT]();
			else if (typeof n === "string") {
				this[BUFFER$1][0] = n.slice(e);
				t = n.slice(0, e);
				this[BUFFERLENGTH] -= e;
			} else {
				this[BUFFER$1][0] = n.subarray(e);
				t = n.subarray(0, e);
				this[BUFFERLENGTH] -= e;
			}
		}
		this.emit("data", t);
		if (!this[BUFFER$1].length && !this[EOF$1]) this.emit("drain");
		return t;
	}
	end(e, t, n) {
		if (typeof e === "function") {
			n = e;
			e = void 0;
		}
		if (typeof t === "function") {
			n = t;
			t = "utf8";
		}
		if (e !== void 0) this.write(e, t);
		if (n) this.once("end", n);
		this[EOF$1] = true;
		this.writable = false;
		if (this[FLOWING] || !this[PAUSED]) this[MAYBE_EMIT_END]();
		return this;
	}
	[RESUME]() {
		if (this[DESTROYED]) return;
		if (!this[DATALISTENERS] && !this[PIPES].length) this[DISCARDED] = true;
		this[PAUSED] = false;
		this[FLOWING] = true;
		this.emit("resume");
		if (this[BUFFER$1].length) this[FLUSH]();
		else if (this[EOF$1]) this[MAYBE_EMIT_END]();
		else this.emit("drain");
	}
	/**
	* Resume the stream if it is currently in a paused state
	*
	* If called when there are no pipe destinations or `data` event listeners,
	* this will place the stream in a "discarded" state, where all data will
	* be thrown away. The discarded state is removed if a pipe destination or
	* data handler is added, if pause() is called, or if any synchronous or
	* asynchronous iteration is started.
	*/
	resume() {
		return this[RESUME]();
	}
	/**
	* Pause the stream
	*/
	pause() {
		this[FLOWING] = false;
		this[PAUSED] = true;
		this[DISCARDED] = false;
	}
	/**
	* true if the stream has been forcibly destroyed
	*/
	get destroyed() {
		return this[DESTROYED];
	}
	/**
	* true if the stream is currently in a flowing state, meaning that
	* any writes will be immediately emitted.
	*/
	get flowing() {
		return this[FLOWING];
	}
	/**
	* true if the stream is currently in a paused state
	*/
	get paused() {
		return this[PAUSED];
	}
	[BUFFERPUSH](e) {
		if (this[OBJECTMODE]) this[BUFFERLENGTH] += 1;
		else this[BUFFERLENGTH] += e.length;
		this[BUFFER$1].push(e);
	}
	[BUFFERSHIFT]() {
		if (this[OBJECTMODE]) this[BUFFERLENGTH] -= 1;
		else this[BUFFERLENGTH] -= this[BUFFER$1][0].length;
		return this[BUFFER$1].shift();
	}
	[FLUSH](e = false) {
		do;
		while (this[FLUSHCHUNK](this[BUFFERSHIFT]()) && this[BUFFER$1].length);
		if (!e && !this[BUFFER$1].length && !this[EOF$1]) this.emit("drain");
	}
	[FLUSHCHUNK](e) {
		this.emit("data", e);
		return this[FLOWING];
	}
	/**
	* Pipe all data emitted by this stream into the destination provided.
	*
	* Triggers the flow of data.
	*/
	pipe(e, t) {
		if (this[DESTROYED]) return e;
		this[DISCARDED] = false;
		const n = this[EMITTED_END];
		t = t || {};
		if (e === proc.stdout || e === proc.stderr) t.end = false;
		else t.end = t.end !== false;
		t.proxyErrors = !!t.proxyErrors;
		if (n) {
			if (t.end) e.end();
		} else {
			this[PIPES].push(!t.proxyErrors ? new Pipe(this, e, t) : new PipeProxyErrors(this, e, t));
			if (this[ASYNC]) defer(() => this[RESUME]());
			else this[RESUME]();
		}
		return e;
	}
	/**
	* Fully unhook a piped destination stream.
	*
	* If the destination stream was the only consumer of this stream (ie,
	* there are no other piped destinations or `'data'` event listeners)
	* then the flow of data will stop until there is another consumer or
	* {@link Minipass#resume} is explicitly called.
	*/
	unpipe(e) {
		const t = this[PIPES].find((t) => t.dest === e);
		if (t) {
			if (this[PIPES].length === 1) {
				if (this[FLOWING] && this[DATALISTENERS] === 0) this[FLOWING] = false;
				this[PIPES] = [];
			} else this[PIPES].splice(this[PIPES].indexOf(t), 1);
			t.unpipe();
		}
	}
	/**
	* Alias for {@link Minipass#on}
	*/
	addListener(e, t) {
		return this.on(e, t);
	}
	/**
	* Mostly identical to `EventEmitter.on`, with the following
	* behavior differences to prevent data loss and unnecessary hangs:
	*
	* - Adding a 'data' event handler will trigger the flow of data
	*
	* - Adding a 'readable' event handler when there is data waiting to be read
	*   will cause 'readable' to be emitted immediately.
	*
	* - Adding an 'endish' event handler ('end', 'finish', etc.) which has
	*   already passed will cause the event to be emitted immediately and all
	*   handlers removed.
	*
	* - Adding an 'error' event handler after an error has been emitted will
	*   cause the event to be re-emitted immediately with the error previously
	*   raised.
	*/
	on(e, t) {
		const n = super.on(e, t);
		if (e === "data") {
			this[DISCARDED] = false;
			this[DATALISTENERS]++;
			if (!this[PIPES].length && !this[FLOWING]) this[RESUME]();
		} else if (e === "readable" && this[BUFFERLENGTH] !== 0) super.emit("readable");
		else if (isEndish(e) && this[EMITTED_END]) {
			super.emit(e);
			this.removeAllListeners(e);
		} else if (e === "error" && this[EMITTED_ERROR]) {
			const e = t;
			if (this[ASYNC]) defer(() => e.call(this, this[EMITTED_ERROR]));
			else e.call(this, this[EMITTED_ERROR]);
		}
		return n;
	}
	/**
	* Alias for {@link Minipass#off}
	*/
	removeListener(e, t) {
		return this.off(e, t);
	}
	/**
	* Mostly identical to `EventEmitter.off`
	*
	* If a 'data' event handler is removed, and it was the last consumer
	* (ie, there are no pipe destinations or other 'data' event listeners),
	* then the flow of data will stop until there is another consumer or
	* {@link Minipass#resume} is explicitly called.
	*/
	off(e, t) {
		const n = super.off(e, t);
		if (e === "data") {
			this[DATALISTENERS] = this.listeners("data").length;
			if (this[DATALISTENERS] === 0 && !this[DISCARDED] && !this[PIPES].length) this[FLOWING] = false;
		}
		return n;
	}
	/**
	* Mostly identical to `EventEmitter.removeAllListeners`
	*
	* If all 'data' event handlers are removed, and they were the last consumer
	* (ie, there are no pipe destinations), then the flow of data will stop
	* until there is another consumer or {@link Minipass#resume} is explicitly
	* called.
	*/
	removeAllListeners(e) {
		const t = super.removeAllListeners(e);
		if (e === "data" || e === void 0) {
			this[DATALISTENERS] = 0;
			if (!this[DISCARDED] && !this[PIPES].length) this[FLOWING] = false;
		}
		return t;
	}
	/**
	* true if the 'end' event has been emitted
	*/
	get emittedEnd() {
		return this[EMITTED_END];
	}
	[MAYBE_EMIT_END]() {
		if (!this[EMITTING_END] && !this[EMITTED_END] && !this[DESTROYED] && this[BUFFER$1].length === 0 && this[EOF$1]) {
			this[EMITTING_END] = true;
			this.emit("end");
			this.emit("prefinish");
			this.emit("finish");
			if (this[CLOSED]) this.emit("close");
			this[EMITTING_END] = false;
		}
	}
	/**
	* Mostly identical to `EventEmitter.emit`, with the following
	* behavior differences to prevent data loss and unnecessary hangs:
	*
	* If the stream has been destroyed, and the event is something other
	* than 'close' or 'error', then `false` is returned and no handlers
	* are called.
	*
	* If the event is 'end', and has already been emitted, then the event
	* is ignored. If the stream is in a paused or non-flowing state, then
	* the event will be deferred until data flow resumes. If the stream is
	* async, then handlers will be called on the next tick rather than
	* immediately.
	*
	* If the event is 'close', and 'end' has not yet been emitted, then
	* the event will be deferred until after 'end' is emitted.
	*
	* If the event is 'error', and an AbortSignal was provided for the stream,
	* and there are no listeners, then the event is ignored, matching the
	* behavior of node core streams in the presense of an AbortSignal.
	*
	* If the event is 'finish' or 'prefinish', then all listeners will be
	* removed after emitting the event, to prevent double-firing.
	*/
	emit(e, ...t) {
		const n = t[0];
		if (e !== "error" && e !== "close" && e !== DESTROYED && this[DESTROYED]) return false;
		else if (e === "data") return !this[OBJECTMODE] && !n ? false : this[ASYNC] ? (defer(() => this[EMITDATA](n)), true) : this[EMITDATA](n);
		else if (e === "end") return this[EMITEND]();
		else if (e === "close") {
			this[CLOSED] = true;
			if (!this[EMITTED_END] && !this[DESTROYED]) return false;
			const e = super.emit("close");
			this.removeAllListeners("close");
			return e;
		} else if (e === "error") {
			this[EMITTED_ERROR] = n;
			super.emit(ERROR, n);
			const e = !this[SIGNAL] || this.listeners("error").length ? super.emit("error", n) : false;
			this[MAYBE_EMIT_END]();
			return e;
		} else if (e === "resume") {
			const e = super.emit("resume");
			this[MAYBE_EMIT_END]();
			return e;
		} else if (e === "finish" || e === "prefinish") {
			const t = super.emit(e);
			this.removeAllListeners(e);
			return t;
		}
		const r = super.emit(e, ...t);
		this[MAYBE_EMIT_END]();
		return r;
	}
	[EMITDATA](e) {
		for (const t of this[PIPES]) if (t.dest.write(e) === false) this.pause();
		const t = this[DISCARDED] ? false : super.emit("data", e);
		this[MAYBE_EMIT_END]();
		return t;
	}
	[EMITEND]() {
		if (this[EMITTED_END]) return false;
		this[EMITTED_END] = true;
		this.readable = false;
		return this[ASYNC] ? (defer(() => this[EMITEND2]()), true) : this[EMITEND2]();
	}
	[EMITEND2]() {
		if (this[DECODER]) {
			const e = this[DECODER].end();
			if (e) {
				for (const t of this[PIPES]) t.dest.write(e);
				if (!this[DISCARDED]) super.emit("data", e);
			}
		}
		for (const e of this[PIPES]) e.end();
		const e = super.emit("end");
		this.removeAllListeners("end");
		return e;
	}
	/**
	* Return a Promise that resolves to an array of all emitted data once
	* the stream ends.
	*/
	async collect() {
		const e = Object.assign([], { dataLength: 0 });
		if (!this[OBJECTMODE]) e.dataLength = 0;
		const t = this.promise();
		this.on("data", (t) => {
			e.push(t);
			if (!this[OBJECTMODE]) e.dataLength += t.length;
		});
		await t;
		return e;
	}
	/**
	* Return a Promise that resolves to the concatenation of all emitted data
	* once the stream ends.
	*
	* Not allowed on objectMode streams.
	*/
	async concat() {
		if (this[OBJECTMODE]) throw new Error("cannot concat in objectMode");
		const e = await this.collect();
		return this[ENCODING] ? e.join("") : Buffer.concat(e, e.dataLength);
	}
	/**
	* Return a void Promise that resolves once the stream ends.
	*/
	async promise() {
		return new Promise((e, t) => {
			this.on(DESTROYED, () => t(/* @__PURE__ */ new Error("stream destroyed")));
			this.on("error", (e) => t(e));
			this.on("end", () => e());
		});
	}
	/**
	* Asynchronous `for await of` iteration.
	*
	* This will continue emitting all chunks until the stream terminates.
	*/
	[Symbol.asyncIterator]() {
		this[DISCARDED] = false;
		let e = false;
		const stop = async () => {
			this.pause();
			e = true;
			return {
				value: void 0,
				done: true
			};
		};
		const next = () => {
			if (e) return stop();
			const t = this.read();
			if (t !== null) return Promise.resolve({
				done: false,
				value: t
			});
			if (this[EOF$1]) return stop();
			let n;
			let r;
			const onerr = (e) => {
				this.off("data", ondata);
				this.off("end", onend);
				this.off(DESTROYED, ondestroy);
				stop();
				r(e);
			};
			const ondata = (e) => {
				this.off("error", onerr);
				this.off("end", onend);
				this.off(DESTROYED, ondestroy);
				this.pause();
				n({
					value: e,
					done: !!this[EOF$1]
				});
			};
			const onend = () => {
				this.off("error", onerr);
				this.off("data", ondata);
				this.off(DESTROYED, ondestroy);
				stop();
				n({
					done: true,
					value: void 0
				});
			};
			const ondestroy = () => onerr(/* @__PURE__ */ new Error("stream destroyed"));
			return new Promise((e, t) => {
				r = t;
				n = e;
				this.once(DESTROYED, ondestroy);
				this.once("error", onerr);
				this.once("end", onend);
				this.once("data", ondata);
			});
		};
		return {
			next,
			throw: stop,
			return: stop,
			[Symbol.asyncIterator]() {
				return this;
			},
			[Symbol.asyncDispose]: async () => {}
		};
	}
	/**
	* Synchronous `for of` iteration.
	*
	* The iteration will terminate when the internal buffer runs out, even
	* if the stream has not yet terminated.
	*/
	[Symbol.iterator]() {
		this[DISCARDED] = false;
		let e = false;
		const stop = () => {
			this.pause();
			this.off(ERROR, stop);
			this.off(DESTROYED, stop);
			this.off("end", stop);
			e = true;
			return {
				done: true,
				value: void 0
			};
		};
		const next = () => {
			if (e) return stop();
			const t = this.read();
			return t === null ? stop() : {
				done: false,
				value: t
			};
		};
		this.once("end", stop);
		this.once(ERROR, stop);
		this.once(DESTROYED, stop);
		return {
			next,
			throw: stop,
			return: stop,
			[Symbol.iterator]() {
				return this;
			},
			[Symbol.dispose]: () => {}
		};
	}
	/**
	* Destroy a stream, preventing it from being used for any further purpose.
	*
	* If the stream has a `close()` method, then it will be called on
	* destruction.
	*
	* After destruction, any attempt to write data, read data, or emit most
	* events will be ignored.
	*
	* If an error argument is provided, then it will be emitted in an
	* 'error' event.
	*/
	destroy(e) {
		if (this[DESTROYED]) {
			if (e) this.emit("error", e);
			else this.emit(DESTROYED);
			return this;
		}
		this[DESTROYED] = true;
		this[DISCARDED] = true;
		this[BUFFER$1].length = 0;
		this[BUFFERLENGTH] = 0;
		const t = this;
		if (typeof t.close === "function" && !this[CLOSED]) t.close();
		if (e) this.emit("error", e);
		else this.emit(DESTROYED);
		return this;
	}
	/**
	* Alias for {@link isStream}
	*
	* Former export location, maintained for backwards compatibility.
	*
	* @deprecated
	*/
	static get isStream() {
		return isStream;
	}
};
//#endregion
//#region node_modules/.pnpm/@isaacs+fs-minipass@4.0.1/node_modules/@isaacs/fs-minipass/dist/esm/index.js
const writev$1 = fs$2.writev;
const _autoClose = Symbol("_autoClose");
const _close = Symbol("_close");
const _ended = Symbol("_ended");
const _fd = Symbol("_fd");
const _finished = Symbol("_finished");
const _flags = Symbol("_flags");
const _flush = Symbol("_flush");
const _handleChunk = Symbol("_handleChunk");
const _makeBuf = Symbol("_makeBuf");
const _mode = Symbol("_mode");
const _needDrain = Symbol("_needDrain");
const _onerror = Symbol("_onerror");
const _onopen = Symbol("_onopen");
const _onread = Symbol("_onread");
const _onwrite = Symbol("_onwrite");
const _open = Symbol("_open");
const _path = Symbol("_path");
const _pos = Symbol("_pos");
const _queue = Symbol("_queue");
const _read = Symbol("_read");
const _readSize = Symbol("_readSize");
const _reading = Symbol("_reading");
const _remain = Symbol("_remain");
const _size = Symbol("_size");
const _write = Symbol("_write");
const _writing = Symbol("_writing");
const _defaultFlag = Symbol("_defaultFlag");
const _errored = Symbol("_errored");
var ReadStream$1 = class extends Minipass {
	[_errored] = false;
	[_fd];
	[_path];
	[_readSize];
	[_reading] = false;
	[_size];
	[_remain];
	[_autoClose];
	constructor(e, t) {
		t = t || {};
		super(t);
		this.readable = true;
		this.writable = false;
		if (typeof e !== "string") throw new TypeError("path must be a string");
		this[_errored] = false;
		this[_fd] = typeof t.fd === "number" ? t.fd : void 0;
		this[_path] = e;
		this[_readSize] = t.readSize || 16777216;
		this[_reading] = false;
		this[_size] = typeof t.size === "number" ? t.size : Infinity;
		this[_remain] = this[_size];
		this[_autoClose] = typeof t.autoClose === "boolean" ? t.autoClose : true;
		if (typeof this[_fd] === "number") this[_read]();
		else this[_open]();
	}
	get fd() {
		return this[_fd];
	}
	get path() {
		return this[_path];
	}
	write() {
		throw new TypeError("this is a readable stream");
	}
	end() {
		throw new TypeError("this is a readable stream");
	}
	[_open]() {
		fs$2.open(this[_path], "r", (e, t) => this[_onopen](e, t));
	}
	[_onopen](e, t) {
		if (e) this[_onerror](e);
		else {
			this[_fd] = t;
			this.emit("open", t);
			this[_read]();
		}
	}
	[_makeBuf]() {
		return Buffer.allocUnsafe(Math.min(this[_readSize], this[_remain]));
	}
	[_read]() {
		if (!this[_reading]) {
			this[_reading] = true;
			const e = this[_makeBuf]();
			/* c8 ignore start */
			if (e.length === 0) return process.nextTick(() => this[_onread](null, 0, e));
			/* c8 ignore stop */
			fs$2.read(this[_fd], e, 0, e.length, null, (e, t, n) => this[_onread](e, t, n));
		}
	}
	[_onread](e, t, n) {
		this[_reading] = false;
		if (e) this[_onerror](e);
		else if (this[_handleChunk](t, n)) this[_read]();
	}
	[_close]() {
		if (this[_autoClose] && typeof this[_fd] === "number") {
			const e = this[_fd];
			this[_fd] = void 0;
			fs$2.close(e, (e) => e ? this.emit("error", e) : this.emit("close"));
		}
	}
	[_onerror](e) {
		this[_reading] = true;
		this[_close]();
		this.emit("error", e);
	}
	[_handleChunk](e, t) {
		let n = false;
		this[_remain] -= e;
		if (e > 0) n = super.write(e < t.length ? t.subarray(0, e) : t);
		if (e === 0 || this[_remain] <= 0) {
			n = false;
			this[_close]();
			super.end();
		}
		return n;
	}
	emit(e, ...t) {
		switch (e) {
			case "prefinish":
			case "finish": return false;
			case "drain":
				if (typeof this[_fd] === "number") this[_read]();
				return false;
			case "error":
				if (this[_errored]) return false;
				this[_errored] = true;
				return super.emit(e, ...t);
			default: return super.emit(e, ...t);
		}
	}
};
var ReadStreamSync = class extends ReadStream$1 {
	[_open]() {
		let e = true;
		try {
			this[_onopen](null, fs$2.openSync(this[_path], "r"));
			e = false;
		} finally {
			if (e) this[_close]();
		}
	}
	[_read]() {
		let e = true;
		try {
			if (!this[_reading]) {
				this[_reading] = true;
				do {
					const e = this[_makeBuf]();
					/* c8 ignore start */
					const t = e.length === 0 ? 0 : fs$2.readSync(this[_fd], e, 0, e.length, null);
					/* c8 ignore stop */
					if (!this[_handleChunk](t, e)) break;
				} while (true);
				this[_reading] = false;
			}
			e = false;
		} finally {
			if (e) this[_close]();
		}
	}
	[_close]() {
		if (this[_autoClose] && typeof this[_fd] === "number") {
			const e = this[_fd];
			this[_fd] = void 0;
			fs$2.closeSync(e);
			this.emit("close");
		}
	}
};
var WriteStream = class extends EE {
	readable = false;
	writable = true;
	[_errored] = false;
	[_writing] = false;
	[_ended] = false;
	[_queue] = [];
	[_needDrain] = false;
	[_path];
	[_mode];
	[_autoClose];
	[_fd];
	[_defaultFlag];
	[_flags];
	[_finished] = false;
	[_pos];
	constructor(e, t) {
		t = t || {};
		super(t);
		this[_path] = e;
		this[_fd] = typeof t.fd === "number" ? t.fd : void 0;
		this[_mode] = t.mode === void 0 ? 438 : t.mode;
		this[_pos] = typeof t.start === "number" ? t.start : void 0;
		this[_autoClose] = typeof t.autoClose === "boolean" ? t.autoClose : true;
		const n = this[_pos] !== void 0 ? "r+" : "w";
		this[_defaultFlag] = t.flags === void 0;
		this[_flags] = t.flags === void 0 ? n : t.flags;
		if (this[_fd] === void 0) this[_open]();
	}
	emit(e, ...t) {
		if (e === "error") {
			if (this[_errored]) return false;
			this[_errored] = true;
		}
		return super.emit(e, ...t);
	}
	get fd() {
		return this[_fd];
	}
	get path() {
		return this[_path];
	}
	[_onerror](e) {
		this[_close]();
		this[_writing] = true;
		this.emit("error", e);
	}
	[_open]() {
		fs$2.open(this[_path], this[_flags], this[_mode], (e, t) => this[_onopen](e, t));
	}
	[_onopen](e, t) {
		if (this[_defaultFlag] && this[_flags] === "r+" && e && e.code === "ENOENT") {
			this[_flags] = "w";
			this[_open]();
		} else if (e) this[_onerror](e);
		else {
			this[_fd] = t;
			this.emit("open", t);
			if (!this[_writing]) this[_flush]();
		}
	}
	end(e, t) {
		if (e) this.write(e, t);
		this[_ended] = true;
		if (!this[_writing] && !this[_queue].length && typeof this[_fd] === "number") this[_onwrite](null, 0);
		return this;
	}
	write(e, t) {
		if (typeof e === "string") e = Buffer.from(e, t);
		if (this[_ended]) {
			this.emit("error", /* @__PURE__ */ new Error("write() after end()"));
			return false;
		}
		if (this[_fd] === void 0 || this[_writing] || this[_queue].length) {
			this[_queue].push(e);
			this[_needDrain] = true;
			return false;
		}
		this[_writing] = true;
		this[_write](e);
		return true;
	}
	[_write](e) {
		fs$2.write(this[_fd], e, 0, e.length, this[_pos], (e, t) => this[_onwrite](e, t));
	}
	[_onwrite](e, t) {
		if (e) this[_onerror](e);
		else {
			if (this[_pos] !== void 0 && typeof t === "number") this[_pos] += t;
			if (this[_queue].length) this[_flush]();
			else {
				this[_writing] = false;
				if (this[_ended] && !this[_finished]) {
					this[_finished] = true;
					this[_close]();
					this.emit("finish");
				} else if (this[_needDrain]) {
					this[_needDrain] = false;
					this.emit("drain");
				}
			}
		}
	}
	[_flush]() {
		if (this[_queue].length === 0) {
			if (this[_ended]) this[_onwrite](null, 0);
		} else if (this[_queue].length === 1) this[_write](this[_queue].pop());
		else {
			const e = this[_queue];
			this[_queue] = [];
			writev$1(this[_fd], e, this[_pos], (e, t) => this[_onwrite](e, t));
		}
	}
	[_close]() {
		if (this[_autoClose] && typeof this[_fd] === "number") {
			const e = this[_fd];
			this[_fd] = void 0;
			fs$2.close(e, (e) => e ? this.emit("error", e) : this.emit("close"));
		}
	}
};
var WriteStreamSync = class extends WriteStream {
	[_open]() {
		let e;
		if (this[_defaultFlag] && this[_flags] === "r+") try {
			e = fs$2.openSync(this[_path], this[_flags], this[_mode]);
		} catch (e) {
			if (e?.code === "ENOENT") {
				this[_flags] = "w";
				return this[_open]();
			} else throw e;
		}
		else e = fs$2.openSync(this[_path], this[_flags], this[_mode]);
		this[_onopen](null, e);
	}
	[_close]() {
		if (this[_autoClose] && typeof this[_fd] === "number") {
			const e = this[_fd];
			this[_fd] = void 0;
			fs$2.closeSync(e);
			this.emit("close");
		}
	}
	[_write](e) {
		let t = true;
		try {
			this[_onwrite](null, fs$2.writeSync(this[_fd], e, 0, e.length, this[_pos]));
			t = false;
		} finally {
			if (t) try {
				this[_close]();
			} catch {}
		}
	}
};
//#endregion
//#region node_modules/.pnpm/tar@7.5.22_patch_hash=fd38a2350a01d3eec80c7c393b88647baea164251683cffc481cb3aa5df2a75c/node_modules/tar/dist/esm/options.js
const argmap = /* @__PURE__ */ new Map([
	["C", "cwd"],
	["f", "file"],
	["z", "gzip"],
	["P", "preservePaths"],
	["U", "unlink"],
	["strip-components", "strip"],
	["stripComponents", "strip"],
	["keep-newer", "newer"],
	["keepNewer", "newer"],
	["keep-newer-files", "newer"],
	["keepNewerFiles", "newer"],
	["k", "keep"],
	["keep-existing", "keep"],
	["keepExisting", "keep"],
	["m", "noMtime"],
	["no-mtime", "noMtime"],
	["p", "preserveOwner"],
	["L", "follow"],
	["h", "follow"],
	["onentry", "onReadEntry"]
]);
const isSyncFile = (e) => !!e.sync && !!e.file;
const isAsyncFile = (e) => !e.sync && !!e.file;
const isSyncNoFile = (e) => !!e.sync && !e.file;
const isAsyncNoFile = (e) => !e.sync && !e.file;
const isFile = (e) => !!e.file;
const dealiasKey = (e) => {
	const t = argmap.get(e);
	if (t) return t;
	return e;
};
const dealias = (e = {}) => {
	if (!e) return {};
	const t = {};
	for (const [n, r] of Object.entries(e)) {
		const e = dealiasKey(n);
		t[e] = r;
	}
	if (t.chmod === void 0 && t.noChmod === false) t.chmod = true;
	delete t.noChmod;
	return t;
};
//#endregion
//#region node_modules/.pnpm/tar@7.5.22_patch_hash=fd38a2350a01d3eec80c7c393b88647baea164251683cffc481cb3aa5df2a75c/node_modules/tar/dist/esm/make-command.js
const makeCommand = (e, t, n, r, i) => {
	return Object.assign((a = [], o, s) => {
		if (Array.isArray(a)) {
			o = a;
			a = {};
		}
		if (typeof o === "function") {
			s = o;
			o = void 0;
		}
		o = !o ? [] : Array.from(o);
		const c = dealias(a);
		i?.(c, o);
		if (isSyncFile(c)) {
			if (typeof s === "function") throw new TypeError("callback not supported for sync tar functions");
			return e(c, o);
		} else if (isAsyncFile(c)) {
			const e = t(c, o);
			return s ? e.then(() => s(), s) : e;
		} else if (isSyncNoFile(c)) {
			if (typeof s === "function") throw new TypeError("callback not supported for sync tar functions");
			return n(c, o);
		} else if (isAsyncNoFile(c)) {
			if (typeof s === "function") throw new TypeError("callback only supported with file option");
			return r(c, o);
		}
		throw new Error("impossible options??");
		/* c8 ignore stop */
	}, {
		syncFile: e,
		asyncFile: t,
		syncNoFile: n,
		asyncNoFile: r,
		validate: i
	});
};
//#endregion
//#region node_modules/.pnpm/minizlib@3.1.0_patch_hash=9669b7a5b10b7831ff19c6066787f9dbed0dca18685d6ea8a17bad8282c3f39c/node_modules/minizlib/dist/esm/constants.js
/* c8 ignore start */
const realZlibConstants = realZlib.constants || { ZLIB_VERNUM: 4736 };
/* c8 ignore stop */
const constants$1 = 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
}, realZlibConstants));
//#endregion
//#region node_modules/.pnpm/minizlib@3.1.0_patch_hash=9669b7a5b10b7831ff19c6066787f9dbed0dca18685d6ea8a17bad8282c3f39c/node_modules/minizlib/dist/esm/index.js
const _superWrite = Symbol("_superWrite");
var ZlibError = class extends Error {
	code;
	errno;
	constructor(e, t) {
		super("zlib: " + e.message, { cause: e });
		this.code = e.code;
		this.errno = e.errno;
		/* c8 ignore next */
		if (!this.code) this.code = "ZLIB_ERROR";
		this.message = "zlib: " + e.message;
		Error.captureStackTrace(this, t ?? this.constructor);
	}
	get name() {
		return "ZlibError";
	}
};
const _flushFlag = Symbol("flushFlag");
var ZlibBase = class extends Minipass {
	#e = false;
	#t = false;
	#n;
	#r;
	#i;
	#a;
	#o;
	get sawError() {
		return this.#e;
	}
	get handle() {
		return this.#a;
	}
	/* c8 ignore start */
	get flushFlag() {
		return this.#n;
	}
	/* c8 ignore stop */
	constructor(e, t) {
		if (!e || typeof e !== "object") throw new TypeError("invalid options for ZlibBase constructor");
		super(e);
		/* c8 ignore start */
		this.#n = e.flush ?? 0;
		this.#r = e.finishFlush ?? 0;
		this.#i = e.fullFlushFlag ?? 0;
		/* c8 ignore stop */
		if (typeof realZlib$1[t] !== "function") throw new TypeError("Compression method not supported: " + t);
		try {
			this.#a = new realZlib$1[t](e);
		} catch (e) {
			throw new ZlibError(e, this.constructor);
		}
		this.#o = (e) => {
			if (this.#e) return;
			this.#e = true;
			this.close();
			this.emit("error", e);
		};
		this.#a?.on("error", (e) => this.#o(new ZlibError(e)));
		this.once("end", () => this.close);
	}
	close() {
		if (this.#a) {
			this.#a.close();
			this.#a = void 0;
			this.emit("close");
		}
	}
	reset() {
		if (!this.#e) {
			assert(this.#a, "zlib binding closed");
			return this.#a.reset?.();
		}
	}
	flush(e) {
		if (this.ended) return;
		if (typeof e !== "number") e = this.#i;
		this.write(Object.assign(Buffer$1.alloc(0), { [_flushFlag]: e }));
	}
	end(e, t, n) {
		/* c8 ignore start */
		if (typeof e === "function") {
			n = e;
			t = void 0;
			e = void 0;
		}
		if (typeof t === "function") {
			n = t;
			t = void 0;
		}
		/* c8 ignore stop */
		if (e) {
			if (t) this.write(e, t);
			else this.write(e);
		}
		this.flush(this.#r);
		this.#t = true;
		return super.end(n);
	}
	get ended() {
		return this.#t;
	}
	[_superWrite](e) {
		return super.write(e);
	}
	write(e, t, n) {
		if (typeof t === "function") n = t, t = "utf8";
		if (typeof e === "string") e = Buffer$1.from(e, t);
		if (this.#e) return;
		assert(this.#a, "zlib binding closed");
		const r = this.#a._handle;
		const i = r.close;
		r.close = () => {};
		const a = this.#a.close;
		this.#a.close = () => {};
		let o = void 0;
		try {
			const t = typeof e[_flushFlag] === "number" ? e[_flushFlag] : this.#n;
			o = this.#a._processChunk(e, t);
		} catch (e) {
			this.#o(new ZlibError(e, this.write));
		} finally {
			if (this.#a) {
				this.#a._handle = r;
				r.close = i;
				this.#a.close = a;
				this.#a.removeAllListeners("error");
			}
		}
		if (this.#a) this.#a.on("error", (e) => this.#o(new ZlibError(e, this.write)));
		let s;
		if (o) s = this[_superWrite](Buffer$1.from(o));
		if (n) n();
		return s;
	}
};
var Zlib = class extends ZlibBase {
	#e;
	#t;
	constructor(e, t) {
		e = e || {};
		e.flush = e.flush || constants$1.Z_NO_FLUSH;
		e.finishFlush = e.finishFlush || constants$1.Z_FINISH;
		e.fullFlushFlag = constants$1.Z_FULL_FLUSH;
		super(e, t);
		this.#e = e.level;
		this.#t = e.strategy;
	}
	params(e, t) {
		if (this.sawError) return;
		if (!this.handle) throw new Error("cannot switch params when binding is closed");
		/* c8 ignore start */
		if (!this.handle.params) throw new Error("not supported in this implementation");
		/* c8 ignore stop */
		if (this.#e !== e || this.#t !== t) {
			this.flush(constants$1.Z_SYNC_FLUSH);
			assert(this.handle, "zlib binding closed");
			const n = this.handle.flush;
			this.handle.flush = (e, t) => {
				/* c8 ignore start */
				if (typeof e === "function") {
					t = e;
					e = this.flushFlag;
				}
				/* c8 ignore stop */
				this.flush(e);
				t?.();
			};
			try {
				this.handle.params(e, t);
			} finally {
				this.handle.flush = n;
			}
			/* c8 ignore start */
			if (this.handle) {
				this.#e = e;
				this.#t = t;
			}
		}
	}
};
var Gzip = class extends Zlib {
	#e;
	constructor(e) {
		super(e, "Gzip");
		this.#e = e && !!e.portable;
	}
	[_superWrite](e) {
		if (!this.#e) return super[_superWrite](e);
		this.#e = false;
		e[9] = 255;
		return super[_superWrite](e);
	}
};
var Unzip = class extends Zlib {
	constructor(e) {
		super(e, "Unzip");
	}
};
var Brotli = class extends ZlibBase {
	constructor(e, t) {
		e = e || {};
		e.flush = e.flush || constants$1.BROTLI_OPERATION_PROCESS;
		e.finishFlush = e.finishFlush || constants$1.BROTLI_OPERATION_FINISH;
		e.fullFlushFlag = constants$1.BROTLI_OPERATION_FLUSH;
		super(e, t);
	}
};
var BrotliCompress = class extends Brotli {
	constructor(e) {
		super(e, "BrotliCompress");
	}
};
var BrotliDecompress = class extends Brotli {
	constructor(e) {
		super(e, "BrotliDecompress");
	}
};
var Zstd = class extends ZlibBase {
	constructor(e, t) {
		e = e || {};
		e.flush = e.flush || constants$1.ZSTD_e_continue;
		e.finishFlush = e.finishFlush || constants$1.ZSTD_e_end;
		e.fullFlushFlag = constants$1.ZSTD_e_flush;
		super(e, t);
	}
};
var ZstdCompress = class extends Zstd {
	constructor(e) {
		super(e, "ZstdCompress");
	}
};
var ZstdDecompress = class extends Zstd {
	constructor(e) {
		super(e, "ZstdDecompress");
	}
};
//#endregion
//#region node_modules/.pnpm/tar@7.5.22_patch_hash=fd38a2350a01d3eec80c7c393b88647baea164251683cffc481cb3aa5df2a75c/node_modules/tar/dist/esm/large-numbers.js
const encode$1 = (e, t) => {
	if (!Number.isSafeInteger(e)) throw Error("cannot encode number outside of javascript safe integer range");
	else if (e < 0) encodeNegative(e, t);
	else encodePositive(e, t);
	return t;
};
const encodePositive = (e, t) => {
	t[0] = 128;
	for (var n = t.length; n > 1; n--) {
		t[n - 1] = e & 255;
		e = Math.floor(e / 256);
	}
};
const encodeNegative = (e, t) => {
	t[0] = 255;
	var n = false;
	e = e * -1;
	for (var r = t.length; r > 1; r--) {
		var i = e & 255;
		e = Math.floor(e / 256);
		if (n) t[r - 1] = onesComp(i);
		else if (i === 0) t[r - 1] = 0;
		else {
			n = true;
			t[r - 1] = twosComp(i);
		}
	}
};
const parse$3 = (e) => {
	const t = e[0];
	const n = t === 128 ? pos(e.subarray(1, e.length)) : t === 255 ? twos(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;
};
const twos = (e) => {
	var t = e.length;
	var n = 0;
	var r = false;
	for (var i = t - 1; i > -1; i--) {
		var a = Number(e[i]);
		var o;
		if (r) o = onesComp(a);
		else if (a === 0) o = a;
		else {
			r = true;
			o = twosComp(a);
		}
		if (o !== 0) n -= o * Math.pow(256, t - i - 1);
	}
	return n;
};
const pos = (e) => {
	var t = e.length;
	var n = 0;
	for (var r = t - 1; r > -1; r--) {
		var i = Number(e[r]);
		if (i !== 0) n += i * Math.pow(256, t - r - 1);
	}
	return n;
};
const onesComp = (e) => (255 ^ e) & 255;
const twosComp = (e) => (255 ^ e) + 1 & 255;
//#endregion
//#region node_modules/.pnpm/tar@7.5.22_patch_hash=fd38a2350a01d3eec80c7c393b88647baea164251683cffc481cb3aa5df2a75c/node_modules/tar/dist/esm/types.js
var types_exports = /* @__PURE__ */ __exportAll({
	code: () => code,
	isCode: () => isCode,
	isName: () => isName,
	name: () => name,
	normalFsTypes: () => normalFsTypes
});
const isCode = (e) => name.has(e);
const isName = (e) => code.has(e);
/**
* types that are a normal file system entry, not metadata.
*
* These can be the subject of extended/globalExtended headers, long path
* names, long linkpath names, etc.
*
* Any other types are meta, and cannot be targetted by extended PAX headers.
*/
const normalFsTypes = /* @__PURE__ */ new Set([
	"0",
	"",
	"1",
	"2",
	"3",
	"4",
	"5",
	"6",
	"7",
	"D"
]);
const name = /* @__PURE__ */ new Map([
	["0", "File"],
	["", "OldFile"],
	["1", "Link"],
	["2", "SymbolicLink"],
	["3", "CharacterDevice"],
	["4", "BlockDevice"],
	["5", "Directory"],
	["6", "FIFO"],
	["7", "ContiguousFile"],
	["g", "GlobalExtendedHeader"],
	["x", "ExtendedHeader"],
	["A", "SolarisACL"],
	["D", "GNUDumpDir"],
	["I", "Inode"],
	["K", "NextFileHasLongLinkpath"],
	["L", "NextFileHasLongPath"],
	["M", "ContinuationFile"],
	["N", "OldGnuLongPath"],
	["S", "SparseFile"],
	["V", "TapeVolumeHeader"],
	["X", "OldExtendedHeader"]
]);
const code = new Map(Array.from(name).map((e) => [e[1], e[0]]));
//#endregion
//#region node_modules/.pnpm/tar@7.5.22_patch_hash=fd38a2350a01d3eec80c7c393b88647baea164251683cffc481cb3aa5df2a75c/node_modules/tar/dist/esm/header.js
const notNegative = (e) => e === void 0 || e < 0 ? void 0 : e;
var Header = class {
	cksumValid = false;
	needPax = false;
	nullBlock = false;
	block;
	path;
	mode;
	uid;
	gid;
	size;
	cksum;
	#e = "Unsupported";
	linkpath;
	uname;
	gname;
	devmaj = 0;
	devmin = 0;
	atime;
	ctime;
	mtime;
	charset;
	comment;
	constructor(e, t = 0, n, r) {
		if (Buffer.isBuffer(e)) this.decode(e, t || 0, n, r);
		else if (e) this.#t(e);
	}
	decode(e, t, n, r) {
		if (!t) t = 0;
		if (!e || !(e.length >= t + 512)) throw new Error("need 512 bytes for header");
		const i = decString(e, t + 156, 1);
		const a = normalFsTypes.has(i);
		const o = a ? n : void 0;
		const s = a ? r : void 0;
		this.path = o?.path ?? decString(e, t, 100);
		this.mode = o?.mode ?? s?.mode ?? decNumber(e, t + 100, 8);
		this.uid = o?.uid ?? s?.uid ?? decNumber(e, t + 108, 8);
		this.gid = o?.gid ?? s?.gid ?? decNumber(e, t + 116, 8);
		this.size = notNegative(o?.size ?? s?.size ?? decNumber(e, t + 124, 12));
		this.mtime = o?.mtime ?? s?.mtime ?? decDate(e, t + 136, 12);
		this.cksum = decNumber(e, t + 148, 12);
		if (s) this.#t(s, true);
		if (o) this.#t(o);
		if (isCode(i)) this.#e = i || "0";
		if (this.#e === "0" && this.path.slice(-1) === "/") this.#e = "5";
		if (this.#e === "5") this.size = 0;
		this.linkpath = decString(e, t + 157, 100);
		if (e.subarray(t + 257, t + 265).toString() === "ustar\x0000") {
			/* c8 ignore start */
			this.uname = o?.uname ?? s?.uname ?? decString(e, t + 265, 32);
			this.gname = o?.gname ?? s?.gname ?? decString(e, t + 297, 32);
			this.devmaj = o?.devmaj ?? s?.devmaj ?? decNumber(e, t + 329, 8) ?? 0;
			this.devmin = o?.devmin ?? s?.devmin ?? decNumber(e, t + 337, 8) ?? 0;
			/* c8 ignore stop */
			if (e[t + 475] !== 0) {
				const n = decString(e, t + 345, 155);
				this.path = n + "/" + this.path;
			} else {
				const i = decString(e, t + 345, 130);
				if (i) this.path = i + "/" + this.path;
				/* c8 ignore start */
				this.atime = n?.atime ?? r?.atime ?? decDate(e, t + 476, 12);
				this.ctime = n?.ctime ?? r?.ctime ?? decDate(e, t + 488, 12);
			}
		}
		let c = 256;
		for (let n = t; n < t + 148; n++) c += e[n];
		for (let n = t + 156; n < t + 512; n++) c += e[n];
		this.cksumValid = c === this.cksum;
		if (this.cksum === void 0 && c === 256) this.nullBlock = true;
	}
	#t(e, t = false) {
		Object.assign(this, Object.fromEntries(Object.entries(e).filter(([e, n]) => {
			return !(n === null || n === void 0 || e === "size" && Number(n) < 0 || e === "path" && t || e === "linkpath" && t || e === "global");
		})));
	}
	encode(e, t = 0) {
		if (!e) e = this.block = Buffer.alloc(512);
		if (this.#e === "Unsupported") this.#e = "0";
		if (!(e.length >= t + 512)) throw new Error("need 512 bytes for header");
		const n = this.ctime || this.atime ? 130 : 155;
		const r = splitPrefix(this.path || "", n);
		const i = r[0];
		const a = r[1];
		this.needPax = !!r[2];
		this.needPax = encString(e, t, 100, i) || this.needPax;
		this.needPax = encNumber(e, t + 100, 8, this.mode) || this.needPax;
		this.needPax = encNumber(e, t + 108, 8, this.uid) || this.needPax;
		this.needPax = encNumber(e, t + 116, 8, this.gid) || this.needPax;
		this.needPax = encNumber(e, t + 124, 12, this.size) || this.needPax;
		this.needPax = encDate(e, t + 136, 12, this.mtime) || this.needPax;
		e[t + 156] = Number(this.#e.codePointAt(0));
		this.needPax = encString(e, t + 157, 100, this.linkpath) || this.needPax;
		e.write("ustar\x0000", t + 257, 8);
		this.needPax = encString(e, t + 265, 32, this.uname) || this.needPax;
		this.needPax = encString(e, t + 297, 32, this.gname) || this.needPax;
		this.needPax = encNumber(e, t + 329, 8, this.devmaj) || this.needPax;
		this.needPax = encNumber(e, t + 337, 8, this.devmin) || this.needPax;
		this.needPax = encString(e, t + 345, n, a) || this.needPax;
		if (e[t + 475] !== 0) this.needPax = encString(e, t + 345, 155, a) || this.needPax;
		else {
			this.needPax = encString(e, t + 345, 130, a) || this.needPax;
			this.needPax = encDate(e, t + 476, 12, this.atime) || this.needPax;
			this.needPax = encDate(e, t + 488, 12, this.ctime) || 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];
		this.cksum = o;
		encNumber(e, t + 148, 8, this.cksum);
		this.cksumValid = true;
		return this.needPax;
	}
	get type() {
		return this.#e === "Unsupported" ? this.#e : name.get(this.#e);
	}
	get typeKey() {
		return this.#e;
	}
	set type(e) {
		const t = String(code.get(e));
		if (isCode(t) || t === "Unsupported") this.#e = t;
		else if (isCode(e)) this.#e = e;
		else throw new TypeError("invalid entry type: " + e);
	}
};
const splitPrefix = (e, t) => {
	const n = 100;
	let r = e;
	let i = "";
	let a = void 0;
	const o = posix.parse(e).root || ".";
	if (Buffer.byteLength(r) < n) a = [
		r,
		i,
		false
	];
	else {
		i = posix.dirname(r);
		r = posix.basename(r);
		do
			if (Buffer.byteLength(r) <= n && Buffer.byteLength(i) <= t) a = [
				r,
				i,
				false
			];
			else if (Buffer.byteLength(r) > n && Buffer.byteLength(i) <= t) a = [
				r.slice(0, 99),
				i,
				true
			];
			else {
				r = posix.join(posix.basename(i), r);
				i = posix.dirname(i);
			}
		while (i !== o && a === void 0);
		if (!a) a = [
			e.slice(0, 99),
			"",
			true
		];
	}
	return a;
};
const decString = (e, t, n) => e.subarray(t, t + n).toString("utf8").replace(/\0.*/, "");
const decDate = (e, t, n) => numToDate(decNumber(e, t, n));
const numToDate = (e) => e === void 0 ? void 0 : /* @__PURE__ */ new Date(e * 1e3);
const decNumber = (e, t, n) => Number(e[t]) & 128 ? parse$3(e.subarray(t, t + n)) : decSmallNumber(e, t, n);
const nanUndef = (e) => isNaN(e) ? void 0 : e;
const decSmallNumber = (e, t, n) => nanUndef(parseInt(e.subarray(t, t + n).toString("utf8").replace(/\0.*$/, "").trim(), 8));
const MAXNUM = {
	12: 8589934591,
	8: 2097151
};
const encNumber = (e, t, n, r) => r === void 0 ? false : r > MAXNUM[n] || r < 0 ? (encode$1(r, e.subarray(t, t + n)), true) : (encSmallNumber(e, t, n, r), false);
const encSmallNumber = (e, t, n, r) => e.write(octalString(r, n), t, n, "ascii");
const octalString = (e, t) => padOctal(Math.floor(e).toString(8), t);
const padOctal = (e, t) => (e.length === t - 1 ? e : new Array(t - e.length - 1).join("0") + e + " ") + "\0";
const encDate = (e, t, n, r) => r === void 0 ? false : encNumber(e, t, n, r.getTime() / 1e3);
const NULLS = new Array(156).join("\0");
const encString = (e, t, n, r) => r === void 0 ? false : (e.write(r + NULLS, t, n, "utf8"), r.length !== Buffer.byteLength(r) || r.length > n);
//#endregion
//#region node_modules/.pnpm/tar@7.5.22_patch_hash=fd38a2350a01d3eec80c7c393b88647baea164251683cffc481cb3aa5df2a75c/node_modules/tar/dist/esm/pax.js
var Pax = class Pax {
	atime;
	mtime;
	ctime;
	charset;
	comment;
	gid;
	uid;
	gname;
	uname;
	linkpath;
	dev;
	ino;
	nlink;
	path;
	size;
	mode;
	global;
	constructor(e, t = false) {
		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() {
		const e = this.encodeBody();
		if (e === "") return Buffer.allocUnsafe(0);
		const t = Buffer.byteLength(e);
		const n = 512 * Math.ceil(1 + t / 512);
		const r = Buffer.allocUnsafe(n);
		for (let e = 0; e < 512; e++) r[e] = 0;
		new Header({
			/* c8 ignore start */
			path: ("PaxHeader/" + basename(this.path ?? "")).slice(0, 99),
			/* c8 ignore stop */
			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 "";
		const t = this[e];
		const n = t instanceof Date ? t.getTime() / 1e3 : t;
		const r = " " + (e === "dev" || e === "ino" || e === "nlink" ? "SCHILY." : "") + e + "=" + n + "\n";
		const i = Buffer.byteLength(r);
		let a = Math.floor(Math.log(i) / Math.log(10)) + 1;
		if (i + a >= Math.pow(10, a)) a += 1;
		return a + i + r;
	}
	static parse(e, t, n = false) {
		return new Pax(merge(parseKV(e), t), n);
	}
};
const merge = (e, t) => t ? Object.assign({}, t, e) : e;
const parseKV = (e) => e.replace(/\n$/, "").split("\n").reduce(parseKVLine, Object.create(null));
const parseKVLine = (e, t) => {
	const n = parseInt(t, 10);
	if (n !== Buffer.byteLength(t) + 1) return e;
	t = t.slice((n + " ").length);
	const r = t.split("=");
	const i = r.shift();
	if (!i) return e;
	const a = i.replace(/^SCHILY\.(dev|ino|nlink)/, "$1");
	const o = r.join("=").replace(/\0.*/, "");
	switch (a) {
		case "path":
		case "linkpath":
		case "type":
		case "charset":
		case "comment":
		case "gname":
		case "uname":
			e[a] = o;
			break;
		case "ctime":
		case "atime":
		case "mtime":
			e[a] = /* @__PURE__ */ new Date(Number(o) * 1e3);
			break;
		case "size":
			const t = +o;
			if (t >= 0) e[a] = t;
			break;
		case "gid":
		case "uid":
		case "dev":
		case "ino":
		case "nlink":
		case "mode": e[a] = +o;
	}
	return e;
};
//#endregion
//#region node_modules/.pnpm/tar@7.5.22_patch_hash=fd38a2350a01d3eec80c7c393b88647baea164251683cffc481cb3aa5df2a75c/node_modules/tar/dist/esm/normalize-windows-path.js
const platform = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
const normalizeWindowsPath = platform !== "win32" ? (e) => String(e) : (e) => String(e).replaceAll(/\\/g, "/");
//#endregion
//#region node_modules/.pnpm/tar@7.5.22_patch_hash=fd38a2350a01d3eec80c7c393b88647baea164251683cffc481cb3aa5df2a75c/node_modules/tar/dist/esm/read-entry.js
var ReadEntry = class extends Minipass {
	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(e, t, n) {
		super({});
		this.pause();
		this.extended = t;
		this.globalExtended = n;
		this.header = e;
		/* c8 ignore start */
		this.remain = e.size ?? 0;
		/* c8 ignore stop */
		this.startBlockSize = 512 * Math.ceil(this.remain / 512);
		this.blockRemain = this.startBlockSize;
		this.type = e.type;
		switch (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;
		}
		/* c8 ignore start */
		if (!e.path) throw new Error("no path provided for tar.ReadEntry");
		/* c8 ignore stop */
		this.path = normalizeWindowsPath(e.path);
		this.mode = e.mode;
		if (this.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;
		/* c8 ignore start */
		this.linkpath = e.linkpath ? normalizeWindowsPath(e.linkpath) : void 0;
		/* c8 ignore stop */
		this.uname = e.uname;
		this.gname = e.gname;
		if (t) this.#e(t);
		if (n) this.#e(n, true);
	}
	write(e) {
		const t = e.length;
		if (t > this.blockRemain) throw new Error("writing more to entry than is appropriate");
		const n = this.remain;
		const r = this.blockRemain;
		this.remain = Math.max(0, n - t);
		this.blockRemain = Math.max(0, r - t);
		if (this.ignore) return true;
		if (n >= t) return super.write(e);
		return super.write(e.subarray(0, n));
	}
	#e(e, t = false) {
		if (e.path) e.path = normalizeWindowsPath(e.path);
		if (e.linkpath) e.linkpath = normalizeWindowsPath(e.linkpath);
		Object.assign(this, Object.fromEntries(Object.entries(e).filter(([e, n]) => {
			return !(n === null || n === void 0 || e === "path" && t);
		})));
	}
};
//#endregion
//#region node_modules/.pnpm/tar@7.5.22_patch_hash=fd38a2350a01d3eec80c7c393b88647baea164251683cffc481cb3aa5df2a75c/node_modules/tar/dist/esm/warn-method.js
const warnMethod = (e, t, n, r = {}) => {
	if (e.file) r.file = e.file;
	if (e.cwd) r.cwd = e.cwd;
	r.code = n instanceof Error && n.code || t;
	r.tarCode = t;
	if (!e.strict && r.recoverable !== false) {
		if (n instanceof Error) {
			r = Object.assign(n, r);
			n = n.message;
		}
		e.emit("warn", t, n, r);
	} else if (n instanceof Error) e.emit("error", Object.assign(n, r));
	else e.emit("error", Object.assign(/* @__PURE__ */ new Error(`${t}: ${n}`), r));
};
//#endregion
//#region node_modules/.pnpm/tar@7.5.22_patch_hash=fd38a2350a01d3eec80c7c393b88647baea164251683cffc481cb3aa5df2a75c/node_modules/tar/dist/esm/parse.js
const maxMetaEntrySize = 1048576;
const gzipHeader = Buffer.from([31, 139]);
const zstdHeader = Buffer.from([
	40,
	181,
	47,
	253
]);
const ZIP_HEADER_LEN = Math.max(gzipHeader.length, zstdHeader.length);
const STATE = Symbol("state");
const WRITEENTRY = Symbol("writeEntry");
const READENTRY = Symbol("readEntry");
const NEXTENTRY = Symbol("nextEntry");
const PROCESSENTRY = Symbol("processEntry");
const EX = Symbol("extendedHeader");
const GEX = Symbol("globalExtendedHeader");
const META = Symbol("meta");
const EMITMETA = Symbol("emitMeta");
const BUFFER = Symbol("buffer");
const QUEUE$1 = Symbol("queue");
const ENDED$2 = Symbol("ended");
const EMITTEDEND = Symbol("emittedEnd");
const EMIT = Symbol("emit");
const UNZIP = Symbol("unzip");
const CONSUMECHUNK = Symbol("consumeChunk");
const CONSUMECHUNKSUB = Symbol("consumeChunkSub");
const CONSUMEBODY = Symbol("consumeBody");
const CONSUMEMETA = Symbol("consumeMeta");
const CONSUMEHEADER = Symbol("consumeHeader");
const CONSUMING = Symbol("consuming");
const BUFFERCONCAT = Symbol("bufferConcat");
const MAYBEEND = Symbol("maybeEnd");
const WRITING = Symbol("writing");
const ABORTED = Symbol("aborted");
const DONE = Symbol("onDone");
const SAW_VALID_ENTRY = Symbol("sawValidEntry");
const SAW_NULL_BLOCK = Symbol("sawNullBlock");
const SAW_EOF = Symbol("sawEOF");
const CLOSESTREAM = Symbol("closeStream");
const MAX_DECOMPRESSION_RATIO = 1e3;
const COMPRESSEDBYTESREAD = Symbol("compressedBytesRead");
const DECOMPRESSEDBYTESREAD = Symbol("decompressedBytesRead");
const CHECKDECOMPRESSIONRATIO = Symbol("checkDecompressionRatio");
const noop = () => true;
var Parser = class extends EventEmitter$1 {
	file;
	strict;
	maxMetaEntrySize;
	filter;
	brotli;
	zstd;
	maxDecompressionRatio;
	writable = true;
	readable = false;
	[QUEUE$1] = [];
	[BUFFER];
	[READENTRY];
	[WRITEENTRY];
	[STATE] = "begin";
	[META] = "";
	[EX];
	[GEX];
	[ENDED$2] = false;
	[UNZIP];
	[ABORTED] = false;
	[SAW_VALID_ENTRY];
	[SAW_NULL_BLOCK] = false;
	[SAW_EOF] = false;
	[WRITING] = false;
	[CONSUMING] = false;
	[EMITTEDEND] = false;
	[COMPRESSEDBYTESREAD] = 0;
	[DECOMPRESSEDBYTESREAD] = 0;
	constructor(e = {}) {
		super();
		this.file = e.file || "";
		this.on(DONE, () => {
			if (this[STATE] === "begin" || this[SAW_VALID_ENTRY] === false) this.warn("TAR_BAD_ARCHIVE", "Unrecognized archive format");
		});
		if (e.ondone) this.on(DONE, e.ondone);
		else this.on(DONE, () => {
			this.emit("prefinish");
			this.emit("finish");
			this.emit("end");
		});
		this.strict = !!e.strict;
		this.maxDecompressionRatio = typeof e.maxDecompressionRatio === "number" ? e.maxDecompressionRatio : MAX_DECOMPRESSION_RATIO;
		this.maxMetaEntrySize = e.maxMetaEntrySize || maxMetaEntrySize;
		this.filter = typeof e.filter === "function" ? e.filter : noop;
		const 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 : false;
		const 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 ? true : void 0;
		this.on("end", () => this[CLOSESTREAM]());
		if (typeof e.onwarn === "function") this.on("warn", e.onwarn);
		if (typeof e.onReadEntry === "function") this.on("entry", e.onReadEntry);
	}
	warn(e, t, n = {}) {
		warnMethod(this, e, t, n);
	}
	[CONSUMEHEADER](e, t) {
		if (this[SAW_VALID_ENTRY] === void 0) this[SAW_VALID_ENTRY] = false;
		let n;
		try {
			n = new Header(e, t, this[EX], this[GEX]);
		} catch (e) {
			return this.warn("TAR_ENTRY_INVALID", e);
		}
		if (n.nullBlock) {
			if (this[SAW_NULL_BLOCK]) {
				this[SAW_EOF] = true;
				if (this[STATE] === "begin") this[STATE] = "header";
				this[EMIT]("eof");
			} else {
				this[SAW_NULL_BLOCK] = true;
				this[EMIT]("nullBlock");
			}
		} else {
			this[SAW_NULL_BLOCK] = false;
			if (!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 {
				const 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 {
					const e = this[WRITEENTRY] = new ReadEntry(n, this[EX], this[GEX]);
					if (!this[SAW_VALID_ENTRY]) {
						if (e.remain) {
							const onend = () => {
								if (!e.invalid) this[SAW_VALID_ENTRY] = true;
							};
							e.on("end", onend);
						} else this[SAW_VALID_ENTRY] = true;
					}
					if (e.meta) {
						if (e.size > this.maxMetaEntrySize) {
							e.ignore = true;
							this[EMIT]("ignoredEntry", e);
							this[STATE] = "ignore";
							e.resume();
						} else if (e.size > 0) {
							this[META] = "";
							e.on("data", (e) => this[META] += e);
							this[STATE] = "meta";
						}
					} else {
						this[EX] = void 0;
						e.ignore = e.ignore || !this.filter(e.path, e);
						if (e.ignore) {
							this[EMIT]("ignoredEntry", e);
							this[STATE] = e.remain ? "ignore" : "header";
							e.resume();
						} else {
							if (e.remain) this[STATE] = "body";
							else {
								this[STATE] = "header";
								e.end();
							}
							if (!this[READENTRY]) {
								this[QUEUE$1].push(e);
								this[NEXTENTRY]();
							} else this[QUEUE$1].push(e);
						}
					}
				}
			}
		}
	}
	[CLOSESTREAM]() {
		queueMicrotask(() => this.emit("close"));
	}
	[PROCESSENTRY](e) {
		let t = true;
		if (!e) {
			this[READENTRY] = void 0;
			t = false;
		} else if (Array.isArray(e)) {
			const [t, ...n] = e;
			this.emit(t, ...n);
		} else {
			this[READENTRY] = e;
			this.emit("entry", e);
			if (!e.emittedEnd) {
				e.on("end", () => this[NEXTENTRY]());
				t = false;
			}
		}
		return t;
	}
	[NEXTENTRY]() {
		do;
		while (this[PROCESSENTRY](this[QUEUE$1].shift()));
		if (this[QUEUE$1].length === 0) {
			const e = this[READENTRY];
			if (!e || e.flowing || e.size === e.remain) {
				if (!this[WRITING]) this.emit("drain");
			} else e.once("drain", () => this.emit("drain"));
		}
	}
	[CONSUMEBODY](e, t) {
		const n = this[WRITEENTRY];
		/* c8 ignore start */
		if (!n) throw new Error("attempt to consume body without entry??");
		const r = n.blockRemain ?? 0;
		/* c8 ignore stop */
		const i = r >= e.length && t === 0 ? e : e.subarray(t, t + r);
		n.write(i);
		if (!n.blockRemain) {
			this[STATE] = "header";
			this[WRITEENTRY] = void 0;
			n.end();
		}
		return i.length;
	}
	[CONSUMEMETA](e, t) {
		const n = this[WRITEENTRY];
		const r = this[CONSUMEBODY](e, t);
		if (!this[WRITEENTRY] && n) this[EMITMETA](n);
		return r;
	}
	[EMIT](e, t, n) {
		if (this[QUEUE$1].length === 0 && !this[READENTRY]) this.emit(e, t, n);
		else this[QUEUE$1].push([
			e,
			t,
			n
		]);
	}
	[EMITMETA](e) {
		this[EMIT]("meta", this[META]);
		switch (e.type) {
			case "ExtendedHeader":
			case "OldExtendedHeader":
				this[EX] = Pax.parse(this[META], this[EX], false);
				break;
			case "GlobalExtendedHeader":
				this[GEX] = Pax.parse(this[META], this[GEX], true);
				break;
			case "NextFileHasLongPath":
			case "OldGnuLongPath": {
				const e = this[EX] ?? Object.create(null);
				this[EX] = e;
				e.path = this[META].replace(/\0.*/, "");
				break;
			}
			case "NextFileHasLongLinkpath": {
				const e = this[EX] || Object.create(null);
				this[EX] = e;
				e.linkpath = this[META].replace(/\0.*/, "");
				break;
			}
			/* c8 ignore start */
			default: throw new Error("unknown meta: " + e.type);
		}
	}
	abort(e) {
		if (this[ABORTED]) return;
		if (this[UNZIP]) {
			const e = this[UNZIP];
			/* c8 ignore start */
			e.write = () => true;
			e.end = () => e;
			e.emit = () => false;
			/* c8 ignore stop */
			e.destroy?.();
		}
		this[ABORTED] = true;
		this.emit("abort", e);
		this.warn("TAR_ABORT", e, { recoverable: false });
	}
	[CHECKDECOMPRESSIONRATIO](e) {
		this[DECOMPRESSEDBYTESREAD] += e.length;
		const t = this[DECOMPRESSEDBYTESREAD] / this[COMPRESSEDBYTESREAD];
		if (t > this.maxDecompressionRatio) {
			this.abort(/* @__PURE__ */ new Error(`max decompression ratio exceeded: ${t.toFixed(2)} > ${this.maxDecompressionRatio}`));
			return false;
		}
		return true;
	}
	write(e, t, n) {
		if (typeof t === "function") {
			n = t;
			t = void 0;
		}
		if (typeof e === "string") e = Buffer.from(
			e,
			/* c8 ignore next */
			typeof t === "string" ? t : "utf8"
		);
		if (this[ABORTED]) {
			/* c8 ignore next */
			n?.();
			return false;
		}
		if ((this[UNZIP] === void 0 || this.brotli === void 0 && this[UNZIP] === false) && e) {
			if (this[BUFFER]) {
				e = Buffer.concat([this[BUFFER], e]);
				this[BUFFER] = void 0;
			}
			if (e.length < ZIP_HEADER_LEN) {
				this[BUFFER] = e;
				/* c8 ignore next */
				n?.();
				return true;
			}
			for (let t = 0; this[UNZIP] === void 0 && t < gzipHeader.length; t++) if (e[t] !== gzipHeader[t]) this[UNZIP] = false;
			let t = false;
			if (this[UNZIP] === false && this.zstd !== false) {
				t = true;
				for (let n = 0; n < zstdHeader.length; n++) if (e[n] !== zstdHeader[n]) {
					t = false;
					break;
				}
			}
			const r = this.brotli === void 0 && !t;
			if (this[UNZIP] === false && r) {
				if (e.length < 512) {
					if (this[ENDED$2]) this.brotli = true;
					else {
						this[BUFFER] = e;
						/* c8 ignore next */
						n?.();
						return true;
					}
				} else try {
					new Header(e.subarray(0, 512));
					this.brotli = false;
				} catch (e) {
					this.brotli = true;
				}
			}
			if (this[UNZIP] === void 0 || this[UNZIP] === false && (this.brotli || t)) {
				const r = this[ENDED$2];
				this[ENDED$2] = false;
				this[UNZIP] = this[UNZIP] === void 0 ? new Unzip({}) : t ? new ZstdDecompress({}) : new BrotliDecompress({});
				this[UNZIP].on("data", (e) => {
					if (this[CHECKDECOMPRESSIONRATIO](e)) this[CONSUMECHUNK](e);
				});
				this[UNZIP].on("error", (e) => {
					if (!this[ABORTED]) this.abort(e);
				});
				this[UNZIP].on("end", () => {
					this[ENDED$2] = true;
					this[CONSUMECHUNK]();
				});
				this[WRITING] = true;
				this[COMPRESSEDBYTESREAD] += e.length;
				const i = !!this[UNZIP][r ? "end" : "write"](e);
				this[WRITING] = false;
				n?.();
				return i;
			}
		}
		this[WRITING] = true;
		if (this[UNZIP]) {
			this[COMPRESSEDBYTESREAD] += e.length;
			this[UNZIP].write(e);
		} else this[CONSUMECHUNK](e);
		this[WRITING] = false;
		const r = this[QUEUE$1].length > 0 ? false : this[READENTRY] ? this[READENTRY].flowing : true;
		if (!r && this[QUEUE$1].length === 0) this[READENTRY]?.once("drain", () => this.emit("drain"));
		/* c8 ignore next */
		n?.();
		return r;
	}
	[BUFFERCONCAT](e) {
		if (e && !this[ABORTED]) this[BUFFER] = this[BUFFER] ? Buffer.concat([this[BUFFER], e]) : e;
	}
	[MAYBEEND]() {
		if (this[ENDED$2] && !this[EMITTEDEND] && !this[ABORTED] && !this[CONSUMING]) {
			this[EMITTEDEND] = true;
			const e = this[WRITEENTRY];
			if (e?.blockRemain) {
				const t = this[BUFFER] ? this[BUFFER].length : 0;
				this.warn("TAR_BAD_ARCHIVE", `Truncated input (needed ${e.blockRemain} more bytes, only ${t} available)`, { entry: e });
				if (this[BUFFER]) e.write(this[BUFFER]);
				e.end();
			}
			this[EMIT](DONE);
		}
	}
	[CONSUMECHUNK](e) {
		if (this[CONSUMING] && e) this[BUFFERCONCAT](e);
		else if (!e && !this[BUFFER]) this[MAYBEEND]();
		else if (e) {
			this[CONSUMING] = true;
			if (this[BUFFER]) {
				this[BUFFERCONCAT](e);
				const t = this[BUFFER];
				this[BUFFER] = void 0;
				this[CONSUMECHUNKSUB](t);
			} else this[CONSUMECHUNKSUB](e);
			while (this[BUFFER] && this[BUFFER]?.length >= 512 && !this[ABORTED] && !this[SAW_EOF]) {
				const e = this[BUFFER];
				this[BUFFER] = void 0;
				this[CONSUMECHUNKSUB](e);
			}
			this[CONSUMING] = false;
		}
		if (!this[BUFFER] || this[ENDED$2]) this[MAYBEEND]();
	}
	[CONSUMECHUNKSUB](e) {
		let t = 0;
		const n = e.length;
		while (t + 512 <= n && !this[ABORTED] && !this[SAW_EOF]) switch (this[STATE]) {
			case "begin":
			case "header":
				this[CONSUMEHEADER](e, t);
				t += 512;
				break;
			case "ignore":
			case "body":
				t += this[CONSUMEBODY](e, t);
				break;
			case "meta":
				t += this[CONSUMEMETA](e, t);
				break;
			/* c8 ignore start */
			default: throw new Error("invalid state: " + this[STATE]);
		}
		if (t < n) this[BUFFER] = this[BUFFER] ? Buffer.concat([e.subarray(t), this[BUFFER]]) : e.subarray(t);
	}
	end(e, t, n) {
		if (typeof e === "function") {
			n = e;
			t = void 0;
			e = void 0;
		}
		if (typeof t === "function") {
			n = t;
			t = void 0;
		}
		if (typeof e === "string") e = Buffer.from(e, t);
		if (n) this.once("finish", n);
		if (!this[ABORTED]) {
			if (this[UNZIP]) {
				/* c8 ignore start */
				if (e) {
					this[COMPRESSEDBYTESREAD] += e.length;
					this[UNZIP].write(e);
				}
				/* c8 ignore stop */
				this[UNZIP].end();
			} else {
				this[ENDED$2] = true;
				if (this.brotli === void 0 || this.zstd === void 0) e = e || Buffer.alloc(0);
				if (e) this.write(e);
				this[MAYBEEND]();
			}
		}
		return this;
	}
};
//#endregion
//#region node_modules/.pnpm/tar@7.5.22_patch_hash=fd38a2350a01d3eec80c7c393b88647baea164251683cffc481cb3aa5df2a75c/node_modules/tar/dist/esm/strip-trailing-slashes.js
const stripTrailingSlashes = (e) => {
	let t = e.length - 1;
	let n = -1;
	while (t > -1 && e.charAt(t) === "/") {
		n = t;
		t--;
	}
	return n === -1 ? e : e.slice(0, n);
};
//#endregion
//#region node_modules/.pnpm/tar@7.5.22_patch_hash=fd38a2350a01d3eec80c7c393b88647baea164251683cffc481cb3aa5df2a75c/node_modules/tar/dist/esm/list.js
const onReadEntryFunction = (e) => {
	const t = e.onReadEntry;
	e.onReadEntry = t ? (e) => {
		t(e);
		e.resume();
	} : (e) => e.resume();
};
const filesFilter = (e, t) => {
	const n = new Map(t.map((e) => [stripTrailingSlashes(e), true]));
	const r = e.filter;
	const i = 100;
	const mapHas = (e, t = "", r = 0) => {
		/* c8 ignore start - excessive caution */
		if (r >= i) {
			n.set(e, false);
			return false;
		}
		/* c8 ignore stop */
		const a = t || parse$1(e).root || ".";
		let o;
		if (e === a) o = false;
		else {
			const t = n.get(e);
			o = t !== void 0 ? t : mapHas(dirname$1(e), a, r + 1);
		}
		n.set(e, o);
		return o;
	};
	e.filter = r ? (e, t) => r(e, t) && mapHas(stripTrailingSlashes(e)) : (e) => mapHas(stripTrailingSlashes(e));
};
const listFileSync = (e) => {
	const t = new Parser(e);
	const n = e.file;
	let r;
	try {
		r = fs.openSync(n, "r");
		const i = fs.fstatSync(r);
		const a = e.maxReadSize || 16777216;
		if (i.size < a) {
			const e = Buffer.allocUnsafe(i.size);
			const n = fs.readSync(r, e, 0, i.size, 0);
			t.end(n === e.byteLength ? e : e.subarray(0, n));
		} else {
			let e = 0;
			const n = Buffer.allocUnsafe(a);
			while (e < i.size) {
				const i = fs.readSync(r, n, 0, a, e);
				if (i === 0) break;
				e += i;
				t.write(n.subarray(0, i));
			}
			t.end();
		}
	} finally {
		if (typeof r === "number") try {
			fs.closeSync(r);
		} catch {}
	}
};
const listFile = (e, t) => {
	const n = new Parser(e);
	const r = e.maxReadSize || 16777216;
	const i = e.file;
	return new Promise((e, t) => {
		n.on("error", t);
		n.on("end", e);
		fs.stat(i, (e, a) => {
			if (e) t(e);
			else {
				const e = new ReadStream$1(i, {
					readSize: r,
					size: a.size
				});
				e.on("error", t);
				e.pipe(n);
			}
		});
	});
};
const list = makeCommand(listFileSync, listFile, (e) => new Parser(e), (e) => new Parser(e), (e, t) => {
	if (t?.length) filesFilter(e, t);
	if (!e.noResume) onReadEntryFunction(e);
});
//#endregion
//#region node_modules/.pnpm/tar@7.5.22_patch_hash=fd38a2350a01d3eec80c7c393b88647baea164251683cffc481cb3aa5df2a75c/node_modules/tar/dist/esm/mode-fix.js
const modeFix = (e, t, n) => {
	e &= 4095;
	if (n) e = (e | 384) & -19;
	if (t) {
		if (e & 256) e |= 64;
		if (e & 32) e |= 8;
		if (e & 4) e |= 1;
	}
	return e;
};
//#endregion
//#region node_modules/.pnpm/tar@7.5.22_patch_hash=fd38a2350a01d3eec80c7c393b88647baea164251683cffc481cb3aa5df2a75c/node_modules/tar/dist/esm/strip-absolute-path.js
const { isAbsolute: isAbsolute$1, parse: parse$2 } = win32;
const stripAbsolutePath = (e) => {
	let t = "";
	let n = parse$2(e);
	while (isAbsolute$1(e) || n.root) {
		const r = e.charAt(0) === "/" && e.slice(0, 4) !== "//?/" ? "/" : n.root;
		e = e.slice(r.length);
		t += r;
		n = parse$2(e);
	}
	return [t, e];
};
//#endregion
//#region node_modules/.pnpm/tar@7.5.22_patch_hash=fd38a2350a01d3eec80c7c393b88647baea164251683cffc481cb3aa5df2a75c/node_modules/tar/dist/esm/winchars.js
const raw = [
	"|",
	"<",
	">",
	"?",
	":"
];
const win = raw.map((e) => String.fromCodePoint(61440 + Number(e.codePointAt(0))));
const toWin = new Map(raw.map((e, t) => [e, win[t]]));
const toRaw = new Map(win.map((e, t) => [e, raw[t]]));
const encode = (e) => raw.reduce((e, t) => e.split(t).join(toWin.get(t)), e);
const decode = (e) => win.reduce((e, t) => e.split(t).join(toRaw.get(t)), e);
//#endregion
//#region node_modules/.pnpm/tar@7.5.22_patch_hash=fd38a2350a01d3eec80c7c393b88647baea164251683cffc481cb3aa5df2a75c/node_modules/tar/dist/esm/write-entry.js
const prefixPath = (e, t) => {
	if (!t) return normalizeWindowsPath(e);
	e = normalizeWindowsPath(e).replace(/^\.(\/|$)/, "");
	return stripTrailingSlashes(t) + "/" + e;
};
const maxReadSize = 16777216;
const PROCESS$1 = Symbol("process");
const FILE$1 = Symbol("file");
const DIRECTORY$1 = Symbol("directory");
const SYMLINK$1 = Symbol("symlink");
const HARDLINK$1 = Symbol("hardlink");
const HEADER = Symbol("header");
const READ = Symbol("read");
const LSTAT = Symbol("lstat");
const ONLSTAT = Symbol("onlstat");
const ONREAD = Symbol("onread");
const ONREADLINK = Symbol("onreadlink");
const OPENFILE = Symbol("openfile");
const ONOPENFILE = Symbol("onopenfile");
const CLOSE = Symbol("close");
const MODE = Symbol("mode");
const AWAITDRAIN = Symbol("awaitDrain");
const ONDRAIN$1 = Symbol("ondrain");
const PREFIX = Symbol("prefix");
var WriteEntry = class extends Minipass {
	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;
	#e = false;
	constructor(e, t = {}) {
		const n = dealias(t);
		super();
		this.path = normalizeWindowsPath(e);
		this.portable = !!n.portable;
		this.maxReadSize = n.maxReadSize || maxReadSize;
		this.linkCache = n.linkCache || /* @__PURE__ */ new Map();
		this.statCache = n.statCache || /* @__PURE__ */ new Map();
		this.preservePaths = !!n.preservePaths;
		this.cwd = normalizeWindowsPath(n.cwd || process.cwd());
		this.strict = !!n.strict;
		this.noPax = !!n.noPax;
		this.noMtime = !!n.noMtime;
		this.mtime = n.mtime;
		this.prefix = n.prefix ? normalizeWindowsPath(n.prefix) : void 0;
		this.onWriteEntry = n.onWriteEntry;
		if (typeof n.onwarn === "function") this.on("warn", n.onwarn);
		let r = false;
		if (!this.preservePaths) {
			const [e, t] = stripAbsolutePath(this.path);
			if (e && typeof t === "string") {
				this.path = t;
				r = e;
			}
		}
		this.win32 = !!n.win32 || process.platform === "win32";
		if (this.win32) {
			this.path = decode(this.path.replaceAll(/\\/g, "/"));
			e = e.replaceAll(/\\/g, "/");
		}
		this.absolute = normalizeWindowsPath(n.absolute || path$1.resolve(this.cwd, e));
		if (this.path === "") this.path = "./";
		if (r) this.warn("TAR_ENTRY_INFO", `stripping ${r} from absolute path`, {
			entry: this,
			path: r + this.path
		});
		const i = this.statCache.get(this.absolute);
		if (i) this[ONLSTAT](i);
		else this[LSTAT]();
	}
	warn(e, t, n = {}) {
		return warnMethod(this, e, t, n);
	}
	emit(e, ...t) {
		if (e === "error") this.#e = true;
		return super.emit(e, ...t);
	}
	[LSTAT]() {
		fs$2.lstat(this.absolute, (e, t) => {
			if (e) return this.emit("error", e);
			this[ONLSTAT](t);
		});
	}
	[ONLSTAT](e) {
		this.statCache.set(this.absolute, e);
		this.stat = e;
		if (!e.isFile()) e.size = 0;
		this.type = getType(e);
		this.emit("stat", e);
		this[PROCESS$1]();
	}
	[PROCESS$1]() {
		switch (this.type) {
			case "File": return this[FILE$1]();
			case "Directory": return this[DIRECTORY$1]();
			case "SymbolicLink": return this[SYMLINK$1]();
			default: return this.end();
		}
	}
	[MODE](e) {
		return modeFix(e, this.type === "Directory", this.portable);
	}
	[PREFIX](e) {
		return prefixPath(e, this.prefix);
	}
	[HEADER]() {
		/* c8 ignore start */
		if (!this.stat) throw new Error("cannot write header before stat");
		/* c8 ignore stop */
		if (this.type === "Directory" && this.portable) this.noMtime = true;
		this.onWriteEntry?.(this);
		this.header = new Header({
			path: this[PREFIX](this.path),
			linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[PREFIX](this.linkpath) : this.linkpath,
			mode: this[MODE](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,
			/* c8 ignore next */
			type: this.type === "Unsupported" ? void 0 : this.type,
			uname: this.portable ? void 0 : this.stat.uid === this.myuid ? this.myuser : "",
			atime: this.portable ? void 0 : this.stat.atime,
			ctime: this.portable ? void 0 : this.stat.ctime
		});
		if (this.header.encode() && !this.noPax) super.write(new Pax({
			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[PREFIX](this.path),
			linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[PREFIX](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 e = this.header?.block;
		/* c8 ignore start */
		if (!e) throw new Error("failed to encode header");
		/* c8 ignore stop */
		super.write(e);
	}
	[DIRECTORY$1]() {
		/* c8 ignore start */
		if (!this.stat) throw new Error("cannot create directory entry without stat");
		/* c8 ignore stop */
		if (this.path.slice(-1) !== "/") this.path += "/";
		this.stat.size = 0;
		this[HEADER]();
		this.end();
	}
	[SYMLINK$1]() {
		fs$2.readlink(this.absolute, (e, t) => {
			if (e) return this.emit("error", e);
			this[ONREADLINK](t);
		});
	}
	[ONREADLINK](e) {
		this.linkpath = normalizeWindowsPath(e);
		this[HEADER]();
		this.end();
	}
	[HARDLINK$1](e) {
		/* c8 ignore start */
		if (!this.stat) throw new Error("cannot create link entry without stat");
		/* c8 ignore stop */
		this.type = "Link";
		this.linkpath = normalizeWindowsPath(path$1.relative(this.cwd, e));
		this.stat.size = 0;
		this[HEADER]();
		this.end();
	}
	[FILE$1]() {
		/* c8 ignore start */
		if (!this.stat) throw new Error("cannot create file entry without stat");
		/* c8 ignore stop */
		if (this.stat.nlink > 1) {
			const e = `${this.stat.dev}:${this.stat.ino}`;
			const t = this.linkCache.get(e);
			if (t?.indexOf(this.cwd) === 0) return this[HARDLINK$1](t);
			this.linkCache.set(e, this.absolute);
		}
		this[HEADER]();
		if (this.stat.size === 0) return this.end();
		this[OPENFILE]();
	}
	[OPENFILE]() {
		fs$2.open(this.absolute, "r", (e, t) => {
			if (e) return this.emit("error", e);
			this[ONOPENFILE](t);
		});
	}
	[ONOPENFILE](e) {
		this.fd = e;
		if (this.#e) return this[CLOSE]();
		/* c8 ignore start */
		if (!this.stat) throw new Error("should stat before calling onopenfile");
		/* c8 ignore start */
		this.blockLen = 512 * Math.ceil(this.stat.size / 512);
		this.blockRemain = this.blockLen;
		const t = Math.min(this.blockLen, this.maxReadSize);
		this.buf = Buffer.allocUnsafe(t);
		this.offset = 0;
		this.pos = 0;
		this.remain = this.stat.size;
		this.length = this.buf.length;
		this[READ]();
	}
	[READ]() {
		const { fd: e, buf: t, offset: n, length: r, pos: i } = this;
		if (e === void 0 || t === void 0) throw new Error("cannot read file without first opening");
		fs$2.read(e, t, n, r, i, (e, t) => {
			if (e) return this[CLOSE](() => this.emit("error", e));
			this[ONREAD](t);
		});
	}
	/* c8 ignore start */
	[CLOSE](e = () => {}) {
		/* c8 ignore stop */
		if (this.fd !== void 0) fs$2.close(this.fd, e);
	}
	[ONREAD](e) {
		if (e <= 0 && this.remain > 0) {
			const e = Object.assign(/* @__PURE__ */ new Error("encountered unexpected EOF"), {
				path: this.absolute,
				syscall: "read",
				code: "EOF"
			});
			return this[CLOSE](() => this.emit("error", e));
		}
		if (e > this.remain) {
			const e = Object.assign(/* @__PURE__ */ new Error("did not encounter expected EOF"), {
				path: this.absolute,
				syscall: "read",
				code: "EOF"
			});
			return this[CLOSE](() => this.emit("error", e));
		}
		/* c8 ignore start */
		if (!this.buf) throw new Error("should have created buffer prior to reading");
		/* c8 ignore stop */
		if (e === this.remain) for (let t = e; t < this.length && e < this.blockRemain; t++) {
			this.buf[t + this.offset] = 0;
			e++;
			this.remain++;
		}
		const t = this.offset === 0 && e === this.buf.length ? this.buf : this.buf.subarray(this.offset, this.offset + e);
		if (!this.write(t)) this[AWAITDRAIN](() => this[ONDRAIN$1]());
		else this[ONDRAIN$1]();
	}
	[AWAITDRAIN](e) {
		this.once("drain", e);
	}
	write(e, t, n) {
		/* c8 ignore start - just junk to comply with NodeJS.WritableStream */
		if (typeof t === "function") {
			n = t;
			t = void 0;
		}
		if (typeof e === "string") e = Buffer.from(e, typeof t === "string" ? t : "utf8");
		/* c8 ignore stop */
		if (this.blockRemain < e.length) {
			const e = Object.assign(/* @__PURE__ */ new Error("writing more data than expected"), { path: this.absolute });
			return this.emit("error", e);
		}
		this.remain -= e.length;
		this.blockRemain -= e.length;
		this.pos += e.length;
		this.offset += e.length;
		return super.write(e, null, n);
	}
	[ONDRAIN$1]() {
		if (!this.remain) {
			if (this.blockRemain) super.write(Buffer.alloc(this.blockRemain));
			return this[CLOSE]((e) => e ? this.emit("error", e) : this.end());
		}
		/* c8 ignore start */
		if (!this.buf) throw new Error("buffer lost somehow in ONDRAIN");
		/* c8 ignore stop */
		if (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[READ]();
	}
};
var WriteEntrySync = class extends WriteEntry {
	sync = true;
	[LSTAT]() {
		this[ONLSTAT](fs$2.lstatSync(this.absolute));
	}
	[SYMLINK$1]() {
		this[ONREADLINK](fs$2.readlinkSync(this.absolute));
	}
	[OPENFILE]() {
		this[ONOPENFILE](fs$2.openSync(this.absolute, "r"));
	}
	[READ]() {
		let e = true;
		try {
			const { fd: t, buf: n, offset: r, length: i, pos: a } = this;
			/* c8 ignore start */
			if (t === void 0 || n === void 0) throw new Error("fd and buf must be set in READ method");
			/* c8 ignore stop */
			const o = fs$2.readSync(t, n, r, i, a);
			this[ONREAD](o);
			e = false;
		} finally {
			if (e) try {
				this[CLOSE](() => {});
			} catch {}
		}
	}
	[AWAITDRAIN](e) {
		e();
	}
	/* c8 ignore start */
	[CLOSE](e = () => {}) {
		/* c8 ignore stop */
		if (this.fd !== void 0) fs$2.closeSync(this.fd);
		e();
	}
};
var WriteEntryTar = class extends Minipass {
	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(e, t, n = {}) {
		return warnMethod(this, e, t, n);
	}
	constructor(e, t = {}) {
		const n = dealias(t);
		super();
		this.preservePaths = !!n.preservePaths;
		this.portable = !!n.portable;
		this.strict = !!n.strict;
		this.noPax = !!n.noPax;
		this.noMtime = !!n.noMtime;
		this.onWriteEntry = n.onWriteEntry;
		this.readEntry = e;
		const { type: r } = e;
		/* c8 ignore start */
		if (r === "Unsupported") throw new Error("writing entry that should be ignored");
		/* c8 ignore stop */
		this.type = r;
		if (this.type === "Directory" && this.portable) this.noMtime = true;
		this.prefix = n.prefix;
		this.path = normalizeWindowsPath(e.path);
		this.mode = e.mode !== void 0 ? this[MODE](e.mode) : void 0;
		this.uid = this.portable ? void 0 : e.uid;
		this.gid = this.portable ? void 0 : e.gid;
		this.uname = this.portable ? void 0 : e.uname;
		this.gname = this.portable ? void 0 : e.gname;
		this.size = e.size;
		this.mtime = this.noMtime ? void 0 : n.mtime || e.mtime;
		this.atime = this.portable ? void 0 : e.atime;
		this.ctime = this.portable ? void 0 : e.ctime;
		this.linkpath = e.linkpath !== void 0 ? normalizeWindowsPath(e.linkpath) : void 0;
		if (typeof n.onwarn === "function") this.on("warn", n.onwarn);
		let i = false;
		if (!this.preservePaths) {
			const [e, t] = stripAbsolutePath(this.path);
			if (e && typeof t === "string") {
				this.path = t;
				i = e;
			}
		}
		this.remain = e.size;
		this.blockRemain = e.startBlockSize;
		this.onWriteEntry?.(this);
		this.header = new Header({
			path: this[PREFIX](this.path),
			linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[PREFIX](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
		});
		if (i) this.warn("TAR_ENTRY_INFO", `stripping ${i} from absolute path`, {
			entry: this,
			path: i + this.path
		});
		if (this.header.encode() && !this.noPax) super.write(new Pax({
			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[PREFIX](this.path),
			linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[PREFIX](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 a = this.header?.block;
		/* c8 ignore start */
		if (!a) throw new Error("failed to encode header");
		/* c8 ignore stop */
		super.write(a);
		e.pipe(this);
	}
	[PREFIX](e) {
		return prefixPath(e, this.prefix);
	}
	[MODE](e) {
		return modeFix(e, this.type === "Directory", this.portable);
	}
	write(e, t, n) {
		/* c8 ignore start - just junk to comply with NodeJS.WritableStream */
		if (typeof t === "function") {
			n = t;
			t = void 0;
		}
		if (typeof e === "string") e = Buffer.from(e, typeof t === "string" ? t : "utf8");
		/* c8 ignore stop */
		const r = e.length;
		if (r > this.blockRemain) throw new Error("writing more to entry than is appropriate");
		this.blockRemain -= r;
		return super.write(e, n);
	}
	end(e, t, n) {
		if (this.blockRemain) super.write(Buffer.alloc(this.blockRemain));
		/* c8 ignore start - just junk to comply with NodeJS.WritableStream */
		if (typeof e === "function") {
			n = e;
			t = void 0;
			e = void 0;
		}
		if (typeof t === "function") {
			n = t;
			t = void 0;
		}
		if (typeof e === "string") e = Buffer.from(e, t ?? "utf8");
		if (n) this.once("finish", n);
		if (e) super.end(e, n);
		else super.end(n);
		/* c8 ignore stop */
		return this;
	}
};
const getType = (e) => e.isFile() ? "File" : e.isDirectory() ? "Directory" : e.isSymbolicLink() ? "SymbolicLink" : "Unsupported";
//#endregion
//#region node_modules/.pnpm/yallist@5.0.0/node_modules/yallist/dist/esm/index.js
var Yallist = class Yallist {
	tail;
	head;
	length = 0;
	static create(e = []) {
		return new Yallist(e);
	}
	constructor(e = []) {
		for (const t of e) this.push(t);
	}
	*[Symbol.iterator]() {
		for (let e = this.head; e; e = e.next) yield e.value;
	}
	removeNode(e) {
		if (e.list !== this) throw new Error("removing node which does not belong to this list");
		const t = e.next;
		const n = e.prev;
		if (t) t.prev = n;
		if (n) n.next = t;
		if (e === this.head) this.head = t;
		if (e === this.tail) this.tail = n;
		this.length--;
		e.next = void 0;
		e.prev = void 0;
		e.list = void 0;
		return t;
	}
	unshiftNode(e) {
		if (e === this.head) return;
		if (e.list) e.list.removeNode(e);
		const t = this.head;
		e.list = this;
		e.next = t;
		if (t) t.prev = e;
		this.head = e;
		if (!this.tail) this.tail = e;
		this.length++;
	}
	pushNode(e) {
		if (e === this.tail) return;
		if (e.list) e.list.removeNode(e);
		const t = this.tail;
		e.list = this;
		e.prev = t;
		if (t) t.next = e;
		this.tail = e;
		if (!this.head) this.head = e;
		this.length++;
	}
	push(...e) {
		for (let t = 0, n = e.length; t < n; t++) push(this, e[t]);
		return this.length;
	}
	unshift(...e) {
		for (var t = 0, n = e.length; t < n; t++) unshift(this, e[t]);
		return this.length;
	}
	pop() {
		if (!this.tail) return;
		const e = this.tail.value;
		const t = this.tail;
		this.tail = this.tail.prev;
		if (this.tail) this.tail.next = void 0;
		else this.head = void 0;
		t.list = void 0;
		this.length--;
		return e;
	}
	shift() {
		if (!this.head) return;
		const e = this.head.value;
		const t = this.head;
		this.head = this.head.next;
		if (this.head) this.head.prev = void 0;
		else this.tail = void 0;
		t.list = void 0;
		this.length--;
		return e;
	}
	forEach(e, t) {
		t = t || this;
		for (let n = this.head, r = 0; !!n; r++) {
			e.call(t, n.value, r, this);
			n = n.next;
		}
	}
	forEachReverse(e, t) {
		t = t || this;
		for (let n = this.tail, r = this.length - 1; !!n; r--) {
			e.call(t, n.value, r, this);
			n = n.prev;
		}
	}
	get(e) {
		let t = 0;
		let n = this.head;
		for (; !!n && t < e; t++) n = n.next;
		if (t === e && !!n) return n.value;
	}
	getReverse(e) {
		let t = 0;
		let n = this.tail;
		for (; !!n && t < e; t++) n = n.prev;
		if (t === e && !!n) return n.value;
	}
	map(e, t) {
		t = t || this;
		const n = new Yallist();
		for (let r = this.head; !!r;) {
			n.push(e.call(t, r.value, this));
			r = r.next;
		}
		return n;
	}
	mapReverse(e, t) {
		t = t || this;
		var n = new Yallist();
		for (let r = this.tail; !!r;) {
			n.push(e.call(t, r.value, this));
			r = r.prev;
		}
		return n;
	}
	reduce(e, t) {
		let n;
		let r = this.head;
		if (arguments.length > 1) n = t;
		else if (this.head) {
			r = this.head.next;
			n = this.head.value;
		} else throw new TypeError("Reduce of empty list with no initial value");
		for (var i = 0; !!r; i++) {
			n = e(n, r.value, i);
			r = r.next;
		}
		return n;
	}
	reduceReverse(e, t) {
		let n;
		let r = this.tail;
		if (arguments.length > 1) n = t;
		else if (this.tail) {
			r = this.tail.prev;
			n = this.tail.value;
		} else throw new TypeError("Reduce of empty list with no initial value");
		for (let t = this.length - 1; !!r; t--) {
			n = e(n, r.value, t);
			r = r.prev;
		}
		return n;
	}
	toArray() {
		const e = new Array(this.length);
		for (let t = 0, n = this.head; !!n; t++) {
			e[t] = n.value;
			n = n.next;
		}
		return e;
	}
	toArrayReverse() {
		const e = new Array(this.length);
		for (let t = 0, n = this.tail; !!n; t++) {
			e[t] = n.value;
			n = n.prev;
		}
		return e;
	}
	slice(e = 0, t = this.length) {
		if (t < 0) t += this.length;
		if (e < 0) e += this.length;
		const n = new Yallist();
		if (t < e || t < 0) return n;
		if (e < 0) e = 0;
		if (t > this.length) t = this.length;
		let r = this.head;
		let i = 0;
		for (i = 0; !!r && i < e; i++) r = r.next;
		for (; !!r && i < t; i++, r = r.next) n.push(r.value);
		return n;
	}
	sliceReverse(e = 0, t = this.length) {
		if (t < 0) t += this.length;
		if (e < 0) e += this.length;
		const n = new Yallist();
		if (t < e || t < 0) return n;
		if (e < 0) e = 0;
		if (t > this.length) t = this.length;
		let r = this.length;
		let i = this.tail;
		for (; !!i && r > t; r--) i = i.prev;
		for (; !!i && r > e; r--, i = i.prev) n.push(i.value);
		return n;
	}
	splice(e, t = 0, ...n) {
		if (e > this.length) e = this.length - 1;
		if (e < 0) e = this.length + e;
		let r = this.head;
		for (let t = 0; !!r && t < e; t++) r = r.next;
		const i = [];
		for (let e = 0; !!r && e < t; e++) {
			i.push(r.value);
			r = this.removeNode(r);
		}
		if (!r) r = this.tail;
		else if (r !== this.tail) r = r.prev;
		for (const e of n) r = insertAfter(this, r, e);
		return i;
	}
	reverse() {
		const e = this.head;
		const t = this.tail;
		for (let t = e; !!t; t = t.prev) {
			const e = t.prev;
			t.prev = t.next;
			t.next = e;
		}
		this.head = t;
		this.tail = e;
		return this;
	}
};
function insertAfter(e, t, n) {
	const r = t;
	const i = t ? t.next : e.head;
	const a = new Node(n, r, i, e);
	if (a.next === void 0) e.tail = a;
	if (a.prev === void 0) e.head = a;
	e.length++;
	return a;
}
function push(e, t) {
	e.tail = new Node(t, e.tail, void 0, e);
	if (!e.head) e.head = e.tail;
	e.length++;
}
function unshift(e, t) {
	e.head = new Node(t, void 0, e.head, e);
	if (!e.tail) e.tail = e.head;
	e.length++;
}
var Node = class {
	list;
	next;
	prev;
	value;
	constructor(e, t, n, r) {
		this.list = r;
		this.value = e;
		if (t) {
			t.next = this;
			this.prev = t;
		} else this.prev = void 0;
		if (n) {
			n.prev = this;
			this.next = n;
		} else this.next = void 0;
	}
};
//#endregion
//#region node_modules/.pnpm/tar@7.5.22_patch_hash=fd38a2350a01d3eec80c7c393b88647baea164251683cffc481cb3aa5df2a75c/node_modules/tar/dist/esm/pack.js
var PackJob = class {
	path;
	absolute;
	entry;
	stat;
	readdir;
	pending = false;
	pendingLink = false;
	ignore = false;
	piped = false;
	constructor(e, t) {
		this.path = e || "./";
		this.absolute = t;
	}
};
const EOF = Buffer.alloc(1024);
const ONSTAT = Symbol("onStat");
const ENDED$1 = Symbol("ended");
const QUEUE = Symbol("queue");
const PENDINGLINKS = Symbol("pendingLinks");
const CURRENT = Symbol("current");
const PROCESS = Symbol("process");
const PROCESSING = Symbol("processing");
const PROCESSJOB = Symbol("processJob");
const JOBS = Symbol("jobs");
const JOBDONE = Symbol("jobDone");
const ADDFSENTRY = Symbol("addFSEntry");
const ADDTARENTRY = Symbol("addTarEntry");
const STAT = Symbol("stat");
const READDIR = Symbol("readdir");
const ONREADDIR = Symbol("onreaddir");
const PIPE = Symbol("pipe");
const ENTRY = Symbol("entry");
const ENTRYOPT = Symbol("entryOpt");
const WRITEENTRYCLASS = Symbol("writeEntryClass");
const WRITE = Symbol("write");
const ONDRAIN = Symbol("ondrain");
var Pack = class extends Minipass {
	sync = false;
	opt;
	cwd;
	maxReadSize;
	preservePaths;
	strict;
	noPax;
	prefix;
	linkCache;
	statCache;
	file;
	portable;
	zip;
	readdirCache;
	noDirRecurse;
	follow;
	noMtime;
	mtime;
	filter;
	jobs;
	[WRITEENTRYCLASS];
	onWriteEntry;
	[QUEUE];
	[PENDINGLINKS] = /* @__PURE__ */ new Map();
	[JOBS] = 0;
	[PROCESSING] = false;
	[ENDED$1] = false;
	constructor(e = {}) {
		super();
		this.opt = e;
		this.file = e.file || "";
		this.cwd = e.cwd || process.cwd();
		this.maxReadSize = e.maxReadSize;
		this.preservePaths = !!e.preservePaths;
		this.strict = !!e.strict;
		this.noPax = !!e.noPax;
		this.prefix = normalizeWindowsPath(e.prefix || "");
		this.linkCache = e.linkCache || /* @__PURE__ */ new Map();
		this.statCache = e.statCache || /* @__PURE__ */ new Map();
		this.readdirCache = e.readdirCache || /* @__PURE__ */ new Map();
		this.onWriteEntry = e.onWriteEntry;
		this[WRITEENTRYCLASS] = WriteEntry;
		if (typeof e.onwarn === "function") this.on("warn", e.onwarn);
		this.portable = !!e.portable;
		if (e.gzip || e.brotli || e.zstd) {
			if ((e.gzip ? 1 : 0) + (e.brotli ? 1 : 0) + (e.zstd ? 1 : 0) > 1) throw new TypeError("gzip, brotli, zstd are mutually exclusive");
			if (e.gzip) {
				if (typeof e.gzip !== "object") e.gzip = {};
				if (this.portable) e.gzip.portable = true;
				this.zip = new Gzip(e.gzip);
			}
			if (e.brotli) {
				if (typeof e.brotli !== "object") e.brotli = {};
				this.zip = new BrotliCompress(e.brotli);
			}
			if (e.zstd) {
				if (typeof e.zstd !== "object") e.zstd = {};
				this.zip = new ZstdCompress(e.zstd);
			}
			/* c8 ignore next */
			if (!this.zip) throw new Error("impossible");
			const t = this.zip;
			t.on("data", (e) => super.write(e));
			t.on("end", () => super.end());
			t.on("drain", () => this[ONDRAIN]());
			this.on("resume", () => t.resume());
		} else this.on("drain", this[ONDRAIN]);
		this.noDirRecurse = !!e.noDirRecurse;
		this.follow = !!e.follow;
		this.noMtime = !!e.noMtime;
		if (e.mtime) this.mtime = e.mtime;
		this.filter = typeof e.filter === "function" ? e.filter : () => true;
		this[QUEUE] = new Yallist();
		this[JOBS] = 0;
		this.jobs = Number(e.jobs) || 4;
		this[PROCESSING] = false;
		this[ENDED$1] = false;
	}
	[WRITE](e) {
		return super.write(e);
	}
	add(e) {
		this.write(e);
		return this;
	}
	end(e, t, n) {
		/* c8 ignore start */
		if (typeof e === "function") {
			n = e;
			e = void 0;
		}
		if (typeof t === "function") {
			n = t;
			t = void 0;
		}
		/* c8 ignore stop */
		if (e) this.add(e);
		this[ENDED$1] = true;
		this[PROCESS]();
		/* c8 ignore next */
		if (n) n();
		return this;
	}
	write(e) {
		if (this[ENDED$1]) throw new Error("write after end");
		if (typeof e === "string") this[ADDFSENTRY](e);
		else this[ADDTARENTRY](e);
		return this.flowing;
	}
	[ADDTARENTRY](e) {
		const t = normalizeWindowsPath(path$1.resolve(this.cwd, e.path));
		if (!this.filter(e.path, e)) e.resume();
		else {
			const n = new PackJob(e.path, t);
			n.entry = new WriteEntryTar(e, this[ENTRYOPT](n));
			n.entry.on("end", () => this[JOBDONE](n));
			this[JOBS] += 1;
			this[QUEUE].push(n);
		}
		this[PROCESS]();
	}
	[ADDFSENTRY](e) {
		const t = normalizeWindowsPath(path$1.resolve(this.cwd, e));
		this[QUEUE].push(new PackJob(e, t));
		this[PROCESS]();
	}
	[STAT](e) {
		e.pending = true;
		this[JOBS] += 1;
		const t = this.follow ? "stat" : "lstat";
		fs$2[t](e.absolute, (t, n) => {
			e.pending = false;
			this[JOBS] -= 1;
			if (t) this.emit("error", t);
			else this[ONSTAT](e, n);
		});
	}
	[ONSTAT](e, t) {
		this.statCache.set(e.absolute, t);
		e.stat = t;
		if (!this.filter(e.path, t)) e.ignore = true;
		else if (t.isFile() && t.nlink > 1 && !this.linkCache.get(`${t.dev}:${t.ino}`) && !this.sync) {
			if (e === this[CURRENT]) this[PROCESSJOB](e);
			else {
				const n = `${t.dev}:${t.ino}`;
				const r = this[PENDINGLINKS].get(n);
				if (r) r.push(e);
				else this[PENDINGLINKS].set(n, [e]);
				e.pendingLink = true;
				e.pending = true;
			}
		}
		this[PROCESS]();
	}
	[READDIR](e) {
		e.pending = true;
		this[JOBS] += 1;
		fs$2.readdir(e.absolute, (t, n) => {
			e.pending = false;
			this[JOBS] -= 1;
			if (t) return this.emit("error", t);
			this[ONREADDIR](e, n);
		});
	}
	[ONREADDIR](e, t) {
		this.readdirCache.set(e.absolute, t);
		e.readdir = t;
		this[PROCESS]();
	}
	[PROCESS]() {
		if (this[PROCESSING]) return;
		this[PROCESSING] = true;
		for (let e = this[QUEUE].head; !!e && this[JOBS] < this.jobs; e = e.next) {
			this[PROCESSJOB](e.value);
			if (e.value.ignore) {
				const t = e.next;
				this[QUEUE].removeNode(e);
				e.next = t;
			}
		}
		this[PROCESSING] = false;
		if (this[ENDED$1] && this[QUEUE].length === 0 && this[JOBS] === 0) {
			if (this.zip) this.zip.end(EOF);
			else {
				super.write(EOF);
				super.end();
			}
		}
	}
	get [CURRENT]() {
		return this[QUEUE] && this[QUEUE].head && this[QUEUE].head.value;
	}
	[JOBDONE](e) {
		this[QUEUE].shift();
		this[JOBS] -= 1;
		const { stat: t } = e;
		if (t && t.isFile() && t.nlink > 1) {
			const e = `${t.dev}:${t.ino}`;
			const n = this[PENDINGLINKS].get(e);
			if (n) {
				this[PENDINGLINKS].delete(e);
				for (const e of n) {
					e.pending = false;
					this[PROCESSJOB](e);
				}
			}
		}
		this[PROCESS]();
	}
	[PROCESSJOB](e) {
		if (e.pending && e.pendingLink && e === this[CURRENT]) {
			e.pending = false;
			e.pendingLink = false;
		}
		if (e.pending) return;
		if (e.entry) {
			if (e === this[CURRENT] && !e.piped) this[PIPE](e);
			return;
		}
		if (!e.stat) {
			const t = this.statCache.get(e.absolute);
			if (t) this[ONSTAT](e, t);
			else this[STAT](e);
		}
		if (!e.stat) return;
		if (e.ignore) return;
		if (!this.noDirRecurse && e.stat.isDirectory() && !e.readdir) {
			const t = this.readdirCache.get(e.absolute);
			if (t) this[ONREADDIR](e, t);
			else this[READDIR](e);
			if (!e.readdir) return;
		}
		e.entry = this[ENTRY](e);
		if (!e.entry) {
			e.ignore = true;
			return;
		}
		if (e === this[CURRENT] && !e.piped) this[PIPE](e);
	}
	[ENTRYOPT](e) {
		return {
			onwarn: (e, t, n) => this.warn(e, t, n),
			noPax: this.noPax,
			cwd: this.cwd,
			absolute: e.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
		};
	}
	[ENTRY](e) {
		this[JOBS] += 1;
		try {
			return new this[WRITEENTRYCLASS](e.path, this[ENTRYOPT](e)).on("end", () => this[JOBDONE](e)).on("error", (e) => this.emit("error", e));
		} catch (e) {
			this.emit("error", e);
		}
	}
	[ONDRAIN]() {
		if (this[CURRENT] && this[CURRENT].entry) this[CURRENT].entry.resume();
	}
	[PIPE](e) {
		e.piped = true;
		if (e.readdir) e.readdir.forEach((t) => {
			const n = e.path;
			const r = n === "./" ? "" : n.replace(/\/*$/, "/");
			this[ADDFSENTRY](r + t);
		});
		const t = e.entry;
		const n = this.zip;
		/* c8 ignore start */
		if (!t) throw new Error("cannot pipe without source");
		/* c8 ignore stop */
		if (n) t.on("data", (e) => {
			if (!n.write(e)) t.pause();
		});
		else t.on("data", (e) => {
			if (!super.write(e)) t.pause();
		});
	}
	pause() {
		if (this.zip) this.zip.pause();
		return super.pause();
	}
	warn(e, t, n = {}) {
		warnMethod(this, e, t, n);
	}
};
var PackSync = class extends Pack {
	sync = true;
	constructor(e) {
		super(e);
		this[WRITEENTRYCLASS] = WriteEntrySync;
	}
	pause() {}
	resume() {}
	[STAT](e) {
		const t = this.follow ? "statSync" : "lstatSync";
		this[ONSTAT](e, fs$2[t](e.absolute));
	}
	[READDIR](e) {
		this[ONREADDIR](e, fs$2.readdirSync(e.absolute));
	}
	[PIPE](e) {
		const t = e.entry;
		const n = this.zip;
		if (e.readdir) e.readdir.forEach((t) => {
			const n = e.path;
			const r = n === "./" ? "" : n.replace(/\/*$/, "/");
			this[ADDFSENTRY](r + t);
		});
		/* c8 ignore start */
		if (!t) throw new Error("Cannot pipe without source");
		/* c8 ignore stop */
		if (n) t.on("data", (e) => {
			n.write(e);
		});
		else t.on("data", (e) => {
			super[WRITE](e);
		});
	}
};
//#endregion
//#region node_modules/.pnpm/tar@7.5.22_patch_hash=fd38a2350a01d3eec80c7c393b88647baea164251683cffc481cb3aa5df2a75c/node_modules/tar/dist/esm/create.js
const createFileSync = (e, t) => {
	const n = new PackSync(e);
	const r = new WriteStreamSync(e.file, { mode: e.mode || 438 });
	n.pipe(r);
	addFilesSync$1(n, t);
};
const createFile = (e, t) => {
	const n = new Pack(e);
	const r = new WriteStream(e.file, { mode: e.mode || 438 });
	n.pipe(r);
	const i = new Promise((e, t) => {
		r.on("error", t);
		r.on("close", e);
		n.on("error", t);
	});
	addFilesAsync$1(n, t).catch((e) => n.emit("error", e));
	return i;
};
const addFilesSync$1 = (e, t) => {
	t.forEach((t) => {
		if (t.charAt(0) === "@") list({
			file: path.resolve(e.cwd, t.slice(1)),
			sync: true,
			noResume: true,
			onReadEntry: (t) => e.add(t)
		});
		else e.add(t);
	});
	e.end();
};
const addFilesAsync$1 = async (e, t) => {
	for (const n of t) if (n.charAt(0) === "@") await list({
		file: path.resolve(String(e.cwd), n.slice(1)),
		noResume: true,
		onReadEntry: (t) => {
			e.add(t);
		}
	});
	else e.add(n);
	e.end();
};
const createSync = (e, t) => {
	const n = new PackSync(e);
	addFilesSync$1(n, t);
	return n;
};
const createAsync = (e, t) => {
	const n = new Pack(e);
	addFilesAsync$1(n, t).catch((e) => n.emit("error", e));
	return n;
};
const create = makeCommand(createFileSync, createFile, createSync, createAsync, (e, t) => {
	if (!t?.length) throw new TypeError("no paths specified to add to archive");
});
//#endregion
//#region node_modules/.pnpm/tar@7.5.22_patch_hash=fd38a2350a01d3eec80c7c393b88647baea164251683cffc481cb3aa5df2a75c/node_modules/tar/dist/esm/get-write-flag.js
const isWindows$2 = (process.env.__FAKE_PLATFORM__ || process.platform) === "win32";
/* c8 ignore start */
const { O_CREAT, O_NOFOLLOW, O_TRUNC, O_WRONLY } = fs$2.constants;
const UV_FS_O_FILEMAP = Number(process.env.__FAKE_FS_O_FILENAME__) || fs$2.constants.UV_FS_O_FILEMAP || 0;
/* c8 ignore stop */
const fMapEnabled = isWindows$2 && !!UV_FS_O_FILEMAP;
const fMapLimit = 524288;
const fMapFlag = UV_FS_O_FILEMAP | O_TRUNC | O_CREAT | O_WRONLY;
const noFollowFlag = !isWindows$2 && typeof O_NOFOLLOW === "number" ? O_NOFOLLOW | O_TRUNC | O_CREAT | O_WRONLY : null;
const getWriteFlag = noFollowFlag !== null ? () => noFollowFlag : !fMapEnabled ? () => "w" : (e) => e < fMapLimit ? fMapFlag : "w";
//#endregion
//#region node_modules/.pnpm/chownr@3.0.0/node_modules/chownr/dist/esm/index.js
const lchownSync = (e, t, n) => {
	try {
		return fs.lchownSync(e, t, n);
	} catch (e) {
		if (e?.code !== "ENOENT") throw e;
	}
};
const chown = (e, t, n, r) => {
	fs.lchown(e, t, n, (e) => {
		r(e && e?.code !== "ENOENT" ? e : null);
	});
};
const chownrKid = (e, t, n, r, i) => {
	if (t.isDirectory()) chownr(path.resolve(e, t.name), n, r, (a) => {
		if (a) return i(a);
		const o = path.resolve(e, t.name);
		chown(o, n, r, i);
	});
	else {
		const a = path.resolve(e, t.name);
		chown(a, n, r, i);
	}
};
const chownr = (e, t, n, r) => {
	fs.readdir(e, { withFileTypes: true }, (i, a) => {
		if (i) {
			if (i.code === "ENOENT") return r();
			else if (i.code !== "ENOTDIR" && i.code !== "ENOTSUP") return r(i);
		}
		if (i || !a.length) return chown(e, t, n, r);
		let o = a.length;
		let s = null;
		const then = (i) => {
			/* c8 ignore start */
			if (s) return;
			/* c8 ignore stop */
			if (i) return r(s = i);
			if (--o === 0) return chown(e, t, n, r);
		};
		for (const r of a) chownrKid(e, r, t, n, then);
	});
};
const chownrKidSync = (e, t, n, r) => {
	if (t.isDirectory()) chownrSync(path.resolve(e, t.name), n, r);
	lchownSync(path.resolve(e, t.name), n, r);
};
const chownrSync = (e, t, n) => {
	let r;
	try {
		r = fs.readdirSync(e, { withFileTypes: true });
	} catch (r) {
		const i = r;
		if (i?.code === "ENOENT") return;
		else if (i?.code === "ENOTDIR" || i?.code === "ENOTSUP") return lchownSync(e, t, n);
		else throw i;
	}
	for (const i of r) chownrKidSync(e, i, t, n);
	return lchownSync(e, t, n);
};
//#endregion
//#region node_modules/.pnpm/tar@7.5.22_patch_hash=fd38a2350a01d3eec80c7c393b88647baea164251683cffc481cb3aa5df2a75c/node_modules/tar/dist/esm/cwd-error.js
var CwdError = class extends Error {
	path;
	code;
	syscall = "chdir";
	constructor(e, t) {
		super(`${t}: Cannot cd into '${e}'`);
		this.path = e;
		this.code = t;
	}
	get name() {
		return "CwdError";
	}
};
//#endregion
//#region node_modules/.pnpm/tar@7.5.22_patch_hash=fd38a2350a01d3eec80c7c393b88647baea164251683cffc481cb3aa5df2a75c/node_modules/tar/dist/esm/symlink-error.js
var SymlinkError = class extends Error {
	path;
	symlink;
	syscall = "symlink";
	code = "TAR_SYMLINK_ERROR";
	constructor(e, t) {
		super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link");
		this.symlink = e;
		this.path = t;
	}
	get name() {
		return "SymlinkError";
	}
};
//#endregion
//#region node_modules/.pnpm/tar@7.5.22_patch_hash=fd38a2350a01d3eec80c7c393b88647baea164251683cffc481cb3aa5df2a75c/node_modules/tar/dist/esm/mkdir.js
const checkCwd = (e, t) => {
	fs.stat(e, (n, r) => {
		if (n || !r.isDirectory()) n = new CwdError(e, n?.code || "ENOTDIR");
		t(n);
	});
};
/**
* Wrapper around fs/promises.mkdir for tar's needs.
*
* The main purpose is to avoid creating directories if we know that
* they already exist (and track which ones exist for this purpose),
* and prevent entries from being extracted into symlinked folders,
* if `preservePaths` is not set.
*/
const mkdir$1 = (e, t, n) => {
	e = normalizeWindowsPath(e);
	/* c8 ignore next */
	const r = t.umask ?? 18;
	const i = t.mode | 448;
	const a = (i & r) !== 0;
	const o = t.uid;
	const s = t.gid;
	const c = typeof o === "number" && typeof s === "number" && (o !== t.processUid || s !== t.processGid);
	const l = t.preserve;
	const u = t.unlink;
	const d = normalizeWindowsPath(t.cwd);
	const done = (t, r) => {
		if (t) n(t);
		else if (r && c) chownr(r, o, s, (e) => done(e));
		else if (a) fs.chmod(e, i, n);
		else n();
	};
	if (e === d) return checkCwd(e, done);
	if (l) return fs$1.mkdir(e, {
		mode: i,
		recursive: true
	}).then((e) => done(null, e ?? void 0), done);
	const f = normalizeWindowsPath(path.relative(d, e)).split("/");
	mkdir_(d, f, i, u, d, void 0, done);
};
const mkdir_ = (e, t, n, r, i, a, o) => {
	if (t.length === 0) return o(null, a);
	const s = t.shift();
	const c = normalizeWindowsPath(path.resolve(e + "/" + s));
	fs.mkdir(c, n, onmkdir(c, t, n, r, i, a, o));
};
const onmkdir = (e, t, n, r, i, a, o) => (s) => {
	if (s) fs.lstat(e, (c, l) => {
		if (c) {
			c.path = c.path && normalizeWindowsPath(c.path);
			o(c);
		} else if (l.isDirectory()) mkdir_(e, t, n, r, i, a, o);
		else if (r) fs.unlink(e, (s) => {
			if (s) return o(s);
			fs.mkdir(e, n, onmkdir(e, t, n, r, i, a, o));
		});
		else if (l.isSymbolicLink()) return o(new SymlinkError(e, e + "/" + t.join("/")));
		else o(s);
	});
	else {
		a = a || e;
		mkdir_(e, t, n, r, i, a, o);
	}
};
const checkCwdSync = (e) => {
	let t = false;
	let n;
	try {
		t = fs.statSync(e).isDirectory();
	} catch (e) {
		n = e?.code;
	} finally {
		if (!t) throw new CwdError(e, n ?? "ENOTDIR");
	}
};
const mkdirSync$1 = (e, t) => {
	e = normalizeWindowsPath(e);
	/* c8 ignore next */
	const n = t.umask ?? 18;
	const r = t.mode | 448;
	const i = (r & n) !== 0;
	const a = t.uid;
	const o = t.gid;
	const s = typeof a === "number" && typeof o === "number" && (a !== t.processUid || o !== t.processGid);
	const c = t.preserve;
	const l = t.unlink;
	const u = normalizeWindowsPath(t.cwd);
	const done = (t) => {
		if (t && s) chownrSync(t, a, o);
		if (i) fs.chmodSync(e, r);
	};
	if (e === u) {
		checkCwdSync(u);
		return done();
	}
	if (c) return done(fs.mkdirSync(e, {
		mode: r,
		recursive: true
	}) ?? void 0);
	const d = normalizeWindowsPath(path.relative(u, e)).split("/");
	let f;
	for (let e = d.shift(), t = u; e && (t += "/" + e); e = d.shift()) {
		t = normalizeWindowsPath(path.resolve(t));
		try {
			fs.mkdirSync(t, r);
			f = f || t;
		} catch {
			const e = fs.lstatSync(t);
			if (e.isDirectory()) continue;
			else if (l) {
				fs.unlinkSync(t);
				fs.mkdirSync(t, r);
				f = f || t;
				continue;
			} else if (e.isSymbolicLink()) return new SymlinkError(t, t + "/" + d.join("/"));
		}
	}
	return done(f);
};
//#endregion
//#region node_modules/.pnpm/tar@7.5.22_patch_hash=fd38a2350a01d3eec80c7c393b88647baea164251683cffc481cb3aa5df2a75c/node_modules/tar/dist/esm/normalize-unicode.js
const normalizeCache = Object.create(null);
const MAX = 1e4;
const cache = /* @__PURE__ */ new Set();
const normalizeUnicode = (e) => {
	if (!cache.has(e)) normalizeCache[e] = e.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en");
	else cache.delete(e);
	cache.add(e);
	const t = normalizeCache[e];
	let n = cache.size - MAX;
	if (n > MAX / 10) for (const e of cache) {
		cache.delete(e);
		delete normalizeCache[e];
		if (--n <= 0) break;
	}
	return t;
};
//#endregion
//#region node_modules/.pnpm/tar@7.5.22_patch_hash=fd38a2350a01d3eec80c7c393b88647baea164251683cffc481cb3aa5df2a75c/node_modules/tar/dist/esm/path-reservations.js
const isWindows$1 = (process.env.TESTING_TAR_FAKE_PLATFORM || process.platform) === "win32";
const getDirs = (e) => {
	return e.split("/").slice(0, -1).reduce((e, t) => {
		const n = e.at(-1);
		if (n !== void 0) t = join(n, t);
		e.push(t || "/");
		return e;
	}, []);
};
var PathReservations = class {
	#e = /* @__PURE__ */ new Map();
	#t = /* @__PURE__ */ new Map();
	#n = /* @__PURE__ */ new Set();
	reserve(e, t) {
		e = isWindows$1 ? ["win32 parallelization disabled"] : e.map((e) => {
			return stripTrailingSlashes(join(normalizeUnicode(e)));
		});
		const n = new Set(e.map((e) => getDirs(e)).reduce((e, t) => e.concat(t)));
		this.#t.set(t, {
			dirs: n,
			paths: e
		});
		for (const n of e) {
			const e = this.#e.get(n);
			if (!e) this.#e.set(n, [t]);
			else e.push(t);
		}
		for (const e of n) {
			const n = this.#e.get(e);
			if (!n) this.#e.set(e, [/* @__PURE__ */ new Set([t])]);
			else {
				const e = n.at(-1);
				if (e instanceof Set) e.add(t);
				else n.push(/* @__PURE__ */ new Set([t]));
			}
		}
		return this.#i(t);
	}
	#r(e) {
		const t = this.#t.get(e);
		/* c8 ignore start */
		if (!t) throw new Error("function does not have any path reservations");
		/* c8 ignore stop */
		return {
			paths: t.paths.map((e) => this.#e.get(e)),
			dirs: [...t.dirs].map((e) => this.#e.get(e))
		};
	}
	check(e) {
		const { paths: t, dirs: n } = this.#r(e);
		return t.every((t) => t && t[0] === e) && n.every((t) => t && t[0] instanceof Set && t[0].has(e));
	}
	#i(e) {
		if (this.#n.has(e) || !this.check(e)) return false;
		this.#n.add(e);
		e(() => this.#a(e));
		return true;
	}
	#a(e) {
		if (!this.#n.has(e)) return false;
		const t = this.#t.get(e);
		/* c8 ignore start */
		if (!t) throw new Error("invalid reservation");
		/* c8 ignore stop */
		const { paths: n, dirs: r } = t;
		const i = /* @__PURE__ */ new Set();
		for (const t of n) {
			const n = this.#e.get(t);
			/* c8 ignore start */
			if (!n || n?.[0] !== e) continue;
			/* c8 ignore stop */
			const r = n[1];
			if (!r) {
				this.#e.delete(t);
				continue;
			}
			n.shift();
			if (typeof r === "function") i.add(r);
			else for (const e of r) i.add(e);
		}
		for (const t of r) {
			const n = this.#e.get(t);
			const r = n?.[0];
			/* c8 ignore next - type safety only */
			if (!n || !(r instanceof Set)) continue;
			if (r.size === 1 && n.length === 1) {
				this.#e.delete(t);
				continue;
			} else if (r.size === 1) {
				n.shift();
				const e = n[0];
				if (typeof e === "function") i.add(e);
			} else r.delete(e);
		}
		this.#n.delete(e);
		i.forEach((e) => this.#i(e));
		return true;
	}
};
//#endregion
//#region node_modules/.pnpm/tar@7.5.22_patch_hash=fd38a2350a01d3eec80c7c393b88647baea164251683cffc481cb3aa5df2a75c/node_modules/tar/dist/esm/process-umask.js
const umask = () => process.umask();
//#endregion
//#region node_modules/.pnpm/tar@7.5.22_patch_hash=fd38a2350a01d3eec80c7c393b88647baea164251683cffc481cb3aa5df2a75c/node_modules/tar/dist/esm/unpack.js
const ONENTRY = Symbol("onEntry");
const CHECKFS = Symbol("checkFs");
const CHECKFS2 = Symbol("checkFs2");
const ISREUSABLE = Symbol("isReusable");
const MAKEFS = Symbol("makeFs");
const FILE = Symbol("file");
const DIRECTORY = Symbol("directory");
const LINK = Symbol("link");
const SYMLINK = Symbol("symlink");
const HARDLINK = Symbol("hardlink");
const ENSURE_NO_SYMLINK = Symbol("ensureNoSymlink");
const UNSUPPORTED = Symbol("unsupported");
const CHECKPATH = Symbol("checkPath");
const STRIPABSOLUTEPATH = Symbol("stripAbsolutePath");
const MKDIR = Symbol("mkdir");
const ONERROR = Symbol("onError");
const PENDING = Symbol("pending");
const PEND = Symbol("pend");
const UNPEND = Symbol("unpend");
const ENDED = Symbol("ended");
const MAYBECLOSE = Symbol("maybeClose");
const SKIP = Symbol("skip");
const DOCHOWN = Symbol("doChown");
const UID = Symbol("uid");
const GID = Symbol("gid");
const CHECKED_CWD = Symbol("checkedCwd");
const isWindows = (process.env.TESTING_TAR_FAKE_PLATFORM || process.platform) === "win32";
const DEFAULT_MAX_DEPTH = 1024;
/* c8 ignore start */
const unlinkFile = (e, t) => {
	if (!isWindows) return fs.unlink(e, t);
	const n = e + ".DELETE." + randomBytes(16).toString("hex");
	fs.rename(e, n, (e) => {
		if (e) return t(e);
		fs.unlink(n, t);
	});
};
/* c8 ignore stop */
/* c8 ignore start */
const unlinkFileSync = (e) => {
	if (!isWindows) return fs.unlinkSync(e);
	const t = e + ".DELETE." + randomBytes(16).toString("hex");
	fs.renameSync(e, t);
	fs.unlinkSync(t);
};
/* c8 ignore stop */
const uint32 = (e, t, n) => e !== void 0 && e === e >>> 0 ? e : t !== void 0 && t === t >>> 0 ? t : n;
var Unpack = class extends Parser {
	[ENDED] = false;
	[CHECKED_CWD] = false;
	[PENDING] = 0;
	reservations = new PathReservations();
	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(e = {}) {
		e.ondone = () => {
			this[ENDED] = true;
			this[MAYBECLOSE]();
		};
		super(e);
		this.transform = e.transform;
		this.chmod = !!e.chmod;
		if (typeof e.uid === "number" || typeof e.gid === "number") {
			if (typeof e.uid !== "number" || typeof e.gid !== "number") throw new TypeError("cannot set owner without number uid and gid");
			if (e.preserveOwner) throw new TypeError("cannot preserve owner in archive and also set owner explicitly");
			this.uid = e.uid;
			this.gid = e.gid;
			this.setOwner = true;
		} else {
			this.uid = void 0;
			this.gid = void 0;
			this.setOwner = false;
		}
		this.preserveOwner = e.preserveOwner === void 0 && typeof e.uid !== "number" ? !!(process.getuid?.() === 0) : !!e.preserveOwner;
		this.processUid = (this.preserveOwner || this.setOwner) && process.getuid ? process.getuid() : void 0;
		this.processGid = (this.preserveOwner || this.setOwner) && process.getgid ? process.getgid() : void 0;
		this.maxDepth = typeof e.maxDepth === "number" ? e.maxDepth : DEFAULT_MAX_DEPTH;
		this.forceChown = e.forceChown === true;
		this.win32 = !!e.win32 || isWindows;
		this.newer = !!e.newer;
		this.keep = !!e.keep;
		this.noMtime = !!e.noMtime;
		this.preservePaths = !!e.preservePaths;
		this.unlink = !!e.unlink;
		this.cwd = normalizeWindowsPath(path.resolve(e.cwd || process.cwd()));
		this.strip = Number(e.strip) || 0;
		this.processUmask = !this.chmod ? 0 : typeof e.processUmask === "number" ? e.processUmask : umask();
		this.umask = typeof e.umask === "number" ? e.umask : this.processUmask;
		this.dmode = e.dmode || 511 & ~this.umask;
		this.fmode = e.fmode || 438 & ~this.umask;
		this.on("entry", (e) => this[ONENTRY](e));
	}
	warn(e, t, n = {}) {
		if (e === "TAR_BAD_ARCHIVE" || e === "TAR_ABORT") n.recoverable = false;
		return super.warn(e, t, n);
	}
	[MAYBECLOSE]() {
		if (this[ENDED] && this[PENDING] === 0) {
			this.emit("prefinish");
			this.emit("finish");
			this.emit("end");
		}
	}
	[STRIPABSOLUTEPATH](e, t) {
		const n = e[t];
		const { type: r } = e;
		if (!n || this.preservePaths) return true;
		const [i, a] = stripAbsolutePath(n);
		const o = a.replaceAll(/\\/g, "/").split("/");
		if (o.includes("..") || isWindows && /^[a-z]:\.\.$/i.test(o[0] ?? "")) {
			if (t === "path" || r === "Link") {
				this.warn("TAR_ENTRY_ERROR", `${t} contains '..'`, {
					entry: e,
					[t]: n
				});
				return false;
			}
			const i = path.posix.dirname(e.path);
			const a = path.posix.normalize(path.posix.join(i, o.join("/")));
			if (a.startsWith("../") || a === "..") {
				this.warn("TAR_ENTRY_ERROR", `${t} escapes extraction directory`, {
					entry: e,
					[t]: n
				});
				return false;
			}
		}
		if (i) {
			e[t] = String(a);
			this.warn("TAR_ENTRY_INFO", `stripping ${i} from absolute ${t}`, {
				entry: e,
				[t]: n
			});
		}
		return true;
	}
	[CHECKPATH](e) {
		const t = normalizeWindowsPath(e.path);
		const n = t.split("/");
		if (this.strip) {
			if (n.length < this.strip) return false;
			if (e.type === "Link") {
				const t = normalizeWindowsPath(String(e.linkpath)).split("/");
				if (t.length >= this.strip) e.linkpath = t.slice(this.strip).join("/");
				else return false;
			}
			n.splice(0, this.strip);
			e.path = n.join("/");
		}
		if (isFinite(this.maxDepth) && n.length > this.maxDepth) {
			this.warn("TAR_ENTRY_ERROR", "path excessively deep", {
				entry: e,
				path: t,
				depth: n.length,
				maxDepth: this.maxDepth
			});
			return false;
		}
		if (!this[STRIPABSOLUTEPATH](e, "path") || !this[STRIPABSOLUTEPATH](e, "linkpath")) return false;
		e.absolute = path.isAbsolute(e.path) ? normalizeWindowsPath(path.resolve(e.path)) : normalizeWindowsPath(path.resolve(this.cwd, e.path));
		/* c8 ignore start - defense in depth */
		if (!this.preservePaths && typeof e.absolute === "string" && e.absolute.indexOf(this.cwd + "/") !== 0 && e.absolute !== this.cwd) {
			this.warn("TAR_ENTRY_ERROR", "path escaped extraction target", {
				entry: e,
				path: normalizeWindowsPath(e.path),
				resolvedPath: e.absolute,
				cwd: this.cwd
			});
			return false;
		}
		/* c8 ignore stop */
		if (e.absolute === this.cwd && e.type !== "Directory" && e.type !== "GNUDumpDir") return false;
		if (this.win32) {
			const { root: t } = path.win32.parse(String(e.absolute));
			e.absolute = t + encode(String(e.absolute).slice(t.length));
			const { root: n } = path.win32.parse(e.path);
			e.path = n + encode(e.path.slice(n.length));
		}
		return true;
	}
	[ONENTRY](e) {
		if (!this[CHECKPATH](e)) return e.resume();
		assert$1.equal(typeof e.absolute, "string");
		switch (e.type) {
			case "Directory":
			case "GNUDumpDir": if (e.mode) e.mode = e.mode | 448;
			case "File":
			case "OldFile":
			case "ContiguousFile":
			case "Link":
			case "SymbolicLink": return this[CHECKFS](e);
			default: return this[UNSUPPORTED](e);
		}
	}
	[ONERROR](e, t) {
		if (e.name === "CwdError") this.emit("error", e);
		else {
			this.warn("TAR_ENTRY_ERROR", e, { entry: t });
			this[UNPEND]();
			t.resume();
		}
	}
	[MKDIR](e, t, n) {
		mkdir$1(normalizeWindowsPath(e), {
			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: t
		}, n);
	}
	[DOCHOWN](e) {
		return this.forceChown || this.preserveOwner && (typeof e.uid === "number" && e.uid !== this.processUid || typeof e.gid === "number" && e.gid !== this.processGid) || typeof this.uid === "number" && this.uid !== this.processUid || typeof this.gid === "number" && this.gid !== this.processGid;
	}
	[UID](e) {
		return uint32(this.uid, e.uid, this.processUid);
	}
	[GID](e) {
		return uint32(this.gid, e.gid, this.processGid);
	}
	[FILE](e, t) {
		const n = typeof e.mode === "number" ? e.mode & 4095 : this.fmode;
		const r = new WriteStream(String(e.absolute), {
			flags: getWriteFlag(e.size),
			mode: n,
			autoClose: false
		});
		r.on("error", (n) => {
			if (r.fd) fs.close(r.fd, () => {});
			r.write = () => true;
			this[ONERROR](n, e);
			t();
		});
		let i = 1;
		const done = (n) => {
			if (n) {
				/* c8 ignore start - we should always have a fd by now */
				if (r.fd) fs.close(r.fd, () => {});
				/* c8 ignore stop */
				this[ONERROR](n, e);
				t();
				return;
			}
			if (--i === 0) {
				if (r.fd !== void 0) fs.close(r.fd, (n) => {
					if (n) this[ONERROR](n, e);
					else this[UNPEND]();
					t();
				});
			}
		};
		r.on("finish", () => {
			const t = String(e.absolute);
			const n = r.fd;
			if (typeof n === "number" && e.mtime && !this.noMtime) {
				i++;
				const r = e.atime || /* @__PURE__ */ new Date();
				const a = e.mtime;
				fs.futimes(n, r, a, (e) => e ? fs.utimes(t, r, a, (t) => done(t && e)) : done());
			}
			if (typeof n === "number" && this[DOCHOWN](e)) {
				i++;
				const r = this[UID](e);
				const a = this[GID](e);
				if (typeof r === "number" && typeof a === "number") fs.fchown(n, r, a, (e) => e ? fs.chown(t, r, a, (t) => done(t && e)) : done());
			}
			done();
		});
		const a = this.transform ? this.transform(e) || e : e;
		if (a !== e) {
			a.on("error", (n) => {
				this[ONERROR](n, e);
				t();
			});
			e.pipe(a);
		}
		a.pipe(r);
	}
	[DIRECTORY](e, t) {
		const n = typeof e.mode === "number" ? e.mode & 4095 : this.dmode;
		this[MKDIR](String(e.absolute), n, (n) => {
			if (n) {
				this[ONERROR](n, e);
				t();
				return;
			}
			let r = 1;
			const done = () => {
				if (--r === 0) {
					t();
					this[UNPEND]();
					e.resume();
				}
			};
			if (e.mtime && !this.noMtime) {
				r++;
				fs.utimes(String(e.absolute), e.atime || /* @__PURE__ */ new Date(), e.mtime, done);
			}
			if (this[DOCHOWN](e)) {
				r++;
				fs.chown(String(e.absolute), Number(this[UID](e)), Number(this[GID](e)), done);
			}
			done();
		});
	}
	[UNSUPPORTED](e) {
		e.unsupported = true;
		this.warn("TAR_ENTRY_UNSUPPORTED", `unsupported entry type: ${e.type}`, { entry: e });
		e.resume();
	}
	[SYMLINK](e, t) {
		const n = normalizeWindowsPath(path.relative(this.cwd, path.resolve(path.dirname(String(e.absolute)), String(e.linkpath)))).split("/");
		this[ENSURE_NO_SYMLINK](e, this.cwd, n, () => this[LINK](e, String(e.linkpath), "symlink", t), (n) => {
			this[ONERROR](n, e);
			t();
		});
	}
	[HARDLINK](e, t) {
		const n = normalizeWindowsPath(path.resolve(this.cwd, String(e.linkpath)));
		const r = normalizeWindowsPath(String(e.linkpath)).split("/");
		this[ENSURE_NO_SYMLINK](e, this.cwd, r, () => this[LINK](e, n, "link", t), (n) => {
			this[ONERROR](n, e);
			t();
		});
	}
	[ENSURE_NO_SYMLINK](e, t, n, r, i) {
		const a = n.shift();
		if (this.preservePaths || a === void 0) return r();
		const o = path.resolve(t, a);
		fs.lstat(o, (t, a) => {
			if (t) return r();
			if (a?.isSymbolicLink()) return i(new SymlinkError(o, path.resolve(o, n.join("/"))));
			this[ENSURE_NO_SYMLINK](e, o, n, r, i);
		});
	}
	[PEND]() {
		this[PENDING]++;
	}
	[UNPEND]() {
		this[PENDING]--;
		this[MAYBECLOSE]();
	}
	[SKIP](e) {
		this[UNPEND]();
		e.resume();
	}
	[ISREUSABLE](e, t) {
		return e.type === "File" && !this.unlink && t.isFile() && t.nlink <= 1 && !isWindows;
	}
	[CHECKFS](e) {
		this[PEND]();
		const t = [e.path];
		if (e.linkpath) t.push(e.linkpath);
		this.reservations.reserve(t, (t) => this[CHECKFS2](e, t));
	}
	[CHECKFS2](e, t) {
		const done = (e) => {
			t(e);
		};
		const checkCwd = () => {
			this[MKDIR](this.cwd, this.dmode, (t) => {
				if (t) {
					this[ONERROR](t, e);
					done();
					return;
				}
				this[CHECKED_CWD] = true;
				start();
			});
		};
		const start = () => {
			if (e.absolute !== this.cwd) {
				const t = normalizeWindowsPath(path.dirname(String(e.absolute)));
				if (t !== this.cwd) return this[MKDIR](t, this.dmode, (t) => {
					if (t) {
						this[ONERROR](t, e);
						done();
						return;
					}
					afterMakeParent();
				});
			}
			afterMakeParent();
		};
		const afterMakeParent = () => {
			fs.lstat(String(e.absolute), (t, n) => {
				if (n && (this.keep || this.newer && n.mtime > (e.mtime ?? n.mtime))) {
					this[SKIP](e);
					done();
					return;
				}
				if (t || this[ISREUSABLE](e, n)) return this[MAKEFS](null, e, done);
				if (n.isDirectory()) {
					if (e.type === "Directory") {
						const t = this.chmod && e.mode && (n.mode & 4095) !== e.mode;
						const afterChmod = (t) => this[MAKEFS](t ?? null, e, done);
						if (!t) return afterChmod();
						return fs.chmod(String(e.absolute), Number(e.mode), afterChmod);
					}
					if (e.absolute !== this.cwd) return fs.rmdir(String(e.absolute), (t) => this[MAKEFS](t ?? null, e, done));
				}
				if (e.absolute === this.cwd) return this[MAKEFS](null, e, done);
				unlinkFile(String(e.absolute), (t) => this[MAKEFS](t ?? null, e, done));
			});
		};
		if (this[CHECKED_CWD]) start();
		else checkCwd();
	}
	[MAKEFS](e, t, n) {
		if (e) {
			this[ONERROR](e, t);
			n();
			return;
		}
		switch (t.type) {
			case "File":
			case "OldFile":
			case "ContiguousFile": return this[FILE](t, n);
			case "Link": return this[HARDLINK](t, n);
			case "SymbolicLink": return this[SYMLINK](t, n);
			case "Directory":
			case "GNUDumpDir": return this[DIRECTORY](t, n);
		}
	}
	[LINK](e, t, n, r) {
		fs[n](t, String(e.absolute), (t) => {
			if (t) this[ONERROR](t, e);
			else {
				this[UNPEND]();
				e.resume();
			}
			r();
		});
	}
};
const callSync = (e) => {
	try {
		return [null, e()];
	} catch (e) {
		return [e, null];
	}
};
var UnpackSync = class extends Unpack {
	sync = true;
	[MAKEFS](e, t) {
		return super[MAKEFS](e, t, () => {});
	}
	[CHECKFS](e) {
		if (!this[CHECKED_CWD]) {
			const t = this[MKDIR](this.cwd, this.dmode);
			if (t) return this[ONERROR](t, e);
			this[CHECKED_CWD] = true;
		}
		if (e.absolute !== this.cwd) {
			const t = normalizeWindowsPath(path.dirname(String(e.absolute)));
			if (t !== this.cwd) {
				const n = this[MKDIR](t, this.dmode);
				if (n) return this[ONERROR](n, e);
			}
		}
		const [t, n] = callSync(() => fs.lstatSync(String(e.absolute)));
		if (n && (this.keep || this.newer && n.mtime > (e.mtime ?? n.mtime))) return this[SKIP](e);
		if (t || this[ISREUSABLE](e, n)) return this[MAKEFS](null, e);
		if (n.isDirectory()) {
			if (e.type === "Directory") {
				const [t] = this.chmod && e.mode && (n.mode & 4095) !== e.mode ? callSync(() => {
					fs.chmodSync(String(e.absolute), Number(e.mode));
				}) : [];
				return this[MAKEFS](t, e);
			}
			const [t] = callSync(() => fs.rmdirSync(String(e.absolute)));
			this[MAKEFS](t, e);
		}
		const [r] = e.absolute === this.cwd ? [] : callSync(() => unlinkFileSync(String(e.absolute)));
		this[MAKEFS](r, e);
	}
	[FILE](e, t) {
		const n = typeof e.mode === "number" ? e.mode & 4095 : this.fmode;
		const oner = (n) => {
			let i;
			try {
				fs.closeSync(r);
			} catch (e) {
				i = e;
			}
			if (n || i) this[ONERROR](n || i, e);
			t();
		};
		let r;
		try {
			r = fs.openSync(String(e.absolute), getWriteFlag(e.size), n);
		} catch (e) {
			return oner(e);
		}
		/* c8 ignore stop */
		const i = this.transform ? this.transform(e) || e : e;
		if (i !== e) {
			i.on("error", (t) => this[ONERROR](t, e));
			e.pipe(i);
		}
		i.on("data", (e) => {
			try {
				fs.writeSync(r, e, 0, e.length);
			} catch (e) {
				oner(e);
			}
		});
		i.on("end", () => {
			let t = null;
			if (e.mtime && !this.noMtime) {
				const n = e.atime || /* @__PURE__ */ new Date();
				const i = e.mtime;
				try {
					fs.futimesSync(r, n, i);
				} catch (r) {
					try {
						fs.utimesSync(String(e.absolute), n, i);
					} catch {
						t = r;
					}
				}
			}
			if (this[DOCHOWN](e)) {
				const n = this[UID](e);
				const i = this[GID](e);
				try {
					fs.fchownSync(r, Number(n), Number(i));
				} catch (r) {
					try {
						fs.chownSync(String(e.absolute), Number(n), Number(i));
					} catch {
						t = t || r;
					}
				}
			}
			oner(t);
		});
	}
	[DIRECTORY](e, t) {
		const n = typeof e.mode === "number" ? e.mode & 4095 : this.dmode;
		const r = this[MKDIR](String(e.absolute), n);
		if (r) {
			this[ONERROR](r, e);
			t();
			return;
		}
		if (e.mtime && !this.noMtime) try {
			fs.utimesSync(String(e.absolute), e.atime || /* @__PURE__ */ new Date(), e.mtime);
		} catch {}
		if (this[DOCHOWN](e)) try {
			fs.chownSync(String(e.absolute), Number(this[UID](e)), Number(this[GID](e)));
		} catch {}
		t();
		e.resume();
	}
	[MKDIR](e, t) {
		try {
			return mkdirSync$1(normalizeWindowsPath(e), {
				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: t
			});
		} catch (e) {
			return e;
		}
	}
	[ENSURE_NO_SYMLINK](e, t, n, r, i) {
		if (this.preservePaths || n.length === 0) return r();
		let a = t;
		for (const e of n) {
			a = path.resolve(a, e);
			const [o, s] = callSync(() => fs.lstatSync(a));
			if (o) return r();
			if (s.isSymbolicLink()) return i(new SymlinkError(a, path.resolve(t, n.join("/"))));
		}
		r();
	}
	[LINK](e, t, n, r) {
		const i = `${n}Sync`;
		try {
			fs[i](t, String(e.absolute));
			r();
			e.resume();
		} catch (t) {
			return this[ONERROR](t, e);
		}
	}
};
//#endregion
//#region node_modules/.pnpm/tar@7.5.22_patch_hash=fd38a2350a01d3eec80c7c393b88647baea164251683cffc481cb3aa5df2a75c/node_modules/tar/dist/esm/extract.js
const extractFileSync = (e) => {
	const t = new UnpackSync(e);
	const n = e.file;
	const r = fs.statSync(n);
	const i = e.maxReadSize || 16777216;
	new ReadStreamSync(n, {
		readSize: i,
		size: r.size
	}).pipe(t);
};
const extractFile = (e, t) => {
	const n = new Unpack(e);
	const r = e.maxReadSize || 16777216;
	const i = e.file;
	return new Promise((e, t) => {
		n.on("error", t);
		n.on("close", e);
		fs.stat(i, (e, a) => {
			if (e) t(e);
			else {
				const e = new ReadStream$1(i, {
					readSize: r,
					size: a.size
				});
				e.on("error", t);
				e.pipe(n);
			}
		});
	});
};
const extract = makeCommand(extractFileSync, extractFile, (e) => new UnpackSync(e), (e) => new Unpack(e), (e, t) => {
	if (t?.length) filesFilter(e, t);
});
//#endregion
//#region node_modules/.pnpm/tar@7.5.22_patch_hash=fd38a2350a01d3eec80c7c393b88647baea164251683cffc481cb3aa5df2a75c/node_modules/tar/dist/esm/replace.js
const replaceSync = (e, t) => {
	const n = new PackSync(e);
	let r = true;
	let i;
	let a;
	try {
		try {
			i = fs.openSync(e.file, "r+");
		} catch (t) {
			if (t?.code === "ENOENT") i = fs.openSync(e.file, "w+");
			else throw t;
		}
		const o = fs.fstatSync(i);
		const s = Buffer.alloc(512);
		POSITION: for (a = 0; a < o.size; a += 512) {
			for (let e = 0, t = 0; e < 512; e += t) {
				t = fs.readSync(i, s, e, s.length - e, a + e);
				if (a === 0 && s[0] === 31 && s[1] === 139) throw new Error("cannot append to compressed archives");
				if (!t) break POSITION;
			}
			const t = new Header(s);
			if (!t.cksumValid) break;
			const n = 512 * Math.ceil((t.size || 0) / 512);
			if (a + n + 512 > o.size) break;
			a += n;
			if (e.mtimeCache && t.mtime) e.mtimeCache.set(String(t.path), t.mtime);
		}
		r = false;
		streamSync(e, n, a, i, t);
	} finally {
		if (r) try {
			fs.closeSync(i);
		} catch {}
	}
};
const streamSync = (e, t, n, r, i) => {
	const a = new WriteStreamSync(e.file, {
		fd: r,
		start: n
	});
	t.pipe(a);
	addFilesSync(t, i);
};
const replaceAsync = (e, t) => {
	t = Array.from(t);
	const n = new Pack(e);
	const getPos = (t, n, r) => {
		const cb = (e, n) => {
			if (e) fs.close(t, (t) => r(e));
			else r(null, n);
		};
		let i = 0;
		if (n === 0) return cb(null, 0);
		let a = 0;
		const o = Buffer.alloc(512);
		const onread = (r, s) => {
			if (r || s === void 0) return cb(r);
			a += s;
			if (a < 512 && s) return fs.read(t, o, a, o.length - a, i + a, onread);
			if (i === 0 && o[0] === 31 && o[1] === 139) return cb(/* @__PURE__ */ new Error("cannot append to compressed archives"));
			if (a < 512) return cb(null, i);
			const c = new Header(o);
			if (!c.cksumValid) return cb(null, i);
			/* c8 ignore next */
			const l = 512 * Math.ceil((c.size ?? 0) / 512);
			if (i + l + 512 > n) return cb(null, i);
			i += l + 512;
			if (i >= n) return cb(null, i);
			if (e.mtimeCache && c.mtime) e.mtimeCache.set(String(c.path), c.mtime);
			a = 0;
			fs.read(t, o, 0, 512, i, onread);
		};
		fs.read(t, o, 0, 512, i, onread);
	};
	return new Promise((r, i) => {
		n.on("error", i);
		let a = "r+";
		const onopen = (o, s) => {
			if (o && o.code === "ENOENT" && a === "r+") {
				a = "w+";
				return fs.open(e.file, a, onopen);
			}
			if (o || !s) return i(o);
			fs.fstat(s, (a, o) => {
				if (a) return fs.close(s, () => i(a));
				getPos(s, o.size, (a, o) => {
					if (a) return i(a);
					const c = new WriteStream(e.file, {
						fd: s,
						start: o
					});
					n.pipe(c);
					c.on("error", i);
					c.on("close", r);
					addFilesAsync(n, t);
				});
			});
		};
		fs.open(e.file, a, onopen);
	});
};
const addFilesSync = (e, t) => {
	t.forEach((t) => {
		if (t.charAt(0) === "@") list({
			file: path.resolve(e.cwd, t.slice(1)),
			sync: true,
			noResume: true,
			onReadEntry: (t) => e.add(t)
		});
		else e.add(t);
	});
	e.end();
};
const addFilesAsync = async (e, t) => {
	for (const n of t) if (n.charAt(0) === "@") await list({
		file: path.resolve(String(e.cwd), n.slice(1)),
		noResume: true,
		onReadEntry: (t) => e.add(t)
	});
	else e.add(n);
	e.end();
};
const replace = makeCommand(
	replaceSync,
	replaceAsync,
	/* c8 ignore start */
	() => {
		throw new TypeError("file is required");
	},
	() => {
		throw new TypeError("file is required");
	},
	/* c8 ignore stop */
	(e, t) => {
		if (!isFile(e)) throw new TypeError("file is required");
		if (e.gzip || e.brotli || e.zstd || e.file.endsWith(".br") || e.file.endsWith(".tbr")) throw new TypeError("cannot append to compressed archives");
		if (!t?.length) throw new TypeError("no paths specified to add/replace");
	}
);
//#endregion
//#region node_modules/.pnpm/tar@7.5.22_patch_hash=fd38a2350a01d3eec80c7c393b88647baea164251683cffc481cb3aa5df2a75c/node_modules/tar/dist/esm/update.js
const update = makeCommand(replace.syncFile, replace.asyncFile, replace.syncNoFile, replace.asyncNoFile, (e, t = []) => {
	replace.validate?.(e, t);
	mtimeFilter(e);
});
const mtimeFilter = (e) => {
	const t = e.filter;
	if (!e.mtimeCache) e.mtimeCache = /* @__PURE__ */ new Map();
	e.filter = t ? (n, r) => t(n, r) && !((e.mtimeCache?.get(n) ?? r.mtime ?? 0) > (r.mtime ?? 0)) : (t, n) => !((e.mtimeCache?.get(t) ?? n.mtime ?? 0) > (n.mtime ?? 0));
};
//#endregion
export { Pax as _, UnpackSync as a, PackJob as c, WriteEntrySync as d, WriteEntryTar as f, ReadEntry as g, Parser as h, Unpack as i, PackSync as l, list as m, replace as n, create as o, filesFilter as p, extract as r, Pack as s, update as t, WriteEntry as u, Header as v, types_exports as y };