chaite
Version:
core for chatgpt-plugin and karin-plugin-chatgpt
1,660 lines (1,644 loc) • 475 kB
JavaScript
import { i as __require, t as __commonJS } from "../../rolldown-runtime-DVriDoez.mjs";
import { a as require_type, i as require_call_bind_apply_helpers, r as require_get_intrinsic } from "../axios/index.mjs-BJujW20l.mjs";
import { n as require_mime_types } from "../accepts/index.mjs-CtXuJELB.mjs";
//#region node_modules/.pnpm/inherits@2.0.4/node_modules/inherits/inherits_browser.js
var require_inherits_browser = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/inherits@2.0.4/node_modules/inherits/inherits_browser.js": ((exports, module) => {
if (typeof Object.create === "function") module.exports = function inherits$1(ctor, superCtor) {
if (superCtor) {
ctor.super_ = superCtor;
ctor.prototype = Object.create(superCtor.prototype, { constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
} });
}
};
else module.exports = function inherits$1(ctor, superCtor) {
if (superCtor) {
ctor.super_ = superCtor;
var TempCtor = function() {};
TempCtor.prototype = superCtor.prototype;
ctor.prototype = new TempCtor();
ctor.prototype.constructor = ctor;
}
};
}) });
//#endregion
//#region node_modules/.pnpm/inherits@2.0.4/node_modules/inherits/inherits.js
var require_inherits = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/inherits@2.0.4/node_modules/inherits/inherits.js": ((exports, module) => {
try {
var util$1 = __require("util");
/* istanbul ignore next */
if (typeof util$1.inherits !== "function") throw "";
module.exports = util$1.inherits;
} catch (e) {
/* istanbul ignore next */
module.exports = require_inherits_browser();
}
}) });
//#endregion
//#region node_modules/.pnpm/depd@2.0.0/node_modules/depd/index.js
var require_depd = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/depd@2.0.0/node_modules/depd/index.js": ((exports, module) => {
/*!
* depd
* Copyright(c) 2014-2018 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module dependencies.
*/
var relative = __require("path").relative;
/**
* Module exports.
*/
module.exports = depd;
/**
* Get the path to base files on.
*/
var basePath = process.cwd();
/**
* Determine if namespace is contained in the string.
*/
function containsNamespace(str, namespace) {
var vals = str.split(/[ ,]+/);
var ns = String(namespace).toLowerCase();
for (var i$3 = 0; i$3 < vals.length; i$3++) {
var val = vals[i$3];
if (val && (val === "*" || val.toLowerCase() === ns)) return true;
}
return false;
}
/**
* Convert a data descriptor to accessor descriptor.
*/
function convertDataDescriptorToAccessor(obj, prop, message) {
var descriptor = Object.getOwnPropertyDescriptor(obj, prop);
var value = descriptor.value;
descriptor.get = function getter() {
return value;
};
if (descriptor.writable) descriptor.set = function setter(val) {
return value = val;
};
delete descriptor.value;
delete descriptor.writable;
Object.defineProperty(obj, prop, descriptor);
return descriptor;
}
/**
* Create arguments string to keep arity.
*/
function createArgumentsString(arity) {
var str = "";
for (var i$3 = 0; i$3 < arity; i$3++) str += ", arg" + i$3;
return str.substr(2);
}
/**
* Create stack string from stack.
*/
function createStackString(stack) {
var str = this.name + ": " + this.namespace;
if (this.message) str += " deprecated " + this.message;
for (var i$3 = 0; i$3 < stack.length; i$3++) str += "\n at " + stack[i$3].toString();
return str;
}
/**
* Create deprecate for namespace in caller.
*/
function depd(namespace) {
if (!namespace) throw new TypeError("argument namespace is required");
var file = callSiteLocation(getStack()[1])[0];
function deprecate$3(message) {
log$2.call(deprecate$3, message);
}
deprecate$3._file = file;
deprecate$3._ignored = isignored(namespace);
deprecate$3._namespace = namespace;
deprecate$3._traced = istraced(namespace);
deprecate$3._warned = Object.create(null);
deprecate$3.function = wrapfunction;
deprecate$3.property = wrapproperty;
return deprecate$3;
}
/**
* Determine if event emitter has listeners of a given type.
*
* The way to do this check is done three different ways in Node.js >= 0.8
* so this consolidates them into a minimal set using instance methods.
*
* @param {EventEmitter} emitter
* @param {string} type
* @returns {boolean}
* @private
*/
function eehaslisteners(emitter, type) {
return (typeof emitter.listenerCount !== "function" ? emitter.listeners(type).length : emitter.listenerCount(type)) > 0;
}
/**
* Determine if namespace is ignored.
*/
function isignored(namespace) {
if (process.noDeprecation) return true;
return containsNamespace(process.env.NO_DEPRECATION || "", namespace);
}
/**
* Determine if namespace is traced.
*/
function istraced(namespace) {
if (process.traceDeprecation) return true;
return containsNamespace(process.env.TRACE_DEPRECATION || "", namespace);
}
/**
* Display deprecation message.
*/
function log$2(message, site) {
var haslisteners = eehaslisteners(process, "deprecation");
if (!haslisteners && this._ignored) return;
var caller;
var callFile;
var callSite;
var depSite;
var i$3 = 0;
var seen = false;
var stack = getStack();
var file = this._file;
if (site) {
depSite = site;
callSite = callSiteLocation(stack[1]);
callSite.name = depSite.name;
file = callSite[0];
} else {
i$3 = 2;
depSite = callSiteLocation(stack[i$3]);
callSite = depSite;
}
for (; i$3 < stack.length; i$3++) {
caller = callSiteLocation(stack[i$3]);
callFile = caller[0];
if (callFile === file) seen = true;
else if (callFile === this._file) file = this._file;
else if (seen) break;
}
var key$1 = caller ? depSite.join(":") + "__" + caller.join(":") : void 0;
if (key$1 !== void 0 && key$1 in this._warned) return;
this._warned[key$1] = true;
var msg = message;
if (!msg) msg = callSite === depSite || !callSite.name ? defaultMessage(depSite) : defaultMessage(callSite);
if (haslisteners) {
var err = DeprecationError(this._namespace, msg, stack.slice(i$3));
process.emit("deprecation", err);
return;
}
var output = (process.stderr.isTTY ? formatColor : formatPlain).call(this, msg, caller, stack.slice(i$3));
process.stderr.write(output + "\n", "utf8");
}
/**
* Get call site location as array.
*/
function callSiteLocation(callSite) {
var file = callSite.getFileName() || "<anonymous>";
var line = callSite.getLineNumber();
var colm = callSite.getColumnNumber();
if (callSite.isEval()) file = callSite.getEvalOrigin() + ", " + file;
var site = [
file,
line,
colm
];
site.callSite = callSite;
site.name = callSite.getFunctionName();
return site;
}
/**
* Generate a default message from the site.
*/
function defaultMessage(site) {
var callSite = site.callSite;
var funcName = site.name;
if (!funcName) funcName = "<anonymous@" + formatLocation(site) + ">";
var context = callSite.getThis();
var typeName = context && callSite.getTypeName();
if (typeName === "Object") typeName = void 0;
if (typeName === "Function") typeName = context.name || typeName;
return typeName && callSite.getMethodName() ? typeName + "." + funcName : funcName;
}
/**
* Format deprecation message without color.
*/
function formatPlain(msg, caller, stack) {
var formatted = (/* @__PURE__ */ new Date()).toUTCString() + " " + this._namespace + " deprecated " + msg;
if (this._traced) {
for (var i$3 = 0; i$3 < stack.length; i$3++) formatted += "\n at " + stack[i$3].toString();
return formatted;
}
if (caller) formatted += " at " + formatLocation(caller);
return formatted;
}
/**
* Format deprecation message with color.
*/
function formatColor(msg, caller, stack) {
var formatted = "\x1B[36;1m" + this._namespace + "\x1B[22;39m \x1B[33;1mdeprecated\x1B[22;39m \x1B[0m" + msg + "\x1B[39m";
if (this._traced) {
for (var i$3 = 0; i$3 < stack.length; i$3++) formatted += "\n \x1B[36mat " + stack[i$3].toString() + "\x1B[39m";
return formatted;
}
if (caller) formatted += " \x1B[36m" + formatLocation(caller) + "\x1B[39m";
return formatted;
}
/**
* Format call site location.
*/
function formatLocation(callSite) {
return relative(basePath, callSite[0]) + ":" + callSite[1] + ":" + callSite[2];
}
/**
* Get the stack as array of call sites.
*/
function getStack() {
var limit$1 = Error.stackTraceLimit;
var obj = {};
var prep = Error.prepareStackTrace;
Error.prepareStackTrace = prepareObjectStackTrace;
Error.stackTraceLimit = Math.max(10, limit$1);
Error.captureStackTrace(obj);
var stack = obj.stack.slice(1);
Error.prepareStackTrace = prep;
Error.stackTraceLimit = limit$1;
return stack;
}
/**
* Capture call site stack from v8.
*/
function prepareObjectStackTrace(obj, stack) {
return stack;
}
/**
* Return a wrapped function in a deprecation message.
*/
function wrapfunction(fn, message) {
if (typeof fn !== "function") throw new TypeError("argument fn must be a function");
var args = createArgumentsString(fn.length);
var site = callSiteLocation(getStack()[1]);
site.name = fn.name;
return new Function("fn", "log", "deprecate", "message", "site", "\"use strict\"\nreturn function (" + args + ") {log.call(deprecate, message, site)\nreturn fn.apply(this, arguments)\n}")(fn, log$2, this, message, site);
}
/**
* Wrap property in a deprecation message.
*/
function wrapproperty(obj, prop, message) {
if (!obj || typeof obj !== "object" && typeof obj !== "function") throw new TypeError("argument obj must be object");
var descriptor = Object.getOwnPropertyDescriptor(obj, prop);
if (!descriptor) throw new TypeError("must call property on owner object");
if (!descriptor.configurable) throw new TypeError("property must be configurable");
var deprecate$3 = this;
var site = callSiteLocation(getStack()[1]);
site.name = prop;
if ("value" in descriptor) descriptor = convertDataDescriptorToAccessor(obj, prop, message);
var get = descriptor.get;
var set = descriptor.set;
if (typeof get === "function") descriptor.get = function getter() {
log$2.call(deprecate$3, message, site);
return get.apply(this, arguments);
};
if (typeof set === "function") descriptor.set = function setter() {
log$2.call(deprecate$3, message, site);
return set.apply(this, arguments);
};
Object.defineProperty(obj, prop, descriptor);
}
/**
* Create DeprecationError for deprecation
*/
function DeprecationError(namespace, message, stack) {
var error = /* @__PURE__ */ new Error();
var stackString;
Object.defineProperty(error, "constructor", { value: DeprecationError });
Object.defineProperty(error, "message", {
configurable: true,
enumerable: false,
value: message,
writable: true
});
Object.defineProperty(error, "name", {
enumerable: false,
configurable: true,
value: "DeprecationError",
writable: true
});
Object.defineProperty(error, "namespace", {
configurable: true,
enumerable: false,
value: namespace,
writable: true
});
Object.defineProperty(error, "stack", {
configurable: true,
enumerable: false,
get: function() {
if (stackString !== void 0) return stackString;
return stackString = createStackString.call(this, stack);
},
set: function setter(val) {
stackString = val;
}
});
return error;
}
}) });
//#endregion
//#region node_modules/.pnpm/bytes@3.1.2/node_modules/bytes/index.js
/*!
* bytes
* Copyright(c) 2012-2014 TJ Holowaychuk
* Copyright(c) 2015 Jed Watson
* MIT Licensed
*/
var require_bytes = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/bytes@3.1.2/node_modules/bytes/index.js": ((exports, module) => {
/**
* Module exports.
* @public
*/
module.exports = bytes$5;
module.exports.format = format$2;
module.exports.parse = parse$4;
/**
* Module variables.
* @private
*/
var formatThousandsRegExp = /\B(?=(\d{3})+(?!\d))/g;
var formatDecimalsRegExp = /(?:\.0*|(\.[^0]+)0+)$/;
var map = {
b: 1,
kb: 1024,
mb: 1 << 20,
gb: 1 << 30,
tb: Math.pow(1024, 4),
pb: Math.pow(1024, 5)
};
var parseRegExp = /^((-|\+)?(\d+(?:\.\d+)?)) *(kb|mb|gb|tb|pb)$/i;
/**
* Convert the given value in bytes into a string or parse to string to an integer in bytes.
*
* @param {string|number} value
* @param {{
* case: [string],
* decimalPlaces: [number]
* fixedDecimals: [boolean]
* thousandsSeparator: [string]
* unitSeparator: [string]
* }} [options] bytes options.
*
* @returns {string|number|null}
*/
function bytes$5(value, options) {
if (typeof value === "string") return parse$4(value);
if (typeof value === "number") return format$2(value, options);
return null;
}
/**
* Format the given value in bytes into a string.
*
* If the value is negative, it is kept as such. If it is a float,
* it is rounded.
*
* @param {number} value
* @param {object} [options]
* @param {number} [options.decimalPlaces=2]
* @param {number} [options.fixedDecimals=false]
* @param {string} [options.thousandsSeparator=]
* @param {string} [options.unit=]
* @param {string} [options.unitSeparator=]
*
* @returns {string|null}
* @public
*/
function format$2(value, options) {
if (!Number.isFinite(value)) return null;
var mag = Math.abs(value);
var thousandsSeparator = options && options.thousandsSeparator || "";
var unitSeparator = options && options.unitSeparator || "";
var decimalPlaces = options && options.decimalPlaces !== void 0 ? options.decimalPlaces : 2;
var fixedDecimals = Boolean(options && options.fixedDecimals);
var unit = options && options.unit || "";
if (!unit || !map[unit.toLowerCase()]) if (mag >= map.pb) unit = "PB";
else if (mag >= map.tb) unit = "TB";
else if (mag >= map.gb) unit = "GB";
else if (mag >= map.mb) unit = "MB";
else if (mag >= map.kb) unit = "KB";
else unit = "B";
var str = (value / map[unit.toLowerCase()]).toFixed(decimalPlaces);
if (!fixedDecimals) str = str.replace(formatDecimalsRegExp, "$1");
if (thousandsSeparator) str = str.split(".").map(function(s$1, i$3) {
return i$3 === 0 ? s$1.replace(formatThousandsRegExp, thousandsSeparator) : s$1;
}).join(".");
return str + unitSeparator + unit;
}
/**
* Parse the string value into an integer in bytes.
*
* If no unit is given, it is assumed the value is in bytes.
*
* @param {number|string} val
*
* @returns {number|null}
* @public
*/
function parse$4(val) {
if (typeof val === "number" && !isNaN(val)) return val;
if (typeof val !== "string") return null;
var results = parseRegExp.exec(val);
var floatValue;
var unit = "b";
if (!results) {
floatValue = parseInt(val, 10);
unit = "b";
} else {
floatValue = parseFloat(results[1]);
unit = results[4].toLowerCase();
}
if (isNaN(floatValue)) return null;
return Math.floor(map[unit] * floatValue);
}
}) });
//#endregion
//#region node_modules/.pnpm/content-type@1.0.5/node_modules/content-type/index.js
/*!
* content-type
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/
var require_content_type = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/content-type@1.0.5/node_modules/content-type/index.js": ((exports) => {
/**
* RegExp to match *( ";" parameter ) in RFC 7231 sec 3.1.1.1
*
* parameter = token "=" ( token / quoted-string )
* token = 1*tchar
* tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*"
* / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~"
* / DIGIT / ALPHA
* ; any VCHAR, except delimiters
* quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE
* qdtext = HTAB / SP / %x21 / %x23-5B / %x5D-7E / obs-text
* obs-text = %x80-FF
* quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text )
*/
var PARAM_REGEXP = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g;
var TEXT_REGEXP = /^[\u000b\u0020-\u007e\u0080-\u00ff]+$/;
var TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
/**
* RegExp to match quoted-pair in RFC 7230 sec 3.2.6
*
* quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text )
* obs-text = %x80-FF
*/
var QESC_REGEXP = /\\([\u000b\u0020-\u00ff])/g;
/**
* RegExp to match chars that must be quoted-pair in RFC 7230 sec 3.2.6
*/
var QUOTE_REGEXP = /([\\"])/g;
/**
* RegExp to match type in RFC 7231 sec 3.1.1.1
*
* media-type = type "/" subtype
* type = token
* subtype = token
*/
var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
/**
* Module exports.
* @public
*/
exports.format = format$1;
exports.parse = parse$3;
/**
* Format object to media type.
*
* @param {object} obj
* @return {string}
* @public
*/
function format$1(obj) {
if (!obj || typeof obj !== "object") throw new TypeError("argument obj is required");
var parameters = obj.parameters;
var type = obj.type;
if (!type || !TYPE_REGEXP.test(type)) throw new TypeError("invalid type");
var string = type;
if (parameters && typeof parameters === "object") {
var param;
var params = Object.keys(parameters).sort();
for (var i$3 = 0; i$3 < params.length; i$3++) {
param = params[i$3];
if (!TOKEN_REGEXP.test(param)) throw new TypeError("invalid parameter name");
string += "; " + param + "=" + qstring$1(parameters[param]);
}
}
return string;
}
/**
* Parse media type to object.
*
* @param {string|object} string
* @return {Object}
* @public
*/
function parse$3(string) {
if (!string) throw new TypeError("argument string is required");
var header = typeof string === "object" ? getcontenttype$1(string) : string;
if (typeof header !== "string") throw new TypeError("argument string is required to be a string");
var index = header.indexOf(";");
var type = index !== -1 ? header.slice(0, index).trim() : header.trim();
if (!TYPE_REGEXP.test(type)) throw new TypeError("invalid media type");
var obj = new ContentType(type.toLowerCase());
if (index !== -1) {
var key$1;
var match;
var value;
PARAM_REGEXP.lastIndex = index;
while (match = PARAM_REGEXP.exec(header)) {
if (match.index !== index) throw new TypeError("invalid parameter format");
index += match[0].length;
key$1 = match[1].toLowerCase();
value = match[2];
if (value.charCodeAt(0) === 34) {
value = value.slice(1, -1);
if (value.indexOf("\\") !== -1) value = value.replace(QESC_REGEXP, "$1");
}
obj.parameters[key$1] = value;
}
if (index !== header.length) throw new TypeError("invalid parameter format");
}
return obj;
}
/**
* Get content-type from req/res objects.
*
* @param {object}
* @return {Object}
* @private
*/
function getcontenttype$1(obj) {
var header;
if (typeof obj.getHeader === "function") header = obj.getHeader("content-type");
else if (typeof obj.headers === "object") header = obj.headers && obj.headers["content-type"];
if (typeof header !== "string") throw new TypeError("content-type header is missing from object");
return header;
}
/**
* Quote a string if necessary.
*
* @param {string} val
* @return {string}
* @private
*/
function qstring$1(val) {
var str = String(val);
if (TOKEN_REGEXP.test(str)) return str;
if (str.length > 0 && !TEXT_REGEXP.test(str)) throw new TypeError("invalid parameter value");
return "\"" + str.replace(QUOTE_REGEXP, "\\$1") + "\"";
}
/**
* Class to represent a content type.
* @private
*/
function ContentType(type) {
this.parameters = Object.create(null);
this.type = type;
}
}) });
//#endregion
//#region node_modules/.pnpm/setprototypeof@1.2.0/node_modules/setprototypeof/index.js
var require_setprototypeof = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/setprototypeof@1.2.0/node_modules/setprototypeof/index.js": ((exports, module) => {
module.exports = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array ? setProtoOf : mixinProperties);
function setProtoOf(obj, proto) {
obj.__proto__ = proto;
return obj;
}
function mixinProperties(obj, proto) {
for (var prop in proto) if (!Object.prototype.hasOwnProperty.call(obj, prop)) obj[prop] = proto[prop];
return obj;
}
}) });
//#endregion
//#region node_modules/.pnpm/statuses@2.0.1/node_modules/statuses/codes.json
var require_codes = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/statuses@2.0.1/node_modules/statuses/codes.json": ((exports, module) => {
module.exports = {
"100": "Continue",
"101": "Switching Protocols",
"102": "Processing",
"103": "Early Hints",
"200": "OK",
"201": "Created",
"202": "Accepted",
"203": "Non-Authoritative Information",
"204": "No Content",
"205": "Reset Content",
"206": "Partial Content",
"207": "Multi-Status",
"208": "Already Reported",
"226": "IM Used",
"300": "Multiple Choices",
"301": "Moved Permanently",
"302": "Found",
"303": "See Other",
"304": "Not Modified",
"305": "Use Proxy",
"307": "Temporary Redirect",
"308": "Permanent Redirect",
"400": "Bad Request",
"401": "Unauthorized",
"402": "Payment Required",
"403": "Forbidden",
"404": "Not Found",
"405": "Method Not Allowed",
"406": "Not Acceptable",
"407": "Proxy Authentication Required",
"408": "Request Timeout",
"409": "Conflict",
"410": "Gone",
"411": "Length Required",
"412": "Precondition Failed",
"413": "Payload Too Large",
"414": "URI Too Long",
"415": "Unsupported Media Type",
"416": "Range Not Satisfiable",
"417": "Expectation Failed",
"418": "I'm a Teapot",
"421": "Misdirected Request",
"422": "Unprocessable Entity",
"423": "Locked",
"424": "Failed Dependency",
"425": "Too Early",
"426": "Upgrade Required",
"428": "Precondition Required",
"429": "Too Many Requests",
"431": "Request Header Fields Too Large",
"451": "Unavailable For Legal Reasons",
"500": "Internal Server Error",
"501": "Not Implemented",
"502": "Bad Gateway",
"503": "Service Unavailable",
"504": "Gateway Timeout",
"505": "HTTP Version Not Supported",
"506": "Variant Also Negotiates",
"507": "Insufficient Storage",
"508": "Loop Detected",
"509": "Bandwidth Limit Exceeded",
"510": "Not Extended",
"511": "Network Authentication Required"
};
}) });
//#endregion
//#region node_modules/.pnpm/statuses@2.0.1/node_modules/statuses/index.js
/*!
* statuses
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2016 Douglas Christopher Wilson
* MIT Licensed
*/
var require_statuses = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/statuses@2.0.1/node_modules/statuses/index.js": ((exports, module) => {
/**
* Module dependencies.
* @private
*/
var codes = require_codes();
/**
* Module exports.
* @public
*/
module.exports = status;
status.message = codes;
status.code = createMessageToStatusCodeMap(codes);
status.codes = createStatusCodeList(codes);
status.redirect = {
300: true,
301: true,
302: true,
303: true,
305: true,
307: true,
308: true
};
status.empty = {
204: true,
205: true,
304: true
};
status.retry = {
502: true,
503: true,
504: true
};
/**
* Create a map of message to status code.
* @private
*/
function createMessageToStatusCodeMap(codes$1) {
var map$1 = {};
Object.keys(codes$1).forEach(function forEachCode(code) {
var message = codes$1[code];
var status$1 = Number(code);
map$1[message.toLowerCase()] = status$1;
});
return map$1;
}
/**
* Create a list of all status codes.
* @private
*/
function createStatusCodeList(codes$1) {
return Object.keys(codes$1).map(function mapCode(code) {
return Number(code);
});
}
/**
* Get the status code for given message.
* @private
*/
function getStatusCode(message) {
var msg = message.toLowerCase();
if (!Object.prototype.hasOwnProperty.call(status.code, msg)) throw new Error("invalid status message: \"" + message + "\"");
return status.code[msg];
}
/**
* Get the status message for given code.
* @private
*/
function getStatusMessage(code) {
if (!Object.prototype.hasOwnProperty.call(status.message, code)) throw new Error("invalid status code: " + code);
return status.message[code];
}
/**
* Get the status code.
*
* Given a number, this will throw if it is not a known status
* code, otherwise the code will be returned. Given a string,
* the string will be parsed for a number and return the code
* if valid, otherwise will lookup the code assuming this is
* the status message.
*
* @param {string|number} code
* @returns {number}
* @public
*/
function status(code) {
if (typeof code === "number") return getStatusMessage(code);
if (typeof code !== "string") throw new TypeError("code must be a number or string");
var n = parseInt(code, 10);
if (!isNaN(n)) return getStatusMessage(n);
return getStatusCode(code);
}
}) });
//#endregion
//#region node_modules/.pnpm/toidentifier@1.0.1/node_modules/toidentifier/index.js
/*!
* toidentifier
* Copyright(c) 2016 Douglas Christopher Wilson
* MIT Licensed
*/
var require_toidentifier = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/toidentifier@1.0.1/node_modules/toidentifier/index.js": ((exports, module) => {
/**
* Module exports.
* @public
*/
module.exports = toIdentifier$1;
/**
* Trasform the given string into a JavaScript identifier
*
* @param {string} str
* @returns {string}
* @public
*/
function toIdentifier$1(str) {
return str.split(" ").map(function(token) {
return token.slice(0, 1).toUpperCase() + token.slice(1);
}).join("").replace(/[^ _0-9a-z]/gi, "");
}
}) });
//#endregion
//#region node_modules/.pnpm/http-errors@2.0.0/node_modules/http-errors/index.js
/*!
* http-errors
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2016 Douglas Christopher Wilson
* MIT Licensed
*/
var require_http_errors = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/http-errors@2.0.0/node_modules/http-errors/index.js": ((exports, module) => {
/**
* Module dependencies.
* @private
*/
var deprecate$2 = require_depd()("http-errors");
var setPrototypeOf = require_setprototypeof();
var statuses = require_statuses();
var inherits = require_inherits();
var toIdentifier = require_toidentifier();
/**
* Module exports.
* @public
*/
module.exports = createError$4;
module.exports.HttpError = createHttpErrorConstructor();
module.exports.isHttpError = createIsHttpErrorFunction(module.exports.HttpError);
populateConstructorExports(module.exports, statuses.codes, module.exports.HttpError);
/**
* Get the code class of a status code.
* @private
*/
function codeClass(status$1) {
return Number(String(status$1).charAt(0) + "00");
}
/**
* Create a new HTTP Error.
*
* @returns {Error}
* @public
*/
function createError$4() {
var err;
var msg;
var status$1 = 500;
var props = {};
for (var i$3 = 0; i$3 < arguments.length; i$3++) {
var arg = arguments[i$3];
var type = typeof arg;
if (type === "object" && arg instanceof Error) {
err = arg;
status$1 = err.status || err.statusCode || status$1;
} else if (type === "number" && i$3 === 0) status$1 = arg;
else if (type === "string") msg = arg;
else if (type === "object") props = arg;
else throw new TypeError("argument #" + (i$3 + 1) + " unsupported type " + type);
}
if (typeof status$1 === "number" && (status$1 < 400 || status$1 >= 600)) deprecate$2("non-error status code; use only 4xx or 5xx status codes");
if (typeof status$1 !== "number" || !statuses.message[status$1] && (status$1 < 400 || status$1 >= 600)) status$1 = 500;
var HttpError = createError$4[status$1] || createError$4[codeClass(status$1)];
if (!err) {
err = HttpError ? new HttpError(msg) : new Error(msg || statuses.message[status$1]);
Error.captureStackTrace(err, createError$4);
}
if (!HttpError || !(err instanceof HttpError) || err.status !== status$1) {
err.expose = status$1 < 500;
err.status = err.statusCode = status$1;
}
for (var key$1 in props) if (key$1 !== "status" && key$1 !== "statusCode") err[key$1] = props[key$1];
return err;
}
/**
* Create HTTP error abstract base class.
* @private
*/
function createHttpErrorConstructor() {
function HttpError() {
throw new TypeError("cannot construct abstract class");
}
inherits(HttpError, Error);
return HttpError;
}
/**
* Create a constructor for a client error.
* @private
*/
function createClientErrorConstructor(HttpError, name, code) {
var className = toClassName(name);
function ClientError(message) {
var msg = message != null ? message : statuses.message[code];
var err = new Error(msg);
Error.captureStackTrace(err, ClientError);
setPrototypeOf(err, ClientError.prototype);
Object.defineProperty(err, "message", {
enumerable: true,
configurable: true,
value: msg,
writable: true
});
Object.defineProperty(err, "name", {
enumerable: false,
configurable: true,
value: className,
writable: true
});
return err;
}
inherits(ClientError, HttpError);
nameFunc(ClientError, className);
ClientError.prototype.status = code;
ClientError.prototype.statusCode = code;
ClientError.prototype.expose = true;
return ClientError;
}
/**
* Create function to test is a value is a HttpError.
* @private
*/
function createIsHttpErrorFunction(HttpError) {
return function isHttpError(val) {
if (!val || typeof val !== "object") return false;
if (val instanceof HttpError) return true;
return val instanceof Error && typeof val.expose === "boolean" && typeof val.statusCode === "number" && val.status === val.statusCode;
};
}
/**
* Create a constructor for a server error.
* @private
*/
function createServerErrorConstructor(HttpError, name, code) {
var className = toClassName(name);
function ServerError(message) {
var msg = message != null ? message : statuses.message[code];
var err = new Error(msg);
Error.captureStackTrace(err, ServerError);
setPrototypeOf(err, ServerError.prototype);
Object.defineProperty(err, "message", {
enumerable: true,
configurable: true,
value: msg,
writable: true
});
Object.defineProperty(err, "name", {
enumerable: false,
configurable: true,
value: className,
writable: true
});
return err;
}
inherits(ServerError, HttpError);
nameFunc(ServerError, className);
ServerError.prototype.status = code;
ServerError.prototype.statusCode = code;
ServerError.prototype.expose = false;
return ServerError;
}
/**
* Set the name of a function, if possible.
* @private
*/
function nameFunc(func, name) {
var desc = Object.getOwnPropertyDescriptor(func, "name");
if (desc && desc.configurable) {
desc.value = name;
Object.defineProperty(func, "name", desc);
}
}
/**
* Populate the exports object with constructors for every error class.
* @private
*/
function populateConstructorExports(exports$1, codes$1, HttpError) {
codes$1.forEach(function forEachCode(code) {
var CodeError;
var name = toIdentifier(statuses.message[code]);
switch (codeClass(code)) {
case 400:
CodeError = createClientErrorConstructor(HttpError, name, code);
break;
case 500:
CodeError = createServerErrorConstructor(HttpError, name, code);
break;
}
if (CodeError) {
exports$1[code] = CodeError;
exports$1[name] = CodeError;
}
});
}
/**
* Get a class name from a name identifier.
* @private
*/
function toClassName(name) {
return name.substr(-5) !== "Error" ? name + "Error" : name;
}
}) });
//#endregion
//#region node_modules/.pnpm/ms@2.0.0/node_modules/ms/index.js
var require_ms = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/ms@2.0.0/node_modules/ms/index.js": ((exports, module) => {
/**
* Helpers.
*/
var s = 1e3;
var m = s * 60;
var h = m * 60;
var d = h * 24;
var y = d * 365.25;
/**
* Parse or format the given `val`.
*
* Options:
*
* - `long` verbose formatting [false]
*
* @param {String|Number} val
* @param {Object} [options]
* @throws {Error} throw an error if val is not a non-empty string or a number
* @return {String|Number}
* @api public
*/
module.exports = function(val, options) {
options = options || {};
var type = typeof val;
if (type === "string" && val.length > 0) return parse$2(val);
else if (type === "number" && isNaN(val) === false) return options.long ? fmtLong(val) : fmtShort(val);
throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(val));
};
/**
* Parse the given `str` and return milliseconds.
*
* @param {String} str
* @return {Number}
* @api private
*/
function parse$2(str) {
str = String(str);
if (str.length > 100) return;
var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str);
if (!match) return;
var n = parseFloat(match[1]);
switch ((match[2] || "ms").toLowerCase()) {
case "years":
case "year":
case "yrs":
case "yr":
case "y": return n * y;
case "days":
case "day":
case "d": return n * d;
case "hours":
case "hour":
case "hrs":
case "hr":
case "h": return n * h;
case "minutes":
case "minute":
case "mins":
case "min":
case "m": return n * m;
case "seconds":
case "second":
case "secs":
case "sec":
case "s": return n * s;
case "milliseconds":
case "millisecond":
case "msecs":
case "msec":
case "ms": return n;
default: return;
}
}
/**
* Short format for `ms`.
*
* @param {Number} ms
* @return {String}
* @api private
*/
function fmtShort(ms) {
if (ms >= d) return Math.round(ms / d) + "d";
if (ms >= h) return Math.round(ms / h) + "h";
if (ms >= m) return Math.round(ms / m) + "m";
if (ms >= s) return Math.round(ms / s) + "s";
return ms + "ms";
}
/**
* Long format for `ms`.
*
* @param {Number} ms
* @return {String}
* @api private
*/
function fmtLong(ms) {
return plural(ms, d, "day") || plural(ms, h, "hour") || plural(ms, m, "minute") || plural(ms, s, "second") || ms + " ms";
}
/**
* Pluralization helper.
*/
function plural(ms, n, name) {
if (ms < n) return;
if (ms < n * 1.5) return Math.floor(ms / n) + " " + name;
return Math.ceil(ms / n) + " " + name + "s";
}
}) });
//#endregion
//#region node_modules/.pnpm/debug@2.6.9/node_modules/debug/src/debug.js
var require_debug = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/debug@2.6.9/node_modules/debug/src/debug.js": ((exports, module) => {
/**
* This is the common logic for both the Node.js and web browser
* implementations of `debug()`.
*
* Expose `debug()` as the module.
*/
exports = module.exports = createDebug.debug = createDebug["default"] = createDebug;
exports.coerce = coerce;
exports.disable = disable;
exports.enable = enable;
exports.enabled = enabled;
exports.humanize = require_ms();
/**
* The currently active debug mode names, and names to skip.
*/
exports.names = [];
exports.skips = [];
/**
* Map of special "%n" handling functions, for the debug "format" argument.
*
* Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
*/
exports.formatters = {};
/**
* Previous log timestamp.
*/
var prevTime;
/**
* Select a color.
* @param {String} namespace
* @return {Number}
* @api private
*/
function selectColor(namespace) {
var hash = 0, i$3;
for (i$3 in namespace) {
hash = (hash << 5) - hash + namespace.charCodeAt(i$3);
hash |= 0;
}
return exports.colors[Math.abs(hash) % exports.colors.length];
}
/**
* Create a debugger with the given `namespace`.
*
* @param {String} namespace
* @return {Function}
* @api public
*/
function createDebug(namespace) {
function debug$4() {
if (!debug$4.enabled) return;
var self = debug$4;
var curr = +/* @__PURE__ */ new Date();
self.diff = curr - (prevTime || curr);
self.prev = prevTime;
self.curr = curr;
prevTime = curr;
var args = new Array(arguments.length);
for (var i$3 = 0; i$3 < args.length; i$3++) args[i$3] = arguments[i$3];
args[0] = exports.coerce(args[0]);
if ("string" !== typeof args[0]) args.unshift("%O");
var index = 0;
args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format$3) {
if (match === "%%") return match;
index++;
var formatter = exports.formatters[format$3];
if ("function" === typeof formatter) {
var val = args[index];
match = formatter.call(self, val);
args.splice(index, 1);
index--;
}
return match;
});
exports.formatArgs.call(self, args);
(debug$4.log || exports.log || console.log.bind(console)).apply(self, args);
}
debug$4.namespace = namespace;
debug$4.enabled = exports.enabled(namespace);
debug$4.useColors = exports.useColors();
debug$4.color = selectColor(namespace);
if ("function" === typeof exports.init) exports.init(debug$4);
return debug$4;
}
/**
* Enables a debug mode by namespaces. This can include modes
* separated by a colon and wildcards.
*
* @param {String} namespaces
* @api public
*/
function enable(namespaces) {
exports.save(namespaces);
exports.names = [];
exports.skips = [];
var split = (typeof namespaces === "string" ? namespaces : "").split(/[\s,]+/);
var len = split.length;
for (var i$3 = 0; i$3 < len; i$3++) {
if (!split[i$3]) continue;
namespaces = split[i$3].replace(/\*/g, ".*?");
if (namespaces[0] === "-") exports.skips.push(/* @__PURE__ */ new RegExp("^" + namespaces.substr(1) + "$"));
else exports.names.push(/* @__PURE__ */ new RegExp("^" + namespaces + "$"));
}
}
/**
* Disable debug output.
*
* @api public
*/
function disable() {
exports.enable("");
}
/**
* Returns true if the given mode name is enabled, false otherwise.
*
* @param {String} name
* @return {Boolean}
* @api public
*/
function enabled(name) {
var i$3, len;
for (i$3 = 0, len = exports.skips.length; i$3 < len; i$3++) if (exports.skips[i$3].test(name)) return false;
for (i$3 = 0, len = exports.names.length; i$3 < len; i$3++) if (exports.names[i$3].test(name)) return true;
return false;
}
/**
* Coerce `val`.
*
* @param {Mixed} val
* @return {Mixed}
* @api private
*/
function coerce(val) {
if (val instanceof Error) return val.stack || val.message;
return val;
}
}) });
//#endregion
//#region node_modules/.pnpm/debug@2.6.9/node_modules/debug/src/browser.js
var require_browser = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/debug@2.6.9/node_modules/debug/src/browser.js": ((exports, module) => {
/**
* This is the web browser implementation of `debug()`.
*
* Expose `debug()` as the module.
*/
exports = module.exports = require_debug();
exports.log = log$1;
exports.formatArgs = formatArgs$1;
exports.save = save$1;
exports.load = load$1;
exports.useColors = useColors$1;
exports.storage = "undefined" != typeof chrome && "undefined" != typeof chrome.storage ? chrome.storage.local : localstorage();
/**
* Colors.
*/
exports.colors = [
"lightseagreen",
"forestgreen",
"goldenrod",
"dodgerblue",
"darkorchid",
"crimson"
];
/**
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
* and the Firebug extension (any Firefox version) are known
* to support "%c" CSS customizations.
*
* TODO: add a `localStorage` variable to explicitly enable/disable colors
*/
function useColors$1() {
if (typeof window !== "undefined" && window.process && window.process.type === "renderer") return true;
return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
}
/**
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
*/
exports.formatters.j = function(v) {
try {
return JSON.stringify(v);
} catch (err) {
return "[UnexpectedJSONParseError]: " + err.message;
}
};
/**
* Colorize log arguments if enabled.
*
* @api public
*/
function formatArgs$1(args) {
var useColors$2 = this.useColors;
args[0] = (useColors$2 ? "%c" : "") + this.namespace + (useColors$2 ? " %c" : " ") + args[0] + (useColors$2 ? "%c " : " ") + "+" + exports.humanize(this.diff);
if (!useColors$2) return;
var c = "color: " + this.color;
args.splice(1, 0, c, "color: inherit");
var index = 0;
var lastC = 0;
args[0].replace(/%[a-zA-Z%]/g, function(match) {
if ("%%" === match) return;
index++;
if ("%c" === match) lastC = index;
});
args.splice(lastC, 0, c);
}
/**
* Invokes `console.log()` when available.
* No-op when `console.log` is not a "function".
*
* @api public
*/
function log$1() {
return "object" === typeof console && console.log && Function.prototype.apply.call(console.log, console, arguments);
}
/**
* Save `namespaces`.
*
* @param {String} namespaces
* @api private
*/
function save$1(namespaces) {
try {
if (null == namespaces) exports.storage.removeItem("debug");
else exports.storage.debug = namespaces;
} catch (e) {}
}
/**
* Load `namespaces`.
*
* @return {String} returns the previously persisted debug modes
* @api private
*/
function load$1() {
var r;
try {
r = exports.storage.debug;
} catch (e) {}
if (!r && typeof process !== "undefined" && "env" in process) r = process.env.DEBUG;
return r;
}
/**
* Enable namespaces listed in `localStorage.debug` initially.
*/
exports.enable(load$1());
/**
* Localstorage attempts to return the localstorage.
*
* This is necessary because safari throws
* when a user disables cookies/localstorage
* and you attempt to access it.
*
* @return {LocalStorage}
* @api private
*/
function localstorage() {
try {
return window.localStorage;
} catch (e) {}
}
}) });
//#endregion
//#region node_modules/.pnpm/debug@2.6.9/node_modules/debug/src/node.js
var require_node = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/debug@2.6.9/node_modules/debug/src/node.js": ((exports, module) => {
/**
* Module dependencies.
*/
var tty = __require("tty");
var util = __require("util");
/**
* This is the Node.js implementation of `debug()`.
*
* Expose `debug()` as the module.
*/
exports = module.exports = require_debug();
exports.init = init;
exports.log = log;
exports.formatArgs = formatArgs;
exports.save = save;
exports.load = load;
exports.useColors = useColors;
/**
* Colors.
*/
exports.colors = [
6,
2,
3,
4,
5,
1
];
/**
* Build up the default `inspectOpts` object from the environment variables.
*
* $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
*/
exports.inspectOpts = Object.keys(process.env).filter(function(key$1) {
return /^debug_/i.test(key$1);
}).reduce(function(obj, key$1) {
var prop = key$1.substring(6).toLowerCase().replace(/_([a-z])/g, function(_, k) {
return k.toUpperCase();
});
var val = process.env[key$1];
if (/^(yes|on|true|enabled)$/i.test(val)) val = true;
else if (/^(no|off|false|disabled)$/i.test(val)) val = false;
else if (val === "null") val = null;
else val = Number(val);
obj[prop] = val;
return obj;
}, {});
/**
* The file descriptor to write the `debug()` calls to.
* Set the `DEBUG_FD` env variable to override with another value. i.e.:
*
* $ DEBUG_FD=3 node script.js 3>debug.log
*/
var fd = parseInt(process.env.DEBUG_FD, 10) || 2;
if (1 !== fd && 2 !== fd) util.deprecate(function() {}, "except for stderr(2) and stdout(1), any other usage of DEBUG_FD is deprecated. Override debug.log if you want to use a different log function (https://git.io/debug_fd)")();
var stream = 1 === fd ? process.stdout : 2 === fd ? process.stderr : createWritableStdioStream(fd);
/**
* Is stdout a TTY? Colored output is enabled when `true`.
*/
function useColors() {
return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(fd);
}
/**
* Map %o to `util.inspect()`, all on a single line.
*/
exports.formatters.o = function(v) {
this.inspectOpts.colors = this.useColors;
return util.inspect(v, this.inspectOpts).split("\n").map(function(str) {
return str.trim();
}).join(" ");
};
/**
* Map %o to `util.inspect()`, allowing multiple lines if needed.
*/
exports.formatters.O = function(v) {
this.inspectOpts.colors = this.useColors;
return util.inspect(v, this.inspectOpts);
};
/**
* Adds ANSI color escape codes if enabled.
*
* @api public
*/
function formatArgs(args) {
var name = this.namespace;
if (this.useColors) {
var c = this.color;
var prefix = " \x1B[3" + c + ";1m" + name + " \x1B[0m";
args[0] = prefix + args[0].split("\n").join("\n" + prefix);
args.push("\x1B[3" + c + "m+" + exports.humanize(this.diff) + "\x1B[0m");
} else args[0] = (/* @__PURE__ */ new Date()).toUTCString() + " " + name + " " + args[0];
}
/**
* Invokes `util.format()` with the specified arguments and writes to `stream`.
*/
function log() {
return stream.write(util.format.apply(util, arguments) + "\n");
}
/**
* Save `namespaces`.
*
* @param {String} namespaces
* @api private
*/
function save(namespaces) {
if (null == namespaces) delete process.env.DEBUG;
else process.env.DEBUG = namespaces;
}
/**
* Load `namespaces`.
*
* @return {String} returns the previously persisted debug modes
* @api private
*/
function load() {
return process.env.DEBUG;
}
/**
* Copied from `node/src/node.js`.
*
* XXX: It's lame that node doesn't expose this API out-of-the-box. It also
* relies on the undocumented `tty_wrap.guessHandleType()` which is also lame.
*/
function createWritableStdioStream(fd$1) {
var stream$1;
switch (process.binding("tty_wrap").guessHandleType(fd$1)) {
case "TTY":
stream$1 = new tty.WriteStream(fd$1);
stream$1._type = "tty";
if (stream$1._handle && stream$1._handle.unref) stream$1._handle.unref();
break;
case "FILE":
stream$1 = new (__require("fs")).SyncWriteStream(fd$1, { autoClose: false });
stream$1._type = "fs";
break;
case "PIPE":
case "TCP":
stream$1 = new (__require("net")).Socket({
fd: fd$1,
readable: false,
writable: true
});
stream$1.readable = false;
stream$1.read = null;
stream$1._type = "pipe";
if (stream$1._handle && stream$1._handle.unref) stream$1._handle.unref();
break;
default: throw new Error("Implement me. Unknown stream file type!");
}
stream$1.fd = fd$1;
stream$1._isStdio = true;
return stream$1;
}
/**
* Init logic for `debug` instances.
*
* Create a new `inspectOpts` object in case `useColors` is set
* differently for a particular `debug` instance.
*/
function init(debug$4) {
debug$4.inspectOpts = {};
var keys = Object.keys(exports.inspectOpts);
for (var i$3 = 0; i$3 < keys.length; i$3++) debug$4.inspectOpts[keys[i$3]] = exports.inspectOpts[keys[i$3]];
}
/**
* Enable namespaces listed in `process.env.DEBUG` initially.
*/
exports.enable(load());
}) });
//#endregion
//#region node_modules/.pnpm/debug@2.6.9/node_modules/debug/src/index.js
var require_src = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/debug@2.6.9/node_modules/debug/src/index.js": ((exports, module) => {
/**
* Detect Electron renderer process, which is node, but we should
* treat as a browser.
*/
if (typeof process !== "undefined" && process.type === "renderer") module.exports = require_browser();
else module.exports = require_node();
}) });
//#endregion
//#region node_modules/.pnpm/destroy@1.2.0/node_modules/destroy/index.js
/*!
* destroy
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2015-2022 Douglas Christopher Wilson
* MIT Licensed
*/
var require_destroy = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/destroy@1.2.0/node_modules/destroy/index.js": ((exports, module) => {
/**
* Module dependencies.
* @private
*/
var EventEmitter = __require("events").EventEmitter;
var ReadStream = __require("fs").ReadStream;
var Stream = __require("stream");
var Zlib = __require("zlib");
/**
* Module exports.
* @public
*/
module.exports = destroy$1;
/**
* Destroy the given stream, and optionally suppress any future `error` events.
*
* @param {object} stream
* @param {boolean} suppress
* @public
*/
function destroy$1(stream$1, suppress) {
if (isFsReadStream(stream$1)) destroyReadStream(stream$1);
else if (isZlibStream(stream$1)) destroyZlibStream(stream$1);
else if (hasDestroy(stream$1)) stream$1.destroy();
if (isEventEmitter(stream$1) && suppress) {
stream$1.removeAllListeners("error");
stream$1.addListener("error", noop);
}
return stream$1;
}
/**
* Destroy a ReadStream.
*
* @param {object} stream
* @private
*/
function destroyReadStream(stream$1) {
stream$1.destroy();
if (typeof stream$1.close === "function") stream$1.on("open", onOpenClose);
}
/**
* Close a Zlib stream.
*
* Zlib streams below Node.js 4.5.5 have a buggy implementation
* of .close() when zlib encountered an error.
*
* @param {object} stream
* @private
*/
function closeZlibStream(stream$1) {
if (stream$1._hadError === true) {
var prop = stream$1._binding === null ? "_binding" : "_handle";
stream$1[prop] = { close: function() {
this[prop] = null;
} };
}
stream$1.close();
}
/**
* Destroy a Zlib stream.
*
* Zlib streams don't have a destroy function in Node.js 6. On top of that
* simply calling destroy on a zlib stream in Node.js 8+ will result in a
* memory leak. So until that is fixed, we need to call both close AND destroy.
*
* PR to fix memory leak: https://github.com/nodejs/node/pull/23734
*
* In