//#region rolldown:runtime
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __commonJS = (cb, mod) => function() {
	return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __copyProps = (to, from, except, desc) => {
	if (from && typeof from === "object" || typeof from === "function") for (var keys$1 = __getOwnPropNames(from), i = 0, n = keys$1.length, key; i < n; i++) {
		key = keys$1[i];
		if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
			get: ((k) => from[k]).bind(null, key),
			enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
		});
	}
	return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
	value: mod,
	enumerable: true
}) : target, mod));

//#endregion
let node_http = require("node:http");
node_http = __toESM(node_http);
let node_crypto = require("node:crypto");
node_crypto = __toESM(node_crypto);
let node_fs = require("node:fs");
node_fs = __toESM(node_fs);

//#region src/callbackServer.ts
const HOSTED_CALLBACK_URL_BASE = "https://oauth.yaak.app/redirect";
const DEFAULT_LOCALHOST_PORT = 8765;
const CALLBACK_TIMEOUT_MS = 300 * 1e3;
/** Singleton: only one callback server runs at a time across all OAuth flows. */
let activeServer = null;
/**
* Start a local HTTP server to receive OAuth callbacks.
* Only one server runs at a time — if a previous server is still active,
* it is stopped before starting the new one.
* Returns the port, redirect URI, and a promise that resolves when the callback is received.
*/
function startCallbackServer(options) {
	if (activeServer) {
		console.log("[oauth2] Stopping previous callback server before starting new one");
		activeServer.stop();
		activeServer = null;
	}
	const { port = 0, path = "/callback", timeoutMs = CALLBACK_TIMEOUT_MS } = options;
	return new Promise((resolve, reject) => {
		let callbackResolve = null;
		let callbackReject = null;
		let timeoutHandle = null;
		let stopped = false;
		const server = node_http.default.createServer((req, res) => {
			const reqUrl = new URL(req.url ?? "/", `http://${req.headers.host}`);
			if (reqUrl.pathname !== path && reqUrl.pathname !== `${path}/`) {
				res.writeHead(404, { "Content-Type": "text/plain" });
				res.end("Not Found");
				return;
			}
			if (req.method === "POST") {
				let body = "";
				req.on("data", (chunk) => {
					body += chunk.toString();
				});
				req.on("end", () => {
					try {
						const { url: callbackUrl } = JSON.parse(body);
						if (!callbackUrl || typeof callbackUrl !== "string") {
							res.writeHead(400, { "Content-Type": "text/plain" });
							res.end("Missing url in request body");
							return;
						}
						res.writeHead(200, { "Content-Type": "text/plain" });
						res.end("OK");
						if (callbackResolve) {
							callbackResolve(callbackUrl);
							callbackResolve = null;
							callbackReject = null;
						}
						setTimeout(() => stopServer(), 100);
					} catch {
						res.writeHead(400, { "Content-Type": "text/plain" });
						res.end("Invalid JSON");
					}
				});
				return;
			}
			res.writeHead(200, { "Content-Type": "text/html" });
			res.end(getFragmentForwardingHtml());
		});
		server.on("error", (err) => {
			if (!stopped) reject(err);
		});
		const stopServer = () => {
			if (stopped) return;
			stopped = true;
			if (activeServer?.stop === stopServer) activeServer = null;
			if (timeoutHandle) {
				clearTimeout(timeoutHandle);
				timeoutHandle = null;
			}
			server.close();
			if (callbackReject) {
				callbackReject(/* @__PURE__ */ new Error("Callback server stopped"));
				callbackResolve = null;
				callbackReject = null;
			}
		};
		server.listen(port, "127.0.0.1", () => {
			const address = server.address();
			if (!address || typeof address === "string") {
				reject(/* @__PURE__ */ new Error("Failed to get server address"));
				return;
			}
			const actualPort = address.port;
			const redirectUri = `http://127.0.0.1:${actualPort}${path}`;
			console.log(`[oauth2] Callback server listening on ${redirectUri}`);
			const result = {
				port: actualPort,
				redirectUri,
				waitForCallback: () => {
					return new Promise((res, rej) => {
						if (stopped) {
							rej(/* @__PURE__ */ new Error("Callback server already stopped"));
							return;
						}
						callbackResolve = res;
						callbackReject = rej;
						timeoutHandle = setTimeout(() => {
							if (callbackReject) {
								callbackReject(/* @__PURE__ */ new Error("Authorization timed out"));
								callbackResolve = null;
								callbackReject = null;
							}
							stopServer();
						}, timeoutMs);
					});
				},
				stop: stopServer
			};
			activeServer = result;
			resolve(result);
		});
	});
}
/**
* Build the redirect URI for the hosted callback page.
* The port is encoded in the URL path so the hosted page can redirect
* to the local server without relying on query params (which some OAuth
* providers strip). The default port is omitted for a cleaner URL.
*/
function buildHostedCallbackRedirectUri(localPort) {
	if (localPort === DEFAULT_LOCALHOST_PORT) return HOSTED_CALLBACK_URL_BASE;
	return `${HOSTED_CALLBACK_URL_BASE}/${localPort}`;
}
/**
* Stop the active callback server if one is running.
* Called during plugin dispose to ensure the server is cleaned up before the process exits.
*/
function stopActiveServer() {
	if (activeServer) {
		console.log("[oauth2] Stopping active callback server during dispose");
		activeServer.stop();
		activeServer = null;
	}
}
/**
* Open an authorization URL in the system browser, start a local callback server,
* and wait for the OAuth provider to redirect back.
*
* Returns the raw callback URL and the redirect URI that was registered with the
* OAuth provider (needed for token exchange).
*/
async function getRedirectUrlViaExternalBrowser(ctx, authorizationUrl, options) {
	const { callbackType, callbackPort } = options;
	const port = callbackPort ?? DEFAULT_LOCALHOST_PORT;
	console.log(`[oauth2] Starting callback server (type: ${callbackType}, port: ${port})`);
	const server = await startCallbackServer({
		port,
		path: "/callback"
	});
	try {
		let oauthRedirectUri;
		if (callbackType === "hosted") {
			oauthRedirectUri = buildHostedCallbackRedirectUri(server.port);
			console.log("[oauth2] Using hosted callback redirect:", oauthRedirectUri);
		} else {
			oauthRedirectUri = server.redirectUri;
			console.log("[oauth2] Using localhost callback redirect:", oauthRedirectUri);
		}
		authorizationUrl.searchParams.set("redirect_uri", oauthRedirectUri);
		const authorizationUrlStr = authorizationUrl.toString();
		console.log("[oauth2] Opening external browser:", authorizationUrlStr);
		await ctx.toast.show({
			message: "Opening browser for authorization...",
			icon: "info",
			timeout: 3e3
		});
		await ctx.window.openExternalUrl(authorizationUrlStr);
		console.log("[oauth2] Waiting for callback on", server.redirectUri);
		const callbackUrl = await server.waitForCallback();
		console.log("[oauth2] Received callback:", callbackUrl);
		return {
			callbackUrl,
			redirectUri: oauthRedirectUri
		};
	} finally {
		server.stop();
	}
}
/**
* Intermediate HTML page that reads the URL fragment and _fragment query param,
* reconstructs a proper OAuth callback URL, and POSTs it back to the server.
*
* Handles three cases:
* - Localhost implicit: fragment is in location.hash (e.g. #access_token=...)
* - Hosted implicit: fragment was converted to ?_fragment=... by the hosted redirect page
* - Auth code: no fragment, code is already in query params
*/
function getFragmentForwardingHtml() {
	return `<!DOCTYPE html>
<html>
<head>
  <title>Yaak</title>
  <style>
    * { box-sizing: border-box; margin: 0; padding: 0; }
    body {
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
      display: flex;
      justify-content: center;
      align-items: center;
      min-height: 100vh;
      background: hsl(244,23%,14%);
      color: hsl(245,23%,85%);
    }
    .container { text-align: center; }
    .logo { display: block; width: 100px; height: 100px; margin: 0 auto 32px; border-radius: 50%; }
    h1 { font-size: 28px; font-weight: 600; margin-bottom: 12px; }
    p { font-size: 16px; color: hsl(245,18%,58%); }
  </style>
</head>
<body>
  <div class="container">
    <svg class="logo" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(649.94,712.03,-712.03,649.94,179.25,220.59)"><stop offset="0" stop-color="#4cc48c"/><stop offset=".5" stop-color="#476cc9"/><stop offset="1" stop-color="#ba1ab7"/></linearGradient></defs><rect x="0" y="0" width="1024" height="1024" fill="url(#g)"/><g transform="matrix(0.822,0,0,0.822,91.26,91.26)"><path d="M766.775,105.176C902.046,190.129 992.031,340.639 992.031,512C992.031,706.357 876.274,873.892 710,949.361C684.748,838.221 632.417,791.074 538.602,758.96C536.859,790.593 545.561,854.983 522.327,856.611C477.951,859.719 321.557,782.368 310.75,710.135C300.443,641.237 302.536,535.834 294.475,482.283C86.974,483.114 245.65,303.256 245.65,303.256L261.925,368.357L294.475,368.357C294.475,368.357 298.094,296.03 310.75,286.981C326.511,275.713 366.457,254.592 473.502,254.431C519.506,190.629 692.164,133.645 766.775,105.176ZM603.703,352.082C598.577,358.301 614.243,384.787 623.39,401.682C639.967,432.299 672.34,459.32 760.231,456.739C780.796,456.135 808.649,456.743 831.555,448.316C919.689,369.191 665.548,260.941 652.528,270.706C629.157,288.235 677.433,340.481 685.079,352.082C663.595,350.818 630.521,352.121 603.703,352.082ZM515.817,516.822C491.026,516.822 470.898,536.949 470.898,561.741C470.898,586.532 491.026,606.66 515.817,606.66C540.609,606.66 560.736,586.532 560.736,561.741C560.736,536.949 540.609,516.822 515.817,516.822ZM656.608,969.83C610.979,984.25 562.391,992.031 512,992.031C247.063,992.031 31.969,776.937 31.969,512C31.969,247.063 247.063,31.969 512,31.969C581.652,31.969 647.859,46.835 707.634,73.574C674.574,86.913 627.224,104.986 620,103.081C343.573,30.201 98.64,283.528 98.64,511.993C98.64,761.842 376.244,989.043 627.831,910C637.21,907.053 645.743,936.753 656.608,969.83Z" fill="#fff"/></g></svg>
    <h1 id="title">Authorizing...</h1>
    <p id="message">Please wait</p>
  </div>
  <script>
  (function() {
    var title = document.getElementById('title');
    var message = document.getElementById('message');
    var url = new URL(window.location.href);
    var fragment = window.location.hash;
    var fragmentParam = url.searchParams.get('_fragment');

    // Build the final callback URL:
    // 1. If _fragment query param exists (from hosted redirect), convert it back to a real fragment
    // 2. If location.hash exists (direct localhost implicit), use it as-is
    // 3. Otherwise (auth code flow), use the URL as-is with query params
    if (fragmentParam) {
      url.searchParams.delete('_fragment');
      url.hash = fragmentParam;
    } else if (fragment && fragment.length > 1) {
      url.hash = fragment;
    }

    // POST the final URL back to the callback server
    fetch(url.pathname, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ url: url.toString() })
    }).then(function(res) {
      if (res.ok) {
        title.textContent = 'Authorization Complete';
        message.textContent = 'You may close this tab and return to Yaak';
      } else {
        title.textContent = 'Authorization Failed';
        message.textContent = 'Something went wrong. Please try again.';
      }
    }).catch(function() {
      title.textContent = 'Authorization Failed';
      message.textContent = 'Something went wrong. Please try again.';
    });
  })();
  <\/script>
</body>
</html>`;
}

//#endregion
//#region src/fetchAccessToken.ts
async function fetchAccessToken(ctx, args) {
	const { clientId, grantType, accessTokenUrl, scope, audience, params } = args;
	console.log("[oauth2] Getting access token", accessTokenUrl);
	const httpRequest = {
		method: "POST",
		url: accessTokenUrl,
		bodyType: "application/x-www-form-urlencoded",
		body: { form: [{
			name: "grant_type",
			value: grantType
		}, ...params] },
		headers: [
			{
				name: "User-Agent",
				value: "yaak"
			},
			{
				name: "Accept",
				value: "application/x-www-form-urlencoded, application/json"
			},
			{
				name: "Content-Type",
				value: "application/x-www-form-urlencoded"
			}
		]
	};
	if (scope) httpRequest.body?.form.push({
		name: "scope",
		value: scope
	});
	if (audience) httpRequest.body?.form.push({
		name: "audience",
		value: audience
	});
	if ("clientAssertion" in args) {
		httpRequest.body?.form.push({
			name: "client_id",
			value: clientId
		});
		httpRequest.body?.form.push({
			name: "client_assertion_type",
			value: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"
		});
		httpRequest.body?.form.push({
			name: "client_assertion",
			value: args.clientAssertion
		});
	} else if (args.credentialsInBody) {
		httpRequest.body?.form.push({
			name: "client_id",
			value: clientId
		});
		httpRequest.body?.form.push({
			name: "client_secret",
			value: args.clientSecret
		});
	} else {
		const value = `Basic ${Buffer.from(`${clientId}:${args.clientSecret}`).toString("base64")}`;
		httpRequest.headers?.push({
			name: "Authorization",
			value
		});
	}
	httpRequest.authenticationType = "none";
	const resp = await ctx.httpRequest.send({ httpRequest });
	console.log("[oauth2] Got access token response", resp.status);
	if (resp.error) throw new Error(`Failed to fetch access token: ${resp.error}`);
	const body = resp.bodyPath ? (0, node_fs.readFileSync)(resp.bodyPath, "utf8") : "";
	if (resp.status < 200 || resp.status >= 300) throw new Error(`Failed to fetch access token with status=${resp.status} and body=${body}`);
	let response;
	try {
		response = JSON.parse(body);
	} catch {
		response = Object.fromEntries(new URLSearchParams(body));
	}
	if (response.error) throw new Error(`Failed to fetch access token with ${response.error}`);
	return response;
}

//#endregion
//#region ../../node_modules/safe-buffer/index.js
var require_safe_buffer = /* @__PURE__ */ __commonJS({ "../../node_modules/safe-buffer/index.js": ((exports, module) => {
	/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
	var buffer = require("buffer");
	var Buffer$8 = buffer.Buffer;
	function copyProps(src$1, dst) {
		for (var key in src$1) dst[key] = src$1[key];
	}
	if (Buffer$8.from && Buffer$8.alloc && Buffer$8.allocUnsafe && Buffer$8.allocUnsafeSlow) module.exports = buffer;
	else {
		copyProps(buffer, exports);
		exports.Buffer = SafeBuffer;
	}
	function SafeBuffer(arg, encodingOrOffset, length) {
		return Buffer$8(arg, encodingOrOffset, length);
	}
	SafeBuffer.prototype = Object.create(Buffer$8.prototype);
	copyProps(Buffer$8, SafeBuffer);
	SafeBuffer.from = function(arg, encodingOrOffset, length) {
		if (typeof arg === "number") throw new TypeError("Argument must not be a number");
		return Buffer$8(arg, encodingOrOffset, length);
	};
	SafeBuffer.alloc = function(size, fill, encoding) {
		if (typeof size !== "number") throw new TypeError("Argument must be a number");
		var buf = Buffer$8(size);
		if (fill !== void 0) if (typeof encoding === "string") buf.fill(fill, encoding);
		else buf.fill(fill);
		else buf.fill(0);
		return buf;
	};
	SafeBuffer.allocUnsafe = function(size) {
		if (typeof size !== "number") throw new TypeError("Argument must be a number");
		return Buffer$8(size);
	};
	SafeBuffer.allocUnsafeSlow = function(size) {
		if (typeof size !== "number") throw new TypeError("Argument must be a number");
		return buffer.SlowBuffer(size);
	};
}) });

//#endregion
//#region ../../node_modules/jws/lib/data-stream.js
var require_data_stream = /* @__PURE__ */ __commonJS({ "../../node_modules/jws/lib/data-stream.js": ((exports, module) => {
	var Buffer$7 = require_safe_buffer().Buffer;
	var Stream$2 = require("stream");
	var util$3 = require("util");
	function DataStream$2(data) {
		this.buffer = null;
		this.writable = true;
		this.readable = true;
		if (!data) {
			this.buffer = Buffer$7.alloc(0);
			return this;
		}
		if (typeof data.pipe === "function") {
			this.buffer = Buffer$7.alloc(0);
			data.pipe(this);
			return this;
		}
		if (data.length || typeof data === "object") {
			this.buffer = data;
			this.writable = false;
			process.nextTick(function() {
				this.emit("end", data);
				this.readable = false;
				this.emit("close");
			}.bind(this));
			return this;
		}
		throw new TypeError("Unexpected data type (" + typeof data + ")");
	}
	util$3.inherits(DataStream$2, Stream$2);
	DataStream$2.prototype.write = function write(data) {
		this.buffer = Buffer$7.concat([this.buffer, Buffer$7.from(data)]);
		this.emit("data", data);
	};
	DataStream$2.prototype.end = function end(data) {
		if (data) this.write(data);
		this.emit("end", data);
		this.emit("close");
		this.writable = false;
		this.readable = false;
	};
	module.exports = DataStream$2;
}) });

//#endregion
//#region ../../node_modules/ecdsa-sig-formatter/src/param-bytes-for-alg.js
var require_param_bytes_for_alg = /* @__PURE__ */ __commonJS({ "../../node_modules/ecdsa-sig-formatter/src/param-bytes-for-alg.js": ((exports, module) => {
	function getParamSize(keySize) {
		return (keySize / 8 | 0) + (keySize % 8 === 0 ? 0 : 1);
	}
	var paramBytesForAlg = {
		ES256: getParamSize(256),
		ES384: getParamSize(384),
		ES512: getParamSize(521)
	};
	function getParamBytesForAlg$1(alg) {
		var paramBytes = paramBytesForAlg[alg];
		if (paramBytes) return paramBytes;
		throw new Error("Unknown algorithm \"" + alg + "\"");
	}
	module.exports = getParamBytesForAlg$1;
}) });

//#endregion
//#region ../../node_modules/ecdsa-sig-formatter/src/ecdsa-sig-formatter.js
var require_ecdsa_sig_formatter = /* @__PURE__ */ __commonJS({ "../../node_modules/ecdsa-sig-formatter/src/ecdsa-sig-formatter.js": ((exports, module) => {
	var Buffer$6 = require_safe_buffer().Buffer;
	var getParamBytesForAlg = require_param_bytes_for_alg();
	var MAX_OCTET = 128, CLASS_UNIVERSAL = 0, PRIMITIVE_BIT = 32, TAG_SEQ = 16, TAG_INT = 2, ENCODED_TAG_SEQ = TAG_SEQ | PRIMITIVE_BIT | CLASS_UNIVERSAL << 6, ENCODED_TAG_INT = TAG_INT | CLASS_UNIVERSAL << 6;
	function base64Url(base64) {
		return base64.replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
	}
	function signatureAsBuffer(signature) {
		if (Buffer$6.isBuffer(signature)) return signature;
		else if ("string" === typeof signature) return Buffer$6.from(signature, "base64");
		throw new TypeError("ECDSA signature must be a Base64 string or a Buffer");
	}
	function derToJose(signature, alg) {
		signature = signatureAsBuffer(signature);
		var paramBytes = getParamBytesForAlg(alg);
		var maxEncodedParamLength = paramBytes + 1;
		var inputLength = signature.length;
		var offset = 0;
		if (signature[offset++] !== ENCODED_TAG_SEQ) throw new Error("Could not find expected \"seq\"");
		var seqLength = signature[offset++];
		if (seqLength === (MAX_OCTET | 1)) seqLength = signature[offset++];
		if (inputLength - offset < seqLength) throw new Error("\"seq\" specified length of \"" + seqLength + "\", only \"" + (inputLength - offset) + "\" remaining");
		if (signature[offset++] !== ENCODED_TAG_INT) throw new Error("Could not find expected \"int\" for \"r\"");
		var rLength = signature[offset++];
		if (inputLength - offset - 2 < rLength) throw new Error("\"r\" specified length of \"" + rLength + "\", only \"" + (inputLength - offset - 2) + "\" available");
		if (maxEncodedParamLength < rLength) throw new Error("\"r\" specified length of \"" + rLength + "\", max of \"" + maxEncodedParamLength + "\" is acceptable");
		var rOffset = offset;
		offset += rLength;
		if (signature[offset++] !== ENCODED_TAG_INT) throw new Error("Could not find expected \"int\" for \"s\"");
		var sLength = signature[offset++];
		if (inputLength - offset !== sLength) throw new Error("\"s\" specified length of \"" + sLength + "\", expected \"" + (inputLength - offset) + "\"");
		if (maxEncodedParamLength < sLength) throw new Error("\"s\" specified length of \"" + sLength + "\", max of \"" + maxEncodedParamLength + "\" is acceptable");
		var sOffset = offset;
		offset += sLength;
		if (offset !== inputLength) throw new Error("Expected to consume entire buffer, but \"" + (inputLength - offset) + "\" bytes remain");
		var rPadding = paramBytes - rLength, sPadding = paramBytes - sLength;
		var dst = Buffer$6.allocUnsafe(rPadding + rLength + sPadding + sLength);
		for (offset = 0; offset < rPadding; ++offset) dst[offset] = 0;
		signature.copy(dst, offset, rOffset + Math.max(-rPadding, 0), rOffset + rLength);
		offset = paramBytes;
		for (var o = offset; offset < o + sPadding; ++offset) dst[offset] = 0;
		signature.copy(dst, offset, sOffset + Math.max(-sPadding, 0), sOffset + sLength);
		dst = dst.toString("base64");
		dst = base64Url(dst);
		return dst;
	}
	function countPadding(buf, start, stop) {
		var padding = 0;
		while (start + padding < stop && buf[start + padding] === 0) ++padding;
		if (buf[start + padding] >= MAX_OCTET) --padding;
		return padding;
	}
	function joseToDer(signature, alg) {
		signature = signatureAsBuffer(signature);
		var paramBytes = getParamBytesForAlg(alg);
		var signatureBytes = signature.length;
		if (signatureBytes !== paramBytes * 2) throw new TypeError("\"" + alg + "\" signatures must be \"" + paramBytes * 2 + "\" bytes, saw \"" + signatureBytes + "\"");
		var rPadding = countPadding(signature, 0, paramBytes);
		var sPadding = countPadding(signature, paramBytes, signature.length);
		var rLength = paramBytes - rPadding;
		var sLength = paramBytes - sPadding;
		var rsBytes = 2 + rLength + 1 + 1 + sLength;
		var shortLength = rsBytes < MAX_OCTET;
		var dst = Buffer$6.allocUnsafe((shortLength ? 2 : 3) + rsBytes);
		var offset = 0;
		dst[offset++] = ENCODED_TAG_SEQ;
		if (shortLength) dst[offset++] = rsBytes;
		else {
			dst[offset++] = MAX_OCTET | 1;
			dst[offset++] = rsBytes & 255;
		}
		dst[offset++] = ENCODED_TAG_INT;
		dst[offset++] = rLength;
		if (rPadding < 0) {
			dst[offset++] = 0;
			offset += signature.copy(dst, offset, 0, paramBytes);
		} else offset += signature.copy(dst, offset, rPadding, paramBytes);
		dst[offset++] = ENCODED_TAG_INT;
		dst[offset++] = sLength;
		if (sPadding < 0) {
			dst[offset++] = 0;
			signature.copy(dst, offset, paramBytes);
		} else signature.copy(dst, offset, paramBytes + sPadding);
		return dst;
	}
	module.exports = {
		derToJose,
		joseToDer
	};
}) });

//#endregion
//#region ../../node_modules/buffer-equal-constant-time/index.js
var require_buffer_equal_constant_time = /* @__PURE__ */ __commonJS({ "../../node_modules/buffer-equal-constant-time/index.js": ((exports, module) => {
	var Buffer$5 = require("buffer").Buffer;
	var SlowBuffer = require("buffer").SlowBuffer;
	module.exports = bufferEq;
	function bufferEq(a, b) {
		if (!Buffer$5.isBuffer(a) || !Buffer$5.isBuffer(b)) return false;
		if (a.length !== b.length) return false;
		var c = 0;
		for (var i = 0; i < a.length; i++) c |= a[i] ^ b[i];
		return c === 0;
	}
	bufferEq.install = function() {
		Buffer$5.prototype.equal = SlowBuffer.prototype.equal = function equal(that) {
			return bufferEq(this, that);
		};
	};
	var origBufEqual = Buffer$5.prototype.equal;
	var origSlowBufEqual = SlowBuffer.prototype.equal;
	bufferEq.restore = function() {
		Buffer$5.prototype.equal = origBufEqual;
		SlowBuffer.prototype.equal = origSlowBufEqual;
	};
}) });

//#endregion
//#region ../../node_modules/jwa/index.js
var require_jwa = /* @__PURE__ */ __commonJS({ "../../node_modules/jwa/index.js": ((exports, module) => {
	var Buffer$4 = require_safe_buffer().Buffer;
	var crypto = require("crypto");
	var formatEcdsa = require_ecdsa_sig_formatter();
	var util$2 = require("util");
	var MSG_INVALID_ALGORITHM = "\"%s\" is not a valid algorithm.\n  Supported algorithms are:\n  \"HS256\", \"HS384\", \"HS512\", \"RS256\", \"RS384\", \"RS512\", \"PS256\", \"PS384\", \"PS512\", \"ES256\", \"ES384\", \"ES512\" and \"none\".";
	var MSG_INVALID_SECRET = "secret must be a string or buffer";
	var MSG_INVALID_VERIFIER_KEY = "key must be a string or a buffer";
	var MSG_INVALID_SIGNER_KEY = "key must be a string, a buffer or an object";
	var supportsKeyObjects = typeof crypto.createPublicKey === "function";
	if (supportsKeyObjects) {
		MSG_INVALID_VERIFIER_KEY += " or a KeyObject";
		MSG_INVALID_SECRET += "or a KeyObject";
	}
	function checkIsPublicKey(key) {
		if (Buffer$4.isBuffer(key)) return;
		if (typeof key === "string") return;
		if (!supportsKeyObjects) throw typeError(MSG_INVALID_VERIFIER_KEY);
		if (typeof key !== "object") throw typeError(MSG_INVALID_VERIFIER_KEY);
		if (typeof key.type !== "string") throw typeError(MSG_INVALID_VERIFIER_KEY);
		if (typeof key.asymmetricKeyType !== "string") throw typeError(MSG_INVALID_VERIFIER_KEY);
		if (typeof key.export !== "function") throw typeError(MSG_INVALID_VERIFIER_KEY);
	}
	function checkIsPrivateKey(key) {
		if (Buffer$4.isBuffer(key)) return;
		if (typeof key === "string") return;
		if (typeof key === "object") return;
		throw typeError(MSG_INVALID_SIGNER_KEY);
	}
	function checkIsSecretKey(key) {
		if (Buffer$4.isBuffer(key)) return;
		if (typeof key === "string") return key;
		if (!supportsKeyObjects) throw typeError(MSG_INVALID_SECRET);
		if (typeof key !== "object") throw typeError(MSG_INVALID_SECRET);
		if (key.type !== "secret") throw typeError(MSG_INVALID_SECRET);
		if (typeof key.export !== "function") throw typeError(MSG_INVALID_SECRET);
	}
	function fromBase64(base64) {
		return base64.replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
	}
	function toBase64(base64url$1) {
		base64url$1 = base64url$1.toString();
		var padding = 4 - base64url$1.length % 4;
		if (padding !== 4) for (var i = 0; i < padding; ++i) base64url$1 += "=";
		return base64url$1.replace(/\-/g, "+").replace(/_/g, "/");
	}
	function typeError(template) {
		var args = [].slice.call(arguments, 1);
		var errMsg = util$2.format.bind(util$2, template).apply(null, args);
		return new TypeError(errMsg);
	}
	function bufferOrString(obj) {
		return Buffer$4.isBuffer(obj) || typeof obj === "string";
	}
	function normalizeInput(thing) {
		if (!bufferOrString(thing)) thing = JSON.stringify(thing);
		return thing;
	}
	function createHmacSigner(bits) {
		return function sign(thing, secret) {
			checkIsSecretKey(secret);
			thing = normalizeInput(thing);
			var hmac = crypto.createHmac("sha" + bits, secret);
			return fromBase64((hmac.update(thing), hmac.digest("base64")));
		};
	}
	var bufferEqual;
	var timingSafeEqual = "timingSafeEqual" in crypto ? function timingSafeEqual$1(a, b) {
		if (a.byteLength !== b.byteLength) return false;
		return crypto.timingSafeEqual(a, b);
	} : function timingSafeEqual$1(a, b) {
		if (!bufferEqual) bufferEqual = require_buffer_equal_constant_time();
		return bufferEqual(a, b);
	};
	function createHmacVerifier(bits) {
		return function verify(thing, signature, secret) {
			var computedSig = createHmacSigner(bits)(thing, secret);
			return timingSafeEqual(Buffer$4.from(signature), Buffer$4.from(computedSig));
		};
	}
	function createKeySigner(bits) {
		return function sign(thing, privateKey) {
			checkIsPrivateKey(privateKey);
			thing = normalizeInput(thing);
			var signer = crypto.createSign("RSA-SHA" + bits);
			return fromBase64((signer.update(thing), signer.sign(privateKey, "base64")));
		};
	}
	function createKeyVerifier(bits) {
		return function verify(thing, signature, publicKey) {
			checkIsPublicKey(publicKey);
			thing = normalizeInput(thing);
			signature = toBase64(signature);
			var verifier = crypto.createVerify("RSA-SHA" + bits);
			verifier.update(thing);
			return verifier.verify(publicKey, signature, "base64");
		};
	}
	function createPSSKeySigner(bits) {
		return function sign(thing, privateKey) {
			checkIsPrivateKey(privateKey);
			thing = normalizeInput(thing);
			var signer = crypto.createSign("RSA-SHA" + bits);
			return fromBase64((signer.update(thing), signer.sign({
				key: privateKey,
				padding: crypto.constants.RSA_PKCS1_PSS_PADDING,
				saltLength: crypto.constants.RSA_PSS_SALTLEN_DIGEST
			}, "base64")));
		};
	}
	function createPSSKeyVerifier(bits) {
		return function verify(thing, signature, publicKey) {
			checkIsPublicKey(publicKey);
			thing = normalizeInput(thing);
			signature = toBase64(signature);
			var verifier = crypto.createVerify("RSA-SHA" + bits);
			verifier.update(thing);
			return verifier.verify({
				key: publicKey,
				padding: crypto.constants.RSA_PKCS1_PSS_PADDING,
				saltLength: crypto.constants.RSA_PSS_SALTLEN_DIGEST
			}, signature, "base64");
		};
	}
	function createECDSASigner(bits) {
		var inner = createKeySigner(bits);
		return function sign() {
			var signature = inner.apply(null, arguments);
			signature = formatEcdsa.derToJose(signature, "ES" + bits);
			return signature;
		};
	}
	function createECDSAVerifer(bits) {
		var inner = createKeyVerifier(bits);
		return function verify(thing, signature, publicKey) {
			signature = formatEcdsa.joseToDer(signature, "ES" + bits).toString("base64");
			return inner(thing, signature, publicKey);
		};
	}
	function createNoneSigner() {
		return function sign() {
			return "";
		};
	}
	function createNoneVerifier() {
		return function verify(thing, signature) {
			return signature === "";
		};
	}
	module.exports = function jwa$2(algorithm) {
		var signerFactories = {
			hs: createHmacSigner,
			rs: createKeySigner,
			ps: createPSSKeySigner,
			es: createECDSASigner,
			none: createNoneSigner
		};
		var verifierFactories = {
			hs: createHmacVerifier,
			rs: createKeyVerifier,
			ps: createPSSKeyVerifier,
			es: createECDSAVerifer,
			none: createNoneVerifier
		};
		var match = algorithm.match(/^(RS|PS|ES|HS)(256|384|512)$|^(none)$/);
		if (!match) throw typeError(MSG_INVALID_ALGORITHM, algorithm);
		var algo = (match[1] || match[3]).toLowerCase();
		var bits = match[2];
		return {
			sign: signerFactories[algo](bits),
			verify: verifierFactories[algo](bits)
		};
	};
}) });

//#endregion
//#region ../../node_modules/jws/lib/tostring.js
var require_tostring = /* @__PURE__ */ __commonJS({ "../../node_modules/jws/lib/tostring.js": ((exports, module) => {
	var Buffer$3 = require("buffer").Buffer;
	module.exports = function toString$2(obj) {
		if (typeof obj === "string") return obj;
		if (typeof obj === "number" || Buffer$3.isBuffer(obj)) return obj.toString();
		return JSON.stringify(obj);
	};
}) });

//#endregion
//#region ../../node_modules/jws/lib/sign-stream.js
var require_sign_stream = /* @__PURE__ */ __commonJS({ "../../node_modules/jws/lib/sign-stream.js": ((exports, module) => {
	var Buffer$2 = require_safe_buffer().Buffer;
	var DataStream$1 = require_data_stream();
	var jwa$1 = require_jwa();
	var Stream$1 = require("stream");
	var toString$1 = require_tostring();
	var util$1 = require("util");
	function base64url(string, encoding) {
		return Buffer$2.from(string, encoding).toString("base64").replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
	}
	function jwsSecuredInput(header, payload, encoding) {
		encoding = encoding || "utf8";
		var encodedHeader = base64url(toString$1(header), "binary");
		var encodedPayload = base64url(toString$1(payload), encoding);
		return util$1.format("%s.%s", encodedHeader, encodedPayload);
	}
	function jwsSign(opts) {
		var header = opts.header;
		var payload = opts.payload;
		var secretOrKey = opts.secret || opts.privateKey;
		var encoding = opts.encoding;
		var algo = jwa$1(header.alg);
		var securedInput = jwsSecuredInput(header, payload, encoding);
		var signature = algo.sign(securedInput, secretOrKey);
		return util$1.format("%s.%s", securedInput, signature);
	}
	function SignStream$1(opts) {
		var secret = opts.secret;
		secret = secret == null ? opts.privateKey : secret;
		secret = secret == null ? opts.key : secret;
		if (/^hs/i.test(opts.header.alg) === true && secret == null) throw new TypeError("secret must be a string or buffer or a KeyObject");
		var secretStream = new DataStream$1(secret);
		this.readable = true;
		this.header = opts.header;
		this.encoding = opts.encoding;
		this.secret = this.privateKey = this.key = secretStream;
		this.payload = new DataStream$1(opts.payload);
		this.secret.once("close", function() {
			if (!this.payload.writable && this.readable) this.sign();
		}.bind(this));
		this.payload.once("close", function() {
			if (!this.secret.writable && this.readable) this.sign();
		}.bind(this));
	}
	util$1.inherits(SignStream$1, Stream$1);
	SignStream$1.prototype.sign = function sign() {
		try {
			var signature = jwsSign({
				header: this.header,
				payload: this.payload.buffer,
				secret: this.secret.buffer,
				encoding: this.encoding
			});
			this.emit("done", signature);
			this.emit("data", signature);
			this.emit("end");
			this.readable = false;
			return signature;
		} catch (e) {
			this.readable = false;
			this.emit("error", e);
			this.emit("close");
		}
	};
	SignStream$1.sign = jwsSign;
	module.exports = SignStream$1;
}) });

//#endregion
//#region ../../node_modules/jws/lib/verify-stream.js
var require_verify_stream = /* @__PURE__ */ __commonJS({ "../../node_modules/jws/lib/verify-stream.js": ((exports, module) => {
	var Buffer$1 = require_safe_buffer().Buffer;
	var DataStream = require_data_stream();
	var jwa = require_jwa();
	var Stream = require("stream");
	var toString = require_tostring();
	var util = require("util");
	var JWS_REGEX = /^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;
	function isObject$3(thing) {
		return Object.prototype.toString.call(thing) === "[object Object]";
	}
	function safeJsonParse(thing) {
		if (isObject$3(thing)) return thing;
		try {
			return JSON.parse(thing);
		} catch (e) {
			return;
		}
	}
	function headerFromJWS(jwsSig) {
		var encodedHeader = jwsSig.split(".", 1)[0];
		return safeJsonParse(Buffer$1.from(encodedHeader, "base64").toString("binary"));
	}
	function securedInputFromJWS(jwsSig) {
		return jwsSig.split(".", 2).join(".");
	}
	function signatureFromJWS(jwsSig) {
		return jwsSig.split(".")[2];
	}
	function payloadFromJWS(jwsSig, encoding) {
		encoding = encoding || "utf8";
		var payload = jwsSig.split(".")[1];
		return Buffer$1.from(payload, "base64").toString(encoding);
	}
	function isValidJws(string) {
		return JWS_REGEX.test(string) && !!headerFromJWS(string);
	}
	function jwsVerify(jwsSig, algorithm, secretOrKey) {
		if (!algorithm) {
			var err = /* @__PURE__ */ new Error("Missing algorithm parameter for jws.verify");
			err.code = "MISSING_ALGORITHM";
			throw err;
		}
		jwsSig = toString(jwsSig);
		var signature = signatureFromJWS(jwsSig);
		var securedInput = securedInputFromJWS(jwsSig);
		return jwa(algorithm).verify(securedInput, signature, secretOrKey);
	}
	function jwsDecode(jwsSig, opts) {
		opts = opts || {};
		jwsSig = toString(jwsSig);
		if (!isValidJws(jwsSig)) return null;
		var header = headerFromJWS(jwsSig);
		if (!header) return null;
		var payload = payloadFromJWS(jwsSig);
		if (header.typ === "JWT" || opts.json) payload = JSON.parse(payload, opts.encoding);
		return {
			header,
			payload,
			signature: signatureFromJWS(jwsSig)
		};
	}
	function VerifyStream$1(opts) {
		opts = opts || {};
		var secretOrKey = opts.secret;
		secretOrKey = secretOrKey == null ? opts.publicKey : secretOrKey;
		secretOrKey = secretOrKey == null ? opts.key : secretOrKey;
		if (/^hs/i.test(opts.algorithm) === true && secretOrKey == null) throw new TypeError("secret must be a string or buffer or a KeyObject");
		var secretStream = new DataStream(secretOrKey);
		this.readable = true;
		this.algorithm = opts.algorithm;
		this.encoding = opts.encoding;
		this.secret = this.publicKey = this.key = secretStream;
		this.signature = new DataStream(opts.signature);
		this.secret.once("close", function() {
			if (!this.signature.writable && this.readable) this.verify();
		}.bind(this));
		this.signature.once("close", function() {
			if (!this.secret.writable && this.readable) this.verify();
		}.bind(this));
	}
	util.inherits(VerifyStream$1, Stream);
	VerifyStream$1.prototype.verify = function verify() {
		try {
			var valid$2 = jwsVerify(this.signature.buffer, this.algorithm, this.key.buffer);
			var obj = jwsDecode(this.signature.buffer, this.encoding);
			this.emit("done", valid$2, obj);
			this.emit("data", valid$2);
			this.emit("end");
			this.readable = false;
			return valid$2;
		} catch (e) {
			this.readable = false;
			this.emit("error", e);
			this.emit("close");
		}
	};
	VerifyStream$1.decode = jwsDecode;
	VerifyStream$1.isValid = isValidJws;
	VerifyStream$1.verify = jwsVerify;
	module.exports = VerifyStream$1;
}) });

//#endregion
//#region ../../node_modules/jws/index.js
var require_jws = /* @__PURE__ */ __commonJS({ "../../node_modules/jws/index.js": ((exports) => {
	var SignStream = require_sign_stream();
	var VerifyStream = require_verify_stream();
	var ALGORITHMS = [
		"HS256",
		"HS384",
		"HS512",
		"RS256",
		"RS384",
		"RS512",
		"PS256",
		"PS384",
		"PS512",
		"ES256",
		"ES384",
		"ES512"
	];
	exports.ALGORITHMS = ALGORITHMS;
	exports.sign = SignStream.sign;
	exports.verify = VerifyStream.verify;
	exports.decode = VerifyStream.decode;
	exports.isValid = VerifyStream.isValid;
	exports.createSign = function createSign(opts) {
		return new SignStream(opts);
	};
	exports.createVerify = function createVerify(opts) {
		return new VerifyStream(opts);
	};
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/decode.js
var require_decode = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/decode.js": ((exports, module) => {
	var jws$2 = require_jws();
	module.exports = function(jwt$2, options) {
		options = options || {};
		var decoded = jws$2.decode(jwt$2, options);
		if (!decoded) return null;
		var payload = decoded.payload;
		if (typeof payload === "string") try {
			var obj = JSON.parse(payload);
			if (obj !== null && typeof obj === "object") payload = obj;
		} catch (e) {}
		if (options.complete === true) return {
			header: decoded.header,
			payload,
			signature: decoded.signature
		};
		return payload;
	};
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/lib/JsonWebTokenError.js
var require_JsonWebTokenError = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/lib/JsonWebTokenError.js": ((exports, module) => {
	var JsonWebTokenError$3 = function(message, error) {
		Error.call(this, message);
		if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
		this.name = "JsonWebTokenError";
		this.message = message;
		if (error) this.inner = error;
	};
	JsonWebTokenError$3.prototype = Object.create(Error.prototype);
	JsonWebTokenError$3.prototype.constructor = JsonWebTokenError$3;
	module.exports = JsonWebTokenError$3;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/lib/NotBeforeError.js
var require_NotBeforeError = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/lib/NotBeforeError.js": ((exports, module) => {
	var JsonWebTokenError$2 = require_JsonWebTokenError();
	var NotBeforeError$1 = function(message, date) {
		JsonWebTokenError$2.call(this, message);
		this.name = "NotBeforeError";
		this.date = date;
	};
	NotBeforeError$1.prototype = Object.create(JsonWebTokenError$2.prototype);
	NotBeforeError$1.prototype.constructor = NotBeforeError$1;
	module.exports = NotBeforeError$1;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/lib/TokenExpiredError.js
var require_TokenExpiredError = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/lib/TokenExpiredError.js": ((exports, module) => {
	var JsonWebTokenError$1 = require_JsonWebTokenError();
	var TokenExpiredError$1 = function(message, expiredAt) {
		JsonWebTokenError$1.call(this, message);
		this.name = "TokenExpiredError";
		this.expiredAt = expiredAt;
	};
	TokenExpiredError$1.prototype = Object.create(JsonWebTokenError$1.prototype);
	TokenExpiredError$1.prototype.constructor = TokenExpiredError$1;
	module.exports = TokenExpiredError$1;
}) });

//#endregion
//#region ../../node_modules/ms/index.js
var require_ms = /* @__PURE__ */ __commonJS({ "../../node_modules/ms/index.js": ((exports, module) => {
	/**
	* Helpers.
	*/
	var s = 1e3;
	var m = s * 60;
	var h = m * 60;
	var d = h * 24;
	var w = d * 7;
	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$7(val);
		else if (type === "number" && isFinite(val)) 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$7(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|weeks?|w|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 "weeks":
			case "week":
			case "w": return n * w;
			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$1) {
		var msAbs = Math.abs(ms$1);
		if (msAbs >= d) return Math.round(ms$1 / d) + "d";
		if (msAbs >= h) return Math.round(ms$1 / h) + "h";
		if (msAbs >= m) return Math.round(ms$1 / m) + "m";
		if (msAbs >= s) return Math.round(ms$1 / s) + "s";
		return ms$1 + "ms";
	}
	/**
	* Long format for `ms`.
	*
	* @param {Number} ms
	* @return {String}
	* @api private
	*/
	function fmtLong(ms$1) {
		var msAbs = Math.abs(ms$1);
		if (msAbs >= d) return plural(ms$1, msAbs, d, "day");
		if (msAbs >= h) return plural(ms$1, msAbs, h, "hour");
		if (msAbs >= m) return plural(ms$1, msAbs, m, "minute");
		if (msAbs >= s) return plural(ms$1, msAbs, s, "second");
		return ms$1 + " ms";
	}
	/**
	* Pluralization helper.
	*/
	function plural(ms$1, msAbs, n, name) {
		var isPlural = msAbs >= n * 1.5;
		return Math.round(ms$1 / n) + " " + name + (isPlural ? "s" : "");
	}
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/lib/timespan.js
var require_timespan = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/lib/timespan.js": ((exports, module) => {
	var ms = require_ms();
	module.exports = function(time, iat) {
		var timestamp = iat || Math.floor(Date.now() / 1e3);
		if (typeof time === "string") {
			var milliseconds = ms(time);
			if (typeof milliseconds === "undefined") return;
			return Math.floor(timestamp + milliseconds / 1e3);
		} else if (typeof time === "number") return timestamp + time;
		else return;
	};
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/internal/constants.js
var require_constants = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/internal/constants.js": ((exports, module) => {
	const SEMVER_SPEC_VERSION = "2.0.0";
	const MAX_LENGTH$2 = 256;
	const MAX_SAFE_INTEGER$2 = Number.MAX_SAFE_INTEGER || 9007199254740991;
	const MAX_SAFE_COMPONENT_LENGTH$1 = 16;
	const MAX_SAFE_BUILD_LENGTH$1 = MAX_LENGTH$2 - 6;
	const RELEASE_TYPES = [
		"major",
		"premajor",
		"minor",
		"preminor",
		"patch",
		"prepatch",
		"prerelease"
	];
	module.exports = {
		MAX_LENGTH: MAX_LENGTH$2,
		MAX_SAFE_COMPONENT_LENGTH: MAX_SAFE_COMPONENT_LENGTH$1,
		MAX_SAFE_BUILD_LENGTH: MAX_SAFE_BUILD_LENGTH$1,
		MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$2,
		RELEASE_TYPES,
		SEMVER_SPEC_VERSION,
		FLAG_INCLUDE_PRERELEASE: 1,
		FLAG_LOOSE: 2
	};
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/internal/debug.js
var require_debug = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/internal/debug.js": ((exports, module) => {
	const debug$4 = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {};
	module.exports = debug$4;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/internal/re.js
var require_re = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/internal/re.js": ((exports, module) => {
	const { MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_BUILD_LENGTH, MAX_LENGTH: MAX_LENGTH$1 } = require_constants();
	const debug$3 = require_debug();
	exports = module.exports = {};
	const re$4 = exports.re = [];
	const safeRe = exports.safeRe = [];
	const src = exports.src = [];
	const safeSrc = exports.safeSrc = [];
	const t$4 = exports.t = {};
	let R = 0;
	const LETTERDASHNUMBER = "[a-zA-Z0-9-]";
	const safeRegexReplacements = [
		["\\s", 1],
		["\\d", MAX_LENGTH$1],
		[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
	];
	const makeSafeRegex = (value) => {
		for (const [token, max] of safeRegexReplacements) value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
		return value;
	};
	const createToken = (name, value, isGlobal) => {
		const safe = makeSafeRegex(value);
		const index = R++;
		debug$3(name, index, value);
		t$4[name] = index;
		src[index] = value;
		safeSrc[index] = safe;
		re$4[index] = new RegExp(value, isGlobal ? "g" : void 0);
		safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
	};
	createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
	createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
	createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
	createToken("MAINVERSION", `(${src[t$4.NUMERICIDENTIFIER]})\\.(${src[t$4.NUMERICIDENTIFIER]})\\.(${src[t$4.NUMERICIDENTIFIER]})`);
	createToken("MAINVERSIONLOOSE", `(${src[t$4.NUMERICIDENTIFIERLOOSE]})\\.(${src[t$4.NUMERICIDENTIFIERLOOSE]})\\.(${src[t$4.NUMERICIDENTIFIERLOOSE]})`);
	createToken("PRERELEASEIDENTIFIER", `(?:${src[t$4.NONNUMERICIDENTIFIER]}|${src[t$4.NUMERICIDENTIFIER]})`);
	createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t$4.NONNUMERICIDENTIFIER]}|${src[t$4.NUMERICIDENTIFIERLOOSE]})`);
	createToken("PRERELEASE", `(?:-(${src[t$4.PRERELEASEIDENTIFIER]}(?:\\.${src[t$4.PRERELEASEIDENTIFIER]})*))`);
	createToken("PRERELEASELOOSE", `(?:-?(${src[t$4.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t$4.PRERELEASEIDENTIFIERLOOSE]})*))`);
	createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
	createToken("BUILD", `(?:\\+(${src[t$4.BUILDIDENTIFIER]}(?:\\.${src[t$4.BUILDIDENTIFIER]})*))`);
	createToken("FULLPLAIN", `v?${src[t$4.MAINVERSION]}${src[t$4.PRERELEASE]}?${src[t$4.BUILD]}?`);
	createToken("FULL", `^${src[t$4.FULLPLAIN]}$`);
	createToken("LOOSEPLAIN", `[v=\\s]*${src[t$4.MAINVERSIONLOOSE]}${src[t$4.PRERELEASELOOSE]}?${src[t$4.BUILD]}?`);
	createToken("LOOSE", `^${src[t$4.LOOSEPLAIN]}$`);
	createToken("GTLT", "((?:<|>)?=?)");
	createToken("XRANGEIDENTIFIERLOOSE", `${src[t$4.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
	createToken("XRANGEIDENTIFIER", `${src[t$4.NUMERICIDENTIFIER]}|x|X|\\*`);
	createToken("XRANGEPLAIN", `[v=\\s]*(${src[t$4.XRANGEIDENTIFIER]})(?:\\.(${src[t$4.XRANGEIDENTIFIER]})(?:\\.(${src[t$4.XRANGEIDENTIFIER]})(?:${src[t$4.PRERELEASE]})?${src[t$4.BUILD]}?)?)?`);
	createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t$4.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t$4.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t$4.XRANGEIDENTIFIERLOOSE]})(?:${src[t$4.PRERELEASELOOSE]})?${src[t$4.BUILD]}?)?)?`);
	createToken("XRANGE", `^${src[t$4.GTLT]}\\s*${src[t$4.XRANGEPLAIN]}$`);
	createToken("XRANGELOOSE", `^${src[t$4.GTLT]}\\s*${src[t$4.XRANGEPLAINLOOSE]}$`);
	createToken("COERCEPLAIN", `(^|[^\\d])(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
	createToken("COERCE", `${src[t$4.COERCEPLAIN]}(?:$|[^\\d])`);
	createToken("COERCEFULL", src[t$4.COERCEPLAIN] + `(?:${src[t$4.PRERELEASE]})?(?:${src[t$4.BUILD]})?(?:$|[^\\d])`);
	createToken("COERCERTL", src[t$4.COERCE], true);
	createToken("COERCERTLFULL", src[t$4.COERCEFULL], true);
	createToken("LONETILDE", "(?:~>?)");
	createToken("TILDETRIM", `(\\s*)${src[t$4.LONETILDE]}\\s+`, true);
	exports.tildeTrimReplace = "$1~";
	createToken("TILDE", `^${src[t$4.LONETILDE]}${src[t$4.XRANGEPLAIN]}$`);
	createToken("TILDELOOSE", `^${src[t$4.LONETILDE]}${src[t$4.XRANGEPLAINLOOSE]}$`);
	createToken("LONECARET", "(?:\\^)");
	createToken("CARETTRIM", `(\\s*)${src[t$4.LONECARET]}\\s+`, true);
	exports.caretTrimReplace = "$1^";
	createToken("CARET", `^${src[t$4.LONECARET]}${src[t$4.XRANGEPLAIN]}$`);
	createToken("CARETLOOSE", `^${src[t$4.LONECARET]}${src[t$4.XRANGEPLAINLOOSE]}$`);
	createToken("COMPARATORLOOSE", `^${src[t$4.GTLT]}\\s*(${src[t$4.LOOSEPLAIN]})$|^$`);
	createToken("COMPARATOR", `^${src[t$4.GTLT]}\\s*(${src[t$4.FULLPLAIN]})$|^$`);
	createToken("COMPARATORTRIM", `(\\s*)${src[t$4.GTLT]}\\s*(${src[t$4.LOOSEPLAIN]}|${src[t$4.XRANGEPLAIN]})`, true);
	exports.comparatorTrimReplace = "$1$2$3";
	createToken("HYPHENRANGE", `^\\s*(${src[t$4.XRANGEPLAIN]})\\s+-\\s+(${src[t$4.XRANGEPLAIN]})\\s*$`);
	createToken("HYPHENRANGELOOSE", `^\\s*(${src[t$4.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t$4.XRANGEPLAINLOOSE]})\\s*$`);
	createToken("STAR", "(<|>)?=?\\s*\\*");
	createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
	createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/internal/parse-options.js
var require_parse_options = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/internal/parse-options.js": ((exports, module) => {
	const looseOption = Object.freeze({ loose: true });
	const emptyOpts = Object.freeze({});
	const parseOptions$3 = (options) => {
		if (!options) return emptyOpts;
		if (typeof options !== "object") return looseOption;
		return options;
	};
	module.exports = parseOptions$3;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/internal/identifiers.js
var require_identifiers = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/internal/identifiers.js": ((exports, module) => {
	const numeric = /^[0-9]+$/;
	const compareIdentifiers$1 = (a, b) => {
		if (typeof a === "number" && typeof b === "number") return a === b ? 0 : a < b ? -1 : 1;
		const anum = numeric.test(a);
		const bnum = numeric.test(b);
		if (anum && bnum) {
			a = +a;
			b = +b;
		}
		return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
	};
	const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a);
	module.exports = {
		compareIdentifiers: compareIdentifiers$1,
		rcompareIdentifiers
	};
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/classes/semver.js
var require_semver$1 = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/classes/semver.js": ((exports, module) => {
	const debug$2 = require_debug();
	const { MAX_LENGTH, MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1 } = require_constants();
	const { safeRe: re$3, t: t$3 } = require_re();
	const parseOptions$2 = require_parse_options();
	const { compareIdentifiers } = require_identifiers();
	var SemVer$15 = class SemVer$15 {
		constructor(version, options) {
			options = parseOptions$2(options);
			if (version instanceof SemVer$15) if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) return version;
			else version = version.version;
			else if (typeof version !== "string") throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
			if (version.length > MAX_LENGTH) throw new TypeError(`version is longer than ${MAX_LENGTH} characters`);
			debug$2("SemVer", version, options);
			this.options = options;
			this.loose = !!options.loose;
			this.includePrerelease = !!options.includePrerelease;
			const m$1 = version.trim().match(options.loose ? re$3[t$3.LOOSE] : re$3[t$3.FULL]);
			if (!m$1) throw new TypeError(`Invalid Version: ${version}`);
			this.raw = version;
			this.major = +m$1[1];
			this.minor = +m$1[2];
			this.patch = +m$1[3];
			if (this.major > MAX_SAFE_INTEGER$1 || this.major < 0) throw new TypeError("Invalid major version");
			if (this.minor > MAX_SAFE_INTEGER$1 || this.minor < 0) throw new TypeError("Invalid minor version");
			if (this.patch > MAX_SAFE_INTEGER$1 || this.patch < 0) throw new TypeError("Invalid patch version");
			if (!m$1[4]) this.prerelease = [];
			else this.prerelease = m$1[4].split(".").map((id) => {
				if (/^[0-9]+$/.test(id)) {
					const num = +id;
					if (num >= 0 && num < MAX_SAFE_INTEGER$1) return num;
				}
				return id;
			});
			this.build = m$1[5] ? m$1[5].split(".") : [];
			this.format();
		}
		format() {
			this.version = `${this.major}.${this.minor}.${this.patch}`;
			if (this.prerelease.length) this.version += `-${this.prerelease.join(".")}`;
			return this.version;
		}
		toString() {
			return this.version;
		}
		compare(other) {
			debug$2("SemVer.compare", this.version, this.options, other);
			if (!(other instanceof SemVer$15)) {
				if (typeof other === "string" && other === this.version) return 0;
				other = new SemVer$15(other, this.options);
			}
			if (other.version === this.version) return 0;
			return this.compareMain(other) || this.comparePre(other);
		}
		compareMain(other) {
			if (!(other instanceof SemVer$15)) other = new SemVer$15(other, this.options);
			if (this.major < other.major) return -1;
			if (this.major > other.major) return 1;
			if (this.minor < other.minor) return -1;
			if (this.minor > other.minor) return 1;
			if (this.patch < other.patch) return -1;
			if (this.patch > other.patch) return 1;
			return 0;
		}
		comparePre(other) {
			if (!(other instanceof SemVer$15)) other = new SemVer$15(other, this.options);
			if (this.prerelease.length && !other.prerelease.length) return -1;
			else if (!this.prerelease.length && other.prerelease.length) return 1;
			else if (!this.prerelease.length && !other.prerelease.length) return 0;
			let i = 0;
			do {
				const a = this.prerelease[i];
				const b = other.prerelease[i];
				debug$2("prerelease compare", i, a, b);
				if (a === void 0 && b === void 0) return 0;
				else if (b === void 0) return 1;
				else if (a === void 0) return -1;
				else if (a === b) continue;
				else return compareIdentifiers(a, b);
			} while (++i);
		}
		compareBuild(other) {
			if (!(other instanceof SemVer$15)) other = new SemVer$15(other, this.options);
			let i = 0;
			do {
				const a = this.build[i];
				const b = other.build[i];
				debug$2("build compare", i, a, b);
				if (a === void 0 && b === void 0) return 0;
				else if (b === void 0) return 1;
				else if (a === void 0) return -1;
				else if (a === b) continue;
				else return compareIdentifiers(a, b);
			} while (++i);
		}
		inc(release, identifier, identifierBase) {
			if (release.startsWith("pre")) {
				if (!identifier && identifierBase === false) throw new Error("invalid increment argument: identifier is empty");
				if (identifier) {
					const match = `-${identifier}`.match(this.options.loose ? re$3[t$3.PRERELEASELOOSE] : re$3[t$3.PRERELEASE]);
					if (!match || match[1] !== identifier) throw new Error(`invalid identifier: ${identifier}`);
				}
			}
			switch (release) {
				case "premajor":
					this.prerelease.length = 0;
					this.patch = 0;
					this.minor = 0;
					this.major++;
					this.inc("pre", identifier, identifierBase);
					break;
				case "preminor":
					this.prerelease.length = 0;
					this.patch = 0;
					this.minor++;
					this.inc("pre", identifier, identifierBase);
					break;
				case "prepatch":
					this.prerelease.length = 0;
					this.inc("patch", identifier, identifierBase);
					this.inc("pre", identifier, identifierBase);
					break;
				case "prerelease":
					if (this.prerelease.length === 0) this.inc("patch", identifier, identifierBase);
					this.inc("pre", identifier, identifierBase);
					break;
				case "release":
					if (this.prerelease.length === 0) throw new Error(`version ${this.raw} is not a prerelease`);
					this.prerelease.length = 0;
					break;
				case "major":
					if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) this.major++;
					this.minor = 0;
					this.patch = 0;
					this.prerelease = [];
					break;
				case "minor":
					if (this.patch !== 0 || this.prerelease.length === 0) this.minor++;
					this.patch = 0;
					this.prerelease = [];
					break;
				case "patch":
					if (this.prerelease.length === 0) this.patch++;
					this.prerelease = [];
					break;
				case "pre": {
					const base = Number(identifierBase) ? 1 : 0;
					if (this.prerelease.length === 0) this.prerelease = [base];
					else {
						let i = this.prerelease.length;
						while (--i >= 0) if (typeof this.prerelease[i] === "number") {
							this.prerelease[i]++;
							i = -2;
						}
						if (i === -1) {
							if (identifier === this.prerelease.join(".") && identifierBase === false) throw new Error("invalid increment argument: identifier already exists");
							this.prerelease.push(base);
						}
					}
					if (identifier) {
						let prerelease$2 = [identifier, base];
						if (identifierBase === false) prerelease$2 = [identifier];
						if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
							if (isNaN(this.prerelease[1])) this.prerelease = prerelease$2;
						} else this.prerelease = prerelease$2;
					}
					break;
				}
				default: throw new Error(`invalid increment argument: ${release}`);
			}
			this.raw = this.format();
			if (this.build.length) this.raw += `+${this.build.join(".")}`;
			return this;
		}
	};
	module.exports = SemVer$15;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/functions/parse.js
var require_parse = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/functions/parse.js": ((exports, module) => {
	const SemVer$14 = require_semver$1();
	const parse$6 = (version, options, throwErrors = false) => {
		if (version instanceof SemVer$14) return version;
		try {
			return new SemVer$14(version, options);
		} catch (er) {
			if (!throwErrors) return null;
			throw er;
		}
	};
	module.exports = parse$6;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/functions/valid.js
var require_valid$1 = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/functions/valid.js": ((exports, module) => {
	const parse$5 = require_parse();
	const valid$1 = (version, options) => {
		const v = parse$5(version, options);
		return v ? v.version : null;
	};
	module.exports = valid$1;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/functions/clean.js
var require_clean = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/functions/clean.js": ((exports, module) => {
	const parse$4 = require_parse();
	const clean$1 = (version, options) => {
		const s$1 = parse$4(version.trim().replace(/^[=v]+/, ""), options);
		return s$1 ? s$1.version : null;
	};
	module.exports = clean$1;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/functions/inc.js
var require_inc = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/functions/inc.js": ((exports, module) => {
	const SemVer$13 = require_semver$1();
	const inc$1 = (version, release, options, identifier, identifierBase) => {
		if (typeof options === "string") {
			identifierBase = identifier;
			identifier = options;
			options = void 0;
		}
		try {
			return new SemVer$13(version instanceof SemVer$13 ? version.version : version, options).inc(release, identifier, identifierBase).version;
		} catch (er) {
			return null;
		}
	};
	module.exports = inc$1;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/functions/diff.js
var require_diff = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/functions/diff.js": ((exports, module) => {
	const parse$3 = require_parse();
	const diff$1 = (version1, version2) => {
		const v1 = parse$3(version1, null, true);
		const v2 = parse$3(version2, null, true);
		const comparison = v1.compare(v2);
		if (comparison === 0) return null;
		const v1Higher = comparison > 0;
		const highVersion = v1Higher ? v1 : v2;
		const lowVersion = v1Higher ? v2 : v1;
		const highHasPre = !!highVersion.prerelease.length;
		if (!!lowVersion.prerelease.length && !highHasPre) {
			if (!lowVersion.patch && !lowVersion.minor) return "major";
			if (lowVersion.compareMain(highVersion) === 0) {
				if (lowVersion.minor && !lowVersion.patch) return "minor";
				return "patch";
			}
		}
		const prefix = highHasPre ? "pre" : "";
		if (v1.major !== v2.major) return prefix + "major";
		if (v1.minor !== v2.minor) return prefix + "minor";
		if (v1.patch !== v2.patch) return prefix + "patch";
		return "prerelease";
	};
	module.exports = diff$1;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/functions/major.js
var require_major = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/functions/major.js": ((exports, module) => {
	const SemVer$12 = require_semver$1();
	const major$1 = (a, loose) => new SemVer$12(a, loose).major;
	module.exports = major$1;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/functions/minor.js
var require_minor = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/functions/minor.js": ((exports, module) => {
	const SemVer$11 = require_semver$1();
	const minor$1 = (a, loose) => new SemVer$11(a, loose).minor;
	module.exports = minor$1;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/functions/patch.js
var require_patch = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/functions/patch.js": ((exports, module) => {
	const SemVer$10 = require_semver$1();
	const patch$1 = (a, loose) => new SemVer$10(a, loose).patch;
	module.exports = patch$1;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/functions/prerelease.js
var require_prerelease = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/functions/prerelease.js": ((exports, module) => {
	const parse$2 = require_parse();
	const prerelease$1 = (version, options) => {
		const parsed = parse$2(version, options);
		return parsed && parsed.prerelease.length ? parsed.prerelease : null;
	};
	module.exports = prerelease$1;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/functions/compare.js
var require_compare = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/functions/compare.js": ((exports, module) => {
	const SemVer$9 = require_semver$1();
	const compare$11 = (a, b, loose) => new SemVer$9(a, loose).compare(new SemVer$9(b, loose));
	module.exports = compare$11;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/functions/rcompare.js
var require_rcompare = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/functions/rcompare.js": ((exports, module) => {
	const compare$10 = require_compare();
	const rcompare$1 = (a, b, loose) => compare$10(b, a, loose);
	module.exports = rcompare$1;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/functions/compare-loose.js
var require_compare_loose = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/functions/compare-loose.js": ((exports, module) => {
	const compare$9 = require_compare();
	const compareLoose$1 = (a, b) => compare$9(a, b, true);
	module.exports = compareLoose$1;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/functions/compare-build.js
var require_compare_build = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/functions/compare-build.js": ((exports, module) => {
	const SemVer$8 = require_semver$1();
	const compareBuild$3 = (a, b, loose) => {
		const versionA = new SemVer$8(a, loose);
		const versionB = new SemVer$8(b, loose);
		return versionA.compare(versionB) || versionA.compareBuild(versionB);
	};
	module.exports = compareBuild$3;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/functions/sort.js
var require_sort = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/functions/sort.js": ((exports, module) => {
	const compareBuild$2 = require_compare_build();
	const sort$1 = (list, loose) => list.sort((a, b) => compareBuild$2(a, b, loose));
	module.exports = sort$1;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/functions/rsort.js
var require_rsort = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/functions/rsort.js": ((exports, module) => {
	const compareBuild$1 = require_compare_build();
	const rsort$1 = (list, loose) => list.sort((a, b) => compareBuild$1(b, a, loose));
	module.exports = rsort$1;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/functions/gt.js
var require_gt = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/functions/gt.js": ((exports, module) => {
	const compare$8 = require_compare();
	const gt$4 = (a, b, loose) => compare$8(a, b, loose) > 0;
	module.exports = gt$4;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/functions/lt.js
var require_lt = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/functions/lt.js": ((exports, module) => {
	const compare$7 = require_compare();
	const lt$3 = (a, b, loose) => compare$7(a, b, loose) < 0;
	module.exports = lt$3;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/functions/eq.js
var require_eq = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/functions/eq.js": ((exports, module) => {
	const compare$6 = require_compare();
	const eq$2 = (a, b, loose) => compare$6(a, b, loose) === 0;
	module.exports = eq$2;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/functions/neq.js
var require_neq = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/functions/neq.js": ((exports, module) => {
	const compare$5 = require_compare();
	const neq$2 = (a, b, loose) => compare$5(a, b, loose) !== 0;
	module.exports = neq$2;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/functions/gte.js
var require_gte = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/functions/gte.js": ((exports, module) => {
	const compare$4 = require_compare();
	const gte$3 = (a, b, loose) => compare$4(a, b, loose) >= 0;
	module.exports = gte$3;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/functions/lte.js
var require_lte = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/functions/lte.js": ((exports, module) => {
	const compare$3 = require_compare();
	const lte$3 = (a, b, loose) => compare$3(a, b, loose) <= 0;
	module.exports = lte$3;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/functions/cmp.js
var require_cmp = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/functions/cmp.js": ((exports, module) => {
	const eq$1 = require_eq();
	const neq$1 = require_neq();
	const gt$3 = require_gt();
	const gte$2 = require_gte();
	const lt$2 = require_lt();
	const lte$2 = require_lte();
	const cmp$2 = (a, op, b, loose) => {
		switch (op) {
			case "===":
				if (typeof a === "object") a = a.version;
				if (typeof b === "object") b = b.version;
				return a === b;
			case "!==":
				if (typeof a === "object") a = a.version;
				if (typeof b === "object") b = b.version;
				return a !== b;
			case "":
			case "=":
			case "==": return eq$1(a, b, loose);
			case "!=": return neq$1(a, b, loose);
			case ">": return gt$3(a, b, loose);
			case ">=": return gte$2(a, b, loose);
			case "<": return lt$2(a, b, loose);
			case "<=": return lte$2(a, b, loose);
			default: throw new TypeError(`Invalid operator: ${op}`);
		}
	};
	module.exports = cmp$2;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/functions/coerce.js
var require_coerce = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/functions/coerce.js": ((exports, module) => {
	const SemVer$7 = require_semver$1();
	const parse$1 = require_parse();
	const { safeRe: re$2, t: t$2 } = require_re();
	const coerce$1 = (version, options) => {
		if (version instanceof SemVer$7) return version;
		if (typeof version === "number") version = String(version);
		if (typeof version !== "string") return null;
		options = options || {};
		let match = null;
		if (!options.rtl) match = version.match(options.includePrerelease ? re$2[t$2.COERCEFULL] : re$2[t$2.COERCE]);
		else {
			const coerceRtlRegex = options.includePrerelease ? re$2[t$2.COERCERTLFULL] : re$2[t$2.COERCERTL];
			let next;
			while ((next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length)) {
				if (!match || next.index + next[0].length !== match.index + match[0].length) match = next;
				coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
			}
			coerceRtlRegex.lastIndex = -1;
		}
		if (match === null) return null;
		const major$2 = match[2];
		return parse$1(`${major$2}.${match[3] || "0"}.${match[4] || "0"}${options.includePrerelease && match[5] ? `-${match[5]}` : ""}${options.includePrerelease && match[6] ? `+${match[6]}` : ""}`, options);
	};
	module.exports = coerce$1;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/internal/lrucache.js
var require_lrucache = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/internal/lrucache.js": ((exports, module) => {
	var LRUCache = class {
		constructor() {
			this.max = 1e3;
			this.map = /* @__PURE__ */ new Map();
		}
		get(key) {
			const value = this.map.get(key);
			if (value === void 0) return;
			else {
				this.map.delete(key);
				this.map.set(key, value);
				return value;
			}
		}
		delete(key) {
			return this.map.delete(key);
		}
		set(key, value) {
			if (!this.delete(key) && value !== void 0) {
				if (this.map.size >= this.max) {
					const firstKey = this.map.keys().next().value;
					this.delete(firstKey);
				}
				this.map.set(key, value);
			}
			return this;
		}
	};
	module.exports = LRUCache;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/classes/range.js
var require_range = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/classes/range.js": ((exports, module) => {
	const SPACE_CHARACTERS = /\s+/g;
	var Range$11 = class Range$11 {
		constructor(range, options) {
			options = parseOptions$1(options);
			if (range instanceof Range$11) if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) return range;
			else return new Range$11(range.raw, options);
			if (range instanceof Comparator$4) {
				this.raw = range.value;
				this.set = [[range]];
				this.formatted = void 0;
				return this;
			}
			this.options = options;
			this.loose = !!options.loose;
			this.includePrerelease = !!options.includePrerelease;
			this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
			this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
			if (!this.set.length) throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
			if (this.set.length > 1) {
				const first = this.set[0];
				this.set = this.set.filter((c) => !isNullSet(c[0]));
				if (this.set.length === 0) this.set = [first];
				else if (this.set.length > 1) {
					for (const c of this.set) if (c.length === 1 && isAny(c[0])) {
						this.set = [c];
						break;
					}
				}
			}
			this.formatted = void 0;
		}
		get range() {
			if (this.formatted === void 0) {
				this.formatted = "";
				for (let i = 0; i < this.set.length; i++) {
					if (i > 0) this.formatted += "||";
					const comps = this.set[i];
					for (let k = 0; k < comps.length; k++) {
						if (k > 0) this.formatted += " ";
						this.formatted += comps[k].toString().trim();
					}
				}
			}
			return this.formatted;
		}
		format() {
			return this.range;
		}
		toString() {
			return this.range;
		}
		parseRange(range) {
			const memoKey = ((this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE)) + ":" + range;
			const cached = cache.get(memoKey);
			if (cached) return cached;
			const loose = this.options.loose;
			const hr = loose ? re$1[t$1.HYPHENRANGELOOSE] : re$1[t$1.HYPHENRANGE];
			range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
			debug$1("hyphen replace", range);
			range = range.replace(re$1[t$1.COMPARATORTRIM], comparatorTrimReplace);
			debug$1("comparator trim", range);
			range = range.replace(re$1[t$1.TILDETRIM], tildeTrimReplace);
			debug$1("tilde trim", range);
			range = range.replace(re$1[t$1.CARETTRIM], caretTrimReplace);
			debug$1("caret trim", range);
			let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
			if (loose) rangeList = rangeList.filter((comp) => {
				debug$1("loose invalid filter", comp, this.options);
				return !!comp.match(re$1[t$1.COMPARATORLOOSE]);
			});
			debug$1("range list", rangeList);
			const rangeMap = /* @__PURE__ */ new Map();
			const comparators = rangeList.map((comp) => new Comparator$4(comp, this.options));
			for (const comp of comparators) {
				if (isNullSet(comp)) return [comp];
				rangeMap.set(comp.value, comp);
			}
			if (rangeMap.size > 1 && rangeMap.has("")) rangeMap.delete("");
			const result = [...rangeMap.values()];
			cache.set(memoKey, result);
			return result;
		}
		intersects(range, options) {
			if (!(range instanceof Range$11)) throw new TypeError("a Range is required");
			return this.set.some((thisComparators) => {
				return isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => {
					return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => {
						return rangeComparators.every((rangeComparator) => {
							return thisComparator.intersects(rangeComparator, options);
						});
					});
				});
			});
		}
		test(version) {
			if (!version) return false;
			if (typeof version === "string") try {
				version = new SemVer$6(version, this.options);
			} catch (er) {
				return false;
			}
			for (let i = 0; i < this.set.length; i++) if (testSet(this.set[i], version, this.options)) return true;
			return false;
		}
	};
	module.exports = Range$11;
	const cache = new (require_lrucache())();
	const parseOptions$1 = require_parse_options();
	const Comparator$4 = require_comparator();
	const debug$1 = require_debug();
	const SemVer$6 = require_semver$1();
	const { safeRe: re$1, t: t$1, comparatorTrimReplace, tildeTrimReplace, caretTrimReplace } = require_re();
	const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
	const isNullSet = (c) => c.value === "<0.0.0-0";
	const isAny = (c) => c.value === "";
	const isSatisfiable = (comparators, options) => {
		let result = true;
		const remainingComparators = comparators.slice();
		let testComparator = remainingComparators.pop();
		while (result && remainingComparators.length) {
			result = remainingComparators.every((otherComparator) => {
				return testComparator.intersects(otherComparator, options);
			});
			testComparator = remainingComparators.pop();
		}
		return result;
	};
	const parseComparator = (comp, options) => {
		comp = comp.replace(re$1[t$1.BUILD], "");
		debug$1("comp", comp, options);
		comp = replaceCarets(comp, options);
		debug$1("caret", comp);
		comp = replaceTildes(comp, options);
		debug$1("tildes", comp);
		comp = replaceXRanges(comp, options);
		debug$1("xrange", comp);
		comp = replaceStars(comp, options);
		debug$1("stars", comp);
		return comp;
	};
	const isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
	const replaceTildes = (comp, options) => {
		return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
	};
	const replaceTilde = (comp, options) => {
		const r = options.loose ? re$1[t$1.TILDELOOSE] : re$1[t$1.TILDE];
		return comp.replace(r, (_, M, m$1, p, pr) => {
			debug$1("tilde", comp, _, M, m$1, p, pr);
			let ret;
			if (isX(M)) ret = "";
			else if (isX(m$1)) ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
			else if (isX(p)) ret = `>=${M}.${m$1}.0 <${M}.${+m$1 + 1}.0-0`;
			else if (pr) {
				debug$1("replaceTilde pr", pr);
				ret = `>=${M}.${m$1}.${p}-${pr} <${M}.${+m$1 + 1}.0-0`;
			} else ret = `>=${M}.${m$1}.${p} <${M}.${+m$1 + 1}.0-0`;
			debug$1("tilde return", ret);
			return ret;
		});
	};
	const replaceCarets = (comp, options) => {
		return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" ");
	};
	const replaceCaret = (comp, options) => {
		debug$1("caret", comp, options);
		const r = options.loose ? re$1[t$1.CARETLOOSE] : re$1[t$1.CARET];
		const z = options.includePrerelease ? "-0" : "";
		return comp.replace(r, (_, M, m$1, p, pr) => {
			debug$1("caret", comp, _, M, m$1, p, pr);
			let ret;
			if (isX(M)) ret = "";
			else if (isX(m$1)) ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
			else if (isX(p)) if (M === "0") ret = `>=${M}.${m$1}.0${z} <${M}.${+m$1 + 1}.0-0`;
			else ret = `>=${M}.${m$1}.0${z} <${+M + 1}.0.0-0`;
			else if (pr) {
				debug$1("replaceCaret pr", pr);
				if (M === "0") if (m$1 === "0") ret = `>=${M}.${m$1}.${p}-${pr} <${M}.${m$1}.${+p + 1}-0`;
				else ret = `>=${M}.${m$1}.${p}-${pr} <${M}.${+m$1 + 1}.0-0`;
				else ret = `>=${M}.${m$1}.${p}-${pr} <${+M + 1}.0.0-0`;
			} else {
				debug$1("no pr");
				if (M === "0") if (m$1 === "0") ret = `>=${M}.${m$1}.${p}${z} <${M}.${m$1}.${+p + 1}-0`;
				else ret = `>=${M}.${m$1}.${p}${z} <${M}.${+m$1 + 1}.0-0`;
				else ret = `>=${M}.${m$1}.${p} <${+M + 1}.0.0-0`;
			}
			debug$1("caret return", ret);
			return ret;
		});
	};
	const replaceXRanges = (comp, options) => {
		debug$1("replaceXRanges", comp, options);
		return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ");
	};
	const replaceXRange = (comp, options) => {
		comp = comp.trim();
		const r = options.loose ? re$1[t$1.XRANGELOOSE] : re$1[t$1.XRANGE];
		return comp.replace(r, (ret, gtlt, M, m$1, p, pr) => {
			debug$1("xRange", comp, ret, gtlt, M, m$1, p, pr);
			const xM = isX(M);
			const xm = xM || isX(m$1);
			const xp = xm || isX(p);
			const anyX = xp;
			if (gtlt === "=" && anyX) gtlt = "";
			pr = options.includePrerelease ? "-0" : "";
			if (xM) if (gtlt === ">" || gtlt === "<") ret = "<0.0.0-0";
			else ret = "*";
			else if (gtlt && anyX) {
				if (xm) m$1 = 0;
				p = 0;
				if (gtlt === ">") {
					gtlt = ">=";
					if (xm) {
						M = +M + 1;
						m$1 = 0;
						p = 0;
					} else {
						m$1 = +m$1 + 1;
						p = 0;
					}
				} else if (gtlt === "<=") {
					gtlt = "<";
					if (xm) M = +M + 1;
					else m$1 = +m$1 + 1;
				}
				if (gtlt === "<") pr = "-0";
				ret = `${gtlt + M}.${m$1}.${p}${pr}`;
			} else if (xm) ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
			else if (xp) ret = `>=${M}.${m$1}.0${pr} <${M}.${+m$1 + 1}.0-0`;
			debug$1("xRange return", ret);
			return ret;
		});
	};
	const replaceStars = (comp, options) => {
		debug$1("replaceStars", comp, options);
		return comp.trim().replace(re$1[t$1.STAR], "");
	};
	const replaceGTE0 = (comp, options) => {
		debug$1("replaceGTE0", comp, options);
		return comp.trim().replace(re$1[options.includePrerelease ? t$1.GTE0PRE : t$1.GTE0], "");
	};
	const hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
		if (isX(fM)) from = "";
		else if (isX(fm)) from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
		else if (isX(fp)) from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
		else if (fpr) from = `>=${from}`;
		else from = `>=${from}${incPr ? "-0" : ""}`;
		if (isX(tM)) to = "";
		else if (isX(tm)) to = `<${+tM + 1}.0.0-0`;
		else if (isX(tp)) to = `<${tM}.${+tm + 1}.0-0`;
		else if (tpr) to = `<=${tM}.${tm}.${tp}-${tpr}`;
		else if (incPr) to = `<${tM}.${tm}.${+tp + 1}-0`;
		else to = `<=${to}`;
		return `${from} ${to}`.trim();
	};
	const testSet = (set, version, options) => {
		for (let i = 0; i < set.length; i++) if (!set[i].test(version)) return false;
		if (version.prerelease.length && !options.includePrerelease) {
			for (let i = 0; i < set.length; i++) {
				debug$1(set[i].semver);
				if (set[i].semver === Comparator$4.ANY) continue;
				if (set[i].semver.prerelease.length > 0) {
					const allowed = set[i].semver;
					if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) return true;
				}
			}
			return false;
		}
		return true;
	};
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/classes/comparator.js
var require_comparator = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/classes/comparator.js": ((exports, module) => {
	const ANY$2 = Symbol("SemVer ANY");
	var Comparator$3 = class Comparator$3 {
		static get ANY() {
			return ANY$2;
		}
		constructor(comp, options) {
			options = parseOptions(options);
			if (comp instanceof Comparator$3) if (comp.loose === !!options.loose) return comp;
			else comp = comp.value;
			comp = comp.trim().split(/\s+/).join(" ");
			debug("comparator", comp, options);
			this.options = options;
			this.loose = !!options.loose;
			this.parse(comp);
			if (this.semver === ANY$2) this.value = "";
			else this.value = this.operator + this.semver.version;
			debug("comp", this);
		}
		parse(comp) {
			const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
			const m$1 = comp.match(r);
			if (!m$1) throw new TypeError(`Invalid comparator: ${comp}`);
			this.operator = m$1[1] !== void 0 ? m$1[1] : "";
			if (this.operator === "=") this.operator = "";
			if (!m$1[2]) this.semver = ANY$2;
			else this.semver = new SemVer$5(m$1[2], this.options.loose);
		}
		toString() {
			return this.value;
		}
		test(version) {
			debug("Comparator.test", version, this.options.loose);
			if (this.semver === ANY$2 || version === ANY$2) return true;
			if (typeof version === "string") try {
				version = new SemVer$5(version, this.options);
			} catch (er) {
				return false;
			}
			return cmp$1(version, this.operator, this.semver, this.options);
		}
		intersects(comp, options) {
			if (!(comp instanceof Comparator$3)) throw new TypeError("a Comparator is required");
			if (this.operator === "") {
				if (this.value === "") return true;
				return new Range$10(comp.value, options).test(this.value);
			} else if (comp.operator === "") {
				if (comp.value === "") return true;
				return new Range$10(this.value, options).test(comp.semver);
			}
			options = parseOptions(options);
			if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) return false;
			if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) return false;
			if (this.operator.startsWith(">") && comp.operator.startsWith(">")) return true;
			if (this.operator.startsWith("<") && comp.operator.startsWith("<")) return true;
			if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) return true;
			if (cmp$1(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) return true;
			if (cmp$1(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) return true;
			return false;
		}
	};
	module.exports = Comparator$3;
	const parseOptions = require_parse_options();
	const { safeRe: re, t } = require_re();
	const cmp$1 = require_cmp();
	const debug = require_debug();
	const SemVer$5 = require_semver$1();
	const Range$10 = require_range();
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/functions/satisfies.js
var require_satisfies = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/functions/satisfies.js": ((exports, module) => {
	const Range$9 = require_range();
	const satisfies$4 = (version, range, options) => {
		try {
			range = new Range$9(range, options);
		} catch (er) {
			return false;
		}
		return range.test(version);
	};
	module.exports = satisfies$4;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/ranges/to-comparators.js
var require_to_comparators = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/ranges/to-comparators.js": ((exports, module) => {
	const Range$8 = require_range();
	const toComparators$1 = (range, options) => new Range$8(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" "));
	module.exports = toComparators$1;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/ranges/max-satisfying.js
var require_max_satisfying = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/ranges/max-satisfying.js": ((exports, module) => {
	const SemVer$4 = require_semver$1();
	const Range$7 = require_range();
	const maxSatisfying$1 = (versions, range, options) => {
		let max = null;
		let maxSV = null;
		let rangeObj = null;
		try {
			rangeObj = new Range$7(range, options);
		} catch (er) {
			return null;
		}
		versions.forEach((v) => {
			if (rangeObj.test(v)) {
				if (!max || maxSV.compare(v) === -1) {
					max = v;
					maxSV = new SemVer$4(max, options);
				}
			}
		});
		return max;
	};
	module.exports = maxSatisfying$1;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/ranges/min-satisfying.js
var require_min_satisfying = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/ranges/min-satisfying.js": ((exports, module) => {
	const SemVer$3 = require_semver$1();
	const Range$6 = require_range();
	const minSatisfying$1 = (versions, range, options) => {
		let min = null;
		let minSV = null;
		let rangeObj = null;
		try {
			rangeObj = new Range$6(range, options);
		} catch (er) {
			return null;
		}
		versions.forEach((v) => {
			if (rangeObj.test(v)) {
				if (!min || minSV.compare(v) === 1) {
					min = v;
					minSV = new SemVer$3(min, options);
				}
			}
		});
		return min;
	};
	module.exports = minSatisfying$1;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/ranges/min-version.js
var require_min_version = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/ranges/min-version.js": ((exports, module) => {
	const SemVer$2 = require_semver$1();
	const Range$5 = require_range();
	const gt$2 = require_gt();
	const minVersion$1 = (range, loose) => {
		range = new Range$5(range, loose);
		let minver = new SemVer$2("0.0.0");
		if (range.test(minver)) return minver;
		minver = new SemVer$2("0.0.0-0");
		if (range.test(minver)) return minver;
		minver = null;
		for (let i = 0; i < range.set.length; ++i) {
			const comparators = range.set[i];
			let setMin = null;
			comparators.forEach((comparator) => {
				const compver = new SemVer$2(comparator.semver.version);
				switch (comparator.operator) {
					case ">":
						if (compver.prerelease.length === 0) compver.patch++;
						else compver.prerelease.push(0);
						compver.raw = compver.format();
					case "":
					case ">=":
						if (!setMin || gt$2(compver, setMin)) setMin = compver;
						break;
					case "<":
					case "<=": break;
					default: throw new Error(`Unexpected operation: ${comparator.operator}`);
				}
			});
			if (setMin && (!minver || gt$2(minver, setMin))) minver = setMin;
		}
		if (minver && range.test(minver)) return minver;
		return null;
	};
	module.exports = minVersion$1;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/ranges/valid.js
var require_valid = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/ranges/valid.js": ((exports, module) => {
	const Range$4 = require_range();
	const validRange$1 = (range, options) => {
		try {
			return new Range$4(range, options).range || "*";
		} catch (er) {
			return null;
		}
	};
	module.exports = validRange$1;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/ranges/outside.js
var require_outside = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/ranges/outside.js": ((exports, module) => {
	const SemVer$1 = require_semver$1();
	const Comparator$2 = require_comparator();
	const { ANY: ANY$1 } = Comparator$2;
	const Range$3 = require_range();
	const satisfies$3 = require_satisfies();
	const gt$1 = require_gt();
	const lt$1 = require_lt();
	const lte$1 = require_lte();
	const gte$1 = require_gte();
	const outside$3 = (version, range, hilo, options) => {
		version = new SemVer$1(version, options);
		range = new Range$3(range, options);
		let gtfn, ltefn, ltfn, comp, ecomp;
		switch (hilo) {
			case ">":
				gtfn = gt$1;
				ltefn = lte$1;
				ltfn = lt$1;
				comp = ">";
				ecomp = ">=";
				break;
			case "<":
				gtfn = lt$1;
				ltefn = gte$1;
				ltfn = gt$1;
				comp = "<";
				ecomp = "<=";
				break;
			default: throw new TypeError("Must provide a hilo val of \"<\" or \">\"");
		}
		if (satisfies$3(version, range, options)) return false;
		for (let i = 0; i < range.set.length; ++i) {
			const comparators = range.set[i];
			let high = null;
			let low = null;
			comparators.forEach((comparator) => {
				if (comparator.semver === ANY$1) comparator = new Comparator$2(">=0.0.0");
				high = high || comparator;
				low = low || comparator;
				if (gtfn(comparator.semver, high.semver, options)) high = comparator;
				else if (ltfn(comparator.semver, low.semver, options)) low = comparator;
			});
			if (high.operator === comp || high.operator === ecomp) return false;
			if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) return false;
			else if (low.operator === ecomp && ltfn(version, low.semver)) return false;
		}
		return true;
	};
	module.exports = outside$3;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/ranges/gtr.js
var require_gtr = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/ranges/gtr.js": ((exports, module) => {
	const outside$2 = require_outside();
	const gtr$1 = (version, range, options) => outside$2(version, range, ">", options);
	module.exports = gtr$1;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/ranges/ltr.js
var require_ltr = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/ranges/ltr.js": ((exports, module) => {
	const outside$1 = require_outside();
	const ltr$1 = (version, range, options) => outside$1(version, range, "<", options);
	module.exports = ltr$1;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/ranges/intersects.js
var require_intersects = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/ranges/intersects.js": ((exports, module) => {
	const Range$2 = require_range();
	const intersects$1 = (r1, r2, options) => {
		r1 = new Range$2(r1, options);
		r2 = new Range$2(r2, options);
		return r1.intersects(r2, options);
	};
	module.exports = intersects$1;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/ranges/simplify.js
var require_simplify = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/ranges/simplify.js": ((exports, module) => {
	const satisfies$2 = require_satisfies();
	const compare$2 = require_compare();
	module.exports = (versions, range, options) => {
		const set = [];
		let first = null;
		let prev = null;
		const v = versions.sort((a, b) => compare$2(a, b, options));
		for (const version of v) if (satisfies$2(version, range, options)) {
			prev = version;
			if (!first) first = version;
		} else {
			if (prev) set.push([first, prev]);
			prev = null;
			first = null;
		}
		if (first) set.push([first, null]);
		const ranges = [];
		for (const [min, max] of set) if (min === max) ranges.push(min);
		else if (!max && min === v[0]) ranges.push("*");
		else if (!max) ranges.push(`>=${min}`);
		else if (min === v[0]) ranges.push(`<=${max}`);
		else ranges.push(`${min} - ${max}`);
		const simplified = ranges.join(" || ");
		const original = typeof range.raw === "string" ? range.raw : String(range);
		return simplified.length < original.length ? simplified : range;
	};
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/ranges/subset.js
var require_subset = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/ranges/subset.js": ((exports, module) => {
	const Range$1 = require_range();
	const Comparator$1 = require_comparator();
	const { ANY } = Comparator$1;
	const satisfies$1 = require_satisfies();
	const compare$1 = require_compare();
	const subset$1 = (sub, dom, options = {}) => {
		if (sub === dom) return true;
		sub = new Range$1(sub, options);
		dom = new Range$1(dom, options);
		let sawNonNull = false;
		OUTER: for (const simpleSub of sub.set) {
			for (const simpleDom of dom.set) {
				const isSub = simpleSubset(simpleSub, simpleDom, options);
				sawNonNull = sawNonNull || isSub !== null;
				if (isSub) continue OUTER;
			}
			if (sawNonNull) return false;
		}
		return true;
	};
	const minimumVersionWithPreRelease = [new Comparator$1(">=0.0.0-0")];
	const minimumVersion = [new Comparator$1(">=0.0.0")];
	const simpleSubset = (sub, dom, options) => {
		if (sub === dom) return true;
		if (sub.length === 1 && sub[0].semver === ANY) if (dom.length === 1 && dom[0].semver === ANY) return true;
		else if (options.includePrerelease) sub = minimumVersionWithPreRelease;
		else sub = minimumVersion;
		if (dom.length === 1 && dom[0].semver === ANY) if (options.includePrerelease) return true;
		else dom = minimumVersion;
		const eqSet = /* @__PURE__ */ new Set();
		let gt$5, lt$4;
		for (const c of sub) if (c.operator === ">" || c.operator === ">=") gt$5 = higherGT(gt$5, c, options);
		else if (c.operator === "<" || c.operator === "<=") lt$4 = lowerLT(lt$4, c, options);
		else eqSet.add(c.semver);
		if (eqSet.size > 1) return null;
		let gtltComp;
		if (gt$5 && lt$4) {
			gtltComp = compare$1(gt$5.semver, lt$4.semver, options);
			if (gtltComp > 0) return null;
			else if (gtltComp === 0 && (gt$5.operator !== ">=" || lt$4.operator !== "<=")) return null;
		}
		for (const eq$3 of eqSet) {
			if (gt$5 && !satisfies$1(eq$3, String(gt$5), options)) return null;
			if (lt$4 && !satisfies$1(eq$3, String(lt$4), options)) return null;
			for (const c of dom) if (!satisfies$1(eq$3, String(c), options)) return false;
			return true;
		}
		let higher, lower;
		let hasDomLT, hasDomGT;
		let needDomLTPre = lt$4 && !options.includePrerelease && lt$4.semver.prerelease.length ? lt$4.semver : false;
		let needDomGTPre = gt$5 && !options.includePrerelease && gt$5.semver.prerelease.length ? gt$5.semver : false;
		if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt$4.operator === "<" && needDomLTPre.prerelease[0] === 0) needDomLTPre = false;
		for (const c of dom) {
			hasDomGT = hasDomGT || c.operator === ">" || c.operator === ">=";
			hasDomLT = hasDomLT || c.operator === "<" || c.operator === "<=";
			if (gt$5) {
				if (needDomGTPre) {
					if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) needDomGTPre = false;
				}
				if (c.operator === ">" || c.operator === ">=") {
					higher = higherGT(gt$5, c, options);
					if (higher === c && higher !== gt$5) return false;
				} else if (gt$5.operator === ">=" && !satisfies$1(gt$5.semver, String(c), options)) return false;
			}
			if (lt$4) {
				if (needDomLTPre) {
					if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) needDomLTPre = false;
				}
				if (c.operator === "<" || c.operator === "<=") {
					lower = lowerLT(lt$4, c, options);
					if (lower === c && lower !== lt$4) return false;
				} else if (lt$4.operator === "<=" && !satisfies$1(lt$4.semver, String(c), options)) return false;
			}
			if (!c.operator && (lt$4 || gt$5) && gtltComp !== 0) return false;
		}
		if (gt$5 && hasDomLT && !lt$4 && gtltComp !== 0) return false;
		if (lt$4 && hasDomGT && !gt$5 && gtltComp !== 0) return false;
		if (needDomGTPre || needDomLTPre) return false;
		return true;
	};
	const higherGT = (a, b, options) => {
		if (!a) return b;
		const comp = compare$1(a.semver, b.semver, options);
		return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a;
	};
	const lowerLT = (a, b, options) => {
		if (!a) return b;
		const comp = compare$1(a.semver, b.semver, options);
		return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a;
	};
	module.exports = subset$1;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/node_modules/semver/index.js
var require_semver = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/node_modules/semver/index.js": ((exports, module) => {
	const internalRe = require_re();
	const constants = require_constants();
	const SemVer = require_semver$1();
	const identifiers = require_identifiers();
	const parse = require_parse();
	const valid = require_valid$1();
	const clean = require_clean();
	const inc = require_inc();
	const diff = require_diff();
	const major = require_major();
	const minor = require_minor();
	const patch = require_patch();
	const prerelease = require_prerelease();
	const compare = require_compare();
	const rcompare = require_rcompare();
	const compareLoose = require_compare_loose();
	const compareBuild = require_compare_build();
	const sort = require_sort();
	const rsort = require_rsort();
	const gt = require_gt();
	const lt = require_lt();
	const eq = require_eq();
	const neq = require_neq();
	const gte = require_gte();
	const lte = require_lte();
	const cmp = require_cmp();
	const coerce = require_coerce();
	const Comparator = require_comparator();
	const Range = require_range();
	const satisfies = require_satisfies();
	const toComparators = require_to_comparators();
	const maxSatisfying = require_max_satisfying();
	const minSatisfying = require_min_satisfying();
	const minVersion = require_min_version();
	const validRange = require_valid();
	const outside = require_outside();
	const gtr = require_gtr();
	const ltr = require_ltr();
	const intersects = require_intersects();
	const simplifyRange = require_simplify();
	const subset = require_subset();
	module.exports = {
		parse,
		valid,
		clean,
		inc,
		diff,
		major,
		minor,
		patch,
		prerelease,
		compare,
		rcompare,
		compareLoose,
		compareBuild,
		sort,
		rsort,
		gt,
		lt,
		eq,
		neq,
		gte,
		lte,
		cmp,
		coerce,
		Comparator,
		Range,
		satisfies,
		toComparators,
		maxSatisfying,
		minSatisfying,
		minVersion,
		validRange,
		outside,
		gtr,
		ltr,
		intersects,
		simplifyRange,
		subset,
		SemVer,
		re: internalRe.re,
		src: internalRe.src,
		tokens: internalRe.t,
		SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
		RELEASE_TYPES: constants.RELEASE_TYPES,
		compareIdentifiers: identifiers.compareIdentifiers,
		rcompareIdentifiers: identifiers.rcompareIdentifiers
	};
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/lib/asymmetricKeyDetailsSupported.js
var require_asymmetricKeyDetailsSupported = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/lib/asymmetricKeyDetailsSupported.js": ((exports, module) => {
	const semver$2 = require_semver();
	module.exports = semver$2.satisfies(process.version, ">=15.7.0");
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/lib/rsaPssKeyDetailsSupported.js
var require_rsaPssKeyDetailsSupported = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/lib/rsaPssKeyDetailsSupported.js": ((exports, module) => {
	const semver$1 = require_semver();
	module.exports = semver$1.satisfies(process.version, ">=16.9.0");
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/lib/validateAsymmetricKey.js
var require_validateAsymmetricKey = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/lib/validateAsymmetricKey.js": ((exports, module) => {
	const ASYMMETRIC_KEY_DETAILS_SUPPORTED = require_asymmetricKeyDetailsSupported();
	const RSA_PSS_KEY_DETAILS_SUPPORTED = require_rsaPssKeyDetailsSupported();
	const allowedAlgorithmsForKeys = {
		"ec": [
			"ES256",
			"ES384",
			"ES512"
		],
		"rsa": [
			"RS256",
			"PS256",
			"RS384",
			"PS384",
			"RS512",
			"PS512"
		],
		"rsa-pss": [
			"PS256",
			"PS384",
			"PS512"
		]
	};
	const allowedCurves = {
		ES256: "prime256v1",
		ES384: "secp384r1",
		ES512: "secp521r1"
	};
	module.exports = function(algorithm, key) {
		if (!algorithm || !key) return;
		const keyType = key.asymmetricKeyType;
		if (!keyType) return;
		const allowedAlgorithms = allowedAlgorithmsForKeys[keyType];
		if (!allowedAlgorithms) throw new Error(`Unknown key type "${keyType}".`);
		if (!allowedAlgorithms.includes(algorithm)) throw new Error(`"alg" parameter for "${keyType}" key type must be one of: ${allowedAlgorithms.join(", ")}.`);
		/* istanbul ignore next */
		if (ASYMMETRIC_KEY_DETAILS_SUPPORTED) switch (keyType) {
			case "ec":
				const keyCurve = key.asymmetricKeyDetails.namedCurve;
				const allowedCurve = allowedCurves[algorithm];
				if (keyCurve !== allowedCurve) throw new Error(`"alg" parameter "${algorithm}" requires curve "${allowedCurve}".`);
				break;
			case "rsa-pss":
				if (RSA_PSS_KEY_DETAILS_SUPPORTED) {
					const length = parseInt(algorithm.slice(-3), 10);
					const { hashAlgorithm, mgf1HashAlgorithm, saltLength } = key.asymmetricKeyDetails;
					if (hashAlgorithm !== `sha${length}` || mgf1HashAlgorithm !== hashAlgorithm) throw new Error(`Invalid key for this operation, its RSA-PSS parameters do not meet the requirements of "alg" ${algorithm}.`);
					if (saltLength !== void 0 && saltLength > length >> 3) throw new Error(`Invalid key for this operation, its RSA-PSS parameter saltLength does not meet the requirements of "alg" ${algorithm}.`);
				}
				break;
		}
	};
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/lib/psSupported.js
var require_psSupported = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/lib/psSupported.js": ((exports, module) => {
	var semver = require_semver();
	module.exports = semver.satisfies(process.version, "^6.12.0 || >=8.0.0");
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/verify.js
var require_verify = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/verify.js": ((exports, module) => {
	const JsonWebTokenError = require_JsonWebTokenError();
	const NotBeforeError = require_NotBeforeError();
	const TokenExpiredError = require_TokenExpiredError();
	const decode = require_decode();
	const timespan$1 = require_timespan();
	const validateAsymmetricKey$1 = require_validateAsymmetricKey();
	const PS_SUPPORTED$1 = require_psSupported();
	const jws$1 = require_jws();
	const { KeyObject: KeyObject$1, createSecretKey: createSecretKey$1, createPublicKey } = require("crypto");
	const PUB_KEY_ALGS = [
		"RS256",
		"RS384",
		"RS512"
	];
	const EC_KEY_ALGS = [
		"ES256",
		"ES384",
		"ES512"
	];
	const RSA_KEY_ALGS = [
		"RS256",
		"RS384",
		"RS512"
	];
	const HS_ALGS = [
		"HS256",
		"HS384",
		"HS512"
	];
	if (PS_SUPPORTED$1) {
		PUB_KEY_ALGS.splice(PUB_KEY_ALGS.length, 0, "PS256", "PS384", "PS512");
		RSA_KEY_ALGS.splice(RSA_KEY_ALGS.length, 0, "PS256", "PS384", "PS512");
	}
	module.exports = function(jwtString, secretOrPublicKey, options, callback) {
		if (typeof options === "function" && !callback) {
			callback = options;
			options = {};
		}
		if (!options) options = {};
		options = Object.assign({}, options);
		let done;
		if (callback) done = callback;
		else done = function(err, data) {
			if (err) throw err;
			return data;
		};
		if (options.clockTimestamp && typeof options.clockTimestamp !== "number") return done(new JsonWebTokenError("clockTimestamp must be a number"));
		if (options.nonce !== void 0 && (typeof options.nonce !== "string" || options.nonce.trim() === "")) return done(new JsonWebTokenError("nonce must be a non-empty string"));
		if (options.allowInvalidAsymmetricKeyTypes !== void 0 && typeof options.allowInvalidAsymmetricKeyTypes !== "boolean") return done(new JsonWebTokenError("allowInvalidAsymmetricKeyTypes must be a boolean"));
		const clockTimestamp = options.clockTimestamp || Math.floor(Date.now() / 1e3);
		if (!jwtString) return done(new JsonWebTokenError("jwt must be provided"));
		if (typeof jwtString !== "string") return done(new JsonWebTokenError("jwt must be a string"));
		const parts = jwtString.split(".");
		if (parts.length !== 3) return done(new JsonWebTokenError("jwt malformed"));
		let decodedToken;
		try {
			decodedToken = decode(jwtString, { complete: true });
		} catch (err) {
			return done(err);
		}
		if (!decodedToken) return done(new JsonWebTokenError("invalid token"));
		const header = decodedToken.header;
		let getSecret;
		if (typeof secretOrPublicKey === "function") {
			if (!callback) return done(new JsonWebTokenError("verify must be called asynchronous if secret or public key is provided as a callback"));
			getSecret = secretOrPublicKey;
		} else getSecret = function(header$1, secretCallback) {
			return secretCallback(null, secretOrPublicKey);
		};
		return getSecret(header, function(err, secretOrPublicKey$1) {
			if (err) return done(new JsonWebTokenError("error in secret or public key callback: " + err.message));
			const hasSignature = parts[2].trim() !== "";
			if (!hasSignature && secretOrPublicKey$1) return done(new JsonWebTokenError("jwt signature is required"));
			if (hasSignature && !secretOrPublicKey$1) return done(new JsonWebTokenError("secret or public key must be provided"));
			if (!hasSignature && !options.algorithms) return done(new JsonWebTokenError("please specify \"none\" in \"algorithms\" to verify unsigned tokens"));
			if (secretOrPublicKey$1 != null && !(secretOrPublicKey$1 instanceof KeyObject$1)) try {
				secretOrPublicKey$1 = createPublicKey(secretOrPublicKey$1);
			} catch (_) {
				try {
					secretOrPublicKey$1 = createSecretKey$1(typeof secretOrPublicKey$1 === "string" ? Buffer.from(secretOrPublicKey$1) : secretOrPublicKey$1);
				} catch (_$1) {
					return done(new JsonWebTokenError("secretOrPublicKey is not valid key material"));
				}
			}
			if (!options.algorithms) if (secretOrPublicKey$1.type === "secret") options.algorithms = HS_ALGS;
			else if (["rsa", "rsa-pss"].includes(secretOrPublicKey$1.asymmetricKeyType)) options.algorithms = RSA_KEY_ALGS;
			else if (secretOrPublicKey$1.asymmetricKeyType === "ec") options.algorithms = EC_KEY_ALGS;
			else options.algorithms = PUB_KEY_ALGS;
			if (options.algorithms.indexOf(decodedToken.header.alg) === -1) return done(new JsonWebTokenError("invalid algorithm"));
			if (header.alg.startsWith("HS") && secretOrPublicKey$1.type !== "secret") return done(new JsonWebTokenError(`secretOrPublicKey must be a symmetric key when using ${header.alg}`));
			else if (/^(?:RS|PS|ES)/.test(header.alg) && secretOrPublicKey$1.type !== "public") return done(new JsonWebTokenError(`secretOrPublicKey must be an asymmetric key when using ${header.alg}`));
			if (!options.allowInvalidAsymmetricKeyTypes) try {
				validateAsymmetricKey$1(header.alg, secretOrPublicKey$1);
			} catch (e) {
				return done(e);
			}
			let valid$2;
			try {
				valid$2 = jws$1.verify(jwtString, decodedToken.header.alg, secretOrPublicKey$1);
			} catch (e) {
				return done(e);
			}
			if (!valid$2) return done(new JsonWebTokenError("invalid signature"));
			const payload = decodedToken.payload;
			if (typeof payload.nbf !== "undefined" && !options.ignoreNotBefore) {
				if (typeof payload.nbf !== "number") return done(new JsonWebTokenError("invalid nbf value"));
				if (payload.nbf > clockTimestamp + (options.clockTolerance || 0)) return done(new NotBeforeError("jwt not active", /* @__PURE__ */ new Date(payload.nbf * 1e3)));
			}
			if (typeof payload.exp !== "undefined" && !options.ignoreExpiration) {
				if (typeof payload.exp !== "number") return done(new JsonWebTokenError("invalid exp value"));
				if (clockTimestamp >= payload.exp + (options.clockTolerance || 0)) return done(new TokenExpiredError("jwt expired", /* @__PURE__ */ new Date(payload.exp * 1e3)));
			}
			if (options.audience) {
				const audiences = Array.isArray(options.audience) ? options.audience : [options.audience];
				if (!(Array.isArray(payload.aud) ? payload.aud : [payload.aud]).some(function(targetAudience) {
					return audiences.some(function(audience) {
						return audience instanceof RegExp ? audience.test(targetAudience) : audience === targetAudience;
					});
				})) return done(new JsonWebTokenError("jwt audience invalid. expected: " + audiences.join(" or ")));
			}
			if (options.issuer) {
				if (typeof options.issuer === "string" && payload.iss !== options.issuer || Array.isArray(options.issuer) && options.issuer.indexOf(payload.iss) === -1) return done(new JsonWebTokenError("jwt issuer invalid. expected: " + options.issuer));
			}
			if (options.subject) {
				if (payload.sub !== options.subject) return done(new JsonWebTokenError("jwt subject invalid. expected: " + options.subject));
			}
			if (options.jwtid) {
				if (payload.jti !== options.jwtid) return done(new JsonWebTokenError("jwt jwtid invalid. expected: " + options.jwtid));
			}
			if (options.nonce) {
				if (payload.nonce !== options.nonce) return done(new JsonWebTokenError("jwt nonce invalid. expected: " + options.nonce));
			}
			if (options.maxAge) {
				if (typeof payload.iat !== "number") return done(new JsonWebTokenError("iat required when maxAge is specified"));
				const maxAgeTimestamp = timespan$1(options.maxAge, payload.iat);
				if (typeof maxAgeTimestamp === "undefined") return done(new JsonWebTokenError("\"maxAge\" should be a number of seconds or string representing a timespan eg: \"1d\", \"20h\", 60"));
				if (clockTimestamp >= maxAgeTimestamp + (options.clockTolerance || 0)) return done(new TokenExpiredError("maxAge exceeded", /* @__PURE__ */ new Date(maxAgeTimestamp * 1e3)));
			}
			if (options.complete === true) {
				const signature = decodedToken.signature;
				return done(null, {
					header,
					payload,
					signature
				});
			}
			return done(null, payload);
		});
	};
}) });

//#endregion
//#region ../../node_modules/lodash.includes/index.js
var require_lodash$6 = /* @__PURE__ */ __commonJS({ "../../node_modules/lodash.includes/index.js": ((exports, module) => {
	/**
	* lodash (Custom Build) <https://lodash.com/>
	* Build: `lodash modularize exports="npm" -o ./`
	* Copyright jQuery Foundation and other contributors <https://jquery.org/>
	* Released under MIT license <https://lodash.com/license>
	* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
	* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
	*/
	/** Used as references for various `Number` constants. */
	var INFINITY$2 = Infinity, MAX_SAFE_INTEGER = 9007199254740991, MAX_INTEGER$2 = 17976931348623157e292, NAN$2 = NaN;
	/** `Object#toString` result references. */
	var argsTag = "[object Arguments]", funcTag = "[object Function]", genTag = "[object GeneratorFunction]", stringTag$1 = "[object String]", symbolTag$2 = "[object Symbol]";
	/** Used to match leading and trailing whitespace. */
	var reTrim$2 = /^\s+|\s+$/g;
	/** Used to detect bad signed hexadecimal string values. */
	var reIsBadHex$2 = /^[-+]0x[0-9a-f]+$/i;
	/** Used to detect binary string values. */
	var reIsBinary$2 = /^0b[01]+$/i;
	/** Used to detect octal string values. */
	var reIsOctal$2 = /^0o[0-7]+$/i;
	/** Used to detect unsigned integer values. */
	var reIsUint = /^(?:0|[1-9]\d*)$/;
	/** Built-in method references without a dependency on `root`. */
	var freeParseInt$2 = parseInt;
	/**
	* A specialized version of `_.map` for arrays without support for iteratee
	* shorthands.
	*
	* @private
	* @param {Array} [array] The array to iterate over.
	* @param {Function} iteratee The function invoked per iteration.
	* @returns {Array} Returns the new mapped array.
	*/
	function arrayMap(array, iteratee) {
		var index = -1, length = array ? array.length : 0, result = Array(length);
		while (++index < length) result[index] = iteratee(array[index], index, array);
		return result;
	}
	/**
	* The base implementation of `_.findIndex` and `_.findLastIndex` without
	* support for iteratee shorthands.
	*
	* @private
	* @param {Array} array The array to inspect.
	* @param {Function} predicate The function invoked per iteration.
	* @param {number} fromIndex The index to search from.
	* @param {boolean} [fromRight] Specify iterating from right to left.
	* @returns {number} Returns the index of the matched value, else `-1`.
	*/
	function baseFindIndex(array, predicate, fromIndex, fromRight) {
		var length = array.length, index = fromIndex + (fromRight ? 1 : -1);
		while (fromRight ? index-- : ++index < length) if (predicate(array[index], index, array)) return index;
		return -1;
	}
	/**
	* The base implementation of `_.indexOf` without `fromIndex` bounds checks.
	*
	* @private
	* @param {Array} array The array to inspect.
	* @param {*} value The value to search for.
	* @param {number} fromIndex The index to search from.
	* @returns {number} Returns the index of the matched value, else `-1`.
	*/
	function baseIndexOf(array, value, fromIndex) {
		if (value !== value) return baseFindIndex(array, baseIsNaN, fromIndex);
		var index = fromIndex - 1, length = array.length;
		while (++index < length) if (array[index] === value) return index;
		return -1;
	}
	/**
	* The base implementation of `_.isNaN` without support for number objects.
	*
	* @private
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
	*/
	function baseIsNaN(value) {
		return value !== value;
	}
	/**
	* The base implementation of `_.times` without support for iteratee shorthands
	* or max array length checks.
	*
	* @private
	* @param {number} n The number of times to invoke `iteratee`.
	* @param {Function} iteratee The function invoked per iteration.
	* @returns {Array} Returns the array of results.
	*/
	function baseTimes(n, iteratee) {
		var index = -1, result = Array(n);
		while (++index < n) result[index] = iteratee(index);
		return result;
	}
	/**
	* The base implementation of `_.values` and `_.valuesIn` which creates an
	* array of `object` property values corresponding to the property names
	* of `props`.
	*
	* @private
	* @param {Object} object The object to query.
	* @param {Array} props The property names to get values for.
	* @returns {Object} Returns the array of property values.
	*/
	function baseValues(object, props) {
		return arrayMap(props, function(key) {
			return object[key];
		});
	}
	/**
	* Creates a unary function that invokes `func` with its argument transformed.
	*
	* @private
	* @param {Function} func The function to wrap.
	* @param {Function} transform The argument transform.
	* @returns {Function} Returns the new function.
	*/
	function overArg$1(func, transform) {
		return function(arg) {
			return func(transform(arg));
		};
	}
	/** Used for built-in method references. */
	var objectProto$1 = Object.prototype;
	/** Used to check objects for own properties. */
	var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
	/**
	* Used to resolve the
	* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
	* of values.
	*/
	var objectToString$6 = objectProto$1.toString;
	/** Built-in value references. */
	var propertyIsEnumerable = objectProto$1.propertyIsEnumerable;
	var nativeKeys = overArg$1(Object.keys, Object), nativeMax = Math.max;
	/**
	* Creates an array of the enumerable property names of the array-like `value`.
	*
	* @private
	* @param {*} value The value to query.
	* @param {boolean} inherited Specify returning inherited property names.
	* @returns {Array} Returns the array of property names.
	*/
	function arrayLikeKeys(value, inherited) {
		var result = isArray$1(value) || isArguments(value) ? baseTimes(value.length, String) : [];
		var length = result.length, skipIndexes = !!length;
		for (var key in value) if ((inherited || hasOwnProperty$1.call(value, key)) && !(skipIndexes && (key == "length" || isIndex(key, length)))) result.push(key);
		return result;
	}
	/**
	* The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
	*
	* @private
	* @param {Object} object The object to query.
	* @returns {Array} Returns the array of property names.
	*/
	function baseKeys(object) {
		if (!isPrototype(object)) return nativeKeys(object);
		var result = [];
		for (var key in Object(object)) if (hasOwnProperty$1.call(object, key) && key != "constructor") result.push(key);
		return result;
	}
	/**
	* Checks if `value` is a valid array-like index.
	*
	* @private
	* @param {*} value The value to check.
	* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
	* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
	*/
	function isIndex(value, length) {
		length = length == null ? MAX_SAFE_INTEGER : length;
		return !!length && (typeof value == "number" || reIsUint.test(value)) && value > -1 && value % 1 == 0 && value < length;
	}
	/**
	* Checks if `value` is likely a prototype object.
	*
	* @private
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
	*/
	function isPrototype(value) {
		var Ctor = value && value.constructor;
		return value === (typeof Ctor == "function" && Ctor.prototype || objectProto$1);
	}
	/**
	* Checks if `value` is in `collection`. If `collection` is a string, it's
	* checked for a substring of `value`, otherwise
	* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
	* is used for equality comparisons. If `fromIndex` is negative, it's used as
	* the offset from the end of `collection`.
	*
	* @static
	* @memberOf _
	* @since 0.1.0
	* @category Collection
	* @param {Array|Object|string} collection The collection to inspect.
	* @param {*} value The value to search for.
	* @param {number} [fromIndex=0] The index to search from.
	* @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
	* @returns {boolean} Returns `true` if `value` is found, else `false`.
	* @example
	*
	* _.includes([1, 2, 3], 1);
	* // => true
	*
	* _.includes([1, 2, 3], 1, 2);
	* // => false
	*
	* _.includes({ 'a': 1, 'b': 2 }, 1);
	* // => true
	*
	* _.includes('abcd', 'bc');
	* // => true
	*/
	function includes$1(collection, value, fromIndex, guard) {
		collection = isArrayLike(collection) ? collection : values(collection);
		fromIndex = fromIndex && !guard ? toInteger$2(fromIndex) : 0;
		var length = collection.length;
		if (fromIndex < 0) fromIndex = nativeMax(length + fromIndex, 0);
		return isString$2(collection) ? fromIndex <= length && collection.indexOf(value, fromIndex) > -1 : !!length && baseIndexOf(collection, value, fromIndex) > -1;
	}
	/**
	* Checks if `value` is likely an `arguments` object.
	*
	* @static
	* @memberOf _
	* @since 0.1.0
	* @category Lang
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` is an `arguments` object,
	*  else `false`.
	* @example
	*
	* _.isArguments(function() { return arguments; }());
	* // => true
	*
	* _.isArguments([1, 2, 3]);
	* // => false
	*/
	function isArguments(value) {
		return isArrayLikeObject(value) && hasOwnProperty$1.call(value, "callee") && (!propertyIsEnumerable.call(value, "callee") || objectToString$6.call(value) == argsTag);
	}
	/**
	* Checks if `value` is classified as an `Array` object.
	*
	* @static
	* @memberOf _
	* @since 0.1.0
	* @category Lang
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` is an array, else `false`.
	* @example
	*
	* _.isArray([1, 2, 3]);
	* // => true
	*
	* _.isArray(document.body.children);
	* // => false
	*
	* _.isArray('abc');
	* // => false
	*
	* _.isArray(_.noop);
	* // => false
	*/
	var isArray$1 = Array.isArray;
	/**
	* Checks if `value` is array-like. A value is considered array-like if it's
	* not a function and has a `value.length` that's an integer greater than or
	* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
	*
	* @static
	* @memberOf _
	* @since 4.0.0
	* @category Lang
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
	* @example
	*
	* _.isArrayLike([1, 2, 3]);
	* // => true
	*
	* _.isArrayLike(document.body.children);
	* // => true
	*
	* _.isArrayLike('abc');
	* // => true
	*
	* _.isArrayLike(_.noop);
	* // => false
	*/
	function isArrayLike(value) {
		return value != null && isLength(value.length) && !isFunction(value);
	}
	/**
	* This method is like `_.isArrayLike` except that it also checks if `value`
	* is an object.
	*
	* @static
	* @memberOf _
	* @since 4.0.0
	* @category Lang
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` is an array-like object,
	*  else `false`.
	* @example
	*
	* _.isArrayLikeObject([1, 2, 3]);
	* // => true
	*
	* _.isArrayLikeObject(document.body.children);
	* // => true
	*
	* _.isArrayLikeObject('abc');
	* // => false
	*
	* _.isArrayLikeObject(_.noop);
	* // => false
	*/
	function isArrayLikeObject(value) {
		return isObjectLike$6(value) && isArrayLike(value);
	}
	/**
	* Checks if `value` is classified as a `Function` object.
	*
	* @static
	* @memberOf _
	* @since 0.1.0
	* @category Lang
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` is a function, else `false`.
	* @example
	*
	* _.isFunction(_);
	* // => true
	*
	* _.isFunction(/abc/);
	* // => false
	*/
	function isFunction(value) {
		var tag = isObject$2(value) ? objectToString$6.call(value) : "";
		return tag == funcTag || tag == genTag;
	}
	/**
	* Checks if `value` is a valid array-like length.
	*
	* **Note:** This method is loosely based on
	* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
	*
	* @static
	* @memberOf _
	* @since 4.0.0
	* @category Lang
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
	* @example
	*
	* _.isLength(3);
	* // => true
	*
	* _.isLength(Number.MIN_VALUE);
	* // => false
	*
	* _.isLength(Infinity);
	* // => false
	*
	* _.isLength('3');
	* // => false
	*/
	function isLength(value) {
		return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
	}
	/**
	* Checks if `value` is the
	* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
	* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
	*
	* @static
	* @memberOf _
	* @since 0.1.0
	* @category Lang
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` is an object, else `false`.
	* @example
	*
	* _.isObject({});
	* // => true
	*
	* _.isObject([1, 2, 3]);
	* // => true
	*
	* _.isObject(_.noop);
	* // => true
	*
	* _.isObject(null);
	* // => false
	*/
	function isObject$2(value) {
		var type = typeof value;
		return !!value && (type == "object" || type == "function");
	}
	/**
	* Checks if `value` is object-like. A value is object-like if it's not `null`
	* and has a `typeof` result of "object".
	*
	* @static
	* @memberOf _
	* @since 4.0.0
	* @category Lang
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
	* @example
	*
	* _.isObjectLike({});
	* // => true
	*
	* _.isObjectLike([1, 2, 3]);
	* // => true
	*
	* _.isObjectLike(_.noop);
	* // => false
	*
	* _.isObjectLike(null);
	* // => false
	*/
	function isObjectLike$6(value) {
		return !!value && typeof value == "object";
	}
	/**
	* Checks if `value` is classified as a `String` primitive or object.
	*
	* @static
	* @since 0.1.0
	* @memberOf _
	* @category Lang
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` is a string, else `false`.
	* @example
	*
	* _.isString('abc');
	* // => true
	*
	* _.isString(1);
	* // => false
	*/
	function isString$2(value) {
		return typeof value == "string" || !isArray$1(value) && isObjectLike$6(value) && objectToString$6.call(value) == stringTag$1;
	}
	/**
	* Checks if `value` is classified as a `Symbol` primitive or object.
	*
	* @static
	* @memberOf _
	* @since 4.0.0
	* @category Lang
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
	* @example
	*
	* _.isSymbol(Symbol.iterator);
	* // => true
	*
	* _.isSymbol('abc');
	* // => false
	*/
	function isSymbol$2(value) {
		return typeof value == "symbol" || isObjectLike$6(value) && objectToString$6.call(value) == symbolTag$2;
	}
	/**
	* Converts `value` to a finite number.
	*
	* @static
	* @memberOf _
	* @since 4.12.0
	* @category Lang
	* @param {*} value The value to convert.
	* @returns {number} Returns the converted number.
	* @example
	*
	* _.toFinite(3.2);
	* // => 3.2
	*
	* _.toFinite(Number.MIN_VALUE);
	* // => 5e-324
	*
	* _.toFinite(Infinity);
	* // => 1.7976931348623157e+308
	*
	* _.toFinite('3.2');
	* // => 3.2
	*/
	function toFinite$2(value) {
		if (!value) return value === 0 ? value : 0;
		value = toNumber$2(value);
		if (value === INFINITY$2 || value === -INFINITY$2) return (value < 0 ? -1 : 1) * MAX_INTEGER$2;
		return value === value ? value : 0;
	}
	/**
	* Converts `value` to an integer.
	*
	* **Note:** This method is loosely based on
	* [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
	*
	* @static
	* @memberOf _
	* @since 4.0.0
	* @category Lang
	* @param {*} value The value to convert.
	* @returns {number} Returns the converted integer.
	* @example
	*
	* _.toInteger(3.2);
	* // => 3
	*
	* _.toInteger(Number.MIN_VALUE);
	* // => 0
	*
	* _.toInteger(Infinity);
	* // => 1.7976931348623157e+308
	*
	* _.toInteger('3.2');
	* // => 3
	*/
	function toInteger$2(value) {
		var result = toFinite$2(value), remainder = result % 1;
		return result === result ? remainder ? result - remainder : result : 0;
	}
	/**
	* Converts `value` to a number.
	*
	* @static
	* @memberOf _
	* @since 4.0.0
	* @category Lang
	* @param {*} value The value to process.
	* @returns {number} Returns the number.
	* @example
	*
	* _.toNumber(3.2);
	* // => 3.2
	*
	* _.toNumber(Number.MIN_VALUE);
	* // => 5e-324
	*
	* _.toNumber(Infinity);
	* // => Infinity
	*
	* _.toNumber('3.2');
	* // => 3.2
	*/
	function toNumber$2(value) {
		if (typeof value == "number") return value;
		if (isSymbol$2(value)) return NAN$2;
		if (isObject$2(value)) {
			var other = typeof value.valueOf == "function" ? value.valueOf() : value;
			value = isObject$2(other) ? other + "" : other;
		}
		if (typeof value != "string") return value === 0 ? value : +value;
		value = value.replace(reTrim$2, "");
		var isBinary = reIsBinary$2.test(value);
		return isBinary || reIsOctal$2.test(value) ? freeParseInt$2(value.slice(2), isBinary ? 2 : 8) : reIsBadHex$2.test(value) ? NAN$2 : +value;
	}
	/**
	* Creates an array of the own enumerable property names of `object`.
	*
	* **Note:** Non-object values are coerced to objects. See the
	* [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
	* for more details.
	*
	* @static
	* @since 0.1.0
	* @memberOf _
	* @category Object
	* @param {Object} object The object to query.
	* @returns {Array} Returns the array of property names.
	* @example
	*
	* function Foo() {
	*   this.a = 1;
	*   this.b = 2;
	* }
	*
	* Foo.prototype.c = 3;
	*
	* _.keys(new Foo);
	* // => ['a', 'b'] (iteration order is not guaranteed)
	*
	* _.keys('hi');
	* // => ['0', '1']
	*/
	function keys(object) {
		return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
	}
	/**
	* Creates an array of the own enumerable string keyed property values of `object`.
	*
	* **Note:** Non-object values are coerced to objects.
	*
	* @static
	* @since 0.1.0
	* @memberOf _
	* @category Object
	* @param {Object} object The object to query.
	* @returns {Array} Returns the array of property values.
	* @example
	*
	* function Foo() {
	*   this.a = 1;
	*   this.b = 2;
	* }
	*
	* Foo.prototype.c = 3;
	*
	* _.values(new Foo);
	* // => [1, 2] (iteration order is not guaranteed)
	*
	* _.values('hi');
	* // => ['h', 'i']
	*/
	function values(object) {
		return object ? baseValues(object, keys(object)) : [];
	}
	module.exports = includes$1;
}) });

//#endregion
//#region ../../node_modules/lodash.isboolean/index.js
var require_lodash$5 = /* @__PURE__ */ __commonJS({ "../../node_modules/lodash.isboolean/index.js": ((exports, module) => {
	/**
	* lodash 3.0.3 (Custom Build) <https://lodash.com/>
	* Build: `lodash modularize exports="npm" -o ./`
	* Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
	* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
	* Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
	* Available under MIT license <https://lodash.com/license>
	*/
	/** `Object#toString` result references. */
	var boolTag = "[object Boolean]";
	/**
	* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
	* of values.
	*/
	var objectToString$5 = Object.prototype.toString;
	/**
	* Checks if `value` is classified as a boolean primitive or object.
	*
	* @static
	* @memberOf _
	* @category Lang
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
	* @example
	*
	* _.isBoolean(false);
	* // => true
	*
	* _.isBoolean(null);
	* // => false
	*/
	function isBoolean$1(value) {
		return value === true || value === false || isObjectLike$5(value) && objectToString$5.call(value) == boolTag;
	}
	/**
	* Checks if `value` is object-like. A value is object-like if it's not `null`
	* and has a `typeof` result of "object".
	*
	* @static
	* @memberOf _
	* @category Lang
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
	* @example
	*
	* _.isObjectLike({});
	* // => true
	*
	* _.isObjectLike([1, 2, 3]);
	* // => true
	*
	* _.isObjectLike(_.noop);
	* // => false
	*
	* _.isObjectLike(null);
	* // => false
	*/
	function isObjectLike$5(value) {
		return !!value && typeof value == "object";
	}
	module.exports = isBoolean$1;
}) });

//#endregion
//#region ../../node_modules/lodash.isinteger/index.js
var require_lodash$4 = /* @__PURE__ */ __commonJS({ "../../node_modules/lodash.isinteger/index.js": ((exports, module) => {
	/**
	* lodash (Custom Build) <https://lodash.com/>
	* Build: `lodash modularize exports="npm" -o ./`
	* Copyright jQuery Foundation and other contributors <https://jquery.org/>
	* Released under MIT license <https://lodash.com/license>
	* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
	* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
	*/
	/** Used as references for various `Number` constants. */
	var INFINITY$1 = Infinity, MAX_INTEGER$1 = 17976931348623157e292, NAN$1 = NaN;
	/** `Object#toString` result references. */
	var symbolTag$1 = "[object Symbol]";
	/** Used to match leading and trailing whitespace. */
	var reTrim$1 = /^\s+|\s+$/g;
	/** Used to detect bad signed hexadecimal string values. */
	var reIsBadHex$1 = /^[-+]0x[0-9a-f]+$/i;
	/** Used to detect binary string values. */
	var reIsBinary$1 = /^0b[01]+$/i;
	/** Used to detect octal string values. */
	var reIsOctal$1 = /^0o[0-7]+$/i;
	/** Built-in method references without a dependency on `root`. */
	var freeParseInt$1 = parseInt;
	/**
	* Used to resolve the
	* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
	* of values.
	*/
	var objectToString$4 = Object.prototype.toString;
	/**
	* Checks if `value` is an integer.
	*
	* **Note:** This method is based on
	* [`Number.isInteger`](https://mdn.io/Number/isInteger).
	*
	* @static
	* @memberOf _
	* @since 4.0.0
	* @category Lang
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` is an integer, else `false`.
	* @example
	*
	* _.isInteger(3);
	* // => true
	*
	* _.isInteger(Number.MIN_VALUE);
	* // => false
	*
	* _.isInteger(Infinity);
	* // => false
	*
	* _.isInteger('3');
	* // => false
	*/
	function isInteger$1(value) {
		return typeof value == "number" && value == toInteger$1(value);
	}
	/**
	* Checks if `value` is the
	* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
	* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
	*
	* @static
	* @memberOf _
	* @since 0.1.0
	* @category Lang
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` is an object, else `false`.
	* @example
	*
	* _.isObject({});
	* // => true
	*
	* _.isObject([1, 2, 3]);
	* // => true
	*
	* _.isObject(_.noop);
	* // => true
	*
	* _.isObject(null);
	* // => false
	*/
	function isObject$1(value) {
		var type = typeof value;
		return !!value && (type == "object" || type == "function");
	}
	/**
	* Checks if `value` is object-like. A value is object-like if it's not `null`
	* and has a `typeof` result of "object".
	*
	* @static
	* @memberOf _
	* @since 4.0.0
	* @category Lang
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
	* @example
	*
	* _.isObjectLike({});
	* // => true
	*
	* _.isObjectLike([1, 2, 3]);
	* // => true
	*
	* _.isObjectLike(_.noop);
	* // => false
	*
	* _.isObjectLike(null);
	* // => false
	*/
	function isObjectLike$4(value) {
		return !!value && typeof value == "object";
	}
	/**
	* Checks if `value` is classified as a `Symbol` primitive or object.
	*
	* @static
	* @memberOf _
	* @since 4.0.0
	* @category Lang
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
	* @example
	*
	* _.isSymbol(Symbol.iterator);
	* // => true
	*
	* _.isSymbol('abc');
	* // => false
	*/
	function isSymbol$1(value) {
		return typeof value == "symbol" || isObjectLike$4(value) && objectToString$4.call(value) == symbolTag$1;
	}
	/**
	* Converts `value` to a finite number.
	*
	* @static
	* @memberOf _
	* @since 4.12.0
	* @category Lang
	* @param {*} value The value to convert.
	* @returns {number} Returns the converted number.
	* @example
	*
	* _.toFinite(3.2);
	* // => 3.2
	*
	* _.toFinite(Number.MIN_VALUE);
	* // => 5e-324
	*
	* _.toFinite(Infinity);
	* // => 1.7976931348623157e+308
	*
	* _.toFinite('3.2');
	* // => 3.2
	*/
	function toFinite$1(value) {
		if (!value) return value === 0 ? value : 0;
		value = toNumber$1(value);
		if (value === INFINITY$1 || value === -INFINITY$1) return (value < 0 ? -1 : 1) * MAX_INTEGER$1;
		return value === value ? value : 0;
	}
	/**
	* Converts `value` to an integer.
	*
	* **Note:** This method is loosely based on
	* [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
	*
	* @static
	* @memberOf _
	* @since 4.0.0
	* @category Lang
	* @param {*} value The value to convert.
	* @returns {number} Returns the converted integer.
	* @example
	*
	* _.toInteger(3.2);
	* // => 3
	*
	* _.toInteger(Number.MIN_VALUE);
	* // => 0
	*
	* _.toInteger(Infinity);
	* // => 1.7976931348623157e+308
	*
	* _.toInteger('3.2');
	* // => 3
	*/
	function toInteger$1(value) {
		var result = toFinite$1(value), remainder = result % 1;
		return result === result ? remainder ? result - remainder : result : 0;
	}
	/**
	* Converts `value` to a number.
	*
	* @static
	* @memberOf _
	* @since 4.0.0
	* @category Lang
	* @param {*} value The value to process.
	* @returns {number} Returns the number.
	* @example
	*
	* _.toNumber(3.2);
	* // => 3.2
	*
	* _.toNumber(Number.MIN_VALUE);
	* // => 5e-324
	*
	* _.toNumber(Infinity);
	* // => Infinity
	*
	* _.toNumber('3.2');
	* // => 3.2
	*/
	function toNumber$1(value) {
		if (typeof value == "number") return value;
		if (isSymbol$1(value)) return NAN$1;
		if (isObject$1(value)) {
			var other = typeof value.valueOf == "function" ? value.valueOf() : value;
			value = isObject$1(other) ? other + "" : other;
		}
		if (typeof value != "string") return value === 0 ? value : +value;
		value = value.replace(reTrim$1, "");
		var isBinary = reIsBinary$1.test(value);
		return isBinary || reIsOctal$1.test(value) ? freeParseInt$1(value.slice(2), isBinary ? 2 : 8) : reIsBadHex$1.test(value) ? NAN$1 : +value;
	}
	module.exports = isInteger$1;
}) });

//#endregion
//#region ../../node_modules/lodash.isnumber/index.js
var require_lodash$3 = /* @__PURE__ */ __commonJS({ "../../node_modules/lodash.isnumber/index.js": ((exports, module) => {
	/**
	* lodash 3.0.3 (Custom Build) <https://lodash.com/>
	* Build: `lodash modularize exports="npm" -o ./`
	* Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
	* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
	* Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
	* Available under MIT license <https://lodash.com/license>
	*/
	/** `Object#toString` result references. */
	var numberTag = "[object Number]";
	/**
	* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
	* of values.
	*/
	var objectToString$3 = Object.prototype.toString;
	/**
	* Checks if `value` is object-like. A value is object-like if it's not `null`
	* and has a `typeof` result of "object".
	*
	* @static
	* @memberOf _
	* @category Lang
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
	* @example
	*
	* _.isObjectLike({});
	* // => true
	*
	* _.isObjectLike([1, 2, 3]);
	* // => true
	*
	* _.isObjectLike(_.noop);
	* // => false
	*
	* _.isObjectLike(null);
	* // => false
	*/
	function isObjectLike$3(value) {
		return !!value && typeof value == "object";
	}
	/**
	* Checks if `value` is classified as a `Number` primitive or object.
	*
	* **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are classified
	* as numbers, use the `_.isFinite` method.
	*
	* @static
	* @memberOf _
	* @category Lang
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
	* @example
	*
	* _.isNumber(3);
	* // => true
	*
	* _.isNumber(Number.MIN_VALUE);
	* // => true
	*
	* _.isNumber(Infinity);
	* // => true
	*
	* _.isNumber('3');
	* // => false
	*/
	function isNumber$1(value) {
		return typeof value == "number" || isObjectLike$3(value) && objectToString$3.call(value) == numberTag;
	}
	module.exports = isNumber$1;
}) });

//#endregion
//#region ../../node_modules/lodash.isplainobject/index.js
var require_lodash$2 = /* @__PURE__ */ __commonJS({ "../../node_modules/lodash.isplainobject/index.js": ((exports, module) => {
	/**
	* lodash (Custom Build) <https://lodash.com/>
	* Build: `lodash modularize exports="npm" -o ./`
	* Copyright jQuery Foundation and other contributors <https://jquery.org/>
	* Released under MIT license <https://lodash.com/license>
	* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
	* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
	*/
	/** `Object#toString` result references. */
	var objectTag = "[object Object]";
	/**
	* Checks if `value` is a host object in IE < 9.
	*
	* @private
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` is a host object, else `false`.
	*/
	function isHostObject(value) {
		var result = false;
		if (value != null && typeof value.toString != "function") try {
			result = !!(value + "");
		} catch (e) {}
		return result;
	}
	/**
	* Creates a unary function that invokes `func` with its argument transformed.
	*
	* @private
	* @param {Function} func The function to wrap.
	* @param {Function} transform The argument transform.
	* @returns {Function} Returns the new function.
	*/
	function overArg(func, transform) {
		return function(arg) {
			return func(transform(arg));
		};
	}
	/** Used for built-in method references. */
	var funcProto = Function.prototype, objectProto = Object.prototype;
	/** Used to resolve the decompiled source of functions. */
	var funcToString = funcProto.toString;
	/** Used to check objects for own properties. */
	var hasOwnProperty = objectProto.hasOwnProperty;
	/** Used to infer the `Object` constructor. */
	var objectCtorString = funcToString.call(Object);
	/**
	* Used to resolve the
	* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
	* of values.
	*/
	var objectToString$2 = objectProto.toString;
	/** Built-in value references. */
	var getPrototype = overArg(Object.getPrototypeOf, Object);
	/**
	* Checks if `value` is object-like. A value is object-like if it's not `null`
	* and has a `typeof` result of "object".
	*
	* @static
	* @memberOf _
	* @since 4.0.0
	* @category Lang
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
	* @example
	*
	* _.isObjectLike({});
	* // => true
	*
	* _.isObjectLike([1, 2, 3]);
	* // => true
	*
	* _.isObjectLike(_.noop);
	* // => false
	*
	* _.isObjectLike(null);
	* // => false
	*/
	function isObjectLike$2(value) {
		return !!value && typeof value == "object";
	}
	/**
	* Checks if `value` is a plain object, that is, an object created by the
	* `Object` constructor or one with a `[[Prototype]]` of `null`.
	*
	* @static
	* @memberOf _
	* @since 0.8.0
	* @category Lang
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
	* @example
	*
	* function Foo() {
	*   this.a = 1;
	* }
	*
	* _.isPlainObject(new Foo);
	* // => false
	*
	* _.isPlainObject([1, 2, 3]);
	* // => false
	*
	* _.isPlainObject({ 'x': 0, 'y': 0 });
	* // => true
	*
	* _.isPlainObject(Object.create(null));
	* // => true
	*/
	function isPlainObject$1(value) {
		if (!isObjectLike$2(value) || objectToString$2.call(value) != objectTag || isHostObject(value)) return false;
		var proto = getPrototype(value);
		if (proto === null) return true;
		var Ctor = hasOwnProperty.call(proto, "constructor") && proto.constructor;
		return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString;
	}
	module.exports = isPlainObject$1;
}) });

//#endregion
//#region ../../node_modules/lodash.isstring/index.js
var require_lodash$1 = /* @__PURE__ */ __commonJS({ "../../node_modules/lodash.isstring/index.js": ((exports, module) => {
	/**
	* lodash 4.0.1 (Custom Build) <https://lodash.com/>
	* Build: `lodash modularize exports="npm" -o ./`
	* Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
	* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
	* Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
	* Available under MIT license <https://lodash.com/license>
	*/
	/** `Object#toString` result references. */
	var stringTag = "[object String]";
	/**
	* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
	* of values.
	*/
	var objectToString$1 = Object.prototype.toString;
	/**
	* Checks if `value` is classified as an `Array` object.
	*
	* @static
	* @memberOf _
	* @type Function
	* @category Lang
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
	* @example
	*
	* _.isArray([1, 2, 3]);
	* // => true
	*
	* _.isArray(document.body.children);
	* // => false
	*
	* _.isArray('abc');
	* // => false
	*
	* _.isArray(_.noop);
	* // => false
	*/
	var isArray = Array.isArray;
	/**
	* Checks if `value` is object-like. A value is object-like if it's not `null`
	* and has a `typeof` result of "object".
	*
	* @static
	* @memberOf _
	* @category Lang
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
	* @example
	*
	* _.isObjectLike({});
	* // => true
	*
	* _.isObjectLike([1, 2, 3]);
	* // => true
	*
	* _.isObjectLike(_.noop);
	* // => false
	*
	* _.isObjectLike(null);
	* // => false
	*/
	function isObjectLike$1(value) {
		return !!value && typeof value == "object";
	}
	/**
	* Checks if `value` is classified as a `String` primitive or object.
	*
	* @static
	* @memberOf _
	* @category Lang
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
	* @example
	*
	* _.isString('abc');
	* // => true
	*
	* _.isString(1);
	* // => false
	*/
	function isString$1(value) {
		return typeof value == "string" || !isArray(value) && isObjectLike$1(value) && objectToString$1.call(value) == stringTag;
	}
	module.exports = isString$1;
}) });

//#endregion
//#region ../../node_modules/lodash.once/index.js
var require_lodash = /* @__PURE__ */ __commonJS({ "../../node_modules/lodash.once/index.js": ((exports, module) => {
	/**
	* lodash (Custom Build) <https://lodash.com/>
	* Build: `lodash modularize exports="npm" -o ./`
	* Copyright jQuery Foundation and other contributors <https://jquery.org/>
	* Released under MIT license <https://lodash.com/license>
	* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
	* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
	*/
	/** Used as the `TypeError` message for "Functions" methods. */
	var FUNC_ERROR_TEXT = "Expected a function";
	/** Used as references for various `Number` constants. */
	var INFINITY = Infinity, MAX_INTEGER = 17976931348623157e292, NAN = NaN;
	/** `Object#toString` result references. */
	var symbolTag = "[object Symbol]";
	/** Used to match leading and trailing whitespace. */
	var reTrim = /^\s+|\s+$/g;
	/** Used to detect bad signed hexadecimal string values. */
	var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
	/** Used to detect binary string values. */
	var reIsBinary = /^0b[01]+$/i;
	/** Used to detect octal string values. */
	var reIsOctal = /^0o[0-7]+$/i;
	/** Built-in method references without a dependency on `root`. */
	var freeParseInt = parseInt;
	/**
	* Used to resolve the
	* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
	* of values.
	*/
	var objectToString = Object.prototype.toString;
	/**
	* Creates a function that invokes `func`, with the `this` binding and arguments
	* of the created function, while it's called less than `n` times. Subsequent
	* calls to the created function return the result of the last `func` invocation.
	*
	* @static
	* @memberOf _
	* @since 3.0.0
	* @category Function
	* @param {number} n The number of calls at which `func` is no longer invoked.
	* @param {Function} func The function to restrict.
	* @returns {Function} Returns the new restricted function.
	* @example
	*
	* jQuery(element).on('click', _.before(5, addContactToList));
	* // => Allows adding up to 4 contacts to the list.
	*/
	function before(n, func) {
		var result;
		if (typeof func != "function") throw new TypeError(FUNC_ERROR_TEXT);
		n = toInteger(n);
		return function() {
			if (--n > 0) result = func.apply(this, arguments);
			if (n <= 1) func = void 0;
			return result;
		};
	}
	/**
	* Creates a function that is restricted to invoking `func` once. Repeat calls
	* to the function return the value of the first invocation. The `func` is
	* invoked with the `this` binding and arguments of the created function.
	*
	* @static
	* @memberOf _
	* @since 0.1.0
	* @category Function
	* @param {Function} func The function to restrict.
	* @returns {Function} Returns the new restricted function.
	* @example
	*
	* var initialize = _.once(createApplication);
	* initialize();
	* initialize();
	* // => `createApplication` is invoked once
	*/
	function once$1(func) {
		return before(2, func);
	}
	/**
	* Checks if `value` is the
	* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
	* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
	*
	* @static
	* @memberOf _
	* @since 0.1.0
	* @category Lang
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` is an object, else `false`.
	* @example
	*
	* _.isObject({});
	* // => true
	*
	* _.isObject([1, 2, 3]);
	* // => true
	*
	* _.isObject(_.noop);
	* // => true
	*
	* _.isObject(null);
	* // => false
	*/
	function isObject(value) {
		var type = typeof value;
		return !!value && (type == "object" || type == "function");
	}
	/**
	* Checks if `value` is object-like. A value is object-like if it's not `null`
	* and has a `typeof` result of "object".
	*
	* @static
	* @memberOf _
	* @since 4.0.0
	* @category Lang
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
	* @example
	*
	* _.isObjectLike({});
	* // => true
	*
	* _.isObjectLike([1, 2, 3]);
	* // => true
	*
	* _.isObjectLike(_.noop);
	* // => false
	*
	* _.isObjectLike(null);
	* // => false
	*/
	function isObjectLike(value) {
		return !!value && typeof value == "object";
	}
	/**
	* Checks if `value` is classified as a `Symbol` primitive or object.
	*
	* @static
	* @memberOf _
	* @since 4.0.0
	* @category Lang
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
	* @example
	*
	* _.isSymbol(Symbol.iterator);
	* // => true
	*
	* _.isSymbol('abc');
	* // => false
	*/
	function isSymbol(value) {
		return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag;
	}
	/**
	* Converts `value` to a finite number.
	*
	* @static
	* @memberOf _
	* @since 4.12.0
	* @category Lang
	* @param {*} value The value to convert.
	* @returns {number} Returns the converted number.
	* @example
	*
	* _.toFinite(3.2);
	* // => 3.2
	*
	* _.toFinite(Number.MIN_VALUE);
	* // => 5e-324
	*
	* _.toFinite(Infinity);
	* // => 1.7976931348623157e+308
	*
	* _.toFinite('3.2');
	* // => 3.2
	*/
	function toFinite(value) {
		if (!value) return value === 0 ? value : 0;
		value = toNumber(value);
		if (value === INFINITY || value === -INFINITY) return (value < 0 ? -1 : 1) * MAX_INTEGER;
		return value === value ? value : 0;
	}
	/**
	* Converts `value` to an integer.
	*
	* **Note:** This method is loosely based on
	* [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
	*
	* @static
	* @memberOf _
	* @since 4.0.0
	* @category Lang
	* @param {*} value The value to convert.
	* @returns {number} Returns the converted integer.
	* @example
	*
	* _.toInteger(3.2);
	* // => 3
	*
	* _.toInteger(Number.MIN_VALUE);
	* // => 0
	*
	* _.toInteger(Infinity);
	* // => 1.7976931348623157e+308
	*
	* _.toInteger('3.2');
	* // => 3
	*/
	function toInteger(value) {
		var result = toFinite(value), remainder = result % 1;
		return result === result ? remainder ? result - remainder : result : 0;
	}
	/**
	* Converts `value` to a number.
	*
	* @static
	* @memberOf _
	* @since 4.0.0
	* @category Lang
	* @param {*} value The value to process.
	* @returns {number} Returns the number.
	* @example
	*
	* _.toNumber(3.2);
	* // => 3.2
	*
	* _.toNumber(Number.MIN_VALUE);
	* // => 5e-324
	*
	* _.toNumber(Infinity);
	* // => Infinity
	*
	* _.toNumber('3.2');
	* // => 3.2
	*/
	function toNumber(value) {
		if (typeof value == "number") return value;
		if (isSymbol(value)) return NAN;
		if (isObject(value)) {
			var other = typeof value.valueOf == "function" ? value.valueOf() : value;
			value = isObject(other) ? other + "" : other;
		}
		if (typeof value != "string") return value === 0 ? value : +value;
		value = value.replace(reTrim, "");
		var isBinary = reIsBinary.test(value);
		return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
	}
	module.exports = once$1;
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/sign.js
var require_sign = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/sign.js": ((exports, module) => {
	const timespan = require_timespan();
	const PS_SUPPORTED = require_psSupported();
	const validateAsymmetricKey = require_validateAsymmetricKey();
	const jws = require_jws();
	const includes = require_lodash$6();
	const isBoolean = require_lodash$5();
	const isInteger = require_lodash$4();
	const isNumber = require_lodash$3();
	const isPlainObject = require_lodash$2();
	const isString = require_lodash$1();
	const once = require_lodash();
	const { KeyObject, createSecretKey, createPrivateKey: createPrivateKey$1 } = require("crypto");
	const SUPPORTED_ALGS = [
		"RS256",
		"RS384",
		"RS512",
		"ES256",
		"ES384",
		"ES512",
		"HS256",
		"HS384",
		"HS512",
		"none"
	];
	if (PS_SUPPORTED) SUPPORTED_ALGS.splice(3, 0, "PS256", "PS384", "PS512");
	const sign_options_schema = {
		expiresIn: {
			isValid: function(value) {
				return isInteger(value) || isString(value) && value;
			},
			message: "\"expiresIn\" should be a number of seconds or string representing a timespan"
		},
		notBefore: {
			isValid: function(value) {
				return isInteger(value) || isString(value) && value;
			},
			message: "\"notBefore\" should be a number of seconds or string representing a timespan"
		},
		audience: {
			isValid: function(value) {
				return isString(value) || Array.isArray(value);
			},
			message: "\"audience\" must be a string or array"
		},
		algorithm: {
			isValid: includes.bind(null, SUPPORTED_ALGS),
			message: "\"algorithm\" must be a valid string enum value"
		},
		header: {
			isValid: isPlainObject,
			message: "\"header\" must be an object"
		},
		encoding: {
			isValid: isString,
			message: "\"encoding\" must be a string"
		},
		issuer: {
			isValid: isString,
			message: "\"issuer\" must be a string"
		},
		subject: {
			isValid: isString,
			message: "\"subject\" must be a string"
		},
		jwtid: {
			isValid: isString,
			message: "\"jwtid\" must be a string"
		},
		noTimestamp: {
			isValid: isBoolean,
			message: "\"noTimestamp\" must be a boolean"
		},
		keyid: {
			isValid: isString,
			message: "\"keyid\" must be a string"
		},
		mutatePayload: {
			isValid: isBoolean,
			message: "\"mutatePayload\" must be a boolean"
		},
		allowInsecureKeySizes: {
			isValid: isBoolean,
			message: "\"allowInsecureKeySizes\" must be a boolean"
		},
		allowInvalidAsymmetricKeyTypes: {
			isValid: isBoolean,
			message: "\"allowInvalidAsymmetricKeyTypes\" must be a boolean"
		}
	};
	const registered_claims_schema = {
		iat: {
			isValid: isNumber,
			message: "\"iat\" should be a number of seconds"
		},
		exp: {
			isValid: isNumber,
			message: "\"exp\" should be a number of seconds"
		},
		nbf: {
			isValid: isNumber,
			message: "\"nbf\" should be a number of seconds"
		}
	};
	function validate(schema, allowUnknown, object, parameterName) {
		if (!isPlainObject(object)) throw new Error("Expected \"" + parameterName + "\" to be a plain object.");
		Object.keys(object).forEach(function(key) {
			const validator = schema[key];
			if (!validator) {
				if (!allowUnknown) throw new Error("\"" + key + "\" is not allowed in \"" + parameterName + "\"");
				return;
			}
			if (!validator.isValid(object[key])) throw new Error(validator.message);
		});
	}
	function validateOptions(options) {
		return validate(sign_options_schema, false, options, "options");
	}
	function validatePayload(payload) {
		return validate(registered_claims_schema, true, payload, "payload");
	}
	const options_to_payload = {
		"audience": "aud",
		"issuer": "iss",
		"subject": "sub",
		"jwtid": "jti"
	};
	const options_for_objects = [
		"expiresIn",
		"notBefore",
		"noTimestamp",
		"audience",
		"issuer",
		"subject",
		"jwtid"
	];
	module.exports = function(payload, secretOrPrivateKey, options, callback) {
		if (typeof options === "function") {
			callback = options;
			options = {};
		} else options = options || {};
		const isObjectPayload = typeof payload === "object" && !Buffer.isBuffer(payload);
		const header = Object.assign({
			alg: options.algorithm || "HS256",
			typ: isObjectPayload ? "JWT" : void 0,
			kid: options.keyid
		}, options.header);
		function failure(err) {
			if (callback) return callback(err);
			throw err;
		}
		if (!secretOrPrivateKey && options.algorithm !== "none") return failure(/* @__PURE__ */ new Error("secretOrPrivateKey must have a value"));
		if (secretOrPrivateKey != null && !(secretOrPrivateKey instanceof KeyObject)) try {
			secretOrPrivateKey = createPrivateKey$1(secretOrPrivateKey);
		} catch (_) {
			try {
				secretOrPrivateKey = createSecretKey(typeof secretOrPrivateKey === "string" ? Buffer.from(secretOrPrivateKey) : secretOrPrivateKey);
			} catch (_$1) {
				return failure(/* @__PURE__ */ new Error("secretOrPrivateKey is not valid key material"));
			}
		}
		if (header.alg.startsWith("HS") && secretOrPrivateKey.type !== "secret") return failure(/* @__PURE__ */ new Error(`secretOrPrivateKey must be a symmetric key when using ${header.alg}`));
		else if (/^(?:RS|PS|ES)/.test(header.alg)) {
			if (secretOrPrivateKey.type !== "private") return failure(/* @__PURE__ */ new Error(`secretOrPrivateKey must be an asymmetric key when using ${header.alg}`));
			if (!options.allowInsecureKeySizes && !header.alg.startsWith("ES") && secretOrPrivateKey.asymmetricKeyDetails !== void 0 && secretOrPrivateKey.asymmetricKeyDetails.modulusLength < 2048) return failure(/* @__PURE__ */ new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${header.alg}`));
		}
		if (typeof payload === "undefined") return failure(/* @__PURE__ */ new Error("payload is required"));
		else if (isObjectPayload) {
			try {
				validatePayload(payload);
			} catch (error) {
				return failure(error);
			}
			if (!options.mutatePayload) payload = Object.assign({}, payload);
		} else {
			const invalid_options = options_for_objects.filter(function(opt) {
				return typeof options[opt] !== "undefined";
			});
			if (invalid_options.length > 0) return failure(/* @__PURE__ */ new Error("invalid " + invalid_options.join(",") + " option for " + typeof payload + " payload"));
		}
		if (typeof payload.exp !== "undefined" && typeof options.expiresIn !== "undefined") return failure(/* @__PURE__ */ new Error("Bad \"options.expiresIn\" option the payload already has an \"exp\" property."));
		if (typeof payload.nbf !== "undefined" && typeof options.notBefore !== "undefined") return failure(/* @__PURE__ */ new Error("Bad \"options.notBefore\" option the payload already has an \"nbf\" property."));
		try {
			validateOptions(options);
		} catch (error) {
			return failure(error);
		}
		if (!options.allowInvalidAsymmetricKeyTypes) try {
			validateAsymmetricKey(header.alg, secretOrPrivateKey);
		} catch (error) {
			return failure(error);
		}
		const timestamp = payload.iat || Math.floor(Date.now() / 1e3);
		if (options.noTimestamp) delete payload.iat;
		else if (isObjectPayload) payload.iat = timestamp;
		if (typeof options.notBefore !== "undefined") {
			try {
				payload.nbf = timespan(options.notBefore, timestamp);
			} catch (err) {
				return failure(err);
			}
			if (typeof payload.nbf === "undefined") return failure(/* @__PURE__ */ new Error("\"notBefore\" should be a number of seconds or string representing a timespan eg: \"1d\", \"20h\", 60"));
		}
		if (typeof options.expiresIn !== "undefined" && typeof payload === "object") {
			try {
				payload.exp = timespan(options.expiresIn, timestamp);
			} catch (err) {
				return failure(err);
			}
			if (typeof payload.exp === "undefined") return failure(/* @__PURE__ */ new Error("\"expiresIn\" should be a number of seconds or string representing a timespan eg: \"1d\", \"20h\", 60"));
		}
		Object.keys(options_to_payload).forEach(function(key) {
			const claim = options_to_payload[key];
			if (typeof options[key] !== "undefined") {
				if (typeof payload[claim] !== "undefined") return failure(/* @__PURE__ */ new Error("Bad \"options." + key + "\" option. The payload already has an \"" + claim + "\" property."));
				payload[claim] = options[key];
			}
		});
		const encoding = options.encoding || "utf8";
		if (typeof callback === "function") {
			callback = callback && once(callback);
			jws.createSign({
				header,
				privateKey: secretOrPrivateKey,
				payload,
				encoding
			}).once("error", callback).once("done", function(signature) {
				if (!options.allowInsecureKeySizes && /^(?:RS|PS)/.test(header.alg) && signature.length < 256) return callback(/* @__PURE__ */ new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${header.alg}`));
				callback(null, signature);
			});
		} else {
			let signature = jws.sign({
				header,
				payload,
				secret: secretOrPrivateKey,
				encoding
			});
			if (!options.allowInsecureKeySizes && /^(?:RS|PS)/.test(header.alg) && signature.length < 256) throw new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${header.alg}`);
			return signature;
		}
	};
}) });

//#endregion
//#region ../../node_modules/jsonwebtoken/index.js
var require_jsonwebtoken = /* @__PURE__ */ __commonJS({ "../../node_modules/jsonwebtoken/index.js": ((exports, module) => {
	module.exports = {
		decode: require_decode(),
		verify: require_verify(),
		sign: require_sign(),
		JsonWebTokenError: require_JsonWebTokenError(),
		NotBeforeError: require_NotBeforeError(),
		TokenExpiredError: require_TokenExpiredError()
	};
}) });

//#endregion
//#region src/util.ts
var import_jsonwebtoken$1 = /* @__PURE__ */ __toESM(require_jsonwebtoken());
function isTokenExpired(token, tokenName = "access_token") {
	const expiresAt = token.expiresAt ?? jwtExpiresAt(token.response[tokenName]);
	return expiresAt != null && Date.now() > expiresAt;
}
/**
* Get the expiry timestamp (ms) from a JWT's `exp` claim, or null if the token
* is not a JWT or has no `exp`.
*/
function jwtExpiresAt(token) {
	if (!token) return null;
	try {
		const payload = import_jsonwebtoken$1.default.decode(token);
		if (payload != null && typeof payload === "object" && typeof payload.exp === "number") return payload.exp * 1e3;
	} catch {}
	return null;
}
function extractCode(urlStr, redirectUri) {
	const url = new URL(urlStr);
	if (!urlMatchesRedirect(url, redirectUri)) {
		console.log("[oauth2] URL does not match redirect origin/path; skipping.");
		return null;
	}
	const query = url.searchParams;
	const queryError = query.get("error");
	const queryDesc = query.get("error_description");
	const queryUri = query.get("error_uri");
	let hashParams = null;
	if (url.hash && url.hash.length > 1) hashParams = new URLSearchParams(url.hash.slice(1));
	const hashError = hashParams?.get("error");
	const hashDesc = hashParams?.get("error_description");
	const hashUri = hashParams?.get("error_uri");
	const error = queryError || hashError;
	if (error) {
		const desc = queryDesc || hashDesc;
		const uri = queryUri || hashUri;
		let message = `Failed to authorize: ${error}`;
		if (desc) message += ` (${desc})`;
		if (uri) message += ` [${uri}]`;
		throw new Error(message);
	}
	const queryCode = query.get("code");
	if (queryCode) return queryCode;
	const hashCode = hashParams?.get("code");
	if (hashCode) return hashCode;
	console.log("[oauth2] Code not found");
	return null;
}
function urlMatchesRedirect(url, redirectUrl) {
	if (!redirectUrl) return true;
	let redirect;
	try {
		redirect = new URL(redirectUrl);
	} catch {
		console.log("[oauth2] Invalid redirect URI; skipping.");
		return false;
	}
	const sameProtocol = url.protocol === redirect.protocol;
	const sameHost = url.hostname.toLowerCase() === redirect.hostname.toLowerCase();
	const normalizePort = (u) => u.protocol === "https:" && (!u.port || u.port === "443") || u.protocol === "http:" && (!u.port || u.port === "80") ? "" : u.port;
	const samePort = normalizePort(url) === normalizePort(redirect);
	const normPath = (p) => {
		return (p.startsWith("/") ? p : `/${p}`).replace(/\/+$/g, "") || "/";
	};
	const urlPath = normPath(url.pathname);
	const redirectPath = normPath(redirect.pathname);
	const pathMatches = urlPath === redirectPath || urlPath.startsWith(`${redirectPath}/`);
	return sameProtocol && sameHost && samePort && pathMatches;
}

//#endregion
//#region src/store.ts
async function storeToken(ctx, args, response, tokenName = "access_token") {
	if (!response[tokenName]) throw new Error(`${tokenName} not found in response ${Object.keys(response).join(", ")}`);
	const token = {
		response,
		expiresAt: response.expires_in ? Date.now() + response.expires_in * 1e3 : jwtExpiresAt(response[tokenName])
	};
	await ctx.store.set(tokenStoreKey(args), token);
	return token;
}
async function getToken(ctx, args) {
	return ctx.store.get(tokenStoreKey(args));
}
async function deleteToken(ctx, args) {
	return ctx.store.delete(tokenStoreKey(args));
}
async function resetDataDirKey(ctx, contextId) {
	const key = (/* @__PURE__ */ new Date()).toISOString();
	return ctx.store.set(dataDirStoreKey(contextId), key);
}
async function getDataDirKey(ctx, contextId) {
	return `${contextId}::${await ctx.store.get(dataDirStoreKey(contextId)) ?? "default"}`;
}
/**
* Generate a store key to use based on some arguments. The arguments will be normalized a bit to
* account for slight variations (like domains with and without a protocol scheme).
*/
function tokenStoreKey(args) {
	const hash = (0, node_crypto.createHash)("md5");
	if (args.contextId) hash.update(args.contextId.trim());
	if (args.clientId) hash.update(args.clientId.trim());
	if (args.accessTokenUrl) hash.update(args.accessTokenUrl.trim().replace(/^https?:\/\//, ""));
	if (args.authorizationUrl) hash.update(args.authorizationUrl.trim().replace(/^https?:\/\//, ""));
	return ["token", hash.digest("hex")].join("::");
}
function dataDirStoreKey(contextId) {
	return ["data_dir", contextId].join("::");
}

//#endregion
//#region src/getOrRefreshAccessToken.ts
async function getOrRefreshAccessToken(ctx, tokenArgs, { scope, accessTokenUrl, credentialsInBody, clientId, clientSecret, tokenName, forceRefresh }) {
	const token = await getToken(ctx, tokenArgs);
	if (token == null) return null;
	if (!isTokenExpired(token, tokenName) && !forceRefresh) return token;
	if (!token.response.refresh_token) return null;
	const httpRequest = {
		method: "POST",
		url: accessTokenUrl,
		bodyType: "application/x-www-form-urlencoded",
		body: { form: [{
			name: "grant_type",
			value: "refresh_token"
		}, {
			name: "refresh_token",
			value: token.response.refresh_token
		}] },
		headers: [
			{
				name: "User-Agent",
				value: "yaak"
			},
			{
				name: "Accept",
				value: "application/x-www-form-urlencoded, application/json"
			},
			{
				name: "Content-Type",
				value: "application/x-www-form-urlencoded"
			}
		]
	};
	if (scope) httpRequest.body?.form.push({
		name: "scope",
		value: scope
	});
	if (credentialsInBody) {
		httpRequest.body?.form.push({
			name: "client_id",
			value: clientId
		});
		httpRequest.body?.form.push({
			name: "client_secret",
			value: clientSecret
		});
	} else {
		const value = `Basic ${Buffer.from(`${clientId}:${clientSecret}`).toString("base64")}`;
		httpRequest.headers?.push({
			name: "Authorization",
			value
		});
	}
	httpRequest.authenticationType = "none";
	const resp = await ctx.httpRequest.send({ httpRequest });
	if (resp.error) throw new Error(`Failed to refresh access token: ${resp.error}`);
	if (resp.status >= 400 && resp.status < 500) {
		console.log("[oauth2] Refresh token request failed with client error, deleting token");
		await deleteToken(ctx, tokenArgs);
		return null;
	}
	const body = resp.bodyPath ? (0, node_fs.readFileSync)(resp.bodyPath, "utf8") : "";
	console.log("[oauth2] Got refresh token response", resp.status);
	if (resp.status < 200 || resp.status >= 300) throw new Error(`Failed to refresh access token with status=${resp.status} and body=${body}`);
	let response;
	try {
		response = JSON.parse(body);
	} catch {
		response = Object.fromEntries(new URLSearchParams(body));
	}
	if (response.error) throw new Error(`Failed to fetch access token with ${response.error} -> ${response.error_description}`);
	return storeToken(ctx, tokenArgs, {
		...response,
		refresh_token: response.refresh_token ?? token.response.refresh_token
	}, tokenName);
}

//#endregion
//#region src/grants/authorizationCode.ts
const PKCE_SHA256 = "S256";
const PKCE_PLAIN = "plain";
const DEFAULT_PKCE_METHOD = PKCE_SHA256;
async function getAuthorizationCode(ctx, contextId, { authorizationUrl: authorizationUrlRaw, accessTokenUrl, clientId, clientSecret, redirectUri, scope, state, audience, credentialsInBody, pkce, tokenName, externalBrowser }) {
	const tokenArgs = {
		contextId,
		clientId,
		accessTokenUrl,
		authorizationUrl: authorizationUrlRaw
	};
	const token = await getOrRefreshAccessToken(ctx, tokenArgs, {
		accessTokenUrl,
		scope,
		clientId,
		clientSecret,
		credentialsInBody,
		tokenName
	});
	if (token != null) return token;
	let authorizationUrl;
	try {
		authorizationUrl = new URL(`${authorizationUrlRaw ?? ""}`);
	} catch {
		throw new Error(`Invalid authorization URL "${authorizationUrlRaw}"`);
	}
	authorizationUrl.searchParams.set("response_type", "code");
	authorizationUrl.searchParams.set("client_id", clientId);
	if (scope) authorizationUrl.searchParams.set("scope", scope);
	if (state) authorizationUrl.searchParams.set("state", state);
	if (audience) authorizationUrl.searchParams.set("audience", audience);
	if (pkce) {
		authorizationUrl.searchParams.set("code_challenge", pkceCodeChallenge(pkce.codeVerifier, pkce.challengeMethod));
		authorizationUrl.searchParams.set("code_challenge_method", pkce.challengeMethod);
	}
	let code;
	let actualRedirectUri = redirectUri;
	if (externalBrowser?.useExternalBrowser) {
		const result = await getRedirectUrlViaExternalBrowser(ctx, authorizationUrl, {
			callbackType: externalBrowser.callbackType,
			callbackPort: externalBrowser.callbackPort
		});
		const extractedCode = extractCode(result.callbackUrl, null);
		if (!extractedCode) throw new Error("No authorization code found in callback URL");
		code = extractedCode;
		actualRedirectUri = result.redirectUri;
	} else {
		if (redirectUri) authorizationUrl.searchParams.set("redirect_uri", redirectUri);
		code = await getCodeViaEmbeddedBrowser(ctx, contextId, authorizationUrl, redirectUri);
	}
	console.log("[oauth2] Code found");
	return storeToken(ctx, tokenArgs, await fetchAccessToken(ctx, {
		grantType: "authorization_code",
		accessTokenUrl,
		clientId,
		clientSecret,
		scope,
		audience,
		credentialsInBody,
		params: [
			{
				name: "code",
				value: code
			},
			...pkce ? [{
				name: "code_verifier",
				value: pkce.codeVerifier
			}] : [],
			...actualRedirectUri ? [{
				name: "redirect_uri",
				value: actualRedirectUri
			}] : []
		]
	}), tokenName);
}
/**
* Get authorization code using the embedded browser window.
* This is the original flow that monitors navigation events.
*/
async function getCodeViaEmbeddedBrowser(ctx, contextId, authorizationUrl, redirectUri) {
	const dataDirKey = await getDataDirKey(ctx, contextId);
	const authorizationUrlStr = authorizationUrl.toString();
	console.log("[oauth2] Authorizing via embedded browser", authorizationUrlStr);
	return new Promise(async (resolve, reject) => {
		let foundCode = false;
		const { close } = await ctx.window.openUrl({
			dataDirKey,
			url: authorizationUrlStr,
			label: "oauth-authorization-url",
			async onClose() {
				if (!foundCode) reject(/* @__PURE__ */ new Error("Authorization window closed"));
			},
			async onNavigate({ url: urlStr }) {
				let code;
				try {
					code = extractCode(urlStr, redirectUri);
				} catch (err) {
					reject(err);
					close();
					return;
				}
				if (!code) return;
				foundCode = true;
				close();
				resolve(code);
			}
		});
	});
}
function genPkceCodeVerifier() {
	return encodeForPkce((0, node_crypto.randomBytes)(32));
}
function pkceCodeChallenge(verifier, method) {
	if (method === "plain") return verifier;
	return encodeForPkce((0, node_crypto.createHash)("sha256").update(verifier).digest()).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
}
function encodeForPkce(bytes) {
	return bytes.toString("base64").replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
}

//#endregion
//#region src/grants/clientCredentials.ts
var import_jsonwebtoken = /* @__PURE__ */ __toESM(require_jsonwebtoken());
const jwtAlgorithms = [
	"HS256",
	"HS384",
	"HS512",
	"RS256",
	"RS384",
	"RS512",
	"PS256",
	"PS384",
	"PS512",
	"ES256",
	"ES384",
	"ES512",
	"none"
];
const defaultJwtAlgorithm = jwtAlgorithms[0];
/**
* Build a signed JWT for the client_assertion parameter (RFC 7523).
*
* The `secret` value is auto-detected as one of:
*   - **JWK** – a JSON string containing a private-key object (has a `kty` field).
*   - **PEM** – a string whose trimmed form starts with `-----`.
*   - **HMAC secret** – anything else, used as-is for HS* algorithms.
*/
function buildClientAssertionJwt(params) {
	const { clientId, accessTokenUrl, secret, algorithm } = params;
	const isHmac = algorithm.startsWith("HS") || algorithm === "none";
	let signingKey;
	let kid;
	const trimmed = secret.trim();
	if (isHmac) signingKey = secret;
	else if (trimmed.startsWith("{")) {
		let jwk;
		try {
			jwk = JSON.parse(trimmed);
		} catch {
			throw new Error("Client Assertion secret looks like JSON but is not valid");
		}
		kid = jwk?.kid;
		signingKey = (0, node_crypto.createPrivateKey)({
			key: jwk,
			format: "jwk"
		});
	} else if (trimmed.startsWith("-----")) signingKey = (0, node_crypto.createPrivateKey)({
		key: trimmed,
		format: "pem"
	});
	else throw new Error("Client Assertion secret must be a JWK JSON object, a PEM-encoded key (starting with -----), or a raw secret for HMAC algorithms.");
	const now = Math.floor(Date.now() / 1e3);
	const payload = {
		iss: clientId,
		sub: clientId,
		aud: accessTokenUrl,
		iat: now,
		exp: now + 300,
		jti: (0, node_crypto.randomUUID)()
	};
	const header = {
		alg: algorithm,
		typ: "JWT"
	};
	if (kid) header.kid = kid;
	return import_jsonwebtoken.default.sign(JSON.stringify(payload), signingKey, {
		algorithm,
		header
	});
}
async function getClientCredentials(ctx, contextId, { accessTokenUrl, clientId, clientSecret, scope, audience, credentialsInBody, clientAssertionSecret, clientAssertionSecretBase64, clientCredentialsMethod, clientAssertionAlgorithm }) {
	const tokenArgs = {
		contextId,
		clientId,
		accessTokenUrl,
		authorizationUrl: null
	};
	const token = await getToken(ctx, tokenArgs);
	if (token && !isTokenExpired(token)) return token;
	const common = {
		grantType: "client_credentials",
		accessTokenUrl,
		audience,
		clientId,
		scope,
		params: []
	};
	return storeToken(ctx, tokenArgs, await fetchAccessToken(ctx, clientCredentialsMethod === "client_assertion" ? {
		...common,
		clientAssertion: buildClientAssertionJwt({
			clientId,
			algorithm: clientAssertionAlgorithm,
			accessTokenUrl,
			secret: clientAssertionSecretBase64 ? Buffer.from(clientAssertionSecret, "base64").toString("utf-8") : clientAssertionSecret
		})
	} : {
		...common,
		clientSecret,
		credentialsInBody
	}));
}

//#endregion
//#region src/grants/implicit.ts
async function getImplicit(ctx, contextId, { authorizationUrl: authorizationUrlRaw, responseType, clientId, redirectUri, scope, state, audience, tokenName, externalBrowser }) {
	const tokenArgs = {
		contextId,
		clientId,
		accessTokenUrl: null,
		authorizationUrl: authorizationUrlRaw
	};
	const token = await getToken(ctx, tokenArgs);
	if (token != null && !isTokenExpired(token, tokenName)) return token;
	let authorizationUrl;
	try {
		authorizationUrl = new URL(`${authorizationUrlRaw ?? ""}`);
	} catch {
		throw new Error(`Invalid authorization URL "${authorizationUrlRaw}"`);
	}
	authorizationUrl.searchParams.set("response_type", responseType);
	authorizationUrl.searchParams.set("client_id", clientId);
	if (scope) authorizationUrl.searchParams.set("scope", scope);
	if (state) authorizationUrl.searchParams.set("state", state);
	if (audience) authorizationUrl.searchParams.set("audience", audience);
	if (responseType.includes("id_token")) authorizationUrl.searchParams.set("nonce", String(Math.floor(Math.random() * 9999999999999) + 1));
	let newToken;
	if (externalBrowser?.useExternalBrowser) newToken = await extractImplicitToken(ctx, (await getRedirectUrlViaExternalBrowser(ctx, authorizationUrl, {
		callbackType: externalBrowser.callbackType,
		callbackPort: externalBrowser.callbackPort
	})).callbackUrl, tokenArgs, tokenName);
	else {
		if (redirectUri) authorizationUrl.searchParams.set("redirect_uri", redirectUri);
		newToken = await getTokenViaEmbeddedBrowser(ctx, contextId, authorizationUrl, tokenArgs, tokenName);
	}
	return newToken;
}
/**
* Get token using the embedded browser window.
* This is the original flow that monitors navigation events.
*/
async function getTokenViaEmbeddedBrowser(ctx, contextId, authorizationUrl, tokenArgs, tokenName) {
	const dataDirKey = await getDataDirKey(ctx, contextId);
	const authorizationUrlStr = authorizationUrl.toString();
	console.log("[oauth2] Authorizing via embedded browser (implicit)", authorizationUrlStr);
	return new Promise(async (resolve, reject) => {
		let foundAccessToken = false;
		const { close } = await ctx.window.openUrl({
			dataDirKey,
			url: authorizationUrlStr,
			label: "oauth-authorization-url",
			async onClose() {
				if (!foundAccessToken) reject(/* @__PURE__ */ new Error("Authorization window closed"));
			},
			async onNavigate({ url: urlStr }) {
				const url = new URL(urlStr);
				if (url.searchParams.has("error")) return reject(Error(`Failed to authorize: ${url.searchParams.get("error")}`));
				const hash = url.hash.slice(1);
				const params = new URLSearchParams(hash);
				if (!params.get(tokenName)) return;
				foundAccessToken = true;
				close();
				const response = Object.fromEntries(params);
				try {
					resolve(storeToken(ctx, tokenArgs, response, tokenName));
				} catch (err) {
					reject(err);
				}
			}
		});
	});
}
/**
* Extract the implicit grant token from a callback URL and store it.
*/
async function extractImplicitToken(ctx, callbackUrl, tokenArgs, tokenName) {
	const url = new URL(callbackUrl);
	if (url.searchParams.has("error")) throw new Error(`Failed to authorize: ${url.searchParams.get("error")}`);
	const hash = url.hash.slice(1);
	const params = new URLSearchParams(hash);
	if (!(params.get(tokenName) ?? url.searchParams.get(tokenName))) throw new Error(`No ${tokenName} found in callback URL`);
	const response = {
		access_token: params.get("access_token") ?? url.searchParams.get("access_token") ?? "",
		token_type: params.get("token_type") ?? url.searchParams.get("token_type") ?? void 0,
		expires_in: params.has("expires_in") ? parseInt(params.get("expires_in") ?? "0", 10) : url.searchParams.has("expires_in") ? parseInt(url.searchParams.get("expires_in") ?? "0", 10) : void 0,
		scope: params.get("scope") ?? url.searchParams.get("scope") ?? void 0
	};
	const idToken = params.get("id_token") ?? url.searchParams.get("id_token");
	if (idToken) response.id_token = idToken;
	return storeToken(ctx, tokenArgs, response, tokenName);
}

//#endregion
//#region src/grants/password.ts
async function getPassword(ctx, contextId, { accessTokenUrl, clientId, clientSecret, username, password, credentialsInBody, audience, scope }) {
	const tokenArgs = {
		contextId,
		clientId,
		accessTokenUrl,
		authorizationUrl: null
	};
	const token = await getOrRefreshAccessToken(ctx, tokenArgs, {
		accessTokenUrl,
		scope,
		clientId,
		clientSecret,
		credentialsInBody
	});
	if (token != null) return token;
	return storeToken(ctx, tokenArgs, await fetchAccessToken(ctx, {
		accessTokenUrl,
		clientId,
		clientSecret,
		scope,
		audience,
		grantType: "password",
		credentialsInBody,
		params: [{
			name: "username",
			value: username
		}, {
			name: "password",
			value: password
		}]
	}));
}

//#endregion
//#region src/index.ts
const grantTypes = [
	{
		label: "Authorization Code",
		value: "authorization_code"
	},
	{
		label: "Implicit",
		value: "implicit"
	},
	{
		label: "Resource Owner Password Credential",
		value: "password"
	},
	{
		label: "Client Credentials",
		value: "client_credentials"
	}
];
const defaultGrantType = grantTypes[0]?.value;
function hiddenIfNot(grantTypes$1, ...other) {
	return (_ctx, { values: values$1 }) => {
		const hasGrantType = grantTypes$1.find((t$5) => t$5 === String(values$1.grantType ?? defaultGrantType));
		const hasOtherBools = other.every((t$5) => t$5(values$1));
		return { hidden: !(hasGrantType && hasOtherBools) };
	};
}
const authorizationUrls = [
	"https://github.com/login/oauth/authorize",
	"https://account.box.com/api/oauth2/authorize",
	"https://accounts.google.com/o/oauth2/v2/auth",
	"https://api.imgur.com/oauth2/authorize",
	"https://bitly.com/oauth/authorize",
	"https://gitlab.example.com/oauth/authorize",
	"https://medium.com/m/oauth/authorize",
	"https://public-api.wordpress.com/oauth2/authorize",
	"https://slack.com/oauth/authorize",
	"https://todoist.com/oauth/authorize",
	"https://www.dropbox.com/oauth2/authorize",
	"https://www.linkedin.com/oauth/v2/authorization",
	"https://MY_SHOP.myshopify.com/admin/oauth/access_token",
	"https://appcenter.intuit.com/app/connect/oauth2/authorize"
];
const accessTokenUrls = [
	"https://github.com/login/oauth/access_token",
	"https://api-ssl.bitly.com/oauth/access_token",
	"https://api.box.com/oauth2/token",
	"https://api.dropboxapi.com/oauth2/token",
	"https://api.imgur.com/oauth2/token",
	"https://api.medium.com/v1/tokens",
	"https://gitlab.example.com/oauth/token",
	"https://public-api.wordpress.com/oauth2/token",
	"https://slack.com/api/oauth.access",
	"https://todoist.com/oauth/access_token",
	"https://www.googleapis.com/oauth2/v4/token",
	"https://www.linkedin.com/oauth/v2/accessToken",
	"https://MY_SHOP.myshopify.com/admin/oauth/authorize",
	"https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer"
];
const plugin = {
	dispose() {
		stopActiveServer();
	},
	authentication: {
		name: "oauth2",
		label: "OAuth 2.0",
		shortLabel: "OAuth 2",
		actions: [
			{
				label: "Copy Current Token",
				async onSelect(ctx, { contextId, values: values$1 }) {
					const token = await getToken(ctx, {
						contextId,
						authorizationUrl: stringArg(values$1, "authorizationUrl"),
						accessTokenUrl: stringArg(values$1, "accessTokenUrl"),
						clientId: stringArg(values$1, "clientId")
					});
					if (token == null) await ctx.toast.show({
						message: "No token to copy",
						color: "warning"
					});
					else {
						await ctx.clipboard.copyText(token.response.access_token);
						await ctx.toast.show({
							message: "Token copied to clipboard",
							icon: "copy",
							color: "success"
						});
					}
				}
			},
			{
				label: "Delete Token",
				async onSelect(ctx, { contextId, values: values$1 }) {
					if (await deleteToken(ctx, {
						contextId,
						authorizationUrl: stringArg(values$1, "authorizationUrl"),
						accessTokenUrl: stringArg(values$1, "accessTokenUrl"),
						clientId: stringArg(values$1, "clientId")
					})) await ctx.toast.show({
						message: "Token deleted",
						color: "success"
					});
					else await ctx.toast.show({
						message: "No token to delete",
						color: "warning"
					});
				}
			},
			{
				label: "Clear Window Session",
				async onSelect(ctx, { contextId }) {
					await resetDataDirKey(ctx, contextId);
				}
			}
		],
		args: [
			{
				type: "select",
				name: "grantType",
				label: "Grant Type",
				defaultValue: defaultGrantType,
				options: grantTypes
			},
			{
				type: "select",
				name: "clientCredentialsMethod",
				label: "Authentication Method",
				description: "\"Client Secret\" sends client_secret. \n\"Client Assertion\" sends a signed JWT.",
				defaultValue: "client_secret",
				options: [{
					label: "Client Secret",
					value: "client_secret"
				}, {
					label: "Client Assertion",
					value: "client_assertion"
				}],
				dynamic: hiddenIfNot(["client_credentials"])
			},
			{
				type: "text",
				name: "clientId",
				label: "Client ID",
				optional: true
			},
			{
				type: "text",
				name: "clientSecret",
				label: "Client Secret",
				optional: true,
				password: true,
				dynamic: hiddenIfNot([
					"authorization_code",
					"password",
					"client_credentials"
				], (values$1) => values$1.clientCredentialsMethod === "client_secret")
			},
			{
				type: "select",
				name: "clientAssertionAlgorithm",
				label: "JWT Algorithm",
				defaultValue: defaultJwtAlgorithm,
				options: jwtAlgorithms.map((value) => ({
					label: value === "none" ? "None" : value,
					value
				})),
				dynamic: hiddenIfNot(["client_credentials"], ({ clientCredentialsMethod }) => clientCredentialsMethod === "client_assertion")
			},
			{
				type: "text",
				name: "clientAssertionSecret",
				label: "JWT Secret",
				description: "Can be HMAC, PEM or JWK. Make sure you pick the correct algorithm type above.",
				password: true,
				optional: true,
				multiLine: true,
				dynamic: hiddenIfNot(["client_credentials"], ({ clientCredentialsMethod }) => clientCredentialsMethod === "client_assertion")
			},
			{
				type: "checkbox",
				name: "clientAssertionSecretBase64",
				label: "JWT secret is base64 encoded",
				dynamic: hiddenIfNot(["client_credentials"], ({ clientCredentialsMethod }) => clientCredentialsMethod === "client_assertion")
			},
			{
				type: "text",
				name: "authorizationUrl",
				optional: true,
				label: "Authorization URL",
				dynamic: hiddenIfNot(["authorization_code", "implicit"]),
				placeholder: authorizationUrls[0],
				completionOptions: authorizationUrls.map((url) => ({
					label: url,
					value: url
				}))
			},
			{
				type: "text",
				name: "accessTokenUrl",
				optional: true,
				label: "Access Token URL",
				placeholder: accessTokenUrls[0],
				dynamic: hiddenIfNot([
					"authorization_code",
					"password",
					"client_credentials"
				]),
				completionOptions: accessTokenUrls.map((url) => ({
					label: url,
					value: url
				}))
			},
			{
				type: "banner",
				inputs: [
					{
						type: "checkbox",
						name: "useExternalBrowser",
						label: "Use External Browser",
						description: "Open authorization URL in your system browser instead of the embedded browser. Useful when the OAuth provider blocks embedded browsers or you need existing browser sessions.",
						dynamic: hiddenIfNot(["authorization_code", "implicit"])
					},
					{
						type: "text",
						name: "redirectUri",
						label: "Redirect URI (can be any valid URL)",
						placeholder: "https://mysite.example.com/oauth/callback",
						description: "URI the OAuth provider redirects to after authorization. Yaak intercepts this automatically in its embedded browser so any valid URI will work.",
						optional: true,
						dynamic: hiddenIfNot(["authorization_code", "implicit"], ({ useExternalBrowser }) => !useExternalBrowser)
					},
					{
						type: "h_stack",
						inputs: [{
							type: "select",
							name: "callbackType",
							label: "Callback Type",
							description: "\"Hosted Redirect\" uses an external Yaak-hosted endpoint. \"Localhost\" starts a local server to receive the callback.",
							defaultValue: "hosted",
							options: [{
								label: "Hosted Redirect",
								value: "hosted"
							}, {
								label: "Localhost",
								value: "localhost"
							}],
							dynamic: hiddenIfNot(["authorization_code", "implicit"], ({ useExternalBrowser }) => !!useExternalBrowser)
						}, {
							type: "text",
							name: "callbackPort",
							label: "Callback Port",
							placeholder: `${DEFAULT_LOCALHOST_PORT}`,
							description: "Port for the local callback server. Defaults to " + DEFAULT_LOCALHOST_PORT + " if empty.",
							optional: true,
							dynamic: hiddenIfNot(["authorization_code", "implicit"], ({ useExternalBrowser }) => !!useExternalBrowser)
						}]
					},
					{
						type: "banner",
						color: "info",
						inputs: [{
							type: "markdown",
							content: "Redirect URI to Register",
							async dynamic(_ctx, { values: values$1 }) {
								const grantType = String(values$1.grantType ?? defaultGrantType);
								const useExternalBrowser = !!values$1.useExternalBrowser;
								const callbackType = stringArg(values$1, "callbackType") || "localhost";
								if (!["authorization_code", "implicit"].includes(grantType) || !useExternalBrowser) return { hidden: true };
								const port = intArg(values$1, "callbackPort") || DEFAULT_LOCALHOST_PORT;
								let redirectUri;
								if (callbackType === "hosted") redirectUri = buildHostedCallbackRedirectUri(port);
								else redirectUri = `http://127.0.0.1:${port}/callback`;
								return {
									hidden: false,
									content: `Register \`${redirectUri}\` as a redirect URI with your OAuth provider.`
								};
							}
						}]
					}
				]
			},
			{
				type: "text",
				name: "state",
				label: "State",
				optional: true,
				dynamic: hiddenIfNot(["authorization_code", "implicit"])
			},
			{
				type: "text",
				name: "scope",
				label: "Scope",
				optional: true
			},
			{
				type: "text",
				name: "audience",
				label: "Audience",
				optional: true
			},
			{
				type: "select",
				name: "tokenName",
				label: "Token for authorization",
				description: "Select which token to send in the \"Authorization: Bearer\" header. Most APIs expect access_token, but some (like OpenID Connect) require id_token.",
				defaultValue: "access_token",
				options: [{
					label: "access_token",
					value: "access_token"
				}, {
					label: "id_token",
					value: "id_token"
				}],
				dynamic: hiddenIfNot(["authorization_code", "implicit"])
			},
			{
				type: "banner",
				inputs: [
					{
						type: "checkbox",
						name: "usePkce",
						label: "Use PKCE",
						dynamic: hiddenIfNot(["authorization_code"])
					},
					{
						type: "select",
						name: "pkceChallengeMethod",
						label: "Code Challenge Method",
						options: [{
							label: "SHA-256",
							value: PKCE_SHA256
						}, {
							label: "Plain",
							value: PKCE_PLAIN
						}],
						defaultValue: DEFAULT_PKCE_METHOD,
						dynamic: hiddenIfNot(["authorization_code"], ({ usePkce }) => !!usePkce)
					},
					{
						type: "text",
						name: "pkceCodeChallenge",
						label: "Code Verifier",
						placeholder: "Automatically generated when not set",
						optional: true,
						dynamic: hiddenIfNot(["authorization_code"], ({ usePkce }) => !!usePkce)
					}
				]
			},
			{
				type: "h_stack",
				inputs: [{
					type: "text",
					name: "username",
					label: "Username",
					optional: true,
					dynamic: hiddenIfNot(["password"])
				}, {
					type: "text",
					name: "password",
					label: "Password",
					password: true,
					optional: true,
					dynamic: hiddenIfNot(["password"])
				}]
			},
			{
				type: "select",
				name: "responseType",
				label: "Response Type",
				defaultValue: "token",
				options: [
					{
						label: "Access Token",
						value: "token"
					},
					{
						label: "ID Token",
						value: "id_token"
					},
					{
						label: "ID and Access Token",
						value: "id_token token"
					}
				],
				dynamic: hiddenIfNot(["implicit"])
			},
			{
				type: "accordion",
				label: "Advanced",
				inputs: [
					{
						type: "text",
						name: "headerName",
						label: "Header Name",
						defaultValue: "Authorization"
					},
					{
						type: "text",
						name: "headerPrefix",
						label: "Header Prefix",
						optional: true,
						defaultValue: "Bearer"
					},
					{
						type: "select",
						name: "credentials",
						label: "Send Credentials",
						defaultValue: "body",
						options: [{
							label: "In Request Body",
							value: "body"
						}, {
							label: "As Basic Authentication",
							value: "basic"
						}],
						dynamic: (_ctx, { values: values$1 }) => ({ hidden: values$1.grantType === "client_credentials" && values$1.clientCredentialsMethod === "client_assertion" })
					}
				]
			},
			{
				type: "accordion",
				label: "Access Token Response",
				inputs: [],
				async dynamic(ctx, { contextId, values: values$1 }) {
					const token = await getToken(ctx, {
						contextId,
						authorizationUrl: stringArg(values$1, "authorizationUrl"),
						accessTokenUrl: stringArg(values$1, "accessTokenUrl"),
						clientId: stringArg(values$1, "clientId")
					});
					if (token == null) return { hidden: true };
					return {
						label: "Access Token Response",
						inputs: [{
							type: "editor",
							name: "response",
							defaultValue: JSON.stringify(token.response, null, 2),
							hideLabel: true,
							readOnly: true,
							language: "json"
						}]
					};
				}
			}
		],
		async onApply(ctx, { values: values$1, contextId }) {
			const headerPrefix = stringArg(values$1, "headerPrefix");
			const grantType = stringArg(values$1, "grantType");
			const credentialsInBody = values$1.credentials === "body";
			const tokenName = values$1.tokenName === "id_token" ? "id_token" : "access_token";
			const externalBrowserOptions = !!values$1.useExternalBrowser ? {
				useExternalBrowser: true,
				callbackType: stringArg(values$1, "callbackType") || "localhost",
				callbackPort: intArg(values$1, "callbackPort") ?? void 0
			} : void 0;
			let token;
			if (grantType === "authorization_code") {
				const authorizationUrl = stringArg(values$1, "authorizationUrl");
				const accessTokenUrl = stringArg(values$1, "accessTokenUrl");
				token = await getAuthorizationCode(ctx, contextId, {
					accessTokenUrl: accessTokenUrl === "" || accessTokenUrl.match(/^https?:\/\//) ? accessTokenUrl : `https://${accessTokenUrl}`,
					authorizationUrl: authorizationUrl === "" || authorizationUrl.match(/^https?:\/\//) ? authorizationUrl : `https://${authorizationUrl}`,
					clientId: stringArg(values$1, "clientId"),
					clientSecret: stringArg(values$1, "clientSecret"),
					redirectUri: stringArgOrNull(values$1, "redirectUri"),
					scope: stringArgOrNull(values$1, "scope"),
					audience: stringArgOrNull(values$1, "audience"),
					state: stringArgOrNull(values$1, "state"),
					credentialsInBody,
					pkce: values$1.usePkce ? {
						challengeMethod: stringArg(values$1, "pkceChallengeMethod") || DEFAULT_PKCE_METHOD,
						codeVerifier: stringArg(values$1, "pkceCodeVerifier") || genPkceCodeVerifier()
					} : null,
					tokenName,
					externalBrowser: externalBrowserOptions
				});
			} else if (grantType === "implicit") {
				const authorizationUrl = stringArg(values$1, "authorizationUrl");
				token = await getImplicit(ctx, contextId, {
					authorizationUrl: authorizationUrl.match(/^https?:\/\//) ? authorizationUrl : `https://${authorizationUrl}`,
					clientId: stringArg(values$1, "clientId"),
					redirectUri: stringArgOrNull(values$1, "redirectUri"),
					responseType: stringArg(values$1, "responseType"),
					scope: stringArgOrNull(values$1, "scope"),
					audience: stringArgOrNull(values$1, "audience"),
					state: stringArgOrNull(values$1, "state"),
					tokenName,
					externalBrowser: externalBrowserOptions
				});
			} else if (grantType === "client_credentials") {
				const accessTokenUrl = stringArg(values$1, "accessTokenUrl");
				token = await getClientCredentials(ctx, contextId, {
					accessTokenUrl: accessTokenUrl.match(/^https?:\/\//) ? accessTokenUrl : `https://${accessTokenUrl}`,
					clientId: stringArg(values$1, "clientId"),
					clientAssertionAlgorithm: stringArg(values$1, "clientAssertionAlgorithm"),
					clientSecret: stringArg(values$1, "clientSecret"),
					clientCredentialsMethod: stringArg(values$1, "clientCredentialsMethod"),
					clientAssertionSecret: stringArg(values$1, "clientAssertionSecret"),
					clientAssertionSecretBase64: !!values$1.clientAssertionSecretBase64,
					scope: stringArgOrNull(values$1, "scope"),
					audience: stringArgOrNull(values$1, "audience"),
					credentialsInBody
				});
			} else if (grantType === "password") {
				const accessTokenUrl = stringArg(values$1, "accessTokenUrl");
				token = await getPassword(ctx, contextId, {
					accessTokenUrl: accessTokenUrl.match(/^https?:\/\//) ? accessTokenUrl : `https://${accessTokenUrl}`,
					clientId: stringArg(values$1, "clientId"),
					clientSecret: stringArg(values$1, "clientSecret"),
					username: stringArg(values$1, "username"),
					password: stringArg(values$1, "password"),
					scope: stringArgOrNull(values$1, "scope"),
					audience: stringArgOrNull(values$1, "audience"),
					credentialsInBody
				});
			} else throw new Error(`Invalid grant type ${String(grantType)}`);
			return { setHeaders: [{
				name: stringArg(values$1, "headerName") || "Authorization",
				value: `${headerPrefix} ${token.response[tokenName] ?? ""}`.trim()
			}] };
		}
	}
};
function stringArgOrNull(values$1, name) {
	const arg = values$1[name];
	if (arg == null || arg === "") return null;
	return `${arg}`;
}
function stringArg(values$1, name) {
	const arg = stringArgOrNull(values$1, name);
	if (!arg) return "";
	return arg;
}
function intArg(values$1, name) {
	const arg = values$1[name];
	if (arg == null || arg === "") return null;
	const num = parseInt(`${arg}`, 10);
	return Number.isNaN(num) ? null : num;
}

//#endregion
exports.plugin = plugin;