diff --git a/dist/index.cjs b/dist/index.cjs index 96eaf40..ff90890 100644 --- a/dist/index.cjs +++ b/dist/index.cjs @@ -15,11 +15,11 @@ var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; -var __copyProps = (to, from3, except, desc) => { - if (from3 && typeof from3 === "object" || typeof from3 === "function") { - for (let key of __getOwnPropNames(from3)) +var __copyProps = (to, from2, except, desc) => { + if (from2 && typeof from2 === "object" || typeof from2 === "function") { + for (let key of __getOwnPropNames(from2)) if (!__hasOwnProp.call(to, key) && key !== except) - __defProp(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc(from3, key)) || desc.enumerable }); + __defProp(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc(from2, key)) || desc.enumerable }); } return to; }; @@ -5985,7 +5985,7 @@ var require_request = __commonJS({ upgrade, headersTimeout, bodyTimeout, - reset: reset3, + reset: reset2, throwOnError, expectContinue }, handler) { @@ -6010,7 +6010,7 @@ var require_request = __commonJS({ if (bodyTimeout != null && (!Number.isFinite(bodyTimeout) || bodyTimeout < 0)) { throw new InvalidArgumentError("invalid bodyTimeout"); } - if (reset3 != null && typeof reset3 !== "boolean") { + if (reset2 != null && typeof reset2 !== "boolean") { throw new InvalidArgumentError("invalid reset"); } if (expectContinue != null && typeof expectContinue !== "boolean") { @@ -6060,7 +6060,7 @@ var require_request = __commonJS({ this.origin = origin; this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent; this.blocking = blocking == null ? false : blocking; - this.reset = reset3 == null ? null : reset3; + this.reset = reset2 == null ? null : reset2; this.host = null; this.contentLength = null; this.contentType = null; @@ -6687,34 +6687,34 @@ var require_constants3 = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.SPECIAL_HEADERS = exports2.HEADER_STATE = exports2.MINOR = exports2.MAJOR = exports2.CONNECTION_TOKEN_CHARS = exports2.HEADER_CHARS = exports2.TOKEN = exports2.STRICT_TOKEN = exports2.HEX = exports2.URL_CHAR = exports2.STRICT_URL_CHAR = exports2.USERINFO_CHARS = exports2.MARK = exports2.ALPHANUM = exports2.NUM = exports2.HEX_MAP = exports2.NUM_MAP = exports2.ALPHA = exports2.FINISH = exports2.H_METHOD_MAP = exports2.METHOD_MAP = exports2.METHODS_RTSP = exports2.METHODS_ICE = exports2.METHODS_HTTP = exports2.METHODS = exports2.LENIENT_FLAGS = exports2.FLAGS = exports2.TYPE = exports2.ERROR = void 0; var utils_1 = require_utils2(); - var ERROR3; - (function(ERROR4) { - ERROR4[ERROR4["OK"] = 0] = "OK"; - ERROR4[ERROR4["INTERNAL"] = 1] = "INTERNAL"; - ERROR4[ERROR4["STRICT"] = 2] = "STRICT"; - ERROR4[ERROR4["LF_EXPECTED"] = 3] = "LF_EXPECTED"; - ERROR4[ERROR4["UNEXPECTED_CONTENT_LENGTH"] = 4] = "UNEXPECTED_CONTENT_LENGTH"; - ERROR4[ERROR4["CLOSED_CONNECTION"] = 5] = "CLOSED_CONNECTION"; - ERROR4[ERROR4["INVALID_METHOD"] = 6] = "INVALID_METHOD"; - ERROR4[ERROR4["INVALID_URL"] = 7] = "INVALID_URL"; - ERROR4[ERROR4["INVALID_CONSTANT"] = 8] = "INVALID_CONSTANT"; - ERROR4[ERROR4["INVALID_VERSION"] = 9] = "INVALID_VERSION"; - ERROR4[ERROR4["INVALID_HEADER_TOKEN"] = 10] = "INVALID_HEADER_TOKEN"; - ERROR4[ERROR4["INVALID_CONTENT_LENGTH"] = 11] = "INVALID_CONTENT_LENGTH"; - ERROR4[ERROR4["INVALID_CHUNK_SIZE"] = 12] = "INVALID_CHUNK_SIZE"; - ERROR4[ERROR4["INVALID_STATUS"] = 13] = "INVALID_STATUS"; - ERROR4[ERROR4["INVALID_EOF_STATE"] = 14] = "INVALID_EOF_STATE"; - ERROR4[ERROR4["INVALID_TRANSFER_ENCODING"] = 15] = "INVALID_TRANSFER_ENCODING"; - ERROR4[ERROR4["CB_MESSAGE_BEGIN"] = 16] = "CB_MESSAGE_BEGIN"; - ERROR4[ERROR4["CB_HEADERS_COMPLETE"] = 17] = "CB_HEADERS_COMPLETE"; - ERROR4[ERROR4["CB_MESSAGE_COMPLETE"] = 18] = "CB_MESSAGE_COMPLETE"; - ERROR4[ERROR4["CB_CHUNK_HEADER"] = 19] = "CB_CHUNK_HEADER"; - ERROR4[ERROR4["CB_CHUNK_COMPLETE"] = 20] = "CB_CHUNK_COMPLETE"; - ERROR4[ERROR4["PAUSED"] = 21] = "PAUSED"; - ERROR4[ERROR4["PAUSED_UPGRADE"] = 22] = "PAUSED_UPGRADE"; - ERROR4[ERROR4["PAUSED_H2_UPGRADE"] = 23] = "PAUSED_H2_UPGRADE"; - ERROR4[ERROR4["USER"] = 24] = "USER"; - })(ERROR3 = exports2.ERROR || (exports2.ERROR = {})); + var ERROR2; + (function(ERROR3) { + ERROR3[ERROR3["OK"] = 0] = "OK"; + ERROR3[ERROR3["INTERNAL"] = 1] = "INTERNAL"; + ERROR3[ERROR3["STRICT"] = 2] = "STRICT"; + ERROR3[ERROR3["LF_EXPECTED"] = 3] = "LF_EXPECTED"; + ERROR3[ERROR3["UNEXPECTED_CONTENT_LENGTH"] = 4] = "UNEXPECTED_CONTENT_LENGTH"; + ERROR3[ERROR3["CLOSED_CONNECTION"] = 5] = "CLOSED_CONNECTION"; + ERROR3[ERROR3["INVALID_METHOD"] = 6] = "INVALID_METHOD"; + ERROR3[ERROR3["INVALID_URL"] = 7] = "INVALID_URL"; + ERROR3[ERROR3["INVALID_CONSTANT"] = 8] = "INVALID_CONSTANT"; + ERROR3[ERROR3["INVALID_VERSION"] = 9] = "INVALID_VERSION"; + ERROR3[ERROR3["INVALID_HEADER_TOKEN"] = 10] = "INVALID_HEADER_TOKEN"; + ERROR3[ERROR3["INVALID_CONTENT_LENGTH"] = 11] = "INVALID_CONTENT_LENGTH"; + ERROR3[ERROR3["INVALID_CHUNK_SIZE"] = 12] = "INVALID_CHUNK_SIZE"; + ERROR3[ERROR3["INVALID_STATUS"] = 13] = "INVALID_STATUS"; + ERROR3[ERROR3["INVALID_EOF_STATE"] = 14] = "INVALID_EOF_STATE"; + ERROR3[ERROR3["INVALID_TRANSFER_ENCODING"] = 15] = "INVALID_TRANSFER_ENCODING"; + ERROR3[ERROR3["CB_MESSAGE_BEGIN"] = 16] = "CB_MESSAGE_BEGIN"; + ERROR3[ERROR3["CB_HEADERS_COMPLETE"] = 17] = "CB_HEADERS_COMPLETE"; + ERROR3[ERROR3["CB_MESSAGE_COMPLETE"] = 18] = "CB_MESSAGE_COMPLETE"; + ERROR3[ERROR3["CB_CHUNK_HEADER"] = 19] = "CB_CHUNK_HEADER"; + ERROR3[ERROR3["CB_CHUNK_COMPLETE"] = 20] = "CB_CHUNK_COMPLETE"; + ERROR3[ERROR3["PAUSED"] = 21] = "PAUSED"; + ERROR3[ERROR3["PAUSED_UPGRADE"] = 22] = "PAUSED_UPGRADE"; + ERROR3[ERROR3["PAUSED_H2_UPGRADE"] = 23] = "PAUSED_H2_UPGRADE"; + ERROR3[ERROR3["USER"] = 24] = "USER"; + })(ERROR2 = exports2.ERROR || (exports2.ERROR = {})); var TYPE; (function(TYPE2) { TYPE2[TYPE2["BOTH"] = 0] = "BOTH"; @@ -8315,7 +8315,7 @@ var require_client = __commonJS({ writeH2(client, client[kHTTP2Session], request); return; } - const { body, method, path, host, upgrade, headers, blocking, reset: reset3 } = request; + const { body, method, path, host, upgrade, headers, blocking, reset: reset2 } = request; const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH"; if (body && typeof body.read === "function") { body.read(0); @@ -8356,8 +8356,8 @@ var require_client = __commonJS({ if (upgrade || method === "CONNECT") { socket[kReset] = true; } - if (reset3 != null) { - socket[kReset] = reset3; + if (reset2 != null) { + socket[kReset] = reset2; } if (client[kMaxRequests] && socket[kCounter]++ >= client[kMaxRequests]) { socket[kReset] = true; @@ -12317,11 +12317,11 @@ var require_response = __commonJS({ return responseObject; } // Creates a redirect Response that redirects to url with status status. - static redirect(url, status2 = 302) { + static redirect(url, status3 = 302) { const relevantRealm = { settingsObject: {} }; webidl.argumentLengthCheck(arguments, 1, { header: "Response.redirect" }); url = webidl.converters.USVString(url); - status2 = webidl.converters["unsigned short"](status2); + status3 = webidl.converters["unsigned short"](status3); let parsedURL; try { parsedURL = new URL(url, getGlobalOrigin()); @@ -12330,14 +12330,14 @@ var require_response = __commonJS({ cause: err }); } - if (!redirectStatusSet.has(status2)) { - throw new RangeError("Invalid status code " + status2); + if (!redirectStatusSet.has(status3)) { + throw new RangeError("Invalid status code " + status3); } const responseObject = new _Response(); responseObject[kRealm] = relevantRealm; responseObject[kHeaders][kGuard] = "immutable"; responseObject[kHeaders][kRealm] = relevantRealm; - responseObject[kState].status = status2; + responseObject[kState].status = status3; const value = isomorphicEncode(URLSerializer(parsedURL)); responseObject[kState].headersList.append("location", value); return responseObject; @@ -14064,13 +14064,13 @@ var require_fetch = __commonJS({ }(); } try { - const { body, status: status2, statusText, headersList, socket } = await dispatch({ body: requestBody }); + const { body, status: status3, statusText, headersList, socket } = await dispatch({ body: requestBody }); if (socket) { - response = makeResponse({ status: status2, statusText, headersList, socket }); + response = makeResponse({ status: status3, statusText, headersList, socket }); } else { const iterator = body[Symbol.asyncIterator](); fetchParams.controller.next = () => iterator.next(); - response = makeResponse({ status: status2, statusText, headersList }); + response = makeResponse({ status: status3, statusText, headersList }); } } catch (err) { if (err.name === "AbortError") { @@ -14190,8 +14190,8 @@ var require_fetch = __commonJS({ this.abort = connection.abort = abort; } }, - onHeaders(status2, headersList, resume, statusText) { - if (status2 < 200) { + onHeaders(status3, headersList, resume, statusText) { + if (status3 < 200) { return; } let codings = []; @@ -14222,8 +14222,8 @@ var require_fetch = __commonJS({ } this.body = new Readable({ read: resume }); const decoders = []; - const willFollow = request.redirect === "follow" && location && redirectStatusSet.has(status2); - if (request.method !== "HEAD" && request.method !== "CONNECT" && !nullBodyStatus.includes(status2) && !willFollow) { + const willFollow = request.redirect === "follow" && location && redirectStatusSet.has(status3); + if (request.method !== "HEAD" && request.method !== "CONNECT" && !nullBodyStatus.includes(status3) && !willFollow) { for (const coding of codings) { if (coding === "x-gzip" || coding === "gzip") { decoders.push(zlib.createGunzip({ @@ -14245,7 +14245,7 @@ var require_fetch = __commonJS({ } } resolve({ - status: status2, + status: status3, statusText, headersList: headers[kHeadersList], body: decoders.length ? pipeline(this.body, ...decoders, () => { @@ -14277,8 +14277,8 @@ var require_fetch = __commonJS({ fetchParams.controller.terminate(error); reject(error); }, - onUpgrade(status2, headersList, socket) { - if (status2 !== 101) { + onUpgrade(status3, headersList, socket) { + if (status3 !== 101) { return; } const headers = new Headers(); @@ -14288,8 +14288,8 @@ var require_fetch = __commonJS({ headers[kHeadersList].append(key, val); } resolve({ - status: status2, - statusText: STATUS_CODES[status2], + status: status3, + statusText: STATUS_CODES[status3], headersList: headers[kHeadersList], socket }); @@ -19355,11 +19355,11 @@ var require_dist_node2 = __commonJS({ for (var name in all) __defProp2(target, name, { get: all[name], enumerable: true }); }; - var __copyProps2 = (to, from3, except, desc) => { - if (from3 && typeof from3 === "object" || typeof from3 === "function") { - for (let key of __getOwnPropNames2(from3)) + var __copyProps2 = (to, from2, except, desc) => { + if (from2 && typeof from2 === "object" || typeof from2 === "function") { + for (let key of __getOwnPropNames2(from2)) if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc2(from3, key)) || desc.enumerable }); + __defProp2(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc2(from2, key)) || desc.enumerable }); } return to; }; @@ -19797,11 +19797,11 @@ var require_dist_node4 = __commonJS({ for (var name in all) __defProp2(target, name, { get: all[name], enumerable: true }); }; - var __copyProps2 = (to, from3, except, desc) => { - if (from3 && typeof from3 === "object" || typeof from3 === "function") { - for (let key of __getOwnPropNames2(from3)) + var __copyProps2 = (to, from2, except, desc) => { + if (from2 && typeof from2 === "object" || typeof from2 === "function") { + for (let key of __getOwnPropNames2(from2)) if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc2(from3, key)) || desc.enumerable }); + __defProp2(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc2(from2, key)) || desc.enumerable }); } return to; }; @@ -19887,11 +19887,11 @@ var require_dist_node5 = __commonJS({ for (var name in all) __defProp2(target, name, { get: all[name], enumerable: true }); }; - var __copyProps2 = (to, from3, except, desc) => { - if (from3 && typeof from3 === "object" || typeof from3 === "function") { - for (let key of __getOwnPropNames2(from3)) + var __copyProps2 = (to, from2, except, desc) => { + if (from2 && typeof from2 === "object" || typeof from2 === "function") { + for (let key of __getOwnPropNames2(from2)) if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc2(from3, key)) || desc.enumerable }); + __defProp2(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc2(from2, key)) || desc.enumerable }); } return to; }; @@ -19921,13 +19921,13 @@ var require_dist_node5 = __commonJS({ } function fetchWrapper(requestOptions) { var _a, _b, _c, _d; - const log2 = requestOptions.request && requestOptions.request.log ? requestOptions.request.log : console; + const log3 = requestOptions.request && requestOptions.request.log ? requestOptions.request.log : console; const parseSuccessResponseBody = ((_a = requestOptions.request) == null ? void 0 : _a.parseSuccessResponseBody) !== false; if (isPlainObject(requestOptions.body) || Array.isArray(requestOptions.body)) { requestOptions.body = JSON.stringify(requestOptions.body); } let headers = {}; - let status2; + let status3; let url; let { fetch: fetch3 } = globalThis; if ((_b = requestOptions.request) == null ? void 0 : _b.fetch) { @@ -19949,51 +19949,51 @@ var require_dist_node5 = __commonJS({ ...requestOptions.body && { duplex: "half" } }).then(async (response) => { url = response.url; - status2 = response.status; + status3 = response.status; for (const keyAndValue of response.headers) { headers[keyAndValue[0]] = keyAndValue[1]; } if ("deprecation" in headers) { const matches = headers.link && headers.link.match(/<([^>]+)>; rel="deprecation"/); const deprecationLink = matches && matches.pop(); - log2.warn( + log3.warn( `[@octokit/request] "${requestOptions.method} ${requestOptions.url}" is deprecated. It is scheduled to be removed on ${headers.sunset}${deprecationLink ? `. See ${deprecationLink}` : ""}` ); } - if (status2 === 204 || status2 === 205) { + if (status3 === 204 || status3 === 205) { return; } if (requestOptions.method === "HEAD") { - if (status2 < 400) { + if (status3 < 400) { return; } - throw new import_request_error.RequestError(response.statusText, status2, { + throw new import_request_error.RequestError(response.statusText, status3, { response: { url, - status: status2, + status: status3, headers, data: void 0 }, request: requestOptions }); } - if (status2 === 304) { - throw new import_request_error.RequestError("Not modified", status2, { + if (status3 === 304) { + throw new import_request_error.RequestError("Not modified", status3, { response: { url, - status: status2, + status: status3, headers, data: await getResponseData(response) }, request: requestOptions }); } - if (status2 >= 400) { + if (status3 >= 400) { const data = await getResponseData(response); - const error = new import_request_error.RequestError(toErrorMessage(data), status2, { + const error = new import_request_error.RequestError(toErrorMessage(data), status3, { response: { url, - status: status2, + status: status3, headers, data }, @@ -20004,7 +20004,7 @@ var require_dist_node5 = __commonJS({ return parseSuccessResponseBody ? await getResponseData(response) : response.body; }).then((data) => { return { - status: status2, + status: status3, url, headers, data @@ -20097,11 +20097,11 @@ var require_dist_node6 = __commonJS({ for (var name in all) __defProp2(target, name, { get: all[name], enumerable: true }); }; - var __copyProps2 = (to, from3, except, desc) => { - if (from3 && typeof from3 === "object" || typeof from3 === "function") { - for (let key of __getOwnPropNames2(from3)) + var __copyProps2 = (to, from2, except, desc) => { + if (from2 && typeof from2 === "object" || typeof from2 === "function") { + for (let key of __getOwnPropNames2(from2)) if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc2(from3, key)) || desc.enumerable }); + __defProp2(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc2(from2, key)) || desc.enumerable }); } return to; }; @@ -20235,11 +20235,11 @@ var require_dist_node7 = __commonJS({ for (var name in all) __defProp2(target, name, { get: all[name], enumerable: true }); }; - var __copyProps2 = (to, from3, except, desc) => { - if (from3 && typeof from3 === "object" || typeof from3 === "function") { - for (let key of __getOwnPropNames2(from3)) + var __copyProps2 = (to, from2, except, desc) => { + if (from2 && typeof from2 === "object" || typeof from2 === "function") { + for (let key of __getOwnPropNames2(from2)) if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc2(from3, key)) || desc.enumerable }); + __defProp2(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc2(from2, key)) || desc.enumerable }); } return to; }; @@ -20306,11 +20306,11 @@ var require_dist_node8 = __commonJS({ for (var name in all) __defProp2(target, name, { get: all[name], enumerable: true }); }; - var __copyProps2 = (to, from3, except, desc) => { - if (from3 && typeof from3 === "object" || typeof from3 === "function") { - for (let key of __getOwnPropNames2(from3)) + var __copyProps2 = (to, from2, except, desc) => { + if (from2 && typeof from2 === "object" || typeof from2 === "function") { + for (let key of __getOwnPropNames2(from2)) if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc2(from3, key)) || desc.enumerable }); + __defProp2(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc2(from2, key)) || desc.enumerable }); } return to; }; @@ -20465,11 +20465,11 @@ var require_dist_node9 = __commonJS({ for (var name in all) __defProp2(target, name, { get: all[name], enumerable: true }); }; - var __copyProps2 = (to, from3, except, desc) => { - if (from3 && typeof from3 === "object" || typeof from3 === "function") { - for (let key of __getOwnPropNames2(from3)) + var __copyProps2 = (to, from2, except, desc) => { + if (from2 && typeof from2 === "object" || typeof from2 === "function") { + for (let key of __getOwnPropNames2(from2)) if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc2(from3, key)) || desc.enumerable }); + __defProp2(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc2(from2, key)) || desc.enumerable }); } return to; }; @@ -22621,11 +22621,11 @@ var require_dist_node10 = __commonJS({ for (var name in all) __defProp2(target, name, { get: all[name], enumerable: true }); }; - var __copyProps2 = (to, from3, except, desc) => { - if (from3 && typeof from3 === "object" || typeof from3 === "function") { - for (let key of __getOwnPropNames2(from3)) + var __copyProps2 = (to, from2, except, desc) => { + if (from2 && typeof from2 === "object" || typeof from2 === "function") { + for (let key of __getOwnPropNames2(from2)) if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc2(from3, key)) || desc.enumerable }); + __defProp2(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc2(from2, key)) || desc.enumerable }); } return to; }; @@ -23102,9994 +23102,7605 @@ var require_github = __commonJS({ } }); -// ../../../node_modules/.pnpm/@octokit+plugin-paginate-graphql@4.0.1_@octokit+core@5.2.0/node_modules/@octokit/plugin-paginate-graphql/dist-node/index.js -var require_dist_node11 = __commonJS({ - "../../../node_modules/.pnpm/@octokit+plugin-paginate-graphql@4.0.1_@octokit+core@5.2.0/node_modules/@octokit/plugin-paginate-graphql/dist-node/index.js"(exports2, module2) { +// ../../../node_modules/.pnpm/async-lock@1.4.1/node_modules/async-lock/lib/index.js +var require_lib2 = __commonJS({ + "../../../node_modules/.pnpm/async-lock@1.4.1/node_modules/async-lock/lib/index.js"(exports2, module2) { "use strict"; - var __defProp2 = Object.defineProperty; - var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; - var __getOwnPropNames2 = Object.getOwnPropertyNames; - var __hasOwnProp2 = Object.prototype.hasOwnProperty; - var __export2 = (target, all) => { - for (var name in all) - __defProp2(target, name, { get: all[name], enumerable: true }); - }; - var __copyProps2 = (to, from3, except, desc) => { - if (from3 && typeof from3 === "object" || typeof from3 === "function") { - for (let key of __getOwnPropNames2(from3)) - if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc2(from3, key)) || desc.enumerable }); - } - return to; - }; - var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); - var dist_src_exports = {}; - __export2(dist_src_exports, { - paginateGraphql: () => paginateGraphql - }); - module2.exports = __toCommonJS2(dist_src_exports); - var generateMessage = (path, cursorValue) => `The cursor at "${path.join( - "," - )}" did not change its value "${cursorValue}" after a page transition. Please make sure your that your query is set up correctly.`; - var MissingCursorChange = class extends Error { - constructor(pageInfo, cursorValue) { - super(generateMessage(pageInfo.pathInQuery, cursorValue)); - this.pageInfo = pageInfo; - this.cursorValue = cursorValue; - this.name = "MissingCursorChangeError"; - if (Error.captureStackTrace) { - Error.captureStackTrace(this, this.constructor); - } - } - }; - var MissingPageInfo = class extends Error { - constructor(response) { - super( - `No pageInfo property found in response. Please make sure to specify the pageInfo in your query. Response-Data: ${JSON.stringify( - response, - null, - 2 - )}` - ); - this.response = response; - this.name = "MissingPageInfo"; - if (Error.captureStackTrace) { - Error.captureStackTrace(this, this.constructor); - } - } - }; - var isObject2 = (value) => Object.prototype.toString.call(value) === "[object Object]"; - function findPaginatedResourcePath(responseData) { - const paginatedResourcePath = deepFindPathToProperty( - responseData, - "pageInfo" - ); - if (paginatedResourcePath.length === 0) { - throw new MissingPageInfo(responseData); - } - return paginatedResourcePath; - } - var deepFindPathToProperty = (object, searchProp, path = []) => { - for (const key of Object.keys(object)) { - const currentPath = [...path, key]; - const currentValue = object[key]; - if (currentValue.hasOwnProperty(searchProp)) { - return currentPath; - } - if (isObject2(currentValue)) { - const result = deepFindPathToProperty( - currentValue, - searchProp, - currentPath + var AsyncLock2 = function(opts) { + opts = opts || {}; + this.Promise = opts.Promise || Promise; + this.queues = /* @__PURE__ */ Object.create(null); + this.domainReentrant = opts.domainReentrant || false; + if (this.domainReentrant) { + if (typeof process === "undefined" || typeof process.domain === "undefined") { + throw new Error( + "Domain-reentrant locks require `process.domain` to exist. Please flip `opts.domainReentrant = false`, use a NodeJS version that still implements Domain, or install a browser polyfill." ); - if (result.length > 0) { - return result; - } } + this.domains = /* @__PURE__ */ Object.create(null); } - return []; - }; - var get = (object, path) => { - return path.reduce((current, nextProperty) => current[nextProperty], object); - }; - var set = (object, path, mutator) => { - const lastProperty = path[path.length - 1]; - const parentPath = [...path].slice(0, -1); - const parent = get(object, parentPath); - if (typeof mutator === "function") { - parent[lastProperty] = mutator(parent[lastProperty]); + this.timeout = opts.timeout || AsyncLock2.DEFAULT_TIMEOUT; + this.maxOccupationTime = opts.maxOccupationTime || AsyncLock2.DEFAULT_MAX_OCCUPATION_TIME; + this.maxExecutionTime = opts.maxExecutionTime || AsyncLock2.DEFAULT_MAX_EXECUTION_TIME; + if (opts.maxPending === Infinity || Number.isInteger(opts.maxPending) && opts.maxPending >= 0) { + this.maxPending = opts.maxPending; } else { - parent[lastProperty] = mutator; + this.maxPending = AsyncLock2.DEFAULT_MAX_PENDING; } }; - var extractPageInfos = (responseData) => { - const pageInfoPath = findPaginatedResourcePath(responseData); - return { - pathInQuery: pageInfoPath, - pageInfo: get(responseData, [...pageInfoPath, "pageInfo"]) - }; - }; - var isForwardSearch = (givenPageInfo) => { - return givenPageInfo.hasOwnProperty("hasNextPage"); - }; - var getCursorFrom = (pageInfo) => isForwardSearch(pageInfo) ? pageInfo.endCursor : pageInfo.startCursor; - var hasAnotherPage = (pageInfo) => isForwardSearch(pageInfo) ? pageInfo.hasNextPage : pageInfo.hasPreviousPage; - var createIterator = (octokit) => { - return (query, initialParameters = {}) => { - let nextPageExists = true; - let parameters = { ...initialParameters }; - return { - [Symbol.asyncIterator]: () => ({ - async next() { - if (!nextPageExists) - return { done: true, value: {} }; - const response = await octokit.graphql( - query, - parameters - ); - const pageInfoContext = extractPageInfos(response); - const nextCursorValue = getCursorFrom(pageInfoContext.pageInfo); - nextPageExists = hasAnotherPage(pageInfoContext.pageInfo); - if (nextPageExists && nextCursorValue === parameters.cursor) { - throw new MissingCursorChange(pageInfoContext, nextCursorValue); - } - parameters = { - ...parameters, - cursor: nextCursorValue - }; - return { done: false, value: response }; - } - }) - }; - }; - }; - var mergeResponses = (response1, response2) => { - if (Object.keys(response1).length === 0) { - return Object.assign(response1, response2); + AsyncLock2.DEFAULT_TIMEOUT = 0; + AsyncLock2.DEFAULT_MAX_OCCUPATION_TIME = 0; + AsyncLock2.DEFAULT_MAX_EXECUTION_TIME = 0; + AsyncLock2.DEFAULT_MAX_PENDING = 1e3; + AsyncLock2.prototype.acquire = function(key, fn, cb, opts) { + if (Array.isArray(key)) { + return this._acquireBatch(key, fn, cb, opts); } - const path = findPaginatedResourcePath(response1); - const nodesPath = [...path, "nodes"]; - const newNodes = get(response2, nodesPath); - if (newNodes) { - set(response1, nodesPath, (values) => { - return [...values, ...newNodes]; - }); + if (typeof fn !== "function") { + throw new Error("You must pass a function to execute"); } - const edgesPath = [...path, "edges"]; - const newEdges = get(response2, edgesPath); - if (newEdges) { - set(response1, edgesPath, (values) => { - return [...values, ...newEdges]; + var deferredResolve = null; + var deferredReject = null; + var deferred = null; + if (typeof cb !== "function") { + opts = cb; + cb = null; + deferred = new this.Promise(function(resolve, reject) { + deferredResolve = resolve; + deferredReject = reject; }); } - const pageInfoPath = [...path, "pageInfo"]; - set(response1, pageInfoPath, get(response2, pageInfoPath)); - return response1; - }; - var createPaginate = (octokit) => { - const iterator = createIterator(octokit); - return async (query, initialParameters = {}) => { - let mergedResponse = {}; - for await (const response of iterator( - query, - initialParameters - )) { - mergedResponse = mergeResponses(mergedResponse, response); - } - return mergedResponse; - }; - }; - function paginateGraphql(octokit) { - octokit.graphql; - return { - graphql: Object.assign(octokit.graphql, { - paginate: Object.assign(createPaginate(octokit), { - iterator: createIterator(octokit) - }) - }) - }; - } - } -}); - -// ../../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/light.js -var require_light = __commonJS({ - "../../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/light.js"(exports2, module2) { - (function(global2, factory) { - typeof exports2 === "object" && typeof module2 !== "undefined" ? module2.exports = factory() : typeof define === "function" && define.amd ? define(factory) : global2.Bottleneck = factory(); - })(exports2, function() { - "use strict"; - var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {}; - function getCjsExportFromNamespace(n) { - return n && n["default"] || n; - } - var load = function(received, defaults, onto = {}) { - var k, ref, v; - for (k in defaults) { - v = defaults[k]; - onto[k] = (ref = received[k]) != null ? ref : v; - } - return onto; - }; - var overwrite = function(received, defaults, onto = {}) { - var k, v; - for (k in received) { - v = received[k]; - if (defaults[k] !== void 0) { - onto[k] = v; - } + opts = opts || {}; + var resolved = false; + var timer = null; + var occupationTimer = null; + var executionTimer = null; + var self2 = this; + var done = function(locked, err, ret) { + if (occupationTimer) { + clearTimeout(occupationTimer); + occupationTimer = null; } - return onto; - }; - var parser = { - load, - overwrite - }; - var DLList; - DLList = class DLList { - constructor(incr, decr) { - this.incr = incr; - this.decr = decr; - this._first = null; - this._last = null; - this.length = 0; + if (executionTimer) { + clearTimeout(executionTimer); + executionTimer = null; } - push(value) { - var node; - this.length++; - if (typeof this.incr === "function") { - this.incr(); + if (locked) { + if (!!self2.queues[key] && self2.queues[key].length === 0) { + delete self2.queues[key]; } - node = { - value, - prev: this._last, - next: null - }; - if (this._last != null) { - this._last.next = node; - this._last = node; - } else { - this._first = this._last = node; + if (self2.domainReentrant) { + delete self2.domains[key]; } - return void 0; } - shift() { - var value; - if (this._first == null) { - return; - } else { - this.length--; - if (typeof this.decr === "function") { - this.decr(); + if (!resolved) { + if (!deferred) { + if (typeof cb === "function") { + cb(err, ret); } - } - value = this._first.value; - if ((this._first = this._first.next) != null) { - this._first.prev = null; } else { - this._last = null; + if (err) { + deferredReject(err); + } else { + deferredResolve(ret); + } } - return value; + resolved = true; } - first() { - if (this._first != null) { - return this._first.value; + if (locked) { + if (!!self2.queues[key] && self2.queues[key].length > 0) { + self2.queues[key].shift()(); } } - getArray() { - var node, ref, results; - node = this._first; - results = []; - while (node != null) { - results.push((ref = node, node = node.next, ref.value)); - } - return results; + }; + var exec2 = function(locked) { + if (resolved) { + return done(locked); } - forEachShift(cb) { - var node; - node = this.shift(); - while (node != null) { - cb(node), node = this.shift(); - } - return void 0; + if (timer) { + clearTimeout(timer); + timer = null; } - debug() { - var node, ref, ref1, ref2, results; - node = this._first; - results = []; - while (node != null) { - results.push((ref = node, node = node.next, { - value: ref.value, - prev: (ref1 = ref.prev) != null ? ref1.value : void 0, - next: (ref2 = ref.next) != null ? ref2.value : void 0 - })); - } - return results; + if (self2.domainReentrant && locked) { + self2.domains[key] = process.domain; } - }; - var DLList_1 = DLList; - var Events; - Events = class Events { - constructor(instance) { - this.instance = instance; - this._events = {}; - if (this.instance.on != null || this.instance.once != null || this.instance.removeAllListeners != null) { - throw new Error("An Emitter already exists for this object"); - } - this.instance.on = (name, cb) => { - return this._addListener(name, "many", cb); - }; - this.instance.once = (name, cb) => { - return this._addListener(name, "once", cb); - }; - this.instance.removeAllListeners = (name = null) => { - if (name != null) { - return delete this._events[name]; - } else { - return this._events = {}; + var maxExecutionTime = opts.maxExecutionTime || self2.maxExecutionTime; + if (maxExecutionTime) { + executionTimer = setTimeout(function() { + if (!!self2.queues[key]) { + done(locked, new Error("Maximum execution time is exceeded " + key)); } - }; - } - _addListener(name, status2, cb) { - var base; - if ((base = this._events)[name] == null) { - base[name] = []; - } - this._events[name].push({ cb, status: status2 }); - return this.instance; - } - listenerCount(name) { - if (this._events[name] != null) { - return this._events[name].length; - } else { - return 0; - } + }, maxExecutionTime); } - async trigger(name, ...args) { - var e, promises; + if (fn.length === 1) { + var called = false; try { - if (name !== "debug") { - this.trigger("debug", `Event triggered: ${name}`, args); - } - if (this._events[name] == null) { - return; - } - this._events[name] = this._events[name].filter(function(listener) { - return listener.status !== "none"; - }); - promises = this._events[name].map(async (listener) => { - var e2, returned; - if (listener.status === "none") { - return; - } - if (listener.status === "once") { - listener.status = "none"; - } - try { - returned = typeof listener.cb === "function" ? listener.cb(...args) : void 0; - if (typeof (returned != null ? returned.then : void 0) === "function") { - return await returned; - } else { - return returned; - } - } catch (error) { - e2 = error; - { - this.trigger("error", e2); - } - return null; + fn(function(err, ret) { + if (!called) { + called = true; + done(locked, err, ret); } }); - return (await Promise.all(promises)).find(function(x) { - return x != null; - }); - } catch (error) { - e = error; - { - this.trigger("error", e); + } catch (err) { + if (!called) { + called = true; + done(locked, err); } - return null; } + } else { + self2._promiseTry(function() { + return fn(); + }).then(function(ret) { + done(locked, void 0, ret); + }, function(error) { + done(locked, error); + }); } }; - var Events_1 = Events; - var DLList$1, Events$1, Queues; - DLList$1 = DLList_1; - Events$1 = Events_1; - Queues = class Queues { - constructor(num_priorities) { - var i; - this.Events = new Events$1(this); - this._length = 0; - this._lists = function() { - var j, ref, results; - results = []; - for (i = j = 1, ref = num_priorities; 1 <= ref ? j <= ref : j >= ref; i = 1 <= ref ? ++j : --j) { - results.push(new DLList$1(() => { - return this.incr(); - }, () => { - return this.decr(); - })); - } - return results; - }.call(this); + if (self2.domainReentrant && !!process.domain) { + exec2 = process.domain.bind(exec2); + } + var maxPending = opts.maxPending || self2.maxPending; + if (!self2.queues[key]) { + self2.queues[key] = []; + exec2(true); + } else if (self2.domainReentrant && !!process.domain && process.domain === self2.domains[key]) { + exec2(false); + } else if (self2.queues[key].length >= maxPending) { + done(false, new Error("Too many pending tasks in queue " + key)); + } else { + var taskFn = function() { + exec2(true); + }; + if (opts.skipQueue) { + self2.queues[key].unshift(taskFn); + } else { + self2.queues[key].push(taskFn); } - incr() { - if (this._length++ === 0) { - return this.Events.trigger("leftzero"); - } + var timeout = opts.timeout || self2.timeout; + if (timeout) { + timer = setTimeout(function() { + timer = null; + done(false, new Error("async-lock timed out in queue " + key)); + }, timeout); } - decr() { - if (--this._length === 0) { - return this.Events.trigger("zero"); + } + var maxOccupationTime = opts.maxOccupationTime || self2.maxOccupationTime; + if (maxOccupationTime) { + occupationTimer = setTimeout(function() { + if (!!self2.queues[key]) { + done(false, new Error("Maximum occupation time is exceeded in queue " + key)); } - } - push(job) { - return this._lists[job.options.priority].push(job); - } - queued(priority) { - if (priority != null) { - return this._lists[priority].length; + }, maxOccupationTime); + } + if (deferred) { + return deferred; + } + }; + AsyncLock2.prototype._acquireBatch = function(keys, fn, cb, opts) { + if (typeof cb !== "function") { + opts = cb; + cb = null; + } + var self2 = this; + var getFn = function(key, fn2) { + return function(cb2) { + self2.acquire(key, fn2, cb2, opts); + }; + }; + var fnx = keys.reduceRight(function(prev, key) { + return getFn(key, prev); + }, fn); + if (typeof cb === "function") { + fnx(cb); + } else { + return new this.Promise(function(resolve, reject) { + if (fnx.length === 1) { + fnx(function(err, ret) { + if (err) { + reject(err); + } else { + resolve(ret); + } + }); } else { - return this._length; + resolve(fnx()); } - } - shiftAll(fn) { - return this._lists.forEach(function(list) { - return list.forEachShift(fn); - }); - } - getFirst(arr = this._lists) { - var j, len, list; - for (j = 0, len = arr.length; j < len; j++) { - list = arr[j]; - if (list.length > 0) { - return list; + }); + } + }; + AsyncLock2.prototype.isBusy = function(key) { + if (!key) { + return Object.keys(this.queues).length > 0; + } else { + return !!this.queues[key]; + } + }; + AsyncLock2.prototype._promiseTry = function(fn) { + try { + return this.Promise.resolve(fn()); + } catch (e) { + return this.Promise.reject(e); + } + }; + module2.exports = AsyncLock2; + } +}); + +// ../../../node_modules/.pnpm/async-lock@1.4.1/node_modules/async-lock/index.js +var require_async_lock = __commonJS({ + "../../../node_modules/.pnpm/async-lock@1.4.1/node_modules/async-lock/index.js"(exports2, module2) { + "use strict"; + module2.exports = require_lib2(); + } +}); + +// ../../../node_modules/.pnpm/inherits@2.0.4/node_modules/inherits/inherits_browser.js +var require_inherits_browser = __commonJS({ + "../../../node_modules/.pnpm/inherits@2.0.4/node_modules/inherits/inherits_browser.js"(exports2, module2) { + if (typeof Object.create === "function") { + module2.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor; + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true } - } - return []; - } - shiftLastFrom(priority) { - return this.getFirst(this._lists.slice(priority).reverse()).shift(); + }); } }; - var Queues_1 = Queues; - var BottleneckError; - BottleneckError = class BottleneckError extends Error { + } else { + module2.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor; + var TempCtor = function() { + }; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } }; - var BottleneckError_1 = BottleneckError; - var BottleneckError$1, DEFAULT_PRIORITY, Job, NUM_PRIORITIES, parser$1; - NUM_PRIORITIES = 10; - DEFAULT_PRIORITY = 5; - parser$1 = parser; - BottleneckError$1 = BottleneckError_1; - Job = class Job { - constructor(task, args, options, jobDefaults, rejectOnDrop, Events2, _states, Promise2) { - this.task = task; - this.args = args; - this.rejectOnDrop = rejectOnDrop; - this.Events = Events2; - this._states = _states; - this.Promise = Promise2; - this.options = parser$1.load(options, jobDefaults); - this.options.priority = this._sanitizePriority(this.options.priority); - if (this.options.id === jobDefaults.id) { - this.options.id = `${this.options.id}-${this._randomIndex()}`; - } - this.promise = new this.Promise((_resolve, _reject) => { - this._resolve = _resolve; - this._reject = _reject; + } + } +}); + +// ../../../node_modules/.pnpm/inherits@2.0.4/node_modules/inherits/inherits.js +var require_inherits = __commonJS({ + "../../../node_modules/.pnpm/inherits@2.0.4/node_modules/inherits/inherits.js"(exports2, module2) { + try { + util = require("util"); + if (typeof util.inherits !== "function") + throw ""; + module2.exports = util.inherits; + } catch (e) { + module2.exports = require_inherits_browser(); + } + var util; + } +}); + +// ../../../node_modules/.pnpm/safe-buffer@5.2.1/node_modules/safe-buffer/index.js +var require_safe_buffer = __commonJS({ + "../../../node_modules/.pnpm/safe-buffer@5.2.1/node_modules/safe-buffer/index.js"(exports2, module2) { + var buffer = require("buffer"); + var Buffer2 = buffer.Buffer; + function copyProps(src, dst) { + for (var key in src) { + dst[key] = src[key]; + } + } + if (Buffer2.from && Buffer2.alloc && Buffer2.allocUnsafe && Buffer2.allocUnsafeSlow) { + module2.exports = buffer; + } else { + copyProps(buffer, exports2); + exports2.Buffer = SafeBuffer; + } + function SafeBuffer(arg, encodingOrOffset, length) { + return Buffer2(arg, encodingOrOffset, length); + } + SafeBuffer.prototype = Object.create(Buffer2.prototype); + copyProps(Buffer2, SafeBuffer); + SafeBuffer.from = function(arg, encodingOrOffset, length) { + if (typeof arg === "number") { + throw new TypeError("Argument must not be a number"); + } + return Buffer2(arg, encodingOrOffset, length); + }; + SafeBuffer.alloc = function(size, fill, encoding) { + if (typeof size !== "number") { + throw new TypeError("Argument must be a number"); + } + var buf = Buffer2(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 Buffer2(size); + }; + SafeBuffer.allocUnsafeSlow = function(size) { + if (typeof size !== "number") { + throw new TypeError("Argument must be a number"); + } + return buffer.SlowBuffer(size); + }; + } +}); + +// ../../../node_modules/.pnpm/sha.js@2.4.11/node_modules/sha.js/hash.js +var require_hash = __commonJS({ + "../../../node_modules/.pnpm/sha.js@2.4.11/node_modules/sha.js/hash.js"(exports2, module2) { + var Buffer2 = require_safe_buffer().Buffer; + function Hash2(blockSize, finalSize) { + this._block = Buffer2.alloc(blockSize); + this._finalSize = finalSize; + this._blockSize = blockSize; + this._len = 0; + } + Hash2.prototype.update = function(data, enc) { + if (typeof data === "string") { + enc = enc || "utf8"; + data = Buffer2.from(data, enc); + } + var block = this._block; + var blockSize = this._blockSize; + var length = data.length; + var accum = this._len; + for (var offset = 0; offset < length; ) { + var assigned = accum % blockSize; + var remainder = Math.min(length - offset, blockSize - assigned); + for (var i = 0; i < remainder; i++) { + block[assigned + i] = data[offset + i]; + } + accum += remainder; + offset += remainder; + if (accum % blockSize === 0) { + this._update(block); + } + } + this._len += length; + return this; + }; + Hash2.prototype.digest = function(enc) { + var rem = this._len % this._blockSize; + this._block[rem] = 128; + this._block.fill(0, rem + 1); + if (rem >= this._finalSize) { + this._update(this._block); + this._block.fill(0); + } + var bits = this._len * 8; + if (bits <= 4294967295) { + this._block.writeUInt32BE(bits, this._blockSize - 4); + } else { + var lowBits = (bits & 4294967295) >>> 0; + var highBits = (bits - lowBits) / 4294967296; + this._block.writeUInt32BE(highBits, this._blockSize - 8); + this._block.writeUInt32BE(lowBits, this._blockSize - 4); + } + this._update(this._block); + var hash2 = this._hash(); + return enc ? hash2.toString(enc) : hash2; + }; + Hash2.prototype._update = function() { + throw new Error("_update must be implemented by subclass"); + }; + module2.exports = Hash2; + } +}); + +// ../../../node_modules/.pnpm/sha.js@2.4.11/node_modules/sha.js/sha1.js +var require_sha1 = __commonJS({ + "../../../node_modules/.pnpm/sha.js@2.4.11/node_modules/sha.js/sha1.js"(exports2, module2) { + var inherits = require_inherits(); + var Hash2 = require_hash(); + var Buffer2 = require_safe_buffer().Buffer; + var K = [ + 1518500249, + 1859775393, + 2400959708 | 0, + 3395469782 | 0 + ]; + var W = new Array(80); + function Sha1() { + this.init(); + this._w = W; + Hash2.call(this, 64, 56); + } + inherits(Sha1, Hash2); + Sha1.prototype.init = function() { + this._a = 1732584193; + this._b = 4023233417; + this._c = 2562383102; + this._d = 271733878; + this._e = 3285377520; + return this; + }; + function rotl1(num2) { + return num2 << 1 | num2 >>> 31; + } + function rotl5(num2) { + return num2 << 5 | num2 >>> 27; + } + function rotl30(num2) { + return num2 << 30 | num2 >>> 2; + } + function ft(s, b, c, d) { + if (s === 0) + return b & c | ~b & d; + if (s === 2) + return b & c | b & d | c & d; + return b ^ c ^ d; + } + Sha1.prototype._update = function(M) { + var W2 = this._w; + var a = this._a | 0; + var b = this._b | 0; + var c = this._c | 0; + var d = this._d | 0; + var e = this._e | 0; + for (var i = 0; i < 16; ++i) + W2[i] = M.readInt32BE(i * 4); + for (; i < 80; ++i) + W2[i] = rotl1(W2[i - 3] ^ W2[i - 8] ^ W2[i - 14] ^ W2[i - 16]); + for (var j = 0; j < 80; ++j) { + var s = ~~(j / 20); + var t = rotl5(a) + ft(s, b, c, d) + e + W2[j] + K[s] | 0; + e = d; + d = c; + c = rotl30(b); + b = a; + a = t; + } + this._a = a + this._a | 0; + this._b = b + this._b | 0; + this._c = c + this._c | 0; + this._d = d + this._d | 0; + this._e = e + this._e | 0; + }; + Sha1.prototype._hash = function() { + var H = Buffer2.allocUnsafe(20); + H.writeInt32BE(this._a | 0, 0); + H.writeInt32BE(this._b | 0, 4); + H.writeInt32BE(this._c | 0, 8); + H.writeInt32BE(this._d | 0, 12); + H.writeInt32BE(this._e | 0, 16); + return H; + }; + module2.exports = Sha1; + } +}); + +// ../../../node_modules/.pnpm/crc-32@1.2.2/node_modules/crc-32/crc32.js +var require_crc32 = __commonJS({ + "../../../node_modules/.pnpm/crc-32@1.2.2/node_modules/crc-32/crc32.js"(exports2) { + var CRC32; + (function(factory) { + if (typeof DO_NOT_EXPORT_CRC === "undefined") { + if ("object" === typeof exports2) { + factory(exports2); + } else if ("function" === typeof define && define.amd) { + define(function() { + var module3 = {}; + factory(module3); + return module3; }); - this.retryCount = 0; + } else { + factory(CRC32 = {}); } - _sanitizePriority(priority) { - var sProperty; - sProperty = ~~priority !== priority ? DEFAULT_PRIORITY : priority; - if (sProperty < 0) { - return 0; - } else if (sProperty > NUM_PRIORITIES - 1) { - return NUM_PRIORITIES - 1; - } else { - return sProperty; - } + } else { + factory(CRC32 = {}); + } + })(function(CRC322) { + CRC322.version = "1.2.2"; + function signed_crc_table() { + var c = 0, table = new Array(256); + for (var n = 0; n != 256; ++n) { + c = n; + c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1; + c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1; + c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1; + c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1; + c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1; + c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1; + c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1; + c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1; + table[n] = c; } - _randomIndex() { - return Math.random().toString(36).slice(2); + return typeof Int32Array !== "undefined" ? new Int32Array(table) : table; + } + var T0 = signed_crc_table(); + function slice_by_16_tables(T) { + var c = 0, v = 0, n = 0, table = typeof Int32Array !== "undefined" ? new Int32Array(4096) : new Array(4096); + for (n = 0; n != 256; ++n) + table[n] = T[n]; + for (n = 0; n != 256; ++n) { + v = T[n]; + for (c = 256 + n; c < 4096; c += 256) + v = table[c] = v >>> 8 ^ T[v & 255]; } - doDrop({ error, message = "This job has been dropped by Bottleneck" } = {}) { - if (this._states.remove(this.options.id)) { - if (this.rejectOnDrop) { - this._reject(error != null ? error : new BottleneckError$1(message)); - } - this.Events.trigger("dropped", { args: this.args, options: this.options, task: this.task, promise: this.promise }); - return true; + var out = []; + for (n = 1; n != 16; ++n) + out[n - 1] = typeof Int32Array !== "undefined" ? table.subarray(n * 256, n * 256 + 256) : table.slice(n * 256, n * 256 + 256); + return out; + } + var TT = slice_by_16_tables(T0); + var T1 = TT[0], T2 = TT[1], T3 = TT[2], T4 = TT[3], T5 = TT[4]; + var T6 = TT[5], T7 = TT[6], T8 = TT[7], T9 = TT[8], Ta = TT[9]; + var Tb = TT[10], Tc = TT[11], Td = TT[12], Te = TT[13], Tf = TT[14]; + function crc32_bstr(bstr, seed) { + var C = seed ^ -1; + for (var i = 0, L = bstr.length; i < L; ) + C = C >>> 8 ^ T0[(C ^ bstr.charCodeAt(i++)) & 255]; + return ~C; + } + function crc32_buf(B, seed) { + var C = seed ^ -1, L = B.length - 15, i = 0; + for (; i < L; ) + C = Tf[B[i++] ^ C & 255] ^ Te[B[i++] ^ C >> 8 & 255] ^ Td[B[i++] ^ C >> 16 & 255] ^ Tc[B[i++] ^ C >>> 24] ^ Tb[B[i++]] ^ Ta[B[i++]] ^ T9[B[i++]] ^ T8[B[i++]] ^ T7[B[i++]] ^ T6[B[i++]] ^ T5[B[i++]] ^ T4[B[i++]] ^ T3[B[i++]] ^ T2[B[i++]] ^ T1[B[i++]] ^ T0[B[i++]]; + L += 15; + while (i < L) + C = C >>> 8 ^ T0[(C ^ B[i++]) & 255]; + return ~C; + } + function crc32_str(str, seed) { + var C = seed ^ -1; + for (var i = 0, L = str.length, c = 0, d = 0; i < L; ) { + c = str.charCodeAt(i++); + if (c < 128) { + C = C >>> 8 ^ T0[(C ^ c) & 255]; + } else if (c < 2048) { + C = C >>> 8 ^ T0[(C ^ (192 | c >> 6 & 31)) & 255]; + C = C >>> 8 ^ T0[(C ^ (128 | c & 63)) & 255]; + } else if (c >= 55296 && c < 57344) { + c = (c & 1023) + 64; + d = str.charCodeAt(i++) & 1023; + C = C >>> 8 ^ T0[(C ^ (240 | c >> 8 & 7)) & 255]; + C = C >>> 8 ^ T0[(C ^ (128 | c >> 2 & 63)) & 255]; + C = C >>> 8 ^ T0[(C ^ (128 | d >> 6 & 15 | (c & 3) << 4)) & 255]; + C = C >>> 8 ^ T0[(C ^ (128 | d & 63)) & 255]; } else { - return false; - } - } - _assertStatus(expected) { - var status2; - status2 = this._states.jobStatus(this.options.id); - if (!(status2 === expected || expected === "DONE" && status2 === null)) { - throw new BottleneckError$1(`Invalid job status ${status2}, expected ${expected}. Please open an issue at https://github.com/SGrondin/bottleneck/issues`); + C = C >>> 8 ^ T0[(C ^ (224 | c >> 12 & 15)) & 255]; + C = C >>> 8 ^ T0[(C ^ (128 | c >> 6 & 63)) & 255]; + C = C >>> 8 ^ T0[(C ^ (128 | c & 63)) & 255]; } } - doReceive() { - this._states.start(this.options.id); - return this.Events.trigger("received", { args: this.args, options: this.options }); + return ~C; + } + CRC322.table = T0; + CRC322.bstr = crc32_bstr; + CRC322.buf = crc32_buf; + CRC322.str = crc32_str; + }); + } +}); + +// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/utils/common.js +var require_common = __commonJS({ + "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/utils/common.js"(exports2) { + "use strict"; + var TYPED_OK = typeof Uint8Array !== "undefined" && typeof Uint16Array !== "undefined" && typeof Int32Array !== "undefined"; + function _has(obj, key) { + return Object.prototype.hasOwnProperty.call(obj, key); + } + exports2.assign = function(obj) { + var sources = Array.prototype.slice.call(arguments, 1); + while (sources.length) { + var source = sources.shift(); + if (!source) { + continue; } - doQueue(reachedHWM, blocked) { - this._assertStatus("RECEIVED"); - this._states.next(this.options.id); - return this.Events.trigger("queued", { args: this.args, options: this.options, reachedHWM, blocked }); + if (typeof source !== "object") { + throw new TypeError(source + "must be non-object"); } - doRun() { - if (this.retryCount === 0) { - this._assertStatus("QUEUED"); - this._states.next(this.options.id); - } else { - this._assertStatus("EXECUTING"); + for (var p in source) { + if (_has(source, p)) { + obj[p] = source[p]; } - return this.Events.trigger("scheduled", { args: this.args, options: this.options }); } - async doExecute(chained, clearGlobalState, run2, free) { - var error, eventInfo, passed; - if (this.retryCount === 0) { - this._assertStatus("RUNNING"); - this._states.next(this.options.id); - } else { - this._assertStatus("EXECUTING"); - } - eventInfo = { args: this.args, options: this.options, retryCount: this.retryCount }; - this.Events.trigger("executing", eventInfo); - try { - passed = await (chained != null ? chained.schedule(this.options, this.task, ...this.args) : this.task(...this.args)); - if (clearGlobalState()) { - this.doDone(eventInfo); - await free(this.options, eventInfo); - this._assertStatus("DONE"); - return this._resolve(passed); - } - } catch (error1) { - error = error1; - return this._onFailure(error, eventInfo, clearGlobalState, run2, free); - } + } + return obj; + }; + exports2.shrinkBuf = function(buf, size) { + if (buf.length === size) { + return buf; + } + if (buf.subarray) { + return buf.subarray(0, size); + } + buf.length = size; + return buf; + }; + var fnTyped = { + arraySet: function(dest, src, src_offs, len, dest_offs) { + if (src.subarray && dest.subarray) { + dest.set(src.subarray(src_offs, src_offs + len), dest_offs); + return; } - doExpire(clearGlobalState, run2, free) { - var error, eventInfo; - if (this._states.jobStatus(this.options.id === "RUNNING")) { - this._states.next(this.options.id); - } - this._assertStatus("EXECUTING"); - eventInfo = { args: this.args, options: this.options, retryCount: this.retryCount }; - error = new BottleneckError$1(`This job timed out after ${this.options.expiration} ms.`); - return this._onFailure(error, eventInfo, clearGlobalState, run2, free); + for (var i = 0; i < len; i++) { + dest[dest_offs + i] = src[src_offs + i]; } - async _onFailure(error, eventInfo, clearGlobalState, run2, free) { - var retry, retryAfter; - if (clearGlobalState()) { - retry = await this.Events.trigger("failed", error, eventInfo); - if (retry != null) { - retryAfter = ~~retry; - this.Events.trigger("retry", `Retrying ${this.options.id} after ${retryAfter} ms`, eventInfo); - this.retryCount++; - return run2(retryAfter); - } else { - this.doDone(eventInfo); - await free(this.options, eventInfo); - this._assertStatus("DONE"); - return this._reject(error); - } - } + }, + // Join array of chunks to single array. + flattenChunks: function(chunks) { + var i, l, len, pos, chunk, result; + len = 0; + for (i = 0, l = chunks.length; i < l; i++) { + len += chunks[i].length; } - doDone(eventInfo) { - this._assertStatus("EXECUTING"); - this._states.next(this.options.id); - return this.Events.trigger("done", eventInfo); + result = new Uint8Array(len); + pos = 0; + for (i = 0, l = chunks.length; i < l; i++) { + chunk = chunks[i]; + result.set(chunk, pos); + pos += chunk.length; } - }; - var Job_1 = Job; - var BottleneckError$2, LocalDatastore, parser$2; - parser$2 = parser; - BottleneckError$2 = BottleneckError_1; - LocalDatastore = class LocalDatastore { - constructor(instance, storeOptions, storeInstanceOptions) { - this.instance = instance; - this.storeOptions = storeOptions; - this.clientId = this.instance._randomIndex(); - parser$2.load(storeInstanceOptions, storeInstanceOptions, this); - this._nextRequest = this._lastReservoirRefresh = this._lastReservoirIncrease = Date.now(); - this._running = 0; - this._done = 0; - this._unblockTime = 0; - this.ready = this.Promise.resolve(); - this.clients = {}; - this._startHeartbeat(); + return result; + } + }; + var fnUntyped = { + arraySet: function(dest, src, src_offs, len, dest_offs) { + for (var i = 0; i < len; i++) { + dest[dest_offs + i] = src[src_offs + i]; } - _startHeartbeat() { - var base; - if (this.heartbeat == null && (this.storeOptions.reservoirRefreshInterval != null && this.storeOptions.reservoirRefreshAmount != null || this.storeOptions.reservoirIncreaseInterval != null && this.storeOptions.reservoirIncreaseAmount != null)) { - return typeof (base = this.heartbeat = setInterval(() => { - var amount, incr, maximum, now, reservoir; - now = Date.now(); - if (this.storeOptions.reservoirRefreshInterval != null && now >= this._lastReservoirRefresh + this.storeOptions.reservoirRefreshInterval) { - this._lastReservoirRefresh = now; - this.storeOptions.reservoir = this.storeOptions.reservoirRefreshAmount; - this.instance._drainAll(this.computeCapacity()); - } - if (this.storeOptions.reservoirIncreaseInterval != null && now >= this._lastReservoirIncrease + this.storeOptions.reservoirIncreaseInterval) { - ({ - reservoirIncreaseAmount: amount, - reservoirIncreaseMaximum: maximum, - reservoir - } = this.storeOptions); - this._lastReservoirIncrease = now; - incr = maximum != null ? Math.min(amount, maximum - reservoir) : amount; - if (incr > 0) { - this.storeOptions.reservoir += incr; - return this.instance._drainAll(this.computeCapacity()); - } - } - }, this.heartbeatInterval)).unref === "function" ? base.unref() : void 0; - } else { - return clearInterval(this.heartbeat); - } + }, + // Join array of chunks to single array. + flattenChunks: function(chunks) { + return [].concat.apply([], chunks); + } + }; + exports2.setTyped = function(on) { + if (on) { + exports2.Buf8 = Uint8Array; + exports2.Buf16 = Uint16Array; + exports2.Buf32 = Int32Array; + exports2.assign(exports2, fnTyped); + } else { + exports2.Buf8 = Array; + exports2.Buf16 = Array; + exports2.Buf32 = Array; + exports2.assign(exports2, fnUntyped); + } + }; + exports2.setTyped(TYPED_OK); + } +}); + +// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/trees.js +var require_trees = __commonJS({ + "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/trees.js"(exports2) { + "use strict"; + var utils = require_common(); + var Z_FIXED = 4; + var Z_BINARY = 0; + var Z_TEXT = 1; + var Z_UNKNOWN = 2; + function zero(buf) { + var len = buf.length; + while (--len >= 0) { + buf[len] = 0; + } + } + var STORED_BLOCK = 0; + var STATIC_TREES = 1; + var DYN_TREES = 2; + var MIN_MATCH = 3; + var MAX_MATCH = 258; + var LENGTH_CODES = 29; + var LITERALS = 256; + var L_CODES = LITERALS + 1 + LENGTH_CODES; + var D_CODES = 30; + var BL_CODES = 19; + var HEAP_SIZE = 2 * L_CODES + 1; + var MAX_BITS = 15; + var Buf_size = 16; + var MAX_BL_BITS = 7; + var END_BLOCK = 256; + var REP_3_6 = 16; + var REPZ_3_10 = 17; + var REPZ_11_138 = 18; + var extra_lbits = ( + /* extra bits for each length code */ + [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0] + ); + var extra_dbits = ( + /* extra bits for each distance code */ + [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13] + ); + var extra_blbits = ( + /* extra bits for each bit length code */ + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7] + ); + var bl_order = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]; + var DIST_CODE_LEN = 512; + var static_ltree = new Array((L_CODES + 2) * 2); + zero(static_ltree); + var static_dtree = new Array(D_CODES * 2); + zero(static_dtree); + var _dist_code = new Array(DIST_CODE_LEN); + zero(_dist_code); + var _length_code = new Array(MAX_MATCH - MIN_MATCH + 1); + zero(_length_code); + var base_length = new Array(LENGTH_CODES); + zero(base_length); + var base_dist = new Array(D_CODES); + zero(base_dist); + function StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) { + this.static_tree = static_tree; + this.extra_bits = extra_bits; + this.extra_base = extra_base; + this.elems = elems; + this.max_length = max_length; + this.has_stree = static_tree && static_tree.length; + } + var static_l_desc; + var static_d_desc; + var static_bl_desc; + function TreeDesc(dyn_tree, stat_desc) { + this.dyn_tree = dyn_tree; + this.max_code = 0; + this.stat_desc = stat_desc; + } + function d_code(dist) { + return dist < 256 ? _dist_code[dist] : _dist_code[256 + (dist >>> 7)]; + } + function put_short(s, w) { + s.pending_buf[s.pending++] = w & 255; + s.pending_buf[s.pending++] = w >>> 8 & 255; + } + function send_bits(s, value, length) { + if (s.bi_valid > Buf_size - length) { + s.bi_buf |= value << s.bi_valid & 65535; + put_short(s, s.bi_buf); + s.bi_buf = value >> Buf_size - s.bi_valid; + s.bi_valid += length - Buf_size; + } else { + s.bi_buf |= value << s.bi_valid & 65535; + s.bi_valid += length; + } + } + function send_code(s, c, tree) { + send_bits( + s, + tree[c * 2], + tree[c * 2 + 1] + /*.Len*/ + ); + } + function bi_reverse(code, len) { + var res = 0; + do { + res |= code & 1; + code >>>= 1; + res <<= 1; + } while (--len > 0); + return res >>> 1; + } + function bi_flush(s) { + if (s.bi_valid === 16) { + put_short(s, s.bi_buf); + s.bi_buf = 0; + s.bi_valid = 0; + } else if (s.bi_valid >= 8) { + s.pending_buf[s.pending++] = s.bi_buf & 255; + s.bi_buf >>= 8; + s.bi_valid -= 8; + } + } + function gen_bitlen(s, desc) { + var tree = desc.dyn_tree; + var max_code = desc.max_code; + var stree = desc.stat_desc.static_tree; + var has_stree = desc.stat_desc.has_stree; + var extra = desc.stat_desc.extra_bits; + var base = desc.stat_desc.extra_base; + var max_length = desc.stat_desc.max_length; + var h; + var n, m; + var bits; + var xbits; + var f; + var overflow = 0; + for (bits = 0; bits <= MAX_BITS; bits++) { + s.bl_count[bits] = 0; + } + tree[s.heap[s.heap_max] * 2 + 1] = 0; + for (h = s.heap_max + 1; h < HEAP_SIZE; h++) { + n = s.heap[h]; + bits = tree[tree[n * 2 + 1] * 2 + 1] + 1; + if (bits > max_length) { + bits = max_length; + overflow++; } - async __publish__(message) { - await this.yieldLoop(); - return this.instance.Events.trigger("message", message.toString()); + tree[n * 2 + 1] = bits; + if (n > max_code) { + continue; } - async __disconnect__(flush) { - await this.yieldLoop(); - clearInterval(this.heartbeat); - return this.Promise.resolve(); + s.bl_count[bits]++; + xbits = 0; + if (n >= base) { + xbits = extra[n - base]; } - yieldLoop(t = 0) { - return new this.Promise(function(resolve, reject) { - return setTimeout(resolve, t); - }); + f = tree[n * 2]; + s.opt_len += f * (bits + xbits); + if (has_stree) { + s.static_len += f * (stree[n * 2 + 1] + xbits); } - computePenalty() { - var ref; - return (ref = this.storeOptions.penalty) != null ? ref : 15 * this.storeOptions.minTime || 5e3; + } + if (overflow === 0) { + return; + } + do { + bits = max_length - 1; + while (s.bl_count[bits] === 0) { + bits--; } - async __updateSettings__(options) { - await this.yieldLoop(); - parser$2.overwrite(options, options, this.storeOptions); - this._startHeartbeat(); - this.instance._drainAll(this.computeCapacity()); - return true; + s.bl_count[bits]--; + s.bl_count[bits + 1] += 2; + s.bl_count[max_length]--; + overflow -= 2; + } while (overflow > 0); + for (bits = max_length; bits !== 0; bits--) { + n = s.bl_count[bits]; + while (n !== 0) { + m = s.heap[--h]; + if (m > max_code) { + continue; + } + if (tree[m * 2 + 1] !== bits) { + s.opt_len += (bits - tree[m * 2 + 1]) * tree[m * 2]; + tree[m * 2 + 1] = bits; + } + n--; } - async __running__() { - await this.yieldLoop(); - return this._running; + } + } + function gen_codes(tree, max_code, bl_count) { + var next_code = new Array(MAX_BITS + 1); + var code = 0; + var bits; + var n; + for (bits = 1; bits <= MAX_BITS; bits++) { + next_code[bits] = code = code + bl_count[bits - 1] << 1; + } + for (n = 0; n <= max_code; n++) { + var len = tree[n * 2 + 1]; + if (len === 0) { + continue; } - async __queued__() { - await this.yieldLoop(); - return this.instance.queued(); + tree[n * 2] = bi_reverse(next_code[len]++, len); + } + } + function tr_static_init() { + var n; + var bits; + var length; + var code; + var dist; + var bl_count = new Array(MAX_BITS + 1); + length = 0; + for (code = 0; code < LENGTH_CODES - 1; code++) { + base_length[code] = length; + for (n = 0; n < 1 << extra_lbits[code]; n++) { + _length_code[length++] = code; } - async __done__() { - await this.yieldLoop(); - return this._done; + } + _length_code[length - 1] = code; + dist = 0; + for (code = 0; code < 16; code++) { + base_dist[code] = dist; + for (n = 0; n < 1 << extra_dbits[code]; n++) { + _dist_code[dist++] = code; } - async __groupCheck__(time) { - await this.yieldLoop(); - return this._nextRequest + this.timeout < time; + } + dist >>= 7; + for (; code < D_CODES; code++) { + base_dist[code] = dist << 7; + for (n = 0; n < 1 << extra_dbits[code] - 7; n++) { + _dist_code[256 + dist++] = code; } - computeCapacity() { - var maxConcurrent, reservoir; - ({ maxConcurrent, reservoir } = this.storeOptions); - if (maxConcurrent != null && reservoir != null) { - return Math.min(maxConcurrent - this._running, reservoir); - } else if (maxConcurrent != null) { - return maxConcurrent - this._running; - } else if (reservoir != null) { - return reservoir; - } else { - return null; - } + } + for (bits = 0; bits <= MAX_BITS; bits++) { + bl_count[bits] = 0; + } + n = 0; + while (n <= 143) { + static_ltree[n * 2 + 1] = 8; + n++; + bl_count[8]++; + } + while (n <= 255) { + static_ltree[n * 2 + 1] = 9; + n++; + bl_count[9]++; + } + while (n <= 279) { + static_ltree[n * 2 + 1] = 7; + n++; + bl_count[7]++; + } + while (n <= 287) { + static_ltree[n * 2 + 1] = 8; + n++; + bl_count[8]++; + } + gen_codes(static_ltree, L_CODES + 1, bl_count); + for (n = 0; n < D_CODES; n++) { + static_dtree[n * 2 + 1] = 5; + static_dtree[n * 2] = bi_reverse(n, 5); + } + static_l_desc = new StaticTreeDesc(static_ltree, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS); + static_d_desc = new StaticTreeDesc(static_dtree, extra_dbits, 0, D_CODES, MAX_BITS); + static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS); + } + function init_block(s) { + var n; + for (n = 0; n < L_CODES; n++) { + s.dyn_ltree[n * 2] = 0; + } + for (n = 0; n < D_CODES; n++) { + s.dyn_dtree[n * 2] = 0; + } + for (n = 0; n < BL_CODES; n++) { + s.bl_tree[n * 2] = 0; + } + s.dyn_ltree[END_BLOCK * 2] = 1; + s.opt_len = s.static_len = 0; + s.last_lit = s.matches = 0; + } + function bi_windup(s) { + if (s.bi_valid > 8) { + put_short(s, s.bi_buf); + } else if (s.bi_valid > 0) { + s.pending_buf[s.pending++] = s.bi_buf; + } + s.bi_buf = 0; + s.bi_valid = 0; + } + function copy_block(s, buf, len, header) { + bi_windup(s); + if (header) { + put_short(s, len); + put_short(s, ~len); + } + utils.arraySet(s.pending_buf, s.window, buf, len, s.pending); + s.pending += len; + } + function smaller(tree, n, m, depth) { + var _n2 = n * 2; + var _m2 = m * 2; + return tree[_n2] < tree[_m2] || tree[_n2] === tree[_m2] && depth[n] <= depth[m]; + } + function pqdownheap(s, tree, k) { + var v = s.heap[k]; + var j = k << 1; + while (j <= s.heap_len) { + if (j < s.heap_len && smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) { + j++; } - conditionsCheck(weight) { - var capacity; - capacity = this.computeCapacity(); - return capacity == null || weight <= capacity; + if (smaller(tree, v, s.heap[j], s.depth)) { + break; } - async __incrementReservoir__(incr) { - var reservoir; - await this.yieldLoop(); - reservoir = this.storeOptions.reservoir += incr; - this.instance._drainAll(this.computeCapacity()); - return reservoir; - } - async __currentReservoir__() { - await this.yieldLoop(); - return this.storeOptions.reservoir; - } - isBlocked(now) { - return this._unblockTime >= now; - } - check(weight, now) { - return this.conditionsCheck(weight) && this._nextRequest - now <= 0; - } - async __check__(weight) { - var now; - await this.yieldLoop(); - now = Date.now(); - return this.check(weight, now); - } - async __register__(index2, weight, expiration) { - var now, wait; - await this.yieldLoop(); - now = Date.now(); - if (this.conditionsCheck(weight)) { - this._running += weight; - if (this.storeOptions.reservoir != null) { - this.storeOptions.reservoir -= weight; - } - wait = Math.max(this._nextRequest - now, 0); - this._nextRequest = now + wait + this.storeOptions.minTime; - return { - success: true, - wait, - reservoir: this.storeOptions.reservoir - }; + s.heap[k] = s.heap[j]; + k = j; + j <<= 1; + } + s.heap[k] = v; + } + function compress_block(s, ltree, dtree) { + var dist; + var lc; + var lx = 0; + var code; + var extra; + if (s.last_lit !== 0) { + do { + dist = s.pending_buf[s.d_buf + lx * 2] << 8 | s.pending_buf[s.d_buf + lx * 2 + 1]; + lc = s.pending_buf[s.l_buf + lx]; + lx++; + if (dist === 0) { + send_code(s, lc, ltree); } else { - return { - success: false - }; + code = _length_code[lc]; + send_code(s, code + LITERALS + 1, ltree); + extra = extra_lbits[code]; + if (extra !== 0) { + lc -= base_length[code]; + send_bits(s, lc, extra); + } + dist--; + code = d_code(dist); + send_code(s, code, dtree); + extra = extra_dbits[code]; + if (extra !== 0) { + dist -= base_dist[code]; + send_bits(s, dist, extra); + } } + } while (lx < s.last_lit); + } + send_code(s, END_BLOCK, ltree); + } + function build_tree(s, desc) { + var tree = desc.dyn_tree; + var stree = desc.stat_desc.static_tree; + var has_stree = desc.stat_desc.has_stree; + var elems = desc.stat_desc.elems; + var n, m; + var max_code = -1; + var node; + s.heap_len = 0; + s.heap_max = HEAP_SIZE; + for (n = 0; n < elems; n++) { + if (tree[n * 2] !== 0) { + s.heap[++s.heap_len] = max_code = n; + s.depth[n] = 0; + } else { + tree[n * 2 + 1] = 0; } - strategyIsBlock() { - return this.storeOptions.strategy === 3; + } + while (s.heap_len < 2) { + node = s.heap[++s.heap_len] = max_code < 2 ? ++max_code : 0; + tree[node * 2] = 1; + s.depth[node] = 0; + s.opt_len--; + if (has_stree) { + s.static_len -= stree[node * 2 + 1]; } - async __submit__(queueLength, weight) { - var blocked, now, reachedHWM; - await this.yieldLoop(); - if (this.storeOptions.maxConcurrent != null && weight > this.storeOptions.maxConcurrent) { - throw new BottleneckError$2(`Impossible to add a job having a weight of ${weight} to a limiter having a maxConcurrent setting of ${this.storeOptions.maxConcurrent}`); - } - now = Date.now(); - reachedHWM = this.storeOptions.highWater != null && queueLength === this.storeOptions.highWater && !this.check(weight, now); - blocked = this.strategyIsBlock() && (reachedHWM || this.isBlocked(now)); - if (blocked) { - this._unblockTime = now + this.computePenalty(); - this._nextRequest = this._unblockTime + this.storeOptions.minTime; - this.instance._dropAllQueued(); + } + desc.max_code = max_code; + for (n = s.heap_len >> 1; n >= 1; n--) { + pqdownheap(s, tree, n); + } + node = elems; + do { + n = s.heap[ + 1 + /*SMALLEST*/ + ]; + s.heap[ + 1 + /*SMALLEST*/ + ] = s.heap[s.heap_len--]; + pqdownheap( + s, + tree, + 1 + /*SMALLEST*/ + ); + m = s.heap[ + 1 + /*SMALLEST*/ + ]; + s.heap[--s.heap_max] = n; + s.heap[--s.heap_max] = m; + tree[node * 2] = tree[n * 2] + tree[m * 2]; + s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1; + tree[n * 2 + 1] = tree[m * 2 + 1] = node; + s.heap[ + 1 + /*SMALLEST*/ + ] = node++; + pqdownheap( + s, + tree, + 1 + /*SMALLEST*/ + ); + } while (s.heap_len >= 2); + s.heap[--s.heap_max] = s.heap[ + 1 + /*SMALLEST*/ + ]; + gen_bitlen(s, desc); + gen_codes(tree, max_code, s.bl_count); + } + function scan_tree(s, tree, max_code) { + var n; + var prevlen = -1; + var curlen; + var nextlen = tree[0 * 2 + 1]; + var count = 0; + var max_count = 7; + var min_count = 4; + if (nextlen === 0) { + max_count = 138; + min_count = 3; + } + tree[(max_code + 1) * 2 + 1] = 65535; + for (n = 0; n <= max_code; n++) { + curlen = nextlen; + nextlen = tree[(n + 1) * 2 + 1]; + if (++count < max_count && curlen === nextlen) { + continue; + } else if (count < min_count) { + s.bl_tree[curlen * 2] += count; + } else if (curlen !== 0) { + if (curlen !== prevlen) { + s.bl_tree[curlen * 2]++; } - return { - reachedHWM, - blocked, - strategy: this.storeOptions.strategy - }; - } - async __free__(index2, weight) { - await this.yieldLoop(); - this._running -= weight; - this._done += weight; - this.instance._drainAll(this.computeCapacity()); - return { - running: this._running - }; + s.bl_tree[REP_3_6 * 2]++; + } else if (count <= 10) { + s.bl_tree[REPZ_3_10 * 2]++; + } else { + s.bl_tree[REPZ_11_138 * 2]++; } - }; - var LocalDatastore_1 = LocalDatastore; - var BottleneckError$3, States; - BottleneckError$3 = BottleneckError_1; - States = class States { - constructor(status1) { - this.status = status1; - this._jobs = {}; - this.counts = this.status.map(function() { - return 0; - }); + count = 0; + prevlen = curlen; + if (nextlen === 0) { + max_count = 138; + min_count = 3; + } else if (curlen === nextlen) { + max_count = 6; + min_count = 3; + } else { + max_count = 7; + min_count = 4; } - next(id) { - var current, next; - current = this._jobs[id]; - next = current + 1; - if (current != null && next < this.status.length) { - this.counts[current]--; - this.counts[next]++; - return this._jobs[id]++; - } else if (current != null) { - this.counts[current]--; - return delete this._jobs[id]; + } + } + function send_tree(s, tree, max_code) { + var n; + var prevlen = -1; + var curlen; + var nextlen = tree[0 * 2 + 1]; + var count = 0; + var max_count = 7; + var min_count = 4; + if (nextlen === 0) { + max_count = 138; + min_count = 3; + } + for (n = 0; n <= max_code; n++) { + curlen = nextlen; + nextlen = tree[(n + 1) * 2 + 1]; + if (++count < max_count && curlen === nextlen) { + continue; + } else if (count < min_count) { + do { + send_code(s, curlen, s.bl_tree); + } while (--count !== 0); + } else if (curlen !== 0) { + if (curlen !== prevlen) { + send_code(s, curlen, s.bl_tree); + count--; } + send_code(s, REP_3_6, s.bl_tree); + send_bits(s, count - 3, 2); + } else if (count <= 10) { + send_code(s, REPZ_3_10, s.bl_tree); + send_bits(s, count - 3, 3); + } else { + send_code(s, REPZ_11_138, s.bl_tree); + send_bits(s, count - 11, 7); } - start(id) { - var initial; - initial = 0; - this._jobs[id] = initial; - return this.counts[initial]++; - } - remove(id) { - var current; - current = this._jobs[id]; - if (current != null) { - this.counts[current]--; - delete this._jobs[id]; - } - return current != null; + count = 0; + prevlen = curlen; + if (nextlen === 0) { + max_count = 138; + min_count = 3; + } else if (curlen === nextlen) { + max_count = 6; + min_count = 3; + } else { + max_count = 7; + min_count = 4; } - jobStatus(id) { - var ref; - return (ref = this.status[this._jobs[id]]) != null ? ref : null; + } + } + function build_bl_tree(s) { + var max_blindex; + scan_tree(s, s.dyn_ltree, s.l_desc.max_code); + scan_tree(s, s.dyn_dtree, s.d_desc.max_code); + build_tree(s, s.bl_desc); + for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) { + if (s.bl_tree[bl_order[max_blindex] * 2 + 1] !== 0) { + break; } - statusJobs(status2) { - var k, pos, ref, results, v; - if (status2 != null) { - pos = this.status.indexOf(status2); - if (pos < 0) { - throw new BottleneckError$3(`status must be one of ${this.status.join(", ")}`); - } - ref = this._jobs; - results = []; - for (k in ref) { - v = ref[k]; - if (v === pos) { - results.push(k); - } - } - return results; - } else { - return Object.keys(this._jobs); - } + } + s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4; + return max_blindex; + } + function send_all_trees(s, lcodes, dcodes, blcodes) { + var rank; + send_bits(s, lcodes - 257, 5); + send_bits(s, dcodes - 1, 5); + send_bits(s, blcodes - 4, 4); + for (rank = 0; rank < blcodes; rank++) { + send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1], 3); + } + send_tree(s, s.dyn_ltree, lcodes - 1); + send_tree(s, s.dyn_dtree, dcodes - 1); + } + function detect_data_type(s) { + var black_mask = 4093624447; + var n; + for (n = 0; n <= 31; n++, black_mask >>>= 1) { + if (black_mask & 1 && s.dyn_ltree[n * 2] !== 0) { + return Z_BINARY; } - statusCounts() { - return this.counts.reduce((acc, v, i) => { - acc[this.status[i]] = v; - return acc; - }, {}); + } + if (s.dyn_ltree[9 * 2] !== 0 || s.dyn_ltree[10 * 2] !== 0 || s.dyn_ltree[13 * 2] !== 0) { + return Z_TEXT; + } + for (n = 32; n < LITERALS; n++) { + if (s.dyn_ltree[n * 2] !== 0) { + return Z_TEXT; } - }; - var States_1 = States; - var DLList$2, Sync; - DLList$2 = DLList_1; - Sync = class Sync { - constructor(name, Promise2) { - this.schedule = this.schedule.bind(this); - this.name = name; - this.Promise = Promise2; - this._running = 0; - this._queue = new DLList$2(); + } + return Z_BINARY; + } + var static_init_done = false; + function _tr_init(s) { + if (!static_init_done) { + tr_static_init(); + static_init_done = true; + } + s.l_desc = new TreeDesc(s.dyn_ltree, static_l_desc); + s.d_desc = new TreeDesc(s.dyn_dtree, static_d_desc); + s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc); + s.bi_buf = 0; + s.bi_valid = 0; + init_block(s); + } + function _tr_stored_block(s, buf, stored_len, last) { + send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3); + copy_block(s, buf, stored_len, true); + } + function _tr_align(s) { + send_bits(s, STATIC_TREES << 1, 3); + send_code(s, END_BLOCK, static_ltree); + bi_flush(s); + } + function _tr_flush_block(s, buf, stored_len, last) { + var opt_lenb, static_lenb; + var max_blindex = 0; + if (s.level > 0) { + if (s.strm.data_type === Z_UNKNOWN) { + s.strm.data_type = detect_data_type(s); } - isEmpty() { - return this._queue.length === 0; + build_tree(s, s.l_desc); + build_tree(s, s.d_desc); + max_blindex = build_bl_tree(s); + opt_lenb = s.opt_len + 3 + 7 >>> 3; + static_lenb = s.static_len + 3 + 7 >>> 3; + if (static_lenb <= opt_lenb) { + opt_lenb = static_lenb; } - async _tryToRun() { - var args, cb, error, reject, resolve, returned, task; - if (this._running < 1 && this._queue.length > 0) { - this._running++; - ({ task, args, resolve, reject } = this._queue.shift()); - cb = await async function() { - try { - returned = await task(...args); - return function() { - return resolve(returned); - }; - } catch (error1) { - error = error1; - return function() { - return reject(error); - }; - } - }(); - this._running--; - this._tryToRun(); - return cb(); - } + } else { + opt_lenb = static_lenb = stored_len + 5; + } + if (stored_len + 4 <= opt_lenb && buf !== -1) { + _tr_stored_block(s, buf, stored_len, last); + } else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) { + send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3); + compress_block(s, static_ltree, static_dtree); + } else { + send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3); + send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1); + compress_block(s, s.dyn_ltree, s.dyn_dtree); + } + init_block(s); + if (last) { + bi_windup(s); + } + } + function _tr_tally(s, dist, lc) { + s.pending_buf[s.d_buf + s.last_lit * 2] = dist >>> 8 & 255; + s.pending_buf[s.d_buf + s.last_lit * 2 + 1] = dist & 255; + s.pending_buf[s.l_buf + s.last_lit] = lc & 255; + s.last_lit++; + if (dist === 0) { + s.dyn_ltree[lc * 2]++; + } else { + s.matches++; + dist--; + s.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2]++; + s.dyn_dtree[d_code(dist) * 2]++; + } + return s.last_lit === s.lit_bufsize - 1; + } + exports2._tr_init = _tr_init; + exports2._tr_stored_block = _tr_stored_block; + exports2._tr_flush_block = _tr_flush_block; + exports2._tr_tally = _tr_tally; + exports2._tr_align = _tr_align; + } +}); + +// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/adler32.js +var require_adler32 = __commonJS({ + "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/adler32.js"(exports2, module2) { + "use strict"; + function adler32(adler, buf, len, pos) { + var s1 = adler & 65535 | 0, s2 = adler >>> 16 & 65535 | 0, n = 0; + while (len !== 0) { + n = len > 2e3 ? 2e3 : len; + len -= n; + do { + s1 = s1 + buf[pos++] | 0; + s2 = s2 + s1 | 0; + } while (--n); + s1 %= 65521; + s2 %= 65521; + } + return s1 | s2 << 16 | 0; + } + module2.exports = adler32; + } +}); + +// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/crc32.js +var require_crc322 = __commonJS({ + "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/crc32.js"(exports2, module2) { + "use strict"; + function makeTable() { + var c, table = []; + for (var n = 0; n < 256; n++) { + c = n; + for (var k = 0; k < 8; k++) { + c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1; } - schedule(task, ...args) { - var promise, reject, resolve; - resolve = reject = null; - promise = new this.Promise(function(_resolve, _reject) { - resolve = _resolve; - return reject = _reject; - }); - this._queue.push({ task, args, resolve, reject }); - this._tryToRun(); - return promise; + table[n] = c; + } + return table; + } + var crcTable = makeTable(); + function crc322(crc, buf, len, pos) { + var t = crcTable, end = pos + len; + crc ^= -1; + for (var i = pos; i < end; i++) { + crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 255]; + } + return crc ^ -1; + } + module2.exports = crc322; + } +}); + +// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/messages.js +var require_messages = __commonJS({ + "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/messages.js"(exports2, module2) { + "use strict"; + module2.exports = { + 2: "need dictionary", + /* Z_NEED_DICT 2 */ + 1: "stream end", + /* Z_STREAM_END 1 */ + 0: "", + /* Z_OK 0 */ + "-1": "file error", + /* Z_ERRNO (-1) */ + "-2": "stream error", + /* Z_STREAM_ERROR (-2) */ + "-3": "data error", + /* Z_DATA_ERROR (-3) */ + "-4": "insufficient memory", + /* Z_MEM_ERROR (-4) */ + "-5": "buffer error", + /* Z_BUF_ERROR (-5) */ + "-6": "incompatible version" + /* Z_VERSION_ERROR (-6) */ + }; + } +}); + +// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/deflate.js +var require_deflate = __commonJS({ + "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/deflate.js"(exports2) { + "use strict"; + var utils = require_common(); + var trees = require_trees(); + var adler32 = require_adler32(); + var crc322 = require_crc322(); + var msg = require_messages(); + var Z_NO_FLUSH = 0; + var Z_PARTIAL_FLUSH = 1; + var Z_FULL_FLUSH = 3; + var Z_FINISH = 4; + var Z_BLOCK = 5; + var Z_OK = 0; + var Z_STREAM_END = 1; + var Z_STREAM_ERROR = -2; + var Z_DATA_ERROR = -3; + var Z_BUF_ERROR = -5; + var Z_DEFAULT_COMPRESSION = -1; + var Z_FILTERED = 1; + var Z_HUFFMAN_ONLY = 2; + var Z_RLE = 3; + var Z_FIXED = 4; + var Z_DEFAULT_STRATEGY = 0; + var Z_UNKNOWN = 2; + var Z_DEFLATED = 8; + var MAX_MEM_LEVEL = 9; + var MAX_WBITS = 15; + var DEF_MEM_LEVEL = 8; + var LENGTH_CODES = 29; + var LITERALS = 256; + var L_CODES = LITERALS + 1 + LENGTH_CODES; + var D_CODES = 30; + var BL_CODES = 19; + var HEAP_SIZE = 2 * L_CODES + 1; + var MAX_BITS = 15; + var MIN_MATCH = 3; + var MAX_MATCH = 258; + var MIN_LOOKAHEAD = MAX_MATCH + MIN_MATCH + 1; + var PRESET_DICT = 32; + var INIT_STATE = 42; + var EXTRA_STATE = 69; + var NAME_STATE = 73; + var COMMENT_STATE = 91; + var HCRC_STATE = 103; + var BUSY_STATE = 113; + var FINISH_STATE = 666; + var BS_NEED_MORE = 1; + var BS_BLOCK_DONE = 2; + var BS_FINISH_STARTED = 3; + var BS_FINISH_DONE = 4; + var OS_CODE = 3; + function err(strm, errorCode) { + strm.msg = msg[errorCode]; + return errorCode; + } + function rank(f) { + return (f << 1) - (f > 4 ? 9 : 0); + } + function zero(buf) { + var len = buf.length; + while (--len >= 0) { + buf[len] = 0; + } + } + function flush_pending(strm) { + var s = strm.state; + var len = s.pending; + if (len > strm.avail_out) { + len = strm.avail_out; + } + if (len === 0) { + return; + } + utils.arraySet(strm.output, s.pending_buf, s.pending_out, len, strm.next_out); + strm.next_out += len; + s.pending_out += len; + strm.total_out += len; + strm.avail_out -= len; + s.pending -= len; + if (s.pending === 0) { + s.pending_out = 0; + } + } + function flush_block_only(s, last) { + trees._tr_flush_block(s, s.block_start >= 0 ? s.block_start : -1, s.strstart - s.block_start, last); + s.block_start = s.strstart; + flush_pending(s.strm); + } + function put_byte(s, b) { + s.pending_buf[s.pending++] = b; + } + function putShortMSB(s, b) { + s.pending_buf[s.pending++] = b >>> 8 & 255; + s.pending_buf[s.pending++] = b & 255; + } + function read_buf(strm, buf, start, size) { + var len = strm.avail_in; + if (len > size) { + len = size; + } + if (len === 0) { + return 0; + } + strm.avail_in -= len; + utils.arraySet(buf, strm.input, strm.next_in, len, start); + if (strm.state.wrap === 1) { + strm.adler = adler32(strm.adler, buf, len, start); + } else if (strm.state.wrap === 2) { + strm.adler = crc322(strm.adler, buf, len, start); + } + strm.next_in += len; + strm.total_in += len; + return len; + } + function longest_match(s, cur_match) { + var chain_length = s.max_chain_length; + var scan = s.strstart; + var match; + var len; + var best_len = s.prev_length; + var nice_match = s.nice_match; + var limit = s.strstart > s.w_size - MIN_LOOKAHEAD ? s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0; + var _win = s.window; + var wmask = s.w_mask; + var prev = s.prev; + var strend = s.strstart + MAX_MATCH; + var scan_end1 = _win[scan + best_len - 1]; + var scan_end = _win[scan + best_len]; + if (s.prev_length >= s.good_match) { + chain_length >>= 2; + } + if (nice_match > s.lookahead) { + nice_match = s.lookahead; + } + do { + match = cur_match; + if (_win[match + best_len] !== scan_end || _win[match + best_len - 1] !== scan_end1 || _win[match] !== _win[scan] || _win[++match] !== _win[scan + 1]) { + continue; } - }; - var Sync_1 = Sync; - var version3 = "2.19.5"; - var version$1 = { - version: version3 - }; - var version$2 = /* @__PURE__ */ Object.freeze({ - version: version3, - default: version$1 - }); - var require$$2 = () => console.log("You must import the full version of Bottleneck in order to use this feature."); - var require$$3 = () => console.log("You must import the full version of Bottleneck in order to use this feature."); - var require$$4 = () => console.log("You must import the full version of Bottleneck in order to use this feature."); - var Events$2, Group, IORedisConnection$1, RedisConnection$1, Scripts$1, parser$3; - parser$3 = parser; - Events$2 = Events_1; - RedisConnection$1 = require$$2; - IORedisConnection$1 = require$$3; - Scripts$1 = require$$4; - Group = function() { - class Group2 { - constructor(limiterOptions = {}) { - this.deleteKey = this.deleteKey.bind(this); - this.limiterOptions = limiterOptions; - parser$3.load(this.limiterOptions, this.defaults, this); - this.Events = new Events$2(this); - this.instances = {}; - this.Bottleneck = Bottleneck_1; - this._startAutoCleanup(); - this.sharedConnection = this.connection != null; - if (this.connection == null) { - if (this.limiterOptions.datastore === "redis") { - this.connection = new RedisConnection$1(Object.assign({}, this.limiterOptions, { Events: this.Events })); - } else if (this.limiterOptions.datastore === "ioredis") { - this.connection = new IORedisConnection$1(Object.assign({}, this.limiterOptions, { Events: this.Events })); - } - } - } - key(key = "") { - var ref; - return (ref = this.instances[key]) != null ? ref : (() => { - var limiter; - limiter = this.instances[key] = new this.Bottleneck(Object.assign(this.limiterOptions, { - id: `${this.id}-${key}`, - timeout: this.timeout, - connection: this.connection - })); - this.Events.trigger("created", limiter, key); - return limiter; - })(); - } - async deleteKey(key = "") { - var deleted, instance; - instance = this.instances[key]; - if (this.connection) { - deleted = await this.connection.__runCommand__(["del", ...Scripts$1.allKeys(`${this.id}-${key}`)]); - } - if (instance != null) { - delete this.instances[key]; - await instance.disconnect(); - } - return instance != null || deleted > 0; - } - limiters() { - var k, ref, results, v; - ref = this.instances; - results = []; - for (k in ref) { - v = ref[k]; - results.push({ - key: k, - limiter: v - }); - } - return results; - } - keys() { - return Object.keys(this.instances); + scan += 2; + match++; + do { + } while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && scan < strend); + len = MAX_MATCH - (strend - scan); + scan = strend - MAX_MATCH; + if (len > best_len) { + s.match_start = cur_match; + best_len = len; + if (len >= nice_match) { + break; } - async clusterKeys() { - var cursor, end, found, i, k, keys, len, next, start; - if (this.connection == null) { - return this.Promise.resolve(this.keys()); - } - keys = []; - cursor = null; - start = `b_${this.id}-`.length; - end = "_settings".length; - while (cursor !== 0) { - [next, found] = await this.connection.__runCommand__(["scan", cursor != null ? cursor : 0, "match", `b_${this.id}-*_settings`, "count", 1e4]); - cursor = ~~next; - for (i = 0, len = found.length; i < len; i++) { - k = found[i]; - keys.push(k.slice(start, -end)); - } + scan_end1 = _win[scan + best_len - 1]; + scan_end = _win[scan + best_len]; + } + } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0); + if (best_len <= s.lookahead) { + return best_len; + } + return s.lookahead; + } + function fill_window(s) { + var _w_size = s.w_size; + var p, n, m, more, str; + do { + more = s.window_size - s.lookahead - s.strstart; + if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) { + utils.arraySet(s.window, s.window, _w_size, _w_size, 0); + s.match_start -= _w_size; + s.strstart -= _w_size; + s.block_start -= _w_size; + n = s.hash_size; + p = n; + do { + m = s.head[--p]; + s.head[p] = m >= _w_size ? m - _w_size : 0; + } while (--n); + n = _w_size; + p = n; + do { + m = s.prev[--p]; + s.prev[p] = m >= _w_size ? m - _w_size : 0; + } while (--n); + more += _w_size; + } + if (s.strm.avail_in === 0) { + break; + } + n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more); + s.lookahead += n; + if (s.lookahead + s.insert >= MIN_MATCH) { + str = s.strstart - s.insert; + s.ins_h = s.window[str]; + s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str + 1]) & s.hash_mask; + while (s.insert) { + s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask; + s.prev[str & s.w_mask] = s.head[s.ins_h]; + s.head[s.ins_h] = str; + str++; + s.insert--; + if (s.lookahead + s.insert < MIN_MATCH) { + break; } - return keys; } - _startAutoCleanup() { - var base; - clearInterval(this.interval); - return typeof (base = this.interval = setInterval(async () => { - var e, k, ref, results, time, v; - time = Date.now(); - ref = this.instances; - results = []; - for (k in ref) { - v = ref[k]; - try { - if (await v._store.__groupCheck__(time)) { - results.push(this.deleteKey(k)); - } else { - results.push(void 0); - } - } catch (error) { - e = error; - results.push(v.Events.trigger("error", e)); - } - } - return results; - }, this.timeout / 2)).unref === "function" ? base.unref() : void 0; + } + } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0); + } + function deflate_stored(s, flush) { + var max_block_size = 65535; + if (max_block_size > s.pending_buf_size - 5) { + max_block_size = s.pending_buf_size - 5; + } + for (; ; ) { + if (s.lookahead <= 1) { + fill_window(s); + if (s.lookahead === 0 && flush === Z_NO_FLUSH) { + return BS_NEED_MORE; } - updateSettings(options = {}) { - parser$3.overwrite(options, this.defaults, this); - parser$3.overwrite(options, options, this.limiterOptions); - if (options.timeout != null) { - return this._startAutoCleanup(); - } + if (s.lookahead === 0) { + break; } - disconnect(flush = true) { - var ref; - if (!this.sharedConnection) { - return (ref = this.connection) != null ? ref.disconnect(flush) : void 0; - } + } + s.strstart += s.lookahead; + s.lookahead = 0; + var max_start = s.block_start + max_block_size; + if (s.strstart === 0 || s.strstart >= max_start) { + s.lookahead = s.strstart - max_start; + s.strstart = max_start; + flush_block_only(s, false); + if (s.strm.avail_out === 0) { + return BS_NEED_MORE; } } - Group2.prototype.defaults = { - timeout: 1e3 * 60 * 5, - connection: null, - Promise, - id: "group-key" - }; - return Group2; - }.call(commonjsGlobal); - var Group_1 = Group; - var Batcher, Events$3, parser$4; - parser$4 = parser; - Events$3 = Events_1; - Batcher = function() { - class Batcher2 { - constructor(options = {}) { - this.options = options; - parser$4.load(this.options, this.defaults, this); - this.Events = new Events$3(this); - this._arr = []; - this._resetPromise(); - this._lastFlush = Date.now(); + if (s.strstart - s.block_start >= s.w_size - MIN_LOOKAHEAD) { + flush_block_only(s, false); + if (s.strm.avail_out === 0) { + return BS_NEED_MORE; } - _resetPromise() { - return this._promise = new this.Promise((res, rej) => { - return this._resolve = res; - }); + } + } + s.insert = 0; + if (flush === Z_FINISH) { + flush_block_only(s, true); + if (s.strm.avail_out === 0) { + return BS_FINISH_STARTED; + } + return BS_FINISH_DONE; + } + if (s.strstart > s.block_start) { + flush_block_only(s, false); + if (s.strm.avail_out === 0) { + return BS_NEED_MORE; + } + } + return BS_NEED_MORE; + } + function deflate_fast(s, flush) { + var hash_head; + var bflush; + for (; ; ) { + if (s.lookahead < MIN_LOOKAHEAD) { + fill_window(s); + if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) { + return BS_NEED_MORE; } - _flush() { - clearTimeout(this._timeout); - this._lastFlush = Date.now(); - this._resolve(); - this.Events.trigger("batch", this._arr); - this._arr = []; - return this._resetPromise(); + if (s.lookahead === 0) { + break; } - add(data) { - var ret; - this._arr.push(data); - ret = this._promise; - if (this._arr.length === this.maxSize) { - this._flush(); - } else if (this.maxTime != null && this._arr.length === 1) { - this._timeout = setTimeout(() => { - return this._flush(); - }, this.maxTime); - } - return ret; + } + hash_head = 0; + if (s.lookahead >= MIN_MATCH) { + s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask; + hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h]; + s.head[s.ins_h] = s.strstart; + } + if (hash_head !== 0 && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD) { + s.match_length = longest_match(s, hash_head); + } + if (s.match_length >= MIN_MATCH) { + bflush = trees._tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH); + s.lookahead -= s.match_length; + if (s.match_length <= s.max_lazy_match && s.lookahead >= MIN_MATCH) { + s.match_length--; + do { + s.strstart++; + s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask; + hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h]; + s.head[s.ins_h] = s.strstart; + } while (--s.match_length !== 0); + s.strstart++; + } else { + s.strstart += s.match_length; + s.match_length = 0; + s.ins_h = s.window[s.strstart]; + s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + 1]) & s.hash_mask; } + } else { + bflush = trees._tr_tally(s, 0, s.window[s.strstart]); + s.lookahead--; + s.strstart++; } - Batcher2.prototype.defaults = { - maxTime: null, - maxSize: null, - Promise - }; - return Batcher2; - }.call(commonjsGlobal); - var Batcher_1 = Batcher; - var require$$4$1 = () => console.log("You must import the full version of Bottleneck in order to use this feature."); - var require$$8 = getCjsExportFromNamespace(version$2); - var Bottleneck, DEFAULT_PRIORITY$1, Events$4, Job$1, LocalDatastore$1, NUM_PRIORITIES$1, Queues$1, RedisDatastore$1, States$1, Sync$1, parser$5, splice = [].splice; - NUM_PRIORITIES$1 = 10; - DEFAULT_PRIORITY$1 = 5; - parser$5 = parser; - Queues$1 = Queues_1; - Job$1 = Job_1; - LocalDatastore$1 = LocalDatastore_1; - RedisDatastore$1 = require$$4$1; - Events$4 = Events_1; - States$1 = States_1; - Sync$1 = Sync_1; - Bottleneck = function() { - class Bottleneck2 { - constructor(options = {}, ...invalid) { - var storeInstanceOptions, storeOptions; - this._addToQueue = this._addToQueue.bind(this); - this._validateOptions(options, invalid); - parser$5.load(options, this.instanceDefaults, this); - this._queues = new Queues$1(NUM_PRIORITIES$1); - this._scheduled = {}; - this._states = new States$1(["RECEIVED", "QUEUED", "RUNNING", "EXECUTING"].concat(this.trackDoneStatus ? ["DONE"] : [])); - this._limiter = null; - this.Events = new Events$4(this); - this._submitLock = new Sync$1("submit", this.Promise); - this._registerLock = new Sync$1("register", this.Promise); - storeOptions = parser$5.load(options, this.storeDefaults, {}); - this._store = function() { - if (this.datastore === "redis" || this.datastore === "ioredis" || this.connection != null) { - storeInstanceOptions = parser$5.load(options, this.redisStoreDefaults, {}); - return new RedisDatastore$1(this, storeOptions, storeInstanceOptions); - } else if (this.datastore === "local") { - storeInstanceOptions = parser$5.load(options, this.localStoreDefaults, {}); - return new LocalDatastore$1(this, storeOptions, storeInstanceOptions); - } else { - throw new Bottleneck2.prototype.BottleneckError(`Invalid datastore type: ${this.datastore}`); - } - }.call(this); - this._queues.on("leftzero", () => { - var ref; - return (ref = this._store.heartbeat) != null ? typeof ref.ref === "function" ? ref.ref() : void 0 : void 0; - }); - this._queues.on("zero", () => { - var ref; - return (ref = this._store.heartbeat) != null ? typeof ref.unref === "function" ? ref.unref() : void 0 : void 0; - }); - } - _validateOptions(options, invalid) { - if (!(options != null && typeof options === "object" && invalid.length === 0)) { - throw new Bottleneck2.prototype.BottleneckError("Bottleneck v2 takes a single object argument. Refer to https://github.com/SGrondin/bottleneck#upgrading-to-v2 if you're upgrading from Bottleneck v1."); - } - } - ready() { - return this._store.ready; - } - clients() { - return this._store.clients; - } - channel() { - return `b_${this.id}`; - } - channel_client() { - return `b_${this.id}_${this._store.clientId}`; - } - publish(message) { - return this._store.__publish__(message); - } - disconnect(flush = true) { - return this._store.__disconnect__(flush); - } - chain(_limiter) { - this._limiter = _limiter; - return this; - } - queued(priority) { - return this._queues.queued(priority); - } - clusterQueued() { - return this._store.__queued__(); - } - empty() { - return this.queued() === 0 && this._submitLock.isEmpty(); - } - running() { - return this._store.__running__(); - } - done() { - return this._store.__done__(); - } - jobStatus(id) { - return this._states.jobStatus(id); - } - jobs(status2) { - return this._states.statusJobs(status2); + if (bflush) { + flush_block_only(s, false); + if (s.strm.avail_out === 0) { + return BS_NEED_MORE; } - counts() { - return this._states.statusCounts(); + } + } + s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1; + if (flush === Z_FINISH) { + flush_block_only(s, true); + if (s.strm.avail_out === 0) { + return BS_FINISH_STARTED; + } + return BS_FINISH_DONE; + } + if (s.last_lit) { + flush_block_only(s, false); + if (s.strm.avail_out === 0) { + return BS_NEED_MORE; + } + } + return BS_BLOCK_DONE; + } + function deflate_slow(s, flush) { + var hash_head; + var bflush; + var max_insert; + for (; ; ) { + if (s.lookahead < MIN_LOOKAHEAD) { + fill_window(s); + if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) { + return BS_NEED_MORE; } - _randomIndex() { - return Math.random().toString(36).slice(2); + if (s.lookahead === 0) { + break; } - check(weight = 1) { - return this._store.__check__(weight); + } + hash_head = 0; + if (s.lookahead >= MIN_MATCH) { + s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask; + hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h]; + s.head[s.ins_h] = s.strstart; + } + s.prev_length = s.match_length; + s.prev_match = s.match_start; + s.match_length = MIN_MATCH - 1; + if (hash_head !== 0 && s.prev_length < s.max_lazy_match && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD) { + s.match_length = longest_match(s, hash_head); + if (s.match_length <= 5 && (s.strategy === Z_FILTERED || s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096)) { + s.match_length = MIN_MATCH - 1; } - _clearGlobalState(index2) { - if (this._scheduled[index2] != null) { - clearTimeout(this._scheduled[index2].expiration); - delete this._scheduled[index2]; - return true; - } else { - return false; + } + if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) { + max_insert = s.strstart + s.lookahead - MIN_MATCH; + bflush = trees._tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH); + s.lookahead -= s.prev_length - 1; + s.prev_length -= 2; + do { + if (++s.strstart <= max_insert) { + s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask; + hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h]; + s.head[s.ins_h] = s.strstart; } - } - async _free(index2, job, options, eventInfo) { - var e, running; - try { - ({ running } = await this._store.__free__(index2, options.weight)); - this.Events.trigger("debug", `Freed ${options.id}`, eventInfo); - if (running === 0 && this.empty()) { - return this.Events.trigger("idle"); - } - } catch (error1) { - e = error1; - return this.Events.trigger("error", e); + } while (--s.prev_length !== 0); + s.match_available = 0; + s.match_length = MIN_MATCH - 1; + s.strstart++; + if (bflush) { + flush_block_only(s, false); + if (s.strm.avail_out === 0) { + return BS_NEED_MORE; } } - _run(index2, job, wait) { - var clearGlobalState, free, run2; - job.doRun(); - clearGlobalState = this._clearGlobalState.bind(this, index2); - run2 = this._run.bind(this, index2, job); - free = this._free.bind(this, index2, job); - return this._scheduled[index2] = { - timeout: setTimeout(() => { - return job.doExecute(this._limiter, clearGlobalState, run2, free); - }, wait), - expiration: job.options.expiration != null ? setTimeout(function() { - return job.doExpire(clearGlobalState, run2, free); - }, wait + job.options.expiration) : void 0, - job - }; - } - _drainOne(capacity) { - return this._registerLock.schedule(() => { - var args, index2, next, options, queue; - if (this.queued() === 0) { - return this.Promise.resolve(null); - } - queue = this._queues.getFirst(); - ({ options, args } = next = queue.first()); - if (capacity != null && options.weight > capacity) { - return this.Promise.resolve(null); - } - this.Events.trigger("debug", `Draining ${options.id}`, { args, options }); - index2 = this._randomIndex(); - return this._store.__register__(index2, options.weight, options.expiration).then(({ success, wait, reservoir }) => { - var empty; - this.Events.trigger("debug", `Drained ${options.id}`, { success, args, options }); - if (success) { - queue.shift(); - empty = this.empty(); - if (empty) { - this.Events.trigger("empty"); - } - if (reservoir === 0) { - this.Events.trigger("depleted", empty); - } - this._run(index2, next, wait); - return this.Promise.resolve(options.weight); - } else { - return this.Promise.resolve(null); - } - }); - }); - } - _drainAll(capacity, total = 0) { - return this._drainOne(capacity).then((drained) => { - var newCapacity; - if (drained != null) { - newCapacity = capacity != null ? capacity - drained : capacity; - return this._drainAll(newCapacity, total + drained); - } else { - return this.Promise.resolve(total); - } - }).catch((e) => { - return this.Events.trigger("error", e); - }); + } else if (s.match_available) { + bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]); + if (bflush) { + flush_block_only(s, false); } - _dropAllQueued(message) { - return this._queues.shiftAll(function(job) { - return job.doDrop({ message }); - }); + s.strstart++; + s.lookahead--; + if (s.strm.avail_out === 0) { + return BS_NEED_MORE; } - stop(options = {}) { - var done, waitForExecuting; - options = parser$5.load(options, this.stopDefaults); - waitForExecuting = (at) => { - var finished; - finished = () => { - var counts; - counts = this._states.counts; - return counts[0] + counts[1] + counts[2] + counts[3] === at; - }; - return new this.Promise((resolve, reject) => { - if (finished()) { - return resolve(); - } else { - return this.on("done", () => { - if (finished()) { - this.removeAllListeners("done"); - return resolve(); - } - }); - } - }); - }; - done = options.dropWaitingJobs ? (this._run = function(index2, next) { - return next.doDrop({ - message: options.dropErrorMessage - }); - }, this._drainOne = () => { - return this.Promise.resolve(null); - }, this._registerLock.schedule(() => { - return this._submitLock.schedule(() => { - var k, ref, v; - ref = this._scheduled; - for (k in ref) { - v = ref[k]; - if (this.jobStatus(v.job.options.id) === "RUNNING") { - clearTimeout(v.timeout); - clearTimeout(v.expiration); - v.job.doDrop({ - message: options.dropErrorMessage - }); - } - } - this._dropAllQueued(options.dropErrorMessage); - return waitForExecuting(0); - }); - })) : this.schedule({ - priority: NUM_PRIORITIES$1 - 1, - weight: 0 - }, () => { - return waitForExecuting(1); - }); - this._receive = function(job) { - return job._reject(new Bottleneck2.prototype.BottleneckError(options.enqueueErrorMessage)); - }; - this.stop = () => { - return this.Promise.reject(new Bottleneck2.prototype.BottleneckError("stop() has already been called")); - }; - return done; + } else { + s.match_available = 1; + s.strstart++; + s.lookahead--; + } + } + if (s.match_available) { + bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]); + s.match_available = 0; + } + s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1; + if (flush === Z_FINISH) { + flush_block_only(s, true); + if (s.strm.avail_out === 0) { + return BS_FINISH_STARTED; + } + return BS_FINISH_DONE; + } + if (s.last_lit) { + flush_block_only(s, false); + if (s.strm.avail_out === 0) { + return BS_NEED_MORE; + } + } + return BS_BLOCK_DONE; + } + function deflate_rle(s, flush) { + var bflush; + var prev; + var scan, strend; + var _win = s.window; + for (; ; ) { + if (s.lookahead <= MAX_MATCH) { + fill_window(s); + if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH) { + return BS_NEED_MORE; } - async _addToQueue(job) { - var args, blocked, error, options, reachedHWM, shifted, strategy; - ({ args, options } = job); - try { - ({ reachedHWM, blocked, strategy } = await this._store.__submit__(this.queued(), options.weight)); - } catch (error1) { - error = error1; - this.Events.trigger("debug", `Could not queue ${options.id}`, { args, options, error }); - job.doDrop({ error }); - return false; - } - if (blocked) { - job.doDrop(); - return true; - } else if (reachedHWM) { - shifted = strategy === Bottleneck2.prototype.strategy.LEAK ? this._queues.shiftLastFrom(options.priority) : strategy === Bottleneck2.prototype.strategy.OVERFLOW_PRIORITY ? this._queues.shiftLastFrom(options.priority + 1) : strategy === Bottleneck2.prototype.strategy.OVERFLOW ? job : void 0; - if (shifted != null) { - shifted.doDrop(); - } - if (shifted == null || strategy === Bottleneck2.prototype.strategy.OVERFLOW) { - if (shifted == null) { - job.doDrop(); - } - return reachedHWM; - } - } - job.doQueue(reachedHWM, blocked); - this._queues.push(job); - await this._drainAll(); - return reachedHWM; + if (s.lookahead === 0) { + break; } - _receive(job) { - if (this._states.jobStatus(job.options.id) != null) { - job._reject(new Bottleneck2.prototype.BottleneckError(`A job with the same id already exists (id=${job.options.id})`)); - return false; - } else { - job.doReceive(); - return this._submitLock.schedule(this._addToQueue, job); + } + s.match_length = 0; + if (s.lookahead >= MIN_MATCH && s.strstart > 0) { + scan = s.strstart - 1; + prev = _win[scan]; + if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) { + strend = s.strstart + MAX_MATCH; + do { + } while (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && scan < strend); + s.match_length = MAX_MATCH - (strend - scan); + if (s.match_length > s.lookahead) { + s.match_length = s.lookahead; } } - submit(...args) { - var cb, fn, job, options, ref, ref1, task; - if (typeof args[0] === "function") { - ref = args, [fn, ...args] = ref, [cb] = splice.call(args, -1); - options = parser$5.load({}, this.jobDefaults); - } else { - ref1 = args, [options, fn, ...args] = ref1, [cb] = splice.call(args, -1); - options = parser$5.load(options, this.jobDefaults); - } - task = (...args2) => { - return new this.Promise(function(resolve, reject) { - return fn(...args2, function(...args3) { - return (args3[0] != null ? reject : resolve)(args3); - }); - }); - }; - job = new Job$1(task, args, options, this.jobDefaults, this.rejectOnDrop, this.Events, this._states, this.Promise); - job.promise.then(function(args2) { - return typeof cb === "function" ? cb(...args2) : void 0; - }).catch(function(args2) { - if (Array.isArray(args2)) { - return typeof cb === "function" ? cb(...args2) : void 0; - } else { - return typeof cb === "function" ? cb(args2) : void 0; - } - }); - return this._receive(job); + } + if (s.match_length >= MIN_MATCH) { + bflush = trees._tr_tally(s, 1, s.match_length - MIN_MATCH); + s.lookahead -= s.match_length; + s.strstart += s.match_length; + s.match_length = 0; + } else { + bflush = trees._tr_tally(s, 0, s.window[s.strstart]); + s.lookahead--; + s.strstart++; + } + if (bflush) { + flush_block_only(s, false); + if (s.strm.avail_out === 0) { + return BS_NEED_MORE; } - schedule(...args) { - var job, options, task; - if (typeof args[0] === "function") { - [task, ...args] = args; - options = {}; - } else { - [options, task, ...args] = args; + } + } + s.insert = 0; + if (flush === Z_FINISH) { + flush_block_only(s, true); + if (s.strm.avail_out === 0) { + return BS_FINISH_STARTED; + } + return BS_FINISH_DONE; + } + if (s.last_lit) { + flush_block_only(s, false); + if (s.strm.avail_out === 0) { + return BS_NEED_MORE; + } + } + return BS_BLOCK_DONE; + } + function deflate_huff(s, flush) { + var bflush; + for (; ; ) { + if (s.lookahead === 0) { + fill_window(s); + if (s.lookahead === 0) { + if (flush === Z_NO_FLUSH) { + return BS_NEED_MORE; } - job = new Job$1(task, args, options, this.jobDefaults, this.rejectOnDrop, this.Events, this._states, this.Promise); - this._receive(job); - return job.promise; - } - wrap(fn) { - var schedule, wrapped; - schedule = this.schedule.bind(this); - wrapped = function(...args) { - return schedule(fn.bind(this), ...args); - }; - wrapped.withOptions = function(options, ...args) { - return schedule(options, fn, ...args); - }; - return wrapped; - } - async updateSettings(options = {}) { - await this._store.__updateSettings__(parser$5.overwrite(options, this.storeDefaults)); - parser$5.overwrite(options, this.instanceDefaults, this); - return this; - } - currentReservoir() { - return this._store.__currentReservoir__(); - } - incrementReservoir(incr = 0) { - return this._store.__incrementReservoir__(incr); + break; + } + } + s.match_length = 0; + bflush = trees._tr_tally(s, 0, s.window[s.strstart]); + s.lookahead--; + s.strstart++; + if (bflush) { + flush_block_only(s, false); + if (s.strm.avail_out === 0) { + return BS_NEED_MORE; } } - Bottleneck2.default = Bottleneck2; - Bottleneck2.Events = Events$4; - Bottleneck2.version = Bottleneck2.prototype.version = require$$8.version; - Bottleneck2.strategy = Bottleneck2.prototype.strategy = { - LEAK: 1, - OVERFLOW: 2, - OVERFLOW_PRIORITY: 4, - BLOCK: 3 - }; - Bottleneck2.BottleneckError = Bottleneck2.prototype.BottleneckError = BottleneckError_1; - Bottleneck2.Group = Bottleneck2.prototype.Group = Group_1; - Bottleneck2.RedisConnection = Bottleneck2.prototype.RedisConnection = require$$2; - Bottleneck2.IORedisConnection = Bottleneck2.prototype.IORedisConnection = require$$3; - Bottleneck2.Batcher = Bottleneck2.prototype.Batcher = Batcher_1; - Bottleneck2.prototype.jobDefaults = { - priority: DEFAULT_PRIORITY$1, - weight: 1, - expiration: null, - id: "" - }; - Bottleneck2.prototype.storeDefaults = { - maxConcurrent: null, - minTime: 0, - highWater: null, - strategy: Bottleneck2.prototype.strategy.LEAK, - penalty: null, - reservoir: null, - reservoirRefreshInterval: null, - reservoirRefreshAmount: null, - reservoirIncreaseInterval: null, - reservoirIncreaseAmount: null, - reservoirIncreaseMaximum: null - }; - Bottleneck2.prototype.localStoreDefaults = { - Promise, - timeout: null, - heartbeatInterval: 250 - }; - Bottleneck2.prototype.redisStoreDefaults = { - Promise, - timeout: null, - heartbeatInterval: 5e3, - clientTimeout: 1e4, - Redis: null, - clientOptions: {}, - clusterNodes: null, - clearDatastore: false, - connection: null - }; - Bottleneck2.prototype.instanceDefaults = { - datastore: "local", - connection: null, - id: "", - rejectOnDrop: true, - trackDoneStatus: false, - Promise - }; - Bottleneck2.prototype.stopDefaults = { - enqueueErrorMessage: "This limiter has been stopped and cannot accept new jobs.", - dropWaitingJobs: true, - dropErrorMessage: "This limiter has been stopped." - }; - return Bottleneck2; - }.call(commonjsGlobal); - var Bottleneck_1 = Bottleneck; - var lib = Bottleneck_1; - return lib; - }); - } -}); - -// ../../../node_modules/.pnpm/@octokit+plugin-retry@6.0.1_@octokit+core@5.2.0/node_modules/@octokit/plugin-retry/dist-node/index.js -var require_dist_node12 = __commonJS({ - "../../../node_modules/.pnpm/@octokit+plugin-retry@6.0.1_@octokit+core@5.2.0/node_modules/@octokit/plugin-retry/dist-node/index.js"(exports2, module2) { - "use strict"; - var __create2 = Object.create; - var __defProp2 = Object.defineProperty; - var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; - var __getOwnPropNames2 = Object.getOwnPropertyNames; - var __getProtoOf2 = Object.getPrototypeOf; - var __hasOwnProp2 = Object.prototype.hasOwnProperty; - var __export2 = (target, all) => { - for (var name in all) - __defProp2(target, name, { get: all[name], enumerable: true }); - }; - var __copyProps2 = (to, from3, except, desc) => { - if (from3 && typeof from3 === "object" || typeof from3 === "function") { - for (let key of __getOwnPropNames2(from3)) - if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc2(from3, key)) || desc.enumerable }); } - return to; - }; - var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2( - // If the importer is in node compatibility mode or this is not an ESM - // file that has been converted to a CommonJS file using a Babel- - // compatible transform (i.e. "__esModule" has not been set), then set - // "default" to the CommonJS "module.exports" for node compatibility. - isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target, - mod - )); - var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); - var dist_src_exports = {}; - __export2(dist_src_exports, { - VERSION: () => VERSION, - retry: () => retry - }); - module2.exports = __toCommonJS2(dist_src_exports); - var import_core = require_dist_node8(); - async function errorRequest(state, octokit, error, options) { - if (!error.request || !error.request.request) { - throw error; + s.insert = 0; + if (flush === Z_FINISH) { + flush_block_only(s, true); + if (s.strm.avail_out === 0) { + return BS_FINISH_STARTED; + } + return BS_FINISH_DONE; } - if (error.status >= 400 && !state.doNotRetry.includes(error.status)) { - const retries = options.request.retries != null ? options.request.retries : state.retries; - const retryAfter = Math.pow((options.request.retryCount || 0) + 1, 2); - throw octokit.retry.retryRequest(error, retries, retryAfter); + if (s.last_lit) { + flush_block_only(s, false); + if (s.strm.avail_out === 0) { + return BS_NEED_MORE; + } } - throw error; + return BS_BLOCK_DONE; } - var import_light = __toESM2(require_light()); - var import_request_error = require_dist_node4(); - async function wrapRequest(state, octokit, request, options) { - const limiter = new import_light.default(); - limiter.on("failed", function(error, info) { - const maxRetries2 = ~~error.request.request.retries; - const after = ~~error.request.request.retryAfter; - options.request.retryCount = info.retryCount + 1; - if (maxRetries2 > info.retryCount) { - return after * state.retryAfterBaseValue; - } - }); - return limiter.schedule( - requestWithGraphqlErrorHandling.bind(null, state, octokit, request), - options - ); + function Config(good_length, max_lazy, nice_length, max_chain, func) { + this.good_length = good_length; + this.max_lazy = max_lazy; + this.nice_length = nice_length; + this.max_chain = max_chain; + this.func = func; } - async function requestWithGraphqlErrorHandling(state, octokit, request, options) { - const response = await request(request, options); - if (response.data && response.data.errors && /Something went wrong while executing your query/.test( - response.data.errors[0].message - )) { - const error = new import_request_error.RequestError(response.data.errors[0].message, 500, { - request: options, - response - }); - return errorRequest(state, octokit, error, options); + var configuration_table; + configuration_table = [ + /* good lazy nice chain */ + new Config(0, 0, 0, 0, deflate_stored), + /* 0 store only */ + new Config(4, 4, 8, 4, deflate_fast), + /* 1 max speed, no lazy matches */ + new Config(4, 5, 16, 8, deflate_fast), + /* 2 */ + new Config(4, 6, 32, 32, deflate_fast), + /* 3 */ + new Config(4, 4, 16, 16, deflate_slow), + /* 4 lazy matches */ + new Config(8, 16, 32, 32, deflate_slow), + /* 5 */ + new Config(8, 16, 128, 128, deflate_slow), + /* 6 */ + new Config(8, 32, 128, 256, deflate_slow), + /* 7 */ + new Config(32, 128, 258, 1024, deflate_slow), + /* 8 */ + new Config(32, 258, 258, 4096, deflate_slow) + /* 9 max compression */ + ]; + function lm_init(s) { + s.window_size = 2 * s.w_size; + zero(s.head); + s.max_lazy_match = configuration_table[s.level].max_lazy; + s.good_match = configuration_table[s.level].good_length; + s.nice_match = configuration_table[s.level].nice_length; + s.max_chain_length = configuration_table[s.level].max_chain; + s.strstart = 0; + s.block_start = 0; + s.lookahead = 0; + s.insert = 0; + s.match_length = s.prev_length = MIN_MATCH - 1; + s.match_available = 0; + s.ins_h = 0; + } + function DeflateState() { + this.strm = null; + this.status = 0; + this.pending_buf = null; + this.pending_buf_size = 0; + this.pending_out = 0; + this.pending = 0; + this.wrap = 0; + this.gzhead = null; + this.gzindex = 0; + this.method = Z_DEFLATED; + this.last_flush = -1; + this.w_size = 0; + this.w_bits = 0; + this.w_mask = 0; + this.window = null; + this.window_size = 0; + this.prev = null; + this.head = null; + this.ins_h = 0; + this.hash_size = 0; + this.hash_bits = 0; + this.hash_mask = 0; + this.hash_shift = 0; + this.block_start = 0; + this.match_length = 0; + this.prev_match = 0; + this.match_available = 0; + this.strstart = 0; + this.match_start = 0; + this.lookahead = 0; + this.prev_length = 0; + this.max_chain_length = 0; + this.max_lazy_match = 0; + this.level = 0; + this.strategy = 0; + this.good_match = 0; + this.nice_match = 0; + this.dyn_ltree = new utils.Buf16(HEAP_SIZE * 2); + this.dyn_dtree = new utils.Buf16((2 * D_CODES + 1) * 2); + this.bl_tree = new utils.Buf16((2 * BL_CODES + 1) * 2); + zero(this.dyn_ltree); + zero(this.dyn_dtree); + zero(this.bl_tree); + this.l_desc = null; + this.d_desc = null; + this.bl_desc = null; + this.bl_count = new utils.Buf16(MAX_BITS + 1); + this.heap = new utils.Buf16(2 * L_CODES + 1); + zero(this.heap); + this.heap_len = 0; + this.heap_max = 0; + this.depth = new utils.Buf16(2 * L_CODES + 1); + zero(this.depth); + this.l_buf = 0; + this.lit_bufsize = 0; + this.last_lit = 0; + this.d_buf = 0; + this.opt_len = 0; + this.static_len = 0; + this.matches = 0; + this.insert = 0; + this.bi_buf = 0; + this.bi_valid = 0; + } + function deflateResetKeep(strm) { + var s; + if (!strm || !strm.state) { + return err(strm, Z_STREAM_ERROR); } - return response; + strm.total_in = strm.total_out = 0; + strm.data_type = Z_UNKNOWN; + s = strm.state; + s.pending = 0; + s.pending_out = 0; + if (s.wrap < 0) { + s.wrap = -s.wrap; + } + s.status = s.wrap ? INIT_STATE : BUSY_STATE; + strm.adler = s.wrap === 2 ? 0 : 1; + s.last_flush = Z_NO_FLUSH; + trees._tr_init(s); + return Z_OK; } - var VERSION = "6.0.1"; - function retry(octokit, octokitOptions) { - const state = Object.assign( - { - enabled: true, - retryAfterBaseValue: 1e3, - doNotRetry: [400, 401, 403, 404, 422, 451], - retries: 3 - }, - octokitOptions.retry - ); - if (state.enabled) { - octokit.hook.error("request", errorRequest.bind(null, state, octokit)); - octokit.hook.wrap("request", wrapRequest.bind(null, state, octokit)); + function deflateReset(strm) { + var ret = deflateResetKeep(strm); + if (ret === Z_OK) { + lm_init(strm.state); } - return { - retry: { - retryRequest: (error, retries, retryAfter) => { - error.request.request = Object.assign({}, error.request.request, { - retries, - retryAfter - }); - return error; - } - } - }; + return ret; } - retry.VERSION = VERSION; - } -}); - -// ../../../node_modules/.pnpm/@octokit+plugin-throttling@8.2.0_@octokit+core@5.2.0/node_modules/@octokit/plugin-throttling/dist-node/index.js -var require_dist_node13 = __commonJS({ - "../../../node_modules/.pnpm/@octokit+plugin-throttling@8.2.0_@octokit+core@5.2.0/node_modules/@octokit/plugin-throttling/dist-node/index.js"(exports2, module2) { - "use strict"; - var __create2 = Object.create; - var __defProp2 = Object.defineProperty; - var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; - var __getOwnPropNames2 = Object.getOwnPropertyNames; - var __getProtoOf2 = Object.getPrototypeOf; - var __hasOwnProp2 = Object.prototype.hasOwnProperty; - var __export2 = (target, all) => { - for (var name in all) - __defProp2(target, name, { get: all[name], enumerable: true }); - }; - var __copyProps2 = (to, from3, except, desc) => { - if (from3 && typeof from3 === "object" || typeof from3 === "function") { - for (let key of __getOwnPropNames2(from3)) - if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc2(from3, key)) || desc.enumerable }); + function deflateSetHeader(strm, head) { + if (!strm || !strm.state) { + return Z_STREAM_ERROR; } - return to; - }; - var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2( - // If the importer is in node compatibility mode or this is not an ESM - // file that has been converted to a CommonJS file using a Babel- - // compatible transform (i.e. "__esModule" has not been set), then set - // "default" to the CommonJS "module.exports" for node compatibility. - isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target, - mod - )); - var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); - var dist_src_exports = {}; - __export2(dist_src_exports, { - throttling: () => throttling - }); - module2.exports = __toCommonJS2(dist_src_exports); - var import_light = __toESM2(require_light()); - var import_core = require_dist_node8(); - var VERSION = "8.2.0"; - var noop = () => Promise.resolve(); - function wrapRequest(state, request, options) { - return state.retryLimiter.schedule(doRequest, state, request, options); + if (strm.state.wrap !== 2) { + return Z_STREAM_ERROR; + } + strm.state.gzhead = head; + return Z_OK; } - async function doRequest(state, request, options) { - const isWrite = options.method !== "GET" && options.method !== "HEAD"; - const { pathname } = new URL(options.url, "http://github.test"); - const isSearch = options.method === "GET" && pathname.startsWith("/search/"); - const isGraphQL = pathname.startsWith("/graphql"); - const retryCount = ~~request.retryCount; - const jobOptions = retryCount > 0 ? { priority: 0, weight: 0 } : {}; - if (state.clustering) { - jobOptions.expiration = 1e3 * 60; + function deflateInit2(strm, level, method, windowBits, memLevel, strategy) { + if (!strm) { + return Z_STREAM_ERROR; } - if (isWrite || isGraphQL) { - await state.write.key(state.id).schedule(jobOptions, noop); + var wrap = 1; + if (level === Z_DEFAULT_COMPRESSION) { + level = 6; } - if (isWrite && state.triggersNotification(pathname)) { - await state.notifications.key(state.id).schedule(jobOptions, noop); + if (windowBits < 0) { + wrap = 0; + windowBits = -windowBits; + } else if (windowBits > 15) { + wrap = 2; + windowBits -= 16; } - if (isSearch) { - await state.search.key(state.id).schedule(jobOptions, noop); + if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED || windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) { + return err(strm, Z_STREAM_ERROR); } - const req = state.global.key(state.id).schedule(jobOptions, request, options); - if (isGraphQL) { - const res = await req; - if (res.data.errors != null && res.data.errors.some((error) => error.type === "RATE_LIMITED")) { - const error = Object.assign(new Error("GraphQL Rate Limit Exceeded"), { - response: res, - data: res.data - }); - throw error; - } + if (windowBits === 8) { + windowBits = 9; } - return req; + var s = new DeflateState(); + strm.state = s; + s.strm = strm; + s.wrap = wrap; + s.gzhead = null; + s.w_bits = windowBits; + s.w_size = 1 << s.w_bits; + s.w_mask = s.w_size - 1; + s.hash_bits = memLevel + 7; + s.hash_size = 1 << s.hash_bits; + s.hash_mask = s.hash_size - 1; + s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH); + s.window = new utils.Buf8(s.w_size * 2); + s.head = new utils.Buf16(s.hash_size); + s.prev = new utils.Buf16(s.w_size); + s.lit_bufsize = 1 << memLevel + 6; + s.pending_buf_size = s.lit_bufsize * 4; + s.pending_buf = new utils.Buf8(s.pending_buf_size); + s.d_buf = 1 * s.lit_bufsize; + s.l_buf = (1 + 2) * s.lit_bufsize; + s.level = level; + s.strategy = strategy; + s.method = method; + return deflateReset(strm); } - var triggers_notification_paths_default = [ - "/orgs/{org}/invitations", - "/orgs/{org}/invitations/{invitation_id}", - "/orgs/{org}/teams/{team_slug}/discussions", - "/orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments", - "/repos/{owner}/{repo}/collaborators/{username}", - "/repos/{owner}/{repo}/commits/{commit_sha}/comments", - "/repos/{owner}/{repo}/issues", - "/repos/{owner}/{repo}/issues/{issue_number}/comments", - "/repos/{owner}/{repo}/pulls", - "/repos/{owner}/{repo}/pulls/{pull_number}/comments", - "/repos/{owner}/{repo}/pulls/{pull_number}/comments/{comment_id}/replies", - "/repos/{owner}/{repo}/pulls/{pull_number}/merge", - "/repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers", - "/repos/{owner}/{repo}/pulls/{pull_number}/reviews", - "/repos/{owner}/{repo}/releases", - "/teams/{team_id}/discussions", - "/teams/{team_id}/discussions/{discussion_number}/comments" - ]; - function routeMatcher(paths) { - const regexes = paths.map( - (path) => path.split("/").map((c) => c.startsWith("{") ? "(?:.+?)" : c).join("/") - ); - const regex2 = `^(?:${regexes.map((r) => `(?:${r})`).join("|")})[^/]*$`; - return new RegExp(regex2, "i"); + function deflateInit(strm, level) { + return deflateInit2(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY); } - var regex = routeMatcher(triggers_notification_paths_default); - var triggersNotification = regex.test.bind(regex); - var groups = {}; - var createGroups = function(Bottleneck, common) { - groups.global = new Bottleneck.Group({ - id: "octokit-global", - maxConcurrent: 10, - ...common - }); - groups.search = new Bottleneck.Group({ - id: "octokit-search", - maxConcurrent: 1, - minTime: 2e3, - ...common - }); - groups.write = new Bottleneck.Group({ - id: "octokit-write", - maxConcurrent: 1, - minTime: 1e3, - ...common - }); - groups.notifications = new Bottleneck.Group({ - id: "octokit-notifications", - maxConcurrent: 1, - minTime: 3e3, - ...common - }); - }; - function throttling(octokit, octokitOptions) { - const { - enabled = true, - Bottleneck = import_light.default, - id = "no-id", - timeout = 1e3 * 60 * 2, - // Redis TTL: 2 minutes - connection - } = octokitOptions.throttle || {}; - if (!enabled) { - return {}; + function deflate2(strm, flush) { + var old_flush, s; + var beg, val; + if (!strm || !strm.state || flush > Z_BLOCK || flush < 0) { + return strm ? err(strm, Z_STREAM_ERROR) : Z_STREAM_ERROR; } - const common = { connection, timeout }; - if (groups.global == null) { - createGroups(Bottleneck, common); + s = strm.state; + if (!strm.output || !strm.input && strm.avail_in !== 0 || s.status === FINISH_STATE && flush !== Z_FINISH) { + return err(strm, strm.avail_out === 0 ? Z_BUF_ERROR : Z_STREAM_ERROR); } - const state = Object.assign( - { - clustering: connection != null, - triggersNotification, - fallbackSecondaryRateRetryAfter: 60, - retryAfterBaseValue: 1e3, - retryLimiter: new Bottleneck(), - id, - ...groups - }, - octokitOptions.throttle - ); - if (typeof state.onSecondaryRateLimit !== "function" || typeof state.onRateLimit !== "function") { - throw new Error(`octokit/plugin-throttling error: - You must pass the onSecondaryRateLimit and onRateLimit error handlers. - See https://octokit.github.io/rest.js/#throttling - - const octokit = new Octokit({ - throttle: { - onSecondaryRateLimit: (retryAfter, options) => {/* ... */}, - onRateLimit: (retryAfter, options) => {/* ... */} + s.strm = strm; + old_flush = s.last_flush; + s.last_flush = flush; + if (s.status === INIT_STATE) { + if (s.wrap === 2) { + strm.adler = 0; + put_byte(s, 31); + put_byte(s, 139); + put_byte(s, 8); + if (!s.gzhead) { + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0); + put_byte(s, OS_CODE); + s.status = BUSY_STATE; + } else { + put_byte( + s, + (s.gzhead.text ? 1 : 0) + (s.gzhead.hcrc ? 2 : 0) + (!s.gzhead.extra ? 0 : 4) + (!s.gzhead.name ? 0 : 8) + (!s.gzhead.comment ? 0 : 16) + ); + put_byte(s, s.gzhead.time & 255); + put_byte(s, s.gzhead.time >> 8 & 255); + put_byte(s, s.gzhead.time >> 16 & 255); + put_byte(s, s.gzhead.time >> 24 & 255); + put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0); + put_byte(s, s.gzhead.os & 255); + if (s.gzhead.extra && s.gzhead.extra.length) { + put_byte(s, s.gzhead.extra.length & 255); + put_byte(s, s.gzhead.extra.length >> 8 & 255); + } + if (s.gzhead.hcrc) { + strm.adler = crc322(strm.adler, s.pending_buf, s.pending, 0); + } + s.gzindex = 0; + s.status = EXTRA_STATE; } - }) - `); + } else { + var header = Z_DEFLATED + (s.w_bits - 8 << 4) << 8; + var level_flags = -1; + if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) { + level_flags = 0; + } else if (s.level < 6) { + level_flags = 1; + } else if (s.level === 6) { + level_flags = 2; + } else { + level_flags = 3; + } + header |= level_flags << 6; + if (s.strstart !== 0) { + header |= PRESET_DICT; + } + header += 31 - header % 31; + s.status = BUSY_STATE; + putShortMSB(s, header); + if (s.strstart !== 0) { + putShortMSB(s, strm.adler >>> 16); + putShortMSB(s, strm.adler & 65535); + } + strm.adler = 1; + } } - const events = {}; - const emitter = new Bottleneck.Events(events); - events.on("secondary-limit", state.onSecondaryRateLimit); - events.on("rate-limit", state.onRateLimit); - events.on( - "error", - (e) => octokit.log.warn("Error in throttling-plugin limit handler", e) - ); - state.retryLimiter.on("failed", async function(error, info) { - const [state2, request, options] = info.args; - const { pathname } = new URL(options.url, "http://github.test"); - const shouldRetryGraphQL = pathname.startsWith("/graphql") && error.status !== 401; - if (!(shouldRetryGraphQL || error.status === 403)) { - return; + if (s.status === EXTRA_STATE) { + if (s.gzhead.extra) { + beg = s.pending; + while (s.gzindex < (s.gzhead.extra.length & 65535)) { + if (s.pending === s.pending_buf_size) { + if (s.gzhead.hcrc && s.pending > beg) { + strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg); + } + flush_pending(strm); + beg = s.pending; + if (s.pending === s.pending_buf_size) { + break; + } + } + put_byte(s, s.gzhead.extra[s.gzindex] & 255); + s.gzindex++; + } + if (s.gzhead.hcrc && s.pending > beg) { + strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg); + } + if (s.gzindex === s.gzhead.extra.length) { + s.gzindex = 0; + s.status = NAME_STATE; + } + } else { + s.status = NAME_STATE; } - const retryCount = ~~request.retryCount; - request.retryCount = retryCount; - options.request.retryCount = retryCount; - const { wantRetry, retryAfter = 0 } = await async function() { - if (/\bsecondary rate\b/i.test(error.message)) { - const retryAfter2 = Number(error.response.headers["retry-after"]) || state2.fallbackSecondaryRateRetryAfter; - const wantRetry2 = await emitter.trigger( - "secondary-limit", - retryAfter2, - options, - octokit, - retryCount - ); - return { wantRetry: wantRetry2, retryAfter: retryAfter2 }; + } + if (s.status === NAME_STATE) { + if (s.gzhead.name) { + beg = s.pending; + do { + if (s.pending === s.pending_buf_size) { + if (s.gzhead.hcrc && s.pending > beg) { + strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg); + } + flush_pending(strm); + beg = s.pending; + if (s.pending === s.pending_buf_size) { + val = 1; + break; + } + } + if (s.gzindex < s.gzhead.name.length) { + val = s.gzhead.name.charCodeAt(s.gzindex++) & 255; + } else { + val = 0; + } + put_byte(s, val); + } while (val !== 0); + if (s.gzhead.hcrc && s.pending > beg) { + strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg); } - if (error.response.headers != null && error.response.headers["x-ratelimit-remaining"] === "0" || (error.response.data?.errors ?? []).some( - (error2) => error2.type === "RATE_LIMITED" - )) { - const rateLimitReset = new Date( - ~~error.response.headers["x-ratelimit-reset"] * 1e3 - ).getTime(); - const retryAfter2 = Math.max( - // Add one second so we retry _after_ the reset time - // https://docs.github.com/en/rest/overview/resources-in-the-rest-api?apiVersion=2022-11-28#exceeding-the-rate-limit - Math.ceil((rateLimitReset - Date.now()) / 1e3) + 1, - 0 - ); - const wantRetry2 = await emitter.trigger( - "rate-limit", - retryAfter2, - options, - octokit, - retryCount - ); - return { wantRetry: wantRetry2, retryAfter: retryAfter2 }; + if (val === 0) { + s.gzindex = 0; + s.status = COMMENT_STATE; } - return {}; - }(); - if (wantRetry) { - request.retryCount++; - return retryAfter * state2.retryAfterBaseValue; + } else { + s.status = COMMENT_STATE; } - }); - octokit.hook.wrap("request", wrapRequest.bind(null, state)); - return {}; + } + if (s.status === COMMENT_STATE) { + if (s.gzhead.comment) { + beg = s.pending; + do { + if (s.pending === s.pending_buf_size) { + if (s.gzhead.hcrc && s.pending > beg) { + strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg); + } + flush_pending(strm); + beg = s.pending; + if (s.pending === s.pending_buf_size) { + val = 1; + break; + } + } + if (s.gzindex < s.gzhead.comment.length) { + val = s.gzhead.comment.charCodeAt(s.gzindex++) & 255; + } else { + val = 0; + } + put_byte(s, val); + } while (val !== 0); + if (s.gzhead.hcrc && s.pending > beg) { + strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg); + } + if (val === 0) { + s.status = HCRC_STATE; + } + } else { + s.status = HCRC_STATE; + } + } + if (s.status === HCRC_STATE) { + if (s.gzhead.hcrc) { + if (s.pending + 2 > s.pending_buf_size) { + flush_pending(strm); + } + if (s.pending + 2 <= s.pending_buf_size) { + put_byte(s, strm.adler & 255); + put_byte(s, strm.adler >> 8 & 255); + strm.adler = 0; + s.status = BUSY_STATE; + } + } else { + s.status = BUSY_STATE; + } + } + if (s.pending !== 0) { + flush_pending(strm); + if (strm.avail_out === 0) { + s.last_flush = -1; + return Z_OK; + } + } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) && flush !== Z_FINISH) { + return err(strm, Z_BUF_ERROR); + } + if (s.status === FINISH_STATE && strm.avail_in !== 0) { + return err(strm, Z_BUF_ERROR); + } + if (strm.avail_in !== 0 || s.lookahead !== 0 || flush !== Z_NO_FLUSH && s.status !== FINISH_STATE) { + var bstate = s.strategy === Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : s.strategy === Z_RLE ? deflate_rle(s, flush) : configuration_table[s.level].func(s, flush); + if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) { + s.status = FINISH_STATE; + } + if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) { + if (strm.avail_out === 0) { + s.last_flush = -1; + } + return Z_OK; + } + if (bstate === BS_BLOCK_DONE) { + if (flush === Z_PARTIAL_FLUSH) { + trees._tr_align(s); + } else if (flush !== Z_BLOCK) { + trees._tr_stored_block(s, 0, 0, false); + if (flush === Z_FULL_FLUSH) { + zero(s.head); + if (s.lookahead === 0) { + s.strstart = 0; + s.block_start = 0; + s.insert = 0; + } + } + } + flush_pending(strm); + if (strm.avail_out === 0) { + s.last_flush = -1; + return Z_OK; + } + } + } + if (flush !== Z_FINISH) { + return Z_OK; + } + if (s.wrap <= 0) { + return Z_STREAM_END; + } + if (s.wrap === 2) { + put_byte(s, strm.adler & 255); + put_byte(s, strm.adler >> 8 & 255); + put_byte(s, strm.adler >> 16 & 255); + put_byte(s, strm.adler >> 24 & 255); + put_byte(s, strm.total_in & 255); + put_byte(s, strm.total_in >> 8 & 255); + put_byte(s, strm.total_in >> 16 & 255); + put_byte(s, strm.total_in >> 24 & 255); + } else { + putShortMSB(s, strm.adler >>> 16); + putShortMSB(s, strm.adler & 65535); + } + flush_pending(strm); + if (s.wrap > 0) { + s.wrap = -s.wrap; + } + return s.pending !== 0 ? Z_OK : Z_STREAM_END; } - throttling.VERSION = VERSION; - throttling.triggersNotification = triggersNotification; - } -}); - -// ../../../node_modules/.pnpm/btoa-lite@1.0.0/node_modules/btoa-lite/btoa-node.js -var require_btoa_node = __commonJS({ - "../../../node_modules/.pnpm/btoa-lite@1.0.0/node_modules/btoa-lite/btoa-node.js"(exports2, module2) { - module2.exports = function btoa(str) { - return new Buffer(str).toString("base64"); - }; - } -}); - -// ../../../node_modules/.pnpm/@octokit+oauth-authorization-url@6.0.2/node_modules/@octokit/oauth-authorization-url/dist-node/index.js -var require_dist_node14 = __commonJS({ - "../../../node_modules/.pnpm/@octokit+oauth-authorization-url@6.0.2/node_modules/@octokit/oauth-authorization-url/dist-node/index.js"(exports2, module2) { - "use strict"; - var __defProp2 = Object.defineProperty; - var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; - var __getOwnPropNames2 = Object.getOwnPropertyNames; - var __hasOwnProp2 = Object.prototype.hasOwnProperty; - var __export2 = (target, all) => { - for (var name in all) - __defProp2(target, name, { get: all[name], enumerable: true }); - }; - var __copyProps2 = (to, from3, except, desc) => { - if (from3 && typeof from3 === "object" || typeof from3 === "function") { - for (let key of __getOwnPropNames2(from3)) - if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc2(from3, key)) || desc.enumerable }); + function deflateEnd(strm) { + var status3; + if (!strm || !strm.state) { + return Z_STREAM_ERROR; } - return to; - }; - var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); - var dist_src_exports = {}; - __export2(dist_src_exports, { - oauthAuthorizationUrl: () => oauthAuthorizationUrl - }); - module2.exports = __toCommonJS2(dist_src_exports); - function oauthAuthorizationUrl(options) { - const clientType = options.clientType || "oauth-app"; - const baseUrl = options.baseUrl || "https://github.com"; - const result = { - clientType, - allowSignup: options.allowSignup === false ? false : true, - clientId: options.clientId, - login: options.login || null, - redirectUrl: options.redirectUrl || null, - state: options.state || Math.random().toString(36).substr(2), - url: "" - }; - if (clientType === "oauth-app") { - const scopes = "scopes" in options ? options.scopes : []; - result.scopes = typeof scopes === "string" ? scopes.split(/[,\s]+/).filter(Boolean) : scopes; + status3 = strm.state.status; + if (status3 !== INIT_STATE && status3 !== EXTRA_STATE && status3 !== NAME_STATE && status3 !== COMMENT_STATE && status3 !== HCRC_STATE && status3 !== BUSY_STATE && status3 !== FINISH_STATE) { + return err(strm, Z_STREAM_ERROR); } - result.url = urlBuilderAuthorize(`${baseUrl}/login/oauth/authorize`, result); - return result; + strm.state = null; + return status3 === BUSY_STATE ? err(strm, Z_DATA_ERROR) : Z_OK; } - function urlBuilderAuthorize(base, options) { - const map = { - allowSignup: "allow_signup", - clientId: "client_id", - login: "login", - redirectUrl: "redirect_uri", - scopes: "scope", - state: "state" - }; - let url = base; - Object.keys(map).filter((k) => options[k] !== null).filter((k) => { - if (k !== "scopes") - return true; - if (options.clientType === "github-app") - return false; - return !Array.isArray(options[k]) || options[k].length > 0; - }).map((key) => [map[key], `${options[key]}`]).forEach(([key, value], index2) => { - url += index2 === 0 ? `?` : "&"; - url += `${key}=${encodeURIComponent(value)}`; - }); - return url; + function deflateSetDictionary(strm, dictionary) { + var dictLength = dictionary.length; + var s; + var str, n; + var wrap; + var avail; + var next; + var input; + var tmpDict; + if (!strm || !strm.state) { + return Z_STREAM_ERROR; + } + s = strm.state; + wrap = s.wrap; + if (wrap === 2 || wrap === 1 && s.status !== INIT_STATE || s.lookahead) { + return Z_STREAM_ERROR; + } + if (wrap === 1) { + strm.adler = adler32(strm.adler, dictionary, dictLength, 0); + } + s.wrap = 0; + if (dictLength >= s.w_size) { + if (wrap === 0) { + zero(s.head); + s.strstart = 0; + s.block_start = 0; + s.insert = 0; + } + tmpDict = new utils.Buf8(s.w_size); + utils.arraySet(tmpDict, dictionary, dictLength - s.w_size, s.w_size, 0); + dictionary = tmpDict; + dictLength = s.w_size; + } + avail = strm.avail_in; + next = strm.next_in; + input = strm.input; + strm.avail_in = dictLength; + strm.next_in = 0; + strm.input = dictionary; + fill_window(s); + while (s.lookahead >= MIN_MATCH) { + str = s.strstart; + n = s.lookahead - (MIN_MATCH - 1); + do { + s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask; + s.prev[str & s.w_mask] = s.head[s.ins_h]; + s.head[s.ins_h] = str; + str++; + } while (--n); + s.strstart = str; + s.lookahead = MIN_MATCH - 1; + fill_window(s); + } + s.strstart += s.lookahead; + s.block_start = s.strstart; + s.insert = s.lookahead; + s.lookahead = 0; + s.match_length = s.prev_length = MIN_MATCH - 1; + s.match_available = 0; + strm.next_in = next; + strm.input = input; + strm.avail_in = avail; + s.wrap = wrap; + return Z_OK; } + exports2.deflateInit = deflateInit; + exports2.deflateInit2 = deflateInit2; + exports2.deflateReset = deflateReset; + exports2.deflateResetKeep = deflateResetKeep; + exports2.deflateSetHeader = deflateSetHeader; + exports2.deflate = deflate2; + exports2.deflateEnd = deflateEnd; + exports2.deflateSetDictionary = deflateSetDictionary; + exports2.deflateInfo = "pako deflate (from Nodeca project)"; } }); -// ../../../node_modules/.pnpm/@octokit+oauth-methods@4.1.0/node_modules/@octokit/oauth-methods/dist-node/index.js -var require_dist_node15 = __commonJS({ - "../../../node_modules/.pnpm/@octokit+oauth-methods@4.1.0/node_modules/@octokit/oauth-methods/dist-node/index.js"(exports2, module2) { +// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/utils/strings.js +var require_strings = __commonJS({ + "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/utils/strings.js"(exports2) { "use strict"; - var __create2 = Object.create; - var __defProp2 = Object.defineProperty; - var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; - var __getOwnPropNames2 = Object.getOwnPropertyNames; - var __getProtoOf2 = Object.getPrototypeOf; - var __hasOwnProp2 = Object.prototype.hasOwnProperty; - var __export2 = (target, all) => { - for (var name in all) - __defProp2(target, name, { get: all[name], enumerable: true }); - }; - var __copyProps2 = (to, from3, except, desc) => { - if (from3 && typeof from3 === "object" || typeof from3 === "function") { - for (let key of __getOwnPropNames2(from3)) - if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc2(from3, key)) || desc.enumerable }); + var utils = require_common(); + var STR_APPLY_OK = true; + var STR_APPLY_UIA_OK = true; + try { + String.fromCharCode.apply(null, [0]); + } catch (__) { + STR_APPLY_OK = false; + } + try { + String.fromCharCode.apply(null, new Uint8Array(1)); + } catch (__) { + STR_APPLY_UIA_OK = false; + } + var _utf8len = new utils.Buf8(256); + for (q = 0; q < 256; q++) { + _utf8len[q] = q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1; + } + var q; + _utf8len[254] = _utf8len[254] = 1; + exports2.string2buf = function(str) { + var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0; + for (m_pos = 0; m_pos < str_len; m_pos++) { + c = str.charCodeAt(m_pos); + if ((c & 64512) === 55296 && m_pos + 1 < str_len) { + c2 = str.charCodeAt(m_pos + 1); + if ((c2 & 64512) === 56320) { + c = 65536 + (c - 55296 << 10) + (c2 - 56320); + m_pos++; + } + } + buf_len += c < 128 ? 1 : c < 2048 ? 2 : c < 65536 ? 3 : 4; } - return to; - }; - var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2( - // If the importer is in node compatibility mode or this is not an ESM - // file that has been converted to a CommonJS file using a Babel- - // compatible transform (i.e. "__esModule" has not been set), then set - // "default" to the CommonJS "module.exports" for node compatibility. - isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target, - mod - )); - var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); - var dist_src_exports = {}; - __export2(dist_src_exports, { - VERSION: () => VERSION, - checkToken: () => checkToken, - createDeviceCode: () => createDeviceCode, - deleteAuthorization: () => deleteAuthorization, - deleteToken: () => deleteToken, - exchangeDeviceCode: () => exchangeDeviceCode, - exchangeWebFlowCode: () => exchangeWebFlowCode, - getWebFlowAuthorizationUrl: () => getWebFlowAuthorizationUrl, - refreshToken: () => refreshToken, - resetToken: () => resetToken, - scopeToken: () => scopeToken - }); - module2.exports = __toCommonJS2(dist_src_exports); - var VERSION = "4.1.0"; - var import_oauth_authorization_url = require_dist_node14(); - var import_request = require_dist_node5(); - var import_request_error = require_dist_node4(); - function requestToOAuthBaseUrl(request) { - const endpointDefaults = request.endpoint.DEFAULTS; - return /^https:\/\/(api\.)?github\.com$/.test(endpointDefaults.baseUrl) ? "https://github.com" : endpointDefaults.baseUrl.replace("/api/v3", ""); - } - async function oauthRequest(request, route, parameters) { - const withOAuthParameters = { - baseUrl: requestToOAuthBaseUrl(request), - headers: { - accept: "application/json" - }, - ...parameters - }; - const response = await request(route, withOAuthParameters); - if ("error" in response.data) { - const error = new import_request_error.RequestError( - `${response.data.error_description} (${response.data.error}, ${response.data.error_uri})`, - 400, - { - request: request.endpoint.merge( - route, - withOAuthParameters - ), - headers: response.headers + buf = new utils.Buf8(buf_len); + for (i = 0, m_pos = 0; i < buf_len; m_pos++) { + c = str.charCodeAt(m_pos); + if ((c & 64512) === 55296 && m_pos + 1 < str_len) { + c2 = str.charCodeAt(m_pos + 1); + if ((c2 & 64512) === 56320) { + c = 65536 + (c - 55296 << 10) + (c2 - 56320); + m_pos++; } - ); - error.response = response; - throw error; - } - return response; - } - function getWebFlowAuthorizationUrl({ - request = import_request.request, - ...options - }) { - const baseUrl = requestToOAuthBaseUrl(request); - return (0, import_oauth_authorization_url.oauthAuthorizationUrl)({ - ...options, - baseUrl - }); - } - var import_request2 = require_dist_node5(); - async function exchangeWebFlowCode(options) { - const request = options.request || /* istanbul ignore next: we always pass a custom request in tests */ - import_request2.request; - const response = await oauthRequest( - request, - "POST /login/oauth/access_token", - { - client_id: options.clientId, - client_secret: options.clientSecret, - code: options.code, - redirect_uri: options.redirectUrl } - ); - const authentication = { - clientType: options.clientType, - clientId: options.clientId, - clientSecret: options.clientSecret, - token: response.data.access_token, - scopes: response.data.scope.split(/\s+/).filter(Boolean) - }; - if (options.clientType === "github-app") { - if ("refresh_token" in response.data) { - const apiTimeInMs = new Date(response.headers.date).getTime(); - authentication.refreshToken = response.data.refresh_token, authentication.expiresAt = toTimestamp( - apiTimeInMs, - response.data.expires_in - ), authentication.refreshTokenExpiresAt = toTimestamp( - apiTimeInMs, - response.data.refresh_token_expires_in - ); + if (c < 128) { + buf[i++] = c; + } else if (c < 2048) { + buf[i++] = 192 | c >>> 6; + buf[i++] = 128 | c & 63; + } else if (c < 65536) { + buf[i++] = 224 | c >>> 12; + buf[i++] = 128 | c >>> 6 & 63; + buf[i++] = 128 | c & 63; + } else { + buf[i++] = 240 | c >>> 18; + buf[i++] = 128 | c >>> 12 & 63; + buf[i++] = 128 | c >>> 6 & 63; + buf[i++] = 128 | c & 63; } - delete authentication.scopes; - } - return { ...response, authentication }; - } - function toTimestamp(apiTimeInMs, expirationInSeconds) { - return new Date(apiTimeInMs + expirationInSeconds * 1e3).toISOString(); - } - var import_request3 = require_dist_node5(); - async function createDeviceCode(options) { - const request = options.request || /* istanbul ignore next: we always pass a custom request in tests */ - import_request3.request; - const parameters = { - client_id: options.clientId - }; - if ("scopes" in options && Array.isArray(options.scopes)) { - parameters.scope = options.scopes.join(" "); } - return oauthRequest(request, "POST /login/device/code", parameters); - } - var import_request4 = require_dist_node5(); - async function exchangeDeviceCode(options) { - const request = options.request || /* istanbul ignore next: we always pass a custom request in tests */ - import_request4.request; - const response = await oauthRequest( - request, - "POST /login/oauth/access_token", - { - client_id: options.clientId, - device_code: options.code, - grant_type: "urn:ietf:params:oauth:grant-type:device_code" + return buf; + }; + function buf2binstring(buf, len) { + if (len < 65534) { + if (buf.subarray && STR_APPLY_UIA_OK || !buf.subarray && STR_APPLY_OK) { + return String.fromCharCode.apply(null, utils.shrinkBuf(buf, len)); } - ); - const authentication = { - clientType: options.clientType, - clientId: options.clientId, - token: response.data.access_token, - scopes: response.data.scope.split(/\s+/).filter(Boolean) - }; - if ("clientSecret" in options) { - authentication.clientSecret = options.clientSecret; } - if (options.clientType === "github-app") { - if ("refresh_token" in response.data) { - const apiTimeInMs = new Date(response.headers.date).getTime(); - authentication.refreshToken = response.data.refresh_token, authentication.expiresAt = toTimestamp2( - apiTimeInMs, - response.data.expires_in - ), authentication.refreshTokenExpiresAt = toTimestamp2( - apiTimeInMs, - response.data.refresh_token_expires_in - ); - } - delete authentication.scopes; + var result = ""; + for (var i = 0; i < len; i++) { + result += String.fromCharCode(buf[i]); } - return { ...response, authentication }; - } - function toTimestamp2(apiTimeInMs, expirationInSeconds) { - return new Date(apiTimeInMs + expirationInSeconds * 1e3).toISOString(); + return result; } - var import_request5 = require_dist_node5(); - var import_btoa_lite = __toESM2(require_btoa_node()); - async function checkToken(options) { - const request = options.request || /* istanbul ignore next: we always pass a custom request in tests */ - import_request5.request; - const response = await request("POST /applications/{client_id}/token", { - headers: { - authorization: `basic ${(0, import_btoa_lite.default)( - `${options.clientId}:${options.clientSecret}` - )}` - }, - client_id: options.clientId, - access_token: options.token - }); - const authentication = { - clientType: options.clientType, - clientId: options.clientId, - clientSecret: options.clientSecret, - token: options.token, - scopes: response.data.scopes - }; - if (response.data.expires_at) - authentication.expiresAt = response.data.expires_at; - if (options.clientType === "github-app") { - delete authentication.scopes; + exports2.buf2binstring = function(buf) { + return buf2binstring(buf, buf.length); + }; + exports2.binstring2buf = function(str) { + var buf = new utils.Buf8(str.length); + for (var i = 0, len = buf.length; i < len; i++) { + buf[i] = str.charCodeAt(i); } - return { ...response, authentication }; - } - var import_request6 = require_dist_node5(); - async function refreshToken(options) { - const request = options.request || /* istanbul ignore next: we always pass a custom request in tests */ - import_request6.request; - const response = await oauthRequest( - request, - "POST /login/oauth/access_token", - { - client_id: options.clientId, - client_secret: options.clientSecret, - grant_type: "refresh_token", - refresh_token: options.refreshToken + return buf; + }; + exports2.buf2string = function(buf, max) { + var i, out, c, c_len; + var len = max || buf.length; + var utf16buf = new Array(len * 2); + for (out = 0, i = 0; i < len; ) { + c = buf[i++]; + if (c < 128) { + utf16buf[out++] = c; + continue; } - ); - const apiTimeInMs = new Date(response.headers.date).getTime(); - const authentication = { - clientType: "github-app", - clientId: options.clientId, - clientSecret: options.clientSecret, - token: response.data.access_token, - refreshToken: response.data.refresh_token, - expiresAt: toTimestamp3(apiTimeInMs, response.data.expires_in), - refreshTokenExpiresAt: toTimestamp3( - apiTimeInMs, - response.data.refresh_token_expires_in - ) - }; - return { ...response, authentication }; - } - function toTimestamp3(apiTimeInMs, expirationInSeconds) { - return new Date(apiTimeInMs + expirationInSeconds * 1e3).toISOString(); - } - var import_request7 = require_dist_node5(); - var import_btoa_lite2 = __toESM2(require_btoa_node()); - async function scopeToken(options) { - const { - request: optionsRequest, - clientType, - clientId, - clientSecret, - token, - ...requestOptions - } = options; - const request = optionsRequest || /* istanbul ignore next: we always pass a custom request in tests */ - import_request7.request; - const response = await request( - "POST /applications/{client_id}/token/scoped", - { - headers: { - authorization: `basic ${(0, import_btoa_lite2.default)(`${clientId}:${clientSecret}`)}` - }, - client_id: clientId, - access_token: token, - ...requestOptions + c_len = _utf8len[c]; + if (c_len > 4) { + utf16buf[out++] = 65533; + i += c_len - 1; + continue; } - ); - const authentication = Object.assign( - { - clientType, - clientId, - clientSecret, - token: response.data.token - }, - response.data.expires_at ? { expiresAt: response.data.expires_at } : {} - ); - return { ...response, authentication }; - } - var import_request8 = require_dist_node5(); - var import_btoa_lite3 = __toESM2(require_btoa_node()); - async function resetToken(options) { - const request = options.request || /* istanbul ignore next: we always pass a custom request in tests */ - import_request8.request; - const auth = (0, import_btoa_lite3.default)(`${options.clientId}:${options.clientSecret}`); - const response = await request( - "PATCH /applications/{client_id}/token", - { - headers: { - authorization: `basic ${auth}` - }, - client_id: options.clientId, - access_token: options.token + c &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7; + while (c_len > 1 && i < len) { + c = c << 6 | buf[i++] & 63; + c_len--; } - ); - const authentication = { - clientType: options.clientType, - clientId: options.clientId, - clientSecret: options.clientSecret, - token: response.data.token, - scopes: response.data.scopes - }; - if (response.data.expires_at) - authentication.expiresAt = response.data.expires_at; - if (options.clientType === "github-app") { - delete authentication.scopes; - } - return { ...response, authentication }; - } - var import_request9 = require_dist_node5(); - var import_btoa_lite4 = __toESM2(require_btoa_node()); - async function deleteToken(options) { - const request = options.request || /* istanbul ignore next: we always pass a custom request in tests */ - import_request9.request; - const auth = (0, import_btoa_lite4.default)(`${options.clientId}:${options.clientSecret}`); - return request( - "DELETE /applications/{client_id}/token", - { - headers: { - authorization: `basic ${auth}` - }, - client_id: options.clientId, - access_token: options.token + if (c_len > 1) { + utf16buf[out++] = 65533; + continue; } - ); - } - var import_request10 = require_dist_node5(); - var import_btoa_lite5 = __toESM2(require_btoa_node()); - async function deleteAuthorization(options) { - const request = options.request || /* istanbul ignore next: we always pass a custom request in tests */ - import_request10.request; - const auth = (0, import_btoa_lite5.default)(`${options.clientId}:${options.clientSecret}`); - return request( - "DELETE /applications/{client_id}/grant", - { - headers: { - authorization: `basic ${auth}` - }, - client_id: options.clientId, - access_token: options.token + if (c < 65536) { + utf16buf[out++] = c; + } else { + c -= 65536; + utf16buf[out++] = 55296 | c >> 10 & 1023; + utf16buf[out++] = 56320 | c & 1023; } - ); + } + return buf2binstring(utf16buf, out); + }; + exports2.utf8border = function(buf, max) { + var pos; + max = max || buf.length; + if (max > buf.length) { + max = buf.length; + } + pos = max - 1; + while (pos >= 0 && (buf[pos] & 192) === 128) { + pos--; + } + if (pos < 0) { + return max; + } + if (pos === 0) { + return max; + } + return pos + _utf8len[buf[pos]] > max ? pos : max; + }; + } +}); + +// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/zstream.js +var require_zstream = __commonJS({ + "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/zstream.js"(exports2, module2) { + "use strict"; + function ZStream() { + this.input = null; + this.next_in = 0; + this.avail_in = 0; + this.total_in = 0; + this.output = null; + this.next_out = 0; + this.avail_out = 0; + this.total_out = 0; + this.msg = ""; + this.state = null; + this.data_type = 2; + this.adler = 0; } + module2.exports = ZStream; } }); -// ../../../node_modules/.pnpm/@octokit+auth-oauth-device@6.1.0/node_modules/@octokit/auth-oauth-device/dist-node/index.js -var require_dist_node16 = __commonJS({ - "../../../node_modules/.pnpm/@octokit+auth-oauth-device@6.1.0/node_modules/@octokit/auth-oauth-device/dist-node/index.js"(exports2, module2) { +// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/deflate.js +var require_deflate2 = __commonJS({ + "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/deflate.js"(exports2) { "use strict"; - var __defProp2 = Object.defineProperty; - var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; - var __getOwnPropNames2 = Object.getOwnPropertyNames; - var __hasOwnProp2 = Object.prototype.hasOwnProperty; - var __export2 = (target, all) => { - for (var name in all) - __defProp2(target, name, { get: all[name], enumerable: true }); - }; - var __copyProps2 = (to, from3, except, desc) => { - if (from3 && typeof from3 === "object" || typeof from3 === "function") { - for (let key of __getOwnPropNames2(from3)) - if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc2(from3, key)) || desc.enumerable }); + var zlib_deflate = require_deflate(); + var utils = require_common(); + var strings = require_strings(); + var msg = require_messages(); + var ZStream = require_zstream(); + var toString = Object.prototype.toString; + var Z_NO_FLUSH = 0; + var Z_FINISH = 4; + var Z_OK = 0; + var Z_STREAM_END = 1; + var Z_SYNC_FLUSH = 2; + var Z_DEFAULT_COMPRESSION = -1; + var Z_DEFAULT_STRATEGY = 0; + var Z_DEFLATED = 8; + function Deflate(options) { + if (!(this instanceof Deflate)) + return new Deflate(options); + this.options = utils.assign({ + level: Z_DEFAULT_COMPRESSION, + method: Z_DEFLATED, + chunkSize: 16384, + windowBits: 15, + memLevel: 8, + strategy: Z_DEFAULT_STRATEGY, + to: "" + }, options || {}); + var opt = this.options; + if (opt.raw && opt.windowBits > 0) { + opt.windowBits = -opt.windowBits; + } else if (opt.gzip && opt.windowBits > 0 && opt.windowBits < 16) { + opt.windowBits += 16; } - return to; - }; - var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); - var dist_src_exports = {}; - __export2(dist_src_exports, { - createOAuthDeviceAuth: () => createOAuthDeviceAuth - }); - module2.exports = __toCommonJS2(dist_src_exports); - var import_universal_user_agent = require_dist_node(); - var import_request = require_dist_node5(); - var import_oauth_methods = require_dist_node15(); - async function getOAuthAccessToken(state, options) { - const cachedAuthentication = getCachedAuthentication(state, options.auth); - if (cachedAuthentication) - return cachedAuthentication; - const { data: verification } = await (0, import_oauth_methods.createDeviceCode)({ - clientType: state.clientType, - clientId: state.clientId, - request: options.request || state.request, - // @ts-expect-error the extra code to make TS happy is not worth it - scopes: options.auth.scopes || state.scopes - }); - await state.onVerification(verification); - const authentication = await waitForAccessToken( - options.request || state.request, - state.clientId, - state.clientType, - verification + this.err = 0; + this.msg = ""; + this.ended = false; + this.chunks = []; + this.strm = new ZStream(); + this.strm.avail_out = 0; + var status3 = zlib_deflate.deflateInit2( + this.strm, + opt.level, + opt.method, + opt.windowBits, + opt.memLevel, + opt.strategy ); - state.authentication = authentication; - return authentication; - } - function getCachedAuthentication(state, auth2) { - if (auth2.refresh === true) - return false; - if (!state.authentication) - return false; - if (state.clientType === "github-app") { - return state.authentication; + if (status3 !== Z_OK) { + throw new Error(msg[status3]); } - const authentication = state.authentication; - const newScope = ("scopes" in auth2 && auth2.scopes || state.scopes).join( - " " - ); - const currentScope = authentication.scopes.join(" "); - return newScope === currentScope ? authentication : false; - } - async function wait(seconds) { - await new Promise((resolve) => setTimeout(resolve, seconds * 1e3)); - } - async function waitForAccessToken(request, clientId, clientType, verification) { - try { - const options = { - clientId, - request, - code: verification.device_code - }; - const { authentication } = clientType === "oauth-app" ? await (0, import_oauth_methods.exchangeDeviceCode)({ - ...options, - clientType: "oauth-app" - }) : await (0, import_oauth_methods.exchangeDeviceCode)({ - ...options, - clientType: "github-app" - }); - return { - type: "token", - tokenType: "oauth", - ...authentication - }; - } catch (error) { - if (!error.response) - throw error; - const errorType = error.response.data.error; - if (errorType === "authorization_pending") { - await wait(verification.interval); - return waitForAccessToken(request, clientId, clientType, verification); - } - if (errorType === "slow_down") { - await wait(verification.interval + 5); - return waitForAccessToken(request, clientId, clientType, verification); - } - throw error; - } - } - async function auth(state, authOptions) { - return getOAuthAccessToken(state, { - auth: authOptions - }); - } - async function hook(state, request, route, parameters) { - let endpoint = request.endpoint.merge( - route, - parameters - ); - if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) { - return request(endpoint); + if (opt.header) { + zlib_deflate.deflateSetHeader(this.strm, opt.header); } - const { token } = await getOAuthAccessToken(state, { - request, - auth: { type: "oauth" } - }); - endpoint.headers.authorization = `token ${token}`; - return request(endpoint); - } - var VERSION = "6.1.0"; - function createOAuthDeviceAuth(options) { - const requestWithDefaults = options.request || import_request.request.defaults({ - headers: { - "user-agent": `octokit-auth-oauth-device.js/${VERSION} ${(0, import_universal_user_agent.getUserAgent)()}` + if (opt.dictionary) { + var dict; + if (typeof opt.dictionary === "string") { + dict = strings.string2buf(opt.dictionary); + } else if (toString.call(opt.dictionary) === "[object ArrayBuffer]") { + dict = new Uint8Array(opt.dictionary); + } else { + dict = opt.dictionary; } - }); - const { request = requestWithDefaults, ...otherOptions } = options; - const state = options.clientType === "github-app" ? { - ...otherOptions, - clientType: "github-app", - request - } : { - ...otherOptions, - clientType: "oauth-app", - request, - scopes: options.scopes || [] - }; - if (!options.clientId) { - throw new Error( - '[@octokit/auth-oauth-device] "clientId" option must be set (https://github.com/octokit/auth-oauth-device.js#usage)' - ); - } - if (!options.onVerification) { - throw new Error( - '[@octokit/auth-oauth-device] "onVerification" option must be a function (https://github.com/octokit/auth-oauth-device.js#usage)' - ); - } - return Object.assign(auth.bind(null, state), { - hook: hook.bind(null, state) - }); - } - } -}); - -// ../../../node_modules/.pnpm/@octokit+auth-oauth-user@4.1.0/node_modules/@octokit/auth-oauth-user/dist-node/index.js -var require_dist_node17 = __commonJS({ - "../../../node_modules/.pnpm/@octokit+auth-oauth-user@4.1.0/node_modules/@octokit/auth-oauth-user/dist-node/index.js"(exports2, module2) { - "use strict"; - var __create2 = Object.create; - var __defProp2 = Object.defineProperty; - var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; - var __getOwnPropNames2 = Object.getOwnPropertyNames; - var __getProtoOf2 = Object.getPrototypeOf; - var __hasOwnProp2 = Object.prototype.hasOwnProperty; - var __export2 = (target, all) => { - for (var name in all) - __defProp2(target, name, { get: all[name], enumerable: true }); - }; - var __copyProps2 = (to, from3, except, desc) => { - if (from3 && typeof from3 === "object" || typeof from3 === "function") { - for (let key of __getOwnPropNames2(from3)) - if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc2(from3, key)) || desc.enumerable }); - } - return to; - }; - var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2( - // If the importer is in node compatibility mode or this is not an ESM - // file that has been converted to a CommonJS file using a Babel- - // compatible transform (i.e. "__esModule" has not been set), then set - // "default" to the CommonJS "module.exports" for node compatibility. - isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target, - mod - )); - var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); - var dist_src_exports = {}; - __export2(dist_src_exports, { - createOAuthUserAuth: () => createOAuthUserAuth2, - requiresBasicAuth: () => requiresBasicAuth - }); - module2.exports = __toCommonJS2(dist_src_exports); - var import_universal_user_agent = require_dist_node(); - var import_request = require_dist_node5(); - var VERSION = "4.1.0"; - var import_auth_oauth_device = require_dist_node16(); - var import_oauth_methods = require_dist_node15(); - async function getAuthentication(state) { - if ("code" in state.strategyOptions) { - const { authentication } = await (0, import_oauth_methods.exchangeWebFlowCode)({ - clientId: state.clientId, - clientSecret: state.clientSecret, - clientType: state.clientType, - onTokenCreated: state.onTokenCreated, - ...state.strategyOptions, - request: state.request - }); - return { - type: "token", - tokenType: "oauth", - ...authentication - }; - } - if ("onVerification" in state.strategyOptions) { - const deviceAuth = (0, import_auth_oauth_device.createOAuthDeviceAuth)({ - clientType: state.clientType, - clientId: state.clientId, - onTokenCreated: state.onTokenCreated, - ...state.strategyOptions, - request: state.request - }); - const authentication = await deviceAuth({ - type: "oauth" - }); - return { - clientSecret: state.clientSecret, - ...authentication - }; - } - if ("token" in state.strategyOptions) { - return { - type: "token", - tokenType: "oauth", - clientId: state.clientId, - clientSecret: state.clientSecret, - clientType: state.clientType, - onTokenCreated: state.onTokenCreated, - ...state.strategyOptions - }; + status3 = zlib_deflate.deflateSetDictionary(this.strm, dict); + if (status3 !== Z_OK) { + throw new Error(msg[status3]); + } + this._dict_set = true; } - throw new Error("[@octokit/auth-oauth-user] Invalid strategy options"); } - var import_oauth_methods2 = require_dist_node15(); - async function auth(state, options = {}) { - var _a, _b; - if (!state.authentication) { - state.authentication = state.clientType === "oauth-app" ? await getAuthentication(state) : await getAuthentication(state); - } - if (state.authentication.invalid) { - throw new Error("[@octokit/auth-oauth-user] Token is invalid"); + Deflate.prototype.push = function(data, mode) { + var strm = this.strm; + var chunkSize = this.options.chunkSize; + var status3, _mode; + if (this.ended) { + return false; } - const currentAuthentication = state.authentication; - if ("expiresAt" in currentAuthentication) { - if (options.type === "refresh" || new Date(currentAuthentication.expiresAt) < /* @__PURE__ */ new Date()) { - const { authentication } = await (0, import_oauth_methods2.refreshToken)({ - clientType: "github-app", - clientId: state.clientId, - clientSecret: state.clientSecret, - refreshToken: currentAuthentication.refreshToken, - request: state.request - }); - state.authentication = { - tokenType: "oauth", - type: "token", - ...authentication - }; - } + _mode = mode === ~~mode ? mode : mode === true ? Z_FINISH : Z_NO_FLUSH; + if (typeof data === "string") { + strm.input = strings.string2buf(data); + } else if (toString.call(data) === "[object ArrayBuffer]") { + strm.input = new Uint8Array(data); + } else { + strm.input = data; } - if (options.type === "refresh") { - if (state.clientType === "oauth-app") { - throw new Error( - "[@octokit/auth-oauth-user] OAuth Apps do not support expiring tokens" - ); + strm.next_in = 0; + strm.avail_in = strm.input.length; + do { + if (strm.avail_out === 0) { + strm.output = new utils.Buf8(chunkSize); + strm.next_out = 0; + strm.avail_out = chunkSize; } - if (!currentAuthentication.hasOwnProperty("expiresAt")) { - throw new Error("[@octokit/auth-oauth-user] Refresh token missing"); + status3 = zlib_deflate.deflate(strm, _mode); + if (status3 !== Z_STREAM_END && status3 !== Z_OK) { + this.onEnd(status3); + this.ended = true; + return false; } - await ((_a = state.onTokenCreated) == null ? void 0 : _a.call(state, state.authentication, { - type: options.type - })); - } - if (options.type === "check" || options.type === "reset") { - const method = options.type === "check" ? import_oauth_methods2.checkToken : import_oauth_methods2.resetToken; - try { - const { authentication } = await method({ - // @ts-expect-error making TS happy would require unnecessary code so no - clientType: state.clientType, - clientId: state.clientId, - clientSecret: state.clientSecret, - token: state.authentication.token, - request: state.request - }); - state.authentication = { - tokenType: "oauth", - type: "token", - // @ts-expect-error TBD - ...authentication - }; - if (options.type === "reset") { - await ((_b = state.onTokenCreated) == null ? void 0 : _b.call(state, state.authentication, { - type: options.type - })); - } - return state.authentication; - } catch (error) { - if (error.status === 404) { - error.message = "[@octokit/auth-oauth-user] Token is invalid"; - state.authentication.invalid = true; + if (strm.avail_out === 0 || strm.avail_in === 0 && (_mode === Z_FINISH || _mode === Z_SYNC_FLUSH)) { + if (this.options.to === "string") { + this.onData(strings.buf2binstring(utils.shrinkBuf(strm.output, strm.next_out))); + } else { + this.onData(utils.shrinkBuf(strm.output, strm.next_out)); } - throw error; - } - } - if (options.type === "delete" || options.type === "deleteAuthorization") { - const method = options.type === "delete" ? import_oauth_methods2.deleteToken : import_oauth_methods2.deleteAuthorization; - try { - await method({ - // @ts-expect-error making TS happy would require unnecessary code so no - clientType: state.clientType, - clientId: state.clientId, - clientSecret: state.clientSecret, - token: state.authentication.token, - request: state.request - }); - } catch (error) { - if (error.status !== 404) - throw error; } - state.authentication.invalid = true; - return state.authentication; - } - return state.authentication; - } - var import_btoa_lite = __toESM2(require_btoa_node()); - var ROUTES_REQUIRING_BASIC_AUTH = /\/applications\/[^/]+\/(token|grant)s?/; - function requiresBasicAuth(url) { - return url && ROUTES_REQUIRING_BASIC_AUTH.test(url); - } - async function hook(state, request, route, parameters = {}) { - const endpoint = request.endpoint.merge( - route, - parameters - ); - if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) { - return request(endpoint); + } while ((strm.avail_in > 0 || strm.avail_out === 0) && status3 !== Z_STREAM_END); + if (_mode === Z_FINISH) { + status3 = zlib_deflate.deflateEnd(this.strm); + this.onEnd(status3); + this.ended = true; + return status3 === Z_OK; } - if (requiresBasicAuth(endpoint.url)) { - const credentials = (0, import_btoa_lite.default)(`${state.clientId}:${state.clientSecret}`); - endpoint.headers.authorization = `basic ${credentials}`; - return request(endpoint); + if (_mode === Z_SYNC_FLUSH) { + this.onEnd(Z_OK); + strm.avail_out = 0; + return true; } - const { token } = state.clientType === "oauth-app" ? await auth({ ...state, request }) : await auth({ ...state, request }); - endpoint.headers.authorization = "token " + token; - return request(endpoint); - } - function createOAuthUserAuth2({ - clientId, - clientSecret, - clientType = "oauth-app", - request = import_request.request.defaults({ - headers: { - "user-agent": `octokit-auth-oauth-app.js/${VERSION} ${(0, import_universal_user_agent.getUserAgent)()}` - } - }), - onTokenCreated, - ...strategyOptions - }) { - const state = Object.assign({ - clientType, - clientId, - clientSecret, - onTokenCreated, - strategyOptions, - request - }); - return Object.assign(auth.bind(null, state), { - // @ts-expect-error not worth the extra code needed to appease TS - hook: hook.bind(null, state) - }); - } - createOAuthUserAuth2.VERSION = VERSION; - } -}); - -// ../../../node_modules/.pnpm/@octokit+auth-oauth-app@7.1.0/node_modules/@octokit/auth-oauth-app/dist-node/index.js -var require_dist_node18 = __commonJS({ - "../../../node_modules/.pnpm/@octokit+auth-oauth-app@7.1.0/node_modules/@octokit/auth-oauth-app/dist-node/index.js"(exports2, module2) { - "use strict"; - var __create2 = Object.create; - var __defProp2 = Object.defineProperty; - var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; - var __getOwnPropNames2 = Object.getOwnPropertyNames; - var __getProtoOf2 = Object.getPrototypeOf; - var __hasOwnProp2 = Object.prototype.hasOwnProperty; - var __export2 = (target, all) => { - for (var name in all) - __defProp2(target, name, { get: all[name], enumerable: true }); + return true; }; - var __copyProps2 = (to, from3, except, desc) => { - if (from3 && typeof from3 === "object" || typeof from3 === "function") { - for (let key of __getOwnPropNames2(from3)) - if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc2(from3, key)) || desc.enumerable }); - } - return to; + Deflate.prototype.onData = function(chunk) { + this.chunks.push(chunk); }; - var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2( - // If the importer is in node compatibility mode or this is not an ESM - // file that has been converted to a CommonJS file using a Babel- - // compatible transform (i.e. "__esModule" has not been set), then set - // "default" to the CommonJS "module.exports" for node compatibility. - isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target, - mod - )); - var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); - var dist_src_exports = {}; - __export2(dist_src_exports, { - createOAuthAppAuth: () => createOAuthAppAuth, - createOAuthUserAuth: () => import_auth_oauth_user3.createOAuthUserAuth - }); - module2.exports = __toCommonJS2(dist_src_exports); - var import_universal_user_agent = require_dist_node(); - var import_request = require_dist_node5(); - var import_btoa_lite = __toESM2(require_btoa_node()); - var import_auth_oauth_user = require_dist_node17(); - async function auth(state, authOptions) { - if (authOptions.type === "oauth-app") { - return { - type: "oauth-app", - clientId: state.clientId, - clientSecret: state.clientSecret, - clientType: state.clientType, - headers: { - authorization: `basic ${(0, import_btoa_lite.default)( - `${state.clientId}:${state.clientSecret}` - )}` - } - }; + Deflate.prototype.onEnd = function(status3) { + if (status3 === Z_OK) { + if (this.options.to === "string") { + this.result = this.chunks.join(""); + } else { + this.result = utils.flattenChunks(this.chunks); + } } - if ("factory" in authOptions) { - const { type, ...options } = { - ...authOptions, - ...state - }; - return authOptions.factory(options); + this.chunks = []; + this.err = status3; + this.msg = this.strm.msg; + }; + function deflate2(input, options) { + var deflator = new Deflate(options); + deflator.push(input, true); + if (deflator.err) { + throw deflator.msg || msg[deflator.err]; } - const common = { - clientId: state.clientId, - clientSecret: state.clientSecret, - request: state.request, - ...authOptions - }; - const userAuth = state.clientType === "oauth-app" ? await (0, import_auth_oauth_user.createOAuthUserAuth)({ - ...common, - clientType: state.clientType - }) : await (0, import_auth_oauth_user.createOAuthUserAuth)({ - ...common, - clientType: state.clientType - }); - return userAuth(); + return deflator.result; } - var import_btoa_lite2 = __toESM2(require_btoa_node()); - var import_auth_oauth_user2 = require_dist_node17(); - async function hook(state, request2, route, parameters) { - let endpoint = request2.endpoint.merge( - route, - parameters - ); - if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) { - return request2(endpoint); - } - if (state.clientType === "github-app" && !(0, import_auth_oauth_user2.requiresBasicAuth)(endpoint.url)) { - throw new Error( - `[@octokit/auth-oauth-app] GitHub Apps cannot use their client ID/secret for basic authentication for endpoints other than "/applications/{client_id}/**". "${endpoint.method} ${endpoint.url}" is not supported.` - ); - } - const credentials = (0, import_btoa_lite2.default)(`${state.clientId}:${state.clientSecret}`); - endpoint.headers.authorization = `basic ${credentials}`; - try { - return await request2(endpoint); - } catch (error) { - if (error.status !== 401) - throw error; - error.message = `[@octokit/auth-oauth-app] "${endpoint.method} ${endpoint.url}" does not support clientId/clientSecret basic authentication.`; - throw error; - } + function deflateRaw(input, options) { + options = options || {}; + options.raw = true; + return deflate2(input, options); } - var VERSION = "7.1.0"; - var import_auth_oauth_user3 = require_dist_node17(); - function createOAuthAppAuth(options) { - const state = Object.assign( - { - request: import_request.request.defaults({ - headers: { - "user-agent": `octokit-auth-oauth-app.js/${VERSION} ${(0, import_universal_user_agent.getUserAgent)()}` - } - }), - clientType: "oauth-app" - }, - options - ); - return Object.assign(auth.bind(null, state), { - hook: hook.bind(null, state) - }); + function gzip(input, options) { + options = options || {}; + options.gzip = true; + return deflate2(input, options); } + exports2.Deflate = Deflate; + exports2.deflate = deflate2; + exports2.deflateRaw = deflateRaw; + exports2.gzip = gzip; } }); -// ../../../node_modules/.pnpm/safe-buffer@5.2.1/node_modules/safe-buffer/index.js -var require_safe_buffer = __commonJS({ - "../../../node_modules/.pnpm/safe-buffer@5.2.1/node_modules/safe-buffer/index.js"(exports2, module2) { - var buffer = require("buffer"); - var Buffer2 = buffer.Buffer; - function copyProps(src, dst) { - for (var key in src) { - dst[key] = src[key]; - } - } - if (Buffer2.from && Buffer2.alloc && Buffer2.allocUnsafe && Buffer2.allocUnsafeSlow) { - module2.exports = buffer; - } else { - copyProps(buffer, exports2); - exports2.Buffer = SafeBuffer; - } - function SafeBuffer(arg, encodingOrOffset, length) { - return Buffer2(arg, encodingOrOffset, length); - } - SafeBuffer.prototype = Object.create(Buffer2.prototype); - copyProps(Buffer2, SafeBuffer); - SafeBuffer.from = function(arg, encodingOrOffset, length) { - if (typeof arg === "number") { - throw new TypeError("Argument must not be a number"); - } - return Buffer2(arg, encodingOrOffset, length); +// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/inffast.js +var require_inffast = __commonJS({ + "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/inffast.js"(exports2, module2) { + "use strict"; + var BAD = 30; + var TYPE = 12; + module2.exports = function inflate_fast(strm, start) { + var state; + var _in; + var last; + var _out; + var beg; + var end; + var dmax; + var wsize; + var whave; + var wnext; + var s_window; + var hold; + var bits; + var lcode; + var dcode; + var lmask; + var dmask; + var here; + var op; + var len; + var dist; + var from2; + var from_source; + var input, output; + state = strm.state; + _in = strm.next_in; + input = strm.input; + last = _in + (strm.avail_in - 5); + _out = strm.next_out; + output = strm.output; + beg = _out - (start - strm.avail_out); + end = _out + (strm.avail_out - 257); + dmax = state.dmax; + wsize = state.wsize; + whave = state.whave; + wnext = state.wnext; + s_window = state.window; + hold = state.hold; + bits = state.bits; + lcode = state.lencode; + dcode = state.distcode; + lmask = (1 << state.lenbits) - 1; + dmask = (1 << state.distbits) - 1; + top: + do { + if (bits < 15) { + hold += input[_in++] << bits; + bits += 8; + hold += input[_in++] << bits; + bits += 8; + } + here = lcode[hold & lmask]; + dolen: + for (; ; ) { + op = here >>> 24; + hold >>>= op; + bits -= op; + op = here >>> 16 & 255; + if (op === 0) { + output[_out++] = here & 65535; + } else if (op & 16) { + len = here & 65535; + op &= 15; + if (op) { + if (bits < op) { + hold += input[_in++] << bits; + bits += 8; + } + len += hold & (1 << op) - 1; + hold >>>= op; + bits -= op; + } + if (bits < 15) { + hold += input[_in++] << bits; + bits += 8; + hold += input[_in++] << bits; + bits += 8; + } + here = dcode[hold & dmask]; + dodist: + for (; ; ) { + op = here >>> 24; + hold >>>= op; + bits -= op; + op = here >>> 16 & 255; + if (op & 16) { + dist = here & 65535; + op &= 15; + if (bits < op) { + hold += input[_in++] << bits; + bits += 8; + if (bits < op) { + hold += input[_in++] << bits; + bits += 8; + } + } + dist += hold & (1 << op) - 1; + if (dist > dmax) { + strm.msg = "invalid distance too far back"; + state.mode = BAD; + break top; + } + hold >>>= op; + bits -= op; + op = _out - beg; + if (dist > op) { + op = dist - op; + if (op > whave) { + if (state.sane) { + strm.msg = "invalid distance too far back"; + state.mode = BAD; + break top; + } + } + from2 = 0; + from_source = s_window; + if (wnext === 0) { + from2 += wsize - op; + if (op < len) { + len -= op; + do { + output[_out++] = s_window[from2++]; + } while (--op); + from2 = _out - dist; + from_source = output; + } + } else if (wnext < op) { + from2 += wsize + wnext - op; + op -= wnext; + if (op < len) { + len -= op; + do { + output[_out++] = s_window[from2++]; + } while (--op); + from2 = 0; + if (wnext < len) { + op = wnext; + len -= op; + do { + output[_out++] = s_window[from2++]; + } while (--op); + from2 = _out - dist; + from_source = output; + } + } + } else { + from2 += wnext - op; + if (op < len) { + len -= op; + do { + output[_out++] = s_window[from2++]; + } while (--op); + from2 = _out - dist; + from_source = output; + } + } + while (len > 2) { + output[_out++] = from_source[from2++]; + output[_out++] = from_source[from2++]; + output[_out++] = from_source[from2++]; + len -= 3; + } + if (len) { + output[_out++] = from_source[from2++]; + if (len > 1) { + output[_out++] = from_source[from2++]; + } + } + } else { + from2 = _out - dist; + do { + output[_out++] = output[from2++]; + output[_out++] = output[from2++]; + output[_out++] = output[from2++]; + len -= 3; + } while (len > 2); + if (len) { + output[_out++] = output[from2++]; + if (len > 1) { + output[_out++] = output[from2++]; + } + } + } + } else if ((op & 64) === 0) { + here = dcode[(here & 65535) + (hold & (1 << op) - 1)]; + continue dodist; + } else { + strm.msg = "invalid distance code"; + state.mode = BAD; + break top; + } + break; + } + } else if ((op & 64) === 0) { + here = lcode[(here & 65535) + (hold & (1 << op) - 1)]; + continue dolen; + } else if (op & 32) { + state.mode = TYPE; + break top; + } else { + strm.msg = "invalid literal/length code"; + state.mode = BAD; + break top; + } + break; + } + } while (_in < last && _out < end); + len = bits >> 3; + _in -= len; + bits -= len << 3; + hold &= (1 << bits) - 1; + strm.next_in = _in; + strm.next_out = _out; + strm.avail_in = _in < last ? 5 + (last - _in) : 5 - (_in - last); + strm.avail_out = _out < end ? 257 + (end - _out) : 257 - (_out - end); + state.hold = hold; + state.bits = bits; + return; }; - SafeBuffer.alloc = function(size, fill, encoding) { - if (typeof size !== "number") { - throw new TypeError("Argument must be a number"); + } +}); + +// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/inftrees.js +var require_inftrees = __commonJS({ + "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/inftrees.js"(exports2, module2) { + "use strict"; + var utils = require_common(); + var MAXBITS = 15; + var ENOUGH_LENS = 852; + var ENOUGH_DISTS = 592; + var CODES = 0; + var LENS = 1; + var DISTS = 2; + var lbase = [ + /* Length codes 257..285 base */ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 13, + 15, + 17, + 19, + 23, + 27, + 31, + 35, + 43, + 51, + 59, + 67, + 83, + 99, + 115, + 131, + 163, + 195, + 227, + 258, + 0, + 0 + ]; + var lext = [ + /* Length codes 257..285 extra */ + 16, + 16, + 16, + 16, + 16, + 16, + 16, + 16, + 17, + 17, + 17, + 17, + 18, + 18, + 18, + 18, + 19, + 19, + 19, + 19, + 20, + 20, + 20, + 20, + 21, + 21, + 21, + 21, + 16, + 72, + 78 + ]; + var dbase = [ + /* Distance codes 0..29 base */ + 1, + 2, + 3, + 4, + 5, + 7, + 9, + 13, + 17, + 25, + 33, + 49, + 65, + 97, + 129, + 193, + 257, + 385, + 513, + 769, + 1025, + 1537, + 2049, + 3073, + 4097, + 6145, + 8193, + 12289, + 16385, + 24577, + 0, + 0 + ]; + var dext = [ + /* Distance codes 0..29 extra */ + 16, + 16, + 16, + 16, + 17, + 17, + 18, + 18, + 19, + 19, + 20, + 20, + 21, + 21, + 22, + 22, + 23, + 23, + 24, + 24, + 25, + 25, + 26, + 26, + 27, + 27, + 28, + 28, + 29, + 29, + 64, + 64 + ]; + module2.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts) { + var bits = opts.bits; + var len = 0; + var sym = 0; + var min = 0, max = 0; + var root = 0; + var curr = 0; + var drop = 0; + var left = 0; + var used = 0; + var huff = 0; + var incr; + var fill; + var low; + var mask; + var next; + var base = null; + var base_index = 0; + var end; + var count = new utils.Buf16(MAXBITS + 1); + var offs = new utils.Buf16(MAXBITS + 1); + var extra = null; + var extra_index = 0; + var here_bits, here_op, here_val; + for (len = 0; len <= MAXBITS; len++) { + count[len] = 0; } - var buf = Buffer2(size); - if (fill !== void 0) { - if (typeof encoding === "string") { - buf.fill(fill, encoding); - } else { - buf.fill(fill); + for (sym = 0; sym < codes; sym++) { + count[lens[lens_index + sym]]++; + } + root = bits; + for (max = MAXBITS; max >= 1; max--) { + if (count[max] !== 0) { + break; } - } else { - buf.fill(0); } - return buf; - }; - SafeBuffer.allocUnsafe = function(size) { - if (typeof size !== "number") { - throw new TypeError("Argument must be a number"); + if (root > max) { + root = max; } - return Buffer2(size); - }; - SafeBuffer.allocUnsafeSlow = function(size) { - if (typeof size !== "number") { - throw new TypeError("Argument must be a number"); + if (max === 0) { + table[table_index++] = 1 << 24 | 64 << 16 | 0; + table[table_index++] = 1 << 24 | 64 << 16 | 0; + opts.bits = 1; + return 0; } - return buffer.SlowBuffer(size); - }; - } -}); - -// ../../../node_modules/.pnpm/jws@3.2.2/node_modules/jws/lib/data-stream.js -var require_data_stream = __commonJS({ - "../../../node_modules/.pnpm/jws@3.2.2/node_modules/jws/lib/data-stream.js"(exports2, module2) { - var Buffer2 = require_safe_buffer().Buffer; - var Stream = require("stream"); - var util = require("util"); - function DataStream(data) { - this.buffer = null; - this.writable = true; - this.readable = true; - if (!data) { - this.buffer = Buffer2.alloc(0); - return this; + for (min = 1; min < max; min++) { + if (count[min] !== 0) { + break; + } } - if (typeof data.pipe === "function") { - this.buffer = Buffer2.alloc(0); - data.pipe(this); - return this; + if (root < min) { + root = min; } - 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; + left = 1; + for (len = 1; len <= MAXBITS; len++) { + left <<= 1; + left -= count[len]; + if (left < 0) { + return -1; + } } - throw new TypeError("Unexpected data type (" + typeof data + ")"); - } - util.inherits(DataStream, Stream); - DataStream.prototype.write = function write(data) { - this.buffer = Buffer2.concat([this.buffer, Buffer2.from(data)]); - this.emit("data", data); - }; - DataStream.prototype.end = function end(data) { - if (data) - this.write(data); - this.emit("end", data); - this.emit("close"); - this.writable = false; - this.readable = false; - }; - module2.exports = DataStream; - } -}); - -// ../../../node_modules/.pnpm/buffer-equal-constant-time@1.0.1/node_modules/buffer-equal-constant-time/index.js -var require_buffer_equal_constant_time = __commonJS({ - "../../../node_modules/.pnpm/buffer-equal-constant-time@1.0.1/node_modules/buffer-equal-constant-time/index.js"(exports2, module2) { - "use strict"; - var Buffer2 = require("buffer").Buffer; - var SlowBuffer = require("buffer").SlowBuffer; - module2.exports = bufferEq; - function bufferEq(a, b) { - if (!Buffer2.isBuffer(a) || !Buffer2.isBuffer(b)) { - return false; + if (left > 0 && (type === CODES || max !== 1)) { + return -1; } - if (a.length !== b.length) { - return false; + offs[1] = 0; + for (len = 1; len < MAXBITS; len++) { + offs[len + 1] = offs[len] + count[len]; } - var c = 0; - for (var i = 0; i < a.length; i++) { - c |= a[i] ^ b[i]; + for (sym = 0; sym < codes; sym++) { + if (lens[lens_index + sym] !== 0) { + work[offs[lens[lens_index + sym]]++] = sym; + } } - return c === 0; - } - bufferEq.install = function() { - Buffer2.prototype.equal = SlowBuffer.prototype.equal = function equal(that) { - return bufferEq(this, that); - }; - }; - var origBufEqual = Buffer2.prototype.equal; - var origSlowBufEqual = SlowBuffer.prototype.equal; - bufferEq.restore = function() { - Buffer2.prototype.equal = origBufEqual; - SlowBuffer.prototype.equal = origSlowBufEqual; - }; - } -}); - -// ../../../node_modules/.pnpm/ecdsa-sig-formatter@1.0.11/node_modules/ecdsa-sig-formatter/src/param-bytes-for-alg.js -var require_param_bytes_for_alg = __commonJS({ - "../../../node_modules/.pnpm/ecdsa-sig-formatter@1.0.11/node_modules/ecdsa-sig-formatter/src/param-bytes-for-alg.js"(exports2, module2) { - "use strict"; - function getParamSize(keySize) { - var result = (keySize / 8 | 0) + (keySize % 8 === 0 ? 0 : 1); - return result; - } - var paramBytesForAlg = { - ES256: getParamSize(256), - ES384: getParamSize(384), - ES512: getParamSize(521) - }; - function getParamBytesForAlg(alg) { - var paramBytes = paramBytesForAlg[alg]; - if (paramBytes) { - return paramBytes; - } - throw new Error('Unknown algorithm "' + alg + '"'); - } - module2.exports = getParamBytesForAlg; - } -}); - -// ../../../node_modules/.pnpm/ecdsa-sig-formatter@1.0.11/node_modules/ecdsa-sig-formatter/src/ecdsa-sig-formatter.js -var require_ecdsa_sig_formatter = __commonJS({ - "../../../node_modules/.pnpm/ecdsa-sig-formatter@1.0.11/node_modules/ecdsa-sig-formatter/src/ecdsa-sig-formatter.js"(exports2, module2) { - "use strict"; - var Buffer2 = require_safe_buffer().Buffer; - var getParamBytesForAlg = require_param_bytes_for_alg(); - var MAX_OCTET = 128; - var CLASS_UNIVERSAL = 0; - var PRIMITIVE_BIT = 32; - var TAG_SEQ = 16; - var TAG_INT = 2; - var ENCODED_TAG_SEQ = TAG_SEQ | PRIMITIVE_BIT | CLASS_UNIVERSAL << 6; - var ENCODED_TAG_INT = TAG_INT | CLASS_UNIVERSAL << 6; - function base64Url(base64) { - return base64.replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_"); - } - function signatureAsBuffer(signature) { - if (Buffer2.isBuffer(signature)) { - return signature; - } else if ("string" === typeof signature) { - return Buffer2.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 = Buffer2.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; - } - var needsSign = buf[start + padding] >= MAX_OCTET; - if (needsSign) { - --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 = 1 + 1 + rLength + 1 + 1 + sLength; - var shortLength = rsBytes < MAX_OCTET; - var dst = Buffer2.allocUnsafe((shortLength ? 2 : 3) + rsBytes); - var offset = 0; - dst[offset++] = ENCODED_TAG_SEQ; - if (shortLength) { - dst[offset++] = rsBytes; + if (type === CODES) { + base = extra = work; + end = 19; + } else if (type === LENS) { + base = lbase; + base_index -= 257; + extra = lext; + extra_index -= 257; + end = 256; } else { - dst[offset++] = MAX_OCTET | 1; - dst[offset++] = rsBytes & 255; + base = dbase; + extra = dext; + end = -1; } - 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); + huff = 0; + sym = 0; + len = min; + next = table_index; + curr = root; + drop = 0; + low = -1; + used = 1 << root; + mask = used - 1; + if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) { + return 1; } - 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); + for (; ; ) { + here_bits = len - drop; + if (work[sym] < end) { + here_op = 0; + here_val = work[sym]; + } else if (work[sym] > end) { + here_op = extra[extra_index + work[sym]]; + here_val = base[base_index + work[sym]]; + } else { + here_op = 32 + 64; + here_val = 0; + } + incr = 1 << len - drop; + fill = 1 << curr; + min = fill; + do { + fill -= incr; + table[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0; + } while (fill !== 0); + incr = 1 << len - 1; + while (huff & incr) { + incr >>= 1; + } + if (incr !== 0) { + huff &= incr - 1; + huff += incr; + } else { + huff = 0; + } + sym++; + if (--count[len] === 0) { + if (len === max) { + break; + } + len = lens[lens_index + work[sym]]; + } + if (len > root && (huff & mask) !== low) { + if (drop === 0) { + drop = root; + } + next += min; + curr = len - drop; + left = 1 << curr; + while (curr + drop < max) { + left -= count[curr + drop]; + if (left <= 0) { + break; + } + curr++; + left <<= 1; + } + used += 1 << curr; + if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) { + return 1; + } + low = huff & mask; + table[low] = root << 24 | curr << 16 | next - table_index | 0; + } } - return dst; - } - module2.exports = { - derToJose, - joseToDer + if (huff !== 0) { + table[next + huff] = len - drop << 24 | 64 << 16 | 0; + } + opts.bits = root; + return 0; }; } }); -// ../../../node_modules/.pnpm/jwa@1.4.1/node_modules/jwa/index.js -var require_jwa = __commonJS({ - "../../../node_modules/.pnpm/jwa@1.4.1/node_modules/jwa/index.js"(exports2, module2) { - var bufferEqual = require_buffer_equal_constant_time(); - var Buffer2 = require_safe_buffer().Buffer; - var crypto5 = require("crypto"); - var formatEcdsa = require_ecdsa_sig_formatter(); - var util = 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 crypto5.createPublicKey === "function"; - if (supportsKeyObjects) { - MSG_INVALID_VERIFIER_KEY += " or a KeyObject"; - MSG_INVALID_SECRET += "or a KeyObject"; +// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/inflate.js +var require_inflate = __commonJS({ + "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/inflate.js"(exports2) { + "use strict"; + var utils = require_common(); + var adler32 = require_adler32(); + var crc322 = require_crc322(); + var inflate_fast = require_inffast(); + var inflate_table = require_inftrees(); + var CODES = 0; + var LENS = 1; + var DISTS = 2; + var Z_FINISH = 4; + var Z_BLOCK = 5; + var Z_TREES = 6; + var Z_OK = 0; + var Z_STREAM_END = 1; + var Z_NEED_DICT = 2; + var Z_STREAM_ERROR = -2; + var Z_DATA_ERROR = -3; + var Z_MEM_ERROR = -4; + var Z_BUF_ERROR = -5; + var Z_DEFLATED = 8; + var HEAD = 1; + var FLAGS = 2; + var TIME = 3; + var OS = 4; + var EXLEN = 5; + var EXTRA = 6; + var NAME = 7; + var COMMENT = 8; + var HCRC = 9; + var DICTID = 10; + var DICT = 11; + var TYPE = 12; + var TYPEDO = 13; + var STORED = 14; + var COPY_ = 15; + var COPY = 16; + var TABLE = 17; + var LENLENS = 18; + var CODELENS = 19; + var LEN_ = 20; + var LEN = 21; + var LENEXT = 22; + var DIST = 23; + var DISTEXT = 24; + var MATCH = 25; + var LIT = 26; + var CHECK = 27; + var LENGTH = 28; + var DONE = 29; + var BAD = 30; + var MEM = 31; + var SYNC = 32; + var ENOUGH_LENS = 852; + var ENOUGH_DISTS = 592; + var MAX_WBITS = 15; + var DEF_WBITS = MAX_WBITS; + function zswap32(q) { + return (q >>> 24 & 255) + (q >>> 8 & 65280) + ((q & 65280) << 8) + ((q & 255) << 24); } - function checkIsPublicKey(key) { - if (Buffer2.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 InflateState() { + this.mode = 0; + this.last = false; + this.wrap = 0; + this.havedict = false; + this.flags = 0; + this.dmax = 0; + this.check = 0; + this.total = 0; + this.head = null; + this.wbits = 0; + this.wsize = 0; + this.whave = 0; + this.wnext = 0; + this.window = null; + this.hold = 0; + this.bits = 0; + this.length = 0; + this.offset = 0; + this.extra = 0; + this.lencode = null; + this.distcode = null; + this.lenbits = 0; + this.distbits = 0; + this.ncode = 0; + this.nlen = 0; + this.ndist = 0; + this.have = 0; + this.next = null; + this.lens = new utils.Buf16(320); + this.work = new utils.Buf16(288); + this.lendyn = null; + this.distdyn = null; + this.sane = 0; + this.back = 0; + this.was = 0; } - function checkIsPrivateKey(key) { - if (Buffer2.isBuffer(key)) { - return; + function inflateResetKeep(strm) { + var state; + if (!strm || !strm.state) { + return Z_STREAM_ERROR; } - if (typeof key === "string") { - return; + state = strm.state; + strm.total_in = strm.total_out = state.total = 0; + strm.msg = ""; + if (state.wrap) { + strm.adler = state.wrap & 1; } - if (typeof key === "object") { - return; + state.mode = HEAD; + state.last = 0; + state.havedict = 0; + state.dmax = 32768; + state.head = null; + state.hold = 0; + state.bits = 0; + state.lencode = state.lendyn = new utils.Buf32(ENOUGH_LENS); + state.distcode = state.distdyn = new utils.Buf32(ENOUGH_DISTS); + state.sane = 1; + state.back = -1; + return Z_OK; + } + function inflateReset(strm) { + var state; + if (!strm || !strm.state) { + return Z_STREAM_ERROR; } - throw typeError(MSG_INVALID_SIGNER_KEY); + state = strm.state; + state.wsize = 0; + state.whave = 0; + state.wnext = 0; + return inflateResetKeep(strm); } - function checkIsSecretKey(key) { - if (Buffer2.isBuffer(key)) { - return; + function inflateReset2(strm, windowBits) { + var wrap; + var state; + if (!strm || !strm.state) { + return Z_STREAM_ERROR; } - if (typeof key === "string") { - return key; + state = strm.state; + if (windowBits < 0) { + wrap = 0; + windowBits = -windowBits; + } else { + wrap = (windowBits >> 4) + 1; + if (windowBits < 48) { + windowBits &= 15; + } } - if (!supportsKeyObjects) { - throw typeError(MSG_INVALID_SECRET); + if (windowBits && (windowBits < 8 || windowBits > 15)) { + return Z_STREAM_ERROR; } - if (typeof key !== "object") { - throw typeError(MSG_INVALID_SECRET); + if (state.window !== null && state.wbits !== windowBits) { + state.window = null; } - if (key.type !== "secret") { - throw typeError(MSG_INVALID_SECRET); + state.wrap = wrap; + state.wbits = windowBits; + return inflateReset(strm); + } + function inflateInit2(strm, windowBits) { + var ret; + var state; + if (!strm) { + return Z_STREAM_ERROR; } - if (typeof key.export !== "function") { - throw typeError(MSG_INVALID_SECRET); + state = new InflateState(); + strm.state = state; + state.window = null; + ret = inflateReset2(strm, windowBits); + if (ret !== Z_OK) { + strm.state = null; } + return ret; } - function fromBase64(base64) { - return base64.replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_"); + function inflateInit(strm) { + return inflateInit2(strm, DEF_WBITS); } - function toBase64(base64url) { - base64url = base64url.toString(); - var padding = 4 - base64url.length % 4; - if (padding !== 4) { - for (var i = 0; i < padding; ++i) { - base64url += "="; + var virgin = true; + var lenfix; + var distfix; + function fixedtables(state) { + if (virgin) { + var sym; + lenfix = new utils.Buf32(512); + distfix = new utils.Buf32(32); + sym = 0; + while (sym < 144) { + state.lens[sym++] = 8; + } + while (sym < 256) { + state.lens[sym++] = 9; + } + while (sym < 280) { + state.lens[sym++] = 7; + } + while (sym < 288) { + state.lens[sym++] = 8; + } + inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 }); + sym = 0; + while (sym < 32) { + state.lens[sym++] = 5; } + inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 }); + virgin = false; } - return base64url.replace(/\-/g, "+").replace(/_/g, "/"); - } - function typeError(template) { - var args = [].slice.call(arguments, 1); - var errMsg = util.format.bind(util, template).apply(null, args); - return new TypeError(errMsg); - } - function bufferOrString(obj) { - return Buffer2.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 = crypto5.createHmac("sha" + bits, secret); - var sig = (hmac.update(thing), hmac.digest("base64")); - return fromBase64(sig); - }; - } - function createHmacVerifier(bits) { - return function verify(thing, signature, secret) { - var computedSig = createHmacSigner(bits)(thing, secret); - return bufferEqual(Buffer2.from(signature), Buffer2.from(computedSig)); - }; - } - function createKeySigner(bits) { - return function sign(thing, privateKey) { - checkIsPrivateKey(privateKey); - thing = normalizeInput(thing); - var signer = crypto5.createSign("RSA-SHA" + bits); - var sig = (signer.update(thing), signer.sign(privateKey, "base64")); - return fromBase64(sig); - }; - } - function createKeyVerifier(bits) { - return function verify(thing, signature, publicKey) { - checkIsPublicKey(publicKey); - thing = normalizeInput(thing); - signature = toBase64(signature); - var verifier = crypto5.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 = crypto5.createSign("RSA-SHA" + bits); - var sig = (signer.update(thing), signer.sign({ - key: privateKey, - padding: crypto5.constants.RSA_PKCS1_PSS_PADDING, - saltLength: crypto5.constants.RSA_PSS_SALTLEN_DIGEST - }, "base64")); - return fromBase64(sig); - }; - } - function createPSSKeyVerifier(bits) { - return function verify(thing, signature, publicKey) { - checkIsPublicKey(publicKey); - thing = normalizeInput(thing); - signature = toBase64(signature); - var verifier = crypto5.createVerify("RSA-SHA" + bits); - verifier.update(thing); - return verifier.verify({ - key: publicKey, - padding: crypto5.constants.RSA_PKCS1_PSS_PADDING, - saltLength: crypto5.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"); - var result = inner(thing, signature, publicKey); - return result; - }; - } - function createNoneSigner() { - return function sign() { - return ""; - }; - } - function createNoneVerifier() { - return function verify(thing, signature) { - return signature === ""; - }; - } - module2.exports = function jwa(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)$/i); - 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) - }; - }; - } -}); - -// ../../../node_modules/.pnpm/jws@3.2.2/node_modules/jws/lib/tostring.js -var require_tostring = __commonJS({ - "../../../node_modules/.pnpm/jws@3.2.2/node_modules/jws/lib/tostring.js"(exports2, module2) { - var Buffer2 = require("buffer").Buffer; - module2.exports = function toString(obj) { - if (typeof obj === "string") - return obj; - if (typeof obj === "number" || Buffer2.isBuffer(obj)) - return obj.toString(); - return JSON.stringify(obj); - }; - } -}); - -// ../../../node_modules/.pnpm/jws@3.2.2/node_modules/jws/lib/sign-stream.js -var require_sign_stream = __commonJS({ - "../../../node_modules/.pnpm/jws@3.2.2/node_modules/jws/lib/sign-stream.js"(exports2, module2) { - var Buffer2 = 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"); - function base64url(string, encoding) { - return Buffer2.from(string, encoding).toString("base64").replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_"); - } - function jwsSecuredInput(header, payload, encoding) { - encoding = encoding || "utf8"; - var encodedHeader = base64url(toString(header), "binary"); - var encodedPayload = base64url(toString(payload), encoding); - return util.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(header.alg); - var securedInput = jwsSecuredInput(header, payload, encoding); - var signature = algo.sign(securedInput, secretOrKey); - return util.format("%s.%s", securedInput, signature); - } - function SignStream(opts) { - var secret = opts.secret || opts.privateKey || opts.key; - var secretStream = new DataStream(secret); - this.readable = true; - this.header = opts.header; - this.encoding = opts.encoding; - this.secret = this.privateKey = this.key = secretStream; - this.payload = new DataStream(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.inherits(SignStream, Stream); - SignStream.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.sign = jwsSign; - module2.exports = SignStream; - } -}); - -// ../../../node_modules/.pnpm/jws@3.2.2/node_modules/jws/lib/verify-stream.js -var require_verify_stream = __commonJS({ - "../../../node_modules/.pnpm/jws@3.2.2/node_modules/jws/lib/verify-stream.js"(exports2, module2) { - var Buffer2 = 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 isObject2(thing) { - return Object.prototype.toString.call(thing) === "[object Object]"; - } - function safeJsonParse(thing) { - if (isObject2(thing)) - return thing; - try { - return JSON.parse(thing); - } catch (e) { - return void 0; - } - } - function headerFromJWS(jwsSig) { - var encodedHeader = jwsSig.split(".", 1)[0]; - return safeJsonParse(Buffer2.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 Buffer2.from(payload, "base64").toString(encoding); - } - function isValidJws(string) { - return JWS_REGEX.test(string) && !!headerFromJWS(string); - } - function jwsVerify(jwsSig, algorithm, secretOrKey) { - if (!algorithm) { - var err = 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); - var algo = jwa(algorithm); - return algo.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(opts) { - opts = opts || {}; - var secretOrKey = opts.secret || opts.publicKey || opts.key; - 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)); + state.lencode = lenfix; + state.lenbits = 9; + state.distcode = distfix; + state.distbits = 5; } - util.inherits(VerifyStream, Stream); - VerifyStream.prototype.verify = function verify() { - try { - var valid = jwsVerify(this.signature.buffer, this.algorithm, this.key.buffer); - var obj = jwsDecode(this.signature.buffer, this.encoding); - this.emit("done", valid, obj); - this.emit("data", valid); - this.emit("end"); - this.readable = false; - return valid; - } catch (e) { - this.readable = false; - this.emit("error", e); - this.emit("close"); - } - }; - VerifyStream.decode = jwsDecode; - VerifyStream.isValid = isValidJws; - VerifyStream.verify = jwsVerify; - module2.exports = VerifyStream; - } -}); - -// ../../../node_modules/.pnpm/jws@3.2.2/node_modules/jws/index.js -var require_jws = __commonJS({ - "../../../node_modules/.pnpm/jws@3.2.2/node_modules/jws/index.js"(exports2) { - var SignStream = require_sign_stream(); - var VerifyStream = require_verify_stream(); - var ALGORITHMS = [ - "HS256", - "HS384", - "HS512", - "RS256", - "RS384", - "RS512", - "PS256", - "PS384", - "PS512", - "ES256", - "ES384", - "ES512" - ]; - exports2.ALGORITHMS = ALGORITHMS; - exports2.sign = SignStream.sign; - exports2.verify = VerifyStream.verify; - exports2.decode = VerifyStream.decode; - exports2.isValid = VerifyStream.isValid; - exports2.createSign = function createSign(opts) { - return new SignStream(opts); - }; - exports2.createVerify = function createVerify(opts) { - return new VerifyStream(opts); - }; - } -}); - -// ../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/decode.js -var require_decode = __commonJS({ - "../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/decode.js"(exports2, module2) { - var jws = require_jws(); - module2.exports = function(jwt, options) { - options = options || {}; - var decoded = jws.decode(jwt, options); - if (!decoded) { - return null; + function updatewindow(strm, src, end, copy) { + var dist; + var state = strm.state; + if (state.window === null) { + state.wsize = 1 << state.wbits; + state.wnext = 0; + state.whave = 0; + state.window = new utils.Buf8(state.wsize); } - var payload = decoded.payload; - if (typeof payload === "string") { - try { - var obj = JSON.parse(payload); - if (obj !== null && typeof obj === "object") { - payload = obj; + if (copy >= state.wsize) { + utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0); + state.wnext = 0; + state.whave = state.wsize; + } else { + dist = state.wsize - state.wnext; + if (dist > copy) { + dist = copy; + } + utils.arraySet(state.window, src, end - copy, dist, state.wnext); + copy -= dist; + if (copy) { + utils.arraySet(state.window, src, end - copy, copy, 0); + state.wnext = copy; + state.whave = state.wsize; + } else { + state.wnext += dist; + if (state.wnext === state.wsize) { + state.wnext = 0; + } + if (state.whave < state.wsize) { + state.whave += dist; } - } catch (e) { } } - if (options.complete === true) { - return { - header: decoded.header, - payload, - signature: decoded.signature - }; - } - return payload; - }; - } -}); - -// ../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/JsonWebTokenError.js -var require_JsonWebTokenError = __commonJS({ - "../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/JsonWebTokenError.js"(exports2, module2) { - var JsonWebTokenError = function(message, error) { - Error.call(this, message); - if (Error.captureStackTrace) { - Error.captureStackTrace(this, this.constructor); + return 0; + } + function inflate2(strm, flush) { + var state; + var input, output; + var next; + var put; + var have, left; + var hold; + var bits; + var _in, _out; + var copy; + var from2; + var from_source; + var here = 0; + var here_bits, here_op, here_val; + var last_bits, last_op, last_val; + var len; + var ret; + var hbuf = new utils.Buf8(4); + var opts; + var n; + var order = ( + /* permutation of code lengths */ + [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15] + ); + if (!strm || !strm.state || !strm.output || !strm.input && strm.avail_in !== 0) { + return Z_STREAM_ERROR; } - this.name = "JsonWebTokenError"; - this.message = message; - if (error) - this.inner = error; - }; - JsonWebTokenError.prototype = Object.create(Error.prototype); - JsonWebTokenError.prototype.constructor = JsonWebTokenError; - module2.exports = JsonWebTokenError; - } -}); - -// ../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/NotBeforeError.js -var require_NotBeforeError = __commonJS({ - "../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/NotBeforeError.js"(exports2, module2) { - var JsonWebTokenError = require_JsonWebTokenError(); - var NotBeforeError = function(message, date) { - JsonWebTokenError.call(this, message); - this.name = "NotBeforeError"; - this.date = date; - }; - NotBeforeError.prototype = Object.create(JsonWebTokenError.prototype); - NotBeforeError.prototype.constructor = NotBeforeError; - module2.exports = NotBeforeError; - } -}); - -// ../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/TokenExpiredError.js -var require_TokenExpiredError = __commonJS({ - "../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/TokenExpiredError.js"(exports2, module2) { - var JsonWebTokenError = require_JsonWebTokenError(); - var TokenExpiredError = function(message, expiredAt) { - JsonWebTokenError.call(this, message); - this.name = "TokenExpiredError"; - this.expiredAt = expiredAt; - }; - TokenExpiredError.prototype = Object.create(JsonWebTokenError.prototype); - TokenExpiredError.prototype.constructor = TokenExpiredError; - module2.exports = TokenExpiredError; - } -}); - -// ../../../node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js -var require_ms = __commonJS({ - "../../../node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js"(exports2, module2) { - var s = 1e3; - var m = s * 60; - var h = m * 60; - var d = h * 24; - var w = d * 7; - var y = d * 365.25; - module2.exports = function(val, options) { - options = options || {}; - var type = typeof val; - if (type === "string" && val.length > 0) { - return parse2(val); - } else if (type === "number" && isFinite(val)) { - return options.long ? fmtLong(val) : fmtShort(val); + state = strm.state; + if (state.mode === TYPE) { + state.mode = TYPEDO; } - throw new Error( - "val is not a non-empty string or a valid number. val=" + JSON.stringify(val) - ); - }; - function parse2(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]); - var type = (match[2] || "ms").toLowerCase(); - switch (type) { - 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 void 0; - } - } - function fmtShort(ms) { - var msAbs = Math.abs(ms); - if (msAbs >= d) { - return Math.round(ms / d) + "d"; - } - if (msAbs >= h) { - return Math.round(ms / h) + "h"; - } - if (msAbs >= m) { - return Math.round(ms / m) + "m"; - } - if (msAbs >= s) { - return Math.round(ms / s) + "s"; - } - return ms + "ms"; - } - function fmtLong(ms) { - var msAbs = Math.abs(ms); - if (msAbs >= d) { - return plural(ms, msAbs, d, "day"); - } - if (msAbs >= h) { - return plural(ms, msAbs, h, "hour"); - } - if (msAbs >= m) { - return plural(ms, msAbs, m, "minute"); - } - if (msAbs >= s) { - return plural(ms, msAbs, s, "second"); - } - return ms + " ms"; - } - function plural(ms, msAbs, n, name) { - var isPlural = msAbs >= n * 1.5; - return Math.round(ms / n) + " " + name + (isPlural ? "s" : ""); - } - } -}); - -// ../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/timespan.js -var require_timespan = __commonJS({ - "../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/timespan.js"(exports2, module2) { - var ms = require_ms(); - module2.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; - } - }; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/internal/constants.js -var require_constants6 = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/internal/constants.js"(exports2, module2) { - var SEMVER_SPEC_VERSION = "2.0.0"; - var MAX_LENGTH = 256; - var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */ - 9007199254740991; - var MAX_SAFE_COMPONENT_LENGTH = 16; - var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6; - var RELEASE_TYPES = [ - "major", - "premajor", - "minor", - "preminor", - "patch", - "prepatch", - "prerelease" - ]; - module2.exports = { - MAX_LENGTH, - MAX_SAFE_COMPONENT_LENGTH, - MAX_SAFE_BUILD_LENGTH, - MAX_SAFE_INTEGER, - RELEASE_TYPES, - SEMVER_SPEC_VERSION, - FLAG_INCLUDE_PRERELEASE: 1, - FLAG_LOOSE: 2 - }; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/internal/debug.js -var require_debug = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/internal/debug.js"(exports2, module2) { - var debug4 = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => { - }; - module2.exports = debug4; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/internal/re.js -var require_re = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/internal/re.js"(exports2, module2) { - var { - MAX_SAFE_COMPONENT_LENGTH, - MAX_SAFE_BUILD_LENGTH, - MAX_LENGTH - } = require_constants6(); - var debug4 = require_debug(); - exports2 = module2.exports = {}; - var re = exports2.re = []; - var safeRe = exports2.safeRe = []; - var src = exports2.src = []; - var t = exports2.t = {}; - var R = 0; - var LETTERDASHNUMBER = "[a-zA-Z0-9-]"; - var safeRegexReplacements = [ - ["\\s", 1], - ["\\d", MAX_LENGTH], - [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH] - ]; - var makeSafeRegex = (value) => { - for (const [token, max] of safeRegexReplacements) { - value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`); - } - return value; - }; - var createToken = (name, value, isGlobal) => { - const safe = makeSafeRegex(value); - const index2 = R++; - debug4(name, index2, value); - t[name] = index2; - src[index2] = value; - re[index2] = new RegExp(value, isGlobal ? "g" : void 0); - safeRe[index2] = 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.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`); - createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`); - createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NUMERICIDENTIFIER]}|${src[t.NONNUMERICIDENTIFIER]})`); - createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NUMERICIDENTIFIERLOOSE]}|${src[t.NONNUMERICIDENTIFIER]})`); - createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`); - createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`); - createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`); - createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`); - createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`); - createToken("FULL", `^${src[t.FULLPLAIN]}$`); - createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`); - createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`); - createToken("GTLT", "((?:<|>)?=?)"); - createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`); - createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`); - createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`); - createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`); - createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`); - createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.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.COERCEPLAIN]}(?:$|[^\\d])`); - createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`); - createToken("COERCERTL", src[t.COERCE], true); - createToken("COERCERTLFULL", src[t.COERCEFULL], true); - createToken("LONETILDE", "(?:~>?)"); - createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true); - exports2.tildeTrimReplace = "$1~"; - createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`); - createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`); - createToken("LONECARET", "(?:\\^)"); - createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true); - exports2.caretTrimReplace = "$1^"; - createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`); - createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`); - createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`); - createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`); - createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true); - exports2.comparatorTrimReplace = "$1$2$3"; - createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`); - createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`); - createToken("STAR", "(<|>)?=?\\s*\\*"); - createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$"); - createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$"); - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/internal/parse-options.js -var require_parse_options = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/internal/parse-options.js"(exports2, module2) { - var looseOption = Object.freeze({ loose: true }); - var emptyOpts = Object.freeze({}); - var parseOptions = (options) => { - if (!options) { - return emptyOpts; - } - if (typeof options !== "object") { - return looseOption; - } - return options; - }; - module2.exports = parseOptions; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/internal/identifiers.js -var require_identifiers = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/internal/identifiers.js"(exports2, module2) { - var numeric = /^[0-9]+$/; - var compareIdentifiers = (a, b) => { - 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; - }; - var rcompareIdentifiers = (a, b) => compareIdentifiers(b, a); - module2.exports = { - compareIdentifiers, - rcompareIdentifiers - }; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/classes/semver.js -var require_semver = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/classes/semver.js"(exports2, module2) { - var debug4 = require_debug(); - var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants6(); - var { safeRe: re, t } = require_re(); - var parseOptions = require_parse_options(); - var { compareIdentifiers } = require_identifiers(); - var SemVer = class _SemVer { - constructor(version3, options) { - options = parseOptions(options); - if (version3 instanceof _SemVer) { - if (version3.loose === !!options.loose && version3.includePrerelease === !!options.includePrerelease) { - return version3; - } else { - version3 = version3.version; - } - } else if (typeof version3 !== "string") { - throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version3}".`); - } - if (version3.length > MAX_LENGTH) { - throw new TypeError( - `version is longer than ${MAX_LENGTH} characters` - ); - } - debug4("SemVer", version3, options); - this.options = options; - this.loose = !!options.loose; - this.includePrerelease = !!options.includePrerelease; - const m = version3.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]); - if (!m) { - throw new TypeError(`Invalid Version: ${version3}`); - } - this.raw = version3; - this.major = +m[1]; - this.minor = +m[2]; - this.patch = +m[3]; - if (this.major > MAX_SAFE_INTEGER || this.major < 0) { - throw new TypeError("Invalid major version"); - } - if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { - throw new TypeError("Invalid minor version"); - } - if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { - throw new TypeError("Invalid patch version"); - } - if (!m[4]) { - this.prerelease = []; - } else { - this.prerelease = m[4].split(".").map((id) => { - if (/^[0-9]+$/.test(id)) { - const num2 = +id; - if (num2 >= 0 && num2 < MAX_SAFE_INTEGER) { - return num2; + put = strm.next_out; + output = strm.output; + left = strm.avail_out; + next = strm.next_in; + input = strm.input; + have = strm.avail_in; + hold = state.hold; + bits = state.bits; + _in = have; + _out = left; + ret = Z_OK; + inf_leave: + for (; ; ) { + switch (state.mode) { + case HEAD: + if (state.wrap === 0) { + state.mode = TYPEDO; + break; } - } - return id; - }); - } - this.build = m[5] ? m[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) { - debug4("SemVer.compare", this.version, this.options, other); - if (!(other instanceof _SemVer)) { - if (typeof other === "string" && other === this.version) { - return 0; - } - other = new _SemVer(other, this.options); - } - if (other.version === this.version) { - return 0; - } - return this.compareMain(other) || this.comparePre(other); - } - compareMain(other) { - if (!(other instanceof _SemVer)) { - other = new _SemVer(other, this.options); - } - return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch); - } - comparePre(other) { - if (!(other instanceof _SemVer)) { - other = new _SemVer(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]; - debug4("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)) { - other = new _SemVer(other, this.options); - } - let i = 0; - do { - const a = this.build[i]; - const b = other.build[i]; - debug4("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); - } - // preminor will bump the version up to the next minor release, and immediately - // down to pre-release. premajor and prepatch work the same way. - inc(release, identifier, identifierBase) { - 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 "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 (!identifier && identifierBase === false) { - throw new Error("invalid increment argument: identifier is empty"); - } - 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; + while (bits < 16) { + if (have === 0) { + break inf_leave; } + have--; + hold += input[next++] << bits; + bits += 8; } - if (i === -1) { - if (identifier === this.prerelease.join(".") && identifierBase === false) { - throw new Error("invalid increment argument: identifier already exists"); - } - this.prerelease.push(base); + if (state.wrap & 2 && hold === 35615) { + state.check = 0; + hbuf[0] = hold & 255; + hbuf[1] = hold >>> 8 & 255; + state.check = crc322(state.check, hbuf, 2, 0); + hold = 0; + bits = 0; + state.mode = FLAGS; + break; } - } - if (identifier) { - let prerelease = [identifier, base]; - if (identifierBase === false) { - prerelease = [identifier]; + state.flags = 0; + if (state.head) { + state.head.done = false; } - if (compareIdentifiers(this.prerelease[0], identifier) === 0) { - if (isNaN(this.prerelease[1])) { - this.prerelease = prerelease; + if (!(state.wrap & 1) || /* check if zlib header allowed */ + (((hold & 255) << 8) + (hold >> 8)) % 31) { + strm.msg = "incorrect header check"; + state.mode = BAD; + break; + } + if ((hold & 15) !== Z_DEFLATED) { + strm.msg = "unknown compression method"; + state.mode = BAD; + break; + } + hold >>>= 4; + bits -= 4; + len = (hold & 15) + 8; + if (state.wbits === 0) { + state.wbits = len; + } else if (len > state.wbits) { + strm.msg = "invalid window size"; + state.mode = BAD; + break; + } + state.dmax = 1 << len; + strm.adler = state.check = 1; + state.mode = hold & 512 ? DICTID : TYPE; + hold = 0; + bits = 0; + break; + case FLAGS: + while (bits < 16) { + if (have === 0) { + break inf_leave; } - } else { - this.prerelease = prerelease; + have--; + hold += input[next++] << bits; + bits += 8; } - } - break; - } - default: - throw new Error(`invalid increment argument: ${release}`); - } - this.raw = this.format(); - if (this.build.length) { - this.raw += `+${this.build.join(".")}`; - } - return this; - } - }; - module2.exports = SemVer; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/parse.js -var require_parse2 = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/parse.js"(exports2, module2) { - var SemVer = require_semver(); - var parse2 = (version3, options, throwErrors = false) => { - if (version3 instanceof SemVer) { - return version3; - } - try { - return new SemVer(version3, options); - } catch (er) { - if (!throwErrors) { - return null; - } - throw er; - } - }; - module2.exports = parse2; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/valid.js -var require_valid = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/valid.js"(exports2, module2) { - var parse2 = require_parse2(); - var valid = (version3, options) => { - const v = parse2(version3, options); - return v ? v.version : null; - }; - module2.exports = valid; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/clean.js -var require_clean = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/clean.js"(exports2, module2) { - var parse2 = require_parse2(); - var clean = (version3, options) => { - const s = parse2(version3.trim().replace(/^[=v]+/, ""), options); - return s ? s.version : null; - }; - module2.exports = clean; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/inc.js -var require_inc = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/inc.js"(exports2, module2) { - var SemVer = require_semver(); - var inc = (version3, release, options, identifier, identifierBase) => { - if (typeof options === "string") { - identifierBase = identifier; - identifier = options; - options = void 0; - } - try { - return new SemVer( - version3 instanceof SemVer ? version3.version : version3, - options - ).inc(release, identifier, identifierBase).version; - } catch (er) { - return null; - } - }; - module2.exports = inc; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/diff.js -var require_diff = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/diff.js"(exports2, module2) { - var parse2 = require_parse2(); - var diff = (version1, version22) => { - const v12 = parse2(version1, null, true); - const v2 = parse2(version22, null, true); - const comparison = v12.compare(v2); - if (comparison === 0) { - return null; - } - const v1Higher = comparison > 0; - const highVersion = v1Higher ? v12 : v2; - const lowVersion = v1Higher ? v2 : v12; - const highHasPre = !!highVersion.prerelease.length; - const lowHasPre = !!lowVersion.prerelease.length; - if (lowHasPre && !highHasPre) { - if (!lowVersion.patch && !lowVersion.minor) { - return "major"; - } - if (highVersion.patch) { - return "patch"; - } - if (highVersion.minor) { - return "minor"; - } - return "major"; - } - const prefix = highHasPre ? "pre" : ""; - if (v12.major !== v2.major) { - return prefix + "major"; - } - if (v12.minor !== v2.minor) { - return prefix + "minor"; - } - if (v12.patch !== v2.patch) { - return prefix + "patch"; - } - return "prerelease"; - }; - module2.exports = diff; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/major.js -var require_major = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/major.js"(exports2, module2) { - var SemVer = require_semver(); - var major = (a, loose) => new SemVer(a, loose).major; - module2.exports = major; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/minor.js -var require_minor = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/minor.js"(exports2, module2) { - var SemVer = require_semver(); - var minor = (a, loose) => new SemVer(a, loose).minor; - module2.exports = minor; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/patch.js -var require_patch = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/patch.js"(exports2, module2) { - var SemVer = require_semver(); - var patch = (a, loose) => new SemVer(a, loose).patch; - module2.exports = patch; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/prerelease.js -var require_prerelease = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/prerelease.js"(exports2, module2) { - var parse2 = require_parse2(); - var prerelease = (version3, options) => { - const parsed = parse2(version3, options); - return parsed && parsed.prerelease.length ? parsed.prerelease : null; - }; - module2.exports = prerelease; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/compare.js -var require_compare = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/compare.js"(exports2, module2) { - var SemVer = require_semver(); - var compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose)); - module2.exports = compare; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/rcompare.js -var require_rcompare = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/rcompare.js"(exports2, module2) { - var compare = require_compare(); - var rcompare = (a, b, loose) => compare(b, a, loose); - module2.exports = rcompare; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/compare-loose.js -var require_compare_loose = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/compare-loose.js"(exports2, module2) { - var compare = require_compare(); - var compareLoose = (a, b) => compare(a, b, true); - module2.exports = compareLoose; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/compare-build.js -var require_compare_build = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/compare-build.js"(exports2, module2) { - var SemVer = require_semver(); - var compareBuild = (a, b, loose) => { - const versionA = new SemVer(a, loose); - const versionB = new SemVer(b, loose); - return versionA.compare(versionB) || versionA.compareBuild(versionB); - }; - module2.exports = compareBuild; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/sort.js -var require_sort = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/sort.js"(exports2, module2) { - var compareBuild = require_compare_build(); - var sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose)); - module2.exports = sort; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/rsort.js -var require_rsort = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/rsort.js"(exports2, module2) { - var compareBuild = require_compare_build(); - var rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose)); - module2.exports = rsort; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/gt.js -var require_gt = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/gt.js"(exports2, module2) { - var compare = require_compare(); - var gt = (a, b, loose) => compare(a, b, loose) > 0; - module2.exports = gt; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/lt.js -var require_lt = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/lt.js"(exports2, module2) { - var compare = require_compare(); - var lt = (a, b, loose) => compare(a, b, loose) < 0; - module2.exports = lt; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/eq.js -var require_eq = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/eq.js"(exports2, module2) { - var compare = require_compare(); - var eq = (a, b, loose) => compare(a, b, loose) === 0; - module2.exports = eq; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/neq.js -var require_neq = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/neq.js"(exports2, module2) { - var compare = require_compare(); - var neq = (a, b, loose) => compare(a, b, loose) !== 0; - module2.exports = neq; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/gte.js -var require_gte = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/gte.js"(exports2, module2) { - var compare = require_compare(); - var gte = (a, b, loose) => compare(a, b, loose) >= 0; - module2.exports = gte; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/lte.js -var require_lte = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/lte.js"(exports2, module2) { - var compare = require_compare(); - var lte = (a, b, loose) => compare(a, b, loose) <= 0; - module2.exports = lte; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/cmp.js -var require_cmp = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/cmp.js"(exports2, module2) { - var eq = require_eq(); - var neq = require_neq(); - var gt = require_gt(); - var gte = require_gte(); - var lt = require_lt(); - var lte = require_lte(); - var cmp = (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(a, b, loose); - case "!=": - return neq(a, b, loose); - case ">": - return gt(a, b, loose); - case ">=": - return gte(a, b, loose); - case "<": - return lt(a, b, loose); - case "<=": - return lte(a, b, loose); - default: - throw new TypeError(`Invalid operator: ${op}`); - } - }; - module2.exports = cmp; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/coerce.js -var require_coerce = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/coerce.js"(exports2, module2) { - var SemVer = require_semver(); - var parse2 = require_parse2(); - var { safeRe: re, t } = require_re(); - var coerce = (version3, options) => { - if (version3 instanceof SemVer) { - return version3; - } - if (typeof version3 === "number") { - version3 = String(version3); - } - if (typeof version3 !== "string") { - return null; - } - options = options || {}; - let match = null; - if (!options.rtl) { - match = version3.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]); - } else { - const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL]; - let next; - while ((next = coerceRtlRegex.exec(version3)) && (!match || match.index + match[0].length !== version3.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 = match[2]; - const minor = match[3] || "0"; - const patch = match[4] || "0"; - const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : ""; - const build = options.includePrerelease && match[6] ? `+${match[6]}` : ""; - return parse2(`${major}.${minor}.${patch}${prerelease}${build}`, options); - }; - module2.exports = coerce; - } -}); - -// ../../../node_modules/.pnpm/yallist@4.0.0/node_modules/yallist/iterator.js -var require_iterator = __commonJS({ - "../../../node_modules/.pnpm/yallist@4.0.0/node_modules/yallist/iterator.js"(exports2, module2) { - "use strict"; - module2.exports = function(Yallist) { - Yallist.prototype[Symbol.iterator] = function* () { - for (let walker = this.head; walker; walker = walker.next) { - yield walker.value; - } - }; - }; - } -}); - -// ../../../node_modules/.pnpm/yallist@4.0.0/node_modules/yallist/yallist.js -var require_yallist = __commonJS({ - "../../../node_modules/.pnpm/yallist@4.0.0/node_modules/yallist/yallist.js"(exports2, module2) { - "use strict"; - module2.exports = Yallist; - Yallist.Node = Node; - Yallist.create = Yallist; - function Yallist(list) { - var self2 = this; - if (!(self2 instanceof Yallist)) { - self2 = new Yallist(); - } - self2.tail = null; - self2.head = null; - self2.length = 0; - if (list && typeof list.forEach === "function") { - list.forEach(function(item) { - self2.push(item); - }); - } else if (arguments.length > 0) { - for (var i = 0, l = arguments.length; i < l; i++) { - self2.push(arguments[i]); - } - } - return self2; - } - Yallist.prototype.removeNode = function(node) { - if (node.list !== this) { - throw new Error("removing node which does not belong to this list"); - } - var next = node.next; - var prev = node.prev; - if (next) { - next.prev = prev; - } - if (prev) { - prev.next = next; - } - if (node === this.head) { - this.head = next; - } - if (node === this.tail) { - this.tail = prev; - } - node.list.length--; - node.next = null; - node.prev = null; - node.list = null; - return next; - }; - Yallist.prototype.unshiftNode = function(node) { - if (node === this.head) { - return; - } - if (node.list) { - node.list.removeNode(node); - } - var head = this.head; - node.list = this; - node.next = head; - if (head) { - head.prev = node; - } - this.head = node; - if (!this.tail) { - this.tail = node; - } - this.length++; - }; - Yallist.prototype.pushNode = function(node) { - if (node === this.tail) { - return; - } - if (node.list) { - node.list.removeNode(node); - } - var tail = this.tail; - node.list = this; - node.prev = tail; - if (tail) { - tail.next = node; - } - this.tail = node; - if (!this.head) { - this.head = node; - } - this.length++; - }; - Yallist.prototype.push = function() { - for (var i = 0, l = arguments.length; i < l; i++) { - push2(this, arguments[i]); - } - return this.length; - }; - Yallist.prototype.unshift = function() { - for (var i = 0, l = arguments.length; i < l; i++) { - unshift(this, arguments[i]); - } - return this.length; - }; - Yallist.prototype.pop = function() { - if (!this.tail) { - return void 0; - } - var res = this.tail.value; - this.tail = this.tail.prev; - if (this.tail) { - this.tail.next = null; - } else { - this.head = null; - } - this.length--; - return res; - }; - Yallist.prototype.shift = function() { - if (!this.head) { - return void 0; - } - var res = this.head.value; - this.head = this.head.next; - if (this.head) { - this.head.prev = null; - } else { - this.tail = null; - } - this.length--; - return res; - }; - Yallist.prototype.forEach = function(fn, thisp) { - thisp = thisp || this; - for (var walker = this.head, i = 0; walker !== null; i++) { - fn.call(thisp, walker.value, i, this); - walker = walker.next; - } - }; - Yallist.prototype.forEachReverse = function(fn, thisp) { - thisp = thisp || this; - for (var walker = this.tail, i = this.length - 1; walker !== null; i--) { - fn.call(thisp, walker.value, i, this); - walker = walker.prev; - } - }; - Yallist.prototype.get = function(n) { - for (var i = 0, walker = this.head; walker !== null && i < n; i++) { - walker = walker.next; - } - if (i === n && walker !== null) { - return walker.value; - } - }; - Yallist.prototype.getReverse = function(n) { - for (var i = 0, walker = this.tail; walker !== null && i < n; i++) { - walker = walker.prev; - } - if (i === n && walker !== null) { - return walker.value; - } - }; - Yallist.prototype.map = function(fn, thisp) { - thisp = thisp || this; - var res = new Yallist(); - for (var walker = this.head; walker !== null; ) { - res.push(fn.call(thisp, walker.value, this)); - walker = walker.next; - } - return res; - }; - Yallist.prototype.mapReverse = function(fn, thisp) { - thisp = thisp || this; - var res = new Yallist(); - for (var walker = this.tail; walker !== null; ) { - res.push(fn.call(thisp, walker.value, this)); - walker = walker.prev; - } - return res; - }; - Yallist.prototype.reduce = function(fn, initial) { - var acc; - var walker = this.head; - if (arguments.length > 1) { - acc = initial; - } else if (this.head) { - walker = this.head.next; - acc = this.head.value; - } else { - throw new TypeError("Reduce of empty list with no initial value"); - } - for (var i = 0; walker !== null; i++) { - acc = fn(acc, walker.value, i); - walker = walker.next; - } - return acc; - }; - Yallist.prototype.reduceReverse = function(fn, initial) { - var acc; - var walker = this.tail; - if (arguments.length > 1) { - acc = initial; - } else if (this.tail) { - walker = this.tail.prev; - acc = this.tail.value; - } else { - throw new TypeError("Reduce of empty list with no initial value"); - } - for (var i = this.length - 1; walker !== null; i--) { - acc = fn(acc, walker.value, i); - walker = walker.prev; - } - return acc; - }; - Yallist.prototype.toArray = function() { - var arr = new Array(this.length); - for (var i = 0, walker = this.head; walker !== null; i++) { - arr[i] = walker.value; - walker = walker.next; - } - return arr; - }; - Yallist.prototype.toArrayReverse = function() { - var arr = new Array(this.length); - for (var i = 0, walker = this.tail; walker !== null; i++) { - arr[i] = walker.value; - walker = walker.prev; - } - return arr; - }; - Yallist.prototype.slice = function(from3, to) { - to = to || this.length; - if (to < 0) { - to += this.length; - } - from3 = from3 || 0; - if (from3 < 0) { - from3 += this.length; - } - var ret = new Yallist(); - if (to < from3 || to < 0) { - return ret; - } - if (from3 < 0) { - from3 = 0; - } - if (to > this.length) { - to = this.length; - } - for (var i = 0, walker = this.head; walker !== null && i < from3; i++) { - walker = walker.next; - } - for (; walker !== null && i < to; i++, walker = walker.next) { - ret.push(walker.value); - } - return ret; - }; - Yallist.prototype.sliceReverse = function(from3, to) { - to = to || this.length; - if (to < 0) { - to += this.length; - } - from3 = from3 || 0; - if (from3 < 0) { - from3 += this.length; - } - var ret = new Yallist(); - if (to < from3 || to < 0) { - return ret; - } - if (from3 < 0) { - from3 = 0; - } - if (to > this.length) { - to = this.length; - } - for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) { - walker = walker.prev; - } - for (; walker !== null && i > from3; i--, walker = walker.prev) { - ret.push(walker.value); - } - return ret; - }; - Yallist.prototype.splice = function(start, deleteCount, ...nodes) { - if (start > this.length) { - start = this.length - 1; - } - if (start < 0) { - start = this.length + start; - } - for (var i = 0, walker = this.head; walker !== null && i < start; i++) { - walker = walker.next; - } - var ret = []; - for (var i = 0; walker && i < deleteCount; i++) { - ret.push(walker.value); - walker = this.removeNode(walker); - } - if (walker === null) { - walker = this.tail; - } - if (walker !== this.head && walker !== this.tail) { - walker = walker.prev; - } - for (var i = 0; i < nodes.length; i++) { - walker = insert(this, walker, nodes[i]); - } - return ret; - }; - Yallist.prototype.reverse = function() { - var head = this.head; - var tail = this.tail; - for (var walker = head; walker !== null; walker = walker.prev) { - var p = walker.prev; - walker.prev = walker.next; - walker.next = p; - } - this.head = tail; - this.tail = head; - return this; - }; - function insert(self2, node, value) { - var inserted = node === self2.head ? new Node(value, null, node, self2) : new Node(value, node, node.next, self2); - if (inserted.next === null) { - self2.tail = inserted; - } - if (inserted.prev === null) { - self2.head = inserted; - } - self2.length++; - return inserted; - } - function push2(self2, item) { - self2.tail = new Node(item, self2.tail, null, self2); - if (!self2.head) { - self2.head = self2.tail; - } - self2.length++; - } - function unshift(self2, item) { - self2.head = new Node(item, null, self2.head, self2); - if (!self2.tail) { - self2.tail = self2.head; - } - self2.length++; - } - function Node(value, prev, next, list) { - if (!(this instanceof Node)) { - return new Node(value, prev, next, list); - } - this.list = list; - this.value = value; - if (prev) { - prev.next = this; - this.prev = prev; - } else { - this.prev = null; - } - if (next) { - next.prev = this; - this.next = next; - } else { - this.next = null; - } - } - try { - require_iterator()(Yallist); - } catch (er) { - } - } -}); - -// ../../../node_modules/.pnpm/lru-cache@6.0.0/node_modules/lru-cache/index.js -var require_lru_cache = __commonJS({ - "../../../node_modules/.pnpm/lru-cache@6.0.0/node_modules/lru-cache/index.js"(exports2, module2) { - "use strict"; - var Yallist = require_yallist(); - var MAX = Symbol("max"); - var LENGTH = Symbol("length"); - var LENGTH_CALCULATOR = Symbol("lengthCalculator"); - var ALLOW_STALE = Symbol("allowStale"); - var MAX_AGE = Symbol("maxAge"); - var DISPOSE = Symbol("dispose"); - var NO_DISPOSE_ON_SET = Symbol("noDisposeOnSet"); - var LRU_LIST = Symbol("lruList"); - var CACHE = Symbol("cache"); - var UPDATE_AGE_ON_GET = Symbol("updateAgeOnGet"); - var naiveLength = () => 1; - var LRUCache = class { - constructor(options) { - if (typeof options === "number") - options = { max: options }; - if (!options) - options = {}; - if (options.max && (typeof options.max !== "number" || options.max < 0)) - throw new TypeError("max must be a non-negative number"); - const max = this[MAX] = options.max || Infinity; - const lc = options.length || naiveLength; - this[LENGTH_CALCULATOR] = typeof lc !== "function" ? naiveLength : lc; - this[ALLOW_STALE] = options.stale || false; - if (options.maxAge && typeof options.maxAge !== "number") - throw new TypeError("maxAge must be a number"); - this[MAX_AGE] = options.maxAge || 0; - this[DISPOSE] = options.dispose; - this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false; - this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false; - this.reset(); - } - // resize the cache when the max changes. - set max(mL) { - if (typeof mL !== "number" || mL < 0) - throw new TypeError("max must be a non-negative number"); - this[MAX] = mL || Infinity; - trim(this); - } - get max() { - return this[MAX]; - } - set allowStale(allowStale) { - this[ALLOW_STALE] = !!allowStale; - } - get allowStale() { - return this[ALLOW_STALE]; - } - set maxAge(mA) { - if (typeof mA !== "number") - throw new TypeError("maxAge must be a non-negative number"); - this[MAX_AGE] = mA; - trim(this); - } - get maxAge() { - return this[MAX_AGE]; - } - // resize the cache when the lengthCalculator changes. - set lengthCalculator(lC) { - if (typeof lC !== "function") - lC = naiveLength; - if (lC !== this[LENGTH_CALCULATOR]) { - this[LENGTH_CALCULATOR] = lC; - this[LENGTH] = 0; - this[LRU_LIST].forEach((hit) => { - hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key); - this[LENGTH] += hit.length; - }); - } - trim(this); - } - get lengthCalculator() { - return this[LENGTH_CALCULATOR]; - } - get length() { - return this[LENGTH]; - } - get itemCount() { - return this[LRU_LIST].length; - } - rforEach(fn, thisp) { - thisp = thisp || this; - for (let walker = this[LRU_LIST].tail; walker !== null; ) { - const prev = walker.prev; - forEachStep(this, fn, walker, thisp); - walker = prev; - } - } - forEach(fn, thisp) { - thisp = thisp || this; - for (let walker = this[LRU_LIST].head; walker !== null; ) { - const next = walker.next; - forEachStep(this, fn, walker, thisp); - walker = next; - } - } - keys() { - return this[LRU_LIST].toArray().map((k) => k.key); - } - values() { - return this[LRU_LIST].toArray().map((k) => k.value); - } - reset() { - if (this[DISPOSE] && this[LRU_LIST] && this[LRU_LIST].length) { - this[LRU_LIST].forEach((hit) => this[DISPOSE](hit.key, hit.value)); - } - this[CACHE] = /* @__PURE__ */ new Map(); - this[LRU_LIST] = new Yallist(); - this[LENGTH] = 0; - } - dump() { - return this[LRU_LIST].map((hit) => isStale(this, hit) ? false : { - k: hit.key, - v: hit.value, - e: hit.now + (hit.maxAge || 0) - }).toArray().filter((h) => h); - } - dumpLru() { - return this[LRU_LIST]; - } - set(key, value, maxAge) { - maxAge = maxAge || this[MAX_AGE]; - if (maxAge && typeof maxAge !== "number") - throw new TypeError("maxAge must be a number"); - const now = maxAge ? Date.now() : 0; - const len = this[LENGTH_CALCULATOR](value, key); - if (this[CACHE].has(key)) { - if (len > this[MAX]) { - del(this, this[CACHE].get(key)); - return false; - } - const node = this[CACHE].get(key); - const item = node.value; - if (this[DISPOSE]) { - if (!this[NO_DISPOSE_ON_SET]) - this[DISPOSE](key, item.value); - } - item.now = now; - item.maxAge = maxAge; - item.value = value; - this[LENGTH] += len - item.length; - item.length = len; - this.get(key); - trim(this); - return true; - } - const hit = new Entry(key, value, len, now, maxAge); - if (hit.length > this[MAX]) { - if (this[DISPOSE]) - this[DISPOSE](key, value); - return false; - } - this[LENGTH] += hit.length; - this[LRU_LIST].unshift(hit); - this[CACHE].set(key, this[LRU_LIST].head); - trim(this); - return true; - } - has(key) { - if (!this[CACHE].has(key)) - return false; - const hit = this[CACHE].get(key).value; - return !isStale(this, hit); - } - get(key) { - return get(this, key, true); - } - peek(key) { - return get(this, key, false); - } - pop() { - const node = this[LRU_LIST].tail; - if (!node) - return null; - del(this, node); - return node.value; - } - del(key) { - del(this, this[CACHE].get(key)); - } - load(arr) { - this.reset(); - const now = Date.now(); - for (let l = arr.length - 1; l >= 0; l--) { - const hit = arr[l]; - const expiresAt = hit.e || 0; - if (expiresAt === 0) - this.set(hit.k, hit.v); - else { - const maxAge = expiresAt - now; - if (maxAge > 0) { - this.set(hit.k, hit.v, maxAge); - } - } - } - } - prune() { - this[CACHE].forEach((value, key) => get(this, key, false)); - } - }; - var get = (self2, key, doUse) => { - const node = self2[CACHE].get(key); - if (node) { - const hit = node.value; - if (isStale(self2, hit)) { - del(self2, node); - if (!self2[ALLOW_STALE]) - return void 0; - } else { - if (doUse) { - if (self2[UPDATE_AGE_ON_GET]) - node.value.now = Date.now(); - self2[LRU_LIST].unshiftNode(node); - } - } - return hit.value; - } - }; - var isStale = (self2, hit) => { - if (!hit || !hit.maxAge && !self2[MAX_AGE]) - return false; - const diff = Date.now() - hit.now; - return hit.maxAge ? diff > hit.maxAge : self2[MAX_AGE] && diff > self2[MAX_AGE]; - }; - var trim = (self2) => { - if (self2[LENGTH] > self2[MAX]) { - for (let walker = self2[LRU_LIST].tail; self2[LENGTH] > self2[MAX] && walker !== null; ) { - const prev = walker.prev; - del(self2, walker); - walker = prev; - } - } - }; - var del = (self2, node) => { - if (node) { - const hit = node.value; - if (self2[DISPOSE]) - self2[DISPOSE](hit.key, hit.value); - self2[LENGTH] -= hit.length; - self2[CACHE].delete(hit.key); - self2[LRU_LIST].removeNode(node); - } - }; - var Entry = class { - constructor(key, value, length, now, maxAge) { - this.key = key; - this.value = value; - this.length = length; - this.now = now; - this.maxAge = maxAge || 0; - } - }; - var forEachStep = (self2, fn, node, thisp) => { - let hit = node.value; - if (isStale(self2, hit)) { - del(self2, node); - if (!self2[ALLOW_STALE]) - hit = void 0; - } - if (hit) - fn.call(thisp, hit.value, hit.key, self2); - }; - module2.exports = LRUCache; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/classes/range.js -var require_range = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/classes/range.js"(exports2, module2) { - var Range = class _Range { - constructor(range, options) { - options = parseOptions(options); - if (range instanceof _Range) { - if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) { - return range; - } else { - return new _Range(range.raw, options); - } - } - if (range instanceof Comparator) { - this.raw = range.value; - this.set = [[range]]; - this.format(); - return this; - } - this.options = options; - this.loose = !!options.loose; - this.includePrerelease = !!options.includePrerelease; - this.raw = range.trim().split(/\s+/).join(" "); - 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.format(); - } - format() { - this.range = this.set.map((comps) => comps.join(" ").trim()).join("||").trim(); - return this.range; - } - toString() { - return this.range; - } - parseRange(range) { - const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE); - const memoKey = memoOpts + ":" + range; - const cached = cache.get(memoKey); - if (cached) { - return cached; - } - const loose = this.options.loose; - const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE]; - range = range.replace(hr, hyphenReplace(this.options.includePrerelease)); - debug4("hyphen replace", range); - range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace); - debug4("comparator trim", range); - range = range.replace(re[t.TILDETRIM], tildeTrimReplace); - debug4("tilde trim", range); - range = range.replace(re[t.CARETTRIM], caretTrimReplace); - debug4("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) => { - debug4("loose invalid filter", comp, this.options); - return !!comp.match(re[t.COMPARATORLOOSE]); - }); - } - debug4("range list", rangeList); - const rangeMap = /* @__PURE__ */ new Map(); - const comparators = rangeList.map((comp) => new Comparator(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)) { - 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); - }); - }); - }); - }); - } - // if ANY of the sets match ALL of its comparators, then pass - test(version3) { - if (!version3) { - return false; - } - if (typeof version3 === "string") { - try { - version3 = new SemVer(version3, this.options); - } catch (er) { - return false; - } - } - for (let i = 0; i < this.set.length; i++) { - if (testSet(this.set[i], version3, this.options)) { - return true; - } - } - return false; - } - }; - module2.exports = Range; - var LRU = require_lru_cache(); - var cache = new LRU({ max: 1e3 }); - var parseOptions = require_parse_options(); - var Comparator = require_comparator(); - var debug4 = require_debug(); - var SemVer = require_semver(); - var { - safeRe: re, - t, - comparatorTrimReplace, - tildeTrimReplace, - caretTrimReplace - } = require_re(); - var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants6(); - var isNullSet = (c) => c.value === "<0.0.0-0"; - var isAny = (c) => c.value === ""; - var 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; - }; - var parseComparator = (comp, options) => { - debug4("comp", comp, options); - comp = replaceCarets(comp, options); - debug4("caret", comp); - comp = replaceTildes(comp, options); - debug4("tildes", comp); - comp = replaceXRanges(comp, options); - debug4("xrange", comp); - comp = replaceStars(comp, options); - debug4("stars", comp); - return comp; - }; - var isX = (id) => !id || id.toLowerCase() === "x" || id === "*"; - var replaceTildes = (comp, options) => { - return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" "); - }; - var replaceTilde = (comp, options) => { - const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE]; - return comp.replace(r, (_, M, m, p, pr) => { - debug4("tilde", comp, _, M, m, p, pr); - let ret; - if (isX(M)) { - ret = ""; - } else if (isX(m)) { - ret = `>=${M}.0.0 <${+M + 1}.0.0-0`; - } else if (isX(p)) { - ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`; - } else if (pr) { - debug4("replaceTilde pr", pr); - ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`; - } else { - ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`; - } - debug4("tilde return", ret); - return ret; - }); - }; - var replaceCarets = (comp, options) => { - return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" "); - }; - var replaceCaret = (comp, options) => { - debug4("caret", comp, options); - const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET]; - const z = options.includePrerelease ? "-0" : ""; - return comp.replace(r, (_, M, m, p, pr) => { - debug4("caret", comp, _, M, m, p, pr); - let ret; - if (isX(M)) { - ret = ""; - } else if (isX(m)) { - ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`; - } else if (isX(p)) { - if (M === "0") { - ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`; - } else { - ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`; - } - } else if (pr) { - debug4("replaceCaret pr", pr); - if (M === "0") { - if (m === "0") { - ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`; - } else { - ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`; - } - } else { - ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`; - } - } else { - debug4("no pr"); - if (M === "0") { - if (m === "0") { - ret = `>=${M}.${m}.${p}${z} <${M}.${m}.${+p + 1}-0`; - } else { - ret = `>=${M}.${m}.${p}${z} <${M}.${+m + 1}.0-0`; - } - } else { - ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`; - } - } - debug4("caret return", ret); - return ret; - }); - }; - var replaceXRanges = (comp, options) => { - debug4("replaceXRanges", comp, options); - return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" "); - }; - var replaceXRange = (comp, options) => { - comp = comp.trim(); - const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE]; - return comp.replace(r, (ret, gtlt, M, m, p, pr) => { - debug4("xRange", comp, ret, gtlt, M, m, p, pr); - const xM = isX(M); - const xm = xM || isX(m); - 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 = 0; - } - p = 0; - if (gtlt === ">") { - gtlt = ">="; - if (xm) { - M = +M + 1; - m = 0; - p = 0; - } else { - m = +m + 1; - p = 0; - } - } else if (gtlt === "<=") { - gtlt = "<"; - if (xm) { - M = +M + 1; - } else { - m = +m + 1; - } - } - if (gtlt === "<") { - pr = "-0"; - } - ret = `${gtlt + M}.${m}.${p}${pr}`; - } else if (xm) { - ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`; - } else if (xp) { - ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`; - } - debug4("xRange return", ret); - return ret; - }); - }; - var replaceStars = (comp, options) => { - debug4("replaceStars", comp, options); - return comp.trim().replace(re[t.STAR], ""); - }; - var replaceGTE0 = (comp, options) => { - debug4("replaceGTE0", comp, options); - return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], ""); - }; - var hyphenReplace = (incPr) => ($0, from3, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) => { - if (isX(fM)) { - from3 = ""; - } else if (isX(fm)) { - from3 = `>=${fM}.0.0${incPr ? "-0" : ""}`; - } else if (isX(fp)) { - from3 = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`; - } else if (fpr) { - from3 = `>=${from3}`; - } else { - from3 = `>=${from3}${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 `${from3} ${to}`.trim(); - }; - var testSet = (set, version3, options) => { - for (let i = 0; i < set.length; i++) { - if (!set[i].test(version3)) { - return false; - } - } - if (version3.prerelease.length && !options.includePrerelease) { - for (let i = 0; i < set.length; i++) { - debug4(set[i].semver); - if (set[i].semver === Comparator.ANY) { - continue; - } - if (set[i].semver.prerelease.length > 0) { - const allowed = set[i].semver; - if (allowed.major === version3.major && allowed.minor === version3.minor && allowed.patch === version3.patch) { - return true; - } - } - } - return false; - } - return true; - }; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/classes/comparator.js -var require_comparator = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/classes/comparator.js"(exports2, module2) { - var ANY = Symbol("SemVer ANY"); - var Comparator = class _Comparator { - static get ANY() { - return ANY; - } - constructor(comp, options) { - options = parseOptions(options); - if (comp instanceof _Comparator) { - if (comp.loose === !!options.loose) { - return comp; - } else { - comp = comp.value; - } - } - comp = comp.trim().split(/\s+/).join(" "); - debug4("comparator", comp, options); - this.options = options; - this.loose = !!options.loose; - this.parse(comp); - if (this.semver === ANY) { - this.value = ""; - } else { - this.value = this.operator + this.semver.version; - } - debug4("comp", this); - } - parse(comp) { - const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]; - const m = comp.match(r); - if (!m) { - throw new TypeError(`Invalid comparator: ${comp}`); - } - this.operator = m[1] !== void 0 ? m[1] : ""; - if (this.operator === "=") { - this.operator = ""; - } - if (!m[2]) { - this.semver = ANY; - } else { - this.semver = new SemVer(m[2], this.options.loose); - } - } - toString() { - return this.value; - } - test(version3) { - debug4("Comparator.test", version3, this.options.loose); - if (this.semver === ANY || version3 === ANY) { - return true; - } - if (typeof version3 === "string") { - try { - version3 = new SemVer(version3, this.options); - } catch (er) { - return false; - } - } - return cmp(version3, this.operator, this.semver, this.options); - } - intersects(comp, options) { - if (!(comp instanceof _Comparator)) { - throw new TypeError("a Comparator is required"); - } - if (this.operator === "") { - if (this.value === "") { - return true; - } - return new Range(comp.value, options).test(this.value); - } else if (comp.operator === "") { - if (comp.value === "") { - return true; - } - return new Range(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(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) { - return true; - } - if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) { - return true; - } - return false; - } - }; - module2.exports = Comparator; - var parseOptions = require_parse_options(); - var { safeRe: re, t } = require_re(); - var cmp = require_cmp(); - var debug4 = require_debug(); - var SemVer = require_semver(); - var Range = require_range(); - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/satisfies.js -var require_satisfies = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/satisfies.js"(exports2, module2) { - var Range = require_range(); - var satisfies = (version3, range, options) => { - try { - range = new Range(range, options); - } catch (er) { - return false; - } - return range.test(version3); - }; - module2.exports = satisfies; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/to-comparators.js -var require_to_comparators = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/to-comparators.js"(exports2, module2) { - var Range = require_range(); - var toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" ")); - module2.exports = toComparators; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/max-satisfying.js -var require_max_satisfying = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/max-satisfying.js"(exports2, module2) { - var SemVer = require_semver(); - var Range = require_range(); - var maxSatisfying = (versions, range, options) => { - let max = null; - let maxSV = null; - let rangeObj = null; - try { - rangeObj = new Range(range, options); - } catch (er) { - return null; - } - versions.forEach((v) => { - if (rangeObj.test(v)) { - if (!max || maxSV.compare(v) === -1) { - max = v; - maxSV = new SemVer(max, options); - } - } - }); - return max; - }; - module2.exports = maxSatisfying; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/min-satisfying.js -var require_min_satisfying = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/min-satisfying.js"(exports2, module2) { - var SemVer = require_semver(); - var Range = require_range(); - var minSatisfying = (versions, range, options) => { - let min = null; - let minSV = null; - let rangeObj = null; - try { - rangeObj = new Range(range, options); - } catch (er) { - return null; - } - versions.forEach((v) => { - if (rangeObj.test(v)) { - if (!min || minSV.compare(v) === 1) { - min = v; - minSV = new SemVer(min, options); - } - } - }); - return min; - }; - module2.exports = minSatisfying; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/min-version.js -var require_min_version = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/min-version.js"(exports2, module2) { - var SemVer = require_semver(); - var Range = require_range(); - var gt = require_gt(); - var minVersion = (range, loose) => { - range = new Range(range, loose); - let minver = new SemVer("0.0.0"); - if (range.test(minver)) { - return minver; - } - minver = new SemVer("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(comparator.semver.version); - switch (comparator.operator) { - case ">": - if (compver.prerelease.length === 0) { - compver.patch++; - } else { - compver.prerelease.push(0); + state.flags = hold; + if ((state.flags & 255) !== Z_DEFLATED) { + strm.msg = "unknown compression method"; + state.mode = BAD; + break; } - compver.raw = compver.format(); - case "": - case ">=": - if (!setMin || gt(compver, setMin)) { - setMin = compver; + if (state.flags & 57344) { + strm.msg = "unknown header flags set"; + state.mode = BAD; + break; + } + if (state.head) { + state.head.text = hold >> 8 & 1; + } + if (state.flags & 512) { + hbuf[0] = hold & 255; + hbuf[1] = hold >>> 8 & 255; + state.check = crc322(state.check, hbuf, 2, 0); + } + hold = 0; + bits = 0; + state.mode = TIME; + case TIME: + while (bits < 32) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + if (state.head) { + state.head.time = hold; + } + if (state.flags & 512) { + hbuf[0] = hold & 255; + hbuf[1] = hold >>> 8 & 255; + hbuf[2] = hold >>> 16 & 255; + hbuf[3] = hold >>> 24 & 255; + state.check = crc322(state.check, hbuf, 4, 0); + } + hold = 0; + bits = 0; + state.mode = OS; + case OS: + while (bits < 16) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + if (state.head) { + state.head.xflags = hold & 255; + state.head.os = hold >> 8; + } + if (state.flags & 512) { + hbuf[0] = hold & 255; + hbuf[1] = hold >>> 8 & 255; + state.check = crc322(state.check, hbuf, 2, 0); + } + hold = 0; + bits = 0; + state.mode = EXLEN; + case EXLEN: + if (state.flags & 1024) { + while (bits < 16) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + state.length = hold; + if (state.head) { + state.head.extra_len = hold; + } + if (state.flags & 512) { + hbuf[0] = hold & 255; + hbuf[1] = hold >>> 8 & 255; + state.check = crc322(state.check, hbuf, 2, 0); + } + hold = 0; + bits = 0; + } else if (state.head) { + state.head.extra = null; + } + state.mode = EXTRA; + case EXTRA: + if (state.flags & 1024) { + copy = state.length; + if (copy > have) { + copy = have; + } + if (copy) { + if (state.head) { + len = state.head.extra_len - state.length; + if (!state.head.extra) { + state.head.extra = new Array(state.head.extra_len); + } + utils.arraySet( + state.head.extra, + input, + next, + // extra field is limited to 65536 bytes + // - no need for additional size check + copy, + /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/ + len + ); + } + if (state.flags & 512) { + state.check = crc322(state.check, input, copy, next); + } + have -= copy; + next += copy; + state.length -= copy; + } + if (state.length) { + break inf_leave; + } + } + state.length = 0; + state.mode = NAME; + case NAME: + if (state.flags & 2048) { + if (have === 0) { + break inf_leave; + } + copy = 0; + do { + len = input[next + copy++]; + if (state.head && len && state.length < 65536) { + state.head.name += String.fromCharCode(len); + } + } while (len && copy < have); + if (state.flags & 512) { + state.check = crc322(state.check, input, copy, next); + } + have -= copy; + next += copy; + if (len) { + break inf_leave; + } + } else if (state.head) { + state.head.name = null; + } + state.length = 0; + state.mode = COMMENT; + case COMMENT: + if (state.flags & 4096) { + if (have === 0) { + break inf_leave; + } + copy = 0; + do { + len = input[next + copy++]; + if (state.head && len && state.length < 65536) { + state.head.comment += String.fromCharCode(len); + } + } while (len && copy < have); + if (state.flags & 512) { + state.check = crc322(state.check, input, copy, next); + } + have -= copy; + next += copy; + if (len) { + break inf_leave; + } + } else if (state.head) { + state.head.comment = null; + } + state.mode = HCRC; + case HCRC: + if (state.flags & 512) { + while (bits < 16) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + if (hold !== (state.check & 65535)) { + strm.msg = "header crc mismatch"; + state.mode = BAD; + break; + } + hold = 0; + bits = 0; + } + if (state.head) { + state.head.hcrc = state.flags >> 9 & 1; + state.head.done = true; + } + strm.adler = state.check = 0; + state.mode = TYPE; + break; + case DICTID: + while (bits < 32) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + strm.adler = state.check = zswap32(hold); + hold = 0; + bits = 0; + state.mode = DICT; + case DICT: + if (state.havedict === 0) { + strm.next_out = put; + strm.avail_out = left; + strm.next_in = next; + strm.avail_in = have; + state.hold = hold; + state.bits = bits; + return Z_NEED_DICT; + } + strm.adler = state.check = 1; + state.mode = TYPE; + case TYPE: + if (flush === Z_BLOCK || flush === Z_TREES) { + break inf_leave; + } + case TYPEDO: + if (state.last) { + hold >>>= bits & 7; + bits -= bits & 7; + state.mode = CHECK; + break; + } + while (bits < 3) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + state.last = hold & 1; + hold >>>= 1; + bits -= 1; + switch (hold & 3) { + case 0: + state.mode = STORED; + break; + case 1: + fixedtables(state); + state.mode = LEN_; + if (flush === Z_TREES) { + hold >>>= 2; + bits -= 2; + break inf_leave; + } + break; + case 2: + state.mode = TABLE; + break; + case 3: + strm.msg = "invalid block type"; + state.mode = BAD; + } + hold >>>= 2; + bits -= 2; + break; + case STORED: + hold >>>= bits & 7; + bits -= bits & 7; + while (bits < 32) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + if ((hold & 65535) !== (hold >>> 16 ^ 65535)) { + strm.msg = "invalid stored block lengths"; + state.mode = BAD; + break; + } + state.length = hold & 65535; + hold = 0; + bits = 0; + state.mode = COPY_; + if (flush === Z_TREES) { + break inf_leave; + } + case COPY_: + state.mode = COPY; + case COPY: + copy = state.length; + if (copy) { + if (copy > have) { + copy = have; + } + if (copy > left) { + copy = left; + } + if (copy === 0) { + break inf_leave; + } + utils.arraySet(output, input, next, copy, put); + have -= copy; + next += copy; + left -= copy; + put += copy; + state.length -= copy; + break; } + state.mode = TYPE; break; - case "<": - case "<=": - break; - default: - throw new Error(`Unexpected operation: ${comparator.operator}`); - } - }); - if (setMin && (!minver || gt(minver, setMin))) { - minver = setMin; - } - } - if (minver && range.test(minver)) { - return minver; - } - return null; - }; - module2.exports = minVersion; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/valid.js -var require_valid2 = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/valid.js"(exports2, module2) { - var Range = require_range(); - var validRange = (range, options) => { - try { - return new Range(range, options).range || "*"; - } catch (er) { - return null; - } - }; - module2.exports = validRange; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/outside.js -var require_outside = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/outside.js"(exports2, module2) { - var SemVer = require_semver(); - var Comparator = require_comparator(); - var { ANY } = Comparator; - var Range = require_range(); - var satisfies = require_satisfies(); - var gt = require_gt(); - var lt = require_lt(); - var lte = require_lte(); - var gte = require_gte(); - var outside = (version3, range, hilo, options) => { - version3 = new SemVer(version3, options); - range = new Range(range, options); - let gtfn, ltefn, ltfn, comp, ecomp; - switch (hilo) { - case ">": - gtfn = gt; - ltefn = lte; - ltfn = lt; - comp = ">"; - ecomp = ">="; - break; - case "<": - gtfn = lt; - ltefn = gte; - ltfn = gt; - comp = "<"; - ecomp = "<="; - break; - default: - throw new TypeError('Must provide a hilo val of "<" or ">"'); - } - if (satisfies(version3, 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) { - comparator = new Comparator(">=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(version3, low.semver)) { - return false; - } else if (low.operator === ecomp && ltfn(version3, low.semver)) { - return false; - } - } - return true; - }; - module2.exports = outside; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/gtr.js -var require_gtr = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/gtr.js"(exports2, module2) { - var outside = require_outside(); - var gtr = (version3, range, options) => outside(version3, range, ">", options); - module2.exports = gtr; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/ltr.js -var require_ltr = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/ltr.js"(exports2, module2) { - var outside = require_outside(); - var ltr = (version3, range, options) => outside(version3, range, "<", options); - module2.exports = ltr; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/intersects.js -var require_intersects = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/intersects.js"(exports2, module2) { - var Range = require_range(); - var intersects = (r1, r2, options) => { - r1 = new Range(r1, options); - r2 = new Range(r2, options); - return r1.intersects(r2, options); - }; - module2.exports = intersects; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/simplify.js -var require_simplify = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/simplify.js"(exports2, module2) { - var satisfies = require_satisfies(); - var compare = require_compare(); - module2.exports = (versions, range, options) => { - const set = []; - let first = null; - let prev = null; - const v = versions.sort((a, b) => compare(a, b, options)); - for (const version3 of v) { - const included = satisfies(version3, range, options); - if (included) { - prev = version3; - if (!first) { - first = version3; - } - } 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; - }; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/subset.js -var require_subset = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/subset.js"(exports2, module2) { - var Range = require_range(); - var Comparator = require_comparator(); - var { ANY } = Comparator; - var satisfies = require_satisfies(); - var compare = require_compare(); - var subset = (sub, dom, options = {}) => { - if (sub === dom) { - return true; - } - sub = new Range(sub, options); - dom = new Range(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; - }; - var minimumVersionWithPreRelease = [new Comparator(">=0.0.0-0")]; - var minimumVersion = [new Comparator(">=0.0.0")]; - var 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, lt; - for (const c of sub) { - if (c.operator === ">" || c.operator === ">=") { - gt = higherGT(gt, c, options); - } else if (c.operator === "<" || c.operator === "<=") { - lt = lowerLT(lt, c, options); - } else { - eqSet.add(c.semver); - } - } - if (eqSet.size > 1) { - return null; - } - let gtltComp; - if (gt && lt) { - gtltComp = compare(gt.semver, lt.semver, options); - if (gtltComp > 0) { - return null; - } else if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<=")) { - return null; - } - } - for (const eq of eqSet) { - if (gt && !satisfies(eq, String(gt), options)) { - return null; - } - if (lt && !satisfies(eq, String(lt), options)) { - return null; - } - for (const c of dom) { - if (!satisfies(eq, String(c), options)) { - return false; - } - } - return true; - } - let higher, lower2; - let hasDomLT, hasDomGT; - let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false; - let needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : false; - if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.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) { - 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, c, options); - if (higher === c && higher !== gt) { - return false; - } - } else if (gt.operator === ">=" && !satisfies(gt.semver, String(c), options)) { - return false; - } - } - if (lt) { - 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 === "<=") { - lower2 = lowerLT(lt, c, options); - if (lower2 === c && lower2 !== lt) { - return false; - } - } else if (lt.operator === "<=" && !satisfies(lt.semver, String(c), options)) { - return false; - } - } - if (!c.operator && (lt || gt) && gtltComp !== 0) { - return false; - } - } - if (gt && hasDomLT && !lt && gtltComp !== 0) { - return false; - } - if (lt && hasDomGT && !gt && gtltComp !== 0) { - return false; - } - if (needDomGTPre || needDomLTPre) { - return false; - } - return true; - }; - var higherGT = (a, b, options) => { - if (!a) { - return b; - } - const comp = compare(a.semver, b.semver, options); - return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a; - }; - var lowerLT = (a, b, options) => { - if (!a) { - return b; - } - const comp = compare(a.semver, b.semver, options); - return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a; - }; - module2.exports = subset; - } -}); - -// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/index.js -var require_semver2 = __commonJS({ - "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/index.js"(exports2, module2) { - var internalRe = require_re(); - var constants = require_constants6(); - var SemVer = require_semver(); - var identifiers = require_identifiers(); - var parse2 = require_parse2(); - var valid = require_valid(); - var clean = require_clean(); - var inc = require_inc(); - var diff = require_diff(); - var major = require_major(); - var minor = require_minor(); - var patch = require_patch(); - var prerelease = require_prerelease(); - var compare = require_compare(); - var rcompare = require_rcompare(); - var compareLoose = require_compare_loose(); - var compareBuild = require_compare_build(); - var sort = require_sort(); - var rsort = require_rsort(); - var gt = require_gt(); - var lt = require_lt(); - var eq = require_eq(); - var neq = require_neq(); - var gte = require_gte(); - var lte = require_lte(); - var cmp = require_cmp(); - var coerce = require_coerce(); - var Comparator = require_comparator(); - var Range = require_range(); - var satisfies = require_satisfies(); - var toComparators = require_to_comparators(); - var maxSatisfying = require_max_satisfying(); - var minSatisfying = require_min_satisfying(); - var minVersion = require_min_version(); - var validRange = require_valid2(); - var outside = require_outside(); - var gtr = require_gtr(); - var ltr = require_ltr(); - var intersects = require_intersects(); - var simplifyRange = require_simplify(); - var subset = require_subset(); - module2.exports = { - parse: parse2, - 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 - }; - } -}); - -// ../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/asymmetricKeyDetailsSupported.js -var require_asymmetricKeyDetailsSupported = __commonJS({ - "../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/asymmetricKeyDetailsSupported.js"(exports2, module2) { - var semver = require_semver2(); - module2.exports = semver.satisfies(process.version, ">=15.7.0"); - } -}); - -// ../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/rsaPssKeyDetailsSupported.js -var require_rsaPssKeyDetailsSupported = __commonJS({ - "../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/rsaPssKeyDetailsSupported.js"(exports2, module2) { - var semver = require_semver2(); - module2.exports = semver.satisfies(process.version, ">=16.9.0"); - } -}); - -// ../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/validateAsymmetricKey.js -var require_validateAsymmetricKey = __commonJS({ - "../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/validateAsymmetricKey.js"(exports2, module2) { - var ASYMMETRIC_KEY_DETAILS_SUPPORTED = require_asymmetricKeyDetailsSupported(); - var RSA_PSS_KEY_DETAILS_SUPPORTED = require_rsaPssKeyDetailsSupported(); - var allowedAlgorithmsForKeys = { - "ec": ["ES256", "ES384", "ES512"], - "rsa": ["RS256", "PS256", "RS384", "PS384", "RS512", "PS512"], - "rsa-pss": ["PS256", "PS384", "PS512"] - }; - var allowedCurves = { - ES256: "prime256v1", - ES384: "secp384r1", - ES512: "secp521r1" - }; - module2.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(", ")}.`); - } - 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}.`); + case TABLE: + while (bits < 14) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; } - 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}.`); + state.nlen = (hold & 31) + 257; + hold >>>= 5; + bits -= 5; + state.ndist = (hold & 31) + 1; + hold >>>= 5; + bits -= 5; + state.ncode = (hold & 15) + 4; + hold >>>= 4; + bits -= 4; + if (state.nlen > 286 || state.ndist > 30) { + strm.msg = "too many length or distance symbols"; + state.mode = BAD; + break; } - } - break; + state.have = 0; + state.mode = LENLENS; + case LENLENS: + while (state.have < state.ncode) { + while (bits < 3) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + state.lens[order[state.have++]] = hold & 7; + hold >>>= 3; + bits -= 3; + } + while (state.have < 19) { + state.lens[order[state.have++]] = 0; + } + state.lencode = state.lendyn; + state.lenbits = 7; + opts = { bits: state.lenbits }; + ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts); + state.lenbits = opts.bits; + if (ret) { + strm.msg = "invalid code lengths set"; + state.mode = BAD; + break; + } + state.have = 0; + state.mode = CODELENS; + case CODELENS: + while (state.have < state.nlen + state.ndist) { + for (; ; ) { + here = state.lencode[hold & (1 << state.lenbits) - 1]; + here_bits = here >>> 24; + here_op = here >>> 16 & 255; + here_val = here & 65535; + if (here_bits <= bits) { + break; + } + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + if (here_val < 16) { + hold >>>= here_bits; + bits -= here_bits; + state.lens[state.have++] = here_val; + } else { + if (here_val === 16) { + n = here_bits + 2; + while (bits < n) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + hold >>>= here_bits; + bits -= here_bits; + if (state.have === 0) { + strm.msg = "invalid bit length repeat"; + state.mode = BAD; + break; + } + len = state.lens[state.have - 1]; + copy = 3 + (hold & 3); + hold >>>= 2; + bits -= 2; + } else if (here_val === 17) { + n = here_bits + 3; + while (bits < n) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + hold >>>= here_bits; + bits -= here_bits; + len = 0; + copy = 3 + (hold & 7); + hold >>>= 3; + bits -= 3; + } else { + n = here_bits + 7; + while (bits < n) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + hold >>>= here_bits; + bits -= here_bits; + len = 0; + copy = 11 + (hold & 127); + hold >>>= 7; + bits -= 7; + } + if (state.have + copy > state.nlen + state.ndist) { + strm.msg = "invalid bit length repeat"; + state.mode = BAD; + break; + } + while (copy--) { + state.lens[state.have++] = len; + } + } + } + if (state.mode === BAD) { + break; + } + if (state.lens[256] === 0) { + strm.msg = "invalid code -- missing end-of-block"; + state.mode = BAD; + break; + } + state.lenbits = 9; + opts = { bits: state.lenbits }; + ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts); + state.lenbits = opts.bits; + if (ret) { + strm.msg = "invalid literal/lengths set"; + state.mode = BAD; + break; + } + state.distbits = 6; + state.distcode = state.distdyn; + opts = { bits: state.distbits }; + ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts); + state.distbits = opts.bits; + if (ret) { + strm.msg = "invalid distances set"; + state.mode = BAD; + break; + } + state.mode = LEN_; + if (flush === Z_TREES) { + break inf_leave; + } + case LEN_: + state.mode = LEN; + case LEN: + if (have >= 6 && left >= 258) { + strm.next_out = put; + strm.avail_out = left; + strm.next_in = next; + strm.avail_in = have; + state.hold = hold; + state.bits = bits; + inflate_fast(strm, _out); + put = strm.next_out; + output = strm.output; + left = strm.avail_out; + next = strm.next_in; + input = strm.input; + have = strm.avail_in; + hold = state.hold; + bits = state.bits; + if (state.mode === TYPE) { + state.back = -1; + } + break; + } + state.back = 0; + for (; ; ) { + here = state.lencode[hold & (1 << state.lenbits) - 1]; + here_bits = here >>> 24; + here_op = here >>> 16 & 255; + here_val = here & 65535; + if (here_bits <= bits) { + break; + } + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + if (here_op && (here_op & 240) === 0) { + last_bits = here_bits; + last_op = here_op; + last_val = here_val; + for (; ; ) { + here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)]; + here_bits = here >>> 24; + here_op = here >>> 16 & 255; + here_val = here & 65535; + if (last_bits + here_bits <= bits) { + break; + } + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + hold >>>= last_bits; + bits -= last_bits; + state.back += last_bits; + } + hold >>>= here_bits; + bits -= here_bits; + state.back += here_bits; + state.length = here_val; + if (here_op === 0) { + state.mode = LIT; + break; + } + if (here_op & 32) { + state.back = -1; + state.mode = TYPE; + break; + } + if (here_op & 64) { + strm.msg = "invalid literal/length code"; + state.mode = BAD; + break; + } + state.extra = here_op & 15; + state.mode = LENEXT; + case LENEXT: + if (state.extra) { + n = state.extra; + while (bits < n) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + state.length += hold & (1 << state.extra) - 1; + hold >>>= state.extra; + bits -= state.extra; + state.back += state.extra; + } + state.was = state.length; + state.mode = DIST; + case DIST: + for (; ; ) { + here = state.distcode[hold & (1 << state.distbits) - 1]; + here_bits = here >>> 24; + here_op = here >>> 16 & 255; + here_val = here & 65535; + if (here_bits <= bits) { + break; + } + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + if ((here_op & 240) === 0) { + last_bits = here_bits; + last_op = here_op; + last_val = here_val; + for (; ; ) { + here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)]; + here_bits = here >>> 24; + here_op = here >>> 16 & 255; + here_val = here & 65535; + if (last_bits + here_bits <= bits) { + break; + } + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + hold >>>= last_bits; + bits -= last_bits; + state.back += last_bits; + } + hold >>>= here_bits; + bits -= here_bits; + state.back += here_bits; + if (here_op & 64) { + strm.msg = "invalid distance code"; + state.mode = BAD; + break; + } + state.offset = here_val; + state.extra = here_op & 15; + state.mode = DISTEXT; + case DISTEXT: + if (state.extra) { + n = state.extra; + while (bits < n) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + state.offset += hold & (1 << state.extra) - 1; + hold >>>= state.extra; + bits -= state.extra; + state.back += state.extra; + } + if (state.offset > state.dmax) { + strm.msg = "invalid distance too far back"; + state.mode = BAD; + break; + } + state.mode = MATCH; + case MATCH: + if (left === 0) { + break inf_leave; + } + copy = _out - left; + if (state.offset > copy) { + copy = state.offset - copy; + if (copy > state.whave) { + if (state.sane) { + strm.msg = "invalid distance too far back"; + state.mode = BAD; + break; + } + } + if (copy > state.wnext) { + copy -= state.wnext; + from2 = state.wsize - copy; + } else { + from2 = state.wnext - copy; + } + if (copy > state.length) { + copy = state.length; + } + from_source = state.window; + } else { + from_source = output; + from2 = put - state.offset; + copy = state.length; + } + if (copy > left) { + copy = left; + } + left -= copy; + state.length -= copy; + do { + output[put++] = from_source[from2++]; + } while (--copy); + if (state.length === 0) { + state.mode = LEN; + } + break; + case LIT: + if (left === 0) { + break inf_leave; + } + output[put++] = state.length; + left--; + state.mode = LEN; + break; + case CHECK: + if (state.wrap) { + while (bits < 32) { + if (have === 0) { + break inf_leave; + } + have--; + hold |= input[next++] << bits; + bits += 8; + } + _out -= left; + strm.total_out += _out; + state.total += _out; + if (_out) { + strm.adler = state.check = /*UPDATE(state.check, put - _out, _out);*/ + state.flags ? crc322(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out); + } + _out = left; + if ((state.flags ? hold : zswap32(hold)) !== state.check) { + strm.msg = "incorrect data check"; + state.mode = BAD; + break; + } + hold = 0; + bits = 0; + } + state.mode = LENGTH; + case LENGTH: + if (state.wrap && state.flags) { + while (bits < 32) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + if (hold !== (state.total & 4294967295)) { + strm.msg = "incorrect length check"; + state.mode = BAD; + break; + } + hold = 0; + bits = 0; + } + state.mode = DONE; + case DONE: + ret = Z_STREAM_END; + break inf_leave; + case BAD: + ret = Z_DATA_ERROR; + break inf_leave; + case MEM: + return Z_MEM_ERROR; + case SYNC: + default: + return Z_STREAM_ERROR; + } + } + strm.next_out = put; + strm.avail_out = left; + strm.next_in = next; + strm.avail_in = have; + state.hold = hold; + state.bits = bits; + if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (state.mode < CHECK || flush !== Z_FINISH)) { + if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) { + state.mode = MEM; + return Z_MEM_ERROR; } } - }; - } -}); - -// ../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/psSupported.js -var require_psSupported = __commonJS({ - "../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/psSupported.js"(exports2, module2) { - var semver = require_semver2(); - module2.exports = semver.satisfies(process.version, "^6.12.0 || >=8.0.0"); - } -}); - -// ../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/verify.js -var require_verify = __commonJS({ - "../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/verify.js"(exports2, module2) { - var JsonWebTokenError = require_JsonWebTokenError(); - var NotBeforeError = require_NotBeforeError(); - var TokenExpiredError = require_TokenExpiredError(); - var decode = require_decode(); - var timespan = require_timespan(); - var validateAsymmetricKey = require_validateAsymmetricKey(); - var PS_SUPPORTED = require_psSupported(); - var jws = require_jws(); - var { KeyObject, createSecretKey, createPublicKey } = require("crypto"); - var PUB_KEY_ALGS = ["RS256", "RS384", "RS512"]; - var EC_KEY_ALGS = ["ES256", "ES384", "ES512"]; - var RSA_KEY_ALGS = ["RS256", "RS384", "RS512"]; - var HS_ALGS = ["HS256", "HS384", "HS512"]; - if (PS_SUPPORTED) { - PUB_KEY_ALGS.splice(PUB_KEY_ALGS.length, 0, "PS256", "PS384", "PS512"); - RSA_KEY_ALGS.splice(RSA_KEY_ALGS.length, 0, "PS256", "PS384", "PS512"); - } - module2.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")); + _in -= strm.avail_in; + _out -= strm.avail_out; + strm.total_in += _in; + strm.total_out += _out; + state.total += _out; + if (state.wrap && _out) { + strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/ + state.flags ? crc322(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out); } - if (options.nonce !== void 0 && (typeof options.nonce !== "string" || options.nonce.trim() === "")) { - return done(new JsonWebTokenError("nonce must be a non-empty string")); + strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0); + if ((_in === 0 && _out === 0 || flush === Z_FINISH) && ret === Z_OK) { + ret = Z_BUF_ERROR; } - if (options.allowInvalidAsymmetricKeyTypes !== void 0 && typeof options.allowInvalidAsymmetricKeyTypes !== "boolean") { - return done(new JsonWebTokenError("allowInvalidAsymmetricKeyTypes must be a boolean")); + return ret; + } + function inflateEnd(strm) { + if (!strm || !strm.state) { + return Z_STREAM_ERROR; } - const clockTimestamp = options.clockTimestamp || Math.floor(Date.now() / 1e3); - if (!jwtString) { - return done(new JsonWebTokenError("jwt must be provided")); + var state = strm.state; + if (state.window) { + state.window = null; } - if (typeof jwtString !== "string") { - return done(new JsonWebTokenError("jwt must be a string")); + strm.state = null; + return Z_OK; + } + function inflateGetHeader(strm, head) { + var state; + if (!strm || !strm.state) { + return Z_STREAM_ERROR; } - const parts = jwtString.split("."); - if (parts.length !== 3) { - return done(new JsonWebTokenError("jwt malformed")); + state = strm.state; + if ((state.wrap & 2) === 0) { + return Z_STREAM_ERROR; } - let decodedToken; - try { - decodedToken = decode(jwtString, { complete: true }); - } catch (err) { - return done(err); + state.head = head; + head.done = false; + return Z_OK; + } + function inflateSetDictionary(strm, dictionary) { + var dictLength = dictionary.length; + var state; + var dictid; + var ret; + if (!strm || !strm.state) { + return Z_STREAM_ERROR; } - if (!decodedToken) { - return done(new JsonWebTokenError("invalid token")); + state = strm.state; + if (state.wrap !== 0 && state.mode !== DICT) { + return Z_STREAM_ERROR; } - 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")); + if (state.mode === DICT) { + dictid = 1; + dictid = adler32(dictid, dictionary, dictLength, 0); + if (dictid !== state.check) { + return Z_DATA_ERROR; } - getSecret = secretOrPublicKey; - } else { - getSecret = function(header2, secretCallback) { - return secretCallback(null, secretOrPublicKey); - }; } - return getSecret(header, function(err, secretOrPublicKey2) { - if (err) { - return done(new JsonWebTokenError("error in secret or public key callback: " + err.message)); - } - const hasSignature = parts[2].trim() !== ""; - if (!hasSignature && secretOrPublicKey2) { - return done(new JsonWebTokenError("jwt signature is required")); - } - if (hasSignature && !secretOrPublicKey2) { - 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 (secretOrPublicKey2 != null && !(secretOrPublicKey2 instanceof KeyObject)) { - try { - secretOrPublicKey2 = createPublicKey(secretOrPublicKey2); - } catch (_) { - try { - secretOrPublicKey2 = createSecretKey(typeof secretOrPublicKey2 === "string" ? Buffer.from(secretOrPublicKey2) : secretOrPublicKey2); - } catch (_2) { - return done(new JsonWebTokenError("secretOrPublicKey is not valid key material")); - } - } - } - if (!options.algorithms) { - if (secretOrPublicKey2.type === "secret") { - options.algorithms = HS_ALGS; - } else if (["rsa", "rsa-pss"].includes(secretOrPublicKey2.asymmetricKeyType)) { - options.algorithms = RSA_KEY_ALGS; - } else if (secretOrPublicKey2.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") && secretOrPublicKey2.type !== "secret") { - return done(new JsonWebTokenError(`secretOrPublicKey must be a symmetric key when using ${header.alg}`)); - } else if (/^(?:RS|PS|ES)/.test(header.alg) && secretOrPublicKey2.type !== "public") { - return done(new JsonWebTokenError(`secretOrPublicKey must be an asymmetric key when using ${header.alg}`)); - } - if (!options.allowInvalidAsymmetricKeyTypes) { - try { - validateAsymmetricKey(header.alg, secretOrPublicKey2); - } catch (e) { - return done(e); - } - } - let valid; - try { - valid = jws.verify(jwtString, decodedToken.header.alg, secretOrPublicKey2); - } catch (e) { - return done(e); - } - if (!valid) { - 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", 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", new Date(payload.exp * 1e3))); - } - } - if (options.audience) { - const audiences = Array.isArray(options.audience) ? options.audience : [options.audience]; - const target = Array.isArray(payload.aud) ? payload.aud : [payload.aud]; - const match = target.some(function(targetAudience) { - return audiences.some(function(audience) { - return audience instanceof RegExp ? audience.test(targetAudience) : audience === targetAudience; - }); - }); - if (!match) { - return done(new JsonWebTokenError("jwt audience invalid. expected: " + audiences.join(" or "))); - } - } - if (options.issuer) { - const invalid_issuer = typeof options.issuer === "string" && payload.iss !== options.issuer || Array.isArray(options.issuer) && options.issuer.indexOf(payload.iss) === -1; - if (invalid_issuer) { - 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(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", new Date(maxAgeTimestamp * 1e3))); - } - } - if (options.complete === true) { - const signature = decodedToken.signature; - return done(null, { - header, - payload, - signature - }); - } - return done(null, payload); - }); + ret = updatewindow(strm, dictionary, dictLength, dictLength); + if (ret) { + state.mode = MEM; + return Z_MEM_ERROR; + } + state.havedict = 1; + return Z_OK; + } + exports2.inflateReset = inflateReset; + exports2.inflateReset2 = inflateReset2; + exports2.inflateResetKeep = inflateResetKeep; + exports2.inflateInit = inflateInit; + exports2.inflateInit2 = inflateInit2; + exports2.inflate = inflate2; + exports2.inflateEnd = inflateEnd; + exports2.inflateGetHeader = inflateGetHeader; + exports2.inflateSetDictionary = inflateSetDictionary; + exports2.inflateInfo = "pako inflate (from Nodeca project)"; + } +}); + +// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/constants.js +var require_constants6 = __commonJS({ + "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/constants.js"(exports2, module2) { + "use strict"; + module2.exports = { + /* Allowed flush values; see deflate() and inflate() below for details */ + Z_NO_FLUSH: 0, + Z_PARTIAL_FLUSH: 1, + Z_SYNC_FLUSH: 2, + Z_FULL_FLUSH: 3, + Z_FINISH: 4, + Z_BLOCK: 5, + Z_TREES: 6, + /* Return codes for the compression/decompression functions. Negative values + * are errors, positive values are used for special but normal events. + */ + Z_OK: 0, + Z_STREAM_END: 1, + Z_NEED_DICT: 2, + Z_ERRNO: -1, + Z_STREAM_ERROR: -2, + Z_DATA_ERROR: -3, + //Z_MEM_ERROR: -4, + Z_BUF_ERROR: -5, + //Z_VERSION_ERROR: -6, + /* compression levels */ + Z_NO_COMPRESSION: 0, + Z_BEST_SPEED: 1, + Z_BEST_COMPRESSION: 9, + Z_DEFAULT_COMPRESSION: -1, + Z_FILTERED: 1, + Z_HUFFMAN_ONLY: 2, + Z_RLE: 3, + Z_FIXED: 4, + Z_DEFAULT_STRATEGY: 0, + /* Possible values of the data_type field (though see inflate()) */ + Z_BINARY: 0, + Z_TEXT: 1, + //Z_ASCII: 1, // = Z_TEXT (deprecated) + Z_UNKNOWN: 2, + /* The deflate compression method */ + Z_DEFLATED: 8 + //Z_NULL: null // Use -1 or null inline, depending on var type }; } }); -// ../../../node_modules/.pnpm/lodash.includes@4.3.0/node_modules/lodash.includes/index.js -var require_lodash = __commonJS({ - "../../../node_modules/.pnpm/lodash.includes@4.3.0/node_modules/lodash.includes/index.js"(exports2, module2) { - var INFINITY = 1 / 0; - var MAX_SAFE_INTEGER = 9007199254740991; - var MAX_INTEGER = 17976931348623157e292; - var NAN = 0 / 0; - var argsTag = "[object Arguments]"; - var funcTag = "[object Function]"; - var genTag = "[object GeneratorFunction]"; - var stringTag = "[object String]"; - var symbolTag = "[object Symbol]"; - var reTrim = /^\s+|\s+$/g; - var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; - var reIsBinary = /^0b[01]+$/i; - var reIsOctal = /^0o[0-7]+$/i; - var reIsUint = /^(?:0|[1-9]\d*)$/; - var freeParseInt = parseInt; - function arrayMap(array, iteratee) { - var index2 = -1, length = array ? array.length : 0, result = Array(length); - while (++index2 < length) { - result[index2] = iteratee(array[index2], index2, array); - } - return result; +// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/gzheader.js +var require_gzheader = __commonJS({ + "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/gzheader.js"(exports2, module2) { + "use strict"; + function GZheader() { + this.text = 0; + this.time = 0; + this.xflags = 0; + this.os = 0; + this.extra = null; + this.extra_len = 0; + this.name = ""; + this.comment = ""; + this.hcrc = 0; + this.done = false; } - function baseFindIndex(array, predicate, fromIndex, fromRight) { - var length = array.length, index2 = fromIndex + (fromRight ? 1 : -1); - while (fromRight ? index2-- : ++index2 < length) { - if (predicate(array[index2], index2, array)) { - return index2; + module2.exports = GZheader; + } +}); + +// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/inflate.js +var require_inflate2 = __commonJS({ + "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/inflate.js"(exports2) { + "use strict"; + var zlib_inflate = require_inflate(); + var utils = require_common(); + var strings = require_strings(); + var c = require_constants6(); + var msg = require_messages(); + var ZStream = require_zstream(); + var GZheader = require_gzheader(); + var toString = Object.prototype.toString; + function Inflate(options) { + if (!(this instanceof Inflate)) + return new Inflate(options); + this.options = utils.assign({ + chunkSize: 16384, + windowBits: 0, + to: "" + }, options || {}); + var opt = this.options; + if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) { + opt.windowBits = -opt.windowBits; + if (opt.windowBits === 0) { + opt.windowBits = -15; } } - return -1; - } - function baseIndexOf(array, value, fromIndex) { - if (value !== value) { - return baseFindIndex(array, baseIsNaN, fromIndex); + if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) { + opt.windowBits += 32; } - var index2 = fromIndex - 1, length = array.length; - while (++index2 < length) { - if (array[index2] === value) { - return index2; + if (opt.windowBits > 15 && opt.windowBits < 48) { + if ((opt.windowBits & 15) === 0) { + opt.windowBits |= 15; } } - return -1; - } - function baseIsNaN(value) { - return value !== value; - } - function baseTimes(n, iteratee) { - var index2 = -1, result = Array(n); - while (++index2 < n) { - result[index2] = iteratee(index2); + this.err = 0; + this.msg = ""; + this.ended = false; + this.chunks = []; + this.strm = new ZStream(); + this.strm.avail_out = 0; + var status3 = zlib_inflate.inflateInit2( + this.strm, + opt.windowBits + ); + if (status3 !== c.Z_OK) { + throw new Error(msg[status3]); } - return result; - } - function baseValues(object, props) { - return arrayMap(props, function(key) { - return object[key]; - }); - } - function overArg(func, transform) { - return function(arg) { - return func(transform(arg)); - }; - } - var objectProto = Object.prototype; - var hasOwnProperty = objectProto.hasOwnProperty; - var objectToString = objectProto.toString; - var propertyIsEnumerable = objectProto.propertyIsEnumerable; - var nativeKeys = overArg(Object.keys, Object); - var nativeMax = Math.max; - function arrayLikeKeys(value, inherited) { - var result = isArray(value) || isArguments(value) ? baseTimes(value.length, String) : []; - var length = result.length, skipIndexes = !!length; - for (var key in value) { - if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && (key == "length" || isIndex(key, length)))) { - result.push(key); + this.header = new GZheader(); + zlib_inflate.inflateGetHeader(this.strm, this.header); + if (opt.dictionary) { + if (typeof opt.dictionary === "string") { + opt.dictionary = strings.string2buf(opt.dictionary); + } else if (toString.call(opt.dictionary) === "[object ArrayBuffer]") { + opt.dictionary = new Uint8Array(opt.dictionary); } - } - return result; - } - function baseKeys(object) { - if (!isPrototype(object)) { - return nativeKeys(object); - } - var result = []; - for (var key in Object(object)) { - if (hasOwnProperty.call(object, key) && key != "constructor") { - result.push(key); + if (opt.raw) { + status3 = zlib_inflate.inflateSetDictionary(this.strm, opt.dictionary); + if (status3 !== c.Z_OK) { + throw new Error(msg[status3]); + } } } - return result; - } - 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); - } - function isPrototype(value) { - var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto; - return value === proto; } - function includes(collection, value, fromIndex, guard) { - collection = isArrayLike(collection) ? collection : values(collection); - fromIndex = fromIndex && !guard ? toInteger(fromIndex) : 0; - var length = collection.length; - if (fromIndex < 0) { - fromIndex = nativeMax(length + fromIndex, 0); + Inflate.prototype.push = function(data, mode) { + var strm = this.strm; + var chunkSize = this.options.chunkSize; + var dictionary = this.options.dictionary; + var status3, _mode; + var next_out_utf8, tail, utf8str; + var allowBufError = false; + if (this.ended) { + return false; } - return isString(collection) ? fromIndex <= length && collection.indexOf(value, fromIndex) > -1 : !!length && baseIndexOf(collection, value, fromIndex) > -1; - } - function isArguments(value) { - return isArrayLikeObject(value) && hasOwnProperty.call(value, "callee") && (!propertyIsEnumerable.call(value, "callee") || objectToString.call(value) == argsTag); - } - var isArray = Array.isArray; - function isArrayLike(value) { - return value != null && isLength(value.length) && !isFunction2(value); - } - function isArrayLikeObject(value) { - return isObjectLike(value) && isArrayLike(value); - } - function isFunction2(value) { - var tag2 = isObject2(value) ? objectToString.call(value) : ""; - return tag2 == funcTag || tag2 == genTag; - } - function isLength(value) { - return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; - } - function isObject2(value) { - var type = typeof value; - return !!value && (type == "object" || type == "function"); - } - function isObjectLike(value) { - return !!value && typeof value == "object"; - } - function isString(value) { - return typeof value == "string" || !isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag; - } - function isSymbol(value) { - return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag; - } - function toFinite(value) { - if (!value) { - return value === 0 ? value : 0; + _mode = mode === ~~mode ? mode : mode === true ? c.Z_FINISH : c.Z_NO_FLUSH; + if (typeof data === "string") { + strm.input = strings.binstring2buf(data); + } else if (toString.call(data) === "[object ArrayBuffer]") { + strm.input = new Uint8Array(data); + } else { + strm.input = data; } - value = toNumber(value); - if (value === INFINITY || value === -INFINITY) { - var sign = value < 0 ? -1 : 1; - return sign * MAX_INTEGER; + strm.next_in = 0; + strm.avail_in = strm.input.length; + do { + if (strm.avail_out === 0) { + strm.output = new utils.Buf8(chunkSize); + strm.next_out = 0; + strm.avail_out = chunkSize; + } + status3 = zlib_inflate.inflate(strm, c.Z_NO_FLUSH); + if (status3 === c.Z_NEED_DICT && dictionary) { + status3 = zlib_inflate.inflateSetDictionary(this.strm, dictionary); + } + if (status3 === c.Z_BUF_ERROR && allowBufError === true) { + status3 = c.Z_OK; + allowBufError = false; + } + if (status3 !== c.Z_STREAM_END && status3 !== c.Z_OK) { + this.onEnd(status3); + this.ended = true; + return false; + } + if (strm.next_out) { + if (strm.avail_out === 0 || status3 === c.Z_STREAM_END || strm.avail_in === 0 && (_mode === c.Z_FINISH || _mode === c.Z_SYNC_FLUSH)) { + if (this.options.to === "string") { + next_out_utf8 = strings.utf8border(strm.output, strm.next_out); + tail = strm.next_out - next_out_utf8; + utf8str = strings.buf2string(strm.output, next_out_utf8); + strm.next_out = tail; + strm.avail_out = chunkSize - tail; + if (tail) { + utils.arraySet(strm.output, strm.output, next_out_utf8, tail, 0); + } + this.onData(utf8str); + } else { + this.onData(utils.shrinkBuf(strm.output, strm.next_out)); + } + } + } + if (strm.avail_in === 0 && strm.avail_out === 0) { + allowBufError = true; + } + } while ((strm.avail_in > 0 || strm.avail_out === 0) && status3 !== c.Z_STREAM_END); + if (status3 === c.Z_STREAM_END) { + _mode = c.Z_FINISH; } - return value === value ? value : 0; - } - function toInteger(value) { - var result = toFinite(value), remainder = result % 1; - return result === result ? remainder ? result - remainder : result : 0; - } - function toNumber(value) { - if (typeof value == "number") { - return value; + if (_mode === c.Z_FINISH) { + status3 = zlib_inflate.inflateEnd(this.strm); + this.onEnd(status3); + this.ended = true; + return status3 === c.Z_OK; } - if (isSymbol(value)) { - return NAN; + if (_mode === c.Z_SYNC_FLUSH) { + this.onEnd(c.Z_OK); + strm.avail_out = 0; + return true; } - if (isObject2(value)) { - var other = typeof value.valueOf == "function" ? value.valueOf() : value; - value = isObject2(other) ? other + "" : other; + return true; + }; + Inflate.prototype.onData = function(chunk) { + this.chunks.push(chunk); + }; + Inflate.prototype.onEnd = function(status3) { + if (status3 === c.Z_OK) { + if (this.options.to === "string") { + this.result = this.chunks.join(""); + } else { + this.result = utils.flattenChunks(this.chunks); + } } - if (typeof value != "string") { - return value === 0 ? value : +value; + this.chunks = []; + this.err = status3; + this.msg = this.strm.msg; + }; + function inflate2(input, options) { + var inflator = new Inflate(options); + inflator.push(input, true); + if (inflator.err) { + throw inflator.msg || msg[inflator.err]; } - value = value.replace(reTrim, ""); - var isBinary2 = reIsBinary.test(value); - return isBinary2 || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary2 ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value; - } - function keys(object) { - return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); + return inflator.result; } - function values(object) { - return object ? baseValues(object, keys(object)) : []; + function inflateRaw(input, options) { + options = options || {}; + options.raw = true; + return inflate2(input, options); } - module2.exports = includes; + exports2.Inflate = Inflate; + exports2.inflate = inflate2; + exports2.inflateRaw = inflateRaw; + exports2.ungzip = inflate2; } }); -// ../../../node_modules/.pnpm/lodash.isboolean@3.0.3/node_modules/lodash.isboolean/index.js -var require_lodash2 = __commonJS({ - "../../../node_modules/.pnpm/lodash.isboolean@3.0.3/node_modules/lodash.isboolean/index.js"(exports2, module2) { - var boolTag = "[object Boolean]"; - var objectProto = Object.prototype; - var objectToString = objectProto.toString; - function isBoolean(value) { - return value === true || value === false || isObjectLike(value) && objectToString.call(value) == boolTag; - } - function isObjectLike(value) { - return !!value && typeof value == "object"; - } - module2.exports = isBoolean; +// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/index.js +var require_pako = __commonJS({ + "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/index.js"(exports2, module2) { + "use strict"; + var assign = require_common().assign; + var deflate2 = require_deflate2(); + var inflate2 = require_inflate2(); + var constants = require_constants6(); + var pako2 = {}; + assign(pako2, deflate2, inflate2, constants); + module2.exports = pako2; } }); -// ../../../node_modules/.pnpm/lodash.isinteger@4.0.4/node_modules/lodash.isinteger/index.js -var require_lodash3 = __commonJS({ - "../../../node_modules/.pnpm/lodash.isinteger@4.0.4/node_modules/lodash.isinteger/index.js"(exports2, module2) { - var INFINITY = 1 / 0; - var MAX_INTEGER = 17976931348623157e292; - var NAN = 0 / 0; - var symbolTag = "[object Symbol]"; - var reTrim = /^\s+|\s+$/g; - var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; - var reIsBinary = /^0b[01]+$/i; - var reIsOctal = /^0o[0-7]+$/i; - var freeParseInt = parseInt; - var objectProto = Object.prototype; - var objectToString = objectProto.toString; - function isInteger(value) { - return typeof value == "number" && value == toInteger(value); - } - function isObject2(value) { - var type = typeof value; - return !!value && (type == "object" || type == "function"); - } - function isObjectLike(value) { - return !!value && typeof value == "object"; +// ../../../node_modules/.pnpm/pify@5.0.0/node_modules/pify/index.js +var require_pify = __commonJS({ + "../../../node_modules/.pnpm/pify@5.0.0/node_modules/pify/index.js"(exports2, module2) { + "use strict"; + var processFn = (fn, options, proxy, unwrapped) => function(...arguments_) { + const P = options.promiseModule; + return new P((resolve, reject) => { + if (options.multiArgs) { + arguments_.push((...result) => { + if (options.errorFirst) { + if (result[0]) { + reject(result); + } else { + result.shift(); + resolve(result); + } + } else { + resolve(result); + } + }); + } else if (options.errorFirst) { + arguments_.push((error, result) => { + if (error) { + reject(error); + } else { + resolve(result); + } + }); + } else { + arguments_.push(resolve); + } + const self2 = this === proxy ? unwrapped : this; + Reflect.apply(fn, self2, arguments_); + }); + }; + var filterCache = /* @__PURE__ */ new WeakMap(); + module2.exports = (input, options) => { + options = { + exclude: [/.+(?:Sync|Stream)$/], + errorFirst: true, + promiseModule: Promise, + ...options + }; + const objectType = typeof input; + if (!(input !== null && (objectType === "object" || objectType === "function"))) { + throw new TypeError(`Expected \`input\` to be a \`Function\` or \`Object\`, got \`${input === null ? "null" : objectType}\``); + } + const filter = (target, key) => { + let cached = filterCache.get(target); + if (!cached) { + cached = {}; + filterCache.set(target, cached); + } + if (key in cached) { + return cached[key]; + } + const match = (pattern2) => typeof pattern2 === "string" || typeof key === "symbol" ? key === pattern2 : pattern2.test(key); + const desc = Reflect.getOwnPropertyDescriptor(target, key); + const writableOrConfigurableOwn = desc === void 0 || desc.writable || desc.configurable; + const included = options.include ? options.include.some(match) : !options.exclude.some(match); + const shouldFilter = included && writableOrConfigurableOwn; + cached[key] = shouldFilter; + return shouldFilter; + }; + const cache = /* @__PURE__ */ new WeakMap(); + const proxy = new Proxy(input, { + apply(target, thisArg, args) { + const cached = cache.get(target); + if (cached) { + return Reflect.apply(cached, thisArg, args); + } + const pified = options.excludeMain ? target : processFn(target, options, proxy, target); + cache.set(target, pified); + return Reflect.apply(pified, thisArg, args); + }, + get(target, key) { + const property = target[key]; + if (!filter(target, key) || property === Function.prototype[key]) { + return property; + } + const cached = cache.get(property); + if (cached) { + return cached; + } + if (typeof property === "function") { + const pified = processFn(property, options, proxy, target); + cache.set(property, pified); + return pified; + } + return property; + } + }); + return proxy; + }; + } +}); + +// ../../../node_modules/.pnpm/ignore@5.3.1/node_modules/ignore/index.js +var require_ignore = __commonJS({ + "../../../node_modules/.pnpm/ignore@5.3.1/node_modules/ignore/index.js"(exports2, module2) { + function makeArray(subject) { + return Array.isArray(subject) ? subject : [subject]; } - function isSymbol(value) { - return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag; + var EMPTY = ""; + var SPACE = " "; + var ESCAPE = "\\"; + var REGEX_TEST_BLANK_LINE = /^\s+$/; + var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/; + var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/; + var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/; + var REGEX_SPLITALL_CRLF = /\r?\n/g; + var REGEX_TEST_INVALID_PATH = /^\.*\/|^\.+$/; + var SLASH = "/"; + var TMP_KEY_IGNORE = "node-ignore"; + if (typeof Symbol !== "undefined") { + TMP_KEY_IGNORE = Symbol.for("node-ignore"); } - function toFinite(value) { - if (!value) { - return value === 0 ? value : 0; + var KEY_IGNORE = TMP_KEY_IGNORE; + var define2 = (object, key, value) => Object.defineProperty(object, key, { value }); + var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g; + var RETURN_FALSE = () => false; + var sanitizeRange = (range) => range.replace( + REGEX_REGEXP_RANGE, + (match, from2, to) => from2.charCodeAt(0) <= to.charCodeAt(0) ? match : EMPTY + ); + var cleanRangeBackSlash = (slashes) => { + const { length } = slashes; + return slashes.slice(0, length - length % 2); + }; + var REPLACERS = [ + [ + // remove BOM + // TODO: + // Other similar zero-width characters? + /^\uFEFF/, + () => EMPTY + ], + // > Trailing spaces are ignored unless they are quoted with backslash ("\") + [ + // (a\ ) -> (a ) + // (a ) -> (a) + // (a \ ) -> (a ) + /\\?\s+$/, + (match) => match.indexOf("\\") === 0 ? SPACE : EMPTY + ], + // replace (\ ) with ' ' + [ + /\\\s/g, + () => SPACE + ], + // Escape metacharacters + // which is written down by users but means special for regular expressions. + // > There are 12 characters with special meanings: + // > - the backslash \, + // > - the caret ^, + // > - the dollar sign $, + // > - the period or dot ., + // > - the vertical bar or pipe symbol |, + // > - the question mark ?, + // > - the asterisk or star *, + // > - the plus sign +, + // > - the opening parenthesis (, + // > - the closing parenthesis ), + // > - and the opening square bracket [, + // > - the opening curly brace {, + // > These special characters are often called "metacharacters". + [ + /[\\$.|*+(){^]/g, + (match) => `\\${match}` + ], + [ + // > a question mark (?) matches a single character + /(?!\\)\?/g, + () => "[^/]" + ], + // leading slash + [ + // > A leading slash matches the beginning of the pathname. + // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c". + // A leading slash matches the beginning of the pathname + /^\//, + () => "^" + ], + // replace special metacharacter slash after the leading slash + [ + /\//g, + () => "\\/" + ], + [ + // > A leading "**" followed by a slash means match in all directories. + // > For example, "**/foo" matches file or directory "foo" anywhere, + // > the same as pattern "foo". + // > "**/foo/bar" matches file or directory "bar" anywhere that is directly + // > under directory "foo". + // Notice that the '*'s have been replaced as '\\*' + /^\^*\\\*\\\*\\\//, + // '**/foo' <-> 'foo' + () => "^(?:.*\\/)?" + ], + // starting + [ + // there will be no leading '/' + // (which has been replaced by section "leading slash") + // If starts with '**', adding a '^' to the regular expression also works + /^(?=[^^])/, + function startingReplacer() { + return !/\/(?!$)/.test(this) ? "(?:^|\\/)" : "^"; + } + ], + // two globstars + [ + // Use lookahead assertions so that we could match more than one `'/**'` + /\\\/\\\*\\\*(?=\\\/|$)/g, + // Zero, one or several directories + // should not use '*', or it will be replaced by the next replacer + // Check if it is not the last `'/**'` + (_, index2, str) => index2 + 6 < str.length ? "(?:\\/[^\\/]+)*" : "\\/.+" + ], + // normal intermediate wildcards + [ + // Never replace escaped '*' + // ignore rule '\*' will match the path '*' + // 'abc.*/' -> go + // 'abc.*' -> skip this rule, + // coz trailing single wildcard will be handed by [trailing wildcard] + /(^|[^\\]+)(\\\*)+(?=.+)/g, + // '*.js' matches '.js' + // '*.js' doesn't match 'abc' + (_, p1, p2) => { + const unescaped = p2.replace(/\\\*/g, "[^\\/]*"); + return p1 + unescaped; + } + ], + [ + // unescape, revert step 3 except for back slash + // For example, if a user escape a '\\*', + // after step 3, the result will be '\\\\\\*' + /\\\\\\(?=[$.|*+(){^])/g, + () => ESCAPE + ], + [ + // '\\\\' -> '\\' + /\\\\/g, + () => ESCAPE + ], + [ + // > The range notation, e.g. [a-zA-Z], + // > can be used to match one of the characters in a range. + // `\` is escaped by step 3 + /(\\)?\[([^\]/]*?)(\\*)($|\])/g, + (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` : close === "]" ? endEscape.length % 2 === 0 ? `[${sanitizeRange(range)}${endEscape}]` : "[]" : "[]" + ], + // ending + [ + // 'js' will not match 'js.' + // 'ab' will not match 'abc' + /(?:[^*])$/, + // WTF! + // https://git-scm.com/docs/gitignore + // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1) + // which re-fixes #24, #38 + // > If there is a separator at the end of the pattern then the pattern + // > will only match directories, otherwise the pattern can match both + // > files and directories. + // 'js*' will not match 'a.js' + // 'js/' will not match 'a.js' + // 'js' will match 'a.js' and 'a.js/' + (match) => /\/$/.test(match) ? `${match}$` : `${match}(?=$|\\/$)` + ], + // trailing wildcard + [ + /(\^|\\\/)?\\\*$/, + (_, p1) => { + const prefix = p1 ? `${p1}[^/]+` : "[^/]*"; + return `${prefix}(?=$|\\/$)`; + } + ] + ]; + var regexCache = /* @__PURE__ */ Object.create(null); + var makeRegex = (pattern2, ignoreCase) => { + let source = regexCache[pattern2]; + if (!source) { + source = REPLACERS.reduce( + (prev, current) => prev.replace(current[0], current[1].bind(pattern2)), + pattern2 + ); + regexCache[pattern2] = source; } - value = toNumber(value); - if (value === INFINITY || value === -INFINITY) { - var sign = value < 0 ? -1 : 1; - return sign * MAX_INTEGER; + return ignoreCase ? new RegExp(source, "i") : new RegExp(source); + }; + var isString = (subject) => typeof subject === "string"; + var checkPattern = (pattern2) => pattern2 && isString(pattern2) && !REGEX_TEST_BLANK_LINE.test(pattern2) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern2) && pattern2.indexOf("#") !== 0; + var splitPattern = (pattern2) => pattern2.split(REGEX_SPLITALL_CRLF); + var IgnoreRule = class { + constructor(origin, pattern2, negative, regex) { + this.origin = origin; + this.pattern = pattern2; + this.negative = negative; + this.regex = regex; } - return value === value ? value : 0; - } - function toInteger(value) { - var result = toFinite(value), remainder = result % 1; - return result === result ? remainder ? result - remainder : result : 0; - } - function toNumber(value) { - if (typeof value == "number") { - return value; + }; + var createRule = (pattern2, ignoreCase) => { + const origin = pattern2; + let negative = false; + if (pattern2.indexOf("!") === 0) { + negative = true; + pattern2 = pattern2.substr(1); } - if (isSymbol(value)) { - return NAN; + pattern2 = pattern2.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#"); + const regex = makeRegex(pattern2, ignoreCase); + return new IgnoreRule( + origin, + pattern2, + negative, + regex + ); + }; + var throwError = (message, Ctor) => { + throw new Ctor(message); + }; + var checkPath = (path, originalPath, doThrow) => { + if (!isString(path)) { + return doThrow( + `path must be a string, but got \`${originalPath}\``, + TypeError + ); } - if (isObject2(value)) { - var other = typeof value.valueOf == "function" ? value.valueOf() : value; - value = isObject2(other) ? other + "" : other; + if (!path) { + return doThrow(`path must not be empty`, TypeError); } - if (typeof value != "string") { - return value === 0 ? value : +value; + if (checkPath.isNotRelative(path)) { + const r = "`path.relative()`d"; + return doThrow( + `path should be a ${r} string, but got "${originalPath}"`, + RangeError + ); } - value = value.replace(reTrim, ""); - var isBinary2 = reIsBinary.test(value); - return isBinary2 || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary2 ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value; - } - module2.exports = isInteger; - } -}); - -// ../../../node_modules/.pnpm/lodash.isnumber@3.0.3/node_modules/lodash.isnumber/index.js -var require_lodash4 = __commonJS({ - "../../../node_modules/.pnpm/lodash.isnumber@3.0.3/node_modules/lodash.isnumber/index.js"(exports2, module2) { - var numberTag = "[object Number]"; - var objectProto = Object.prototype; - var objectToString = objectProto.toString; - function isObjectLike(value) { - return !!value && typeof value == "object"; - } - function isNumber(value) { - return typeof value == "number" || isObjectLike(value) && objectToString.call(value) == numberTag; - } - module2.exports = isNumber; - } -}); - -// ../../../node_modules/.pnpm/lodash.isplainobject@4.0.6/node_modules/lodash.isplainobject/index.js -var require_lodash5 = __commonJS({ - "../../../node_modules/.pnpm/lodash.isplainobject@4.0.6/node_modules/lodash.isplainobject/index.js"(exports2, module2) { - var objectTag = "[object Object]"; - function isHostObject(value) { - var result = false; - if (value != null && typeof value.toString != "function") { - try { - result = !!(value + ""); - } catch (e) { + return true; + }; + var isNotRelative = (path) => REGEX_TEST_INVALID_PATH.test(path); + checkPath.isNotRelative = isNotRelative; + checkPath.convert = (p) => p; + var Ignore = class { + constructor({ + ignorecase = true, + ignoreCase = ignorecase, + allowRelativePaths = false + } = {}) { + define2(this, KEY_IGNORE, true); + this._rules = []; + this._ignoreCase = ignoreCase; + this._allowRelativePaths = allowRelativePaths; + this._initCache(); + } + _initCache() { + this._ignoreCache = /* @__PURE__ */ Object.create(null); + this._testCache = /* @__PURE__ */ Object.create(null); + } + _addPattern(pattern2) { + if (pattern2 && pattern2[KEY_IGNORE]) { + this._rules = this._rules.concat(pattern2._rules); + this._added = true; + return; + } + if (checkPattern(pattern2)) { + const rule = createRule(pattern2, this._ignoreCase); + this._added = true; + this._rules.push(rule); } } - return result; - } - function overArg(func, transform) { - return function(arg) { - return func(transform(arg)); - }; - } - var funcProto = Function.prototype; - var objectProto = Object.prototype; - var funcToString = funcProto.toString; - var hasOwnProperty = objectProto.hasOwnProperty; - var objectCtorString = funcToString.call(Object); - var objectToString = objectProto.toString; - var getPrototype = overArg(Object.getPrototypeOf, Object); - function isObjectLike(value) { - return !!value && typeof value == "object"; - } - function isPlainObject(value) { - if (!isObjectLike(value) || objectToString.call(value) != objectTag || isHostObject(value)) { - return false; + // @param {Array | string | Ignore} pattern + add(pattern2) { + this._added = false; + makeArray( + isString(pattern2) ? splitPattern(pattern2) : pattern2 + ).forEach(this._addPattern, this); + if (this._added) { + this._initCache(); + } + return this; } - var proto = getPrototype(value); - if (proto === null) { - return true; + // legacy + addPattern(pattern2) { + return this.add(pattern2); } - var Ctor = hasOwnProperty.call(proto, "constructor") && proto.constructor; - return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString; - } - module2.exports = isPlainObject; - } -}); - -// ../../../node_modules/.pnpm/lodash.isstring@4.0.1/node_modules/lodash.isstring/index.js -var require_lodash6 = __commonJS({ - "../../../node_modules/.pnpm/lodash.isstring@4.0.1/node_modules/lodash.isstring/index.js"(exports2, module2) { - var stringTag = "[object String]"; - var objectProto = Object.prototype; - var objectToString = objectProto.toString; - var isArray = Array.isArray; - function isObjectLike(value) { - return !!value && typeof value == "object"; - } - function isString(value) { - return typeof value == "string" || !isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag; - } - module2.exports = isString; - } -}); - -// ../../../node_modules/.pnpm/lodash.once@4.1.1/node_modules/lodash.once/index.js -var require_lodash7 = __commonJS({ - "../../../node_modules/.pnpm/lodash.once@4.1.1/node_modules/lodash.once/index.js"(exports2, module2) { - var FUNC_ERROR_TEXT = "Expected a function"; - var INFINITY = 1 / 0; - var MAX_INTEGER = 17976931348623157e292; - var NAN = 0 / 0; - var symbolTag = "[object Symbol]"; - var reTrim = /^\s+|\s+$/g; - var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; - var reIsBinary = /^0b[01]+$/i; - var reIsOctal = /^0o[0-7]+$/i; - var freeParseInt = parseInt; - var objectProto = Object.prototype; - var objectToString = objectProto.toString; - function before(n, func) { - var result; - if (typeof func != "function") { - throw new TypeError(FUNC_ERROR_TEXT); + // | ignored : unignored + // negative | 0:0 | 0:1 | 1:0 | 1:1 + // -------- | ------- | ------- | ------- | -------- + // 0 | TEST | TEST | SKIP | X + // 1 | TESTIF | SKIP | TEST | X + // - SKIP: always skip + // - TEST: always test + // - TESTIF: only test if checkUnignored + // - X: that never happen + // @param {boolean} whether should check if the path is unignored, + // setting `checkUnignored` to `false` could reduce additional + // path matching. + // @returns {TestResult} true if a file is ignored + _testOne(path, checkUnignored) { + let ignored = false; + let unignored = false; + this._rules.forEach((rule) => { + const { negative } = rule; + if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) { + return; + } + const matched = rule.regex.test(path); + if (matched) { + ignored = !negative; + unignored = negative; + } + }); + return { + ignored, + unignored + }; } - n = toInteger(n); - return function() { - if (--n > 0) { - result = func.apply(this, arguments); + // @returns {TestResult} + _test(originalPath, cache, checkUnignored, slices) { + const path = originalPath && checkPath.convert(originalPath); + checkPath( + path, + originalPath, + this._allowRelativePaths ? RETURN_FALSE : throwError + ); + return this._t(path, cache, checkUnignored, slices); + } + _t(path, cache, checkUnignored, slices) { + if (path in cache) { + return cache[path]; } - if (n <= 1) { - func = void 0; + if (!slices) { + slices = path.split(SLASH); } - return result; - }; - } - function once(func) { - return before(2, func); - } - function isObject2(value) { - var type = typeof value; - return !!value && (type == "object" || type == "function"); - } - function isObjectLike(value) { - return !!value && typeof value == "object"; - } - function isSymbol(value) { - return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag; - } - function toFinite(value) { - if (!value) { - return value === 0 ? value : 0; - } - value = toNumber(value); - if (value === INFINITY || value === -INFINITY) { - var sign = value < 0 ? -1 : 1; - return sign * MAX_INTEGER; + slices.pop(); + if (!slices.length) { + return cache[path] = this._testOne(path, checkUnignored); + } + const parent = this._t( + slices.join(SLASH) + SLASH, + cache, + checkUnignored, + slices + ); + return cache[path] = parent.ignored ? parent : this._testOne(path, checkUnignored); } - return value === value ? value : 0; - } - function toInteger(value) { - var result = toFinite(value), remainder = result % 1; - return result === result ? remainder ? result - remainder : result : 0; - } - function toNumber(value) { - if (typeof value == "number") { - return value; + ignores(path) { + return this._test(path, this._ignoreCache, false).ignored; } - if (isSymbol(value)) { - return NAN; + createFilter() { + return (path) => !this.ignores(path); } - if (isObject2(value)) { - var other = typeof value.valueOf == "function" ? value.valueOf() : value; - value = isObject2(other) ? other + "" : other; + filter(paths) { + return makeArray(paths).filter(this.createFilter()); } - if (typeof value != "string") { - return value === 0 ? value : +value; + // @returns {TestResult} + test(path) { + return this._test(path, this._testCache, true); } - value = value.replace(reTrim, ""); - var isBinary2 = reIsBinary.test(value); - return isBinary2 || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary2 ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value; + }; + var factory = (options) => new Ignore(options); + var isPathValid = (path) => checkPath(path && checkPath.convert(path), path, RETURN_FALSE); + factory.isPathValid = isPathValid; + factory.default = factory; + module2.exports = factory; + if ( + // Detect `process` so that it can run in browsers. + typeof process !== "undefined" && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === "win32") + ) { + const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/"); + checkPath.convert = makePosix; + const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i; + checkPath.isNotRelative = (path) => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path) || isNotRelative(path); } - module2.exports = once; } }); -// ../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/sign.js -var require_sign = __commonJS({ - "../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/sign.js"(exports2, module2) { - var timespan = require_timespan(); - var PS_SUPPORTED = require_psSupported(); - var validateAsymmetricKey = require_validateAsymmetricKey(); - var jws = require_jws(); - var includes = require_lodash(); - var isBoolean = require_lodash2(); - var isInteger = require_lodash3(); - var isNumber = require_lodash4(); - var isPlainObject = require_lodash5(); - var isString = require_lodash6(); - var once = require_lodash7(); - var { KeyObject, createSecretKey, createPrivateKey } = require("crypto"); - var SUPPORTED_ALGS = ["RS256", "RS384", "RS512", "ES256", "ES384", "ES512", "HS256", "HS384", "HS512", "none"]; - if (PS_SUPPORTED) { - SUPPORTED_ALGS.splice(3, 0, "PS256", "PS384", "PS512"); - } - var 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' } - }; - var 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 validate2(schema2, allowUnknown, object, parameterName) { - if (!isPlainObject(object)) { - throw new Error('Expected "' + parameterName + '" to be a plain object.'); - } - Object.keys(object).forEach(function(key) { - const validator = schema2[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 validate2(sign_options_schema, false, options, "options"); +// ../../../node_modules/.pnpm/clean-git-ref@2.0.1/node_modules/clean-git-ref/lib/index.js +var require_lib3 = __commonJS({ + "../../../node_modules/.pnpm/clean-git-ref@2.0.1/node_modules/clean-git-ref/lib/index.js"(exports2, module2) { + "use strict"; + function escapeRegExp(string) { + return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); } - function validatePayload(payload) { - return validate2(registered_claims_schema, true, payload, "payload"); + function replaceAll(str, search, replacement) { + search = search instanceof RegExp ? search : new RegExp(escapeRegExp(search), "g"); + return str.replace(search, replacement); } - var options_to_payload = { - "audience": "aud", - "issuer": "iss", - "subject": "sub", - "jwtid": "jti" - }; - var options_for_objects = [ - "expiresIn", - "notBefore", - "noTimestamp", - "audience", - "issuer", - "subject", - "jwtid" - ]; - module2.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(new Error("secretOrPrivateKey must have a value")); - } - if (secretOrPrivateKey != null && !(secretOrPrivateKey instanceof KeyObject)) { - try { - secretOrPrivateKey = createPrivateKey(secretOrPrivateKey); - } catch (_) { - try { - secretOrPrivateKey = createSecretKey(typeof secretOrPrivateKey === "string" ? Buffer.from(secretOrPrivateKey) : secretOrPrivateKey); - } catch (_2) { - return failure(new Error("secretOrPrivateKey is not valid key material")); - } + var CleanGitRef = { + clean: function clean(value) { + if (typeof value !== "string") { + throw new Error("Expected a string, received: " + value); } + value = replaceAll(value, "./", "/"); + value = replaceAll(value, "..", "."); + value = replaceAll(value, " ", "-"); + value = replaceAll(value, /^[~^:?*\\\-]/g, ""); + value = replaceAll(value, /[~^:?*\\]/g, "-"); + value = replaceAll(value, /[~^:?*\\\-]$/g, ""); + value = replaceAll(value, "@{", "-"); + value = replaceAll(value, /\.$/g, ""); + value = replaceAll(value, /\/$/g, ""); + value = replaceAll(value, /\.lock$/g, ""); + return value; } - if (header.alg.startsWith("HS") && secretOrPrivateKey.type !== "secret") { - return failure(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(new Error(`secretOrPrivateKey must be an asymmetric key when using ${header.alg}`)); + }; + module2.exports = CleanGitRef; + } +}); + +// ../../../node_modules/.pnpm/diff3@0.0.4/node_modules/diff3/onp.js +var require_onp = __commonJS({ + "../../../node_modules/.pnpm/diff3@0.0.4/node_modules/diff3/onp.js"(exports2, module2) { + module2.exports = function(a_, b_) { + var a = a_, b = b_, m = a.length, n = b.length, reverse = false, offset = m + 1, path = [], pathposi = []; + var tmp1, tmp2; + var init2 = function() { + if (m >= n) { + tmp1 = a; + tmp2 = m; + a = b; + b = tmp1; + m = n; + n = tmp2; + reverse = true; + offset = m + 1; } - if (!options.allowInsecureKeySizes && !header.alg.startsWith("ES") && secretOrPrivateKey.asymmetricKeyDetails !== void 0 && //KeyObject.asymmetricKeyDetails is supported in Node 15+ - secretOrPrivateKey.asymmetricKeyDetails.modulusLength < 2048) { - return failure(new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${header.alg}`)); + }; + var P = function(startX, startY, endX, endY, r) { + return { + startX, + startY, + endX, + endY, + r + }; + }; + var snake = function(k, p, pp) { + var r, x, y, startX, startY; + if (p > pp) { + r = path[k - 1 + offset]; + } else { + r = path[k + 1 + offset]; } - } - if (typeof payload === "undefined") { - return failure(new Error("payload is required")); - } else if (isObjectPayload) { - try { - validatePayload(payload); - } catch (error) { - return failure(error); + startY = y = Math.max(p, pp); + startX = x = y - k; + while (x < m && y < n && a[x] === b[y]) { + ++x; + ++y; } - if (!options.mutatePayload) { - payload = Object.assign({}, payload); + if (startX == x && startY == y) { + path[k + offset] = r; + } else { + path[k + offset] = pathposi.length; + pathposi[pathposi.length] = new P(startX, startY, x, y, r); } - } else { - const invalid_options = options_for_objects.filter(function(opt) { - return typeof options[opt] !== "undefined"; - }); - if (invalid_options.length > 0) { - return failure(new Error("invalid " + invalid_options.join(",") + " option for " + typeof payload + " payload")); + return y; + }; + init2(); + return { + compose: function() { + var delta, size, fp, p, r, i, k, lastStartX, lastStartY, result; + delta = n - m; + size = m + n + 3; + fp = {}; + for (i = 0; i < size; ++i) { + fp[i] = -1; + path[i] = -1; + } + p = -1; + do { + ++p; + for (k = -p; k <= delta - 1; ++k) { + fp[k + offset] = snake(k, fp[k - 1 + offset] + 1, fp[k + 1 + offset]); + } + for (k = delta + p; k >= delta + 1; --k) { + fp[k + offset] = snake(k, fp[k - 1 + offset] + 1, fp[k + 1 + offset]); + } + fp[delta + offset] = snake(delta, fp[delta - 1 + offset] + 1, fp[delta + 1 + offset]); + } while (fp[delta + offset] !== n); + ed = delta + 2 * p; + r = path[delta + offset]; + lastStartX = m; + lastStartY = n; + result = []; + while (r !== -1) { + let elem = pathposi[r]; + if (m != elem.endX || n != elem.endY) { + result.push({ + file1: [ + reverse ? elem.endY : elem.endX, + reverse ? lastStartY - elem.endY : lastStartX - elem.endX + ], + file2: [ + reverse ? elem.endX : elem.endY, + reverse ? lastStartX - elem.endX : lastStartY - elem.endY + ] + }); + } + lastStartX = elem.startX; + lastStartY = elem.startY; + r = pathposi[r].r; + } + if (lastStartX != 0 || lastStartY != 0) { + result.push({ + file1: [0, reverse ? lastStartY : lastStartX], + file2: [0, reverse ? lastStartX : lastStartY] + }); + } + result.reverse(); + return result; } + }; + }; + } +}); + +// ../../../node_modules/.pnpm/diff3@0.0.4/node_modules/diff3/diff3.js +var require_diff3 = __commonJS({ + "../../../node_modules/.pnpm/diff3@0.0.4/node_modules/diff3/diff3.js"(exports2, module2) { + var onp = require_onp(); + function diff3MergeIndices(a, o, b) { + var i; + var m1 = new onp(o, a).compose(); + var m2 = new onp(o, b).compose(); + var hunks = []; + function addHunk(h, side2) { + hunks.push([h.file1[0], side2, h.file1[1], h.file2[0], h.file2[1]]); } - if (typeof payload.exp !== "undefined" && typeof options.expiresIn !== "undefined") { - return failure(new Error('Bad "options.expiresIn" option the payload already has an "exp" property.')); - } - if (typeof payload.nbf !== "undefined" && typeof options.notBefore !== "undefined") { - return failure(new Error('Bad "options.notBefore" option the payload already has an "nbf" property.')); + for (i = 0; i < m1.length; i++) { + addHunk(m1[i], 0); } - try { - validateOptions(options); - } catch (error) { - return failure(error); + for (i = 0; i < m2.length; i++) { + addHunk(m2[i], 2); } - if (!options.allowInvalidAsymmetricKeyTypes) { - try { - validateAsymmetricKey(header.alg, secretOrPrivateKey); - } catch (error) { - return failure(error); + hunks.sort(function(x, y) { + return x[0] - y[0]; + }); + var result = []; + var commonOffset = 0; + function copyCommon(targetOffset) { + if (targetOffset > commonOffset) { + result.push([1, commonOffset, targetOffset - commonOffset]); + commonOffset = targetOffset; } } - 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); + for (var hunkIndex = 0; hunkIndex < hunks.length; hunkIndex++) { + var firstHunkIndex = hunkIndex; + var hunk = hunks[hunkIndex]; + var regionLhs = hunk[0]; + var regionRhs = regionLhs + hunk[2]; + while (hunkIndex < hunks.length - 1) { + var maybeOverlapping = hunks[hunkIndex + 1]; + var maybeLhs = maybeOverlapping[0]; + if (maybeLhs > regionRhs) + break; + regionRhs = Math.max(regionRhs, maybeLhs + maybeOverlapping[2]); + hunkIndex++; } - if (typeof payload.nbf === "undefined") { - return failure(new Error('"notBefore" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60')); + copyCommon(regionLhs); + if (firstHunkIndex == hunkIndex) { + if (hunk[4] > 0) { + result.push([hunk[1], hunk[3], hunk[4]]); + } + } else { + var regions = { + 0: [a.length, -1, o.length, -1], + 2: [b.length, -1, o.length, -1] + }; + for (i = firstHunkIndex; i <= hunkIndex; i++) { + hunk = hunks[i]; + var side = hunk[1]; + var r = regions[side]; + var oLhs = hunk[0]; + var oRhs = oLhs + hunk[2]; + var abLhs = hunk[3]; + var abRhs = abLhs + hunk[4]; + r[0] = Math.min(abLhs, r[0]); + r[1] = Math.max(abRhs, r[1]); + r[2] = Math.min(oLhs, r[2]); + r[3] = Math.max(oRhs, r[3]); + } + var aLhs = regions[0][0] + (regionLhs - regions[0][2]); + var aRhs = regions[0][1] + (regionRhs - regions[0][3]); + var bLhs = regions[2][0] + (regionLhs - regions[2][2]); + var bRhs = regions[2][1] + (regionRhs - regions[2][3]); + result.push([ + -1, + aLhs, + aRhs - aLhs, + regionLhs, + regionRhs - regionLhs, + bLhs, + bRhs - bLhs + ]); } + commonOffset = regionRhs; } - if (typeof options.expiresIn !== "undefined" && typeof payload === "object") { - try { - payload.exp = timespan(options.expiresIn, timestamp); - } catch (err) { - return failure(err); + copyCommon(o.length); + return result; + } + function diff3Merge2(a, o, b) { + var result = []; + var files = [a, o, b]; + var indices = diff3MergeIndices(a, o, b); + var okLines = []; + function flushOk() { + if (okLines.length) { + result.push({ + ok: okLines + }); } - if (typeof payload.exp === "undefined") { - return failure(new Error('"expiresIn" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60')); + okLines = []; + } + function pushOk(xs) { + for (var j = 0; j < xs.length; j++) { + okLines.push(xs[j]); } } - 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(new Error('Bad "options.' + key + '" option. The payload already has an "' + claim + '" property.')); - } - payload[claim] = options[key]; + function isTrueConflict(rec) { + if (rec[2] != rec[6]) + return true; + var aoff = rec[1]; + var boff = rec[5]; + for (var j = 0; j < rec[2]; j++) { + if (a[j + aoff] != b[j + boff]) + return true; } - }); - 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(new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${header.alg}`)); + return false; + } + for (var i = 0; i < indices.length; i++) { + var x = indices[i]; + var side = x[0]; + if (side == -1) { + if (!isTrueConflict(x)) { + pushOk(files[0].slice(x[1], x[1] + x[2])); + } else { + flushOk(); + result.push({ + conflict: { + a: a.slice(x[1], x[1] + x[2]), + aIndex: x[1], + o: o.slice(x[3], x[3] + x[4]), + oIndex: x[3], + b: b.slice(x[5], x[5] + x[6]), + bIndex: x[5] + } + }); } - 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}`); + } else { + pushOk(files[side].slice(x[1], x[1] + x[2])); } - return signature; } - }; + flushOk(); + return result; + } + module2.exports = diff3Merge2; } }); -// ../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/index.js -var require_jsonwebtoken = __commonJS({ - "../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/index.js"(exports2, module2) { - module2.exports = { - decode: require_decode(), - verify: require_verify(), - sign: require_sign(), - JsonWebTokenError: require_JsonWebTokenError(), - NotBeforeError: require_NotBeforeError(), - TokenExpiredError: require_TokenExpiredError() +// ../../../lix/packages/fs/dist/errors/FilesystemError.js +var FilesystemError; +var init_FilesystemError = __esm({ + "../../../lix/packages/fs/dist/errors/FilesystemError.js"() { + "use strict"; + FilesystemError = class extends Error { + code; + path; + syscall; + target; + constructor(code, path, syscall, target) { + let message; + switch (code) { + case "ENOENT": + message = `${code}: No such file or directory, ${syscall} '${path}'`; + break; + case "ENOTDIR": + message = `${code}: Not a directory, ${syscall} '${path}'`; + break; + case "EISDIR": + message = `${code}: Illegal operation on a directory, ${syscall} '${path}'`; + break; + case "ENOTEMPTY": + message = `${code}: Directory not empty, ${syscall} '${path}'`; + break; + case "EEXIST": + message = `${code}: File exists, ${syscall} '${path}' -> '${target}'`; + break; + case "EINVAL": + message = `${code}: Invaid argument, ${syscall} '${path}'`; + break; + default: + message = `Unknown error with code "${code}", '${syscall}' on '${path}'`; + } + super(message); + this.name = "FilesystemError"; + this.code = code; + this.path = path; + this.syscall = syscall; + this.target = target; + } }; } }); -// ../../../node_modules/.pnpm/universal-github-app-jwt@1.1.2/node_modules/universal-github-app-jwt/dist-node/index.js -var require_dist_node19 = __commonJS({ - "../../../node_modules/.pnpm/universal-github-app-jwt@1.1.2/node_modules/universal-github-app-jwt/dist-node/index.js"(exports2) { - "use strict"; - Object.defineProperty(exports2, "__esModule", { value: true }); - function _interopDefault(ex) { - return ex && typeof ex === "object" && "default" in ex ? ex["default"] : ex; - } - var jsonwebtoken = _interopDefault(require_jsonwebtoken()); - async function getToken({ - privateKey, - payload - }) { - return jsonwebtoken.sign(payload, privateKey, { - algorithm: "RS256" - }); +// ../../../lix/packages/fs/dist/utilities/helpers.js +function assertIsAbsolutePath(path) { + if ((path.startsWith("/") || /^[A-Za-z]:[\\/]/.test(path)) === false) { + { + throw new Error(`Path is not absolute: ${path}. All paths should be absolute to avoid bugs.`); } - async function githubAppJwt({ - id, - privateKey, - now = Math.floor(Date.now() / 1e3) - }) { - const nowWithSafetyMargin = now - 30; - const expiration = nowWithSafetyMargin + 60 * 10; - const payload = { - iat: nowWithSafetyMargin, - exp: expiration, - iss: id - }; - const token = await getToken({ - privateKey, - payload - }); - return { - appId: id, - expiration, - token - }; + } +} +function normalizePath2(path, stripTrailing) { + if (path === "\\" || path === "/") + return "/"; + const len = path.length; + if (len <= 1) + return path; + let prefix = ""; + if (len > 4 && path[3] === "\\") { + const ch = path[2]; + if ((ch === "?" || ch === ".") && path.slice(0, 2) === "\\\\") { + path = path.slice(2); + prefix = "//"; } - exports2.githubAppJwt = githubAppJwt; } -}); - -// ../../../node_modules/.pnpm/lru-cache@10.2.0/node_modules/lru-cache/dist/commonjs/index.js -var require_commonjs = __commonJS({ - "../../../node_modules/.pnpm/lru-cache@10.2.0/node_modules/lru-cache/dist/commonjs/index.js"(exports2) { - "use strict"; - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.LRUCache = void 0; - var perf = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date; - var warned = /* @__PURE__ */ new Set(); - var PROCESS = typeof process === "object" && !!process ? process : {}; - var emitWarning = (msg, type, code, fn) => { - typeof PROCESS.emitWarning === "function" ? PROCESS.emitWarning(msg, type, code, fn) : console.error(`[${code}] ${type}: ${msg}`); - }; - var AC = globalThis.AbortController; - var AS = globalThis.AbortSignal; - if (typeof AC === "undefined") { - AS = class AbortSignal { - onabort; - _onabort = []; - reason; - aborted = false; - addEventListener(_, fn) { - this._onabort.push(fn); - } - }; - AC = class AbortController { - constructor() { - warnACPolyfill(); - } - signal = new AS(); - abort(reason) { - if (this.signal.aborted) - return; - this.signal.reason = reason; - this.signal.aborted = true; - for (const fn of this.signal._onabort) { - fn(reason); - } - this.signal.onabort?.(reason); - } - }; - let printACPolyfillWarning = PROCESS.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1"; - const warnACPolyfill = () => { - if (!printACPolyfillWarning) - return; - printACPolyfillWarning = false; - emitWarning("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", warnACPolyfill); - }; + const segs = path.split(/[/\\]+/); + const stack = []; + for (const seg of segs) { + if (seg === "..") { + stack.pop(); + } else if (seg !== ".") { + stack.push(seg); } - var shouldWarn = (code) => !warned.has(code); - var TYPE = Symbol("type"); - var isPosInt = (n) => n && n === Math.floor(n) && n > 0 && isFinite(n); - var getUintArray = (max) => !isPosInt(max) ? null : max <= Math.pow(2, 8) ? Uint8Array : max <= Math.pow(2, 16) ? Uint16Array : max <= Math.pow(2, 32) ? Uint32Array : max <= Number.MAX_SAFE_INTEGER ? ZeroArray : null; - var ZeroArray = class extends Array { - constructor(size) { - super(size); - this.fill(0); - } - }; - var Stack = class _Stack { - heap; - length; - // private constructor - static #constructing = false; - static create(max) { - const HeapCls = getUintArray(max); - if (!HeapCls) - return []; - _Stack.#constructing = true; - const s = new _Stack(max, HeapCls); - _Stack.#constructing = false; - return s; - } - constructor(max, HeapCls) { - if (!_Stack.#constructing) { - throw new TypeError("instantiate Stack using Stack.create(n)"); - } - this.heap = new HeapCls(max); - this.length = 0; - } - push(n) { - this.heap[this.length++] = n; - } - pop() { - return this.heap[--this.length]; - } - }; - var LRUCache = class _LRUCache { - // properties coming in from the options of these, only max and maxSize - // really *need* to be protected. The rest can be modified, as they just - // set defaults for various methods. - #max; - #maxSize; - #dispose; - #disposeAfter; - #fetchMethod; - /** - * {@link LRUCache.OptionsBase.ttl} - */ - ttl; - /** - * {@link LRUCache.OptionsBase.ttlResolution} - */ - ttlResolution; - /** - * {@link LRUCache.OptionsBase.ttlAutopurge} - */ - ttlAutopurge; - /** - * {@link LRUCache.OptionsBase.updateAgeOnGet} - */ - updateAgeOnGet; - /** - * {@link LRUCache.OptionsBase.updateAgeOnHas} - */ - updateAgeOnHas; - /** - * {@link LRUCache.OptionsBase.allowStale} - */ - allowStale; - /** - * {@link LRUCache.OptionsBase.noDisposeOnSet} - */ - noDisposeOnSet; - /** - * {@link LRUCache.OptionsBase.noUpdateTTL} - */ - noUpdateTTL; - /** - * {@link LRUCache.OptionsBase.maxEntrySize} - */ - maxEntrySize; - /** - * {@link LRUCache.OptionsBase.sizeCalculation} - */ - sizeCalculation; - /** - * {@link LRUCache.OptionsBase.noDeleteOnFetchRejection} - */ - noDeleteOnFetchRejection; - /** - * {@link LRUCache.OptionsBase.noDeleteOnStaleGet} - */ - noDeleteOnStaleGet; - /** - * {@link LRUCache.OptionsBase.allowStaleOnFetchAbort} - */ - allowStaleOnFetchAbort; - /** - * {@link LRUCache.OptionsBase.allowStaleOnFetchRejection} - */ - allowStaleOnFetchRejection; - /** - * {@link LRUCache.OptionsBase.ignoreFetchAbort} - */ - ignoreFetchAbort; - // computed properties - #size; - #calculatedSize; - #keyMap; - #keyList; - #valList; - #next; - #prev; - #head; - #tail; - #free; - #disposed; - #sizes; - #starts; - #ttls; - #hasDispose; - #hasFetchMethod; - #hasDisposeAfter; - /** - * Do not call this method unless you need to inspect the - * inner workings of the cache. If anything returned by this - * object is modified in any way, strange breakage may occur. - * - * These fields are private for a reason! - * - * @internal - */ - static unsafeExposeInternals(c) { - return { - // properties - starts: c.#starts, - ttls: c.#ttls, - sizes: c.#sizes, - keyMap: c.#keyMap, - keyList: c.#keyList, - valList: c.#valList, - next: c.#next, - prev: c.#prev, - get head() { - return c.#head; - }, - get tail() { - return c.#tail; - }, - free: c.#free, - // methods - isBackgroundFetch: (p) => c.#isBackgroundFetch(p), - backgroundFetch: (k, index2, options, context2) => c.#backgroundFetch(k, index2, options, context2), - moveToTail: (index2) => c.#moveToTail(index2), - indexes: (options) => c.#indexes(options), - rindexes: (options) => c.#rindexes(options), - isStale: (index2) => c.#isStale(index2) - }; - } - // Protected read-only members - /** - * {@link LRUCache.OptionsBase.max} (read-only) - */ - get max() { - return this.#max; + } + if (stripTrailing !== false && stack.at(-1) === "") { + stack.pop(); + } + return prefix + stack.join("/"); +} +function normalPath(path) { + const dots = /(\/|^)(\.\/)+/g; + const slashes = /\/+/g; + const upreference = /(? x).slice(0, -1).join("/") ?? path); +} +function getBasename(path) { + return path.split("/").filter((x) => x).at(-1) ?? path; +} +var init_helpers = __esm({ + "../../../lix/packages/fs/dist/utilities/helpers.js"() { + "use strict"; + } +}); + +// ../../../lix/packages/fs/dist/memoryFs.js +function toSnapshot(fs2) { + return { + fsMap: Object.fromEntries([...fs2._state.fsMap].map(([path, content]) => { + let serializedContent; + if (content instanceof Set) { + serializedContent = [...content].sort(); + } else if (content.placeholder) { + serializedContent = content; + } else { + serializedContent = content.toString("base64"); } - /** - * {@link LRUCache.OptionsBase.maxSize} (read-only) - */ - get maxSize() { - return this.#maxSize; + return [ + path, + // requires node buffers, but no web standard method exists + serializedContent + // Alternative to try: + // onst binaryData = new Uint8Array([255, 116, 79, 99 /*...*/]); + // const base64Encoded = btoa(String.fromCharCode.apply(null, binaryData)); + // // Decode Base64 back to binary + // const decodedBinaryString = atob(base64Encoded); + // const decodedBinaryData = new Uint8Array([...decodedBinaryString].map(char => char.charCodeAt(0))); + // this breaks packfile binary data but could be fixed in future btoa(unescape(encodeURIComponent(new TextDecoder().decode(content)))), + ]; + })), + fsStats: Object.fromEntries([...fs2._state.fsStats].map(([path, fsStat]) => { + return [ + path, + { + ...fsStat, + ino: void 0, + isFile: void 0, + isDirectory: void 0, + isSymbolicLink: void 0 + } + ]; + })) + }; +} +function fromSnapshot(fs2, snapshot, { pathPrefix = "" } = {}) { + fs2._state.lastIno = 1; + fs2._state.fsMap = new Map( + // @ts-ignore FIXME: no idea what ts wants me to do here the error message is ridiculous + Object.entries(snapshot.fsMap).map(([path, content]) => { + if (typeof content === "string") { + const data = Buffer.from(content, "base64"); + return [pathPrefix + path, data]; + } else if (content?.placeholder) { + return [pathPrefix + path, content]; } - /** - * The total computed size of items in the cache (read-only) - */ - get calculatedSize() { - return this.#calculatedSize; + return [pathPrefix + path, new Set(content)]; + }) + ); + fs2._state.fsStats = new Map(Object.entries(snapshot.fsStats).map(([path, rawStat]) => { + const serializedStat = rawStat; + const statsObj = { + ...serializedStat, + ino: fs2._state.lastIno++, + isFile: () => serializedStat._kind === 0, + isDirectory: () => serializedStat._kind === 1, + isSymbolicLink: () => serializedStat._kind === 2 + }; + return [pathPrefix + path, statsObj]; + })); + if (pathPrefix) { + const prefixParts = pathPrefix.split("/"); + const rootStat = fs2._state.fsStats.get(pathPrefix + "/"); + for (let i = 1; i < prefixParts.length; i++) { + const path = prefixParts.slice(0, i).join("/") + "/"; + fs2._state.fsMap.set(path, /* @__PURE__ */ new Set([prefixParts[i]])); + fs2._state.fsStats.set(path, rootStat); + } + } +} +function createNodeishMemoryFs() { + const state = { + lastIno: 1, + fsMap: /* @__PURE__ */ new Map(), + fsStats: /* @__PURE__ */ new Map() + }; + state.fsMap.set("/", /* @__PURE__ */ new Set()); + newStatEntry("/", state.fsStats, 1, 493); + const listeners = /* @__PURE__ */ new Set(); + async function stat(path) { + path = normalPath(path); + const stats = state.fsStats.get(path); + if (stats === void 0) + throw new FilesystemError("ENOENT", path, "stat"); + if (stats.symlinkTarget) + return stat(stats.symlinkTarget); + return Object.assign({}, stats); + } + async function lstat(path) { + path = normalPath(path); + const stats = state.fsStats.get(path); + if (stats === void 0) + throw new FilesystemError("ENOENT", path, "lstat"); + if (!stats.symlinkTarget) + return stat(path); + return Object.assign({}, stats); + } + return { + _state: state, + _createPlaceholder: async function(path, options) { + path = normalPath(path); + const dirName = getDirname(path); + const baseName = getBasename(path); + let parentDir = state.fsMap.get(dirName); + if (!(parentDir instanceof Set)) { + await this.mkdir(dirName, { recursive: true }); + parentDir = state.fsMap.get(dirName); + if (!(parentDir instanceof Set)) { + throw new FilesystemError("ENOENT", path, "writeFile"); + } } - /** - * The number of items stored in the cache (read-only) - */ - get size() { - return this.#size; + parentDir.add(baseName); + const isSymbolicLink = options?.mode === 12e4; + newStatEntry(path, state.fsStats, isSymbolicLink ? 2 : 0, options?.mode ?? 420); + state.fsMap.set(path, { placeholder: true }); + }, + _isPlaceholder: function(path) { + path = normalPath(path); + const entry = state.fsMap.get(path); + if (entry && "placeholder" in entry) { + return true; } - /** - * {@link LRUCache.OptionsBase.fetchMethod} (read-only) - */ - get fetchMethod() { - return this.#fetchMethod; + return false; + }, + writeFile: async function(path, data, options) { + path = normalPath(path); + const dirName = getDirname(path); + const baseName = getBasename(path); + const parentDir = state.fsMap.get(dirName); + if (!(parentDir instanceof Set)) + throw new FilesystemError("ENOENT", path, "writeFile"); + if (typeof data === "string") { + data = Buffer.from(new TextEncoder().encode(data)); + } else if (!(data instanceof Uint8Array)) { + throw new FilesystemError('The "data" argument must be of type string/Uint8Array', data, "readFile"); + } else if (!Buffer.isBuffer(data)) { + data = Buffer.from(data); } - /** - * {@link LRUCache.OptionsBase.dispose} (read-only) - */ - get dispose() { - return this.#dispose; + parentDir.add(baseName); + newStatEntry(path, state.fsStats, 0, options?.mode ?? 420); + state.fsMap.set(path, data); + for (const listener of listeners) { + listener({ eventType: "rename", filename: dirName + baseName }); } - /** - * {@link LRUCache.OptionsBase.disposeAfter} (read-only) - */ - get disposeAfter() { - return this.#disposeAfter; + }, + // @ts-expect-error + // Typescript can't derive that the return type is either + // a string or a Uint8Array based on the options. + readFile: async function(path, options) { + const decoder = new TextDecoder(); + path = normalPath(path); + const file = state.fsMap.get(path); + if (file instanceof Set) + throw new FilesystemError("EISDIR", path, "readFile"); + if (file === void 0) + throw new FilesystemError("ENOENT", path, "readFile"); + if ("placeholder" in file) + throw new FilesystemError("EPLACEHOLDER", path, "readFile"); + if (!(options?.encoding || typeof options === "string")) + return file; + return decoder.decode(file); + }, + readdir: async function(path) { + path = normalPath(path); + const dir = state.fsMap.get(path); + if (dir instanceof Set) + return [...dir.keys()]; + if (dir === void 0) + throw new FilesystemError("ENOENT", path, "readdir"); + throw new FilesystemError("ENOTDIR", path, "readdir"); + }, + mkdir: async function mkdir(path, options) { + path = normalPath(path); + const dirName = getDirname(path); + const baseName = getBasename(path); + const parentDir = state.fsMap.get(dirName); + if (typeof parentDir === "string" || parentDir && "palceholder" in parentDir) { + throw new FilesystemError("ENOTDIR", path, "mkdir"); } - constructor(options) { - const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort } = options; - if (max !== 0 && !isPosInt(max)) { - throw new TypeError("max option must be a nonnegative integer"); - } - const UintArray = max ? getUintArray(max) : Array; - if (!UintArray) { - throw new Error("invalid max value: " + max); - } - this.#max = max; - this.#maxSize = maxSize; - this.maxEntrySize = maxEntrySize || this.#maxSize; - this.sizeCalculation = sizeCalculation; - if (this.sizeCalculation) { - if (!this.#maxSize && !this.maxEntrySize) { - throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize"); - } - if (typeof this.sizeCalculation !== "function") { - throw new TypeError("sizeCalculation set to non-function"); - } - } - if (fetchMethod !== void 0 && typeof fetchMethod !== "function") { - throw new TypeError("fetchMethod must be a function if specified"); - } - this.#fetchMethod = fetchMethod; - this.#hasFetchMethod = !!fetchMethod; - this.#keyMap = /* @__PURE__ */ new Map(); - this.#keyList = new Array(max).fill(void 0); - this.#valList = new Array(max).fill(void 0); - this.#next = new UintArray(max); - this.#prev = new UintArray(max); - this.#head = 0; - this.#tail = 0; - this.#free = Stack.create(max); - this.#size = 0; - this.#calculatedSize = 0; - if (typeof dispose === "function") { - this.#dispose = dispose; - } - if (typeof disposeAfter === "function") { - this.#disposeAfter = disposeAfter; - this.#disposed = []; - } else { - this.#disposeAfter = void 0; - this.#disposed = void 0; - } - this.#hasDispose = !!this.#dispose; - this.#hasDisposeAfter = !!this.#disposeAfter; - this.noDisposeOnSet = !!noDisposeOnSet; - this.noUpdateTTL = !!noUpdateTTL; - this.noDeleteOnFetchRejection = !!noDeleteOnFetchRejection; - this.allowStaleOnFetchRejection = !!allowStaleOnFetchRejection; - this.allowStaleOnFetchAbort = !!allowStaleOnFetchAbort; - this.ignoreFetchAbort = !!ignoreFetchAbort; - if (this.maxEntrySize !== 0) { - if (this.#maxSize !== 0) { - if (!isPosInt(this.#maxSize)) { - throw new TypeError("maxSize must be a positive integer if specified"); - } - } - if (!isPosInt(this.maxEntrySize)) { - throw new TypeError("maxEntrySize must be a positive integer if specified"); - } - this.#initializeSizeTracking(); - } - this.allowStale = !!allowStale; - this.noDeleteOnStaleGet = !!noDeleteOnStaleGet; - this.updateAgeOnGet = !!updateAgeOnGet; - this.updateAgeOnHas = !!updateAgeOnHas; - this.ttlResolution = isPosInt(ttlResolution) || ttlResolution === 0 ? ttlResolution : 1; - this.ttlAutopurge = !!ttlAutopurge; - this.ttl = ttl || 0; - if (this.ttl) { - if (!isPosInt(this.ttl)) { - throw new TypeError("ttl must be a positive integer if specified"); + if (parentDir && parentDir instanceof Set) { + if (state.fsMap.has(path)) { + if (!options?.recursive) { + throw new FilesystemError("EEXIST", path, "mkdir"); + } else { + return void 0; } - this.#initializeTTLTracking(); } - if (this.#max === 0 && this.ttl === 0 && this.#maxSize === 0) { - throw new TypeError("At least one of max, maxSize, or ttl is required"); + parentDir.add(baseName); + newStatEntry(path, state.fsStats, 1, 493); + state.fsMap.set(path, /* @__PURE__ */ new Set()); + for (const listener of listeners) { + listener({ eventType: "rename", filename: dirName + baseName }); } - if (!this.ttlAutopurge && !this.#max && !this.#maxSize) { - const code = "LRU_CACHE_UNBOUNDED"; - if (shouldWarn(code)) { - warned.add(code); - const msg = "TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption."; - emitWarning(msg, "UnboundedCacheWarning", code, _LRUCache); - } + return path; + } else if (options?.recursive) { + const parent = getDirname(path); + const parentRes = await mkdir(parent, options); + await mkdir(path, options); + return parentRes; + } + throw new FilesystemError("ENOENT", path, "mkdir"); + }, + rm: async function rm(path, options) { + path = normalPath(path); + const dirName = getDirname(path); + const baseName = getBasename(path); + const target = state.fsMap.get(path); + const parentDir = state.fsMap.get(dirName); + if (parentDir === void 0 || target === void 0) + throw new FilesystemError("ENOENT", path, "rm"); + if (parentDir instanceof Uint8Array || "placeholder" in parentDir) { + throw new FilesystemError("ENOTDIR", path, "rm"); + } + if (target instanceof Uint8Array || "placeholder" in target) { + parentDir.delete(baseName); + state.fsStats.delete(path); + state.fsMap.delete(path); + for (const listener of listeners) { + listener({ eventType: "rename", filename: dirName + baseName }); } + return; } - /** - * Return the remaining TTL time for a given entry key - */ - getRemainingTTL(key) { - return this.#keyMap.has(key) ? Infinity : 0; + if (target instanceof Set && options?.recursive) { + await Promise.all([...target.keys()].map(async (child) => { + await rm(`${path}/${child}`, { recursive: true }); + })); + parentDir.delete(baseName); + state.fsStats.delete(path); + state.fsMap.delete(path); + for (const listener of listeners) { + listener({ eventType: "rename", filename: dirName + baseName }); + } + return; } - #initializeTTLTracking() { - const ttls = new ZeroArray(this.#max); - const starts = new ZeroArray(this.#max); - this.#ttls = ttls; - this.#starts = starts; - this.#setItemTTL = (index2, ttl, start = perf.now()) => { - starts[index2] = ttl !== 0 ? start : 0; - ttls[index2] = ttl; - if (ttl !== 0 && this.ttlAutopurge) { - const t = setTimeout(() => { - if (this.#isStale(index2)) { - this.delete(this.#keyList[index2]); - } - }, ttl + 1); - if (t.unref) { - t.unref(); - } - } - }; - this.#updateItemAge = (index2) => { - starts[index2] = ttls[index2] !== 0 ? perf.now() : 0; - }; - this.#statusTTL = (status2, index2) => { - if (ttls[index2]) { - const ttl = ttls[index2]; - const start = starts[index2]; - if (!ttl || !start) - return; - status2.ttl = ttl; - status2.start = start; - status2.now = cachedNow || getNow(); - const age = status2.now - start; - status2.remainingTTL = ttl - age; - } - }; - let cachedNow = 0; - const getNow = () => { - const n = perf.now(); - if (this.ttlResolution > 0) { - cachedNow = n; - const t = setTimeout(() => cachedNow = 0, this.ttlResolution); - if (t.unref) { - t.unref(); - } - } - return n; - }; - this.getRemainingTTL = (key) => { - const index2 = this.#keyMap.get(key); - if (index2 === void 0) { - return 0; - } - const ttl = ttls[index2]; - const start = starts[index2]; - if (!ttl || !start) { - return Infinity; - } - const age = (cachedNow || getNow()) - start; - return ttl - age; - }; - this.#isStale = (index2) => { - const s = starts[index2]; - const t = ttls[index2]; - return !!t && !!s && (cachedNow || getNow()) - s > t; - }; + throw new FilesystemError("EISDIR", path, "rm"); + }, + /** + * + * @throws {"ENOENT" | WatchAbortedError} // TODO: move to lix error classes FileDoesNotExistError + */ + watch: function(path, options) { + path = normalPath(path); + const watchName = getBasename(path); + const watchDir = getDirname(path); + const watchPath = watchName === "/" ? watchDir : watchDir + watchName; + if (options?.persistent || options?.encoding) { + throw new Error("Some watch opptions not implemented, only 'recursive' allowed"); } - // conditionally set private methods related to TTL - #updateItemAge = () => { - }; - #statusTTL = () => { - }; - #setItemTTL = () => { - }; - /* c8 ignore stop */ - #isStale = () => false; - #initializeSizeTracking() { - const sizes = new ZeroArray(this.#max); - this.#calculatedSize = 0; - this.#sizes = sizes; - this.#removeItemSize = (index2) => { - this.#calculatedSize -= sizes[index2]; - sizes[index2] = 0; - }; - this.#requireSize = (k, v, size, sizeCalculation) => { - if (this.#isBackgroundFetch(v)) { - return 0; - } - if (!isPosInt(size)) { - if (sizeCalculation) { - if (typeof sizeCalculation !== "function") { - throw new TypeError("sizeCalculation must be a function"); - } - size = sizeCalculation(v, k); - if (!isPosInt(size)) { - throw new TypeError("sizeCalculation return invalid (expect positive integer)"); - } - } else { - throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set."); - } - } - return size; - }; - this.#addItemSize = (index2, size, status2) => { - sizes[index2] = size; - if (this.#maxSize) { - const maxSize = this.#maxSize - sizes[index2]; - while (this.#calculatedSize > maxSize) { - this.#evict(true); - } - } - this.#calculatedSize += sizes[index2]; - if (status2) { - status2.entrySize = size; - status2.totalCalculatedSize = this.#calculatedSize; - } + const queue = []; + let handleNext; + let rejecteNext; + let changeEvent = new Promise((resolve, reject) => { + handleNext = resolve; + rejecteNext = reject; + }); + const listener = ({ eventType, filename }) => { + const event = { + eventType, + filename }; - } - #removeItemSize = (_i) => { - }; - #addItemSize = (_i, _s, _st) => { - }; - #requireSize = (_k, _v, size, sizeCalculation) => { - if (size || sizeCalculation) { - throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache"); + if (event.filename === null) { + throw new Error("Internal watcher error: missing filename"); + } + const changeName = getBasename(event.filename); + const changeDir = getDirname(event.filename); + if (event.filename === watchPath) { + event.filename = changeName; + queue.push(event); + setTimeout(() => handleNext(void 0), 0); + } else if (changeDir === `${watchPath}/`) { + event.filename = event.filename.replace(`${watchPath}/`, "") || changeName; + queue.push(event); + setTimeout(() => handleNext(void 0), 0); + } else if (options?.recursive && event.filename.startsWith(watchPath)) { + event.filename = event.filename.replace(`${watchPath}/`, "") || changeName; + queue.push(event); + setTimeout(() => handleNext(void 0), 0); } - return 0; }; - *#indexes({ allowStale = this.allowStale } = {}) { - if (this.#size) { - for (let i = this.#tail; true; ) { - if (!this.#isValidIndex(i)) { - break; - } - if (allowStale || !this.#isStale(i)) { - yield i; - } - if (i === this.#head) { - break; - } else { - i = this.#prev[i]; - } - } - } - } - *#rindexes({ allowStale = this.allowStale } = {}) { - if (this.#size) { - for (let i = this.#head; true; ) { - if (!this.#isValidIndex(i)) { - break; - } - if (allowStale || !this.#isStale(i)) { - yield i; - } - if (i === this.#tail) { - break; - } else { - i = this.#next[i]; - } + listeners.add(listener); + if (options?.signal) { + options.signal.addEventListener("abort", () => { + listeners.delete(listener); + try { + options.signal?.throwIfAborted(); + } catch (err) { + rejecteNext(err); } - } - } - #isValidIndex(index2) { - return index2 !== void 0 && this.#keyMap.get(this.#keyList[index2]) === index2; + }, { once: true }); } - /** - * Return a generator yielding `[key, value]` pairs, - * in order from most recently used to least recently used. - */ - *entries() { - for (const i of this.#indexes()) { - if (this.#valList[i] !== void 0 && this.#keyList[i] !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) { - yield [this.#keyList[i], this.#valList[i]]; + const asyncIterator = async function* () { + while (!options?.signal?.aborted) { + if (queue.length > 0) { + yield queue.shift(); + } else { + await changeEvent; + changeEvent = new Promise((resolve, reject) => { + handleNext = resolve; + rejecteNext = reject; + }); } } + }; + return asyncIterator(); + }, + rmdir: async function(path) { + path = normalPath(path); + const dirName = getDirname(path); + const baseName = getBasename(path); + const target = state.fsMap.get(path); + const parentDir = state.fsMap.get(dirName); + if (parentDir === void 0 || target === void 0) + throw new FilesystemError("ENOENT", path, "rmdir"); + if (parentDir instanceof Uint8Array || target instanceof Uint8Array) + throw new FilesystemError("ENOTDIR", path, "rmdir"); + if ("placeholder" in parentDir || "placeholder" in target) { + throw new FilesystemError("ENOTDIR", path, "rmdir"); } - /** - * Inverse order version of {@link LRUCache.entries} - * - * Return a generator yielding `[key, value]` pairs, - * in order from least recently used to most recently used. - */ - *rentries() { - for (const i of this.#rindexes()) { - if (this.#valList[i] !== void 0 && this.#keyList[i] !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) { - yield [this.#keyList[i], this.#valList[i]]; - } - } + if (target.size) + throw new FilesystemError("ENOTEMPTY", path, "rmdir"); + parentDir.delete(baseName); + state.fsStats.delete(path); + state.fsMap.delete(path); + for (const listener of listeners) { + listener({ eventType: "rename", filename: dirName + baseName }); } - /** - * Return a generator yielding the keys in the cache, - * in order from most recently used to least recently used. - */ - *keys() { - for (const i of this.#indexes()) { - const k = this.#keyList[i]; - if (k !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) { - yield k; - } - } + }, + symlink: async function(target, path) { + path = normalPath(path); + target = target.startsWith("/") ? target : `${path}/../${target}`; + const targetInode = state.fsMap.get(normalPath(target)); + const parentDir = state.fsMap.get(getDirname(path)); + if (state.fsMap.get(path)) { + throw new FilesystemError("EEXIST", path, "symlink", target); } - /** - * Inverse order version of {@link LRUCache.keys} - * - * Return a generator yielding the keys in the cache, - * in order from least recently used to most recently used. - */ - *rkeys() { - for (const i of this.#rindexes()) { - const k = this.#keyList[i]; - if (k !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) { - yield k; - } - } + if (parentDir === void 0) { + throw new FilesystemError("ENOENT", path, "symlink", target); } - /** - * Return a generator yielding the values in the cache, - * in order from most recently used to least recently used. - */ - *values() { - for (const i of this.#indexes()) { - const v = this.#valList[i]; - if (v !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) { - yield this.#valList[i]; - } - } + if (parentDir instanceof Uint8Array || "placeholder" in parentDir) { + throw new FilesystemError("ENOTDIR", path, "symlink", target); } - /** - * Inverse order version of {@link LRUCache.values} - * - * Return a generator yielding the values in the cache, - * in order from least recently used to most recently used. - */ - *rvalues() { - for (const i of this.#rindexes()) { - const v = this.#valList[i]; - if (v !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) { - yield this.#valList[i]; - } - } + if (targetInode !== void 0) { + state.fsMap.set(path, targetInode); } - /** - * Iterating over the cache itself yields the same results as - * {@link LRUCache.entries} - */ - [Symbol.iterator]() { - return this.entries(); + parentDir.add(getBasename(path)); + newStatEntry(path, state.fsStats, 2, 511, target); + }, + unlink: async function(path) { + path = normalPath(path); + const targetStats = state.fsStats.get(path); + const target = state.fsMap.get(path); + const parentDir = state.fsMap.get(getDirname(path)); + if (parentDir === void 0 || target === void 0) + throw new FilesystemError("ENOENT", path, "unlink"); + if (parentDir instanceof Uint8Array || "placeholder" in parentDir) { + throw new FilesystemError("ENOTDIR", path, "unlink"); } - /** - * A String value that is used in the creation of the default string description of an object. - * Called by the built-in method Object.prototype.toString. - */ - [Symbol.toStringTag] = "LRUCache"; - /** - * Find a value for which the supplied fn method returns a truthy value, - * similar to Array.find(). fn is called as fn(value, key, cache). - */ - find(fn, getOptions = {}) { - for (const i of this.#indexes()) { - const v = this.#valList[i]; - const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v; - if (value === void 0) - continue; - if (fn(value, this.#keyList[i], this)) { - return this.get(this.#keyList[i], getOptions); - } - } + if (targetStats?.isDirectory()) { + throw new FilesystemError("EISDIR", path, "unlink"); } - /** - * Call the supplied function on each item in the cache, in order from - * most recently used to least recently used. fn is called as - * fn(value, key, cache). Does not update age or recenty of use. - * Does not iterate over stale values. - */ - forEach(fn, thisp = this) { - for (const i of this.#indexes()) { - const v = this.#valList[i]; - const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v; - if (value === void 0) - continue; - fn.call(thisp, value, this.#keyList[i], this); - } + parentDir.delete(getBasename(path)); + state.fsStats.delete(path); + state.fsMap.delete(path); + }, + readlink: async function(path) { + path = normalPath(path); + const linkStats = await lstat(path); + if (linkStats === void 0) { + throw new FilesystemError("ENOENT", path, "readlink"); } - /** - * The same as {@link LRUCache.forEach} but items are iterated over in - * reverse order. (ie, less recently used items are iterated over first.) - */ - rforEach(fn, thisp = this) { - for (const i of this.#rindexes()) { - const v = this.#valList[i]; - const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v; - if (value === void 0) - continue; - fn.call(thisp, value, this.#keyList[i], this); - } + if (linkStats.symlinkTarget === void 0) { + throw new FilesystemError("EINVAL", path, "readlink"); } - /** - * Delete any stale entries. Returns true if anything was removed, - * false otherwise. - */ - purgeStale() { - let deleted = false; - for (const i of this.#rindexes({ allowStale: true })) { - if (this.#isStale(i)) { - this.delete(this.#keyList[i]); - deleted = true; - } - } - return deleted; + return linkStats.symlinkTarget; + }, + stat, + lstat + }; + function newStatEntry(path, stats, kind, modeBits, target) { + const currentTime = Date.now(); + const _kind = kind; + const oldStats = stats.get(normalPath(path)); + const mtimeMs = Math.floor(currentTime / 1e3) === (oldStats?.mtimeMs && Math.floor(oldStats?.mtimeMs / 1e3)) ? currentTime + 1e3 : currentTime; + stats.set(normalPath(path), { + ctimeMs: oldStats?.ctimeMs || currentTime, + mtimeMs, + dev: 0, + ino: oldStats?.ino || state.lastIno++, + mode: (!kind ? 32768 : kind === 1 ? 16384 : 40960) | modeBits, + uid: 0, + gid: 0, + size: -1, + isFile: () => kind === 0, + isDirectory: () => kind === 1, + isSymbolicLink: () => kind === 2, + // symlinkTarget is only for symlinks, and is not normalized + symlinkTarget: target, + _kind + }); + } +} +var init_memoryFs = __esm({ + "../../../lix/packages/fs/dist/memoryFs.js"() { + "use strict"; + init_FilesystemError(); + init_helpers(); + } +}); + +// ../../../lix/packages/fs/dist/index.js +var dist_exports = {}; +__export(dist_exports, { + assertIsAbsolutePath: () => assertIsAbsolutePath, + createNodeishMemoryFs: () => createNodeishMemoryFs, + fromSnapshot: () => fromSnapshot, + getBasename: () => getBasename, + getDirname: () => getDirname, + normalPath: () => normalPath, + normalizePath: () => normalizePath2, + toSnapshot: () => toSnapshot +}); +var init_dist = __esm({ + "../../../lix/packages/fs/dist/index.js"() { + "use strict"; + init_memoryFs(); + init_helpers(); + } +}); + +// ../../../node_modules/.pnpm/@octokit+plugin-paginate-graphql@4.0.1_@octokit+core@5.2.0/node_modules/@octokit/plugin-paginate-graphql/dist-node/index.js +var require_dist_node11 = __commonJS({ + "../../../node_modules/.pnpm/@octokit+plugin-paginate-graphql@4.0.1_@octokit+core@5.2.0/node_modules/@octokit/plugin-paginate-graphql/dist-node/index.js"(exports2, module2) { + "use strict"; + var __defProp2 = Object.defineProperty; + var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; + var __getOwnPropNames2 = Object.getOwnPropertyNames; + var __hasOwnProp2 = Object.prototype.hasOwnProperty; + var __export2 = (target, all) => { + for (var name in all) + __defProp2(target, name, { get: all[name], enumerable: true }); + }; + var __copyProps2 = (to, from2, except, desc) => { + if (from2 && typeof from2 === "object" || typeof from2 === "function") { + for (let key of __getOwnPropNames2(from2)) + if (!__hasOwnProp2.call(to, key) && key !== except) + __defProp2(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc2(from2, key)) || desc.enumerable }); } - /** - * Get the extended info about a given entry, to get its value, size, and - * TTL info simultaneously. Like {@link LRUCache#dump}, but just for a - * single key. Always returns stale values, if their info is found in the - * cache, so be sure to check for expired TTLs if relevant. - */ - info(key) { - const i = this.#keyMap.get(key); - if (i === void 0) - return void 0; - const v = this.#valList[i]; - const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v; - if (value === void 0) - return void 0; - const entry = { value }; - if (this.#ttls && this.#starts) { - const ttl = this.#ttls[i]; - const start = this.#starts[i]; - if (ttl && start) { - const remain = ttl - (perf.now() - start); - entry.ttl = remain; - entry.start = Date.now(); - } - } - if (this.#sizes) { - entry.size = this.#sizes[i]; + return to; + }; + var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); + var dist_src_exports = {}; + __export2(dist_src_exports, { + paginateGraphql: () => paginateGraphql + }); + module2.exports = __toCommonJS2(dist_src_exports); + var generateMessage = (path, cursorValue) => `The cursor at "${path.join( + "," + )}" did not change its value "${cursorValue}" after a page transition. Please make sure your that your query is set up correctly.`; + var MissingCursorChange = class extends Error { + constructor(pageInfo, cursorValue) { + super(generateMessage(pageInfo.pathInQuery, cursorValue)); + this.pageInfo = pageInfo; + this.cursorValue = cursorValue; + this.name = "MissingCursorChangeError"; + if (Error.captureStackTrace) { + Error.captureStackTrace(this, this.constructor); } - return entry; } - /** - * Return an array of [key, {@link LRUCache.Entry}] tuples which can be - * passed to cache.load() - */ - dump() { - const arr = []; - for (const i of this.#indexes({ allowStale: true })) { - const key = this.#keyList[i]; - const v = this.#valList[i]; - const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v; - if (value === void 0 || key === void 0) - continue; - const entry = { value }; - if (this.#ttls && this.#starts) { - entry.ttl = this.#ttls[i]; - const age = perf.now() - this.#starts[i]; - entry.start = Math.floor(Date.now() - age); - } - if (this.#sizes) { - entry.size = this.#sizes[i]; - } - arr.unshift([key, entry]); + }; + var MissingPageInfo = class extends Error { + constructor(response) { + super( + `No pageInfo property found in response. Please make sure to specify the pageInfo in your query. Response-Data: ${JSON.stringify( + response, + null, + 2 + )}` + ); + this.response = response; + this.name = "MissingPageInfo"; + if (Error.captureStackTrace) { + Error.captureStackTrace(this, this.constructor); } - return arr; } - /** - * Reset the cache and load in the items in entries in the order listed. - * Note that the shape of the resulting cache may be different if the - * same options are not used in both caches. - */ - load(arr) { - this.clear(); - for (const [key, entry] of arr) { - if (entry.start) { - const age = Date.now() - entry.start; - entry.start = perf.now() - age; - } - this.set(key, entry.value, entry); - } + }; + var isObject2 = (value) => Object.prototype.toString.call(value) === "[object Object]"; + function findPaginatedResourcePath(responseData) { + const paginatedResourcePath = deepFindPathToProperty( + responseData, + "pageInfo" + ); + if (paginatedResourcePath.length === 0) { + throw new MissingPageInfo(responseData); } - /** - * Add a value to the cache. - * - * Note: if `undefined` is specified as a value, this is an alias for - * {@link LRUCache#delete} - */ - set(k, v, setOptions = {}) { - if (v === void 0) { - this.delete(k); - return this; - } - const { ttl = this.ttl, start, noDisposeOnSet = this.noDisposeOnSet, sizeCalculation = this.sizeCalculation, status: status2 } = setOptions; - let { noUpdateTTL = this.noUpdateTTL } = setOptions; - const size = this.#requireSize(k, v, setOptions.size || 0, sizeCalculation); - if (this.maxEntrySize && size > this.maxEntrySize) { - if (status2) { - status2.set = "miss"; - status2.maxEntrySizeExceeded = true; - } - this.delete(k); - return this; - } - let index2 = this.#size === 0 ? void 0 : this.#keyMap.get(k); - if (index2 === void 0) { - index2 = this.#size === 0 ? this.#tail : this.#free.length !== 0 ? this.#free.pop() : this.#size === this.#max ? this.#evict(false) : this.#size; - this.#keyList[index2] = k; - this.#valList[index2] = v; - this.#keyMap.set(k, index2); - this.#next[this.#tail] = index2; - this.#prev[index2] = this.#tail; - this.#tail = index2; - this.#size++; - this.#addItemSize(index2, size, status2); - if (status2) - status2.set = "add"; - noUpdateTTL = false; - } else { - this.#moveToTail(index2); - const oldVal = this.#valList[index2]; - if (v !== oldVal) { - if (this.#hasFetchMethod && this.#isBackgroundFetch(oldVal)) { - oldVal.__abortController.abort(new Error("replaced")); - const { __staleWhileFetching: s } = oldVal; - if (s !== void 0 && !noDisposeOnSet) { - if (this.#hasDispose) { - this.#dispose?.(s, k, "set"); - } - if (this.#hasDisposeAfter) { - this.#disposed?.push([s, k, "set"]); - } - } - } else if (!noDisposeOnSet) { - if (this.#hasDispose) { - this.#dispose?.(oldVal, k, "set"); - } - if (this.#hasDisposeAfter) { - this.#disposed?.push([oldVal, k, "set"]); - } - } - this.#removeItemSize(index2); - this.#addItemSize(index2, size, status2); - this.#valList[index2] = v; - if (status2) { - status2.set = "replace"; - const oldValue = oldVal && this.#isBackgroundFetch(oldVal) ? oldVal.__staleWhileFetching : oldVal; - if (oldValue !== void 0) - status2.oldValue = oldValue; - } - } else if (status2) { - status2.set = "update"; - } - } - if (ttl !== 0 && !this.#ttls) { - this.#initializeTTLTracking(); - } - if (this.#ttls) { - if (!noUpdateTTL) { - this.#setItemTTL(index2, ttl, start); - } - if (status2) - this.#statusTTL(status2, index2); + return paginatedResourcePath; + } + var deepFindPathToProperty = (object, searchProp, path = []) => { + for (const key of Object.keys(object)) { + const currentPath = [...path, key]; + const currentValue = object[key]; + if (currentValue.hasOwnProperty(searchProp)) { + return currentPath; } - if (!noDisposeOnSet && this.#hasDisposeAfter && this.#disposed) { - const dt = this.#disposed; - let task; - while (task = dt?.shift()) { - this.#disposeAfter?.(...task); + if (isObject2(currentValue)) { + const result = deepFindPathToProperty( + currentValue, + searchProp, + currentPath + ); + if (result.length > 0) { + return result; } } - return this; } - /** - * Evict the least recently used item, returning its value or - * `undefined` if cache is empty. - */ - pop() { - try { - while (this.#size) { - const val = this.#valList[this.#head]; - this.#evict(true); - if (this.#isBackgroundFetch(val)) { - if (val.__staleWhileFetching) { - return val.__staleWhileFetching; + return []; + }; + var get = (object, path) => { + return path.reduce((current, nextProperty) => current[nextProperty], object); + }; + var set = (object, path, mutator) => { + const lastProperty = path[path.length - 1]; + const parentPath = [...path].slice(0, -1); + const parent = get(object, parentPath); + if (typeof mutator === "function") { + parent[lastProperty] = mutator(parent[lastProperty]); + } else { + parent[lastProperty] = mutator; + } + }; + var extractPageInfos = (responseData) => { + const pageInfoPath = findPaginatedResourcePath(responseData); + return { + pathInQuery: pageInfoPath, + pageInfo: get(responseData, [...pageInfoPath, "pageInfo"]) + }; + }; + var isForwardSearch = (givenPageInfo) => { + return givenPageInfo.hasOwnProperty("hasNextPage"); + }; + var getCursorFrom = (pageInfo) => isForwardSearch(pageInfo) ? pageInfo.endCursor : pageInfo.startCursor; + var hasAnotherPage = (pageInfo) => isForwardSearch(pageInfo) ? pageInfo.hasNextPage : pageInfo.hasPreviousPage; + var createIterator = (octokit) => { + return (query, initialParameters = {}) => { + let nextPageExists = true; + let parameters = { ...initialParameters }; + return { + [Symbol.asyncIterator]: () => ({ + async next() { + if (!nextPageExists) + return { done: true, value: {} }; + const response = await octokit.graphql( + query, + parameters + ); + const pageInfoContext = extractPageInfos(response); + const nextCursorValue = getCursorFrom(pageInfoContext.pageInfo); + nextPageExists = hasAnotherPage(pageInfoContext.pageInfo); + if (nextPageExists && nextCursorValue === parameters.cursor) { + throw new MissingCursorChange(pageInfoContext, nextCursorValue); } - } else if (val !== void 0) { - return val; - } - } - } finally { - if (this.#hasDisposeAfter && this.#disposed) { - const dt = this.#disposed; - let task; - while (task = dt?.shift()) { - this.#disposeAfter?.(...task); + parameters = { + ...parameters, + cursor: nextCursorValue + }; + return { done: false, value: response }; } - } - } + }) + }; + }; + }; + var mergeResponses = (response1, response2) => { + if (Object.keys(response1).length === 0) { + return Object.assign(response1, response2); } - #evict(free) { - const head = this.#head; - const k = this.#keyList[head]; - const v = this.#valList[head]; - if (this.#hasFetchMethod && this.#isBackgroundFetch(v)) { - v.__abortController.abort(new Error("evicted")); - } else if (this.#hasDispose || this.#hasDisposeAfter) { - if (this.#hasDispose) { - this.#dispose?.(v, k, "evict"); - } - if (this.#hasDisposeAfter) { - this.#disposed?.push([v, k, "evict"]); - } - } - this.#removeItemSize(head); - if (free) { - this.#keyList[head] = void 0; - this.#valList[head] = void 0; - this.#free.push(head); - } - if (this.#size === 1) { - this.#head = this.#tail = 0; - this.#free.length = 0; - } else { - this.#head = this.#next[head]; - } - this.#keyMap.delete(k); - this.#size--; - return head; + const path = findPaginatedResourcePath(response1); + const nodesPath = [...path, "nodes"]; + const newNodes = get(response2, nodesPath); + if (newNodes) { + set(response1, nodesPath, (values) => { + return [...values, ...newNodes]; + }); } - /** - * Check if a key is in the cache, without updating the recency of use. - * Will return false if the item is stale, even though it is technically - * in the cache. - * - * Will not update item age unless - * {@link LRUCache.OptionsBase.updateAgeOnHas} is set. - */ - has(k, hasOptions = {}) { - const { updateAgeOnHas = this.updateAgeOnHas, status: status2 } = hasOptions; - const index2 = this.#keyMap.get(k); - if (index2 !== void 0) { - const v = this.#valList[index2]; - if (this.#isBackgroundFetch(v) && v.__staleWhileFetching === void 0) { - return false; - } - if (!this.#isStale(index2)) { - if (updateAgeOnHas) { - this.#updateItemAge(index2); - } - if (status2) { - status2.has = "hit"; - this.#statusTTL(status2, index2); - } - return true; - } else if (status2) { - status2.has = "stale"; - this.#statusTTL(status2, index2); - } - } else if (status2) { - status2.has = "miss"; - } - return false; + const edgesPath = [...path, "edges"]; + const newEdges = get(response2, edgesPath); + if (newEdges) { + set(response1, edgesPath, (values) => { + return [...values, ...newEdges]; + }); } - /** - * Like {@link LRUCache#get} but doesn't update recency or delete stale - * items. - * - * Returns `undefined` if the item is stale, unless - * {@link LRUCache.OptionsBase.allowStale} is set. - */ - peek(k, peekOptions = {}) { - const { allowStale = this.allowStale } = peekOptions; - const index2 = this.#keyMap.get(k); - if (index2 === void 0 || !allowStale && this.#isStale(index2)) { - return; + const pageInfoPath = [...path, "pageInfo"]; + set(response1, pageInfoPath, get(response2, pageInfoPath)); + return response1; + }; + var createPaginate = (octokit) => { + const iterator = createIterator(octokit); + return async (query, initialParameters = {}) => { + let mergedResponse = {}; + for await (const response of iterator( + query, + initialParameters + )) { + mergedResponse = mergeResponses(mergedResponse, response); } - const v = this.#valList[index2]; - return this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v; + return mergedResponse; + }; + }; + function paginateGraphql(octokit) { + octokit.graphql; + return { + graphql: Object.assign(octokit.graphql, { + paginate: Object.assign(createPaginate(octokit), { + iterator: createIterator(octokit) + }) + }) + }; + } + } +}); + +// ../../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/light.js +var require_light = __commonJS({ + "../../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/light.js"(exports2, module2) { + (function(global2, factory) { + typeof exports2 === "object" && typeof module2 !== "undefined" ? module2.exports = factory() : typeof define === "function" && define.amd ? define(factory) : global2.Bottleneck = factory(); + })(exports2, function() { + "use strict"; + var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {}; + function getCjsExportFromNamespace(n) { + return n && n["default"] || n; } - #backgroundFetch(k, index2, options, context2) { - const v = index2 === void 0 ? void 0 : this.#valList[index2]; - if (this.#isBackgroundFetch(v)) { - return v; + var load = function(received, defaults, onto = {}) { + var k, ref, v; + for (k in defaults) { + v = defaults[k]; + onto[k] = (ref = received[k]) != null ? ref : v; } - const ac = new AC(); - const { signal } = options; - signal?.addEventListener("abort", () => ac.abort(signal.reason), { - signal: ac.signal - }); - const fetchOpts = { - signal: ac.signal, - options, - context: context2 - }; - const cb = (v2, updateCache = false) => { - const { aborted } = ac.signal; - const ignoreAbort = options.ignoreFetchAbort && v2 !== void 0; - if (options.status) { - if (aborted && !updateCache) { - options.status.fetchAborted = true; - options.status.fetchError = ac.signal.reason; - if (ignoreAbort) - options.status.fetchAbortIgnored = true; - } else { - options.status.fetchResolved = true; - } - } - if (aborted && !ignoreAbort && !updateCache) { - return fetchFail(ac.signal.reason); - } - const bf2 = p; - if (this.#valList[index2] === p) { - if (v2 === void 0) { - if (bf2.__staleWhileFetching) { - this.#valList[index2] = bf2.__staleWhileFetching; - } else { - this.delete(k); - } - } else { - if (options.status) - options.status.fetchUpdated = true; - this.set(k, v2, fetchOpts.options); - } + return onto; + }; + var overwrite = function(received, defaults, onto = {}) { + var k, v; + for (k in received) { + v = received[k]; + if (defaults[k] !== void 0) { + onto[k] = v; } - return v2; - }; - const eb = (er) => { - if (options.status) { - options.status.fetchRejected = true; - options.status.fetchError = er; + } + return onto; + }; + var parser = { + load, + overwrite + }; + var DLList; + DLList = class DLList { + constructor(incr, decr) { + this.incr = incr; + this.decr = decr; + this._first = null; + this._last = null; + this.length = 0; + } + push(value) { + var node; + this.length++; + if (typeof this.incr === "function") { + this.incr(); } - return fetchFail(er); - }; - const fetchFail = (er) => { - const { aborted } = ac.signal; - const allowStaleAborted = aborted && options.allowStaleOnFetchAbort; - const allowStale = allowStaleAborted || options.allowStaleOnFetchRejection; - const noDelete = allowStale || options.noDeleteOnFetchRejection; - const bf2 = p; - if (this.#valList[index2] === p) { - const del = !noDelete || bf2.__staleWhileFetching === void 0; - if (del) { - this.delete(k); - } else if (!allowStaleAborted) { - this.#valList[index2] = bf2.__staleWhileFetching; - } + node = { + value, + prev: this._last, + next: null + }; + if (this._last != null) { + this._last.next = node; + this._last = node; + } else { + this._first = this._last = node; } - if (allowStale) { - if (options.status && bf2.__staleWhileFetching !== void 0) { - options.status.returnedStale = true; + return void 0; + } + shift() { + var value; + if (this._first == null) { + return; + } else { + this.length--; + if (typeof this.decr === "function") { + this.decr(); } - return bf2.__staleWhileFetching; - } else if (bf2.__returned === bf2) { - throw er; } - }; - const pcall = (res, rej) => { - const fmp = this.#fetchMethod?.(k, v, fetchOpts); - if (fmp && fmp instanceof Promise) { - fmp.then((v2) => res(v2 === void 0 ? void 0 : v2), rej); + value = this._first.value; + if ((this._first = this._first.next) != null) { + this._first.prev = null; + } else { + this._last = null; } - ac.signal.addEventListener("abort", () => { - if (!options.ignoreFetchAbort || options.allowStaleOnFetchAbort) { - res(void 0); - if (options.allowStaleOnFetchAbort) { - res = (v2) => cb(v2, true); - } - } - }); - }; - if (options.status) - options.status.fetchDispatched = true; - const p = new Promise(pcall).then(cb, eb); - const bf = Object.assign(p, { - __abortController: ac, - __staleWhileFetching: v, - __returned: void 0 - }); - if (index2 === void 0) { - this.set(k, bf, { ...fetchOpts.options, status: void 0 }); - index2 = this.#keyMap.get(k); - } else { - this.#valList[index2] = bf; + return value; } - return bf; - } - #isBackgroundFetch(p) { - if (!this.#hasFetchMethod) - return false; - const b = p; - return !!b && b instanceof Promise && b.hasOwnProperty("__staleWhileFetching") && b.__abortController instanceof AC; - } - async fetch(k, fetchOptions = {}) { - const { - // get options - allowStale = this.allowStale, - updateAgeOnGet = this.updateAgeOnGet, - noDeleteOnStaleGet = this.noDeleteOnStaleGet, - // set options - ttl = this.ttl, - noDisposeOnSet = this.noDisposeOnSet, - size = 0, - sizeCalculation = this.sizeCalculation, - noUpdateTTL = this.noUpdateTTL, - // fetch exclusive options - noDeleteOnFetchRejection = this.noDeleteOnFetchRejection, - allowStaleOnFetchRejection = this.allowStaleOnFetchRejection, - ignoreFetchAbort = this.ignoreFetchAbort, - allowStaleOnFetchAbort = this.allowStaleOnFetchAbort, - context: context2, - forceRefresh = false, - status: status2, - signal - } = fetchOptions; - if (!this.#hasFetchMethod) { - if (status2) - status2.fetch = "get"; - return this.get(k, { - allowStale, - updateAgeOnGet, - noDeleteOnStaleGet, - status: status2 - }); + first() { + if (this._first != null) { + return this._first.value; + } } - const options = { - allowStale, - updateAgeOnGet, - noDeleteOnStaleGet, - ttl, - noDisposeOnSet, - size, - sizeCalculation, - noUpdateTTL, - noDeleteOnFetchRejection, - allowStaleOnFetchRejection, - allowStaleOnFetchAbort, - ignoreFetchAbort, - status: status2, - signal - }; - let index2 = this.#keyMap.get(k); - if (index2 === void 0) { - if (status2) - status2.fetch = "miss"; - const p = this.#backgroundFetch(k, index2, options, context2); - return p.__returned = p; - } else { - const v = this.#valList[index2]; - if (this.#isBackgroundFetch(v)) { - const stale = allowStale && v.__staleWhileFetching !== void 0; - if (status2) { - status2.fetch = "inflight"; - if (stale) - status2.returnedStale = true; - } - return stale ? v.__staleWhileFetching : v.__returned = v; + getArray() { + var node, ref, results; + node = this._first; + results = []; + while (node != null) { + results.push((ref = node, node = node.next, ref.value)); } - const isStale = this.#isStale(index2); - if (!forceRefresh && !isStale) { - if (status2) - status2.fetch = "hit"; - this.#moveToTail(index2); - if (updateAgeOnGet) { - this.#updateItemAge(index2); - } - if (status2) - this.#statusTTL(status2, index2); - return v; + return results; + } + forEachShift(cb) { + var node; + node = this.shift(); + while (node != null) { + cb(node), node = this.shift(); } - const p = this.#backgroundFetch(k, index2, options, context2); - const hasStale = p.__staleWhileFetching !== void 0; - const staleVal = hasStale && allowStale; - if (status2) { - status2.fetch = isStale ? "stale" : "refresh"; - if (staleVal && isStale) - status2.returnedStale = true; + return void 0; + } + debug() { + var node, ref, ref1, ref2, results; + node = this._first; + results = []; + while (node != null) { + results.push((ref = node, node = node.next, { + value: ref.value, + prev: (ref1 = ref.prev) != null ? ref1.value : void 0, + next: (ref2 = ref.next) != null ? ref2.value : void 0 + })); } - return staleVal ? p.__staleWhileFetching : p.__returned = p; + return results; } - } - /** - * Return a value from the cache. Will update the recency of the cache - * entry found. - * - * If the key is not found, get() will return `undefined`. - */ - get(k, getOptions = {}) { - const { allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet, status: status2 } = getOptions; - const index2 = this.#keyMap.get(k); - if (index2 !== void 0) { - const value = this.#valList[index2]; - const fetching = this.#isBackgroundFetch(value); - if (status2) - this.#statusTTL(status2, index2); - if (this.#isStale(index2)) { - if (status2) - status2.get = "stale"; - if (!fetching) { - if (!noDeleteOnStaleGet) { - this.delete(k); - } - if (status2 && allowStale) - status2.returnedStale = true; - return allowStale ? value : void 0; - } else { - if (status2 && allowStale && value.__staleWhileFetching !== void 0) { - status2.returnedStale = true; - } - return allowStale ? value.__staleWhileFetching : void 0; - } - } else { - if (status2) - status2.get = "hit"; - if (fetching) { - return value.__staleWhileFetching; - } - this.#moveToTail(index2); - if (updateAgeOnGet) { - this.#updateItemAge(index2); + }; + var DLList_1 = DLList; + var Events; + Events = class Events { + constructor(instance) { + this.instance = instance; + this._events = {}; + if (this.instance.on != null || this.instance.once != null || this.instance.removeAllListeners != null) { + throw new Error("An Emitter already exists for this object"); + } + this.instance.on = (name, cb) => { + return this._addListener(name, "many", cb); + }; + this.instance.once = (name, cb) => { + return this._addListener(name, "once", cb); + }; + this.instance.removeAllListeners = (name = null) => { + if (name != null) { + return delete this._events[name]; + } else { + return this._events = {}; } - return value; + }; + } + _addListener(name, status3, cb) { + var base; + if ((base = this._events)[name] == null) { + base[name] = []; } - } else if (status2) { - status2.get = "miss"; + this._events[name].push({ cb, status: status3 }); + return this.instance; } - } - #connect(p, n) { - this.#prev[n] = p; - this.#next[p] = n; - } - #moveToTail(index2) { - if (index2 !== this.#tail) { - if (index2 === this.#head) { - this.#head = this.#next[index2]; + listenerCount(name) { + if (this._events[name] != null) { + return this._events[name].length; } else { - this.#connect(this.#prev[index2], this.#next[index2]); + return 0; } - this.#connect(this.#tail, index2); - this.#tail = index2; } - } - /** - * Deletes a key out of the cache. - * Returns true if the key was deleted, false otherwise. - */ - delete(k) { - let deleted = false; - if (this.#size !== 0) { - const index2 = this.#keyMap.get(k); - if (index2 !== void 0) { - deleted = true; - if (this.#size === 1) { - this.clear(); - } else { - this.#removeItemSize(index2); - const v = this.#valList[index2]; - if (this.#isBackgroundFetch(v)) { - v.__abortController.abort(new Error("deleted")); - } else if (this.#hasDispose || this.#hasDisposeAfter) { - if (this.#hasDispose) { - this.#dispose?.(v, k, "delete"); + async trigger(name, ...args) { + var e, promises; + try { + if (name !== "debug") { + this.trigger("debug", `Event triggered: ${name}`, args); + } + if (this._events[name] == null) { + return; + } + this._events[name] = this._events[name].filter(function(listener) { + return listener.status !== "none"; + }); + promises = this._events[name].map(async (listener) => { + var e2, returned; + if (listener.status === "none") { + return; + } + if (listener.status === "once") { + listener.status = "none"; + } + try { + returned = typeof listener.cb === "function" ? listener.cb(...args) : void 0; + if (typeof (returned != null ? returned.then : void 0) === "function") { + return await returned; + } else { + return returned; } - if (this.#hasDisposeAfter) { - this.#disposed?.push([v, k, "delete"]); + } catch (error) { + e2 = error; + { + this.trigger("error", e2); } + return null; } - this.#keyMap.delete(k); - this.#keyList[index2] = void 0; - this.#valList[index2] = void 0; - if (index2 === this.#tail) { - this.#tail = this.#prev[index2]; - } else if (index2 === this.#head) { - this.#head = this.#next[index2]; - } else { - const pi = this.#prev[index2]; - this.#next[pi] = this.#next[index2]; - const ni = this.#next[index2]; - this.#prev[ni] = this.#prev[index2]; - } - this.#size--; - this.#free.push(index2); + }); + return (await Promise.all(promises)).find(function(x) { + return x != null; + }); + } catch (error) { + e = error; + { + this.trigger("error", e); } + return null; } } - if (this.#hasDisposeAfter && this.#disposed?.length) { - const dt = this.#disposed; - let task; - while (task = dt?.shift()) { - this.#disposeAfter?.(...task); + }; + var Events_1 = Events; + var DLList$1, Events$1, Queues; + DLList$1 = DLList_1; + Events$1 = Events_1; + Queues = class Queues { + constructor(num_priorities) { + var i; + this.Events = new Events$1(this); + this._length = 0; + this._lists = function() { + var j, ref, results; + results = []; + for (i = j = 1, ref = num_priorities; 1 <= ref ? j <= ref : j >= ref; i = 1 <= ref ? ++j : --j) { + results.push(new DLList$1(() => { + return this.incr(); + }, () => { + return this.decr(); + })); + } + return results; + }.call(this); + } + incr() { + if (this._length++ === 0) { + return this.Events.trigger("leftzero"); } } - return deleted; - } - /** - * Clear the cache entirely, throwing away all values. - */ - clear() { - for (const index2 of this.#rindexes({ allowStale: true })) { - const v = this.#valList[index2]; - if (this.#isBackgroundFetch(v)) { - v.__abortController.abort(new Error("deleted")); + decr() { + if (--this._length === 0) { + return this.Events.trigger("zero"); + } + } + push(job) { + return this._lists[job.options.priority].push(job); + } + queued(priority) { + if (priority != null) { + return this._lists[priority].length; } else { - const k = this.#keyList[index2]; - if (this.#hasDispose) { - this.#dispose?.(v, k, "delete"); - } - if (this.#hasDisposeAfter) { - this.#disposed?.push([v, k, "delete"]); + return this._length; + } + } + shiftAll(fn) { + return this._lists.forEach(function(list) { + return list.forEachShift(fn); + }); + } + getFirst(arr = this._lists) { + var j, len, list; + for (j = 0, len = arr.length; j < len; j++) { + list = arr[j]; + if (list.length > 0) { + return list; } } + return []; } - this.#keyMap.clear(); - this.#valList.fill(void 0); - this.#keyList.fill(void 0); - if (this.#ttls && this.#starts) { - this.#ttls.fill(0); - this.#starts.fill(0); + shiftLastFrom(priority) { + return this.getFirst(this._lists.slice(priority).reverse()).shift(); } - if (this.#sizes) { - this.#sizes.fill(0); + }; + var Queues_1 = Queues; + var BottleneckError; + BottleneckError = class BottleneckError extends Error { + }; + var BottleneckError_1 = BottleneckError; + var BottleneckError$1, DEFAULT_PRIORITY, Job, NUM_PRIORITIES, parser$1; + NUM_PRIORITIES = 10; + DEFAULT_PRIORITY = 5; + parser$1 = parser; + BottleneckError$1 = BottleneckError_1; + Job = class Job { + constructor(task, args, options, jobDefaults, rejectOnDrop, Events2, _states, Promise2) { + this.task = task; + this.args = args; + this.rejectOnDrop = rejectOnDrop; + this.Events = Events2; + this._states = _states; + this.Promise = Promise2; + this.options = parser$1.load(options, jobDefaults); + this.options.priority = this._sanitizePriority(this.options.priority); + if (this.options.id === jobDefaults.id) { + this.options.id = `${this.options.id}-${this._randomIndex()}`; + } + this.promise = new this.Promise((_resolve, _reject) => { + this._resolve = _resolve; + this._reject = _reject; + }); + this.retryCount = 0; } - this.#head = 0; - this.#tail = 0; - this.#free.length = 0; - this.#calculatedSize = 0; - this.#size = 0; - if (this.#hasDisposeAfter && this.#disposed) { - const dt = this.#disposed; - let task; - while (task = dt?.shift()) { - this.#disposeAfter?.(...task); + _sanitizePriority(priority) { + var sProperty; + sProperty = ~~priority !== priority ? DEFAULT_PRIORITY : priority; + if (sProperty < 0) { + return 0; + } else if (sProperty > NUM_PRIORITIES - 1) { + return NUM_PRIORITIES - 1; + } else { + return sProperty; } } - } - }; - exports2.LRUCache = LRUCache; - } -}); - -// ../../../node_modules/.pnpm/@octokit+auth-app@6.1.1/node_modules/@octokit/auth-app/dist-node/index.js -var require_dist_node20 = __commonJS({ - "../../../node_modules/.pnpm/@octokit+auth-app@6.1.1/node_modules/@octokit/auth-app/dist-node/index.js"(exports2, module2) { - "use strict"; - var __create2 = Object.create; - var __defProp2 = Object.defineProperty; - var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; - var __getOwnPropNames2 = Object.getOwnPropertyNames; - var __getProtoOf2 = Object.getPrototypeOf; - var __hasOwnProp2 = Object.prototype.hasOwnProperty; - var __export2 = (target, all) => { - for (var name in all) - __defProp2(target, name, { get: all[name], enumerable: true }); - }; - var __copyProps2 = (to, from3, except, desc) => { - if (from3 && typeof from3 === "object" || typeof from3 === "function") { - for (let key of __getOwnPropNames2(from3)) - if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc2(from3, key)) || desc.enumerable }); - } - return to; - }; - var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2( - // If the importer is in node compatibility mode or this is not an ESM - // file that has been converted to a CommonJS file using a Babel- - // compatible transform (i.e. "__esModule" has not been set), then set - // "default" to the CommonJS "module.exports" for node compatibility. - isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target, - mod - )); - var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); - var dist_src_exports = {}; - __export2(dist_src_exports, { - createAppAuth: () => createAppAuth, - createOAuthUserAuth: () => import_auth_oauth_user2.createOAuthUserAuth - }); - module2.exports = __toCommonJS2(dist_src_exports); - var import_universal_user_agent = require_dist_node(); - var import_request = require_dist_node5(); - var import_auth_oauth_app = require_dist_node18(); - var import_deprecation = require_dist_node3(); - var OAuthAppAuth = __toESM2(require_dist_node18()); - var import_universal_github_app_jwt = require_dist_node19(); - async function getAppAuthentication({ - appId, - privateKey, - timeDifference - }) { - try { - const appAuthentication = await (0, import_universal_github_app_jwt.githubAppJwt)({ - id: +appId, - privateKey, - now: timeDifference && Math.floor(Date.now() / 1e3) + timeDifference - }); - return { - type: "app", - token: appAuthentication.token, - appId: appAuthentication.appId, - expiresAt: new Date(appAuthentication.expiration * 1e3).toISOString() - }; - } catch (error) { - if (privateKey === "-----BEGIN RSA PRIVATE KEY-----") { - throw new Error( - "The 'privateKey` option contains only the first line '-----BEGIN RSA PRIVATE KEY-----'. If you are setting it using a `.env` file, make sure it is set on a single line with newlines replaced by '\n'" - ); - } else { - throw error; + _randomIndex() { + return Math.random().toString(36).slice(2); } - } - } - var import_lru_cache = require_commonjs(); - function getCache() { - return new import_lru_cache.LRUCache({ - // cache max. 15000 tokens, that will use less than 10mb memory - max: 15e3, - // Cache for 1 minute less than GitHub expiry - ttl: 1e3 * 60 * 59 - }); - } - async function get(cache, options) { - const cacheKey = optionsToCacheKey(options); - const result = await cache.get(cacheKey); - if (!result) { - return; - } - const [ - token, - createdAt, - expiresAt, - repositorySelection, - permissionsString, - singleFileName - ] = result.split("|"); - const permissions = options.permissions || permissionsString.split(/,/).reduce((permissions2, string) => { - if (/!$/.test(string)) { - permissions2[string.slice(0, -1)] = "write"; - } else { - permissions2[string] = "read"; + doDrop({ error, message = "This job has been dropped by Bottleneck" } = {}) { + if (this._states.remove(this.options.id)) { + if (this.rejectOnDrop) { + this._reject(error != null ? error : new BottleneckError$1(message)); + } + this.Events.trigger("dropped", { args: this.args, options: this.options, task: this.task, promise: this.promise }); + return true; + } else { + return false; + } } - return permissions2; - }, {}); - return { - token, - createdAt, - expiresAt, - permissions, - repositoryIds: options.repositoryIds, - repositoryNames: options.repositoryNames, - singleFileName, - repositorySelection - }; - } - async function set(cache, options, data) { - const key = optionsToCacheKey(options); - const permissionsString = options.permissions ? "" : Object.keys(data.permissions).map( - (name) => `${name}${data.permissions[name] === "write" ? "!" : ""}` - ).join(","); - const value = [ - data.token, - data.createdAt, - data.expiresAt, - data.repositorySelection, - permissionsString, - data.singleFileName - ].join("|"); - await cache.set(key, value); - } - function optionsToCacheKey({ - installationId, - permissions = {}, - repositoryIds = [], - repositoryNames = [] - }) { - const permissionsString = Object.keys(permissions).sort().map((name) => permissions[name] === "read" ? name : `${name}!`).join(","); - const repositoryIdsString = repositoryIds.sort().join(","); - const repositoryNamesString = repositoryNames.join(","); - return [ - installationId, - repositoryIdsString, - repositoryNamesString, - permissionsString - ].filter(Boolean).join("|"); - } - function toTokenAuthentication({ - installationId, - token, - createdAt, - expiresAt, - repositorySelection, - permissions, - repositoryIds, - repositoryNames, - singleFileName - }) { - return Object.assign( - { - type: "token", - tokenType: "installation", - token, - installationId, - permissions, - createdAt, - expiresAt, - repositorySelection - }, - repositoryIds ? { repositoryIds } : null, - repositoryNames ? { repositoryNames } : null, - singleFileName ? { singleFileName } : null - ); - } - async function getInstallationAuthentication(state, options, customRequest) { - const installationId = Number(options.installationId || state.installationId); - if (!installationId) { - throw new Error( - "[@octokit/auth-app] installationId option is required for installation authentication." - ); - } - if (options.factory) { - const { type, factory, oauthApp, ...factoryAuthOptions } = { - ...state, - ...options - }; - return factory(factoryAuthOptions); - } - const optionsWithInstallationTokenFromState = Object.assign( - { installationId }, - options - ); - if (!options.refresh) { - const result = await get( - state.cache, - optionsWithInstallationTokenFromState - ); - if (result) { - const { - token: token2, - createdAt: createdAt2, - expiresAt: expiresAt2, - permissions: permissions2, - repositoryIds: repositoryIds2, - repositoryNames: repositoryNames2, - singleFileName: singleFileName2, - repositorySelection: repositorySelection2 - } = result; - return toTokenAuthentication({ - installationId, - token: token2, - createdAt: createdAt2, - expiresAt: expiresAt2, - permissions: permissions2, - repositorySelection: repositorySelection2, - repositoryIds: repositoryIds2, - repositoryNames: repositoryNames2, - singleFileName: singleFileName2 - }); + _assertStatus(expected) { + var status3; + status3 = this._states.jobStatus(this.options.id); + if (!(status3 === expected || expected === "DONE" && status3 === null)) { + throw new BottleneckError$1(`Invalid job status ${status3}, expected ${expected}. Please open an issue at https://github.com/SGrondin/bottleneck/issues`); + } } - } - const appAuthentication = await getAppAuthentication(state); - const request = customRequest || state.request; - const { - data: { - token, - expires_at: expiresAt, - repositories, - permissions: permissionsOptional, - repository_selection: repositorySelectionOptional, - single_file: singleFileName + doReceive() { + this._states.start(this.options.id); + return this.Events.trigger("received", { args: this.args, options: this.options }); + } + doQueue(reachedHWM, blocked) { + this._assertStatus("RECEIVED"); + this._states.next(this.options.id); + return this.Events.trigger("queued", { args: this.args, options: this.options, reachedHWM, blocked }); + } + doRun() { + if (this.retryCount === 0) { + this._assertStatus("QUEUED"); + this._states.next(this.options.id); + } else { + this._assertStatus("EXECUTING"); + } + return this.Events.trigger("scheduled", { args: this.args, options: this.options }); + } + async doExecute(chained, clearGlobalState, run2, free) { + var error, eventInfo, passed; + if (this.retryCount === 0) { + this._assertStatus("RUNNING"); + this._states.next(this.options.id); + } else { + this._assertStatus("EXECUTING"); + } + eventInfo = { args: this.args, options: this.options, retryCount: this.retryCount }; + this.Events.trigger("executing", eventInfo); + try { + passed = await (chained != null ? chained.schedule(this.options, this.task, ...this.args) : this.task(...this.args)); + if (clearGlobalState()) { + this.doDone(eventInfo); + await free(this.options, eventInfo); + this._assertStatus("DONE"); + return this._resolve(passed); + } + } catch (error1) { + error = error1; + return this._onFailure(error, eventInfo, clearGlobalState, run2, free); + } } - } = await request("POST /app/installations/{installation_id}/access_tokens", { - installation_id: installationId, - repository_ids: options.repositoryIds, - repositories: options.repositoryNames, - permissions: options.permissions, - mediaType: { - previews: ["machine-man"] - }, - headers: { - authorization: `bearer ${appAuthentication.token}` + doExpire(clearGlobalState, run2, free) { + var error, eventInfo; + if (this._states.jobStatus(this.options.id === "RUNNING")) { + this._states.next(this.options.id); + } + this._assertStatus("EXECUTING"); + eventInfo = { args: this.args, options: this.options, retryCount: this.retryCount }; + error = new BottleneckError$1(`This job timed out after ${this.options.expiration} ms.`); + return this._onFailure(error, eventInfo, clearGlobalState, run2, free); } - }); - const permissions = permissionsOptional || {}; - const repositorySelection = repositorySelectionOptional || "all"; - const repositoryIds = repositories ? repositories.map((r) => r.id) : void 0; - const repositoryNames = repositories ? repositories.map((repo) => repo.name) : void 0; - const createdAt = (/* @__PURE__ */ new Date()).toISOString(); - await set(state.cache, optionsWithInstallationTokenFromState, { - token, - createdAt, - expiresAt, - repositorySelection, - permissions, - repositoryIds, - repositoryNames, - singleFileName - }); - return toTokenAuthentication({ - installationId, - token, - createdAt, - expiresAt, - repositorySelection, - permissions, - repositoryIds, - repositoryNames, - singleFileName - }); - } - async function auth(state, authOptions) { - switch (authOptions.type) { - case "app": - return getAppAuthentication(state); - case "oauth": - state.log.warn( - // @ts-expect-error `log.warn()` expects string - new import_deprecation.Deprecation( - `[@octokit/auth-app] {type: "oauth"} is deprecated. Use {type: "oauth-app"} instead` - ) - ); - case "oauth-app": - return state.oauthApp({ type: "oauth-app" }); - case "installation": - authOptions; - return getInstallationAuthentication(state, { - ...authOptions, - type: "installation" - }); - case "oauth-user": - return state.oauthApp(authOptions); - default: - throw new Error(`Invalid auth type: ${authOptions.type}`); - } - } - var import_auth_oauth_user = require_dist_node17(); - var import_request_error = require_dist_node4(); - var PATHS = [ - "/app", - "/app/hook/config", - "/app/hook/deliveries", - "/app/hook/deliveries/{delivery_id}", - "/app/hook/deliveries/{delivery_id}/attempts", - "/app/installations", - "/app/installations/{installation_id}", - "/app/installations/{installation_id}/access_tokens", - "/app/installations/{installation_id}/suspended", - "/app/installation-requests", - "/marketplace_listing/accounts/{account_id}", - "/marketplace_listing/plan", - "/marketplace_listing/plans", - "/marketplace_listing/plans/{plan_id}/accounts", - "/marketplace_listing/stubbed/accounts/{account_id}", - "/marketplace_listing/stubbed/plan", - "/marketplace_listing/stubbed/plans", - "/marketplace_listing/stubbed/plans/{plan_id}/accounts", - "/orgs/{org}/installation", - "/repos/{owner}/{repo}/installation", - "/users/{username}/installation" - ]; - function routeMatcher(paths) { - const regexes = paths.map( - (p) => p.split("/").map((c) => c.startsWith("{") ? "(?:.+?)" : c).join("/") - ); - const regex = `^(?:${regexes.map((r) => `(?:${r})`).join("|")})$`; - return new RegExp(regex, "i"); - } - var REGEX = routeMatcher(PATHS); - function requiresAppAuth(url) { - return !!url && REGEX.test(url.split("?")[0]); - } - var FIVE_SECONDS_IN_MS = 5 * 1e3; - function isNotTimeSkewError(error) { - return !(error.message.match( - /'Expiration time' claim \('exp'\) must be a numeric value representing the future time at which the assertion expires/ - ) || error.message.match( - /'Issued at' claim \('iat'\) must be an Integer representing the time that the assertion was issued/ - )); - } - async function hook(state, request, route, parameters) { - const endpoint = request.endpoint.merge(route, parameters); - const url = endpoint.url; - if (/\/login\/oauth\/access_token$/.test(url)) { - return request(endpoint); - } - if (requiresAppAuth(url.replace(request.endpoint.DEFAULTS.baseUrl, ""))) { - const { token: token2 } = await getAppAuthentication(state); - endpoint.headers.authorization = `bearer ${token2}`; - let response; - try { - response = await request(endpoint); - } catch (error) { - if (isNotTimeSkewError(error)) { - throw error; + async _onFailure(error, eventInfo, clearGlobalState, run2, free) { + var retry, retryAfter; + if (clearGlobalState()) { + retry = await this.Events.trigger("failed", error, eventInfo); + if (retry != null) { + retryAfter = ~~retry; + this.Events.trigger("retry", `Retrying ${this.options.id} after ${retryAfter} ms`, eventInfo); + this.retryCount++; + return run2(retryAfter); + } else { + this.doDone(eventInfo); + await free(this.options, eventInfo); + this._assertStatus("DONE"); + return this._reject(error); + } } - if (typeof error.response.headers.date === "undefined") { - throw error; + } + doDone(eventInfo) { + this._assertStatus("EXECUTING"); + this._states.next(this.options.id); + return this.Events.trigger("done", eventInfo); + } + }; + var Job_1 = Job; + var BottleneckError$2, LocalDatastore, parser$2; + parser$2 = parser; + BottleneckError$2 = BottleneckError_1; + LocalDatastore = class LocalDatastore { + constructor(instance, storeOptions, storeInstanceOptions) { + this.instance = instance; + this.storeOptions = storeOptions; + this.clientId = this.instance._randomIndex(); + parser$2.load(storeInstanceOptions, storeInstanceOptions, this); + this._nextRequest = this._lastReservoirRefresh = this._lastReservoirIncrease = Date.now(); + this._running = 0; + this._done = 0; + this._unblockTime = 0; + this.ready = this.Promise.resolve(); + this.clients = {}; + this._startHeartbeat(); + } + _startHeartbeat() { + var base; + if (this.heartbeat == null && (this.storeOptions.reservoirRefreshInterval != null && this.storeOptions.reservoirRefreshAmount != null || this.storeOptions.reservoirIncreaseInterval != null && this.storeOptions.reservoirIncreaseAmount != null)) { + return typeof (base = this.heartbeat = setInterval(() => { + var amount, incr, maximum, now, reservoir; + now = Date.now(); + if (this.storeOptions.reservoirRefreshInterval != null && now >= this._lastReservoirRefresh + this.storeOptions.reservoirRefreshInterval) { + this._lastReservoirRefresh = now; + this.storeOptions.reservoir = this.storeOptions.reservoirRefreshAmount; + this.instance._drainAll(this.computeCapacity()); + } + if (this.storeOptions.reservoirIncreaseInterval != null && now >= this._lastReservoirIncrease + this.storeOptions.reservoirIncreaseInterval) { + ({ + reservoirIncreaseAmount: amount, + reservoirIncreaseMaximum: maximum, + reservoir + } = this.storeOptions); + this._lastReservoirIncrease = now; + incr = maximum != null ? Math.min(amount, maximum - reservoir) : amount; + if (incr > 0) { + this.storeOptions.reservoir += incr; + return this.instance._drainAll(this.computeCapacity()); + } + } + }, this.heartbeatInterval)).unref === "function" ? base.unref() : void 0; + } else { + return clearInterval(this.heartbeat); } - const diff = Math.floor( - (Date.parse(error.response.headers.date) - Date.parse((/* @__PURE__ */ new Date()).toString())) / 1e3 - ); - state.log.warn(error.message); - state.log.warn( - `[@octokit/auth-app] GitHub API time and system time are different by ${diff} seconds. Retrying request with the difference accounted for.` - ); - const { token: token3 } = await getAppAuthentication({ - ...state, - timeDifference: diff + } + async __publish__(message) { + await this.yieldLoop(); + return this.instance.Events.trigger("message", message.toString()); + } + async __disconnect__(flush) { + await this.yieldLoop(); + clearInterval(this.heartbeat); + return this.Promise.resolve(); + } + yieldLoop(t = 0) { + return new this.Promise(function(resolve, reject) { + return setTimeout(resolve, t); }); - endpoint.headers.authorization = `bearer ${token3}`; - return request(endpoint); } - return response; - } - if ((0, import_auth_oauth_user.requiresBasicAuth)(url)) { - const authentication = await state.oauthApp({ type: "oauth-app" }); - endpoint.headers.authorization = authentication.headers.authorization; - return request(endpoint); - } - const { token, createdAt } = await getInstallationAuthentication( - state, - // @ts-expect-error TBD - {}, - request - ); - endpoint.headers.authorization = `token ${token}`; - return sendRequestWithRetries( - state, - request, - endpoint, - createdAt - ); - } - async function sendRequestWithRetries(state, request, options, createdAt, retries = 0) { - const timeSinceTokenCreationInMs = +/* @__PURE__ */ new Date() - +new Date(createdAt); - try { - return await request(options); - } catch (error) { - if (error.status !== 401) { - throw error; + computePenalty() { + var ref; + return (ref = this.storeOptions.penalty) != null ? ref : 15 * this.storeOptions.minTime || 5e3; } - if (timeSinceTokenCreationInMs >= FIVE_SECONDS_IN_MS) { - if (retries > 0) { - error.message = `After ${retries} retries within ${timeSinceTokenCreationInMs / 1e3}s of creating the installation access token, the response remains 401. At this point, the cause may be an authentication problem or a system outage. Please check https://www.githubstatus.com for status information`; + async __updateSettings__(options) { + await this.yieldLoop(); + parser$2.overwrite(options, options, this.storeOptions); + this._startHeartbeat(); + this.instance._drainAll(this.computeCapacity()); + return true; + } + async __running__() { + await this.yieldLoop(); + return this._running; + } + async __queued__() { + await this.yieldLoop(); + return this.instance.queued(); + } + async __done__() { + await this.yieldLoop(); + return this._done; + } + async __groupCheck__(time) { + await this.yieldLoop(); + return this._nextRequest + this.timeout < time; + } + computeCapacity() { + var maxConcurrent, reservoir; + ({ maxConcurrent, reservoir } = this.storeOptions); + if (maxConcurrent != null && reservoir != null) { + return Math.min(maxConcurrent - this._running, reservoir); + } else if (maxConcurrent != null) { + return maxConcurrent - this._running; + } else if (reservoir != null) { + return reservoir; + } else { + return null; } - throw error; } - ++retries; - const awaitTime = retries * 1e3; - state.log.warn( - `[@octokit/auth-app] Retrying after 401 response to account for token replication delay (retry: ${retries}, wait: ${awaitTime / 1e3}s)` - ); - await new Promise((resolve) => setTimeout(resolve, awaitTime)); - return sendRequestWithRetries(state, request, options, createdAt, retries); - } - } - var VERSION = "6.1.1"; - var import_auth_oauth_user2 = require_dist_node17(); - function createAppAuth(options) { - if (!options.appId) { - throw new Error("[@octokit/auth-app] appId option is required"); - } - if (!Number.isFinite(+options.appId)) { - throw new Error( - "[@octokit/auth-app] appId option must be a number or numeric string" - ); - } - if (!options.privateKey) { - throw new Error("[@octokit/auth-app] privateKey option is required"); - } - if ("installationId" in options && !options.installationId) { - throw new Error( - "[@octokit/auth-app] installationId is set to a falsy value" - ); - } - const log2 = Object.assign( - { - warn: console.warn.bind(console) - }, - options.log - ); - const request = options.request || import_request.request.defaults({ - headers: { - "user-agent": `octokit-auth-app.js/${VERSION} ${(0, import_universal_user_agent.getUserAgent)()}` + conditionsCheck(weight) { + var capacity; + capacity = this.computeCapacity(); + return capacity == null || weight <= capacity; } - }); - const state = Object.assign( - { - request, - cache: getCache() - }, - options, - options.installationId ? { installationId: Number(options.installationId) } : {}, - { - log: log2, - oauthApp: (0, import_auth_oauth_app.createOAuthAppAuth)({ - clientType: "github-app", - clientId: options.clientId || "", - clientSecret: options.clientSecret || "", - request - }) + async __incrementReservoir__(incr) { + var reservoir; + await this.yieldLoop(); + reservoir = this.storeOptions.reservoir += incr; + this.instance._drainAll(this.computeCapacity()); + return reservoir; + } + async __currentReservoir__() { + await this.yieldLoop(); + return this.storeOptions.reservoir; + } + isBlocked(now) { + return this._unblockTime >= now; + } + check(weight, now) { + return this.conditionsCheck(weight) && this._nextRequest - now <= 0; + } + async __check__(weight) { + var now; + await this.yieldLoop(); + now = Date.now(); + return this.check(weight, now); + } + async __register__(index2, weight, expiration) { + var now, wait; + await this.yieldLoop(); + now = Date.now(); + if (this.conditionsCheck(weight)) { + this._running += weight; + if (this.storeOptions.reservoir != null) { + this.storeOptions.reservoir -= weight; + } + wait = Math.max(this._nextRequest - now, 0); + this._nextRequest = now + wait + this.storeOptions.minTime; + return { + success: true, + wait, + reservoir: this.storeOptions.reservoir + }; + } else { + return { + success: false + }; + } + } + strategyIsBlock() { + return this.storeOptions.strategy === 3; + } + async __submit__(queueLength, weight) { + var blocked, now, reachedHWM; + await this.yieldLoop(); + if (this.storeOptions.maxConcurrent != null && weight > this.storeOptions.maxConcurrent) { + throw new BottleneckError$2(`Impossible to add a job having a weight of ${weight} to a limiter having a maxConcurrent setting of ${this.storeOptions.maxConcurrent}`); + } + now = Date.now(); + reachedHWM = this.storeOptions.highWater != null && queueLength === this.storeOptions.highWater && !this.check(weight, now); + blocked = this.strategyIsBlock() && (reachedHWM || this.isBlocked(now)); + if (blocked) { + this._unblockTime = now + this.computePenalty(); + this._nextRequest = this._unblockTime + this.storeOptions.minTime; + this.instance._dropAllQueued(); + } + return { + reachedHWM, + blocked, + strategy: this.storeOptions.strategy + }; + } + async __free__(index2, weight) { + await this.yieldLoop(); + this._running -= weight; + this._done += weight; + this.instance._drainAll(this.computeCapacity()); + return { + running: this._running + }; } - ); - return Object.assign(auth.bind(null, state), { - hook: hook.bind(null, state) - }); - } - } -}); - -// ../../../node_modules/.pnpm/@octokit+auth-unauthenticated@5.0.1/node_modules/@octokit/auth-unauthenticated/dist-node/index.js -var require_dist_node21 = __commonJS({ - "../../../node_modules/.pnpm/@octokit+auth-unauthenticated@5.0.1/node_modules/@octokit/auth-unauthenticated/dist-node/index.js"(exports2, module2) { - "use strict"; - var __defProp2 = Object.defineProperty; - var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; - var __getOwnPropNames2 = Object.getOwnPropertyNames; - var __hasOwnProp2 = Object.prototype.hasOwnProperty; - var __export2 = (target, all) => { - for (var name in all) - __defProp2(target, name, { get: all[name], enumerable: true }); - }; - var __copyProps2 = (to, from3, except, desc) => { - if (from3 && typeof from3 === "object" || typeof from3 === "function") { - for (let key of __getOwnPropNames2(from3)) - if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc2(from3, key)) || desc.enumerable }); - } - return to; - }; - var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); - var dist_src_exports = {}; - __export2(dist_src_exports, { - createUnauthenticatedAuth: () => createUnauthenticatedAuth - }); - module2.exports = __toCommonJS2(dist_src_exports); - async function auth(reason) { - return { - type: "unauthenticated", - reason }; - } - var import_request_error = require_dist_node4(); - function isRateLimitError(error) { - if (error.status !== 403) { - return false; - } - if (!error.response) { - return false; - } - return error.response.headers["x-ratelimit-remaining"] === "0"; - } - var import_request_error2 = require_dist_node4(); - var REGEX_ABUSE_LIMIT_MESSAGE = /\babuse\b/i; - function isAbuseLimitError(error) { - if (error.status !== 403) { - return false; - } - return REGEX_ABUSE_LIMIT_MESSAGE.test(error.message); - } - async function hook(reason, request, route, parameters) { - const endpoint = request.endpoint.merge( - route, - parameters - ); - return request(endpoint).catch((error) => { - if (error.status === 404) { - error.message = `Not found. May be due to lack of authentication. Reason: ${reason}`; - throw error; + var LocalDatastore_1 = LocalDatastore; + var BottleneckError$3, States; + BottleneckError$3 = BottleneckError_1; + States = class States { + constructor(status1) { + this.status = status1; + this._jobs = {}; + this.counts = this.status.map(function() { + return 0; + }); + } + next(id) { + var current, next; + current = this._jobs[id]; + next = current + 1; + if (current != null && next < this.status.length) { + this.counts[current]--; + this.counts[next]++; + return this._jobs[id]++; + } else if (current != null) { + this.counts[current]--; + return delete this._jobs[id]; + } } - if (isRateLimitError(error)) { - error.message = `API rate limit exceeded. This maybe caused by the lack of authentication. Reason: ${reason}`; - throw error; + start(id) { + var initial; + initial = 0; + this._jobs[id] = initial; + return this.counts[initial]++; } - if (isAbuseLimitError(error)) { - error.message = `You have triggered an abuse detection mechanism. This maybe caused by the lack of authentication. Reason: ${reason}`; - throw error; + remove(id) { + var current; + current = this._jobs[id]; + if (current != null) { + this.counts[current]--; + delete this._jobs[id]; + } + return current != null; } - if (error.status === 401) { - error.message = `Unauthorized. "${endpoint.method} ${endpoint.url}" failed most likely due to lack of authentication. Reason: ${reason}`; - throw error; + jobStatus(id) { + var ref; + return (ref = this.status[this._jobs[id]]) != null ? ref : null; } - if (error.status >= 400 && error.status < 500) { - error.message = error.message.replace( - /\.?$/, - `. May be caused by lack of authentication (${reason}).` - ); + statusJobs(status3) { + var k, pos, ref, results, v; + if (status3 != null) { + pos = this.status.indexOf(status3); + if (pos < 0) { + throw new BottleneckError$3(`status must be one of ${this.status.join(", ")}`); + } + ref = this._jobs; + results = []; + for (k in ref) { + v = ref[k]; + if (v === pos) { + results.push(k); + } + } + return results; + } else { + return Object.keys(this._jobs); + } } - throw error; - }); - } - var createUnauthenticatedAuth = function createUnauthenticatedAuth2(options) { - if (!options || !options.reason) { - throw new Error( - "[@octokit/auth-unauthenticated] No reason passed to createUnauthenticatedAuth" - ); - } - return Object.assign(auth.bind(null, options.reason), { - hook: hook.bind(null, options.reason) - }); - }; - } -}); - -// ../../../node_modules/.pnpm/@octokit+oauth-app@6.1.0/node_modules/@octokit/oauth-app/dist-node/index.js -var require_dist_node22 = __commonJS({ - "../../../node_modules/.pnpm/@octokit+oauth-app@6.1.0/node_modules/@octokit/oauth-app/dist-node/index.js"(exports2, module2) { - "use strict"; - var __create2 = Object.create; - var __defProp2 = Object.defineProperty; - var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; - var __getOwnPropNames2 = Object.getOwnPropertyNames; - var __getProtoOf2 = Object.getPrototypeOf; - var __hasOwnProp2 = Object.prototype.hasOwnProperty; - var __export2 = (target, all) => { - for (var name in all) - __defProp2(target, name, { get: all[name], enumerable: true }); - }; - var __copyProps2 = (to, from3, except, desc) => { - if (from3 && typeof from3 === "object" || typeof from3 === "function") { - for (let key of __getOwnPropNames2(from3)) - if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc2(from3, key)) || desc.enumerable }); - } - return to; - }; - var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2( - // If the importer is in node compatibility mode or this is not an ESM - // file that has been converted to a CommonJS file using a Babel- - // compatible transform (i.e. "__esModule" has not been set), then set - // "default" to the CommonJS "module.exports" for node compatibility. - isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target, - mod - )); - var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); - var dist_src_exports = {}; - __export2(dist_src_exports, { - OAuthApp: () => OAuthApp, - createAWSLambdaAPIGatewayV2Handler: () => createAWSLambdaAPIGatewayV2Handler, - createNodeMiddleware: () => createNodeMiddleware2, - createWebWorkerHandler: () => createWebWorkerHandler, - handleRequest: () => handleRequest, - sendNodeResponse: () => sendResponse, - unknownRouteResponse: () => unknownRouteResponse - }); - module2.exports = __toCommonJS2(dist_src_exports); - var import_auth_oauth_app = require_dist_node18(); - var VERSION = "6.1.0"; - function addEventHandler(state, eventName, eventHandler) { - if (Array.isArray(eventName)) { - for (const singleEventName of eventName) { - addEventHandler(state, singleEventName, eventHandler); + statusCounts() { + return this.counts.reduce((acc, v, i) => { + acc[this.status[i]] = v; + return acc; + }, {}); } - return; - } - if (!state.eventHandlers[eventName]) { - state.eventHandlers[eventName] = []; - } - state.eventHandlers[eventName].push(eventHandler); - } - var import_core = require_dist_node8(); - var import_universal_user_agent = require_dist_node(); - var OAuthAppOctokit = import_core.Octokit.defaults({ - userAgent: `octokit-oauth-app.js/${VERSION} ${(0, import_universal_user_agent.getUserAgent)()}` - }); - var import_auth_oauth_user = require_dist_node17(); - async function emitEvent(state, context2) { - const { name, action } = context2; - if (state.eventHandlers[`${name}.${action}`]) { - for (const eventHandler of state.eventHandlers[`${name}.${action}`]) { - await eventHandler(context2); + }; + var States_1 = States; + var DLList$2, Sync; + DLList$2 = DLList_1; + Sync = class Sync { + constructor(name, Promise2) { + this.schedule = this.schedule.bind(this); + this.name = name; + this.Promise = Promise2; + this._running = 0; + this._queue = new DLList$2(); } - } - if (state.eventHandlers[name]) { - for (const eventHandler of state.eventHandlers[name]) { - await eventHandler(context2); + isEmpty() { + return this._queue.length === 0; } - } - } - async function getUserOctokitWithState(state, options) { - return state.octokit.auth({ - type: "oauth-user", - ...options, - async factory(options2) { - const octokit = new state.Octokit({ - authStrategy: import_auth_oauth_user.createOAuthUserAuth, - auth: options2 - }); - const authentication = await octokit.auth({ - type: "get" - }); - await emitEvent(state, { - name: "token", - action: "created", - token: authentication.token, - scopes: authentication.scopes, - authentication, - octokit + async _tryToRun() { + var args, cb, error, reject, resolve, returned, task; + if (this._running < 1 && this._queue.length > 0) { + this._running++; + ({ task, args, resolve, reject } = this._queue.shift()); + cb = await async function() { + try { + returned = await task(...args); + return function() { + return resolve(returned); + }; + } catch (error1) { + error = error1; + return function() { + return reject(error); + }; + } + }(); + this._running--; + this._tryToRun(); + return cb(); + } + } + schedule(task, ...args) { + var promise, reject, resolve; + resolve = reject = null; + promise = new this.Promise(function(_resolve, _reject) { + resolve = _resolve; + return reject = _reject; }); - return octokit; + this._queue.push({ task, args, resolve, reject }); + this._tryToRun(); + return promise; } - }); - } - var OAuthMethods = __toESM2(require_dist_node15()); - function getWebFlowAuthorizationUrlWithState(state, options) { - const optionsWithDefaults = { - clientId: state.clientId, - request: state.octokit.request, - ...options, - allowSignup: state.allowSignup ?? options.allowSignup, - redirectUrl: options.redirectUrl ?? state.redirectUrl, - scopes: options.scopes ?? state.defaultScopes }; - return OAuthMethods.getWebFlowAuthorizationUrl({ - clientType: state.clientType, - ...optionsWithDefaults - }); - } - var OAuthAppAuth = __toESM2(require_dist_node18()); - async function createTokenWithState(state, options) { - const authentication = await state.octokit.auth({ - type: "oauth-user", - ...options + var Sync_1 = Sync; + var version3 = "2.19.5"; + var version$1 = { + version: version3 + }; + var version$2 = /* @__PURE__ */ Object.freeze({ + version: version3, + default: version$1 }); - await emitEvent(state, { - name: "token", - action: "created", - token: authentication.token, - scopes: authentication.scopes, - authentication, - octokit: new state.Octokit({ - authStrategy: OAuthAppAuth.createOAuthUserAuth, - auth: { - clientType: state.clientType, - clientId: state.clientId, - clientSecret: state.clientSecret, - token: authentication.token, - scopes: authentication.scopes, - refreshToken: authentication.refreshToken, - expiresAt: authentication.expiresAt, - refreshTokenExpiresAt: authentication.refreshTokenExpiresAt + var require$$2 = () => console.log("You must import the full version of Bottleneck in order to use this feature."); + var require$$3 = () => console.log("You must import the full version of Bottleneck in order to use this feature."); + var require$$4 = () => console.log("You must import the full version of Bottleneck in order to use this feature."); + var Events$2, Group, IORedisConnection$1, RedisConnection$1, Scripts$1, parser$3; + parser$3 = parser; + Events$2 = Events_1; + RedisConnection$1 = require$$2; + IORedisConnection$1 = require$$3; + Scripts$1 = require$$4; + Group = function() { + class Group2 { + constructor(limiterOptions = {}) { + this.deleteKey = this.deleteKey.bind(this); + this.limiterOptions = limiterOptions; + parser$3.load(this.limiterOptions, this.defaults, this); + this.Events = new Events$2(this); + this.instances = {}; + this.Bottleneck = Bottleneck_1; + this._startAutoCleanup(); + this.sharedConnection = this.connection != null; + if (this.connection == null) { + if (this.limiterOptions.datastore === "redis") { + this.connection = new RedisConnection$1(Object.assign({}, this.limiterOptions, { Events: this.Events })); + } else if (this.limiterOptions.datastore === "ioredis") { + this.connection = new IORedisConnection$1(Object.assign({}, this.limiterOptions, { Events: this.Events })); + } + } } - }) - }); - return { authentication }; - } - var OAuthMethods2 = __toESM2(require_dist_node15()); - async function checkTokenWithState(state, options) { - const result = await OAuthMethods2.checkToken({ - // @ts-expect-error not worth the extra code to appease TS - clientType: state.clientType, - clientId: state.clientId, - clientSecret: state.clientSecret, - request: state.octokit.request, - ...options - }); - Object.assign(result.authentication, { type: "token", tokenType: "oauth" }); - return result; - } - var OAuthMethods3 = __toESM2(require_dist_node15()); - var import_auth_oauth_user2 = require_dist_node17(); - async function resetTokenWithState(state, options) { - const optionsWithDefaults = { - clientId: state.clientId, - clientSecret: state.clientSecret, - request: state.octokit.request, - ...options - }; - if (state.clientType === "oauth-app") { - const response2 = await OAuthMethods3.resetToken({ - clientType: "oauth-app", - ...optionsWithDefaults - }); - const authentication2 = Object.assign(response2.authentication, { - type: "token", - tokenType: "oauth" - }); - await emitEvent(state, { - name: "token", - action: "reset", - token: response2.authentication.token, - scopes: response2.authentication.scopes || void 0, - authentication: authentication2, - octokit: new state.Octokit({ - authStrategy: import_auth_oauth_user2.createOAuthUserAuth, - auth: { - clientType: state.clientType, - clientId: state.clientId, - clientSecret: state.clientSecret, - token: response2.authentication.token, - scopes: response2.authentication.scopes + key(key = "") { + var ref; + return (ref = this.instances[key]) != null ? ref : (() => { + var limiter; + limiter = this.instances[key] = new this.Bottleneck(Object.assign(this.limiterOptions, { + id: `${this.id}-${key}`, + timeout: this.timeout, + connection: this.connection + })); + this.Events.trigger("created", limiter, key); + return limiter; + })(); + } + async deleteKey(key = "") { + var deleted, instance; + instance = this.instances[key]; + if (this.connection) { + deleted = await this.connection.__runCommand__(["del", ...Scripts$1.allKeys(`${this.id}-${key}`)]); + } + if (instance != null) { + delete this.instances[key]; + await instance.disconnect(); + } + return instance != null || deleted > 0; + } + limiters() { + var k, ref, results, v; + ref = this.instances; + results = []; + for (k in ref) { + v = ref[k]; + results.push({ + key: k, + limiter: v + }); + } + return results; + } + keys() { + return Object.keys(this.instances); + } + async clusterKeys() { + var cursor, end, found, i, k, keys, len, next, start; + if (this.connection == null) { + return this.Promise.resolve(this.keys()); + } + keys = []; + cursor = null; + start = `b_${this.id}-`.length; + end = "_settings".length; + while (cursor !== 0) { + [next, found] = await this.connection.__runCommand__(["scan", cursor != null ? cursor : 0, "match", `b_${this.id}-*_settings`, "count", 1e4]); + cursor = ~~next; + for (i = 0, len = found.length; i < len; i++) { + k = found[i]; + keys.push(k.slice(start, -end)); + } + } + return keys; + } + _startAutoCleanup() { + var base; + clearInterval(this.interval); + return typeof (base = this.interval = setInterval(async () => { + var e, k, ref, results, time, v; + time = Date.now(); + ref = this.instances; + results = []; + for (k in ref) { + v = ref[k]; + try { + if (await v._store.__groupCheck__(time)) { + results.push(this.deleteKey(k)); + } else { + results.push(void 0); + } + } catch (error) { + e = error; + results.push(v.Events.trigger("error", e)); + } + } + return results; + }, this.timeout / 2)).unref === "function" ? base.unref() : void 0; + } + updateSettings(options = {}) { + parser$3.overwrite(options, this.defaults, this); + parser$3.overwrite(options, options, this.limiterOptions); + if (options.timeout != null) { + return this._startAutoCleanup(); + } + } + disconnect(flush = true) { + var ref; + if (!this.sharedConnection) { + return (ref = this.connection) != null ? ref.disconnect(flush) : void 0; + } + } + } + Group2.prototype.defaults = { + timeout: 1e3 * 60 * 5, + connection: null, + Promise, + id: "group-key" + }; + return Group2; + }.call(commonjsGlobal); + var Group_1 = Group; + var Batcher, Events$3, parser$4; + parser$4 = parser; + Events$3 = Events_1; + Batcher = function() { + class Batcher2 { + constructor(options = {}) { + this.options = options; + parser$4.load(this.options, this.defaults, this); + this.Events = new Events$3(this); + this._arr = []; + this._resetPromise(); + this._lastFlush = Date.now(); + } + _resetPromise() { + return this._promise = new this.Promise((res, rej) => { + return this._resolve = res; + }); + } + _flush() { + clearTimeout(this._timeout); + this._lastFlush = Date.now(); + this._resolve(); + this.Events.trigger("batch", this._arr); + this._arr = []; + return this._resetPromise(); + } + add(data) { + var ret; + this._arr.push(data); + ret = this._promise; + if (this._arr.length === this.maxSize) { + this._flush(); + } else if (this.maxTime != null && this._arr.length === 1) { + this._timeout = setTimeout(() => { + return this._flush(); + }, this.maxTime); + } + return ret; + } + } + Batcher2.prototype.defaults = { + maxTime: null, + maxSize: null, + Promise + }; + return Batcher2; + }.call(commonjsGlobal); + var Batcher_1 = Batcher; + var require$$4$1 = () => console.log("You must import the full version of Bottleneck in order to use this feature."); + var require$$8 = getCjsExportFromNamespace(version$2); + var Bottleneck, DEFAULT_PRIORITY$1, Events$4, Job$1, LocalDatastore$1, NUM_PRIORITIES$1, Queues$1, RedisDatastore$1, States$1, Sync$1, parser$5, splice = [].splice; + NUM_PRIORITIES$1 = 10; + DEFAULT_PRIORITY$1 = 5; + parser$5 = parser; + Queues$1 = Queues_1; + Job$1 = Job_1; + LocalDatastore$1 = LocalDatastore_1; + RedisDatastore$1 = require$$4$1; + Events$4 = Events_1; + States$1 = States_1; + Sync$1 = Sync_1; + Bottleneck = function() { + class Bottleneck2 { + constructor(options = {}, ...invalid) { + var storeInstanceOptions, storeOptions; + this._addToQueue = this._addToQueue.bind(this); + this._validateOptions(options, invalid); + parser$5.load(options, this.instanceDefaults, this); + this._queues = new Queues$1(NUM_PRIORITIES$1); + this._scheduled = {}; + this._states = new States$1(["RECEIVED", "QUEUED", "RUNNING", "EXECUTING"].concat(this.trackDoneStatus ? ["DONE"] : [])); + this._limiter = null; + this.Events = new Events$4(this); + this._submitLock = new Sync$1("submit", this.Promise); + this._registerLock = new Sync$1("register", this.Promise); + storeOptions = parser$5.load(options, this.storeDefaults, {}); + this._store = function() { + if (this.datastore === "redis" || this.datastore === "ioredis" || this.connection != null) { + storeInstanceOptions = parser$5.load(options, this.redisStoreDefaults, {}); + return new RedisDatastore$1(this, storeOptions, storeInstanceOptions); + } else if (this.datastore === "local") { + storeInstanceOptions = parser$5.load(options, this.localStoreDefaults, {}); + return new LocalDatastore$1(this, storeOptions, storeInstanceOptions); + } else { + throw new Bottleneck2.prototype.BottleneckError(`Invalid datastore type: ${this.datastore}`); + } + }.call(this); + this._queues.on("leftzero", () => { + var ref; + return (ref = this._store.heartbeat) != null ? typeof ref.ref === "function" ? ref.ref() : void 0 : void 0; + }); + this._queues.on("zero", () => { + var ref; + return (ref = this._store.heartbeat) != null ? typeof ref.unref === "function" ? ref.unref() : void 0 : void 0; + }); + } + _validateOptions(options, invalid) { + if (!(options != null && typeof options === "object" && invalid.length === 0)) { + throw new Bottleneck2.prototype.BottleneckError("Bottleneck v2 takes a single object argument. Refer to https://github.com/SGrondin/bottleneck#upgrading-to-v2 if you're upgrading from Bottleneck v1."); } - }) - }); - return { ...response2, authentication: authentication2 }; - } - const response = await OAuthMethods3.resetToken({ - clientType: "github-app", - ...optionsWithDefaults - }); - const authentication = Object.assign(response.authentication, { - type: "token", - tokenType: "oauth" - }); - await emitEvent(state, { - name: "token", - action: "reset", - token: response.authentication.token, - authentication, - octokit: new state.Octokit({ - authStrategy: import_auth_oauth_user2.createOAuthUserAuth, - auth: { - clientType: state.clientType, - clientId: state.clientId, - clientSecret: state.clientSecret, - token: response.authentication.token } - }) - }); - return { ...response, authentication }; - } - var OAuthMethods4 = __toESM2(require_dist_node15()); - var import_auth_oauth_user3 = require_dist_node17(); - async function refreshTokenWithState(state, options) { - if (state.clientType === "oauth-app") { - throw new Error( - "[@octokit/oauth-app] app.refreshToken() is not supported for OAuth Apps" - ); - } - const response = await OAuthMethods4.refreshToken({ - clientType: "github-app", - clientId: state.clientId, - clientSecret: state.clientSecret, - request: state.octokit.request, - refreshToken: options.refreshToken - }); - const authentication = Object.assign(response.authentication, { - type: "token", - tokenType: "oauth" - }); - await emitEvent(state, { - name: "token", - action: "refreshed", - token: response.authentication.token, - authentication, - octokit: new state.Octokit({ - authStrategy: import_auth_oauth_user3.createOAuthUserAuth, - auth: { - clientType: state.clientType, - clientId: state.clientId, - clientSecret: state.clientSecret, - token: response.authentication.token + ready() { + return this._store.ready; } - }) - }); - return { ...response, authentication }; - } - var OAuthMethods5 = __toESM2(require_dist_node15()); - var import_auth_oauth_user4 = require_dist_node17(); - async function scopeTokenWithState(state, options) { - if (state.clientType === "oauth-app") { - throw new Error( - "[@octokit/oauth-app] app.scopeToken() is not supported for OAuth Apps" - ); - } - const response = await OAuthMethods5.scopeToken({ - clientType: "github-app", - clientId: state.clientId, - clientSecret: state.clientSecret, - request: state.octokit.request, - ...options - }); - const authentication = Object.assign(response.authentication, { - type: "token", - tokenType: "oauth" - }); - await emitEvent(state, { - name: "token", - action: "scoped", - token: response.authentication.token, - authentication, - octokit: new state.Octokit({ - authStrategy: import_auth_oauth_user4.createOAuthUserAuth, - auth: { - clientType: state.clientType, - clientId: state.clientId, - clientSecret: state.clientSecret, - token: response.authentication.token + clients() { + return this._store.clients; } - }) - }); - return { ...response, authentication }; - } - var OAuthMethods6 = __toESM2(require_dist_node15()); - var import_auth_unauthenticated = require_dist_node21(); - async function deleteTokenWithState(state, options) { - const optionsWithDefaults = { - clientId: state.clientId, - clientSecret: state.clientSecret, - request: state.octokit.request, - ...options - }; - const response = state.clientType === "oauth-app" ? await OAuthMethods6.deleteToken({ - clientType: "oauth-app", - ...optionsWithDefaults - }) : ( - // istanbul ignore next - await OAuthMethods6.deleteToken({ - clientType: "github-app", - ...optionsWithDefaults - }) - ); - await emitEvent(state, { - name: "token", - action: "deleted", - token: options.token, - octokit: new state.Octokit({ - authStrategy: import_auth_unauthenticated.createUnauthenticatedAuth, - auth: { - reason: `Handling "token.deleted" event. The access for the token has been revoked.` + channel() { + return `b_${this.id}`; } - }) - }); - return response; - } - var OAuthMethods7 = __toESM2(require_dist_node15()); - var import_auth_unauthenticated2 = require_dist_node21(); - async function deleteAuthorizationWithState(state, options) { - const optionsWithDefaults = { - clientId: state.clientId, - clientSecret: state.clientSecret, - request: state.octokit.request, - ...options - }; - const response = state.clientType === "oauth-app" ? await OAuthMethods7.deleteAuthorization({ - clientType: "oauth-app", - ...optionsWithDefaults - }) : ( - // istanbul ignore next - await OAuthMethods7.deleteAuthorization({ - clientType: "github-app", - ...optionsWithDefaults - }) - ); - await emitEvent(state, { - name: "token", - action: "deleted", - token: options.token, - octokit: new state.Octokit({ - authStrategy: import_auth_unauthenticated2.createUnauthenticatedAuth, - auth: { - reason: `Handling "token.deleted" event. The access for the token has been revoked.` + channel_client() { + return `b_${this.id}_${this._store.clientId}`; } - }) - }); - await emitEvent(state, { - name: "authorization", - action: "deleted", - token: options.token, - octokit: new state.Octokit({ - authStrategy: import_auth_unauthenticated2.createUnauthenticatedAuth, - auth: { - reason: `Handling "authorization.deleted" event. The access for the app has been revoked.` + publish(message) { + return this._store.__publish__(message); } - }) - }); - return response; - } - function unknownRouteResponse(request) { - return { - status: 404, - headers: { "content-type": "application/json" }, - text: JSON.stringify({ - error: `Unknown route: ${request.method} ${request.url}` - }) - }; - } - async function handleRequest(app, { pathPrefix = "/api/github/oauth" }, request) { - if (request.method === "OPTIONS") { - return { - status: 200, - headers: { - "access-control-allow-origin": "*", - "access-control-allow-methods": "*", - "access-control-allow-headers": "Content-Type, User-Agent, Authorization" + disconnect(flush = true) { + return this._store.__disconnect__(flush); } - }; - } - let { pathname } = new URL(request.url, "http://localhost"); - if (!pathname.startsWith(`${pathPrefix}/`)) { - return void 0; - } - pathname = pathname.slice(pathPrefix.length + 1); - const route = [request.method, pathname].join(" "); - const routes = { - getLogin: `GET login`, - getCallback: `GET callback`, - createToken: `POST token`, - getToken: `GET token`, - patchToken: `PATCH token`, - patchRefreshToken: `PATCH refresh-token`, - scopeToken: `POST token/scoped`, - deleteToken: `DELETE token`, - deleteGrant: `DELETE grant` - }; - if (!Object.values(routes).includes(route)) { - return unknownRouteResponse(request); - } - let json; - try { - const text = await request.text(); - json = text ? JSON.parse(text) : {}; - } catch (error) { - return { - status: 400, - headers: { - "content-type": "application/json", - "access-control-allow-origin": "*" - }, - text: JSON.stringify({ - error: "[@octokit/oauth-app] request error" - }) - }; - } - const { searchParams } = new URL(request.url, "http://localhost"); - const query = Object.fromEntries(searchParams); - const headers = request.headers; - try { - if (route === routes.getLogin) { - const { url } = app.getWebFlowAuthorizationUrl({ - state: query.state, - scopes: query.scopes ? query.scopes.split(",") : void 0, - allowSignup: query.allowSignup ? query.allowSignup === "true" : void 0, - redirectUrl: query.redirectUrl - }); - return { status: 302, headers: { location: url } }; - } - if (route === routes.getCallback) { - if (query.error) { - throw new Error( - `[@octokit/oauth-app] ${query.error} ${query.error_description}` - ); + chain(_limiter) { + this._limiter = _limiter; + return this; } - if (!query.code) { - throw new Error('[@octokit/oauth-app] "code" parameter is required'); + queued(priority) { + return this._queues.queued(priority); } - const { - authentication: { token: token2 } - } = await app.createToken({ - code: query.code - }); - return { - status: 200, - headers: { - "content-type": "text/html" - }, - text: `

Token created successfully

- -

Your token is: ${token2}. Copy it now as it cannot be shown again.

` - }; - } - if (route === routes.createToken) { - const { code, redirectUrl } = json; - if (!code) { - throw new Error('[@octokit/oauth-app] "code" parameter is required'); + clusterQueued() { + return this._store.__queued__(); } - const result = await app.createToken({ - code, - redirectUrl - }); - delete result.authentication.clientSecret; - return { - status: 201, - headers: { - "content-type": "application/json", - "access-control-allow-origin": "*" - }, - text: JSON.stringify(result) - }; - } - if (route === routes.getToken) { - const token2 = headers.authorization?.substr("token ".length); - if (!token2) { - throw new Error( - '[@octokit/oauth-app] "Authorization" header is required' - ); + empty() { + return this.queued() === 0 && this._submitLock.isEmpty(); } - const result = await app.checkToken({ - token: token2 - }); - delete result.authentication.clientSecret; - return { - status: 200, - headers: { - "content-type": "application/json", - "access-control-allow-origin": "*" - }, - text: JSON.stringify(result) - }; - } - if (route === routes.patchToken) { - const token2 = headers.authorization?.substr("token ".length); - if (!token2) { - throw new Error( - '[@octokit/oauth-app] "Authorization" header is required' - ); + running() { + return this._store.__running__(); } - const result = await app.resetToken({ token: token2 }); - delete result.authentication.clientSecret; - return { - status: 200, - headers: { - "content-type": "application/json", - "access-control-allow-origin": "*" - }, - text: JSON.stringify(result) - }; - } - if (route === routes.patchRefreshToken) { - const token2 = headers.authorization?.substr("token ".length); - if (!token2) { - throw new Error( - '[@octokit/oauth-app] "Authorization" header is required' - ); + done() { + return this._store.__done__(); } - const { refreshToken: refreshToken2 } = json; - if (!refreshToken2) { - throw new Error( - "[@octokit/oauth-app] refreshToken must be sent in request body" - ); + jobStatus(id) { + return this._states.jobStatus(id); + } + jobs(status3) { + return this._states.statusJobs(status3); + } + counts() { + return this._states.statusCounts(); + } + _randomIndex() { + return Math.random().toString(36).slice(2); + } + check(weight = 1) { + return this._store.__check__(weight); + } + _clearGlobalState(index2) { + if (this._scheduled[index2] != null) { + clearTimeout(this._scheduled[index2].expiration); + delete this._scheduled[index2]; + return true; + } else { + return false; + } + } + async _free(index2, job, options, eventInfo) { + var e, running; + try { + ({ running } = await this._store.__free__(index2, options.weight)); + this.Events.trigger("debug", `Freed ${options.id}`, eventInfo); + if (running === 0 && this.empty()) { + return this.Events.trigger("idle"); + } + } catch (error1) { + e = error1; + return this.Events.trigger("error", e); + } + } + _run(index2, job, wait) { + var clearGlobalState, free, run2; + job.doRun(); + clearGlobalState = this._clearGlobalState.bind(this, index2); + run2 = this._run.bind(this, index2, job); + free = this._free.bind(this, index2, job); + return this._scheduled[index2] = { + timeout: setTimeout(() => { + return job.doExecute(this._limiter, clearGlobalState, run2, free); + }, wait), + expiration: job.options.expiration != null ? setTimeout(function() { + return job.doExpire(clearGlobalState, run2, free); + }, wait + job.options.expiration) : void 0, + job + }; + } + _drainOne(capacity) { + return this._registerLock.schedule(() => { + var args, index2, next, options, queue; + if (this.queued() === 0) { + return this.Promise.resolve(null); + } + queue = this._queues.getFirst(); + ({ options, args } = next = queue.first()); + if (capacity != null && options.weight > capacity) { + return this.Promise.resolve(null); + } + this.Events.trigger("debug", `Draining ${options.id}`, { args, options }); + index2 = this._randomIndex(); + return this._store.__register__(index2, options.weight, options.expiration).then(({ success, wait, reservoir }) => { + var empty; + this.Events.trigger("debug", `Drained ${options.id}`, { success, args, options }); + if (success) { + queue.shift(); + empty = this.empty(); + if (empty) { + this.Events.trigger("empty"); + } + if (reservoir === 0) { + this.Events.trigger("depleted", empty); + } + this._run(index2, next, wait); + return this.Promise.resolve(options.weight); + } else { + return this.Promise.resolve(null); + } + }); + }); + } + _drainAll(capacity, total = 0) { + return this._drainOne(capacity).then((drained) => { + var newCapacity; + if (drained != null) { + newCapacity = capacity != null ? capacity - drained : capacity; + return this._drainAll(newCapacity, total + drained); + } else { + return this.Promise.resolve(total); + } + }).catch((e) => { + return this.Events.trigger("error", e); + }); + } + _dropAllQueued(message) { + return this._queues.shiftAll(function(job) { + return job.doDrop({ message }); + }); + } + stop(options = {}) { + var done, waitForExecuting; + options = parser$5.load(options, this.stopDefaults); + waitForExecuting = (at) => { + var finished; + finished = () => { + var counts; + counts = this._states.counts; + return counts[0] + counts[1] + counts[2] + counts[3] === at; + }; + return new this.Promise((resolve, reject) => { + if (finished()) { + return resolve(); + } else { + return this.on("done", () => { + if (finished()) { + this.removeAllListeners("done"); + return resolve(); + } + }); + } + }); + }; + done = options.dropWaitingJobs ? (this._run = function(index2, next) { + return next.doDrop({ + message: options.dropErrorMessage + }); + }, this._drainOne = () => { + return this.Promise.resolve(null); + }, this._registerLock.schedule(() => { + return this._submitLock.schedule(() => { + var k, ref, v; + ref = this._scheduled; + for (k in ref) { + v = ref[k]; + if (this.jobStatus(v.job.options.id) === "RUNNING") { + clearTimeout(v.timeout); + clearTimeout(v.expiration); + v.job.doDrop({ + message: options.dropErrorMessage + }); + } + } + this._dropAllQueued(options.dropErrorMessage); + return waitForExecuting(0); + }); + })) : this.schedule({ + priority: NUM_PRIORITIES$1 - 1, + weight: 0 + }, () => { + return waitForExecuting(1); + }); + this._receive = function(job) { + return job._reject(new Bottleneck2.prototype.BottleneckError(options.enqueueErrorMessage)); + }; + this.stop = () => { + return this.Promise.reject(new Bottleneck2.prototype.BottleneckError("stop() has already been called")); + }; + return done; } - const result = await app.refreshToken({ refreshToken: refreshToken2 }); - delete result.authentication.clientSecret; - return { - status: 200, - headers: { - "content-type": "application/json", - "access-control-allow-origin": "*" - }, - text: JSON.stringify(result) - }; - } - if (route === routes.scopeToken) { - const token2 = headers.authorization?.substr("token ".length); - if (!token2) { - throw new Error( - '[@octokit/oauth-app] "Authorization" header is required' - ); + async _addToQueue(job) { + var args, blocked, error, options, reachedHWM, shifted, strategy; + ({ args, options } = job); + try { + ({ reachedHWM, blocked, strategy } = await this._store.__submit__(this.queued(), options.weight)); + } catch (error1) { + error = error1; + this.Events.trigger("debug", `Could not queue ${options.id}`, { args, options, error }); + job.doDrop({ error }); + return false; + } + if (blocked) { + job.doDrop(); + return true; + } else if (reachedHWM) { + shifted = strategy === Bottleneck2.prototype.strategy.LEAK ? this._queues.shiftLastFrom(options.priority) : strategy === Bottleneck2.prototype.strategy.OVERFLOW_PRIORITY ? this._queues.shiftLastFrom(options.priority + 1) : strategy === Bottleneck2.prototype.strategy.OVERFLOW ? job : void 0; + if (shifted != null) { + shifted.doDrop(); + } + if (shifted == null || strategy === Bottleneck2.prototype.strategy.OVERFLOW) { + if (shifted == null) { + job.doDrop(); + } + return reachedHWM; + } + } + job.doQueue(reachedHWM, blocked); + this._queues.push(job); + await this._drainAll(); + return reachedHWM; } - const result = await app.scopeToken({ - token: token2, - ...json - }); - delete result.authentication.clientSecret; - return { - status: 200, - headers: { - "content-type": "application/json", - "access-control-allow-origin": "*" - }, - text: JSON.stringify(result) - }; - } - if (route === routes.deleteToken) { - const token2 = headers.authorization?.substr("token ".length); - if (!token2) { - throw new Error( - '[@octokit/oauth-app] "Authorization" header is required' - ); + _receive(job) { + if (this._states.jobStatus(job.options.id) != null) { + job._reject(new Bottleneck2.prototype.BottleneckError(`A job with the same id already exists (id=${job.options.id})`)); + return false; + } else { + job.doReceive(); + return this._submitLock.schedule(this._addToQueue, job); + } } - await app.deleteToken({ - token: token2 - }); - return { - status: 204, - headers: { "access-control-allow-origin": "*" } - }; - } - const token = headers.authorization?.substr("token ".length); - if (!token) { - throw new Error( - '[@octokit/oauth-app] "Authorization" header is required' - ); - } - await app.deleteAuthorization({ - token - }); - return { - status: 204, - headers: { "access-control-allow-origin": "*" } - }; - } catch (error) { - return { - status: 400, - headers: { - "content-type": "application/json", - "access-control-allow-origin": "*" - }, - text: JSON.stringify({ error: error.message }) - }; - } - } - function parseRequest(request) { - const { method, url, headers } = request; - async function text() { - const text2 = await new Promise((resolve, reject) => { - let bodyChunks = []; - request.on("error", reject).on("data", (chunk) => bodyChunks.push(chunk)).on("end", () => resolve(Buffer.concat(bodyChunks).toString())); - }); - return text2; - } - return { method, url, headers, text }; - } - function sendResponse(octokitResponse, response) { - response.writeHead(octokitResponse.status, octokitResponse.headers); - response.end(octokitResponse.text); - } - function createNodeMiddleware2(app, options = {}) { - return async function(request, response, next) { - const octokitRequest = await parseRequest(request); - const octokitResponse = await handleRequest(app, options, octokitRequest); - if (octokitResponse) { - sendResponse(octokitResponse, response); - return true; - } else { - next?.(); - return false; - } - }; - } - function parseRequest2(request) { - const headers = Object.fromEntries(request.headers.entries()); - return { - method: request.method, - url: request.url, - headers, - text: () => request.text() - }; - } - function sendResponse2(octokitResponse) { - return new Response(octokitResponse.text, { - status: octokitResponse.status, - headers: octokitResponse.headers - }); - } - function createWebWorkerHandler(app, options = {}) { - return async function(request) { - const octokitRequest = await parseRequest2(request); - const octokitResponse = await handleRequest(app, options, octokitRequest); - return octokitResponse ? sendResponse2(octokitResponse) : void 0; - }; - } - function parseRequest3(request) { - const { method } = request.requestContext.http; - let url = request.rawPath; - const { stage } = request.requestContext; - if (url.startsWith("/" + stage)) - url = url.substring(stage.length + 1); - if (request.rawQueryString) - url += "?" + request.rawQueryString; - const headers = request.headers; - const text = async () => request.body || ""; - return { method, url, headers, text }; - } - function sendResponse3(octokitResponse) { - return { - statusCode: octokitResponse.status, - headers: octokitResponse.headers, - body: octokitResponse.text - }; - } - function createAWSLambdaAPIGatewayV2Handler(app, options = {}) { - return async function(event) { - const request = parseRequest3(event); - const response = await handleRequest(app, options, request); - return response ? sendResponse3(response) : void 0; - }; - } - var OAuthApp = class { - static { - this.VERSION = VERSION; - } - static defaults(defaults) { - const OAuthAppWithDefaults = class extends this { - constructor(...args) { - super({ - ...defaults, - ...args[0] + submit(...args) { + var cb, fn, job, options, ref, ref1, task; + if (typeof args[0] === "function") { + ref = args, [fn, ...args] = ref, [cb] = splice.call(args, -1); + options = parser$5.load({}, this.jobDefaults); + } else { + ref1 = args, [options, fn, ...args] = ref1, [cb] = splice.call(args, -1); + options = parser$5.load(options, this.jobDefaults); + } + task = (...args2) => { + return new this.Promise(function(resolve, reject) { + return fn(...args2, function(...args3) { + return (args3[0] != null ? reject : resolve)(args3); + }); + }); + }; + job = new Job$1(task, args, options, this.jobDefaults, this.rejectOnDrop, this.Events, this._states, this.Promise); + job.promise.then(function(args2) { + return typeof cb === "function" ? cb(...args2) : void 0; + }).catch(function(args2) { + if (Array.isArray(args2)) { + return typeof cb === "function" ? cb(...args2) : void 0; + } else { + return typeof cb === "function" ? cb(args2) : void 0; + } }); + return this._receive(job); } - }; - return OAuthAppWithDefaults; - } - constructor(options) { - const Octokit2 = options.Octokit || OAuthAppOctokit; - this.type = options.clientType || "oauth-app"; - const octokit = new Octokit2({ - authStrategy: import_auth_oauth_app.createOAuthAppAuth, - auth: { - clientType: this.type, - clientId: options.clientId, - clientSecret: options.clientSecret - } - }); - const state = { - clientType: this.type, - clientId: options.clientId, - clientSecret: options.clientSecret, - // @ts-expect-error defaultScopes not permitted for GitHub Apps - defaultScopes: options.defaultScopes || [], - allowSignup: options.allowSignup, - baseUrl: options.baseUrl, - redirectUrl: options.redirectUrl, - log: options.log, - Octokit: Octokit2, - octokit, - eventHandlers: {} - }; - this.on = addEventHandler.bind(null, state); - this.octokit = octokit; - this.getUserOctokit = getUserOctokitWithState.bind(null, state); - this.getWebFlowAuthorizationUrl = getWebFlowAuthorizationUrlWithState.bind( - null, - state - ); - this.createToken = createTokenWithState.bind( - null, - state - ); - this.checkToken = checkTokenWithState.bind( - null, - state - ); - this.resetToken = resetTokenWithState.bind( - null, - state - ); - this.refreshToken = refreshTokenWithState.bind( - null, - state - ); - this.scopeToken = scopeTokenWithState.bind( - null, - state - ); - this.deleteToken = deleteTokenWithState.bind(null, state); - this.deleteAuthorization = deleteAuthorizationWithState.bind(null, state); - } - }; - } -}); - -// ../../../node_modules/.pnpm/indent-string@4.0.0/node_modules/indent-string/index.js -var require_indent_string = __commonJS({ - "../../../node_modules/.pnpm/indent-string@4.0.0/node_modules/indent-string/index.js"(exports2, module2) { - "use strict"; - module2.exports = (string, count = 1, options) => { - options = { - indent: " ", - includeEmptyLines: false, - ...options - }; - if (typeof string !== "string") { - throw new TypeError( - `Expected \`input\` to be a \`string\`, got \`${typeof string}\`` - ); - } - if (typeof count !== "number") { - throw new TypeError( - `Expected \`count\` to be a \`number\`, got \`${typeof count}\`` - ); - } - if (typeof options.indent !== "string") { - throw new TypeError( - `Expected \`options.indent\` to be a \`string\`, got \`${typeof options.indent}\`` - ); - } - if (count === 0) { - return string; - } - const regex = options.includeEmptyLines ? /^/gm : /^(?!\s*$)/gm; - return string.replace(regex, options.indent.repeat(count)); - }; - } -}); - -// ../../../node_modules/.pnpm/clean-stack@2.2.0/node_modules/clean-stack/index.js -var require_clean_stack = __commonJS({ - "../../../node_modules/.pnpm/clean-stack@2.2.0/node_modules/clean-stack/index.js"(exports2, module2) { - "use strict"; - var os = require("os"); - var extractPathRegex = /\s+at.*(?:\(|\s)(.*)\)?/; - var pathRegex = /^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:babel-polyfill|pirates)\/.*)?\w+)\.js:\d+:\d+)|native)/; - var homeDir = typeof os.homedir === "undefined" ? "" : os.homedir(); - module2.exports = (stack, options) => { - options = Object.assign({ pretty: false }, options); - return stack.replace(/\\/g, "/").split("\n").filter((line) => { - const pathMatches = line.match(extractPathRegex); - if (pathMatches === null || !pathMatches[1]) { - return true; - } - const match = pathMatches[1]; - if (match.includes(".app/Contents/Resources/electron.asar") || match.includes(".app/Contents/Resources/default_app.asar")) { - return false; - } - return !pathRegex.test(match); - }).filter((line) => line.trim() !== "").map((line) => { - if (options.pretty) { - return line.replace(extractPathRegex, (m, p1) => m.replace(p1, p1.replace(homeDir, "~"))); - } - return line; - }).join("\n"); - }; - } -}); - -// ../../../node_modules/.pnpm/aggregate-error@3.1.0/node_modules/aggregate-error/index.js -var require_aggregate_error = __commonJS({ - "../../../node_modules/.pnpm/aggregate-error@3.1.0/node_modules/aggregate-error/index.js"(exports2, module2) { - "use strict"; - var indentString = require_indent_string(); - var cleanStack = require_clean_stack(); - var cleanInternalStack = (stack) => stack.replace(/\s+at .*aggregate-error\/index.js:\d+:\d+\)?/g, ""); - var AggregateError = class extends Error { - constructor(errors) { - if (!Array.isArray(errors)) { - throw new TypeError(`Expected input to be an Array, got ${typeof errors}`); - } - errors = [...errors].map((error) => { - if (error instanceof Error) { - return error; + schedule(...args) { + var job, options, task; + if (typeof args[0] === "function") { + [task, ...args] = args; + options = {}; + } else { + [options, task, ...args] = args; + } + job = new Job$1(task, args, options, this.jobDefaults, this.rejectOnDrop, this.Events, this._states, this.Promise); + this._receive(job); + return job.promise; } - if (error !== null && typeof error === "object") { - return Object.assign(new Error(error.message), error); + wrap(fn) { + var schedule, wrapped; + schedule = this.schedule.bind(this); + wrapped = function(...args) { + return schedule(fn.bind(this), ...args); + }; + wrapped.withOptions = function(options, ...args) { + return schedule(options, fn, ...args); + }; + return wrapped; } - return new Error(error); - }); - let message = errors.map((error) => { - return typeof error.stack === "string" ? cleanInternalStack(cleanStack(error.stack)) : String(error); - }).join("\n"); - message = "\n" + indentString(message, 4); - super(message); - this.name = "AggregateError"; - Object.defineProperty(this, "_errors", { value: errors }); - } - *[Symbol.iterator]() { - for (const error of this._errors) { - yield error; - } - } - }; - module2.exports = AggregateError; - } -}); - -// ../../../node_modules/.pnpm/@octokit+webhooks-methods@4.1.0/node_modules/@octokit/webhooks-methods/dist-node/index.js -var require_dist_node23 = __commonJS({ - "../../../node_modules/.pnpm/@octokit+webhooks-methods@4.1.0/node_modules/@octokit/webhooks-methods/dist-node/index.js"(exports2, module2) { - "use strict"; - var __defProp2 = Object.defineProperty; - var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; - var __getOwnPropNames2 = Object.getOwnPropertyNames; - var __hasOwnProp2 = Object.prototype.hasOwnProperty; - var __export2 = (target, all) => { - for (var name in all) - __defProp2(target, name, { get: all[name], enumerable: true }); - }; - var __copyProps2 = (to, from3, except, desc) => { - if (from3 && typeof from3 === "object" || typeof from3 === "function") { - for (let key of __getOwnPropNames2(from3)) - if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc2(from3, key)) || desc.enumerable }); - } - return to; - }; - var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); - var dist_src_exports = {}; - __export2(dist_src_exports, { - sign: () => sign, - verify: () => verify, - verifyWithFallback: () => verifyWithFallback - }); - module2.exports = __toCommonJS2(dist_src_exports); - var import_node_crypto = require("node:crypto"); - var Algorithm = /* @__PURE__ */ ((Algorithm2) => { - Algorithm2["SHA1"] = "sha1"; - Algorithm2["SHA256"] = "sha256"; - return Algorithm2; - })(Algorithm || {}); - var VERSION = "4.1.0"; - async function sign(options, payload) { - const { secret, algorithm } = typeof options === "object" ? { - secret: options.secret, - algorithm: options.algorithm || Algorithm.SHA256 - } : { secret: options, algorithm: Algorithm.SHA256 }; - if (!secret || !payload) { - throw new TypeError( - "[@octokit/webhooks-methods] secret & payload required for sign()" - ); - } - if (typeof payload !== "string") { - throw new TypeError("[@octokit/webhooks-methods] payload must be a string"); - } - if (!Object.values(Algorithm).includes(algorithm)) { - throw new TypeError( - `[@octokit/webhooks] Algorithm ${algorithm} is not supported. Must be 'sha1' or 'sha256'` - ); - } - return `${algorithm}=${(0, import_node_crypto.createHmac)(algorithm, secret).update(payload).digest("hex")}`; - } - sign.VERSION = VERSION; - var import_node_crypto2 = require("node:crypto"); - var import_node_buffer = require("node:buffer"); - var getAlgorithm = (signature) => { - return signature.startsWith("sha256=") ? "sha256" : "sha1"; - }; - async function verify(secret, eventPayload, signature) { - if (!secret || !eventPayload || !signature) { - throw new TypeError( - "[@octokit/webhooks-methods] secret, eventPayload & signature required" - ); - } - if (typeof eventPayload !== "string") { - throw new TypeError( - "[@octokit/webhooks-methods] eventPayload must be a string" - ); - } - const signatureBuffer = import_node_buffer.Buffer.from(signature); - const algorithm = getAlgorithm(signature); - const verificationBuffer = import_node_buffer.Buffer.from( - await sign({ secret, algorithm }, eventPayload) - ); - if (signatureBuffer.length !== verificationBuffer.length) { - return false; - } - return (0, import_node_crypto2.timingSafeEqual)(signatureBuffer, verificationBuffer); - } - verify.VERSION = VERSION; - async function verifyWithFallback(secret, payload, signature, additionalSecrets) { - const firstPass = await verify(secret, payload, signature); - if (firstPass) { - return true; - } - if (additionalSecrets !== void 0) { - for (const s of additionalSecrets) { - const v = await verify(s, payload, signature); - if (v) { - return v; + async updateSettings(options = {}) { + await this._store.__updateSettings__(parser$5.overwrite(options, this.storeDefaults)); + parser$5.overwrite(options, this.instanceDefaults, this); + return this; + } + currentReservoir() { + return this._store.__currentReservoir__(); + } + incrementReservoir(incr = 0) { + return this._store.__incrementReservoir__(incr); } } - } - return false; - } + Bottleneck2.default = Bottleneck2; + Bottleneck2.Events = Events$4; + Bottleneck2.version = Bottleneck2.prototype.version = require$$8.version; + Bottleneck2.strategy = Bottleneck2.prototype.strategy = { + LEAK: 1, + OVERFLOW: 2, + OVERFLOW_PRIORITY: 4, + BLOCK: 3 + }; + Bottleneck2.BottleneckError = Bottleneck2.prototype.BottleneckError = BottleneckError_1; + Bottleneck2.Group = Bottleneck2.prototype.Group = Group_1; + Bottleneck2.RedisConnection = Bottleneck2.prototype.RedisConnection = require$$2; + Bottleneck2.IORedisConnection = Bottleneck2.prototype.IORedisConnection = require$$3; + Bottleneck2.Batcher = Bottleneck2.prototype.Batcher = Batcher_1; + Bottleneck2.prototype.jobDefaults = { + priority: DEFAULT_PRIORITY$1, + weight: 1, + expiration: null, + id: "" + }; + Bottleneck2.prototype.storeDefaults = { + maxConcurrent: null, + minTime: 0, + highWater: null, + strategy: Bottleneck2.prototype.strategy.LEAK, + penalty: null, + reservoir: null, + reservoirRefreshInterval: null, + reservoirRefreshAmount: null, + reservoirIncreaseInterval: null, + reservoirIncreaseAmount: null, + reservoirIncreaseMaximum: null + }; + Bottleneck2.prototype.localStoreDefaults = { + Promise, + timeout: null, + heartbeatInterval: 250 + }; + Bottleneck2.prototype.redisStoreDefaults = { + Promise, + timeout: null, + heartbeatInterval: 5e3, + clientTimeout: 1e4, + Redis: null, + clientOptions: {}, + clusterNodes: null, + clearDatastore: false, + connection: null + }; + Bottleneck2.prototype.instanceDefaults = { + datastore: "local", + connection: null, + id: "", + rejectOnDrop: true, + trackDoneStatus: false, + Promise + }; + Bottleneck2.prototype.stopDefaults = { + enqueueErrorMessage: "This limiter has been stopped and cannot accept new jobs.", + dropWaitingJobs: true, + dropErrorMessage: "This limiter has been stopped." + }; + return Bottleneck2; + }.call(commonjsGlobal); + var Bottleneck_1 = Bottleneck; + var lib = Bottleneck_1; + return lib; + }); } }); -// ../../../node_modules/.pnpm/@octokit+webhooks@12.2.0/node_modules/@octokit/webhooks/dist-node/index.js -var require_dist_node24 = __commonJS({ - "../../../node_modules/.pnpm/@octokit+webhooks@12.2.0/node_modules/@octokit/webhooks/dist-node/index.js"(exports2, module2) { +// ../../../node_modules/.pnpm/@octokit+plugin-retry@6.0.1_@octokit+core@5.2.0/node_modules/@octokit/plugin-retry/dist-node/index.js +var require_dist_node12 = __commonJS({ + "../../../node_modules/.pnpm/@octokit+plugin-retry@6.0.1_@octokit+core@5.2.0/node_modules/@octokit/plugin-retry/dist-node/index.js"(exports2, module2) { "use strict"; var __create2 = Object.create; var __defProp2 = Object.defineProperty; @@ -33101,11 +30712,11 @@ var require_dist_node24 = __commonJS({ for (var name in all) __defProp2(target, name, { get: all[name], enumerable: true }); }; - var __copyProps2 = (to, from3, except, desc) => { - if (from3 && typeof from3 === "object" || typeof from3 === "function") { - for (let key of __getOwnPropNames2(from3)) + var __copyProps2 = (to, from2, except, desc) => { + if (from2 && typeof from2 === "object" || typeof from2 === "function") { + for (let key of __getOwnPropNames2(from2)) if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc2(from3, key)) || desc.enumerable }); + __defProp2(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc2(from2, key)) || desc.enumerable }); } return to; }; @@ -33120,932 +30731,744 @@ var require_dist_node24 = __commonJS({ var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); var dist_src_exports = {}; __export2(dist_src_exports, { - Webhooks: () => Webhooks, - createEventHandler: () => createEventHandler, - createNodeMiddleware: () => createNodeMiddleware2, - emitterEventNames: () => emitterEventNames + VERSION: () => VERSION, + retry: () => retry }); module2.exports = __toCommonJS2(dist_src_exports); - var createLogger = (logger) => ({ - debug: () => { - }, - info: () => { - }, - warn: console.warn.bind(console), - error: console.error.bind(console), - ...logger - }); - var emitterEventNames = [ - "branch_protection_configuration", - "branch_protection_rule.disabled", - "branch_protection_rule.enabled", - "branch_protection_rule", - "branch_protection_rule.created", - "branch_protection_rule.deleted", - "branch_protection_rule.edited", - "check_run", - "check_run.completed", - "check_run.created", - "check_run.requested_action", - "check_run.rerequested", - "check_suite", - "check_suite.completed", - "check_suite.requested", - "check_suite.rerequested", - "code_scanning_alert", - "code_scanning_alert.appeared_in_branch", - "code_scanning_alert.closed_by_user", - "code_scanning_alert.created", - "code_scanning_alert.fixed", - "code_scanning_alert.reopened", - "code_scanning_alert.reopened_by_user", - "commit_comment", - "commit_comment.created", - "create", - "custom_property", - "custom_property.created", - "custom_property.deleted", - "custom_property_values", - "custom_property_values.updated", - "delete", - "dependabot_alert", - "dependabot_alert.created", - "dependabot_alert.dismissed", - "dependabot_alert.fixed", - "dependabot_alert.reintroduced", - "dependabot_alert.reopened", - "deploy_key", - "deploy_key.created", - "deploy_key.deleted", - "deployment", - "deployment.created", - "deployment_protection_rule", - "deployment_protection_rule.requested", - "deployment_review", - "deployment_review.approved", - "deployment_review.rejected", - "deployment_review.requested", - "deployment_status", - "deployment_status.created", - "discussion", - "discussion.answered", - "discussion.category_changed", - "discussion.created", - "discussion.deleted", - "discussion.edited", - "discussion.labeled", - "discussion.locked", - "discussion.pinned", - "discussion.transferred", - "discussion.unanswered", - "discussion.unlabeled", - "discussion.unlocked", - "discussion.unpinned", - "discussion_comment", - "discussion_comment.created", - "discussion_comment.deleted", - "discussion_comment.edited", - "fork", - "github_app_authorization", - "github_app_authorization.revoked", - "gollum", - "installation", - "installation.created", - "installation.deleted", - "installation.new_permissions_accepted", - "installation.suspend", - "installation.unsuspend", - "installation_repositories", - "installation_repositories.added", - "installation_repositories.removed", - "installation_target", - "installation_target.renamed", - "issue_comment", - "issue_comment.created", - "issue_comment.deleted", - "issue_comment.edited", - "issues", - "issues.assigned", - "issues.closed", - "issues.deleted", - "issues.demilestoned", - "issues.edited", - "issues.labeled", - "issues.locked", - "issues.milestoned", - "issues.opened", - "issues.pinned", - "issues.reopened", - "issues.transferred", - "issues.unassigned", - "issues.unlabeled", - "issues.unlocked", - "issues.unpinned", - "label", - "label.created", - "label.deleted", - "label.edited", - "marketplace_purchase", - "marketplace_purchase.cancelled", - "marketplace_purchase.changed", - "marketplace_purchase.pending_change", - "marketplace_purchase.pending_change_cancelled", - "marketplace_purchase.purchased", - "member", - "member.added", - "member.edited", - "member.removed", - "membership", - "membership.added", - "membership.removed", - "merge_group", - "merge_group.checks_requested", - "meta", - "meta.deleted", - "milestone", - "milestone.closed", - "milestone.created", - "milestone.deleted", - "milestone.edited", - "milestone.opened", - "org_block", - "org_block.blocked", - "org_block.unblocked", - "organization", - "organization.deleted", - "organization.member_added", - "organization.member_invited", - "organization.member_removed", - "organization.renamed", - "package", - "package.published", - "package.updated", - "page_build", - "ping", - "project", - "project.closed", - "project.created", - "project.deleted", - "project.edited", - "project.reopened", - "project_card", - "project_card.converted", - "project_card.created", - "project_card.deleted", - "project_card.edited", - "project_card.moved", - "project_column", - "project_column.created", - "project_column.deleted", - "project_column.edited", - "project_column.moved", - "projects_v2_item", - "projects_v2_item.archived", - "projects_v2_item.converted", - "projects_v2_item.created", - "projects_v2_item.deleted", - "projects_v2_item.edited", - "projects_v2_item.reordered", - "projects_v2_item.restored", - "public", - "pull_request", - "pull_request.assigned", - "pull_request.auto_merge_disabled", - "pull_request.auto_merge_enabled", - "pull_request.closed", - "pull_request.converted_to_draft", - "pull_request.demilestoned", - "pull_request.dequeued", - "pull_request.edited", - "pull_request.enqueued", - "pull_request.labeled", - "pull_request.locked", - "pull_request.milestoned", - "pull_request.opened", - "pull_request.ready_for_review", - "pull_request.reopened", - "pull_request.review_request_removed", - "pull_request.review_requested", - "pull_request.synchronize", - "pull_request.unassigned", - "pull_request.unlabeled", - "pull_request.unlocked", - "pull_request_review", - "pull_request_review.dismissed", - "pull_request_review.edited", - "pull_request_review.submitted", - "pull_request_review_comment", - "pull_request_review_comment.created", - "pull_request_review_comment.deleted", - "pull_request_review_comment.edited", - "pull_request_review_thread", - "pull_request_review_thread.resolved", - "pull_request_review_thread.unresolved", - "push", - "registry_package", - "registry_package.published", - "registry_package.updated", - "release", - "release.created", - "release.deleted", - "release.edited", - "release.prereleased", - "release.published", - "release.released", - "release.unpublished", - "repository", - "repository.archived", - "repository.created", - "repository.deleted", - "repository.edited", - "repository.privatized", - "repository.publicized", - "repository.renamed", - "repository.transferred", - "repository.unarchived", - "repository_dispatch", - "repository_import", - "repository_vulnerability_alert", - "repository_vulnerability_alert.create", - "repository_vulnerability_alert.dismiss", - "repository_vulnerability_alert.reopen", - "repository_vulnerability_alert.resolve", - "secret_scanning_alert", - "secret_scanning_alert.created", - "secret_scanning_alert.reopened", - "secret_scanning_alert.resolved", - "secret_scanning_alert.revoked", - "secret_scanning_alert_location", - "secret_scanning_alert_location.created", - "security_advisory", - "security_advisory.performed", - "security_advisory.published", - "security_advisory.updated", - "security_advisory.withdrawn", - "sponsorship", - "sponsorship.cancelled", - "sponsorship.created", - "sponsorship.edited", - "sponsorship.pending_cancellation", - "sponsorship.pending_tier_change", - "sponsorship.tier_changed", - "star", - "star.created", - "star.deleted", - "status", - "team", - "team.added_to_repository", - "team.created", - "team.deleted", - "team.edited", - "team.removed_from_repository", - "team_add", - "watch", - "watch.started", - "workflow_dispatch", - "workflow_job", - "workflow_job.completed", - "workflow_job.in_progress", - "workflow_job.queued", - "workflow_job.waiting", - "workflow_run", - "workflow_run.completed", - "workflow_run.in_progress", - "workflow_run.requested" - ]; - function handleEventHandlers(state, webhookName, handler) { - if (!state.hooks[webhookName]) { - state.hooks[webhookName] = []; - } - state.hooks[webhookName].push(handler); - } - function receiverOn(state, webhookNameOrNames, handler) { - if (Array.isArray(webhookNameOrNames)) { - webhookNameOrNames.forEach( - (webhookName) => receiverOn(state, webhookName, handler) - ); - return; - } - if (["*", "error"].includes(webhookNameOrNames)) { - const webhookName = webhookNameOrNames === "*" ? "any" : webhookNameOrNames; - const message = `Using the "${webhookNameOrNames}" event with the regular Webhooks.on() function is not supported. Please use the Webhooks.on${webhookName.charAt(0).toUpperCase() + webhookName.slice(1)}() method instead`; - throw new Error(message); - } - if (!emitterEventNames.includes(webhookNameOrNames)) { - state.log.warn( - `"${webhookNameOrNames}" is not a known webhook name (https://developer.github.com/v3/activity/events/types/)` - ); - } - handleEventHandlers(state, webhookNameOrNames, handler); - } - function receiverOnAny(state, handler) { - handleEventHandlers(state, "*", handler); - } - function receiverOnError(state, handler) { - handleEventHandlers(state, "error", handler); - } - var import_aggregate_error = __toESM2(require_aggregate_error()); - function wrapErrorHandler(handler, error) { - let returnValue; - try { - returnValue = handler(error); - } catch (error2) { - console.log('FATAL: Error occurred in "error" event handler'); - console.log(error2); - } - if (returnValue && returnValue.catch) { - returnValue.catch((error2) => { - console.log('FATAL: Error occurred in "error" event handler'); - console.log(error2); - }); + var import_core = require_dist_node8(); + async function errorRequest(state, octokit, error, options) { + if (!error.request || !error.request.request) { + throw error; } - } - function getHooks(state, eventPayloadAction, eventName) { - const hooks = [state.hooks[eventName], state.hooks["*"]]; - if (eventPayloadAction) { - hooks.unshift(state.hooks[`${eventName}.${eventPayloadAction}`]); + if (error.status >= 400 && !state.doNotRetry.includes(error.status)) { + const retries = options.request.retries != null ? options.request.retries : state.retries; + const retryAfter = Math.pow((options.request.retryCount || 0) + 1, 2); + throw octokit.retry.retryRequest(error, retries, retryAfter); } - return [].concat(...hooks.filter(Boolean)); + throw error; } - function receiverHandle(state, event) { - const errorHandlers = state.hooks.error || []; - if (event instanceof Error) { - const error = Object.assign(new import_aggregate_error.default([event]), { - event, - errors: [event] - }); - errorHandlers.forEach((handler) => wrapErrorHandler(handler, error)); - return Promise.reject(error); - } - if (!event || !event.name) { - throw new import_aggregate_error.default(["Event name not passed"]); - } - if (!event.payload) { - throw new import_aggregate_error.default(["Event payload not passed"]); - } - const hooks = getHooks( - state, - "action" in event.payload ? event.payload.action : null, - event.name - ); - if (hooks.length === 0) { - return Promise.resolve(); - } - const errors = []; - const promises = hooks.map((handler) => { - let promise = Promise.resolve(event); - if (state.transform) { - promise = promise.then(state.transform); - } - return promise.then((event2) => { - return handler(event2); - }).catch((error) => errors.push(Object.assign(error, { event }))); - }); - return Promise.all(promises).then(() => { - if (errors.length === 0) { - return; + var import_light = __toESM2(require_light()); + var import_request_error = require_dist_node4(); + async function wrapRequest(state, octokit, request, options) { + const limiter = new import_light.default(); + limiter.on("failed", function(error, info) { + const maxRetries2 = ~~error.request.request.retries; + const after = ~~error.request.request.retryAfter; + options.request.retryCount = info.retryCount + 1; + if (maxRetries2 > info.retryCount) { + return after * state.retryAfterBaseValue; } - const error = new import_aggregate_error.default(errors); - Object.assign(error, { - event, - errors - }); - errorHandlers.forEach((handler) => wrapErrorHandler(handler, error)); - throw error; }); - } - function removeListener(state, webhookNameOrNames, handler) { - if (Array.isArray(webhookNameOrNames)) { - webhookNameOrNames.forEach( - (webhookName) => removeListener(state, webhookName, handler) - ); - return; - } - if (!state.hooks[webhookNameOrNames]) { - return; - } - for (let i = state.hooks[webhookNameOrNames].length - 1; i >= 0; i--) { - if (state.hooks[webhookNameOrNames][i] === handler) { - state.hooks[webhookNameOrNames].splice(i, 1); - return; - } + return limiter.schedule( + requestWithGraphqlErrorHandling.bind(null, state, octokit, request), + options + ); + } + async function requestWithGraphqlErrorHandling(state, octokit, request, options) { + const response = await request(request, options); + if (response.data && response.data.errors && /Something went wrong while executing your query/.test( + response.data.errors[0].message + )) { + const error = new import_request_error.RequestError(response.data.errors[0].message, 500, { + request: options, + response + }); + return errorRequest(state, octokit, error, options); } + return response; } - function createEventHandler(options) { - const state = { - hooks: {}, - log: createLogger(options && options.log) - }; - if (options && options.transform) { - state.transform = options.transform; + var VERSION = "6.0.1"; + function retry(octokit, octokitOptions) { + const state = Object.assign( + { + enabled: true, + retryAfterBaseValue: 1e3, + doNotRetry: [400, 401, 403, 404, 422, 451], + retries: 3 + }, + octokitOptions.retry + ); + if (state.enabled) { + octokit.hook.error("request", errorRequest.bind(null, state, octokit)); + octokit.hook.wrap("request", wrapRequest.bind(null, state, octokit)); } return { - on: receiverOn.bind(null, state), - onAny: receiverOnAny.bind(null, state), - onError: receiverOnError.bind(null, state), - removeListener: removeListener.bind(null, state), - receive: receiverHandle.bind(null, state) + retry: { + retryRequest: (error, retries, retryAfter) => { + error.request.request = Object.assign({}, error.request.request, { + retries, + retryAfter + }); + return error; + } + } }; } - var import_webhooks_methods2 = require_dist_node23(); - var import_aggregate_error2 = __toESM2(require_aggregate_error()); - var import_webhooks_methods = require_dist_node23(); - async function verifyAndReceive(state, event) { - const matchesSignature = await (0, import_webhooks_methods.verify)( - state.secret, - event.payload, - event.signature - ).catch(() => false); - if (!matchesSignature) { - const error = new Error( - "[@octokit/webhooks] signature does not match event payload and secret" - ); - return state.eventHandler.receive( - Object.assign(error, { event, status: 400 }) - ); - } - let payload; - try { - payload = JSON.parse(event.payload); - } catch (error) { - error.message = "Invalid JSON"; - error.status = 400; - throw new import_aggregate_error2.default([error]); + retry.VERSION = VERSION; + } +}); + +// ../../../node_modules/.pnpm/@octokit+plugin-throttling@8.2.0_@octokit+core@5.2.0/node_modules/@octokit/plugin-throttling/dist-node/index.js +var require_dist_node13 = __commonJS({ + "../../../node_modules/.pnpm/@octokit+plugin-throttling@8.2.0_@octokit+core@5.2.0/node_modules/@octokit/plugin-throttling/dist-node/index.js"(exports2, module2) { + "use strict"; + var __create2 = Object.create; + var __defProp2 = Object.defineProperty; + var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; + var __getOwnPropNames2 = Object.getOwnPropertyNames; + var __getProtoOf2 = Object.getPrototypeOf; + var __hasOwnProp2 = Object.prototype.hasOwnProperty; + var __export2 = (target, all) => { + for (var name in all) + __defProp2(target, name, { get: all[name], enumerable: true }); + }; + var __copyProps2 = (to, from2, except, desc) => { + if (from2 && typeof from2 === "object" || typeof from2 === "function") { + for (let key of __getOwnPropNames2(from2)) + if (!__hasOwnProp2.call(to, key) && key !== except) + __defProp2(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc2(from2, key)) || desc.enumerable }); } - return state.eventHandler.receive({ - id: event.id, - name: event.name, - payload - }); - } - var WEBHOOK_HEADERS = [ - "x-github-event", - "x-hub-signature-256", - "x-github-delivery" - ]; - function getMissingHeaders(request) { - return WEBHOOK_HEADERS.filter((header) => !(header in request.headers)); + return to; + }; + var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target, + mod + )); + var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); + var dist_src_exports = {}; + __export2(dist_src_exports, { + throttling: () => throttling + }); + module2.exports = __toCommonJS2(dist_src_exports); + var import_light = __toESM2(require_light()); + var import_core = require_dist_node8(); + var VERSION = "8.2.0"; + var noop = () => Promise.resolve(); + function wrapRequest(state, request, options) { + return state.retryLimiter.schedule(doRequest, state, request, options); } - var import_aggregate_error3 = __toESM2(require_aggregate_error()); - function getPayload(request) { - if ("body" in request) { - if (typeof request.body === "object" && "rawBody" in request && request.rawBody instanceof Buffer) { - return Promise.resolve(request.rawBody.toString("utf8")); - } else { - return Promise.resolve(request.body); + async function doRequest(state, request, options) { + const isWrite = options.method !== "GET" && options.method !== "HEAD"; + const { pathname } = new URL(options.url, "http://github.test"); + const isSearch = options.method === "GET" && pathname.startsWith("/search/"); + const isGraphQL = pathname.startsWith("/graphql"); + const retryCount = ~~request.retryCount; + const jobOptions = retryCount > 0 ? { priority: 0, weight: 0 } : {}; + if (state.clustering) { + jobOptions.expiration = 1e3 * 60; + } + if (isWrite || isGraphQL) { + await state.write.key(state.id).schedule(jobOptions, noop); + } + if (isWrite && state.triggersNotification(pathname)) { + await state.notifications.key(state.id).schedule(jobOptions, noop); + } + if (isSearch) { + await state.search.key(state.id).schedule(jobOptions, noop); + } + const req = state.global.key(state.id).schedule(jobOptions, request, options); + if (isGraphQL) { + const res = await req; + if (res.data.errors != null && res.data.errors.some((error) => error.type === "RATE_LIMITED")) { + const error = Object.assign(new Error("GraphQL Rate Limit Exceeded"), { + response: res, + data: res.data + }); + throw error; } } - return new Promise((resolve, reject) => { - let data = []; - request.on("error", (error) => reject(new import_aggregate_error3.default([error]))); - request.on("data", (chunk) => data.push(chunk)); - request.on( - "end", - () => ( - // setImmediate improves the throughput by reducing the pressure from - // the event loop - setImmediate( - resolve, - data.length === 1 ? data[0].toString("utf8") : Buffer.concat(data).toString("utf8") - ) - ) - ); - }); + return req; } - function onUnhandledRequestDefault(request, response) { - response.writeHead(404, { - "content-type": "application/json" - }); - response.end( - JSON.stringify({ - error: `Unknown route: ${request.method} ${request.url}` - }) + var triggers_notification_paths_default = [ + "/orgs/{org}/invitations", + "/orgs/{org}/invitations/{invitation_id}", + "/orgs/{org}/teams/{team_slug}/discussions", + "/orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments", + "/repos/{owner}/{repo}/collaborators/{username}", + "/repos/{owner}/{repo}/commits/{commit_sha}/comments", + "/repos/{owner}/{repo}/issues", + "/repos/{owner}/{repo}/issues/{issue_number}/comments", + "/repos/{owner}/{repo}/pulls", + "/repos/{owner}/{repo}/pulls/{pull_number}/comments", + "/repos/{owner}/{repo}/pulls/{pull_number}/comments/{comment_id}/replies", + "/repos/{owner}/{repo}/pulls/{pull_number}/merge", + "/repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers", + "/repos/{owner}/{repo}/pulls/{pull_number}/reviews", + "/repos/{owner}/{repo}/releases", + "/teams/{team_id}/discussions", + "/teams/{team_id}/discussions/{discussion_number}/comments" + ]; + function routeMatcher(paths) { + const regexes = paths.map( + (path) => path.split("/").map((c) => c.startsWith("{") ? "(?:.+?)" : c).join("/") ); + const regex2 = `^(?:${regexes.map((r) => `(?:${r})`).join("|")})[^/]*$`; + return new RegExp(regex2, "i"); } - async function middleware(webhooks, options, request, response, next) { - let pathname; - try { - pathname = new URL(request.url, "http://localhost").pathname; - } catch (error) { - response.writeHead(422, { - "content-type": "application/json" - }); - response.end( - JSON.stringify({ - error: `Request URL could not be parsed: ${request.url}` - }) - ); - return true; - } - if (pathname !== options.path) { - next?.(); - return false; - } else if (request.method !== "POST") { - onUnhandledRequestDefault(request, response); - return true; - } - if (!request.headers["content-type"] || !request.headers["content-type"].startsWith("application/json")) { - response.writeHead(415, { - "content-type": "application/json", - accept: "application/json" - }); - response.end( - JSON.stringify({ - error: `Unsupported "Content-Type" header value. Must be "application/json"` - }) - ); - return true; + var regex = routeMatcher(triggers_notification_paths_default); + var triggersNotification = regex.test.bind(regex); + var groups = {}; + var createGroups = function(Bottleneck, common) { + groups.global = new Bottleneck.Group({ + id: "octokit-global", + maxConcurrent: 10, + ...common + }); + groups.search = new Bottleneck.Group({ + id: "octokit-search", + maxConcurrent: 1, + minTime: 2e3, + ...common + }); + groups.write = new Bottleneck.Group({ + id: "octokit-write", + maxConcurrent: 1, + minTime: 1e3, + ...common + }); + groups.notifications = new Bottleneck.Group({ + id: "octokit-notifications", + maxConcurrent: 1, + minTime: 3e3, + ...common + }); + }; + function throttling(octokit, octokitOptions) { + const { + enabled = true, + Bottleneck = import_light.default, + id = "no-id", + timeout = 1e3 * 60 * 2, + // Redis TTL: 2 minutes + connection + } = octokitOptions.throttle || {}; + if (!enabled) { + return {}; } - const missingHeaders = getMissingHeaders(request).join(", "); - if (missingHeaders) { - response.writeHead(400, { - "content-type": "application/json" - }); - response.end( - JSON.stringify({ - error: `Required headers missing: ${missingHeaders}` - }) - ); - return true; + const common = { connection, timeout }; + if (groups.global == null) { + createGroups(Bottleneck, common); } - const eventName = request.headers["x-github-event"]; - const signatureSHA256 = request.headers["x-hub-signature-256"]; - const id = request.headers["x-github-delivery"]; - options.log.debug(`${eventName} event received (id: ${id})`); - let didTimeout = false; - const timeout = setTimeout(() => { - didTimeout = true; - response.statusCode = 202; - response.end("still processing\n"); - }, 9e3).unref(); - try { - const payload = await getPayload(request); - await webhooks.verifyAndReceive({ + const state = Object.assign( + { + clustering: connection != null, + triggersNotification, + fallbackSecondaryRateRetryAfter: 60, + retryAfterBaseValue: 1e3, + retryLimiter: new Bottleneck(), id, - name: eventName, - payload, - signature: signatureSHA256 - }); - clearTimeout(timeout); - if (didTimeout) - return true; - response.end("ok\n"); - return true; - } catch (error) { - clearTimeout(timeout); - if (didTimeout) - return true; - const err = Array.from(error)[0]; - const errorMessage = err.message ? `${err.name}: ${err.message}` : "Error: An Unspecified error occurred"; - response.statusCode = typeof err.status !== "undefined" ? err.status : 500; - options.log.error(error); - response.end( - JSON.stringify({ - error: errorMessage - }) - ); - return true; + ...groups + }, + octokitOptions.throttle + ); + if (typeof state.onSecondaryRateLimit !== "function" || typeof state.onRateLimit !== "function") { + throw new Error(`octokit/plugin-throttling error: + You must pass the onSecondaryRateLimit and onRateLimit error handlers. + See https://octokit.github.io/rest.js/#throttling + + const octokit = new Octokit({ + throttle: { + onSecondaryRateLimit: (retryAfter, options) => {/* ... */}, + onRateLimit: (retryAfter, options) => {/* ... */} + } + }) + `); } - } - function createNodeMiddleware2(webhooks, { - path = "/api/github/webhooks", - log: log2 = createLogger() - } = {}) { - return middleware.bind(null, webhooks, { - path, - log: log2 + const events = {}; + const emitter = new Bottleneck.Events(events); + events.on("secondary-limit", state.onSecondaryRateLimit); + events.on("rate-limit", state.onRateLimit); + events.on( + "error", + (e) => octokit.log.warn("Error in throttling-plugin limit handler", e) + ); + state.retryLimiter.on("failed", async function(error, info) { + const [state2, request, options] = info.args; + const { pathname } = new URL(options.url, "http://github.test"); + const shouldRetryGraphQL = pathname.startsWith("/graphql") && error.status !== 401; + if (!(shouldRetryGraphQL || error.status === 403)) { + return; + } + const retryCount = ~~request.retryCount; + request.retryCount = retryCount; + options.request.retryCount = retryCount; + const { wantRetry, retryAfter = 0 } = await async function() { + if (/\bsecondary rate\b/i.test(error.message)) { + const retryAfter2 = Number(error.response.headers["retry-after"]) || state2.fallbackSecondaryRateRetryAfter; + const wantRetry2 = await emitter.trigger( + "secondary-limit", + retryAfter2, + options, + octokit, + retryCount + ); + return { wantRetry: wantRetry2, retryAfter: retryAfter2 }; + } + if (error.response.headers != null && error.response.headers["x-ratelimit-remaining"] === "0" || (error.response.data?.errors ?? []).some( + (error2) => error2.type === "RATE_LIMITED" + )) { + const rateLimitReset = new Date( + ~~error.response.headers["x-ratelimit-reset"] * 1e3 + ).getTime(); + const retryAfter2 = Math.max( + // Add one second so we retry _after_ the reset time + // https://docs.github.com/en/rest/overview/resources-in-the-rest-api?apiVersion=2022-11-28#exceeding-the-rate-limit + Math.ceil((rateLimitReset - Date.now()) / 1e3) + 1, + 0 + ); + const wantRetry2 = await emitter.trigger( + "rate-limit", + retryAfter2, + options, + octokit, + retryCount + ); + return { wantRetry: wantRetry2, retryAfter: retryAfter2 }; + } + return {}; + }(); + if (wantRetry) { + request.retryCount++; + return retryAfter * state2.retryAfterBaseValue; + } }); + octokit.hook.wrap("request", wrapRequest.bind(null, state)); + return {}; } - var Webhooks = class { - constructor(options) { - if (!options || !options.secret) { - throw new Error("[@octokit/webhooks] options.secret required"); - } - const state = { - eventHandler: createEventHandler(options), - secret: options.secret, - hooks: {}, - log: createLogger(options.log) - }; - this.sign = import_webhooks_methods2.sign.bind(null, options.secret); - this.verify = import_webhooks_methods2.verify.bind(null, options.secret); - this.on = state.eventHandler.on; - this.onAny = state.eventHandler.onAny; - this.onError = state.eventHandler.onError; - this.removeListener = state.eventHandler.removeListener; - this.receive = state.eventHandler.receive; - this.verifyAndReceive = verifyAndReceive.bind(null, state); + throttling.VERSION = VERSION; + throttling.triggersNotification = triggersNotification; + } +}); + +// ../../../node_modules/.pnpm/btoa-lite@1.0.0/node_modules/btoa-lite/btoa-node.js +var require_btoa_node = __commonJS({ + "../../../node_modules/.pnpm/btoa-lite@1.0.0/node_modules/btoa-lite/btoa-node.js"(exports2, module2) { + module2.exports = function btoa(str) { + return new Buffer(str).toString("base64"); + }; + } +}); + +// ../../../node_modules/.pnpm/@octokit+oauth-authorization-url@6.0.2/node_modules/@octokit/oauth-authorization-url/dist-node/index.js +var require_dist_node14 = __commonJS({ + "../../../node_modules/.pnpm/@octokit+oauth-authorization-url@6.0.2/node_modules/@octokit/oauth-authorization-url/dist-node/index.js"(exports2, module2) { + "use strict"; + var __defProp2 = Object.defineProperty; + var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; + var __getOwnPropNames2 = Object.getOwnPropertyNames; + var __hasOwnProp2 = Object.prototype.hasOwnProperty; + var __export2 = (target, all) => { + for (var name in all) + __defProp2(target, name, { get: all[name], enumerable: true }); + }; + var __copyProps2 = (to, from2, except, desc) => { + if (from2 && typeof from2 === "object" || typeof from2 === "function") { + for (let key of __getOwnPropNames2(from2)) + if (!__hasOwnProp2.call(to, key) && key !== except) + __defProp2(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc2(from2, key)) || desc.enumerable }); } + return to; }; + var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); + var dist_src_exports = {}; + __export2(dist_src_exports, { + oauthAuthorizationUrl: () => oauthAuthorizationUrl + }); + module2.exports = __toCommonJS2(dist_src_exports); + function oauthAuthorizationUrl(options) { + const clientType = options.clientType || "oauth-app"; + const baseUrl = options.baseUrl || "https://github.com"; + const result = { + clientType, + allowSignup: options.allowSignup === false ? false : true, + clientId: options.clientId, + login: options.login || null, + redirectUrl: options.redirectUrl || null, + state: options.state || Math.random().toString(36).substr(2), + url: "" + }; + if (clientType === "oauth-app") { + const scopes = "scopes" in options ? options.scopes : []; + result.scopes = typeof scopes === "string" ? scopes.split(/[,\s]+/).filter(Boolean) : scopes; + } + result.url = urlBuilderAuthorize(`${baseUrl}/login/oauth/authorize`, result); + return result; + } + function urlBuilderAuthorize(base, options) { + const map = { + allowSignup: "allow_signup", + clientId: "client_id", + login: "login", + redirectUrl: "redirect_uri", + scopes: "scope", + state: "state" + }; + let url = base; + Object.keys(map).filter((k) => options[k] !== null).filter((k) => { + if (k !== "scopes") + return true; + if (options.clientType === "github-app") + return false; + return !Array.isArray(options[k]) || options[k].length > 0; + }).map((key) => [map[key], `${options[key]}`]).forEach(([key, value], index2) => { + url += index2 === 0 ? `?` : "&"; + url += `${key}=${encodeURIComponent(value)}`; + }); + return url; + } } }); -// ../../../node_modules/.pnpm/@octokit+app@14.1.0/node_modules/@octokit/app/dist-node/index.js -var require_dist_node25 = __commonJS({ - "../../../node_modules/.pnpm/@octokit+app@14.1.0/node_modules/@octokit/app/dist-node/index.js"(exports2, module2) { +// ../../../node_modules/.pnpm/@octokit+oauth-methods@4.1.0/node_modules/@octokit/oauth-methods/dist-node/index.js +var require_dist_node15 = __commonJS({ + "../../../node_modules/.pnpm/@octokit+oauth-methods@4.1.0/node_modules/@octokit/oauth-methods/dist-node/index.js"(exports2, module2) { "use strict"; + var __create2 = Object.create; var __defProp2 = Object.defineProperty; var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; var __getOwnPropNames2 = Object.getOwnPropertyNames; + var __getProtoOf2 = Object.getPrototypeOf; var __hasOwnProp2 = Object.prototype.hasOwnProperty; var __export2 = (target, all) => { for (var name in all) __defProp2(target, name, { get: all[name], enumerable: true }); }; - var __copyProps2 = (to, from3, except, desc) => { - if (from3 && typeof from3 === "object" || typeof from3 === "function") { - for (let key of __getOwnPropNames2(from3)) + var __copyProps2 = (to, from2, except, desc) => { + if (from2 && typeof from2 === "object" || typeof from2 === "function") { + for (let key of __getOwnPropNames2(from2)) if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc2(from3, key)) || desc.enumerable }); + __defProp2(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc2(from2, key)) || desc.enumerable }); } return to; }; + var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target, + mod + )); var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); var dist_src_exports = {}; __export2(dist_src_exports, { - App: () => App, - createNodeMiddleware: () => createNodeMiddleware2 + VERSION: () => VERSION, + checkToken: () => checkToken, + createDeviceCode: () => createDeviceCode, + deleteAuthorization: () => deleteAuthorization, + deleteToken: () => deleteToken, + exchangeDeviceCode: () => exchangeDeviceCode, + exchangeWebFlowCode: () => exchangeWebFlowCode, + getWebFlowAuthorizationUrl: () => getWebFlowAuthorizationUrl, + refreshToken: () => refreshToken, + resetToken: () => resetToken, + scopeToken: () => scopeToken }); module2.exports = __toCommonJS2(dist_src_exports); - var import_core = require_dist_node8(); - var import_auth_app3 = require_dist_node20(); - var import_oauth_app2 = require_dist_node22(); - var VERSION = "14.1.0"; - var import_auth_app = require_dist_node20(); - var import_auth_unauthenticated = require_dist_node21(); - var import_webhooks = require_dist_node24(); - function webhooks(appOctokit, options) { - return new import_webhooks.Webhooks({ - secret: options.secret, - transform: async (event) => { - if (!("installation" in event.payload) || typeof event.payload.installation !== "object") { - const octokit2 = new appOctokit.constructor({ - authStrategy: import_auth_unauthenticated.createUnauthenticatedAuth, - auth: { - reason: `"installation" key missing in webhook event payload` - } - }); - return { - ...event, - octokit: octokit2 - }; + var VERSION = "4.1.0"; + var import_oauth_authorization_url = require_dist_node14(); + var import_request = require_dist_node5(); + var import_request_error = require_dist_node4(); + function requestToOAuthBaseUrl(request) { + const endpointDefaults = request.endpoint.DEFAULTS; + return /^https:\/\/(api\.)?github\.com$/.test(endpointDefaults.baseUrl) ? "https://github.com" : endpointDefaults.baseUrl.replace("/api/v3", ""); + } + async function oauthRequest(request, route, parameters) { + const withOAuthParameters = { + baseUrl: requestToOAuthBaseUrl(request), + headers: { + accept: "application/json" + }, + ...parameters + }; + const response = await request(route, withOAuthParameters); + if ("error" in response.data) { + const error = new import_request_error.RequestError( + `${response.data.error_description} (${response.data.error}, ${response.data.error_uri})`, + 400, + { + request: request.endpoint.merge( + route, + withOAuthParameters + ), + headers: response.headers } - const installationId = event.payload.installation.id; - const octokit = await appOctokit.auth({ - type: "installation", - installationId, - factory(auth) { - return new auth.octokit.constructor({ - ...auth.octokitOptions, - authStrategy: import_auth_app.createAppAuth, - ...{ - auth: { - ...auth, - installationId - } - } - }); - } - }); - octokit.hook.before("request", (options2) => { - options2.headers["x-github-delivery"] = event.id; - }); - return { - ...event, - octokit - }; - } + ); + error.response = response; + throw error; + } + return response; + } + function getWebFlowAuthorizationUrl({ + request = import_request.request, + ...options + }) { + const baseUrl = requestToOAuthBaseUrl(request); + return (0, import_oauth_authorization_url.oauthAuthorizationUrl)({ + ...options, + baseUrl }); } - var import_plugin_paginate_rest = require_dist_node10(); - var import_auth_app2 = require_dist_node20(); - async function getInstallationOctokit(app, installationId) { - return app.octokit.auth({ - type: "installation", - installationId, - factory(auth) { - const options = { - ...auth.octokitOptions, - authStrategy: import_auth_app2.createAppAuth, - ...{ auth: { ...auth, installationId } } - }; - return new auth.octokit.constructor(options); + var import_request2 = require_dist_node5(); + async function exchangeWebFlowCode(options) { + const request = options.request || /* istanbul ignore next: we always pass a custom request in tests */ + import_request2.request; + const response = await oauthRequest( + request, + "POST /login/oauth/access_token", + { + client_id: options.clientId, + client_secret: options.clientSecret, + code: options.code, + redirect_uri: options.redirectUrl } - }); + ); + const authentication = { + clientType: options.clientType, + clientId: options.clientId, + clientSecret: options.clientSecret, + token: response.data.access_token, + scopes: response.data.scope.split(/\s+/).filter(Boolean) + }; + if (options.clientType === "github-app") { + if ("refresh_token" in response.data) { + const apiTimeInMs = new Date(response.headers.date).getTime(); + authentication.refreshToken = response.data.refresh_token, authentication.expiresAt = toTimestamp( + apiTimeInMs, + response.data.expires_in + ), authentication.refreshTokenExpiresAt = toTimestamp( + apiTimeInMs, + response.data.refresh_token_expires_in + ); + } + delete authentication.scopes; + } + return { ...response, authentication }; } - function eachInstallationFactory(app) { - return Object.assign(eachInstallation.bind(null, app), { - iterator: eachInstallationIterator.bind(null, app) - }); + function toTimestamp(apiTimeInMs, expirationInSeconds) { + return new Date(apiTimeInMs + expirationInSeconds * 1e3).toISOString(); } - async function eachInstallation(app, callback) { - const i = eachInstallationIterator(app)[Symbol.asyncIterator](); - let result = await i.next(); - while (!result.done) { - await callback(result.value); - result = await i.next(); + var import_request3 = require_dist_node5(); + async function createDeviceCode(options) { + const request = options.request || /* istanbul ignore next: we always pass a custom request in tests */ + import_request3.request; + const parameters = { + client_id: options.clientId + }; + if ("scopes" in options && Array.isArray(options.scopes)) { + parameters.scope = options.scopes.join(" "); } + return oauthRequest(request, "POST /login/device/code", parameters); } - function eachInstallationIterator(app) { - return { - async *[Symbol.asyncIterator]() { - const iterator = import_plugin_paginate_rest.composePaginateRest.iterator( - app.octokit, - "GET /app/installations" - ); - for await (const { data: installations } of iterator) { - for (const installation of installations) { - const installationOctokit = await getInstallationOctokit( - app, - installation.id - ); - yield { octokit: installationOctokit, installation }; - } - } + var import_request4 = require_dist_node5(); + async function exchangeDeviceCode(options) { + const request = options.request || /* istanbul ignore next: we always pass a custom request in tests */ + import_request4.request; + const response = await oauthRequest( + request, + "POST /login/oauth/access_token", + { + client_id: options.clientId, + device_code: options.code, + grant_type: "urn:ietf:params:oauth:grant-type:device_code" } + ); + const authentication = { + clientType: options.clientType, + clientId: options.clientId, + token: response.data.access_token, + scopes: response.data.scope.split(/\s+/).filter(Boolean) }; - } - var import_plugin_paginate_rest2 = require_dist_node10(); - function eachRepositoryFactory(app) { - return Object.assign(eachRepository.bind(null, app), { - iterator: eachRepositoryIterator.bind(null, app) - }); - } - async function eachRepository(app, queryOrCallback, callback) { - const i = eachRepositoryIterator( - app, - callback ? queryOrCallback : void 0 - )[Symbol.asyncIterator](); - let result = await i.next(); - while (!result.done) { - if (callback) { - await callback(result.value); - } else { - await queryOrCallback(result.value); + if ("clientSecret" in options) { + authentication.clientSecret = options.clientSecret; + } + if (options.clientType === "github-app") { + if ("refresh_token" in response.data) { + const apiTimeInMs = new Date(response.headers.date).getTime(); + authentication.refreshToken = response.data.refresh_token, authentication.expiresAt = toTimestamp2( + apiTimeInMs, + response.data.expires_in + ), authentication.refreshTokenExpiresAt = toTimestamp2( + apiTimeInMs, + response.data.refresh_token_expires_in + ); } - result = await i.next(); + delete authentication.scopes; } + return { ...response, authentication }; } - function singleInstallationIterator(app, installationId) { - return { - async *[Symbol.asyncIterator]() { - yield { - octokit: await app.getInstallationOctokit(installationId) - }; - } + function toTimestamp2(apiTimeInMs, expirationInSeconds) { + return new Date(apiTimeInMs + expirationInSeconds * 1e3).toISOString(); + } + var import_request5 = require_dist_node5(); + var import_btoa_lite = __toESM2(require_btoa_node()); + async function checkToken(options) { + const request = options.request || /* istanbul ignore next: we always pass a custom request in tests */ + import_request5.request; + const response = await request("POST /applications/{client_id}/token", { + headers: { + authorization: `basic ${(0, import_btoa_lite.default)( + `${options.clientId}:${options.clientSecret}` + )}` + }, + client_id: options.clientId, + access_token: options.token + }); + const authentication = { + clientType: options.clientType, + clientId: options.clientId, + clientSecret: options.clientSecret, + token: options.token, + scopes: response.data.scopes }; + if (response.data.expires_at) + authentication.expiresAt = response.data.expires_at; + if (options.clientType === "github-app") { + delete authentication.scopes; + } + return { ...response, authentication }; } - function eachRepositoryIterator(app, query) { - return { - async *[Symbol.asyncIterator]() { - const iterator = query ? singleInstallationIterator(app, query.installationId) : app.eachInstallation.iterator(); - for await (const { octokit } of iterator) { - const repositoriesIterator = import_plugin_paginate_rest2.composePaginateRest.iterator( - octokit, - "GET /installation/repositories" - ); - for await (const { data: repositories } of repositoriesIterator) { - for (const repository of repositories) { - yield { octokit, repository }; - } - } - } + var import_request6 = require_dist_node5(); + async function refreshToken(options) { + const request = options.request || /* istanbul ignore next: we always pass a custom request in tests */ + import_request6.request; + const response = await oauthRequest( + request, + "POST /login/oauth/access_token", + { + client_id: options.clientId, + client_secret: options.clientSecret, + grant_type: "refresh_token", + refresh_token: options.refreshToken } + ); + const apiTimeInMs = new Date(response.headers.date).getTime(); + const authentication = { + clientType: "github-app", + clientId: options.clientId, + clientSecret: options.clientSecret, + token: response.data.access_token, + refreshToken: response.data.refresh_token, + expiresAt: toTimestamp3(apiTimeInMs, response.data.expires_in), + refreshTokenExpiresAt: toTimestamp3( + apiTimeInMs, + response.data.refresh_token_expires_in + ) }; + return { ...response, authentication }; } - var import_oauth_app = require_dist_node22(); - var import_webhooks2 = require_dist_node24(); - function noop() { + function toTimestamp3(apiTimeInMs, expirationInSeconds) { + return new Date(apiTimeInMs + expirationInSeconds * 1e3).toISOString(); } - function createNodeMiddleware2(app, options = {}) { - const log2 = Object.assign( + var import_request7 = require_dist_node5(); + var import_btoa_lite2 = __toESM2(require_btoa_node()); + async function scopeToken(options) { + const { + request: optionsRequest, + clientType, + clientId, + clientSecret, + token, + ...requestOptions + } = options; + const request = optionsRequest || /* istanbul ignore next: we always pass a custom request in tests */ + import_request7.request; + const response = await request( + "POST /applications/{client_id}/token/scoped", { - debug: noop, - info: noop, - warn: console.warn.bind(console), - error: console.error.bind(console) - }, - options.log + headers: { + authorization: `basic ${(0, import_btoa_lite2.default)(`${clientId}:${clientSecret}`)}` + }, + client_id: clientId, + access_token: token, + ...requestOptions + } ); - const optionsWithDefaults = { - pathPrefix: "/api/github", - ...options, - log: log2 - }; - const webhooksMiddleware = (0, import_webhooks2.createNodeMiddleware)(app.webhooks, { - path: optionsWithDefaults.pathPrefix + "/webhooks", - log: log2 - }); - const oauthMiddleware = (0, import_oauth_app.createNodeMiddleware)(app.oauth, { - pathPrefix: optionsWithDefaults.pathPrefix + "/oauth" - }); - return middleware.bind( - null, - optionsWithDefaults.pathPrefix, - webhooksMiddleware, - oauthMiddleware + const authentication = Object.assign( + { + clientType, + clientId, + clientSecret, + token: response.data.token + }, + response.data.expires_at ? { expiresAt: response.data.expires_at } : {} ); + return { ...response, authentication }; } - async function middleware(pathPrefix, webhooksMiddleware, oauthMiddleware, request, response, next) { - const { pathname } = new URL(request.url, "http://localhost"); - if (pathname.startsWith(`${pathPrefix}/`)) { - if (pathname === `${pathPrefix}/webhooks`) { - webhooksMiddleware(request, response); - } else if (pathname.startsWith(`${pathPrefix}/oauth/`)) { - oauthMiddleware(request, response); - } else { - (0, import_oauth_app.sendNodeResponse)((0, import_oauth_app.unknownRouteResponse)(request), response); + var import_request8 = require_dist_node5(); + var import_btoa_lite3 = __toESM2(require_btoa_node()); + async function resetToken(options) { + const request = options.request || /* istanbul ignore next: we always pass a custom request in tests */ + import_request8.request; + const auth = (0, import_btoa_lite3.default)(`${options.clientId}:${options.clientSecret}`); + const response = await request( + "PATCH /applications/{client_id}/token", + { + headers: { + authorization: `basic ${auth}` + }, + client_id: options.clientId, + access_token: options.token } - return true; - } else { - next == null ? void 0 : next(); - return false; + ); + const authentication = { + clientType: options.clientType, + clientId: options.clientId, + clientSecret: options.clientSecret, + token: response.data.token, + scopes: response.data.scopes + }; + if (response.data.expires_at) + authentication.expiresAt = response.data.expires_at; + if (options.clientType === "github-app") { + delete authentication.scopes; } + return { ...response, authentication }; } - var _App = class _App { - static defaults(defaults) { - const AppWithDefaults = class extends this { - constructor(...args) { - super({ - ...defaults, - ...args[0] - }); - } - }; - return AppWithDefaults; - } - constructor(options) { - const Octokit2 = options.Octokit || import_core.Octokit; - const authOptions = Object.assign( - { - appId: options.appId, - privateKey: options.privateKey - }, - options.oauth ? { - clientId: options.oauth.clientId, - clientSecret: options.oauth.clientSecret - } : {} - ); - this.octokit = new Octokit2({ - authStrategy: import_auth_app3.createAppAuth, - auth: authOptions, - log: options.log - }); - this.log = Object.assign( - { - debug: () => { - }, - info: () => { - }, - warn: console.warn.bind(console), - error: console.error.bind(console) + var import_request9 = require_dist_node5(); + var import_btoa_lite4 = __toESM2(require_btoa_node()); + async function deleteToken(options) { + const request = options.request || /* istanbul ignore next: we always pass a custom request in tests */ + import_request9.request; + const auth = (0, import_btoa_lite4.default)(`${options.clientId}:${options.clientSecret}`); + return request( + "DELETE /applications/{client_id}/token", + { + headers: { + authorization: `basic ${auth}` }, - options.log - ); - if (options.webhooks) { - this.webhooks = webhooks(this.octokit, options.webhooks); - } else { - Object.defineProperty(this, "webhooks", { - get() { - throw new Error("[@octokit/app] webhooks option not set"); - } - }); + client_id: options.clientId, + access_token: options.token } - if (options.oauth) { - this.oauth = new import_oauth_app2.OAuthApp({ - ...options.oauth, - clientType: "github-app", - Octokit: Octokit2 - }); - } else { - Object.defineProperty(this, "oauth", { - get() { - throw new Error( - "[@octokit/app] oauth.clientId / oauth.clientSecret options are not set" - ); - } - }); + ); + } + var import_request10 = require_dist_node5(); + var import_btoa_lite5 = __toESM2(require_btoa_node()); + async function deleteAuthorization(options) { + const request = options.request || /* istanbul ignore next: we always pass a custom request in tests */ + import_request10.request; + const auth = (0, import_btoa_lite5.default)(`${options.clientId}:${options.clientSecret}`); + return request( + "DELETE /applications/{client_id}/grant", + { + headers: { + authorization: `basic ${auth}` + }, + client_id: options.clientId, + access_token: options.token } - this.getInstallationOctokit = getInstallationOctokit.bind( - null, - this - ); - this.eachInstallation = eachInstallationFactory( - this - ); - this.eachRepository = eachRepositoryFactory( - this - ); - } - }; - _App.VERSION = VERSION; - var App = _App; + ); + } } }); -// ../../../node_modules/.pnpm/octokit@3.1.2/node_modules/octokit/dist-node/index.js -var require_dist_node26 = __commonJS({ - "../../../node_modules/.pnpm/octokit@3.1.2/node_modules/octokit/dist-node/index.js"(exports2, module2) { +// ../../../node_modules/.pnpm/@octokit+auth-oauth-device@6.1.0/node_modules/@octokit/auth-oauth-device/dist-node/index.js +var require_dist_node16 = __commonJS({ + "../../../node_modules/.pnpm/@octokit+auth-oauth-device@6.1.0/node_modules/@octokit/auth-oauth-device/dist-node/index.js"(exports2, module2) { "use strict"; var __defProp2 = Object.defineProperty; var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; @@ -34055,6097 +31478,8674 @@ var require_dist_node26 = __commonJS({ for (var name in all) __defProp2(target, name, { get: all[name], enumerable: true }); }; - var __copyProps2 = (to, from3, except, desc) => { - if (from3 && typeof from3 === "object" || typeof from3 === "function") { - for (let key of __getOwnPropNames2(from3)) + var __copyProps2 = (to, from2, except, desc) => { + if (from2 && typeof from2 === "object" || typeof from2 === "function") { + for (let key of __getOwnPropNames2(from2)) if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc2(from3, key)) || desc.enumerable }); + __defProp2(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc2(from2, key)) || desc.enumerable }); } return to; }; var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); var dist_src_exports = {}; __export2(dist_src_exports, { - App: () => App, - OAuthApp: () => OAuthApp, - Octokit: () => Octokit2, - RequestError: () => import_request_error.RequestError, - createNodeMiddleware: () => import_app2.createNodeMiddleware + createOAuthDeviceAuth: () => createOAuthDeviceAuth }); module2.exports = __toCommonJS2(dist_src_exports); - var import_core = require_dist_node8(); - var import_plugin_paginate_rest = require_dist_node10(); - var import_plugin_paginate_graphql = require_dist_node11(); - var import_plugin_rest_endpoint_methods = require_dist_node9(); - var import_plugin_retry = require_dist_node12(); - var import_plugin_throttling = require_dist_node13(); - var VERSION = "3.1.2"; - var import_request_error = require_dist_node4(); - var Octokit2 = import_core.Octokit.plugin( - import_plugin_rest_endpoint_methods.restEndpointMethods, - import_plugin_paginate_rest.paginateRest, - import_plugin_paginate_graphql.paginateGraphql, - import_plugin_retry.retry, - import_plugin_throttling.throttling - ).defaults({ - userAgent: `octokit.js/${VERSION}`, - throttle: { - onRateLimit, - onSecondaryRateLimit + var import_universal_user_agent = require_dist_node(); + var import_request = require_dist_node5(); + var import_oauth_methods = require_dist_node15(); + async function getOAuthAccessToken(state, options) { + const cachedAuthentication = getCachedAuthentication(state, options.auth); + if (cachedAuthentication) + return cachedAuthentication; + const { data: verification } = await (0, import_oauth_methods.createDeviceCode)({ + clientType: state.clientType, + clientId: state.clientId, + request: options.request || state.request, + // @ts-expect-error the extra code to make TS happy is not worth it + scopes: options.auth.scopes || state.scopes + }); + await state.onVerification(verification); + const authentication = await waitForAccessToken( + options.request || state.request, + state.clientId, + state.clientType, + verification + ); + state.authentication = authentication; + return authentication; + } + function getCachedAuthentication(state, auth2) { + if (auth2.refresh === true) + return false; + if (!state.authentication) + return false; + if (state.clientType === "github-app") { + return state.authentication; } - }); - function onRateLimit(retryAfter, options, octokit) { - octokit.log.warn( - `Request quota exhausted for request ${options.method} ${options.url}` + const authentication = state.authentication; + const newScope = ("scopes" in auth2 && auth2.scopes || state.scopes).join( + " " ); - if (options.request.retryCount === 0) { - octokit.log.info(`Retrying after ${retryAfter} seconds!`); - return true; + const currentScope = authentication.scopes.join(" "); + return newScope === currentScope ? authentication : false; + } + async function wait(seconds) { + await new Promise((resolve) => setTimeout(resolve, seconds * 1e3)); + } + async function waitForAccessToken(request, clientId, clientType, verification) { + try { + const options = { + clientId, + request, + code: verification.device_code + }; + const { authentication } = clientType === "oauth-app" ? await (0, import_oauth_methods.exchangeDeviceCode)({ + ...options, + clientType: "oauth-app" + }) : await (0, import_oauth_methods.exchangeDeviceCode)({ + ...options, + clientType: "github-app" + }); + return { + type: "token", + tokenType: "oauth", + ...authentication + }; + } catch (error) { + if (!error.response) + throw error; + const errorType = error.response.data.error; + if (errorType === "authorization_pending") { + await wait(verification.interval); + return waitForAccessToken(request, clientId, clientType, verification); + } + if (errorType === "slow_down") { + await wait(verification.interval + 5); + return waitForAccessToken(request, clientId, clientType, verification); + } + throw error; } } - function onSecondaryRateLimit(retryAfter, options, octokit) { - octokit.log.warn( - `SecondaryRateLimit detected for request ${options.method} ${options.url}` + async function auth(state, authOptions) { + return getOAuthAccessToken(state, { + auth: authOptions + }); + } + async function hook(state, request, route, parameters) { + let endpoint = request.endpoint.merge( + route, + parameters ); - if (options.request.retryCount === 0) { - octokit.log.info(`Retrying after ${retryAfter} seconds!`); - return true; + if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) { + return request(endpoint); } + const { token } = await getOAuthAccessToken(state, { + request, + auth: { type: "oauth" } + }); + endpoint.headers.authorization = `token ${token}`; + return request(endpoint); + } + var VERSION = "6.1.0"; + function createOAuthDeviceAuth(options) { + const requestWithDefaults = options.request || import_request.request.defaults({ + headers: { + "user-agent": `octokit-auth-oauth-device.js/${VERSION} ${(0, import_universal_user_agent.getUserAgent)()}` + } + }); + const { request = requestWithDefaults, ...otherOptions } = options; + const state = options.clientType === "github-app" ? { + ...otherOptions, + clientType: "github-app", + request + } : { + ...otherOptions, + clientType: "oauth-app", + request, + scopes: options.scopes || [] + }; + if (!options.clientId) { + throw new Error( + '[@octokit/auth-oauth-device] "clientId" option must be set (https://github.com/octokit/auth-oauth-device.js#usage)' + ); + } + if (!options.onVerification) { + throw new Error( + '[@octokit/auth-oauth-device] "onVerification" option must be a function (https://github.com/octokit/auth-oauth-device.js#usage)' + ); + } + return Object.assign(auth.bind(null, state), { + hook: hook.bind(null, state) + }); } - var import_app = require_dist_node25(); - var import_oauth_app = require_dist_node22(); - var import_app2 = require_dist_node25(); - var App = import_app.App.defaults({ Octokit: Octokit2 }); - var OAuthApp = import_oauth_app.OAuthApp.defaults({ Octokit: Octokit2 }); } }); -// ../../../node_modules/.pnpm/async-lock@1.4.1/node_modules/async-lock/lib/index.js -var require_lib2 = __commonJS({ - "../../../node_modules/.pnpm/async-lock@1.4.1/node_modules/async-lock/lib/index.js"(exports2, module2) { +// ../../../node_modules/.pnpm/@octokit+auth-oauth-user@4.1.0/node_modules/@octokit/auth-oauth-user/dist-node/index.js +var require_dist_node17 = __commonJS({ + "../../../node_modules/.pnpm/@octokit+auth-oauth-user@4.1.0/node_modules/@octokit/auth-oauth-user/dist-node/index.js"(exports2, module2) { "use strict"; - var AsyncLock2 = function(opts) { - opts = opts || {}; - this.Promise = opts.Promise || Promise; - this.queues = /* @__PURE__ */ Object.create(null); - this.domainReentrant = opts.domainReentrant || false; - if (this.domainReentrant) { - if (typeof process === "undefined" || typeof process.domain === "undefined") { - throw new Error( - "Domain-reentrant locks require `process.domain` to exist. Please flip `opts.domainReentrant = false`, use a NodeJS version that still implements Domain, or install a browser polyfill." - ); - } - this.domains = /* @__PURE__ */ Object.create(null); - } - this.timeout = opts.timeout || AsyncLock2.DEFAULT_TIMEOUT; - this.maxOccupationTime = opts.maxOccupationTime || AsyncLock2.DEFAULT_MAX_OCCUPATION_TIME; - this.maxExecutionTime = opts.maxExecutionTime || AsyncLock2.DEFAULT_MAX_EXECUTION_TIME; - if (opts.maxPending === Infinity || Number.isInteger(opts.maxPending) && opts.maxPending >= 0) { - this.maxPending = opts.maxPending; - } else { - this.maxPending = AsyncLock2.DEFAULT_MAX_PENDING; - } + var __create2 = Object.create; + var __defProp2 = Object.defineProperty; + var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; + var __getOwnPropNames2 = Object.getOwnPropertyNames; + var __getProtoOf2 = Object.getPrototypeOf; + var __hasOwnProp2 = Object.prototype.hasOwnProperty; + var __export2 = (target, all) => { + for (var name in all) + __defProp2(target, name, { get: all[name], enumerable: true }); }; - AsyncLock2.DEFAULT_TIMEOUT = 0; - AsyncLock2.DEFAULT_MAX_OCCUPATION_TIME = 0; - AsyncLock2.DEFAULT_MAX_EXECUTION_TIME = 0; - AsyncLock2.DEFAULT_MAX_PENDING = 1e3; - AsyncLock2.prototype.acquire = function(key, fn, cb, opts) { - if (Array.isArray(key)) { - return this._acquireBatch(key, fn, cb, opts); - } - if (typeof fn !== "function") { - throw new Error("You must pass a function to execute"); + var __copyProps2 = (to, from2, except, desc) => { + if (from2 && typeof from2 === "object" || typeof from2 === "function") { + for (let key of __getOwnPropNames2(from2)) + if (!__hasOwnProp2.call(to, key) && key !== except) + __defProp2(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc2(from2, key)) || desc.enumerable }); } - var deferredResolve = null; - var deferredReject = null; - var deferred = null; - if (typeof cb !== "function") { - opts = cb; - cb = null; - deferred = new this.Promise(function(resolve, reject) { - deferredResolve = resolve; - deferredReject = reject; + return to; + }; + var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target, + mod + )); + var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); + var dist_src_exports = {}; + __export2(dist_src_exports, { + createOAuthUserAuth: () => createOAuthUserAuth2, + requiresBasicAuth: () => requiresBasicAuth + }); + module2.exports = __toCommonJS2(dist_src_exports); + var import_universal_user_agent = require_dist_node(); + var import_request = require_dist_node5(); + var VERSION = "4.1.0"; + var import_auth_oauth_device = require_dist_node16(); + var import_oauth_methods = require_dist_node15(); + async function getAuthentication(state) { + if ("code" in state.strategyOptions) { + const { authentication } = await (0, import_oauth_methods.exchangeWebFlowCode)({ + clientId: state.clientId, + clientSecret: state.clientSecret, + clientType: state.clientType, + onTokenCreated: state.onTokenCreated, + ...state.strategyOptions, + request: state.request }); - } - opts = opts || {}; - var resolved = false; - var timer = null; - var occupationTimer = null; - var executionTimer = null; - var self2 = this; - var done = function(locked, err, ret) { - if (occupationTimer) { - clearTimeout(occupationTimer); - occupationTimer = null; - } - if (executionTimer) { - clearTimeout(executionTimer); - executionTimer = null; - } - if (locked) { - if (!!self2.queues[key] && self2.queues[key].length === 0) { - delete self2.queues[key]; - } - if (self2.domainReentrant) { - delete self2.domains[key]; - } - } - if (!resolved) { - if (!deferred) { - if (typeof cb === "function") { - cb(err, ret); - } - } else { - if (err) { - deferredReject(err); - } else { - deferredResolve(ret); - } - } - resolved = true; - } - if (locked) { - if (!!self2.queues[key] && self2.queues[key].length > 0) { - self2.queues[key].shift()(); - } - } - }; - var exec2 = function(locked) { - if (resolved) { - return done(locked); - } - if (timer) { - clearTimeout(timer); - timer = null; - } - if (self2.domainReentrant && locked) { - self2.domains[key] = process.domain; - } - var maxExecutionTime = opts.maxExecutionTime || self2.maxExecutionTime; - if (maxExecutionTime) { - executionTimer = setTimeout(function() { - if (!!self2.queues[key]) { - done(locked, new Error("Maximum execution time is exceeded " + key)); - } - }, maxExecutionTime); - } - if (fn.length === 1) { - var called = false; - try { - fn(function(err, ret) { - if (!called) { - called = true; - done(locked, err, ret); - } - }); - } catch (err) { - if (!called) { - called = true; - done(locked, err); - } - } - } else { - self2._promiseTry(function() { - return fn(); - }).then(function(ret) { - done(locked, void 0, ret); - }, function(error) { - done(locked, error); - }); - } - }; - if (self2.domainReentrant && !!process.domain) { - exec2 = process.domain.bind(exec2); - } - var maxPending = opts.maxPending || self2.maxPending; - if (!self2.queues[key]) { - self2.queues[key] = []; - exec2(true); - } else if (self2.domainReentrant && !!process.domain && process.domain === self2.domains[key]) { - exec2(false); - } else if (self2.queues[key].length >= maxPending) { - done(false, new Error("Too many pending tasks in queue " + key)); - } else { - var taskFn = function() { - exec2(true); + return { + type: "token", + tokenType: "oauth", + ...authentication }; - if (opts.skipQueue) { - self2.queues[key].unshift(taskFn); - } else { - self2.queues[key].push(taskFn); - } - var timeout = opts.timeout || self2.timeout; - if (timeout) { - timer = setTimeout(function() { - timer = null; - done(false, new Error("async-lock timed out in queue " + key)); - }, timeout); - } - } - var maxOccupationTime = opts.maxOccupationTime || self2.maxOccupationTime; - if (maxOccupationTime) { - occupationTimer = setTimeout(function() { - if (!!self2.queues[key]) { - done(false, new Error("Maximum occupation time is exceeded in queue " + key)); - } - }, maxOccupationTime); - } - if (deferred) { - return deferred; - } - }; - AsyncLock2.prototype._acquireBatch = function(keys, fn, cb, opts) { - if (typeof cb !== "function") { - opts = cb; - cb = null; } - var self2 = this; - var getFn = function(key, fn2) { - return function(cb2) { - self2.acquire(key, fn2, cb2, opts); - }; - }; - var fnx = keys.reduceRight(function(prev, key) { - return getFn(key, prev); - }, fn); - if (typeof cb === "function") { - fnx(cb); - } else { - return new this.Promise(function(resolve, reject) { - if (fnx.length === 1) { - fnx(function(err, ret) { - if (err) { - reject(err); - } else { - resolve(ret); - } - }); - } else { - resolve(fnx()); - } + if ("onVerification" in state.strategyOptions) { + const deviceAuth = (0, import_auth_oauth_device.createOAuthDeviceAuth)({ + clientType: state.clientType, + clientId: state.clientId, + onTokenCreated: state.onTokenCreated, + ...state.strategyOptions, + request: state.request }); + const authentication = await deviceAuth({ + type: "oauth" + }); + return { + clientSecret: state.clientSecret, + ...authentication + }; } - }; - AsyncLock2.prototype.isBusy = function(key) { - if (!key) { - return Object.keys(this.queues).length > 0; - } else { - return !!this.queues[key]; - } - }; - AsyncLock2.prototype._promiseTry = function(fn) { - try { - return this.Promise.resolve(fn()); - } catch (e) { - return this.Promise.reject(e); + if ("token" in state.strategyOptions) { + return { + type: "token", + tokenType: "oauth", + clientId: state.clientId, + clientSecret: state.clientSecret, + clientType: state.clientType, + onTokenCreated: state.onTokenCreated, + ...state.strategyOptions + }; } - }; - module2.exports = AsyncLock2; - } -}); - -// ../../../node_modules/.pnpm/async-lock@1.4.1/node_modules/async-lock/index.js -var require_async_lock = __commonJS({ - "../../../node_modules/.pnpm/async-lock@1.4.1/node_modules/async-lock/index.js"(exports2, module2) { - "use strict"; - module2.exports = require_lib2(); - } -}); - -// ../../../node_modules/.pnpm/inherits@2.0.4/node_modules/inherits/inherits_browser.js -var require_inherits_browser = __commonJS({ - "../../../node_modules/.pnpm/inherits@2.0.4/node_modules/inherits/inherits_browser.js"(exports2, module2) { - if (typeof Object.create === "function") { - module2.exports = function inherits(ctor, superCtor) { - if (superCtor) { - ctor.super_ = superCtor; - ctor.prototype = Object.create(superCtor.prototype, { - constructor: { - value: ctor, - enumerable: false, - writable: true, - configurable: true - } + throw new Error("[@octokit/auth-oauth-user] Invalid strategy options"); + } + var import_oauth_methods2 = require_dist_node15(); + async function auth(state, options = {}) { + var _a, _b; + if (!state.authentication) { + state.authentication = state.clientType === "oauth-app" ? await getAuthentication(state) : await getAuthentication(state); + } + if (state.authentication.invalid) { + throw new Error("[@octokit/auth-oauth-user] Token is invalid"); + } + const currentAuthentication = state.authentication; + if ("expiresAt" in currentAuthentication) { + if (options.type === "refresh" || new Date(currentAuthentication.expiresAt) < /* @__PURE__ */ new Date()) { + const { authentication } = await (0, import_oauth_methods2.refreshToken)({ + clientType: "github-app", + clientId: state.clientId, + clientSecret: state.clientSecret, + refreshToken: currentAuthentication.refreshToken, + request: state.request }); - } - }; - } else { - module2.exports = function inherits(ctor, superCtor) { - if (superCtor) { - ctor.super_ = superCtor; - var TempCtor = function() { + state.authentication = { + tokenType: "oauth", + type: "token", + ...authentication }; - TempCtor.prototype = superCtor.prototype; - ctor.prototype = new TempCtor(); - ctor.prototype.constructor = ctor; } - }; - } - } -}); - -// ../../../node_modules/.pnpm/inherits@2.0.4/node_modules/inherits/inherits.js -var require_inherits = __commonJS({ - "../../../node_modules/.pnpm/inherits@2.0.4/node_modules/inherits/inherits.js"(exports2, module2) { - try { - util = require("util"); - if (typeof util.inherits !== "function") - throw ""; - module2.exports = util.inherits; - } catch (e) { - module2.exports = require_inherits_browser(); - } - var util; - } -}); - -// ../../../node_modules/.pnpm/sha.js@2.4.11/node_modules/sha.js/hash.js -var require_hash = __commonJS({ - "../../../node_modules/.pnpm/sha.js@2.4.11/node_modules/sha.js/hash.js"(exports2, module2) { - var Buffer2 = require_safe_buffer().Buffer; - function Hash2(blockSize, finalSize) { - this._block = Buffer2.alloc(blockSize); - this._finalSize = finalSize; - this._blockSize = blockSize; - this._len = 0; - } - Hash2.prototype.update = function(data, enc) { - if (typeof data === "string") { - enc = enc || "utf8"; - data = Buffer2.from(data, enc); } - var block = this._block; - var blockSize = this._blockSize; - var length = data.length; - var accum = this._len; - for (var offset = 0; offset < length; ) { - var assigned = accum % blockSize; - var remainder = Math.min(length - offset, blockSize - assigned); - for (var i = 0; i < remainder; i++) { - block[assigned + i] = data[offset + i]; + if (options.type === "refresh") { + if (state.clientType === "oauth-app") { + throw new Error( + "[@octokit/auth-oauth-user] OAuth Apps do not support expiring tokens" + ); } - accum += remainder; - offset += remainder; - if (accum % blockSize === 0) { - this._update(block); + if (!currentAuthentication.hasOwnProperty("expiresAt")) { + throw new Error("[@octokit/auth-oauth-user] Refresh token missing"); } + await ((_a = state.onTokenCreated) == null ? void 0 : _a.call(state, state.authentication, { + type: options.type + })); } - this._len += length; - return this; - }; - Hash2.prototype.digest = function(enc) { - var rem = this._len % this._blockSize; - this._block[rem] = 128; - this._block.fill(0, rem + 1); - if (rem >= this._finalSize) { - this._update(this._block); - this._block.fill(0); + if (options.type === "check" || options.type === "reset") { + const method = options.type === "check" ? import_oauth_methods2.checkToken : import_oauth_methods2.resetToken; + try { + const { authentication } = await method({ + // @ts-expect-error making TS happy would require unnecessary code so no + clientType: state.clientType, + clientId: state.clientId, + clientSecret: state.clientSecret, + token: state.authentication.token, + request: state.request + }); + state.authentication = { + tokenType: "oauth", + type: "token", + // @ts-expect-error TBD + ...authentication + }; + if (options.type === "reset") { + await ((_b = state.onTokenCreated) == null ? void 0 : _b.call(state, state.authentication, { + type: options.type + })); + } + return state.authentication; + } catch (error) { + if (error.status === 404) { + error.message = "[@octokit/auth-oauth-user] Token is invalid"; + state.authentication.invalid = true; + } + throw error; + } } - var bits = this._len * 8; - if (bits <= 4294967295) { - this._block.writeUInt32BE(bits, this._blockSize - 4); - } else { - var lowBits = (bits & 4294967295) >>> 0; - var highBits = (bits - lowBits) / 4294967296; - this._block.writeUInt32BE(highBits, this._blockSize - 8); - this._block.writeUInt32BE(lowBits, this._blockSize - 4); + if (options.type === "delete" || options.type === "deleteAuthorization") { + const method = options.type === "delete" ? import_oauth_methods2.deleteToken : import_oauth_methods2.deleteAuthorization; + try { + await method({ + // @ts-expect-error making TS happy would require unnecessary code so no + clientType: state.clientType, + clientId: state.clientId, + clientSecret: state.clientSecret, + token: state.authentication.token, + request: state.request + }); + } catch (error) { + if (error.status !== 404) + throw error; + } + state.authentication.invalid = true; + return state.authentication; } - this._update(this._block); - var hash2 = this._hash(); - return enc ? hash2.toString(enc) : hash2; - }; - Hash2.prototype._update = function() { - throw new Error("_update must be implemented by subclass"); - }; - module2.exports = Hash2; - } -}); - -// ../../../node_modules/.pnpm/sha.js@2.4.11/node_modules/sha.js/sha1.js -var require_sha1 = __commonJS({ - "../../../node_modules/.pnpm/sha.js@2.4.11/node_modules/sha.js/sha1.js"(exports2, module2) { - var inherits = require_inherits(); - var Hash2 = require_hash(); - var Buffer2 = require_safe_buffer().Buffer; - var K = [ - 1518500249, - 1859775393, - 2400959708 | 0, - 3395469782 | 0 - ]; - var W = new Array(80); - function Sha1() { - this.init(); - this._w = W; - Hash2.call(this, 64, 56); - } - inherits(Sha1, Hash2); - Sha1.prototype.init = function() { - this._a = 1732584193; - this._b = 4023233417; - this._c = 2562383102; - this._d = 271733878; - this._e = 3285377520; - return this; - }; - function rotl1(num2) { - return num2 << 1 | num2 >>> 31; + return state.authentication; } - function rotl5(num2) { - return num2 << 5 | num2 >>> 27; + var import_btoa_lite = __toESM2(require_btoa_node()); + var ROUTES_REQUIRING_BASIC_AUTH = /\/applications\/[^/]+\/(token|grant)s?/; + function requiresBasicAuth(url) { + return url && ROUTES_REQUIRING_BASIC_AUTH.test(url); } - function rotl30(num2) { - return num2 << 30 | num2 >>> 2; + async function hook(state, request, route, parameters = {}) { + const endpoint = request.endpoint.merge( + route, + parameters + ); + if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) { + return request(endpoint); + } + if (requiresBasicAuth(endpoint.url)) { + const credentials = (0, import_btoa_lite.default)(`${state.clientId}:${state.clientSecret}`); + endpoint.headers.authorization = `basic ${credentials}`; + return request(endpoint); + } + const { token } = state.clientType === "oauth-app" ? await auth({ ...state, request }) : await auth({ ...state, request }); + endpoint.headers.authorization = "token " + token; + return request(endpoint); } - function ft(s, b, c, d) { - if (s === 0) - return b & c | ~b & d; - if (s === 2) - return b & c | b & d | c & d; - return b ^ c ^ d; + function createOAuthUserAuth2({ + clientId, + clientSecret, + clientType = "oauth-app", + request = import_request.request.defaults({ + headers: { + "user-agent": `octokit-auth-oauth-app.js/${VERSION} ${(0, import_universal_user_agent.getUserAgent)()}` + } + }), + onTokenCreated, + ...strategyOptions + }) { + const state = Object.assign({ + clientType, + clientId, + clientSecret, + onTokenCreated, + strategyOptions, + request + }); + return Object.assign(auth.bind(null, state), { + // @ts-expect-error not worth the extra code needed to appease TS + hook: hook.bind(null, state) + }); } - Sha1.prototype._update = function(M) { - var W2 = this._w; - var a = this._a | 0; - var b = this._b | 0; - var c = this._c | 0; - var d = this._d | 0; - var e = this._e | 0; - for (var i = 0; i < 16; ++i) - W2[i] = M.readInt32BE(i * 4); - for (; i < 80; ++i) - W2[i] = rotl1(W2[i - 3] ^ W2[i - 8] ^ W2[i - 14] ^ W2[i - 16]); - for (var j = 0; j < 80; ++j) { - var s = ~~(j / 20); - var t = rotl5(a) + ft(s, b, c, d) + e + W2[j] + K[s] | 0; - e = d; - d = c; - c = rotl30(b); - b = a; - a = t; - } - this._a = a + this._a | 0; - this._b = b + this._b | 0; - this._c = c + this._c | 0; - this._d = d + this._d | 0; - this._e = e + this._e | 0; - }; - Sha1.prototype._hash = function() { - var H = Buffer2.allocUnsafe(20); - H.writeInt32BE(this._a | 0, 0); - H.writeInt32BE(this._b | 0, 4); - H.writeInt32BE(this._c | 0, 8); - H.writeInt32BE(this._d | 0, 12); - H.writeInt32BE(this._e | 0, 16); - return H; - }; - module2.exports = Sha1; + createOAuthUserAuth2.VERSION = VERSION; } }); -// ../../../node_modules/.pnpm/crc-32@1.2.2/node_modules/crc-32/crc32.js -var require_crc32 = __commonJS({ - "../../../node_modules/.pnpm/crc-32@1.2.2/node_modules/crc-32/crc32.js"(exports2) { - var CRC32; - (function(factory) { - if (typeof DO_NOT_EXPORT_CRC === "undefined") { - if ("object" === typeof exports2) { - factory(exports2); - } else if ("function" === typeof define && define.amd) { - define(function() { - var module3 = {}; - factory(module3); - return module3; - }); - } else { - factory(CRC32 = {}); - } - } else { - factory(CRC32 = {}); +// ../../../node_modules/.pnpm/@octokit+auth-oauth-app@7.1.0/node_modules/@octokit/auth-oauth-app/dist-node/index.js +var require_dist_node18 = __commonJS({ + "../../../node_modules/.pnpm/@octokit+auth-oauth-app@7.1.0/node_modules/@octokit/auth-oauth-app/dist-node/index.js"(exports2, module2) { + "use strict"; + var __create2 = Object.create; + var __defProp2 = Object.defineProperty; + var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; + var __getOwnPropNames2 = Object.getOwnPropertyNames; + var __getProtoOf2 = Object.getPrototypeOf; + var __hasOwnProp2 = Object.prototype.hasOwnProperty; + var __export2 = (target, all) => { + for (var name in all) + __defProp2(target, name, { get: all[name], enumerable: true }); + }; + var __copyProps2 = (to, from2, except, desc) => { + if (from2 && typeof from2 === "object" || typeof from2 === "function") { + for (let key of __getOwnPropNames2(from2)) + if (!__hasOwnProp2.call(to, key) && key !== except) + __defProp2(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc2(from2, key)) || desc.enumerable }); } - })(function(CRC322) { - CRC322.version = "1.2.2"; - function signed_crc_table() { - var c = 0, table = new Array(256); - for (var n = 0; n != 256; ++n) { - c = n; - c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1; - c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1; - c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1; - c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1; - c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1; - c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1; - c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1; - c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1; - table[n] = c; - } - return typeof Int32Array !== "undefined" ? new Int32Array(table) : table; + return to; + }; + var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target, + mod + )); + var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); + var dist_src_exports = {}; + __export2(dist_src_exports, { + createOAuthAppAuth: () => createOAuthAppAuth, + createOAuthUserAuth: () => import_auth_oauth_user3.createOAuthUserAuth + }); + module2.exports = __toCommonJS2(dist_src_exports); + var import_universal_user_agent = require_dist_node(); + var import_request = require_dist_node5(); + var import_btoa_lite = __toESM2(require_btoa_node()); + var import_auth_oauth_user = require_dist_node17(); + async function auth(state, authOptions) { + if (authOptions.type === "oauth-app") { + return { + type: "oauth-app", + clientId: state.clientId, + clientSecret: state.clientSecret, + clientType: state.clientType, + headers: { + authorization: `basic ${(0, import_btoa_lite.default)( + `${state.clientId}:${state.clientSecret}` + )}` + } + }; } - var T0 = signed_crc_table(); - function slice_by_16_tables(T) { - var c = 0, v = 0, n = 0, table = typeof Int32Array !== "undefined" ? new Int32Array(4096) : new Array(4096); - for (n = 0; n != 256; ++n) - table[n] = T[n]; - for (n = 0; n != 256; ++n) { - v = T[n]; - for (c = 256 + n; c < 4096; c += 256) - v = table[c] = v >>> 8 ^ T[v & 255]; - } - var out = []; - for (n = 1; n != 16; ++n) - out[n - 1] = typeof Int32Array !== "undefined" ? table.subarray(n * 256, n * 256 + 256) : table.slice(n * 256, n * 256 + 256); - return out; + if ("factory" in authOptions) { + const { type, ...options } = { + ...authOptions, + ...state + }; + return authOptions.factory(options); } - var TT = slice_by_16_tables(T0); - var T1 = TT[0], T2 = TT[1], T3 = TT[2], T4 = TT[3], T5 = TT[4]; - var T6 = TT[5], T7 = TT[6], T8 = TT[7], T9 = TT[8], Ta = TT[9]; - var Tb = TT[10], Tc = TT[11], Td = TT[12], Te = TT[13], Tf = TT[14]; - function crc32_bstr(bstr, seed) { - var C = seed ^ -1; - for (var i = 0, L = bstr.length; i < L; ) - C = C >>> 8 ^ T0[(C ^ bstr.charCodeAt(i++)) & 255]; - return ~C; + const common = { + clientId: state.clientId, + clientSecret: state.clientSecret, + request: state.request, + ...authOptions + }; + const userAuth = state.clientType === "oauth-app" ? await (0, import_auth_oauth_user.createOAuthUserAuth)({ + ...common, + clientType: state.clientType + }) : await (0, import_auth_oauth_user.createOAuthUserAuth)({ + ...common, + clientType: state.clientType + }); + return userAuth(); + } + var import_btoa_lite2 = __toESM2(require_btoa_node()); + var import_auth_oauth_user2 = require_dist_node17(); + async function hook(state, request2, route, parameters) { + let endpoint = request2.endpoint.merge( + route, + parameters + ); + if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) { + return request2(endpoint); } - function crc32_buf(B, seed) { - var C = seed ^ -1, L = B.length - 15, i = 0; - for (; i < L; ) - C = Tf[B[i++] ^ C & 255] ^ Te[B[i++] ^ C >> 8 & 255] ^ Td[B[i++] ^ C >> 16 & 255] ^ Tc[B[i++] ^ C >>> 24] ^ Tb[B[i++]] ^ Ta[B[i++]] ^ T9[B[i++]] ^ T8[B[i++]] ^ T7[B[i++]] ^ T6[B[i++]] ^ T5[B[i++]] ^ T4[B[i++]] ^ T3[B[i++]] ^ T2[B[i++]] ^ T1[B[i++]] ^ T0[B[i++]]; - L += 15; - while (i < L) - C = C >>> 8 ^ T0[(C ^ B[i++]) & 255]; - return ~C; + if (state.clientType === "github-app" && !(0, import_auth_oauth_user2.requiresBasicAuth)(endpoint.url)) { + throw new Error( + `[@octokit/auth-oauth-app] GitHub Apps cannot use their client ID/secret for basic authentication for endpoints other than "/applications/{client_id}/**". "${endpoint.method} ${endpoint.url}" is not supported.` + ); } - function crc32_str(str, seed) { - var C = seed ^ -1; - for (var i = 0, L = str.length, c = 0, d = 0; i < L; ) { - c = str.charCodeAt(i++); - if (c < 128) { - C = C >>> 8 ^ T0[(C ^ c) & 255]; - } else if (c < 2048) { - C = C >>> 8 ^ T0[(C ^ (192 | c >> 6 & 31)) & 255]; - C = C >>> 8 ^ T0[(C ^ (128 | c & 63)) & 255]; - } else if (c >= 55296 && c < 57344) { - c = (c & 1023) + 64; - d = str.charCodeAt(i++) & 1023; - C = C >>> 8 ^ T0[(C ^ (240 | c >> 8 & 7)) & 255]; - C = C >>> 8 ^ T0[(C ^ (128 | c >> 2 & 63)) & 255]; - C = C >>> 8 ^ T0[(C ^ (128 | d >> 6 & 15 | (c & 3) << 4)) & 255]; - C = C >>> 8 ^ T0[(C ^ (128 | d & 63)) & 255]; - } else { - C = C >>> 8 ^ T0[(C ^ (224 | c >> 12 & 15)) & 255]; - C = C >>> 8 ^ T0[(C ^ (128 | c >> 6 & 63)) & 255]; - C = C >>> 8 ^ T0[(C ^ (128 | c & 63)) & 255]; - } - } - return ~C; + const credentials = (0, import_btoa_lite2.default)(`${state.clientId}:${state.clientSecret}`); + endpoint.headers.authorization = `basic ${credentials}`; + try { + return await request2(endpoint); + } catch (error) { + if (error.status !== 401) + throw error; + error.message = `[@octokit/auth-oauth-app] "${endpoint.method} ${endpoint.url}" does not support clientId/clientSecret basic authentication.`; + throw error; + } + } + var VERSION = "7.1.0"; + var import_auth_oauth_user3 = require_dist_node17(); + function createOAuthAppAuth(options) { + const state = Object.assign( + { + request: import_request.request.defaults({ + headers: { + "user-agent": `octokit-auth-oauth-app.js/${VERSION} ${(0, import_universal_user_agent.getUserAgent)()}` + } + }), + clientType: "oauth-app" + }, + options + ); + return Object.assign(auth.bind(null, state), { + hook: hook.bind(null, state) + }); + } + } +}); + +// ../../../node_modules/.pnpm/jws@3.2.2/node_modules/jws/lib/data-stream.js +var require_data_stream = __commonJS({ + "../../../node_modules/.pnpm/jws@3.2.2/node_modules/jws/lib/data-stream.js"(exports2, module2) { + var Buffer2 = require_safe_buffer().Buffer; + var Stream = require("stream"); + var util = require("util"); + function DataStream(data) { + this.buffer = null; + this.writable = true; + this.readable = true; + if (!data) { + this.buffer = Buffer2.alloc(0); + return this; + } + if (typeof data.pipe === "function") { + this.buffer = Buffer2.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; } - CRC322.table = T0; - CRC322.bstr = crc32_bstr; - CRC322.buf = crc32_buf; - CRC322.str = crc32_str; - }); + throw new TypeError("Unexpected data type (" + typeof data + ")"); + } + util.inherits(DataStream, Stream); + DataStream.prototype.write = function write(data) { + this.buffer = Buffer2.concat([this.buffer, Buffer2.from(data)]); + this.emit("data", data); + }; + DataStream.prototype.end = function end(data) { + if (data) + this.write(data); + this.emit("end", data); + this.emit("close"); + this.writable = false; + this.readable = false; + }; + module2.exports = DataStream; } }); -// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/utils/common.js -var require_common = __commonJS({ - "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/utils/common.js"(exports2) { +// ../../../node_modules/.pnpm/buffer-equal-constant-time@1.0.1/node_modules/buffer-equal-constant-time/index.js +var require_buffer_equal_constant_time = __commonJS({ + "../../../node_modules/.pnpm/buffer-equal-constant-time@1.0.1/node_modules/buffer-equal-constant-time/index.js"(exports2, module2) { "use strict"; - var TYPED_OK = typeof Uint8Array !== "undefined" && typeof Uint16Array !== "undefined" && typeof Int32Array !== "undefined"; - function _has(obj, key) { - return Object.prototype.hasOwnProperty.call(obj, key); - } - exports2.assign = function(obj) { - var sources = Array.prototype.slice.call(arguments, 1); - while (sources.length) { - var source = sources.shift(); - if (!source) { - continue; - } - if (typeof source !== "object") { - throw new TypeError(source + "must be non-object"); - } - for (var p in source) { - if (_has(source, p)) { - obj[p] = source[p]; - } - } - } - return obj; - }; - exports2.shrinkBuf = function(buf, size) { - if (buf.length === size) { - return buf; - } - if (buf.subarray) { - return buf.subarray(0, size); + var Buffer2 = require("buffer").Buffer; + var SlowBuffer = require("buffer").SlowBuffer; + module2.exports = bufferEq; + function bufferEq(a, b) { + if (!Buffer2.isBuffer(a) || !Buffer2.isBuffer(b)) { + return false; } - buf.length = size; - return buf; - }; - var fnTyped = { - arraySet: function(dest, src, src_offs, len, dest_offs) { - if (src.subarray && dest.subarray) { - dest.set(src.subarray(src_offs, src_offs + len), dest_offs); - return; - } - for (var i = 0; i < len; i++) { - dest[dest_offs + i] = src[src_offs + i]; - } - }, - // Join array of chunks to single array. - flattenChunks: function(chunks) { - var i, l, len, pos, chunk, result; - len = 0; - for (i = 0, l = chunks.length; i < l; i++) { - len += chunks[i].length; - } - result = new Uint8Array(len); - pos = 0; - for (i = 0, l = chunks.length; i < l; i++) { - chunk = chunks[i]; - result.set(chunk, pos); - pos += chunk.length; - } - return result; + if (a.length !== b.length) { + return false; } - }; - var fnUntyped = { - arraySet: function(dest, src, src_offs, len, dest_offs) { - for (var i = 0; i < len; i++) { - dest[dest_offs + i] = src[src_offs + i]; - } - }, - // Join array of chunks to single array. - flattenChunks: function(chunks) { - return [].concat.apply([], chunks); + var c = 0; + for (var i = 0; i < a.length; i++) { + c |= a[i] ^ b[i]; } + return c === 0; + } + bufferEq.install = function() { + Buffer2.prototype.equal = SlowBuffer.prototype.equal = function equal(that) { + return bufferEq(this, that); + }; }; - exports2.setTyped = function(on) { - if (on) { - exports2.Buf8 = Uint8Array; - exports2.Buf16 = Uint16Array; - exports2.Buf32 = Int32Array; - exports2.assign(exports2, fnTyped); - } else { - exports2.Buf8 = Array; - exports2.Buf16 = Array; - exports2.Buf32 = Array; - exports2.assign(exports2, fnUntyped); - } + var origBufEqual = Buffer2.prototype.equal; + var origSlowBufEqual = SlowBuffer.prototype.equal; + bufferEq.restore = function() { + Buffer2.prototype.equal = origBufEqual; + SlowBuffer.prototype.equal = origSlowBufEqual; }; - exports2.setTyped(TYPED_OK); } }); -// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/trees.js -var require_trees = __commonJS({ - "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/trees.js"(exports2) { +// ../../../node_modules/.pnpm/ecdsa-sig-formatter@1.0.11/node_modules/ecdsa-sig-formatter/src/param-bytes-for-alg.js +var require_param_bytes_for_alg = __commonJS({ + "../../../node_modules/.pnpm/ecdsa-sig-formatter@1.0.11/node_modules/ecdsa-sig-formatter/src/param-bytes-for-alg.js"(exports2, module2) { "use strict"; - var utils = require_common(); - var Z_FIXED = 4; - var Z_BINARY = 0; - var Z_TEXT = 1; - var Z_UNKNOWN = 2; - function zero(buf) { - var len = buf.length; - while (--len >= 0) { - buf[len] = 0; - } - } - var STORED_BLOCK = 0; - var STATIC_TREES = 1; - var DYN_TREES = 2; - var MIN_MATCH = 3; - var MAX_MATCH = 258; - var LENGTH_CODES = 29; - var LITERALS = 256; - var L_CODES = LITERALS + 1 + LENGTH_CODES; - var D_CODES = 30; - var BL_CODES = 19; - var HEAP_SIZE = 2 * L_CODES + 1; - var MAX_BITS = 15; - var Buf_size = 16; - var MAX_BL_BITS = 7; - var END_BLOCK = 256; - var REP_3_6 = 16; - var REPZ_3_10 = 17; - var REPZ_11_138 = 18; - var extra_lbits = ( - /* extra bits for each length code */ - [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0] - ); - var extra_dbits = ( - /* extra bits for each distance code */ - [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13] - ); - var extra_blbits = ( - /* extra bits for each bit length code */ - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7] - ); - var bl_order = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]; - var DIST_CODE_LEN = 512; - var static_ltree = new Array((L_CODES + 2) * 2); - zero(static_ltree); - var static_dtree = new Array(D_CODES * 2); - zero(static_dtree); - var _dist_code = new Array(DIST_CODE_LEN); - zero(_dist_code); - var _length_code = new Array(MAX_MATCH - MIN_MATCH + 1); - zero(_length_code); - var base_length = new Array(LENGTH_CODES); - zero(base_length); - var base_dist = new Array(D_CODES); - zero(base_dist); - function StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) { - this.static_tree = static_tree; - this.extra_bits = extra_bits; - this.extra_base = extra_base; - this.elems = elems; - this.max_length = max_length; - this.has_stree = static_tree && static_tree.length; - } - var static_l_desc; - var static_d_desc; - var static_bl_desc; - function TreeDesc(dyn_tree, stat_desc) { - this.dyn_tree = dyn_tree; - this.max_code = 0; - this.stat_desc = stat_desc; - } - function d_code(dist) { - return dist < 256 ? _dist_code[dist] : _dist_code[256 + (dist >>> 7)]; - } - function put_short(s, w) { - s.pending_buf[s.pending++] = w & 255; - s.pending_buf[s.pending++] = w >>> 8 & 255; + function getParamSize(keySize) { + var result = (keySize / 8 | 0) + (keySize % 8 === 0 ? 0 : 1); + return result; } - function send_bits(s, value, length) { - if (s.bi_valid > Buf_size - length) { - s.bi_buf |= value << s.bi_valid & 65535; - put_short(s, s.bi_buf); - s.bi_buf = value >> Buf_size - s.bi_valid; - s.bi_valid += length - Buf_size; - } else { - s.bi_buf |= value << s.bi_valid & 65535; - s.bi_valid += length; + var paramBytesForAlg = { + ES256: getParamSize(256), + ES384: getParamSize(384), + ES512: getParamSize(521) + }; + function getParamBytesForAlg(alg) { + var paramBytes = paramBytesForAlg[alg]; + if (paramBytes) { + return paramBytes; } + throw new Error('Unknown algorithm "' + alg + '"'); } - function send_code(s, c, tree) { - send_bits( - s, - tree[c * 2], - tree[c * 2 + 1] - /*.Len*/ - ); - } - function bi_reverse(code, len) { - var res = 0; - do { - res |= code & 1; - code >>>= 1; - res <<= 1; - } while (--len > 0); - return res >>> 1; + module2.exports = getParamBytesForAlg; + } +}); + +// ../../../node_modules/.pnpm/ecdsa-sig-formatter@1.0.11/node_modules/ecdsa-sig-formatter/src/ecdsa-sig-formatter.js +var require_ecdsa_sig_formatter = __commonJS({ + "../../../node_modules/.pnpm/ecdsa-sig-formatter@1.0.11/node_modules/ecdsa-sig-formatter/src/ecdsa-sig-formatter.js"(exports2, module2) { + "use strict"; + var Buffer2 = require_safe_buffer().Buffer; + var getParamBytesForAlg = require_param_bytes_for_alg(); + var MAX_OCTET = 128; + var CLASS_UNIVERSAL = 0; + var PRIMITIVE_BIT = 32; + var TAG_SEQ = 16; + var TAG_INT = 2; + var ENCODED_TAG_SEQ = TAG_SEQ | PRIMITIVE_BIT | CLASS_UNIVERSAL << 6; + var ENCODED_TAG_INT = TAG_INT | CLASS_UNIVERSAL << 6; + function base64Url(base64) { + return base64.replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_"); } - function bi_flush(s) { - if (s.bi_valid === 16) { - put_short(s, s.bi_buf); - s.bi_buf = 0; - s.bi_valid = 0; - } else if (s.bi_valid >= 8) { - s.pending_buf[s.pending++] = s.bi_buf & 255; - s.bi_buf >>= 8; - s.bi_valid -= 8; + function signatureAsBuffer(signature) { + if (Buffer2.isBuffer(signature)) { + return signature; + } else if ("string" === typeof signature) { + return Buffer2.from(signature, "base64"); } + throw new TypeError("ECDSA signature must be a Base64 string or a Buffer"); } - function gen_bitlen(s, desc) { - var tree = desc.dyn_tree; - var max_code = desc.max_code; - var stree = desc.stat_desc.static_tree; - var has_stree = desc.stat_desc.has_stree; - var extra = desc.stat_desc.extra_bits; - var base = desc.stat_desc.extra_base; - var max_length = desc.stat_desc.max_length; - var h; - var n, m; - var bits; - var xbits; - var f; - var overflow = 0; - for (bits = 0; bits <= MAX_BITS; bits++) { - s.bl_count[bits] = 0; + 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"'); } - tree[s.heap[s.heap_max] * 2 + 1] = 0; - for (h = s.heap_max + 1; h < HEAP_SIZE; h++) { - n = s.heap[h]; - bits = tree[tree[n * 2 + 1] * 2 + 1] + 1; - if (bits > max_length) { - bits = max_length; - overflow++; - } - tree[n * 2 + 1] = bits; - if (n > max_code) { - continue; - } - s.bl_count[bits]++; - xbits = 0; - if (n >= base) { - xbits = extra[n - base]; - } - f = tree[n * 2]; - s.opt_len += f * (bits + xbits); - if (has_stree) { - s.static_len += f * (stree[n * 2 + 1] + xbits); - } + var seqLength = signature[offset++]; + if (seqLength === (MAX_OCTET | 1)) { + seqLength = signature[offset++]; } - if (overflow === 0) { - return; + if (inputLength - offset < seqLength) { + throw new Error('"seq" specified length of "' + seqLength + '", only "' + (inputLength - offset) + '" remaining'); } - do { - bits = max_length - 1; - while (s.bl_count[bits] === 0) { - bits--; - } - s.bl_count[bits]--; - s.bl_count[bits + 1] += 2; - s.bl_count[max_length]--; - overflow -= 2; - } while (overflow > 0); - for (bits = max_length; bits !== 0; bits--) { - n = s.bl_count[bits]; - while (n !== 0) { - m = s.heap[--h]; - if (m > max_code) { - continue; - } - if (tree[m * 2 + 1] !== bits) { - s.opt_len += (bits - tree[m * 2 + 1]) * tree[m * 2]; - tree[m * 2 + 1] = bits; - } - n--; - } + 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 = Buffer2.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 gen_codes(tree, max_code, bl_count) { - var next_code = new Array(MAX_BITS + 1); - var code = 0; - var bits; - var n; - for (bits = 1; bits <= MAX_BITS; bits++) { - next_code[bits] = code = code + bl_count[bits - 1] << 1; + function countPadding(buf, start, stop) { + var padding = 0; + while (start + padding < stop && buf[start + padding] === 0) { + ++padding; } - for (n = 0; n <= max_code; n++) { - var len = tree[n * 2 + 1]; - if (len === 0) { - continue; - } - tree[n * 2] = bi_reverse(next_code[len]++, len); + var needsSign = buf[start + padding] >= MAX_OCTET; + if (needsSign) { + --padding; } + return padding; } - function tr_static_init() { - var n; - var bits; - var length; - var code; - var dist; - var bl_count = new Array(MAX_BITS + 1); - length = 0; - for (code = 0; code < LENGTH_CODES - 1; code++) { - base_length[code] = length; - for (n = 0; n < 1 << extra_lbits[code]; n++) { - _length_code[length++] = code; - } + 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 + '"'); } - _length_code[length - 1] = code; - dist = 0; - for (code = 0; code < 16; code++) { - base_dist[code] = dist; - for (n = 0; n < 1 << extra_dbits[code]; n++) { - _dist_code[dist++] = code; - } + var rPadding = countPadding(signature, 0, paramBytes); + var sPadding = countPadding(signature, paramBytes, signature.length); + var rLength = paramBytes - rPadding; + var sLength = paramBytes - sPadding; + var rsBytes = 1 + 1 + rLength + 1 + 1 + sLength; + var shortLength = rsBytes < MAX_OCTET; + var dst = Buffer2.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; } - dist >>= 7; - for (; code < D_CODES; code++) { - base_dist[code] = dist << 7; - for (n = 0; n < 1 << extra_dbits[code] - 7; n++) { - _dist_code[256 + dist++] = code; - } + 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; + } + module2.exports = { + derToJose, + joseToDer + }; + } +}); + +// ../../../node_modules/.pnpm/jwa@1.4.1/node_modules/jwa/index.js +var require_jwa = __commonJS({ + "../../../node_modules/.pnpm/jwa@1.4.1/node_modules/jwa/index.js"(exports2, module2) { + var bufferEqual = require_buffer_equal_constant_time(); + var Buffer2 = require_safe_buffer().Buffer; + var crypto5 = require("crypto"); + var formatEcdsa = require_ecdsa_sig_formatter(); + var util = 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 crypto5.createPublicKey === "function"; + if (supportsKeyObjects) { + MSG_INVALID_VERIFIER_KEY += " or a KeyObject"; + MSG_INVALID_SECRET += "or a KeyObject"; + } + function checkIsPublicKey(key) { + if (Buffer2.isBuffer(key)) { + return; } - for (bits = 0; bits <= MAX_BITS; bits++) { - bl_count[bits] = 0; + if (typeof key === "string") { + return; } - n = 0; - while (n <= 143) { - static_ltree[n * 2 + 1] = 8; - n++; - bl_count[8]++; + if (!supportsKeyObjects) { + throw typeError(MSG_INVALID_VERIFIER_KEY); } - while (n <= 255) { - static_ltree[n * 2 + 1] = 9; - n++; - bl_count[9]++; + if (typeof key !== "object") { + throw typeError(MSG_INVALID_VERIFIER_KEY); } - while (n <= 279) { - static_ltree[n * 2 + 1] = 7; - n++; - bl_count[7]++; + if (typeof key.type !== "string") { + throw typeError(MSG_INVALID_VERIFIER_KEY); } - while (n <= 287) { - static_ltree[n * 2 + 1] = 8; - n++; - bl_count[8]++; + if (typeof key.asymmetricKeyType !== "string") { + throw typeError(MSG_INVALID_VERIFIER_KEY); } - gen_codes(static_ltree, L_CODES + 1, bl_count); - for (n = 0; n < D_CODES; n++) { - static_dtree[n * 2 + 1] = 5; - static_dtree[n * 2] = bi_reverse(n, 5); + if (typeof key.export !== "function") { + throw typeError(MSG_INVALID_VERIFIER_KEY); } - static_l_desc = new StaticTreeDesc(static_ltree, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS); - static_d_desc = new StaticTreeDesc(static_dtree, extra_dbits, 0, D_CODES, MAX_BITS); - static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS); } - function init_block(s) { - var n; - for (n = 0; n < L_CODES; n++) { - s.dyn_ltree[n * 2] = 0; - } - for (n = 0; n < D_CODES; n++) { - s.dyn_dtree[n * 2] = 0; + function checkIsPrivateKey(key) { + if (Buffer2.isBuffer(key)) { + return; } - for (n = 0; n < BL_CODES; n++) { - s.bl_tree[n * 2] = 0; + if (typeof key === "string") { + return; } - s.dyn_ltree[END_BLOCK * 2] = 1; - s.opt_len = s.static_len = 0; - s.last_lit = s.matches = 0; - } - function bi_windup(s) { - if (s.bi_valid > 8) { - put_short(s, s.bi_buf); - } else if (s.bi_valid > 0) { - s.pending_buf[s.pending++] = s.bi_buf; + if (typeof key === "object") { + return; } - s.bi_buf = 0; - s.bi_valid = 0; + throw typeError(MSG_INVALID_SIGNER_KEY); } - function copy_block(s, buf, len, header) { - bi_windup(s); - if (header) { - put_short(s, len); - put_short(s, ~len); + function checkIsSecretKey(key) { + if (Buffer2.isBuffer(key)) { + return; } - utils.arraySet(s.pending_buf, s.window, buf, len, s.pending); - s.pending += len; - } - function smaller(tree, n, m, depth) { - var _n2 = n * 2; - var _m2 = m * 2; - return tree[_n2] < tree[_m2] || tree[_n2] === tree[_m2] && depth[n] <= depth[m]; - } - function pqdownheap(s, tree, k) { - var v = s.heap[k]; - var j = k << 1; - while (j <= s.heap_len) { - if (j < s.heap_len && smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) { - j++; - } - if (smaller(tree, v, s.heap[j], s.depth)) { - break; - } - s.heap[k] = s.heap[j]; - k = j; - j <<= 1; + if (typeof key === "string") { + return key; } - s.heap[k] = v; - } - function compress_block(s, ltree, dtree) { - var dist; - var lc; - var lx = 0; - var code; - var extra; - if (s.last_lit !== 0) { - do { - dist = s.pending_buf[s.d_buf + lx * 2] << 8 | s.pending_buf[s.d_buf + lx * 2 + 1]; - lc = s.pending_buf[s.l_buf + lx]; - lx++; - if (dist === 0) { - send_code(s, lc, ltree); - } else { - code = _length_code[lc]; - send_code(s, code + LITERALS + 1, ltree); - extra = extra_lbits[code]; - if (extra !== 0) { - lc -= base_length[code]; - send_bits(s, lc, extra); - } - dist--; - code = d_code(dist); - send_code(s, code, dtree); - extra = extra_dbits[code]; - if (extra !== 0) { - dist -= base_dist[code]; - send_bits(s, dist, extra); - } - } - } while (lx < s.last_lit); + if (!supportsKeyObjects) { + throw typeError(MSG_INVALID_SECRET); } - send_code(s, END_BLOCK, ltree); - } - function build_tree(s, desc) { - var tree = desc.dyn_tree; - var stree = desc.stat_desc.static_tree; - var has_stree = desc.stat_desc.has_stree; - var elems = desc.stat_desc.elems; - var n, m; - var max_code = -1; - var node; - s.heap_len = 0; - s.heap_max = HEAP_SIZE; - for (n = 0; n < elems; n++) { - if (tree[n * 2] !== 0) { - s.heap[++s.heap_len] = max_code = n; - s.depth[n] = 0; - } else { - tree[n * 2 + 1] = 0; - } + if (typeof key !== "object") { + throw typeError(MSG_INVALID_SECRET); } - while (s.heap_len < 2) { - node = s.heap[++s.heap_len] = max_code < 2 ? ++max_code : 0; - tree[node * 2] = 1; - s.depth[node] = 0; - s.opt_len--; - if (has_stree) { - s.static_len -= stree[node * 2 + 1]; - } + if (key.type !== "secret") { + throw typeError(MSG_INVALID_SECRET); } - desc.max_code = max_code; - for (n = s.heap_len >> 1; n >= 1; n--) { - pqdownheap(s, tree, n); + if (typeof key.export !== "function") { + throw typeError(MSG_INVALID_SECRET); } - node = elems; - do { - n = s.heap[ - 1 - /*SMALLEST*/ - ]; - s.heap[ - 1 - /*SMALLEST*/ - ] = s.heap[s.heap_len--]; - pqdownheap( - s, - tree, - 1 - /*SMALLEST*/ - ); - m = s.heap[ - 1 - /*SMALLEST*/ - ]; - s.heap[--s.heap_max] = n; - s.heap[--s.heap_max] = m; - tree[node * 2] = tree[n * 2] + tree[m * 2]; - s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1; - tree[n * 2 + 1] = tree[m * 2 + 1] = node; - s.heap[ - 1 - /*SMALLEST*/ - ] = node++; - pqdownheap( - s, - tree, - 1 - /*SMALLEST*/ - ); - } while (s.heap_len >= 2); - s.heap[--s.heap_max] = s.heap[ - 1 - /*SMALLEST*/ - ]; - gen_bitlen(s, desc); - gen_codes(tree, max_code, s.bl_count); } - function scan_tree(s, tree, max_code) { - var n; - var prevlen = -1; - var curlen; - var nextlen = tree[0 * 2 + 1]; - var count = 0; - var max_count = 7; - var min_count = 4; - if (nextlen === 0) { - max_count = 138; - min_count = 3; - } - tree[(max_code + 1) * 2 + 1] = 65535; - for (n = 0; n <= max_code; n++) { - curlen = nextlen; - nextlen = tree[(n + 1) * 2 + 1]; - if (++count < max_count && curlen === nextlen) { - continue; - } else if (count < min_count) { - s.bl_tree[curlen * 2] += count; - } else if (curlen !== 0) { - if (curlen !== prevlen) { - s.bl_tree[curlen * 2]++; - } - s.bl_tree[REP_3_6 * 2]++; - } else if (count <= 10) { - s.bl_tree[REPZ_3_10 * 2]++; - } else { - s.bl_tree[REPZ_11_138 * 2]++; - } - count = 0; - prevlen = curlen; - if (nextlen === 0) { - max_count = 138; - min_count = 3; - } else if (curlen === nextlen) { - max_count = 6; - min_count = 3; - } else { - max_count = 7; - min_count = 4; + function fromBase64(base64) { + return base64.replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_"); + } + function toBase64(base64url) { + base64url = base64url.toString(); + var padding = 4 - base64url.length % 4; + if (padding !== 4) { + for (var i = 0; i < padding; ++i) { + base64url += "="; } } + return base64url.replace(/\-/g, "+").replace(/_/g, "/"); } - function send_tree(s, tree, max_code) { - var n; - var prevlen = -1; - var curlen; - var nextlen = tree[0 * 2 + 1]; - var count = 0; - var max_count = 7; - var min_count = 4; - if (nextlen === 0) { - max_count = 138; - min_count = 3; - } - for (n = 0; n <= max_code; n++) { - curlen = nextlen; - nextlen = tree[(n + 1) * 2 + 1]; - if (++count < max_count && curlen === nextlen) { - continue; - } else if (count < min_count) { - do { - send_code(s, curlen, s.bl_tree); - } while (--count !== 0); - } else if (curlen !== 0) { - if (curlen !== prevlen) { - send_code(s, curlen, s.bl_tree); - count--; - } - send_code(s, REP_3_6, s.bl_tree); - send_bits(s, count - 3, 2); - } else if (count <= 10) { - send_code(s, REPZ_3_10, s.bl_tree); - send_bits(s, count - 3, 3); - } else { - send_code(s, REPZ_11_138, s.bl_tree); - send_bits(s, count - 11, 7); - } - count = 0; - prevlen = curlen; - if (nextlen === 0) { - max_count = 138; - min_count = 3; - } else if (curlen === nextlen) { - max_count = 6; - min_count = 3; - } else { - max_count = 7; - min_count = 4; - } + function typeError(template) { + var args = [].slice.call(arguments, 1); + var errMsg = util.format.bind(util, template).apply(null, args); + return new TypeError(errMsg); + } + function bufferOrString(obj) { + return Buffer2.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 = crypto5.createHmac("sha" + bits, secret); + var sig = (hmac.update(thing), hmac.digest("base64")); + return fromBase64(sig); + }; + } + function createHmacVerifier(bits) { + return function verify(thing, signature, secret) { + var computedSig = createHmacSigner(bits)(thing, secret); + return bufferEqual(Buffer2.from(signature), Buffer2.from(computedSig)); + }; + } + function createKeySigner(bits) { + return function sign(thing, privateKey) { + checkIsPrivateKey(privateKey); + thing = normalizeInput(thing); + var signer = crypto5.createSign("RSA-SHA" + bits); + var sig = (signer.update(thing), signer.sign(privateKey, "base64")); + return fromBase64(sig); + }; + } + function createKeyVerifier(bits) { + return function verify(thing, signature, publicKey) { + checkIsPublicKey(publicKey); + thing = normalizeInput(thing); + signature = toBase64(signature); + var verifier = crypto5.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 = crypto5.createSign("RSA-SHA" + bits); + var sig = (signer.update(thing), signer.sign({ + key: privateKey, + padding: crypto5.constants.RSA_PKCS1_PSS_PADDING, + saltLength: crypto5.constants.RSA_PSS_SALTLEN_DIGEST + }, "base64")); + return fromBase64(sig); + }; + } + function createPSSKeyVerifier(bits) { + return function verify(thing, signature, publicKey) { + checkIsPublicKey(publicKey); + thing = normalizeInput(thing); + signature = toBase64(signature); + var verifier = crypto5.createVerify("RSA-SHA" + bits); + verifier.update(thing); + return verifier.verify({ + key: publicKey, + padding: crypto5.constants.RSA_PKCS1_PSS_PADDING, + saltLength: crypto5.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"); + var result = inner(thing, signature, publicKey); + return result; + }; + } + function createNoneSigner() { + return function sign() { + return ""; + }; + } + function createNoneVerifier() { + return function verify(thing, signature) { + return signature === ""; + }; + } + module2.exports = function jwa(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)$/i); + 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) + }; + }; + } +}); + +// ../../../node_modules/.pnpm/jws@3.2.2/node_modules/jws/lib/tostring.js +var require_tostring = __commonJS({ + "../../../node_modules/.pnpm/jws@3.2.2/node_modules/jws/lib/tostring.js"(exports2, module2) { + var Buffer2 = require("buffer").Buffer; + module2.exports = function toString(obj) { + if (typeof obj === "string") + return obj; + if (typeof obj === "number" || Buffer2.isBuffer(obj)) + return obj.toString(); + return JSON.stringify(obj); + }; + } +}); + +// ../../../node_modules/.pnpm/jws@3.2.2/node_modules/jws/lib/sign-stream.js +var require_sign_stream = __commonJS({ + "../../../node_modules/.pnpm/jws@3.2.2/node_modules/jws/lib/sign-stream.js"(exports2, module2) { + var Buffer2 = 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"); + function base64url(string, encoding) { + return Buffer2.from(string, encoding).toString("base64").replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_"); + } + function jwsSecuredInput(header, payload, encoding) { + encoding = encoding || "utf8"; + var encodedHeader = base64url(toString(header), "binary"); + var encodedPayload = base64url(toString(payload), encoding); + return util.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(header.alg); + var securedInput = jwsSecuredInput(header, payload, encoding); + var signature = algo.sign(securedInput, secretOrKey); + return util.format("%s.%s", securedInput, signature); + } + function SignStream(opts) { + var secret = opts.secret || opts.privateKey || opts.key; + var secretStream = new DataStream(secret); + this.readable = true; + this.header = opts.header; + this.encoding = opts.encoding; + this.secret = this.privateKey = this.key = secretStream; + this.payload = new DataStream(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.inherits(SignStream, Stream); + SignStream.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.sign = jwsSign; + module2.exports = SignStream; + } +}); + +// ../../../node_modules/.pnpm/jws@3.2.2/node_modules/jws/lib/verify-stream.js +var require_verify_stream = __commonJS({ + "../../../node_modules/.pnpm/jws@3.2.2/node_modules/jws/lib/verify-stream.js"(exports2, module2) { + var Buffer2 = 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 isObject2(thing) { + return Object.prototype.toString.call(thing) === "[object Object]"; } - function build_bl_tree(s) { - var max_blindex; - scan_tree(s, s.dyn_ltree, s.l_desc.max_code); - scan_tree(s, s.dyn_dtree, s.d_desc.max_code); - build_tree(s, s.bl_desc); - for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) { - if (s.bl_tree[bl_order[max_blindex] * 2 + 1] !== 0) { - break; - } + function safeJsonParse(thing) { + if (isObject2(thing)) + return thing; + try { + return JSON.parse(thing); + } catch (e) { + return void 0; } - s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4; - return max_blindex; } - function send_all_trees(s, lcodes, dcodes, blcodes) { - var rank; - send_bits(s, lcodes - 257, 5); - send_bits(s, dcodes - 1, 5); - send_bits(s, blcodes - 4, 4); - for (rank = 0; rank < blcodes; rank++) { - send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1], 3); - } - send_tree(s, s.dyn_ltree, lcodes - 1); - send_tree(s, s.dyn_dtree, dcodes - 1); + function headerFromJWS(jwsSig) { + var encodedHeader = jwsSig.split(".", 1)[0]; + return safeJsonParse(Buffer2.from(encodedHeader, "base64").toString("binary")); } - function detect_data_type(s) { - var black_mask = 4093624447; - var n; - for (n = 0; n <= 31; n++, black_mask >>>= 1) { - if (black_mask & 1 && s.dyn_ltree[n * 2] !== 0) { - return Z_BINARY; - } - } - if (s.dyn_ltree[9 * 2] !== 0 || s.dyn_ltree[10 * 2] !== 0 || s.dyn_ltree[13 * 2] !== 0) { - return Z_TEXT; - } - for (n = 32; n < LITERALS; n++) { - if (s.dyn_ltree[n * 2] !== 0) { - return Z_TEXT; - } - } - return Z_BINARY; + function securedInputFromJWS(jwsSig) { + return jwsSig.split(".", 2).join("."); } - var static_init_done = false; - function _tr_init(s) { - if (!static_init_done) { - tr_static_init(); - static_init_done = true; - } - s.l_desc = new TreeDesc(s.dyn_ltree, static_l_desc); - s.d_desc = new TreeDesc(s.dyn_dtree, static_d_desc); - s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc); - s.bi_buf = 0; - s.bi_valid = 0; - init_block(s); + function signatureFromJWS(jwsSig) { + return jwsSig.split(".")[2]; } - function _tr_stored_block(s, buf, stored_len, last) { - send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3); - copy_block(s, buf, stored_len, true); + function payloadFromJWS(jwsSig, encoding) { + encoding = encoding || "utf8"; + var payload = jwsSig.split(".")[1]; + return Buffer2.from(payload, "base64").toString(encoding); } - function _tr_align(s) { - send_bits(s, STATIC_TREES << 1, 3); - send_code(s, END_BLOCK, static_ltree); - bi_flush(s); + function isValidJws(string) { + return JWS_REGEX.test(string) && !!headerFromJWS(string); } - function _tr_flush_block(s, buf, stored_len, last) { - var opt_lenb, static_lenb; - var max_blindex = 0; - if (s.level > 0) { - if (s.strm.data_type === Z_UNKNOWN) { - s.strm.data_type = detect_data_type(s); - } - build_tree(s, s.l_desc); - build_tree(s, s.d_desc); - max_blindex = build_bl_tree(s); - opt_lenb = s.opt_len + 3 + 7 >>> 3; - static_lenb = s.static_len + 3 + 7 >>> 3; - if (static_lenb <= opt_lenb) { - opt_lenb = static_lenb; - } - } else { - opt_lenb = static_lenb = stored_len + 5; - } - if (stored_len + 4 <= opt_lenb && buf !== -1) { - _tr_stored_block(s, buf, stored_len, last); - } else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) { - send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3); - compress_block(s, static_ltree, static_dtree); - } else { - send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3); - send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1); - compress_block(s, s.dyn_ltree, s.dyn_dtree); - } - init_block(s); - if (last) { - bi_windup(s); + function jwsVerify(jwsSig, algorithm, secretOrKey) { + if (!algorithm) { + var err = 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); + var algo = jwa(algorithm); + return algo.verify(securedInput, signature, secretOrKey); } - function _tr_tally(s, dist, lc) { - s.pending_buf[s.d_buf + s.last_lit * 2] = dist >>> 8 & 255; - s.pending_buf[s.d_buf + s.last_lit * 2 + 1] = dist & 255; - s.pending_buf[s.l_buf + s.last_lit] = lc & 255; - s.last_lit++; - if (dist === 0) { - s.dyn_ltree[lc * 2]++; - } else { - s.matches++; - dist--; - s.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2]++; - s.dyn_dtree[d_code(dist) * 2]++; - } - return s.last_lit === s.lit_bufsize - 1; + 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) + }; } - exports2._tr_init = _tr_init; - exports2._tr_stored_block = _tr_stored_block; - exports2._tr_flush_block = _tr_flush_block; - exports2._tr_tally = _tr_tally; - exports2._tr_align = _tr_align; + function VerifyStream(opts) { + opts = opts || {}; + var secretOrKey = opts.secret || opts.publicKey || opts.key; + 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, Stream); + VerifyStream.prototype.verify = function verify() { + try { + var valid = jwsVerify(this.signature.buffer, this.algorithm, this.key.buffer); + var obj = jwsDecode(this.signature.buffer, this.encoding); + this.emit("done", valid, obj); + this.emit("data", valid); + this.emit("end"); + this.readable = false; + return valid; + } catch (e) { + this.readable = false; + this.emit("error", e); + this.emit("close"); + } + }; + VerifyStream.decode = jwsDecode; + VerifyStream.isValid = isValidJws; + VerifyStream.verify = jwsVerify; + module2.exports = VerifyStream; } }); -// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/adler32.js -var require_adler32 = __commonJS({ - "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/adler32.js"(exports2, module2) { - "use strict"; - function adler32(adler, buf, len, pos) { - var s1 = adler & 65535 | 0, s2 = adler >>> 16 & 65535 | 0, n = 0; - while (len !== 0) { - n = len > 2e3 ? 2e3 : len; - len -= n; - do { - s1 = s1 + buf[pos++] | 0; - s2 = s2 + s1 | 0; - } while (--n); - s1 %= 65521; - s2 %= 65521; - } - return s1 | s2 << 16 | 0; - } - module2.exports = adler32; +// ../../../node_modules/.pnpm/jws@3.2.2/node_modules/jws/index.js +var require_jws = __commonJS({ + "../../../node_modules/.pnpm/jws@3.2.2/node_modules/jws/index.js"(exports2) { + var SignStream = require_sign_stream(); + var VerifyStream = require_verify_stream(); + var ALGORITHMS = [ + "HS256", + "HS384", + "HS512", + "RS256", + "RS384", + "RS512", + "PS256", + "PS384", + "PS512", + "ES256", + "ES384", + "ES512" + ]; + exports2.ALGORITHMS = ALGORITHMS; + exports2.sign = SignStream.sign; + exports2.verify = VerifyStream.verify; + exports2.decode = VerifyStream.decode; + exports2.isValid = VerifyStream.isValid; + exports2.createSign = function createSign(opts) { + return new SignStream(opts); + }; + exports2.createVerify = function createVerify(opts) { + return new VerifyStream(opts); + }; } }); -// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/crc32.js -var require_crc322 = __commonJS({ - "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/crc32.js"(exports2, module2) { - "use strict"; - function makeTable() { - var c, table = []; - for (var n = 0; n < 256; n++) { - c = n; - for (var k = 0; k < 8; k++) { - c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1; +// ../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/decode.js +var require_decode = __commonJS({ + "../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/decode.js"(exports2, module2) { + var jws = require_jws(); + module2.exports = function(jwt, options) { + options = options || {}; + var decoded = jws.decode(jwt, 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) { } - table[n] = c; } - return table; - } - var crcTable = makeTable(); - function crc322(crc, buf, len, pos) { - var t = crcTable, end = pos + len; - crc ^= -1; - for (var i = pos; i < end; i++) { - crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 255]; + if (options.complete === true) { + return { + header: decoded.header, + payload, + signature: decoded.signature + }; } - return crc ^ -1; - } - module2.exports = crc322; + return payload; + }; } }); -// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/messages.js -var require_messages = __commonJS({ - "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/messages.js"(exports2, module2) { - "use strict"; - module2.exports = { - 2: "need dictionary", - /* Z_NEED_DICT 2 */ - 1: "stream end", - /* Z_STREAM_END 1 */ - 0: "", - /* Z_OK 0 */ - "-1": "file error", - /* Z_ERRNO (-1) */ - "-2": "stream error", - /* Z_STREAM_ERROR (-2) */ - "-3": "data error", - /* Z_DATA_ERROR (-3) */ - "-4": "insufficient memory", - /* Z_MEM_ERROR (-4) */ - "-5": "buffer error", - /* Z_BUF_ERROR (-5) */ - "-6": "incompatible version" - /* Z_VERSION_ERROR (-6) */ +// ../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/JsonWebTokenError.js +var require_JsonWebTokenError = __commonJS({ + "../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/JsonWebTokenError.js"(exports2, module2) { + var JsonWebTokenError = 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.prototype = Object.create(Error.prototype); + JsonWebTokenError.prototype.constructor = JsonWebTokenError; + module2.exports = JsonWebTokenError; } }); -// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/deflate.js -var require_deflate = __commonJS({ - "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/deflate.js"(exports2) { - "use strict"; - var utils = require_common(); - var trees = require_trees(); - var adler32 = require_adler32(); - var crc322 = require_crc322(); - var msg = require_messages(); - var Z_NO_FLUSH = 0; - var Z_PARTIAL_FLUSH = 1; - var Z_FULL_FLUSH = 3; - var Z_FINISH = 4; - var Z_BLOCK = 5; - var Z_OK = 0; - var Z_STREAM_END = 1; - var Z_STREAM_ERROR = -2; - var Z_DATA_ERROR = -3; - var Z_BUF_ERROR = -5; - var Z_DEFAULT_COMPRESSION = -1; - var Z_FILTERED = 1; - var Z_HUFFMAN_ONLY = 2; - var Z_RLE = 3; - var Z_FIXED = 4; - var Z_DEFAULT_STRATEGY = 0; - var Z_UNKNOWN = 2; - var Z_DEFLATED = 8; - var MAX_MEM_LEVEL = 9; - var MAX_WBITS = 15; - var DEF_MEM_LEVEL = 8; - var LENGTH_CODES = 29; - var LITERALS = 256; - var L_CODES = LITERALS + 1 + LENGTH_CODES; - var D_CODES = 30; - var BL_CODES = 19; - var HEAP_SIZE = 2 * L_CODES + 1; - var MAX_BITS = 15; - var MIN_MATCH = 3; - var MAX_MATCH = 258; - var MIN_LOOKAHEAD = MAX_MATCH + MIN_MATCH + 1; - var PRESET_DICT = 32; - var INIT_STATE = 42; - var EXTRA_STATE = 69; - var NAME_STATE = 73; - var COMMENT_STATE = 91; - var HCRC_STATE = 103; - var BUSY_STATE = 113; - var FINISH_STATE = 666; - var BS_NEED_MORE = 1; - var BS_BLOCK_DONE = 2; - var BS_FINISH_STARTED = 3; - var BS_FINISH_DONE = 4; - var OS_CODE = 3; - function err(strm, errorCode) { - strm.msg = msg[errorCode]; - return errorCode; - } - function rank(f) { - return (f << 1) - (f > 4 ? 9 : 0); - } - function zero(buf) { - var len = buf.length; - while (--len >= 0) { - buf[len] = 0; +// ../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/NotBeforeError.js +var require_NotBeforeError = __commonJS({ + "../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/NotBeforeError.js"(exports2, module2) { + var JsonWebTokenError = require_JsonWebTokenError(); + var NotBeforeError = function(message, date) { + JsonWebTokenError.call(this, message); + this.name = "NotBeforeError"; + this.date = date; + }; + NotBeforeError.prototype = Object.create(JsonWebTokenError.prototype); + NotBeforeError.prototype.constructor = NotBeforeError; + module2.exports = NotBeforeError; + } +}); + +// ../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/TokenExpiredError.js +var require_TokenExpiredError = __commonJS({ + "../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/TokenExpiredError.js"(exports2, module2) { + var JsonWebTokenError = require_JsonWebTokenError(); + var TokenExpiredError = function(message, expiredAt) { + JsonWebTokenError.call(this, message); + this.name = "TokenExpiredError"; + this.expiredAt = expiredAt; + }; + TokenExpiredError.prototype = Object.create(JsonWebTokenError.prototype); + TokenExpiredError.prototype.constructor = TokenExpiredError; + module2.exports = TokenExpiredError; + } +}); + +// ../../../node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js +var require_ms = __commonJS({ + "../../../node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js"(exports2, module2) { + var s = 1e3; + var m = s * 60; + var h = m * 60; + var d = h * 24; + var w = d * 7; + var y = d * 365.25; + module2.exports = function(val, options) { + options = options || {}; + var type = typeof val; + if (type === "string" && val.length > 0) { + return parse2(val); + } else if (type === "number" && isFinite(val)) { + return options.long ? fmtLong(val) : fmtShort(val); } - } - function flush_pending(strm) { - var s = strm.state; - var len = s.pending; - if (len > strm.avail_out) { - len = strm.avail_out; + throw new Error( + "val is not a non-empty string or a valid number. val=" + JSON.stringify(val) + ); + }; + function parse2(str) { + str = String(str); + if (str.length > 100) { + return; } - if (len === 0) { + 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; } - utils.arraySet(strm.output, s.pending_buf, s.pending_out, len, strm.next_out); - strm.next_out += len; - s.pending_out += len; - strm.total_out += len; - strm.avail_out -= len; - s.pending -= len; - if (s.pending === 0) { - s.pending_out = 0; + var n = parseFloat(match[1]); + var type = (match[2] || "ms").toLowerCase(); + switch (type) { + 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 void 0; } } - function flush_block_only(s, last) { - trees._tr_flush_block(s, s.block_start >= 0 ? s.block_start : -1, s.strstart - s.block_start, last); - s.block_start = s.strstart; - flush_pending(s.strm); - } - function put_byte(s, b) { - s.pending_buf[s.pending++] = b; - } - function putShortMSB(s, b) { - s.pending_buf[s.pending++] = b >>> 8 & 255; - s.pending_buf[s.pending++] = b & 255; - } - function read_buf(strm, buf, start, size) { - var len = strm.avail_in; - if (len > size) { - len = size; + function fmtShort(ms) { + var msAbs = Math.abs(ms); + if (msAbs >= d) { + return Math.round(ms / d) + "d"; } - if (len === 0) { - return 0; + if (msAbs >= h) { + return Math.round(ms / h) + "h"; } - strm.avail_in -= len; - utils.arraySet(buf, strm.input, strm.next_in, len, start); - if (strm.state.wrap === 1) { - strm.adler = adler32(strm.adler, buf, len, start); - } else if (strm.state.wrap === 2) { - strm.adler = crc322(strm.adler, buf, len, start); + if (msAbs >= m) { + return Math.round(ms / m) + "m"; } - strm.next_in += len; - strm.total_in += len; - return len; + if (msAbs >= s) { + return Math.round(ms / s) + "s"; + } + return ms + "ms"; } - function longest_match(s, cur_match) { - var chain_length = s.max_chain_length; - var scan = s.strstart; - var match; - var len; - var best_len = s.prev_length; - var nice_match = s.nice_match; - var limit = s.strstart > s.w_size - MIN_LOOKAHEAD ? s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0; - var _win = s.window; - var wmask = s.w_mask; - var prev = s.prev; - var strend = s.strstart + MAX_MATCH; - var scan_end1 = _win[scan + best_len - 1]; - var scan_end = _win[scan + best_len]; - if (s.prev_length >= s.good_match) { - chain_length >>= 2; + function fmtLong(ms) { + var msAbs = Math.abs(ms); + if (msAbs >= d) { + return plural(ms, msAbs, d, "day"); } - if (nice_match > s.lookahead) { - nice_match = s.lookahead; + if (msAbs >= h) { + return plural(ms, msAbs, h, "hour"); } - do { - match = cur_match; - if (_win[match + best_len] !== scan_end || _win[match + best_len - 1] !== scan_end1 || _win[match] !== _win[scan] || _win[++match] !== _win[scan + 1]) { - continue; - } - scan += 2; - match++; - do { - } while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && scan < strend); - len = MAX_MATCH - (strend - scan); - scan = strend - MAX_MATCH; - if (len > best_len) { - s.match_start = cur_match; - best_len = len; - if (len >= nice_match) { - break; - } - scan_end1 = _win[scan + best_len - 1]; - scan_end = _win[scan + best_len]; - } - } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0); - if (best_len <= s.lookahead) { - return best_len; + if (msAbs >= m) { + return plural(ms, msAbs, m, "minute"); } - return s.lookahead; + if (msAbs >= s) { + return plural(ms, msAbs, s, "second"); + } + return ms + " ms"; } - function fill_window(s) { - var _w_size = s.w_size; - var p, n, m, more, str; - do { - more = s.window_size - s.lookahead - s.strstart; - if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) { - utils.arraySet(s.window, s.window, _w_size, _w_size, 0); - s.match_start -= _w_size; - s.strstart -= _w_size; - s.block_start -= _w_size; - n = s.hash_size; - p = n; - do { - m = s.head[--p]; - s.head[p] = m >= _w_size ? m - _w_size : 0; - } while (--n); - n = _w_size; - p = n; - do { - m = s.prev[--p]; - s.prev[p] = m >= _w_size ? m - _w_size : 0; - } while (--n); - more += _w_size; - } - if (s.strm.avail_in === 0) { - break; - } - n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more); - s.lookahead += n; - if (s.lookahead + s.insert >= MIN_MATCH) { - str = s.strstart - s.insert; - s.ins_h = s.window[str]; - s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str + 1]) & s.hash_mask; - while (s.insert) { - s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask; - s.prev[str & s.w_mask] = s.head[s.ins_h]; - s.head[s.ins_h] = str; - str++; - s.insert--; - if (s.lookahead + s.insert < MIN_MATCH) { - break; - } - } - } - } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0); + function plural(ms, msAbs, n, name) { + var isPlural = msAbs >= n * 1.5; + return Math.round(ms / n) + " " + name + (isPlural ? "s" : ""); } - function deflate_stored(s, flush) { - var max_block_size = 65535; - if (max_block_size > s.pending_buf_size - 5) { - max_block_size = s.pending_buf_size - 5; - } - for (; ; ) { - if (s.lookahead <= 1) { - fill_window(s); - if (s.lookahead === 0 && flush === Z_NO_FLUSH) { - return BS_NEED_MORE; - } - if (s.lookahead === 0) { - break; - } - } - s.strstart += s.lookahead; - s.lookahead = 0; - var max_start = s.block_start + max_block_size; - if (s.strstart === 0 || s.strstart >= max_start) { - s.lookahead = s.strstart - max_start; - s.strstart = max_start; - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } - } - if (s.strstart - s.block_start >= s.w_size - MIN_LOOKAHEAD) { - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } - } - } - s.insert = 0; - if (flush === Z_FINISH) { - flush_block_only(s, true); - if (s.strm.avail_out === 0) { - return BS_FINISH_STARTED; + } +}); + +// ../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/timespan.js +var require_timespan = __commonJS({ + "../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/timespan.js"(exports2, module2) { + var ms = require_ms(); + module2.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 BS_FINISH_DONE; + return Math.floor(timestamp + milliseconds / 1e3); + } else if (typeof time === "number") { + return timestamp + time; + } else { + return; } - if (s.strstart > s.block_start) { - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } + }; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/internal/constants.js +var require_constants7 = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/internal/constants.js"(exports2, module2) { + var SEMVER_SPEC_VERSION = "2.0.0"; + var MAX_LENGTH = 256; + var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */ + 9007199254740991; + var MAX_SAFE_COMPONENT_LENGTH = 16; + var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6; + var RELEASE_TYPES = [ + "major", + "premajor", + "minor", + "preminor", + "patch", + "prepatch", + "prerelease" + ]; + module2.exports = { + MAX_LENGTH, + MAX_SAFE_COMPONENT_LENGTH, + MAX_SAFE_BUILD_LENGTH, + MAX_SAFE_INTEGER, + RELEASE_TYPES, + SEMVER_SPEC_VERSION, + FLAG_INCLUDE_PRERELEASE: 1, + FLAG_LOOSE: 2 + }; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/internal/debug.js +var require_debug = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/internal/debug.js"(exports2, module2) { + var debug4 = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => { + }; + module2.exports = debug4; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/internal/re.js +var require_re = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/internal/re.js"(exports2, module2) { + var { + MAX_SAFE_COMPONENT_LENGTH, + MAX_SAFE_BUILD_LENGTH, + MAX_LENGTH + } = require_constants7(); + var debug4 = require_debug(); + exports2 = module2.exports = {}; + var re = exports2.re = []; + var safeRe = exports2.safeRe = []; + var src = exports2.src = []; + var t = exports2.t = {}; + var R = 0; + var LETTERDASHNUMBER = "[a-zA-Z0-9-]"; + var safeRegexReplacements = [ + ["\\s", 1], + ["\\d", MAX_LENGTH], + [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH] + ]; + var makeSafeRegex = (value) => { + for (const [token, max] of safeRegexReplacements) { + value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`); } - return BS_NEED_MORE; - } - function deflate_fast(s, flush) { - var hash_head; - var bflush; - for (; ; ) { - if (s.lookahead < MIN_LOOKAHEAD) { - fill_window(s); - if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) { - return BS_NEED_MORE; - } - if (s.lookahead === 0) { - break; - } - } - hash_head = 0; - if (s.lookahead >= MIN_MATCH) { - s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask; - hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h]; - s.head[s.ins_h] = s.strstart; - } - if (hash_head !== 0 && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD) { - s.match_length = longest_match(s, hash_head); - } - if (s.match_length >= MIN_MATCH) { - bflush = trees._tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH); - s.lookahead -= s.match_length; - if (s.match_length <= s.max_lazy_match && s.lookahead >= MIN_MATCH) { - s.match_length--; - do { - s.strstart++; - s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask; - hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h]; - s.head[s.ins_h] = s.strstart; - } while (--s.match_length !== 0); - s.strstart++; - } else { - s.strstart += s.match_length; - s.match_length = 0; - s.ins_h = s.window[s.strstart]; - s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + 1]) & s.hash_mask; - } - } else { - bflush = trees._tr_tally(s, 0, s.window[s.strstart]); - s.lookahead--; - s.strstart++; - } - if (bflush) { - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } - } + return value; + }; + var createToken = (name, value, isGlobal) => { + const safe = makeSafeRegex(value); + const index2 = R++; + debug4(name, index2, value); + t[name] = index2; + src[index2] = value; + re[index2] = new RegExp(value, isGlobal ? "g" : void 0); + safeRe[index2] = 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.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`); + createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`); + createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NUMERICIDENTIFIER]}|${src[t.NONNUMERICIDENTIFIER]})`); + createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NUMERICIDENTIFIERLOOSE]}|${src[t.NONNUMERICIDENTIFIER]})`); + createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`); + createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`); + createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`); + createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`); + createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`); + createToken("FULL", `^${src[t.FULLPLAIN]}$`); + createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`); + createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`); + createToken("GTLT", "((?:<|>)?=?)"); + createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`); + createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`); + createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`); + createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`); + createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`); + createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.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.COERCEPLAIN]}(?:$|[^\\d])`); + createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`); + createToken("COERCERTL", src[t.COERCE], true); + createToken("COERCERTLFULL", src[t.COERCEFULL], true); + createToken("LONETILDE", "(?:~>?)"); + createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true); + exports2.tildeTrimReplace = "$1~"; + createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`); + createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`); + createToken("LONECARET", "(?:\\^)"); + createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true); + exports2.caretTrimReplace = "$1^"; + createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`); + createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`); + createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`); + createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`); + createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true); + exports2.comparatorTrimReplace = "$1$2$3"; + createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`); + createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`); + createToken("STAR", "(<|>)?=?\\s*\\*"); + createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$"); + createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$"); + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/internal/parse-options.js +var require_parse_options = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/internal/parse-options.js"(exports2, module2) { + var looseOption = Object.freeze({ loose: true }); + var emptyOpts = Object.freeze({}); + var parseOptions = (options) => { + if (!options) { + return emptyOpts; } - s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1; - if (flush === Z_FINISH) { - flush_block_only(s, true); - if (s.strm.avail_out === 0) { - return BS_FINISH_STARTED; - } - return BS_FINISH_DONE; + if (typeof options !== "object") { + return looseOption; } - if (s.last_lit) { - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } + return options; + }; + module2.exports = parseOptions; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/internal/identifiers.js +var require_identifiers = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/internal/identifiers.js"(exports2, module2) { + var numeric = /^[0-9]+$/; + var compareIdentifiers = (a, b) => { + const anum = numeric.test(a); + const bnum = numeric.test(b); + if (anum && bnum) { + a = +a; + b = +b; } - return BS_BLOCK_DONE; - } - function deflate_slow(s, flush) { - var hash_head; - var bflush; - var max_insert; - for (; ; ) { - if (s.lookahead < MIN_LOOKAHEAD) { - fill_window(s); - if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) { - return BS_NEED_MORE; - } - if (s.lookahead === 0) { - break; - } - } - hash_head = 0; - if (s.lookahead >= MIN_MATCH) { - s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask; - hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h]; - s.head[s.ins_h] = s.strstart; - } - s.prev_length = s.match_length; - s.prev_match = s.match_start; - s.match_length = MIN_MATCH - 1; - if (hash_head !== 0 && s.prev_length < s.max_lazy_match && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD) { - s.match_length = longest_match(s, hash_head); - if (s.match_length <= 5 && (s.strategy === Z_FILTERED || s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096)) { - s.match_length = MIN_MATCH - 1; - } - } - if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) { - max_insert = s.strstart + s.lookahead - MIN_MATCH; - bflush = trees._tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH); - s.lookahead -= s.prev_length - 1; - s.prev_length -= 2; - do { - if (++s.strstart <= max_insert) { - s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask; - hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h]; - s.head[s.ins_h] = s.strstart; - } - } while (--s.prev_length !== 0); - s.match_available = 0; - s.match_length = MIN_MATCH - 1; - s.strstart++; - if (bflush) { - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } - } - } else if (s.match_available) { - bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]); - if (bflush) { - flush_block_only(s, false); - } - s.strstart++; - s.lookahead--; - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; + return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1; + }; + var rcompareIdentifiers = (a, b) => compareIdentifiers(b, a); + module2.exports = { + compareIdentifiers, + rcompareIdentifiers + }; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/classes/semver.js +var require_semver = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/classes/semver.js"(exports2, module2) { + var debug4 = require_debug(); + var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants7(); + var { safeRe: re, t } = require_re(); + var parseOptions = require_parse_options(); + var { compareIdentifiers } = require_identifiers(); + var SemVer = class _SemVer { + constructor(version3, options) { + options = parseOptions(options); + if (version3 instanceof _SemVer) { + if (version3.loose === !!options.loose && version3.includePrerelease === !!options.includePrerelease) { + return version3; + } else { + version3 = version3.version; } + } else if (typeof version3 !== "string") { + throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version3}".`); + } + if (version3.length > MAX_LENGTH) { + throw new TypeError( + `version is longer than ${MAX_LENGTH} characters` + ); + } + debug4("SemVer", version3, options); + this.options = options; + this.loose = !!options.loose; + this.includePrerelease = !!options.includePrerelease; + const m = version3.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]); + if (!m) { + throw new TypeError(`Invalid Version: ${version3}`); + } + this.raw = version3; + this.major = +m[1]; + this.minor = +m[2]; + this.patch = +m[3]; + if (this.major > MAX_SAFE_INTEGER || this.major < 0) { + throw new TypeError("Invalid major version"); + } + if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { + throw new TypeError("Invalid minor version"); + } + if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { + throw new TypeError("Invalid patch version"); + } + if (!m[4]) { + this.prerelease = []; } else { - s.match_available = 1; - s.strstart++; - s.lookahead--; + this.prerelease = m[4].split(".").map((id) => { + if (/^[0-9]+$/.test(id)) { + const num2 = +id; + if (num2 >= 0 && num2 < MAX_SAFE_INTEGER) { + return num2; + } + } + return id; + }); } + this.build = m[5] ? m[5].split(".") : []; + this.format(); } - if (s.match_available) { - bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]); - s.match_available = 0; - } - s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1; - if (flush === Z_FINISH) { - flush_block_only(s, true); - if (s.strm.avail_out === 0) { - return BS_FINISH_STARTED; + format() { + this.version = `${this.major}.${this.minor}.${this.patch}`; + if (this.prerelease.length) { + this.version += `-${this.prerelease.join(".")}`; } - return BS_FINISH_DONE; + return this.version; } - if (s.last_lit) { - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } + toString() { + return this.version; } - return BS_BLOCK_DONE; - } - function deflate_rle(s, flush) { - var bflush; - var prev; - var scan, strend; - var _win = s.window; - for (; ; ) { - if (s.lookahead <= MAX_MATCH) { - fill_window(s); - if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH) { - return BS_NEED_MORE; - } - if (s.lookahead === 0) { - break; - } - } - s.match_length = 0; - if (s.lookahead >= MIN_MATCH && s.strstart > 0) { - scan = s.strstart - 1; - prev = _win[scan]; - if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) { - strend = s.strstart + MAX_MATCH; - do { - } while (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && scan < strend); - s.match_length = MAX_MATCH - (strend - scan); - if (s.match_length > s.lookahead) { - s.match_length = s.lookahead; - } + compare(other) { + debug4("SemVer.compare", this.version, this.options, other); + if (!(other instanceof _SemVer)) { + if (typeof other === "string" && other === this.version) { + return 0; } + other = new _SemVer(other, this.options); } - if (s.match_length >= MIN_MATCH) { - bflush = trees._tr_tally(s, 1, s.match_length - MIN_MATCH); - s.lookahead -= s.match_length; - s.strstart += s.match_length; - s.match_length = 0; - } else { - bflush = trees._tr_tally(s, 0, s.window[s.strstart]); - s.lookahead--; - s.strstart++; + if (other.version === this.version) { + return 0; } - if (bflush) { - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } + return this.compareMain(other) || this.comparePre(other); + } + compareMain(other) { + if (!(other instanceof _SemVer)) { + other = new _SemVer(other, this.options); } + return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch); } - s.insert = 0; - if (flush === Z_FINISH) { - flush_block_only(s, true); - if (s.strm.avail_out === 0) { - return BS_FINISH_STARTED; + comparePre(other) { + if (!(other instanceof _SemVer)) { + other = new _SemVer(other, this.options); } - return BS_FINISH_DONE; + 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]; + debug4("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); } - if (s.last_lit) { - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; + compareBuild(other) { + if (!(other instanceof _SemVer)) { + other = new _SemVer(other, this.options); } + let i = 0; + do { + const a = this.build[i]; + const b = other.build[i]; + debug4("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); } - return BS_BLOCK_DONE; - } - function deflate_huff(s, flush) { - var bflush; - for (; ; ) { - if (s.lookahead === 0) { - fill_window(s); - if (s.lookahead === 0) { - if (flush === Z_NO_FLUSH) { - return BS_NEED_MORE; + // preminor will bump the version up to the next minor release, and immediately + // down to pre-release. premajor and prepatch work the same way. + inc(release, identifier, identifierBase) { + 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 "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 (!identifier && identifierBase === false) { + throw new Error("invalid increment argument: identifier is empty"); + } + 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 = [identifier, base]; + if (identifierBase === false) { + prerelease = [identifier]; + } + if (compareIdentifiers(this.prerelease[0], identifier) === 0) { + if (isNaN(this.prerelease[1])) { + this.prerelease = prerelease; + } + } else { + this.prerelease = prerelease; + } } break; } + default: + throw new Error(`invalid increment argument: ${release}`); } - s.match_length = 0; - bflush = trees._tr_tally(s, 0, s.window[s.strstart]); - s.lookahead--; - s.strstart++; - if (bflush) { - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } + this.raw = this.format(); + if (this.build.length) { + this.raw += `+${this.build.join(".")}`; } + return this; } - s.insert = 0; - if (flush === Z_FINISH) { - flush_block_only(s, true); - if (s.strm.avail_out === 0) { - return BS_FINISH_STARTED; - } - return BS_FINISH_DONE; + }; + module2.exports = SemVer; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/parse.js +var require_parse2 = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/parse.js"(exports2, module2) { + var SemVer = require_semver(); + var parse2 = (version3, options, throwErrors = false) => { + if (version3 instanceof SemVer) { + return version3; } - if (s.last_lit) { - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; + try { + return new SemVer(version3, options); + } catch (er) { + if (!throwErrors) { + return null; } + throw er; } - return BS_BLOCK_DONE; - } - function Config(good_length, max_lazy, nice_length, max_chain, func) { - this.good_length = good_length; - this.max_lazy = max_lazy; - this.nice_length = nice_length; - this.max_chain = max_chain; - this.func = func; - } - var configuration_table; - configuration_table = [ - /* good lazy nice chain */ - new Config(0, 0, 0, 0, deflate_stored), - /* 0 store only */ - new Config(4, 4, 8, 4, deflate_fast), - /* 1 max speed, no lazy matches */ - new Config(4, 5, 16, 8, deflate_fast), - /* 2 */ - new Config(4, 6, 32, 32, deflate_fast), - /* 3 */ - new Config(4, 4, 16, 16, deflate_slow), - /* 4 lazy matches */ - new Config(8, 16, 32, 32, deflate_slow), - /* 5 */ - new Config(8, 16, 128, 128, deflate_slow), - /* 6 */ - new Config(8, 32, 128, 256, deflate_slow), - /* 7 */ - new Config(32, 128, 258, 1024, deflate_slow), - /* 8 */ - new Config(32, 258, 258, 4096, deflate_slow) - /* 9 max compression */ - ]; - function lm_init(s) { - s.window_size = 2 * s.w_size; - zero(s.head); - s.max_lazy_match = configuration_table[s.level].max_lazy; - s.good_match = configuration_table[s.level].good_length; - s.nice_match = configuration_table[s.level].nice_length; - s.max_chain_length = configuration_table[s.level].max_chain; - s.strstart = 0; - s.block_start = 0; - s.lookahead = 0; - s.insert = 0; - s.match_length = s.prev_length = MIN_MATCH - 1; - s.match_available = 0; - s.ins_h = 0; - } - function DeflateState() { - this.strm = null; - this.status = 0; - this.pending_buf = null; - this.pending_buf_size = 0; - this.pending_out = 0; - this.pending = 0; - this.wrap = 0; - this.gzhead = null; - this.gzindex = 0; - this.method = Z_DEFLATED; - this.last_flush = -1; - this.w_size = 0; - this.w_bits = 0; - this.w_mask = 0; - this.window = null; - this.window_size = 0; - this.prev = null; - this.head = null; - this.ins_h = 0; - this.hash_size = 0; - this.hash_bits = 0; - this.hash_mask = 0; - this.hash_shift = 0; - this.block_start = 0; - this.match_length = 0; - this.prev_match = 0; - this.match_available = 0; - this.strstart = 0; - this.match_start = 0; - this.lookahead = 0; - this.prev_length = 0; - this.max_chain_length = 0; - this.max_lazy_match = 0; - this.level = 0; - this.strategy = 0; - this.good_match = 0; - this.nice_match = 0; - this.dyn_ltree = new utils.Buf16(HEAP_SIZE * 2); - this.dyn_dtree = new utils.Buf16((2 * D_CODES + 1) * 2); - this.bl_tree = new utils.Buf16((2 * BL_CODES + 1) * 2); - zero(this.dyn_ltree); - zero(this.dyn_dtree); - zero(this.bl_tree); - this.l_desc = null; - this.d_desc = null; - this.bl_desc = null; - this.bl_count = new utils.Buf16(MAX_BITS + 1); - this.heap = new utils.Buf16(2 * L_CODES + 1); - zero(this.heap); - this.heap_len = 0; - this.heap_max = 0; - this.depth = new utils.Buf16(2 * L_CODES + 1); - zero(this.depth); - this.l_buf = 0; - this.lit_bufsize = 0; - this.last_lit = 0; - this.d_buf = 0; - this.opt_len = 0; - this.static_len = 0; - this.matches = 0; - this.insert = 0; - this.bi_buf = 0; - this.bi_valid = 0; - } - function deflateResetKeep(strm) { - var s; - if (!strm || !strm.state) { - return err(strm, Z_STREAM_ERROR); - } - strm.total_in = strm.total_out = 0; - strm.data_type = Z_UNKNOWN; - s = strm.state; - s.pending = 0; - s.pending_out = 0; - if (s.wrap < 0) { - s.wrap = -s.wrap; - } - s.status = s.wrap ? INIT_STATE : BUSY_STATE; - strm.adler = s.wrap === 2 ? 0 : 1; - s.last_flush = Z_NO_FLUSH; - trees._tr_init(s); - return Z_OK; - } - function deflateReset(strm) { - var ret = deflateResetKeep(strm); - if (ret === Z_OK) { - lm_init(strm.state); - } - return ret; - } - function deflateSetHeader(strm, head) { - if (!strm || !strm.state) { - return Z_STREAM_ERROR; - } - if (strm.state.wrap !== 2) { - return Z_STREAM_ERROR; - } - strm.state.gzhead = head; - return Z_OK; - } - function deflateInit2(strm, level, method, windowBits, memLevel, strategy) { - if (!strm) { - return Z_STREAM_ERROR; + }; + module2.exports = parse2; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/valid.js +var require_valid = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/valid.js"(exports2, module2) { + var parse2 = require_parse2(); + var valid = (version3, options) => { + const v = parse2(version3, options); + return v ? v.version : null; + }; + module2.exports = valid; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/clean.js +var require_clean = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/clean.js"(exports2, module2) { + var parse2 = require_parse2(); + var clean = (version3, options) => { + const s = parse2(version3.trim().replace(/^[=v]+/, ""), options); + return s ? s.version : null; + }; + module2.exports = clean; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/inc.js +var require_inc = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/inc.js"(exports2, module2) { + var SemVer = require_semver(); + var inc = (version3, release, options, identifier, identifierBase) => { + if (typeof options === "string") { + identifierBase = identifier; + identifier = options; + options = void 0; } - var wrap = 1; - if (level === Z_DEFAULT_COMPRESSION) { - level = 6; + try { + return new SemVer( + version3 instanceof SemVer ? version3.version : version3, + options + ).inc(release, identifier, identifierBase).version; + } catch (er) { + return null; } - if (windowBits < 0) { - wrap = 0; - windowBits = -windowBits; - } else if (windowBits > 15) { - wrap = 2; - windowBits -= 16; + }; + module2.exports = inc; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/diff.js +var require_diff = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/diff.js"(exports2, module2) { + var parse2 = require_parse2(); + var diff = (version1, version22) => { + const v12 = parse2(version1, null, true); + const v2 = parse2(version22, null, true); + const comparison = v12.compare(v2); + if (comparison === 0) { + return null; } - if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED || windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) { - return err(strm, Z_STREAM_ERROR); + const v1Higher = comparison > 0; + const highVersion = v1Higher ? v12 : v2; + const lowVersion = v1Higher ? v2 : v12; + const highHasPre = !!highVersion.prerelease.length; + const lowHasPre = !!lowVersion.prerelease.length; + if (lowHasPre && !highHasPre) { + if (!lowVersion.patch && !lowVersion.minor) { + return "major"; + } + if (highVersion.patch) { + return "patch"; + } + if (highVersion.minor) { + return "minor"; + } + return "major"; } - if (windowBits === 8) { - windowBits = 9; + const prefix = highHasPre ? "pre" : ""; + if (v12.major !== v2.major) { + return prefix + "major"; } - var s = new DeflateState(); - strm.state = s; - s.strm = strm; - s.wrap = wrap; - s.gzhead = null; - s.w_bits = windowBits; - s.w_size = 1 << s.w_bits; - s.w_mask = s.w_size - 1; - s.hash_bits = memLevel + 7; - s.hash_size = 1 << s.hash_bits; - s.hash_mask = s.hash_size - 1; - s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH); - s.window = new utils.Buf8(s.w_size * 2); - s.head = new utils.Buf16(s.hash_size); - s.prev = new utils.Buf16(s.w_size); - s.lit_bufsize = 1 << memLevel + 6; - s.pending_buf_size = s.lit_bufsize * 4; - s.pending_buf = new utils.Buf8(s.pending_buf_size); - s.d_buf = 1 * s.lit_bufsize; - s.l_buf = (1 + 2) * s.lit_bufsize; - s.level = level; - s.strategy = strategy; - s.method = method; - return deflateReset(strm); - } - function deflateInit(strm, level) { - return deflateInit2(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY); - } - function deflate2(strm, flush) { - var old_flush, s; - var beg, val; - if (!strm || !strm.state || flush > Z_BLOCK || flush < 0) { - return strm ? err(strm, Z_STREAM_ERROR) : Z_STREAM_ERROR; + if (v12.minor !== v2.minor) { + return prefix + "minor"; } - s = strm.state; - if (!strm.output || !strm.input && strm.avail_in !== 0 || s.status === FINISH_STATE && flush !== Z_FINISH) { - return err(strm, strm.avail_out === 0 ? Z_BUF_ERROR : Z_STREAM_ERROR); + if (v12.patch !== v2.patch) { + return prefix + "patch"; } - s.strm = strm; - old_flush = s.last_flush; - s.last_flush = flush; - if (s.status === INIT_STATE) { - if (s.wrap === 2) { - strm.adler = 0; - put_byte(s, 31); - put_byte(s, 139); - put_byte(s, 8); - if (!s.gzhead) { - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0); - put_byte(s, OS_CODE); - s.status = BUSY_STATE; - } else { - put_byte( - s, - (s.gzhead.text ? 1 : 0) + (s.gzhead.hcrc ? 2 : 0) + (!s.gzhead.extra ? 0 : 4) + (!s.gzhead.name ? 0 : 8) + (!s.gzhead.comment ? 0 : 16) - ); - put_byte(s, s.gzhead.time & 255); - put_byte(s, s.gzhead.time >> 8 & 255); - put_byte(s, s.gzhead.time >> 16 & 255); - put_byte(s, s.gzhead.time >> 24 & 255); - put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0); - put_byte(s, s.gzhead.os & 255); - if (s.gzhead.extra && s.gzhead.extra.length) { - put_byte(s, s.gzhead.extra.length & 255); - put_byte(s, s.gzhead.extra.length >> 8 & 255); - } - if (s.gzhead.hcrc) { - strm.adler = crc322(strm.adler, s.pending_buf, s.pending, 0); - } - s.gzindex = 0; - s.status = EXTRA_STATE; + return "prerelease"; + }; + module2.exports = diff; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/major.js +var require_major = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/major.js"(exports2, module2) { + var SemVer = require_semver(); + var major = (a, loose) => new SemVer(a, loose).major; + module2.exports = major; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/minor.js +var require_minor = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/minor.js"(exports2, module2) { + var SemVer = require_semver(); + var minor = (a, loose) => new SemVer(a, loose).minor; + module2.exports = minor; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/patch.js +var require_patch = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/patch.js"(exports2, module2) { + var SemVer = require_semver(); + var patch = (a, loose) => new SemVer(a, loose).patch; + module2.exports = patch; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/prerelease.js +var require_prerelease = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/prerelease.js"(exports2, module2) { + var parse2 = require_parse2(); + var prerelease = (version3, options) => { + const parsed = parse2(version3, options); + return parsed && parsed.prerelease.length ? parsed.prerelease : null; + }; + module2.exports = prerelease; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/compare.js +var require_compare = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/compare.js"(exports2, module2) { + var SemVer = require_semver(); + var compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose)); + module2.exports = compare; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/rcompare.js +var require_rcompare = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/rcompare.js"(exports2, module2) { + var compare = require_compare(); + var rcompare = (a, b, loose) => compare(b, a, loose); + module2.exports = rcompare; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/compare-loose.js +var require_compare_loose = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/compare-loose.js"(exports2, module2) { + var compare = require_compare(); + var compareLoose = (a, b) => compare(a, b, true); + module2.exports = compareLoose; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/compare-build.js +var require_compare_build = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/compare-build.js"(exports2, module2) { + var SemVer = require_semver(); + var compareBuild = (a, b, loose) => { + const versionA = new SemVer(a, loose); + const versionB = new SemVer(b, loose); + return versionA.compare(versionB) || versionA.compareBuild(versionB); + }; + module2.exports = compareBuild; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/sort.js +var require_sort = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/sort.js"(exports2, module2) { + var compareBuild = require_compare_build(); + var sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose)); + module2.exports = sort; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/rsort.js +var require_rsort = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/rsort.js"(exports2, module2) { + var compareBuild = require_compare_build(); + var rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose)); + module2.exports = rsort; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/gt.js +var require_gt = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/gt.js"(exports2, module2) { + var compare = require_compare(); + var gt = (a, b, loose) => compare(a, b, loose) > 0; + module2.exports = gt; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/lt.js +var require_lt = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/lt.js"(exports2, module2) { + var compare = require_compare(); + var lt = (a, b, loose) => compare(a, b, loose) < 0; + module2.exports = lt; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/eq.js +var require_eq = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/eq.js"(exports2, module2) { + var compare = require_compare(); + var eq = (a, b, loose) => compare(a, b, loose) === 0; + module2.exports = eq; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/neq.js +var require_neq = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/neq.js"(exports2, module2) { + var compare = require_compare(); + var neq = (a, b, loose) => compare(a, b, loose) !== 0; + module2.exports = neq; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/gte.js +var require_gte = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/gte.js"(exports2, module2) { + var compare = require_compare(); + var gte = (a, b, loose) => compare(a, b, loose) >= 0; + module2.exports = gte; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/lte.js +var require_lte = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/lte.js"(exports2, module2) { + var compare = require_compare(); + var lte = (a, b, loose) => compare(a, b, loose) <= 0; + module2.exports = lte; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/cmp.js +var require_cmp = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/cmp.js"(exports2, module2) { + var eq = require_eq(); + var neq = require_neq(); + var gt = require_gt(); + var gte = require_gte(); + var lt = require_lt(); + var lte = require_lte(); + var cmp = (a, op, b, loose) => { + switch (op) { + case "===": + if (typeof a === "object") { + a = a.version; } - } else { - var header = Z_DEFLATED + (s.w_bits - 8 << 4) << 8; - var level_flags = -1; - if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) { - level_flags = 0; - } else if (s.level < 6) { - level_flags = 1; - } else if (s.level === 6) { - level_flags = 2; - } else { - level_flags = 3; + if (typeof b === "object") { + b = b.version; } - header |= level_flags << 6; - if (s.strstart !== 0) { - header |= PRESET_DICT; + return a === b; + case "!==": + if (typeof a === "object") { + a = a.version; } - header += 31 - header % 31; - s.status = BUSY_STATE; - putShortMSB(s, header); - if (s.strstart !== 0) { - putShortMSB(s, strm.adler >>> 16); - putShortMSB(s, strm.adler & 65535); + if (typeof b === "object") { + b = b.version; } - strm.adler = 1; - } + return a !== b; + case "": + case "=": + case "==": + return eq(a, b, loose); + case "!=": + return neq(a, b, loose); + case ">": + return gt(a, b, loose); + case ">=": + return gte(a, b, loose); + case "<": + return lt(a, b, loose); + case "<=": + return lte(a, b, loose); + default: + throw new TypeError(`Invalid operator: ${op}`); } - if (s.status === EXTRA_STATE) { - if (s.gzhead.extra) { - beg = s.pending; - while (s.gzindex < (s.gzhead.extra.length & 65535)) { - if (s.pending === s.pending_buf_size) { - if (s.gzhead.hcrc && s.pending > beg) { - strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg); - } - flush_pending(strm); - beg = s.pending; - if (s.pending === s.pending_buf_size) { - break; - } - } - put_byte(s, s.gzhead.extra[s.gzindex] & 255); - s.gzindex++; - } - if (s.gzhead.hcrc && s.pending > beg) { - strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg); - } - if (s.gzindex === s.gzhead.extra.length) { - s.gzindex = 0; - s.status = NAME_STATE; - } - } else { - s.status = NAME_STATE; - } + }; + module2.exports = cmp; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/coerce.js +var require_coerce = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/coerce.js"(exports2, module2) { + var SemVer = require_semver(); + var parse2 = require_parse2(); + var { safeRe: re, t } = require_re(); + var coerce = (version3, options) => { + if (version3 instanceof SemVer) { + return version3; } - if (s.status === NAME_STATE) { - if (s.gzhead.name) { - beg = s.pending; - do { - if (s.pending === s.pending_buf_size) { - if (s.gzhead.hcrc && s.pending > beg) { - strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg); - } - flush_pending(strm); - beg = s.pending; - if (s.pending === s.pending_buf_size) { - val = 1; - break; - } - } - if (s.gzindex < s.gzhead.name.length) { - val = s.gzhead.name.charCodeAt(s.gzindex++) & 255; - } else { - val = 0; - } - put_byte(s, val); - } while (val !== 0); - if (s.gzhead.hcrc && s.pending > beg) { - strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg); - } - if (val === 0) { - s.gzindex = 0; - s.status = COMMENT_STATE; + if (typeof version3 === "number") { + version3 = String(version3); + } + if (typeof version3 !== "string") { + return null; + } + options = options || {}; + let match = null; + if (!options.rtl) { + match = version3.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]); + } else { + const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL]; + let next; + while ((next = coerceRtlRegex.exec(version3)) && (!match || match.index + match[0].length !== version3.length)) { + if (!match || next.index + next[0].length !== match.index + match[0].length) { + match = next; } - } else { - s.status = COMMENT_STATE; + coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length; } + coerceRtlRegex.lastIndex = -1; } - if (s.status === COMMENT_STATE) { - if (s.gzhead.comment) { - beg = s.pending; - do { - if (s.pending === s.pending_buf_size) { - if (s.gzhead.hcrc && s.pending > beg) { - strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg); - } - flush_pending(strm); - beg = s.pending; - if (s.pending === s.pending_buf_size) { - val = 1; - break; - } - } - if (s.gzindex < s.gzhead.comment.length) { - val = s.gzhead.comment.charCodeAt(s.gzindex++) & 255; - } else { - val = 0; - } - put_byte(s, val); - } while (val !== 0); - if (s.gzhead.hcrc && s.pending > beg) { - strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg); - } - if (val === 0) { - s.status = HCRC_STATE; - } - } else { - s.status = HCRC_STATE; + if (match === null) { + return null; + } + const major = match[2]; + const minor = match[3] || "0"; + const patch = match[4] || "0"; + const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : ""; + const build = options.includePrerelease && match[6] ? `+${match[6]}` : ""; + return parse2(`${major}.${minor}.${patch}${prerelease}${build}`, options); + }; + module2.exports = coerce; + } +}); + +// ../../../node_modules/.pnpm/yallist@4.0.0/node_modules/yallist/iterator.js +var require_iterator = __commonJS({ + "../../../node_modules/.pnpm/yallist@4.0.0/node_modules/yallist/iterator.js"(exports2, module2) { + "use strict"; + module2.exports = function(Yallist) { + Yallist.prototype[Symbol.iterator] = function* () { + for (let walker = this.head; walker; walker = walker.next) { + yield walker.value; } + }; + }; + } +}); + +// ../../../node_modules/.pnpm/yallist@4.0.0/node_modules/yallist/yallist.js +var require_yallist = __commonJS({ + "../../../node_modules/.pnpm/yallist@4.0.0/node_modules/yallist/yallist.js"(exports2, module2) { + "use strict"; + module2.exports = Yallist; + Yallist.Node = Node; + Yallist.create = Yallist; + function Yallist(list) { + var self2 = this; + if (!(self2 instanceof Yallist)) { + self2 = new Yallist(); } - if (s.status === HCRC_STATE) { - if (s.gzhead.hcrc) { - if (s.pending + 2 > s.pending_buf_size) { - flush_pending(strm); - } - if (s.pending + 2 <= s.pending_buf_size) { - put_byte(s, strm.adler & 255); - put_byte(s, strm.adler >> 8 & 255); - strm.adler = 0; - s.status = BUSY_STATE; - } - } else { - s.status = BUSY_STATE; + self2.tail = null; + self2.head = null; + self2.length = 0; + if (list && typeof list.forEach === "function") { + list.forEach(function(item) { + self2.push(item); + }); + } else if (arguments.length > 0) { + for (var i = 0, l = arguments.length; i < l; i++) { + self2.push(arguments[i]); } } - if (s.pending !== 0) { - flush_pending(strm); - if (strm.avail_out === 0) { - s.last_flush = -1; - return Z_OK; - } - } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) && flush !== Z_FINISH) { - return err(strm, Z_BUF_ERROR); + return self2; + } + Yallist.prototype.removeNode = function(node) { + if (node.list !== this) { + throw new Error("removing node which does not belong to this list"); } - if (s.status === FINISH_STATE && strm.avail_in !== 0) { - return err(strm, Z_BUF_ERROR); + var next = node.next; + var prev = node.prev; + if (next) { + next.prev = prev; } - if (strm.avail_in !== 0 || s.lookahead !== 0 || flush !== Z_NO_FLUSH && s.status !== FINISH_STATE) { - var bstate = s.strategy === Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : s.strategy === Z_RLE ? deflate_rle(s, flush) : configuration_table[s.level].func(s, flush); - if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) { - s.status = FINISH_STATE; - } - if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) { - if (strm.avail_out === 0) { - s.last_flush = -1; - } - return Z_OK; - } - if (bstate === BS_BLOCK_DONE) { - if (flush === Z_PARTIAL_FLUSH) { - trees._tr_align(s); - } else if (flush !== Z_BLOCK) { - trees._tr_stored_block(s, 0, 0, false); - if (flush === Z_FULL_FLUSH) { - zero(s.head); - if (s.lookahead === 0) { - s.strstart = 0; - s.block_start = 0; - s.insert = 0; - } - } - } - flush_pending(strm); - if (strm.avail_out === 0) { - s.last_flush = -1; - return Z_OK; - } - } + if (prev) { + prev.next = next; } - if (flush !== Z_FINISH) { - return Z_OK; + if (node === this.head) { + this.head = next; } - if (s.wrap <= 0) { - return Z_STREAM_END; + if (node === this.tail) { + this.tail = prev; } - if (s.wrap === 2) { - put_byte(s, strm.adler & 255); - put_byte(s, strm.adler >> 8 & 255); - put_byte(s, strm.adler >> 16 & 255); - put_byte(s, strm.adler >> 24 & 255); - put_byte(s, strm.total_in & 255); - put_byte(s, strm.total_in >> 8 & 255); - put_byte(s, strm.total_in >> 16 & 255); - put_byte(s, strm.total_in >> 24 & 255); - } else { - putShortMSB(s, strm.adler >>> 16); - putShortMSB(s, strm.adler & 65535); + node.list.length--; + node.next = null; + node.prev = null; + node.list = null; + return next; + }; + Yallist.prototype.unshiftNode = function(node) { + if (node === this.head) { + return; } - flush_pending(strm); - if (s.wrap > 0) { - s.wrap = -s.wrap; + if (node.list) { + node.list.removeNode(node); } - return s.pending !== 0 ? Z_OK : Z_STREAM_END; - } - function deflateEnd(strm) { - var status2; - if (!strm || !strm.state) { - return Z_STREAM_ERROR; + var head = this.head; + node.list = this; + node.next = head; + if (head) { + head.prev = node; } - status2 = strm.state.status; - if (status2 !== INIT_STATE && status2 !== EXTRA_STATE && status2 !== NAME_STATE && status2 !== COMMENT_STATE && status2 !== HCRC_STATE && status2 !== BUSY_STATE && status2 !== FINISH_STATE) { - return err(strm, Z_STREAM_ERROR); + this.head = node; + if (!this.tail) { + this.tail = node; } - strm.state = null; - return status2 === BUSY_STATE ? err(strm, Z_DATA_ERROR) : Z_OK; - } - function deflateSetDictionary(strm, dictionary) { - var dictLength = dictionary.length; - var s; - var str, n; - var wrap; - var avail; - var next; - var input; - var tmpDict; - if (!strm || !strm.state) { - return Z_STREAM_ERROR; + this.length++; + }; + Yallist.prototype.pushNode = function(node) { + if (node === this.tail) { + return; } - s = strm.state; - wrap = s.wrap; - if (wrap === 2 || wrap === 1 && s.status !== INIT_STATE || s.lookahead) { - return Z_STREAM_ERROR; + if (node.list) { + node.list.removeNode(node); } - if (wrap === 1) { - strm.adler = adler32(strm.adler, dictionary, dictLength, 0); + var tail = this.tail; + node.list = this; + node.prev = tail; + if (tail) { + tail.next = node; } - s.wrap = 0; - if (dictLength >= s.w_size) { - if (wrap === 0) { - zero(s.head); - s.strstart = 0; - s.block_start = 0; - s.insert = 0; - } - tmpDict = new utils.Buf8(s.w_size); - utils.arraySet(tmpDict, dictionary, dictLength - s.w_size, s.w_size, 0); - dictionary = tmpDict; - dictLength = s.w_size; + this.tail = node; + if (!this.head) { + this.head = node; } - avail = strm.avail_in; - next = strm.next_in; - input = strm.input; - strm.avail_in = dictLength; - strm.next_in = 0; - strm.input = dictionary; - fill_window(s); - while (s.lookahead >= MIN_MATCH) { - str = s.strstart; - n = s.lookahead - (MIN_MATCH - 1); - do { - s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask; - s.prev[str & s.w_mask] = s.head[s.ins_h]; - s.head[s.ins_h] = str; - str++; - } while (--n); - s.strstart = str; - s.lookahead = MIN_MATCH - 1; - fill_window(s); + this.length++; + }; + Yallist.prototype.push = function() { + for (var i = 0, l = arguments.length; i < l; i++) { + push3(this, arguments[i]); } - s.strstart += s.lookahead; - s.block_start = s.strstart; - s.insert = s.lookahead; - s.lookahead = 0; - s.match_length = s.prev_length = MIN_MATCH - 1; - s.match_available = 0; - strm.next_in = next; - strm.input = input; - strm.avail_in = avail; - s.wrap = wrap; - return Z_OK; - } - exports2.deflateInit = deflateInit; - exports2.deflateInit2 = deflateInit2; - exports2.deflateReset = deflateReset; - exports2.deflateResetKeep = deflateResetKeep; - exports2.deflateSetHeader = deflateSetHeader; - exports2.deflate = deflate2; - exports2.deflateEnd = deflateEnd; - exports2.deflateSetDictionary = deflateSetDictionary; - exports2.deflateInfo = "pako deflate (from Nodeca project)"; - } -}); - -// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/utils/strings.js -var require_strings = __commonJS({ - "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/utils/strings.js"(exports2) { - "use strict"; - var utils = require_common(); - var STR_APPLY_OK = true; - var STR_APPLY_UIA_OK = true; - try { - String.fromCharCode.apply(null, [0]); - } catch (__) { - STR_APPLY_OK = false; - } - try { - String.fromCharCode.apply(null, new Uint8Array(1)); - } catch (__) { - STR_APPLY_UIA_OK = false; - } - var _utf8len = new utils.Buf8(256); - for (q = 0; q < 256; q++) { - _utf8len[q] = q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1; - } - var q; - _utf8len[254] = _utf8len[254] = 1; - exports2.string2buf = function(str) { - var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0; - for (m_pos = 0; m_pos < str_len; m_pos++) { - c = str.charCodeAt(m_pos); - if ((c & 64512) === 55296 && m_pos + 1 < str_len) { - c2 = str.charCodeAt(m_pos + 1); - if ((c2 & 64512) === 56320) { - c = 65536 + (c - 55296 << 10) + (c2 - 56320); - m_pos++; - } - } - buf_len += c < 128 ? 1 : c < 2048 ? 2 : c < 65536 ? 3 : 4; + return this.length; + }; + Yallist.prototype.unshift = function() { + for (var i = 0, l = arguments.length; i < l; i++) { + unshift(this, arguments[i]); } - buf = new utils.Buf8(buf_len); - for (i = 0, m_pos = 0; i < buf_len; m_pos++) { - c = str.charCodeAt(m_pos); - if ((c & 64512) === 55296 && m_pos + 1 < str_len) { - c2 = str.charCodeAt(m_pos + 1); - if ((c2 & 64512) === 56320) { - c = 65536 + (c - 55296 << 10) + (c2 - 56320); - m_pos++; - } - } - if (c < 128) { - buf[i++] = c; - } else if (c < 2048) { - buf[i++] = 192 | c >>> 6; - buf[i++] = 128 | c & 63; - } else if (c < 65536) { - buf[i++] = 224 | c >>> 12; - buf[i++] = 128 | c >>> 6 & 63; - buf[i++] = 128 | c & 63; - } else { - buf[i++] = 240 | c >>> 18; - buf[i++] = 128 | c >>> 12 & 63; - buf[i++] = 128 | c >>> 6 & 63; - buf[i++] = 128 | c & 63; - } + return this.length; + }; + Yallist.prototype.pop = function() { + if (!this.tail) { + return void 0; } - return buf; + var res = this.tail.value; + this.tail = this.tail.prev; + if (this.tail) { + this.tail.next = null; + } else { + this.head = null; + } + this.length--; + return res; }; - function buf2binstring(buf, len) { - if (len < 65534) { - if (buf.subarray && STR_APPLY_UIA_OK || !buf.subarray && STR_APPLY_OK) { - return String.fromCharCode.apply(null, utils.shrinkBuf(buf, len)); - } + Yallist.prototype.shift = function() { + if (!this.head) { + return void 0; } - var result = ""; - for (var i = 0; i < len; i++) { - result += String.fromCharCode(buf[i]); + var res = this.head.value; + this.head = this.head.next; + if (this.head) { + this.head.prev = null; + } else { + this.tail = null; } - return result; - } - exports2.buf2binstring = function(buf) { - return buf2binstring(buf, buf.length); + this.length--; + return res; }; - exports2.binstring2buf = function(str) { - var buf = new utils.Buf8(str.length); - for (var i = 0, len = buf.length; i < len; i++) { - buf[i] = str.charCodeAt(i); + Yallist.prototype.forEach = function(fn, thisp) { + thisp = thisp || this; + for (var walker = this.head, i = 0; walker !== null; i++) { + fn.call(thisp, walker.value, i, this); + walker = walker.next; } - return buf; }; - exports2.buf2string = function(buf, max) { - var i, out, c, c_len; - var len = max || buf.length; - var utf16buf = new Array(len * 2); - for (out = 0, i = 0; i < len; ) { - c = buf[i++]; - if (c < 128) { - utf16buf[out++] = c; - continue; - } - c_len = _utf8len[c]; - if (c_len > 4) { - utf16buf[out++] = 65533; - i += c_len - 1; - continue; - } - c &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7; - while (c_len > 1 && i < len) { - c = c << 6 | buf[i++] & 63; - c_len--; - } - if (c_len > 1) { - utf16buf[out++] = 65533; - continue; - } - if (c < 65536) { - utf16buf[out++] = c; - } else { - c -= 65536; - utf16buf[out++] = 55296 | c >> 10 & 1023; - utf16buf[out++] = 56320 | c & 1023; - } + Yallist.prototype.forEachReverse = function(fn, thisp) { + thisp = thisp || this; + for (var walker = this.tail, i = this.length - 1; walker !== null; i--) { + fn.call(thisp, walker.value, i, this); + walker = walker.prev; } - return buf2binstring(utf16buf, out); }; - exports2.utf8border = function(buf, max) { - var pos; - max = max || buf.length; - if (max > buf.length) { - max = buf.length; + Yallist.prototype.get = function(n) { + for (var i = 0, walker = this.head; walker !== null && i < n; i++) { + walker = walker.next; } - pos = max - 1; - while (pos >= 0 && (buf[pos] & 192) === 128) { - pos--; + if (i === n && walker !== null) { + return walker.value; } - if (pos < 0) { - return max; + }; + Yallist.prototype.getReverse = function(n) { + for (var i = 0, walker = this.tail; walker !== null && i < n; i++) { + walker = walker.prev; } - if (pos === 0) { - return max; + if (i === n && walker !== null) { + return walker.value; } - return pos + _utf8len[buf[pos]] > max ? pos : max; }; - } -}); - -// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/zstream.js -var require_zstream = __commonJS({ - "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/zstream.js"(exports2, module2) { - "use strict"; - function ZStream() { - this.input = null; - this.next_in = 0; - this.avail_in = 0; - this.total_in = 0; - this.output = null; - this.next_out = 0; - this.avail_out = 0; - this.total_out = 0; - this.msg = ""; - this.state = null; - this.data_type = 2; - this.adler = 0; - } - module2.exports = ZStream; - } -}); - -// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/deflate.js -var require_deflate2 = __commonJS({ - "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/deflate.js"(exports2) { - "use strict"; - var zlib_deflate = require_deflate(); - var utils = require_common(); - var strings = require_strings(); - var msg = require_messages(); - var ZStream = require_zstream(); - var toString = Object.prototype.toString; - var Z_NO_FLUSH = 0; - var Z_FINISH = 4; - var Z_OK = 0; - var Z_STREAM_END = 1; - var Z_SYNC_FLUSH = 2; - var Z_DEFAULT_COMPRESSION = -1; - var Z_DEFAULT_STRATEGY = 0; - var Z_DEFLATED = 8; - function Deflate(options) { - if (!(this instanceof Deflate)) - return new Deflate(options); - this.options = utils.assign({ - level: Z_DEFAULT_COMPRESSION, - method: Z_DEFLATED, - chunkSize: 16384, - windowBits: 15, - memLevel: 8, - strategy: Z_DEFAULT_STRATEGY, - to: "" - }, options || {}); - var opt = this.options; - if (opt.raw && opt.windowBits > 0) { - opt.windowBits = -opt.windowBits; - } else if (opt.gzip && opt.windowBits > 0 && opt.windowBits < 16) { - opt.windowBits += 16; + Yallist.prototype.map = function(fn, thisp) { + thisp = thisp || this; + var res = new Yallist(); + for (var walker = this.head; walker !== null; ) { + res.push(fn.call(thisp, walker.value, this)); + walker = walker.next; + } + return res; + }; + Yallist.prototype.mapReverse = function(fn, thisp) { + thisp = thisp || this; + var res = new Yallist(); + for (var walker = this.tail; walker !== null; ) { + res.push(fn.call(thisp, walker.value, this)); + walker = walker.prev; + } + return res; + }; + Yallist.prototype.reduce = function(fn, initial) { + var acc; + var walker = this.head; + if (arguments.length > 1) { + acc = initial; + } else if (this.head) { + walker = this.head.next; + acc = this.head.value; + } else { + throw new TypeError("Reduce of empty list with no initial value"); + } + for (var i = 0; walker !== null; i++) { + acc = fn(acc, walker.value, i); + walker = walker.next; + } + return acc; + }; + Yallist.prototype.reduceReverse = function(fn, initial) { + var acc; + var walker = this.tail; + if (arguments.length > 1) { + acc = initial; + } else if (this.tail) { + walker = this.tail.prev; + acc = this.tail.value; + } else { + throw new TypeError("Reduce of empty list with no initial value"); + } + for (var i = this.length - 1; walker !== null; i--) { + acc = fn(acc, walker.value, i); + walker = walker.prev; + } + return acc; + }; + Yallist.prototype.toArray = function() { + var arr = new Array(this.length); + for (var i = 0, walker = this.head; walker !== null; i++) { + arr[i] = walker.value; + walker = walker.next; + } + return arr; + }; + Yallist.prototype.toArrayReverse = function() { + var arr = new Array(this.length); + for (var i = 0, walker = this.tail; walker !== null; i++) { + arr[i] = walker.value; + walker = walker.prev; } - this.err = 0; - this.msg = ""; - this.ended = false; - this.chunks = []; - this.strm = new ZStream(); - this.strm.avail_out = 0; - var status2 = zlib_deflate.deflateInit2( - this.strm, - opt.level, - opt.method, - opt.windowBits, - opt.memLevel, - opt.strategy - ); - if (status2 !== Z_OK) { - throw new Error(msg[status2]); + return arr; + }; + Yallist.prototype.slice = function(from2, to) { + to = to || this.length; + if (to < 0) { + to += this.length; } - if (opt.header) { - zlib_deflate.deflateSetHeader(this.strm, opt.header); + from2 = from2 || 0; + if (from2 < 0) { + from2 += this.length; } - if (opt.dictionary) { - var dict; - if (typeof opt.dictionary === "string") { - dict = strings.string2buf(opt.dictionary); - } else if (toString.call(opt.dictionary) === "[object ArrayBuffer]") { - dict = new Uint8Array(opt.dictionary); - } else { - dict = opt.dictionary; - } - status2 = zlib_deflate.deflateSetDictionary(this.strm, dict); - if (status2 !== Z_OK) { - throw new Error(msg[status2]); - } - this._dict_set = true; + var ret = new Yallist(); + if (to < from2 || to < 0) { + return ret; } - } - Deflate.prototype.push = function(data, mode) { - var strm = this.strm; - var chunkSize = this.options.chunkSize; - var status2, _mode; - if (this.ended) { - return false; + if (from2 < 0) { + from2 = 0; } - _mode = mode === ~~mode ? mode : mode === true ? Z_FINISH : Z_NO_FLUSH; - if (typeof data === "string") { - strm.input = strings.string2buf(data); - } else if (toString.call(data) === "[object ArrayBuffer]") { - strm.input = new Uint8Array(data); - } else { - strm.input = data; + if (to > this.length) { + to = this.length; } - strm.next_in = 0; - strm.avail_in = strm.input.length; - do { - if (strm.avail_out === 0) { - strm.output = new utils.Buf8(chunkSize); - strm.next_out = 0; - strm.avail_out = chunkSize; - } - status2 = zlib_deflate.deflate(strm, _mode); - if (status2 !== Z_STREAM_END && status2 !== Z_OK) { - this.onEnd(status2); - this.ended = true; - return false; - } - if (strm.avail_out === 0 || strm.avail_in === 0 && (_mode === Z_FINISH || _mode === Z_SYNC_FLUSH)) { - if (this.options.to === "string") { - this.onData(strings.buf2binstring(utils.shrinkBuf(strm.output, strm.next_out))); - } else { - this.onData(utils.shrinkBuf(strm.output, strm.next_out)); - } - } - } while ((strm.avail_in > 0 || strm.avail_out === 0) && status2 !== Z_STREAM_END); - if (_mode === Z_FINISH) { - status2 = zlib_deflate.deflateEnd(this.strm); - this.onEnd(status2); - this.ended = true; - return status2 === Z_OK; + for (var i = 0, walker = this.head; walker !== null && i < from2; i++) { + walker = walker.next; } - if (_mode === Z_SYNC_FLUSH) { - this.onEnd(Z_OK); - strm.avail_out = 0; - return true; + for (; walker !== null && i < to; i++, walker = walker.next) { + ret.push(walker.value); } - return true; - }; - Deflate.prototype.onData = function(chunk) { - this.chunks.push(chunk); + return ret; }; - Deflate.prototype.onEnd = function(status2) { - if (status2 === Z_OK) { - if (this.options.to === "string") { - this.result = this.chunks.join(""); - } else { - this.result = utils.flattenChunks(this.chunks); - } + Yallist.prototype.sliceReverse = function(from2, to) { + to = to || this.length; + if (to < 0) { + to += this.length; } - this.chunks = []; - this.err = status2; - this.msg = this.strm.msg; - }; - function deflate2(input, options) { - var deflator = new Deflate(options); - deflator.push(input, true); - if (deflator.err) { - throw deflator.msg || msg[deflator.err]; + from2 = from2 || 0; + if (from2 < 0) { + from2 += this.length; } - return deflator.result; - } - function deflateRaw(input, options) { - options = options || {}; - options.raw = true; - return deflate2(input, options); - } - function gzip(input, options) { - options = options || {}; - options.gzip = true; - return deflate2(input, options); - } - exports2.Deflate = Deflate; - exports2.deflate = deflate2; - exports2.deflateRaw = deflateRaw; - exports2.gzip = gzip; - } -}); - -// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/inffast.js -var require_inffast = __commonJS({ - "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/inffast.js"(exports2, module2) { - "use strict"; - var BAD = 30; - var TYPE = 12; - module2.exports = function inflate_fast(strm, start) { - var state; - var _in; - var last; - var _out; - var beg; - var end; - var dmax; - var wsize; - var whave; - var wnext; - var s_window; - var hold; - var bits; - var lcode; - var dcode; - var lmask; - var dmask; - var here; - var op; - var len; - var dist; - var from3; - var from_source; - var input, output; - state = strm.state; - _in = strm.next_in; - input = strm.input; - last = _in + (strm.avail_in - 5); - _out = strm.next_out; - output = strm.output; - beg = _out - (start - strm.avail_out); - end = _out + (strm.avail_out - 257); - dmax = state.dmax; - wsize = state.wsize; - whave = state.whave; - wnext = state.wnext; - s_window = state.window; - hold = state.hold; - bits = state.bits; - lcode = state.lencode; - dcode = state.distcode; - lmask = (1 << state.lenbits) - 1; - dmask = (1 << state.distbits) - 1; - top: - do { - if (bits < 15) { - hold += input[_in++] << bits; - bits += 8; - hold += input[_in++] << bits; - bits += 8; - } - here = lcode[hold & lmask]; - dolen: - for (; ; ) { - op = here >>> 24; - hold >>>= op; - bits -= op; - op = here >>> 16 & 255; - if (op === 0) { - output[_out++] = here & 65535; - } else if (op & 16) { - len = here & 65535; - op &= 15; - if (op) { - if (bits < op) { - hold += input[_in++] << bits; - bits += 8; - } - len += hold & (1 << op) - 1; - hold >>>= op; - bits -= op; - } - if (bits < 15) { - hold += input[_in++] << bits; - bits += 8; - hold += input[_in++] << bits; - bits += 8; - } - here = dcode[hold & dmask]; - dodist: - for (; ; ) { - op = here >>> 24; - hold >>>= op; - bits -= op; - op = here >>> 16 & 255; - if (op & 16) { - dist = here & 65535; - op &= 15; - if (bits < op) { - hold += input[_in++] << bits; - bits += 8; - if (bits < op) { - hold += input[_in++] << bits; - bits += 8; - } - } - dist += hold & (1 << op) - 1; - if (dist > dmax) { - strm.msg = "invalid distance too far back"; - state.mode = BAD; - break top; - } - hold >>>= op; - bits -= op; - op = _out - beg; - if (dist > op) { - op = dist - op; - if (op > whave) { - if (state.sane) { - strm.msg = "invalid distance too far back"; - state.mode = BAD; - break top; - } - } - from3 = 0; - from_source = s_window; - if (wnext === 0) { - from3 += wsize - op; - if (op < len) { - len -= op; - do { - output[_out++] = s_window[from3++]; - } while (--op); - from3 = _out - dist; - from_source = output; - } - } else if (wnext < op) { - from3 += wsize + wnext - op; - op -= wnext; - if (op < len) { - len -= op; - do { - output[_out++] = s_window[from3++]; - } while (--op); - from3 = 0; - if (wnext < len) { - op = wnext; - len -= op; - do { - output[_out++] = s_window[from3++]; - } while (--op); - from3 = _out - dist; - from_source = output; - } - } - } else { - from3 += wnext - op; - if (op < len) { - len -= op; - do { - output[_out++] = s_window[from3++]; - } while (--op); - from3 = _out - dist; - from_source = output; - } - } - while (len > 2) { - output[_out++] = from_source[from3++]; - output[_out++] = from_source[from3++]; - output[_out++] = from_source[from3++]; - len -= 3; - } - if (len) { - output[_out++] = from_source[from3++]; - if (len > 1) { - output[_out++] = from_source[from3++]; - } - } - } else { - from3 = _out - dist; - do { - output[_out++] = output[from3++]; - output[_out++] = output[from3++]; - output[_out++] = output[from3++]; - len -= 3; - } while (len > 2); - if (len) { - output[_out++] = output[from3++]; - if (len > 1) { - output[_out++] = output[from3++]; - } - } - } - } else if ((op & 64) === 0) { - here = dcode[(here & 65535) + (hold & (1 << op) - 1)]; - continue dodist; - } else { - strm.msg = "invalid distance code"; - state.mode = BAD; - break top; - } - break; - } - } else if ((op & 64) === 0) { - here = lcode[(here & 65535) + (hold & (1 << op) - 1)]; - continue dolen; - } else if (op & 32) { - state.mode = TYPE; - break top; - } else { - strm.msg = "invalid literal/length code"; - state.mode = BAD; - break top; - } - break; - } - } while (_in < last && _out < end); - len = bits >> 3; - _in -= len; - bits -= len << 3; - hold &= (1 << bits) - 1; - strm.next_in = _in; - strm.next_out = _out; - strm.avail_in = _in < last ? 5 + (last - _in) : 5 - (_in - last); - strm.avail_out = _out < end ? 257 + (end - _out) : 257 - (_out - end); - state.hold = hold; - state.bits = bits; - return; + var ret = new Yallist(); + if (to < from2 || to < 0) { + return ret; + } + if (from2 < 0) { + from2 = 0; + } + if (to > this.length) { + to = this.length; + } + for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) { + walker = walker.prev; + } + for (; walker !== null && i > from2; i--, walker = walker.prev) { + ret.push(walker.value); + } + return ret; }; - } -}); - -// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/inftrees.js -var require_inftrees = __commonJS({ - "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/inftrees.js"(exports2, module2) { - "use strict"; - var utils = require_common(); - var MAXBITS = 15; - var ENOUGH_LENS = 852; - var ENOUGH_DISTS = 592; - var CODES = 0; - var LENS = 1; - var DISTS = 2; - var lbase = [ - /* Length codes 257..285 base */ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 13, - 15, - 17, - 19, - 23, - 27, - 31, - 35, - 43, - 51, - 59, - 67, - 83, - 99, - 115, - 131, - 163, - 195, - 227, - 258, - 0, - 0 - ]; - var lext = [ - /* Length codes 257..285 extra */ - 16, - 16, - 16, - 16, - 16, - 16, - 16, - 16, - 17, - 17, - 17, - 17, - 18, - 18, - 18, - 18, - 19, - 19, - 19, - 19, - 20, - 20, - 20, - 20, - 21, - 21, - 21, - 21, - 16, - 72, - 78 - ]; - var dbase = [ - /* Distance codes 0..29 base */ - 1, - 2, - 3, - 4, - 5, - 7, - 9, - 13, - 17, - 25, - 33, - 49, - 65, - 97, - 129, - 193, - 257, - 385, - 513, - 769, - 1025, - 1537, - 2049, - 3073, - 4097, - 6145, - 8193, - 12289, - 16385, - 24577, - 0, - 0 - ]; - var dext = [ - /* Distance codes 0..29 extra */ - 16, - 16, - 16, - 16, - 17, - 17, - 18, - 18, - 19, - 19, - 20, - 20, - 21, - 21, - 22, - 22, - 23, - 23, - 24, - 24, - 25, - 25, - 26, - 26, - 27, - 27, - 28, - 28, - 29, - 29, - 64, - 64 - ]; - module2.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts) { - var bits = opts.bits; - var len = 0; - var sym = 0; - var min = 0, max = 0; - var root = 0; - var curr = 0; - var drop = 0; - var left = 0; - var used = 0; - var huff = 0; - var incr; - var fill; - var low; - var mask; - var next; - var base = null; - var base_index = 0; - var end; - var count = new utils.Buf16(MAXBITS + 1); - var offs = new utils.Buf16(MAXBITS + 1); - var extra = null; - var extra_index = 0; - var here_bits, here_op, here_val; - for (len = 0; len <= MAXBITS; len++) { - count[len] = 0; + Yallist.prototype.splice = function(start, deleteCount, ...nodes) { + if (start > this.length) { + start = this.length - 1; } - for (sym = 0; sym < codes; sym++) { - count[lens[lens_index + sym]]++; + if (start < 0) { + start = this.length + start; } - root = bits; - for (max = MAXBITS; max >= 1; max--) { - if (count[max] !== 0) { - break; + for (var i = 0, walker = this.head; walker !== null && i < start; i++) { + walker = walker.next; + } + var ret = []; + for (var i = 0; walker && i < deleteCount; i++) { + ret.push(walker.value); + walker = this.removeNode(walker); + } + if (walker === null) { + walker = this.tail; + } + if (walker !== this.head && walker !== this.tail) { + walker = walker.prev; + } + for (var i = 0; i < nodes.length; i++) { + walker = insert(this, walker, nodes[i]); + } + return ret; + }; + Yallist.prototype.reverse = function() { + var head = this.head; + var tail = this.tail; + for (var walker = head; walker !== null; walker = walker.prev) { + var p = walker.prev; + walker.prev = walker.next; + walker.next = p; + } + this.head = tail; + this.tail = head; + return this; + }; + function insert(self2, node, value) { + var inserted = node === self2.head ? new Node(value, null, node, self2) : new Node(value, node, node.next, self2); + if (inserted.next === null) { + self2.tail = inserted; + } + if (inserted.prev === null) { + self2.head = inserted; + } + self2.length++; + return inserted; + } + function push3(self2, item) { + self2.tail = new Node(item, self2.tail, null, self2); + if (!self2.head) { + self2.head = self2.tail; + } + self2.length++; + } + function unshift(self2, item) { + self2.head = new Node(item, null, self2.head, self2); + if (!self2.tail) { + self2.tail = self2.head; + } + self2.length++; + } + function Node(value, prev, next, list) { + if (!(this instanceof Node)) { + return new Node(value, prev, next, list); + } + this.list = list; + this.value = value; + if (prev) { + prev.next = this; + this.prev = prev; + } else { + this.prev = null; + } + if (next) { + next.prev = this; + this.next = next; + } else { + this.next = null; + } + } + try { + require_iterator()(Yallist); + } catch (er) { + } + } +}); + +// ../../../node_modules/.pnpm/lru-cache@6.0.0/node_modules/lru-cache/index.js +var require_lru_cache = __commonJS({ + "../../../node_modules/.pnpm/lru-cache@6.0.0/node_modules/lru-cache/index.js"(exports2, module2) { + "use strict"; + var Yallist = require_yallist(); + var MAX = Symbol("max"); + var LENGTH = Symbol("length"); + var LENGTH_CALCULATOR = Symbol("lengthCalculator"); + var ALLOW_STALE = Symbol("allowStale"); + var MAX_AGE = Symbol("maxAge"); + var DISPOSE = Symbol("dispose"); + var NO_DISPOSE_ON_SET = Symbol("noDisposeOnSet"); + var LRU_LIST = Symbol("lruList"); + var CACHE = Symbol("cache"); + var UPDATE_AGE_ON_GET = Symbol("updateAgeOnGet"); + var naiveLength = () => 1; + var LRUCache = class { + constructor(options) { + if (typeof options === "number") + options = { max: options }; + if (!options) + options = {}; + if (options.max && (typeof options.max !== "number" || options.max < 0)) + throw new TypeError("max must be a non-negative number"); + const max = this[MAX] = options.max || Infinity; + const lc = options.length || naiveLength; + this[LENGTH_CALCULATOR] = typeof lc !== "function" ? naiveLength : lc; + this[ALLOW_STALE] = options.stale || false; + if (options.maxAge && typeof options.maxAge !== "number") + throw new TypeError("maxAge must be a number"); + this[MAX_AGE] = options.maxAge || 0; + this[DISPOSE] = options.dispose; + this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false; + this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false; + this.reset(); + } + // resize the cache when the max changes. + set max(mL) { + if (typeof mL !== "number" || mL < 0) + throw new TypeError("max must be a non-negative number"); + this[MAX] = mL || Infinity; + trim(this); + } + get max() { + return this[MAX]; + } + set allowStale(allowStale) { + this[ALLOW_STALE] = !!allowStale; + } + get allowStale() { + return this[ALLOW_STALE]; + } + set maxAge(mA) { + if (typeof mA !== "number") + throw new TypeError("maxAge must be a non-negative number"); + this[MAX_AGE] = mA; + trim(this); + } + get maxAge() { + return this[MAX_AGE]; + } + // resize the cache when the lengthCalculator changes. + set lengthCalculator(lC) { + if (typeof lC !== "function") + lC = naiveLength; + if (lC !== this[LENGTH_CALCULATOR]) { + this[LENGTH_CALCULATOR] = lC; + this[LENGTH] = 0; + this[LRU_LIST].forEach((hit) => { + hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key); + this[LENGTH] += hit.length; + }); } + trim(this); } - if (root > max) { - root = max; + get lengthCalculator() { + return this[LENGTH_CALCULATOR]; } - if (max === 0) { - table[table_index++] = 1 << 24 | 64 << 16 | 0; - table[table_index++] = 1 << 24 | 64 << 16 | 0; - opts.bits = 1; - return 0; + get length() { + return this[LENGTH]; } - for (min = 1; min < max; min++) { - if (count[min] !== 0) { - break; + get itemCount() { + return this[LRU_LIST].length; + } + rforEach(fn, thisp) { + thisp = thisp || this; + for (let walker = this[LRU_LIST].tail; walker !== null; ) { + const prev = walker.prev; + forEachStep(this, fn, walker, thisp); + walker = prev; } } - if (root < min) { - root = min; + forEach(fn, thisp) { + thisp = thisp || this; + for (let walker = this[LRU_LIST].head; walker !== null; ) { + const next = walker.next; + forEachStep(this, fn, walker, thisp); + walker = next; + } } - left = 1; - for (len = 1; len <= MAXBITS; len++) { - left <<= 1; - left -= count[len]; - if (left < 0) { - return -1; + keys() { + return this[LRU_LIST].toArray().map((k) => k.key); + } + values() { + return this[LRU_LIST].toArray().map((k) => k.value); + } + reset() { + if (this[DISPOSE] && this[LRU_LIST] && this[LRU_LIST].length) { + this[LRU_LIST].forEach((hit) => this[DISPOSE](hit.key, hit.value)); } + this[CACHE] = /* @__PURE__ */ new Map(); + this[LRU_LIST] = new Yallist(); + this[LENGTH] = 0; } - if (left > 0 && (type === CODES || max !== 1)) { - return -1; + dump() { + return this[LRU_LIST].map((hit) => isStale(this, hit) ? false : { + k: hit.key, + v: hit.value, + e: hit.now + (hit.maxAge || 0) + }).toArray().filter((h) => h); } - offs[1] = 0; - for (len = 1; len < MAXBITS; len++) { - offs[len + 1] = offs[len] + count[len]; + dumpLru() { + return this[LRU_LIST]; } - for (sym = 0; sym < codes; sym++) { - if (lens[lens_index + sym] !== 0) { - work[offs[lens[lens_index + sym]]++] = sym; + set(key, value, maxAge) { + maxAge = maxAge || this[MAX_AGE]; + if (maxAge && typeof maxAge !== "number") + throw new TypeError("maxAge must be a number"); + const now = maxAge ? Date.now() : 0; + const len = this[LENGTH_CALCULATOR](value, key); + if (this[CACHE].has(key)) { + if (len > this[MAX]) { + del(this, this[CACHE].get(key)); + return false; + } + const node = this[CACHE].get(key); + const item = node.value; + if (this[DISPOSE]) { + if (!this[NO_DISPOSE_ON_SET]) + this[DISPOSE](key, item.value); + } + item.now = now; + item.maxAge = maxAge; + item.value = value; + this[LENGTH] += len - item.length; + item.length = len; + this.get(key); + trim(this); + return true; } + const hit = new Entry(key, value, len, now, maxAge); + if (hit.length > this[MAX]) { + if (this[DISPOSE]) + this[DISPOSE](key, value); + return false; + } + this[LENGTH] += hit.length; + this[LRU_LIST].unshift(hit); + this[CACHE].set(key, this[LRU_LIST].head); + trim(this); + return true; } - if (type === CODES) { - base = extra = work; - end = 19; - } else if (type === LENS) { - base = lbase; - base_index -= 257; - extra = lext; - extra_index -= 257; - end = 256; - } else { - base = dbase; - extra = dext; - end = -1; + has(key) { + if (!this[CACHE].has(key)) + return false; + const hit = this[CACHE].get(key).value; + return !isStale(this, hit); } - huff = 0; - sym = 0; - len = min; - next = table_index; - curr = root; - drop = 0; - low = -1; - used = 1 << root; - mask = used - 1; - if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) { - return 1; + get(key) { + return get(this, key, true); } - for (; ; ) { - here_bits = len - drop; - if (work[sym] < end) { - here_op = 0; - here_val = work[sym]; - } else if (work[sym] > end) { - here_op = extra[extra_index + work[sym]]; - here_val = base[base_index + work[sym]]; + peek(key) { + return get(this, key, false); + } + pop() { + const node = this[LRU_LIST].tail; + if (!node) + return null; + del(this, node); + return node.value; + } + del(key) { + del(this, this[CACHE].get(key)); + } + load(arr) { + this.reset(); + const now = Date.now(); + for (let l = arr.length - 1; l >= 0; l--) { + const hit = arr[l]; + const expiresAt = hit.e || 0; + if (expiresAt === 0) + this.set(hit.k, hit.v); + else { + const maxAge = expiresAt - now; + if (maxAge > 0) { + this.set(hit.k, hit.v, maxAge); + } + } + } + } + prune() { + this[CACHE].forEach((value, key) => get(this, key, false)); + } + }; + var get = (self2, key, doUse) => { + const node = self2[CACHE].get(key); + if (node) { + const hit = node.value; + if (isStale(self2, hit)) { + del(self2, node); + if (!self2[ALLOW_STALE]) + return void 0; } else { - here_op = 32 + 64; - here_val = 0; + if (doUse) { + if (self2[UPDATE_AGE_ON_GET]) + node.value.now = Date.now(); + self2[LRU_LIST].unshiftNode(node); + } + } + return hit.value; + } + }; + var isStale = (self2, hit) => { + if (!hit || !hit.maxAge && !self2[MAX_AGE]) + return false; + const diff = Date.now() - hit.now; + return hit.maxAge ? diff > hit.maxAge : self2[MAX_AGE] && diff > self2[MAX_AGE]; + }; + var trim = (self2) => { + if (self2[LENGTH] > self2[MAX]) { + for (let walker = self2[LRU_LIST].tail; self2[LENGTH] > self2[MAX] && walker !== null; ) { + const prev = walker.prev; + del(self2, walker); + walker = prev; + } + } + }; + var del = (self2, node) => { + if (node) { + const hit = node.value; + if (self2[DISPOSE]) + self2[DISPOSE](hit.key, hit.value); + self2[LENGTH] -= hit.length; + self2[CACHE].delete(hit.key); + self2[LRU_LIST].removeNode(node); + } + }; + var Entry = class { + constructor(key, value, length, now, maxAge) { + this.key = key; + this.value = value; + this.length = length; + this.now = now; + this.maxAge = maxAge || 0; + } + }; + var forEachStep = (self2, fn, node, thisp) => { + let hit = node.value; + if (isStale(self2, hit)) { + del(self2, node); + if (!self2[ALLOW_STALE]) + hit = void 0; + } + if (hit) + fn.call(thisp, hit.value, hit.key, self2); + }; + module2.exports = LRUCache; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/classes/range.js +var require_range = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/classes/range.js"(exports2, module2) { + var Range = class _Range { + constructor(range, options) { + options = parseOptions(options); + if (range instanceof _Range) { + if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) { + return range; + } else { + return new _Range(range.raw, options); + } + } + if (range instanceof Comparator) { + this.raw = range.value; + this.set = [[range]]; + this.format(); + return this; + } + this.options = options; + this.loose = !!options.loose; + this.includePrerelease = !!options.includePrerelease; + this.raw = range.trim().split(/\s+/).join(" "); + 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.format(); + } + format() { + this.range = this.set.map((comps) => comps.join(" ").trim()).join("||").trim(); + return this.range; + } + toString() { + return this.range; + } + parseRange(range) { + const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE); + const memoKey = memoOpts + ":" + range; + const cached = cache.get(memoKey); + if (cached) { + return cached; + } + const loose = this.options.loose; + const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE]; + range = range.replace(hr, hyphenReplace(this.options.includePrerelease)); + debug4("hyphen replace", range); + range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace); + debug4("comparator trim", range); + range = range.replace(re[t.TILDETRIM], tildeTrimReplace); + debug4("tilde trim", range); + range = range.replace(re[t.CARETTRIM], caretTrimReplace); + debug4("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) => { + debug4("loose invalid filter", comp, this.options); + return !!comp.match(re[t.COMPARATORLOOSE]); + }); + } + debug4("range list", rangeList); + const rangeMap = /* @__PURE__ */ new Map(); + const comparators = rangeList.map((comp) => new Comparator(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)) { + 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); + }); + }); + }); + }); + } + // if ANY of the sets match ALL of its comparators, then pass + test(version3) { + if (!version3) { + return false; } - incr = 1 << len - drop; - fill = 1 << curr; - min = fill; - do { - fill -= incr; - table[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0; - } while (fill !== 0); - incr = 1 << len - 1; - while (huff & incr) { - incr >>= 1; + if (typeof version3 === "string") { + try { + version3 = new SemVer(version3, this.options); + } catch (er) { + return false; + } } - if (incr !== 0) { - huff &= incr - 1; - huff += incr; + for (let i = 0; i < this.set.length; i++) { + if (testSet(this.set[i], version3, this.options)) { + return true; + } + } + return false; + } + }; + module2.exports = Range; + var LRU = require_lru_cache(); + var cache = new LRU({ max: 1e3 }); + var parseOptions = require_parse_options(); + var Comparator = require_comparator(); + var debug4 = require_debug(); + var SemVer = require_semver(); + var { + safeRe: re, + t, + comparatorTrimReplace, + tildeTrimReplace, + caretTrimReplace + } = require_re(); + var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants7(); + var isNullSet = (c) => c.value === "<0.0.0-0"; + var isAny = (c) => c.value === ""; + var 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; + }; + var parseComparator = (comp, options) => { + debug4("comp", comp, options); + comp = replaceCarets(comp, options); + debug4("caret", comp); + comp = replaceTildes(comp, options); + debug4("tildes", comp); + comp = replaceXRanges(comp, options); + debug4("xrange", comp); + comp = replaceStars(comp, options); + debug4("stars", comp); + return comp; + }; + var isX = (id) => !id || id.toLowerCase() === "x" || id === "*"; + var replaceTildes = (comp, options) => { + return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" "); + }; + var replaceTilde = (comp, options) => { + const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE]; + return comp.replace(r, (_, M, m, p, pr) => { + debug4("tilde", comp, _, M, m, p, pr); + let ret; + if (isX(M)) { + ret = ""; + } else if (isX(m)) { + ret = `>=${M}.0.0 <${+M + 1}.0.0-0`; + } else if (isX(p)) { + ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`; + } else if (pr) { + debug4("replaceTilde pr", pr); + ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`; } else { - huff = 0; + ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`; } - sym++; - if (--count[len] === 0) { - if (len === max) { - break; + debug4("tilde return", ret); + return ret; + }); + }; + var replaceCarets = (comp, options) => { + return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" "); + }; + var replaceCaret = (comp, options) => { + debug4("caret", comp, options); + const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET]; + const z = options.includePrerelease ? "-0" : ""; + return comp.replace(r, (_, M, m, p, pr) => { + debug4("caret", comp, _, M, m, p, pr); + let ret; + if (isX(M)) { + ret = ""; + } else if (isX(m)) { + ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`; + } else if (isX(p)) { + if (M === "0") { + ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`; + } else { + ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`; + } + } else if (pr) { + debug4("replaceCaret pr", pr); + if (M === "0") { + if (m === "0") { + ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`; + } else { + ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`; + } + } else { + ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`; + } + } else { + debug4("no pr"); + if (M === "0") { + if (m === "0") { + ret = `>=${M}.${m}.${p}${z} <${M}.${m}.${+p + 1}-0`; + } else { + ret = `>=${M}.${m}.${p}${z} <${M}.${+m + 1}.0-0`; + } + } else { + ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`; } - len = lens[lens_index + work[sym]]; } - if (len > root && (huff & mask) !== low) { - if (drop === 0) { - drop = root; + debug4("caret return", ret); + return ret; + }); + }; + var replaceXRanges = (comp, options) => { + debug4("replaceXRanges", comp, options); + return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" "); + }; + var replaceXRange = (comp, options) => { + comp = comp.trim(); + const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE]; + return comp.replace(r, (ret, gtlt, M, m, p, pr) => { + debug4("xRange", comp, ret, gtlt, M, m, p, pr); + const xM = isX(M); + const xm = xM || isX(m); + 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 = "*"; } - next += min; - curr = len - drop; - left = 1 << curr; - while (curr + drop < max) { - left -= count[curr + drop]; - if (left <= 0) { - break; + } else if (gtlt && anyX) { + if (xm) { + m = 0; + } + p = 0; + if (gtlt === ">") { + gtlt = ">="; + if (xm) { + M = +M + 1; + m = 0; + p = 0; + } else { + m = +m + 1; + p = 0; + } + } else if (gtlt === "<=") { + gtlt = "<"; + if (xm) { + M = +M + 1; + } else { + m = +m + 1; } - curr++; - left <<= 1; } - used += 1 << curr; - if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) { - return 1; + if (gtlt === "<") { + pr = "-0"; } - low = huff & mask; - table[low] = root << 24 | curr << 16 | next - table_index | 0; + ret = `${gtlt + M}.${m}.${p}${pr}`; + } else if (xm) { + ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`; + } else if (xp) { + ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`; } + debug4("xRange return", ret); + return ret; + }); + }; + var replaceStars = (comp, options) => { + debug4("replaceStars", comp, options); + return comp.trim().replace(re[t.STAR], ""); + }; + var replaceGTE0 = (comp, options) => { + debug4("replaceGTE0", comp, options); + return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], ""); + }; + var hyphenReplace = (incPr) => ($0, from2, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) => { + if (isX(fM)) { + from2 = ""; + } else if (isX(fm)) { + from2 = `>=${fM}.0.0${incPr ? "-0" : ""}`; + } else if (isX(fp)) { + from2 = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`; + } else if (fpr) { + from2 = `>=${from2}`; + } else { + from2 = `>=${from2}${incPr ? "-0" : ""}`; } - if (huff !== 0) { - table[next + huff] = len - drop << 24 | 64 << 16 | 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}`; } - opts.bits = root; - return 0; + return `${from2} ${to}`.trim(); + }; + var testSet = (set, version3, options) => { + for (let i = 0; i < set.length; i++) { + if (!set[i].test(version3)) { + return false; + } + } + if (version3.prerelease.length && !options.includePrerelease) { + for (let i = 0; i < set.length; i++) { + debug4(set[i].semver); + if (set[i].semver === Comparator.ANY) { + continue; + } + if (set[i].semver.prerelease.length > 0) { + const allowed = set[i].semver; + if (allowed.major === version3.major && allowed.minor === version3.minor && allowed.patch === version3.patch) { + return true; + } + } + } + return false; + } + return true; }; } }); -// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/inflate.js -var require_inflate = __commonJS({ - "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/inflate.js"(exports2) { - "use strict"; - var utils = require_common(); - var adler32 = require_adler32(); - var crc322 = require_crc322(); - var inflate_fast = require_inffast(); - var inflate_table = require_inftrees(); - var CODES = 0; - var LENS = 1; - var DISTS = 2; - var Z_FINISH = 4; - var Z_BLOCK = 5; - var Z_TREES = 6; - var Z_OK = 0; - var Z_STREAM_END = 1; - var Z_NEED_DICT = 2; - var Z_STREAM_ERROR = -2; - var Z_DATA_ERROR = -3; - var Z_MEM_ERROR = -4; - var Z_BUF_ERROR = -5; - var Z_DEFLATED = 8; - var HEAD = 1; - var FLAGS = 2; - var TIME = 3; - var OS = 4; - var EXLEN = 5; - var EXTRA = 6; - var NAME = 7; - var COMMENT = 8; - var HCRC = 9; - var DICTID = 10; - var DICT = 11; - var TYPE = 12; - var TYPEDO = 13; - var STORED = 14; - var COPY_ = 15; - var COPY = 16; - var TABLE = 17; - var LENLENS = 18; - var CODELENS = 19; - var LEN_ = 20; - var LEN = 21; - var LENEXT = 22; - var DIST = 23; - var DISTEXT = 24; - var MATCH = 25; - var LIT = 26; - var CHECK = 27; - var LENGTH = 28; - var DONE = 29; - var BAD = 30; - var MEM = 31; - var SYNC = 32; - var ENOUGH_LENS = 852; - var ENOUGH_DISTS = 592; - var MAX_WBITS = 15; - var DEF_WBITS = MAX_WBITS; - function zswap32(q) { - return (q >>> 24 & 255) + (q >>> 8 & 65280) + ((q & 65280) << 8) + ((q & 255) << 24); - } - function InflateState() { - this.mode = 0; - this.last = false; - this.wrap = 0; - this.havedict = false; - this.flags = 0; - this.dmax = 0; - this.check = 0; - this.total = 0; - this.head = null; - this.wbits = 0; - this.wsize = 0; - this.whave = 0; - this.wnext = 0; - this.window = null; - this.hold = 0; - this.bits = 0; - this.length = 0; - this.offset = 0; - this.extra = 0; - this.lencode = null; - this.distcode = null; - this.lenbits = 0; - this.distbits = 0; - this.ncode = 0; - this.nlen = 0; - this.ndist = 0; - this.have = 0; - this.next = null; - this.lens = new utils.Buf16(320); - this.work = new utils.Buf16(288); - this.lendyn = null; - this.distdyn = null; - this.sane = 0; - this.back = 0; - this.was = 0; - } - function inflateResetKeep(strm) { - var state; - if (!strm || !strm.state) { - return Z_STREAM_ERROR; - } - state = strm.state; - strm.total_in = strm.total_out = state.total = 0; - strm.msg = ""; - if (state.wrap) { - strm.adler = state.wrap & 1; - } - state.mode = HEAD; - state.last = 0; - state.havedict = 0; - state.dmax = 32768; - state.head = null; - state.hold = 0; - state.bits = 0; - state.lencode = state.lendyn = new utils.Buf32(ENOUGH_LENS); - state.distcode = state.distdyn = new utils.Buf32(ENOUGH_DISTS); - state.sane = 1; - state.back = -1; - return Z_OK; - } - function inflateReset(strm) { - var state; - if (!strm || !strm.state) { - return Z_STREAM_ERROR; - } - state = strm.state; - state.wsize = 0; - state.whave = 0; - state.wnext = 0; - return inflateResetKeep(strm); - } - function inflateReset2(strm, windowBits) { - var wrap; - var state; - if (!strm || !strm.state) { - return Z_STREAM_ERROR; +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/classes/comparator.js +var require_comparator = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/classes/comparator.js"(exports2, module2) { + var ANY = Symbol("SemVer ANY"); + var Comparator = class _Comparator { + static get ANY() { + return ANY; } - state = strm.state; - if (windowBits < 0) { - wrap = 0; - windowBits = -windowBits; - } else { - wrap = (windowBits >> 4) + 1; - if (windowBits < 48) { - windowBits &= 15; + constructor(comp, options) { + options = parseOptions(options); + if (comp instanceof _Comparator) { + if (comp.loose === !!options.loose) { + return comp; + } else { + comp = comp.value; + } } + comp = comp.trim().split(/\s+/).join(" "); + debug4("comparator", comp, options); + this.options = options; + this.loose = !!options.loose; + this.parse(comp); + if (this.semver === ANY) { + this.value = ""; + } else { + this.value = this.operator + this.semver.version; + } + debug4("comp", this); } - if (windowBits && (windowBits < 8 || windowBits > 15)) { - return Z_STREAM_ERROR; - } - if (state.window !== null && state.wbits !== windowBits) { - state.window = null; + parse(comp) { + const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]; + const m = comp.match(r); + if (!m) { + throw new TypeError(`Invalid comparator: ${comp}`); + } + this.operator = m[1] !== void 0 ? m[1] : ""; + if (this.operator === "=") { + this.operator = ""; + } + if (!m[2]) { + this.semver = ANY; + } else { + this.semver = new SemVer(m[2], this.options.loose); + } } - state.wrap = wrap; - state.wbits = windowBits; - return inflateReset(strm); - } - function inflateInit2(strm, windowBits) { - var ret; - var state; - if (!strm) { - return Z_STREAM_ERROR; + toString() { + return this.value; } - state = new InflateState(); - strm.state = state; - state.window = null; - ret = inflateReset2(strm, windowBits); - if (ret !== Z_OK) { - strm.state = null; + test(version3) { + debug4("Comparator.test", version3, this.options.loose); + if (this.semver === ANY || version3 === ANY) { + return true; + } + if (typeof version3 === "string") { + try { + version3 = new SemVer(version3, this.options); + } catch (er) { + return false; + } + } + return cmp(version3, this.operator, this.semver, this.options); } - return ret; - } - function inflateInit(strm) { - return inflateInit2(strm, DEF_WBITS); - } - var virgin = true; - var lenfix; - var distfix; - function fixedtables(state) { - if (virgin) { - var sym; - lenfix = new utils.Buf32(512); - distfix = new utils.Buf32(32); - sym = 0; - while (sym < 144) { - state.lens[sym++] = 8; + intersects(comp, options) { + if (!(comp instanceof _Comparator)) { + throw new TypeError("a Comparator is required"); + } + if (this.operator === "") { + if (this.value === "") { + return true; + } + return new Range(comp.value, options).test(this.value); + } else if (comp.operator === "") { + if (comp.value === "") { + return true; + } + return new Range(this.value, options).test(comp.semver); } - while (sym < 256) { - state.lens[sym++] = 9; + options = parseOptions(options); + if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) { + return false; } - while (sym < 280) { - state.lens[sym++] = 7; + if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) { + return false; } - while (sym < 288) { - state.lens[sym++] = 8; + if (this.operator.startsWith(">") && comp.operator.startsWith(">")) { + return true; } - inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 }); - sym = 0; - while (sym < 32) { - state.lens[sym++] = 5; + if (this.operator.startsWith("<") && comp.operator.startsWith("<")) { + return true; } - inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 }); - virgin = false; - } - state.lencode = lenfix; - state.lenbits = 9; - state.distcode = distfix; - state.distbits = 5; - } - function updatewindow(strm, src, end, copy) { - var dist; - var state = strm.state; - if (state.window === null) { - state.wsize = 1 << state.wbits; - state.wnext = 0; - state.whave = 0; - state.window = new utils.Buf8(state.wsize); - } - if (copy >= state.wsize) { - utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0); - state.wnext = 0; - state.whave = state.wsize; - } else { - dist = state.wsize - state.wnext; - if (dist > copy) { - dist = copy; + if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) { + return true; } - utils.arraySet(state.window, src, end - copy, dist, state.wnext); - copy -= dist; - if (copy) { - utils.arraySet(state.window, src, end - copy, copy, 0); - state.wnext = copy; - state.whave = state.wsize; - } else { - state.wnext += dist; - if (state.wnext === state.wsize) { - state.wnext = 0; - } - if (state.whave < state.wsize) { - state.whave += dist; - } + if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) { + return true; + } + if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) { + return true; } + return false; } - return 0; - } - function inflate2(strm, flush) { - var state; - var input, output; - var next; - var put; - var have, left; - var hold; - var bits; - var _in, _out; - var copy; - var from3; - var from_source; - var here = 0; - var here_bits, here_op, here_val; - var last_bits, last_op, last_val; - var len; - var ret; - var hbuf = new utils.Buf8(4); - var opts; - var n; - var order = ( - /* permutation of code lengths */ - [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15] - ); - if (!strm || !strm.state || !strm.output || !strm.input && strm.avail_in !== 0) { - return Z_STREAM_ERROR; + }; + module2.exports = Comparator; + var parseOptions = require_parse_options(); + var { safeRe: re, t } = require_re(); + var cmp = require_cmp(); + var debug4 = require_debug(); + var SemVer = require_semver(); + var Range = require_range(); + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/satisfies.js +var require_satisfies = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/functions/satisfies.js"(exports2, module2) { + var Range = require_range(); + var satisfies = (version3, range, options) => { + try { + range = new Range(range, options); + } catch (er) { + return false; } - state = strm.state; - if (state.mode === TYPE) { - state.mode = TYPEDO; + return range.test(version3); + }; + module2.exports = satisfies; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/to-comparators.js +var require_to_comparators = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/to-comparators.js"(exports2, module2) { + var Range = require_range(); + var toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" ")); + module2.exports = toComparators; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/max-satisfying.js +var require_max_satisfying = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/max-satisfying.js"(exports2, module2) { + var SemVer = require_semver(); + var Range = require_range(); + var maxSatisfying = (versions, range, options) => { + let max = null; + let maxSV = null; + let rangeObj = null; + try { + rangeObj = new Range(range, options); + } catch (er) { + return null; } - put = strm.next_out; - output = strm.output; - left = strm.avail_out; - next = strm.next_in; - input = strm.input; - have = strm.avail_in; - hold = state.hold; - bits = state.bits; - _in = have; - _out = left; - ret = Z_OK; - inf_leave: - for (; ; ) { - switch (state.mode) { - case HEAD: - if (state.wrap === 0) { - state.mode = TYPEDO; - break; - } - while (bits < 16) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - if (state.wrap & 2 && hold === 35615) { - state.check = 0; - hbuf[0] = hold & 255; - hbuf[1] = hold >>> 8 & 255; - state.check = crc322(state.check, hbuf, 2, 0); - hold = 0; - bits = 0; - state.mode = FLAGS; - break; - } - state.flags = 0; - if (state.head) { - state.head.done = false; - } - if (!(state.wrap & 1) || /* check if zlib header allowed */ - (((hold & 255) << 8) + (hold >> 8)) % 31) { - strm.msg = "incorrect header check"; - state.mode = BAD; - break; - } - if ((hold & 15) !== Z_DEFLATED) { - strm.msg = "unknown compression method"; - state.mode = BAD; - break; - } - hold >>>= 4; - bits -= 4; - len = (hold & 15) + 8; - if (state.wbits === 0) { - state.wbits = len; - } else if (len > state.wbits) { - strm.msg = "invalid window size"; - state.mode = BAD; - break; - } - state.dmax = 1 << len; - strm.adler = state.check = 1; - state.mode = hold & 512 ? DICTID : TYPE; - hold = 0; - bits = 0; - break; - case FLAGS: - while (bits < 16) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - state.flags = hold; - if ((state.flags & 255) !== Z_DEFLATED) { - strm.msg = "unknown compression method"; - state.mode = BAD; - break; - } - if (state.flags & 57344) { - strm.msg = "unknown header flags set"; - state.mode = BAD; - break; - } - if (state.head) { - state.head.text = hold >> 8 & 1; - } - if (state.flags & 512) { - hbuf[0] = hold & 255; - hbuf[1] = hold >>> 8 & 255; - state.check = crc322(state.check, hbuf, 2, 0); - } - hold = 0; - bits = 0; - state.mode = TIME; - case TIME: - while (bits < 32) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - if (state.head) { - state.head.time = hold; - } - if (state.flags & 512) { - hbuf[0] = hold & 255; - hbuf[1] = hold >>> 8 & 255; - hbuf[2] = hold >>> 16 & 255; - hbuf[3] = hold >>> 24 & 255; - state.check = crc322(state.check, hbuf, 4, 0); - } - hold = 0; - bits = 0; - state.mode = OS; - case OS: - while (bits < 16) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - if (state.head) { - state.head.xflags = hold & 255; - state.head.os = hold >> 8; - } - if (state.flags & 512) { - hbuf[0] = hold & 255; - hbuf[1] = hold >>> 8 & 255; - state.check = crc322(state.check, hbuf, 2, 0); - } - hold = 0; - bits = 0; - state.mode = EXLEN; - case EXLEN: - if (state.flags & 1024) { - while (bits < 16) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - state.length = hold; - if (state.head) { - state.head.extra_len = hold; - } - if (state.flags & 512) { - hbuf[0] = hold & 255; - hbuf[1] = hold >>> 8 & 255; - state.check = crc322(state.check, hbuf, 2, 0); - } - hold = 0; - bits = 0; - } else if (state.head) { - state.head.extra = null; - } - state.mode = EXTRA; - case EXTRA: - if (state.flags & 1024) { - copy = state.length; - if (copy > have) { - copy = have; - } - if (copy) { - if (state.head) { - len = state.head.extra_len - state.length; - if (!state.head.extra) { - state.head.extra = new Array(state.head.extra_len); - } - utils.arraySet( - state.head.extra, - input, - next, - // extra field is limited to 65536 bytes - // - no need for additional size check - copy, - /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/ - len - ); - } - if (state.flags & 512) { - state.check = crc322(state.check, input, copy, next); - } - have -= copy; - next += copy; - state.length -= copy; - } - if (state.length) { - break inf_leave; - } - } - state.length = 0; - state.mode = NAME; - case NAME: - if (state.flags & 2048) { - if (have === 0) { - break inf_leave; - } - copy = 0; - do { - len = input[next + copy++]; - if (state.head && len && state.length < 65536) { - state.head.name += String.fromCharCode(len); - } - } while (len && copy < have); - if (state.flags & 512) { - state.check = crc322(state.check, input, copy, next); - } - have -= copy; - next += copy; - if (len) { - break inf_leave; - } - } else if (state.head) { - state.head.name = null; - } - state.length = 0; - state.mode = COMMENT; - case COMMENT: - if (state.flags & 4096) { - if (have === 0) { - break inf_leave; - } - copy = 0; - do { - len = input[next + copy++]; - if (state.head && len && state.length < 65536) { - state.head.comment += String.fromCharCode(len); - } - } while (len && copy < have); - if (state.flags & 512) { - state.check = crc322(state.check, input, copy, next); - } - have -= copy; - next += copy; - if (len) { - break inf_leave; - } - } else if (state.head) { - state.head.comment = null; - } - state.mode = HCRC; - case HCRC: - if (state.flags & 512) { - while (bits < 16) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - if (hold !== (state.check & 65535)) { - strm.msg = "header crc mismatch"; - state.mode = BAD; - break; - } - hold = 0; - bits = 0; - } - if (state.head) { - state.head.hcrc = state.flags >> 9 & 1; - state.head.done = true; - } - strm.adler = state.check = 0; - state.mode = TYPE; - break; - case DICTID: - while (bits < 32) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - strm.adler = state.check = zswap32(hold); - hold = 0; - bits = 0; - state.mode = DICT; - case DICT: - if (state.havedict === 0) { - strm.next_out = put; - strm.avail_out = left; - strm.next_in = next; - strm.avail_in = have; - state.hold = hold; - state.bits = bits; - return Z_NEED_DICT; - } - strm.adler = state.check = 1; - state.mode = TYPE; - case TYPE: - if (flush === Z_BLOCK || flush === Z_TREES) { - break inf_leave; - } - case TYPEDO: - if (state.last) { - hold >>>= bits & 7; - bits -= bits & 7; - state.mode = CHECK; - break; - } - while (bits < 3) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; + versions.forEach((v) => { + if (rangeObj.test(v)) { + if (!max || maxSV.compare(v) === -1) { + max = v; + maxSV = new SemVer(max, options); + } + } + }); + return max; + }; + module2.exports = maxSatisfying; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/min-satisfying.js +var require_min_satisfying = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/min-satisfying.js"(exports2, module2) { + var SemVer = require_semver(); + var Range = require_range(); + var minSatisfying = (versions, range, options) => { + let min = null; + let minSV = null; + let rangeObj = null; + try { + rangeObj = new Range(range, options); + } catch (er) { + return null; + } + versions.forEach((v) => { + if (rangeObj.test(v)) { + if (!min || minSV.compare(v) === 1) { + min = v; + minSV = new SemVer(min, options); + } + } + }); + return min; + }; + module2.exports = minSatisfying; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/min-version.js +var require_min_version = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/min-version.js"(exports2, module2) { + var SemVer = require_semver(); + var Range = require_range(); + var gt = require_gt(); + var minVersion = (range, loose) => { + range = new Range(range, loose); + let minver = new SemVer("0.0.0"); + if (range.test(minver)) { + return minver; + } + minver = new SemVer("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(comparator.semver.version); + switch (comparator.operator) { + case ">": + if (compver.prerelease.length === 0) { + compver.patch++; + } else { + compver.prerelease.push(0); } - state.last = hold & 1; - hold >>>= 1; - bits -= 1; - switch (hold & 3) { - case 0: - state.mode = STORED; - break; - case 1: - fixedtables(state); - state.mode = LEN_; - if (flush === Z_TREES) { - hold >>>= 2; - bits -= 2; - break inf_leave; - } - break; - case 2: - state.mode = TABLE; - break; - case 3: - strm.msg = "invalid block type"; - state.mode = BAD; + compver.raw = compver.format(); + case "": + case ">=": + if (!setMin || gt(compver, setMin)) { + setMin = compver; } - hold >>>= 2; - bits -= 2; break; - case STORED: - hold >>>= bits & 7; - bits -= bits & 7; - while (bits < 32) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - if ((hold & 65535) !== (hold >>> 16 ^ 65535)) { - strm.msg = "invalid stored block lengths"; - state.mode = BAD; - break; - } - state.length = hold & 65535; - hold = 0; - bits = 0; - state.mode = COPY_; - if (flush === Z_TREES) { - break inf_leave; - } - case COPY_: - state.mode = COPY; - case COPY: - copy = state.length; - if (copy) { - if (copy > have) { - copy = have; - } - if (copy > left) { - copy = left; - } - if (copy === 0) { - break inf_leave; - } - utils.arraySet(output, input, next, copy, put); - have -= copy; - next += copy; - left -= copy; - put += copy; - state.length -= copy; - break; - } - state.mode = TYPE; + case "<": + case "<=": break; - case TABLE: - while (bits < 14) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - state.nlen = (hold & 31) + 257; - hold >>>= 5; - bits -= 5; - state.ndist = (hold & 31) + 1; - hold >>>= 5; - bits -= 5; - state.ncode = (hold & 15) + 4; - hold >>>= 4; - bits -= 4; - if (state.nlen > 286 || state.ndist > 30) { - strm.msg = "too many length or distance symbols"; - state.mode = BAD; - break; - } - state.have = 0; - state.mode = LENLENS; - case LENLENS: - while (state.have < state.ncode) { - while (bits < 3) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - state.lens[order[state.have++]] = hold & 7; - hold >>>= 3; - bits -= 3; - } - while (state.have < 19) { - state.lens[order[state.have++]] = 0; - } - state.lencode = state.lendyn; - state.lenbits = 7; - opts = { bits: state.lenbits }; - ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts); - state.lenbits = opts.bits; - if (ret) { - strm.msg = "invalid code lengths set"; - state.mode = BAD; - break; - } - state.have = 0; - state.mode = CODELENS; - case CODELENS: - while (state.have < state.nlen + state.ndist) { - for (; ; ) { - here = state.lencode[hold & (1 << state.lenbits) - 1]; - here_bits = here >>> 24; - here_op = here >>> 16 & 255; - here_val = here & 65535; - if (here_bits <= bits) { - break; - } - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - if (here_val < 16) { - hold >>>= here_bits; - bits -= here_bits; - state.lens[state.have++] = here_val; - } else { - if (here_val === 16) { - n = here_bits + 2; - while (bits < n) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - hold >>>= here_bits; - bits -= here_bits; - if (state.have === 0) { - strm.msg = "invalid bit length repeat"; - state.mode = BAD; - break; - } - len = state.lens[state.have - 1]; - copy = 3 + (hold & 3); - hold >>>= 2; - bits -= 2; - } else if (here_val === 17) { - n = here_bits + 3; - while (bits < n) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - hold >>>= here_bits; - bits -= here_bits; - len = 0; - copy = 3 + (hold & 7); - hold >>>= 3; - bits -= 3; - } else { - n = here_bits + 7; - while (bits < n) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - hold >>>= here_bits; - bits -= here_bits; - len = 0; - copy = 11 + (hold & 127); - hold >>>= 7; - bits -= 7; - } - if (state.have + copy > state.nlen + state.ndist) { - strm.msg = "invalid bit length repeat"; - state.mode = BAD; - break; - } - while (copy--) { - state.lens[state.have++] = len; - } - } - } - if (state.mode === BAD) { - break; - } - if (state.lens[256] === 0) { - strm.msg = "invalid code -- missing end-of-block"; - state.mode = BAD; - break; - } - state.lenbits = 9; - opts = { bits: state.lenbits }; - ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts); - state.lenbits = opts.bits; - if (ret) { - strm.msg = "invalid literal/lengths set"; - state.mode = BAD; - break; - } - state.distbits = 6; - state.distcode = state.distdyn; - opts = { bits: state.distbits }; - ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts); - state.distbits = opts.bits; - if (ret) { - strm.msg = "invalid distances set"; - state.mode = BAD; - break; - } - state.mode = LEN_; - if (flush === Z_TREES) { - break inf_leave; - } - case LEN_: - state.mode = LEN; - case LEN: - if (have >= 6 && left >= 258) { - strm.next_out = put; - strm.avail_out = left; - strm.next_in = next; - strm.avail_in = have; - state.hold = hold; - state.bits = bits; - inflate_fast(strm, _out); - put = strm.next_out; - output = strm.output; - left = strm.avail_out; - next = strm.next_in; - input = strm.input; - have = strm.avail_in; - hold = state.hold; - bits = state.bits; - if (state.mode === TYPE) { - state.back = -1; - } - break; - } - state.back = 0; - for (; ; ) { - here = state.lencode[hold & (1 << state.lenbits) - 1]; - here_bits = here >>> 24; - here_op = here >>> 16 & 255; - here_val = here & 65535; - if (here_bits <= bits) { - break; - } - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - if (here_op && (here_op & 240) === 0) { - last_bits = here_bits; - last_op = here_op; - last_val = here_val; - for (; ; ) { - here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)]; - here_bits = here >>> 24; - here_op = here >>> 16 & 255; - here_val = here & 65535; - if (last_bits + here_bits <= bits) { - break; - } - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - hold >>>= last_bits; - bits -= last_bits; - state.back += last_bits; + default: + throw new Error(`Unexpected operation: ${comparator.operator}`); + } + }); + if (setMin && (!minver || gt(minver, setMin))) { + minver = setMin; + } + } + if (minver && range.test(minver)) { + return minver; + } + return null; + }; + module2.exports = minVersion; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/valid.js +var require_valid2 = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/valid.js"(exports2, module2) { + var Range = require_range(); + var validRange = (range, options) => { + try { + return new Range(range, options).range || "*"; + } catch (er) { + return null; + } + }; + module2.exports = validRange; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/outside.js +var require_outside = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/outside.js"(exports2, module2) { + var SemVer = require_semver(); + var Comparator = require_comparator(); + var { ANY } = Comparator; + var Range = require_range(); + var satisfies = require_satisfies(); + var gt = require_gt(); + var lt = require_lt(); + var lte = require_lte(); + var gte = require_gte(); + var outside = (version3, range, hilo, options) => { + version3 = new SemVer(version3, options); + range = new Range(range, options); + let gtfn, ltefn, ltfn, comp, ecomp; + switch (hilo) { + case ">": + gtfn = gt; + ltefn = lte; + ltfn = lt; + comp = ">"; + ecomp = ">="; + break; + case "<": + gtfn = lt; + ltefn = gte; + ltfn = gt; + comp = "<"; + ecomp = "<="; + break; + default: + throw new TypeError('Must provide a hilo val of "<" or ">"'); + } + if (satisfies(version3, 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) { + comparator = new Comparator(">=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(version3, low.semver)) { + return false; + } else if (low.operator === ecomp && ltfn(version3, low.semver)) { + return false; + } + } + return true; + }; + module2.exports = outside; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/gtr.js +var require_gtr = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/gtr.js"(exports2, module2) { + var outside = require_outside(); + var gtr = (version3, range, options) => outside(version3, range, ">", options); + module2.exports = gtr; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/ltr.js +var require_ltr = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/ltr.js"(exports2, module2) { + var outside = require_outside(); + var ltr = (version3, range, options) => outside(version3, range, "<", options); + module2.exports = ltr; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/intersects.js +var require_intersects = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/intersects.js"(exports2, module2) { + var Range = require_range(); + var intersects = (r1, r2, options) => { + r1 = new Range(r1, options); + r2 = new Range(r2, options); + return r1.intersects(r2, options); + }; + module2.exports = intersects; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/simplify.js +var require_simplify = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/simplify.js"(exports2, module2) { + var satisfies = require_satisfies(); + var compare = require_compare(); + module2.exports = (versions, range, options) => { + const set = []; + let first = null; + let prev = null; + const v = versions.sort((a, b) => compare(a, b, options)); + for (const version3 of v) { + const included = satisfies(version3, range, options); + if (included) { + prev = version3; + if (!first) { + first = version3; + } + } 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; + }; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/subset.js +var require_subset = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/ranges/subset.js"(exports2, module2) { + var Range = require_range(); + var Comparator = require_comparator(); + var { ANY } = Comparator; + var satisfies = require_satisfies(); + var compare = require_compare(); + var subset = (sub, dom, options = {}) => { + if (sub === dom) { + return true; + } + sub = new Range(sub, options); + dom = new Range(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; + }; + var minimumVersionWithPreRelease = [new Comparator(">=0.0.0-0")]; + var minimumVersion = [new Comparator(">=0.0.0")]; + var 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, lt; + for (const c of sub) { + if (c.operator === ">" || c.operator === ">=") { + gt = higherGT(gt, c, options); + } else if (c.operator === "<" || c.operator === "<=") { + lt = lowerLT(lt, c, options); + } else { + eqSet.add(c.semver); + } + } + if (eqSet.size > 1) { + return null; + } + let gtltComp; + if (gt && lt) { + gtltComp = compare(gt.semver, lt.semver, options); + if (gtltComp > 0) { + return null; + } else if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<=")) { + return null; + } + } + for (const eq of eqSet) { + if (gt && !satisfies(eq, String(gt), options)) { + return null; + } + if (lt && !satisfies(eq, String(lt), options)) { + return null; + } + for (const c of dom) { + if (!satisfies(eq, String(c), options)) { + return false; + } + } + return true; + } + let higher, lower2; + let hasDomLT, hasDomGT; + let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false; + let needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : false; + if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.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) { + 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, c, options); + if (higher === c && higher !== gt) { + return false; + } + } else if (gt.operator === ">=" && !satisfies(gt.semver, String(c), options)) { + return false; + } + } + if (lt) { + 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 === "<=") { + lower2 = lowerLT(lt, c, options); + if (lower2 === c && lower2 !== lt) { + return false; + } + } else if (lt.operator === "<=" && !satisfies(lt.semver, String(c), options)) { + return false; + } + } + if (!c.operator && (lt || gt) && gtltComp !== 0) { + return false; + } + } + if (gt && hasDomLT && !lt && gtltComp !== 0) { + return false; + } + if (lt && hasDomGT && !gt && gtltComp !== 0) { + return false; + } + if (needDomGTPre || needDomLTPre) { + return false; + } + return true; + }; + var higherGT = (a, b, options) => { + if (!a) { + return b; + } + const comp = compare(a.semver, b.semver, options); + return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a; + }; + var lowerLT = (a, b, options) => { + if (!a) { + return b; + } + const comp = compare(a.semver, b.semver, options); + return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a; + }; + module2.exports = subset; + } +}); + +// ../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/index.js +var require_semver2 = __commonJS({ + "../../../node_modules/.pnpm/semver@7.6.0/node_modules/semver/index.js"(exports2, module2) { + var internalRe = require_re(); + var constants = require_constants7(); + var SemVer = require_semver(); + var identifiers = require_identifiers(); + var parse2 = require_parse2(); + var valid = require_valid(); + var clean = require_clean(); + var inc = require_inc(); + var diff = require_diff(); + var major = require_major(); + var minor = require_minor(); + var patch = require_patch(); + var prerelease = require_prerelease(); + var compare = require_compare(); + var rcompare = require_rcompare(); + var compareLoose = require_compare_loose(); + var compareBuild = require_compare_build(); + var sort = require_sort(); + var rsort = require_rsort(); + var gt = require_gt(); + var lt = require_lt(); + var eq = require_eq(); + var neq = require_neq(); + var gte = require_gte(); + var lte = require_lte(); + var cmp = require_cmp(); + var coerce = require_coerce(); + var Comparator = require_comparator(); + var Range = require_range(); + var satisfies = require_satisfies(); + var toComparators = require_to_comparators(); + var maxSatisfying = require_max_satisfying(); + var minSatisfying = require_min_satisfying(); + var minVersion = require_min_version(); + var validRange = require_valid2(); + var outside = require_outside(); + var gtr = require_gtr(); + var ltr = require_ltr(); + var intersects = require_intersects(); + var simplifyRange = require_simplify(); + var subset = require_subset(); + module2.exports = { + parse: parse2, + 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 + }; + } +}); + +// ../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/asymmetricKeyDetailsSupported.js +var require_asymmetricKeyDetailsSupported = __commonJS({ + "../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/asymmetricKeyDetailsSupported.js"(exports2, module2) { + var semver = require_semver2(); + module2.exports = semver.satisfies(process.version, ">=15.7.0"); + } +}); + +// ../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/rsaPssKeyDetailsSupported.js +var require_rsaPssKeyDetailsSupported = __commonJS({ + "../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/rsaPssKeyDetailsSupported.js"(exports2, module2) { + var semver = require_semver2(); + module2.exports = semver.satisfies(process.version, ">=16.9.0"); + } +}); + +// ../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/validateAsymmetricKey.js +var require_validateAsymmetricKey = __commonJS({ + "../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/validateAsymmetricKey.js"(exports2, module2) { + var ASYMMETRIC_KEY_DETAILS_SUPPORTED = require_asymmetricKeyDetailsSupported(); + var RSA_PSS_KEY_DETAILS_SUPPORTED = require_rsaPssKeyDetailsSupported(); + var allowedAlgorithmsForKeys = { + "ec": ["ES256", "ES384", "ES512"], + "rsa": ["RS256", "PS256", "RS384", "PS384", "RS512", "PS512"], + "rsa-pss": ["PS256", "PS384", "PS512"] + }; + var allowedCurves = { + ES256: "prime256v1", + ES384: "secp384r1", + ES512: "secp521r1" + }; + module2.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(", ")}.`); + } + 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}.`); } - hold >>>= here_bits; - bits -= here_bits; - state.back += here_bits; - state.length = here_val; - if (here_op === 0) { - state.mode = LIT; - break; + 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}.`); } - if (here_op & 32) { - state.back = -1; - state.mode = TYPE; - break; + } + break; + } + } + }; + } +}); + +// ../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/psSupported.js +var require_psSupported = __commonJS({ + "../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/psSupported.js"(exports2, module2) { + var semver = require_semver2(); + module2.exports = semver.satisfies(process.version, "^6.12.0 || >=8.0.0"); + } +}); + +// ../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/verify.js +var require_verify = __commonJS({ + "../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/verify.js"(exports2, module2) { + var JsonWebTokenError = require_JsonWebTokenError(); + var NotBeforeError = require_NotBeforeError(); + var TokenExpiredError = require_TokenExpiredError(); + var decode = require_decode(); + var timespan = require_timespan(); + var validateAsymmetricKey = require_validateAsymmetricKey(); + var PS_SUPPORTED = require_psSupported(); + var jws = require_jws(); + var { KeyObject, createSecretKey, createPublicKey } = require("crypto"); + var PUB_KEY_ALGS = ["RS256", "RS384", "RS512"]; + var EC_KEY_ALGS = ["ES256", "ES384", "ES512"]; + var RSA_KEY_ALGS = ["RS256", "RS384", "RS512"]; + var HS_ALGS = ["HS256", "HS384", "HS512"]; + if (PS_SUPPORTED) { + PUB_KEY_ALGS.splice(PUB_KEY_ALGS.length, 0, "PS256", "PS384", "PS512"); + RSA_KEY_ALGS.splice(RSA_KEY_ALGS.length, 0, "PS256", "PS384", "PS512"); + } + module2.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(header2, secretCallback) { + return secretCallback(null, secretOrPublicKey); + }; + } + return getSecret(header, function(err, secretOrPublicKey2) { + if (err) { + return done(new JsonWebTokenError("error in secret or public key callback: " + err.message)); + } + const hasSignature = parts[2].trim() !== ""; + if (!hasSignature && secretOrPublicKey2) { + return done(new JsonWebTokenError("jwt signature is required")); + } + if (hasSignature && !secretOrPublicKey2) { + 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 (secretOrPublicKey2 != null && !(secretOrPublicKey2 instanceof KeyObject)) { + try { + secretOrPublicKey2 = createPublicKey(secretOrPublicKey2); + } catch (_) { + try { + secretOrPublicKey2 = createSecretKey(typeof secretOrPublicKey2 === "string" ? Buffer.from(secretOrPublicKey2) : secretOrPublicKey2); + } catch (_2) { + return done(new JsonWebTokenError("secretOrPublicKey is not valid key material")); + } + } + } + if (!options.algorithms) { + if (secretOrPublicKey2.type === "secret") { + options.algorithms = HS_ALGS; + } else if (["rsa", "rsa-pss"].includes(secretOrPublicKey2.asymmetricKeyType)) { + options.algorithms = RSA_KEY_ALGS; + } else if (secretOrPublicKey2.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") && secretOrPublicKey2.type !== "secret") { + return done(new JsonWebTokenError(`secretOrPublicKey must be a symmetric key when using ${header.alg}`)); + } else if (/^(?:RS|PS|ES)/.test(header.alg) && secretOrPublicKey2.type !== "public") { + return done(new JsonWebTokenError(`secretOrPublicKey must be an asymmetric key when using ${header.alg}`)); + } + if (!options.allowInvalidAsymmetricKeyTypes) { + try { + validateAsymmetricKey(header.alg, secretOrPublicKey2); + } catch (e) { + return done(e); + } + } + let valid; + try { + valid = jws.verify(jwtString, decodedToken.header.alg, secretOrPublicKey2); + } catch (e) { + return done(e); + } + if (!valid) { + 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", 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", new Date(payload.exp * 1e3))); + } + } + if (options.audience) { + const audiences = Array.isArray(options.audience) ? options.audience : [options.audience]; + const target = Array.isArray(payload.aud) ? payload.aud : [payload.aud]; + const match = target.some(function(targetAudience) { + return audiences.some(function(audience) { + return audience instanceof RegExp ? audience.test(targetAudience) : audience === targetAudience; + }); + }); + if (!match) { + return done(new JsonWebTokenError("jwt audience invalid. expected: " + audiences.join(" or "))); + } + } + if (options.issuer) { + const invalid_issuer = typeof options.issuer === "string" && payload.iss !== options.issuer || Array.isArray(options.issuer) && options.issuer.indexOf(payload.iss) === -1; + if (invalid_issuer) { + 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(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", new Date(maxAgeTimestamp * 1e3))); + } + } + if (options.complete === true) { + const signature = decodedToken.signature; + return done(null, { + header, + payload, + signature + }); + } + return done(null, payload); + }); + }; + } +}); + +// ../../../node_modules/.pnpm/lodash.includes@4.3.0/node_modules/lodash.includes/index.js +var require_lodash = __commonJS({ + "../../../node_modules/.pnpm/lodash.includes@4.3.0/node_modules/lodash.includes/index.js"(exports2, module2) { + var INFINITY = 1 / 0; + var MAX_SAFE_INTEGER = 9007199254740991; + var MAX_INTEGER = 17976931348623157e292; + var NAN = 0 / 0; + var argsTag = "[object Arguments]"; + var funcTag = "[object Function]"; + var genTag = "[object GeneratorFunction]"; + var stringTag = "[object String]"; + var symbolTag = "[object Symbol]"; + var reTrim = /^\s+|\s+$/g; + var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; + var reIsBinary = /^0b[01]+$/i; + var reIsOctal = /^0o[0-7]+$/i; + var reIsUint = /^(?:0|[1-9]\d*)$/; + var freeParseInt = parseInt; + function arrayMap(array, iteratee) { + var index2 = -1, length = array ? array.length : 0, result = Array(length); + while (++index2 < length) { + result[index2] = iteratee(array[index2], index2, array); + } + return result; + } + function baseFindIndex(array, predicate, fromIndex, fromRight) { + var length = array.length, index2 = fromIndex + (fromRight ? 1 : -1); + while (fromRight ? index2-- : ++index2 < length) { + if (predicate(array[index2], index2, array)) { + return index2; + } + } + return -1; + } + function baseIndexOf(array, value, fromIndex) { + if (value !== value) { + return baseFindIndex(array, baseIsNaN, fromIndex); + } + var index2 = fromIndex - 1, length = array.length; + while (++index2 < length) { + if (array[index2] === value) { + return index2; + } + } + return -1; + } + function baseIsNaN(value) { + return value !== value; + } + function baseTimes(n, iteratee) { + var index2 = -1, result = Array(n); + while (++index2 < n) { + result[index2] = iteratee(index2); + } + return result; + } + function baseValues(object, props) { + return arrayMap(props, function(key) { + return object[key]; + }); + } + function overArg(func, transform) { + return function(arg) { + return func(transform(arg)); + }; + } + var objectProto = Object.prototype; + var hasOwnProperty = objectProto.hasOwnProperty; + var objectToString = objectProto.toString; + var propertyIsEnumerable = objectProto.propertyIsEnumerable; + var nativeKeys = overArg(Object.keys, Object); + var nativeMax = Math.max; + function arrayLikeKeys(value, inherited) { + var result = isArray(value) || isArguments(value) ? baseTimes(value.length, String) : []; + var length = result.length, skipIndexes = !!length; + for (var key in value) { + if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && (key == "length" || isIndex(key, length)))) { + result.push(key); + } + } + return result; + } + function baseKeys(object) { + if (!isPrototype(object)) { + return nativeKeys(object); + } + var result = []; + for (var key in Object(object)) { + if (hasOwnProperty.call(object, key) && key != "constructor") { + result.push(key); + } + } + return result; + } + 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); + } + function isPrototype(value) { + var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto; + return value === proto; + } + function includes(collection, value, fromIndex, guard) { + collection = isArrayLike(collection) ? collection : values(collection); + fromIndex = fromIndex && !guard ? toInteger(fromIndex) : 0; + var length = collection.length; + if (fromIndex < 0) { + fromIndex = nativeMax(length + fromIndex, 0); + } + return isString(collection) ? fromIndex <= length && collection.indexOf(value, fromIndex) > -1 : !!length && baseIndexOf(collection, value, fromIndex) > -1; + } + function isArguments(value) { + return isArrayLikeObject(value) && hasOwnProperty.call(value, "callee") && (!propertyIsEnumerable.call(value, "callee") || objectToString.call(value) == argsTag); + } + var isArray = Array.isArray; + function isArrayLike(value) { + return value != null && isLength(value.length) && !isFunction2(value); + } + function isArrayLikeObject(value) { + return isObjectLike(value) && isArrayLike(value); + } + function isFunction2(value) { + var tag2 = isObject2(value) ? objectToString.call(value) : ""; + return tag2 == funcTag || tag2 == genTag; + } + function isLength(value) { + return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; + } + function isObject2(value) { + var type = typeof value; + return !!value && (type == "object" || type == "function"); + } + function isObjectLike(value) { + return !!value && typeof value == "object"; + } + function isString(value) { + return typeof value == "string" || !isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag; + } + function isSymbol(value) { + return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag; + } + function toFinite(value) { + if (!value) { + return value === 0 ? value : 0; + } + value = toNumber(value); + if (value === INFINITY || value === -INFINITY) { + var sign = value < 0 ? -1 : 1; + return sign * MAX_INTEGER; + } + return value === value ? value : 0; + } + function toInteger(value) { + var result = toFinite(value), remainder = result % 1; + return result === result ? remainder ? result - remainder : result : 0; + } + function toNumber(value) { + if (typeof value == "number") { + return value; + } + if (isSymbol(value)) { + return NAN; + } + if (isObject2(value)) { + var other = typeof value.valueOf == "function" ? value.valueOf() : value; + value = isObject2(other) ? other + "" : other; + } + if (typeof value != "string") { + return value === 0 ? value : +value; + } + value = value.replace(reTrim, ""); + var isBinary2 = reIsBinary.test(value); + return isBinary2 || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary2 ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value; + } + function keys(object) { + return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); + } + function values(object) { + return object ? baseValues(object, keys(object)) : []; + } + module2.exports = includes; + } +}); + +// ../../../node_modules/.pnpm/lodash.isboolean@3.0.3/node_modules/lodash.isboolean/index.js +var require_lodash2 = __commonJS({ + "../../../node_modules/.pnpm/lodash.isboolean@3.0.3/node_modules/lodash.isboolean/index.js"(exports2, module2) { + var boolTag = "[object Boolean]"; + var objectProto = Object.prototype; + var objectToString = objectProto.toString; + function isBoolean(value) { + return value === true || value === false || isObjectLike(value) && objectToString.call(value) == boolTag; + } + function isObjectLike(value) { + return !!value && typeof value == "object"; + } + module2.exports = isBoolean; + } +}); + +// ../../../node_modules/.pnpm/lodash.isinteger@4.0.4/node_modules/lodash.isinteger/index.js +var require_lodash3 = __commonJS({ + "../../../node_modules/.pnpm/lodash.isinteger@4.0.4/node_modules/lodash.isinteger/index.js"(exports2, module2) { + var INFINITY = 1 / 0; + var MAX_INTEGER = 17976931348623157e292; + var NAN = 0 / 0; + var symbolTag = "[object Symbol]"; + var reTrim = /^\s+|\s+$/g; + var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; + var reIsBinary = /^0b[01]+$/i; + var reIsOctal = /^0o[0-7]+$/i; + var freeParseInt = parseInt; + var objectProto = Object.prototype; + var objectToString = objectProto.toString; + function isInteger(value) { + return typeof value == "number" && value == toInteger(value); + } + function isObject2(value) { + var type = typeof value; + return !!value && (type == "object" || type == "function"); + } + function isObjectLike(value) { + return !!value && typeof value == "object"; + } + function isSymbol(value) { + return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag; + } + function toFinite(value) { + if (!value) { + return value === 0 ? value : 0; + } + value = toNumber(value); + if (value === INFINITY || value === -INFINITY) { + var sign = value < 0 ? -1 : 1; + return sign * MAX_INTEGER; + } + return value === value ? value : 0; + } + function toInteger(value) { + var result = toFinite(value), remainder = result % 1; + return result === result ? remainder ? result - remainder : result : 0; + } + function toNumber(value) { + if (typeof value == "number") { + return value; + } + if (isSymbol(value)) { + return NAN; + } + if (isObject2(value)) { + var other = typeof value.valueOf == "function" ? value.valueOf() : value; + value = isObject2(other) ? other + "" : other; + } + if (typeof value != "string") { + return value === 0 ? value : +value; + } + value = value.replace(reTrim, ""); + var isBinary2 = reIsBinary.test(value); + return isBinary2 || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary2 ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value; + } + module2.exports = isInteger; + } +}); + +// ../../../node_modules/.pnpm/lodash.isnumber@3.0.3/node_modules/lodash.isnumber/index.js +var require_lodash4 = __commonJS({ + "../../../node_modules/.pnpm/lodash.isnumber@3.0.3/node_modules/lodash.isnumber/index.js"(exports2, module2) { + var numberTag = "[object Number]"; + var objectProto = Object.prototype; + var objectToString = objectProto.toString; + function isObjectLike(value) { + return !!value && typeof value == "object"; + } + function isNumber(value) { + return typeof value == "number" || isObjectLike(value) && objectToString.call(value) == numberTag; + } + module2.exports = isNumber; + } +}); + +// ../../../node_modules/.pnpm/lodash.isplainobject@4.0.6/node_modules/lodash.isplainobject/index.js +var require_lodash5 = __commonJS({ + "../../../node_modules/.pnpm/lodash.isplainobject@4.0.6/node_modules/lodash.isplainobject/index.js"(exports2, module2) { + var objectTag = "[object Object]"; + function isHostObject(value) { + var result = false; + if (value != null && typeof value.toString != "function") { + try { + result = !!(value + ""); + } catch (e) { + } + } + return result; + } + function overArg(func, transform) { + return function(arg) { + return func(transform(arg)); + }; + } + var funcProto = Function.prototype; + var objectProto = Object.prototype; + var funcToString = funcProto.toString; + var hasOwnProperty = objectProto.hasOwnProperty; + var objectCtorString = funcToString.call(Object); + var objectToString = objectProto.toString; + var getPrototype = overArg(Object.getPrototypeOf, Object); + function isObjectLike(value) { + return !!value && typeof value == "object"; + } + function isPlainObject(value) { + if (!isObjectLike(value) || objectToString.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; + } + module2.exports = isPlainObject; + } +}); + +// ../../../node_modules/.pnpm/lodash.isstring@4.0.1/node_modules/lodash.isstring/index.js +var require_lodash6 = __commonJS({ + "../../../node_modules/.pnpm/lodash.isstring@4.0.1/node_modules/lodash.isstring/index.js"(exports2, module2) { + var stringTag = "[object String]"; + var objectProto = Object.prototype; + var objectToString = objectProto.toString; + var isArray = Array.isArray; + function isObjectLike(value) { + return !!value && typeof value == "object"; + } + function isString(value) { + return typeof value == "string" || !isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag; + } + module2.exports = isString; + } +}); + +// ../../../node_modules/.pnpm/lodash.once@4.1.1/node_modules/lodash.once/index.js +var require_lodash7 = __commonJS({ + "../../../node_modules/.pnpm/lodash.once@4.1.1/node_modules/lodash.once/index.js"(exports2, module2) { + var FUNC_ERROR_TEXT = "Expected a function"; + var INFINITY = 1 / 0; + var MAX_INTEGER = 17976931348623157e292; + var NAN = 0 / 0; + var symbolTag = "[object Symbol]"; + var reTrim = /^\s+|\s+$/g; + var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; + var reIsBinary = /^0b[01]+$/i; + var reIsOctal = /^0o[0-7]+$/i; + var freeParseInt = parseInt; + var objectProto = Object.prototype; + var objectToString = objectProto.toString; + 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; + }; + } + function once(func) { + return before(2, func); + } + function isObject2(value) { + var type = typeof value; + return !!value && (type == "object" || type == "function"); + } + function isObjectLike(value) { + return !!value && typeof value == "object"; + } + function isSymbol(value) { + return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag; + } + function toFinite(value) { + if (!value) { + return value === 0 ? value : 0; + } + value = toNumber(value); + if (value === INFINITY || value === -INFINITY) { + var sign = value < 0 ? -1 : 1; + return sign * MAX_INTEGER; + } + return value === value ? value : 0; + } + function toInteger(value) { + var result = toFinite(value), remainder = result % 1; + return result === result ? remainder ? result - remainder : result : 0; + } + function toNumber(value) { + if (typeof value == "number") { + return value; + } + if (isSymbol(value)) { + return NAN; + } + if (isObject2(value)) { + var other = typeof value.valueOf == "function" ? value.valueOf() : value; + value = isObject2(other) ? other + "" : other; + } + if (typeof value != "string") { + return value === 0 ? value : +value; + } + value = value.replace(reTrim, ""); + var isBinary2 = reIsBinary.test(value); + return isBinary2 || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary2 ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value; + } + module2.exports = once; + } +}); + +// ../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/sign.js +var require_sign = __commonJS({ + "../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/sign.js"(exports2, module2) { + var timespan = require_timespan(); + var PS_SUPPORTED = require_psSupported(); + var validateAsymmetricKey = require_validateAsymmetricKey(); + var jws = require_jws(); + var includes = require_lodash(); + var isBoolean = require_lodash2(); + var isInteger = require_lodash3(); + var isNumber = require_lodash4(); + var isPlainObject = require_lodash5(); + var isString = require_lodash6(); + var once = require_lodash7(); + var { KeyObject, createSecretKey, createPrivateKey } = require("crypto"); + var SUPPORTED_ALGS = ["RS256", "RS384", "RS512", "ES256", "ES384", "ES512", "HS256", "HS384", "HS512", "none"]; + if (PS_SUPPORTED) { + SUPPORTED_ALGS.splice(3, 0, "PS256", "PS384", "PS512"); + } + var 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' } + }; + var 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 validate2(schema2, allowUnknown, object, parameterName) { + if (!isPlainObject(object)) { + throw new Error('Expected "' + parameterName + '" to be a plain object.'); + } + Object.keys(object).forEach(function(key) { + const validator = schema2[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 validate2(sign_options_schema, false, options, "options"); + } + function validatePayload(payload) { + return validate2(registered_claims_schema, true, payload, "payload"); + } + var options_to_payload = { + "audience": "aud", + "issuer": "iss", + "subject": "sub", + "jwtid": "jti" + }; + var options_for_objects = [ + "expiresIn", + "notBefore", + "noTimestamp", + "audience", + "issuer", + "subject", + "jwtid" + ]; + module2.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(new Error("secretOrPrivateKey must have a value")); + } + if (secretOrPrivateKey != null && !(secretOrPrivateKey instanceof KeyObject)) { + try { + secretOrPrivateKey = createPrivateKey(secretOrPrivateKey); + } catch (_) { + try { + secretOrPrivateKey = createSecretKey(typeof secretOrPrivateKey === "string" ? Buffer.from(secretOrPrivateKey) : secretOrPrivateKey); + } catch (_2) { + return failure(new Error("secretOrPrivateKey is not valid key material")); + } + } + } + if (header.alg.startsWith("HS") && secretOrPrivateKey.type !== "secret") { + return failure(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(new Error(`secretOrPrivateKey must be an asymmetric key when using ${header.alg}`)); + } + if (!options.allowInsecureKeySizes && !header.alg.startsWith("ES") && secretOrPrivateKey.asymmetricKeyDetails !== void 0 && //KeyObject.asymmetricKeyDetails is supported in Node 15+ + secretOrPrivateKey.asymmetricKeyDetails.modulusLength < 2048) { + return failure(new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${header.alg}`)); + } + } + if (typeof payload === "undefined") { + return failure(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(new Error("invalid " + invalid_options.join(",") + " option for " + typeof payload + " payload")); + } + } + if (typeof payload.exp !== "undefined" && typeof options.expiresIn !== "undefined") { + return failure(new Error('Bad "options.expiresIn" option the payload already has an "exp" property.')); + } + if (typeof payload.nbf !== "undefined" && typeof options.notBefore !== "undefined") { + return failure(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(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(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(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(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; + } + }; + } +}); + +// ../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/index.js +var require_jsonwebtoken = __commonJS({ + "../../../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/index.js"(exports2, module2) { + module2.exports = { + decode: require_decode(), + verify: require_verify(), + sign: require_sign(), + JsonWebTokenError: require_JsonWebTokenError(), + NotBeforeError: require_NotBeforeError(), + TokenExpiredError: require_TokenExpiredError() + }; + } +}); + +// ../../../node_modules/.pnpm/universal-github-app-jwt@1.1.2/node_modules/universal-github-app-jwt/dist-node/index.js +var require_dist_node19 = __commonJS({ + "../../../node_modules/.pnpm/universal-github-app-jwt@1.1.2/node_modules/universal-github-app-jwt/dist-node/index.js"(exports2) { + "use strict"; + Object.defineProperty(exports2, "__esModule", { value: true }); + function _interopDefault(ex) { + return ex && typeof ex === "object" && "default" in ex ? ex["default"] : ex; + } + var jsonwebtoken = _interopDefault(require_jsonwebtoken()); + async function getToken({ + privateKey, + payload + }) { + return jsonwebtoken.sign(payload, privateKey, { + algorithm: "RS256" + }); + } + async function githubAppJwt({ + id, + privateKey, + now = Math.floor(Date.now() / 1e3) + }) { + const nowWithSafetyMargin = now - 30; + const expiration = nowWithSafetyMargin + 60 * 10; + const payload = { + iat: nowWithSafetyMargin, + exp: expiration, + iss: id + }; + const token = await getToken({ + privateKey, + payload + }); + return { + appId: id, + expiration, + token + }; + } + exports2.githubAppJwt = githubAppJwt; + } +}); + +// ../../../node_modules/.pnpm/lru-cache@10.2.0/node_modules/lru-cache/dist/commonjs/index.js +var require_commonjs = __commonJS({ + "../../../node_modules/.pnpm/lru-cache@10.2.0/node_modules/lru-cache/dist/commonjs/index.js"(exports2) { + "use strict"; + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.LRUCache = void 0; + var perf = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date; + var warned = /* @__PURE__ */ new Set(); + var PROCESS = typeof process === "object" && !!process ? process : {}; + var emitWarning = (msg, type, code, fn) => { + typeof PROCESS.emitWarning === "function" ? PROCESS.emitWarning(msg, type, code, fn) : console.error(`[${code}] ${type}: ${msg}`); + }; + var AC = globalThis.AbortController; + var AS = globalThis.AbortSignal; + if (typeof AC === "undefined") { + AS = class AbortSignal { + onabort; + _onabort = []; + reason; + aborted = false; + addEventListener(_, fn) { + this._onabort.push(fn); + } + }; + AC = class AbortController { + constructor() { + warnACPolyfill(); + } + signal = new AS(); + abort(reason) { + if (this.signal.aborted) + return; + this.signal.reason = reason; + this.signal.aborted = true; + for (const fn of this.signal._onabort) { + fn(reason); + } + this.signal.onabort?.(reason); + } + }; + let printACPolyfillWarning = PROCESS.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1"; + const warnACPolyfill = () => { + if (!printACPolyfillWarning) + return; + printACPolyfillWarning = false; + emitWarning("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", warnACPolyfill); + }; + } + var shouldWarn = (code) => !warned.has(code); + var TYPE = Symbol("type"); + var isPosInt = (n) => n && n === Math.floor(n) && n > 0 && isFinite(n); + var getUintArray = (max) => !isPosInt(max) ? null : max <= Math.pow(2, 8) ? Uint8Array : max <= Math.pow(2, 16) ? Uint16Array : max <= Math.pow(2, 32) ? Uint32Array : max <= Number.MAX_SAFE_INTEGER ? ZeroArray : null; + var ZeroArray = class extends Array { + constructor(size) { + super(size); + this.fill(0); + } + }; + var Stack = class _Stack { + heap; + length; + // private constructor + static #constructing = false; + static create(max) { + const HeapCls = getUintArray(max); + if (!HeapCls) + return []; + _Stack.#constructing = true; + const s = new _Stack(max, HeapCls); + _Stack.#constructing = false; + return s; + } + constructor(max, HeapCls) { + if (!_Stack.#constructing) { + throw new TypeError("instantiate Stack using Stack.create(n)"); + } + this.heap = new HeapCls(max); + this.length = 0; + } + push(n) { + this.heap[this.length++] = n; + } + pop() { + return this.heap[--this.length]; + } + }; + var LRUCache = class _LRUCache { + // properties coming in from the options of these, only max and maxSize + // really *need* to be protected. The rest can be modified, as they just + // set defaults for various methods. + #max; + #maxSize; + #dispose; + #disposeAfter; + #fetchMethod; + /** + * {@link LRUCache.OptionsBase.ttl} + */ + ttl; + /** + * {@link LRUCache.OptionsBase.ttlResolution} + */ + ttlResolution; + /** + * {@link LRUCache.OptionsBase.ttlAutopurge} + */ + ttlAutopurge; + /** + * {@link LRUCache.OptionsBase.updateAgeOnGet} + */ + updateAgeOnGet; + /** + * {@link LRUCache.OptionsBase.updateAgeOnHas} + */ + updateAgeOnHas; + /** + * {@link LRUCache.OptionsBase.allowStale} + */ + allowStale; + /** + * {@link LRUCache.OptionsBase.noDisposeOnSet} + */ + noDisposeOnSet; + /** + * {@link LRUCache.OptionsBase.noUpdateTTL} + */ + noUpdateTTL; + /** + * {@link LRUCache.OptionsBase.maxEntrySize} + */ + maxEntrySize; + /** + * {@link LRUCache.OptionsBase.sizeCalculation} + */ + sizeCalculation; + /** + * {@link LRUCache.OptionsBase.noDeleteOnFetchRejection} + */ + noDeleteOnFetchRejection; + /** + * {@link LRUCache.OptionsBase.noDeleteOnStaleGet} + */ + noDeleteOnStaleGet; + /** + * {@link LRUCache.OptionsBase.allowStaleOnFetchAbort} + */ + allowStaleOnFetchAbort; + /** + * {@link LRUCache.OptionsBase.allowStaleOnFetchRejection} + */ + allowStaleOnFetchRejection; + /** + * {@link LRUCache.OptionsBase.ignoreFetchAbort} + */ + ignoreFetchAbort; + // computed properties + #size; + #calculatedSize; + #keyMap; + #keyList; + #valList; + #next; + #prev; + #head; + #tail; + #free; + #disposed; + #sizes; + #starts; + #ttls; + #hasDispose; + #hasFetchMethod; + #hasDisposeAfter; + /** + * Do not call this method unless you need to inspect the + * inner workings of the cache. If anything returned by this + * object is modified in any way, strange breakage may occur. + * + * These fields are private for a reason! + * + * @internal + */ + static unsafeExposeInternals(c) { + return { + // properties + starts: c.#starts, + ttls: c.#ttls, + sizes: c.#sizes, + keyMap: c.#keyMap, + keyList: c.#keyList, + valList: c.#valList, + next: c.#next, + prev: c.#prev, + get head() { + return c.#head; + }, + get tail() { + return c.#tail; + }, + free: c.#free, + // methods + isBackgroundFetch: (p) => c.#isBackgroundFetch(p), + backgroundFetch: (k, index2, options, context2) => c.#backgroundFetch(k, index2, options, context2), + moveToTail: (index2) => c.#moveToTail(index2), + indexes: (options) => c.#indexes(options), + rindexes: (options) => c.#rindexes(options), + isStale: (index2) => c.#isStale(index2) + }; + } + // Protected read-only members + /** + * {@link LRUCache.OptionsBase.max} (read-only) + */ + get max() { + return this.#max; + } + /** + * {@link LRUCache.OptionsBase.maxSize} (read-only) + */ + get maxSize() { + return this.#maxSize; + } + /** + * The total computed size of items in the cache (read-only) + */ + get calculatedSize() { + return this.#calculatedSize; + } + /** + * The number of items stored in the cache (read-only) + */ + get size() { + return this.#size; + } + /** + * {@link LRUCache.OptionsBase.fetchMethod} (read-only) + */ + get fetchMethod() { + return this.#fetchMethod; + } + /** + * {@link LRUCache.OptionsBase.dispose} (read-only) + */ + get dispose() { + return this.#dispose; + } + /** + * {@link LRUCache.OptionsBase.disposeAfter} (read-only) + */ + get disposeAfter() { + return this.#disposeAfter; + } + constructor(options) { + const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort } = options; + if (max !== 0 && !isPosInt(max)) { + throw new TypeError("max option must be a nonnegative integer"); + } + const UintArray = max ? getUintArray(max) : Array; + if (!UintArray) { + throw new Error("invalid max value: " + max); + } + this.#max = max; + this.#maxSize = maxSize; + this.maxEntrySize = maxEntrySize || this.#maxSize; + this.sizeCalculation = sizeCalculation; + if (this.sizeCalculation) { + if (!this.#maxSize && !this.maxEntrySize) { + throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize"); + } + if (typeof this.sizeCalculation !== "function") { + throw new TypeError("sizeCalculation set to non-function"); + } + } + if (fetchMethod !== void 0 && typeof fetchMethod !== "function") { + throw new TypeError("fetchMethod must be a function if specified"); + } + this.#fetchMethod = fetchMethod; + this.#hasFetchMethod = !!fetchMethod; + this.#keyMap = /* @__PURE__ */ new Map(); + this.#keyList = new Array(max).fill(void 0); + this.#valList = new Array(max).fill(void 0); + this.#next = new UintArray(max); + this.#prev = new UintArray(max); + this.#head = 0; + this.#tail = 0; + this.#free = Stack.create(max); + this.#size = 0; + this.#calculatedSize = 0; + if (typeof dispose === "function") { + this.#dispose = dispose; + } + if (typeof disposeAfter === "function") { + this.#disposeAfter = disposeAfter; + this.#disposed = []; + } else { + this.#disposeAfter = void 0; + this.#disposed = void 0; + } + this.#hasDispose = !!this.#dispose; + this.#hasDisposeAfter = !!this.#disposeAfter; + this.noDisposeOnSet = !!noDisposeOnSet; + this.noUpdateTTL = !!noUpdateTTL; + this.noDeleteOnFetchRejection = !!noDeleteOnFetchRejection; + this.allowStaleOnFetchRejection = !!allowStaleOnFetchRejection; + this.allowStaleOnFetchAbort = !!allowStaleOnFetchAbort; + this.ignoreFetchAbort = !!ignoreFetchAbort; + if (this.maxEntrySize !== 0) { + if (this.#maxSize !== 0) { + if (!isPosInt(this.#maxSize)) { + throw new TypeError("maxSize must be a positive integer if specified"); + } + } + if (!isPosInt(this.maxEntrySize)) { + throw new TypeError("maxEntrySize must be a positive integer if specified"); + } + this.#initializeSizeTracking(); + } + this.allowStale = !!allowStale; + this.noDeleteOnStaleGet = !!noDeleteOnStaleGet; + this.updateAgeOnGet = !!updateAgeOnGet; + this.updateAgeOnHas = !!updateAgeOnHas; + this.ttlResolution = isPosInt(ttlResolution) || ttlResolution === 0 ? ttlResolution : 1; + this.ttlAutopurge = !!ttlAutopurge; + this.ttl = ttl || 0; + if (this.ttl) { + if (!isPosInt(this.ttl)) { + throw new TypeError("ttl must be a positive integer if specified"); + } + this.#initializeTTLTracking(); + } + if (this.#max === 0 && this.ttl === 0 && this.#maxSize === 0) { + throw new TypeError("At least one of max, maxSize, or ttl is required"); + } + if (!this.ttlAutopurge && !this.#max && !this.#maxSize) { + const code = "LRU_CACHE_UNBOUNDED"; + if (shouldWarn(code)) { + warned.add(code); + const msg = "TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption."; + emitWarning(msg, "UnboundedCacheWarning", code, _LRUCache); + } + } + } + /** + * Return the remaining TTL time for a given entry key + */ + getRemainingTTL(key) { + return this.#keyMap.has(key) ? Infinity : 0; + } + #initializeTTLTracking() { + const ttls = new ZeroArray(this.#max); + const starts = new ZeroArray(this.#max); + this.#ttls = ttls; + this.#starts = starts; + this.#setItemTTL = (index2, ttl, start = perf.now()) => { + starts[index2] = ttl !== 0 ? start : 0; + ttls[index2] = ttl; + if (ttl !== 0 && this.ttlAutopurge) { + const t = setTimeout(() => { + if (this.#isStale(index2)) { + this.delete(this.#keyList[index2]); } - if (here_op & 64) { - strm.msg = "invalid literal/length code"; - state.mode = BAD; - break; + }, ttl + 1); + if (t.unref) { + t.unref(); + } + } + }; + this.#updateItemAge = (index2) => { + starts[index2] = ttls[index2] !== 0 ? perf.now() : 0; + }; + this.#statusTTL = (status3, index2) => { + if (ttls[index2]) { + const ttl = ttls[index2]; + const start = starts[index2]; + if (!ttl || !start) + return; + status3.ttl = ttl; + status3.start = start; + status3.now = cachedNow || getNow(); + const age = status3.now - start; + status3.remainingTTL = ttl - age; + } + }; + let cachedNow = 0; + const getNow = () => { + const n = perf.now(); + if (this.ttlResolution > 0) { + cachedNow = n; + const t = setTimeout(() => cachedNow = 0, this.ttlResolution); + if (t.unref) { + t.unref(); + } + } + return n; + }; + this.getRemainingTTL = (key) => { + const index2 = this.#keyMap.get(key); + if (index2 === void 0) { + return 0; + } + const ttl = ttls[index2]; + const start = starts[index2]; + if (!ttl || !start) { + return Infinity; + } + const age = (cachedNow || getNow()) - start; + return ttl - age; + }; + this.#isStale = (index2) => { + const s = starts[index2]; + const t = ttls[index2]; + return !!t && !!s && (cachedNow || getNow()) - s > t; + }; + } + // conditionally set private methods related to TTL + #updateItemAge = () => { + }; + #statusTTL = () => { + }; + #setItemTTL = () => { + }; + /* c8 ignore stop */ + #isStale = () => false; + #initializeSizeTracking() { + const sizes = new ZeroArray(this.#max); + this.#calculatedSize = 0; + this.#sizes = sizes; + this.#removeItemSize = (index2) => { + this.#calculatedSize -= sizes[index2]; + sizes[index2] = 0; + }; + this.#requireSize = (k, v, size, sizeCalculation) => { + if (this.#isBackgroundFetch(v)) { + return 0; + } + if (!isPosInt(size)) { + if (sizeCalculation) { + if (typeof sizeCalculation !== "function") { + throw new TypeError("sizeCalculation must be a function"); } - state.extra = here_op & 15; - state.mode = LENEXT; - case LENEXT: - if (state.extra) { - n = state.extra; - while (bits < n) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - state.length += hold & (1 << state.extra) - 1; - hold >>>= state.extra; - bits -= state.extra; - state.back += state.extra; + size = sizeCalculation(v, k); + if (!isPosInt(size)) { + throw new TypeError("sizeCalculation return invalid (expect positive integer)"); } - state.was = state.length; - state.mode = DIST; - case DIST: - for (; ; ) { - here = state.distcode[hold & (1 << state.distbits) - 1]; - here_bits = here >>> 24; - here_op = here >>> 16 & 255; - here_val = here & 65535; - if (here_bits <= bits) { - break; - } - if (have === 0) { - break inf_leave; + } else { + throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set."); + } + } + return size; + }; + this.#addItemSize = (index2, size, status3) => { + sizes[index2] = size; + if (this.#maxSize) { + const maxSize = this.#maxSize - sizes[index2]; + while (this.#calculatedSize > maxSize) { + this.#evict(true); + } + } + this.#calculatedSize += sizes[index2]; + if (status3) { + status3.entrySize = size; + status3.totalCalculatedSize = this.#calculatedSize; + } + }; + } + #removeItemSize = (_i) => { + }; + #addItemSize = (_i, _s, _st) => { + }; + #requireSize = (_k, _v, size, sizeCalculation) => { + if (size || sizeCalculation) { + throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache"); + } + return 0; + }; + *#indexes({ allowStale = this.allowStale } = {}) { + if (this.#size) { + for (let i = this.#tail; true; ) { + if (!this.#isValidIndex(i)) { + break; + } + if (allowStale || !this.#isStale(i)) { + yield i; + } + if (i === this.#head) { + break; + } else { + i = this.#prev[i]; + } + } + } + } + *#rindexes({ allowStale = this.allowStale } = {}) { + if (this.#size) { + for (let i = this.#head; true; ) { + if (!this.#isValidIndex(i)) { + break; + } + if (allowStale || !this.#isStale(i)) { + yield i; + } + if (i === this.#tail) { + break; + } else { + i = this.#next[i]; + } + } + } + } + #isValidIndex(index2) { + return index2 !== void 0 && this.#keyMap.get(this.#keyList[index2]) === index2; + } + /** + * Return a generator yielding `[key, value]` pairs, + * in order from most recently used to least recently used. + */ + *entries() { + for (const i of this.#indexes()) { + if (this.#valList[i] !== void 0 && this.#keyList[i] !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) { + yield [this.#keyList[i], this.#valList[i]]; + } + } + } + /** + * Inverse order version of {@link LRUCache.entries} + * + * Return a generator yielding `[key, value]` pairs, + * in order from least recently used to most recently used. + */ + *rentries() { + for (const i of this.#rindexes()) { + if (this.#valList[i] !== void 0 && this.#keyList[i] !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) { + yield [this.#keyList[i], this.#valList[i]]; + } + } + } + /** + * Return a generator yielding the keys in the cache, + * in order from most recently used to least recently used. + */ + *keys() { + for (const i of this.#indexes()) { + const k = this.#keyList[i]; + if (k !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) { + yield k; + } + } + } + /** + * Inverse order version of {@link LRUCache.keys} + * + * Return a generator yielding the keys in the cache, + * in order from least recently used to most recently used. + */ + *rkeys() { + for (const i of this.#rindexes()) { + const k = this.#keyList[i]; + if (k !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) { + yield k; + } + } + } + /** + * Return a generator yielding the values in the cache, + * in order from most recently used to least recently used. + */ + *values() { + for (const i of this.#indexes()) { + const v = this.#valList[i]; + if (v !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) { + yield this.#valList[i]; + } + } + } + /** + * Inverse order version of {@link LRUCache.values} + * + * Return a generator yielding the values in the cache, + * in order from least recently used to most recently used. + */ + *rvalues() { + for (const i of this.#rindexes()) { + const v = this.#valList[i]; + if (v !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) { + yield this.#valList[i]; + } + } + } + /** + * Iterating over the cache itself yields the same results as + * {@link LRUCache.entries} + */ + [Symbol.iterator]() { + return this.entries(); + } + /** + * A String value that is used in the creation of the default string description of an object. + * Called by the built-in method Object.prototype.toString. + */ + [Symbol.toStringTag] = "LRUCache"; + /** + * Find a value for which the supplied fn method returns a truthy value, + * similar to Array.find(). fn is called as fn(value, key, cache). + */ + find(fn, getOptions = {}) { + for (const i of this.#indexes()) { + const v = this.#valList[i]; + const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v; + if (value === void 0) + continue; + if (fn(value, this.#keyList[i], this)) { + return this.get(this.#keyList[i], getOptions); + } + } + } + /** + * Call the supplied function on each item in the cache, in order from + * most recently used to least recently used. fn is called as + * fn(value, key, cache). Does not update age or recenty of use. + * Does not iterate over stale values. + */ + forEach(fn, thisp = this) { + for (const i of this.#indexes()) { + const v = this.#valList[i]; + const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v; + if (value === void 0) + continue; + fn.call(thisp, value, this.#keyList[i], this); + } + } + /** + * The same as {@link LRUCache.forEach} but items are iterated over in + * reverse order. (ie, less recently used items are iterated over first.) + */ + rforEach(fn, thisp = this) { + for (const i of this.#rindexes()) { + const v = this.#valList[i]; + const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v; + if (value === void 0) + continue; + fn.call(thisp, value, this.#keyList[i], this); + } + } + /** + * Delete any stale entries. Returns true if anything was removed, + * false otherwise. + */ + purgeStale() { + let deleted = false; + for (const i of this.#rindexes({ allowStale: true })) { + if (this.#isStale(i)) { + this.delete(this.#keyList[i]); + deleted = true; + } + } + return deleted; + } + /** + * Get the extended info about a given entry, to get its value, size, and + * TTL info simultaneously. Like {@link LRUCache#dump}, but just for a + * single key. Always returns stale values, if their info is found in the + * cache, so be sure to check for expired TTLs if relevant. + */ + info(key) { + const i = this.#keyMap.get(key); + if (i === void 0) + return void 0; + const v = this.#valList[i]; + const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v; + if (value === void 0) + return void 0; + const entry = { value }; + if (this.#ttls && this.#starts) { + const ttl = this.#ttls[i]; + const start = this.#starts[i]; + if (ttl && start) { + const remain = ttl - (perf.now() - start); + entry.ttl = remain; + entry.start = Date.now(); + } + } + if (this.#sizes) { + entry.size = this.#sizes[i]; + } + return entry; + } + /** + * Return an array of [key, {@link LRUCache.Entry}] tuples which can be + * passed to cache.load() + */ + dump() { + const arr = []; + for (const i of this.#indexes({ allowStale: true })) { + const key = this.#keyList[i]; + const v = this.#valList[i]; + const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v; + if (value === void 0 || key === void 0) + continue; + const entry = { value }; + if (this.#ttls && this.#starts) { + entry.ttl = this.#ttls[i]; + const age = perf.now() - this.#starts[i]; + entry.start = Math.floor(Date.now() - age); + } + if (this.#sizes) { + entry.size = this.#sizes[i]; + } + arr.unshift([key, entry]); + } + return arr; + } + /** + * Reset the cache and load in the items in entries in the order listed. + * Note that the shape of the resulting cache may be different if the + * same options are not used in both caches. + */ + load(arr) { + this.clear(); + for (const [key, entry] of arr) { + if (entry.start) { + const age = Date.now() - entry.start; + entry.start = perf.now() - age; + } + this.set(key, entry.value, entry); + } + } + /** + * Add a value to the cache. + * + * Note: if `undefined` is specified as a value, this is an alias for + * {@link LRUCache#delete} + */ + set(k, v, setOptions = {}) { + if (v === void 0) { + this.delete(k); + return this; + } + const { ttl = this.ttl, start, noDisposeOnSet = this.noDisposeOnSet, sizeCalculation = this.sizeCalculation, status: status3 } = setOptions; + let { noUpdateTTL = this.noUpdateTTL } = setOptions; + const size = this.#requireSize(k, v, setOptions.size || 0, sizeCalculation); + if (this.maxEntrySize && size > this.maxEntrySize) { + if (status3) { + status3.set = "miss"; + status3.maxEntrySizeExceeded = true; + } + this.delete(k); + return this; + } + let index2 = this.#size === 0 ? void 0 : this.#keyMap.get(k); + if (index2 === void 0) { + index2 = this.#size === 0 ? this.#tail : this.#free.length !== 0 ? this.#free.pop() : this.#size === this.#max ? this.#evict(false) : this.#size; + this.#keyList[index2] = k; + this.#valList[index2] = v; + this.#keyMap.set(k, index2); + this.#next[this.#tail] = index2; + this.#prev[index2] = this.#tail; + this.#tail = index2; + this.#size++; + this.#addItemSize(index2, size, status3); + if (status3) + status3.set = "add"; + noUpdateTTL = false; + } else { + this.#moveToTail(index2); + const oldVal = this.#valList[index2]; + if (v !== oldVal) { + if (this.#hasFetchMethod && this.#isBackgroundFetch(oldVal)) { + oldVal.__abortController.abort(new Error("replaced")); + const { __staleWhileFetching: s } = oldVal; + if (s !== void 0 && !noDisposeOnSet) { + if (this.#hasDispose) { + this.#dispose?.(s, k, "set"); } - have--; - hold += input[next++] << bits; - bits += 8; - } - if ((here_op & 240) === 0) { - last_bits = here_bits; - last_op = here_op; - last_val = here_val; - for (; ; ) { - here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)]; - here_bits = here >>> 24; - here_op = here >>> 16 & 255; - here_val = here & 65535; - if (last_bits + here_bits <= bits) { - break; - } - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; + if (this.#hasDisposeAfter) { + this.#disposed?.push([s, k, "set"]); } - hold >>>= last_bits; - bits -= last_bits; - state.back += last_bits; - } - hold >>>= here_bits; - bits -= here_bits; - state.back += here_bits; - if (here_op & 64) { - strm.msg = "invalid distance code"; - state.mode = BAD; - break; } - state.offset = here_val; - state.extra = here_op & 15; - state.mode = DISTEXT; - case DISTEXT: - if (state.extra) { - n = state.extra; - while (bits < n) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - state.offset += hold & (1 << state.extra) - 1; - hold >>>= state.extra; - bits -= state.extra; - state.back += state.extra; + } else if (!noDisposeOnSet) { + if (this.#hasDispose) { + this.#dispose?.(oldVal, k, "set"); } - if (state.offset > state.dmax) { - strm.msg = "invalid distance too far back"; - state.mode = BAD; - break; + if (this.#hasDisposeAfter) { + this.#disposed?.push([oldVal, k, "set"]); } - state.mode = MATCH; - case MATCH: - if (left === 0) { - break inf_leave; + } + this.#removeItemSize(index2); + this.#addItemSize(index2, size, status3); + this.#valList[index2] = v; + if (status3) { + status3.set = "replace"; + const oldValue = oldVal && this.#isBackgroundFetch(oldVal) ? oldVal.__staleWhileFetching : oldVal; + if (oldValue !== void 0) + status3.oldValue = oldValue; + } + } else if (status3) { + status3.set = "update"; + } + } + if (ttl !== 0 && !this.#ttls) { + this.#initializeTTLTracking(); + } + if (this.#ttls) { + if (!noUpdateTTL) { + this.#setItemTTL(index2, ttl, start); + } + if (status3) + this.#statusTTL(status3, index2); + } + if (!noDisposeOnSet && this.#hasDisposeAfter && this.#disposed) { + const dt = this.#disposed; + let task; + while (task = dt?.shift()) { + this.#disposeAfter?.(...task); + } + } + return this; + } + /** + * Evict the least recently used item, returning its value or + * `undefined` if cache is empty. + */ + pop() { + try { + while (this.#size) { + const val = this.#valList[this.#head]; + this.#evict(true); + if (this.#isBackgroundFetch(val)) { + if (val.__staleWhileFetching) { + return val.__staleWhileFetching; } - copy = _out - left; - if (state.offset > copy) { - copy = state.offset - copy; - if (copy > state.whave) { - if (state.sane) { - strm.msg = "invalid distance too far back"; - state.mode = BAD; - break; - } - } - if (copy > state.wnext) { - copy -= state.wnext; - from3 = state.wsize - copy; - } else { - from3 = state.wnext - copy; - } - if (copy > state.length) { - copy = state.length; - } - from_source = state.window; + } else if (val !== void 0) { + return val; + } + } + } finally { + if (this.#hasDisposeAfter && this.#disposed) { + const dt = this.#disposed; + let task; + while (task = dt?.shift()) { + this.#disposeAfter?.(...task); + } + } + } + } + #evict(free) { + const head = this.#head; + const k = this.#keyList[head]; + const v = this.#valList[head]; + if (this.#hasFetchMethod && this.#isBackgroundFetch(v)) { + v.__abortController.abort(new Error("evicted")); + } else if (this.#hasDispose || this.#hasDisposeAfter) { + if (this.#hasDispose) { + this.#dispose?.(v, k, "evict"); + } + if (this.#hasDisposeAfter) { + this.#disposed?.push([v, k, "evict"]); + } + } + this.#removeItemSize(head); + if (free) { + this.#keyList[head] = void 0; + this.#valList[head] = void 0; + this.#free.push(head); + } + if (this.#size === 1) { + this.#head = this.#tail = 0; + this.#free.length = 0; + } else { + this.#head = this.#next[head]; + } + this.#keyMap.delete(k); + this.#size--; + return head; + } + /** + * Check if a key is in the cache, without updating the recency of use. + * Will return false if the item is stale, even though it is technically + * in the cache. + * + * Will not update item age unless + * {@link LRUCache.OptionsBase.updateAgeOnHas} is set. + */ + has(k, hasOptions = {}) { + const { updateAgeOnHas = this.updateAgeOnHas, status: status3 } = hasOptions; + const index2 = this.#keyMap.get(k); + if (index2 !== void 0) { + const v = this.#valList[index2]; + if (this.#isBackgroundFetch(v) && v.__staleWhileFetching === void 0) { + return false; + } + if (!this.#isStale(index2)) { + if (updateAgeOnHas) { + this.#updateItemAge(index2); + } + if (status3) { + status3.has = "hit"; + this.#statusTTL(status3, index2); + } + return true; + } else if (status3) { + status3.has = "stale"; + this.#statusTTL(status3, index2); + } + } else if (status3) { + status3.has = "miss"; + } + return false; + } + /** + * Like {@link LRUCache#get} but doesn't update recency or delete stale + * items. + * + * Returns `undefined` if the item is stale, unless + * {@link LRUCache.OptionsBase.allowStale} is set. + */ + peek(k, peekOptions = {}) { + const { allowStale = this.allowStale } = peekOptions; + const index2 = this.#keyMap.get(k); + if (index2 === void 0 || !allowStale && this.#isStale(index2)) { + return; + } + const v = this.#valList[index2]; + return this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v; + } + #backgroundFetch(k, index2, options, context2) { + const v = index2 === void 0 ? void 0 : this.#valList[index2]; + if (this.#isBackgroundFetch(v)) { + return v; + } + const ac = new AC(); + const { signal } = options; + signal?.addEventListener("abort", () => ac.abort(signal.reason), { + signal: ac.signal + }); + const fetchOpts = { + signal: ac.signal, + options, + context: context2 + }; + const cb = (v2, updateCache = false) => { + const { aborted } = ac.signal; + const ignoreAbort = options.ignoreFetchAbort && v2 !== void 0; + if (options.status) { + if (aborted && !updateCache) { + options.status.fetchAborted = true; + options.status.fetchError = ac.signal.reason; + if (ignoreAbort) + options.status.fetchAbortIgnored = true; + } else { + options.status.fetchResolved = true; + } + } + if (aborted && !ignoreAbort && !updateCache) { + return fetchFail(ac.signal.reason); + } + const bf2 = p; + if (this.#valList[index2] === p) { + if (v2 === void 0) { + if (bf2.__staleWhileFetching) { + this.#valList[index2] = bf2.__staleWhileFetching; } else { - from_source = output; - from3 = put - state.offset; - copy = state.length; - } - if (copy > left) { - copy = left; + this.delete(k); } - left -= copy; - state.length -= copy; - do { - output[put++] = from_source[from3++]; - } while (--copy); - if (state.length === 0) { - state.mode = LEN; + } else { + if (options.status) + options.status.fetchUpdated = true; + this.set(k, v2, fetchOpts.options); + } + } + return v2; + }; + const eb = (er) => { + if (options.status) { + options.status.fetchRejected = true; + options.status.fetchError = er; + } + return fetchFail(er); + }; + const fetchFail = (er) => { + const { aborted } = ac.signal; + const allowStaleAborted = aborted && options.allowStaleOnFetchAbort; + const allowStale = allowStaleAborted || options.allowStaleOnFetchRejection; + const noDelete = allowStale || options.noDeleteOnFetchRejection; + const bf2 = p; + if (this.#valList[index2] === p) { + const del = !noDelete || bf2.__staleWhileFetching === void 0; + if (del) { + this.delete(k); + } else if (!allowStaleAborted) { + this.#valList[index2] = bf2.__staleWhileFetching; + } + } + if (allowStale) { + if (options.status && bf2.__staleWhileFetching !== void 0) { + options.status.returnedStale = true; + } + return bf2.__staleWhileFetching; + } else if (bf2.__returned === bf2) { + throw er; + } + }; + const pcall = (res, rej) => { + const fmp = this.#fetchMethod?.(k, v, fetchOpts); + if (fmp && fmp instanceof Promise) { + fmp.then((v2) => res(v2 === void 0 ? void 0 : v2), rej); + } + ac.signal.addEventListener("abort", () => { + if (!options.ignoreFetchAbort || options.allowStaleOnFetchAbort) { + res(void 0); + if (options.allowStaleOnFetchAbort) { + res = (v2) => cb(v2, true); } - break; - case LIT: - if (left === 0) { - break inf_leave; + } + }); + }; + if (options.status) + options.status.fetchDispatched = true; + const p = new Promise(pcall).then(cb, eb); + const bf = Object.assign(p, { + __abortController: ac, + __staleWhileFetching: v, + __returned: void 0 + }); + if (index2 === void 0) { + this.set(k, bf, { ...fetchOpts.options, status: void 0 }); + index2 = this.#keyMap.get(k); + } else { + this.#valList[index2] = bf; + } + return bf; + } + #isBackgroundFetch(p) { + if (!this.#hasFetchMethod) + return false; + const b = p; + return !!b && b instanceof Promise && b.hasOwnProperty("__staleWhileFetching") && b.__abortController instanceof AC; + } + async fetch(k, fetchOptions = {}) { + const { + // get options + allowStale = this.allowStale, + updateAgeOnGet = this.updateAgeOnGet, + noDeleteOnStaleGet = this.noDeleteOnStaleGet, + // set options + ttl = this.ttl, + noDisposeOnSet = this.noDisposeOnSet, + size = 0, + sizeCalculation = this.sizeCalculation, + noUpdateTTL = this.noUpdateTTL, + // fetch exclusive options + noDeleteOnFetchRejection = this.noDeleteOnFetchRejection, + allowStaleOnFetchRejection = this.allowStaleOnFetchRejection, + ignoreFetchAbort = this.ignoreFetchAbort, + allowStaleOnFetchAbort = this.allowStaleOnFetchAbort, + context: context2, + forceRefresh = false, + status: status3, + signal + } = fetchOptions; + if (!this.#hasFetchMethod) { + if (status3) + status3.fetch = "get"; + return this.get(k, { + allowStale, + updateAgeOnGet, + noDeleteOnStaleGet, + status: status3 + }); + } + const options = { + allowStale, + updateAgeOnGet, + noDeleteOnStaleGet, + ttl, + noDisposeOnSet, + size, + sizeCalculation, + noUpdateTTL, + noDeleteOnFetchRejection, + allowStaleOnFetchRejection, + allowStaleOnFetchAbort, + ignoreFetchAbort, + status: status3, + signal + }; + let index2 = this.#keyMap.get(k); + if (index2 === void 0) { + if (status3) + status3.fetch = "miss"; + const p = this.#backgroundFetch(k, index2, options, context2); + return p.__returned = p; + } else { + const v = this.#valList[index2]; + if (this.#isBackgroundFetch(v)) { + const stale = allowStale && v.__staleWhileFetching !== void 0; + if (status3) { + status3.fetch = "inflight"; + if (stale) + status3.returnedStale = true; + } + return stale ? v.__staleWhileFetching : v.__returned = v; + } + const isStale = this.#isStale(index2); + if (!forceRefresh && !isStale) { + if (status3) + status3.fetch = "hit"; + this.#moveToTail(index2); + if (updateAgeOnGet) { + this.#updateItemAge(index2); + } + if (status3) + this.#statusTTL(status3, index2); + return v; + } + const p = this.#backgroundFetch(k, index2, options, context2); + const hasStale = p.__staleWhileFetching !== void 0; + const staleVal = hasStale && allowStale; + if (status3) { + status3.fetch = isStale ? "stale" : "refresh"; + if (staleVal && isStale) + status3.returnedStale = true; + } + return staleVal ? p.__staleWhileFetching : p.__returned = p; + } + } + /** + * Return a value from the cache. Will update the recency of the cache + * entry found. + * + * If the key is not found, get() will return `undefined`. + */ + get(k, getOptions = {}) { + const { allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet, status: status3 } = getOptions; + const index2 = this.#keyMap.get(k); + if (index2 !== void 0) { + const value = this.#valList[index2]; + const fetching = this.#isBackgroundFetch(value); + if (status3) + this.#statusTTL(status3, index2); + if (this.#isStale(index2)) { + if (status3) + status3.get = "stale"; + if (!fetching) { + if (!noDeleteOnStaleGet) { + this.delete(k); } - output[put++] = state.length; - left--; - state.mode = LEN; - break; - case CHECK: - if (state.wrap) { - while (bits < 32) { - if (have === 0) { - break inf_leave; - } - have--; - hold |= input[next++] << bits; - bits += 8; - } - _out -= left; - strm.total_out += _out; - state.total += _out; - if (_out) { - strm.adler = state.check = /*UPDATE(state.check, put - _out, _out);*/ - state.flags ? crc322(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out); - } - _out = left; - if ((state.flags ? hold : zswap32(hold)) !== state.check) { - strm.msg = "incorrect data check"; - state.mode = BAD; - break; - } - hold = 0; - bits = 0; + if (status3 && allowStale) + status3.returnedStale = true; + return allowStale ? value : void 0; + } else { + if (status3 && allowStale && value.__staleWhileFetching !== void 0) { + status3.returnedStale = true; } - state.mode = LENGTH; - case LENGTH: - if (state.wrap && state.flags) { - while (bits < 32) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; + return allowStale ? value.__staleWhileFetching : void 0; + } + } else { + if (status3) + status3.get = "hit"; + if (fetching) { + return value.__staleWhileFetching; + } + this.#moveToTail(index2); + if (updateAgeOnGet) { + this.#updateItemAge(index2); + } + return value; + } + } else if (status3) { + status3.get = "miss"; + } + } + #connect(p, n) { + this.#prev[n] = p; + this.#next[p] = n; + } + #moveToTail(index2) { + if (index2 !== this.#tail) { + if (index2 === this.#head) { + this.#head = this.#next[index2]; + } else { + this.#connect(this.#prev[index2], this.#next[index2]); + } + this.#connect(this.#tail, index2); + this.#tail = index2; + } + } + /** + * Deletes a key out of the cache. + * Returns true if the key was deleted, false otherwise. + */ + delete(k) { + let deleted = false; + if (this.#size !== 0) { + const index2 = this.#keyMap.get(k); + if (index2 !== void 0) { + deleted = true; + if (this.#size === 1) { + this.clear(); + } else { + this.#removeItemSize(index2); + const v = this.#valList[index2]; + if (this.#isBackgroundFetch(v)) { + v.__abortController.abort(new Error("deleted")); + } else if (this.#hasDispose || this.#hasDisposeAfter) { + if (this.#hasDispose) { + this.#dispose?.(v, k, "delete"); } - if (hold !== (state.total & 4294967295)) { - strm.msg = "incorrect length check"; - state.mode = BAD; - break; + if (this.#hasDisposeAfter) { + this.#disposed?.push([v, k, "delete"]); } - hold = 0; - bits = 0; } - state.mode = DONE; - case DONE: - ret = Z_STREAM_END; - break inf_leave; - case BAD: - ret = Z_DATA_ERROR; - break inf_leave; - case MEM: - return Z_MEM_ERROR; - case SYNC: - default: - return Z_STREAM_ERROR; + this.#keyMap.delete(k); + this.#keyList[index2] = void 0; + this.#valList[index2] = void 0; + if (index2 === this.#tail) { + this.#tail = this.#prev[index2]; + } else if (index2 === this.#head) { + this.#head = this.#next[index2]; + } else { + const pi = this.#prev[index2]; + this.#next[pi] = this.#next[index2]; + const ni = this.#next[index2]; + this.#prev[ni] = this.#prev[index2]; + } + this.#size--; + this.#free.push(index2); + } + } + } + if (this.#hasDisposeAfter && this.#disposed?.length) { + const dt = this.#disposed; + let task; + while (task = dt?.shift()) { + this.#disposeAfter?.(...task); + } + } + return deleted; + } + /** + * Clear the cache entirely, throwing away all values. + */ + clear() { + for (const index2 of this.#rindexes({ allowStale: true })) { + const v = this.#valList[index2]; + if (this.#isBackgroundFetch(v)) { + v.__abortController.abort(new Error("deleted")); + } else { + const k = this.#keyList[index2]; + if (this.#hasDispose) { + this.#dispose?.(v, k, "delete"); + } + if (this.#hasDisposeAfter) { + this.#disposed?.push([v, k, "delete"]); + } + } + } + this.#keyMap.clear(); + this.#valList.fill(void 0); + this.#keyList.fill(void 0); + if (this.#ttls && this.#starts) { + this.#ttls.fill(0); + this.#starts.fill(0); + } + if (this.#sizes) { + this.#sizes.fill(0); + } + this.#head = 0; + this.#tail = 0; + this.#free.length = 0; + this.#calculatedSize = 0; + this.#size = 0; + if (this.#hasDisposeAfter && this.#disposed) { + const dt = this.#disposed; + let task; + while (task = dt?.shift()) { + this.#disposeAfter?.(...task); + } + } + } + }; + exports2.LRUCache = LRUCache; + } +}); + +// ../../../node_modules/.pnpm/@octokit+auth-app@6.1.1/node_modules/@octokit/auth-app/dist-node/index.js +var require_dist_node20 = __commonJS({ + "../../../node_modules/.pnpm/@octokit+auth-app@6.1.1/node_modules/@octokit/auth-app/dist-node/index.js"(exports2, module2) { + "use strict"; + var __create2 = Object.create; + var __defProp2 = Object.defineProperty; + var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; + var __getOwnPropNames2 = Object.getOwnPropertyNames; + var __getProtoOf2 = Object.getPrototypeOf; + var __hasOwnProp2 = Object.prototype.hasOwnProperty; + var __export2 = (target, all) => { + for (var name in all) + __defProp2(target, name, { get: all[name], enumerable: true }); + }; + var __copyProps2 = (to, from2, except, desc) => { + if (from2 && typeof from2 === "object" || typeof from2 === "function") { + for (let key of __getOwnPropNames2(from2)) + if (!__hasOwnProp2.call(to, key) && key !== except) + __defProp2(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc2(from2, key)) || desc.enumerable }); + } + return to; + }; + var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target, + mod + )); + var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); + var dist_src_exports = {}; + __export2(dist_src_exports, { + createAppAuth: () => createAppAuth, + createOAuthUserAuth: () => import_auth_oauth_user2.createOAuthUserAuth + }); + module2.exports = __toCommonJS2(dist_src_exports); + var import_universal_user_agent = require_dist_node(); + var import_request = require_dist_node5(); + var import_auth_oauth_app = require_dist_node18(); + var import_deprecation = require_dist_node3(); + var OAuthAppAuth = __toESM2(require_dist_node18()); + var import_universal_github_app_jwt = require_dist_node19(); + async function getAppAuthentication({ + appId, + privateKey, + timeDifference + }) { + try { + const appAuthentication = await (0, import_universal_github_app_jwt.githubAppJwt)({ + id: +appId, + privateKey, + now: timeDifference && Math.floor(Date.now() / 1e3) + timeDifference + }); + return { + type: "app", + token: appAuthentication.token, + appId: appAuthentication.appId, + expiresAt: new Date(appAuthentication.expiration * 1e3).toISOString() + }; + } catch (error) { + if (privateKey === "-----BEGIN RSA PRIVATE KEY-----") { + throw new Error( + "The 'privateKey` option contains only the first line '-----BEGIN RSA PRIVATE KEY-----'. If you are setting it using a `.env` file, make sure it is set on a single line with newlines replaced by '\n'" + ); + } else { + throw error; + } + } + } + var import_lru_cache = require_commonjs(); + function getCache() { + return new import_lru_cache.LRUCache({ + // cache max. 15000 tokens, that will use less than 10mb memory + max: 15e3, + // Cache for 1 minute less than GitHub expiry + ttl: 1e3 * 60 * 59 + }); + } + async function get(cache, options) { + const cacheKey = optionsToCacheKey(options); + const result = await cache.get(cacheKey); + if (!result) { + return; + } + const [ + token, + createdAt, + expiresAt, + repositorySelection, + permissionsString, + singleFileName + ] = result.split("|"); + const permissions = options.permissions || permissionsString.split(/,/).reduce((permissions2, string) => { + if (/!$/.test(string)) { + permissions2[string.slice(0, -1)] = "write"; + } else { + permissions2[string] = "read"; + } + return permissions2; + }, {}); + return { + token, + createdAt, + expiresAt, + permissions, + repositoryIds: options.repositoryIds, + repositoryNames: options.repositoryNames, + singleFileName, + repositorySelection + }; + } + async function set(cache, options, data) { + const key = optionsToCacheKey(options); + const permissionsString = options.permissions ? "" : Object.keys(data.permissions).map( + (name) => `${name}${data.permissions[name] === "write" ? "!" : ""}` + ).join(","); + const value = [ + data.token, + data.createdAt, + data.expiresAt, + data.repositorySelection, + permissionsString, + data.singleFileName + ].join("|"); + await cache.set(key, value); + } + function optionsToCacheKey({ + installationId, + permissions = {}, + repositoryIds = [], + repositoryNames = [] + }) { + const permissionsString = Object.keys(permissions).sort().map((name) => permissions[name] === "read" ? name : `${name}!`).join(","); + const repositoryIdsString = repositoryIds.sort().join(","); + const repositoryNamesString = repositoryNames.join(","); + return [ + installationId, + repositoryIdsString, + repositoryNamesString, + permissionsString + ].filter(Boolean).join("|"); + } + function toTokenAuthentication({ + installationId, + token, + createdAt, + expiresAt, + repositorySelection, + permissions, + repositoryIds, + repositoryNames, + singleFileName + }) { + return Object.assign( + { + type: "token", + tokenType: "installation", + token, + installationId, + permissions, + createdAt, + expiresAt, + repositorySelection + }, + repositoryIds ? { repositoryIds } : null, + repositoryNames ? { repositoryNames } : null, + singleFileName ? { singleFileName } : null + ); + } + async function getInstallationAuthentication(state, options, customRequest) { + const installationId = Number(options.installationId || state.installationId); + if (!installationId) { + throw new Error( + "[@octokit/auth-app] installationId option is required for installation authentication." + ); + } + if (options.factory) { + const { type, factory, oauthApp, ...factoryAuthOptions } = { + ...state, + ...options + }; + return factory(factoryAuthOptions); + } + const optionsWithInstallationTokenFromState = Object.assign( + { installationId }, + options + ); + if (!options.refresh) { + const result = await get( + state.cache, + optionsWithInstallationTokenFromState + ); + if (result) { + const { + token: token2, + createdAt: createdAt2, + expiresAt: expiresAt2, + permissions: permissions2, + repositoryIds: repositoryIds2, + repositoryNames: repositoryNames2, + singleFileName: singleFileName2, + repositorySelection: repositorySelection2 + } = result; + return toTokenAuthentication({ + installationId, + token: token2, + createdAt: createdAt2, + expiresAt: expiresAt2, + permissions: permissions2, + repositorySelection: repositorySelection2, + repositoryIds: repositoryIds2, + repositoryNames: repositoryNames2, + singleFileName: singleFileName2 + }); + } + } + const appAuthentication = await getAppAuthentication(state); + const request = customRequest || state.request; + const { + data: { + token, + expires_at: expiresAt, + repositories, + permissions: permissionsOptional, + repository_selection: repositorySelectionOptional, + single_file: singleFileName + } + } = await request("POST /app/installations/{installation_id}/access_tokens", { + installation_id: installationId, + repository_ids: options.repositoryIds, + repositories: options.repositoryNames, + permissions: options.permissions, + mediaType: { + previews: ["machine-man"] + }, + headers: { + authorization: `bearer ${appAuthentication.token}` + } + }); + const permissions = permissionsOptional || {}; + const repositorySelection = repositorySelectionOptional || "all"; + const repositoryIds = repositories ? repositories.map((r) => r.id) : void 0; + const repositoryNames = repositories ? repositories.map((repo) => repo.name) : void 0; + const createdAt = (/* @__PURE__ */ new Date()).toISOString(); + await set(state.cache, optionsWithInstallationTokenFromState, { + token, + createdAt, + expiresAt, + repositorySelection, + permissions, + repositoryIds, + repositoryNames, + singleFileName + }); + return toTokenAuthentication({ + installationId, + token, + createdAt, + expiresAt, + repositorySelection, + permissions, + repositoryIds, + repositoryNames, + singleFileName + }); + } + async function auth(state, authOptions) { + switch (authOptions.type) { + case "app": + return getAppAuthentication(state); + case "oauth": + state.log.warn( + // @ts-expect-error `log.warn()` expects string + new import_deprecation.Deprecation( + `[@octokit/auth-app] {type: "oauth"} is deprecated. Use {type: "oauth-app"} instead` + ) + ); + case "oauth-app": + return state.oauthApp({ type: "oauth-app" }); + case "installation": + authOptions; + return getInstallationAuthentication(state, { + ...authOptions, + type: "installation" + }); + case "oauth-user": + return state.oauthApp(authOptions); + default: + throw new Error(`Invalid auth type: ${authOptions.type}`); + } + } + var import_auth_oauth_user = require_dist_node17(); + var import_request_error = require_dist_node4(); + var PATHS = [ + "/app", + "/app/hook/config", + "/app/hook/deliveries", + "/app/hook/deliveries/{delivery_id}", + "/app/hook/deliveries/{delivery_id}/attempts", + "/app/installations", + "/app/installations/{installation_id}", + "/app/installations/{installation_id}/access_tokens", + "/app/installations/{installation_id}/suspended", + "/app/installation-requests", + "/marketplace_listing/accounts/{account_id}", + "/marketplace_listing/plan", + "/marketplace_listing/plans", + "/marketplace_listing/plans/{plan_id}/accounts", + "/marketplace_listing/stubbed/accounts/{account_id}", + "/marketplace_listing/stubbed/plan", + "/marketplace_listing/stubbed/plans", + "/marketplace_listing/stubbed/plans/{plan_id}/accounts", + "/orgs/{org}/installation", + "/repos/{owner}/{repo}/installation", + "/users/{username}/installation" + ]; + function routeMatcher(paths) { + const regexes = paths.map( + (p) => p.split("/").map((c) => c.startsWith("{") ? "(?:.+?)" : c).join("/") + ); + const regex = `^(?:${regexes.map((r) => `(?:${r})`).join("|")})$`; + return new RegExp(regex, "i"); + } + var REGEX = routeMatcher(PATHS); + function requiresAppAuth(url) { + return !!url && REGEX.test(url.split("?")[0]); + } + var FIVE_SECONDS_IN_MS = 5 * 1e3; + function isNotTimeSkewError(error) { + return !(error.message.match( + /'Expiration time' claim \('exp'\) must be a numeric value representing the future time at which the assertion expires/ + ) || error.message.match( + /'Issued at' claim \('iat'\) must be an Integer representing the time that the assertion was issued/ + )); + } + async function hook(state, request, route, parameters) { + const endpoint = request.endpoint.merge(route, parameters); + const url = endpoint.url; + if (/\/login\/oauth\/access_token$/.test(url)) { + return request(endpoint); + } + if (requiresAppAuth(url.replace(request.endpoint.DEFAULTS.baseUrl, ""))) { + const { token: token2 } = await getAppAuthentication(state); + endpoint.headers.authorization = `bearer ${token2}`; + let response; + try { + response = await request(endpoint); + } catch (error) { + if (isNotTimeSkewError(error)) { + throw error; + } + if (typeof error.response.headers.date === "undefined") { + throw error; + } + const diff = Math.floor( + (Date.parse(error.response.headers.date) - Date.parse((/* @__PURE__ */ new Date()).toString())) / 1e3 + ); + state.log.warn(error.message); + state.log.warn( + `[@octokit/auth-app] GitHub API time and system time are different by ${diff} seconds. Retrying request with the difference accounted for.` + ); + const { token: token3 } = await getAppAuthentication({ + ...state, + timeDifference: diff + }); + endpoint.headers.authorization = `bearer ${token3}`; + return request(endpoint); + } + return response; + } + if ((0, import_auth_oauth_user.requiresBasicAuth)(url)) { + const authentication = await state.oauthApp({ type: "oauth-app" }); + endpoint.headers.authorization = authentication.headers.authorization; + return request(endpoint); + } + const { token, createdAt } = await getInstallationAuthentication( + state, + // @ts-expect-error TBD + {}, + request + ); + endpoint.headers.authorization = `token ${token}`; + return sendRequestWithRetries( + state, + request, + endpoint, + createdAt + ); + } + async function sendRequestWithRetries(state, request, options, createdAt, retries = 0) { + const timeSinceTokenCreationInMs = +/* @__PURE__ */ new Date() - +new Date(createdAt); + try { + return await request(options); + } catch (error) { + if (error.status !== 401) { + throw error; + } + if (timeSinceTokenCreationInMs >= FIVE_SECONDS_IN_MS) { + if (retries > 0) { + error.message = `After ${retries} retries within ${timeSinceTokenCreationInMs / 1e3}s of creating the installation access token, the response remains 401. At this point, the cause may be an authentication problem or a system outage. Please check https://www.githubstatus.com for status information`; } + throw error; + } + ++retries; + const awaitTime = retries * 1e3; + state.log.warn( + `[@octokit/auth-app] Retrying after 401 response to account for token replication delay (retry: ${retries}, wait: ${awaitTime / 1e3}s)` + ); + await new Promise((resolve) => setTimeout(resolve, awaitTime)); + return sendRequestWithRetries(state, request, options, createdAt, retries); + } + } + var VERSION = "6.1.1"; + var import_auth_oauth_user2 = require_dist_node17(); + function createAppAuth(options) { + if (!options.appId) { + throw new Error("[@octokit/auth-app] appId option is required"); + } + if (!Number.isFinite(+options.appId)) { + throw new Error( + "[@octokit/auth-app] appId option must be a number or numeric string" + ); + } + if (!options.privateKey) { + throw new Error("[@octokit/auth-app] privateKey option is required"); + } + if ("installationId" in options && !options.installationId) { + throw new Error( + "[@octokit/auth-app] installationId is set to a falsy value" + ); + } + const log3 = Object.assign( + { + warn: console.warn.bind(console) + }, + options.log + ); + const request = options.request || import_request.request.defaults({ + headers: { + "user-agent": `octokit-auth-app.js/${VERSION} ${(0, import_universal_user_agent.getUserAgent)()}` } - strm.next_out = put; - strm.avail_out = left; - strm.next_in = next; - strm.avail_in = have; - state.hold = hold; - state.bits = bits; - if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (state.mode < CHECK || flush !== Z_FINISH)) { - if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) { - state.mode = MEM; - return Z_MEM_ERROR; + }); + const state = Object.assign( + { + request, + cache: getCache() + }, + options, + options.installationId ? { installationId: Number(options.installationId) } : {}, + { + log: log3, + oauthApp: (0, import_auth_oauth_app.createOAuthAppAuth)({ + clientType: "github-app", + clientId: options.clientId || "", + clientSecret: options.clientSecret || "", + request + }) } + ); + return Object.assign(auth.bind(null, state), { + hook: hook.bind(null, state) + }); + } + } +}); + +// ../../../node_modules/.pnpm/@octokit+auth-unauthenticated@5.0.1/node_modules/@octokit/auth-unauthenticated/dist-node/index.js +var require_dist_node21 = __commonJS({ + "../../../node_modules/.pnpm/@octokit+auth-unauthenticated@5.0.1/node_modules/@octokit/auth-unauthenticated/dist-node/index.js"(exports2, module2) { + "use strict"; + var __defProp2 = Object.defineProperty; + var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; + var __getOwnPropNames2 = Object.getOwnPropertyNames; + var __hasOwnProp2 = Object.prototype.hasOwnProperty; + var __export2 = (target, all) => { + for (var name in all) + __defProp2(target, name, { get: all[name], enumerable: true }); + }; + var __copyProps2 = (to, from2, except, desc) => { + if (from2 && typeof from2 === "object" || typeof from2 === "function") { + for (let key of __getOwnPropNames2(from2)) + if (!__hasOwnProp2.call(to, key) && key !== except) + __defProp2(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc2(from2, key)) || desc.enumerable }); } - _in -= strm.avail_in; - _out -= strm.avail_out; - strm.total_in += _in; - strm.total_out += _out; - state.total += _out; - if (state.wrap && _out) { - strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/ - state.flags ? crc322(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out); + return to; + }; + var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); + var dist_src_exports = {}; + __export2(dist_src_exports, { + createUnauthenticatedAuth: () => createUnauthenticatedAuth + }); + module2.exports = __toCommonJS2(dist_src_exports); + async function auth(reason) { + return { + type: "unauthenticated", + reason + }; + } + var import_request_error = require_dist_node4(); + function isRateLimitError(error) { + if (error.status !== 403) { + return false; } - strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0); - if ((_in === 0 && _out === 0 || flush === Z_FINISH) && ret === Z_OK) { - ret = Z_BUF_ERROR; + if (!error.response) { + return false; } - return ret; + return error.response.headers["x-ratelimit-remaining"] === "0"; } - function inflateEnd(strm) { - if (!strm || !strm.state) { - return Z_STREAM_ERROR; - } - var state = strm.state; - if (state.window) { - state.window = null; + var import_request_error2 = require_dist_node4(); + var REGEX_ABUSE_LIMIT_MESSAGE = /\babuse\b/i; + function isAbuseLimitError(error) { + if (error.status !== 403) { + return false; } - strm.state = null; - return Z_OK; + return REGEX_ABUSE_LIMIT_MESSAGE.test(error.message); } - function inflateGetHeader(strm, head) { - var state; - if (!strm || !strm.state) { - return Z_STREAM_ERROR; + async function hook(reason, request, route, parameters) { + const endpoint = request.endpoint.merge( + route, + parameters + ); + return request(endpoint).catch((error) => { + if (error.status === 404) { + error.message = `Not found. May be due to lack of authentication. Reason: ${reason}`; + throw error; + } + if (isRateLimitError(error)) { + error.message = `API rate limit exceeded. This maybe caused by the lack of authentication. Reason: ${reason}`; + throw error; + } + if (isAbuseLimitError(error)) { + error.message = `You have triggered an abuse detection mechanism. This maybe caused by the lack of authentication. Reason: ${reason}`; + throw error; + } + if (error.status === 401) { + error.message = `Unauthorized. "${endpoint.method} ${endpoint.url}" failed most likely due to lack of authentication. Reason: ${reason}`; + throw error; + } + if (error.status >= 400 && error.status < 500) { + error.message = error.message.replace( + /\.?$/, + `. May be caused by lack of authentication (${reason}).` + ); + } + throw error; + }); + } + var createUnauthenticatedAuth = function createUnauthenticatedAuth2(options) { + if (!options || !options.reason) { + throw new Error( + "[@octokit/auth-unauthenticated] No reason passed to createUnauthenticatedAuth" + ); } - state = strm.state; - if ((state.wrap & 2) === 0) { - return Z_STREAM_ERROR; + return Object.assign(auth.bind(null, options.reason), { + hook: hook.bind(null, options.reason) + }); + }; + } +}); + +// ../../../node_modules/.pnpm/@octokit+oauth-app@6.1.0/node_modules/@octokit/oauth-app/dist-node/index.js +var require_dist_node22 = __commonJS({ + "../../../node_modules/.pnpm/@octokit+oauth-app@6.1.0/node_modules/@octokit/oauth-app/dist-node/index.js"(exports2, module2) { + "use strict"; + var __create2 = Object.create; + var __defProp2 = Object.defineProperty; + var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; + var __getOwnPropNames2 = Object.getOwnPropertyNames; + var __getProtoOf2 = Object.getPrototypeOf; + var __hasOwnProp2 = Object.prototype.hasOwnProperty; + var __export2 = (target, all) => { + for (var name in all) + __defProp2(target, name, { get: all[name], enumerable: true }); + }; + var __copyProps2 = (to, from2, except, desc) => { + if (from2 && typeof from2 === "object" || typeof from2 === "function") { + for (let key of __getOwnPropNames2(from2)) + if (!__hasOwnProp2.call(to, key) && key !== except) + __defProp2(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc2(from2, key)) || desc.enumerable }); } - state.head = head; - head.done = false; - return Z_OK; + return to; + }; + var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target, + mod + )); + var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); + var dist_src_exports = {}; + __export2(dist_src_exports, { + OAuthApp: () => OAuthApp, + createAWSLambdaAPIGatewayV2Handler: () => createAWSLambdaAPIGatewayV2Handler, + createNodeMiddleware: () => createNodeMiddleware2, + createWebWorkerHandler: () => createWebWorkerHandler, + handleRequest: () => handleRequest, + sendNodeResponse: () => sendResponse, + unknownRouteResponse: () => unknownRouteResponse + }); + module2.exports = __toCommonJS2(dist_src_exports); + var import_auth_oauth_app = require_dist_node18(); + var VERSION = "6.1.0"; + function addEventHandler(state, eventName, eventHandler) { + if (Array.isArray(eventName)) { + for (const singleEventName of eventName) { + addEventHandler(state, singleEventName, eventHandler); + } + return; + } + if (!state.eventHandlers[eventName]) { + state.eventHandlers[eventName] = []; + } + state.eventHandlers[eventName].push(eventHandler); } - function inflateSetDictionary(strm, dictionary) { - var dictLength = dictionary.length; - var state; - var dictid; - var ret; - if (!strm || !strm.state) { - return Z_STREAM_ERROR; + var import_core = require_dist_node8(); + var import_universal_user_agent = require_dist_node(); + var OAuthAppOctokit = import_core.Octokit.defaults({ + userAgent: `octokit-oauth-app.js/${VERSION} ${(0, import_universal_user_agent.getUserAgent)()}` + }); + var import_auth_oauth_user = require_dist_node17(); + async function emitEvent(state, context2) { + const { name, action } = context2; + if (state.eventHandlers[`${name}.${action}`]) { + for (const eventHandler of state.eventHandlers[`${name}.${action}`]) { + await eventHandler(context2); + } } - state = strm.state; - if (state.wrap !== 0 && state.mode !== DICT) { - return Z_STREAM_ERROR; + if (state.eventHandlers[name]) { + for (const eventHandler of state.eventHandlers[name]) { + await eventHandler(context2); + } } - if (state.mode === DICT) { - dictid = 1; - dictid = adler32(dictid, dictionary, dictLength, 0); - if (dictid !== state.check) { - return Z_DATA_ERROR; + } + async function getUserOctokitWithState(state, options) { + return state.octokit.auth({ + type: "oauth-user", + ...options, + async factory(options2) { + const octokit = new state.Octokit({ + authStrategy: import_auth_oauth_user.createOAuthUserAuth, + auth: options2 + }); + const authentication = await octokit.auth({ + type: "get" + }); + await emitEvent(state, { + name: "token", + action: "created", + token: authentication.token, + scopes: authentication.scopes, + authentication, + octokit + }); + return octokit; } + }); + } + var OAuthMethods = __toESM2(require_dist_node15()); + function getWebFlowAuthorizationUrlWithState(state, options) { + const optionsWithDefaults = { + clientId: state.clientId, + request: state.octokit.request, + ...options, + allowSignup: state.allowSignup ?? options.allowSignup, + redirectUrl: options.redirectUrl ?? state.redirectUrl, + scopes: options.scopes ?? state.defaultScopes + }; + return OAuthMethods.getWebFlowAuthorizationUrl({ + clientType: state.clientType, + ...optionsWithDefaults + }); + } + var OAuthAppAuth = __toESM2(require_dist_node18()); + async function createTokenWithState(state, options) { + const authentication = await state.octokit.auth({ + type: "oauth-user", + ...options + }); + await emitEvent(state, { + name: "token", + action: "created", + token: authentication.token, + scopes: authentication.scopes, + authentication, + octokit: new state.Octokit({ + authStrategy: OAuthAppAuth.createOAuthUserAuth, + auth: { + clientType: state.clientType, + clientId: state.clientId, + clientSecret: state.clientSecret, + token: authentication.token, + scopes: authentication.scopes, + refreshToken: authentication.refreshToken, + expiresAt: authentication.expiresAt, + refreshTokenExpiresAt: authentication.refreshTokenExpiresAt + } + }) + }); + return { authentication }; + } + var OAuthMethods2 = __toESM2(require_dist_node15()); + async function checkTokenWithState(state, options) { + const result = await OAuthMethods2.checkToken({ + // @ts-expect-error not worth the extra code to appease TS + clientType: state.clientType, + clientId: state.clientId, + clientSecret: state.clientSecret, + request: state.octokit.request, + ...options + }); + Object.assign(result.authentication, { type: "token", tokenType: "oauth" }); + return result; + } + var OAuthMethods3 = __toESM2(require_dist_node15()); + var import_auth_oauth_user2 = require_dist_node17(); + async function resetTokenWithState(state, options) { + const optionsWithDefaults = { + clientId: state.clientId, + clientSecret: state.clientSecret, + request: state.octokit.request, + ...options + }; + if (state.clientType === "oauth-app") { + const response2 = await OAuthMethods3.resetToken({ + clientType: "oauth-app", + ...optionsWithDefaults + }); + const authentication2 = Object.assign(response2.authentication, { + type: "token", + tokenType: "oauth" + }); + await emitEvent(state, { + name: "token", + action: "reset", + token: response2.authentication.token, + scopes: response2.authentication.scopes || void 0, + authentication: authentication2, + octokit: new state.Octokit({ + authStrategy: import_auth_oauth_user2.createOAuthUserAuth, + auth: { + clientType: state.clientType, + clientId: state.clientId, + clientSecret: state.clientSecret, + token: response2.authentication.token, + scopes: response2.authentication.scopes + } + }) + }); + return { ...response2, authentication: authentication2 }; } - ret = updatewindow(strm, dictionary, dictLength, dictLength); - if (ret) { - state.mode = MEM; - return Z_MEM_ERROR; + const response = await OAuthMethods3.resetToken({ + clientType: "github-app", + ...optionsWithDefaults + }); + const authentication = Object.assign(response.authentication, { + type: "token", + tokenType: "oauth" + }); + await emitEvent(state, { + name: "token", + action: "reset", + token: response.authentication.token, + authentication, + octokit: new state.Octokit({ + authStrategy: import_auth_oauth_user2.createOAuthUserAuth, + auth: { + clientType: state.clientType, + clientId: state.clientId, + clientSecret: state.clientSecret, + token: response.authentication.token + } + }) + }); + return { ...response, authentication }; + } + var OAuthMethods4 = __toESM2(require_dist_node15()); + var import_auth_oauth_user3 = require_dist_node17(); + async function refreshTokenWithState(state, options) { + if (state.clientType === "oauth-app") { + throw new Error( + "[@octokit/oauth-app] app.refreshToken() is not supported for OAuth Apps" + ); } - state.havedict = 1; - return Z_OK; + const response = await OAuthMethods4.refreshToken({ + clientType: "github-app", + clientId: state.clientId, + clientSecret: state.clientSecret, + request: state.octokit.request, + refreshToken: options.refreshToken + }); + const authentication = Object.assign(response.authentication, { + type: "token", + tokenType: "oauth" + }); + await emitEvent(state, { + name: "token", + action: "refreshed", + token: response.authentication.token, + authentication, + octokit: new state.Octokit({ + authStrategy: import_auth_oauth_user3.createOAuthUserAuth, + auth: { + clientType: state.clientType, + clientId: state.clientId, + clientSecret: state.clientSecret, + token: response.authentication.token + } + }) + }); + return { ...response, authentication }; + } + var OAuthMethods5 = __toESM2(require_dist_node15()); + var import_auth_oauth_user4 = require_dist_node17(); + async function scopeTokenWithState(state, options) { + if (state.clientType === "oauth-app") { + throw new Error( + "[@octokit/oauth-app] app.scopeToken() is not supported for OAuth Apps" + ); + } + const response = await OAuthMethods5.scopeToken({ + clientType: "github-app", + clientId: state.clientId, + clientSecret: state.clientSecret, + request: state.octokit.request, + ...options + }); + const authentication = Object.assign(response.authentication, { + type: "token", + tokenType: "oauth" + }); + await emitEvent(state, { + name: "token", + action: "scoped", + token: response.authentication.token, + authentication, + octokit: new state.Octokit({ + authStrategy: import_auth_oauth_user4.createOAuthUserAuth, + auth: { + clientType: state.clientType, + clientId: state.clientId, + clientSecret: state.clientSecret, + token: response.authentication.token + } + }) + }); + return { ...response, authentication }; + } + var OAuthMethods6 = __toESM2(require_dist_node15()); + var import_auth_unauthenticated = require_dist_node21(); + async function deleteTokenWithState(state, options) { + const optionsWithDefaults = { + clientId: state.clientId, + clientSecret: state.clientSecret, + request: state.octokit.request, + ...options + }; + const response = state.clientType === "oauth-app" ? await OAuthMethods6.deleteToken({ + clientType: "oauth-app", + ...optionsWithDefaults + }) : ( + // istanbul ignore next + await OAuthMethods6.deleteToken({ + clientType: "github-app", + ...optionsWithDefaults + }) + ); + await emitEvent(state, { + name: "token", + action: "deleted", + token: options.token, + octokit: new state.Octokit({ + authStrategy: import_auth_unauthenticated.createUnauthenticatedAuth, + auth: { + reason: `Handling "token.deleted" event. The access for the token has been revoked.` + } + }) + }); + return response; + } + var OAuthMethods7 = __toESM2(require_dist_node15()); + var import_auth_unauthenticated2 = require_dist_node21(); + async function deleteAuthorizationWithState(state, options) { + const optionsWithDefaults = { + clientId: state.clientId, + clientSecret: state.clientSecret, + request: state.octokit.request, + ...options + }; + const response = state.clientType === "oauth-app" ? await OAuthMethods7.deleteAuthorization({ + clientType: "oauth-app", + ...optionsWithDefaults + }) : ( + // istanbul ignore next + await OAuthMethods7.deleteAuthorization({ + clientType: "github-app", + ...optionsWithDefaults + }) + ); + await emitEvent(state, { + name: "token", + action: "deleted", + token: options.token, + octokit: new state.Octokit({ + authStrategy: import_auth_unauthenticated2.createUnauthenticatedAuth, + auth: { + reason: `Handling "token.deleted" event. The access for the token has been revoked.` + } + }) + }); + await emitEvent(state, { + name: "authorization", + action: "deleted", + token: options.token, + octokit: new state.Octokit({ + authStrategy: import_auth_unauthenticated2.createUnauthenticatedAuth, + auth: { + reason: `Handling "authorization.deleted" event. The access for the app has been revoked.` + } + }) + }); + return response; } - exports2.inflateReset = inflateReset; - exports2.inflateReset2 = inflateReset2; - exports2.inflateResetKeep = inflateResetKeep; - exports2.inflateInit = inflateInit; - exports2.inflateInit2 = inflateInit2; - exports2.inflate = inflate2; - exports2.inflateEnd = inflateEnd; - exports2.inflateGetHeader = inflateGetHeader; - exports2.inflateSetDictionary = inflateSetDictionary; - exports2.inflateInfo = "pako inflate (from Nodeca project)"; - } -}); - -// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/constants.js -var require_constants7 = __commonJS({ - "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/constants.js"(exports2, module2) { - "use strict"; - module2.exports = { - /* Allowed flush values; see deflate() and inflate() below for details */ - Z_NO_FLUSH: 0, - Z_PARTIAL_FLUSH: 1, - Z_SYNC_FLUSH: 2, - Z_FULL_FLUSH: 3, - Z_FINISH: 4, - Z_BLOCK: 5, - Z_TREES: 6, - /* Return codes for the compression/decompression functions. Negative values - * are errors, positive values are used for special but normal events. - */ - Z_OK: 0, - Z_STREAM_END: 1, - Z_NEED_DICT: 2, - Z_ERRNO: -1, - Z_STREAM_ERROR: -2, - Z_DATA_ERROR: -3, - //Z_MEM_ERROR: -4, - Z_BUF_ERROR: -5, - //Z_VERSION_ERROR: -6, - /* compression levels */ - Z_NO_COMPRESSION: 0, - Z_BEST_SPEED: 1, - Z_BEST_COMPRESSION: 9, - Z_DEFAULT_COMPRESSION: -1, - Z_FILTERED: 1, - Z_HUFFMAN_ONLY: 2, - Z_RLE: 3, - Z_FIXED: 4, - Z_DEFAULT_STRATEGY: 0, - /* Possible values of the data_type field (though see inflate()) */ - Z_BINARY: 0, - Z_TEXT: 1, - //Z_ASCII: 1, // = Z_TEXT (deprecated) - Z_UNKNOWN: 2, - /* The deflate compression method */ - Z_DEFLATED: 8 - //Z_NULL: null // Use -1 or null inline, depending on var type - }; - } -}); - -// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/gzheader.js -var require_gzheader = __commonJS({ - "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/gzheader.js"(exports2, module2) { - "use strict"; - function GZheader() { - this.text = 0; - this.time = 0; - this.xflags = 0; - this.os = 0; - this.extra = null; - this.extra_len = 0; - this.name = ""; - this.comment = ""; - this.hcrc = 0; - this.done = false; + function unknownRouteResponse(request) { + return { + status: 404, + headers: { "content-type": "application/json" }, + text: JSON.stringify({ + error: `Unknown route: ${request.method} ${request.url}` + }) + }; } - module2.exports = GZheader; - } -}); - -// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/inflate.js -var require_inflate2 = __commonJS({ - "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/inflate.js"(exports2) { - "use strict"; - var zlib_inflate = require_inflate(); - var utils = require_common(); - var strings = require_strings(); - var c = require_constants7(); - var msg = require_messages(); - var ZStream = require_zstream(); - var GZheader = require_gzheader(); - var toString = Object.prototype.toString; - function Inflate(options) { - if (!(this instanceof Inflate)) - return new Inflate(options); - this.options = utils.assign({ - chunkSize: 16384, - windowBits: 0, - to: "" - }, options || {}); - var opt = this.options; - if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) { - opt.windowBits = -opt.windowBits; - if (opt.windowBits === 0) { - opt.windowBits = -15; - } + async function handleRequest(app, { pathPrefix = "/api/github/oauth" }, request) { + if (request.method === "OPTIONS") { + return { + status: 200, + headers: { + "access-control-allow-origin": "*", + "access-control-allow-methods": "*", + "access-control-allow-headers": "Content-Type, User-Agent, Authorization" + } + }; } - if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) { - opt.windowBits += 32; + let { pathname } = new URL(request.url, "http://localhost"); + if (!pathname.startsWith(`${pathPrefix}/`)) { + return void 0; } - if (opt.windowBits > 15 && opt.windowBits < 48) { - if ((opt.windowBits & 15) === 0) { - opt.windowBits |= 15; - } + pathname = pathname.slice(pathPrefix.length + 1); + const route = [request.method, pathname].join(" "); + const routes = { + getLogin: `GET login`, + getCallback: `GET callback`, + createToken: `POST token`, + getToken: `GET token`, + patchToken: `PATCH token`, + patchRefreshToken: `PATCH refresh-token`, + scopeToken: `POST token/scoped`, + deleteToken: `DELETE token`, + deleteGrant: `DELETE grant` + }; + if (!Object.values(routes).includes(route)) { + return unknownRouteResponse(request); } - this.err = 0; - this.msg = ""; - this.ended = false; - this.chunks = []; - this.strm = new ZStream(); - this.strm.avail_out = 0; - var status2 = zlib_inflate.inflateInit2( - this.strm, - opt.windowBits - ); - if (status2 !== c.Z_OK) { - throw new Error(msg[status2]); + let json; + try { + const text = await request.text(); + json = text ? JSON.parse(text) : {}; + } catch (error) { + return { + status: 400, + headers: { + "content-type": "application/json", + "access-control-allow-origin": "*" + }, + text: JSON.stringify({ + error: "[@octokit/oauth-app] request error" + }) + }; } - this.header = new GZheader(); - zlib_inflate.inflateGetHeader(this.strm, this.header); - if (opt.dictionary) { - if (typeof opt.dictionary === "string") { - opt.dictionary = strings.string2buf(opt.dictionary); - } else if (toString.call(opt.dictionary) === "[object ArrayBuffer]") { - opt.dictionary = new Uint8Array(opt.dictionary); + const { searchParams } = new URL(request.url, "http://localhost"); + const query = Object.fromEntries(searchParams); + const headers = request.headers; + try { + if (route === routes.getLogin) { + const { url } = app.getWebFlowAuthorizationUrl({ + state: query.state, + scopes: query.scopes ? query.scopes.split(",") : void 0, + allowSignup: query.allowSignup ? query.allowSignup === "true" : void 0, + redirectUrl: query.redirectUrl + }); + return { status: 302, headers: { location: url } }; } - if (opt.raw) { - status2 = zlib_inflate.inflateSetDictionary(this.strm, opt.dictionary); - if (status2 !== c.Z_OK) { - throw new Error(msg[status2]); + if (route === routes.getCallback) { + if (query.error) { + throw new Error( + `[@octokit/oauth-app] ${query.error} ${query.error_description}` + ); + } + if (!query.code) { + throw new Error('[@octokit/oauth-app] "code" parameter is required'); } + const { + authentication: { token: token2 } + } = await app.createToken({ + code: query.code + }); + return { + status: 200, + headers: { + "content-type": "text/html" + }, + text: `

Token created successfully

+ +

Your token is: ${token2}. Copy it now as it cannot be shown again.

` + }; } - } - } - Inflate.prototype.push = function(data, mode) { - var strm = this.strm; - var chunkSize = this.options.chunkSize; - var dictionary = this.options.dictionary; - var status2, _mode; - var next_out_utf8, tail, utf8str; - var allowBufError = false; - if (this.ended) { - return false; - } - _mode = mode === ~~mode ? mode : mode === true ? c.Z_FINISH : c.Z_NO_FLUSH; - if (typeof data === "string") { - strm.input = strings.binstring2buf(data); - } else if (toString.call(data) === "[object ArrayBuffer]") { - strm.input = new Uint8Array(data); - } else { - strm.input = data; - } - strm.next_in = 0; - strm.avail_in = strm.input.length; - do { - if (strm.avail_out === 0) { - strm.output = new utils.Buf8(chunkSize); - strm.next_out = 0; - strm.avail_out = chunkSize; + if (route === routes.createToken) { + const { code, redirectUrl } = json; + if (!code) { + throw new Error('[@octokit/oauth-app] "code" parameter is required'); + } + const result = await app.createToken({ + code, + redirectUrl + }); + delete result.authentication.clientSecret; + return { + status: 201, + headers: { + "content-type": "application/json", + "access-control-allow-origin": "*" + }, + text: JSON.stringify(result) + }; } - status2 = zlib_inflate.inflate(strm, c.Z_NO_FLUSH); - if (status2 === c.Z_NEED_DICT && dictionary) { - status2 = zlib_inflate.inflateSetDictionary(this.strm, dictionary); + if (route === routes.getToken) { + const token2 = headers.authorization?.substr("token ".length); + if (!token2) { + throw new Error( + '[@octokit/oauth-app] "Authorization" header is required' + ); + } + const result = await app.checkToken({ + token: token2 + }); + delete result.authentication.clientSecret; + return { + status: 200, + headers: { + "content-type": "application/json", + "access-control-allow-origin": "*" + }, + text: JSON.stringify(result) + }; } - if (status2 === c.Z_BUF_ERROR && allowBufError === true) { - status2 = c.Z_OK; - allowBufError = false; + if (route === routes.patchToken) { + const token2 = headers.authorization?.substr("token ".length); + if (!token2) { + throw new Error( + '[@octokit/oauth-app] "Authorization" header is required' + ); + } + const result = await app.resetToken({ token: token2 }); + delete result.authentication.clientSecret; + return { + status: 200, + headers: { + "content-type": "application/json", + "access-control-allow-origin": "*" + }, + text: JSON.stringify(result) + }; } - if (status2 !== c.Z_STREAM_END && status2 !== c.Z_OK) { - this.onEnd(status2); - this.ended = true; - return false; + if (route === routes.patchRefreshToken) { + const token2 = headers.authorization?.substr("token ".length); + if (!token2) { + throw new Error( + '[@octokit/oauth-app] "Authorization" header is required' + ); + } + const { refreshToken: refreshToken2 } = json; + if (!refreshToken2) { + throw new Error( + "[@octokit/oauth-app] refreshToken must be sent in request body" + ); + } + const result = await app.refreshToken({ refreshToken: refreshToken2 }); + delete result.authentication.clientSecret; + return { + status: 200, + headers: { + "content-type": "application/json", + "access-control-allow-origin": "*" + }, + text: JSON.stringify(result) + }; } - if (strm.next_out) { - if (strm.avail_out === 0 || status2 === c.Z_STREAM_END || strm.avail_in === 0 && (_mode === c.Z_FINISH || _mode === c.Z_SYNC_FLUSH)) { - if (this.options.to === "string") { - next_out_utf8 = strings.utf8border(strm.output, strm.next_out); - tail = strm.next_out - next_out_utf8; - utf8str = strings.buf2string(strm.output, next_out_utf8); - strm.next_out = tail; - strm.avail_out = chunkSize - tail; - if (tail) { - utils.arraySet(strm.output, strm.output, next_out_utf8, tail, 0); - } - this.onData(utf8str); - } else { - this.onData(utils.shrinkBuf(strm.output, strm.next_out)); - } + if (route === routes.scopeToken) { + const token2 = headers.authorization?.substr("token ".length); + if (!token2) { + throw new Error( + '[@octokit/oauth-app] "Authorization" header is required' + ); } + const result = await app.scopeToken({ + token: token2, + ...json + }); + delete result.authentication.clientSecret; + return { + status: 200, + headers: { + "content-type": "application/json", + "access-control-allow-origin": "*" + }, + text: JSON.stringify(result) + }; } - if (strm.avail_in === 0 && strm.avail_out === 0) { - allowBufError = true; + if (route === routes.deleteToken) { + const token2 = headers.authorization?.substr("token ".length); + if (!token2) { + throw new Error( + '[@octokit/oauth-app] "Authorization" header is required' + ); + } + await app.deleteToken({ + token: token2 + }); + return { + status: 204, + headers: { "access-control-allow-origin": "*" } + }; } - } while ((strm.avail_in > 0 || strm.avail_out === 0) && status2 !== c.Z_STREAM_END); - if (status2 === c.Z_STREAM_END) { - _mode = c.Z_FINISH; + const token = headers.authorization?.substr("token ".length); + if (!token) { + throw new Error( + '[@octokit/oauth-app] "Authorization" header is required' + ); + } + await app.deleteAuthorization({ + token + }); + return { + status: 204, + headers: { "access-control-allow-origin": "*" } + }; + } catch (error) { + return { + status: 400, + headers: { + "content-type": "application/json", + "access-control-allow-origin": "*" + }, + text: JSON.stringify({ error: error.message }) + }; } - if (_mode === c.Z_FINISH) { - status2 = zlib_inflate.inflateEnd(this.strm); - this.onEnd(status2); - this.ended = true; - return status2 === c.Z_OK; + } + function parseRequest(request) { + const { method, url, headers } = request; + async function text() { + const text2 = await new Promise((resolve, reject) => { + let bodyChunks = []; + request.on("error", reject).on("data", (chunk) => bodyChunks.push(chunk)).on("end", () => resolve(Buffer.concat(bodyChunks).toString())); + }); + return text2; } - if (_mode === c.Z_SYNC_FLUSH) { - this.onEnd(c.Z_OK); - strm.avail_out = 0; - return true; + return { method, url, headers, text }; + } + function sendResponse(octokitResponse, response) { + response.writeHead(octokitResponse.status, octokitResponse.headers); + response.end(octokitResponse.text); + } + function createNodeMiddleware2(app, options = {}) { + return async function(request, response, next) { + const octokitRequest = await parseRequest(request); + const octokitResponse = await handleRequest(app, options, octokitRequest); + if (octokitResponse) { + sendResponse(octokitResponse, response); + return true; + } else { + next?.(); + return false; + } + }; + } + function parseRequest2(request) { + const headers = Object.fromEntries(request.headers.entries()); + return { + method: request.method, + url: request.url, + headers, + text: () => request.text() + }; + } + function sendResponse2(octokitResponse) { + return new Response(octokitResponse.text, { + status: octokitResponse.status, + headers: octokitResponse.headers + }); + } + function createWebWorkerHandler(app, options = {}) { + return async function(request) { + const octokitRequest = await parseRequest2(request); + const octokitResponse = await handleRequest(app, options, octokitRequest); + return octokitResponse ? sendResponse2(octokitResponse) : void 0; + }; + } + function parseRequest3(request) { + const { method } = request.requestContext.http; + let url = request.rawPath; + const { stage } = request.requestContext; + if (url.startsWith("/" + stage)) + url = url.substring(stage.length + 1); + if (request.rawQueryString) + url += "?" + request.rawQueryString; + const headers = request.headers; + const text = async () => request.body || ""; + return { method, url, headers, text }; + } + function sendResponse3(octokitResponse) { + return { + statusCode: octokitResponse.status, + headers: octokitResponse.headers, + body: octokitResponse.text + }; + } + function createAWSLambdaAPIGatewayV2Handler(app, options = {}) { + return async function(event) { + const request = parseRequest3(event); + const response = await handleRequest(app, options, request); + return response ? sendResponse3(response) : void 0; + }; + } + var OAuthApp = class { + static { + this.VERSION = VERSION; + } + static defaults(defaults) { + const OAuthAppWithDefaults = class extends this { + constructor(...args) { + super({ + ...defaults, + ...args[0] + }); + } + }; + return OAuthAppWithDefaults; } - return true; - }; - Inflate.prototype.onData = function(chunk) { - this.chunks.push(chunk); - }; - Inflate.prototype.onEnd = function(status2) { - if (status2 === c.Z_OK) { - if (this.options.to === "string") { - this.result = this.chunks.join(""); - } else { - this.result = utils.flattenChunks(this.chunks); - } + constructor(options) { + const Octokit2 = options.Octokit || OAuthAppOctokit; + this.type = options.clientType || "oauth-app"; + const octokit = new Octokit2({ + authStrategy: import_auth_oauth_app.createOAuthAppAuth, + auth: { + clientType: this.type, + clientId: options.clientId, + clientSecret: options.clientSecret + } + }); + const state = { + clientType: this.type, + clientId: options.clientId, + clientSecret: options.clientSecret, + // @ts-expect-error defaultScopes not permitted for GitHub Apps + defaultScopes: options.defaultScopes || [], + allowSignup: options.allowSignup, + baseUrl: options.baseUrl, + redirectUrl: options.redirectUrl, + log: options.log, + Octokit: Octokit2, + octokit, + eventHandlers: {} + }; + this.on = addEventHandler.bind(null, state); + this.octokit = octokit; + this.getUserOctokit = getUserOctokitWithState.bind(null, state); + this.getWebFlowAuthorizationUrl = getWebFlowAuthorizationUrlWithState.bind( + null, + state + ); + this.createToken = createTokenWithState.bind( + null, + state + ); + this.checkToken = checkTokenWithState.bind( + null, + state + ); + this.resetToken = resetTokenWithState.bind( + null, + state + ); + this.refreshToken = refreshTokenWithState.bind( + null, + state + ); + this.scopeToken = scopeTokenWithState.bind( + null, + state + ); + this.deleteToken = deleteTokenWithState.bind(null, state); + this.deleteAuthorization = deleteAuthorizationWithState.bind(null, state); } - this.chunks = []; - this.err = status2; - this.msg = this.strm.msg; }; - function inflate2(input, options) { - var inflator = new Inflate(options); - inflator.push(input, true); - if (inflator.err) { - throw inflator.msg || msg[inflator.err]; - } - return inflator.result; - } - function inflateRaw(input, options) { - options = options || {}; - options.raw = true; - return inflate2(input, options); - } - exports2.Inflate = Inflate; - exports2.inflate = inflate2; - exports2.inflateRaw = inflateRaw; - exports2.ungzip = inflate2; - } -}); - -// ../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/index.js -var require_pako = __commonJS({ - "../../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/index.js"(exports2, module2) { - "use strict"; - var assign = require_common().assign; - var deflate2 = require_deflate2(); - var inflate2 = require_inflate2(); - var constants = require_constants7(); - var pako2 = {}; - assign(pako2, deflate2, inflate2, constants); - module2.exports = pako2; } }); -// ../../../node_modules/.pnpm/pify@5.0.0/node_modules/pify/index.js -var require_pify = __commonJS({ - "../../../node_modules/.pnpm/pify@5.0.0/node_modules/pify/index.js"(exports2, module2) { +// ../../../node_modules/.pnpm/indent-string@4.0.0/node_modules/indent-string/index.js +var require_indent_string = __commonJS({ + "../../../node_modules/.pnpm/indent-string@4.0.0/node_modules/indent-string/index.js"(exports2, module2) { "use strict"; - var processFn = (fn, options, proxy, unwrapped) => function(...arguments_) { - const P = options.promiseModule; - return new P((resolve, reject) => { - if (options.multiArgs) { - arguments_.push((...result) => { - if (options.errorFirst) { - if (result[0]) { - reject(result); - } else { - result.shift(); - resolve(result); - } - } else { - resolve(result); - } - }); - } else if (options.errorFirst) { - arguments_.push((error, result) => { - if (error) { - reject(error); - } else { - resolve(result); - } - }); - } else { - arguments_.push(resolve); - } - const self2 = this === proxy ? unwrapped : this; - Reflect.apply(fn, self2, arguments_); - }); - }; - var filterCache = /* @__PURE__ */ new WeakMap(); - module2.exports = (input, options) => { + module2.exports = (string, count = 1, options) => { options = { - exclude: [/.+(?:Sync|Stream)$/], - errorFirst: true, - promiseModule: Promise, + indent: " ", + includeEmptyLines: false, ...options }; - const objectType = typeof input; - if (!(input !== null && (objectType === "object" || objectType === "function"))) { - throw new TypeError(`Expected \`input\` to be a \`Function\` or \`Object\`, got \`${input === null ? "null" : objectType}\``); + if (typeof string !== "string") { + throw new TypeError( + `Expected \`input\` to be a \`string\`, got \`${typeof string}\`` + ); } - const filter = (target, key) => { - let cached = filterCache.get(target); - if (!cached) { - cached = {}; - filterCache.set(target, cached); + if (typeof count !== "number") { + throw new TypeError( + `Expected \`count\` to be a \`number\`, got \`${typeof count}\`` + ); + } + if (typeof options.indent !== "string") { + throw new TypeError( + `Expected \`options.indent\` to be a \`string\`, got \`${typeof options.indent}\`` + ); + } + if (count === 0) { + return string; + } + const regex = options.includeEmptyLines ? /^/gm : /^(?!\s*$)/gm; + return string.replace(regex, options.indent.repeat(count)); + }; + } +}); + +// ../../../node_modules/.pnpm/clean-stack@2.2.0/node_modules/clean-stack/index.js +var require_clean_stack = __commonJS({ + "../../../node_modules/.pnpm/clean-stack@2.2.0/node_modules/clean-stack/index.js"(exports2, module2) { + "use strict"; + var os = require("os"); + var extractPathRegex = /\s+at.*(?:\(|\s)(.*)\)?/; + var pathRegex = /^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:babel-polyfill|pirates)\/.*)?\w+)\.js:\d+:\d+)|native)/; + var homeDir = typeof os.homedir === "undefined" ? "" : os.homedir(); + module2.exports = (stack, options) => { + options = Object.assign({ pretty: false }, options); + return stack.replace(/\\/g, "/").split("\n").filter((line) => { + const pathMatches = line.match(extractPathRegex); + if (pathMatches === null || !pathMatches[1]) { + return true; } - if (key in cached) { - return cached[key]; + const match = pathMatches[1]; + if (match.includes(".app/Contents/Resources/electron.asar") || match.includes(".app/Contents/Resources/default_app.asar")) { + return false; } - const match = (pattern2) => typeof pattern2 === "string" || typeof key === "symbol" ? key === pattern2 : pattern2.test(key); - const desc = Reflect.getOwnPropertyDescriptor(target, key); - const writableOrConfigurableOwn = desc === void 0 || desc.writable || desc.configurable; - const included = options.include ? options.include.some(match) : !options.exclude.some(match); - const shouldFilter = included && writableOrConfigurableOwn; - cached[key] = shouldFilter; - return shouldFilter; - }; - const cache = /* @__PURE__ */ new WeakMap(); - const proxy = new Proxy(input, { - apply(target, thisArg, args) { - const cached = cache.get(target); - if (cached) { - return Reflect.apply(cached, thisArg, args); - } - const pified = options.excludeMain ? target : processFn(target, options, proxy, target); - cache.set(target, pified); - return Reflect.apply(pified, thisArg, args); - }, - get(target, key) { - const property = target[key]; - if (!filter(target, key) || property === Function.prototype[key]) { - return property; - } - const cached = cache.get(property); - if (cached) { - return cached; - } - if (typeof property === "function") { - const pified = processFn(property, options, proxy, target); - cache.set(property, pified); - return pified; - } - return property; + return !pathRegex.test(match); + }).filter((line) => line.trim() !== "").map((line) => { + if (options.pretty) { + return line.replace(extractPathRegex, (m, p1) => m.replace(p1, p1.replace(homeDir, "~"))); } - }); - return proxy; + return line; + }).join("\n"); }; } }); -// ../../../node_modules/.pnpm/ignore@5.3.1/node_modules/ignore/index.js -var require_ignore = __commonJS({ - "../../../node_modules/.pnpm/ignore@5.3.1/node_modules/ignore/index.js"(exports2, module2) { - function makeArray(subject) { - return Array.isArray(subject) ? subject : [subject]; - } - var EMPTY = ""; - var SPACE = " "; - var ESCAPE = "\\"; - var REGEX_TEST_BLANK_LINE = /^\s+$/; - var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/; - var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/; - var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/; - var REGEX_SPLITALL_CRLF = /\r?\n/g; - var REGEX_TEST_INVALID_PATH = /^\.*\/|^\.+$/; - var SLASH = "/"; - var TMP_KEY_IGNORE = "node-ignore"; - if (typeof Symbol !== "undefined") { - TMP_KEY_IGNORE = Symbol.for("node-ignore"); - } - var KEY_IGNORE = TMP_KEY_IGNORE; - var define2 = (object, key, value) => Object.defineProperty(object, key, { value }); - var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g; - var RETURN_FALSE = () => false; - var sanitizeRange = (range) => range.replace( - REGEX_REGEXP_RANGE, - (match, from3, to) => from3.charCodeAt(0) <= to.charCodeAt(0) ? match : EMPTY - ); - var cleanRangeBackSlash = (slashes) => { - const { length } = slashes; - return slashes.slice(0, length - length % 2); - }; - var REPLACERS = [ - [ - // remove BOM - // TODO: - // Other similar zero-width characters? - /^\uFEFF/, - () => EMPTY - ], - // > Trailing spaces are ignored unless they are quoted with backslash ("\") - [ - // (a\ ) -> (a ) - // (a ) -> (a) - // (a \ ) -> (a ) - /\\?\s+$/, - (match) => match.indexOf("\\") === 0 ? SPACE : EMPTY - ], - // replace (\ ) with ' ' - [ - /\\\s/g, - () => SPACE - ], - // Escape metacharacters - // which is written down by users but means special for regular expressions. - // > There are 12 characters with special meanings: - // > - the backslash \, - // > - the caret ^, - // > - the dollar sign $, - // > - the period or dot ., - // > - the vertical bar or pipe symbol |, - // > - the question mark ?, - // > - the asterisk or star *, - // > - the plus sign +, - // > - the opening parenthesis (, - // > - the closing parenthesis ), - // > - and the opening square bracket [, - // > - the opening curly brace {, - // > These special characters are often called "metacharacters". - [ - /[\\$.|*+(){^]/g, - (match) => `\\${match}` - ], - [ - // > a question mark (?) matches a single character - /(?!\\)\?/g, - () => "[^/]" - ], - // leading slash - [ - // > A leading slash matches the beginning of the pathname. - // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c". - // A leading slash matches the beginning of the pathname - /^\//, - () => "^" - ], - // replace special metacharacter slash after the leading slash - [ - /\//g, - () => "\\/" - ], - [ - // > A leading "**" followed by a slash means match in all directories. - // > For example, "**/foo" matches file or directory "foo" anywhere, - // > the same as pattern "foo". - // > "**/foo/bar" matches file or directory "bar" anywhere that is directly - // > under directory "foo". - // Notice that the '*'s have been replaced as '\\*' - /^\^*\\\*\\\*\\\//, - // '**/foo' <-> 'foo' - () => "^(?:.*\\/)?" - ], - // starting - [ - // there will be no leading '/' - // (which has been replaced by section "leading slash") - // If starts with '**', adding a '^' to the regular expression also works - /^(?=[^^])/, - function startingReplacer() { - return !/\/(?!$)/.test(this) ? "(?:^|\\/)" : "^"; - } - ], - // two globstars - [ - // Use lookahead assertions so that we could match more than one `'/**'` - /\\\/\\\*\\\*(?=\\\/|$)/g, - // Zero, one or several directories - // should not use '*', or it will be replaced by the next replacer - // Check if it is not the last `'/**'` - (_, index2, str) => index2 + 6 < str.length ? "(?:\\/[^\\/]+)*" : "\\/.+" - ], - // normal intermediate wildcards - [ - // Never replace escaped '*' - // ignore rule '\*' will match the path '*' - // 'abc.*/' -> go - // 'abc.*' -> skip this rule, - // coz trailing single wildcard will be handed by [trailing wildcard] - /(^|[^\\]+)(\\\*)+(?=.+)/g, - // '*.js' matches '.js' - // '*.js' doesn't match 'abc' - (_, p1, p2) => { - const unescaped = p2.replace(/\\\*/g, "[^\\/]*"); - return p1 + unescaped; +// ../../../node_modules/.pnpm/aggregate-error@3.1.0/node_modules/aggregate-error/index.js +var require_aggregate_error = __commonJS({ + "../../../node_modules/.pnpm/aggregate-error@3.1.0/node_modules/aggregate-error/index.js"(exports2, module2) { + "use strict"; + var indentString = require_indent_string(); + var cleanStack = require_clean_stack(); + var cleanInternalStack = (stack) => stack.replace(/\s+at .*aggregate-error\/index.js:\d+:\d+\)?/g, ""); + var AggregateError = class extends Error { + constructor(errors) { + if (!Array.isArray(errors)) { + throw new TypeError(`Expected input to be an Array, got ${typeof errors}`); } - ], - [ - // unescape, revert step 3 except for back slash - // For example, if a user escape a '\\*', - // after step 3, the result will be '\\\\\\*' - /\\\\\\(?=[$.|*+(){^])/g, - () => ESCAPE - ], - [ - // '\\\\' -> '\\' - /\\\\/g, - () => ESCAPE - ], - [ - // > The range notation, e.g. [a-zA-Z], - // > can be used to match one of the characters in a range. - // `\` is escaped by step 3 - /(\\)?\[([^\]/]*?)(\\*)($|\])/g, - (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` : close === "]" ? endEscape.length % 2 === 0 ? `[${sanitizeRange(range)}${endEscape}]` : "[]" : "[]" - ], - // ending - [ - // 'js' will not match 'js.' - // 'ab' will not match 'abc' - /(?:[^*])$/, - // WTF! - // https://git-scm.com/docs/gitignore - // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1) - // which re-fixes #24, #38 - // > If there is a separator at the end of the pattern then the pattern - // > will only match directories, otherwise the pattern can match both - // > files and directories. - // 'js*' will not match 'a.js' - // 'js/' will not match 'a.js' - // 'js' will match 'a.js' and 'a.js/' - (match) => /\/$/.test(match) ? `${match}$` : `${match}(?=$|\\/$)` - ], - // trailing wildcard - [ - /(\^|\\\/)?\\\*$/, - (_, p1) => { - const prefix = p1 ? `${p1}[^/]+` : "[^/]*"; - return `${prefix}(?=$|\\/$)`; + errors = [...errors].map((error) => { + if (error instanceof Error) { + return error; + } + if (error !== null && typeof error === "object") { + return Object.assign(new Error(error.message), error); + } + return new Error(error); + }); + let message = errors.map((error) => { + return typeof error.stack === "string" ? cleanInternalStack(cleanStack(error.stack)) : String(error); + }).join("\n"); + message = "\n" + indentString(message, 4); + super(message); + this.name = "AggregateError"; + Object.defineProperty(this, "_errors", { value: errors }); + } + *[Symbol.iterator]() { + for (const error of this._errors) { + yield error; } - ] - ]; - var regexCache = /* @__PURE__ */ Object.create(null); - var makeRegex = (pattern2, ignoreCase) => { - let source = regexCache[pattern2]; - if (!source) { - source = REPLACERS.reduce( - (prev, current) => prev.replace(current[0], current[1].bind(pattern2)), - pattern2 - ); - regexCache[pattern2] = source; } - return ignoreCase ? new RegExp(source, "i") : new RegExp(source); }; - var isString = (subject) => typeof subject === "string"; - var checkPattern = (pattern2) => pattern2 && isString(pattern2) && !REGEX_TEST_BLANK_LINE.test(pattern2) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern2) && pattern2.indexOf("#") !== 0; - var splitPattern = (pattern2) => pattern2.split(REGEX_SPLITALL_CRLF); - var IgnoreRule = class { - constructor(origin, pattern2, negative, regex) { - this.origin = origin; - this.pattern = pattern2; - this.negative = negative; - this.regex = regex; - } + module2.exports = AggregateError; + } +}); + +// ../../../node_modules/.pnpm/@octokit+webhooks-methods@4.1.0/node_modules/@octokit/webhooks-methods/dist-node/index.js +var require_dist_node23 = __commonJS({ + "../../../node_modules/.pnpm/@octokit+webhooks-methods@4.1.0/node_modules/@octokit/webhooks-methods/dist-node/index.js"(exports2, module2) { + "use strict"; + var __defProp2 = Object.defineProperty; + var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; + var __getOwnPropNames2 = Object.getOwnPropertyNames; + var __hasOwnProp2 = Object.prototype.hasOwnProperty; + var __export2 = (target, all) => { + for (var name in all) + __defProp2(target, name, { get: all[name], enumerable: true }); }; - var createRule = (pattern2, ignoreCase) => { - const origin = pattern2; - let negative = false; - if (pattern2.indexOf("!") === 0) { - negative = true; - pattern2 = pattern2.substr(1); + var __copyProps2 = (to, from2, except, desc) => { + if (from2 && typeof from2 === "object" || typeof from2 === "function") { + for (let key of __getOwnPropNames2(from2)) + if (!__hasOwnProp2.call(to, key) && key !== except) + __defProp2(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc2(from2, key)) || desc.enumerable }); } - pattern2 = pattern2.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#"); - const regex = makeRegex(pattern2, ignoreCase); - return new IgnoreRule( - origin, - pattern2, - negative, - regex - ); - }; - var throwError = (message, Ctor) => { - throw new Ctor(message); + return to; }; - var checkPath = (path, originalPath, doThrow) => { - if (!isString(path)) { - return doThrow( - `path must be a string, but got \`${originalPath}\``, - TypeError + var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); + var dist_src_exports = {}; + __export2(dist_src_exports, { + sign: () => sign, + verify: () => verify, + verifyWithFallback: () => verifyWithFallback + }); + module2.exports = __toCommonJS2(dist_src_exports); + var import_node_crypto = require("node:crypto"); + var Algorithm = /* @__PURE__ */ ((Algorithm2) => { + Algorithm2["SHA1"] = "sha1"; + Algorithm2["SHA256"] = "sha256"; + return Algorithm2; + })(Algorithm || {}); + var VERSION = "4.1.0"; + async function sign(options, payload) { + const { secret, algorithm } = typeof options === "object" ? { + secret: options.secret, + algorithm: options.algorithm || Algorithm.SHA256 + } : { secret: options, algorithm: Algorithm.SHA256 }; + if (!secret || !payload) { + throw new TypeError( + "[@octokit/webhooks-methods] secret & payload required for sign()" ); } - if (!path) { - return doThrow(`path must not be empty`, TypeError); + if (typeof payload !== "string") { + throw new TypeError("[@octokit/webhooks-methods] payload must be a string"); } - if (checkPath.isNotRelative(path)) { - const r = "`path.relative()`d"; - return doThrow( - `path should be a ${r} string, but got "${originalPath}"`, - RangeError + if (!Object.values(Algorithm).includes(algorithm)) { + throw new TypeError( + `[@octokit/webhooks] Algorithm ${algorithm} is not supported. Must be 'sha1' or 'sha256'` ); } - return true; + return `${algorithm}=${(0, import_node_crypto.createHmac)(algorithm, secret).update(payload).digest("hex")}`; + } + sign.VERSION = VERSION; + var import_node_crypto2 = require("node:crypto"); + var import_node_buffer = require("node:buffer"); + var getAlgorithm = (signature) => { + return signature.startsWith("sha256=") ? "sha256" : "sha1"; }; - var isNotRelative = (path) => REGEX_TEST_INVALID_PATH.test(path); - checkPath.isNotRelative = isNotRelative; - checkPath.convert = (p) => p; - var Ignore = class { - constructor({ - ignorecase = true, - ignoreCase = ignorecase, - allowRelativePaths = false - } = {}) { - define2(this, KEY_IGNORE, true); - this._rules = []; - this._ignoreCase = ignoreCase; - this._allowRelativePaths = allowRelativePaths; - this._initCache(); - } - _initCache() { - this._ignoreCache = /* @__PURE__ */ Object.create(null); - this._testCache = /* @__PURE__ */ Object.create(null); + async function verify(secret, eventPayload, signature) { + if (!secret || !eventPayload || !signature) { + throw new TypeError( + "[@octokit/webhooks-methods] secret, eventPayload & signature required" + ); } - _addPattern(pattern2) { - if (pattern2 && pattern2[KEY_IGNORE]) { - this._rules = this._rules.concat(pattern2._rules); - this._added = true; - return; - } - if (checkPattern(pattern2)) { - const rule = createRule(pattern2, this._ignoreCase); - this._added = true; - this._rules.push(rule); - } + if (typeof eventPayload !== "string") { + throw new TypeError( + "[@octokit/webhooks-methods] eventPayload must be a string" + ); } - // @param {Array | string | Ignore} pattern - add(pattern2) { - this._added = false; - makeArray( - isString(pattern2) ? splitPattern(pattern2) : pattern2 - ).forEach(this._addPattern, this); - if (this._added) { - this._initCache(); - } - return this; + const signatureBuffer = import_node_buffer.Buffer.from(signature); + const algorithm = getAlgorithm(signature); + const verificationBuffer = import_node_buffer.Buffer.from( + await sign({ secret, algorithm }, eventPayload) + ); + if (signatureBuffer.length !== verificationBuffer.length) { + return false; } - // legacy - addPattern(pattern2) { - return this.add(pattern2); + return (0, import_node_crypto2.timingSafeEqual)(signatureBuffer, verificationBuffer); + } + verify.VERSION = VERSION; + async function verifyWithFallback(secret, payload, signature, additionalSecrets) { + const firstPass = await verify(secret, payload, signature); + if (firstPass) { + return true; } - // | ignored : unignored - // negative | 0:0 | 0:1 | 1:0 | 1:1 - // -------- | ------- | ------- | ------- | -------- - // 0 | TEST | TEST | SKIP | X - // 1 | TESTIF | SKIP | TEST | X - // - SKIP: always skip - // - TEST: always test - // - TESTIF: only test if checkUnignored - // - X: that never happen - // @param {boolean} whether should check if the path is unignored, - // setting `checkUnignored` to `false` could reduce additional - // path matching. - // @returns {TestResult} true if a file is ignored - _testOne(path, checkUnignored) { - let ignored = false; - let unignored = false; - this._rules.forEach((rule) => { - const { negative } = rule; - if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) { - return; - } - const matched = rule.regex.test(path); - if (matched) { - ignored = !negative; - unignored = negative; + if (additionalSecrets !== void 0) { + for (const s of additionalSecrets) { + const v = await verify(s, payload, signature); + if (v) { + return v; } - }); - return { - ignored, - unignored - }; - } - // @returns {TestResult} - _test(originalPath, cache, checkUnignored, slices) { - const path = originalPath && checkPath.convert(originalPath); - checkPath( - path, - originalPath, - this._allowRelativePaths ? RETURN_FALSE : throwError - ); - return this._t(path, cache, checkUnignored, slices); - } - _t(path, cache, checkUnignored, slices) { - if (path in cache) { - return cache[path]; - } - if (!slices) { - slices = path.split(SLASH); } - slices.pop(); - if (!slices.length) { - return cache[path] = this._testOne(path, checkUnignored); - } - const parent = this._t( - slices.join(SLASH) + SLASH, - cache, - checkUnignored, - slices - ); - return cache[path] = parent.ignored ? parent : this._testOne(path, checkUnignored); } - ignores(path) { - return this._test(path, this._ignoreCache, false).ignored; + return false; + } + } +}); + +// ../../../node_modules/.pnpm/@octokit+webhooks@12.2.0/node_modules/@octokit/webhooks/dist-node/index.js +var require_dist_node24 = __commonJS({ + "../../../node_modules/.pnpm/@octokit+webhooks@12.2.0/node_modules/@octokit/webhooks/dist-node/index.js"(exports2, module2) { + "use strict"; + var __create2 = Object.create; + var __defProp2 = Object.defineProperty; + var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; + var __getOwnPropNames2 = Object.getOwnPropertyNames; + var __getProtoOf2 = Object.getPrototypeOf; + var __hasOwnProp2 = Object.prototype.hasOwnProperty; + var __export2 = (target, all) => { + for (var name in all) + __defProp2(target, name, { get: all[name], enumerable: true }); + }; + var __copyProps2 = (to, from2, except, desc) => { + if (from2 && typeof from2 === "object" || typeof from2 === "function") { + for (let key of __getOwnPropNames2(from2)) + if (!__hasOwnProp2.call(to, key) && key !== except) + __defProp2(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc2(from2, key)) || desc.enumerable }); } - createFilter() { - return (path) => !this.ignores(path); + return to; + }; + var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target, + mod + )); + var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); + var dist_src_exports = {}; + __export2(dist_src_exports, { + Webhooks: () => Webhooks, + createEventHandler: () => createEventHandler, + createNodeMiddleware: () => createNodeMiddleware2, + emitterEventNames: () => emitterEventNames + }); + module2.exports = __toCommonJS2(dist_src_exports); + var createLogger = (logger) => ({ + debug: () => { + }, + info: () => { + }, + warn: console.warn.bind(console), + error: console.error.bind(console), + ...logger + }); + var emitterEventNames = [ + "branch_protection_configuration", + "branch_protection_rule.disabled", + "branch_protection_rule.enabled", + "branch_protection_rule", + "branch_protection_rule.created", + "branch_protection_rule.deleted", + "branch_protection_rule.edited", + "check_run", + "check_run.completed", + "check_run.created", + "check_run.requested_action", + "check_run.rerequested", + "check_suite", + "check_suite.completed", + "check_suite.requested", + "check_suite.rerequested", + "code_scanning_alert", + "code_scanning_alert.appeared_in_branch", + "code_scanning_alert.closed_by_user", + "code_scanning_alert.created", + "code_scanning_alert.fixed", + "code_scanning_alert.reopened", + "code_scanning_alert.reopened_by_user", + "commit_comment", + "commit_comment.created", + "create", + "custom_property", + "custom_property.created", + "custom_property.deleted", + "custom_property_values", + "custom_property_values.updated", + "delete", + "dependabot_alert", + "dependabot_alert.created", + "dependabot_alert.dismissed", + "dependabot_alert.fixed", + "dependabot_alert.reintroduced", + "dependabot_alert.reopened", + "deploy_key", + "deploy_key.created", + "deploy_key.deleted", + "deployment", + "deployment.created", + "deployment_protection_rule", + "deployment_protection_rule.requested", + "deployment_review", + "deployment_review.approved", + "deployment_review.rejected", + "deployment_review.requested", + "deployment_status", + "deployment_status.created", + "discussion", + "discussion.answered", + "discussion.category_changed", + "discussion.created", + "discussion.deleted", + "discussion.edited", + "discussion.labeled", + "discussion.locked", + "discussion.pinned", + "discussion.transferred", + "discussion.unanswered", + "discussion.unlabeled", + "discussion.unlocked", + "discussion.unpinned", + "discussion_comment", + "discussion_comment.created", + "discussion_comment.deleted", + "discussion_comment.edited", + "fork", + "github_app_authorization", + "github_app_authorization.revoked", + "gollum", + "installation", + "installation.created", + "installation.deleted", + "installation.new_permissions_accepted", + "installation.suspend", + "installation.unsuspend", + "installation_repositories", + "installation_repositories.added", + "installation_repositories.removed", + "installation_target", + "installation_target.renamed", + "issue_comment", + "issue_comment.created", + "issue_comment.deleted", + "issue_comment.edited", + "issues", + "issues.assigned", + "issues.closed", + "issues.deleted", + "issues.demilestoned", + "issues.edited", + "issues.labeled", + "issues.locked", + "issues.milestoned", + "issues.opened", + "issues.pinned", + "issues.reopened", + "issues.transferred", + "issues.unassigned", + "issues.unlabeled", + "issues.unlocked", + "issues.unpinned", + "label", + "label.created", + "label.deleted", + "label.edited", + "marketplace_purchase", + "marketplace_purchase.cancelled", + "marketplace_purchase.changed", + "marketplace_purchase.pending_change", + "marketplace_purchase.pending_change_cancelled", + "marketplace_purchase.purchased", + "member", + "member.added", + "member.edited", + "member.removed", + "membership", + "membership.added", + "membership.removed", + "merge_group", + "merge_group.checks_requested", + "meta", + "meta.deleted", + "milestone", + "milestone.closed", + "milestone.created", + "milestone.deleted", + "milestone.edited", + "milestone.opened", + "org_block", + "org_block.blocked", + "org_block.unblocked", + "organization", + "organization.deleted", + "organization.member_added", + "organization.member_invited", + "organization.member_removed", + "organization.renamed", + "package", + "package.published", + "package.updated", + "page_build", + "ping", + "project", + "project.closed", + "project.created", + "project.deleted", + "project.edited", + "project.reopened", + "project_card", + "project_card.converted", + "project_card.created", + "project_card.deleted", + "project_card.edited", + "project_card.moved", + "project_column", + "project_column.created", + "project_column.deleted", + "project_column.edited", + "project_column.moved", + "projects_v2_item", + "projects_v2_item.archived", + "projects_v2_item.converted", + "projects_v2_item.created", + "projects_v2_item.deleted", + "projects_v2_item.edited", + "projects_v2_item.reordered", + "projects_v2_item.restored", + "public", + "pull_request", + "pull_request.assigned", + "pull_request.auto_merge_disabled", + "pull_request.auto_merge_enabled", + "pull_request.closed", + "pull_request.converted_to_draft", + "pull_request.demilestoned", + "pull_request.dequeued", + "pull_request.edited", + "pull_request.enqueued", + "pull_request.labeled", + "pull_request.locked", + "pull_request.milestoned", + "pull_request.opened", + "pull_request.ready_for_review", + "pull_request.reopened", + "pull_request.review_request_removed", + "pull_request.review_requested", + "pull_request.synchronize", + "pull_request.unassigned", + "pull_request.unlabeled", + "pull_request.unlocked", + "pull_request_review", + "pull_request_review.dismissed", + "pull_request_review.edited", + "pull_request_review.submitted", + "pull_request_review_comment", + "pull_request_review_comment.created", + "pull_request_review_comment.deleted", + "pull_request_review_comment.edited", + "pull_request_review_thread", + "pull_request_review_thread.resolved", + "pull_request_review_thread.unresolved", + "push", + "registry_package", + "registry_package.published", + "registry_package.updated", + "release", + "release.created", + "release.deleted", + "release.edited", + "release.prereleased", + "release.published", + "release.released", + "release.unpublished", + "repository", + "repository.archived", + "repository.created", + "repository.deleted", + "repository.edited", + "repository.privatized", + "repository.publicized", + "repository.renamed", + "repository.transferred", + "repository.unarchived", + "repository_dispatch", + "repository_import", + "repository_vulnerability_alert", + "repository_vulnerability_alert.create", + "repository_vulnerability_alert.dismiss", + "repository_vulnerability_alert.reopen", + "repository_vulnerability_alert.resolve", + "secret_scanning_alert", + "secret_scanning_alert.created", + "secret_scanning_alert.reopened", + "secret_scanning_alert.resolved", + "secret_scanning_alert.revoked", + "secret_scanning_alert_location", + "secret_scanning_alert_location.created", + "security_advisory", + "security_advisory.performed", + "security_advisory.published", + "security_advisory.updated", + "security_advisory.withdrawn", + "sponsorship", + "sponsorship.cancelled", + "sponsorship.created", + "sponsorship.edited", + "sponsorship.pending_cancellation", + "sponsorship.pending_tier_change", + "sponsorship.tier_changed", + "star", + "star.created", + "star.deleted", + "status", + "team", + "team.added_to_repository", + "team.created", + "team.deleted", + "team.edited", + "team.removed_from_repository", + "team_add", + "watch", + "watch.started", + "workflow_dispatch", + "workflow_job", + "workflow_job.completed", + "workflow_job.in_progress", + "workflow_job.queued", + "workflow_job.waiting", + "workflow_run", + "workflow_run.completed", + "workflow_run.in_progress", + "workflow_run.requested" + ]; + function handleEventHandlers(state, webhookName, handler) { + if (!state.hooks[webhookName]) { + state.hooks[webhookName] = []; } - filter(paths) { - return makeArray(paths).filter(this.createFilter()); + state.hooks[webhookName].push(handler); + } + function receiverOn(state, webhookNameOrNames, handler) { + if (Array.isArray(webhookNameOrNames)) { + webhookNameOrNames.forEach( + (webhookName) => receiverOn(state, webhookName, handler) + ); + return; } - // @returns {TestResult} - test(path) { - return this._test(path, this._testCache, true); + if (["*", "error"].includes(webhookNameOrNames)) { + const webhookName = webhookNameOrNames === "*" ? "any" : webhookNameOrNames; + const message = `Using the "${webhookNameOrNames}" event with the regular Webhooks.on() function is not supported. Please use the Webhooks.on${webhookName.charAt(0).toUpperCase() + webhookName.slice(1)}() method instead`; + throw new Error(message); } - }; - var factory = (options) => new Ignore(options); - var isPathValid = (path) => checkPath(path && checkPath.convert(path), path, RETURN_FALSE); - factory.isPathValid = isPathValid; - factory.default = factory; - module2.exports = factory; - if ( - // Detect `process` so that it can run in browsers. - typeof process !== "undefined" && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === "win32") - ) { - const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/"); - checkPath.convert = makePosix; - const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i; - checkPath.isNotRelative = (path) => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path) || isNotRelative(path); + if (!emitterEventNames.includes(webhookNameOrNames)) { + state.log.warn( + `"${webhookNameOrNames}" is not a known webhook name (https://developer.github.com/v3/activity/events/types/)` + ); + } + handleEventHandlers(state, webhookNameOrNames, handler); } - } -}); - -// ../../../node_modules/.pnpm/clean-git-ref@2.0.1/node_modules/clean-git-ref/lib/index.js -var require_lib3 = __commonJS({ - "../../../node_modules/.pnpm/clean-git-ref@2.0.1/node_modules/clean-git-ref/lib/index.js"(exports2, module2) { - "use strict"; - function escapeRegExp(string) { - return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); + function receiverOnAny(state, handler) { + handleEventHandlers(state, "*", handler); } - function replaceAll(str, search, replacement) { - search = search instanceof RegExp ? search : new RegExp(escapeRegExp(search), "g"); - return str.replace(search, replacement); + function receiverOnError(state, handler) { + handleEventHandlers(state, "error", handler); } - var CleanGitRef = { - clean: function clean(value) { - if (typeof value !== "string") { - throw new Error("Expected a string, received: " + value); - } - value = replaceAll(value, "./", "/"); - value = replaceAll(value, "..", "."); - value = replaceAll(value, " ", "-"); - value = replaceAll(value, /^[~^:?*\\\-]/g, ""); - value = replaceAll(value, /[~^:?*\\]/g, "-"); - value = replaceAll(value, /[~^:?*\\\-]$/g, ""); - value = replaceAll(value, "@{", "-"); - value = replaceAll(value, /\.$/g, ""); - value = replaceAll(value, /\/$/g, ""); - value = replaceAll(value, /\.lock$/g, ""); - return value; + var import_aggregate_error = __toESM2(require_aggregate_error()); + function wrapErrorHandler(handler, error) { + let returnValue; + try { + returnValue = handler(error); + } catch (error2) { + console.log('FATAL: Error occurred in "error" event handler'); + console.log(error2); } - }; - module2.exports = CleanGitRef; - } -}); - -// ../../../node_modules/.pnpm/diff3@0.0.4/node_modules/diff3/onp.js -var require_onp = __commonJS({ - "../../../node_modules/.pnpm/diff3@0.0.4/node_modules/diff3/onp.js"(exports2, module2) { - module2.exports = function(a_, b_) { - var a = a_, b = b_, m = a.length, n = b.length, reverse = false, offset = m + 1, path = [], pathposi = []; - var tmp1, tmp2; - var init2 = function() { - if (m >= n) { - tmp1 = a; - tmp2 = m; - a = b; - b = tmp1; - m = n; - n = tmp2; - reverse = true; - offset = m + 1; - } - }; - var P = function(startX, startY, endX, endY, r) { - return { - startX, - startY, - endX, - endY, - r - }; - }; - var snake = function(k, p, pp) { - var r, x, y, startX, startY; - if (p > pp) { - r = path[k - 1 + offset]; - } else { - r = path[k + 1 + offset]; - } - startY = y = Math.max(p, pp); - startX = x = y - k; - while (x < m && y < n && a[x] === b[y]) { - ++x; - ++y; - } - if (startX == x && startY == y) { - path[k + offset] = r; - } else { - path[k + offset] = pathposi.length; - pathposi[pathposi.length] = new P(startX, startY, x, y, r); - } - return y; - }; - init2(); - return { - compose: function() { - var delta, size, fp, p, r, i, k, lastStartX, lastStartY, result; - delta = n - m; - size = m + n + 3; - fp = {}; - for (i = 0; i < size; ++i) { - fp[i] = -1; - path[i] = -1; - } - p = -1; - do { - ++p; - for (k = -p; k <= delta - 1; ++k) { - fp[k + offset] = snake(k, fp[k - 1 + offset] + 1, fp[k + 1 + offset]); - } - for (k = delta + p; k >= delta + 1; --k) { - fp[k + offset] = snake(k, fp[k - 1 + offset] + 1, fp[k + 1 + offset]); - } - fp[delta + offset] = snake(delta, fp[delta - 1 + offset] + 1, fp[delta + 1 + offset]); - } while (fp[delta + offset] !== n); - ed = delta + 2 * p; - r = path[delta + offset]; - lastStartX = m; - lastStartY = n; - result = []; - while (r !== -1) { - let elem = pathposi[r]; - if (m != elem.endX || n != elem.endY) { - result.push({ - file1: [ - reverse ? elem.endY : elem.endX, - reverse ? lastStartY - elem.endY : lastStartX - elem.endX - ], - file2: [ - reverse ? elem.endX : elem.endY, - reverse ? lastStartX - elem.endX : lastStartY - elem.endY - ] - }); - } - lastStartX = elem.startX; - lastStartY = elem.startY; - r = pathposi[r].r; - } - if (lastStartX != 0 || lastStartY != 0) { - result.push({ - file1: [0, reverse ? lastStartY : lastStartX], - file2: [0, reverse ? lastStartX : lastStartY] - }); - } - result.reverse(); - return result; - } - }; - }; - } -}); - -// ../../../node_modules/.pnpm/diff3@0.0.4/node_modules/diff3/diff3.js -var require_diff3 = __commonJS({ - "../../../node_modules/.pnpm/diff3@0.0.4/node_modules/diff3/diff3.js"(exports2, module2) { - var onp = require_onp(); - function diff3MergeIndices(a, o, b) { - var i; - var m1 = new onp(o, a).compose(); - var m2 = new onp(o, b).compose(); - var hunks = []; - function addHunk(h, side2) { - hunks.push([h.file1[0], side2, h.file1[1], h.file2[0], h.file2[1]]); + if (returnValue && returnValue.catch) { + returnValue.catch((error2) => { + console.log('FATAL: Error occurred in "error" event handler'); + console.log(error2); + }); } - for (i = 0; i < m1.length; i++) { - addHunk(m1[i], 0); + } + function getHooks(state, eventPayloadAction, eventName) { + const hooks = [state.hooks[eventName], state.hooks["*"]]; + if (eventPayloadAction) { + hooks.unshift(state.hooks[`${eventName}.${eventPayloadAction}`]); } - for (i = 0; i < m2.length; i++) { - addHunk(m2[i], 2); + return [].concat(...hooks.filter(Boolean)); + } + function receiverHandle(state, event) { + const errorHandlers = state.hooks.error || []; + if (event instanceof Error) { + const error = Object.assign(new import_aggregate_error.default([event]), { + event, + errors: [event] + }); + errorHandlers.forEach((handler) => wrapErrorHandler(handler, error)); + return Promise.reject(error); } - hunks.sort(function(x, y) { - return x[0] - y[0]; - }); - var result = []; - var commonOffset = 0; - function copyCommon(targetOffset) { - if (targetOffset > commonOffset) { - result.push([1, commonOffset, targetOffset - commonOffset]); - commonOffset = targetOffset; - } + if (!event || !event.name) { + throw new import_aggregate_error.default(["Event name not passed"]); } - for (var hunkIndex = 0; hunkIndex < hunks.length; hunkIndex++) { - var firstHunkIndex = hunkIndex; - var hunk = hunks[hunkIndex]; - var regionLhs = hunk[0]; - var regionRhs = regionLhs + hunk[2]; - while (hunkIndex < hunks.length - 1) { - var maybeOverlapping = hunks[hunkIndex + 1]; - var maybeLhs = maybeOverlapping[0]; - if (maybeLhs > regionRhs) - break; - regionRhs = Math.max(regionRhs, maybeLhs + maybeOverlapping[2]); - hunkIndex++; - } - copyCommon(regionLhs); - if (firstHunkIndex == hunkIndex) { - if (hunk[4] > 0) { - result.push([hunk[1], hunk[3], hunk[4]]); - } - } else { - var regions = { - 0: [a.length, -1, o.length, -1], - 2: [b.length, -1, o.length, -1] - }; - for (i = firstHunkIndex; i <= hunkIndex; i++) { - hunk = hunks[i]; - var side = hunk[1]; - var r = regions[side]; - var oLhs = hunk[0]; - var oRhs = oLhs + hunk[2]; - var abLhs = hunk[3]; - var abRhs = abLhs + hunk[4]; - r[0] = Math.min(abLhs, r[0]); - r[1] = Math.max(abRhs, r[1]); - r[2] = Math.min(oLhs, r[2]); - r[3] = Math.max(oRhs, r[3]); - } - var aLhs = regions[0][0] + (regionLhs - regions[0][2]); - var aRhs = regions[0][1] + (regionRhs - regions[0][3]); - var bLhs = regions[2][0] + (regionLhs - regions[2][2]); - var bRhs = regions[2][1] + (regionRhs - regions[2][3]); - result.push([ - -1, - aLhs, - aRhs - aLhs, - regionLhs, - regionRhs - regionLhs, - bLhs, - bRhs - bLhs - ]); - } - commonOffset = regionRhs; + if (!event.payload) { + throw new import_aggregate_error.default(["Event payload not passed"]); } - copyCommon(o.length); - return result; - } - function diff3Merge2(a, o, b) { - var result = []; - var files = [a, o, b]; - var indices = diff3MergeIndices(a, o, b); - var okLines = []; - function flushOk() { - if (okLines.length) { - result.push({ - ok: okLines - }); - } - okLines = []; + const hooks = getHooks( + state, + "action" in event.payload ? event.payload.action : null, + event.name + ); + if (hooks.length === 0) { + return Promise.resolve(); } - function pushOk(xs) { - for (var j = 0; j < xs.length; j++) { - okLines.push(xs[j]); + const errors = []; + const promises = hooks.map((handler) => { + let promise = Promise.resolve(event); + if (state.transform) { + promise = promise.then(state.transform); } - } - function isTrueConflict(rec) { - if (rec[2] != rec[6]) - return true; - var aoff = rec[1]; - var boff = rec[5]; - for (var j = 0; j < rec[2]; j++) { - if (a[j + aoff] != b[j + boff]) - return true; + return promise.then((event2) => { + return handler(event2); + }).catch((error) => errors.push(Object.assign(error, { event }))); + }); + return Promise.all(promises).then(() => { + if (errors.length === 0) { + return; } - return false; + const error = new import_aggregate_error.default(errors); + Object.assign(error, { + event, + errors + }); + errorHandlers.forEach((handler) => wrapErrorHandler(handler, error)); + throw error; + }); + } + function removeListener(state, webhookNameOrNames, handler) { + if (Array.isArray(webhookNameOrNames)) { + webhookNameOrNames.forEach( + (webhookName) => removeListener(state, webhookName, handler) + ); + return; } - for (var i = 0; i < indices.length; i++) { - var x = indices[i]; - var side = x[0]; - if (side == -1) { - if (!isTrueConflict(x)) { - pushOk(files[0].slice(x[1], x[1] + x[2])); - } else { - flushOk(); - result.push({ - conflict: { - a: a.slice(x[1], x[1] + x[2]), - aIndex: x[1], - o: o.slice(x[3], x[3] + x[4]), - oIndex: x[3], - b: b.slice(x[5], x[5] + x[6]), - bIndex: x[5] - } - }); - } - } else { - pushOk(files[side].slice(x[1], x[1] + x[2])); - } + if (!state.hooks[webhookNameOrNames]) { + return; } - flushOk(); - return result; - } - module2.exports = diff3Merge2; - } -}); - -// ../../../lix/packages/fs/dist/errors/FilesystemError.js -var FilesystemError; -var init_FilesystemError = __esm({ - "../../../lix/packages/fs/dist/errors/FilesystemError.js"() { - "use strict"; - FilesystemError = class extends Error { - code; - path; - syscall; - target; - constructor(code, path, syscall, target) { - let message; - switch (code) { - case "ENOENT": - message = `${code}: No such file or directory, ${syscall} '${path}'`; - break; - case "ENOTDIR": - message = `${code}: Not a directory, ${syscall} '${path}'`; - break; - case "EISDIR": - message = `${code}: Illegal operation on a directory, ${syscall} '${path}'`; - break; - case "ENOTEMPTY": - message = `${code}: Directory not empty, ${syscall} '${path}'`; - break; - case "EEXIST": - message = `${code}: File exists, ${syscall} '${path}' -> '${target}'`; - break; - case "EINVAL": - message = `${code}: Invaid argument, ${syscall} '${path}'`; - break; - default: - message = `Unknown error with code "${code}", '${syscall}' on '${path}'`; + for (let i = state.hooks[webhookNameOrNames].length - 1; i >= 0; i--) { + if (state.hooks[webhookNameOrNames][i] === handler) { + state.hooks[webhookNameOrNames].splice(i, 1); + return; } - super(message); - this.name = "FilesystemError"; - this.code = code; - this.path = path; - this.syscall = syscall; - this.target = target; } - }; - } -}); - -// ../../../lix/packages/fs/dist/utilities/helpers.js -function assertIsAbsolutePath(path) { - if ((path.startsWith("/") || /^[A-Za-z]:[\\/]/.test(path)) === false) { - { - throw new Error(`Path is not absolute: ${path}. All paths should be absolute to avoid bugs.`); - } - } -} -function normalizePath2(path, stripTrailing) { - if (path === "\\" || path === "/") - return "/"; - const len = path.length; - if (len <= 1) - return path; - let prefix = ""; - if (len > 4 && path[3] === "\\") { - const ch = path[2]; - if ((ch === "?" || ch === ".") && path.slice(0, 2) === "\\\\") { - path = path.slice(2); - prefix = "//"; } - } - const segs = path.split(/[/\\]+/); - const stack = []; - for (const seg of segs) { - if (seg === "..") { - stack.pop(); - } else if (seg !== ".") { - stack.push(seg); + function createEventHandler(options) { + const state = { + hooks: {}, + log: createLogger(options && options.log) + }; + if (options && options.transform) { + state.transform = options.transform; + } + return { + on: receiverOn.bind(null, state), + onAny: receiverOnAny.bind(null, state), + onError: receiverOnError.bind(null, state), + removeListener: removeListener.bind(null, state), + receive: receiverHandle.bind(null, state) + }; } - } - if (stripTrailing !== false && stack.at(-1) === "") { - stack.pop(); - } - return prefix + stack.join("/"); -} -function normalPath(path) { - const dots = /(\/|^)(\.\/)+/g; - const slashes = /\/+/g; - const upreference = /(? x).slice(0, -1).join("/") ?? path); -} -function getBasename(path) { - return path.split("/").filter((x) => x).at(-1) ?? path; -} -var init_helpers = __esm({ - "../../../lix/packages/fs/dist/utilities/helpers.js"() { - "use strict"; - } -}); - -// ../../../lix/packages/fs/dist/memoryFs.js -function toSnapshot(fs2) { - return { - fsMap: Object.fromEntries([...fs2._state.fsMap].map(([path, content]) => { - let serializedContent; - if (content instanceof Set) { - serializedContent = [...content].sort(); - } else if (content.placeholder) { - serializedContent = content; - } else { - serializedContent = content.toString("base64"); + var import_webhooks_methods2 = require_dist_node23(); + var import_aggregate_error2 = __toESM2(require_aggregate_error()); + var import_webhooks_methods = require_dist_node23(); + async function verifyAndReceive(state, event) { + const matchesSignature = await (0, import_webhooks_methods.verify)( + state.secret, + event.payload, + event.signature + ).catch(() => false); + if (!matchesSignature) { + const error = new Error( + "[@octokit/webhooks] signature does not match event payload and secret" + ); + return state.eventHandler.receive( + Object.assign(error, { event, status: 400 }) + ); } - return [ - path, - // requires node buffers, but no web standard method exists - serializedContent - // Alternative to try: - // onst binaryData = new Uint8Array([255, 116, 79, 99 /*...*/]); - // const base64Encoded = btoa(String.fromCharCode.apply(null, binaryData)); - // // Decode Base64 back to binary - // const decodedBinaryString = atob(base64Encoded); - // const decodedBinaryData = new Uint8Array([...decodedBinaryString].map(char => char.charCodeAt(0))); - // this breaks packfile binary data but could be fixed in future btoa(unescape(encodeURIComponent(new TextDecoder().decode(content)))), - ]; - })), - fsStats: Object.fromEntries([...fs2._state.fsStats].map(([path, fsStat]) => { - return [ - path, - { - ...fsStat, - ino: void 0, - isFile: void 0, - isDirectory: void 0, - isSymbolicLink: void 0 - } - ]; - })) - }; -} -function fromSnapshot(fs2, snapshot, { pathPrefix = "" } = {}) { - fs2._state.lastIno = 1; - fs2._state.fsMap = new Map( - // @ts-ignore FIXME: no idea what ts wants me to do here the error message is ridiculous - Object.entries(snapshot.fsMap).map(([path, content]) => { - if (typeof content === "string") { - const data = Buffer.from(content, "base64"); - return [pathPrefix + path, data]; - } else if (content?.placeholder) { - return [pathPrefix + path, content]; + let payload; + try { + payload = JSON.parse(event.payload); + } catch (error) { + error.message = "Invalid JSON"; + error.status = 400; + throw new import_aggregate_error2.default([error]); } - return [pathPrefix + path, new Set(content)]; - }) - ); - fs2._state.fsStats = new Map(Object.entries(snapshot.fsStats).map(([path, rawStat]) => { - const serializedStat = rawStat; - const statsObj = { - ...serializedStat, - ino: fs2._state.lastIno++, - isFile: () => serializedStat._kind === 0, - isDirectory: () => serializedStat._kind === 1, - isSymbolicLink: () => serializedStat._kind === 2 - }; - return [pathPrefix + path, statsObj]; - })); - if (pathPrefix) { - const prefixParts = pathPrefix.split("/"); - const rootStat = fs2._state.fsStats.get(pathPrefix + "/"); - for (let i = 1; i < prefixParts.length; i++) { - const path = prefixParts.slice(0, i).join("/") + "/"; - fs2._state.fsMap.set(path, /* @__PURE__ */ new Set([prefixParts[i]])); - fs2._state.fsStats.set(path, rootStat); + return state.eventHandler.receive({ + id: event.id, + name: event.name, + payload + }); } - } -} -function createNodeishMemoryFs() { - const state = { - lastIno: 1, - fsMap: /* @__PURE__ */ new Map(), - fsStats: /* @__PURE__ */ new Map() - }; - state.fsMap.set("/", /* @__PURE__ */ new Set()); - newStatEntry("/", state.fsStats, 1, 493); - const listeners = /* @__PURE__ */ new Set(); - async function stat(path) { - path = normalPath(path); - const stats = state.fsStats.get(path); - if (stats === void 0) - throw new FilesystemError("ENOENT", path, "stat"); - if (stats.symlinkTarget) - return stat(stats.symlinkTarget); - return Object.assign({}, stats); - } - async function lstat(path) { - path = normalPath(path); - const stats = state.fsStats.get(path); - if (stats === void 0) - throw new FilesystemError("ENOENT", path, "lstat"); - if (!stats.symlinkTarget) - return stat(path); - return Object.assign({}, stats); - } - return { - _state: state, - _createPlaceholder: async function(path, options) { - path = normalPath(path); - const dirName = getDirname(path); - const baseName = getBasename(path); - let parentDir = state.fsMap.get(dirName); - if (!(parentDir instanceof Set)) { - await this.mkdir(dirName, { recursive: true }); - parentDir = state.fsMap.get(dirName); - if (!(parentDir instanceof Set)) { - throw new FilesystemError("ENOENT", path, "writeFile"); + var WEBHOOK_HEADERS = [ + "x-github-event", + "x-hub-signature-256", + "x-github-delivery" + ]; + function getMissingHeaders(request) { + return WEBHOOK_HEADERS.filter((header) => !(header in request.headers)); + } + var import_aggregate_error3 = __toESM2(require_aggregate_error()); + function getPayload(request) { + if ("body" in request) { + if (typeof request.body === "object" && "rawBody" in request && request.rawBody instanceof Buffer) { + return Promise.resolve(request.rawBody.toString("utf8")); + } else { + return Promise.resolve(request.body); } } - parentDir.add(baseName); - const isSymbolicLink = options?.mode === 12e4; - newStatEntry(path, state.fsStats, isSymbolicLink ? 2 : 0, options?.mode ?? 420); - state.fsMap.set(path, { placeholder: true }); - }, - _isPlaceholder: function(path) { - path = normalPath(path); - const entry = state.fsMap.get(path); - if (entry && "placeholder" in entry) { + return new Promise((resolve, reject) => { + let data = []; + request.on("error", (error) => reject(new import_aggregate_error3.default([error]))); + request.on("data", (chunk) => data.push(chunk)); + request.on( + "end", + () => ( + // setImmediate improves the throughput by reducing the pressure from + // the event loop + setImmediate( + resolve, + data.length === 1 ? data[0].toString("utf8") : Buffer.concat(data).toString("utf8") + ) + ) + ); + }); + } + function onUnhandledRequestDefault(request, response) { + response.writeHead(404, { + "content-type": "application/json" + }); + response.end( + JSON.stringify({ + error: `Unknown route: ${request.method} ${request.url}` + }) + ); + } + async function middleware(webhooks, options, request, response, next) { + let pathname; + try { + pathname = new URL(request.url, "http://localhost").pathname; + } catch (error) { + response.writeHead(422, { + "content-type": "application/json" + }); + response.end( + JSON.stringify({ + error: `Request URL could not be parsed: ${request.url}` + }) + ); return true; } - return false; - }, - writeFile: async function(path, data, options) { - path = normalPath(path); - const dirName = getDirname(path); - const baseName = getBasename(path); - const parentDir = state.fsMap.get(dirName); - if (!(parentDir instanceof Set)) - throw new FilesystemError("ENOENT", path, "writeFile"); - if (typeof data === "string") { - data = Buffer.from(new TextEncoder().encode(data)); - } else if (!(data instanceof Uint8Array)) { - throw new FilesystemError('The "data" argument must be of type string/Uint8Array', data, "readFile"); - } else if (!Buffer.isBuffer(data)) { - data = Buffer.from(data); + if (pathname !== options.path) { + next?.(); + return false; + } else if (request.method !== "POST") { + onUnhandledRequestDefault(request, response); + return true; } - parentDir.add(baseName); - newStatEntry(path, state.fsStats, 0, options?.mode ?? 420); - state.fsMap.set(path, data); - for (const listener of listeners) { - listener({ eventType: "rename", filename: dirName + baseName }); + if (!request.headers["content-type"] || !request.headers["content-type"].startsWith("application/json")) { + response.writeHead(415, { + "content-type": "application/json", + accept: "application/json" + }); + response.end( + JSON.stringify({ + error: `Unsupported "Content-Type" header value. Must be "application/json"` + }) + ); + return true; } - }, - // @ts-expect-error - // Typescript can't derive that the return type is either - // a string or a Uint8Array based on the options. - readFile: async function(path, options) { - const decoder = new TextDecoder(); - path = normalPath(path); - const file = state.fsMap.get(path); - if (file instanceof Set) - throw new FilesystemError("EISDIR", path, "readFile"); - if (file === void 0) - throw new FilesystemError("ENOENT", path, "readFile"); - if ("placeholder" in file) - throw new FilesystemError("EPLACEHOLDER", path, "readFile"); - if (!(options?.encoding || typeof options === "string")) - return file; - return decoder.decode(file); - }, - readdir: async function(path) { - path = normalPath(path); - const dir = state.fsMap.get(path); - if (dir instanceof Set) - return [...dir.keys()]; - if (dir === void 0) - throw new FilesystemError("ENOENT", path, "readdir"); - throw new FilesystemError("ENOTDIR", path, "readdir"); - }, - mkdir: async function mkdir(path, options) { - path = normalPath(path); - const dirName = getDirname(path); - const baseName = getBasename(path); - const parentDir = state.fsMap.get(dirName); - if (typeof parentDir === "string" || parentDir && "palceholder" in parentDir) { - throw new FilesystemError("ENOTDIR", path, "mkdir"); + const missingHeaders = getMissingHeaders(request).join(", "); + if (missingHeaders) { + response.writeHead(400, { + "content-type": "application/json" + }); + response.end( + JSON.stringify({ + error: `Required headers missing: ${missingHeaders}` + }) + ); + return true; } - if (parentDir && parentDir instanceof Set) { - if (state.fsMap.has(path)) { - if (!options?.recursive) { - throw new FilesystemError("EEXIST", path, "mkdir"); - } else { - return void 0; - } - } - parentDir.add(baseName); - newStatEntry(path, state.fsStats, 1, 493); - state.fsMap.set(path, /* @__PURE__ */ new Set()); - for (const listener of listeners) { - listener({ eventType: "rename", filename: dirName + baseName }); + const eventName = request.headers["x-github-event"]; + const signatureSHA256 = request.headers["x-hub-signature-256"]; + const id = request.headers["x-github-delivery"]; + options.log.debug(`${eventName} event received (id: ${id})`); + let didTimeout = false; + const timeout = setTimeout(() => { + didTimeout = true; + response.statusCode = 202; + response.end("still processing\n"); + }, 9e3).unref(); + try { + const payload = await getPayload(request); + await webhooks.verifyAndReceive({ + id, + name: eventName, + payload, + signature: signatureSHA256 + }); + clearTimeout(timeout); + if (didTimeout) + return true; + response.end("ok\n"); + return true; + } catch (error) { + clearTimeout(timeout); + if (didTimeout) + return true; + const err = Array.from(error)[0]; + const errorMessage = err.message ? `${err.name}: ${err.message}` : "Error: An Unspecified error occurred"; + response.statusCode = typeof err.status !== "undefined" ? err.status : 500; + options.log.error(error); + response.end( + JSON.stringify({ + error: errorMessage + }) + ); + return true; + } + } + function createNodeMiddleware2(webhooks, { + path = "/api/github/webhooks", + log: log3 = createLogger() + } = {}) { + return middleware.bind(null, webhooks, { + path, + log: log3 + }); + } + var Webhooks = class { + constructor(options) { + if (!options || !options.secret) { + throw new Error("[@octokit/webhooks] options.secret required"); } - return path; - } else if (options?.recursive) { - const parent = getDirname(path); - const parentRes = await mkdir(parent, options); - await mkdir(path, options); - return parentRes; + const state = { + eventHandler: createEventHandler(options), + secret: options.secret, + hooks: {}, + log: createLogger(options.log) + }; + this.sign = import_webhooks_methods2.sign.bind(null, options.secret); + this.verify = import_webhooks_methods2.verify.bind(null, options.secret); + this.on = state.eventHandler.on; + this.onAny = state.eventHandler.onAny; + this.onError = state.eventHandler.onError; + this.removeListener = state.eventHandler.removeListener; + this.receive = state.eventHandler.receive; + this.verifyAndReceive = verifyAndReceive.bind(null, state); } - throw new FilesystemError("ENOENT", path, "mkdir"); - }, - rm: async function rm(path, options) { - path = normalPath(path); - const dirName = getDirname(path); - const baseName = getBasename(path); - const target = state.fsMap.get(path); - const parentDir = state.fsMap.get(dirName); - if (parentDir === void 0 || target === void 0) - throw new FilesystemError("ENOENT", path, "rm"); - if (parentDir instanceof Uint8Array || "placeholder" in parentDir) { - throw new FilesystemError("ENOTDIR", path, "rm"); + }; + } +}); + +// ../../../node_modules/.pnpm/@octokit+app@14.1.0/node_modules/@octokit/app/dist-node/index.js +var require_dist_node25 = __commonJS({ + "../../../node_modules/.pnpm/@octokit+app@14.1.0/node_modules/@octokit/app/dist-node/index.js"(exports2, module2) { + "use strict"; + var __defProp2 = Object.defineProperty; + var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; + var __getOwnPropNames2 = Object.getOwnPropertyNames; + var __hasOwnProp2 = Object.prototype.hasOwnProperty; + var __export2 = (target, all) => { + for (var name in all) + __defProp2(target, name, { get: all[name], enumerable: true }); + }; + var __copyProps2 = (to, from2, except, desc) => { + if (from2 && typeof from2 === "object" || typeof from2 === "function") { + for (let key of __getOwnPropNames2(from2)) + if (!__hasOwnProp2.call(to, key) && key !== except) + __defProp2(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc2(from2, key)) || desc.enumerable }); } - if (target instanceof Uint8Array || "placeholder" in target) { - parentDir.delete(baseName); - state.fsStats.delete(path); - state.fsMap.delete(path); - for (const listener of listeners) { - listener({ eventType: "rename", filename: dirName + baseName }); + return to; + }; + var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); + var dist_src_exports = {}; + __export2(dist_src_exports, { + App: () => App, + createNodeMiddleware: () => createNodeMiddleware2 + }); + module2.exports = __toCommonJS2(dist_src_exports); + var import_core = require_dist_node8(); + var import_auth_app3 = require_dist_node20(); + var import_oauth_app2 = require_dist_node22(); + var VERSION = "14.1.0"; + var import_auth_app = require_dist_node20(); + var import_auth_unauthenticated = require_dist_node21(); + var import_webhooks = require_dist_node24(); + function webhooks(appOctokit, options) { + return new import_webhooks.Webhooks({ + secret: options.secret, + transform: async (event) => { + if (!("installation" in event.payload) || typeof event.payload.installation !== "object") { + const octokit2 = new appOctokit.constructor({ + authStrategy: import_auth_unauthenticated.createUnauthenticatedAuth, + auth: { + reason: `"installation" key missing in webhook event payload` + } + }); + return { + ...event, + octokit: octokit2 + }; + } + const installationId = event.payload.installation.id; + const octokit = await appOctokit.auth({ + type: "installation", + installationId, + factory(auth) { + return new auth.octokit.constructor({ + ...auth.octokitOptions, + authStrategy: import_auth_app.createAppAuth, + ...{ + auth: { + ...auth, + installationId + } + } + }); + } + }); + octokit.hook.before("request", (options2) => { + options2.headers["x-github-delivery"] = event.id; + }); + return { + ...event, + octokit + }; } - return; - } - if (target instanceof Set && options?.recursive) { - await Promise.all([...target.keys()].map(async (child) => { - await rm(`${path}/${child}`, { recursive: true }); - })); - parentDir.delete(baseName); - state.fsStats.delete(path); - state.fsMap.delete(path); - for (const listener of listeners) { - listener({ eventType: "rename", filename: dirName + baseName }); + }); + } + var import_plugin_paginate_rest = require_dist_node10(); + var import_auth_app2 = require_dist_node20(); + async function getInstallationOctokit(app, installationId) { + return app.octokit.auth({ + type: "installation", + installationId, + factory(auth) { + const options = { + ...auth.octokitOptions, + authStrategy: import_auth_app2.createAppAuth, + ...{ auth: { ...auth, installationId } } + }; + return new auth.octokit.constructor(options); } - return; - } - throw new FilesystemError("EISDIR", path, "rm"); - }, - /** - * - * @throws {"ENOENT" | WatchAbortedError} // TODO: move to lix error classes FileDoesNotExistError - */ - watch: function(path, options) { - path = normalPath(path); - const watchName = getBasename(path); - const watchDir = getDirname(path); - const watchPath = watchName === "/" ? watchDir : watchDir + watchName; - if (options?.persistent || options?.encoding) { - throw new Error("Some watch opptions not implemented, only 'recursive' allowed"); + }); + } + function eachInstallationFactory(app) { + return Object.assign(eachInstallation.bind(null, app), { + iterator: eachInstallationIterator.bind(null, app) + }); + } + async function eachInstallation(app, callback) { + const i = eachInstallationIterator(app)[Symbol.asyncIterator](); + let result = await i.next(); + while (!result.done) { + await callback(result.value); + result = await i.next(); } - const queue = []; - let handleNext; - let rejecteNext; - let changeEvent = new Promise((resolve, reject) => { - handleNext = resolve; - rejecteNext = reject; + } + function eachInstallationIterator(app) { + return { + async *[Symbol.asyncIterator]() { + const iterator = import_plugin_paginate_rest.composePaginateRest.iterator( + app.octokit, + "GET /app/installations" + ); + for await (const { data: installations } of iterator) { + for (const installation of installations) { + const installationOctokit = await getInstallationOctokit( + app, + installation.id + ); + yield { octokit: installationOctokit, installation }; + } + } + } + }; + } + var import_plugin_paginate_rest2 = require_dist_node10(); + function eachRepositoryFactory(app) { + return Object.assign(eachRepository.bind(null, app), { + iterator: eachRepositoryIterator.bind(null, app) }); - const listener = ({ eventType, filename }) => { - const event = { - eventType, - filename - }; - if (event.filename === null) { - throw new Error("Internal watcher error: missing filename"); + } + async function eachRepository(app, queryOrCallback, callback) { + const i = eachRepositoryIterator( + app, + callback ? queryOrCallback : void 0 + )[Symbol.asyncIterator](); + let result = await i.next(); + while (!result.done) { + if (callback) { + await callback(result.value); + } else { + await queryOrCallback(result.value); } - const changeName = getBasename(event.filename); - const changeDir = getDirname(event.filename); - if (event.filename === watchPath) { - event.filename = changeName; - queue.push(event); - setTimeout(() => handleNext(void 0), 0); - } else if (changeDir === `${watchPath}/`) { - event.filename = event.filename.replace(`${watchPath}/`, "") || changeName; - queue.push(event); - setTimeout(() => handleNext(void 0), 0); - } else if (options?.recursive && event.filename.startsWith(watchPath)) { - event.filename = event.filename.replace(`${watchPath}/`, "") || changeName; - queue.push(event); - setTimeout(() => handleNext(void 0), 0); + result = await i.next(); + } + } + function singleInstallationIterator(app, installationId) { + return { + async *[Symbol.asyncIterator]() { + yield { + octokit: await app.getInstallationOctokit(installationId) + }; } }; - listeners.add(listener); - if (options?.signal) { - options.signal.addEventListener("abort", () => { - listeners.delete(listener); - try { - options.signal?.throwIfAborted(); - } catch (err) { - rejecteNext(err); - } - }, { once: true }); - } - const asyncIterator = async function* () { - while (!options?.signal?.aborted) { - if (queue.length > 0) { - yield queue.shift(); - } else { - await changeEvent; - changeEvent = new Promise((resolve, reject) => { - handleNext = resolve; - rejecteNext = reject; - }); + } + function eachRepositoryIterator(app, query) { + return { + async *[Symbol.asyncIterator]() { + const iterator = query ? singleInstallationIterator(app, query.installationId) : app.eachInstallation.iterator(); + for await (const { octokit } of iterator) { + const repositoriesIterator = import_plugin_paginate_rest2.composePaginateRest.iterator( + octokit, + "GET /installation/repositories" + ); + for await (const { data: repositories } of repositoriesIterator) { + for (const repository of repositories) { + yield { octokit, repository }; + } + } } } }; - return asyncIterator(); - }, - rmdir: async function(path) { - path = normalPath(path); - const dirName = getDirname(path); - const baseName = getBasename(path); - const target = state.fsMap.get(path); - const parentDir = state.fsMap.get(dirName); - if (parentDir === void 0 || target === void 0) - throw new FilesystemError("ENOENT", path, "rmdir"); - if (parentDir instanceof Uint8Array || target instanceof Uint8Array) - throw new FilesystemError("ENOTDIR", path, "rmdir"); - if ("placeholder" in parentDir || "placeholder" in target) { - throw new FilesystemError("ENOTDIR", path, "rmdir"); - } - if (target.size) - throw new FilesystemError("ENOTEMPTY", path, "rmdir"); - parentDir.delete(baseName); - state.fsStats.delete(path); - state.fsMap.delete(path); - for (const listener of listeners) { - listener({ eventType: "rename", filename: dirName + baseName }); - } - }, - symlink: async function(target, path) { - path = normalPath(path); - target = target.startsWith("/") ? target : `${path}/../${target}`; - const targetInode = state.fsMap.get(normalPath(target)); - const parentDir = state.fsMap.get(getDirname(path)); - if (state.fsMap.get(path)) { - throw new FilesystemError("EEXIST", path, "symlink", target); - } - if (parentDir === void 0) { - throw new FilesystemError("ENOENT", path, "symlink", target); - } - if (parentDir instanceof Uint8Array || "placeholder" in parentDir) { - throw new FilesystemError("ENOTDIR", path, "symlink", target); - } - if (targetInode !== void 0) { - state.fsMap.set(path, targetInode); - } - parentDir.add(getBasename(path)); - newStatEntry(path, state.fsStats, 2, 511, target); - }, - unlink: async function(path) { - path = normalPath(path); - const targetStats = state.fsStats.get(path); - const target = state.fsMap.get(path); - const parentDir = state.fsMap.get(getDirname(path)); - if (parentDir === void 0 || target === void 0) - throw new FilesystemError("ENOENT", path, "unlink"); - if (parentDir instanceof Uint8Array || "placeholder" in parentDir) { - throw new FilesystemError("ENOTDIR", path, "unlink"); - } - if (targetStats?.isDirectory()) { - throw new FilesystemError("EISDIR", path, "unlink"); + } + var import_oauth_app = require_dist_node22(); + var import_webhooks2 = require_dist_node24(); + function noop() { + } + function createNodeMiddleware2(app, options = {}) { + const log3 = Object.assign( + { + debug: noop, + info: noop, + warn: console.warn.bind(console), + error: console.error.bind(console) + }, + options.log + ); + const optionsWithDefaults = { + pathPrefix: "/api/github", + ...options, + log: log3 + }; + const webhooksMiddleware = (0, import_webhooks2.createNodeMiddleware)(app.webhooks, { + path: optionsWithDefaults.pathPrefix + "/webhooks", + log: log3 + }); + const oauthMiddleware = (0, import_oauth_app.createNodeMiddleware)(app.oauth, { + pathPrefix: optionsWithDefaults.pathPrefix + "/oauth" + }); + return middleware.bind( + null, + optionsWithDefaults.pathPrefix, + webhooksMiddleware, + oauthMiddleware + ); + } + async function middleware(pathPrefix, webhooksMiddleware, oauthMiddleware, request, response, next) { + const { pathname } = new URL(request.url, "http://localhost"); + if (pathname.startsWith(`${pathPrefix}/`)) { + if (pathname === `${pathPrefix}/webhooks`) { + webhooksMiddleware(request, response); + } else if (pathname.startsWith(`${pathPrefix}/oauth/`)) { + oauthMiddleware(request, response); + } else { + (0, import_oauth_app.sendNodeResponse)((0, import_oauth_app.unknownRouteResponse)(request), response); + } + return true; + } else { + next == null ? void 0 : next(); + return false; } - parentDir.delete(getBasename(path)); - state.fsStats.delete(path); - state.fsMap.delete(path); - }, - readlink: async function(path) { - path = normalPath(path); - const linkStats = await lstat(path); - if (linkStats === void 0) { - throw new FilesystemError("ENOENT", path, "readlink"); + } + var _App = class _App { + static defaults(defaults) { + const AppWithDefaults = class extends this { + constructor(...args) { + super({ + ...defaults, + ...args[0] + }); + } + }; + return AppWithDefaults; } - if (linkStats.symlinkTarget === void 0) { - throw new FilesystemError("EINVAL", path, "readlink"); + constructor(options) { + const Octokit2 = options.Octokit || import_core.Octokit; + const authOptions = Object.assign( + { + appId: options.appId, + privateKey: options.privateKey + }, + options.oauth ? { + clientId: options.oauth.clientId, + clientSecret: options.oauth.clientSecret + } : {} + ); + this.octokit = new Octokit2({ + authStrategy: import_auth_app3.createAppAuth, + auth: authOptions, + log: options.log + }); + this.log = Object.assign( + { + debug: () => { + }, + info: () => { + }, + warn: console.warn.bind(console), + error: console.error.bind(console) + }, + options.log + ); + if (options.webhooks) { + this.webhooks = webhooks(this.octokit, options.webhooks); + } else { + Object.defineProperty(this, "webhooks", { + get() { + throw new Error("[@octokit/app] webhooks option not set"); + } + }); + } + if (options.oauth) { + this.oauth = new import_oauth_app2.OAuthApp({ + ...options.oauth, + clientType: "github-app", + Octokit: Octokit2 + }); + } else { + Object.defineProperty(this, "oauth", { + get() { + throw new Error( + "[@octokit/app] oauth.clientId / oauth.clientSecret options are not set" + ); + } + }); + } + this.getInstallationOctokit = getInstallationOctokit.bind( + null, + this + ); + this.eachInstallation = eachInstallationFactory( + this + ); + this.eachRepository = eachRepositoryFactory( + this + ); } - return linkStats.symlinkTarget; - }, - stat, - lstat - }; - function newStatEntry(path, stats, kind, modeBits, target) { - const currentTime = Date.now(); - const _kind = kind; - const oldStats = stats.get(normalPath(path)); - const mtimeMs = Math.floor(currentTime / 1e3) === (oldStats?.mtimeMs && Math.floor(oldStats?.mtimeMs / 1e3)) ? currentTime + 1e3 : currentTime; - stats.set(normalPath(path), { - ctimeMs: oldStats?.ctimeMs || currentTime, - mtimeMs, - dev: 0, - ino: oldStats?.ino || state.lastIno++, - mode: (!kind ? 32768 : kind === 1 ? 16384 : 40960) | modeBits, - uid: 0, - gid: 0, - size: -1, - isFile: () => kind === 0, - isDirectory: () => kind === 1, - isSymbolicLink: () => kind === 2, - // symlinkTarget is only for symlinks, and is not normalized - symlinkTarget: target, - _kind - }); - } -} -var init_memoryFs = __esm({ - "../../../lix/packages/fs/dist/memoryFs.js"() { - "use strict"; - init_FilesystemError(); - init_helpers(); + }; + _App.VERSION = VERSION; + var App = _App; } }); -// ../../../lix/packages/fs/dist/index.js -var dist_exports = {}; -__export(dist_exports, { - assertIsAbsolutePath: () => assertIsAbsolutePath, - createNodeishMemoryFs: () => createNodeishMemoryFs, - fromSnapshot: () => fromSnapshot, - getBasename: () => getBasename, - getDirname: () => getDirname, - normalPath: () => normalPath, - normalizePath: () => normalizePath2, - toSnapshot: () => toSnapshot -}); -var init_dist = __esm({ - "../../../lix/packages/fs/dist/index.js"() { +// ../../../node_modules/.pnpm/octokit@3.1.2/node_modules/octokit/dist-node/index.js +var require_dist_node26 = __commonJS({ + "../../../node_modules/.pnpm/octokit@3.1.2/node_modules/octokit/dist-node/index.js"(exports2, module2) { "use strict"; - init_memoryFs(); - init_helpers(); + var __defProp2 = Object.defineProperty; + var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; + var __getOwnPropNames2 = Object.getOwnPropertyNames; + var __hasOwnProp2 = Object.prototype.hasOwnProperty; + var __export2 = (target, all) => { + for (var name in all) + __defProp2(target, name, { get: all[name], enumerable: true }); + }; + var __copyProps2 = (to, from2, except, desc) => { + if (from2 && typeof from2 === "object" || typeof from2 === "function") { + for (let key of __getOwnPropNames2(from2)) + if (!__hasOwnProp2.call(to, key) && key !== except) + __defProp2(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc2(from2, key)) || desc.enumerable }); + } + return to; + }; + var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); + var dist_src_exports = {}; + __export2(dist_src_exports, { + App: () => App, + OAuthApp: () => OAuthApp, + Octokit: () => Octokit2, + RequestError: () => import_request_error.RequestError, + createNodeMiddleware: () => import_app2.createNodeMiddleware + }); + module2.exports = __toCommonJS2(dist_src_exports); + var import_core = require_dist_node8(); + var import_plugin_paginate_rest = require_dist_node10(); + var import_plugin_paginate_graphql = require_dist_node11(); + var import_plugin_rest_endpoint_methods = require_dist_node9(); + var import_plugin_retry = require_dist_node12(); + var import_plugin_throttling = require_dist_node13(); + var VERSION = "3.1.2"; + var import_request_error = require_dist_node4(); + var Octokit2 = import_core.Octokit.plugin( + import_plugin_rest_endpoint_methods.restEndpointMethods, + import_plugin_paginate_rest.paginateRest, + import_plugin_paginate_graphql.paginateGraphql, + import_plugin_retry.retry, + import_plugin_throttling.throttling + ).defaults({ + userAgent: `octokit.js/${VERSION}`, + throttle: { + onRateLimit, + onSecondaryRateLimit + } + }); + function onRateLimit(retryAfter, options, octokit) { + octokit.log.warn( + `Request quota exhausted for request ${options.method} ${options.url}` + ); + if (options.request.retryCount === 0) { + octokit.log.info(`Retrying after ${retryAfter} seconds!`); + return true; + } + } + function onSecondaryRateLimit(retryAfter, options, octokit) { + octokit.log.warn( + `SecondaryRateLimit detected for request ${options.method} ${options.url}` + ); + if (options.request.retryCount === 0) { + octokit.log.info(`Retrying after ${retryAfter} seconds!`); + return true; + } + } + var import_app = require_dist_node25(); + var import_oauth_app = require_dist_node22(); + var import_app2 = require_dist_node25(); + var App = import_app.App.defaults({ Octokit: Octokit2 }); + var OAuthApp = import_oauth_app.OAuthApp.defaults({ Octokit: Octokit2 }); } }); @@ -44668,192 +44668,62 @@ var require_transform = __commonJS({ return Default(schema2, unknownProperties); } function TNot(schema2, references, value) { - return Default(schema2, Visit(schema2.not, references, value)); - } - function TObject(schema2, references, value) { - if (!(0, guard_1.IsPlainObject)(value)) - return Default(schema2, value); - const knownKeys = Types.KeyResolver.ResolveKeys(schema2, { includePatterns: false }); - const knownProperties = knownKeys.reduce((value2, key) => { - return key in value2 ? { ...value2, [key]: Visit(schema2.properties[key], references, value2[key]) } : value2; - }, value); - if (!Types.TypeGuard.TSchema(schema2.additionalProperties)) { - return Default(schema2, knownProperties); - } - const unknownKeys = Object.getOwnPropertyNames(knownProperties); - const additionalProperties = schema2.additionalProperties; - const unknownProperties = unknownKeys.reduce((value2, key) => { - return !knownKeys.includes(key) ? { ...value2, [key]: Default(additionalProperties, value2[key]) } : value2; - }, knownProperties); - return Default(schema2, unknownProperties); - } - function TRecord(schema2, references, value) { - if (!(0, guard_1.IsPlainObject)(value)) - return Default(schema2, value); - const pattern2 = Object.getOwnPropertyNames(schema2.patternProperties)[0]; - const knownKeys = new RegExp(pattern2); - const knownProperties = Object.getOwnPropertyNames(value).reduce((value2, key) => { - return knownKeys.test(key) ? { ...value2, [key]: Visit(schema2.patternProperties[pattern2], references, value2[key]) } : value2; - }, value); - if (!Types.TypeGuard.TSchema(schema2.additionalProperties)) { - return Default(schema2, knownProperties); - } - const unknownKeys = Object.getOwnPropertyNames(knownProperties); - const additionalProperties = schema2.additionalProperties; - const unknownProperties = unknownKeys.reduce((value2, key) => { - return !knownKeys.test(key) ? { ...value2, [key]: Default(additionalProperties, value2[key]) } : value2; - }, knownProperties); - return Default(schema2, unknownProperties); - } - function TRef(schema2, references, value) { - const target = (0, deref_1.Deref)(schema2, references); - return Default(schema2, Visit(target, references, value)); - } - function TThis(schema2, references, value) { - const target = (0, deref_1.Deref)(schema2, references); - return Default(schema2, Visit(target, references, value)); - } - function TTuple(schema2, references, value) { - return (0, guard_1.IsArray)(value) && (0, guard_1.IsArray)(schema2.items) ? Default(schema2, schema2.items.map((schema3, index2) => Visit(schema3, references, value[index2]))) : Default(schema2, value); - } - function TUnion(schema2, references, value) { - const defaulted = Default(schema2, value); - for (const subschema of schema2.anyOf) { - if (!(0, check_1.Check)(subschema, references, defaulted)) - continue; - return Visit(subschema, references, defaulted); - } - return defaulted; - } - function Visit(schema2, references, value) { - const references_ = typeof schema2.$id === "string" ? [...references, schema2] : references; - const schema_ = schema2; - switch (schema2[Types.Kind]) { - case "Array": - return TArray(schema_, references_, value); - case "Intersect": - return TIntersect(schema_, references_, value); - case "Not": - return TNot(schema_, references_, value); - case "Object": - return TObject(schema_, references_, value); - case "Record": - return TRecord(schema_, references_, value); - case "Ref": - return TRef(schema_, references_, value); - case "Symbol": - return Default(schema_, value); - case "This": - return TThis(schema_, references_, value); - case "Tuple": - return TTuple(schema_, references_, value); - case "Union": - return TUnion(schema_, references_, value); - default: - return Default(schema_, value); - } - } - function Decode(schema2, references, value) { - return Visit(schema2, references, value); - } - DecodeTransform2.Decode = Decode; - })(DecodeTransform || (exports2.DecodeTransform = DecodeTransform = {})); - var EncodeTransform; - (function(EncodeTransform2) { - function Default(schema2, value) { - try { - return Types.TypeGuard.TTransform(schema2) ? schema2[Types.Transform].Encode(value) : value; - } catch (error) { - throw new TransformEncodeError(schema2, value, error); - } - } - function TArray(schema2, references, value) { - const defaulted = Default(schema2, value); - return (0, guard_1.IsArray)(defaulted) ? defaulted.map((value2) => Visit(schema2.items, references, value2)) : defaulted; - } - function TIntersect(schema2, references, value) { - const defaulted = Default(schema2, value); - if (!(0, guard_1.IsPlainObject)(value) || (0, guard_1.IsValueType)(value)) - return defaulted; - const knownKeys = Types.KeyResolver.ResolveKeys(schema2, { includePatterns: false }); - const knownProperties = knownKeys.reduce((value2, key) => { - return key in defaulted ? { ...value2, [key]: Visit(Types.IndexedAccessor.Resolve(schema2, [key]), references, value2[key]) } : value2; - }, defaulted); - if (!Types.TypeGuard.TTransform(schema2.unevaluatedProperties)) { - return Default(schema2, knownProperties); - } - const unknownKeys = Object.getOwnPropertyNames(knownProperties); - const unevaluatedProperties = schema2.unevaluatedProperties; - return unknownKeys.reduce((value2, key) => { - return !knownKeys.includes(key) ? { ...value2, [key]: Default(unevaluatedProperties, value2[key]) } : value2; - }, knownProperties); - } - function TNot(schema2, references, value) { - return Default(schema2.not, Default(schema2, value)); + return Default(schema2, Visit(schema2.not, references, value)); } function TObject(schema2, references, value) { - const defaulted = Default(schema2, value); if (!(0, guard_1.IsPlainObject)(value)) - return defaulted; + return Default(schema2, value); const knownKeys = Types.KeyResolver.ResolveKeys(schema2, { includePatterns: false }); const knownProperties = knownKeys.reduce((value2, key) => { return key in value2 ? { ...value2, [key]: Visit(schema2.properties[key], references, value2[key]) } : value2; - }, defaulted); + }, value); if (!Types.TypeGuard.TSchema(schema2.additionalProperties)) { - return knownProperties; + return Default(schema2, knownProperties); } const unknownKeys = Object.getOwnPropertyNames(knownProperties); const additionalProperties = schema2.additionalProperties; - return unknownKeys.reduce((value2, key) => { + const unknownProperties = unknownKeys.reduce((value2, key) => { return !knownKeys.includes(key) ? { ...value2, [key]: Default(additionalProperties, value2[key]) } : value2; }, knownProperties); + return Default(schema2, unknownProperties); } function TRecord(schema2, references, value) { - const defaulted = Default(schema2, value); if (!(0, guard_1.IsPlainObject)(value)) - return defaulted; + return Default(schema2, value); const pattern2 = Object.getOwnPropertyNames(schema2.patternProperties)[0]; const knownKeys = new RegExp(pattern2); const knownProperties = Object.getOwnPropertyNames(value).reduce((value2, key) => { return knownKeys.test(key) ? { ...value2, [key]: Visit(schema2.patternProperties[pattern2], references, value2[key]) } : value2; - }, defaulted); + }, value); if (!Types.TypeGuard.TSchema(schema2.additionalProperties)) { return Default(schema2, knownProperties); } const unknownKeys = Object.getOwnPropertyNames(knownProperties); const additionalProperties = schema2.additionalProperties; - return unknownKeys.reduce((value2, key) => { + const unknownProperties = unknownKeys.reduce((value2, key) => { return !knownKeys.test(key) ? { ...value2, [key]: Default(additionalProperties, value2[key]) } : value2; }, knownProperties); + return Default(schema2, unknownProperties); } function TRef(schema2, references, value) { const target = (0, deref_1.Deref)(schema2, references); - const resolved = Visit(target, references, value); - return Default(schema2, resolved); + return Default(schema2, Visit(target, references, value)); } function TThis(schema2, references, value) { const target = (0, deref_1.Deref)(schema2, references); - const resolved = Visit(target, references, value); - return Default(schema2, resolved); + return Default(schema2, Visit(target, references, value)); } function TTuple(schema2, references, value) { - const value1 = Default(schema2, value); - return (0, guard_1.IsArray)(schema2.items) ? schema2.items.map((schema3, index2) => Visit(schema3, references, value1[index2])) : []; + return (0, guard_1.IsArray)(value) && (0, guard_1.IsArray)(schema2.items) ? Default(schema2, schema2.items.map((schema3, index2) => Visit(schema3, references, value[index2]))) : Default(schema2, value); } function TUnion(schema2, references, value) { + const defaulted = Default(schema2, value); for (const subschema of schema2.anyOf) { - if (!(0, check_1.Check)(subschema, references, value)) - continue; - const value1 = Visit(subschema, references, value); - return Default(schema2, value1); - } - for (const subschema of schema2.anyOf) { - const value1 = Visit(subschema, references, value); - if (!(0, check_1.Check)(schema2, references, value1)) + if (!(0, check_1.Check)(subschema, references, defaulted)) continue; - return Default(schema2, value1); + return Visit(subschema, references, defaulted); } - return Default(schema2, value); + return defaulted; } function Visit(schema2, references, value) { const references_ = typeof schema2.$id === "string" ? [...references, schema2] : references; @@ -44870,735 +44740,243 @@ var require_transform = __commonJS({ case "Record": return TRecord(schema_, references_, value); case "Ref": - return TRef(schema_, references_, value); - case "This": - return TThis(schema_, references_, value); - case "Tuple": - return TTuple(schema_, references_, value); - case "Union": - return TUnion(schema_, references_, value); - default: - return Default(schema_, value); - } - } - function Encode(schema2, references, value) { - return Visit(schema2, references, value); - } - EncodeTransform2.Encode = Encode; - })(EncodeTransform || (exports2.EncodeTransform = EncodeTransform = {})); - } -}); - -// ../../../node_modules/.pnpm/@sinclair+typebox@0.31.28/node_modules/@sinclair/typebox/value/value.js -var require_value = __commonJS({ - "../../../node_modules/.pnpm/@sinclair+typebox@0.31.28/node_modules/@sinclair/typebox/value/value.js"(exports2) { - "use strict"; - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.Value = void 0; - var ValueErrors = require_errors3(); - var ValueMutate = require_mutate(); - var ValueHash = require_hash2(); - var ValueEqual = require_equal(); - var ValueCast = require_cast(); - var ValueClone = require_clone(); - var ValueConvert = require_convert(); - var ValueCreate = require_create(); - var ValueCheck = require_check(); - var ValueDelta = require_delta(); - var ValueTransform = require_transform(); - var Value3; - (function(Value4) { - function Cast(...args) { - return ValueCast.Cast.apply(ValueCast, args); - } - Value4.Cast = Cast; - function Create(...args) { - return ValueCreate.Create.apply(ValueCreate, args); - } - Value4.Create = Create; - function Check(...args) { - return ValueCheck.Check.apply(ValueCheck, args); - } - Value4.Check = Check; - function Convert(...args) { - return ValueConvert.Convert.apply(ValueConvert, args); - } - Value4.Convert = Convert; - function Clone(value) { - return ValueClone.Clone(value); - } - Value4.Clone = Clone; - function Decode(...args) { - const [schema2, references, value] = args.length === 3 ? [args[0], args[1], args[2]] : [args[0], [], args[1]]; - if (!Check(schema2, references, value)) - throw new ValueTransform.TransformDecodeCheckError(schema2, value, Errors2(schema2, references, value).First()); - return ValueTransform.DecodeTransform.Decode(schema2, references, value); - } - Value4.Decode = Decode; - function Encode(...args) { - const [schema2, references, value] = args.length === 3 ? [args[0], args[1], args[2]] : [args[0], [], args[1]]; - const encoded = ValueTransform.EncodeTransform.Encode(schema2, references, value); - if (!Check(schema2, references, encoded)) - throw new ValueTransform.TransformEncodeCheckError(schema2, value, Errors2(schema2, references, value).First()); - return encoded; - } - Value4.Encode = Encode; - function Errors2(...args) { - return ValueErrors.Errors.apply(ValueErrors, args); - } - Value4.Errors = Errors2; - function Equal(left, right) { - return ValueEqual.Equal(left, right); - } - Value4.Equal = Equal; - function Diff(current, next) { - return ValueDelta.Diff(current, next); - } - Value4.Diff = Diff; - function Hash2(value) { - return ValueHash.Hash(value); - } - Value4.Hash = Hash2; - function Patch(current, edits) { - return ValueDelta.Patch(current, edits); - } - Value4.Patch = Patch; - function Mutate(current, next) { - ValueMutate.Mutate(current, next); - } - Value4.Mutate = Mutate; - })(Value3 || (exports2.Value = Value3 = {})); - } -}); - -// ../../../node_modules/.pnpm/@sinclair+typebox@0.31.28/node_modules/@sinclair/typebox/value/index.js -var require_value2 = __commonJS({ - "../../../node_modules/.pnpm/@sinclair+typebox@0.31.28/node_modules/@sinclair/typebox/value/index.js"(exports2) { - "use strict"; - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.Value = exports2.ValuePointer = exports2.Delete = exports2.Update = exports2.Insert = exports2.Edit = exports2.ValueErrorIterator = exports2.ValueErrorType = void 0; - var index_1 = require_errors3(); - Object.defineProperty(exports2, "ValueErrorType", { enumerable: true, get: function() { - return index_1.ValueErrorType; - } }); - Object.defineProperty(exports2, "ValueErrorIterator", { enumerable: true, get: function() { - return index_1.ValueErrorIterator; - } }); - var delta_1 = require_delta(); - Object.defineProperty(exports2, "Edit", { enumerable: true, get: function() { - return delta_1.Edit; - } }); - Object.defineProperty(exports2, "Insert", { enumerable: true, get: function() { - return delta_1.Insert; - } }); - Object.defineProperty(exports2, "Update", { enumerable: true, get: function() { - return delta_1.Update; - } }); - Object.defineProperty(exports2, "Delete", { enumerable: true, get: function() { - return delta_1.Delete; - } }); - var pointer_1 = require_pointer(); - Object.defineProperty(exports2, "ValuePointer", { enumerable: true, get: function() { - return pointer_1.ValuePointer; - } }); - var value_1 = require_value(); - Object.defineProperty(exports2, "Value", { enumerable: true, get: function() { - return value_1.Value; - } }); - } -}); - -// ../../../node_modules/.pnpm/@sinclair+typebox@0.31.28/node_modules/@sinclair/typebox/compiler/compiler.js -var require_compiler = __commonJS({ - "../../../node_modules/.pnpm/@sinclair+typebox@0.31.28/node_modules/@sinclair/typebox/compiler/compiler.js"(exports2) { - "use strict"; - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.TypeCompiler = exports2.Policy = exports2.TypeCompilerTypeGuardError = exports2.TypeCompilerUnknownTypeError = exports2.TypeCheck = void 0; - var transform_1 = require_transform(); - var guard_1 = require_guard(); - var errors_1 = require_errors2(); - var index_1 = require_system2(); - var deref_1 = require_deref(); - var hash_1 = require_hash2(); - var Types = require_typebox(); - var TypeCheck = class { - constructor(schema2, references, checkFunc, code) { - this.schema = schema2; - this.references = references; - this.checkFunc = checkFunc; - this.code = code; - this.hasTransform = transform_1.HasTransform.Has(schema2, references); - } - /** Returns the generated assertion code used to validate this type. */ - Code() { - return this.code; - } - /** Returns an iterator for each error in this value. */ - Errors(value) { - return (0, errors_1.Errors)(this.schema, this.references, value); - } - /** Returns true if the value matches the compiled type. */ - Check(value) { - return this.checkFunc(value); - } - /** Decodes a value or throws if error */ - Decode(value) { - if (!this.checkFunc(value)) - throw new transform_1.TransformDecodeCheckError(this.schema, value, this.Errors(value).First()); - return this.hasTransform ? transform_1.DecodeTransform.Decode(this.schema, this.references, value) : value; - } - /** Encodes a value or throws if error */ - Encode(value) { - const encoded = this.hasTransform ? transform_1.EncodeTransform.Encode(this.schema, this.references, value) : value; - if (!this.checkFunc(encoded)) - throw new transform_1.TransformEncodeCheckError(this.schema, value, this.Errors(value).First()); - return encoded; - } - }; - exports2.TypeCheck = TypeCheck; - var Character; - (function(Character2) { - function DollarSign(code) { - return code === 36; - } - Character2.DollarSign = DollarSign; - function IsUnderscore(code) { - return code === 95; - } - Character2.IsUnderscore = IsUnderscore; - function IsAlpha(code) { - return code >= 65 && code <= 90 || code >= 97 && code <= 122; - } - Character2.IsAlpha = IsAlpha; - function IsNumeric(code) { - return code >= 48 && code <= 57; - } - Character2.IsNumeric = IsNumeric; - })(Character || (Character = {})); - var MemberExpression; - (function(MemberExpression2) { - function IsFirstCharacterNumeric(value) { - if (value.length === 0) - return false; - return Character.IsNumeric(value.charCodeAt(0)); - } - function IsAccessor(value) { - if (IsFirstCharacterNumeric(value)) - return false; - for (let i = 0; i < value.length; i++) { - const code = value.charCodeAt(i); - const check = Character.IsAlpha(code) || Character.IsNumeric(code) || Character.DollarSign(code) || Character.IsUnderscore(code); - if (!check) - return false; - } - return true; - } - function EscapeHyphen(key) { - return key.replace(/'/g, "\\'"); - } - function Encode(object, key) { - return IsAccessor(key) ? `${object}.${key}` : `${object}['${EscapeHyphen(key)}']`; - } - MemberExpression2.Encode = Encode; - })(MemberExpression || (MemberExpression = {})); - var Identifier; - (function(Identifier2) { - function Encode($id) { - const buffer = []; - for (let i = 0; i < $id.length; i++) { - const code = $id.charCodeAt(i); - if (Character.IsNumeric(code) || Character.IsAlpha(code)) { - buffer.push($id.charAt(i)); - } else { - buffer.push(`_${code}_`); - } - } - return buffer.join("").replace(/__/g, "_"); - } - Identifier2.Encode = Encode; - })(Identifier || (Identifier = {})); - var LiteralString; - (function(LiteralString2) { - function Escape(content) { - return content.replace(/'/g, "\\'"); - } - LiteralString2.Escape = Escape; - })(LiteralString || (LiteralString = {})); - var TypeCompilerUnknownTypeError = class extends Types.TypeBoxError { - constructor(schema2) { - super("Unknown type"); - this.schema = schema2; - } - }; - exports2.TypeCompilerUnknownTypeError = TypeCompilerUnknownTypeError; - var TypeCompilerTypeGuardError = class extends Types.TypeBoxError { - constructor(schema2) { - super("Preflight validation check failed to guard for the given schema"); - this.schema = schema2; - } - }; - exports2.TypeCompilerTypeGuardError = TypeCompilerTypeGuardError; - var Policy; - (function(Policy2) { - function IsExactOptionalProperty(value, key, expression) { - return index_1.TypeSystemPolicy.ExactOptionalPropertyTypes ? `('${key}' in ${value} ? ${expression} : true)` : `(${MemberExpression.Encode(value, key)} !== undefined ? ${expression} : true)`; - } - Policy2.IsExactOptionalProperty = IsExactOptionalProperty; - function IsObjectLike(value) { - return !index_1.TypeSystemPolicy.AllowArrayObject ? `(typeof ${value} === 'object' && ${value} !== null && !Array.isArray(${value}))` : `(typeof ${value} === 'object' && ${value} !== null)`; - } - Policy2.IsObjectLike = IsObjectLike; - function IsRecordLike(value) { - return !index_1.TypeSystemPolicy.AllowArrayObject ? `(typeof ${value} === 'object' && ${value} !== null && !Array.isArray(${value}) && !(${value} instanceof Date) && !(${value} instanceof Uint8Array))` : `(typeof ${value} === 'object' && ${value} !== null && !(${value} instanceof Date) && !(${value} instanceof Uint8Array))`; - } - Policy2.IsRecordLike = IsRecordLike; - function IsNumberLike(value) { - return !index_1.TypeSystemPolicy.AllowNaN ? `(typeof ${value} === 'number' && Number.isFinite(${value}))` : `typeof ${value} === 'number'`; - } - Policy2.IsNumberLike = IsNumberLike; - function IsVoidLike(value) { - return index_1.TypeSystemPolicy.AllowNullVoid ? `(${value} === undefined || ${value} === null)` : `${value} === undefined`; - } - Policy2.IsVoidLike = IsVoidLike; - })(Policy || (exports2.Policy = Policy = {})); - var TypeCompiler4; - (function(TypeCompiler5) { - function IsAnyOrUnknown(schema2) { - return schema2[Types.Kind] === "Any" || schema2[Types.Kind] === "Unknown"; - } - function* TAny(schema2, references, value) { - yield "true"; - } - function* TArray(schema2, references, value) { - yield `Array.isArray(${value})`; - const [parameter, accumulator] = [CreateParameter("value", "any"), CreateParameter("acc", "number")]; - if ((0, guard_1.IsNumber)(schema2.maxItems)) - yield `${value}.length <= ${schema2.maxItems}`; - if ((0, guard_1.IsNumber)(schema2.minItems)) - yield `${value}.length >= ${schema2.minItems}`; - const elementExpression = CreateExpression(schema2.items, references, "value"); - yield `${value}.every((${parameter}) => ${elementExpression})`; - if (Types.TypeGuard.TSchema(schema2.contains) || (0, guard_1.IsNumber)(schema2.minContains) || (0, guard_1.IsNumber)(schema2.maxContains)) { - const containsSchema = Types.TypeGuard.TSchema(schema2.contains) ? schema2.contains : Types.Type.Never(); - const checkExpression = CreateExpression(containsSchema, references, "value"); - const checkMinContains = (0, guard_1.IsNumber)(schema2.minContains) ? [`(count >= ${schema2.minContains})`] : []; - const checkMaxContains = (0, guard_1.IsNumber)(schema2.maxContains) ? [`(count <= ${schema2.maxContains})`] : []; - const checkCount = `const count = value.reduce((${accumulator}, ${parameter}) => ${checkExpression} ? acc + 1 : acc, 0)`; - const check = [`(count > 0)`, ...checkMinContains, ...checkMaxContains].join(" && "); - yield `((${parameter}) => { ${checkCount}; return ${check}})(${value})`; - } - if (schema2.uniqueItems === true) { - const check = `const hashed = hash(element); if(set.has(hashed)) { return false } else { set.add(hashed) } } return true`; - const block = `const set = new Set(); for(const element of value) { ${check} }`; - yield `((${parameter}) => { ${block} )(${value})`; - } - } - function* TAsyncIterator(schema2, references, value) { - yield `(typeof value === 'object' && Symbol.asyncIterator in ${value})`; - } - function* TBigInt(schema2, references, value) { - yield `(typeof ${value} === 'bigint')`; - if ((0, guard_1.IsBigInt)(schema2.exclusiveMaximum)) - yield `${value} < BigInt(${schema2.exclusiveMaximum})`; - if ((0, guard_1.IsBigInt)(schema2.exclusiveMinimum)) - yield `${value} > BigInt(${schema2.exclusiveMinimum})`; - if ((0, guard_1.IsBigInt)(schema2.maximum)) - yield `${value} <= BigInt(${schema2.maximum})`; - if ((0, guard_1.IsBigInt)(schema2.minimum)) - yield `${value} >= BigInt(${schema2.minimum})`; - if ((0, guard_1.IsBigInt)(schema2.multipleOf)) - yield `(${value} % BigInt(${schema2.multipleOf})) === 0`; - } - function* TBoolean(schema2, references, value) { - yield `(typeof ${value} === 'boolean')`; - } - function* TConstructor(schema2, references, value) { - yield* Visit(schema2.returns, references, `${value}.prototype`); - } - function* TDate(schema2, references, value) { - yield `(${value} instanceof Date) && Number.isFinite(${value}.getTime())`; - if ((0, guard_1.IsNumber)(schema2.exclusiveMaximumTimestamp)) - yield `${value}.getTime() < ${schema2.exclusiveMaximumTimestamp}`; - if ((0, guard_1.IsNumber)(schema2.exclusiveMinimumTimestamp)) - yield `${value}.getTime() > ${schema2.exclusiveMinimumTimestamp}`; - if ((0, guard_1.IsNumber)(schema2.maximumTimestamp)) - yield `${value}.getTime() <= ${schema2.maximumTimestamp}`; - if ((0, guard_1.IsNumber)(schema2.minimumTimestamp)) - yield `${value}.getTime() >= ${schema2.minimumTimestamp}`; - if ((0, guard_1.IsNumber)(schema2.multipleOfTimestamp)) - yield `(${value}.getTime() % ${schema2.multipleOfTimestamp}) === 0`; - } - function* TFunction(schema2, references, value) { - yield `(typeof ${value} === 'function')`; - } - function* TInteger(schema2, references, value) { - yield `(typeof ${value} === 'number' && Number.isInteger(${value}))`; - if ((0, guard_1.IsNumber)(schema2.exclusiveMaximum)) - yield `${value} < ${schema2.exclusiveMaximum}`; - if ((0, guard_1.IsNumber)(schema2.exclusiveMinimum)) - yield `${value} > ${schema2.exclusiveMinimum}`; - if ((0, guard_1.IsNumber)(schema2.maximum)) - yield `${value} <= ${schema2.maximum}`; - if ((0, guard_1.IsNumber)(schema2.minimum)) - yield `${value} >= ${schema2.minimum}`; - if ((0, guard_1.IsNumber)(schema2.multipleOf)) - yield `(${value} % ${schema2.multipleOf}) === 0`; - } - function* TIntersect(schema2, references, value) { - const check1 = schema2.allOf.map((schema3) => CreateExpression(schema3, references, value)).join(" && "); - if (schema2.unevaluatedProperties === false) { - const keyCheck = CreateVariable(`${new RegExp(Types.KeyResolver.ResolvePattern(schema2))};`); - const check2 = `Object.getOwnPropertyNames(${value}).every(key => ${keyCheck}.test(key))`; - yield `(${check1} && ${check2})`; - } else if (Types.TypeGuard.TSchema(schema2.unevaluatedProperties)) { - const keyCheck = CreateVariable(`${new RegExp(Types.KeyResolver.ResolvePattern(schema2))};`); - const check2 = `Object.getOwnPropertyNames(${value}).every(key => ${keyCheck}.test(key) || ${CreateExpression(schema2.unevaluatedProperties, references, `${value}[key]`)})`; - yield `(${check1} && ${check2})`; - } else { - yield `(${check1})`; - } - } - function* TIterator(schema2, references, value) { - yield `(typeof value === 'object' && Symbol.iterator in ${value})`; - } - function* TLiteral(schema2, references, value) { - if (typeof schema2.const === "number" || typeof schema2.const === "boolean") { - yield `(${value} === ${schema2.const})`; - } else { - yield `(${value} === '${LiteralString.Escape(schema2.const)}')`; - } - } - function* TNever(schema2, references, value) { - yield `false`; - } - function* TNot(schema2, references, value) { - const expression = CreateExpression(schema2.not, references, value); - yield `(!${expression})`; - } - function* TNull(schema2, references, value) { - yield `(${value} === null)`; - } - function* TNumber(schema2, references, value) { - yield Policy.IsNumberLike(value); - if ((0, guard_1.IsNumber)(schema2.exclusiveMaximum)) - yield `${value} < ${schema2.exclusiveMaximum}`; - if ((0, guard_1.IsNumber)(schema2.exclusiveMinimum)) - yield `${value} > ${schema2.exclusiveMinimum}`; - if ((0, guard_1.IsNumber)(schema2.maximum)) - yield `${value} <= ${schema2.maximum}`; - if ((0, guard_1.IsNumber)(schema2.minimum)) - yield `${value} >= ${schema2.minimum}`; - if ((0, guard_1.IsNumber)(schema2.multipleOf)) - yield `(${value} % ${schema2.multipleOf}) === 0`; - } - function* TObject(schema2, references, value) { - yield Policy.IsObjectLike(value); - if ((0, guard_1.IsNumber)(schema2.minProperties)) - yield `Object.getOwnPropertyNames(${value}).length >= ${schema2.minProperties}`; - if ((0, guard_1.IsNumber)(schema2.maxProperties)) - yield `Object.getOwnPropertyNames(${value}).length <= ${schema2.maxProperties}`; - const knownKeys = Object.getOwnPropertyNames(schema2.properties); - for (const knownKey of knownKeys) { - const memberExpression = MemberExpression.Encode(value, knownKey); - const property = schema2.properties[knownKey]; - if (schema2.required && schema2.required.includes(knownKey)) { - yield* Visit(property, references, memberExpression); - if (Types.ExtendsUndefined.Check(property) || IsAnyOrUnknown(property)) - yield `('${knownKey}' in ${value})`; - } else { - const expression = CreateExpression(property, references, memberExpression); - yield Policy.IsExactOptionalProperty(value, knownKey, expression); - } - } - if (schema2.additionalProperties === false) { - if (schema2.required && schema2.required.length === knownKeys.length) { - yield `Object.getOwnPropertyNames(${value}).length === ${knownKeys.length}`; - } else { - const keys = `[${knownKeys.map((key) => `'${key}'`).join(", ")}]`; - yield `Object.getOwnPropertyNames(${value}).every(key => ${keys}.includes(key))`; - } - } - if (typeof schema2.additionalProperties === "object") { - const expression = CreateExpression(schema2.additionalProperties, references, `${value}[key]`); - const keys = `[${knownKeys.map((key) => `'${key}'`).join(", ")}]`; - yield `(Object.getOwnPropertyNames(${value}).every(key => ${keys}.includes(key) || ${expression}))`; - } - } - function* TPromise(schema2, references, value) { - yield `(typeof value === 'object' && typeof ${value}.then === 'function')`; - } - function* TRecord(schema2, references, value) { - yield Policy.IsRecordLike(value); - if ((0, guard_1.IsNumber)(schema2.minProperties)) - yield `Object.getOwnPropertyNames(${value}).length >= ${schema2.minProperties}`; - if ((0, guard_1.IsNumber)(schema2.maxProperties)) - yield `Object.getOwnPropertyNames(${value}).length <= ${schema2.maxProperties}`; - const [patternKey, patternSchema] = Object.entries(schema2.patternProperties)[0]; - const variable = CreateVariable(`${new RegExp(patternKey)}`); - const check1 = CreateExpression(patternSchema, references, "value"); - const check2 = Types.TypeGuard.TSchema(schema2.additionalProperties) ? CreateExpression(schema2.additionalProperties, references, value) : schema2.additionalProperties === false ? "false" : "true"; - const expression = `(${variable}.test(key) ? ${check1} : ${check2})`; - yield `(Object.entries(${value}).every(([key, value]) => ${expression}))`; + return TRef(schema_, references_, value); + case "Symbol": + return Default(schema_, value); + case "This": + return TThis(schema_, references_, value); + case "Tuple": + return TTuple(schema_, references_, value); + case "Union": + return TUnion(schema_, references_, value); + default: + return Default(schema_, value); + } } - function* TRef(schema2, references, value) { - const target = (0, deref_1.Deref)(schema2, references); - if (state.functions.has(schema2.$ref)) - return yield `${CreateFunctionName(schema2.$ref)}(${value})`; - yield* Visit(target, references, value); + function Decode(schema2, references, value) { + return Visit(schema2, references, value); } - function* TString(schema2, references, value) { - yield `(typeof ${value} === 'string')`; - if ((0, guard_1.IsNumber)(schema2.maxLength)) - yield `${value}.length <= ${schema2.maxLength}`; - if ((0, guard_1.IsNumber)(schema2.minLength)) - yield `${value}.length >= ${schema2.minLength}`; - if (schema2.pattern !== void 0) { - const variable = CreateVariable(`${new RegExp(schema2.pattern)};`); - yield `${variable}.test(${value})`; - } - if (schema2.format !== void 0) { - yield `format('${schema2.format}', ${value})`; + DecodeTransform2.Decode = Decode; + })(DecodeTransform || (exports2.DecodeTransform = DecodeTransform = {})); + var EncodeTransform; + (function(EncodeTransform2) { + function Default(schema2, value) { + try { + return Types.TypeGuard.TTransform(schema2) ? schema2[Types.Transform].Encode(value) : value; + } catch (error) { + throw new TransformEncodeError(schema2, value, error); } } - function* TSymbol(schema2, references, value) { - yield `(typeof ${value} === 'symbol')`; + function TArray(schema2, references, value) { + const defaulted = Default(schema2, value); + return (0, guard_1.IsArray)(defaulted) ? defaulted.map((value2) => Visit(schema2.items, references, value2)) : defaulted; } - function* TTemplateLiteral(schema2, references, value) { - yield `(typeof ${value} === 'string')`; - const variable = CreateVariable(`${new RegExp(schema2.pattern)};`); - yield `${variable}.test(${value})`; + function TIntersect(schema2, references, value) { + const defaulted = Default(schema2, value); + if (!(0, guard_1.IsPlainObject)(value) || (0, guard_1.IsValueType)(value)) + return defaulted; + const knownKeys = Types.KeyResolver.ResolveKeys(schema2, { includePatterns: false }); + const knownProperties = knownKeys.reduce((value2, key) => { + return key in defaulted ? { ...value2, [key]: Visit(Types.IndexedAccessor.Resolve(schema2, [key]), references, value2[key]) } : value2; + }, defaulted); + if (!Types.TypeGuard.TTransform(schema2.unevaluatedProperties)) { + return Default(schema2, knownProperties); + } + const unknownKeys = Object.getOwnPropertyNames(knownProperties); + const unevaluatedProperties = schema2.unevaluatedProperties; + return unknownKeys.reduce((value2, key) => { + return !knownKeys.includes(key) ? { ...value2, [key]: Default(unevaluatedProperties, value2[key]) } : value2; + }, knownProperties); } - function* TThis(schema2, references, value) { - yield `${CreateFunctionName(schema2.$ref)}(${value})`; + function TNot(schema2, references, value) { + return Default(schema2.not, Default(schema2, value)); } - function* TTuple(schema2, references, value) { - yield `Array.isArray(${value})`; - if (schema2.items === void 0) - return yield `${value}.length === 0`; - yield `(${value}.length === ${schema2.maxItems})`; - for (let i = 0; i < schema2.items.length; i++) { - const expression = CreateExpression(schema2.items[i], references, `${value}[${i}]`); - yield `${expression}`; + function TObject(schema2, references, value) { + const defaulted = Default(schema2, value); + if (!(0, guard_1.IsPlainObject)(value)) + return defaulted; + const knownKeys = Types.KeyResolver.ResolveKeys(schema2, { includePatterns: false }); + const knownProperties = knownKeys.reduce((value2, key) => { + return key in value2 ? { ...value2, [key]: Visit(schema2.properties[key], references, value2[key]) } : value2; + }, defaulted); + if (!Types.TypeGuard.TSchema(schema2.additionalProperties)) { + return knownProperties; } + const unknownKeys = Object.getOwnPropertyNames(knownProperties); + const additionalProperties = schema2.additionalProperties; + return unknownKeys.reduce((value2, key) => { + return !knownKeys.includes(key) ? { ...value2, [key]: Default(additionalProperties, value2[key]) } : value2; + }, knownProperties); } - function* TUndefined(schema2, references, value) { - yield `${value} === undefined`; - } - function* TUnion(schema2, references, value) { - const expressions = schema2.anyOf.map((schema3) => CreateExpression(schema3, references, value)); - yield `(${expressions.join(" || ")})`; + function TRecord(schema2, references, value) { + const defaulted = Default(schema2, value); + if (!(0, guard_1.IsPlainObject)(value)) + return defaulted; + const pattern2 = Object.getOwnPropertyNames(schema2.patternProperties)[0]; + const knownKeys = new RegExp(pattern2); + const knownProperties = Object.getOwnPropertyNames(value).reduce((value2, key) => { + return knownKeys.test(key) ? { ...value2, [key]: Visit(schema2.patternProperties[pattern2], references, value2[key]) } : value2; + }, defaulted); + if (!Types.TypeGuard.TSchema(schema2.additionalProperties)) { + return Default(schema2, knownProperties); + } + const unknownKeys = Object.getOwnPropertyNames(knownProperties); + const additionalProperties = schema2.additionalProperties; + return unknownKeys.reduce((value2, key) => { + return !knownKeys.test(key) ? { ...value2, [key]: Default(additionalProperties, value2[key]) } : value2; + }, knownProperties); } - function* TUint8Array(schema2, references, value) { - yield `${value} instanceof Uint8Array`; - if ((0, guard_1.IsNumber)(schema2.maxByteLength)) - yield `(${value}.length <= ${schema2.maxByteLength})`; - if ((0, guard_1.IsNumber)(schema2.minByteLength)) - yield `(${value}.length >= ${schema2.minByteLength})`; + function TRef(schema2, references, value) { + const target = (0, deref_1.Deref)(schema2, references); + const resolved = Visit(target, references, value); + return Default(schema2, resolved); } - function* TUnknown(schema2, references, value) { - yield "true"; + function TThis(schema2, references, value) { + const target = (0, deref_1.Deref)(schema2, references); + const resolved = Visit(target, references, value); + return Default(schema2, resolved); } - function* TVoid(schema2, references, value) { - yield Policy.IsVoidLike(value); + function TTuple(schema2, references, value) { + const value1 = Default(schema2, value); + return (0, guard_1.IsArray)(schema2.items) ? schema2.items.map((schema3, index2) => Visit(schema3, references, value1[index2])) : []; } - function* TKind(schema2, references, value) { - const instance = state.instances.size; - state.instances.set(instance, schema2); - yield `kind('${schema2[Types.Kind]}', ${instance}, ${value})`; + function TUnion(schema2, references, value) { + for (const subschema of schema2.anyOf) { + if (!(0, check_1.Check)(subschema, references, value)) + continue; + const value1 = Visit(subschema, references, value); + return Default(schema2, value1); + } + for (const subschema of schema2.anyOf) { + const value1 = Visit(subschema, references, value); + if (!(0, check_1.Check)(schema2, references, value1)) + continue; + return Default(schema2, value1); + } + return Default(schema2, value); } - function* Visit(schema2, references, value, useHoisting = true) { - const references_ = (0, guard_1.IsString)(schema2.$id) ? [...references, schema2] : references; + function Visit(schema2, references, value) { + const references_ = typeof schema2.$id === "string" ? [...references, schema2] : references; const schema_ = schema2; - if (useHoisting && (0, guard_1.IsString)(schema2.$id)) { - const functionName = CreateFunctionName(schema2.$id); - if (state.functions.has(functionName)) { - return yield `${functionName}(${value})`; - } else { - const functionCode = CreateFunction(functionName, schema2, references, "value", false); - state.functions.set(functionName, functionCode); - return yield `${functionName}(${value})`; - } - } - switch (schema_[Types.Kind]) { - case "Any": - return yield* TAny(schema_, references_, value); + switch (schema2[Types.Kind]) { case "Array": - return yield* TArray(schema_, references_, value); - case "AsyncIterator": - return yield* TAsyncIterator(schema_, references_, value); - case "BigInt": - return yield* TBigInt(schema_, references_, value); - case "Boolean": - return yield* TBoolean(schema_, references_, value); - case "Constructor": - return yield* TConstructor(schema_, references_, value); - case "Date": - return yield* TDate(schema_, references_, value); - case "Function": - return yield* TFunction(schema_, references_, value); - case "Integer": - return yield* TInteger(schema_, references_, value); + return TArray(schema_, references_, value); case "Intersect": - return yield* TIntersect(schema_, references_, value); - case "Iterator": - return yield* TIterator(schema_, references_, value); - case "Literal": - return yield* TLiteral(schema_, references_, value); - case "Never": - return yield* TNever(schema_, references_, value); + return TIntersect(schema_, references_, value); case "Not": - return yield* TNot(schema_, references_, value); - case "Null": - return yield* TNull(schema_, references_, value); - case "Number": - return yield* TNumber(schema_, references_, value); + return TNot(schema_, references_, value); case "Object": - return yield* TObject(schema_, references_, value); - case "Promise": - return yield* TPromise(schema_, references_, value); + return TObject(schema_, references_, value); case "Record": - return yield* TRecord(schema_, references_, value); + return TRecord(schema_, references_, value); case "Ref": - return yield* TRef(schema_, references_, value); - case "String": - return yield* TString(schema_, references_, value); - case "Symbol": - return yield* TSymbol(schema_, references_, value); - case "TemplateLiteral": - return yield* TTemplateLiteral(schema_, references_, value); + return TRef(schema_, references_, value); case "This": - return yield* TThis(schema_, references_, value); + return TThis(schema_, references_, value); case "Tuple": - return yield* TTuple(schema_, references_, value); - case "Undefined": - return yield* TUndefined(schema_, references_, value); + return TTuple(schema_, references_, value); case "Union": - return yield* TUnion(schema_, references_, value); - case "Uint8Array": - return yield* TUint8Array(schema_, references_, value); - case "Unknown": - return yield* TUnknown(schema_, references_, value); - case "Void": - return yield* TVoid(schema_, references_, value); + return TUnion(schema_, references_, value); default: - if (!Types.TypeRegistry.Has(schema_[Types.Kind])) - throw new TypeCompilerUnknownTypeError(schema2); - return yield* TKind(schema_, references_, value); + return Default(schema_, value); } } - const state = { - language: "javascript", - functions: /* @__PURE__ */ new Map(), - variables: /* @__PURE__ */ new Map(), - instances: /* @__PURE__ */ new Map() - // exterior kind instances - }; - function CreateExpression(schema2, references, value, useHoisting = true) { - return `(${[...Visit(schema2, references, value, useHoisting)].join(" && ")})`; + function Encode(schema2, references, value) { + return Visit(schema2, references, value); } - function CreateFunctionName($id) { - return `check_${Identifier.Encode($id)}`; + EncodeTransform2.Encode = Encode; + })(EncodeTransform || (exports2.EncodeTransform = EncodeTransform = {})); + } +}); + +// ../../../node_modules/.pnpm/@sinclair+typebox@0.31.28/node_modules/@sinclair/typebox/value/value.js +var require_value = __commonJS({ + "../../../node_modules/.pnpm/@sinclair+typebox@0.31.28/node_modules/@sinclair/typebox/value/value.js"(exports2) { + "use strict"; + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.Value = void 0; + var ValueErrors = require_errors3(); + var ValueMutate = require_mutate(); + var ValueHash = require_hash2(); + var ValueEqual = require_equal(); + var ValueCast = require_cast(); + var ValueClone = require_clone(); + var ValueConvert = require_convert(); + var ValueCreate = require_create(); + var ValueCheck = require_check(); + var ValueDelta = require_delta(); + var ValueTransform = require_transform(); + var Value3; + (function(Value4) { + function Cast(...args) { + return ValueCast.Cast.apply(ValueCast, args); } - function CreateVariable(expression) { - const variableName = `local_${state.variables.size}`; - state.variables.set(variableName, `const ${variableName} = ${expression}`); - return variableName; + Value4.Cast = Cast; + function Create(...args) { + return ValueCreate.Create.apply(ValueCreate, args); } - function CreateFunction(name, schema2, references, value, useHoisting = true) { - const [newline, pad] = ["\n", (length) => "".padStart(length, " ")]; - const parameter = CreateParameter("value", "any"); - const returns = CreateReturns("boolean"); - const expression = [...Visit(schema2, references, value, useHoisting)].map((expression2) => `${pad(4)}${expression2}`).join(` &&${newline}`); - return `function ${name}(${parameter})${returns} {${newline}${pad(2)}return (${newline}${expression}${newline}${pad(2)}) -}`; + Value4.Create = Create; + function Check(...args) { + return ValueCheck.Check.apply(ValueCheck, args); } - function CreateParameter(name, type) { - const annotation = state.language === "typescript" ? `: ${type}` : ""; - return `${name}${annotation}`; + Value4.Check = Check; + function Convert(...args) { + return ValueConvert.Convert.apply(ValueConvert, args); } - function CreateReturns(type) { - return state.language === "typescript" ? `: ${type}` : ""; + Value4.Convert = Convert; + function Clone(value) { + return ValueClone.Clone(value); } - function Build(schema2, references, options) { - const functionCode = CreateFunction("check", schema2, references, "value"); - const parameter = CreateParameter("value", "any"); - const returns = CreateReturns("boolean"); - const functions = [...state.functions.values()]; - const variables = [...state.variables.values()]; - const checkFunction = (0, guard_1.IsString)(schema2.$id) ? `return function check(${parameter})${returns} { - return ${CreateFunctionName(schema2.$id)}(value) -}` : `return ${functionCode}`; - return [...variables, ...functions, checkFunction].join("\n"); + Value4.Clone = Clone; + function Decode(...args) { + const [schema2, references, value] = args.length === 3 ? [args[0], args[1], args[2]] : [args[0], [], args[1]]; + if (!Check(schema2, references, value)) + throw new ValueTransform.TransformDecodeCheckError(schema2, value, Errors2(schema2, references, value).First()); + return ValueTransform.DecodeTransform.Decode(schema2, references, value); } - function Code(...args) { - const defaults = { language: "javascript" }; - const [schema2, references, options] = args.length === 2 && (0, guard_1.IsArray)(args[1]) ? [args[0], args[1], defaults] : args.length === 2 && !(0, guard_1.IsArray)(args[1]) ? [args[0], [], args[1]] : args.length === 3 ? [args[0], args[1], args[2]] : args.length === 1 ? [args[0], [], defaults] : [null, [], defaults]; - state.language = options.language; - state.variables.clear(); - state.functions.clear(); - state.instances.clear(); - if (!Types.TypeGuard.TSchema(schema2)) - throw new TypeCompilerTypeGuardError(schema2); - for (const schema3 of references) - if (!Types.TypeGuard.TSchema(schema3)) - throw new TypeCompilerTypeGuardError(schema3); - return Build(schema2, references, options); + Value4.Decode = Decode; + function Encode(...args) { + const [schema2, references, value] = args.length === 3 ? [args[0], args[1], args[2]] : [args[0], [], args[1]]; + const encoded = ValueTransform.EncodeTransform.Encode(schema2, references, value); + if (!Check(schema2, references, encoded)) + throw new ValueTransform.TransformEncodeCheckError(schema2, value, Errors2(schema2, references, value).First()); + return encoded; } - TypeCompiler5.Code = Code; - function Compile(schema2, references = []) { - const generatedCode = Code(schema2, references, { language: "javascript" }); - const compiledFunction = globalThis.Function("kind", "format", "hash", generatedCode); - const instances = new Map(state.instances); - function typeRegistryFunction(kind, instance, value) { - if (!Types.TypeRegistry.Has(kind) || !instances.has(instance)) - return false; - const checkFunc = Types.TypeRegistry.Get(kind); - const schema3 = instances.get(instance); - return checkFunc(schema3, value); - } - function formatRegistryFunction(format, value) { - if (!Types.FormatRegistry.Has(format)) - return false; - const checkFunc = Types.FormatRegistry.Get(format); - return checkFunc(value); - } - function hashFunction(value) { - return (0, hash_1.Hash)(value); - } - const checkFunction = compiledFunction(typeRegistryFunction, formatRegistryFunction, hashFunction); - return new TypeCheck(schema2, references, checkFunction, generatedCode); + Value4.Encode = Encode; + function Errors2(...args) { + return ValueErrors.Errors.apply(ValueErrors, args); } - TypeCompiler5.Compile = Compile; - })(TypeCompiler4 || (exports2.TypeCompiler = TypeCompiler4 = {})); + Value4.Errors = Errors2; + function Equal(left, right) { + return ValueEqual.Equal(left, right); + } + Value4.Equal = Equal; + function Diff(current, next) { + return ValueDelta.Diff(current, next); + } + Value4.Diff = Diff; + function Hash2(value) { + return ValueHash.Hash(value); + } + Value4.Hash = Hash2; + function Patch(current, edits) { + return ValueDelta.Patch(current, edits); + } + Value4.Patch = Patch; + function Mutate(current, next) { + ValueMutate.Mutate(current, next); + } + Value4.Mutate = Mutate; + })(Value3 || (exports2.Value = Value3 = {})); } }); -// ../../../node_modules/.pnpm/@sinclair+typebox@0.31.28/node_modules/@sinclair/typebox/compiler/index.js -var require_compiler2 = __commonJS({ - "../../../node_modules/.pnpm/@sinclair+typebox@0.31.28/node_modules/@sinclair/typebox/compiler/index.js"(exports2) { +// ../../../node_modules/.pnpm/@sinclair+typebox@0.31.28/node_modules/@sinclair/typebox/value/index.js +var require_value2 = __commonJS({ + "../../../node_modules/.pnpm/@sinclair+typebox@0.31.28/node_modules/@sinclair/typebox/value/index.js"(exports2) { "use strict"; - var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { - if (k2 === void 0) - k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { - return m[k]; - } }; - } - Object.defineProperty(o, k2, desc); - } : function(o, m, k, k2) { - if (k2 === void 0) - k2 = k; - o[k2] = m[k]; - }); - var __exportStar = exports2 && exports2.__exportStar || function(m, exports3) { - for (var p in m) - if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) - __createBinding(exports3, m, p); - }; Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.ValueErrorIterator = exports2.ValueErrorType = void 0; + exports2.Value = exports2.ValuePointer = exports2.Delete = exports2.Update = exports2.Insert = exports2.Edit = exports2.ValueErrorIterator = exports2.ValueErrorType = void 0; var index_1 = require_errors3(); Object.defineProperty(exports2, "ValueErrorType", { enumerable: true, get: function() { return index_1.ValueErrorType; @@ -45606,2108 +44984,1766 @@ var require_compiler2 = __commonJS({ Object.defineProperty(exports2, "ValueErrorIterator", { enumerable: true, get: function() { return index_1.ValueErrorIterator; } }); - __exportStar(require_compiler(), exports2); - } -}); - -// ../../../node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js -var require_ms2 = __commonJS({ - "../../../node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js"(exports2, module2) { - var s = 1e3; - var m = s * 60; - var h = m * 60; - var d = h * 24; - var w = d * 7; - var y = d * 365.25; - module2.exports = function(val, options) { - options = options || {}; - var type = typeof val; - if (type === "string" && val.length > 0) { - return parse2(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) - ); - }; - function parse2(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]); - var type = (match[2] || "ms").toLowerCase(); - switch (type) { - 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 void 0; + var delta_1 = require_delta(); + Object.defineProperty(exports2, "Edit", { enumerable: true, get: function() { + return delta_1.Edit; + } }); + Object.defineProperty(exports2, "Insert", { enumerable: true, get: function() { + return delta_1.Insert; + } }); + Object.defineProperty(exports2, "Update", { enumerable: true, get: function() { + return delta_1.Update; + } }); + Object.defineProperty(exports2, "Delete", { enumerable: true, get: function() { + return delta_1.Delete; + } }); + var pointer_1 = require_pointer(); + Object.defineProperty(exports2, "ValuePointer", { enumerable: true, get: function() { + return pointer_1.ValuePointer; + } }); + var value_1 = require_value(); + Object.defineProperty(exports2, "Value", { enumerable: true, get: function() { + return value_1.Value; + } }); + } +}); + +// ../../../node_modules/.pnpm/@sinclair+typebox@0.31.28/node_modules/@sinclair/typebox/compiler/compiler.js +var require_compiler = __commonJS({ + "../../../node_modules/.pnpm/@sinclair+typebox@0.31.28/node_modules/@sinclair/typebox/compiler/compiler.js"(exports2) { + "use strict"; + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.TypeCompiler = exports2.Policy = exports2.TypeCompilerTypeGuardError = exports2.TypeCompilerUnknownTypeError = exports2.TypeCheck = void 0; + var transform_1 = require_transform(); + var guard_1 = require_guard(); + var errors_1 = require_errors2(); + var index_1 = require_system2(); + var deref_1 = require_deref(); + var hash_1 = require_hash2(); + var Types = require_typebox(); + var TypeCheck = class { + constructor(schema2, references, checkFunc, code) { + this.schema = schema2; + this.references = references; + this.checkFunc = checkFunc; + this.code = code; + this.hasTransform = transform_1.HasTransform.Has(schema2, references); } - } - function fmtShort(ms) { - var msAbs = Math.abs(ms); - if (msAbs >= d) { - return Math.round(ms / d) + "d"; + /** Returns the generated assertion code used to validate this type. */ + Code() { + return this.code; } - if (msAbs >= h) { - return Math.round(ms / h) + "h"; + /** Returns an iterator for each error in this value. */ + Errors(value) { + return (0, errors_1.Errors)(this.schema, this.references, value); } - if (msAbs >= m) { - return Math.round(ms / m) + "m"; + /** Returns true if the value matches the compiled type. */ + Check(value) { + return this.checkFunc(value); } - if (msAbs >= s) { - return Math.round(ms / s) + "s"; + /** Decodes a value or throws if error */ + Decode(value) { + if (!this.checkFunc(value)) + throw new transform_1.TransformDecodeCheckError(this.schema, value, this.Errors(value).First()); + return this.hasTransform ? transform_1.DecodeTransform.Decode(this.schema, this.references, value) : value; } - return ms + "ms"; - } - function fmtLong(ms) { - var msAbs = Math.abs(ms); - if (msAbs >= d) { - return plural(ms, msAbs, d, "day"); + /** Encodes a value or throws if error */ + Encode(value) { + const encoded = this.hasTransform ? transform_1.EncodeTransform.Encode(this.schema, this.references, value) : value; + if (!this.checkFunc(encoded)) + throw new transform_1.TransformEncodeCheckError(this.schema, value, this.Errors(value).First()); + return encoded; } - if (msAbs >= h) { - return plural(ms, msAbs, h, "hour"); + }; + exports2.TypeCheck = TypeCheck; + var Character; + (function(Character2) { + function DollarSign(code) { + return code === 36; } - if (msAbs >= m) { - return plural(ms, msAbs, m, "minute"); + Character2.DollarSign = DollarSign; + function IsUnderscore(code) { + return code === 95; } - if (msAbs >= s) { - return plural(ms, msAbs, s, "second"); + Character2.IsUnderscore = IsUnderscore; + function IsAlpha(code) { + return code >= 65 && code <= 90 || code >= 97 && code <= 122; } - return ms + " ms"; - } - function plural(ms, msAbs, n, name) { - var isPlural = msAbs >= n * 1.5; - return Math.round(ms / n) + " " + name + (isPlural ? "s" : ""); - } - } -}); - -// ../../../node_modules/.pnpm/debug@4.3.4_supports-color@8.1.1/node_modules/debug/src/common.js -var require_common2 = __commonJS({ - "../../../node_modules/.pnpm/debug@4.3.4_supports-color@8.1.1/node_modules/debug/src/common.js"(exports2, module2) { - function setup(env) { - createDebug.debug = createDebug; - createDebug.default = createDebug; - createDebug.coerce = coerce; - createDebug.disable = disable; - createDebug.enable = enable; - createDebug.enabled = enabled; - createDebug.humanize = require_ms2(); - createDebug.destroy = destroy; - Object.keys(env).forEach((key) => { - createDebug[key] = env[key]; - }); - createDebug.names = []; - createDebug.skips = []; - createDebug.formatters = {}; - function selectColor(namespace) { - let hash2 = 0; - for (let i = 0; i < namespace.length; i++) { - hash2 = (hash2 << 5) - hash2 + namespace.charCodeAt(i); - hash2 |= 0; - } - return createDebug.colors[Math.abs(hash2) % createDebug.colors.length]; + Character2.IsAlpha = IsAlpha; + function IsNumeric(code) { + return code >= 48 && code <= 57; } - createDebug.selectColor = selectColor; - function createDebug(namespace) { - let prevTime; - let enableOverride = null; - let namespacesCache; - let enabledCache; - function debug4(...args) { - if (!debug4.enabled) { - return; - } - const self2 = debug4; - const curr = Number(/* @__PURE__ */ new Date()); - const ms = curr - (prevTime || curr); - self2.diff = ms; - self2.prev = prevTime; - self2.curr = curr; - prevTime = curr; - args[0] = createDebug.coerce(args[0]); - if (typeof args[0] !== "string") { - args.unshift("%O"); - } - let index2 = 0; - args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { - if (match === "%%") { - return "%"; - } - index2++; - const formatter = createDebug.formatters[format]; - if (typeof formatter === "function") { - const val = args[index2]; - match = formatter.call(self2, val); - args.splice(index2, 1); - index2--; - } - return match; - }); - createDebug.formatArgs.call(self2, args); - const logFn = self2.log || createDebug.log; - logFn.apply(self2, args); - } - debug4.namespace = namespace; - debug4.useColors = createDebug.useColors(); - debug4.color = createDebug.selectColor(namespace); - debug4.extend = extend; - debug4.destroy = createDebug.destroy; - Object.defineProperty(debug4, "enabled", { - enumerable: true, - configurable: false, - get: () => { - if (enableOverride !== null) { - return enableOverride; - } - if (namespacesCache !== createDebug.namespaces) { - namespacesCache = createDebug.namespaces; - enabledCache = createDebug.enabled(namespace); - } - return enabledCache; - }, - set: (v) => { - enableOverride = v; - } - }); - if (typeof createDebug.init === "function") { - createDebug.init(debug4); + Character2.IsNumeric = IsNumeric; + })(Character || (Character = {})); + var MemberExpression; + (function(MemberExpression2) { + function IsFirstCharacterNumeric(value) { + if (value.length === 0) + return false; + return Character.IsNumeric(value.charCodeAt(0)); + } + function IsAccessor(value) { + if (IsFirstCharacterNumeric(value)) + return false; + for (let i = 0; i < value.length; i++) { + const code = value.charCodeAt(i); + const check = Character.IsAlpha(code) || Character.IsNumeric(code) || Character.DollarSign(code) || Character.IsUnderscore(code); + if (!check) + return false; } - return debug4; + return true; } - function extend(namespace, delimiter) { - const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace); - newDebug.log = this.log; - return newDebug; + function EscapeHyphen(key) { + return key.replace(/'/g, "\\'"); } - function enable(namespaces) { - createDebug.save(namespaces); - createDebug.namespaces = namespaces; - createDebug.names = []; - createDebug.skips = []; - let i; - const split = (typeof namespaces === "string" ? namespaces : "").split(/[\s,]+/); - const len = split.length; - for (i = 0; i < len; i++) { - if (!split[i]) { - continue; - } - namespaces = split[i].replace(/\*/g, ".*?"); - if (namespaces[0] === "-") { - createDebug.skips.push(new RegExp("^" + namespaces.slice(1) + "$")); + function Encode(object, key) { + return IsAccessor(key) ? `${object}.${key}` : `${object}['${EscapeHyphen(key)}']`; + } + MemberExpression2.Encode = Encode; + })(MemberExpression || (MemberExpression = {})); + var Identifier; + (function(Identifier2) { + function Encode($id) { + const buffer = []; + for (let i = 0; i < $id.length; i++) { + const code = $id.charCodeAt(i); + if (Character.IsNumeric(code) || Character.IsAlpha(code)) { + buffer.push($id.charAt(i)); } else { - createDebug.names.push(new RegExp("^" + namespaces + "$")); + buffer.push(`_${code}_`); } } + return buffer.join("").replace(/__/g, "_"); } - function disable() { - const namespaces = [ - ...createDebug.names.map(toNamespace), - ...createDebug.skips.map(toNamespace).map((namespace) => "-" + namespace) - ].join(","); - createDebug.enable(""); - return namespaces; + Identifier2.Encode = Encode; + })(Identifier || (Identifier = {})); + var LiteralString; + (function(LiteralString2) { + function Escape(content) { + return content.replace(/'/g, "\\'"); } - function enabled(name) { - if (name[name.length - 1] === "*") { - return true; - } - let i; - let len; - for (i = 0, len = createDebug.skips.length; i < len; i++) { - if (createDebug.skips[i].test(name)) { - return false; - } - } - for (i = 0, len = createDebug.names.length; i < len; i++) { - if (createDebug.names[i].test(name)) { - return true; - } - } - return false; + LiteralString2.Escape = Escape; + })(LiteralString || (LiteralString = {})); + var TypeCompilerUnknownTypeError = class extends Types.TypeBoxError { + constructor(schema2) { + super("Unknown type"); + this.schema = schema2; } - function toNamespace(regexp) { - return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*"); + }; + exports2.TypeCompilerUnknownTypeError = TypeCompilerUnknownTypeError; + var TypeCompilerTypeGuardError = class extends Types.TypeBoxError { + constructor(schema2) { + super("Preflight validation check failed to guard for the given schema"); + this.schema = schema2; } - function coerce(val) { - if (val instanceof Error) { - return val.stack || val.message; - } - return val; + }; + exports2.TypeCompilerTypeGuardError = TypeCompilerTypeGuardError; + var Policy; + (function(Policy2) { + function IsExactOptionalProperty(value, key, expression) { + return index_1.TypeSystemPolicy.ExactOptionalPropertyTypes ? `('${key}' in ${value} ? ${expression} : true)` : `(${MemberExpression.Encode(value, key)} !== undefined ? ${expression} : true)`; } - function destroy() { - console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."); + Policy2.IsExactOptionalProperty = IsExactOptionalProperty; + function IsObjectLike(value) { + return !index_1.TypeSystemPolicy.AllowArrayObject ? `(typeof ${value} === 'object' && ${value} !== null && !Array.isArray(${value}))` : `(typeof ${value} === 'object' && ${value} !== null)`; } - createDebug.enable(createDebug.load()); - return createDebug; - } - module2.exports = setup; - } -}); - -// ../../../node_modules/.pnpm/debug@4.3.4_supports-color@8.1.1/node_modules/debug/src/browser.js -var require_browser = __commonJS({ - "../../../node_modules/.pnpm/debug@4.3.4_supports-color@8.1.1/node_modules/debug/src/browser.js"(exports2, module2) { - exports2.formatArgs = formatArgs; - exports2.save = save; - exports2.load = load; - exports2.useColors = useColors; - exports2.storage = localstorage(); - exports2.destroy = /* @__PURE__ */ (() => { - let warned = false; - return () => { - if (!warned) { - warned = true; - console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."); - } - }; - })(); - exports2.colors = [ - "#0000CC", - "#0000FF", - "#0033CC", - "#0033FF", - "#0066CC", - "#0066FF", - "#0099CC", - "#0099FF", - "#00CC00", - "#00CC33", - "#00CC66", - "#00CC99", - "#00CCCC", - "#00CCFF", - "#3300CC", - "#3300FF", - "#3333CC", - "#3333FF", - "#3366CC", - "#3366FF", - "#3399CC", - "#3399FF", - "#33CC00", - "#33CC33", - "#33CC66", - "#33CC99", - "#33CCCC", - "#33CCFF", - "#6600CC", - "#6600FF", - "#6633CC", - "#6633FF", - "#66CC00", - "#66CC33", - "#9900CC", - "#9900FF", - "#9933CC", - "#9933FF", - "#99CC00", - "#99CC33", - "#CC0000", - "#CC0033", - "#CC0066", - "#CC0099", - "#CC00CC", - "#CC00FF", - "#CC3300", - "#CC3333", - "#CC3366", - "#CC3399", - "#CC33CC", - "#CC33FF", - "#CC6600", - "#CC6633", - "#CC9900", - "#CC9933", - "#CCCC00", - "#CCCC33", - "#FF0000", - "#FF0033", - "#FF0066", - "#FF0099", - "#FF00CC", - "#FF00FF", - "#FF3300", - "#FF3333", - "#FF3366", - "#FF3399", - "#FF33CC", - "#FF33FF", - "#FF6600", - "#FF6633", - "#FF9900", - "#FF9933", - "#FFCC00", - "#FFCC33" - ]; - function useColors() { - if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) { - return true; + Policy2.IsObjectLike = IsObjectLike; + function IsRecordLike(value) { + return !index_1.TypeSystemPolicy.AllowArrayObject ? `(typeof ${value} === 'object' && ${value} !== null && !Array.isArray(${value}) && !(${value} instanceof Date) && !(${value} instanceof Uint8Array))` : `(typeof ${value} === 'object' && ${value} !== null && !(${value} instanceof Date) && !(${value} instanceof Uint8Array))`; } - if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { - return false; + Policy2.IsRecordLike = IsRecordLike; + function IsNumberLike(value) { + return !index_1.TypeSystemPolicy.AllowNaN ? `(typeof ${value} === 'number' && Number.isFinite(${value}))` : `typeof ${value} === 'number'`; } - return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773 - typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker - typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/); - } - function formatArgs(args) { - args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module2.exports.humanize(this.diff); - if (!this.useColors) { - return; + Policy2.IsNumberLike = IsNumberLike; + function IsVoidLike(value) { + return index_1.TypeSystemPolicy.AllowNullVoid ? `(${value} === undefined || ${value} === null)` : `${value} === undefined`; } - const c = "color: " + this.color; - args.splice(1, 0, c, "color: inherit"); - let index2 = 0; - let lastC = 0; - args[0].replace(/%[a-zA-Z%]/g, (match) => { - if (match === "%%") { - return; - } - index2++; - if (match === "%c") { - lastC = index2; + Policy2.IsVoidLike = IsVoidLike; + })(Policy || (exports2.Policy = Policy = {})); + var TypeCompiler4; + (function(TypeCompiler5) { + function IsAnyOrUnknown(schema2) { + return schema2[Types.Kind] === "Any" || schema2[Types.Kind] === "Unknown"; + } + function* TAny(schema2, references, value) { + yield "true"; + } + function* TArray(schema2, references, value) { + yield `Array.isArray(${value})`; + const [parameter, accumulator] = [CreateParameter("value", "any"), CreateParameter("acc", "number")]; + if ((0, guard_1.IsNumber)(schema2.maxItems)) + yield `${value}.length <= ${schema2.maxItems}`; + if ((0, guard_1.IsNumber)(schema2.minItems)) + yield `${value}.length >= ${schema2.minItems}`; + const elementExpression = CreateExpression(schema2.items, references, "value"); + yield `${value}.every((${parameter}) => ${elementExpression})`; + if (Types.TypeGuard.TSchema(schema2.contains) || (0, guard_1.IsNumber)(schema2.minContains) || (0, guard_1.IsNumber)(schema2.maxContains)) { + const containsSchema = Types.TypeGuard.TSchema(schema2.contains) ? schema2.contains : Types.Type.Never(); + const checkExpression = CreateExpression(containsSchema, references, "value"); + const checkMinContains = (0, guard_1.IsNumber)(schema2.minContains) ? [`(count >= ${schema2.minContains})`] : []; + const checkMaxContains = (0, guard_1.IsNumber)(schema2.maxContains) ? [`(count <= ${schema2.maxContains})`] : []; + const checkCount = `const count = value.reduce((${accumulator}, ${parameter}) => ${checkExpression} ? acc + 1 : acc, 0)`; + const check = [`(count > 0)`, ...checkMinContains, ...checkMaxContains].join(" && "); + yield `((${parameter}) => { ${checkCount}; return ${check}})(${value})`; } - }); - args.splice(lastC, 0, c); - } - exports2.log = console.debug || console.log || (() => { - }); - function save(namespaces) { - try { - if (namespaces) { - exports2.storage.setItem("debug", namespaces); - } else { - exports2.storage.removeItem("debug"); + if (schema2.uniqueItems === true) { + const check = `const hashed = hash(element); if(set.has(hashed)) { return false } else { set.add(hashed) } } return true`; + const block = `const set = new Set(); for(const element of value) { ${check} }`; + yield `((${parameter}) => { ${block} )(${value})`; } - } catch (error) { } - } - function load() { - let r; - try { - r = exports2.storage.getItem("debug"); - } catch (error) { + function* TAsyncIterator(schema2, references, value) { + yield `(typeof value === 'object' && Symbol.asyncIterator in ${value})`; + } + function* TBigInt(schema2, references, value) { + yield `(typeof ${value} === 'bigint')`; + if ((0, guard_1.IsBigInt)(schema2.exclusiveMaximum)) + yield `${value} < BigInt(${schema2.exclusiveMaximum})`; + if ((0, guard_1.IsBigInt)(schema2.exclusiveMinimum)) + yield `${value} > BigInt(${schema2.exclusiveMinimum})`; + if ((0, guard_1.IsBigInt)(schema2.maximum)) + yield `${value} <= BigInt(${schema2.maximum})`; + if ((0, guard_1.IsBigInt)(schema2.minimum)) + yield `${value} >= BigInt(${schema2.minimum})`; + if ((0, guard_1.IsBigInt)(schema2.multipleOf)) + yield `(${value} % BigInt(${schema2.multipleOf})) === 0`; + } + function* TBoolean(schema2, references, value) { + yield `(typeof ${value} === 'boolean')`; + } + function* TConstructor(schema2, references, value) { + yield* Visit(schema2.returns, references, `${value}.prototype`); + } + function* TDate(schema2, references, value) { + yield `(${value} instanceof Date) && Number.isFinite(${value}.getTime())`; + if ((0, guard_1.IsNumber)(schema2.exclusiveMaximumTimestamp)) + yield `${value}.getTime() < ${schema2.exclusiveMaximumTimestamp}`; + if ((0, guard_1.IsNumber)(schema2.exclusiveMinimumTimestamp)) + yield `${value}.getTime() > ${schema2.exclusiveMinimumTimestamp}`; + if ((0, guard_1.IsNumber)(schema2.maximumTimestamp)) + yield `${value}.getTime() <= ${schema2.maximumTimestamp}`; + if ((0, guard_1.IsNumber)(schema2.minimumTimestamp)) + yield `${value}.getTime() >= ${schema2.minimumTimestamp}`; + if ((0, guard_1.IsNumber)(schema2.multipleOfTimestamp)) + yield `(${value}.getTime() % ${schema2.multipleOfTimestamp}) === 0`; + } + function* TFunction(schema2, references, value) { + yield `(typeof ${value} === 'function')`; } - if (!r && typeof process !== "undefined" && "env" in process) { - r = process.env.DEBUG; + function* TInteger(schema2, references, value) { + yield `(typeof ${value} === 'number' && Number.isInteger(${value}))`; + if ((0, guard_1.IsNumber)(schema2.exclusiveMaximum)) + yield `${value} < ${schema2.exclusiveMaximum}`; + if ((0, guard_1.IsNumber)(schema2.exclusiveMinimum)) + yield `${value} > ${schema2.exclusiveMinimum}`; + if ((0, guard_1.IsNumber)(schema2.maximum)) + yield `${value} <= ${schema2.maximum}`; + if ((0, guard_1.IsNumber)(schema2.minimum)) + yield `${value} >= ${schema2.minimum}`; + if ((0, guard_1.IsNumber)(schema2.multipleOf)) + yield `(${value} % ${schema2.multipleOf}) === 0`; } - return r; - } - function localstorage() { - try { - return localStorage; - } catch (error) { + function* TIntersect(schema2, references, value) { + const check1 = schema2.allOf.map((schema3) => CreateExpression(schema3, references, value)).join(" && "); + if (schema2.unevaluatedProperties === false) { + const keyCheck = CreateVariable(`${new RegExp(Types.KeyResolver.ResolvePattern(schema2))};`); + const check2 = `Object.getOwnPropertyNames(${value}).every(key => ${keyCheck}.test(key))`; + yield `(${check1} && ${check2})`; + } else if (Types.TypeGuard.TSchema(schema2.unevaluatedProperties)) { + const keyCheck = CreateVariable(`${new RegExp(Types.KeyResolver.ResolvePattern(schema2))};`); + const check2 = `Object.getOwnPropertyNames(${value}).every(key => ${keyCheck}.test(key) || ${CreateExpression(schema2.unevaluatedProperties, references, `${value}[key]`)})`; + yield `(${check1} && ${check2})`; + } else { + yield `(${check1})`; + } } - } - module2.exports = require_common2()(exports2); - var { formatters } = module2.exports; - formatters.j = function(v) { - try { - return JSON.stringify(v); - } catch (error) { - return "[UnexpectedJSONParseError]: " + error.message; + function* TIterator(schema2, references, value) { + yield `(typeof value === 'object' && Symbol.iterator in ${value})`; } - }; - } -}); - -// ../../../node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js -var require_has_flag = __commonJS({ - "../../../node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js"(exports2, module2) { - "use strict"; - module2.exports = (flag, argv = process.argv) => { - const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--"; - const position = argv.indexOf(prefix + flag); - const terminatorPosition = argv.indexOf("--"); - return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition); - }; - } -}); - -// ../../../node_modules/.pnpm/supports-color@8.1.1/node_modules/supports-color/index.js -var require_supports_color = __commonJS({ - "../../../node_modules/.pnpm/supports-color@8.1.1/node_modules/supports-color/index.js"(exports2, module2) { - "use strict"; - var os = require("os"); - var tty = require("tty"); - var hasFlag = require_has_flag(); - var { env } = process; - var flagForceColor; - if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) { - flagForceColor = 0; - } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) { - flagForceColor = 1; - } - function envForceColor() { - if ("FORCE_COLOR" in env) { - if (env.FORCE_COLOR === "true") { - return 1; - } - if (env.FORCE_COLOR === "false") { - return 0; + function* TLiteral(schema2, references, value) { + if (typeof schema2.const === "number" || typeof schema2.const === "boolean") { + yield `(${value} === ${schema2.const})`; + } else { + yield `(${value} === '${LiteralString.Escape(schema2.const)}')`; } - return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3); } - } - function translateLevel(level) { - if (level === 0) { - return false; + function* TNever(schema2, references, value) { + yield `false`; } - return { - level, - hasBasic: true, - has256: level >= 2, - has16m: level >= 3 - }; - } - function supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) { - const noFlagForceColor = envForceColor(); - if (noFlagForceColor !== void 0) { - flagForceColor = noFlagForceColor; + function* TNot(schema2, references, value) { + const expression = CreateExpression(schema2.not, references, value); + yield `(!${expression})`; } - const forceColor = sniffFlags ? flagForceColor : noFlagForceColor; - if (forceColor === 0) { - return 0; + function* TNull(schema2, references, value) { + yield `(${value} === null)`; } - if (sniffFlags) { - if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) { - return 3; + function* TNumber(schema2, references, value) { + yield Policy.IsNumberLike(value); + if ((0, guard_1.IsNumber)(schema2.exclusiveMaximum)) + yield `${value} < ${schema2.exclusiveMaximum}`; + if ((0, guard_1.IsNumber)(schema2.exclusiveMinimum)) + yield `${value} > ${schema2.exclusiveMinimum}`; + if ((0, guard_1.IsNumber)(schema2.maximum)) + yield `${value} <= ${schema2.maximum}`; + if ((0, guard_1.IsNumber)(schema2.minimum)) + yield `${value} >= ${schema2.minimum}`; + if ((0, guard_1.IsNumber)(schema2.multipleOf)) + yield `(${value} % ${schema2.multipleOf}) === 0`; + } + function* TObject(schema2, references, value) { + yield Policy.IsObjectLike(value); + if ((0, guard_1.IsNumber)(schema2.minProperties)) + yield `Object.getOwnPropertyNames(${value}).length >= ${schema2.minProperties}`; + if ((0, guard_1.IsNumber)(schema2.maxProperties)) + yield `Object.getOwnPropertyNames(${value}).length <= ${schema2.maxProperties}`; + const knownKeys = Object.getOwnPropertyNames(schema2.properties); + for (const knownKey of knownKeys) { + const memberExpression = MemberExpression.Encode(value, knownKey); + const property = schema2.properties[knownKey]; + if (schema2.required && schema2.required.includes(knownKey)) { + yield* Visit(property, references, memberExpression); + if (Types.ExtendsUndefined.Check(property) || IsAnyOrUnknown(property)) + yield `('${knownKey}' in ${value})`; + } else { + const expression = CreateExpression(property, references, memberExpression); + yield Policy.IsExactOptionalProperty(value, knownKey, expression); + } } - if (hasFlag("color=256")) { - return 2; + if (schema2.additionalProperties === false) { + if (schema2.required && schema2.required.length === knownKeys.length) { + yield `Object.getOwnPropertyNames(${value}).length === ${knownKeys.length}`; + } else { + const keys = `[${knownKeys.map((key) => `'${key}'`).join(", ")}]`; + yield `Object.getOwnPropertyNames(${value}).every(key => ${keys}.includes(key))`; + } + } + if (typeof schema2.additionalProperties === "object") { + const expression = CreateExpression(schema2.additionalProperties, references, `${value}[key]`); + const keys = `[${knownKeys.map((key) => `'${key}'`).join(", ")}]`; + yield `(Object.getOwnPropertyNames(${value}).every(key => ${keys}.includes(key) || ${expression}))`; } } - if (haveStream && !streamIsTTY && forceColor === void 0) { - return 0; + function* TPromise(schema2, references, value) { + yield `(typeof value === 'object' && typeof ${value}.then === 'function')`; } - const min = forceColor || 0; - if (env.TERM === "dumb") { - return min; + function* TRecord(schema2, references, value) { + yield Policy.IsRecordLike(value); + if ((0, guard_1.IsNumber)(schema2.minProperties)) + yield `Object.getOwnPropertyNames(${value}).length >= ${schema2.minProperties}`; + if ((0, guard_1.IsNumber)(schema2.maxProperties)) + yield `Object.getOwnPropertyNames(${value}).length <= ${schema2.maxProperties}`; + const [patternKey, patternSchema] = Object.entries(schema2.patternProperties)[0]; + const variable = CreateVariable(`${new RegExp(patternKey)}`); + const check1 = CreateExpression(patternSchema, references, "value"); + const check2 = Types.TypeGuard.TSchema(schema2.additionalProperties) ? CreateExpression(schema2.additionalProperties, references, value) : schema2.additionalProperties === false ? "false" : "true"; + const expression = `(${variable}.test(key) ? ${check1} : ${check2})`; + yield `(Object.entries(${value}).every(([key, value]) => ${expression}))`; } - if (process.platform === "win32") { - const osRelease = os.release().split("."); - if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) { - return Number(osRelease[2]) >= 14931 ? 3 : 2; - } - return 1; + function* TRef(schema2, references, value) { + const target = (0, deref_1.Deref)(schema2, references); + if (state.functions.has(schema2.$ref)) + return yield `${CreateFunctionName(schema2.$ref)}(${value})`; + yield* Visit(target, references, value); } - if ("CI" in env) { - if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") { - return 1; + function* TString(schema2, references, value) { + yield `(typeof ${value} === 'string')`; + if ((0, guard_1.IsNumber)(schema2.maxLength)) + yield `${value}.length <= ${schema2.maxLength}`; + if ((0, guard_1.IsNumber)(schema2.minLength)) + yield `${value}.length >= ${schema2.minLength}`; + if (schema2.pattern !== void 0) { + const variable = CreateVariable(`${new RegExp(schema2.pattern)};`); + yield `${variable}.test(${value})`; + } + if (schema2.format !== void 0) { + yield `format('${schema2.format}', ${value})`; } - return min; - } - if ("TEAMCITY_VERSION" in env) { - return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0; } - if (env.COLORTERM === "truecolor") { - return 3; + function* TSymbol(schema2, references, value) { + yield `(typeof ${value} === 'symbol')`; } - if ("TERM_PROGRAM" in env) { - const version3 = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10); - switch (env.TERM_PROGRAM) { - case "iTerm.app": - return version3 >= 3 ? 3 : 2; - case "Apple_Terminal": - return 2; - } + function* TTemplateLiteral(schema2, references, value) { + yield `(typeof ${value} === 'string')`; + const variable = CreateVariable(`${new RegExp(schema2.pattern)};`); + yield `${variable}.test(${value})`; } - if (/-256(color)?$/i.test(env.TERM)) { - return 2; + function* TThis(schema2, references, value) { + yield `${CreateFunctionName(schema2.$ref)}(${value})`; } - if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) { - return 1; + function* TTuple(schema2, references, value) { + yield `Array.isArray(${value})`; + if (schema2.items === void 0) + return yield `${value}.length === 0`; + yield `(${value}.length === ${schema2.maxItems})`; + for (let i = 0; i < schema2.items.length; i++) { + const expression = CreateExpression(schema2.items[i], references, `${value}[${i}]`); + yield `${expression}`; + } } - if ("COLORTERM" in env) { - return 1; + function* TUndefined(schema2, references, value) { + yield `${value} === undefined`; } - return min; - } - function getSupportLevel(stream, options = {}) { - const level = supportsColor(stream, { - streamIsTTY: stream && stream.isTTY, - ...options - }); - return translateLevel(level); - } - module2.exports = { - supportsColor: getSupportLevel, - stdout: getSupportLevel({ isTTY: tty.isatty(1) }), - stderr: getSupportLevel({ isTTY: tty.isatty(2) }) - }; - } -}); - -// ../../../node_modules/.pnpm/debug@4.3.4_supports-color@8.1.1/node_modules/debug/src/node.js -var require_node = __commonJS({ - "../../../node_modules/.pnpm/debug@4.3.4_supports-color@8.1.1/node_modules/debug/src/node.js"(exports2, module2) { - var tty = require("tty"); - var util = require("util"); - exports2.init = init2; - exports2.log = log2; - exports2.formatArgs = formatArgs; - exports2.save = save; - exports2.load = load; - exports2.useColors = useColors; - exports2.destroy = util.deprecate( - () => { - }, - "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`." - ); - exports2.colors = [6, 2, 3, 4, 5, 1]; - try { - const supportsColor = require_supports_color(); - if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) { - exports2.colors = [ - 20, - 21, - 26, - 27, - 32, - 33, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 56, - 57, - 62, - 63, - 68, - 69, - 74, - 75, - 76, - 77, - 78, - 79, - 80, - 81, - 92, - 93, - 98, - 99, - 112, - 113, - 128, - 129, - 134, - 135, - 148, - 149, - 160, - 161, - 162, - 163, - 164, - 165, - 166, - 167, - 168, - 169, - 170, - 171, - 172, - 173, - 178, - 179, - 184, - 185, - 196, - 197, - 198, - 199, - 200, - 201, - 202, - 203, - 204, - 205, - 206, - 207, - 208, - 209, - 214, - 215, - 220, - 221 - ]; + function* TUnion(schema2, references, value) { + const expressions = schema2.anyOf.map((schema3) => CreateExpression(schema3, references, value)); + yield `(${expressions.join(" || ")})`; } - } catch (error) { - } - exports2.inspectOpts = Object.keys(process.env).filter((key) => { - return /^debug_/i.test(key); - }).reduce((obj, key) => { - const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => { - return k.toUpperCase(); - }); - let val = process.env[key]; - if (/^(yes|on|true|enabled)$/i.test(val)) { - val = true; - } else if (/^(no|off|false|disabled)$/i.test(val)) { - val = false; - } else if (val === "null") { - val = null; - } else { - val = Number(val); + function* TUint8Array(schema2, references, value) { + yield `${value} instanceof Uint8Array`; + if ((0, guard_1.IsNumber)(schema2.maxByteLength)) + yield `(${value}.length <= ${schema2.maxByteLength})`; + if ((0, guard_1.IsNumber)(schema2.minByteLength)) + yield `(${value}.length >= ${schema2.minByteLength})`; } - obj[prop] = val; - return obj; - }, {}); - function useColors() { - return "colors" in exports2.inspectOpts ? Boolean(exports2.inspectOpts.colors) : tty.isatty(process.stderr.fd); - } - function formatArgs(args) { - const { namespace: name, useColors: useColors2 } = this; - if (useColors2) { - const c = this.color; - const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c); - const prefix = ` ${colorCode};1m${name} \x1B[0m`; - args[0] = prefix + args[0].split("\n").join("\n" + prefix); - args.push(colorCode + "m+" + module2.exports.humanize(this.diff) + "\x1B[0m"); - } else { - args[0] = getDate() + name + " " + args[0]; + function* TUnknown(schema2, references, value) { + yield "true"; } - } - function getDate() { - if (exports2.inspectOpts.hideDate) { - return ""; + function* TVoid(schema2, references, value) { + yield Policy.IsVoidLike(value); } - return (/* @__PURE__ */ new Date()).toISOString() + " "; - } - function log2(...args) { - return process.stderr.write(util.format(...args) + "\n"); - } - function save(namespaces) { - if (namespaces) { - process.env.DEBUG = namespaces; - } else { - delete process.env.DEBUG; + function* TKind(schema2, references, value) { + const instance = state.instances.size; + state.instances.set(instance, schema2); + yield `kind('${schema2[Types.Kind]}', ${instance}, ${value})`; } - } - function load() { - return process.env.DEBUG; - } - function init2(debug4) { - debug4.inspectOpts = {}; - const keys = Object.keys(exports2.inspectOpts); - for (let i = 0; i < keys.length; i++) { - debug4.inspectOpts[keys[i]] = exports2.inspectOpts[keys[i]]; + function* Visit(schema2, references, value, useHoisting = true) { + const references_ = (0, guard_1.IsString)(schema2.$id) ? [...references, schema2] : references; + const schema_ = schema2; + if (useHoisting && (0, guard_1.IsString)(schema2.$id)) { + const functionName = CreateFunctionName(schema2.$id); + if (state.functions.has(functionName)) { + return yield `${functionName}(${value})`; + } else { + const functionCode = CreateFunction(functionName, schema2, references, "value", false); + state.functions.set(functionName, functionCode); + return yield `${functionName}(${value})`; + } + } + switch (schema_[Types.Kind]) { + case "Any": + return yield* TAny(schema_, references_, value); + case "Array": + return yield* TArray(schema_, references_, value); + case "AsyncIterator": + return yield* TAsyncIterator(schema_, references_, value); + case "BigInt": + return yield* TBigInt(schema_, references_, value); + case "Boolean": + return yield* TBoolean(schema_, references_, value); + case "Constructor": + return yield* TConstructor(schema_, references_, value); + case "Date": + return yield* TDate(schema_, references_, value); + case "Function": + return yield* TFunction(schema_, references_, value); + case "Integer": + return yield* TInteger(schema_, references_, value); + case "Intersect": + return yield* TIntersect(schema_, references_, value); + case "Iterator": + return yield* TIterator(schema_, references_, value); + case "Literal": + return yield* TLiteral(schema_, references_, value); + case "Never": + return yield* TNever(schema_, references_, value); + case "Not": + return yield* TNot(schema_, references_, value); + case "Null": + return yield* TNull(schema_, references_, value); + case "Number": + return yield* TNumber(schema_, references_, value); + case "Object": + return yield* TObject(schema_, references_, value); + case "Promise": + return yield* TPromise(schema_, references_, value); + case "Record": + return yield* TRecord(schema_, references_, value); + case "Ref": + return yield* TRef(schema_, references_, value); + case "String": + return yield* TString(schema_, references_, value); + case "Symbol": + return yield* TSymbol(schema_, references_, value); + case "TemplateLiteral": + return yield* TTemplateLiteral(schema_, references_, value); + case "This": + return yield* TThis(schema_, references_, value); + case "Tuple": + return yield* TTuple(schema_, references_, value); + case "Undefined": + return yield* TUndefined(schema_, references_, value); + case "Union": + return yield* TUnion(schema_, references_, value); + case "Uint8Array": + return yield* TUint8Array(schema_, references_, value); + case "Unknown": + return yield* TUnknown(schema_, references_, value); + case "Void": + return yield* TVoid(schema_, references_, value); + default: + if (!Types.TypeRegistry.Has(schema_[Types.Kind])) + throw new TypeCompilerUnknownTypeError(schema2); + return yield* TKind(schema_, references_, value); + } } - } - module2.exports = require_common2()(exports2); - var { formatters } = module2.exports; - formatters.o = function(v) { - this.inspectOpts.colors = this.useColors; - return util.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" "); - }; - formatters.O = function(v) { - this.inspectOpts.colors = this.useColors; - return util.inspect(v, this.inspectOpts); - }; - } -}); - -// ../../../node_modules/.pnpm/debug@4.3.4_supports-color@8.1.1/node_modules/debug/src/index.js -var require_src = __commonJS({ - "../../../node_modules/.pnpm/debug@4.3.4_supports-color@8.1.1/node_modules/debug/src/index.js"(exports2, module2) { - if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) { - module2.exports = require_browser(); - } else { - module2.exports = require_node(); - } - } -}); - -// ../../../node_modules/.pnpm/murmurhash3js@3.0.1/node_modules/murmurhash3js/lib/murmurHash3js.js -var require_murmurHash3js = __commonJS({ - "../../../node_modules/.pnpm/murmurhash3js@3.0.1/node_modules/murmurhash3js/lib/murmurHash3js.js"(exports2, module2) { - (function(root, undefined2) { - "use strict"; - var library = { - "version": "3.0.1", - "x86": {}, - "x64": {} + const state = { + language: "javascript", + functions: /* @__PURE__ */ new Map(), + variables: /* @__PURE__ */ new Map(), + instances: /* @__PURE__ */ new Map() + // exterior kind instances }; - function _x86Multiply(m, n) { - return (m & 65535) * n + (((m >>> 16) * n & 65535) << 16); - } - function _x86Rotl(m, n) { - return m << n | m >>> 32 - n; + function CreateExpression(schema2, references, value, useHoisting = true) { + return `(${[...Visit(schema2, references, value, useHoisting)].join(" && ")})`; } - function _x86Fmix(h) { - h ^= h >>> 16; - h = _x86Multiply(h, 2246822507); - h ^= h >>> 13; - h = _x86Multiply(h, 3266489909); - h ^= h >>> 16; - return h; + function CreateFunctionName($id) { + return `check_${Identifier.Encode($id)}`; } - function _x64Add(m, n) { - m = [m[0] >>> 16, m[0] & 65535, m[1] >>> 16, m[1] & 65535]; - n = [n[0] >>> 16, n[0] & 65535, n[1] >>> 16, n[1] & 65535]; - var o = [0, 0, 0, 0]; - o[3] += m[3] + n[3]; - o[2] += o[3] >>> 16; - o[3] &= 65535; - o[2] += m[2] + n[2]; - o[1] += o[2] >>> 16; - o[2] &= 65535; - o[1] += m[1] + n[1]; - o[0] += o[1] >>> 16; - o[1] &= 65535; - o[0] += m[0] + n[0]; - o[0] &= 65535; - return [o[0] << 16 | o[1], o[2] << 16 | o[3]]; + function CreateVariable(expression) { + const variableName = `local_${state.variables.size}`; + state.variables.set(variableName, `const ${variableName} = ${expression}`); + return variableName; } - function _x64Multiply(m, n) { - m = [m[0] >>> 16, m[0] & 65535, m[1] >>> 16, m[1] & 65535]; - n = [n[0] >>> 16, n[0] & 65535, n[1] >>> 16, n[1] & 65535]; - var o = [0, 0, 0, 0]; - o[3] += m[3] * n[3]; - o[2] += o[3] >>> 16; - o[3] &= 65535; - o[2] += m[2] * n[3]; - o[1] += o[2] >>> 16; - o[2] &= 65535; - o[2] += m[3] * n[2]; - o[1] += o[2] >>> 16; - o[2] &= 65535; - o[1] += m[1] * n[3]; - o[0] += o[1] >>> 16; - o[1] &= 65535; - o[1] += m[2] * n[2]; - o[0] += o[1] >>> 16; - o[1] &= 65535; - o[1] += m[3] * n[1]; - o[0] += o[1] >>> 16; - o[1] &= 65535; - o[0] += m[0] * n[3] + m[1] * n[2] + m[2] * n[1] + m[3] * n[0]; - o[0] &= 65535; - return [o[0] << 16 | o[1], o[2] << 16 | o[3]]; + function CreateFunction(name, schema2, references, value, useHoisting = true) { + const [newline, pad] = ["\n", (length) => "".padStart(length, " ")]; + const parameter = CreateParameter("value", "any"); + const returns = CreateReturns("boolean"); + const expression = [...Visit(schema2, references, value, useHoisting)].map((expression2) => `${pad(4)}${expression2}`).join(` &&${newline}`); + return `function ${name}(${parameter})${returns} {${newline}${pad(2)}return (${newline}${expression}${newline}${pad(2)}) +}`; } - function _x64Rotl(m, n) { - n %= 64; - if (n === 32) { - return [m[1], m[0]]; - } else if (n < 32) { - return [m[0] << n | m[1] >>> 32 - n, m[1] << n | m[0] >>> 32 - n]; - } else { - n -= 32; - return [m[1] << n | m[0] >>> 32 - n, m[0] << n | m[1] >>> 32 - n]; - } + function CreateParameter(name, type) { + const annotation = state.language === "typescript" ? `: ${type}` : ""; + return `${name}${annotation}`; } - function _x64LeftShift(m, n) { - n %= 64; - if (n === 0) { - return m; - } else if (n < 32) { - return [m[0] << n | m[1] >>> 32 - n, m[1] << n]; - } else { - return [m[1] << n - 32, 0]; - } + function CreateReturns(type) { + return state.language === "typescript" ? `: ${type}` : ""; } - function _x64Xor(m, n) { - return [m[0] ^ n[0], m[1] ^ n[1]]; + function Build(schema2, references, options) { + const functionCode = CreateFunction("check", schema2, references, "value"); + const parameter = CreateParameter("value", "any"); + const returns = CreateReturns("boolean"); + const functions = [...state.functions.values()]; + const variables = [...state.variables.values()]; + const checkFunction = (0, guard_1.IsString)(schema2.$id) ? `return function check(${parameter})${returns} { + return ${CreateFunctionName(schema2.$id)}(value) +}` : `return ${functionCode}`; + return [...variables, ...functions, checkFunction].join("\n"); } - function _x64Fmix(h) { - h = _x64Xor(h, [0, h[0] >>> 1]); - h = _x64Multiply(h, [4283543511, 3981806797]); - h = _x64Xor(h, [0, h[0] >>> 1]); - h = _x64Multiply(h, [3301882366, 444984403]); - h = _x64Xor(h, [0, h[0] >>> 1]); - return h; + function Code(...args) { + const defaults = { language: "javascript" }; + const [schema2, references, options] = args.length === 2 && (0, guard_1.IsArray)(args[1]) ? [args[0], args[1], defaults] : args.length === 2 && !(0, guard_1.IsArray)(args[1]) ? [args[0], [], args[1]] : args.length === 3 ? [args[0], args[1], args[2]] : args.length === 1 ? [args[0], [], defaults] : [null, [], defaults]; + state.language = options.language; + state.variables.clear(); + state.functions.clear(); + state.instances.clear(); + if (!Types.TypeGuard.TSchema(schema2)) + throw new TypeCompilerTypeGuardError(schema2); + for (const schema3 of references) + if (!Types.TypeGuard.TSchema(schema3)) + throw new TypeCompilerTypeGuardError(schema3); + return Build(schema2, references, options); } - library.x86.hash32 = function(key, seed) { - key = key || ""; - seed = seed || 0; - var remainder = key.length % 4; - var bytes = key.length - remainder; - var h1 = seed; - var k1 = 0; - var c1 = 3432918353; - var c2 = 461845907; - for (var i = 0; i < bytes; i = i + 4) { - k1 = key.charCodeAt(i) & 255 | (key.charCodeAt(i + 1) & 255) << 8 | (key.charCodeAt(i + 2) & 255) << 16 | (key.charCodeAt(i + 3) & 255) << 24; - k1 = _x86Multiply(k1, c1); - k1 = _x86Rotl(k1, 15); - k1 = _x86Multiply(k1, c2); - h1 ^= k1; - h1 = _x86Rotl(h1, 13); - h1 = _x86Multiply(h1, 5) + 3864292196; - } - k1 = 0; - switch (remainder) { - case 3: - k1 ^= (key.charCodeAt(i + 2) & 255) << 16; - case 2: - k1 ^= (key.charCodeAt(i + 1) & 255) << 8; - case 1: - k1 ^= key.charCodeAt(i) & 255; - k1 = _x86Multiply(k1, c1); - k1 = _x86Rotl(k1, 15); - k1 = _x86Multiply(k1, c2); - h1 ^= k1; - } - h1 ^= key.length; - h1 = _x86Fmix(h1); - return h1 >>> 0; - }; - library.x86.hash128 = function(key, seed) { - key = key || ""; - seed = seed || 0; - var remainder = key.length % 16; - var bytes = key.length - remainder; - var h1 = seed; - var h2 = seed; - var h3 = seed; - var h4 = seed; - var k1 = 0; - var k2 = 0; - var k3 = 0; - var k4 = 0; - var c1 = 597399067; - var c2 = 2869860233; - var c3 = 951274213; - var c4 = 2716044179; - for (var i = 0; i < bytes; i = i + 16) { - k1 = key.charCodeAt(i) & 255 | (key.charCodeAt(i + 1) & 255) << 8 | (key.charCodeAt(i + 2) & 255) << 16 | (key.charCodeAt(i + 3) & 255) << 24; - k2 = key.charCodeAt(i + 4) & 255 | (key.charCodeAt(i + 5) & 255) << 8 | (key.charCodeAt(i + 6) & 255) << 16 | (key.charCodeAt(i + 7) & 255) << 24; - k3 = key.charCodeAt(i + 8) & 255 | (key.charCodeAt(i + 9) & 255) << 8 | (key.charCodeAt(i + 10) & 255) << 16 | (key.charCodeAt(i + 11) & 255) << 24; - k4 = key.charCodeAt(i + 12) & 255 | (key.charCodeAt(i + 13) & 255) << 8 | (key.charCodeAt(i + 14) & 255) << 16 | (key.charCodeAt(i + 15) & 255) << 24; - k1 = _x86Multiply(k1, c1); - k1 = _x86Rotl(k1, 15); - k1 = _x86Multiply(k1, c2); - h1 ^= k1; - h1 = _x86Rotl(h1, 19); - h1 += h2; - h1 = _x86Multiply(h1, 5) + 1444728091; - k2 = _x86Multiply(k2, c2); - k2 = _x86Rotl(k2, 16); - k2 = _x86Multiply(k2, c3); - h2 ^= k2; - h2 = _x86Rotl(h2, 17); - h2 += h3; - h2 = _x86Multiply(h2, 5) + 197830471; - k3 = _x86Multiply(k3, c3); - k3 = _x86Rotl(k3, 17); - k3 = _x86Multiply(k3, c4); - h3 ^= k3; - h3 = _x86Rotl(h3, 15); - h3 += h4; - h3 = _x86Multiply(h3, 5) + 2530024501; - k4 = _x86Multiply(k4, c4); - k4 = _x86Rotl(k4, 18); - k4 = _x86Multiply(k4, c1); - h4 ^= k4; - h4 = _x86Rotl(h4, 13); - h4 += h1; - h4 = _x86Multiply(h4, 5) + 850148119; - } - k1 = 0; - k2 = 0; - k3 = 0; - k4 = 0; - switch (remainder) { - case 15: - k4 ^= key.charCodeAt(i + 14) << 16; - case 14: - k4 ^= key.charCodeAt(i + 13) << 8; - case 13: - k4 ^= key.charCodeAt(i + 12); - k4 = _x86Multiply(k4, c4); - k4 = _x86Rotl(k4, 18); - k4 = _x86Multiply(k4, c1); - h4 ^= k4; - case 12: - k3 ^= key.charCodeAt(i + 11) << 24; - case 11: - k3 ^= key.charCodeAt(i + 10) << 16; - case 10: - k3 ^= key.charCodeAt(i + 9) << 8; - case 9: - k3 ^= key.charCodeAt(i + 8); - k3 = _x86Multiply(k3, c3); - k3 = _x86Rotl(k3, 17); - k3 = _x86Multiply(k3, c4); - h3 ^= k3; - case 8: - k2 ^= key.charCodeAt(i + 7) << 24; - case 7: - k2 ^= key.charCodeAt(i + 6) << 16; - case 6: - k2 ^= key.charCodeAt(i + 5) << 8; - case 5: - k2 ^= key.charCodeAt(i + 4); - k2 = _x86Multiply(k2, c2); - k2 = _x86Rotl(k2, 16); - k2 = _x86Multiply(k2, c3); - h2 ^= k2; - case 4: - k1 ^= key.charCodeAt(i + 3) << 24; - case 3: - k1 ^= key.charCodeAt(i + 2) << 16; - case 2: - k1 ^= key.charCodeAt(i + 1) << 8; - case 1: - k1 ^= key.charCodeAt(i); - k1 = _x86Multiply(k1, c1); - k1 = _x86Rotl(k1, 15); - k1 = _x86Multiply(k1, c2); - h1 ^= k1; - } - h1 ^= key.length; - h2 ^= key.length; - h3 ^= key.length; - h4 ^= key.length; - h1 += h2; - h1 += h3; - h1 += h4; - h2 += h1; - h3 += h1; - h4 += h1; - h1 = _x86Fmix(h1); - h2 = _x86Fmix(h2); - h3 = _x86Fmix(h3); - h4 = _x86Fmix(h4); - h1 += h2; - h1 += h3; - h1 += h4; - h2 += h1; - h3 += h1; - h4 += h1; - return ("00000000" + (h1 >>> 0).toString(16)).slice(-8) + ("00000000" + (h2 >>> 0).toString(16)).slice(-8) + ("00000000" + (h3 >>> 0).toString(16)).slice(-8) + ("00000000" + (h4 >>> 0).toString(16)).slice(-8); - }; - library.x64.hash128 = function(key, seed) { - key = key || ""; - seed = seed || 0; - var remainder = key.length % 16; - var bytes = key.length - remainder; - var h1 = [0, seed]; - var h2 = [0, seed]; - var k1 = [0, 0]; - var k2 = [0, 0]; - var c1 = [2277735313, 289559509]; - var c2 = [1291169091, 658871167]; - for (var i = 0; i < bytes; i = i + 16) { - k1 = [key.charCodeAt(i + 4) & 255 | (key.charCodeAt(i + 5) & 255) << 8 | (key.charCodeAt(i + 6) & 255) << 16 | (key.charCodeAt(i + 7) & 255) << 24, key.charCodeAt(i) & 255 | (key.charCodeAt(i + 1) & 255) << 8 | (key.charCodeAt(i + 2) & 255) << 16 | (key.charCodeAt(i + 3) & 255) << 24]; - k2 = [key.charCodeAt(i + 12) & 255 | (key.charCodeAt(i + 13) & 255) << 8 | (key.charCodeAt(i + 14) & 255) << 16 | (key.charCodeAt(i + 15) & 255) << 24, key.charCodeAt(i + 8) & 255 | (key.charCodeAt(i + 9) & 255) << 8 | (key.charCodeAt(i + 10) & 255) << 16 | (key.charCodeAt(i + 11) & 255) << 24]; - k1 = _x64Multiply(k1, c1); - k1 = _x64Rotl(k1, 31); - k1 = _x64Multiply(k1, c2); - h1 = _x64Xor(h1, k1); - h1 = _x64Rotl(h1, 27); - h1 = _x64Add(h1, h2); - h1 = _x64Add(_x64Multiply(h1, [0, 5]), [0, 1390208809]); - k2 = _x64Multiply(k2, c2); - k2 = _x64Rotl(k2, 33); - k2 = _x64Multiply(k2, c1); - h2 = _x64Xor(h2, k2); - h2 = _x64Rotl(h2, 31); - h2 = _x64Add(h2, h1); - h2 = _x64Add(_x64Multiply(h2, [0, 5]), [0, 944331445]); + TypeCompiler5.Code = Code; + function Compile(schema2, references = []) { + const generatedCode = Code(schema2, references, { language: "javascript" }); + const compiledFunction = globalThis.Function("kind", "format", "hash", generatedCode); + const instances = new Map(state.instances); + function typeRegistryFunction(kind, instance, value) { + if (!Types.TypeRegistry.Has(kind) || !instances.has(instance)) + return false; + const checkFunc = Types.TypeRegistry.Get(kind); + const schema3 = instances.get(instance); + return checkFunc(schema3, value); } - k1 = [0, 0]; - k2 = [0, 0]; - switch (remainder) { - case 15: - k2 = _x64Xor(k2, _x64LeftShift([0, key.charCodeAt(i + 14)], 48)); - case 14: - k2 = _x64Xor(k2, _x64LeftShift([0, key.charCodeAt(i + 13)], 40)); - case 13: - k2 = _x64Xor(k2, _x64LeftShift([0, key.charCodeAt(i + 12)], 32)); - case 12: - k2 = _x64Xor(k2, _x64LeftShift([0, key.charCodeAt(i + 11)], 24)); - case 11: - k2 = _x64Xor(k2, _x64LeftShift([0, key.charCodeAt(i + 10)], 16)); - case 10: - k2 = _x64Xor(k2, _x64LeftShift([0, key.charCodeAt(i + 9)], 8)); - case 9: - k2 = _x64Xor(k2, [0, key.charCodeAt(i + 8)]); - k2 = _x64Multiply(k2, c2); - k2 = _x64Rotl(k2, 33); - k2 = _x64Multiply(k2, c1); - h2 = _x64Xor(h2, k2); - case 8: - k1 = _x64Xor(k1, _x64LeftShift([0, key.charCodeAt(i + 7)], 56)); - case 7: - k1 = _x64Xor(k1, _x64LeftShift([0, key.charCodeAt(i + 6)], 48)); - case 6: - k1 = _x64Xor(k1, _x64LeftShift([0, key.charCodeAt(i + 5)], 40)); - case 5: - k1 = _x64Xor(k1, _x64LeftShift([0, key.charCodeAt(i + 4)], 32)); - case 4: - k1 = _x64Xor(k1, _x64LeftShift([0, key.charCodeAt(i + 3)], 24)); - case 3: - k1 = _x64Xor(k1, _x64LeftShift([0, key.charCodeAt(i + 2)], 16)); - case 2: - k1 = _x64Xor(k1, _x64LeftShift([0, key.charCodeAt(i + 1)], 8)); - case 1: - k1 = _x64Xor(k1, [0, key.charCodeAt(i)]); - k1 = _x64Multiply(k1, c1); - k1 = _x64Rotl(k1, 31); - k1 = _x64Multiply(k1, c2); - h1 = _x64Xor(h1, k1); + function formatRegistryFunction(format, value) { + if (!Types.FormatRegistry.Has(format)) + return false; + const checkFunc = Types.FormatRegistry.Get(format); + return checkFunc(value); } - h1 = _x64Xor(h1, [0, key.length]); - h2 = _x64Xor(h2, [0, key.length]); - h1 = _x64Add(h1, h2); - h2 = _x64Add(h2, h1); - h1 = _x64Fmix(h1); - h2 = _x64Fmix(h2); - h1 = _x64Add(h1, h2); - h2 = _x64Add(h2, h1); - return ("00000000" + (h1[0] >>> 0).toString(16)).slice(-8) + ("00000000" + (h1[1] >>> 0).toString(16)).slice(-8) + ("00000000" + (h2[0] >>> 0).toString(16)).slice(-8) + ("00000000" + (h2[1] >>> 0).toString(16)).slice(-8); - }; - if (typeof exports2 !== "undefined") { - if (typeof module2 !== "undefined" && module2.exports) { - exports2 = module2.exports = library; + function hashFunction(value) { + return (0, hash_1.Hash)(value); } - exports2.murmurHash3 = library; - } else if (typeof define === "function" && define.amd) { - define([], function() { - return library; - }); - } else { - library._murmurHash3 = root.murmurHash3; - library.noConflict = function() { - root.murmurHash3 = library._murmurHash3; - library._murmurHash3 = undefined2; - library.noConflict = undefined2; - return library; - }; - root.murmurHash3 = library; + const checkFunction = compiledFunction(typeRegistryFunction, formatRegistryFunction, hashFunction); + return new TypeCheck(schema2, references, checkFunction, generatedCode); + } + TypeCompiler5.Compile = Compile; + })(TypeCompiler4 || (exports2.TypeCompiler = TypeCompiler4 = {})); + } +}); + +// ../../../node_modules/.pnpm/@sinclair+typebox@0.31.28/node_modules/@sinclair/typebox/compiler/index.js +var require_compiler2 = __commonJS({ + "../../../node_modules/.pnpm/@sinclair+typebox@0.31.28/node_modules/@sinclair/typebox/compiler/index.js"(exports2) { + "use strict"; + var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { + if (k2 === void 0) + k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { + return m[k]; + } }; + } + Object.defineProperty(o, k2, desc); + } : function(o, m, k, k2) { + if (k2 === void 0) + k2 = k; + o[k2] = m[k]; + }); + var __exportStar = exports2 && exports2.__exportStar || function(m, exports3) { + for (var p in m) + if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) + __createBinding(exports3, m, p); + }; + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.ValueErrorIterator = exports2.ValueErrorType = void 0; + var index_1 = require_errors3(); + Object.defineProperty(exports2, "ValueErrorType", { enumerable: true, get: function() { + return index_1.ValueErrorType; + } }); + Object.defineProperty(exports2, "ValueErrorIterator", { enumerable: true, get: function() { + return index_1.ValueErrorIterator; + } }); + __exportStar(require_compiler(), exports2); + } +}); + +// ../../../node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js +var require_ms2 = __commonJS({ + "../../../node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js"(exports2, module2) { + var s = 1e3; + var m = s * 60; + var h = m * 60; + var d = h * 24; + var w = d * 7; + var y = d * 365.25; + module2.exports = function(val, options) { + options = options || {}; + var type = typeof val; + if (type === "string" && val.length > 0) { + return parse2(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) + ); + }; + function parse2(str) { + str = String(str); + if (str.length > 100) { + return; } - })(exports2); - } -}); - -// ../../../node_modules/.pnpm/murmurhash3js@3.0.1/node_modules/murmurhash3js/index.js -var require_murmurhash3js = __commonJS({ - "../../../node_modules/.pnpm/murmurhash3js@3.0.1/node_modules/murmurhash3js/index.js"(exports2, module2) { - module2.exports = require_murmurHash3js(); + 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]); + var type = (match[2] || "ms").toLowerCase(); + switch (type) { + 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 void 0; + } + } + function fmtShort(ms) { + var msAbs = Math.abs(ms); + if (msAbs >= d) { + return Math.round(ms / d) + "d"; + } + if (msAbs >= h) { + return Math.round(ms / h) + "h"; + } + if (msAbs >= m) { + return Math.round(ms / m) + "m"; + } + if (msAbs >= s) { + return Math.round(ms / s) + "s"; + } + return ms + "ms"; + } + function fmtLong(ms) { + var msAbs = Math.abs(ms); + if (msAbs >= d) { + return plural(ms, msAbs, d, "day"); + } + if (msAbs >= h) { + return plural(ms, msAbs, h, "hour"); + } + if (msAbs >= m) { + return plural(ms, msAbs, m, "minute"); + } + if (msAbs >= s) { + return plural(ms, msAbs, s, "second"); + } + return ms + " ms"; + } + function plural(ms, msAbs, n, name) { + var isPlural = msAbs >= n * 1.5; + return Math.round(ms / n) + " " + name + (isPlural ? "s" : ""); + } } }); -// src/main.ts -var fs = __toESM(require("node:fs/promises"), 1); -var core = __toESM(require_core(), 1); -var github = __toESM(require_github(), 1); - -// ../../../lix/packages/client/dist/helpers.js -var withProxy = ({ nodeishFs, verbose = false, description, intercept }) => { - return new Proxy(nodeishFs, { - get(getTarget, prop, receiver) { - if (getTarget[prop]) { - return new Proxy(getTarget[prop], { - apply(callTarget, thisArg, argumentsList) { - if (verbose) { - console.warn(`${description} fs:`, prop, argumentsList); +// ../../../node_modules/.pnpm/debug@4.3.4_supports-color@8.1.1/node_modules/debug/src/common.js +var require_common2 = __commonJS({ + "../../../node_modules/.pnpm/debug@4.3.4_supports-color@8.1.1/node_modules/debug/src/common.js"(exports2, module2) { + function setup(env) { + createDebug.debug = createDebug; + createDebug.default = createDebug; + createDebug.coerce = coerce; + createDebug.disable = disable; + createDebug.enable = enable; + createDebug.enabled = enabled; + createDebug.humanize = require_ms2(); + createDebug.destroy = destroy; + Object.keys(env).forEach((key) => { + createDebug[key] = env[key]; + }); + createDebug.names = []; + createDebug.skips = []; + createDebug.formatters = {}; + function selectColor(namespace) { + let hash2 = 0; + for (let i = 0; i < namespace.length; i++) { + hash2 = (hash2 << 5) - hash2 + namespace.charCodeAt(i); + hash2 |= 0; + } + return createDebug.colors[Math.abs(hash2) % createDebug.colors.length]; + } + createDebug.selectColor = selectColor; + function createDebug(namespace) { + let prevTime; + let enableOverride = null; + let namespacesCache; + let enabledCache; + function debug4(...args) { + if (!debug4.enabled) { + return; + } + const self2 = debug4; + const curr = Number(/* @__PURE__ */ new Date()); + const ms = curr - (prevTime || curr); + self2.diff = ms; + self2.prev = prevTime; + self2.curr = curr; + prevTime = curr; + args[0] = createDebug.coerce(args[0]); + if (typeof args[0] !== "string") { + args.unshift("%O"); + } + let index2 = 0; + args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { + if (match === "%%") { + return "%"; } - const execute = () => Reflect.apply(callTarget, thisArg, argumentsList); - return intercept ? intercept({ prop, argumentsList, execute }) : execute(); + index2++; + const formatter = createDebug.formatters[format]; + if (typeof formatter === "function") { + const val = args[index2]; + match = formatter.call(self2, val); + args.splice(index2, 1); + index2--; + } + return match; + }); + createDebug.formatArgs.call(self2, args); + const logFn = self2.log || createDebug.log; + logFn.apply(self2, args); + } + debug4.namespace = namespace; + debug4.useColors = createDebug.useColors(); + debug4.color = createDebug.selectColor(namespace); + debug4.extend = extend; + debug4.destroy = createDebug.destroy; + Object.defineProperty(debug4, "enabled", { + enumerable: true, + configurable: false, + get: () => { + if (enableOverride !== null) { + return enableOverride; + } + if (namespacesCache !== createDebug.namespaces) { + namespacesCache = createDebug.namespaces; + enabledCache = createDebug.enabled(namespace); + } + return enabledCache; + }, + set: (v) => { + enableOverride = v; } }); + if (typeof createDebug.init === "function") { + createDebug.init(debug4); + } + return debug4; } - return Reflect.get(getTarget, prop, receiver); - } - }); -}; -function parseOrigin({ remotes }) { - const origin = remotes?.find((elements) => elements.remote === "origin"); - if (origin === void 0) { - return void 0; - } - let result = origin.url; - if (result.endsWith(".git") === false) { - result += ".git"; - } - return transformRemote(result); -} -function transformRemote(remote) { - const regex = /(?:https:\/\/|@|git:\/\/)([^/]+)\/(.+?)(?:\.git)?$/; - const matches = remote.match(regex); - if (matches && matches[1] && matches[2]) { - let host = matches[1].replace(/:/g, "/"); - const repo = matches[2]; - const hostRegex = /(ghp_|ghs_)[\w]+@/; - host = host.replace(hostRegex, ""); - return `${host}/${repo}.git`; - } - return void 0; -} -function parseLixUri(uriText) { - let url; - try { - url = new URL(uriText); - } catch (error) { - return { - error, - username: "", - password: "", - protocol: "", - lixHost: "", - namespace: "", - repoHost: "", - owner: "", - repoName: "" - }; - } - const { protocol, host, pathname, username, password } = url; - const pathParts = pathname.split("/"); - let lixHost = ""; - let namespace = ""; - let repoHost = ""; - let owner = ""; - let repoName = ""; - if (host === "github.com") { - repoHost = host; - owner = pathParts[1] || ""; - repoName = pathParts[2] || ""; - if (!repoHost || !owner || !repoName) { - return { - error: new Error(`Invalid url format for '${uriText}' for direct cloning repository from github, please use the format of https://github.com/opral/monorepo.`), - username, - password, - protocol, - lixHost, - namespace, - repoHost, - owner, - repoName - }; - } - } else { - lixHost = host; - namespace = pathParts[1] || ""; - repoHost = pathParts[2] || ""; - owner = pathParts[3] || ""; - repoName = pathParts[4] || ""; - if (!namespace || !host || !owner || !repoName) { - return { - error: new Error(`Invalid url format for '${uriText}' for cloning repository, please use the format of https://lix.inlang.com/git/github.com/opral/monorepo.`), - username, - password, - protocol, - lixHost, - namespace, - repoHost, - owner, - repoName - }; + function extend(namespace, delimiter) { + const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace); + newDebug.log = this.log; + return newDebug; + } + function enable(namespaces) { + createDebug.save(namespaces); + createDebug.namespaces = namespaces; + createDebug.names = []; + createDebug.skips = []; + let i; + const split = (typeof namespaces === "string" ? namespaces : "").split(/[\s,]+/); + const len = split.length; + for (i = 0; i < len; i++) { + if (!split[i]) { + continue; + } + namespaces = split[i].replace(/\*/g, ".*?"); + if (namespaces[0] === "-") { + createDebug.skips.push(new RegExp("^" + namespaces.slice(1) + "$")); + } else { + createDebug.names.push(new RegExp("^" + namespaces + "$")); + } + } + } + function disable() { + const namespaces = [ + ...createDebug.names.map(toNamespace), + ...createDebug.skips.map(toNamespace).map((namespace) => "-" + namespace) + ].join(","); + createDebug.enable(""); + return namespaces; + } + function enabled(name) { + if (name[name.length - 1] === "*") { + return true; + } + let i; + let len; + for (i = 0, len = createDebug.skips.length; i < len; i++) { + if (createDebug.skips[i].test(name)) { + return false; + } + } + for (i = 0, len = createDebug.names.length; i < len; i++) { + if (createDebug.names[i].test(name)) { + return true; + } + } + return false; + } + function toNamespace(regexp) { + return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*"); + } + function coerce(val) { + if (val instanceof Error) { + return val.stack || val.message; + } + return val; + } + function destroy() { + console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."); + } + createDebug.enable(createDebug.load()); + return createDebug; } + module2.exports = setup; } - return { - username, - password, - protocol, - lixHost, - namespace, - repoHost, - owner, - repoName - }; -} +}); -// ../../../lix/packages/client/dist/git-http/client.js -function fromValue(value) { - let queue = [value]; - return { - next() { - return Promise.resolve({ done: queue.length === 0, value: queue.pop() }); - }, - return() { - queue = []; - return {}; - }, - [Symbol.asyncIterator]() { - return this; - } - }; -} -function getIterator(iterable) { - if (iterable[Symbol.asyncIterator]) { - return iterable[Symbol.asyncIterator](); - } - if (iterable[Symbol.iterator]) { - return iterable[Symbol.iterator](); - } - if (iterable.next) { - return iterable; - } - return fromValue(iterable); -} -async function forAwait(iterable, cb) { - const iter = getIterator(iterable); - while (true) { - const { value, done } = await iter.next(); - if (value) - await cb(value); - if (done) - break; - } - if (iter.return) - iter.return(); -} -async function collect(iterable) { - let size = 0; - const buffers = []; - await forAwait(iterable, (value) => { - buffers.push(value); - size += value.byteLength; - }); - const result = new Uint8Array(size); - let nextIndex = 0; - for (const buffer of buffers) { - result.set(buffer, nextIndex); - nextIndex += buffer.byteLength; - } - return result; -} -function fromStream(stream) { - if (stream[Symbol.asyncIterator]) - return stream; - const reader = stream.getReader(); - return { - next() { - return reader.read(); - }, - return() { - reader.releaseLock(); - return {}; - }, - [Symbol.asyncIterator]() { - return this; - } - }; -} -function makeHttpClient({ verbose, description, onReq, onRes }) { - async function request({ url, method = "GET", headers = {}, body }) { - if (body) { - body = await collect(body); - } - const origUrl = url; - const origMethod = method; - if (onReq) { - const rewritten = await onReq({ body, url }); - method = rewritten?.method || method; - headers = rewritten?.headers || headers; - body = rewritten?.body || body; - url = rewritten?.url || url; +// ../../../node_modules/.pnpm/debug@4.3.4_supports-color@8.1.1/node_modules/debug/src/browser.js +var require_browser = __commonJS({ + "../../../node_modules/.pnpm/debug@4.3.4_supports-color@8.1.1/node_modules/debug/src/browser.js"(exports2, module2) { + exports2.formatArgs = formatArgs; + exports2.save = save; + exports2.load = load; + exports2.useColors = useColors; + exports2.storage = localstorage(); + exports2.destroy = /* @__PURE__ */ (() => { + let warned = false; + return () => { + if (!warned) { + warned = true; + console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."); + } + }; + })(); + exports2.colors = [ + "#0000CC", + "#0000FF", + "#0033CC", + "#0033FF", + "#0066CC", + "#0066FF", + "#0099CC", + "#0099FF", + "#00CC00", + "#00CC33", + "#00CC66", + "#00CC99", + "#00CCCC", + "#00CCFF", + "#3300CC", + "#3300FF", + "#3333CC", + "#3333FF", + "#3366CC", + "#3366FF", + "#3399CC", + "#3399FF", + "#33CC00", + "#33CC33", + "#33CC66", + "#33CC99", + "#33CCCC", + "#33CCFF", + "#6600CC", + "#6600FF", + "#6633CC", + "#6633FF", + "#66CC00", + "#66CC33", + "#9900CC", + "#9900FF", + "#9933CC", + "#9933FF", + "#99CC00", + "#99CC33", + "#CC0000", + "#CC0033", + "#CC0066", + "#CC0099", + "#CC00CC", + "#CC00FF", + "#CC3300", + "#CC3333", + "#CC3366", + "#CC3399", + "#CC33CC", + "#CC33FF", + "#CC6600", + "#CC6633", + "#CC9900", + "#CC9933", + "#CCCC00", + "#CCCC33", + "#FF0000", + "#FF0033", + "#FF0066", + "#FF0099", + "#FF00CC", + "#FF00FF", + "#FF3300", + "#FF3333", + "#FF3366", + "#FF3399", + "#FF33CC", + "#FF33FF", + "#FF6600", + "#FF6633", + "#FF9900", + "#FF9933", + "#FFCC00", + "#FFCC33" + ]; + function useColors() { + if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) { + return true; + } + if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { + return false; + } + return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773 + typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31? + // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages + typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker + typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/); } - const res = await fetch(url, { method, headers, body, credentials: "include" }); - let resHeaders = {}; - for (const [key, value] of res.headers.entries()) { - resHeaders[key] = value; + function formatArgs(args) { + args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module2.exports.humanize(this.diff); + if (!this.useColors) { + return; + } + const c = "color: " + this.color; + args.splice(1, 0, c, "color: inherit"); + let index2 = 0; + let lastC = 0; + args[0].replace(/%[a-zA-Z%]/g, (match) => { + if (match === "%%") { + return; + } + index2++; + if (match === "%c") { + lastC = index2; + } + }); + args.splice(lastC, 0, c); } - if (verbose) { - console.warn(`${description} git req:`, origUrl); + exports2.log = console.debug || console.log || (() => { + }); + function save(namespaces) { + try { + if (namespaces) { + exports2.storage.setItem("debug", namespaces); + } else { + exports2.storage.removeItem("debug"); + } + } catch (error) { + } } - const statusCode = res.status; - let resBody; - if (onRes) { - const uint8Array = new Uint8Array(await res.arrayBuffer()); - const rewritten = await onRes({ - origUrl, - usedUrl: url, - resBody: uint8Array, - statusCode, - resHeaders - }); - resHeaders = rewritten?.resHeaders || resHeaders; - resBody = rewritten?.resBody || [uint8Array]; + function load() { + let r; + try { + r = exports2.storage.getItem("debug"); + } catch (error) { + } + if (!r && typeof process !== "undefined" && "env" in process) { + r = process.env.DEBUG; + } + return r; } - if (!resBody) { - resBody = res.body && res.body.getReader ? fromStream(res.body) : [new Uint8Array(await res.arrayBuffer())]; + function localstorage() { + try { + return localStorage; + } catch (error) { + } } - return { - url: origUrl, - method: origMethod, - statusCode, - statusMessage: res.statusText, - body: resBody, - headers: resHeaders + module2.exports = require_common2()(exports2); + var { formatters } = module2.exports; + formatters.j = function(v) { + try { + return JSON.stringify(v); + } catch (error) { + return "[UnexpectedJSONParseError]: " + error.message; + } }; } - return { request }; -} +}); -// ../../../lix/packages/client/dist/git-http/helpers.js -function padHex(pad, n) { - const s = n.toString(16); - return "0".repeat(pad - s.length) + s; -} -function encodePackLine(line) { - const flushLine = ""; - if (line === flushLine) { - const paddedHex = padHex(4, 0); - return paddedHex; - } - const length = line.length + 4; - const hexLength = padHex(4, length); - const lineWithLength = hexLength + line; - return lineWithLength; -} -function decodeGitPackLines(concatenatedUint8Array) { - const strings = []; - let offset = 0; - while (offset + 4 < concatenatedUint8Array.length) { - const hexLength = new TextDecoder().decode(concatenatedUint8Array.subarray(offset, offset + 4)); - const packLineLength = parseInt(hexLength, 16); - if (packLineLength === 0) { - strings.push(""); - offset += 4; - } else if (packLineLength === 1) { - throw new Error("decodeGitPackLines does not support delimiter yet"); - } else { - const contentStart = offset + 4; - const stringData = new TextDecoder().decode(concatenatedUint8Array.subarray(contentStart, offset + packLineLength)); - offset += packLineLength; - strings.push(stringData); - } +// ../../../node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js +var require_has_flag = __commonJS({ + "../../../node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js"(exports2, module2) { + "use strict"; + module2.exports = (flag, argv = process.argv) => { + const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--"; + const position = argv.indexOf(prefix + flag); + const terminatorPosition = argv.indexOf("--"); + return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition); + }; } - return strings; -} +}); -// ../../../lix/packages/client/dist/git-http/optimize-refs.js -async function optimizedRefsReq({ url, addRef }) { - if (!url.endsWith("info/refs?service=git-upload-pack")) { - return; - } - const uploadPackUrl = url.replace("info/refs?service=git-upload-pack", "git-upload-pack"); - const lines = []; - lines.push(encodePackLine("command=ls-refs")); - lines.push(encodePackLine("agent=git/isomorphic-git@1.24.5") + "0001"); - if (addRef) { - lines.push(encodePackLine("ref-prefix refs/heads/" + addRef)); - } - lines.push(encodePackLine("ref-prefix HEAD")); - lines.push(encodePackLine("symrefs")); - lines.push(encodePackLine("")); - return { - url: uploadPackUrl, - method: "POST", - headers: { - accept: "application/x-git-upload-pack-result", - "content-type": "application/x-git-upload-pack-request", - "git-protocol": "version=2" - }, - // here we expect the body to be a string - we can just use the array and join it - body: lines.join("") - }; -} -async function optimizedRefsRes({ origUrl, resBody, statusCode, resHeaders }) { - if (!origUrl.endsWith("info/refs?service=git-upload-pack")) { - return; - } - if (statusCode !== 200) { - return; - } else { - let headSymref = ""; - const origLines = decodeGitPackLines(resBody); - const rewrittenLines = ["# service=git-upload-pack\n", ""]; - const capabilites = "\0multi_ack thin-pack side-band side-band-64k ofs-delta shallow deepen-since deepen-not deepen-relative no-progress include-tag multi_ack_detailed allow-tip-sha1-in-want allow-reachable-sha1-in-want no-done filter object-format=sha1"; - for (const line of origLines) { - if (line.includes("HEAD symref-target")) { - headSymref = "refs" + line.slice(64); - headSymref = headSymref.endsWith("\n") ? headSymref.slice(0, -1) : headSymref; - const headBlob = line.slice(0, 40); - rewrittenLines.push(headBlob + " HEAD" + capabilites + " symref=HEAD:" + headSymref); - rewrittenLines.push(headBlob + " " + headSymref); - } else { - rewrittenLines.push(line); +// ../../../node_modules/.pnpm/supports-color@8.1.1/node_modules/supports-color/index.js +var require_supports_color = __commonJS({ + "../../../node_modules/.pnpm/supports-color@8.1.1/node_modules/supports-color/index.js"(exports2, module2) { + "use strict"; + var os = require("os"); + var tty = require("tty"); + var hasFlag = require_has_flag(); + var { env } = process; + var flagForceColor; + if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) { + flagForceColor = 0; + } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) { + flagForceColor = 1; + } + function envForceColor() { + if ("FORCE_COLOR" in env) { + if (env.FORCE_COLOR === "true") { + return 1; + } + if (env.FORCE_COLOR === "false") { + return 0; + } + return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3); } } - rewrittenLines.push(""); - resHeaders["content-type"] = "application/x-git-upload-pack-advertisement"; - const bodyString = rewrittenLines.map((updatedRawLine) => encodePackLine(updatedRawLine)).join(""); - return { - resHeaders, - // eslint-disable-next-line no-undef - resBody: [new TextEncoder().encode(bodyString)] + function translateLevel(level) { + if (level === 0) { + return false; + } + return { + level, + hasBasic: true, + has256: level >= 2, + has16m: level >= 3 + }; + } + function supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) { + const noFlagForceColor = envForceColor(); + if (noFlagForceColor !== void 0) { + flagForceColor = noFlagForceColor; + } + const forceColor = sniffFlags ? flagForceColor : noFlagForceColor; + if (forceColor === 0) { + return 0; + } + if (sniffFlags) { + if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) { + return 3; + } + if (hasFlag("color=256")) { + return 2; + } + } + if (haveStream && !streamIsTTY && forceColor === void 0) { + return 0; + } + const min = forceColor || 0; + if (env.TERM === "dumb") { + return min; + } + if (process.platform === "win32") { + const osRelease = os.release().split("."); + if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) { + return Number(osRelease[2]) >= 14931 ? 3 : 2; + } + return 1; + } + if ("CI" in env) { + if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") { + return 1; + } + return min; + } + if ("TEAMCITY_VERSION" in env) { + return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0; + } + if (env.COLORTERM === "truecolor") { + return 3; + } + if ("TERM_PROGRAM" in env) { + const version3 = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10); + switch (env.TERM_PROGRAM) { + case "iTerm.app": + return version3 >= 3 ? 3 : 2; + case "Apple_Terminal": + return 2; + } + } + if (/-256(color)?$/i.test(env.TERM)) { + return 2; + } + if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) { + return 1; + } + if ("COLORTERM" in env) { + return 1; + } + return min; + } + function getSupportLevel(stream, options = {}) { + const level = supportsColor(stream, { + streamIsTTY: stream && stream.isTTY, + ...options + }); + return translateLevel(level); + } + module2.exports = { + supportsColor: getSupportLevel, + stdout: getSupportLevel({ isTTY: tty.isatty(1) }), + stderr: getSupportLevel({ isTTY: tty.isatty(2) }) }; } -} - -// ../../../lix/packages/client/dist/openRepository.js -var import_octokit = __toESM(require_dist_node26(), 1); +}); -// ../../../node_modules/.pnpm/solid-js@1.7.11/node_modules/solid-js/dist/solid.js -var sharedConfig = { - context: void 0, - registry: void 0 -}; -function setHydrateContext(context2) { - sharedConfig.context = context2; -} -var equalFn = (a, b) => a === b; -var $PROXY = Symbol("solid-proxy"); -var $TRACK = Symbol("solid-track"); -var $DEVCOMP = Symbol("solid-dev-component"); -var signalOptions = { - equals: equalFn -}; -var ERROR = null; -var runEffects = runQueue; -var STALE = 1; -var PENDING = 2; -var UNOWNED = { - owned: null, - cleanups: null, - context: null, - owner: null -}; -var Owner = null; -var Transition = null; -var Scheduler = null; -var ExternalSourceFactory = null; -var Listener = null; -var Updates = null; -var Effects = null; -var ExecCount = 0; -var [transPending, setTransPending] = /* @__PURE__ */ createSignal(false); -function createSignal(value, options) { - options = options ? Object.assign({}, signalOptions, options) : signalOptions; - const s = { - value, - observers: null, - observerSlots: null, - comparator: options.equals || void 0 - }; - const setter = (value2) => { - if (typeof value2 === "function") { - if (Transition && Transition.running && Transition.sources.has(s)) - value2 = value2(s.tValue); - else - value2 = value2(s.value); - } - return writeSignal(s, value2); - }; - return [readSignal.bind(s), setter]; -} -function createRenderEffect(fn, value, options) { - const c = createComputation(fn, value, false, STALE); - if (Scheduler && Transition && Transition.running) - Updates.push(c); - else - updateComputation(c); -} -function createEffect(fn, value, options) { - runEffects = runUserEffects; - const c = createComputation(fn, value, false, STALE), s = SuspenseContext && useContext(SuspenseContext); - if (s) - c.suspense = s; - if (!options || !options.render) - c.user = true; - Effects ? Effects.push(c) : updateComputation(c); -} -function createMemo(fn, value, options) { - options = options ? Object.assign({}, signalOptions, options) : signalOptions; - const c = createComputation(fn, value, true, 0); - c.observers = null; - c.observerSlots = null; - c.comparator = options.equals || void 0; - if (Scheduler && Transition && Transition.running) { - c.tState = STALE; - Updates.push(c); - } else - updateComputation(c); - return readSignal.bind(c); -} -function untrack(fn) { - if (Listener === null) - return fn(); - const listener = Listener; - Listener = null; - try { - return fn(); - } finally { - Listener = listener; - } -} -function onCleanup(fn) { - if (Owner === null) - ; - else if (Owner.cleanups === null) - Owner.cleanups = [fn]; - else - Owner.cleanups.push(fn); - return fn; -} -function startTransition(fn) { - if (Transition && Transition.running) { - fn(); - return Transition.done; - } - const l = Listener; - const o = Owner; - return Promise.resolve().then(() => { - Listener = l; - Owner = o; - let t; - if (Scheduler || SuspenseContext) { - t = Transition || (Transition = { - sources: /* @__PURE__ */ new Set(), - effects: [], - promises: /* @__PURE__ */ new Set(), - disposed: /* @__PURE__ */ new Set(), - queue: /* @__PURE__ */ new Set(), - running: true +// ../../../node_modules/.pnpm/debug@4.3.4_supports-color@8.1.1/node_modules/debug/src/node.js +var require_node = __commonJS({ + "../../../node_modules/.pnpm/debug@4.3.4_supports-color@8.1.1/node_modules/debug/src/node.js"(exports2, module2) { + var tty = require("tty"); + var util = require("util"); + exports2.init = init2; + exports2.log = log3; + exports2.formatArgs = formatArgs; + exports2.save = save; + exports2.load = load; + exports2.useColors = useColors; + exports2.destroy = util.deprecate( + () => { + }, + "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`." + ); + exports2.colors = [6, 2, 3, 4, 5, 1]; + try { + const supportsColor = require_supports_color(); + if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) { + exports2.colors = [ + 20, + 21, + 26, + 27, + 32, + 33, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 56, + 57, + 62, + 63, + 68, + 69, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 92, + 93, + 98, + 99, + 112, + 113, + 128, + 129, + 134, + 135, + 148, + 149, + 160, + 161, + 162, + 163, + 164, + 165, + 166, + 167, + 168, + 169, + 170, + 171, + 172, + 173, + 178, + 179, + 184, + 185, + 196, + 197, + 198, + 199, + 200, + 201, + 202, + 203, + 204, + 205, + 206, + 207, + 208, + 209, + 214, + 215, + 220, + 221 + ]; + } + } catch (error) { + } + exports2.inspectOpts = Object.keys(process.env).filter((key) => { + return /^debug_/i.test(key); + }).reduce((obj, key) => { + const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => { + return k.toUpperCase(); }); - t.done || (t.done = new Promise((res) => t.resolve = res)); - t.running = true; + let val = process.env[key]; + if (/^(yes|on|true|enabled)$/i.test(val)) { + val = true; + } else if (/^(no|off|false|disabled)$/i.test(val)) { + val = false; + } else if (val === "null") { + val = null; + } else { + val = Number(val); + } + obj[prop] = val; + return obj; + }, {}); + function useColors() { + return "colors" in exports2.inspectOpts ? Boolean(exports2.inspectOpts.colors) : tty.isatty(process.stderr.fd); } - runUpdates(fn, false); - Listener = Owner = null; - return t ? t.done : void 0; - }); -} -function createContext(defaultValue, options) { - const id = Symbol("context"); - return { - id, - Provider: createProvider(id), - defaultValue - }; -} -function useContext(context2) { - return Owner && Owner.context && Owner.context[context2.id] !== void 0 ? Owner.context[context2.id] : context2.defaultValue; -} -function children(fn) { - const children3 = createMemo(fn); - const memo2 = createMemo(() => resolveChildren(children3())); - memo2.toArray = () => { - const c = memo2(); - return Array.isArray(c) ? c : c != null ? [c] : []; - }; - return memo2; -} -var SuspenseContext; -function readSignal() { - const runningTransition = Transition && Transition.running; - if (this.sources && (runningTransition ? this.tState : this.state)) { - if ((runningTransition ? this.tState : this.state) === STALE) - updateComputation(this); - else { - const updates = Updates; - Updates = null; - runUpdates(() => lookUpstream(this), false); - Updates = updates; + function formatArgs(args) { + const { namespace: name, useColors: useColors2 } = this; + if (useColors2) { + const c = this.color; + const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c); + const prefix = ` ${colorCode};1m${name} \x1B[0m`; + args[0] = prefix + args[0].split("\n").join("\n" + prefix); + args.push(colorCode + "m+" + module2.exports.humanize(this.diff) + "\x1B[0m"); + } else { + args[0] = getDate() + name + " " + args[0]; + } } - } - if (Listener) { - const sSlot = this.observers ? this.observers.length : 0; - if (!Listener.sources) { - Listener.sources = [this]; - Listener.sourceSlots = [sSlot]; - } else { - Listener.sources.push(this); - Listener.sourceSlots.push(sSlot); + function getDate() { + if (exports2.inspectOpts.hideDate) { + return ""; + } + return (/* @__PURE__ */ new Date()).toISOString() + " "; } - if (!this.observers) { - this.observers = [Listener]; - this.observerSlots = [Listener.sources.length - 1]; - } else { - this.observers.push(Listener); - this.observerSlots.push(Listener.sources.length - 1); + function log3(...args) { + return process.stderr.write(util.format(...args) + "\n"); } - } - if (runningTransition && Transition.sources.has(this)) - return this.tValue; - return this.value; -} -function writeSignal(node, value, isComp) { - let current = Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value; - if (!node.comparator || !node.comparator(current, value)) { - if (Transition) { - const TransitionRunning = Transition.running; - if (TransitionRunning || !isComp && Transition.sources.has(node)) { - Transition.sources.add(node); - node.tValue = value; + function save(namespaces) { + if (namespaces) { + process.env.DEBUG = namespaces; + } else { + delete process.env.DEBUG; } - if (!TransitionRunning) - node.value = value; - } else - node.value = value; - if (node.observers && node.observers.length) { - runUpdates(() => { - for (let i = 0; i < node.observers.length; i += 1) { - const o = node.observers[i]; - const TransitionRunning = Transition && Transition.running; - if (TransitionRunning && Transition.disposed.has(o)) - continue; - if (TransitionRunning ? !o.tState : !o.state) { - if (o.pure) - Updates.push(o); - else - Effects.push(o); - if (o.observers) - markDownstream(o); - } - if (!TransitionRunning) - o.state = STALE; - else - o.tState = STALE; - } - if (Updates.length > 1e6) { - Updates = []; - if (false) - ; - throw new Error(); - } - }, false); } - } - return value; -} -function updateComputation(node) { - if (!node.fn) - return; - cleanNode(node); - const owner = Owner, listener = Listener, time = ExecCount; - Listener = Owner = node; - runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time); - if (Transition && !Transition.running && Transition.sources.has(node)) { - queueMicrotask(() => { - runUpdates(() => { - Transition && (Transition.running = true); - Listener = Owner = node; - runComputation(node, node.tValue, time); - Listener = Owner = null; - }, false); - }); - } - Listener = listener; - Owner = owner; -} -function runComputation(node, value, time) { - let nextValue; - try { - nextValue = node.fn(value); - } catch (err) { - if (node.pure) { - if (Transition && Transition.running) { - node.tState = STALE; - node.tOwned && node.tOwned.forEach(cleanNode); - node.tOwned = void 0; - } else { - node.state = STALE; - node.owned && node.owned.forEach(cleanNode); - node.owned = null; + function load() { + return process.env.DEBUG; + } + function init2(debug4) { + debug4.inspectOpts = {}; + const keys = Object.keys(exports2.inspectOpts); + for (let i = 0; i < keys.length; i++) { + debug4.inspectOpts[keys[i]] = exports2.inspectOpts[keys[i]]; } } - node.updatedAt = time + 1; - return handleError(err); - } - if (!node.updatedAt || node.updatedAt <= time) { - if (node.updatedAt != null && "observers" in node) { - writeSignal(node, nextValue, true); - } else if (Transition && Transition.running && node.pure) { - Transition.sources.add(node); - node.tValue = nextValue; - } else - node.value = nextValue; - node.updatedAt = time; - } -} -function createComputation(fn, init2, pure, state = STALE, options) { - const c = { - fn, - state, - updatedAt: null, - owned: null, - sources: null, - sourceSlots: null, - cleanups: null, - value: init2, - owner: Owner, - context: Owner ? Owner.context : null, - pure - }; - if (Transition && Transition.running) { - c.state = 0; - c.tState = state; + module2.exports = require_common2()(exports2); + var { formatters } = module2.exports; + formatters.o = function(v) { + this.inspectOpts.colors = this.useColors; + return util.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" "); + }; + formatters.O = function(v) { + this.inspectOpts.colors = this.useColors; + return util.inspect(v, this.inspectOpts); + }; } - if (Owner === null) - ; - else if (Owner !== UNOWNED) { - if (Transition && Transition.running && Owner.pure) { - if (!Owner.tOwned) - Owner.tOwned = [c]; - else - Owner.tOwned.push(c); +}); + +// ../../../node_modules/.pnpm/debug@4.3.4_supports-color@8.1.1/node_modules/debug/src/index.js +var require_src = __commonJS({ + "../../../node_modules/.pnpm/debug@4.3.4_supports-color@8.1.1/node_modules/debug/src/index.js"(exports2, module2) { + if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) { + module2.exports = require_browser(); } else { - if (!Owner.owned) - Owner.owned = [c]; - else - Owner.owned.push(c); + module2.exports = require_node(); } } - if (ExternalSourceFactory) { - const [track, trigger] = createSignal(void 0, { - equals: false - }); - const ordinary = ExternalSourceFactory(c.fn, trigger); - onCleanup(() => ordinary.dispose()); - const triggerInTransition = () => startTransition(trigger).then(() => inTransition.dispose()); - const inTransition = ExternalSourceFactory(c.fn, triggerInTransition); - c.fn = (x) => { - track(); - return Transition && Transition.running ? inTransition.track(x) : ordinary.track(x); - }; - } - return c; -} -function runTop(node) { - const runningTransition = Transition && Transition.running; - if ((runningTransition ? node.tState : node.state) === 0) - return; - if ((runningTransition ? node.tState : node.state) === PENDING) - return lookUpstream(node); - if (node.suspense && untrack(node.suspense.inFallback)) - return node.suspense.effects.push(node); - const ancestors = [node]; - while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) { - if (runningTransition && Transition.disposed.has(node)) - return; - if (runningTransition ? node.tState : node.state) - ancestors.push(node); - } - for (let i = ancestors.length - 1; i >= 0; i--) { - node = ancestors[i]; - if (runningTransition) { - let top = node, prev = ancestors[i + 1]; - while ((top = top.owner) && top !== prev) { - if (Transition.disposed.has(top)) - return; +}); + +// ../../../node_modules/.pnpm/murmurhash3js@3.0.1/node_modules/murmurhash3js/lib/murmurHash3js.js +var require_murmurHash3js = __commonJS({ + "../../../node_modules/.pnpm/murmurhash3js@3.0.1/node_modules/murmurhash3js/lib/murmurHash3js.js"(exports2, module2) { + (function(root, undefined2) { + "use strict"; + var library = { + "version": "3.0.1", + "x86": {}, + "x64": {} + }; + function _x86Multiply(m, n) { + return (m & 65535) * n + (((m >>> 16) * n & 65535) << 16); } - } - if ((runningTransition ? node.tState : node.state) === STALE) { - updateComputation(node); - } else if ((runningTransition ? node.tState : node.state) === PENDING) { - const updates = Updates; - Updates = null; - runUpdates(() => lookUpstream(node, ancestors[0]), false); - Updates = updates; - } - } -} -function runUpdates(fn, init2) { - if (Updates) - return fn(); - let wait = false; - if (!init2) - Updates = []; - if (Effects) - wait = true; - else - Effects = []; - ExecCount++; - try { - const res = fn(); - completeUpdates(wait); - return res; - } catch (err) { - if (!wait) - Effects = null; - Updates = null; - handleError(err); - } -} -function completeUpdates(wait) { - if (Updates) { - if (Scheduler && Transition && Transition.running) - scheduleQueue(Updates); - else - runQueue(Updates); - Updates = null; - } - if (wait) - return; - let res; - if (Transition) { - if (!Transition.promises.size && !Transition.queue.size) { - const sources = Transition.sources; - const disposed = Transition.disposed; - Effects.push.apply(Effects, Transition.effects); - res = Transition.resolve; - for (const e2 of Effects) { - "tState" in e2 && (e2.state = e2.tState); - delete e2.tState; + function _x86Rotl(m, n) { + return m << n | m >>> 32 - n; } - Transition = null; - runUpdates(() => { - for (const d of disposed) - cleanNode(d); - for (const v of sources) { - v.value = v.tValue; - if (v.owned) { - for (let i = 0, len = v.owned.length; i < len; i++) - cleanNode(v.owned[i]); - } - if (v.tOwned) - v.owned = v.tOwned; - delete v.tValue; - delete v.tOwned; - v.tState = 0; + function _x86Fmix(h) { + h ^= h >>> 16; + h = _x86Multiply(h, 2246822507); + h ^= h >>> 13; + h = _x86Multiply(h, 3266489909); + h ^= h >>> 16; + return h; + } + function _x64Add(m, n) { + m = [m[0] >>> 16, m[0] & 65535, m[1] >>> 16, m[1] & 65535]; + n = [n[0] >>> 16, n[0] & 65535, n[1] >>> 16, n[1] & 65535]; + var o = [0, 0, 0, 0]; + o[3] += m[3] + n[3]; + o[2] += o[3] >>> 16; + o[3] &= 65535; + o[2] += m[2] + n[2]; + o[1] += o[2] >>> 16; + o[2] &= 65535; + o[1] += m[1] + n[1]; + o[0] += o[1] >>> 16; + o[1] &= 65535; + o[0] += m[0] + n[0]; + o[0] &= 65535; + return [o[0] << 16 | o[1], o[2] << 16 | o[3]]; + } + function _x64Multiply(m, n) { + m = [m[0] >>> 16, m[0] & 65535, m[1] >>> 16, m[1] & 65535]; + n = [n[0] >>> 16, n[0] & 65535, n[1] >>> 16, n[1] & 65535]; + var o = [0, 0, 0, 0]; + o[3] += m[3] * n[3]; + o[2] += o[3] >>> 16; + o[3] &= 65535; + o[2] += m[2] * n[3]; + o[1] += o[2] >>> 16; + o[2] &= 65535; + o[2] += m[3] * n[2]; + o[1] += o[2] >>> 16; + o[2] &= 65535; + o[1] += m[1] * n[3]; + o[0] += o[1] >>> 16; + o[1] &= 65535; + o[1] += m[2] * n[2]; + o[0] += o[1] >>> 16; + o[1] &= 65535; + o[1] += m[3] * n[1]; + o[0] += o[1] >>> 16; + o[1] &= 65535; + o[0] += m[0] * n[3] + m[1] * n[2] + m[2] * n[1] + m[3] * n[0]; + o[0] &= 65535; + return [o[0] << 16 | o[1], o[2] << 16 | o[3]]; + } + function _x64Rotl(m, n) { + n %= 64; + if (n === 32) { + return [m[1], m[0]]; + } else if (n < 32) { + return [m[0] << n | m[1] >>> 32 - n, m[1] << n | m[0] >>> 32 - n]; + } else { + n -= 32; + return [m[1] << n | m[0] >>> 32 - n, m[0] << n | m[1] >>> 32 - n]; + } + } + function _x64LeftShift(m, n) { + n %= 64; + if (n === 0) { + return m; + } else if (n < 32) { + return [m[0] << n | m[1] >>> 32 - n, m[1] << n]; + } else { + return [m[1] << n - 32, 0]; + } + } + function _x64Xor(m, n) { + return [m[0] ^ n[0], m[1] ^ n[1]]; + } + function _x64Fmix(h) { + h = _x64Xor(h, [0, h[0] >>> 1]); + h = _x64Multiply(h, [4283543511, 3981806797]); + h = _x64Xor(h, [0, h[0] >>> 1]); + h = _x64Multiply(h, [3301882366, 444984403]); + h = _x64Xor(h, [0, h[0] >>> 1]); + return h; + } + library.x86.hash32 = function(key, seed) { + key = key || ""; + seed = seed || 0; + var remainder = key.length % 4; + var bytes = key.length - remainder; + var h1 = seed; + var k1 = 0; + var c1 = 3432918353; + var c2 = 461845907; + for (var i = 0; i < bytes; i = i + 4) { + k1 = key.charCodeAt(i) & 255 | (key.charCodeAt(i + 1) & 255) << 8 | (key.charCodeAt(i + 2) & 255) << 16 | (key.charCodeAt(i + 3) & 255) << 24; + k1 = _x86Multiply(k1, c1); + k1 = _x86Rotl(k1, 15); + k1 = _x86Multiply(k1, c2); + h1 ^= k1; + h1 = _x86Rotl(h1, 13); + h1 = _x86Multiply(h1, 5) + 3864292196; + } + k1 = 0; + switch (remainder) { + case 3: + k1 ^= (key.charCodeAt(i + 2) & 255) << 16; + case 2: + k1 ^= (key.charCodeAt(i + 1) & 255) << 8; + case 1: + k1 ^= key.charCodeAt(i) & 255; + k1 = _x86Multiply(k1, c1); + k1 = _x86Rotl(k1, 15); + k1 = _x86Multiply(k1, c2); + h1 ^= k1; + } + h1 ^= key.length; + h1 = _x86Fmix(h1); + return h1 >>> 0; + }; + library.x86.hash128 = function(key, seed) { + key = key || ""; + seed = seed || 0; + var remainder = key.length % 16; + var bytes = key.length - remainder; + var h1 = seed; + var h2 = seed; + var h3 = seed; + var h4 = seed; + var k1 = 0; + var k2 = 0; + var k3 = 0; + var k4 = 0; + var c1 = 597399067; + var c2 = 2869860233; + var c3 = 951274213; + var c4 = 2716044179; + for (var i = 0; i < bytes; i = i + 16) { + k1 = key.charCodeAt(i) & 255 | (key.charCodeAt(i + 1) & 255) << 8 | (key.charCodeAt(i + 2) & 255) << 16 | (key.charCodeAt(i + 3) & 255) << 24; + k2 = key.charCodeAt(i + 4) & 255 | (key.charCodeAt(i + 5) & 255) << 8 | (key.charCodeAt(i + 6) & 255) << 16 | (key.charCodeAt(i + 7) & 255) << 24; + k3 = key.charCodeAt(i + 8) & 255 | (key.charCodeAt(i + 9) & 255) << 8 | (key.charCodeAt(i + 10) & 255) << 16 | (key.charCodeAt(i + 11) & 255) << 24; + k4 = key.charCodeAt(i + 12) & 255 | (key.charCodeAt(i + 13) & 255) << 8 | (key.charCodeAt(i + 14) & 255) << 16 | (key.charCodeAt(i + 15) & 255) << 24; + k1 = _x86Multiply(k1, c1); + k1 = _x86Rotl(k1, 15); + k1 = _x86Multiply(k1, c2); + h1 ^= k1; + h1 = _x86Rotl(h1, 19); + h1 += h2; + h1 = _x86Multiply(h1, 5) + 1444728091; + k2 = _x86Multiply(k2, c2); + k2 = _x86Rotl(k2, 16); + k2 = _x86Multiply(k2, c3); + h2 ^= k2; + h2 = _x86Rotl(h2, 17); + h2 += h3; + h2 = _x86Multiply(h2, 5) + 197830471; + k3 = _x86Multiply(k3, c3); + k3 = _x86Rotl(k3, 17); + k3 = _x86Multiply(k3, c4); + h3 ^= k3; + h3 = _x86Rotl(h3, 15); + h3 += h4; + h3 = _x86Multiply(h3, 5) + 2530024501; + k4 = _x86Multiply(k4, c4); + k4 = _x86Rotl(k4, 18); + k4 = _x86Multiply(k4, c1); + h4 ^= k4; + h4 = _x86Rotl(h4, 13); + h4 += h1; + h4 = _x86Multiply(h4, 5) + 850148119; } - setTransPending(false); - }, false); - } else if (Transition.running) { - Transition.running = false; - Transition.effects.push.apply(Transition.effects, Effects); - Effects = null; - setTransPending(true); - return; - } - } - const e = Effects; - Effects = null; - if (e.length) - runUpdates(() => runEffects(e), false); - if (res) - res(); -} -function runQueue(queue) { - for (let i = 0; i < queue.length; i++) - runTop(queue[i]); -} -function scheduleQueue(queue) { - for (let i = 0; i < queue.length; i++) { - const item = queue[i]; - const tasks = Transition.queue; - if (!tasks.has(item)) { - tasks.add(item); - Scheduler(() => { - tasks.delete(item); - runUpdates(() => { - Transition.running = true; - runTop(item); - }, false); - Transition && (Transition.running = false); - }); - } - } -} -function runUserEffects(queue) { - let i, userLength = 0; - for (i = 0; i < queue.length; i++) { - const e = queue[i]; - if (!e.user) - runTop(e); - else - queue[userLength++] = e; - } - if (sharedConfig.context) { - if (sharedConfig.count) { - sharedConfig.effects || (sharedConfig.effects = []); - sharedConfig.effects.push(...queue.slice(0, userLength)); - return; - } else if (sharedConfig.effects) { - queue = [...sharedConfig.effects, ...queue]; - userLength += sharedConfig.effects.length; - delete sharedConfig.effects; - } - setHydrateContext(); - } - for (i = 0; i < userLength; i++) - runTop(queue[i]); -} -function lookUpstream(node, ignore2) { - const runningTransition = Transition && Transition.running; - if (runningTransition) - node.tState = 0; - else - node.state = 0; - for (let i = 0; i < node.sources.length; i += 1) { - const source = node.sources[i]; - if (source.sources) { - const state = runningTransition ? source.tState : source.state; - if (state === STALE) { - if (source !== ignore2 && (!source.updatedAt || source.updatedAt < ExecCount)) - runTop(source); - } else if (state === PENDING) - lookUpstream(source, ignore2); - } - } -} -function markDownstream(node) { - const runningTransition = Transition && Transition.running; - for (let i = 0; i < node.observers.length; i += 1) { - const o = node.observers[i]; - if (runningTransition ? !o.tState : !o.state) { - if (runningTransition) - o.tState = PENDING; - else - o.state = PENDING; - if (o.pure) - Updates.push(o); - else - Effects.push(o); - o.observers && markDownstream(o); - } - } -} -function cleanNode(node) { - let i; - if (node.sources) { - while (node.sources.length) { - const source = node.sources.pop(), index2 = node.sourceSlots.pop(), obs = source.observers; - if (obs && obs.length) { - const n = obs.pop(), s = source.observerSlots.pop(); - if (index2 < obs.length) { - n.sourceSlots[s] = index2; - obs[index2] = n; - source.observerSlots[index2] = s; + k1 = 0; + k2 = 0; + k3 = 0; + k4 = 0; + switch (remainder) { + case 15: + k4 ^= key.charCodeAt(i + 14) << 16; + case 14: + k4 ^= key.charCodeAt(i + 13) << 8; + case 13: + k4 ^= key.charCodeAt(i + 12); + k4 = _x86Multiply(k4, c4); + k4 = _x86Rotl(k4, 18); + k4 = _x86Multiply(k4, c1); + h4 ^= k4; + case 12: + k3 ^= key.charCodeAt(i + 11) << 24; + case 11: + k3 ^= key.charCodeAt(i + 10) << 16; + case 10: + k3 ^= key.charCodeAt(i + 9) << 8; + case 9: + k3 ^= key.charCodeAt(i + 8); + k3 = _x86Multiply(k3, c3); + k3 = _x86Rotl(k3, 17); + k3 = _x86Multiply(k3, c4); + h3 ^= k3; + case 8: + k2 ^= key.charCodeAt(i + 7) << 24; + case 7: + k2 ^= key.charCodeAt(i + 6) << 16; + case 6: + k2 ^= key.charCodeAt(i + 5) << 8; + case 5: + k2 ^= key.charCodeAt(i + 4); + k2 = _x86Multiply(k2, c2); + k2 = _x86Rotl(k2, 16); + k2 = _x86Multiply(k2, c3); + h2 ^= k2; + case 4: + k1 ^= key.charCodeAt(i + 3) << 24; + case 3: + k1 ^= key.charCodeAt(i + 2) << 16; + case 2: + k1 ^= key.charCodeAt(i + 1) << 8; + case 1: + k1 ^= key.charCodeAt(i); + k1 = _x86Multiply(k1, c1); + k1 = _x86Rotl(k1, 15); + k1 = _x86Multiply(k1, c2); + h1 ^= k1; + } + h1 ^= key.length; + h2 ^= key.length; + h3 ^= key.length; + h4 ^= key.length; + h1 += h2; + h1 += h3; + h1 += h4; + h2 += h1; + h3 += h1; + h4 += h1; + h1 = _x86Fmix(h1); + h2 = _x86Fmix(h2); + h3 = _x86Fmix(h3); + h4 = _x86Fmix(h4); + h1 += h2; + h1 += h3; + h1 += h4; + h2 += h1; + h3 += h1; + h4 += h1; + return ("00000000" + (h1 >>> 0).toString(16)).slice(-8) + ("00000000" + (h2 >>> 0).toString(16)).slice(-8) + ("00000000" + (h3 >>> 0).toString(16)).slice(-8) + ("00000000" + (h4 >>> 0).toString(16)).slice(-8); + }; + library.x64.hash128 = function(key, seed) { + key = key || ""; + seed = seed || 0; + var remainder = key.length % 16; + var bytes = key.length - remainder; + var h1 = [0, seed]; + var h2 = [0, seed]; + var k1 = [0, 0]; + var k2 = [0, 0]; + var c1 = [2277735313, 289559509]; + var c2 = [1291169091, 658871167]; + for (var i = 0; i < bytes; i = i + 16) { + k1 = [key.charCodeAt(i + 4) & 255 | (key.charCodeAt(i + 5) & 255) << 8 | (key.charCodeAt(i + 6) & 255) << 16 | (key.charCodeAt(i + 7) & 255) << 24, key.charCodeAt(i) & 255 | (key.charCodeAt(i + 1) & 255) << 8 | (key.charCodeAt(i + 2) & 255) << 16 | (key.charCodeAt(i + 3) & 255) << 24]; + k2 = [key.charCodeAt(i + 12) & 255 | (key.charCodeAt(i + 13) & 255) << 8 | (key.charCodeAt(i + 14) & 255) << 16 | (key.charCodeAt(i + 15) & 255) << 24, key.charCodeAt(i + 8) & 255 | (key.charCodeAt(i + 9) & 255) << 8 | (key.charCodeAt(i + 10) & 255) << 16 | (key.charCodeAt(i + 11) & 255) << 24]; + k1 = _x64Multiply(k1, c1); + k1 = _x64Rotl(k1, 31); + k1 = _x64Multiply(k1, c2); + h1 = _x64Xor(h1, k1); + h1 = _x64Rotl(h1, 27); + h1 = _x64Add(h1, h2); + h1 = _x64Add(_x64Multiply(h1, [0, 5]), [0, 1390208809]); + k2 = _x64Multiply(k2, c2); + k2 = _x64Rotl(k2, 33); + k2 = _x64Multiply(k2, c1); + h2 = _x64Xor(h2, k2); + h2 = _x64Rotl(h2, 31); + h2 = _x64Add(h2, h1); + h2 = _x64Add(_x64Multiply(h2, [0, 5]), [0, 944331445]); + } + k1 = [0, 0]; + k2 = [0, 0]; + switch (remainder) { + case 15: + k2 = _x64Xor(k2, _x64LeftShift([0, key.charCodeAt(i + 14)], 48)); + case 14: + k2 = _x64Xor(k2, _x64LeftShift([0, key.charCodeAt(i + 13)], 40)); + case 13: + k2 = _x64Xor(k2, _x64LeftShift([0, key.charCodeAt(i + 12)], 32)); + case 12: + k2 = _x64Xor(k2, _x64LeftShift([0, key.charCodeAt(i + 11)], 24)); + case 11: + k2 = _x64Xor(k2, _x64LeftShift([0, key.charCodeAt(i + 10)], 16)); + case 10: + k2 = _x64Xor(k2, _x64LeftShift([0, key.charCodeAt(i + 9)], 8)); + case 9: + k2 = _x64Xor(k2, [0, key.charCodeAt(i + 8)]); + k2 = _x64Multiply(k2, c2); + k2 = _x64Rotl(k2, 33); + k2 = _x64Multiply(k2, c1); + h2 = _x64Xor(h2, k2); + case 8: + k1 = _x64Xor(k1, _x64LeftShift([0, key.charCodeAt(i + 7)], 56)); + case 7: + k1 = _x64Xor(k1, _x64LeftShift([0, key.charCodeAt(i + 6)], 48)); + case 6: + k1 = _x64Xor(k1, _x64LeftShift([0, key.charCodeAt(i + 5)], 40)); + case 5: + k1 = _x64Xor(k1, _x64LeftShift([0, key.charCodeAt(i + 4)], 32)); + case 4: + k1 = _x64Xor(k1, _x64LeftShift([0, key.charCodeAt(i + 3)], 24)); + case 3: + k1 = _x64Xor(k1, _x64LeftShift([0, key.charCodeAt(i + 2)], 16)); + case 2: + k1 = _x64Xor(k1, _x64LeftShift([0, key.charCodeAt(i + 1)], 8)); + case 1: + k1 = _x64Xor(k1, [0, key.charCodeAt(i)]); + k1 = _x64Multiply(k1, c1); + k1 = _x64Rotl(k1, 31); + k1 = _x64Multiply(k1, c2); + h1 = _x64Xor(h1, k1); + } + h1 = _x64Xor(h1, [0, key.length]); + h2 = _x64Xor(h2, [0, key.length]); + h1 = _x64Add(h1, h2); + h2 = _x64Add(h2, h1); + h1 = _x64Fmix(h1); + h2 = _x64Fmix(h2); + h1 = _x64Add(h1, h2); + h2 = _x64Add(h2, h1); + return ("00000000" + (h1[0] >>> 0).toString(16)).slice(-8) + ("00000000" + (h1[1] >>> 0).toString(16)).slice(-8) + ("00000000" + (h2[0] >>> 0).toString(16)).slice(-8) + ("00000000" + (h2[1] >>> 0).toString(16)).slice(-8); + }; + if (typeof exports2 !== "undefined") { + if (typeof module2 !== "undefined" && module2.exports) { + exports2 = module2.exports = library; } + exports2.murmurHash3 = library; + } else if (typeof define === "function" && define.amd) { + define([], function() { + return library; + }); + } else { + library._murmurHash3 = root.murmurHash3; + library.noConflict = function() { + root.murmurHash3 = library._murmurHash3; + library._murmurHash3 = undefined2; + library.noConflict = undefined2; + return library; + }; + root.murmurHash3 = library; } - } - } - if (Transition && Transition.running && node.pure) { - if (node.tOwned) { - for (i = node.tOwned.length - 1; i >= 0; i--) - cleanNode(node.tOwned[i]); - delete node.tOwned; - } - reset(node, true); - } else if (node.owned) { - for (i = node.owned.length - 1; i >= 0; i--) - cleanNode(node.owned[i]); - node.owned = null; - } - if (node.cleanups) { - for (i = node.cleanups.length - 1; i >= 0; i--) - node.cleanups[i](); - node.cleanups = null; - } - if (Transition && Transition.running) - node.tState = 0; - else - node.state = 0; -} -function reset(node, top) { - if (!top) { - node.tState = 0; - Transition.disposed.add(node); - } - if (node.owned) { - for (let i = 0; i < node.owned.length; i++) - reset(node.owned[i]); - } -} -function castError(err) { - if (err instanceof Error) - return err; - return new Error(typeof err === "string" ? err : "Unknown error", { - cause: err - }); -} -function runErrors(err, fns, owner) { - try { - for (const f of fns) - f(err); - } catch (e) { - handleError(e, owner && owner.owner || null); + })(exports2); } -} -function handleError(err, owner = Owner) { - const fns = ERROR && owner && owner.context && owner.context[ERROR]; - const error = castError(err); - if (!fns) - throw error; - if (Effects) - Effects.push({ - fn() { - runErrors(error, fns, owner); - }, - state: STALE - }); - else - runErrors(error, fns, owner); -} -function resolveChildren(children3) { - if (typeof children3 === "function" && !children3.length) - return resolveChildren(children3()); - if (Array.isArray(children3)) { - const results = []; - for (let i = 0; i < children3.length; i++) { - const result = resolveChildren(children3[i]); - Array.isArray(result) ? results.push.apply(results, result) : results.push(result); - } - return results; +}); + +// ../../../node_modules/.pnpm/murmurhash3js@3.0.1/node_modules/murmurhash3js/index.js +var require_murmurhash3js = __commonJS({ + "../../../node_modules/.pnpm/murmurhash3js@3.0.1/node_modules/murmurhash3js/index.js"(exports2, module2) { + module2.exports = require_murmurHash3js(); } - return children3; -} -function createProvider(id, options) { - return function provider(props) { - let res; - createRenderEffect(() => res = untrack(() => { - Owner.context = { - ...Owner.context, - [id]: props.value - }; - return children(() => props.children); - }), void 0); - return res; - }; -} -var FALLBACK = Symbol("fallback"); -var SuspenseListContext = createContext(); +}); -// ../../../lix/packages/client/dist/solid.js -var createSignal2 = createSignal; -var createEffect2 = createEffect; +// src/main.ts +var fs = __toESM(require("node:fs/promises"), 1); +var core = __toESM(require_core(), 1); +var github = __toESM(require_github(), 1); // ../../../lix/packages/client/vendored/isomorphic-git/index.js var import_async_lock = __toESM(require_async_lock(), 1); @@ -49397,7 +48433,7 @@ function readOp(reader, source) { return reader.slice(byte); } } -function fromValue2(value) { +function fromValue(value) { let queue = [value]; return { next() { @@ -49412,7 +48448,7 @@ function fromValue2(value) { } }; } -function getIterator2(iterable) { +function getIterator(iterable) { if (iterable[Symbol.asyncIterator]) { return iterable[Symbol.asyncIterator](); } @@ -49422,11 +48458,11 @@ function getIterator2(iterable) { if (iterable.next) { return iterable; } - return fromValue2(iterable); + return fromValue(iterable); } var StreamReader = class { constructor(stream) { - this.stream = getIterator2(stream); + this.stream = getIterator(stream); this.buffer = null; this.cursor = 0; this.undoCursor = 0; @@ -51027,14 +50063,14 @@ async function _walk({ // @ts-ignore map = async (_, entry) => entry, // The default reducer is a flatmap that filters out undefineds. - reduce = async (parent, children3) => { - const flatten = flat(children3); + reduce = async (parent, children2) => { + const flatten = flat(children2); if (parent !== void 0) flatten.unshift(parent); return flatten; }, // The default iterate function walks all children concurrently - iterate = (walk3, children3) => Promise.all([...children3].map(walk3)) + iterate = (walk3, children2) => Promise.all([...children2].map(walk3)) }) { const walkers = trees.map( (proxy) => proxy[GitWalkSymbol]({ fs: fs2, dir, gitdir, cache }) @@ -51055,11 +50091,11 @@ async function _walk({ }; }; const walk3 = async (root2) => { - const { entries, children: children3 } = await unionWalkerFromReaddir(root2); + const { entries, children: children2 } = await unionWalkerFromReaddir(root2); const fullpath = entries.find((entry) => entry && entry._fullpath)._fullpath; const parent = await map(fullpath, entries); if (parent !== null) { - let walkedChildren = await iterate(walk3, children3); + let walkedChildren = await iterate(walk3, children2); walkedChildren = walkedChildren.filter((x) => x !== void 0); return reduce(parent, walkedChildren); } @@ -51575,9 +50611,9 @@ async function addToIndex({ if (!stats) throw new NotFoundError(currentFilepath); if (stats.isDirectory()) { - const children3 = await fs2.readdir(join(dir, currentFilepath)); + const children2 = await fs2.readdir(join(dir, currentFilepath)); if (parallel) { - const promises2 = children3.map( + const promises2 = children2.map( (child) => addToIndex({ dir, gitdir, @@ -51590,7 +50626,7 @@ async function addToIndex({ ); await Promise.all(promises2); } else { - for (const child of children3) { + for (const child of children2) { await addToIndex({ dir, gitdir, @@ -51701,14 +50737,14 @@ async function _commit({ ); } async function constructTree({ fs: fs2, gitdir, inode, dryRun }) { - const children3 = inode.children; - for (const inode2 of children3) { + const children2 = inode.children; + for (const inode2 of children2) { if (inode2.type === "tree") { inode2.metadata.mode = "040000"; inode2.metadata.oid = await constructTree({ fs: fs2, gitdir, inode: inode2, dryRun }); } } - const entries = children3.map((inode2) => ({ + const entries = children2.map((inode2) => ({ mode: inode2.metadata.mode, path: inode2.basename, oid: inode2.metadata.oid, @@ -52594,16 +51630,16 @@ async function analyze({ } }, // Modify the default flat mapping - reduce: async function(parent, children3) { - children3 = flat(children3); + reduce: async function(parent, children2) { + children2 = flat(children2); if (!parent) { - return children3; + return children2; } else if (parent && parent[0] === "rmdir") { - children3.push(parent); - return children3; + children2.push(parent); + return children2; } else { - children3.unshift(parent); - return children3; + children2.unshift(parent); + return children2; } } }); @@ -52691,8 +51727,8 @@ function translateSSHtoHTTP(url) { function calculateBasicAuthHeader({ username = "", password = "" }) { return `Basic ${Buffer.from(`${username}:${password}`).toString("base64")}`; } -async function forAwait2(iterable, cb) { - const iter = getIterator2(iterable); +async function forAwait(iterable, cb) { + const iter = getIterator(iterable); while (true) { const { value, done } = await iter.next(); if (value) @@ -52703,10 +51739,10 @@ async function forAwait2(iterable, cb) { if (iter.return) iter.return(); } -async function collect2(iterable) { +async function collect(iterable) { let size = 0; const buffers = []; - await forAwait2(iterable, (value) => { + await forAwait(iterable, (value) => { buffers.push(value); size += value.byteLength; }); @@ -52727,7 +51763,7 @@ function extractAuthFromUrl(url) { url = url.replace(`${userpass}@`, ""); return { url, auth: { username, password } }; } -function padHex2(b, n) { +function padHex(b, n) { const s = n.toString(16); return "0".repeat(b - s.length) + s; } @@ -52743,7 +51779,7 @@ var GitPktLine = class { line = Buffer.from(line); } const length = line.length + 4; - const hexlength = padHex2(4, length); + const hexlength = padHex(4, length); return Buffer.concat([Buffer.from(hexlength, "utf8"), line]); } static streamReader(stream) { @@ -52859,7 +51895,7 @@ var updateHeaders = (headers, auth) => { }; var stringifyBody = async (res) => { try { - const data = Buffer.from(await collect2(res.body)); + const data = Buffer.from(await collect(res.body)); const response = data.toString("utf8"); const preview = response.length < 256 ? response : response.slice(0, 256) + "..."; return { preview, response, data }; @@ -53203,7 +52239,7 @@ function splitLines(input) { const output = new FIFO(); let tmp = ""; (async () => { - await forAwait2(input, (chunk) => { + await forAwait(input, (chunk) => { chunk = chunk.toString("utf8"); tmp += chunk; while (true) { @@ -53343,7 +52379,7 @@ async function parseUploadPackResponse(stream) { let nak = false; let done = false; return new Promise((resolve, reject) => { - forAwait2(packetlines, (data) => { + forAwait(packetlines, (data) => { const line = data.toString("utf8").trim(); if (line.startsWith("shallow")) { const oid = line.slice(-41).trim(); @@ -53358,9 +52394,9 @@ async function parseUploadPackResponse(stream) { } unshallows.push(oid); } else if (line.startsWith("ACK")) { - const [, oid, status2] = line.split(" "); - acks.push({ oid, status: status2 }); - if (!status2) + const [, oid, status3] = line.split(" "); + acks.push({ oid, status: status3 }); + if (!status3) done = true; } else if (line.startsWith("NAK")) { nak = true; @@ -53548,7 +52584,7 @@ async function _fetch({ since, exclude }); - const packbuffer = Buffer.from(await collect2(packstream)); + const packbuffer = Buffer.from(await collect(packstream)); const raw = await GitRemoteHTTP2.connect({ http, onProgress, @@ -53647,7 +52683,7 @@ async function _fetch({ }; if (onProgress || onMessage) { const lines = splitLines(response.progress); - forAwait2(lines, async (line) => { + forAwait(lines, async (line) => { if (onMessage) await onMessage(line); if (onProgress) { @@ -53662,7 +52698,7 @@ async function _fetch({ } }); } - const packfile = Buffer.from(await collect2(response.packfile)); + const packfile = Buffer.from(await collect(response.packfile)); if (raw.body.error) throw raw.body.error; const packfileSha = packfile.slice(-20).toString("hex"); @@ -54310,8 +53346,8 @@ async function mergeTree({ * @param {TreeEntry} [parent] * @param {Array} children */ - reduce: unmergedFiles.length !== 0 && (!dir || abortOnConflict) ? void 0 : async (parent, children3) => { - const entries = children3.filter(Boolean); + reduce: unmergedFiles.length !== 0 && (!dir || abortOnConflict) ? void 0 : async (parent, children2) => { + const entries = children2.filter(Boolean); if (!parent) return; if (parent && parent.type === "tree" && entries.length === 0) @@ -55748,14 +54784,14 @@ async function _pack({ while (multibyte) { multibyte = length > 127 ? 128 : 0; byte = multibyte | length & 127; - write(padHex2(2, byte), "hex"); + write(padHex(2, byte), "hex"); length = length >>> 7; } write(Buffer.from(await deflate(object))); } write("PACK"); write("00000002", "hex"); - write(padHex2(8, oids.length), "hex"); + write(padHex(8, oids.length), "hex"); for (const oid of oids) { const { type, object } = await _readObject({ fs: fs2, cache, gitdir, oid }); await writeObject2({ write, object, stype: type }); @@ -55766,7 +54802,7 @@ async function _pack({ } async function _packObjects({ fs: fs2, cache, gitdir, oids, write }) { const buffers = await _pack({ fs: fs2, cache, gitdir, oids }); - const packfile = Buffer.from(await collect2(buffers)); + const packfile = Buffer.from(await collect(buffers)); const packfileSha = packfile.slice(-20).toString("hex"); const filename = `pack-${packfileSha}.pack`; if (write) { @@ -55983,7 +55019,7 @@ async function parseReceivePackResponse(packfile) { for (const line2 of lines) { if (line2.trim() === "") continue; - const status2 = line2.slice(0, 2); + const status3 = line2.slice(0, 2); const refAndMessage = line2.slice(3); let space = refAndMessage.indexOf(" "); if (space === -1) @@ -55991,7 +55027,7 @@ async function parseReceivePackResponse(packfile) { const ref = refAndMessage.slice(0, space); const error = refAndMessage.slice(space + 1); result.refs[ref] = { - ok: status2 === "ok", + ok: status3 === "ok", error }; } @@ -56180,7 +55216,7 @@ async function _push({ const { packfile, progress } = await GitSideBand.demux(res.body); if (onMessage) { const lines = splitLines(progress); - forAwait2(lines, async (line) => { + forAwait(lines, async (line) => { await onMessage(line); }); } @@ -57052,8 +56088,8 @@ async function updateIndex({ filepath, oid, mode, - add: add2, - remove: remove2, + add: add3, + remove: remove3, force }) { try { @@ -57061,7 +56097,7 @@ async function updateIndex({ assertParameter("gitdir", gitdir); assertParameter("filepath", filepath); const fs2 = new FileSystem(_fs); - if (remove2) { + if (remove3) { return await GitIndexManager.acquire( { fs: fs2, gitdir, cache }, async function(index2) { @@ -57096,7 +56132,7 @@ async function updateIndex({ } } return await GitIndexManager.acquire({ fs: fs2, gitdir, cache }, async function(index2) { - if (!add2 && !index2.has({ filepath })) { + if (!add3 && !index2.has({ filepath })) { throw new NotFoundError( `file at "${filepath}" in index and "add" not set` ); @@ -57501,7 +56537,7 @@ function fromNodeStream(stream) { } }; } -function fromStream2(stream) { +function fromStream(stream) { if (stream[Symbol.asyncIterator]) return stream; const reader = stream.getReader(); @@ -57706,7 +56742,7 @@ var index = { // _asyncIteratorToStream, _basename: basename, _calculateBasicAuthHeader: calculateBasicAuthHeader, - _collect: collect2, + _collect: collect, _compareAge: compareAge, _comparePath: comparePath, _compareRefNames: compareRefNames, @@ -57720,14 +56756,14 @@ var index = { _filterCapabilities: filterCapabilities, _flat: flat, _flatFileListToDirectoryStructure: flatFileListToDirectoryStructure, - _forAwait: forAwait2, + _forAwait: forAwait, _formatAuthor: formatAuthor, _formatInfoRefs: formatInfoRefs, _fromEntries: fromEntries, _fromNodeStream: fromNodeStream, - _fromStream: fromStream2, - _fromValue: fromValue2, - _getIterator: getIterator2, + _fromStream: fromStream, + _fromValue: fromValue, + _getIterator: getIterator, _listpack: listpack, _utils_hashObject: hashObject$1, _indent: indent, @@ -57745,7 +56781,7 @@ var index = { _normalizePath: normalizePath, _normalizeStats: normalizeStats, _outdent: outdent, - _padHex: padHex2, + _padHex: padHex, _parseAuthor: parseAuthor, _pkg: pkg, _posixifyPathBuffer: posixifyPathBuffer, @@ -57776,9 +56812,66 @@ var index = { }; var isomorphic_git_default = index; +// ../../../lix/packages/client/dist/git/add.js +async function add2(ctx, filepath) { + return await isomorphic_git_default.add({ + fs: ctx.rawFs, + parallel: true, + dir: ctx.dir, + cache: ctx.cache, + filepath + }); +} + +// ../../../lix/packages/client/dist/git/remove.js +async function remove2(ctx, filepath) { + return await isomorphic_git_default.remove({ + fs: ctx.rawFs, + dir: ctx.dir, + cache: ctx.cache, + filepath + }); +} + // ../../../lix/packages/client/dist/git/commit.js init_dist(); -async function commit2({ cache, fs: fs2, dir, ref, author, message }) { +var isoCommit = (ctx, { author, message }) => commit({ + fs: ctx.rawFs, + dir: ctx.dir, + cache: ctx.cache, + author: author || ctx.author, + message +}); +async function commit2(ctx, state, { author: overrideAuthor, message, include }) { + if (include) { + const additions = []; + const deletions = []; + for (const entry of include) { + if (await ctx.rawFs.lstat(entry).catch(() => void 0)) { + additions.push(entry); + } else { + deletions.push(entry); + } + } + additions.length && await add2(ctx, additions); + deletions.length && await Promise.all(deletions.map((del) => remove2(ctx, del))); + } else { + } + const commitArgs = { + fs: state.nodeishFs, + dir: ctx.dir, + cache: ctx.cache, + author: overrideAuthor || ctx.author, + message + }; + if (ctx.experimentalFeatures.lixCommit) { + console.warn("using experimental commit for this repo."); + return doCommit(commitArgs); + } else { + return commit(commitArgs); + } +} +async function doCommit({ cache, fs: fs2, dir, ref, author, message }) { const fileStates = {}; async function createTree(currentFolder, fileStates2) { const entries = []; @@ -57893,14 +56986,32 @@ function modeToFileType(mode) { } // ../../../lix/packages/client/dist/git/status-list.js -var { walk: walk2, TREE: TREE2, WORKDIR: WORKDIR2, STAGE: STAGE2, isIgnored: isIgnored2 } = isomorphic_git_default; +var { + walk: walk2, + // _walk expects cache to always exist. + TREE: TREE2, + WORKDIR: WORKDIR2, + STAGE: STAGE2, + isIgnored: isIgnored2 +} = isomorphic_git_default; function normalizePath3(path) { return path.replace(/\/\.\//g, "/").replace(/\/{2,}/g, "/").replace(/^\/\.$/, "/").replace(/^\.\/$/, ".").replace(/^\.\//, "").replace(/\/\.$/, "").replace(/(.+)\/$/, "$1").replace(/^$/, "."); } function join2(...parts) { return normalizePath3(parts.map(normalizePath3).join("/")); } -async function statusList({ +async function statusList(ctx, state, statusArg) { + return await _statusList({ + fs: ctx.rawFs, + dir: ctx.dir, + cache: ctx.cache, + sparseFilter: state.sparseFilter, + filter: statusArg?.filter, + filepaths: statusArg?.filepaths, + includeStatus: statusArg?.includeStatus + }); +} +async function _statusList({ fs: fs2, dir = "/", gitdir = join2(dir, ".git"), @@ -58060,6 +57171,156 @@ async function statusList({ } } +// ../../../lix/packages/client/dist/git/status.js +async function status2(ctx, state, filepath) { + if (typeof filepath !== "string") { + throw new Error("parameter must be a string"); + } + const statusList2 = await statusList(ctx, state, { + filepaths: [filepath] + }); + const maybeStatusEntry = statusList2[0] || [filepath, "unknown"]; + return maybeStatusEntry?.[1]; +} + +// ../../../lix/packages/client/dist/git-http/client.js +function fromValue2(value) { + let queue = [value]; + return { + next() { + return Promise.resolve({ done: queue.length === 0, value: queue.pop() }); + }, + return() { + queue = []; + return {}; + }, + [Symbol.asyncIterator]() { + return this; + } + }; +} +function getIterator2(iterable) { + if (iterable[Symbol.asyncIterator]) { + return iterable[Symbol.asyncIterator](); + } + if (iterable[Symbol.iterator]) { + return iterable[Symbol.iterator](); + } + if (iterable.next) { + return iterable; + } + return fromValue2(iterable); +} +async function forAwait2(iterable, cb) { + const iter = getIterator2(iterable); + while (true) { + const { value, done } = await iter.next(); + if (value) + await cb(value); + if (done) + break; + } + if (iter.return) + iter.return(); +} +async function collect2(iterable) { + let size = 0; + const buffers = []; + await forAwait2(iterable, (value) => { + buffers.push(value); + size += value.byteLength; + }); + const result = new Uint8Array(size); + let nextIndex = 0; + for (const buffer of buffers) { + result.set(buffer, nextIndex); + nextIndex += buffer.byteLength; + } + return result; +} +function fromStream2(stream) { + if (stream[Symbol.asyncIterator]) + return stream; + const reader = stream.getReader(); + return { + next() { + return reader.read(); + }, + return() { + reader.releaseLock(); + return {}; + }, + [Symbol.asyncIterator]() { + return this; + } + }; +} +function makeHttpClient({ verbose, description, onReq, onRes }) { + async function request({ url, method = "GET", headers = {}, body }) { + if (body) { + body = await collect2(body); + } + const origUrl = url; + const origMethod = method; + if (onReq) { + const rewritten = await onReq({ body, url }); + method = rewritten?.method || method; + headers = rewritten?.headers || headers; + body = rewritten?.body || body; + url = rewritten?.url || url; + } + const res = await fetch(url, { method, headers, body, credentials: "include" }); + let resHeaders = {}; + for (const [key, value] of res.headers.entries()) { + resHeaders[key] = value; + } + if (verbose) { + console.warn(`${description} git req:`, origUrl); + } + const statusCode = res.status; + let resBody; + if (onRes) { + const uint8Array = new Uint8Array(await res.arrayBuffer()); + const rewritten = await onRes({ + origUrl, + usedUrl: url, + resBody: uint8Array, + statusCode, + resHeaders + }); + resHeaders = rewritten?.resHeaders || resHeaders; + resBody = rewritten?.resBody || [uint8Array]; + } + if (!resBody) { + resBody = res.body && res.body.getReader ? fromStream2(res.body) : [new Uint8Array(await res.arrayBuffer())]; + } + return { + url: origUrl, + method: origMethod, + statusCode, + statusMessage: res.statusText, + body: resBody, + headers: resHeaders + }; + } + return { request }; +} + +// ../../../lix/packages/client/dist/git/push.js +var push2 = async (ctx, state) => { + if (!ctx.gitUrl) { + throw new Error("Could not find repo url, only github supported for push at the moment"); + } + return await isomorphic_git_default.push({ + fs: state.nodeishFs, + url: ctx.gitUrl, + cache: ctx.cache, + corsProxy: ctx.gitProxyUrl, + http: makeHttpClient({ debug: ctx.debug, description: "push" }), + dir: ctx.dir + }); +}; + // ../../../lix/packages/client/dist/git/_checkout.js async function _checkout2({ fs: fs2, cache, onProgress, dir, gitdir, remote, ref, filepaths, noCheckout, noUpdateHead, dryRun, force, track = true }) { let oid; @@ -58435,23 +57696,35 @@ async function analyze2({ fs: fs2, cache, onProgress, dir, gitdir, ref, force, f } }, // Modify the default flat mapping - reduce: async function(parent, children3) { - children3 = flat(children3); + reduce: async function(parent, children2) { + children2 = flat(children2); if (!parent) { - return children3; + return children2; } else if (parent && parent[0] === "rmdir") { - children3.push(parent); - return children3; + children2.push(parent); + return children2; } else { - children3.unshift(parent); - return children3; + children2.unshift(parent); + return children2; } } }); } // ../../../lix/packages/client/dist/git/checkout.js -async function checkout2({ fs: fs2, onProgress, dir, gitdir = join(dir, ".git"), remote = "origin", ref: _ref, filepaths, noCheckout = false, noUpdateHead = _ref === void 0, dryRun = false, force = false, track = true, cache = {} }) { +async function checkout2(ctx, state, { branch: branch2 }) { + state.branchName = branch2; + if (ctx.useLazyFS) { + throw new Error("not implemented for lazy lix mode yet, use openRepo with different branch instead"); + } + return await doCheckout({ + fs: ctx.rawFs, + cache: ctx.cache, + dir: ctx.dir, + ref: state.branchName + }); +} +async function doCheckout({ fs: fs2, onProgress, dir, gitdir = join(dir, ".git"), remote = "origin", ref: _ref, filepaths, noCheckout = false, noUpdateHead = _ref === void 0, dryRun = false, force = false, track = true, cache = {} }) { try { assertParameter("fs", fs2); assertParameter("dir", dir); @@ -58478,18 +57751,624 @@ async function checkout2({ fs: fs2, onProgress, dir, gitdir = join(dir, ".git"), } } -// ../../../lix/packages/client/dist/openRepository.js -var checkout3 = checkout2; -var whitelistedExperimentalRepos = [ +// ../../../lix/packages/client/dist/lix/emptyWorkdir.js +async function emptyWorkdir(ctx, state) { + const { rawFs, cache, dir } = ctx; + const { checkedOut } = state; + const statusResult = await statusList(ctx, state); + if (statusResult.length > 0) { + throw new Error("could not empty the workdir, uncommitted changes"); + } + const listing = (await rawFs.readdir("/")).filter((entry) => { + return !checkedOut.has(entry) && entry !== ".git"; + }); + const notIgnored = (await Promise.all(listing.map((entry) => isomorphic_git_default.isIgnored({ fs: rawFs, dir, filepath: entry }).then((ignored) => { + return { ignored, entry }; + })))).filter(({ ignored }) => !ignored).map(({ entry }) => entry); + for (const toDelete of notIgnored) { + await rawFs.rm(toDelete, { recursive: true }).catch(() => { + }); + await isomorphic_git_default.remove({ + fs: rawFs, + // ref: args.branch, + dir: "/", + cache, + filepath: toDelete + }); + } +} + +// ../../../lix/packages/client/dist/git/pull.js +async function pull2(ctx, state, cmdArgs = {}) { + if (!ctx.gitUrl) { + throw new Error("Could not find repo url, only github supported for pull at the moment"); + } + const pullFs = state.nodeishFs; + const { fetchHead, fetchHeadDescription } = await isomorphic_git_default.fetch({ + depth: 5, + fs: pullFs, + cache: ctx.cache, + http: makeHttpClient({ verbose: ctx.debug, description: "pull" }), + corsProxy: ctx.gitProxyUrl, + ref: state.branchName, + tags: false, + dir: ctx.dir, + url: ctx.gitUrl, + // remote: "origin", + // remoteRef, + singleBranch: cmdArgs.singleBranch || true + }); + if (!fetchHead) { + throw new Error("could not fetch head"); + } + await isomorphic_git_default.merge({ + fs: pullFs, + cache: ctx.cache, + dir: ctx.dir, + ours: state.branchName, + theirs: fetchHead, + fastForward: cmdArgs.fastForward, + message: `Merge ${fetchHeadDescription}`, + author: cmdArgs.author || ctx.author, + dryRun: false, + noUpdateBranch: false + // committer, + // signingKey, + // fastForwardOnly, + }); + if (ctx.experimentalFeatures.lazyClone) { + console.warn("enableExperimentalFeatures.lazyClone is set for this repo but pull not fully implemented. disabling lazy files"); + await emptyWorkdir(ctx, state); + ctx.experimentalFeatures.lazyClone = false; + ctx.debug && console.info('checking out "HEAD" after pull'); + await doCheckout({ + fs: ctx.rawFs, + cache: ctx.cache, + dir: ctx.dir, + ref: state.branchName, + noCheckout: false + }); + } else { + await doCheckout({ + fs: ctx.rawFs, + cache: ctx.cache, + dir: ctx.dir, + ref: state.branchName, + noCheckout: false + }); + } +} + +// ../../../lix/packages/client/dist/git/listRemotes.js +async function listRemotes2(ctx, state) { + try { + const remotes = await isomorphic_git_default.listRemotes({ + fs: state.nodeishFs, + dir: ctx.dir + }); + return remotes; + } catch (_err) { + return void 0; + } +} + +// ../../../lix/packages/client/dist/git/log.js +async function log2(ctx, cmdArgs) { + return await isomorphic_git_default.log({ + fs: ctx.rawFs, + depth: cmdArgs.depth, + filepath: cmdArgs.filepath, + dir: ctx.dir, + ref: cmdArgs.ref, + cache: ctx.cache, + since: cmdArgs.since + }); +} + +// ../../../lix/packages/client/dist/helpers.js +var withProxy = ({ nodeishFs, verbose = false, description, intercept }) => { + return new Proxy(nodeishFs, { + get(getTarget, prop, receiver) { + if (getTarget[prop]) { + return new Proxy(getTarget[prop], { + apply(callTarget, thisArg, argumentsList) { + if (verbose) { + console.warn(`${description} fs:`, prop, argumentsList); + } + const execute = () => Reflect.apply(callTarget, thisArg, argumentsList); + return intercept ? intercept({ prop, argumentsList, execute }) : execute(); + } + }); + } + return Reflect.get(getTarget, prop, receiver); + } + }); +}; +function parseOrigin({ remotes }) { + const origin = remotes?.find((elements) => elements.remote === "origin"); + if (origin === void 0) { + return void 0; + } + let result = origin.url; + if (result.endsWith(".git") === false) { + result += ".git"; + } + return transformRemote(result); +} +function transformRemote(remote) { + const regex = /(?:https:\/\/|@|git:\/\/)([^/]+)\/(.+?)(?:\.git)?$/; + const matches = remote.match(regex); + if (matches && matches[1] && matches[2]) { + let host = matches[1].replace(/:/g, "/"); + const repo = matches[2]; + const hostRegex = /(ghp_|ghs_)[\w]+@/; + host = host.replace(hostRegex, ""); + return `${host}/${repo}.git`; + } + return void 0; +} +function parseLixUri(uriText) { + let url; + try { + url = new URL(uriText); + } catch (error) { + return { + error, + username: "", + password: "", + protocol: "", + lixHost: "", + namespace: "", + repoHost: "", + owner: "", + repoName: "" + }; + } + const { protocol, host, pathname, username, password } = url; + const pathParts = pathname.split("/"); + let lixHost = ""; + let namespace = ""; + let repoHost = ""; + let owner = ""; + let repoName = ""; + if (host === "github.com") { + repoHost = host; + owner = pathParts[1] || ""; + repoName = pathParts[2] || ""; + if (!repoHost || !owner || !repoName) { + return { + error: new Error(`Invalid url format for '${uriText}' for direct cloning repository from github, please use the format of https://github.com/opral/monorepo.`), + username, + password, + protocol, + lixHost, + namespace, + repoHost, + owner, + repoName + }; + } + } else { + lixHost = host; + namespace = pathParts[1] || ""; + repoHost = pathParts[2] || ""; + owner = pathParts[3] || ""; + repoName = pathParts[4] || ""; + if (!namespace || !host || !owner || !repoName) { + return { + error: new Error(`Invalid url format for '${uriText}' for cloning repository, please use the format of https://lix.inlang.com/git/github.com/opral/monorepo.`), + username, + password, + protocol, + lixHost, + namespace, + repoHost, + owner, + repoName + }; + } + } + return { + username, + password, + protocol, + lixHost, + namespace, + repoHost, + owner, + repoName + }; +} +async function hash(inputStr) { + let usedCrypto; + if (typeof crypto === "undefined" && typeof process !== "undefined" && process?.versions?.node) { + const modName = "crypto"; + usedCrypto = globalThis?.crypto || await import(`node:${modName}`); + } else if (typeof crypto !== "undefined") { + usedCrypto = crypto; + } + if (!usedCrypto) { + throw new Error("Could not find crypto features in runtime"); + } + const idDigest = await usedCrypto.subtle.digest("SHA-256", new TextEncoder().encode(inputStr)); + return [...new Uint8Array(idDigest)].map((b) => ("00" + b.toString(16)).slice(-2)).join(""); +} + +// ../../../lix/packages/client/dist/git/getOrigin.js +async function getOrigin(ctx, state) { + const remotes = await listRemotes2(ctx, state) || []; + return await parseOrigin({ remotes }); +} + +// ../../../lix/packages/client/dist/git/getBranches.js +async function getBranches(ctx) { + if (!ctx.gitUrl) { + throw new Error("Could not find repo url, only github supported for getBranches at the moment"); + } + let serverRefs; + try { + serverRefs = await isomorphic_git_default.listServerRefs({ + url: ctx.gitUrl, + corsProxy: ctx.gitProxyUrl, + prefix: "refs/heads", + http: makeHttpClient({ verbose: ctx.debug, description: "getBranches" }) + }); + } catch (_error) { + return void 0; + } + return serverRefs.filter((ref) => !ref.ref.startsWith("refs/heads/gh-readonly-queue/")).map((ref) => ref.ref.replace("refs/heads/", "")) || void 0; +} + +// ../../../lix/packages/client/dist/git/getCurrentBranch.js +async function getCurrentBranch(ctx, state) { + return await isomorphic_git_default.currentBranch({ + fs: state.nodeishFs, + dir: ctx.dir + }) || void 0; +} + +// ../../../lix/packages/client/dist/github/getMeta.js +async function getMeta(ctx) { + const { gitUrl, owner, repoName, githubClient } = ctx; + if (!gitUrl) { + throw new Error("Could not find repo url, only github supported for getMeta at the moment"); + } + const res = await githubClient.getRepo({ repoName, owner }); + if ("error" in res) { + return { error: res.error }; + } else { + return { + name: res.data.name, + isPrivate: res.data.private, + isFork: res.data.fork, + permissions: { + admin: res.data.permissions?.admin || false, + push: res.data.permissions?.push || false, + pull: res.data.permissions?.pull || false + }, + owner: { + name: res.data.owner.name || void 0, + email: res.data.owner.email || void 0, + login: res.data.owner.login + }, + parent: res.data.parent ? { + url: transformRemote(res.data.parent.git_url) || "unknown", + fullName: res.data.parent.full_name + } : void 0 + }; + } +} + +// ../../../lix/packages/client/dist/github/forkStatus.js +async function forkStatus(ctx, state) { + const { gitUrl, debug: debug4, dir, cache, owner, repoName, githubClient, gitProxyUrl } = ctx; + if (!gitUrl) { + throw new Error("Could not find repo url, only github supported for forkStatus at the moment"); + } + const { isFork, parent, error } = await getMeta(ctx); + if (error) { + return { error: "could check fork status of repo" }; + } + if (!isFork) { + return { error: "repo is not a fork" }; + } + const forkFs = state.nodeishFs; + const useBranchName = await isomorphic_git_default.currentBranch({ + fs: forkFs, + dir, + fullname: false + }); + if (!useBranchName) { + return { error: "could not get fork status for detached head" }; + } + await isomorphic_git_default.addRemote({ + dir, + remote: "upstream", + url: "https://" + parent.url, + fs: forkFs + }); + try { + await isomorphic_git_default.fetch({ + depth: 1, + singleBranch: true, + dir, + cache, + ref: useBranchName, + remote: "upstream", + http: makeHttpClient({ debug: debug4, description: "forkStatus" }), + fs: forkFs + }); + } catch (err) { + return { error: err }; + } + const currentUpstreamCommit = await isomorphic_git_default.resolveRef({ + fs: forkFs, + dir: "/", + ref: "upstream/" + useBranchName + }); + const currentOriginCommit = await isomorphic_git_default.resolveRef({ + fs: forkFs, + dir: "/", + ref: useBranchName + }); + if (currentUpstreamCommit === currentOriginCommit) { + return { ahead: 0, behind: 0, conflicts: false }; + } + const compare = await githubClient.compare({ + owner, + repoName, + base: currentUpstreamCommit, + head: currentOriginCommit + }).catch((newError) => { + return { error: newError }; + }); + if ("error" in compare || !("data" in compare)) { + return { error: compare.error || "could not diff repos on github" }; + } + await isomorphic_git_default.fetch({ + depth: compare.data.behind_by + 1, + remote: "upstream", + cache, + singleBranch: true, + dir, + ref: useBranchName, + http: makeHttpClient({ debug: debug4, description: "forkStatus" }), + fs: forkFs + }); + await isomorphic_git_default.fetch({ + depth: compare.data.ahead_by + 1, + cache, + singleBranch: true, + ref: useBranchName, + dir, + http: makeHttpClient({ debug: debug4, description: "forkStatus" }), + corsProxy: gitProxyUrl, + fs: forkFs + }); + let conflicts = false; + try { + await isomorphic_git_default.merge({ + fs: forkFs, + cache, + author: { name: "lix" }, + dir, + ours: useBranchName, + dryRun: true, + theirs: "upstream/" + useBranchName, + noUpdateBranch: true, + abortOnConflict: true + }); + } catch (err) { + conflicts = true; + } + return { ahead: compare.data.ahead_by, behind: compare.data.behind_by, conflicts }; +} + +// ../../../lix/packages/client/dist/github/createFork.js +async function createFork(ctx) { + return await ctx.githubClient.createFork({ + owner: ctx.owner, + repo: ctx.repoName + }); +} + +// ../../../lix/packages/client/dist/github/mergeUpstream.js +async function mergeUpstream(ctx, cmdArgs = {}) { + if (!ctx.gitUrl) { + throw new Error("Could not find repo url, only github supported for mergeUpstream at the moment"); + } + const branch2 = cmdArgs?.branch || await isomorphic_git_default.currentBranch({ + fs: ctx.rawFs, + dir: ctx.dir, + fullname: false + }); + if (typeof branch2 !== "string") { + throw "could not get current branch"; + } + let response; + try { + response = await ctx.githubClient.mergeUpstream({ + branch: branch2, + owner: ctx.owner, + repoName: ctx.repoName + }); + } catch (error) { + return { error }; + } + return response?.data || response.error; +} + +// ../../../lix/packages/client/dist/lix/getFirstCommitHash.js +async function getFirstCommitHash(ctx) { + const getFirstCommitFs = ctx.rawFs; + const maybeShallow = !!await getFirstCommitFs.readFile(ctx.dir + "/.git/shallow", { encoding: "utf-8" }).catch(() => void 0); + if (maybeShallow) { + console.warn("shallow clone detected, not generating first commit hash."); + return void 0; + } + if (ctx.useLazyFS) { + try { + await isomorphic_git_default.fetch({ + singleBranch: true, + dir: ctx.dir, + depth: 2147483647, + http: makeHttpClient({ verbose: ctx.debug, description: "getFirstCommitHash" }), + corsProxy: ctx.gitProxyUrl, + fs: getFirstCommitFs + }); + } catch { + return void 0; + } + } + let firstCommitHash = "HEAD"; + for (; ; ) { + const commits = await isomorphic_git_default.log({ + fs: getFirstCommitFs, + depth: 550, + dir: ctx.dir, + ref: firstCommitHash + }).catch((error) => { + return { error }; + }); + if ("error" in commits) { + firstCommitHash = void 0; + break; + } + const lastHashInPage = commits.at(-1)?.oid; + if (lastHashInPage) { + firstCommitHash = lastHashInPage; + } + if (commits.length < 550) { + break; + } + } + return firstCommitHash; +} + +// ../../../lix/packages/client/dist/lix/checkoutPlaceholders.js +async function checkOutPlaceholders(ctx, state) { + const { rawFs, cache, dir } = ctx; + const { branchName, checkedOut, sparseFilter } = state; + await doCheckout({ + fs: rawFs, + cache, + dir, + ref: branchName, + filepaths: [] + }); + const fs2 = rawFs; + const gitignoreFiles = []; + await isomorphic_git_default.walk({ + fs: fs2, + dir, + cache, + gitdir: ".git", + trees: [isomorphic_git_default.TREE({ ref: branchName })], + map: async function(fullpath, [commit3]) { + if (!commit3) { + return void 0; + } + const fileMode = await commit3.mode(); + const fileType = modeToFileType(fileMode); + if (fullpath.endsWith(".gitignore")) { + gitignoreFiles.push(fullpath); + return void 0; + } + if (sparseFilter && !sparseFilter({ + filename: fullpath, + type: fileType + })) { + return void 0; + } + if (fileType === "folder" && !checkedOut.has(fullpath)) { + return fullpath; + } + if (fileType === "file" && !checkedOut.has(fullpath)) { + await fs2._createPlaceholder(fullpath, { mode: fileMode }); + return fullpath; + } + if (fileType === "symlink" && !checkedOut.has(fullpath)) { + await fs2._createPlaceholder(fullpath, { mode: fileMode }); + return fullpath; + } + console.warn("ignored checkout palcholder path", fullpath, fileType); + return void 0; + } + }); + if (gitignoreFiles.length) { + await doCheckout({ + fs: rawFs, + dir, + cache, + ref: branchName, + filepaths: gitignoreFiles + }); + gitignoreFiles.map((file) => checkedOut.add(file)); + } + state.pending && await state.pending; +} + +// ../../../lix/packages/client/dist/allowedRepos.js +var allowedRepos_default = [ "inlang/example", + "opral/example", "inlang/ci-test-repo", + "opral/ci-test-repo", "opral/monorepo", "inlang/example-test", + "opral/example-test", "janfjohannes/inlang-example", "janfjohannes/cal.com", "niklasbuchfink/appflowy" ]; -async function openRepository(url, args) { + +// ../../../lix/packages/client/dist/github/client.js +var import_octokit = __toESM(require_dist_node26(), 1); +function makeGithubClient({ gitHubProxyUrl } = {}) { + const githubClient = new import_octokit.Octokit({ + request: { + fetch: (...ghArgs) => { + ghArgs[0] = gitHubProxyUrl + "/" + ghArgs[0]; + if (!ghArgs[1]) { + ghArgs[1] = {}; + } + if (gitHubProxyUrl) { + ghArgs[1].credentials = "include"; + } + return fetch(...ghArgs); + } + } + }); + const getRepo = async ({ repoName, owner }) => await githubClient.request("GET /repos/{owner}/{repo}", { + owner, + repo: repoName + }).catch((newError) => { + return { error: newError }; + }); + const createFork2 = githubClient.rest.repos.createFork; + const mergeUpstream2 = async ({ branch: branch2, owner, repoName }) => await githubClient.request("POST /repos/{owner}/{repo}/merge-upstream", { + branch: branch2, + owner, + repo: repoName + }); + const compare = async ({ owner, repoName, base, head }) => { + return await githubClient.request("GET /repos/{owner}/{repo}/compare/{base}...{head}", { + owner, + repo: repoName, + base, + head + }); + }; + return { + getRepo, + createFork: createFork2, + mergeUpstream: mergeUpstream2, + compare + }; +} + +// ../../../lix/packages/client/dist/repoContext.js +async function repoContext(url, args) { const rawFs = args.nodeishFs || (await Promise.resolve().then(() => (init_dist(), dist_exports))).createNodeishMemoryFs(); const author = args.author; let debug4 = args.debug || false; @@ -58499,19 +58378,17 @@ async function openRepository(url, args) { if (debug4 && typeof window !== "undefined") { window["rawFs"] = rawFs; } - const [errors, setErrors] = createSignal2([]); let freshClone = false; - let branchName = args.branch; let dir = "/"; if (url.startsWith("file:")) { dir = url.replace("file://", ""); const remotes = await isomorphic_git_default.listRemotes({ fs: rawFs, - dir: url.replace("file://", "") + dir }).catch(() => []); const origin = remotes.find(({ remote }) => remote === "origin")?.url || ""; - if (origin.startsWith("git@github.com:")) { - url = origin.replace("git@github.com:", "https://github.com/"); + if (origin.startsWith("git@githubClient.com:")) { + url = origin.replace("git@githubClient.com:", "https://githubClient.com/"); } else { url = origin; } @@ -58525,10 +58402,10 @@ async function openRepository(url, args) { if (debug4 && (username || password)) { console.warn("username and password and providers other than github are not supported yet. Only local commands will work."); } - const isWhitelistedRepo = whitelistedExperimentalRepos.includes(`${owner}/${repoName}`.toLocaleLowerCase()); - const experimentalFeatures = args.experimentalFeatures || (isWhitelistedRepo ? { lazyClone: true, lixCommit: true } : {}); - const lazyFS = typeof experimentalFeatures.lazyClone === "undefined" ? freshClone : experimentalFeatures.lazyClone; - const cache = lazyFS ? {} : void 0; + const isWhitelistedRepo = allowedRepos_default.includes(`${owner}/${repoName}`.toLocaleLowerCase()); + const experimentalFeatures = args.experimentalFeatures || (isWhitelistedRepo ? { lazyClone: freshClone, lixCommit: true } : {}); + const useLazyFS = experimentalFeatures?.lazyClone && args.nodeishFs?._createPlaceholder; + const cache = useLazyFS ? {} : void 0; let gitProxyUrl; let gitHubProxyUrl; if (namespace === "git") { @@ -58546,20 +58423,7 @@ async function openRepository(url, args) { username, password }); - const github2 = new import_octokit.Octokit({ - request: { - fetch: (...ghArgs) => { - ghArgs[0] = gitHubProxyUrl + "/" + ghArgs[0]; - if (!ghArgs[1]) { - ghArgs[1] = {}; - } - if (gitHubProxyUrl) { - ghArgs[1].credentials = "include"; - } - return fetch(...ghArgs); - } - } - }); + const githubClient = makeGithubClient({ gitHubProxyUrl }); const gitUrl = repoName ? `https://${repoHost}/${owner}/${repoName}` : ""; if (!gitUrl && debug4) { console.warn("valid repo url / local repo not found, only fs features available outside of repo"); @@ -58568,10 +58432,144 @@ async function openRepository(url, args) { if (expFeatures.length) { console.warn("using experimental git features for this repo.", expFeatures); } - let pending; - const checkedOut = /* @__PURE__ */ new Set(); + return { + gitUrl, + gitProxyUrl, + protocol, + lixHost, + repoHost, + owner, + repoName, + username, + password, + namespace, + useLazyFS, + githubClient, + debug: debug4, + experimentalFeatures, + author, + freshClone, + dir, + // maybe handle these different when touching lixFS impl. + rawFs, + cache + }; +} + +// ../../../lix/packages/client/dist/git-http/helpers.js +function padHex2(pad, n) { + const s = n.toString(16); + return "0".repeat(pad - s.length) + s; +} +function encodePackLine(line) { + const flushLine = ""; + if (line === flushLine) { + const paddedHex = padHex2(4, 0); + return paddedHex; + } + const length = line.length + 4; + const hexLength = padHex2(4, length); + const lineWithLength = hexLength + line; + return lineWithLength; +} +function decodeGitPackLines(concatenatedUint8Array) { + const strings = []; + let offset = 0; + while (offset + 4 < concatenatedUint8Array.length) { + const hexLength = new TextDecoder().decode(concatenatedUint8Array.subarray(offset, offset + 4)); + const packLineLength = parseInt(hexLength, 16); + if (packLineLength === 0) { + strings.push(""); + offset += 4; + } else if (packLineLength === 1) { + throw new Error("decodeGitPackLines does not support delimiter yet"); + } else { + const contentStart = offset + 4; + const stringData = new TextDecoder().decode(concatenatedUint8Array.subarray(contentStart, offset + packLineLength)); + offset += packLineLength; + strings.push(stringData); + } + } + return strings; +} + +// ../../../lix/packages/client/dist/git-http/optimize-refs.js +async function optimizedRefsReq({ url, addRef }) { + if (!url.endsWith("info/refs?service=git-upload-pack")) { + return; + } + const uploadPackUrl = url.replace("info/refs?service=git-upload-pack", "git-upload-pack"); + const lines = []; + lines.push(encodePackLine("command=ls-refs")); + lines.push(encodePackLine("agent=git/isomorphic-git@1.24.5") + "0001"); + if (addRef) { + lines.push(encodePackLine("ref-prefix refs/heads/" + addRef)); + } + lines.push(encodePackLine("ref-prefix HEAD")); + lines.push(encodePackLine("symrefs")); + lines.push(encodePackLine("")); + return { + url: uploadPackUrl, + method: "POST", + headers: { + accept: "application/x-git-upload-pack-result", + "content-type": "application/x-git-upload-pack-request", + "git-protocol": "version=2" + }, + // here we expect the body to be a string - we can just use the array and join it + body: lines.join("") + }; +} +async function optimizedRefsRes({ origUrl, resBody, statusCode, resHeaders }) { + if (!origUrl.endsWith("info/refs?service=git-upload-pack")) { + return; + } + if (statusCode !== 200) { + return; + } else { + let headSymref = ""; + const origLines = decodeGitPackLines(resBody); + const rewrittenLines = ["# service=git-upload-pack\n", ""]; + const capabilites = "\0multi_ack thin-pack side-band side-band-64k ofs-delta shallow deepen-since deepen-not deepen-relative no-progress include-tag multi_ack_detailed allow-tip-sha1-in-want allow-reachable-sha1-in-want no-done filter object-format=sha1"; + for (const line of origLines) { + if (line.includes("HEAD symref-target")) { + headSymref = "refs" + line.slice(64); + headSymref = headSymref.endsWith("\n") ? headSymref.slice(0, -1) : headSymref; + const headBlob = line.slice(0, 40); + rewrittenLines.push(headBlob + " HEAD" + capabilites + " symref=HEAD:" + headSymref); + rewrittenLines.push(headBlob + " " + headSymref); + } else { + rewrittenLines.push(line); + } + } + rewrittenLines.push(""); + resHeaders["content-type"] = "application/x-git-upload-pack-advertisement"; + const bodyString = rewrittenLines.map((updatedRawLine) => encodePackLine(updatedRawLine)).join(""); + return { + resHeaders, + resBody: [new TextEncoder().encode(bodyString)] + }; + } +} + +// ../../../lix/packages/client/dist/repoState.js +var checkout3 = doCheckout; +async function repoState(ctx, args) { + const { gitUrl, debug: debug4, rawFs, experimentalFeatures, gitProxyUrl, freshClone, useLazyFS, dir, cache } = ctx; + const state = { + pending: void 0, + nodeishFs: withProxy({ + nodeishFs: rawFs, + verbose: debug4, + description: "app", + intercept: useLazyFS ? delayedAction : void 0 + }), + checkedOut: /* @__PURE__ */ new Set(), + branchName: args.branch, + sparseFilter: args.sparseFilter + }; let nextBatch = []; - async function doCheckout() { + async function doCheckout2() { if (nextBatch.length < 1) { return; } @@ -58591,93 +58589,22 @@ async function openRepository(url, args) { }), dir, cache, - ref: args.branch, + ref: state.branchName, filepaths: thisBatch }).catch((error) => { console.error({ error, thisBatch }); }); for (const entry of thisBatch) { - checkedOut.add(entry); + state.checkedOut.add(entry); } if (debug4) { console.warn("checked out ", thisBatch); } if (nextBatch.length) { - return doCheckout(); + return doCheckout2(); } return res; } - async function checkOutPlaceholders() { - if (!experimentalFeatures.lazyClone) { - return; - } - await checkout3({ - fs: withProxy({ - nodeishFs: rawFs, - verbose: debug4, - description: "checkout" - }), - cache, - dir, - ref: branchName, - filepaths: [] - }); - const fs2 = withProxy({ nodeishFs: rawFs, verbose: debug4, description: "checkout placeholders" }); - const gitignoreFiles = []; - await isomorphic_git_default.walk({ - fs: fs2, - dir, - cache, - gitdir: ".git", - trees: [isomorphic_git_default.TREE({ ref: branchName })], - // eslint-disable-next-line @typescript-eslint/no-unused-vars - map: async function(fullpath, [commit3]) { - if (!commit3) { - return void 0; - } - const fileMode = await commit3.mode(); - const fileType = modeToFileType(fileMode); - if (fullpath.endsWith(".gitignore")) { - gitignoreFiles.push(fullpath); - return void 0; - } - if (args.sparseFilter && !args.sparseFilter({ - filename: fullpath, - type: fileType - })) { - return void 0; - } - if (fileType === "folder" && !checkedOut.has(fullpath)) { - return fullpath; - } - if (fileType === "file" && !checkedOut.has(fullpath)) { - await fs2._createPlaceholder(fullpath, { mode: fileMode }); - return fullpath; - } - if (fileType === "symlink" && !checkedOut.has(fullpath)) { - await fs2._createPlaceholder(fullpath, { mode: fileMode }); - return fullpath; - } - console.warn("ignored checkout palcholder path", fullpath, fileType); - return void 0; - } - }); - if (gitignoreFiles.length) { - await checkout3({ - fs: withProxy({ - nodeishFs: rawFs, - verbose: debug4, - description: "checkout gitignores: " + JSON.stringify(gitignoreFiles) - }), - dir, - cache, - ref: args.branch, - filepaths: gitignoreFiles - }); - gitignoreFiles.map((file) => checkedOut.add(file)); - } - pending && await pending; - } if (freshClone) { if (!rawFs._createPlaceholder && !rawFs._isPlaceholder) { throw new Error("fs provider does not support placeholders"); @@ -58688,8 +58615,8 @@ async function openRepository(url, args) { http: makeHttpClient({ debug: debug4, description: "clone", - onReq: ({ url: url2, body }) => { - return optimizedRefsReq({ url: url2, body, addRef: branchName }); + onReq: ({ url, body }) => { + return optimizedRefsReq({ url, body, addRef: state.branchName }); }, onRes: optimizedRefsRes }), @@ -58699,11 +58626,20 @@ async function openRepository(url, args) { url: gitUrl, singleBranch: true, noCheckout: experimentalFeatures.lazyClone, - ref: branchName, + ref: state.branchName, // TODO: use only first and last commit in lazy clone? (we need first commit for repo id) depth: 1, noTags: true - }).then(() => checkOutPlaceholders()); + }).then(() => { + if (!experimentalFeatures.lazyClone) { + return; + } + return checkOutPlaceholders(ctx, { + branchName: state.branchName, + checkedOut: state.checkedOut, + sparseFilter: state.sparseFilter + }); + }); } else { console.info("Using existing cloned repo"); } @@ -58711,30 +58647,30 @@ async function openRepository(url, args) { const filename = argumentsList?.[0]?.replace(/^(\.)?(\/)?\//, ""); const pathParts = filename?.split("/") || []; const rootObject = pathParts[0]; - if (experimentalFeatures.lazyClone && typeof rootObject !== "undefined" && rootObject !== ".git" && ["readFile", "readlink", "writeFile", "readdir"].includes(prop) && !checkedOut.has(rootObject) && !checkedOut.has(filename)) { + if (experimentalFeatures.lazyClone && typeof rootObject !== "undefined" && rootObject !== ".git" && ["readFile", "readlink", "writeFile", "readdir"].includes(prop) && !state.checkedOut.has(rootObject) && !state.checkedOut.has(filename)) { if (debug4) { console.warn("delayedAction", { prop, argumentsList, rootObject, - checkedOut, + checkedOut: state.checkedOut, filename, - pending, + pending: state.pending, nextBatch }); } if (prop !== "readdir") { nextBatch.push(filename); } - if (!pending) { - pending = doCheckout(); + if (!state.pending) { + state.pending = doCheckout2(); } } else { return execute(); } - if (pending) { - return pending.then(execute).finally(() => { - pending = void 0; + if (state.pending) { + return state.pending.then(execute).finally(() => { + state.pending = void 0; if (debug4) { console.warn("executed", filename, prop); } @@ -58742,591 +58678,59 @@ async function openRepository(url, args) { } return execute(); } - const nodeishFs = withProxy({ - nodeishFs: rawFs, - verbose: debug4, - description: "app", - intercept: lazyFS ? delayedAction : void 0 - }); - const add2 = (filepath) => isomorphic_git_default.add({ - fs: withProxy({ - nodeishFs: rawFs, - verbose: debug4, - description: "add" - }), - parallel: true, - dir, - cache, - filepath - }); - const remove2 = (filepath) => isomorphic_git_default.remove({ - fs: withProxy({ - nodeishFs: rawFs, - verbose: debug4, - description: "remove" - }), - dir, - cache, - filepath - }); - async function emptyWorkdir() { - const statusResult = await statusList2(); - if (statusResult.length > 0) { - throw new Error("could not empty the workdir, uncommitted changes"); - } - const listing = (await rawFs.readdir("/")).filter((entry) => { - return !checkedOut.has(entry) && entry !== ".git"; - }); - const notIgnored = (await Promise.all(listing.map((entry) => isomorphic_git_default.isIgnored({ fs: rawFs, dir, filepath: entry }).then((ignored) => { - return { ignored, entry }; - })))).filter(({ ignored }) => !ignored).map(({ entry }) => entry); - for (const toDelete of notIgnored) { - await rawFs.rm(toDelete, { recursive: true }).catch(() => { - }); - await isomorphic_git_default.remove({ - fs: rawFs, - // ref: args.branch, - dir: "/", - cache, - filepath: toDelete - }); - } - } - async function statusList2(statusArg) { - return statusList({ - fs: withProxy({ - nodeishFs: rawFs, - verbose: debug4, - description: "lixStatusList" - }), - dir, - cache, - sparseFilter: args?.sparseFilter, - filter: statusArg?.filter, - filepaths: statusArg?.filepaths, - includeStatus: statusArg?.includeStatus - }); - } - async function status2(filepath) { - if (typeof filepath !== "string") { - throw new Error("parameter must be a string"); - } - const statusList3 = await statusList({ - fs: withProxy({ - nodeishFs: rawFs, - verbose: debug4, - description: "lixStatus" - }), - dir, - cache, - sparseFilter: args.sparseFilter, - filepaths: [filepath] - }); - const maybeStatusEntry = statusList3[0] || [filepath, "unknown"]; - return maybeStatusEntry?.[1]; - } - if (args.debugTime) { - console.timeEnd("repo"); + return state; +} + +// ../../../lix/packages/client/dist/lixFs.js +var lixFs = (nodeishFs) => ({ + read(path) { + return nodeishFs.readFile(path, { encoding: "utf-8" }); + }, + write(path, content) { + return nodeishFs.writeFile(path, content); + }, + listDir(path) { + return nodeishFs.readdir(path); } +}); + +// ../../../lix/packages/client/dist/openRepository.js +async function openRepository(url, args) { + const ctx = await repoContext(url, args); + const state = await repoState(ctx, args); return { - _experimentalFeatures: experimentalFeatures, - _rawFs: rawFs, - _emptyWorkdir: emptyWorkdir, - _checkOutPlaceholders: checkOutPlaceholders, - _add: add2, - _remove: remove2, - // @ts-ignore - _isoCommit: ({ author: overrideAuthor, message }) => isomorphic_git_default.commit({ - fs: withProxy({ - nodeishFs: rawFs, - verbose: debug4, - description: "iso commit" - }), - dir, - cache, - author: overrideAuthor || author, - message - }), - nodeishFs, - ...experimentalFeatures.lixFs ? { - read(path) { - return nodeishFs.readFile(path, { encoding: "utf-8" }); - }, - write(path, content) { - return nodeishFs.writeFile(path, content); - }, - listDir(path) { - return nodeishFs.readdir(path); - } - } : {}, - /** - * Gets the git origin url of the current repository. - * - * @returns The git origin url or undefined if it could not be found. - */ - async listRemotes() { - try { - const withProxypedFS = withProxy({ - nodeishFs: rawFs, - verbose: debug4, - description: "listRemotes", - intercept: delayedAction - }); - const remotes = await isomorphic_git_default.listRemotes({ - fs: withProxypedFS, - dir - }); - return remotes; - } catch (_err) { - return void 0; - } - }, - async checkout({ branch: branch2 }) { - branchName = branch2; - if (lazyFS) { - throw new Error("not implemented for lazy lix mode yet, use openRepo with different branch instead"); - } - await checkout3({ - fs: withProxy({ - nodeishFs: rawFs, - verbose: debug4, - description: "checkout" - }), - cache, - dir, - ref: branchName - }); - }, - status: status2, - statusList: statusList2, - async forkStatus() { - if (!gitUrl) { - throw new Error("Could not find repo url, only github supported for forkStatus at the moment"); - } - const repo = await this; - const { isFork, parent } = await repo.getMeta(); - if (!isFork) { - return { error: "could not get fork upstream or repo not a fork" }; - } - const forkFs = withProxy({ - nodeishFs: rawFs, - verbose: debug4, - description: "forkStatus", - intercept: delayedAction - }); - const useBranchName = await isomorphic_git_default.currentBranch({ - fs: forkFs, - dir, - fullname: false - }); - if (!useBranchName) { - return { error: "could not get fork status for detached head" }; - } - await isomorphic_git_default.addRemote({ - dir, - remote: "upstream", - url: "https://" + parent.url, - fs: forkFs - }); - try { - await isomorphic_git_default.fetch({ - depth: 1, - singleBranch: true, - dir, - cache, - ref: useBranchName, - remote: "upstream", - http: makeHttpClient({ debug: debug4, description: "forkStatus" }), - fs: forkFs - }); - } catch (err) { - return { error: err }; - } - const currentUpstreamCommit = await isomorphic_git_default.resolveRef({ - fs: forkFs, - dir: "/", - ref: "upstream/" + useBranchName - }); - const currentOriginCommit = await isomorphic_git_default.resolveRef({ - fs: forkFs, - dir: "/", - ref: useBranchName - }); - if (currentUpstreamCommit === currentOriginCommit) { - return { ahead: 0, behind: 0, conflicts: false }; - } - const res = github2.request("GET /repos/{owner}/{repo}/compare/{base}...{head}", { - owner, - repo: repoName, - base: currentUpstreamCommit, - head: currentOriginCommit - }).catch((newError) => { - setErrors((previous) => [...previous || [], newError]); - return { error: newError }; - }); - const compare = await res; - if ("error" in compare || !("data" in compare)) { - return { error: compare.error || "could not diff repos on github" }; - } - await isomorphic_git_default.fetch({ - depth: compare.data.behind_by + 1, - remote: "upstream", - cache, - singleBranch: true, - dir, - ref: useBranchName, - http: makeHttpClient({ debug: debug4, description: "forkStatus" }), - fs: forkFs - }); - await isomorphic_git_default.fetch({ - depth: compare.data.ahead_by + 1, - cache, - singleBranch: true, - ref: useBranchName, - dir, - http: makeHttpClient({ debug: debug4, description: "forkStatus" }), - corsProxy: gitProxyUrl, - fs: forkFs - }); - let conflicts = false; - try { - await isomorphic_git_default.merge({ - fs: forkFs, - cache, - author: { name: "lix" }, - dir, - ours: useBranchName, - dryRun: true, - theirs: "upstream/" + useBranchName, - noUpdateBranch: true, - abortOnConflict: true - }); - } catch (err) { - conflicts = true; - } - return { ahead: compare.data.ahead_by, behind: compare.data.behind_by, conflicts }; - }, - async commit({ author: overrideAuthor, message, include }) { - if (include) { - const additions = []; - const deletions = []; - for (const entry of include) { - if (await rawFs.lstat(entry).catch(() => void 0)) { - additions.push(entry); - } else { - deletions.push(entry); - } - } - additions.length && await add2(additions); - deletions.length && await Promise.all(deletions.map((del) => remove2(del))); - } else { - } - const commitArgs = { - fs: withProxy({ - nodeishFs: rawFs, - verbose: debug4, - description: "commit", - intercept: delayedAction - }), - dir, - cache, - author: overrideAuthor || author, - message - }; - if (experimentalFeatures.lixCommit) { - console.warn("using experimental commit for this repo."); - return commit2(commitArgs); - } else { - return isomorphic_git_default.commit(commitArgs); - } - }, - push() { - if (!gitUrl) { - throw new Error("Could not find repo url, only github supported for push at the moment"); - } - return isomorphic_git_default.push({ - fs: withProxy({ - nodeishFs: rawFs, - verbose: debug4, - description: "push", - intercept: delayedAction - }), - url: gitUrl, - cache, - corsProxy: gitProxyUrl, - http: makeHttpClient({ debug: debug4, description: "push" }), - dir - }); - }, - async pull(cmdArgs) { - if (!gitUrl) { - throw new Error("Could not find repo url, only github supported for pull at the moment"); - } - const pullFs = withProxy({ - nodeishFs: rawFs, - verbose: debug4, - description: "pull", - intercept: delayedAction - }); - const { fetchHead, fetchHeadDescription } = await isomorphic_git_default.fetch({ - depth: 5, - fs: pullFs, - cache, - http: makeHttpClient({ verbose: debug4, description: "pull" }), - corsProxy: gitProxyUrl, - ref: branchName, - tags: false, - dir, - url: gitUrl, - // remote: "origin", - // remoteRef, - singleBranch: cmdArgs?.singleBranch || true - }); - if (!fetchHead) { - throw new Error("could not fetch head"); - } - await isomorphic_git_default.merge({ - fs: pullFs, - cache, - dir, - ours: branchName, - theirs: fetchHead, - fastForward: cmdArgs?.fastForward, - message: `Merge ${fetchHeadDescription}`, - author: cmdArgs?.author || author, - dryRun: false, - noUpdateBranch: false - // committer, - // signingKey, - // fastForwardOnly, - }); - if (experimentalFeatures.lazyClone) { - console.warn("enableExperimentalFeatures.lazyClone is set for this repo but pull not fully implemented. disabling lazy files"); - await emptyWorkdir(); - experimentalFeatures.lazyClone = false; - console.info('checking out "HEAD" after pull'); - await checkout3({ - fs: rawFs, - cache, - dir, - ref: branchName, - noCheckout: false - }); - } else { - await checkout3({ - fs: rawFs, - cache, - dir, - ref: branchName, - noCheckout: false - }); - } - }, - // experimental - it uses delayed actions - log(cmdArgs = {}) { - return isomorphic_git_default.log({ - fs: withProxy({ - nodeishFs: rawFs, - verbose: debug4, - description: "log", - intercept: delayedAction - }), - depth: cmdArgs.depth, - filepath: cmdArgs.filepath, - dir, - ref: cmdArgs.ref, - cache, - since: cmdArgs.since - }); - }, - async mergeUpstream(cmdArgs) { - if (!gitUrl) { - throw new Error("Could not find repo url, only github supported for mergeUpstream at the moment"); - } - const branch2 = cmdArgs?.branch || await isomorphic_git_default.currentBranch({ - fs: withProxy({ - nodeishFs: rawFs, - verbose: debug4, - description: "mergeUpstream", - intercept: delayedAction - }), - dir, - fullname: false - }); - if (typeof branch2 !== "string") { - throw "could not get current branch"; - } - let response; - try { - response = await github2.request("POST /repos/{owner}/{repo}/merge-upstream", { - branch: branch2, - owner, - repo: repoName - }); - } catch (error) { - return { error }; - } - return response?.data; - }, - async createFork() { - return github2.rest.repos.createFork({ - owner, - repo: repoName - }); - }, - /** - * Parses the origin from remotes. - * - * The function ensures that the same orgin is always returned for the same repository. - */ - async getOrigin() { - const repo = await this; - const remotes = await repo.listRemotes() || []; - return parseOrigin({ remotes }); - }, - async getCurrentBranch() { - return await isomorphic_git_default.currentBranch({ - fs: withProxy({ - nodeishFs: rawFs, - verbose: debug4, - description: "getCurrentBranch", - intercept: delayedAction - }), - dir - }) || void 0; - }, - async getBranches() { - if (!gitUrl) { - throw new Error("Could not find repo url, only github supported for getBranches at the moment"); - } - const serverRefs = await isomorphic_git_default.listServerRefs({ - url: gitUrl, - corsProxy: gitProxyUrl, - prefix: "refs/heads", - http: makeHttpClient({ verbose: debug4, description: "getBranches" }) - }).catch((error) => { - return { error }; - }); - if ("error" in serverRefs) { - return void 0; - } - return serverRefs.filter((ref) => !ref.ref.startsWith("refs/heads/gh-readonly-queue/")).map((ref) => ref.ref.replace("refs/heads/", "")) || void 0; - }, - errors: Object.assign(errors, { - subscribe: (callback) => { - createEffect2(() => { - const allErrors = errors(); - if (allErrors.length) { - callback(allErrors); - } - }); - } - }), - async getFirstCommitHash() { - const getFirstCommitFs = withProxy({ - nodeishFs: rawFs, - verbose: debug4, - description: "getFirstCommitHash", - intercept: delayedAction - }); - if (lazyFS) { - try { - await isomorphic_git_default.fetch({ - singleBranch: true, - dir, - depth: 2147483647, - http: makeHttpClient({ verbose: debug4, description: "getFirstCommitHash" }), - corsProxy: gitProxyUrl, - fs: getFirstCommitFs - }); - } catch { - return void 0; - } - } - let firstCommitHash = "HEAD"; - for (; ; ) { - const commits = await isomorphic_git_default.log({ - fs: getFirstCommitFs, - depth: 550, - dir, - ref: firstCommitHash - }).catch((error) => { - return { error }; - }); - if ("error" in commits) { - firstCommitHash = void 0; - break; - } - const lastHashInPage = commits.at(-1)?.oid; - if (lastHashInPage) { - firstCommitHash = lastHashInPage; - } - if (commits.length < 550) { - break; - } - } - return firstCommitHash; - }, - /** - * Additional information about a repository provided by GitHub. - */ - async getMeta() { - if (!gitUrl) { - throw new Error("Could not find repo url, only github supported for getMeta at the moment"); - } - const res = await github2.request("GET /repos/{owner}/{repo}", { - owner, - repo: repoName - }).catch((newError) => { - setErrors((previous) => [...previous || [], newError]); - return { error: newError }; - }); - if ("error" in res) { - return { error: res.error }; - } else { - return { - name: res.data.name, - isPrivate: res.data.private, - isFork: res.data.fork, - permissions: { - admin: res.data.permissions?.admin || false, - push: res.data.permissions?.push || false, - pull: res.data.permissions?.pull || false - }, - owner: { - name: res.data.owner.name || void 0, - email: res.data.owner.email || void 0, - login: res.data.owner.login - }, - parent: res.data.parent ? { - url: transformRemote(res.data.parent.git_url) || "unknown", - fullName: res.data.parent.full_name - } : void 0 - }; - } - } + _experimentalFeatures: ctx.experimentalFeatures, + _rawFs: ctx.rawFs, + nodeishFs: state.nodeishFs, + commit: commit2.bind(void 0, ctx, state), + status: status2.bind(void 0, ctx, state), + statusList: statusList.bind(void 0, ctx, state), + forkStatus: forkStatus.bind(void 0, ctx, state), + getMeta: getMeta.bind(void 0, ctx), + listRemotes: listRemotes2.bind(void 0, ctx, state), + log: log2.bind(void 0, ctx), + getOrigin: getOrigin.bind(void 0, ctx, state), + getBranches: getBranches.bind(void 0, ctx), + getCurrentBranch: getCurrentBranch.bind(void 0, ctx, state), + getFirstCommitHash: getFirstCommitHash.bind(void 0, ctx), + checkout: checkout2.bind(void 0, ctx, state), + createFork: createFork.bind(void 0, ctx), + mergeUpstream: mergeUpstream.bind(void 0, ctx), + push: push2.bind(void 0, ctx, state), + pull: pull2.bind(void 0, ctx, state), + ...ctx.experimentalFeatures.lixFs ? lixFs(state.nodeishFs) : {}, + // only exposed for testing + _emptyWorkdir: emptyWorkdir.bind(void 0, ctx, state), + _checkOutPlaceholders: checkOutPlaceholders.bind(void 0, ctx, state), + _add: add2.bind(void 0, ctx), + _remove: remove2.bind(void 0, ctx), + _isoCommit: isoCommit.bind(void 0, ctx) }; } // ../../../lix/packages/client/dist/index.js init_dist(); -// ../../../lix/packages/client/dist/hash.js -async function hash(inputStr) { - let usedCrypto; - if (typeof crypto === "undefined" && typeof process !== "undefined" && process?.versions?.node) { - const modName = "crypto"; - usedCrypto = await import(`node:${modName}`); - } else if (typeof crypto !== "undefined") { - usedCrypto = crypto; - } - if (!usedCrypto) { - throw new Error("Could not find crypto features in runtime"); - } - const idDigest = await usedCrypto.subtle.digest("SHA-256", new TextEncoder().encode(inputStr)); - return [...new Uint8Array(idDigest)].map((b) => ("00" + b.toString(16)).slice(-2)).join(""); -} - // ../../../lix/packages/client/dist/mockRepo.js init_dist(); @@ -59427,7 +58831,10 @@ var InternalProjectSettings = import_typebox4.Type.Object({ } ] })), - experimental: import_typebox4.Type.Optional(import_typebox4.Type.Record(import_typebox4.Type.String(), import_typebox4.Type.Literal(true))) + experimental: import_typebox4.Type.Optional(import_typebox4.Type.Record(import_typebox4.Type.String(), import_typebox4.Type.Literal(true), { + title: "Experimental settings", + description: "Experimental settings that are used for product development." + })) }); var ExternalProjectSettings = import_typebox4.Type.Record( import_typebox4.Type.String({ @@ -60295,54 +59702,54 @@ var PluginLoadMessagesError = class extends Error { }; // ../../../node_modules/.pnpm/solid-js@1.6.12/node_modules/solid-js/dist/solid.js -var sharedConfig2 = {}; -function setHydrateContext2(context2) { - sharedConfig2.context = context2; -} -var equalFn2 = (a, b) => a === b; -var $PROXY2 = Symbol("solid-proxy"); -var $TRACK2 = Symbol("solid-track"); -var $DEVCOMP2 = Symbol("solid-dev-component"); -var signalOptions2 = { - equals: equalFn2 +var sharedConfig = {}; +function setHydrateContext(context2) { + sharedConfig.context = context2; +} +var equalFn = (a, b) => a === b; +var $PROXY = Symbol("solid-proxy"); +var $TRACK = Symbol("solid-track"); +var $DEVCOMP = Symbol("solid-dev-component"); +var signalOptions = { + equals: equalFn }; -var ERROR2 = null; -var runEffects2 = runQueue2; -var STALE2 = 1; -var PENDING2 = 2; -var UNOWNED2 = { +var ERROR = null; +var runEffects = runQueue; +var STALE = 1; +var PENDING = 2; +var UNOWNED = { owned: null, cleanups: null, context: null, owner: null }; -var Owner2 = null; -var Transition2 = null; -var Scheduler2 = null; -var ExternalSourceFactory2 = null; -var Listener2 = null; -var Updates2 = null; -var Effects2 = null; -var ExecCount2 = 0; -var [transPending2, setTransPending2] = /* @__PURE__ */ createSignal3(false); -function createRoot2(fn, detachedOwner) { - const listener = Listener2, owner = Owner2, unowned = fn.length === 0, root = unowned ? UNOWNED2 : { +var Owner = null; +var Transition = null; +var Scheduler = null; +var ExternalSourceFactory = null; +var Listener = null; +var Updates = null; +var Effects = null; +var ExecCount = 0; +var [transPending, setTransPending] = /* @__PURE__ */ createSignal(false); +function createRoot(fn, detachedOwner) { + const listener = Listener, owner = Owner, unowned = fn.length === 0, root = unowned ? UNOWNED : { owned: null, cleanups: null, context: null, owner: detachedOwner === void 0 ? owner : detachedOwner - }, updateFn = unowned ? fn : () => fn(() => untrack2(() => cleanNode2(root))); - Owner2 = root; - Listener2 = null; + }, updateFn = unowned ? fn : () => fn(() => untrack(() => cleanNode(root))); + Owner = root; + Listener = null; try { - return runUpdates2(updateFn, true); + return runUpdates(updateFn, true); } finally { - Listener2 = listener; - Owner2 = owner; + Listener = listener; + Owner = owner; } } -function createSignal3(value, options) { - options = options ? Object.assign({}, signalOptions2, options) : signalOptions2; +function createSignal(value, options) { + options = options ? Object.assign({}, signalOptions, options) : signalOptions; const s = { value, observers: null, @@ -60351,82 +59758,82 @@ function createSignal3(value, options) { }; const setter = (value2) => { if (typeof value2 === "function") { - if (Transition2 && Transition2.running && Transition2.sources.has(s)) + if (Transition && Transition.running && Transition.sources.has(s)) value2 = value2(s.tValue); else value2 = value2(s.value); } - return writeSignal2(s, value2); + return writeSignal(s, value2); }; - return [readSignal2.bind(s), setter]; + return [readSignal.bind(s), setter]; } -function createRenderEffect2(fn, value, options) { - const c = createComputation2(fn, value, false, STALE2); - if (Scheduler2 && Transition2 && Transition2.running) - Updates2.push(c); +function createRenderEffect(fn, value, options) { + const c = createComputation(fn, value, false, STALE); + if (Scheduler && Transition && Transition.running) + Updates.push(c); else - updateComputation2(c); + updateComputation(c); } -function createEffect3(fn, value, options) { - runEffects2 = runUserEffects2; - const c = createComputation2(fn, value, false, STALE2), s = SuspenseContext2 && lookup2(Owner2, SuspenseContext2.id); +function createEffect(fn, value, options) { + runEffects = runUserEffects; + const c = createComputation(fn, value, false, STALE), s = SuspenseContext && lookup2(Owner, SuspenseContext.id); if (s) c.suspense = s; c.user = true; - Effects2 ? Effects2.push(c) : updateComputation2(c); + Effects ? Effects.push(c) : updateComputation(c); } -function createMemo2(fn, value, options) { - options = options ? Object.assign({}, signalOptions2, options) : signalOptions2; - const c = createComputation2(fn, value, true, 0); +function createMemo(fn, value, options) { + options = options ? Object.assign({}, signalOptions, options) : signalOptions; + const c = createComputation(fn, value, true, 0); c.observers = null; c.observerSlots = null; c.comparator = options.equals || void 0; - if (Scheduler2 && Transition2 && Transition2.running) { - c.tState = STALE2; - Updates2.push(c); + if (Scheduler && Transition && Transition.running) { + c.tState = STALE; + Updates.push(c); } else - updateComputation2(c); - return readSignal2.bind(c); + updateComputation(c); + return readSignal.bind(c); } function batch(fn) { - return runUpdates2(fn, false); + return runUpdates(fn, false); } -function untrack2(fn) { - if (Listener2 === null) +function untrack(fn) { + if (Listener === null) return fn(); - const listener = Listener2; - Listener2 = null; + const listener = Listener; + Listener = null; try { return fn(); } finally { - Listener2 = listener; + Listener = listener; } } -function onCleanup2(fn) { - if (Owner2 === null) +function onCleanup(fn) { + if (Owner === null) ; - else if (Owner2.cleanups === null) - Owner2.cleanups = [fn]; + else if (Owner.cleanups === null) + Owner.cleanups = [fn]; else - Owner2.cleanups.push(fn); + Owner.cleanups.push(fn); return fn; } function getListener() { - return Listener2; + return Listener; } -function startTransition2(fn) { - if (Transition2 && Transition2.running) { +function startTransition(fn) { + if (Transition && Transition.running) { fn(); - return Transition2.done; + return Transition.done; } - const l = Listener2; - const o = Owner2; + const l = Listener; + const o = Owner; return Promise.resolve().then(() => { - Listener2 = l; - Owner2 = o; + Listener = l; + Owner = o; let t; - if (Scheduler2 || SuspenseContext2) { - t = Transition2 || (Transition2 = { + if (Scheduler || SuspenseContext) { + t = Transition || (Transition = { sources: /* @__PURE__ */ new Set(), effects: [], promises: /* @__PURE__ */ new Set(), @@ -60437,69 +59844,69 @@ function startTransition2(fn) { t.done || (t.done = new Promise((res) => t.resolve = res)); t.running = true; } - runUpdates2(fn, false); - Listener2 = Owner2 = null; + runUpdates(fn, false); + Listener = Owner = null; return t ? t.done : void 0; }); } -function createContext2(defaultValue, options) { +function createContext(defaultValue, options) { const id = Symbol("context"); return { id, - Provider: createProvider2(id), + Provider: createProvider(id), defaultValue }; } -function children2(fn) { - const children3 = createMemo2(fn); - const memo2 = createMemo2(() => resolveChildren2(children3())); +function children(fn) { + const children2 = createMemo(fn); + const memo2 = createMemo(() => resolveChildren(children2())); memo2.toArray = () => { const c = memo2(); return Array.isArray(c) ? c : c != null ? [c] : []; }; return memo2; } -var SuspenseContext2; -function readSignal2() { - const runningTransition = Transition2 && Transition2.running; +var SuspenseContext; +function readSignal() { + const runningTransition = Transition && Transition.running; if (this.sources && (!runningTransition && this.state || runningTransition && this.tState)) { - if (!runningTransition && this.state === STALE2 || runningTransition && this.tState === STALE2) - updateComputation2(this); + if (!runningTransition && this.state === STALE || runningTransition && this.tState === STALE) + updateComputation(this); else { - const updates = Updates2; - Updates2 = null; - runUpdates2(() => lookUpstream2(this), false); - Updates2 = updates; + const updates = Updates; + Updates = null; + runUpdates(() => lookUpstream(this), false); + Updates = updates; } } - if (Listener2) { + if (Listener) { const sSlot = this.observers ? this.observers.length : 0; - if (!Listener2.sources) { - Listener2.sources = [this]; - Listener2.sourceSlots = [sSlot]; + if (!Listener.sources) { + Listener.sources = [this]; + Listener.sourceSlots = [sSlot]; } else { - Listener2.sources.push(this); - Listener2.sourceSlots.push(sSlot); + Listener.sources.push(this); + Listener.sourceSlots.push(sSlot); } if (!this.observers) { - this.observers = [Listener2]; - this.observerSlots = [Listener2.sources.length - 1]; + this.observers = [Listener]; + this.observerSlots = [Listener.sources.length - 1]; } else { - this.observers.push(Listener2); - this.observerSlots.push(Listener2.sources.length - 1); + this.observers.push(Listener); + this.observerSlots.push(Listener.sources.length - 1); } } - if (runningTransition && Transition2.sources.has(this)) + if (runningTransition && Transition.sources.has(this)) return this.tValue; return this.value; } -function writeSignal2(node, value, isComp) { - let current = Transition2 && Transition2.running && Transition2.sources.has(node) ? node.tValue : node.value; +function writeSignal(node, value, isComp) { + let current = Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value; if (!node.comparator || !node.comparator(current, value)) { - if (Transition2) { - const TransitionRunning = Transition2.running; - if (TransitionRunning || !isComp && Transition2.sources.has(node)) { - Transition2.sources.add(node); + if (Transition) { + const TransitionRunning = Transition.running; + if (TransitionRunning || !isComp && Transition.sources.has(node)) { + Transition.sources.add(node); node.tValue = value; } if (!TransitionRunning) @@ -60507,27 +59914,27 @@ function writeSignal2(node, value, isComp) { } else node.value = value; if (node.observers && node.observers.length) { - runUpdates2(() => { + runUpdates(() => { for (let i = 0; i < node.observers.length; i += 1) { const o = node.observers[i]; - const TransitionRunning = Transition2 && Transition2.running; - if (TransitionRunning && Transition2.disposed.has(o)) + const TransitionRunning = Transition && Transition.running; + if (TransitionRunning && Transition.disposed.has(o)) continue; if (TransitionRunning && !o.tState || !TransitionRunning && !o.state) { if (o.pure) - Updates2.push(o); + Updates.push(o); else - Effects2.push(o); + Effects.push(o); if (o.observers) - markDownstream2(o); + markDownstream(o); } if (TransitionRunning) - o.tState = STALE2; + o.tState = STALE; else - o.state = STALE2; + o.state = STALE; } - if (Updates2.length > 1e6) { - Updates2 = []; + if (Updates.length > 1e6) { + Updates = []; if (false) ; throw new Error(); @@ -60537,57 +59944,57 @@ function writeSignal2(node, value, isComp) { } return value; } -function updateComputation2(node) { +function updateComputation(node) { if (!node.fn) return; - cleanNode2(node); - const owner = Owner2, listener = Listener2, time = ExecCount2; - Listener2 = Owner2 = node; - runComputation2(node, Transition2 && Transition2.running && Transition2.sources.has(node) ? node.tValue : node.value, time); - if (Transition2 && !Transition2.running && Transition2.sources.has(node)) { + cleanNode(node); + const owner = Owner, listener = Listener, time = ExecCount; + Listener = Owner = node; + runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time); + if (Transition && !Transition.running && Transition.sources.has(node)) { queueMicrotask(() => { - runUpdates2(() => { - Transition2 && (Transition2.running = true); - Listener2 = Owner2 = node; - runComputation2(node, node.tValue, time); - Listener2 = Owner2 = null; + runUpdates(() => { + Transition && (Transition.running = true); + Listener = Owner = node; + runComputation(node, node.tValue, time); + Listener = Owner = null; }, false); }); } - Listener2 = listener; - Owner2 = owner; + Listener = listener; + Owner = owner; } -function runComputation2(node, value, time) { +function runComputation(node, value, time) { let nextValue; try { nextValue = node.fn(value); } catch (err) { if (node.pure) { - if (Transition2 && Transition2.running) { - node.tState = STALE2; - node.tOwned && node.tOwned.forEach(cleanNode2); + if (Transition && Transition.running) { + node.tState = STALE; + node.tOwned && node.tOwned.forEach(cleanNode); node.tOwned = void 0; } else { - node.state = STALE2; - node.owned && node.owned.forEach(cleanNode2); + node.state = STALE; + node.owned && node.owned.forEach(cleanNode); node.owned = null; } } node.updatedAt = time + 1; - return handleError2(err); + return handleError(err); } if (!node.updatedAt || node.updatedAt <= time) { if (node.updatedAt != null && "observers" in node) { - writeSignal2(node, nextValue, true); - } else if (Transition2 && Transition2.running && node.pure) { - Transition2.sources.add(node); + writeSignal(node, nextValue, true); + } else if (Transition && Transition.running && node.pure) { + Transition.sources.add(node); node.tValue = nextValue; } else node.value = nextValue; node.updatedAt = time; } } -function createComputation2(fn, init2, pure, state = STALE2, options) { +function createComputation(fn, init2, pure, state = STALE, options) { const c = { fn, state, @@ -60597,55 +60004,55 @@ function createComputation2(fn, init2, pure, state = STALE2, options) { sourceSlots: null, cleanups: null, value: init2, - owner: Owner2, + owner: Owner, context: null, pure }; - if (Transition2 && Transition2.running) { + if (Transition && Transition.running) { c.state = 0; c.tState = state; } - if (Owner2 === null) + if (Owner === null) ; - else if (Owner2 !== UNOWNED2) { - if (Transition2 && Transition2.running && Owner2.pure) { - if (!Owner2.tOwned) - Owner2.tOwned = [c]; + else if (Owner !== UNOWNED) { + if (Transition && Transition.running && Owner.pure) { + if (!Owner.tOwned) + Owner.tOwned = [c]; else - Owner2.tOwned.push(c); + Owner.tOwned.push(c); } else { - if (!Owner2.owned) - Owner2.owned = [c]; + if (!Owner.owned) + Owner.owned = [c]; else - Owner2.owned.push(c); + Owner.owned.push(c); } } - if (ExternalSourceFactory2) { - const [track, trigger] = createSignal3(void 0, { + if (ExternalSourceFactory) { + const [track, trigger] = createSignal(void 0, { equals: false }); - const ordinary = ExternalSourceFactory2(c.fn, trigger); - onCleanup2(() => ordinary.dispose()); - const triggerInTransition = () => startTransition2(trigger).then(() => inTransition.dispose()); - const inTransition = ExternalSourceFactory2(c.fn, triggerInTransition); + const ordinary = ExternalSourceFactory(c.fn, trigger); + onCleanup(() => ordinary.dispose()); + const triggerInTransition = () => startTransition(trigger).then(() => inTransition.dispose()); + const inTransition = ExternalSourceFactory(c.fn, triggerInTransition); c.fn = (x) => { track(); - return Transition2 && Transition2.running ? inTransition.track(x) : ordinary.track(x); + return Transition && Transition.running ? inTransition.track(x) : ordinary.track(x); }; } return c; } -function runTop2(node) { - const runningTransition = Transition2 && Transition2.running; +function runTop(node) { + const runningTransition = Transition && Transition.running; if (!runningTransition && node.state === 0 || runningTransition && node.tState === 0) return; - if (!runningTransition && node.state === PENDING2 || runningTransition && node.tState === PENDING2) - return lookUpstream2(node); - if (node.suspense && untrack2(node.suspense.inFallback)) + if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) + return lookUpstream(node); + if (node.suspense && untrack(node.suspense.inFallback)) return node.suspense.effects.push(node); const ancestors = [node]; - while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount2)) { - if (runningTransition && Transition2.disposed.has(node)) + while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) { + if (runningTransition && Transition.disposed.has(node)) return; if (!runningTransition && node.state || runningTransition && node.tState) ancestors.push(node); @@ -60655,72 +60062,72 @@ function runTop2(node) { if (runningTransition) { let top = node, prev = ancestors[i + 1]; while ((top = top.owner) && top !== prev) { - if (Transition2.disposed.has(top)) + if (Transition.disposed.has(top)) return; } } - if (!runningTransition && node.state === STALE2 || runningTransition && node.tState === STALE2) { - updateComputation2(node); - } else if (!runningTransition && node.state === PENDING2 || runningTransition && node.tState === PENDING2) { - const updates = Updates2; - Updates2 = null; - runUpdates2(() => lookUpstream2(node, ancestors[0]), false); - Updates2 = updates; + if (!runningTransition && node.state === STALE || runningTransition && node.tState === STALE) { + updateComputation(node); + } else if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) { + const updates = Updates; + Updates = null; + runUpdates(() => lookUpstream(node, ancestors[0]), false); + Updates = updates; } } } -function runUpdates2(fn, init2) { - if (Updates2) +function runUpdates(fn, init2) { + if (Updates) return fn(); let wait = false; if (!init2) - Updates2 = []; - if (Effects2) + Updates = []; + if (Effects) wait = true; else - Effects2 = []; - ExecCount2++; + Effects = []; + ExecCount++; try { const res = fn(); - completeUpdates2(wait); + completeUpdates(wait); return res; } catch (err) { if (!wait) - Effects2 = null; - Updates2 = null; - handleError2(err); + Effects = null; + Updates = null; + handleError(err); } } -function completeUpdates2(wait) { - if (Updates2) { - if (Scheduler2 && Transition2 && Transition2.running) - scheduleQueue2(Updates2); +function completeUpdates(wait) { + if (Updates) { + if (Scheduler && Transition && Transition.running) + scheduleQueue(Updates); else - runQueue2(Updates2); - Updates2 = null; + runQueue(Updates); + Updates = null; } if (wait) return; let res; - if (Transition2) { - if (!Transition2.promises.size && !Transition2.queue.size) { - const sources = Transition2.sources; - const disposed = Transition2.disposed; - Effects2.push.apply(Effects2, Transition2.effects); - res = Transition2.resolve; - for (const e2 of Effects2) { + if (Transition) { + if (!Transition.promises.size && !Transition.queue.size) { + const sources = Transition.sources; + const disposed = Transition.disposed; + Effects.push.apply(Effects, Transition.effects); + res = Transition.resolve; + for (const e2 of Effects) { "tState" in e2 && (e2.state = e2.tState); delete e2.tState; } - Transition2 = null; - runUpdates2(() => { + Transition = null; + runUpdates(() => { for (const d of disposed) - cleanNode2(d); + cleanNode(d); for (const v of sources) { v.value = v.tValue; if (v.owned) { for (let i = 0, len = v.owned.length; i < len; i++) - cleanNode2(v.owned[i]); + cleanNode(v.owned[i]); } if (v.tOwned) v.owned = v.tOwned; @@ -60728,60 +60135,60 @@ function completeUpdates2(wait) { delete v.tOwned; v.tState = 0; } - setTransPending2(false); + setTransPending(false); }, false); - } else if (Transition2.running) { - Transition2.running = false; - Transition2.effects.push.apply(Transition2.effects, Effects2); - Effects2 = null; - setTransPending2(true); + } else if (Transition.running) { + Transition.running = false; + Transition.effects.push.apply(Transition.effects, Effects); + Effects = null; + setTransPending(true); return; } } - const e = Effects2; - Effects2 = null; + const e = Effects; + Effects = null; if (e.length) - runUpdates2(() => runEffects2(e), false); + runUpdates(() => runEffects(e), false); if (res) res(); } -function runQueue2(queue) { +function runQueue(queue) { for (let i = 0; i < queue.length; i++) - runTop2(queue[i]); + runTop(queue[i]); } -function scheduleQueue2(queue) { +function scheduleQueue(queue) { for (let i = 0; i < queue.length; i++) { const item = queue[i]; - const tasks = Transition2.queue; + const tasks = Transition.queue; if (!tasks.has(item)) { tasks.add(item); - Scheduler2(() => { + Scheduler(() => { tasks.delete(item); - runUpdates2(() => { - Transition2.running = true; - runTop2(item); + runUpdates(() => { + Transition.running = true; + runTop(item); }, false); - Transition2 && (Transition2.running = false); + Transition && (Transition.running = false); }); } } } -function runUserEffects2(queue) { +function runUserEffects(queue) { let i, userLength = 0; for (i = 0; i < queue.length; i++) { const e = queue[i]; if (!e.user) - runTop2(e); + runTop(e); else queue[userLength++] = e; } - if (sharedConfig2.context) - setHydrateContext2(); + if (sharedConfig.context) + setHydrateContext(); for (i = 0; i < userLength; i++) - runTop2(queue[i]); + runTop(queue[i]); } -function lookUpstream2(node, ignore2) { - const runningTransition = Transition2 && Transition2.running; +function lookUpstream(node, ignore2) { + const runningTransition = Transition && Transition.running; if (runningTransition) node.tState = 0; else @@ -60789,32 +60196,32 @@ function lookUpstream2(node, ignore2) { for (let i = 0; i < node.sources.length; i += 1) { const source = node.sources[i]; if (source.sources) { - if (!runningTransition && source.state === STALE2 || runningTransition && source.tState === STALE2) { - if (source !== ignore2 && (!source.updatedAt || source.updatedAt < ExecCount2)) - runTop2(source); - } else if (!runningTransition && source.state === PENDING2 || runningTransition && source.tState === PENDING2) - lookUpstream2(source, ignore2); + if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) { + if (source !== ignore2 && (!source.updatedAt || source.updatedAt < ExecCount)) + runTop(source); + } else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) + lookUpstream(source, ignore2); } } } -function markDownstream2(node) { - const runningTransition = Transition2 && Transition2.running; +function markDownstream(node) { + const runningTransition = Transition && Transition.running; for (let i = 0; i < node.observers.length; i += 1) { const o = node.observers[i]; if (!runningTransition && !o.state || runningTransition && !o.tState) { if (runningTransition) - o.tState = PENDING2; + o.tState = PENDING; else - o.state = PENDING2; + o.state = PENDING; if (o.pure) - Updates2.push(o); + Updates.push(o); else - Effects2.push(o); - o.observers && markDownstream2(o); + Effects.push(o); + o.observers && markDownstream(o); } } } -function cleanNode2(node) { +function cleanNode(node) { let i; if (node.sources) { while (node.sources.length) { @@ -60829,16 +60236,16 @@ function cleanNode2(node) { } } } - if (Transition2 && Transition2.running && node.pure) { + if (Transition && Transition.running && node.pure) { if (node.tOwned) { for (i = 0; i < node.tOwned.length; i++) - cleanNode2(node.tOwned[i]); + cleanNode(node.tOwned[i]); delete node.tOwned; } - reset2(node, true); + reset(node, true); } else if (node.owned) { for (i = 0; i < node.owned.length; i++) - cleanNode2(node.owned[i]); + cleanNode(node.owned[i]); node.owned = null; } if (node.cleanups) { @@ -60846,85 +60253,85 @@ function cleanNode2(node) { node.cleanups[i](); node.cleanups = null; } - if (Transition2 && Transition2.running) + if (Transition && Transition.running) node.tState = 0; else node.state = 0; node.context = null; } -function reset2(node, top) { +function reset(node, top) { if (!top) { node.tState = 0; - Transition2.disposed.add(node); + Transition.disposed.add(node); } if (node.owned) { for (let i = 0; i < node.owned.length; i++) - reset2(node.owned[i]); + reset(node.owned[i]); } } -function castError2(err) { +function castError(err) { if (err instanceof Error || typeof err === "string") return err; return new Error("Unknown error"); } -function runErrors2(fns, err) { +function runErrors(fns, err) { for (const f of fns) f(err); } -function handleError2(err) { - err = castError2(err); - const fns = ERROR2 && lookup2(Owner2, ERROR2); +function handleError(err) { + err = castError(err); + const fns = ERROR && lookup2(Owner, ERROR); if (!fns) throw err; - if (Effects2) - Effects2.push({ + if (Effects) + Effects.push({ fn() { - runErrors2(fns, err); + runErrors(fns, err); }, - state: STALE2 + state: STALE }); else - runErrors2(fns, err); + runErrors(fns, err); } function lookup2(owner, key) { return owner ? owner.context && owner.context[key] !== void 0 ? owner.context[key] : lookup2(owner.owner, key) : void 0; } -function resolveChildren2(children3) { - if (typeof children3 === "function" && !children3.length) - return resolveChildren2(children3()); - if (Array.isArray(children3)) { +function resolveChildren(children2) { + if (typeof children2 === "function" && !children2.length) + return resolveChildren(children2()); + if (Array.isArray(children2)) { const results = []; - for (let i = 0; i < children3.length; i++) { - const result = resolveChildren2(children3[i]); + for (let i = 0; i < children2.length; i++) { + const result = resolveChildren(children2[i]); Array.isArray(result) ? results.push.apply(results, result) : results.push(result); } return results; } - return children3; + return children2; } -function createProvider2(id, options) { +function createProvider(id, options) { return function provider(props) { let res; - createRenderEffect2(() => res = untrack2(() => { - Owner2.context = { + createRenderEffect(() => res = untrack(() => { + Owner.context = { [id]: props.value }; - return children2(() => props.children); + return children(() => props.children); }), void 0); return res; }; } -var FALLBACK2 = Symbol("fallback"); -var SuspenseListContext2 = createContext2(); +var FALLBACK = Symbol("fallback"); +var SuspenseListContext = createContext(); var DEV; // ../sdk/dist/reactivity/solid.js -var createSignal4 = createSignal3; -var createRoot3 = createRoot2; -var createEffect4 = createEffect3; +var createSignal2 = createSignal; +var createRoot2 = createRoot; +var createEffect2 = createEffect; var batch2 = batch; var getListener2 = getListener; -var onCleanup3 = onCleanup2; +var onCleanup2 = onCleanup; // ../sdk/dist/reactivity/trigger.js var isServer = false; @@ -60945,11 +60352,11 @@ var TriggerCache = class { return; let trigger = this.#map.get(key); if (!trigger) { - const [$, $$] = createSignal4(void 0, triggerCacheOptions); + const [$, $$] = createSignal2(void 0, triggerCacheOptions); this.#map.set(key, trigger = { $, $$, n: 1 }); } else trigger.n++; - onCleanup3(() => { + onCleanup2(() => { if (trigger.n-- === 1) queueMicrotask(() => trigger.n === 0 && this.#map.delete(key)); }); @@ -61049,7 +60456,7 @@ var ReactiveMap = class extends Map { function createMessagesQuery(messages) { const index2 = new ReactiveMap(); const defaultAliasIndex = new ReactiveMap(); - createEffect4(() => { + createEffect2(() => { index2.clear(); for (const message of structuredClone(messages())) { index2.set(message.id, message); @@ -61230,14 +60637,14 @@ function createMessageLintReportsQuery(messagesQuery, settings, installedMessage const throttledLogLintMessage = throttle(2e3, (messageId) => { debug(`lintSingleMessage: ${lintMessageCount} id: ${messageId}`); }); - createEffect4(() => { + createEffect2(() => { const currentMessageIds = new Set(messagesQuery.includedMessageIds()); const deletedTrackedMessages = [...trackedMessages].filter((tracked) => !currentMessageIds.has(tracked[0])); if (rulesArray) { for (const messageId of currentMessageIds) { if (!trackedMessages.has(messageId)) { - createRoot3((dispose) => { - createEffect4(() => { + createRoot2((dispose) => { + createEffect2(() => { const message = messagesQuery.get({ where: { id: messageId } }); if (!message) { return; @@ -62606,11 +62013,11 @@ async function loadProject(args) { }); await maybeMigrateToDirectory({ nodeishFs, projectPath }); await maybeCreateFirstProjectId({ projectPath, repo: args.repo }); - return await createRoot3(async () => { + return await createRoot2(async () => { const { data: projectId } = await tryCatch(() => nodeishFs.readFile(args.projectPath + "/project_id", { encoding: "utf-8" })); const [initialized, markInitAsComplete, markInitAsFailed] = createAwaitable(); - const [settings, _setSettings] = createSignal4(); - createEffect4(() => { + const [settings, _setSettings] = createSignal2(); + createEffect2(() => { loadSettings({ settingsFilePath: projectPath + "/settings.json", nodeishFs }).then((settings2) => setSettings(settings2)).catch((err) => { markInitAsFailed(err); }); @@ -62629,8 +62036,8 @@ async function loadProject(args) { throw new Error("Unhandled error in setSettings. This is an internal bug. Please file an issue."); } }; - const [resolvedModules, setResolvedModules] = createSignal4(); - createEffect4(() => { + const [resolvedModules, setResolvedModules] = createSignal2(); + createEffect2(() => { const _settings = settings(); if (!_settings) return; @@ -62639,13 +62046,13 @@ async function loadProject(args) { }).catch((err) => markInitAsFailed(err)); }); let settingsValue; - createEffect4(() => settingsValue = settings()); - const [messages, setMessages] = createSignal4([]); - const [loadMessagesViaPluginError, setLoadMessagesViaPluginError] = createSignal4(); - const [saveMessagesViaPluginError, setSaveMessagesViaPluginError] = createSignal4(); + createEffect2(() => settingsValue = settings()); + const [messages, setMessages] = createSignal2([]); + const [loadMessagesViaPluginError, setLoadMessagesViaPluginError] = createSignal2(); + const [saveMessagesViaPluginError, setSaveMessagesViaPluginError] = createSignal2(); const messagesQuery = createMessagesQuery(() => messages()); const messageLockDirPath = projectPath + "/messagelock"; - createEffect4(() => { + createEffect2(() => { const _resolvedModules = resolvedModules(); if (!_resolvedModules) return; @@ -62713,7 +62120,7 @@ async function loadProject(args) { nodeishFs.watch("/", { signal: abortController.signal }) !== void 0; const trackedMessages = /* @__PURE__ */ new Map(); let initialSetup = true; - createEffect4(() => { + createEffect2(() => { const _resolvedModules = resolvedModules(); if (!_resolvedModules) return; @@ -62723,8 +62130,8 @@ async function loadProject(args) { const loadMessagesPlugin = _resolvedModules.plugins.find((plugin) => plugin.loadMessages !== void 0); for (const messageId of currentMessageIds) { if (!trackedMessages.has(messageId)) { - createRoot3((dispose) => { - createEffect4(() => { + createRoot2((dispose) => { + createEffect2(() => { const message = messagesQuery.get({ where: { id: messageId } }); if (!message) { return; @@ -62886,7 +62293,7 @@ function skipFirst(func) { function createSubscribable(signal) { return Object.assign(signal, { subscribe: (callback) => { - createEffect4(() => { + createEffect2(() => { callback(signal()); }); } @@ -63158,7 +62565,7 @@ async function releaseLock(fs2, lockDirPath, lockOrigin, lockTime) { // ../sdk/dist/listProjects.js var ignores = ["node_modules", ".git"]; -var listProjects = async (nodeishFs, from3) => { +var listProjects = async (nodeishFs, from2) => { const recursionLimit = 5; const projects = []; async function searchDir(path, depth) { @@ -63185,7 +62592,7 @@ var listProjects = async (nodeishFs, from3) => { } } } - await searchDir(from3, 0); + await searchDir(from2, 0); for (const project of projects) { project.projectPath = project.projectPath.replace(/\/\//g, "/"); } @@ -63262,7 +62669,7 @@ async function run() { core.debug("Fork not detected, fetching and checking out head repository"); await fetchBranch(headMeta.branch); await checkoutBranch(headMeta.branch); - await pull2(); + await pull3(); repoHead = await openRepository("file://" + process.cwd(), { nodeishFs: fs, branch: headMeta.branch @@ -63481,7 +62888,7 @@ async function fetchBranch(branchName) { }); }); } -async function pull2() { +async function pull3() { return new Promise((resolve, reject) => { (0, import_node_child_process.exec)(`git pull`, { cwd: process.cwd() }, (error, stdout, stderr) => { if (error) {