@rasla/logify
Version:
A lightweight, flexible, and easy-to-use logging middleware for Elysia.js applications
1,612 lines (1,595 loc) • 537 kB
JavaScript
var __create = Object.create;
var __getProtoOf = Object.getPrototypeOf;
var __defProp = Object.defineProperty;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __toESM = (mod, isNodeMode, target) => {
target = mod != null ? __create(__getProtoOf(mod)) : {};
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
for (let key of __getOwnPropNames(mod))
if (!__hasOwnProp.call(to, key))
__defProp(to, key, {
get: () => mod[key],
enumerable: true
});
return to;
};
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, {
get: all[name],
enumerable: true,
configurable: true,
set: (newValue) => all[name] = () => newValue
});
};
// node_modules/cookie/dist/index.js
var require_dist = __commonJS((exports) => {
Object.defineProperty(exports, "__esModule", { value: true });
exports.parse = parse2;
exports.serialize = serialize;
var cookieNameRegExp = /^[\u0021-\u003A\u003C\u003E-\u007E]+$/;
var cookieValueRegExp = /^[\u0021-\u003A\u003C-\u007E]*$/;
var domainValueRegExp = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i;
var pathValueRegExp = /^[\u0020-\u003A\u003D-\u007E]*$/;
var __toString = Object.prototype.toString;
var NullObject = /* @__PURE__ */ (() => {
const C = function() {};
C.prototype = Object.create(null);
return C;
})();
function parse2(str, options) {
const obj = new NullObject;
const len = str.length;
if (len < 2)
return obj;
const dec = options?.decode || decode2;
let index = 0;
do {
const eqIdx = str.indexOf("=", index);
if (eqIdx === -1)
break;
const colonIdx = str.indexOf(";", index);
const endIdx = colonIdx === -1 ? len : colonIdx;
if (eqIdx > endIdx) {
index = str.lastIndexOf(";", eqIdx - 1) + 1;
continue;
}
const keyStartIdx = startIndex(str, index, eqIdx);
const keyEndIdx = endIndex(str, eqIdx, keyStartIdx);
const key = str.slice(keyStartIdx, keyEndIdx);
if (obj[key] === undefined) {
let valStartIdx = startIndex(str, eqIdx + 1, endIdx);
let valEndIdx = endIndex(str, endIdx, valStartIdx);
const value = dec(str.slice(valStartIdx, valEndIdx));
obj[key] = value;
}
index = endIdx + 1;
} while (index < len);
return obj;
}
function startIndex(str, index, max) {
do {
const code = str.charCodeAt(index);
if (code !== 32 && code !== 9)
return index;
} while (++index < max);
return max;
}
function endIndex(str, index, min) {
while (index > min) {
const code = str.charCodeAt(--index);
if (code !== 32 && code !== 9)
return index + 1;
}
return min;
}
function serialize(name, val, options) {
const enc = options?.encode || encodeURIComponent;
if (!cookieNameRegExp.test(name)) {
throw new TypeError(`argument name is invalid: ${name}`);
}
const value = enc(val);
if (!cookieValueRegExp.test(value)) {
throw new TypeError(`argument val is invalid: ${val}`);
}
let str = name + "=" + value;
if (!options)
return str;
if (options.maxAge !== undefined) {
if (!Number.isInteger(options.maxAge)) {
throw new TypeError(`option maxAge is invalid: ${options.maxAge}`);
}
str += "; Max-Age=" + options.maxAge;
}
if (options.domain) {
if (!domainValueRegExp.test(options.domain)) {
throw new TypeError(`option domain is invalid: ${options.domain}`);
}
str += "; Domain=" + options.domain;
}
if (options.path) {
if (!pathValueRegExp.test(options.path)) {
throw new TypeError(`option path is invalid: ${options.path}`);
}
str += "; Path=" + options.path;
}
if (options.expires) {
if (!isDate(options.expires) || !Number.isFinite(options.expires.valueOf())) {
throw new TypeError(`option expires is invalid: ${options.expires}`);
}
str += "; Expires=" + options.expires.toUTCString();
}
if (options.httpOnly) {
str += "; HttpOnly";
}
if (options.secure) {
str += "; Secure";
}
if (options.partitioned) {
str += "; Partitioned";
}
if (options.priority) {
const priority = typeof options.priority === "string" ? options.priority.toLowerCase() : undefined;
switch (priority) {
case "low":
str += "; Priority=Low";
break;
case "medium":
str += "; Priority=Medium";
break;
case "high":
str += "; Priority=High";
break;
default:
throw new TypeError(`option priority is invalid: ${options.priority}`);
}
}
if (options.sameSite) {
const sameSite = typeof options.sameSite === "string" ? options.sameSite.toLowerCase() : options.sameSite;
switch (sameSite) {
case true:
case "strict":
str += "; SameSite=Strict";
break;
case "lax":
str += "; SameSite=Lax";
break;
case "none":
str += "; SameSite=None";
break;
default:
throw new TypeError(`option sameSite is invalid: ${options.sameSite}`);
}
}
return str;
}
function decode2(str) {
if (str.indexOf("%") === -1)
return str;
try {
return decodeURIComponent(str);
} catch (e) {
return str;
}
}
function isDate(val) {
return __toString.call(val) === "[object Date]";
}
});
// node_modules/chalk/source/vendor/ansi-styles/index.js
var ANSI_BACKGROUND_OFFSET = 10;
var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
var styles = {
modifier: {
reset: [0, 0],
bold: [1, 22],
dim: [2, 22],
italic: [3, 23],
underline: [4, 24],
overline: [53, 55],
inverse: [7, 27],
hidden: [8, 28],
strikethrough: [9, 29]
},
color: {
black: [30, 39],
red: [31, 39],
green: [32, 39],
yellow: [33, 39],
blue: [34, 39],
magenta: [35, 39],
cyan: [36, 39],
white: [37, 39],
blackBright: [90, 39],
gray: [90, 39],
grey: [90, 39],
redBright: [91, 39],
greenBright: [92, 39],
yellowBright: [93, 39],
blueBright: [94, 39],
magentaBright: [95, 39],
cyanBright: [96, 39],
whiteBright: [97, 39]
},
bgColor: {
bgBlack: [40, 49],
bgRed: [41, 49],
bgGreen: [42, 49],
bgYellow: [43, 49],
bgBlue: [44, 49],
bgMagenta: [45, 49],
bgCyan: [46, 49],
bgWhite: [47, 49],
bgBlackBright: [100, 49],
bgGray: [100, 49],
bgGrey: [100, 49],
bgRedBright: [101, 49],
bgGreenBright: [102, 49],
bgYellowBright: [103, 49],
bgBlueBright: [104, 49],
bgMagentaBright: [105, 49],
bgCyanBright: [106, 49],
bgWhiteBright: [107, 49]
}
};
var modifierNames = Object.keys(styles.modifier);
var foregroundColorNames = Object.keys(styles.color);
var backgroundColorNames = Object.keys(styles.bgColor);
var colorNames = [...foregroundColorNames, ...backgroundColorNames];
function assembleStyles() {
const codes = new Map;
for (const [groupName, group] of Object.entries(styles)) {
for (const [styleName, style] of Object.entries(group)) {
styles[styleName] = {
open: `\x1B[${style[0]}m`,
close: `\x1B[${style[1]}m`
};
group[styleName] = styles[styleName];
codes.set(style[0], style[1]);
}
Object.defineProperty(styles, groupName, {
value: group,
enumerable: false
});
}
Object.defineProperty(styles, "codes", {
value: codes,
enumerable: false
});
styles.color.close = "\x1B[39m";
styles.bgColor.close = "\x1B[49m";
styles.color.ansi = wrapAnsi16();
styles.color.ansi256 = wrapAnsi256();
styles.color.ansi16m = wrapAnsi16m();
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
Object.defineProperties(styles, {
rgbToAnsi256: {
value(red, green, blue) {
if (red === green && green === blue) {
if (red < 8) {
return 16;
}
if (red > 248) {
return 231;
}
return Math.round((red - 8) / 247 * 24) + 232;
}
return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
},
enumerable: false
},
hexToRgb: {
value(hex) {
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
if (!matches) {
return [0, 0, 0];
}
let [colorString] = matches;
if (colorString.length === 3) {
colorString = [...colorString].map((character) => character + character).join("");
}
const integer = Number.parseInt(colorString, 16);
return [
integer >> 16 & 255,
integer >> 8 & 255,
integer & 255
];
},
enumerable: false
},
hexToAnsi256: {
value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
enumerable: false
},
ansi256ToAnsi: {
value(code) {
if (code < 8) {
return 30 + code;
}
if (code < 16) {
return 90 + (code - 8);
}
let red;
let green;
let blue;
if (code >= 232) {
red = ((code - 232) * 10 + 8) / 255;
green = red;
blue = red;
} else {
code -= 16;
const remainder = code % 36;
red = Math.floor(code / 36) / 5;
green = Math.floor(remainder / 6) / 5;
blue = remainder % 6 / 5;
}
const value = Math.max(red, green, blue) * 2;
if (value === 0) {
return 30;
}
let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
if (value === 2) {
result += 60;
}
return result;
},
enumerable: false
},
rgbToAnsi: {
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
enumerable: false
},
hexToAnsi: {
value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
enumerable: false
}
});
return styles;
}
var ansiStyles = assembleStyles();
var ansi_styles_default = ansiStyles;
// node_modules/chalk/source/vendor/supports-color/index.js
import process2 from "node:process";
import os from "node:os";
import tty from "node:tty";
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process2.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);
}
var { env } = process2;
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);
}
}
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 !== undefined) {
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 ("TF_BUILD" in env && "AGENT_NAME" in env) {
return 1;
}
if (haveStream && !streamIsTTY && forceColor === undefined) {
return 0;
}
const min = forceColor || 0;
if (env.TERM === "dumb") {
return min;
}
if (process2.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 (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => (key in env))) {
return 3;
}
if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "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 (env.TERM === "xterm-kitty") {
return 3;
}
if ("TERM_PROGRAM" in env) {
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
switch (env.TERM_PROGRAM) {
case "iTerm.app": {
return version >= 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 createSupportsColor(stream, options = {}) {
const level = _supportsColor(stream, {
streamIsTTY: stream && stream.isTTY,
...options
});
return translateLevel(level);
}
var supportsColor = {
stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
stderr: createSupportsColor({ isTTY: tty.isatty(2) })
};
var supports_color_default = supportsColor;
// node_modules/chalk/source/utilities.js
function stringReplaceAll(string, substring, replacer) {
let index = string.indexOf(substring);
if (index === -1) {
return string;
}
const substringLength = substring.length;
let endIndex = 0;
let returnValue = "";
do {
returnValue += string.slice(endIndex, index) + substring + replacer;
endIndex = index + substringLength;
index = string.indexOf(substring, endIndex);
} while (index !== -1);
returnValue += string.slice(endIndex);
return returnValue;
}
function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
let endIndex = 0;
let returnValue = "";
do {
const gotCR = string[index - 1] === "\r";
returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? `\r
` : `
`) + postfix;
endIndex = index + 1;
index = string.indexOf(`
`, endIndex);
} while (index !== -1);
returnValue += string.slice(endIndex);
return returnValue;
}
// node_modules/chalk/source/index.js
var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
var GENERATOR = Symbol("GENERATOR");
var STYLER = Symbol("STYLER");
var IS_EMPTY = Symbol("IS_EMPTY");
var levelMapping = [
"ansi",
"ansi",
"ansi256",
"ansi16m"
];
var styles2 = Object.create(null);
var applyOptions = (object, options = {}) => {
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
throw new Error("The `level` option should be an integer from 0 to 3");
}
const colorLevel = stdoutColor ? stdoutColor.level : 0;
object.level = options.level === undefined ? colorLevel : options.level;
};
var chalkFactory = (options) => {
const chalk = (...strings) => strings.join(" ");
applyOptions(chalk, options);
Object.setPrototypeOf(chalk, createChalk.prototype);
return chalk;
};
function createChalk(options) {
return chalkFactory(options);
}
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
for (const [styleName, style] of Object.entries(ansi_styles_default)) {
styles2[styleName] = {
get() {
const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
Object.defineProperty(this, styleName, { value: builder });
return builder;
}
};
}
styles2.visible = {
get() {
const builder = createBuilder(this, this[STYLER], true);
Object.defineProperty(this, "visible", { value: builder });
return builder;
}
};
var getModelAnsi = (model, level, type, ...arguments_) => {
if (model === "rgb") {
if (level === "ansi16m") {
return ansi_styles_default[type].ansi16m(...arguments_);
}
if (level === "ansi256") {
return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
}
return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
}
if (model === "hex") {
return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
}
return ansi_styles_default[type][model](...arguments_);
};
var usedModels = ["rgb", "hex", "ansi256"];
for (const model of usedModels) {
styles2[model] = {
get() {
const { level } = this;
return function(...arguments_) {
const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
return createBuilder(this, styler, this[IS_EMPTY]);
};
}
};
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
styles2[bgModel] = {
get() {
const { level } = this;
return function(...arguments_) {
const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
return createBuilder(this, styler, this[IS_EMPTY]);
};
}
};
}
var proto = Object.defineProperties(() => {}, {
...styles2,
level: {
enumerable: true,
get() {
return this[GENERATOR].level;
},
set(level) {
this[GENERATOR].level = level;
}
}
});
var createStyler = (open, close, parent) => {
let openAll;
let closeAll;
if (parent === undefined) {
openAll = open;
closeAll = close;
} else {
openAll = parent.openAll + open;
closeAll = close + parent.closeAll;
}
return {
open,
close,
openAll,
closeAll,
parent
};
};
var createBuilder = (self, _styler, _isEmpty) => {
const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
Object.setPrototypeOf(builder, proto);
builder[GENERATOR] = self;
builder[STYLER] = _styler;
builder[IS_EMPTY] = _isEmpty;
return builder;
};
var applyStyle = (self, string) => {
if (self.level <= 0 || !string) {
return self[IS_EMPTY] ? "" : string;
}
let styler = self[STYLER];
if (styler === undefined) {
return string;
}
const { openAll, closeAll } = styler;
if (string.includes("\x1B")) {
while (styler !== undefined) {
string = stringReplaceAll(string, styler.close, styler.open);
styler = styler.parent;
}
}
const lfIndex = string.indexOf(`
`);
if (lfIndex !== -1) {
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
}
return openAll + string + closeAll;
};
Object.defineProperties(createChalk.prototype, styles2);
var chalk = createChalk();
var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
var source_default = chalk;
// src/logger.ts
import { appendFileSync, existsSync, mkdirSync } from "node:fs";
import { dirname } from "node:path";
var LOG_COLORS = {
debug: source_default.gray,
info: source_default.blue,
warn: source_default.yellow,
error: source_default.red
};
class Logger {
options;
static DEFAULT_OPTIONS = {
console: true,
file: false,
level: "info",
format: "[{timestamp}] {level} [{method}] {path} - {statusCode} {duration}ms{ip} {message}",
includeIp: false
};
constructor(options = {}) {
this.options = { ...Logger.DEFAULT_OPTIONS, ...options };
this.initializeFileLogger();
}
initializeFileLogger() {
if (this.options.file && this.options.filePath) {
try {
const dir = dirname(this.options.filePath);
if (!existsSync(dir)) {
mkdirSync(dir, { recursive: true });
}
} catch (error) {
console.error("Failed to initialize log directory:", error);
}
}
}
shouldLog(level) {
const levels = ["debug", "info", "warn", "error"];
const configuredLevel = levels.indexOf(this.options.level || "info");
const currentLevel = levels.indexOf(level);
return currentLevel >= configuredLevel;
}
formatLogEntry(entry) {
const format = this.options.format || Logger.DEFAULT_OPTIONS.format;
const timestamp = entry.timestamp.toISOString();
const level = entry.level.toUpperCase().padEnd(5);
const method = (entry.method || "").toUpperCase().padEnd(7);
const path = entry.path || "-";
const statusCode = entry.statusCode ? ` [${entry.statusCode}]` : "";
const duration = entry.duration ? `${entry.duration}` : "";
const message = entry.message || "";
const ip = entry.ip && this.options.includeIp ? ` from ${entry.ip}` : "";
return format.replace("{timestamp}", timestamp).replace("{level}", level).replace("{method}", method).replace("{path}", path).replace("{statusCode}", statusCode).replace("{duration}", duration).replace("{message}", message).replace("{ip}", ip).trim();
}
writeToFile(message) {
if (this.options.file && this.options.filePath) {
try {
appendFileSync(this.options.filePath, message + `
`);
} catch (error) {
console.error("Failed to write to log file:", error);
}
}
}
createLogEntry(level, input) {
const timestamp = new Date;
if (typeof input === "string") {
return {
timestamp,
level,
method: "",
path: "",
statusCode: 0,
duration: 0,
message: input
};
}
return {
timestamp,
level,
method: input.method || "",
path: input.path || "",
statusCode: input.statusCode || 0,
duration: input.duration || 0,
message: input.message || "",
ip: input.ip
};
}
log(level, input) {
if (!this.shouldLog(level))
return;
const entry = this.createLogEntry(level, input);
const formattedMessage = this.formatLogEntry(entry);
if (this.options.console) {
const colorize = LOG_COLORS[level] || source_default.white;
console.log(colorize(formattedMessage));
}
if (this.options.file) {
this.writeToFile(formattedMessage);
}
}
debug(input) {
this.log("debug", input);
}
info(input) {
this.log("info", input);
}
warn(input) {
this.log("warn", input);
}
error(input) {
this.log("error", input);
}
}
// node_modules/memoirist/dist/index.mjs
var createNode = (part, inert) => {
const inertMap = inert?.length ? {} : null;
if (inertMap)
for (const child of inert)
inertMap[child.part.charCodeAt(0)] = child;
return {
part,
store: null,
inert: inertMap,
params: null,
wildcardStore: null
};
};
var cloneNode = (node, part) => ({
...node,
part
});
var createParamNode = (name) => ({
name,
store: null,
inert: null
});
var Memoirist = class _Memoirist {
constructor(config = {}) {
this.config = config;
if (config.lazy)
this.find = this.lazyFind;
}
root = {};
history = [];
deferred = [];
static regex = {
static: /:.+?(?=\/|$)/,
params: /:.+?(?=\/|$)/g,
optionalParams: /:.+?\?(?=\/|$)/g
};
lazyFind = (method, url) => {
if (!this.config.lazy)
return this.find;
this.build();
return this.find(method, url);
};
build() {
if (!this.config.lazy)
return;
for (const [method, path, store] of this.deferred)
this.add(method, path, store, { lazy: false, ignoreHistory: true });
this.deferred = [];
this.find = (method, url) => {
const root = this.root[method];
if (!root)
return null;
return matchRoute(url, url.length, root, 0);
};
}
add(method, path, store, {
ignoreError = false,
ignoreHistory = false,
lazy = this.config.lazy
} = {}) {
if (lazy) {
this.find = this.lazyFind;
this.deferred.push([method, path, store]);
return store;
}
if (typeof path !== "string")
throw new TypeError("Route path must be a string");
if (path === "")
path = "/";
else if (path[0] !== "/")
path = `/${path}`;
const isWildcard = path[path.length - 1] === "*";
const optionalParams = path.match(_Memoirist.regex.optionalParams);
if (optionalParams) {
const originalPath = path.replaceAll("?", "");
this.add(method, originalPath, store, {
ignoreError,
ignoreHistory,
lazy
});
for (let i = 0;i < optionalParams.length; i++) {
let newPath = path.replace("/" + optionalParams[i], "");
this.add(method, newPath, store, {
ignoreError: true,
ignoreHistory,
lazy
});
}
return store;
}
if (optionalParams)
path = path.replaceAll("?", "");
if (this.history.find(([m, p, s]) => m === method && p === path))
return store;
if (isWildcard || optionalParams && path.charCodeAt(path.length - 1) === 63)
path = path.slice(0, -1);
if (!ignoreHistory)
this.history.push([method, path, store]);
const inertParts = path.split(_Memoirist.regex.static);
const paramParts = path.match(_Memoirist.regex.params) || [];
if (inertParts[inertParts.length - 1] === "")
inertParts.pop();
let node;
if (!this.root[method])
node = this.root[method] = createNode("/");
else
node = this.root[method];
let paramPartsIndex = 0;
for (let i = 0;i < inertParts.length; ++i) {
let part = inertParts[i];
if (i > 0) {
const param = paramParts[paramPartsIndex++].slice(1);
if (node.params === null)
node.params = createParamNode(param);
else if (node.params.name !== param) {
if (ignoreError)
return store;
else
throw new Error(`Cannot create route "${path}" with parameter "${param}" because a route already exists with a different parameter name ("${node.params.name}") in the same location`);
}
const params = node.params;
if (params.inert === null) {
node = params.inert = createNode(part);
continue;
}
node = params.inert;
}
for (let j = 0;; ) {
if (j === part.length) {
if (j < node.part.length) {
const childNode = cloneNode(node, node.part.slice(j));
Object.assign(node, createNode(part, [childNode]));
}
break;
}
if (j === node.part.length) {
if (node.inert === null)
node.inert = {};
const inert = node.inert[part.charCodeAt(j)];
if (inert) {
node = inert;
part = part.slice(j);
j = 0;
continue;
}
const childNode = createNode(part.slice(j));
node.inert[part.charCodeAt(j)] = childNode;
node = childNode;
break;
}
if (part[j] !== node.part[j]) {
const existingChild = cloneNode(node, node.part.slice(j));
const newChild = createNode(part.slice(j));
Object.assign(node, createNode(node.part.slice(0, j), [
existingChild,
newChild
]));
node = newChild;
break;
}
++j;
}
}
if (paramPartsIndex < paramParts.length) {
const param = paramParts[paramPartsIndex];
const name = param.slice(1);
if (node.params === null)
node.params = createParamNode(name);
else if (node.params.name !== name) {
if (ignoreError)
return store;
else
throw new Error(`Cannot create route "${path}" with parameter "${name}" because a route already exists with a different parameter name ("${node.params.name}") in the same location`);
}
if (node.params.store === null)
node.params.store = store;
return node.params.store;
}
if (isWildcard) {
if (node.wildcardStore === null)
node.wildcardStore = store;
return node.wildcardStore;
}
if (node.store === null)
node.store = store;
return node.store;
}
find(method, url) {
const root = this.root[method];
if (!root)
return null;
return matchRoute(url, url.length, root, 0);
}
};
var matchRoute = (url, urlLength, node, startIndex) => {
const part = node.part;
const length = part.length;
const endIndex = startIndex + length;
if (length > 1) {
if (endIndex > urlLength)
return null;
if (length < 15) {
for (let i = 1, j = startIndex + 1;i < length; ++i, ++j)
if (part.charCodeAt(i) !== url.charCodeAt(j))
return null;
} else if (url.slice(startIndex, endIndex) !== part)
return null;
}
if (endIndex === urlLength) {
if (node.store !== null)
return {
store: node.store,
params: {}
};
if (node.wildcardStore !== null)
return {
store: node.wildcardStore,
params: { "*": "" }
};
return null;
}
if (node.inert !== null) {
const inert = node.inert[url.charCodeAt(endIndex)];
if (inert !== undefined) {
const route = matchRoute(url, urlLength, inert, endIndex);
if (route !== null)
return route;
}
}
if (node.params !== null) {
const { store, name, inert } = node.params;
const slashIndex = url.indexOf("/", endIndex);
if (slashIndex !== endIndex) {
if (slashIndex === -1 || slashIndex >= urlLength) {
if (store !== null) {
const params = {};
params[name] = url.substring(endIndex, urlLength);
return {
store,
params
};
}
} else if (inert !== null) {
const route = matchRoute(url, urlLength, inert, slashIndex);
if (route !== null) {
route.params[name] = url.substring(endIndex, slashIndex);
return route;
}
}
}
}
if (node.wildcardStore !== null)
return {
store: node.wildcardStore,
params: {
"*": url.substring(endIndex, urlLength)
}
};
return null;
};
// node_modules/@sinclair/typebox/build/esm/type/guard/value.mjs
var exports_value = {};
__export(exports_value, {
IsUndefined: () => IsUndefined,
IsUint8Array: () => IsUint8Array,
IsSymbol: () => IsSymbol,
IsString: () => IsString,
IsRegExp: () => IsRegExp,
IsObject: () => IsObject,
IsNumber: () => IsNumber,
IsNull: () => IsNull,
IsIterator: () => IsIterator,
IsFunction: () => IsFunction,
IsDate: () => IsDate,
IsBoolean: () => IsBoolean,
IsBigInt: () => IsBigInt,
IsAsyncIterator: () => IsAsyncIterator,
IsArray: () => IsArray,
HasPropertyKey: () => HasPropertyKey
});
function HasPropertyKey(value, key) {
return key in value;
}
function IsAsyncIterator(value) {
return IsObject(value) && !IsArray(value) && !IsUint8Array(value) && Symbol.asyncIterator in value;
}
function IsArray(value) {
return Array.isArray(value);
}
function IsBigInt(value) {
return typeof value === "bigint";
}
function IsBoolean(value) {
return typeof value === "boolean";
}
function IsDate(value) {
return value instanceof globalThis.Date;
}
function IsFunction(value) {
return typeof value === "function";
}
function IsIterator(value) {
return IsObject(value) && !IsArray(value) && !IsUint8Array(value) && Symbol.iterator in value;
}
function IsNull(value) {
return value === null;
}
function IsNumber(value) {
return typeof value === "number";
}
function IsObject(value) {
return typeof value === "object" && value !== null;
}
function IsRegExp(value) {
return value instanceof globalThis.RegExp;
}
function IsString(value) {
return typeof value === "string";
}
function IsSymbol(value) {
return typeof value === "symbol";
}
function IsUint8Array(value) {
return value instanceof globalThis.Uint8Array;
}
function IsUndefined(value) {
return value === undefined;
}
// node_modules/@sinclair/typebox/build/esm/type/clone/value.mjs
function ArrayType(value) {
return value.map((value2) => Visit(value2));
}
function DateType(value) {
return new Date(value.getTime());
}
function Uint8ArrayType(value) {
return new Uint8Array(value);
}
function RegExpType(value) {
return new RegExp(value.source, value.flags);
}
function ObjectType(value) {
const result = {};
for (const key of Object.getOwnPropertyNames(value)) {
result[key] = Visit(value[key]);
}
for (const key of Object.getOwnPropertySymbols(value)) {
result[key] = Visit(value[key]);
}
return result;
}
function Visit(value) {
return IsArray(value) ? ArrayType(value) : IsDate(value) ? DateType(value) : IsUint8Array(value) ? Uint8ArrayType(value) : IsRegExp(value) ? RegExpType(value) : IsObject(value) ? ObjectType(value) : value;
}
function Clone(value) {
return Visit(value);
}
// node_modules/@sinclair/typebox/build/esm/type/clone/type.mjs
function CloneType(schema, options) {
return options === undefined ? Clone(schema) : Clone({ ...options, ...schema });
}
// node_modules/@sinclair/typebox/build/esm/value/guard/guard.mjs
function IsAsyncIterator2(value) {
return IsObject2(value) && globalThis.Symbol.asyncIterator in value;
}
function IsIterator2(value) {
return IsObject2(value) && globalThis.Symbol.iterator in value;
}
function IsStandardObject(value) {
return IsObject2(value) && (globalThis.Object.getPrototypeOf(value) === Object.prototype || globalThis.Object.getPrototypeOf(value) === null);
}
function IsPromise(value) {
return value instanceof globalThis.Promise;
}
function IsDate2(value) {
return value instanceof Date && globalThis.Number.isFinite(value.getTime());
}
function IsMap(value) {
return value instanceof globalThis.Map;
}
function IsSet(value) {
return value instanceof globalThis.Set;
}
function IsTypedArray(value) {
return globalThis.ArrayBuffer.isView(value);
}
function IsUint8Array2(value) {
return value instanceof globalThis.Uint8Array;
}
function HasPropertyKey2(value, key) {
return key in value;
}
function IsObject2(value) {
return value !== null && typeof value === "object";
}
function IsArray2(value) {
return globalThis.Array.isArray(value) && !globalThis.ArrayBuffer.isView(value);
}
function IsUndefined2(value) {
return value === undefined;
}
function IsNull2(value) {
return value === null;
}
function IsBoolean2(value) {
return typeof value === "boolean";
}
function IsNumber2(value) {
return typeof value === "number";
}
function IsInteger(value) {
return globalThis.Number.isInteger(value);
}
function IsBigInt2(value) {
return typeof value === "bigint";
}
function IsString2(value) {
return typeof value === "string";
}
function IsFunction2(value) {
return typeof value === "function";
}
function IsSymbol2(value) {
return typeof value === "symbol";
}
function IsValueType(value) {
return IsBigInt2(value) || IsBoolean2(value) || IsNull2(value) || IsNumber2(value) || IsString2(value) || IsSymbol2(value) || IsUndefined2(value);
}
// node_modules/@sinclair/typebox/build/esm/system/policy.mjs
var TypeSystemPolicy;
(function(TypeSystemPolicy2) {
TypeSystemPolicy2.InstanceMode = "default";
TypeSystemPolicy2.ExactOptionalPropertyTypes = false;
TypeSystemPolicy2.AllowArrayObject = false;
TypeSystemPolicy2.AllowNaN = false;
TypeSystemPolicy2.AllowNullVoid = false;
function IsExactOptionalProperty(value, key) {
return TypeSystemPolicy2.ExactOptionalPropertyTypes ? key in value : value[key] !== undefined;
}
TypeSystemPolicy2.IsExactOptionalProperty = IsExactOptionalProperty;
function IsObjectLike(value) {
const isObject = IsObject2(value);
return TypeSystemPolicy2.AllowArrayObject ? isObject : isObject && !IsArray2(value);
}
TypeSystemPolicy2.IsObjectLike = IsObjectLike;
function IsRecordLike(value) {
return IsObjectLike(value) && !(value instanceof Date) && !(value instanceof Uint8Array);
}
TypeSystemPolicy2.IsRecordLike = IsRecordLike;
function IsNumberLike(value) {
return TypeSystemPolicy2.AllowNaN ? IsNumber2(value) : Number.isFinite(value);
}
TypeSystemPolicy2.IsNumberLike = IsNumberLike;
function IsVoidLike(value) {
const isUndefined = IsUndefined2(value);
return TypeSystemPolicy2.AllowNullVoid ? isUndefined || value === null : isUndefined;
}
TypeSystemPolicy2.IsVoidLike = IsVoidLike;
})(TypeSystemPolicy || (TypeSystemPolicy = {}));
// node_modules/@sinclair/typebox/build/esm/type/create/immutable.mjs
function ImmutableArray(value) {
return globalThis.Object.freeze(value).map((value2) => Immutable(value2));
}
function ImmutableDate(value) {
return value;
}
function ImmutableUint8Array(value) {
return value;
}
function ImmutableRegExp(value) {
return value;
}
function ImmutableObject(value) {
const result = {};
for (const key of Object.getOwnPropertyNames(value)) {
result[key] = Immutable(value[key]);
}
for (const key of Object.getOwnPropertySymbols(value)) {
result[key] = Immutable(value[key]);
}
return globalThis.Object.freeze(result);
}
function Immutable(value) {
return IsArray(value) ? ImmutableArray(value) : IsDate(value) ? ImmutableDate(value) : IsUint8Array(value) ? ImmutableUint8Array(value) : IsRegExp(value) ? ImmutableRegExp(value) : IsObject(value) ? ImmutableObject(value) : value;
}
// node_modules/@sinclair/typebox/build/esm/type/create/type.mjs
function CreateType(schema, options) {
const result = options !== undefined ? { ...options, ...schema } : schema;
switch (TypeSystemPolicy.InstanceMode) {
case "freeze":
return Immutable(result);
case "clone":
return Clone(result);
default:
return result;
}
}
// node_modules/@sinclair/typebox/build/esm/type/error/error.mjs
class TypeBoxError extends Error {
constructor(message) {
super(message);
}
}
// node_modules/@sinclair/typebox/build/esm/type/symbols/symbols.mjs
var TransformKind = Symbol.for("TypeBox.Transform");
var ReadonlyKind = Symbol.for("TypeBox.Readonly");
var OptionalKind = Symbol.for("TypeBox.Optional");
var Hint = Symbol.for("TypeBox.Hint");
var Kind = Symbol.for("TypeBox.Kind");
// node_modules/@sinclair/typebox/build/esm/type/guard/kind.mjs
function IsReadonly(value) {
return IsObject(value) && value[ReadonlyKind] === "Readonly";
}
function IsOptional(value) {
return IsObject(value) && value[OptionalKind] === "Optional";
}
function IsAny(value) {
return IsKindOf(value, "Any");
}
function IsArgument(value) {
return IsKindOf(value, "Argument");
}
function IsArray3(value) {
return IsKindOf(value, "Array");
}
function IsAsyncIterator3(value) {
return IsKindOf(value, "AsyncIterator");
}
function IsBigInt3(value) {
return IsKindOf(value, "BigInt");
}
function IsBoolean3(value) {
return IsKindOf(value, "Boolean");
}
function IsComputed(value) {
return IsKindOf(value, "Computed");
}
function IsConstructor(value) {
return IsKindOf(value, "Constructor");
}
function IsDate3(value) {
return IsKindOf(value, "Date");
}
function IsFunction3(value) {
return IsKindOf(value, "Function");
}
function IsInteger2(value) {
return IsKindOf(value, "Integer");
}
function IsIntersect(value) {
return IsKindOf(value, "Intersect");
}
function IsIterator3(value) {
return IsKindOf(value, "Iterator");
}
function IsKindOf(value, kind) {
return IsObject(value) && Kind in value && value[Kind] === kind;
}
function IsLiteralValue(value) {
return IsBoolean(value) || IsNumber(value) || IsString(value);
}
function IsLiteral(value) {
return IsKindOf(value, "Literal");
}
function IsMappedKey(value) {
return IsKindOf(value, "MappedKey");
}
function IsMappedResult(value) {
return IsKindOf(value, "MappedResult");
}
function IsNever(value) {
return IsKindOf(value, "Never");
}
function IsNot(value) {
return IsKindOf(value, "Not");
}
function IsNull3(value) {
return IsKindOf(value, "Null");
}
function IsNumber3(value) {
return IsKindOf(value, "Number");
}
function IsObject3(value) {
return IsKindOf(value, "Object");
}
function IsPromise2(value) {
return IsKindOf(value, "Promise");
}
function IsRecord(value) {
return IsKindOf(value, "Record");
}
function IsRef(value) {
return IsKindOf(value, "Ref");
}
function IsRegExp2(value) {
return IsKindOf(value, "RegExp");
}
function IsString3(value) {
return IsKindOf(value, "String");
}
function IsSymbol3(value) {
return IsKindOf(value, "Symbol");
}
function IsTemplateLiteral(value) {
return IsKindOf(value, "TemplateLiteral");
}
function IsThis(value) {
return IsKindOf(value, "This");
}
function IsTransform(value) {
return IsObject(value) && TransformKind in value;
}
function IsTuple(value) {
return IsKindOf(value, "Tuple");
}
function IsUndefined3(value) {
return IsKindOf(value, "Undefined");
}
function IsUnion(value) {
return IsKindOf(value, "Union");
}
function IsUint8Array3(value) {
return IsKindOf(value, "Uint8Array");
}
function IsUnknown(value) {
return IsKindOf(value, "Unknown");
}
function IsUnsafe(value) {
return IsKindOf(value, "Unsafe");
}
function IsVoid(value) {
return IsKindOf(value, "Void");
}
function IsKind(value) {
return IsObject(value) && Kind in value && IsString(value[Kind]);
}
function IsSchema(value) {
return IsAny(value) || IsArgument(value) || IsArray3(value) || IsBoolean3(value) || IsBigInt3(value) || IsAsyncIterator3(value) || IsComputed(value) || IsConstructor(value) || IsDate3(value) || IsFunction3(value) || IsInteger2(value) || IsIntersect(value) || IsIterator3(value) || IsLiteral(value) || IsMappedKey(value) || IsMappedResult(value) || IsNever(value) || IsNot(value) || IsNull3(value) || IsNumber3(value) || IsObject3(value) || IsPromise2(value) || IsRecord(value) || IsRef(value) || IsRegExp2(value) || IsString3(value) || IsSymbol3(value) || IsTemplateLiteral(value) || IsThis(value) || IsTuple(value) || IsUndefined3(value) || IsUnion(value) || IsUint8Array3(value) || IsUnknown(value) || IsUnsafe(value) || IsVoid(value) || IsKind(value);
}
// node_modules/@sinclair/typebox/build/esm/type/guard/type.mjs
var exports_type = {};
__export(exports_type, {
TypeGuardUnknownTypeError: () => TypeGuardUnknownTypeError,
IsVoid: () => IsVoid2,
IsUnsafe: () => IsUnsafe2,
IsUnknown: () => IsUnknown2,
IsUnionLiteral: () => IsUnionLiteral,
IsUnion: () => IsUnion2,
IsUndefined: () => IsUndefined4,
IsUint8Array: () => IsUint8Array4,
IsTuple: () => IsTuple2,
IsTransform: () => IsTransform2,
IsThis: () => IsThis2,
IsTemplateLiteral: () => IsTemplateLiteral2,
IsSymbol: () => IsSymbol4,
IsString: () => IsString4,
IsSchema: () => IsSchema2,
IsRegExp: () => IsRegExp3,
IsRef: () => IsRef2,
IsRecursive: () => IsRecursive,
IsRecord: () => IsRecord2,
IsReadonly: () => IsReadonly2,
IsProperties: () => IsProperties,
IsPromise: () => IsPromise3,
IsOptional: () => IsOptional2,
IsObject: () => IsObject4,
IsNumber: () => IsNumber4,
IsNull: () => IsNull4,
IsNot: () => IsNot2,
IsNever: () => IsNever2,
IsMappedResult: () => IsMappedResult2,
IsMappedKey: () => IsMappedKey2,
IsLiteralValue: () => IsLiteralValue2,
IsLiteralString: () => IsLiteralString,
IsLiteralNumber: () => IsLiteralNumber,
IsLiteralBoolean: () => IsLiteralBoolean,
IsLiteral: () => IsLiteral2,
IsKindOf: () => IsKindOf2,
IsKind: () => IsKind2,
IsIterator: () => IsIterator4,
IsIntersect: () => IsIntersect2,
IsInteger: () => IsInteger3,
IsImport: () => IsImport,
IsFunction: () => IsFunction4,
IsDate: () => IsDate4,
IsConstructor: () => IsConstructor2,
IsComputed: () => IsComputed2,
IsBoolean: () => IsBoolean4,
IsBigInt: () => IsBigInt4,
IsAsyncIterator: () => IsAsyncIterator4,
IsArray: () => IsArray4,
IsArgument: () => IsArgument2,
IsAny: () => IsAny2
});
class TypeGuardUnknownTypeError extends TypeBoxError {
}
var KnownTypes = [
"Argument",
"Any",
"Array",
"AsyncIterator",
"BigInt",
"Boolean",
"Computed",
"Constructor",
"Date",
"Enum",
"Function",
"Integer",
"Intersect",
"Iterator",
"Literal",
"MappedKey",
"MappedResult",
"Not",
"Null",
"Number",
"Object",
"Promise",
"Record",
"Ref",
"RegExp",
"String",
"Symbol",
"TemplateLiteral",
"This",
"Tuple",
"Undefined",
"Union",
"Uint8Array",
"Unknown",
"Void"
];
function IsPattern(value) {
try {
new RegExp(value);
return true;
} catch {
return false;
}
}
function IsControlCharacterFree(value) {
if (!IsString(value))
return false;
for (let i = 0;i < value.length; i++) {
const code = value.charCodeAt(i);
if (code >= 7 && code <= 13 || code === 27 || code === 127) {
return false;
}
}
return true;
}
function IsAdditionalProperties(value) {
return IsOptionalBoolean(value) || IsSchema2(value);
}
function IsOptionalBigInt(value) {
return IsUndefined(value) || IsBigInt(value);
}
function IsOptionalNumber(value) {
return IsUndefined(value) || IsNumber(value);
}
function IsOptionalBoolean(value) {
return IsUndefined(value) || IsBoolean(value);
}
function IsOptionalString(value) {
return IsUndefined(value) || IsString(value);
}
function IsOptionalPattern(value) {
return IsUndefined(value) || IsString(value) && IsControlCharacterFree(value) && IsPattern(value);
}
function IsOptionalFormat(value) {
return IsUndefined(value) || IsString(value) && IsControlCharacterFree(value);
}
function IsOptionalSchema(value) {
return IsUndefined(value) || IsSchema2(value);
}
function IsReadonly2(value) {
return IsObject(value) && value[ReadonlyKind] === "Readonly";
}
function IsOptional2(value) {
return IsObject(value) && value[OptionalKind] === "Optional";
}
function IsAny2(value) {
return IsKindOf2(value, "Any") && IsOptionalString(value.$id);
}
function IsArgument2(value) {
return IsKindOf2(value, "Argument") && IsNumber(value.index);
}
function IsArray4(value) {
return IsKindOf2(value, "Array") && value.type === "array" && IsOptionalString(value.$id) && IsSchema2(value.items) && IsOptionalNumber(value.minItems) && IsOptionalNumber(value.maxItems) && IsOptionalBoolean(value.uniqueItems) && IsOptionalSchema(value.contains) && IsOptionalNumber(value.minContains) && IsOptionalNumber(value.maxContains);
}
function IsAsyncIterator4(value) {
return IsKindOf2(value, "AsyncIterator") && value.type === "AsyncIterator" && IsOptionalString(value.$id) && IsSchema2(value.items);
}
function IsBigInt4(value) {
return IsKindOf2(value, "BigInt") && value.type === "bigint" && IsOptionalString(value.$id) && IsOptionalBigInt(value.exclusiveMaximum) && IsOptionalBigInt(value.exclusiveMinimum) && IsOptionalBigInt(value.maximum) && IsOptionalBigInt(value.minimum) && IsOptionalBigInt(value.multipleOf);
}
function IsBoolean4(value) {
return IsKindOf2(value, "Boolean") && value.type === "boolean" && IsOptionalString(value.$id);
}
function IsComputed2(value) {
return IsKindOf2(value, "Computed") && IsString(value.target) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema));
}
function IsConstructor2(value) {
return IsKindOf2(value, "Constructor") && value.type === "Constructor" && IsOptionalString(value.$id) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema)) && IsSchema2(value.returns);
}
function IsDate4(value) {
return IsKindOf2(value, "Date") && value.type === "Date" && IsOptionalString(value.$id) && IsOptionalNumber(value.exclusiveMaximumTimestamp) && IsOptionalNumber(value.exclusiveMinimumTimestamp) && IsOptionalNumber(value.maximumTimestamp) && IsOptionalNumber(value.minimumTimestamp) && IsOptionalNumber(value.multipleOfTimestamp);
}
function IsFunction4(value) {
return IsKindOf2(value, "Function") && value.type === "Function" && IsOptionalString(value.$id) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema)) && IsSchema2(value.returns);
}
function IsImport(value) {
return IsKindOf2(value, "Import") && HasPropertyKey(value, "$defs") && IsObject(value.$defs) && IsProperties(value.$defs) && HasPropertyKey(value, "$ref") && IsString(value.$ref) && value.$ref in value.$defs;
}
function IsInteger3(value) {
return IsKindOf2(value, "Integer") && value.type === "integer" && IsOptionalString(value.$id) && IsOptionalNumber(value.exclusiveMaximum) && IsOptionalNumber(value.exclusiveMinimum) && IsOptionalNumber(value.maximum) && IsOptionalNumber(value.minimum) && IsOptionalNumber(value.multipleOf);
}
function IsProperties(value) {
return IsObject(value) && Object.entries(value).every(([key, schema]) => IsControlCharacterFree(key) && IsSchema2(schema));
}
function IsIntersect2(value) {
return IsKindOf2(value, "Intersect") && (IsString(value.type) && value.type !== "object" ? false : true) && IsArray(value.allOf) && value.allOf.every((schema) => IsSchema2(schema) && !IsTransform2(schema)) && IsOptionalString(value.type) && (IsOptionalBoolean(value.uneval